perimeterx-js-core 0.10.0 → 0.12.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 (259) hide show
  1. package/lib/cjs/action/utils.js +6 -1
  2. package/lib/cjs/activities/utils.js +11 -8
  3. package/lib/cjs/blocker/BlockerBase.js +29 -0
  4. package/lib/cjs/blocker/JsonBlockerBase.js +36 -0
  5. package/lib/cjs/blocker/MobileBlocker.js +48 -0
  6. package/lib/cjs/blocker/index.js +5 -3
  7. package/lib/cjs/blocker/{BlockAction.js → model/BlockAction.js} +2 -0
  8. package/lib/cjs/blocker/{BlockActionToWordMap.js → model/BlockActionToWordMap.js} +1 -0
  9. package/lib/cjs/blocker/model/index.js +19 -0
  10. package/lib/cjs/{products/bot_defender/block → blocker}/utils.js +10 -7
  11. package/lib/cjs/config/ConfigurationBase.js +7 -0
  12. package/lib/cjs/config/defaults/DefaultCommonConfigurationParams.js +1 -0
  13. package/lib/cjs/config/remote_config/DefaultRemoteConfigUpdater.js +23 -11
  14. package/lib/cjs/context/DefaultContext.js +18 -3
  15. package/lib/cjs/custom_parameters/CustomParameters.js +1 -0
  16. package/lib/cjs/custom_parameters/CustomParametersUtils.js +5 -0
  17. package/lib/cjs/enforcer/EnforcerBase.js +9 -6
  18. package/lib/cjs/http/interfaces/index.js +0 -2
  19. package/lib/cjs/http/utils/constants.js +2 -1
  20. package/lib/cjs/http/utils/index.js +0 -3
  21. package/lib/cjs/impl/cipher/CryptoCipherUtils.js +2 -1
  22. package/lib/cjs/impl/hash/CryptoHashUtils.js +2 -1
  23. package/lib/cjs/impl/hash/SubtleCryptoHashUtils.js +1 -32
  24. package/lib/cjs/impl/hmac/CryptoHmacUtils.js +5 -10
  25. package/lib/cjs/impl/hmac/SubtleCryptoHmacUtils.js +72 -0
  26. package/lib/cjs/impl/http/phin/PhinIncomingResponse.js +5 -2
  27. package/lib/cjs/impl/url/CustomImplUrlUtils.js +71 -0
  28. package/lib/cjs/impl/url/DefaultUrlUtils.js +27 -0
  29. package/lib/cjs/{http/utils → impl/url}/UrlImpl.js +3 -2
  30. package/lib/cjs/{http/utils → impl/url}/UrlSearchParamsImpl.js +8 -9
  31. package/lib/cjs/logger/HttpLogServiceClient.js +4 -5
  32. package/lib/cjs/phase/flow/EnforceFlow.js +4 -1
  33. package/lib/cjs/phase/impl/DecideActionPhase.js +8 -0
  34. package/lib/cjs/phase/impl/EnrichContextFromRequestPhase.js +2 -2
  35. package/lib/cjs/phase/impl/RiskApiPhase.js +6 -8
  36. package/lib/cjs/products/bot_defender/BotDefender.js +2 -1
  37. package/lib/cjs/products/bot_defender/block/captcha/CaptchaBlocker.js +2 -2
  38. package/lib/cjs/products/bot_defender/block/captcha/HtmlCaptchaBlocker.js +26 -17
  39. package/lib/cjs/products/bot_defender/block/captcha/JsonCaptchaBlocker.js +27 -19
  40. package/lib/cjs/products/bot_defender/block/captcha/MobileCaptchaBlocker.js +19 -31
  41. package/lib/cjs/products/bot_defender/block/index.js +1 -1
  42. package/lib/cjs/products/bot_defender/block/model/index.js +1 -2
  43. package/lib/cjs/products/bot_defender/first_party/DefaultBotDefenderFirstParty.js +3 -2
  44. package/lib/cjs/products/credential_intelligence/CredentialIntelligence.js +5 -5
  45. package/lib/cjs/products/credential_intelligence/endpoint/CredentialEndpoint.js +17 -3
  46. package/lib/cjs/products/credential_intelligence/endpoint/extractor/CredentialExtractorFactory.js +2 -2
  47. package/lib/cjs/products/credential_intelligence/endpoint/extractor/QueryParamCredentialExtractor.js +3 -3
  48. package/lib/cjs/products/hype_sale_challenge/HypeSaleChallenge.js +81 -0
  49. package/lib/cjs/products/hype_sale_challenge/block/JsonHypeSaleChallengeBlocker.js +40 -0
  50. package/lib/cjs/products/hype_sale_challenge/block/MobileHypeSaleChallengeBlocker.js +28 -0
  51. package/lib/cjs/products/hype_sale_challenge/block/index.js +19 -0
  52. package/lib/cjs/products/hype_sale_challenge/block/templates/hype_sale_challenge_template.js +4 -0
  53. package/lib/cjs/{utils/url_parser → products/hype_sale_challenge/block/templates}/index.js +1 -1
  54. package/lib/cjs/products/hype_sale_challenge/index.js +21 -0
  55. package/lib/cjs/products/hype_sale_challenge/model/index.js +18 -0
  56. package/lib/cjs/products/hype_sale_challenge/utils.js +23 -0
  57. package/lib/cjs/products/index.js +1 -0
  58. package/lib/cjs/pxde/DefaultDataEnrichment.js +14 -8
  59. package/lib/cjs/risk_api/client/PostRiskApiClientBase.js +2 -2
  60. package/lib/cjs/risk_api/risk_response/CommonRiskResponsePayload.js +2 -0
  61. package/lib/cjs/risk_api/risk_response/RiskResponseBase.js +8 -0
  62. package/lib/cjs/risk_api/risk_response/index.js +1 -0
  63. package/lib/cjs/risk_token/token/TokenBase.js +1 -1
  64. package/lib/cjs/risk_token/token/v2/DefaultTokenV2.js +14 -5
  65. package/lib/cjs/risk_token/token/v3/DefaultTokenV3.js +42 -16
  66. package/lib/cjs/utils/Algorithm.js +2 -2
  67. package/lib/cjs/utils/constants.js +1 -1
  68. package/lib/cjs/utils/index.js +1 -1
  69. package/lib/cjs/utils/timestamp_hmac_header_validator/DefaultTimestampHmacHeaderValidator.js +81 -25
  70. package/lib/cjs/utils/url/IUrl.js +2 -0
  71. package/lib/cjs/utils/url/IUrlSearchParams.js +2 -0
  72. package/lib/cjs/utils/url/IUrlUtils.js +2 -0
  73. package/lib/cjs/utils/url/index.js +19 -0
  74. package/lib/cjs/utils/utils.js +19 -2
  75. package/lib/esm/action/utils.js +4 -0
  76. package/lib/esm/activities/utils.js +12 -8
  77. package/lib/esm/blocker/BlockerBase.js +24 -0
  78. package/lib/esm/blocker/JsonBlockerBase.js +17 -0
  79. package/lib/esm/blocker/MobileBlocker.js +29 -0
  80. package/lib/esm/blocker/index.js +5 -3
  81. package/lib/esm/blocker/{BlockAction.js → model/BlockAction.js} +2 -0
  82. package/lib/esm/blocker/{BlockActionToWordMap.js → model/BlockActionToWordMap.js} +1 -0
  83. package/lib/esm/blocker/model/index.js +3 -0
  84. package/lib/esm/{products/bot_defender/block → blocker}/utils.js +7 -4
  85. package/lib/esm/config/ConfigurationBase.js +3 -0
  86. package/lib/esm/config/defaults/DefaultCommonConfigurationParams.js +1 -0
  87. package/lib/esm/config/remote_config/DefaultRemoteConfigUpdater.js +3 -3
  88. package/lib/esm/context/DefaultContext.js +20 -4
  89. package/lib/esm/custom_parameters/CustomParameters.js +1 -1
  90. package/lib/esm/custom_parameters/CustomParametersUtils.js +5 -0
  91. package/lib/esm/enforcer/EnforcerBase.js +10 -7
  92. package/lib/esm/http/interfaces/index.js +0 -2
  93. package/lib/esm/http/utils/constants.js +1 -0
  94. package/lib/esm/http/utils/index.js +0 -3
  95. package/lib/esm/impl/cipher/CryptoCipherUtils.js +2 -1
  96. package/lib/esm/impl/hash/CryptoHashUtils.js +2 -1
  97. package/lib/esm/impl/hash/SubtleCryptoHashUtils.js +2 -10
  98. package/lib/esm/impl/hmac/CryptoHmacUtils.js +6 -11
  99. package/lib/esm/impl/hmac/SubtleCryptoHmacUtils.js +19 -0
  100. package/lib/esm/impl/http/phin/PhinIncomingResponse.js +4 -2
  101. package/lib/esm/impl/url/CustomImplUrlUtils.js +64 -0
  102. package/lib/esm/impl/url/DefaultUrlUtils.js +20 -0
  103. package/lib/esm/{http/utils → impl/url}/UrlImpl.js +3 -2
  104. package/lib/esm/{http/utils → impl/url}/UrlSearchParamsImpl.js +8 -9
  105. package/lib/esm/logger/HttpLogServiceClient.js +5 -6
  106. package/lib/esm/phase/flow/EnforceFlow.js +4 -1
  107. package/lib/esm/phase/impl/DecideActionPhase.js +9 -1
  108. package/lib/esm/phase/impl/EnrichContextFromRequestPhase.js +1 -1
  109. package/lib/esm/phase/impl/RiskApiPhase.js +4 -5
  110. package/lib/esm/products/bot_defender/BotDefender.js +2 -1
  111. package/lib/esm/products/bot_defender/block/captcha/CaptchaBlocker.js +2 -2
  112. package/lib/esm/products/bot_defender/block/captcha/HtmlCaptchaBlocker.js +9 -15
  113. package/lib/esm/products/bot_defender/block/captcha/JsonCaptchaBlocker.js +10 -19
  114. package/lib/esm/products/bot_defender/block/captcha/MobileCaptchaBlocker.js +3 -32
  115. package/lib/esm/products/bot_defender/block/index.js +1 -1
  116. package/lib/esm/products/bot_defender/block/model/index.js +1 -2
  117. package/lib/esm/products/bot_defender/first_party/DefaultBotDefenderFirstParty.js +5 -3
  118. package/lib/esm/products/credential_intelligence/CredentialIntelligence.js +5 -5
  119. package/lib/esm/products/credential_intelligence/endpoint/CredentialEndpoint.js +18 -6
  120. package/lib/esm/products/credential_intelligence/endpoint/extractor/CredentialExtractorFactory.js +2 -2
  121. package/lib/esm/products/credential_intelligence/endpoint/extractor/QueryParamCredentialExtractor.js +4 -3
  122. package/lib/esm/products/hype_sale_challenge/HypeSaleChallenge.js +76 -0
  123. package/lib/esm/products/hype_sale_challenge/block/JsonHypeSaleChallengeBlocker.js +20 -0
  124. package/lib/esm/products/hype_sale_challenge/block/MobileHypeSaleChallengeBlocker.js +7 -0
  125. package/lib/esm/products/hype_sale_challenge/block/index.js +3 -0
  126. package/lib/esm/products/hype_sale_challenge/block/templates/hype_sale_challenge_template.js +42 -0
  127. package/lib/esm/products/hype_sale_challenge/block/templates/index.js +1 -0
  128. package/lib/esm/products/hype_sale_challenge/index.js +5 -0
  129. package/lib/esm/products/hype_sale_challenge/model/index.js +2 -0
  130. package/lib/esm/products/hype_sale_challenge/utils.js +11 -0
  131. package/lib/esm/products/index.js +1 -0
  132. package/lib/esm/pxde/DefaultDataEnrichment.js +2 -1
  133. package/lib/esm/risk_api/client/PostRiskApiClientBase.js +3 -2
  134. package/lib/esm/risk_api/risk_response/CommonRiskResponsePayload.js +1 -0
  135. package/lib/esm/risk_api/risk_response/RiskResponseBase.js +3 -0
  136. package/lib/esm/risk_api/risk_response/index.js +1 -0
  137. package/lib/esm/risk_token/token/TokenBase.js +2 -2
  138. package/lib/esm/risk_token/token/v2/DefaultTokenV2.js +10 -5
  139. package/lib/esm/risk_token/token/v3/DefaultTokenV3.js +22 -5
  140. package/lib/esm/utils/Algorithm.js +2 -2
  141. package/lib/esm/utils/constants.js +1 -1
  142. package/lib/esm/utils/index.js +1 -1
  143. package/lib/esm/utils/timestamp_hmac_header_validator/DefaultTimestampHmacHeaderValidator.js +4 -4
  144. package/lib/esm/utils/url/IUrl.js +1 -0
  145. package/lib/esm/utils/url/IUrlSearchParams.js +1 -0
  146. package/lib/esm/utils/url/IUrlUtils.js +1 -0
  147. package/lib/esm/utils/url/index.js +3 -0
  148. package/lib/esm/utils/utils.js +16 -1
  149. package/lib/types/action/utils.d.ts +2 -0
  150. package/lib/types/activities/model/CommonActivityDetails.d.ts +3 -0
  151. package/lib/types/activities/utils.d.ts +493 -172
  152. package/lib/types/blocker/BlockerBase.d.ts +11 -0
  153. package/lib/types/blocker/JsonBlockerBase.d.ts +9 -0
  154. package/lib/types/blocker/MobileBlocker.d.ts +13 -0
  155. package/lib/types/blocker/index.d.ts +5 -3
  156. package/lib/types/blocker/model/BlockAction.d.ts +7 -0
  157. package/lib/types/{products/bot_defender/block → blocker}/model/BlockData.d.ts +2 -1
  158. package/lib/types/blocker/model/index.d.ts +3 -0
  159. package/lib/types/blocker/utils.d.ts +641 -0
  160. package/lib/types/config/ConfigurationBase.d.ts +6 -5
  161. package/lib/types/config/IConfiguration.d.ts +10 -6
  162. package/lib/types/config/params/CommonConfigurationParams.d.ts +6 -5
  163. package/lib/types/config/remote_config/DefaultRemoteConfigUpdater.d.ts +1 -1
  164. package/lib/types/context/DefaultContext.d.ts +6 -5
  165. package/lib/types/context/interfaces/IContext.d.ts +4 -0
  166. package/lib/types/context/interfaces/RequestData.d.ts +7 -2
  167. package/lib/types/context/interfaces/RiskApiData.d.ts +4 -0
  168. package/lib/types/custom_parameters/CustomParameters.d.ts +2 -0
  169. package/lib/types/enforcer/EnforcerBase.d.ts +2 -2
  170. package/lib/types/enforcer/options/EnforcerBaseOptions.d.ts +2 -1
  171. package/lib/types/http/interfaces/IBody.d.ts +2 -2
  172. package/lib/types/http/interfaces/index.d.ts +0 -2
  173. package/lib/types/http/utils/constants.d.ts +1 -0
  174. package/lib/types/http/utils/index.d.ts +0 -3
  175. package/lib/types/impl/hash/SubtleCryptoHashUtils.d.ts +0 -1
  176. package/lib/types/impl/hmac/SubtleCryptoHmacUtils.d.ts +7 -0
  177. package/lib/types/impl/http/phin/PhinIncomingResponse.d.ts +3 -2
  178. package/lib/types/impl/url/CustomImplUrlUtils.d.ts +10 -0
  179. package/lib/types/impl/url/DefaultUrlUtils.d.ts +9 -0
  180. package/lib/types/{http/utils → impl/url}/UrlImpl.d.ts +3 -3
  181. package/lib/types/{http/utils → impl/url}/UrlSearchParamsImpl.d.ts +5 -4
  182. package/lib/types/phase/impl/DecideActionPhase.d.ts +1 -0
  183. package/lib/types/phase/impl/RiskApiPhase.d.ts +1 -1
  184. package/lib/types/products/bot_defender/BotDefender.d.ts +7 -2
  185. package/lib/types/products/bot_defender/block/captcha/HtmlCaptchaBlocker.d.ts +6 -5
  186. package/lib/types/products/bot_defender/block/captcha/JsonCaptchaBlocker.d.ts +7 -5
  187. package/lib/types/products/bot_defender/block/captcha/MobileCaptchaBlocker.d.ts +2 -8
  188. package/lib/types/products/bot_defender/block/index.d.ts +1 -1
  189. package/lib/types/products/bot_defender/block/model/{JsonBlockPayload.d.ts → JsonCaptchaBlockPayload.d.ts} +1 -1
  190. package/lib/types/products/bot_defender/block/model/index.d.ts +1 -2
  191. package/lib/types/products/bot_defender/first_party/DefaultBotDefenderFirstParty.d.ts +7 -2
  192. package/lib/types/products/credential_intelligence/CredentialIntelligence.d.ts +7 -3
  193. package/lib/types/products/credential_intelligence/endpoint/extractor/BodyCredentialExtractor.d.ts +3 -2
  194. package/lib/types/products/credential_intelligence/endpoint/extractor/CredentialExtractorFactory.d.ts +2 -1
  195. package/lib/types/products/credential_intelligence/endpoint/extractor/QueryParamCredentialExtractor.d.ts +5 -3
  196. package/lib/types/products/hype_sale_challenge/HypeSaleChallenge.d.ts +28 -0
  197. package/lib/types/products/hype_sale_challenge/IHypeSaleChallenge.d.ts +5 -0
  198. package/lib/types/products/hype_sale_challenge/block/JsonHypeSaleChallengeBlocker.d.ts +11 -0
  199. package/lib/types/products/hype_sale_challenge/block/MobileHypeSaleChallengeBlocker.d.ts +6 -0
  200. package/lib/types/products/hype_sale_challenge/block/index.d.ts +3 -0
  201. package/lib/types/products/hype_sale_challenge/block/templates/hype_sale_challenge_template.d.ts +1 -0
  202. package/lib/types/products/hype_sale_challenge/block/templates/index.d.ts +1 -0
  203. package/lib/types/products/hype_sale_challenge/index.d.ts +5 -0
  204. package/lib/types/products/hype_sale_challenge/model/HypeSaleChallengeData.d.ts +5 -0
  205. package/lib/types/products/hype_sale_challenge/model/JsonHypeSaleChallengeBlockPayload.d.ts +5 -0
  206. package/lib/types/products/hype_sale_challenge/model/index.d.ts +2 -0
  207. package/lib/types/products/hype_sale_challenge/utils.d.ts +5 -0
  208. package/lib/types/products/index.d.ts +1 -0
  209. package/lib/types/products/interfaces/ProductDataType.d.ts +2 -1
  210. package/lib/types/risk_api/model/RiskActivity.d.ts +1 -0
  211. package/lib/types/risk_api/risk_response/CommonRiskResponsePayload.d.ts +14 -0
  212. package/lib/types/risk_api/risk_response/IRiskResponse.d.ts +1 -0
  213. package/lib/types/risk_api/risk_response/RiskResponseBase.d.ts +1 -0
  214. package/lib/types/risk_api/risk_response/index.d.ts +1 -0
  215. package/lib/types/risk_api/risk_response/v2/RiskResponseV2Payload.d.ts +2 -12
  216. package/lib/types/risk_api/risk_response/v3/RiskResponseV3Payload.d.ts +2 -12
  217. package/lib/types/risk_token/token/IToken.d.ts +4 -0
  218. package/lib/types/risk_token/token/TokenBase.d.ts +2 -2
  219. package/lib/types/risk_token/token/v2/DefaultTokenV2.d.ts +1 -0
  220. package/lib/types/risk_token/token/v3/DefaultTokenV3.d.ts +1 -0
  221. package/lib/types/risk_token/token/v3/TokenV3Payload.d.ts +1 -0
  222. package/lib/types/utils/Algorithm.d.ts +2 -2
  223. package/lib/types/utils/constants.d.ts +1 -1
  224. package/lib/types/utils/hmac/IHmacUtils.d.ts +2 -1
  225. package/lib/types/utils/index.d.ts +1 -1
  226. package/lib/types/utils/timestamp_hmac_header_validator/DefaultTimestampHmacHeaderValidator.d.ts +2 -2
  227. package/lib/types/utils/timestamp_hmac_header_validator/ITimestampHmacHeaderValidator.d.ts +2 -1
  228. package/lib/types/utils/url/IUrl.d.ts +9 -0
  229. package/lib/types/{http/interfaces/IURLSearchParams.d.ts → utils/url/IUrlSearchParams.d.ts} +2 -2
  230. package/lib/types/utils/url/IUrlUtils.d.ts +10 -0
  231. package/lib/types/utils/url/index.d.ts +3 -0
  232. package/lib/types/utils/utils.d.ts +3 -0
  233. package/package.json +9 -6
  234. package/lib/cjs/blocker/BlockActionToProductMap.js +0 -10
  235. package/lib/cjs/http/utils/URLUtils.js +0 -65
  236. package/lib/cjs/impl/url_parser/DefaultUrlParser.js +0 -39
  237. package/lib/esm/blocker/BlockActionToProductMap.js +0 -7
  238. package/lib/esm/http/utils/URLUtils.js +0 -62
  239. package/lib/esm/impl/url_parser/DefaultUrlParser.js +0 -28
  240. package/lib/esm/utils/url_parser/index.js +0 -1
  241. package/lib/types/blocker/BlockAction.d.ts +0 -5
  242. package/lib/types/blocker/BlockActionToProductMap.d.ts +0 -3
  243. package/lib/types/http/interfaces/IURL.d.ts +0 -9
  244. package/lib/types/http/utils/URLUtils.d.ts +0 -7
  245. package/lib/types/impl/url_parser/DefaultUrlParser.d.ts +0 -13
  246. package/lib/types/products/bot_defender/block/utils.d.ts +0 -5
  247. package/lib/types/utils/url_parser/IURLParser.d.ts +0 -4
  248. package/lib/types/utils/url_parser/index.d.ts +0 -1
  249. /package/lib/cjs/{products/bot_defender/block → blocker}/model/BlockData.js +0 -0
  250. /package/lib/cjs/{http/interfaces/IURL.js → products/bot_defender/block/model/JsonCaptchaBlockPayload.js} +0 -0
  251. /package/lib/cjs/{http/interfaces/IURLSearchParams.js → products/hype_sale_challenge/IHypeSaleChallenge.js} +0 -0
  252. /package/lib/cjs/products/{bot_defender/block/model/JsonBlockPayload.js → hype_sale_challenge/model/HypeSaleChallengeData.js} +0 -0
  253. /package/lib/cjs/{utils/url_parser/IURLParser.js → products/hype_sale_challenge/model/JsonHypeSaleChallengeBlockPayload.js} +0 -0
  254. /package/lib/esm/{products/bot_defender/block → blocker}/model/BlockData.js +0 -0
  255. /package/lib/esm/{http/interfaces/IURL.js → products/bot_defender/block/model/JsonCaptchaBlockPayload.js} +0 -0
  256. /package/lib/esm/{http/interfaces/IURLSearchParams.js → products/hype_sale_challenge/IHypeSaleChallenge.js} +0 -0
  257. /package/lib/esm/products/{bot_defender/block/model/JsonBlockPayload.js → hype_sale_challenge/model/HypeSaleChallengeData.js} +0 -0
  258. /package/lib/esm/{utils/url_parser/IURLParser.js → products/hype_sale_challenge/model/JsonHypeSaleChallengeBlockPayload.js} +0 -0
  259. /package/lib/types/blocker/{BlockActionToWordMap.d.ts → model/BlockActionToWordMap.d.ts} +0 -0
