perimeterx-js-core 0.9.0 → 0.11.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 (273) hide show
  1. package/README.md +1 -1
  2. package/lib/cjs/action/utils.js +6 -1
  3. package/lib/cjs/activities/utils.js +13 -8
  4. package/lib/cjs/blocker/BlockerBase.js +29 -0
  5. package/lib/cjs/blocker/JsonBlockerBase.js +36 -0
  6. package/lib/cjs/blocker/MobileBlocker.js +48 -0
  7. package/lib/cjs/blocker/index.js +5 -3
  8. package/lib/cjs/blocker/{BlockAction.js → model/BlockAction.js} +2 -0
  9. package/lib/cjs/blocker/model/index.js +19 -0
  10. package/lib/cjs/{products/bot_defender/block → blocker}/utils.js +7 -5
  11. package/lib/cjs/config/{StaticConfigurationBase.js → ConfigurationBase.js} +127 -85
  12. package/lib/cjs/config/ConfigurationBuilderBase.js +129 -0
  13. package/lib/cjs/config/{DefaultConfigurations.js → defaults/DefaultCommonConfigurationParams.js} +7 -9
  14. package/lib/cjs/config/defaults/DefaultConfigurationParams.js +18 -0
  15. package/lib/cjs/config/defaults/DefaultRemoteConfigurationParams.js +8 -0
  16. package/lib/cjs/config/defaults/DefaultStaticConfigurationParams.js +11 -0
  17. package/lib/cjs/config/defaults/index.js +20 -0
  18. package/lib/cjs/config/index.js +20 -5
  19. package/lib/cjs/config/params/InitializeConfigurationParams.js +2 -0
  20. package/lib/cjs/config/params/RemoteConfigurationParams.js +2 -0
  21. package/lib/cjs/config/params/StaticConfigurationParams.js +2 -0
  22. package/lib/cjs/config/params/index.js +21 -0
  23. package/lib/cjs/config/remote_config/DefaultRemoteConfigUpdater.js +188 -0
  24. package/lib/cjs/config/remote_config/IRemoteConfigUpdater.js +2 -0
  25. package/lib/cjs/config/remote_config/constants.js +6 -0
  26. package/lib/cjs/config/remote_config/index.js +22 -0
  27. package/lib/cjs/config/remote_config/model/RemoteConfigData.js +2 -0
  28. package/lib/cjs/config/remote_config/model/RemoteConfigUpdateRequestData.js +2 -0
  29. package/lib/cjs/config/remote_config/model/index.js +18 -0
  30. package/lib/cjs/config/remote_config/service_client/HttpRemoteConfigServiceClient.js +77 -0
  31. package/lib/cjs/config/remote_config/service_client/IRemoteConfigServiceClient.js +2 -0
  32. package/lib/cjs/config/remote_config/service_client/index.js +18 -0
  33. package/lib/cjs/config/remote_config/storage_client/IRemoteConfigStorageClient.js +2 -0
  34. package/lib/cjs/config/remote_config/storage_client/index.js +17 -0
  35. package/lib/cjs/context/DefaultContext.js +6 -0
  36. package/lib/cjs/custom_parameters/CustomParameters.js +1 -0
  37. package/lib/cjs/custom_parameters/CustomParametersUtils.js +5 -0
  38. package/lib/cjs/enforcer/EnforcerBase.js +19 -1
  39. package/lib/cjs/http/utils/constants.js +2 -1
  40. package/lib/cjs/logger/HttpLogServiceClient.js +6 -0
  41. package/lib/cjs/logger/LoggerBase.js +17 -6
  42. package/lib/cjs/phase/flow/EnforceFlow.js +4 -1
  43. package/lib/cjs/phase/flow/FilterFlow.js +9 -4
  44. package/lib/cjs/phase/impl/EnrichContextFromRequestPhase.js +2 -2
  45. package/lib/cjs/phase/impl/FirstPartyPhase.js +4 -1
  46. package/lib/cjs/phase/impl/RiskApiPhase.js +5 -8
  47. package/lib/cjs/phase/impl/SendLogsPhase.js +5 -9
  48. package/lib/cjs/phase/impl/UpdateRemoteConfigPhase.js +71 -0
  49. package/lib/cjs/phase/impl/index.js +1 -0
  50. package/lib/cjs/products/bot_defender/block/captcha/HtmlCaptchaBlocker.js +24 -16
  51. package/lib/cjs/products/bot_defender/block/captcha/JsonCaptchaBlocker.js +25 -18
  52. package/lib/cjs/products/bot_defender/block/captcha/MobileCaptchaBlocker.js +19 -31
  53. package/lib/cjs/products/bot_defender/block/index.js +1 -1
  54. package/lib/cjs/products/bot_defender/block/model/JsonCaptchaBlockPayload.js +2 -0
  55. package/lib/cjs/products/bot_defender/block/model/index.js +1 -2
  56. package/lib/cjs/products/hype_sale_challenge/HypeSaleChallenge.js +73 -0
  57. package/lib/cjs/products/hype_sale_challenge/IHypeSaleChallenge.js +2 -0
  58. package/lib/cjs/products/hype_sale_challenge/block/JsonHypeSaleChallengeBlocker.js +39 -0
  59. package/lib/cjs/products/hype_sale_challenge/block/MobileHypeSaleChallengeBlocker.js +28 -0
  60. package/lib/cjs/products/hype_sale_challenge/block/index.js +19 -0
  61. package/lib/cjs/products/hype_sale_challenge/block/templates/hype_sale_challenge_template.js +4 -0
  62. package/lib/cjs/products/hype_sale_challenge/block/templates/index.js +17 -0
  63. package/lib/cjs/products/hype_sale_challenge/index.js +21 -0
  64. package/lib/cjs/products/hype_sale_challenge/model/HypeSaleChallengeData.js +2 -0
  65. package/lib/cjs/products/hype_sale_challenge/model/JsonHypeSaleChallengeBlockPayload.js +2 -0
  66. package/lib/cjs/products/hype_sale_challenge/model/index.js +18 -0
  67. package/lib/cjs/products/hype_sale_challenge/utils.js +23 -0
  68. package/lib/cjs/products/index.js +1 -0
  69. package/lib/cjs/risk_api/risk_response/CommonRiskResponsePayload.js +2 -0
  70. package/lib/cjs/risk_api/risk_response/RiskResponseBase.js +8 -0
  71. package/lib/cjs/risk_api/risk_response/index.js +1 -0
  72. package/lib/cjs/risk_token/token/v2/DefaultTokenV2.js +11 -1
  73. package/lib/cjs/risk_token/token/v3/DefaultTokenV3.js +8 -0
  74. package/lib/cjs/telemetry/DefaultTelemetry.js +2 -31
  75. package/lib/cjs/telemetry/constants.js +1 -5
  76. package/lib/cjs/utils/WaitsUntil.js +58 -0
  77. package/lib/cjs/utils/constants.js +4 -3
  78. package/lib/cjs/utils/index.js +2 -0
  79. package/lib/cjs/utils/timestamp_hmac_header_validator/DefaultTimestampHmacHeaderValidator.js +45 -0
  80. package/lib/cjs/utils/timestamp_hmac_header_validator/ITimestampHmacHeaderValidator.js +2 -0
  81. package/lib/cjs/utils/timestamp_hmac_header_validator/index.js +18 -0
  82. package/lib/cjs/utils/utils.js +5 -1
  83. package/lib/esm/action/utils.js +4 -0
  84. package/lib/esm/activities/utils.js +12 -7
  85. package/lib/esm/blocker/BlockerBase.js +24 -0
  86. package/lib/esm/blocker/JsonBlockerBase.js +17 -0
  87. package/lib/esm/blocker/MobileBlocker.js +29 -0
  88. package/lib/esm/blocker/index.js +5 -3
  89. package/lib/esm/blocker/{BlockAction.js → model/BlockAction.js} +2 -0
  90. package/lib/esm/blocker/model/index.js +3 -0
  91. package/lib/esm/{products/bot_defender/block → blocker}/utils.js +4 -2
  92. package/lib/esm/config/{StaticConfigurationBase.js → ConfigurationBase.js} +24 -3
  93. package/lib/esm/config/ConfigurationBuilderBase.js +60 -0
  94. package/lib/esm/config/{DefaultConfigurations.js → defaults/DefaultCommonConfigurationParams.js} +6 -8
  95. package/lib/esm/config/defaults/DefaultConfigurationParams.js +8 -0
  96. package/lib/esm/config/defaults/DefaultRemoteConfigurationParams.js +5 -0
  97. package/lib/esm/config/defaults/DefaultStaticConfigurationParams.js +8 -0
  98. package/lib/esm/config/defaults/index.js +4 -0
  99. package/lib/esm/config/index.js +6 -2
  100. package/lib/esm/config/params/InitializeConfigurationParams.js +1 -0
  101. package/lib/esm/config/params/RemoteConfigurationParams.js +1 -0
  102. package/lib/esm/config/params/StaticConfigurationParams.js +1 -0
  103. package/lib/esm/config/params/index.js +5 -0
  104. package/lib/esm/config/remote_config/DefaultRemoteConfigUpdater.js +97 -0
  105. package/lib/esm/config/remote_config/IRemoteConfigUpdater.js +1 -0
  106. package/lib/esm/config/remote_config/constants.js +3 -0
  107. package/lib/esm/config/remote_config/index.js +6 -0
  108. package/lib/esm/config/remote_config/model/RemoteConfigData.js +1 -0
  109. package/lib/esm/config/remote_config/model/RemoteConfigUpdateRequestData.js +1 -0
  110. package/lib/esm/config/remote_config/model/index.js +2 -0
  111. package/lib/esm/config/remote_config/service_client/HttpRemoteConfigServiceClient.js +27 -0
  112. package/lib/esm/config/remote_config/service_client/IRemoteConfigServiceClient.js +1 -0
  113. package/lib/esm/config/remote_config/service_client/index.js +2 -0
  114. package/lib/esm/config/remote_config/storage_client/IRemoteConfigStorageClient.js +1 -0
  115. package/lib/esm/config/remote_config/storage_client/index.js +1 -0
  116. package/lib/esm/context/DefaultContext.js +6 -0
  117. package/lib/esm/custom_parameters/CustomParameters.js +1 -1
  118. package/lib/esm/custom_parameters/CustomParametersUtils.js +5 -0
  119. package/lib/esm/enforcer/EnforcerBase.js +19 -1
  120. package/lib/esm/http/utils/constants.js +1 -0
  121. package/lib/esm/logger/HttpLogServiceClient.js +8 -0
  122. package/lib/esm/logger/LoggerBase.js +11 -6
  123. package/lib/esm/phase/flow/EnforceFlow.js +4 -1
  124. package/lib/esm/phase/flow/FilterFlow.js +10 -5
  125. package/lib/esm/phase/impl/EnrichContextFromRequestPhase.js +1 -1
  126. package/lib/esm/phase/impl/FirstPartyPhase.js +5 -1
  127. package/lib/esm/phase/impl/RiskApiPhase.js +3 -5
  128. package/lib/esm/phase/impl/SendLogsPhase.js +1 -3
  129. package/lib/esm/phase/impl/UpdateRemoteConfigPhase.js +23 -0
  130. package/lib/esm/phase/impl/index.js +1 -0
  131. package/lib/esm/products/bot_defender/block/captcha/HtmlCaptchaBlocker.js +6 -14
  132. package/lib/esm/products/bot_defender/block/captcha/JsonCaptchaBlocker.js +6 -17
  133. package/lib/esm/products/bot_defender/block/captcha/MobileCaptchaBlocker.js +3 -32
  134. package/lib/esm/products/bot_defender/block/index.js +1 -1
  135. package/lib/esm/products/bot_defender/block/model/JsonCaptchaBlockPayload.js +1 -0
  136. package/lib/esm/products/bot_defender/block/model/index.js +1 -2
  137. package/lib/esm/products/hype_sale_challenge/HypeSaleChallenge.js +69 -0
  138. package/lib/esm/products/hype_sale_challenge/IHypeSaleChallenge.js +1 -0
  139. package/lib/esm/products/hype_sale_challenge/block/JsonHypeSaleChallengeBlocker.js +18 -0
  140. package/lib/esm/products/hype_sale_challenge/block/MobileHypeSaleChallengeBlocker.js +7 -0
  141. package/lib/esm/products/hype_sale_challenge/block/index.js +3 -0
  142. package/lib/esm/products/hype_sale_challenge/block/templates/hype_sale_challenge_template.js +42 -0
  143. package/lib/esm/products/hype_sale_challenge/block/templates/index.js +1 -0
  144. package/lib/esm/products/hype_sale_challenge/index.js +5 -0
  145. package/lib/esm/products/hype_sale_challenge/model/HypeSaleChallengeData.js +1 -0
  146. package/lib/esm/products/hype_sale_challenge/model/JsonHypeSaleChallengeBlockPayload.js +1 -0
  147. package/lib/esm/products/hype_sale_challenge/model/index.js +2 -0
  148. package/lib/esm/products/hype_sale_challenge/utils.js +11 -0
  149. package/lib/esm/products/index.js +1 -0
  150. package/lib/esm/risk_api/client/PostRiskApiClientBase.js +1 -1
  151. package/lib/esm/risk_api/risk_response/CommonRiskResponsePayload.js +1 -0
  152. package/lib/esm/risk_api/risk_response/RiskResponseBase.js +3 -0
  153. package/lib/esm/risk_api/risk_response/index.js +1 -0
  154. package/lib/esm/risk_token/token/v2/DefaultTokenV2.js +7 -1
  155. package/lib/esm/risk_token/token/v3/DefaultTokenV3.js +3 -0
  156. package/lib/esm/telemetry/DefaultTelemetry.js +5 -34
  157. package/lib/esm/telemetry/constants.js +0 -4
  158. package/lib/esm/utils/WaitsUntil.js +12 -0
  159. package/lib/esm/utils/constants.js +3 -2
  160. package/lib/esm/utils/index.js +2 -0
  161. package/lib/esm/utils/timestamp_hmac_header_validator/DefaultTimestampHmacHeaderValidator.js +44 -0
  162. package/lib/esm/utils/timestamp_hmac_header_validator/ITimestampHmacHeaderValidator.js +1 -0
  163. package/lib/esm/utils/timestamp_hmac_header_validator/index.js +2 -0
  164. package/lib/esm/utils/utils.js +3 -0
  165. package/lib/types/action/utils.d.ts +2 -0
  166. package/lib/types/activities/model/CommonActivityDetails.d.ts +2 -0
  167. package/lib/types/activities/utils.d.ts +371 -110
  168. package/lib/types/blocker/BlockerBase.d.ts +11 -0
  169. package/lib/types/blocker/JsonBlockerBase.d.ts +9 -0
  170. package/lib/types/blocker/MobileBlocker.d.ts +13 -0
  171. package/lib/types/blocker/index.d.ts +5 -3
  172. package/lib/types/blocker/model/BlockAction.d.ts +7 -0
  173. package/lib/types/{products/bot_defender/block → blocker}/model/BlockData.d.ts +2 -1
  174. package/lib/types/blocker/model/index.d.ts +3 -0
  175. package/lib/types/blocker/utils.d.ts +631 -0
  176. package/lib/types/config/{StaticConfigurationBase.d.ts → ConfigurationBase.d.ts} +8 -2
  177. package/lib/types/config/ConfigurationBuilderBase.d.ts +13 -0
  178. package/lib/types/config/IConfiguration.d.ts +25 -1
  179. package/lib/types/config/defaults/DefaultCommonConfigurationParams.d.ts +2 -0
  180. package/lib/types/config/defaults/DefaultConfigurationParams.d.ts +2 -0
  181. package/lib/types/config/defaults/DefaultRemoteConfigurationParams.d.ts +2 -0
  182. package/lib/types/config/defaults/DefaultStaticConfigurationParams.d.ts +2 -0
  183. package/lib/types/config/defaults/index.d.ts +4 -0
  184. package/lib/types/config/index.d.ts +6 -4
  185. package/lib/types/config/{ConfigurationParams.d.ts → params/CommonConfigurationParams.d.ts} +10 -12
  186. package/lib/types/config/params/ConfigurationParams.d.ts +4 -0
  187. package/lib/types/config/params/InitializeConfigurationParams.d.ts +3 -0
  188. package/lib/types/config/params/RemoteConfigurationParams.d.ts +5 -0
  189. package/lib/types/config/params/StaticConfigurationParams.d.ts +8 -0
  190. package/lib/types/config/params/index.d.ts +5 -0
  191. package/lib/types/config/remote_config/DefaultRemoteConfigUpdater.d.ts +35 -0
  192. package/lib/types/config/remote_config/IRemoteConfigUpdater.d.ts +6 -0
  193. package/lib/types/config/remote_config/constants.d.ts +3 -0
  194. package/lib/types/config/remote_config/index.d.ts +6 -0
  195. package/lib/types/config/remote_config/model/RemoteConfigData.d.ts +7 -0
  196. package/lib/types/config/remote_config/model/RemoteConfigUpdateRequestData.d.ts +3 -0
  197. package/lib/types/config/remote_config/model/index.d.ts +2 -0
  198. package/lib/types/config/remote_config/service_client/HttpRemoteConfigServiceClient.d.ts +12 -0
  199. package/lib/types/config/remote_config/service_client/IRemoteConfigServiceClient.d.ts +5 -0
  200. package/lib/types/config/remote_config/service_client/index.d.ts +2 -0
  201. package/lib/types/config/remote_config/storage_client/IRemoteConfigStorageClient.d.ts +6 -0
  202. package/lib/types/config/remote_config/storage_client/index.d.ts +1 -0
  203. package/lib/types/context/DefaultContext.d.ts +2 -0
  204. package/lib/types/context/interfaces/IContext.d.ts +4 -0
  205. package/lib/types/custom_parameters/CustomParameters.d.ts +2 -0
  206. package/lib/types/enforcer/options/EnforcerBaseOptions.d.ts +4 -0
  207. package/lib/types/http/utils/constants.d.ts +1 -0
  208. package/lib/types/logger/HttpLogServiceClient.d.ts +2 -0
  209. package/lib/types/logger/ILogger.d.ts +4 -2
  210. package/lib/types/logger/LoggerBase.d.ts +3 -3
  211. package/lib/types/logger/model/LogMetadata.d.ts +2 -0
  212. package/lib/types/logger/model/LogRecord.d.ts +1 -1
  213. package/lib/types/phase/flow/FilterFlow.d.ts +1 -1
  214. package/lib/types/phase/impl/FirstPartyPhase.d.ts +3 -1
  215. package/lib/types/phase/impl/RiskApiPhase.d.ts +1 -1
  216. package/lib/types/phase/impl/UpdateRemoteConfigPhase.d.ts +12 -0
  217. package/lib/types/phase/impl/index.d.ts +1 -0
  218. package/lib/types/products/bot_defender/block/captcha/HtmlCaptchaBlocker.d.ts +3 -4
  219. package/lib/types/products/bot_defender/block/captcha/JsonCaptchaBlocker.d.ts +4 -4
  220. package/lib/types/products/bot_defender/block/captcha/MobileCaptchaBlocker.d.ts +2 -8
  221. package/lib/types/products/bot_defender/block/index.d.ts +1 -1
  222. package/lib/types/products/bot_defender/block/model/{JsonBlockPayload.d.ts → JsonCaptchaBlockPayload.d.ts} +1 -1
  223. package/lib/types/products/bot_defender/block/model/index.d.ts +1 -2
  224. package/lib/types/products/hype_sale_challenge/HypeSaleChallenge.d.ts +26 -0
  225. package/lib/types/products/hype_sale_challenge/IHypeSaleChallenge.d.ts +5 -0
  226. package/lib/types/products/hype_sale_challenge/block/JsonHypeSaleChallengeBlocker.d.ts +9 -0
  227. package/lib/types/products/hype_sale_challenge/block/MobileHypeSaleChallengeBlocker.d.ts +6 -0
  228. package/lib/types/products/hype_sale_challenge/block/index.d.ts +3 -0
  229. package/lib/types/products/hype_sale_challenge/block/templates/hype_sale_challenge_template.d.ts +1 -0
  230. package/lib/types/products/hype_sale_challenge/block/templates/index.d.ts +1 -0
  231. package/lib/types/products/hype_sale_challenge/index.d.ts +5 -0
  232. package/lib/types/products/hype_sale_challenge/model/HypeSaleChallengeData.d.ts +5 -0
  233. package/lib/types/products/hype_sale_challenge/model/JsonHypeSaleChallengeBlockPayload.d.ts +5 -0
  234. package/lib/types/products/hype_sale_challenge/model/index.d.ts +2 -0
  235. package/lib/types/products/hype_sale_challenge/utils.d.ts +5 -0
  236. package/lib/types/products/index.d.ts +1 -0
  237. package/lib/types/products/interfaces/ProductDataType.d.ts +2 -1
  238. package/lib/types/risk_api/risk_response/CommonRiskResponsePayload.d.ts +14 -0
  239. package/lib/types/risk_api/risk_response/IRiskResponse.d.ts +1 -0
  240. package/lib/types/risk_api/risk_response/RiskResponseBase.d.ts +1 -0
  241. package/lib/types/risk_api/risk_response/index.d.ts +1 -0
  242. package/lib/types/risk_api/risk_response/v2/RiskResponseV2Payload.d.ts +2 -12
  243. package/lib/types/risk_api/risk_response/v3/RiskResponseV3Payload.d.ts +2 -12
  244. package/lib/types/risk_token/token/IToken.d.ts +4 -0
  245. package/lib/types/risk_token/token/TokenBase.d.ts +1 -0
  246. package/lib/types/risk_token/token/v2/DefaultTokenV2.d.ts +1 -0
  247. package/lib/types/risk_token/token/v3/DefaultTokenV3.d.ts +1 -0
  248. package/lib/types/risk_token/token/v3/TokenV3Payload.d.ts +1 -0
  249. package/lib/types/telemetry/DefaultTelemetry.d.ts +11 -12
  250. package/lib/types/telemetry/constants.d.ts +0 -4
  251. package/lib/types/utils/WaitsUntil.d.ts +9 -0
  252. package/lib/types/utils/constants.d.ts +3 -2
  253. package/lib/types/utils/index.d.ts +2 -0
  254. package/lib/types/utils/timestamp_hmac_header_validator/DefaultTimestampHmacHeaderValidator.d.ts +13 -0
  255. package/lib/types/utils/timestamp_hmac_header_validator/ITimestampHmacHeaderValidator.d.ts +3 -0
  256. package/lib/types/utils/timestamp_hmac_header_validator/index.d.ts +2 -0
  257. package/lib/types/utils/utils.d.ts +1 -0
  258. package/package.json +5 -3
  259. package/lib/cjs/blocker/BlockActionToProductMap.js +0 -10
  260. package/lib/esm/blocker/BlockActionToProductMap.js +0 -7
  261. package/lib/types/blocker/BlockAction.d.ts +0 -5
  262. package/lib/types/blocker/BlockActionToProductMap.d.ts +0 -3
  263. package/lib/types/config/DefaultConfigurations.d.ts +0 -2
  264. package/lib/types/products/bot_defender/block/utils.d.ts +0 -5
  265. /package/lib/cjs/blocker/{BlockActionToWordMap.js → model/BlockActionToWordMap.js} +0 -0
  266. /package/lib/cjs/{products/bot_defender/block → blocker}/model/BlockData.js +0 -0
  267. /package/lib/cjs/config/{ConfigurationParams.js → params/CommonConfigurationParams.js} +0 -0
  268. /package/lib/cjs/{products/bot_defender/block/model/JsonBlockPayload.js → config/params/ConfigurationParams.js} +0 -0
  269. /package/lib/esm/blocker/{BlockActionToWordMap.js → model/BlockActionToWordMap.js} +0 -0
  270. /package/lib/esm/{products/bot_defender/block → blocker}/model/BlockData.js +0 -0
  271. /package/lib/esm/config/{ConfigurationParams.js → params/CommonConfigurationParams.js} +0 -0
  272. /package/lib/esm/{products/bot_defender/block/model/JsonBlockPayload.js → config/params/ConfigurationParams.js} +0 -0
  273. /package/lib/types/blocker/{BlockActionToWordMap.d.ts → model/BlockActionToWordMap.d.ts} +0 -0
