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
@@ -0,0 +1,4 @@
1
+ export declare enum VidSource {
2
+ VID_COOKIE = "vid_cookie",
3
+ RISK_COOKIE = "risk_cookie"
4
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VidSource = void 0;
4
+ var VidSource;
5
+ (function (VidSource) {
6
+ VidSource["VID_COOKIE"] = "vid_cookie";
7
+ VidSource["RISK_COOKIE"] = "risk_cookie";
8
+ })(VidSource = exports.VidSource || (exports.VidSource = {}));
@@ -0,0 +1,5 @@
1
+ import { IBase64Utils } from './IBase64Utils';
2
+ export declare class DefaultBase64Utils implements IBase64Utils {
3
+ base64Encode(stringToEncode: string): string;
4
+ base64Decode(stringToDecode: string): string;
5
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DefaultBase64Utils = void 0;
4
+ var js_base64_1 = require("js-base64");
5
+ var DefaultBase64Utils = /** @class */ (function () {
6
+ function DefaultBase64Utils() {
7
+ }
8
+ DefaultBase64Utils.prototype.base64Encode = function (stringToEncode) {
9
+ return (0, js_base64_1.encode)(stringToEncode);
10
+ };
11
+ DefaultBase64Utils.prototype.base64Decode = function (stringToDecode) {
12
+ return (0, js_base64_1.decode)(stringToDecode);
13
+ };
14
+ return DefaultBase64Utils;
15
+ }());
16
+ exports.DefaultBase64Utils = DefaultBase64Utils;
@@ -0,0 +1,4 @@
1
+ export interface IBase64Utils {
2
+ base64Encode(stringToEncode: string): string;
3
+ base64Decode(stringToDecode: string): string;
4
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export { IBase64Utils } from './IBase64Utils';
2
+ export { DefaultBase64Utils } from './DefaultBase64Utils';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DefaultBase64Utils = void 0;
4
+ var DefaultBase64Utils_1 = require("./DefaultBase64Utils");
5
+ Object.defineProperty(exports, "DefaultBase64Utils", { enumerable: true, get: function () { return DefaultBase64Utils_1.DefaultBase64Utils; } });
@@ -0,0 +1,7 @@
1
+ export declare type Pbkdf2DecryptOptions = {
2
+ keylen?: number;
3
+ ivlen?: number;
4
+ };
5
+ export interface ICipherUtils {
6
+ pbkdf2Decrypt(secret: string, encryptedString: string, iterations: number, salt: string, options?: Pbkdf2DecryptOptions): string | Promise<string>;
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export { ICipherUtils, Pbkdf2DecryptOptions } from './ICipherUtils';
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,10 @@
1
+ export declare const PXVID_COOKIE_NAME = "_pxvid";
2
+ export declare const PXHD_COOKIE_NAME = "_pxhd";
3
+ export declare const PXDE_COOKIE_NAME = "_pxde";
4
+ export declare const CD_PXVID_COOKIE_NAME = "__pxvid";
5
+ export declare const CTS_COOKIE_NAME = "pxcts";
6
+ export declare const BYPASS_MONITOR_HEADER_VALUE = "1";
7
+ export declare const X_PX_AUTHORIZATION_HEADER_NAME = "x-px-authorization";
8
+ export declare const X_PX_ORIGINAL_TOKEN_HEADER_NAME = "x-px-original-token";
9
+ export declare const X_PX_BYPASS_REASON_HEADER_NAME = "x-px-bypass-reason";
10
+ export declare const CORE_MODULE_VERSION = "JS Core 0.1.0";
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CORE_MODULE_VERSION = exports.X_PX_BYPASS_REASON_HEADER_NAME = exports.X_PX_ORIGINAL_TOKEN_HEADER_NAME = exports.X_PX_AUTHORIZATION_HEADER_NAME = exports.BYPASS_MONITOR_HEADER_VALUE = exports.CTS_COOKIE_NAME = exports.CD_PXVID_COOKIE_NAME = exports.PXDE_COOKIE_NAME = exports.PXHD_COOKIE_NAME = exports.PXVID_COOKIE_NAME = void 0;
4
+ exports.PXVID_COOKIE_NAME = '_pxvid';
5
+ exports.PXHD_COOKIE_NAME = '_pxhd';
6
+ exports.PXDE_COOKIE_NAME = '_pxde';
7
+ exports.CD_PXVID_COOKIE_NAME = '__pxvid';
8
+ exports.CTS_COOKIE_NAME = 'pxcts';
9
+ exports.BYPASS_MONITOR_HEADER_VALUE = '1';
10
+ exports.X_PX_AUTHORIZATION_HEADER_NAME = 'x-px-authorization';
11
+ exports.X_PX_ORIGINAL_TOKEN_HEADER_NAME = 'x-px-original-token';
12
+ exports.X_PX_BYPASS_REASON_HEADER_NAME = 'x-px-bypass-reason';
13
+ exports.CORE_MODULE_VERSION = 'JS Core 0.1.0';
@@ -0,0 +1,4 @@
1
+ import { ICookieParser } from './ICookieParser';
2
+ export declare class DefaultCookieParser implements ICookieParser {
3
+ parseCookies(cookieHeaderValue: string): Record<string, string>;
4
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DefaultCookieParser = void 0;
4
+ var cookie = require("cookie");
5
+ var DefaultCookieParser = /** @class */ (function () {
6
+ function DefaultCookieParser() {
7
+ }
8
+ DefaultCookieParser.prototype.parseCookies = function (cookieHeaderValue) {
9
+ return cookie.parse(cookieHeaderValue);
10
+ };
11
+ return DefaultCookieParser;
12
+ }());
13
+ exports.DefaultCookieParser = DefaultCookieParser;
@@ -0,0 +1,3 @@
1
+ export interface ICookieParser {
2
+ parseCookies(cookieHeaderValue: string): Record<string, string>;
3
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export { ICookieParser } from './ICookieParser';
2
+ export { DefaultCookieParser } from './DefaultCookieParser';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DefaultCookieParser = void 0;
4
+ var DefaultCookieParser_1 = require("./DefaultCookieParser");
5
+ Object.defineProperty(exports, "DefaultCookieParser", { enumerable: true, get: function () { return DefaultCookieParser_1.DefaultCookieParser; } });
@@ -0,0 +1,5 @@
1
+ import { IHashUtils } from './IHashUtils';
2
+ import { Algorithm } from '../Algorithm';
3
+ export declare class DefaultHashUtils implements IHashUtils {
4
+ createHmac(algo: Algorithm, payload: string, secret: string): string;
5
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DefaultHashUtils = void 0;
4
+ var crypto_js_1 = require("crypto-js");
5
+ var Algorithm_1 = require("../Algorithm");
6
+ var DefaultHashUtils = /** @class */ (function () {
7
+ function DefaultHashUtils() {
8
+ }
9
+ DefaultHashUtils.prototype.createHmac = function (algo, payload, secret) {
10
+ switch (algo) {
11
+ case Algorithm_1.Algorithm.SHA256:
12
+ default:
13
+ var payloadHmac = (0, crypto_js_1.HmacSHA256)(payload, secret);
14
+ return crypto_js_1.enc.Hex.stringify(payloadHmac);
15
+ }
16
+ };
17
+ return DefaultHashUtils;
18
+ }());
19
+ exports.DefaultHashUtils = DefaultHashUtils;
@@ -0,0 +1,4 @@
1
+ import { Algorithm } from '../Algorithm';
2
+ export interface IHashUtils {
3
+ createHmac(algo: Algorithm, payload: string, secret: string): string;
4
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export { IHashUtils } from './IHashUtils';
2
+ export { DefaultHashUtils } from './DefaultHashUtils';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DefaultHashUtils = void 0;
4
+ var DefaultHashUtils_1 = require("./DefaultHashUtils");
5
+ Object.defineProperty(exports, "DefaultHashUtils", { enumerable: true, get: function () { return DefaultHashUtils_1.DefaultHashUtils; } });
@@ -0,0 +1,14 @@
1
+ export * from './base64';
2
+ export * from './cookie_parser';
3
+ export * from './hash';
4
+ export * from './ip_range_checker';
5
+ export * from './uuid_generator';
6
+ export * from './cipher';
7
+ export * from './utils';
8
+ export * from './constants';
9
+ export { ModuleMode } from './ModuleMode';
10
+ export { VidSource } from './VidSource';
11
+ export { PassReason } from './PassReason';
12
+ export { Algorithm } from './Algorithm';
13
+ export { EnforcerException } from './EnforcerException';
14
+ export { IScoreRetriever } from './IScoreRetriever';
@@ -0,0 +1,35 @@
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
+ exports.EnforcerException = exports.Algorithm = exports.PassReason = exports.VidSource = exports.ModuleMode = void 0;
18
+ __exportStar(require("./base64"), exports);
19
+ __exportStar(require("./cookie_parser"), exports);
20
+ __exportStar(require("./hash"), exports);
21
+ __exportStar(require("./ip_range_checker"), exports);
22
+ __exportStar(require("./uuid_generator"), exports);
23
+ __exportStar(require("./cipher"), exports);
24
+ __exportStar(require("./utils"), exports);
25
+ __exportStar(require("./constants"), exports);
26
+ var ModuleMode_1 = require("./ModuleMode");
27
+ Object.defineProperty(exports, "ModuleMode", { enumerable: true, get: function () { return ModuleMode_1.ModuleMode; } });
28
+ var VidSource_1 = require("./VidSource");
29
+ Object.defineProperty(exports, "VidSource", { enumerable: true, get: function () { return VidSource_1.VidSource; } });
30
+ var PassReason_1 = require("./PassReason");
31
+ Object.defineProperty(exports, "PassReason", { enumerable: true, get: function () { return PassReason_1.PassReason; } });
32
+ var Algorithm_1 = require("./Algorithm");
33
+ Object.defineProperty(exports, "Algorithm", { enumerable: true, get: function () { return Algorithm_1.Algorithm; } });
34
+ var EnforcerException_1 = require("./EnforcerException");
35
+ Object.defineProperty(exports, "EnforcerException", { enumerable: true, get: function () { return EnforcerException_1.EnforcerException; } });
@@ -0,0 +1,4 @@
1
+ import { IIpRangeChecker } from './IIpRangeChecker';
2
+ export declare class DefaultIpRangeChecker implements IIpRangeChecker {
3
+ isIpInRange(ip: string, range: string | string[]): boolean;
4
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DefaultIpRangeChecker = void 0;
4
+ var ipRangeCheck = require("ip-range-check");
5
+ var DefaultIpRangeChecker = /** @class */ (function () {
6
+ function DefaultIpRangeChecker() {
7
+ }
8
+ DefaultIpRangeChecker.prototype.isIpInRange = function (ip, range) {
9
+ return ipRangeCheck(ip, range);
10
+ };
11
+ return DefaultIpRangeChecker;
12
+ }());
13
+ exports.DefaultIpRangeChecker = DefaultIpRangeChecker;
@@ -0,0 +1,3 @@
1
+ export interface IIpRangeChecker {
2
+ isIpInRange(ip: string, range: string | string[]): boolean;
3
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export { IIpRangeChecker } from './IIpRangeChecker';
2
+ export { DefaultIpRangeChecker } from './DefaultIpRangeChecker';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DefaultIpRangeChecker = void 0;
4
+ var DefaultIpRangeChecker_1 = require("./DefaultIpRangeChecker");
5
+ Object.defineProperty(exports, "DefaultIpRangeChecker", { enumerable: true, get: function () { return DefaultIpRangeChecker_1.DefaultIpRangeChecker; } });
@@ -0,0 +1,13 @@
1
+ import { HttpHeaders } from '../http';
2
+ export declare const isValidEnumValue: <T>(options: Record<string, T>, selection: T) => boolean;
3
+ export declare const isValidUuid: (uuid: string) => boolean;
4
+ export declare const getScoreApiDomain: (appId: string) => string;
5
+ export declare const getCollectorDomain: (appId: string) => string;
6
+ export declare const getAuthorizationHeader: (authToken: string) => string;
7
+ export declare const getExtension: (route: string) => string;
8
+ export declare const getDecodedUrl: (rawUrl: string) => URL;
9
+ export declare const removeSensitiveFields: <T extends Record<string, any>>(object: T, sensitiveFields: (keyof T)[]) => T;
10
+ export declare const removeSensitiveHeaders: (headers: HttpHeaders, sensitiveHeaderNames: string[]) => HttpHeaders;
11
+ export declare const isRouteInPatterns: (route: string, patterns: Array<string | RegExp>) => boolean;
12
+ export declare const isRouteMatch: (route: string, pattern: string | RegExp) => boolean;
13
+ export declare const transferExistingProperties: <FromObj extends Record<string, any>, ToObj extends Record<string, any>>(fromObj: FromObj, toObj: ToObj, propertyMappings: Partial<Record<keyof FromObj, keyof ToObj>>) => void;
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transferExistingProperties = exports.isRouteMatch = exports.isRouteInPatterns = exports.removeSensitiveHeaders = exports.removeSensitiveFields = exports.getDecodedUrl = exports.getExtension = exports.getAuthorizationHeader = exports.getCollectorDomain = exports.getScoreApiDomain = exports.isValidUuid = exports.isValidEnumValue = void 0;
4
+ var isValidEnumValue = function (options, selection) {
5
+ return Object.values(options).includes(selection);
6
+ };
7
+ exports.isValidEnumValue = isValidEnumValue;
8
+ var isValidUuid = function (uuid) {
9
+ if (!uuid) {
10
+ return false;
11
+ }
12
+ var uuidValidator = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
13
+ return uuidValidator.test(uuid);
14
+ };
15
+ exports.isValidUuid = isValidUuid;
16
+ var getScoreApiDomain = function (appId) { return "sapi-".concat(appId.toLowerCase(), ".perimeterx.net"); };
17
+ exports.getScoreApiDomain = getScoreApiDomain;
18
+ var getCollectorDomain = function (appId) { return "collector-".concat(appId.toLowerCase(), ".perimeterx.net"); };
19
+ exports.getCollectorDomain = getCollectorDomain;
20
+ var getAuthorizationHeader = function (authToken) { return "Bearer ".concat(authToken); };
21
+ exports.getAuthorizationHeader = getAuthorizationHeader;
22
+ var getExtension = function (route) {
23
+ var EXTENSION_INDICATOR = '.';
24
+ if (route.indexOf(EXTENSION_INDICATOR) === -1) {
25
+ return '';
26
+ }
27
+ var cleanPath = route.split('?')[0].split('#')[0];
28
+ var endOfPath = cleanPath.substring(cleanPath.lastIndexOf('/') + 1);
29
+ var extensionIndex = endOfPath.lastIndexOf(EXTENSION_INDICATOR);
30
+ if (extensionIndex === -1 || extensionIndex + 1 === endOfPath.length) {
31
+ return '';
32
+ }
33
+ return endOfPath.substring(extensionIndex);
34
+ };
35
+ exports.getExtension = getExtension;
36
+ var getDecodedUrl = function (rawUrl) {
37
+ rawUrl = rawUrl.replace(/%/g, '%25');
38
+ try {
39
+ return new URL(decodeURIComponent(rawUrl));
40
+ }
41
+ catch (e) {
42
+ return new URL(rawUrl);
43
+ }
44
+ };
45
+ exports.getDecodedUrl = getDecodedUrl;
46
+ var removeSensitiveFields = function (object, sensitiveFields) {
47
+ var newObj = Object.assign({}, object);
48
+ sensitiveFields.forEach(function (fieldName) {
49
+ delete newObj[fieldName];
50
+ });
51
+ return newObj;
52
+ };
53
+ exports.removeSensitiveFields = removeSensitiveFields;
54
+ var removeSensitiveHeaders = function (headers, sensitiveHeaderNames) {
55
+ var headersCopy = headers.copy();
56
+ sensitiveHeaderNames.forEach(function (name) {
57
+ headersCopy.delete(name);
58
+ });
59
+ return headersCopy;
60
+ };
61
+ exports.removeSensitiveHeaders = removeSensitiveHeaders;
62
+ var isRouteInPatterns = function (route, patterns) {
63
+ return patterns.some(function (pattern) { return (0, exports.isRouteMatch)(route, pattern); });
64
+ };
65
+ exports.isRouteInPatterns = isRouteInPatterns;
66
+ var isRouteMatch = function (route, pattern) {
67
+ if (!route || !pattern) {
68
+ return false;
69
+ }
70
+ if (pattern instanceof RegExp && route.match(pattern)) {
71
+ return true;
72
+ }
73
+ if (typeof pattern === 'string' && route.startsWith(pattern)) {
74
+ return true;
75
+ }
76
+ return false;
77
+ };
78
+ exports.isRouteMatch = isRouteMatch;
79
+ var transferExistingProperties = function (fromObj, toObj, propertyMappings) {
80
+ if (!toObj || !fromObj) {
81
+ return;
82
+ }
83
+ Object.entries(propertyMappings).forEach(function (_a) {
84
+ var fromObjKey = _a[0], toObjKey = _a[1];
85
+ if ((typeof fromObj[fromObjKey] !== 'string' && fromObj[fromObjKey] != null) ||
86
+ (typeof fromObj[fromObjKey] === 'string' && fromObj[fromObjKey] !== '')) {
87
+ toObj[toObjKey] = fromObj[fromObjKey];
88
+ }
89
+ });
90
+ };
91
+ exports.transferExistingProperties = transferExistingProperties;
@@ -0,0 +1,4 @@
1
+ import { IUuidGenerator } from './IUuidGenerator';
2
+ export declare class DefaultUuidGenerator implements IUuidGenerator {
3
+ generateUuidV4(): string;
4
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DefaultUuidGenerator = void 0;
4
+ var uuid_1 = require("uuid");
5
+ var DefaultUuidGenerator = /** @class */ (function () {
6
+ function DefaultUuidGenerator() {
7
+ }
8
+ DefaultUuidGenerator.prototype.generateUuidV4 = function () {
9
+ return (0, uuid_1.v4)();
10
+ };
11
+ return DefaultUuidGenerator;
12
+ }());
13
+ exports.DefaultUuidGenerator = DefaultUuidGenerator;
@@ -0,0 +1,3 @@
1
+ export interface IUuidGenerator {
2
+ generateUuidV4(): string;
3
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export { IUuidGenerator } from './IUuidGenerator';
2
+ export { DefaultUuidGenerator } from './DefaultUuidGenerator';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DefaultUuidGenerator = void 0;
4
+ var DefaultUuidGenerator_1 = require("./DefaultUuidGenerator");
5
+ Object.defineProperty(exports, "DefaultUuidGenerator", { enumerable: true, get: function () { return DefaultUuidGenerator_1.DefaultUuidGenerator; } });
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "perimeterx-js-core",
3
+ "version": "0.1.0",
4
+ "description": "",
5
+ "main": "lib/index.js",
6
+ "types": "lib/index.d.ts",
7
+ "files": [
8
+ "lib/**/*"
9
+ ],
10
+ "scripts": {
11
+ "build": "tsc",
12
+ "clean": "rm -rf lib",
13
+ "lint": "./node_modules/eslint/bin/eslint.js . --ext .ts",
14
+ "lint:fix": "./node_modules/eslint/bin/eslint.js . --ext .ts --fix",
15
+ "test": "mocha",
16
+ "coverage": "nyc npm run test"
17
+ },
18
+ "dependencies": {
19
+ "cookie": "^0.5.0",
20
+ "crypto-js": "^4.1.1",
21
+ "ip-range-check": "^0.2.0",
22
+ "js-base64": "^3.7.2",
23
+ "uuid": "^9.0.0"
24
+ },
25
+ "devDependencies": {
26
+ "@types/chai": "^4.3.3",
27
+ "@types/chai-as-promised": "^7.1.5",
28
+ "@types/cookie": "^0.5.1",
29
+ "@types/crypto-js": "^4.1.1",
30
+ "@types/mocha": "^10.0.0",
31
+ "@types/sinon": "^10.0.13",
32
+ "@types/uuid": "^8.3.4",
33
+ "@typescript-eslint/eslint-plugin": "^5.40.0",
34
+ "@typescript-eslint/parser": "^5.40.0",
35
+ "chai": "^4.3.6",
36
+ "chai-as-promised": "^7.1.1",
37
+ "core-js": "^3.19.1",
38
+ "eslint": "^8.25.0",
39
+ "eslint-config-prettier": "^8.5.0",
40
+ "eslint-plugin-no-loops": "^0.3.0",
41
+ "eslint-plugin-prettier": "^4.2.1",
42
+ "mocha": "^10.0.0",
43
+ "nyc": "^15.1.0",
44
+ "prettier": "^2.7.1",
45
+ "sinon": "^14.0.1",
46
+ "ts-loader": "^9.4.1",
47
+ "ts-node": "^10.9.1",
48
+ "typescript": "^4.4.4"
49
+ },
50
+ "author": "",
51
+ "license": "ISC"
52
+ }