@verii/data-loader 1.1.0-pre.1770077593 → 1.1.0-pre.1770080046
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 +12 -11
- package/src/batch-issuing/fetchers.js +6 -6
- package/src/batch-issuing/index.js +19 -19
- package/src/batch-issuing/orchestrators.js +22 -22
- package/src/batch-issuing/prepare-data.js +5 -5
- package/src/batch-issuing/prompts.js +2 -2
- package/src/helpers/prepare-variable-sets.js +2 -2
- package/src/vendor-credentials/index.js +5 -5
- package/test/batch-issuing.test.js +38 -38
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verii/data-loader",
|
|
3
|
-
"version": "1.1.0-pre.
|
|
3
|
+
"version": "1.1.0-pre.1770080046",
|
|
4
4
|
"description": "A tool for uploading data to the different target systems.",
|
|
5
5
|
"repository": "https://github.com/LFDT-Verii/core",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
11
|
"test": "cross-env NODE_ENV=test node --test --test-concurrency=1 --experimental-test-module-mocks --experimental-test-coverage **/*.test.js --passWithNoTests",
|
|
12
|
-
"lint": "eslint
|
|
12
|
+
"lint": "eslint .",
|
|
13
13
|
"lint:ci": "eslint . --format json >> eslint-results.json",
|
|
14
|
-
"lint:fix": "eslint --fix
|
|
14
|
+
"lint:fix": "eslint --fix ."
|
|
15
15
|
},
|
|
16
16
|
"author": "Itay Podhajcer",
|
|
17
17
|
"license": "Apache-2.0",
|
|
@@ -19,16 +19,17 @@
|
|
|
19
19
|
"access": "public"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"eslint": "
|
|
23
|
-
"eslint-config-airbnb-
|
|
24
|
-
"eslint-config-prettier": "
|
|
25
|
-
"eslint-plugin-better-mutation": "1.
|
|
22
|
+
"eslint": "9.39.2",
|
|
23
|
+
"eslint-config-airbnb-extended": "3.0.1",
|
|
24
|
+
"eslint-config-prettier": "10.1.8",
|
|
25
|
+
"eslint-plugin-better-mutation": "2.1.0",
|
|
26
26
|
"eslint-plugin-import": "2.32.0",
|
|
27
|
-
"eslint-plugin-prettier": "
|
|
28
|
-
"eslint-watch": "
|
|
27
|
+
"eslint-plugin-prettier": "5.5.5",
|
|
28
|
+
"eslint-watch": "8.0.0",
|
|
29
29
|
"expect": "30.2.0",
|
|
30
|
+
"globals": "16.5.0",
|
|
30
31
|
"nock": "15.0.0-beta.6",
|
|
31
|
-
"prettier": "
|
|
32
|
+
"prettier": "3.8.1"
|
|
32
33
|
},
|
|
33
34
|
"dependencies": {
|
|
34
35
|
"chalk": "~4.1.2",
|
|
@@ -42,5 +43,5 @@
|
|
|
42
43
|
"nanoid": "5.1.6",
|
|
43
44
|
"strip-bom-stream": "^4.0.0"
|
|
44
45
|
},
|
|
45
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "b095afed30b67c9643860bfddec83169ef8a50b4"
|
|
46
47
|
}
|
|
@@ -39,7 +39,7 @@ const initFetchers = (options) => {
|
|
|
39
39
|
printInfo('Retrieving disclosure list');
|
|
40
40
|
const url = new URL(
|
|
41
41
|
`tenants/${param}/disclosures`,
|
|
42
|
-
credentialAgentTenantGot.defaults.options.prefixUrl
|
|
42
|
+
credentialAgentTenantGot.defaults.options.prefixUrl,
|
|
43
43
|
);
|
|
44
44
|
|
|
45
45
|
if (!isEmpty(vendorEndpoints)) {
|
|
@@ -66,7 +66,7 @@ const initFetchers = (options) => {
|
|
|
66
66
|
},
|
|
67
67
|
createOffer: async (exchange, newOffer) => {
|
|
68
68
|
printInfo(
|
|
69
|
-
`Adding offer ${newOffer.offerId} to exchange id: ${exchange.id}
|
|
69
|
+
`Adding offer ${newOffer.offerId} to exchange id: ${exchange.id}`,
|
|
70
70
|
);
|
|
71
71
|
return credentialAgentTenantGot
|
|
72
72
|
.post(`tenants/${param}/exchanges/${exchange.id}/offers`, {
|
|
@@ -78,8 +78,8 @@ const initFetchers = (options) => {
|
|
|
78
78
|
printInfo(
|
|
79
79
|
`Completing exchange id: ${exchange.id} with offers ${map(
|
|
80
80
|
'id',
|
|
81
|
-
offers
|
|
82
|
-
)}
|
|
81
|
+
offers,
|
|
82
|
+
)}`,
|
|
83
83
|
);
|
|
84
84
|
return credentialAgentTenantGot
|
|
85
85
|
.post(`tenants/${param}/exchanges/${exchange.id}/offers/complete`)
|
|
@@ -88,7 +88,7 @@ const initFetchers = (options) => {
|
|
|
88
88
|
loadExchangeQrcode: async (exchange) =>
|
|
89
89
|
(
|
|
90
90
|
await credentialAgentTenantGot.get(
|
|
91
|
-
`tenants/${param}/exchanges/${exchange.id}/qrcode.png
|
|
91
|
+
`tenants/${param}/exchanges/${exchange.id}/qrcode.png`,
|
|
92
92
|
)
|
|
93
93
|
).rawBody,
|
|
94
94
|
loadExchangeDeeplink: async (exchange) =>
|
|
@@ -98,7 +98,7 @@ const initFetchers = (options) => {
|
|
|
98
98
|
loadDisclosureQrcode: async (disclosure) =>
|
|
99
99
|
(
|
|
100
100
|
await credentialAgentTenantGot.get(
|
|
101
|
-
`tenants/${param}/disclosures/${disclosure.id}/qrcode.png
|
|
101
|
+
`tenants/${param}/disclosures/${disclosure.id}/qrcode.png`,
|
|
102
102
|
)
|
|
103
103
|
).rawBody,
|
|
104
104
|
loadDisclosureDeeplink: async (disclosure) =>
|
|
@@ -15,27 +15,27 @@ program
|
|
|
15
15
|
.usage('[options]')
|
|
16
16
|
.requiredOption(
|
|
17
17
|
'-c, --csv-filename <filename>',
|
|
18
|
-
'file name containing variables'
|
|
18
|
+
'file name containing variables',
|
|
19
19
|
)
|
|
20
20
|
.requiredOption(
|
|
21
21
|
'-o, --offer-template-filename <filename>',
|
|
22
|
-
'file name containing the credential template file'
|
|
22
|
+
'file name containing the credential template file',
|
|
23
23
|
)
|
|
24
24
|
.requiredOption(
|
|
25
25
|
'-p, --path <path>',
|
|
26
|
-
'the output directory to use where QR codes and output state files are stored'
|
|
26
|
+
'the output directory to use where QR codes and output state files are stored',
|
|
27
27
|
)
|
|
28
28
|
.requiredOption(
|
|
29
29
|
'-t, --terms-url <termsUrl>',
|
|
30
|
-
'the url to the T&Cs that holder must consent to'
|
|
30
|
+
'the url to the T&Cs that holder must consent to',
|
|
31
31
|
)
|
|
32
32
|
.option(
|
|
33
33
|
'-d, --did <did>',
|
|
34
|
-
'DID of the issuing organization. One of `tenant` or `did` must be specified.'
|
|
34
|
+
'DID of the issuing organization. One of `tenant` or `did` must be specified.',
|
|
35
35
|
)
|
|
36
36
|
.option(
|
|
37
37
|
'-n, --tenant <tenantId>',
|
|
38
|
-
"Id of the issuing organization's tenant. One of `tenant` or `did` must be specified."
|
|
38
|
+
"Id of the issuing organization's tenant. One of `tenant` or `did` must be specified.",
|
|
39
39
|
)
|
|
40
40
|
.option(
|
|
41
41
|
'-m, --identifier-match-column <identifierMatchColumn>',
|
|
@@ -43,62 +43,62 @@ program
|
|
|
43
43
|
For example this should be the email column if matching against an Email credential type, or the phone number if
|
|
44
44
|
matching against a Phone credential type. Accepts header name or index. Default is 0.`,
|
|
45
45
|
parseColumn,
|
|
46
|
-
0
|
|
46
|
+
0,
|
|
47
47
|
)
|
|
48
48
|
.option(
|
|
49
49
|
'-u, --vendor-userid-column <vendorUseridColumn>',
|
|
50
50
|
`the column from the CSV that is users id. Value is made available as "vendorUserId" in the offer template. Accepts
|
|
51
51
|
header name or index. Default is 0.`,
|
|
52
52
|
parseColumn,
|
|
53
|
-
0
|
|
53
|
+
0,
|
|
54
54
|
)
|
|
55
55
|
.option(
|
|
56
56
|
'-e, --endpoint <url>',
|
|
57
|
-
'Credential Agent Endpoint to call to execute the issuing'
|
|
57
|
+
'Credential Agent Endpoint to call to execute the issuing',
|
|
58
58
|
)
|
|
59
59
|
.option(
|
|
60
60
|
'-a, --auth-token <url>',
|
|
61
|
-
'Bearer Auth Token to be used on the Agent API'
|
|
61
|
+
'Bearer Auth Token to be used on the Agent API',
|
|
62
62
|
)
|
|
63
63
|
.option('-l, --label <label>', 'A label to attach to the documents inserted')
|
|
64
64
|
.option(
|
|
65
65
|
'-v, --var <var...>',
|
|
66
|
-
'A variable that will be injected into the credential template renderer. use name=value'
|
|
66
|
+
'A variable that will be injected into the credential template renderer. use name=value',
|
|
67
67
|
)
|
|
68
68
|
.option(
|
|
69
69
|
'-y, --credential-type <idCredentialType>',
|
|
70
70
|
'the credential type used for identifying the user. Default is EmailV1.0.',
|
|
71
|
-
'EmailV1.0'
|
|
71
|
+
'EmailV1.0',
|
|
72
72
|
)
|
|
73
73
|
.option(
|
|
74
74
|
'--purpose <purpose>',
|
|
75
|
-
'The purpose to display to the user. Use a maximum for 64 chars. Default is "Career Credential Issuing"'
|
|
75
|
+
'The purpose to display to the user. Use a maximum for 64 chars. Default is "Career Credential Issuing"',
|
|
76
76
|
)
|
|
77
77
|
.option(
|
|
78
78
|
'--authTokenExpiresIn <authTokenExpiresIn>',
|
|
79
79
|
'The number of minutes that the offer will be available for after activation. Default is 365 days.',
|
|
80
|
-
'525600'
|
|
80
|
+
'525600',
|
|
81
81
|
)
|
|
82
82
|
.option('--new', 'Use a new disclosure for batch issuing')
|
|
83
83
|
.option(
|
|
84
84
|
'-i, --disclosure [disclosure]',
|
|
85
|
-
'An existing disclosure to use for the batch issuing'
|
|
85
|
+
'An existing disclosure to use for the batch issuing',
|
|
86
86
|
)
|
|
87
87
|
.option(
|
|
88
88
|
'--legacy',
|
|
89
|
-
'the target credential agent is running in the "LEGACY" offer type mode. Default is false'
|
|
89
|
+
'the target credential agent is running in the "LEGACY" offer type mode. Default is false',
|
|
90
90
|
)
|
|
91
91
|
.option(
|
|
92
92
|
'-x --outputcsv',
|
|
93
|
-
"if passed an output csv is generated including the vendor's user id as the first column and the generated qrcode filename and deeplink"
|
|
93
|
+
"if passed an output csv is generated including the vendor's user id as the first column and the generated qrcode filename and deeplink",
|
|
94
94
|
)
|
|
95
95
|
.option(
|
|
96
96
|
'--x-name <outputCsvName>',
|
|
97
|
-
'The file name for the output CSV. Default is "output"'
|
|
97
|
+
'The file name for the output CSV. Default is "output"',
|
|
98
98
|
)
|
|
99
99
|
.option(
|
|
100
100
|
'--dryrun',
|
|
101
|
-
'if passed in then a dry run executes showing how the data will be formatted'
|
|
101
|
+
'if passed in then a dry run executes showing how the data will be formatted',
|
|
102
102
|
)
|
|
103
103
|
.action(async () => {
|
|
104
104
|
const options = program.opts();
|
|
@@ -40,13 +40,13 @@ const runBatchIssuing = async (opts) => {
|
|
|
40
40
|
const disclosureRequest = await loadOrPrepareNewDisclosureRequest(
|
|
41
41
|
csvHeaders,
|
|
42
42
|
options,
|
|
43
|
-
context
|
|
43
|
+
context,
|
|
44
44
|
);
|
|
45
45
|
|
|
46
46
|
const newExchangeOffers = await prepareExchangeOffers(
|
|
47
47
|
csvHeaders,
|
|
48
48
|
csvRows,
|
|
49
|
-
options
|
|
49
|
+
options,
|
|
50
50
|
);
|
|
51
51
|
|
|
52
52
|
if (options.dryrun) {
|
|
@@ -55,8 +55,8 @@ const runBatchIssuing = async (opts) => {
|
|
|
55
55
|
JSON.stringify(
|
|
56
56
|
omitBy(isNil, { disclosureRequest, newExchangeOffers }),
|
|
57
57
|
0,
|
|
58
|
-
2
|
|
59
|
-
)
|
|
58
|
+
2,
|
|
59
|
+
),
|
|
60
60
|
);
|
|
61
61
|
|
|
62
62
|
return { disclosureRequest, newExchangeOffers };
|
|
@@ -74,13 +74,13 @@ const runBatchIssuing = async (opts) => {
|
|
|
74
74
|
issuingDisclosure,
|
|
75
75
|
newExchangeOffers,
|
|
76
76
|
options,
|
|
77
|
-
context
|
|
77
|
+
context,
|
|
78
78
|
)
|
|
79
79
|
: await runSingleQrCodeBatchIssuing(
|
|
80
80
|
issuingDisclosure,
|
|
81
81
|
newExchangeOffers,
|
|
82
82
|
options,
|
|
83
|
-
context
|
|
83
|
+
context,
|
|
84
84
|
);
|
|
85
85
|
|
|
86
86
|
writeOutput(outputs, {
|
|
@@ -105,7 +105,7 @@ const loadExistingDisclosuresIfRequired = async (options, context) => {
|
|
|
105
105
|
const useNewDisclosure = await askUseNewDisclosure();
|
|
106
106
|
if (!useNewDisclosure)
|
|
107
107
|
throw new Error(
|
|
108
|
-
'no existing disclosures on the target agent. Use a new disclosure'
|
|
108
|
+
'no existing disclosures on the target agent. Use a new disclosure',
|
|
109
109
|
);
|
|
110
110
|
|
|
111
111
|
return [];
|
|
@@ -125,7 +125,7 @@ const runLegacyBatchIssuing = async (
|
|
|
125
125
|
disclosureRequest,
|
|
126
126
|
newExchangeOffers,
|
|
127
127
|
options,
|
|
128
|
-
context
|
|
128
|
+
context,
|
|
129
129
|
) => {
|
|
130
130
|
const outputs = [];
|
|
131
131
|
for (const newExchangeOffer of newExchangeOffers) {
|
|
@@ -137,8 +137,8 @@ const runLegacyBatchIssuing = async (
|
|
|
137
137
|
disclosureRequest,
|
|
138
138
|
},
|
|
139
139
|
options,
|
|
140
|
-
context
|
|
141
|
-
)
|
|
140
|
+
context,
|
|
141
|
+
),
|
|
142
142
|
);
|
|
143
143
|
}
|
|
144
144
|
|
|
@@ -149,7 +149,7 @@ const runSingleQrCodeBatchIssuing = async (
|
|
|
149
149
|
disclosureRequest,
|
|
150
150
|
newExchangeOffers,
|
|
151
151
|
options,
|
|
152
|
-
context
|
|
152
|
+
context,
|
|
153
153
|
) => {
|
|
154
154
|
const outputs = [];
|
|
155
155
|
for (const newExchangeOffer of newExchangeOffers) {
|
|
@@ -160,8 +160,8 @@ const runSingleQrCodeBatchIssuing = async (
|
|
|
160
160
|
...newExchangeOffer,
|
|
161
161
|
disclosureRequest,
|
|
162
162
|
},
|
|
163
|
-
context
|
|
164
|
-
)
|
|
163
|
+
context,
|
|
164
|
+
),
|
|
165
165
|
);
|
|
166
166
|
}
|
|
167
167
|
|
|
@@ -179,7 +179,7 @@ const runSingleQrCodeBatchIssuing = async (
|
|
|
179
179
|
const loadOrPrepareNewDisclosureRequest = async (
|
|
180
180
|
csvHeaders,
|
|
181
181
|
options,
|
|
182
|
-
context
|
|
182
|
+
context,
|
|
183
183
|
) => {
|
|
184
184
|
const disclosures = await loadExistingDisclosuresIfRequired(options, context);
|
|
185
185
|
|
|
@@ -225,7 +225,7 @@ const writeDisclosureToJson = async (disclosureRequest, options) => {
|
|
|
225
225
|
const { filePath: disclosureFilePath } = await writeJsonFile(
|
|
226
226
|
disclosureRequest,
|
|
227
227
|
`disclosure-${disclosureRequest.id}`,
|
|
228
|
-
options
|
|
228
|
+
options,
|
|
229
229
|
);
|
|
230
230
|
await writeJsonFile(
|
|
231
231
|
{
|
|
@@ -235,14 +235,14 @@ const writeDisclosureToJson = async (disclosureRequest, options) => {
|
|
|
235
235
|
...options,
|
|
236
236
|
},
|
|
237
237
|
'lastrun',
|
|
238
|
-
options
|
|
238
|
+
options,
|
|
239
239
|
);
|
|
240
240
|
};
|
|
241
241
|
|
|
242
242
|
const createOfferExchangeAndQrCode = async (
|
|
243
243
|
{ newExchange, newOffer, disclosureRequest },
|
|
244
244
|
options,
|
|
245
|
-
context
|
|
245
|
+
context,
|
|
246
246
|
) => {
|
|
247
247
|
const { fetchers } = context;
|
|
248
248
|
const { exchange, offer, vendorUserId } = await createOfferExchange(
|
|
@@ -251,7 +251,7 @@ const createOfferExchangeAndQrCode = async (
|
|
|
251
251
|
newOffer,
|
|
252
252
|
disclosureRequest,
|
|
253
253
|
},
|
|
254
|
-
context
|
|
254
|
+
context,
|
|
255
255
|
);
|
|
256
256
|
|
|
257
257
|
const deeplink = await fetchers.loadExchangeDeeplink(exchange);
|
|
@@ -259,7 +259,7 @@ const createOfferExchangeAndQrCode = async (
|
|
|
259
259
|
const { filePath } = await writeQrCodeFile(
|
|
260
260
|
`qrcode-${vendorUserId}`,
|
|
261
261
|
qrcode,
|
|
262
|
-
options
|
|
262
|
+
options,
|
|
263
263
|
);
|
|
264
264
|
printInfo(`${vendorUserId} Done. Qrcode file:${filePath}`);
|
|
265
265
|
printInfo('');
|
|
@@ -276,7 +276,7 @@ const createOfferExchangeAndQrCode = async (
|
|
|
276
276
|
|
|
277
277
|
const createOfferExchange = async (
|
|
278
278
|
{ newExchange, newOffer, disclosureRequest },
|
|
279
|
-
context
|
|
279
|
+
context,
|
|
280
280
|
) => {
|
|
281
281
|
const { fetchers } = context;
|
|
282
282
|
const { vendorUserId } = newOffer.credentialSubject;
|
|
@@ -297,7 +297,7 @@ const createOfferExchange = async (
|
|
|
297
297
|
const validateOptions = (options) => {
|
|
298
298
|
if (options.dryrun == null && options.endpoint == null) {
|
|
299
299
|
throw new Error(
|
|
300
|
-
'"-e" or "--endpoint" is required unless executing a "dryrun"'
|
|
300
|
+
'"-e" or "--endpoint" is required unless executing a "dryrun"',
|
|
301
301
|
);
|
|
302
302
|
}
|
|
303
303
|
if (options.endpoint != null && options.authToken == null) {
|
|
@@ -324,7 +324,7 @@ const validateCredentialType = (idCredentialType) => {
|
|
|
324
324
|
!allowedIdCredentialTypes.includes(idCredentialType)
|
|
325
325
|
) {
|
|
326
326
|
throw new Error(
|
|
327
|
-
`${idCredentialType} doesn't exist. Please use one of ${allowedIdCredentialTypes}
|
|
327
|
+
`${idCredentialType} doesn't exist. Please use one of ${allowedIdCredentialTypes}`,
|
|
328
328
|
);
|
|
329
329
|
}
|
|
330
330
|
};
|
|
@@ -24,7 +24,7 @@ const prepareExchangeOffers = async (csvHeaders, csvRows, options) => {
|
|
|
24
24
|
}),
|
|
25
25
|
newExchange: prepareNewExchange({ variableSet, ...options }),
|
|
26
26
|
}),
|
|
27
|
-
variableSets
|
|
27
|
+
variableSets,
|
|
28
28
|
);
|
|
29
29
|
};
|
|
30
30
|
|
|
@@ -59,7 +59,7 @@ const validateVariableSet = (variableSet) => {
|
|
|
59
59
|
const validateVendorUserIdVariable = (vendorUserId) => {
|
|
60
60
|
if (isEmpty(vendorUserId)) {
|
|
61
61
|
throw new Error(
|
|
62
|
-
'vendorUserId variable must exist. Use the -u <column> option'
|
|
62
|
+
'vendorUserId variable must exist. Use the -u <column> option',
|
|
63
63
|
);
|
|
64
64
|
}
|
|
65
65
|
};
|
|
@@ -85,8 +85,8 @@ const validateVendorUserIdInOffer = (offer, variableSet) => {
|
|
|
85
85
|
if (!includes(value, variableSet)) {
|
|
86
86
|
throw new Error(
|
|
87
87
|
`${VENDOR_USER_ID_PATH}: ${value} cannot be hardcoded and must be defined in ${JSON.stringify(
|
|
88
|
-
variableSet
|
|
89
|
-
)})
|
|
88
|
+
variableSet,
|
|
89
|
+
)})`,
|
|
90
90
|
);
|
|
91
91
|
}
|
|
92
92
|
};
|
|
@@ -125,7 +125,7 @@ const prepareNewDisclosureRequest = (
|
|
|
125
125
|
vendorUseridColumn,
|
|
126
126
|
authTokenExpiresIn,
|
|
127
127
|
...options
|
|
128
|
-
}
|
|
128
|
+
},
|
|
129
129
|
) => {
|
|
130
130
|
const activationDate = computeActivationDate(options);
|
|
131
131
|
|
|
@@ -11,10 +11,10 @@ const disclosureListQuestion = (disclosures) => ({
|
|
|
11
11
|
map((disclosure) => ({
|
|
12
12
|
name: `${disclosure.purpose}, ${format(
|
|
13
13
|
parseISO(disclosure.createdAt),
|
|
14
|
-
'MMM d yyyy h:mma'
|
|
14
|
+
'MMM d yyyy h:mma',
|
|
15
15
|
)}`,
|
|
16
16
|
value: disclosure.id,
|
|
17
|
-
}))
|
|
17
|
+
})),
|
|
18
18
|
)(disclosures),
|
|
19
19
|
});
|
|
20
20
|
|
|
@@ -4,7 +4,7 @@ const { getColName } = require('./load-csv');
|
|
|
4
4
|
const prepareVariableSets = async (
|
|
5
5
|
csvHeaders,
|
|
6
6
|
csvRows,
|
|
7
|
-
{ vendorUseridColumn, vars, did }
|
|
7
|
+
{ vendorUseridColumn, vars, did },
|
|
8
8
|
) => {
|
|
9
9
|
const overrideVars = { ...vars };
|
|
10
10
|
if (did != null) {
|
|
@@ -16,7 +16,7 @@ const prepareVariableSets = async (
|
|
|
16
16
|
...overrideVars,
|
|
17
17
|
vendorUserId: csvRow[getColName(csvHeaders, vendorUseridColumn)],
|
|
18
18
|
}),
|
|
19
|
-
csvRows
|
|
19
|
+
csvRows,
|
|
20
20
|
);
|
|
21
21
|
};
|
|
22
22
|
|
|
@@ -15,26 +15,26 @@ program
|
|
|
15
15
|
.usage('[options]')
|
|
16
16
|
.requiredOption(
|
|
17
17
|
'-c, --csv-filename <filename>',
|
|
18
|
-
'File name containing variables'
|
|
18
|
+
'File name containing variables',
|
|
19
19
|
)
|
|
20
20
|
.requiredOption(
|
|
21
21
|
'-o, --offer-template-filename <filename>',
|
|
22
|
-
'File name containing the credential template file'
|
|
22
|
+
'File name containing the credential template file',
|
|
23
23
|
)
|
|
24
24
|
.option(
|
|
25
25
|
'-p, --person-template-filename <filename>',
|
|
26
|
-
'File name containing the credential template file'
|
|
26
|
+
'File name containing the credential template file',
|
|
27
27
|
)
|
|
28
28
|
.option(
|
|
29
29
|
'-e, --endpoint <url>',
|
|
30
|
-
'Endpoint to call to upload the people and credentials to'
|
|
30
|
+
'Endpoint to call to upload the people and credentials to',
|
|
31
31
|
)
|
|
32
32
|
.option(
|
|
33
33
|
'-u --vendor-userid-column <vendorUseridColumn>',
|
|
34
34
|
`the column from the CSV that is users id. Value is made available as "vendorUserId" in the offer template. Accepts
|
|
35
35
|
header name or index. Default is 0.`,
|
|
36
36
|
parseColumn,
|
|
37
|
-
'0'
|
|
37
|
+
'0',
|
|
38
38
|
)
|
|
39
39
|
.option('-t, --auth-token <url>', 'Bearer Auth Token to use')
|
|
40
40
|
.option('-l, --label <label>', 'A label to attach to the documents inserted')
|
|
@@ -25,7 +25,7 @@ describe('batch issuing test', () => {
|
|
|
25
25
|
csvFilename: path.join(__dirname, 'data/batch-vars-offerids.csv'),
|
|
26
26
|
offerTemplateFilename: path.join(
|
|
27
27
|
__dirname,
|
|
28
|
-
'data/email-offer.template.json'
|
|
28
|
+
'data/email-offer.template.json',
|
|
29
29
|
),
|
|
30
30
|
tenant: 'foo',
|
|
31
31
|
termsUrl: 'http://example.com/terms.html',
|
|
@@ -35,7 +35,7 @@ describe('batch issuing test', () => {
|
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
await expect(() => runBatchIssuing(options)).rejects.toThrow(
|
|
38
|
-
"Mug2.1 doesn't exist. Please use one of EmailV1.0,PhoneV1.0,DriversLicenseV1.0"
|
|
38
|
+
"Mug2.1 doesn't exist. Please use one of EmailV1.0,PhoneV1.0,DriversLicenseV1.0",
|
|
39
39
|
);
|
|
40
40
|
});
|
|
41
41
|
it("should fail if options doesn't have 'did' or `tenant'", async () => {
|
|
@@ -43,7 +43,7 @@ describe('batch issuing test', () => {
|
|
|
43
43
|
csvFilename: path.join(__dirname, 'data/batch-vars-offerids.csv'),
|
|
44
44
|
offerTemplateFilename: path.join(
|
|
45
45
|
__dirname,
|
|
46
|
-
'data/email-offer.template.json'
|
|
46
|
+
'data/email-offer.template.json',
|
|
47
47
|
),
|
|
48
48
|
termsUrl: 'http://example.com/terms.html',
|
|
49
49
|
idCredentialType: 'Mug2.1',
|
|
@@ -52,7 +52,7 @@ describe('batch issuing test', () => {
|
|
|
52
52
|
};
|
|
53
53
|
|
|
54
54
|
await expect(() => runBatchIssuing(options)).rejects.toThrow(
|
|
55
|
-
'one of "--tenant" or "--did" is required'
|
|
55
|
+
'one of "--tenant" or "--did" is required',
|
|
56
56
|
);
|
|
57
57
|
});
|
|
58
58
|
|
|
@@ -61,7 +61,7 @@ describe('batch issuing test', () => {
|
|
|
61
61
|
csvFilename: path.join(__dirname, 'data/batch-vars-offerids.csv'),
|
|
62
62
|
offerTemplateFilename: path.join(
|
|
63
63
|
__dirname,
|
|
64
|
-
'data/email-offer.template.json'
|
|
64
|
+
'data/email-offer.template.json',
|
|
65
65
|
),
|
|
66
66
|
tenant: 'foo',
|
|
67
67
|
termsUrl: 'http://example.com/terms.html',
|
|
@@ -71,7 +71,7 @@ describe('batch issuing test', () => {
|
|
|
71
71
|
|
|
72
72
|
const updates = await runBatchIssuing(options);
|
|
73
73
|
expect(
|
|
74
|
-
new Date(updates.disclosureRequest.activationDate).getTime()
|
|
74
|
+
new Date(updates.disclosureRequest.activationDate).getTime(),
|
|
75
75
|
).toBeLessThan(Date.now());
|
|
76
76
|
|
|
77
77
|
expect(updates).toEqual({
|
|
@@ -148,7 +148,7 @@ describe('batch issuing test', () => {
|
|
|
148
148
|
csvFilename: path.join(__dirname, 'data/batch-vars-offerids.csv'),
|
|
149
149
|
offerTemplateFilename: path.join(
|
|
150
150
|
__dirname,
|
|
151
|
-
'data/email-offer.template.json'
|
|
151
|
+
'data/email-offer.template.json',
|
|
152
152
|
),
|
|
153
153
|
tenant: 'foo',
|
|
154
154
|
termsUrl: 'http://example.com/terms.html',
|
|
@@ -160,7 +160,7 @@ describe('batch issuing test', () => {
|
|
|
160
160
|
|
|
161
161
|
const updates = await runBatchIssuing(options);
|
|
162
162
|
expect(
|
|
163
|
-
new Date(updates.disclosureRequest.activationDate).getTime()
|
|
163
|
+
new Date(updates.disclosureRequest.activationDate).getTime(),
|
|
164
164
|
).toBeLessThan(Date.now());
|
|
165
165
|
|
|
166
166
|
expect(updates).toEqual({
|
|
@@ -235,7 +235,7 @@ describe('batch issuing test', () => {
|
|
|
235
235
|
csvFilename: path.join(__dirname, 'data/batch-vars-offerids.csv'),
|
|
236
236
|
offerTemplateFilename: path.join(
|
|
237
237
|
__dirname,
|
|
238
|
-
'data/email-offer.template.json'
|
|
238
|
+
'data/email-offer.template.json',
|
|
239
239
|
),
|
|
240
240
|
tenant: 'foo',
|
|
241
241
|
termsUrl: 'http://example.com/terms.html',
|
|
@@ -247,7 +247,7 @@ describe('batch issuing test', () => {
|
|
|
247
247
|
|
|
248
248
|
const updates = await runBatchIssuing(options);
|
|
249
249
|
expect(
|
|
250
|
-
new Date(updates.disclosureRequest.activationDate).getTime()
|
|
250
|
+
new Date(updates.disclosureRequest.activationDate).getTime(),
|
|
251
251
|
).toBeLessThan(Date.now());
|
|
252
252
|
|
|
253
253
|
expect(updates).toEqual({
|
|
@@ -322,7 +322,7 @@ describe('batch issuing test', () => {
|
|
|
322
322
|
csvFilename: path.join(__dirname, 'data/batch-vars-offerids.csv'),
|
|
323
323
|
offerTemplateFilename: path.join(
|
|
324
324
|
__dirname,
|
|
325
|
-
'data/email-offer.template.json'
|
|
325
|
+
'data/email-offer.template.json',
|
|
326
326
|
),
|
|
327
327
|
tenant: 'foo',
|
|
328
328
|
termsUrl: 'http://example.com/terms.html',
|
|
@@ -334,7 +334,7 @@ describe('batch issuing test', () => {
|
|
|
334
334
|
|
|
335
335
|
const updates = await runBatchIssuing(options);
|
|
336
336
|
expect(
|
|
337
|
-
new Date(updates.disclosureRequest.activationDate).getTime()
|
|
337
|
+
new Date(updates.disclosureRequest.activationDate).getTime(),
|
|
338
338
|
).toBeLessThan(Date.now());
|
|
339
339
|
|
|
340
340
|
expect(updates).toEqual({
|
|
@@ -410,7 +410,7 @@ describe('batch issuing test', () => {
|
|
|
410
410
|
csvFilename: path.join(__dirname, 'data/phones-batch-vars-offerids.csv'),
|
|
411
411
|
offerTemplateFilename: path.join(
|
|
412
412
|
__dirname,
|
|
413
|
-
'data/phone-offer.template.json'
|
|
413
|
+
'data/phone-offer.template.json',
|
|
414
414
|
),
|
|
415
415
|
tenant: 'foo',
|
|
416
416
|
termsUrl: 'http://example.com/terms.html',
|
|
@@ -421,7 +421,7 @@ describe('batch issuing test', () => {
|
|
|
421
421
|
|
|
422
422
|
const updates = await runBatchIssuing(options);
|
|
423
423
|
expect(
|
|
424
|
-
new Date(updates.disclosureRequest.activationDate).getTime()
|
|
424
|
+
new Date(updates.disclosureRequest.activationDate).getTime(),
|
|
425
425
|
).toBeLessThan(Date.now());
|
|
426
426
|
|
|
427
427
|
expect(updates).toEqual({
|
|
@@ -497,7 +497,7 @@ describe('batch issuing test', () => {
|
|
|
497
497
|
csvFilename: path.join(__dirname, 'data/driver-license-variables.csv'),
|
|
498
498
|
offerTemplateFilename: path.join(
|
|
499
499
|
__dirname,
|
|
500
|
-
'data/driver-license-offer.template.json'
|
|
500
|
+
'data/driver-license-offer.template.json',
|
|
501
501
|
),
|
|
502
502
|
tenant: 'foo',
|
|
503
503
|
termsUrl: 'http://example.com/terms.html',
|
|
@@ -508,7 +508,7 @@ describe('batch issuing test', () => {
|
|
|
508
508
|
|
|
509
509
|
const updates = await runBatchIssuing(options);
|
|
510
510
|
expect(
|
|
511
|
-
new Date(updates.disclosureRequest.activationDate).getTime()
|
|
511
|
+
new Date(updates.disclosureRequest.activationDate).getTime(),
|
|
512
512
|
).toBeLessThan(Date.now());
|
|
513
513
|
|
|
514
514
|
expect(updates).toEqual({
|
|
@@ -585,7 +585,7 @@ describe('batch issuing test', () => {
|
|
|
585
585
|
csvFilename: path.join(__dirname, 'data/id-document-variables.csv'),
|
|
586
586
|
offerTemplateFilename: path.join(
|
|
587
587
|
__dirname,
|
|
588
|
-
'data/id-document-offer.template.json'
|
|
588
|
+
'data/id-document-offer.template.json',
|
|
589
589
|
),
|
|
590
590
|
tenant: 'foo',
|
|
591
591
|
termsUrl: 'http://example.com/terms.html',
|
|
@@ -596,7 +596,7 @@ describe('batch issuing test', () => {
|
|
|
596
596
|
|
|
597
597
|
const updates = await runBatchIssuing(options);
|
|
598
598
|
expect(
|
|
599
|
-
new Date(updates.disclosureRequest.activationDate).getTime()
|
|
599
|
+
new Date(updates.disclosureRequest.activationDate).getTime(),
|
|
600
600
|
).toBeLessThan(Date.now());
|
|
601
601
|
|
|
602
602
|
expect(updates).toEqual({
|
|
@@ -673,7 +673,7 @@ describe('batch issuing test', () => {
|
|
|
673
673
|
csvFilename: path.join(__dirname, 'data/resident-permit-variables.csv'),
|
|
674
674
|
offerTemplateFilename: path.join(
|
|
675
675
|
__dirname,
|
|
676
|
-
'data/resident-permit-offer.template.json'
|
|
676
|
+
'data/resident-permit-offer.template.json',
|
|
677
677
|
),
|
|
678
678
|
tenant: 'foo',
|
|
679
679
|
termsUrl: 'http://example.com/terms.html',
|
|
@@ -684,7 +684,7 @@ describe('batch issuing test', () => {
|
|
|
684
684
|
|
|
685
685
|
const updates = await runBatchIssuing(options);
|
|
686
686
|
expect(
|
|
687
|
-
new Date(updates.disclosureRequest.activationDate).getTime()
|
|
687
|
+
new Date(updates.disclosureRequest.activationDate).getTime(),
|
|
688
688
|
).toBeLessThan(Date.now());
|
|
689
689
|
|
|
690
690
|
expect(updates).toEqual({
|
|
@@ -761,7 +761,7 @@ describe('batch issuing test', () => {
|
|
|
761
761
|
csvFilename: path.join(__dirname, 'data/passport-variables.csv'),
|
|
762
762
|
offerTemplateFilename: path.join(
|
|
763
763
|
__dirname,
|
|
764
|
-
'data/passport-offer.template.json'
|
|
764
|
+
'data/passport-offer.template.json',
|
|
765
765
|
),
|
|
766
766
|
tenant: 'foo',
|
|
767
767
|
termsUrl: 'http://example.com/terms.html',
|
|
@@ -772,7 +772,7 @@ describe('batch issuing test', () => {
|
|
|
772
772
|
|
|
773
773
|
const updates = await runBatchIssuing(options);
|
|
774
774
|
expect(
|
|
775
|
-
new Date(updates.disclosureRequest.activationDate).getTime()
|
|
775
|
+
new Date(updates.disclosureRequest.activationDate).getTime(),
|
|
776
776
|
).toBeLessThan(Date.now());
|
|
777
777
|
|
|
778
778
|
expect(updates).toEqual({
|
|
@@ -849,7 +849,7 @@ describe('batch issuing test', () => {
|
|
|
849
849
|
csvFilename: path.join(__dirname, 'data/national-id-card-variables.csv'),
|
|
850
850
|
offerTemplateFilename: path.join(
|
|
851
851
|
__dirname,
|
|
852
|
-
'data/national-id-card-offer.template.json'
|
|
852
|
+
'data/national-id-card-offer.template.json',
|
|
853
853
|
),
|
|
854
854
|
tenant: 'foo',
|
|
855
855
|
termsUrl: 'http://example.com/terms.html',
|
|
@@ -860,7 +860,7 @@ describe('batch issuing test', () => {
|
|
|
860
860
|
|
|
861
861
|
const updates = await runBatchIssuing(options);
|
|
862
862
|
expect(
|
|
863
|
-
new Date(updates.disclosureRequest.activationDate).getTime()
|
|
863
|
+
new Date(updates.disclosureRequest.activationDate).getTime(),
|
|
864
864
|
).toBeLessThan(Date.now());
|
|
865
865
|
|
|
866
866
|
expect(updates).toEqual({
|
|
@@ -937,7 +937,7 @@ describe('batch issuing test', () => {
|
|
|
937
937
|
csvFilename: path.join(__dirname, 'data/proof-of-age-variables.csv'),
|
|
938
938
|
offerTemplateFilename: path.join(
|
|
939
939
|
__dirname,
|
|
940
|
-
'data/proof-of-age-offer.template.json'
|
|
940
|
+
'data/proof-of-age-offer.template.json',
|
|
941
941
|
),
|
|
942
942
|
tenant: 'foo',
|
|
943
943
|
termsUrl: 'http://example.com/terms.html',
|
|
@@ -948,7 +948,7 @@ describe('batch issuing test', () => {
|
|
|
948
948
|
|
|
949
949
|
const updates = await runBatchIssuing(options);
|
|
950
950
|
expect(
|
|
951
|
-
new Date(updates.disclosureRequest.activationDate).getTime()
|
|
951
|
+
new Date(updates.disclosureRequest.activationDate).getTime(),
|
|
952
952
|
).toBeLessThan(Date.now());
|
|
953
953
|
|
|
954
954
|
expect(updates).toEqual({
|
|
@@ -1025,7 +1025,7 @@ describe('batch issuing test', () => {
|
|
|
1025
1025
|
csvFilename: path.join(__dirname, 'data/variables.csv'),
|
|
1026
1026
|
offerTemplateFilename: path.join(
|
|
1027
1027
|
__dirname,
|
|
1028
|
-
'data/email-offer.template.json'
|
|
1028
|
+
'data/email-offer.template.json',
|
|
1029
1029
|
),
|
|
1030
1030
|
tenant: 'foo',
|
|
1031
1031
|
termsUrl: 'http://example.com/terms.html',
|
|
@@ -1037,7 +1037,7 @@ describe('batch issuing test', () => {
|
|
|
1037
1037
|
|
|
1038
1038
|
const updates = await runBatchIssuing(options);
|
|
1039
1039
|
expect(
|
|
1040
|
-
new Date(updates.disclosureRequest.activationDate).getTime()
|
|
1040
|
+
new Date(updates.disclosureRequest.activationDate).getTime(),
|
|
1041
1041
|
).toBeLessThan(Date.now());
|
|
1042
1042
|
|
|
1043
1043
|
expect(updates).toEqual({
|
|
@@ -1114,7 +1114,7 @@ describe('batch issuing test', () => {
|
|
|
1114
1114
|
csvFilename: path.join(__dirname, 'data/with-bom.csv'),
|
|
1115
1115
|
offerTemplateFilename: path.join(
|
|
1116
1116
|
__dirname,
|
|
1117
|
-
'data/email-offer.template.json'
|
|
1117
|
+
'data/email-offer.template.json',
|
|
1118
1118
|
),
|
|
1119
1119
|
tenant: 'foo',
|
|
1120
1120
|
termsUrl: 'http://example.com/terms.html',
|
|
@@ -1126,7 +1126,7 @@ describe('batch issuing test', () => {
|
|
|
1126
1126
|
|
|
1127
1127
|
const updates = await runBatchIssuing(options);
|
|
1128
1128
|
expect(
|
|
1129
|
-
new Date(updates.disclosureRequest.activationDate).getTime()
|
|
1129
|
+
new Date(updates.disclosureRequest.activationDate).getTime(),
|
|
1130
1130
|
).toBeLessThan(Date.now());
|
|
1131
1131
|
|
|
1132
1132
|
expect(updates).toEqual({
|
|
@@ -1203,7 +1203,7 @@ describe('batch issuing test', () => {
|
|
|
1203
1203
|
csvFilename: path.join(__dirname, 'data/variables.csv'),
|
|
1204
1204
|
offerTemplateFilename: path.join(
|
|
1205
1205
|
__dirname,
|
|
1206
|
-
'data/email-offer.template.json'
|
|
1206
|
+
'data/email-offer.template.json',
|
|
1207
1207
|
),
|
|
1208
1208
|
tenant: 'foo',
|
|
1209
1209
|
termsUrl: 'http://example.com/terms.html',
|
|
@@ -1294,7 +1294,7 @@ describe('batch issuing test', () => {
|
|
|
1294
1294
|
});
|
|
1295
1295
|
|
|
1296
1296
|
expect(
|
|
1297
|
-
new Date(updates.disclosureRequest.activationDate).getTime()
|
|
1297
|
+
new Date(updates.disclosureRequest.activationDate).getTime(),
|
|
1298
1298
|
).toBeGreaterThan(Date.now());
|
|
1299
1299
|
});
|
|
1300
1300
|
|
|
@@ -1306,7 +1306,7 @@ describe('batch issuing test', () => {
|
|
|
1306
1306
|
const tenant = '123';
|
|
1307
1307
|
nock(agentUrl)
|
|
1308
1308
|
.get(
|
|
1309
|
-
`/operator-api/v0.8/tenants/${tenant}/disclosures?vendorEndpoint=integrated-issuing-identification
|
|
1309
|
+
`/operator-api/v0.8/tenants/${tenant}/disclosures?vendorEndpoint=integrated-issuing-identification`,
|
|
1310
1310
|
)
|
|
1311
1311
|
.reply(200, existingDisclosures);
|
|
1312
1312
|
|
|
@@ -1314,7 +1314,7 @@ describe('batch issuing test', () => {
|
|
|
1314
1314
|
csvFilename: path.join(__dirname, 'data/variables.csv'),
|
|
1315
1315
|
offerTemplateFilename: path.join(
|
|
1316
1316
|
__dirname,
|
|
1317
|
-
'data/email-offer.template.json'
|
|
1317
|
+
'data/email-offer.template.json',
|
|
1318
1318
|
),
|
|
1319
1319
|
tenant,
|
|
1320
1320
|
termsUrl: 'http://example.com/terms.html',
|
|
@@ -1333,7 +1333,7 @@ describe('batch issuing test', () => {
|
|
|
1333
1333
|
const tenant = '123';
|
|
1334
1334
|
nock(agentUrl)
|
|
1335
1335
|
.get(
|
|
1336
|
-
`/operator-api/v0.8/tenants/${tenant}/disclosures?vendorEndpoint=integrated-issuing-identification
|
|
1336
|
+
`/operator-api/v0.8/tenants/${tenant}/disclosures?vendorEndpoint=integrated-issuing-identification`,
|
|
1337
1337
|
)
|
|
1338
1338
|
.reply(200, existingDisclosures);
|
|
1339
1339
|
|
|
@@ -1341,7 +1341,7 @@ describe('batch issuing test', () => {
|
|
|
1341
1341
|
csvFilename: path.join(__dirname, 'data/variables.csv'),
|
|
1342
1342
|
offerTemplateFilename: path.join(
|
|
1343
1343
|
__dirname,
|
|
1344
|
-
'data/email-offer.template.json'
|
|
1344
|
+
'data/email-offer.template.json',
|
|
1345
1345
|
),
|
|
1346
1346
|
tenant,
|
|
1347
1347
|
termsUrl: 'http://example.com/terms.html',
|
|
@@ -1401,7 +1401,7 @@ describe('batch issuing test', () => {
|
|
|
1401
1401
|
const did = 'did:sap:123';
|
|
1402
1402
|
nock(agentUrl)
|
|
1403
1403
|
.get(
|
|
1404
|
-
`/operator-api/v0.8/tenants/${did}/disclosures?vendorEndpoint=integrated-issuing-identification
|
|
1404
|
+
`/operator-api/v0.8/tenants/${did}/disclosures?vendorEndpoint=integrated-issuing-identification`,
|
|
1405
1405
|
)
|
|
1406
1406
|
.reply(200, existingDisclosures);
|
|
1407
1407
|
|
|
@@ -1409,7 +1409,7 @@ describe('batch issuing test', () => {
|
|
|
1409
1409
|
csvFilename: path.join(__dirname, 'data/variables.csv'),
|
|
1410
1410
|
offerTemplateFilename: path.join(
|
|
1411
1411
|
__dirname,
|
|
1412
|
-
'data/email-offer.template.json'
|
|
1412
|
+
'data/email-offer.template.json',
|
|
1413
1413
|
),
|
|
1414
1414
|
did,
|
|
1415
1415
|
termsUrl: 'http://example.com/terms.html',
|