From 7888a148a8d1c41103fde35dd065ef84c4a17c2b Mon Sep 17 00:00:00 2001 From: Martin Auer Date: Fri, 5 Jul 2024 09:51:17 +0200 Subject: [PATCH] fix: undo tx_code changes --- packages/issuer/lib/tokens/index.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/issuer/lib/tokens/index.ts b/packages/issuer/lib/tokens/index.ts index 50e1fd33..9ec1befe 100644 --- a/packages/issuer/lib/tokens/index.ts +++ b/packages/issuer/lib/tokens/index.ts @@ -100,18 +100,19 @@ export const assertValidAccessTokenRequest = async ( invalid_request: the Authorization Server expects a PIN in the pre-authorized flow but the client does not provide a PIN */ - const preAuthorizedGrant = credentialOfferSession.credentialOffer.credential_offer?.grants?.[GrantTypes.PRE_AUTHORIZED_CODE] - if ((preAuthorizedGrant?.tx_code || preAuthorizedGrant?.user_pin_required) && !request.user_pin) { + if ( + credentialOfferSession.credentialOffer.credential_offer?.grants?.['urn:ietf:params:oauth:grant-type:pre-authorized_code']?.tx_code && + !request.user_pin + ) { throw new TokenError(400, TokenErrorResponse.invalid_request, USER_PIN_REQUIRED_ERROR) } /* invalid_request: the Authorization Server does not expect a PIN in the pre-authorized flow but the client provides a PIN */ - if (!preAuthorizedGrant?.user_pin_required && !preAuthorizedGrant?.tx_code && request.user_pin) { + if (!credentialOfferSession.credentialOffer.credential_offer?.grants?.[GrantTypes.PRE_AUTHORIZED_CODE]?.user_pin_required && request.user_pin) { throw new TokenError(400, TokenErrorResponse.invalid_request, USER_PIN_NOT_REQUIRED_ERROR) } - /* invalid_grant: the Authorization Server expects a PIN in the pre-authorized flow but the client provides the wrong PIN