From a2b3c2294331bceea8c39228b9b3da1c385d01cd Mon Sep 17 00:00:00 2001 From: sksadjad Date: Thu, 16 May 2024 15:00:40 +0200 Subject: [PATCH] fix: fixed type mismatch in some files --- packages/client/lib/AuthorizationCodeClient.ts | 12 ++++++------ packages/client/lib/OpenID4VCIClient.ts | 5 ++--- packages/client/lib/OpenID4VCIClientV1_0_11.ts | 4 ++-- .../common/lib/functions/IssuerMetadataUtils.ts | 16 ++++++++-------- 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/packages/client/lib/AuthorizationCodeClient.ts b/packages/client/lib/AuthorizationCodeClient.ts index 4699146f..9a35c2c4 100644 --- a/packages/client/lib/AuthorizationCodeClient.ts +++ b/packages/client/lib/AuthorizationCodeClient.ts @@ -3,7 +3,7 @@ import { AuthorizationRequestOpts, CodeChallengeMethod, convertJsonToURI, - CredentialOfferFormat, + CredentialConfigurationSupportedV1_0_13, CredentialOfferPayloadV1_0_13, CredentialOfferRequestWithBaseUrl, CredentialSupported, @@ -14,7 +14,7 @@ import { OpenId4VCIVersion, PARMode, PKCEOpts, - PushedAuthorizationResponse, + PushedAuthorizationResponse, ResponseType } from '@sphereon/oid4vci-common' import Debug from 'debug'; @@ -23,8 +23,8 @@ const debug = Debug('sphereon:oid4vci'); function filterSupportedCredentials( credentialOffer: CredentialOfferPayloadV1_0_13, - credentialsSupported?: Record, -): CredentialSupported[] { + credentialsSupported?: Record, +): CredentialConfigurationSupportedV1_0_13[] { if (!credentialOffer.credential_configuration_ids || !credentialsSupported) { return []; } @@ -42,7 +42,7 @@ export const createAuthorizationRequestUrl = async ({ endpointMetadata: EndpointMetadataResultV1_0_13; authorizationRequest: AuthorizationRequestOpts; credentialOffer?: CredentialOfferRequestWithBaseUrl; - credentialConfigurationSupported?: Record; + credentialConfigurationSupported?: Record; }): Promise => { const { redirectUri, clientId } = authorizationRequest; let { scope, authorizationDetails } = authorizationRequest; @@ -58,7 +58,7 @@ export const createAuthorizationRequestUrl = async ({ if ('credentials' in credentialOffer.credential_offer) { throw new Error('CredentialOffer format is wrong.'); } - const creds: (CredentialSupported | CredentialOfferFormat | string)[] = + const creds: CredentialConfigurationSupportedV1_0_13[] = determineSpecVersionFromOffer(credentialOffer.credential_offer) === OpenId4VCIVersion.VER_1_0_13 ? filterSupportedCredentials(credentialOffer.credential_offer as CredentialOfferPayloadV1_0_13, credentialConfigurationSupported) : []; diff --git a/packages/client/lib/OpenID4VCIClient.ts b/packages/client/lib/OpenID4VCIClient.ts index e055eee9..2533eb46 100644 --- a/packages/client/lib/OpenID4VCIClient.ts +++ b/packages/client/lib/OpenID4VCIClient.ts @@ -4,10 +4,9 @@ import { AuthorizationRequestOpts, AuthorizationResponse, AuthzFlowType, - CodeChallengeMethod, + CodeChallengeMethod, CredentialConfigurationSupportedV1_0_13, CredentialOfferRequestWithBaseUrl, CredentialResponse, - CredentialSupported, DefaultURISchemes, EndpointMetadataResultV1_0_13, getClientIdFromCredentialOfferPayload, @@ -440,7 +439,7 @@ export class OpenID4VCIClient { getCredentialsSupported( format?: (OID4VCICredentialFormat | string) | (OID4VCICredentialFormat | string)[], - ): Record { + ): Record { return getSupportedCredentials({ issuerMetadata: this.endpointMetadata.credentialIssuerMetadata, version: this.version(), diff --git a/packages/client/lib/OpenID4VCIClientV1_0_11.ts b/packages/client/lib/OpenID4VCIClientV1_0_11.ts index 9c7f0206..e9d264be 100644 --- a/packages/client/lib/OpenID4VCIClientV1_0_11.ts +++ b/packages/client/lib/OpenID4VCIClientV1_0_11.ts @@ -455,7 +455,7 @@ export class OpenID4VCIClientV1_0_11 { version: this.version(), format: format, types: restrictToInitiationTypes ? this.getCredentialOfferTypes() : undefined, - }); + }) as Record; } getCredentialsSupported( @@ -466,7 +466,7 @@ export class OpenID4VCIClientV1_0_11 { version: this.version(), format: format, types: undefined, - }); + }) as Record; } getCredentialOfferTypes(): string[][] { diff --git a/packages/common/lib/functions/IssuerMetadataUtils.ts b/packages/common/lib/functions/IssuerMetadataUtils.ts index 3bbe7f8d..3bcc1b3c 100644 --- a/packages/common/lib/functions/IssuerMetadataUtils.ts +++ b/packages/common/lib/functions/IssuerMetadataUtils.ts @@ -1,14 +1,14 @@ import { AuthorizationServerMetadata, - CredentialSupported, + CredentialConfigurationSupportedV1_0_13, CredentialIssuerMetadata, + CredentialSupported, CredentialSupportedTypeV1_0_08, CredentialSupportedV1_0_08, IssuerMetadataV1_0_08, MetadataDisplay, - OID4VCICredentialFormat, - OpenId4VCIVersion, -} from '../types'; + OID4VCICredentialFormat, OpenId4VCIVersion +} from '../types' import { IssuerMetadataV1_0_13 } from '../types'; export function getSupportedCredentials(options?: { @@ -16,7 +16,7 @@ export function getSupportedCredentials(options?: { version: OpenId4VCIVersion; types?: string[][]; format?: OID4VCICredentialFormat | string | (OID4VCICredentialFormat | string)[]; -}): Record { +}): Record { if (options?.types && Array.isArray(options.types)) { return options.types .map((typeSet) => { @@ -27,7 +27,7 @@ export function getSupportedCredentials(options?: { Object.assign(acc, result); return acc; }, - {} as Record, + {} as Record, ); } @@ -39,7 +39,7 @@ export function getSupportedCredential(opts?: { version: OpenId4VCIVersion; types?: string | string[]; format?: (OID4VCICredentialFormat | string) | (OID4VCICredentialFormat | string)[]; -}): Record { +}): Record { const { issuerMetadata, types, format } = opts ?? {}; if (!issuerMetadata || !issuerMetadata.credential_configurations_supported) { @@ -50,7 +50,7 @@ export function getSupportedCredential(opts?: { const formats = Array.isArray(format) ? format : format ? [format] : []; const normalizedTypes = Array.isArray(types) ? types : types ? [types] : []; - const filteredConfigs: Record = {}; + const filteredConfigs: Record = {}; Object.entries(configurations).forEach(([key, value]) => { const isTypeMatch = normalizedTypes.length === 0 || normalizedTypes.includes(key); const isFormatMatch = formats.length === 0 || formats.includes(value.format);