Skip to content

Commit

Permalink
feat: allow existing did document for mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
nklomp committed Jan 16, 2023
1 parent f57ae17 commit 4d82518
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/did-utils/src/didFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,13 @@ export function extractPublicKeyHexWithJwkSupport(pk: _ExtendedVerificationMetho
export async function mapIdentifierKeysToDocWithJwkSupport(
identifier: IIdentifier,
section: DIDDocumentSection = 'keyAgreement',
context: IAgentContext<IResolver>
context: IAgentContext<IResolver>,
didDocument?: DIDDocument
): Promise<_ExtendedIKey[]> {
const keys = await mapIdentifierKeysToDoc(identifier, section, context)
const didDocument = await resolveDidOrThrow(identifier.did, context)
const didDoc = didDocument ? didDocument : await resolveDidOrThrow(identifier.did, context)
// dereference all key agreement keys from DID document and normalize
const documentKeys: VerificationMethod[] = await dereferenceDidKeysWithJwkSupport(didDocument, section, context)
const documentKeys: VerificationMethod[] = await dereferenceDidKeysWithJwkSupport(didDoc, section, context)

const localKeys = identifier.keys.filter(isDefined)
// finally map the didDocument keys to the identifier keys by comparing `publicKeyHex`
Expand Down

0 comments on commit 4d82518

Please sign in to comment.