npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mapkitjs-token-tool

v1.0.1

Published

pixelcation

Downloads

9

Readme

MapKit JS Token Generator

Generate long-lived tokens from the CLI that can be used with the MapKit JS's authorizationCallback.

Setting authorizationCallback to a function that returns a token as a string is useful for local development, or if you want to use a long-lived token with MapKit JS. Sign a token locally on your development machine with an expiration, then use the token directly in your code.

mapkit.init({
   authorizationCallback(done) {
       done('your-generated-token-string-here');
   },
});

Features

  • Verifies if the token works against MapKit servers

Usage

$ npx mapkitjs-token [options]

Since we're dealing with private keys, you may feel safer compiling this tool yourself and running it locally (see Compiling).

Options

Options:
  --help     Show help                                                 [boolean]
  --version  Show version number                                       [boolean]
  --kid      A 10-character key identifier (kid) key, obtained from your Apple
             Developer account                               [string] [required]
  --iss      The Issuer (iss) registered claim key. This key's value is your
             10-character Team ID, obtained from your developer account.
                                                             [string] [required]
  --iat      The Issued At (iat), relative to now. Uses `zeit/ms` strings (e.g
             '0', '2d', '1y')
                  [string] [default: 0, current time (e.g 0 seconds from "now")]
  --exp      The Expiration Time (exp) relative to `iat`, using a `zeit/ms`
             string (e.g '1hr, '2d', '1y').
                                    [string] [default: 364d, 364 day expiration]
  --key      MapKit private key file path                             [required]
  --origin   The Origin (origin) key. This key's value is a fully qualified
             domain that should match the Origin header passed by a browser.
                                                                        [string]
  --verify   Test the generated token with MapKit servers to verify if valid
                 [boolean] [default: true, will verify token after it generates]
  --stdout   Set to true to output only the token, suitable for piping
      [boolean] [default: false, by default, outputs extra data about the token]

See the MapKit JS documentation for the full explanation of these options.

Examples

Generate a token with the default expiration (1 hour) and verify the token works:

$ npx mapkitjs-token --kid ABC123DEFG --iss DEF123GHIJ --key ./secret.p8

Token Information:
Key Id (kid)  ABC123DEFG
Issuer (iss)  DEF123GHIJ
Issued (iat)  1583626697 (Sat Mar 07 2020 16:18:17 GMT-0800 (Pacific Standard Time))
Expire (exp)  1583630297 (Sat Mar 07 2020 17:18:17 GMT-0800 (Pacific Standard Time))
Expires In    1 hour (3600s)
Origin        none
Valid         valid
Token         [generated token]

Generate a token with a 10 year expiration, verify, and copy directly to clipboard (macOS via pbcopy):

$ npx mapkitjs-token --kid ABC123DEFG --iss DEF123GHIJ --key ./secret.p8  --exp 10y --stdout | pbcopy 

Generate a token with a 8 year expiration, add an origin, and skip verification:

$ npx mapkitjs-token --kid ABC123DEFG --iss DEF123GHIJ --key ./secret.p8 --exp=8y --origin https://mywebsite.org --verify=false

Token Information:
Key Id (kid)  ABC123DEFG
Issuer (iss)  DEF123GHIJ
Issued (iat)  1583627770 (Sat Mar 07 2020 16:36:10 GMT-0800 (Pacific Standard Time))
Expire (exp)  1836088570 (Tue Mar 07 2028 16:36:10 GMT-0800 (Pacific Standard Time))
Expires In    2922 days (252460800s)
Origin        https://mywebsite.org
Valid         skipped
Token         [generated token]

Compiling

$ npm ci
$ npm run build
$ node ./dist/cli.js [options]