package/README.md CHANGED
@@ -60,7 +60,7 @@ your enforcer's configuration setup.
60
60
  `IConfiguration` - Represents the enforcer configuration and is required to construct most other components
61
61
  in this library.
62
62
 
63
- `StaticConfigurationBase` - An implementation of the above interface that validates provided configurations and merges
63
+ `ConfigurationBase` - An implementation of the above interface that validates provided configurations and merges
64
64
  them with default ones.
65
65
 
66
66
  `DefaultConfigurations` - A static object complete with all default enforcer configurations.
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getDecisionFromActions = exports.getProductActions = exports.getDecisionFromContext = void 0;
3
+ exports.getReasonForHighestPriorityProduct = exports.getDecisionFromActions = exports.getProductActions = exports.getDecisionFromContext = void 0;
4
4
  var Action_1 = require("./Action");
5
+ var products_1 = require("../products");
5
6
  var ActionPriorityOrder_1 = require("./ActionPriorityOrder");
6
7
  var getDecisionFromContext = function (context) {
7
8
  return (0, exports.getDecisionFromActions)((0, exports.getProductActions)(context));
@@ -46,3 +47,7 @@ var createDecision = function (tally) {
46
47
  }
47
48
  return { action: Action_1.Action.PASS_REQUEST };
48
49
  };
