@velocitycareerlabs/data-loader 1.24.0-dev-build.1f3067cef → 1.24.0-dev-build.16c8205cb
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/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@velocitycareerlabs/data-loader",
|
3
|
-
"version": "1.24.0-dev-build.
|
3
|
+
"version": "1.24.0-dev-build.16c8205cb",
|
4
4
|
"description": "A tool for uploading data to the different target systems.",
|
5
5
|
"repository": "https://github.com/velocitycareerlabs/packages",
|
6
6
|
"main": "src/index.js",
|
@@ -37,9 +37,9 @@
|
|
37
37
|
"got": "11.8.6",
|
38
38
|
"handlebars": "~4.7.7",
|
39
39
|
"inquirer": "^8.0.0",
|
40
|
-
"lodash": "
|
40
|
+
"lodash": "^4.17.21",
|
41
41
|
"nanoid": "3.3.8",
|
42
42
|
"strip-bom-stream": "^4.0.0"
|
43
43
|
},
|
44
|
-
"gitHead": "
|
44
|
+
"gitHead": "47219b1c7a582a35e430a2c2befe8cb674b0fea7"
|
45
45
|
}
|
@@ -30,9 +30,9 @@ Used for generating ready-to-claim qr-code from a csv that can be shared in orde
|
|
30
30
|
|
31
31
|
### Options
|
32
32
|
|
33
|
-
|
33
|
+
`--tenant [TENANT_ID]` **required** Id of the issuing organization's tenant
|
34
34
|
|
35
|
-
`-
|
35
|
+
`-d [DID]` **required** DID of the issuing organization
|
36
36
|
|
37
37
|
`-o [OFFER_TEMPLATE_PATH]` **required** path to an offer handlebars template. Use moustaches around variables such as `{{email}}`
|
38
38
|
|
@@ -3,10 +3,10 @@ const got = require('got');
|
|
3
3
|
const { map, isEmpty } = require('lodash/fp');
|
4
4
|
const { printInfo } = require('../helpers/common');
|
5
5
|
|
6
|
-
const setupGot = ({ endpoint, authToken }) => {
|
6
|
+
const setupGot = ({ endpoint, authToken, tenant }) => {
|
7
7
|
const options = {};
|
8
8
|
if (endpoint != null) {
|
9
|
-
options.prefixUrl = `${endpoint}/operator-api/v0.8`;
|
9
|
+
options.prefixUrl = `${endpoint}/operator-api/v0.8/tenants/${tenant}`;
|
10
10
|
}
|
11
11
|
if (authToken != null) {
|
12
12
|
options.headers = { Authorization: `Bearer ${authToken}` };
|
@@ -21,16 +21,11 @@ const setupGot = ({ endpoint, authToken }) => {
|
|
21
21
|
|
22
22
|
const initFetchers = (options) => {
|
23
23
|
const credentialAgentTenantGot = setupGot(options);
|
24
|
-
const param = getTenantsRouteParam(options);
|
25
24
|
return {
|
26
|
-
getTenant: async () => {
|
27
|
-
printInfo('Retrieving tenant');
|
28
|
-
return credentialAgentTenantGot.get(`tenants/${param}`).json();
|
29
|
-
},
|
30
25
|
createDisclosure: async (disclosureRequest) => {
|
31
26
|
printInfo('Creating disclosure');
|
32
27
|
return credentialAgentTenantGot
|
33
|
-
.post(
|
28
|
+
.post('disclosures', {
|
34
29
|
json: disclosureRequest,
|
35
30
|
})
|
36
31
|
.json();
|
@@ -38,7 +33,7 @@ const initFetchers = (options) => {
|
|
38
33
|
getDisclosureList: async (vendorEndpoints) => {
|
39
34
|
printInfo('Retrieving disclosure list');
|
40
35
|
const url = new URL(
|
41
|
-
|
36
|
+
'disclosures',
|
42
37
|
credentialAgentTenantGot.defaults.options.prefixUrl
|
43
38
|
);
|
44
39
|
|
@@ -52,14 +47,12 @@ const initFetchers = (options) => {
|
|
52
47
|
},
|
53
48
|
getDisclosure: async (disclosureId) => {
|
54
49
|
printInfo('Retrieving disclosure');
|
55
|
-
return credentialAgentTenantGot
|
56
|
-
.get(`tenants/${param}/disclosures/${disclosureId}`)
|
57
|
-
.json();
|
50
|
+
return credentialAgentTenantGot.get(`disclosures/${disclosureId}`).json();
|
58
51
|
},
|
59
52
|
createOfferExchange: async (newExchange) => {
|
60
53
|
printInfo('Creating exchange');
|
61
54
|
return credentialAgentTenantGot
|
62
|
-
.post(
|
55
|
+
.post('exchanges', {
|
63
56
|
json: newExchange,
|
64
57
|
})
|
65
58
|
.json();
|
@@ -69,7 +62,7 @@ const initFetchers = (options) => {
|
|
69
62
|
`Adding offer ${newOffer.offerId} to exchange id: ${exchange.id}`
|
70
63
|
);
|
71
64
|
return credentialAgentTenantGot
|
72
|
-
.post(`
|
65
|
+
.post(`exchanges/${exchange.id}/offers`, {
|
73
66
|
json: newOffer,
|
74
67
|
})
|
75
68
|
.json();
|
@@ -82,33 +75,32 @@ const initFetchers = (options) => {
|
|
82
75
|
)}`
|
83
76
|
);
|
84
77
|
return credentialAgentTenantGot
|
85
|
-
.post(`
|
78
|
+
.post(`exchanges/${exchange.id}/offers/complete`)
|
86
79
|
.json();
|
87
80
|
},
|
88
81
|
loadExchangeQrcode: async (exchange) =>
|
89
82
|
(
|
90
83
|
await credentialAgentTenantGot.get(
|
91
|
-
`
|
84
|
+
`exchanges/${exchange.id}/qrcode.png`
|
92
85
|
)
|
93
86
|
).rawBody,
|
94
87
|
loadExchangeDeeplink: async (exchange) =>
|
95
88
|
credentialAgentTenantGot
|
96
|
-
.get(`
|
89
|
+
.get(`exchanges/${exchange.id}/qrcode.uri`)
|
97
90
|
.text(),
|
98
91
|
loadDisclosureQrcode: async (disclosure) =>
|
99
92
|
(
|
100
93
|
await credentialAgentTenantGot.get(
|
101
|
-
`
|
94
|
+
`disclosures/${disclosure.id}/qrcode.png`
|
102
95
|
)
|
103
96
|
).rawBody,
|
104
97
|
loadDisclosureDeeplink: async (disclosure) =>
|
105
98
|
credentialAgentTenantGot
|
106
|
-
.get(`
|
99
|
+
.get(`disclosures/${disclosure.id}/qrcode.uri`)
|
107
100
|
.text(),
|
108
101
|
};
|
109
102
|
};
|
110
103
|
|
111
|
-
const getTenantsRouteParam = (options) => options.tenant ?? options.did;
|
112
104
|
module.exports = {
|
113
105
|
initFetchers,
|
114
106
|
};
|
@@ -21,6 +21,11 @@ program
|
|
21
21
|
'-o, --offer-template-filename <filename>',
|
22
22
|
'file name containing the credential template file'
|
23
23
|
)
|
24
|
+
.requiredOption('-d, --did <did>', "the issuer's DID")
|
25
|
+
.requiredOption(
|
26
|
+
'--tenant <tenantId>',
|
27
|
+
"Id of the issuing organization's tenant"
|
28
|
+
)
|
24
29
|
.requiredOption(
|
25
30
|
'-p, --path <path>',
|
26
31
|
'the output directory to use where QR codes and output state files are stored'
|
@@ -30,15 +35,7 @@ program
|
|
30
35
|
'the url to the T&Cs that holder must consent to'
|
31
36
|
)
|
32
37
|
.option(
|
33
|
-
'-
|
34
|
-
'DID of the issuing organization. One of `tenant` or `did` must be specified.'
|
35
|
-
)
|
36
|
-
.option(
|
37
|
-
'-n, --tenant <tenantId>',
|
38
|
-
"Id of the issuing organization's tenant. One of `tenant` or `did` must be specified."
|
39
|
-
)
|
40
|
-
.option(
|
41
|
-
'-m, --identifier-match-column <identifierMatchColumn>',
|
38
|
+
'-m --identifier-match-column <identifierMatchColumn>',
|
42
39
|
`the column from the CSV for the user to be matched against the ID credential's "identifier" property
|
43
40
|
For example this should be the email column if matching against an Email credential type, or the phone number if
|
44
41
|
matching against a Phone credential type. Accepts header name or index. Default is 0.`,
|
@@ -46,7 +43,7 @@ program
|
|
46
43
|
0
|
47
44
|
)
|
48
45
|
.option(
|
49
|
-
'-u
|
46
|
+
'-u --vendor-userid-column <vendorUseridColumn>',
|
50
47
|
`the column from the CSV that is users id. Value is made available as "vendorUserId" in the offer template. Accepts
|
51
48
|
header name or index. Default is 0.`,
|
52
49
|
parseColumn,
|
@@ -34,7 +34,7 @@ const runBatchIssuing = async (opts) => {
|
|
34
34
|
validateOptions(options);
|
35
35
|
|
36
36
|
const context = { fetchers: initFetchers(options) };
|
37
|
-
|
37
|
+
|
38
38
|
const [csvHeaders, csvRows] = await loadCsv(options.csvFilename);
|
39
39
|
|
40
40
|
const disclosureRequest = await loadOrPrepareNewDisclosureRequest(
|
@@ -204,20 +204,6 @@ const createDisclosureRequest = async (newDisclosureRequest, { fetchers }) => {
|
|
204
204
|
return fetchers.createDisclosure(newDisclosureRequest);
|
205
205
|
};
|
206
206
|
|
207
|
-
const setupDidOption = async (options, { fetchers }) => {
|
208
|
-
if (options.did != null) {
|
209
|
-
return;
|
210
|
-
}
|
211
|
-
let did = 'did to be determined at runtime';
|
212
|
-
if (options.dryrun == null) {
|
213
|
-
const tenant = await fetchers.getTenant();
|
214
|
-
// eslint-disable-next-line better-mutation/no-mutation
|
215
|
-
({ did } = tenant);
|
216
|
-
}
|
217
|
-
// eslint-disable-next-line better-mutation/no-mutation
|
218
|
-
options.did = did;
|
219
|
-
};
|
220
|
-
|
221
207
|
const writeDisclosureToJson = async (disclosureRequest, options) => {
|
222
208
|
printInfo(`Using disclosureId:${disclosureRequest.id}`);
|
223
209
|
printInfo('');
|
@@ -304,19 +290,11 @@ const validateOptions = (options) => {
|
|
304
290
|
throw new Error('"-a" or "--auth-token" is required');
|
305
291
|
}
|
306
292
|
|
307
|
-
validateTenantAndDidArgs(options);
|
308
|
-
|
309
293
|
validateDirectoryExists(options);
|
310
294
|
|
311
295
|
validateCredentialType(options.idCredentialType);
|
312
296
|
};
|
313
297
|
|
314
|
-
const validateTenantAndDidArgs = (options) => {
|
315
|
-
if (options.tenant == null && options.did == null) {
|
316
|
-
throw new Error('one of "--tenant" or "--did" is required');
|
317
|
-
}
|
318
|
-
};
|
319
|
-
|
320
298
|
const validateCredentialType = (idCredentialType) => {
|
321
299
|
const allowedIdCredentialTypes = values(CREDENTIAL_TYPES);
|
322
300
|
if (
|
@@ -31,8 +31,8 @@ describe('batch issuing test', () => {
|
|
31
31
|
__dirname,
|
32
32
|
'data/email-offer.template.json'
|
33
33
|
),
|
34
|
-
tenant: 'foo',
|
35
34
|
termsUrl: 'http://example.com/terms.html',
|
35
|
+
did: 'did:ion:sap123',
|
36
36
|
idCredentialType: 'Mug2.1',
|
37
37
|
new: true,
|
38
38
|
dryrun: true,
|
@@ -42,23 +42,6 @@ describe('batch issuing test', () => {
|
|
42
42
|
"Mug2.1 doesn't exist. Please use one of EmailV1.0,PhoneV1.0,DriversLicenseV1.0"
|
43
43
|
);
|
44
44
|
});
|
45
|
-
it("should fail if options doesn't have 'did' or `tenant'", async () => {
|
46
|
-
const options = {
|
47
|
-
csvFilename: path.join(__dirname, 'data/batch-vars-offerids.csv'),
|
48
|
-
offerTemplateFilename: path.join(
|
49
|
-
__dirname,
|
50
|
-
'data/email-offer.template.json'
|
51
|
-
),
|
52
|
-
termsUrl: 'http://example.com/terms.html',
|
53
|
-
idCredentialType: 'Mug2.1',
|
54
|
-
new: true,
|
55
|
-
dryrun: true,
|
56
|
-
};
|
57
|
-
|
58
|
-
await expect(() => runBatchIssuing(options)).rejects.toThrowError(
|
59
|
-
'one of "--tenant" or "--did" is required'
|
60
|
-
);
|
61
|
-
});
|
62
45
|
|
63
46
|
it('should load the templates and use offerIds from the csv', async () => {
|
64
47
|
const options = {
|
@@ -67,8 +50,8 @@ describe('batch issuing test', () => {
|
|
67
50
|
__dirname,
|
68
51
|
'data/email-offer.template.json'
|
69
52
|
),
|
70
|
-
tenant: 'foo',
|
71
53
|
termsUrl: 'http://example.com/terms.html',
|
54
|
+
did: 'did:ion:sap123',
|
72
55
|
new: true,
|
73
56
|
dryrun: true,
|
74
57
|
};
|
@@ -111,7 +94,7 @@ describe('batch issuing test', () => {
|
|
111
94
|
newOffer: {
|
112
95
|
type: ['EmailV1.0'],
|
113
96
|
issuer: {
|
114
|
-
id: 'did
|
97
|
+
id: 'did:ion:sap123',
|
115
98
|
},
|
116
99
|
credentialSubject: {
|
117
100
|
vendorUserId: 'joan.lee@sap.com',
|
@@ -129,7 +112,7 @@ describe('batch issuing test', () => {
|
|
129
112
|
newOffer: {
|
130
113
|
type: ['EmailV1.0'],
|
131
114
|
issuer: {
|
132
|
-
id: 'did
|
115
|
+
id: 'did:ion:sap123',
|
133
116
|
},
|
134
117
|
credentialSubject: {
|
135
118
|
vendorUserId: 'john.smith@sap.com',
|
@@ -154,8 +137,8 @@ describe('batch issuing test', () => {
|
|
154
137
|
__dirname,
|
155
138
|
'data/email-offer.template.json'
|
156
139
|
),
|
157
|
-
tenant: 'foo',
|
158
140
|
termsUrl: 'http://example.com/terms.html',
|
141
|
+
did: 'did:ion:sap123',
|
159
142
|
idCredentialType: 'PhoneV1.0',
|
160
143
|
identifierMatchColumn: 1,
|
161
144
|
new: true,
|
@@ -200,7 +183,7 @@ describe('batch issuing test', () => {
|
|
200
183
|
newOffer: {
|
201
184
|
type: ['EmailV1.0'],
|
202
185
|
issuer: {
|
203
|
-
id: 'did
|
186
|
+
id: 'did:ion:sap123',
|
204
187
|
},
|
205
188
|
credentialSubject: {
|
206
189
|
vendorUserId: 'joan.lee@sap.com',
|
@@ -217,7 +200,7 @@ describe('batch issuing test', () => {
|
|
217
200
|
newOffer: {
|
218
201
|
type: ['EmailV1.0'],
|
219
202
|
issuer: {
|
220
|
-
id: 'did
|
203
|
+
id: 'did:ion:sap123',
|
221
204
|
},
|
222
205
|
credentialSubject: {
|
223
206
|
vendorUserId: 'john.smith@sap.com',
|
@@ -241,8 +224,8 @@ describe('batch issuing test', () => {
|
|
241
224
|
__dirname,
|
242
225
|
'data/email-offer.template.json'
|
243
226
|
),
|
244
|
-
tenant: 'foo',
|
245
227
|
termsUrl: 'http://example.com/terms.html',
|
228
|
+
did: 'did:ion:sap123',
|
246
229
|
idCredentialType: 'PhoneV1.0',
|
247
230
|
identifierMatchColumn: 'phone',
|
248
231
|
new: true,
|
@@ -287,7 +270,7 @@ describe('batch issuing test', () => {
|
|
287
270
|
newOffer: {
|
288
271
|
type: ['EmailV1.0'],
|
289
272
|
issuer: {
|
290
|
-
id: 'did
|
273
|
+
id: 'did:ion:sap123',
|
291
274
|
},
|
292
275
|
credentialSubject: {
|
293
276
|
vendorUserId: 'joan.lee@sap.com',
|
@@ -304,7 +287,7 @@ describe('batch issuing test', () => {
|
|
304
287
|
newOffer: {
|
305
288
|
type: ['EmailV1.0'],
|
306
289
|
issuer: {
|
307
|
-
id: 'did
|
290
|
+
id: 'did:ion:sap123',
|
308
291
|
},
|
309
292
|
credentialSubject: {
|
310
293
|
vendorUserId: 'john.smith@sap.com',
|
@@ -328,8 +311,8 @@ describe('batch issuing test', () => {
|
|
328
311
|
__dirname,
|
329
312
|
'data/email-offer.template.json'
|
330
313
|
),
|
331
|
-
tenant: 'foo',
|
332
314
|
termsUrl: 'http://example.com/terms.html',
|
315
|
+
did: 'did:ion:sap123',
|
333
316
|
idCredentialType: 'EmailV1.0',
|
334
317
|
vendorUseridColumn: 1,
|
335
318
|
new: true,
|
@@ -374,7 +357,7 @@ describe('batch issuing test', () => {
|
|
374
357
|
newOffer: {
|
375
358
|
type: ['EmailV1.0'],
|
376
359
|
issuer: {
|
377
|
-
id: 'did
|
360
|
+
id: 'did:ion:sap123',
|
378
361
|
},
|
379
362
|
credentialSubject: {
|
380
363
|
vendorUserId: '+16478275610',
|
@@ -392,7 +375,7 @@ describe('batch issuing test', () => {
|
|
392
375
|
newOffer: {
|
393
376
|
type: ['EmailV1.0'],
|
394
377
|
issuer: {
|
395
|
-
id: 'did
|
378
|
+
id: 'did:ion:sap123',
|
396
379
|
},
|
397
380
|
credentialSubject: {
|
398
381
|
vendorUserId: '+9711234567',
|
@@ -416,9 +399,9 @@ describe('batch issuing test', () => {
|
|
416
399
|
__dirname,
|
417
400
|
'data/phone-offer.template.json'
|
418
401
|
),
|
419
|
-
tenant: 'foo',
|
420
402
|
termsUrl: 'http://example.com/terms.html',
|
421
403
|
idCredentialType: 'PhoneV1.0',
|
404
|
+
did: 'did:ion:sap123',
|
422
405
|
new: true,
|
423
406
|
dryrun: true,
|
424
407
|
};
|
@@ -461,7 +444,7 @@ describe('batch issuing test', () => {
|
|
461
444
|
newOffer: {
|
462
445
|
type: ['PhoneV1.0'],
|
463
446
|
issuer: {
|
464
|
-
id: 'did
|
447
|
+
id: 'did:ion:sap123',
|
465
448
|
},
|
466
449
|
credentialSubject: {
|
467
450
|
vendorUserId: '+1234567890',
|
@@ -479,7 +462,7 @@ describe('batch issuing test', () => {
|
|
479
462
|
newOffer: {
|
480
463
|
type: ['PhoneV1.0'],
|
481
464
|
issuer: {
|
482
|
-
id: 'did
|
465
|
+
id: 'did:ion:sap123',
|
483
466
|
},
|
484
467
|
credentialSubject: {
|
485
468
|
vendorUserId: '+2345678901',
|
@@ -503,9 +486,9 @@ describe('batch issuing test', () => {
|
|
503
486
|
__dirname,
|
504
487
|
'data/driver-license-offer.template.json'
|
505
488
|
),
|
506
|
-
tenant: 'foo',
|
507
489
|
termsUrl: 'http://example.com/terms.html',
|
508
490
|
idCredentialType: 'DriversLicenseV1.0',
|
491
|
+
did: 'did:ion:sap123',
|
509
492
|
new: true,
|
510
493
|
dryrun: true,
|
511
494
|
};
|
@@ -548,7 +531,7 @@ describe('batch issuing test', () => {
|
|
548
531
|
newOffer: {
|
549
532
|
type: ['DriversLicenseV1.0'],
|
550
533
|
issuer: {
|
551
|
-
id: 'did
|
534
|
+
id: 'did:ion:sap123',
|
552
535
|
},
|
553
536
|
credentialSubject: {
|
554
537
|
vendorUserId: 'vm123456',
|
@@ -566,7 +549,7 @@ describe('batch issuing test', () => {
|
|
566
549
|
newOffer: {
|
567
550
|
type: ['DriversLicenseV1.0'],
|
568
551
|
issuer: {
|
569
|
-
id: 'did
|
552
|
+
id: 'did:ion:sap123',
|
570
553
|
},
|
571
554
|
credentialSubject: {
|
572
555
|
vendorUserId: 'as4523456',
|
@@ -591,9 +574,9 @@ describe('batch issuing test', () => {
|
|
591
574
|
__dirname,
|
592
575
|
'data/id-document-offer.template.json'
|
593
576
|
),
|
594
|
-
tenant: 'foo',
|
595
577
|
termsUrl: 'http://example.com/terms.html',
|
596
578
|
idCredentialType: 'IdDocumentV1.0',
|
579
|
+
did: 'did:ion:sap123',
|
597
580
|
new: true,
|
598
581
|
dryrun: true,
|
599
582
|
};
|
@@ -636,7 +619,7 @@ describe('batch issuing test', () => {
|
|
636
619
|
newOffer: {
|
637
620
|
type: ['IdDocumentV1.0'],
|
638
621
|
issuer: {
|
639
|
-
id: 'did
|
622
|
+
id: 'did:ion:sap123',
|
640
623
|
},
|
641
624
|
credentialSubject: {
|
642
625
|
vendorUserId: 'BR514345',
|
@@ -654,7 +637,7 @@ describe('batch issuing test', () => {
|
|
654
637
|
newOffer: {
|
655
638
|
type: ['IdDocumentV1.0'],
|
656
639
|
issuer: {
|
657
|
-
id: 'did
|
640
|
+
id: 'did:ion:sap123',
|
658
641
|
},
|
659
642
|
credentialSubject: {
|
660
643
|
vendorUserId: 'BT678543',
|
@@ -679,9 +662,9 @@ describe('batch issuing test', () => {
|
|
679
662
|
__dirname,
|
680
663
|
'data/resident-permit-offer.template.json'
|
681
664
|
),
|
682
|
-
tenant: 'foo',
|
683
665
|
termsUrl: 'http://example.com/terms.html',
|
684
666
|
idCredentialType: 'ResidentPermitV1.0',
|
667
|
+
did: 'did:ion:sap123',
|
685
668
|
new: true,
|
686
669
|
dryrun: true,
|
687
670
|
};
|
@@ -724,7 +707,7 @@ describe('batch issuing test', () => {
|
|
724
707
|
newOffer: {
|
725
708
|
type: ['ResidentPermitV1.0'],
|
726
709
|
issuer: {
|
727
|
-
id: 'did
|
710
|
+
id: 'did:ion:sap123',
|
728
711
|
},
|
729
712
|
credentialSubject: {
|
730
713
|
vendorUserId: 'ER514345',
|
@@ -742,7 +725,7 @@ describe('batch issuing test', () => {
|
|
742
725
|
newOffer: {
|
743
726
|
type: ['ResidentPermitV1.0'],
|
744
727
|
issuer: {
|
745
|
-
id: 'did
|
728
|
+
id: 'did:ion:sap123',
|
746
729
|
},
|
747
730
|
credentialSubject: {
|
748
731
|
vendorUserId: 'RT678543',
|
@@ -767,9 +750,9 @@ describe('batch issuing test', () => {
|
|
767
750
|
__dirname,
|
768
751
|
'data/passport-offer.template.json'
|
769
752
|
),
|
770
|
-
tenant: 'foo',
|
771
753
|
termsUrl: 'http://example.com/terms.html',
|
772
754
|
idCredentialType: 'PassportV1.0',
|
755
|
+
did: 'did:ion:sap123',
|
773
756
|
new: true,
|
774
757
|
dryrun: true,
|
775
758
|
};
|
@@ -812,7 +795,7 @@ describe('batch issuing test', () => {
|
|
812
795
|
newOffer: {
|
813
796
|
type: ['PassportV1.0'],
|
814
797
|
issuer: {
|
815
|
-
id: 'did
|
798
|
+
id: 'did:ion:sap123',
|
816
799
|
},
|
817
800
|
credentialSubject: {
|
818
801
|
vendorUserId: 'ER514345',
|
@@ -830,7 +813,7 @@ describe('batch issuing test', () => {
|
|
830
813
|
newOffer: {
|
831
814
|
type: ['PassportV1.0'],
|
832
815
|
issuer: {
|
833
|
-
id: 'did
|
816
|
+
id: 'did:ion:sap123',
|
834
817
|
},
|
835
818
|
credentialSubject: {
|
836
819
|
vendorUserId: 'RT678543',
|
@@ -855,9 +838,9 @@ describe('batch issuing test', () => {
|
|
855
838
|
__dirname,
|
856
839
|
'data/national-id-card-offer.template.json'
|
857
840
|
),
|
858
|
-
tenant: 'foo',
|
859
841
|
termsUrl: 'http://example.com/terms.html',
|
860
842
|
idCredentialType: 'NationalIdCardV1.0',
|
843
|
+
did: 'did:ion:sap123',
|
861
844
|
new: true,
|
862
845
|
dryrun: true,
|
863
846
|
};
|
@@ -900,7 +883,7 @@ describe('batch issuing test', () => {
|
|
900
883
|
newOffer: {
|
901
884
|
type: ['NationalIdCardV1.0'],
|
902
885
|
issuer: {
|
903
|
-
id: 'did
|
886
|
+
id: 'did:ion:sap123',
|
904
887
|
},
|
905
888
|
credentialSubject: {
|
906
889
|
vendorUserId: 'BR514345',
|
@@ -918,7 +901,7 @@ describe('batch issuing test', () => {
|
|
918
901
|
newOffer: {
|
919
902
|
type: ['NationalIdCardV1.0'],
|
920
903
|
issuer: {
|
921
|
-
id: 'did
|
904
|
+
id: 'did:ion:sap123',
|
922
905
|
},
|
923
906
|
credentialSubject: {
|
924
907
|
vendorUserId: 'BT678543',
|
@@ -943,9 +926,9 @@ describe('batch issuing test', () => {
|
|
943
926
|
__dirname,
|
944
927
|
'data/proof-of-age-offer.template.json'
|
945
928
|
),
|
946
|
-
tenant: 'foo',
|
947
929
|
termsUrl: 'http://example.com/terms.html',
|
948
930
|
idCredentialType: 'ProofOfAgeV1.0',
|
931
|
+
did: 'did:ion:sap123',
|
949
932
|
new: true,
|
950
933
|
dryrun: true,
|
951
934
|
};
|
@@ -988,7 +971,7 @@ describe('batch issuing test', () => {
|
|
988
971
|
newOffer: {
|
989
972
|
type: ['ProofOfAgeV1.0'],
|
990
973
|
issuer: {
|
991
|
-
id: 'did
|
974
|
+
id: 'did:ion:sap123',
|
992
975
|
},
|
993
976
|
credentialSubject: {
|
994
977
|
vendorUserId: 'ER514345',
|
@@ -1006,7 +989,7 @@ describe('batch issuing test', () => {
|
|
1006
989
|
newOffer: {
|
1007
990
|
type: ['ProofOfAgeV1.0'],
|
1008
991
|
issuer: {
|
1009
|
-
id: 'did
|
992
|
+
id: 'did:ion:sap123',
|
1010
993
|
},
|
1011
994
|
credentialSubject: {
|
1012
995
|
vendorUserId: 'RT678543',
|
@@ -1031,8 +1014,8 @@ describe('batch issuing test', () => {
|
|
1031
1014
|
__dirname,
|
1032
1015
|
'data/email-offer.template.json'
|
1033
1016
|
),
|
1034
|
-
tenant: 'foo',
|
1035
1017
|
termsUrl: 'http://example.com/terms.html',
|
1018
|
+
did: 'did:ion:sap123',
|
1036
1019
|
idCredentialType: 'EmailV1.0',
|
1037
1020
|
vendorUseridColumn: 'email',
|
1038
1021
|
new: true,
|
@@ -1077,7 +1060,7 @@ describe('batch issuing test', () => {
|
|
1077
1060
|
newOffer: {
|
1078
1061
|
type: ['EmailV1.0'],
|
1079
1062
|
issuer: {
|
1080
|
-
id: 'did
|
1063
|
+
id: 'did:ion:sap123',
|
1081
1064
|
},
|
1082
1065
|
credentialSubject: {
|
1083
1066
|
vendorUserId: 'joan.lee@sap.com',
|
@@ -1095,7 +1078,7 @@ describe('batch issuing test', () => {
|
|
1095
1078
|
newOffer: {
|
1096
1079
|
type: ['EmailV1.0'],
|
1097
1080
|
issuer: {
|
1098
|
-
id: 'did
|
1081
|
+
id: 'did:ion:sap123',
|
1099
1082
|
},
|
1100
1083
|
credentialSubject: {
|
1101
1084
|
vendorUserId: 'john.smith@sap.com',
|
@@ -1120,8 +1103,8 @@ describe('batch issuing test', () => {
|
|
1120
1103
|
__dirname,
|
1121
1104
|
'data/email-offer.template.json'
|
1122
1105
|
),
|
1123
|
-
tenant: 'foo',
|
1124
1106
|
termsUrl: 'http://example.com/terms.html',
|
1107
|
+
did: 'did:ion:sap123',
|
1125
1108
|
idCredentialType: 'EmailV1.0',
|
1126
1109
|
vendorUseridColumn: 'email',
|
1127
1110
|
new: true,
|
@@ -1166,7 +1149,7 @@ describe('batch issuing test', () => {
|
|
1166
1149
|
newOffer: {
|
1167
1150
|
type: ['EmailV1.0'],
|
1168
1151
|
issuer: {
|
1169
|
-
id: 'did
|
1152
|
+
id: 'did:ion:sap123',
|
1170
1153
|
},
|
1171
1154
|
credentialSubject: {
|
1172
1155
|
vendorUserId: 'joan.lee@sap.com',
|
@@ -1184,7 +1167,7 @@ describe('batch issuing test', () => {
|
|
1184
1167
|
newOffer: {
|
1185
1168
|
type: ['EmailV1.0'],
|
1186
1169
|
issuer: {
|
1187
|
-
id: 'did
|
1170
|
+
id: 'did:ion:sap123',
|
1188
1171
|
},
|
1189
1172
|
credentialSubject: {
|
1190
1173
|
vendorUserId: 'john.smith@sap.com',
|
@@ -1209,13 +1192,13 @@ describe('batch issuing test', () => {
|
|
1209
1192
|
__dirname,
|
1210
1193
|
'data/email-offer.template.json'
|
1211
1194
|
),
|
1212
|
-
tenant: 'foo',
|
1213
1195
|
termsUrl: 'http://example.com/terms.html',
|
1214
1196
|
label: 'testLabel',
|
1215
1197
|
offerMode: 'preloaded',
|
1216
1198
|
purpose: 'Some Purpose',
|
1217
1199
|
expiresInHours: 100,
|
1218
1200
|
activatesInHours: 10,
|
1201
|
+
did: 'did:ion:sap456',
|
1219
1202
|
idCredentialType: 'EmailV1.0',
|
1220
1203
|
vendorUseridColumn: 'email',
|
1221
1204
|
new: true,
|
@@ -1258,7 +1241,7 @@ describe('batch issuing test', () => {
|
|
1258
1241
|
newOffer: {
|
1259
1242
|
type: ['EmailV1.0'],
|
1260
1243
|
issuer: {
|
1261
|
-
id: 'did
|
1244
|
+
id: 'did:ion:sap456',
|
1262
1245
|
},
|
1263
1246
|
credentialSubject: {
|
1264
1247
|
vendorUserId: 'joan.lee@sap.com',
|
@@ -1278,7 +1261,7 @@ describe('batch issuing test', () => {
|
|
1278
1261
|
newOffer: {
|
1279
1262
|
type: ['EmailV1.0'],
|
1280
1263
|
issuer: {
|
1281
|
-
id: 'did
|
1264
|
+
id: 'did:ion:sap456',
|
1282
1265
|
},
|
1283
1266
|
credentialSubject: {
|
1284
1267
|
vendorUserId: 'john.smith@sap.com',
|
@@ -1307,6 +1290,7 @@ describe('batch issuing test', () => {
|
|
1307
1290
|
|
1308
1291
|
it('should have error if the disclosureRequest is not found', async () => {
|
1309
1292
|
const agentUrl = 'https://exampleUrl';
|
1293
|
+
const did = 'did:ion:sap123';
|
1310
1294
|
const tenant = '123';
|
1311
1295
|
nock(agentUrl)
|
1312
1296
|
.get(
|
@@ -1321,6 +1305,7 @@ describe('batch issuing test', () => {
|
|
1321
1305
|
'data/email-offer.template.json'
|
1322
1306
|
),
|
1323
1307
|
tenant,
|
1308
|
+
did,
|
1324
1309
|
termsUrl: 'http://example.com/terms.html',
|
1325
1310
|
idCredentialType: 'EmailV1.0',
|
1326
1311
|
disclosure: 'foo',
|
@@ -1332,8 +1317,9 @@ describe('batch issuing test', () => {
|
|
1332
1317
|
await expect(() => runBatchIssuing(options)).rejects.toThrowError();
|
1333
1318
|
});
|
1334
1319
|
|
1335
|
-
it(
|
1320
|
+
it('should find the existing disclosure disclosureRequest', async () => {
|
1336
1321
|
const agentUrl = 'https://exampleUrl';
|
1322
|
+
const did = 'did:ion:sap123';
|
1337
1323
|
const tenant = '123';
|
1338
1324
|
nock(agentUrl)
|
1339
1325
|
.get(
|
@@ -1348,73 +1334,6 @@ describe('batch issuing test', () => {
|
|
1348
1334
|
'data/email-offer.template.json'
|
1349
1335
|
),
|
1350
1336
|
tenant,
|
1351
|
-
termsUrl: 'http://example.com/terms.html',
|
1352
|
-
idCredentialType: 'EmailV1.0',
|
1353
|
-
vendorUseridColumn: 'email',
|
1354
|
-
disclosure: existingDisclosures[0].id,
|
1355
|
-
dryrun: true,
|
1356
|
-
endpoint: agentUrl,
|
1357
|
-
authToken: 'fakeToken',
|
1358
|
-
};
|
1359
|
-
|
1360
|
-
const updates = await runBatchIssuing(options);
|
1361
|
-
expect(updates).toEqual({
|
1362
|
-
disclosureRequest: existingDisclosures[0],
|
1363
|
-
newExchangeOffers: [
|
1364
|
-
{
|
1365
|
-
newOffer: {
|
1366
|
-
type: ['EmailV1.0'],
|
1367
|
-
issuer: {
|
1368
|
-
id: 'did to be determined at runtime',
|
1369
|
-
},
|
1370
|
-
credentialSubject: {
|
1371
|
-
vendorUserId: 'joan.lee@sap.com',
|
1372
|
-
email: 'joan.lee@sap.com',
|
1373
|
-
},
|
1374
|
-
|
1375
|
-
offerId: expect.any(String),
|
1376
|
-
},
|
1377
|
-
newExchange: {
|
1378
|
-
type: 'ISSUING',
|
1379
|
-
identityMatcherValues: ['joan.lee@sap.com'],
|
1380
|
-
},
|
1381
|
-
},
|
1382
|
-
{
|
1383
|
-
newOffer: {
|
1384
|
-
type: ['EmailV1.0'],
|
1385
|
-
issuer: {
|
1386
|
-
id: 'did to be determined at runtime',
|
1387
|
-
},
|
1388
|
-
credentialSubject: {
|
1389
|
-
vendorUserId: 'john.smith@sap.com',
|
1390
|
-
email: 'john.smith@sap.com',
|
1391
|
-
},
|
1392
|
-
|
1393
|
-
offerId: expect.any(String),
|
1394
|
-
},
|
1395
|
-
newExchange: {
|
1396
|
-
type: 'ISSUING',
|
1397
|
-
identityMatcherValues: ['john.smith@sap.com'],
|
1398
|
-
},
|
1399
|
-
},
|
1400
|
-
],
|
1401
|
-
});
|
1402
|
-
});
|
1403
|
-
it("should find the existing disclosure disclosureRequest with 'did' option", async () => {
|
1404
|
-
const agentUrl = 'https://exampleUrl';
|
1405
|
-
const did = 'did:sap:123';
|
1406
|
-
nock(agentUrl)
|
1407
|
-
.get(
|
1408
|
-
`/operator-api/v0.8/tenants/${did}/disclosures?vendorEndpoint=integrated-issuing-identification`
|
1409
|
-
)
|
1410
|
-
.reply(200, existingDisclosures);
|
1411
|
-
|
1412
|
-
const options = {
|
1413
|
-
csvFilename: path.join(__dirname, 'data/variables.csv'),
|
1414
|
-
offerTemplateFilename: path.join(
|
1415
|
-
__dirname,
|
1416
|
-
'data/email-offer.template.json'
|
1417
|
-
),
|
1418
1337
|
did,
|
1419
1338
|
termsUrl: 'http://example.com/terms.html',
|
1420
1339
|
idCredentialType: 'EmailV1.0',
|
@@ -1486,8 +1405,8 @@ describe('batch issuing test', () => {
|
|
1486
1405
|
__dirname,
|
1487
1406
|
'data/email-offer.template.json'
|
1488
1407
|
),
|
1489
|
-
tenant: 'foo',
|
1490
1408
|
termsUrl: 'http://example.com/terms.html',
|
1409
|
+
did: 'did:ion:sap123',
|
1491
1410
|
new: true,
|
1492
1411
|
dryrun: true,
|
1493
1412
|
};
|
@@ -1504,8 +1423,9 @@ describe('batch issuing test', () => {
|
|
1504
1423
|
__dirname,
|
1505
1424
|
'data/email-offer.template.json'
|
1506
1425
|
),
|
1507
|
-
tenant: 'foo',
|
1508
1426
|
termsUrl: 'http://example.com/terms.html',
|
1427
|
+
did: 'did:ion:sap123',
|
1428
|
+
tenant: '123',
|
1509
1429
|
new: true,
|
1510
1430
|
dryrun: true,
|
1511
1431
|
};
|