@bedrock/vc-verifier 11.0.0 → 12.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.
@@ -1,232 +0,0 @@
1
- /*
2
- * Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
3
- */
4
- import * as bedrock from '@bedrock/core';
5
- import {httpsAgent} from '@bedrock/https-agent';
6
- import {createRequire} from 'module';
7
- import {didIo} from '@bedrock/did-io';
8
- import {getAppIdentity} from '@bedrock/app-identity';
9
- import {mockData} from './mock.data.js';
10
- import {httpClient} from '@digitalbazaar/http-client';
11
- const require = createRequire(import.meta.url);
12
- const {Ed25519Signature2020} = require('@digitalbazaar/ed25519-signature-2020');
13
- const {EdvClient} = require('@digitalbazaar/edv-client');
14
- const {KeystoreAgent, KmsClient} = require('@digitalbazaar/webkms-client');
15
- const {ZcapClient} = require('@digitalbazaar/ezcap');
16
-
17
- const edvBaseUrl = `${mockData.baseUrl}/edvs`;
18
- const kmsBaseUrl = `${mockData.baseUrl}/kms`;
19
-
20
- const FIVE_MINUTES = 1000 * 60 * 5;
21
-
22
- export async function createMeter({capabilityAgent, serviceType} = {}) {
23
- // create signer using the application's capability invocation key
24
- const {keys: {capabilityInvocationKey}} = getAppIdentity();
25
-
26
- const zcapClient = new ZcapClient({
27
- agent: httpsAgent,
28
- invocationSigner: capabilityInvocationKey.signer(),
29
- SuiteClass: Ed25519Signature2020
30
- });
31
-
32
- // create a meter
33
- const meterService = `${bedrock.config.server.baseUri}/meters`;
34
- let meter = {
35
- controller: capabilityAgent.id,
36
- product: {
37
- // mock ID for service type
38
- id: mockData.productIdMap.get(serviceType)
39
- }
40
- };
41
- ({data: {meter}} = await zcapClient.write({url: meterService, json: meter}));
42
-
43
- // return full meter ID
44
- const {id} = meter;
45
- return {id: `${meterService}/${id}`};
46
- }
47
-
48
- export async function createConfig({
49
- capabilityAgent, ipAllowList, meterId, zcaps
50
- } = {}) {
51
- if(!meterId) {
52
- // create a meter for the keystore
53
- ({id: meterId} = await createMeter({
54
- capabilityAgent, serviceType: 'vc-verifier'
55
- }));
56
- }
57
-
58
- // create service object
59
- const config = {
60
- sequence: 0,
61
- controller: capabilityAgent.id,
62
- meterId
63
- };
64
- if(ipAllowList) {
65
- config.ipAllowList = ipAllowList;
66
- }
67
- if(zcaps) {
68
- config.zcaps = zcaps;
69
- }
70
-
71
- const zcapClient = createZcapClient({capabilityAgent});
72
- const url = `${mockData.baseUrl}/verifiers`;
73
- const response = await zcapClient.write({url, json: config});
74
- return response.data;
75
- }
76
-
77
- export async function getConfig({id, capabilityAgent}) {
78
- const zcapClient = createZcapClient({capabilityAgent});
79
- const {data} = await zcapClient.read({url: id});
80
- return data;
81
- }
82
-
83
- export async function createChallenge({
84
- capabilityAgent, capability, verifierId
85
- }) {
86
- const zcapClient = createZcapClient({capabilityAgent});
87
- return zcapClient.write({
88
- url: `${verifierId}/challenges`,
89
- capability: capability ||
90
- `urn:zcap:root:${encodeURIComponent(verifierId)}`,
91
- json: {}
92
- });
93
- }
94
-
95
- export async function createEdv({
96
- capabilityAgent, keystoreAgent, keyAgreementKey, hmac, meterId
97
- }) {
98
- if(!meterId) {
99
- // create a meter for the keystore
100
- ({id: meterId} = await createMeter({
101
- capabilityAgent, serviceType: 'edv'
102
- }));
103
- }
104
-
105
- if(!(keyAgreementKey && hmac) && keystoreAgent) {
106
- // create KAK and HMAC keys for edv config
107
- ([keyAgreementKey, hmac] = await Promise.all([
108
- keystoreAgent.generateKey({type: 'keyAgreement'}),
109
- keystoreAgent.generateKey({type: 'hmac'})
110
- ]));
111
- }
112
-
113
- // create edv
114
- const newEdvConfig = {
115
- sequence: 0,
116
- controller: capabilityAgent.id,
117
- keyAgreementKey: {id: keyAgreementKey.id, type: keyAgreementKey.type},
118
- hmac: {id: hmac.id, type: hmac.type},
119
- meterId
120
- };
121
-
122
- const edvConfig = await EdvClient.createEdv({
123
- config: newEdvConfig,
124
- httpsAgent,
125
- invocationSigner: capabilityAgent.getSigner(),
126
- url: edvBaseUrl
127
- });
128
-
129
- const edvClient = new EdvClient({
130
- id: edvConfig.id,
131
- keyResolver,
132
- keyAgreementKey,
133
- hmac,
134
- httpsAgent
135
- });
136
-
137
- return {edvClient, edvConfig, hmac, keyAgreementKey};
138
- }
139
-
140
- export async function createKeystore({
141
- capabilityAgent, ipAllowList, meterId,
142
- kmsModule = 'ssm-v1'
143
- }) {
144
- if(!meterId) {
145
- // create a meter for the keystore
146
- ({id: meterId} = await createMeter(
147
- {capabilityAgent, serviceType: 'webkms'}));
148
- }
149
-
150
- // create keystore
151
- const config = {
152
- sequence: 0,
153
- controller: capabilityAgent.id,
154
- meterId,
155
- kmsModule
156
- };
157
- if(ipAllowList) {
158
- config.ipAllowList = ipAllowList;
159
- }
160
-
161
- return KmsClient.createKeystore({
162
- url: `${kmsBaseUrl}/keystores`,
163
- config,
164
- invocationSigner: capabilityAgent.getSigner(),
165
- httpsAgent
166
- });
167
- }
168
-
169
- export async function createKeystoreAgent({capabilityAgent, ipAllowList}) {
170
- let err;
171
- let keystore;
172
- try {
173
- keystore = await createKeystore({capabilityAgent, ipAllowList});
174
- } catch(e) {
175
- err = e;
176
- }
177
- assertNoError(err);
178
-
179
- // create kmsClient only required because we need to use httpsAgent
180
- // that accepts self-signed certs used in test suite
181
- const kmsClient = new KmsClient({httpsAgent});
182
- const keystoreAgent = new KeystoreAgent({
183
- capabilityAgent,
184
- keystoreId: keystore.id,
185
- kmsClient
186
- });
187
-
188
- return keystoreAgent;
189
- }
190
-
191
- export function createZcapClient({
192
- capabilityAgent, delegationSigner, invocationSigner
193
- }) {
194
- const signer = capabilityAgent && capabilityAgent.getSigner();
195
- return new ZcapClient({
196
- agent: httpsAgent,
197
- invocationSigner: invocationSigner || signer,
198
- delegationSigner: delegationSigner || signer,
199
- SuiteClass: Ed25519Signature2020
200
- });
201
- }
202
-
203
- export async function delegate({
204
- capability, controller, invocationTarget, expires, allowedActions,
205
- delegator
206
- }) {
207
- const zcapClient = createZcapClient({capabilityAgent: delegator});
208
- expires = expires || (capability && capability.expires) ||
209
- new Date(Date.now() + FIVE_MINUTES).toISOString().slice(0, -5) + 'Z';
210
- return zcapClient.delegate({
211
- capability, controller, expires, invocationTarget, allowedActions
212
- });
213
- }
214
-
215
- export async function revokeDelegatedCapability({
216
- serviceObjectId, capabilityToRevoke, invocationSigner
217
- }) {
218
- const url = `${serviceObjectId}/zcaps/revocations/` +
219
- encodeURIComponent(capabilityToRevoke.id);
220
- const zcapClient = createZcapClient({invocationSigner});
221
- return zcapClient.write({url, json: capabilityToRevoke});
222
- }
223
-
224
- async function keyResolver({id}) {
225
- // support DID-based keys only
226
- if(id.startsWith('did:')) {
227
- return didIo.get({url: id});
228
- }
229
- // support HTTP-based keys; currently a requirement for WebKMS
230
- const {data} = await httpClient.get(id, {agent: httpsAgent});
231
- return data;
232
- }
@@ -1,28 +0,0 @@
1
- -----BEGIN PRIVATE KEY-----
2
- MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC5egV0Yz8iZziL
3
- p5HNSiIfMISiDd/wqArJKJjr9aY96Sa9cVLSBt+4xJrAxKpCVlgAl/6ZNnVrftZ+
4
- SwqBvQ9I2WlodQhu4Gs1ImrSj44P+SooyGO6IT1mhZMt++0oUj/ZjdaIoFaNjzKo
5
- D1N0RLdI5l6lSSbO/E86sXMX9tHGrjSElMO0EF5dXPLMLrRFjRQ4md819aKpH8Ob
6
- yCI02wRK8j2LI8Cfqka0kxdxQSLQ4z5yDsb3ajd5avJzgCEprOOvwy36dvtuT11X
7
- pstS0Sqgwk1BRhYvYn99H4euSwx9BpoA6GiVM2OaI4SctpvfGxbnhh0Z5SU+JaxJ
8
- xPAnQe9JAgMBAAECggEBAJmBQ8Jv4XC3vTTYGvOsx1DI9vyoPw8OBN83mlivlkbn
9
- EAj6IXFx/vcMwIeKPN9qVqsnIK/tQoEVGLCtqqR1tJC2X2b0dWZOlmwDcCWUah8O
10
- OLZII0GJAS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Oe6AhrzGGQqbGdL4EOCBKEEHQZP4WSwHZwTvEn0arQfzvz9MecT5WU
27
- X+bA8m6q9sVohy1RtvGNzZBu
28
- -----END PRIVATE KEY-----
@@ -1,39 +0,0 @@
1
- {
2
- "@context": [
3
- "https://www.w3.org/2018/credentials/v1",
4
- {
5
- "ex": "https://example.org/examples#",
6
- "schema": "http://schema.org/",
7
- "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
8
- "BachelorDegree": "ex:BachelorDegree",
9
- "UniversityDegreeCredential": "ex:UniversityDegreeCredential",
10
- "degree": "ex:degree",
11
- "name": {
12
- "@id": "schema:name",
13
- "@type": "rdf:HTML"
14
- }
15
- },
16
- "https://w3id.org/security/suites/ed25519-2020/v1"
17
- ],
18
- "id": "http://example.gov/credentials/3732",
19
- "type": [
20
- "VerifiableCredential",
21
- "UniversityDegreeCredential"
22
- ],
23
- "issuer": "did:key:z6MkmHipNuE35C6ona8Hkgpq3mpn4C3rX5kp1SjwcZ7HCWnH",
24
- "issuanceDate": "2020-03-11T23:09:06.803Z",
25
- "credentialSubject": {
26
- "id": "did:example:ebfeb1f712ebc6f1c276e12ec21",
27
- "degree": {
28
- "type": "BachelorDegree",
29
- "name": "Bachelor of Science and Arts"
30
- }
31
- },
32
- "proof": {
33
- "type": "Ed25519Signature2020",
34
- "created": "2021-05-11T18:44:41Z",
35
- "verificationMethod": "did:key:z6MkmHipNuE35C6ona8Hkgpq3mpn4C3rX5kp1SjwcZ7HCWnH#z6MkmHipNuE35C6ona8Hkgpq3mpn4C3rX5kp1SjwcZ7HCWnH",
36
- "proofPurpose": "assertionMethod",
37
- "proofValue": "zqvrFELnqNYWBEsqkHPhqxXuQaNf3dpsQ3s6dLgkS1jAtAwXfwxf2TirW4kyPAUHNU3TXbS7JT38aF4jtnXGwiBT"
38
- }
39
- }
@@ -1,21 +0,0 @@
1
- /*!
2
- * Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
3
- */
4
- import {config} from '@bedrock/core';
5
-
6
- export const mockData = {};
7
-
8
- // mock product IDs and reverse lookup for service products
9
- mockData.productIdMap = new Map([
10
- // edv service
11
- ['edv', 'urn:uuid:dbd15f08-ff67-11eb-893b-10bf48838a41'],
12
- ['urn:uuid:dbd15f08-ff67-11eb-893b-10bf48838a41', 'edv'],
13
- // vc-verifier service
14
- ['vc-verifier', 'urn:uuid:66aad4d0-8ac1-11ec-856f-10bf48838a41'],
15
- ['urn:uuid:66aad4d0-8ac1-11ec-856f-10bf48838a41', 'vc-verifier'],
16
- // webkms service
17
- ['webkms', 'urn:uuid:80a82316-e8c2-11eb-9570-10bf48838a41'],
18
- ['urn:uuid:80a82316-e8c2-11eb-9570-10bf48838a41', 'webkms']
19
- ]);
20
-
21
- mockData.baseUrl = config.server.baseUri;
package/test/package.json DELETED
@@ -1,72 +0,0 @@
1
- {
2
- "name": "bedrock-vc-verifier-test",
3
- "version": "0.0.1-0",
4
- "type": "module",
5
- "description": "Bedrock VC Verifier Test",
6
- "private": true,
7
- "scripts": {
8
- "test": "node --preserve-symlinks test.js test",
9
- "coverage": "cross-env NODE_ENV=test c8 --reporter=lcov --reporter=text-summary npm test",
10
- "coverage-ci": "cross-env NODE_ENV=test c8 --reporter=lcovonly npm test",
11
- "coverage-report": "c8 report"
12
- },
13
- "author": {
14
- "name": "Digital Bazaar, Inc.",
15
- "email": "support@digitalbazaar.com",
16
- "url": "http://digitalbazaar.com"
17
- },
18
- "dependencies": {
19
- "@bedrock/app-identity": "^3.0.0",
20
- "@bedrock/core": "^6.0.0",
21
- "@bedrock/credentials-context": "^3.0.0",
22
- "@bedrock/did-context": "^4.0.0",
23
- "@bedrock/did-io": "^8.0.0",
24
- "@bedrock/edv-storage": "^15.0.0",
25
- "@bedrock/express": "^8.0.0",
26
- "@bedrock/https-agent": "^4.0.0",
27
- "@bedrock/jsonld-document-loader": "^3.0.0",
28
- "@bedrock/kms": "^10.0.0",
29
- "@bedrock/kms-http": "^14.0.0",
30
- "@bedrock/ledger-context": "^23.0.0",
31
- "@bedrock/meter": "^3.0.0",
32
- "@bedrock/meter-http": "^8.0.0",
33
- "@bedrock/meter-usage-reporter": "^7.0.0",
34
- "@bedrock/mongodb": "^10.0.0",
35
- "@bedrock/package-manager": "^3.0.0",
36
- "@bedrock/security-context": "^7.0.0",
37
- "@bedrock/server": "^5.0.0",
38
- "@bedrock/service-agent": "^5.0.0",
39
- "@bedrock/service-context-store": "^7.0.0",
40
- "@bedrock/service-core": "5.0.0",
41
- "@bedrock/ssm-mongodb": "^9.0.0",
42
- "@bedrock/test": "^8.0.0",
43
- "@bedrock/validation": "^7.0.0",
44
- "@bedrock/vc-revocation-list-context": "^3.0.0",
45
- "@bedrock/vc-status-list-context": "^4.0.0",
46
- "@bedrock/vc-verifier": "file:..",
47
- "@bedrock/veres-one-context": "^14.0.0",
48
- "@bedrock/zcap-storage": "^7.0.0",
49
- "@digitalbazaar/did-method-key": "^2.0.0",
50
- "@digitalbazaar/ed25519-signature-2020": "^3.0.0",
51
- "@digitalbazaar/ed25519-verification-key-2020": "^3.2.0",
52
- "@digitalbazaar/edv-client": "^14.0.0",
53
- "@digitalbazaar/ezcap": "^2.0.2",
54
- "@digitalbazaar/http-client": "^3.0.1",
55
- "@digitalbazaar/vc": "^2.1.0",
56
- "@digitalbazaar/vc-status-list-context": "^3.0.0",
57
- "@digitalbazaar/webkms-client": "^10.0.0",
58
- "c8": "^7.11.0",
59
- "cross-env": "^7.0.3",
60
- "express": "^4.17.2",
61
- "vc-revocation-list-context": "^1.0.0"
62
- },
63
- "c8": {
64
- "excludeNodeModules": false,
65
- "include": [
66
- "node_modules/@bedrock/vc-verifier/**"
67
- ],
68
- "exclude": [
69
- "node_modules/@bedrock/vc-verifier/node_modules/**"
70
- ]
71
- }
72
- }
@@ -1,40 +0,0 @@
1
- /*!
2
- * Copyright (c) 2012-2022 Digital Bazaar, Inc. All rights reserved.
3
- */
4
- import {config} from '@bedrock/core';
5
- import {fileURLToPath} from 'url';
6
- import path from 'path';
7
- import '@bedrock/app-identity';
8
- import '@bedrock/https-agent';
9
- import '@bedrock/mongodb';
10
- import '@bedrock/service-agent';
11
- import '@bedrock/vc-verifier';
12
-
13
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
14
-
15
- config.mocha.options.fullTrace = true;
16
- config.mocha.tests.push(path.join(__dirname, 'mocha'));
17
-
18
- // MongoDB
19
- config.mongodb.name = 'bedrock_vc_verifier_test';
20
- config.mongodb.dropCollections.onInit = true;
21
- config.mongodb.dropCollections.collections = [];
22
- // drop all collections on initialization
23
- config.mongodb.dropCollections = {};
24
- config.mongodb.dropCollections.onInit = true;
25
- config.mongodb.dropCollections.collections = [];
26
-
27
- // allow self-signed certs in test framework
28
- config['https-agent'].rejectUnauthorized = false;
29
-
30
- // create test application identity
31
- // ...and `ensureConfigOverride` has already been set via
32
- // `bedrock-app-identity` so it doesn't have to be set here
33
- config['app-identity'].seeds.services['vc-verifier'] = {
34
- id: 'did:key:z6MkrH839XwPCUQ2TkA6ifehciWnEvzuQ2njc6J19fpuP5oN',
35
- seedMultibase: 'z1AgvAGfbairK3AV6GqbeF8gSpYZXftQsGb5DTjptgawNyn',
36
- serviceType: 'vc-verifier'
37
- };
38
-
39
- // use local KMS for testing
40
- config['service-agent'].kms.baseUrl = 'https://localhost:18443/kms';
package/test/test.js DELETED
@@ -1,40 +0,0 @@
1
- /*!
2
- * Copyright (c) 2016-2022 Digital Bazaar, Inc. All rights reserved.
3
- */
4
- import * as bedrock from '@bedrock/core';
5
- import '@bedrock/ssm-mongodb';
6
- import '@bedrock/kms';
7
- import '@bedrock/https-agent';
8
- import '@bedrock/meter';
9
- import '@bedrock/meter-usage-reporter';
10
- import {getServiceIdentities} from '@bedrock/app-identity';
11
- import {handlers} from '@bedrock/meter-http';
12
- import '@bedrock/server';
13
- import '@bedrock/kms-http';
14
- import '@bedrock/edv-storage';
15
- import '@bedrock/vc-verifier';
16
- import {mockData} from './mocha/mock.data.js';
17
-
18
- bedrock.events.on('bedrock.init', async () => {
19
- /* Handlers need to be added before `bedrock.start` is called. These are
20
- no-op handlers to enable meter usage without restriction */
21
- handlers.setCreateHandler({
22
- handler({meter} = {}) {
23
- // use configured meter usage reporter as service ID for tests
24
- const clientName = mockData.productIdMap.get(meter.product.id);
25
- const serviceIdentites = getServiceIdentities();
26
- const serviceIdentity = serviceIdentites.get(clientName);
27
- if(!serviceIdentity) {
28
- throw new Error(`Could not find identity "${clientName}".`);
29
- }
30
- meter.serviceId = serviceIdentity.id;
31
- return {meter};
32
- }
33
- });
34
- handlers.setUpdateHandler({handler: ({meter} = {}) => ({meter})});
35
- handlers.setRemoveHandler({handler: ({meter} = {}) => ({meter})});
36
- handlers.setUseHandler({handler: ({meter} = {}) => ({meter})});
37
- });
38
-
39
- import '@bedrock/test';
40
- bedrock.start();