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,206 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
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;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.ContextBase = void 0;
|
|
40
|
+
var block_handler_1 = require("../block_handler");
|
|
41
|
+
var custom_parameters_1 = require("../custom_parameters");
|
|
42
|
+
var http_1 = require("../http");
|
|
43
|
+
var risk_token_1 = require("../risk_token");
|
|
44
|
+
var utils_1 = require("../utils");
|
|
45
|
+
var ContextBase = /** @class */ (function () {
|
|
46
|
+
function ContextBase(config, request, options) {
|
|
47
|
+
this.config = config;
|
|
48
|
+
this.mobileData = {};
|
|
49
|
+
this.riskApiData = {};
|
|
50
|
+
this.tlsData = {};
|
|
51
|
+
this.responseData = {};
|
|
52
|
+
this.serverData = {};
|
|
53
|
+
this.requestId = ((options === null || options === void 0 ? void 0 : options.uuidGenerator) || new utils_1.DefaultUuidGenerator()).generateUuidV4();
|
|
54
|
+
this.tokenOrigin = risk_token_1.TokenOrigin.COOKIE;
|
|
55
|
+
this.blockAction = block_handler_1.BlockAction.CAPTCHA;
|
|
56
|
+
this.pxdeVerified = false;
|
|
57
|
+
this.requestData = this.createRequestData(config, request, options === null || options === void 0 ? void 0 : options.cookieParser);
|
|
58
|
+
this.isMonitoredRequest = this.isMonitored(config, this.requestData);
|
|
59
|
+
this.isSensitiveRequest = this.isSensitive(config, this.requestData);
|
|
60
|
+
this.setRiskTokenOnContext(config, options);
|
|
61
|
+
if (!this.isMobile) {
|
|
62
|
+
this.setCookiesOnContext();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
ContextBase.prototype.createRequestData = function (config, request, cookieParser) {
|
|
66
|
+
var _a;
|
|
67
|
+
if (cookieParser === void 0) { cookieParser = new utils_1.DefaultCookieParser(); }
|
|
68
|
+
var url = (0, utils_1.getDecodedUrl)(request.url);
|
|
69
|
+
var method = request.method;
|
|
70
|
+
var headers = request.headers;
|
|
71
|
+
var cookieHeaderValue = ((_a = request.headers.get(config.customCookieHeader || http_1.COOKIE_HEADER_NAME)) === null || _a === void 0 ? void 0 : _a[0]) || '';
|
|
72
|
+
var cookies = cookieHeaderValue ? cookieParser.parseCookies(cookieHeaderValue) : {};
|
|
73
|
+
var requestCookieNames = Object.keys(cookies);
|
|
74
|
+
var userAgent = this.extractUserAgentFromHeader(config, headers);
|
|
75
|
+
var ip = this.extractIpFromHeader(config, headers);
|
|
76
|
+
return { url: url, method: method, headers: headers, cookies: cookies, ip: ip, userAgent: userAgent, requestCookieNames: requestCookieNames, request: request };
|
|
77
|
+
};
|
|
78
|
+
ContextBase.prototype.extractUserAgentFromHeader = function (config, headers) {
|
|
79
|
+
var _a;
|
|
80
|
+
var userAgent = ((_a = headers === null || headers === void 0 ? void 0 : headers.get(http_1.USER_AGENT_HEADER_NAME)) === null || _a === void 0 ? void 0 : _a[0]) || '';
|
|
81
|
+
if (userAgent.length > config.userAgentMaxLength) {
|
|
82
|
+
userAgent = userAgent.substring(0, config.userAgentMaxLength);
|
|
83
|
+
}
|
|
84
|
+
return userAgent;
|
|
85
|
+
};
|
|
86
|
+
ContextBase.prototype.extractIpFromHeader = function (config, headers) {
|
|
87
|
+
var ip;
|
|
88
|
+
config.ipHeaders.some(function (ipHeader) {
|
|
89
|
+
var _a;
|
|
90
|
+
var headerValue = (_a = headers.get(ipHeader)) === null || _a === void 0 ? void 0 : _a[0];
|
|
91
|
+
if (headerValue) {
|
|
92
|
+
ip = headerValue;
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
return ip;
|
|
97
|
+
};
|
|
98
|
+
ContextBase.prototype.isMonitored = function (config, requestData) {
|
|
99
|
+
var pathname = requestData.url.pathname;
|
|
100
|
+
var enforcedRoute = (0, utils_1.isRouteInPatterns)(pathname, config.enforcedRoutes);
|
|
101
|
+
var monitoredRoute = !enforcedRoute && (0, utils_1.isRouteInPatterns)(pathname, config.monitoredRoutes);
|
|
102
|
+
var monitorMode = config.moduleMode === utils_1.ModuleMode.MONITOR && !enforcedRoute;
|
|
103
|
+
return (monitorMode || monitoredRoute) && !this.isAllowedToBypassMonitor(config, requestData);
|
|
104
|
+
};
|
|
105
|
+
ContextBase.prototype.isSensitive = function (config, _a) {
|
|
106
|
+
var url = _a.url;
|
|
107
|
+
return (0, utils_1.isRouteInPatterns)(url.pathname, config.sensitiveRoutes);
|
|
108
|
+
};
|
|
109
|
+
ContextBase.prototype.isAllowedToBypassMonitor = function (config, requestData) {
|
|
110
|
+
var _a;
|
|
111
|
+
return (config.bypassMonitorHeader &&
|
|
112
|
+
((_a = requestData.headers.get(config.bypassMonitorHeader)) === null || _a === void 0 ? void 0 : _a[0]) === utils_1.BYPASS_MONITOR_HEADER_VALUE);
|
|
113
|
+
};
|
|
114
|
+
ContextBase.prototype.completeInitialization = function () {
|
|
115
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
116
|
+
return __generator(this, function (_a) {
|
|
117
|
+
switch (_a.label) {
|
|
118
|
+
case 0: return [4 /*yield*/, this.handleCustomParameters(this.config, this.requestData.request)];
|
|
119
|
+
case 1:
|
|
120
|
+
_a.sent();
|
|
121
|
+
return [2 /*return*/];
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
ContextBase.prototype.setRiskTokenOnContext = function (config, options) {
|
|
127
|
+
var _a;
|
|
128
|
+
var mobileToken = (_a = this.requestData.headers.get(utils_1.X_PX_AUTHORIZATION_HEADER_NAME)) === null || _a === void 0 ? void 0 : _a[0];
|
|
129
|
+
if (mobileToken) {
|
|
130
|
+
this.setMobileTokenOnContext(config, mobileToken, options);
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
this.setWebTokenOnContext(config, options);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
ContextBase.prototype.setMobileTokenOnContext = function (config, mobileToken, options) {
|
|
137
|
+
var _a, _b;
|
|
138
|
+
this.tokenOrigin = risk_token_1.TokenOrigin.HEADER;
|
|
139
|
+
this.riskToken = this.getMobileToken(config, mobileToken, options);
|
|
140
|
+
this.mobileData.originalToken = this.getMobileToken(config, (_a = this.requestData.headers.get(utils_1.X_PX_ORIGINAL_TOKEN_HEADER_NAME)) === null || _a === void 0 ? void 0 : _a[0], options);
|
|
141
|
+
this.mobileData.bypassReason = ((_b = this.requestData.headers.get(utils_1.X_PX_BYPASS_REASON_HEADER_NAME)) === null || _b === void 0 ? void 0 : _b[0]) || '';
|
|
142
|
+
if (!this.riskToken && /^\d+$/.test(mobileToken)) {
|
|
143
|
+
this.mobileData.mobileError = mobileToken;
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
ContextBase.prototype.setWebTokenOnContext = function (config, options) {
|
|
147
|
+
this.tokenOrigin = risk_token_1.TokenOrigin.COOKIE;
|
|
148
|
+
this.riskToken = this.createRiskToken(config, this.requestData.cookies, options);
|
|
149
|
+
};
|
|
150
|
+
ContextBase.prototype.setCookiesOnContext = function () {
|
|
151
|
+
this.vid = this.requestData.cookies[utils_1.PXVID_COOKIE_NAME] || '';
|
|
152
|
+
this.pxhd = this.requestData.cookies[utils_1.PXHD_COOKIE_NAME] || '';
|
|
153
|
+
};
|
|
154
|
+
ContextBase.prototype.getMobileToken = function (config, mobileToken, options) {
|
|
155
|
+
var _a;
|
|
156
|
+
try {
|
|
157
|
+
if (!mobileToken || (mobileToken === null || mobileToken === void 0 ? void 0 : mobileToken.indexOf(risk_token_1.COOKIE_SPLIT_DELIMITER)) === -1) {
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
var _b = mobileToken.split(risk_token_1.COOKIE_SPLIT_DELIMITER), tokenVersion = _b[0], cookieString = _b.slice(1);
|
|
161
|
+
var cookieName = (0, risk_token_1.convertMobileTokenVersionToCookieName)(tokenVersion);
|
|
162
|
+
if (!cookieName) {
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
return this.createRiskToken(config, (_a = {}, _a[cookieName] = cookieString.join(risk_token_1.COOKIE_SPLIT_DELIMITER), _a), options);
|
|
166
|
+
}
|
|
167
|
+
catch (e) {
|
|
168
|
+
config.logger.debug("error extracting mobile token - ".concat(e, ", token: ").concat(mobileToken));
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
ContextBase.prototype.handleCustomParameters = function (config, request) {
|
|
173
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
174
|
+
var _a, _b, _c, e_1;
|
|
175
|
+
return __generator(this, function (_d) {
|
|
176
|
+
switch (_d.label) {
|
|
177
|
+
case 0:
|
|
178
|
+
if (!(config.enrichCustomParameters && typeof config.enrichCustomParameters === 'function')) return [3 /*break*/, 4];
|
|
179
|
+
_d.label = 1;
|
|
180
|
+
case 1:
|
|
181
|
+
_d.trys.push([1, 3, , 4]);
|
|
182
|
+
_a = this;
|
|
183
|
+
_c = (_b = custom_parameters_1.CustomParametersUtils).normalizeCustomParams;
|
|
184
|
+
return [4 /*yield*/, config.enrichCustomParameters(config.toParams(), request)];
|
|
185
|
+
case 2:
|
|
186
|
+
_a.customParameters = _c.apply(_b, [_d.sent()]);
|
|
187
|
+
return [3 /*break*/, 4];
|
|
188
|
+
case 3:
|
|
189
|
+
e_1 = _d.sent();
|
|
190
|
+
config.logger.error("unable to enrich custom params: ".concat(e_1));
|
|
191
|
+
return [3 /*break*/, 4];
|
|
192
|
+
case 4: return [2 /*return*/];
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
};
|
|
197
|
+
Object.defineProperty(ContextBase.prototype, "isMobile", {
|
|
198
|
+
get: function () {
|
|
199
|
+
return this.tokenOrigin === risk_token_1.TokenOrigin.HEADER;
|
|
200
|
+
},
|
|
201
|
+
enumerable: false,
|
|
202
|
+
configurable: true
|
|
203
|
+
});
|
|
204
|
+
return ContextBase;
|
|
205
|
+
}());
|
|
206
|
+
exports.ContextBase = ContextBase;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IConfiguration } from '../config';
|
|
2
|
+
import { IHttpRequest } from '../http';
|
|
3
|
+
import { IBotDefenderToken } from '../risk_token';
|
|
4
|
+
import { IBase64Utils, IHashUtils } from '../utils';
|
|
5
|
+
import { ContextBase, ContextBaseOptions } from './ContextBase';
|
|
6
|
+
export declare type DefaultTokenV2ContextOptions = {
|
|
7
|
+
base64Utils?: IBase64Utils;
|
|
8
|
+
hashUtils?: IHashUtils;
|
|
9
|
+
} & ContextBaseOptions;
|
|
10
|
+
export declare class DefaultTokenV2Context extends ContextBase<DefaultTokenV2ContextOptions> {
|
|
11
|
+
constructor(config: IConfiguration, httpRequest: IHttpRequest, options?: DefaultTokenV2ContextOptions);
|
|
12
|
+
protected createRiskToken(config: IConfiguration, cookies: Record<string, string>, options: DefaultTokenV2ContextOptions): IBotDefenderToken;
|
|
13
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.DefaultTokenV2Context = void 0;
|
|
19
|
+
var risk_token_1 = require("../risk_token");
|
|
20
|
+
var utils_1 = require("../utils");
|
|
21
|
+
var ContextBase_1 = require("./ContextBase");
|
|
22
|
+
var DefaultTokenV2Context = /** @class */ (function (_super) {
|
|
23
|
+
__extends(DefaultTokenV2Context, _super);
|
|
24
|
+
function DefaultTokenV2Context(config, httpRequest, options) {
|
|
25
|
+
return _super.call(this, config, httpRequest, options) || this;
|
|
26
|
+
}
|
|
27
|
+
DefaultTokenV2Context.prototype.createRiskToken = function (config, cookies, options) {
|
|
28
|
+
if (cookies[risk_token_1.COOKIE_V2_NAME]) {
|
|
29
|
+
return new risk_token_1.DefaultBotDefenderTokenV2(config, cookies[risk_token_1.COOKIE_V2_NAME], (options === null || options === void 0 ? void 0 : options.base64Utils) || new utils_1.DefaultBase64Utils(), (options === null || options === void 0 ? void 0 : options.hashUtils) || new utils_1.DefaultHashUtils());
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
};
|
|
33
|
+
return DefaultTokenV2Context;
|
|
34
|
+
}(ContextBase_1.ContextBase));
|
|
35
|
+
exports.DefaultTokenV2Context = DefaultTokenV2Context;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IConfiguration } from '../config';
|
|
2
|
+
import { IHttpRequest } from '../http';
|
|
3
|
+
import { IBotDefenderToken } from '../risk_token';
|
|
4
|
+
import { IHashUtils, ICipherUtils } from '../utils';
|
|
5
|
+
import { ContextBase, ContextBaseOptions } from './ContextBase';
|
|
6
|
+
export declare type DefaultTokenV3ContextOptions = {
|
|
7
|
+
cipherUtils: ICipherUtils;
|
|
8
|
+
hashUtils?: IHashUtils;
|
|
9
|
+
} & ContextBaseOptions;
|
|
10
|
+
export declare class DefaultTokenV3Context extends ContextBase<DefaultTokenV3ContextOptions> {
|
|
11
|
+
constructor(config: IConfiguration, httpRequest: IHttpRequest, options: DefaultTokenV3ContextOptions);
|
|
12
|
+
protected createRiskToken(config: IConfiguration, cookies: Record<string, string>, options: DefaultTokenV3ContextOptions): IBotDefenderToken;
|
|
13
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.DefaultTokenV3Context = void 0;
|
|
19
|
+
var risk_token_1 = require("../risk_token");
|
|
20
|
+
var utils_1 = require("../utils");
|
|
21
|
+
var ContextBase_1 = require("./ContextBase");
|
|
22
|
+
var DefaultTokenV3Context = /** @class */ (function (_super) {
|
|
23
|
+
__extends(DefaultTokenV3Context, _super);
|
|
24
|
+
function DefaultTokenV3Context(config, httpRequest, options) {
|
|
25
|
+
return _super.call(this, config, httpRequest, options) || this;
|
|
26
|
+
}
|
|
27
|
+
DefaultTokenV3Context.prototype.createRiskToken = function (config, cookies, options) {
|
|
28
|
+
if (cookies[risk_token_1.COOKIE_V3_NAME]) {
|
|
29
|
+
return new risk_token_1.DefaultBotDefenderTokenV3(config, cookies[risk_token_1.COOKIE_V3_NAME], options.cipherUtils, options.hashUtils || new utils_1.DefaultHashUtils());
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
};
|
|
33
|
+
return DefaultTokenV3Context;
|
|
34
|
+
}(ContextBase_1.ContextBase));
|
|
35
|
+
exports.DefaultTokenV3Context = DefaultTokenV3Context;
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { TokenOrigin, MobileError, IBotDefenderToken } from '../risk_token';
|
|
2
|
+
import { FilterReason } from '../filter';
|
|
3
|
+
import { S2SCallReason, S2SErrorReason } from '../risk_api';
|
|
4
|
+
import { PassReason, VidSource } from '../utils';
|
|
5
|
+
import { BlockAction, BlockReason } from '../block_handler';
|
|
6
|
+
import { HttpHeaders, HttpMethod, IHttpRequest } from '../http';
|
|
7
|
+
import { CustomParameters } from '../custom_parameters';
|
|
8
|
+
import { PXDE } from '../pxde';
|
|
9
|
+
export declare type RequestData = {
|
|
10
|
+
/**
|
|
11
|
+
* The request URL.
|
|
12
|
+
*/
|
|
13
|
+
url: URL;
|
|
14
|
+
/**
|
|
15
|
+
* The request method, capitalized.
|
|
16
|
+
*/
|
|
17
|
+
method: HttpMethod;
|
|
18
|
+
/**
|
|
19
|
+
* An object representing the request headers. The keys are the header names (all lowercase) and the values
|
|
20
|
+
* are arrays of strings, with each string representing one value associated with the header name.
|
|
21
|
+
*/
|
|
22
|
+
headers: HttpHeaders;
|
|
23
|
+
/**
|
|
24
|
+
* An object representing the request cookies. The keys are the cookie
|
|
25
|
+
* names and the values are the cookie values.
|
|
26
|
+
*/
|
|
27
|
+
cookies: Record<string, string>;
|
|
28
|
+
/**
|
|
29
|
+
* An array of the cookie names present on the request.
|
|
30
|
+
*/
|
|
31
|
+
requestCookieNames: string[];
|
|
32
|
+
/**
|
|
33
|
+
* The user agent header on the request.
|
|
34
|
+
*/
|
|
35
|
+
userAgent: string;
|
|
36
|
+
/**
|
|
37
|
+
* The IP of the request.
|
|
38
|
+
*/
|
|
39
|
+
ip: string;
|
|
40
|
+
/**
|
|
41
|
+
* An interface representing the original HTTP request.
|
|
42
|
+
*/
|
|
43
|
+
request: IHttpRequest;
|
|
44
|
+
/**
|
|
45
|
+
* The HTTP version used for the request (e.g., 0.9, 1.0, 1.1, 2.0).
|
|
46
|
+
*/
|
|
47
|
+
httpVersion?: string;
|
|
48
|
+
};
|
|
49
|
+
export declare type ResponseData = {
|
|
50
|
+
/**
|
|
51
|
+
* The HTTP status code from the response to the original request.
|
|
52
|
+
*/
|
|
53
|
+
status?: number;
|
|
54
|
+
};
|
|
55
|
+
export interface TlsData {
|
|
56
|
+
/**
|
|
57
|
+
* The TLS version used for the HTTPS request (e.g., 1.2, 1.3).
|
|
58
|
+
*/
|
|
59
|
+
tlsProtocol?: string;
|
|
60
|
+
/**
|
|
61
|
+
* The Server Name Indication (SNI) the client sent in the TLS Client Hello packet of the HTTPS request.
|
|
62
|
+
*/
|
|
63
|
+
tlsServer?: string;
|
|
64
|
+
/**
|
|
65
|
+
* The name of the TLS cipher used to encrypt the HTTPS request.
|
|
66
|
+
*/
|
|
67
|
+
tlsCipher?: string;
|
|
68
|
+
/**
|
|
69
|
+
* The hash used to encrypt the HTTPS request.
|
|
70
|
+
*/
|
|
71
|
+
tlsCiphersSha?: string;
|
|
72
|
+
/**
|
|
73
|
+
* The hash of the TLS extension identifiers sent from the client as part of the TLS handshake
|
|
74
|
+
*/
|
|
75
|
+
tlsExtensionSha?: string;
|
|
76
|
+
/**
|
|
77
|
+
* The client's preferred TLS ciphers for the HTTPS request.
|
|
78
|
+
*/
|
|
79
|
+
tlsPreferredCiphers?: string;
|
|
80
|
+
/**
|
|
81
|
+
* The JA3 fingerprint computed from the TLS Client Hello packet of th HTTPS request.
|
|
82
|
+
*/
|
|
83
|
+
tlsJa3Fingerprint?: string;
|
|
84
|
+
}
|
|
85
|
+
export interface MobileData {
|
|
86
|
+
/**
|
|
87
|
+
* The mobile error sent on the X-PX-Authorization header for mobile requests.
|
|
88
|
+
*/
|
|
89
|
+
mobileError?: MobileError;
|
|
90
|
+
/**
|
|
91
|
+
* An interface representing the original token sent on the X-PX-Original-Token header for mobile requests.
|
|
92
|
+
*/
|
|
93
|
+
originalToken?: IBotDefenderToken;
|
|
94
|
+
/**
|
|
95
|
+
* The bypass reason from the X-PX-Bypass-Reason header for mobile requests.
|
|
96
|
+
*/
|
|
97
|
+
bypassReason?: string;
|
|
98
|
+
/**
|
|
99
|
+
* The reason the original token could not be verified (e.g., cookie_decryption_failed, cookie_validation_failed).
|
|
100
|
+
*/
|
|
101
|
+
originalTokenError?: string;
|
|
102
|
+
/**
|
|
103
|
+
* The JSON string of the original token if one was sent on the mobile request.
|
|
104
|
+
*/
|
|
105
|
+
decodedOriginalToken?: string;
|
|
106
|
+
}
|
|
107
|
+
export interface RiskApiData {
|
|
108
|
+
/**
|
|
109
|
+
* The risk API round trip time in milliseconds.
|
|
110
|
+
*/
|
|
111
|
+
riskRtt?: number;
|
|
112
|
+
/**
|
|
113
|
+
* Whether the enforcer completed the risk API call.
|
|
114
|
+
*/
|
|
115
|
+
madeApiCall?: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* The reason for the risk API call.
|
|
118
|
+
*/
|
|
119
|
+
s2sCallReason?: S2SCallReason;
|
|
120
|
+
/**
|
|
121
|
+
* The reason for the error during the risk API call if an error occurred.
|
|
122
|
+
*/
|
|
123
|
+
s2sErrorReason?: S2SErrorReason;
|
|
124
|
+
/**
|
|
125
|
+
* The HTTP response status that was received for the risk API call if an error occurred.
|
|
126
|
+
*/
|
|
127
|
+
s2sErrorHttpStatus?: number;
|
|
128
|
+
/**
|
|
129
|
+
* An error message that contains more details about the risk API error if an error occurred.
|
|
130
|
+
*/
|
|
131
|
+
errorMessage?: string;
|
|
132
|
+
}
|
|
133
|
+
export interface ServerData {
|
|
134
|
+
/**
|
|
135
|
+
* The operating system platform.
|
|
136
|
+
*/
|
|
137
|
+
osName?: string;
|
|
138
|
+
/**
|
|
139
|
+
* The CDN PoP/data center region the request hit.
|
|
140
|
+
*/
|
|
141
|
+
region?: string;
|
|
142
|
+
/**
|
|
143
|
+
* The host name of the operating system.
|
|
144
|
+
*/
|
|
145
|
+
nodeName?: string;
|
|
146
|
+
}
|
|
147
|
+
export interface IContext {
|
|
148
|
+
/**
|
|
149
|
+
* A UUID v4 generated in the enforcer unique to each HTTP request.
|
|
150
|
+
*/
|
|
151
|
+
readonly requestId: string;
|
|
152
|
+
/**
|
|
153
|
+
* Whether the request is from a mobile device.
|
|
154
|
+
*/
|
|
155
|
+
readonly isMobile: boolean;
|
|
156
|
+
/**
|
|
157
|
+
* An object containing details about the original HTTP request.
|
|
158
|
+
*/
|
|
159
|
+
readonly requestData: RequestData;
|
|
160
|
+
/**
|
|
161
|
+
* An object containing details about the HTTP response.
|
|
162
|
+
*/
|
|
163
|
+
readonly responseData: ResponseData;
|
|
164
|
+
/**
|
|
165
|
+
* An object containing details about the mobile data if the request was made from a mobile device.
|
|
166
|
+
*/
|
|
167
|
+
readonly mobileData: MobileData;
|
|
168
|
+
/**
|
|
169
|
+
* An object containing details about the risk API data.
|
|
170
|
+
*/
|
|
171
|
+
readonly riskApiData: RiskApiData;
|
|
172
|
+
/**
|
|
173
|
+
* An object containing details about the TLS metadata of the HTTP request.
|
|
174
|
+
*/
|
|
175
|
+
readonly tlsData: TlsData;
|
|
176
|
+
/**
|
|
177
|
+
* An object containing details about the server on which the enforcer is running.
|
|
178
|
+
*/
|
|
179
|
+
readonly serverData: ServerData;
|
|
180
|
+
/**
|
|
181
|
+
* The client UUID.
|
|
182
|
+
*/
|
|
183
|
+
uuid: string;
|
|
184
|
+
/**
|
|
185
|
+
* The visitor ID, unique to the end-user.
|
|
186
|
+
*/
|
|
187
|
+
vid?: string;
|
|
188
|
+
/**
|
|
189
|
+
* A string representing where the visitor ID was obtained.
|
|
190
|
+
*/
|
|
191
|
+
vidSource?: VidSource;
|
|
192
|
+
/**
|
|
193
|
+
* The risk score retrieved from either the risk cookie or risk API request. This should be a value
|
|
194
|
+
* between 0 and 100 (inclusive), with 100 representing a bot.
|
|
195
|
+
*/
|
|
196
|
+
score?: number;
|
|
197
|
+
/**
|
|
198
|
+
* Whether the request should go through the enforcement flow in monitor mode.
|
|
199
|
+
* This depends on various configurations including the module mode, monitored routes, enforced
|
|
200
|
+
* routes, and the bypass monitor header.
|
|
201
|
+
*/
|
|
202
|
+
isMonitoredRequest: boolean;
|
|
203
|
+
/**
|
|
204
|
+
* Whether the request should trigger a Risk API call regardless of the risk cookie it carries.
|
|
205
|
+
*/
|
|
206
|
+
isSensitiveRequest: boolean;
|
|
207
|
+
/**
|
|
208
|
+
* The reason to pass the request, if it should be passed.
|
|
209
|
+
*/
|
|
210
|
+
passReason?: PassReason;
|
|
211
|
+
/**
|
|
212
|
+
* The reason to block the request, if it should be blocked.
|
|
213
|
+
*/
|
|
214
|
+
blockReason?: BlockReason;
|
|
215
|
+
/**
|
|
216
|
+
* The action to take in the event of a block.
|
|
217
|
+
*/
|
|
218
|
+
blockAction?: BlockAction;
|
|
219
|
+
/**
|
|
220
|
+
* The reason the request was filtered, if it was filtered.
|
|
221
|
+
*/
|
|
222
|
+
filterReason?: FilterReason;
|
|
223
|
+
/**
|
|
224
|
+
* The origin of the risk token, indicating whether the request originates from
|
|
225
|
+
* a web browser ('cookie') or from the mobile SDK ('header').
|
|
226
|
+
*/
|
|
227
|
+
tokenOrigin?: TokenOrigin;
|
|
228
|
+
/**
|
|
229
|
+
* An interface representing the risk token.
|
|
230
|
+
*/
|
|
231
|
+
riskToken?: IBotDefenderToken;
|
|
232
|
+
/**
|
|
233
|
+
* The PXHD (PerimeterX Hashed Data) cookie value, if it exists on the request.
|
|
234
|
+
*/
|
|
235
|
+
pxhd?: string;
|
|
236
|
+
/**
|
|
237
|
+
* The PXDE (PerimeterX Data Enrichment) object, if it was parsed from
|
|
238
|
+
* the PXDE cookie or received on the risk response.
|
|
239
|
+
*/
|
|
240
|
+
pxde?: PXDE;
|
|
241
|
+
/**
|
|
242
|
+
* Whether the HMAC on the PXDE cookie has been validated. If the PXDE object
|
|
243
|
+
* was received on the risk response, this value will be true.
|
|
244
|
+
*/
|
|
245
|
+
pxdeVerified?: boolean;
|
|
246
|
+
/**
|
|
247
|
+
* An object with 10 custom parameters that the customer can set and define. These
|
|
248
|
+
* custom parameters will be added to the activities sent to the collector.
|
|
249
|
+
*/
|
|
250
|
+
customParameters?: CustomParameters;
|
|
251
|
+
/**
|
|
252
|
+
* A function that completes context initialization. Should be called only if
|
|
253
|
+
* the request should not be filtered and is not first-party.
|
|
254
|
+
*/
|
|
255
|
+
completeInitialization(): Promise<void>;
|
|
256
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { IContext } from './IContext';
|
|
2
|
+
export { ContextBase, ContextBaseOptions } from './ContextBase';
|
|
3
|
+
export { DefaultTokenV2Context, DefaultTokenV2ContextOptions } from './DefaultTokenV2Context';
|
|
4
|
+
export { DefaultTokenV3Context, DefaultTokenV3ContextOptions } from './DefaultTokenV3Context';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefaultTokenV3Context = exports.DefaultTokenV2Context = exports.ContextBase = void 0;
|
|
4
|
+
var ContextBase_1 = require("./ContextBase");
|
|
5
|
+
Object.defineProperty(exports, "ContextBase", { enumerable: true, get: function () { return ContextBase_1.ContextBase; } });
|
|
6
|
+
var DefaultTokenV2Context_1 = require("./DefaultTokenV2Context");
|
|
7
|
+
Object.defineProperty(exports, "DefaultTokenV2Context", { enumerable: true, get: function () { return DefaultTokenV2Context_1.DefaultTokenV2Context; } });
|
|
8
|
+
var DefaultTokenV3Context_1 = require("./DefaultTokenV3Context");
|
|
9
|
+
Object.defineProperty(exports, "DefaultTokenV3Context", { enumerable: true, get: function () { return DefaultTokenV3Context_1.DefaultTokenV3Context; } });
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare type CustomParameters = {
|
|
2
|
+
custom_param1?: any;
|
|
3
|
+
custom_param2?: any;
|
|
4
|
+
custom_param3?: any;
|
|
5
|
+
custom_param4?: any;
|
|
6
|
+
custom_param5?: any;
|
|
7
|
+
custom_param6?: any;
|
|
8
|
+
custom_param7?: any;
|
|
9
|
+
custom_param8?: any;
|
|
10
|
+
custom_param9?: any;
|
|
11
|
+
custom_param10?: any;
|
|
12
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { IHttpRequest } from '../http';
|
|
2
|
+
import { ConfigurationParams } from '../config';
|
|
3
|
+
import { CustomParameters } from './CustomParameters';
|
|
4
|
+
export declare type CustomParametersFunction = (config: ConfigurationParams, httpRequest: IHttpRequest) => CustomParameters | Promise<CustomParameters>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CustomParametersUtils = void 0;
|
|
4
|
+
var CustomParametersUtils;
|
|
5
|
+
(function (CustomParametersUtils) {
|
|
6
|
+
CustomParametersUtils.normalizeCustomParams = function (customParameters) {
|
|
7
|
+
var normalizedParams = {};
|
|
8
|
+
if (customParameters && typeof customParameters === 'object') {
|
|
9
|
+
var paramKeyRegex_1 = /^custom_param([1-9]|10)$/;
|
|
10
|
+
Object.entries(customParameters).forEach(function (_a) {
|
|
11
|
+
var param = _a[0], value = _a[1];
|
|
12
|
+
if (param.match(paramKeyRegex_1) && value !== '') {
|
|
13
|
+
normalizedParams[param] = value;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return Object.keys(normalizedParams).length === 0 ? null : normalizedParams;
|
|
18
|
+
};
|
|
19
|
+
})(CustomParametersUtils = exports.CustomParametersUtils || (exports.CustomParametersUtils = {}));
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CustomParametersUtils = void 0;
|
|
4
|
+
var CustomParametersUtils_1 = require("./CustomParametersUtils");
|
|
5
|
+
Object.defineProperty(exports, "CustomParametersUtils", { enumerable: true, get: function () { return CustomParametersUtils_1.CustomParametersUtils; } });
|