perimeterx-js-core 0.12.0 → 0.13.0

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.
@@ -214,6 +214,13 @@ var ConfigurationBase = /** @class */ (function () {
214
214
  enumerable: false,
215
215
  configurable: true
216
216
  });
217
+ Object.defineProperty(ConfigurationBase.prototype, "firstPartyTimeoutMs", {
218
+ get: function () {
219
+ return this.configParams.px_first_party_timeout_ms;
220
+ },
221
+ enumerable: false,
222
+ configurable: true
223
+ });
217
224
  Object.defineProperty(ConfigurationBase.prototype, "loggerSeverity", {
218
225
  get: function () {
219
226
  return this.logger.getLoggerSeverity();
@@ -30,6 +30,7 @@ exports.DEFAULT_COMMON_CONFIGURATION_PARAMS = {
30
30
  px_custom_first_party_sensor_endpoint: '',
31
31
  px_custom_first_party_xhr_endpoint: '',
32
32
  px_custom_first_party_captcha_endpoint: '',
33
+ px_first_party_timeout_ms: 4000,
33
34
  px_backend_url: '',
34
35
  px_backend_collector_url: '',
35
36
  px_backend_captcha_url: 'https://captcha.px-cdn.net',
@@ -5,7 +5,7 @@ var FormDataImpl = /** @class */ (function () {
5
5
  function FormDataImpl(data) {
6
6
  this.data = data !== null && data !== void 0 ? data : {};
7
7
  }
8
- FormDataImpl.prototype.append = function (name, value, fileName) {
8
+ FormDataImpl.prototype.append = function (name, value) {
9
9
  this.data[name] = (this.data[name] || []).concat(value);
10
10
  };
11
11
  FormDataImpl.prototype.delete = function (name) {
@@ -30,13 +30,10 @@ var FormDataImpl = /** @class */ (function () {
30
30
  FormDataImpl.prototype.has = function (name) {
31
31
  return this.get(name) !== null;
32
32
  };
33
- FormDataImpl.prototype.set = function (name, value, filename) {
33
+ FormDataImpl.prototype.set = function (name, value) {
34
34
  if (typeof value === 'string') {
35
35
  this.data[name] = [value];
36
36
  }
37
- else if (File) {
38
- this.data[name] = [new File([value], filename)];
39
- }
40
37
  };
41
38
  return FormDataImpl;
42
39
  }());
@@ -85,7 +85,7 @@ var FirstPartyPhase = /** @class */ (function () {
85
85
  _b.label = 1;
86
86
  case 1:
87
87
  _b.trys.push([1, 3, , 4]);
88
- return [4 /*yield*/, this.httpClient.send(request)];
88
+ return [4 /*yield*/, this.httpClient.send(request, { timeoutMs: this.config.firstPartyTimeoutMs })];
89
89
  case 2:
90
90
  response = _b.sent();
91
91
  return [2 /*return*/, http_1.MinimalResponseUtils.from(response)];
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CAPTCHA_TEMPLATE = void 0;
4
- exports.CAPTCHA_TEMPLATE = "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <meta name=\"description\" content=\"px-captcha\">\n <title>Access to this page has been denied</title>\n {{cssRef}}\n</head>\n<body>\n <script>\n /* PerimeterX assignments */\n window._pxVid = '{{vid}}';\n window._pxUuid = '{{uuid}}';\n window._pxAppId = '{{appId}}';\n window._pxMobile = {{isMobile}};\n window._pxHostUrl = '{{hostUrl}}';\n window._pxCustomLogo = '{{customLogo}}';\n window._pxJsClientSrc = '{{jsClientSrc}}';\n window._pxFirstPartyEnabled = {{firstPartyEnabled}};\n var pxCaptchaSrc = '{{blockScript}}';\n\n var script = document.createElement('script');\n script.src = pxCaptchaSrc;\n script.onerror = function () {\n script = document.createElement('script');\n script.src = '{{altBlockScript}}';\n script.onerror = window._pxOnError;\n document.head.appendChild(script);\n };\n window._pxOnError = function () {\n var style = document.createElement('style');\n style.innerText = '@import url(https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap);body{background-color:#fafbfc}.px-captcha-error-container{position:fixed;height:340px;background-color:#fff;font-family:Roboto,sans-serif}.px-captcha-error-header{color:#f0f1f2;font-size:29px;margin:67px 0 33px;font-weight:500;line-height:.83;text-align:center}.px-captcha-error-message{color:#f0f1f2;font-size:18px;margin:0 0 29px;line-height:1.33;text-align:center}.px-captcha-error-button{text-align:center;line-height:48px;width:253px;margin:auto;border-radius:50px;border:solid 1px #f0f1f2;font-size:20px;color:#f0f1f2}.px-captcha-error-wrapper{margin:18px 0 0}div.px-captcha-error{margin:auto;text-align:center;width:400px;height:30px;font-size:12px;background-color:#fcf0f2;color:#ce0e2d}img.px-captcha-error{margin:6px 8px -2px 0}.px-captcha-error-refid{border-top:solid 1px #f0eeee;height:27px;margin:13px 0 0;border-radius:0 0 3px 3px;background-color:#fafbfc;font-size:10px;line-height:2.5;text-align:center;color:#b1b5b8}@media (min-width:620px){.px-captcha-error-container{width:530px;top:50%;left:50%;margin-top:-170px;margin-left:-265px;border-radius:3px;box-shadow:0 2px 9px -1px rgba(0,0,0,.13)}}@media (min-width:481px) and (max-width:620px){.px-captcha-error-container{width:85%;top:50%;left:50%;margin-top:-170px;margin-left:-42.5%;border-radius:3px;box-shadow:0 2px 9px -1px rgba(0,0,0,.13)}}@media (max-width:480px){body{background-color:#fff}.px-captcha-error-header{color:#f0f1f2;font-size:29px;margin:55px 0 33px}.px-captcha-error-container{width:530px;top:50%;left:50%;margin-top:-170px;margin-left:-265px}.px-captcha-error-refid{position:fixed;width:100%;left:0;bottom:0;border-radius:0;font-size:14px;line-height:2}}@media (max-width:390px){div.px-captcha-error{font-size:10px}.px-captcha-error-refid{font-size:11px;line-height:2.5}}';\n document.head.appendChild(style);\n var div = document.createElement('div');\n div.className = 'px-captcha-error-container';\n div.innerHTML = '<div class=\"px-captcha-error-header\">Before we continue...</div><div class=\"px-captcha-error-message\">Press & Hold to confirm you are<br>a human (and not a bot).</div><div class=\"px-captcha-error-button\">Press & Hold</div><div class=\"px-captcha-error-wrapper\"><div class=\"px-captcha-error\"><img class=\"px-captcha-error\" src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAAQCAMAAADDGrRQAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAABFUExURUdwTNYELOEGONQILd0AONwALtwEL+AAL9MFLfkJSNQGLdMJLdQJLdQGLdQKLtYFLNcELdUGLdcBL9gFL88OLdUFLNEOLglBhT4AAAAXdFJOUwC8CqgNIRgRoAS1dWWuR4RTjzgryZpYblfkcAAAAI9JREFUGNNdj+sWhCAIhAdvqGVa1r7/oy6RZ7eaH3D4ZACBIed9wlOOMtUnSrEmZ6cHa9YAIfsbCkWrdpi/c50Bk2CO9mNLdMAu03wJA3HpEnfpxbyOg6ruyx8JJi6KNstnslp1dbPd9GnqmuYq7mmcv1zjnbQw8cV0xzkqo+fX1zkjUOO7wnrInUTxJiruC3vtBNRoQQn2AAAAAElFTkSuQmCC\">Please check your internet connection' + (window._pxMobile ? '' : ' or disable your ad-blocker') + '.</div></div><div class=\"px-captcha-error-refid\">Reference ID ' + window._pxUuid + '</div>';\n document.body.appendChild(div);\n if (window._pxMobile) {\n setTimeout(function() {\n location.href = '/px/captcha_close?status=-1';\n }, 5000);\n }\n };\n document.head.appendChild(script);\n </script>\n {{jsRef}}\n</body>\n</html>\n";
4
+ exports.CAPTCHA_TEMPLATE = "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <meta name=\"description\" content=\"px-captcha\">\n <title>Access to this page has been denied</title>\n {{cssRef}}\n</head>\n<body>\n<script>\n /* PerimeterX assignments */\n window._pxVid = '{{vid}}';\n window._pxUuid = '{{uuid}}';\n window._pxAppId = '{{appId}}';\n window._pxHostUrl = '{{hostUrl}}';\n window._pxCustomLogo = '{{customLogo}}';\n window._pxJsClientSrc = '{{jsClientSrc}}';\n window._pxMobile = {{isMobile}};\n window._pxFirstPartyEnabled = {{firstPartyEnabled}};\n var pxCaptchaSrc = '{{blockScript}}';\n var script = document.createElement('script');\n script.src = pxCaptchaSrc;\n script.onload = onScriptLoad;\n script.onerror = onScriptError;\n var onScriptErrorCalled;\n document.head.appendChild(script);\n var timeoutID = setTimeout(onScriptError, 5000);\n function onScriptLoad() {\n clearTimeout(timeoutID);\n setTimeout(function() {\n if (isCaptchaNotLoaded()) {\n onScriptError();\n }\n }, 1000);\n }\n function onScriptError() {\n if (onScriptErrorCalled) {\n return;\n }\n onScriptErrorCalled = true;\n script = document.createElement('script');\n script.src = '{{altBlockScript}}';\n script.onload = function() {\n clearTimeout(timeoutID);\n };\n script.onerror = window._pxOnError;\n document.head.appendChild(script);\n timeoutID = setTimeout(function() {\n if (isCaptchaNotLoaded()) {\n window._pxOnError();\n }\n }, 5000);\n }\n function isCaptchaNotLoaded() {\n return !document.querySelector('div');\n }\n window._pxOnError = function () {\n var style = document.createElement('style');\n style.innerText = '@import url(https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap);body{background-color:#fafbfc}.px-captcha-error-container{position:fixed;height:340px;background-color:#fff;font-family:Roboto,sans-serif}.px-captcha-error-header{color:#f0f1f2;font-size:29px;margin:67px 0 33px;font-weight:500;line-height:.83;text-align:center}.px-captcha-error-message{color:#f0f1f2;font-size:18px;margin:0 0 29px;line-height:1.33;text-align:center}.px-captcha-error-button{text-align:center;line-height:48px;width:253px;margin:auto;border-radius:50px;border:solid 1px #f0f1f2;font-size:20px;color:#f0f1f2}.px-captcha-error-wrapper{margin:18px 0 0}div.px-captcha-error{margin:auto;text-align:center;width:400px;height:30px;font-size:12px;background-color:#fcf0f2;color:#ce0e2d}img.px-captcha-error{margin:6px 8px -2px 0}.px-captcha-error-refid{border-top:solid 1px #f0eeee;height:27px;margin:13px 0 0;border-radius:0 0 3px 3px;background-color:#fafbfc;font-size:10px;line-height:2.5;text-align:center;color:#b1b5b8}@media (min-width:620px){.px-captcha-error-container{width:530px;top:50%;left:50%;margin-top:-170px;margin-left:-265px;border-radius:3px;box-shadow:0 2px 9px -1px rgba(0,0,0,.13)}}@media (min-width:481px) and (max-width:620px){.px-captcha-error-container{width:85%;top:50%;left:50%;margin-top:-170px;margin-left:-42.5%;border-radius:3px;box-shadow:0 2px 9px -1px rgba(0,0,0,.13)}}@media (max-width:480px){body{background-color:#fff}.px-captcha-error-header{color:#f0f1f2;font-size:29px;margin:55px 0 33px}.px-captcha-error-container{width:530px;top:50%;left:50%;margin-top:-170px;margin-left:-265px}.px-captcha-error-refid{position:fixed;width:100%;left:0;bottom:0;border-radius:0;font-size:14px;line-height:2}}@media (max-width:390px){div.px-captcha-error{font-size:10px}.px-captcha-error-refid{font-size:11px;line-height:2.5}}';\n document.head.appendChild(style);\n var div = document.createElement('div');\n div.className = 'px-captcha-error-container';\n div.innerHTML = '<div class=\"px-captcha-error-header\">Before we continue...</div><div class=\"px-captcha-error-message\">Press & Hold to confirm you are<br>a human (and not a bot).</div><div class=\"px-captcha-error-button\">Press & Hold</div><div class=\"px-captcha-error-wrapper\"><div class=\"px-captcha-error\"><img class=\"px-captcha-error\" src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAAQCAMAAADDGrRQAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAABFUExURUdwTNYELOEGONQILd0AONwALtwEL+AAL9MFLfkJSNQGLdMJLdQJLdQGLdQKLtYFLNcELdUGLdcBL9gFL88OLdUFLNEOLglBhT4AAAAXdFJOUwC8CqgNIRgRoAS1dWWuR4RTjzgryZpYblfkcAAAAI9JREFUGNNdj+sWhCAIhAdvqGVa1r7/oy6RZ7eaH3D4ZACBIed9wlOOMtUnSrEmZ6cHa9YAIfsbCkWrdpi/c50Bk2CO9mNLdMAu03wJA3HpEnfpxbyOg6ruyx8JJi6KNstnslp1dbPd9GnqmuYq7mmcv1zjnbQw8cV0xzkqo+fX1zkjUOO7wnrInUTxJiruC3vtBNRoQQn2AAAAAElFTkSuQmCC\">Please check your internet connection' + (window._pxMobile ? '' : ' or disable your ad-blocker') + '.</div></div><div class=\"px-captcha-error-refid\">Reference ID ' + window._pxUuid + '</div>';\n document.body.appendChild(div);\n if (window._pxMobile) {\n setTimeout(function() {\n location.href = '/px/captcha_close?status=-1';\n }, 5000);\n }\n };\n</script>\n{{jsRef}}\n</body>\n</html>\n";
@@ -13,4 +13,4 @@ exports.PUSH_DATA_HMAC_HEADER_NAME = 'x-px-pushdata';
13
13
  exports.PUSH_DATA_FEATURE_HEADER_NAME = 'x-px-feature';
14
14
  exports.EMAIL_ADDRESS_REGEX = /^[a-zA-Z0-9_+&*-]+(?:\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,7}$/;
15
15
  exports.URL_REGEX = /^(https?\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)([\/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/;
16
- exports.CORE_MODULE_VERSION = 'JS Core 0.12.0';
16
+ exports.CORE_MODULE_VERSION = 'JS Core 0.13.0';
@@ -124,6 +124,9 @@ export class ConfigurationBase {
124
124
  get customFirstPartyCaptchaEndpoint() {
125
125
  return this.configParams.px_custom_first_party_captcha_endpoint;
126
126
  }
127
+ get firstPartyTimeoutMs() {
128
+ return this.configParams.px_first_party_timeout_ms;
129
+ }
127
130
  get loggerSeverity() {
128
131
  return this.logger.getLoggerSeverity();
129
132
  }
@@ -27,6 +27,7 @@ export const DEFAULT_COMMON_CONFIGURATION_PARAMS = {
27
27
  px_custom_first_party_sensor_endpoint: '',
28
28
  px_custom_first_party_xhr_endpoint: '',
29
29
  px_custom_first_party_captcha_endpoint: '',
30
+ px_first_party_timeout_ms: 4000,
30
31
  px_backend_url: '',
31
32
  px_backend_collector_url: '',
32
33
  px_backend_captcha_url: 'https://captcha.px-cdn.net',
@@ -3,7 +3,7 @@ export class FormDataImpl {
3
3
  constructor(data) {
4
4
  this.data = data ?? {};
5
5
  }
6
- append(name, value, fileName) {
6
+ append(name, value) {
7
7
  this.data[name] = (this.data[name] || []).concat(value);
8
8
  }
9
9
  delete(name) {
@@ -25,12 +25,9 @@ export class FormDataImpl {
25
25
  has(name) {
26
26
  return this.get(name) !== null;
27
27
  }
28
- set(name, value, filename) {
28
+ set(name, value) {
29
29
  if (typeof value === 'string') {
30
30
  this.data[name] = [value];
31
31
  }
32
- else if (File) {
33
- this.data[name] = [new File([value], filename)];
34
- }
35
32
  }
36
33
  }
@@ -24,7 +24,7 @@ export class FirstPartyPhase {
24
24
  return defaultResponse;
25
25
  }
26
26
  try {
27
- const response = await this.httpClient.send(request);
27
+ const response = await this.httpClient.send(request, { timeoutMs: this.config.firstPartyTimeoutMs });
28
28
  return MinimalResponseUtils.from(response);
29
29
  }
30
30
  catch (e) {
@@ -8,43 +8,69 @@ export const CAPTCHA_TEMPLATE = `<!DOCTYPE html>
8
8
  {{cssRef}}
9
9
  </head>
10
10
  <body>
11
- <script>
12
- /* PerimeterX assignments */
13
- window._pxVid = '{{vid}}';
14
- window._pxUuid = '{{uuid}}';
15
- window._pxAppId = '{{appId}}';
16
- window._pxMobile = {{isMobile}};
17
- window._pxHostUrl = '{{hostUrl}}';
18
- window._pxCustomLogo = '{{customLogo}}';
19
- window._pxJsClientSrc = '{{jsClientSrc}}';
20
- window._pxFirstPartyEnabled = {{firstPartyEnabled}};
21
- var pxCaptchaSrc = '{{blockScript}}';
22
-
23
- var script = document.createElement('script');
24
- script.src = pxCaptchaSrc;
25
- script.onerror = function () {
26
- script = document.createElement('script');
27
- script.src = '{{altBlockScript}}';
28
- script.onerror = window._pxOnError;
29
- document.head.appendChild(script);
30
- };
31
- window._pxOnError = function () {
32
- var style = document.createElement('style');
33
- style.innerText = '@import url(https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap);body{background-color:#fafbfc}.px-captcha-error-container{position:fixed;height:340px;background-color:#fff;font-family:Roboto,sans-serif}.px-captcha-error-header{color:#f0f1f2;font-size:29px;margin:67px 0 33px;font-weight:500;line-height:.83;text-align:center}.px-captcha-error-message{color:#f0f1f2;font-size:18px;margin:0 0 29px;line-height:1.33;text-align:center}.px-captcha-error-button{text-align:center;line-height:48px;width:253px;margin:auto;border-radius:50px;border:solid 1px #f0f1f2;font-size:20px;color:#f0f1f2}.px-captcha-error-wrapper{margin:18px 0 0}div.px-captcha-error{margin:auto;text-align:center;width:400px;height:30px;font-size:12px;background-color:#fcf0f2;color:#ce0e2d}img.px-captcha-error{margin:6px 8px -2px 0}.px-captcha-error-refid{border-top:solid 1px #f0eeee;height:27px;margin:13px 0 0;border-radius:0 0 3px 3px;background-color:#fafbfc;font-size:10px;line-height:2.5;text-align:center;color:#b1b5b8}@media (min-width:620px){.px-captcha-error-container{width:530px;top:50%;left:50%;margin-top:-170px;margin-left:-265px;border-radius:3px;box-shadow:0 2px 9px -1px rgba(0,0,0,.13)}}@media (min-width:481px) and (max-width:620px){.px-captcha-error-container{width:85%;top:50%;left:50%;margin-top:-170px;margin-left:-42.5%;border-radius:3px;box-shadow:0 2px 9px -1px rgba(0,0,0,.13)}}@media (max-width:480px){body{background-color:#fff}.px-captcha-error-header{color:#f0f1f2;font-size:29px;margin:55px 0 33px}.px-captcha-error-container{width:530px;top:50%;left:50%;margin-top:-170px;margin-left:-265px}.px-captcha-error-refid{position:fixed;width:100%;left:0;bottom:0;border-radius:0;font-size:14px;line-height:2}}@media (max-width:390px){div.px-captcha-error{font-size:10px}.px-captcha-error-refid{font-size:11px;line-height:2.5}}';
34
- document.head.appendChild(style);
35
- var div = document.createElement('div');
36
- div.className = 'px-captcha-error-container';
37
- div.innerHTML = '<div class="px-captcha-error-header">Before we continue...</div><div class="px-captcha-error-message">Press & Hold to confirm you are<br>a human (and not a bot).</div><div class="px-captcha-error-button">Press & Hold</div><div class="px-captcha-error-wrapper"><div class="px-captcha-error"><img class="px-captcha-error" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAAQCAMAAADDGrRQAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAABFUExURUdwTNYELOEGONQILd0AONwALtwEL+AAL9MFLfkJSNQGLdMJLdQJLdQGLdQKLtYFLNcELdUGLdcBL9gFL88OLdUFLNEOLglBhT4AAAAXdFJOUwC8CqgNIRgRoAS1dWWuR4RTjzgryZpYblfkcAAAAI9JREFUGNNdj+sWhCAIhAdvqGVa1r7/oy6RZ7eaH3D4ZACBIed9wlOOMtUnSrEmZ6cHa9YAIfsbCkWrdpi/c50Bk2CO9mNLdMAu03wJA3HpEnfpxbyOg6ruyx8JJi6KNstnslp1dbPd9GnqmuYq7mmcv1zjnbQw8cV0xzkqo+fX1zkjUOO7wnrInUTxJiruC3vtBNRoQQn2AAAAAElFTkSuQmCC">Please check your internet connection' + (window._pxMobile ? '' : ' or disable your ad-blocker') + '.</div></div><div class="px-captcha-error-refid">Reference ID ' + window._pxUuid + '</div>';
38
- document.body.appendChild(div);
39
- if (window._pxMobile) {
40
- setTimeout(function() {
41
- location.href = '/px/captcha_close?status=-1';
42
- }, 5000);
11
+ <script>
12
+ /* PerimeterX assignments */
13
+ window._pxVid = '{{vid}}';
14
+ window._pxUuid = '{{uuid}}';
15
+ window._pxAppId = '{{appId}}';
16
+ window._pxHostUrl = '{{hostUrl}}';
17
+ window._pxCustomLogo = '{{customLogo}}';
18
+ window._pxJsClientSrc = '{{jsClientSrc}}';
19
+ window._pxMobile = {{isMobile}};
20
+ window._pxFirstPartyEnabled = {{firstPartyEnabled}};
21
+ var pxCaptchaSrc = '{{blockScript}}';
22
+ var script = document.createElement('script');
23
+ script.src = pxCaptchaSrc;
24
+ script.onload = onScriptLoad;
25
+ script.onerror = onScriptError;
26
+ var onScriptErrorCalled;
27
+ document.head.appendChild(script);
28
+ var timeoutID = setTimeout(onScriptError, 5000);
29
+ function onScriptLoad() {
30
+ clearTimeout(timeoutID);
31
+ setTimeout(function() {
32
+ if (isCaptchaNotLoaded()) {
33
+ onScriptError();
43
34
  }
35
+ }, 1000);
36
+ }
37
+ function onScriptError() {
38
+ if (onScriptErrorCalled) {
39
+ return;
40
+ }
41
+ onScriptErrorCalled = true;
42
+ script = document.createElement('script');
43
+ script.src = '{{altBlockScript}}';
44
+ script.onload = function() {
45
+ clearTimeout(timeoutID);
44
46
  };
47
+ script.onerror = window._pxOnError;
45
48
  document.head.appendChild(script);
46
- </script>
47
- {{jsRef}}
49
+ timeoutID = setTimeout(function() {
50
+ if (isCaptchaNotLoaded()) {
51
+ window._pxOnError();
52
+ }
53
+ }, 5000);
54
+ }
55
+ function isCaptchaNotLoaded() {
56
+ return !document.querySelector('div');
57
+ }
58
+ window._pxOnError = function () {
59
+ var style = document.createElement('style');
60
+ style.innerText = '@import url(https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap);body{background-color:#fafbfc}.px-captcha-error-container{position:fixed;height:340px;background-color:#fff;font-family:Roboto,sans-serif}.px-captcha-error-header{color:#f0f1f2;font-size:29px;margin:67px 0 33px;font-weight:500;line-height:.83;text-align:center}.px-captcha-error-message{color:#f0f1f2;font-size:18px;margin:0 0 29px;line-height:1.33;text-align:center}.px-captcha-error-button{text-align:center;line-height:48px;width:253px;margin:auto;border-radius:50px;border:solid 1px #f0f1f2;font-size:20px;color:#f0f1f2}.px-captcha-error-wrapper{margin:18px 0 0}div.px-captcha-error{margin:auto;text-align:center;width:400px;height:30px;font-size:12px;background-color:#fcf0f2;color:#ce0e2d}img.px-captcha-error{margin:6px 8px -2px 0}.px-captcha-error-refid{border-top:solid 1px #f0eeee;height:27px;margin:13px 0 0;border-radius:0 0 3px 3px;background-color:#fafbfc;font-size:10px;line-height:2.5;text-align:center;color:#b1b5b8}@media (min-width:620px){.px-captcha-error-container{width:530px;top:50%;left:50%;margin-top:-170px;margin-left:-265px;border-radius:3px;box-shadow:0 2px 9px -1px rgba(0,0,0,.13)}}@media (min-width:481px) and (max-width:620px){.px-captcha-error-container{width:85%;top:50%;left:50%;margin-top:-170px;margin-left:-42.5%;border-radius:3px;box-shadow:0 2px 9px -1px rgba(0,0,0,.13)}}@media (max-width:480px){body{background-color:#fff}.px-captcha-error-header{color:#f0f1f2;font-size:29px;margin:55px 0 33px}.px-captcha-error-container{width:530px;top:50%;left:50%;margin-top:-170px;margin-left:-265px}.px-captcha-error-refid{position:fixed;width:100%;left:0;bottom:0;border-radius:0;font-size:14px;line-height:2}}@media (max-width:390px){div.px-captcha-error{font-size:10px}.px-captcha-error-refid{font-size:11px;line-height:2.5}}';
61
+ document.head.appendChild(style);
62
+ var div = document.createElement('div');
63
+ div.className = 'px-captcha-error-container';
64
+ div.innerHTML = '<div class="px-captcha-error-header">Before we continue...</div><div class="px-captcha-error-message">Press & Hold to confirm you are<br>a human (and not a bot).</div><div class="px-captcha-error-button">Press & Hold</div><div class="px-captcha-error-wrapper"><div class="px-captcha-error"><img class="px-captcha-error" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAAQCAMAAADDGrRQAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAABFUExURUdwTNYELOEGONQILd0AONwALtwEL+AAL9MFLfkJSNQGLdMJLdQJLdQGLdQKLtYFLNcELdUGLdcBL9gFL88OLdUFLNEOLglBhT4AAAAXdFJOUwC8CqgNIRgRoAS1dWWuR4RTjzgryZpYblfkcAAAAI9JREFUGNNdj+sWhCAIhAdvqGVa1r7/oy6RZ7eaH3D4ZACBIed9wlOOMtUnSrEmZ6cHa9YAIfsbCkWrdpi/c50Bk2CO9mNLdMAu03wJA3HpEnfpxbyOg6ruyx8JJi6KNstnslp1dbPd9GnqmuYq7mmcv1zjnbQw8cV0xzkqo+fX1zkjUOO7wnrInUTxJiruC3vtBNRoQQn2AAAAAElFTkSuQmCC">Please check your internet connection' + (window._pxMobile ? '' : ' or disable your ad-blocker') + '.</div></div><div class="px-captcha-error-refid">Reference ID ' + window._pxUuid + '</div>';
65
+ document.body.appendChild(div);
66
+ if (window._pxMobile) {
67
+ setTimeout(function() {
68
+ location.href = '/px/captcha_close?status=-1';
69
+ }, 5000);
70
+ }
71
+ };
72
+ </script>
73
+ {{jsRef}}
48
74
  </body>
49
75
  </html>
50
76
  `;
@@ -10,4 +10,4 @@ export const PUSH_DATA_HMAC_HEADER_NAME = 'x-px-pushdata';
10
10
  export const PUSH_DATA_FEATURE_HEADER_NAME = 'x-px-feature';
11
11
  export const EMAIL_ADDRESS_REGEX = /^[a-zA-Z0-9_+&*-]+(?:\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,7}$/;
12
12
  export const URL_REGEX = /^(https?\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)([\/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/;
13
- export const CORE_MODULE_VERSION = 'JS Core 0.12.0';
13
+ export const CORE_MODULE_VERSION = 'JS Core 0.13.0';
@@ -37,6 +37,7 @@ export declare abstract class ConfigurationBase<Req, Res, ParamsType extends Con
37
37
  get customFirstPartySensorEndpoint(): string;
38
38
  get customFirstPartyXhrEndpoint(): string;
39
39
  get customFirstPartyCaptchaEndpoint(): string;
40
+ get firstPartyTimeoutMs(): number;
40
41
  get loggerSeverity(): LoggerSeverity;
41
42
  get moduleEnabled(): boolean;
42
43
  get moduleMode(): ModuleMode;
@@ -103,6 +103,10 @@ export interface IConfiguration<Req, Res, ParamsType extends ConfigurationParams
103
103
  * take precedence over if a custom first party prefix is configured.
104
104
  */
105
105
  readonly customFirstPartyXhrEndpoint: string;
106
+ /**
107
+ * The timeout for first party calls, in milliseconds.
108
+ */
109
+ readonly firstPartyTimeoutMs: number;
106
110
  /**
107
111
  * The customized endpoint to use for the captcha script. This will
108
112
  * take precedence over if a custom first party prefix is configured.
@@ -30,6 +30,7 @@ export type CommonConfigurationParams<Req, Res> = {
30
30
  px_custom_first_party_sensor_endpoint?: string;
31
31
  px_custom_first_party_xhr_endpoint?: string;
32
32
  px_custom_first_party_captcha_endpoint?: string;
33
+ px_first_party_timeout_ms?: number;
33
34
  px_backend_captcha_url?: string;
34
35
  px_backend_client_url?: string;
35
36
  px_backend_collector_url?: string;
@@ -1,9 +1,3 @@
1
1
  export interface IFormData {
2
- append(name: string, value: string | Blob, fileName?: string): void;
3
- delete(name: string): void;
4
- get(name: string): FormDataEntryValue | null;
5
- getAll(name: string): FormDataEntryValue[];
6
- has(name: string): boolean;
7
- set(name: string, value: string | Blob, fileName?: string): void;
8
- forEach(callbackfn: (value: FormDataEntryValue, key: string, parent: IFormData) => void, thisArg?: any): void;
2
+ get(name: string): string;
9
3
  }
@@ -1,12 +1,12 @@
1
1
  import { IFormData } from '../interfaces';
2
2
  export declare class FormDataImpl implements IFormData {
3
- protected data: Record<string, FormDataEntryValue[]>;
4
- constructor(data?: Record<string, FormDataEntryValue[]>);
5
- append(name: string, value: string, fileName?: string): void;
3
+ protected data: Record<string, string[]>;
4
+ constructor(data?: Record<string, string[]>);
5
+ append(name: string, value: string): void;
6
6
  delete(name: string): void;
7
- forEach(callbackfn: (value: string | FormDataEntryValue, key: string, parent: IFormData) => void, thisArg?: any): void;
8
- get(name: string): FormDataEntryValue | null;
9
- getAll(name: string): FormDataEntryValue[];
7
+ forEach(callbackfn: (value: string, key: string, parent: IFormData) => void, thisArg?: any): void;
8
+ get(name: string): string;
9
+ getAll(name: string): string[];
10
10
  has(name: string): boolean;
11
- set(name: string, value: string | Blob, filename?: string): void;
11
+ set(name: string, value: string): void;
12
12
  }
@@ -1 +1 @@
1
- export declare const CAPTCHA_TEMPLATE = "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <meta name=\"description\" content=\"px-captcha\">\n <title>Access to this page has been denied</title>\n {{cssRef}}\n</head>\n<body>\n <script>\n /* PerimeterX assignments */\n window._pxVid = '{{vid}}';\n window._pxUuid = '{{uuid}}';\n window._pxAppId = '{{appId}}';\n window._pxMobile = {{isMobile}};\n window._pxHostUrl = '{{hostUrl}}';\n window._pxCustomLogo = '{{customLogo}}';\n window._pxJsClientSrc = '{{jsClientSrc}}';\n window._pxFirstPartyEnabled = {{firstPartyEnabled}};\n var pxCaptchaSrc = '{{blockScript}}';\n\n var script = document.createElement('script');\n script.src = pxCaptchaSrc;\n script.onerror = function () {\n script = document.createElement('script');\n script.src = '{{altBlockScript}}';\n script.onerror = window._pxOnError;\n document.head.appendChild(script);\n };\n window._pxOnError = function () {\n var style = document.createElement('style');\n style.innerText = '@import url(https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap);body{background-color:#fafbfc}.px-captcha-error-container{position:fixed;height:340px;background-color:#fff;font-family:Roboto,sans-serif}.px-captcha-error-header{color:#f0f1f2;font-size:29px;margin:67px 0 33px;font-weight:500;line-height:.83;text-align:center}.px-captcha-error-message{color:#f0f1f2;font-size:18px;margin:0 0 29px;line-height:1.33;text-align:center}.px-captcha-error-button{text-align:center;line-height:48px;width:253px;margin:auto;border-radius:50px;border:solid 1px #f0f1f2;font-size:20px;color:#f0f1f2}.px-captcha-error-wrapper{margin:18px 0 0}div.px-captcha-error{margin:auto;text-align:center;width:400px;height:30px;font-size:12px;background-color:#fcf0f2;color:#ce0e2d}img.px-captcha-error{margin:6px 8px -2px 0}.px-captcha-error-refid{border-top:solid 1px #f0eeee;height:27px;margin:13px 0 0;border-radius:0 0 3px 3px;background-color:#fafbfc;font-size:10px;line-height:2.5;text-align:center;color:#b1b5b8}@media (min-width:620px){.px-captcha-error-container{width:530px;top:50%;left:50%;margin-top:-170px;margin-left:-265px;border-radius:3px;box-shadow:0 2px 9px -1px rgba(0,0,0,.13)}}@media (min-width:481px) and (max-width:620px){.px-captcha-error-container{width:85%;top:50%;left:50%;margin-top:-170px;margin-left:-42.5%;border-radius:3px;box-shadow:0 2px 9px -1px rgba(0,0,0,.13)}}@media (max-width:480px){body{background-color:#fff}.px-captcha-error-header{color:#f0f1f2;font-size:29px;margin:55px 0 33px}.px-captcha-error-container{width:530px;top:50%;left:50%;margin-top:-170px;margin-left:-265px}.px-captcha-error-refid{position:fixed;width:100%;left:0;bottom:0;border-radius:0;font-size:14px;line-height:2}}@media (max-width:390px){div.px-captcha-error{font-size:10px}.px-captcha-error-refid{font-size:11px;line-height:2.5}}';\n document.head.appendChild(style);\n var div = document.createElement('div');\n div.className = 'px-captcha-error-container';\n div.innerHTML = '<div class=\"px-captcha-error-header\">Before we continue...</div><div class=\"px-captcha-error-message\">Press & Hold to confirm you are<br>a human (and not a bot).</div><div class=\"px-captcha-error-button\">Press & Hold</div><div class=\"px-captcha-error-wrapper\"><div class=\"px-captcha-error\"><img class=\"px-captcha-error\" src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAAQCAMAAADDGrRQAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAABFUExURUdwTNYELOEGONQILd0AONwALtwEL+AAL9MFLfkJSNQGLdMJLdQJLdQGLdQKLtYFLNcELdUGLdcBL9gFL88OLdUFLNEOLglBhT4AAAAXdFJOUwC8CqgNIRgRoAS1dWWuR4RTjzgryZpYblfkcAAAAI9JREFUGNNdj+sWhCAIhAdvqGVa1r7/oy6RZ7eaH3D4ZACBIed9wlOOMtUnSrEmZ6cHa9YAIfsbCkWrdpi/c50Bk2CO9mNLdMAu03wJA3HpEnfpxbyOg6ruyx8JJi6KNstnslp1dbPd9GnqmuYq7mmcv1zjnbQw8cV0xzkqo+fX1zkjUOO7wnrInUTxJiruC3vtBNRoQQn2AAAAAElFTkSuQmCC\">Please check your internet connection' + (window._pxMobile ? '' : ' or disable your ad-blocker') + '.</div></div><div class=\"px-captcha-error-refid\">Reference ID ' + window._pxUuid + '</div>';\n document.body.appendChild(div);\n if (window._pxMobile) {\n setTimeout(function() {\n location.href = '/px/captcha_close?status=-1';\n }, 5000);\n }\n };\n document.head.appendChild(script);\n </script>\n {{jsRef}}\n</body>\n</html>\n";
1
+ export declare const CAPTCHA_TEMPLATE = "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n <meta name=\"description\" content=\"px-captcha\">\n <title>Access to this page has been denied</title>\n {{cssRef}}\n</head>\n<body>\n<script>\n /* PerimeterX assignments */\n window._pxVid = '{{vid}}';\n window._pxUuid = '{{uuid}}';\n window._pxAppId = '{{appId}}';\n window._pxHostUrl = '{{hostUrl}}';\n window._pxCustomLogo = '{{customLogo}}';\n window._pxJsClientSrc = '{{jsClientSrc}}';\n window._pxMobile = {{isMobile}};\n window._pxFirstPartyEnabled = {{firstPartyEnabled}};\n var pxCaptchaSrc = '{{blockScript}}';\n var script = document.createElement('script');\n script.src = pxCaptchaSrc;\n script.onload = onScriptLoad;\n script.onerror = onScriptError;\n var onScriptErrorCalled;\n document.head.appendChild(script);\n var timeoutID = setTimeout(onScriptError, 5000);\n function onScriptLoad() {\n clearTimeout(timeoutID);\n setTimeout(function() {\n if (isCaptchaNotLoaded()) {\n onScriptError();\n }\n }, 1000);\n }\n function onScriptError() {\n if (onScriptErrorCalled) {\n return;\n }\n onScriptErrorCalled = true;\n script = document.createElement('script');\n script.src = '{{altBlockScript}}';\n script.onload = function() {\n clearTimeout(timeoutID);\n };\n script.onerror = window._pxOnError;\n document.head.appendChild(script);\n timeoutID = setTimeout(function() {\n if (isCaptchaNotLoaded()) {\n window._pxOnError();\n }\n }, 5000);\n }\n function isCaptchaNotLoaded() {\n return !document.querySelector('div');\n }\n window._pxOnError = function () {\n var style = document.createElement('style');\n style.innerText = '@import url(https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap);body{background-color:#fafbfc}.px-captcha-error-container{position:fixed;height:340px;background-color:#fff;font-family:Roboto,sans-serif}.px-captcha-error-header{color:#f0f1f2;font-size:29px;margin:67px 0 33px;font-weight:500;line-height:.83;text-align:center}.px-captcha-error-message{color:#f0f1f2;font-size:18px;margin:0 0 29px;line-height:1.33;text-align:center}.px-captcha-error-button{text-align:center;line-height:48px;width:253px;margin:auto;border-radius:50px;border:solid 1px #f0f1f2;font-size:20px;color:#f0f1f2}.px-captcha-error-wrapper{margin:18px 0 0}div.px-captcha-error{margin:auto;text-align:center;width:400px;height:30px;font-size:12px;background-color:#fcf0f2;color:#ce0e2d}img.px-captcha-error{margin:6px 8px -2px 0}.px-captcha-error-refid{border-top:solid 1px #f0eeee;height:27px;margin:13px 0 0;border-radius:0 0 3px 3px;background-color:#fafbfc;font-size:10px;line-height:2.5;text-align:center;color:#b1b5b8}@media (min-width:620px){.px-captcha-error-container{width:530px;top:50%;left:50%;margin-top:-170px;margin-left:-265px;border-radius:3px;box-shadow:0 2px 9px -1px rgba(0,0,0,.13)}}@media (min-width:481px) and (max-width:620px){.px-captcha-error-container{width:85%;top:50%;left:50%;margin-top:-170px;margin-left:-42.5%;border-radius:3px;box-shadow:0 2px 9px -1px rgba(0,0,0,.13)}}@media (max-width:480px){body{background-color:#fff}.px-captcha-error-header{color:#f0f1f2;font-size:29px;margin:55px 0 33px}.px-captcha-error-container{width:530px;top:50%;left:50%;margin-top:-170px;margin-left:-265px}.px-captcha-error-refid{position:fixed;width:100%;left:0;bottom:0;border-radius:0;font-size:14px;line-height:2}}@media (max-width:390px){div.px-captcha-error{font-size:10px}.px-captcha-error-refid{font-size:11px;line-height:2.5}}';\n document.head.appendChild(style);\n var div = document.createElement('div');\n div.className = 'px-captcha-error-container';\n div.innerHTML = '<div class=\"px-captcha-error-header\">Before we continue...</div><div class=\"px-captcha-error-message\">Press & Hold to confirm you are<br>a human (and not a bot).</div><div class=\"px-captcha-error-button\">Press & Hold</div><div class=\"px-captcha-error-wrapper\"><div class=\"px-captcha-error\"><img class=\"px-captcha-error\" src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAAQCAMAAADDGrRQAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAABFUExURUdwTNYELOEGONQILd0AONwALtwEL+AAL9MFLfkJSNQGLdMJLdQJLdQGLdQKLtYFLNcELdUGLdcBL9gFL88OLdUFLNEOLglBhT4AAAAXdFJOUwC8CqgNIRgRoAS1dWWuR4RTjzgryZpYblfkcAAAAI9JREFUGNNdj+sWhCAIhAdvqGVa1r7/oy6RZ7eaH3D4ZACBIed9wlOOMtUnSrEmZ6cHa9YAIfsbCkWrdpi/c50Bk2CO9mNLdMAu03wJA3HpEnfpxbyOg6ruyx8JJi6KNstnslp1dbPd9GnqmuYq7mmcv1zjnbQw8cV0xzkqo+fX1zkjUOO7wnrInUTxJiruC3vtBNRoQQn2AAAAAElFTkSuQmCC\">Please check your internet connection' + (window._pxMobile ? '' : ' or disable your ad-blocker') + '.</div></div><div class=\"px-captcha-error-refid\">Reference ID ' + window._pxUuid + '</div>';\n document.body.appendChild(div);\n if (window._pxMobile) {\n setTimeout(function() {\n location.href = '/px/captcha_close?status=-1';\n }, 5000);\n }\n };\n</script>\n{{jsRef}}\n</body>\n</html>\n";
@@ -10,4 +10,4 @@ export declare const PUSH_DATA_HMAC_HEADER_NAME = "x-px-pushdata";
10
10
  export declare const PUSH_DATA_FEATURE_HEADER_NAME = "x-px-feature";
11
11
  export declare const EMAIL_ADDRESS_REGEX: RegExp;
12
12
  export declare const URL_REGEX: RegExp;
13
- export declare const CORE_MODULE_VERSION = "JS Core 0.12.0";
13
+ export declare const CORE_MODULE_VERSION = "JS Core 0.13.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "perimeterx-js-core",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "typesVersions": {