perimeterx-js-core 0.10.0 → 0.11.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 +5 -7
- 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/model/index.js +19 -0
- package/lib/cjs/{products/bot_defender/block → blocker}/utils.js +7 -5
- package/lib/cjs/custom_parameters/CustomParameters.js +1 -0
- package/lib/cjs/custom_parameters/CustomParametersUtils.js +5 -0
- package/lib/cjs/enforcer/EnforcerBase.js +3 -1
- package/lib/cjs/http/utils/constants.js +2 -1
- package/lib/cjs/phase/flow/EnforceFlow.js +4 -1
- package/lib/cjs/phase/impl/EnrichContextFromRequestPhase.js +2 -2
- package/lib/cjs/phase/impl/RiskApiPhase.js +5 -8
- package/lib/cjs/products/bot_defender/block/captcha/HtmlCaptchaBlocker.js +24 -16
- package/lib/cjs/products/bot_defender/block/captcha/JsonCaptchaBlocker.js +25 -18
- 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/hype_sale_challenge/HypeSaleChallenge.js +73 -0
- package/lib/cjs/products/hype_sale_challenge/IHypeSaleChallenge.js +2 -0
- package/lib/cjs/products/hype_sale_challenge/block/JsonHypeSaleChallengeBlocker.js +39 -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/products/hype_sale_challenge/block/templates/index.js +17 -0
- package/lib/cjs/products/hype_sale_challenge/index.js +21 -0
- package/lib/cjs/products/hype_sale_challenge/model/HypeSaleChallengeData.js +2 -0
- package/lib/cjs/products/hype_sale_challenge/model/JsonHypeSaleChallengeBlockPayload.js +2 -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/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/v2/DefaultTokenV2.js +9 -1
- package/lib/cjs/risk_token/token/v3/DefaultTokenV3.js +8 -0
- package/lib/cjs/utils/constants.js +1 -1
- package/lib/esm/action/utils.js +4 -0
- package/lib/esm/activities/utils.js +6 -7
- 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/model/index.js +3 -0
- package/lib/esm/{products/bot_defender/block → blocker}/utils.js +4 -2
- package/lib/esm/custom_parameters/CustomParameters.js +1 -1
- package/lib/esm/custom_parameters/CustomParametersUtils.js +5 -0
- package/lib/esm/enforcer/EnforcerBase.js +3 -1
- package/lib/esm/http/utils/constants.js +1 -0
- package/lib/esm/phase/flow/EnforceFlow.js +4 -1
- package/lib/esm/phase/impl/EnrichContextFromRequestPhase.js +1 -1
- package/lib/esm/phase/impl/RiskApiPhase.js +3 -5
- package/lib/esm/products/bot_defender/block/captcha/HtmlCaptchaBlocker.js +6 -14
- package/lib/esm/products/bot_defender/block/captcha/JsonCaptchaBlocker.js +6 -17
- 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/hype_sale_challenge/HypeSaleChallenge.js +69 -0
- package/lib/esm/products/hype_sale_challenge/IHypeSaleChallenge.js +1 -0
- package/lib/esm/products/hype_sale_challenge/block/JsonHypeSaleChallengeBlocker.js +18 -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/HypeSaleChallengeData.js +1 -0
- package/lib/esm/products/hype_sale_challenge/model/JsonHypeSaleChallengeBlockPayload.js +1 -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/risk_api/client/PostRiskApiClientBase.js +1 -1
- 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/v2/DefaultTokenV2.js +5 -1
- package/lib/esm/risk_token/token/v3/DefaultTokenV3.js +3 -0
- package/lib/esm/utils/constants.js +1 -1
- package/lib/types/action/utils.d.ts +2 -0
- package/lib/types/activities/model/CommonActivityDetails.d.ts +1 -0
- package/lib/types/activities/utils.d.ts +340 -110
- 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 +631 -0
- package/lib/types/custom_parameters/CustomParameters.d.ts +2 -0
- package/lib/types/http/utils/constants.d.ts +1 -0
- package/lib/types/phase/impl/RiskApiPhase.d.ts +1 -1
- package/lib/types/products/bot_defender/block/captcha/HtmlCaptchaBlocker.d.ts +3 -4
- package/lib/types/products/bot_defender/block/captcha/JsonCaptchaBlocker.d.ts +4 -4
- 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/hype_sale_challenge/HypeSaleChallenge.d.ts +26 -0
- package/lib/types/products/hype_sale_challenge/IHypeSaleChallenge.d.ts +5 -0
- package/lib/types/products/hype_sale_challenge/block/JsonHypeSaleChallengeBlocker.d.ts +9 -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/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 +1 -0
- 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/constants.d.ts +1 -1
- package/package.json +5 -3
- package/lib/cjs/blocker/BlockActionToProductMap.js +0 -10
- package/lib/esm/blocker/BlockActionToProductMap.js +0 -7
- package/lib/types/blocker/BlockAction.d.ts +0 -5
- package/lib/types/blocker/BlockActionToProductMap.d.ts +0 -3
- package/lib/types/products/bot_defender/block/utils.d.ts +0 -5
- /package/lib/cjs/blocker/{BlockActionToWordMap.js → model/BlockActionToWordMap.js} +0 -0
- /package/lib/cjs/{products/bot_defender/block → blocker}/model/BlockData.js +0 -0
- /package/lib/cjs/products/bot_defender/block/model/{JsonBlockPayload.js → JsonCaptchaBlockPayload.js} +0 -0
- /package/lib/esm/blocker/{BlockActionToWordMap.js → model/BlockActionToWordMap.js} +0 -0
- /package/lib/esm/{products/bot_defender/block → blocker}/model/BlockData.js +0 -0
- /package/lib/esm/products/bot_defender/block/model/{JsonBlockPayload.js → JsonCaptchaBlockPayload.js} +0 -0
- /package/lib/types/blocker/{BlockActionToWordMap.d.ts → model/BlockActionToWordMap.d.ts} +0 -0
package/lib/cjs/action/utils.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDecisionFromActions = exports.getProductActions = exports.getDecisionFromContext = void 0;
|
|
3
|
+
exports.getReasonForHighestPriorityProduct = exports.getDecisionFromActions = exports.getProductActions = exports.getDecisionFromContext = void 0;
|
|
4
4
|
var Action_1 = require("./Action");
|
|
5
|
+
var products_1 = require("../products");
|
|
5
6
|
var ActionPriorityOrder_1 = require("./ActionPriorityOrder");
|
|
6
7
|
var getDecisionFromContext = function (context) {
|
|
7
8
|
return (0, exports.getDecisionFromActions)((0, exports.getProductActions)(context));
|
|
@@ -46,3 +47,7 @@ var createDecision = function (tally) {
|
|
|
46
47
|
}
|
|
47
48
|
return { action: Action_1.Action.PASS_REQUEST };
|
|
48
49
|
};
|
|
50
|
+
var getReasonForHighestPriorityProduct = function (reasons) {
|
|
51
|
+
return reasons[products_1.PRODUCT_PRIORITY_ORDER.find(function (product) { return !!reasons[product]; })];
|
|
52
|
+
};
|
|
53
|
+
exports.getReasonForHighestPriorityProduct = getReasonForHighestPriorityProduct;
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.toHeaderEntryArray = exports.createAdditionalS2SActivityDetails = exports.createBlockActivityDetails = exports.createPageRequestedActivityDetails = exports.addResponseDataToAsyncActivityCommonDetails = exports.addRiskApiDataToAsyncActivityCommonDetails = exports.addTokenDataToDetails = exports.addRequestDataToDetails = exports.addServerDataToDetails = exports.addTlsDataToDetails = exports.addProductDataToDetails = exports.addCustomParametersToDetails = exports.addConfigDataToDetails = exports.addRootContextDataToDetails = exports.createCommonActivityDetails = exports.createAsyncActivityCommonDetails = exports.createActivityDetails = exports.createAsyncActivity = void 0;
|
|
4
4
|
var utils_1 = require("../utils");
|
|
5
5
|
var products_1 = require("../products");
|
|
6
|
-
var blocker_1 = require("../blocker");
|
|
7
6
|
var action_1 = require("../action");
|
|
8
7
|
var ActivityType_1 = require("./ActivityType");
|
|
9
8
|
var risk_token_1 = require("../risk_token");
|
|
@@ -102,6 +101,9 @@ var addProductDataToDetails = function (details, productData) {
|
|
|
102
101
|
ciVersion: 'ci_version',
|
|
103
102
|
ssoStep: 'sso_step',
|
|
104
103
|
});
|
|
104
|
+
(0, utils_1.transferExistingProperties)(productData.hsc, details, {
|
|
105
|
+
isTokenHscApproved: 'cpa',
|
|
106
|
+
});
|
|
105
107
|
};
|
|
106
108
|
exports.addProductDataToDetails = addProductDataToDetails;
|
|
107
109
|
var addTlsDataToDetails = function (details, tlsData) {
|
|
@@ -178,9 +180,7 @@ var addResponseDataToAsyncActivityCommonDetails = function (details, context) {
|
|
|
178
180
|
exports.addResponseDataToAsyncActivityCommonDetails = addResponseDataToAsyncActivityCommonDetails;
|
|
179
181
|
var createPageRequestedActivityDetails = function (context) {
|
|
180
182
|
var details = {};
|
|
181
|
-
details.pass_reason =
|
|
182
|
-
.filter(function (x) { return x; })
|
|
183
|
-
.join(', ');
|
|
183
|
+
details.pass_reason = (0, action_1.getReasonForHighestPriorityProduct)(context.reasons);
|
|
184
184
|
(0, utils_1.transferExistingProperties)(context.riskApiData, details, {
|
|
185
185
|
errorReason: 's2s_error_reason',
|
|
186
186
|
errorHttpStatus: 's2s_error_http_status',
|
|
@@ -190,10 +190,8 @@ var createPageRequestedActivityDetails = function (context) {
|
|
|
190
190
|
};
|
|
191
191
|
exports.createPageRequestedActivityDetails = createPageRequestedActivityDetails;
|
|
192
192
|
var createBlockActivityDetails = function (context) {
|
|
193
|
-
var _a;
|
|
194
193
|
var details = {};
|
|
195
|
-
|
|
196
|
-
details.block_reason = (_a = context.reasons) === null || _a === void 0 ? void 0 : _a[blockingProduct];
|
|
194
|
+
details.block_reason = (0, action_1.getReasonForHighestPriorityProduct)(context.reasons);
|
|
197
195
|
details.simulated_block = context.action === action_1.Action.SIMULATED_BLOCK;
|
|
198
196
|
(0, utils_1.transferExistingProperties)(context, details, {
|
|
199
197
|
blockAction: 'block_action',
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BlockerBase = void 0;
|
|
4
|
+
var http_1 = require("../http");
|
|
5
|
+
var BlockerBase = /** @class */ (function () {
|
|
6
|
+
function BlockerBase(contentType, statusCode) {
|
|
7
|
+
if (statusCode === void 0) { statusCode = 403; }
|
|
8
|
+
this.contentType = contentType;
|
|
9
|
+
this.statusCode = statusCode;
|
|
10
|
+
}
|
|
11
|
+
BlockerBase.prototype.createBlockResponse = function (context) {
|
|
12
|
+
var status = this.statusCode;
|
|
13
|
+
var headers = this.createHeaders(context);
|
|
14
|
+
var body = this.createBlockBody(context);
|
|
15
|
+
return new http_1.MinimalResponseImpl({
|
|
16
|
+
status: status,
|
|
17
|
+
headers: headers,
|
|
18
|
+
body: body,
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
BlockerBase.prototype.createHeaders = function (context) {
|
|
22
|
+
var _a;
|
|
23
|
+
return _a = {},
|
|
24
|
+
_a[http_1.CONTENT_TYPE_HEADER_NAME] = [this.contentType],
|
|
25
|
+
_a;
|
|
26
|
+
};
|
|
27
|
+
return BlockerBase;
|
|
28
|
+
}());
|
|
29
|
+
exports.BlockerBase = BlockerBase;
|
|
@@ -0,0 +1,36 @@
|
|
|
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.JsonBlockerBase = void 0;
|
|
19
|
+
var BlockerBase_1 = require("./BlockerBase");
|
|
20
|
+
var http_1 = require("../http");
|
|
21
|
+
var JsonBlockerBase = /** @class */ (function (_super) {
|
|
22
|
+
__extends(JsonBlockerBase, _super);
|
|
23
|
+
function JsonBlockerBase() {
|
|
24
|
+
return _super.call(this, http_1.ContentType.APPLICATION_JSON) || this;
|
|
25
|
+
}
|
|
26
|
+
JsonBlockerBase.prototype.shouldBlock = function (context) {
|
|
27
|
+
var acceptHeaderValue = context.requestData.request.headers.get(http_1.ACCEPT_HEADER_NAME) || '';
|
|
28
|
+
var acceptHeaderContainsJson = acceptHeaderValue === null || acceptHeaderValue === void 0 ? void 0 : acceptHeaderValue.split(',').some(function (value) { return value.toLowerCase() === http_1.ContentType.APPLICATION_JSON; });
|
|
29
|
+
return !context.isMobile && acceptHeaderContainsJson;
|
|
30
|
+
};
|
|
31
|
+
JsonBlockerBase.prototype.createBlockBody = function (context) {
|
|
32
|
+
return JSON.stringify(this.createJsonPayload(context));
|
|
33
|
+
};
|
|
34
|
+
return JsonBlockerBase;
|
|
35
|
+
}(BlockerBase_1.BlockerBase));
|
|
36
|
+
exports.JsonBlockerBase = JsonBlockerBase;
|
|
@@ -0,0 +1,48 @@
|
|
|
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.MobileBlocker = void 0;
|
|
19
|
+
var http_1 = require("../http");
|
|
20
|
+
var blocker_1 = require("../blocker");
|
|
21
|
+
var BlockerBase_1 = require("./BlockerBase");
|
|
22
|
+
var MobileBlocker = /** @class */ (function (_super) {
|
|
23
|
+
__extends(MobileBlocker, _super);
|
|
24
|
+
function MobileBlocker(config, base64Utils, template) {
|
|
25
|
+
var _this = _super.call(this, http_1.ContentType.APPLICATION_JSON) || this;
|
|
26
|
+
_this.config = config;
|
|
27
|
+
_this.base64Utils = base64Utils;
|
|
28
|
+
_this.template = template;
|
|
29
|
+
return _this;
|
|
30
|
+
}
|
|
31
|
+
MobileBlocker.prototype.shouldBlock = function (context) {
|
|
32
|
+
return context.isMobile;
|
|
33
|
+
};
|
|
34
|
+
MobileBlocker.prototype.createBlockBody = function (context) {
|
|
35
|
+
var blockData = (0, blocker_1.createBlockData)(this.config, context);
|
|
36
|
+
var html = (0, blocker_1.renderHtml)(this.template, blockData);
|
|
37
|
+
return JSON.stringify({
|
|
38
|
+
action: blocker_1.BLOCK_ACTION_TO_WORD_MAP.get(blockData.blockAction),
|
|
39
|
+
uuid: blockData.uuid,
|
|
40
|
+
vid: blockData.vid,
|
|
41
|
+
appId: blockData.appId,
|
|
42
|
+
page: this.base64Utils.base64Encode(html),
|
|
43
|
+
collectorHost: this.config.backendCollectorUrl,
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
return MobileBlocker;
|
|
47
|
+
}(BlockerBase_1.BlockerBase));
|
|
48
|
+
exports.MobileBlocker = MobileBlocker;
|
package/lib/cjs/blocker/index.js
CHANGED
|
@@ -16,6 +16,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./IConditionalBlocker"), exports);
|
|
18
18
|
__exportStar(require("./IBlocker"), exports);
|
|
19
|
-
__exportStar(require("./
|
|
20
|
-
__exportStar(require("./
|
|
21
|
-
__exportStar(require("./
|
|
19
|
+
__exportStar(require("./BlockerBase"), exports);
|
|
20
|
+
__exportStar(require("./JsonBlockerBase"), exports);
|
|
21
|
+
__exportStar(require("./MobileBlocker"), exports);
|
|
22
|
+
__exportStar(require("./model"), exports);
|
|
23
|
+
__exportStar(require("./utils"), exports);
|
|
@@ -6,4 +6,6 @@ var BlockAction;
|
|
|
6
6
|
BlockAction["CAPTCHA"] = "c";
|
|
7
7
|
BlockAction["RATE_LIMIT"] = "r";
|
|
8
8
|
BlockAction["CHALLENGE"] = "j";
|
|
9
|
+
BlockAction["HYPE_SALE_CHALLENGE"] = "hsc";
|
|
10
|
+
BlockAction["HYPE_SALE_CHALLENGE_LEGACY"] = "cp";
|
|
9
11
|
})(BlockAction || (exports.BlockAction = BlockAction = {}));
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
__exportStar(require("./BlockAction"), exports);
|
|
18
|
+
__exportStar(require("./BlockActionToWordMap"), exports);
|
|
19
|
+
__exportStar(require("./BlockData"), exports);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createBlockData = exports.renderHtml = void 0;
|
|
4
|
-
var utils_1 = require("
|
|
5
|
-
var
|
|
4
|
+
var utils_1 = require("../utils");
|
|
5
|
+
var products_1 = require("../products");
|
|
6
6
|
var renderHtml = function (htmlTemplate, blockData) {
|
|
7
7
|
if (!blockData) {
|
|
8
8
|
return htmlTemplate;
|
|
@@ -24,13 +24,14 @@ var createBlockData = function (config, context) {
|
|
|
24
24
|
var blockScript = "".concat(config.backendCaptchaUrl, "/").concat(config.appId).concat(captchaScriptSuffix).concat(captchaParams);
|
|
25
25
|
var hostUrl = config.backendCollectorUrl;
|
|
26
26
|
if (config.firstPartyEnabled && !context.isMobile) {
|
|
27
|
-
jsClientSrc = (0,
|
|
28
|
-
blockScript = "".concat((0,
|
|
29
|
-
hostUrl = (0,
|
|
27
|
+
jsClientSrc = (0, products_1.getMostCustomizedFirstPartyPath)(config, products_1.FirstPartySuffix.SENSOR);
|
|
28
|
+
blockScript = "".concat((0, products_1.getMostCustomizedFirstPartyPath)(config, products_1.FirstPartySuffix.CAPTCHA)).concat(config.customFirstPartyCaptchaEndpoint ? captchaParams : "".concat(captchaScriptSuffix).concat(captchaParams));
|
|
29
|
+
hostUrl = (0, products_1.getMostCustomizedFirstPartyPath)(config, products_1.FirstPartySuffix.XHR);
|
|
30
30
|
}
|
|
31
31
|
var cssRef = config.cssRef ? "<link rel=\"stylesheet\" type=\"text/css\" href=\"".concat(config.cssRef, "\" />") : '';
|
|
32
32
|
var jsRef = config.jsRef ? "<script src=\"".concat(config.jsRef, "\"></script>") : '';
|
|
33
33
|
var altBlockScript = "".concat(config.altBackendCaptchaUrl, "/").concat(config.appId).concat(captchaScriptSuffix).concat(captchaParams);
|
|
34
|
+
var jsTemplateScriptSrc = "https://captcha.px-cdn.net/".concat(config.appId, "/checkpoint.js");
|
|
34
35
|
return {
|
|
35
36
|
appId: config.appId,
|
|
36
37
|
vid: context.vid || ((_b = (_a = context.requestData) === null || _a === void 0 ? void 0 : _a.cookies) === null || _b === void 0 ? void 0 : _b[utils_1.PXVID_COOKIE_NAME]) || '',
|
|
@@ -45,6 +46,7 @@ var createBlockData = function (config, context) {
|
|
|
45
46
|
firstPartyEnabled: config.firstPartyEnabled,
|
|
46
47
|
blockScript: blockScript,
|
|
47
48
|
altBlockScript: altBlockScript,
|
|
49
|
+
jsTemplateScriptSrc: jsTemplateScriptSrc,
|
|
48
50
|
};
|
|
49
51
|
};
|
|
50
52
|
exports.createBlockData = createBlockData;
|
|
@@ -37,6 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.CustomParametersUtils = void 0;
|
|
40
|
+
var products_1 = require("../products");
|
|
40
41
|
var CustomParametersUtils;
|
|
41
42
|
(function (CustomParametersUtils) {
|
|
42
43
|
var _this = this;
|
|
@@ -71,6 +72,10 @@ var CustomParametersUtils;
|
|
|
71
72
|
normalizedParams[param] = value;
|
|
72
73
|
}
|
|
73
74
|
});
|
|
75
|
+
if (products_1.IS_HYPESALE_PARAM_NAME in customParameters &&
|
|
76
|
+
typeof customParameters[products_1.IS_HYPESALE_PARAM_NAME] === 'boolean') {
|
|
77
|
+
normalizedParams[products_1.IS_HYPESALE_PARAM_NAME] = customParameters[products_1.IS_HYPESALE_PARAM_NAME];
|
|
78
|
+
}
|
|
74
79
|
}
|
|
75
80
|
return Object.keys(normalizedParams).length === 0 ? null : normalizedParams;
|
|
76
81
|
};
|
|
@@ -68,6 +68,7 @@ var products_1 = require("../products");
|
|
|
68
68
|
var activities_1 = require("../activities");
|
|
69
69
|
var graphql_1 = require("../graphql");
|
|
70
70
|
var logger_1 = require("../logger");
|
|
71
|
+
var products_2 = require("../products");
|
|
71
72
|
var EnforcerBase = /** @class */ (function () {
|
|
72
73
|
/**
|
|
73
74
|
* The EnforcerBase constructor.
|
|
@@ -285,12 +286,13 @@ var EnforcerBase = /** @class */ (function () {
|
|
|
285
286
|
var credentialIntelligence = config.ciEnabled
|
|
286
287
|
? (products === null || products === void 0 ? void 0 : products.ci) || new products_1.CredentialIntelligence(config, hashUtils)
|
|
287
288
|
: null;
|
|
289
|
+
var hypeSaleChallenge = (products === null || products === void 0 ? void 0 : products.hsc) || new products_2.HypeSaleChallenge(config, { base64Utils: base64Utils });
|
|
288
290
|
return _a = {},
|
|
289
291
|
_a[products_1.ProductName.BOT_DEFENDER] = botDefender,
|
|
290
292
|
_a[products_1.ProductName.ACCOUNT_DEFENDER] = accountDefender,
|
|
291
293
|
_a[products_1.ProductName.CODE_DEFENDER] = products === null || products === void 0 ? void 0 : products.cd,
|
|
292
294
|
_a[products_1.ProductName.CREDENTIAL_INTELLIGENCE] = credentialIntelligence,
|
|
293
|
-
_a[products_1.ProductName.HYPE_SALE_CHALLENGE] =
|
|
295
|
+
_a[products_1.ProductName.HYPE_SALE_CHALLENGE] = hypeSaleChallenge,
|
|
294
296
|
_a;
|
|
295
297
|
};
|
|
296
298
|
return EnforcerBase;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HOST_HEADER_NAME = exports.SET_COOKIE_HEADER_NAME = exports.ACCEPT_HEADER_NAME = exports.AUTHORIZATION_HEADER_NAME = exports.COOKIE_HEADER_NAME = exports.CONTENT_LENGTH_HEADER_NAME = exports.CONTENT_TYPE_HEADER_NAME = exports.USER_AGENT_HEADER_NAME = exports.X_FORWARDED_FOR_HEADER_NAME = void 0;
|
|
3
|
+
exports.CACHE_CONTROL_HEADER_NAME = exports.HOST_HEADER_NAME = exports.SET_COOKIE_HEADER_NAME = exports.ACCEPT_HEADER_NAME = exports.AUTHORIZATION_HEADER_NAME = exports.COOKIE_HEADER_NAME = exports.CONTENT_LENGTH_HEADER_NAME = exports.CONTENT_TYPE_HEADER_NAME = exports.USER_AGENT_HEADER_NAME = exports.X_FORWARDED_FOR_HEADER_NAME = void 0;
|
|
4
4
|
exports.X_FORWARDED_FOR_HEADER_NAME = 'x-forwarded-for';
|
|
5
5
|
exports.USER_AGENT_HEADER_NAME = 'user-agent';
|
|
6
6
|
exports.CONTENT_TYPE_HEADER_NAME = 'content-type';
|
|
@@ -10,3 +10,4 @@ exports.AUTHORIZATION_HEADER_NAME = 'authorization';
|
|
|
10
10
|
exports.ACCEPT_HEADER_NAME = 'accept';
|
|
11
11
|
exports.SET_COOKIE_HEADER_NAME = 'set-cookie';
|
|
12
12
|
exports.HOST_HEADER_NAME = 'host';
|
|
13
|
+
exports.CACHE_CONTROL_HEADER_NAME = 'cache-control';
|
|
@@ -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
|
}
|
|
@@ -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,15 @@ 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
|
-
((_a = context.reasons) === null || _a === void 0 ? void 0 : _a[products_1.ProductName.BOT_DEFENDER]) || ((_b = context.reasons) === null || _b === void 0 ? void 0 : _b[products_1.ProductName.CREDENTIAL_INTELLIGENCE]);
|
|
97
|
+
context.riskApiData.s2sCallReason = (0, action_1.getReasonForHighestPriorityProduct)(context.reasons);
|
|
101
98
|
return [4 /*yield*/, this.riskApiClient.executeRiskApi(context)];
|
|
102
99
|
case 1:
|
|
103
|
-
riskApiData =
|
|
100
|
+
riskApiData = _a.sent();
|
|
104
101
|
Object.assign(context.riskApiData, riskApiData);
|
|
105
102
|
return [2 /*return*/];
|
|
106
103
|
}
|
|
@@ -1,26 +1,34 @@
|
|
|
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 () {
|
|
22
|
+
var HtmlCaptchaBlocker = /** @class */ (function (_super) {
|
|
23
|
+
__extends(HtmlCaptchaBlocker, _super);
|
|
8
24
|
function HtmlCaptchaBlocker(config) {
|
|
9
|
-
this.
|
|
25
|
+
var _this = _super.call(this, http_1.ContentType.TEXT_HTML) || this;
|
|
26
|
+
_this.config = config;
|
|
27
|
+
return _this;
|
|
10
28
|
}
|
|
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
|
-
});
|
|
29
|
+
HtmlCaptchaBlocker.prototype.createBlockBody = function (context) {
|
|
30
|
+
return (0, blocker_1.renderHtml)(templates_1.CAPTCHA_TEMPLATE, (0, blocker_1.createBlockData)(this.config, context));
|
|
23
31
|
};
|
|
24
32
|
return HtmlCaptchaBlocker;
|
|
25
|
-
}());
|
|
33
|
+
}(blocker_1.BlockerBase));
|
|
26
34
|
exports.HtmlCaptchaBlocker = HtmlCaptchaBlocker;
|
|
@@ -1,29 +1,38 @@
|
|
|
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
|
-
var JsonCaptchaBlocker = /** @class */ (function () {
|
|
20
|
+
var JsonCaptchaBlocker = /** @class */ (function (_super) {
|
|
21
|
+
__extends(JsonCaptchaBlocker, _super);
|
|
8
22
|
function JsonCaptchaBlocker(config) {
|
|
9
|
-
|
|
23
|
+
var _this = _super.call(this) || this;
|
|
24
|
+
_this.config = config;
|
|
25
|
+
return _this;
|
|
10
26
|
}
|
|
11
27
|
JsonCaptchaBlocker.prototype.shouldBlock = function (context) {
|
|
12
28
|
if (!this.config.advancedBlockingResponseEnabled) {
|
|
13
29
|
return false;
|
|
14
30
|
}
|
|
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;
|
|
31
|
+
return context.blockAction !== blocker_1.BlockAction.RATE_LIMIT && _super.prototype.shouldBlock.call(this, context);
|
|
18
32
|
};
|
|
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 = {
|
|
33
|
+
JsonCaptchaBlocker.prototype.createJsonPayload = function (context) {
|
|
34
|
+
var blockData = (0, blocker_1.createBlockData)(this.config, context);
|
|
35
|
+
return {
|
|
27
36
|
appId: blockData.appId,
|
|
28
37
|
jsClientSrc: blockData.jsClientSrc,
|
|
29
38
|
customLogo: blockData.customLogo,
|
|
@@ -34,9 +43,7 @@ var JsonCaptchaBlocker = /** @class */ (function () {
|
|
|
34
43
|
blockScript: blockData.blockScript,
|
|
35
44
|
altBlockScript: blockData.altBlockScript,
|
|
36
45
|
};
|
|
37
|
-
var body = JSON.stringify(jsonBlockPayload);
|
|
38
|
-
return new http_1.MinimalResponseImpl({ status: status, headers: headers, body: body });
|
|
39
46
|
};
|
|
40
47
|
return JsonCaptchaBlocker;
|
|
41
|
-
}());
|
|
48
|
+
}(blocker_1.JsonBlockerBase));
|
|
42
49
|
exports.JsonCaptchaBlocker = JsonCaptchaBlocker;
|
|
@@ -1,40 +1,28 @@
|
|
|
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.MobileCaptchaBlocker = void 0;
|
|
4
19
|
var blocker_1 = require("../../../../blocker");
|
|
5
|
-
var http_1 = require("../../../../http");
|
|
6
|
-
var utils_1 = require("../utils");
|
|
7
20
|
var templates_1 = require("../templates");
|
|
8
|
-
var MobileCaptchaBlocker = /** @class */ (function () {
|
|
21
|
+
var MobileCaptchaBlocker = /** @class */ (function (_super) {
|
|
22
|
+
__extends(MobileCaptchaBlocker, _super);
|
|
9
23
|
function MobileCaptchaBlocker(config, base64Utils) {
|
|
10
|
-
this
|
|
11
|
-
this.base64Utils = base64Utils;
|
|
24
|
+
return _super.call(this, config, base64Utils, templates_1.CAPTCHA_TEMPLATE) || this;
|
|
12
25
|
}
|
|
13
|
-
MobileCaptchaBlocker.prototype.shouldBlock = function (context) {
|
|
14
|
-
return context.isMobile;
|
|
15
|
-
};
|
|
16
|
-
MobileCaptchaBlocker.prototype.createBlockResponse = function (context) {
|
|
17
|
-
var _a;
|
|
18
|
-
var status = 403;
|
|
19
|
-
var headers = (_a = {},
|
|
20
|
-
_a[http_1.CONTENT_TYPE_HEADER_NAME] = [http_1.ContentType.APPLICATION_JSON],
|
|
21
|
-
_a);
|
|
22
|
-
var blockData = (0, utils_1.createBlockData)(this.config, context);
|
|
23
|
-
var captchaPage = (0, utils_1.renderHtml)(templates_1.CAPTCHA_TEMPLATE, blockData);
|
|
24
|
-
var mobileBlockPayload = {
|
|
25
|
-
action: blocker_1.BLOCK_ACTION_TO_WORD_MAP.get(blockData.blockAction),
|
|
26
|
-
uuid: blockData.uuid,
|
|
27
|
-
vid: blockData.vid,
|
|
28
|
-
appId: blockData.appId,
|
|
29
|
-
page: this.base64Utils.base64Encode(captchaPage),
|
|
30
|
-
collectorHost: this.config.backendCollectorUrl,
|
|
31
|
-
};
|
|
32
|
-
return new http_1.MinimalResponseImpl({
|
|
33
|
-
body: JSON.stringify(mobileBlockPayload),
|
|
34
|
-
status: status,
|
|
35
|
-
headers: headers,
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
26
|
return MobileCaptchaBlocker;
|
|
39
|
-
}());
|
|
27
|
+
}(blocker_1.MobileBlocker));
|
|
40
28
|
exports.MobileCaptchaBlocker = MobileCaptchaBlocker;
|
|
@@ -17,5 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./model"), exports);
|
|
18
18
|
__exportStar(require("./captcha"), exports);
|
|
19
19
|
__exportStar(require("./templates"), exports);
|
|
20
|
-
__exportStar(require("
|
|
20
|
+
__exportStar(require("../../../blocker/utils"), exports);
|
|
21
21
|
__exportStar(require("./DefaultBotDefenderBlocker"), exports);
|
|
@@ -14,6 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
18
|
-
__exportStar(require("./JsonBlockPayload"), exports);
|
|
17
|
+
__exportStar(require("./JsonCaptchaBlockPayload"), exports);
|
|
19
18
|
__exportStar(require("./MobileBlockPayload"), exports);
|