Skip to content

Commit

Permalink
fix: pass custom documentLoader to frameing func
Browse files Browse the repository at this point in the history
Signed-off-by: Karim Stekelenburg <[email protected]>
  • Loading branch information
karimStekelenburg committed Nov 24, 2022
1 parent 03cdf39 commit 955aefb
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions packages/core/src/modules/vc/__tests__/documentLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const DOCUMENTS = {
'https://w3id.org/vaccination/v1': VACCINATION_V1,
}

export const customDocumentLoader = async (url: string): Promise<DocumentLoaderResult> => {
async function _customDocumentLoader(url: string): Promise<DocumentLoaderResult> {
let result = DOCUMENTS[url]

if (!result) {
Expand All @@ -94,11 +94,16 @@ export const customDocumentLoader = async (url: string): Promise<DocumentLoaderR
}

if (url.startsWith('did:')) {
result = await jsonld.frame(result, {
'@context': result['@context'],
'@embed': '@never',
id: url,
})
result = await jsonld.frame(
result,
{
'@context': result['@context'],
'@embed': '@never',
id: url,
},
// @ts-ignore
{ documentLoader: this }
)
}

return {
Expand All @@ -107,3 +112,5 @@ export const customDocumentLoader = async (url: string): Promise<DocumentLoaderR
document: result as JsonObject,
}
}

export const customDocumentLoader = _customDocumentLoader.bind(_customDocumentLoader)

0 comments on commit 955aefb

Please sign in to comment.