@tspacejs/tokens
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

@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

Readme

Keywords

none

Package Sidebar

Install

npm i @tspacejs/tokens

Weekly Downloads

0

Version

1.0.2

License

MIT

Unpacked Size

60.7 kB

Total Files

39

Last publish

Collaborators

  • codeiqne