From 6ddf9b0b60f3ea36bb5d9fd5c1aa18977d9b6deb Mon Sep 17 00:00:00 2001 From: Niels Klomp Date: Wed, 7 Feb 2024 21:37:50 +0100 Subject: [PATCH] chore: Add a default clientId --- packages/client/lib/OpenID4VCIClient.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/client/lib/OpenID4VCIClient.ts b/packages/client/lib/OpenID4VCIClient.ts index 59b9ac36..f41d15ba 100644 --- a/packages/client/lib/OpenID4VCIClient.ts +++ b/packages/client/lib/OpenID4VCIClient.ts @@ -75,7 +75,12 @@ export class OpenID4VCIClient { this._credentialIssuer = issuer; this._kid = kid; this._alg = alg; - this._clientId = clientId ?? (credentialOffer ? getClientIdFromCredentialOfferPayload(credentialOffer.credential_offer) : undefined); + // 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 + this._clientId = + clientId ?? + (credentialOffer && getClientIdFromCredentialOfferPayload(credentialOffer.credential_offer)) ?? + kid?.split('#')[0] ?? + 'com.sphereon.ssi.wallet'; this._pkce = { ...this._pkce, ...pkce }; this._authorizationRequestOpts = this.syncAuthorizationRequestOpts(authorizationRequest); console.log(`Authorization req options: ${JSON.stringify(this._authorizationRequestOpts, null, 2)}`); @@ -548,6 +553,7 @@ export class OpenID4VCIClient { authorizationRequestOpts = { redirectUri: `${DefaultURISchemes.CREDENTIAL_OFFER}://` }; } const clientId = authorizationRequestOpts.clientId ?? this._clientId; + // sync clientId this._clientId = clientId; authorizationRequestOpts.clientId = clientId; return authorizationRequestOpts;