50
+ var getReasonForHighestPriorityProduct = function (reasons) {
51
+ return reasons[products_1.PRODUCT_PRIORITY_ORDER.find(function (product) { return !!reasons[product]; })];
52
+ };
53
+ exports.getReasonForHighestPriorityProduct = getReasonForHighestPriorityProduct;
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toHeaderEntryArray = exports.createAdditionalS2SActivityDetails = exports.createBlockActivityDetails = exports.createPageRequestedActivityDetails = exports.addResponseDataToAsyncActivityCommonDetails = exports.addRiskApiDataToAsyncActivityCommonDetails = exports.addTokenDataToDetails = exports.addRequestDataToDetails = exports.addServerDataToDetails = exports.addTlsDataToDetails = exports.addProductDataToDetails = exports.addCustomParametersToDetails = exports.addRootContextDataToDetails = exports.createCommonActivityDetails = exports.createAsyncActivityCommonDetails = exports.createActivityDetails = exports.createAsyncActivity = void 0;
3
+ exports.toHeaderEntryArray = exports.createAdditionalS2SActivityDetails = exports.createBlockActivityDetails = exports.createPageRequestedActivityDetails = exports.addResponseDataToAsyncActivityCommonDetails = exports.addRiskApiDataToAsyncActivityCommonDetails = exports.addTokenDataToDetails = exports.addRequestDataToDetails = exports.addServerDataToDetails = exports.addTlsDataToDetails = exports.addProductDataToDetails = exports.addCustomParametersToDetails = exports.addConfigDataToDetails = exports.addRootContextDataToDetails = exports.createCommonActivityDetails = exports.createAsyncActivityCommonDetails = exports.createActivityDetails = exports.createAsyncActivity = void 0;
4
4
  var utils_1 = require("../utils");
