jose/test-browser/jwks.js
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

18 lines
620 B
JavaScript

import createRemoteJWKSet from '../dist/browser/jwks/remote';
const jwksUri = 'https://www.googleapis.com/oauth2/v3/certs';
QUnit.test('fetches the JWKSet', async (assert) => {
const response = await fetch(jwksUri).then((r) => r.json());
const { alg, kid } = response.keys[0];
const jwks = createRemoteJWKSet(new URL(jwksUri));
await assert.rejects(
jwks({ alg: 'RS256' }),
'multiple matching keys found in the JSON Web Key Set',
);
await assert.rejects(
jwks({ kid: 'foo', alg: 'RS256' }),
'no applicable key found in the JSON Web Key Set',
);
assert.ok(await jwks({ alg, kid }));
});