Skip to content

Commit

Permalink
fix: added back the isEbsi function to the new version's OpenID4VCICl…
Browse files Browse the repository at this point in the history
…ient
  • Loading branch information
sksadjad committed May 17, 2024
1 parent 03c5d0d commit 479bea7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
34 changes: 34 additions & 0 deletions packages/client/lib/OpenID4VCIClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
AuthzFlowType,
CodeChallengeMethod,
CredentialConfigurationSupportedV1_0_13,
CredentialOfferPayloadV1_0_13,
CredentialOfferRequestWithBaseUrl,
CredentialResponse,
DefaultURISchemes,
Expand Down Expand Up @@ -514,6 +515,39 @@ export class OpenID4VCIClient {
return this.endpointMetadata ? this.endpointMetadata.credential_endpoint : `${this.getIssuer()}/credential`;
}

/**
* Too bad we need a method like this, but EBSI is not exposing metadata
*/
public isEBSI(): boolean {
const credentialOffer = this.credentialOffer?.credential_offer as CredentialOfferPayloadV1_0_13;

if (credentialOffer?.credential_configuration_ids) {
const credentialConfigurations = this.endpointMetadata.credentialIssuerMetadata?.credential_configurations_supported;

if (credentialConfigurations) {
const isEBSITrustFramework = credentialOffer.credential_configuration_ids
.map(id => credentialConfigurations[id])
.filter((config): config is CredentialConfigurationSupportedV1_0_13 =>
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
config !== undefined && 'trust_framework' in config && 'name' in config.trust_framework
)
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
.some(config => config.trust_framework.name.includes('ebsi'));

if (isEBSITrustFramework) {
return true;
}
}
}

this.assertIssuerData();
return this.endpointMetadata.credentialIssuerMetadata?.authorization_endpoint?.includes('ebsi.eu') ?? false;
}



private assertIssuerData(): void {
if (!this._state.credentialIssuer) {
throw Error(`No credential issuer value present`);
Expand Down
1 change: 1 addition & 0 deletions packages/common/lib/types/v1_0_13.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export type CredentialConfigurationSupportedV1_0_13 = {
credential_signing_alg_values_supported?: string[];
proof_types_supported?: Record<KeyProofType, ProofType>;
display?: CredentialsSupportedDisplay[]; // OPTIONAL. An array of objects, where each object contains the display properties of the supported credential for a certain language
[x: string]: unknown;
};

export type CredentialRequestV1_0_13 = CommonCredentialRequest &
Expand Down

0 comments on commit 479bea7

Please sign in to comment.