@velocitycareerlabs/data-loader 1.20.0-dev-build.1cb592b8f → 1.20.0-dev-build.1e6832e17
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 +3 -2
- package/src/batch-issuing/constants.js +25 -0
- package/src/batch-issuing/file-writers.js +2 -5
- package/src/batch-issuing/index.js +50 -48
- package/src/batch-issuing/orchestrators.js +146 -99
- package/src/batch-issuing/prepare-data.js +40 -81
- package/src/batch-issuing/validate-directory-exists.js +3 -3
- package/src/helpers/index.js +2 -0
- package/src/helpers/load-csv.js +14 -11
- package/src/helpers/parse-column.js +8 -0
- package/src/helpers/prepare-variable-sets.js +23 -0
- package/src/vendor-credentials/README.md +48 -8
- package/src/vendor-credentials/index.js +10 -14
- package/src/vendor-credentials/orchestrator.js +22 -0
- package/src/vendor-credentials/prepare-data.js +5 -9
- package/test/batch-issuing.test.js +448 -75
- package/test/data/batch-vars-offerids.csv +3 -3
- package/test/data/email-offer.template.json +1 -1
- package/test/vendor-credentials.test.js +6 -4
@@ -1,11 +1,20 @@
|
|
1
1
|
const path = require('path');
|
2
|
-
const
|
3
|
-
const {
|
2
|
+
const nock = require('nock');
|
3
|
+
const { nanoid } = require('nanoid');
|
4
|
+
const { runBatchIssuing } = require('../src/batch-issuing/orchestrators');
|
4
5
|
|
5
6
|
const ISO_DATETIME_TZ_FORMAT =
|
6
7
|
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d\d:\d\d|Z)$/;
|
7
8
|
|
8
9
|
describe('batch issuing test', () => {
|
10
|
+
beforeAll(() => {
|
11
|
+
nock.cleanAll();
|
12
|
+
});
|
13
|
+
|
14
|
+
afterAll(() => {
|
15
|
+
nock.restore();
|
16
|
+
});
|
17
|
+
|
9
18
|
it("should fail if options don't have credential type or type doesn't exist", async () => {
|
10
19
|
const options = {
|
11
20
|
csvFilename: path.join(__dirname, 'data/batch-vars-offerids.csv'),
|
@@ -15,15 +24,12 @@ describe('batch issuing test', () => {
|
|
15
24
|
),
|
16
25
|
termsUrl: 'http://example.com/terms.html',
|
17
26
|
did: 'did:ion:sap123',
|
27
|
+
idCredentialType: 'Mug2.1',
|
28
|
+
new: true,
|
29
|
+
dryrun: true,
|
18
30
|
};
|
19
31
|
|
20
|
-
expect(() =>
|
21
|
-
"undefined doesn't exist. Please use one of EmailV1.0,PhoneV1.0,DriversLicenseV1.0"
|
22
|
-
);
|
23
|
-
|
24
|
-
expect(() =>
|
25
|
-
prepareData(DisclosureType.NEW, { ...options, credentialType: 'Mug2.1' })
|
26
|
-
).rejects.toThrowError(
|
32
|
+
await expect(() => runBatchIssuing(options)).rejects.toThrowError(
|
27
33
|
"Mug2.1 doesn't exist. Please use one of EmailV1.0,PhoneV1.0,DriversLicenseV1.0"
|
28
34
|
);
|
29
35
|
});
|
@@ -37,16 +43,17 @@ describe('batch issuing test', () => {
|
|
37
43
|
),
|
38
44
|
termsUrl: 'http://example.com/terms.html',
|
39
45
|
did: 'did:ion:sap123',
|
40
|
-
|
46
|
+
new: true,
|
47
|
+
dryrun: true,
|
41
48
|
};
|
42
49
|
|
43
|
-
const updates = await
|
50
|
+
const updates = await runBatchIssuing(options);
|
44
51
|
expect(
|
45
|
-
new Date(updates.
|
52
|
+
new Date(updates.disclosureRequest.activationDate).getTime()
|
46
53
|
).toBeLessThan(Date.now());
|
47
54
|
|
48
55
|
expect(updates).toEqual({
|
49
|
-
|
56
|
+
disclosureRequest: {
|
50
57
|
configurationType: 'issuing',
|
51
58
|
vendorEndpoint: 'integrated-issuing-identification',
|
52
59
|
types: [
|
@@ -71,7 +78,7 @@ describe('batch issuing test', () => {
|
|
71
78
|
purpose: 'Issuing Career Credential', // by default have a generic message
|
72
79
|
activationDate: expect.stringMatching(ISO_DATETIME_TZ_FORMAT),
|
73
80
|
termsUrl: 'http://example.com/terms.html',
|
74
|
-
authTokenExpiresIn:
|
81
|
+
authTokenExpiresIn: 525600,
|
75
82
|
},
|
76
83
|
newExchangeOffers: [
|
77
84
|
{
|
@@ -113,6 +120,269 @@ describe('batch issuing test', () => {
|
|
113
120
|
],
|
114
121
|
});
|
115
122
|
});
|
123
|
+
|
124
|
+
it('should load the templates and use offerIds from the csv using phone for identifier matching using col index', async () => {
|
125
|
+
const options = {
|
126
|
+
csvFilename: path.join(__dirname, 'data/batch-vars-offerids.csv'),
|
127
|
+
offerTemplateFilename: path.join(
|
128
|
+
__dirname,
|
129
|
+
'data/email-offer.template.json'
|
130
|
+
),
|
131
|
+
termsUrl: 'http://example.com/terms.html',
|
132
|
+
did: 'did:ion:sap123',
|
133
|
+
idCredentialType: 'PhoneV1.0',
|
134
|
+
identifierMatchColumn: 1,
|
135
|
+
new: true,
|
136
|
+
dryrun: true,
|
137
|
+
};
|
138
|
+
|
139
|
+
const updates = await runBatchIssuing(options);
|
140
|
+
expect(
|
141
|
+
new Date(updates.disclosureRequest.activationDate).getTime()
|
142
|
+
).toBeLessThan(Date.now());
|
143
|
+
|
144
|
+
expect(updates).toEqual({
|
145
|
+
disclosureRequest: {
|
146
|
+
configurationType: 'issuing',
|
147
|
+
vendorEndpoint: 'integrated-issuing-identification',
|
148
|
+
types: [
|
149
|
+
{
|
150
|
+
type: 'PhoneV1.0',
|
151
|
+
},
|
152
|
+
],
|
153
|
+
identityMatchers: {
|
154
|
+
rules: [
|
155
|
+
{
|
156
|
+
valueIndex: 1,
|
157
|
+
path: ['$.phones'],
|
158
|
+
rule: 'pick',
|
159
|
+
},
|
160
|
+
],
|
161
|
+
vendorUserIdIndex: 0,
|
162
|
+
},
|
163
|
+
vendorDisclosureId: expect.any(Number),
|
164
|
+
setIssuingDefault: true,
|
165
|
+
duration: '1h', // 1 hour by default
|
166
|
+
offerMode: 'preloaded',
|
167
|
+
purpose: 'Issuing Career Credential', // by default have a generic message
|
168
|
+
activationDate: expect.stringMatching(ISO_DATETIME_TZ_FORMAT),
|
169
|
+
termsUrl: 'http://example.com/terms.html',
|
170
|
+
authTokenExpiresIn: 525600,
|
171
|
+
},
|
172
|
+
newExchangeOffers: [
|
173
|
+
{
|
174
|
+
newOffer: {
|
175
|
+
type: ['EmailV1.0'],
|
176
|
+
issuer: {
|
177
|
+
id: 'did:ion:sap123',
|
178
|
+
},
|
179
|
+
credentialSubject: {
|
180
|
+
vendorUserId: 'joan.lee@sap.com',
|
181
|
+
email: 'joan.lee@sap.com',
|
182
|
+
},
|
183
|
+
offerId: '100',
|
184
|
+
},
|
185
|
+
newExchange: {
|
186
|
+
type: 'ISSUING',
|
187
|
+
identityMatcherValues: ['+16478275610'],
|
188
|
+
},
|
189
|
+
},
|
190
|
+
{
|
191
|
+
newOffer: {
|
192
|
+
type: ['EmailV1.0'],
|
193
|
+
issuer: {
|
194
|
+
id: 'did:ion:sap123',
|
195
|
+
},
|
196
|
+
credentialSubject: {
|
197
|
+
vendorUserId: 'john.smith@sap.com',
|
198
|
+
email: 'john.smith@sap.com',
|
199
|
+
},
|
200
|
+
offerId: '200',
|
201
|
+
},
|
202
|
+
newExchange: {
|
203
|
+
type: 'ISSUING',
|
204
|
+
identityMatcherValues: ['+9711234567'],
|
205
|
+
},
|
206
|
+
},
|
207
|
+
],
|
208
|
+
});
|
209
|
+
});
|
210
|
+
|
211
|
+
it('should load the templates and use offerIds from the csv using phone for identifier matching using col name', async () => {
|
212
|
+
const options = {
|
213
|
+
csvFilename: path.join(__dirname, 'data/batch-vars-offerids.csv'),
|
214
|
+
offerTemplateFilename: path.join(
|
215
|
+
__dirname,
|
216
|
+
'data/email-offer.template.json'
|
217
|
+
),
|
218
|
+
termsUrl: 'http://example.com/terms.html',
|
219
|
+
did: 'did:ion:sap123',
|
220
|
+
idCredentialType: 'PhoneV1.0',
|
221
|
+
identifierMatchColumn: 'phone',
|
222
|
+
new: true,
|
223
|
+
dryrun: true,
|
224
|
+
};
|
225
|
+
|
226
|
+
const updates = await runBatchIssuing(options);
|
227
|
+
expect(
|
228
|
+
new Date(updates.disclosureRequest.activationDate).getTime()
|
229
|
+
).toBeLessThan(Date.now());
|
230
|
+
|
231
|
+
expect(updates).toEqual({
|
232
|
+
disclosureRequest: {
|
233
|
+
configurationType: 'issuing',
|
234
|
+
vendorEndpoint: 'integrated-issuing-identification',
|
235
|
+
types: [
|
236
|
+
{
|
237
|
+
type: 'PhoneV1.0',
|
238
|
+
},
|
239
|
+
],
|
240
|
+
identityMatchers: {
|
241
|
+
rules: [
|
242
|
+
{
|
243
|
+
valueIndex: 1,
|
244
|
+
path: ['$.phones'],
|
245
|
+
rule: 'pick',
|
246
|
+
},
|
247
|
+
],
|
248
|
+
vendorUserIdIndex: 0,
|
249
|
+
},
|
250
|
+
vendorDisclosureId: expect.any(Number),
|
251
|
+
setIssuingDefault: true,
|
252
|
+
duration: '1h', // 1 hour by default
|
253
|
+
offerMode: 'preloaded',
|
254
|
+
purpose: 'Issuing Career Credential', // by default have a generic message
|
255
|
+
activationDate: expect.stringMatching(ISO_DATETIME_TZ_FORMAT),
|
256
|
+
termsUrl: 'http://example.com/terms.html',
|
257
|
+
authTokenExpiresIn: 525600,
|
258
|
+
},
|
259
|
+
newExchangeOffers: [
|
260
|
+
{
|
261
|
+
newOffer: {
|
262
|
+
type: ['EmailV1.0'],
|
263
|
+
issuer: {
|
264
|
+
id: 'did:ion:sap123',
|
265
|
+
},
|
266
|
+
credentialSubject: {
|
267
|
+
vendorUserId: 'joan.lee@sap.com',
|
268
|
+
email: 'joan.lee@sap.com',
|
269
|
+
},
|
270
|
+
offerId: '100',
|
271
|
+
},
|
272
|
+
newExchange: {
|
273
|
+
type: 'ISSUING',
|
274
|
+
identityMatcherValues: ['+16478275610'],
|
275
|
+
},
|
276
|
+
},
|
277
|
+
{
|
278
|
+
newOffer: {
|
279
|
+
type: ['EmailV1.0'],
|
280
|
+
issuer: {
|
281
|
+
id: 'did:ion:sap123',
|
282
|
+
},
|
283
|
+
credentialSubject: {
|
284
|
+
vendorUserId: 'john.smith@sap.com',
|
285
|
+
email: 'john.smith@sap.com',
|
286
|
+
},
|
287
|
+
offerId: '200',
|
288
|
+
},
|
289
|
+
newExchange: {
|
290
|
+
type: 'ISSUING',
|
291
|
+
identityMatcherValues: ['+9711234567'],
|
292
|
+
},
|
293
|
+
},
|
294
|
+
],
|
295
|
+
});
|
296
|
+
});
|
297
|
+
|
298
|
+
it('should load the templates and use offerIds from the csv and use phone as the vendorUserId', async () => {
|
299
|
+
const options = {
|
300
|
+
csvFilename: path.join(__dirname, 'data/batch-vars-offerids.csv'),
|
301
|
+
offerTemplateFilename: path.join(
|
302
|
+
__dirname,
|
303
|
+
'data/email-offer.template.json'
|
304
|
+
),
|
305
|
+
termsUrl: 'http://example.com/terms.html',
|
306
|
+
did: 'did:ion:sap123',
|
307
|
+
idCredentialType: 'EmailV1.0',
|
308
|
+
vendorUseridColumn: 1,
|
309
|
+
new: true,
|
310
|
+
dryrun: true,
|
311
|
+
};
|
312
|
+
|
313
|
+
const updates = await runBatchIssuing(options);
|
314
|
+
expect(
|
315
|
+
new Date(updates.disclosureRequest.activationDate).getTime()
|
316
|
+
).toBeLessThan(Date.now());
|
317
|
+
|
318
|
+
expect(updates).toEqual({
|
319
|
+
disclosureRequest: {
|
320
|
+
configurationType: 'issuing',
|
321
|
+
vendorEndpoint: 'integrated-issuing-identification',
|
322
|
+
types: [
|
323
|
+
{
|
324
|
+
type: 'EmailV1.0',
|
325
|
+
},
|
326
|
+
],
|
327
|
+
identityMatchers: {
|
328
|
+
rules: [
|
329
|
+
{
|
330
|
+
valueIndex: 0,
|
331
|
+
path: ['$.emails'],
|
332
|
+
rule: 'pick',
|
333
|
+
},
|
334
|
+
],
|
335
|
+
vendorUserIdIndex: 1,
|
336
|
+
},
|
337
|
+
vendorDisclosureId: expect.any(Number),
|
338
|
+
setIssuingDefault: true,
|
339
|
+
duration: '1h', // 1 hour by default
|
340
|
+
offerMode: 'preloaded',
|
341
|
+
purpose: 'Issuing Career Credential', // by default have a generic message
|
342
|
+
activationDate: expect.stringMatching(ISO_DATETIME_TZ_FORMAT),
|
343
|
+
termsUrl: 'http://example.com/terms.html',
|
344
|
+
authTokenExpiresIn: 525600,
|
345
|
+
},
|
346
|
+
newExchangeOffers: [
|
347
|
+
{
|
348
|
+
newOffer: {
|
349
|
+
type: ['EmailV1.0'],
|
350
|
+
issuer: {
|
351
|
+
id: 'did:ion:sap123',
|
352
|
+
},
|
353
|
+
credentialSubject: {
|
354
|
+
vendorUserId: '+16478275610',
|
355
|
+
email: 'joan.lee@sap.com',
|
356
|
+
},
|
357
|
+
|
358
|
+
offerId: '100',
|
359
|
+
},
|
360
|
+
newExchange: {
|
361
|
+
type: 'ISSUING',
|
362
|
+
identityMatcherValues: ['joan.lee@sap.com'],
|
363
|
+
},
|
364
|
+
},
|
365
|
+
{
|
366
|
+
newOffer: {
|
367
|
+
type: ['EmailV1.0'],
|
368
|
+
issuer: {
|
369
|
+
id: 'did:ion:sap123',
|
370
|
+
},
|
371
|
+
credentialSubject: {
|
372
|
+
vendorUserId: '+9711234567',
|
373
|
+
email: 'john.smith@sap.com',
|
374
|
+
},
|
375
|
+
|
376
|
+
offerId: '200',
|
377
|
+
},
|
378
|
+
newExchange: {
|
379
|
+
type: 'ISSUING',
|
380
|
+
identityMatcherValues: ['john.smith@sap.com'],
|
381
|
+
},
|
382
|
+
},
|
383
|
+
],
|
384
|
+
});
|
385
|
+
});
|
116
386
|
it('should load the templates and use offerIds by phone from the csv', async () => {
|
117
387
|
const options = {
|
118
388
|
csvFilename: path.join(__dirname, 'data/phones-batch-vars-offerids.csv'),
|
@@ -121,17 +391,19 @@ describe('batch issuing test', () => {
|
|
121
391
|
'data/phone-offer.template.json'
|
122
392
|
),
|
123
393
|
termsUrl: 'http://example.com/terms.html',
|
124
|
-
|
394
|
+
idCredentialType: 'PhoneV1.0',
|
125
395
|
did: 'did:ion:sap123',
|
396
|
+
new: true,
|
397
|
+
dryrun: true,
|
126
398
|
};
|
127
399
|
|
128
|
-
const updates = await
|
400
|
+
const updates = await runBatchIssuing(options);
|
129
401
|
expect(
|
130
|
-
new Date(updates.
|
402
|
+
new Date(updates.disclosureRequest.activationDate).getTime()
|
131
403
|
).toBeLessThan(Date.now());
|
132
404
|
|
133
405
|
expect(updates).toEqual({
|
134
|
-
|
406
|
+
disclosureRequest: {
|
135
407
|
configurationType: 'issuing',
|
136
408
|
vendorEndpoint: 'integrated-issuing-identification',
|
137
409
|
types: [
|
@@ -156,7 +428,7 @@ describe('batch issuing test', () => {
|
|
156
428
|
purpose: 'Issuing Career Credential', // by default have a generic message
|
157
429
|
activationDate: expect.stringMatching(ISO_DATETIME_TZ_FORMAT),
|
158
430
|
termsUrl: 'http://example.com/terms.html',
|
159
|
-
authTokenExpiresIn:
|
431
|
+
authTokenExpiresIn: 525600,
|
160
432
|
},
|
161
433
|
newExchangeOffers: [
|
162
434
|
{
|
@@ -206,17 +478,19 @@ describe('batch issuing test', () => {
|
|
206
478
|
'data/driver-license-offer.template.json'
|
207
479
|
),
|
208
480
|
termsUrl: 'http://example.com/terms.html',
|
209
|
-
|
481
|
+
idCredentialType: 'DriversLicenseV1.0',
|
210
482
|
did: 'did:ion:sap123',
|
483
|
+
new: true,
|
484
|
+
dryrun: true,
|
211
485
|
};
|
212
486
|
|
213
|
-
const updates = await
|
487
|
+
const updates = await runBatchIssuing(options);
|
214
488
|
expect(
|
215
|
-
new Date(updates.
|
489
|
+
new Date(updates.disclosureRequest.activationDate).getTime()
|
216
490
|
).toBeLessThan(Date.now());
|
217
491
|
|
218
492
|
expect(updates).toEqual({
|
219
|
-
|
493
|
+
disclosureRequest: {
|
220
494
|
configurationType: 'issuing',
|
221
495
|
vendorEndpoint: 'integrated-issuing-identification',
|
222
496
|
types: [
|
@@ -241,7 +515,7 @@ describe('batch issuing test', () => {
|
|
241
515
|
purpose: 'Issuing Career Credential', // by default have a generic message
|
242
516
|
activationDate: expect.stringMatching(ISO_DATETIME_TZ_FORMAT),
|
243
517
|
termsUrl: 'http://example.com/terms.html',
|
244
|
-
authTokenExpiresIn:
|
518
|
+
authTokenExpiresIn: 525600,
|
245
519
|
},
|
246
520
|
newExchangeOffers: [
|
247
521
|
{
|
@@ -292,17 +566,19 @@ describe('batch issuing test', () => {
|
|
292
566
|
'data/id-document-offer.template.json'
|
293
567
|
),
|
294
568
|
termsUrl: 'http://example.com/terms.html',
|
295
|
-
|
569
|
+
idCredentialType: 'IdDocumentV1.0',
|
296
570
|
did: 'did:ion:sap123',
|
571
|
+
new: true,
|
572
|
+
dryrun: true,
|
297
573
|
};
|
298
574
|
|
299
|
-
const updates = await
|
575
|
+
const updates = await runBatchIssuing(options);
|
300
576
|
expect(
|
301
|
-
new Date(updates.
|
577
|
+
new Date(updates.disclosureRequest.activationDate).getTime()
|
302
578
|
).toBeLessThan(Date.now());
|
303
579
|
|
304
580
|
expect(updates).toEqual({
|
305
|
-
|
581
|
+
disclosureRequest: {
|
306
582
|
configurationType: 'issuing',
|
307
583
|
vendorEndpoint: 'integrated-issuing-identification',
|
308
584
|
types: [
|
@@ -327,7 +603,7 @@ describe('batch issuing test', () => {
|
|
327
603
|
purpose: 'Issuing Career Credential', // by default have a generic message
|
328
604
|
activationDate: expect.stringMatching(ISO_DATETIME_TZ_FORMAT),
|
329
605
|
termsUrl: 'http://example.com/terms.html',
|
330
|
-
authTokenExpiresIn:
|
606
|
+
authTokenExpiresIn: 525600,
|
331
607
|
},
|
332
608
|
newExchangeOffers: [
|
333
609
|
{
|
@@ -378,17 +654,19 @@ describe('batch issuing test', () => {
|
|
378
654
|
'data/resident-permit-offer.template.json'
|
379
655
|
),
|
380
656
|
termsUrl: 'http://example.com/terms.html',
|
381
|
-
|
657
|
+
idCredentialType: 'ResidentPermitV1.0',
|
382
658
|
did: 'did:ion:sap123',
|
659
|
+
new: true,
|
660
|
+
dryrun: true,
|
383
661
|
};
|
384
662
|
|
385
|
-
const updates = await
|
663
|
+
const updates = await runBatchIssuing(options);
|
386
664
|
expect(
|
387
|
-
new Date(updates.
|
665
|
+
new Date(updates.disclosureRequest.activationDate).getTime()
|
388
666
|
).toBeLessThan(Date.now());
|
389
667
|
|
390
668
|
expect(updates).toEqual({
|
391
|
-
|
669
|
+
disclosureRequest: {
|
392
670
|
configurationType: 'issuing',
|
393
671
|
vendorEndpoint: 'integrated-issuing-identification',
|
394
672
|
types: [
|
@@ -413,7 +691,7 @@ describe('batch issuing test', () => {
|
|
413
691
|
purpose: 'Issuing Career Credential', // by default have a generic message
|
414
692
|
activationDate: expect.stringMatching(ISO_DATETIME_TZ_FORMAT),
|
415
693
|
termsUrl: 'http://example.com/terms.html',
|
416
|
-
authTokenExpiresIn:
|
694
|
+
authTokenExpiresIn: 525600,
|
417
695
|
},
|
418
696
|
newExchangeOffers: [
|
419
697
|
{
|
@@ -464,17 +742,19 @@ describe('batch issuing test', () => {
|
|
464
742
|
'data/passport-offer.template.json'
|
465
743
|
),
|
466
744
|
termsUrl: 'http://example.com/terms.html',
|
467
|
-
|
745
|
+
idCredentialType: 'PassportV1.0',
|
468
746
|
did: 'did:ion:sap123',
|
747
|
+
new: true,
|
748
|
+
dryrun: true,
|
469
749
|
};
|
470
750
|
|
471
|
-
const updates = await
|
751
|
+
const updates = await runBatchIssuing(options);
|
472
752
|
expect(
|
473
|
-
new Date(updates.
|
753
|
+
new Date(updates.disclosureRequest.activationDate).getTime()
|
474
754
|
).toBeLessThan(Date.now());
|
475
755
|
|
476
756
|
expect(updates).toEqual({
|
477
|
-
|
757
|
+
disclosureRequest: {
|
478
758
|
configurationType: 'issuing',
|
479
759
|
vendorEndpoint: 'integrated-issuing-identification',
|
480
760
|
types: [
|
@@ -499,7 +779,7 @@ describe('batch issuing test', () => {
|
|
499
779
|
purpose: 'Issuing Career Credential', // by default have a generic message
|
500
780
|
activationDate: expect.stringMatching(ISO_DATETIME_TZ_FORMAT),
|
501
781
|
termsUrl: 'http://example.com/terms.html',
|
502
|
-
authTokenExpiresIn:
|
782
|
+
authTokenExpiresIn: 525600,
|
503
783
|
},
|
504
784
|
newExchangeOffers: [
|
505
785
|
{
|
@@ -550,17 +830,19 @@ describe('batch issuing test', () => {
|
|
550
830
|
'data/national-id-card-offer.template.json'
|
551
831
|
),
|
552
832
|
termsUrl: 'http://example.com/terms.html',
|
553
|
-
|
833
|
+
idCredentialType: 'NationalIdCardV1.0',
|
554
834
|
did: 'did:ion:sap123',
|
835
|
+
new: true,
|
836
|
+
dryrun: true,
|
555
837
|
};
|
556
838
|
|
557
|
-
const updates = await
|
839
|
+
const updates = await runBatchIssuing(options);
|
558
840
|
expect(
|
559
|
-
new Date(updates.
|
841
|
+
new Date(updates.disclosureRequest.activationDate).getTime()
|
560
842
|
).toBeLessThan(Date.now());
|
561
843
|
|
562
844
|
expect(updates).toEqual({
|
563
|
-
|
845
|
+
disclosureRequest: {
|
564
846
|
configurationType: 'issuing',
|
565
847
|
vendorEndpoint: 'integrated-issuing-identification',
|
566
848
|
types: [
|
@@ -585,7 +867,7 @@ describe('batch issuing test', () => {
|
|
585
867
|
purpose: 'Issuing Career Credential', // by default have a generic message
|
586
868
|
activationDate: expect.stringMatching(ISO_DATETIME_TZ_FORMAT),
|
587
869
|
termsUrl: 'http://example.com/terms.html',
|
588
|
-
authTokenExpiresIn:
|
870
|
+
authTokenExpiresIn: 525600,
|
589
871
|
},
|
590
872
|
newExchangeOffers: [
|
591
873
|
{
|
@@ -636,17 +918,19 @@ describe('batch issuing test', () => {
|
|
636
918
|
'data/proof-of-age-offer.template.json'
|
637
919
|
),
|
638
920
|
termsUrl: 'http://example.com/terms.html',
|
639
|
-
|
921
|
+
idCredentialType: 'ProofOfAgeV1.0',
|
640
922
|
did: 'did:ion:sap123',
|
923
|
+
new: true,
|
924
|
+
dryrun: true,
|
641
925
|
};
|
642
926
|
|
643
|
-
const updates = await
|
927
|
+
const updates = await runBatchIssuing(options);
|
644
928
|
expect(
|
645
|
-
new Date(updates.
|
929
|
+
new Date(updates.disclosureRequest.activationDate).getTime()
|
646
930
|
).toBeLessThan(Date.now());
|
647
931
|
|
648
932
|
expect(updates).toEqual({
|
649
|
-
|
933
|
+
disclosureRequest: {
|
650
934
|
configurationType: 'issuing',
|
651
935
|
vendorEndpoint: 'integrated-issuing-identification',
|
652
936
|
types: [
|
@@ -671,7 +955,7 @@ describe('batch issuing test', () => {
|
|
671
955
|
purpose: 'Issuing Career Credential', // by default have a generic message
|
672
956
|
activationDate: expect.stringMatching(ISO_DATETIME_TZ_FORMAT),
|
673
957
|
termsUrl: 'http://example.com/terms.html',
|
674
|
-
authTokenExpiresIn:
|
958
|
+
authTokenExpiresIn: 525600,
|
675
959
|
},
|
676
960
|
newExchangeOffers: [
|
677
961
|
{
|
@@ -723,16 +1007,19 @@ describe('batch issuing test', () => {
|
|
723
1007
|
),
|
724
1008
|
termsUrl: 'http://example.com/terms.html',
|
725
1009
|
did: 'did:ion:sap123',
|
726
|
-
|
1010
|
+
idCredentialType: 'EmailV1.0',
|
1011
|
+
vendorUseridColumn: 'email',
|
1012
|
+
new: true,
|
1013
|
+
dryrun: true,
|
727
1014
|
};
|
728
1015
|
|
729
|
-
const updates = await
|
1016
|
+
const updates = await runBatchIssuing(options);
|
730
1017
|
expect(
|
731
|
-
new Date(updates.
|
1018
|
+
new Date(updates.disclosureRequest.activationDate).getTime()
|
732
1019
|
).toBeLessThan(Date.now());
|
733
1020
|
|
734
1021
|
expect(updates).toEqual({
|
735
|
-
|
1022
|
+
disclosureRequest: {
|
736
1023
|
configurationType: 'issuing',
|
737
1024
|
vendorEndpoint: 'integrated-issuing-identification',
|
738
1025
|
types: [
|
@@ -748,7 +1035,7 @@ describe('batch issuing test', () => {
|
|
748
1035
|
rule: 'pick',
|
749
1036
|
},
|
750
1037
|
],
|
751
|
-
vendorUserIdIndex:
|
1038
|
+
vendorUserIdIndex: 2,
|
752
1039
|
},
|
753
1040
|
vendorDisclosureId: expect.any(Number),
|
754
1041
|
setIssuingDefault: true,
|
@@ -757,7 +1044,7 @@ describe('batch issuing test', () => {
|
|
757
1044
|
purpose: 'Issuing Career Credential', // by default have a generic message
|
758
1045
|
activationDate: expect.stringMatching(ISO_DATETIME_TZ_FORMAT),
|
759
1046
|
termsUrl: 'http://example.com/terms.html',
|
760
|
-
authTokenExpiresIn:
|
1047
|
+
authTokenExpiresIn: 525600,
|
761
1048
|
},
|
762
1049
|
newExchangeOffers: [
|
763
1050
|
{
|
@@ -814,13 +1101,16 @@ describe('batch issuing test', () => {
|
|
814
1101
|
expiresInHours: 100,
|
815
1102
|
activatesInHours: 10,
|
816
1103
|
did: 'did:ion:sap456',
|
817
|
-
|
1104
|
+
idCredentialType: 'EmailV1.0',
|
1105
|
+
vendorUseridColumn: 'email',
|
1106
|
+
new: true,
|
1107
|
+
dryrun: true,
|
818
1108
|
};
|
819
1109
|
|
820
|
-
const updates = await
|
1110
|
+
const updates = await runBatchIssuing(options);
|
821
1111
|
|
822
1112
|
expect(updates).toEqual({
|
823
|
-
|
1113
|
+
disclosureRequest: {
|
824
1114
|
configurationType: 'issuing',
|
825
1115
|
vendorEndpoint: 'integrated-issuing-identification',
|
826
1116
|
types: [
|
@@ -836,7 +1126,7 @@ describe('batch issuing test', () => {
|
|
836
1126
|
rule: 'pick',
|
837
1127
|
},
|
838
1128
|
],
|
839
|
-
vendorUserIdIndex:
|
1129
|
+
vendorUserIdIndex: 2,
|
840
1130
|
},
|
841
1131
|
vendorDisclosureId: expect.any(Number),
|
842
1132
|
setIssuingDefault: true,
|
@@ -846,7 +1136,7 @@ describe('batch issuing test', () => {
|
|
846
1136
|
activationDate: expect.stringMatching(ISO_DATETIME_TZ_FORMAT),
|
847
1137
|
termsUrl: 'http://example.com/terms.html',
|
848
1138
|
label: options.label,
|
849
|
-
authTokenExpiresIn:
|
1139
|
+
authTokenExpiresIn: 525600,
|
850
1140
|
},
|
851
1141
|
newExchangeOffers: [
|
852
1142
|
{
|
@@ -893,24 +1183,107 @@ describe('batch issuing test', () => {
|
|
893
1183
|
});
|
894
1184
|
|
895
1185
|
expect(
|
896
|
-
new Date(updates.
|
1186
|
+
new Date(updates.disclosureRequest.activationDate).getTime()
|
897
1187
|
).toBeGreaterThan(Date.now());
|
898
1188
|
});
|
899
1189
|
|
900
|
-
|
901
|
-
const
|
902
|
-
csvFilename: path.join(__dirname, 'data/variables.csv'),
|
903
|
-
offerTemplateFilename: path.join(
|
904
|
-
__dirname,
|
905
|
-
'data/email-offer.template.json'
|
906
|
-
),
|
907
|
-
termsUrl: 'http://example.com/terms.html',
|
908
|
-
did: 'did:ion:sap123',
|
909
|
-
credentialType: 'EmailV1.0',
|
910
|
-
disclosure: 'foo',
|
911
|
-
};
|
1190
|
+
describe('existing disclosure endpoints', () => {
|
1191
|
+
const existingDisclosures = [{ id: nanoid() }, { id: nanoid() }];
|
912
1192
|
|
913
|
-
|
914
|
-
|
1193
|
+
it('should have error if the disclosureRequest is not found', async () => {
|
1194
|
+
const agentUrl = 'https://exampleUrl';
|
1195
|
+
const did = 'did:ion:sap123';
|
1196
|
+
nock(agentUrl)
|
1197
|
+
.get(
|
1198
|
+
`/operator-api/v0.8/tenants/${did}/disclosures?vendorEndpoint=integrated-issuing-identification`
|
1199
|
+
)
|
1200
|
+
.reply(200, existingDisclosures);
|
1201
|
+
|
1202
|
+
const options = {
|
1203
|
+
csvFilename: path.join(__dirname, 'data/variables.csv'),
|
1204
|
+
offerTemplateFilename: path.join(
|
1205
|
+
__dirname,
|
1206
|
+
'data/email-offer.template.json'
|
1207
|
+
),
|
1208
|
+
did,
|
1209
|
+
termsUrl: 'http://example.com/terms.html',
|
1210
|
+
idCredentialType: 'EmailV1.0',
|
1211
|
+
disclosure: 'foo',
|
1212
|
+
dryrun: true,
|
1213
|
+
endpoint: agentUrl,
|
1214
|
+
authToken: 'fakeToken',
|
1215
|
+
};
|
1216
|
+
|
1217
|
+
await expect(() => runBatchIssuing(options)).rejects.toThrowError();
|
1218
|
+
});
|
1219
|
+
|
1220
|
+
it('should find the existing disclosure disclosureRequest', async () => {
|
1221
|
+
const agentUrl = 'https://exampleUrl';
|
1222
|
+
const did = 'did:ion:sap123';
|
1223
|
+
nock(agentUrl)
|
1224
|
+
.get(
|
1225
|
+
`/operator-api/v0.8/tenants/${did}/disclosures?vendorEndpoint=integrated-issuing-identification`
|
1226
|
+
)
|
1227
|
+
.reply(200, existingDisclosures);
|
1228
|
+
|
1229
|
+
const options = {
|
1230
|
+
csvFilename: path.join(__dirname, 'data/variables.csv'),
|
1231
|
+
offerTemplateFilename: path.join(
|
1232
|
+
__dirname,
|
1233
|
+
'data/email-offer.template.json'
|
1234
|
+
),
|
1235
|
+
did,
|
1236
|
+
termsUrl: 'http://example.com/terms.html',
|
1237
|
+
idCredentialType: 'EmailV1.0',
|
1238
|
+
vendorUseridColumn: 'email',
|
1239
|
+
disclosure: existingDisclosures[0].id,
|
1240
|
+
dryrun: true,
|
1241
|
+
endpoint: agentUrl,
|
1242
|
+
authToken: 'fakeToken',
|
1243
|
+
};
|
1244
|
+
|
1245
|
+
const updates = await runBatchIssuing(options);
|
1246
|
+
expect(updates).toEqual({
|
1247
|
+
disclosureRequest: existingDisclosures[0],
|
1248
|
+
newExchangeOffers: [
|
1249
|
+
{
|
1250
|
+
newOffer: {
|
1251
|
+
type: ['EmailV1.0'],
|
1252
|
+
issuer: {
|
1253
|
+
id: did,
|
1254
|
+
},
|
1255
|
+
credentialSubject: {
|
1256
|
+
vendorUserId: 'joan.lee@sap.com',
|
1257
|
+
email: 'joan.lee@sap.com',
|
1258
|
+
},
|
1259
|
+
|
1260
|
+
offerId: expect.any(String),
|
1261
|
+
},
|
1262
|
+
newExchange: {
|
1263
|
+
type: 'ISSUING',
|
1264
|
+
identityMatcherValues: ['joan.lee@sap.com'],
|
1265
|
+
},
|
1266
|
+
},
|
1267
|
+
{
|
1268
|
+
newOffer: {
|
1269
|
+
type: ['EmailV1.0'],
|
1270
|
+
issuer: {
|
1271
|
+
id: did,
|
1272
|
+
},
|
1273
|
+
credentialSubject: {
|
1274
|
+
vendorUserId: 'john.smith@sap.com',
|
1275
|
+
email: 'john.smith@sap.com',
|
1276
|
+
},
|
1277
|
+
|
1278
|
+
offerId: expect.any(String),
|
1279
|
+
},
|
1280
|
+
newExchange: {
|
1281
|
+
type: 'ISSUING',
|
1282
|
+
identityMatcherValues: ['john.smith@sap.com'],
|
1283
|
+
},
|
1284
|
+
},
|
1285
|
+
],
|
1286
|
+
});
|
1287
|
+
});
|
915
1288
|
});
|
916
1289
|
});
|