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
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { IConfiguration } from '
|
|
2
|
-
import { EnforcerOptions } from '
|
|
3
|
-
import { Products } from '
|
|
4
|
-
import { IFirstParty } from '
|
|
5
|
-
import { IFilter } from '
|
|
6
|
-
import {
|
|
7
|
-
export declare class FilterFlow<Req, Res, Added, Removed> extends
|
|
1
|
+
import { IConfiguration } from '../config';
|
|
2
|
+
import { EnforcerOptions } from '../enforcer';
|
|
3
|
+
import { Products } from '../products';
|
|
4
|
+
import { IFirstParty } from '../first_party';
|
|
5
|
+
import { IFilter } from '../filter';
|
|
6
|
+
import { Flow } from './Flow';
|
|
7
|
+
export declare class FilterFlow<Req, Res, Added, Removed> extends Flow<Req, Res> {
|
|
8
8
|
constructor(config: IConfiguration<Req, Res, Added, Removed>, { httpClient, products, cors, telemetry, remoteConfigUpdateParser, }: Required<EnforcerOptions<Req, Res, Added, Removed>>);
|
|
9
9
|
protected static getFirstPartyProducts<Req, Res>(products: Products<Req, Res>): IFirstParty<Req, Res>[];
|
|
10
10
|
protected static getFilterProducts<Req, Res>(products: Products<Req, Res>): IFilter<Req, Res>[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IContext } from '../context';
|
|
2
|
+
import { IPhase, PhaseResult } from '../phase';
|
|
3
|
+
import { IFlow, InsertPhaseOptions } from './IFlow';
|
|
4
|
+
export declare class Flow<Req, Res> implements IFlow<Req, Res> {
|
|
5
|
+
readonly phases: IPhase<Req, Res>[];
|
|
6
|
+
constructor(phases: IPhase<Req, Res>[]);
|
|
7
|
+
insert(phase: IPhase<Req, Res>, options?: InsertPhaseOptions): void;
|
|
8
|
+
remove(name: string): void;
|
|
9
|
+
replace(name: string, phase: IPhase<Req, Res>): void;
|
|
10
|
+
move(name: string, to: InsertPhaseOptions): void;
|
|
11
|
+
protected getIndexOfPhase(name: string): number;
|
|
12
|
+
execute(context: IContext<Req, Res>): Promise<PhaseResult>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { IPhase } from '../phase';
|
|
2
|
+
export type InsertPhaseOptions = {
|
|
3
|
+
/**
|
|
4
|
+
* The name of the phase before which the new phase will be inserted. For example, if
|
|
5
|
+
* this value is set to Phase1, the phase that is inserted into the flow will be
|
|
6
|
+
* inserted immediately preceding Phase1.
|
|
7
|
+
*/
|
|
8
|
+
before?: string;
|
|
9
|
+
/**
|
|
10
|
+
* The name of the phase after which the new phase will be inserted. For example, if
|
|
11
|
+
* this value is set to Phase1, the phase that is inserted into the flow will be
|
|
12
|
+
* inserted immediately following Phase1.
|
|
13
|
+
*/
|
|
14
|
+
after?: never;
|
|
15
|
+
} | {
|
|
16
|
+
/**
|
|
17
|
+
* The name of the phase before which the new phase will be inserted. For example, if
|
|
18
|
+
* this value is set to Phase1, the phase that is inserted into the flow will be
|
|
19
|
+
* inserted immediately preceding Phase1.
|
|
20
|
+
*/
|
|
21
|
+
before?: never;
|
|
22
|
+
/**
|
|
23
|
+
* The name of the phase after which the new phase will be inserted. For example, if
|
|
24
|
+
* this value is set to Phase1, the phase that is inserted into the flow will be
|
|
25
|
+
* inserted immediately following Phase1.
|
|
26
|
+
*/
|
|
27
|
+
after?: string;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* The IFlow interface represents a flow of phases that can be executed in a specific order.
|
|
31
|
+
*/
|
|
32
|
+
export interface IFlow<Req, Res> extends IPhase<Req, Res> {
|
|
33
|
+
/**
|
|
34
|
+
* Replaces the named phase in the flow with the provided phase. If the named phase is not found, nothing happens.
|
|
35
|
+
* @param name - The name of the phase to replace. A phase with this name should exist in the flow already.
|
|
36
|
+
* @param phase - The phase that should replace the named phase.
|
|
37
|
+
*/
|
|
38
|
+
replace(name: string, phase: IPhase<Req, Res>): void;
|
|
39
|
+
/**
|
|
40
|
+
* Removes the named phase from the flow. If the named phase is not found, does nothing.
|
|
41
|
+
* @param name - The name of the phase to remove. A phase with this name should exist in the flow already.
|
|
42
|
+
*/
|
|
43
|
+
remove(name: string): void;
|
|
44
|
+
/**
|
|
45
|
+
* Inserts the provided phase into the flow at the specified position. If no position is specified,
|
|
46
|
+
* the phase will be added to the very end of the flow.
|
|
47
|
+
* @param phase - The phase to insert into the flow.
|
|
48
|
+
* @param options - The options for inserting the phase. If no options are provided, the phase will be added to the end of the flow.
|
|
49
|
+
*/
|
|
50
|
+
insert(phase: IPhase<Req, Res>, options?: InsertPhaseOptions): void;
|
|
51
|
+
/**
|
|
52
|
+
* Moves the named phase to the specified position in the flow. If the named phase is not found, nothing happens.
|
|
53
|
+
* @param name - The name of the phase to move. A phase with this name should exist in the flow already.
|
|
54
|
+
* @param to - The options for moving the phase. The phase will be moved to the specified position in the flow.
|
|
55
|
+
*/
|
|
56
|
+
move(name: string, to: InsertPhaseOptions): void;
|
|
57
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IConfiguration } from '../config';
|
|
2
|
+
import { EnforcerOptions } from '../enforcer';
|
|
3
|
+
import { Flow } from './Flow';
|
|
4
|
+
export declare class PostEnforceFlow<Req, Res, Added, Removed> extends Flow<Req, Res> {
|
|
5
|
+
constructor(config: IConfiguration<Req, Res, Added, Removed>, { products, snippetRetriever, snippetInjector, }: Pick<Required<EnforcerOptions<Req, Res, Added, Removed>>, 'products' | 'snippetRetriever' | 'snippetInjector'>);
|
|
6
|
+
}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { AsyncOrSync } from 'ts-essentials';
|
|
2
2
|
import { IContext } from '../context';
|
|
3
3
|
import { PhaseResult } from './PhaseResult';
|
|
4
|
+
/**
|
|
5
|
+
* A self-contained unit of logic that can be invoked as part of the overall enforcer logic.
|
|
6
|
+
*/
|
|
4
7
|
export interface IPhase<Req, Res> {
|
|
8
|
+
/**
|
|
9
|
+
* Executes the logic of the phase with the provided context.
|
|
10
|
+
* @param context - The context that contains all the necessary information about the incoming request and HUMAN-related metadata.
|
|
11
|
+
* The context is mutable, meaning that phases may change the context as they see fit.
|
|
12
|
+
* @returns AsyncOrSync<PhaseResult> - The result of the phase execution.
|
|
13
|
+
*/
|
|
5
14
|
execute(context: IContext<Req, Res>): AsyncOrSync<PhaseResult>;
|
|
6
15
|
}
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import { IMinimalResponse } from '../http';
|
|
2
|
+
/**
|
|
3
|
+
* The result of a phase execution in the flow, indicating whether to continue to the next phase or to stop the flow,
|
|
4
|
+
* and optionally providing an HTTP response to return.
|
|
5
|
+
*/
|
|
2
6
|
export type PhaseResult = {
|
|
7
|
+
/**
|
|
8
|
+
* Whether the flow should exit immediately after this phase. If true, no further phases should be executed
|
|
9
|
+
* within the flow. If false, the next phase should be executed.
|
|
10
|
+
*/
|
|
3
11
|
done: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* An interface representing the HTTP response to return from the enforcer, if any.
|
|
14
|
+
*/
|
|
4
15
|
response?: IMinimalResponse;
|
|
5
16
|
};
|
|
@@ -2,6 +2,9 @@ import { IPhase } from '../IPhase';
|
|
|
2
2
|
import { IConfiguration } from '../../config';
|
|
3
3
|
import { IContext } from '../../context';
|
|
4
4
|
import { PhaseResult } from '../PhaseResult';
|
|
5
|
+
/**
|
|
6
|
+
* The `AdditionalActivityHandlerPhase` invokes the additional activity handler defined in the configuration.
|
|
7
|
+
*/
|
|
5
8
|
export declare class AdditionalActivityHandlerPhase<Req, Res, Added, Removed> implements IPhase<Req, Res> {
|
|
6
9
|
protected config: IConfiguration<Req, Res, Added, Removed>;
|
|
7
10
|
constructor(config: IConfiguration<Req, Res, Added, Removed>);
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { IContext } from '../../context';
|
|
2
2
|
import { IPhase } from '../IPhase';
|
|
3
3
|
import { PhaseResult } from '../PhaseResult';
|
|
4
|
+
/**
|
|
5
|
+
* The `ClearLogsPhase` class deletes the context logs to free up memory.
|
|
6
|
+
*/
|
|
4
7
|
export declare class ClearLogsPhase<Req, Res> implements IPhase<Req, Res> {
|
|
5
8
|
execute(context: IContext<Req, Res>): Promise<PhaseResult>;
|
|
6
9
|
}
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { IPhase } from '../IPhase';
|
|
2
2
|
import { IContext } from '../../context';
|
|
3
3
|
import { PhaseResult } from '../PhaseResult';
|
|
4
|
+
/**
|
|
5
|
+
* The `CompositePhase` class executes a series of phases in sequence.
|
|
6
|
+
* It will stop executing phases as soon as one of them returns a result with `done: true`.
|
|
7
|
+
* It will return the result of the last phase executed or `{ done: false }`.
|
|
8
|
+
*/
|
|
4
9
|
export declare class CompositePhase<Req, Res> implements IPhase<Req, Res> {
|
|
5
10
|
protected readonly phases: IPhase<Req, Res>[];
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new CompositePhase instance.
|
|
13
|
+
* @param phases - An array of phases to be executed in sequence.
|
|
14
|
+
*/
|
|
6
15
|
constructor(phases: IPhase<Req, Res>[]);
|
|
7
16
|
execute(context: IContext<Req, Res>): Promise<PhaseResult>;
|
|
8
17
|
}
|
|
@@ -3,14 +3,24 @@ import { IContext, ReadonlyContext } from '../../context';
|
|
|
3
3
|
import { IMinimalResponse } from '../../http';
|
|
4
4
|
import { IConditionalBlocker } from '../../blocker';
|
|
5
5
|
import { ICors } from '../../cors';
|
|
6
|
-
import { ProductName } from '../../products';
|
|
6
|
+
import { ProductName, Products } from '../../products';
|
|
7
7
|
import { IPhase } from '../IPhase';
|
|
8
8
|
import { PhaseResult } from '../PhaseResult';
|
|
9
|
+
/**
|
|
10
|
+
* `CreateBlockResponsePhase` is a phase that creates a block response for the product that recommended a block action.
|
|
11
|
+
* If multiple products recommended block, it will return the block response for the highest priority product.
|
|
12
|
+
*/
|
|
9
13
|
export declare class CreateBlockResponsePhase<Req, Res, Added, Removed> implements IPhase<Req, Res> {
|
|
10
14
|
protected readonly config: IConfiguration<Req, Res, Added, Removed>;
|
|
11
15
|
protected readonly blockers: Partial<Record<ProductName, IConditionalBlocker<Req, Res>>>;
|
|
12
16
|
protected readonly cors?: ICors<Req, Res>;
|
|
13
17
|
constructor(config: IConfiguration<Req, Res, Added, Removed>, blockers: Partial<Record<ProductName, IConditionalBlocker<Req, Res>>>, cors?: ICors<Req, Res>);
|
|
18
|
+
/**
|
|
19
|
+
* A static method that identifies those products that can block incoming requests and returns a map of the product name to the product instance.
|
|
20
|
+
* @param products - All supported products.
|
|
21
|
+
* @returns A mapping of those products that implement the `IConditionalBlocker` interface.
|
|
22
|
+
*/
|
|
23
|
+
static getBlockers<Req, Res>(products: Products<Req, Res>): Partial<Record<ProductName, IConditionalBlocker<Req, Res>>>;
|
|
14
24
|
execute(context: IContext<Req, Res>): Promise<PhaseResult>;
|
|
15
25
|
protected createBlockResponse(context: ReadonlyContext<Req, Res>): IMinimalResponse | null;
|
|
16
26
|
protected addHeadersToResponse(response: IMinimalResponse, context: ReadonlyContext<Req, Res>): Promise<IMinimalResponse>;
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import { IContext } from '../../context';
|
|
2
2
|
import { IPhase } from '../IPhase';
|
|
3
3
|
import { PhaseResult } from '../PhaseResult';
|
|
4
|
+
/**
|
|
5
|
+
* `DecideActionPhase` is an abstract class that provides the protected function `updateContextDecision`.
|
|
6
|
+
* Phases that extend this class can use the `updateContextDecision` method to update the `context.action` and
|
|
7
|
+
* `context.reasons` properties based on the product data in the context. Calling this function essentially
|
|
8
|
+
* recalculates what action the enforcer should take and why.
|
|
9
|
+
*/
|
|
4
10
|
export declare abstract class DecideActionPhase<Req, Res> implements IPhase<Req, Res> {
|
|
5
11
|
abstract execute(context: IContext<Req, Res>): Promise<PhaseResult>;
|
|
12
|
+
/**
|
|
13
|
+
* Updates the `action`, `reasons`, and `blockAction` properties based on the product data in the context.
|
|
14
|
+
* @param context - The request context.
|
|
15
|
+
* @protected
|
|
16
|
+
*/
|
|
6
17
|
protected updateContextDecision(context: IContext<Req, Res>): Promise<void>;
|
|
7
18
|
protected modifyBlockActionIfNeeded(context: IContext<Req, Res>): void;
|
|
8
19
|
}
|
|
@@ -5,6 +5,15 @@ import { PhaseResult } from '../PhaseResult';
|
|
|
5
5
|
import { IDataEnrichment } from '../../pxde';
|
|
6
6
|
import { IGraphQLParser } from '../../graphql';
|
|
7
7
|
import { DecideActionPhase } from './DecideActionPhase';
|
|
8
|
+
/**
|
|
9
|
+
* `EnrichContextFromRequestPhase` adds data to the context from the request. This includes parsing the data enrichment cookie,
|
|
10
|
+
* adding GraphQL data, custom parameters, and enriching the context with any product-specific data by calling each product's
|
|
11
|
+
* `enrichContextFromRequest` method. (As an example, this is where the Credential Intelligence product enriches the context by
|
|
12
|
+
* extracting login credentials and adding them to the product data of the request.) It then updates the context's final action
|
|
13
|
+
* and reasons based on the enriched data.
|
|
14
|
+
*
|
|
15
|
+
* Note: This phase should come after the `ParseTokenPhase`, since the Bot Defender product uses the parsed token to determine its recommended action.
|
|
16
|
+
*/
|
|
8
17
|
export declare class EnrichContextFromRequestPhase<Req, Res, Added, Removed> extends DecideActionPhase<Req, Res> {
|
|
9
18
|
protected readonly config: IConfiguration<Req, Res, Added, Removed>;
|
|
10
19
|
protected readonly products: Products<Req, Res>;
|
|
@@ -3,6 +3,10 @@ import { Products } from '../../products';
|
|
|
3
3
|
import { IPhase } from '../IPhase';
|
|
4
4
|
import { PhaseResult } from '../PhaseResult';
|
|
5
5
|
import { IConfiguration } from '../../config';
|
|
6
|
+
/**
|
|
7
|
+
* `EnrichContextFromResponsePhase` enriches the context with response data. Each product's `enrichContextFromResponse`
|
|
8
|
+
* method is called since every product may use the response data differently.
|
|
9
|
+
*/
|
|
6
10
|
export declare class EnrichContextFromResponsePhase<Req, Res, Added, Removed> implements IPhase<Req, Res> {
|
|
7
11
|
protected readonly config: IConfiguration<Req, Res, Added, Removed>;
|
|
8
12
|
protected readonly products: Products<Req, Res>;
|
|
@@ -2,6 +2,10 @@ import { IContext } from '../../context';
|
|
|
2
2
|
import { IFilter } from '../../filter';
|
|
3
3
|
import { PhaseResult } from '../PhaseResult';
|
|
4
4
|
import { IPhase } from '../IPhase';
|
|
5
|
+
/**
|
|
6
|
+
* The `FilterPhase` class checks if the provided filters indicate that the incoming HTTP request should be filtered from the flow.
|
|
7
|
+
* If any filter returns `true` for `shouldFilter`, the phase will stop further processing and return a `done` status.
|
|
8
|
+
*/
|
|
5
9
|
export declare class FilterPhase<Req, Res> implements IPhase<Req, Res> {
|
|
6
10
|
protected readonly filters: IFilter<Req, Res>[];
|
|
7
11
|
constructor(filters: IFilter<Req, Res>[]);
|
|
@@ -4,6 +4,11 @@ import { IHttpClient, IMinimalResponse } from '../../http';
|
|
|
4
4
|
import { IPhase } from '../IPhase';
|
|
5
5
|
import { PhaseResult } from '../PhaseResult';
|
|
6
6
|
import { IConfiguration } from '../../config';
|
|
7
|
+
/**
|
|
8
|
+
* The `FirstPartyPhase` class is responsible for handling first-party requests. If a first-party request is detected,
|
|
9
|
+
* it will create the `FirstPartyData`, send the request to the configured endpoint using the provided HTTP client, and return
|
|
10
|
+
* a done status with the response. If an error occurs, it will return the default response.
|
|
11
|
+
*/
|
|
7
12
|
export declare class FirstPartyPhase<Req, Res, Added, Removed> implements IPhase<Req, Res> {
|
|
8
13
|
protected readonly config: IConfiguration<Req, Res, Added, Removed>;
|
|
9
14
|
protected readonly httpClient: IHttpClient;
|
|
@@ -2,6 +2,11 @@ import { IContext } from '../../context';
|
|
|
2
2
|
import { PhaseResult } from '../PhaseResult';
|
|
3
3
|
import { IPhase } from '../IPhase';
|
|
4
4
|
import { IRemoteConfigUpdateParser } from '../../config';
|
|
5
|
+
/**
|
|
6
|
+
* The `IdentifyRemoteConfigNotifyRequestPhase` class is responsible for identifying incoming remote config update requests.
|
|
7
|
+
* It checks if the request is a remote config update request and, if so, parses the request and updates the context accordingly.
|
|
8
|
+
* Note that the remote config is not updated during this phase; that occurs in the `UpdateRemoteConfigPhase`.
|
|
9
|
+
*/
|
|
5
10
|
export declare class IdentifyRemoteConfigNotifyRequestPhase<Req, Res> implements IPhase<Req, Res> {
|
|
6
11
|
protected readonly remoteConfigUpdateParser: IRemoteConfigUpdateParser<Req, Res>;
|
|
7
12
|
constructor(remoteConfigUpdateParser: IRemoteConfigUpdateParser<Req, Res>);
|
|
@@ -2,6 +2,11 @@ import { IPhase } from '../IPhase';
|
|
|
2
2
|
import { PhaseResult } from '../PhaseResult';
|
|
3
3
|
import { IContext } from '../../context';
|
|
4
4
|
import { ITelemetry } from '../../telemetry';
|
|
5
|
+
/**
|
|
6
|
+
* The `IdentifyTelemetryRequestPhase` class is responsible for identifying incoming telemetry requests.
|
|
7
|
+
* It checks if the request is a telemetry request and, if so, parses the request and updates the context accordingly.
|
|
8
|
+
* Note that the telemetry activity is not sent during this phase; that occurs in the `SendTelemetryActivityPhase`.
|
|
9
|
+
*/
|
|
5
10
|
export declare class IdentifyTelemetryRequestPhase<Req, Res> implements IPhase<Req, Res> {
|
|
6
11
|
protected readonly telemetry: ITelemetry<Req, Res>;
|
|
7
12
|
constructor(telemetry: ITelemetry<Req, Res>);
|
|
@@ -2,6 +2,11 @@ import { IContext } from '../../context';
|
|
|
2
2
|
import { IProduct } from '../../products';
|
|
3
3
|
import { IPhase } from '../IPhase';
|
|
4
4
|
import { PhaseResult } from '../PhaseResult';
|
|
5
|
+
/**
|
|
6
|
+
* The `ModifyIncomingRequestPhase` class is responsible for modifying the incoming HTTP request prior to forwarding the
|
|
7
|
+
* request to the origin server or cache. This phase invokes each product's `modifyIncomingRequest` method. (As an example,
|
|
8
|
+
* this is where the Credential Intelligence product adds the compromised credentials header to the request if needed.)
|
|
9
|
+
*/
|
|
5
10
|
export declare class ModifyIncomingRequestPhase<Req, Res> implements IPhase<Req, Res> {
|
|
6
11
|
protected readonly products: IProduct<any, Req, Res>[];
|
|
7
12
|
constructor(products: IProduct<any, Req, Res>[]);
|
|
@@ -4,6 +4,11 @@ import { IPhase } from '../IPhase';
|
|
|
4
4
|
import { PhaseResult } from '../PhaseResult';
|
|
5
5
|
import { IConfiguration } from '../../config';
|
|
6
6
|
import { ISnippetInjector, ISnippetRetriever } from '../../snippet_injection';
|
|
7
|
+
/**
|
|
8
|
+
* The `ModifyOutgoingResponsePhase` class is responsible for modifying the outgoing HTTP response prior to returning it
|
|
9
|
+
* to the end user. This phase invokes each product's `modifyOutgoingResponse` method, as well as adding the PXHD cookie.
|
|
10
|
+
* If snippet injection is supported and enabled, it also occurs in this phase.
|
|
11
|
+
*/
|
|
7
12
|
export declare class ModifyOutgoingResponsePhase<Req, Res, Added, Removed> implements IPhase<Req, Res> {
|
|
8
13
|
protected readonly config: IConfiguration<Req, Res, Added, Removed>;
|
|
9
14
|
protected readonly products: IProduct<any, Req, Res>[];
|
|
@@ -2,6 +2,9 @@ import { IPhase } from '../IPhase';
|
|
|
2
2
|
import { ITokenParser } from '../../risk_token';
|
|
3
3
|
import { PhaseResult } from '../PhaseResult';
|
|
4
4
|
import { IContext, TokenData } from '../../context';
|
|
5
|
+
/**
|
|
6
|
+
* The `ParseTokenPhase` class is responsible for parsing the risk token from the incoming request and updating the context.
|
|
7
|
+
*/
|
|
5
8
|
export declare class ParseTokenPhase<Req, Res> implements IPhase<Req, Res> {
|
|
6
9
|
protected readonly tokenParser: ITokenParser<Req, Res>;
|
|
7
10
|
constructor(tokenParser: ITokenParser<Req, Res>);
|
|
@@ -3,6 +3,10 @@ import { IContext } from '../../context';
|
|
|
3
3
|
import { PhaseResult } from '../PhaseResult';
|
|
4
4
|
import { ICors } from '../../cors';
|
|
5
5
|
import { IConfiguration } from '../../config';
|
|
6
|
+
/**
|
|
7
|
+
* The `PreflightPhase` class is responsible for handling preflight requests in CORS (Cross-Origin Resource Sharing).
|
|
8
|
+
* This includes filtering preflight requests or invoking the preflight custom handler if configured.
|
|
9
|
+
*/
|
|
6
10
|
export declare class PreflightPhase<Req, Res, Added, Removed> implements IPhase<Req, Res> {
|
|
7
11
|
protected readonly corsSupportEnabled: boolean;
|
|
8
12
|
protected readonly filterPreflightRequestsEnabled: boolean;
|
|
@@ -3,6 +3,11 @@ import { IRiskApiClient } from '../../risk_api';
|
|
|
3
3
|
import { Products } from '../../products';
|
|
4
4
|
import { PhaseResult } from '../PhaseResult';
|
|
5
5
|
import { DecideActionPhase } from './DecideActionPhase';
|
|
6
|
+
/**
|
|
7
|
+
* The `RiskApiPhase` class is responsible for making the synchronous Risk API request when necessary. If a Risk API call
|
|
8
|
+
* is made, it will also update the context with the Risk API response, product data (invoking each product's
|
|
9
|
+
* `enrichContextFromRiskApi` method), and update the context decision.
|
|
10
|
+
*/
|
|
6
11
|
export declare class RiskApiPhase<Req, Res> extends DecideActionPhase<Req, Res> {
|
|
7
12
|
protected readonly products: Products<Req, Res>;
|
|
8
13
|
protected readonly riskApiClient: IRiskApiClient<Req, Res>;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { IContext } from '../../context';
|
|
2
2
|
import { IActivityClient } from '../../activities';
|
|
3
|
-
import { IPhase } from '../IPhase';
|
|
4
3
|
import { PhaseResult } from '../PhaseResult';
|
|
5
|
-
|
|
4
|
+
import { IPhase } from '../IPhase';
|
|
5
|
+
/**
|
|
6
|
+
* The `SendAsyncActivitiesPhase` class is responsible for sending all necessary asynchronous activities based on the context.
|
|
7
|
+
*/
|
|
8
|
+
export declare class SendAsyncActivitiesPhase<Req, Res> implements IPhase<Req, Res> {
|
|
6
9
|
protected readonly activityClient: IActivityClient<Req, Res>;
|
|
7
10
|
constructor(activityClient: IActivityClient<Req, Res>);
|
|
8
11
|
execute(context: IContext<Req, Res>): Promise<PhaseResult>;
|
|
@@ -3,6 +3,9 @@ import { IPhase } from '../IPhase';
|
|
|
3
3
|
import { PhaseResult } from '../PhaseResult';
|
|
4
4
|
import { IConfiguration } from '../../config';
|
|
5
5
|
import { ILogServiceClient } from '../../logger';
|
|
6
|
+
/**
|
|
7
|
+
* The `SendLogsPhase` class is responsible for sending logs to the HUMAN logging service.
|
|
8
|
+
*/
|
|
6
9
|
export declare class SendLogsPhase<Req, Res, Added, Removed> implements IPhase<Req, Res> {
|
|
7
10
|
private readonly logServiceClient;
|
|
8
11
|
constructor(_config: IConfiguration<Req, Res, Added, Removed>, logServiceClient: ILogServiceClient<Req, Res>);
|
|
@@ -2,6 +2,9 @@ import { IPhase } from '../IPhase';
|
|
|
2
2
|
import { PhaseResult } from '../PhaseResult';
|
|
3
3
|
import { IContext } from '../../context';
|
|
4
4
|
import { ITelemetry } from '../../telemetry';
|
|
5
|
+
/**
|
|
6
|
+
* The `SendTelemetryActivityPhase` class is responsible for sending the telemetry activity if necessary.
|
|
7
|
+
*/
|
|
5
8
|
export declare class SendTelemetryActivityPhase<Req, Res> implements IPhase<Req, Res> {
|
|
6
9
|
protected readonly telemetry: ITelemetry<Req, Res>;
|
|
7
10
|
constructor(telemetry: ITelemetry<Req, Res>);
|
|
@@ -2,6 +2,9 @@ import { IConfiguration, IRemoteConfigManager } from '../../config';
|
|
|
2
2
|
import { IContext } from '../../context';
|
|
3
3
|
import { IPhase } from '../IPhase';
|
|
4
4
|
import { PhaseResult } from '../PhaseResult';
|
|
5
|
+
/**
|
|
6
|
+
* The `UpdateRemoteConfigPhase` class is responsible for updating the remote configuration if necessary.
|
|
7
|
+
*/
|
|
5
8
|
export declare class UpdateRemoteConfigPhase<Req, Res, Added, Removed> implements IPhase<Req, Res> {
|
|
6
9
|
protected readonly config: IConfiguration<Req, Res, Added, Removed>;
|
|
7
10
|
protected readonly remoteConfigManager: IRemoteConfigManager<Req, Res>;
|
|
@@ -9,8 +9,7 @@ export * from './CreateBlockResponsePhase';
|
|
|
9
9
|
export * from './ModifyIncomingRequestPhase';
|
|
10
10
|
export * from './EnrichContextFromResponsePhase';
|
|
11
11
|
export * from './ModifyOutgoingResponsePhase';
|
|
12
|
-
export * from './
|
|
13
|
-
export * from './SendAsyncActivitiesOnResponsePhase';
|
|
12
|
+
export * from './SendAsyncActivitiesPhase';
|
|
14
13
|
export * from './AdditionalActivityHandlerPhase';
|
|
15
14
|
export * from './CompositePhase';
|
|
16
15
|
export * from './SendLogsPhase';
|
package/lib/types/products/credential_intelligence/endpoint/CredentialEndpointConfiguration.d.ts
CHANGED
|
@@ -43,7 +43,7 @@ export type CredentialEndpointConfiguration<Req, Res> = {
|
|
|
43
43
|
/**
|
|
44
44
|
* The method by which the module will determine whether the login request was successful.
|
|
45
45
|
*/
|
|
46
|
-
login_successful_reporting_method?:
|
|
46
|
+
login_successful_reporting_method?: `${LoginSuccessfulReportingMethod}`;
|
|
47
47
|
/**
|
|
48
48
|
* An array of HTTP statuses signifying a successful login. All other status codes
|
|
49
49
|
* will be treated as unsuccessful login attempts.
|
|
@@ -2,6 +2,6 @@ import { IOutgoingResponse } from '../../../../http';
|
|
|
2
2
|
import { ILoginSuccessfulParser } from './ILoginSuccessfulParser';
|
|
3
3
|
export declare class BodyLoginSuccessfulParser<Res> implements ILoginSuccessfulParser<Res> {
|
|
4
4
|
protected readonly bodyRegex: RegExp;
|
|
5
|
-
constructor(regex: RegExp
|
|
5
|
+
constructor(regex: RegExp);
|
|
6
6
|
isLoginSuccessful(response: IOutgoingResponse<Res>): Promise<boolean>;
|
|
7
7
|
}
|
|
@@ -2,10 +2,38 @@ import { AsyncOrSync } from 'ts-essentials';
|
|
|
2
2
|
import { ReadonlyContext } from '../../context';
|
|
3
3
|
import { ProductName } from '../utils';
|
|
4
4
|
import { ProductDataType } from './ProductDataType';
|
|
5
|
+
/**
|
|
6
|
+
* A product interface that allows for enriching the request context and modifying the HTTP request and response.
|
|
7
|
+
*/
|
|
5
8
|
export interface IProduct<Name extends ProductName, Req, Res> {
|
|
9
|
+
/**
|
|
10
|
+
* Enriches the context with product-specific data from the incoming request prior to performing a Risk API request.
|
|
11
|
+
* @param context - The request context.
|
|
12
|
+
* @returns {AsyncOrSync<ProductDataType<Name> | null>} - The relevant product data or null if no data is available.
|
|
13
|
+
*/
|
|
6
14
|
enrichContextFromRequest(context: ReadonlyContext<Req, Res>): AsyncOrSync<ProductDataType<Name> | null>;
|
|
15
|
+
/**
|
|
16
|
+
* Enriches the context with product-specific data from the Risk API response.
|
|
17
|
+
* @param context - The request context.
|
|
18
|
+
* @returns {AsyncOrSync<Partial<ProductDataType<Name>> | null>} - The relevant product data or null if no data is available.
|
|
19
|
+
*/
|
|
7
20
|
enrichContextFromRiskApi(context: ReadonlyContext<Req, Res>): AsyncOrSync<Partial<ProductDataType<Name>> | null>;
|
|
21
|
+
/**
|
|
22
|
+
* Modifies the incoming HTTP request as needed for the product.
|
|
23
|
+
* @param context - The request context.
|
|
24
|
+
* @returns {AsyncOrSync<void>} - A promise that resolves when the modification is complete.
|
|
25
|
+
*/
|
|
8
26
|
modifyIncomingRequest(context: ReadonlyContext<Req, Res>): AsyncOrSync<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Enriches the context with product-specific data from the HTTP response.
|
|
29
|
+
* @param context - The request context.
|
|
30
|
+
* @returns {AsyncOrSync<Partial<ProductDataType<Name>> | null>} - The relevant product data or null if no data is available.
|
|
31
|
+
*/
|
|
9
32
|
enrichContextFromResponse(context: ReadonlyContext<Req, Res>): AsyncOrSync<Partial<ProductDataType<Name>> | null>;
|
|
33
|
+
/**
|
|
34
|
+
* Modifies the outgoing HTTP response as needed for the product.
|
|
35
|
+
* @param context - The request context.
|
|
36
|
+
* @returns {AsyncOrSync<void>} - A promise that resolves when the modification is complete.
|
|
37
|
+
*/
|
|
10
38
|
modifyOutgoingResponse(context: ReadonlyContext<Req, Res>): AsyncOrSync<void>;
|
|
11
39
|
}
|
|
@@ -2,5 +2,5 @@ import { ProductName } from '../utils';
|
|
|
2
2
|
import { BotDefenderData } from '../bot_defender';
|
|
3
3
|
import { CredentialIntelligenceData } from '../credential_intelligence';
|
|
4
4
|
import { AccountDefenderData } from '../account_defender';
|
|
5
|
-
import { HypeSaleChallengeData } from '../hype_sale_challenge
|
|
5
|
+
import { HypeSaleChallengeData } from '../hype_sale_challenge';
|
|
6
6
|
export type ProductDataType<Name extends ProductName> = Name extends ProductName.BOT_DEFENDER ? BotDefenderData : Name extends ProductName.CREDENTIAL_INTELLIGENCE ? CredentialIntelligenceData : Name extends ProductName.ACCOUNT_DEFENDER ? AccountDefenderData : Name extends ProductName.HYPE_SALE_CHALLENGE ? HypeSaleChallengeData : never;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { RiskApiClientBase } from './abstract';
|
|
2
|
+
import { IConfiguration } from '../../config';
|
|
3
|
+
import { IHttpClient, IIncomingResponse, OutgoingRequestImpl, ReadonlyHeaders } from '../../http';
|
|
4
|
+
import { ReadonlyContext } from '../../context';
|
|
5
|
+
import { IRiskResponse } from '../risk_response';
|
|
6
|
+
import { RiskActivity } from '../model';
|
|
7
|
+
export declare class GetRiskApiClientV2<Req, Res, Added, Removed> extends RiskApiClientBase<Req, Res, Added, Removed> {
|
|
8
|
+
constructor(config: IConfiguration<Req, Res, Added, Removed>, httpClient: IHttpClient);
|
|
9
|
+
protected createRiskRequest(context: ReadonlyContext<Req, Res>): OutgoingRequestImpl;
|
|
10
|
+
protected getRiskActivityHeaders(context: ReadonlyContext<Req, Res>): ReadonlyHeaders;
|
|
11
|
+
protected getRequestHeadersForRisk(context: ReadonlyContext<Req, Res>): Record<string, string[]>;
|
|
12
|
+
protected riskActivityToHeaders(riskActivity: RiskActivity): Record<string, string[]>;
|
|
13
|
+
private addHeadersFromObject;
|
|
14
|
+
protected createRiskResponse(response: IIncomingResponse): IRiskResponse;
|
|
15
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IConfiguration } from '../../config';
|
|
2
2
|
import { IHttpClient, IIncomingResponse } from '../../http';
|
|
3
3
|
import { IRiskResponse } from '../risk_response';
|
|
4
|
-
import { PostRiskApiClientBase } from './
|
|
4
|
+
import { PostRiskApiClientBase } from './abstract';
|
|
5
5
|
export declare class PostRiskApiClientV2<Req, Res, Added, Removed> extends PostRiskApiClientBase<Req, Res, Added, Removed> {
|
|
6
6
|
constructor(config: IConfiguration<Req, Res, Added, Removed>, httpClient: IHttpClient);
|
|
7
7
|
protected createRiskResponse(response: IIncomingResponse): IRiskResponse;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IConfiguration } from '../../config';
|
|
2
2
|
import { IHttpClient, IIncomingResponse } from '../../http';
|
|
3
3
|
import { IRiskResponse } from '../risk_response';
|
|
4
|
-
import {
|
|
4
|
+
import { PostRiskApiClientBase } from './abstract';
|
|
5
5
|
export declare class PostRiskApiClientV3<Req, Res, Added, Removed> extends PostRiskApiClientBase<Req, Res, Added, Removed> {
|
|
6
6
|
constructor(config: IConfiguration<Req, Res, Added, Removed>, httpClient: IHttpClient);
|
|
7
7
|
protected createRiskResponse(response: IIncomingResponse): IRiskResponse;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AsyncOrSync } from 'ts-essentials';
|
|
2
|
-
import { ReadonlyContext, RiskApiData } from '
|
|
2
|
+
import { ReadonlyContext, RiskApiData } from '../../../context';
|
|
3
3
|
export interface IRiskApiClient<Req, Res> {
|
|
4
4
|
executeRiskApi(context: ReadonlyContext<Req, Res>): AsyncOrSync<RiskApiData>;
|
|
5
5
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RiskApiClientBase } from './RiskApiClientBase';
|
|
2
|
+
import { OutgoingRequestImpl } from '../../../http';
|
|
3
|
+
import { ReadonlyContext } from '../../../context';
|
|
4
|
+
import { ReadonlyHeaders } from '../../../http';
|
|
5
|
+
export declare abstract class PostRiskApiClientBase<Req, Res, Added, Removed> extends RiskApiClientBase<Req, Res, Added, Removed> {
|
|
6
|
+
protected createRiskRequest(context: ReadonlyContext<Req, Res>): OutgoingRequestImpl;
|
|
7
|
+
protected getRiskHeaders(): ReadonlyHeaders;
|
|
8
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ReadonlyContext, RiskApiData } from '../../../context';
|
|
2
|
+
import { IConfiguration } from '../../../config';
|
|
3
|
+
import { IHttpClient, IIncomingResponse, OutgoingRequestImpl, ReadonlyHeaders } from '../../../http';
|
|
4
|
+
import { HeaderEntry } from '../../../activities';
|
|
5
|
+
import { IRiskResponse } from '../../risk_response';
|
|
6
|
+
import { IRiskApiClient } from './IRiskApiClient';
|
|
7
|
+
export declare abstract class RiskApiClientBase<Req, Res, Added, Removed> implements IRiskApiClient<Req, Res> {
|
|
8
|
+
protected readonly config: IConfiguration<Req, Res, Added, Removed>;
|
|
9
|
+
protected readonly httpClient: IHttpClient;
|
|
10
|
+
protected constructor(config: IConfiguration<Req, Res, Added, Removed>, httpClient: IHttpClient);
|
|
11
|
+
protected abstract createRiskRequest(context: ReadonlyContext<Req, Res>): OutgoingRequestImpl;
|
|
12
|
+
protected abstract createRiskResponse(response: IIncomingResponse): IRiskResponse;
|
|
13
|
+
/**
|
|
14
|
+
* Builds the Risk API activity, sends the request, and returns RiskApiData with the response.
|
|
15
|
+
* @param context
|
|
16
|
+
* @returns Promise<RiskApiData>
|
|
17
|
+
*/
|
|
18
|
+
executeRiskApi(context: ReadonlyContext<Req, Res>): Promise<RiskApiData>;
|
|
19
|
+
protected formatRiskHeadersField(headers: ReadonlyHeaders): HeaderEntry[];
|
|
20
|
+
protected sendRiskActivity(riskRequest: OutgoingRequestImpl, riskApiData: RiskApiData, context: ReadonlyContext<Req, Res>): Promise<IIncomingResponse>;
|
|
21
|
+
protected getRiskUrl(): string;
|
|
22
|
+
protected getRiskHeaders(): ReadonlyHeaders;
|
|
23
|
+
protected handleS2STimeout(riskApiData: RiskApiData): RiskApiData;
|
|
24
|
+
protected handleS2SError(riskApiData: RiskApiData, context: ReadonlyContext<Req, Res>, response?: IIncomingResponse, error?: unknown): Promise<RiskApiData>;
|
|
25
|
+
}
|
|
26
|
+
export declare const isEnforcerTimeoutError: (err: unknown) => boolean;
|