Skip to content

Commit 8447426

Browse files
committed
fix: did web resolution from identifier was not taking keys into account that had no purpose set
1 parent 980075b commit 8447426

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

packages/did-utils/src/did-functions.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -644,20 +644,20 @@ export function toDidDocument(
644644
...((opts?.use === undefined || opts?.use?.includes(JwkKeyUse.Signature)) &&
645645
identifier.keys && {
646646
assertionMethod: identifier.keys
647-
.filter((key) => key?.meta?.purpose === undefined || key?.meta?.purpose === 'assertionMethod')
647+
.filter((key) => key?.meta?.purpose === undefined || key?.meta?.purpose === 'assertionMethod' || key?.meta?.purpose?.includes('assertionMethod'))
648648
.map((key) => {
649649
return `${did}#${key.kid}`
650650
}),
651651
authentication: identifier.keys
652-
.filter((key) => key?.meta?.purpose === undefined || key?.meta?.purpose === 'authentication')
652+
.filter((key) => key?.meta?.purpose === undefined || key?.meta?.purpose === 'authentication' || key?.meta?.purpose?.includes('authentication'))
653653
.map((key) => {
654654
return `${did}#${key.kid}`
655655
}),
656656
}),
657657
...((opts?.use === undefined || opts?.use?.includes(JwkKeyUse.Encryption)) &&
658658
identifier.keys && {
659659
keyAgreement: identifier.keys
660-
.filter((key) => key.type === 'X25519' || key?.meta?.purpose === 'keyAgreement')
660+
.filter((key) => key.type === 'X25519' || key?.meta?.purpose === 'keyAgreement' || key?.meta?.purpose?.includes('keyAgreement'))
661661
.map((key) => {
662662
if (key.kid.startsWith(did) && key.kid.includes('#')) {
663663
return key.kid
@@ -667,7 +667,7 @@ export function toDidDocument(
667667
} &&
668668
identifier.keys && {
669669
capabilityInvocation: identifier.keys
670-
.filter((key) => key.type === 'X25519' || key?.meta?.purpose === 'capabilityInvocation')
670+
.filter((key) => key.type === 'X25519' || key?.meta?.purpose === 'capabilityInvocation' || key?.meta?.purpose?.includes('capabilityInvocation'))
671671
.map((key) => {
672672
if (key.kid.startsWith(did) && key.kid.includes('#')) {
673673
return key.kid
@@ -677,7 +677,7 @@ export function toDidDocument(
677677
} &&
678678
identifier.keys && {
679679
capabilityDelegation: identifier.keys
680-
.filter((key) => key.type === 'X25519' || key?.meta?.purpose === 'capabilityDelegation')
680+
.filter((key) => key.type === 'X25519' || key?.meta?.purpose === 'capabilityDelegation' || key?.meta?.purpose?.includes('capabilityDelegation'))
681681
.map((key) => {
682682
if (key.kid.startsWith(did) && key.kid.includes('#')) {
683683
return key.kid

0 commit comments

Comments
 (0)