@ama-sdk/core 11.0.0-prerelease.24 → 11.0.0-prerelease.26
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/plugins/timeout/timeout.fetch.js +14 -3
- package/cjs/plugins/timeout/timeout.spec.js +114 -0
- package/esm2015/plugins/timeout/timeout.fetch.js +14 -3
- package/esm2015/plugins/timeout/timeout.spec.js +115 -1
- package/package.json +5 -5
- 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
|
@@ -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
|
+
});
|
|
@@ -59,6 +59,10 @@ function _define_property(obj, key, value) {
|
|
|
59
59
|
}
|
|
60
60
|
return obj;
|
|
61
61
|
}
|
|
62
|
+
function _type_of(obj) {
|
|
63
|
+
"@swc/helpers - typeof";
|
|
64
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
65
|
+
}
|
|
62
66
|
function _ts_generator(thisArg, body) {
|
|
63
67
|
var f, y, t, g, _ = {
|
|
64
68
|
label: 0,
|
|
@@ -159,7 +163,7 @@ import { ResponseTimeoutError } from '../../fwk/errors';
|
|
|
159
163
|
* Check if a message can be cast as an {@link ImpervaCaptchaMessage}
|
|
160
164
|
* @param message
|
|
161
165
|
*/ function isImpervaCaptchaMessage(message) {
|
|
162
|
-
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';
|
|
166
|
+
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';
|
|
163
167
|
}
|
|
164
168
|
/**
|
|
165
169
|
* Captures Imperva captcha events and calls the event callback
|
|
@@ -174,8 +178,15 @@ import { ResponseTimeoutError } from '../../fwk/errors';
|
|
|
174
178
|
if (originHostname !== location.hostname && ((config === null || config === void 0 ? void 0 : config.whiteListedHostNames) || []).indexOf(originHostname) === -1) {
|
|
175
179
|
return;
|
|
176
180
|
}
|
|
177
|
-
var message =
|
|
178
|
-
if (
|
|
181
|
+
var message = event.data;
|
|
182
|
+
if (typeof event.data === 'string') {
|
|
183
|
+
try {
|
|
184
|
+
message = JSON.parse(event.data);
|
|
185
|
+
} catch (e) {
|
|
186
|
+
// This might not be an imperva message
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
if ((typeof message === "undefined" ? "undefined" : _type_of(message)) === 'object' && isImpervaCaptchaMessage(message)) {
|
|
179
190
|
timeoutPauseCallback(message.impervaChallenge.status === 'started' ? 'timeoutStopped' : 'timeoutStarted');
|
|
180
191
|
}
|
|
181
192
|
};
|
|
@@ -27,6 +27,10 @@ function _async_to_generator(fn) {
|
|
|
27
27
|
});
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
|
+
function _type_of(obj) {
|
|
31
|
+
"@swc/helpers - typeof";
|
|
32
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
33
|
+
}
|
|
30
34
|
function _ts_generator(thisArg, body) {
|
|
31
35
|
var f, y, t, g, _ = {
|
|
32
36
|
label: 0,
|
|
@@ -122,8 +126,9 @@ function _ts_generator(thisArg, body) {
|
|
|
122
126
|
};
|
|
123
127
|
}
|
|
124
128
|
}
|
|
129
|
+
var _this = this;
|
|
125
130
|
import { EmptyResponseError, ResponseTimeoutError } from '../../fwk/errors';
|
|
126
|
-
import { TimeoutFetch } from './timeout.fetch';
|
|
131
|
+
import { impervaCaptchaEventHandlerFactory, TimeoutFetch } from './timeout.fetch';
|
|
127
132
|
describe('Timeout Fetch Plugin', function() {
|
|
128
133
|
it('should reject on timeout', /*#__PURE__*/ _async_to_generator(function() {
|
|
129
134
|
var plugin, runner, call, callback;
|
|
@@ -323,3 +328,112 @@ describe('Timeout Fetch Plugin', function() {
|
|
|
323
328
|
});
|
|
324
329
|
}));
|
|
325
330
|
});
|
|
331
|
+
describe('impervaCaptchaEventHandlerFactory', function() {
|
|
332
|
+
var postMessageTemp;
|
|
333
|
+
beforeAll(function() {
|
|
334
|
+
var _global, _global1;
|
|
335
|
+
(_global = global).location || (_global.location = {
|
|
336
|
+
hostname: 'test'
|
|
337
|
+
});
|
|
338
|
+
(_global1 = global).addEventListener || (_global1.addEventListener = jest.fn().mockImplementation(function(event, handler) {
|
|
339
|
+
if (event === 'message') {
|
|
340
|
+
postMessageTemp = function(msg, origin) {
|
|
341
|
+
var eventObject = {
|
|
342
|
+
origin: origin || 'https://test',
|
|
343
|
+
data: msg
|
|
344
|
+
};
|
|
345
|
+
if ((typeof handler === "undefined" ? "undefined" : _type_of(handler)) === 'object') {
|
|
346
|
+
handler.handleEvent(eventObject);
|
|
347
|
+
} else {
|
|
348
|
+
handler(eventObject);
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
}));
|
|
353
|
+
});
|
|
354
|
+
afterAll(function() {
|
|
355
|
+
jest.clearAllMocks();
|
|
356
|
+
});
|
|
357
|
+
it('should not throw on unexpected messages', function() {
|
|
358
|
+
var callback = jest.fn();
|
|
359
|
+
impervaCaptchaEventHandlerFactory({
|
|
360
|
+
whiteListedHostNames: []
|
|
361
|
+
})(callback, _this);
|
|
362
|
+
postMessageTemp('pouet');
|
|
363
|
+
expect(callback).not.toHaveBeenCalled();
|
|
364
|
+
postMessageTemp(JSON.stringify({
|
|
365
|
+
impervaChallenge: {
|
|
366
|
+
type: 'incorrectType'
|
|
367
|
+
}
|
|
368
|
+
}));
|
|
369
|
+
expect(callback).not.toHaveBeenCalled();
|
|
370
|
+
postMessageTemp(JSON.stringify({
|
|
371
|
+
impervaChallenge: {
|
|
372
|
+
incorrectFormat: true
|
|
373
|
+
}
|
|
374
|
+
}));
|
|
375
|
+
expect(callback).not.toHaveBeenCalled();
|
|
376
|
+
});
|
|
377
|
+
it('should not throw on null messages', function() {
|
|
378
|
+
var callback = jest.fn();
|
|
379
|
+
impervaCaptchaEventHandlerFactory({
|
|
380
|
+
whiteListedHostNames: []
|
|
381
|
+
})(callback, _this);
|
|
382
|
+
postMessageTemp(null);
|
|
383
|
+
expect(callback).not.toHaveBeenCalled();
|
|
384
|
+
});
|
|
385
|
+
it('should trigger a timeoutStopped if the captcha challenge has been started', function() {
|
|
386
|
+
var callback = jest.fn();
|
|
387
|
+
impervaCaptchaEventHandlerFactory({
|
|
388
|
+
whiteListedHostNames: []
|
|
389
|
+
})(callback, _this);
|
|
390
|
+
postMessageTemp(JSON.stringify({
|
|
391
|
+
impervaChallenge: {
|
|
392
|
+
status: 'started',
|
|
393
|
+
type: 'captcha'
|
|
394
|
+
}
|
|
395
|
+
}));
|
|
396
|
+
expect(callback).toHaveBeenCalledWith('timeoutStopped');
|
|
397
|
+
});
|
|
398
|
+
it('should trigger a timeoutStarted if the captcha challenge has been finished', function() {
|
|
399
|
+
var callback = jest.fn();
|
|
400
|
+
impervaCaptchaEventHandlerFactory({
|
|
401
|
+
whiteListedHostNames: []
|
|
402
|
+
})(callback, _this);
|
|
403
|
+
postMessageTemp({
|
|
404
|
+
impervaChallenge: {
|
|
405
|
+
status: 'ended',
|
|
406
|
+
type: 'captcha'
|
|
407
|
+
}
|
|
408
|
+
});
|
|
409
|
+
expect(callback).toHaveBeenCalledWith('timeoutStarted');
|
|
410
|
+
});
|
|
411
|
+
it('should trigger a timeoutStarted if the captcha challenge has been finished on a whitelisted domain', function() {
|
|
412
|
+
var callback = jest.fn();
|
|
413
|
+
impervaCaptchaEventHandlerFactory({
|
|
414
|
+
whiteListedHostNames: [
|
|
415
|
+
'valid.domain'
|
|
416
|
+
]
|
|
417
|
+
})(callback, _this);
|
|
418
|
+
postMessageTemp(JSON.stringify({
|
|
419
|
+
impervaChallenge: {
|
|
420
|
+
status: 'ended',
|
|
421
|
+
type: 'captcha'
|
|
422
|
+
}
|
|
423
|
+
}), 'http://valid.domain');
|
|
424
|
+
expect(callback).toHaveBeenCalledWith('timeoutStarted');
|
|
425
|
+
});
|
|
426
|
+
it('should ignore postMessage from non whitelisted domain', function() {
|
|
427
|
+
var callback = jest.fn();
|
|
428
|
+
impervaCaptchaEventHandlerFactory({
|
|
429
|
+
whiteListedHostNames: []
|
|
430
|
+
})(callback, _this);
|
|
431
|
+
postMessageTemp(JSON.stringify({
|
|
432
|
+
impervaChallenge: {
|
|
433
|
+
status: 'ended',
|
|
434
|
+
type: 'captcha'
|
|
435
|
+
}
|
|
436
|
+
}), 'http://invalid.domain');
|
|
437
|
+
expect(callback).not.toHaveBeenCalled();
|
|
438
|
+
});
|
|
439
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ama-sdk/core",
|
|
3
|
-
"version": "11.0.0-prerelease.
|
|
3
|
+
"version": "11.0.0-prerelease.26",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"@angular-devkit/schematics": "~17.3.0",
|
|
83
83
|
"@angular/cli": "~17.3.0",
|
|
84
84
|
"@angular/common": "~17.3.0",
|
|
85
|
-
"@o3r/schematics": "^11.0.0-prerelease.
|
|
85
|
+
"@o3r/schematics": "^11.0.0-prerelease.26",
|
|
86
86
|
"@schematics/angular": "~17.3.0",
|
|
87
87
|
"globby": "^11.1.0",
|
|
88
88
|
"isomorphic-fetch": "^3.0.0",
|
|
@@ -123,9 +123,9 @@
|
|
|
123
123
|
"@angular/core": "~17.3.0",
|
|
124
124
|
"@nx/eslint-plugin": "~18.3.0",
|
|
125
125
|
"@nx/jest": "~18.3.0",
|
|
126
|
-
"@o3r/build-helpers": "^11.0.0-prerelease.
|
|
127
|
-
"@o3r/eslint-plugin": "^11.0.0-prerelease.
|
|
128
|
-
"@o3r/test-helpers": "^11.0.0-prerelease.
|
|
126
|
+
"@o3r/build-helpers": "^11.0.0-prerelease.26",
|
|
127
|
+
"@o3r/eslint-plugin": "^11.0.0-prerelease.26",
|
|
128
|
+
"@o3r/test-helpers": "^11.0.0-prerelease.26",
|
|
129
129
|
"@schematics/angular": "~17.3.0",
|
|
130
130
|
"@stylistic/eslint-plugin-ts": "^1.5.4",
|
|
131
131
|
"@swc/cli": "~0.3.0",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeout.fetch.d.ts","sourceRoot":"","sources":["../../../../src/plugins/timeout/timeout.fetch.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,SAAS,EAAE,WAAW,EAAE,kBAAkB,EAAC,MAAM,SAAS,CAAC;AAcnE;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,gBAAgB,GAAG,gBAAgB,CAAC;AAYhE;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,oBAAoB,EAAE,CAAC,aAAa,EAAE,aAAa,KAAK,IAAI,EAAE,OAAO,EAAE,GAAG,KAAK,MAAM,IAAI,CAAC,CAAC;AACpI;;GAEG;AACH,MAAM,MAAM,+BAA+B,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,wBAAwB,CAAC;AAEnG;;;;;;GAMG;AACH,eAAO,MAAM,iCAAiC,EAAE,+BAA+B,CAAC;IAAE,oBAAoB,EAAE,MAAM,EAAE,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"timeout.fetch.d.ts","sourceRoot":"","sources":["../../../../src/plugins/timeout/timeout.fetch.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,SAAS,EAAE,WAAW,EAAE,kBAAkB,EAAC,MAAM,SAAS,CAAC;AAcnE;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,gBAAgB,GAAG,gBAAgB,CAAC;AAYhE;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,oBAAoB,EAAE,CAAC,aAAa,EAAE,aAAa,KAAK,IAAI,EAAE,OAAO,EAAE,GAAG,KAAK,MAAM,IAAI,CAAC,CAAC;AACpI;;GAEG;AACH,MAAM,MAAM,+BAA+B,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,wBAAwB,CAAC;AAEnG;;;;;;GAMG;AACH,eAAO,MAAM,iCAAiC,EAAE,+BAA+B,CAAC;IAAE,oBAAoB,EAAE,MAAM,EAAE,CAAA;CAAE,CAuB/G,CAAC;AAEJ;;GAEG;AACH,qBAAa,YAAa,YAAW,WAAW;IAYjB,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAC;IAVhE,qCAAqC;IAC9B,OAAO,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,iBAAiB,CAAgD;IACzE,OAAO,CAAC,eAAe,CAAmC;IAE1D;;;;OAIG;gBACS,OAAO,SAAQ,EAAmB,iBAAiB,CAAC,sCAA0B;IAUnF,IAAI,CAAC,OAAO,EAAE,kBAAkB;;;CAuCxC"}
|
|
@@ -4,7 +4,7 @@ import { ResponseTimeoutError } from '../../fwk/errors';
|
|
|
4
4
|
* @param message
|
|
5
5
|
*/
|
|
6
6
|
function isImpervaCaptchaMessage(message) {
|
|
7
|
-
return Object.prototype.hasOwnProperty.call(message, 'impervaChallenge') &&
|
|
7
|
+
return !!message && Object.prototype.hasOwnProperty.call(message, 'impervaChallenge') &&
|
|
8
8
|
Object.prototype.hasOwnProperty.call(message.impervaChallenge, 'status') &&
|
|
9
9
|
Object.prototype.hasOwnProperty.call(message.impervaChallenge, 'type') && message.impervaChallenge.type === 'captcha';
|
|
10
10
|
}
|
|
@@ -21,8 +21,16 @@ export const impervaCaptchaEventHandlerFactory = (config) => (timeoutPauseCallba
|
|
|
21
21
|
if (originHostname !== location.hostname && (config?.whiteListedHostNames || []).indexOf(originHostname) === -1) {
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
if (
|
|
24
|
+
let message = event.data;
|
|
25
|
+
if (typeof event.data === 'string') {
|
|
26
|
+
try {
|
|
27
|
+
message = JSON.parse(event.data);
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
// This might not be an imperva message
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (typeof message === 'object' && isImpervaCaptchaMessage(message)) {
|
|
26
34
|
timeoutPauseCallback(message.impervaChallenge.status === 'started' ? 'timeoutStopped' : 'timeoutStarted');
|
|
27
35
|
}
|
|
28
36
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeout.fetch.js","sourceRoot":"","sources":["../../../../src/plugins/timeout/timeout.fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,kBAAkB,CAAC;AAuBtD;;;GAGG;AACH,SAAS,uBAAuB,CAAC,OAAY;IAC3C,OAAO,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"timeout.fetch.js","sourceRoot":"","sources":["../../../../src/plugins/timeout/timeout.fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,kBAAkB,CAAC;AAuBtD;;;GAGG;AACH,SAAS,uBAAuB,CAAC,OAAY;IAC3C,OAAO,CAAC,CAAC,OAAO,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,kBAAkB,CAAC;QACnF,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,QAAQ,CAAC;QACxE,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,MAAM,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