From 1a54e6966da62e4796640dd73393fd0fdc5c76b4 Mon Sep 17 00:00:00 2001 From: Martin Auer Date: Mon, 29 Jul 2024 15:35:16 +0200 Subject: [PATCH] fix: nits Signed-off-by: Martin Auer --- packages/common/lib/jwt/Jwt.types.ts | 2 +- packages/common/lib/jwt/JwtVerifier.ts | 6 +++--- packages/siop-oid4vp/lib/types/VpJwtVerifier.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/common/lib/jwt/Jwt.types.ts b/packages/common/lib/jwt/Jwt.types.ts index 1b2f3b90..19fb4398 100644 --- a/packages/common/lib/jwt/Jwt.types.ts +++ b/packages/common/lib/jwt/Jwt.types.ts @@ -5,7 +5,7 @@ export type JwtHeader = jwtDecodeJwtHeader & { alg?: string; x5c?: string[]; kid?: string; - jwk?: JWK; + jwk?: JWK & { kty: string }; jwt?: string; } & Record; diff --git a/packages/common/lib/jwt/JwtVerifier.ts b/packages/common/lib/jwt/JwtVerifier.ts index 690f092e..ec446987 100644 --- a/packages/common/lib/jwt/JwtVerifier.ts +++ b/packages/common/lib/jwt/JwtVerifier.ts @@ -63,7 +63,7 @@ export const getDidJwtVerifier = (jwt: { header: JwtHeader; payload: JwtPayload if (!jwt.header.kid.includes('#')) { throw new Error(`Received an invalid JWT.. '${type}' contains an invalid kid header.`); } - return { method: 'did', didUrl: jwt.header.kid, type: type, alg: jwt.header.alg as SigningAlgo }; + return { method: 'did', didUrl: jwt.header.kid, type: type, alg: jwt.header.alg }; }; export const getX5cVerifier = (jwt: { header: JwtHeader; payload: JwtPayload }, options: { type: JwtType }): X5cJwtVerifier => { @@ -79,7 +79,7 @@ export const getX5cVerifier = (jwt: { header: JwtHeader; payload: JwtPayload }, throw new Error(`Received an invalid JWT. '${type}' contains an invalid iss claim.`); } - return { method: 'x5c', x5c: jwt.header.x5c, issuer: jwt.payload.iss, type: type, alg: jwt.header.alg as SigningAlgo }; + return { method: 'x5c', x5c: jwt.header.x5c, issuer: jwt.payload.iss, type: type, alg: jwt.header.alg }; }; export const getJwkVerifier = async (jwt: { header: JwtHeader; payload: JwtPayload }, options: { type: JwtType }): Promise => { @@ -91,7 +91,7 @@ export const getJwkVerifier = async (jwt: { header: JwtHeader; payload: JwtPaylo throw new Error(`Received an invalid JWT. '${type}' contains an invalid jwk header.`); } - return { method: 'jwk', type, jwk: jwt.header.jwk, alg: jwt.header.alg as SigningAlgo }; + return { method: 'jwk', type, jwk: jwt.header.jwk, alg: jwt.header.alg }; }; export const getJwtVerifierWithContext = async ( diff --git a/packages/siop-oid4vp/lib/types/VpJwtVerifier.ts b/packages/siop-oid4vp/lib/types/VpJwtVerifier.ts index 8d8781cd..4fb055a0 100644 --- a/packages/siop-oid4vp/lib/types/VpJwtVerifier.ts +++ b/packages/siop-oid4vp/lib/types/VpJwtVerifier.ts @@ -145,7 +145,7 @@ export const getRequestObjectJwtVerifier = async ( } // The iss claim value of the Verifier Attestation JWT MUST identify a party the Wallet trusts for issuing Verifier Attestation JWTs. // If the Wallet cannot establish trust, it MUST refuse the request. - return { method: 'jwk', type, jwk: attestationPayload.cnf['jwk'] as JWK, alg: (jwk.alg ?? attestationHeader.alg) as SigningAlgo } + return { method: 'jwk', type, jwk: attestationPayload.cnf['jwk'] as JWK, alg: jwk.alg ?? attestationHeader.alg } } else if (clientIdScheme === 'entity_id') { if (!clientId.startsWith('http')) { throw new Error(SIOPErrors.INVALID_REQUEST_OBJECT_ENTITY_ID_SCHEME_CLIENT_ID)