@castleio/sdk 2.3.1 → 3.0.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 (382) hide show
  1. package/README.md +352 -31
  2. package/dist/index.d.mts +966 -0
  3. package/dist/index.d.ts +966 -8
  4. package/dist/index.js +1562 -25
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +1499 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/package.json +43 -38
  9. package/CHANGELOG.md +0 -194
  10. package/dist/package.json +0 -77
  11. package/dist/src/Castle.d.ts +0 -36
  12. package/dist/src/Castle.js +0 -194
  13. package/dist/src/Castle.js.map +0 -1
  14. package/dist/src/api/api.module.d.ts +0 -1
  15. package/dist/src/api/api.module.js +0 -18
  16. package/dist/src/api/api.module.js.map +0 -1
  17. package/dist/src/api/services/api-approve-device.service.d.ts +0 -5
  18. package/dist/src/api/services/api-approve-device.service.js +0 -26
  19. package/dist/src/api/services/api-approve-device.service.js.map +0 -1
  20. package/dist/src/api/services/api-archive-list-item.service.d.ts +0 -5
  21. package/dist/src/api/services/api-archive-list-item.service.js +0 -26
  22. package/dist/src/api/services/api-archive-list-item.service.js.map +0 -1
  23. package/dist/src/api/services/api-authenticate.service.d.ts +0 -6
  24. package/dist/src/api/services/api-authenticate.service.js +0 -58
  25. package/dist/src/api/services/api-authenticate.service.js.map +0 -1
  26. package/dist/src/api/services/api-batch-upsert-list-items.service.d.ts +0 -5
  27. package/dist/src/api/services/api-batch-upsert-list-items.service.js +0 -26
  28. package/dist/src/api/services/api-batch-upsert-list-items.service.js.map +0 -1
  29. package/dist/src/api/services/api-count-list-items.service.d.ts +0 -5
  30. package/dist/src/api/services/api-count-list-items.service.js +0 -26
  31. package/dist/src/api/services/api-count-list-items.service.js.map +0 -1
  32. package/dist/src/api/services/api-create-list-item.service.d.ts +0 -5
  33. package/dist/src/api/services/api-create-list-item.service.js +0 -26
  34. package/dist/src/api/services/api-create-list-item.service.js.map +0 -1
  35. package/dist/src/api/services/api-create-list.service.d.ts +0 -5
  36. package/dist/src/api/services/api-create-list.service.js +0 -26
  37. package/dist/src/api/services/api-create-list.service.js.map +0 -1
  38. package/dist/src/api/services/api-delete-list.service.d.ts +0 -5
  39. package/dist/src/api/services/api-delete-list.service.js +0 -26
  40. package/dist/src/api/services/api-delete-list.service.js.map +0 -1
  41. package/dist/src/api/services/api-delete-user-data.service.d.ts +0 -5
  42. package/dist/src/api/services/api-delete-user-data.service.js +0 -26
  43. package/dist/src/api/services/api-delete-user-data.service.js.map +0 -1
  44. package/dist/src/api/services/api-fetch-all-lists.service.d.ts +0 -4
  45. package/dist/src/api/services/api-fetch-all-lists.service.js +0 -26
  46. package/dist/src/api/services/api-fetch-all-lists.service.js.map +0 -1
  47. package/dist/src/api/services/api-fetch-list-item.service.d.ts +0 -5
  48. package/dist/src/api/services/api-fetch-list-item.service.js +0 -26
  49. package/dist/src/api/services/api-fetch-list-item.service.js.map +0 -1
  50. package/dist/src/api/services/api-fetch-list.service.d.ts +0 -5
  51. package/dist/src/api/services/api-fetch-list.service.js +0 -26
  52. package/dist/src/api/services/api-fetch-list.service.js.map +0 -1
  53. package/dist/src/api/services/api-filter.service.d.ts +0 -5
  54. package/dist/src/api/services/api-filter.service.js +0 -57
  55. package/dist/src/api/services/api-filter.service.js.map +0 -1
  56. package/dist/src/api/services/api-get-device.service.d.ts +0 -5
  57. package/dist/src/api/services/api-get-device.service.js +0 -26
  58. package/dist/src/api/services/api-get-device.service.js.map +0 -1
  59. package/dist/src/api/services/api-get-devices-for-user.service.d.ts +0 -5
  60. package/dist/src/api/services/api-get-devices-for-user.service.js +0 -26
  61. package/dist/src/api/services/api-get-devices-for-user.service.js.map +0 -1
  62. package/dist/src/api/services/api-get-events-schema.service.d.ts +0 -5
  63. package/dist/src/api/services/api-get-events-schema.service.js +0 -26
  64. package/dist/src/api/services/api-get-events-schema.service.js.map +0 -1
  65. package/dist/src/api/services/api-group-events.service.d.ts +0 -5
  66. package/dist/src/api/services/api-group-events.service.js +0 -26
  67. package/dist/src/api/services/api-group-events.service.js.map +0 -1
  68. package/dist/src/api/services/api-log.service.d.ts +0 -5
  69. package/dist/src/api/services/api-log.service.js +0 -26
  70. package/dist/src/api/services/api-log.service.js.map +0 -1
  71. package/dist/src/api/services/api-report-device.service.d.ts +0 -5
  72. package/dist/src/api/services/api-report-device.service.js +0 -26
  73. package/dist/src/api/services/api-report-device.service.js.map +0 -1
  74. package/dist/src/api/services/api-request-user-data.service.d.ts +0 -5
  75. package/dist/src/api/services/api-request-user-data.service.js +0 -26
  76. package/dist/src/api/services/api-request-user-data.service.js.map +0 -1
  77. package/dist/src/api/services/api-risk.service.d.ts +0 -5
  78. package/dist/src/api/services/api-risk.service.js +0 -57
  79. package/dist/src/api/services/api-risk.service.js.map +0 -1
  80. package/dist/src/api/services/api-search-events.service.d.ts +0 -5
  81. package/dist/src/api/services/api-search-events.service.js +0 -26
  82. package/dist/src/api/services/api-search-events.service.js.map +0 -1
  83. package/dist/src/api/services/api-search-list-items.service.d.ts +0 -5
  84. package/dist/src/api/services/api-search-list-items.service.js +0 -26
  85. package/dist/src/api/services/api-search-list-items.service.js.map +0 -1
  86. package/dist/src/api/services/api-search-lists.service.d.ts +0 -5
  87. package/dist/src/api/services/api-search-lists.service.js +0 -26
  88. package/dist/src/api/services/api-search-lists.service.js.map +0 -1
  89. package/dist/src/api/services/api-track.service.d.ts +0 -5
  90. package/dist/src/api/services/api-track.service.js +0 -26
  91. package/dist/src/api/services/api-track.service.js.map +0 -1
  92. package/dist/src/api/services/api-unarchive-list-item.service.d.ts +0 -5
  93. package/dist/src/api/services/api-unarchive-list-item.service.js +0 -26
  94. package/dist/src/api/services/api-unarchive-list-item.service.js.map +0 -1
  95. package/dist/src/api/services/api-update-list-item.service.d.ts +0 -5
  96. package/dist/src/api/services/api-update-list-item.service.js +0 -26
  97. package/dist/src/api/services/api-update-list-item.service.js.map +0 -1
  98. package/dist/src/api/services/api-update-list.service.d.ts +0 -5
  99. package/dist/src/api/services/api-update-list.service.js +0 -26
  100. package/dist/src/api/services/api-update-list.service.js.map +0 -1
  101. package/dist/src/api/services/api.service.d.ts +0 -8
  102. package/dist/src/api/services/api.service.js +0 -40
  103. package/dist/src/api/services/api.service.js.map +0 -1
  104. package/dist/src/api/services/index.d.ts +0 -29
  105. package/dist/src/api/services/index.js +0 -46
  106. package/dist/src/api/services/index.js.map +0 -1
  107. package/dist/src/client-id/client-id.module.d.ts +0 -1
  108. package/dist/src/client-id/client-id.module.js +0 -18
  109. package/dist/src/client-id/client-id.module.js.map +0 -1
  110. package/dist/src/client-id/services/client-id-extract.service.d.ts +0 -4
  111. package/dist/src/client-id/services/client-id-extract.service.js +0 -12
  112. package/dist/src/client-id/services/client-id-extract.service.js.map +0 -1
  113. package/dist/src/client-id/services/index.d.ts +0 -1
  114. package/dist/src/client-id/services/index.js +0 -18
  115. package/dist/src/client-id/services/index.js.map +0 -1
  116. package/dist/src/command/command.module.d.ts +0 -1
  117. package/dist/src/command/command.module.js +0 -18
  118. package/dist/src/command/command.module.js.map +0 -1
  119. package/dist/src/command/services/command-approve-device.service.d.ts +0 -16
  120. package/dist/src/command/services/command-approve-device.service.js +0 -12
  121. package/dist/src/command/services/command-approve-device.service.js.map +0 -1
  122. package/dist/src/command/services/command-archive-list-item.service.d.ts +0 -16
  123. package/dist/src/command/services/command-archive-list-item.service.js +0 -12
  124. package/dist/src/command/services/command-archive-list-item.service.js.map +0 -1
  125. package/dist/src/command/services/command-authenticate.service.d.ts +0 -16
  126. package/dist/src/command/services/command-authenticate.service.js +0 -12
  127. package/dist/src/command/services/command-authenticate.service.js.map +0 -1
  128. package/dist/src/command/services/command-batch-upsert-list-items.service.d.ts +0 -16
  129. package/dist/src/command/services/command-batch-upsert-list-items.service.js +0 -12
  130. package/dist/src/command/services/command-batch-upsert-list-items.service.js.map +0 -1
  131. package/dist/src/command/services/command-count-list-items.service.d.ts +0 -16
  132. package/dist/src/command/services/command-count-list-items.service.js +0 -12
  133. package/dist/src/command/services/command-count-list-items.service.js.map +0 -1
  134. package/dist/src/command/services/command-create-list-item.service.d.ts +0 -16
  135. package/dist/src/command/services/command-create-list-item.service.js +0 -12
  136. package/dist/src/command/services/command-create-list-item.service.js.map +0 -1
  137. package/dist/src/command/services/command-create-list.service.d.ts +0 -16
  138. package/dist/src/command/services/command-create-list.service.js +0 -10
  139. package/dist/src/command/services/command-create-list.service.js.map +0 -1
  140. package/dist/src/command/services/command-delete-list.service.d.ts +0 -16
  141. package/dist/src/command/services/command-delete-list.service.js +0 -12
  142. package/dist/src/command/services/command-delete-list.service.js.map +0 -1
  143. package/dist/src/command/services/command-delete-user-data.service.d.ts +0 -16
  144. package/dist/src/command/services/command-delete-user-data.service.js +0 -10
  145. package/dist/src/command/services/command-delete-user-data.service.js.map +0 -1
  146. package/dist/src/command/services/command-fetch-all-lists.service.d.ts +0 -15
  147. package/dist/src/command/services/command-fetch-all-lists.service.js +0 -10
  148. package/dist/src/command/services/command-fetch-all-lists.service.js.map +0 -1
  149. package/dist/src/command/services/command-fetch-list-item.service.d.ts +0 -16
  150. package/dist/src/command/services/command-fetch-list-item.service.js +0 -12
  151. package/dist/src/command/services/command-fetch-list-item.service.js.map +0 -1
  152. package/dist/src/command/services/command-fetch-list.service.d.ts +0 -16
  153. package/dist/src/command/services/command-fetch-list.service.js +0 -12
  154. package/dist/src/command/services/command-fetch-list.service.js.map +0 -1
  155. package/dist/src/command/services/command-filter.service.d.ts +0 -16
  156. package/dist/src/command/services/command-filter.service.js +0 -12
  157. package/dist/src/command/services/command-filter.service.js.map +0 -1
  158. package/dist/src/command/services/command-generate.service.d.ts +0 -17
  159. package/dist/src/command/services/command-generate.service.js +0 -18
  160. package/dist/src/command/services/command-generate.service.js.map +0 -1
  161. package/dist/src/command/services/command-get-device.service.d.ts +0 -16
  162. package/dist/src/command/services/command-get-device.service.js +0 -12
  163. package/dist/src/command/services/command-get-device.service.js.map +0 -1
  164. package/dist/src/command/services/command-get-devices-for-user.service.d.ts +0 -16
  165. package/dist/src/command/services/command-get-devices-for-user.service.js +0 -12
  166. package/dist/src/command/services/command-get-devices-for-user.service.js.map +0 -1
  167. package/dist/src/command/services/command-get-events-schema.service.d.ts +0 -15
  168. package/dist/src/command/services/command-get-events-schema.service.js +0 -10
  169. package/dist/src/command/services/command-get-events-schema.service.js.map +0 -1
  170. package/dist/src/command/services/command-group-events.service.d.ts +0 -16
  171. package/dist/src/command/services/command-group-events.service.js +0 -10
  172. package/dist/src/command/services/command-group-events.service.js.map +0 -1
  173. package/dist/src/command/services/command-log.service.d.ts +0 -16
  174. package/dist/src/command/services/command-log.service.js +0 -12
  175. package/dist/src/command/services/command-log.service.js.map +0 -1
  176. package/dist/src/command/services/command-report-device.service.d.ts +0 -16
  177. package/dist/src/command/services/command-report-device.service.js +0 -12
  178. package/dist/src/command/services/command-report-device.service.js.map +0 -1
  179. package/dist/src/command/services/command-request-user-data.service.d.ts +0 -16
  180. package/dist/src/command/services/command-request-user-data.service.js +0 -10
  181. package/dist/src/command/services/command-request-user-data.service.js.map +0 -1
  182. package/dist/src/command/services/command-risk.service.d.ts +0 -16
  183. package/dist/src/command/services/command-risk.service.js +0 -12
  184. package/dist/src/command/services/command-risk.service.js.map +0 -1
  185. package/dist/src/command/services/command-search-events.service.d.ts +0 -16
  186. package/dist/src/command/services/command-search-events.service.js +0 -10
  187. package/dist/src/command/services/command-search-events.service.js.map +0 -1
  188. package/dist/src/command/services/command-search-list-items.service.d.ts +0 -16
  189. package/dist/src/command/services/command-search-list-items.service.js +0 -12
  190. package/dist/src/command/services/command-search-list-items.service.js.map +0 -1
  191. package/dist/src/command/services/command-search-lists.service.d.ts +0 -16
  192. package/dist/src/command/services/command-search-lists.service.js +0 -10
  193. package/dist/src/command/services/command-search-lists.service.js.map +0 -1
  194. package/dist/src/command/services/command-track.service.d.ts +0 -16
  195. package/dist/src/command/services/command-track.service.js +0 -12
  196. package/dist/src/command/services/command-track.service.js.map +0 -1
  197. package/dist/src/command/services/command-unarchive-list-item.service.d.ts +0 -16
  198. package/dist/src/command/services/command-unarchive-list-item.service.js +0 -12
  199. package/dist/src/command/services/command-unarchive-list-item.service.js.map +0 -1
  200. package/dist/src/command/services/command-update-list-item.service.d.ts +0 -16
  201. package/dist/src/command/services/command-update-list-item.service.js +0 -12
  202. package/dist/src/command/services/command-update-list-item.service.js.map +0 -1
  203. package/dist/src/command/services/command-update-list.service.d.ts +0 -16
  204. package/dist/src/command/services/command-update-list.service.js +0 -12
  205. package/dist/src/command/services/command-update-list.service.js.map +0 -1
  206. package/dist/src/command/services/index.d.ts +0 -29
  207. package/dist/src/command/services/index.js +0 -46
  208. package/dist/src/command/services/index.js.map +0 -1
  209. package/dist/src/configuration.d.ts +0 -32
  210. package/dist/src/configuration.js +0 -34
  211. package/dist/src/configuration.js.map +0 -1
  212. package/dist/src/constants.d.ts +0 -4
  213. package/dist/src/constants.js +0 -42
  214. package/dist/src/constants.js.map +0 -1
  215. package/dist/src/context/context.module.d.ts +0 -1
  216. package/dist/src/context/context.module.js +0 -18
  217. package/dist/src/context/context.module.js.map +0 -1
  218. package/dist/src/context/services/context-get-default.service.d.ts +0 -9
  219. package/dist/src/context/services/context-get-default.service.js +0 -34
  220. package/dist/src/context/services/context-get-default.service.js.map +0 -1
  221. package/dist/src/context/services/context-prepare.service.d.ts +0 -9
  222. package/dist/src/context/services/context-prepare.service.js +0 -15
  223. package/dist/src/context/services/context-prepare.service.js.map +0 -1
  224. package/dist/src/context/services/context-sanitize.service.d.ts +0 -7
  225. package/dist/src/context/services/context-sanitize.service.js +0 -19
  226. package/dist/src/context/services/context-sanitize.service.js.map +0 -1
  227. package/dist/src/context/services/index.d.ts +0 -3
  228. package/dist/src/context/services/index.js +0 -20
  229. package/dist/src/context/services/index.js.map +0 -1
  230. package/dist/src/core/core.module.d.ts +0 -1
  231. package/dist/src/core/core.module.js +0 -18
  232. package/dist/src/core/core.module.js.map +0 -1
  233. package/dist/src/core/services/core-generate-default-headers.service.d.ts +0 -7
  234. package/dist/src/core/services/core-generate-default-headers.service.js +0 -12
  235. package/dist/src/core/services/core-generate-default-headers.service.js.map +0 -1
  236. package/dist/src/core/services/core-generate-request-body.service.d.ts +0 -5
  237. package/dist/src/core/services/core-generate-request-body.service.js +0 -9
  238. package/dist/src/core/services/core-generate-request-body.service.js.map +0 -1
  239. package/dist/src/core/services/core-process-response.service.d.ts +0 -3
  240. package/dist/src/core/services/core-process-response.service.js +0 -61
  241. package/dist/src/core/services/core-process-response.service.js.map +0 -1
  242. package/dist/src/core/services/index.d.ts +0 -3
  243. package/dist/src/core/services/index.js +0 -20
  244. package/dist/src/core/services/index.js.map +0 -1
  245. package/dist/src/errors.d.ts +0 -36
  246. package/dist/src/errors.js +0 -88
  247. package/dist/src/errors.js.map +0 -1
  248. package/dist/src/failover/failover.module.d.ts +0 -1
  249. package/dist/src/failover/failover.module.js +0 -18
  250. package/dist/src/failover/failover.module.js.map +0 -1
  251. package/dist/src/failover/models/failover-strategy.d.ts +0 -6
  252. package/dist/src/failover/models/failover-strategy.js +0 -11
  253. package/dist/src/failover/models/failover-strategy.js.map +0 -1
  254. package/dist/src/failover/models/index.d.ts +0 -1
  255. package/dist/src/failover/models/index.js +0 -18
  256. package/dist/src/failover/models/index.js.map +0 -1
  257. package/dist/src/headers/headers.module.d.ts +0 -1
  258. package/dist/src/headers/headers.module.js +0 -18
  259. package/dist/src/headers/headers.module.js.map +0 -1
  260. package/dist/src/headers/services/headers-extract.service.d.ts +0 -9
  261. package/dist/src/headers/services/headers-extract.service.js +0 -30
  262. package/dist/src/headers/services/headers-extract.service.js.map +0 -1
  263. package/dist/src/headers/services/headers-get-cookie.service.d.ts +0 -3
  264. package/dist/src/headers/services/headers-get-cookie.service.js +0 -17
  265. package/dist/src/headers/services/headers-get-cookie.service.js.map +0 -1
  266. package/dist/src/headers/services/index.d.ts +0 -2
  267. package/dist/src/headers/services/index.js +0 -19
  268. package/dist/src/headers/services/index.js.map +0 -1
  269. package/dist/src/ips/ips.module.d.ts +0 -1
  270. package/dist/src/ips/ips.module.js +0 -18
  271. package/dist/src/ips/ips.module.js.map +0 -1
  272. package/dist/src/ips/services/index.d.ts +0 -1
  273. package/dist/src/ips/services/index.js +0 -18
  274. package/dist/src/ips/services/index.js.map +0 -1
  275. package/dist/src/ips/services/ips-extract.service.d.ts +0 -5
  276. package/dist/src/ips/services/ips-extract.service.js +0 -50
  277. package/dist/src/ips/services/ips-extract.service.js.map +0 -1
  278. package/dist/src/logger/logger.module.d.ts +0 -2
  279. package/dist/src/logger/logger.module.js +0 -19
  280. package/dist/src/logger/logger.module.js.map +0 -1
  281. package/dist/src/logger/models/index.d.ts +0 -1
  282. package/dist/src/logger/models/index.js +0 -18
  283. package/dist/src/logger/models/index.js.map +0 -1
  284. package/dist/src/logger/models/logging-parameters.d.ts +0 -7
  285. package/dist/src/logger/models/logging-parameters.js +0 -3
  286. package/dist/src/logger/models/logging-parameters.js.map +0 -1
  287. package/dist/src/logger/services/index.d.ts +0 -4
  288. package/dist/src/logger/services/index.js +0 -21
  289. package/dist/src/logger/services/index.js.map +0 -1
  290. package/dist/src/logger/services/logger-error-formatter.service.d.ts +0 -3
  291. package/dist/src/logger/services/logger-error-formatter.service.js +0 -10
  292. package/dist/src/logger/services/logger-error-formatter.service.js.map +0 -1
  293. package/dist/src/logger/services/logger-request-formatter.service.d.ts +0 -4
  294. package/dist/src/logger/services/logger-request-formatter.service.js +0 -16
  295. package/dist/src/logger/services/logger-request-formatter.service.js.map +0 -1
  296. package/dist/src/logger/services/logger-response-formatter.service.d.ts +0 -3
  297. package/dist/src/logger/services/logger-response-formatter.service.js +0 -10
  298. package/dist/src/logger/services/logger-response-formatter.service.js.map +0 -1
  299. package/dist/src/logger/services/logger.service.d.ts +0 -4
  300. package/dist/src/logger/services/logger.service.js +0 -25
  301. package/dist/src/logger/services/logger.service.js.map +0 -1
  302. package/dist/src/models/action.d.ts +0 -5
  303. package/dist/src/models/action.js +0 -10
  304. package/dist/src/models/action.js.map +0 -1
  305. package/dist/src/models/authenticate-result.d.ts +0 -18
  306. package/dist/src/models/authenticate-result.js +0 -3
  307. package/dist/src/models/authenticate-result.js.map +0 -1
  308. package/dist/src/models/device.d.ts +0 -3
  309. package/dist/src/models/device.js +0 -3
  310. package/dist/src/models/device.js.map +0 -1
  311. package/dist/src/models/events.d.ts +0 -17
  312. package/dist/src/models/events.js +0 -23
  313. package/dist/src/models/events.js.map +0 -1
  314. package/dist/src/models/index.d.ts +0 -8
  315. package/dist/src/models/index.js +0 -25
  316. package/dist/src/models/index.js.map +0 -1
  317. package/dist/src/models/list-item.d.ts +0 -15
  318. package/dist/src/models/list-item.js +0 -3
  319. package/dist/src/models/list-item.js.map +0 -1
  320. package/dist/src/models/list.d.ts +0 -11
  321. package/dist/src/models/list.js +0 -3
  322. package/dist/src/models/list.js.map +0 -1
  323. package/dist/src/models/risk-policy.d.ts +0 -9
  324. package/dist/src/models/risk-policy.js +0 -3
  325. package/dist/src/models/risk-policy.js.map +0 -1
  326. package/dist/src/models/signals.d.ts +0 -3
  327. package/dist/src/models/signals.js +0 -3
  328. package/dist/src/models/signals.js.map +0 -1
  329. package/dist/src/payload/models/address_payload.d.ts +0 -8
  330. package/dist/src/payload/models/address_payload.js +0 -3
  331. package/dist/src/payload/models/address_payload.js.map +0 -1
  332. package/dist/src/payload/models/device_payload.d.ts +0 -7
  333. package/dist/src/payload/models/device_payload.js +0 -3
  334. package/dist/src/payload/models/device_payload.js.map +0 -1
  335. package/dist/src/payload/models/event_payload.d.ts +0 -89
  336. package/dist/src/payload/models/event_payload.js +0 -29
  337. package/dist/src/payload/models/event_payload.js.map +0 -1
  338. package/dist/src/payload/models/event_response.d.ts +0 -346
  339. package/dist/src/payload/models/event_response.js +0 -51
  340. package/dist/src/payload/models/event_response.js.map +0 -1
  341. package/dist/src/payload/models/filter_payload.d.ts +0 -68
  342. package/dist/src/payload/models/filter_payload.js +0 -3
  343. package/dist/src/payload/models/filter_payload.js.map +0 -1
  344. package/dist/src/payload/models/index.d.ts +0 -11
  345. package/dist/src/payload/models/index.js +0 -28
  346. package/dist/src/payload/models/index.js.map +0 -1
  347. package/dist/src/payload/models/list-payload.d.ts +0 -26
  348. package/dist/src/payload/models/list-payload.js +0 -3
  349. package/dist/src/payload/models/list-payload.js.map +0 -1
  350. package/dist/src/payload/models/list_item_payload.d.ts +0 -45
  351. package/dist/src/payload/models/list_item_payload.js +0 -3
  352. package/dist/src/payload/models/list_item_payload.js.map +0 -1
  353. package/dist/src/payload/models/log_payload.d.ts +0 -42
  354. package/dist/src/payload/models/log_payload.js +0 -3
  355. package/dist/src/payload/models/log_payload.js.map +0 -1
  356. package/dist/src/payload/models/payload.d.ts +0 -15
  357. package/dist/src/payload/models/payload.js +0 -3
  358. package/dist/src/payload/models/payload.js.map +0 -1
  359. package/dist/src/payload/models/privacy_payload.d.ts +0 -8
  360. package/dist/src/payload/models/privacy_payload.js +0 -3
  361. package/dist/src/payload/models/privacy_payload.js.map +0 -1
  362. package/dist/src/payload/models/risk_payload.d.ts +0 -75
  363. package/dist/src/payload/models/risk_payload.js +0 -3
  364. package/dist/src/payload/models/risk_payload.js.map +0 -1
  365. package/dist/src/payload/payload.module.d.ts +0 -2
  366. package/dist/src/payload/payload.module.js +0 -19
  367. package/dist/src/payload/payload.module.js.map +0 -1
  368. package/dist/src/payload/services/index.d.ts +0 -1
  369. package/dist/src/payload/services/index.js +0 -18
  370. package/dist/src/payload/services/index.js.map +0 -1
  371. package/dist/src/payload/services/payload-prepare-service.d.ts +0 -13
  372. package/dist/src/payload/services/payload-prepare-service.js +0 -15
  373. package/dist/src/payload/services/payload-prepare-service.js.map +0 -1
  374. package/dist/src/validator/services/index.d.ts +0 -1
  375. package/dist/src/validator/services/index.js +0 -18
  376. package/dist/src/validator/services/index.js.map +0 -1
  377. package/dist/src/validator/services/validator-present.service.d.ts +0 -3
  378. package/dist/src/validator/services/validator-present.service.js +0 -15
  379. package/dist/src/validator/services/validator-present.service.js.map +0 -1
  380. package/dist/src/validator/validator.module.d.ts +0 -1
  381. package/dist/src/validator/validator.module.js +0 -18
  382. package/dist/src/validator/validator.module.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,27 +1,1564 @@
