Skip to content

Commit

Permalink
fix: access token client_id not always set
Browse files Browse the repository at this point in the history
  • Loading branch information
nklomp committed Feb 17, 2025
1 parent 362da1a commit a3ef03e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/client/lib/OpenID4VCIClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@ export class OpenID4VCIClient {

if (clientId) {
this._state.clientId = clientId;
if (!asOpts.clientOpts) {
asOpts.clientOpts = { clientId };
}
asOpts.clientOpts.clientId = clientId;
}
if (!this._state.accessTokenResponse) {
const accessTokenClient = this.version() <= OpenId4VCIVersion.VER_1_0_12 ? new AccessTokenClientV1_0_11() : new AccessTokenClient();
Expand Down
7 changes: 6 additions & 1 deletion packages/client/lib/OpenID4VCIClientV1_0_11.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,13 @@ export class OpenID4VCIClientV1_0_11 {
}
this.assertIssuerData();

const asOpts: AuthorizationServerOpts = { ...opts?.asOpts };
if (clientId) {
this._state.clientId = clientId;
if (!asOpts.clientOpts) {
asOpts.clientOpts = { clientId };
}
asOpts.clientOpts.clientId = clientId;
}
if (!this._state.accessTokenResponse) {
const accessTokenClient = new AccessTokenClientV1_0_11();
Expand All @@ -315,7 +320,7 @@ export class OpenID4VCIClientV1_0_11 {
if (this._state.authorizationRequestOpts?.redirectUri && !redirectUri) {
redirectUri = this._state.authorizationRequestOpts.redirectUri;
}
const asOpts: AuthorizationServerOpts = { ...opts?.asOpts };

const kid = asOpts.clientOpts?.kid ?? this._state.kid ?? this._state.authorizationRequestOpts?.requestObjectOpts?.kid;
const clientAssertionType =
asOpts.clientOpts?.clientAssertionType ??
Expand Down
4 changes: 4 additions & 0 deletions packages/client/lib/OpenID4VCIClientV1_0_13.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,10 @@ export class OpenID4VCIClientV1_0_13 {

if (clientId) {
this._state.clientId = clientId;
if (!asOpts.clientOpts) {
asOpts.clientOpts = { clientId };
}
asOpts.clientOpts.clientId = clientId;
}
if (!this._state.accessTokenResponse) {
const accessTokenClient = new AccessTokenClient();
Expand Down
4 changes: 3 additions & 1 deletion packages/issuer/lib/__tests__/VcIssuer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,9 @@ describe('VcIssuer without did', () => {
})

it('should throw error when getting session with invalid uri', async () => {
await expect(vcIssuer.getCredentialOfferSessionById('https://example.com/invalid-uri')).rejects.toThrow('no value found for id https://example.com/invalid-uri')
await expect(vcIssuer.getCredentialOfferSessionById('https://example.com/invalid-uri')).rejects.toThrow(
'no value found for id https://example.com/invalid-uri',
)
})

it('should throw error when getting session by uri without uri state manager', async () => {
Expand Down

0 comments on commit a3ef03e

Please sign in to comment.