@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
@@ -53,7 +53,7 @@ function _define_property(obj, key, value) {
53
53
  return obj;
54
54
  }
55
55
  function _ts_generator(thisArg, body) {
56
- var f, y, t, g, _ = {
56
+ var f, y, t, _ = {
57
57
  label: 0,
58
58
  sent: function() {
59
59
  if (t[0] & 1) throw t[1];
@@ -61,12 +61,8 @@ function _ts_generator(thisArg, body) {
61
61
  },
62
62
  trys: [],
63
63
  ops: []
64
- };
65
- return g = {
66
- next: verb(0),
67
- "throw": verb(1),
68
- "return": verb(2)
69
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
64
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
65
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
70
66
  return this;
71
67
  }), g;
72
68
  function verb(n) {
@@ -79,7 +75,7 @@ function _ts_generator(thisArg, body) {
79
75
  }
80
76
  function step(op) {
81
77
  if (f) throw new TypeError("Generator is already executing.");
82
- while(_)try {
78
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
83
79
  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;
84
80
  if (y = 0, t) op = [
85
81
  op[0] & 2,
@@ -191,200 +187,212 @@ describe('JSON auth token request plugin', function() {
191
187
  afterAll(function() {
192
188
  global.sessionStorage = undefined;
193
189
  });
194
- it('should add a Bearer in the header', /*#__PURE__*/ _async_to_generator(function() {
195
- var _result_headers_get, plugin, result;
196
- return _ts_generator(this, function(_state) {
197
- switch(_state.label){
198
- case 0:
199
- plugin = new _mgwmdwauthrequest.MicroGatewayMiddlewareAuthenticationRequest(jsonAuthTokenOptions);
200
- return [
201
- 4,
202
- plugin.load().transform(options)
203
- ];
204
- case 1:
205
- result = _state.sent();
206
- expect(result.headers.has(authHeaderKey)).toBeTruthy();
207
- expect((_result_headers_get = result.headers.get(authHeaderKey)) === null || _result_headers_get === void 0 ? void 0 : _result_headers_get.startsWith(authHeaderPrefix)).toBeTruthy();
208
- return [
209
- 2
210
- ];
211
- }
212
- });
213
- }));
214
- it('should check that the jws token is well formatted', /*#__PURE__*/ _async_to_generator(function() {
215
- var plugin, result, token, tokenParts;
216
- return _ts_generator(this, function(_state) {
217
- switch(_state.label){
218
- case 0:
219
- plugin = new _mgwmdwauthrequest.MicroGatewayMiddlewareAuthenticationRequest(jsonAuthTokenOptions);
220
- return [
221
- 4,
222
- plugin.load().transform(options)
223
- ];
224
- case 1:
225
- result = _state.sent();
226
- token = result.headers.get(authHeaderKey).replace(authHeaderPrefix, '');
227
- tokenParts = token.split('.');
228
- expect(token).toBeDefined();
229
- expect(tokenParts.length).toEqual(3);
230
- return [
231
- 2
232
- ];
233
- }
234
- });
235
- }));
236
- it('should check that the header is properly set', /*#__PURE__*/ _async_to_generator(function() {
237
- var base64URLDecoder, plugin, result, token, tokenParts, header;
238
- return _ts_generator(this, function(_state) {
239
- switch(_state.label){
240
- case 0:
241
- base64URLDecoder = (0, _jsontoken.createBase64UrlDecoder)();
242
- plugin = new _mgwmdwauthrequest.MicroGatewayMiddlewareAuthenticationRequest(jsonAuthTokenOptions);
243
- return [
244
- 4,
245
- plugin.load().transform(options)
246
- ];
247
- case 1:
248
- result = _state.sent();
249
- token = result.headers.get(authHeaderKey).replace(authHeaderPrefix, '');
250
- expect(token).toBeDefined();
251
- tokenParts = token.split('.');
252
- header = JSON.parse(base64URLDecoder(tokenParts[0]));
253
- expect(header.alg).toBeDefined();
254
- expect(header.alg).toEqual('HS256');
255
- expect(header.typ).toBeDefined();
256
- expect(header.typ).toEqual('JWT');
257
- return [
258
- 2
259
- ];
260
- }
261
- });
262
- }));
263
- it('should check that the payload is properly set', /*#__PURE__*/ _async_to_generator(function() {
264
- var base64URLDecoder, base64Decoder, plugin, result, token, tokenParts, payload, context;
265
- return _ts_generator(this, function(_state) {
266
- switch(_state.label){
267
- case 0:
268
- base64URLDecoder = (0, _jsontoken.createBase64UrlDecoder)();
269
- base64Decoder = (0, _jsontoken.createBase64Decoder)();
270
- plugin = new _mgwmdwauthrequest.MicroGatewayMiddlewareAuthenticationRequest(jsonAuthTokenOptions);
271
- return [
272
- 4,
273
- plugin.load().transform(options)
274
- ];
275
- case 1:
276
- result = _state.sent();
277
- token = result.headers.get(authHeaderKey).replace(authHeaderPrefix, '');
278
- expect(token).toBeDefined();
279
- tokenParts = token.split('.');
280
- payload = JSON.parse(base64URLDecoder(tokenParts[1]));
281
- expect(payload.jti).toBeDefined();
282
- expect(payload.iat).toBeDefined();
283
- expect(payload.exp).toBeDefined();
284
- expect(payload.iss).toBeDefined();
285
- expect(payload.iss).toEqual(jsonAuthTokenOptions.applicationId);
286
- expect(payload.context).toBeDefined();
287
- context = JSON.parse(base64Decoder(payload.context));
288
- expect(context.oid).toBeDefined();
289
- expect(context.oid).toEqual(jsonAuthTokenOptions.context.oid);
290
- return [
291
- 2
292
- ];
293
- }
294
- });
295
- }));
296
- it('should check the signature validity', /*#__PURE__*/ _async_to_generator(function() {
297
- var base64URLDecoder, base64UrlEncoder, plugin, result, token, tokenParts, header, payload, signature, secretKey, _, message, signCheck;
298
- return _ts_generator(this, function(_state) {
299
- switch(_state.label){
300
- case 0:
301
- base64URLDecoder = (0, _jsontoken.createBase64UrlDecoder)();
302
- base64UrlEncoder = (0, _jsontoken.createBase64UrlEncoder)();
303
- plugin = new _mgwmdwauthrequest.MicroGatewayMiddlewareAuthenticationRequest(jsonAuthTokenOptions);
304
- return [
305
- 4,
306
- plugin.load().transform(options)
307
- ];
308
- case 1:
309
- result = _state.sent();
310
- token = result.headers.get(authHeaderKey).replace(authHeaderPrefix, '');
311
- tokenParts = token.split('.');
312
- header = JSON.parse(base64URLDecoder(tokenParts[0]));
313
- payload = JSON.parse(base64URLDecoder(tokenParts[1]));
314
- signature = tokenParts[2];
315
- _ = jsonAuthTokenOptions.apiKey;
316
- return [
317
- 4,
318
- (0, _mgwmdwauthhelpers.sha256)(jsonAuthTokenOptions.secret + payload.jti + payload.iat + routePath)
319
- ];
320
- case 2:
321
- return [
322
- 4,
323
- _mgwmdwauthhelpers.sha256.apply(void 0, [
324
- _ + _state.sent()
325
- ])
326
- ];
327
- case 3:
328
- secretKey = _state.sent();
329
- message = "".concat(base64UrlEncoder(JSON.stringify(header)), ".").concat(base64UrlEncoder(JSON.stringify(payload)));
330
- return [
331
- 4,
332
- (0, _mgwmdwauthhelpers.hmacSHA256)(message, secretKey)
333
- ];
334
- case 4:
335
- signCheck = _jsontoken.base64EncodeUrl.apply(void 0, [
336
- _state.sent()
337
- ]);
338
- expect(signature).toEqual(signCheck);
339
- return [
340
- 2
341
- ];
342
- }
343
- });
344
- }));
345
- it('should have same hmacSHA256 of node implementation', /*#__PURE__*/ _async_to_generator(function() {
346
- var base64URLDecoder, base64UrlEncoder, plugin, result, token, tokenParts, header, payload, secretKey, _, message;
347
- return _ts_generator(this, function(_state) {
348
- switch(_state.label){
349
- case 0:
350
- base64URLDecoder = (0, _jsontoken.createBase64UrlDecoder)();
351
- base64UrlEncoder = (0, _jsontoken.createBase64UrlEncoder)();
352
- plugin = new _mgwmdwauthrequest.MicroGatewayMiddlewareAuthenticationRequest(jsonAuthTokenOptions);
353
- return [
354
- 4,
355
- plugin.load().transform(options)
356
- ];
357
- case 1:
358
- result = _state.sent();
359
- token = result.headers.get(authHeaderKey).replace(authHeaderPrefix, '');
360
- tokenParts = token.split('.');
361
- header = JSON.parse(base64URLDecoder(tokenParts[0]));
362
- payload = JSON.parse(base64URLDecoder(tokenParts[1]));
363
- _ = jsonAuthTokenOptions.apiKey;
364
- return [
365
- 4,
366
- (0, _mgwmdwauthhelpers.sha256)(jsonAuthTokenOptions.secret + payload.jti + payload.iat + routePath)
367
- ];
368
- case 2:
369
- return [
370
- 4,
371
- _mgwmdwauthhelpers.sha256.apply(void 0, [
372
- _ + _state.sent()
373
- ])
374
- ];
375
- case 3:
376
- secretKey = _state.sent();
377
- message = "".concat(base64UrlEncoder(JSON.stringify(header)), ".").concat(base64UrlEncoder(JSON.stringify(payload)));
378
- return [
379
- 4,
380
- expect((0, _mgwmdwauthhelpers.hmacSHA256)(message, secretKey)).resolves.toBe(hmacSHA256NodeImplementation(message, secretKey))
381
- ];
382
- case 4:
383
- _state.sent();
384
- return [
385
- 2
386
- ];
387
- }
388
- });
389
- }));
190
+ it('should add a Bearer in the header', function() {
191
+ return _async_to_generator(function() {
192
+ var _result_headers_get, plugin, result;
193
+ return _ts_generator(this, function(_state) {
194
+ switch(_state.label){
195
+ case 0:
196
+ plugin = new _mgwmdwauthrequest.MicroGatewayMiddlewareAuthenticationRequest(jsonAuthTokenOptions);
197
+ return [
198
+ 4,
199
+ plugin.load().transform(options)
200
+ ];
201
+ case 1:
202
+ result = _state.sent();
203
+ expect(result.headers.has(authHeaderKey)).toBeTruthy();
204
+ expect((_result_headers_get = result.headers.get(authHeaderKey)) === null || _result_headers_get === void 0 ? void 0 : _result_headers_get.startsWith(authHeaderPrefix)).toBeTruthy();
205
+ return [
206
+ 2
207
+ ];
208
+ }
209
+ });
210
+ })();
211
+ });
212
+ it('should check that the jws token is well formatted', function() {
213
+ return _async_to_generator(function() {
214
+ var plugin, result, token, tokenParts;
215
+ return _ts_generator(this, function(_state) {
216
+ switch(_state.label){
217
+ case 0:
218
+ plugin = new _mgwmdwauthrequest.MicroGatewayMiddlewareAuthenticationRequest(jsonAuthTokenOptions);
219
+ return [
220
+ 4,
221
+ plugin.load().transform(options)
222
+ ];
223
+ case 1:
224
+ result = _state.sent();
225
+ token = result.headers.get(authHeaderKey).replace(authHeaderPrefix, '');
226
+ tokenParts = token.split('.');
227
+ expect(token).toBeDefined();
228
+ expect(tokenParts.length).toEqual(3);
229
+ return [
230
+ 2
231
+ ];
232
+ }
233
+ });
234
+ })();
235
+ });
236
+ it('should check that the header is properly set', function() {
237
+ return _async_to_generator(function() {
238
+ var base64URLDecoder, plugin, result, token, tokenParts, header;
239
+ return _ts_generator(this, function(_state) {
240
+ switch(_state.label){
241
+ case 0:
242
+ base64URLDecoder = (0, _jsontoken.createBase64UrlDecoder)();
243
+ plugin = new _mgwmdwauthrequest.MicroGatewayMiddlewareAuthenticationRequest(jsonAuthTokenOptions);
244
+ return [
245
+ 4,
246
+ plugin.load().transform(options)
247
+ ];
248
+ case 1:
249
+ result = _state.sent();
250
+ token = result.headers.get(authHeaderKey).replace(authHeaderPrefix, '');
251
+ expect(token).toBeDefined();
252
+ tokenParts = token.split('.');
253
+ header = JSON.parse(base64URLDecoder(tokenParts[0]));
254
+ expect(header.alg).toBeDefined();
255
+ expect(header.alg).toEqual('HS256');
256
+ expect(header.typ).toBeDefined();
257
+ expect(header.typ).toEqual('JWT');
258
+ return [
259
+ 2
260
+ ];
261
+ }
262
+ });
263
+ })();
264
+ });
265
+ it('should check that the payload is properly set', function() {
266
+ return _async_to_generator(function() {
267
+ var base64URLDecoder, base64Decoder, plugin, result, token, tokenParts, payload, context;
268
+ return _ts_generator(this, function(_state) {
269
+ switch(_state.label){
270
+ case 0:
271
+ base64URLDecoder = (0, _jsontoken.createBase64UrlDecoder)();
272
+ base64Decoder = (0, _jsontoken.createBase64Decoder)();
273
+ plugin = new _mgwmdwauthrequest.MicroGatewayMiddlewareAuthenticationRequest(jsonAuthTokenOptions);
274
+ return [
275
+ 4,
276
+ plugin.load().transform(options)
277
+ ];
278
+ case 1:
279
+ result = _state.sent();
280
+ token = result.headers.get(authHeaderKey).replace(authHeaderPrefix, '');
281
+ expect(token).toBeDefined();
282
+ tokenParts = token.split('.');
283
+ payload = JSON.parse(base64URLDecoder(tokenParts[1]));
284
+ expect(payload.jti).toBeDefined();
285
+ expect(payload.iat).toBeDefined();
286
+ expect(payload.exp).toBeDefined();
287
+ expect(payload.iss).toBeDefined();
288
+ expect(payload.iss).toEqual(jsonAuthTokenOptions.applicationId);
289
+ expect(payload.context).toBeDefined();
290
+ context = JSON.parse(base64Decoder(payload.context));
291
+ expect(context.oid).toBeDefined();
292
+ expect(context.oid).toEqual(jsonAuthTokenOptions.context.oid);
293
+ return [
294
+ 2
295
+ ];
296
+ }
297
+ });
298
+ })();
299
+ });
300
+ it('should check the signature validity', function() {
301
+ return _async_to_generator(function() {
302
+ var base64URLDecoder, base64UrlEncoder, plugin, result, token, tokenParts, header, payload, signature, secretKey, _, message, signCheck;
303
+ return _ts_generator(this, function(_state) {
304
+ switch(_state.label){
305
+ case 0:
306
+ base64URLDecoder = (0, _jsontoken.createBase64UrlDecoder)();
307
+ base64UrlEncoder = (0, _jsontoken.createBase64UrlEncoder)();
308
+ plugin = new _mgwmdwauthrequest.MicroGatewayMiddlewareAuthenticationRequest(jsonAuthTokenOptions);
309
+ return [
310
+ 4,
311
+ plugin.load().transform(options)
312
+ ];
313
+ case 1:
314
+ result = _state.sent();
315
+ token = result.headers.get(authHeaderKey).replace(authHeaderPrefix, '');
316
+ tokenParts = token.split('.');
317
+ header = JSON.parse(base64URLDecoder(tokenParts[0]));
318
+ payload = JSON.parse(base64URLDecoder(tokenParts[1]));
319
+ signature = tokenParts[2];
320
+ _ = jsonAuthTokenOptions.apiKey;
321
+ return [
322
+ 4,
323
+ (0, _mgwmdwauthhelpers.sha256)(jsonAuthTokenOptions.secret + payload.jti + payload.iat + routePath)
324
+ ];
325
+ case 2:
326
+ return [
327
+ 4,
328
+ _mgwmdwauthhelpers.sha256.apply(void 0, [
329
+ _ + _state.sent()
330
+ ])
331
+ ];
332
+ case 3:
333
+ secretKey = _state.sent();
334
+ message = "".concat(base64UrlEncoder(JSON.stringify(header)), ".").concat(base64UrlEncoder(JSON.stringify(payload)));
335
+ return [
336
+ 4,
337
+ (0, _mgwmdwauthhelpers.hmacSHA256)(message, secretKey)
338
+ ];
339
+ case 4:
340
+ signCheck = _jsontoken.base64EncodeUrl.apply(void 0, [
341
+ _state.sent()
342
+ ]);
343
+ expect(signature).toEqual(signCheck);
344
+ return [
345
+ 2
346
+ ];
347
+ }
348
+ });
349
+ })();
350
+ });
351
+ it('should have same hmacSHA256 of node implementation', function() {
352
+ return _async_to_generator(function() {
353
+ var base64URLDecoder, base64UrlEncoder, plugin, result, token, tokenParts, header, payload, secretKey, _, message;
354
+ return _ts_generator(this, function(_state) {
355
+ switch(_state.label){
356
+ case 0:
357
+ base64URLDecoder = (0, _jsontoken.createBase64UrlDecoder)();
358
+ base64UrlEncoder = (0, _jsontoken.createBase64UrlEncoder)();
359
+ plugin = new _mgwmdwauthrequest.MicroGatewayMiddlewareAuthenticationRequest(jsonAuthTokenOptions);
360
+ return [
361
+ 4,
362
+ plugin.load().transform(options)
363
+ ];
364
+ case 1:
365
+ result = _state.sent();
366
+ token = result.headers.get(authHeaderKey).replace(authHeaderPrefix, '');
367
+ tokenParts = token.split('.');
368
+ header = JSON.parse(base64URLDecoder(tokenParts[0]));
369
+ payload = JSON.parse(base64URLDecoder(tokenParts[1]));
370
+ _ = jsonAuthTokenOptions.apiKey;
371
+ return [
372
+ 4,
373
+ (0, _mgwmdwauthhelpers.sha256)(jsonAuthTokenOptions.secret + payload.jti + payload.iat + routePath)
374
+ ];
375
+ case 2:
376
+ return [
377
+ 4,
378
+ _mgwmdwauthhelpers.sha256.apply(void 0, [
379
+ _ + _state.sent()
380
+ ])
381
+ ];
382
+ case 3:
383
+ secretKey = _state.sent();
384
+ message = "".concat(base64UrlEncoder(JSON.stringify(header)), ".").concat(base64UrlEncoder(JSON.stringify(payload)));
385
+ return [
386
+ 4,
387
+ expect((0, _mgwmdwauthhelpers.hmacSHA256)(message, secretKey)).resolves.toBe(hmacSHA256NodeImplementation(message, secretKey))
388
+ ];
389
+ case 4:
390
+ _state.sent();
391
+ return [
392
+ 2
393
+ ];
394
+ }
395
+ });
396
+ })();
397
+ });
390
398
  });