@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
@@ -99,7 +99,7 @@ function _object_spread_props(target, source) {
99
99
  return target;
100
100
  }
101
101
  function _ts_generator(thisArg, body) {
102
- var f, y, t, g, _ = {
102
+ var f, y, t, _ = {
103
103
  label: 0,
104
104
  sent: function() {
105
105
  if (t[0] & 1) throw t[1];
@@ -107,12 +107,8 @@ function _ts_generator(thisArg, body) {
107
107
  },
108
108
  trys: [],
109
109
  ops: []
110
- };
111
- return g = {
112
- next: verb(0),
113
- "throw": verb(1),
114
- "return": verb(2)
115
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
110
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
111
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
116
112
  return this;
117
113
  }), g;
118
114
  function verb(n) {
@@ -125,7 +121,7 @@ function _ts_generator(thisArg, body) {
125
121
  }
126
122
  function step(op) {
127
123
  if (f) throw new TypeError("Generator is already executing.");
128
- while(_)try {
124
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
129
125
  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;
130
126
  if (y = 0, t) op = [
131
127
  op[0] & 2,
@@ -248,23 +244,23 @@ function _ts_generator(thisArg, body) {
248
244
  {
249
245
  key: "load",
250
246
  value: /** @inheritDoc */ function load(context) {
251
- var data;
252
247
  var _this = this;
248
+ var data;
253
249
  return {
254
250
  // eslint-disable-next-line no-async-promise-executor -- all await are handled with a try-catch block
255
251
  canStart: function() {
256
- return new Promise(/*#__PURE__*/ function() {
257
- var _ref = _async_to_generator(function(resolve) {
252
+ return new Promise(function(resolve) {
253
+ return _async_to_generator(function() {
258
254
  var didTimeOut, timer, canStartCondition, canStart, e;
259
255
  return _ts_generator(this, function(_state) {
260
256
  switch(_state.label){
261
257
  case 0:
262
258
  didTimeOut = false;
263
- if (_this.timeout) {
259
+ if (this.timeout) {
264
260
  timer = setTimeout(function() {
265
261
  didTimeOut = true;
266
262
  resolve(false);
267
- }, _this.timeout);
263
+ }, this.timeout);
268
264
  }
269
265
  _state.label = 1;
270
266
  case 1:
@@ -276,7 +272,7 @@ function _ts_generator(thisArg, body) {
276
272
  ]);
277
273
  return [
278
274
  4,
279
- _this.canStartCondition(context)
275
+ this.canStartCondition(context)
280
276
  ];
281
277
  case 2:
282
278
  canStartCondition = _state.sent();
@@ -316,19 +312,16 @@ function _ts_generator(thisArg, body) {
316
312
  ];
317
313
  }
318
314
  });
319
- });
320
- return function(resolve) {
321
- return _ref.apply(this, arguments);
322
- };
323
- }());
315
+ }).call(_this);
316
+ });
324
317
  },
325
- transform: /*#__PURE__*/ function() {
326
- var _ref = _async_to_generator(function(fetchCall) {
318
+ transform: function(fetchCall) {
319
+ return _async_to_generator(function() {
327
320
  var response, e;
328
321
  return _ts_generator(this, function(_state) {
329
322
  switch(_state.label){
330
323
  case 0:
331
- if (!_this.callback) {
324
+ if (!this.callback) {
332
325
  return [
333
326
  2,
334
327
  fetchCall
@@ -348,7 +341,7 @@ function _ts_generator(thisArg, body) {
348
341
  ];
349
342
  case 2:
350
343
  response = _state.sent();
351
- _this.callback(_object_spread_props(_object_spread({}, context), {
344
+ this.callback(_object_spread_props(_object_spread({}, context), {
352
345
  data: data
353
346
  }), fetchCall, response);
354
347
  return [
@@ -357,7 +350,7 @@ function _ts_generator(thisArg, body) {
357
350
  ];
358
351
  case 3:
359
352
  e = _state.sent();
360
- _this.callback(_object_spread_props(_object_spread({}, context), {
353
+ this.callback(_object_spread_props(_object_spread({}, context), {
361
354
  data: data
362
355
  }), fetchCall, response);
363
356
  throw e;
@@ -367,11 +360,8 @@ function _ts_generator(thisArg, body) {
367
360
  ];
368
361
  }
369
362
  });
370
- });
371
- return function(fetchCall) {
372
- return _ref.apply(this, arguments);
373
- };
374
- }()
363
+ }).call(_this);
364
+ }
375
365
  };
376
366
  }
377
367
  }
@@ -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, g, _ = {
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,
@@ -177,203 +173,215 @@ function _ts_generator(thisArg, body) {
177
173
  import { WaitForFetch } from './wait-for.fetch';
178
174
  describe('Wait For Fetch Plugin', function() {
179
175
  var defaultContext = {};
180
- it('should not start if timeout', /*#__PURE__*/ _async_to_generator(function() {
181
- var plugin, runner, canStart;
182
- return _ts_generator(this, function(_state) {
183
- switch(_state.label){
184
- case 0:
185
- plugin = new WaitForFetch(function() {
186
- return {
187
- result: new Promise(function(resolve) {
188
- return setTimeout(function() {
189
- return resolve(true);
190
- }, 2000);
191
- })
192
- };
193
- }, 100);
194
- runner = plugin.load(defaultContext);
195
- canStart = runner.canStart();
196
- return [
197
- 4,
198
- jest.runAllTimersAsync()
199
- ];
200
- case 1:
201
- _state.sent();
202
- return [
203
- 4,
204
- canStart
205
- ];
206
- case 2:
207
- expect.apply(void 0, [
208
- _state.sent()
209
- ]).toBe(false);
210
- return [
211
- 2
212
- ];
213
- }
214
- });
215
- }));
216
- it('should start if promise condition passed', /*#__PURE__*/ _async_to_generator(function() {
217
- var plugin, runner, canStart;
218
- return _ts_generator(this, function(_state) {
219
- switch(_state.label){
220
- case 0:
221
- plugin = new WaitForFetch(function() {
222
- return {
223
- result: Promise.resolve(true)
224
- };
225
- }, 100);
226
- runner = plugin.load(defaultContext);
227
- return [
228
- 4,
229
- runner.canStart()
230
- ];
231
- case 1:
232
- canStart = _state.sent();
233
- expect(canStart).toBe(true);
234
- return [
235
- 2
236
- ];
237
- }
238
- });
239
- }));
240
- it('should start if condition passed', /*#__PURE__*/ _async_to_generator(function() {
241
- var plugin, runner, canStart;
242
- return _ts_generator(this, function(_state) {
243
- switch(_state.label){
244
- case 0:
245
- plugin = new WaitForFetch(function() {
246
- return {
247
- result: true
176
+ it('should not start if timeout', function() {
177
+ return _async_to_generator(function() {
178
+ var plugin, runner, canStart;
179
+ return _ts_generator(this, function(_state) {
180
+ switch(_state.label){
181
+ case 0:
182
+ plugin = new WaitForFetch(function() {
183
+ return {
184
+ result: new Promise(function(resolve) {
185
+ return setTimeout(function() {
186
+ return resolve(true);
187
+ }, 2000);
188
+ })
189
+ };
190
+ }, 100);
191
+ runner = plugin.load(defaultContext);
192
+ canStart = runner.canStart();
193
+ return [
194
+ 4,
195
+ jest.runAllTimersAsync()
196
+ ];
197
+ case 1:
198
+ _state.sent();
199
+ return [
200
+ 4,
201
+ canStart
202
+ ];
203
+ case 2:
204
+ expect.apply(void 0, [
205
+ _state.sent()
206
+ ]).toBe(false);
207
+ return [
208
+ 2
209
+ ];
210
+ }
211
+ });
212
+ })();
213
+ });
214
+ it('should start if promise condition passed', function() {
215
+ return _async_to_generator(function() {
216
+ var plugin, runner, canStart;
217
+ return _ts_generator(this, function(_state) {
218
+ switch(_state.label){
219
+ case 0:
220
+ plugin = new WaitForFetch(function() {
221
+ return {
222
+ result: Promise.resolve(true)
223
+ };
224
+ }, 100);
225
+ runner = plugin.load(defaultContext);
226
+ return [
227
+ 4,
228
+ runner.canStart()
229
+ ];
230
+ case 1:
231
+ canStart = _state.sent();
232
+ expect(canStart).toBe(true);
233
+ return [
234
+ 2
235
+ ];
236
+ }
237
+ });
238
+ })();
239
+ });
240
+ it('should start if condition passed', function() {
241
+ return _async_to_generator(function() {
242
+ var plugin, runner, canStart;
243
+ return _ts_generator(this, function(_state) {
244
+ switch(_state.label){
245
+ case 0:
246
+ plugin = new WaitForFetch(function() {
247
+ return {
248
+ result: true
249
+ };
250
+ }, 100);
251
+ runner = plugin.load(defaultContext);
252
+ return [
253
+ 4,
254
+ runner.canStart()
255
+ ];
256
+ case 1:
257
+ canStart = _state.sent();
258
+ expect(canStart).toBe(true);
259
+ return [
260
+ 2
261
+ ];
262
+ }
263
+ });
264
+ })();
265
+ });
266
+ it('should call the callback function on success', function() {
267
+ return _async_to_generator(function() {
268
+ var callback, plugin, runner, response, fetchCall;
269
+ return _ts_generator(this, function(_state) {
270
+ switch(_state.label){
271
+ case 0:
272
+ callback = jest.fn();
273
+ plugin = new WaitForFetch(function() {
274
+ return {
275
+ result: true
276
+ };
277
+ }, 100, callback);
278
+ runner = plugin.load(defaultContext);
279
+ response = {
280
+ test: true
248
281
  };
249
- }, 100);
250
- runner = plugin.load(defaultContext);
251
- return [
252
- 4,
253
- runner.canStart()
254
- ];
255
- case 1:
256
- canStart = _state.sent();
257
- expect(canStart).toBe(true);
258
- return [
259
- 2
260
- ];
261
- }
262
- });
263
- }));
264
- it('should call the callback function on success', /*#__PURE__*/ _async_to_generator(function() {
265
- var callback, plugin, runner, response, fetchCall;
266
- return _ts_generator(this, function(_state) {
267
- switch(_state.label){
268
- case 0:
269
- callback = jest.fn();
270
- plugin = new WaitForFetch(function() {
271
- return {
272
- result: true
282
+ fetchCall = Promise.resolve(response);
283
+ return [
284
+ 4,
285
+ runner.transform(fetchCall)
286
+ ];
287
+ case 1:
288
+ _state.sent();
289
+ expect(callback).toHaveBeenCalledWith(expect.objectContaining(defaultContext), fetchCall, response);
290
+ return [
291
+ 2
292
+ ];
293
+ }
294
+ });
295
+ })();
296
+ });
297
+ it('should call the callback function with the correct data', function() {
298
+ return _async_to_generator(function() {
299
+ var callback, plugin, runner, response, fetchCall;
300
+ return _ts_generator(this, function(_state) {
301
+ switch(_state.label){
302
+ case 0:
303
+ callback = jest.fn();
304
+ plugin = new WaitForFetch(function() {
305
+ return {
306
+ result: true,
307
+ data: 'test'
308
+ };
309
+ }, 100, callback);
310
+ runner = plugin.load(defaultContext);
311
+ response = {
312
+ test: true
273
313
  };
274
- }, 100, callback);
275
- runner = plugin.load(defaultContext);
276
- response = {
277
- test: true
278
- };
279
- fetchCall = Promise.resolve(response);
280
- return [
281
- 4,
282
- runner.transform(fetchCall)
283
- ];
284
- case 1:
285
- _state.sent();
286
- expect(callback).toHaveBeenCalledWith(expect.objectContaining(defaultContext), fetchCall, response);
287
- return [
288
- 2
289
- ];
290
- }
291
- });
292
- }));
293
- it('should call the callback function with the correct data', /*#__PURE__*/ _async_to_generator(function() {
294
- var callback, plugin, runner, response, fetchCall;
295
- return _ts_generator(this, function(_state) {
296
- switch(_state.label){
297
- case 0:
298
- callback = jest.fn();
299
- plugin = new WaitForFetch(function() {
300
- return {
301
- result: true,
314
+ fetchCall = Promise.resolve(response);
315
+ return [
316
+ 4,
317
+ runner.canStart()
318
+ ];
319
+ case 1:
320
+ _state.sent();
321
+ return [
322
+ 4,
323
+ runner.transform(fetchCall)
324
+ ];
325
+ case 2:
326
+ _state.sent();
327
+ expect(callback).toHaveBeenCalledWith(expect.objectContaining(_object_spread_props(_object_spread({}, defaultContext), {
302
328
  data: 'test'
329
+ })), fetchCall, response);
330
+ return [
331
+ 2
332
+ ];
333
+ }
334
+ });
335
+ })();
336
+ });
337
+ it('should call the callback function on failure', function() {
338
+ return _async_to_generator(function() {
339
+ var callback, plugin, runner, response, fetchCall, e;
340
+ return _ts_generator(this, function(_state) {
341
+ switch(_state.label){
342
+ case 0:
343
+ callback = jest.fn();
344
+ plugin = new WaitForFetch(function() {
345
+ return {
346
+ result: true
347
+ };
348
+ }, 100, callback);
349
+ runner = plugin.load(defaultContext);
350
+ response = {
351
+ test: true
303
352
  };
304
- }, 100, callback);
305
- runner = plugin.load(defaultContext);
306
- response = {
307
- test: true
308
- };
309
- fetchCall = Promise.resolve(response);
310
- return [
311
- 4,
312
- runner.canStart()
313
- ];
314
- case 1:
315
- _state.sent();
316
- return [
317
- 4,
318
- runner.transform(fetchCall)
319
- ];
320
- case 2:
321
- _state.sent();
322
- expect(callback).toHaveBeenCalledWith(expect.objectContaining(_object_spread_props(_object_spread({}, defaultContext), {
323
- data: 'test'
324
- })), fetchCall, response);
325
- return [
326
- 2
327
- ];
328
- }
329
- });
330
- }));
331
- it('should call the callback function on failure', /*#__PURE__*/ _async_to_generator(function() {
332
- var callback, plugin, runner, response, fetchCall, e;
333
- return _ts_generator(this, function(_state) {
334
- switch(_state.label){
335
- case 0:
336
- callback = jest.fn();
337
- plugin = new WaitForFetch(function() {
338
- return {
339
- result: true
340
- };
341
- }, 100, callback);
342
- runner = plugin.load(defaultContext);
343
- response = {
344
- test: true
345
- };
346
- fetchCall = Promise.reject(new Error(JSON.stringify(response)));
347
- _state.label = 1;
348
- case 1:
349
- _state.trys.push([
350
- 1,
351
- 3,
352
- ,
353
- 4
354
- ]);
355
- return [
356
- 4,
357
- runner.transform(fetchCall)
358
- ];
359
- case 2:
360
- _state.sent();
361
- return [
362
- 3,
363
- 4
364
- ];
365
- case 3:
366
- e = _state.sent();
367
- return [
368
- 3,
369
- 4
370
- ];
371
- case 4:
372
- expect(callback).toHaveBeenCalledWith(expect.objectContaining(defaultContext), fetchCall, undefined);
373
- return [
374
- 2
375
- ];
376
- }
377
- });
378
- }));
353
+ fetchCall = Promise.reject(new Error(JSON.stringify(response)));
354
+ _state.label = 1;
355
+ case 1:
356
+ _state.trys.push([
357
+ 1,
358
+ 3,
359
+ ,
360
+ 4
361
+ ]);
362
+ return [
363
+ 4,
364
+ runner.transform(fetchCall)
365
+ ];
366
+ case 2:
367
+ _state.sent();
368
+ return [
369
+ 3,
370
+ 4
371
+ ];
372
+ case 3:
373
+ e = _state.sent();
374
+ return [
375
+ 3,
376
+ 4
377
+ ];
378
+ case 4:
379
+ expect(callback).toHaveBeenCalledWith(expect.objectContaining(defaultContext), fetchCall, undefined);
380
+ return [
381
+ 2
382
+ ];
383
+ }
384
+ });
385
+ })();
386
+ });
379
387
  });
@@ -28,7 +28,7 @@ function _async_to_generator(fn) {
28
28
  };
29
29
  }
30
30
  function _ts_generator(thisArg, body) {
31
- var f, y, t, g, _ = {
31
+ var f, y, t, _ = {
32
32
  label: 0,
33
33
  sent: function() {
34
34
  if (t[0] & 1) throw t[1];
@@ -36,12 +36,8 @@ function _ts_generator(thisArg, body) {
36
36
  },
37
37
  trys: [],
38
38
  ops: []
39
- };
40
- return g = {
41
- next: verb(0),
42
- "throw": verb(1),
43
- "return": verb(2)
44
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
39
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
40
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
45
41
  return this;
46
42
  }), g;
47
43
  function verb(n) {
@@ -54,7 +50,7 @@ function _ts_generator(thisArg, body) {
54
50
  }
55
51
  function step(op) {
56
52
  if (f) throw new TypeError("Generator is already executing.");
57
- while(_)try {
53
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
58
54
  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;
59
55
  if (y = 0, t) op = [
60
56
  op[0] & 2,
@@ -171,10 +167,7 @@ import { promisifyMsCrypto } from './ie11';
171
167
  * @param publicKey Public key used to wrap the key
172
168
  * @param contentEncryptionKey Key to wrap
173
169
  */ export function wrapContentEncryptionKey(publicKey, contentEncryptionKey) {
174
- return _wrapContentEncryptionKey.apply(this, arguments);
175
- }
176
- function _wrapContentEncryptionKey() {
177
- _wrapContentEncryptionKey = _async_to_generator(function(publicKey, contentEncryptionKey) {
170
+ return _async_to_generator(function() {
178
171
  var bufferCek;
179
172
  return _ts_generator(this, function(_state) {
180
173
  switch(_state.label){
@@ -206,8 +199,7 @@ function _wrapContentEncryptionKey() {
206
199
  ];
207
200
  }
208
201
  });
209
- });
210
- return _wrapContentEncryptionKey.apply(this, arguments);
202
+ })();
211
203
  }
212
204
  /**
213
205
  * Generates ciphertext and 96 bits authentication tag using AES-GCM
@@ -217,10 +209,7 @@ function _wrapContentEncryptionKey() {
217
209
  * @param authenticationTagLength Length of the authentication tag AES will generate
218
210
  * @param additionalAuthenticatedData Additional cleartext data to authenticate. Altering them will make decryption impossible.
219
211
  */ export function encryptPayload(iv, key, payload, authenticationTagLength, additionalAuthenticatedData) {
220
- return _encryptPayload.apply(this, arguments);
221
- }
222
- function _encryptPayload() {
223
- _encryptPayload = _async_to_generator(function(iv, key, payload, authenticationTagLength, additionalAuthenticatedData) {
212
+ return _async_to_generator(function() {
224
213
  var ciphertext, authenticationTag, aesParams, aesOutput, aesOutput1;
225
214
  return _ts_generator(this, function(_state) {
226
215
  switch(_state.label){
@@ -269,6 +258,5 @@ function _encryptPayload() {
269
258
  ];
270
259
  }
271
260
  });
272
- });
273
- return _encryptPayload.apply(this, arguments);
261
+ })();
274
262
  }