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,231 @@
|
|
|
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
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
+
function step(op) {
|
|
31
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
+
while (_) try {
|
|
33
|
+
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;
|
|
34
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
+
switch (op[0]) {
|
|
36
|
+
case 0: case 1: t = op; break;
|
|
37
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
+
default:
|
|
41
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
+
if (t[2]) _.ops.pop();
|
|
46
|
+
_.trys.pop(); continue;
|
|
47
|
+
}
|
|
48
|
+
op = body.call(thisArg, _);
|
|
49
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
+
exports.DefaultBotDefenderTokenV3 = void 0;
|
|
55
|
+
var utils_1 = require("../../../utils");
|
|
56
|
+
var constants_1 = require("../../constants");
|
|
57
|
+
var TokenSignField_1 = require("./TokenSignField");
|
|
58
|
+
var BotDefenderTokenBase_1 = require("../BotDefenderTokenBase");
|
|
59
|
+
var DefaultBotDefenderTokenV3 = /** @class */ (function (_super) {
|
|
60
|
+
__extends(DefaultBotDefenderTokenV3, _super);
|
|
61
|
+
function DefaultBotDefenderTokenV3(config, cookieString, cipherUtils, hashUtils) {
|
|
62
|
+
var _this = _super.call(this, config, cookieString) || this;
|
|
63
|
+
_this.logger = config.logger;
|
|
64
|
+
_this.maxIterations = config.riskCookieMaxIterations;
|
|
65
|
+
_this.minIterations = config.riskCookieMinIterations;
|
|
66
|
+
_this.blockingScore = config.blockingScore;
|
|
67
|
+
_this.cookieString = cookieString;
|
|
68
|
+
_this.cipherUtils = cipherUtils;
|
|
69
|
+
_this.hashUtils = hashUtils;
|
|
70
|
+
return _this;
|
|
71
|
+
}
|
|
72
|
+
DefaultBotDefenderTokenV3.prototype.decrypt = function (context) {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
74
|
+
var data, salt, iterations, encryptedCookie, e_1;
|
|
75
|
+
return __generator(this, function (_a) {
|
|
76
|
+
switch (_a.label) {
|
|
77
|
+
case 0:
|
|
78
|
+
_a.trys.push([0, 2, , 3]);
|
|
79
|
+
data = this.cookieString.split(constants_1.COOKIE_SPLIT_DELIMITER);
|
|
80
|
+
if (data.length !== constants_1.COOKIE_V3_PARTS_COUNT) {
|
|
81
|
+
return [2 /*return*/, null];
|
|
82
|
+
}
|
|
83
|
+
this.hash = data[constants_1.COOKIE_V3_HMAC_INDEX];
|
|
84
|
+
salt = data[constants_1.COOKIE_V3_SALT_INDEX];
|
|
85
|
+
iterations = parseInt
|
|
86
|
+
? parseInt(data[constants_1.COOKIE_V3_ITERATIONS_INDEX])
|
|
87
|
+
: Number(data[constants_1.COOKIE_V3_ITERATIONS_INDEX]);
|
|
88
|
+
encryptedCookie = data[constants_1.COOKIE_V3_PAYLOAD_INDEX];
|
|
89
|
+
if (!iterations || iterations > this.maxIterations || iterations < this.minIterations) {
|
|
90
|
+
return [2 /*return*/, null];
|
|
91
|
+
}
|
|
92
|
+
if (!salt || typeof salt !== 'string' || salt.length > constants_1.COOKIE_V3_MAXIMUM_SALT_LENGTH) {
|
|
93
|
+
return [2 /*return*/, null];
|
|
94
|
+
}
|
|
95
|
+
if (!encryptedCookie || typeof encryptedCookie !== 'string') {
|
|
96
|
+
return [2 /*return*/, null];
|
|
97
|
+
}
|
|
98
|
+
return [4 /*yield*/, this.decryptPayload(encryptedCookie, salt, iterations)];
|
|
99
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
100
|
+
case 2:
|
|
101
|
+
e_1 = _a.sent();
|
|
102
|
+
this.logger.debug("cookie v3 decryption failed: ".concat(e_1));
|
|
103
|
+
return [3 /*break*/, 3];
|
|
104
|
+
case 3: return [2 /*return*/, null];
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
DefaultBotDefenderTokenV3.prototype.decryptPayload = function (encryptedCookie, salt, iterations) {
|
|
110
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
111
|
+
var decryptedCookie, e_2;
|
|
112
|
+
return __generator(this, function (_a) {
|
|
113
|
+
switch (_a.label) {
|
|
114
|
+
case 0:
|
|
115
|
+
_a.trys.push([0, 2, , 3]);
|
|
116
|
+
return [4 /*yield*/, this.cipherUtils.pbkdf2Decrypt(this.cookieSecret, encryptedCookie, iterations, salt)];
|
|
117
|
+
case 1:
|
|
118
|
+
decryptedCookie = _a.sent();
|
|
119
|
+
if (!decryptedCookie) {
|
|
120
|
+
return [2 /*return*/, null];
|
|
121
|
+
}
|
|
122
|
+
return [2 /*return*/, JSON.parse(decryptedCookie)];
|
|
123
|
+
case 2:
|
|
124
|
+
e_2 = _a.sent();
|
|
125
|
+
this.logger.debug("error decrypting cookie v3: ".concat(e_2));
|
|
126
|
+
return [2 /*return*/, null];
|
|
127
|
+
case 3: return [2 /*return*/];
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
DefaultBotDefenderTokenV3.prototype.validate = function (context) {
|
|
133
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
134
|
+
var signedFields, payload, hash;
|
|
135
|
+
return __generator(this, function (_a) {
|
|
136
|
+
try {
|
|
137
|
+
signedFields = this.getSignedWithFields(context);
|
|
138
|
+
payload = "".concat(this.cookieString).concat(signedFields.join(''));
|
|
139
|
+
hash = this.hashUtils.createHmac(utils_1.Algorithm.SHA256, payload, this.cookieSecret);
|
|
140
|
+
return [2 /*return*/, hash === this.hmac];
|
|
141
|
+
}
|
|
142
|
+
catch (e) {
|
|
143
|
+
this.logger.debug("error validating cookie v3: ".concat(e));
|
|
144
|
+
return [2 /*return*/, false];
|
|
145
|
+
}
|
|
146
|
+
return [2 /*return*/];
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
};
|
|
150
|
+
DefaultBotDefenderTokenV3.prototype.getSignedWithFields = function (context) {
|
|
151
|
+
var _this = this;
|
|
152
|
+
var _a;
|
|
153
|
+
if (context.isMobile) {
|
|
154
|
+
return [];
|
|
155
|
+
}
|
|
156
|
+
else if ((_a = this.payload) === null || _a === void 0 ? void 0 : _a.x) {
|
|
157
|
+
return this.payload.x.split('').map(function (char) { return _this.getSignedWithField(char, context); });
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
return [context.requestData.userAgent];
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
DefaultBotDefenderTokenV3.prototype.getSignedWithField = function (char, _a) {
|
|
164
|
+
var requestData = _a.requestData;
|
|
165
|
+
switch (char) {
|
|
166
|
+
case TokenSignField_1.TokenSignField.SOCKET_IP:
|
|
167
|
+
return requestData.ip;
|
|
168
|
+
case TokenSignField_1.TokenSignField.USER_AGENT:
|
|
169
|
+
return requestData.userAgent;
|
|
170
|
+
default:
|
|
171
|
+
return '';
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
DefaultBotDefenderTokenV3.prototype.isExpired = function () {
|
|
175
|
+
var _a;
|
|
176
|
+
return Date.now() > ((_a = this.payload) === null || _a === void 0 ? void 0 : _a.t);
|
|
177
|
+
};
|
|
178
|
+
DefaultBotDefenderTokenV3.prototype.isHighScore = function () {
|
|
179
|
+
var _a;
|
|
180
|
+
return ((_a = this.payload) === null || _a === void 0 ? void 0 : _a.s) >= this.blockingScore;
|
|
181
|
+
};
|
|
182
|
+
Object.defineProperty(DefaultBotDefenderTokenV3.prototype, "timestamp", {
|
|
183
|
+
get: function () {
|
|
184
|
+
var _a;
|
|
185
|
+
return (_a = this.payload) === null || _a === void 0 ? void 0 : _a.t;
|
|
186
|
+
},
|
|
187
|
+
enumerable: false,
|
|
188
|
+
configurable: true
|
|
189
|
+
});
|
|
190
|
+
Object.defineProperty(DefaultBotDefenderTokenV3.prototype, "uuid", {
|
|
191
|
+
get: function () {
|
|
192
|
+
var _a;
|
|
193
|
+
return (_a = this.payload) === null || _a === void 0 ? void 0 : _a.u;
|
|
194
|
+
},
|
|
195
|
+
enumerable: false,
|
|
196
|
+
configurable: true
|
|
197
|
+
});
|
|
198
|
+
Object.defineProperty(DefaultBotDefenderTokenV3.prototype, "vid", {
|
|
199
|
+
get: function () {
|
|
200
|
+
var _a;
|
|
201
|
+
return (_a = this.payload) === null || _a === void 0 ? void 0 : _a.v;
|
|
202
|
+
},
|
|
203
|
+
enumerable: false,
|
|
204
|
+
configurable: true
|
|
205
|
+
});
|
|
206
|
+
Object.defineProperty(DefaultBotDefenderTokenV3.prototype, "score", {
|
|
207
|
+
get: function () {
|
|
208
|
+
var _a;
|
|
209
|
+
return (_a = this.payload) === null || _a === void 0 ? void 0 : _a.s;
|
|
210
|
+
},
|
|
211
|
+
enumerable: false,
|
|
212
|
+
configurable: true
|
|
213
|
+
});
|
|
214
|
+
Object.defineProperty(DefaultBotDefenderTokenV3.prototype, "action", {
|
|
215
|
+
get: function () {
|
|
216
|
+
var _a;
|
|
217
|
+
return (_a = this.payload) === null || _a === void 0 ? void 0 : _a.a;
|
|
218
|
+
},
|
|
219
|
+
enumerable: false,
|
|
220
|
+
configurable: true
|
|
221
|
+
});
|
|
222
|
+
Object.defineProperty(DefaultBotDefenderTokenV3.prototype, "hmac", {
|
|
223
|
+
get: function () {
|
|
224
|
+
return this.hash;
|
|
225
|
+
},
|
|
226
|
+
enumerable: false,
|
|
227
|
+
configurable: true
|
|
228
|
+
});
|
|
229
|
+
return DefaultBotDefenderTokenV3;
|
|
230
|
+
}(BotDefenderTokenBase_1.BotDefenderTokenBase));
|
|
231
|
+
exports.DefaultBotDefenderTokenV3 = DefaultBotDefenderTokenV3;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TokenSignField = void 0;
|
|
4
|
+
var TokenSignField;
|
|
5
|
+
(function (TokenSignField) {
|
|
6
|
+
TokenSignField["SOCKET_IP"] = "s";
|
|
7
|
+
TokenSignField["USER_AGENT"] = "u";
|
|
8
|
+
})(TokenSignField = exports.TokenSignField || (exports.TokenSignField = {}));
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertMobileTokenVersionToCookieName = void 0;
|
|
4
|
+
var constants_1 = require("./constants");
|
|
5
|
+
var TokenVersion_1 = require("./TokenVersion");
|
|
6
|
+
var convertMobileTokenVersionToCookieName = function (tokenVersion) {
|
|
7
|
+
switch (tokenVersion) {
|
|
8
|
+
case TokenVersion_1.TokenVersion.V2:
|
|
9
|
+
return constants_1.COOKIE_V2_NAME;
|
|
10
|
+
case TokenVersion_1.TokenVersion.V3:
|
|
11
|
+
return constants_1.COOKIE_V3_NAME;
|
|
12
|
+
default:
|
|
13
|
+
return '';
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
exports.convertMobileTokenVersionToCookieName = convertMobileTokenVersionToCookieName;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { IConfiguration } from '../config';
|
|
2
|
+
import { IContext } from '../context';
|
|
3
|
+
import { IHttpClient } from '../http';
|
|
4
|
+
import { IBase64Utils, IHashUtils } from '../utils';
|
|
5
|
+
import { ITelemetry } from './ITelemetry';
|
|
6
|
+
export declare class DefaultTelemetry implements ITelemetry {
|
|
7
|
+
private readonly config;
|
|
8
|
+
private readonly httpClient;
|
|
9
|
+
private readonly base64Utils;
|
|
10
|
+
private readonly hashUtils;
|
|
11
|
+
constructor(config: IConfiguration, httpClient: IHttpClient, base64Utils: IBase64Utils, hashUtils: IHashUtils);
|
|
12
|
+
isValidTelemetryRequest(context: IContext): Promise<boolean>;
|
|
13
|
+
sendTelemetry(context: IContext): Promise<void>;
|
|
14
|
+
private getTelemetryHeader;
|
|
15
|
+
private isTelemetryHeaderValid;
|
|
16
|
+
private sendTelemetryActivity;
|
|
17
|
+
private createTelemetryRequest;
|
|
18
|
+
private createTelemetryActivity;
|
|
19
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
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.DefaultTelemetry = void 0;
|
|
40
|
+
var http_1 = require("../http");
|
|
41
|
+
var activities_1 = require("../activities");
|
|
42
|
+
var utils_1 = require("../utils");
|
|
43
|
+
var constants_1 = require("./constants");
|
|
44
|
+
var DefaultTelemetry = /** @class */ (function () {
|
|
45
|
+
function DefaultTelemetry(config, httpClient, base64Utils, hashUtils) {
|
|
46
|
+
this.config = config;
|
|
47
|
+
this.httpClient = httpClient;
|
|
48
|
+
this.base64Utils = base64Utils;
|
|
49
|
+
this.hashUtils = hashUtils;
|
|
50
|
+
}
|
|
51
|
+
DefaultTelemetry.prototype.isValidTelemetryRequest = function (context) {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
53
|
+
var telemetryHeader, _a, e_1;
|
|
54
|
+
return __generator(this, function (_b) {
|
|
55
|
+
switch (_b.label) {
|
|
56
|
+
case 0:
|
|
57
|
+
_b.trys.push([0, 3, , 4]);
|
|
58
|
+
telemetryHeader = this.getTelemetryHeader(context);
|
|
59
|
+
_a = !!telemetryHeader;
|
|
60
|
+
if (!_a) return [3 /*break*/, 2];
|
|
61
|
+
return [4 /*yield*/, this.isTelemetryHeaderValid(telemetryHeader)];
|
|
62
|
+
case 1:
|
|
63
|
+
_a = (_b.sent());
|
|
64
|
+
_b.label = 2;
|
|
65
|
+
case 2: return [2 /*return*/, _a];
|
|
66
|
+
case 3:
|
|
67
|
+
e_1 = _b.sent();
|
|
68
|
+
this.config.logger.debug("error validating telemetry - ".concat(e_1));
|
|
69
|
+
return [2 /*return*/, false];
|
|
70
|
+
case 4: return [2 /*return*/];
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
DefaultTelemetry.prototype.sendTelemetry = function (context) {
|
|
76
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
77
|
+
var e_2;
|
|
78
|
+
return __generator(this, function (_a) {
|
|
79
|
+
switch (_a.label) {
|
|
80
|
+
case 0:
|
|
81
|
+
_a.trys.push([0, 2, , 3]);
|
|
82
|
+
return [4 /*yield*/, this.sendTelemetryActivity(context)];
|
|
83
|
+
case 1:
|
|
84
|
+
_a.sent();
|
|
85
|
+
return [3 /*break*/, 3];
|
|
86
|
+
case 2:
|
|
87
|
+
e_2 = _a.sent();
|
|
88
|
+
this.config.logger.debug("error sending telemetry - ".concat(e_2));
|
|
89
|
+
return [3 /*break*/, 3];
|
|
90
|
+
case 3: return [2 /*return*/];
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
DefaultTelemetry.prototype.getTelemetryHeader = function (context) {
|
|
96
|
+
var _a;
|
|
97
|
+
return ((_a = context.requestData.headers.get(constants_1.TELEMETRY_HEADER_NAME)) === null || _a === void 0 ? void 0 : _a[0]) || '';
|
|
98
|
+
};
|
|
99
|
+
DefaultTelemetry.prototype.isTelemetryHeaderValid = function (headerValue) {
|
|
100
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
101
|
+
var decodedValue, splitValue, timestamp, givenHmac, calculatedHmac, curUnixTime, timestampNumber;
|
|
102
|
+
return __generator(this, function (_a) {
|
|
103
|
+
this.config.logger.debug('received command to send enforcer telemetry');
|
|
104
|
+
decodedValue = this.base64Utils.base64Decode(headerValue);
|
|
105
|
+
splitValue = decodedValue.split(constants_1.TELEMETRY_HEADER_DELIMITER);
|
|
106
|
+
if (splitValue.length !== constants_1.TELEMETRY_HEADER_PART_COUNT) {
|
|
107
|
+
this.config.logger.debug("malformed ".concat(constants_1.TELEMETRY_HEADER_NAME, " header: ").concat(decodedValue));
|
|
108
|
+
return [2 /*return*/, false];
|
|
109
|
+
}
|
|
110
|
+
timestamp = splitValue[constants_1.TELEMETRY_HEADER_TIMESTAMP_INDEX];
|
|
111
|
+
givenHmac = splitValue[constants_1.TELEMETRY_HEADER_HMAC_INDEX];
|
|
112
|
+
calculatedHmac = this.hashUtils.createHmac(utils_1.Algorithm.SHA256, timestamp, this.config.cookieSecret);
|
|
113
|
+
if (givenHmac !== calculatedHmac) {
|
|
114
|
+
this.config.logger.debug("".concat(constants_1.TELEMETRY_HEADER_NAME, " hmac validation failed. original hmac: ").concat(givenHmac, ", timestamp: ").concat(timestamp, "."));
|
|
115
|
+
return [2 /*return*/, false];
|
|
116
|
+
}
|
|
117
|
+
curUnixTime = +new Date();
|
|
118
|
+
timestampNumber = parseInt ? parseInt(timestamp) : Number(timestamp);
|
|
119
|
+
if (isNaN(timestampNumber) || timestampNumber < curUnixTime) {
|
|
120
|
+
this.config.logger.debug("".concat(constants_1.TELEMETRY_HEADER_NAME, " timestamp expired: ").concat(timestamp, " < ").concat(curUnixTime));
|
|
121
|
+
return [2 /*return*/, false];
|
|
122
|
+
}
|
|
123
|
+
return [2 /*return*/, true];
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
DefaultTelemetry.prototype.sendTelemetryActivity = function (context) {
|
|
128
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
129
|
+
var telemetryRequest;
|
|
130
|
+
return __generator(this, function (_a) {
|
|
131
|
+
switch (_a.label) {
|
|
132
|
+
case 0:
|
|
133
|
+
telemetryRequest = this.createTelemetryRequest(context);
|
|
134
|
+
this.config.logger.debug("sending telemetry to ".concat(telemetryRequest.url));
|
|
135
|
+
return [4 /*yield*/, this.httpClient.send(telemetryRequest)];
|
|
136
|
+
case 1:
|
|
137
|
+
_a.sent();
|
|
138
|
+
return [2 /*return*/];
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
DefaultTelemetry.prototype.createTelemetryRequest = function (context) {
|
|
144
|
+
var _a;
|
|
145
|
+
var url = "".concat(this.config.backendScoreApiUrl).concat(constants_1.TELEMETRY_ENDPOINT);
|
|
146
|
+
var method = http_1.HttpMethod.POST;
|
|
147
|
+
var headers = (_a = {},
|
|
148
|
+
_a[http_1.CONTENT_TYPE_HEADER_NAME] = [http_1.ContentType.APPLICATION_JSON],
|
|
149
|
+
_a[http_1.AUTHORIZATION_HEADER_NAME] = [(0, utils_1.getAuthorizationHeader)(this.config.authToken)],
|
|
150
|
+
_a);
|
|
151
|
+
var activity = this.createTelemetryActivity(context);
|
|
152
|
+
return new http_1.DefaultHttpRequest(url, { method: method, headers: headers, body: JSON.stringify(activity) });
|
|
153
|
+
};
|
|
154
|
+
DefaultTelemetry.prototype.createTelemetryActivity = function (context) {
|
|
155
|
+
var SENSITIVE_CONFIG_FIELDS = ['px_auth_token', 'px_cookie_secret'];
|
|
156
|
+
var config = this.config.toParams();
|
|
157
|
+
config = (0, utils_1.removeSensitiveFields)(config, SENSITIVE_CONFIG_FIELDS);
|
|
158
|
+
var activity = {
|
|
159
|
+
type: activities_1.ActivityType.ENFORCER_TELEMETRY,
|
|
160
|
+
timestamp: Date.now(),
|
|
161
|
+
px_app_id: this.config.appId,
|
|
162
|
+
details: {
|
|
163
|
+
update_reason: constants_1.TELEMETRY_UPDATE_REASON,
|
|
164
|
+
module_version: this.config.moduleVersion,
|
|
165
|
+
enforcer_configs: config,
|
|
166
|
+
},
|
|
167
|
+
};
|
|
168
|
+
(0, utils_1.transferExistingProperties)(context.serverData, activity.details, {
|
|
169
|
+
osName: 'os_name',
|
|
170
|
+
nodeName: 'node_name',
|
|
171
|
+
});
|
|
172
|
+
return activity;
|
|
173
|
+
};
|
|
174
|
+
return DefaultTelemetry;
|
|
175
|
+
}());
|
|
176
|
+
exports.DefaultTelemetry = DefaultTelemetry;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IContext } from '../context';
|
|
2
|
+
export interface ITelemetry {
|
|
3
|
+
/**
|
|
4
|
+
* @param context - The request context.
|
|
5
|
+
* @returns Promise<boolean> - A Promise resolving to a boolean that indicates whether the request is a valid telemetry request.
|
|
6
|
+
*/
|
|
7
|
+
isValidTelemetryRequest(context: IContext): Promise<boolean>;
|
|
8
|
+
/**
|
|
9
|
+
* @param context - The request context.
|
|
10
|
+
* @returns void
|
|
11
|
+
*/
|
|
12
|
+
sendTelemetry(context: IContext): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const TELEMETRY_HEADER_DELIMITER = ":";
|
|
2
|
+
export declare const TELEMETRY_HEADER_TIMESTAMP_INDEX = 0;
|
|
3
|
+
export declare const TELEMETRY_HEADER_HMAC_INDEX = 1;
|
|
4
|
+
export declare const TELEMETRY_HEADER_PART_COUNT = 2;
|
|
5
|
+
export declare const TELEMETRY_HEADER_NAME = "x-px-enforcer-telemetry";
|
|
6
|
+
export declare const TELEMETRY_ENDPOINT = "/api/v2/risk/telemetry";
|
|
7
|
+
export declare const TELEMETRY_UPDATE_REASON = "command";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TELEMETRY_UPDATE_REASON = exports.TELEMETRY_ENDPOINT = exports.TELEMETRY_HEADER_NAME = exports.TELEMETRY_HEADER_PART_COUNT = exports.TELEMETRY_HEADER_HMAC_INDEX = exports.TELEMETRY_HEADER_TIMESTAMP_INDEX = exports.TELEMETRY_HEADER_DELIMITER = void 0;
|
|
4
|
+
exports.TELEMETRY_HEADER_DELIMITER = ':';
|
|
5
|
+
exports.TELEMETRY_HEADER_TIMESTAMP_INDEX = 0;
|
|
6
|
+
exports.TELEMETRY_HEADER_HMAC_INDEX = 1;
|
|
7
|
+
exports.TELEMETRY_HEADER_PART_COUNT = 2;
|
|
8
|
+
exports.TELEMETRY_HEADER_NAME = 'x-px-enforcer-telemetry';
|
|
9
|
+
exports.TELEMETRY_ENDPOINT = '/api/v2/risk/telemetry';
|
|
10
|
+
exports.TELEMETRY_UPDATE_REASON = 'command';
|
|
@@ -0,0 +1,20 @@
|
|
|
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.DefaultTelemetry = void 0;
|
|
18
|
+
var DefaultTelemetry_1 = require("./DefaultTelemetry");
|
|
19
|
+
Object.defineProperty(exports, "DefaultTelemetry", { enumerable: true, get: function () { return DefaultTelemetry_1.DefaultTelemetry; } });
|
|
20
|
+
__exportStar(require("./constants"), exports);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ActivityType } from '../../activities';
|
|
2
|
+
import { ConfigurationParams } from '../../config';
|
|
3
|
+
export declare type TelemetryActivityDetails = {
|
|
4
|
+
enforcer_configs: ConfigurationParams;
|
|
5
|
+
module_version: string;
|
|
6
|
+
update_reason: 'command';
|
|
7
|
+
node_name?: string;
|
|
8
|
+
os_name?: string;
|
|
9
|
+
};
|
|
10
|
+
export declare type TelemetryActivity = {
|
|
11
|
+
type: ActivityType.ENFORCER_TELEMETRY;
|
|
12
|
+
timestamp: number;
|
|
13
|
+
px_app_id: string;
|
|
14
|
+
details: TelemetryActivityDetails;
|
|
15
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Algorithm = void 0;
|
|
4
|
+
var Algorithm;
|
|
5
|
+
(function (Algorithm) {
|
|
6
|
+
Algorithm["SHA256"] = "sha256";
|
|
7
|
+
Algorithm["AES_CBC"] = "aes_cbc";
|
|
8
|
+
})(Algorithm = exports.Algorithm || (exports.Algorithm = {}));
|
|
@@ -0,0 +1,26 @@
|
|
|
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.EnforcerException = void 0;
|
|
19
|
+
var EnforcerException = /** @class */ (function (_super) {
|
|
20
|
+
__extends(EnforcerException, _super);
|
|
21
|
+
function EnforcerException(message) {
|
|
22
|
+
return _super.call(this, "enforcer exception - ".concat(message)) || this;
|
|
23
|
+
}
|
|
24
|
+
return EnforcerException;
|
|
25
|
+
}(Error));
|
|
26
|
+
exports.EnforcerException = EnforcerException;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IContext } from '../context/IContext';
|
|
2
|
+
export interface IScoreRetriever {
|
|
3
|
+
/**
|
|
4
|
+
* @param context - The request context.
|
|
5
|
+
* @returns boolean - Whether or not the score retriever should attempt to retrieve the risk score.
|
|
6
|
+
*/
|
|
7
|
+
shouldRetrieveScore(context: IContext): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* @param context - The request context.
|
|
10
|
+
* @returns Promise<boolean> - A Promise resolving to whether or not the score was retrieved successfully. If so,
|
|
11
|
+
* the function should set the score property of the context to the retrieved value.
|
|
12
|
+
*/
|
|
13
|
+
retrieveScore(context: IContext): Promise<boolean>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ModuleMode = void 0;
|
|
4
|
+
var ModuleMode;
|
|
5
|
+
(function (ModuleMode) {
|
|
6
|
+
ModuleMode["MONITOR"] = "monitor";
|
|
7
|
+
ModuleMode["ACTIVE_BLOCKING"] = "active_blocking";
|
|
8
|
+
})(ModuleMode = exports.ModuleMode || (exports.ModuleMode = {}));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PassReason = void 0;
|
|
4
|
+
var PassReason;
|
|
5
|
+
(function (PassReason) {
|
|
6
|
+
PassReason["COOKIE"] = "cookie";
|
|
7
|
+
PassReason["S2S"] = "s2s";
|
|
8
|
+
PassReason["S2S_ERROR"] = "s2s_error";
|
|
9
|
+
PassReason["S2S_TIMEOUT"] = "s2s_timeout";
|
|
10
|
+
})(PassReason = exports.PassReason || (exports.PassReason = {}));
|