perimeterx-js-core 0.10.0 → 0.12.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/lib/cjs/action/utils.js +6 -1
- package/lib/cjs/activities/utils.js +11 -8
- package/lib/cjs/blocker/BlockerBase.js +29 -0
- package/lib/cjs/blocker/JsonBlockerBase.js +36 -0
- package/lib/cjs/blocker/MobileBlocker.js +48 -0
- package/lib/cjs/blocker/index.js +5 -3
- package/lib/cjs/blocker/{BlockAction.js → model/BlockAction.js} +2 -0
- package/lib/cjs/blocker/{BlockActionToWordMap.js → model/BlockActionToWordMap.js} +1 -0
- package/lib/cjs/blocker/model/index.js +19 -0
- package/lib/cjs/{products/bot_defender/block → blocker}/utils.js +10 -7
- package/lib/cjs/config/ConfigurationBase.js +7 -0
- package/lib/cjs/config/defaults/DefaultCommonConfigurationParams.js +1 -0
- package/lib/cjs/config/remote_config/DefaultRemoteConfigUpdater.js +23 -11
- package/lib/cjs/context/DefaultContext.js +18 -3
- package/lib/cjs/custom_parameters/CustomParameters.js +1 -0
- package/lib/cjs/custom_parameters/CustomParametersUtils.js +5 -0
- package/lib/cjs/enforcer/EnforcerBase.js +9 -6
- package/lib/cjs/http/interfaces/index.js +0 -2
- package/lib/cjs/http/utils/constants.js +2 -1
- package/lib/cjs/http/utils/index.js +0 -3
- package/lib/cjs/impl/cipher/CryptoCipherUtils.js +2 -1
- package/lib/cjs/impl/hash/CryptoHashUtils.js +2 -1
- package/lib/cjs/impl/hash/SubtleCryptoHashUtils.js +1 -32
- package/lib/cjs/impl/hmac/CryptoHmacUtils.js +5 -10
- package/lib/cjs/impl/hmac/SubtleCryptoHmacUtils.js +72 -0
- package/lib/cjs/impl/http/phin/PhinIncomingResponse.js +5 -2
- package/lib/cjs/impl/url/CustomImplUrlUtils.js +71 -0
- package/lib/cjs/impl/url/DefaultUrlUtils.js +27 -0
- package/lib/cjs/{http/utils → impl/url}/UrlImpl.js +3 -2
- package/lib/cjs/{http/utils → impl/url}/UrlSearchParamsImpl.js +8 -9
- package/lib/cjs/logger/HttpLogServiceClient.js +4 -5
- package/lib/cjs/phase/flow/EnforceFlow.js +4 -1
- package/lib/cjs/phase/impl/DecideActionPhase.js +8 -0
- package/lib/cjs/phase/impl/EnrichContextFromRequestPhase.js +2 -2
- package/lib/cjs/phase/impl/RiskApiPhase.js +6 -8
- package/lib/cjs/products/bot_defender/BotDefender.js +2 -1
- package/lib/cjs/products/bot_defender/block/captcha/CaptchaBlocker.js +2 -2
- package/lib/cjs/products/bot_defender/block/captcha/HtmlCaptchaBlocker.js +26 -17
- package/lib/cjs/products/bot_defender/block/captcha/JsonCaptchaBlocker.js +27 -19
- package/lib/cjs/products/bot_defender/block/captcha/MobileCaptchaBlocker.js +19 -31
- package/lib/cjs/products/bot_defender/block/index.js +1 -1
- package/lib/cjs/products/bot_defender/block/model/index.js +1 -2
- package/lib/cjs/products/bot_defender/first_party/DefaultBotDefenderFirstParty.js +3 -2
- package/lib/cjs/products/credential_intelligence/CredentialIntelligence.js +5 -5
- package/lib/cjs/products/credential_intelligence/endpoint/CredentialEndpoint.js +17 -3
- package/lib/cjs/products/credential_intelligence/endpoint/extractor/CredentialExtractorFactory.js +2 -2
- package/lib/cjs/products/credential_intelligence/endpoint/extractor/QueryParamCredentialExtractor.js +3 -3
- package/lib/cjs/products/hype_sale_challenge/HypeSaleChallenge.js +81 -0
- package/lib/cjs/products/hype_sale_challenge/block/JsonHypeSaleChallengeBlocker.js +40 -0
- package/lib/cjs/products/hype_sale_challenge/block/MobileHypeSaleChallengeBlocker.js +28 -0
- package/lib/cjs/products/hype_sale_challenge/block/index.js +19 -0
- package/lib/cjs/products/hype_sale_challenge/block/templates/hype_sale_challenge_template.js +4 -0
- package/lib/cjs/{utils/url_parser → products/hype_sale_challenge/block/templates}/index.js +1 -1
- package/lib/cjs/products/hype_sale_challenge/index.js +21 -0
- package/lib/cjs/products/hype_sale_challenge/model/index.js +18 -0
- package/lib/cjs/products/hype_sale_challenge/utils.js +23 -0
- package/lib/cjs/products/index.js +1 -0
- package/lib/cjs/pxde/DefaultDataEnrichment.js +14 -8
- package/lib/cjs/risk_api/client/PostRiskApiClientBase.js +2 -2
- package/lib/cjs/risk_api/risk_response/CommonRiskResponsePayload.js +2 -0
- package/lib/cjs/risk_api/risk_response/RiskResponseBase.js +8 -0
- package/lib/cjs/risk_api/risk_response/index.js +1 -0
- package/lib/cjs/risk_token/token/TokenBase.js +1 -1
- package/lib/cjs/risk_token/token/v2/DefaultTokenV2.js +14 -5
- package/lib/cjs/risk_token/token/v3/DefaultTokenV3.js +42 -16
- package/lib/cjs/utils/Algorithm.js +2 -2
- package/lib/cjs/utils/constants.js +1 -1
- package/lib/cjs/utils/index.js +1 -1
- package/lib/cjs/utils/timestamp_hmac_header_validator/DefaultTimestampHmacHeaderValidator.js +81 -25
- package/lib/cjs/utils/url/IUrl.js +2 -0
- package/lib/cjs/utils/url/IUrlSearchParams.js +2 -0
- package/lib/cjs/utils/url/IUrlUtils.js +2 -0
- package/lib/cjs/utils/url/index.js +19 -0
- package/lib/cjs/utils/utils.js +19 -2
- package/lib/esm/action/utils.js +4 -0
- package/lib/esm/activities/utils.js +12 -8
- package/lib/esm/blocker/BlockerBase.js +24 -0
- package/lib/esm/blocker/JsonBlockerBase.js +17 -0
- package/lib/esm/blocker/MobileBlocker.js +29 -0
- package/lib/esm/blocker/index.js +5 -3
- package/lib/esm/blocker/{BlockAction.js → model/BlockAction.js} +2 -0
- package/lib/esm/blocker/{BlockActionToWordMap.js → model/BlockActionToWordMap.js} +1 -0
- package/lib/esm/blocker/model/index.js +3 -0
- package/lib/esm/{products/bot_defender/block → blocker}/utils.js +7 -4
- package/lib/esm/config/ConfigurationBase.js +3 -0
- package/lib/esm/config/defaults/DefaultCommonConfigurationParams.js +1 -0
- package/lib/esm/config/remote_config/DefaultRemoteConfigUpdater.js +3 -3
- package/lib/esm/context/DefaultContext.js +20 -4
- package/lib/esm/custom_parameters/CustomParameters.js +1 -1
- package/lib/esm/custom_parameters/CustomParametersUtils.js +5 -0
- package/lib/esm/enforcer/EnforcerBase.js +10 -7
- package/lib/esm/http/interfaces/index.js +0 -2
- package/lib/esm/http/utils/constants.js +1 -0
- package/lib/esm/http/utils/index.js +0 -3
- package/lib/esm/impl/cipher/CryptoCipherUtils.js +2 -1
- package/lib/esm/impl/hash/CryptoHashUtils.js +2 -1
- package/lib/esm/impl/hash/SubtleCryptoHashUtils.js +2 -10
- package/lib/esm/impl/hmac/CryptoHmacUtils.js +6 -11
- package/lib/esm/impl/hmac/SubtleCryptoHmacUtils.js +19 -0
- package/lib/esm/impl/http/phin/PhinIncomingResponse.js +4 -2
- package/lib/esm/impl/url/CustomImplUrlUtils.js +64 -0
- package/lib/esm/impl/url/DefaultUrlUtils.js +20 -0
- package/lib/esm/{http/utils → impl/url}/UrlImpl.js +3 -2
- package/lib/esm/{http/utils → impl/url}/UrlSearchParamsImpl.js +8 -9
- package/lib/esm/logger/HttpLogServiceClient.js +5 -6
- package/lib/esm/phase/flow/EnforceFlow.js +4 -1
- package/lib/esm/phase/impl/DecideActionPhase.js +9 -1
- package/lib/esm/phase/impl/EnrichContextFromRequestPhase.js +1 -1
- package/lib/esm/phase/impl/RiskApiPhase.js +4 -5
- package/lib/esm/products/bot_defender/BotDefender.js +2 -1
- package/lib/esm/products/bot_defender/block/captcha/CaptchaBlocker.js +2 -2
- package/lib/esm/products/bot_defender/block/captcha/HtmlCaptchaBlocker.js +9 -15
- package/lib/esm/products/bot_defender/block/captcha/JsonCaptchaBlocker.js +10 -19
- package/lib/esm/products/bot_defender/block/captcha/MobileCaptchaBlocker.js +3 -32
- package/lib/esm/products/bot_defender/block/index.js +1 -1
- package/lib/esm/products/bot_defender/block/model/index.js +1 -2
- package/lib/esm/products/bot_defender/first_party/DefaultBotDefenderFirstParty.js +5 -3
- package/lib/esm/products/credential_intelligence/CredentialIntelligence.js +5 -5
- package/lib/esm/products/credential_intelligence/endpoint/CredentialEndpoint.js +18 -6
- package/lib/esm/products/credential_intelligence/endpoint/extractor/CredentialExtractorFactory.js +2 -2
- package/lib/esm/products/credential_intelligence/endpoint/extractor/QueryParamCredentialExtractor.js +4 -3
- package/lib/esm/products/hype_sale_challenge/HypeSaleChallenge.js +76 -0
- package/lib/esm/products/hype_sale_challenge/block/JsonHypeSaleChallengeBlocker.js +20 -0
- package/lib/esm/products/hype_sale_challenge/block/MobileHypeSaleChallengeBlocker.js +7 -0
- package/lib/esm/products/hype_sale_challenge/block/index.js +3 -0
- package/lib/esm/products/hype_sale_challenge/block/templates/hype_sale_challenge_template.js +42 -0
- package/lib/esm/products/hype_sale_challenge/block/templates/index.js +1 -0
- package/lib/esm/products/hype_sale_challenge/index.js +5 -0
- package/lib/esm/products/hype_sale_challenge/model/index.js +2 -0
- package/lib/esm/products/hype_sale_challenge/utils.js +11 -0
- package/lib/esm/products/index.js +1 -0
- package/lib/esm/pxde/DefaultDataEnrichment.js +2 -1
- package/lib/esm/risk_api/client/PostRiskApiClientBase.js +3 -2
- package/lib/esm/risk_api/risk_response/CommonRiskResponsePayload.js +1 -0
- package/lib/esm/risk_api/risk_response/RiskResponseBase.js +3 -0
- package/lib/esm/risk_api/risk_response/index.js +1 -0
- package/lib/esm/risk_token/token/TokenBase.js +2 -2
- package/lib/esm/risk_token/token/v2/DefaultTokenV2.js +10 -5
- package/lib/esm/risk_token/token/v3/DefaultTokenV3.js +22 -5
- package/lib/esm/utils/Algorithm.js +2 -2
- package/lib/esm/utils/constants.js +1 -1
- package/lib/esm/utils/index.js +1 -1
- package/lib/esm/utils/timestamp_hmac_header_validator/DefaultTimestampHmacHeaderValidator.js +4 -4
- package/lib/esm/utils/url/IUrl.js +1 -0
- package/lib/esm/utils/url/IUrlSearchParams.js +1 -0
- package/lib/esm/utils/url/IUrlUtils.js +1 -0
- package/lib/esm/utils/url/index.js +3 -0
- package/lib/esm/utils/utils.js +16 -1
- package/lib/types/action/utils.d.ts +2 -0
- package/lib/types/activities/model/CommonActivityDetails.d.ts +3 -0
- package/lib/types/activities/utils.d.ts +493 -172
- package/lib/types/blocker/BlockerBase.d.ts +11 -0
- package/lib/types/blocker/JsonBlockerBase.d.ts +9 -0
- package/lib/types/blocker/MobileBlocker.d.ts +13 -0
- package/lib/types/blocker/index.d.ts +5 -3
- package/lib/types/blocker/model/BlockAction.d.ts +7 -0
- package/lib/types/{products/bot_defender/block → blocker}/model/BlockData.d.ts +2 -1
- package/lib/types/blocker/model/index.d.ts +3 -0
- package/lib/types/blocker/utils.d.ts +641 -0
- package/lib/types/config/ConfigurationBase.d.ts +6 -5
- package/lib/types/config/IConfiguration.d.ts +10 -6
- package/lib/types/config/params/CommonConfigurationParams.d.ts +6 -5
- package/lib/types/config/remote_config/DefaultRemoteConfigUpdater.d.ts +1 -1
- package/lib/types/context/DefaultContext.d.ts +6 -5
- package/lib/types/context/interfaces/IContext.d.ts +4 -0
- package/lib/types/context/interfaces/RequestData.d.ts +7 -2
- package/lib/types/context/interfaces/RiskApiData.d.ts +4 -0
- package/lib/types/custom_parameters/CustomParameters.d.ts +2 -0
- package/lib/types/enforcer/EnforcerBase.d.ts +2 -2
- package/lib/types/enforcer/options/EnforcerBaseOptions.d.ts +2 -1
- package/lib/types/http/interfaces/IBody.d.ts +2 -2
- package/lib/types/http/interfaces/index.d.ts +0 -2
- package/lib/types/http/utils/constants.d.ts +1 -0
- package/lib/types/http/utils/index.d.ts +0 -3
- package/lib/types/impl/hash/SubtleCryptoHashUtils.d.ts +0 -1
- package/lib/types/impl/hmac/SubtleCryptoHmacUtils.d.ts +7 -0
- package/lib/types/impl/http/phin/PhinIncomingResponse.d.ts +3 -2
- package/lib/types/impl/url/CustomImplUrlUtils.d.ts +10 -0
- package/lib/types/impl/url/DefaultUrlUtils.d.ts +9 -0
- package/lib/types/{http/utils → impl/url}/UrlImpl.d.ts +3 -3
- package/lib/types/{http/utils → impl/url}/UrlSearchParamsImpl.d.ts +5 -4
- package/lib/types/phase/impl/DecideActionPhase.d.ts +1 -0
- package/lib/types/phase/impl/RiskApiPhase.d.ts +1 -1
- package/lib/types/products/bot_defender/BotDefender.d.ts +7 -2
- package/lib/types/products/bot_defender/block/captcha/HtmlCaptchaBlocker.d.ts +6 -5
- package/lib/types/products/bot_defender/block/captcha/JsonCaptchaBlocker.d.ts +7 -5
- package/lib/types/products/bot_defender/block/captcha/MobileCaptchaBlocker.d.ts +2 -8
- package/lib/types/products/bot_defender/block/index.d.ts +1 -1
- package/lib/types/products/bot_defender/block/model/{JsonBlockPayload.d.ts → JsonCaptchaBlockPayload.d.ts} +1 -1
- package/lib/types/products/bot_defender/block/model/index.d.ts +1 -2
- package/lib/types/products/bot_defender/first_party/DefaultBotDefenderFirstParty.d.ts +7 -2
- package/lib/types/products/credential_intelligence/CredentialIntelligence.d.ts +7 -3
- package/lib/types/products/credential_intelligence/endpoint/extractor/BodyCredentialExtractor.d.ts +3 -2
- package/lib/types/products/credential_intelligence/endpoint/extractor/CredentialExtractorFactory.d.ts +2 -1
- package/lib/types/products/credential_intelligence/endpoint/extractor/QueryParamCredentialExtractor.d.ts +5 -3
- package/lib/types/products/hype_sale_challenge/HypeSaleChallenge.d.ts +28 -0
- package/lib/types/products/hype_sale_challenge/IHypeSaleChallenge.d.ts +5 -0
- package/lib/types/products/hype_sale_challenge/block/JsonHypeSaleChallengeBlocker.d.ts +11 -0
- package/lib/types/products/hype_sale_challenge/block/MobileHypeSaleChallengeBlocker.d.ts +6 -0
- package/lib/types/products/hype_sale_challenge/block/index.d.ts +3 -0
- package/lib/types/products/hype_sale_challenge/block/templates/hype_sale_challenge_template.d.ts +1 -0
- package/lib/types/products/hype_sale_challenge/block/templates/index.d.ts +1 -0
- package/lib/types/products/hype_sale_challenge/index.d.ts +5 -0
- package/lib/types/products/hype_sale_challenge/model/HypeSaleChallengeData.d.ts +5 -0
- package/lib/types/products/hype_sale_challenge/model/JsonHypeSaleChallengeBlockPayload.d.ts +5 -0
- package/lib/types/products/hype_sale_challenge/model/index.d.ts +2 -0
- package/lib/types/products/hype_sale_challenge/utils.d.ts +5 -0
- package/lib/types/products/index.d.ts +1 -0
- package/lib/types/products/interfaces/ProductDataType.d.ts +2 -1
- package/lib/types/risk_api/model/RiskActivity.d.ts +1 -0
- package/lib/types/risk_api/risk_response/CommonRiskResponsePayload.d.ts +14 -0
- package/lib/types/risk_api/risk_response/IRiskResponse.d.ts +1 -0
- package/lib/types/risk_api/risk_response/RiskResponseBase.d.ts +1 -0
- package/lib/types/risk_api/risk_response/index.d.ts +1 -0
- package/lib/types/risk_api/risk_response/v2/RiskResponseV2Payload.d.ts +2 -12
- package/lib/types/risk_api/risk_response/v3/RiskResponseV3Payload.d.ts +2 -12
- package/lib/types/risk_token/token/IToken.d.ts +4 -0
- package/lib/types/risk_token/token/TokenBase.d.ts +2 -2
- package/lib/types/risk_token/token/v2/DefaultTokenV2.d.ts +1 -0
- package/lib/types/risk_token/token/v3/DefaultTokenV3.d.ts +1 -0
- package/lib/types/risk_token/token/v3/TokenV3Payload.d.ts +1 -0
- package/lib/types/utils/Algorithm.d.ts +2 -2
- package/lib/types/utils/constants.d.ts +1 -1
- package/lib/types/utils/hmac/IHmacUtils.d.ts +2 -1
- package/lib/types/utils/index.d.ts +1 -1
- package/lib/types/utils/timestamp_hmac_header_validator/DefaultTimestampHmacHeaderValidator.d.ts +2 -2
- package/lib/types/utils/timestamp_hmac_header_validator/ITimestampHmacHeaderValidator.d.ts +2 -1
- package/lib/types/utils/url/IUrl.d.ts +9 -0
- package/lib/types/{http/interfaces/IURLSearchParams.d.ts → utils/url/IUrlSearchParams.d.ts} +2 -2
- package/lib/types/utils/url/IUrlUtils.d.ts +10 -0
- package/lib/types/utils/url/index.d.ts +3 -0
- package/lib/types/utils/utils.d.ts +3 -0
- package/package.json +9 -6
- package/lib/cjs/blocker/BlockActionToProductMap.js +0 -10
- package/lib/cjs/http/utils/URLUtils.js +0 -65
- package/lib/cjs/impl/url_parser/DefaultUrlParser.js +0 -39
- package/lib/esm/blocker/BlockActionToProductMap.js +0 -7
- package/lib/esm/http/utils/URLUtils.js +0 -62
- package/lib/esm/impl/url_parser/DefaultUrlParser.js +0 -28
- package/lib/esm/utils/url_parser/index.js +0 -1
- package/lib/types/blocker/BlockAction.d.ts +0 -5
- package/lib/types/blocker/BlockActionToProductMap.d.ts +0 -3
- package/lib/types/http/interfaces/IURL.d.ts +0 -9
- package/lib/types/http/utils/URLUtils.d.ts +0 -7
- package/lib/types/impl/url_parser/DefaultUrlParser.d.ts +0 -13
- package/lib/types/products/bot_defender/block/utils.d.ts +0 -5
- package/lib/types/utils/url_parser/IURLParser.d.ts +0 -4
- package/lib/types/utils/url_parser/index.d.ts +0 -1
- /package/lib/cjs/{products/bot_defender/block → blocker}/model/BlockData.js +0 -0
- /package/lib/cjs/{http/interfaces/IURL.js → products/bot_defender/block/model/JsonCaptchaBlockPayload.js} +0 -0
- /package/lib/cjs/{http/interfaces/IURLSearchParams.js → products/hype_sale_challenge/IHypeSaleChallenge.js} +0 -0
- /package/lib/cjs/products/{bot_defender/block/model/JsonBlockPayload.js → hype_sale_challenge/model/HypeSaleChallengeData.js} +0 -0
- /package/lib/cjs/{utils/url_parser/IURLParser.js → products/hype_sale_challenge/model/JsonHypeSaleChallengeBlockPayload.js} +0 -0
- /package/lib/esm/{products/bot_defender/block → blocker}/model/BlockData.js +0 -0
- /package/lib/esm/{http/interfaces/IURL.js → products/bot_defender/block/model/JsonCaptchaBlockPayload.js} +0 -0
- /package/lib/esm/{http/interfaces/IURLSearchParams.js → products/hype_sale_challenge/IHypeSaleChallenge.js} +0 -0
- /package/lib/esm/products/{bot_defender/block/model/JsonBlockPayload.js → hype_sale_challenge/model/HypeSaleChallengeData.js} +0 -0
- /package/lib/esm/{utils/url_parser/IURLParser.js → products/hype_sale_challenge/model/JsonHypeSaleChallengeBlockPayload.js} +0 -0
- /package/lib/types/blocker/{BlockActionToWordMap.d.ts → model/BlockActionToWordMap.d.ts} +0 -0
|
@@ -1,27 +1,4 @@
|
|
|
1
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -60,7 +37,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
60
37
|
};
|
|
61
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
39
|
exports.SubtleCryptoHashUtils = void 0;
|
|
63
|
-
var crypto = __importStar(require("crypto"));
|
|
64
40
|
var utils_1 = require("../../utils");
|
|
65
41
|
var SubtleCryptoHashUtils = /** @class */ (function () {
|
|
66
42
|
function SubtleCryptoHashUtils(subtleCrypto) {
|
|
@@ -74,7 +50,7 @@ var SubtleCryptoHashUtils = /** @class */ (function () {
|
|
|
74
50
|
switch (_a.label) {
|
|
75
51
|
case 0:
|
|
76
52
|
textUint8 = new TextEncoder().encode(text);
|
|
77
|
-
return [4 /*yield*/, this.subtle.digest(
|
|
53
|
+
return [4 /*yield*/, this.subtle.digest((0, utils_1.algoToSubtleCryptoString)(algo), textUint8)];
|
|
78
54
|
case 1:
|
|
79
55
|
hashBuffer = _a.sent();
|
|
80
56
|
hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
@@ -83,13 +59,6 @@ var SubtleCryptoHashUtils = /** @class */ (function () {
|
|
|
83
59
|
});
|
|
84
60
|
});
|
|
85
61
|
};
|
|
86
|
-
SubtleCryptoHashUtils.prototype.convertAlgo = function (algo) {
|
|
87
|
-
switch (algo) {
|
|
88
|
-
case utils_1.Algorithm.SHA256:
|
|
89
|
-
default:
|
|
90
|
-
return 'SHA-256';
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
62
|
return SubtleCryptoHashUtils;
|
|
94
63
|
}());
|
|
95
64
|
exports.SubtleCryptoHashUtils = SubtleCryptoHashUtils;
|
|
@@ -32,16 +32,11 @@ var CryptoHmacUtils = /** @class */ (function () {
|
|
|
32
32
|
this.crypto = cryptoModule;
|
|
33
33
|
}
|
|
34
34
|
CryptoHmacUtils.prototype.createHmac = function (algo, payload, secret) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
hmac.end();
|
|
41
|
-
return hmac.read();
|
|
42
|
-
default:
|
|
43
|
-
return '';
|
|
44
|
-
}
|
|
35
|
+
var hmac = this.crypto.createHmac((0, utils_1.algoToCryptoString)(algo), secret);
|
|
36
|
+
hmac.setEncoding('hex');
|
|
37
|
+
hmac.write(payload);
|
|
38
|
+
hmac.end();
|
|
39
|
+
return hmac.read();
|
|
45
40
|
};
|
|
46
41
|
return CryptoHmacUtils;
|
|
47
42
|
}());
|
|
@@ -0,0 +1,72 @@
|
|
|
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 (g && (g = 0, op[0] && (_ = 0)), _) 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.SubtleCryptoHmacUtils = void 0;
|
|
40
|
+
var utils_1 = require("../../utils");
|
|
41
|
+
var SubtleCryptoHmacUtils = /** @class */ (function () {
|
|
42
|
+
function SubtleCryptoHmacUtils(subtleCrypto) {
|
|
43
|
+
if (subtleCrypto === void 0) { subtleCrypto = crypto.subtle; }
|
|
44
|
+
this.subtle = subtleCrypto;
|
|
45
|
+
}
|
|
46
|
+
SubtleCryptoHmacUtils.prototype.createHmac = function (algo, payload, secret) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
48
|
+
var encodedStr, encodedPassword, importedKey, signature;
|
|
49
|
+
return __generator(this, function (_a) {
|
|
50
|
+
switch (_a.label) {
|
|
51
|
+
case 0:
|
|
52
|
+
encodedStr = new TextEncoder().encode(payload);
|
|
53
|
+
encodedPassword = new TextEncoder().encode(secret);
|
|
54
|
+
return [4 /*yield*/, this.subtle.importKey('raw', encodedPassword, { name: 'HMAC', hash: { name: (0, utils_1.algoToSubtleCryptoString)(algo) } }, false, ['sign'])];
|
|
55
|
+
case 1:
|
|
56
|
+
importedKey = _a.sent();
|
|
57
|
+
return [4 /*yield*/, this.subtle.sign({ name: 'HMAC' }, importedKey, encodedStr)];
|
|
58
|
+
case 2:
|
|
59
|
+
signature = _a.sent();
|
|
60
|
+
return [2 /*return*/, this.bufferToHex(signature)];
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
SubtleCryptoHmacUtils.prototype.bufferToHex = function (buffer) {
|
|
66
|
+
return Array.prototype.map
|
|
67
|
+
.call(new Uint8Array(buffer), function (x) { return ('00' + x.toString(16)).slice(-2); })
|
|
68
|
+
.join('');
|
|
69
|
+
};
|
|
70
|
+
return SubtleCryptoHmacUtils;
|
|
71
|
+
}());
|
|
72
|
+
exports.SubtleCryptoHmacUtils = SubtleCryptoHmacUtils;
|
|
@@ -38,6 +38,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.PhinIncomingResponse = void 0;
|
|
40
40
|
var http_1 = require("../../../http");
|
|
41
|
+
var DefaultUrlUtils_1 = require("../../url/DefaultUrlUtils");
|
|
41
42
|
var PhinIncomingResponse = /** @class */ (function () {
|
|
42
43
|
function PhinIncomingResponse(response) {
|
|
43
44
|
this.status = response.statusCode;
|
|
@@ -67,9 +68,11 @@ var PhinIncomingResponse = /** @class */ (function () {
|
|
|
67
68
|
return __generator(this, function (_c) {
|
|
68
69
|
switch (_c.label) {
|
|
69
70
|
case 0:
|
|
70
|
-
_b = (_a =
|
|
71
|
+
_b = (_a = new DefaultUrlUtils_1.DefaultUrlUtils()).createUrlSearchParams;
|
|
71
72
|
return [4 /*yield*/, this.text()];
|
|
72
|
-
case 1:
|
|
73
|
+
case 1:
|
|
74
|
+
// Using DefaultUrlUtils since Phin safely assumes Node.js environment
|
|
75
|
+
return [2 /*return*/, _b.apply(_a, [_c.sent()])];
|
|
73
76
|
}
|
|
74
77
|
});
|
|
75
78
|
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CustomImplUrlUtils = void 0;
|
|
4
|
+
var utils_1 = require("../../utils");
|
|
5
|
+
var UrlImpl_1 = require("./UrlImpl");
|
|
6
|
+
var UrlSearchParamsImpl_1 = require("./UrlSearchParamsImpl");
|
|
7
|
+
var CustomImplUrlUtils = /** @class */ (function () {
|
|
8
|
+
function CustomImplUrlUtils() {
|
|
9
|
+
}
|
|
10
|
+
CustomImplUrlUtils.prototype.createUrl = function (rawUrl) {
|
|
11
|
+
return new UrlImpl_1.UrlImpl(rawUrl);
|
|
12
|
+
};
|
|
13
|
+
CustomImplUrlUtils.prototype.createUrlSearchParams = function (params) {
|
|
14
|
+
return new UrlSearchParamsImpl_1.UrlSearchParamsImpl(this, params);
|
|
15
|
+
};
|
|
16
|
+
CustomImplUrlUtils.prototype.decodeUriComponent = function (uriComponent) {
|
|
17
|
+
// https://www.npmjs.com/package/as-uri-encode-decode
|
|
18
|
+
// Note: Does not work well with multibyte characters
|
|
19
|
+
var result = '';
|
|
20
|
+
for (var i = 0; i < uriComponent.length; i++) {
|
|
21
|
+
if (uriComponent.charAt(i) === '+') {
|
|
22
|
+
result += ' ';
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (uriComponent.charAt(i) === '%' &&
|
|
26
|
+
uriComponent.charAt(i + 1) !== '%' &&
|
|
27
|
+
uriComponent.charAt(i + 2) !== '%') {
|
|
28
|
+
var charCode = parseInt(uriComponent.charAt(i + 1) + uriComponent.charAt(i + 2), 16);
|
|
29
|
+
var char = String.fromCharCode(charCode);
|
|
30
|
+
result += char;
|
|
31
|
+
i += 2;
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
result += uriComponent.charAt(i);
|
|
35
|
+
}
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
CustomImplUrlUtils.prototype.encodeUriComponent = function (uriComponent) {
|
|
39
|
+
// https://www.npmjs.com/package/as-uri-encode-decode
|
|
40
|
+
// Note: Does not work well with multibyte characters
|
|
41
|
+
var result = '';
|
|
42
|
+
for (var i = 0; i < uriComponent.length; i++) {
|
|
43
|
+
var c = uriComponent.charAt(i);
|
|
44
|
+
if (this.isSafe(c)) {
|
|
45
|
+
result += c;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
result += '%' + c.charCodeAt(0).toString(16).toUpperCase();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
52
|
+
};
|
|
53
|
+
CustomImplUrlUtils.prototype.encodeUri = function (uri) {
|
|
54
|
+
throw new utils_1.EnforcerError('method not implemented: CustomImplUrlUtils.encodeUri()');
|
|
55
|
+
};
|
|
56
|
+
CustomImplUrlUtils.prototype.decodeUri = function (uri) {
|
|
57
|
+
throw new utils_1.EnforcerError('method not implemented: CustomImplUrlUtils.decodeUri()');
|
|
58
|
+
};
|
|
59
|
+
CustomImplUrlUtils.prototype.isSafe = function (c) {
|
|
60
|
+
return ((c >= 'a' && c <= 'z') ||
|
|
61
|
+
(c >= 'A' && c <= 'Z') ||
|
|
62
|
+
(c >= '0' && c <= '9') ||
|
|
63
|
+
c == '-' ||
|
|
64
|
+
c == '_' ||
|
|
65
|
+
c == '.' ||
|
|
66
|
+
c == '*' ||
|
|
67
|
+
c == '!');
|
|
68
|
+
};
|
|
69
|
+
return CustomImplUrlUtils;
|
|
70
|
+
}());
|
|
71
|
+
exports.CustomImplUrlUtils = CustomImplUrlUtils;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefaultUrlUtils = void 0;
|
|
4
|
+
var DefaultUrlUtils = /** @class */ (function () {
|
|
5
|
+
function DefaultUrlUtils() {
|
|
6
|
+
}
|
|
7
|
+
DefaultUrlUtils.prototype.createUrl = function (rawUrl) {
|
|
8
|
+
return new URL(rawUrl);
|
|
9
|
+
};
|
|
10
|
+
DefaultUrlUtils.prototype.createUrlSearchParams = function (params) {
|
|
11
|
+
return new URLSearchParams(params);
|
|
12
|
+
};
|
|
13
|
+
DefaultUrlUtils.prototype.decodeUriComponent = function (uriComponent) {
|
|
14
|
+
return decodeURIComponent(uriComponent);
|
|
15
|
+
};
|
|
16
|
+
DefaultUrlUtils.prototype.encodeUriComponent = function (uriComponent) {
|
|
17
|
+
return encodeURIComponent(uriComponent);
|
|
18
|
+
};
|
|
19
|
+
DefaultUrlUtils.prototype.decodeUri = function (uri) {
|
|
20
|
+
return decodeURI(uri);
|
|
21
|
+
};
|
|
22
|
+
DefaultUrlUtils.prototype.encodeUri = function (uri) {
|
|
23
|
+
return encodeURI(uri);
|
|
24
|
+
};
|
|
25
|
+
return DefaultUrlUtils;
|
|
26
|
+
}());
|
|
27
|
+
exports.DefaultUrlUtils = DefaultUrlUtils;
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UrlImpl = void 0;
|
|
4
4
|
var utils_1 = require("../../utils");
|
|
5
|
-
var
|
|
5
|
+
var UrlSearchParamsImpl_1 = require("./UrlSearchParamsImpl");
|
|
6
|
+
var CustomImplUrlUtils_1 = require("./CustomImplUrlUtils");
|
|
6
7
|
var UrlImpl = /** @class */ (function () {
|
|
7
8
|
function UrlImpl(rawUrl) {
|
|
8
9
|
var match = rawUrl.match(utils_1.URL_REGEX);
|
|
@@ -56,7 +57,7 @@ var UrlImpl = /** @class */ (function () {
|
|
|
56
57
|
});
|
|
57
58
|
Object.defineProperty(UrlImpl.prototype, "searchParams", {
|
|
58
59
|
get: function () {
|
|
59
|
-
return
|
|
60
|
+
return new UrlSearchParamsImpl_1.UrlSearchParamsImpl(new CustomImplUrlUtils_1.CustomImplUrlUtils(), this.search);
|
|
60
61
|
},
|
|
61
62
|
enumerable: false,
|
|
62
63
|
configurable: true
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UrlSearchParamsImpl = void 0;
|
|
4
|
-
// This file is based on the implementation found here:
|
|
5
|
-
// https://github.com/pinglu85/BFEdevSolutions/blob/main/Coding-Problems/80.implement-your-own-URLSearchParams.md
|
|
6
|
-
var URLUtils_1 = require("./URLUtils");
|
|
7
4
|
var UrlSearchParamsImpl = /** @class */ (function () {
|
|
8
|
-
function UrlSearchParamsImpl(init) {
|
|
5
|
+
function UrlSearchParamsImpl(urlUtils, init) {
|
|
6
|
+
this.urlUtils = urlUtils;
|
|
9
7
|
this._searchParamsArray = [];
|
|
10
8
|
this._searchParamsMap = new Map();
|
|
11
9
|
if (init) {
|
|
@@ -57,18 +55,19 @@ var UrlSearchParamsImpl = /** @class */ (function () {
|
|
|
57
55
|
this.append(name, value);
|
|
58
56
|
return;
|
|
59
57
|
}
|
|
60
|
-
name =
|
|
61
|
-
value =
|
|
58
|
+
name = this.urlUtils.decodeUriComponent(name);
|
|
59
|
+
value = this.urlUtils.decodeUriComponent(value);
|
|
62
60
|
this._searchParamsMap.set(name, [value]);
|
|
63
61
|
var searchParamIdx = this._searchParamsArray.findIndex(function (param) { return param[0] === name; });
|
|
64
62
|
this._searchParamsArray[searchParamIdx][1] = value;
|
|
65
63
|
this._searchParamsArray = this._searchParamsArray.filter(function (param, idx) { return param[0] !== name || idx === searchParamIdx; });
|
|
66
64
|
};
|
|
67
65
|
UrlSearchParamsImpl.prototype.toString = function () {
|
|
66
|
+
var _this = this;
|
|
68
67
|
return this._searchParamsArray
|
|
69
68
|
.map(function (_a) {
|
|
70
69
|
var key = _a[0], value = _a[1];
|
|
71
|
-
return "".concat(
|
|
70
|
+
return "".concat(_this.urlUtils.encodeUriComponent(key), "=").concat(_this.urlUtils.encodeUriComponent(value));
|
|
72
71
|
})
|
|
73
72
|
.join('&');
|
|
74
73
|
};
|
|
@@ -108,8 +107,8 @@ var UrlSearchParamsImpl = /** @class */ (function () {
|
|
|
108
107
|
}
|
|
109
108
|
};
|
|
110
109
|
UrlSearchParamsImpl.prototype._saveParam = function (key, value) {
|
|
111
|
-
key =
|
|
112
|
-
value =
|
|
110
|
+
key = this.urlUtils.decodeUriComponent(key);
|
|
111
|
+
value = this.urlUtils.decodeUriComponent(value);
|
|
113
112
|
this._searchParamsArray.push([key, value]);
|
|
114
113
|
this._storeParamInSearchParamsMap(key, value);
|
|
115
114
|
};
|
|
@@ -84,15 +84,14 @@ var HttpLogServiceClient = /** @class */ (function () {
|
|
|
84
84
|
});
|
|
85
85
|
};
|
|
86
86
|
HttpLogServiceClient.prototype.enrichLogRecord = function (context, log) {
|
|
87
|
-
var
|
|
88
|
-
var url = http_1.URLUtils.parseURL(requestData.rawUrl);
|
|
87
|
+
var _a = context.requestData, method = _a.method, url = _a.url, rawUrl = _a.rawUrl;
|
|
89
88
|
var logMeta = {
|
|
90
89
|
container: 'enforcer',
|
|
91
90
|
appID: this.appId,
|
|
92
|
-
method:
|
|
91
|
+
method: method,
|
|
93
92
|
host: url.host,
|
|
94
|
-
url:
|
|
95
|
-
path: url.pathname +
|
|
93
|
+
url: rawUrl,
|
|
94
|
+
path: url.pathname + url.search,
|
|
96
95
|
requestId: context.requestId,
|
|
97
96
|
};
|
|
98
97
|
if (this.remoteConfigId && this.remoteConfigVersion) {
|
|
@@ -29,7 +29,10 @@ var EnforceFlow = /** @class */ (function (_super) {
|
|
|
29
29
|
new impl_1.RiskApiPhase(config, products, riskApiClient),
|
|
30
30
|
new impl_1.AdditionalActivityHandlerPhase(config),
|
|
31
31
|
new impl_1.SendAsyncActivitiesOnRequestPhase(activityClient),
|
|
32
|
-
new impl_1.CreateBlockResponsePhase(config, (_b = {},
|
|
32
|
+
new impl_1.CreateBlockResponsePhase(config, (_b = {},
|
|
33
|
+
_b[products_1.ProductName.BOT_DEFENDER] = products[products_1.ProductName.BOT_DEFENDER],
|
|
34
|
+
_b[products_1.ProductName.HYPE_SALE_CHALLENGE] = products[products_1.ProductName.HYPE_SALE_CHALLENGE],
|
|
35
|
+
_b), cors),
|
|
33
36
|
new impl_1.ModifyIncomingRequestPhase(Object.values(products)),
|
|
34
37
|
]) || this;
|
|
35
38
|
}
|
|
@@ -39,6 +39,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
exports.DecideActionPhase = void 0;
|
|
40
40
|
var logger_1 = require("../../logger");
|
|
41
41
|
var action_1 = require("../../action");
|
|
42
|
+
var blocker_1 = require("../../blocker");
|
|
42
43
|
var DecideActionPhase = /** @class */ (function () {
|
|
43
44
|
function DecideActionPhase(config) {
|
|
44
45
|
this.config = config;
|
|
@@ -59,10 +60,17 @@ var DecideActionPhase = /** @class */ (function () {
|
|
|
59
60
|
}
|
|
60
61
|
context.action = action;
|
|
61
62
|
context.reasons = reasons;
|
|
63
|
+
this.modifyBlockActionIfNeeded(context);
|
|
62
64
|
return [2 /*return*/];
|
|
63
65
|
});
|
|
64
66
|
});
|
|
65
67
|
};
|
|
68
|
+
DecideActionPhase.prototype.modifyBlockActionIfNeeded = function (context) {
|
|
69
|
+
var isHypeSaleChallengeBlock = context.reasons.hsc && (context.action === action_1.Action.BLOCK || context.action === action_1.Action.SIMULATED_BLOCK);
|
|
70
|
+
if (isHypeSaleChallengeBlock) {
|
|
71
|
+
context.blockAction = blocker_1.BlockAction.HYPE_SALE_CHALLENGE;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
66
74
|
return DecideActionPhase;
|
|
67
75
|
}());
|
|
68
76
|
exports.DecideActionPhase = DecideActionPhase;
|
|
@@ -75,10 +75,10 @@ var EnrichContextFromRequestPhase = /** @class */ (function (_super) {
|
|
|
75
75
|
return [4 /*yield*/, this.addGraphQLDataToContext(context)];
|
|
76
76
|
case 2:
|
|
77
77
|
_a.sent();
|
|
78
|
-
return [4 /*yield*/, this.
|
|
78
|
+
return [4 /*yield*/, this.addCustomParametersToContext(context)];
|
|
79
79
|
case 3:
|
|
80
80
|
_a.sent();
|
|
81
|
-
return [4 /*yield*/, this.
|
|
81
|
+
return [4 /*yield*/, this.addProductDataToContext(context)];
|
|
82
82
|
case 4:
|
|
83
83
|
_a.sent();
|
|
84
84
|
return [4 /*yield*/, this.updateContextDecision(context)];
|
|
@@ -54,9 +54,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
54
54
|
exports.RiskApiPhase = void 0;
|
|
55
55
|
var action_1 = require("../../action");
|
|
56
56
|
var utils_1 = require("../../utils");
|
|
57
|
-
var DecideActionPhase_1 = require("./DecideActionPhase");
|
|
58
|
-
var products_1 = require("../../products");
|
|
59
57
|
var pxhd_1 = require("../../pxhd");
|
|
58
|
+
var DecideActionPhase_1 = require("./DecideActionPhase");
|
|
60
59
|
var RiskApiPhase = /** @class */ (function (_super) {
|
|
61
60
|
__extends(RiskApiPhase, _super);
|
|
62
61
|
function RiskApiPhase(config, products, riskApiClient) {
|
|
@@ -90,17 +89,16 @@ var RiskApiPhase = /** @class */ (function (_super) {
|
|
|
90
89
|
return context.action === action_1.Action.TRIGGER_RISK_API;
|
|
91
90
|
};
|
|
92
91
|
RiskApiPhase.prototype.triggerRiskApi = function (context) {
|
|
93
|
-
var _a, _b;
|
|
94
92
|
return __awaiter(this, void 0, void 0, function () {
|
|
95
93
|
var riskApiData;
|
|
96
|
-
return __generator(this, function (
|
|
97
|
-
switch (
|
|
94
|
+
return __generator(this, function (_a) {
|
|
95
|
+
switch (_a.label) {
|
|
98
96
|
case 0:
|
|
99
|
-
context.riskApiData.s2sCallReason =
|
|
100
|
-
|
|
97
|
+
context.riskApiData.s2sCallReason = (0, action_1.getReasonForHighestPriorityProduct)(context.reasons);
|
|
98
|
+
context.riskApiData.riskStartTime = Date.now();
|
|
101
99
|
return [4 /*yield*/, this.riskApiClient.executeRiskApi(context)];
|
|
102
100
|
case 1:
|
|
103
|
-
riskApiData =
|
|
101
|
+
riskApiData = _a.sent();
|
|
104
102
|
Object.assign(context.riskApiData, riskApiData);
|
|
105
103
|
return [2 /*return*/];
|
|
106
104
|
}
|
|
@@ -62,7 +62,8 @@ var BotDefender = /** @class */ (function () {
|
|
|
62
62
|
function BotDefender(config, options) {
|
|
63
63
|
var _a, _b, _c;
|
|
64
64
|
this.config = config;
|
|
65
|
-
this.firstParty =
|
|
65
|
+
this.firstParty =
|
|
66
|
+
(_a = options.firstParty) !== null && _a !== void 0 ? _a : new first_party_1.DefaultBotDefenderFirstParty(config, { urlUtils: options.urlUtils });
|
|
66
67
|
this.filter = (_b = options.filter) !== null && _b !== void 0 ? _b : new filter_1.DefaultBotDefenderFilter(config, options.ipRangeChecker);
|
|
67
68
|
this.blocker = (_c = options.blocker) !== null && _c !== void 0 ? _c : new block_1.DefaultBotDefenderBlocker(config, options.base64Utils);
|
|
68
69
|
}
|
|
@@ -7,9 +7,9 @@ var HtmlCaptchaBlocker_1 = require("./HtmlCaptchaBlocker");
|
|
|
7
7
|
var CaptchaBlocker = /** @class */ (function () {
|
|
8
8
|
function CaptchaBlocker(config, base64Utils) {
|
|
9
9
|
this.config = config;
|
|
10
|
-
this.jsonCaptchaBlocker = new JsonCaptchaBlocker_1.JsonCaptchaBlocker(config);
|
|
10
|
+
this.jsonCaptchaBlocker = new JsonCaptchaBlocker_1.JsonCaptchaBlocker(config, base64Utils);
|
|
11
11
|
this.mobileCaptchaBlocker = new MobileCaptchaBlocker_1.MobileCaptchaBlocker(config, base64Utils);
|
|
12
|
-
this.htmlCaptchaBlocker = new HtmlCaptchaBlocker_1.HtmlCaptchaBlocker(config);
|
|
12
|
+
this.htmlCaptchaBlocker = new HtmlCaptchaBlocker_1.HtmlCaptchaBlocker(config, base64Utils);
|
|
13
13
|
}
|
|
14
14
|
CaptchaBlocker.prototype.createBlockResponse = function (context) {
|
|
15
15
|
if (this.mobileCaptchaBlocker.shouldBlock(context)) {
|
|
@@ -1,26 +1,35 @@
|
|
|
1
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
|
+
})();
|
|
2
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
18
|
exports.HtmlCaptchaBlocker = void 0;
|
|
4
19
|
var http_1 = require("../../../../http");
|
|
5
|
-
var
|
|
20
|
+
var blocker_1 = require("../../../../blocker");
|
|
6
21
|
var templates_1 = require("../templates");
|
|
7
|
-
var HtmlCaptchaBlocker = /** @class */ (function () {
|
|
8
|
-
|
|
9
|
-
|
|
22
|
+
var HtmlCaptchaBlocker = /** @class */ (function (_super) {
|
|
23
|
+
__extends(HtmlCaptchaBlocker, _super);
|
|
24
|
+
function HtmlCaptchaBlocker(config, base64Utils) {
|
|
25
|
+
var _this = _super.call(this, http_1.ContentType.TEXT_HTML) || this;
|
|
26
|
+
_this.config = config;
|
|
27
|
+
_this.base64Utils = base64Utils;
|
|
28
|
+
return _this;
|
|
10
29
|
}
|
|
11
|
-
HtmlCaptchaBlocker.prototype.
|
|
12
|
-
|
|
13
|
-
var status = 403;
|
|
14
|
-
var headers = (_a = {},
|
|
15
|
-
_a[http_1.CONTENT_TYPE_HEADER_NAME] = [http_1.ContentType.TEXT_HTML],
|
|
16
|
-
_a);
|
|
17
|
-
var body = (0, utils_1.renderHtml)(templates_1.CAPTCHA_TEMPLATE, (0, utils_1.createBlockData)(this.config, context));
|
|
18
|
-
return new http_1.MinimalResponseImpl({
|
|
19
|
-
body: body,
|
|
20
|
-
status: status,
|
|
21
|
-
headers: headers,
|
|
22
|
-
});
|
|
30
|
+
HtmlCaptchaBlocker.prototype.createBlockBody = function (context) {
|
|
31
|
+
return (0, blocker_1.renderHtml)(templates_1.CAPTCHA_TEMPLATE, (0, blocker_1.createBlockData)(this.config, context, this.base64Utils));
|
|
23
32
|
};
|
|
24
33
|
return HtmlCaptchaBlocker;
|
|
25
|
-
}());
|
|
34
|
+
}(blocker_1.BlockerBase));
|
|
26
35
|
exports.HtmlCaptchaBlocker = HtmlCaptchaBlocker;
|
|
@@ -1,29 +1,39 @@
|
|
|
1
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
|
+
})();
|
|
2
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
18
|
exports.JsonCaptchaBlocker = void 0;
|
|
4
19
|
var blocker_1 = require("../../../../blocker");
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
20
|
+
var JsonCaptchaBlocker = /** @class */ (function (_super) {
|
|
21
|
+
__extends(JsonCaptchaBlocker, _super);
|
|
22
|
+
function JsonCaptchaBlocker(config, base64Utils) {
|
|
23
|
+
var _this = _super.call(this) || this;
|
|
24
|
+
_this.config = config;
|
|
25
|
+
_this.base64Utils = base64Utils;
|
|
26
|
+
return _this;
|
|
10
27
|
}
|
|
11
28
|
JsonCaptchaBlocker.prototype.shouldBlock = function (context) {
|
|
12
29
|
if (!this.config.advancedBlockingResponseEnabled) {
|
|
13
30
|
return false;
|
|
14
31
|
}
|
|
15
|
-
|
|
16
|
-
var acceptHeaderContainsJson = acceptHeaderValue === null || acceptHeaderValue === void 0 ? void 0 : acceptHeaderValue.split(',').some(function (value) { return value.toLowerCase() === http_1.ContentType.APPLICATION_JSON; });
|
|
17
|
-
return !context.isMobile && context.blockAction !== blocker_1.BlockAction.RATE_LIMIT && acceptHeaderContainsJson;
|
|
32
|
+
return context.blockAction !== blocker_1.BlockAction.RATE_LIMIT && _super.prototype.shouldBlock.call(this, context);
|
|
18
33
|
};
|
|
19
|
-
JsonCaptchaBlocker.prototype.
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
var headers = (_a = {},
|
|
23
|
-
_a[http_1.CONTENT_TYPE_HEADER_NAME] = [http_1.ContentType.APPLICATION_JSON],
|
|
24
|
-
_a);
|
|
25
|
-
var blockData = (0, utils_1.createBlockData)(this.config, context);
|
|
26
|
-
var jsonBlockPayload = {
|
|
34
|
+
JsonCaptchaBlocker.prototype.createJsonPayload = function (context) {
|
|
35
|
+
var blockData = (0, blocker_1.createBlockData)(this.config, context, this.base64Utils);
|
|
36
|
+
return {
|
|
27
37
|
appId: blockData.appId,
|
|
28
38
|
jsClientSrc: blockData.jsClientSrc,
|
|
29
39
|
customLogo: blockData.customLogo,
|
|
@@ -34,9 +44,7 @@ var JsonCaptchaBlocker = /** @class */ (function () {
|
|
|
34
44
|
blockScript: blockData.blockScript,
|
|
35
45
|
altBlockScript: blockData.altBlockScript,
|
|
36
46
|
};
|
|
37
|
-
var body = JSON.stringify(jsonBlockPayload);
|
|
38
|
-
return new http_1.MinimalResponseImpl({ status: status, headers: headers, body: body });
|
|
39
47
|
};
|
|
40
48
|
return JsonCaptchaBlocker;
|
|
41
|
-
}());
|
|
49
|
+
}(blocker_1.JsonBlockerBase));
|
|
42
50
|
exports.JsonCaptchaBlocker = JsonCaptchaBlocker;
|