perimeterx-js-core 0.1.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/README.md +158 -0
- package/lib/activities/ActivityType.d.ts +6 -0
- package/lib/activities/ActivityType.js +10 -0
- package/lib/activities/HttpActivityClient.d.ts +12 -0
- package/lib/activities/HttpActivityClient.js +107 -0
- package/lib/activities/IActivityClient.d.ts +8 -0
- package/lib/activities/IActivityClient.js +2 -0
- package/lib/activities/constants.d.ts +1 -0
- package/lib/activities/constants.js +4 -0
- package/lib/activities/index.d.ts +5 -0
- package/lib/activities/index.js +7 -0
- package/lib/activities/model/Activity.d.ts +13 -0
- package/lib/activities/model/Activity.js +2 -0
- package/lib/activities/model/ActivityDetails.d.ts +41 -0
- package/lib/activities/model/ActivityDetails.js +2 -0
- package/lib/activities/utils.d.ts +10 -0
- package/lib/activities/utils.js +88 -0
- package/lib/additional_activity_handler/AdditionalActivityHandler.d.ts +3 -0
- package/lib/additional_activity_handler/AdditionalActivityHandler.js +2 -0
- package/lib/additional_activity_handler/AdditionalActivityHandlerUtils.d.ts +5 -0
- package/lib/additional_activity_handler/AdditionalActivityHandlerUtils.js +64 -0
- package/lib/additional_activity_handler/index.d.ts +2 -0
- package/lib/additional_activity_handler/index.js +5 -0
- package/lib/block_handler/BlockAction.d.ts +6 -0
- package/lib/block_handler/BlockAction.js +21 -0
- package/lib/block_handler/BlockReason.d.ts +4 -0
- package/lib/block_handler/BlockReason.js +8 -0
- package/lib/block_handler/DefaultBlockResponseGenerator.d.ts +14 -0
- package/lib/block_handler/DefaultBlockResponseGenerator.js +44 -0
- package/lib/block_handler/IBlockResponseGenerator.d.ts +14 -0
- package/lib/block_handler/IBlockResponseGenerator.js +2 -0
- package/lib/block_handler/captcha/CaptchaBlockResponseGenerator.d.ts +14 -0
- package/lib/block_handler/captcha/CaptchaBlockResponseGenerator.js +30 -0
- package/lib/block_handler/captcha/HtmlCaptchaResponseGenerator.d.ts +10 -0
- package/lib/block_handler/captcha/HtmlCaptchaResponseGenerator.js +25 -0
- package/lib/block_handler/captcha/JsonCaptchaResponseGenerator.d.ts +10 -0
- package/lib/block_handler/captcha/JsonCaptchaResponseGenerator.js +44 -0
- package/lib/block_handler/captcha/MobileCaptchaResponseGenerator.d.ts +12 -0
- package/lib/block_handler/captcha/MobileCaptchaResponseGenerator.js +36 -0
- package/lib/block_handler/index.d.ts +13 -0
- package/lib/block_handler/index.js +21 -0
- package/lib/block_handler/model/BlockData.d.ts +16 -0
- package/lib/block_handler/model/BlockData.js +2 -0
- package/lib/block_handler/model/JsonBlockPayload.d.ts +11 -0
- package/lib/block_handler/model/JsonBlockPayload.js +2 -0
- package/lib/block_handler/model/MobileBlockPayload.d.ts +8 -0
- package/lib/block_handler/model/MobileBlockPayload.js +2 -0
- package/lib/block_handler/templates/captcha_template.d.ts +1 -0
- package/lib/block_handler/templates/captcha_template.js +4 -0
- package/lib/block_handler/templates/rate_limit_template.d.ts +1 -0
- package/lib/block_handler/templates/rate_limit_template.js +4 -0
- package/lib/block_handler/utils.d.ts +5 -0
- package/lib/block_handler/utils.js +48 -0
- package/lib/config/ConfigurationParams.d.ts +65 -0
- package/lib/config/ConfigurationParams.js +2 -0
- package/lib/config/DefaultConfigurations.d.ts +2 -0
- package/lib/config/DefaultConfigurations.js +107 -0
- package/lib/config/IConfiguration.d.ts +172 -0
- package/lib/config/IConfiguration.js +2 -0
- package/lib/config/StaticConfigurationBase.d.ts +57 -0
- package/lib/config/StaticConfigurationBase.js +355 -0
- package/lib/config/index.d.ts +4 -0
- package/lib/config/index.js +7 -0
- package/lib/context/ContextBase.d.ts +55 -0
- package/lib/context/ContextBase.js +206 -0
- package/lib/context/DefaultTokenV2Context.d.ts +13 -0
- package/lib/context/DefaultTokenV2Context.js +35 -0
- package/lib/context/DefaultTokenV3Context.d.ts +13 -0
- package/lib/context/DefaultTokenV3Context.js +35 -0
- package/lib/context/IContext.d.ts +256 -0
- package/lib/context/IContext.js +2 -0
- package/lib/context/index.d.ts +4 -0
- package/lib/context/index.js +9 -0
- package/lib/custom_parameters/CustomParameters.d.ts +12 -0
- package/lib/custom_parameters/CustomParameters.js +2 -0
- package/lib/custom_parameters/CustomParametersFunction.d.ts +4 -0
- package/lib/custom_parameters/CustomParametersFunction.js +2 -0
- package/lib/custom_parameters/CustomParametersUtils.d.ts +4 -0
- package/lib/custom_parameters/CustomParametersUtils.js +19 -0
- package/lib/custom_parameters/index.d.ts +3 -0
- package/lib/custom_parameters/index.js +5 -0
- package/lib/enforcer/EnforcerBase.d.ts +139 -0
- package/lib/enforcer/EnforcerBase.js +376 -0
- package/lib/enforcer/IEnforcer.d.ts +4 -0
- package/lib/enforcer/IEnforcer.js +2 -0
- package/lib/enforcer/index.d.ts +2 -0
- package/lib/enforcer/index.js +5 -0
- package/lib/filter/DefaultFilter.d.ts +16 -0
- package/lib/filter/DefaultFilter.js +59 -0
- package/lib/filter/FilterReason.d.ts +8 -0
- package/lib/filter/FilterReason.js +12 -0
- package/lib/filter/IFilter.d.ts +8 -0
- package/lib/filter/IFilter.js +2 -0
- package/lib/filter/index.d.ts +3 -0
- package/lib/filter/index.js +7 -0
- package/lib/first_party/DefaultFirstParty.d.ts +22 -0
- package/lib/first_party/DefaultFirstParty.js +215 -0
- package/lib/first_party/IFirstParty.d.ts +9 -0
- package/lib/first_party/IFirstParty.js +2 -0
- package/lib/first_party/constants.d.ts +32 -0
- package/lib/first_party/constants.js +39 -0
- package/lib/first_party/index.d.ts +4 -0
- package/lib/first_party/index.js +21 -0
- package/lib/first_party/utils.d.ts +8 -0
- package/lib/first_party/utils.js +27 -0
- package/lib/http/IHttpClient.d.ts +10 -0
- package/lib/http/IHttpClient.js +2 -0
- package/lib/http/body_reader/IBodyReader.d.ts +5 -0
- package/lib/http/body_reader/IBodyReader.js +2 -0
- package/lib/http/body_reader/StringBodyReader.d.ts +8 -0
- package/lib/http/body_reader/StringBodyReader.js +70 -0
- package/lib/http/index.d.ts +10 -0
- package/lib/http/index.js +28 -0
- package/lib/http/request/DefaultHttpRequest.d.ts +5 -0
- package/lib/http/request/DefaultHttpRequest.js +42 -0
- package/lib/http/request/HttpRequestBase.d.ts +24 -0
- package/lib/http/request/HttpRequestBase.js +77 -0
- package/lib/http/request/IHttpRequest.d.ts +31 -0
- package/lib/http/request/IHttpRequest.js +2 -0
- package/lib/http/response/DefaultHttpResponse.d.ts +5 -0
- package/lib/http/response/DefaultHttpResponse.js +32 -0
- package/lib/http/response/HttpResponseBase.d.ts +17 -0
- package/lib/http/response/HttpResponseBase.js +75 -0
- package/lib/http/response/IHttpResponse.d.ts +26 -0
- package/lib/http/response/IHttpResponse.js +2 -0
- package/lib/http/utils/ContentType.d.ts +9 -0
- package/lib/http/utils/ContentType.js +13 -0
- package/lib/http/utils/HttpBody.d.ts +4 -0
- package/lib/http/utils/HttpBody.js +2 -0
- package/lib/http/utils/HttpHeaders.d.ts +51 -0
- package/lib/http/utils/HttpHeaders.js +106 -0
- package/lib/http/utils/HttpMethod.d.ts +11 -0
- package/lib/http/utils/HttpMethod.js +15 -0
- package/lib/http/utils/constants.d.ts +9 -0
- package/lib/http/utils/constants.js +12 -0
- package/lib/http/utils/index.d.ts +5 -0
- package/lib/http/utils/index.js +24 -0
- package/lib/index.d.ts +17 -0
- package/lib/index.js +33 -0
- package/lib/logger/DefaultLogger.d.ts +7 -0
- package/lib/logger/DefaultLogger.js +31 -0
- package/lib/logger/ILogger.d.ts +24 -0
- package/lib/logger/ILogger.js +2 -0
- package/lib/logger/LoggerBase.d.ts +11 -0
- package/lib/logger/LoggerBase.js +28 -0
- package/lib/logger/LoggerSeverity.d.ts +5 -0
- package/lib/logger/LoggerSeverity.js +9 -0
- package/lib/logger/index.d.ts +4 -0
- package/lib/logger/index.js +9 -0
- package/lib/pxde/DefaultDataEnrichment.d.ts +14 -0
- package/lib/pxde/DefaultDataEnrichment.js +133 -0
- package/lib/pxde/IDataEnrichment.d.ts +9 -0
- package/lib/pxde/IDataEnrichment.js +2 -0
- package/lib/pxde/constants.d.ts +4 -0
- package/lib/pxde/constants.js +7 -0
- package/lib/pxde/index.d.ts +4 -0
- package/lib/pxde/index.js +20 -0
- package/lib/pxde/model/PXDE.d.ts +9 -0
- package/lib/pxde/model/PXDE.js +2 -0
- package/lib/pxhd/PXHDUtils.d.ts +8 -0
- package/lib/pxhd/PXHDUtils.js +20 -0
- package/lib/pxhd/index.d.ts +1 -0
- package/lib/pxhd/index.js +5 -0
- package/lib/risk_api/PostRiskApiClient.d.ts +27 -0
- package/lib/risk_api/PostRiskApiClient.js +232 -0
- package/lib/risk_api/S2SCallReason.d.ts +12 -0
- package/lib/risk_api/S2SCallReason.js +16 -0
- package/lib/risk_api/S2SErrorHandler.d.ts +9 -0
- package/lib/risk_api/S2SErrorHandler.js +121 -0
- package/lib/risk_api/S2SErrorReason.d.ts +8 -0
- package/lib/risk_api/S2SErrorReason.js +12 -0
- package/lib/risk_api/constants.d.ts +1 -0
- package/lib/risk_api/constants.js +4 -0
- package/lib/risk_api/index.d.ts +13 -0
- package/lib/risk_api/index.js +34 -0
- package/lib/risk_api/model/RiskActivity.d.ts +50 -0
- package/lib/risk_api/model/RiskActivity.js +2 -0
- package/lib/risk_api/model/RiskResponseV2.d.ts +10 -0
- package/lib/risk_api/model/RiskResponseV2.js +2 -0
- package/lib/risk_api/model/RiskResponseV3.d.ts +12 -0
- package/lib/risk_api/model/RiskResponseV3.js +2 -0
- package/lib/risk_api/model/RiskStatus.d.ts +4 -0
- package/lib/risk_api/model/RiskStatus.js +8 -0
- package/lib/risk_api/risk_response_handler/IRiskResponseHandler.d.ts +5 -0
- package/lib/risk_api/risk_response_handler/IRiskResponseHandler.js +2 -0
- package/lib/risk_api/risk_response_handler/RiskResponseHandlerBase.d.ts +16 -0
- package/lib/risk_api/risk_response_handler/RiskResponseHandlerBase.js +73 -0
- package/lib/risk_api/risk_response_handler/RiskResponseV2Handler.d.ts +10 -0
- package/lib/risk_api/risk_response_handler/RiskResponseV2Handler.js +46 -0
- package/lib/risk_api/risk_response_handler/RiskResponseV3Handler.d.ts +10 -0
- package/lib/risk_api/risk_response_handler/RiskResponseV3Handler.js +47 -0
- package/lib/risk_token/MobileError.d.ts +6 -0
- package/lib/risk_token/MobileError.js +10 -0
- package/lib/risk_token/MobileErrorHandler.d.ts +9 -0
- package/lib/risk_token/MobileErrorHandler.js +100 -0
- package/lib/risk_token/RiskTokenScoreRetriever.d.ts +14 -0
- package/lib/risk_token/RiskTokenScoreRetriever.js +148 -0
- package/lib/risk_token/TokenOrigin.d.ts +4 -0
- package/lib/risk_token/TokenOrigin.js +8 -0
- package/lib/risk_token/TokenVerificationResult.d.ts +6 -0
- package/lib/risk_token/TokenVerificationResult.js +10 -0
- package/lib/risk_token/TokenVersion.d.ts +4 -0
- package/lib/risk_token/TokenVersion.js +8 -0
- package/lib/risk_token/constants.d.ts +9 -0
- package/lib/risk_token/constants.js +12 -0
- package/lib/risk_token/index.d.ts +9 -0
- package/lib/risk_token/index.js +32 -0
- package/lib/risk_token/token/BotDefenderTokenBase.d.ts +27 -0
- package/lib/risk_token/token/BotDefenderTokenBase.js +94 -0
- package/lib/risk_token/token/IBotDefenderToken.d.ts +54 -0
- package/lib/risk_token/token/IBotDefenderToken.js +2 -0
- package/lib/risk_token/token/index.d.ts +7 -0
- package/lib/risk_token/token/index.js +11 -0
- package/lib/risk_token/token/v2/BotDefenderTokenV2Payload.d.ts +6 -0
- package/lib/risk_token/token/v2/BotDefenderTokenV2Payload.js +2 -0
- package/lib/risk_token/token/v2/DefaultBotDefenderTokenV2.d.ts +28 -0
- package/lib/risk_token/token/v2/DefaultBotDefenderTokenV2.js +199 -0
- package/lib/risk_token/token/v3/BotDefenderTokenV3Payload.d.ts +9 -0
- package/lib/risk_token/token/v3/BotDefenderTokenV3Payload.js +2 -0
- package/lib/risk_token/token/v3/DefaultBotDefenderTokenV3.d.ts +31 -0
- package/lib/risk_token/token/v3/DefaultBotDefenderTokenV3.js +231 -0
- package/lib/risk_token/token/v3/TokenSignField.d.ts +4 -0
- package/lib/risk_token/token/v3/TokenSignField.js +8 -0
- package/lib/risk_token/utils.d.ts +2 -0
- package/lib/risk_token/utils.js +16 -0
- package/lib/telemetry/DefaultTelemetry.d.ts +19 -0
- package/lib/telemetry/DefaultTelemetry.js +176 -0
- package/lib/telemetry/ITelemetry.d.ts +13 -0
- package/lib/telemetry/ITelemetry.js +2 -0
- package/lib/telemetry/constants.d.ts +7 -0
- package/lib/telemetry/constants.js +10 -0
- package/lib/telemetry/index.d.ts +4 -0
- package/lib/telemetry/index.js +20 -0
- package/lib/telemetry/model/TelemetryActivity.d.ts +15 -0
- package/lib/telemetry/model/TelemetryActivity.js +2 -0
- package/lib/utils/Algorithm.d.ts +4 -0
- package/lib/utils/Algorithm.js +8 -0
- package/lib/utils/EnforcerException.d.ts +3 -0
- package/lib/utils/EnforcerException.js +26 -0
- package/lib/utils/IScoreRetriever.d.ts +14 -0
- package/lib/utils/IScoreRetriever.js +2 -0
- package/lib/utils/ModuleMode.d.ts +4 -0
- package/lib/utils/ModuleMode.js +8 -0
- package/lib/utils/PassReason.d.ts +6 -0
- package/lib/utils/PassReason.js +10 -0
- package/lib/utils/VidSource.d.ts +4 -0
- package/lib/utils/VidSource.js +8 -0
- package/lib/utils/base64/DefaultBase64Utils.d.ts +5 -0
- package/lib/utils/base64/DefaultBase64Utils.js +16 -0
- package/lib/utils/base64/IBase64Utils.d.ts +4 -0
- package/lib/utils/base64/IBase64Utils.js +2 -0
- package/lib/utils/base64/index.d.ts +2 -0
- package/lib/utils/base64/index.js +5 -0
- package/lib/utils/cipher/ICipherUtils.d.ts +7 -0
- package/lib/utils/cipher/ICipherUtils.js +2 -0
- package/lib/utils/cipher/index.d.ts +1 -0
- package/lib/utils/cipher/index.js +2 -0
- package/lib/utils/constants.d.ts +10 -0
- package/lib/utils/constants.js +13 -0
- package/lib/utils/cookie_parser/DefaultCookieParser.d.ts +4 -0
- package/lib/utils/cookie_parser/DefaultCookieParser.js +13 -0
- package/lib/utils/cookie_parser/ICookieParser.d.ts +3 -0
- package/lib/utils/cookie_parser/ICookieParser.js +2 -0
- package/lib/utils/cookie_parser/index.d.ts +2 -0
- package/lib/utils/cookie_parser/index.js +5 -0
- package/lib/utils/hash/DefaultHashUtils.d.ts +5 -0
- package/lib/utils/hash/DefaultHashUtils.js +19 -0
- package/lib/utils/hash/IHashUtils.d.ts +4 -0
- package/lib/utils/hash/IHashUtils.js +2 -0
- package/lib/utils/hash/index.d.ts +2 -0
- package/lib/utils/hash/index.js +5 -0
- package/lib/utils/index.d.ts +14 -0
- package/lib/utils/index.js +35 -0
- package/lib/utils/ip_range_checker/DefaultIpRangeChecker.d.ts +4 -0
- package/lib/utils/ip_range_checker/DefaultIpRangeChecker.js +13 -0
- package/lib/utils/ip_range_checker/IIpRangeChecker.d.ts +3 -0
- package/lib/utils/ip_range_checker/IIpRangeChecker.js +2 -0
- package/lib/utils/ip_range_checker/index.d.ts +2 -0
- package/lib/utils/ip_range_checker/index.js +5 -0
- package/lib/utils/utils.d.ts +13 -0
- package/lib/utils/utils.js +91 -0
- package/lib/utils/uuid_generator/DefaultUuidGenerator.d.ts +4 -0
- package/lib/utils/uuid_generator/DefaultUuidGenerator.js +13 -0
- package/lib/utils/uuid_generator/IUuidGenerator.d.ts +3 -0
- package/lib/utils/uuid_generator/IUuidGenerator.js +2 -0
- package/lib/utils/uuid_generator/index.d.ts +2 -0
- package/lib/utils/uuid_generator/index.js +5 -0
- package/package.json +52 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { ModuleMode } from '../utils';
|
|
2
|
+
import { ILogger, LoggerSeverity } from '../logger';
|
|
3
|
+
import { CustomParametersFunction } from '../custom_parameters';
|
|
4
|
+
import { AdditionalActivityHandler } from '../additional_activity_handler';
|
|
5
|
+
import { ConfigurationParams } from './ConfigurationParams';
|
|
6
|
+
export interface IConfiguration<ParamsType extends ConfigurationParams = ConfigurationParams> {
|
|
7
|
+
/**
|
|
8
|
+
* The application ID.
|
|
9
|
+
*/
|
|
10
|
+
readonly appId: string;
|
|
11
|
+
/**
|
|
12
|
+
* The cookie secret used to decrypt the risk cookie.
|
|
13
|
+
*/
|
|
14
|
+
readonly cookieSecret: string;
|
|
15
|
+
/**
|
|
16
|
+
* The token used to authenticate with the Human/PerimeterX backend.
|
|
17
|
+
*/
|
|
18
|
+
readonly authToken: string;
|
|
19
|
+
/**
|
|
20
|
+
* Whether the enforcer is enabled.
|
|
21
|
+
*/
|
|
22
|
+
readonly moduleEnabled: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* The timeout for risk API calls, in milliseconds.
|
|
25
|
+
*/
|
|
26
|
+
readonly s2sTimeout: number;
|
|
27
|
+
/**
|
|
28
|
+
* An interface used to log enforcer debug and error messages.
|
|
29
|
+
*/
|
|
30
|
+
readonly logger: ILogger;
|
|
31
|
+
/**
|
|
32
|
+
* The logger severity level of the logger.
|
|
33
|
+
*/
|
|
34
|
+
readonly loggerSeverity: LoggerSeverity;
|
|
35
|
+
/**
|
|
36
|
+
* The default module mode of the enforcer.
|
|
37
|
+
*/
|
|
38
|
+
readonly moduleMode: ModuleMode;
|
|
39
|
+
/**
|
|
40
|
+
* An array of header names to remove from all requests to Human/PerimeterX backends.
|
|
41
|
+
*/
|
|
42
|
+
readonly sensitiveHeaders: string[];
|
|
43
|
+
/**
|
|
44
|
+
* An array of agents that should not go through the enforcer flow.
|
|
45
|
+
*/
|
|
46
|
+
readonly filteredUserAgents: string[];
|
|
47
|
+
/**
|
|
48
|
+
* An array of regular expressions or prefixes of routes that should not go through the enforcer flow.
|
|
49
|
+
*/
|
|
50
|
+
readonly filteredRoutes: string[];
|
|
51
|
+
/**
|
|
52
|
+
* An array of extensions that should not go through the enforcer flow.
|
|
53
|
+
*/
|
|
54
|
+
readonly filteredExtensions: string[];
|
|
55
|
+
/**
|
|
56
|
+
* An array of IP addresses that should not go through the enforcer flow.
|
|
57
|
+
*/
|
|
58
|
+
readonly filteredIps: string[];
|
|
59
|
+
/**
|
|
60
|
+
* An array of HTTP methods that should not go through the enforcer flow.
|
|
61
|
+
*/
|
|
62
|
+
readonly filteredHttpMethods: string[];
|
|
63
|
+
/**
|
|
64
|
+
* An array of header names from which to extract the request IP.
|
|
65
|
+
*/
|
|
66
|
+
readonly ipHeaders: string[];
|
|
67
|
+
/**
|
|
68
|
+
* An array of regular expressions or prefixes of routes that should go through the enforcer flow
|
|
69
|
+
* in active_blocking rather than monitor mode.
|
|
70
|
+
*/
|
|
71
|
+
readonly enforcedRoutes: string[];
|
|
72
|
+
/**
|
|
73
|
+
* An array of regular expressions or prefixes of routes that should trigger a risk API call
|
|
74
|
+
* even if a valid, unexpired, low-score risk cookie is present.
|
|
75
|
+
*/
|
|
76
|
+
readonly sensitiveRoutes: string[];
|
|
77
|
+
/**
|
|
78
|
+
* An array of regular expressions or prefixes of routes that should go through the enforcer flow
|
|
79
|
+
* in monitor rather than active_blocking mode.
|
|
80
|
+
*/
|
|
81
|
+
readonly monitoredRoutes: string[];
|
|
82
|
+
/**
|
|
83
|
+
* The name of the header that contains the PX cookies.
|
|
84
|
+
*/
|
|
85
|
+
readonly customCookieHeader: string;
|
|
86
|
+
/**
|
|
87
|
+
* Whether the enforcer should respond to first party endpoints.
|
|
88
|
+
*/
|
|
89
|
+
readonly firstPartyEnabled: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* The prefix to use for first party requests.
|
|
92
|
+
*/
|
|
93
|
+
readonly firstPartyPrefix: string;
|
|
94
|
+
/**
|
|
95
|
+
* Whether the enforcer should return a JSON block response in cases where the
|
|
96
|
+
* Accept header on the request includes application/json.
|
|
97
|
+
*/
|
|
98
|
+
readonly advancedBlockingResponseEnabled: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* The name of the header which, if present on the request with a value of 1, should
|
|
101
|
+
* trigger the request to go through the enforcer flow in active_blocking mode.
|
|
102
|
+
*/
|
|
103
|
+
readonly bypassMonitorHeader: string;
|
|
104
|
+
/**
|
|
105
|
+
* The origin the enforcer will use to make risk API requests.
|
|
106
|
+
*/
|
|
107
|
+
readonly backendScoreApiUrl: string;
|
|
108
|
+
/**
|
|
109
|
+
* The origin the enforcer will use to proxy captcha script requests.
|
|
110
|
+
*/
|
|
111
|
+
readonly backendCaptchaUrl: string;
|
|
112
|
+
/**
|
|
113
|
+
* The origin the enforcer will use to proxy sensor script requests.
|
|
114
|
+
*/
|
|
115
|
+
readonly backendClientUrl: string;
|
|
116
|
+
/**
|
|
117
|
+
* The origin the enforcer will use to send first-party XHR and async activities.
|
|
118
|
+
*/
|
|
119
|
+
readonly backendCollectorUrl: string;
|
|
120
|
+
/**
|
|
121
|
+
* An alternative third-party URL to retrieve the captcha script for the block page in case of error.
|
|
122
|
+
*/
|
|
123
|
+
readonly altBackendCaptchaUrl: string;
|
|
124
|
+
/**
|
|
125
|
+
* The name and version of the enforcer module.
|
|
126
|
+
*/
|
|
127
|
+
readonly moduleVersion: string;
|
|
128
|
+
/**
|
|
129
|
+
* The risk score at and above which the request should be blocked.
|
|
130
|
+
*/
|
|
131
|
+
readonly blockingScore: number;
|
|
132
|
+
/**
|
|
133
|
+
* A URL to a custom CSS file that should be added to the block page.
|
|
134
|
+
*/
|
|
135
|
+
readonly cssRef: string;
|
|
136
|
+
/**
|
|
137
|
+
* A URL to a custom JS file that should be added to the block page.
|
|
138
|
+
*/
|
|
139
|
+
readonly jsRef: string;
|
|
140
|
+
/**
|
|
141
|
+
* A URL to a custom logo that should be added to the block page.
|
|
142
|
+
*/
|
|
143
|
+
readonly customLogo: string;
|
|
144
|
+
/**
|
|
145
|
+
* The maximum expected iterations for PBKDF2. Used for Cookie v3 only.
|
|
146
|
+
*/
|
|
147
|
+
readonly riskCookieMaxIterations: number;
|
|
148
|
+
/**
|
|
149
|
+
* The minimum expected iterations for PBKDF2. Used for Cookie v3 only.
|
|
150
|
+
*/
|
|
151
|
+
readonly riskCookieMinIterations: number;
|
|
152
|
+
/**
|
|
153
|
+
* The maximum expected length of risk cookie beyond which it will not be processed.
|
|
154
|
+
*/
|
|
155
|
+
readonly riskCookieMaxLength: number;
|
|
156
|
+
/**
|
|
157
|
+
* The maximum expected length of the user-agent beyond which it will be truncated.
|
|
158
|
+
*/
|
|
159
|
+
readonly userAgentMaxLength: number;
|
|
160
|
+
/**
|
|
161
|
+
* A function returning CustomParameters that will be added to the enforcer activities.
|
|
162
|
+
*/
|
|
163
|
+
readonly enrichCustomParameters: CustomParametersFunction;
|
|
164
|
+
/**
|
|
165
|
+
* A function that will be called after the asynchronous activities are sent to the backend.
|
|
166
|
+
*/
|
|
167
|
+
readonly additionalActivityHandler: AdditionalActivityHandler;
|
|
168
|
+
/**
|
|
169
|
+
* Returns an object representation of the current configuration.
|
|
170
|
+
*/
|
|
171
|
+
toParams(): ParamsType;
|
|
172
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { IConfiguration } from './IConfiguration';
|
|
2
|
+
import { ConfigurationParams } from './ConfigurationParams';
|
|
3
|
+
import { CustomParametersFunction } from '../custom_parameters';
|
|
4
|
+
import { AdditionalActivityHandler } from '../additional_activity_handler';
|
|
5
|
+
import { ILogger, LoggerSeverity } from '../logger';
|
|
6
|
+
import { ModuleMode } from '../utils';
|
|
7
|
+
export declare abstract class StaticConfigurationBase<ParamsType extends ConfigurationParams = ConfigurationParams> implements IConfiguration<ParamsType> {
|
|
8
|
+
protected readonly configParams: ParamsType;
|
|
9
|
+
protected internalLogger: ILogger;
|
|
10
|
+
protected abstract getModuleVersion(): string;
|
|
11
|
+
protected constructor(params: ParamsType, defaultParams?: Partial<ParamsType>);
|
|
12
|
+
private initialize;
|
|
13
|
+
private throwIfMissingRequiredField;
|
|
14
|
+
private getValidConfigValue;
|
|
15
|
+
private isValidConfigValue;
|
|
16
|
+
private getDefaultConfigurationValue;
|
|
17
|
+
toParams(): ParamsType;
|
|
18
|
+
get moduleVersion(): string;
|
|
19
|
+
get logger(): ILogger;
|
|
20
|
+
get appId(): string;
|
|
21
|
+
get authToken(): string;
|
|
22
|
+
get blockingScore(): number;
|
|
23
|
+
get bypassMonitorHeader(): string;
|
|
24
|
+
get cookieSecret(): string;
|
|
25
|
+
get customCookieHeader(): string;
|
|
26
|
+
get customLogo(): string;
|
|
27
|
+
get enforcedRoutes(): string[];
|
|
28
|
+
get filteredExtensions(): string[];
|
|
29
|
+
get filteredHttpMethods(): string[];
|
|
30
|
+
get filteredIps(): string[];
|
|
31
|
+
get filteredRoutes(): string[];
|
|
32
|
+
get filteredUserAgents(): string[];
|
|
33
|
+
get firstPartyEnabled(): boolean;
|
|
34
|
+
get firstPartyPrefix(): string;
|
|
35
|
+
get loggerSeverity(): LoggerSeverity;
|
|
36
|
+
get moduleEnabled(): boolean;
|
|
37
|
+
get moduleMode(): ModuleMode;
|
|
38
|
+
get monitoredRoutes(): string[];
|
|
39
|
+
get s2sTimeout(): number;
|
|
40
|
+
get sensitiveHeaders(): string[];
|
|
41
|
+
get sensitiveRoutes(): string[];
|
|
42
|
+
get advancedBlockingResponseEnabled(): boolean;
|
|
43
|
+
get backendScoreApiUrl(): string;
|
|
44
|
+
get ipHeaders(): string[];
|
|
45
|
+
get backendCaptchaUrl(): string;
|
|
46
|
+
get backendClientUrl(): string;
|
|
47
|
+
get backendCollectorUrl(): string;
|
|
48
|
+
get cssRef(): string;
|
|
49
|
+
get jsRef(): string;
|
|
50
|
+
get riskCookieMaxIterations(): number;
|
|
51
|
+
get riskCookieMinIterations(): number;
|
|
52
|
+
get riskCookieMaxLength(): number;
|
|
53
|
+
get userAgentMaxLength(): number;
|
|
54
|
+
get enrichCustomParameters(): CustomParametersFunction;
|
|
55
|
+
get additionalActivityHandler(): AdditionalActivityHandler;
|
|
56
|
+
get altBackendCaptchaUrl(): string;
|
|
57
|
+
}
|
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.StaticConfigurationBase = void 0;
|
|
15
|
+
var DefaultConfigurations_1 = require("./DefaultConfigurations");
|
|
16
|
+
var logger_1 = require("../logger");
|
|
17
|
+
var utils_1 = require("../utils");
|
|
18
|
+
var first_party_1 = require("../first_party");
|
|
19
|
+
var StaticConfigurationBase = /** @class */ (function () {
|
|
20
|
+
function StaticConfigurationBase(params, defaultParams) {
|
|
21
|
+
this.configParams = this.initialize(params, __assign(__assign({}, DefaultConfigurations_1.DEFAULT_CONFIGURATIONS), defaultParams));
|
|
22
|
+
this.internalLogger = new logger_1.DefaultLogger(this.configParams.px_logger_severity);
|
|
23
|
+
}
|
|
24
|
+
StaticConfigurationBase.prototype.initialize = function (params, defaultParams) {
|
|
25
|
+
var _this = this;
|
|
26
|
+
this.throwIfMissingRequiredField(params);
|
|
27
|
+
var config = {};
|
|
28
|
+
Object.keys(defaultParams).forEach(function (k) {
|
|
29
|
+
config[k] = _this.getValidConfigValue(params, defaultParams, k);
|
|
30
|
+
});
|
|
31
|
+
return config;
|
|
32
|
+
};
|
|
33
|
+
StaticConfigurationBase.prototype.throwIfMissingRequiredField = function (params) {
|
|
34
|
+
var REQUIRED_FIELDS = ['px_app_id', 'px_cookie_secret', 'px_auth_token'];
|
|
35
|
+
REQUIRED_FIELDS.forEach(function (key) {
|
|
36
|
+
if (!params[key]) {
|
|
37
|
+
throw new utils_1.EnforcerException("".concat(key, " cannot be empty!"));
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
StaticConfigurationBase.prototype.getValidConfigValue = function (params, defaultParams, key) {
|
|
42
|
+
if (params[key] != null && this.isValidConfigValue(params, defaultParams, key)) {
|
|
43
|
+
return params[key];
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
return this.getDefaultConfigurationValue(params, defaultParams, key);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
StaticConfigurationBase.prototype.isValidConfigValue = function (params, defaultParams, key) {
|
|
50
|
+
switch (key) {
|
|
51
|
+
case 'px_logger_severity':
|
|
52
|
+
return (0, utils_1.isValidEnumValue)(logger_1.LoggerSeverity, params[key]);
|
|
53
|
+
case 'px_module_mode':
|
|
54
|
+
return (0, utils_1.isValidEnumValue)(utils_1.ModuleMode, params[key]);
|
|
55
|
+
default:
|
|
56
|
+
if (defaultParams[key] === null) {
|
|
57
|
+
return typeof params[key] === 'function';
|
|
58
|
+
}
|
|
59
|
+
if (Array.isArray(defaultParams[key])) {
|
|
60
|
+
return Array.isArray(params[key]);
|
|
61
|
+
}
|
|
62
|
+
return typeof params[key] === typeof defaultParams[key];
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
StaticConfigurationBase.prototype.getDefaultConfigurationValue = function (params, defaultParams, key) {
|
|
66
|
+
switch (key) {
|
|
67
|
+
case 'px_backend_url':
|
|
68
|
+
return "https://".concat((0, utils_1.getScoreApiDomain)(params.px_app_id));
|
|
69
|
+
case 'px_backend_collector_url':
|
|
70
|
+
return "https://".concat((0, utils_1.getCollectorDomain)(params.px_app_id));
|
|
71
|
+
case 'px_first_party_prefix':
|
|
72
|
+
return (0, first_party_1.getDefaultFirstPartyPrefix)(params.px_app_id);
|
|
73
|
+
default:
|
|
74
|
+
return defaultParams[key];
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
StaticConfigurationBase.prototype.toParams = function () {
|
|
78
|
+
return Object.assign({}, this.configParams);
|
|
79
|
+
};
|
|
80
|
+
Object.defineProperty(StaticConfigurationBase.prototype, "moduleVersion", {
|
|
81
|
+
get: function () {
|
|
82
|
+
return "".concat(this.getModuleVersion(), " (").concat(utils_1.CORE_MODULE_VERSION, ")");
|
|
83
|
+
},
|
|
84
|
+
enumerable: false,
|
|
85
|
+
configurable: true
|
|
86
|
+
});
|
|
87
|
+
Object.defineProperty(StaticConfigurationBase.prototype, "logger", {
|
|
88
|
+
get: function () {
|
|
89
|
+
return this.internalLogger;
|
|
90
|
+
},
|
|
91
|
+
enumerable: false,
|
|
92
|
+
configurable: true
|
|
93
|
+
});
|
|
94
|
+
Object.defineProperty(StaticConfigurationBase.prototype, "appId", {
|
|
95
|
+
get: function () {
|
|
96
|
+
return this.configParams.px_app_id;
|
|
97
|
+
},
|
|
98
|
+
enumerable: false,
|
|
99
|
+
configurable: true
|
|
100
|
+
});
|
|
101
|
+
Object.defineProperty(StaticConfigurationBase.prototype, "authToken", {
|
|
102
|
+
get: function () {
|
|
103
|
+
return this.configParams.px_auth_token;
|
|
104
|
+
},
|
|
105
|
+
enumerable: false,
|
|
106
|
+
configurable: true
|
|
107
|
+
});
|
|
108
|
+
Object.defineProperty(StaticConfigurationBase.prototype, "blockingScore", {
|
|
109
|
+
get: function () {
|
|
110
|
+
return this.configParams.px_blocking_score;
|
|
111
|
+
},
|
|
112
|
+
enumerable: false,
|
|
113
|
+
configurable: true
|
|
114
|
+
});
|
|
115
|
+
Object.defineProperty(StaticConfigurationBase.prototype, "bypassMonitorHeader", {
|
|
116
|
+
get: function () {
|
|
117
|
+
return this.configParams.px_bypass_monitor_header;
|
|
118
|
+
},
|
|
119
|
+
enumerable: false,
|
|
120
|
+
configurable: true
|
|
121
|
+
});
|
|
122
|
+
Object.defineProperty(StaticConfigurationBase.prototype, "cookieSecret", {
|
|
123
|
+
get: function () {
|
|
124
|
+
return this.configParams.px_cookie_secret;
|
|
125
|
+
},
|
|
126
|
+
enumerable: false,
|
|
127
|
+
configurable: true
|
|
128
|
+
});
|
|
129
|
+
Object.defineProperty(StaticConfigurationBase.prototype, "customCookieHeader", {
|
|
130
|
+
get: function () {
|
|
131
|
+
return this.configParams.px_custom_cookie_header;
|
|
132
|
+
},
|
|
133
|
+
enumerable: false,
|
|
134
|
+
configurable: true
|
|
135
|
+
});
|
|
136
|
+
Object.defineProperty(StaticConfigurationBase.prototype, "customLogo", {
|
|
137
|
+
get: function () {
|
|
138
|
+
return this.configParams.px_custom_logo;
|
|
139
|
+
},
|
|
140
|
+
enumerable: false,
|
|
141
|
+
configurable: true
|
|
142
|
+
});
|
|
143
|
+
Object.defineProperty(StaticConfigurationBase.prototype, "enforcedRoutes", {
|
|
144
|
+
get: function () {
|
|
145
|
+
return this.configParams.px_enforced_routes;
|
|
146
|
+
},
|
|
147
|
+
enumerable: false,
|
|
148
|
+
configurable: true
|
|
149
|
+
});
|
|
150
|
+
Object.defineProperty(StaticConfigurationBase.prototype, "filteredExtensions", {
|
|
151
|
+
get: function () {
|
|
152
|
+
return this.configParams.px_filter_by_extension.map(function (ext) { return (ext.startsWith('.') ? ext : ".".concat(ext)); });
|
|
153
|
+
},
|
|
154
|
+
enumerable: false,
|
|
155
|
+
configurable: true
|
|
156
|
+
});
|
|
157
|
+
Object.defineProperty(StaticConfigurationBase.prototype, "filteredHttpMethods", {
|
|
158
|
+
get: function () {
|
|
159
|
+
return this.configParams.px_filter_by_http_method;
|
|
160
|
+
},
|
|
161
|
+
enumerable: false,
|
|
162
|
+
configurable: true
|
|
163
|
+
});
|
|
164
|
+
Object.defineProperty(StaticConfigurationBase.prototype, "filteredIps", {
|
|
165
|
+
get: function () {
|
|
166
|
+
return this.configParams.px_filter_by_ip;
|
|
167
|
+
},
|
|
168
|
+
enumerable: false,
|
|
169
|
+
configurable: true
|
|
170
|
+
});
|
|
171
|
+
Object.defineProperty(StaticConfigurationBase.prototype, "filteredRoutes", {
|
|
172
|
+
get: function () {
|
|
173
|
+
return this.configParams.px_filter_by_route;
|
|
174
|
+
},
|
|
175
|
+
enumerable: false,
|
|
176
|
+
configurable: true
|
|
177
|
+
});
|
|
178
|
+
Object.defineProperty(StaticConfigurationBase.prototype, "filteredUserAgents", {
|
|
179
|
+
get: function () {
|
|
180
|
+
return this.configParams.px_filter_by_user_agent;
|
|
181
|
+
},
|
|
182
|
+
enumerable: false,
|
|
183
|
+
configurable: true
|
|
184
|
+
});
|
|
185
|
+
Object.defineProperty(StaticConfigurationBase.prototype, "firstPartyEnabled", {
|
|
186
|
+
get: function () {
|
|
187
|
+
return this.configParams.px_first_party_enabled;
|
|
188
|
+
},
|
|
189
|
+
enumerable: false,
|
|
190
|
+
configurable: true
|
|
191
|
+
});
|
|
192
|
+
Object.defineProperty(StaticConfigurationBase.prototype, "firstPartyPrefix", {
|
|
193
|
+
get: function () {
|
|
194
|
+
return this.configParams.px_first_party_prefix;
|
|
195
|
+
},
|
|
196
|
+
enumerable: false,
|
|
197
|
+
configurable: true
|
|
198
|
+
});
|
|
199
|
+
Object.defineProperty(StaticConfigurationBase.prototype, "loggerSeverity", {
|
|
200
|
+
get: function () {
|
|
201
|
+
return this.logger.getLoggerSeverity();
|
|
202
|
+
},
|
|
203
|
+
enumerable: false,
|
|
204
|
+
configurable: true
|
|
205
|
+
});
|
|
206
|
+
Object.defineProperty(StaticConfigurationBase.prototype, "moduleEnabled", {
|
|
207
|
+
get: function () {
|
|
208
|
+
return this.configParams.px_module_enabled;
|
|
209
|
+
},
|
|
210
|
+
enumerable: false,
|
|
211
|
+
configurable: true
|
|
212
|
+
});
|
|
213
|
+
Object.defineProperty(StaticConfigurationBase.prototype, "moduleMode", {
|
|
214
|
+
get: function () {
|
|
215
|
+
return this.configParams.px_module_mode;
|
|
216
|
+
},
|
|
217
|
+
enumerable: false,
|
|
218
|
+
configurable: true
|
|
219
|
+
});
|
|
220
|
+
Object.defineProperty(StaticConfigurationBase.prototype, "monitoredRoutes", {
|
|
221
|
+
get: function () {
|
|
222
|
+
return this.configParams.px_monitored_routes;
|
|
223
|
+
},
|
|
224
|
+
enumerable: false,
|
|
225
|
+
configurable: true
|
|
226
|
+
});
|
|
227
|
+
Object.defineProperty(StaticConfigurationBase.prototype, "s2sTimeout", {
|
|
228
|
+
get: function () {
|
|
229
|
+
return this.configParams.px_s2s_timeout;
|
|
230
|
+
},
|
|
231
|
+
enumerable: false,
|
|
232
|
+
configurable: true
|
|
233
|
+
});
|
|
234
|
+
Object.defineProperty(StaticConfigurationBase.prototype, "sensitiveHeaders", {
|
|
235
|
+
get: function () {
|
|
236
|
+
return this.configParams.px_sensitive_headers;
|
|
237
|
+
},
|
|
238
|
+
enumerable: false,
|
|
239
|
+
configurable: true
|
|
240
|
+
});
|
|
241
|
+
Object.defineProperty(StaticConfigurationBase.prototype, "sensitiveRoutes", {
|
|
242
|
+
get: function () {
|
|
243
|
+
return this.configParams.px_sensitive_routes;
|
|
244
|
+
},
|
|
245
|
+
enumerable: false,
|
|
246
|
+
configurable: true
|
|
247
|
+
});
|
|
248
|
+
Object.defineProperty(StaticConfigurationBase.prototype, "advancedBlockingResponseEnabled", {
|
|
249
|
+
get: function () {
|
|
250
|
+
return this.configParams.px_advanced_blocking_response_enabled;
|
|
251
|
+
},
|
|
252
|
+
enumerable: false,
|
|
253
|
+
configurable: true
|
|
254
|
+
});
|
|
255
|
+
Object.defineProperty(StaticConfigurationBase.prototype, "backendScoreApiUrl", {
|
|
256
|
+
get: function () {
|
|
257
|
+
return this.configParams.px_backend_url;
|
|
258
|
+
},
|
|
259
|
+
enumerable: false,
|
|
260
|
+
configurable: true
|
|
261
|
+
});
|
|
262
|
+
Object.defineProperty(StaticConfigurationBase.prototype, "ipHeaders", {
|
|
263
|
+
get: function () {
|
|
264
|
+
return this.configParams.px_ip_headers;
|
|
265
|
+
},
|
|
266
|
+
enumerable: false,
|
|
267
|
+
configurable: true
|
|
268
|
+
});
|
|
269
|
+
Object.defineProperty(StaticConfigurationBase.prototype, "backendCaptchaUrl", {
|
|
270
|
+
get: function () {
|
|
271
|
+
return this.configParams.px_backend_captcha_url;
|
|
272
|
+
},
|
|
273
|
+
enumerable: false,
|
|
274
|
+
configurable: true
|
|
275
|
+
});
|
|
276
|
+
Object.defineProperty(StaticConfigurationBase.prototype, "backendClientUrl", {
|
|
277
|
+
get: function () {
|
|
278
|
+
return this.configParams.px_backend_client_url;
|
|
279
|
+
},
|
|
280
|
+
enumerable: false,
|
|
281
|
+
configurable: true
|
|
282
|
+
});
|
|
283
|
+
Object.defineProperty(StaticConfigurationBase.prototype, "backendCollectorUrl", {
|
|
284
|
+
get: function () {
|
|
285
|
+
return this.configParams.px_backend_collector_url;
|
|
286
|
+
},
|
|
287
|
+
enumerable: false,
|
|
288
|
+
configurable: true
|
|
289
|
+
});
|
|
290
|
+
Object.defineProperty(StaticConfigurationBase.prototype, "cssRef", {
|
|
291
|
+
get: function () {
|
|
292
|
+
return this.configParams.px_css_ref;
|
|
293
|
+
},
|
|
294
|
+
enumerable: false,
|
|
295
|
+
configurable: true
|
|
296
|
+
});
|
|
297
|
+
Object.defineProperty(StaticConfigurationBase.prototype, "jsRef", {
|
|
298
|
+
get: function () {
|
|
299
|
+
return this.configParams.px_js_ref;
|
|
300
|
+
},
|
|
301
|
+
enumerable: false,
|
|
302
|
+
configurable: true
|
|
303
|
+
});
|
|
304
|
+
Object.defineProperty(StaticConfigurationBase.prototype, "riskCookieMaxIterations", {
|
|
305
|
+
get: function () {
|
|
306
|
+
return this.configParams.px_risk_cookie_max_iterations;
|
|
307
|
+
},
|
|
308
|
+
enumerable: false,
|
|
309
|
+
configurable: true
|
|
310
|
+
});
|
|
311
|
+
Object.defineProperty(StaticConfigurationBase.prototype, "riskCookieMinIterations", {
|
|
312
|
+
get: function () {
|
|
313
|
+
return this.configParams.px_risk_cookie_min_iterations;
|
|
314
|
+
},
|
|
315
|
+
enumerable: false,
|
|
316
|
+
configurable: true
|
|
317
|
+
});
|
|
318
|
+
Object.defineProperty(StaticConfigurationBase.prototype, "riskCookieMaxLength", {
|
|
319
|
+
get: function () {
|
|
320
|
+
return this.configParams.px_risk_cookie_max_length;
|
|
321
|
+
},
|
|
322
|
+
enumerable: false,
|
|
323
|
+
configurable: true
|
|
324
|
+
});
|
|
325
|
+
Object.defineProperty(StaticConfigurationBase.prototype, "userAgentMaxLength", {
|
|
326
|
+
get: function () {
|
|
327
|
+
return this.configParams.px_user_agent_max_length;
|
|
328
|
+
},
|
|
329
|
+
enumerable: false,
|
|
330
|
+
configurable: true
|
|
331
|
+
});
|
|
332
|
+
Object.defineProperty(StaticConfigurationBase.prototype, "enrichCustomParameters", {
|
|
333
|
+
get: function () {
|
|
334
|
+
return this.configParams.px_enrich_custom_parameters || null;
|
|
335
|
+
},
|
|
336
|
+
enumerable: false,
|
|
337
|
+
configurable: true
|
|
338
|
+
});
|
|
339
|
+
Object.defineProperty(StaticConfigurationBase.prototype, "additionalActivityHandler", {
|
|
340
|
+
get: function () {
|
|
341
|
+
return this.configParams.px_additional_activity_handler || null;
|
|
342
|
+
},
|
|
343
|
+
enumerable: false,
|
|
344
|
+
configurable: true
|
|
345
|
+
});
|
|
346
|
+
Object.defineProperty(StaticConfigurationBase.prototype, "altBackendCaptchaUrl", {
|
|
347
|
+
get: function () {
|
|
348
|
+
return 'https://captcha.px-cloud.net';
|
|
349
|
+
},
|
|
350
|
+
enumerable: false,
|
|
351
|
+
configurable: true
|
|
352
|
+
});
|
|
353
|
+
return StaticConfigurationBase;
|
|
354
|
+
}());
|
|
355
|
+
exports.StaticConfigurationBase = StaticConfigurationBase;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StaticConfigurationBase = exports.DEFAULT_CONFIGURATIONS = void 0;
|
|
4
|
+
var DefaultConfigurations_1 = require("./DefaultConfigurations");
|
|
5
|
+
Object.defineProperty(exports, "DEFAULT_CONFIGURATIONS", { enumerable: true, get: function () { return DefaultConfigurations_1.DEFAULT_CONFIGURATIONS; } });
|
|
6
|
+
var StaticConfigurationBase_1 = require("./StaticConfigurationBase");
|
|
7
|
+
Object.defineProperty(exports, "StaticConfigurationBase", { enumerable: true, get: function () { return StaticConfigurationBase_1.StaticConfigurationBase; } });
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { IConfiguration } from '../config';
|
|
2
|
+
import { BlockReason, BlockAction } from '../block_handler';
|
|
3
|
+
import { CustomParameters } from '../custom_parameters';
|
|
4
|
+
import { FilterReason } from '../filter';
|
|
5
|
+
import { IHttpRequest, HttpHeaders } from '../http';
|
|
6
|
+
import { PXDE } from '../pxde';
|
|
7
|
+
import { IBotDefenderToken, TokenOrigin } from '../risk_token';
|
|
8
|
+
import { VidSource, PassReason, ICookieParser, IUuidGenerator } from '../utils';
|
|
9
|
+
import { IContext, MobileData, RequestData, ResponseData, RiskApiData, ServerData, TlsData } from './IContext';
|
|
10
|
+
export declare type ContextBaseOptions = {
|
|
11
|
+
cookieParser?: ICookieParser;
|
|
12
|
+
uuidGenerator?: IUuidGenerator;
|
|
13
|
+
};
|
|
14
|
+
export declare abstract class ContextBase<OptionsType extends ContextBaseOptions> implements IContext {
|
|
15
|
+
readonly requestId: string;
|
|
16
|
+
readonly requestData: RequestData;
|
|
17
|
+
readonly responseData: ResponseData;
|
|
18
|
+
readonly mobileData: MobileData;
|
|
19
|
+
readonly riskApiData: RiskApiData;
|
|
20
|
+
readonly tlsData: TlsData;
|
|
21
|
+
readonly serverData: ServerData;
|
|
22
|
+
uuid: string;
|
|
23
|
+
vid?: string;
|
|
24
|
+
vidSource?: VidSource;
|
|
25
|
+
isMonitoredRequest: boolean;
|
|
26
|
+
isSensitiveRequest: boolean;
|
|
27
|
+
score?: number;
|
|
28
|
+
passReason?: PassReason;
|
|
29
|
+
blockReason?: BlockReason;
|
|
30
|
+
blockAction?: BlockAction;
|
|
31
|
+
filterReason?: FilterReason;
|
|
32
|
+
tokenOrigin?: TokenOrigin;
|
|
33
|
+
riskToken?: IBotDefenderToken;
|
|
34
|
+
pxhd?: string;
|
|
35
|
+
pxde?: PXDE;
|
|
36
|
+
pxdeVerified?: boolean;
|
|
37
|
+
customParameters?: CustomParameters;
|
|
38
|
+
protected readonly config: IConfiguration;
|
|
39
|
+
protected constructor(config: IConfiguration, request: IHttpRequest, options?: OptionsType);
|
|
40
|
+
protected abstract createRiskToken(config: IConfiguration, cookies: Record<string, string>, options: OptionsType): IBotDefenderToken;
|
|
41
|
+
protected createRequestData(config: IConfiguration, request: IHttpRequest, cookieParser?: ICookieParser): RequestData;
|
|
42
|
+
protected extractUserAgentFromHeader(config: IConfiguration, headers: HttpHeaders): string;
|
|
43
|
+
protected extractIpFromHeader(config: IConfiguration, headers: HttpHeaders): string;
|
|
44
|
+
protected isMonitored(config: IConfiguration, requestData: RequestData): boolean;
|
|
45
|
+
protected isSensitive(config: IConfiguration, { url }: RequestData): boolean;
|
|
46
|
+
protected isAllowedToBypassMonitor(config: IConfiguration, requestData: RequestData): boolean;
|
|
47
|
+
completeInitialization(): Promise<void>;
|
|
48
|
+
protected setRiskTokenOnContext(config: IConfiguration, options: OptionsType): void;
|
|
49
|
+
protected setMobileTokenOnContext(config: IConfiguration, mobileToken: string, options: OptionsType): void;
|
|
50
|
+
protected setWebTokenOnContext(config: IConfiguration, options: OptionsType): void;
|
|
51
|
+
protected setCookiesOnContext(): void;
|
|
52
|
+
protected getMobileToken(config: IConfiguration, mobileToken: string, options: OptionsType): IBotDefenderToken;
|
|
53
|
+
protected handleCustomParameters(config: IConfiguration, request: IHttpRequest): Promise<void>;
|
|
54
|
+
get isMobile(): boolean;
|
|
55
|
+
}
|