@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
|
@@ -127,7 +127,7 @@ function _object_spread_props(target, source) {
|
|
|
127
127
|
return target;
|
|
128
128
|
}
|
|
129
129
|
function _ts_generator(thisArg, body) {
|
|
130
|
-
var f, y, t,
|
|
130
|
+
var f, y, t, _ = {
|
|
131
131
|
label: 0,
|
|
132
132
|
sent: function() {
|
|
133
133
|
if (t[0] & 1) throw t[1];
|
|
@@ -135,12 +135,8 @@ function _ts_generator(thisArg, body) {
|
|
|
135
135
|
},
|
|
136
136
|
trys: [],
|
|
137
137
|
ops: []
|
|
138
|
-
};
|
|
139
|
-
return g = {
|
|
140
|
-
next: verb(0),
|
|
141
|
-
"throw": verb(1),
|
|
142
|
-
"return": verb(2)
|
|
143
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
138
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
139
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
144
140
|
return this;
|
|
145
141
|
}), g;
|
|
146
142
|
function verb(n) {
|
|
@@ -153,7 +149,7 @@ function _ts_generator(thisArg, body) {
|
|
|
153
149
|
}
|
|
154
150
|
function step(op) {
|
|
155
151
|
if (f) throw new TypeError("Generator is already executing.");
|
|
156
|
-
while(_)try {
|
|
152
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
157
153
|
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;
|
|
158
154
|
if (y = 0, t) op = [
|
|
159
155
|
op[0] & 2,
|
|
@@ -249,382 +245,404 @@ describe('Tokenizer Request Plugin', function() {
|
|
|
249
245
|
afterEach(function() {
|
|
250
246
|
jest.restoreAllMocks();
|
|
251
247
|
});
|
|
252
|
-
it('should replace sensitive parameters with tokens',
|
|
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
|
-
runner.
|
|
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
|
-
|
|
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
|
-
key
|
|
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
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
248
|
+
it('should replace sensitive parameters with tokens', function() {
|
|
249
|
+
return _async_to_generator(function() {
|
|
250
|
+
var plugin, runner, result;
|
|
251
|
+
return _ts_generator(this, function(_state) {
|
|
252
|
+
switch(_state.label){
|
|
253
|
+
case 0:
|
|
254
|
+
plugin = new _piitokenizerrequest.PiiTokenizerRequest({
|
|
255
|
+
applicationId: 'app-id'
|
|
256
|
+
});
|
|
257
|
+
runner = plugin.load();
|
|
258
|
+
return [
|
|
259
|
+
4,
|
|
260
|
+
runner.transform(_object_spread_props(_object_spread({}, options), {
|
|
261
|
+
tokenizedOptions: tokenizedOptions
|
|
262
|
+
}))
|
|
263
|
+
];
|
|
264
|
+
case 1:
|
|
265
|
+
result = _state.sent();
|
|
266
|
+
expect(result.basePath).toEqual('http://test.com/path/$pathParamToken$');
|
|
267
|
+
expect(result.queryParams.classicParam).toEqual('classicParamValue');
|
|
268
|
+
expect(result.queryParams.sensitiveParam).toEqual('$sensitiveParamToken$');
|
|
269
|
+
expect(result.headers.get('ama-client-facts')).not.toBeNull();
|
|
270
|
+
return [
|
|
271
|
+
2
|
|
272
|
+
];
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
})();
|
|
276
|
+
});
|
|
277
|
+
it('should put token-value associations in custom header if provided', function() {
|
|
278
|
+
return _async_to_generator(function() {
|
|
279
|
+
var plugin, runner, result;
|
|
280
|
+
return _ts_generator(this, function(_state) {
|
|
281
|
+
switch(_state.label){
|
|
282
|
+
case 0:
|
|
283
|
+
plugin = new _piitokenizerrequest.PiiTokenizerRequest({
|
|
284
|
+
applicationId: 'app-id',
|
|
285
|
+
headerName: 'custom-header'
|
|
286
|
+
});
|
|
287
|
+
runner = plugin.load();
|
|
288
|
+
return [
|
|
289
|
+
4,
|
|
290
|
+
runner.transform(_object_spread_props(_object_spread({}, options), {
|
|
291
|
+
tokenizedOptions: tokenizedOptions
|
|
292
|
+
}))
|
|
293
|
+
];
|
|
294
|
+
case 1:
|
|
295
|
+
result = _state.sent();
|
|
296
|
+
expect(result.headers.get('ama-client-facts')).toBeNull();
|
|
297
|
+
expect(result.headers.get('custom-header')).not.toBeNull();
|
|
298
|
+
return [
|
|
299
|
+
2
|
|
300
|
+
];
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
})();
|
|
304
|
+
});
|
|
305
|
+
it('should keep default parameters and print an error if tokenization is disabled', function() {
|
|
306
|
+
return _async_to_generator(function() {
|
|
307
|
+
var plugin, runner, result;
|
|
308
|
+
return _ts_generator(this, function(_state) {
|
|
309
|
+
switch(_state.label){
|
|
310
|
+
case 0:
|
|
311
|
+
plugin = new _piitokenizerrequest.PiiTokenizerRequest({
|
|
312
|
+
applicationId: 'app-id'
|
|
313
|
+
});
|
|
314
|
+
runner = plugin.load();
|
|
315
|
+
return [
|
|
316
|
+
4,
|
|
317
|
+
runner.transform(options)
|
|
318
|
+
];
|
|
319
|
+
case 1:
|
|
320
|
+
result = _state.sent();
|
|
321
|
+
expect(result.basePath).toEqual('http://test.com/path/pathParamValue');
|
|
322
|
+
expect(result.queryParams.classicParam).toEqual('classicParamValue');
|
|
323
|
+
expect(result.queryParams.sensitiveParam).toEqual('sensitiveParamValue');
|
|
324
|
+
expect(result.headers.get('ama-client-facts')).toBeNull();
|
|
325
|
+
// eslint-disable-next-line no-console -- not calling console.error but expect if it has been called or not
|
|
326
|
+
expect(console.error).toHaveBeenCalled();
|
|
327
|
+
return [
|
|
328
|
+
2
|
|
329
|
+
];
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
})();
|
|
333
|
+
});
|
|
334
|
+
it('should keep default parameters if no token-value associations is provided', function() {
|
|
335
|
+
return _async_to_generator(function() {
|
|
336
|
+
var plugin, runner, result;
|
|
337
|
+
return _ts_generator(this, function(_state) {
|
|
338
|
+
switch(_state.label){
|
|
339
|
+
case 0:
|
|
340
|
+
plugin = new _piitokenizerrequest.PiiTokenizerRequest({
|
|
341
|
+
applicationId: 'app-id'
|
|
342
|
+
});
|
|
343
|
+
runner = plugin.load();
|
|
344
|
+
return [
|
|
345
|
+
4,
|
|
346
|
+
runner.transform(_object_spread_props(_object_spread({}, options), {
|
|
347
|
+
tokenizedOptions: _object_spread_props(_object_spread({}, tokenizedOptions), {
|
|
348
|
+
values: {}
|
|
349
|
+
})
|
|
350
|
+
}))
|
|
351
|
+
];
|
|
352
|
+
case 1:
|
|
353
|
+
result = _state.sent();
|
|
354
|
+
expect(result.basePath).toEqual('http://test.com/path/pathParamValue');
|
|
355
|
+
expect(result.queryParams.classicParam).toEqual('classicParamValue');
|
|
356
|
+
expect(result.queryParams.sensitiveParam).toEqual('sensitiveParamValue');
|
|
357
|
+
expect(result.headers.get('ama-client-facts')).toBeNull();
|
|
358
|
+
// eslint-disable-next-line no-console -- not calling console.error but expect if it has been called or not
|
|
359
|
+
expect(console.error).not.toHaveBeenCalled();
|
|
360
|
+
return [
|
|
361
|
+
2
|
|
362
|
+
];
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
})();
|
|
366
|
+
});
|
|
367
|
+
it('should use JWT if no key specified', function() {
|
|
368
|
+
return _async_to_generator(function() {
|
|
369
|
+
var mockJweEncoder, mockJwtEncoder, plugin, runner;
|
|
370
|
+
return _ts_generator(this, function(_state) {
|
|
371
|
+
switch(_state.label){
|
|
372
|
+
case 0:
|
|
373
|
+
mockJweEncoder = jest.spyOn(_jsontoken, 'createJweEncoder');
|
|
374
|
+
mockJwtEncoder = jest.spyOn(_jsontoken, 'createJwtEncoder');
|
|
375
|
+
plugin = new _piitokenizerrequest.PiiTokenizerRequest({
|
|
376
|
+
applicationId: 'app-id'
|
|
377
|
+
});
|
|
378
|
+
runner = plugin.load();
|
|
379
|
+
return [
|
|
380
|
+
4,
|
|
381
|
+
runner.transform(_object_spread_props(_object_spread({}, options), {
|
|
382
|
+
tokenizedOptions: tokenizedOptions
|
|
383
|
+
}))
|
|
384
|
+
];
|
|
385
|
+
case 1:
|
|
386
|
+
_state.sent();
|
|
387
|
+
expect(mockJweEncoder).not.toHaveBeenCalled();
|
|
388
|
+
expect(mockJwtEncoder).toHaveBeenCalled();
|
|
389
|
+
return [
|
|
390
|
+
2
|
|
391
|
+
];
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
})();
|
|
395
|
+
});
|
|
396
|
+
it('should use JWE if a key is specified', function() {
|
|
397
|
+
return _async_to_generator(function() {
|
|
398
|
+
var key, mockJweEncoder, mockJwtEncoder, plugin, runner, result, expectedJwePayload;
|
|
399
|
+
return _ts_generator(this, function(_state) {
|
|
400
|
+
switch(_state.label){
|
|
401
|
+
case 0:
|
|
402
|
+
jest.spyOn(Date, 'now').mockImplementation(function() {
|
|
403
|
+
return 0;
|
|
404
|
+
});
|
|
405
|
+
key = {
|
|
406
|
+
publicKey: 'myPublicKey',
|
|
407
|
+
keyId: 'TEST'
|
|
408
|
+
};
|
|
409
|
+
mockJweEncoder = jest.fn().mockResolvedValue('myJweToken');
|
|
410
|
+
jest.spyOn(_jsontoken, 'createJweEncoder').mockImplementation(function() {
|
|
411
|
+
return mockJweEncoder;
|
|
412
|
+
});
|
|
413
|
+
mockJwtEncoder = jest.spyOn(_jsontoken, 'createJwtEncoder');
|
|
414
|
+
plugin = new _piitokenizerrequest.PiiTokenizerRequest({
|
|
415
|
+
applicationId: 'app-id',
|
|
416
|
+
key: key
|
|
417
|
+
});
|
|
418
|
+
runner = plugin.load();
|
|
419
|
+
return [
|
|
420
|
+
4,
|
|
421
|
+
runner.transform(_object_spread_props(_object_spread({}, options), {
|
|
422
|
+
tokenizedOptions: tokenizedOptions
|
|
423
|
+
}))
|
|
424
|
+
];
|
|
425
|
+
case 1:
|
|
426
|
+
result = _state.sent();
|
|
427
|
+
expectedJwePayload = {
|
|
428
|
+
'ama-tokens': {
|
|
429
|
+
$pathParamToken$: 'pathParamValue',
|
|
430
|
+
$sensitiveParamToken$: 'sensitiveParamValue'
|
|
431
|
+
},
|
|
432
|
+
exp: 3600,
|
|
433
|
+
iat: 0,
|
|
434
|
+
iss: 'app-id',
|
|
435
|
+
sub: 'pii'
|
|
436
|
+
};
|
|
437
|
+
expect(result.headers.get('ama-client-facts')).toEqual('myJweToken');
|
|
438
|
+
expect(mockJweEncoder).toHaveBeenCalledWith(key, expectedJwePayload, [
|
|
439
|
+
'iss',
|
|
440
|
+
'sub'
|
|
441
|
+
]);
|
|
442
|
+
expect(mockJwtEncoder).not.toHaveBeenCalled();
|
|
443
|
+
return [
|
|
444
|
+
2
|
|
445
|
+
];
|
|
446
|
+
}
|
|
447
|
+
});
|
|
448
|
+
})();
|
|
449
|
+
});
|
|
450
|
+
it('should throw by default if an exception is raised for JWE encoder', function() {
|
|
451
|
+
return _async_to_generator(function() {
|
|
452
|
+
var key, mockJweEncoder, plugin, runner;
|
|
453
|
+
return _ts_generator(this, function(_state) {
|
|
454
|
+
switch(_state.label){
|
|
455
|
+
case 0:
|
|
456
|
+
key = {
|
|
457
|
+
publicKey: 'myPublicKey',
|
|
458
|
+
keyId: 'TEST'
|
|
459
|
+
};
|
|
460
|
+
mockJweEncoder = jest.fn().mockRejectedValue('Error creating JWE');
|
|
461
|
+
jest.spyOn(_jsontoken, 'createJweEncoder').mockImplementation(function() {
|
|
462
|
+
return mockJweEncoder;
|
|
463
|
+
});
|
|
464
|
+
plugin = new _piitokenizerrequest.PiiTokenizerRequest({
|
|
465
|
+
applicationId: 'app-id',
|
|
466
|
+
key: key
|
|
467
|
+
});
|
|
468
|
+
runner = plugin.load();
|
|
469
|
+
return [
|
|
470
|
+
4,
|
|
471
|
+
expect(runner.transform(_object_spread_props(_object_spread({}, options), {
|
|
472
|
+
tokenizedOptions: tokenizedOptions
|
|
473
|
+
}))).rejects.toThrow()
|
|
474
|
+
];
|
|
475
|
+
case 1:
|
|
476
|
+
_state.sent();
|
|
477
|
+
expect(mockJweEncoder).toHaveBeenCalled();
|
|
478
|
+
// eslint-disable-next-line no-console -- not calling console.error but expect if it has been called or not
|
|
479
|
+
expect(console.error).not.toHaveBeenCalled();
|
|
480
|
+
return [
|
|
481
|
+
2
|
|
482
|
+
];
|
|
483
|
+
}
|
|
484
|
+
});
|
|
485
|
+
})();
|
|
486
|
+
});
|
|
487
|
+
it('should handle errors silently if an exception is raised for JWE encoder', function() {
|
|
488
|
+
return _async_to_generator(function() {
|
|
489
|
+
var key, mockJweEncoder, plugin, runner;
|
|
490
|
+
return _ts_generator(this, function(_state) {
|
|
491
|
+
switch(_state.label){
|
|
492
|
+
case 0:
|
|
493
|
+
key = {
|
|
494
|
+
publicKey: 'myPublicKey',
|
|
495
|
+
keyId: 'TEST'
|
|
496
|
+
};
|
|
497
|
+
mockJweEncoder = jest.fn().mockRejectedValue('Error creating JWE');
|
|
498
|
+
jest.spyOn(_jsontoken, 'createJweEncoder').mockImplementation(function() {
|
|
499
|
+
return mockJweEncoder;
|
|
500
|
+
});
|
|
501
|
+
plugin = new _piitokenizerrequest.PiiTokenizerRequest({
|
|
502
|
+
applicationId: 'app-id',
|
|
503
|
+
key: key,
|
|
504
|
+
silent: true
|
|
505
|
+
});
|
|
506
|
+
runner = plugin.load();
|
|
507
|
+
return [
|
|
508
|
+
4,
|
|
509
|
+
expect(runner.transform(_object_spread_props(_object_spread({}, options), {
|
|
510
|
+
tokenizedOptions: tokenizedOptions
|
|
511
|
+
}))).resolves.toBeDefined()
|
|
512
|
+
];
|
|
513
|
+
case 1:
|
|
514
|
+
_state.sent();
|
|
515
|
+
expect(mockJweEncoder).toHaveBeenCalled();
|
|
516
|
+
// eslint-disable-next-line no-console -- not calling console.error but expect if it has been called or not
|
|
517
|
+
expect(console.error).toHaveBeenCalled();
|
|
518
|
+
return [
|
|
519
|
+
2
|
|
520
|
+
];
|
|
521
|
+
}
|
|
522
|
+
});
|
|
523
|
+
})();
|
|
524
|
+
});
|
|
525
|
+
it('should skip PII tokenization and put DeepLink token in corresponding header when DeepLink token is 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.PiiTokenizerRequest({
|
|
532
|
+
applicationId: 'app-id'
|
|
533
|
+
});
|
|
534
|
+
runner = plugin.load();
|
|
535
|
+
deepLinkOptions = {
|
|
536
|
+
token: 'myDeepLinkToken'
|
|
537
|
+
};
|
|
538
|
+
metadata = {
|
|
539
|
+
deepLinkOptions: deepLinkOptions
|
|
540
|
+
};
|
|
541
|
+
options.basePath = 'http://test.com/path/$pathParamToken$';
|
|
542
|
+
options.queryParams = {
|
|
543
|
+
classicParam: 'classicParamValue',
|
|
544
|
+
sensitiveParam: '$sensitiveParamToken$'
|
|
545
|
+
};
|
|
546
|
+
return [
|
|
547
|
+
4,
|
|
548
|
+
runner.transform(_object_spread_props(_object_spread({}, options), {
|
|
549
|
+
tokenizedOptions: _object_spread_props(_object_spread({}, tokenizedOptions), {
|
|
550
|
+
values: {}
|
|
551
|
+
}),
|
|
552
|
+
metadata: metadata
|
|
553
|
+
}))
|
|
554
|
+
];
|
|
555
|
+
case 1:
|
|
556
|
+
result = _state.sent();
|
|
557
|
+
expect(result.basePath).toEqual('http://test.com/path/$pathParamToken$');
|
|
558
|
+
expect(result.queryParams.classicParam).toEqual('classicParamValue');
|
|
559
|
+
expect(result.queryParams.sensitiveParam).toEqual('$sensitiveParamToken$');
|
|
560
|
+
expect(result.headers.get('ama-client-facts')).toEqual('myDeepLinkToken');
|
|
561
|
+
// eslint-disable-next-line no-console -- not calling console.error but expect if it has been called or not
|
|
562
|
+
expect(console.error).not.toHaveBeenCalled();
|
|
563
|
+
return [
|
|
564
|
+
2
|
|
565
|
+
];
|
|
566
|
+
}
|
|
567
|
+
});
|
|
568
|
+
})();
|
|
569
|
+
});
|
|
570
|
+
it('should put DeepLink challenge answers in corresponding header when provided', function() {
|
|
571
|
+
return _async_to_generator(function() {
|
|
572
|
+
var plugin, runner, deepLinkOptions, metadata, result;
|
|
573
|
+
return _ts_generator(this, function(_state) {
|
|
574
|
+
switch(_state.label){
|
|
575
|
+
case 0:
|
|
576
|
+
plugin = new _piitokenizerrequest.PiiTokenizerRequest({
|
|
577
|
+
applicationId: 'app-id'
|
|
578
|
+
});
|
|
579
|
+
runner = plugin.load();
|
|
580
|
+
deepLinkOptions = {
|
|
581
|
+
token: 'myDeepLinkToken',
|
|
582
|
+
challengeAnswers: {
|
|
583
|
+
lastName: 'Doe'
|
|
584
|
+
}
|
|
585
|
+
};
|
|
586
|
+
metadata = {
|
|
587
|
+
deepLinkOptions: deepLinkOptions
|
|
588
|
+
};
|
|
589
|
+
options.basePath = 'http://test.com/path/$pathParamToken$';
|
|
590
|
+
options.queryParams = {
|
|
591
|
+
classicParam: 'classicParamValue',
|
|
592
|
+
sensitiveParam: '$sensitiveParamToken$'
|
|
593
|
+
};
|
|
594
|
+
return [
|
|
595
|
+
4,
|
|
596
|
+
runner.transform(_object_spread_props(_object_spread({}, options), {
|
|
597
|
+
tokenizedOptions: _object_spread_props(_object_spread({}, tokenizedOptions), {
|
|
598
|
+
values: {}
|
|
599
|
+
}),
|
|
600
|
+
metadata: metadata
|
|
601
|
+
}))
|
|
602
|
+
];
|
|
603
|
+
case 1:
|
|
604
|
+
result = _state.sent();
|
|
605
|
+
expect(result.basePath).toEqual('http://test.com/path/$pathParamToken$');
|
|
606
|
+
expect(result.queryParams.classicParam).toEqual('classicParamValue');
|
|
607
|
+
expect(result.queryParams.sensitiveParam).toEqual('$sensitiveParamToken$');
|
|
608
|
+
expect(result.headers.get('ama-client-facts')).toEqual('myDeepLinkToken');
|
|
609
|
+
expect(result.headers.get('ama-client-facts-challenge')).toEqual('{"lastName":"Doe"}');
|
|
610
|
+
return [
|
|
611
|
+
2
|
|
612
|
+
];
|
|
613
|
+
}
|
|
614
|
+
});
|
|
615
|
+
})();
|
|
616
|
+
});
|
|
617
|
+
it('Should not loose additional parameters not expected for the actual request', function() {
|
|
618
|
+
return _async_to_generator(function() {
|
|
619
|
+
var plugin, runner, result;
|
|
620
|
+
return _ts_generator(this, function(_state) {
|
|
621
|
+
switch(_state.label){
|
|
622
|
+
case 0:
|
|
623
|
+
plugin = new _piitokenizerrequest.PiiTokenizerRequest({
|
|
624
|
+
applicationId: 'app-id'
|
|
625
|
+
});
|
|
626
|
+
runner = plugin.load();
|
|
627
|
+
options.basePath = 'http://test.com/path/pathParamValue';
|
|
628
|
+
options.queryParams = _object_spread_props(_object_spread({}, options.queryParams), {
|
|
629
|
+
additionalParam: 'foo'
|
|
630
|
+
});
|
|
631
|
+
return [
|
|
632
|
+
4,
|
|
633
|
+
runner.transform(_object_spread_props(_object_spread({}, options), {
|
|
634
|
+
tokenizedOptions: tokenizedOptions
|
|
635
|
+
}))
|
|
636
|
+
];
|
|
637
|
+
case 1:
|
|
638
|
+
result = _state.sent();
|
|
639
|
+
expect(result.basePath).toEqual('http://test.com/path/$pathParamToken$');
|
|
640
|
+
expect(result.queryParams.additionalParam).toEqual('foo');
|
|
641
|
+
return [
|
|
642
|
+
2
|
|
643
|
+
];
|
|
644
|
+
}
|
|
645
|
+
});
|
|
646
|
+
})();
|
|
647
|
+
});
|
|
630
648
|
});
|