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
|
@@ -4,24 +4,80 @@ import { IHttpClient } from '../http';
|
|
|
4
4
|
import { IActivityClient } from './IActivityClient';
|
|
5
5
|
import { AsyncActivity } from './model';
|
|
6
6
|
import { ILogger } from '../logger';
|
|
7
|
+
/**
|
|
8
|
+
* The HttpActivityClient is responsible for sending async activities to the backend via HTTP.
|
|
9
|
+
*/
|
|
7
10
|
export declare class HttpActivityClient<Req, Res, Added, Removed> implements IActivityClient<Req, Res> {
|
|
8
11
|
protected readonly config: IConfiguration<Req, Res, Added, Removed>;
|
|
9
12
|
protected readonly httpClient: IHttpClient;
|
|
13
|
+
/**
|
|
14
|
+
* Creates an instance of HttpActivityClient.
|
|
15
|
+
* @param config
|
|
16
|
+
* @param httpClient
|
|
17
|
+
*/
|
|
10
18
|
constructor(config: IConfiguration<Req, Res, Added, Removed>, httpClient: IHttpClient);
|
|
19
|
+
/**
|
|
20
|
+
* Creates and sends all necessary async activities to the backend.
|
|
21
|
+
* @param context - The context containing the request (and possibly response).
|
|
22
|
+
* @returns {Promise<boolean>} - A boolean indicating if the activities were sent successfully.
|
|
23
|
+
*/
|
|
11
24
|
sendActivities(context: ReadonlyContext<Req, Res>): Promise<boolean>;
|
|
25
|
+
/**
|
|
26
|
+
* Creates all async activities (block, page_requested, additional_s2s) that should be sent based on the context.
|
|
27
|
+
* @param context - The context containing the request (and possibly response).
|
|
28
|
+
* @returns {AsyncActivity[]} - An array of async activities to be sent.
|
|
29
|
+
* @protected
|
|
30
|
+
*/
|
|
12
31
|
protected createActivities(context: ReadonlyContext<Req, Res>): AsyncActivity[];
|
|
32
|
+
/**
|
|
33
|
+
* Whether to create a block activity based on the context.
|
|
34
|
+
* @param context
|
|
35
|
+
* @protected
|
|
36
|
+
*/
|
|
13
37
|
protected shouldCreateBlockActivity(context: ReadonlyContext<Req, Res>): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Whether to create a page_requested activity based on the context.
|
|
40
|
+
* @param context
|
|
41
|
+
* @protected
|
|
42
|
+
*/
|
|
14
43
|
protected shouldCreatePageRequestedActivity(context: ReadonlyContext<Req, Res>): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Whether to create an additional_s2s activity based on the context.
|
|
46
|
+
* @param context
|
|
47
|
+
* @protected
|
|
48
|
+
*/
|
|
15
49
|
protected shouldCreateAdditionalS2SActivity(context: ReadonlyContext<Req, Res>): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Creates a block activity based on the context.
|
|
52
|
+
* @param context
|
|
53
|
+
* @protected
|
|
54
|
+
*/
|
|
16
55
|
protected createBlockActivity(context: ReadonlyContext<Req, Res>): AsyncActivity;
|
|
56
|
+
/**
|
|
57
|
+
* Creates a page_requested activity based on the context.
|
|
58
|
+
* @param context
|
|
59
|
+
* @protected
|
|
60
|
+
*/
|
|
17
61
|
protected createPageRequestedActivity(context: ReadonlyContext<Req, Res>): AsyncActivity;
|
|
62
|
+
/**
|
|
63
|
+
* Creates an additional_s2s activity based on the context.
|
|
64
|
+
* @param context
|
|
65
|
+
* @protected
|
|
66
|
+
*/
|
|
18
67
|
protected createAdditionalS2SActivity(context: ReadonlyContext<Req, Res>): AsyncActivity;
|
|
19
68
|
/**
|
|
20
|
-
* Allows for expansions or alterations to
|
|
69
|
+
* Allows for expansions or alterations to an async activity if needed. This applies to all created async activities.
|
|
21
70
|
* @param activity
|
|
22
71
|
* @returns AsyncActivity
|
|
23
72
|
* @protected
|
|
24
73
|
*/
|
|
25
74
|
protected finalizeActivity(activity: AsyncActivity): AsyncActivity;
|
|
75
|
+
/**
|
|
76
|
+
* Sends the async activities to the backend.
|
|
77
|
+
* @param activities - The activities to be sent.
|
|
78
|
+
* @param logger - The logger instance for logging.
|
|
79
|
+
* @returns {Promise<boolean>} - A boolean indicating if the activities were sent successfully.
|
|
80
|
+
* @protected
|
|
81
|
+
*/
|
|
26
82
|
protected postActivities(activities: AsyncActivity[], logger: ILogger): Promise<boolean>;
|
|
27
83
|
}
|
|
@@ -3,6 +3,13 @@ import { IConfiguration } from '../config';
|
|
|
3
3
|
import { AsyncActivity } from './model';
|
|
4
4
|
import { IHttpClient } from '../http';
|
|
5
5
|
import { ILogger } from '../logger';
|
|
6
|
+
/**
|
|
7
|
+
* The HttpBatchedActivityClient is responsible for sending async activities to the backend via HTTP in batches.
|
|
8
|
+
* It extends the HttpActivityClient class and adds functionality for batching activities.
|
|
9
|
+
*
|
|
10
|
+
* This class uses setTimeout and clearTimeout for managing the timeout for sending activities. It also exposes the stop()
|
|
11
|
+
* method to stop the timer and prevent further activity sending, which should be called on shutdown.
|
|
12
|
+
*/
|
|
6
13
|
export declare class HttpBatchedActivityClient<Req, Res, Added, Removed> extends HttpActivityClient<Req, Res, Added, Removed> {
|
|
7
14
|
private readonly batchSize;
|
|
8
15
|
private readonly timeoutMs;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { AsyncOrSync } from 'ts-essentials';
|
|
2
2
|
import { ReadonlyContext } from '../context';
|
|
3
|
+
/**
|
|
4
|
+
* Interface for an activity client that sends asynchronous activities to the HUMAN server.
|
|
5
|
+
*/
|
|
3
6
|
export interface IActivityClient<Req, Res> {
|
|
4
7
|
/**
|
|
5
8
|
* @param context - The request context.
|
|
6
|
-
* @returns
|
|
9
|
+
* @returns AsyncOrSync<boolean> - Whether sending the activities was successful or not.
|
|
7
10
|
*/
|
|
8
11
|
sendActivities(context: ReadonlyContext<Req, Res>): AsyncOrSync<boolean>;
|
|
9
12
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { ActivityType } from '../ActivityType';
|
|
2
2
|
import { AsyncActivityDetails } from './AsyncActivityDetails';
|
|
3
3
|
import { HeaderEntry } from './HeaderEntry';
|
|
4
|
+
/**
|
|
5
|
+
* The complete contents of an asynchronous activity payload.
|
|
6
|
+
*/
|
|
4
7
|
export type AsyncActivity = {
|
|
5
8
|
type: ActivityType;
|
|
6
9
|
timestamp: number;
|
|
@@ -2,6 +2,9 @@ import { BlockAction } from '../../blocker';
|
|
|
2
2
|
import { CommonActivityDetails } from './CommonActivityDetails';
|
|
3
3
|
import { RiskAdditionalData } from '../../risk_api';
|
|
4
4
|
export type AsyncActivityDetails = ActivityTypeDetails & AsyncActivityCommonDetails & CommonActivityDetails;
|
|
5
|
+
/**
|
|
6
|
+
* Activity details that should be included in all async activities.
|
|
7
|
+
*/
|
|
5
8
|
export type AsyncActivityCommonDetails = Partial<RiskAdditionalData> & {
|
|
6
9
|
client_uuid?: string;
|
|
7
10
|
risk_rtt?: number;
|
|
@@ -10,18 +13,27 @@ export type AsyncActivityCommonDetails = Partial<RiskAdditionalData> & {
|
|
|
10
13
|
credentials_compromised?: boolean;
|
|
11
14
|
};
|
|
12
15
|
export type ActivityTypeDetails = PageRequestedActivityDetails | BlockActivityDetails | AdditionalS2SActivityDetails;
|
|
16
|
+
/**
|
|
17
|
+
* Activity details that should be included in page_requested activities.
|
|
18
|
+
*/
|
|
13
19
|
export type PageRequestedActivityDetails = {
|
|
14
20
|
pass_reason: string;
|
|
15
21
|
error_message?: string;
|
|
16
22
|
s2s_error_reason?: string;
|
|
17
23
|
s2s_error_http_status?: number;
|
|
18
24
|
};
|
|
25
|
+
/**
|
|
26
|
+
* Activity details that should be included in block activities.
|
|
27
|
+
*/
|
|
19
28
|
export type BlockActivityDetails = {
|
|
20
29
|
block_reason: string;
|
|
21
30
|
block_action: BlockAction;
|
|
22
31
|
block_score: number;
|
|
23
32
|
simulated_block: boolean;
|
|
24
33
|
};
|
|
34
|
+
/**
|
|
35
|
+
* Activity details that should be included in additional_s2s activities.
|
|
36
|
+
*/
|
|
25
37
|
export type AdditionalS2SActivityDetails = {
|
|
26
38
|
http_status_code: number;
|
|
27
39
|
login_successful: boolean;
|
|
@@ -4,6 +4,9 @@ import { GraphQLData } from '../../graphql';
|
|
|
4
4
|
import { ModuleMode, VidSource } from '../../utils';
|
|
5
5
|
import { CredentialIntelligenceVersion, SsoStep } from '../../products';
|
|
6
6
|
import { CustomParameters } from '../../custom_parameters';
|
|
7
|
+
/**
|
|
8
|
+
* Activity details that should be included in both synchronous and asynchronous activities.
|
|
9
|
+
*/
|
|
7
10
|
export type CommonActivityDetails = {
|
|
8
11
|
request_id: string;
|
|
9
12
|
module_version: string;
|
|
@@ -5,7 +5,21 @@ import { ProductData } from '../products';
|
|
|
5
5
|
import { ActivityType } from './ActivityType';
|
|
6
6
|
import { AdditionalS2SActivityDetails, AsyncActivity, AsyncActivityCommonDetails, AsyncActivityDetails, BlockActivityDetails, CommonActivityDetails, HeaderEntry, PageRequestedActivityDetails } from './model';
|
|
7
7
|
import { CustomParameters } from '../custom_parameters';
|
|
8
|
+
/**
|
|
9
|
+
* Creates an async activity object based on the provided parameters.
|
|
10
|
+
* @param activityType - The activity type to create.
|
|
11
|
+
* @param config - The enforcer configuration.
|
|
12
|
+
* @param context - The request context.
|
|
13
|
+
* @returns {AsyncActivity} - The complete async activity payload.
|
|
14
|
+
*/
|
|
8
15
|
export declare const createAsyncActivity: <Req, Res, Added, Removed>(activityType: ActivityType, config: IConfiguration<Req, Res, Added, Removed>, context: ReadonlyContext<Req, Res>) => AsyncActivity;
|
|
16
|
+
/**
|
|
17
|
+
* Creates activity details based on the provided parameters.
|
|
18
|
+
* @param activityType - The activity type to create.
|
|
19
|
+
* @param config - The enforcer configuration.
|
|
20
|
+
* @param context - The request context.
|
|
21
|
+
* @returns {AsyncActivityDetails} - The activity details.
|
|
22
|
+
*/
|
|
9
23
|
export declare const createActivityDetails: <Req, Res, Added, Removed>(activityType: ActivityType, config: IConfiguration<Req, Res, Added, Removed>, context: ReadonlyContext<Req, Res>) => AsyncActivityDetails;
|
|
10
24
|
export declare const createAsyncActivityCommonDetails: <Req, Res>(context: ReadonlyContext<Req, Res>) => AsyncActivityCommonDetails;
|
|
11
25
|
export declare const createCommonActivityDetails: <Req, Res, Added, Removed>(config: IConfiguration<Req, Res, Added, Removed>, context: ReadonlyContext<Req, Res>) => CommonActivityDetails;
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { ReadonlyContext } from '../context';
|
|
2
2
|
import { IConfiguration } from '../config';
|
|
3
3
|
export declare namespace AdditionalActivityHandlerUtils {
|
|
4
|
+
/**
|
|
5
|
+
* Invokes the additional activity handler if it is defined in the configuration.
|
|
6
|
+
* @param config - The enforcer configuration.
|
|
7
|
+
* @param context - The request context.
|
|
8
|
+
* @returns {Promise<void>} - A promise that resolves when the additional activity handler is complete.
|
|
9
|
+
*/
|
|
4
10
|
const invokeAdditionalActivityHandler: <Req, Res, Added, Removed>(config: IConfiguration<Req, Res, Added, Removed>, context: ReadonlyContext<Req, Res>) => Promise<void>;
|
|
5
11
|
}
|
|
@@ -1,11 +1,32 @@
|
|
|
1
1
|
import { ReadonlyContext } from '../context';
|
|
2
2
|
import { IBlocker } from '../blocker';
|
|
3
3
|
import { ContentType, IMinimalResponse, ReadonlyHeaders } from '../http';
|
|
4
|
+
/**
|
|
5
|
+
* Base class for creating a block response.
|
|
6
|
+
*/
|
|
4
7
|
export declare abstract class BlockerBase<Req, Res> implements IBlocker<Req, Res> {
|
|
5
8
|
protected readonly statusCode: number;
|
|
6
9
|
protected readonly contentType: ContentType;
|
|
10
|
+
/**
|
|
11
|
+
* Creates a new instance of BlockerBase.
|
|
12
|
+
* @param contentType - The Content-Type header to be included in the HTTP block response.
|
|
13
|
+
* @param statusCode - The status code of the HTTP block response.
|
|
14
|
+
* @protected
|
|
15
|
+
*/
|
|
7
16
|
protected constructor(contentType: ContentType, statusCode?: number);
|
|
17
|
+
/**
|
|
18
|
+
* Creates the body of the block response.
|
|
19
|
+
* @param context - THe request context.
|
|
20
|
+
* @returns {string} - The HTTP body of the block response.
|
|
21
|
+
* @protected
|
|
22
|
+
* @abstract
|
|
23
|
+
*/
|
|
8
24
|
protected abstract createBlockBody(context: ReadonlyContext<Req, Res>): string;
|
|
25
|
+
/**
|
|
26
|
+
* Creates the complete HTTP block response based on the given context.
|
|
27
|
+
* @param context - The request context.
|
|
28
|
+
* @returns {IMinimalResponse} - The HTTP block response.
|
|
29
|
+
*/
|
|
9
30
|
createBlockResponse(context: ReadonlyContext<Req, Res>): IMinimalResponse;
|
|
10
31
|
protected createHeaders(): ReadonlyHeaders;
|
|
11
32
|
}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { ReadonlyContext } from '../context';
|
|
2
2
|
import { IMinimalResponse } from '../http';
|
|
3
|
+
/**
|
|
4
|
+
* Interface for an entity that creates a block response.
|
|
5
|
+
*/
|
|
3
6
|
export interface IBlocker<Req, Res> {
|
|
7
|
+
/**
|
|
8
|
+
* Creates a block response based on the given context.
|
|
9
|
+
* @param context - The request context.
|
|
10
|
+
* @returns IMinimalResponse - The HTTP block response.
|
|
11
|
+
*/
|
|
4
12
|
createBlockResponse(context: ReadonlyContext<Req, Res>): IMinimalResponse;
|
|
5
13
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { IBlocker } from './IBlocker';
|
|
2
2
|
import { ReadonlyContext } from '../context';
|
|
3
|
+
/**
|
|
4
|
+
* Interface for an entity that creates a block response based on a condition.
|
|
5
|
+
*/
|
|
3
6
|
export interface IConditionalBlocker<Req, Res> extends IBlocker<Req, Res> {
|
|
4
7
|
/**
|
|
8
|
+
* Whether the blocker instance should create a block response or not.
|
|
5
9
|
* @param context - The request context.
|
|
6
10
|
* @returns boolean - Whether a block response should be created.
|
|
7
11
|
*/
|
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
import { BlockerBase } from './BlockerBase';
|
|
2
2
|
import { IConditionalBlocker } from './IConditionalBlocker';
|
|
3
3
|
import { ReadonlyContext } from '../context';
|
|
4
|
+
/**
|
|
5
|
+
* Base class for creating a block response with JSON payload.
|
|
6
|
+
*
|
|
7
|
+
* The generic argument JsonPayloadT is the specific structure of the JSON payload to be returned.
|
|
8
|
+
*/
|
|
4
9
|
export declare abstract class JsonBlockerBase<Req, Res, JsonPayloadT extends Record<string, any>> extends BlockerBase<Req, Res> implements IConditionalBlocker<Req, Res> {
|
|
5
10
|
protected constructor();
|
|
11
|
+
/**
|
|
12
|
+
* Creates the JSON payload (JsonPayloadT) for the block response.
|
|
13
|
+
* @param context - The request context.
|
|
14
|
+
* @returns {JsonPayloadT} - The JSON payload to be included in the block response.
|
|
15
|
+
* @abstract
|
|
16
|
+
* @protected
|
|
17
|
+
*/
|
|
6
18
|
protected abstract createJsonPayload(context: ReadonlyContext<Req, Res>): JsonPayloadT;
|
|
7
19
|
shouldBlock(context: ReadonlyContext<Req, Res>): boolean;
|
|
8
20
|
protected createBlockBody(context: ReadonlyContext<Req, Res>): string;
|
|
@@ -2,5 +2,18 @@ import { IConfiguration } from '../config';
|
|
|
2
2
|
import { ReadonlyContext } from '../context';
|
|
3
3
|
import { IBase64Utils } from '../utils';
|
|
4
4
|
import { BlockData } from './model';
|
|
5
|
+
/**
|
|
6
|
+
* Renders the HTML template with the provided block data.
|
|
7
|
+
* @param htmlTemplate - The HTML template to be rendered. Placeholders are indicated with {{key_name}} where the key_name should be keyof BlockData.
|
|
8
|
+
* @param blockData - The block data to be used for rendering. The keys in the object should match the placeholders in the template.
|
|
9
|
+
* @returns {string} - The final HTML string. If no block data is provided, the original template is returned unchanged.
|
|
10
|
+
*/
|
|
5
11
|
export declare const renderHtml: (htmlTemplate: string, blockData?: BlockData) => string;
|
|
12
|
+
/**
|
|
13
|
+
* Creates the block data object to be used when creating a block response.
|
|
14
|
+
* @param config - The enforcer configuration.
|
|
15
|
+
* @param context - The request context.
|
|
16
|
+
* @param base64Utils - The base64 utility functions.
|
|
17
|
+
* @returns {BlockData} - The block data object.
|
|
18
|
+
*/
|
|
6
19
|
export declare const createBlockData: <Req, Res, Added, Removed>(config: IConfiguration<Req, Res, Added, Removed>, context: ReadonlyContext<Req, Res>, base64Utils: IBase64Utils) => BlockData;
|
|
@@ -11,6 +11,9 @@ import { ExtractGraphQLKeywordsFunction } from '../graphql';
|
|
|
11
11
|
import { RemoteConfigData } from './remote_config';
|
|
12
12
|
import { TokenVersion } from '../risk_token';
|
|
13
13
|
import { CustomSnippetFunction } from '../snippet_injection';
|
|
14
|
+
/**
|
|
15
|
+
* Base class for the enforcer configuration.
|
|
16
|
+
*/
|
|
14
17
|
export declare abstract class ConfigurationBase<Req, Res, Added, Removed extends string> implements IConfiguration<Req, Res, Added, Removed> {
|
|
15
18
|
protected configParams: RequiredAllConfigurationParams<Req, Res, Added, Removed>;
|
|
16
19
|
protected readonly staticConfigParams: StaticConfigurationParams<Req, Res, Added, Removed>;
|
|
@@ -18,7 +21,25 @@ export declare abstract class ConfigurationBase<Req, Res, Added, Removed extends
|
|
|
18
21
|
protected readonly defaultConfigParams: RequiredAllConfigurationParams<Req, Res, Added, Removed>;
|
|
19
22
|
protected readonly removedParams: Record<Removed, undefined>;
|
|
20
23
|
private internalLogger;
|
|
24
|
+
/**
|
|
25
|
+
* Returns the module version of the enforcer.
|
|
26
|
+
*
|
|
27
|
+
* Examples:
|
|
28
|
+
* - Akamai EdgeWorker 1.2.3
|
|
29
|
+
* - AWS Lambda@Edge 4.5.6
|
|
30
|
+
* - Cloudflare Worker 7.8.9
|
|
31
|
+
*
|
|
32
|
+
* Note: The JS Core version will be added automatically.
|
|
33
|
+
* @protected
|
|
34
|
+
*/
|
|
21
35
|
protected abstract getModuleVersion(): string;
|
|
36
|
+
/**
|
|
37
|
+
* Creates an instance of the configuration base class.
|
|
38
|
+
* @param params - The configuration parameters as provided by the customer.
|
|
39
|
+
* @param defaultParams - Default parameters for added configurations or any default core configurations that should be overridden.
|
|
40
|
+
* @param removedParams - A map of all removed (unsupported) configuration parameters set to undefined. This parameter can be generated automatically by your IDE.
|
|
41
|
+
* @protected
|
|
42
|
+
*/
|
|
22
43
|
protected constructor(params: StaticConfigurationParams<Req, Res, Added, Removed>, defaultParams: Required<Added> & Partial<CoreConfigurationParams<Req, Res, Added, Removed>>, removedParams: Record<Removed, undefined>);
|
|
23
44
|
protected createActiveConfiguration(params: AllConfigurationParams<Req, Res, Added, Removed>, defaultParams: RequiredAllConfigurationParams<Req, Res, Added, Removed>): RequiredAllConfigurationParams<Req, Res, Added, Removed>;
|
|
24
45
|
protected throwIfMissingRequiredField(params: AllConfigurationParams<Req, Res, Added, Removed>): void;
|
|
@@ -120,4 +141,5 @@ export declare abstract class ConfigurationBase<Req, Res, Added, Removed extends
|
|
|
120
141
|
get snippetInjectionEnabled(): boolean;
|
|
121
142
|
get createCustomSnippet(): CustomSnippetFunction<Req, Res, Added, Removed> | null;
|
|
122
143
|
get enableBlockedUrlOnCaptchaBlockPage(): boolean;
|
|
144
|
+
get isPostEnforceEnabled(): boolean;
|
|
123
145
|
}
|
|
@@ -384,6 +384,10 @@ export interface IConfiguration<Req, Res, Added, Removed> {
|
|
|
384
384
|
* Whether to include the request url in captcha block page
|
|
385
385
|
*/
|
|
386
386
|
readonly enableBlockedUrlOnCaptchaBlockPage: boolean;
|
|
387
|
+
/**
|
|
388
|
+
* Whether the enforcer has access to the HTTP response, which is required for the postEnforce function call
|
|
389
|
+
*/
|
|
390
|
+
readonly isPostEnforceEnabled: boolean;
|
|
387
391
|
/**
|
|
388
392
|
* The version of the token the enforcer is able to parse.
|
|
389
393
|
*/
|
|
@@ -8,6 +8,9 @@ import { CustomBlockResponseHeadersHandler, CustomPreflightHandler } from '../..
|
|
|
8
8
|
import { CustomRequestFunction } from '../CustomRequestFunction';
|
|
9
9
|
import { TokenVersion } from '../../risk_token';
|
|
10
10
|
import { CustomSnippetFunction } from '../../snippet_injection';
|
|
11
|
+
/**
|
|
12
|
+
* The configuration parameters that can be set only via the static configuration..
|
|
13
|
+
*/
|
|
11
14
|
export type StaticConfigurationParamsOnly = {
|
|
12
15
|
px_app_id: string;
|
|
13
16
|
px_cookie_secret: string | string[];
|
|
@@ -16,6 +19,9 @@ export type StaticConfigurationParamsOnly = {
|
|
|
16
19
|
px_remote_config_auth_token?: string;
|
|
17
20
|
px_remote_config_id?: string;
|
|
18
21
|
};
|
|
22
|
+
/**
|
|
23
|
+
* The configuration parameters that can be set only via the remote configuration.
|
|
24
|
+
*/
|
|
19
25
|
export type RemoteConfigurationParamsOnly = {
|
|
20
26
|
px_remote_config_enabled?: boolean;
|
|
21
27
|
px_remote_config_version?: number;
|
|
@@ -25,20 +31,32 @@ export type RemoteConfigurationParamsOnly = {
|
|
|
25
31
|
px_filter_by_route_regex?: string[];
|
|
26
32
|
px_graphql_routes_regex?: string[];
|
|
27
33
|
};
|
|
34
|
+
/**
|
|
35
|
+
* The configuration parameters relevant to the batched activities feature.
|
|
36
|
+
*/
|
|
28
37
|
export type BatchedActivitiesConfigParamsOnly = {
|
|
29
38
|
px_max_activity_batch_size?: number;
|
|
30
39
|
px_batch_activities_timeout_ms?: number;
|
|
31
40
|
};
|
|
41
|
+
/**
|
|
42
|
+
* The configuration parameters relevant to supporting Token (Cookie) V3.
|
|
43
|
+
*/
|
|
32
44
|
export type TokenV3ConfigurationParamsOnly = {
|
|
33
45
|
px_token_version?: `${TokenVersion}`;
|
|
34
46
|
px_blocking_score?: number;
|
|
35
47
|
px_risk_cookie_min_iterations?: number;
|
|
36
48
|
px_risk_cookie_max_iterations?: number;
|
|
37
49
|
};
|
|
50
|
+
/**
|
|
51
|
+
* The configuration parameters relevant to the snippet injection feature.
|
|
52
|
+
*/
|
|
38
53
|
export type SnippetInjectionParamsOnly<Req, Res, Added, Removed> = {
|
|
39
54
|
px_snippet_injection_enabled?: boolean;
|
|
40
55
|
px_create_custom_snippet?: CustomSnippetFunction<Req, Res, Added, Removed> | null;
|
|
41
56
|
};
|
|
57
|
+
/**
|
|
58
|
+
* The configuration parameters that can be set via either the static or remote configuration.
|
|
59
|
+
*/
|
|
42
60
|
export type CommonConfigurationParams<Req, Res, Added, Removed> = TokenV3ConfigurationParamsOnly & BatchedActivitiesConfigParamsOnly & SnippetInjectionParamsOnly<Req, Res, Added, Removed> & {
|
|
43
61
|
px_s2s_timeout?: number;
|
|
44
62
|
px_backend_url?: string;
|
|
@@ -112,4 +130,7 @@ export type CommonConfigurationParams<Req, Res, Added, Removed> = TokenV3Configu
|
|
|
112
130
|
px_custom_is_filtered_request?: CustomRequestFunction<Req> | null;
|
|
113
131
|
px_extract_graphql_keywords?: ExtractGraphQLKeywordsFunction | null;
|
|
114
132
|
};
|
|
133
|
+
/**
|
|
134
|
+
* All configuration parameters supported by JS Core.
|
|
135
|
+
*/
|
|
115
136
|
export type CoreConfigurationParams<Req, Res, Added, Removed> = StaticConfigurationParamsOnly & RemoteConfigurationParamsOnly & CommonConfigurationParams<Req, Res, Added, Removed>;
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
import { CoreConfigurationParams, StaticConfigurationParamsOnly } from './CoreConfigurationParams';
|
|
2
|
+
/**
|
|
3
|
+
* All configurations that can be set via the remote configurations, taking into account any added or removed configurations.
|
|
4
|
+
*/
|
|
2
5
|
export type RemoteConfigurationParams<Req, Res, Added, Removed> = Omit<CoreConfigurationParams<Req, Res, Added, Removed>, keyof StaticConfigurationParamsOnly>;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import { RemoteConfigurationParamsOnly } from './CoreConfigurationParams';
|
|
2
2
|
import { CreateHumanSecurityConfigurationParams } from './AllConfigurationParams';
|
|
3
|
+
/**
|
|
4
|
+
* All configurations that can be set via the static configurations, taking into account any added or removed configurations.
|
|
5
|
+
*/
|
|
3
6
|
export type StaticConfigurationParams<Req, Res, Added = {}, Removed = never> = Omit<CreateHumanSecurityConfigurationParams<Req, Res, Added, Removed>, keyof RemoteConfigurationParamsOnly>;
|
|
@@ -13,6 +13,10 @@ type RequestDataJson<Req> = Omit<RequestData<Req>, 'url' | 'request'> & {
|
|
|
13
13
|
url: string;
|
|
14
14
|
request: undefined;
|
|
15
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* A JSON representation of the request context data. Used when the context must be serialized to JSON in order to
|
|
18
|
+
* preserve it between the `enforce()` and `postEnforce()` calls.
|
|
19
|
+
*/
|
|
16
20
|
export type ContextJson<Req = unknown, Res = unknown> = {
|
|
17
21
|
readonly requestId: string;
|
|
18
22
|
readonly isMobile: boolean;
|
|
@@ -17,6 +17,10 @@ export type DefaultContextOptions = {
|
|
|
17
17
|
requestIdGenerator: IRequestIdGenerator;
|
|
18
18
|
urlUtils: IUrlUtils;
|
|
19
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* The default implementation of the request context which uses the incoming HTTP request and enforcer configuration
|
|
22
|
+
* to populate the context with relevant data.
|
|
23
|
+
*/
|
|
20
24
|
export declare class DefaultContext<Req, Res, Added, Removed> implements IContext<Req, Res> {
|
|
21
25
|
readonly requestId: string;
|
|
22
26
|
readonly tokenOrigin: TokenOrigin;
|
|
@@ -12,6 +12,11 @@ import { CustomParameters } from '../custom_parameters';
|
|
|
12
12
|
import { GraphQLData } from '../graphql';
|
|
13
13
|
import { IContext, RemoteConfigUpdateData, RequestData, RiskApiData, ServerData, TlsData, TokenData } from './interfaces';
|
|
14
14
|
import { ContextJson } from './ContextJson';
|
|
15
|
+
/**
|
|
16
|
+
* Implements the `IContext` interface based an already serialized `ContextJson`. This class does not extract data from the
|
|
17
|
+
* incoming request, but rather uses already-extracted data from the `ContextJson` (likely returned from the `DefaultContext.toJSON()`
|
|
18
|
+
* function) and fills in the gaps using the other parameters.
|
|
19
|
+
*/
|
|
15
20
|
export declare class SerializedContext<Req, Res, Added, Removed> implements IContext<Req, Res> {
|
|
16
21
|
readonly isMobile: boolean;
|
|
17
22
|
readonly remoteConfigUpdateData: RemoteConfigUpdateData;
|
|
@@ -2,16 +2,20 @@ import { AsyncOrSync } from 'ts-essentials';
|
|
|
2
2
|
import { IConfiguration, IRemoteConfigManager } from '../config';
|
|
3
3
|
import { IContext } from '../context';
|
|
4
4
|
import { IMinimalResponse, IOutgoingResponse } from '../http';
|
|
5
|
-
import {
|
|
5
|
+
import { IFlow } from '../flow';
|
|
6
6
|
import { IActivityClient } from '../activities';
|
|
7
|
-
import { IEnforcer } from './IEnforcer';
|
|
8
7
|
import { EnforcerOptions } from './EnforcerOptions';
|
|
9
|
-
|
|
8
|
+
import { IEnforcer } from './IEnforcer';
|
|
9
|
+
import { IPostEnforcer } from './IPostEnforcer';
|
|
10
|
+
/**
|
|
11
|
+
* The base class for fundamental enforcer logic.
|
|
12
|
+
*/
|
|
13
|
+
export declare abstract class EnforcerBase<Req, Res, EnforceArgs extends any[], PostEnforceArgs extends any[], Added, Removed> implements IEnforcer<EnforceArgs, Promise<Res | null>>, IPostEnforcer<PostEnforceArgs, Promise<void>> {
|
|
10
14
|
protected readonly config: IConfiguration<Req, Res, Added, Removed>;
|
|
11
|
-
protected readonly filterFlow:
|
|
12
|
-
protected readonly enforceFlow:
|
|
13
|
-
protected readonly postEnforceFlow:
|
|
14
|
-
protected readonly endEnforcerFlow:
|
|
15
|
+
protected readonly filterFlow: IFlow<Req, Res>;
|
|
16
|
+
protected readonly enforceFlow: IFlow<Req, Res>;
|
|
17
|
+
protected readonly postEnforceFlow: IFlow<Req, Res> | null;
|
|
18
|
+
protected readonly endEnforcerFlow: IFlow<Req, Res>;
|
|
15
19
|
protected readonly activityClient: IActivityClient<Req, Res>;
|
|
16
20
|
protected readonly remoteConfigManager: IRemoteConfigManager<Req, Res> | null;
|
|
17
21
|
/**
|
|
@@ -58,10 +62,42 @@ export declare abstract class EnforcerBase<Req, Res, EnforceArgs extends any[],
|
|
|
58
62
|
* @protected
|
|
59
63
|
*/
|
|
60
64
|
protected constructor(config: IConfiguration<Req, Res, Added, Removed>, options: EnforcerOptions<Req, Res, Added, Removed>);
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
/**
|
|
66
|
+
* Creates the filter flow for the enforcer. The filter flow is responsible for filtering out requests that should not undergo the usual enforcement flow.
|
|
67
|
+
* For example, first party, filtered, CORS preflight, and telemetry requests are filtered out.
|
|
68
|
+
* @param config - The configuration object.
|
|
69
|
+
* @param initializationBlock - All entities necessary for the enforcer to function.
|
|
70
|
+
* @protected
|
|
71
|
+
* @returns - The filter flow for the enforcer.
|
|
72
|
+
*/
|
|
73
|
+
protected createFilterFlow(config: IConfiguration<Req, Res, Added, Removed>, initializationBlock: Required<EnforcerOptions<Req, Res, Added, Removed>>): IFlow<Req, Res>;
|
|
74
|
+
/**
|
|
75
|
+
* 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.
|
|
76
|
+
* 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.
|
|
77
|
+
* @param config - The configuration object.
|
|
78
|
+
* @param initializationBlock - All entities necessary for the enforcer to function.
|
|
79
|
+
* @protected
|
|
80
|
+
* @returns - The post enforce flow for the enforcer or null if post enforce is not enabled.
|
|
81
|
+
*/
|
|
82
|
+
protected createPostEnforceFlow(config: IConfiguration<Req, Res, Added, Removed>, initializationBlock: Required<EnforcerOptions<Req, Res, Added, Removed>>): IFlow<Req, Res> | null;
|
|
83
|
+
/**
|
|
84
|
+
* Creates the enforce flow for the enforcer. The enforce flow is responsible for the core functionality of HUMAN enforcement.
|
|
85
|
+
* For example, parsing HUMAN cookies, performing Risk API, invoking the additional activity handler, and returning a block response are part of the enforce flow.
|
|
86
|
+
* @param config - The configuration object.
|
|
87
|
+
* @param initializationBlock - All entities necessary for the enforcer to function.
|
|
88
|
+
* @protected
|
|
89
|
+
* @returns - The enforce flow for the enforcer.
|
|
90
|
+
*/
|
|
91
|
+
protected createEnforceFlow(config: IConfiguration<Req, Res, Added, Removed>, initializationBlock: Required<EnforcerOptions<Req, Res, Added, Removed>>): IFlow<Req, Res>;
|
|
92
|
+
/**
|
|
93
|
+
* 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.
|
|
94
|
+
* 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.
|
|
95
|
+
* @param config - The configuration object.
|
|
96
|
+
* @param initializationBlock - All entities necessary for the enforcer to function.
|
|
97
|
+
* @protected
|
|
98
|
+
* @returns - The end enforce flow for the enforcer.
|
|
99
|
+
*/
|
|
100
|
+
protected createEndEnforcerFlow(config: IConfiguration<Req, Res, Added, Removed>, initializationBlock: Required<EnforcerOptions<Req, Res, Added, Removed>>): IFlow<Req, Res>;
|
|
65
101
|
/**
|
|
66
102
|
* The central function that triggers enforcement on the incoming request.
|
|
67
103
|
* @param args - The EnforceArgs required to enforce the incoming request.
|
|
@@ -82,5 +118,5 @@ export declare abstract class EnforcerBase<Req, Res, EnforceArgs extends any[],
|
|
|
82
118
|
* @returns Promise<void> - The response parameter will be modified as needed
|
|
83
119
|
*/
|
|
84
120
|
postEnforce(...args: PostEnforceArgs): Promise<void>;
|
|
85
|
-
sendAdditionalS2SActivity(...args: PostEnforceArgs): Promise<void>;
|
|
121
|
+
protected sendAdditionalS2SActivity(...args: PostEnforceArgs): Promise<void>;
|
|
86
122
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export interface IEnforcer<EnforceArgs extends any[],
|
|
1
|
+
export interface IEnforcer<EnforceArgs extends any[], EnforceResult> {
|
|
2
2
|
enforce(...args: EnforceArgs): EnforceResult;
|
|
3
|
-
postEnforce(...args: PostEnforceArgs): PostEnforceResult;
|
|
4
3
|
}
|
|
@@ -4,7 +4,7 @@ import { FirstPartyData } from './FirstPartyData';
|
|
|
4
4
|
export interface IFirstParty<Req, Res> {
|
|
5
5
|
/**
|
|
6
6
|
* @param context - The request context
|
|
7
|
-
* @returns
|
|
7
|
+
* @returns {AsyncOrSync<FirstPartyData|null>} - If the request is a first party request, it will return a FirstPartyData object. Otherwise, it will return null.
|
|
8
8
|
*/
|
|
9
9
|
handleFirstPartyRequest(context: ReadonlyContext<Req, Res>): AsyncOrSync<FirstPartyData | null>;
|
|
10
10
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IConfiguration } from '../config';
|
|
2
|
+
import { EnforcerOptions } from '../enforcer';
|
|
3
|
+
import { Flow } from './Flow';
|
|
4
|
+
type RequiredEndEnforcerFlowOptions = 'activityClient' | 'logServiceClient' | 'telemetry' | 'remoteConfigManager';
|
|
5
|
+
export declare class EndEnforcerFlow<Req, Res, Added, Removed> extends Flow<Req, Res> {
|
|
6
|
+
constructor(config: IConfiguration<Req, Res, Added, Removed>, { logServiceClient, telemetry, remoteConfigManager, activityClient, }: Pick<Required<EnforcerOptions<Req, Res, Added, Removed>>, RequiredEndEnforcerFlowOptions>);
|
|
7
|
+
}
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IConfiguration } from '../config';
|
|
2
|
+
import { EnforcerOptions } from '../enforcer';
|
|
3
|
+
import { Flow } from './Flow';
|
|
4
|
+
type RequiredEnforceFlowOptions = 'dataEnrichment' | 'tokenParser' | 'riskApiClient' | 'cors' | 'products' | 'graphQLParser';
|
|
5
|
+
export declare class EnforceFlow<Req, Res, Added, Removed> extends Flow<Req, Res> {
|
|
6
|
+
constructor(config: IConfiguration<Req, Res, Added, Removed>, { dataEnrichment, tokenParser, riskApiClient, cors, products, graphQLParser, }: Pick<Required<EnforcerOptions<Req, Res, Added, Removed>>, RequiredEnforceFlowOptions>);
|
|
7
|
+
}
|
|
8
|
+
export {};
|