@ama-sdk/core 12.1.8 → 12.1.11
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/cjs/clients/api-angular-client.js +13 -18
- package/cjs/clients/api-fetch-client.js +16 -21
- package/cjs/fwk/api.helpers.js +11 -11
- package/cjs/fwk/date.js +5 -5
- package/cjs/fwk/errors.js +7 -7
- package/cjs/fwk/mocks/alf-mock-adapter.js +58 -60
- package/cjs/fwk/mocks/base-mock-adapter.js +15 -19
- package/cjs/fwk/mocks/helpers.js +3 -3
- package/cjs/fwk/param-serialization.js +6 -6
- package/cjs/fwk/reviver.js +4 -4
- package/cjs/plugins/abort/abort.spec.js +83 -81
- package/cjs/plugins/additional-params/additional-params.request.js +18 -25
- package/cjs/plugins/additional-params/additional-params.spec.js +194 -186
- package/cjs/plugins/api-configuration-override/api-configuration-override.request.js +10 -17
- package/cjs/plugins/api-configuration-override/api-configuration-override.spec.js +83 -81
- package/cjs/plugins/api-key/api-key.request.js +12 -19
- package/cjs/plugins/api-key/api-key.spec.js +50 -50
- package/cjs/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.js +25 -36
- package/cjs/plugins/bot-protection-fingerprint/bot-protection-fingerprint.spec.js +343 -327
- package/cjs/plugins/client-facts/client-facts.request.js +18 -25
- package/cjs/plugins/client-facts/client-facts.spec.js +218 -208
- package/cjs/plugins/concurrent/concurrent.fetch.js +12 -20
- package/cjs/plugins/concurrent/concurrent.spec.js +99 -99
- package/cjs/plugins/custom-info/custom-info.spec.js +90 -90
- package/cjs/plugins/fetch-cache/fetch-cache.spec.js +100 -98
- package/cjs/plugins/fetch-credentials/fetch-credentials.spec.js +60 -60
- package/cjs/plugins/json-token/json-token.spec.js +109 -107
- package/cjs/plugins/keepalive/keepalive.request.js +7 -12
- package/cjs/plugins/keepalive/keepalive.spec.js +32 -34
- package/cjs/plugins/mgw-mdw-auth/mgw-mdw-auth.helpers.js +11 -23
- package/cjs/plugins/mgw-mdw-auth/mgw-mdw-auth.request.js +18 -28
- package/cjs/plugins/mgw-mdw-auth/mgw-mdw-auth.spec.js +212 -204
- package/cjs/plugins/mock-intercept/mock-intercept.angular.js +94 -100
- package/cjs/plugins/mock-intercept/mock-intercept.fetch.js +15 -22
- package/cjs/plugins/mock-intercept/mock-intercept.interface.js +3 -3
- package/cjs/plugins/mock-intercept/mock-intercept.request.js +12 -19
- package/cjs/plugins/mock-intercept/mock-intercept.spec.js +245 -237
- package/cjs/plugins/perf-metric/perf-metric.fetch.js +11 -18
- package/cjs/plugins/pii-tokenizer/pii-tokenizer.request.js +19 -27
- package/cjs/plugins/pii-tokenizer/pii-tokenizer.spec.js +404 -386
- package/cjs/plugins/raw-response-info/raw-response-info.spec.js +67 -67
- package/cjs/plugins/retry/retry.fetch.js +18 -27
- package/cjs/plugins/retry/retry.spec.js +233 -225
- package/cjs/plugins/reviver/reviver.spec.js +88 -86
- package/cjs/plugins/session-id/session-id.spec.js +98 -94
- package/cjs/plugins/si-token/si-token.spec.js +27 -29
- package/cjs/plugins/simple-api-key-authentication/simple-api-key-authentication.request.js +17 -24
- package/cjs/plugins/simple-api-key-authentication/simple-api-key-authentication.spec.js +199 -191
- package/cjs/plugins/timeout/timeout.fetch.js +16 -22
- package/cjs/plugins/timeout/timeout.spec.js +211 -205
- package/cjs/plugins/url-rewrite/url-rewrite.request.js +9 -16
- package/cjs/plugins/url-rewrite/url-rewrite.spec.js +48 -48
- package/cjs/plugins/wait-for/wait-for.fetch.js +19 -29
- package/cjs/plugins/wait-for/wait-for.spec.js +211 -203
- package/cjs/utils/crypto.js +15 -27
- package/cjs/utils/generic-api.js +9 -14
- package/cjs/utils/json-token.js +19 -26
- package/cjs/utils/json-token.spec.js +495 -497
- package/cjs/utils/mime-types.js +3 -3
- package/esm2015/clients/api-angular-client.js +13 -18
- package/esm2015/clients/api-fetch-client.js +16 -21
- package/esm2015/fwk/mocks/alf-mock-adapter.js +58 -60
- package/esm2015/fwk/mocks/base-mock-adapter.js +15 -19
- package/esm2015/plugins/abort/abort.spec.js +83 -81
- package/esm2015/plugins/additional-params/additional-params.request.js +15 -22
- package/esm2015/plugins/additional-params/additional-params.spec.js +194 -186
- package/esm2015/plugins/api-configuration-override/api-configuration-override.request.js +10 -17
- package/esm2015/plugins/api-configuration-override/api-configuration-override.spec.js +83 -81
- package/esm2015/plugins/api-key/api-key.request.js +12 -19
- package/esm2015/plugins/api-key/api-key.spec.js +50 -50
- package/esm2015/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.js +21 -32
- package/esm2015/plugins/bot-protection-fingerprint/bot-protection-fingerprint.spec.js +343 -327
- package/esm2015/plugins/client-facts/client-facts.request.js +15 -22
- package/esm2015/plugins/client-facts/client-facts.spec.js +218 -208
- package/esm2015/plugins/concurrent/concurrent.fetch.js +12 -20
- package/esm2015/plugins/concurrent/concurrent.spec.js +99 -99
- package/esm2015/plugins/custom-info/custom-info.spec.js +90 -90
- package/esm2015/plugins/fetch-cache/fetch-cache.spec.js +100 -98
- package/esm2015/plugins/fetch-credentials/fetch-credentials.spec.js +60 -60
- package/esm2015/plugins/json-token/json-token.spec.js +109 -107
- package/esm2015/plugins/keepalive/keepalive.request.js +7 -12
- package/esm2015/plugins/keepalive/keepalive.spec.js +32 -34
- package/esm2015/plugins/mgw-mdw-auth/mgw-mdw-auth.helpers.js +8 -20
- package/esm2015/plugins/mgw-mdw-auth/mgw-mdw-auth.request.js +18 -28
- package/esm2015/plugins/mgw-mdw-auth/mgw-mdw-auth.spec.js +212 -204
- package/esm2015/plugins/mock-intercept/mock-intercept.angular.js +94 -100
- package/esm2015/plugins/mock-intercept/mock-intercept.fetch.js +15 -22
- package/esm2015/plugins/mock-intercept/mock-intercept.request.js +12 -19
- package/esm2015/plugins/mock-intercept/mock-intercept.spec.js +245 -237
- package/esm2015/plugins/perf-metric/perf-metric.fetch.js +11 -18
- package/esm2015/plugins/pii-tokenizer/pii-tokenizer.request.js +15 -23
- package/esm2015/plugins/pii-tokenizer/pii-tokenizer.spec.js +404 -386
- package/esm2015/plugins/raw-response-info/raw-response-info.spec.js +67 -67
- package/esm2015/plugins/retry/retry.fetch.js +18 -27
- package/esm2015/plugins/retry/retry.spec.js +233 -225
- package/esm2015/plugins/reviver/reviver.spec.js +88 -86
- package/esm2015/plugins/session-id/session-id.spec.js +98 -94
- package/esm2015/plugins/si-token/si-token.spec.js +27 -29
- package/esm2015/plugins/simple-api-key-authentication/simple-api-key-authentication.request.js +17 -24
- package/esm2015/plugins/simple-api-key-authentication/simple-api-key-authentication.spec.js +199 -191
- package/esm2015/plugins/timeout/timeout.fetch.js +13 -19
- package/esm2015/plugins/timeout/timeout.spec.js +211 -205
- package/esm2015/plugins/url-rewrite/url-rewrite.request.js +9 -16
- package/esm2015/plugins/url-rewrite/url-rewrite.spec.js +48 -48
- package/esm2015/plugins/wait-for/wait-for.fetch.js +19 -29
- package/esm2015/plugins/wait-for/wait-for.spec.js +211 -203
- package/esm2015/utils/crypto.js +8 -20
- package/esm2015/utils/generic-api.js +9 -14
- package/esm2015/utils/json-token.js +10 -17
- package/esm2015/utils/json-token.spec.js +495 -497
- package/package.json +6 -6
|
@@ -80,7 +80,7 @@ function _object_spread_props(target, source) {
|
|
|
80
80
|
return target;
|
|
81
81
|
}
|
|
82
82
|
function _ts_generator(thisArg, body) {
|
|
83
|
-
var f, y, t,
|
|
83
|
+
var f, y, t, _ = {
|
|
84
84
|
label: 0,
|
|
85
85
|
sent: function() {
|
|
86
86
|
if (t[0] & 1) throw t[1];
|
|
@@ -88,12 +88,8 @@ function _ts_generator(thisArg, body) {
|
|
|
88
88
|
},
|
|
89
89
|
trys: [],
|
|
90
90
|
ops: []
|
|
91
|
-
};
|
|
92
|
-
return g = {
|
|
93
|
-
next: verb(0),
|
|
94
|
-
"throw": verb(1),
|
|
95
|
-
"return": verb(2)
|
|
96
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
91
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
92
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
97
93
|
return this;
|
|
98
94
|
}), g;
|
|
99
95
|
function verb(n) {
|
|
@@ -106,7 +102,7 @@ function _ts_generator(thisArg, body) {
|
|
|
106
102
|
}
|
|
107
103
|
function step(op) {
|
|
108
104
|
if (f) throw new TypeError("Generator is already executing.");
|
|
109
|
-
while(_)try {
|
|
105
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
110
106
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
111
107
|
if (y = 0, t) op = [
|
|
112
108
|
op[0] & 2,
|
|
@@ -204,382 +200,404 @@ describe('Tokenizer Request Plugin', function() {
|
|
|
204
200
|
afterEach(function() {
|
|
205
201
|
jest.restoreAllMocks();
|
|
206
202
|
});
|
|
207
|
-
it('should replace sensitive parameters with tokens',
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
runner.
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
key
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
})
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
203
|
+
it('should replace sensitive parameters with tokens', function() {
|
|
204
|
+
return _async_to_generator(function() {
|
|
205
|
+
var plugin, runner, result;
|
|
206
|
+
return _ts_generator(this, function(_state) {
|
|
207
|
+
switch(_state.label){
|
|
208
|
+
case 0:
|
|
209
|
+
plugin = new PiiTokenizerRequest({
|
|
210
|
+
applicationId: 'app-id'
|
|
211
|
+
});
|
|
212
|
+
runner = plugin.load();
|
|
213
|
+
return [
|
|
214
|
+
4,
|
|
215
|
+
runner.transform(_object_spread_props(_object_spread({}, options), {
|
|
216
|
+
tokenizedOptions: tokenizedOptions
|
|
217
|
+
}))
|
|
218
|
+
];
|
|
219
|
+
case 1:
|
|
220
|
+
result = _state.sent();
|
|
221
|
+
expect(result.basePath).toEqual('http://test.com/path/$pathParamToken$');
|
|
222
|
+
expect(result.queryParams.classicParam).toEqual('classicParamValue');
|
|
223
|
+
expect(result.queryParams.sensitiveParam).toEqual('$sensitiveParamToken$');
|
|
224
|
+
expect(result.headers.get('ama-client-facts')).not.toBeNull();
|
|
225
|
+
return [
|
|
226
|
+
2
|
|
227
|
+
];
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
})();
|
|
231
|
+
});
|
|
232
|
+
it('should put token-value associations in custom header if provided', function() {
|
|
233
|
+
return _async_to_generator(function() {
|
|
234
|
+
var plugin, runner, result;
|
|
235
|
+
return _ts_generator(this, function(_state) {
|
|
236
|
+
switch(_state.label){
|
|
237
|
+
case 0:
|
|
238
|
+
plugin = new PiiTokenizerRequest({
|
|
239
|
+
applicationId: 'app-id',
|
|
240
|
+
headerName: 'custom-header'
|
|
241
|
+
});
|
|
242
|
+
runner = plugin.load();
|
|
243
|
+
return [
|
|
244
|
+
4,
|
|
245
|
+
runner.transform(_object_spread_props(_object_spread({}, options), {
|
|
246
|
+
tokenizedOptions: tokenizedOptions
|
|
247
|
+
}))
|
|
248
|
+
];
|
|
249
|
+
case 1:
|
|
250
|
+
result = _state.sent();
|
|
251
|
+
expect(result.headers.get('ama-client-facts')).toBeNull();
|
|
252
|
+
expect(result.headers.get('custom-header')).not.toBeNull();
|
|
253
|
+
return [
|
|
254
|
+
2
|
|
255
|
+
];
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
})();
|
|
259
|
+
});
|
|
260
|
+
it('should keep default parameters and print an error if tokenization is disabled', function() {
|
|
261
|
+
return _async_to_generator(function() {
|
|
262
|
+
var plugin, runner, result;
|
|
263
|
+
return _ts_generator(this, function(_state) {
|
|
264
|
+
switch(_state.label){
|
|
265
|
+
case 0:
|
|
266
|
+
plugin = new PiiTokenizerRequest({
|
|
267
|
+
applicationId: 'app-id'
|
|
268
|
+
});
|
|
269
|
+
runner = plugin.load();
|
|
270
|
+
return [
|
|
271
|
+
4,
|
|
272
|
+
runner.transform(options)
|
|
273
|
+
];
|
|
274
|
+
case 1:
|
|
275
|
+
result = _state.sent();
|
|
276
|
+
expect(result.basePath).toEqual('http://test.com/path/pathParamValue');
|
|
277
|
+
expect(result.queryParams.classicParam).toEqual('classicParamValue');
|
|
278
|
+
expect(result.queryParams.sensitiveParam).toEqual('sensitiveParamValue');
|
|
279
|
+
expect(result.headers.get('ama-client-facts')).toBeNull();
|
|
280
|
+
// eslint-disable-next-line no-console -- not calling console.error but expect if it has been called or not
|
|
281
|
+
expect(console.error).toHaveBeenCalled();
|
|
282
|
+
return [
|
|
283
|
+
2
|
|
284
|
+
];
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
})();
|
|
288
|
+
});
|
|
289
|
+
it('should keep default parameters if no token-value associations is provided', function() {
|
|
290
|
+
return _async_to_generator(function() {
|
|
291
|
+
var plugin, runner, result;
|
|
292
|
+
return _ts_generator(this, function(_state) {
|
|
293
|
+
switch(_state.label){
|
|
294
|
+
case 0:
|
|
295
|
+
plugin = new PiiTokenizerRequest({
|
|
296
|
+
applicationId: 'app-id'
|
|
297
|
+
});
|
|
298
|
+
runner = plugin.load();
|
|
299
|
+
return [
|
|
300
|
+
4,
|
|
301
|
+
runner.transform(_object_spread_props(_object_spread({}, options), {
|
|
302
|
+
tokenizedOptions: _object_spread_props(_object_spread({}, tokenizedOptions), {
|
|
303
|
+
values: {}
|
|
304
|
+
})
|
|
305
|
+
}))
|
|
306
|
+
];
|
|
307
|
+
case 1:
|
|
308
|
+
result = _state.sent();
|
|
309
|
+
expect(result.basePath).toEqual('http://test.com/path/pathParamValue');
|
|
310
|
+
expect(result.queryParams.classicParam).toEqual('classicParamValue');
|
|
311
|
+
expect(result.queryParams.sensitiveParam).toEqual('sensitiveParamValue');
|
|
312
|
+
expect(result.headers.get('ama-client-facts')).toBeNull();
|
|
313
|
+
// eslint-disable-next-line no-console -- not calling console.error but expect if it has been called or not
|
|
314
|
+
expect(console.error).not.toHaveBeenCalled();
|
|
315
|
+
return [
|
|
316
|
+
2
|
|
317
|
+
];
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
})();
|
|
321
|
+
});
|
|
322
|
+
it('should use JWT if no key specified', function() {
|
|
323
|
+
return _async_to_generator(function() {
|
|
324
|
+
var mockJweEncoder, mockJwtEncoder, plugin, runner;
|
|
325
|
+
return _ts_generator(this, function(_state) {
|
|
326
|
+
switch(_state.label){
|
|
327
|
+
case 0:
|
|
328
|
+
mockJweEncoder = jest.spyOn(jsonToken, 'createJweEncoder');
|
|
329
|
+
mockJwtEncoder = jest.spyOn(jsonToken, 'createJwtEncoder');
|
|
330
|
+
plugin = new PiiTokenizerRequest({
|
|
331
|
+
applicationId: 'app-id'
|
|
332
|
+
});
|
|
333
|
+
runner = plugin.load();
|
|
334
|
+
return [
|
|
335
|
+
4,
|
|
336
|
+
runner.transform(_object_spread_props(_object_spread({}, options), {
|
|
337
|
+
tokenizedOptions: tokenizedOptions
|
|
338
|
+
}))
|
|
339
|
+
];
|
|
340
|
+
case 1:
|
|
341
|
+
_state.sent();
|
|
342
|
+
expect(mockJweEncoder).not.toHaveBeenCalled();
|
|
343
|
+
expect(mockJwtEncoder).toHaveBeenCalled();
|
|
344
|
+
return [
|
|
345
|
+
2
|
|
346
|
+
];
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
})();
|
|
350
|
+
});
|
|
351
|
+
it('should use JWE if a key is specified', function() {
|
|
352
|
+
return _async_to_generator(function() {
|
|
353
|
+
var key, mockJweEncoder, mockJwtEncoder, plugin, runner, result, expectedJwePayload;
|
|
354
|
+
return _ts_generator(this, function(_state) {
|
|
355
|
+
switch(_state.label){
|
|
356
|
+
case 0:
|
|
357
|
+
jest.spyOn(Date, 'now').mockImplementation(function() {
|
|
358
|
+
return 0;
|
|
359
|
+
});
|
|
360
|
+
key = {
|
|
361
|
+
publicKey: 'myPublicKey',
|
|
362
|
+
keyId: 'TEST'
|
|
363
|
+
};
|
|
364
|
+
mockJweEncoder = jest.fn().mockResolvedValue('myJweToken');
|
|
365
|
+
jest.spyOn(jsonToken, 'createJweEncoder').mockImplementation(function() {
|
|
366
|
+
return mockJweEncoder;
|
|
367
|
+
});
|
|
368
|
+
mockJwtEncoder = jest.spyOn(jsonToken, 'createJwtEncoder');
|
|
369
|
+
plugin = new PiiTokenizerRequest({
|
|
370
|
+
applicationId: 'app-id',
|
|
371
|
+
key: key
|
|
372
|
+
});
|
|
373
|
+
runner = plugin.load();
|
|
374
|
+
return [
|
|
375
|
+
4,
|
|
376
|
+
runner.transform(_object_spread_props(_object_spread({}, options), {
|
|
377
|
+
tokenizedOptions: tokenizedOptions
|
|
378
|
+
}))
|
|
379
|
+
];
|
|
380
|
+
case 1:
|
|
381
|
+
result = _state.sent();
|
|
382
|
+
expectedJwePayload = {
|
|
383
|
+
'ama-tokens': {
|
|
384
|
+
$pathParamToken$: 'pathParamValue',
|
|
385
|
+
$sensitiveParamToken$: 'sensitiveParamValue'
|
|
386
|
+
},
|
|
387
|
+
exp: 3600,
|
|
388
|
+
iat: 0,
|
|
389
|
+
iss: 'app-id',
|
|
390
|
+
sub: 'pii'
|
|
391
|
+
};
|
|
392
|
+
expect(result.headers.get('ama-client-facts')).toEqual('myJweToken');
|
|
393
|
+
expect(mockJweEncoder).toHaveBeenCalledWith(key, expectedJwePayload, [
|
|
394
|
+
'iss',
|
|
395
|
+
'sub'
|
|
396
|
+
]);
|
|
397
|
+
expect(mockJwtEncoder).not.toHaveBeenCalled();
|
|
398
|
+
return [
|
|
399
|
+
2
|
|
400
|
+
];
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
})();
|
|
404
|
+
});
|
|
405
|
+
it('should throw by default if an exception is raised for JWE encoder', function() {
|
|
406
|
+
return _async_to_generator(function() {
|
|
407
|
+
var key, mockJweEncoder, plugin, runner;
|
|
408
|
+
return _ts_generator(this, function(_state) {
|
|
409
|
+
switch(_state.label){
|
|
410
|
+
case 0:
|
|
411
|
+
key = {
|
|
412
|
+
publicKey: 'myPublicKey',
|
|
413
|
+
keyId: 'TEST'
|
|
414
|
+
};
|
|
415
|
+
mockJweEncoder = jest.fn().mockRejectedValue('Error creating JWE');
|
|
416
|
+
jest.spyOn(jsonToken, 'createJweEncoder').mockImplementation(function() {
|
|
417
|
+
return mockJweEncoder;
|
|
418
|
+
});
|
|
419
|
+
plugin = new PiiTokenizerRequest({
|
|
420
|
+
applicationId: 'app-id',
|
|
421
|
+
key: key
|
|
422
|
+
});
|
|
423
|
+
runner = plugin.load();
|
|
424
|
+
return [
|
|
425
|
+
4,
|
|
426
|
+
expect(runner.transform(_object_spread_props(_object_spread({}, options), {
|
|
427
|
+
tokenizedOptions: tokenizedOptions
|
|
428
|
+
}))).rejects.toThrow()
|
|
429
|
+
];
|
|
430
|
+
case 1:
|
|
431
|
+
_state.sent();
|
|
432
|
+
expect(mockJweEncoder).toHaveBeenCalled();
|
|
433
|
+
// eslint-disable-next-line no-console -- not calling console.error but expect if it has been called or not
|
|
434
|
+
expect(console.error).not.toHaveBeenCalled();
|
|
435
|
+
return [
|
|
436
|
+
2
|
|
437
|
+
];
|
|
438
|
+
}
|
|
439
|
+
});
|
|
440
|
+
})();
|
|
441
|
+
});
|
|
442
|
+
it('should handle errors silently if an exception is raised for JWE encoder', function() {
|
|
443
|
+
return _async_to_generator(function() {
|
|
444
|
+
var key, mockJweEncoder, plugin, runner;
|
|
445
|
+
return _ts_generator(this, function(_state) {
|
|
446
|
+
switch(_state.label){
|
|
447
|
+
case 0:
|
|
448
|
+
key = {
|
|
449
|
+
publicKey: 'myPublicKey',
|
|
450
|
+
keyId: 'TEST'
|
|
451
|
+
};
|
|
452
|
+
mockJweEncoder = jest.fn().mockRejectedValue('Error creating JWE');
|
|
453
|
+
jest.spyOn(jsonToken, 'createJweEncoder').mockImplementation(function() {
|
|
454
|
+
return mockJweEncoder;
|
|
455
|
+
});
|
|
456
|
+
plugin = new PiiTokenizerRequest({
|
|
457
|
+
applicationId: 'app-id',
|
|
458
|
+
key: key,
|
|
459
|
+
silent: true
|
|
460
|
+
});
|
|
461
|
+
runner = plugin.load();
|
|
462
|
+
return [
|
|
463
|
+
4,
|
|
464
|
+
expect(runner.transform(_object_spread_props(_object_spread({}, options), {
|
|
465
|
+
tokenizedOptions: tokenizedOptions
|
|
466
|
+
}))).resolves.toBeDefined()
|
|
467
|
+
];
|
|
468
|
+
case 1:
|
|
469
|
+
_state.sent();
|
|
470
|
+
expect(mockJweEncoder).toHaveBeenCalled();
|
|
471
|
+
// eslint-disable-next-line no-console -- not calling console.error but expect if it has been called or not
|
|
472
|
+
expect(console.error).toHaveBeenCalled();
|
|
473
|
+
return [
|
|
474
|
+
2
|
|
475
|
+
];
|
|
476
|
+
}
|
|
477
|
+
});
|
|
478
|
+
})();
|
|
479
|
+
});
|
|
480
|
+
it('should skip PII tokenization and put DeepLink token in corresponding header when DeepLink token is provided', function() {
|
|
481
|
+
return _async_to_generator(function() {
|
|
482
|
+
var plugin, runner, deepLinkOptions, metadata, result;
|
|
483
|
+
return _ts_generator(this, function(_state) {
|
|
484
|
+
switch(_state.label){
|
|
485
|
+
case 0:
|
|
486
|
+
plugin = new PiiTokenizerRequest({
|
|
487
|
+
applicationId: 'app-id'
|
|
488
|
+
});
|
|
489
|
+
runner = plugin.load();
|
|
490
|
+
deepLinkOptions = {
|
|
491
|
+
token: 'myDeepLinkToken'
|
|
492
|
+
};
|
|
493
|
+
metadata = {
|
|
494
|
+
deepLinkOptions: deepLinkOptions
|
|
495
|
+
};
|
|
496
|
+
options.basePath = 'http://test.com/path/$pathParamToken$';
|
|
497
|
+
options.queryParams = {
|
|
498
|
+
classicParam: 'classicParamValue',
|
|
499
|
+
sensitiveParam: '$sensitiveParamToken$'
|
|
500
|
+
};
|
|
501
|
+
return [
|
|
502
|
+
4,
|
|
503
|
+
runner.transform(_object_spread_props(_object_spread({}, options), {
|
|
504
|
+
tokenizedOptions: _object_spread_props(_object_spread({}, tokenizedOptions), {
|
|
505
|
+
values: {}
|
|
506
|
+
}),
|
|
507
|
+
metadata: metadata
|
|
508
|
+
}))
|
|
509
|
+
];
|
|
510
|
+
case 1:
|
|
511
|
+
result = _state.sent();
|
|
512
|
+
expect(result.basePath).toEqual('http://test.com/path/$pathParamToken$');
|
|
513
|
+
expect(result.queryParams.classicParam).toEqual('classicParamValue');
|
|
514
|
+
expect(result.queryParams.sensitiveParam).toEqual('$sensitiveParamToken$');
|
|
515
|
+
expect(result.headers.get('ama-client-facts')).toEqual('myDeepLinkToken');
|
|
516
|
+
// eslint-disable-next-line no-console -- not calling console.error but expect if it has been called or not
|
|
517
|
+
expect(console.error).not.toHaveBeenCalled();
|
|
518
|
+
return [
|
|
519
|
+
2
|
|
520
|
+
];
|
|
521
|
+
}
|
|
522
|
+
});
|
|
523
|
+
})();
|
|
524
|
+
});
|
|
525
|
+
it('should put DeepLink challenge answers in corresponding header when provided', function() {
|
|
526
|
+
return _async_to_generator(function() {
|
|
527
|
+
var plugin, runner, deepLinkOptions, metadata, result;
|
|
528
|
+
return _ts_generator(this, function(_state) {
|
|
529
|
+
switch(_state.label){
|
|
530
|
+
case 0:
|
|
531
|
+
plugin = new PiiTokenizerRequest({
|
|
532
|
+
applicationId: 'app-id'
|
|
533
|
+
});
|
|
534
|
+
runner = plugin.load();
|
|
535
|
+
deepLinkOptions = {
|
|
536
|
+
token: 'myDeepLinkToken',
|
|
537
|
+
challengeAnswers: {
|
|
538
|
+
lastName: 'Doe'
|
|
539
|
+
}
|
|
540
|
+
};
|
|
541
|
+
metadata = {
|
|
542
|
+
deepLinkOptions: deepLinkOptions
|
|
543
|
+
};
|
|
544
|
+
options.basePath = 'http://test.com/path/$pathParamToken$';
|
|
545
|
+
options.queryParams = {
|
|
546
|
+
classicParam: 'classicParamValue',
|
|
547
|
+
sensitiveParam: '$sensitiveParamToken$'
|
|
548
|
+
};
|
|
549
|
+
return [
|
|
550
|
+
4,
|
|
551
|
+
runner.transform(_object_spread_props(_object_spread({}, options), {
|
|
552
|
+
tokenizedOptions: _object_spread_props(_object_spread({}, tokenizedOptions), {
|
|
553
|
+
values: {}
|
|
554
|
+
}),
|
|
555
|
+
metadata: metadata
|
|
556
|
+
}))
|
|
557
|
+
];
|
|
558
|
+
case 1:
|
|
559
|
+
result = _state.sent();
|
|
560
|
+
expect(result.basePath).toEqual('http://test.com/path/$pathParamToken$');
|
|
561
|
+
expect(result.queryParams.classicParam).toEqual('classicParamValue');
|
|
562
|
+
expect(result.queryParams.sensitiveParam).toEqual('$sensitiveParamToken$');
|
|
563
|
+
expect(result.headers.get('ama-client-facts')).toEqual('myDeepLinkToken');
|
|
564
|
+
expect(result.headers.get('ama-client-facts-challenge')).toEqual('{"lastName":"Doe"}');
|
|
565
|
+
return [
|
|
566
|
+
2
|
|
567
|
+
];
|
|
568
|
+
}
|
|
569
|
+
});
|
|
570
|
+
})();
|
|
571
|
+
});
|
|
572
|
+
it('Should not loose additional parameters not expected for the actual request', function() {
|
|
573
|
+
return _async_to_generator(function() {
|
|
574
|
+
var plugin, runner, result;
|
|
575
|
+
return _ts_generator(this, function(_state) {
|
|
576
|
+
switch(_state.label){
|
|
577
|
+
case 0:
|
|
578
|
+
plugin = new PiiTokenizerRequest({
|
|
579
|
+
applicationId: 'app-id'
|
|
580
|
+
});
|
|
581
|
+
runner = plugin.load();
|
|
582
|
+
options.basePath = 'http://test.com/path/pathParamValue';
|
|
583
|
+
options.queryParams = _object_spread_props(_object_spread({}, options.queryParams), {
|
|
584
|
+
additionalParam: 'foo'
|
|
585
|
+
});
|
|
586
|
+
return [
|
|
587
|
+
4,
|
|
588
|
+
runner.transform(_object_spread_props(_object_spread({}, options), {
|
|
589
|
+
tokenizedOptions: tokenizedOptions
|
|
590
|
+
}))
|
|
591
|
+
];
|
|
592
|
+
case 1:
|
|
593
|
+
result = _state.sent();
|
|
594
|
+
expect(result.basePath).toEqual('http://test.com/path/$pathParamToken$');
|
|
595
|
+
expect(result.queryParams.additionalParam).toEqual('foo');
|
|
596
|
+
return [
|
|
597
|
+
2
|
|
598
|
+
];
|
|
599
|
+
}
|
|
600
|
+
});
|
|
601
|
+
})();
|
|
602
|
+
});
|
|
585
603
|
});
|