File tree 1 file changed +5
-2
lines changed
1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -323,13 +323,16 @@ export async function getKey(
323
323
if ( ! identifier ) {
324
324
return Promise . reject ( new Error ( `No identifier provided to getKey method!` ) )
325
325
}
326
- let identifierKey = keyId ? identifier . keys . find ( ( key : IKey ) => key . kid === keyId || key ?. meta ?. jwkThumbprint === keyId ) : undefined
326
+ // normalize to kid, in case keyId was passed in as did#vm or #vm
327
+ const kidVals = keyId ?. split ( `#` )
328
+ const kid = kidVals ? ( kidVals ?. length === 2 ? kidVals [ 1 ] : kidVals [ 0 ] ) : undefined
329
+ let identifierKey = keyId ? identifier . keys . find ( ( key : IKey ) => key . kid === kid || key ?. meta ?. jwkThumbprint === kid ) : undefined
327
330
if ( ! identifierKey ) {
328
331
const keys = await mapIdentifierKeysToDocWithJwkSupport ( identifier , verificationMethodSection , context )
329
332
if ( ! keys || keys . length === 0 ) {
330
333
throw new Error ( `No keys found for verificationMethodSection: ${ verificationMethodSection } and did ${ identifier . did } ` )
331
334
}
332
- identifierKey = keyId ? keys . find ( ( key : _ExtendedIKey ) => key . meta . verificationMethod . id === keyId ) : keys [ 0 ]
335
+ identifierKey = keyId ? keys . find ( ( key : _ExtendedIKey ) => key . meta . verificationMethod ? .id === keyId || ( kid && key . meta . verificationMethod ?. id ?. includes ( kid ) ) ) : keys [ 0 ]
333
336
}
334
337
if ( ! identifierKey ) {
335
338
throw new Error (
You can’t perform that action at this time.
0 commit comments