perimeterx-js-core 0.27.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.
Files changed (92) hide show
  1. package/lib/cjs/activities/HttpActivityClient.js +3 -3
  2. package/lib/cjs/activities/HttpBatchedActivityClient.js +2 -2
  3. package/lib/cjs/additional_activity_handler/AdditionalActivityHandlerUtils.js +2 -2
  4. package/lib/cjs/config/ConfigurationBase.js +29 -5
  5. package/lib/cjs/config/defaults/DefaultConfigurationParams.js +1 -0
  6. package/lib/cjs/config/remote_config/manager/DefaultRemoteConfigManager.js +2 -2
  7. package/lib/cjs/config/remote_config/service_client/HttpRemoteConfigServiceClient.js +3 -3
  8. package/lib/cjs/config/remote_config/update_parser/DefaultNotifyRemoteConfigUpdateParser.js +2 -2
  9. package/lib/cjs/cors/DefaultCors.js +2 -2
  10. package/lib/cjs/custom_parameters/CustomParametersUtils.js +2 -2
  11. package/lib/cjs/enforcer/EnforcerBase.js +2 -2
  12. package/lib/cjs/flow/Flow.js +10 -6
  13. package/lib/cjs/graphql/DefaultGraphQLParser.js +7 -3
  14. package/lib/cjs/impl/cipher/CryptoCipherUtils.js +19 -9
  15. package/lib/cjs/impl/cipher/CryptoJsCipherUtils.js +2 -2
  16. package/lib/cjs/impl/cipher/SubtleCryptoCipherUtils.js +2 -2
  17. package/lib/cjs/impl/hash/CryptoHashUtils.js +19 -9
  18. package/lib/cjs/impl/hash/SubtleCryptoHashUtils.js +2 -2
  19. package/lib/cjs/impl/hmac/CryptoHmacUtils.js +17 -7
  20. package/lib/cjs/impl/hmac/SubtleCryptoHmacUtils.js +2 -2
  21. package/lib/cjs/impl/http/phin/PhinHttpClient.js +2 -2
  22. package/lib/cjs/impl/http/phin/PhinIncomingResponse.js +2 -2
  23. package/lib/cjs/logger/HttpLogServiceClient.js +3 -3
  24. package/lib/cjs/monitored_request/MonitoredRequestUtils.js +2 -2
  25. package/lib/cjs/phase/impl/AdditionalActivityHandlerPhase.js +2 -2
  26. package/lib/cjs/phase/impl/ClearLogsPhase.js +2 -2
  27. package/lib/cjs/phase/impl/CompositePhase.js +2 -2
  28. package/lib/cjs/phase/impl/CreateBlockResponsePhase.js +2 -2
  29. package/lib/cjs/phase/impl/DecideActionPhase.js +2 -2
  30. package/lib/cjs/phase/impl/EnrichContextFromRequestPhase.js +2 -2
  31. package/lib/cjs/phase/impl/EnrichContextFromResponsePhase.js +2 -2
  32. package/lib/cjs/phase/impl/FilterPhase.js +2 -2
  33. package/lib/cjs/phase/impl/FirstPartyPhase.js +2 -2
  34. package/lib/cjs/phase/impl/IdentifyRemoteConfigNotifyRequestPhase.js +2 -2
  35. package/lib/cjs/phase/impl/IdentifyTelemetryRequestPhase.js +2 -2
  36. package/lib/cjs/phase/impl/ModifyIncomingRequestPhase.js +2 -2
  37. package/lib/cjs/phase/impl/ModifyOutgoingResponsePhase.js +2 -2
  38. package/lib/cjs/phase/impl/ParseTokenPhase.js +2 -2
  39. package/lib/cjs/phase/impl/PreflightPhase.js +2 -2
  40. package/lib/cjs/phase/impl/RiskApiPhase.js +2 -2
  41. package/lib/cjs/phase/impl/SendAsyncActivitiesPhase.js +2 -2
  42. package/lib/cjs/phase/impl/SendLogsPhase.js +2 -2
  43. package/lib/cjs/phase/impl/SendTelemetryActivityPhase.js +2 -2
  44. package/lib/cjs/phase/impl/UpdateRemoteConfigPhase.js +2 -2
  45. package/lib/cjs/products/account_defender/AccountDefender.js +2 -2
  46. package/lib/cjs/products/bot_defender/BotDefender.js +2 -2
  47. package/lib/cjs/products/bot_defender/filter/DefaultBotDefenderFilter.js +2 -2
  48. package/lib/cjs/products/bot_defender/first_party/DefaultBotDefenderFirstParty.js +2 -2
  49. package/lib/cjs/products/credential_intelligence/CredentialIntelligence.js +2 -2
  50. package/lib/cjs/products/credential_intelligence/endpoint/CredentialEndpoint.js +2 -2
  51. package/lib/cjs/products/credential_intelligence/endpoint/CredentialEndpointManager.js +2 -2
  52. package/lib/cjs/products/credential_intelligence/endpoint/extractor/BodyCredentialExtractor.js +2 -2
  53. package/lib/cjs/products/credential_intelligence/endpoint/extractor/CustomCredentialExtractor.js +2 -2
  54. package/lib/cjs/products/credential_intelligence/endpoint/extractor/QueryParamCredentialExtractor.js +2 -2
  55. package/lib/cjs/products/credential_intelligence/endpoint/hash_protocol/MultistepHashProtocol.js +2 -2
  56. package/lib/cjs/products/credential_intelligence/endpoint/hash_protocol/SingleStepAndMultistepHashProtocol.js +2 -2
  57. package/lib/cjs/products/credential_intelligence/endpoint/hash_protocol/SingleStepHashProtocol.js +2 -2
  58. package/lib/cjs/products/credential_intelligence/endpoint/login_successful/BodyLoginSuccessfulParser.js +2 -2
  59. package/lib/cjs/products/credential_intelligence/endpoint/login_successful/CustomLoginSuccessfulParser.js +2 -2
  60. package/lib/cjs/products/credential_intelligence/endpoint/login_successful/HeaderLoginSuccessfulParser.js +2 -2
  61. package/lib/cjs/products/credential_intelligence/endpoint/login_successful/StatusLoginSuccessfulParser.js +2 -2
  62. package/lib/cjs/pxde/DefaultDataEnrichment.js +2 -2
  63. package/lib/cjs/risk_api/client/abstract/RiskApiClientBase.js +2 -2
  64. package/lib/cjs/risk_api/risk_response/PostRiskResponseBase.js +2 -2
  65. package/lib/cjs/risk_api/risk_response/RiskResponseBase.js +2 -2
  66. package/lib/cjs/risk_token/parser/TokenParserBase.js +2 -2
  67. package/lib/cjs/risk_token/token/TokenBase.js +2 -2
  68. package/lib/cjs/risk_token/token/v2/DefaultTokenV2.js +2 -2
  69. package/lib/cjs/risk_token/token/v3/DefaultTokenV3.js +2 -2
  70. package/lib/cjs/sensitive_request/SensitiveRequestUtils.js +2 -2
  71. package/lib/cjs/snippet_injection/snippet_retriever/DefaultSnippetRetriever.js +2 -2
  72. package/lib/cjs/telemetry/DefaultTelemetry.js +3 -3
  73. package/lib/cjs/utils/WaitsUntil.js +2 -2
  74. package/lib/cjs/utils/constants.js +3 -2
  75. package/lib/cjs/utils/timestamp_hmac_header_validator/DefaultTimestampHmacHeaderValidator.js +2 -2
  76. package/lib/cjs/utils/utils.js +2 -2
  77. package/lib/esm/activities/HttpActivityClient.js +1 -1
  78. package/lib/esm/config/ConfigurationBase.js +26 -5
  79. package/lib/esm/config/defaults/DefaultConfigurationParams.js +2 -1
  80. package/lib/esm/config/remote_config/service_client/HttpRemoteConfigServiceClient.js +1 -1
  81. package/lib/esm/flow/Flow.js +10 -6
  82. package/lib/esm/graphql/DefaultGraphQLParser.js +5 -1
  83. package/lib/esm/logger/HttpLogServiceClient.js +1 -1
  84. package/lib/esm/telemetry/DefaultTelemetry.js +1 -1
  85. package/lib/esm/utils/constants.js +2 -1
  86. package/lib/types/config/ConfigurationBase.d.ts +2 -0
  87. package/lib/types/config/IConfiguration.d.ts +4 -0
  88. package/lib/types/config/params/CoreConfigurationParams.d.ts +2 -1
  89. package/lib/types/flow/Flow.d.ts +4 -4
  90. package/lib/types/flow/IFlow.d.ts +8 -4
  91. package/lib/types/utils/constants.d.ts +2 -1
  92. package/package.json +5 -4
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
@@ -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 { 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
  /**
@@ -46,9 +46,8 @@ export class ConfigurationBase {
46
46
  });
47
47
  }
48
48
  getValidConfigValue(params, defaultParams, key) {
49
- const paramsValue = params[key];
50
- if (!isNullOrUndefined(paramsValue) && this.isValidConfigValue(params, defaultParams, key)) {
51
- return paramsValue;
49
+ if (!isNullOrUndefined(params[key]) && this.isValidConfigValue(params, defaultParams, key)) {
50
+ return this.normalizeConfigurationValue(params, key);
52
51
  }
53
52
  else {
54
53
  return this.getDefaultConfigurationValue(params, defaultParams, key);
@@ -84,6 +83,23 @@ export class ConfigurationBase {
84
83
  return defaultParams[key];
85
84
  }
86
85
  }
86
+ normalizeConfigurationValue(params, key) {
87
+ switch (key) {
88
+ case 'px_filter_by_extension':
89
+ return params[key].map((ext) => (ext.startsWith('.') ? ext : `.${ext}`));
90
+ case 'px_sensitive_routes':
91
+ case 'px_monitored_routes':
92
+ case 'px_enforced_routes':
93
+ case 'px_graphql_routes':
94
+ case 'px_filter_by_route':
95
+ case 'px_filter_by_user_agent':
96
+ case 'px_graphql_keywords':
97
+ case 'px_sensitive_graphql_operation_names':
98
+ return params[key].map((pattern) => typeof pattern === 'string' ? (convertRegexStringToRegex(pattern) ?? pattern) : pattern);
99
+ default:
100
+ return params[key];
101
+ }
102
+ }
87
103
  createInternalLogger(params) {
88
104
  return new DefaultLogger(params.px_logger_severity, false, this.logger?.getLogs());
89
105
  }
@@ -148,7 +164,7 @@ export class ConfigurationBase {
148
164
  return this.configParams.px_custom_is_enforced_request;
149
165
  }
150
166
  get filteredExtensions() {
151
- return this.configParams.px_filter_by_extension?.map((ext) => (ext.startsWith('.') ? ext : `.${ext}`));
167
+ return this.configParams.px_filter_by_extension;
152
168
  }
153
169
  get filteredHttpMethods() {
154
170
  return this.configParams.px_filter_by_http_method;
@@ -201,6 +217,11 @@ export class ConfigurationBase {
201
217
  get s2sTimeout() {
202
218
  return this.configParams.px_s2s_timeout;
203
219
  }
220
+ get asyncTimeout() {
221
+ return this.configParams.px_async_timeout === UNLIMITED_TIMEOUT
222
+ ? undefined
223
+ : this.configParams.px_async_timeout;
224
+ }
204
225
  get sensitiveHeaders() {
205
226
  return this.configParams.px_sensitive_headers;
206
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() {
@@ -7,45 +7,49 @@ export class Flow {
7
7
  insert(phase, options) {
8
8
  if (!options) {
9
9
  this.phases.push(phase);
10
- return;
10
+ return this;
11
11
  }
12
12
  if (options.before) {
13
13
  const index = this.getIndexOfPhase(options.before);
14
14
  if (index === -1) {
15
- return;
15
+ return this;
16
16
  }
17
17
  this.phases.splice(index, 0, phase);
18
18
  }
19
19
  if (options.after) {
20
20
  const index = this.getIndexOfPhase(options.after);
21
21
  if (index === -1) {
22
- return;
22
+ return this;
23
23
  }
24
24
  this.phases.splice(index + 1, 0, phase);
25
25
  }
26
+ return this;
26
27
  }
27
28
  remove(name) {
28
29
  const index = this.getIndexOfPhase(name);
29
30
  if (index === -1) {
30
- return;
31
+ return this;
31
32
  }
32
33
  this.phases.splice(index, 1);
34
+ return this;
33
35
  }
34
36
  replace(name, phase) {
35
37
  const index = this.getIndexOfPhase(name);
36
38
  if (index === -1) {
37
- return;
39
+ return this;
38
40
  }
39
41
  this.phases.splice(index, 1, phase);
42
+ return this;
40
43
  }
41
44
  move(name, to) {
42
45
  const index = this.getIndexOfPhase(name);
43
46
  if (index === -1) {
44
- return;
47
+ return this;
45
48
  }
46
49
  const phase = this.phases[index];
47
50
  this.phases.splice(index, 1);
48
51
  this.insert(phase, to);
52
+ return this;
49
53
  }
50
54
  getIndexOfPhase(name) {
51
55
  return this.phases.findIndex((existingPhase) => existingPhase.constructor.name === name);
@@ -147,11 +147,15 @@ export class DefaultGraphQLParser {
147
147
  }
148
148
  }
149
149
  getQueryKeywordsFromArray(query, context) {
150
+ if (!query) {
151
+ context.logger.debug(`empty query, unable to extract graphql keywords`);
152
+ return [];
153
+ }
150
154
  let keywords = [];
151
155
  try {
152
156
  this.config.graphqlKeywords.forEach((keyword) => {
153
157
  const pattern = this.toGlobalRegExp(keyword);
154
- let matchGroup = query?.match(pattern);
158
+ let matchGroup = query.match(pattern);
155
159
  if (!matchGroup) {
156
160
  return;
157
161
  }
@@ -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.27.0';
15
+ export const CORE_MODULE_VERSION = 'JS Core 0.29.0';
@@ -46,6 +46,7 @@ export declare abstract class ConfigurationBase<Req, Res, Added, Removed extends
46
46
  protected getValidConfigValue<K extends keyof RequiredAllConfigurationParams<Req, Res, Added, Removed>, V extends RequiredAllConfigurationParams<Req, Res, Added, Removed>[K]>(params: AllConfigurationParams<Req, Res, Added, Removed>, defaultParams: RequiredAllConfigurationParams<Req, Res, Added, Removed>, key: K): V;
47
47
  protected isValidConfigValue(params: AllConfigurationParams<Req, Res, Added, Removed>, defaultParams: RequiredAllConfigurationParams<Req, Res, Added, Removed>, key: keyof RequiredAllConfigurationParams<Req, Res, Added, Removed>): boolean;
48
48
  protected getDefaultConfigurationValue<K extends keyof RequiredAllConfigurationParams<Req, Res, Added, Removed>, V extends RequiredAllConfigurationParams<Req, Res, Added, Removed>[K]>(params: AllConfigurationParams<Req, Res, Added, Removed>, defaultParams: RequiredAllConfigurationParams<Req, Res, Added, Removed>, key: K): V;
49
+ protected normalizeConfigurationValue<K extends keyof RequiredAllConfigurationParams<Req, Res, Added, Removed>, V extends RequiredAllConfigurationParams<Req, Res, Added, Removed>[K]>(params: AllConfigurationParams<Req, Res, Added, Removed>, key: K): V;
49
50
  protected createInternalLogger(params: RequiredAllConfigurationParams<Req, Res, Added, Removed>): ILogger;
50
51
  setRemoteConfigData(remoteConfigData: RemoteConfigData<Req, Res, Added, Removed>): void;
51
52
  getActiveConfig(): ActiveConfigurationParams<Req, Res, Added, Removed>;
@@ -80,6 +81,7 @@ export declare abstract class ConfigurationBase<Req, Res, Added, Removed extends
80
81
  get monitoredRoutes(): Array<string | RegExp>;
81
82
  get customIsMonitoredRequest(): CustomRequestFunction<Req> | null;
82
83
  get s2sTimeout(): number;
84
+ get asyncTimeout(): number | undefined;
83
85
  get sensitiveHeaders(): string[];
84
86
  get sensitiveRoutes(): Array<string | RegExp>;
85
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
  */
@@ -9,7 +9,7 @@ import { CustomRequestFunction } from '../CustomRequestFunction';
9
9
  import { TokenVersion } from '../../risk_token';
10
10
  import { CustomSnippetFunction } from '../../snippet_injection';
11
11
  /**
12
- * The configuration parameters that can be set only via the static configuration..
12
+ * The configuration parameters that can be set only via the static configuration.
13
13
  */
14
14
  export type StaticConfigurationParamsOnly = {
15
15
  px_app_id: string;
@@ -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}`;
@@ -4,10 +4,10 @@ import { IFlow, InsertPhaseOptions } from './IFlow';
4
4
  export declare class Flow<Req, Res> implements IFlow<Req, Res> {
5
5
  readonly phases: IPhase<Req, Res>[];
6
6
  constructor(phases: IPhase<Req, Res>[]);
7
- insert(phase: IPhase<Req, Res>, options?: InsertPhaseOptions): void;
8
- remove(name: string): void;
9
- replace(name: string, phase: IPhase<Req, Res>): void;
10
- move(name: string, to: InsertPhaseOptions): void;
7
+ insert(phase: IPhase<Req, Res>, options?: InsertPhaseOptions): IFlow<Req, Res>;
8
+ remove(name: string): IFlow<Req, Res>;
9
+ replace(name: string, phase: IPhase<Req, Res>): IFlow<Req, Res>;
10
+ move(name: string, to: InsertPhaseOptions): IFlow<Req, Res>;
11
11
  protected getIndexOfPhase(name: string): number;
12
12
  execute(context: IContext<Req, Res>): Promise<PhaseResult>;
13
13
  }
@@ -34,24 +34,28 @@ export interface IFlow<Req, Res> extends IPhase<Req, Res> {
34
34
  * Replaces the named phase in the flow with the provided phase. If the named phase is not found, nothing happens.
35
35
  * @param name - The name of the phase to replace. A phase with this name should exist in the flow already.
36
36
  * @param phase - The phase that should replace the named phase.
37
+ * @returns The flow instance itself for chaining.
37
38
  */
38
- replace(name: string, phase: IPhase<Req, Res>): void;
39
+ replace(name: string, phase: IPhase<Req, Res>): IFlow<Req, Res>;
39
40
  /**
40
41
  * Removes the named phase from the flow. If the named phase is not found, does nothing.
41
42
  * @param name - The name of the phase to remove. A phase with this name should exist in the flow already.
43
+ * @returns The flow instance itself for chaining.
42
44
  */
43
- remove(name: string): void;
45
+ remove(name: string): IFlow<Req, Res>;
44
46
  /**
45
47
  * Inserts the provided phase into the flow at the specified position. If no position is specified,
46
48
  * the phase will be added to the very end of the flow.
47
49
  * @param phase - The phase to insert into the flow.
48
50
  * @param options - The options for inserting the phase. If no options are provided, the phase will be added to the end of the flow.
51
+ * @returns The flow instance itself for chaining.
49
52
  */
50
- insert(phase: IPhase<Req, Res>, options?: InsertPhaseOptions): void;
53
+ insert(phase: IPhase<Req, Res>, options?: InsertPhaseOptions): IFlow<Req, Res>;
51
54
  /**
52
55
  * Moves the named phase to the specified position in the flow. If the named phase is not found, nothing happens.
53
56
  * @param name - The name of the phase to move. A phase with this name should exist in the flow already.
54
57
  * @param to - The options for moving the phase. The phase will be moved to the specified position in the flow.
58
+ * @returns The flow instance itself for chaining.
55
59
  */
56
- move(name: string, to: InsertPhaseOptions): void;
60
+ move(name: string, to: InsertPhaseOptions): IFlow<Req, Res>;
57
61
  }
@@ -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.27.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.27.0",
3
+ "version": "0.29.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "typesVersions": {
@@ -55,6 +55,7 @@
55
55
  "@types/chai-as-promised": "^8.0.2",
56
56
  "@types/crypto-js": "^4.1.1",
57
57
  "@types/mocha": "^10.0.0",
58
+ "@types/node": "^18.19.50 || ^20.6.0 || ^22.0.0",
58
59
  "@types/sinon": "^17.0.1",
59
60
  "@types/uuid": "^10.0.0",
60
61
  "@typescript-eslint/eslint-plugin": "^8.26.0",
@@ -66,11 +67,11 @@
66
67
  "eslint-config-prettier": "^10.0.2",
67
68
  "eslint-plugin-prettier": "^5.2.3",
68
69
  "husky": "^9.1.7",
69
- "lint-staged": "^15.4.3",
70
- "mocha": "^10.0.0",
70
+ "lint-staged": "^16.0.0",
71
+ "mocha": "^11.4.0",
71
72
  "nyc": "^17.0.0",
72
73
  "prettier": "^3.5.3",
73
- "sinon": "^18.0.0",
74
+ "sinon": "^20.0.0",
74
75
  "ts-loader": "^9.4.1",
75
76
  "ts-node": "^10.9.1",
76
77
  "tsc-alias": "^1.8.11",