1.2.0 • Published 7 months ago

@storyous/identity v1.2.0

Weekly downloads
-
License
ISC
Repository
github
Last release
7 months ago

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

7 months ago

1.1.0

7 months ago

1.0.9

7 months ago

1.0.8

7 months ago

1.0.7

7 months ago

1.1.2

7 months ago

1.0.6-beta.1

7 months ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago