perimeterx-js-core 0.1.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 (288) hide show
  1. package/README.md +158 -0
  2. package/lib/activities/ActivityType.d.ts +6 -0
  3. package/lib/activities/ActivityType.js +10 -0
  4. package/lib/activities/HttpActivityClient.d.ts +12 -0
  5. package/lib/activities/HttpActivityClient.js +107 -0
  6. package/lib/activities/IActivityClient.d.ts +8 -0
  7. package/lib/activities/IActivityClient.js +2 -0
  8. package/lib/activities/constants.d.ts +1 -0
  9. package/lib/activities/constants.js +4 -0
  10. package/lib/activities/index.d.ts +5 -0
  11. package/lib/activities/index.js +7 -0
  12. package/lib/activities/model/Activity.d.ts +13 -0
  13. package/lib/activities/model/Activity.js +2 -0
  14. package/lib/activities/model/ActivityDetails.d.ts +41 -0
  15. package/lib/activities/model/ActivityDetails.js +2 -0
  16. package/lib/activities/utils.d.ts +10 -0
  17. package/lib/activities/utils.js +88 -0
  18. package/lib/additional_activity_handler/AdditionalActivityHandler.d.ts +3 -0
  19. package/lib/additional_activity_handler/AdditionalActivityHandler.js +2 -0
  20. package/lib/additional_activity_handler/AdditionalActivityHandlerUtils.d.ts +5 -0
  21. package/lib/additional_activity_handler/AdditionalActivityHandlerUtils.js +64 -0
  22. package/lib/additional_activity_handler/index.d.ts +2 -0
  23. package/lib/additional_activity_handler/index.js +5 -0
  24. package/lib/block_handler/BlockAction.d.ts +6 -0
  25. package/lib/block_handler/BlockAction.js +21 -0
  26. package/lib/block_handler/BlockReason.d.ts +4 -0
  27. package/lib/block_handler/BlockReason.js +8 -0
  28. package/lib/block_handler/DefaultBlockResponseGenerator.d.ts +14 -0
  29. package/lib/block_handler/DefaultBlockResponseGenerator.js +44 -0
  30. package/lib/block_handler/IBlockResponseGenerator.d.ts +14 -0
  31. package/lib/block_handler/IBlockResponseGenerator.js +2 -0
  32. package/lib/block_handler/captcha/CaptchaBlockResponseGenerator.d.ts +14 -0
  33. package/lib/block_handler/captcha/CaptchaBlockResponseGenerator.js +30 -0
  34. package/lib/block_handler/captcha/HtmlCaptchaResponseGenerator.d.ts +10 -0
  35. package/lib/block_handler/captcha/HtmlCaptchaResponseGenerator.js +25 -0
  36. package/lib/block_handler/captcha/JsonCaptchaResponseGenerator.d.ts +10 -0
  37. package/lib/block_handler/captcha/JsonCaptchaResponseGenerator.js +44 -0
  38. package/lib/block_handler/captcha/MobileCaptchaResponseGenerator.d.ts +12 -0
  39. package/lib/block_handler/captcha/MobileCaptchaResponseGenerator.js +36 -0
  40. package/lib/block_handler/index.d.ts +13 -0
  41. package/lib/block_handler/index.js +21 -0
  42. package/lib/block_handler/model/BlockData.d.ts +16 -0
  43. package/lib/block_handler/model/BlockData.js +2 -0
  44. package/lib/block_handler/model/JsonBlockPayload.d.ts +11 -0
  45. package/lib/block_handler/model/JsonBlockPayload.js +2 -0
  46. package/lib/block_handler/model/MobileBlockPayload.d.ts +8 -0
  47. package/lib/block_handler/model/MobileBlockPayload.js +2 -0
  48. package/lib/block_handler/templates/captcha_template.d.ts +1 -0
  49. package/lib/block_handler/templates/captcha_template.js +4 -0
  50. package/lib/block_handler/templates/rate_limit_template.d.ts +1 -0
  51. package/lib/block_handler/templates/rate_limit_template.js +4 -0
  52. package/lib/block_handler/utils.d.ts +5 -0
  53. package/lib/block_handler/utils.js +48 -0
  54. package/lib/config/ConfigurationParams.d.ts +65 -0
  55. package/lib/config/ConfigurationParams.js +2 -0
  56. package/lib/config/DefaultConfigurations.d.ts +2 -0
  57. package/lib/config/DefaultConfigurations.js +107 -0
  58. package/lib/config/IConfiguration.d.ts +172 -0
  59. package/lib/config/IConfiguration.js +2 -0
  60. package/lib/config/StaticConfigurationBase.d.ts +57 -0
  61. package/lib/config/StaticConfigurationBase.js +355 -0
  62. package/lib/config/index.d.ts +4 -0
  63. package/lib/config/index.js +7 -0
  64. package/lib/context/ContextBase.d.ts +55 -0
  65. package/lib/context/ContextBase.js +206 -0
  66. package/lib/context/DefaultTokenV2Context.d.ts +13 -0
  67. package/lib/context/DefaultTokenV2Context.js +35 -0
  68. package/lib/context/DefaultTokenV3Context.d.ts +13 -0
  69. package/lib/context/DefaultTokenV3Context.js +35 -0
  70. package/lib/context/IContext.d.ts +256 -0
  71. package/lib/context/IContext.js +2 -0
  72. package/lib/context/index.d.ts +4 -0
  73. package/lib/context/index.js +9 -0
  74. package/lib/custom_parameters/CustomParameters.d.ts +12 -0
  75. package/lib/custom_parameters/CustomParameters.js +2 -0
  76. package/lib/custom_parameters/CustomParametersFunction.d.ts +4 -0
  77. package/lib/custom_parameters/CustomParametersFunction.js +2 -0
  78. package/lib/custom_parameters/CustomParametersUtils.d.ts +4 -0
  79. package/lib/custom_parameters/CustomParametersUtils.js +19 -0
  80. package/lib/custom_parameters/index.d.ts +3 -0
  81. package/lib/custom_parameters/index.js +5 -0
  82. package/lib/enforcer/EnforcerBase.d.ts +139 -0
  83. package/lib/enforcer/EnforcerBase.js +376 -0
  84. package/lib/enforcer/IEnforcer.d.ts +4 -0
  85. package/lib/enforcer/IEnforcer.js +2 -0
  86. package/lib/enforcer/index.d.ts +2 -0
  87. package/lib/enforcer/index.js +5 -0
  88. package/lib/filter/DefaultFilter.d.ts +16 -0
  89. package/lib/filter/DefaultFilter.js +59 -0
  90. package/lib/filter/FilterReason.d.ts +8 -0
  91. package/lib/filter/FilterReason.js +12 -0
  92. package/lib/filter/IFilter.d.ts +8 -0
  93. package/lib/filter/IFilter.js +2 -0
  94. package/lib/filter/index.d.ts +3 -0
  95. package/lib/filter/index.js +7 -0
  96. package/lib/first_party/DefaultFirstParty.d.ts +22 -0
  97. package/lib/first_party/DefaultFirstParty.js +215 -0
  98. package/lib/first_party/IFirstParty.d.ts +9 -0
  99. package/lib/first_party/IFirstParty.js +2 -0
  100. package/lib/first_party/constants.d.ts +32 -0
  101. package/lib/first_party/constants.js +39 -0
  102. package/lib/first_party/index.d.ts +4 -0
  103. package/lib/first_party/index.js +21 -0
  104. package/lib/first_party/utils.d.ts +8 -0
  105. package/lib/first_party/utils.js +27 -0
  106. package/lib/http/IHttpClient.d.ts +10 -0
  107. package/lib/http/IHttpClient.js +2 -0
  108. package/lib/http/body_reader/IBodyReader.d.ts +5 -0
  109. package/lib/http/body_reader/IBodyReader.js +2 -0
  110. package/lib/http/body_reader/StringBodyReader.d.ts +8 -0
  111. package/lib/http/body_reader/StringBodyReader.js +70 -0
  112. package/lib/http/index.d.ts +10 -0
  113. package/lib/http/index.js +28 -0
  114. package/lib/http/request/DefaultHttpRequest.d.ts +5 -0
  115. package/lib/http/request/DefaultHttpRequest.js +42 -0
  116. package/lib/http/request/HttpRequestBase.d.ts +24 -0
  117. package/lib/http/request/HttpRequestBase.js +77 -0
  118. package/lib/http/request/IHttpRequest.d.ts +31 -0
  119. package/lib/http/request/IHttpRequest.js +2 -0
  120. package/lib/http/response/DefaultHttpResponse.d.ts +5 -0
  121. package/lib/http/response/DefaultHttpResponse.js +32 -0
  122. package/lib/http/response/HttpResponseBase.d.ts +17 -0
  123. package/lib/http/response/HttpResponseBase.js +75 -0
  124. package/lib/http/response/IHttpResponse.d.ts +26 -0
  125. package/lib/http/response/IHttpResponse.js +2 -0
  126. package/lib/http/utils/ContentType.d.ts +9 -0
  127. package/lib/http/utils/ContentType.js +13 -0
  128. package/lib/http/utils/HttpBody.d.ts +4 -0
  129. package/lib/http/utils/HttpBody.js +2 -0
  130. package/lib/http/utils/HttpHeaders.d.ts +51 -0
  131. package/lib/http/utils/HttpHeaders.js +106 -0
  132. package/lib/http/utils/HttpMethod.d.ts +11 -0
  133. package/lib/http/utils/HttpMethod.js +15 -0
  134. package/lib/http/utils/constants.d.ts +9 -0
  135. package/lib/http/utils/constants.js +12 -0
  136. package/lib/http/utils/index.d.ts +5 -0
  137. package/lib/http/utils/index.js +24 -0
  138. package/lib/index.d.ts +17 -0
  139. package/lib/index.js +33 -0
  140. package/lib/logger/DefaultLogger.d.ts +7 -0
  141. package/lib/logger/DefaultLogger.js +31 -0
  142. package/lib/logger/ILogger.d.ts +24 -0
  143. package/lib/logger/ILogger.js +2 -0
  144. package/lib/logger/LoggerBase.d.ts +11 -0
  145. package/lib/logger/LoggerBase.js +28 -0
  146. package/lib/logger/LoggerSeverity.d.ts +5 -0
  147. package/lib/logger/LoggerSeverity.js +9 -0
  148. package/lib/logger/index.d.ts +4 -0
  149. package/lib/logger/index.js +9 -0
  150. package/lib/pxde/DefaultDataEnrichment.d.ts +14 -0
  151. package/lib/pxde/DefaultDataEnrichment.js +133 -0
  152. package/lib/pxde/IDataEnrichment.d.ts +9 -0
  153. package/lib/pxde/IDataEnrichment.js +2 -0
  154. package/lib/pxde/constants.d.ts +4 -0
  155. package/lib/pxde/constants.js +7 -0
  156. package/lib/pxde/index.d.ts +4 -0
  157. package/lib/pxde/index.js +20 -0
  158. package/lib/pxde/model/PXDE.d.ts +9 -0
  159. package/lib/pxde/model/PXDE.js +2 -0
  160. package/lib/pxhd/PXHDUtils.d.ts +8 -0
  161. package/lib/pxhd/PXHDUtils.js +20 -0
  162. package/lib/pxhd/index.d.ts +1 -0
  163. package/lib/pxhd/index.js +5 -0
  164. package/lib/risk_api/PostRiskApiClient.d.ts +27 -0
  165. package/lib/risk_api/PostRiskApiClient.js +232 -0
  166. package/lib/risk_api/S2SCallReason.d.ts +12 -0
  167. package/lib/risk_api/S2SCallReason.js +16 -0
  168. package/lib/risk_api/S2SErrorHandler.d.ts +9 -0
  169. package/lib/risk_api/S2SErrorHandler.js +121 -0
  170. package/lib/risk_api/S2SErrorReason.d.ts +8 -0
  171. package/lib/risk_api/S2SErrorReason.js +12 -0
  172. package/lib/risk_api/constants.d.ts +1 -0
  173. package/lib/risk_api/constants.js +4 -0
  174. package/lib/risk_api/index.d.ts +13 -0
  175. package/lib/risk_api/index.js +34 -0
  176. package/lib/risk_api/model/RiskActivity.d.ts +50 -0
  177. package/lib/risk_api/model/RiskActivity.js +2 -0
  178. package/lib/risk_api/model/RiskResponseV2.d.ts +10 -0
  179. package/lib/risk_api/model/RiskResponseV2.js +2 -0
  180. package/lib/risk_api/model/RiskResponseV3.d.ts +12 -0
  181. package/lib/risk_api/model/RiskResponseV3.js +2 -0
  182. package/lib/risk_api/model/RiskStatus.d.ts +4 -0
  183. package/lib/risk_api/model/RiskStatus.js +8 -0
  184. package/lib/risk_api/risk_response_handler/IRiskResponseHandler.d.ts +5 -0
  185. package/lib/risk_api/risk_response_handler/IRiskResponseHandler.js +2 -0
  186. package/lib/risk_api/risk_response_handler/RiskResponseHandlerBase.d.ts +16 -0
  187. package/lib/risk_api/risk_response_handler/RiskResponseHandlerBase.js +73 -0
  188. package/lib/risk_api/risk_response_handler/RiskResponseV2Handler.d.ts +10 -0
  189. package/lib/risk_api/risk_response_handler/RiskResponseV2Handler.js +46 -0
  190. package/lib/risk_api/risk_response_handler/RiskResponseV3Handler.d.ts +10 -0
  191. package/lib/risk_api/risk_response_handler/RiskResponseV3Handler.js +47 -0
  192. package/lib/risk_token/MobileError.d.ts +6 -0
  193. package/lib/risk_token/MobileError.js +10 -0
  194. package/lib/risk_token/MobileErrorHandler.d.ts +9 -0
  195. package/lib/risk_token/MobileErrorHandler.js +100 -0
  196. package/lib/risk_token/RiskTokenScoreRetriever.d.ts +14 -0
  197. package/lib/risk_token/RiskTokenScoreRetriever.js +148 -0
  198. package/lib/risk_token/TokenOrigin.d.ts +4 -0
  199. package/lib/risk_token/TokenOrigin.js +8 -0
  200. package/lib/risk_token/TokenVerificationResult.d.ts +6 -0
  201. package/lib/risk_token/TokenVerificationResult.js +10 -0
  202. package/lib/risk_token/TokenVersion.d.ts +4 -0
  203. package/lib/risk_token/TokenVersion.js +8 -0
  204. package/lib/risk_token/constants.d.ts +9 -0
  205. package/lib/risk_token/constants.js +12 -0
  206. package/lib/risk_token/index.d.ts +9 -0
  207. package/lib/risk_token/index.js +32 -0
  208. package/lib/risk_token/token/BotDefenderTokenBase.d.ts +27 -0
  209. package/lib/risk_token/token/BotDefenderTokenBase.js +94 -0
  210. package/lib/risk_token/token/IBotDefenderToken.d.ts +54 -0
  211. package/lib/risk_token/token/IBotDefenderToken.js +2 -0
  212. package/lib/risk_token/token/index.d.ts +7 -0
  213. package/lib/risk_token/token/index.js +11 -0
  214. package/lib/risk_token/token/v2/BotDefenderTokenV2Payload.d.ts +6 -0
  215. package/lib/risk_token/token/v2/BotDefenderTokenV2Payload.js +2 -0
  216. package/lib/risk_token/token/v2/DefaultBotDefenderTokenV2.d.ts +28 -0
  217. package/lib/risk_token/token/v2/DefaultBotDefenderTokenV2.js +199 -0
  218. package/lib/risk_token/token/v3/BotDefenderTokenV3Payload.d.ts +9 -0
  219. package/lib/risk_token/token/v3/BotDefenderTokenV3Payload.js +2 -0
  220. package/lib/risk_token/token/v3/DefaultBotDefenderTokenV3.d.ts +31 -0
  221. package/lib/risk_token/token/v3/DefaultBotDefenderTokenV3.js +231 -0
  222. package/lib/risk_token/token/v3/TokenSignField.d.ts +4 -0
  223. package/lib/risk_token/token/v3/TokenSignField.js +8 -0
  224. package/lib/risk_token/utils.d.ts +2 -0
  225. package/lib/risk_token/utils.js +16 -0
  226. package/lib/telemetry/DefaultTelemetry.d.ts +19 -0
  227. package/lib/telemetry/DefaultTelemetry.js +176 -0
  228. package/lib/telemetry/ITelemetry.d.ts +13 -0
  229. package/lib/telemetry/ITelemetry.js +2 -0
  230. package/lib/telemetry/constants.d.ts +7 -0
  231. package/lib/telemetry/constants.js +10 -0
  232. package/lib/telemetry/index.d.ts +4 -0
  233. package/lib/telemetry/index.js +20 -0
  234. package/lib/telemetry/model/TelemetryActivity.d.ts +15 -0
  235. package/lib/telemetry/model/TelemetryActivity.js +2 -0
  236. package/lib/utils/Algorithm.d.ts +4 -0
  237. package/lib/utils/Algorithm.js +8 -0
  238. package/lib/utils/EnforcerException.d.ts +3 -0
  239. package/lib/utils/EnforcerException.js +26 -0
  240. package/lib/utils/IScoreRetriever.d.ts +14 -0
  241. package/lib/utils/IScoreRetriever.js +2 -0
  242. package/lib/utils/ModuleMode.d.ts +4 -0
  243. package/lib/utils/ModuleMode.js +8 -0
  244. package/lib/utils/PassReason.d.ts +6 -0
  245. package/lib/utils/PassReason.js +10 -0
  246. package/lib/utils/VidSource.d.ts +4 -0
  247. package/lib/utils/VidSource.js +8 -0
  248. package/lib/utils/base64/DefaultBase64Utils.d.ts +5 -0
  249. package/lib/utils/base64/DefaultBase64Utils.js +16 -0
  250. package/lib/utils/base64/IBase64Utils.d.ts +4 -0
  251. package/lib/utils/base64/IBase64Utils.js +2 -0
  252. package/lib/utils/base64/index.d.ts +2 -0
  253. package/lib/utils/base64/index.js +5 -0
  254. package/lib/utils/cipher/ICipherUtils.d.ts +7 -0
  255. package/lib/utils/cipher/ICipherUtils.js +2 -0
  256. package/lib/utils/cipher/index.d.ts +1 -0
  257. package/lib/utils/cipher/index.js +2 -0
  258. package/lib/utils/constants.d.ts +10 -0
  259. package/lib/utils/constants.js +13 -0
  260. package/lib/utils/cookie_parser/DefaultCookieParser.d.ts +4 -0
  261. package/lib/utils/cookie_parser/DefaultCookieParser.js +13 -0
  262. package/lib/utils/cookie_parser/ICookieParser.d.ts +3 -0
  263. package/lib/utils/cookie_parser/ICookieParser.js +2 -0
  264. package/lib/utils/cookie_parser/index.d.ts +2 -0
  265. package/lib/utils/cookie_parser/index.js +5 -0
  266. package/lib/utils/hash/DefaultHashUtils.d.ts +5 -0
  267. package/lib/utils/hash/DefaultHashUtils.js +19 -0
  268. package/lib/utils/hash/IHashUtils.d.ts +4 -0
  269. package/lib/utils/hash/IHashUtils.js +2 -0
  270. package/lib/utils/hash/index.d.ts +2 -0
  271. package/lib/utils/hash/index.js +5 -0
  272. package/lib/utils/index.d.ts +14 -0
  273. package/lib/utils/index.js +35 -0
  274. package/lib/utils/ip_range_checker/DefaultIpRangeChecker.d.ts +4 -0
  275. package/lib/utils/ip_range_checker/DefaultIpRangeChecker.js +13 -0
  276. package/lib/utils/ip_range_checker/IIpRangeChecker.d.ts +3 -0
  277. package/lib/utils/ip_range_checker/IIpRangeChecker.js +2 -0
  278. package/lib/utils/ip_range_checker/index.d.ts +2 -0
  279. package/lib/utils/ip_range_checker/index.js +5 -0
  280. package/lib/utils/utils.d.ts +13 -0
  281. package/lib/utils/utils.js +91 -0
  282. package/lib/utils/uuid_generator/DefaultUuidGenerator.d.ts +4 -0
  283. package/lib/utils/uuid_generator/DefaultUuidGenerator.js +13 -0
  284. package/lib/utils/uuid_generator/IUuidGenerator.d.ts +3 -0
  285. package/lib/utils/uuid_generator/IUuidGenerator.js +2 -0
  286. package/lib/utils/uuid_generator/index.d.ts +2 -0
  287. package/lib/utils/uuid_generator/index.js +5 -0
  288. package/package.json +52 -0
