perimeterx-js-core 0.24.4 → 0.26.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 (314) 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 +26 -6
  12. package/lib/cjs/config/index.js +0 -1
  13. package/lib/cjs/config/remote_config/RemoteConfigUtils.js +12 -2
  14. package/lib/cjs/config/remote_config/index.js +2 -2
  15. package/lib/cjs/config/remote_config/manager/DefaultRemoteConfigManager.js +191 -0
  16. package/lib/cjs/config/remote_config/manager/index.js +18 -0
  17. package/lib/cjs/config/remote_config/model/index.js +1 -1
  18. package/lib/cjs/config/remote_config/update_parser/DefaultNotifyRemoteConfigUpdateParser.js +139 -0
  19. package/lib/cjs/config/remote_config/update_parser/index.js +18 -0
  20. package/lib/cjs/context/DefaultContext.js +26 -4
  21. package/lib/cjs/context/SerializedContext.js +6 -1
  22. package/lib/cjs/context/interfaces/RemoteConfigUpdateData.js +2 -0
  23. package/lib/cjs/context/interfaces/index.js +1 -0
  24. package/lib/cjs/enforcer/EnforcerBase.js +77 -32
  25. package/lib/cjs/enforcer/IPostEnforcer.js +2 -0
  26. package/lib/cjs/enforcer/index.js +1 -0
  27. package/lib/cjs/enforcer/utils.js +34 -38
  28. package/lib/cjs/{phase/flow → flow}/EndEnforcerFlow.js +13 -7
  29. package/lib/cjs/{phase/flow → flow}/EnforceFlow.js +10 -15
  30. package/lib/cjs/{phase/flow → flow}/FilterFlow.js +12 -12
  31. package/lib/cjs/flow/Flow.js +60 -0
  32. package/lib/cjs/flow/IFlow.js +2 -0
  33. package/lib/cjs/{phase/flow → flow}/PostEnforceFlow.js +6 -6
  34. package/lib/cjs/{phase/flow → flow}/index.js +2 -0
  35. package/lib/cjs/index.js +1 -0
  36. package/lib/cjs/phase/impl/AdditionalActivityHandlerPhase.js +3 -0
  37. package/lib/cjs/phase/impl/ClearLogsPhase.js +3 -0
  38. package/lib/cjs/phase/impl/CompositePhase.js +9 -0
  39. package/lib/cjs/phase/impl/CreateBlockResponsePhase.js +16 -0
  40. package/lib/cjs/phase/impl/DecideActionPhase.js +11 -0
  41. package/lib/cjs/phase/impl/EnrichContextFromRequestPhase.js +13 -9
  42. package/lib/cjs/phase/impl/EnrichContextFromResponsePhase.js +4 -0
  43. package/lib/cjs/phase/impl/FilterPhase.js +4 -0
  44. package/lib/cjs/phase/impl/FirstPartyPhase.js +5 -0
  45. package/lib/cjs/phase/impl/IdentifyRemoteConfigNotifyRequestPhase.js +80 -0
  46. package/lib/cjs/phase/impl/IdentifyTelemetryRequestPhase.js +5 -0
  47. package/lib/cjs/phase/impl/ModifyIncomingRequestPhase.js +5 -0
  48. package/lib/cjs/phase/impl/ModifyOutgoingResponsePhase.js +5 -0
  49. package/lib/cjs/phase/impl/ParseTokenPhase.js +14 -7
  50. package/lib/cjs/phase/impl/PreflightPhase.js +4 -0
  51. package/lib/cjs/phase/impl/RiskApiPhase.js +18 -7
  52. package/lib/cjs/phase/impl/{SendAsyncActivitiesOnResponsePhase.js → SendAsyncActivitiesPhase.js} +15 -8
  53. package/lib/cjs/phase/impl/SendLogsPhase.js +3 -0
  54. package/lib/cjs/phase/impl/SendTelemetryActivityPhase.js +3 -0
  55. package/lib/cjs/phase/impl/UpdateRemoteConfigPhase.js +10 -14
  56. package/lib/cjs/phase/impl/index.js +3 -3
  57. package/lib/cjs/phase/index.js +0 -1
  58. package/lib/cjs/products/credential_intelligence/endpoint/login_successful/BodyLoginSuccessfulParser.js +1 -1
  59. package/lib/cjs/products/credential_intelligence/endpoint/login_successful/LoginSuccessfulParserFactory.js +5 -2
  60. package/lib/cjs/products/credential_intelligence/endpoint/matcher/CredentialIntelligenceEndpointMatcherFactory.js +3 -1
  61. package/lib/cjs/risk_api/client/GetRiskApiClientV2.js +80 -0
  62. package/lib/cjs/risk_api/client/PostRiskApiClientV2.js +3 -3
  63. package/lib/cjs/risk_api/client/PostRiskApiClientV3.js +3 -3
  64. package/lib/cjs/risk_api/client/abstract/IRiskApiClient.js +2 -0
  65. package/lib/cjs/risk_api/client/abstract/PostRiskApiClientBase.js +43 -0
  66. package/lib/cjs/risk_api/client/{PostRiskApiClientBase.js → abstract/RiskApiClientBase.js} +22 -69
  67. package/lib/cjs/risk_api/client/abstract/index.js +19 -0
  68. package/lib/cjs/risk_api/client/index.js +2 -2
  69. package/lib/cjs/risk_api/index.js +1 -0
  70. package/lib/cjs/risk_api/model/GetRiskRequestHeaders.js +185 -0
  71. package/lib/cjs/risk_api/model/GetRiskResponseHeaders.js +16 -0
  72. package/lib/cjs/risk_api/model/index.js +2 -0
  73. package/lib/cjs/{phase/impl/SendAsyncActivitiesOnRequestPhase.js → risk_api/risk_response/PostRiskResponseBase.js} +26 -30
  74. package/lib/cjs/risk_api/risk_response/RiskResponseBase.js +11 -8
  75. package/lib/cjs/risk_api/risk_response/index.js +1 -0
  76. package/lib/cjs/risk_api/risk_response/serialize/SerializedRiskResponse.js +5 -1
  77. package/lib/cjs/risk_api/risk_response/v2/GetRiskResponseV2.js +80 -0
  78. package/lib/cjs/risk_api/risk_response/v2/{DefaultRiskResponseV2.js → PostRiskResponseV2.js} +10 -10
  79. package/lib/cjs/risk_api/risk_response/v2/index.js +2 -1
  80. package/lib/cjs/risk_api/risk_response/v3/{DefaultRiskResponseV3.js → PostRiskResponseV3.js} +10 -10
  81. package/lib/cjs/risk_api/risk_response/v3/index.js +1 -1
  82. package/lib/cjs/risk_api/utils.js +36 -0
  83. package/lib/cjs/telemetry/DefaultTelemetry.js +12 -9
  84. package/lib/cjs/utils/constants.js +1 -1
  85. package/lib/cjs/utils/utils.js +1 -19
  86. package/lib/esm/action/Action.js +15 -0
  87. package/lib/esm/action/ActionPriorityOrder.js +4 -0
  88. package/lib/esm/action/utils.js +20 -0
  89. package/lib/esm/activities/HttpActivityClient.js +61 -1
  90. package/lib/esm/activities/HttpBatchedActivityClient.js +7 -0
  91. package/lib/esm/activities/utils.js +128 -63
  92. package/lib/esm/additional_activity_handler/AdditionalActivityHandlerUtils.js +6 -0
  93. package/lib/esm/blocker/BlockerBase.js +14 -0
  94. package/lib/esm/blocker/JsonBlockerBase.js +5 -0
  95. package/lib/esm/blocker/utils.js +13 -0
  96. package/lib/esm/config/ConfigurationBase.js +23 -8
  97. package/lib/esm/config/index.js +0 -1
  98. package/lib/esm/config/remote_config/RemoteConfigUtils.js +11 -2
  99. package/lib/esm/config/remote_config/index.js +2 -2
  100. package/lib/esm/config/remote_config/manager/DefaultRemoteConfigManager.js +87 -0
  101. package/lib/esm/config/remote_config/manager/index.js +2 -0
  102. package/lib/esm/config/remote_config/model/index.js +1 -1
  103. package/lib/esm/config/remote_config/update_parser/DefaultNotifyRemoteConfigUpdateParser.js +60 -0
  104. package/lib/esm/config/remote_config/update_parser/index.js +2 -0
  105. package/lib/esm/context/DefaultContext.js +23 -6
  106. package/lib/esm/context/SerializedContext.js +7 -2
  107. package/lib/esm/context/interfaces/RemoteConfigUpdateData.js +1 -0
  108. package/lib/esm/context/interfaces/index.js +1 -0
  109. package/lib/esm/enforcer/EnforcerBase.js +46 -6
  110. package/lib/esm/enforcer/IPostEnforcer.js +1 -0
  111. package/lib/esm/enforcer/index.js +1 -0
  112. package/lib/esm/enforcer/utils.js +32 -17
  113. package/lib/esm/flow/EndEnforcerFlow.js +18 -0
  114. package/lib/esm/flow/EnforceFlow.js +14 -0
  115. package/lib/esm/{phase/flow → flow}/FilterFlow.js +8 -8
  116. package/lib/esm/flow/Flow.js +56 -0
  117. package/lib/esm/flow/IFlow.js +1 -0
  118. package/lib/esm/flow/PostEnforceFlow.js +10 -0
  119. package/lib/esm/{phase/flow → flow}/index.js +2 -0
  120. package/lib/esm/index.js +1 -0
  121. package/lib/esm/logger/LoggerBase.js +1 -1
  122. package/lib/esm/phase/impl/AdditionalActivityHandlerPhase.js +3 -0
  123. package/lib/esm/phase/impl/ClearLogsPhase.js +3 -0
  124. package/lib/esm/phase/impl/CompositePhase.js +9 -0
  125. package/lib/esm/phase/impl/CreateBlockResponsePhase.js +16 -1
  126. package/lib/esm/phase/impl/DecideActionPhase.js +11 -0
  127. package/lib/esm/phase/impl/EnrichContextFromRequestPhase.js +9 -0
  128. package/lib/esm/phase/impl/EnrichContextFromResponsePhase.js +4 -0
  129. package/lib/esm/phase/impl/FilterPhase.js +4 -0
  130. package/lib/esm/phase/impl/FirstPartyPhase.js +5 -0
  131. package/lib/esm/phase/impl/IdentifyRemoteConfigNotifyRequestPhase.js +29 -0
  132. package/lib/esm/phase/impl/IdentifyTelemetryRequestPhase.js +5 -0
  133. package/lib/esm/phase/impl/ModifyIncomingRequestPhase.js +5 -0
  134. package/lib/esm/phase/impl/ModifyOutgoingResponsePhase.js +5 -0
  135. package/lib/esm/phase/impl/ParseTokenPhase.js +15 -8
  136. package/lib/esm/phase/impl/PreflightPhase.js +4 -0
  137. package/lib/esm/phase/impl/RiskApiPhase.js +19 -8
  138. package/lib/esm/phase/impl/SendAsyncActivitiesPhase.js +16 -0
  139. package/lib/esm/phase/impl/SendLogsPhase.js +3 -0
  140. package/lib/esm/phase/impl/SendTelemetryActivityPhase.js +3 -0
  141. package/lib/esm/phase/impl/UpdateRemoteConfigPhase.js +9 -13
  142. package/lib/esm/phase/impl/index.js +3 -3
  143. package/lib/esm/phase/index.js +0 -1
  144. package/lib/esm/products/credential_intelligence/endpoint/login_successful/BodyLoginSuccessfulParser.js +1 -1
  145. package/lib/esm/products/credential_intelligence/endpoint/login_successful/LoginSuccessfulParserFactory.js +5 -2
  146. package/lib/esm/products/credential_intelligence/endpoint/matcher/CredentialIntelligenceEndpointMatcherFactory.js +2 -1
  147. package/lib/esm/risk_api/client/GetRiskApiClientV2.js +57 -0
  148. package/lib/esm/risk_api/client/PostRiskApiClientV2.js +3 -3
  149. package/lib/esm/risk_api/client/PostRiskApiClientV3.js +3 -3
  150. package/lib/esm/risk_api/client/abstract/IRiskApiClient.js +1 -0
  151. package/lib/esm/risk_api/client/abstract/PostRiskApiClientBase.js +18 -0
  152. package/lib/esm/risk_api/client/{PostRiskApiClientBase.js → abstract/RiskApiClientBase.js} +10 -49
  153. package/lib/esm/risk_api/client/abstract/index.js +3 -0
  154. package/lib/esm/risk_api/client/index.js +2 -2
  155. package/lib/esm/risk_api/index.js +1 -0
  156. package/lib/esm/risk_api/model/GetRiskRequestHeaders.js +182 -0
  157. package/lib/esm/risk_api/model/GetRiskResponseHeaders.js +13 -0
  158. package/lib/esm/risk_api/model/index.js +2 -0
  159. package/lib/esm/risk_api/risk_response/PostRiskResponseBase.js +6 -0
  160. package/lib/esm/risk_api/risk_response/RiskResponseBase.js +5 -1
  161. package/lib/esm/risk_api/risk_response/index.js +1 -0
  162. package/lib/esm/risk_api/risk_response/serialize/SerializedRiskResponse.js +5 -1
  163. package/lib/esm/risk_api/risk_response/v2/GetRiskResponseV2.js +52 -0
  164. package/lib/esm/risk_api/risk_response/v2/{DefaultRiskResponseV2.js → PostRiskResponseV2.js} +2 -2
  165. package/lib/esm/risk_api/risk_response/v2/index.js +2 -1
  166. package/lib/esm/risk_api/risk_response/v3/{DefaultRiskResponseV3.js → PostRiskResponseV3.js} +2 -2
  167. package/lib/esm/risk_api/risk_response/v3/index.js +1 -1
  168. package/lib/esm/risk_api/utils.js +23 -0
  169. package/lib/esm/telemetry/DefaultTelemetry.js +13 -10
  170. package/lib/esm/utils/constants.js +1 -1
  171. package/lib/esm/utils/utils.js +0 -16
  172. package/lib/types/action/Action.d.ts +15 -0
  173. package/lib/types/action/ActionData.d.ts +3 -0
  174. package/lib/types/action/ActionPriorityOrder.d.ts +4 -0
  175. package/lib/types/action/Decision.d.ts +9 -0
  176. package/lib/types/action/ProductAction.d.ts +3 -0
  177. package/lib/types/action/utils.d.ts +20 -0
  178. package/lib/types/activities/HttpActivityClient.d.ts +57 -1
  179. package/lib/types/activities/HttpBatchedActivityClient.d.ts +7 -0
  180. package/lib/types/activities/IActivityClient.d.ts +4 -1
  181. package/lib/types/activities/model/AsyncActivity.d.ts +3 -0
  182. package/lib/types/activities/model/AsyncActivityDetails.d.ts +12 -0
  183. package/lib/types/activities/model/CommonActivityDetails.d.ts +3 -0
  184. package/lib/types/activities/utils.d.ts +14 -0
  185. package/lib/types/additional_activity_handler/AdditionalActivityHandlerUtils.d.ts +6 -0
  186. package/lib/types/blocker/BlockerBase.d.ts +21 -0
  187. package/lib/types/blocker/IBlocker.d.ts +8 -0
  188. package/lib/types/blocker/IConditionalBlocker.d.ts +4 -0
  189. package/lib/types/blocker/JsonBlockerBase.d.ts +12 -0
  190. package/lib/types/blocker/model/BlockData.d.ts +3 -0
  191. package/lib/types/blocker/utils.d.ts +13 -0
  192. package/lib/types/config/ConfigurationBase.d.ts +25 -2
  193. package/lib/types/config/IConfiguration.d.ts +7 -2
  194. package/lib/types/config/index.d.ts +0 -1
  195. package/lib/types/config/params/CoreConfigurationParams.d.ts +22 -1
  196. package/lib/types/config/params/RemoteConfigurationParams.d.ts +3 -0
  197. package/lib/types/config/params/StaticConfigurationParams.d.ts +3 -0
  198. package/lib/types/config/remote_config/RemoteConfigUtils.d.ts +2 -1
  199. package/lib/types/config/remote_config/index.d.ts +2 -2
  200. package/lib/types/config/remote_config/manager/DefaultRemoteConfigManager.d.ts +23 -0
  201. package/lib/types/config/remote_config/manager/IRemoteConfigManager.d.ts +7 -0
  202. package/lib/types/config/remote_config/manager/index.d.ts +2 -0
  203. package/lib/types/config/remote_config/model/RemoteConfigNotifyRequestPayload.d.ts +3 -0
  204. package/lib/types/config/remote_config/model/index.d.ts +1 -1
  205. package/lib/types/config/remote_config/service_client/HttpRemoteConfigServiceClient.d.ts +2 -2
  206. package/lib/types/config/remote_config/service_client/IRemoteConfigServiceClient.d.ts +2 -2
  207. package/lib/types/config/remote_config/storage_client/IRemoteConfigStorageClient.d.ts +1 -1
  208. package/lib/types/config/remote_config/update_parser/DefaultNotifyRemoteConfigUpdateParser.d.ts +22 -0
  209. package/lib/types/config/remote_config/update_parser/IRemoteConfigUpdateParser.d.ts +5 -0
  210. package/lib/types/config/remote_config/update_parser/index.d.ts +2 -0
  211. package/lib/types/context/ContextJson.d.ts +6 -2
  212. package/lib/types/context/DefaultContext.d.ts +9 -3
  213. package/lib/types/context/SerializedContext.d.ts +7 -2
  214. package/lib/types/context/interfaces/IContext.d.ts +4 -3
  215. package/lib/types/context/interfaces/RemoteConfigUpdateData.d.ts +4 -0
  216. package/lib/types/context/interfaces/index.d.ts +1 -0
  217. package/lib/types/custom_parameters/CustomParameters.d.ts +3 -0
  218. package/lib/types/enforcer/EnforcerBase.d.ts +50 -13
  219. package/lib/types/enforcer/EnforcerOptions.d.ts +3 -2
  220. package/lib/types/enforcer/IEnforcer.d.ts +1 -2
  221. package/lib/types/enforcer/IPostEnforcer.d.ts +3 -0
  222. package/lib/types/enforcer/index.d.ts +1 -0
  223. package/lib/types/enforcer/utils.d.ts +7 -1
  224. package/lib/types/first_party/IFirstParty.d.ts +1 -1
  225. package/lib/types/flow/EndEnforcerFlow.d.ts +8 -0
  226. package/lib/types/flow/EnforceFlow.d.ts +8 -0
  227. package/lib/types/flow/FilterFlow.d.ts +11 -0
  228. package/lib/types/flow/Flow.d.ts +13 -0
  229. package/lib/types/flow/IFlow.d.ts +57 -0
  230. package/lib/types/flow/PostEnforceFlow.d.ts +6 -0
  231. package/lib/types/{phase/flow → flow}/index.d.ts +2 -0
  232. package/lib/types/index.d.ts +1 -0
  233. package/lib/types/logger/ILogger.d.ts +4 -0
  234. package/lib/types/logger/LoggerBase.d.ts +1 -1
  235. package/lib/types/phase/IPhase.d.ts +9 -0
  236. package/lib/types/phase/PhaseResult.d.ts +11 -0
  237. package/lib/types/phase/impl/AdditionalActivityHandlerPhase.d.ts +3 -0
  238. package/lib/types/phase/impl/ClearLogsPhase.d.ts +3 -0
  239. package/lib/types/phase/impl/CompositePhase.d.ts +9 -0
  240. package/lib/types/phase/impl/CreateBlockResponsePhase.d.ts +11 -1
  241. package/lib/types/phase/impl/DecideActionPhase.d.ts +11 -0
  242. package/lib/types/phase/impl/EnrichContextFromRequestPhase.d.ts +9 -0
  243. package/lib/types/phase/impl/EnrichContextFromResponsePhase.d.ts +4 -0
  244. package/lib/types/phase/impl/FilterPhase.d.ts +4 -0
  245. package/lib/types/phase/impl/FirstPartyPhase.d.ts +5 -0
  246. package/lib/types/phase/impl/IdentifyRemoteConfigNotifyRequestPhase.d.ts +14 -0
  247. package/lib/types/phase/impl/IdentifyTelemetryRequestPhase.d.ts +5 -0
  248. package/lib/types/phase/impl/ModifyIncomingRequestPhase.d.ts +5 -0
  249. package/lib/types/phase/impl/ModifyOutgoingResponsePhase.d.ts +5 -0
  250. package/lib/types/phase/impl/ParseTokenPhase.d.ts +3 -0
  251. package/lib/types/phase/impl/PreflightPhase.d.ts +4 -0
  252. package/lib/types/phase/impl/RiskApiPhase.d.ts +5 -0
  253. package/lib/types/phase/impl/{SendAsyncActivitiesOnResponsePhase.d.ts → SendAsyncActivitiesPhase.d.ts} +5 -2
  254. package/lib/types/phase/impl/SendLogsPhase.d.ts +3 -0
  255. package/lib/types/phase/impl/SendTelemetryActivityPhase.d.ts +3 -0
  256. package/lib/types/phase/impl/UpdateRemoteConfigPhase.d.ts +6 -5
  257. package/lib/types/phase/impl/index.d.ts +3 -3
  258. package/lib/types/phase/index.d.ts +0 -1
  259. package/lib/types/products/credential_intelligence/endpoint/CredentialEndpointConfiguration.d.ts +1 -1
  260. package/lib/types/products/credential_intelligence/endpoint/login_successful/BodyLoginSuccessfulParser.d.ts +1 -1
  261. package/lib/types/products/interfaces/IProduct.d.ts +28 -0
  262. package/lib/types/products/interfaces/ProductDataType.d.ts +1 -1
  263. package/lib/types/risk_api/client/GetRiskApiClientV2.d.ts +15 -0
  264. package/lib/types/risk_api/client/PostRiskApiClientV2.d.ts +1 -1
  265. package/lib/types/risk_api/client/PostRiskApiClientV3.d.ts +2 -2
  266. package/lib/types/risk_api/client/{IRiskApiClient.d.ts → abstract/IRiskApiClient.d.ts} +1 -1
  267. package/lib/types/risk_api/client/abstract/PostRiskApiClientBase.d.ts +8 -0
  268. package/lib/types/risk_api/client/abstract/RiskApiClientBase.d.ts +26 -0
  269. package/lib/types/risk_api/client/abstract/index.d.ts +3 -0
  270. package/lib/types/risk_api/client/index.d.ts +2 -2
  271. package/lib/types/risk_api/index.d.ts +1 -0
  272. package/lib/types/risk_api/model/GetRiskRequestHeaders.d.ts +17 -0
  273. package/lib/types/risk_api/model/GetRiskResponseHeaders.d.ts +3 -0
  274. package/lib/types/risk_api/model/index.d.ts +2 -0
  275. package/lib/types/risk_api/risk_response/IRiskResponse.d.ts +2 -0
  276. package/lib/types/risk_api/risk_response/PostRiskResponseBase.d.ts +7 -0
  277. package/lib/types/risk_api/risk_response/RiskResponseBase.d.ts +3 -1
  278. package/lib/types/risk_api/risk_response/index.d.ts +1 -0
  279. package/lib/types/risk_api/risk_response/serialize/SerializedRiskResponse.d.ts +1 -0
  280. package/lib/types/risk_api/risk_response/v2/GetRiskResponseV2.d.ts +11 -0
  281. package/lib/types/risk_api/risk_response/v2/{DefaultRiskResponseV2.d.ts → PostRiskResponseV2.d.ts} +2 -2
  282. package/lib/types/risk_api/risk_response/v2/index.d.ts +2 -1
  283. package/lib/types/risk_api/risk_response/v3/{DefaultRiskResponseV3.d.ts → PostRiskResponseV3.d.ts} +2 -2
  284. package/lib/types/risk_api/risk_response/v3/index.d.ts +1 -1
  285. package/lib/types/risk_api/utils.d.ts +69 -0
  286. package/lib/types/telemetry/model/TelemetryActivity.d.ts +1 -1
  287. package/lib/types/utils/constants.d.ts +1 -1
  288. package/lib/types/utils/utils.d.ts +0 -5
  289. package/package.json +13 -13
  290. package/lib/cjs/config/ConfigurationBuilderBase.js +0 -135
  291. package/lib/cjs/config/remote_config/DefaultRemoteConfigUpdater.js +0 -200
  292. package/lib/esm/config/ConfigurationBuilderBase.js +0 -66
  293. package/lib/esm/config/remote_config/DefaultRemoteConfigUpdater.js +0 -99
  294. package/lib/esm/phase/flow/EndEnforcerFlow.js +0 -12
  295. package/lib/esm/phase/flow/EnforceFlow.js +0 -18
  296. package/lib/esm/phase/flow/PostEnforceFlow.js +0 -10
  297. package/lib/esm/phase/impl/SendAsyncActivitiesOnRequestPhase.js +0 -16
  298. package/lib/esm/phase/impl/SendAsyncActivitiesOnResponsePhase.js +0 -10
  299. package/lib/types/config/ConfigurationBuilderBase.d.ts +0 -13
  300. package/lib/types/config/remote_config/DefaultRemoteConfigUpdater.d.ts +0 -34
  301. package/lib/types/config/remote_config/IRemoteConfigUpdater.d.ts +0 -6
  302. package/lib/types/config/remote_config/model/RemoteConfigUpdateRequestData.d.ts +0 -3
  303. package/lib/types/phase/flow/EndEnforcerFlow.d.ts +0 -8
  304. package/lib/types/phase/flow/EnforceFlow.d.ts +0 -8
  305. package/lib/types/phase/flow/FilterFlow.d.ts +0 -11
  306. package/lib/types/phase/flow/PostEnforceFlow.d.ts +0 -6
  307. package/lib/types/phase/impl/SendAsyncActivitiesOnRequestPhase.d.ts +0 -10
  308. package/lib/types/risk_api/client/PostRiskApiClientBase.d.ts +0 -40
  309. /package/lib/cjs/config/remote_config/{IRemoteConfigUpdater.js → manager/IRemoteConfigManager.js} +0 -0
  310. /package/lib/cjs/config/remote_config/model/{RemoteConfigUpdateRequestData.js → RemoteConfigNotifyRequestPayload.js} +0 -0
  311. /package/lib/cjs/{risk_api/client/IRiskApiClient.js → config/remote_config/update_parser/IRemoteConfigUpdateParser.js} +0 -0
  312. /package/lib/esm/config/remote_config/{IRemoteConfigUpdater.js → manager/IRemoteConfigManager.js} +0 -0
  313. /package/lib/esm/config/remote_config/model/{RemoteConfigUpdateRequestData.js → RemoteConfigNotifyRequestPayload.js} +0 -0
  314. /package/lib/esm/{risk_api/client/IRiskApiClient.js → config/remote_config/update_parser/IRemoteConfigUpdateParser.js} +0 -0
