perimeterx-js-core 0.25.0 → 0.26.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/Action.js +15 -0
- package/lib/cjs/action/ActionPriorityOrder.js +4 -0
- package/lib/cjs/action/utils.js +20 -0
- package/lib/cjs/activities/HttpActivityClient.js +61 -1
- package/lib/cjs/activities/HttpBatchedActivityClient.js +7 -0
- package/lib/cjs/activities/utils.js +128 -62
- package/lib/cjs/additional_activity_handler/AdditionalActivityHandlerUtils.js +6 -0
- package/lib/cjs/blocker/BlockerBase.js +14 -0
- package/lib/cjs/blocker/JsonBlockerBase.js +5 -0
- package/lib/cjs/blocker/utils.js +13 -0
- package/lib/cjs/config/ConfigurationBase.js +17 -0
- package/lib/cjs/context/DefaultContext.js +4 -0
- package/lib/cjs/context/SerializedContext.js +5 -0
- package/lib/cjs/enforcer/EnforcerBase.js +61 -22
- package/lib/cjs/enforcer/index.js +1 -0
- package/lib/cjs/{phase/flow → flow}/EndEnforcerFlow.js +11 -7
- package/lib/cjs/{phase/flow → flow}/EnforceFlow.js +10 -15
- package/lib/cjs/{phase/flow → flow}/FilterFlow.js +10 -9
- package/lib/cjs/flow/Flow.js +60 -0
- package/lib/cjs/flow/IFlow.js +2 -0
- package/lib/cjs/{phase/flow → flow}/PostEnforceFlow.js +6 -6
- package/lib/cjs/{phase/flow → flow}/index.js +2 -0
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/phase/impl/AdditionalActivityHandlerPhase.js +3 -0
- package/lib/cjs/phase/impl/ClearLogsPhase.js +3 -0
- package/lib/cjs/phase/impl/CompositePhase.js +9 -0
- package/lib/cjs/phase/impl/CreateBlockResponsePhase.js +16 -0
- package/lib/cjs/phase/impl/DecideActionPhase.js +11 -0
- package/lib/cjs/phase/impl/EnrichContextFromRequestPhase.js +13 -9
- package/lib/cjs/phase/impl/EnrichContextFromResponsePhase.js +4 -0
- package/lib/cjs/phase/impl/FilterPhase.js +4 -0
- package/lib/cjs/phase/impl/FirstPartyPhase.js +5 -0
- package/lib/cjs/phase/impl/IdentifyRemoteConfigNotifyRequestPhase.js +5 -0
- package/lib/cjs/phase/impl/IdentifyTelemetryRequestPhase.js +5 -0
- package/lib/cjs/phase/impl/ModifyIncomingRequestPhase.js +5 -0
- package/lib/cjs/phase/impl/ModifyOutgoingResponsePhase.js +5 -0
- package/lib/cjs/phase/impl/ParseTokenPhase.js +14 -7
- package/lib/cjs/phase/impl/PreflightPhase.js +4 -0
- package/lib/cjs/phase/impl/RiskApiPhase.js +18 -7
- package/lib/cjs/phase/impl/{SendAsyncActivitiesOnResponsePhase.js → SendAsyncActivitiesPhase.js} +15 -8
- package/lib/cjs/phase/impl/SendLogsPhase.js +3 -0
- package/lib/cjs/phase/impl/SendTelemetryActivityPhase.js +3 -0
- package/lib/cjs/phase/impl/UpdateRemoteConfigPhase.js +3 -0
- package/lib/cjs/phase/impl/index.js +1 -2
- package/lib/cjs/phase/index.js +0 -1
- package/lib/cjs/products/credential_intelligence/endpoint/login_successful/BodyLoginSuccessfulParser.js +1 -1
- package/lib/cjs/products/credential_intelligence/endpoint/login_successful/LoginSuccessfulParserFactory.js +5 -2
- package/lib/cjs/products/credential_intelligence/endpoint/matcher/CredentialIntelligenceEndpointMatcherFactory.js +3 -1
- package/lib/cjs/risk_api/client/GetRiskApiClientV2.js +80 -0
- package/lib/cjs/risk_api/client/PostRiskApiClientV2.js +3 -3
- package/lib/cjs/risk_api/client/PostRiskApiClientV3.js +3 -3
- package/lib/cjs/risk_api/client/abstract/IRiskApiClient.js +2 -0
- package/lib/cjs/risk_api/client/abstract/PostRiskApiClientBase.js +43 -0
- package/lib/cjs/risk_api/client/{PostRiskApiClientBase.js → abstract/RiskApiClientBase.js} +22 -69
- package/lib/cjs/risk_api/client/abstract/index.js +19 -0
- package/lib/cjs/risk_api/client/index.js +2 -2
- package/lib/cjs/risk_api/index.js +1 -0
- package/lib/cjs/risk_api/model/GetRiskRequestHeaders.js +185 -0
- package/lib/cjs/risk_api/model/GetRiskResponseHeaders.js +16 -0
- package/lib/cjs/risk_api/model/index.js +2 -0
- package/lib/cjs/{phase/impl/SendAsyncActivitiesOnRequestPhase.js → risk_api/risk_response/PostRiskResponseBase.js} +26 -30
- package/lib/cjs/risk_api/risk_response/RiskResponseBase.js +11 -8
- package/lib/cjs/risk_api/risk_response/index.js +1 -0
- package/lib/cjs/risk_api/risk_response/serialize/SerializedRiskResponse.js +5 -1
- package/lib/cjs/risk_api/risk_response/v2/GetRiskResponseV2.js +80 -0
- package/lib/cjs/risk_api/risk_response/v2/{DefaultRiskResponseV2.js → PostRiskResponseV2.js} +10 -10
- package/lib/cjs/risk_api/risk_response/v2/index.js +2 -1
- package/lib/cjs/risk_api/risk_response/v3/{DefaultRiskResponseV3.js → PostRiskResponseV3.js} +10 -10
- package/lib/cjs/risk_api/risk_response/v3/index.js +1 -1
- package/lib/cjs/risk_api/utils.js +36 -0
- package/lib/cjs/telemetry/DefaultTelemetry.js +12 -9
- package/lib/cjs/utils/constants.js +1 -1
- package/lib/cjs/utils/utils.js +1 -19
- package/lib/esm/action/Action.js +15 -0
- package/lib/esm/action/ActionPriorityOrder.js +4 -0
- package/lib/esm/action/utils.js +20 -0
- package/lib/esm/activities/HttpActivityClient.js +61 -1
- package/lib/esm/activities/HttpBatchedActivityClient.js +7 -0
- package/lib/esm/activities/utils.js +128 -63
- package/lib/esm/additional_activity_handler/AdditionalActivityHandlerUtils.js +6 -0
- package/lib/esm/blocker/BlockerBase.js +14 -0
- package/lib/esm/blocker/JsonBlockerBase.js +5 -0
- package/lib/esm/blocker/utils.js +13 -0
- package/lib/esm/config/ConfigurationBase.js +13 -0
- package/lib/esm/context/DefaultContext.js +4 -0
- package/lib/esm/context/SerializedContext.js +5 -0
- package/lib/esm/enforcer/EnforcerBase.js +43 -6
- package/lib/esm/enforcer/index.js +1 -0
- package/lib/esm/flow/EndEnforcerFlow.js +18 -0
- package/lib/esm/flow/EnforceFlow.js +14 -0
- package/lib/esm/{phase/flow → flow}/FilterFlow.js +5 -4
- package/lib/esm/flow/Flow.js +56 -0
- package/lib/esm/flow/IFlow.js +1 -0
- package/lib/esm/flow/PostEnforceFlow.js +10 -0
- package/lib/esm/{phase/flow → flow}/index.js +2 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/phase/impl/AdditionalActivityHandlerPhase.js +3 -0
- package/lib/esm/phase/impl/ClearLogsPhase.js +3 -0
- package/lib/esm/phase/impl/CompositePhase.js +9 -0
- package/lib/esm/phase/impl/CreateBlockResponsePhase.js +16 -1
- package/lib/esm/phase/impl/DecideActionPhase.js +11 -0
- package/lib/esm/phase/impl/EnrichContextFromRequestPhase.js +9 -0
- package/lib/esm/phase/impl/EnrichContextFromResponsePhase.js +4 -0
- package/lib/esm/phase/impl/FilterPhase.js +4 -0
- package/lib/esm/phase/impl/FirstPartyPhase.js +5 -0
- package/lib/esm/phase/impl/IdentifyRemoteConfigNotifyRequestPhase.js +5 -0
- package/lib/esm/phase/impl/IdentifyTelemetryRequestPhase.js +5 -0
- package/lib/esm/phase/impl/ModifyIncomingRequestPhase.js +5 -0
- package/lib/esm/phase/impl/ModifyOutgoingResponsePhase.js +5 -0
- package/lib/esm/phase/impl/ParseTokenPhase.js +15 -8
- package/lib/esm/phase/impl/PreflightPhase.js +4 -0
- package/lib/esm/phase/impl/RiskApiPhase.js +19 -8
- package/lib/esm/phase/impl/SendAsyncActivitiesPhase.js +16 -0
- package/lib/esm/phase/impl/SendLogsPhase.js +3 -0
- package/lib/esm/phase/impl/SendTelemetryActivityPhase.js +3 -0
- package/lib/esm/phase/impl/UpdateRemoteConfigPhase.js +3 -0
- package/lib/esm/phase/impl/index.js +1 -2
- package/lib/esm/phase/index.js +0 -1
- package/lib/esm/products/credential_intelligence/endpoint/login_successful/BodyLoginSuccessfulParser.js +1 -1
- package/lib/esm/products/credential_intelligence/endpoint/login_successful/LoginSuccessfulParserFactory.js +5 -2
- package/lib/esm/products/credential_intelligence/endpoint/matcher/CredentialIntelligenceEndpointMatcherFactory.js +2 -1
- package/lib/esm/risk_api/client/GetRiskApiClientV2.js +57 -0
- package/lib/esm/risk_api/client/PostRiskApiClientV2.js +3 -3
- package/lib/esm/risk_api/client/PostRiskApiClientV3.js +3 -3
- package/lib/esm/risk_api/client/abstract/IRiskApiClient.js +1 -0
- package/lib/esm/risk_api/client/abstract/PostRiskApiClientBase.js +18 -0
- package/lib/esm/risk_api/client/{PostRiskApiClientBase.js → abstract/RiskApiClientBase.js} +10 -49
- package/lib/esm/risk_api/client/abstract/index.js +3 -0
- package/lib/esm/risk_api/client/index.js +2 -2
- package/lib/esm/risk_api/index.js +1 -0
- package/lib/esm/risk_api/model/GetRiskRequestHeaders.js +182 -0
- package/lib/esm/risk_api/model/GetRiskResponseHeaders.js +13 -0
- package/lib/esm/risk_api/model/index.js +2 -0
- package/lib/esm/risk_api/risk_response/PostRiskResponseBase.js +6 -0
- package/lib/esm/risk_api/risk_response/RiskResponseBase.js +5 -1
- package/lib/esm/risk_api/risk_response/index.js +1 -0
- package/lib/esm/risk_api/risk_response/serialize/SerializedRiskResponse.js +5 -1
- package/lib/esm/risk_api/risk_response/v2/GetRiskResponseV2.js +52 -0
- package/lib/esm/risk_api/risk_response/v2/{DefaultRiskResponseV2.js → PostRiskResponseV2.js} +2 -2
- package/lib/esm/risk_api/risk_response/v2/index.js +2 -1
- package/lib/esm/risk_api/risk_response/v3/{DefaultRiskResponseV3.js → PostRiskResponseV3.js} +2 -2
- package/lib/esm/risk_api/risk_response/v3/index.js +1 -1
- package/lib/esm/risk_api/utils.js +23 -0
- package/lib/esm/telemetry/DefaultTelemetry.js +13 -10
- package/lib/esm/utils/constants.js +1 -1
- package/lib/esm/utils/utils.js +0 -16
- package/lib/types/action/Action.d.ts +15 -0
- package/lib/types/action/ActionData.d.ts +3 -0
- package/lib/types/action/ActionPriorityOrder.d.ts +4 -0
- package/lib/types/action/Decision.d.ts +9 -0
- package/lib/types/action/ProductAction.d.ts +3 -0
- package/lib/types/action/utils.d.ts +20 -0
- package/lib/types/activities/HttpActivityClient.d.ts +57 -1
- package/lib/types/activities/HttpBatchedActivityClient.d.ts +7 -0
- package/lib/types/activities/IActivityClient.d.ts +4 -1
- package/lib/types/activities/model/AsyncActivity.d.ts +3 -0
- package/lib/types/activities/model/AsyncActivityDetails.d.ts +12 -0
- package/lib/types/activities/model/CommonActivityDetails.d.ts +3 -0
- package/lib/types/activities/utils.d.ts +14 -0
- package/lib/types/additional_activity_handler/AdditionalActivityHandlerUtils.d.ts +6 -0
- package/lib/types/blocker/BlockerBase.d.ts +21 -0
- package/lib/types/blocker/IBlocker.d.ts +8 -0
- package/lib/types/blocker/IConditionalBlocker.d.ts +4 -0
- package/lib/types/blocker/JsonBlockerBase.d.ts +12 -0
- package/lib/types/blocker/model/BlockData.d.ts +3 -0
- package/lib/types/blocker/utils.d.ts +13 -0
- package/lib/types/config/ConfigurationBase.d.ts +22 -0
- package/lib/types/config/IConfiguration.d.ts +4 -0
- package/lib/types/config/params/CoreConfigurationParams.d.ts +21 -0
- package/lib/types/config/params/RemoteConfigurationParams.d.ts +3 -0
- package/lib/types/config/params/StaticConfigurationParams.d.ts +3 -0
- package/lib/types/context/ContextJson.d.ts +4 -0
- package/lib/types/context/DefaultContext.d.ts +4 -0
- package/lib/types/context/SerializedContext.d.ts +5 -0
- package/lib/types/custom_parameters/CustomParameters.d.ts +3 -0
- package/lib/types/enforcer/EnforcerBase.d.ts +48 -12
- package/lib/types/enforcer/IEnforcer.d.ts +1 -2
- package/lib/types/enforcer/IPostEnforcer.d.ts +3 -0
- package/lib/types/enforcer/index.d.ts +1 -0
- package/lib/types/first_party/IFirstParty.d.ts +1 -1
- package/lib/types/flow/EndEnforcerFlow.d.ts +8 -0
- package/lib/types/flow/EnforceFlow.d.ts +8 -0
- package/lib/types/{phase/flow → flow}/FilterFlow.d.ts +7 -7
- package/lib/types/flow/Flow.d.ts +13 -0
- package/lib/types/flow/IFlow.d.ts +57 -0
- package/lib/types/flow/PostEnforceFlow.d.ts +6 -0
- package/lib/types/{phase/flow → flow}/index.d.ts +2 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/phase/IPhase.d.ts +9 -0
- package/lib/types/phase/PhaseResult.d.ts +11 -0
- package/lib/types/phase/impl/AdditionalActivityHandlerPhase.d.ts +3 -0
- package/lib/types/phase/impl/ClearLogsPhase.d.ts +3 -0
- package/lib/types/phase/impl/CompositePhase.d.ts +9 -0
- package/lib/types/phase/impl/CreateBlockResponsePhase.d.ts +11 -1
- package/lib/types/phase/impl/DecideActionPhase.d.ts +11 -0
- package/lib/types/phase/impl/EnrichContextFromRequestPhase.d.ts +9 -0
- package/lib/types/phase/impl/EnrichContextFromResponsePhase.d.ts +4 -0
- package/lib/types/phase/impl/FilterPhase.d.ts +4 -0
- package/lib/types/phase/impl/FirstPartyPhase.d.ts +5 -0
- package/lib/types/phase/impl/IdentifyRemoteConfigNotifyRequestPhase.d.ts +5 -0
- package/lib/types/phase/impl/IdentifyTelemetryRequestPhase.d.ts +5 -0
- package/lib/types/phase/impl/ModifyIncomingRequestPhase.d.ts +5 -0
- package/lib/types/phase/impl/ModifyOutgoingResponsePhase.d.ts +5 -0
- package/lib/types/phase/impl/ParseTokenPhase.d.ts +3 -0
- package/lib/types/phase/impl/PreflightPhase.d.ts +4 -0
- package/lib/types/phase/impl/RiskApiPhase.d.ts +5 -0
- package/lib/types/phase/impl/{SendAsyncActivitiesOnResponsePhase.d.ts → SendAsyncActivitiesPhase.d.ts} +5 -2
- package/lib/types/phase/impl/SendLogsPhase.d.ts +3 -0
- package/lib/types/phase/impl/SendTelemetryActivityPhase.d.ts +3 -0
- package/lib/types/phase/impl/UpdateRemoteConfigPhase.d.ts +3 -0
- package/lib/types/phase/impl/index.d.ts +1 -2
- package/lib/types/phase/index.d.ts +0 -1
- package/lib/types/products/credential_intelligence/endpoint/CredentialEndpointConfiguration.d.ts +1 -1
- package/lib/types/products/credential_intelligence/endpoint/login_successful/BodyLoginSuccessfulParser.d.ts +1 -1
- package/lib/types/products/interfaces/IProduct.d.ts +28 -0
- package/lib/types/products/interfaces/ProductDataType.d.ts +1 -1
- package/lib/types/risk_api/client/GetRiskApiClientV2.d.ts +15 -0
- package/lib/types/risk_api/client/PostRiskApiClientV2.d.ts +1 -1
- package/lib/types/risk_api/client/PostRiskApiClientV3.d.ts +2 -2
- package/lib/types/risk_api/client/{IRiskApiClient.d.ts → abstract/IRiskApiClient.d.ts} +1 -1
- package/lib/types/risk_api/client/abstract/PostRiskApiClientBase.d.ts +8 -0
- package/lib/types/risk_api/client/abstract/RiskApiClientBase.d.ts +26 -0
- package/lib/types/risk_api/client/abstract/index.d.ts +3 -0
- package/lib/types/risk_api/client/index.d.ts +2 -2
- package/lib/types/risk_api/index.d.ts +1 -0
- package/lib/types/risk_api/model/GetRiskRequestHeaders.d.ts +17 -0
- package/lib/types/risk_api/model/GetRiskResponseHeaders.d.ts +3 -0
- package/lib/types/risk_api/model/index.d.ts +2 -0
- package/lib/types/risk_api/risk_response/IRiskResponse.d.ts +2 -0
- package/lib/types/risk_api/risk_response/PostRiskResponseBase.d.ts +7 -0
- package/lib/types/risk_api/risk_response/RiskResponseBase.d.ts +3 -1
- package/lib/types/risk_api/risk_response/index.d.ts +1 -0
- package/lib/types/risk_api/risk_response/serialize/SerializedRiskResponse.d.ts +1 -0
- package/lib/types/risk_api/risk_response/v2/GetRiskResponseV2.d.ts +11 -0
- package/lib/types/risk_api/risk_response/{v3/DefaultRiskResponseV3.d.ts → v2/PostRiskResponseV2.d.ts} +2 -2
- package/lib/types/risk_api/risk_response/v2/index.d.ts +2 -1
- package/lib/types/risk_api/risk_response/{v2/DefaultRiskResponseV2.d.ts → v3/PostRiskResponseV3.d.ts} +2 -2
- package/lib/types/risk_api/risk_response/v3/index.d.ts +1 -1
- package/lib/types/risk_api/utils.d.ts +69 -0
- package/lib/types/telemetry/model/TelemetryActivity.d.ts +1 -1
- package/lib/types/utils/constants.d.ts +1 -1
- package/lib/types/utils/utils.d.ts +0 -5
- package/package.json +1 -1
- package/lib/esm/phase/flow/EndEnforcerFlow.js +0 -14
- package/lib/esm/phase/flow/EnforceFlow.js +0 -18
- package/lib/esm/phase/flow/PostEnforceFlow.js +0 -10
- package/lib/esm/phase/impl/SendAsyncActivitiesOnRequestPhase.js +0 -16
- package/lib/esm/phase/impl/SendAsyncActivitiesOnResponsePhase.js +0 -10
- package/lib/types/phase/flow/EndEnforcerFlow.d.ts +0 -8
- package/lib/types/phase/flow/EnforceFlow.d.ts +0 -8
- package/lib/types/phase/flow/PostEnforceFlow.d.ts +0 -6
- package/lib/types/phase/impl/SendAsyncActivitiesOnRequestPhase.d.ts +0 -10
- package/lib/types/risk_api/client/PostRiskApiClientBase.d.ts +0 -40
- /package/lib/cjs/{risk_api/client/IRiskApiClient.js → enforcer/IPostEnforcer.js} +0 -0
- /package/lib/esm/{risk_api/client/IRiskApiClient.js → enforcer/IPostEnforcer.js} +0 -0
|
@@ -46,8 +46,11 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
46
46
|
};
|
|
47
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
48
|
exports.EnforcerBase = void 0;
|
|
49
|
-
var
|
|
49
|
+
var flow_1 = require("../flow/index.js");
|
|
50
50
|
var utils_1 = require("./utils.js");
|
|
51
|
+
/**
|
|
52
|
+
* The base class for fundamental enforcer logic.
|
|
53
|
+
*/
|
|
51
54
|
var EnforcerBase = /** @class */ (function () {
|
|
52
55
|
/**
|
|
53
56
|
* The EnforcerBase constructor.
|
|
@@ -68,17 +71,49 @@ var EnforcerBase = /** @class */ (function () {
|
|
|
68
71
|
this.config.logger.debug('HUMAN enforcer is disabled, will not enforce');
|
|
69
72
|
}
|
|
70
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Creates the filter flow for the enforcer. The filter flow is responsible for filtering out requests that should not undergo the usual enforcement flow.
|
|
76
|
+
* For example, first party, filtered, CORS preflight, and telemetry requests are filtered out.
|
|
77
|
+
* @param config - The configuration object.
|
|
78
|
+
* @param initializationBlock - All entities necessary for the enforcer to function.
|
|
79
|
+
* @protected
|
|
80
|
+
* @returns - The filter flow for the enforcer.
|
|
81
|
+
*/
|
|
71
82
|
EnforcerBase.prototype.createFilterFlow = function (config, initializationBlock) {
|
|
72
|
-
return new
|
|
83
|
+
return new flow_1.FilterFlow(config, initializationBlock);
|
|
73
84
|
};
|
|
85
|
+
/**
|
|
86
|
+
* Creates the post enforce flow for the enforcer. The post enforce flow is responsible for any logic that requires the origin response in the case of passed requests.
|
|
87
|
+
* For example, enriching the context with response data (status, login successful information) and modifying the origin response (snippet injection, PXHD) are part of the post enforce flow.
|
|
88
|
+
* @param config - The configuration object.
|
|
89
|
+
* @param initializationBlock - All entities necessary for the enforcer to function.
|
|
90
|
+
* @protected
|
|
91
|
+
* @returns - The post enforce flow for the enforcer or null if post enforce is not enabled.
|
|
92
|
+
*/
|
|
74
93
|
EnforcerBase.prototype.createPostEnforceFlow = function (config, initializationBlock) {
|
|
75
|
-
return new
|
|
94
|
+
return this.config.isPostEnforceEnabled ? new flow_1.PostEnforceFlow(config, initializationBlock) : null;
|
|
76
95
|
};
|
|
96
|
+
/**
|
|
97
|
+
* Creates the enforce flow for the enforcer. The enforce flow is responsible for the core functionality of HUMAN enforcement.
|
|
98
|
+
* For example, parsing HUMAN cookies, performing Risk API, invoking the additional activity handler, and returning a block response are part of the enforce flow.
|
|
99
|
+
* @param config - The configuration object.
|
|
100
|
+
* @param initializationBlock - All entities necessary for the enforcer to function.
|
|
101
|
+
* @protected
|
|
102
|
+
* @returns - The enforce flow for the enforcer.
|
|
103
|
+
*/
|
|
77
104
|
EnforcerBase.prototype.createEnforceFlow = function (config, initializationBlock) {
|
|
78
|
-
return new
|
|
105
|
+
return new flow_1.EnforceFlow(config, initializationBlock);
|
|
79
106
|
};
|
|
107
|
+
/**
|
|
108
|
+
* Creates the end enforce flow for the enforcer. The end enforce flow is responsible for all actions that must be done after every incoming request.
|
|
109
|
+
* For example, sending the async activities, sending the telemetry activity, or updating the remote config, sending and clearing the enforcer logs, are parts of the end enforce flow.
|
|
110
|
+
* @param config - The configuration object.
|
|
111
|
+
* @param initializationBlock - All entities necessary for the enforcer to function.
|
|
112
|
+
* @protected
|
|
113
|
+
* @returns - The end enforce flow for the enforcer.
|
|
114
|
+
*/
|
|
80
115
|
EnforcerBase.prototype.createEndEnforcerFlow = function (config, initializationBlock) {
|
|
81
|
-
return new
|
|
116
|
+
return new flow_1.EndEnforcerFlow(config, initializationBlock);
|
|
82
117
|
};
|
|
83
118
|
/**
|
|
84
119
|
* The central function that triggers enforcement on the incoming request.
|
|
@@ -142,18 +177,21 @@ var EnforcerBase = /** @class */ (function () {
|
|
|
142
177
|
case 2:
|
|
143
178
|
_a.sent();
|
|
144
179
|
return [2 /*return*/, result.response ? this.convertToRes.apply(this, __spreadArray([result.response], args, false)) : null];
|
|
145
|
-
case 3: return [4 /*yield*/, this.
|
|
180
|
+
case 3: return [4 /*yield*/, this.enforceFlow.execute(context)];
|
|
146
181
|
case 4:
|
|
147
|
-
_a.sent();
|
|
148
|
-
return [4 /*yield*/, this.enforceFlow.execute(context)];
|
|
149
|
-
case 5:
|
|
150
182
|
result = _a.sent();
|
|
151
|
-
if (!result.done) return [3 /*break*/,
|
|
183
|
+
if (!(result.done || !this.config.isPostEnforceEnabled)) return [3 /*break*/, 6];
|
|
152
184
|
return [4 /*yield*/, this.endEnforcerFlow.execute(context)];
|
|
153
|
-
case
|
|
185
|
+
case 5:
|
|
154
186
|
_a.sent();
|
|
155
187
|
return [2 /*return*/, result.response ? this.convertToRes.apply(this, __spreadArray([result.response], args, false)) : null];
|
|
156
|
-
case
|
|
188
|
+
case 6:
|
|
189
|
+
if (!this.config.isPostEnforceEnabled) return [3 /*break*/, 8];
|
|
190
|
+
return [4 /*yield*/, this.preserveContext.apply(this, __spreadArray([context], args, false))];
|
|
191
|
+
case 7:
|
|
192
|
+
_a.sent();
|
|
193
|
+
_a.label = 8;
|
|
194
|
+
case 8: return [2 /*return*/, null];
|
|
157
195
|
}
|
|
158
196
|
});
|
|
159
197
|
});
|
|
@@ -170,11 +208,12 @@ var EnforcerBase = /** @class */ (function () {
|
|
|
170
208
|
}
|
|
171
209
|
return __awaiter(this, void 0, void 0, function () {
|
|
172
210
|
var context, _a, e_2;
|
|
173
|
-
|
|
174
|
-
|
|
211
|
+
var _b;
|
|
212
|
+
return __generator(this, function (_c) {
|
|
213
|
+
switch (_c.label) {
|
|
175
214
|
case 0:
|
|
176
|
-
|
|
177
|
-
if (!this.config.moduleEnabled) {
|
|
215
|
+
_c.trys.push([0, 5, , 6]);
|
|
216
|
+
if (!this.config.moduleEnabled || !this.config.isPostEnforceEnabled) {
|
|
178
217
|
return [2 /*return*/];
|
|
179
218
|
}
|
|
180
219
|
context = this.retrieveContext.apply(this, args);
|
|
@@ -182,17 +221,17 @@ var EnforcerBase = /** @class */ (function () {
|
|
|
182
221
|
_a = context;
|
|
183
222
|
return [4 /*yield*/, this.convertToOutgoingResponse.apply(this, args)];
|
|
184
223
|
case 1:
|
|
185
|
-
_a.response =
|
|
186
|
-
return [4 /*yield*/, this.postEnforceFlow.execute(context)];
|
|
224
|
+
_a.response = _c.sent();
|
|
225
|
+
return [4 /*yield*/, ((_b = this.postEnforceFlow) === null || _b === void 0 ? void 0 : _b.execute(context))];
|
|
187
226
|
case 2:
|
|
188
|
-
|
|
227
|
+
_c.sent();
|
|
189
228
|
return [4 /*yield*/, this.endEnforcerFlow.execute(context)];
|
|
190
229
|
case 3:
|
|
191
|
-
|
|
192
|
-
|
|
230
|
+
_c.sent();
|
|
231
|
+
_c.label = 4;
|
|
193
232
|
case 4: return [3 /*break*/, 6];
|
|
194
233
|
case 5:
|
|
195
|
-
e_2 =
|
|
234
|
+
e_2 = _c.sent();
|
|
196
235
|
(context || this.config).logger.error("caught error in post enforce - ".concat(e_2));
|
|
197
236
|
return [3 /*break*/, 6];
|
|
198
237
|
case 6: return [2 /*return*/];
|
|
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./IEnforcer.js"), exports);
|
|
18
|
+
__exportStar(require("./IPostEnforcer.js"), exports);
|
|
18
19
|
__exportStar(require("./EnforcerBase.js"), exports);
|
|
19
20
|
__exportStar(require("./EnforcerOptions.js"), exports);
|
|
20
21
|
__exportStar(require("./utils.js"), exports);
|
|
@@ -16,21 +16,25 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
16
16
|
})();
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.EndEnforcerFlow = void 0;
|
|
19
|
-
var
|
|
19
|
+
var phase_1 = require("../phase/index.js");
|
|
20
|
+
var Flow_1 = require("./Flow.js");
|
|
20
21
|
var EndEnforcerFlow = /** @class */ (function (_super) {
|
|
21
22
|
__extends(EndEnforcerFlow, _super);
|
|
22
23
|
function EndEnforcerFlow(config, _a) {
|
|
23
|
-
var logServiceClient = _a.logServiceClient, telemetry = _a.telemetry, remoteConfigManager = _a.remoteConfigManager;
|
|
24
|
-
var phases = [
|
|
24
|
+
var logServiceClient = _a.logServiceClient, telemetry = _a.telemetry, remoteConfigManager = _a.remoteConfigManager, activityClient = _a.activityClient;
|
|
25
|
+
var phases = [
|
|
26
|
+
new phase_1.SendAsyncActivitiesPhase(activityClient),
|
|
27
|
+
new phase_1.SendTelemetryActivityPhase(telemetry),
|
|
28
|
+
];
|
|
25
29
|
if (remoteConfigManager) {
|
|
26
|
-
phases.push(new
|
|
30
|
+
phases.push(new phase_1.UpdateRemoteConfigPhase(config, remoteConfigManager));
|
|
27
31
|
}
|
|
28
32
|
if (logServiceClient) {
|
|
29
|
-
phases.push(new
|
|
33
|
+
phases.push(new phase_1.SendLogsPhase(config, logServiceClient));
|
|
30
34
|
}
|
|
31
|
-
phases.push(new
|
|
35
|
+
phases.push(new phase_1.ClearLogsPhase());
|
|
32
36
|
return _super.call(this, phases) || this;
|
|
33
37
|
}
|
|
34
38
|
return EndEnforcerFlow;
|
|
35
|
-
}(
|
|
39
|
+
}(Flow_1.Flow));
|
|
36
40
|
exports.EndEnforcerFlow = EndEnforcerFlow;
|
|
@@ -16,26 +16,21 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
16
16
|
})();
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.EnforceFlow = void 0;
|
|
19
|
-
var
|
|
20
|
-
var
|
|
19
|
+
var phase_1 = require("../phase/index.js");
|
|
20
|
+
var Flow_1 = require("./Flow.js");
|
|
21
21
|
var EnforceFlow = /** @class */ (function (_super) {
|
|
22
22
|
__extends(EnforceFlow, _super);
|
|
23
23
|
function EnforceFlow(config, _a) {
|
|
24
|
-
var
|
|
25
|
-
var dataEnrichment = _a.dataEnrichment, tokenParser = _a.tokenParser, riskApiClient = _a.riskApiClient, activityClient = _a.activityClient, cors = _a.cors, products = _a.products, graphQLParser = _a.graphQLParser;
|
|
24
|
+
var dataEnrichment = _a.dataEnrichment, tokenParser = _a.tokenParser, riskApiClient = _a.riskApiClient, cors = _a.cors, products = _a.products, graphQLParser = _a.graphQLParser;
|
|
26
25
|
return _super.call(this, [
|
|
27
|
-
new
|
|
28
|
-
new
|
|
29
|
-
new
|
|
30
|
-
new
|
|
31
|
-
new
|
|
32
|
-
new
|
|
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),
|
|
36
|
-
new impl_1.ModifyIncomingRequestPhase(Object.values(products)),
|
|
26
|
+
new phase_1.ParseTokenPhase(tokenParser),
|
|
27
|
+
new phase_1.EnrichContextFromRequestPhase(config, products, dataEnrichment, graphQLParser),
|
|
28
|
+
new phase_1.RiskApiPhase(products, riskApiClient),
|
|
29
|
+
new phase_1.AdditionalActivityHandlerPhase(config),
|
|
30
|
+
new phase_1.CreateBlockResponsePhase(config, phase_1.CreateBlockResponsePhase.getBlockers(products), cors),
|
|
31
|
+
new phase_1.ModifyIncomingRequestPhase(Object.values(products)),
|
|
37
32
|
]) || this;
|
|
38
33
|
}
|
|
39
34
|
return EnforceFlow;
|
|
40
|
-
}(
|
|
35
|
+
}(Flow_1.Flow));
|
|
41
36
|
exports.EnforceFlow = EnforceFlow;
|
|
@@ -16,9 +16,10 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
16
16
|
})();
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.FilterFlow = void 0;
|
|
19
|
-
var products_1 = require("
|
|
20
|
-
var utils_1 = require("
|
|
21
|
-
var
|
|
19
|
+
var products_1 = require("../products/index.js");
|
|
20
|
+
var utils_1 = require("../utils/index.js");
|
|
21
|
+
var phase_1 = require("../phase/index.js");
|
|
22
|
+
var Flow_1 = require("./Flow.js");
|
|
22
23
|
var FilterFlow = /** @class */ (function (_super) {
|
|
23
24
|
__extends(FilterFlow, _super);
|
|
24
25
|
function FilterFlow(config, _a) {
|
|
@@ -26,16 +27,16 @@ var FilterFlow = /** @class */ (function (_super) {
|
|
|
26
27
|
var phases = [];
|
|
27
28
|
var firstPartyProducts = FilterFlow.getFirstPartyProducts(products);
|
|
28
29
|
if ((firstPartyProducts === null || firstPartyProducts === void 0 ? void 0 : firstPartyProducts.length) > 0) {
|
|
29
|
-
phases.push(new
|
|
30
|
+
phases.push(new phase_1.FirstPartyPhase(config, httpClient, firstPartyProducts));
|
|
30
31
|
}
|
|
31
32
|
var filterProducts = FilterFlow.getFilterProducts(products);
|
|
32
33
|
if ((filterProducts === null || filterProducts === void 0 ? void 0 : filterProducts.length) > 0) {
|
|
33
|
-
phases.push(new
|
|
34
|
+
phases.push(new phase_1.FilterPhase(filterProducts));
|
|
34
35
|
}
|
|
35
|
-
phases.push(new
|
|
36
|
-
phases.push(new
|
|
36
|
+
phases.push(new phase_1.PreflightPhase(config, cors));
|
|
37
|
+
phases.push(new phase_1.IdentifyTelemetryRequestPhase(telemetry));
|
|
37
38
|
if (remoteConfigUpdateParser) {
|
|
38
|
-
phases.push(new
|
|
39
|
+
phases.push(new phase_1.IdentifyRemoteConfigNotifyRequestPhase(remoteConfigUpdateParser));
|
|
39
40
|
}
|
|
40
41
|
return _super.call(this, phases) || this;
|
|
41
42
|
}
|
|
@@ -46,5 +47,5 @@ var FilterFlow = /** @class */ (function (_super) {
|
|
|
46
47
|
return [products[products_1.ProductName.BOT_DEFENDER]].filter(function (prod) { return !(0, utils_1.isNullOrUndefined)(prod); });
|
|
47
48
|
};
|
|
48
49
|
return FilterFlow;
|
|
49
|
-
}(
|
|
50
|
+
}(Flow_1.Flow));
|
|
50
51
|
exports.FilterFlow = FilterFlow;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Flow = void 0;
|
|
4
|
+
var phase_1 = require("../phase/index.js");
|
|
5
|
+
var Flow = /** @class */ (function () {
|
|
6
|
+
function Flow(phases) {
|
|
7
|
+
this.phases = phases;
|
|
8
|
+
}
|
|
9
|
+
Flow.prototype.insert = function (phase, options) {
|
|
10
|
+
if (!options) {
|
|
11
|
+
this.phases.push(phase);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (options.before) {
|
|
15
|
+
var index = this.getIndexOfPhase(options.before);
|
|
16
|
+
if (index === -1) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
this.phases.splice(index, 0, phase);
|
|
20
|
+
}
|
|
21
|
+
if (options.after) {
|
|
22
|
+
var index = this.getIndexOfPhase(options.after);
|
|
23
|
+
if (index === -1) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
this.phases.splice(index + 1, 0, phase);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
Flow.prototype.remove = function (name) {
|
|
30
|
+
var index = this.getIndexOfPhase(name);
|
|
31
|
+
if (index === -1) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
this.phases.splice(index, 1);
|
|
35
|
+
};
|
|
36
|
+
Flow.prototype.replace = function (name, phase) {
|
|
37
|
+
var index = this.getIndexOfPhase(name);
|
|
38
|
+
if (index === -1) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
this.phases.splice(index, 1, phase);
|
|
42
|
+
};
|
|
43
|
+
Flow.prototype.move = function (name, to) {
|
|
44
|
+
var index = this.getIndexOfPhase(name);
|
|
45
|
+
if (index === -1) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
var phase = this.phases[index];
|
|
49
|
+
this.phases.splice(index, 1);
|
|
50
|
+
this.insert(phase, to);
|
|
51
|
+
};
|
|
52
|
+
Flow.prototype.getIndexOfPhase = function (name) {
|
|
53
|
+
return this.phases.findIndex(function (existingPhase) { return existingPhase.constructor.name === name; });
|
|
54
|
+
};
|
|
55
|
+
Flow.prototype.execute = function (context) {
|
|
56
|
+
return new phase_1.CompositePhase(this.phases).execute(context);
|
|
57
|
+
};
|
|
58
|
+
return Flow;
|
|
59
|
+
}());
|
|
60
|
+
exports.Flow = Flow;
|
|
@@ -16,17 +16,17 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
16
16
|
})();
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.PostEnforceFlow = void 0;
|
|
19
|
-
var
|
|
19
|
+
var phase_1 = require("../phase/index.js");
|
|
20
|
+
var Flow_1 = require("./Flow.js");
|
|
20
21
|
var PostEnforceFlow = /** @class */ (function (_super) {
|
|
21
22
|
__extends(PostEnforceFlow, _super);
|
|
22
23
|
function PostEnforceFlow(config, _a) {
|
|
23
|
-
var products = _a.products,
|
|
24
|
+
var products = _a.products, snippetRetriever = _a.snippetRetriever, snippetInjector = _a.snippetInjector;
|
|
24
25
|
return _super.call(this, [
|
|
25
|
-
new
|
|
26
|
-
new
|
|
27
|
-
new impl_1.SendAsyncActivitiesOnResponsePhase(activityClient),
|
|
26
|
+
new phase_1.EnrichContextFromResponsePhase(config, products),
|
|
27
|
+
new phase_1.ModifyOutgoingResponsePhase(config, Object.values(products), snippetRetriever, snippetInjector),
|
|
28
28
|
]) || this;
|
|
29
29
|
}
|
|
30
30
|
return PostEnforceFlow;
|
|
31
|
-
}(
|
|
31
|
+
}(Flow_1.Flow));
|
|
32
32
|
exports.PostEnforceFlow = PostEnforceFlow;
|
|
@@ -18,3 +18,5 @@ __exportStar(require("./FilterFlow.js"), exports);
|
|
|
18
18
|
__exportStar(require("./EnforceFlow.js"), exports);
|
|
19
19
|
__exportStar(require("./PostEnforceFlow.js"), exports);
|
|
20
20
|
__exportStar(require("./EndEnforcerFlow.js"), exports);
|
|
21
|
+
__exportStar(require("./IFlow.js"), exports);
|
|
22
|
+
__exportStar(require("./Flow.js"), exports);
|
package/lib/cjs/index.js
CHANGED
|
@@ -25,6 +25,7 @@ __exportStar(require("./sensitive_request/index.js"), exports);
|
|
|
25
25
|
__exportStar(require("./monitored_request/index.js"), exports);
|
|
26
26
|
__exportStar(require("./snippet_injection/index.js"), exports);
|
|
27
27
|
__exportStar(require("./cors/index.js"), exports);
|
|
28
|
+
__exportStar(require("./flow/index.js"), exports);
|
|
28
29
|
__exportStar(require("./enforcer/index.js"), exports);
|
|
29
30
|
__exportStar(require("./filter/index.js"), exports);
|
|
30
31
|
__exportStar(require("./first_party/index.js"), exports);
|
|
@@ -38,6 +38,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.AdditionalActivityHandlerPhase = void 0;
|
|
40
40
|
var additional_activity_handler_1 = require("../../additional_activity_handler/index.js");
|
|
41
|
+
/**
|
|
42
|
+
* The `AdditionalActivityHandlerPhase` invokes the additional activity handler defined in the configuration.
|
|
43
|
+
*/
|
|
41
44
|
var AdditionalActivityHandlerPhase = /** @class */ (function () {
|
|
42
45
|
function AdditionalActivityHandlerPhase(config) {
|
|
43
46
|
this.config = config;
|
|
@@ -37,6 +37,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.ClearLogsPhase = void 0;
|
|
40
|
+
/**
|
|
41
|
+
* The `ClearLogsPhase` class deletes the context logs to free up memory.
|
|
42
|
+
*/
|
|
40
43
|
var ClearLogsPhase = /** @class */ (function () {
|
|
41
44
|
function ClearLogsPhase() {
|
|
42
45
|
}
|
|
@@ -37,7 +37,16 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.CompositePhase = void 0;
|
|
40
|
+
/**
|
|
41
|
+
* The `CompositePhase` class executes a series of phases in sequence.
|
|
42
|
+
* It will stop executing phases as soon as one of them returns a result with `done: true`.
|
|
43
|
+
* It will return the result of the last phase executed or `{ done: false }`.
|
|
44
|
+
*/
|
|
40
45
|
var CompositePhase = /** @class */ (function () {
|
|
46
|
+
/**
|
|
47
|
+
* Creates a new CompositePhase instance.
|
|
48
|
+
* @param phases - An array of phases to be executed in sequence.
|
|
49
|
+
*/
|
|
41
50
|
function CompositePhase(phases) {
|
|
42
51
|
this.phases = phases;
|
|
43
52
|
}
|
|
@@ -41,6 +41,10 @@ var http_1 = require("../../http/index.js");
|
|
|
41
41
|
var pxhd_1 = require("../../pxhd/index.js");
|
|
42
42
|
var action_1 = require("../../action/index.js");
|
|
43
43
|
var products_1 = require("../../products/index.js");
|
|
44
|
+
/**
|
|
45
|
+
* `CreateBlockResponsePhase` is a phase that creates a block response for the product that recommended a block action.
|
|
46
|
+
* If multiple products recommended block, it will return the block response for the highest priority product.
|
|
47
|
+
*/
|
|
44
48
|
var CreateBlockResponsePhase = /** @class */ (function () {
|
|
45
49
|
function CreateBlockResponsePhase(config, blockers, cors) {
|
|
46
50
|
this.config = config;
|
|
@@ -49,6 +53,18 @@ var CreateBlockResponsePhase = /** @class */ (function () {
|
|
|
49
53
|
this.cors = cors;
|
|
50
54
|
}
|
|
51
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* A static method that identifies those products that can block incoming requests and returns a map of the product name to the product instance.
|
|
58
|
+
* @param products - All supported products.
|
|
59
|
+
* @returns A mapping of those products that implement the `IConditionalBlocker` interface.
|
|
60
|
+
*/
|
|
61
|
+
CreateBlockResponsePhase.getBlockers = function (products) {
|
|
62
|
+
var _a;
|
|
63
|
+
return _a = {},
|
|
64
|
+
_a[products_1.ProductName.BOT_DEFENDER] = products[products_1.ProductName.BOT_DEFENDER],
|
|
65
|
+
_a[products_1.ProductName.HYPE_SALE_CHALLENGE] = products[products_1.ProductName.HYPE_SALE_CHALLENGE],
|
|
66
|
+
_a;
|
|
67
|
+
};
|
|
52
68
|
CreateBlockResponsePhase.prototype.execute = function (context) {
|
|
53
69
|
return __awaiter(this, void 0, void 0, function () {
|
|
54
70
|
var response;
|
|
@@ -40,9 +40,20 @@ exports.DecideActionPhase = void 0;
|
|
|
40
40
|
var logger_1 = require("../../logger/index.js");
|
|
41
41
|
var action_1 = require("../../action/index.js");
|
|
42
42
|
var blocker_1 = require("../../blocker/index.js");
|
|
43
|
+
/**
|
|
44
|
+
* `DecideActionPhase` is an abstract class that provides the protected function `updateContextDecision`.
|
|
45
|
+
* Phases that extend this class can use the `updateContextDecision` method to update the `context.action` and
|
|
46
|
+
* `context.reasons` properties based on the product data in the context. Calling this function essentially
|
|
47
|
+
* recalculates what action the enforcer should take and why.
|
|
48
|
+
*/
|
|
43
49
|
var DecideActionPhase = /** @class */ (function () {
|
|
44
50
|
function DecideActionPhase() {
|
|
45
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Updates the `action`, `reasons`, and `blockAction` properties based on the product data in the context.
|
|
54
|
+
* @param context - The request context.
|
|
55
|
+
* @protected
|
|
56
|
+
*/
|
|
46
57
|
DecideActionPhase.prototype.updateContextDecision = function (context) {
|
|
47
58
|
return __awaiter(this, void 0, void 0, function () {
|
|
48
59
|
var _a, action, reasons, productReasons;
|
|
@@ -54,6 +54,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
54
54
|
exports.EnrichContextFromRequestPhase = void 0;
|
|
55
55
|
var custom_parameters_1 = require("../../custom_parameters/index.js");
|
|
56
56
|
var DecideActionPhase_1 = require("./DecideActionPhase.js");
|
|
57
|
+
/**
|
|
58
|
+
* `EnrichContextFromRequestPhase` adds data to the context from the request. This includes parsing the data enrichment cookie,
|
|
59
|
+
* adding GraphQL data, custom parameters, and enriching the context with any product-specific data by calling each product's
|
|
60
|
+
* `enrichContextFromRequest` method. (As an example, this is where the Credential Intelligence product enriches the context by
|
|
61
|
+
* extracting login credentials and adding them to the product data of the request.) It then updates the context's final action
|
|
62
|
+
* and reasons based on the enriched data.
|
|
63
|
+
*
|
|
64
|
+
* Note: This phase should come after the `ParseTokenPhase`, since the Bot Defender product uses the parsed token to determine its recommended action.
|
|
65
|
+
*/
|
|
57
66
|
var EnrichContextFromRequestPhase = /** @class */ (function (_super) {
|
|
58
67
|
__extends(EnrichContextFromRequestPhase, _super);
|
|
59
68
|
function EnrichContextFromRequestPhase(config, products, dataEnrichment, graphQLParser) {
|
|
@@ -131,18 +140,13 @@ var EnrichContextFromRequestPhase = /** @class */ (function (_super) {
|
|
|
131
140
|
return __generator(this, function (_a) {
|
|
132
141
|
switch (_a.label) {
|
|
133
142
|
case 0: return [4 /*yield*/, Promise.all(Object.entries(this.products).map(function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
|
|
134
|
-
var _c, _d;
|
|
135
143
|
var name = _b[0], product = _b[1];
|
|
136
|
-
return __generator(this, function (
|
|
137
|
-
switch (
|
|
138
|
-
case 0:
|
|
139
|
-
// @ts-ignore
|
|
140
|
-
_c = context.productData;
|
|
141
|
-
_d = name;
|
|
142
|
-
return [4 /*yield*/, (product === null || product === void 0 ? void 0 : product.enrichContextFromRequest(context))];
|
|
144
|
+
return __generator(this, function (_c) {
|
|
145
|
+
switch (_c.label) {
|
|
146
|
+
case 0: return [4 /*yield*/, (product === null || product === void 0 ? void 0 : product.enrichContextFromRequest(context))];
|
|
143
147
|
case 1:
|
|
144
148
|
// @ts-ignore
|
|
145
|
-
|
|
149
|
+
context.productData[name] = _c.sent();
|
|
146
150
|
return [2 /*return*/];
|
|
147
151
|
}
|
|
148
152
|
});
|
|
@@ -38,6 +38,10 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.EnrichContextFromResponsePhase = void 0;
|
|
40
40
|
var utils_1 = require("../../utils/index.js");
|
|
41
|
+
/**
|
|
42
|
+
* `EnrichContextFromResponsePhase` enriches the context with response data. Each product's `enrichContextFromResponse`
|
|
43
|
+
* method is called since every product may use the response data differently.
|
|
44
|
+
*/
|
|
41
45
|
var EnrichContextFromResponsePhase = /** @class */ (function () {
|
|
42
46
|
function EnrichContextFromResponsePhase(config, products) {
|
|
43
47
|
this.config = config;
|
|
@@ -37,6 +37,10 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.FilterPhase = void 0;
|
|
40
|
+
/**
|
|
41
|
+
* The `FilterPhase` class checks if the provided filters indicate that the incoming HTTP request should be filtered from the flow.
|
|
42
|
+
* If any filter returns `true` for `shouldFilter`, the phase will stop further processing and return a `done` status.
|
|
43
|
+
*/
|
|
40
44
|
var FilterPhase = /** @class */ (function () {
|
|
41
45
|
function FilterPhase(filters) {
|
|
42
46
|
this.filters = filters;
|
|
@@ -38,6 +38,11 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.FirstPartyPhase = void 0;
|
|
40
40
|
var http_1 = require("../../http/index.js");
|
|
41
|
+
/**
|
|
42
|
+
* The `FirstPartyPhase` class is responsible for handling first-party requests. If a first-party request is detected,
|
|
43
|
+
* it will create the `FirstPartyData`, send the request to the configured endpoint using the provided HTTP client, and return
|
|
44
|
+
* a done status with the response. If an error occurs, it will return the default response.
|
|
45
|
+
*/
|
|
41
46
|
var FirstPartyPhase = /** @class */ (function () {
|
|
42
47
|
function FirstPartyPhase(config, httpClient, firstParties) {
|
|
43
48
|
this.config = config;
|
|
@@ -38,6 +38,11 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.IdentifyRemoteConfigNotifyRequestPhase = void 0;
|
|
40
40
|
var http_1 = require("../../http/index.js");
|
|
41
|
+
/**
|
|
42
|
+
* The `IdentifyRemoteConfigNotifyRequestPhase` class is responsible for identifying incoming remote config update requests.
|
|
43
|
+
* It checks if the request is a remote config update request and, if so, parses the request and updates the context accordingly.
|
|
44
|
+
* Note that the remote config is not updated during this phase; that occurs in the `UpdateRemoteConfigPhase`.
|
|
45
|
+
*/
|
|
41
46
|
var IdentifyRemoteConfigNotifyRequestPhase = /** @class */ (function () {
|
|
42
47
|
function IdentifyRemoteConfigNotifyRequestPhase(remoteConfigUpdateParser) {
|
|
43
48
|
this.remoteConfigUpdateParser = remoteConfigUpdateParser;
|
|
@@ -37,6 +37,11 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.IdentifyTelemetryRequestPhase = void 0;
|
|
40
|
+
/**
|
|
41
|
+
* The `IdentifyTelemetryRequestPhase` class is responsible for identifying incoming telemetry requests.
|
|
42
|
+
* It checks if the request is a telemetry request and, if so, parses the request and updates the context accordingly.
|
|
43
|
+
* Note that the telemetry activity is not sent during this phase; that occurs in the `SendTelemetryActivityPhase`.
|
|
44
|
+
*/
|
|
40
45
|
var IdentifyTelemetryRequestPhase = /** @class */ (function () {
|
|
41
46
|
function IdentifyTelemetryRequestPhase(telemetry) {
|
|
42
47
|
this.telemetry = telemetry;
|
|
@@ -37,6 +37,11 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.ModifyIncomingRequestPhase = void 0;
|
|
40
|
+
/**
|
|
41
|
+
* The `ModifyIncomingRequestPhase` class is responsible for modifying the incoming HTTP request prior to forwarding the
|
|
42
|
+
* request to the origin server or cache. This phase invokes each product's `modifyIncomingRequest` method. (As an example,
|
|
43
|
+
* this is where the Credential Intelligence product adds the compromised credentials header to the request if needed.)
|
|
44
|
+
*/
|
|
40
45
|
var ModifyIncomingRequestPhase = /** @class */ (function () {
|
|
41
46
|
function ModifyIncomingRequestPhase(products) {
|
|
42
47
|
this.products = products;
|
|
@@ -39,6 +39,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
exports.ModifyOutgoingResponsePhase = void 0;
|
|
40
40
|
var pxhd_1 = require("../../pxhd/index.js");
|
|
41
41
|
var http_1 = require("../../http/index.js");
|
|
42
|
+
/**
|
|
43
|
+
* The `ModifyOutgoingResponsePhase` class is responsible for modifying the outgoing HTTP response prior to returning it
|
|
44
|
+
* to the end user. This phase invokes each product's `modifyOutgoingResponse` method, as well as adding the PXHD cookie.
|
|
45
|
+
* If snippet injection is supported and enabled, it also occurs in this phase.
|
|
46
|
+
*/
|
|
42
47
|
var ModifyOutgoingResponsePhase = /** @class */ (function () {
|
|
43
48
|
function ModifyOutgoingResponsePhase(config, products, snippetRetriever, snippetInjector) {
|
|
44
49
|
this.config = config;
|
|
@@ -39,6 +39,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
exports.ParseTokenPhase = void 0;
|
|
40
40
|
var risk_token_1 = require("../../risk_token/index.js");
|
|
41
41
|
var utils_1 = require("../../utils/index.js");
|
|
42
|
+
/**
|
|
43
|
+
* The `ParseTokenPhase` class is responsible for parsing the risk token from the incoming request and updating the context.
|
|
44
|
+
*/
|
|
42
45
|
var ParseTokenPhase = /** @class */ (function () {
|
|
43
46
|
function ParseTokenPhase(tokenParser) {
|
|
44
47
|
this.tokenParser = tokenParser;
|
|
@@ -59,14 +62,18 @@ var ParseTokenPhase = /** @class */ (function () {
|
|
|
59
62
|
};
|
|
60
63
|
ParseTokenPhase.prototype.addTokenDataToContext = function (context, tokenData) {
|
|
61
64
|
Object.assign(context.tokenData, tokenData);
|
|
62
|
-
if (tokenData.tokenParseResult === risk_token_1.TokenParseResult.SUCCESSFUL) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
action
|
|
68
|
-
}
|
|
65
|
+
if (tokenData.tokenParseResult === risk_token_1.TokenParseResult.SUCCESSFUL && tokenData.token) {
|
|
66
|
+
if (tokenData.token.score != null) {
|
|
67
|
+
context.score = tokenData.token.score;
|
|
68
|
+
}
|
|
69
|
+
if (tokenData.token.action) {
|
|
70
|
+
context.blockAction = tokenData.token.action;
|
|
71
|
+
}
|
|
72
|
+
if (tokenData.token.uuid) {
|
|
73
|
+
context.uuid = tokenData.token.uuid;
|
|
74
|
+
}
|
|
69
75
|
if (tokenData.token.vid) {
|
|
76
|
+
context.vid = tokenData.token.vid;
|
|
70
77
|
context.vidSource = utils_1.VidSource.RISK_COOKIE;
|
|
71
78
|
}
|
|
72
79
|
}
|
|
@@ -37,6 +37,10 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.PreflightPhase = void 0;
|
|
40
|
+
/**
|
|
41
|
+
* The `PreflightPhase` class is responsible for handling preflight requests in CORS (Cross-Origin Resource Sharing).
|
|
42
|
+
* This includes filtering preflight requests or invoking the preflight custom handler if configured.
|
|
43
|
+
*/
|
|
40
44
|
var PreflightPhase = /** @class */ (function () {
|
|
41
45
|
function PreflightPhase(config, cors) {
|
|
42
46
|
this.corsSupportEnabled = config.corsSupportEnabled;
|