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