@@ -0,0 +1,43 @@
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.PostRiskApiClientBase = void 0;
19
+ var RiskApiClientBase_1 = require("./RiskApiClientBase.js");
20
+ var http_1 = require("../../../http/index.js");
21
+ var utils_1 = require("../../utils.js");
22
+ var http_2 = require("../../../http/index.js");
23
+ var PostRiskApiClientBase = /** @class */ (function (_super) {
24
+ __extends(PostRiskApiClientBase, _super);
25
+ function PostRiskApiClientBase() {
26
+ return _super !== null && _super.apply(this, arguments) || this;
27
+ }
28
+ PostRiskApiClientBase.prototype.createRiskRequest = function (context) {
29
+ var url = this.getRiskUrl();
30
+ var headers = this.getRiskHeaders();
31
+ var body = JSON.stringify((0, utils_1.createRiskApiActivity)(this.config, context));
32
+ var method = http_1.HttpMethod.POST;
33
+ return new http_1.OutgoingRequestImpl({ url: url, method: method, headers: headers, body: body });
34
+ };
35
+ PostRiskApiClientBase.prototype.getRiskHeaders = function () {
36
+ var _a;
37
+ return Object.assign((_a = {},
38
+ _a[http_2.CONTENT_TYPE_HEADER_NAME] = [http_2.ContentType.APPLICATION_JSON],
39
+ _a), _super.prototype.getRiskHeaders.call(this));
40
+ };
41
+ return PostRiskApiClientBase;
42
+ }(RiskApiClientBase_1.RiskApiClientBase));
43
+ exports.PostRiskApiClientBase = PostRiskApiClientBase;
@@ -1,15 +1,4 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -47,14 +36,14 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
47
36
  }
