@digitalbazaar/vc 2.0.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -1
- package/lib/CredentialIssuancePurpose.js +6 -7
- package/lib/contexts/index.js +17 -11
- package/lib/contexts/odrl.js +3 -3
- package/lib/contexts/vc-examples-v1.js +21 -2
- package/lib/documentLoader.js +4 -6
- package/lib/index.js +652 -3
- package/package.json +29 -43
- package/CHANGELOG.md +0 -102
- package/lib/vc.js +0 -601
package/README.md
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Copyright (c) 2019-
|
|
2
|
+
* Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
|
|
3
3
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import jsonld from 'jsonld';
|
|
5
|
+
import jsigs from 'jsonld-signatures';
|
|
6
|
+
|
|
7
|
+
const {purposes: {AssertionProofPurpose}} = jsigs;
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Creates a proof purpose that will validate whether or not the verification
|
|
10
11
|
* method in a proof was authorized by its declared controller for the
|
|
11
12
|
* proof's purpose.
|
|
12
13
|
*/
|
|
13
|
-
class CredentialIssuancePurpose extends AssertionProofPurpose {
|
|
14
|
+
export class CredentialIssuancePurpose extends AssertionProofPurpose {
|
|
14
15
|
/**
|
|
15
16
|
* @param {object} options - The options to use.
|
|
16
17
|
* @param {object} [options.controller] - The description of the controller,
|
|
@@ -77,5 +78,3 @@ class CredentialIssuancePurpose extends AssertionProofPurpose {
|
|
|
77
78
|
}
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
|
-
|
|
81
|
-
module.exports = CredentialIssuancePurpose;
|
package/lib/contexts/index.js
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Copyright (c) 2019-
|
|
2
|
+
* Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
import {
|
|
5
|
+
contexts as credentialContexts
|
|
6
|
+
} from 'credentials-context';
|
|
7
|
+
import {
|
|
8
|
+
CONTEXT as vcExamplesV1Context,
|
|
9
|
+
CONTEXT_URL as vcExamplesV1ContextUrl
|
|
10
|
+
} from './vc-examples-v1.js';
|
|
11
|
+
import {
|
|
12
|
+
CONTEXT as odrlContext,
|
|
13
|
+
CONTEXT_URL as odrlContextUrl
|
|
14
|
+
} from './odrl.js';
|
|
5
15
|
|
|
6
|
-
const
|
|
16
|
+
export const contexts = {};
|
|
7
17
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
require('./vc-examples-v1'),
|
|
11
|
-
'https://www.w3.org/ns/odrl.jsonld': require('./odrl')
|
|
12
|
-
};
|
|
18
|
+
contexts[vcExamplesV1ContextUrl] = vcExamplesV1Context;
|
|
19
|
+
contexts[odrlContextUrl] = odrlContext;
|
|
13
20
|
|
|
14
|
-
for(const
|
|
15
|
-
|
|
16
|
-
exportedContexts[contextUrl] = contexts.get(contextUrl);
|
|
21
|
+
for(const [url, context] of credentialContexts.entries()) {
|
|
22
|
+
contexts[url] = context;
|
|
17
23
|
}
|
package/lib/contexts/odrl.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Copyright (c) 2019-
|
|
2
|
+
* Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
|
|
3
3
|
*/
|
|
4
|
-
'use strict';
|
|
5
4
|
|
|
5
|
+
export const CONTEXT_URL = 'https://www.w3.org/ns/odrl.jsonld';
|
|
6
6
|
/* eslint-disable quote-props, key-spacing, max-len */
|
|
7
|
-
|
|
7
|
+
export const CONTEXT = {
|
|
8
8
|
'@context': {
|
|
9
9
|
'odrl': 'http://www.w3.org/ns/odrl/2/',
|
|
10
10
|
'rdf': 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Copyright (c) 2019-
|
|
2
|
+
* Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
+
export const CONTEXT_URL = 'https://www.w3.org/2018/credentials/examples/v1';
|
|
5
6
|
/* eslint-disable quote-props */
|
|
6
|
-
|
|
7
|
+
export const CONTEXT = {
|
|
7
8
|
'@context': [
|
|
8
9
|
{
|
|
9
10
|
'@version': 1.1
|
|
@@ -16,26 +17,44 @@ module.exports = {
|
|
|
16
17
|
|
|
17
18
|
'3rdPartyCorrelation': 'ex:3rdPartyCorrelation',
|
|
18
19
|
'AllVerifiers': 'ex:AllVerifiers',
|
|
20
|
+
'AlumniCredential': 'ex:AlumniCredential',
|
|
19
21
|
'Archival': 'ex:Archival',
|
|
20
22
|
'BachelorDegree': 'ex:BachelorDegree',
|
|
21
23
|
'Child': 'ex:Child',
|
|
22
24
|
'CLCredentialDefinition2019': 'ex:CLCredentialDefinition2019',
|
|
23
25
|
'CLSignature2019': 'ex:CLSignature2019',
|
|
26
|
+
'DisputeCredential': 'ex:DisputeCredential',
|
|
24
27
|
'IssuerPolicy': 'ex:IssuerPolicy',
|
|
25
28
|
'HolderPolicy': 'ex:HolderPolicy',
|
|
26
29
|
'Mother': 'ex:Mother',
|
|
30
|
+
'PrescriptionCredential': 'ex:PrescriptionCredential',
|
|
27
31
|
'RelationshipCredential': 'ex:RelationshipCredential',
|
|
28
32
|
'UniversityDegreeCredential': 'ex:UniversityDegreeCredential',
|
|
29
33
|
'ZkpExampleSchema2018': 'ex:ZkpExampleSchema2018',
|
|
30
34
|
|
|
31
35
|
'alumniOf': {'@id': 'schema:alumniOf', '@type': 'rdf:HTML'},
|
|
36
|
+
'attributes': 'ex:attributes',
|
|
32
37
|
'child': {'@id': 'ex:child', '@type': '@id'},
|
|
38
|
+
'college': 'ex:college',
|
|
39
|
+
'currentStatus': 'ex:currentStatus',
|
|
33
40
|
'degree': 'ex:degree',
|
|
41
|
+
'degreeSchool': 'ex:degreeSchool',
|
|
42
|
+
'degreeType': 'ex:degreeType',
|
|
43
|
+
'familyName': 'schema:familyName',
|
|
44
|
+
'givenName': 'schema:givenName',
|
|
45
|
+
'issuerData': 'ex:issuerData',
|
|
34
46
|
'name': {'@id': 'schema:name', '@type': 'rdf:HTML'},
|
|
47
|
+
'nonRevocationProof': 'ex:nonRevocationProof',
|
|
35
48
|
'parent': {'@id': 'ex:parent', '@type': '@id'},
|
|
49
|
+
'prescription': 'ex:prescription',
|
|
50
|
+
'primaryProof': 'ex:primaryProof',
|
|
36
51
|
'referenceId': 'ex:referenceId',
|
|
37
52
|
'documentPresence': 'ex:documentPresence',
|
|
38
53
|
'evidenceDocument': 'ex:evidenceDocument',
|
|
54
|
+
'signature': 'ex:signature',
|
|
55
|
+
'signatureCorrectnessProof': 'ex:signatureCorrectnessProof',
|
|
56
|
+
'spouse': 'schema:spouse',
|
|
57
|
+
'statusReason': 'ex:statusReason',
|
|
39
58
|
'subjectPresence': 'ex:subjectPresence',
|
|
40
59
|
'verifier': {'@id': 'ex:verifier', '@type': '@id'},
|
|
41
60
|
}
|
package/lib/documentLoader.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Copyright (c) 2019-
|
|
2
|
+
* Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
|
|
3
3
|
*/
|
|
4
|
-
'use strict';
|
|
5
|
-
|
|
6
4
|
// load locally embedded contexts
|
|
7
|
-
|
|
5
|
+
import {contexts} from './contexts/index.js';
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
export async function documentLoader(url) {
|
|
10
8
|
const context = contexts[url];
|
|
11
9
|
if(context !== undefined) {
|
|
12
10
|
return {
|
|
@@ -16,4 +14,4 @@ module.exports = async function documentLoader(url) {
|
|
|
16
14
|
};
|
|
17
15
|
}
|
|
18
16
|
throw new Error(`Document loader unable to load URL "${url}".`);
|
|
19
|
-
}
|
|
17
|
+
}
|