1
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.ContextPrepareService = exports.Castle = void 0;
18
- var Castle_1 = require("./src/Castle");
19
- Object.defineProperty(exports, "Castle", { enumerable: true, get: function () { return Castle_1.Castle; } });
20
- __exportStar(require("./src/constants"), exports);
21
- __exportStar(require("./src/models"), exports);
22
- __exportStar(require("./src/errors"), exports);
23
- __exportStar(require("./src/failover/failover.module"), exports);
24
- __exportStar(require("./src/payload/payload.module"), exports);
25
- var context_module_1 = require("./src/context/context.module");
26
- Object.defineProperty(exports, "ContextPrepareService", { enumerable: true, get: function () { return context_module_1.ContextPrepareService; } });
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ APIError: () => APIError,
34
+ Action: () => Action,
35
+ BadRequestError: () => BadRequestError,
36
+ Castle: () => Castle,
37
+ ConfigurationError: () => ConfigurationError,
38
+ ContextPrepareService: () => ContextPrepareService,
39
+ DEFAULT_ALLOWLIST: () => DEFAULT_ALLOWLIST,
40
+ DEFAULT_API_URL: () => DEFAULT_API_URL,
41
+ DEFAULT_TIMEOUT: () => DEFAULT_TIMEOUT,
42
+ EventAuthenticationMethod: () => EventAuthenticationMethod,
43
+ EventSignal: () => EventSignal,
44
+ EventStatus: () => EventStatus,
45
+ EventType: () => EventType,
46
+ FailoverStrategy: () => FailoverStrategy,
47
+ ForbiddenError: () => ForbiddenError,
48
+ InternalServerError: () => InternalServerError,
49
+ InvalidParametersError: () => InvalidParametersError,
50
+ InvalidRequestTokenError: () => InvalidRequestTokenError,
51
+ NotFoundError: () => NotFoundError,
52
+ PayloadPrepareService: () => PayloadPrepareService,
53
+ RateLimitError: () => RateLimitError,
54
+ SearchEventsQueryFilterOperator: () => SearchEventsQueryFilterOperator,
55
+ SearchEventsQueryType: () => SearchEventsQueryType,
56
+ SecureModeService: () => SecureModeService,
57
+ TRUSTED_PROXIES: () => TRUSTED_PROXIES,
58
+ UnauthorizedError: () => UnauthorizedError,
59
+ UserUnauthorizedError: () => UserUnauthorizedError,
60
+ WebhookVerificationError: () => WebhookVerificationError,
61
+ WebhookVerifyService: () => WebhookVerifyService
62
+ });
63
+ module.exports = __toCommonJS(index_exports);
64
+
65
+ // src/core/services/core-generate-default-headers.service.ts
66
+ var CoreGenerateDefaultHeadersService = {
67
+ call: (configuration) => {
68
+ return {
69
+ Authorization: `Basic ${Buffer.from(
70
+ `:${configuration.apiSecret}`
71
+ ).toString("base64")}`,
72
+ "Content-Type": "application/json"
73
+ };
74
+ }
75
+ };
76
+
77
+ // src/core/services/core-generate-request-body.service.ts
78
+ var CoreGenerateRequestBody = {
79
+ call: (payload) => {
80
+ return JSON.stringify({
81
+ sent_at: (/* @__PURE__ */ new Date()).toISOString(),
82
+ ...payload
83
+ });
84
+ }
85
+ };
86
+
87
+ // src/errors.ts
88
+ var ConfigurationError = class extends Error {
89
+ constructor(message) {
90
+ super(message);
91
+ this.name = "ConfigurationError";
92
+ }
93
+ };
94
+ var APIError = class extends Error {
95
+ constructor(message) {
96
+ super(message);
97
+ this.name = "APIError";
98
+ }
99
+ };
100
+ var BadRequestError = class extends APIError {
101
+ constructor(message) {
102
+ super(message);
103
+ this.name = "BadRequestError";
104
+ }
105
+ };
106
+ var UnauthorizedError = class extends APIError {
107
+ constructor(message) {
108
+ super(message);
109
+ this.name = "UnauthorizedError";
110
+ }
111
+ };
112
+ var ForbiddenError = class extends APIError {
113
+ constructor(message) {
114
+ super(message);
115
+ this.name = "ForbiddenError";
116
+ }
117
+ };
118
+ var NotFoundError = class extends APIError {
119
+ constructor(message) {
120
+ super(message);
121
+ this.name = "NotFoundError";
122
+ }
123
+ };
124
+ var UserUnauthorizedError = class extends APIError {
125
+ constructor(message) {
126
+ super(message);
127
+ this.name = "UserUnauthorizedError";
128
+ }
129
+ };
130
+ var InvalidParametersError = class extends APIError {
131
+ constructor(message) {
132
+ super(message);
133
+ this.name = "InvalidParametersError";
134
+ }
135
+ };
136
+ var InvalidRequestTokenError = class extends InvalidParametersError {
137
+ constructor(message) {
138
+ super(message);
139
+ this.name = "InvalidRequestTokenError";
140
+ }
141
+ };
142
+ var RateLimitError = class extends APIError {
143
+ constructor(message) {
144
+ super(message);
145
+ this.name = "RateLimitError";
146
+ }
147
+ };
148
+ var InternalServerError = class extends APIError {
149
+ constructor(message) {
150
+ super(message);
151
+ this.name = "InternalServerError";
152
+ }
153
+ };
154
+ var WebhookVerificationError = class extends Error {
155
+ constructor(message) {
156
+ super(message);
157
+ this.name = "WebhookVerificationError";
158
+ }
159
+ };
160
+
161
+ // src/logger/services/logger-error-formatter.service.ts
162
+ var LoggerErrorFormatterService = {
163
+ call: (err) => err ? `
164
+ Error name: ${err.name}
165
+ Error message: ${err.message}
166
+ `.trim() : ""
167
+ };
168
+
169
+ // src/logger/services/logger-request-formatter.service.ts
170
+ var LoggerRequestFormatterService = {
171
+ call: ({
172
+ requestUrl,
173
+ requestOptions,
174
+ response,
175
+ err,
176
+ body
177
+ }) => `
178
+ -- Castle request
179
+ URL: ${requestUrl}
180
+ Request: ${JSON.stringify(requestOptions)}
181
+ -- Castle response
182
+ ${response ? LoggerResponseFormatterService.call(response, body) : LoggerErrorFormatterService.call(err)}
183
+ `
184
+ };
185
+
186
+ // src/logger/services/logger-response-formatter.service.ts
187
+ var LoggerResponseFormatterService = {
188
+ call: (response, body) => `
189
+ Response status: ${response.status}
190
+ Response body: ${JSON.stringify(body)}
191
+ `.trim()
192
+ };
193
+
194
+ // src/logger/services/logger.service.ts
195
+ var LoggerService = {
196
+ call: async ({ requestUrl, requestOptions, response, body, err }, logger) => {
197
+ return logger.info(
198
+ LoggerRequestFormatterService.call({
199
+ requestUrl,
200
+ requestOptions,
201
+ response,
202
+ err,
203
+ body
204
+ })
205
+ );
206
+ }
207
+ };
208
+
209
+ // src/core/services/core-process-response.service.ts
210
+ var RESPONSE_ERRORS = {
211
+ "400": BadRequestError,
212
+ "401": UnauthorizedError,
213
+ "403": ForbiddenError,
214
+ "404": NotFoundError,
215
+ "419": UserUnauthorizedError,
216
+ "422": InvalidParametersError,
217
+ "429": RateLimitError
218
+ };
219
+ var RESPONSE_SUB_ERRORS = {
220
+ invalid_request_token: InvalidRequestTokenError
221
+ };
222
+ var getBody = async (response) => {
223
+ if (response.cachedBody) {
224
+ return response.cachedBody;
225
+ }
226
+ try {
227
+ const preparsedResponse = await response.text();
228
+ if (preparsedResponse) {
229
+ response.cachedBody = await JSON.parse(preparsedResponse);
230
+ } else {
231
+ response.cachedBody = {};
232
+ }
233
+ } catch (e) {
234
+ throw new APIError("Castle: Malformed JSON response");
235
+ }
236
+ return response.cachedBody;
237
+ };
238
+ var CoreProcessResponseService = {
239
+ call: async (requestUrl, requestOptions, response, logger) => {
240
+ const body = await getBody(response);
241
+ LoggerService.call({ requestUrl, requestOptions, response, body }, logger);
242
+ if (response.status >= 200 && response.status <= 299) {
243
+ return body;
244
+ }
245
+ if (response.status >= 500 && response.status <= 599) {
246
+ throw new InternalServerError(
247
+ `Castle: Responded with ${response.status} code`
248
+ );
249
+ }
250
+ const err = RESPONSE_SUB_ERRORS[body.type] || RESPONSE_ERRORS[response.status.toString()] || APIError;
251
+ throw new err(`Castle: Responded with ${response.status} code`);
252
+ }
253
+ };
254
+
255
+ // src/api/services/api.service.ts
256
+ var APIService = {
257
+ call: async (controller, { requestUrl, requestOptions }, configuration) => {
258
+ const fetcher = configuration.overrideFetch || fetch;
259
+ let response;
260
+ const timeout = setTimeout(() => {
261
+ controller.abort();
262
+ }, configuration.timeout);
263
+ try {
264
+ response = await fetcher(requestUrl, requestOptions);
265
+ } catch (err) {
266
+ LoggerService.call(
267
+ { requestUrl, requestOptions, err },
268
+ configuration.logger
269
+ );
270
+ throw err;
271
+ } finally {
272
+ clearTimeout(timeout);
273
+ }
274
+ const processedResponse = await CoreProcessResponseService.call(
275
+ requestUrl,
276
+ requestOptions,
277
+ response,
278
+ configuration.logger
279
+ );
280
+ return processedResponse;
281
+ }
282
+ };
283
+
284
+ // src/command/services/command-generate.service.ts
285
+ var combineURLs = (baseURL, relativeURL) => {
286
+ return baseURL.replace(/\/+$/, "") + "/" + relativeURL.replace(/^\/+/, "");
287
+ };
288
+ var CommandGenerateService = {
289
+ call: (controller, path, options, method, configuration) => {
290
+ return {
291
+ requestUrl: new URL(combineURLs(configuration.baseUrl.toString(), path)),
292
+ requestOptions: {
293
+ signal: controller.signal,
294
+ method,
295
+ headers: CoreGenerateDefaultHeadersService.call(configuration),
296
+ ...method !== "GET" && {
297
+ body: CoreGenerateRequestBody.call(options)
298
+ }
299
+ }
300
+ };
301
+ }
302
+ };
303
+
304
+ // src/utils/object.ts
305
+ var isPlainObject = (value) => Object.prototype.toString.call(value) === "[object Object]";
306
+ var deepMerge = (target, ...sources) => {
307
+ for (const source of sources) {
308
+ if (source === null || source === void 0) {
309
+ continue;
310
+ }
311
+ for (const key of Object.keys(source)) {
312
+ const sourceValue = source[key];
313
+ const targetValue = target[key];
314
+ if (sourceValue === void 0) {
315
+ continue;
316
+ }
317
+ if (isPlainObject(sourceValue) && isPlainObject(targetValue)) {
318
+ deepMerge(targetValue, sourceValue);
319
+ } else if (Array.isArray(sourceValue) && Array.isArray(targetValue)) {
320
+ deepMerge(targetValue, sourceValue);
321
+ } else if (isPlainObject(sourceValue)) {
322
+ target[key] = deepMerge({}, sourceValue);
323
+ } else if (Array.isArray(sourceValue)) {
324
+ target[key] = deepMerge([], sourceValue);
325
+ } else {
326
+ target[key] = sourceValue;
327
+ }
328
+ }
329
+ }
330
+ return target;
331
+ };
332
+ var isEmpty = (value) => {
333
+ if (value === null || value === void 0) {
334
+ return true;
335
+ }
336
+ if (Array.isArray(value) || typeof value === "string") {
337
+ return value.length === 0;
338
+ }
339
+ if (value instanceof Map || value instanceof Set) {
340
+ return value.size === 0;
341
+ }
342
+ if (typeof value === "object") {
343
+ return Object.keys(value).length === 0;
344
+ }
345
+ return true;
346
+ };
347
+ var pickByTruthy = (object) => Object.entries(object).reduce((accumulator, [key, value]) => {
348
+ if (value) {
349
+ accumulator[key] = value;
350
+ }
351
+ return accumulator;
352
+ }, {});
353
+
354
+ // src/headers/services/headers-extract.service.ts
355
+ var ALWAYS_ALLOWLISTED = ["user-agent"];
356
+ var ALWAYS_DENYLISTED = ["cookie", "authorization"];
357
+ var HeadersExtractService = {
358
+ call: (headers, configuration) => {
359
+ return Object.entries(headers).reduce(
360
+ (accumulator, [key, value]) => {
361
+ if (ALWAYS_DENYLISTED.includes(key.toLowerCase())) {
362
+ return {
363
+ ...accumulator,
364
+ [key]: true
365
+ };
366
+ }
367
+ if (ALWAYS_ALLOWLISTED.includes(key.toLowerCase())) {
368
+ return {
369
+ ...accumulator,
370
+ [key]: value
371
+ };
372
+ }
373
+ if (configuration.denylisted.includes(key.toLowerCase())) {
374
+ return {
375
+ ...accumulator,
376
+ [key]: true
377
+ };
378
+ }
379
+ if (configuration.allowlisted.length === 0 || configuration.allowlisted.includes(key.toLowerCase())) {
380
+ return {
381
+ ...accumulator,
382
+ [key]: value
383
+ };
384
+ }
385
+ return {
386
+ ...accumulator,
387
+ [key]: true
388
+ };
389
+ },
390
+ {}
391
+ );
392
+ }
393
+ };
394
+
395
+ // src/headers/services/headers-get-cookie.service.ts
396
+ var HeadersGetCookieService = {
397
+ call: (cookies, name) => {
398
+ if (!cookies) {
399
+ return;
400
+ }
401
+ const pattern = new RegExp(`(?:^|\\s+)\\s?${name}=(.*?)(?:;|$)`);
402
+ const results = cookies.toString().match(pattern);
403
+ if (results && results.length === 2) {
404
+ return results[1];
405
+ }
406
+ return;
407
+ }
408
+ };
409
+
410
+ // src/client-id/services/client-id-extract.service.ts
411
+ var ClientIdExtractService = {
412
+ call: (headers = {}, cookies) => {
413
+ return headers["x-castle-client-id"] || HeadersGetCookieService.call(cookies, "__cid") || "";
414
+ }
415
+ };
416
+
417
+ // src/constants.ts
418
+ var DEFAULT_API_URL = "https://api.castle.io/v1";
419
+ var DEFAULT_TIMEOUT = 1500;
420
+ var DEFAULT_ALLOWLIST = [
421
+ "accept",
422
+ "accept-charset",
423
+ "accept-datetime",
424
+ "accept-encoding",
425
+ "accept-language",
426
+ "cache-control",
427
+ "connection",
428
+ "content-length",
429
+ "content-type",
430
+ "dnt",
431
+ "host",
432
+ "origin",
433
+ "pragma",
434
+ "referer",
435
+ "sec-fetch-dest",
436
+ "sec-fetch-mode",
437
+ "sec-fetch-site",
438
+ "sec-fetch-user",
439
+ "te",
440
+ "upgrade-insecure-requests",
441
+ "user-agent",
442
+ "x-requested-with"
443
+ ];
444
+ var TRUSTED_PROXIES = [
445
+ new RegExp(
446
+ [
447
+ /^127\.0\.0\.1$|/,
448
+ /^(10|172\.(1[6-9]|2[0-9]|30|31)|192\.168)\.|/,
449
+ /^::1\Z|\Afd[0-9a-f]{2}:.+|/,
450
+ /^localhost$|/,
451
+ /^unix$|/,
452
+ /^unix:/
453
+ ].map((r) => r.source).join("")
454
+ )
455
+ ];
456
+
457
+ // src/ips/services/ips-extract.service.ts
458
+ var DEFAULT = ["x-forwarded-for", "remote-addr"];
459
+ var DEPTH_RELATED = ["x-forwarded-for"];
460
+ var checkInternal = (ipAddress, proxies) => {
461
+ return proxies.some((proxyRegexp) => proxyRegexp.test(ipAddress));
462
+ };
463
+ var limitProxyDepth = (ips, ipHeader, trustedProxyDepth) => {
464
+ if (DEPTH_RELATED.includes(ipHeader)) {
465
+ ips.splice(ips.length - 1, trustedProxyDepth);
466
+ }
467
+ return ips;
468
+ };
469
+ var IPsFrom = (ipHeader, headers, trustedProxyDepth) => {
470
+ if (!headers) {
471
+ return [];
472
+ }
473
+ const headerValue = headers[ipHeader];
474
+ if (!headerValue) {
475
+ return [];
476
+ }
477
+ const ips = headerValue.trim().split(/[,\s]+/);
478
+ return limitProxyDepth(ips, ipHeader, trustedProxyDepth);
479
+ };
480
+ var removeProxies = (ips, trustProxyChain, proxiesList) => {
481
+ if (trustProxyChain) {
482
+ return ips[0];
483
+ }
484
+ const filteredIps = ips.filter((ip) => !checkInternal(ip, proxiesList));
485
+ return filteredIps[filteredIps.length - 1];
486
+ };
487
+ var IPsExtractService = {
488
+ call: (headers, {
489
+ ipHeaders = [],
490
+ trustedProxies = [],
491
+ trustProxyChain = false,
492
+ trustedProxyDepth = 0
493
+ }) => {
494
+ const ipHeadersList = ipHeaders.length ? ipHeaders : DEFAULT;
495
+ const proxiesList = trustedProxies.concat(TRUSTED_PROXIES);
496
+ let allIPs = [];
497
+ for (const ipHeader of ipHeadersList) {
498
+ const IPs = IPsFrom(ipHeader, headers, trustedProxyDepth);
499
+ const IPValue = removeProxies(IPs, trustProxyChain, proxiesList);
500
+ if (IPValue) {
501
+ return IPValue;
502
+ }
503
+ allIPs = [...allIPs, ...IPs];
504
+ }
505
+ return allIPs[0];
506
+ }
507
+ };
508
+
509
+ // package.json
510
+ var version = "3.0.0";
511
+
512
+ // src/context/services/context-get-default.service.ts
513
+ var requestContextData = (request, cookies, configuration) => {
514
+ if (isEmpty(request)) {
515
+ return {};
516
+ }
517
+ const cookiesForClientId = cookies || request.headers?.cookies;
518
+ return {
519
+ client_id: ClientIdExtractService.call(request.headers, cookiesForClientId) || false,
520
+ active: true,
521
+ headers: HeadersExtractService.call(request.headers, configuration),
522
+ ip: IPsExtractService.call(request.headers, configuration)
523
+ };
524
+ };
525
+ var ContextGetDefaultService = {
526
+ call: (request, cookies, configuration) => {
527
+ return {
528
+ ...pickByTruthy(requestContextData(request, cookies, configuration)),
529
+ library: {
530
+ name: "castle-node",
531
+ version
532
+ }
533
+ };
534
+ }
535
+ };
536
+
537
+ // src/context/services/context-prepare.service.ts
538
+ var ContextPrepareService = {
539
+ call: (request, options, configuration) => {
540
+ const defaultContext = ContextGetDefaultService.call(
541
+ request,
542
+ options?.cookies,
543
+ configuration
544
+ );
545
+ return deepMerge(defaultContext, options?.context);
546
+ }
547
+ };
548
+
549
+ // src/context/services/context-sanitize.service.ts
550
+ var ContextSanitizeService = {
551
+ call: (context) => {
552
+ if (!context) {
553
+ return {};
554
+ }
555
+ if (!("active" in context)) {
556
+ return context;
557
+ }
558
+ if (typeof context.active === "boolean") {
559
+ return context;
560
+ }
561
+ delete context.active;
562
+ return context;
563
+ }
564
+ };
565
+
566
+ // src/command/services/command-filter.service.ts
567
+ var CommandFilterService = {
568
+ call: (controller, options, configuration) => {
569
+ const context = ContextSanitizeService.call(options.context);
570
+ return CommandGenerateService.call(
571
+ controller,
572
+ "filter",
573
+ { ...options, ...{ context } },
574
+ "POST",
575
+ configuration
576
+ );
577
+ }
578
+ };
579
+
580
+ // src/command/services/command-log.service.ts
581
+ var CommandLogService = {
582
+ call: (controller, options, configuration) => {
583
+ const context = ContextSanitizeService.call(options.context);
584
+ return CommandGenerateService.call(
585
+ controller,
586
+ "log",
587
+ { ...options, ...{ context } },
588
+ "POST",
589
+ configuration
590
+ );
591
+ }
592
+ };
593
+
594
+ // src/command/services/command-risk.service.ts
595
+ var CommandRiskService = {
596
+ call: (controller, options, configuration) => {
597
+ const context = ContextSanitizeService.call(options.context);
598
+ return CommandGenerateService.call(
599
+ controller,
600
+ "risk",
601
+ { ...options, ...{ context } },
602
+ "POST",
603
+ configuration
604
+ );
605
+ }
606
+ };
607
+
608
+ // src/validator/services/validator-present.service.ts
609
+ var ValidatorPresentService = {
610
+ call: (options, keys) => {
611
+ for (const key of keys) {
612
+ if (options[key]) {
613
+ continue;
614
+ }
615
+ throw new InvalidParametersError(`Castle: ${key} is missing or empty`);
616
+ }
617
+ }
618
+ };
619
+
620
+ // src/command/services/command-create-list-item.service.ts
621
+ var CommandCreateListItemService = {
622
+ call: (controller, options, configuration) => {
623
+ ValidatorPresentService.call(options, ["list_id"]);
624
+ return CommandGenerateService.call(
625
+ controller,
626
+ `lists/${options.list_id}/items`,
627
+ options,
628
+ "POST",
629
+ configuration
630
+ );
631
+ }
632
+ };
633
+
634
+ // src/command/services/command-search-list-items.service.ts
635
+ var CommandSearchListItemsService = {
636
+ call: (controller, options, configuration) => {
637
+ ValidatorPresentService.call(options, ["list_id"]);
638
+ return CommandGenerateService.call(
639
+ controller,
640
+ `lists/${options.list_id}/items/query`,
641
+ options,
642
+ "POST",
643
+ configuration
644
+ );
645
+ }
646
+ };
647
+
648
+ // src/command/services/command-update-list-item.service.ts
649
+ var CommandUpdateListItemService = {
650
+ call: (controller, options, configuration) => {
651
+ ValidatorPresentService.call(options, ["id", "list_id"]);
652
+ return CommandGenerateService.call(
653
+ controller,
654
+ `lists/${options.list_id}/items/${options.id}`,
655
+ options,
656
+ "PUT",
657
+ configuration
658
+ );
659
+ }
660
+ };
661
+
662
+ // src/command/services/command-archive-list-item.service.ts
663
+ var CommandArchiveListItemService = {
664
+ call: (controller, options, configuration) => {
665
+ ValidatorPresentService.call(options, ["id", "list_id"]);
666
+ return CommandGenerateService.call(
667
+ controller,
668
+ `lists/${options.list_id}/items/${options.id}/archive`,
669
+ {},
670
+ "DELETE",
671
+ configuration
672
+ );
673
+ }
674
+ };
675
+
676
+ // src/command/services/command-unarchive-list-item.service.ts
677
+ var CommandUnarchiveListItemService = {
678
+ call: (controller, options, configuration) => {
679
+ ValidatorPresentService.call(options, ["id", "list_id"]);
680
+ return CommandGenerateService.call(
681
+ controller,
682
+ `lists/${options.list_id}/items/${options.id}/unarchive`,
683
+ {},
684
+ "PUT",
685
+ configuration
686
+ );
687
+ }
688
+ };
689
+
690
+ // src/command/services/command-fetch-list-item.service.ts
691
+ var CommandFetchListItemService = {
692
+ call: (controller, options, configuration) => {
693
+ ValidatorPresentService.call(options, ["id", "list_id"]);
694
+ return CommandGenerateService.call(
695
+ controller,
696
+ `lists/${options.list_id}/items/${options.id}`,
697
+ {},
698
+ "GET",
699
+ configuration
700
+ );
701
+ }
702
+ };
703
+
704
+ // src/command/services/command-fetch-list.service.ts
705
+ var CommandFetchListService = {
706
+ call: (controller, options, configuration) => {
707
+ ValidatorPresentService.call(options, ["id"]);
708
+ return CommandGenerateService.call(
709
+ controller,
710
+ `lists/${options.id}`,
711
+ {},
712
+ "GET",
713
+ configuration
714
+ );
715
+ }
716
+ };
717
+
718
+ // src/command/services/command-delete-list.service.ts
719
+ var CommandDeleteListService = {
720
+ call: (controller, options, configuration) => {
721
+ ValidatorPresentService.call(options, ["id"]);
722
+ return CommandGenerateService.call(
723
+ controller,
724
+ `lists/${options.id}`,
725
+ {},
726
+ "DELETE",
727
+ configuration
728
+ );
729
+ }
730
+ };
731
+
732
+ // src/command/services/command-fetch-all-lists.service.ts
733
+ var CommandFetchAllListsService = {
734
+ call: (controller, configuration) => {
735
+ return CommandGenerateService.call(
736
+ controller,
737
+ `lists`,
738
+ {},
739
+ "GET",
740
+ configuration
741
+ );
742
+ }
743
+ };
744
+
745
+ // src/command/services/command-search-lists.service.ts
746
+ var CommandSearchListsService = {
747
+ call: (controller, options, configuration) => {
748
+ return CommandGenerateService.call(
749
+ controller,
750
+ `lists/query`,
751
+ options,
752
+ "POST",
753
+ configuration
754
+ );
755
+ }
756
+ };
757
+
758
+ // src/command/services/command-update-list.service.ts
759
+ var CommandUpdateListService = {
760
+ call: (controller, options, configuration) => {
761
+ ValidatorPresentService.call(options, ["id"]);
762
+ return CommandGenerateService.call(
763
+ controller,
764
+ `lists/${options.id}`,
765
+ options,
766
+ "PUT",
767
+ configuration
768
+ );
769
+ }
770
+ };
771
+
772
+ // src/command/services/command-create-list.service.ts
773
+ var CommandCreateListService = {
774
+ call: (controller, options, configuration) => {
775
+ return CommandGenerateService.call(
776
+ controller,
777
+ `lists`,
778
+ options,
779
+ "POST",
780
+ configuration
781
+ );
782
+ }
783
+ };
784
+
785
+ // src/command/services/command-get-events-schema.service.ts
786
+ var CommandGetEventsSchemaService = {
787
+ call: (controller, configuration) => {
788
+ return CommandGenerateService.call(
789
+ controller,
790
+ "events/schema",
791
+ {},
792
+ "GET",
793
+ configuration
794
+ );
795
+ }
796
+ };
797
+
798
+ // src/command/services/command-group-events.service.ts
799
+ var CommandGroupEventsService = {
800
+ call: (controller, options, configuration) => {
801
+ return CommandGenerateService.call(
802
+ controller,
803
+ "events/group",
804
+ options,
805
+ "POST",
806
+ configuration
807
+ );
808
+ }
809
+ };
810
+
811
+ // src/command/services/command-search-events.service.ts
812
+ var CommandSearchEventsService = {
813
+ call: (controller, options, configuration) => {
814
+ return CommandGenerateService.call(
815
+ controller,
816
+ "events/query",
817
+ options,
818
+ "POST",
819
+ configuration
820
+ );
821
+ }
822
+ };
823
+
824
+ // src/command/services/command-count-list-items.service.ts
825
+ var CommandCountListItemsService = {
826
+ call: (controller, options, configuration) => {
827
+ ValidatorPresentService.call(options, ["list_id"]);
828
+ return CommandGenerateService.call(
829
+ controller,
830
+ `lists/${options.list_id}/items/count`,
831
+ options,
832
+ "POST",
833
+ configuration
834
+ );
835
+ }
836
+ };
837
+
838
+ // src/command/services/command-batch-upsert-list-items.service.ts
839
+ var CommandBatchUpsertListItemsService = {
840
+ call: (controller, options, configuration) => {
841
+ ValidatorPresentService.call(options, ["list_id"]);
842
+ return CommandGenerateService.call(
843
+ controller,
844
+ `lists/${options.list_id}/items/batch`,
845
+ options,
846
+ "POST",
847
+ configuration
848
+ );
849
+ }
850
+ };
851
+
852
+ // src/command/services/command-request-user-data.service.ts
853
+ var CommandRequestUserDataService = {
854
+ call: (controller, options, configuration) => {
855
+ return CommandGenerateService.call(
856
+ controller,
857
+ "privacy/users",
858
+ options,
859
+ "POST",
860
+ configuration
861
+ );
862
+ }
863
+ };
864
+
865
+ // src/command/services/command-delete-user-data.service.ts
866
+ var CommandDeleteUserDataService = {
867
+ call: (controller, options, configuration) => {
868
+ return CommandGenerateService.call(
869
+ controller,
870
+ "privacy/users",
871
+ options,
872
+ "DELETE",
873
+ configuration
874
+ );
875
+ }
876
+ };
877
+
878
+ // src/failover/models/failover-strategy.ts
879
+ var FailoverStrategy = /* @__PURE__ */ ((FailoverStrategy2) => {
880
+ FailoverStrategy2["allow"] = "allow";
881
+ FailoverStrategy2["deny"] = "deny";
882
+ FailoverStrategy2["challenge"] = "challenge";
883
+ FailoverStrategy2["throw"] = "throw";
884
+ return FailoverStrategy2;
885
+ })(FailoverStrategy || {});
886
+
887
+ // src/api/services/api-risk.service.ts
888
+ var handleFailover = (reason, configuration, err) => {
889
+ if (configuration.failoverStrategy === "throw" /* throw */) {
890
+ throw err;
891
+ }
892
+ return {
893
+ policy: {
894
+ action: configuration.failoverStrategy
895
+ },
896
+ action: configuration.failoverStrategy,
897
+ failover: true,
898
+ failover_reason: reason
899
+ };
900
+ };
901
+ var isTimeoutError = (e) => e.name === "AbortError";
902
+ var APIRiskService = {
903
+ call: async (options, configuration) => {
904
+ const controller = new AbortController();
905
+ const command = CommandRiskService.call(controller, options, configuration);
906
+ let processedResponse;
907
+ try {
908
+ processedResponse = await APIService.call(
909
+ controller,
910
+ command,
911
+ configuration
912
+ );
913
+ } catch (e) {
914
+ if (isTimeoutError(e)) {
915
+ return handleFailover("timeout", configuration, e);
916
+ } else if (e instanceof InternalServerError) {
917
+ return handleFailover("server error", configuration);
918
+ } else {
919
+ throw e;
920
+ }
921
+ }
922
+ return processedResponse;
923
+ }
924
+ };
925
+
926
+ // src/api/services/api-log.service.ts
927
+ var APILogService = {
928
+ call: async (options, configuration) => {
929
+ const controller = new AbortController();
930
+ const command = CommandLogService.call(controller, options, configuration);
931
+ APIService.call(controller, command, configuration);
932
+ }
933
+ };
934
+
935
+ // src/api/services/api-filter.service.ts
936
+ var handleFailover2 = (reason, configuration, err) => {
937
+ if (configuration.failoverStrategy === "throw" /* throw */) {
938
+ throw err;
939
+ }
940
+ return {
941
+ policy: {
942
+ action: configuration.failoverStrategy
943
+ },
944
+ action: configuration.failoverStrategy,
945
+ failover: true,
946
+ failover_reason: reason
947
+ };
948
+ };
949
+ var isTimeoutError2 = (e) => e.name === "AbortError";
950
+ var APIFilterService = {
951
+ call: async (options, configuration) => {
952
+ const controller = new AbortController();
953
+ const command = CommandFilterService.call(
954
+ controller,
955
+ options,
956
+ configuration
957
+ );
958
+ let processedResponse;
959
+ try {
960
+ processedResponse = await APIService.call(
961
+ controller,
962
+ command,
963
+ configuration
964
+ );
965
+ } catch (e) {
966
+ if (isTimeoutError2(e)) {
967
+ return handleFailover2("timeout", configuration, e);
968
+ } else if (e instanceof InternalServerError) {
969
+ return handleFailover2("server error", configuration, e);
970
+ } else {
971
+ throw e;
972
+ }
973
+ }
974
+ return processedResponse;
975
+ }
976
+ };
977
+
978
+ // src/api/services/api-create-list-item.service.ts
979
+ var APICreateListItemService = {
980
+ call: async (options, configuration) => {
981
+ const controller = new AbortController();
982
+ const command = CommandCreateListItemService.call(
983
+ controller,
984
+ options,
985
+ configuration
986
+ );
987
+ return APIService.call(controller, command, configuration);
988
+ }
989
+ };
990
+
991
+ // src/api/services/api-create-list.service.ts
992
+ var APICreateListService = {
993
+ call: async (options, configuration) => {
994
+ const controller = new AbortController();
995
+ const command = CommandCreateListService.call(
996
+ controller,
997
+ options,
998
+ configuration
999
+ );
1000
+ return APIService.call(controller, command, configuration);
1001
+ }
1002
+ };
1003
+
1004
+ // src/api/services/api-archive-list-item.service.ts
1005
+ var APIArchiveListItemService = {
1006
+ call: async (options, configuration) => {
1007
+ const controller = new AbortController();
1008
+ const command = CommandArchiveListItemService.call(
1009
+ controller,
1010
+ options,
1011
+ configuration
1012
+ );
1013
+ return APIService.call(controller, command, configuration);
1014
+ }
1015
+ };
1016
+
1017
+ // src/api/services/api-delete-list.service.ts
1018
+ var APIDeleteListService = {
1019
+ call: async (options, configuration) => {
1020
+ const controller = new AbortController();
1021
+ const command = CommandDeleteListService.call(
1022
+ controller,
1023
+ options,
1024
+ configuration
1025
+ );
1026
+ return APIService.call(controller, command, configuration);
1027
+ }
1028
+ };
1029
+
1030
+ // src/api/services/api-unarchive-list-item.service.ts
1031
+ var APIUnarchiveListItemService = {
1032
+ call: async (options, configuration) => {
1033
+ const controller = new AbortController();
1034
+ const command = CommandUnarchiveListItemService.call(
1035
+ controller,
1036
+ options,
1037
+ configuration
1038
+ );
1039
+ return APIService.call(controller, command, configuration);
1040
+ }
1041
+ };
1042
+
1043
+ // src/api/services/api-fetch-list-item.service.ts
1044
+ var APIFetchListItemService = {
1045
+ call: async (options, configuration) => {
1046
+ const controller = new AbortController();
1047
+ const command = CommandFetchListItemService.call(
1048
+ controller,
1049
+ options,
1050
+ configuration
1051
+ );
1052
+ return APIService.call(controller, command, configuration);
1053
+ }
1054
+ };
1055
+
1056
+ // src/api/services/api-fetch-list.service.ts
1057
+ var APIFetchListService = {
1058
+ call: async (options, configuration) => {
1059
+ const controller = new AbortController();
1060
+ const command = CommandFetchListService.call(
1061
+ controller,
1062
+ options,
1063
+ configuration
1064
+ );
1065
+ return APIService.call(controller, command, configuration);
1066
+ }
1067
+ };
1068
+
1069
+ // src/api/services/api-search-list-items.service.ts
1070
+ var APISearchListItemsService = {
1071
+ call: async (options, configuration) => {
1072
+ const controller = new AbortController();
1073
+ const command = CommandSearchListItemsService.call(
1074
+ controller,
1075
+ options,
1076
+ configuration
1077
+ );
1078
+ return APIService.call(controller, command, configuration);
1079
+ }
1080
+ };
1081
+
1082
+ // src/api/services/api-search-lists.service.ts
1083
+ var APISearchListsService = {
1084
+ call: async (options, configuration) => {
1085
+ const controller = new AbortController();
1086
+ const command = CommandSearchListsService.call(
1087
+ controller,
1088
+ options,
1089
+ configuration
1090
+ );
1091
+ return APIService.call(controller, command, configuration);
1092
+ }
1093
+ };
1094
+
1095
+ // src/api/services/api-update-list-item.service.ts
1096
+ var APIUpdateListItemService = {
1097
+ call: async (options, configuration) => {
1098
+ const controller = new AbortController();
1099
+ const command = CommandUpdateListItemService.call(
1100
+ controller,
1101
+ options,
1102
+ configuration
1103
+ );
1104
+ return APIService.call(controller, command, configuration);
1105
+ }
1106
+ };
1107
+
1108
+ // src/api/services/api-update-list.service.ts
1109
+ var APIUpdateListService = {
1110
+ call: async (options, configuration) => {
1111
+ const controller = new AbortController();
1112
+ const command = CommandUpdateListService.call(
1113
+ controller,
1114
+ options,
1115
+ configuration
1116
+ );
1117
+ return APIService.call(controller, command, configuration);
1118
+ }
1119
+ };
1120
+
1121
+ // src/api/services/api-fetch-all-lists.service.ts
1122
+ var APIFetchAllListsService = {
1123
+ call: async (configuration) => {
1124
+ const controller = new AbortController();
1125
+ const command = CommandFetchAllListsService.call(controller, configuration);
1126
+ return APIService.call(controller, command, configuration);
1127
+ }
1128
+ };
1129
+
1130
+ // src/api/services/api-get-events-schema.service.ts
1131
+ var APIGetEventsSchemaService = {
1132
+ call: async (configuration) => {
1133
+ const controller = new AbortController();
1134
+ const command = CommandGetEventsSchemaService.call(
1135
+ controller,
1136
+ configuration
1137
+ );
1138
+ return APIService.call(controller, command, configuration);
1139
+ }
1140
+ };
1141
+
1142
+ // src/api/services/api-group-events.service.ts
1143
+ var APIGroupEventsService = {
1144
+ call: async (options, configuration) => {
1145
+ const controller = new AbortController();
1146
+ const command = CommandGroupEventsService.call(
1147
+ controller,
1148
+ options,
1149
+ configuration
1150
+ );
1151
+ return APIService.call(controller, command, configuration);
1152
+ }
1153
+ };
1154
+
1155
+ // src/api/services/api-search-events.service.ts
1156
+ var APISearchEventsService = {
1157
+ call: async (options, configuration) => {
1158
+ const controller = new AbortController();
1159
+ const command = CommandSearchEventsService.call(
1160
+ controller,
1161
+ options,
1162
+ configuration
1163
+ );
1164
+ return APIService.call(controller, command, configuration);
1165
+ }
1166
+ };
1167
+
1168
+ // src/api/services/api-count-list-items.service.ts
1169
+ var APICountListItemsService = {
1170
+ call: async (options, configuration) => {
1171
+ const controller = new AbortController();
1172
+ const command = CommandCountListItemsService.call(
1173
+ controller,
1174
+ options,
1175
+ configuration
1176
+ );
1177
+ return APIService.call(controller, command, configuration);
1178
+ }
1179
+ };
1180
+
1181
+ // src/api/services/api-batch-upsert-list-items.service.ts
1182
+ var APIBatchUpsertListItemsService = {
1183
+ call: async (options, configuration) => {
1184
+ const controller = new AbortController();
1185
+ const command = CommandBatchUpsertListItemsService.call(
1186
+ controller,
1187
+ options,
1188
+ configuration
1189
+ );
1190
+ return APIService.call(controller, command, configuration);
1191
+ }
1192
+ };
1193
+
1194
+ // src/api/services/api-request-user-data.service.ts
1195
+ var APIRequestUserDataService = {
1196
+ call: async (options, configuration) => {
1197
+ const controller = new AbortController();
1198
+ const command = CommandRequestUserDataService.call(
1199
+ controller,
1200
+ options,
1201
+ configuration
1202
+ );
1203
+ return APIService.call(controller, command, configuration);
1204
+ }
1205
+ };
1206
+
1207
+ // src/api/services/api-delete-user-data.service.ts
1208
+ var APIDeleteUserDataService = {
1209
+ call: async (options, configuration) => {
1210
+ const controller = new AbortController();
1211
+ const command = CommandDeleteUserDataService.call(
1212
+ controller,
1213
+ options,
1214
+ configuration
1215
+ );
1216
+ return APIService.call(controller, command, configuration);
1217
+ }
1218
+ };
1219
+
1220
+ // src/webhook/services/webhook-verify.service.ts
1221
+ var import_crypto = require("crypto");
1222
+ var secureCompare = (a, b) => {
1223
+ const bufferA = Buffer.from(a);
1224
+ const bufferB = Buffer.from(b);
1225
+ if (bufferA.length !== bufferB.length) {
1226
+ return false;
1227
+ }
1228
+ return (0, import_crypto.timingSafeEqual)(bufferA, bufferB);
1229
+ };
1230
+ var WebhookVerifyService = {
1231
+ // Verifies the `X-Castle-Signature` of an incoming webhook against the raw
1232
+ // request body. Throws `WebhookVerificationError` when it does not match.
1233
+ call: (payload, signature, configuration) => {
1234
+ if (!payload || payload.length === 0) {
1235
+ throw new WebhookVerificationError("Invalid webhook from Castle API");
1236
+ }
1237
+ const expectedSignature = (0, import_crypto.createHmac)("sha256", configuration.apiSecret).update(payload).digest("base64");
1238
+ if (!signature || !secureCompare(signature, expectedSignature)) {
1239
+ throw new WebhookVerificationError(
1240
+ "Signature not matching the expected signature"
1241
+ );
1242
+ }
1243
+ }
1244
+ };
1245
+
1246
+ // src/secure-mode/services/secure-mode.service.ts
1247
+ var import_crypto2 = require("crypto");
1248
+ var SecureModeService = {
1249
+ // Computes the secure-mode signature for a user id: a hex HMAC-SHA256 of the
1250
+ // user id keyed with the API secret. Use it to authenticate the user id sent
1251
+ // to Castle from the browser.
1252
+ call: (userId, configuration) => (0, import_crypto2.createHmac)("sha256", configuration.apiSecret).update(userId).digest("hex")
1253
+ };
1254
+
1255
+ // src/configuration.ts
1256
+ var import_pino = __toESM(require("pino"));
1257
+ var import_pino_pretty = __toESM(require("pino-pretty"));
1258
+ var Configuration = class {
1259
+ apiSecret;
1260
+ baseUrl;
1261
+ timeout;
1262
+ allowlisted;
1263
+ denylisted;
1264
+ overrideFetch;
1265
+ failoverStrategy;
1266
+ doNotTrack;
1267
+ ipHeaders;
1268
+ trustedProxies;
1269
+ trustProxyChain;
1270
+ trustedProxyDepth;
1271
+ logger;
1272
+ constructor({
1273
+ apiSecret,
1274
+ baseUrl = DEFAULT_API_URL,
1275
+ timeout = DEFAULT_TIMEOUT,
1276
+ allowlisted = [],
1277
+ denylisted = [],
1278
+ overrideFetch = fetch,
1279
+ failoverStrategy = "allow" /* allow */,
1280
+ doNotTrack = false,
1281
+ ipHeaders = [],
1282
+ trustedProxies = [],
1283
+ trustProxyChain = false,
1284
+ trustedProxyDepth = 0,
1285
+ logger = (0, import_pino.default)((0, import_pino_pretty.default)({ levelFirst: true }))
1286
+ }) {
1287
+ if (!apiSecret) {
1288
+ throw new ConfigurationError(
1289
+ "Castle: Unable to instantiate Castle client, API secret is missing."
1290
+ );
1291
+ }
1292
+ this.apiSecret = apiSecret;
1293
+ this.baseUrl = new URL(baseUrl);
1294
+ this.timeout = timeout;
1295
+ this.allowlisted = allowlisted.map((x) => x.toLowerCase());
1296
+ this.denylisted = denylisted.map((x) => x.toLowerCase());
1297
+ this.overrideFetch = overrideFetch;
1298
+ this.failoverStrategy = failoverStrategy;
1299
+ this.doNotTrack = doNotTrack;
1300
+ this.ipHeaders = ipHeaders;
1301
+ this.trustedProxies = trustedProxies.map((proxy) => new RegExp(proxy));
1302
+ this.trustProxyChain = trustProxyChain;
1303
+ this.trustedProxyDepth = trustedProxyDepth;
1304
+ this.logger = logger;
1305
+ }
1306
+ };
1307
+
1308
+ // src/Castle.ts
1309
+ var Castle = class {
1310
+ configuration;
1311
+ constructor(configAttributes) {
1312
+ this.configuration = new Configuration(configAttributes);
1313
+ }
1314
+ async risk(params) {
1315
+ if (this.configuration.doNotTrack) {
1316
+ return this.generateDoNotTrackResponse(params.user?.id);
1317
+ }
1318
+ return APIRiskService.call(params, this.configuration);
1319
+ }
1320
+ async filter(params) {
1321
+ if (this.configuration.doNotTrack) {
1322
+ return this.generateDoNotTrackResponse(params.matching_user_id);
1323
+ }
1324
+ return APIFilterService.call(params, this.configuration);
1325
+ }
1326
+ async log(params) {
1327
+ if (this.configuration.doNotTrack) {
1328
+ return;
1329
+ }
1330
+ APILogService.call(params, this.configuration);
1331
+ }
1332
+ async createListItem(params) {
1333
+ return APICreateListItemService.call(params, this.configuration);
1334
+ }
1335
+ async createList(params) {
1336
+ return APICreateListService.call(params, this.configuration);
1337
+ }
1338
+ async updateListItem(params) {
1339
+ return APIUpdateListItemService.call(params, this.configuration);
1340
+ }
1341
+ async updateList(params) {
1342
+ return APIUpdateListService.call(params, this.configuration);
1343
+ }
1344
+ async archiveListItem(params) {
1345
+ return APIArchiveListItemService.call(params, this.configuration);
1346
+ }
1347
+ async unarchiveListItem(params) {
1348
+ return APIUnarchiveListItemService.call(params, this.configuration);
1349
+ }
1350
+ async deleteList(params) {
1351
+ return APIDeleteListService.call(params, this.configuration);
1352
+ }
1353
+ async fetchListItem(params) {
1354
+ return APIFetchListItemService.call(params, this.configuration);
1355
+ }
1356
+ async fetchList(params) {
1357
+ return APIFetchListService.call(params, this.configuration);
1358
+ }
1359
+ async fetchAllLists() {
1360
+ return APIFetchAllListsService.call(this.configuration);
1361
+ }
1362
+ async searchListItems(params) {
1363
+ return APISearchListItemsService.call(params, this.configuration);
1364
+ }
1365
+ async searchLists(params) {
1366
+ return APISearchListsService.call(params, this.configuration);
1367
+ }
1368
+ async batchUpdateListItems(params) {
1369
+ return APIBatchUpsertListItemsService.call(params, this.configuration);
1370
+ }
1371
+ async countListItems(params) {
1372
+ return APICountListItemsService.call(params, this.configuration);
1373
+ }
1374
+ async queryEvents(params) {
1375
+ return APISearchEventsService.call(params, this.configuration);
1376
+ }
1377
+ async eventsSchema() {
1378
+ return APIGetEventsSchemaService.call(this.configuration);
1379
+ }
1380
+ async groupEvents(params) {
1381
+ return APIGroupEventsService.call(params, this.configuration);
1382
+ }
1383
+ /** Alias of {@link Castle.queryEvents}. */
1384
+ async searchEvents(params) {
1385
+ return this.queryEvents(params);
1386
+ }
1387
+ /** Alias of {@link Castle.eventsSchema}. */
1388
+ async getEventsSchema() {
1389
+ return this.eventsSchema();
1390
+ }
1391
+ async requestUserData(params) {
1392
+ return APIRequestUserDataService.call(params, this.configuration);
1393
+ }
1394
+ async deleteUserData(params) {
1395
+ return APIDeleteUserDataService.call(params, this.configuration);
1396
+ }
1397
+ verifyWebhookSignature(payload, signature) {
1398
+ WebhookVerifyService.call(payload, signature, this.configuration);
1399
+ }
1400
+ secureModeSignature(userId) {
1401
+ return SecureModeService.call(userId, this.configuration);
1402
+ }
1403
+ generateDoNotTrackResponse(userId) {
1404
+ return {
1405
+ policy: {
1406
+ action: "allow" /* allow */
1407
+ },
1408
+ action: "allow" /* allow */,
1409
+ user_id: userId,
1410
+ failover: true,
1411
+ failover_reason: "do not track"
1412
+ };
1413
+ }
1414
+ };
1415
+
1416
+ // src/models/events.ts
1417
+ var EventType = /* @__PURE__ */ ((EventType2) => {
1418
+ EventType2["CHALLENGE"] = "$challenge";
1419
+ EventType2["CUSTOM"] = "$custom";
1420
+ EventType2["LOGIN"] = "$login";
1421
+ EventType2["LOGOUT"] = "$logout";
1422
+ EventType2["PASSWORD_RESET_REQUEST"] = "$password_reset_request";
1423
+ EventType2["PROFILE_RESET"] = "$profile_reset";
1424
+ EventType2["PROFILE_UPDATE"] = "$profile_update";
1425
+ EventType2["REGISTRATION"] = "$registration";
1426
+ EventType2["TRANSACTION"] = "$transaction";
1427
+ return EventType2;
1428
+ })(EventType || {});
1429
+ var EventStatus = /* @__PURE__ */ ((EventStatus2) => {
1430
+ EventStatus2["ATTEMPTED"] = "$attempted";
1431
+ EventStatus2["FAILED"] = "$failed";
1432
+ EventStatus2["REQUESTED"] = "$requested";
1433
+ EventStatus2["SUCCEEDED"] = "$succeeded";
1434
+ return EventStatus2;
1435
+ })(EventStatus || {});
1436
+
1437
+ // src/models/action.ts
1438
+ var Action = /* @__PURE__ */ ((Action2) => {
1439
+ Action2["allow"] = "allow";
1440
+ Action2["deny"] = "deny";
1441
+ Action2["challenge"] = "challenge";
1442
+ return Action2;
1443
+ })(Action || {});
1444
+
1445
+ // src/payload/models/event_payload.ts
1446
+ var SearchEventsQueryType = /* @__PURE__ */ ((SearchEventsQueryType2) => {
1447
+ SearchEventsQueryType2["COUNT"] = "$count";
1448
+ SearchEventsQueryType2["RECORDS"] = "$records";
1449
+ SearchEventsQueryType2["RECORDS_WITH_COUNT"] = "$records_with_count";
1450
+ return SearchEventsQueryType2;
1451
+ })(SearchEventsQueryType || {});
1452
+ var SearchEventsQueryFilterOperator = /* @__PURE__ */ ((SearchEventsQueryFilterOperator2) => {
1453
+ SearchEventsQueryFilterOperator2["IN"] = "$in";
1454
+ SearchEventsQueryFilterOperator2["NIN"] = "$nin";
1455
+ SearchEventsQueryFilterOperator2["EQ"] = "$eq";
1456
+ SearchEventsQueryFilterOperator2["NEQ"] = "$neq";
1457
+ SearchEventsQueryFilterOperator2["LIKE"] = "$like";
1458
+ SearchEventsQueryFilterOperator2["NLIKE"] = "$nlike";
1459
+ SearchEventsQueryFilterOperator2["CONTAINS"] = "$contains";
1460
+ SearchEventsQueryFilterOperator2["NCONTAINS"] = "$ncontains";
1461
+ SearchEventsQueryFilterOperator2["STARTS_WITH"] = "$starts_with";
1462
+ SearchEventsQueryFilterOperator2["NSTARTS_WITH"] = "$nstarts_with";
1463
+ SearchEventsQueryFilterOperator2["ENDS_WITH"] = "$ends_with";
1464
+ SearchEventsQueryFilterOperator2["NENDS_WITH"] = "$nends_with";
1465
+ SearchEventsQueryFilterOperator2["MATCHES"] = "$matches";
1466
+ SearchEventsQueryFilterOperator2["NMATCHES"] = "$nmatches";
1467
+ SearchEventsQueryFilterOperator2["IP_RANGE"] = "$ip_range";
1468
+ SearchEventsQueryFilterOperator2["NIP_RANGE"] = "$nip_range";
1469
+ return SearchEventsQueryFilterOperator2;
1470
+ })(SearchEventsQueryFilterOperator || {});
1471
+
1472
+ // src/payload/models/event_response.ts
1473
+ var EventSignal = /* @__PURE__ */ ((EventSignal2) => {
1474
+ EventSignal2["ABUSE_IP"] = "abuse_ip";
1475
+ EventSignal2["BOT_BEHAVIOR"] = "bot_behavior";
1476
+ EventSignal2["CREDENTIAL_STUFFING"] = "credential_stuffing";
1477
+ EventSignal2["DISPOSABLE_EMAIL_DOMAIN"] = "disposable_email_domain";
1478
+ EventSignal2["GENERATED_EMAIL"] = "generated_email";
1479
+ EventSignal2["HEADLESS_BROWSER"] = "headless_browser";
1480
+ EventSignal2["HTTP_CLIENT_LIBRARY"] = "http_client_library";
1481
+ EventSignal2["IMPOSSIBLE_TRAVEL"] = "impossible_travel";
1482
+ EventSignal2["INVALID_EMAIL"] = "invalid_email";
1483
+ EventSignal2["INVALID_DEVICE_DATA"] = "invalid_device_data";
1484
+ EventSignal2["MISSING_DEVICE_DATA"] = "missing_device_data";
1485
+ EventSignal2["MISSING_HEADERS"] = "missing_headers";
1486
+ EventSignal2["MULTIPLE_ACCOUNTS_PER_DEVICE"] = "multiple_accounts_per_device";
1487
+ EventSignal2["MULTIPLE_ALIASES_PER_EMAIL"] = "multiple_aliases_per_email";
1488
+ EventSignal2["NEW_COUNTRY"] = "new_country";
1489
+ EventSignal2["NEW_DEVICE"] = "new_device";
1490
+ EventSignal2["NEW_DEVICE_TYPE"] = "new_device_type";
1491
+ EventSignal2["NEW_ISP"] = "new_isp";
1492
+ EventSignal2["NEW_LANGUAGE"] = "new_language";
1493
+ EventSignal2["NEW_OS"] = "new_os";
1494
+ EventSignal2["HIGH_ACTIVITY_DEVICE"] = "high_activity_device";
1495
+ EventSignal2["HIGH_ACTIVITY_IP"] = "high_activity_ip";
1496
+ EventSignal2["HIGH_ACTIVITY_ACCOUNT"] = "high_activity_account";
1497
+ EventSignal2["SPOOFED_DEVICE"] = "spoofed_device";
1498
+ EventSignal2["WEB_CRAWLER"] = "web_crawler";
1499
+ return EventSignal2;
1500
+ })(EventSignal || {});
1501
+ var EventAuthenticationMethod = /* @__PURE__ */ ((EventAuthenticationMethod2) => {
1502
+ EventAuthenticationMethod2["AUTHENTICATOR"] = "$authenticator";
1503
+ EventAuthenticationMethod2["BIOMETRICS"] = "$biometrics";
1504
+ EventAuthenticationMethod2["EMAIL"] = "$email";
1505
+ EventAuthenticationMethod2["PASSWORD"] = "$password";
1506
+ EventAuthenticationMethod2["PHONE"] = "$phone";
1507
+ EventAuthenticationMethod2["PUSH"] = "$push";
1508
+ EventAuthenticationMethod2["SECURITY_KEY"] = "$security_key";
1509
+ EventAuthenticationMethod2["SOCIAL"] = "$social";
1510
+ EventAuthenticationMethod2["SSO"] = "$sso";
1511
+ EventAuthenticationMethod2["KBA"] = "$kba";
1512
+ EventAuthenticationMethod2["ELECTRONIC_ID"] = "$electronic_id";
1513
+ EventAuthenticationMethod2["PHYSICAL_ID"] = "$physical_id";
1514
+ EventAuthenticationMethod2["DOCUMENT"] = "$document";
1515
+ EventAuthenticationMethod2["VIDEO"] = "$video";
1516
+ EventAuthenticationMethod2["PASSKEY"] = "$passkey";
1517
+ EventAuthenticationMethod2["OTHER"] = "$other";
1518
+ return EventAuthenticationMethod2;
1519
+ })(EventAuthenticationMethod || {});
1520
+
1521
+ // src/payload/services/payload-prepare-service.ts
1522
+ var PayloadPrepareService = {
1523
+ call: (payloadParams, request, configuration, options = {}) => {
1524
+ const context = ContextPrepareService.call(
1525
+ request,
1526
+ deepMerge(payloadParams, options),
1527
+ configuration
1528
+ );
1529
+ return deepMerge(payloadParams, { context });
1530
+ }
1531
+ };
1532
+ // Annotate the CommonJS export names for ESM import in node:
1533
+ 0 && (module.exports = {
1534
+ APIError,
1535
+ Action,
1536
+ BadRequestError,
1537
+ Castle,
1538
+ ConfigurationError,
1539
+ ContextPrepareService,
1540
+ DEFAULT_ALLOWLIST,
1541
+ DEFAULT_API_URL,
1542
+ DEFAULT_TIMEOUT,
1543
+ EventAuthenticationMethod,
1544
+ EventSignal,
1545
+ EventStatus,
1546
+ EventType,
1547
+ FailoverStrategy,
1548
+ ForbiddenError,
1549
+ InternalServerError,
1550
+ InvalidParametersError,
1551
+ InvalidRequestTokenError,
1552
+ NotFoundError,
1553
+ PayloadPrepareService,
1554
+ RateLimitError,
1555
+ SearchEventsQueryFilterOperator,
1556
+ SearchEventsQueryType,
1557
+ SecureModeService,
1558
+ TRUSTED_PROXIES,
1559
+ UnauthorizedError,
1560
+ UserUnauthorizedError,
1561
+ WebhookVerificationError,
1562
+ WebhookVerifyService
1563
+ });
27
1564
  //# sourceMappingURL=index.js.map