@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.
- package/README.md +4 -4
- package/lib/challenges.js +1 -3
- package/lib/documentLoader.js +8 -8
- package/lib/http.js +8 -12
- package/lib/index.js +1 -1
- package/lib/status.js +8 -10
- package/package.json +28 -23
- package/.eslintrc.cjs +0 -12
- package/.github/workflows/main.yml +0 -77
- package/CHANGELOG.md +0 -175
- package/test/mocha/.eslintrc.cjs +0 -9
- package/test/mocha/10-provision.js +0 -868
- package/test/mocha/20-verify.js +0 -390
- package/test/mocha/30-credential-status.js +0 -651
- package/test/mocha/cert.pem +0 -18
- package/test/mocha/helpers.js +0 -232
- package/test/mocha/key.pem +0 -28
- package/test/mocha/mock-credential.json +0 -39
- package/test/mocha/mock.data.js +0 -21
- package/test/package.json +0 -72
- package/test/test.config.js +0 -40
- package/test/test.js +0 -40
|
@@ -1,651 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
import * as helpers from './helpers.js';
|
|
5
|
-
import {agent} from '@bedrock/https-agent';
|
|
6
|
-
import {createRequire} from 'node:module';
|
|
7
|
-
import {documentLoader as brDocLoader} from '@bedrock/jsonld-document-loader';
|
|
8
|
-
import express from 'express';
|
|
9
|
-
import {fileURLToPath} from 'node:url';
|
|
10
|
-
import fs from 'node:fs';
|
|
11
|
-
import {httpClient} from '@digitalbazaar/http-client';
|
|
12
|
-
import https from 'node:https';
|
|
13
|
-
import {klona} from 'klona';
|
|
14
|
-
import {mockData} from './mock.data.js';
|
|
15
|
-
import path from 'node:path';
|
|
16
|
-
const require = createRequire(import.meta.url);
|
|
17
|
-
const {CapabilityAgent} = require('@digitalbazaar/webkms-client');
|
|
18
|
-
const {Ed25519Signature2020} = require('@digitalbazaar/ed25519-signature-2020');
|
|
19
|
-
const {Ed25519VerificationKey2020} =
|
|
20
|
-
require('@digitalbazaar/ed25519-verification-key-2020');
|
|
21
|
-
const revocationListCtx = require('vc-revocation-list-context');
|
|
22
|
-
const statusListCtx = require('@digitalbazaar/vc-status-list-context');
|
|
23
|
-
const vc = require('@digitalbazaar/vc');
|
|
24
|
-
|
|
25
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
26
|
-
|
|
27
|
-
const {baseUrl} = mockData;
|
|
28
|
-
const serviceType = 'vc-verifier';
|
|
29
|
-
|
|
30
|
-
const VC_SL_CONTEXT_URL = statusListCtx.constants.CONTEXT_URL_V1;
|
|
31
|
-
const VC_RL_CONTEXT_URL =
|
|
32
|
-
revocationListCtx.constants.VC_REVOCATION_LIST_CONTEXT_V1_URL;
|
|
33
|
-
|
|
34
|
-
const encodedList100k =
|
|
35
|
-
'H4sIAAAAAAAAA-3BMQEAAADCoPVPbQsvoAAAAAAAAAAAAAAAAP4GcwM92tQwAAA';
|
|
36
|
-
const encodedList100KWith50KthRevoked =
|
|
37
|
-
'H4sIAAAAAAAAA-3OMQ0AAAgDsOHfNB72EJJWQRMAAAAAAIDWXAcAAAAAAIDHFrc4zDz' +
|
|
38
|
-
'UMAAA';
|
|
39
|
-
const key = fs.readFileSync(__dirname + '/key.pem');
|
|
40
|
-
const cert = fs.readFileSync(__dirname + '/cert.pem');
|
|
41
|
-
|
|
42
|
-
let slCredentialRevocation;
|
|
43
|
-
let unsignedCredentialSl2021TypeRevocation;
|
|
44
|
-
let slCredentialSuspension;
|
|
45
|
-
let unsignedCredentialSl2021TypeSuspension;
|
|
46
|
-
let unsignedCredentialSl2021WithUnmatchingStatusPurpose;
|
|
47
|
-
let revokedSlCredential;
|
|
48
|
-
let revokedUnsignedCredential;
|
|
49
|
-
let rlCredential;
|
|
50
|
-
let unsignedCredentialRL2020Type;
|
|
51
|
-
let revokedRlCredential;
|
|
52
|
-
let revokedUnsignedCredential2;
|
|
53
|
-
|
|
54
|
-
// load docs from test server (e.g., load RL VCs and SL VCs)
|
|
55
|
-
let testServerBaseUrl;
|
|
56
|
-
async function _documentLoader(url) {
|
|
57
|
-
if(url.startsWith(testServerBaseUrl)) {
|
|
58
|
-
const response = await httpClient.get(url, {agent});
|
|
59
|
-
return {
|
|
60
|
-
contextUrl: null,
|
|
61
|
-
documentUrl: url,
|
|
62
|
-
document: response.data
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
return brDocLoader(url);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function _startServer({app}) {
|
|
69
|
-
return new Promise(resolve => {
|
|
70
|
-
const server = https.createServer({key, cert}, app);
|
|
71
|
-
server.listen(() => {
|
|
72
|
-
const {port} = server.address();
|
|
73
|
-
const BASE_URL = `https://localhost:${port}`;
|
|
74
|
-
testServerBaseUrl = BASE_URL;
|
|
75
|
-
console.log(`Test server listening at ${BASE_URL}`);
|
|
76
|
-
|
|
77
|
-
// Status List 2021 Credential with statusPurpose `revocation`
|
|
78
|
-
slCredentialRevocation = {
|
|
79
|
-
'@context': [
|
|
80
|
-
'https://www.w3.org/2018/credentials/v1',
|
|
81
|
-
VC_SL_CONTEXT_URL
|
|
82
|
-
],
|
|
83
|
-
id: `${BASE_URL}/status/748a7d8e-9111-11ec-a934-10bf48838a41`,
|
|
84
|
-
issuer: 'did:key:z6Mktpn6cXks1PBKLMgZH2VaahvCtBMF6K8eCa7HzrnuYLZv',
|
|
85
|
-
issuanceDate: '2022-01-10T04:24:12.164Z',
|
|
86
|
-
type: ['VerifiableCredential', 'StatusList2021Credential'],
|
|
87
|
-
credentialSubject: {
|
|
88
|
-
id: `${BASE_URL}/status/748a7d8e-9111-11ec-a934-10bf48838a41#list`,
|
|
89
|
-
type: 'StatusList2021',
|
|
90
|
-
statusPurpose: 'revocation',
|
|
91
|
-
encodedList: encodedList100k
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
// Unsigned 2021 Credential with "credentialStatus.statusPurpose"
|
|
96
|
-
// `revocation`
|
|
97
|
-
unsignedCredentialSl2021TypeRevocation = {
|
|
98
|
-
'@context': [
|
|
99
|
-
'https://www.w3.org/2018/credentials/v1',
|
|
100
|
-
VC_SL_CONTEXT_URL,
|
|
101
|
-
'https://w3id.org/security/suites/ed25519-2020/v1'
|
|
102
|
-
],
|
|
103
|
-
id: 'urn:uuid:a0418a78-7924-11ea-8a23-10bf48838a41',
|
|
104
|
-
type: ['VerifiableCredential', 'example:TestCredential'],
|
|
105
|
-
credentialSubject: {
|
|
106
|
-
id: 'urn:uuid:4886029a-7925-11ea-9274-10bf48838a41',
|
|
107
|
-
'example:test': 'foo'
|
|
108
|
-
},
|
|
109
|
-
credentialStatus: {
|
|
110
|
-
id: `${BASE_URL}/status/748a7d8e-9111-11ec-a934-10bf48838a41#67342`,
|
|
111
|
-
type: 'StatusList2021Entry',
|
|
112
|
-
statusPurpose: 'revocation',
|
|
113
|
-
statusListIndex: '67342',
|
|
114
|
-
statusListCredential: slCredentialRevocation.id
|
|
115
|
-
},
|
|
116
|
-
issuer: slCredentialRevocation.issuer,
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
// Status List 2021 Credential with statusPurpose `suspension`
|
|
120
|
-
slCredentialSuspension = {
|
|
121
|
-
'@context': [
|
|
122
|
-
'https://www.w3.org/2018/credentials/v1',
|
|
123
|
-
VC_SL_CONTEXT_URL
|
|
124
|
-
],
|
|
125
|
-
id: `${BASE_URL}/status/5d3e7a97-1121-11ec-9b38-10bf48838a41`,
|
|
126
|
-
issuer: 'did:key:z6Mktpn6cXks1PBKLMgZH2VaahvCtBMF6K8eCa7HzrnuYLZv',
|
|
127
|
-
issuanceDate: '2022-01-10T04:24:12.164Z',
|
|
128
|
-
type: ['VerifiableCredential', 'StatusList2021Credential'],
|
|
129
|
-
credentialSubject: {
|
|
130
|
-
id: `${BASE_URL}/status/5d3e7a97-1121-11ec-9b38-10bf48838a41#list`,
|
|
131
|
-
type: 'StatusList2021',
|
|
132
|
-
statusPurpose: 'suspension',
|
|
133
|
-
encodedList: encodedList100k
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
// Unsigned 2021 Credential with "credentialStatus.statusPurpose"
|
|
138
|
-
// `suspension`
|
|
139
|
-
unsignedCredentialSl2021TypeSuspension = {
|
|
140
|
-
'@context': [
|
|
141
|
-
'https://www.w3.org/2018/credentials/v1',
|
|
142
|
-
VC_SL_CONTEXT_URL,
|
|
143
|
-
'https://w3id.org/security/suites/ed25519-2020/v1'
|
|
144
|
-
],
|
|
145
|
-
id: 'urn:uuid:a0418a78-7924-11ea-8a23-10bf48838a41',
|
|
146
|
-
type: ['VerifiableCredential', 'example:TestCredential'],
|
|
147
|
-
credentialSubject: {
|
|
148
|
-
id: 'urn:uuid:4886029a-7925-11ea-9274-10bf48838a41',
|
|
149
|
-
'example:test': 'foo'
|
|
150
|
-
},
|
|
151
|
-
credentialStatus: {
|
|
152
|
-
id: `${BASE_URL}/status/5d3e7a97-1121-11ec-9b38-10bf48838a41#67342`,
|
|
153
|
-
type: 'StatusList2021Entry',
|
|
154
|
-
statusPurpose: 'suspension',
|
|
155
|
-
statusListIndex: '67342',
|
|
156
|
-
statusListCredential: slCredentialSuspension.id
|
|
157
|
-
},
|
|
158
|
-
issuer: slCredentialSuspension.issuer,
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
// Unsigned 2021 Credential with unmatching status purpose
|
|
162
|
-
unsignedCredentialSl2021WithUnmatchingStatusPurpose = {
|
|
163
|
-
'@context': [
|
|
164
|
-
'https://www.w3.org/2018/credentials/v1',
|
|
165
|
-
VC_SL_CONTEXT_URL,
|
|
166
|
-
'https://w3id.org/security/suites/ed25519-2020/v1'
|
|
167
|
-
],
|
|
168
|
-
id: 'urn:uuid:a0418a78-7924-11ea-8a23-10bf48838a41',
|
|
169
|
-
type: ['VerifiableCredential', 'example:TestCredential'],
|
|
170
|
-
credentialSubject: {
|
|
171
|
-
id: 'urn:uuid:4886029a-7925-11ea-9274-10bf48838a41',
|
|
172
|
-
'example:test': 'foo'
|
|
173
|
-
},
|
|
174
|
-
credentialStatus: {
|
|
175
|
-
id: `${BASE_URL}/status/748a7d8e-9111-11ec-a934-10bf48838a41#67342`,
|
|
176
|
-
type: 'StatusList2021Entry',
|
|
177
|
-
// intentionally set status purpose that does not match status purpose
|
|
178
|
-
// of sl credential that it fetches.
|
|
179
|
-
statusPurpose: 'suspension',
|
|
180
|
-
statusListIndex: '67342',
|
|
181
|
-
// intentionally point `statusListCredential` to a sl credential
|
|
182
|
-
// with status purpose `revocation`.
|
|
183
|
-
statusListCredential: slCredentialRevocation.id
|
|
184
|
-
},
|
|
185
|
-
issuer: slCredentialRevocation.issuer,
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
// Revoked Status List 2021 Credential
|
|
189
|
-
revokedSlCredential = klona(slCredentialRevocation);
|
|
190
|
-
|
|
191
|
-
revokedSlCredential.id =
|
|
192
|
-
`${BASE_URL}/status/8ec30054-9111-11ec-9ab5-10bf48838a41`,
|
|
193
|
-
revokedSlCredential.credentialSubject.encodedList =
|
|
194
|
-
encodedList100KWith50KthRevoked;
|
|
195
|
-
revokedSlCredential.credentialSubject.id =
|
|
196
|
-
`${BASE_URL}/status/8ec30054-9111-11ec-9ab5-10bf48838a41#list`;
|
|
197
|
-
|
|
198
|
-
// Revoked Unsigned 2021 Credential
|
|
199
|
-
revokedUnsignedCredential = klona(unsignedCredentialSl2021TypeRevocation);
|
|
200
|
-
revokedUnsignedCredential.credentialStatus.id =
|
|
201
|
-
`${revokedSlCredential.id}#50000`;
|
|
202
|
-
revokedUnsignedCredential.credentialStatus.statusListIndex = 50000;
|
|
203
|
-
revokedUnsignedCredential.credentialStatus.statusListCredential =
|
|
204
|
-
`${revokedSlCredential.id}`;
|
|
205
|
-
revokedUnsignedCredential.issuer = revokedSlCredential.issuer;
|
|
206
|
-
|
|
207
|
-
// Revocation List 2020 Credential
|
|
208
|
-
rlCredential = {
|
|
209
|
-
'@context': [
|
|
210
|
-
'https://www.w3.org/2018/credentials/v1',
|
|
211
|
-
VC_RL_CONTEXT_URL
|
|
212
|
-
],
|
|
213
|
-
id: `${BASE_URL}/status/9d5a3fb0-9111-11ec-862d-10bf48838a41`,
|
|
214
|
-
issuer: 'did:key:z6Mktpn6cXks1PBKLMgZH2VaahvCtBMF6K8eCa7HzrnuYLZv',
|
|
215
|
-
issuanceDate: '2022-01-10T04:24:12.164Z',
|
|
216
|
-
type: ['VerifiableCredential', 'RevocationList2020Credential'],
|
|
217
|
-
credentialSubject: {
|
|
218
|
-
id: `${BASE_URL}/status/9d5a3fb0-9111-11ec-862d-10bf48838a41#list`,
|
|
219
|
-
type: 'RevocationList2020',
|
|
220
|
-
encodedList: encodedList100k
|
|
221
|
-
}
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
// Unsigned 2020 Credential
|
|
225
|
-
unsignedCredentialRL2020Type = {
|
|
226
|
-
'@context': [
|
|
227
|
-
'https://www.w3.org/2018/credentials/v1',
|
|
228
|
-
VC_RL_CONTEXT_URL,
|
|
229
|
-
'https://w3id.org/security/suites/ed25519-2020/v1'
|
|
230
|
-
],
|
|
231
|
-
id: 'urn:uuid:a0418a78-7924-11ea-8a23-10bf48838a41',
|
|
232
|
-
type: ['VerifiableCredential', 'example:TestCredential'],
|
|
233
|
-
credentialSubject: {
|
|
234
|
-
id: 'urn:uuid:4886029a-7925-11ea-9274-10bf48838a41',
|
|
235
|
-
'example:test': 'foo'
|
|
236
|
-
},
|
|
237
|
-
issuanceDate: '2022-01-11T19:23:24Z',
|
|
238
|
-
credentialStatus: {
|
|
239
|
-
id: `${BASE_URL}/status/9d5a3fb0-9111-11ec-862d-10bf48838a41#67342`,
|
|
240
|
-
type: 'RevocationList2020Status',
|
|
241
|
-
revocationListIndex: '67342',
|
|
242
|
-
revocationListCredential: rlCredential.id
|
|
243
|
-
},
|
|
244
|
-
issuer: rlCredential.issuer,
|
|
245
|
-
};
|
|
246
|
-
|
|
247
|
-
// Revoked Revocation List 2020 Credential
|
|
248
|
-
revokedRlCredential = klona(rlCredential);
|
|
249
|
-
|
|
250
|
-
revokedRlCredential.id =
|
|
251
|
-
`${BASE_URL}/status/a63896b8-9111-11ec-9fd2-10bf48838a41`,
|
|
252
|
-
revokedRlCredential.credentialSubject.encodedList =
|
|
253
|
-
encodedList100KWith50KthRevoked;
|
|
254
|
-
revokedRlCredential.credentialSubject.id =
|
|
255
|
-
`${BASE_URL}/status/a63896b8-9111-11ec-9fd2-10bf48838a41#list`;
|
|
256
|
-
|
|
257
|
-
// Revoked Unsigned 2020 Credential
|
|
258
|
-
revokedUnsignedCredential2 = klona(unsignedCredentialRL2020Type);
|
|
259
|
-
revokedUnsignedCredential2.credentialStatus.id =
|
|
260
|
-
`${revokedRlCredential.id}#50000`;
|
|
261
|
-
revokedUnsignedCredential2.credentialStatus.revocationListIndex = 50000;
|
|
262
|
-
revokedUnsignedCredential2.credentialStatus.revocationListCredential =
|
|
263
|
-
`${revokedRlCredential.id}`;
|
|
264
|
-
revokedUnsignedCredential2.issuer = revokedRlCredential.issuer;
|
|
265
|
-
|
|
266
|
-
return resolve(server);
|
|
267
|
-
});
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
const app = express();
|
|
272
|
-
app.use(express.json());
|
|
273
|
-
|
|
274
|
-
// mount the test routes
|
|
275
|
-
app.get('/status/748a7d8e-9111-11ec-a934-10bf48838a41',
|
|
276
|
-
// eslint-disable-next-line no-unused-vars
|
|
277
|
-
(req, res, next) => {
|
|
278
|
-
// responds with a valid status list 2021 type credential
|
|
279
|
-
res.json(slCredentialRevocation);
|
|
280
|
-
});
|
|
281
|
-
app.get('/status/5d3e7a97-1121-11ec-9b38-10bf48838a41',
|
|
282
|
-
// eslint-disable-next-line no-unused-vars
|
|
283
|
-
(req, res, next) => {
|
|
284
|
-
// responds with a valid status list 2021 type credential
|
|
285
|
-
res.json(slCredentialSuspension);
|
|
286
|
-
});
|
|
287
|
-
app.get('/status/8ec30054-9111-11ec-9ab5-10bf48838a41',
|
|
288
|
-
// eslint-disable-next-line no-unused-vars
|
|
289
|
-
(req, res, next) => {
|
|
290
|
-
// responds with a revoked status list 2021 type credential
|
|
291
|
-
res.json(revokedSlCredential);
|
|
292
|
-
});
|
|
293
|
-
app.get('/status/9d5a3fb0-9111-11ec-862d-10bf48838a41',
|
|
294
|
-
// eslint-disable-next-line no-unused-vars
|
|
295
|
-
(req, res, next) => {
|
|
296
|
-
// responds with a valid revocation list 2020 type credential
|
|
297
|
-
res.json(rlCredential);
|
|
298
|
-
});
|
|
299
|
-
app.get('/status/a63896b8-9111-11ec-9fd2-10bf48838a41',
|
|
300
|
-
// eslint-disable-next-line no-unused-vars
|
|
301
|
-
(req, res, next) => {
|
|
302
|
-
// responds with a revoked revocation list 2020 type credential
|
|
303
|
-
res.json(revokedRlCredential);
|
|
304
|
-
});
|
|
305
|
-
let server;
|
|
306
|
-
before(async () => {
|
|
307
|
-
server = await _startServer({app});
|
|
308
|
-
});
|
|
309
|
-
after(async () => {
|
|
310
|
-
server.close();
|
|
311
|
-
});
|
|
312
|
-
|
|
313
|
-
describe('verify credential status', () => {
|
|
314
|
-
let keyData;
|
|
315
|
-
let keyPair;
|
|
316
|
-
let suite;
|
|
317
|
-
before(async () => {
|
|
318
|
-
keyData = {
|
|
319
|
-
id: 'did:key:z6Mktpn6cXks1PBKLMgZH2VaahvCtBMF6K8eCa7HzrnuYLZv#' +
|
|
320
|
-
'z6Mktpn6cXks1PBKLMgZH2VaahvCtBMF6K8eCa7HzrnuYLZv',
|
|
321
|
-
controller: 'did:key:z6Mktpn6cXks1PBKLMgZH2VaahvCtBMF6K8eCa7HzrnuYLZv',
|
|
322
|
-
type: 'Ed25519VerificationKey2020',
|
|
323
|
-
publicKeyMultibase: 'z6Mktpn6cXks1PBKLMgZH2VaahvCtBMF6K8eCa7HzrnuYLZv',
|
|
324
|
-
privateKeyMultibase: 'zrv2rP9yjtz3YwCas9m6hnoPxmoqZV72xbCEuomXi4wwSS' +
|
|
325
|
-
'4ShekesADYiAMHoxoqfyBDKQowGMvYx9rp6QGJ7Qbk7Y4'
|
|
326
|
-
};
|
|
327
|
-
keyPair = await Ed25519VerificationKey2020.from(keyData);
|
|
328
|
-
suite = new Ed25519Signature2020({key: keyPair});
|
|
329
|
-
});
|
|
330
|
-
let capabilityAgent;
|
|
331
|
-
let verifierConfig;
|
|
332
|
-
let verifierId;
|
|
333
|
-
let rootZcap;
|
|
334
|
-
const zcaps = {};
|
|
335
|
-
beforeEach(async () => {
|
|
336
|
-
const secret = '53ad64ce-8e1d-11ec-bb12-10bf48838a41';
|
|
337
|
-
const handle = 'test';
|
|
338
|
-
capabilityAgent = await CapabilityAgent.fromSecret({secret, handle});
|
|
339
|
-
|
|
340
|
-
// create keystore for capability agent
|
|
341
|
-
const keystoreAgent = await helpers.createKeystoreAgent(
|
|
342
|
-
{capabilityAgent});
|
|
343
|
-
|
|
344
|
-
// create EDV for storage (creating hmac and kak in the process)
|
|
345
|
-
const {
|
|
346
|
-
edvConfig,
|
|
347
|
-
hmac,
|
|
348
|
-
keyAgreementKey
|
|
349
|
-
} = await helpers.createEdv({capabilityAgent, keystoreAgent});
|
|
350
|
-
|
|
351
|
-
// get service agent to delegate to
|
|
352
|
-
const serviceAgentUrl =
|
|
353
|
-
`${baseUrl}/service-agents/${encodeURIComponent(serviceType)}`;
|
|
354
|
-
const {data: serviceAgent} = await httpClient.get(serviceAgentUrl, {
|
|
355
|
-
agent
|
|
356
|
-
});
|
|
357
|
-
|
|
358
|
-
// delegate edv, hmac, and key agreement key zcaps to service agent
|
|
359
|
-
const {id: edvId} = edvConfig;
|
|
360
|
-
zcaps.edv = await helpers.delegate({
|
|
361
|
-
controller: serviceAgent.id,
|
|
362
|
-
delegator: capabilityAgent,
|
|
363
|
-
invocationTarget: edvId
|
|
364
|
-
});
|
|
365
|
-
const {keystoreId} = keystoreAgent;
|
|
366
|
-
zcaps.hmac = await helpers.delegate({
|
|
367
|
-
capability: `urn:zcap:root:${encodeURIComponent(keystoreId)}`,
|
|
368
|
-
controller: serviceAgent.id,
|
|
369
|
-
invocationTarget: hmac.id,
|
|
370
|
-
delegator: capabilityAgent
|
|
371
|
-
});
|
|
372
|
-
zcaps.keyAgreementKey = await helpers.delegate({
|
|
373
|
-
capability: `urn:zcap:root:${encodeURIComponent(keystoreId)}`,
|
|
374
|
-
controller: serviceAgent.id,
|
|
375
|
-
invocationTarget: keyAgreementKey.kmsId,
|
|
376
|
-
delegator: capabilityAgent
|
|
377
|
-
});
|
|
378
|
-
|
|
379
|
-
// create verifier instance
|
|
380
|
-
verifierConfig = await helpers.createConfig({capabilityAgent, zcaps});
|
|
381
|
-
verifierId = verifierConfig.id;
|
|
382
|
-
rootZcap = `urn:zcap:root:${encodeURIComponent(verifierId)}`;
|
|
383
|
-
});
|
|
384
|
-
it('should verify "StatusList2021Credential" type with "statusPurpose" ' +
|
|
385
|
-
'revocation', async () => {
|
|
386
|
-
slCredentialRevocation = await vc.issue({
|
|
387
|
-
credential: slCredentialRevocation,
|
|
388
|
-
documentLoader: _documentLoader,
|
|
389
|
-
suite
|
|
390
|
-
});
|
|
391
|
-
const verifiableCredential = await vc.issue({
|
|
392
|
-
credential: unsignedCredentialSl2021TypeRevocation,
|
|
393
|
-
documentLoader: _documentLoader,
|
|
394
|
-
suite
|
|
395
|
-
});
|
|
396
|
-
let error;
|
|
397
|
-
let result;
|
|
398
|
-
try {
|
|
399
|
-
const zcapClient = helpers.createZcapClient({capabilityAgent});
|
|
400
|
-
result = await zcapClient.write({
|
|
401
|
-
url: `${verifierId}/credentials/verify`,
|
|
402
|
-
capability: rootZcap,
|
|
403
|
-
json: {
|
|
404
|
-
options: {
|
|
405
|
-
checks: ['proof', 'credentialStatus'],
|
|
406
|
-
},
|
|
407
|
-
verifiableCredential
|
|
408
|
-
}
|
|
409
|
-
});
|
|
410
|
-
} catch(e) {
|
|
411
|
-
error = e;
|
|
412
|
-
}
|
|
413
|
-
assertNoError(error);
|
|
414
|
-
should.exist(result.data.verified);
|
|
415
|
-
result.data.verified.should.be.a('boolean');
|
|
416
|
-
result.data.verified.should.equal(true);
|
|
417
|
-
const {checks} = result.data;
|
|
418
|
-
checks.should.be.an('array');
|
|
419
|
-
checks.should.have.length(2);
|
|
420
|
-
checks.should.be.an('array');
|
|
421
|
-
checks.should.eql(['proof', 'credentialStatus']);
|
|
422
|
-
should.exist(result.data.results);
|
|
423
|
-
result.data.results.should.be.an('array');
|
|
424
|
-
result.data.results.should.have.length(1);
|
|
425
|
-
const [r] = result.data.results;
|
|
426
|
-
r.verified.should.be.a('boolean');
|
|
427
|
-
r.verified.should.equal(true);
|
|
428
|
-
});
|
|
429
|
-
it('should verify "StatusList2021Credential" type with "statusPurpose" ' +
|
|
430
|
-
'suspension', async () => {
|
|
431
|
-
slCredentialSuspension = await vc.issue({
|
|
432
|
-
credential: slCredentialSuspension,
|
|
433
|
-
documentLoader: _documentLoader,
|
|
434
|
-
suite
|
|
435
|
-
});
|
|
436
|
-
const verifiableCredential = await vc.issue({
|
|
437
|
-
credential: unsignedCredentialSl2021TypeSuspension,
|
|
438
|
-
documentLoader: _documentLoader,
|
|
439
|
-
suite
|
|
440
|
-
});
|
|
441
|
-
let error;
|
|
442
|
-
let result;
|
|
443
|
-
try {
|
|
444
|
-
const zcapClient = helpers.createZcapClient({capabilityAgent});
|
|
445
|
-
result = await zcapClient.write({
|
|
446
|
-
url: `${verifierId}/credentials/verify`,
|
|
447
|
-
capability: rootZcap,
|
|
448
|
-
json: {
|
|
449
|
-
options: {
|
|
450
|
-
checks: ['proof', 'credentialStatus'],
|
|
451
|
-
},
|
|
452
|
-
verifiableCredential
|
|
453
|
-
}
|
|
454
|
-
});
|
|
455
|
-
} catch(e) {
|
|
456
|
-
error = e;
|
|
457
|
-
}
|
|
458
|
-
assertNoError(error);
|
|
459
|
-
should.exist(result.data.verified);
|
|
460
|
-
result.data.verified.should.be.a('boolean');
|
|
461
|
-
result.data.verified.should.equal(true);
|
|
462
|
-
const {checks} = result.data;
|
|
463
|
-
checks.should.be.an('array');
|
|
464
|
-
checks.should.have.length(2);
|
|
465
|
-
checks.should.be.an('array');
|
|
466
|
-
checks.should.eql(['proof', 'credentialStatus']);
|
|
467
|
-
should.exist(result.data.results);
|
|
468
|
-
result.data.results.should.be.an('array');
|
|
469
|
-
result.data.results.should.have.length(1);
|
|
470
|
-
const [r] = result.data.results;
|
|
471
|
-
r.verified.should.be.a('boolean');
|
|
472
|
-
r.verified.should.equal(true);
|
|
473
|
-
});
|
|
474
|
-
it('should throw error if "statusPurpose" of the slCredential does not ' +
|
|
475
|
-
'match the "statusPurpose" of the credentialStatus', async () => {
|
|
476
|
-
slCredentialRevocation = await vc.issue({
|
|
477
|
-
credential: slCredentialRevocation,
|
|
478
|
-
documentLoader: _documentLoader,
|
|
479
|
-
suite
|
|
480
|
-
});
|
|
481
|
-
const verifiableCredential = await vc.issue({
|
|
482
|
-
credential: unsignedCredentialSl2021WithUnmatchingStatusPurpose,
|
|
483
|
-
documentLoader: _documentLoader,
|
|
484
|
-
suite
|
|
485
|
-
});
|
|
486
|
-
let error;
|
|
487
|
-
let result;
|
|
488
|
-
try {
|
|
489
|
-
const zcapClient = helpers.createZcapClient({capabilityAgent});
|
|
490
|
-
result = await zcapClient.write({
|
|
491
|
-
url: `${verifierId}/credentials/verify`,
|
|
492
|
-
capability: rootZcap,
|
|
493
|
-
json: {
|
|
494
|
-
options: {
|
|
495
|
-
checks: ['proof', 'credentialStatus'],
|
|
496
|
-
},
|
|
497
|
-
verifiableCredential
|
|
498
|
-
}
|
|
499
|
-
});
|
|
500
|
-
} catch(e) {
|
|
501
|
-
error = e;
|
|
502
|
-
}
|
|
503
|
-
should.exist(error);
|
|
504
|
-
should.not.exist(result);
|
|
505
|
-
error.data.verified.should.equal(false);
|
|
506
|
-
const {error: {cause: errorCause}} = error.data;
|
|
507
|
-
errorCause.should.equal(
|
|
508
|
-
'The status purpose "revocation" of the status list credential ' +
|
|
509
|
-
'does not match the status purpose "suspension" in the credential.');
|
|
510
|
-
});
|
|
511
|
-
it('should fail to verify a revoked "StatusList2021Credential" type',
|
|
512
|
-
async () => {
|
|
513
|
-
revokedSlCredential = await vc.issue({
|
|
514
|
-
credential: revokedSlCredential,
|
|
515
|
-
documentLoader: _documentLoader,
|
|
516
|
-
suite
|
|
517
|
-
});
|
|
518
|
-
const verifiableCredential = await vc.issue({
|
|
519
|
-
credential: revokedUnsignedCredential,
|
|
520
|
-
documentLoader: _documentLoader,
|
|
521
|
-
suite
|
|
522
|
-
});
|
|
523
|
-
let error;
|
|
524
|
-
let result;
|
|
525
|
-
try {
|
|
526
|
-
const zcapClient = helpers.createZcapClient({capabilityAgent});
|
|
527
|
-
result = await zcapClient.write({
|
|
528
|
-
url: `${verifierId}/credentials/verify`,
|
|
529
|
-
capability: rootZcap,
|
|
530
|
-
json: {
|
|
531
|
-
options: {
|
|
532
|
-
checks: ['credentialStatus'],
|
|
533
|
-
},
|
|
534
|
-
verifiableCredential
|
|
535
|
-
}
|
|
536
|
-
});
|
|
537
|
-
} catch(e) {
|
|
538
|
-
error = e;
|
|
539
|
-
}
|
|
540
|
-
should.exist(error);
|
|
541
|
-
should.not.exist(result);
|
|
542
|
-
error.data.verified.should.be.a('boolean');
|
|
543
|
-
error.data.verified.should.equal(false);
|
|
544
|
-
const {checks, error: {message: errorMsg}} = error.data;
|
|
545
|
-
checks.should.be.an('array');
|
|
546
|
-
checks.should.have.length(1);
|
|
547
|
-
errorMsg.should.equal('The credential failed a status check.');
|
|
548
|
-
error.data.statusResult.verified.should.equal(false);
|
|
549
|
-
const [{check}] = checks;
|
|
550
|
-
check.should.be.an('array');
|
|
551
|
-
check.should.eql(['credentialStatus']);
|
|
552
|
-
should.exist(error.data.results);
|
|
553
|
-
error.data.results.should.be.an('array');
|
|
554
|
-
error.data.results.should.have.length(1);
|
|
555
|
-
const [r] = error.data.results;
|
|
556
|
-
r.verified.should.be.a('boolean');
|
|
557
|
-
r.verified.should.equal(true);
|
|
558
|
-
});
|
|
559
|
-
it('should verify "RevocationList2020Credential" type', async () => {
|
|
560
|
-
rlCredential = await vc.issue({
|
|
561
|
-
credential: rlCredential,
|
|
562
|
-
documentLoader: _documentLoader,
|
|
563
|
-
suite
|
|
564
|
-
});
|
|
565
|
-
const verifiableCredential = await vc.issue({
|
|
566
|
-
credential: unsignedCredentialRL2020Type,
|
|
567
|
-
documentLoader: _documentLoader,
|
|
568
|
-
suite
|
|
569
|
-
});
|
|
570
|
-
let error;
|
|
571
|
-
let result;
|
|
572
|
-
try {
|
|
573
|
-
const zcapClient = helpers.createZcapClient({capabilityAgent});
|
|
574
|
-
result = await zcapClient.write({
|
|
575
|
-
url: `${verifierId}/credentials/verify`,
|
|
576
|
-
capability: rootZcap,
|
|
577
|
-
json: {
|
|
578
|
-
options: {
|
|
579
|
-
checks: ['proof', 'credentialStatus'],
|
|
580
|
-
},
|
|
581
|
-
verifiableCredential
|
|
582
|
-
}
|
|
583
|
-
});
|
|
584
|
-
} catch(e) {
|
|
585
|
-
error = e;
|
|
586
|
-
}
|
|
587
|
-
should.not.exist(error);
|
|
588
|
-
should.exist(result.data.verified);
|
|
589
|
-
result.data.verified.should.be.a('boolean');
|
|
590
|
-
result.data.verified.should.equal(true);
|
|
591
|
-
const {checks} = result.data;
|
|
592
|
-
checks.should.be.an('array');
|
|
593
|
-
checks.should.have.length(2);
|
|
594
|
-
checks.should.be.an('array');
|
|
595
|
-
checks.should.eql(['proof', 'credentialStatus']);
|
|
596
|
-
should.exist(result.data.results);
|
|
597
|
-
result.data.results.should.be.an('array');
|
|
598
|
-
result.data.results.should.have.length(1);
|
|
599
|
-
const [r] = result.data.results;
|
|
600
|
-
r.verified.should.be.a('boolean');
|
|
601
|
-
r.verified.should.equal(true);
|
|
602
|
-
});
|
|
603
|
-
it('should fail to verify a revoked "RevocationList2020Credential" type',
|
|
604
|
-
async () => {
|
|
605
|
-
revokedRlCredential = await vc.issue({
|
|
606
|
-
credential: revokedRlCredential,
|
|
607
|
-
documentLoader: _documentLoader,
|
|
608
|
-
suite
|
|
609
|
-
});
|
|
610
|
-
const verifiableCredential = await vc.issue({
|
|
611
|
-
credential: revokedUnsignedCredential2,
|
|
612
|
-
documentLoader: _documentLoader,
|
|
613
|
-
suite
|
|
614
|
-
});
|
|
615
|
-
let error;
|
|
616
|
-
let result;
|
|
617
|
-
try {
|
|
618
|
-
const zcapClient = helpers.createZcapClient({capabilityAgent});
|
|
619
|
-
result = await zcapClient.write({
|
|
620
|
-
url: `${verifierId}/credentials/verify`,
|
|
621
|
-
capability: rootZcap,
|
|
622
|
-
json: {
|
|
623
|
-
options: {
|
|
624
|
-
checks: ['credentialStatus'],
|
|
625
|
-
},
|
|
626
|
-
verifiableCredential
|
|
627
|
-
}
|
|
628
|
-
});
|
|
629
|
-
} catch(e) {
|
|
630
|
-
error = e;
|
|
631
|
-
}
|
|
632
|
-
should.exist(error);
|
|
633
|
-
should.not.exist(result);
|
|
634
|
-
error.data.verified.should.be.a('boolean');
|
|
635
|
-
error.data.verified.should.equal(false);
|
|
636
|
-
const {checks, error: {message: errorMsg}} = error.data;
|
|
637
|
-
checks.should.be.an('array');
|
|
638
|
-
checks.should.have.length(1);
|
|
639
|
-
errorMsg.should.equal('The credential failed a status check.');
|
|
640
|
-
error.data.statusResult.verified.should.equal(false);
|
|
641
|
-
const [{check}] = checks;
|
|
642
|
-
check.should.be.an('array');
|
|
643
|
-
check.should.eql(['credentialStatus']);
|
|
644
|
-
should.exist(error.data.results);
|
|
645
|
-
error.data.results.should.be.an('array');
|
|
646
|
-
error.data.results.should.have.length(1);
|
|
647
|
-
const [r] = error.data.results;
|
|
648
|
-
r.verified.should.be.a('boolean');
|
|
649
|
-
r.verified.should.equal(true);
|
|
650
|
-
});
|
|
651
|
-
});
|
package/test/mocha/cert.pem
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
-----BEGIN CERTIFICATE-----
|
|
2
|
-
MIIC8zCCAdugAwIBAgIJAJ+LafmOp1a0MA0GCSqGSIb3DQEBCwUAMCgxJjAkBgNV
|
|
3
|
-
BAMMHWJlZHJvY2stdmMtdmVyaWZpZXIubG9jYWxob3N0MB4XDTIyMDIwMzA1MzU1
|
|
4
|
-
NloXDTQ5MDYyMTA1MzU1NlowKDEmMCQGA1UEAwwdYmVkcm9jay12Yy12ZXJpZmll
|
|
5
|
-
ci5sb2NhbGhvc3QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC5egV0
|
|
6
|
-
Yz8iZziLp5HNSiIfMISiDd/wqArJKJjr9aY96Sa9cVLSBt+4xJrAxKpCVlgAl/6Z
|
|
7
|
-
NnVrftZ+SwqBvQ9I2WlodQhu4Gs1ImrSj44P+SooyGO6IT1mhZMt++0oUj/ZjdaI
|
|
8
|
-
oFaNjzKoD1N0RLdI5l6lSSbO/E86sXMX9tHGrjSElMO0EF5dXPLMLrRFjRQ4md81
|
|
9
|
-
9aKpH8ObyCI02wRK8j2LI8Cfqka0kxdxQSLQ4z5yDsb3ajd5avJzgCEprOOvwy36
|
|
10
|
-
dvtuT11XpstS0Sqgwk1BRhYvYn99H4euSwx9BpoA6GiVM2OaI4SctpvfGxbnhh0Z
|
|
11
|
-
5SU+JaxJxPAnQe9JAgMBAAGjIDAeMBwGA1UdEQQVMBOCEWJlZHJvY2subG9jYWxo
|
|
12
|
-
b3N0MA0GCSqGSIb3DQEBCwUAA4IBAQANK3NiEcnhY+bRZymEAJKzy6Ar1vxAsko2
|
|
13
|
-
qOtP4/gB9bqBhQLoWRGL66rJ+l2ixNEuK9ammOx6LgRtvDgF/kXovcJyJJtf3FrE
|
|
14
|
-
afr9BpWmyIhRW1zGBK/kTz8lB0kHYbE650cAzCK4+pcIxXl3v5HWvAoxUCraVZzB
|
|
15
|
-
aggd9ATR0wgGP4dDhUWMDEW9T2GbFSilIW6k7WUpadBUtQb6NzaF3DSUw3jl4LXN
|
|
16
|
-
FL/PIWj81f6Uskt0qhDTzVRrn+LgrJklhazvuWpasItEM0WeJRKGp7GcoylASrYx
|
|
17
|
-
SwxnpYemqVJ2dTwwkDQfFg/aSyYNwNohywUngRJdDdQOLQQbfrxm
|
|
18
|
-
-----END CERTIFICATE-----
|