@mapbox/parse-mapbox-token

0.2.0 • Public • Published

@mapbox/parse-mapbox-token

Build Status

Parse a Mapbox API token, in any JS environment, including Node, browser, and React Native.

Learn about Mapbox API tokens by reading Mapbox's API documentation.

Installation

npm install @mapbox/parse-mapbox-token

Usage

var parseToken = require('@mapbox/parse-mapbox-token');
var parsed = parseToken('MY_MAPBOX_TOKEN');
var ownerId = parsed.user;

Returns an object representing the parsed token. Properties vary depending on the type of token (public, secret, or temporary).

The following properties will always be present:

  • usage: pk, sk, or tk (public, secret, or temporary).
  • user: The ID of the token's owner.

The following properties may or may not be present:

  • authorization: Authorization associated with the owner's account.
  • created: Timestamp for the creation time of the token.
  • expires: Timestamp for the expiration time of the token.
  • lastLogin: Timestamp of the owner's last verified login.
  • scopes: Array of scopes available to the token.
  • client: OAuth client for which the token was granted.
  • impersonator: ID of the user impersonating the account owner.

The token's payload is parsed with base-64.

Readme

Keywords

Package Sidebar

Install

npm i @mapbox/parse-mapbox-token

Weekly Downloads

141,322

Version

0.2.0

License

BSD-2-Clause

Unpacked Size

9.52 kB

Total Files

11

Last publish

Collaborators

  • mbx-npm-ci-production
  • mbx-npm-ci-staging
  • mbx-npm-advanced-actions-production
  • mbx-npm-advanced-actions-staging
  • mbx-npm-09-production
  • mbx-npm-08-production
  • mbx-npm-07-production
  • mbx-npm-06-production
  • mbx-npm-05-production
  • mbx-npm-04-production
  • mbx-npm-03-production
  • mbx-npm-02-production
  • mbx-npm-01-production
  • mbx-npm-02-staging
  • mapbox-npm-01
  • mapbox-npm-02
  • mapbox-npm-07
  • mapbox-npm-03
  • mapbox-npm-04
  • mapbox-npm-09
  • mapbox-npm-05
  • mapbox-npm-06
  • mapbox-npm-08
  • mapbox-npm-advanced-actions
  • mapbox-npm-ci
  • mapbox-npm
  • mapbox-admin
  • mapbox-machine-user