48
37
  };
49
38
  Object.defineProperty(exports, "__esModule", { value: true });
50
- exports.isEnforcerTimeoutError = exports.PostRiskApiClientBase = void 0;
51
- var http_1 = require("../../http/index.js");
52
- var utils_1 = require("../../utils/index.js");
53
- var activities_1 = require("../../activities/index.js");
54
- var constants_1 = require("../constants.js");
55
- var model_1 = require("../model/index.js");
56
- var PostRiskApiClientBase = /** @class */ (function () {
57
- function PostRiskApiClientBase(config, httpClient) {
39
+ exports.isEnforcerTimeoutError = exports.RiskApiClientBase = void 0;
40
+ var http_1 = require("../../../http/index.js");
41
+ var utils_1 = require("../../../utils/index.js");
42
+ var activities_1 = require("../../../activities/index.js");
43
+ var constants_1 = require("../../constants.js");
44
+ var model_1 = require("../../model/index.js");
45
+ var RiskApiClientBase = /** @class */ (function () {
46
+ function RiskApiClientBase(config, httpClient) {
58
47
  this.config = config;
59
48
  this.httpClient = httpClient;
60
49
  }
@@ -63,9 +52,9 @@ var PostRiskApiClientBase = /** @class */ (function () {
63
52
  * @param context
64
53
  * @returns Promise<RiskApiData>
65
54
  */
66
- PostRiskApiClientBase.prototype.executeRiskApi = function (context) {
55
+ RiskApiClientBase.prototype.executeRiskApi = function (context) {
67
56
  return __awaiter(this, void 0, void 0, function () {
68
- var response, riskResponse, riskApiData, riskActivity, err_1;
57
+ var response, riskResponse, riskApiData, riskRequest, err_1;
69
58
  return __generator(this, function (_a) {
70
59
  switch (_a.label) {
71
60
  case 0:
@@ -73,8 +62,8 @@ var PostRiskApiClientBase = /** @class */ (function () {
73
62
  _a.label = 1;
74
63
  case 1:
75
64
  _a.trys.push([1, 8, , 10]);
76
- riskActivity = this.createRiskActivity(context);
77
- return [4 /*yield*/, this.sendRiskActivity(riskActivity, riskApiData, context)];
65
+ riskRequest = this.createRiskRequest(context);
66
+ return [4 /*yield*/, this.sendRiskActivity(riskRequest, riskApiData, context)];
78
67
  case 2:
79
68
  response = _a.sent();
80
69
  if (!((response === null || response === void 0 ? void 0 : response.status) !== 200)) return [3 /*break*/, 4];
@@ -104,52 +93,17 @@ var PostRiskApiClientBase = /** @class */ (function () {
104
93
  });
105
94
  });
106
95
  };
107
- /**
108
- * Creates the RiskActivity payload
109
- * @param context
110
- * @returns RiskActivity
111
- * @protected
112
- */
113
- PostRiskApiClientBase.prototype.createRiskActivity = function (context) {
114
- var _a, _b, _c;
115
- var riskActivity = {
116
- vid: context.vid,
117
- client_uuid: context.uuid,
118
- pxhd: (_a = context.pxhd) === null || _a === void 0 ? void 0 : _a.value,
119
- request: {
120
- socket_ip: context.requestData.ip,
121
- headers: this.formatRiskHeadersField(context.requestData.headers),
122
- url: context.requestData.url.href,
123
- },
124
- additional: __assign(__assign({}, (0, activities_1.createCommonActivityDetails)(this.config, context)), { s2s_call_reason: (_b = context.riskApiData.s2sCallReason) !== null && _b !== void 0 ? _b : 'unknown_reason', risk_start_time: (_c = context.riskApiData.riskStartTime) !== null && _c !== void 0 ? _c : Date.now() }),
125
- };
126
- return this.finalizeRiskActivity(riskActivity);
127
- };
128
- /**
129
- * Protected function in case expansions or alterations to the risk activity are needed for certain platforms.
130
- * @param riskActivity
131
- * @returns RiskActivity
132
- * @protected
133
- */
134
- PostRiskApiClientBase.prototype.finalizeRiskActivity = function (riskActivity) {
135
- return riskActivity;
136
- };
137
- PostRiskApiClientBase.prototype.formatRiskHeadersField = function (headers) {
96
+ RiskApiClientBase.prototype.formatRiskHeadersField = function (headers) {
138
97
  var headersWithoutSensitive = (0, utils_1.removeSensitiveHeaders)(headers, this.config.sensitiveHeaders);
139
98
  return (0, activities_1.toHeaderEntryArray)(headersWithoutSensitive);
140
99
  };
141
- PostRiskApiClientBase.prototype.sendRiskActivity = function (riskActivity, riskApiData, context) {
100
+ RiskApiClientBase.prototype.sendRiskActivity = function (riskRequest, riskApiData, context) {
142
101
  return __awaiter(this, void 0, void 0, function () {
143
- var url, headers, body, method, riskRequest, startTime, response, endTime;
102
+ var startTime, response, endTime;
144
103
  return __generator(this, function (_a) {
145
104
  switch (_a.label) {
146
105
  case 0:
147
- url = this.getRiskUrl();
148
- headers = this.getRiskHeaders();
149
- body = JSON.stringify(riskActivity);
150
- method = http_1.HttpMethod.POST;
151
- riskRequest = new http_1.OutgoingRequestImpl({ url: url, method: method, headers: headers, body: body });
152
- context.logger.debug("sending risk api to ".concat(url));
106
+ context.logger.debug("sending risk api to ".concat(riskRequest.url));
153
107
  startTime = Date.now();
154
108
  return [4 /*yield*/, this.httpClient.send(riskRequest, { timeoutMs: this.config.s2sTimeout })];
155
109
  case 1:
@@ -162,21 +116,20 @@ var PostRiskApiClientBase = /** @class */ (function () {
162
116
  });
163
117
  });
164
118
  };
165
- PostRiskApiClientBase.prototype.getRiskUrl = function () {
119
+ RiskApiClientBase.prototype.getRiskUrl = function () {
166
120
  return "".concat(this.config.backendScoreApiUrl).concat(constants_1.RISK_API_ENDPOINT);
167
121
  };
168
- PostRiskApiClientBase.prototype.getRiskHeaders = function () {
122
+ RiskApiClientBase.prototype.getRiskHeaders = function () {
169
123
  var _a;
170
124
  return _a = {},
171
- _a[http_1.CONTENT_TYPE_HEADER_NAME] = [http_1.ContentType.APPLICATION_JSON],
172
125
  _a[http_1.AUTHORIZATION_HEADER_NAME] = [(0, utils_1.getAuthorizationHeader)(this.config.authToken)],
173
126
  _a;
174
127
  };
175
- PostRiskApiClientBase.prototype.handleS2STimeout = function (riskApiData) {
128
+ RiskApiClientBase.prototype.handleS2STimeout = function (riskApiData) {
176
129
  riskApiData.riskApiCallResult = model_1.RiskApiCallResult.TIMEOUT;
177
130
  return riskApiData;
178
131
  };
179
- PostRiskApiClientBase.prototype.handleS2SError = function (riskApiData, context, response, error) {
132
+ RiskApiClientBase.prototype.handleS2SError = function (riskApiData, context, response, error) {
180
133
  return __awaiter(this, void 0, void 0, function () {
181
134
  var _a, _b, _c, errorMessage, existingMessage;
182
135
  var _d, _e, _f;
@@ -228,9 +181,9 @@ var PostRiskApiClientBase = /** @class */ (function () {
228
181
  });
229
182
  });
230
183
  };
231
- return PostRiskApiClientBase;
184
+ return RiskApiClientBase;
232
185
  }());
233
- exports.PostRiskApiClientBase = PostRiskApiClientBase;
186
+ exports.RiskApiClientBase = RiskApiClientBase;
234
187
  var isEnforcerTimeoutError = function (err) {
235
188
  return typeof err === 'object' && !!err && 'name' in err && err.name === utils_1.EnforcerErrorName.ENFORCER_TIMEOUT_ERROR;
236
189
  };
@@ -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("./PostRiskApiClientBase.js"), exports);
18
+ __exportStar(require("./RiskApiClientBase.js"), exports);
19
+ __exportStar(require("./IRiskApiClient.js"), exports);
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./IRiskApiClient.js"), exports);
18
- __exportStar(require("./PostRiskApiClientBase.js"), exports);
19
17
  __exportStar(require("./PostRiskApiClientV2.js"), exports);
20
18
  __exportStar(require("./PostRiskApiClientV3.js"), exports);
19
+ __exportStar(require("./abstract/index.js"), exports);
20
+ __exportStar(require("./GetRiskApiClientV2.js"), exports);
@@ -18,3 +18,4 @@ __exportStar(require("./model/index.js"), exports);
18
18
  __exportStar(require("./risk_response/index.js"), exports);
19
19
  __exportStar(require("./client/index.js"), exports);
20
20
  __exportStar(require("./constants.js"), exports);
21
+ __exportStar(require("./utils.js"), exports);
@@ -0,0 +1,185 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RISK_ACTIVITY_ADDITIONAL_FIELDS_TO_HEADER_NAMES = exports.RISK_ACTIVITY_REQUEST_FIELDS_TO_HEADER_NAMES = exports.RISK_ACTIVITY_FIELDS_TO_HEADER_NAMES = void 0;
4
+ exports.RISK_ACTIVITY_FIELDS_TO_HEADER_NAMES = {
5
+ vid: {
6
+ header: 'x-px-vid',
7
+ },
8
+ client_uuid: {
9
+ header: 'x-px-client-uuid',
10
+ },
11
+ pxhd: {
12
+ header: 'x-px-pxhd',
13
+ },
14
+ };
15
+ exports.RISK_ACTIVITY_REQUEST_FIELDS_TO_HEADER_NAMES = {
16
+ socket_ip: {
17
+ header: 'x-px-socket-ip',
18
+ },
19
+ url: {
20
+ header: 'x-px-url',
21
+ },
22
+ };
23
+ exports.RISK_ACTIVITY_ADDITIONAL_FIELDS_TO_HEADER_NAMES = {
24
+ cpa: {
25
+ header: 'x-px-add-cpa',
26
+ convertToString: function (value) { return "".concat(value); },
27
+ },
28
+ enforcer_start_time: {
29
+ header: 'x-px-add-enforcer-start-time',
30
+ convertToString: function (value) { return "".concat(value); },
31
+ },
32
+ is_hype_sale: {
33
+ header: 'x-px-add-is-hype-sale',
34
+ convertToString: function (value) { return "".concat(value); },
35
+ },
36
+ px_cookie_hmac: {
37
+ header: 'x-px-add-cookie-hmac',
38
+ },
39
+ raw_url: {
40
+ header: 'x-px-add-raw-url',
41
+ },
42
+ tls_ja3_fingerprint: {
43
+ header: 'x-px-add-tls-ja3-fingerprint',
44
+ },
45
+ tls_preferred_ciphers: {
46
+ header: 'x-px-add-tls-preferred-ciphers',
47
+ },
48
+ used_cookie_secret: {
49
+ header: 'x-px-add-used-cookie-secret',
50
+ },
51
+ risk_start_time: {
52
+ header: 'x-px-add-risk-start-time',
53
+ convertToString: function (value) { return "".concat(value); },
54
+ },
55
+ app_user_id: {
56
+ header: 'x-px-add-app-user-id',
57
+ },
58
+ ci_version: {
59
+ header: 'x-px-add-ci-version',
60
+ },
61
+ cookie_origin: {
62
+ header: 'x-px-add-cookie-origin',
63
+ },
64
+ cross_tab_session: {
65
+ header: 'x-px-add-cross-tab-session',
66
+ },
67
+ custom_param1: {
68
+ header: 'x-px-custom-param1',
69
+ },
70
+ custom_param10: {
71
+ header: 'x-px-custom-param10',
72
+ },
73
+ custom_param2: {
74
+ header: 'x-px-custom-param2',
75
+ },
76
+ custom_param3: {
77
+ header: 'x-px-custom-param3',
78
+ },
79
+ custom_param4: {
80
+ header: 'x-px-custom-param4',
81
+ },
82
+ custom_param5: {
83
+ header: 'x-px-custom-param5',
84
+ },
85
+ custom_param6: {
86
+ header: 'x-px-custom-param6',
87
+ },
88
+ custom_param7: {
89
+ header: 'x-px-custom-param7',
90
+ },
91
+ custom_param8: {
92
+ header: 'x-px-custom-param8',
93
+ },
94
+ custom_param9: {
95
+ header: 'x-px-custom-param9',
96
+ },
97
+ enforcer_vid_source: {
98
+ header: 'x-px-add-enforcer-vid-source',
99
+ },
100
+ server_info_datacenter: {
101
+ header: 'x-px-add-server-info-datacenter',
102
+ },
103
+ server_info_region: {
104
+ header: 'x-px-add-server-info-region',
105
+ },
106
+ graphql_operations: {
107
+ header: 'x-px-add-graphql-operations',
108
+ convertToString: function (value) { return JSON.stringify(value); },
109
+ },
110
+ http_method: {
111
+ header: 'x-px-add-http-method',
112
+ },
113
+ http_version: {
114
+ header: 'x-px-add-http-version',
115
+ },
116
+ jwt_additional_fields: {
117
+ header: 'x-px-add-jwt-additional-fields',
118
+ convertToString: function (value) { return JSON.stringify(value); },
119
+ },
120
+ module_version: {
121
+ header: 'x-px-add-module-version',
122
+ },
123
+ original_token: {
124
+ header: 'x-px-add-original-token',
125
+ },
126
+ original_token_error: {
127
+ header: 'x-px-add-original-token-error',
128
+ },
129
+ original_uuid: {
130
+ header: 'x-px-add-original-uuid',
131
+ },
132
+ pass: {
133
+ header: 'x-px-add-pass',
134
+ },
135
+ px_cookie: {
136
+ header: 'x-px-add-px-cookie',
137
+ },
138
+ px_decoded_original_token: {
139
+ header: 'x-px-decoded-original-token',
140
+ },
141
+ px_orig_cookie: {
142
+ header: 'x-px-add-px-orig-cookie',
143
+ },
144
+ request_cookie_names: {
145
+ header: 'x-px-add-request-cookie-names',
146
+ convertToString: function (value) { return value.join(','); },
147
+ },
148
+ request_id: {
149
+ header: 'x-px-add-request-id',
150
+ },
151
+ risk_mode: {
152
+ header: 'x-px-add-risk-mode',
153
+ },
154
+ sso_step: {
155
+ header: 'x-px-add-sso-step',
156
+ },
157
+ tls_cipher: {
158
+ header: 'x-px-add-tls-cipher',
159
+ },
160
+ tls_ciphers_sha: {
161
+ header: 'x-px-add-tls-ciphers-sha',
162
+ },
163
+ tls_extension_sha: {
164
+ header: 'x-px-add-tls-extension-sha',
165
+ },
166
+ tls_protocol: {
167
+ header: 'x-px-add-tls-protocol',
168
+ },
169
+ tls_server: {
170
+ header: 'x-px-add-tls-server',
171
+ },
172
+ user: {
173
+ header: 'x-px-add-user',
174
+ },
175
+ remote_config_id: {
176
+ header: 'x-px-add-remote-config-id',
177
+ },
178
+ remote_config_version: {
179
+ header: 'x-px-add-remote-config-version',
180
+ convertToString: function (value) { return "".concat(value); },
181
+ },
182
+ s2s_call_reason: {
183
+ header: 'x-px-add-s2s-call-reason',
184
+ },
185
+ };
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetRiskResponseHeaders = void 0;
4
+ exports.GetRiskResponseHeaders = {
5
+ Action: 'x-px-action',
6
+ AdditionalRiskInfo: 'x-px-additional-risk-info',
7
+ CookieCfgBlockResult: 'x-px-cookie-cfg-block-result',
8
+ DataEnrichment: 'x-px-data-enrichment',
9
+ Drc: 'x-px-drc',
10
+ Message: 'x-px-message',
11
+ Pxhd: 'x-px-pxhd',
12
+ PxhdDomain: 'x-px-pxhddomain',
13
+ Status: 'x-px-status',
14
+ TelemetryRequested: 'x-px-telemetry-requested',
15
+ Uuid: 'x-px-uuid',
16
+ };
@@ -18,3 +18,5 @@ __exportStar(require("./RiskActivity.js"), exports);
18
18
  __exportStar(require("./RiskStatus.js"), exports);
19
19
  __exportStar(require("./RiskApiCallResult.js"), exports);
20
20
  __exportStar(require("./S2SErrorReason.js"), exports);
21
+ __exportStar(require("./GetRiskResponseHeaders.js"), exports);
22
+ __exportStar(require("./GetRiskRequestHeaders.js"), exports);
@@ -1,4 +1,19 @@
1
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
+ })();
2
17
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
18
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
19
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -36,39 +51,20 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
36
51
  }
37
52
  };
38
53
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.SendAsyncActivitiesOnRequestPhase = void 0;
40
- var action_1 = require("../../action/index.js");
41
- var SendAsyncActivitiesOnRequestPhase = /** @class */ (function () {
42
- function SendAsyncActivitiesOnRequestPhase(activityClient) {
43
- this.activityClient = activityClient;
54
+ exports.PostRiskResponseBase = void 0;
55
+ var RiskResponseBase_1 = require("./RiskResponseBase.js");
56
+ var PostRiskResponseBase = /** @class */ (function (_super) {
57
+ __extends(PostRiskResponseBase, _super);
58
+ function PostRiskResponseBase() {
59
+ return _super !== null && _super.apply(this, arguments) || this;
44
60
  }
45
- SendAsyncActivitiesOnRequestPhase.prototype.execute = function (context) {
46
- return __awaiter(this, void 0, void 0, function () {
47
- return __generator(this, function (_a) {
48
- switch (_a.label) {
49
- case 0:
50
- if (!(context.action === action_1.Action.BLOCK)) return [3 /*break*/, 2];
51
- return [4 /*yield*/, this.sendAsyncActivity(context)];
52
- case 1:
53
- _a.sent();
54
- _a.label = 2;
55
- case 2: return [2 /*return*/, { done: false }];
56
- }
57
- });
58
- });
59
- };
60
- SendAsyncActivitiesOnRequestPhase.prototype.sendAsyncActivity = function (context) {
61
+ PostRiskResponseBase.prototype.parseRiskResponse = function (response) {
61
62
  return __awaiter(this, void 0, void 0, function () {
62
63
  return __generator(this, function (_a) {
63
- switch (_a.label) {
64
- case 0: return [4 /*yield*/, this.activityClient.sendActivities(context)];
65
- case 1:
66
- _a.sent();
67
- return [2 /*return*/];
68
- }
64
+ return [2 /*return*/, response.json()];
69
65
  });
70
66
  });
71
67
  };
72
- return SendAsyncActivitiesOnRequestPhase;
73
- }());
74
- exports.SendAsyncActivitiesOnRequestPhase = SendAsyncActivitiesOnRequestPhase;
68
+ return PostRiskResponseBase;
69
+ }(RiskResponseBase_1.RiskResponseBase));
70
+ exports.PostRiskResponseBase = PostRiskResponseBase;
@@ -44,18 +44,21 @@ var RiskResponseBase = /** @class */ (function () {
44
44
  }
45
45
  RiskResponseBase.prototype.validate = function () {
46
46
  return __awaiter(this, void 0, void 0, function () {
47
- var _a, e_1;
48
- return __generator(this, function (_b) {
49
- switch (_b.label) {
47
+ var riskResponse, e_1;
48
+ return __generator(this, function (_a) {
49
+ switch (_a.label) {
50
50
  case 0:
51
- _b.trys.push([0, 2, , 3]);
52
- _a = this;
53
- return [4 /*yield*/, this.response.json()];
51
+ _a.trys.push([0, 2, , 3]);
52
+ return [4 /*yield*/, this.parseRiskResponse(this.response)];
54
53
  case 1:
55
- _a.riskResponse = (_b.sent());
54
+ riskResponse = _a.sent();
55
+ if (!riskResponse) {
56
+ return [2 /*return*/, false];
57
+ }
58
+ this.riskResponse = riskResponse;
56
59
  return [2 /*return*/, this.status === model_1.RiskStatus.SUCCESS && this.validateRiskResponseScore()];
57
60
  case 2:
58
- e_1 = _b.sent();
61
+ e_1 = _a.sent();
59
62
  return [2 /*return*/, false];
60
63
  case 3: return [2 /*return*/];
61
64
  }
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./IRiskResponse.js"), exports);
18
18
  __exportStar(require("./RiskResponseBase.js"), exports);
19
+ __exportStar(require("./PostRiskResponseBase.js"), exports);
19
20
  __exportStar(require("./CommonRiskResponsePayload.js"), exports);
20
21
  __exportStar(require("./v2/index.js"), exports);
21
22
  __exportStar(require("./v3/index.js"), exports);
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SerializedRiskResponse = void 0;
4
+ var utils_1 = require("../../../utils/index.js");
4
5
  var SerializedRiskResponse = /** @class */ (function () {
5
6
  function SerializedRiskResponse(riskResponseJson) {
6
7
  this.action = riskResponseJson.action;
@@ -16,7 +17,10 @@ var SerializedRiskResponse = /** @class */ (function () {
16
17
  this.uuid = riskResponseJson.uuid;
17
18
  }
18
19
  SerializedRiskResponse.prototype.validate = function () {
19
- return true;
20
+ throw new utils_1.EnforcerError('SerializedRiskResponse.validate() should not be invoked');
21
+ };
22
+ SerializedRiskResponse.prototype.toJSON = function () {
23
+ return this;
20
24
  };
21
25
  return SerializedRiskResponse;
22
26
  }());
@@ -0,0 +1,80 @@
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.GetRiskResponseV2 = void 0;
19
+ var RiskResponseBase_1 = require("../RiskResponseBase.js");
20
+ var model_1 = require("../../model/index.js");
21
+ var GetRiskResponseV2 = /** @class */ (function (_super) {
22
+ __extends(GetRiskResponseV2, _super);
23
+ function GetRiskResponseV2(response) {
24
+ return _super.call(this, response) || this;
25
+ }
26
+ GetRiskResponseV2.prototype.parseRiskResponse = function (response) {
27
+ var riskStatus = this.getHeader(response, model_1.GetRiskResponseHeaders.Status);
28
+ if (!riskStatus) {
29
+ return null;
30
+ }
31
+ var status = parseInt(riskStatus);
32
+ var blockResult = this.getHeader(response, model_1.GetRiskResponseHeaders.CookieCfgBlockResult);
33
+ var additionalRiskInfo = this.getHeader(response, model_1.GetRiskResponseHeaders.AdditionalRiskInfo);
34
+ var dataEnrichment = this.getHeader(response, model_1.GetRiskResponseHeaders.DataEnrichment);
35
+ var drc = this.getHeader(response, model_1.GetRiskResponseHeaders.Drc);
36
+ var message = this.getHeader(response, model_1.GetRiskResponseHeaders.Message);
37
+ var pxhd = this.getHeader(response, model_1.GetRiskResponseHeaders.Pxhd);
38
+ var pxhdDomain = this.getHeader(response, model_1.GetRiskResponseHeaders.PxhdDomain);
39
+ var telemetryRequested = this.getHeader(response, model_1.GetRiskResponseHeaders.TelemetryRequested);
40
+ var uuid = this.getHeader(response, model_1.GetRiskResponseHeaders.Uuid);
41
+ var action = this.getHeader(response, model_1.GetRiskResponseHeaders.Action);
42
+ return {
43
+ status: status,
44
+ action: action,
45
+ uuid: uuid,
46
+ pxhd: pxhd,
47
+ message: message,
48
+ data_enrichment: dataEnrichment ? JSON.parse(dataEnrichment) : undefined,
49
+ pxhdDomain: pxhdDomain,
50
+ additional_risk_info: additionalRiskInfo,
51
+ telemetry_requested: !!telemetryRequested,
52
+ drc: drc ? parseInt(drc) : undefined,
53
+ cookie_cfg_block_result: blockResult,
54
+ };
55
+ };
56
+ GetRiskResponseV2.prototype.getHeader = function (response, header) {
57
+ var _a;
58
+ return (_a = response.headers[header.toLowerCase()]) === null || _a === void 0 ? void 0 : _a[0];
59
+ };
60
+ Object.defineProperty(GetRiskResponseV2.prototype, "score", {
61
+ // TODO: This is the same as in PostRiskResponseV2. We should deduplicate this.
62
+ get: function () {
63
+ var _a;
64
+ return typeof ((_a = this.riskResponse) === null || _a === void 0 ? void 0 : _a.cookie_cfg_block_result) === 'undefined'
65
+ ? undefined
66
+ : this.riskResponse.cookie_cfg_block_result === '1'
67
+ ? 100
68
+ : 0;
69
+ },
70
+ enumerable: false,
71
+ configurable: true
72
+ });
73
+ GetRiskResponseV2.prototype.validateRiskResponseScore = function () {
74
+ var _a;
75
+ var blockResult = (_a = this.riskResponse) === null || _a === void 0 ? void 0 : _a.cookie_cfg_block_result;
76
+ return typeof blockResult === 'string' && ['0', '1'].includes(blockResult);
77
+ };
78
+ return GetRiskResponseV2;
79
+ }(RiskResponseBase_1.RiskResponseBase));
80
+ exports.GetRiskResponseV2 = GetRiskResponseV2;