From 72474d6b95d58914d31ee36875feace8f0432942 Mon Sep 17 00:00:00 2001 From: sksadjad Date: Fri, 17 May 2024 10:54:42 +0200 Subject: [PATCH] fix: added generic union types for frequently used types --- packages/common/lib/functions/IssuerMetadataUtils.ts | 4 +++- packages/common/lib/types/Generic.types.ts | 8 +++++--- packages/common/lib/types/v1_0_13.types.ts | 4 ---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/common/lib/functions/IssuerMetadataUtils.ts b/packages/common/lib/functions/IssuerMetadataUtils.ts index 3bcc1b3c..14b9ebd7 100644 --- a/packages/common/lib/functions/IssuerMetadataUtils.ts +++ b/packages/common/lib/functions/IssuerMetadataUtils.ts @@ -74,8 +74,10 @@ export function getTypesFromCredentialSupported( credentialSupported.format === 'jwt_vc_json-ld' || credentialSupported.format === 'ldp_vc' ) { - types = credentialSupported.types; + types = credentialSupported.types? credentialSupported.types as string[]: 'credential_definition' in credentialSupported? credentialSupported.credential_definition.type: []; } else if (credentialSupported.format === 'vc+sd-jwt') { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore types = [credentialSupported.vct]; } diff --git a/packages/common/lib/types/Generic.types.ts b/packages/common/lib/types/Generic.types.ts index ab0a4600..7bc6212d 100644 --- a/packages/common/lib/types/Generic.types.ts +++ b/packages/common/lib/types/Generic.types.ts @@ -9,6 +9,7 @@ import { EndpointMetadataResultV1_0_11 } from './v1_0_11.types' import { + CredentialConfigurationSupportedV1_0_13, CredentialRequestV1_0_13, EndpointMetadataResultV1_0_13, IssuerMetadataV1_0_13 @@ -156,8 +157,8 @@ export interface CredentialSupportedSdJwtVc extends CommonCredentialSupported { order?: string[]; //An array of claims.display.name values that lists them in the order they should be displayed by the Wallet. } -export type CredentialSupported = CommonCredentialSupported & - (CredentialSupportedJwtVcJson | CredentialSupportedJwtVcJsonLdAndLdpVc | CredentialSupportedSdJwtVc); +export type CredentialSupported = CredentialConfigurationSupportedV1_0_13 | (CommonCredentialSupported & + (CredentialSupportedJwtVcJson | CredentialSupportedJwtVcJsonLdAndLdpVc | CredentialSupportedSdJwtVc)); export interface CommonCredentialOfferFormat { format: OID4VCICredentialFormat | string; @@ -364,4 +365,5 @@ export const PRE_AUTH_CODE_LITERAL = 'pre-authorized_code'; export type EndpointMetadataResult = EndpointMetadataResultV1_0_13 | EndpointMetadataResultV1_0_11 -export type IssuerMetadata = IssuerMetadataV1_0_13 | IssuerMetadataV1_0_08 \ No newline at end of file +export type IssuerMetadata = IssuerMetadataV1_0_13 | IssuerMetadataV1_0_08 + diff --git a/packages/common/lib/types/v1_0_13.types.ts b/packages/common/lib/types/v1_0_13.types.ts index 61067a37..182c23dd 100644 --- a/packages/common/lib/types/v1_0_13.types.ts +++ b/packages/common/lib/types/v1_0_13.types.ts @@ -40,10 +40,6 @@ export type CredentialDefinitionV1_0_13 = { export type CredentialConfigurationSupportedV1_0_13 = { credential_definition: CredentialDefinitionV1_0_13; - /** - * TODO: These two (vct and id) are solely added because of backward compatibility with sd-jwt. as soons as we have a clear understanding of the new sd-jwt issuer protocol we can remove this - */ - vct?: string; id?: string; format: OID4VCICredentialFormat; //REQUIRED. A JSON string identifying the format of this credential, e.g. jwt_vc_json or ldp_vc. scope?: string; // OPTIONAL. A JSON string identifying the scope value that this Credential Issuer supports for this particular Credential. The value can be the same across multiple credential_configurations_supported objects. The Authorization Server MUST be able to uniquely identify the Credential Issuer based on the scope value. The Wallet can use this value in the Authorization Request as defined in Section 5.1.2. Scope values in this Credential Issuer metadata MAY duplicate those in the scopes_supported parameter of the Authorization Server.