mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-11-13 03:35:52 +01:00
ddb6a22396
* feat: signature package * feat: signature package
24 lines
709 B
TypeScript
24 lines
709 B
TypeScript
import {
|
|
aesDecryptDeprecated,
|
|
aesEncryptDeprecated,
|
|
generateRandomSecretKeyDeprecated,
|
|
} from '../src';
|
|
|
|
describe('test deprecated crypto utils', () => {
|
|
test('decrypt payload flow', () => {
|
|
const secret = generateRandomSecretKeyDeprecated();
|
|
const payload = 'juan:password';
|
|
const token = aesEncryptDeprecated(Buffer.from(payload), secret);
|
|
const data = aesDecryptDeprecated(token, secret);
|
|
|
|
expect(data.toString()).toEqual(payload.toString());
|
|
});
|
|
|
|
test('crypt fails if secret is incorrect', () => {
|
|
const payload = 'juan:password';
|
|
expect(aesEncryptDeprecated(Buffer.from(payload), 'fake_token').toString()).not.toEqual(
|
|
Buffer.from(payload)
|
|
);
|
|
});
|
|
});
|