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
@@ -1,28 +1,20 @@
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
  export class PreflightPhase {
2
+ corsSupportEnabled;
3
+ filterPreflightRequestsEnabled;
4
+ cors;
11
5
  constructor(config, cors) {
12
6
  this.corsSupportEnabled = config.corsSupportEnabled;
13
7
  this.filterPreflightRequestsEnabled = config.corsPreflightRequestFilterEnabled;
14
8
  this.cors = cors;
15
9
  }
16
- execute(context) {
17
- return __awaiter(this, void 0, void 0, function* () {
18
- if (!this.corsSupportEnabled || !this.cors.isPreflightRequest(context)) {
19
- return { done: false };
20
- }
21
- const response = yield this.cors.runPreflightCustomHandler(context);
22
- if (response) {
23
- return { done: true, response };
24
- }
25
- return { done: this.filterPreflightRequestsEnabled };
26
- });
10
+ async execute(context) {
11
+ if (!this.corsSupportEnabled || !this.cors.isPreflightRequest(context)) {
12
+ return { done: false };
13
+ }
14
+ const response = await this.cors.runPreflightCustomHandler(context);
15
+ if (response) {
16
+ return { done: true, response };
17
+ }
18
+ return { done: this.filterPreflightRequestsEnabled };
27
19
  }
28
20
  }
@@ -1,46 +1,36 @@
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 { transferExistingProperties } from '../../utils';
12
3
  import { DecideActionPhase } from './DecideActionPhase';
4
+ import { ProductName } from '../../products';
13
5
  import { PXHDSource } from '../../pxhd';
14
6
  export class RiskApiPhase extends DecideActionPhase {
7
+ products;
8
+ riskApiClient;
15
9
  constructor(config, products, riskApiClient) {
16
10
  super(config);
17
11
  this.products = products;
18
12
  this.riskApiClient = riskApiClient;
19
13
  }
20
- execute(context) {
21
- return __awaiter(this, void 0, void 0, function* () {
22
- if (this.shouldTriggerRiskApi(context)) {
23
- yield this.triggerRiskApi(context);
24
- yield this.enrichContextFromRiskApi(context);
25
- yield this.updateContextDecision(context);
26
- }
27
- return { done: false };
28
- });
14
+ async execute(context) {
15
+ if (this.shouldTriggerRiskApi(context)) {
16
+ await this.triggerRiskApi(context);
17
+ await this.enrichContextFromRiskApi(context);
18
+ await this.updateContextDecision(context);
19
+ }
20
+ return { done: false };
29
21
  }
30
22
  shouldTriggerRiskApi(context) {
31
23
  return context.action === Action.TRIGGER_RISK_API;
32
24
  }
33
- triggerRiskApi(context) {
34
- return __awaiter(this, void 0, void 0, function* () {
35
- const riskApiData = yield this.riskApiClient.executeRiskApi(context);
36
- Object.assign(context.riskApiData, riskApiData);
37
- });
25
+ async triggerRiskApi(context) {
26
+ context.riskApiData.s2sCallReason =
27
+ context.reasons?.[ProductName.BOT_DEFENDER] || context.reasons?.[ProductName.CREDENTIAL_INTELLIGENCE];
28
+ const riskApiData = await this.riskApiClient.executeRiskApi(context);
29
+ Object.assign(context.riskApiData, riskApiData);
38
30
  }
39
- enrichContextFromRiskApi(context) {
40
- return __awaiter(this, void 0, void 0, function* () {
41
- this.addRiskApiDataToContext(context);
42
- yield this.enrichContextWithProductDataFromRiskApi(context);
43
- });
31
+ async enrichContextFromRiskApi(context) {
32
+ this.addRiskApiDataToContext(context);
33
+ await this.enrichContextWithProductDataFromRiskApi(context);
44
34
  }
45
35
  addRiskApiDataToContext(context) {
46
36
  const { riskResponse } = context.riskApiData;
@@ -64,13 +54,11 @@ export class RiskApiPhase extends DecideActionPhase {
64
54
  };
65
55
  }
66
56
  }
67
- enrichContextWithProductDataFromRiskApi(context) {
68
- return __awaiter(this, void 0, void 0, function* () {
69
- yield Promise.all(Object.entries(this.products).map(([name, product]) => __awaiter(this, void 0, void 0, function* () {
70
- if (context.productData[name]) {
71
- Object.assign(context.productData[name], yield (product === null || product === void 0 ? void 0 : product.enrichContextFromRiskApi(context)));
72
- }
73
- })));
74
- });
57
+ async enrichContextWithProductDataFromRiskApi(context) {
58
+ await Promise.all(Object.entries(this.products).map(async ([name, product]) => {
59
+ if (context.productData[name]) {
60
+ Object.assign(context.productData[name], await product?.enrichContextFromRiskApi(context));
61
+ }
62
+ }));
75
63
  }
76
64
  }
@@ -1,28 +1,16 @@
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
  export class SendAsyncActivitiesOnRequestPhase {
3
+ activityClient;
12
4
  constructor(activityClient) {
13
5
  this.activityClient = activityClient;
14
6
  }
15
- execute(context) {
16
- return __awaiter(this, void 0, void 0, function* () {
17
- if (context.action === Action.BLOCK) {
18
- yield this.sendAsyncActivity(context);
19
- }
20
- return { done: false };
21
- });
7
+ async execute(context) {
8
+ if (context.action === Action.BLOCK) {
9
+ await this.sendAsyncActivity(context);
10
+ }
11
+ return { done: false };
22
12
  }
23
- sendAsyncActivity(context) {
24
- return __awaiter(this, void 0, void 0, function* () {
25
- yield this.activityClient.sendActivities(context);
26
- });
13
+ async sendAsyncActivity(context) {
14
+ await this.activityClient.sendActivities(context);
27
15
  }
28
16
  }
@@ -1,20 +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
  export class SendAsyncActivitiesOnResponsePhase {
2
+ activityClient;
11
3
  constructor(activityClient) {
12
4
  this.activityClient = activityClient;
13
5
  }
14
- execute(context) {
15
- return __awaiter(this, void 0, void 0, function* () {
16
- yield this.activityClient.sendActivities(context);
17
- return { done: false };
18
- });
6
+ async execute(context) {
7
+ await this.activityClient.sendActivities(context);
8
+ return { done: false };
19
9
  }
20
10
  }
@@ -0,0 +1,11 @@
1
+ import { IContext } from '../../context';
2
+ import { IPhase } from '../IPhase';
3
+ import { PhaseResult } from '../PhaseResult';
4
+ import { IConfiguration } from '../../config';
5
+ import { ILogServiceClient } from '../../logger';
6
+ export declare class SendLogsPhase<Req, Res> implements IPhase<Req, Res> {
7
+ private readonly config;
8
+ private readonly logServiceClient;
9
+ constructor(config: IConfiguration<Req, Res>, logServiceClient: ILogServiceClient<Req, Res>);
10
+ execute(context: IContext<Req, Res>): Promise<PhaseResult>;
11
+ }
@@ -0,0 +1,16 @@
1
+ import { X_PX_ENFORCER_LOG_HEADER } from '../../logger';
2
+ export class SendLogsPhase {
3
+ config;
4
+ logServiceClient;
5
+ constructor(config, logServiceClient) {
6
+ this.config = config;
7
+ this.logServiceClient = logServiceClient;
8
+ }
9
+ async execute(context) {
10
+ const headerValue = context.requestData.headers[X_PX_ENFORCER_LOG_HEADER]?.[0];
11
+ if (headerValue == this.config.loggerAuthToken) {
12
+ await this.logServiceClient.sendLogs(context, this.config.logger.getLogs());
13
+ }
14
+ return { done: false };
15
+ }
16
+ }
@@ -1,29 +1,17 @@
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
  export class TelemetryPhase {
2
+ telemetry;
11
3
  constructor(telemetry) {
12
4
  this.telemetry = telemetry;
13
5
  }
14
- execute(context) {
15
- return __awaiter(this, void 0, void 0, function* () {
16
- if (yield this.telemetry.isValidTelemetryRequest(context)) {
17
- yield this.sendTelemetry(context);
18
- return { done: true };
19
- }
20
- return { done: false };
21
- });
6
+ async execute(context) {
7
+ if (await this.telemetry.isValidTelemetryRequest(context)) {
8
+ await this.sendTelemetry(context);
9
+ return { done: true };
10
+ }
11
+ return { done: false };
22
12
  }
23
13
  // Note: If await is not necessary, can be overridden
24
- sendTelemetry(context) {
25
- return __awaiter(this, void 0, void 0, function* () {
26
- yield this.telemetry.sendTelemetry(context);
27
- });
14
+ async sendTelemetry(context) {
15
+ await this.telemetry.sendTelemetry(context);
28
16
  }
29
17
  }
@@ -14,3 +14,4 @@ export * from './SendAsyncActivitiesOnRequestPhase';
14
14
  export * from './SendAsyncActivitiesOnResponsePhase';
15
15
  export * from './AdditionalActivityHandlerPhase';
16
16
  export * from './CompositePhase';
17
+ export * from './SendLogsPhase';
@@ -14,3 +14,4 @@ export * from './SendAsyncActivitiesOnRequestPhase';
14
14
  export * from './SendAsyncActivitiesOnResponsePhase';
15
15
  export * from './AdditionalActivityHandlerPhase';
16
16
  export * from './CompositePhase';
17
+ export * from './SendLogsPhase';
@@ -1,48 +1,30 @@
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 { getPropertyFromObject } from '../../utils';
11
2
  import { CROSS_TAB_SESSION_COOKIE_NAME } from './constants';
12
3
  export class AccountDefender {
4
+ config;
5
+ base64Utils;
13
6
  constructor(config, options) {
14
7
  this.config = config;
15
8
  this.base64Utils = options.base64Utils;
16
9
  }
17
- enrichContextFromRequest(context) {
18
- return __awaiter(this, void 0, void 0, function* () {
19
- const crossTabSession = context.requestData.cookies[CROSS_TAB_SESSION_COOKIE_NAME];
20
- const jwtData = this.getJwtData(context.requestData);
21
- return Object.assign({ crossTabSession }, jwtData);
22
- });
10
+ async enrichContextFromRequest(context) {
11
+ const crossTabSession = context.requestData.cookies[CROSS_TAB_SESSION_COOKIE_NAME];
12
+ const jwtData = this.getJwtData(context.requestData);
13
+ return { crossTabSession, ...jwtData };
23
14
  }
24
- enrichContextFromRiskApi(context) {
25
- return __awaiter(this, void 0, void 0, function* () {
26
- return;
27
- });
15
+ async enrichContextFromRiskApi(context) {
16
+ return;
28
17
  }
29
- enrichContextFromResponse(context) {
30
- return __awaiter(this, void 0, void 0, function* () {
31
- return;
32
- });
18
+ async enrichContextFromResponse(context) {
19
+ return;
33
20
  }
34
- modifyIncomingRequest(context) {
35
- return __awaiter(this, void 0, void 0, function* () {
36
- return;
37
- });
21
+ async modifyIncomingRequest(context) {
22
+ return;
38
23
  }
39
- modifyOutgoingResponse(context) {
40
- return __awaiter(this, void 0, void 0, function* () {
41
- return;
42
- });
24
+ async modifyOutgoingResponse(context) {
25
+ return;
43
26
  }
44
27
  getJwtData(requestData) {
45
- var _a;
46
28
  let jwtToken;
47
29
  let userIdFieldName;
48
30
  let additionalFieldNames;
@@ -54,7 +36,7 @@ export class AccountDefender {
54
36
  }
55
37
  }
56
38
  if (!jwtToken && this.config.jwtHeaderName) {
57
- jwtToken = (_a = requestData.headers[this.config.jwtHeaderName]) === null || _a === void 0 ? void 0 : _a[0];
39
+ jwtToken = requestData.headers[this.config.jwtHeaderName]?.[0];
58
40
  if (jwtToken) {
59
41
  userIdFieldName = this.config.jwtHeaderUserIdFieldName;
60
42
  additionalFieldNames = this.config.jwtHeaderAdditionalFieldNames;
@@ -84,9 +66,8 @@ export class AccountDefender {
84
66
  return null;
85
67
  }
86
68
  getDecodedJwt(jwt) {
87
- var _a;
88
69
  try {
89
- const encodedPayload = (_a = jwt.split('.')) === null || _a === void 0 ? void 0 : _a[1];
70
+ const encodedPayload = jwt.split('.')?.[1];
90
71
  const base64 = encodedPayload.replace('-', '+').replace('_', '/');
91
72
  return JSON.parse(this.base64Utils.base64Decode(base64));
92
73
  }
@@ -1,12 +1,3 @@
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 { TokenParseResult } from '../../risk_token';
12
3
  import { RiskApiCallResult } from '../../risk_api';
@@ -18,30 +9,31 @@ import { BotDefenderBlockReason, BotDefenderPassReason, BotDefenderS2SCallReason
18
9
  import { BotDefenderUtils } from './BotDefenderUtils';
19
10
  import { DefaultBotDefenderBlocker } from './block';
20
11
  export class BotDefender {
12
+ config;
13
+ firstParty;
14
+ filter;
15
+ blocker;
21
16
  constructor(config, options) {
22
- var _a, _b, _c;
23
17
  this.config = config;
24
- this.firstParty = (_a = options.firstParty) !== null && _a !== void 0 ? _a : new DefaultBotDefenderFirstParty(config);
25
- this.filter = (_b = options.filter) !== null && _b !== void 0 ? _b : new DefaultBotDefenderFilter(config, options.ipRangeChecker);
26
- this.blocker = (_c = options.blocker) !== null && _c !== void 0 ? _c : new DefaultBotDefenderBlocker(config, options.base64Utils);
18
+ this.firstParty = options.firstParty ?? new DefaultBotDefenderFirstParty(config);
19
+ this.filter = options.filter ?? new DefaultBotDefenderFilter(config, options.ipRangeChecker);
20
+ this.blocker = options.blocker ?? new DefaultBotDefenderBlocker(config, options.base64Utils);
27
21
  }
28
- handleFirstPartyRequest(context) {
29
- return __awaiter(this, void 0, void 0, function* () {
30
- return this.firstParty.handleFirstPartyRequest(context);
31
- });
22
+ async handleFirstPartyRequest(context) {
23
+ return this.firstParty.handleFirstPartyRequest(context);
32
24
  }
33
25
  shouldFilter(context) {
34
26
  return this.filter.shouldFilter(context);
35
27
  }
36
- enrichContextFromRequest(context) {
37
- var _a;
38
- return __awaiter(this, void 0, void 0, function* () {
39
- const isMonitoredRequest = this.isMonitoredRoute(context);
40
- const isSensitiveRequest = this.isSensitiveRequest(context) || ((_a = context.graphqlData) === null || _a === void 0 ? void 0 : _a.some((operation) => operation.sensitive));
41
- const actionData = yield this.getTokenAction(context, isMonitoredRequest, isSensitiveRequest);
42
- return Object.assign(Object.assign({}, actionData), { isMonitoredRequest,
43
- isSensitiveRequest });
44
- });
28
+ async enrichContextFromRequest(context) {
29
+ const isMonitoredRequest = this.isMonitoredRoute(context);
30
+ const isSensitiveRequest = this.isSensitiveRequest(context) || context.graphqlData?.some((operation) => operation.sensitive);
31
+ const actionData = await this.getTokenAction(context, isMonitoredRequest, isSensitiveRequest);
32
+ return {
33
+ ...actionData,
34
+ isMonitoredRequest,
35
+ isSensitiveRequest,
36
+ };
45
37
  }
46
38
  isMonitoredRoute(context) {
47
39
  return isMonitoredRequest(this.config, context);
@@ -50,28 +42,23 @@ export class BotDefender {
50
42
  // TODO: Include custom sensitive request function
51
43
  return isRouteInPatterns(url.pathname, this.config.sensitiveRoutes);
52
44
  }
53
- enrichContextFromResponse(context) {
54
- return __awaiter(this, void 0, void 0, function* () {
55
- return;
56
- });
57
- }
58
- getTokenAction(context, isMonitoredRequest, isSensitiveRequest) {
59
- return __awaiter(this, void 0, void 0, function* () {
60
- switch (context.tokenData.tokenParseResult) {
61
- case TokenParseResult.NONE:
62
- return new BotDefenderActionData(Action.TRIGGER_RISK_API, this.getNoTokenS2SCallReason(context));
63
- case TokenParseResult.DECRYPTION_FAILED:
64
- return new BotDefenderActionData(Action.TRIGGER_RISK_API, BotDefenderS2SCallReason.COOKIE_DECRYPTION_FAILED);
65
- case TokenParseResult.VALIDATION_FAILED:
66
- return new BotDefenderActionData(Action.TRIGGER_RISK_API, BotDefenderS2SCallReason.COOKIE_VALIDATION_FAILED);
67
- case TokenParseResult.SUCCESSFUL:
68
- return this.getActionForSuccessfulTokenParse(context, isMonitoredRequest, isSensitiveRequest);
69
- }
70
- });
45
+ async enrichContextFromResponse(context) {
46
+ return;
47
+ }
48
+ async getTokenAction(context, isMonitoredRequest, isSensitiveRequest) {
49
+ switch (context.tokenData.tokenParseResult) {
50
+ case TokenParseResult.NONE:
51
+ return new BotDefenderActionData(Action.TRIGGER_RISK_API, this.getNoTokenS2SCallReason(context));
52
+ case TokenParseResult.DECRYPTION_FAILED:
53
+ return new BotDefenderActionData(Action.TRIGGER_RISK_API, BotDefenderS2SCallReason.COOKIE_DECRYPTION_FAILED);
54
+ case TokenParseResult.VALIDATION_FAILED:
55
+ return new BotDefenderActionData(Action.TRIGGER_RISK_API, BotDefenderS2SCallReason.COOKIE_VALIDATION_FAILED);
56
+ case TokenParseResult.SUCCESSFUL:
57
+ return this.getActionForSuccessfulTokenParse(context, isMonitoredRequest, isSensitiveRequest);
58
+ }
71
59
  }
72
60
  getNoTokenS2SCallReason({ pxhd, isMobile, tokenData, }) {
73
- var _a;
74
- if (isMobile && ((_a = tokenData.mobileData) === null || _a === void 0 ? void 0 : _a.mobileError)) {
61
+ if (isMobile && tokenData.mobileData?.mobileError) {
75
62
  return BotDefenderUtils.getS2SCallReasonFromMobileError(tokenData.mobileData.mobileError);
76
63
  }
77
64
  if (pxhd) {
@@ -91,24 +78,20 @@ export class BotDefender {
91
78
  }
92
79
  return new BotDefenderActionData(Action.PASS_REQUEST, BotDefenderPassReason.COOKIE);
93
80
  }
94
- enrichContextFromRiskApi(context) {
95
- return __awaiter(this, void 0, void 0, function* () {
96
- return yield this.getRiskApiActionData(context);
97
- });
98
- }
99
- getRiskApiActionData({ riskApiData, productData: { bd }, }) {
100
- return __awaiter(this, void 0, void 0, function* () {
101
- switch (riskApiData.riskApiCallResult) {
102
- case RiskApiCallResult.NONE:
103
- throw new EnforcerError('risk api call result should not be none!');
104
- case RiskApiCallResult.ERROR:
105
- return new BotDefenderActionData(Action.PASS_REQUEST, BotDefenderPassReason.S2S_ERROR);
106
- case RiskApiCallResult.TIMEOUT:
107
- return new BotDefenderActionData(Action.PASS_REQUEST, BotDefenderPassReason.S2S_TIMEOUT);
108
- case RiskApiCallResult.SUCCESSFUL:
109
- return this.getSuccessfulRiskApiAction(riskApiData.riskResponse, bd.isMonitoredRequest);
110
- }
111
- });
81
+ async enrichContextFromRiskApi(context) {
82
+ return await this.getRiskApiActionData(context);
83
+ }
84
+ async getRiskApiActionData({ riskApiData, productData: { bd }, }) {
85
+ switch (riskApiData.riskApiCallResult) {
86
+ case RiskApiCallResult.NONE:
87
+ throw new EnforcerError('risk api call result should not be none!');
88
+ case RiskApiCallResult.ERROR:
89
+ return new BotDefenderActionData(Action.PASS_REQUEST, BotDefenderPassReason.S2S_ERROR);
90
+ case RiskApiCallResult.TIMEOUT:
91
+ return new BotDefenderActionData(Action.PASS_REQUEST, BotDefenderPassReason.S2S_TIMEOUT);
92
+ case RiskApiCallResult.SUCCESSFUL:
93
+ return this.getSuccessfulRiskApiAction(riskApiData.riskResponse, bd.isMonitoredRequest);
94
+ }
112
95
  }
113
96
  getSuccessfulRiskApiAction(riskResponse, isMonitored) {
114
97
  if (riskResponse.score >= this.config.blockingScore) {
@@ -122,14 +105,10 @@ export class BotDefender {
122
105
  createBlockResponse(context) {
123
106
  return this.blocker.createBlockResponse(context);
124
107
  }
125
- modifyIncomingRequest(context) {
126
- return __awaiter(this, void 0, void 0, function* () {
127
- // intentionally left blank
128
- });
108
+ async modifyIncomingRequest(context) {
109
+ // intentionally left blank
129
110
  }
130
- modifyOutgoingResponse(context) {
131
- return __awaiter(this, void 0, void 0, function* () {
132
- // intentionally left blank
133
- });
111
+ async modifyOutgoingResponse(context) {
112
+ // intentionally left blank
134
113
  }
135
114
  }
@@ -1,4 +1,6 @@
1
1
  export class BotDefenderActionData {
2
+ action;
3
+ reason;
2
4
  constructor(action, reason) {
3
5
  this.action = action;
4
6
  this.reason = reason;
@@ -1,14 +1,14 @@
1
1
  import { ReadonlyContext } from '../../../context';
2
2
  import { IConfiguration } from '../../../config';
3
3
  import { IBase64Utils } from '../../../utils';
4
- import { IConditionalBlocker } from '../../../blocker';
4
+ import { IBlocker, IConditionalBlocker } from '../../../blocker';
5
5
  import { IMinimalResponse } from '../../../http';
6
6
  export declare class DefaultBotDefenderBlocker<Req, Res> implements IConditionalBlocker<Req, Res> {
7
- private readonly config;
8
- private readonly captchaResponseGenerator;
7
+ protected readonly config: IConfiguration<Req, Res>;
8
+ protected readonly captchaBlocker: IBlocker<Req, Res>;
9
9
  constructor(config: IConfiguration<Req, Res>, base64Utils: IBase64Utils);
10
10
  shouldBlock({ action, reasons, productData }: ReadonlyContext<Req, Res>): boolean;
11
11
  createBlockResponse(context: ReadonlyContext<Req, Res>): IMinimalResponse;
12
- private createRateLimitResponse;
12
+ protected createRateLimitResponse(): IMinimalResponse;
13
13
  private createCaptchaResponse;
14
14
  }
@@ -5,12 +5,14 @@ import { ProductName } from '../../utils';
5
5
  import { CaptchaBlocker } from './captcha';
6
6
  import { RATE_LIMIT_TEMPLATE } from './templates';
7
7
  export class DefaultBotDefenderBlocker {
8
+ config;
9
+ captchaBlocker;
8
10
  constructor(config, base64Utils) {
9
11
  this.config = config;
10
- this.captchaResponseGenerator = new CaptchaBlocker(config, base64Utils);
12
+ this.captchaBlocker = new CaptchaBlocker(config, base64Utils);
11
13
  }
12
14
  shouldBlock({ action, reasons, productData }) {
13
- return action === Action.BLOCK && !!(reasons === null || reasons === void 0 ? void 0 : reasons[ProductName.BOT_DEFENDER]);
15
+ return action === Action.BLOCK && !!reasons?.[ProductName.BOT_DEFENDER];
14
16
  }
15
17
  createBlockResponse(context) {
16
18
  switch (context.blockAction) {
@@ -34,6 +36,6 @@ export class DefaultBotDefenderBlocker {
34
36
  });
35
37
  }
36
38
  createCaptchaResponse(context) {
37
- return this.captchaResponseGenerator.createBlockResponse(context);
39
+ return this.captchaBlocker.createBlockResponse(context);
38
40
  }
39
41
  }
@@ -3,11 +3,14 @@ import { ReadonlyContext } from '../../../../context';
3
3
  import { IBase64Utils } from '../../../../utils';
4
4
  import { IBlocker } from '../../../../blocker';
5
5
  import { IMinimalResponse } from '../../../../http';
6
+ import { JsonCaptchaBlocker } from './JsonCaptchaBlocker';
7
+ import { MobileCaptchaBlocker } from './MobileCaptchaBlocker';
8
+ import { HtmlCaptchaBlocker } from './HtmlCaptchaBlocker';
6
9
  export declare class CaptchaBlocker<Req, Res> implements IBlocker<Req, Res> {
7
- private readonly config;
8
- private readonly jsonCaptchaGenerator;
9
- private readonly mobileCaptchaGenerator;
10
- private readonly htmlCaptchaGenerator;
10
+ protected readonly config: IConfiguration<Req, Res>;
11
+ protected readonly jsonCaptchaBlocker: JsonCaptchaBlocker<Req, Res>;
12
+ protected readonly mobileCaptchaBlocker: MobileCaptchaBlocker<Req, Res>;
13
+ protected readonly htmlCaptchaBlocker: HtmlCaptchaBlocker<Req, Res>;
11
14
  constructor(config: IConfiguration<Req, Res>, base64Utils: IBase64Utils);
12
15
  createBlockResponse(context: ReadonlyContext<Req, Res>): IMinimalResponse;
13
16
  }
@@ -2,19 +2,23 @@ import { JsonCaptchaBlocker } from './JsonCaptchaBlocker';
2
2
  import { MobileCaptchaBlocker } from './MobileCaptchaBlocker';
3
3
  import { HtmlCaptchaBlocker } from './HtmlCaptchaBlocker';
4
4
  export class CaptchaBlocker {
5
+ config;
6
+ jsonCaptchaBlocker;
7
+ mobileCaptchaBlocker;
8
+ htmlCaptchaBlocker;
5
9
  constructor(config, base64Utils) {
6
10
  this.config = config;
7
- this.jsonCaptchaGenerator = new JsonCaptchaBlocker(config);
8
- this.mobileCaptchaGenerator = new MobileCaptchaBlocker(config, base64Utils);
9
- this.htmlCaptchaGenerator = new HtmlCaptchaBlocker(config);
11
+ this.jsonCaptchaBlocker = new JsonCaptchaBlocker(config);
12
+ this.mobileCaptchaBlocker = new MobileCaptchaBlocker(config, base64Utils);
13
+ this.htmlCaptchaBlocker = new HtmlCaptchaBlocker(config);
10
14
  }
11
15
  createBlockResponse(context) {
12
- if (this.mobileCaptchaGenerator.shouldBlock(context)) {
13
- return this.mobileCaptchaGenerator.createBlockResponse(context);
16
+ if (this.mobileCaptchaBlocker.shouldBlock(context)) {
17
+ return this.mobileCaptchaBlocker.createBlockResponse(context);
14
18
  }
15
- if (this.jsonCaptchaGenerator.shouldBlock(context)) {
16
- return this.jsonCaptchaGenerator.createBlockResponse(context);
19
+ if (this.jsonCaptchaBlocker.shouldBlock(context)) {
20
+ return this.jsonCaptchaBlocker.createBlockResponse(context);
17
21
  }
18
- return this.htmlCaptchaGenerator.createBlockResponse(context);
22
+ return this.htmlCaptchaBlocker.createBlockResponse(context);
19
23
  }
20
24
  }
@@ -3,7 +3,7 @@ import { ReadonlyContext } from '../../../../context';
3
3
  import { IBlocker } from '../../../../blocker';
4
4
  import { IMinimalResponse } from '../../../../http';
5
5
  export declare class HtmlCaptchaBlocker<Req, Res> implements IBlocker<Req, Res> {
6
- private readonly config;
6
+ protected readonly config: IConfiguration<Req, Res>;
7
7
  constructor(config: IConfiguration<Req, Res>);
8
8
  createBlockResponse(context: ReadonlyContext<Req, Res>): IMinimalResponse;
9
9
  }