5
5
  var products_1 = require("../products");
6
- var blocker_1 = require("../blocker");
7
6
  var action_1 = require("../action");
8
7
  var ActivityType_1 = require("./ActivityType");
9
8
  var risk_token_1 = require("../risk_token");
@@ -58,6 +57,7 @@ var createCommonActivityDetails = function (config, context) {
58
57
  // Note: risk_mode currently reflects only Bot Defender mode
59
58
  risk_mode: ((_a = context.productData.bd) === null || _a === void 0 ? void 0 : _a.isMonitoredRequest) ? utils_1.ModuleMode.MONITOR : utils_1.ModuleMode.ACTIVE_BLOCKING,
60
59
  };
60
+ (0, exports.addConfigDataToDetails)(details, config);
61
61
  (0, exports.addRootContextDataToDetails)(details, context);
62
62
  (0, exports.addRequestDataToDetails)(details, context.requestData);
63
63
  (0, exports.addTokenDataToDetails)(details, context.tokenData);
@@ -77,6 +77,12 @@ var addRootContextDataToDetails = function (details, context) {
77
77
  });
78
78
  };
79
79
  exports.addRootContextDataToDetails = addRootContextDataToDetails;
80
+ var addConfigDataToDetails = function (details, config) {
81
+ if (config.remoteConfigVersion) {
82
+ details.remote_config_version = config.remoteConfigVersion;
83
+ }
84
+ };
85
+ exports.addConfigDataToDetails = addConfigDataToDetails;
80
86
  var addCustomParametersToDetails = function (details, customParameters) {
81
87
  if (customParameters) {
82
88
  Object.assign(details, customParameters);
@@ -95,6 +101,9 @@ var addProductDataToDetails = function (details, productData) {
95
101
  ciVersion: 'ci_version',
96
102
  ssoStep: 'sso_step',
97
103
  });
104
+ (0, utils_1.transferExistingProperties)(productData.hsc, details, {
105
+ isTokenHscApproved: 'cpa',
106
+ });
98
107
  };
