mirror of
https://github.com/danbulant/jose
synced 2026-05-23 06:18:58 +00:00
24 lines
724 B
JavaScript
24 lines
724 B
JavaScript
/* eslint-disable no-param-reassign */
|
|
import test from 'ava';
|
|
|
|
const root = !('WEBCRYPTO' in process.env) ? '#dist' : '#dist/webcrypto';
|
|
import(`${root}/jwe/compact/decrypt`).then(
|
|
({ default: flattenedDecrypt }) => {
|
|
test('JWE format validation', async (t) => {
|
|
await t.throwsAsync(flattenedDecrypt(null, new Uint8Array(0)), {
|
|
message: 'Compact JWE must be a string or Uint8Array',
|
|
code: 'ERR_JWE_INVALID',
|
|
});
|
|
await t.throwsAsync(flattenedDecrypt('...', new Uint8Array(0)), {
|
|
message: 'Invalid Compact JWE',
|
|
code: 'ERR_JWE_INVALID',
|
|
});
|
|
});
|
|
},
|
|
(err) => {
|
|
test('failed to import', (t) => {
|
|
console.error(err);
|
|
t.fail();
|
|
});
|
|
},
|
|
);
|