From b9cee65be08ad5f53119ce3420fa8c16f2673fdf Mon Sep 17 00:00:00 2001 From: David Date: Fri, 25 Jun 2021 14:55:41 -0700 Subject: [PATCH 1/2] [SDK-2626] getKeysInterceptor types getKeysInterceptor keys supplied are not quite not known yet, alg+kid should be specified, but further strictness is not needed --- index.d.ts | 8 +++++++- tests/ts-definitions.tests.ts | 21 +++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 422f9d3a..a76565cc 100644 --- a/index.d.ts +++ b/index.d.ts @@ -30,7 +30,13 @@ declare namespace JwksRsa { timeout?: number; requestAgent?: HttpAgent | HttpsAgent; fetcher?(jwksUri: string): Promise<{ keys: any }>; - getKeysInterceptor?(): Promise; + getKeysInterceptor?(): Promise; + } + + interface UnknownKey { + kid: string, + alg: string, + [key: string]: any } interface CertSigningKey { diff --git a/tests/ts-definitions.tests.ts b/tests/ts-definitions.tests.ts index 0cf0401f..9d5adc33 100644 --- a/tests/ts-definitions.tests.ts +++ b/tests/ts-definitions.tests.ts @@ -23,4 +23,25 @@ describe('typescript definition', () => { expect(key).to.contain('-----BEGIN PUBLIC KEY'); }); }); + + describe('getKeysInterceptor', async () => { + const keySetResponse = { + keys: [ + { + alg: 'RS256', + kty: 'RSA', + use: 'sig', + kid: 'NkFCNEE1NDFDNTQ5RTQ5OTE1QzRBMjYyMzY0NEJCQTJBMjJBQkZCMA' + } + ] + }; + + const client = new jwksRsa.JwksClient({ + jwksUri: `${jwksHost}/.well-known/jwks.json`, + getKeysInterceptor: () => Promise.resolve(keySetResponse.keys) + }); + + const key = await client.getSigningKey('NkFCNEE1NDFDNTQ5RTQ5OTE1QzRBMjYyMzY0NEJCQTJBMjJBQkZCMA'); + expect(key.kid).to.equal('NkFCNEE1NDFDNTQ5RTQ5OTE1QzRBMjYyMzY0NEJCQTJBMjJBQkZCMA'); + }); }); From 45575a6f96e55d628ff187d0307cc47431b46b88 Mon Sep 17 00:00:00 2001 From: adamjmcgrath Date: Thu, 15 Jul 2021 16:45:16 +0100 Subject: [PATCH 2/2] Rename to JSONWebKey --- index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.d.ts b/index.d.ts index a76565cc..99516afa 100644 --- a/index.d.ts +++ b/index.d.ts @@ -30,13 +30,13 @@ declare namespace JwksRsa { timeout?: number; requestAgent?: HttpAgent | HttpsAgent; fetcher?(jwksUri: string): Promise<{ keys: any }>; - getKeysInterceptor?(): Promise; + getKeysInterceptor?(): Promise; } - interface UnknownKey { + interface JSONWebKey { kid: string, alg: string, - [key: string]: any + [key: string]: any } interface CertSigningKey {