perimeterx-js-core 0.7.0 → 0.8.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/action/utils.js +1 -1
- package/lib/activities/HttpActivityClient.d.ts +5 -5
- package/lib/activities/HttpActivityClient.js +28 -39
- package/lib/activities/HttpBatchedActivityClient.d.ts +2 -2
- package/lib/activities/HttpBatchedActivityClient.js +19 -32
- package/lib/activities/model/AsyncActivity.d.ts +14 -0
- package/lib/activities/model/{ActivityDetails.d.ts → AsyncActivityDetails.d.ts} +6 -23
- package/lib/activities/model/CommonActivityDetails.d.ts +40 -0
- package/lib/activities/model/CommonActivityDetails.js +1 -0
- package/lib/activities/model/HeaderEntry.d.ts +4 -0
- package/lib/activities/model/HeaderEntry.js +1 -0
- package/lib/activities/model/index.d.ts +4 -2
- package/lib/activities/model/index.js +4 -2
- package/lib/activities/utils.d.ts +6071 -9
- package/lib/activities/utils.js +111 -35
- package/lib/additional_activity_handler/AdditionalActivityHandler.d.ts +1 -1
- package/lib/additional_activity_handler/AdditionalActivityHandlerUtils.js +4 -12
- package/lib/config/ConfigurationParams.d.ts +2 -1
- package/lib/config/DefaultConfigurations.js +1 -0
- package/lib/config/IConfiguration.d.ts +5 -1
- package/lib/config/StaticConfigurationBase.d.ts +2 -1
- package/lib/config/StaticConfigurationBase.js +6 -1
- package/lib/context/DefaultContext.d.ts +1 -1
- package/lib/context/DefaultContext.js +40 -8
- package/lib/context/interfaces/RiskApiData.d.ts +4 -0
- package/lib/cors/DefaultCors.js +21 -31
- package/lib/custom_parameters/CustomParametersUtils.js +3 -12
- package/lib/enforcer/EnforcerBase.d.ts +2 -1
- package/lib/enforcer/EnforcerBase.js +56 -57
- package/lib/enforcer/options/EnforcerBaseOptions.d.ts +2 -0
- package/lib/graphql/DefaultGraphQLParser.js +30 -39
- package/lib/http/index.d.ts +0 -1
- package/lib/http/index.js +0 -1
- package/lib/http/interfaces/IBody.d.ts +3 -2
- package/lib/http/interfaces/IIncomingRequest.d.ts +4 -0
- package/lib/http/interfaces/IURL.d.ts +3 -0
- package/lib/http/interfaces/IURLSearchParams.d.ts +9 -0
- package/lib/http/interfaces/IURLSearchParams.js +1 -0
- package/lib/http/interfaces/index.d.ts +1 -0
- package/lib/http/interfaces/index.js +1 -0
- package/lib/http/{impl → utils}/FormDataImpl.js +4 -4
- package/lib/http/{impl → utils}/MinimalResponseImpl.js +3 -0
- package/lib/http/utils/MinimalResponseUtils.js +5 -7
- package/lib/http/utils/MultipartFormDataUtils.js +4 -5
- package/lib/http/{impl → utils}/OutgoingRequestImpl.d.ts +1 -1
- package/lib/http/{impl → utils}/OutgoingRequestImpl.js +5 -1
- package/lib/http/utils/URLUtils.d.ts +7 -0
- package/lib/http/utils/URLUtils.js +62 -0
- package/lib/http/utils/UrlImpl.d.ts +18 -0
- package/lib/http/utils/UrlImpl.js +54 -0
- package/lib/http/utils/UrlSearchParamsImpl.d.ts +19 -0
- package/lib/http/utils/UrlSearchParamsImpl.js +116 -0
- package/lib/http/utils/index.d.ts +6 -0
- package/lib/http/utils/index.js +6 -0
- package/lib/{utils → impl}/base64/AtobBase64Utils.d.ts +1 -1
- package/lib/{utils → impl}/base64/BufferBase64Utils.d.ts +1 -1
- package/lib/{utils → impl}/base64/BufferBase64Utils.js +1 -1
- package/lib/{utils → impl}/base64/JSBase64Base64Utils.d.ts +1 -1
- package/lib/{utils → impl}/cipher/CryptoCipherUtils.d.ts +1 -1
- package/lib/impl/cipher/CryptoCipherUtils.js +18 -0
- package/lib/{utils → impl}/cipher/SubtleCryptoCipherUtils.d.ts +1 -2
- package/lib/impl/cipher/SubtleCryptoCipherUtils.js +38 -0
- package/lib/{utils → impl}/hash/CryptoHashUtils.d.ts +1 -2
- package/lib/impl/hash/CryptoHashUtils.js +10 -0
- package/lib/{utils → impl}/hash/CryptoJSHashUtils.d.ts +1 -2
- package/lib/{utils → impl}/hash/CryptoJSHashUtils.js +1 -1
- package/lib/{utils → impl}/hash/SubtleCryptoHashUtils.d.ts +1 -2
- package/lib/impl/hash/SubtleCryptoHashUtils.js +21 -0
- package/lib/{utils → impl}/hmac/CryptoHmacUtils.d.ts +1 -2
- package/lib/{utils → impl}/hmac/CryptoHmacUtils.js +2 -1
- package/lib/{utils → impl}/hmac/CryptoJSHmacUtils.d.ts +1 -2
- package/lib/{utils → impl}/hmac/CryptoJSHmacUtils.js +1 -1
- package/lib/{http/impl → impl/http}/phin/PhinHttpClient.d.ts +1 -1
- package/lib/impl/http/phin/PhinHttpClient.js +31 -0
- package/lib/{http/impl → impl/http}/phin/PhinIncomingResponse.d.ts +2 -2
- package/lib/impl/http/phin/PhinIncomingResponse.js +23 -0
- package/lib/{utils → impl}/ip_range_checker/DefaultIpRangeChecker.d.ts +1 -1
- package/lib/{utils → impl}/request_id_generator/UuidRequestIdGenerator.d.ts +1 -1
- package/lib/{utils → impl}/url_parser/DefaultUrlParser.d.ts +4 -4
- package/lib/{utils → impl}/url_parser/DefaultUrlParser.js +9 -2
- package/lib/logger/HttpLogServiceClient.d.ts +17 -0
- package/lib/logger/HttpLogServiceClient.js +52 -0
- package/lib/logger/ILogServiceClient.d.ts +6 -0
- package/lib/logger/ILogServiceClient.js +1 -0
- package/lib/logger/ILogger.d.ts +6 -0
- package/lib/logger/LoggerBase.d.ts +6 -2
- package/lib/logger/LoggerBase.js +14 -1
- package/lib/logger/constants.d.ts +2 -0
- package/lib/logger/constants.js +2 -0
- package/lib/logger/index.d.ts +4 -0
- package/lib/logger/index.js +3 -0
- package/lib/logger/model/EnrichedLogRecord.d.ts +3 -0
- package/lib/logger/model/EnrichedLogRecord.js +1 -0
- package/lib/logger/model/LogMetadata.d.ts +9 -0
- package/lib/logger/model/LogMetadata.js +1 -0
- package/lib/logger/model/LogRecord.d.ts +6 -0
- package/lib/logger/model/LogRecord.js +1 -0
- package/lib/logger/model/index.d.ts +3 -0
- package/lib/logger/model/index.js +3 -0
- package/lib/phase/flow/EndEnforcerFlow.d.ts +6 -0
- package/lib/phase/flow/EndEnforcerFlow.js +10 -0
- package/lib/phase/flow/index.d.ts +1 -0
- package/lib/phase/flow/index.js +1 -0
- package/lib/phase/impl/AdditionalActivityHandlerPhase.js +4 -15
- package/lib/phase/impl/CompositePhase.js +9 -19
- package/lib/phase/impl/CreateBlockResponsePhase.js +24 -35
- package/lib/phase/impl/DecideActionPhase.js +11 -21
- package/lib/phase/impl/EnrichContextFromRequestPhase.js +28 -45
- package/lib/phase/impl/EnrichContextFromResponsePhase.js +12 -23
- package/lib/phase/impl/FilterPhase.js +3 -13
- package/lib/phase/impl/FirstPartyPhase.js +21 -32
- package/lib/phase/impl/ModifyIncomingRequestPhase.js +4 -14
- package/lib/phase/impl/ModifyOutgoingResponsePhase.js +7 -18
- package/lib/phase/impl/ParseTokenPhase.js +5 -15
- package/lib/phase/impl/PreflightPhase.js +12 -20
- package/lib/phase/impl/RiskApiPhase.js +24 -36
- package/lib/phase/impl/SendAsyncActivitiesOnRequestPhase.js +8 -20
- package/lib/phase/impl/SendAsyncActivitiesOnResponsePhase.js +4 -14
- package/lib/phase/impl/SendLogsPhase.d.ts +11 -0
- package/lib/phase/impl/SendLogsPhase.js +16 -0
- package/lib/phase/impl/TelemetryPhase.js +9 -21
- package/lib/phase/impl/index.d.ts +1 -0
- package/lib/phase/impl/index.js +1 -0
- package/lib/products/account_defender/AccountDefender.js +16 -35
- package/lib/products/bot_defender/BotDefender.js +51 -72
- package/lib/products/bot_defender/BotDefenderActionData.js +2 -0
- package/lib/products/bot_defender/block/DefaultBotDefenderBlocker.d.ts +4 -4
- package/lib/products/bot_defender/block/DefaultBotDefenderBlocker.js +5 -3
- package/lib/products/bot_defender/block/captcha/CaptchaBlocker.d.ts +7 -4
- package/lib/products/bot_defender/block/captcha/CaptchaBlocker.js +12 -8
- package/lib/products/bot_defender/block/captcha/HtmlCaptchaBlocker.d.ts +1 -1
- package/lib/products/bot_defender/block/captcha/HtmlCaptchaBlocker.js +1 -0
- package/lib/products/bot_defender/block/captcha/JsonCaptchaBlocker.d.ts +1 -1
- package/lib/products/bot_defender/block/captcha/JsonCaptchaBlocker.js +5 -4
- package/lib/products/bot_defender/block/captcha/MobileCaptchaBlocker.d.ts +2 -2
- package/lib/products/bot_defender/block/captcha/MobileCaptchaBlocker.js +2 -0
- package/lib/products/bot_defender/block/utils.js +1 -2
- package/lib/products/bot_defender/filter/DefaultBotDefenderFilter.js +7 -1
- package/lib/products/bot_defender/first_party/DefaultBotDefenderFirstParty.js +51 -68
- package/lib/products/bot_defender/first_party/constants.d.ts +0 -4
- package/lib/products/bot_defender/first_party/constants.js +0 -7
- package/lib/products/credential_intelligence/CredentialIntelligence.js +42 -63
- package/lib/products/credential_intelligence/endpoint/CredentialEndpoint.js +15 -23
- package/lib/products/credential_intelligence/endpoint/CredentialEndpointManager.js +9 -22
- package/lib/products/credential_intelligence/endpoint/extractor/BodyCredentialExtractor.d.ts +5 -5
- package/lib/products/credential_intelligence/endpoint/extractor/BodyCredentialExtractor.js +22 -33
- package/lib/products/credential_intelligence/endpoint/extractor/CustomCredentialExtractor.js +8 -18
- package/lib/products/credential_intelligence/endpoint/extractor/HeaderCredentialExtractor.js +2 -0
- package/lib/products/credential_intelligence/endpoint/extractor/QueryParamCredentialExtractor.d.ts +1 -1
- package/lib/products/credential_intelligence/endpoint/extractor/QueryParamCredentialExtractor.js +11 -16
- package/lib/products/credential_intelligence/endpoint/hash_protocol/MultistepHashProtocol.js +11 -21
- package/lib/products/credential_intelligence/endpoint/hash_protocol/SingleStepAndMultistepHashProtocol.js +9 -18
- package/lib/products/credential_intelligence/endpoint/hash_protocol/SingleStepHashProtocol.js +13 -25
- package/lib/products/credential_intelligence/endpoint/login_successful/BodyLoginSuccessfulParser.js +4 -14
- package/lib/products/credential_intelligence/endpoint/login_successful/CustomLoginSuccessfulParser.js +10 -20
- package/lib/products/credential_intelligence/endpoint/login_successful/HeaderLoginSuccessfulParser.js +7 -16
- package/lib/products/credential_intelligence/endpoint/login_successful/LoginSuccessfulParserFactory.js +7 -6
- package/lib/products/credential_intelligence/endpoint/login_successful/StatusLoginSuccessfulParser.js +3 -13
- package/lib/products/credential_intelligence/endpoint/matcher/ExactPathEndpointMatcher.js +2 -0
- package/lib/products/credential_intelligence/endpoint/matcher/RegexPathEndpointMatcher.js +2 -0
- package/lib/pxde/DefaultDataEnrichment.js +47 -61
- package/lib/pxhd/PXHDUtils.js +2 -2
- package/lib/risk_api/client/PostRiskApiClientBase.d.ts +7 -12
- package/lib/risk_api/client/PostRiskApiClientBase.js +70 -171
- package/lib/risk_api/model/RiskActivity.d.ts +5 -45
- package/lib/risk_api/risk_response/IRiskResponse.d.ts +1 -0
- package/lib/risk_api/risk_response/RiskResponseBase.d.ts +1 -0
- package/lib/risk_api/risk_response/RiskResponseBase.js +20 -33
- package/lib/risk_api/risk_response/v2/DefaultRiskResponseV2.d.ts +1 -1
- package/lib/risk_api/risk_response/v2/DefaultRiskResponseV2.js +3 -5
- package/lib/risk_api/risk_response/v2/RiskResponseV2Payload.d.ts +1 -0
- package/lib/risk_api/risk_response/v3/DefaultRiskResponseV3.js +2 -4
- package/lib/risk_api/risk_response/v3/RiskResponseV3Payload.d.ts +1 -0
- package/lib/risk_token/parser/TokenParserBase.js +25 -36
- package/lib/risk_token/token/TokenBase.js +24 -29
- package/lib/risk_token/token/v2/DefaultTokenV2.js +34 -49
- package/lib/risk_token/token/v3/DefaultTokenV3.js +63 -77
- package/lib/telemetry/DefaultTelemetry.js +46 -58
- package/lib/utils/base64/index.d.ts +0 -3
- package/lib/utils/base64/index.js +0 -3
- package/lib/utils/cipher/index.d.ts +1 -3
- package/lib/utils/cipher/index.js +1 -2
- package/lib/utils/constants.d.ts +2 -1
- package/lib/utils/constants.js +2 -1
- package/lib/utils/hash/index.d.ts +0 -3
- package/lib/utils/hash/index.js +0 -3
- package/lib/utils/hmac/index.d.ts +0 -2
- package/lib/utils/hmac/index.js +0 -2
- package/lib/utils/ip_range_checker/index.d.ts +1 -2
- package/lib/utils/ip_range_checker/index.js +1 -1
- package/lib/utils/request_id_generator/index.d.ts +1 -2
- package/lib/utils/request_id_generator/index.js +1 -1
- package/lib/utils/url_parser/index.d.ts +0 -1
- package/lib/utils/url_parser/index.js +0 -1
- package/lib/utils/utils.d.ts +1 -7
- package/lib/utils/utils.js +3 -25
- package/package.json +12 -6
- package/lib/activities/model/Activity.d.ts +0 -13
- package/lib/http/impl/index.d.ts +0 -4
- package/lib/http/impl/index.js +0 -4
- package/lib/http/impl/phin/PhinHttpClient.js +0 -41
- package/lib/http/impl/phin/PhinIncomingResponse.js +0 -38
- package/lib/utils/cipher/CryptoCipherUtils.js +0 -28
- package/lib/utils/cipher/SubtleCryptoCipherUtils.js +0 -47
- package/lib/utils/hash/CryptoHashUtils.js +0 -20
- package/lib/utils/hash/SubtleCryptoHashUtils.js +0 -31
- /package/lib/activities/model/{Activity.js → AsyncActivity.js} +0 -0
- /package/lib/activities/model/{ActivityDetails.js → AsyncActivityDetails.js} +0 -0
- /package/lib/http/{impl → utils}/FormDataImpl.d.ts +0 -0
- /package/lib/http/{impl → utils}/MinimalResponseImpl.d.ts +0 -0
- /package/lib/{utils → impl}/base64/AtobBase64Utils.js +0 -0
- /package/lib/{utils → impl}/base64/JSBase64Base64Utils.js +0 -0
- /package/lib/{http/impl → impl/http}/phin/index.d.ts +0 -0
- /package/lib/{http/impl → impl/http}/phin/index.js +0 -0
- /package/lib/{utils → impl}/ip_range_checker/DefaultIpRangeChecker.js +0 -0
- /package/lib/{utils → impl}/request_id_generator/UuidRequestIdGenerator.js +0 -0
package/lib/action/utils.js
CHANGED
|
@@ -5,7 +5,7 @@ export const getDecisionFromContext = (context) => {
|
|
|
5
5
|
};
|
|
6
6
|
export const getProductActions = (context) => {
|
|
7
7
|
return Object.entries(context.productData)
|
|
8
|
-
.filter(([_, data]) =>
|
|
8
|
+
.filter(([_, data]) => data?.action != null && data?.reason != null)
|
|
9
9
|
.map(([productName, data]) => ({
|
|
10
10
|
action: data.action,
|
|
11
11
|
reason: data.reason,
|
|
@@ -2,19 +2,19 @@ import { IConfiguration } from '../config';
|
|
|
2
2
|
import { ReadonlyContext } from '../context';
|
|
3
3
|
import { IHttpClient } from '../http';
|
|
4
4
|
import { IActivityClient } from './IActivityClient';
|
|
5
|
-
import {
|
|
5
|
+
import { AsyncActivity } from './model';
|
|
6
6
|
export declare class HttpActivityClient<Req, Res> implements IActivityClient<Req, Res> {
|
|
7
7
|
private readonly config;
|
|
8
8
|
private readonly httpClient;
|
|
9
9
|
constructor(config: IConfiguration<Req, Res>, httpClient: IHttpClient);
|
|
10
10
|
sendActivities(context: ReadonlyContext<Req, Res>): Promise<boolean>;
|
|
11
|
-
protected createActivities(context: ReadonlyContext<Req, Res>):
|
|
11
|
+
protected createActivities(context: ReadonlyContext<Req, Res>): AsyncActivity[];
|
|
12
12
|
/**
|
|
13
13
|
* Allows for expansions or alterations to the async activity if needed.
|
|
14
14
|
* @param activity
|
|
15
|
-
* @returns
|
|
15
|
+
* @returns AsyncActivity
|
|
16
16
|
* @protected
|
|
17
17
|
*/
|
|
18
|
-
protected finalizeActivity(activity:
|
|
19
|
-
protected postActivities(activities:
|
|
18
|
+
protected finalizeActivity(activity: AsyncActivity): AsyncActivity;
|
|
19
|
+
protected postActivities(activities: AsyncActivity[]): Promise<boolean>;
|
|
20
20
|
}
|
|
@@ -1,44 +1,35 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import { Action } from '../action';
|
|
11
2
|
import { AUTHORIZATION_HEADER_NAME, CONTENT_TYPE_HEADER_NAME, ContentType, HttpMethod, OutgoingRequestImpl, } from '../http';
|
|
12
3
|
import { getAuthorizationHeader } from '../utils';
|
|
13
4
|
import { ActivityType } from './ActivityType';
|
|
14
|
-
import {
|
|
5
|
+
import { createAsyncActivity } from './utils';
|
|
15
6
|
import { ACTIVITIES_ENDPOINT } from './constants';
|
|
16
7
|
export class HttpActivityClient {
|
|
8
|
+
config;
|
|
9
|
+
httpClient;
|
|
17
10
|
constructor(config, httpClient) {
|
|
18
11
|
this.config = config;
|
|
19
12
|
this.httpClient = httpClient;
|
|
20
13
|
}
|
|
21
|
-
sendActivities(context) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
});
|
|
14
|
+
async sendActivities(context) {
|
|
15
|
+
try {
|
|
16
|
+
const activities = this.createActivities(context);
|
|
17
|
+
return await this.postActivities(activities);
|
|
18
|
+
}
|
|
19
|
+
catch (e) {
|
|
20
|
+
this.config.logger.error(`unable to send activities - ${e}`);
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
32
23
|
}
|
|
33
24
|
createActivities(context) {
|
|
34
25
|
const activities = [];
|
|
35
26
|
if (context.action === Action.BLOCK || context.action === Action.SIMULATED_BLOCK) {
|
|
36
|
-
activities.push(
|
|
27
|
+
activities.push(createAsyncActivity(ActivityType.BLOCK, this.config, context));
|
|
37
28
|
}
|
|
38
29
|
else if (context.action === Action.PASS_REQUEST) {
|
|
39
|
-
activities.push(
|
|
30
|
+
activities.push(createAsyncActivity(ActivityType.PAGE_REQUESTED, this.config, context));
|
|
40
31
|
if (context.productData.ci && this.config.ciAutomaticAdditionalS2SEnabled) {
|
|
41
|
-
activities.push(
|
|
32
|
+
activities.push(createAsyncActivity(ActivityType.ADDITIONAL_S2S, this.config, context));
|
|
42
33
|
}
|
|
43
34
|
}
|
|
44
35
|
return activities.map(this.finalizeActivity);
|
|
@@ -46,25 +37,23 @@ export class HttpActivityClient {
|
|
|
46
37
|
/**
|
|
47
38
|
* Allows for expansions or alterations to the async activity if needed.
|
|
48
39
|
* @param activity
|
|
49
|
-
* @returns
|
|
40
|
+
* @returns AsyncActivity
|
|
50
41
|
* @protected
|
|
51
42
|
*/
|
|
52
43
|
finalizeActivity(activity) {
|
|
53
44
|
return activity;
|
|
54
45
|
}
|
|
55
|
-
postActivities(activities) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return (res === null || res === void 0 ? void 0 : res.status) === 200;
|
|
68
|
-
});
|
|
46
|
+
async postActivities(activities) {
|
|
47
|
+
const url = `${this.config.backendCollectorUrl}${ACTIVITIES_ENDPOINT}`;
|
|
48
|
+
const method = HttpMethod.POST;
|
|
49
|
+
const headers = {
|
|
50
|
+
[CONTENT_TYPE_HEADER_NAME]: [ContentType.APPLICATION_JSON],
|
|
51
|
+
[AUTHORIZATION_HEADER_NAME]: [getAuthorizationHeader(this.config.authToken)],
|
|
52
|
+
};
|
|
53
|
+
const body = activities.length === 1 ? JSON.stringify(activities[0]) : JSON.stringify(activities);
|
|
54
|
+
this.config.logger.debug(`sending ${activities.map(({ type }) => `${type} activity`).join(', ')} to ${url}`);
|
|
55
|
+
const req = new OutgoingRequestImpl({ url, method, headers, body });
|
|
56
|
+
const res = await this.httpClient.send(req);
|
|
57
|
+
return res?.status === 200;
|
|
69
58
|
}
|
|
70
59
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HttpActivityClient } from './HttpActivityClient';
|
|
2
2
|
import { IConfiguration } from '../config';
|
|
3
|
-
import {
|
|
3
|
+
import { AsyncActivity } from './model/AsyncActivity';
|
|
4
4
|
import { IHttpClient } from '../http';
|
|
5
5
|
export declare class HttpBatchedActivityClient<Req, Res> extends HttpActivityClient<Req, Res> {
|
|
6
6
|
private readonly batchSize;
|
|
@@ -10,7 +10,7 @@ export declare class HttpBatchedActivityClient<Req, Res> extends HttpActivityCli
|
|
|
10
10
|
private timeoutId;
|
|
11
11
|
constructor(config: IConfiguration<Req, Res>, httpClient: IHttpClient);
|
|
12
12
|
stop(): void;
|
|
13
|
-
protected postActivities(activities:
|
|
13
|
+
protected postActivities(activities: AsyncActivity[]): Promise<boolean>;
|
|
14
14
|
private addToBuffer;
|
|
15
15
|
private shouldFlush;
|
|
16
16
|
protected triggerFlush(): Promise<boolean>;
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import { HttpActivityClient } from './HttpActivityClient';
|
|
11
2
|
export class HttpBatchedActivityClient extends HttpActivityClient {
|
|
3
|
+
batchSize;
|
|
4
|
+
timeoutMs;
|
|
5
|
+
maxBufferSize;
|
|
6
|
+
buffer;
|
|
7
|
+
timeoutId;
|
|
12
8
|
constructor(config, httpClient) {
|
|
13
9
|
super(config, httpClient);
|
|
14
10
|
this.buffer = [];
|
|
@@ -20,11 +16,9 @@ export class HttpBatchedActivityClient extends HttpActivityClient {
|
|
|
20
16
|
stop() {
|
|
21
17
|
this.stopTimer();
|
|
22
18
|
}
|
|
23
|
-
postActivities(activities) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return this.shouldFlush() ? this.triggerFlush() : true;
|
|
27
|
-
});
|
|
19
|
+
async postActivities(activities) {
|
|
20
|
+
this.addToBuffer(activities);
|
|
21
|
+
return this.shouldFlush() ? this.triggerFlush() : true;
|
|
28
22
|
}
|
|
29
23
|
addToBuffer(activities) {
|
|
30
24
|
this.buffer = activities.concat(this.buffer);
|
|
@@ -35,25 +29,18 @@ export class HttpBatchedActivityClient extends HttpActivityClient {
|
|
|
35
29
|
shouldFlush() {
|
|
36
30
|
return this.buffer.length >= this.batchSize;
|
|
37
31
|
}
|
|
38
|
-
triggerFlush() {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return sentSuccessfully;
|
|
44
|
-
});
|
|
32
|
+
async triggerFlush() {
|
|
33
|
+
this.stopTimer();
|
|
34
|
+
const sentSuccessfully = this.buffer.length > 0 && (await this.flush());
|
|
35
|
+
this.startTimer();
|
|
36
|
+
return sentSuccessfully;
|
|
45
37
|
}
|
|
46
|
-
flush() {
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (sentSuccessfully) {
|
|
53
|
-
this.clear();
|
|
54
|
-
}
|
|
55
|
-
return sentSuccessfully;
|
|
56
|
-
});
|
|
38
|
+
async flush() {
|
|
39
|
+
const sentSuccessfully = await super.postActivities(this.buffer);
|
|
40
|
+
if (sentSuccessfully) {
|
|
41
|
+
this.clear();
|
|
42
|
+
}
|
|
43
|
+
return sentSuccessfully;
|
|
57
44
|
}
|
|
58
45
|
clear() {
|
|
59
46
|
this.buffer = [];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ActivityType } from '../ActivityType';
|
|
2
|
+
import { AsyncActivityDetails } from './AsyncActivityDetails';
|
|
3
|
+
import { HeaderEntry } from './HeaderEntry';
|
|
4
|
+
export type AsyncActivity = {
|
|
5
|
+
type: ActivityType;
|
|
6
|
+
timestamp: number;
|
|
7
|
+
socket_ip: string;
|
|
8
|
+
url: string;
|
|
9
|
+
px_app_id: string;
|
|
10
|
+
headers?: HeaderEntry[];
|
|
11
|
+
vid?: string;
|
|
12
|
+
pxhd?: string;
|
|
13
|
+
details: AsyncActivityDetails;
|
|
14
|
+
};
|
|
@@ -1,34 +1,17 @@
|
|
|
1
|
-
import { GraphQLData } from '../../graphql';
|
|
2
1
|
import { BlockAction } from '../../blocker';
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { CommonActivityDetails } from './CommonActivityDetails';
|
|
3
|
+
import { RiskAdditionalData } from '../../risk_api';
|
|
4
|
+
export type AsyncActivityDetails = ActivityTypeDetails & AsyncActivityCommonDetails & CommonActivityDetails;
|
|
5
|
+
export type AsyncActivityCommonDetails = Partial<RiskAdditionalData> & {
|
|
5
6
|
client_uuid: string;
|
|
6
|
-
request_id: string;
|
|
7
|
-
module_version: string;
|
|
8
|
-
cookie_origin: string;
|
|
9
|
-
http_method: string;
|
|
10
|
-
http_version: string;
|
|
11
7
|
risk_rtt?: number;
|
|
8
|
+
additional_risk_info?: string;
|
|
12
9
|
http_status_code?: number;
|
|
13
|
-
request_cookie_names?: string[];
|
|
14
|
-
server_info_region?: string;
|
|
15
|
-
server_info_datacenter?: string;
|
|
16
|
-
tls_protocol?: string;
|
|
17
|
-
tls_cipher?: string;
|
|
18
|
-
tls_preferred_ciphers?: string;
|
|
19
|
-
tls_ciphers_sha?: string;
|
|
20
|
-
tls_ja3_fingerprint?: string;
|
|
21
|
-
graphql_operations?: GraphQLData[];
|
|
22
10
|
credentials_compromised?: boolean;
|
|
23
|
-
ci_version?: string;
|
|
24
|
-
sso_step?: string;
|
|
25
|
-
cross_tab_session?: string;
|
|
26
|
-
app_user_id?: string;
|
|
27
|
-
jwt_additional_fields?: Record<string, any>;
|
|
28
11
|
};
|
|
12
|
+
export type ActivityTypeDetails = PageRequestedActivityDetails | BlockActivityDetails | AdditionalS2SActivityDetails;
|
|
29
13
|
export type PageRequestedActivityDetails = {
|
|
30
14
|
pass_reason: string;
|
|
31
|
-
px_cookie?: string;
|
|
32
15
|
error_message?: string;
|
|
33
16
|
s2s_error_reason?: string;
|
|
34
17
|
s2s_error_http_status?: number;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { HttpMethod } from '../../http';
|
|
2
|
+
import { TokenOrigin } from '../../risk_token';
|
|
3
|
+
import { GraphQLData } from '../../graphql';
|
|
4
|
+
import { ModuleMode, VidSource } from '../../utils';
|
|
5
|
+
import { CredentialIntelligenceVersion, SsoStep } from '../../products';
|
|
6
|
+
import { CustomParameters } from '../../custom_parameters';
|
|
7
|
+
export type CommonActivityDetails = {
|
|
8
|
+
request_id: string;
|
|
9
|
+
module_version: string;
|
|
10
|
+
risk_mode: ModuleMode;
|
|
11
|
+
http_method: HttpMethod;
|
|
12
|
+
http_version?: string;
|
|
13
|
+
px_orig_cookie?: string;
|
|
14
|
+
px_cookie?: string;
|
|
15
|
+
px_cookie_hmac?: string;
|
|
16
|
+
tls_protocol?: string;
|
|
17
|
+
tls_server?: string;
|
|
18
|
+
tls_cipher?: string;
|
|
19
|
+
tls_ciphers_sha?: string;
|
|
20
|
+
tls_extension_sha?: string;
|
|
21
|
+
tls_preferred_ciphers?: string;
|
|
22
|
+
tls_ja3_fingerprint?: string;
|
|
23
|
+
enforcer_vid_source?: VidSource;
|
|
24
|
+
original_uuid?: string;
|
|
25
|
+
original_token_error?: string;
|
|
26
|
+
original_token?: string;
|
|
27
|
+
px_decoded_original_token?: string;
|
|
28
|
+
cookie_origin?: TokenOrigin;
|
|
29
|
+
request_cookie_names?: string[];
|
|
30
|
+
server_info_region?: string;
|
|
31
|
+
server_info_datacenter?: string;
|
|
32
|
+
cross_tab_session?: string;
|
|
33
|
+
app_user_id?: string;
|
|
34
|
+
jwt_additional_fields?: Record<string, any>;
|
|
35
|
+
graphql_operations?: GraphQLData[];
|
|
36
|
+
user?: string;
|
|
37
|
+
pass?: string;
|
|
38
|
+
ci_version?: CredentialIntelligenceVersion;
|
|
39
|
+
sso_step?: SsoStep;
|
|
40
|
+
} & CustomParameters;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|