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.
Files changed (216) hide show
  1. package/lib/action/utils.js +1 -1
  2. package/lib/activities/HttpActivityClient.d.ts +5 -5
  3. package/lib/activities/HttpActivityClient.js +28 -39
  4. package/lib/activities/HttpBatchedActivityClient.d.ts +2 -2
  5. package/lib/activities/HttpBatchedActivityClient.js +19 -32
  6. package/lib/activities/model/AsyncActivity.d.ts +14 -0
  7. package/lib/activities/model/{ActivityDetails.d.ts → AsyncActivityDetails.d.ts} +6 -23
  8. package/lib/activities/model/CommonActivityDetails.d.ts +40 -0
  9. package/lib/activities/model/CommonActivityDetails.js +1 -0
  10. package/lib/activities/model/HeaderEntry.d.ts +4 -0
  11. package/lib/activities/model/HeaderEntry.js +1 -0
  12. package/lib/activities/model/index.d.ts +4 -2
  13. package/lib/activities/model/index.js +4 -2
  14. package/lib/activities/utils.d.ts +6071 -9
  15. package/lib/activities/utils.js +111 -35
  16. package/lib/additional_activity_handler/AdditionalActivityHandler.d.ts +1 -1
  17. package/lib/additional_activity_handler/AdditionalActivityHandlerUtils.js +4 -12
  18. package/lib/config/ConfigurationParams.d.ts +2 -1
  19. package/lib/config/DefaultConfigurations.js +1 -0
  20. package/lib/config/IConfiguration.d.ts +5 -1
  21. package/lib/config/StaticConfigurationBase.d.ts +2 -1
  22. package/lib/config/StaticConfigurationBase.js +6 -1
  23. package/lib/context/DefaultContext.d.ts +1 -1
  24. package/lib/context/DefaultContext.js +40 -8
  25. package/lib/context/interfaces/RiskApiData.d.ts +4 -0
  26. package/lib/cors/DefaultCors.js +21 -31
  27. package/lib/custom_parameters/CustomParametersUtils.js +3 -12
  28. package/lib/enforcer/EnforcerBase.d.ts +2 -1
  29. package/lib/enforcer/EnforcerBase.js +56 -57
  30. package/lib/enforcer/options/EnforcerBaseOptions.d.ts +2 -0
  31. package/lib/graphql/DefaultGraphQLParser.js +30 -39
  32. package/lib/http/index.d.ts +0 -1
  33. package/lib/http/index.js +0 -1
  34. package/lib/http/interfaces/IBody.d.ts +3 -2
  35. package/lib/http/interfaces/IIncomingRequest.d.ts +4 -0
  36. package/lib/http/interfaces/IURL.d.ts +3 -0
  37. package/lib/http/interfaces/IURLSearchParams.d.ts +9 -0
  38. package/lib/http/interfaces/IURLSearchParams.js +1 -0
  39. package/lib/http/interfaces/index.d.ts +1 -0
  40. package/lib/http/interfaces/index.js +1 -0
  41. package/lib/http/{impl → utils}/FormDataImpl.js +4 -4
  42. package/lib/http/{impl → utils}/MinimalResponseImpl.js +3 -0
  43. package/lib/http/utils/MinimalResponseUtils.js +5 -7
  44. package/lib/http/utils/MultipartFormDataUtils.js +4 -5
  45. package/lib/http/{impl → utils}/OutgoingRequestImpl.d.ts +1 -1
  46. package/lib/http/{impl → utils}/OutgoingRequestImpl.js +5 -1
  47. package/lib/http/utils/URLUtils.d.ts +7 -0
  48. package/lib/http/utils/URLUtils.js +62 -0
  49. package/lib/http/utils/UrlImpl.d.ts +18 -0
  50. package/lib/http/utils/UrlImpl.js +54 -0
  51. package/lib/http/utils/UrlSearchParamsImpl.d.ts +19 -0
  52. package/lib/http/utils/UrlSearchParamsImpl.js +116 -0
  53. package/lib/http/utils/index.d.ts +6 -0
  54. package/lib/http/utils/index.js +6 -0
  55. package/lib/{utils → impl}/base64/AtobBase64Utils.d.ts +1 -1
  56. package/lib/{utils → impl}/base64/BufferBase64Utils.d.ts +1 -1
  57. package/lib/{utils → impl}/base64/BufferBase64Utils.js +1 -1
  58. package/lib/{utils → impl}/base64/JSBase64Base64Utils.d.ts +1 -1
  59. package/lib/{utils → impl}/cipher/CryptoCipherUtils.d.ts +1 -1
  60. package/lib/impl/cipher/CryptoCipherUtils.js +18 -0
  61. package/lib/{utils → impl}/cipher/SubtleCryptoCipherUtils.d.ts +1 -2
  62. package/lib/impl/cipher/SubtleCryptoCipherUtils.js +38 -0
  63. package/lib/{utils → impl}/hash/CryptoHashUtils.d.ts +1 -2
  64. package/lib/impl/hash/CryptoHashUtils.js +10 -0
  65. package/lib/{utils → impl}/hash/CryptoJSHashUtils.d.ts +1 -2
  66. package/lib/{utils → impl}/hash/CryptoJSHashUtils.js +1 -1
  67. package/lib/{utils → impl}/hash/SubtleCryptoHashUtils.d.ts +1 -2
  68. package/lib/impl/hash/SubtleCryptoHashUtils.js +21 -0
  69. package/lib/{utils → impl}/hmac/CryptoHmacUtils.d.ts +1 -2
  70. package/lib/{utils → impl}/hmac/CryptoHmacUtils.js +2 -1
  71. package/lib/{utils → impl}/hmac/CryptoJSHmacUtils.d.ts +1 -2
  72. package/lib/{utils → impl}/hmac/CryptoJSHmacUtils.js +1 -1
  73. package/lib/{http/impl → impl/http}/phin/PhinHttpClient.d.ts +1 -1
  74. package/lib/impl/http/phin/PhinHttpClient.js +31 -0
  75. package/lib/{http/impl → impl/http}/phin/PhinIncomingResponse.d.ts +2 -2
  76. package/lib/impl/http/phin/PhinIncomingResponse.js +23 -0
  77. package/lib/{utils → impl}/ip_range_checker/DefaultIpRangeChecker.d.ts +1 -1
  78. package/lib/{utils → impl}/request_id_generator/UuidRequestIdGenerator.d.ts +1 -1
  79. package/lib/{utils → impl}/url_parser/DefaultUrlParser.d.ts +4 -4
  80. package/lib/{utils → impl}/url_parser/DefaultUrlParser.js +9 -2
  81. package/lib/logger/HttpLogServiceClient.d.ts +17 -0
  82. package/lib/logger/HttpLogServiceClient.js +52 -0
  83. package/lib/logger/ILogServiceClient.d.ts +6 -0
  84. package/lib/logger/ILogServiceClient.js +1 -0
  85. package/lib/logger/ILogger.d.ts +6 -0
  86. package/lib/logger/LoggerBase.d.ts +6 -2
  87. package/lib/logger/LoggerBase.js +14 -1
  88. package/lib/logger/constants.d.ts +2 -0
  89. package/lib/logger/constants.js +2 -0
  90. package/lib/logger/index.d.ts +4 -0
  91. package/lib/logger/index.js +3 -0
  92. package/lib/logger/model/EnrichedLogRecord.d.ts +3 -0
  93. package/lib/logger/model/EnrichedLogRecord.js +1 -0
  94. package/lib/logger/model/LogMetadata.d.ts +9 -0
  95. package/lib/logger/model/LogMetadata.js +1 -0
  96. package/lib/logger/model/LogRecord.d.ts +6 -0
  97. package/lib/logger/model/LogRecord.js +1 -0
  98. package/lib/logger/model/index.d.ts +3 -0
  99. package/lib/logger/model/index.js +3 -0
  100. package/lib/phase/flow/EndEnforcerFlow.d.ts +6 -0
  101. package/lib/phase/flow/EndEnforcerFlow.js +10 -0
  102. package/lib/phase/flow/index.d.ts +1 -0
  103. package/lib/phase/flow/index.js +1 -0
  104. package/lib/phase/impl/AdditionalActivityHandlerPhase.js +4 -15
  105. package/lib/phase/impl/CompositePhase.js +9 -19
  106. package/lib/phase/impl/CreateBlockResponsePhase.js +24 -35
  107. package/lib/phase/impl/DecideActionPhase.js +11 -21
  108. package/lib/phase/impl/EnrichContextFromRequestPhase.js +28 -45
  109. package/lib/phase/impl/EnrichContextFromResponsePhase.js +12 -23
  110. package/lib/phase/impl/FilterPhase.js +3 -13
  111. package/lib/phase/impl/FirstPartyPhase.js +21 -32
  112. package/lib/phase/impl/ModifyIncomingRequestPhase.js +4 -14
  113. package/lib/phase/impl/ModifyOutgoingResponsePhase.js +7 -18
  114. package/lib/phase/impl/ParseTokenPhase.js +5 -15
  115. package/lib/phase/impl/PreflightPhase.js +12 -20
  116. package/lib/phase/impl/RiskApiPhase.js +24 -36
  117. package/lib/phase/impl/SendAsyncActivitiesOnRequestPhase.js +8 -20
  118. package/lib/phase/impl/SendAsyncActivitiesOnResponsePhase.js +4 -14
  119. package/lib/phase/impl/SendLogsPhase.d.ts +11 -0
  120. package/lib/phase/impl/SendLogsPhase.js +16 -0
  121. package/lib/phase/impl/TelemetryPhase.js +9 -21
  122. package/lib/phase/impl/index.d.ts +1 -0
  123. package/lib/phase/impl/index.js +1 -0
  124. package/lib/products/account_defender/AccountDefender.js +16 -35
  125. package/lib/products/bot_defender/BotDefender.js +51 -72
  126. package/lib/products/bot_defender/BotDefenderActionData.js +2 -0
  127. package/lib/products/bot_defender/block/DefaultBotDefenderBlocker.d.ts +4 -4
  128. package/lib/products/bot_defender/block/DefaultBotDefenderBlocker.js +5 -3
  129. package/lib/products/bot_defender/block/captcha/CaptchaBlocker.d.ts +7 -4
  130. package/lib/products/bot_defender/block/captcha/CaptchaBlocker.js +12 -8
  131. package/lib/products/bot_defender/block/captcha/HtmlCaptchaBlocker.d.ts +1 -1
  132. package/lib/products/bot_defender/block/captcha/HtmlCaptchaBlocker.js +1 -0
  133. package/lib/products/bot_defender/block/captcha/JsonCaptchaBlocker.d.ts +1 -1
  134. package/lib/products/bot_defender/block/captcha/JsonCaptchaBlocker.js +5 -4
  135. package/lib/products/bot_defender/block/captcha/MobileCaptchaBlocker.d.ts +2 -2
  136. package/lib/products/bot_defender/block/captcha/MobileCaptchaBlocker.js +2 -0
  137. package/lib/products/bot_defender/block/utils.js +1 -2
  138. package/lib/products/bot_defender/filter/DefaultBotDefenderFilter.js +7 -1
  139. package/lib/products/bot_defender/first_party/DefaultBotDefenderFirstParty.js +51 -68
  140. package/lib/products/bot_defender/first_party/constants.d.ts +0 -4
  141. package/lib/products/bot_defender/first_party/constants.js +0 -7
  142. package/lib/products/credential_intelligence/CredentialIntelligence.js +42 -63
  143. package/lib/products/credential_intelligence/endpoint/CredentialEndpoint.js +15 -23
  144. package/lib/products/credential_intelligence/endpoint/CredentialEndpointManager.js +9 -22
  145. package/lib/products/credential_intelligence/endpoint/extractor/BodyCredentialExtractor.d.ts +5 -5
  146. package/lib/products/credential_intelligence/endpoint/extractor/BodyCredentialExtractor.js +22 -33
  147. package/lib/products/credential_intelligence/endpoint/extractor/CustomCredentialExtractor.js +8 -18
  148. package/lib/products/credential_intelligence/endpoint/extractor/HeaderCredentialExtractor.js +2 -0
  149. package/lib/products/credential_intelligence/endpoint/extractor/QueryParamCredentialExtractor.d.ts +1 -1
  150. package/lib/products/credential_intelligence/endpoint/extractor/QueryParamCredentialExtractor.js +11 -16
  151. package/lib/products/credential_intelligence/endpoint/hash_protocol/MultistepHashProtocol.js +11 -21
  152. package/lib/products/credential_intelligence/endpoint/hash_protocol/SingleStepAndMultistepHashProtocol.js +9 -18
  153. package/lib/products/credential_intelligence/endpoint/hash_protocol/SingleStepHashProtocol.js +13 -25
  154. package/lib/products/credential_intelligence/endpoint/login_successful/BodyLoginSuccessfulParser.js +4 -14
  155. package/lib/products/credential_intelligence/endpoint/login_successful/CustomLoginSuccessfulParser.js +10 -20
  156. package/lib/products/credential_intelligence/endpoint/login_successful/HeaderLoginSuccessfulParser.js +7 -16
  157. package/lib/products/credential_intelligence/endpoint/login_successful/LoginSuccessfulParserFactory.js +7 -6
  158. package/lib/products/credential_intelligence/endpoint/login_successful/StatusLoginSuccessfulParser.js +3 -13
  159. package/lib/products/credential_intelligence/endpoint/matcher/ExactPathEndpointMatcher.js +2 -0
  160. package/lib/products/credential_intelligence/endpoint/matcher/RegexPathEndpointMatcher.js +2 -0
  161. package/lib/pxde/DefaultDataEnrichment.js +47 -61
  162. package/lib/pxhd/PXHDUtils.js +2 -2
  163. package/lib/risk_api/client/PostRiskApiClientBase.d.ts +7 -12
  164. package/lib/risk_api/client/PostRiskApiClientBase.js +70 -171
  165. package/lib/risk_api/model/RiskActivity.d.ts +5 -45
  166. package/lib/risk_api/risk_response/IRiskResponse.d.ts +1 -0
  167. package/lib/risk_api/risk_response/RiskResponseBase.d.ts +1 -0
  168. package/lib/risk_api/risk_response/RiskResponseBase.js +20 -33
  169. package/lib/risk_api/risk_response/v2/DefaultRiskResponseV2.d.ts +1 -1
  170. package/lib/risk_api/risk_response/v2/DefaultRiskResponseV2.js +3 -5
  171. package/lib/risk_api/risk_response/v2/RiskResponseV2Payload.d.ts +1 -0
  172. package/lib/risk_api/risk_response/v3/DefaultRiskResponseV3.js +2 -4
  173. package/lib/risk_api/risk_response/v3/RiskResponseV3Payload.d.ts +1 -0
  174. package/lib/risk_token/parser/TokenParserBase.js +25 -36
  175. package/lib/risk_token/token/TokenBase.js +24 -29
  176. package/lib/risk_token/token/v2/DefaultTokenV2.js +34 -49
  177. package/lib/risk_token/token/v3/DefaultTokenV3.js +63 -77
  178. package/lib/telemetry/DefaultTelemetry.js +46 -58
  179. package/lib/utils/base64/index.d.ts +0 -3
  180. package/lib/utils/base64/index.js +0 -3
  181. package/lib/utils/cipher/index.d.ts +1 -3
  182. package/lib/utils/cipher/index.js +1 -2
  183. package/lib/utils/constants.d.ts +2 -1
  184. package/lib/utils/constants.js +2 -1
  185. package/lib/utils/hash/index.d.ts +0 -3
  186. package/lib/utils/hash/index.js +0 -3
  187. package/lib/utils/hmac/index.d.ts +0 -2
  188. package/lib/utils/hmac/index.js +0 -2
  189. package/lib/utils/ip_range_checker/index.d.ts +1 -2
  190. package/lib/utils/ip_range_checker/index.js +1 -1
  191. package/lib/utils/request_id_generator/index.d.ts +1 -2
  192. package/lib/utils/request_id_generator/index.js +1 -1
  193. package/lib/utils/url_parser/index.d.ts +0 -1
  194. package/lib/utils/url_parser/index.js +0 -1
  195. package/lib/utils/utils.d.ts +1 -7
  196. package/lib/utils/utils.js +3 -25
  197. package/package.json +12 -6
  198. package/lib/activities/model/Activity.d.ts +0 -13
  199. package/lib/http/impl/index.d.ts +0 -4
  200. package/lib/http/impl/index.js +0 -4
  201. package/lib/http/impl/phin/PhinHttpClient.js +0 -41
  202. package/lib/http/impl/phin/PhinIncomingResponse.js +0 -38
  203. package/lib/utils/cipher/CryptoCipherUtils.js +0 -28
  204. package/lib/utils/cipher/SubtleCryptoCipherUtils.js +0 -47
  205. package/lib/utils/hash/CryptoHashUtils.js +0 -20
  206. package/lib/utils/hash/SubtleCryptoHashUtils.js +0 -31
  207. /package/lib/activities/model/{Activity.js → AsyncActivity.js} +0 -0
  208. /package/lib/activities/model/{ActivityDetails.js → AsyncActivityDetails.js} +0 -0
  209. /package/lib/http/{impl → utils}/FormDataImpl.d.ts +0 -0
  210. /package/lib/http/{impl → utils}/MinimalResponseImpl.d.ts +0 -0
  211. /package/lib/{utils → impl}/base64/AtobBase64Utils.js +0 -0
  212. /package/lib/{utils → impl}/base64/JSBase64Base64Utils.js +0 -0
  213. /package/lib/{http/impl → impl/http}/phin/index.d.ts +0 -0
  214. /package/lib/{http/impl → impl/http}/phin/index.js +0 -0
  215. /package/lib/{utils → impl}/ip_range_checker/DefaultIpRangeChecker.js +0 -0
  216. /package/lib/{utils → impl}/request_id_generator/UuidRequestIdGenerator.js +0 -0
