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,232 @@
|
|
|
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.PostRiskApiClient = void 0;
|
|
40
|
+
var risk_token_1 = require("../risk_token");
|
|
41
|
+
var http_1 = require("../http");
|
|
42
|
+
var utils_1 = require("../utils");
|
|
43
|
+
var S2SCallReason_1 = require("./S2SCallReason");
|
|
44
|
+
var S2SErrorHandler_1 = require("./S2SErrorHandler");
|
|
45
|
+
var constants_1 = require("./constants");
|
|
46
|
+
var PostRiskApiClient = /** @class */ (function () {
|
|
47
|
+
function PostRiskApiClient(config, httpClient, riskResponseHandler) {
|
|
48
|
+
this.config = config;
|
|
49
|
+
this.httpClient = httpClient;
|
|
50
|
+
this.riskResponseHandler = riskResponseHandler;
|
|
51
|
+
this.s2sErrorHandler = new S2SErrorHandler_1.S2SErrorHandler();
|
|
52
|
+
}
|
|
53
|
+
PostRiskApiClient.prototype.shouldRetrieveScore = function (context) {
|
|
54
|
+
if (context.riskApiData.s2sCallReason) {
|
|
55
|
+
if (context.riskApiData.s2sCallReason === S2SCallReason_1.S2SCallReason.NO_COOKIE && context.pxhd) {
|
|
56
|
+
context.riskApiData.s2sCallReason = S2SCallReason_1.S2SCallReason.NO_COOKIE_WITH_VID;
|
|
57
|
+
}
|
|
58
|
+
this.unsetScoreFields(context);
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
if (context.passReason) {
|
|
62
|
+
if (context.isSensitiveRequest && context.passReason === utils_1.PassReason.COOKIE) {
|
|
63
|
+
context.riskApiData.s2sCallReason = S2SCallReason_1.S2SCallReason.SENSITIVE_ROUTE;
|
|
64
|
+
this.unsetScoreFields(context);
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
if (context.blockReason) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
context.riskApiData.s2sCallReason = context.pxhd ? S2SCallReason_1.S2SCallReason.NO_COOKIE_WITH_VID : S2SCallReason_1.S2SCallReason.NO_COOKIE;
|
|
73
|
+
this.unsetScoreFields(context);
|
|
74
|
+
return true;
|
|
75
|
+
};
|
|
76
|
+
PostRiskApiClient.prototype.unsetScoreFields = function (context) {
|
|
77
|
+
context.passReason = undefined;
|
|
78
|
+
context.blockReason = undefined;
|
|
79
|
+
context.score = undefined;
|
|
80
|
+
};
|
|
81
|
+
PostRiskApiClient.prototype.retrieveScore = function (context) {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
83
|
+
var response, riskResponse, riskActivity, err_1;
|
|
84
|
+
return __generator(this, function (_a) {
|
|
85
|
+
switch (_a.label) {
|
|
86
|
+
case 0:
|
|
87
|
+
_a.trys.push([0, 6, , 8]);
|
|
88
|
+
riskActivity = this.createRiskActivity(context);
|
|
89
|
+
return [4 /*yield*/, this.sendRiskActivity(context, riskActivity)];
|
|
90
|
+
case 1:
|
|
91
|
+
response = _a.sent();
|
|
92
|
+
if (!((response === null || response === void 0 ? void 0 : response.status) !== 200)) return [3 /*break*/, 3];
|
|
93
|
+
return [4 /*yield*/, this.s2sErrorHandler.handleS2SError(context, response, null, null)];
|
|
94
|
+
case 2:
|
|
95
|
+
_a.sent();
|
|
96
|
+
return [2 /*return*/, false];
|
|
97
|
+
case 3: return [4 /*yield*/, response.readBody()];
|
|
98
|
+
case 4:
|
|
99
|
+
riskResponse = (_a.sent());
|
|
100
|
+
return [4 /*yield*/, this.riskResponseHandler.handleRiskResponse(context, response, riskResponse)];
|
|
101
|
+
case 5:
|
|
102
|
+
_a.sent();
|
|
103
|
+
return [2 /*return*/, true];
|
|
104
|
+
case 6:
|
|
105
|
+
err_1 = _a.sent();
|
|
106
|
+
this.config.logger.error("Caught error on Risk API: ".concat(err_1));
|
|
107
|
+
return [4 /*yield*/, this.s2sErrorHandler.handleS2SError(context, response, riskResponse, err_1)];
|
|
108
|
+
case 7:
|
|
109
|
+
_a.sent();
|
|
110
|
+
return [2 /*return*/, false];
|
|
111
|
+
case 8: return [2 /*return*/];
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
PostRiskApiClient.prototype.createRiskActivity = function (context) {
|
|
117
|
+
var riskActivity = {
|
|
118
|
+
request: {
|
|
119
|
+
ip: context.requestData.ip,
|
|
120
|
+
headers: this.formatRiskHeadersField(context.requestData.headers),
|
|
121
|
+
url: context.requestData.url.href,
|
|
122
|
+
},
|
|
123
|
+
additional: {
|
|
124
|
+
s2s_call_reason: context.riskApiData.s2sCallReason,
|
|
125
|
+
module_version: this.config.moduleVersion,
|
|
126
|
+
http_method: context.requestData.method,
|
|
127
|
+
http_version: context.requestData.httpVersion,
|
|
128
|
+
risk_mode: context.isMonitoredRequest ? utils_1.ModuleMode.MONITOR : utils_1.ModuleMode.ACTIVE_BLOCKING,
|
|
129
|
+
cookie_origin: context.tokenOrigin || risk_token_1.TokenOrigin.COOKIE,
|
|
130
|
+
request_cookie_names: context.requestData.requestCookieNames,
|
|
131
|
+
request_id: context.requestId,
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
this.addOptionalRiskFields(riskActivity, context);
|
|
135
|
+
return riskActivity;
|
|
136
|
+
};
|
|
137
|
+
PostRiskApiClient.prototype.addOptionalRiskFields = function (riskActivity, context) {
|
|
138
|
+
this.addOptionalRiskFieldsToRoot(riskActivity, context);
|
|
139
|
+
this.addOptionalRiskFieldsToAdditional(riskActivity, context);
|
|
140
|
+
this.addCookieRiskFieldsToAdditional(riskActivity, context);
|
|
141
|
+
this.addCustomParamsToAdditional(riskActivity, context);
|
|
142
|
+
};
|
|
143
|
+
PostRiskApiClient.prototype.addOptionalRiskFieldsToRoot = function (riskActivity, context) {
|
|
144
|
+
(0, utils_1.transferExistingProperties)(context, riskActivity, {
|
|
145
|
+
vid: 'vid',
|
|
146
|
+
uuid: 'uuid',
|
|
147
|
+
pxhd: 'pxhd',
|
|
148
|
+
});
|
|
149
|
+
};
|
|
150
|
+
PostRiskApiClient.prototype.addOptionalRiskFieldsToAdditional = function (riskActivity, context) {
|
|
151
|
+
(0, utils_1.transferExistingProperties)(context, riskActivity.additional, {
|
|
152
|
+
vidSource: 'enforcer_vid_source',
|
|
153
|
+
});
|
|
154
|
+
(0, utils_1.transferExistingProperties)(context.serverData, riskActivity.additional, {
|
|
155
|
+
region: 'server_info_region',
|
|
156
|
+
});
|
|
157
|
+
(0, utils_1.transferExistingProperties)(context.mobileData, riskActivity.additional, {
|
|
158
|
+
originalToken: 'original_token',
|
|
159
|
+
originalTokenError: 'original_token_error',
|
|
160
|
+
decodedOriginalToken: 'px_decoded_original_token',
|
|
161
|
+
});
|
|
162
|
+
(0, utils_1.transferExistingProperties)(context.tlsData, riskActivity.additional, {
|
|
163
|
+
tlsProtocol: 'tls_protocol',
|
|
164
|
+
tlsServer: 'tls_server',
|
|
165
|
+
tlsCipher: 'tls_cipher',
|
|
166
|
+
tlsCiphersSha: 'tls_ciphers_sha',
|
|
167
|
+
tlsExtensionSha: 'tls_extension_sha',
|
|
168
|
+
tlsPreferredCiphers: 'tls_preferred_ciphers',
|
|
169
|
+
tlsJa3Fingerprint: 'tls_ja3_fingerprint',
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
PostRiskApiClient.prototype.addCustomParamsToAdditional = function (riskActivity, context) {
|
|
173
|
+
if (context.customParameters) {
|
|
174
|
+
Object.assign(riskActivity.additional, context.customParameters);
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
PostRiskApiClient.prototype.addCookieRiskFieldsToAdditional = function (riskActivity, _a) {
|
|
178
|
+
var riskToken = _a.riskToken;
|
|
179
|
+
if (riskToken) {
|
|
180
|
+
riskActivity.additional.px_orig_cookie = riskToken.getCookieString();
|
|
181
|
+
if (riskToken.isValid()) {
|
|
182
|
+
riskActivity.additional.px_cookie = riskToken.getPayloadString();
|
|
183
|
+
riskActivity.additional.px_cookie_hmac = riskToken.hmac;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
PostRiskApiClient.prototype.formatRiskHeadersField = function (headers) {
|
|
188
|
+
var headerEntries = [];
|
|
189
|
+
(0, utils_1.removeSensitiveHeaders)(headers, this.config.sensitiveHeaders).forEach(function (values, name) {
|
|
190
|
+
values.forEach(function (value) {
|
|
191
|
+
headerEntries.push({ name: name, value: value });
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
return headerEntries;
|
|
195
|
+
};
|
|
196
|
+
PostRiskApiClient.prototype.sendRiskActivity = function (context, riskActivity) {
|
|
197
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
198
|
+
var url, headers, body, method, riskRequest, startTime, response, endTime;
|
|
199
|
+
return __generator(this, function (_a) {
|
|
200
|
+
switch (_a.label) {
|
|
201
|
+
case 0:
|
|
202
|
+
url = this.getRiskUrl();
|
|
203
|
+
headers = this.getRiskHeaders();
|
|
204
|
+
body = JSON.stringify(riskActivity);
|
|
205
|
+
method = http_1.HttpMethod.POST;
|
|
206
|
+
riskRequest = new http_1.DefaultHttpRequest(url, { headers: headers, method: method, body: body });
|
|
207
|
+
this.config.logger.debug("sending risk api to ".concat(url));
|
|
208
|
+
startTime = Date.now();
|
|
209
|
+
return [4 /*yield*/, this.httpClient.send(riskRequest)];
|
|
210
|
+
case 1:
|
|
211
|
+
response = _a.sent();
|
|
212
|
+
endTime = Date.now();
|
|
213
|
+
context.riskApiData.madeApiCall = true;
|
|
214
|
+
context.riskApiData.riskRtt = endTime - startTime;
|
|
215
|
+
return [2 /*return*/, response];
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
};
|
|
220
|
+
PostRiskApiClient.prototype.getRiskUrl = function () {
|
|
221
|
+
return "".concat(this.config.backendScoreApiUrl).concat(constants_1.RISK_API_ENDPOINT);
|
|
222
|
+
};
|
|
223
|
+
PostRiskApiClient.prototype.getRiskHeaders = function () {
|
|
224
|
+
var _a;
|
|
225
|
+
return new http_1.HttpHeaders((_a = {},
|
|
226
|
+
_a[http_1.CONTENT_TYPE_HEADER_NAME] = [http_1.ContentType.APPLICATION_JSON],
|
|
227
|
+
_a[http_1.AUTHORIZATION_HEADER_NAME] = [(0, utils_1.getAuthorizationHeader)(this.config.authToken)],
|
|
228
|
+
_a));
|
|
229
|
+
};
|
|
230
|
+
return PostRiskApiClient;
|
|
231
|
+
}());
|
|
232
|
+
exports.PostRiskApiClient = PostRiskApiClient;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare enum S2SCallReason {
|
|
2
|
+
COOKIE_EXPIRED = "cookie_expired",
|
|
3
|
+
COOKIE_DECRYPTION_FAILED = "cookie_decryption_failed",
|
|
4
|
+
COOKIE_VALIDATION_FAILED = "cookie_validation_failed",
|
|
5
|
+
NO_COOKIE_WITH_VID = "no_cookie_w_vid",
|
|
6
|
+
NO_COOKIE = "no_cookie",
|
|
7
|
+
SENSITIVE_ROUTE = "sensitive_route",
|
|
8
|
+
MOBILE_ERROR_NO_COOKIE = "mobile_error_1",
|
|
9
|
+
MOBILE_ERROR_CONNECTION_ERROR = "mobile_error_2",
|
|
10
|
+
MOBILE_ERROR_CERTIFICATE_PINNING_ERROR = "mobile_error_3",
|
|
11
|
+
MOBILE_ERROR_BYPASS = "mobile_error_4"
|
|
12
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.S2SCallReason = void 0;
|
|
4
|
+
var S2SCallReason;
|
|
5
|
+
(function (S2SCallReason) {
|
|
6
|
+
S2SCallReason["COOKIE_EXPIRED"] = "cookie_expired";
|
|
7
|
+
S2SCallReason["COOKIE_DECRYPTION_FAILED"] = "cookie_decryption_failed";
|
|
8
|
+
S2SCallReason["COOKIE_VALIDATION_FAILED"] = "cookie_validation_failed";
|
|
9
|
+
S2SCallReason["NO_COOKIE_WITH_VID"] = "no_cookie_w_vid";
|
|
10
|
+
S2SCallReason["NO_COOKIE"] = "no_cookie";
|
|
11
|
+
S2SCallReason["SENSITIVE_ROUTE"] = "sensitive_route";
|
|
12
|
+
S2SCallReason["MOBILE_ERROR_NO_COOKIE"] = "mobile_error_1";
|
|
13
|
+
S2SCallReason["MOBILE_ERROR_CONNECTION_ERROR"] = "mobile_error_2";
|
|
14
|
+
S2SCallReason["MOBILE_ERROR_CERTIFICATE_PINNING_ERROR"] = "mobile_error_3";
|
|
15
|
+
S2SCallReason["MOBILE_ERROR_BYPASS"] = "mobile_error_4";
|
|
16
|
+
})(S2SCallReason = exports.S2SCallReason || (exports.S2SCallReason = {}));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IContext } from '../context';
|
|
2
|
+
import { IHttpResponse } from '../http';
|
|
3
|
+
import { RiskResponseV2 } from './model/RiskResponseV2';
|
|
4
|
+
import { RiskResponseV3 } from './model/RiskResponseV3';
|
|
5
|
+
export declare class S2SErrorHandler {
|
|
6
|
+
handleS2SError(context: IContext, response?: IHttpResponse, responseBody?: RiskResponseV2 | RiskResponseV3, exception?: Error): Promise<void>;
|
|
7
|
+
private enrichS2SErrorWithResponse;
|
|
8
|
+
private enrichS2SErrorWithException;
|
|
9
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
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.S2SErrorHandler = void 0;
|
|
40
|
+
var utils_1 = require("../utils");
|
|
41
|
+
var S2SErrorReason_1 = require("./S2SErrorReason");
|
|
42
|
+
var RiskStatus_1 = require("./model/RiskStatus");
|
|
43
|
+
var S2SErrorHandler = /** @class */ (function () {
|
|
44
|
+
function S2SErrorHandler() {
|
|
45
|
+
}
|
|
46
|
+
S2SErrorHandler.prototype.handleS2SError = function (context, response, responseBody, exception) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
48
|
+
return __generator(this, function (_a) {
|
|
49
|
+
switch (_a.label) {
|
|
50
|
+
case 0:
|
|
51
|
+
context.passReason = utils_1.PassReason.S2S_ERROR;
|
|
52
|
+
context.riskApiData.s2sErrorReason = S2SErrorReason_1.S2SErrorReason.UNKNOWN_ERROR;
|
|
53
|
+
if (!(response || responseBody)) return [3 /*break*/, 2];
|
|
54
|
+
return [4 /*yield*/, this.enrichS2SErrorWithResponse(context, response, responseBody)];
|
|
55
|
+
case 1:
|
|
56
|
+
_a.sent();
|
|
57
|
+
_a.label = 2;
|
|
58
|
+
case 2:
|
|
59
|
+
if (exception) {
|
|
60
|
+
this.enrichS2SErrorWithException(context, exception);
|
|
61
|
+
}
|
|
62
|
+
return [2 /*return*/];
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
S2SErrorHandler.prototype.enrichS2SErrorWithResponse = function (context, response, responseBody) {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
69
|
+
var message, _a, _b, e_1;
|
|
70
|
+
return __generator(this, function (_c) {
|
|
71
|
+
switch (_c.label) {
|
|
72
|
+
case 0:
|
|
73
|
+
_c.trys.push([0, 4, , 5]);
|
|
74
|
+
_a = "response body: ".concat;
|
|
75
|
+
if (!responseBody) return [3 /*break*/, 1];
|
|
76
|
+
_b = JSON.stringify(responseBody);
|
|
77
|
+
return [3 /*break*/, 3];
|
|
78
|
+
case 1: return [4 /*yield*/, response.readBody()];
|
|
79
|
+
case 2:
|
|
80
|
+
_b = _c.sent();
|
|
81
|
+
_c.label = 3;
|
|
82
|
+
case 3:
|
|
83
|
+
message = _a.apply("response body: ", [_b]);
|
|
84
|
+
return [3 /*break*/, 5];
|
|
85
|
+
case 4:
|
|
86
|
+
e_1 = _c.sent();
|
|
87
|
+
message = "error: ".concat(e_1, ", response body: ").concat(responseBody ? JSON.stringify(responseBody) : 'empty');
|
|
88
|
+
return [3 /*break*/, 5];
|
|
89
|
+
case 5:
|
|
90
|
+
context.riskApiData.errorMessage = message;
|
|
91
|
+
context.riskApiData.s2sErrorHttpStatus = response.status;
|
|
92
|
+
if (response.status >= 400 && response.status < 500) {
|
|
93
|
+
context.riskApiData.s2sErrorReason = S2SErrorReason_1.S2SErrorReason.BAD_REQUEST;
|
|
94
|
+
}
|
|
95
|
+
else if (response.status >= 500 && response.status < 600) {
|
|
96
|
+
context.riskApiData.s2sErrorReason = S2SErrorReason_1.S2SErrorReason.SERVER_ERROR;
|
|
97
|
+
}
|
|
98
|
+
else if (response.status === 200) {
|
|
99
|
+
if ((responseBody === null || responseBody === void 0 ? void 0 : responseBody.status) === RiskStatus_1.RiskStatus.FAILURE) {
|
|
100
|
+
context.riskApiData.s2sErrorReason = S2SErrorReason_1.S2SErrorReason.REQUEST_FAILED_ON_SERVER;
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
context.riskApiData.s2sErrorReason = S2SErrorReason_1.S2SErrorReason.INVALID_RESPONSE;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (responseBody === null || responseBody === void 0 ? void 0 : responseBody.uuid) {
|
|
107
|
+
context.uuid = responseBody.uuid;
|
|
108
|
+
}
|
|
109
|
+
return [2 /*return*/];
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
S2SErrorHandler.prototype.enrichS2SErrorWithException = function (context, exception) {
|
|
115
|
+
var errorMessage = "encountered error ".concat(exception);
|
|
116
|
+
var existingMessage = context.riskApiData.errorMessage;
|
|
117
|
+
context.riskApiData.errorMessage = existingMessage ? "".concat(existingMessage, ", ").concat(errorMessage) : errorMessage;
|
|
118
|
+
};
|
|
119
|
+
return S2SErrorHandler;
|
|
120
|
+
}());
|
|
121
|
+
exports.S2SErrorHandler = S2SErrorHandler;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare enum S2SErrorReason {
|
|
2
|
+
UNABLE_TO_SEND_REQUEST = "unable_to_send_request",
|
|
3
|
+
BAD_REQUEST = "bad_request",
|
|
4
|
+
SERVER_ERROR = "server_error",
|
|
5
|
+
INVALID_RESPONSE = "invalid_response",
|
|
6
|
+
REQUEST_FAILED_ON_SERVER = "request_failed_on_server",
|
|
7
|
+
UNKNOWN_ERROR = "unknown_error"
|
|
8
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.S2SErrorReason = void 0;
|
|
4
|
+
var S2SErrorReason;
|
|
5
|
+
(function (S2SErrorReason) {
|
|
6
|
+
S2SErrorReason["UNABLE_TO_SEND_REQUEST"] = "unable_to_send_request";
|
|
7
|
+
S2SErrorReason["BAD_REQUEST"] = "bad_request";
|
|
8
|
+
S2SErrorReason["SERVER_ERROR"] = "server_error";
|
|
9
|
+
S2SErrorReason["INVALID_RESPONSE"] = "invalid_response";
|
|
10
|
+
S2SErrorReason["REQUEST_FAILED_ON_SERVER"] = "request_failed_on_server";
|
|
11
|
+
S2SErrorReason["UNKNOWN_ERROR"] = "unknown_error";
|
|
12
|
+
})(S2SErrorReason = exports.S2SErrorReason || (exports.S2SErrorReason = {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const RISK_API_ENDPOINT = "/api/v3/risk";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { RiskStatus } from './model/RiskStatus';
|
|
2
|
+
export { RiskResponseV3 } from './model/RiskResponseV3';
|
|
3
|
+
export { RiskResponseV2 } from './model/RiskResponseV2';
|
|
4
|
+
export { RiskActivity } from './model/RiskActivity';
|
|
5
|
+
export { IRiskResponseHandler } from './risk_response_handler/IRiskResponseHandler';
|
|
6
|
+
export { RiskResponseHandlerBase } from './risk_response_handler/RiskResponseHandlerBase';
|
|
7
|
+
export { RiskResponseV2Handler } from './risk_response_handler/RiskResponseV2Handler';
|
|
8
|
+
export { RiskResponseV3Handler } from './risk_response_handler/RiskResponseV3Handler';
|
|
9
|
+
export { S2SErrorHandler } from './S2SErrorHandler';
|
|
10
|
+
export { PostRiskApiClient } from './PostRiskApiClient';
|
|
11
|
+
export { S2SCallReason } from './S2SCallReason';
|
|
12
|
+
export { S2SErrorReason } from './S2SErrorReason';
|
|
13
|
+
export * from './constants';
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
exports.S2SErrorReason = exports.S2SCallReason = exports.PostRiskApiClient = exports.S2SErrorHandler = exports.RiskResponseV3Handler = exports.RiskResponseV2Handler = exports.RiskResponseHandlerBase = exports.RiskStatus = void 0;
|
|
18
|
+
var RiskStatus_1 = require("./model/RiskStatus");
|
|
19
|
+
Object.defineProperty(exports, "RiskStatus", { enumerable: true, get: function () { return RiskStatus_1.RiskStatus; } });
|
|
20
|
+
var RiskResponseHandlerBase_1 = require("./risk_response_handler/RiskResponseHandlerBase");
|
|
21
|
+
Object.defineProperty(exports, "RiskResponseHandlerBase", { enumerable: true, get: function () { return RiskResponseHandlerBase_1.RiskResponseHandlerBase; } });
|
|
22
|
+
var RiskResponseV2Handler_1 = require("./risk_response_handler/RiskResponseV2Handler");
|
|
23
|
+
Object.defineProperty(exports, "RiskResponseV2Handler", { enumerable: true, get: function () { return RiskResponseV2Handler_1.RiskResponseV2Handler; } });
|
|
24
|
+
var RiskResponseV3Handler_1 = require("./risk_response_handler/RiskResponseV3Handler");
|
|
25
|
+
Object.defineProperty(exports, "RiskResponseV3Handler", { enumerable: true, get: function () { return RiskResponseV3Handler_1.RiskResponseV3Handler; } });
|
|
26
|
+
var S2SErrorHandler_1 = require("./S2SErrorHandler");
|
|
27
|
+
Object.defineProperty(exports, "S2SErrorHandler", { enumerable: true, get: function () { return S2SErrorHandler_1.S2SErrorHandler; } });
|
|
28
|
+
var PostRiskApiClient_1 = require("./PostRiskApiClient");
|
|
29
|
+
Object.defineProperty(exports, "PostRiskApiClient", { enumerable: true, get: function () { return PostRiskApiClient_1.PostRiskApiClient; } });
|
|
30
|
+
var S2SCallReason_1 = require("./S2SCallReason");
|
|
31
|
+
Object.defineProperty(exports, "S2SCallReason", { enumerable: true, get: function () { return S2SCallReason_1.S2SCallReason; } });
|
|
32
|
+
var S2SErrorReason_1 = require("./S2SErrorReason");
|
|
33
|
+
Object.defineProperty(exports, "S2SErrorReason", { enumerable: true, get: function () { return S2SErrorReason_1.S2SErrorReason; } });
|
|
34
|
+
__exportStar(require("./constants"), exports);
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { S2SCallReason } from '../S2SCallReason';
|
|
2
|
+
import { ModuleMode } from '../../utils/ModuleMode';
|
|
3
|
+
import { VidSource } from '../../utils/VidSource';
|
|
4
|
+
import { TokenOrigin } from '../../risk_token/TokenOrigin';
|
|
5
|
+
import { CustomParameters } from '../../custom_parameters/CustomParameters';
|
|
6
|
+
export declare type HeaderEntry = {
|
|
7
|
+
name: string;
|
|
8
|
+
value: string;
|
|
9
|
+
};
|
|
10
|
+
export declare type RiskRequestData = {
|
|
11
|
+
ip: string;
|
|
12
|
+
url: string;
|
|
13
|
+
headers: HeaderEntry[];
|
|
14
|
+
};
|
|
15
|
+
export declare type RiskAdditionalData = {
|
|
16
|
+
request_id: string;
|
|
17
|
+
module_version: string;
|
|
18
|
+
s2s_call_reason: S2SCallReason;
|
|
19
|
+
risk_mode: ModuleMode;
|
|
20
|
+
http_method: string;
|
|
21
|
+
http_version?: string;
|
|
22
|
+
px_orig_cookie?: string;
|
|
23
|
+
px_cookie?: string;
|
|
24
|
+
px_cookie_hmac?: string;
|
|
25
|
+
tls_protocol?: string;
|
|
26
|
+
tls_server?: string;
|
|
27
|
+
tls_cipher?: string;
|
|
28
|
+
tls_ciphers_sha?: string;
|
|
29
|
+
tls_extension_sha?: string;
|
|
30
|
+
tls_preferred_ciphers?: string;
|
|
31
|
+
tls_ja3_fingerprint?: string;
|
|
32
|
+
enforcer_vid_source?: VidSource;
|
|
33
|
+
original_uuid?: string;
|
|
34
|
+
original_token_error?: string;
|
|
35
|
+
original_token?: string;
|
|
36
|
+
px_decoded_original_token?: string;
|
|
37
|
+
cookie_origin?: TokenOrigin;
|
|
38
|
+
request_cookie_names?: string[];
|
|
39
|
+
server_info_region?: string;
|
|
40
|
+
cross_tab_session?: string;
|
|
41
|
+
app_user_id?: string;
|
|
42
|
+
jwt_additional_fields?: string[];
|
|
43
|
+
} & CustomParameters;
|
|
44
|
+
export declare type RiskActivity = {
|
|
45
|
+
vid?: string;
|
|
46
|
+
uuid?: string;
|
|
47
|
+
pxhd?: string;
|
|
48
|
+
request: RiskRequestData;
|
|
49
|
+
additional: RiskAdditionalData;
|
|
50
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RiskStatus } from './RiskStatus';
|
|
2
|
+
import { PXDE } from '../../pxde';
|
|
3
|
+
export declare type RiskResponseV2 = {
|
|
4
|
+
status: RiskStatus;
|
|
5
|
+
cookie_cfg_block_result?: '0' | '1';
|
|
6
|
+
uuid?: string;
|
|
7
|
+
pxhd?: string;
|
|
8
|
+
message?: string;
|
|
9
|
+
data_enrichment?: PXDE;
|
|
10
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { RiskStatus } from './RiskStatus';
|
|
2
|
+
import { BlockAction } from '../../block_handler';
|
|
3
|
+
import { PXDE } from '../../pxde';
|
|
4
|
+
export declare type RiskResponseV3 = {
|
|
5
|
+
status: RiskStatus;
|
|
6
|
+
score?: number;
|
|
7
|
+
action?: BlockAction;
|
|
8
|
+
uuid?: string;
|
|
9
|
+
pxhd?: string;
|
|
10
|
+
message?: string;
|
|
11
|
+
data_enrichment?: PXDE;
|
|
12
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RiskStatus = void 0;
|
|
4
|
+
var RiskStatus;
|
|
5
|
+
(function (RiskStatus) {
|
|
6
|
+
RiskStatus[RiskStatus["FAILURE"] = -1] = "FAILURE";
|
|
7
|
+
RiskStatus[RiskStatus["SUCCESS"] = 0] = "SUCCESS";
|
|
8
|
+
})(RiskStatus = exports.RiskStatus || (exports.RiskStatus = {}));
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IConfiguration } from '../../config';
|
|
2
|
+
import { IContext } from '../../context';
|
|
3
|
+
import { IHttpResponse } from '../../http';
|
|
4
|
+
import { IRiskResponseHandler } from './IRiskResponseHandler';
|
|
5
|
+
import { RiskResponseV2 } from '../model/RiskResponseV2';
|
|
6
|
+
import { RiskResponseV3 } from '../model/RiskResponseV3';
|
|
7
|
+
export declare abstract class RiskResponseHandlerBase<RiskResponseType extends RiskResponseV2 | RiskResponseV3> implements IRiskResponseHandler<RiskResponseType> {
|
|
8
|
+
protected readonly config: IConfiguration;
|
|
9
|
+
protected abstract isRiskResponseValid(riskResponse: RiskResponseType): boolean;
|
|
10
|
+
protected abstract extractScoreFromRiskResponse(riskResponse: RiskResponseType): number;
|
|
11
|
+
protected abstract setRiskResponseContextFields(context: IContext, riskResponse: RiskResponseType): void;
|
|
12
|
+
protected constructor(config: IConfiguration);
|
|
13
|
+
handleRiskResponse(context: IContext, response: IHttpResponse, riskResponse: RiskResponseType): Promise<void>;
|
|
14
|
+
protected handleValidRiskResponse(context: IContext, riskResponse: RiskResponseType): void;
|
|
15
|
+
protected shouldBlock(score: number): boolean;
|
|
16
|
+
}
|