Skip to content

Commit

Permalink
fix: changed the logic for pin validation
Browse files Browse the repository at this point in the history
  • Loading branch information
sksadjad committed May 17, 2024
1 parent 5655859 commit b8bb359
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/client/lib/AccessTokenClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export class AccessTokenClient {
if (accessTokenRequest.grant_type === GrantTypes.PRE_AUTHORIZED_CODE) {
this.assertPreAuthorizedGrantType(accessTokenRequest.grant_type);
this.assertNonEmptyPreAuthorizedCode(accessTokenRequest);
this.assertAlphanumericPin(pinMeta, accessTokenRequest['pre-authorized_code']);
this.assertAlphanumericPin(pinMeta, accessTokenRequest.user_pin);
} else if (accessTokenRequest.grant_type === GrantTypes.AUTHORIZATION_CODE) {
this.assertAuthorizationGrantType(accessTokenRequest.grant_type);
this.assertNonEmptyCodeVerifier(accessTokenRequest);
Expand Down
12 changes: 6 additions & 6 deletions packages/client/lib/__tests__/AccessTokenClient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ describe('AccessTokenClient should', () => {

const accessTokenRequest: AccessTokenRequest = {
grant_type: GrantTypes.PRE_AUTHORIZED_CODE,
user_pin: '20221013',
'pre-authorized_code': '20221013',
client_id: 'sphereon',
} as AccessTokenRequest;
Expand Down Expand Up @@ -219,12 +220,11 @@ describe('AccessTokenClient should', () => {
.post(/.*/)
.reply(200, {});

await expect(() =>
accessTokenClient.acquireAccessToken({
credentialOffer: INITIATION_TEST,
pin: '1234',
}),
).rejects.toThrow(Error('A valid pin must be present according to the specified transaction code requirements.'));
const response: OpenIDResponse<AccessTokenResponse> = await accessTokenClient.acquireAccessToken({
credentialOffer: INITIATION_TEST,
pin: '1234',
})
expect(response.successBody).toBeDefined()
});

it('get error if no as, issuer and metadata values are present', async () => {
Expand Down

0 comments on commit b8bb359

Please sign in to comment.