@@ -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;
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
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");
@@ -12,7 +11,7 @@ var createAsyncActivity = function (activityType, config, context) {
12
11
  return {
13
12
  type: activityType,
14
13
  px_app_id: config.appId,
15
- url: context.requestData.rawUrl,
14
+ url: context.requestData.url.href,
16
15
  headers: activityType !== ActivityType_1.ActivityType.ADDITIONAL_S2S
17
16
  ? (0, exports.toHeaderEntryArray)((0, utils_1.removeSensitiveHeaders)(context.requestData.headers, config.sensitiveHeaders))
18
17
  : undefined,
@@ -75,6 +74,7 @@ var addRootContextDataToDetails = function (details, context) {
75
74
  tokenOrigin: 'cookie_origin',
76
75
  vidSource: 'enforcer_vid_source',
77
76
  graphqlData: 'graphql_operations',
77
+ enforcerStartTime: 'enforcer_start_time',
78
78
  });
79
79
  };
80
80
  exports.addRootContextDataToDetails = addRootContextDataToDetails;
@@ -102,6 +102,9 @@ var addProductDataToDetails = function (details, productData) {
102
102
  ciVersion: 'ci_version',
103
103
  ssoStep: 'sso_step',
104
104
  });
105
+ (0, utils_1.transferExistingProperties)(productData.hsc, details, {
106
+ isTokenHscApproved: 'cpa',
107
+ });
105
108
  };
