@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.
Files changed (111) hide show
  1. package/cjs/clients/api-angular-client.js +13 -18
  2. package/cjs/clients/api-fetch-client.js +16 -21
  3. package/cjs/fwk/api.helpers.js +11 -11
  4. package/cjs/fwk/date.js +5 -5
  5. package/cjs/fwk/errors.js +7 -7
  6. package/cjs/fwk/mocks/alf-mock-adapter.js +58 -60
  7. package/cjs/fwk/mocks/base-mock-adapter.js +15 -19
  8. package/cjs/fwk/mocks/helpers.js +3 -3
  9. package/cjs/fwk/param-serialization.js +6 -6
  10. package/cjs/fwk/reviver.js +4 -4
  11. package/cjs/plugins/abort/abort.spec.js +83 -81
  12. package/cjs/plugins/additional-params/additional-params.request.js +18 -25
  13. package/cjs/plugins/additional-params/additional-params.spec.js +194 -186
  14. package/cjs/plugins/api-configuration-override/api-configuration-override.request.js +10 -17
  15. package/cjs/plugins/api-configuration-override/api-configuration-override.spec.js +83 -81
  16. package/cjs/plugins/api-key/api-key.request.js +12 -19
  17. package/cjs/plugins/api-key/api-key.spec.js +50 -50
  18. package/cjs/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.js +25 -36
  19. package/cjs/plugins/bot-protection-fingerprint/bot-protection-fingerprint.spec.js +343 -327
  20. package/cjs/plugins/client-facts/client-facts.request.js +18 -25
  21. package/cjs/plugins/client-facts/client-facts.spec.js +218 -208
  22. package/cjs/plugins/concurrent/concurrent.fetch.js +12 -20
  23. package/cjs/plugins/concurrent/concurrent.spec.js +99 -99
  24. package/cjs/plugins/custom-info/custom-info.spec.js +90 -90
  25. package/cjs/plugins/fetch-cache/fetch-cache.spec.js +100 -98
  26. package/cjs/plugins/fetch-credentials/fetch-credentials.spec.js +60 -60
  27. package/cjs/plugins/json-token/json-token.spec.js +109 -107
  28. package/cjs/plugins/keepalive/keepalive.request.js +7 -12
  29. package/cjs/plugins/keepalive/keepalive.spec.js +32 -34
  30. package/cjs/plugins/mgw-mdw-auth/mgw-mdw-auth.helpers.js +11 -23
  31. package/cjs/plugins/mgw-mdw-auth/mgw-mdw-auth.request.js +18 -28
  32. package/cjs/plugins/mgw-mdw-auth/mgw-mdw-auth.spec.js +212 -204
  33. package/cjs/plugins/mock-intercept/mock-intercept.angular.js +94 -100
  34. package/cjs/plugins/mock-intercept/mock-intercept.fetch.js +15 -22
  35. package/cjs/plugins/mock-intercept/mock-intercept.interface.js +3 -3
  36. package/cjs/plugins/mock-intercept/mock-intercept.request.js +12 -19
  37. package/cjs/plugins/mock-intercept/mock-intercept.spec.js +245 -237
  38. package/cjs/plugins/perf-metric/perf-metric.fetch.js +11 -18
  39. package/cjs/plugins/pii-tokenizer/pii-tokenizer.request.js +19 -27
  40. package/cjs/plugins/pii-tokenizer/pii-tokenizer.spec.js +404 -386
  41. package/cjs/plugins/raw-response-info/raw-response-info.spec.js +67 -67
  42. package/cjs/plugins/retry/retry.fetch.js +18 -27
  43. package/cjs/plugins/retry/retry.spec.js +233 -225
  44. package/cjs/plugins/reviver/reviver.spec.js +88 -86
  45. package/cjs/plugins/session-id/session-id.spec.js +98 -94
  46. package/cjs/plugins/si-token/si-token.spec.js +27 -29
  47. package/cjs/plugins/simple-api-key-authentication/simple-api-key-authentication.request.js +17 -24
  48. package/cjs/plugins/simple-api-key-authentication/simple-api-key-authentication.spec.js +199 -191
  49. package/cjs/plugins/timeout/timeout.fetch.js +16 -22
  50. package/cjs/plugins/timeout/timeout.spec.js +211 -205
  51. package/cjs/plugins/url-rewrite/url-rewrite.request.js +9 -16
  52. package/cjs/plugins/url-rewrite/url-rewrite.spec.js +48 -48
  53. package/cjs/plugins/wait-for/wait-for.fetch.js +19 -29
  54. package/cjs/plugins/wait-for/wait-for.spec.js +211 -203
  55. package/cjs/utils/crypto.js +15 -27
  56. package/cjs/utils/generic-api.js +9 -14
  57. package/cjs/utils/json-token.js +19 -26
  58. package/cjs/utils/json-token.spec.js +495 -497
  59. package/cjs/utils/mime-types.js +3 -3
  60. package/esm2015/clients/api-angular-client.js +13 -18
  61. package/esm2015/clients/api-fetch-client.js +16 -21
  62. package/esm2015/fwk/mocks/alf-mock-adapter.js +58 -60
  63. package/esm2015/fwk/mocks/base-mock-adapter.js +15 -19
  64. package/esm2015/plugins/abort/abort.spec.js +83 -81
  65. package/esm2015/plugins/additional-params/additional-params.request.js +15 -22
  66. package/esm2015/plugins/additional-params/additional-params.spec.js +194 -186
  67. package/esm2015/plugins/api-configuration-override/api-configuration-override.request.js +10 -17
  68. package/esm2015/plugins/api-configuration-override/api-configuration-override.spec.js +83 -81
  69. package/esm2015/plugins/api-key/api-key.request.js +12 -19
  70. package/esm2015/plugins/api-key/api-key.spec.js +50 -50
  71. package/esm2015/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.js +21 -32
  72. package/esm2015/plugins/bot-protection-fingerprint/bot-protection-fingerprint.spec.js +343 -327
  73. package/esm2015/plugins/client-facts/client-facts.request.js +15 -22
  74. package/esm2015/plugins/client-facts/client-facts.spec.js +218 -208
  75. package/esm2015/plugins/concurrent/concurrent.fetch.js +12 -20
  76. package/esm2015/plugins/concurrent/concurrent.spec.js +99 -99
  77. package/esm2015/plugins/custom-info/custom-info.spec.js +90 -90
  78. package/esm2015/plugins/fetch-cache/fetch-cache.spec.js +100 -98
  79. package/esm2015/plugins/fetch-credentials/fetch-credentials.spec.js +60 -60
  80. package/esm2015/plugins/json-token/json-token.spec.js +109 -107
  81. package/esm2015/plugins/keepalive/keepalive.request.js +7 -12
  82. package/esm2015/plugins/keepalive/keepalive.spec.js +32 -34
  83. package/esm2015/plugins/mgw-mdw-auth/mgw-mdw-auth.helpers.js +8 -20
  84. package/esm2015/plugins/mgw-mdw-auth/mgw-mdw-auth.request.js +18 -28
  85. package/esm2015/plugins/mgw-mdw-auth/mgw-mdw-auth.spec.js +212 -204
  86. package/esm2015/plugins/mock-intercept/mock-intercept.angular.js +94 -100
  87. package/esm2015/plugins/mock-intercept/mock-intercept.fetch.js +15 -22
  88. package/esm2015/plugins/mock-intercept/mock-intercept.request.js +12 -19
  89. package/esm2015/plugins/mock-intercept/mock-intercept.spec.js +245 -237
  90. package/esm2015/plugins/perf-metric/perf-metric.fetch.js +11 -18
  91. package/esm2015/plugins/pii-tokenizer/pii-tokenizer.request.js +15 -23
  92. package/esm2015/plugins/pii-tokenizer/pii-tokenizer.spec.js +404 -386
  93. package/esm2015/plugins/raw-response-info/raw-response-info.spec.js +67 -67
  94. package/esm2015/plugins/retry/retry.fetch.js +18 -27
  95. package/esm2015/plugins/retry/retry.spec.js +233 -225
  96. package/esm2015/plugins/reviver/reviver.spec.js +88 -86
  97. package/esm2015/plugins/session-id/session-id.spec.js +98 -94
  98. package/esm2015/plugins/si-token/si-token.spec.js +27 -29
  99. package/esm2015/plugins/simple-api-key-authentication/simple-api-key-authentication.request.js +17 -24
  100. package/esm2015/plugins/simple-api-key-authentication/simple-api-key-authentication.spec.js +199 -191
  101. package/esm2015/plugins/timeout/timeout.fetch.js +13 -19
  102. package/esm2015/plugins/timeout/timeout.spec.js +211 -205
  103. package/esm2015/plugins/url-rewrite/url-rewrite.request.js +9 -16
  104. package/esm2015/plugins/url-rewrite/url-rewrite.spec.js +48 -48
  105. package/esm2015/plugins/wait-for/wait-for.fetch.js +19 -29
  106. package/esm2015/plugins/wait-for/wait-for.spec.js +211 -203
  107. package/esm2015/utils/crypto.js +8 -20
  108. package/esm2015/utils/generic-api.js +9 -14
  109. package/esm2015/utils/json-token.js +10 -17
  110. package/esm2015/utils/json-token.spec.js +495 -497
  111. package/package.json +6 -6
