0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-30 22:34:10 -05:00
verdaccio/packages/signature/test/legacy-token.spec.ts
Juan Picado ddb6a22396
feat: signature package (#3653)
* feat: signature package

* feat: signature package
2023-02-26 13:19:22 +01:00

19 lines
609 B
TypeScript

import { aesDecrypt, aesEncrypt } from '../src';
describe('test crypto utils', () => {
test('decrypt payload flow', () => {
const secret = 'f5bb945cc57fea2f25961e1bd6fb3c89';
const payload = 'juan:password';
const token = aesEncrypt(payload, secret) as string;
const data = aesDecrypt(token, secret);
expect(payload).toEqual(data);
});
test('crypt fails if secret is incorrect', () => {
const secret = 'f5bb945cc57fea2f25961e1bd6fb3c89_TO_LONG';
const payload = 'juan';
const token = aesEncrypt(payload, secret) as string;
expect(token).toBeUndefined();
});
});