@ama-sdk/core 11.0.0-prerelease.9 → 11.0.0-rc.10
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 +0 -23
- package/cjs/clients/api-beacon-client.js +0 -15
- package/cjs/clients/api-fetch-client.js +0 -23
- package/cjs/fwk/api.helpers.js +1 -1
- package/cjs/fwk/core/api-client.js +1 -1
- package/cjs/fwk/index.js +0 -1
- package/cjs/plugins/perf-metric/perf-metric.fetch.js +44 -14
- package/cjs/plugins/perf-metric/perf-metric.probe.spec.js +11 -1
- package/cjs/plugins/session-id/session-id.request.js +1 -0
- package/cjs/plugins/timeout/timeout.fetch.js +14 -3
- package/cjs/plugins/timeout/timeout.spec.js +114 -0
- package/cjs/utils/generic-api.js +2 -20
- package/cjs/utils/index.js +0 -1
- package/esm2015/clients/api-angular-client.js +0 -23
- package/esm2015/clients/api-beacon-client.js +0 -15
- package/esm2015/clients/api-fetch-client.js +0 -23
- package/esm2015/fwk/api.helpers.js +1 -1
- package/esm2015/fwk/core/api-client.js +1 -1
- package/esm2015/fwk/index.js +0 -1
- package/esm2015/plugins/perf-metric/perf-metric.fetch.js +44 -14
- package/esm2015/plugins/perf-metric/perf-metric.probe.spec.js +11 -1
- package/esm2015/plugins/session-id/session-id.request.js +1 -0
- package/esm2015/plugins/timeout/timeout.fetch.js +14 -3
- package/esm2015/plugins/timeout/timeout.spec.js +115 -1
- package/esm2015/utils/generic-api.js +2 -20
- package/esm2015/utils/index.js +0 -1
- package/package.json +34 -42
- package/schematics/ng-add/index.d.ts.map +1 -1
- package/schematics/ng-add/index.js +1 -4
- package/schematics/ng-add/index.js.map +1 -0
- package/schematics/ng-add/schema.js.map +1 -0
- package/src/clients/api-angular-client.d.ts +2 -8
- package/src/clients/api-angular-client.d.ts.map +1 -1
- package/src/clients/api-angular-client.js +0 -13
- package/src/clients/api-angular-client.js.map +1 -1
- package/src/clients/api-beacon-client.d.ts +2 -8
- package/src/clients/api-beacon-client.d.ts.map +1 -1
- package/src/clients/api-beacon-client.js +0 -13
- package/src/clients/api-beacon-client.js.map +1 -1
- package/src/clients/api-fetch-client.d.ts +2 -8
- package/src/clients/api-fetch-client.d.ts.map +1 -1
- package/src/clients/api-fetch-client.js +0 -13
- package/src/clients/api-fetch-client.js.map +1 -1
- package/src/fwk/api.helpers.js +1 -1
- package/src/fwk/api.helpers.js.map +1 -1
- package/src/fwk/core/api-client.d.ts +6 -17
- package/src/fwk/core/api-client.d.ts.map +1 -1
- package/src/fwk/core/api-client.js +1 -1
- package/src/fwk/core/api-client.js.map +1 -1
- package/src/fwk/index.d.ts +0 -1
- package/src/fwk/index.d.ts.map +1 -1
- package/src/fwk/index.js +0 -1
- package/src/fwk/index.js.map +1 -1
- package/src/plugins/perf-metric/perf-metric.fetch.d.ts +45 -7
- package/src/plugins/perf-metric/perf-metric.fetch.d.ts.map +1 -1
- package/src/plugins/perf-metric/perf-metric.fetch.js +32 -17
- package/src/plugins/perf-metric/perf-metric.fetch.js.map +1 -1
- package/src/plugins/session-id/session-id.request.d.ts +1 -1
- package/src/plugins/session-id/session-id.request.d.ts.map +1 -1
- package/src/plugins/session-id/session-id.request.js +1 -0
- package/src/plugins/session-id/session-id.request.js.map +1 -1
- package/src/plugins/timeout/timeout.fetch.d.ts.map +1 -1
- package/src/plugins/timeout/timeout.fetch.js +11 -3
- package/src/plugins/timeout/timeout.fetch.js.map +1 -1
- package/src/utils/generic-api.d.ts.map +1 -1
- package/src/utils/generic-api.js +1 -3
- package/src/utils/generic-api.js.map +1 -1
- package/src/utils/index.d.ts +0 -1
- package/src/utils/index.d.ts.map +1 -1
- package/src/utils/index.js +0 -1
- package/src/utils/index.js.map +1 -1
- package/cjs/fwk/open-api-tools-configuration.js +0 -4
- package/cjs/utils/generators.js +0 -25
- package/cli/clear-index.cjs +0 -34
- package/cli/clear-index.d.cts +0 -3
- package/cli/clear-index.d.cts.map +0 -1
- package/cli/files-pack.cjs +0 -95
- package/cli/files-pack.d.cts +0 -3
- package/cli/files-pack.d.cts.map +0 -1
- package/cli/package.json +0 -3
- package/cli/update-spec-from-npm.cjs +0 -75
- package/cli/update-spec-from-npm.d.cts +0 -3
- package/cli/update-spec-from-npm.d.cts.map +0 -1
- package/esm2015/fwk/open-api-tools-configuration.js +0 -1
- package/esm2015/utils/generators.js +0 -5
- package/src/fwk/open-api-tools-configuration.d.ts +0 -28
- package/src/fwk/open-api-tools-configuration.d.ts.map +0 -1
- package/src/fwk/open-api-tools-configuration.js +0 -2
- package/src/fwk/open-api-tools-configuration.js.map +0 -1
- package/src/utils/generators.d.ts +0 -7
- package/src/utils/generators.d.ts.map +0 -1
- package/src/utils/generators.js +0 -9
- package/src/utils/generators.js.map +0 -1
|
@@ -317,29 +317,6 @@ var ApiAngularClient = /*#__PURE__*/ function() {
|
|
|
317
317
|
})();
|
|
318
318
|
}
|
|
319
319
|
},
|
|
320
|
-
{
|
|
321
|
-
key: "prepareOptions",
|
|
322
|
-
value: /** @inheritdoc */ function prepareOptions(url, method, queryParams, headers, body, tokenizedOptions, metadata, api) {
|
|
323
|
-
var _this = this;
|
|
324
|
-
return _async_to_generator(function() {
|
|
325
|
-
return _ts_generator(this, function(_state) {
|
|
326
|
-
return [
|
|
327
|
-
2,
|
|
328
|
-
_this.getRequestOptions({
|
|
329
|
-
headers: headers,
|
|
330
|
-
method: method,
|
|
331
|
-
basePath: url,
|
|
332
|
-
queryParams: queryParams,
|
|
333
|
-
body: body,
|
|
334
|
-
metadata: metadata,
|
|
335
|
-
tokenizedOptions: tokenizedOptions,
|
|
336
|
-
api: api
|
|
337
|
-
})
|
|
338
|
-
];
|
|
339
|
-
});
|
|
340
|
-
})();
|
|
341
|
-
}
|
|
342
|
-
},
|
|
343
320
|
{
|
|
344
321
|
key: "prepareUrl",
|
|
345
322
|
value: /** @inheritdoc */ function prepareUrl(url) {
|
|
@@ -161,21 +161,6 @@ var ApiBeaconClient = /*#__PURE__*/ function() {
|
|
|
161
161
|
return Promise.resolve(opts);
|
|
162
162
|
}
|
|
163
163
|
},
|
|
164
|
-
{
|
|
165
|
-
key: "prepareOptions",
|
|
166
|
-
value: /** @inheritdoc */ function prepareOptions(url, method, queryParams, headers, body, tokenizedOptions, metadata, api) {
|
|
167
|
-
return this.getRequestOptions({
|
|
168
|
-
headers: headers,
|
|
169
|
-
method: method,
|
|
170
|
-
basePath: url,
|
|
171
|
-
queryParams: queryParams,
|
|
172
|
-
body: body,
|
|
173
|
-
metadata: metadata,
|
|
174
|
-
tokenizedOptions: tokenizedOptions,
|
|
175
|
-
api: api
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
},
|
|
179
164
|
{
|
|
180
165
|
key: "prepareUrl",
|
|
181
166
|
value: /** @inheritdoc */ function prepareUrl(url, queryParameters) {
|
|
@@ -355,29 +355,6 @@ var ApiFetchClient = /*#__PURE__*/ function() {
|
|
|
355
355
|
})();
|
|
356
356
|
}
|
|
357
357
|
},
|
|
358
|
-
{
|
|
359
|
-
key: "prepareOptions",
|
|
360
|
-
value: /** @inheritdoc */ function prepareOptions(url, method, queryParams, headers, body, tokenizedOptions, metadata, api) {
|
|
361
|
-
var _this = this;
|
|
362
|
-
return _async_to_generator(function() {
|
|
363
|
-
return _ts_generator(this, function(_state) {
|
|
364
|
-
return [
|
|
365
|
-
2,
|
|
366
|
-
_this.getRequestOptions({
|
|
367
|
-
headers: headers,
|
|
368
|
-
method: method,
|
|
369
|
-
basePath: url,
|
|
370
|
-
queryParams: queryParams,
|
|
371
|
-
body: body,
|
|
372
|
-
metadata: metadata,
|
|
373
|
-
tokenizedOptions: tokenizedOptions,
|
|
374
|
-
api: api
|
|
375
|
-
})
|
|
376
|
-
];
|
|
377
|
-
});
|
|
378
|
-
})();
|
|
379
|
-
}
|
|
380
|
-
},
|
|
381
358
|
{
|
|
382
359
|
key: "prepareUrl",
|
|
383
360
|
value: /** @inheritdoc */ function prepareUrl(url) {
|
package/cjs/fwk/api.helpers.js
CHANGED
|
@@ -188,7 +188,7 @@ endpoint) {
|
|
|
188
188
|
if (typeof revivers === 'function' || typeof revivers === 'undefined') {
|
|
189
189
|
return revivers;
|
|
190
190
|
}
|
|
191
|
-
if (response.status && revivers
|
|
191
|
+
if (response.status && Object.keys(revivers).indexOf("".concat(response.status)) > -1) {
|
|
192
192
|
return revivers[response.status];
|
|
193
193
|
}
|
|
194
194
|
if (options === null || options === void 0 ? void 0 : options.disableFallback) {
|
|
@@ -9,5 +9,5 @@ Object.defineProperty(exports, "isApiClient", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
function isApiClient(client) {
|
|
12
|
-
return client && !!client.options && typeof client.extractQueryParams === 'function' && typeof client.
|
|
12
|
+
return client && !!client.options && typeof client.extractQueryParams === 'function' && typeof client.getRequestOptions === 'function' && typeof client.prepareUrl === 'function' && typeof client.processFormData === 'function' && typeof client.processCall === 'function';
|
|
13
13
|
}
|
package/cjs/fwk/index.js
CHANGED
|
@@ -11,7 +11,6 @@ _export_star(require("./errors"), exports);
|
|
|
11
11
|
_export_star(require("./ignore-enum.type"), exports);
|
|
12
12
|
_export_star(require("./logger"), exports);
|
|
13
13
|
_export_star(require("./mocks/index"), exports);
|
|
14
|
-
_export_star(require("./open-api-tools-configuration"), exports);
|
|
15
14
|
_export_star(require("./Reviver"), exports);
|
|
16
15
|
function _export_star(from, to) {
|
|
17
16
|
Object.keys(from).forEach(function(k) {
|
|
@@ -215,19 +215,31 @@ var PerformanceMetricPlugin = /*#__PURE__*/ function() {
|
|
|
215
215
|
* Callback function called when a mark is closed with an error.
|
|
216
216
|
*/ _define_property(this, "onMarkError", void 0);
|
|
217
217
|
/**
|
|
218
|
+
* Callback function called when a mark is opened.
|
|
219
|
+
*/ _define_property(this, "onMarkOpen", void 0);
|
|
220
|
+
/**
|
|
218
221
|
* Opened marks.
|
|
219
222
|
*/ _define_property(this, "openMarks", {});
|
|
220
223
|
/**
|
|
221
|
-
*
|
|
222
|
-
*
|
|
224
|
+
* Performance reporter to use for performance measurements.
|
|
225
|
+
* @default window.performance on browser only, undefined on node
|
|
226
|
+
*/ _define_property(this, "performance", void 0);
|
|
227
|
+
/**
|
|
228
|
+
* Method used to get the current time as default implementation if no Performance API available.
|
|
229
|
+
* Date.now() is used by default.
|
|
223
230
|
*/ _define_property(this, "getTime", Date.now);
|
|
231
|
+
/**
|
|
232
|
+
* Retrieve the performance tag name
|
|
233
|
+
* @param status status of the call
|
|
234
|
+
* @param markId Mark ID
|
|
235
|
+
*/ _define_property(this, "getPerformanceTag", function(status, markId) {
|
|
236
|
+
return "sdk:".concat(status, ":").concat(markId);
|
|
237
|
+
});
|
|
238
|
+
this.getPerformanceTag = (options === null || options === void 0 ? void 0 : options.getPerformanceTag) || this.getPerformanceTag;
|
|
239
|
+
this.performance = (options === null || options === void 0 ? void 0 : options.performance) || (typeof window !== 'undefined' ? window.performance : undefined);
|
|
224
240
|
this.onMarkComplete = options ? options.onMarkComplete : this.onMarkComplete;
|
|
225
241
|
this.onMarkError = options ? options.onMarkError : this.onMarkError;
|
|
226
|
-
|
|
227
|
-
this.getTime = function() {
|
|
228
|
-
return window.performance.now();
|
|
229
|
-
};
|
|
230
|
-
}
|
|
242
|
+
this.onMarkOpen = options ? options.onMarkOpen : this.onMarkOpen;
|
|
231
243
|
}
|
|
232
244
|
_create_class(PerformanceMetricPlugin, [
|
|
233
245
|
{
|
|
@@ -237,13 +249,21 @@ var PerformanceMetricPlugin = /*#__PURE__*/ function() {
|
|
|
237
249
|
* @param url URL of the call associated to the mark to open
|
|
238
250
|
* @param requestOptions Options of the call associated to the mark to open
|
|
239
251
|
*/ function openMark(url, requestOptions) {
|
|
252
|
+
var _this_performance;
|
|
240
253
|
var markId = (0, _uuid.v4)();
|
|
241
|
-
|
|
254
|
+
var perfMark = ((_this_performance = this.performance) === null || _this_performance === void 0 ? void 0 : _this_performance.mark(this.getPerformanceTag('start', markId))) || undefined;
|
|
255
|
+
var _perfMark_startTime;
|
|
256
|
+
var startTime = (_perfMark_startTime = perfMark === null || perfMark === void 0 ? void 0 : perfMark.startTime) !== null && _perfMark_startTime !== void 0 ? _perfMark_startTime : this.getTime();
|
|
257
|
+
var mark = {
|
|
242
258
|
markId: markId,
|
|
243
259
|
url: url,
|
|
244
260
|
requestOptions: requestOptions,
|
|
245
|
-
startTime:
|
|
246
|
-
}
|
|
261
|
+
startTime: startTime
|
|
262
|
+
};
|
|
263
|
+
this.openMarks[markId] = mark;
|
|
264
|
+
if (this.onMarkOpen) {
|
|
265
|
+
void this.onMarkOpen(mark);
|
|
266
|
+
}
|
|
247
267
|
return markId;
|
|
248
268
|
}
|
|
249
269
|
},
|
|
@@ -254,14 +274,19 @@ var PerformanceMetricPlugin = /*#__PURE__*/ function() {
|
|
|
254
274
|
* @param markId Id of the mark to close
|
|
255
275
|
* @param response Response of the call associated to the mark to close
|
|
256
276
|
*/ function closeMark(markId, response) {
|
|
277
|
+
var _this_performance, _this_performance1;
|
|
278
|
+
var perfMark = ((_this_performance = this.performance) === null || _this_performance === void 0 ? void 0 : _this_performance.mark(this.getPerformanceTag('end', markId))) || undefined;
|
|
279
|
+
var _perfMark_startTime;
|
|
280
|
+
var endTime = (_perfMark_startTime = perfMark === null || perfMark === void 0 ? void 0 : perfMark.startTime) !== null && _perfMark_startTime !== void 0 ? _perfMark_startTime : this.getTime();
|
|
281
|
+
(_this_performance1 = this.performance) === null || _this_performance1 === void 0 ? void 0 : _this_performance1.measure(this.getPerformanceTag('measure', markId), this.getPerformanceTag('start', markId), this.getPerformanceTag('end', markId));
|
|
257
282
|
var mark = this.openMarks[markId];
|
|
258
283
|
if (!mark) {
|
|
259
284
|
return;
|
|
260
285
|
}
|
|
261
286
|
if (this.onMarkComplete) {
|
|
262
|
-
this.onMarkComplete(_object_spread_props(_object_spread({}, mark), {
|
|
287
|
+
void this.onMarkComplete(_object_spread_props(_object_spread({}, mark), {
|
|
263
288
|
response: response,
|
|
264
|
-
endTime:
|
|
289
|
+
endTime: endTime
|
|
265
290
|
}));
|
|
266
291
|
}
|
|
267
292
|
delete this.openMarks[markId];
|
|
@@ -274,14 +299,19 @@ var PerformanceMetricPlugin = /*#__PURE__*/ function() {
|
|
|
274
299
|
* @param markId Id of the mark to close
|
|
275
300
|
* @param error Optional error of the call associated to the mark to close
|
|
276
301
|
*/ function closeMarkWithError(markId, error) {
|
|
302
|
+
var _this_performance, _this_performance1;
|
|
303
|
+
var perfMark = ((_this_performance = this.performance) === null || _this_performance === void 0 ? void 0 : _this_performance.mark(this.getPerformanceTag('error', markId))) || undefined;
|
|
304
|
+
var _perfMark_startTime;
|
|
305
|
+
var endTime = (_perfMark_startTime = perfMark === null || perfMark === void 0 ? void 0 : perfMark.startTime) !== null && _perfMark_startTime !== void 0 ? _perfMark_startTime : this.getTime();
|
|
306
|
+
(_this_performance1 = this.performance) === null || _this_performance1 === void 0 ? void 0 : _this_performance1.measure(this.getPerformanceTag('measure', markId), this.getPerformanceTag('start', markId), this.getPerformanceTag('error', markId));
|
|
277
307
|
var mark = this.openMarks[markId];
|
|
278
308
|
if (!mark) {
|
|
279
309
|
return;
|
|
280
310
|
}
|
|
281
311
|
if (this.onMarkError) {
|
|
282
|
-
this.onMarkError(_object_spread_props(_object_spread({}, mark), {
|
|
312
|
+
void this.onMarkError(_object_spread_props(_object_spread({}, mark), {
|
|
283
313
|
error: error,
|
|
284
|
-
endTime:
|
|
314
|
+
endTime: endTime
|
|
285
315
|
}));
|
|
286
316
|
}
|
|
287
317
|
delete this.openMarks[markId];
|
|
@@ -5,8 +5,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
var _perfmetricfetch = require("./perf-metric.fetch");
|
|
6
6
|
var perfPlugin;
|
|
7
7
|
describe('PerformanceMetricPlugin', function() {
|
|
8
|
+
var onMarkOpen;
|
|
8
9
|
beforeEach(function() {
|
|
9
|
-
|
|
10
|
+
onMarkOpen = jest.fn();
|
|
11
|
+
perfPlugin = new _perfmetricfetch.PerformanceMetricPlugin({
|
|
12
|
+
onMarkOpen: onMarkOpen
|
|
13
|
+
});
|
|
10
14
|
});
|
|
11
15
|
it('should generate new mark ids', function() {
|
|
12
16
|
expect(perfPlugin.openMark('', {})).not.toEqual(perfPlugin.openMark('', {}));
|
|
@@ -47,4 +51,10 @@ describe('PerformanceMetricPlugin', function() {
|
|
|
47
51
|
perfPlugin.closeMarkWithError(markId, {});
|
|
48
52
|
return ret;
|
|
49
53
|
});
|
|
54
|
+
it('should include call the open mark callback', function() {
|
|
55
|
+
var markId = perfPlugin.openMark('my-url', {});
|
|
56
|
+
expect(onMarkOpen).toHaveBeenCalledWith(expect.objectContaining({
|
|
57
|
+
markId: markId
|
|
58
|
+
}));
|
|
59
|
+
});
|
|
50
60
|
});
|
|
@@ -59,6 +59,7 @@ var SessionIdRequest = /*#__PURE__*/ function() {
|
|
|
59
59
|
// Declaration done first since generateSessionId uses the logger
|
|
60
60
|
this.sessionIdHeader = sessionIdHeader;
|
|
61
61
|
this.requestIdActivated = activateRequestId;
|
|
62
|
+
this.sessionId = this.generateSessionId();
|
|
62
63
|
}
|
|
63
64
|
_create_class(SessionIdRequest, [
|
|
64
65
|
{
|
|
@@ -78,6 +78,10 @@ function _define_property(obj, key, value) {
|
|
|
78
78
|
}
|
|
79
79
|
return obj;
|
|
80
80
|
}
|
|
81
|
+
function _type_of(obj) {
|
|
82
|
+
"@swc/helpers - typeof";
|
|
83
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
84
|
+
}
|
|
81
85
|
function _ts_generator(thisArg, body) {
|
|
82
86
|
var f, y, t, g, _ = {
|
|
83
87
|
label: 0,
|
|
@@ -177,7 +181,7 @@ function _ts_generator(thisArg, body) {
|
|
|
177
181
|
* Check if a message can be cast as an {@link ImpervaCaptchaMessage}
|
|
178
182
|
* @param message
|
|
179
183
|
*/ function isImpervaCaptchaMessage(message) {
|
|
180
|
-
return Object.prototype.hasOwnProperty.call(message, 'impervaChallenge') && Object.prototype.hasOwnProperty.call(message.impervaChallenge, 'status') && Object.prototype.hasOwnProperty.call(message.impervaChallenge, 'type') && message.impervaChallenge.type === 'captcha';
|
|
184
|
+
return !!message && Object.prototype.hasOwnProperty.call(message, 'impervaChallenge') && Object.prototype.hasOwnProperty.call(message.impervaChallenge, 'status') && Object.prototype.hasOwnProperty.call(message.impervaChallenge, 'type') && message.impervaChallenge.type === 'captcha';
|
|
181
185
|
}
|
|
182
186
|
var impervaCaptchaEventHandlerFactory = function(config) {
|
|
183
187
|
return function(timeoutPauseCallback) {
|
|
@@ -186,8 +190,15 @@ var impervaCaptchaEventHandlerFactory = function(config) {
|
|
|
186
190
|
if (originHostname !== location.hostname && ((config === null || config === void 0 ? void 0 : config.whiteListedHostNames) || []).indexOf(originHostname) === -1) {
|
|
187
191
|
return;
|
|
188
192
|
}
|
|
189
|
-
var message =
|
|
190
|
-
if (
|
|
193
|
+
var message = event.data;
|
|
194
|
+
if (typeof event.data === 'string') {
|
|
195
|
+
try {
|
|
196
|
+
message = JSON.parse(event.data);
|
|
197
|
+
} catch (e) {
|
|
198
|
+
// This might not be an imperva message
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
if ((typeof message === "undefined" ? "undefined" : _type_of(message)) === 'object' && isImpervaCaptchaMessage(message)) {
|
|
191
202
|
timeoutPauseCallback(message.impervaChallenge.status === 'started' ? 'timeoutStopped' : 'timeoutStarted');
|
|
192
203
|
}
|
|
193
204
|
};
|
|
@@ -33,6 +33,10 @@ function _async_to_generator(fn) {
|
|
|
33
33
|
});
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
+
function _type_of(obj) {
|
|
37
|
+
"@swc/helpers - typeof";
|
|
38
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
39
|
+
}
|
|
36
40
|
function _ts_generator(thisArg, body) {
|
|
37
41
|
var f, y, t, g, _ = {
|
|
38
42
|
label: 0,
|
|
@@ -128,6 +132,7 @@ function _ts_generator(thisArg, body) {
|
|
|
128
132
|
};
|
|
129
133
|
}
|
|
130
134
|
}
|
|
135
|
+
var _this = void 0;
|
|
131
136
|
describe('Timeout Fetch Plugin', function() {
|
|
132
137
|
it('should reject on timeout', /*#__PURE__*/ _async_to_generator(function() {
|
|
133
138
|
var plugin, runner, call, callback;
|
|
@@ -327,3 +332,112 @@ describe('Timeout Fetch Plugin', function() {
|
|
|
327
332
|
});
|
|
328
333
|
}));
|
|
329
334
|
});
|
|
335
|
+
describe('impervaCaptchaEventHandlerFactory', function() {
|
|
336
|
+
var postMessageTemp;
|
|
337
|
+
beforeAll(function() {
|
|
338
|
+
var _global, _global1;
|
|
339
|
+
(_global = global).location || (_global.location = {
|
|
340
|
+
hostname: 'test'
|
|
341
|
+
});
|
|
342
|
+
(_global1 = global).addEventListener || (_global1.addEventListener = jest.fn().mockImplementation(function(event, handler) {
|
|
343
|
+
if (event === 'message') {
|
|
344
|
+
postMessageTemp = function(msg, origin) {
|
|
345
|
+
var eventObject = {
|
|
346
|
+
origin: origin || 'https://test',
|
|
347
|
+
data: msg
|
|
348
|
+
};
|
|
349
|
+
if ((typeof handler === "undefined" ? "undefined" : _type_of(handler)) === 'object') {
|
|
350
|
+
handler.handleEvent(eventObject);
|
|
351
|
+
} else {
|
|
352
|
+
handler(eventObject);
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
}));
|
|
357
|
+
});
|
|
358
|
+
afterAll(function() {
|
|
359
|
+
jest.clearAllMocks();
|
|
360
|
+
});
|
|
361
|
+
it('should not throw on unexpected messages', function() {
|
|
362
|
+
var callback = jest.fn();
|
|
363
|
+
(0, _timeoutfetch.impervaCaptchaEventHandlerFactory)({
|
|
364
|
+
whiteListedHostNames: []
|
|
365
|
+
})(callback, _this);
|
|
366
|
+
postMessageTemp('pouet');
|
|
367
|
+
expect(callback).not.toHaveBeenCalled();
|
|
368
|
+
postMessageTemp(JSON.stringify({
|
|
369
|
+
impervaChallenge: {
|
|
370
|
+
type: 'incorrectType'
|
|
371
|
+
}
|
|
372
|
+
}));
|
|
373
|
+
expect(callback).not.toHaveBeenCalled();
|
|
374
|
+
postMessageTemp(JSON.stringify({
|
|
375
|
+
impervaChallenge: {
|
|
376
|
+
incorrectFormat: true
|
|
377
|
+
}
|
|
378
|
+
}));
|
|
379
|
+
expect(callback).not.toHaveBeenCalled();
|
|
380
|
+
});
|
|
381
|
+
it('should not throw on null messages', function() {
|
|
382
|
+
var callback = jest.fn();
|
|
383
|
+
(0, _timeoutfetch.impervaCaptchaEventHandlerFactory)({
|
|
384
|
+
whiteListedHostNames: []
|
|
385
|
+
})(callback, _this);
|
|
386
|
+
postMessageTemp(null);
|
|
387
|
+
expect(callback).not.toHaveBeenCalled();
|
|
388
|
+
});
|
|
389
|
+
it('should trigger a timeoutStopped if the captcha challenge has been started', function() {
|
|
390
|
+
var callback = jest.fn();
|
|
391
|
+
(0, _timeoutfetch.impervaCaptchaEventHandlerFactory)({
|
|
392
|
+
whiteListedHostNames: []
|
|
393
|
+
})(callback, _this);
|
|
394
|
+
postMessageTemp(JSON.stringify({
|
|
395
|
+
impervaChallenge: {
|
|
396
|
+
status: 'started',
|
|
397
|
+
type: 'captcha'
|
|
398
|
+
}
|
|
399
|
+
}));
|
|
400
|
+
expect(callback).toHaveBeenCalledWith('timeoutStopped');
|
|
401
|
+
});
|
|
402
|
+
it('should trigger a timeoutStarted if the captcha challenge has been finished', function() {
|
|
403
|
+
var callback = jest.fn();
|
|
404
|
+
(0, _timeoutfetch.impervaCaptchaEventHandlerFactory)({
|
|
405
|
+
whiteListedHostNames: []
|
|
406
|
+
})(callback, _this);
|
|
407
|
+
postMessageTemp({
|
|
408
|
+
impervaChallenge: {
|
|
409
|
+
status: 'ended',
|
|
410
|
+
type: 'captcha'
|
|
411
|
+
}
|
|
412
|
+
});
|
|
413
|
+
expect(callback).toHaveBeenCalledWith('timeoutStarted');
|
|
414
|
+
});
|
|
415
|
+
it('should trigger a timeoutStarted if the captcha challenge has been finished on a whitelisted domain', function() {
|
|
416
|
+
var callback = jest.fn();
|
|
417
|
+
(0, _timeoutfetch.impervaCaptchaEventHandlerFactory)({
|
|
418
|
+
whiteListedHostNames: [
|
|
419
|
+
'valid.domain'
|
|
420
|
+
]
|
|
421
|
+
})(callback, _this);
|
|
422
|
+
postMessageTemp(JSON.stringify({
|
|
423
|
+
impervaChallenge: {
|
|
424
|
+
status: 'ended',
|
|
425
|
+
type: 'captcha'
|
|
426
|
+
}
|
|
427
|
+
}), 'http://valid.domain');
|
|
428
|
+
expect(callback).toHaveBeenCalledWith('timeoutStarted');
|
|
429
|
+
});
|
|
430
|
+
it('should ignore postMessage from non whitelisted domain', function() {
|
|
431
|
+
var callback = jest.fn();
|
|
432
|
+
(0, _timeoutfetch.impervaCaptchaEventHandlerFactory)({
|
|
433
|
+
whiteListedHostNames: []
|
|
434
|
+
})(callback, _this);
|
|
435
|
+
postMessageTemp(JSON.stringify({
|
|
436
|
+
impervaChallenge: {
|
|
437
|
+
status: 'ended',
|
|
438
|
+
type: 'captcha'
|
|
439
|
+
}
|
|
440
|
+
}), 'http://invalid.domain');
|
|
441
|
+
expect(callback).not.toHaveBeenCalled();
|
|
442
|
+
});
|
|
443
|
+
});
|
package/cjs/utils/generic-api.js
CHANGED
|
@@ -197,7 +197,7 @@ var GenericApi = /*#__PURE__*/ function() {
|
|
|
197
197
|
*/ function request(requestOptions) {
|
|
198
198
|
var _this = this;
|
|
199
199
|
return _async_to_generator(function() {
|
|
200
|
-
var _requestOptions_metadata, _requestOptions_metadata1, metadataHeaderAccept, headers, requestParameters, options,
|
|
200
|
+
var _requestOptions_metadata, _requestOptions_metadata1, metadataHeaderAccept, headers, requestParameters, options, url, ret;
|
|
201
201
|
return _ts_generator(this, function(_state) {
|
|
202
202
|
switch(_state.label){
|
|
203
203
|
case 0:
|
|
@@ -212,30 +212,12 @@ var GenericApi = /*#__PURE__*/ function() {
|
|
|
212
212
|
api: _this,
|
|
213
213
|
headers: headers
|
|
214
214
|
}, requestOptions);
|
|
215
|
-
if (!_this.client.getRequestOptions) return [
|
|
216
|
-
3,
|
|
217
|
-
2
|
|
218
|
-
];
|
|
219
215
|
return [
|
|
220
216
|
4,
|
|
221
217
|
_this.client.getRequestOptions(requestParameters)
|
|
222
218
|
];
|
|
223
219
|
case 1:
|
|
224
|
-
|
|
225
|
-
return [
|
|
226
|
-
3,
|
|
227
|
-
4
|
|
228
|
-
];
|
|
229
|
-
case 2:
|
|
230
|
-
return [
|
|
231
|
-
4,
|
|
232
|
-
_this.client.prepareOptions(requestParameters.basePath, requestParameters.method, requestParameters.queryParams || {}, requestParameters.headers)
|
|
233
|
-
];
|
|
234
|
-
case 3:
|
|
235
|
-
_tmp = _state.sent();
|
|
236
|
-
_state.label = 4;
|
|
237
|
-
case 4:
|
|
238
|
-
options = _tmp;
|
|
220
|
+
options = _state.sent();
|
|
239
221
|
url = _this.client.prepareUrl(options.basePath, options.queryParams);
|
|
240
222
|
ret = _this.client.processCall(url, options, _fwk.ApiTypes.DEFAULT, requestOptions.api.apiName, requestOptions.revivers, requestOptions.operationId);
|
|
241
223
|
return [
|
package/cjs/utils/index.js
CHANGED
|
@@ -8,7 +8,6 @@ _export_star(require("./ie11"), exports);
|
|
|
8
8
|
_export_star(require("./json-token"), exports);
|
|
9
9
|
_export_star(require("./mime-types"), exports);
|
|
10
10
|
_export_star(require("./generic-api"), exports);
|
|
11
|
-
_export_star(require("./generators"), exports);
|
|
12
11
|
function _export_star(from, to) {
|
|
13
12
|
Object.keys(from).forEach(function(k) {
|
|
14
13
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
@@ -307,29 +307,6 @@ var DEFAULT_OPTIONS = {
|
|
|
307
307
|
})();
|
|
308
308
|
}
|
|
309
309
|
},
|
|
310
|
-
{
|
|
311
|
-
key: "prepareOptions",
|
|
312
|
-
value: /** @inheritdoc */ function prepareOptions(url, method, queryParams, headers, body, tokenizedOptions, metadata, api) {
|
|
313
|
-
var _this = this;
|
|
314
|
-
return _async_to_generator(function() {
|
|
315
|
-
return _ts_generator(this, function(_state) {
|
|
316
|
-
return [
|
|
317
|
-
2,
|
|
318
|
-
_this.getRequestOptions({
|
|
319
|
-
headers: headers,
|
|
320
|
-
method: method,
|
|
321
|
-
basePath: url,
|
|
322
|
-
queryParams: queryParams,
|
|
323
|
-
body: body,
|
|
324
|
-
metadata: metadata,
|
|
325
|
-
tokenizedOptions: tokenizedOptions,
|
|
326
|
-
api: api
|
|
327
|
-
})
|
|
328
|
-
];
|
|
329
|
-
});
|
|
330
|
-
})();
|
|
331
|
-
}
|
|
332
|
-
},
|
|
333
310
|
{
|
|
334
311
|
key: "prepareUrl",
|
|
335
312
|
value: /** @inheritdoc */ function prepareUrl1(url) {
|
|
@@ -154,21 +154,6 @@ var isPromise = function(value) {
|
|
|
154
154
|
return Promise.resolve(opts);
|
|
155
155
|
}
|
|
156
156
|
},
|
|
157
|
-
{
|
|
158
|
-
key: "prepareOptions",
|
|
159
|
-
value: /** @inheritdoc */ function prepareOptions(url, method, queryParams, headers, body, tokenizedOptions, metadata, api) {
|
|
160
|
-
return this.getRequestOptions({
|
|
161
|
-
headers: headers,
|
|
162
|
-
method: method,
|
|
163
|
-
basePath: url,
|
|
164
|
-
queryParams: queryParams,
|
|
165
|
-
body: body,
|
|
166
|
-
metadata: metadata,
|
|
167
|
-
tokenizedOptions: tokenizedOptions,
|
|
168
|
-
api: api
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
},
|
|
172
157
|
{
|
|
173
158
|
key: "prepareUrl",
|
|
174
159
|
value: /** @inheritdoc */ function prepareUrl1(url, queryParameters) {
|
|
@@ -345,29 +345,6 @@ var DEFAULT_OPTIONS = {
|
|
|
345
345
|
})();
|
|
346
346
|
}
|
|
347
347
|
},
|
|
348
|
-
{
|
|
349
|
-
key: "prepareOptions",
|
|
350
|
-
value: /** @inheritdoc */ function prepareOptions(url, method, queryParams, headers, body, tokenizedOptions, metadata, api) {
|
|
351
|
-
var _this = this;
|
|
352
|
-
return _async_to_generator(function() {
|
|
353
|
-
return _ts_generator(this, function(_state) {
|
|
354
|
-
return [
|
|
355
|
-
2,
|
|
356
|
-
_this.getRequestOptions({
|
|
357
|
-
headers: headers,
|
|
358
|
-
method: method,
|
|
359
|
-
basePath: url,
|
|
360
|
-
queryParams: queryParams,
|
|
361
|
-
body: body,
|
|
362
|
-
metadata: metadata,
|
|
363
|
-
tokenizedOptions: tokenizedOptions,
|
|
364
|
-
api: api
|
|
365
|
-
})
|
|
366
|
-
];
|
|
367
|
-
});
|
|
368
|
-
})();
|
|
369
|
-
}
|
|
370
|
-
},
|
|
371
348
|
{
|
|
372
349
|
key: "prepareUrl",
|
|
373
350
|
value: /** @inheritdoc */ function prepareUrl1(url) {
|
|
@@ -196,7 +196,7 @@ endpoint) {
|
|
|
196
196
|
if (typeof revivers === 'function' || typeof revivers === 'undefined') {
|
|
197
197
|
return revivers;
|
|
198
198
|
}
|
|
199
|
-
if (response.status && revivers
|
|
199
|
+
if (response.status && Object.keys(revivers).indexOf("".concat(response.status)) > -1) {
|
|
200
200
|
return revivers[response.status];
|
|
201
201
|
}
|
|
202
202
|
if (options === null || options === void 0 ? void 0 : options.disableFallback) {
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Check if the object is an Api Client object
|
|
3
3
|
* @param client object to check
|
|
4
4
|
*/ export function isApiClient(client) {
|
|
5
|
-
return client && !!client.options && typeof client.extractQueryParams === 'function' && typeof client.
|
|
5
|
+
return client && !!client.options && typeof client.extractQueryParams === 'function' && typeof client.getRequestOptions === 'function' && typeof client.prepareUrl === 'function' && typeof client.processFormData === 'function' && typeof client.processCall === 'function';
|
|
6
6
|
}
|