@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],
    }
);

Readme

Keywords

none

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