File tree Expand file tree Collapse file tree
packages/common/lib/functions Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -51,7 +51,19 @@ export function getSupportedCredential(opts?: {
5151 let credentialConfigurationsV11 : Array < CredentialConfigurationSupported > | undefined = undefined ;
5252 let credentialConfigurationsV13 : Record < string , CredentialConfigurationSupportedV1_0_13 > | undefined = undefined ;
5353 if ( version < OpenId4VCIVersion . VER_1_0_12 || issuerMetadata ?. credentials_supported ) {
54- credentialConfigurationsV11 = ( issuerMetadata ?. credentials_supported as Array < CredentialConfigurationSupported > ) ?? [ ] ;
54+ if ( typeof issuerMetadata ?. credentials_supported === 'object' ) {
55+ // The current code duplication and logic is such a mess, that we re-adjust the object to the proper type again
56+ credentialConfigurationsV11 = [ ]
57+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
58+ Object . entries ( issuerMetadata . credentials_supported ! ) . forEach ( ( [ id , supported ] ) => {
59+ if ( ! supported . id ) {
60+ supported . id = id
61+ }
62+ credentialConfigurationsV11 ?. push ( supported as CredentialConfigurationSupported )
63+ } )
64+ } else {
65+ credentialConfigurationsV11 = ( issuerMetadata ?. credentials_supported as Array < CredentialConfigurationSupported > ) ?? [ ] ;
66+ }
5567 } else {
5668 credentialConfigurationsV13 =
5769 ( issuerMetadata ?. credential_configurations_supported as Record < string , CredentialConfigurationSupportedV1_0_13 > ) ?? { } ;
You can’t perform that action at this time.
0 commit comments