@@ -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]) => (data === null || data === void 0 ? void 0 : data.action) != null && (data === null || data === void 0 ? void 0 : data.reason) != null)
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 { Activity } from './model';
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>): Activity[];
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 Activity
15
+ * @returns AsyncActivity
16
16
  * @protected
17
17
  */
18
- protected finalizeActivity(activity: Activity): Activity;
19
- protected postActivities(activities: Activity[]): Promise<boolean>;
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 { createActivity } from './utils';
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
- return __awaiter(this, void 0, void 0, function* () {
23
- try {
24
- const activities = this.createActivities(context);
25
- return yield this.postActivities(activities);
26
- }
27
- catch (e) {
28
- this.config.logger.error(`unable to send activities - ${e}`);
29
- return false;
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(createActivity(ActivityType.BLOCK, this.config, context));
27
+ activities.push(createAsyncActivity(ActivityType.BLOCK, this.config, context));
37
28
  }
38
29
  else if (context.action === Action.PASS_REQUEST) {
39
- activities.push(createActivity(ActivityType.PAGE_REQUESTED, this.config, context));
30
+ activities.push(createAsyncActivity(ActivityType.PAGE_REQUESTED, this.config, context));
40
31
  if (context.productData.ci && this.config.ciAutomaticAdditionalS2SEnabled) {
41
- activities.push(createActivity(ActivityType.ADDITIONAL_S2S, this.config, context));
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 Activity
40
+ * @returns AsyncActivity
50
41
  * @protected
51
42
  */
52
43
  finalizeActivity(activity) {
53
44
  return activity;
54
45
  }
55
- postActivities(activities) {
56
- return __awaiter(this, void 0, void 0, function* () {
57
- const url = `${this.config.backendCollectorUrl}${ACTIVITIES_ENDPOINT}`;
58
- const method = HttpMethod.POST;
59
- const headers = {
60
- [CONTENT_TYPE_HEADER_NAME]: [ContentType.APPLICATION_JSON],
61
- [AUTHORIZATION_HEADER_NAME]: [getAuthorizationHeader(this.config.authToken)],
62
- };
63
- const body = activities.length === 1 ? JSON.stringify(activities[0]) : JSON.stringify(activities);
64
- this.config.logger.debug(`sending ${activities.map(({ type }) => `${type} activity`).join(', ')} to ${url}`);
65
- const req = new OutgoingRequestImpl({ url, method, headers, body });
66
- const res = yield this.httpClient.send(req);
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 { Activity } from './model/Activity';
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: Activity[]): Promise<boolean>;
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
- return __awaiter(this, void 0, void 0, function* () {
25
- this.addToBuffer(activities);
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
- return __awaiter(this, void 0, void 0, function* () {
40
- this.stopTimer();
41
- const sentSuccessfully = this.buffer.length > 0 && (yield this.flush());
42
- this.startTimer();
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 _super = Object.create(null, {
48
- postActivities: { get: () => super.postActivities }
49
- });
50
- return __awaiter(this, void 0, void 0, function* () {
51
- const sentSuccessfully = yield _super.postActivities.call(this, this.buffer);
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
- export type ActivityTypeDetails = PageRequestedActivityDetails | BlockActivityDetails | AdditionalS2SActivityDetails;
4
- export type ActivityDetails = ActivityTypeDetails & {
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,4 @@
1
+ export type HeaderEntry = {
2
+ name: string;
3
+ value: string;
4
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,2 +1,4 @@
1
- export * from './Activity';
2
- export * from './ActivityDetails';
1
+ export * from './AsyncActivity';
2
+ export * from './AsyncActivityDetails';
3
+ export * from './HeaderEntry';
4
+ export * from './CommonActivityDetails';
@@ -1,2 +1,4 @@
1
- export * from './Activity';
2
- export * from './ActivityDetails';
1
+ export * from './AsyncActivity';
2
+ export * from './AsyncActivityDetails';
3
+ export * from './HeaderEntry';
4
+ export * from './CommonActivityDetails';