@@ -85,7 +85,7 @@ function _unsupported_iterable_to_array(o, minLen) {
85
85
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
86
86
  }
87
87
  function _ts_generator(thisArg, body) {
88
- var f, y, t, g, _ = {
88
+ var f, y, t, _ = {
89
89
  label: 0,
90
90
  sent: function() {
91
91
  if (t[0] & 1) throw t[1];
@@ -93,12 +93,8 @@ function _ts_generator(thisArg, body) {
93
93
  },
94
94
  trys: [],
95
95
  ops: []
96
- };
97
- return g = {
98
- next: verb(0),
99
- "throw": verb(1),
100
- "return": verb(2)
101
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
96
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
97
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
102
98
  return this;
103
99
  }), g;
104
100
  function verb(n) {
@@ -111,7 +107,7 @@ function _ts_generator(thisArg, body) {
111
107
  }
112
108
  function step(op) {
113
109
  if (f) throw new TypeError("Generator is already executing.");
114
- while(_)try {
110
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
115
111
  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;
116
112
  if (y = 0, t) op = [
117
113
  op[0] & 2,
@@ -198,494 +194,496 @@ describe('JSON token utils', function() {
198
194
  });
199
195
  });
200
196
  describe('JSON Web Encryption Token', function() {
201
- it('should generate a proper JWE Token', /*#__PURE__*/ _async_to_generator(function() {
202
- var expectedJwePayload, expectedJweHeader, expectedIv, cek, expectedJweEncryptedKey, outputAesGcm, jweToken, _jweToken_split, jweHeader, jweEncryptedKey, iv, cipherContent, authenticationTag, decipher, decrypted;
203
- return _ts_generator(this, function(_state) {
204
- switch(_state.label){
205
- case 0:
206
- expectedJwePayload = {
207
- iat: 0,
208
- exp: 3600,
209
- iss: 'DEMO_JWE',
210
- sub: 'pii',
211
- 'ama-tokens': {
212
- '{orderId}': 'RG287F',
213
- '{lastName}': 'Doe'
214
- }
215
- };
216
- expectedJweHeader = {
217
- alg: 'RSA-OAEP-256',
218
- enc: 'A256GCM',
219
- typ: 'JWE',
220
- kid: 'TEST',
221
- iss: 'DEMO_JWE',
222
- sub: 'pii'
223
- };
224
- expectedIv = new Uint8Array([
225
- 21,
226
- 214,
227
- 56,
228
- 246,
229
- 25,
230
- 105,
231
- 77,
232
- 119,
233
- 182,
234
- 205,
235
- 77,
236
- 245
237
- ]);
238
- cek = new Uint8Array([
239
- 247,
240
- 35,
241
- 44,
242
- 202,
243
- 131,
244
- 97,
245
- 211,
246
- 246,
247
- 244,
248
- 124,
249
- 103,
250
- 84,
251
- 189,
252
- 120,
253
- 172,
254
- 170,
255
- 207,
256
- 181,
257
- 26,
258
- 179,
259
- 11,
260
- 94,
261
- 23,
262
- 252,
263
- 252,
264
- 68,
265
- 55,
266
- 215,
267
- 250,
268
- 132,
269
- 167,
270
- 206
271
- ]);
272
- /* eslint-disable @stylistic/max-len -- keep the buffer on the same line */ expectedJweEncryptedKey = new Uint8Array([
273
- 37,
274
- 70,
275
- 170,
276
- 164,
277
- 178,
278
- 219,
279
- 174,
280
- 171,
281
- 41,
282
- 250,
283
- 254,
284
- 108,
285
- 183,
286
- 65,
287
- 233,
288
- 204,
289
- 14,
290
- 227,
291
- 187,
292
- 199,
293
- 54,
294
- 14,
295
- 72,
296
- 177,
297
- 223,
298
- 129,
299
- 9,
300
- 222,
301
- 38,
302
- 58,
303
- 184,
304
- 136,
305
- 82,
306
- 241,
307
- 61,
308
- 34,
309
- 126,
310
- 105,
311
- 106,
312
- 229,
313
- 183,
314
- 51,
315
- 147,
316
- 94,
317
- 152,
318
- 255,
319
- 20,
320
- 81,
321
- 122,
322
- 84,
323
- 150,
324
- 65,
325
- 189,
326
- 198,
327
- 38,
328
- 16,
329
- 134,
330
- 100,
331
- 213,
332
- 27,
333
- 132,
334
- 63,
335
- 190,
336
- 150,
337
- 171,
338
- 188,
339
- 122,
340
- 28,
341
- 28,
342
- 206,
343
- 178,
344
- 190,
345
- 100,
346
- 220,
347
- 239,
348
- 25,
349
- 172,
350
- 209,
351
- 239,
352
- 148,
353
- 161,
354
- 164,
355
- 131,
356
- 18,
357
- 184,
358
- 163,
359
- 35,
360
- 112,
361
- 77,
362
- 144,
363
- 67,
364
- 8,
365
- 151,
366
- 0,
367
- 157,
368
- 162,
369
- 162,
370
- 46,
371
- 181,
372
- 83,
373
- 203,
374
- 129,
375
- 167,
376
- 59,
377
- 254,
378
- 85,
379
- 58,
380
- 165,
381
- 148,
382
- 126,
383
- 32,
384
- 76,
385
- 77,
386
- 248,
387
- 134,
388
- 241,
389
- 21,
390
- 13,
391
- 66,
392
- 10,
393
- 100,
394
- 255,
395
- 185,
396
- 149,
397
- 80,
398
- 180,
399
- 173,
400
- 151,
401
- 124,
402
- 147,
403
- 211,
404
- 148,
405
- 110,
406
- 16,
407
- 232,
408
- 90,
409
- 70,
410
- 4,
411
- 155,
412
- 59,
413
- 141,
414
- 132,
415
- 19,
416
- 66,
417
- 148,
418
- 187,
419
- 232,
420
- 67,
421
- 145,
422
- 164,
423
- 254,
424
- 17,
425
- 175,
426
- 219,
427
- 77,
428
- 255,
429
- 233,
430
- 67,
431
- 188,
432
- 32,
433
- 215,
434
- 65,
435
- 60,
436
- 111,
437
- 29,
438
- 92,
439
- 117,
440
- 94,
441
- 10,
442
- 179,
443
- 214,
444
- 39,
445
- 44,
446
- 118,
447
- 18,
448
- 62,
449
- 74,
450
- 236,
451
- 88,
452
- 3,
453
- 24,
454
- 42,
455
- 81,
456
- 85,
457
- 87,
458
- 165,
459
- 116,
460
- 139,
461
- 245,
462
- 230,
463
- 66,
464
- 245,
465
- 12,
466
- 182,
467
- 211,
468
- 13,
469
- 17,
470
- 148,
471
- 221,
472
- 87,
473
- 0,
474
- 44,
475
- 229,
476
- 106,
477
- 31,
478
- 6,
479
- 206,
480
- 81,
481
- 185,
482
- 149,
483
- 101,
484
- 115,
485
- 244,
486
- 123,
487
- 26,
488
- 81,
489
- 177,
490
- 22,
491
- 183,
492
- 49,
493
- 153,
494
- 226,
495
- 120,
496
- 87,
497
- 58,
498
- 156,
499
- 133,
500
- 189,
501
- 134,
502
- 144,
503
- 77,
504
- 30,
505
- 20,
506
- 9,
507
- 171,
508
- 212,
509
- 253,
510
- 79,
511
- 177,
512
- 34,
513
- 200,
514
- 127,
515
- 236,
516
- 153,
517
- 179,
518
- 249,
519
- 204,
520
- 19,
521
- 240,
522
- 175,
523
- 2,
524
- 147,
525
- 158,
526
- 47,
527
- 239,
528
- 108
529
- ]);
530
- outputAesGcm = new Uint8Array([
531
- 179,
532
- 46,
533
- 131,
534
- 35,
535
- 83,
536
- 219,
537
- 214,
538
- 127,
539
- 56,
540
- 159,
541
- 140,
542
- 140,
543
- 140,
544
- 49,
545
- 182,
546
- 43,
547
- 246,
548
- 215,
549
- 71,
550
- 91,
551
- 178,
552
- 97,
553
- 151,
554
- 245,
555
- 65,
556
- 187,
557
- 218,
558
- 196,
559
- 140,
560
- 86,
561
- 60,
562
- 224,
563
- 80,
564
- 214,
565
- 52,
566
- 12,
567
- 174,
568
- 146,
569
- 238,
570
- 89,
571
- 22,
572
- 224,
573
- 29,
574
- 221,
575
- 213,
576
- 246,
577
- 253,
578
- 35,
579
- 122,
580
- 21,
581
- 151,
582
- 96,
583
- 240,
584
- 179,
585
- 237,
586
- 93,
587
- 75,
588
- 247,
589
- 101,
590
- 165,
591
- 43,
592
- 74,
593
- 179,
594
- 212,
595
- 165,
596
- 223,
597
- 137,
598
- 70,
599
- 249,
600
- 80,
601
- 60,
602
- 217,
603
- 54,
604
- 216,
605
- 19,
606
- 241,
607
- 212,
608
- 103,
609
- 188,
610
- 157,
611
- 186,
612
- 144,
613
- 235,
614
- 79,
615
- 162,
616
- 188,
617
- 8,
618
- 77,
619
- 173,
620
- 65,
621
- 216,
622
- 160,
623
- 59,
624
- 184,
625
- 122,
626
- 119,
627
- 78,
628
- 91,
629
- 140,
630
- 135,
631
- 6,
632
- 139,
633
- 178,
634
- 11,
635
- 135,
636
- 141,
637
- 193,
638
- 214,
639
- 171,
640
- 208,
641
- 137,
642
- 20,
643
- 236,
644
- 129,
645
- 126,
646
- 8
647
- ]);
648
- /* eslint-enable @stylistic/max-len */ global.window = {
649
- btoa: function(data) {
650
- return Buffer.from(data, 'ascii').toString('base64');
651
- },
652
- crypto: {
653
- getRandomValues: jest.fn().mockReturnValue(expectedIv),
654
- subtle: {
655
- wrapKey: jest.fn().mockReturnValue(expectedJweEncryptedKey),
656
- generateKey: jest.fn().mockReturnValue(cek),
657
- encrypt: jest.fn().mockReturnValue(outputAesGcm)
197
+ it('should generate a proper JWE Token', function() {
198
+ return _async_to_generator(function() {
199
+ var expectedJwePayload, expectedJweHeader, expectedIv, cek, expectedJweEncryptedKey, outputAesGcm, jweToken, _jweToken_split, jweHeader, jweEncryptedKey, iv, cipherContent, authenticationTag, decipher, decrypted;
200
+ return _ts_generator(this, function(_state) {
201
+ switch(_state.label){
202
+ case 0:
203
+ expectedJwePayload = {
204
+ iat: 0,
205
+ exp: 3600,
206
+ iss: 'DEMO_JWE',
207
+ sub: 'pii',
208
+ 'ama-tokens': {
209
+ '{orderId}': 'RG287F',
210
+ '{lastName}': 'Doe'
658
211
  }
659
- }
660
- };
661
- return [
662
- 4,
663
- (0, _jsontoken.createJweEncoder)(96)({
664
- publicKey: 'myPublicKey',
665
- keyId: 'TEST'
666
- }, expectedJwePayload, [
667
- 'iss',
668
- 'sub'
669
- ])
670
- ];
671
- case 1:
672
- jweToken = _state.sent();
673
- global.window = undefined;
674
- _jweToken_split = _sliced_to_array(jweToken.split('.'), 5), jweHeader = _jweToken_split[0], jweEncryptedKey = _jweToken_split[1], iv = _jweToken_split[2], cipherContent = _jweToken_split[3], authenticationTag = _jweToken_split[4];
675
- expect(decodeURI(Buffer.from((0, _jsontoken.base64DecodeUrl)(jweHeader), 'base64').toString())).toEqual(JSON.stringify(expectedJweHeader));
676
- expect(Buffer.from((0, _jsontoken.base64DecodeUrl)(jweEncryptedKey), 'base64')).toEqual(Buffer.from(expectedJweEncryptedKey));
677
- expect(Buffer.from((0, _jsontoken.base64DecodeUrl)(iv), 'base64')).toEqual(Buffer.from(expectedIv));
678
- decipher = _nodecrypto.default.createDecipheriv('aes-256-gcm', cek, Buffer.from((0, _jsontoken.base64DecodeUrl)(iv), 'base64'), {
679
- authTagLength: 12
680
- });
681
- decipher.setAuthTag(Buffer.from((0, _jsontoken.base64DecodeUrl)(authenticationTag), 'base64'));
682
- decrypted = decipher.update(Buffer.from((0, _jsontoken.base64DecodeUrl)(cipherContent), 'base64')).toString();
683
- decrypted += decipher.final().toString();
684
- expect(decrypted).toEqual(JSON.stringify(expectedJwePayload));
685
- return [
686
- 2
687
- ];
688
- }
689
- });
690
- }));
212
+ };
213
+ expectedJweHeader = {
214
+ alg: 'RSA-OAEP-256',
215
+ enc: 'A256GCM',
216
+ typ: 'JWE',
217
+ kid: 'TEST',
218
+ iss: 'DEMO_JWE',
219
+ sub: 'pii'
220
+ };
221
+ expectedIv = new Uint8Array([
222
+ 21,
223
+ 214,
224
+ 56,
225
+ 246,
226
+ 25,
227
+ 105,
228
+ 77,
229
+ 119,
230
+ 182,
231
+ 205,
232
+ 77,
233
+ 245
234
+ ]);
235
+ cek = new Uint8Array([
236
+ 247,
237
+ 35,
238
+ 44,
239
+ 202,
240
+ 131,
241
+ 97,
242
+ 211,
243
+ 246,
244
+ 244,
245
+ 124,
246
+ 103,
247
+ 84,
248
+ 189,
249
+ 120,
250
+ 172,
251
+ 170,
252
+ 207,
253
+ 181,
254
+ 26,
255
+ 179,
256
+ 11,
257
+ 94,
258
+ 23,
259
+ 252,
260
+ 252,
261
+ 68,
262
+ 55,
263
+ 215,
264
+ 250,
265
+ 132,
266
+ 167,
267
+ 206
268
+ ]);
269
+ /* eslint-disable @stylistic/max-len -- keep the buffer on the same line */ expectedJweEncryptedKey = new Uint8Array([
270
+ 37,
271
+ 70,
272
+ 170,
273
+ 164,
274
+ 178,
275
+ 219,
276
+ 174,
277
+ 171,
278
+ 41,
279
+ 250,
280
+ 254,
281
+ 108,
282
+ 183,
283
+ 65,
284
+ 233,
285
+ 204,
286
+ 14,
287
+ 227,
288
+ 187,
289
+ 199,
290
+ 54,
291
+ 14,
292
+ 72,
293
+ 177,
294
+ 223,
295
+ 129,
296
+ 9,
297
+ 222,
298
+ 38,
299
+ 58,
300
+ 184,
301
+ 136,
302
+ 82,
303
+ 241,
304
+ 61,
305
+ 34,
306
+ 126,
307
+ 105,
308
+ 106,
309
+ 229,
310
+ 183,
311
+ 51,
312
+ 147,
313
+ 94,
314
+ 152,
315
+ 255,
316
+ 20,
317
+ 81,
318
+ 122,
319
+ 84,
320
+ 150,
321
+ 65,
322
+ 189,
323
+ 198,
324
+ 38,
325
+ 16,
326
+ 134,
327
+ 100,
328
+ 213,
329
+ 27,
330
+ 132,
331
+ 63,
332
+ 190,
333
+ 150,
334
+ 171,
335
+ 188,
336
+ 122,
337
+ 28,
338
+ 28,
339
+ 206,
340
+ 178,
341
+ 190,
342
+ 100,
343
+ 220,
344
+ 239,
345
+ 25,
346
+ 172,
347
+ 209,
348
+ 239,
349
+ 148,
350
+ 161,
351
+ 164,
352
+ 131,
353
+ 18,
354
+ 184,
355
+ 163,
356
+ 35,
357
+ 112,
358
+ 77,
359
+ 144,
360
+ 67,
361
+ 8,
362
+ 151,
363
+ 0,
364
+ 157,
365
+ 162,
366
+ 162,
367
+ 46,
368
+ 181,
369
+ 83,
370
+ 203,
371
+ 129,
372
+ 167,
373
+ 59,
374
+ 254,
375
+ 85,
376
+ 58,
377
+ 165,
378
+ 148,
379
+ 126,
380
+ 32,
381
+ 76,
382
+ 77,
383
+ 248,
384
+ 134,
385
+ 241,
386
+ 21,
387
+ 13,
388
+ 66,
389
+ 10,
390
+ 100,
391
+ 255,
392
+ 185,
393
+ 149,
394
+ 80,
395
+ 180,
396
+ 173,
397
+ 151,
398
+ 124,
399
+ 147,
400
+ 211,
401
+ 148,
402
+ 110,
403
+ 16,
404
+ 232,
405
+ 90,
406
+ 70,
407
+ 4,
408
+ 155,
409
+ 59,
410
+ 141,
411
+ 132,
412
+ 19,
413
+ 66,
414
+ 148,
415
+ 187,
416
+ 232,
417
+ 67,
418
+ 145,
419
+ 164,
420
+ 254,
421
+ 17,
422
+ 175,
423
+ 219,
424
+ 77,
425
+ 255,
426
+ 233,
427
+ 67,
428
+ 188,
429
+ 32,
430
+ 215,
431
+ 65,
432
+ 60,
433
+ 111,
434
+ 29,
435
+ 92,
436
+ 117,
437
+ 94,
438
+ 10,
439
+ 179,
440
+ 214,
441
+ 39,
442
+ 44,
443
+ 118,
444
+ 18,
445
+ 62,
446
+ 74,
447
+ 236,
448
+ 88,
449
+ 3,
450
+ 24,
451
+ 42,
452
+ 81,
453
+ 85,
454
+ 87,
455
+ 165,
456
+ 116,
457
+ 139,
458
+ 245,
459
+ 230,
460
+ 66,
461
+ 245,
462
+ 12,
463
+ 182,
464
+ 211,
465
+ 13,
466
+ 17,
467
+ 148,
468
+ 221,
469
+ 87,
470
+ 0,
471
+ 44,
472
+ 229,
473
+ 106,
474
+ 31,
475
+ 6,
476
+ 206,
477
+ 81,
478
+ 185,
479
+ 149,
480
+ 101,
481
+ 115,
482
+ 244,
483
+ 123,
484
+ 26,
485
+ 81,
486
+ 177,
487
+ 22,
488
+ 183,
489
+ 49,
490
+ 153,
491
+ 226,
492
+ 120,
493
+ 87,
494
+ 58,
495
+ 156,
496
+ 133,
497
+ 189,
498
+ 134,
499
+ 144,
500
+ 77,
501
+ 30,
502
+ 20,
503
+ 9,
504
+ 171,
505
+ 212,
506
+ 253,
507
+ 79,
508
+ 177,
509
+ 34,
510
+ 200,
511
+ 127,
512
+ 236,
513
+ 153,
514
+ 179,
515
+ 249,
516
+ 204,
517
+ 19,
518
+ 240,
519
+ 175,
520
+ 2,
521
+ 147,
522
+ 158,
523
+ 47,
524
+ 239,
525
+ 108
526
+ ]);
527
+ outputAesGcm = new Uint8Array([
528
+ 179,
529
+ 46,
530
+ 131,
531
+ 35,
532
+ 83,
533
+ 219,
534
+ 214,
535
+ 127,
536
+ 56,
537
+ 159,
538
+ 140,
539
+ 140,
540
+ 140,
541
+ 49,
542
+ 182,
543
+ 43,
544
+ 246,
545
+ 215,
546
+ 71,
547
+ 91,
548
+ 178,
549
+ 97,
550
+ 151,
551
+ 245,
552
+ 65,
553
+ 187,
554
+ 218,
555
+ 196,
556
+ 140,
557
+ 86,
558
+ 60,
559
+ 224,
560
+ 80,
561
+ 214,
562
+ 52,
563
+ 12,
564
+ 174,
565
+ 146,
566
+ 238,
567
+ 89,
568
+ 22,
569
+ 224,
570
+ 29,
571
+ 221,
572
+ 213,
573
+ 246,
574
+ 253,
575
+ 35,
576
+ 122,
577
+ 21,
578
+ 151,
579
+ 96,
580
+ 240,
581
+ 179,
582
+ 237,
583
+ 93,
584
+ 75,
585
+ 247,
586
+ 101,
587
+ 165,
588
+ 43,
589
+ 74,
590
+ 179,
591
+ 212,
592
+ 165,
593
+ 223,
594
+ 137,
595
+ 70,
596
+ 249,
597
+ 80,
598
+ 60,
599
+ 217,
600
+ 54,
601
+ 216,
602
+ 19,
603
+ 241,
604
+ 212,
605
+ 103,
606
+ 188,
607
+ 157,
608
+ 186,
609
+ 144,
610
+ 235,
611
+ 79,
612
+ 162,
613
+ 188,
614
+ 8,
615
+ 77,
616
+ 173,
617
+ 65,
618
+ 216,
619
+ 160,
620
+ 59,
621
+ 184,
622
+ 122,
623
+ 119,
624
+ 78,
625
+ 91,
626
+ 140,
627
+ 135,
628
+ 6,
629
+ 139,
630
+ 178,
631
+ 11,
632
+ 135,
633
+ 141,
634
+ 193,
635
+ 214,
636
+ 171,
637
+ 208,
638
+ 137,
639
+ 20,
640
+ 236,
641
+ 129,
642
+ 126,
643
+ 8
644
+ ]);
645
+ /* eslint-enable @stylistic/max-len */ global.window = {
646
+ btoa: function(data) {
647
+ return Buffer.from(data, 'ascii').toString('base64');
648
+ },
649
+ crypto: {
650
+ getRandomValues: jest.fn().mockReturnValue(expectedIv),
651
+ subtle: {
652
+ wrapKey: jest.fn().mockReturnValue(expectedJweEncryptedKey),
653
+ generateKey: jest.fn().mockReturnValue(cek),
654
+ encrypt: jest.fn().mockReturnValue(outputAesGcm)
655
+ }
656
+ }
657
+ };
658
+ return [
659
+ 4,
660
+ (0, _jsontoken.createJweEncoder)(96)({
661
+ publicKey: 'myPublicKey',
662
+ keyId: 'TEST'
663
+ }, expectedJwePayload, [
664
+ 'iss',
665
+ 'sub'
666
+ ])
667
+ ];
668
+ case 1:
669
+ jweToken = _state.sent();
670
+ global.window = undefined;
671
+ _jweToken_split = _sliced_to_array(jweToken.split('.'), 5), jweHeader = _jweToken_split[0], jweEncryptedKey = _jweToken_split[1], iv = _jweToken_split[2], cipherContent = _jweToken_split[3], authenticationTag = _jweToken_split[4];
672
+ expect(decodeURI(Buffer.from((0, _jsontoken.base64DecodeUrl)(jweHeader), 'base64').toString())).toEqual(JSON.stringify(expectedJweHeader));
673
+ expect(Buffer.from((0, _jsontoken.base64DecodeUrl)(jweEncryptedKey), 'base64')).toEqual(Buffer.from(expectedJweEncryptedKey));
674
+ expect(Buffer.from((0, _jsontoken.base64DecodeUrl)(iv), 'base64')).toEqual(Buffer.from(expectedIv));
675
+ decipher = _nodecrypto.default.createDecipheriv('aes-256-gcm', cek, Buffer.from((0, _jsontoken.base64DecodeUrl)(iv), 'base64'), {
676
+ authTagLength: 12
677
+ });
678
+ decipher.setAuthTag(Buffer.from((0, _jsontoken.base64DecodeUrl)(authenticationTag), 'base64'));
679
+ decrypted = decipher.update(Buffer.from((0, _jsontoken.base64DecodeUrl)(cipherContent), 'base64')).toString();
680
+ decrypted += decipher.final().toString();
681
+ expect(decrypted).toEqual(JSON.stringify(expectedJwePayload));
682
+ return [
683
+ 2
684
+ ];
685
+ }
686
+ });
687
+ })();
688
+ });
691
689
  });