@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
|
@@ -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,
|
|
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(
|
|
257
|
-
|
|
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 (
|
|
259
|
+
if (this.timeout) {
|
|
264
260
|
timer = setTimeout(function() {
|
|
265
261
|
didTimeOut = true;
|
|
266
262
|
resolve(false);
|
|
267
|
-
},
|
|
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
|
-
|
|
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
|
-
|
|
321
|
-
return _ref.apply(this, arguments);
|
|
322
|
-
};
|
|
323
|
-
}());
|
|
315
|
+
}).call(_this);
|
|
316
|
+
});
|
|
324
317
|
},
|
|
325
|
-
transform:
|
|
326
|
-
|
|
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 (!
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
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',
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
return
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
runner.
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
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
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
}
|
|
262
|
-
});
|
|
263
|
-
})
|
|
264
|
-
it('should call the callback function
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
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
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
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
|
-
|
|
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
|
-
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
|
});
|
package/esm2015/utils/crypto.js
CHANGED
|
@@ -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,
|
|
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
|
|
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
|
|
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
|
}
|