@storyous/identity
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

identity

Usage of PermissionHelper

import { permissionHelper } from '@storyous/identity';

// encode
const rawPermission = [true, true, true, false, false, true];
const response = permissionHelper.encodeData(rawPermission);

...

// decode
const encodedPermission = 'e4';
const response = permissionHelper.decodeData(encodedPermission);

Usage of JwtPermissions

import { jwtPermissions } from '@storyous/identity';
import Router from 'koa-router';


// Validate JWT and permissions for specific route
router = new Router();
router.get(
    '/',
    jwtPermissions.validateJwtTokenMiddleware('https://example.com/getPublicKey'),
    jwtPermissions.checkPermissionsMiddleWare([8, 9]),
    (ctx: any) => {
        ctx.body = {status: 'ok'};
        ctx.status = 200;
    },
);

// Authorize User
const jwtFromUser = 'someToken';
await jwtPermissions.authorizeUser(
    jwtFromUser,
    {
        merchantId: '123,
        publicKeyUrl: 'https://example.com/getPublicKey',
        placeId: '1',
        deviceId: '2'
        permissions: [8, 9],
    }
);

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.2.025latest
1.0.6-beta.10beta

Version History

VersionDownloads (Last 7 Days)Published
1.2.025
1.1.20
1.1.00
1.0.90
1.0.80
1.0.70
1.0.6-beta.10
1.0.60
1.0.50
1.0.43
1.0.20
1.0.10
1.0.00

Package Sidebar

Install

npm i @storyous/identity

Weekly Downloads

0

Version

1.2.0

License

ISC

Unpacked Size

89.7 kB

Total Files

70

Last publish

Collaborators

  • danieldadateya
  • nte-saltpay
  • mkoubik
  • storyous-user
  • vaclav.obornik
  • tymak
  • ivo.sofranek