Skip to content

Commit

Permalink
chore: constructor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Brummos committed Feb 14, 2024
1 parent 65ca260 commit 75961ef
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/client/lib/OpenID4VCIClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,15 @@ export class OpenID4VCIClient {
// TODO: We need to refactor this and always explicitly call createAuthorizationRequestUrl, so we can have a credential selection first and use the kid as a default for the client id
clientId: clientId ?? (credentialOffer && getClientIdFromCredentialOfferPayload(credentialOffer.credential_offer)) ?? kid?.split('#')[0],
pkce: { disabled: false, codeChallengeMethod: CodeChallengeMethod.S256, ...pkce },
authorizationRequestOpts: authorizationRequestOpts ?? this.syncAuthorizationRequestOpts(authorizationRequest),
jwk,
endpointMetadata,
accessTokenResponse,
authorizationURL
}
this._state = {
...this._state,
authorizationRequestOpts: authorizationRequestOpts ?? this.syncAuthorizationRequestOpts(authorizationRequest),
}
debug(`Authorization req options: ${JSON.stringify(this._state.authorizationRequestOpts, null, 2)}`);
}

Expand Down Expand Up @@ -595,7 +598,7 @@ export class OpenID4VCIClient {
}

private syncAuthorizationRequestOpts(opts?: AuthorizationRequestOpts): AuthorizationRequestOpts {
let authorizationRequestOpts = { ...this._state.authorizationRequestOpts, ...opts } as AuthorizationRequestOpts;
let authorizationRequestOpts = { ...this._state?.authorizationRequestOpts, ...opts } as AuthorizationRequestOpts;
if (!authorizationRequestOpts) {
// We only set a redirectUri if no options are provided.
// Note that this only works for mobile apps, that can handle a code query param on the default openid-credential-offer deeplink.
Expand Down

0 comments on commit 75961ef

Please sign in to comment.