Skip to content

Commit 6fd7a28

Browse files
committed
chore: stumbled upon a bug in findAuthorizationDetail
1 parent 3428567 commit 6fd7a28

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

packages/client/lib/CredentialRequestClient.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ function isOpenIdCredentialDetail(ad: AuthorizationDetails): ad is Authorization
7676
return typeof ad === 'object' && ad !== null && ad.type === 'openid_credential'
7777
}
7878

79-
// Update the helper function:
8079
function findAuthorizationDetail(
8180
authorizationDetails: AuthorizationDetails[] | undefined,
8281
preferredConfigId?: string
@@ -93,10 +92,20 @@ function findAuthorizationDetail(
9392

9493
// If a preferred config ID is specified, try to find a match
9594
if (preferredConfigId) {
96-
const match = openIdCredentialDetails.find(detail =>
97-
typeof detail === 'object' && detail !== null &&
98-
(detail as any).credential_configuration_id === preferredConfigId
99-
)
95+
const match = openIdCredentialDetails.find(detail => {
96+
if (typeof detail !== 'object' || detail === null) return false
97+
98+
const detailObj = detail as any
99+
100+
if (detailObj.credential_configuration_id === preferredConfigId) {
101+
return true
102+
}
103+
if (detailObj.credential_identifier === preferredConfigId) {
104+
return true
105+
}
106+
return Array.isArray(detailObj.credential_identifiers) && detailObj.credential_identifiers.includes(preferredConfigId)
107+
})
108+
100109
if (match) {
101110
return match
102111
}

0 commit comments

Comments
 (0)