Skip to content

Commit

Permalink
Merge branch 'main' into refactor/remove-proofrequest-property
Browse files Browse the repository at this point in the history
  • Loading branch information
tipusingh authored Dec 12, 2022
2 parents 0066e59 + 36d4656 commit 6ac2741
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 8 deletions.
41 changes: 39 additions & 2 deletions packages/core/src/modules/vc/__tests__/contexts/bbs_v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export const BBS_V1 = {
'@protected': true,
id: '@id',
type: '@type',

challenge: 'https://w3id.org/security#challenge',
created: {
'@id': 'http://purl.org/dc/terms/created',
Expand Down Expand Up @@ -86,7 +87,43 @@ export const BBS_V1 = {
},
},
},
Bls12381G1Key2020: 'https://w3id.org/security#Bls12381G1Key2020',
Bls12381G2Key2020: 'https://w3id.org/security#Bls12381G2Key2020',
Bls12381G1Key2020: {
'@id': 'https://w3id.org/security#Bls12381G1Key2020',
'@context': {
'@protected': true,
id: '@id',
type: '@type',
controller: {
'@id': 'https://w3id.org/security#controller',
'@type': '@id',
},
revoked: {
'@id': 'https://w3id.org/security#revoked',
'@type': 'http://www.w3.org/2001/XMLSchema#dateTime',
},
publicKeyBase58: {
'@id': 'https://w3id.org/security#publicKeyBase58',
},
},
},
Bls12381G2Key2020: {
'@id': 'https://w3id.org/security#Bls12381G2Key2020',
'@context': {
'@protected': true,
id: '@id',
type: '@type',
controller: {
'@id': 'https://w3id.org/security#controller',
'@type': '@id',
},
revoked: {
'@id': 'https://w3id.org/security#revoked',
'@type': 'http://www.w3.org/2001/XMLSchema#dateTime',
},
publicKeyBase58: {
'@id': 'https://w3id.org/security#publicKeyBase58',
},
},
},
},
}
21 changes: 15 additions & 6 deletions packages/core/src/modules/vc/__tests__/documentLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export const DOCUMENTS = {
DID_V1_CONTEXT_URL: DID_V1,
CREDENTIALS_CONTEXT_V1_URL: CREDENTIALS_V1,
SECURITY_CONTEXT_BBS_URL: BBS_V1,
'https://w3id.org/security/suites/bls12381-2020/v1': BBS_V1,
'https://w3id.org/security/bbs/v1': BBS_V1,
'https://w3id.org/security/v1': SECURITY_V1,
'https://w3id.org/security/v2': SECURITY_V2,
Expand All @@ -75,13 +76,14 @@ export const DOCUMENTS = {
'https://www.w3.org/2018/credentials/examples/v1': EXAMPLES_V1,
'https://www.w3.org/2018/credentials/v1': CREDENTIALS_V1,
'https://w3id.org/did/v1': DID_V1,
'https://www.w3.org/ns/did/v1': DID_V1,
'https://w3id.org/citizenship/v1': CITIZENSHIP_V1,
'https://www.w3.org/ns/odrl.jsonld': ODRL,
'http://schema.org/': SCHEMA_ORG,
'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 +96,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 +114,5 @@ export const customDocumentLoader = async (url: string): Promise<DocumentLoaderR
document: result as JsonObject,
}
}

export const customDocumentLoader = _customDocumentLoader.bind(_customDocumentLoader)

0 comments on commit 6ac2741

Please sign in to comment.