Skip to content

Commit 858a8ea

Browse files
authored
Merge pull request #132 from cre8/fix/txCode
fix: remove bug for txCode
2 parents 105fc37 + 5ca1eda commit 858a8ea

4 files changed

Lines changed: 9 additions & 4 deletions

File tree

packages/client/lib/AccessTokenClient.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ export class AccessTokenClient {
105105
if (credentialOfferRequest?.supportedFlows.includes(AuthzFlowType.PRE_AUTHORIZED_CODE_FLOW)) {
106106
this.assertAlphanumericPin(opts.pinMetadata, pin);
107107
request.user_pin = pin;
108+
request.tx_code = pin;
108109

109110
request.grant_type = GrantTypes.PRE_AUTHORIZED_CODE;
110111
// we actually know it is there because of the isPreAuthCode call

packages/common/lib/types/Authorization.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ export interface AccessTokenRequest {
312312
'pre-authorized_code': string;
313313
redirect_uri?: string;
314314
scope?: string;
315-
user_pin?: string; //pre draft 13
315+
user_pin?: string; //this is for v11, not required in v13 anymore
316316
tx_code?: string; //draft 13
317317
[s: string]: unknown;
318318
}

packages/issuer/lib/VcIssuer.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ export class VcIssuer<DIDDoc extends object> {
192192
status,
193193
notification_id: v4(),
194194
...(userPin && { txCode: userPin }), // We used to use userPin according to older specs. We map these onto txCode now. If both are used, txCode in the end wins, even if they are different
195-
...(txCode && { txCode }),
196195
...(opts.credentialDataSupplierInput && { credentialDataSupplierInput: opts.credentialDataSupplierInput }),
197196
credentialOffer,
198197
}

packages/issuer/lib/tokens/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,17 @@ export const assertValidAccessTokenRequest = async (
102102
invalid_request:
103103
the Authorization Server does not expect a PIN in the pre-authorized flow but the client provides a PIN
104104
*/
105-
if (!credentialOfferSession.credentialOffer.credential_offer?.grants?.[GrantTypes.PRE_AUTHORIZED_CODE]?.tx_code && request.tx_code) {
105+
if (
106+
!credentialOfferSession.credentialOffer.credential_offer?.grants?.[GrantTypes.PRE_AUTHORIZED_CODE]?.tx_code &&
107+
request.tx_code &&
108+
!request.user_pin
109+
) {
106110
// >= v13
107111
throw new TokenError(400, TokenErrorResponse.invalid_request, USER_PIN_NOT_REQUIRED_ERROR)
108112
} else if (
109113
!credentialOfferSession.credentialOffer.credential_offer?.grants?.[GrantTypes.PRE_AUTHORIZED_CODE]?.user_pin_required &&
110-
request.user_pin
114+
request.user_pin &&
115+
!request.tx_code
111116
) {
112117
// <= v12
113118
throw new TokenError(400, TokenErrorResponse.invalid_request, USER_PIN_NOT_REQUIRED_ERROR)

0 commit comments

Comments
 (0)