106
109
  exports.addProductDataToDetails = addProductDataToDetails;
107
110
  var addTlsDataToDetails = function (details, tlsData) {
@@ -129,6 +132,9 @@ var addRequestDataToDetails = function (details, requestData) {
129
132
  method: 'http_method',
130
133
  requestCookieNames: 'request_cookie_names',
131
134
  });
135
+ if (requestData.isUrlDifferentFromRawUrl) {
136
+ details.raw_url = requestData.rawUrl;
137
+ }
132
138
  };
133
139
  exports.addRequestDataToDetails = addRequestDataToDetails;
134
140
  var addTokenDataToDetails = function (details, _a) {
@@ -161,6 +167,7 @@ var addRiskApiDataToAsyncActivityCommonDetails = function (details, context) {
161
167
  (0, utils_1.transferExistingProperties)(context.riskApiData, details, {
162
168
  riskRtt: 'risk_rtt',
163
169
  s2sCallReason: 's2s_call_reason',
170
+ riskStartTime: 'risk_start_time',
164
171
  });
165
172
  if ((_a = context.riskApiData.riskResponse) === null || _a === void 0 ? void 0 : _a.additionalRiskInfo) {
166
173
  details.additional_risk_info = context.riskApiData.riskResponse.additionalRiskInfo;
@@ -178,9 +185,7 @@ var addResponseDataToAsyncActivityCommonDetails = function (details, context) {
178
185
  exports.addResponseDataToAsyncActivityCommonDetails = addResponseDataToAsyncActivityCommonDetails;
179
186
  var createPageRequestedActivityDetails = function (context) {
180
187
  var details = {};
181
- details.pass_reason = Object.values(context.reasons)
182
- .filter(function (x) { return x; })
183
- .join(', ');
188
+ details.pass_reason = (0, action_1.getReasonForHighestPriorityProduct)(context.reasons);
184
189
  (0, utils_1.transferExistingProperties)(context.riskApiData, details, {
185
190
  errorReason: 's2s_error_reason',
186
191
  errorHttpStatus: 's2s_error_http_status',
@@ -190,10 +195,8 @@ var createPageRequestedActivityDetails = function (context) {
190
195
  };
191
196
  exports.createPageRequestedActivityDetails = createPageRequestedActivityDetails;
192
197
  var createBlockActivityDetails = function (context) {
193
- var _a;
194
198
  var details = {};
195
- var blockingProduct = blocker_1.BLOCK_ACTION_TO_PRODUCT_MAP.get(context.blockAction);
196
- details.block_reason = (_a = context.reasons) === null || _a === void 0 ? void 0 : _a[blockingProduct];
199
+ details.block_reason = (0, action_1.getReasonForHighestPriorityProduct)(context.reasons);
197
200
  details.simulated_block = context.action === action_1.Action.SIMULATED_BLOCK;
198
201
  (0, utils_1.transferExistingProperties)(context, details, {
199
202
  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, this.base64Utils);
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 = {}));
@@ -6,4 +6,5 @@ exports.BLOCK_ACTION_TO_WORD_MAP = new Map([
6
6
  [BlockAction_1.BlockAction.CAPTCHA, 'captcha'],
7
7
  [BlockAction_1.BlockAction.RATE_LIMIT, 'ratelimit'],
8
8
  [BlockAction_1.BlockAction.CHALLENGE, 'challenge'],
9
+ [BlockAction_1.BlockAction.HYPE_SALE_CHALLENGE, 'captcha'], // this is what mobile HSC expects
9
10
  ]);
@@ -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;
@@ -16,21 +16,23 @@ var renderHtml = function (htmlTemplate, blockData) {
16
16
  return htmlTemplate;
17
17
  };
18
18
  exports.renderHtml = renderHtml;
19
- var createBlockData = function (config, context) {
19
+ var createBlockData = function (config, context, base64Utils) {
20
20
  var _a, _b;
21
21
  var captchaScriptSuffix = '/captcha.js';
22
- var captchaParams = "?a=".concat(context.blockAction, "&u=").concat(context.uuid, "&v=").concat(context.vid || '', "&m=").concat(context.isMobile ? '1' : '0');
22
+ var b64EncodedUrl = base64Utils.base64Encode(context.requestData.url.href);
23
+ var captchaParams = "?a=".concat(context.blockAction, "&u=").concat(context.uuid, "&v=").concat(context.vid || '', "&m=").concat(context.isMobile ? '1' : '0', "&b=").concat(b64EncodedUrl);
23
24
  var jsClientSrc = "".concat(config.backendClientUrl, "/").concat(config.appId, "/main.min.js");
24
25
  var blockScript = "".concat(config.backendCaptchaUrl, "/").concat(config.appId).concat(captchaScriptSuffix).concat(captchaParams);
25
26
  var hostUrl = config.backendCollectorUrl;
26
27
  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);
28
+ jsClientSrc = (0, products_1.getMostCustomizedFirstPartyPath)(config, products_1.FirstPartySuffix.SENSOR);
29
+ blockScript = "".concat((0, products_1.getMostCustomizedFirstPartyPath)(config, products_1.FirstPartySuffix.CAPTCHA)).concat(config.customFirstPartyCaptchaEndpoint ? captchaParams : "".concat(captchaScriptSuffix).concat(captchaParams));
30
+ hostUrl = (0, products_1.getMostCustomizedFirstPartyPath)(config, products_1.FirstPartySuffix.XHR);
30
31
  }
31
32
  var cssRef = config.cssRef ? "<link rel=\"stylesheet\" type=\"text/css\" href=\"".concat(config.cssRef, "\" />") : '';
32
33
  var jsRef = config.jsRef ? "<script src=\"".concat(config.jsRef, "\"></script>") : '';
33
34
  var altBlockScript = "".concat(config.altBackendCaptchaUrl, "/").concat(config.appId).concat(captchaScriptSuffix).concat(captchaParams);
35
+ var jsTemplateScriptSrc = "https://captcha.px-cdn.net/".concat(config.appId, "/checkpoint.js");
34
36
  return {
35
37
  appId: config.appId,
36
38
  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 +47,7 @@ var createBlockData = function (config, context) {
45
47
  firstPartyEnabled: config.firstPartyEnabled,
46
48
  blockScript: blockScript,
47
49
  altBlockScript: altBlockScript,
50
+ jsTemplateScriptSrc: jsTemplateScriptSrc,
48
51
  };
49
52
  };
50
53
  exports.createBlockData = createBlockData;
@@ -620,6 +620,13 @@ var ConfigurationBase = /** @class */ (function () {
620
620
  enumerable: false,
621
621
  configurable: true
622
622
  });
623
+ Object.defineProperty(ConfigurationBase.prototype, "urlDecodeReservedCharacters", {
624
+ get: function () {
625
+ return this.configParams.px_url_decode_reserved_characters;
626
+ },
627
+ enumerable: false,
628
+ configurable: true
629
+ });
623
630
  return ConfigurationBase;
624
631
  }());
625
632
  exports.ConfigurationBase = ConfigurationBase;
@@ -116,4 +116,5 @@ exports.DEFAULT_COMMON_CONFIGURATION_PARAMS = {
116
116
  px_cors_create_custom_block_response_headers: null,
117
117
  px_remote_config_max_fetch_attempts: 5,
118
118
  px_remote_config_retry_interval_ms: 1000,
119
+ px_url_decode_reserved_characters: false,
119
120
  };
@@ -64,23 +64,25 @@ var DefaultRemoteConfigUpdater = /** @class */ (function () {
64
64
  switch (_b.label) {
65
65
  case 0:
66
66
  this.config.logger.debug('identified an update remote config request');
67
- if (!this.isUpdateRequestValid(request)) {
67
+ return [4 /*yield*/, this.isUpdateRequestValid(request)];
68
+ case 1:
69
+ if (!(_b.sent())) {
68
70
  return [2 /*return*/, false];
69
71
  }
70
72
  return [4 /*yield*/, this.getUpdateRequestData(request)];
71
- case 1:
73
+ case 2:
72
74
  updateRequestData = _b.sent();
73
75
  if (!updateRequestData) {
74
76
  return [2 /*return*/, false];
75
77
  }
76
78
  return [4 /*yield*/, this.fetchRemoteConfig(updateRequestData)];
77
- case 2:
79
+ case 3:
78
80
  remoteConfig = _b.sent();
79
81
  if (!remoteConfig) {
80
82
  return [2 /*return*/, false];
81
83
  }
82
84
  return [4 /*yield*/, this.storageClient.save(remoteConfig)];
83
- case 3:
85
+ case 4:
84
86
  _b.sent();
85
87
  this.config.logger.debug("successfully updated with remote config version ".concat(remoteConfig.version));
86
88
  return [2 /*return*/, true];
@@ -89,14 +91,24 @@ var DefaultRemoteConfigUpdater = /** @class */ (function () {
89
91
  });
90
92
  };
91
93
  DefaultRemoteConfigUpdater.prototype.isUpdateRequestValid = function (request) {
92
- var timestampHmacHeader = request.headers.get(utils_1.PUSH_DATA_HMAC_HEADER_NAME);
93
- var isValid = this.timestampHmacHeaderValidator.isValid(timestampHmacHeader);
94
- if (!isValid) {
95
- this.config.logger.error("invalid timestamp hmac header received: ".concat(timestampHmacHeader), {
96
- errorType: constants_1.WRITE_REMOTE_CONFIG_ERROR_NAME,
94
+ return __awaiter(this, void 0, void 0, function () {
95
+ var timestampHmacHeader, isValid;
96
+ return __generator(this, function (_a) {
97
+ switch (_a.label) {
98
+ case 0:
99
+ timestampHmacHeader = request.headers.get(utils_1.PUSH_DATA_HMAC_HEADER_NAME);
100
+ return [4 /*yield*/, this.timestampHmacHeaderValidator.isValid(timestampHmacHeader)];
101
+ case 1:
102
+ isValid = _a.sent();
103
+ if (!isValid) {
104
+ this.config.logger.error("invalid timestamp hmac header received: ".concat(timestampHmacHeader), {
105
+ errorType: constants_1.WRITE_REMOTE_CONFIG_ERROR_NAME,
106
+ });
107
+ }
108
+ return [2 /*return*/, isValid];
109
+ }
97
110
  });
98
- }
99
- return isValid;
111
+ });
100
112
  };
101
113
  DefaultRemoteConfigUpdater.prototype.getUpdateRequestData = function (request) {
102
114
  return __awaiter(this, void 0, void 0, function () {
@@ -7,12 +7,12 @@ var risk_token_1 = require("../risk_token");
7
7
  var risk_api_1 = require("../risk_api");
8
8
  var http_1 = require("../http");
9
9
  var utils_1 = require("../utils");
10
- var DefaultUrlParser_1 = require("../impl/url_parser/DefaultUrlParser");
11
10
  var logger_1 = require("../logger");
12
11
  var DefaultContext = /** @class */ (function () {
13
12
  function DefaultContext(config, request, options) {
13
+ this.enforcerStartTime = Date.now();
14
14
  this.config = config;
15
- this.urlParser = options.urlParser || new DefaultUrlParser_1.DefaultUrlParser();
15
+ this.urlUtils = options.urlUtils;
16
16
  this.tokenData = {
17
17
  tokenParseResult: risk_token_1.TokenParseResult.NONE,
18
18
  };
@@ -42,7 +42,8 @@ var DefaultContext = /** @class */ (function () {
42
42
  DefaultContext.prototype.createRequestData = function (config, request, cookieParser) {
43
43
  if (cookieParser === void 0) { cookieParser = new utils_1.StringSplitCookieParser(); }
44
44
  var rawUrl = request.url;
45
- var url = this.urlParser.parse(rawUrl);
45
+ var url = this.normalizeUrl(rawUrl);
46
+ var isUrlDifferentFromRawUrl = rawUrl !== url.href;
46
47
  var method = request.method;
47
48
  var headers = request.headers;
48
49
  var cookies = DefaultContext.getCookies(cookieParser, request.headers.get(http_1.COOKIE_HEADER_NAME), request.headers.get(config.customCookieHeader));
@@ -62,6 +63,7 @@ var DefaultContext = /** @class */ (function () {
62
63
  requestCookieNames: requestCookieNames,
63
64
  request: request,
64
65
  httpVersion: httpVersion,
66
+ isUrlDifferentFromRawUrl: isUrlDifferentFromRawUrl,
65
67
  };
66
68
  };
67
69
  DefaultContext.getCookies = function (cookieParser) {
@@ -75,6 +77,19 @@ var DefaultContext = /** @class */ (function () {
75
77
  });
76
78
  return cookies;
77
79
  };
80
+ DefaultContext.prototype.normalizeUrl = function (rawUrl) {
81
+ var url = this.urlUtils.createUrl(rawUrl);
82
+ if (this.config.urlDecodeReservedCharacters) {
83
+ try {
84
+ url = this.urlUtils.createUrl("".concat(url.origin).concat(this.urlUtils.decodeUriComponent(url.pathname)).concat(url.search));
85
+ }
86
+ catch (e) {
87
+ this.config.logger.debug("unable to URL decode reserved characters: ".concat(e));
88
+ }
89
+ }
90
+ url.pathname = url.pathname.replace(/\/+$/, '').replace(/\/+/g, '/');
91
+ return url;
92
+ };
78
93
  DefaultContext.prototype.extractUserAgentFromHeader = function (config, headers) {
79
94
  var _a;
80
95
  var userAgent = ((_a = headers[http_1.USER_AGENT_HEADER_NAME]) === null || _a === void 0 ? void 0 : _a[0]) || '';
@@ -1,2 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ var products_1 = require("../products");
@@ -37,6 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.CustomParametersUtils = void 0;
40
+ var products_1 = require("../products");
40
41
  var CustomParametersUtils;
41
42
  (function (CustomParametersUtils) {
42
43
  var _this = this;
@@ -71,6 +72,10 @@ var CustomParametersUtils;
71
72
  normalizedParams[param] = value;
72
73
  }
73
74
  });
75
+ if (products_1.IS_HYPESALE_PARAM_NAME in customParameters &&
76
+ typeof customParameters[products_1.IS_HYPESALE_PARAM_NAME] === 'boolean') {
77
+ normalizedParams[products_1.IS_HYPESALE_PARAM_NAME] = customParameters[products_1.IS_HYPESALE_PARAM_NAME];
78
+ }
74
79
  }
75
80
  return Object.keys(normalizedParams).length === 0 ? null : normalizedParams;
76
81
  };
@@ -68,6 +68,7 @@ var products_1 = require("../products");
68
68
  var activities_1 = require("../activities");
69
69
  var graphql_1 = require("../graphql");
70
70
  var logger_1 = require("../logger");
71
+ var products_2 = require("../products");
71
72
  var EnforcerBase = /** @class */ (function () {
72
73
  /**
73
74
  * The EnforcerBase constructor.
@@ -226,7 +227,7 @@ var EnforcerBase = /** @class */ (function () {
226
227
  * @protected
227
228
  */
228
229
  EnforcerBase.prototype.getInitializationBlock = function (config, options) {
229
- var tokenVersion = options.tokenVersion, httpClient = options.httpClient, base64Utils = options.base64Utils, hmacUtils = options.hmacUtils, hashUtils = options.hashUtils, ipRangeChecker = options.ipRangeChecker;
230
+ var tokenVersion = options.tokenVersion, httpClient = options.httpClient, base64Utils = options.base64Utils, hmacUtils = options.hmacUtils, hashUtils = options.hashUtils, urlUtils = options.urlUtils, ipRangeChecker = options.ipRangeChecker;
230
231
  var cipherUtils = tokenVersion === risk_token_1.TokenVersion.V2 ? null : options.cipherUtils;
231
232
  var cors = options.cors || new cors_1.DefaultCors(config);
232
233
  var telemetry = options.telemetry || new telemetry_1.DefaultTelemetry(config, httpClient, base64Utils, hmacUtils);
@@ -262,6 +263,7 @@ var EnforcerBase = /** @class */ (function () {
262
263
  base64Utils: base64Utils,
263
264
  hmacUtils: hmacUtils,
264
265
  hashUtils: hashUtils,
266
+ urlUtils: urlUtils,
265
267
  ipRangeChecker: ipRangeChecker,
266
268
  cors: cors,
267
269
  telemetry: telemetry,
@@ -275,22 +277,23 @@ var EnforcerBase = /** @class */ (function () {
275
277
  remoteConfigServiceClient: remoteConfigServiceClient,
276
278
  remoteConfigUpdater: remoteConfigUpdater,
277
279
  };
278
- var products = this.initializeProducts(config, options.products, base64Utils, hashUtils, ipRangeChecker);
280
+ var products = this.initializeProducts(config, options.products, base64Utils, hashUtils, urlUtils, ipRangeChecker);
279
281
  return __assign({ products: products }, allOptions);
280
282
  };
281
- EnforcerBase.prototype.initializeProducts = function (config, products, base64Utils, hashUtils, ipRangeChecker) {
283
+ EnforcerBase.prototype.initializeProducts = function (config, products, base64Utils, hashUtils, urlUtils, ipRangeChecker) {
282
284
  var _a;
283
- var botDefender = (products === null || products === void 0 ? void 0 : products.bd) || new products_1.BotDefender(config, { base64Utils: base64Utils, ipRangeChecker: ipRangeChecker });
285
+ var botDefender = (products === null || products === void 0 ? void 0 : products.bd) || new products_1.BotDefender(config, { base64Utils: base64Utils, ipRangeChecker: ipRangeChecker, urlUtils: urlUtils });
284
286
  var accountDefender = (products === null || products === void 0 ? void 0 : products.ad) || new products_1.AccountDefender(config, { base64Utils: base64Utils });
285
287
  var credentialIntelligence = config.ciEnabled
286
- ? (products === null || products === void 0 ? void 0 : products.ci) || new products_1.CredentialIntelligence(config, hashUtils)
288
+ ? (products === null || products === void 0 ? void 0 : products.ci) || new products_1.CredentialIntelligence(config, { hashUtils: hashUtils, urlUtils: urlUtils })
287
289
  : null;
290
+ var hypeSaleChallenge = (products === null || products === void 0 ? void 0 : products.hsc) || new products_2.HypeSaleChallenge(config, { base64Utils: base64Utils });
288
291
  return _a = {},
289
292
  _a[products_1.ProductName.BOT_DEFENDER] = botDefender,
290
293
  _a[products_1.ProductName.ACCOUNT_DEFENDER] = accountDefender,
291
294
  _a[products_1.ProductName.CODE_DEFENDER] = products === null || products === void 0 ? void 0 : products.cd,
292
295
  _a[products_1.ProductName.CREDENTIAL_INTELLIGENCE] = credentialIntelligence,
293
- _a[products_1.ProductName.HYPE_SALE_CHALLENGE] = products === null || products === void 0 ? void 0 : products.hsc,
296
+ _a[products_1.ProductName.HYPE_SALE_CHALLENGE] = hypeSaleChallenge,
294
297
  _a;
295
298
  };
296
299
  return EnforcerBase;
@@ -24,5 +24,3 @@ __exportStar(require("./IBody"), exports);
24
24
  __exportStar(require("./IHeaders"), exports);
25
25
  __exportStar(require("./IFormData"), exports);
26
26
  __exportStar(require("./ReadonlyHeaders"), exports);
27
- __exportStar(require("./IURL"), exports);
28
- __exportStar(require("./IURLSearchParams"), exports);
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HOST_HEADER_NAME = exports.SET_COOKIE_HEADER_NAME = exports.ACCEPT_HEADER_NAME = exports.AUTHORIZATION_HEADER_NAME = exports.COOKIE_HEADER_NAME = exports.CONTENT_LENGTH_HEADER_NAME = exports.CONTENT_TYPE_HEADER_NAME = exports.USER_AGENT_HEADER_NAME = exports.X_FORWARDED_FOR_HEADER_NAME = void 0;
3
+ exports.CACHE_CONTROL_HEADER_NAME = exports.HOST_HEADER_NAME = exports.SET_COOKIE_HEADER_NAME = exports.ACCEPT_HEADER_NAME = exports.AUTHORIZATION_HEADER_NAME = exports.COOKIE_HEADER_NAME = exports.CONTENT_LENGTH_HEADER_NAME = exports.CONTENT_TYPE_HEADER_NAME = exports.USER_AGENT_HEADER_NAME = exports.X_FORWARDED_FOR_HEADER_NAME = void 0;
4
4
  exports.X_FORWARDED_FOR_HEADER_NAME = 'x-forwarded-for';
5
5
  exports.USER_AGENT_HEADER_NAME = 'user-agent';
6
6
  exports.CONTENT_TYPE_HEADER_NAME = 'content-type';
@@ -10,3 +10,4 @@ exports.AUTHORIZATION_HEADER_NAME = 'authorization';
10
10
  exports.ACCEPT_HEADER_NAME = 'accept';
11
11
  exports.SET_COOKIE_HEADER_NAME = 'set-cookie';
12
12
  exports.HOST_HEADER_NAME = 'host';
13
+ exports.CACHE_CONTROL_HEADER_NAME = 'cache-control';
@@ -22,6 +22,3 @@ __exportStar(require("./MultipartFormDataUtils"), exports);
22
22
  __exportStar(require("./FormDataImpl"), exports);
23
23
  __exportStar(require("./MinimalResponseImpl"), exports);
24
24
  __exportStar(require("./OutgoingRequestImpl"), exports);
25
- __exportStar(require("./UrlImpl"), exports);
26
- __exportStar(require("./UrlSearchParamsImpl"), exports);
27
- __exportStar(require("./URLUtils"), exports);
@@ -61,6 +61,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
61
61
  Object.defineProperty(exports, "__esModule", { value: true });
62
62
  exports.CryptoCipherUtils = void 0;
63
63
  var crypto = __importStar(require("crypto"));
64
+ var utils_1 = require("../../utils");
64
65
  var CryptoCipherUtils = /** @class */ (function () {
65
66
  function CryptoCipherUtils(cryptoModule) {
66
67
  if (cryptoModule === void 0) { cryptoModule = crypto; }
@@ -72,7 +73,7 @@ var CryptoCipherUtils = /** @class */ (function () {
72
73
  return __generator(this, function (_a) {
73
74
  keylen = (options === null || options === void 0 ? void 0 : options.keylen) || 32;
74
75
  ivlen = (options === null || options === void 0 ? void 0 : options.ivlen) || 16;
75
- derivation = this.crypto.pbkdf2Sync(secret, Buffer.from(salt, 'base64'), iterations, keylen + ivlen, 'sha256');
76
+ derivation = this.crypto.pbkdf2Sync(secret, Buffer.from(salt, 'base64'), iterations, keylen + ivlen, (0, utils_1.algoToCryptoString)(utils_1.Algorithm.SHA256));
76
77
  key = derivation.subarray(0, keylen);
77
78
  iv = derivation.subarray(keylen);
78
79
  cipher = this.crypto.createDecipheriv('aes-256-cbc', key, iv);
@@ -61,6 +61,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
61
61
  Object.defineProperty(exports, "__esModule", { value: true });
62
62
  exports.CryptoHashUtils = void 0;
63
63
  var crypto = __importStar(require("crypto"));
64
+ var utils_1 = require("../../utils");
64
65
  var CryptoHashUtils = /** @class */ (function () {
65
66
  function CryptoHashUtils(cryptoModule) {
66
67
  if (cryptoModule === void 0) { cryptoModule = crypto; }
@@ -69,7 +70,7 @@ var CryptoHashUtils = /** @class */ (function () {
69
70
  CryptoHashUtils.prototype.hashString = function (text, algo) {
70
71
  return __awaiter(this, void 0, void 0, function () {
71
72
  return __generator(this, function (_a) {
72
- return [2 /*return*/, this.crypto.createHash(algo).update(text).digest('hex')];
73
+ return [2 /*return*/, this.crypto.createHash((0, utils_1.algoToCryptoString)(algo)).update(text).digest('hex')];
73
74
  });
74
75
  });
75
76
  };