1.0.2 • Published 6 months ago

@tspacejs/tokens v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

@tspacejs/tokens

simple package for scoped API tokens

install

using npm:

$ npm i --save @tspacejs/tokens

or using yarn:

$ yarn add @tspacejs/tokens

usage

import tokens as t from '@tspacejs/tokens';
const tokens = t.Tokens(<typeorm datasource >, {privateKey: 'shhhh'});

const expiration = new Date();
expiration.setDate(expiration.getDate() + 90); // 90 days
const token = tokens.createScopedToken({accountId: 123}, ['posts:write'], expiration, "this is an API token");
// -----------------------------------
await tokens.guard("<token>", ["posts:write"]);
// -----------------------------------
await token.revoke();

better docs coming soon

1.0.2

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago