perimeterx-js-core 0.21.6 → 0.22.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/config/ConfigurationBase.js +3 -3
- package/lib/cjs/config/defaults/DefaultConfigurationParams.js +2 -0
- package/lib/cjs/config/params/index.js +2 -0
- package/lib/cjs/enforcer/index.js +1 -1
- package/lib/cjs/enforcer/utils.js +12 -1
- package/lib/cjs/utils/constants.js +1 -1
- package/lib/cjs/utils/utils.js +6 -1
- package/lib/esm/config/ConfigurationBase.js +3 -3
- package/lib/esm/config/defaults/DefaultConfigurationParams.js +2 -0
- package/lib/esm/config/params/index.js +2 -0
- package/lib/esm/enforcer/index.js +1 -1
- package/lib/esm/enforcer/utils.js +12 -1
- package/lib/esm/utils/constants.js +1 -1
- package/lib/esm/utils/utils.js +4 -0
- package/lib/types/config/ConfigurationBase.d.ts +4 -2
- package/lib/types/config/IConfiguration.d.ts +5 -0
- package/lib/types/config/params/BatchedActivitiesConfigParams.d.ts +4 -0
- package/lib/types/config/params/CommonConfigurationParams.d.ts +4 -7
- package/lib/types/config/params/TokenV3ConfigurationParamsOnly.d.ts +7 -0
- package/lib/types/config/params/index.d.ts +2 -0
- package/lib/types/enforcer/EnforcerBase.d.ts +7 -8
- package/lib/types/enforcer/{options/EnforcerBaseOptions.d.ts → EnforcerOptions.d.ts} +14 -13
- package/lib/types/enforcer/index.d.ts +1 -1
- package/lib/types/enforcer/utils.d.ts +2 -3
- package/lib/types/phase/flow/EndEnforcerFlow.d.ts +2 -2
- package/lib/types/phase/flow/EnforceFlow.d.ts +2 -2
- package/lib/types/phase/flow/FilterFlow.d.ts +2 -2
- package/lib/types/phase/flow/PostEnforceFlow.d.ts +2 -2
- package/lib/types/utils/constants.d.ts +1 -1
- package/lib/types/utils/utils.d.ts +1 -0
- package/package.json +1 -1
- package/lib/cjs/enforcer/options/EnforcerV3Options.js +0 -2
- package/lib/cjs/enforcer/options/index.js +0 -20
- package/lib/esm/enforcer/options/EnforcerV3Options.js +0 -1
- package/lib/esm/enforcer/options/index.js +0 -4
- package/lib/types/enforcer/options/EnforcerOptionsType.d.ts +0 -4
- package/lib/types/enforcer/options/EnforcerV2Options.d.ts +0 -5
- package/lib/types/enforcer/options/EnforcerV3Options.d.ts +0 -7
- package/lib/types/enforcer/options/index.d.ts +0 -4
- /package/lib/cjs/{enforcer/options/EnforcerBaseOptions.js → config/params/BatchedActivitiesConfigParams.js} +0 -0
- /package/lib/cjs/{enforcer/options/EnforcerOptionsType.js → config/params/TokenV3ConfigurationParamsOnly.js} +0 -0
- /package/lib/cjs/enforcer/{options/EnforcerV2Options.js → EnforcerOptions.js} +0 -0
- /package/lib/esm/{enforcer/options/EnforcerBaseOptions.js → config/params/BatchedActivitiesConfigParams.js} +0 -0
- /package/lib/esm/{enforcer/options/EnforcerOptionsType.js → config/params/TokenV3ConfigurationParamsOnly.js} +0 -0
- /package/lib/esm/enforcer/{options/EnforcerV2Options.js → EnforcerOptions.js} +0 -0
|
@@ -29,7 +29,7 @@ var ConfigurationBase = /** @class */ (function () {
|
|
|
29
29
|
Object.keys(defaultParams).forEach(function (k) {
|
|
30
30
|
config[k] = _this.getValidConfigValue(params, defaultParams, k);
|
|
31
31
|
});
|
|
32
|
-
this.internalLogger = this.createInternalLogger(config
|
|
32
|
+
this.internalLogger = this.createInternalLogger(config);
|
|
33
33
|
return config;
|
|
34
34
|
};
|
|
35
35
|
ConfigurationBase.prototype.throwIfMissingRequiredField = function (params) {
|
|
@@ -76,8 +76,8 @@ var ConfigurationBase = /** @class */ (function () {
|
|
|
76
76
|
return defaultParams[key];
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
|
-
ConfigurationBase.prototype.createInternalLogger = function (
|
|
80
|
-
return new logger_1.DefaultLogger(
|
|
79
|
+
ConfigurationBase.prototype.createInternalLogger = function (params) {
|
|
80
|
+
return new logger_1.DefaultLogger(params.px_logger_severity, false);
|
|
81
81
|
};
|
|
82
82
|
ConfigurationBase.prototype.addRemoteConfig = function (remoteConfigParams) {
|
|
83
83
|
this.remoteConfigParams = remoteConfigParams;
|
|
@@ -4,6 +4,7 @@ exports.DEFAULT_CONFIGURATION_PARAMS = void 0;
|
|
|
4
4
|
var logger_1 = require("../../logger");
|
|
5
5
|
var utils_1 = require("../../utils");
|
|
6
6
|
var products_1 = require("../../products");
|
|
7
|
+
var risk_token_1 = require("../../risk_token");
|
|
7
8
|
exports.DEFAULT_CONFIGURATION_PARAMS = {
|
|
8
9
|
px_app_id: '',
|
|
9
10
|
px_auth_token: '',
|
|
@@ -12,6 +13,7 @@ exports.DEFAULT_CONFIGURATION_PARAMS = {
|
|
|
12
13
|
px_remote_config_auth_token: '',
|
|
13
14
|
px_remote_config_enabled: true,
|
|
14
15
|
px_remote_config_id: '',
|
|
16
|
+
px_token_version: risk_token_1.TokenVersion.V3,
|
|
15
17
|
px_remote_config_version: 0,
|
|
16
18
|
px_filter_by_route_regex: [],
|
|
17
19
|
px_monitored_routes_regex: [],
|
|
@@ -20,3 +20,5 @@ __exportStar(require("./StaticConfigurationParamsOnly"), exports);
|
|
|
20
20
|
__exportStar(require("./StaticConfigurationParams"), exports);
|
|
21
21
|
__exportStar(require("./RemoteConfigurationParams"), exports);
|
|
22
22
|
__exportStar(require("./ConfigurationParams"), exports);
|
|
23
|
+
__exportStar(require("./TokenV3ConfigurationParamsOnly"), exports);
|
|
24
|
+
__exportStar(require("./BatchedActivitiesConfigParams"), exports);
|
|
@@ -16,5 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./IEnforcer"), exports);
|
|
18
18
|
__exportStar(require("./EnforcerBase"), exports);
|
|
19
|
-
__exportStar(require("./
|
|
19
|
+
__exportStar(require("./EnforcerOptions"), exports);
|
|
20
20
|
__exportStar(require("./utils"), exports);
|
|
@@ -22,9 +22,19 @@ var risk_api_1 = require("../risk_api");
|
|
|
22
22
|
var activities_1 = require("../activities");
|
|
23
23
|
var logger_1 = require("../logger");
|
|
24
24
|
var products_1 = require("../products");
|
|
25
|
+
var utils_1 = require("../utils");
|
|
25
26
|
var createEnforcerInitializationBlock = function (config, options) {
|
|
26
|
-
var tokenVersion =
|
|
27
|
+
var tokenVersion = config.tokenVersion;
|
|
28
|
+
if (!(0, utils_1.isValidTokenVersion)(tokenVersion)) {
|
|
29
|
+
throw new utils_1.EnforcerError("error initializing enforcer: token version ".concat(tokenVersion, " is invalid (must be one of ").concat(Object.values(risk_token_1.TokenVersion)
|
|
30
|
+
.map(function (v) { return "\"".concat(v, "\""); })
|
|
31
|
+
.join(', '), ")"));
|
|
32
|
+
}
|
|
33
|
+
var httpClient = options.httpClient, base64Utils = options.base64Utils, hmacUtils = options.hmacUtils, hashUtils = options.hashUtils, urlUtils = options.urlUtils, ipRangeChecker = options.ipRangeChecker;
|
|
27
34
|
var cipherUtils = tokenVersion === risk_token_1.TokenVersion.V2 ? null : options.cipherUtils;
|
|
35
|
+
if (tokenVersion === risk_token_1.TokenVersion.V3 && !cipherUtils) {
|
|
36
|
+
throw new utils_1.EnforcerError('error initializing enforcer: token v3 requires cipherUtils');
|
|
37
|
+
}
|
|
28
38
|
var cors = options.cors || new cors_1.DefaultCors(config);
|
|
29
39
|
var telemetry = options.telemetry || new telemetry_1.DefaultTelemetry(config, httpClient, base64Utils, hmacUtils);
|
|
30
40
|
var dataEnrichment = options.dataEnrichment || new pxde_1.DefaultDataEnrichment(config, base64Utils, hmacUtils);
|
|
@@ -61,6 +71,7 @@ var createEnforcerInitializationBlock = function (config, options) {
|
|
|
61
71
|
hashUtils: hashUtils,
|
|
62
72
|
urlUtils: urlUtils,
|
|
63
73
|
ipRangeChecker: ipRangeChecker,
|
|
74
|
+
cipherUtils: cipherUtils,
|
|
64
75
|
cors: cors,
|
|
65
76
|
telemetry: telemetry,
|
|
66
77
|
dataEnrichment: dataEnrichment,
|
|
@@ -14,4 +14,4 @@ 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?\:)\/\/(([^@\s:]+):?([^@\s]*)@)?(([^:\/?#]*)(?:\:([0-9]+))?)([\/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/;
|
|
16
16
|
exports.REGEX_STRUCTURE = /^\/(.+?)\/([gimsuyvd]*)$/;
|
|
17
|
-
exports.CORE_MODULE_VERSION = 'JS Core 0.
|
|
17
|
+
exports.CORE_MODULE_VERSION = 'JS Core 0.22.0';
|
package/lib/cjs/utils/utils.js
CHANGED
|
@@ -36,11 +36,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.telemetryConfigReplacer = exports.convertRegexStringToRegex = exports.algoToCryptoString = exports.algoToSubtleCryptoString = exports.sleep = exports.getPropertyFromObject = exports.rejectOnTimeout = exports.transferExistingProperties = exports.isRouteMatch = exports.isRouteInPatterns = exports.removeSensitiveHeaders = exports.redactSensitiveFields = exports.getExtension = exports.getAuthorizationHeader = exports.getCollectorDomain = exports.getScoreApiDomain = exports.isEmailAddress = exports.isValidUuid = exports.isValidEnumValue = void 0;
|
|
39
|
+
exports.isValidTokenVersion = exports.telemetryConfigReplacer = exports.convertRegexStringToRegex = exports.algoToCryptoString = exports.algoToSubtleCryptoString = exports.sleep = exports.getPropertyFromObject = exports.rejectOnTimeout = exports.transferExistingProperties = exports.isRouteMatch = exports.isRouteInPatterns = exports.removeSensitiveHeaders = exports.redactSensitiveFields = exports.getExtension = exports.getAuthorizationHeader = exports.getCollectorDomain = exports.getScoreApiDomain = exports.isEmailAddress = exports.isValidUuid = exports.isValidEnumValue = void 0;
|
|
40
40
|
var http_1 = require("../http");
|
|
41
41
|
var error_1 = require("./error");
|
|
42
42
|
var constants_1 = require("./constants");
|
|
43
43
|
var Algorithm_1 = require("./Algorithm");
|
|
44
|
+
var risk_token_1 = require("../risk_token");
|
|
44
45
|
var isValidEnumValue = function (options, selection) {
|
|
45
46
|
return Object.values(options).includes(selection);
|
|
46
47
|
};
|
|
@@ -237,3 +238,7 @@ var telemetryConfigReplacer = function (key, value) {
|
|
|
237
238
|
return value;
|
|
238
239
|
};
|
|
239
240
|
exports.telemetryConfigReplacer = telemetryConfigReplacer;
|
|
241
|
+
var isValidTokenVersion = function (tokenVersion) {
|
|
242
|
+
return tokenVersion === risk_token_1.TokenVersion.V2 || tokenVersion === risk_token_1.TokenVersion.V3;
|
|
243
|
+
};
|
|
244
|
+
exports.isValidTokenVersion = isValidTokenVersion;
|
|
@@ -19,7 +19,7 @@ export class ConfigurationBase {
|
|
|
19
19
|
Object.keys(defaultParams).forEach((k) => {
|
|
20
20
|
config[k] = this.getValidConfigValue(params, defaultParams, k);
|
|
21
21
|
});
|
|
22
|
-
this.internalLogger = this.createInternalLogger(config
|
|
22
|
+
this.internalLogger = this.createInternalLogger(config);
|
|
23
23
|
return config;
|
|
24
24
|
}
|
|
25
25
|
throwIfMissingRequiredField(params) {
|
|
@@ -66,8 +66,8 @@ export class ConfigurationBase {
|
|
|
66
66
|
return defaultParams[key];
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
createInternalLogger(
|
|
70
|
-
return new DefaultLogger(
|
|
69
|
+
createInternalLogger(params) {
|
|
70
|
+
return new DefaultLogger(params.px_logger_severity, false);
|
|
71
71
|
}
|
|
72
72
|
addRemoteConfig(remoteConfigParams) {
|
|
73
73
|
this.remoteConfigParams = remoteConfigParams;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { LoggerSeverity } from '../../logger';
|
|
2
2
|
import { ModuleMode } from '../../utils';
|
|
3
3
|
import { CredentialIntelligenceVersion, DEFAULT_COMPROMISED_CREDENTIALS_HEADER_NAME, LoginSuccessfulReportingMethod, } from '../../products';
|
|
4
|
+
import { TokenVersion } from '../../risk_token';
|
|
4
5
|
export const DEFAULT_CONFIGURATION_PARAMS = {
|
|
5
6
|
px_app_id: '',
|
|
6
7
|
px_auth_token: '',
|
|
@@ -9,6 +10,7 @@ export const DEFAULT_CONFIGURATION_PARAMS = {
|
|
|
9
10
|
px_remote_config_auth_token: '',
|
|
10
11
|
px_remote_config_enabled: true,
|
|
11
12
|
px_remote_config_id: '',
|
|
13
|
+
px_token_version: TokenVersion.V3,
|
|
12
14
|
px_remote_config_version: 0,
|
|
13
15
|
px_filter_by_route_regex: [],
|
|
14
16
|
px_monitored_routes_regex: [],
|
|
@@ -4,3 +4,5 @@ export * from './StaticConfigurationParamsOnly';
|
|
|
4
4
|
export * from './StaticConfigurationParams';
|
|
5
5
|
export * from './RemoteConfigurationParams';
|
|
6
6
|
export * from './ConfigurationParams';
|
|
7
|
+
export * from './TokenV3ConfigurationParamsOnly';
|
|
8
|
+
export * from './BatchedActivitiesConfigParams';
|
|
@@ -8,9 +8,19 @@ import { PostRiskApiClientV2, PostRiskApiClientV3 } from '../risk_api';
|
|
|
8
8
|
import { HttpActivityClient, HttpBatchedActivityClient } from '../activities';
|
|
9
9
|
import { HttpLogServiceClient } from '../logger';
|
|
10
10
|
import { AccountDefender, BotDefender, CredentialIntelligence, HypeSaleChallenge, ProductName, } from '../products';
|
|
11
|
+
import { EnforcerError, isValidTokenVersion } from '../utils';
|
|
11
12
|
export const createEnforcerInitializationBlock = (config, options) => {
|
|
12
|
-
const
|
|
13
|
+
const tokenVersion = config.tokenVersion;
|
|
14
|
+
if (!isValidTokenVersion(tokenVersion)) {
|
|
15
|
+
throw new EnforcerError(`error initializing enforcer: token version ${tokenVersion} is invalid (must be one of ${Object.values(TokenVersion)
|
|
16
|
+
.map((v) => `"${v}"`)
|
|
17
|
+
.join(', ')})`);
|
|
18
|
+
}
|
|
19
|
+
const { httpClient, base64Utils, hmacUtils, hashUtils, urlUtils, ipRangeChecker } = options;
|
|
13
20
|
const cipherUtils = tokenVersion === TokenVersion.V2 ? null : options.cipherUtils;
|
|
21
|
+
if (tokenVersion === TokenVersion.V3 && !cipherUtils) {
|
|
22
|
+
throw new EnforcerError('error initializing enforcer: token v3 requires cipherUtils');
|
|
23
|
+
}
|
|
14
24
|
const cors = options.cors || new DefaultCors(config);
|
|
15
25
|
const telemetry = options.telemetry || new DefaultTelemetry(config, httpClient, base64Utils, hmacUtils);
|
|
16
26
|
const dataEnrichment = options.dataEnrichment || new DefaultDataEnrichment(config, base64Utils, hmacUtils);
|
|
@@ -47,6 +57,7 @@ export const createEnforcerInitializationBlock = (config, options) => {
|
|
|
47
57
|
hashUtils,
|
|
48
58
|
urlUtils,
|
|
49
59
|
ipRangeChecker,
|
|
60
|
+
cipherUtils,
|
|
50
61
|
cors,
|
|
51
62
|
telemetry,
|
|
52
63
|
dataEnrichment,
|
|
@@ -11,4 +11,4 @@ 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?\:)\/\/(([^@\s:]+):?([^@\s]*)@)?(([^:\/?#]*)(?:\:([0-9]+))?)([\/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/;
|
|
13
13
|
export const REGEX_STRUCTURE = /^\/(.+?)\/([gimsuyvd]*)$/;
|
|
14
|
-
export const CORE_MODULE_VERSION = 'JS Core 0.
|
|
14
|
+
export const CORE_MODULE_VERSION = 'JS Core 0.22.0';
|
package/lib/esm/utils/utils.js
CHANGED
|
@@ -2,6 +2,7 @@ import { toMutableHeaders } from '../http';
|
|
|
2
2
|
import { EnforcerTimeoutError } from './error';
|
|
3
3
|
import { EMAIL_ADDRESS_REGEX, REGEX_STRUCTURE } from './constants';
|
|
4
4
|
import { Algorithm } from './Algorithm';
|
|
5
|
+
import { TokenVersion } from '../risk_token';
|
|
5
6
|
export const isValidEnumValue = (options, selection) => {
|
|
6
7
|
return Object.values(options).includes(selection);
|
|
7
8
|
};
|
|
@@ -166,3 +167,6 @@ export const telemetryConfigReplacer = (key, value) => {
|
|
|
166
167
|
else
|
|
167
168
|
return value;
|
|
168
169
|
};
|
|
170
|
+
export const isValidTokenVersion = (tokenVersion) => {
|
|
171
|
+
return tokenVersion === TokenVersion.V2 || tokenVersion === TokenVersion.V3;
|
|
172
|
+
};
|
|
@@ -8,20 +8,22 @@ import { ModuleMode } from '../utils';
|
|
|
8
8
|
import { CredentialEndpointConfiguration, CredentialIntelligenceVersion, CustomLoginSuccessfulCallback, LoginSuccessfulReportingMethod } from '../products';
|
|
9
9
|
import { CustomRequestFunction } from './CustomRequestFunction';
|
|
10
10
|
import { ExtractGraphQLKeywordsFunction } from '../graphql';
|
|
11
|
+
import { TokenVersion } from '../risk_token';
|
|
11
12
|
export declare abstract class ConfigurationBase<Req, Res, ParamsType extends ConfigurationParams<Req, Res> = ConfigurationParams<Req, Res>> implements IConfiguration<Req, Res, ParamsType> {
|
|
12
13
|
protected activeConfigParams: ParamsType;
|
|
13
14
|
protected readonly staticConfigParams: StaticConfigurationParams<Req, Res, ParamsType>;
|
|
14
15
|
protected remoteConfigParams: RemoteConfigurationParams<Req, Res>;
|
|
15
16
|
protected readonly defaultConfigParams: ParamsType;
|
|
16
17
|
private internalLogger;
|
|
18
|
+
abstract tokenVersion: TokenVersion;
|
|
17
19
|
protected abstract getModuleVersion(): string;
|
|
18
|
-
constructor(params: StaticConfigurationParams<Req, Res, ParamsType>, defaultParams?: Partial<ParamsType>);
|
|
20
|
+
protected constructor(params: StaticConfigurationParams<Req, Res, ParamsType>, defaultParams?: Partial<ParamsType>);
|
|
19
21
|
protected createActiveConfiguration(params: ParamsType, defaultParams: ParamsType): ParamsType;
|
|
20
22
|
protected throwIfMissingRequiredField(params: ParamsType): void;
|
|
21
23
|
protected getValidConfigValue<K extends keyof ParamsType, V extends ParamsType[K]>(params: ParamsType, defaultParams: ParamsType, key: K): V;
|
|
22
24
|
protected isValidConfigValue(params: ParamsType, defaultParams: ParamsType, key: keyof ParamsType): boolean;
|
|
23
25
|
protected getDefaultConfigurationValue<K extends keyof ParamsType, V extends ParamsType[K]>(params: ParamsType, defaultParams: ParamsType, key: K): V;
|
|
24
|
-
protected createInternalLogger(
|
|
26
|
+
protected createInternalLogger(params: ParamsType): ILogger;
|
|
25
27
|
addRemoteConfig(remoteConfigParams: RemoteConfigurationParams<Req, Res>): void;
|
|
26
28
|
getActiveConfig(): ParamsType;
|
|
27
29
|
getStaticConfig(): StaticConfigurationParams<Req, Res, ParamsType>;
|
|
@@ -7,6 +7,7 @@ import { CustomPreflightHandler, CustomBlockResponseHeadersHandler } from '../co
|
|
|
7
7
|
import { CredentialEndpointConfiguration, CredentialIntelligenceVersion, CustomLoginSuccessfulCallback, LoginSuccessfulReportingMethod } from '../products';
|
|
8
8
|
import { CustomRequestFunction } from './CustomRequestFunction';
|
|
9
9
|
import { ExtractGraphQLKeywordsFunction } from '../graphql';
|
|
10
|
+
import { TokenVersion } from '../risk_token';
|
|
10
11
|
export interface IConfiguration<Req, Res, ParamsType extends ConfigurationParams<Req, Res> = ConfigurationParams<Req, Res>> {
|
|
11
12
|
/**
|
|
12
13
|
* The application ID.
|
|
@@ -373,6 +374,10 @@ export interface IConfiguration<Req, Res, ParamsType extends ConfigurationParams
|
|
|
373
374
|
* Whether to include the request url in captcha block page
|
|
374
375
|
*/
|
|
375
376
|
readonly enableBlockedUrlOnCaptchaBlockPage: boolean;
|
|
377
|
+
/**
|
|
378
|
+
* The version of the token the enforcer is able to parse.
|
|
379
|
+
*/
|
|
380
|
+
readonly tokenVersion: TokenVersion;
|
|
376
381
|
/**
|
|
377
382
|
* Returns an object representation of the current configuration.
|
|
378
383
|
*/
|
|
@@ -6,21 +6,18 @@ import { AdditionalActivityHandler } from '../../additional_activity_handler';
|
|
|
6
6
|
import { CustomParametersFunction } from '../../custom_parameters';
|
|
7
7
|
import { CustomBlockResponseHeadersHandler, CustomPreflightHandler } from '../../cors';
|
|
8
8
|
import { CustomRequestFunction } from '../CustomRequestFunction';
|
|
9
|
-
|
|
9
|
+
import { TokenV3ConfigurationParamsOnly } from './TokenV3ConfigurationParamsOnly';
|
|
10
|
+
import { BatchedActivitiesConfigParamsOnly } from './BatchedActivitiesConfigParams';
|
|
11
|
+
export type CommonConfigurationParams<Req, Res> = TokenV3ConfigurationParamsOnly & BatchedActivitiesConfigParamsOnly & {
|
|
10
12
|
px_s2s_timeout?: number;
|
|
11
13
|
px_backend_url?: string;
|
|
12
|
-
px_blocking_score?: number;
|
|
13
14
|
px_user_agent_max_length?: number;
|
|
14
|
-
px_risk_cookie_max_length?: number;
|
|
15
|
-
px_risk_cookie_min_iterations?: number;
|
|
16
|
-
px_risk_cookie_max_iterations?: number;
|
|
17
15
|
px_logger_severity?: 'debug' | 'error' | 'none' | LoggerSeverity;
|
|
18
16
|
px_ip_headers?: string[];
|
|
19
17
|
px_module_enabled?: boolean;
|
|
20
18
|
px_module_mode?: 'monitor' | 'active_blocking' | ModuleMode;
|
|
21
19
|
px_advanced_blocking_response_enabled?: boolean;
|
|
22
|
-
|
|
23
|
-
px_batch_activities_timeout_ms?: number;
|
|
20
|
+
px_risk_cookie_max_length?: number;
|
|
24
21
|
px_bypass_monitor_header?: string;
|
|
25
22
|
px_enforced_routes?: Array<string | RegExp>;
|
|
26
23
|
px_first_party_enabled?: boolean;
|
|
@@ -4,3 +4,5 @@ export * from './StaticConfigurationParamsOnly';
|
|
|
4
4
|
export * from './StaticConfigurationParams';
|
|
5
5
|
export * from './RemoteConfigurationParams';
|
|
6
6
|
export * from './ConfigurationParams';
|
|
7
|
+
export * from './TokenV3ConfigurationParamsOnly';
|
|
8
|
+
export * from './BatchedActivitiesConfigParams';
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { AsyncOrSync } from 'ts-essentials';
|
|
2
2
|
import { IConfiguration } from '../config';
|
|
3
3
|
import { IContext } from '../context';
|
|
4
|
-
import { TokenVersion } from '../risk_token';
|
|
5
4
|
import { IMinimalResponse, IOutgoingResponse } from '../http';
|
|
6
5
|
import { IPhase } from '../phase';
|
|
7
6
|
import { IActivityClient } from '../activities';
|
|
8
7
|
import { IEnforcer } from './IEnforcer';
|
|
9
|
-
import {
|
|
10
|
-
export declare abstract class EnforcerBase<
|
|
8
|
+
import { EnforcerOptions } from './EnforcerOptions';
|
|
9
|
+
export declare abstract class EnforcerBase<Req, Res, EnforceArgs extends any[], PostEnforceArgs extends any[]> implements IEnforcer<EnforceArgs, PostEnforceArgs, Promise<null | Res>, Promise<void>> {
|
|
11
10
|
protected readonly config: IConfiguration<Req, Res>;
|
|
12
11
|
protected readonly filterFlow: IPhase<Req, Res>;
|
|
13
12
|
protected readonly enforceFlow: IPhase<Req, Res>;
|
|
@@ -57,11 +56,11 @@ export declare abstract class EnforcerBase<TokenV extends TokenVersion, Req, Res
|
|
|
57
56
|
* @param options - An EnforcerOptions object that allows for overriding any functional building blocks in the enforcer.
|
|
58
57
|
* @protected
|
|
59
58
|
*/
|
|
60
|
-
protected constructor(config: IConfiguration<Req, Res>, options:
|
|
61
|
-
protected createFilterFlow(config: IConfiguration<Req, Res>, initializationBlock: Required<
|
|
62
|
-
protected createPostEnforceFlow(config: IConfiguration<Req, Res>, initializationBlock: Required<
|
|
63
|
-
protected createEnforceFlow(config: IConfiguration<Req, Res>, initializationBlock: Required<
|
|
64
|
-
protected createEndEnforcerFlow(config: IConfiguration<Req, Res>, initializationBlock: Required<
|
|
59
|
+
protected constructor(config: IConfiguration<Req, Res>, options: EnforcerOptions<Req, Res>);
|
|
60
|
+
protected createFilterFlow(config: IConfiguration<Req, Res>, initializationBlock: Required<EnforcerOptions<Req, Res>>): IPhase<Req, Res>;
|
|
61
|
+
protected createPostEnforceFlow(config: IConfiguration<Req, Res>, initializationBlock: Required<EnforcerOptions<Req, Res>>): IPhase<Req, Res>;
|
|
62
|
+
protected createEnforceFlow(config: IConfiguration<Req, Res>, initializationBlock: Required<EnforcerOptions<Req, Res>>): IPhase<Req, Res>;
|
|
63
|
+
protected createEndEnforcerFlow(config: IConfiguration<Req, Res>, initializationBlock: Required<EnforcerOptions<Req, Res>>): IPhase<Req, Res>;
|
|
65
64
|
/**
|
|
66
65
|
* The central function that triggers enforcement on the incoming request.
|
|
67
66
|
* @param args - The EnforceArgs required to enforce the incoming request.
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import { IDataEnrichment } from '
|
|
2
|
-
import { ITokenParser } from '
|
|
3
|
-
import { IBase64Utils, IHashUtils, IHmacUtils, IIpRangeChecker, IUrlUtils } from '
|
|
4
|
-
import { ICors } from '
|
|
5
|
-
import { IHttpClient } from '
|
|
6
|
-
import { ITelemetry } from '
|
|
7
|
-
import { IRiskApiClient } from '
|
|
8
|
-
import { IActivityClient } from '
|
|
9
|
-
import { Products } from '
|
|
10
|
-
import { IGraphQLParser } from '
|
|
11
|
-
import { ILogServiceClient } from '
|
|
12
|
-
import { IRemoteConfigStorageClient, IRemoteConfigServiceClient, IRemoteConfigUpdater } from '
|
|
13
|
-
export type
|
|
1
|
+
import { IDataEnrichment } from '../pxde';
|
|
2
|
+
import { ITokenParser } from '../risk_token';
|
|
3
|
+
import { IBase64Utils, ICipherUtils, IHashUtils, IHmacUtils, IIpRangeChecker, IUrlUtils } from '../utils';
|
|
4
|
+
import { ICors } from '../cors';
|
|
5
|
+
import { IHttpClient } from '../http';
|
|
6
|
+
import { ITelemetry } from '../telemetry';
|
|
7
|
+
import { IRiskApiClient } from '../risk_api';
|
|
8
|
+
import { IActivityClient } from '../activities';
|
|
9
|
+
import { Products } from '../products';
|
|
10
|
+
import { IGraphQLParser } from '../graphql';
|
|
11
|
+
import { ILogServiceClient } from '../logger';
|
|
12
|
+
import { IRemoteConfigStorageClient, IRemoteConfigServiceClient, IRemoteConfigUpdater } from '../config';
|
|
13
|
+
export type EnforcerOptions<Req, Res> = {
|
|
14
14
|
httpClient: IHttpClient;
|
|
15
15
|
base64Utils: IBase64Utils;
|
|
16
16
|
hmacUtils: IHmacUtils;
|
|
17
17
|
hashUtils: IHashUtils;
|
|
18
18
|
urlUtils: IUrlUtils;
|
|
19
|
+
cipherUtils?: ICipherUtils;
|
|
19
20
|
ipRangeChecker: IIpRangeChecker;
|
|
20
21
|
products?: Products<Req, Res>;
|
|
21
22
|
dataEnrichment?: IDataEnrichment<Req, Res>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { TokenVersion } from '../risk_token';
|
|
2
1
|
import { IConfiguration } from '../config';
|
|
3
|
-
import {
|
|
2
|
+
import { EnforcerOptions } from './EnforcerOptions';
|
|
4
3
|
import { Products } from '../products';
|
|
5
4
|
import { IBase64Utils, IHashUtils, IIpRangeChecker, IUrlUtils } from '../utils';
|
|
6
|
-
export declare const createEnforcerInitializationBlock: <Req, Res
|
|
5
|
+
export declare const createEnforcerInitializationBlock: <Req, Res>(config: IConfiguration<Req, Res, import("../config").ConfigurationParams<Req, Res>>, options: EnforcerOptions<Req, Res>) => Required<EnforcerOptions<Req, Res>>;
|
|
7
6
|
export declare const createEnforcerProducts: <Req, Res>(config: IConfiguration<Req, Res, import("../config").ConfigurationParams<Req, Res>>, products: Products<Req, Res>, base64Utils: IBase64Utils, hashUtils: IHashUtils, urlUtils: IUrlUtils, ipRangeChecker: IIpRangeChecker) => Required<Products<Req, Res>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IConfiguration } from '../../config';
|
|
2
2
|
import { CompositePhase } from '../impl';
|
|
3
|
-
import {
|
|
3
|
+
import { EnforcerOptions } from '../../enforcer';
|
|
4
4
|
export declare class EndEnforcerFlow<Req, Res> extends CompositePhase<Req, Res> {
|
|
5
|
-
constructor(config: IConfiguration<Req, Res>, { logServiceClient }: Pick<Required<
|
|
5
|
+
constructor(config: IConfiguration<Req, Res>, { logServiceClient }: Pick<Required<EnforcerOptions<Req, Res>>, 'logServiceClient'>);
|
|
6
6
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { IConfiguration } from '../../config';
|
|
2
|
-
import {
|
|
2
|
+
import { EnforcerOptions } from '../../enforcer';
|
|
3
3
|
import { CompositePhase } from '../impl';
|
|
4
4
|
type RequiredEnforceFlowOptions = 'dataEnrichment' | 'tokenParser' | 'riskApiClient' | 'activityClient' | 'cors' | 'products' | 'graphQLParser';
|
|
5
5
|
export declare class EnforceFlow<Req, Res> extends CompositePhase<Req, Res> {
|
|
6
|
-
constructor(config: IConfiguration<Req, Res>, { dataEnrichment, tokenParser, riskApiClient, activityClient, cors, products, graphQLParser, }: Pick<Required<
|
|
6
|
+
constructor(config: IConfiguration<Req, Res>, { dataEnrichment, tokenParser, riskApiClient, activityClient, cors, products, graphQLParser, }: Pick<Required<EnforcerOptions<Req, Res>>, RequiredEnforceFlowOptions>);
|
|
7
7
|
}
|
|
8
8
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IConfiguration } from '../../config';
|
|
2
|
-
import {
|
|
2
|
+
import { EnforcerOptions } from '../../enforcer';
|
|
3
3
|
import { CompositePhase } from '../impl';
|
|
4
4
|
export declare class FilterFlow<Req, Res> extends CompositePhase<Req, Res> {
|
|
5
|
-
constructor(config: IConfiguration<Req, Res>, { httpClient, products, cors, telemetry, remoteConfigUpdater }: Required<
|
|
5
|
+
constructor(config: IConfiguration<Req, Res>, { httpClient, products, cors, telemetry, remoteConfigUpdater }: Required<EnforcerOptions<Req, Res>>);
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IConfiguration } from '../../config';
|
|
2
|
-
import {
|
|
2
|
+
import { EnforcerOptions } from '../../enforcer';
|
|
3
3
|
import { CompositePhase } from '../impl';
|
|
4
4
|
export declare class PostEnforceFlow<Req, Res> extends CompositePhase<Req, Res> {
|
|
5
|
-
constructor(config: IConfiguration<Req, Res>, { products, activityClient }: Pick<Required<
|
|
5
|
+
constructor(config: IConfiguration<Req, Res>, { products, activityClient }: Pick<Required<EnforcerOptions<Req, Res>>, 'products' | 'activityClient'>);
|
|
6
6
|
}
|
|
@@ -11,4 +11,4 @@ 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
13
|
export declare const REGEX_STRUCTURE: RegExp;
|
|
14
|
-
export declare const CORE_MODULE_VERSION = "JS Core 0.
|
|
14
|
+
export declare const CORE_MODULE_VERSION = "JS Core 0.22.0";
|
|
@@ -23,3 +23,4 @@ export declare const algoToSubtleCryptoString: (algo: Algorithm) => string;
|
|
|
23
23
|
export declare const algoToCryptoString: (algo: Algorithm) => string;
|
|
24
24
|
export declare const convertRegexStringToRegex: (regexString: string, logger?: ILogger) => RegExp;
|
|
25
25
|
export declare const telemetryConfigReplacer: (key: string, value: any) => string;
|
|
26
|
+
export declare const isValidTokenVersion: (tokenVersion: any) => boolean;
|
package/package.json
CHANGED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./EnforcerBaseOptions"), exports);
|
|
18
|
-
__exportStar(require("./EnforcerV2Options"), exports);
|
|
19
|
-
__exportStar(require("./EnforcerV3Options"), exports);
|
|
20
|
-
__exportStar(require("./EnforcerOptionsType"), exports);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { TokenVersion } from '../../risk_token';
|
|
2
|
-
import { EnforcerV2Options } from './EnforcerV2Options';
|
|
3
|
-
import { EnforcerV3Options } from './EnforcerV3Options';
|
|
4
|
-
export type EnforcerOptionsType<TokenV extends TokenVersion, Req, Res> = TokenV extends TokenVersion.V2 ? EnforcerV2Options<Req, Res> : TokenV extends TokenVersion.V3 ? EnforcerV3Options<Req, Res> : never;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { TokenVersion } from '../../risk_token';
|
|
2
|
-
import { ICipherUtils } from '../../utils';
|
|
3
|
-
import { EnforcerBaseOptions } from './EnforcerBaseOptions';
|
|
4
|
-
export type EnforcerV3Options<Req, Res> = {
|
|
5
|
-
tokenVersion: TokenVersion.V3;
|
|
6
|
-
cipherUtils: ICipherUtils;
|
|
7
|
-
} & EnforcerBaseOptions<Req, Res>;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|