Skip to content

Commit

Permalink
chore: more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nklomp committed Jun 15, 2024
1 parent b8d5819 commit 6099dea
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/common/lib/functions/IssuerMetadataUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,19 @@ export function getSupportedCredential(opts?: {
let credentialConfigurationsV11: Array<CredentialConfigurationSupported> | undefined = undefined;
let credentialConfigurationsV13: Record<string, CredentialConfigurationSupportedV1_0_13> | undefined = undefined;
if (version < OpenId4VCIVersion.VER_1_0_12 || issuerMetadata?.credentials_supported) {
credentialConfigurationsV11 = (issuerMetadata?.credentials_supported as Array<CredentialConfigurationSupported>) ?? [];
if (typeof issuerMetadata?.credentials_supported === 'object') {
// The current code duplication and logic is such a mess, that we re-adjust the object to the proper type again
credentialConfigurationsV11 = []
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
Object.entries(issuerMetadata.credentials_supported!).forEach(([id, supported]) => {
if (!supported.id) {
supported.id = id
}
credentialConfigurationsV11?.push(supported as CredentialConfigurationSupported)
})
} else {
credentialConfigurationsV11 = (issuerMetadata?.credentials_supported as Array<CredentialConfigurationSupported>) ?? [];
}
} else {
credentialConfigurationsV13 =
(issuerMetadata?.credential_configurations_supported as Record<string, CredentialConfigurationSupportedV1_0_13>) ?? {};
Expand Down

0 comments on commit 6099dea

Please sign in to comment.