jose/test/jws/compact.verify.test.mjs
Filip Skokan 357fe0b964 feat: Revised API, No dependencies, Browser Support, Promises
BREAKING CHANGE: Revised, Promise-based API
BREAKING CHANGE: No dependencies
BREAKING CHANGE: Browser support (using [Web Cryptography API](https://www.w3.org/TR/WebCryptoAPI/))
BREAKING CHANGE: Support for verification using a remote JWKS endpoint
BREAKING CHANGE: Experimental Node.js libuv thread pool based runtime (non-blocking 🎉)
2020-11-14 18:26:46 +01:00

24 lines
706 B
JavaScript

/* eslint-disable no-param-reassign */
import test from 'ava';
const root = !('WEBCRYPTO' in process.env) ? '#dist' : '#dist/webcrypto';
import(`${root}/jws/compact/verify`).then(
({ default: flattenedVerify }) => {
test('JWS format validation', async (t) => {
await t.throwsAsync(flattenedVerify(null, new Uint8Array()), {
message: 'Compact JWS must be a string',
code: 'ERR_JWS_INVALID',
});
await t.throwsAsync(flattenedVerify('.....', new Uint8Array()), {
message: 'Invalid Compact JWS',
code: 'ERR_JWS_INVALID',
});
});
},
(err) => {
test('failed to import', (t) => {
console.error(err);
t.fail();
});
},
);