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,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VidSource = void 0;
|
|
4
|
+
var VidSource;
|
|
5
|
+
(function (VidSource) {
|
|
6
|
+
VidSource["VID_COOKIE"] = "vid_cookie";
|
|
7
|
+
VidSource["RISK_COOKIE"] = "risk_cookie";
|
|
8
|
+
})(VidSource = exports.VidSource || (exports.VidSource = {}));
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefaultBase64Utils = void 0;
|
|
4
|
+
var js_base64_1 = require("js-base64");
|
|
5
|
+
var DefaultBase64Utils = /** @class */ (function () {
|
|
6
|
+
function DefaultBase64Utils() {
|
|
7
|
+
}
|
|
8
|
+
DefaultBase64Utils.prototype.base64Encode = function (stringToEncode) {
|
|
9
|
+
return (0, js_base64_1.encode)(stringToEncode);
|
|
10
|
+
};
|
|
11
|
+
DefaultBase64Utils.prototype.base64Decode = function (stringToDecode) {
|
|
12
|
+
return (0, js_base64_1.decode)(stringToDecode);
|
|
13
|
+
};
|
|
14
|
+
return DefaultBase64Utils;
|
|
15
|
+
}());
|
|
16
|
+
exports.DefaultBase64Utils = DefaultBase64Utils;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefaultBase64Utils = void 0;
|
|
4
|
+
var DefaultBase64Utils_1 = require("./DefaultBase64Utils");
|
|
5
|
+
Object.defineProperty(exports, "DefaultBase64Utils", { enumerable: true, get: function () { return DefaultBase64Utils_1.DefaultBase64Utils; } });
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare type Pbkdf2DecryptOptions = {
|
|
2
|
+
keylen?: number;
|
|
3
|
+
ivlen?: number;
|
|
4
|
+
};
|
|
5
|
+
export interface ICipherUtils {
|
|
6
|
+
pbkdf2Decrypt(secret: string, encryptedString: string, iterations: number, salt: string, options?: Pbkdf2DecryptOptions): string | Promise<string>;
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ICipherUtils, Pbkdf2DecryptOptions } from './ICipherUtils';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const PXVID_COOKIE_NAME = "_pxvid";
|
|
2
|
+
export declare const PXHD_COOKIE_NAME = "_pxhd";
|
|
3
|
+
export declare const PXDE_COOKIE_NAME = "_pxde";
|
|
4
|
+
export declare const CD_PXVID_COOKIE_NAME = "__pxvid";
|
|
5
|
+
export declare const CTS_COOKIE_NAME = "pxcts";
|
|
6
|
+
export declare const BYPASS_MONITOR_HEADER_VALUE = "1";
|
|
7
|
+
export declare const X_PX_AUTHORIZATION_HEADER_NAME = "x-px-authorization";
|
|
8
|
+
export declare const X_PX_ORIGINAL_TOKEN_HEADER_NAME = "x-px-original-token";
|
|
9
|
+
export declare const X_PX_BYPASS_REASON_HEADER_NAME = "x-px-bypass-reason";
|
|
10
|
+
export declare const CORE_MODULE_VERSION = "JS Core 0.1.0";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CORE_MODULE_VERSION = exports.X_PX_BYPASS_REASON_HEADER_NAME = exports.X_PX_ORIGINAL_TOKEN_HEADER_NAME = exports.X_PX_AUTHORIZATION_HEADER_NAME = exports.BYPASS_MONITOR_HEADER_VALUE = exports.CTS_COOKIE_NAME = exports.CD_PXVID_COOKIE_NAME = exports.PXDE_COOKIE_NAME = exports.PXHD_COOKIE_NAME = exports.PXVID_COOKIE_NAME = void 0;
|
|
4
|
+
exports.PXVID_COOKIE_NAME = '_pxvid';
|
|
5
|
+
exports.PXHD_COOKIE_NAME = '_pxhd';
|
|
6
|
+
exports.PXDE_COOKIE_NAME = '_pxde';
|
|
7
|
+
exports.CD_PXVID_COOKIE_NAME = '__pxvid';
|
|
8
|
+
exports.CTS_COOKIE_NAME = 'pxcts';
|
|
9
|
+
exports.BYPASS_MONITOR_HEADER_VALUE = '1';
|
|
10
|
+
exports.X_PX_AUTHORIZATION_HEADER_NAME = 'x-px-authorization';
|
|
11
|
+
exports.X_PX_ORIGINAL_TOKEN_HEADER_NAME = 'x-px-original-token';
|
|
12
|
+
exports.X_PX_BYPASS_REASON_HEADER_NAME = 'x-px-bypass-reason';
|
|
13
|
+
exports.CORE_MODULE_VERSION = 'JS Core 0.1.0';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefaultCookieParser = void 0;
|
|
4
|
+
var cookie = require("cookie");
|
|
5
|
+
var DefaultCookieParser = /** @class */ (function () {
|
|
6
|
+
function DefaultCookieParser() {
|
|
7
|
+
}
|
|
8
|
+
DefaultCookieParser.prototype.parseCookies = function (cookieHeaderValue) {
|
|
9
|
+
return cookie.parse(cookieHeaderValue);
|
|
10
|
+
};
|
|
11
|
+
return DefaultCookieParser;
|
|
12
|
+
}());
|
|
13
|
+
exports.DefaultCookieParser = DefaultCookieParser;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefaultCookieParser = void 0;
|
|
4
|
+
var DefaultCookieParser_1 = require("./DefaultCookieParser");
|
|
5
|
+
Object.defineProperty(exports, "DefaultCookieParser", { enumerable: true, get: function () { return DefaultCookieParser_1.DefaultCookieParser; } });
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefaultHashUtils = void 0;
|
|
4
|
+
var crypto_js_1 = require("crypto-js");
|
|
5
|
+
var Algorithm_1 = require("../Algorithm");
|
|
6
|
+
var DefaultHashUtils = /** @class */ (function () {
|
|
7
|
+
function DefaultHashUtils() {
|
|
8
|
+
}
|
|
9
|
+
DefaultHashUtils.prototype.createHmac = function (algo, payload, secret) {
|
|
10
|
+
switch (algo) {
|
|
11
|
+
case Algorithm_1.Algorithm.SHA256:
|
|
12
|
+
default:
|
|
13
|
+
var payloadHmac = (0, crypto_js_1.HmacSHA256)(payload, secret);
|
|
14
|
+
return crypto_js_1.enc.Hex.stringify(payloadHmac);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
return DefaultHashUtils;
|
|
18
|
+
}());
|
|
19
|
+
exports.DefaultHashUtils = DefaultHashUtils;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefaultHashUtils = void 0;
|
|
4
|
+
var DefaultHashUtils_1 = require("./DefaultHashUtils");
|
|
5
|
+
Object.defineProperty(exports, "DefaultHashUtils", { enumerable: true, get: function () { return DefaultHashUtils_1.DefaultHashUtils; } });
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from './base64';
|
|
2
|
+
export * from './cookie_parser';
|
|
3
|
+
export * from './hash';
|
|
4
|
+
export * from './ip_range_checker';
|
|
5
|
+
export * from './uuid_generator';
|
|
6
|
+
export * from './cipher';
|
|
7
|
+
export * from './utils';
|
|
8
|
+
export * from './constants';
|
|
9
|
+
export { ModuleMode } from './ModuleMode';
|
|
10
|
+
export { VidSource } from './VidSource';
|
|
11
|
+
export { PassReason } from './PassReason';
|
|
12
|
+
export { Algorithm } from './Algorithm';
|
|
13
|
+
export { EnforcerException } from './EnforcerException';
|
|
14
|
+
export { IScoreRetriever } from './IScoreRetriever';
|
|
@@ -0,0 +1,35 @@
|
|
|
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.EnforcerException = exports.Algorithm = exports.PassReason = exports.VidSource = exports.ModuleMode = void 0;
|
|
18
|
+
__exportStar(require("./base64"), exports);
|
|
19
|
+
__exportStar(require("./cookie_parser"), exports);
|
|
20
|
+
__exportStar(require("./hash"), exports);
|
|
21
|
+
__exportStar(require("./ip_range_checker"), exports);
|
|
22
|
+
__exportStar(require("./uuid_generator"), exports);
|
|
23
|
+
__exportStar(require("./cipher"), exports);
|
|
24
|
+
__exportStar(require("./utils"), exports);
|
|
25
|
+
__exportStar(require("./constants"), exports);
|
|
26
|
+
var ModuleMode_1 = require("./ModuleMode");
|
|
27
|
+
Object.defineProperty(exports, "ModuleMode", { enumerable: true, get: function () { return ModuleMode_1.ModuleMode; } });
|
|
28
|
+
var VidSource_1 = require("./VidSource");
|
|
29
|
+
Object.defineProperty(exports, "VidSource", { enumerable: true, get: function () { return VidSource_1.VidSource; } });
|
|
30
|
+
var PassReason_1 = require("./PassReason");
|
|
31
|
+
Object.defineProperty(exports, "PassReason", { enumerable: true, get: function () { return PassReason_1.PassReason; } });
|
|
32
|
+
var Algorithm_1 = require("./Algorithm");
|
|
33
|
+
Object.defineProperty(exports, "Algorithm", { enumerable: true, get: function () { return Algorithm_1.Algorithm; } });
|
|
34
|
+
var EnforcerException_1 = require("./EnforcerException");
|
|
35
|
+
Object.defineProperty(exports, "EnforcerException", { enumerable: true, get: function () { return EnforcerException_1.EnforcerException; } });
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefaultIpRangeChecker = void 0;
|
|
4
|
+
var ipRangeCheck = require("ip-range-check");
|
|
5
|
+
var DefaultIpRangeChecker = /** @class */ (function () {
|
|
6
|
+
function DefaultIpRangeChecker() {
|
|
7
|
+
}
|
|
8
|
+
DefaultIpRangeChecker.prototype.isIpInRange = function (ip, range) {
|
|
9
|
+
return ipRangeCheck(ip, range);
|
|
10
|
+
};
|
|
11
|
+
return DefaultIpRangeChecker;
|
|
12
|
+
}());
|
|
13
|
+
exports.DefaultIpRangeChecker = DefaultIpRangeChecker;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefaultIpRangeChecker = void 0;
|
|
4
|
+
var DefaultIpRangeChecker_1 = require("./DefaultIpRangeChecker");
|
|
5
|
+
Object.defineProperty(exports, "DefaultIpRangeChecker", { enumerable: true, get: function () { return DefaultIpRangeChecker_1.DefaultIpRangeChecker; } });
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { HttpHeaders } from '../http';
|
|
2
|
+
export declare const isValidEnumValue: <T>(options: Record<string, T>, selection: T) => boolean;
|
|
3
|
+
export declare const isValidUuid: (uuid: string) => boolean;
|
|
4
|
+
export declare const getScoreApiDomain: (appId: string) => string;
|
|
5
|
+
export declare const getCollectorDomain: (appId: string) => string;
|
|
6
|
+
export declare const getAuthorizationHeader: (authToken: string) => string;
|
|
7
|
+
export declare const getExtension: (route: string) => string;
|
|
8
|
+
export declare const getDecodedUrl: (rawUrl: string) => URL;
|
|
9
|
+
export declare const removeSensitiveFields: <T extends Record<string, any>>(object: T, sensitiveFields: (keyof T)[]) => T;
|
|
10
|
+
export declare const removeSensitiveHeaders: (headers: HttpHeaders, sensitiveHeaderNames: string[]) => HttpHeaders;
|
|
11
|
+
export declare const isRouteInPatterns: (route: string, patterns: Array<string | RegExp>) => boolean;
|
|
12
|
+
export declare const isRouteMatch: (route: string, pattern: string | RegExp) => boolean;
|
|
13
|
+
export declare const transferExistingProperties: <FromObj extends Record<string, any>, ToObj extends Record<string, any>>(fromObj: FromObj, toObj: ToObj, propertyMappings: Partial<Record<keyof FromObj, keyof ToObj>>) => void;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transferExistingProperties = exports.isRouteMatch = exports.isRouteInPatterns = exports.removeSensitiveHeaders = exports.removeSensitiveFields = exports.getDecodedUrl = exports.getExtension = exports.getAuthorizationHeader = exports.getCollectorDomain = exports.getScoreApiDomain = exports.isValidUuid = exports.isValidEnumValue = void 0;
|
|
4
|
+
var isValidEnumValue = function (options, selection) {
|
|
5
|
+
return Object.values(options).includes(selection);
|
|
6
|
+
};
|
|
7
|
+
exports.isValidEnumValue = isValidEnumValue;
|
|
8
|
+
var isValidUuid = function (uuid) {
|
|
9
|
+
if (!uuid) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
var uuidValidator = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
|
|
13
|
+
return uuidValidator.test(uuid);
|
|
14
|
+
};
|
|
15
|
+
exports.isValidUuid = isValidUuid;
|
|
16
|
+
var getScoreApiDomain = function (appId) { return "sapi-".concat(appId.toLowerCase(), ".perimeterx.net"); };
|
|
17
|
+
exports.getScoreApiDomain = getScoreApiDomain;
|
|
18
|
+
var getCollectorDomain = function (appId) { return "collector-".concat(appId.toLowerCase(), ".perimeterx.net"); };
|
|
19
|
+
exports.getCollectorDomain = getCollectorDomain;
|
|
20
|
+
var getAuthorizationHeader = function (authToken) { return "Bearer ".concat(authToken); };
|
|
21
|
+
exports.getAuthorizationHeader = getAuthorizationHeader;
|
|
22
|
+
var getExtension = function (route) {
|
|
23
|
+
var EXTENSION_INDICATOR = '.';
|
|
24
|
+
if (route.indexOf(EXTENSION_INDICATOR) === -1) {
|
|
25
|
+
return '';
|
|
26
|
+
}
|
|
27
|
+
var cleanPath = route.split('?')[0].split('#')[0];
|
|
28
|
+
var endOfPath = cleanPath.substring(cleanPath.lastIndexOf('/') + 1);
|
|
29
|
+
var extensionIndex = endOfPath.lastIndexOf(EXTENSION_INDICATOR);
|
|
30
|
+
if (extensionIndex === -1 || extensionIndex + 1 === endOfPath.length) {
|
|
31
|
+
return '';
|
|
32
|
+
}
|
|
33
|
+
return endOfPath.substring(extensionIndex);
|
|
34
|
+
};
|
|
35
|
+
exports.getExtension = getExtension;
|
|
36
|
+
var getDecodedUrl = function (rawUrl) {
|
|
37
|
+
rawUrl = rawUrl.replace(/%/g, '%25');
|
|
38
|
+
try {
|
|
39
|
+
return new URL(decodeURIComponent(rawUrl));
|
|
40
|
+
}
|
|
41
|
+
catch (e) {
|
|
42
|
+
return new URL(rawUrl);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
exports.getDecodedUrl = getDecodedUrl;
|
|
46
|
+
var removeSensitiveFields = function (object, sensitiveFields) {
|
|
47
|
+
var newObj = Object.assign({}, object);
|
|
48
|
+
sensitiveFields.forEach(function (fieldName) {
|
|
49
|
+
delete newObj[fieldName];
|
|
50
|
+
});
|
|
51
|
+
return newObj;
|
|
52
|
+
};
|
|
53
|
+
exports.removeSensitiveFields = removeSensitiveFields;
|
|
54
|
+
var removeSensitiveHeaders = function (headers, sensitiveHeaderNames) {
|
|
55
|
+
var headersCopy = headers.copy();
|
|
56
|
+
sensitiveHeaderNames.forEach(function (name) {
|
|
57
|
+
headersCopy.delete(name);
|
|
58
|
+
});
|
|
59
|
+
return headersCopy;
|
|
60
|
+
};
|
|
61
|
+
exports.removeSensitiveHeaders = removeSensitiveHeaders;
|
|
62
|
+
var isRouteInPatterns = function (route, patterns) {
|
|
63
|
+
return patterns.some(function (pattern) { return (0, exports.isRouteMatch)(route, pattern); });
|
|
64
|
+
};
|
|
65
|
+
exports.isRouteInPatterns = isRouteInPatterns;
|
|
66
|
+
var isRouteMatch = function (route, pattern) {
|
|
67
|
+
if (!route || !pattern) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
if (pattern instanceof RegExp && route.match(pattern)) {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
if (typeof pattern === 'string' && route.startsWith(pattern)) {
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
return false;
|
|
77
|
+
};
|
|
78
|
+
exports.isRouteMatch = isRouteMatch;
|
|
79
|
+
var transferExistingProperties = function (fromObj, toObj, propertyMappings) {
|
|
80
|
+
if (!toObj || !fromObj) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
Object.entries(propertyMappings).forEach(function (_a) {
|
|
84
|
+
var fromObjKey = _a[0], toObjKey = _a[1];
|
|
85
|
+
if ((typeof fromObj[fromObjKey] !== 'string' && fromObj[fromObjKey] != null) ||
|
|
86
|
+
(typeof fromObj[fromObjKey] === 'string' && fromObj[fromObjKey] !== '')) {
|
|
87
|
+
toObj[toObjKey] = fromObj[fromObjKey];
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
exports.transferExistingProperties = transferExistingProperties;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefaultUuidGenerator = void 0;
|
|
4
|
+
var uuid_1 = require("uuid");
|
|
5
|
+
var DefaultUuidGenerator = /** @class */ (function () {
|
|
6
|
+
function DefaultUuidGenerator() {
|
|
7
|
+
}
|
|
8
|
+
DefaultUuidGenerator.prototype.generateUuidV4 = function () {
|
|
9
|
+
return (0, uuid_1.v4)();
|
|
10
|
+
};
|
|
11
|
+
return DefaultUuidGenerator;
|
|
12
|
+
}());
|
|
13
|
+
exports.DefaultUuidGenerator = DefaultUuidGenerator;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefaultUuidGenerator = void 0;
|
|
4
|
+
var DefaultUuidGenerator_1 = require("./DefaultUuidGenerator");
|
|
5
|
+
Object.defineProperty(exports, "DefaultUuidGenerator", { enumerable: true, get: function () { return DefaultUuidGenerator_1.DefaultUuidGenerator; } });
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "perimeterx-js-core",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"types": "lib/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"lib/**/*"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"clean": "rm -rf lib",
|
|
13
|
+
"lint": "./node_modules/eslint/bin/eslint.js . --ext .ts",
|
|
14
|
+
"lint:fix": "./node_modules/eslint/bin/eslint.js . --ext .ts --fix",
|
|
15
|
+
"test": "mocha",
|
|
16
|
+
"coverage": "nyc npm run test"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"cookie": "^0.5.0",
|
|
20
|
+
"crypto-js": "^4.1.1",
|
|
21
|
+
"ip-range-check": "^0.2.0",
|
|
22
|
+
"js-base64": "^3.7.2",
|
|
23
|
+
"uuid": "^9.0.0"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/chai": "^4.3.3",
|
|
27
|
+
"@types/chai-as-promised": "^7.1.5",
|
|
28
|
+
"@types/cookie": "^0.5.1",
|
|
29
|
+
"@types/crypto-js": "^4.1.1",
|
|
30
|
+
"@types/mocha": "^10.0.0",
|
|
31
|
+
"@types/sinon": "^10.0.13",
|
|
32
|
+
"@types/uuid": "^8.3.4",
|
|
33
|
+
"@typescript-eslint/eslint-plugin": "^5.40.0",
|
|
34
|
+
"@typescript-eslint/parser": "^5.40.0",
|
|
35
|
+
"chai": "^4.3.6",
|
|
36
|
+
"chai-as-promised": "^7.1.1",
|
|
37
|
+
"core-js": "^3.19.1",
|
|
38
|
+
"eslint": "^8.25.0",
|
|
39
|
+
"eslint-config-prettier": "^8.5.0",
|
|
40
|
+
"eslint-plugin-no-loops": "^0.3.0",
|
|
41
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
42
|
+
"mocha": "^10.0.0",
|
|
43
|
+
"nyc": "^15.1.0",
|
|
44
|
+
"prettier": "^2.7.1",
|
|
45
|
+
"sinon": "^14.0.1",
|
|
46
|
+
"ts-loader": "^9.4.1",
|
|
47
|
+
"ts-node": "^10.9.1",
|
|
48
|
+
"typescript": "^4.4.4"
|
|
49
|
+
},
|
|
50
|
+
"author": "",
|
|
51
|
+
"license": "ISC"
|
|
52
|
+
}
|