Skip to content

Commit 1c9b5ea

Browse files
authored
Merge pull request #118 from cre8/fix/tx_code
fix: update tx_code check
2 parents b1d0422 + 5127390 commit 1c9b5ea

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

packages/issuer-rest/lib/__tests__/IssuerTokenServer.spec.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ describe('OID4VCIServer', () => {
6060
grants: {
6161
'urn:ietf:params:oauth:grant-type:pre-authorized_code': {
6262
user_pin_required: true,
63+
tx_code: {
64+
length: 6,
65+
input_mode: 'numeric',
66+
description: 'Please enter the 6 digit code you received on your phone',
67+
},
6368
'pre-authorized_code': preAuthorizedCode1,
6469
},
6570
},
@@ -79,7 +84,6 @@ describe('OID4VCIServer', () => {
7984
'urn:ietf:params:oauth:grant-type:pre-authorized_code': {
8085
...credentialOfferState1.credentialOffer.credential_offer?.grants?.['urn:ietf:params:oauth:grant-type:pre-authorized_code'],
8186
'pre-authorized_code': preAuthorizedCode2,
82-
user_pin_required: false,
8387
},
8488
},
8589
},
@@ -185,7 +189,7 @@ describe('OID4VCIServer', () => {
185189
it('should return http code 400 with message User pin is required', async () => {
186190
const res = await requests(app)
187191
.post('/token')
188-
.send(`grant_type=urn:ietf:params:oauth:grant-type:pre-authorized_code&pre-authorized_code=${preAuthorizedCode1}`)
192+
.send(`grant_type=urn:ietf:params:oauth:grant-type:pre-authorized_code&pre-authorized_code=${preAuthorizedCode1}&user_pin=12345678`)
189193
expect(res.statusCode).toEqual(400)
190194
const actual = JSON.parse(res.text)
191195
expect(actual).toEqual({

packages/issuer/lib/tokens/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export const assertValidAccessTokenRequest = async (
110110
invalid_request:
111111
the Authorization Server does not expect a PIN in the pre-authorized flow but the client provides a PIN
112112
*/
113-
if (!credentialOfferSession.credentialOffer.credential_offer?.grants?.[GrantTypes.PRE_AUTHORIZED_CODE]?.user_pin_required && request.user_pin) {
113+
if (!credentialOfferSession.credentialOffer.credential_offer?.grants?.[GrantTypes.PRE_AUTHORIZED_CODE]?.tx_code && request.user_pin) {
114114
throw new TokenError(400, TokenErrorResponse.invalid_request, USER_PIN_NOT_REQUIRED_ERROR)
115115
}
116116
/*

0 commit comments

Comments
 (0)