perimeterx-js-core 0.25.0 → 0.26.1

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 (255) hide show
  1. package/lib/cjs/action/Action.js +15 -0
  2. package/lib/cjs/action/ActionPriorityOrder.js +4 -0
  3. package/lib/cjs/action/utils.js +20 -0
  4. package/lib/cjs/activities/HttpActivityClient.js +61 -1
  5. package/lib/cjs/activities/HttpBatchedActivityClient.js +7 -0
  6. package/lib/cjs/activities/utils.js +128 -62
  7. package/lib/cjs/additional_activity_handler/AdditionalActivityHandlerUtils.js +6 -0
  8. package/lib/cjs/blocker/BlockerBase.js +14 -0
  9. package/lib/cjs/blocker/JsonBlockerBase.js +5 -0
  10. package/lib/cjs/blocker/utils.js +13 -0
  11. package/lib/cjs/config/ConfigurationBase.js +17 -0
  12. package/lib/cjs/context/DefaultContext.js +4 -0
  13. package/lib/cjs/context/SerializedContext.js +5 -0
  14. package/lib/cjs/enforcer/EnforcerBase.js +61 -22
  15. package/lib/cjs/enforcer/index.js +1 -0
  16. package/lib/cjs/{phase/flow → flow}/EndEnforcerFlow.js +11 -7
  17. package/lib/cjs/{phase/flow → flow}/EnforceFlow.js +10 -15
  18. package/lib/cjs/{phase/flow → flow}/FilterFlow.js +10 -9
  19. package/lib/cjs/flow/Flow.js +60 -0
  20. package/lib/cjs/flow/IFlow.js +2 -0
  21. package/lib/cjs/{phase/flow → flow}/PostEnforceFlow.js +6 -6
  22. package/lib/cjs/{phase/flow → flow}/index.js +2 -0
  23. package/lib/cjs/index.js +1 -0
  24. package/lib/cjs/phase/impl/AdditionalActivityHandlerPhase.js +3 -0
  25. package/lib/cjs/phase/impl/ClearLogsPhase.js +3 -0
  26. package/lib/cjs/phase/impl/CompositePhase.js +9 -0
  27. package/lib/cjs/phase/impl/CreateBlockResponsePhase.js +16 -0
  28. package/lib/cjs/phase/impl/DecideActionPhase.js +11 -0
  29. package/lib/cjs/phase/impl/EnrichContextFromRequestPhase.js +13 -9
  30. package/lib/cjs/phase/impl/EnrichContextFromResponsePhase.js +4 -0
  31. package/lib/cjs/phase/impl/FilterPhase.js +4 -0
  32. package/lib/cjs/phase/impl/FirstPartyPhase.js +5 -0
  33. package/lib/cjs/phase/impl/IdentifyRemoteConfigNotifyRequestPhase.js +5 -0
  34. package/lib/cjs/phase/impl/IdentifyTelemetryRequestPhase.js +5 -0
  35. package/lib/cjs/phase/impl/ModifyIncomingRequestPhase.js +5 -0
  36. package/lib/cjs/phase/impl/ModifyOutgoingResponsePhase.js +5 -0
  37. package/lib/cjs/phase/impl/ParseTokenPhase.js +14 -7
  38. package/lib/cjs/phase/impl/PreflightPhase.js +4 -0
  39. package/lib/cjs/phase/impl/RiskApiPhase.js +18 -7
  40. package/lib/cjs/phase/impl/{SendAsyncActivitiesOnResponsePhase.js → SendAsyncActivitiesPhase.js} +15 -8
  41. package/lib/cjs/phase/impl/SendLogsPhase.js +3 -0
  42. package/lib/cjs/phase/impl/SendTelemetryActivityPhase.js +3 -0
  43. package/lib/cjs/phase/impl/UpdateRemoteConfigPhase.js +3 -0
  44. package/lib/cjs/phase/impl/index.js +1 -2
  45. package/lib/cjs/phase/index.js +0 -1
  46. package/lib/cjs/products/credential_intelligence/endpoint/login_successful/BodyLoginSuccessfulParser.js +1 -1
  47. package/lib/cjs/products/credential_intelligence/endpoint/login_successful/LoginSuccessfulParserFactory.js +5 -2
  48. package/lib/cjs/products/credential_intelligence/endpoint/matcher/CredentialIntelligenceEndpointMatcherFactory.js +3 -1
  49. package/lib/cjs/risk_api/client/GetRiskApiClientV2.js +91 -0
  50. package/lib/cjs/risk_api/client/PostRiskApiClientV2.js +3 -3
  51. package/lib/cjs/risk_api/client/PostRiskApiClientV3.js +3 -3
  52. package/lib/cjs/risk_api/client/abstract/IRiskApiClient.js +2 -0
  53. package/lib/cjs/risk_api/client/abstract/PostRiskApiClientBase.js +43 -0
  54. package/lib/cjs/risk_api/client/{PostRiskApiClientBase.js → abstract/RiskApiClientBase.js} +22 -69
  55. package/lib/cjs/risk_api/client/abstract/index.js +19 -0
  56. package/lib/cjs/risk_api/client/index.js +2 -2
  57. package/lib/cjs/risk_api/index.js +1 -0
  58. package/lib/cjs/risk_api/model/GetRiskRequestHeaders.js +185 -0
  59. package/lib/cjs/risk_api/model/GetRiskResponseHeaders.js +16 -0
  60. package/lib/cjs/risk_api/model/index.js +2 -0
  61. package/lib/cjs/{phase/impl/SendAsyncActivitiesOnRequestPhase.js → risk_api/risk_response/PostRiskResponseBase.js} +26 -30
  62. package/lib/cjs/risk_api/risk_response/RiskResponseBase.js +11 -8
  63. package/lib/cjs/risk_api/risk_response/index.js +1 -0
  64. package/lib/cjs/risk_api/risk_response/serialize/SerializedRiskResponse.js +5 -1
  65. package/lib/cjs/risk_api/risk_response/v2/GetRiskResponseV2.js +80 -0
  66. package/lib/cjs/risk_api/risk_response/v2/{DefaultRiskResponseV2.js → PostRiskResponseV2.js} +10 -10
  67. package/lib/cjs/risk_api/risk_response/v2/index.js +2 -1
  68. package/lib/cjs/risk_api/risk_response/v3/{DefaultRiskResponseV3.js → PostRiskResponseV3.js} +10 -10
  69. package/lib/cjs/risk_api/risk_response/v3/index.js +1 -1
  70. package/lib/cjs/risk_api/utils.js +36 -0
  71. package/lib/cjs/telemetry/DefaultTelemetry.js +12 -9
  72. package/lib/cjs/utils/constants.js +1 -1
  73. package/lib/cjs/utils/utils.js +3 -19
  74. package/lib/esm/action/Action.js +15 -0
  75. package/lib/esm/action/ActionPriorityOrder.js +4 -0
  76. package/lib/esm/action/utils.js +20 -0
  77. package/lib/esm/activities/HttpActivityClient.js +61 -1
  78. package/lib/esm/activities/HttpBatchedActivityClient.js +7 -0
  79. package/lib/esm/activities/utils.js +128 -63
  80. package/lib/esm/additional_activity_handler/AdditionalActivityHandlerUtils.js +6 -0
  81. package/lib/esm/blocker/BlockerBase.js +14 -0
  82. package/lib/esm/blocker/JsonBlockerBase.js +5 -0
  83. package/lib/esm/blocker/utils.js +13 -0
  84. package/lib/esm/config/ConfigurationBase.js +13 -0
  85. package/lib/esm/context/DefaultContext.js +4 -0
  86. package/lib/esm/context/SerializedContext.js +5 -0
  87. package/lib/esm/enforcer/EnforcerBase.js +43 -6
  88. package/lib/esm/enforcer/index.js +1 -0
  89. package/lib/esm/flow/EndEnforcerFlow.js +18 -0
  90. package/lib/esm/flow/EnforceFlow.js +14 -0
  91. package/lib/esm/{phase/flow → flow}/FilterFlow.js +5 -4
  92. package/lib/esm/flow/Flow.js +56 -0
  93. package/lib/esm/flow/IFlow.js +1 -0
  94. package/lib/esm/flow/PostEnforceFlow.js +10 -0
  95. package/lib/esm/{phase/flow → flow}/index.js +2 -0
  96. package/lib/esm/index.js +1 -0
  97. package/lib/esm/phase/impl/AdditionalActivityHandlerPhase.js +3 -0
  98. package/lib/esm/phase/impl/ClearLogsPhase.js +3 -0
  99. package/lib/esm/phase/impl/CompositePhase.js +9 -0
  100. package/lib/esm/phase/impl/CreateBlockResponsePhase.js +16 -1
  101. package/lib/esm/phase/impl/DecideActionPhase.js +11 -0
  102. package/lib/esm/phase/impl/EnrichContextFromRequestPhase.js +9 -0
  103. package/lib/esm/phase/impl/EnrichContextFromResponsePhase.js +4 -0
  104. package/lib/esm/phase/impl/FilterPhase.js +4 -0
  105. package/lib/esm/phase/impl/FirstPartyPhase.js +5 -0
  106. package/lib/esm/phase/impl/IdentifyRemoteConfigNotifyRequestPhase.js +5 -0
  107. package/lib/esm/phase/impl/IdentifyTelemetryRequestPhase.js +5 -0
  108. package/lib/esm/phase/impl/ModifyIncomingRequestPhase.js +5 -0
  109. package/lib/esm/phase/impl/ModifyOutgoingResponsePhase.js +5 -0
  110. package/lib/esm/phase/impl/ParseTokenPhase.js +15 -8
  111. package/lib/esm/phase/impl/PreflightPhase.js +4 -0
  112. package/lib/esm/phase/impl/RiskApiPhase.js +19 -8
  113. package/lib/esm/phase/impl/SendAsyncActivitiesPhase.js +16 -0
  114. package/lib/esm/phase/impl/SendLogsPhase.js +3 -0
  115. package/lib/esm/phase/impl/SendTelemetryActivityPhase.js +3 -0
  116. package/lib/esm/phase/impl/UpdateRemoteConfigPhase.js +3 -0
  117. package/lib/esm/phase/impl/index.js +1 -2
  118. package/lib/esm/phase/index.js +0 -1
  119. package/lib/esm/products/credential_intelligence/endpoint/login_successful/BodyLoginSuccessfulParser.js +1 -1
  120. package/lib/esm/products/credential_intelligence/endpoint/login_successful/LoginSuccessfulParserFactory.js +5 -2
  121. package/lib/esm/products/credential_intelligence/endpoint/matcher/CredentialIntelligenceEndpointMatcherFactory.js +2 -1
  122. package/lib/esm/risk_api/client/GetRiskApiClientV2.js +64 -0
  123. package/lib/esm/risk_api/client/PostRiskApiClientV2.js +3 -3
  124. package/lib/esm/risk_api/client/PostRiskApiClientV3.js +3 -3
  125. package/lib/esm/risk_api/client/abstract/IRiskApiClient.js +1 -0
  126. package/lib/esm/risk_api/client/abstract/PostRiskApiClientBase.js +18 -0
  127. package/lib/esm/risk_api/client/{PostRiskApiClientBase.js → abstract/RiskApiClientBase.js} +10 -49
  128. package/lib/esm/risk_api/client/abstract/index.js +3 -0
  129. package/lib/esm/risk_api/client/index.js +2 -2
  130. package/lib/esm/risk_api/index.js +1 -0
  131. package/lib/esm/risk_api/model/GetRiskRequestHeaders.js +182 -0
  132. package/lib/esm/risk_api/model/GetRiskResponseHeaders.js +13 -0
  133. package/lib/esm/risk_api/model/index.js +2 -0
  134. package/lib/esm/risk_api/risk_response/PostRiskResponseBase.js +6 -0
  135. package/lib/esm/risk_api/risk_response/RiskResponseBase.js +5 -1
  136. package/lib/esm/risk_api/risk_response/index.js +1 -0
  137. package/lib/esm/risk_api/risk_response/serialize/SerializedRiskResponse.js +5 -1
  138. package/lib/esm/risk_api/risk_response/v2/GetRiskResponseV2.js +52 -0
  139. package/lib/esm/risk_api/risk_response/v2/{DefaultRiskResponseV2.js → PostRiskResponseV2.js} +2 -2
  140. package/lib/esm/risk_api/risk_response/v2/index.js +2 -1
  141. package/lib/esm/risk_api/risk_response/v3/{DefaultRiskResponseV3.js → PostRiskResponseV3.js} +2 -2
  142. package/lib/esm/risk_api/risk_response/v3/index.js +1 -1
  143. package/lib/esm/risk_api/utils.js +23 -0
  144. package/lib/esm/telemetry/DefaultTelemetry.js +13 -10
  145. package/lib/esm/utils/constants.js +1 -1
  146. package/lib/esm/utils/utils.js +1 -16
  147. package/lib/types/action/Action.d.ts +15 -0
  148. package/lib/types/action/ActionData.d.ts +3 -0
  149. package/lib/types/action/ActionPriorityOrder.d.ts +4 -0
  150. package/lib/types/action/Decision.d.ts +9 -0
  151. package/lib/types/action/ProductAction.d.ts +3 -0
  152. package/lib/types/action/utils.d.ts +20 -0
  153. package/lib/types/activities/HttpActivityClient.d.ts +57 -1
  154. package/lib/types/activities/HttpBatchedActivityClient.d.ts +7 -0
  155. package/lib/types/activities/IActivityClient.d.ts +4 -1
  156. package/lib/types/activities/model/AsyncActivity.d.ts +3 -0
  157. package/lib/types/activities/model/AsyncActivityDetails.d.ts +12 -0
  158. package/lib/types/activities/model/CommonActivityDetails.d.ts +3 -0
  159. package/lib/types/activities/utils.d.ts +14 -0
  160. package/lib/types/additional_activity_handler/AdditionalActivityHandlerUtils.d.ts +6 -0
  161. package/lib/types/blocker/BlockerBase.d.ts +21 -0
  162. package/lib/types/blocker/IBlocker.d.ts +8 -0
  163. package/lib/types/blocker/IConditionalBlocker.d.ts +4 -0
  164. package/lib/types/blocker/JsonBlockerBase.d.ts +12 -0
  165. package/lib/types/blocker/model/BlockData.d.ts +3 -0
  166. package/lib/types/blocker/utils.d.ts +13 -0
  167. package/lib/types/config/ConfigurationBase.d.ts +22 -0
  168. package/lib/types/config/IConfiguration.d.ts +4 -0
  169. package/lib/types/config/params/CoreConfigurationParams.d.ts +21 -0
  170. package/lib/types/config/params/RemoteConfigurationParams.d.ts +3 -0
  171. package/lib/types/config/params/StaticConfigurationParams.d.ts +3 -0
  172. package/lib/types/context/ContextJson.d.ts +4 -0
  173. package/lib/types/context/DefaultContext.d.ts +4 -0
  174. package/lib/types/context/SerializedContext.d.ts +5 -0
  175. package/lib/types/custom_parameters/CustomParameters.d.ts +3 -0
  176. package/lib/types/enforcer/EnforcerBase.d.ts +48 -12
  177. package/lib/types/enforcer/IEnforcer.d.ts +1 -2
  178. package/lib/types/enforcer/IPostEnforcer.d.ts +3 -0
  179. package/lib/types/enforcer/index.d.ts +1 -0
  180. package/lib/types/first_party/IFirstParty.d.ts +1 -1
  181. package/lib/types/flow/EndEnforcerFlow.d.ts +8 -0
  182. package/lib/types/flow/EnforceFlow.d.ts +8 -0
  183. package/lib/types/{phase/flow → flow}/FilterFlow.d.ts +7 -7
  184. package/lib/types/flow/Flow.d.ts +13 -0
  185. package/lib/types/flow/IFlow.d.ts +57 -0
  186. package/lib/types/flow/PostEnforceFlow.d.ts +6 -0
  187. package/lib/types/{phase/flow → flow}/index.d.ts +2 -0
  188. package/lib/types/index.d.ts +1 -0
  189. package/lib/types/phase/IPhase.d.ts +9 -0
  190. package/lib/types/phase/PhaseResult.d.ts +11 -0
  191. package/lib/types/phase/impl/AdditionalActivityHandlerPhase.d.ts +3 -0
  192. package/lib/types/phase/impl/ClearLogsPhase.d.ts +3 -0
  193. package/lib/types/phase/impl/CompositePhase.d.ts +9 -0
  194. package/lib/types/phase/impl/CreateBlockResponsePhase.d.ts +11 -1
  195. package/lib/types/phase/impl/DecideActionPhase.d.ts +11 -0
  196. package/lib/types/phase/impl/EnrichContextFromRequestPhase.d.ts +9 -0
  197. package/lib/types/phase/impl/EnrichContextFromResponsePhase.d.ts +4 -0
  198. package/lib/types/phase/impl/FilterPhase.d.ts +4 -0
  199. package/lib/types/phase/impl/FirstPartyPhase.d.ts +5 -0
  200. package/lib/types/phase/impl/IdentifyRemoteConfigNotifyRequestPhase.d.ts +5 -0
  201. package/lib/types/phase/impl/IdentifyTelemetryRequestPhase.d.ts +5 -0
  202. package/lib/types/phase/impl/ModifyIncomingRequestPhase.d.ts +5 -0
  203. package/lib/types/phase/impl/ModifyOutgoingResponsePhase.d.ts +5 -0
  204. package/lib/types/phase/impl/ParseTokenPhase.d.ts +3 -0
  205. package/lib/types/phase/impl/PreflightPhase.d.ts +4 -0
  206. package/lib/types/phase/impl/RiskApiPhase.d.ts +5 -0
  207. package/lib/types/phase/impl/{SendAsyncActivitiesOnResponsePhase.d.ts → SendAsyncActivitiesPhase.d.ts} +5 -2
  208. package/lib/types/phase/impl/SendLogsPhase.d.ts +3 -0
  209. package/lib/types/phase/impl/SendTelemetryActivityPhase.d.ts +3 -0
  210. package/lib/types/phase/impl/UpdateRemoteConfigPhase.d.ts +3 -0
  211. package/lib/types/phase/impl/index.d.ts +1 -2
  212. package/lib/types/phase/index.d.ts +0 -1
  213. package/lib/types/products/credential_intelligence/endpoint/CredentialEndpointConfiguration.d.ts +1 -1
  214. package/lib/types/products/credential_intelligence/endpoint/login_successful/BodyLoginSuccessfulParser.d.ts +1 -1
  215. package/lib/types/products/interfaces/IProduct.d.ts +28 -0
  216. package/lib/types/products/interfaces/ProductDataType.d.ts +1 -1
  217. package/lib/types/risk_api/client/GetRiskApiClientV2.d.ts +18 -0
  218. package/lib/types/risk_api/client/PostRiskApiClientV2.d.ts +1 -1
  219. package/lib/types/risk_api/client/PostRiskApiClientV3.d.ts +2 -2
  220. package/lib/types/risk_api/client/{IRiskApiClient.d.ts → abstract/IRiskApiClient.d.ts} +1 -1
  221. package/lib/types/risk_api/client/abstract/PostRiskApiClientBase.d.ts +8 -0
  222. package/lib/types/risk_api/client/abstract/RiskApiClientBase.d.ts +26 -0
  223. package/lib/types/risk_api/client/abstract/index.d.ts +3 -0
  224. package/lib/types/risk_api/client/index.d.ts +2 -2
  225. package/lib/types/risk_api/index.d.ts +1 -0
  226. package/lib/types/risk_api/model/GetRiskRequestHeaders.d.ts +17 -0
  227. package/lib/types/risk_api/model/GetRiskResponseHeaders.d.ts +3 -0
  228. package/lib/types/risk_api/model/index.d.ts +2 -0
  229. package/lib/types/risk_api/risk_response/IRiskResponse.d.ts +2 -0
  230. package/lib/types/risk_api/risk_response/PostRiskResponseBase.d.ts +7 -0
  231. package/lib/types/risk_api/risk_response/RiskResponseBase.d.ts +3 -1
  232. package/lib/types/risk_api/risk_response/index.d.ts +1 -0
  233. package/lib/types/risk_api/risk_response/serialize/SerializedRiskResponse.d.ts +1 -0
  234. package/lib/types/risk_api/risk_response/v2/GetRiskResponseV2.d.ts +11 -0
  235. package/lib/types/risk_api/risk_response/{v3/DefaultRiskResponseV3.d.ts → v2/PostRiskResponseV2.d.ts} +2 -2
  236. package/lib/types/risk_api/risk_response/v2/index.d.ts +2 -1
  237. package/lib/types/risk_api/risk_response/{v2/DefaultRiskResponseV2.d.ts → v3/PostRiskResponseV3.d.ts} +2 -2
  238. package/lib/types/risk_api/risk_response/v3/index.d.ts +1 -1
  239. package/lib/types/risk_api/utils.d.ts +69 -0
  240. package/lib/types/telemetry/model/TelemetryActivity.d.ts +1 -1
  241. package/lib/types/utils/constants.d.ts +1 -1
  242. package/lib/types/utils/utils.d.ts +1 -5
  243. package/package.json +1 -1
  244. package/lib/esm/phase/flow/EndEnforcerFlow.js +0 -14
  245. package/lib/esm/phase/flow/EnforceFlow.js +0 -18
  246. package/lib/esm/phase/flow/PostEnforceFlow.js +0 -10
  247. package/lib/esm/phase/impl/SendAsyncActivitiesOnRequestPhase.js +0 -16
  248. package/lib/esm/phase/impl/SendAsyncActivitiesOnResponsePhase.js +0 -10
  249. package/lib/types/phase/flow/EndEnforcerFlow.d.ts +0 -8
  250. package/lib/types/phase/flow/EnforceFlow.d.ts +0 -8
  251. package/lib/types/phase/flow/PostEnforceFlow.d.ts +0 -6
  252. package/lib/types/phase/impl/SendAsyncActivitiesOnRequestPhase.d.ts +0 -10
  253. package/lib/types/risk_api/client/PostRiskApiClientBase.d.ts +0 -40
  254. /package/lib/cjs/{risk_api/client/IRiskApiClient.js → enforcer/IPostEnforcer.js} +0 -0
  255. /package/lib/esm/{risk_api/client/IRiskApiClient.js → enforcer/IPostEnforcer.js} +0 -0
