diff --git a/packages/client/lib/OpenID4VCIClient.ts b/packages/client/lib/OpenID4VCIClient.ts index 90337abd..3125208f 100644 --- a/packages/client/lib/OpenID4VCIClient.ts +++ b/packages/client/lib/OpenID4VCIClient.ts @@ -1,4 +1,4 @@ -import { CreateDPoPClientOpts, JWK, parseJWT } from '@sphereon/oid4vc-common'; +import { CreateDPoPClientOpts, JWK } from '@sphereon/oid4vc-common'; import { AccessTokenRequestOpts, AccessTokenResponse, @@ -35,7 +35,6 @@ import { ProofOfPossessionCallbacks, toAuthorizationResponsePayload, } from '@sphereon/oid4vci-common'; -import { FederationClient } from '@sphereon/openid-federation-client'; import { CredentialFormat } from '@sphereon/ssi-types'; import Debug from 'debug'; @@ -55,9 +54,7 @@ import { generateMissingPKCEOpts, sendNotification } from './functions'; const debug = Debug('sphereon:oid4vci'); -export type OpenID4VCIClientState = - | (OpenID4VCIClientStateV1_0_11 & { trustChains?: Array }) - | (OpenID4VCIClientStateV1_0_13 & { trustChains?: Array }); +export type OpenID4VCIClientState = OpenID4VCIClientStateV1_0_11 | OpenID4VCIClientStateV1_0_13; export type EndpointMetadataResult = EndpointMetadataResultV1_0_11 | EndpointMetadataResultV1_0_13; @@ -79,7 +76,6 @@ export class OpenID4VCIClient { authorizationRequestOpts, authorizationCodeResponse, authorizationURL, - trustChains, }: { credentialOffer?: CredentialOfferRequestWithBaseUrl; kid?: string; @@ -95,7 +91,6 @@ export class OpenID4VCIClient { authorizationRequestOpts?: AuthorizationRequestOpts; authorizationCodeResponse?: AuthorizationResponse; authorizationURL?: string; - trustChains?: Array; }) { const issuer = credentialIssuer ?? (credentialOffer ? getIssuerFromCredentialOfferPayload(credentialOffer.credential_offer) : undefined); if (!issuer) { @@ -118,7 +113,6 @@ export class OpenID4VCIClient { : (endpointMetadata as EndpointMetadataResultV1_0_13 | undefined), accessTokenResponse, authorizationURL, - trustChains, } as OpenID4VCIClientState; // Running syncAuthorizationRequestOpts later as it is using the state if (!this._state.authorizationRequestOpts) { @@ -136,7 +130,7 @@ export class OpenID4VCIClient { pkce, authorizationRequest, createAuthorizationRequestURL, - trustChains, + endpointMetadata }: { credentialIssuer: string; kid?: string; @@ -146,7 +140,7 @@ export class OpenID4VCIClient { createAuthorizationRequestURL?: boolean; authorizationRequest?: AuthorizationRequestOpts; // Can be provided here, or when manually calling createAuthorizationUrl pkce?: PKCEOpts; - trustChains?: Array; + endpointMetadata?: EndpointMetadataResult }) { const client = new OpenID4VCIClient({ kid, @@ -155,7 +149,7 @@ export class OpenID4VCIClient { credentialIssuer, pkce, authorizationRequest, - trustChains, + endpointMetadata }); if (retrieveServerMetadata === undefined || retrieveServerMetadata) { await client.retrieveServerMetadata(); @@ -182,6 +176,7 @@ export class OpenID4VCIClient { createAuthorizationRequestURL, authorizationRequest, resolveOfferUri, + endpointMetadata }: { uri: string; kid?: string; @@ -192,6 +187,7 @@ export class OpenID4VCIClient { pkce?: PKCEOpts; clientId?: string; authorizationRequest?: AuthorizationRequestOpts; // Can be provided here, or when manually calling createAuthorizationUrl + endpointMetadata?: EndpointMetadataResult }): Promise { const credentialOfferClient = await CredentialOfferClient.fromURI(uri, { resolve: resolveOfferUri }); const client = new OpenID4VCIClient({ @@ -201,6 +197,7 @@ export class OpenID4VCIClient { clientId: clientId ?? authorizationRequest?.clientId ?? credentialOfferClient.clientId, pkce, authorizationRequest, + endpointMetadata }); if (retrieveServerMetadata === undefined || retrieveServerMetadata) { @@ -266,11 +263,7 @@ export class OpenID4VCIClient { if (this.credentialOffer) { this._state.endpointMetadata = await MetadataClient.retrieveAllMetadataFromCredentialOffer(this.credentialOffer); } else if (this._state.credentialIssuer) { - if (this._state.trustChains !== undefined && this._state.trustChains !== null && this._state.trustChains.length !== 0) { - this._state.endpointMetadata = await this.retrieveTrustChainMetadata(this._state.credentialIssuer, this._state.trustChains); - } else { - this._state.endpointMetadata = await MetadataClient.retrieveAllMetadata(this._state.credentialIssuer); - } + this._state.endpointMetadata = await MetadataClient.retrieveAllMetadata(this._state.credentialIssuer); } else { throw Error(`Cannot retrieve issuer metadata without either a credential offer, or issuer value`); } @@ -279,12 +272,6 @@ export class OpenID4VCIClient { return this.endpointMetadata; } - private async retrieveTrustChainMetadata(credentialIssuer: string, trustChains: Array): Promise { - const oidfClient = new FederationClient(null, null); - const resolvedTrustChain = await oidfClient.resolveTrustChain(credentialIssuer, trustChains); - return resolvedTrustChain?.trustChain?.asJsReadonlyArrayView().map((s) => parseJWT(s))[1].payload as EndpointMetadataResult | undefined; - } - private calculatePKCEOpts(pkce?: PKCEOpts) { this._state.pkce = generateMissingPKCEOpts({ ...this._state.pkce, ...pkce }); } diff --git a/packages/client/package.json b/packages/client/package.json index abb569e3..42c78f5f 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -47,11 +47,6 @@ "uint8arrays": "3.1.1", "uuid": "^9.0.1" }, - "peerDependencies": { - "@sphereon/openid-federation-client": "^0.1.1-unstable.21e8440", - "@sphereon/openid-federation-common": "^0.1.1-unstable.21e8440", - "@sphereon/openid-federation-open-api": "^0.1.1-unstable.21e8440" - }, "engines": { "node": ">=18" },