Skip to content

Commit 6099dea

Browse files
committed
chore: more fixes
1 parent b8d5819 commit 6099dea

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

packages/common/lib/functions/IssuerMetadataUtils.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff 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>) ?? {};

0 commit comments

Comments
 (0)