perimeterx-js-core 0.28.0 → 0.29.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.
- package/lib/cjs/activities/HttpActivityClient.js +1 -1
- package/lib/cjs/config/ConfigurationBase.js +9 -0
- package/lib/cjs/config/defaults/DefaultConfigurationParams.js +1 -0
- package/lib/cjs/config/remote_config/service_client/HttpRemoteConfigServiceClient.js +1 -1
- package/lib/cjs/logger/HttpLogServiceClient.js +1 -1
- package/lib/cjs/telemetry/DefaultTelemetry.js +1 -1
- package/lib/cjs/utils/constants.js +3 -2
- package/lib/esm/activities/HttpActivityClient.js +1 -1
- package/lib/esm/config/ConfigurationBase.js +6 -1
- package/lib/esm/config/defaults/DefaultConfigurationParams.js +2 -1
- package/lib/esm/config/remote_config/service_client/HttpRemoteConfigServiceClient.js +1 -1
- package/lib/esm/logger/HttpLogServiceClient.js +1 -1
- package/lib/esm/telemetry/DefaultTelemetry.js +1 -1
- package/lib/esm/utils/constants.js +2 -1
- package/lib/types/config/ConfigurationBase.d.ts +1 -0
- package/lib/types/config/IConfiguration.d.ts +4 -0
- package/lib/types/config/params/CoreConfigurationParams.d.ts +1 -0
- package/lib/types/utils/constants.d.ts +2 -1
- package/package.json +2 -2
|
@@ -188,7 +188,7 @@ var HttpActivityClient = /** @class */ (function () {
|
|
|
188
188
|
return "".concat(type, " activity");
|
|
189
189
|
}).join(', '), " to ").concat(url));
|
|
190
190
|
req = new http_1.OutgoingRequestImpl({ url: url, method: method, headers: headers, body: body });
|
|
191
|
-
return [4 /*yield*/, this.httpClient.send(req)];
|
|
191
|
+
return [4 /*yield*/, this.httpClient.send(req, { timeoutMs: this.config.asyncTimeout })];
|
|
192
192
|
case 1:
|
|
193
193
|
res = _b.sent();
|
|
194
194
|
return [2 /*return*/, (res === null || res === void 0 ? void 0 : res.status) === 200];
|
|
@@ -339,6 +339,15 @@ var ConfigurationBase = /** @class */ (function () {
|
|
|
339
339
|
enumerable: false,
|
|
340
340
|
configurable: true
|
|
341
341
|
});
|
|
342
|
+
Object.defineProperty(ConfigurationBase.prototype, "asyncTimeout", {
|
|
343
|
+
get: function () {
|
|
344
|
+
return this.configParams.px_async_timeout === utils_1.UNLIMITED_TIMEOUT
|
|
345
|
+
? undefined
|
|
346
|
+
: this.configParams.px_async_timeout;
|
|
347
|
+
},
|
|
348
|
+
enumerable: false,
|
|
349
|
+
configurable: true
|
|
350
|
+
});
|
|
342
351
|
Object.defineProperty(ConfigurationBase.prototype, "sensitiveHeaders", {
|
|
343
352
|
get: function () {
|
|
344
353
|
return this.configParams.px_sensitive_headers;
|
|
@@ -21,6 +21,7 @@ var defaultConfigurationParams = function () { return ({
|
|
|
21
21
|
px_graphql_routes_regex: [],
|
|
22
22
|
px_sensitive_routes_regex: [],
|
|
23
23
|
px_s2s_timeout: 1000,
|
|
24
|
+
px_async_timeout: utils_1.UNLIMITED_TIMEOUT,
|
|
24
25
|
px_blocking_score: 100,
|
|
25
26
|
px_user_agent_max_length: 8528,
|
|
26
27
|
px_risk_cookie_max_length: 2048,
|
|
@@ -51,7 +51,7 @@ var HttpRemoteConfigServiceClient = /** @class */ (function () {
|
|
|
51
51
|
switch (_a.label) {
|
|
52
52
|
case 0:
|
|
53
53
|
request = this.createFetchRemoteConfigRequest();
|
|
54
|
-
return [4 /*yield*/, this.httpClient.send(request)];
|
|
54
|
+
return [4 /*yield*/, this.httpClient.send(request, { timeoutMs: this.config.asyncTimeout })];
|
|
55
55
|
case 1:
|
|
56
56
|
response = _a.sent();
|
|
57
57
|
return [2 /*return*/, this.extractConfigFromResponse(response)];
|
|
@@ -120,7 +120,7 @@ var HttpLogServiceClient = /** @class */ (function () {
|
|
|
120
120
|
_a);
|
|
121
121
|
body = JSON.stringify(logRecords);
|
|
122
122
|
req = new http_1.OutgoingRequestImpl({ url: url, method: method, headers: headers, body: body });
|
|
123
|
-
return [4 /*yield*/, this.httpClient.send(req)];
|
|
123
|
+
return [4 /*yield*/, this.httpClient.send(req, { timeoutMs: this.config.asyncTimeout })];
|
|
124
124
|
case 1:
|
|
125
125
|
res = _b.sent();
|
|
126
126
|
return [2 /*return*/, (res === null || res === void 0 ? void 0 : res.status) === 200];
|
|
@@ -110,7 +110,7 @@ var DefaultTelemetry = /** @class */ (function () {
|
|
|
110
110
|
case 0:
|
|
111
111
|
telemetryRequest = this.createTelemetryRequest(context);
|
|
112
112
|
context.logger.debug("sending telemetry to ".concat(telemetryRequest.url));
|
|
113
|
-
return [4 /*yield*/, this.httpClient.send(telemetryRequest)];
|
|
113
|
+
return [4 /*yield*/, this.httpClient.send(telemetryRequest, { timeoutMs: this.config.asyncTimeout })];
|
|
114
114
|
case 1:
|
|
115
115
|
_a.sent();
|
|
116
116
|
return [2 /*return*/];
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CORE_MODULE_VERSION = exports.REGEX_STRUCTURE = exports.URL_REGEX = exports.EMAIL_ADDRESS_REGEX = exports.PUSH_DATA_FEATURE_HEADER_NAME = exports.PUSH_DATA_HMAC_HEADER_NAME = exports.X_PX_BYPASS_REASON_HEADER_NAME = exports.X_PX_ORIGINAL_TOKEN_HEADER_NAME = exports.X_PX_AUTHORIZATION_HEADER_NAME = exports.BYPASS_MONITOR_HEADER_VALUE = exports.CD_PXVID_COOKIE_NAME = exports.PXDE_COOKIE_NAME = exports.PXHD_COOKIE_NAME = exports.PXVID_COOKIE_NAME = void 0;
|
|
3
|
+
exports.CORE_MODULE_VERSION = exports.REGEX_STRUCTURE = exports.URL_REGEX = exports.EMAIL_ADDRESS_REGEX = exports.PUSH_DATA_FEATURE_HEADER_NAME = exports.PUSH_DATA_HMAC_HEADER_NAME = exports.X_PX_BYPASS_REASON_HEADER_NAME = exports.X_PX_ORIGINAL_TOKEN_HEADER_NAME = exports.X_PX_AUTHORIZATION_HEADER_NAME = exports.UNLIMITED_TIMEOUT = exports.BYPASS_MONITOR_HEADER_VALUE = exports.CD_PXVID_COOKIE_NAME = exports.PXDE_COOKIE_NAME = exports.PXHD_COOKIE_NAME = exports.PXVID_COOKIE_NAME = void 0;
|
|
4
4
|
exports.PXVID_COOKIE_NAME = '_pxvid';
|
|
5
5
|
exports.PXHD_COOKIE_NAME = '_pxhd';
|
|
6
6
|
exports.PXDE_COOKIE_NAME = '_pxde';
|
|
7
7
|
exports.CD_PXVID_COOKIE_NAME = '__pxvid';
|
|
8
8
|
exports.BYPASS_MONITOR_HEADER_VALUE = '1';
|
|
9
|
+
exports.UNLIMITED_TIMEOUT = 0;
|
|
9
10
|
exports.X_PX_AUTHORIZATION_HEADER_NAME = 'x-px-authorization';
|
|
10
11
|
exports.X_PX_ORIGINAL_TOKEN_HEADER_NAME = 'x-px-original-token';
|
|
11
12
|
exports.X_PX_BYPASS_REASON_HEADER_NAME = 'x-px-bypass-reason';
|
|
@@ -14,4 +15,4 @@ exports.PUSH_DATA_FEATURE_HEADER_NAME = 'x-px-feature';
|
|
|
14
15
|
exports.EMAIL_ADDRESS_REGEX = /^[a-zA-Z0-9_+&*-]+(?:\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,7}$/;
|
|
15
16
|
exports.URL_REGEX = /^(https?:)\/\/(([^@\s:\/]+):?([^@\s\/]*)@)?(([^:\/?#]*)(?:\:([0-9]+))?)(\/?[^?#]*)(\?[^#]*|)(#.*|)$/;
|
|
16
17
|
exports.REGEX_STRUCTURE = /^\/(.+?)\/([gimsuyvd]*)$/;
|
|
17
|
-
exports.CORE_MODULE_VERSION = 'JS Core 0.
|
|
18
|
+
exports.CORE_MODULE_VERSION = 'JS Core 0.29.0';
|
|
@@ -133,7 +133,7 @@ export class HttpActivityClient {
|
|
|
133
133
|
const body = activities.length === 1 ? JSON.stringify(activities[0]) : JSON.stringify(activities);
|
|
134
134
|
logger.debug(`sending ${activities.map(({ type }) => `${type} activity`).join(', ')} to ${url}`);
|
|
135
135
|
const req = new OutgoingRequestImpl({ url, method, headers, body });
|
|
136
|
-
const res = await this.httpClient.send(req);
|
|
136
|
+
const res = await this.httpClient.send(req, { timeoutMs: this.config.asyncTimeout });
|
|
137
137
|
return res?.status === 200;
|
|
138
138
|
}
|
|
139
139
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defaultConfigurationParams } from './defaults/index.js';
|
|
2
2
|
import { DefaultLogger, LoggerSeverity } from '../logger/index.js';
|
|
3
|
-
import { convertRegexStringToRegex, CORE_MODULE_VERSION, EnforcerConfigurationError, getCollectorDomain, getScoreApiDomain, isNullOrUndefined, isValidEnumValue, ModuleMode, } from '../utils/index.js';
|
|
3
|
+
import { convertRegexStringToRegex, CORE_MODULE_VERSION, EnforcerConfigurationError, getCollectorDomain, getScoreApiDomain, isNullOrUndefined, isValidEnumValue, ModuleMode, UNLIMITED_TIMEOUT, } from '../utils/index.js';
|
|
4
4
|
import { RemoteConfigUtils } from './remote_config/index.js';
|
|
5
5
|
import { TokenVersion } from '../risk_token/index.js';
|
|
6
6
|
/**
|
|
@@ -217,6 +217,11 @@ export class ConfigurationBase {
|
|
|
217
217
|
get s2sTimeout() {
|
|
218
218
|
return this.configParams.px_s2s_timeout;
|
|
219
219
|
}
|
|
220
|
+
get asyncTimeout() {
|
|
221
|
+
return this.configParams.px_async_timeout === UNLIMITED_TIMEOUT
|
|
222
|
+
? undefined
|
|
223
|
+
: this.configParams.px_async_timeout;
|
|
224
|
+
}
|
|
220
225
|
get sensitiveHeaders() {
|
|
221
226
|
return this.configParams.px_sensitive_headers;
|
|
222
227
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LoggerSeverity } from '../../logger/index.js';
|
|
2
|
-
import { ModuleMode } from '../../utils/index.js';
|
|
2
|
+
import { ModuleMode, UNLIMITED_TIMEOUT } from '../../utils/index.js';
|
|
3
3
|
import { CredentialIntelligenceVersion, DEFAULT_COMPROMISED_CREDENTIALS_HEADER_NAME, LoginSuccessfulReportingMethod, } from '../../products/index.js';
|
|
4
4
|
import { TokenVersion } from '../../risk_token/index.js';
|
|
5
5
|
export const defaultConfigurationParams = () => ({
|
|
@@ -18,6 +18,7 @@ export const defaultConfigurationParams = () => ({
|
|
|
18
18
|
px_graphql_routes_regex: [],
|
|
19
19
|
px_sensitive_routes_regex: [],
|
|
20
20
|
px_s2s_timeout: 1000,
|
|
21
|
+
px_async_timeout: UNLIMITED_TIMEOUT,
|
|
21
22
|
px_blocking_score: 100,
|
|
22
23
|
px_user_agent_max_length: 8528,
|
|
23
24
|
px_risk_cookie_max_length: 2048,
|
|
@@ -9,7 +9,7 @@ export class HttpRemoteConfigServiceClient {
|
|
|
9
9
|
}
|
|
10
10
|
async fetch(_updateRequestData) {
|
|
11
11
|
const request = this.createFetchRemoteConfigRequest();
|
|
12
|
-
const response = await this.httpClient.send(request);
|
|
12
|
+
const response = await this.httpClient.send(request, { timeoutMs: this.config.asyncTimeout });
|
|
13
13
|
return this.extractConfigFromResponse(response);
|
|
14
14
|
}
|
|
15
15
|
createFetchRemoteConfigRequest() {
|
|
@@ -51,7 +51,7 @@ export class HttpLogServiceClient {
|
|
|
51
51
|
};
|
|
52
52
|
const body = JSON.stringify(logRecords);
|
|
53
53
|
const req = new OutgoingRequestImpl({ url, method, headers, body });
|
|
54
|
-
const res = await this.httpClient.send(req);
|
|
54
|
+
const res = await this.httpClient.send(req, { timeoutMs: this.config.asyncTimeout });
|
|
55
55
|
return res?.status === 200;
|
|
56
56
|
}
|
|
57
57
|
}
|
|
@@ -39,7 +39,7 @@ export class DefaultTelemetry {
|
|
|
39
39
|
async sendTelemetryActivity(context) {
|
|
40
40
|
const telemetryRequest = this.createTelemetryRequest(context);
|
|
41
41
|
context.logger.debug(`sending telemetry to ${telemetryRequest.url}`);
|
|
42
|
-
await this.httpClient.send(telemetryRequest);
|
|
42
|
+
await this.httpClient.send(telemetryRequest, { timeoutMs: this.config.asyncTimeout });
|
|
43
43
|
}
|
|
44
44
|
createTelemetryRequest(context) {
|
|
45
45
|
const url = `${this.config.backendScoreApiUrl}${TELEMETRY_ENDPOINT}`;
|
|
@@ -3,6 +3,7 @@ export const PXHD_COOKIE_NAME = '_pxhd';
|
|
|
3
3
|
export const PXDE_COOKIE_NAME = '_pxde';
|
|
4
4
|
export const CD_PXVID_COOKIE_NAME = '__pxvid';
|
|
5
5
|
export const BYPASS_MONITOR_HEADER_VALUE = '1';
|
|
6
|
+
export const UNLIMITED_TIMEOUT = 0;
|
|
6
7
|
export const X_PX_AUTHORIZATION_HEADER_NAME = 'x-px-authorization';
|
|
7
8
|
export const X_PX_ORIGINAL_TOKEN_HEADER_NAME = 'x-px-original-token';
|
|
8
9
|
export const X_PX_BYPASS_REASON_HEADER_NAME = 'x-px-bypass-reason';
|
|
@@ -11,4 +12,4 @@ export const PUSH_DATA_FEATURE_HEADER_NAME = 'x-px-feature';
|
|
|
11
12
|
export const EMAIL_ADDRESS_REGEX = /^[a-zA-Z0-9_+&*-]+(?:\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,7}$/;
|
|
12
13
|
export const URL_REGEX = /^(https?:)\/\/(([^@\s:\/]+):?([^@\s\/]*)@)?(([^:\/?#]*)(?:\:([0-9]+))?)(\/?[^?#]*)(\?[^#]*|)(#.*|)$/;
|
|
13
14
|
export const REGEX_STRUCTURE = /^\/(.+?)\/([gimsuyvd]*)$/;
|
|
14
|
-
export const CORE_MODULE_VERSION = 'JS Core 0.
|
|
15
|
+
export const CORE_MODULE_VERSION = 'JS Core 0.29.0';
|
|
@@ -81,6 +81,7 @@ export declare abstract class ConfigurationBase<Req, Res, Added, Removed extends
|
|
|
81
81
|
get monitoredRoutes(): Array<string | RegExp>;
|
|
82
82
|
get customIsMonitoredRequest(): CustomRequestFunction<Req> | null;
|
|
83
83
|
get s2sTimeout(): number;
|
|
84
|
+
get asyncTimeout(): number | undefined;
|
|
84
85
|
get sensitiveHeaders(): string[];
|
|
85
86
|
get sensitiveRoutes(): Array<string | RegExp>;
|
|
86
87
|
get customIsSensitiveRequest(): CustomRequestFunction<Req> | null;
|
|
@@ -31,6 +31,10 @@ export interface IConfiguration<Req, Res, Added, Removed> {
|
|
|
31
31
|
* The timeout for risk API calls, in milliseconds.
|
|
32
32
|
*/
|
|
33
33
|
readonly s2sTimeout: number;
|
|
34
|
+
/**
|
|
35
|
+
* The timeout for async HTTP requests, in milliseconds. A value of undefined means an unlimited timeout.
|
|
36
|
+
*/
|
|
37
|
+
readonly asyncTimeout: number | undefined;
|
|
34
38
|
/**
|
|
35
39
|
* An interface used to log enforcer debug and error messages.
|
|
36
40
|
*/
|
|
@@ -59,6 +59,7 @@ export type SnippetInjectionParamsOnly<Req, Res, Added, Removed> = {
|
|
|
59
59
|
*/
|
|
60
60
|
export type CommonConfigurationParams<Req, Res, Added, Removed> = TokenV3ConfigurationParamsOnly & BatchedActivitiesConfigParamsOnly & SnippetInjectionParamsOnly<Req, Res, Added, Removed> & {
|
|
61
61
|
px_s2s_timeout?: number;
|
|
62
|
+
px_async_timeout?: number;
|
|
62
63
|
px_backend_url?: string;
|
|
63
64
|
px_user_agent_max_length?: number;
|
|
64
65
|
px_logger_severity?: `${LoggerSeverity}`;
|
|
@@ -3,6 +3,7 @@ export declare const PXHD_COOKIE_NAME = "_pxhd";
|
|
|
3
3
|
export declare const PXDE_COOKIE_NAME = "_pxde";
|
|
4
4
|
export declare const CD_PXVID_COOKIE_NAME = "__pxvid";
|
|
5
5
|
export declare const BYPASS_MONITOR_HEADER_VALUE = "1";
|
|
6
|
+
export declare const UNLIMITED_TIMEOUT = 0;
|
|
6
7
|
export declare const X_PX_AUTHORIZATION_HEADER_NAME = "x-px-authorization";
|
|
7
8
|
export declare const X_PX_ORIGINAL_TOKEN_HEADER_NAME = "x-px-original-token";
|
|
8
9
|
export declare const X_PX_BYPASS_REASON_HEADER_NAME = "x-px-bypass-reason";
|
|
@@ -11,4 +12,4 @@ export declare const PUSH_DATA_FEATURE_HEADER_NAME = "x-px-feature";
|
|
|
11
12
|
export declare const EMAIL_ADDRESS_REGEX: RegExp;
|
|
12
13
|
export declare const URL_REGEX: RegExp;
|
|
13
14
|
export declare const REGEX_STRUCTURE: RegExp;
|
|
14
|
-
export declare const CORE_MODULE_VERSION = "JS Core 0.
|
|
15
|
+
export declare const CORE_MODULE_VERSION = "JS Core 0.29.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "perimeterx-js-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"typesVersions": {
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"eslint-plugin-prettier": "^5.2.3",
|
|
69
69
|
"husky": "^9.1.7",
|
|
70
70
|
"lint-staged": "^16.0.0",
|
|
71
|
-
"mocha": "^
|
|
71
|
+
"mocha": "^11.4.0",
|
|
72
72
|
"nyc": "^17.0.0",
|
|
73
73
|
"prettier": "^3.5.3",
|
|
74
74
|
"sinon": "^20.0.0",
|