package/README.md ADDED
@@ -0,0 +1,158 @@
1
+ # PerimeterX JavaScript Core
2
+
3
+ ## Overview
4
+
5
+ The purpose of this repository is to provide the components and utilities needed to build a JavaScript/TypeScript enforcer
6
+ on any platform/environment. This repository is *not* a complete running enforcer; rather, it is a tool kit with all the
7
+ building blocks that an enforcer comprises, separated into small, self-contained chunks.
8
+
9
+ A single repository for core enforcer components allows for:
10
+
11
+ * Consistent functionality across all JavaScript enforcers.
12
+ * Faster delivery of new features and bug fixes.
13
+
14
+ ## Design Principles
15
+
16
+ This library was designed with an interface-first mindset. In other words, all provided classes are implementations of defined
17
+ interfaces. Whenever possible, you should use the provided, default implementation for a particular feature to ensure consistent
18
+ behavior across enforcers.
19
+
20
+ However, if the default component cannot be made to function in the framework you are working on, extend it or create a
21
+ new class that implements the relevant interface, and it will work with all the other components in the library.
22
+
23
+ ### Naming Conventions
24
+
25
+ * Interfaces always start with the letter `I` (e.g., `IFirstParty`)
26
+ * Abstract classes always end with the word `Base` (e.g., `ContextBase`)
27
+ * Complete, standard implementations start with the word `Default` (e.g., `DefaultTelemetry`)
28
+ * Utility functions relevant to a particular feature live in a `Utils` namespace named for the feature (e.g., `PXHDUtils`)
29
+
30
+ ## Library Components
31
+
32
+ In using this library, most features will work out-of-the-box. However, there are certain classes you will need to modify
33
+ depending on the specific platform you're developing for.
34
+
35
+ Most development you will need to complete will most likely be in the following areas.
36
+
37
+ ### Enforcer
38
+
39
+ While every enforcer will require a different implementation, the API and sequence of events in an enforcer should be consistent
40
+ across different SDKs. To maintain consistency, the following interface and abstract class have been included.
41
+
42
+ `IEnforcer` - Represents the enforcer itself. The parameters and return values are `any` due to the varying nature of each
43
+ platform. The specific enforcer implementation you create should have a concrete signature.
44
+
45
+ `EnforcerBase` - An abstract base class that provides the basic enforcer flow with the default building blocks. Select abstract
46
+ functions must be implemented (such as constructing the context, etc.). All key functional building blocks are interfaces
47
+ that can be swapped out, and modifications to the flow can be made by overriding the protected class methods.
48
+
49
+ ### Configuration
50
+
51
+ Every enforcer configuration is different. This includes how the configurations are stored (a JSON file, in-memory object,
52
+ or KV namespace), the configuration values themselves, and logging functionality. Utilize these components to simplify
53
+ your enforcer's configuration setup.
54
+
55
+ `IConfiguration` - Represents the enforcer configuration and is required to construct most other components
56
+ in this library.
57
+
58
+ `StaticConfigurationBase` - An implementation of the above interface that validates provided configurations and merges
59
+ them with default ones.
60
+
61
+ `DefaultConfigurations` - A static object complete with all default enforcer configurations.
62
+
63
+ ### Context
64
+
65
+ Different platforms expose varying levels of information about the HTTP request and server environment. Additionally,
66
+ the cryptographic capabilities on each platform may vary, allowing the support of either V2 or V3 of the Risk Cookie.
67
+ While you will need to create a custom implementation for the request context, you can use these tools to help.
68
+
69
+ `IContext` - Represents the request context.
70
+
71
+ `ContextBase` - An implementation of the above interface that takes care of basic context setup.
72
+
73
+ `DefaultTokenV2Context` - An extension of the above abstract class that creates a `DefaultBotDefenderTokenV2`.
74
+
75
+ `DefaultTokenV3Context` - An extension of the above abstract class that creates a `DefaultBotDefenderTokenV3`.
76
+
77
+ ### HTTP
78
+
79
+ Every framework has a different API for creating and sending HTTP requests and responses. This library reduces this functionality
80
+ into three interfaces:
81
+
82
+ `IHttpRequest` - Represents an HTTP request.
83
+
84
+ `IHttpResponse` - Represents an HTTP response.
85
+
86
+ `IHttpClient` - Represents a client that can send an `IHttpRequest` and return an `IHttpResponse`.
87
+
88
+ When developing your JavaScript/TypeScript enforcer with this library, you will need to wrap the native HTTP request/response
89
+ objects such that they conform to these interfaces. Of course, you are free to extend these interfaces as needed.
90
+
91
+ The `HttpRequestBase` and `HttpResponseBase` classes are also provided for minimizing code repetition, simplifying
92
+ encapsulating request and response body handling to a single `IBodyReader` interface.
93
+
94
+ The library also provides the `DefaultHttpRequest` and `DefaultHttpResponse` classes, simple implementations of the
95
+ `IHttpRequest` and `IHttpResponse` interfaces, which are used internally. These implementations use the `StringBodyReader`
96
+ class to parse request and response bodies provided as strings.
97
+
98
+ You will also need to implement an HTTP client. You can do this however you see fit: use the platform's built-in API
99
+ or use an external library (e.g., `phin`, `axios`) if needed.
100
+
101
+ ### Crypto
102
+
103
+ Since cryptographic functionality varies from platform to platform, this library's crypto utils takes the form of an interface
104
+ as well. It comes with a specific default implementation.
105
+
106
+ `IBase64Utils` - Represents a Base64 encoding and decoding utility that other components may require. A `DefaultBase64Utils`
107
+ implementation using the `js-base64` dependency is provided.
108
+
109
+ `IHashUtils` - Represents an HMAC-generating utility that other components may require. A `DefaultHashUtils`
110
+ implementation using the `crypto-js` dependency is provided.
111
+
112
+ `ICipherUtils` - Represents an encryption and decryption utility that is required for RiskTokenV3. No default
113
+ implementation is provided.
114
+
115
+ ### Other Dependencies
116
+
117
+ All dependencies in this library have been encapsulated into specific implementations with a defined interface and therefore
118
+ can be swapped with other implementations. These classes are:
119
+
120
+ | **Library** | **Implementation** | **Used For** |
121
+ | :--- | :--- | :--- |
122
+ | `crypto-js` | `DefaultHashUtils` | PXDE, telemetry, risk token V2/V3, etc. |
123
+ | `js-base64` | `DefaultBase64Utils` | PXDE, telemetry, risk token V2, etc. |
124
+ | `cookie` | `DefaultCookieParser` | `ContextBase` |
125
+ | `uuid` | `DefaultUuidGenerator` | `ContextBase` |
126
+ | `ip-range-check` | `DefaultIpRangeChecker` | `DefaultFilter` |
127
+
128
+ ## For Contributors
129
+
130
+ ### Installing Dependencies
131
+
132
+ To install dependencies, run:
133
+
134
+ ```shell
135
+ npm install
136
+ ```
137
+
138
+ ### Building
139
+
140
+ To build the module as a library, run:
141
+
142
+ ```shell
143
+ npm run build
144
+ ```
145
+
146
+ ### Testing
147
+
148
+ To run unit tests, run:
149
+
150
+ ```shell
151
+ npm run test
152
+ ```
153
+
154
+ To see unit test coverage, run:
155
+
156
+ ```shell
157
+ npm run coverage
158
+ ```
@@ -0,0 +1,6 @@
1
+ export declare enum ActivityType {
2
+ PAGE_REQUESTED = "page_requested",
3
+ BLOCK = "block",
4
+ ADDITIONAL_S2S = "additional_s2s",
5
+ ENFORCER_TELEMETRY = "enforcer_telemetry"
6
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ActivityType = void 0;
4
+ var ActivityType;
5
+ (function (ActivityType) {
6
+ ActivityType["PAGE_REQUESTED"] = "page_requested";
7
+ ActivityType["BLOCK"] = "block";
8
+ ActivityType["ADDITIONAL_S2S"] = "additional_s2s";
9
+ ActivityType["ENFORCER_TELEMETRY"] = "enforcer_telemetry";
10
+ })(ActivityType = exports.ActivityType || (exports.ActivityType = {}));
@@ -0,0 +1,12 @@
1
+ import { IConfiguration } from '../config';
2
+ import { IContext } from '../context';
3
+ import { IHttpClient } from '../http';
4
+ import { IActivityClient } from './IActivityClient';
5
+ export declare class HttpActivityClient implements IActivityClient {
6
+ private readonly config;
7
+ private readonly httpClient;
8
+ constructor(config: IConfiguration, httpClient: IHttpClient);
9
+ sendActivities(context: IContext): Promise<boolean>;
10
+ private createActivities;
11
+ private postActivities;
12
+ }
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.HttpActivityClient = void 0;
40
+ var http_1 = require("../http");
41
+ var utils_1 = require("../utils");
42
+ var ActivityType_1 = require("./ActivityType");
43
+ var utils_2 = require("./utils");
44
+ var constants_1 = require("./constants");
45
+ var HttpActivityClient = /** @class */ (function () {
46
+ function HttpActivityClient(config, httpClient) {
47
+ this.config = config;
48
+ this.httpClient = httpClient;
49
+ }
50
+ HttpActivityClient.prototype.sendActivities = function (context) {
51
+ return __awaiter(this, void 0, void 0, function () {
52
+ var activities, e_1;
53
+ return __generator(this, function (_a) {
54
+ switch (_a.label) {
55
+ case 0:
56
+ _a.trys.push([0, 2, , 3]);
57
+ activities = this.createActivities(context);
58
+ return [4 /*yield*/, this.postActivities(activities)];
59
+ case 1: return [2 /*return*/, _a.sent()];
60
+ case 2:
61
+ e_1 = _a.sent();
62
+ this.config.logger.error("unable to send activities - ".concat(e_1));
63
+ return [2 /*return*/, false];
64
+ case 3: return [2 /*return*/];
65
+ }
66
+ });
67
+ });
68
+ };
69
+ HttpActivityClient.prototype.createActivities = function (context) {
70
+ var activities = [];
71
+ if (context.blockReason) {
72
+ activities.push((0, utils_2.createActivity)(ActivityType_1.ActivityType.BLOCK, this.config, context));
73
+ }
74
+ else if (context.passReason) {
75
+ activities.push((0, utils_2.createActivity)(ActivityType_1.ActivityType.PAGE_REQUESTED, this.config, context));
76
+ }
77
+ return activities;
78
+ };
79
+ HttpActivityClient.prototype.postActivities = function (activities) {
80
+ return __awaiter(this, void 0, void 0, function () {
81
+ var url, method, headers, body, status;
82
+ var _a;
83
+ return __generator(this, function (_b) {
84
+ switch (_b.label) {
85
+ case 0:
86
+ url = "".concat(this.config.backendCollectorUrl).concat(constants_1.ACTIVITIES_ENDPOINT);
87
+ method = http_1.HttpMethod.POST;
88
+ headers = (_a = {},
89
+ _a[http_1.CONTENT_TYPE_HEADER_NAME] = [http_1.ContentType.APPLICATION_JSON],
90
+ _a[http_1.AUTHORIZATION_HEADER_NAME] = [(0, utils_1.getAuthorizationHeader)(this.config.authToken)],
91
+ _a);
92
+ body = activities.length === 1 ? JSON.stringify(activities[0]) : JSON.stringify(activities);
93
+ this.config.logger.debug("sending ".concat(activities.map(function (_a) {
94
+ var type = _a.type;
95
+ return "".concat(type, " activity");
96
+ }).join(', '), " to ").concat(url));
97
+ return [4 /*yield*/, this.httpClient.send(new http_1.DefaultHttpRequest(url, { method: method, headers: headers, body: body }))];
98
+ case 1:
99
+ status = (_b.sent()).status;
100
+ return [2 /*return*/, status === 200];
101
+ }
102
+ });
103
+ });
104
+ };
105
+ return HttpActivityClient;
106
+ }());
107
+ exports.HttpActivityClient = HttpActivityClient;
@@ -0,0 +1,8 @@
1
+ import { IContext } from '../context';
2
+ export interface IActivityClient {
3
+ /**
4
+ * @param context - The request context.
5
+ * @returns Promise<boolean> - Whether sending the activities was successful or not.
6
+ */
7
+ sendActivities(context: IContext): Promise<boolean>;
8
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export declare const ACTIVITIES_ENDPOINT = "/api/v1/collector/s2s";
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ACTIVITIES_ENDPOINT = void 0;
4
+ exports.ACTIVITIES_ENDPOINT = '/api/v1/collector/s2s';
@@ -0,0 +1,5 @@
1
+ export { IActivityClient } from './IActivityClient';
2
+ export { Activity } from './model/Activity';
3
+ export { ActivityTypeDetails, ActivityDetails, BlockActivityDetails, PageRequestedActivityDetails, } from './model/ActivityDetails';
4
+ export { ActivityType } from './ActivityType';
5
+ export { HttpActivityClient } from './HttpActivityClient';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HttpActivityClient = exports.ActivityType = void 0;
4
+ var ActivityType_1 = require("./ActivityType");
5
+ Object.defineProperty(exports, "ActivityType", { enumerable: true, get: function () { return ActivityType_1.ActivityType; } });
6
+ var HttpActivityClient_1 = require("./HttpActivityClient");
7
+ Object.defineProperty(exports, "HttpActivityClient", { enumerable: true, get: function () { return HttpActivityClient_1.HttpActivityClient; } });
@@ -0,0 +1,13 @@
1
+ import { ActivityType } from '../ActivityType';
2
+ import { ActivityDetails } from './ActivityDetails';
3
+ export declare type Activity = {
4
+ type: ActivityType;
5
+ timestamp: number;
6
+ socket_ip: string;
7
+ url: string;
8
+ px_app_id: string;
9
+ headers?: Record<string, string | string[]>;
10
+ vid?: string;
11
+ pxhd?: string;
12
+ details: ActivityDetails;
13
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,41 @@
1
+ import { PassReason } from '../../utils/PassReason';
2
+ import { BlockReason } from '../../block_handler/BlockReason';
3
+ export declare type ActivityTypeDetails = PageRequestedActivityDetails | BlockActivityDetails | AdditionalS2SActivityDetails;
4
+ export declare type ActivityDetails = ActivityTypeDetails & {
5
+ client_uuid: string;
6
+ request_id: string;
7
+ module_version: string;
8
+ cookie_origin: string;
9
+ http_method: string;
10
+ http_version: string;
11
+ risk_rtt?: number;
12
+ request_cookie_names?: string[];
13
+ server_info_region?: string;
14
+ tls_protocol?: string;
15
+ tls_cipher?: string;
16
+ tls_preferred_ciphers?: string;
17
+ tls_ciphers_sha?: string;
18
+ tls_ja3_fingerprint?: string;
19
+ credentials_compromised?: boolean;
20
+ ci_version?: string;
21
+ sso_step?: string;
22
+ };
23
+ export declare type PageRequestedActivityDetails = {
24
+ pass_reason: PassReason;
25
+ http_status_code?: number;
26
+ px_cookie?: string;
27
+ error_message?: string;
28
+ s2s_error_reason?: string;
29
+ s2s_error_http_status?: number;
30
+ };
31
+ export declare type BlockActivityDetails = {
32
+ block_reason: BlockReason;
33
+ block_action: string;
34
+ block_score: string;
35
+ simulated_block: boolean;
36
+ };
37
+ export declare type AdditionalS2SActivityDetails = {
38
+ http_status_code: number;
39
+ login_successful: boolean;
40
+ raw_username?: string;
41
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,10 @@
1
+ import { IContext } from '../context';
2
+ import { IConfiguration } from '../config';
3
+ import { ActivityType } from './ActivityType';
4
+ import { Activity } from './model/Activity';
5
+ import { ActivityDetails, BlockActivityDetails, PageRequestedActivityDetails } from './model/ActivityDetails';
6
+ export declare const createActivity: (activityType: ActivityType, config: IConfiguration, context: IContext) => Activity;
7
+ export declare const createActivityDetails: (activityType: ActivityType, config: IConfiguration, context: IContext) => ActivityDetails;
8
+ export declare const createGenericActivityDetails: (config: IConfiguration, context: IContext) => ActivityDetails;
9
+ export declare const createPageRequestedActivityDetails: (context: IContext) => PageRequestedActivityDetails;
10
+ export declare const createBlockActivityDetails: (context: IContext) => BlockActivityDetails;
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createBlockActivityDetails = exports.createPageRequestedActivityDetails = exports.createGenericActivityDetails = exports.createActivityDetails = exports.createActivity = void 0;
4
+ var utils_1 = require("../utils");
5
+ var ActivityType_1 = require("./ActivityType");
6
+ var createActivity = function (activityType, config, context) {
7
+ return {
8
+ type: activityType,
9
+ px_app_id: config.appId,
10
+ url: context.requestData.url.href,
11
+ headers: (0, utils_1.removeSensitiveHeaders)(context.requestData.headers, config.sensitiveHeaders).toObject(),
12
+ pxhd: context.pxhd,
13
+ socket_ip: context.requestData.ip,
14
+ timestamp: Date.now(),
15
+ vid: context.vid,
16
+ details: (0, exports.createActivityDetails)(activityType, config, context),
17
+ };
18
+ };
19
+ exports.createActivity = createActivity;
20
+ var createActivityDetails = function (activityType, config, context) {
21
+ var genericActivityDetails = (0, exports.createGenericActivityDetails)(config, context);
22
+ var specificActivityDetails = {};
23
+ switch (activityType) {
24
+ case ActivityType_1.ActivityType.PAGE_REQUESTED:
25
+ specificActivityDetails = (0, exports.createPageRequestedActivityDetails)(context);
26
+ break;
27
+ case ActivityType_1.ActivityType.BLOCK:
28
+ specificActivityDetails = (0, exports.createBlockActivityDetails)(context);
29
+ break;
30
+ case ActivityType_1.ActivityType.ADDITIONAL_S2S:
31
+ break;
32
+ }
33
+ return Object.assign(genericActivityDetails, specificActivityDetails);
34
+ };
35
+ exports.createActivityDetails = createActivityDetails;
36
+ var createGenericActivityDetails = function (config, context) {
37
+ var genericActivityDetails = {
38
+ module_version: config.moduleVersion,
39
+ };
40
+ if (context.customParameters) {
41
+ Object.assign(genericActivityDetails, context.customParameters);
42
+ }
43
+ (0, utils_1.transferExistingProperties)(context, genericActivityDetails, {
44
+ requestId: 'request_id',
45
+ uuid: 'client_uuid',
46
+ tokenOrigin: 'cookie_origin',
47
+ });
48
+ (0, utils_1.transferExistingProperties)(context.requestData, genericActivityDetails, {
49
+ httpVersion: 'http_version',
50
+ method: 'http_method',
51
+ requestCookieNames: 'request_cookie_names',
52
+ });
53
+ (0, utils_1.transferExistingProperties)(context.riskApiData, genericActivityDetails, {
54
+ riskRtt: 'risk_rtt',
55
+ });
56
+ (0, utils_1.transferExistingProperties)(context.serverData, genericActivityDetails, {
57
+ region: 'server_info_region',
58
+ });
59
+ return genericActivityDetails;
60
+ };
61
+ exports.createGenericActivityDetails = createGenericActivityDetails;
62
+ var createPageRequestedActivityDetails = function (context) {
63
+ var details = {};
64
+ (0, utils_1.transferExistingProperties)(context, details, {
65
+ passReason: 'pass_reason',
66
+ });
67
+ (0, utils_1.transferExistingProperties)(context.riskApiData, details, {
68
+ s2sErrorReason: 's2s_error_reason',
69
+ s2sErrorHttpStatus: 's2s_error_http_status',
70
+ errorMessage: 'error_message',
71
+ });
72
+ (0, utils_1.transferExistingProperties)(context.responseData, details, {
73
+ status: 'http_status_code',
74
+ });
75
+ return details;
76
+ };
77
+ exports.createPageRequestedActivityDetails = createPageRequestedActivityDetails;
78
+ var createBlockActivityDetails = function (context) {
79
+ var details = {};
80
+ (0, utils_1.transferExistingProperties)(context, details, {
81
+ blockReason: 'block_reason',
82
+ blockAction: 'block_action',
83
+ score: 'block_score',
84
+ isMonitoredRequest: 'simulated_block',
85
+ });
86
+ return details;
87
+ };
88
+ exports.createBlockActivityDetails = createBlockActivityDetails;
@@ -0,0 +1,3 @@
1
+ import { ConfigurationParams } from '../config';
2
+ import { IContext } from '../context';
3
+ export declare type AdditionalActivityHandler = (config: ConfigurationParams, context: IContext) => void | Promise<void>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,5 @@
1
+ import { IContext } from '../context';
2
+ import { IConfiguration } from '../config';
3
+ export declare namespace AdditionalActivityHandlerUtils {
4
+ const invokeAdditionalActivityHandler: (config: IConfiguration, context: IContext) => Promise<void>;
5
+ }
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.AdditionalActivityHandlerUtils = void 0;
40
+ var AdditionalActivityHandlerUtils;
41
+ (function (AdditionalActivityHandlerUtils) {
42
+ var _this = this;
43
+ AdditionalActivityHandlerUtils.invokeAdditionalActivityHandler = function (config, context) { return __awaiter(_this, void 0, void 0, function () {
44
+ var e_1;
45
+ return __generator(this, function (_a) {
46
+ switch (_a.label) {
47
+ case 0:
48
+ if (!(config.additionalActivityHandler && typeof config.additionalActivityHandler === 'function')) return [3 /*break*/, 4];
49
+ _a.label = 1;
50
+ case 1:
51
+ _a.trys.push([1, 3, , 4]);
52
+ return [4 /*yield*/, config.additionalActivityHandler(config.toParams(), context)];
53
+ case 2:
54
+ _a.sent();
55
+ return [3 /*break*/, 4];
56
+ case 3:
57
+ e_1 = _a.sent();
58
+ config.logger.error("caught additional activity handler error - ".concat(e_1));
59
+ return [3 /*break*/, 4];
60
+ case 4: return [2 /*return*/];
61
+ }
62
+ });
63
+ }); };
64
+ })(AdditionalActivityHandlerUtils = exports.AdditionalActivityHandlerUtils || (exports.AdditionalActivityHandlerUtils = {}));
@@ -0,0 +1,2 @@
1
+ export { AdditionalActivityHandler } from './AdditionalActivityHandler';
2
+ export { AdditionalActivityHandlerUtils } from './AdditionalActivityHandlerUtils';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AdditionalActivityHandlerUtils = void 0;
4
+ var AdditionalActivityHandlerUtils_1 = require("./AdditionalActivityHandlerUtils");
5
+ Object.defineProperty(exports, "AdditionalActivityHandlerUtils", { enumerable: true, get: function () { return AdditionalActivityHandlerUtils_1.AdditionalActivityHandlerUtils; } });
@@ -0,0 +1,6 @@
1
+ export declare enum BlockAction {
2
+ CAPTCHA = "c",
3
+ RATE_LIMIT = "r",
4
+ CHALLENGE = "j"
5
+ }
6
+ export declare const blockActionToWord: (blockAction: BlockAction) => string;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.blockActionToWord = exports.BlockAction = void 0;
4
+ var BlockAction;
5
+ (function (BlockAction) {
6
+ BlockAction["CAPTCHA"] = "c";
7
+ BlockAction["RATE_LIMIT"] = "r";
8
+ BlockAction["CHALLENGE"] = "j";
9
+ })(BlockAction = exports.BlockAction || (exports.BlockAction = {}));
10
+ var blockActionToWord = function (blockAction) {
11
+ switch (blockAction) {
12
+ case BlockAction.RATE_LIMIT:
13
+ return 'ratelimit';
14
+ case BlockAction.CHALLENGE:
15
+ return 'challenge';
16
+ case BlockAction.CAPTCHA:
17
+ default:
18
+ return 'captcha';
19
+ }
20
+ };
21
+ exports.blockActionToWord = blockActionToWord;
@@ -0,0 +1,4 @@
1
+ export declare enum BlockReason {
2
+ S2S_HIGH_SCORE = "s2s_high_score",
3
+ COOKIE_HIGH_SCORE = "cookie_high_score"
4
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BlockReason = void 0;
4
+ var BlockReason;
5
+ (function (BlockReason) {
6
+ BlockReason["S2S_HIGH_SCORE"] = "s2s_high_score";
7
+ BlockReason["COOKIE_HIGH_SCORE"] = "cookie_high_score";
8
+ })(BlockReason = exports.BlockReason || (exports.BlockReason = {}));