99
108
  exports.addProductDataToDetails = addProductDataToDetails;
100
109
  var addTlsDataToDetails = function (details, tlsData) {
@@ -171,9 +180,7 @@ var addResponseDataToAsyncActivityCommonDetails = function (details, context) {
171
180
  exports.addResponseDataToAsyncActivityCommonDetails = addResponseDataToAsyncActivityCommonDetails;
172
181
  var createPageRequestedActivityDetails = function (context) {
173
182
  var details = {};
174
- details.pass_reason = Object.values(context.reasons)
175
- .filter(function (x) { return x; })
176
- .join(', ');
183
+ details.pass_reason = (0, action_1.getReasonForHighestPriorityProduct)(context.reasons);
177
184
  (0, utils_1.transferExistingProperties)(context.riskApiData, details, {
178
185
  errorReason: 's2s_error_reason',
179
186
  errorHttpStatus: 's2s_error_http_status',
@@ -183,10 +190,8 @@ var createPageRequestedActivityDetails = function (context) {
183
190
  };
184
191
  exports.createPageRequestedActivityDetails = createPageRequestedActivityDetails;
185
192
  var createBlockActivityDetails = function (context) {
186
- var _a;
187
193
  var details = {};
188
- var blockingProduct = blocker_1.BLOCK_ACTION_TO_PRODUCT_MAP.get(context.blockAction);
189
- details.block_reason = (_a = context.reasons) === null || _a === void 0 ? void 0 : _a[blockingProduct];
194
+ details.block_reason = (0, action_1.getReasonForHighestPriorityProduct)(context.reasons);
190
195
  details.simulated_block = context.action === action_1.Action.SIMULATED_BLOCK;
191
196
  (0, utils_1.transferExistingProperties)(context, details, {
192
197
  blockAction: 'block_action',
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BlockerBase = void 0;
4
+ var http_1 = require("../http");
5
+ var BlockerBase = /** @class */ (function () {
6
+ function BlockerBase(contentType, statusCode) {
7
+ if (statusCode === void 0) { statusCode = 403; }
8
+ this.contentType = contentType;
9
+ this.statusCode = statusCode;
10
+ }
11
+ BlockerBase.prototype.createBlockResponse = function (context) {
12
+ var status = this.statusCode;
13
+ var headers = this.createHeaders(context);
14
+ var body = this.createBlockBody(context);
15
+ return new http_1.MinimalResponseImpl({
16
+ status: status,
17
+ headers: headers,
18
+ body: body,
19
+ });
20
+ };
21
+ BlockerBase.prototype.createHeaders = function (context) {
22
+ var _a;
23
+ return _a = {},
24
+ _a[http_1.CONTENT_TYPE_HEADER_NAME] = [this.contentType],
25
+ _a;
26
+ };
27
+ return BlockerBase;
28
+ }());
29
+ exports.BlockerBase = BlockerBase;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.JsonBlockerBase = void 0;
19
+ var BlockerBase_1 = require("./BlockerBase");
20
+ var http_1 = require("../http");
21
+ var JsonBlockerBase = /** @class */ (function (_super) {
22
+ __extends(JsonBlockerBase, _super);
23
+ function JsonBlockerBase() {
24
+ return _super.call(this, http_1.ContentType.APPLICATION_JSON) || this;
25
+ }
26
+ JsonBlockerBase.prototype.shouldBlock = function (context) {
27
+ var acceptHeaderValue = context.requestData.request.headers.get(http_1.ACCEPT_HEADER_NAME) || '';
28
+ var acceptHeaderContainsJson = acceptHeaderValue === null || acceptHeaderValue === void 0 ? void 0 : acceptHeaderValue.split(',').some(function (value) { return value.toLowerCase() === http_1.ContentType.APPLICATION_JSON; });
29
+ return !context.isMobile && acceptHeaderContainsJson;
30
+ };
31
+ JsonBlockerBase.prototype.createBlockBody = function (context) {
32
+ return JSON.stringify(this.createJsonPayload(context));
33
+ };
34
+ return JsonBlockerBase;
35
+ }(BlockerBase_1.BlockerBase));
36
+ exports.JsonBlockerBase = JsonBlockerBase;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.MobileBlocker = void 0;
19
+ var http_1 = require("../http");
20
+ var blocker_1 = require("../blocker");
21
+ var BlockerBase_1 = require("./BlockerBase");
22
+ var MobileBlocker = /** @class */ (function (_super) {
23
+ __extends(MobileBlocker, _super);
24
+ function MobileBlocker(config, base64Utils, template) {
25
+ var _this = _super.call(this, http_1.ContentType.APPLICATION_JSON) || this;
26
+ _this.config = config;
27
+ _this.base64Utils = base64Utils;
28
+ _this.template = template;
29
+ return _this;
30
+ }
31
+ MobileBlocker.prototype.shouldBlock = function (context) {
32
+ return context.isMobile;
33
+ };
34
+ MobileBlocker.prototype.createBlockBody = function (context) {
35
+ var blockData = (0, blocker_1.createBlockData)(this.config, context);
36
+ var html = (0, blocker_1.renderHtml)(this.template, blockData);
37
+ return JSON.stringify({
38
+ action: blocker_1.BLOCK_ACTION_TO_WORD_MAP.get(blockData.blockAction),
39
+ uuid: blockData.uuid,
40
+ vid: blockData.vid,
41
+ appId: blockData.appId,
42
+ page: this.base64Utils.base64Encode(html),
43
+ collectorHost: this.config.backendCollectorUrl,
44
+ });
45
+ };
46
+ return MobileBlocker;
47
+ }(BlockerBase_1.BlockerBase));
48
+ exports.MobileBlocker = MobileBlocker;
@@ -16,6 +16,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./IConditionalBlocker"), exports);
18
18
  __exportStar(require("./IBlocker"), exports);
19
- __exportStar(require("./BlockAction"), exports);
20
- __exportStar(require("./BlockActionToProductMap"), exports);
21
- __exportStar(require("./BlockActionToWordMap"), exports);
19
+ __exportStar(require("./BlockerBase"), exports);
20
+ __exportStar(require("./JsonBlockerBase"), exports);
21
+ __exportStar(require("./MobileBlocker"), exports);
22
+ __exportStar(require("./model"), exports);
23
+ __exportStar(require("./utils"), exports);
@@ -6,4 +6,6 @@ var BlockAction;
6
6
  BlockAction["CAPTCHA"] = "c";
7
7
  BlockAction["RATE_LIMIT"] = "r";
8
8
  BlockAction["CHALLENGE"] = "j";
9
+ BlockAction["HYPE_SALE_CHALLENGE"] = "hsc";
10
+ BlockAction["HYPE_SALE_CHALLENGE_LEGACY"] = "cp";
9
11
  })(BlockAction || (exports.BlockAction = BlockAction = {}));
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./BlockAction"), exports);
18
+ __exportStar(require("./BlockActionToWordMap"), exports);
19
+ __exportStar(require("./BlockData"), exports);
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createBlockData = exports.renderHtml = void 0;
4
- var utils_1 = require("../../../utils");
5
- var first_party_1 = require("../first_party");
4
+ var utils_1 = require("../utils");
5
+ var products_1 = require("../products");
6
6
  var renderHtml = function (htmlTemplate, blockData) {
7
7
  if (!blockData) {
8
8
  return htmlTemplate;
@@ -24,13 +24,14 @@ var createBlockData = function (config, context) {
24
24
  var blockScript = "".concat(config.backendCaptchaUrl, "/").concat(config.appId).concat(captchaScriptSuffix).concat(captchaParams);
25
25
  var hostUrl = config.backendCollectorUrl;
26
26
  if (config.firstPartyEnabled && !context.isMobile) {
27
- jsClientSrc = (0, first_party_1.getMostCustomizedFirstPartyPath)(config, first_party_1.FirstPartySuffix.SENSOR);
28
- blockScript = "".concat((0, first_party_1.getMostCustomizedFirstPartyPath)(config, first_party_1.FirstPartySuffix.CAPTCHA)).concat(config.customFirstPartyCaptchaEndpoint ? captchaParams : "".concat(captchaScriptSuffix).concat(captchaParams));
29
- hostUrl = (0, first_party_1.getMostCustomizedFirstPartyPath)(config, first_party_1.FirstPartySuffix.XHR);
27
+ jsClientSrc = (0, products_1.getMostCustomizedFirstPartyPath)(config, products_1.FirstPartySuffix.SENSOR);
28
+ blockScript = "".concat((0, products_1.getMostCustomizedFirstPartyPath)(config, products_1.FirstPartySuffix.CAPTCHA)).concat(config.customFirstPartyCaptchaEndpoint ? captchaParams : "".concat(captchaScriptSuffix).concat(captchaParams));
29
+ hostUrl = (0, products_1.getMostCustomizedFirstPartyPath)(config, products_1.FirstPartySuffix.XHR);
30
30
  }
31
31
  var cssRef = config.cssRef ? "<link rel=\"stylesheet\" type=\"text/css\" href=\"".concat(config.cssRef, "\" />") : '';
32
32
  var jsRef = config.jsRef ? "<script src=\"".concat(config.jsRef, "\"></script>") : '';
33
33
  var altBlockScript = "".concat(config.altBackendCaptchaUrl, "/").concat(config.appId).concat(captchaScriptSuffix).concat(captchaParams);
34
+ var jsTemplateScriptSrc = "https://captcha.px-cdn.net/".concat(config.appId, "/checkpoint.js");
34
35
  return {
35
36
  appId: config.appId,
36
37
  vid: context.vid || ((_b = (_a = context.requestData) === null || _a === void 0 ? void 0 : _a.cookies) === null || _b === void 0 ? void 0 : _b[utils_1.PXVID_COOKIE_NAME]) || '',
@@ -45,6 +46,7 @@ var createBlockData = function (config, context) {
45
46
  firstPartyEnabled: config.firstPartyEnabled,
46
47
  blockScript: blockScript,
47
48
  altBlockScript: altBlockScript,
49
+ jsTemplateScriptSrc: jsTemplateScriptSrc,
48
50
  };
49
51
  };
50
52
  exports.createBlockData = createBlockData;