Skip to content

jonathansamines/chance-access-token

Repository files navigation

chance-access-token

npm Build Status

A simple chance mixin which generates a random access token

Installation

npm install --save chance-access-token

Usage

const Chance = require('chance');
const accessToken = require('chance-access-token');

const chance = new Chance();

chance.mixin({ accessToken });

const expiredAccessToken = chance.accessToken({
  expireMode: 'expires_at',
  expired: true,
});

// =>
// {
//   token_type: 'bearer',
//   access_token: '89D690FF-C19D-4F0E-B8E2-B1EBB3F26B0B',
//   refresh_token: '8B4361C2-4E90-4E00-B825-48C0D82F7B93',
//   expires_at: '',
// }

API

chance.accessToken(options)

  • options
    • expireMode - Can be either expires_at or expires_in. When set to expires_at it generates a token which expires at a random date. When set to expires_in it generates a token which expires in a random number of seconds.
    • dateFormat - Used when expireMode is expires_at to determine the format of the expires_at field. Can be date to generate a date object, unix to generate a UNIX timestamp in seconds since epoch or iso to generate an ISO formatted string.
    • expired - When is true and expireMode is expires_at it generates a date in the past

About

A simple chance.js mixin to generate random access tokens

Resources

Stars

Watchers

Forks

Packages

No packages published