From e086fc66464b71e9f95df74fecefc16d41b7b96a Mon Sep 17 00:00:00 2001 From: Tom Spencer Date: Tue, 3 Mar 2020 14:20:54 +0000 Subject: [PATCH] fix(typescript): adapter methods typings and interface name typo Fixes the omission of `consumed` from an AdapterPayload and fixes a typo in the `AsymmetricSigningAlgoritm` interface (`AsymmetricSigningAlgorithm`). --- package.json | 3 ++- types/index.d.ts | 11 ++++++----- types/oidc-provider-tests.ts | 16 +++++++++++----- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 12c63909b..7d1239479 100644 --- a/package.json +++ b/package.json @@ -91,7 +91,8 @@ "paseto": "^1.0.5", "sinon": "^9.0.0", "supertest": "^4.0.2", - "timekeeper": "^2.2.0" + "timekeeper": "^2.2.0", + "typescript": "^3.8.3" }, "engines": { "node": "^10.13.0 || >=12.0.0" diff --git a/types/index.d.ts b/types/index.d.ts index d87c31227..e476bf415 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -749,6 +749,7 @@ export interface AdapterPayload { clientId?: string; codeChallenge?: string; codeChallengeMethod?: string; + consumed?: any; deviceInfo?: AnyObject; error?: string; errorDescription?: string; @@ -1007,7 +1008,7 @@ export interface Configuration { formats?: { AccessToken?: AccessTokenFormatFunction | TokenFormat; ClientCredentials?: ClientCredentialsFormatFunction | TokenFormat; - jwtAccessTokenSigningAlg?: (ctx: KoaContextWithOIDC, token: AccessToken | ClientCredentials, client: Client) => CanBePromise; + jwtAccessTokenSigningAlg?: (ctx: KoaContextWithOIDC, token: AccessToken | ClientCredentials, client: Client) => CanBePromise; customizers?: { jwt?: (ctx: KoaContextWithOIDC, token: AccessToken | ClientCredentials, parts: JWTStructured) => Promise | JWTStructured; 'jwt-ietf'?: (ctx: KoaContextWithOIDC, token: AccessToken | ClientCredentials, parts: JWTStructured) => Promise | JWTStructured; @@ -1099,7 +1100,7 @@ export interface Configuration { authorizationEncryptionAlgValues?: EncryptionAlgValues[]; authorizationEncryptionEncValues?: EncryptionEncValues[]; authorizationSigningAlgValues?: SigningAlgorithm[]; - dPoPSigningAlgValues?: AsymmetricSigningAlgoritm[]; + dPoPSigningAlgValues?: AsymmetricSigningAlgorithm[]; idTokenEncryptionAlgValues?: EncryptionAlgValues[]; idTokenEncryptionEncValues?: EncryptionEncValues[]; idTokenSigningAlgValues?: SigningAlgorithmWithNone[]; @@ -1119,10 +1120,10 @@ export interface Configuration { } export type NoneAlg = 'none'; -export type AsymmetricSigningAlgoritm = 'PS256' | 'PS384' | 'PS512' | 'ES256' | 'ES256K' | 'ES384' | 'ES512' | 'EdDSA' | 'RS256' | 'RS384' | 'RS512'; +export type AsymmetricSigningAlgorithm = 'PS256' | 'PS384' | 'PS512' | 'ES256' | 'ES256K' | 'ES384' | 'ES512' | 'EdDSA' | 'RS256' | 'RS384' | 'RS512'; export type SymmetricSigningAlgorithm = 'HS256' | 'HS384' | 'HS512'; -export type SigningAlgorithm = AsymmetricSigningAlgoritm | SymmetricSigningAlgorithm; -export type SigningAlgorithmWithNone = AsymmetricSigningAlgoritm | SymmetricSigningAlgorithm | NoneAlg; +export type SigningAlgorithm = AsymmetricSigningAlgorithm | SymmetricSigningAlgorithm; +export type SigningAlgorithmWithNone = AsymmetricSigningAlgorithm | SymmetricSigningAlgorithm | NoneAlg; export type EncryptionAlgValues = 'RSA-OAEP' | 'RSA-OAEP-256' | 'RSA-OAEP-384' | 'RSA-OAEP-512' | 'RSA1_5' | 'ECDH-ES' | 'ECDH-ES+A128KW' | 'ECDH-ES+A192KW' | 'ECDH-ES+A256KW' | 'A128KW' | 'A192KW' | 'A256KW' | 'A128GCMKW' | 'A192GCMKW' | 'A256GCMKW' | 'PBES2-HS256+A128KW' | 'PBES2-HS384+A192KW' | diff --git a/types/oidc-provider-tests.ts b/types/oidc-provider-tests.ts index 1d251ff59..df7eb7db6 100644 --- a/types/oidc-provider-tests.ts +++ b/types/oidc-provider-tests.ts @@ -1,5 +1,5 @@ // tslint:disable-next-line:no-relative-import-in-test -import { Provider, interactionPolicy, AsymmetricSigningAlgoritm } from './index.d'; +import { Provider, interactionPolicy, AsymmetricSigningAlgorithm } from './index.d'; new Provider('https://op.example.com'); @@ -52,13 +52,19 @@ const provider = new Provider('https://op.example.com', { async revokeByGrantId(grantId: string) {} async find(id: string) { - return {}; + return { + consumed: false + }; } async findByUserCode(userCode: string) { - return {}; + return { + consumed: false + }; } async findByUid(uid: string) { - return {}; + return { + consumed: false + }; } }, claims: { @@ -122,7 +128,7 @@ const provider = new Provider('https://op.example.com', { clientCredentials.iat.toFixed(); return 'opaque'; }, - async jwtAccessTokenSigningAlg(ctx, token, client): Promise { + async jwtAccessTokenSigningAlg(ctx, token, client): Promise { ctx.oidc.issuer.substring(0); token.iat.toFixed(); client.clientId.substring(0);