@@ -1,10 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Action = void 0;
4
+ /**
5
+ * The action that should be taken by the enforcer.
6
+ */
4
7
  var Action;
5
8
  (function (Action) {
9
+ /**
10
+ * Indicates that the request should be allowed to pass.
11
+ */
6
12
  Action["PASS_REQUEST"] = "pass_request";
13
+ /**
14
+ * Indicates that there is not enough information to make a decision and a Risk API request should be made.
15
+ */
7
16
  Action["TRIGGER_RISK_API"] = "trigger_risk_api";
17
+ /**
18
+ * Indicates that the request should be blocked, but no block response will be returned.
19
+ */
8
20
  Action["SIMULATED_BLOCK"] = "simulated_block";
21
+ /**
22
+ * Indicates that the request should be blocked and a block response should be returned.
23
+ */
9
24
  Action["BLOCK"] = "block";
10
25
  })(Action || (exports.Action = Action = {}));
@@ -2,6 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ACTION_PRIORITY_ORDER = void 0;
4
4
  var Action_1 = require("./Action.js");
5
+ /**
6
+ * The priority order of actions that the enforcer should take. The array will be traversed in order,
7
+ * and the first action that matches a product recommendation will be taken.
8
+ */
5
9
  exports.ACTION_PRIORITY_ORDER = [
6
10
  Action_1.Action.BLOCK,
7
11
  Action_1.Action.SIMULATED_BLOCK,
@@ -4,10 +4,20 @@ exports.getReasonForHighestPriorityProduct = exports.getDecisionFromActions = ex
4
4
  var Action_1 = require("./Action.js");
5
5
  var products_1 = require("../products/index.js");
6
6
  var ActionPriorityOrder_1 = require("./ActionPriorityOrder.js");
7
+ /**
8
+ * Determines the final decision from the context.
9
+ * @param context - The request context.
10
+ * @returns Decision - The final action that should be taken and the associated products and reasons responsible for the decision.
11
+ */
7
12
  var getDecisionFromContext = function (context) {
8
13
  return (0, exports.getDecisionFromActions)((0, exports.getProductActions)(context));
9
14
  };
10
15
  exports.getDecisionFromContext = getDecisionFromContext;
16
+ /**
17
+ * Determines all product recommended actions from the context.
18
+ * @param context - The request context.
19
+ * @returns ProductAction[] - An array of objects, representing the recommended action and reason of all relevant products.
20
+ */
11
21
  var getProductActions = function (context) {
12
22
  return Object.entries(context.productData)
13
23
  .filter(function (_a) {
@@ -24,6 +34,11 @@ var getProductActions = function (context) {
24
34
  });
25
35
  };
26
36
  exports.getProductActions = getProductActions;
37
+ /**
38
+ * Reduces a list of ProductActions to a single Decision, taking into consideration the ACTION_PRIORITY_ORDER.
39
+ * @param productActions - All possible actions from all products.
40
+ * @returns Decision - The final action that should be taken and the associated products and reasons responsible for the decision.
41
+ */
27
42
  var getDecisionFromActions = function (productActions) {
28
43
  return createDecision(reduce(productActions));
29
44
  };
@@ -47,6 +62,11 @@ var createDecision = function (tally) {
47
62
  }
48
63
  return { action: Action_1.Action.PASS_REQUEST, reasons: {} };
49
64
  };
65
+ /**
66
+ * Provided a mapping of product names to reasons, returns the reason associated with the highest priority product in the mapping.
67
+ * @param reasons - An object mapping any product names to their associated reasons.
68
+ * @returns string - The reason for the highest priority product, or 'unknown_reason' if none is found.
69
+ */
50
70
  var getReasonForHighestPriorityProduct = function (reasons) {
51
71
  for (var _i = 0, PRODUCT_PRIORITY_ORDER_1 = products_1.PRODUCT_PRIORITY_ORDER; _i < PRODUCT_PRIORITY_ORDER_1.length; _i++) {
52
72
  var productName = PRODUCT_PRIORITY_ORDER_1[_i];
@@ -43,11 +43,24 @@ var utils_1 = require("../utils/index.js");
43
43
  var ActivityType_1 = require("./ActivityType.js");
44
44
  var utils_2 = require("./utils.js");
45
45
  var constants_1 = require("./constants.js");
46
+ /**
47
+ * The HttpActivityClient is responsible for sending async activities to the backend via HTTP.
48
+ */
46
49
  var HttpActivityClient = /** @class */ (function () {
50
+ /**
51
+ * Creates an instance of HttpActivityClient.
52
+ * @param config
53
+ * @param httpClient
54
+ */
47
55
  function HttpActivityClient(config, httpClient) {
48
56
  this.config = config;
49
57
  this.httpClient = httpClient;
50
58
  }
59
+ /**
60
+ * Creates and sends all necessary async activities to the backend.
61
+ * @param context - The context containing the request (and possibly response).
62
+ * @returns {Promise<boolean>} - A boolean indicating if the activities were sent successfully.
63
+ */
51
64
  HttpActivityClient.prototype.sendActivities = function (context) {
52
65
  return __awaiter(this, void 0, void 0, function () {
53
66
  var activities, e_1;
@@ -56,6 +69,10 @@ var HttpActivityClient = /** @class */ (function () {
56
69
  case 0:
57
70
  _a.trys.push([0, 2, , 3]);
58
71
  activities = this.createActivities(context);
72
+ if (!activities || activities.length === 0) {
73
+ context.logger.debug('no activities to send');
74
+ return [2 /*return*/, true];
75
+ }
59
76
  return [4 /*yield*/, this.postActivities(activities, context.logger)];
60
77
  case 1: return [2 /*return*/, _a.sent()];
61
78
  case 2:
@@ -67,6 +84,12 @@ var HttpActivityClient = /** @class */ (function () {
67
84
  });
68
85
  });
69
86
  };
87
+ /**
88
+ * Creates all async activities (block, page_requested, additional_s2s) that should be sent based on the context.
89
+ * @param context - The context containing the request (and possibly response).
90
+ * @returns {AsyncActivity[]} - An array of async activities to be sent.
91
+ * @protected
92
+ */
70
93
  HttpActivityClient.prototype.createActivities = function (context) {
71
94
  var activities = [];
72
95
  if (this.shouldCreateBlockActivity(context)) {
@@ -80,28 +103,58 @@ var HttpActivityClient = /** @class */ (function () {
80
103
  }
81
104
  return activities.map(this.finalizeActivity);
82
105
  };
106
+ /**
107
+ * Whether to create a block activity based on the context.
108
+ * @param context
109
+ * @protected
110
+ */
83
111
  HttpActivityClient.prototype.shouldCreateBlockActivity = function (context) {
84
112
  return context.action === action_1.Action.BLOCK || context.action === action_1.Action.SIMULATED_BLOCK;
85
113
  };
114
+ /**
115
+ * Whether to create a page_requested activity based on the context.
116
+ * @param context
117
+ * @protected
118
+ */
86
119
  HttpActivityClient.prototype.shouldCreatePageRequestedActivity = function (context) {
87
120
  return context.action === action_1.Action.PASS_REQUEST;
88
121
  };
122
+ /**
123
+ * Whether to create an additional_s2s activity based on the context.
124
+ * @param context
125
+ * @protected
126
+ */
89
127
  HttpActivityClient.prototype.shouldCreateAdditionalS2SActivity = function (context) {
90
128
  return (this.shouldCreatePageRequestedActivity(context) &&
91
129
  !!context.productData.ci &&
92
130
  this.config.ciAutomaticAdditionalS2SEnabled);
93
131
  };
132
+ /**
133
+ * Creates a block activity based on the context.
134
+ * @param context
135
+ * @protected
136
+ */
94
137
  HttpActivityClient.prototype.createBlockActivity = function (context) {
95
138
  return (0, utils_2.createAsyncActivity)(ActivityType_1.ActivityType.BLOCK, this.config, context);
96
139
  };
140
+ /**
141
+ * Creates a page_requested activity based on the context.
142
+ * @param context
143
+ * @protected
144
+ */
97
145
  HttpActivityClient.prototype.createPageRequestedActivity = function (context) {
98
146
  return (0, utils_2.createAsyncActivity)(ActivityType_1.ActivityType.PAGE_REQUESTED, this.config, context);
99
147
  };
148
+ /**
149
+ * Creates an additional_s2s activity based on the context.
150
+ * @param context
151
+ * @protected
152
+ */
100
153
  HttpActivityClient.prototype.createAdditionalS2SActivity = function (context) {
101
154
  return (0, utils_2.createAsyncActivity)(ActivityType_1.ActivityType.ADDITIONAL_S2S, this.config, context);
102
155
  };
103
156
  /**
104
- * Allows for expansions or alterations to the async activity if needed.
157
+ * Allows for expansions or alterations to an async activity if needed. This applies to all created async activities.
105
158
  * @param activity
106
159
  * @returns AsyncActivity
107
160
  * @protected
@@ -109,6 +162,13 @@ var HttpActivityClient = /** @class */ (function () {
109
162
  HttpActivityClient.prototype.finalizeActivity = function (activity) {
110
163
  return activity;
111
164
  };
165
+ /**
166
+ * Sends the async activities to the backend.
167
+ * @param activities - The activities to be sent.
168
+ * @param logger - The logger instance for logging.
169
+ * @returns {Promise<boolean>} - A boolean indicating if the activities were sent successfully.
170
+ * @protected
171
+ */
112
172
  HttpActivityClient.prototype.postActivities = function (activities, logger) {
113
173
  return __awaiter(this, void 0, void 0, function () {
114
174
  var url, method, headers, body, req, res;
@@ -53,6 +53,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
53
53
  Object.defineProperty(exports, "__esModule", { value: true });
54
54
  exports.HttpBatchedActivityClient = void 0;
55
55
  var HttpActivityClient_1 = require("./HttpActivityClient.js");
56
+ /**
57
+ * The HttpBatchedActivityClient is responsible for sending async activities to the backend via HTTP in batches.
58
+ * It extends the HttpActivityClient class and adds functionality for batching activities.
59
+ *
60
+ * This class uses setTimeout and clearTimeout for managing the timeout for sending activities. It also exposes the stop()
61
+ * method to stop the timer and prevent further activity sending, which should be called on shutdown.
62
+ */
56
63
  var HttpBatchedActivityClient = /** @class */ (function (_super) {
57
64
  __extends(HttpBatchedActivityClient, _super);
58
65
  function HttpBatchedActivityClient(config, httpClient) {
@@ -7,6 +7,13 @@ var products_1 = require("../products/index.js");
7
7
  var action_1 = require("../action/index.js");
8
8
  var ActivityType_1 = require("./ActivityType.js");
9
9
  var risk_token_1 = require("../risk_token/index.js");
10
+ /**
11
+ * Creates an async activity object based on the provided parameters.
12
+ * @param activityType - The activity type to create.
13
+ * @param config - The enforcer configuration.
14
+ * @param context - The request context.
15
+ * @returns {AsyncActivity} - The complete async activity payload.
16
+ */
10
17
  var createAsyncActivity = function (activityType, config, context) {
11
18
  var _a;
12
19
  return {
@@ -24,6 +31,13 @@ var createAsyncActivity = function (activityType, config, context) {
24
31
  };
25
32
  };
26
33
  exports.createAsyncActivity = createAsyncActivity;
34
+ /**
35
+ * Creates activity details based on the provided parameters.
36
+ * @param activityType - The activity type to create.
37
+ * @param config - The enforcer configuration.
38
+ * @param context - The request context.
39
+ * @returns {AsyncActivityDetails} - The activity details.
40
+ */
27
41
  var createActivityDetails = function (activityType, config, context) {
28
42
  var commonActivityDetails = (0, exports.createCommonActivityDetails)(config, context);
29
43
  var commonAsyncActivityDetails = (0, exports.createAsyncActivityCommonDetails)(context);
@@ -70,13 +84,21 @@ var createCommonActivityDetails = function (config, context) {
70
84
  };
71
85
  exports.createCommonActivityDetails = createCommonActivityDetails;
72
86
  var addRootContextDataToDetails = function (details, context) {
73
- (0, utils_1.transferExistingProperties)(context, details, {
74
- requestId: 'request_id',
75
- tokenOrigin: 'cookie_origin',
76
- vidSource: 'enforcer_vid_source',
77
- graphqlData: 'graphql_operations',
78
- enforcerStartTime: 'enforcer_start_time',
79
- });
87
+ if (context.requestId) {
88
+ details.request_id = context.requestId;
89
+ }
90
+ if (context.tokenOrigin) {
91
+ details.cookie_origin = context.tokenOrigin;
92
+ }
93
+ if (context.vidSource) {
94
+ details.enforcer_vid_source = context.vidSource;
95
+ }
96
+ if (context.graphqlData) {
97
+ details.graphql_operations = context.graphqlData;
98
+ }
99
+ if (context.enforcerStartTime) {
100
+ details.enforcer_start_time = context.enforcerStartTime;
101
+ }
80
102
  if (context.usedCookieSecret) {
81
103
  details.used_cookie_secret = redactCookieSecret(context.usedCookieSecret);
82
104
  }
@@ -86,10 +108,12 @@ function redactCookieSecret(secret) {
86
108
  return '***'.concat(secret.substring(secret.length - 3, secret.length));
87
109
  }
88
110
  var addConfigDataToDetails = function (details, config) {
89
- (0, utils_1.transferExistingProperties)(config, details, {
90
- remoteConfigId: 'remote_config_id',
91
- remoteConfigVersion: 'remote_config_version',
92
- });
111
+ if (config.remoteConfigId) {
112
+ details.remote_config_id = config.remoteConfigId;
113
+ }
114
+ if (config.remoteConfigVersion) {
115
+ details.remote_config_version = config.remoteConfigVersion;
116
+ }
93
117
  };
94
118
  exports.addConfigDataToDetails = addConfigDataToDetails;
95
119
  var addCustomParametersToDetails = function (details, customParameters) {
@@ -99,47 +123,81 @@ var addCustomParametersToDetails = function (details, customParameters) {
99
123
  };
100
124
  exports.addCustomParametersToDetails = addCustomParametersToDetails;
101
125
  var addProductDataToDetails = function (details, productData) {
102
- (0, utils_1.transferExistingProperties)(productData.ad, details, {
103
- appUserId: 'app_user_id',
104
- additionalFields: 'jwt_additional_fields',
105
- crossTabSession: 'cross_tab_session',
106
- });
107
- (0, utils_1.transferExistingProperties)(productData.ci, details, {
108
- hashedUsername: 'user',
109
- hashedPassword: 'pass',
110
- ciVersion: 'ci_version',
111
- ssoStep: 'sso_step',
112
- });
113
- (0, utils_1.transferExistingProperties)(productData.hsc, details, {
114
- isTokenHscApproved: 'cpa',
115
- });
126
+ if (productData.ad) {
127
+ if (productData.ad.appUserId) {
128
+ details.app_user_id = productData.ad.appUserId;
129
+ }
130
+ if (productData.ad.additionalFields) {
131
+ details.jwt_additional_fields = productData.ad.additionalFields;
132
+ }
133
+ if (productData.ad.crossTabSession) {
134
+ details.cross_tab_session = productData.ad.crossTabSession;
135
+ }
136
+ }
137
+ if (productData.ci) {
138
+ if (productData.ci.hashedUsername) {
139
+ details.user = productData.ci.hashedUsername;
140
+ }
141
+ if (productData.ci.hashedPassword) {
142
+ details.pass = productData.ci.hashedPassword;
143
+ }
144
+ if (productData.ci.ciVersion) {
145
+ details.ci_version = productData.ci.ciVersion;
146
+ }
147
+ if (productData.ci.ssoStep) {
148
+ details.sso_step = productData.ci.ssoStep;
149
+ }
150
+ }
151
+ if (productData.hsc) {
152
+ if (typeof productData.hsc.isTokenHscApproved === 'boolean') {
153
+ details.cpa = productData.hsc.isTokenHscApproved;
154
+ }
155
+ }
116
156
  };
117
157
  exports.addProductDataToDetails = addProductDataToDetails;
118
158
  var addTlsDataToDetails = function (details, tlsData) {
119
- (0, utils_1.transferExistingProperties)(tlsData, details, {
120
- tlsProtocol: 'tls_protocol',
121
- tlsServer: 'tls_server',
122
- tlsCipher: 'tls_cipher',
123
- tlsCiphersSha: 'tls_ciphers_sha',
124
- tlsExtensionSha: 'tls_extension_sha',
125
- tlsPreferredCiphers: 'tls_preferred_ciphers',
126
- tlsJa3Fingerprint: 'tls_ja3_fingerprint',
127
- });
159
+ if (tlsData.tlsCipher) {
160
+ details.tls_cipher = tlsData.tlsCipher;
161
+ }
162
+ if (tlsData.tlsCiphersSha) {
163
+ details.tls_ciphers_sha = tlsData.tlsCiphersSha;
164
+ }
165
+ if (tlsData.tlsExtensionSha) {
166
+ details.tls_extension_sha = tlsData.tlsExtensionSha;
167
+ }
168
+ if (tlsData.tlsPreferredCiphers) {
169
+ details.tls_preferred_ciphers = tlsData.tlsPreferredCiphers;
170
+ }
171
+ if (tlsData.tlsJa3Fingerprint) {
172
+ details.tls_ja3_fingerprint = tlsData.tlsJa3Fingerprint;
173
+ }
174
+ if (tlsData.tlsProtocol) {
175
+ details.tls_protocol = tlsData.tlsProtocol;
176
+ }
177
+ if (tlsData.tlsServer) {
178
+ details.tls_server = tlsData.tlsServer;
179
+ }
128
180
  };
129
181
  exports.addTlsDataToDetails = addTlsDataToDetails;
130
182
  var addServerDataToDetails = function (details, serverData) {
131
- (0, utils_1.transferExistingProperties)(serverData, details, {
132
- region: 'server_info_region',
133
- datacenter: 'server_info_datacenter',
134
- });
183
+ if (serverData.datacenter) {
184
+ details.server_info_datacenter = serverData.datacenter;
185
+ }
186
+ if (serverData.region) {
187
+ details.server_info_region = serverData.region;
188
+ }
135
189
  };
136
190
  exports.addServerDataToDetails = addServerDataToDetails;
137
191
  var addRequestDataToDetails = function (details, requestData) {
138
- (0, utils_1.transferExistingProperties)(requestData, details, {
139
- httpVersion: 'http_version',
140
- method: 'http_method',
141
- requestCookieNames: 'request_cookie_names',
142
- });
192
+ if (requestData.httpVersion) {
193
+ details.http_version = requestData.httpVersion;
194
+ }
195
+ if (requestData.method) {
196
+ details.http_method = requestData.method;
197
+ }
198
+ if (requestData.requestCookieNames) {
199
+ details.request_cookie_names = requestData.requestCookieNames.concat();
200
+ }
143
201
  if (requestData.isUrlDifferentFromRawUrl) {
144
202
  details.raw_url = requestData.rawUrl;
145
203
  }
@@ -157,10 +215,12 @@ var addTokenDataToDetails = function (details, _a) {
157
215
  }
158
216
  }
159
217
  if (mobileData) {
160
- (0, utils_1.transferExistingProperties)(mobileData, details, {
161
- originalToken: 'original_token',
162
- decodedOriginalToken: 'px_decoded_original_token',
163
- });
218
+ if (mobileData.originalToken) {
219
+ details.original_token = mobileData.originalToken.tokenString;
220
+ }
221
+ if (mobileData.decodedOriginalToken) {
222
+ details.px_decoded_original_token = mobileData.decodedOriginalToken;
223
+ }
164
224
  if (mobileData.originalTokenParseResult === risk_token_1.TokenParseResult.DECRYPTION_FAILED) {
165
225
  details.original_token_error = 'cookie_decryption_failed';
166
226
  }
@@ -172,11 +232,15 @@ var addTokenDataToDetails = function (details, _a) {
172
232
  exports.addTokenDataToDetails = addTokenDataToDetails;
173
233
  var addRiskApiDataToAsyncActivityCommonDetails = function (details, context) {
174
234
  var _a;
175
- (0, utils_1.transferExistingProperties)(context.riskApiData, details, {
176
- riskRtt: 'risk_rtt',
177
- s2sCallReason: 's2s_call_reason',
178
- riskStartTime: 'risk_start_time',
179
- });
235
+ if (context.riskApiData.riskRtt) {
236
+ details.risk_rtt = context.riskApiData.riskRtt;
237
+ }
238
+ if (context.riskApiData.s2sCallReason) {
239
+ details.s2s_call_reason = context.riskApiData.s2sCallReason;
240
+ }
241
+ if (context.riskApiData.riskStartTime) {
242
+ details.risk_start_time = context.riskApiData.riskStartTime;
243
+ }
180
244
  if ((_a = context.riskApiData.riskResponse) === null || _a === void 0 ? void 0 : _a.additionalRiskInfo) {
181
245
  details.additional_risk_info = context.riskApiData.riskResponse.additionalRiskInfo;
182
246
  }
@@ -186,10 +250,9 @@ var addRiskApiDataToAsyncActivityCommonDetails = function (details, context) {
186
250
  };
187
251
  exports.addRiskApiDataToAsyncActivityCommonDetails = addRiskApiDataToAsyncActivityCommonDetails;
188
252
  var addResponseDataToAsyncActivityCommonDetails = function (details, context) {
189
- if (context.action !== action_1.Action.BLOCK) {
190
- (0, utils_1.transferExistingProperties)(context.response, details, {
191
- status: 'http_status_code',
192
- });
253
+ var _a;
254
+ if (context.action !== action_1.Action.BLOCK && ((_a = context.response) === null || _a === void 0 ? void 0 : _a.status)) {
255
+ details.http_status_code = context.response.status;
193
256
  }
194
257
  };
195
258
  exports.addResponseDataToAsyncActivityCommonDetails = addResponseDataToAsyncActivityCommonDetails;
@@ -197,11 +260,15 @@ var createPageRequestedActivityDetails = function (context) {
197
260
  var details = {
198
261
  pass_reason: (0, action_1.getReasonForHighestPriorityProduct)(context.reasons),
199
262
  };
200
- (0, utils_1.transferExistingProperties)(context.riskApiData, details, {
201
- errorReason: 's2s_error_reason',
202
- errorHttpStatus: 's2s_error_http_status',
203
- errorMessage: 'error_message',
204
- });
263
+ if (context.riskApiData.errorReason) {
264
+ details.s2s_error_reason = context.riskApiData.errorReason;
265
+ }
266
+ if (context.riskApiData.errorHttpStatus) {
267
+ details.s2s_error_http_status = context.riskApiData.errorHttpStatus;
268
+ }
269
+ if (context.riskApiData.errorMessage) {
270
+ details.error_message = context.riskApiData.errorMessage;
271
+ }
205
272
  return details;
206
273
  };
207
274
  exports.createPageRequestedActivityDetails = createPageRequestedActivityDetails;
@@ -210,7 +277,6 @@ var createBlockActivityDetails = function (context) {
210
277
  block_reason: (0, action_1.getReasonForHighestPriorityProduct)(context.reasons),
211
278
  simulated_block: context.action === action_1.Action.SIMULATED_BLOCK,
212
279
  block_action: context.blockAction,
213
- // @ts-ignore
214
280
  block_score: context.score,
215
281
  };
216
282
  };
@@ -40,6 +40,12 @@ exports.AdditionalActivityHandlerUtils = void 0;
40
40
  var AdditionalActivityHandlerUtils;
41
41
  (function (AdditionalActivityHandlerUtils) {
42
42
  var _this = this;
43
+ /**
44
+ * Invokes the additional activity handler if it is defined in the configuration.
45
+ * @param config - The enforcer configuration.
46
+ * @param context - The request context.
47
+ * @returns {Promise<void>} - A promise that resolves when the additional activity handler is complete.
48
+ */
43
49
  AdditionalActivityHandlerUtils.invokeAdditionalActivityHandler = function (config, context) { return __awaiter(_this, void 0, void 0, function () {
44
50
  var e_1;
45
51
  return __generator(this, function (_a) {
@@ -2,12 +2,26 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BlockerBase = void 0;
4
4
  var http_1 = require("../http/index.js");
5
+ /**
6
+ * Base class for creating a block response.
7
+ */
5
8
  var BlockerBase = /** @class */ (function () {
9
+ /**
10
+ * Creates a new instance of BlockerBase.
11
+ * @param contentType - The Content-Type header to be included in the HTTP block response.
12
+ * @param statusCode - The status code of the HTTP block response.
13
+ * @protected
14
+ */
6
15
  function BlockerBase(contentType, statusCode) {
7
16
  if (statusCode === void 0) { statusCode = 403; }
8
17
  this.contentType = contentType;
9
18
  this.statusCode = statusCode;
10
19
  }
20
+ /**
21
+ * Creates the complete HTTP block response based on the given context.
22
+ * @param context - The request context.
23
+ * @returns {IMinimalResponse} - The HTTP block response.
24
+ */
11
25
  BlockerBase.prototype.createBlockResponse = function (context) {
12
26
  var status = this.statusCode;
13
27
  var headers = this.createHeaders();
@@ -18,6 +18,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.JsonBlockerBase = void 0;
19
19
  var BlockerBase_1 = require("./BlockerBase.js");
20
20
  var http_1 = require("../http/index.js");
21
+ /**
22
+ * Base class for creating a block response with JSON payload.
23
+ *
24
+ * The generic argument JsonPayloadT is the specific structure of the JSON payload to be returned.
25
+ */
21
26
  var JsonBlockerBase = /** @class */ (function (_super) {
22
27
  __extends(JsonBlockerBase, _super);
23
28
  function JsonBlockerBase() {
@@ -2,6 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createBlockData = exports.renderHtml = void 0;
4
4
  var products_1 = require("../products/index.js");
5
+ /**
6
+ * Renders the HTML template with the provided block data.
7
+ * @param htmlTemplate - The HTML template to be rendered. Placeholders are indicated with {{key_name}} where the key_name should be keyof BlockData.
8
+ * @param blockData - The block data to be used for rendering. The keys in the object should match the placeholders in the template.
9
+ * @returns {string} - The final HTML string. If no block data is provided, the original template is returned unchanged.
10
+ */
5
11
  var renderHtml = function (htmlTemplate, blockData) {
6
12
  if (!blockData) {
7
13
  return htmlTemplate;
@@ -15,6 +21,13 @@ var renderHtml = function (htmlTemplate, blockData) {
15
21
  return htmlTemplate;
16
22
  };
17
23
  exports.renderHtml = renderHtml;
24
+ /**
25
+ * Creates the block data object to be used when creating a block response.
26
+ * @param config - The enforcer configuration.
27
+ * @param context - The request context.
28
+ * @param base64Utils - The base64 utility functions.
29
+ * @returns {BlockData} - The block data object.
30
+ */
18
31
  var createBlockData = function (config, context, base64Utils) {
19
32
  var captchaScriptSuffix = '/captcha.js';
20
33
  var b64EncodedUrl = config.enableBlockedUrlOnCaptchaBlockPage
@@ -17,7 +17,17 @@ var logger_1 = require("../logger/index.js");
17
17
  var utils_1 = require("../utils/index.js");
18
18
  var remote_config_1 = require("./remote_config/index.js");
19
19
  var risk_token_1 = require("../risk_token/index.js");
20
+ /**
21
+ * Base class for the enforcer configuration.
22
+ */
20
23
  var ConfigurationBase = /** @class */ (function () {
24
+ /**
25
+ * Creates an instance of the configuration base class.
26
+ * @param params - The configuration parameters as provided by the customer.
27
+ * @param defaultParams - Default parameters for added configurations or any default core configurations that should be overridden.
28
+ * @param removedParams - A map of all removed (unsupported) configuration parameters set to undefined. This parameter can be generated automatically by your IDE.
29
+ * @protected
30
+ */
21
31
  function ConfigurationBase(params, defaultParams, removedParams) {
22
32
  this.defaultConfigParams = __assign(__assign({}, (0, defaults_1.defaultConfigurationParams)()), defaultParams);
23
33
  this.configParams = this.createActiveConfiguration(params, this.defaultConfigParams);
@@ -741,6 +751,13 @@ var ConfigurationBase = /** @class */ (function () {
741
751
  enumerable: false,
742
752
  configurable: true
743
753
  });
754
+ Object.defineProperty(ConfigurationBase.prototype, "isPostEnforceEnabled", {
755
+ get: function () {
756
+ return true;
757
+ },
758
+ enumerable: false,
759
+ configurable: true
760
+ });
744
761
  return ConfigurationBase;
745
762
  }());
746
763
  exports.ConfigurationBase = ConfigurationBase;
@@ -20,6 +20,10 @@ var http_1 = require("../http/index.js");
20
20
  var utils_1 = require("../utils/index.js");
21
21
  var action_1 = require("../action/index.js");
22
22
  var logger_1 = require("../logger/index.js");
23
+ /**
24
+ * The default implementation of the request context which uses the incoming HTTP request and enforcer configuration
25
+ * to populate the context with relevant data.
26
+ */
23
27
  var DefaultContext = /** @class */ (function () {
24
28
  function DefaultContext(config, request, options) {
25
29
  this._shouldSendLogs = false;
@@ -15,6 +15,11 @@ exports.SerializedContext = void 0;
15
15
  var logger_1 = require("../logger/index.js");
16
16
  var risk_token_1 = require("../risk_token/index.js");
17
17
  var risk_api_1 = require("../risk_api/index.js");
18
+ /**
19
+ * Implements the `IContext` interface based an already serialized `ContextJson`. This class does not extract data from the
20
+ * incoming request, but rather uses already-extracted data from the `ContextJson` (likely returned from the `DefaultContext.toJSON()`
21
+ * function) and fills in the gaps using the other parameters.
22
+ */
18
23
  var SerializedContext = /** @class */ (function () {
19
24
  function SerializedContext(config, contextJson, request, urlUtils) {
20
25
  var _a;