@castleio/sdk 2.3.3 → 3.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 (381) 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 +1536 -25
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +1473 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/package.json +43 -37
  9. package/CHANGELOG.md +0 -199
  10. package/dist/Castle.d.ts +0 -36
  11. package/dist/Castle.js +0 -194
  12. package/dist/Castle.js.map +0 -1
  13. package/dist/api/api.module.d.ts +0 -1
  14. package/dist/api/api.module.js +0 -18
  15. package/dist/api/api.module.js.map +0 -1
  16. package/dist/api/services/api-approve-device.service.d.ts +0 -5
  17. package/dist/api/services/api-approve-device.service.js +0 -26
  18. package/dist/api/services/api-approve-device.service.js.map +0 -1
  19. package/dist/api/services/api-archive-list-item.service.d.ts +0 -5
  20. package/dist/api/services/api-archive-list-item.service.js +0 -26
  21. package/dist/api/services/api-archive-list-item.service.js.map +0 -1
  22. package/dist/api/services/api-authenticate.service.d.ts +0 -6
  23. package/dist/api/services/api-authenticate.service.js +0 -58
  24. package/dist/api/services/api-authenticate.service.js.map +0 -1
  25. package/dist/api/services/api-batch-upsert-list-items.service.d.ts +0 -5
  26. package/dist/api/services/api-batch-upsert-list-items.service.js +0 -26
  27. package/dist/api/services/api-batch-upsert-list-items.service.js.map +0 -1
  28. package/dist/api/services/api-count-list-items.service.d.ts +0 -5
  29. package/dist/api/services/api-count-list-items.service.js +0 -26
  30. package/dist/api/services/api-count-list-items.service.js.map +0 -1
  31. package/dist/api/services/api-create-list-item.service.d.ts +0 -5
  32. package/dist/api/services/api-create-list-item.service.js +0 -26
  33. package/dist/api/services/api-create-list-item.service.js.map +0 -1
  34. package/dist/api/services/api-create-list.service.d.ts +0 -5
  35. package/dist/api/services/api-create-list.service.js +0 -26
  36. package/dist/api/services/api-create-list.service.js.map +0 -1
  37. package/dist/api/services/api-delete-list.service.d.ts +0 -5
  38. package/dist/api/services/api-delete-list.service.js +0 -26
  39. package/dist/api/services/api-delete-list.service.js.map +0 -1
  40. package/dist/api/services/api-delete-user-data.service.d.ts +0 -5
  41. package/dist/api/services/api-delete-user-data.service.js +0 -26
  42. package/dist/api/services/api-delete-user-data.service.js.map +0 -1
  43. package/dist/api/services/api-fetch-all-lists.service.d.ts +0 -4
  44. package/dist/api/services/api-fetch-all-lists.service.js +0 -26
  45. package/dist/api/services/api-fetch-all-lists.service.js.map +0 -1
  46. package/dist/api/services/api-fetch-list-item.service.d.ts +0 -5
  47. package/dist/api/services/api-fetch-list-item.service.js +0 -26
  48. package/dist/api/services/api-fetch-list-item.service.js.map +0 -1
  49. package/dist/api/services/api-fetch-list.service.d.ts +0 -5
  50. package/dist/api/services/api-fetch-list.service.js +0 -26
  51. package/dist/api/services/api-fetch-list.service.js.map +0 -1
  52. package/dist/api/services/api-filter.service.d.ts +0 -5
  53. package/dist/api/services/api-filter.service.js +0 -57
  54. package/dist/api/services/api-filter.service.js.map +0 -1
  55. package/dist/api/services/api-get-device.service.d.ts +0 -5
  56. package/dist/api/services/api-get-device.service.js +0 -26
  57. package/dist/api/services/api-get-device.service.js.map +0 -1
  58. package/dist/api/services/api-get-devices-for-user.service.d.ts +0 -5
  59. package/dist/api/services/api-get-devices-for-user.service.js +0 -26
  60. package/dist/api/services/api-get-devices-for-user.service.js.map +0 -1
  61. package/dist/api/services/api-get-events-schema.service.d.ts +0 -5
  62. package/dist/api/services/api-get-events-schema.service.js +0 -26
  63. package/dist/api/services/api-get-events-schema.service.js.map +0 -1
  64. package/dist/api/services/api-group-events.service.d.ts +0 -5
  65. package/dist/api/services/api-group-events.service.js +0 -26
  66. package/dist/api/services/api-group-events.service.js.map +0 -1
  67. package/dist/api/services/api-log.service.d.ts +0 -5
  68. package/dist/api/services/api-log.service.js +0 -26
  69. package/dist/api/services/api-log.service.js.map +0 -1
  70. package/dist/api/services/api-report-device.service.d.ts +0 -5
  71. package/dist/api/services/api-report-device.service.js +0 -26
  72. package/dist/api/services/api-report-device.service.js.map +0 -1
  73. package/dist/api/services/api-request-user-data.service.d.ts +0 -5
  74. package/dist/api/services/api-request-user-data.service.js +0 -26
  75. package/dist/api/services/api-request-user-data.service.js.map +0 -1
  76. package/dist/api/services/api-risk.service.d.ts +0 -5
  77. package/dist/api/services/api-risk.service.js +0 -57
  78. package/dist/api/services/api-risk.service.js.map +0 -1
  79. package/dist/api/services/api-search-events.service.d.ts +0 -5
  80. package/dist/api/services/api-search-events.service.js +0 -26
  81. package/dist/api/services/api-search-events.service.js.map +0 -1
  82. package/dist/api/services/api-search-list-items.service.d.ts +0 -5
  83. package/dist/api/services/api-search-list-items.service.js +0 -26
  84. package/dist/api/services/api-search-list-items.service.js.map +0 -1
  85. package/dist/api/services/api-search-lists.service.d.ts +0 -5
  86. package/dist/api/services/api-search-lists.service.js +0 -26
  87. package/dist/api/services/api-search-lists.service.js.map +0 -1
  88. package/dist/api/services/api-track.service.d.ts +0 -5
  89. package/dist/api/services/api-track.service.js +0 -26
  90. package/dist/api/services/api-track.service.js.map +0 -1
  91. package/dist/api/services/api-unarchive-list-item.service.d.ts +0 -5
  92. package/dist/api/services/api-unarchive-list-item.service.js +0 -26
  93. package/dist/api/services/api-unarchive-list-item.service.js.map +0 -1
  94. package/dist/api/services/api-update-list-item.service.d.ts +0 -5
  95. package/dist/api/services/api-update-list-item.service.js +0 -26
  96. package/dist/api/services/api-update-list-item.service.js.map +0 -1
  97. package/dist/api/services/api-update-list.service.d.ts +0 -5
  98. package/dist/api/services/api-update-list.service.js +0 -26
  99. package/dist/api/services/api-update-list.service.js.map +0 -1
  100. package/dist/api/services/api.service.d.ts +0 -8
  101. package/dist/api/services/api.service.js +0 -40
  102. package/dist/api/services/api.service.js.map +0 -1
  103. package/dist/api/services/index.d.ts +0 -29
  104. package/dist/api/services/index.js +0 -46
  105. package/dist/api/services/index.js.map +0 -1
  106. package/dist/client-id/client-id.module.d.ts +0 -1
  107. package/dist/client-id/client-id.module.js +0 -18
  108. package/dist/client-id/client-id.module.js.map +0 -1
  109. package/dist/client-id/services/client-id-extract.service.d.ts +0 -4
  110. package/dist/client-id/services/client-id-extract.service.js +0 -12
  111. package/dist/client-id/services/client-id-extract.service.js.map +0 -1
  112. package/dist/client-id/services/index.d.ts +0 -1
  113. package/dist/client-id/services/index.js +0 -18
  114. package/dist/client-id/services/index.js.map +0 -1
  115. package/dist/command/command.module.d.ts +0 -1
  116. package/dist/command/command.module.js +0 -18
  117. package/dist/command/command.module.js.map +0 -1
  118. package/dist/command/services/command-approve-device.service.d.ts +0 -16
  119. package/dist/command/services/command-approve-device.service.js +0 -12
  120. package/dist/command/services/command-approve-device.service.js.map +0 -1
  121. package/dist/command/services/command-archive-list-item.service.d.ts +0 -16
  122. package/dist/command/services/command-archive-list-item.service.js +0 -12
  123. package/dist/command/services/command-archive-list-item.service.js.map +0 -1
  124. package/dist/command/services/command-authenticate.service.d.ts +0 -16
  125. package/dist/command/services/command-authenticate.service.js +0 -12
  126. package/dist/command/services/command-authenticate.service.js.map +0 -1
  127. package/dist/command/services/command-batch-upsert-list-items.service.d.ts +0 -16
  128. package/dist/command/services/command-batch-upsert-list-items.service.js +0 -12
  129. package/dist/command/services/command-batch-upsert-list-items.service.js.map +0 -1
  130. package/dist/command/services/command-count-list-items.service.d.ts +0 -16
  131. package/dist/command/services/command-count-list-items.service.js +0 -12
  132. package/dist/command/services/command-count-list-items.service.js.map +0 -1
  133. package/dist/command/services/command-create-list-item.service.d.ts +0 -16
  134. package/dist/command/services/command-create-list-item.service.js +0 -12
  135. package/dist/command/services/command-create-list-item.service.js.map +0 -1
  136. package/dist/command/services/command-create-list.service.d.ts +0 -16
  137. package/dist/command/services/command-create-list.service.js +0 -10
  138. package/dist/command/services/command-create-list.service.js.map +0 -1
  139. package/dist/command/services/command-delete-list.service.d.ts +0 -16
  140. package/dist/command/services/command-delete-list.service.js +0 -12
  141. package/dist/command/services/command-delete-list.service.js.map +0 -1
  142. package/dist/command/services/command-delete-user-data.service.d.ts +0 -16
  143. package/dist/command/services/command-delete-user-data.service.js +0 -10
  144. package/dist/command/services/command-delete-user-data.service.js.map +0 -1
  145. package/dist/command/services/command-fetch-all-lists.service.d.ts +0 -15
  146. package/dist/command/services/command-fetch-all-lists.service.js +0 -10
  147. package/dist/command/services/command-fetch-all-lists.service.js.map +0 -1
  148. package/dist/command/services/command-fetch-list-item.service.d.ts +0 -16
  149. package/dist/command/services/command-fetch-list-item.service.js +0 -12
  150. package/dist/command/services/command-fetch-list-item.service.js.map +0 -1
  151. package/dist/command/services/command-fetch-list.service.d.ts +0 -16
  152. package/dist/command/services/command-fetch-list.service.js +0 -12
  153. package/dist/command/services/command-fetch-list.service.js.map +0 -1
  154. package/dist/command/services/command-filter.service.d.ts +0 -16
  155. package/dist/command/services/command-filter.service.js +0 -12
  156. package/dist/command/services/command-filter.service.js.map +0 -1
  157. package/dist/command/services/command-generate.service.d.ts +0 -17
  158. package/dist/command/services/command-generate.service.js +0 -18
  159. package/dist/command/services/command-generate.service.js.map +0 -1
  160. package/dist/command/services/command-get-device.service.d.ts +0 -16
  161. package/dist/command/services/command-get-device.service.js +0 -12
  162. package/dist/command/services/command-get-device.service.js.map +0 -1
  163. package/dist/command/services/command-get-devices-for-user.service.d.ts +0 -16
  164. package/dist/command/services/command-get-devices-for-user.service.js +0 -12
  165. package/dist/command/services/command-get-devices-for-user.service.js.map +0 -1
  166. package/dist/command/services/command-get-events-schema.service.d.ts +0 -15
  167. package/dist/command/services/command-get-events-schema.service.js +0 -10
  168. package/dist/command/services/command-get-events-schema.service.js.map +0 -1
  169. package/dist/command/services/command-group-events.service.d.ts +0 -16
  170. package/dist/command/services/command-group-events.service.js +0 -10
  171. package/dist/command/services/command-group-events.service.js.map +0 -1
  172. package/dist/command/services/command-log.service.d.ts +0 -16
  173. package/dist/command/services/command-log.service.js +0 -12
  174. package/dist/command/services/command-log.service.js.map +0 -1
  175. package/dist/command/services/command-report-device.service.d.ts +0 -16
  176. package/dist/command/services/command-report-device.service.js +0 -12
  177. package/dist/command/services/command-report-device.service.js.map +0 -1
  178. package/dist/command/services/command-request-user-data.service.d.ts +0 -16
  179. package/dist/command/services/command-request-user-data.service.js +0 -10
  180. package/dist/command/services/command-request-user-data.service.js.map +0 -1
  181. package/dist/command/services/command-risk.service.d.ts +0 -16
  182. package/dist/command/services/command-risk.service.js +0 -12
  183. package/dist/command/services/command-risk.service.js.map +0 -1
  184. package/dist/command/services/command-search-events.service.d.ts +0 -16
  185. package/dist/command/services/command-search-events.service.js +0 -10
  186. package/dist/command/services/command-search-events.service.js.map +0 -1
  187. package/dist/command/services/command-search-list-items.service.d.ts +0 -16
  188. package/dist/command/services/command-search-list-items.service.js +0 -12
  189. package/dist/command/services/command-search-list-items.service.js.map +0 -1
  190. package/dist/command/services/command-search-lists.service.d.ts +0 -16
  191. package/dist/command/services/command-search-lists.service.js +0 -10
  192. package/dist/command/services/command-search-lists.service.js.map +0 -1
  193. package/dist/command/services/command-track.service.d.ts +0 -16
  194. package/dist/command/services/command-track.service.js +0 -12
  195. package/dist/command/services/command-track.service.js.map +0 -1
  196. package/dist/command/services/command-unarchive-list-item.service.d.ts +0 -16
  197. package/dist/command/services/command-unarchive-list-item.service.js +0 -12
  198. package/dist/command/services/command-unarchive-list-item.service.js.map +0 -1
  199. package/dist/command/services/command-update-list-item.service.d.ts +0 -16
  200. package/dist/command/services/command-update-list-item.service.js +0 -12
  201. package/dist/command/services/command-update-list-item.service.js.map +0 -1
  202. package/dist/command/services/command-update-list.service.d.ts +0 -16
  203. package/dist/command/services/command-update-list.service.js +0 -12
  204. package/dist/command/services/command-update-list.service.js.map +0 -1
  205. package/dist/command/services/index.d.ts +0 -29
  206. package/dist/command/services/index.js +0 -46
  207. package/dist/command/services/index.js.map +0 -1
  208. package/dist/configuration.d.ts +0 -32
  209. package/dist/configuration.js +0 -34
  210. package/dist/configuration.js.map +0 -1
  211. package/dist/constants.d.ts +0 -4
  212. package/dist/constants.js +0 -42
  213. package/dist/constants.js.map +0 -1
  214. package/dist/context/context.module.d.ts +0 -1
  215. package/dist/context/context.module.js +0 -18
  216. package/dist/context/context.module.js.map +0 -1
  217. package/dist/context/services/context-get-default.service.d.ts +0 -9
  218. package/dist/context/services/context-get-default.service.js +0 -34
  219. package/dist/context/services/context-get-default.service.js.map +0 -1
  220. package/dist/context/services/context-prepare.service.d.ts +0 -9
  221. package/dist/context/services/context-prepare.service.js +0 -15
  222. package/dist/context/services/context-prepare.service.js.map +0 -1
  223. package/dist/context/services/context-sanitize.service.d.ts +0 -7
  224. package/dist/context/services/context-sanitize.service.js +0 -19
  225. package/dist/context/services/context-sanitize.service.js.map +0 -1
  226. package/dist/context/services/index.d.ts +0 -3
  227. package/dist/context/services/index.js +0 -20
  228. package/dist/context/services/index.js.map +0 -1
  229. package/dist/core/core.module.d.ts +0 -1
  230. package/dist/core/core.module.js +0 -18
  231. package/dist/core/core.module.js.map +0 -1
  232. package/dist/core/services/core-generate-default-headers.service.d.ts +0 -7
  233. package/dist/core/services/core-generate-default-headers.service.js +0 -12
  234. package/dist/core/services/core-generate-default-headers.service.js.map +0 -1
  235. package/dist/core/services/core-generate-request-body.service.d.ts +0 -5
  236. package/dist/core/services/core-generate-request-body.service.js +0 -9
  237. package/dist/core/services/core-generate-request-body.service.js.map +0 -1
  238. package/dist/core/services/core-process-response.service.d.ts +0 -3
  239. package/dist/core/services/core-process-response.service.js +0 -61
  240. package/dist/core/services/core-process-response.service.js.map +0 -1
  241. package/dist/core/services/index.d.ts +0 -3
  242. package/dist/core/services/index.js +0 -20
  243. package/dist/core/services/index.js.map +0 -1
  244. package/dist/errors.d.ts +0 -36
  245. package/dist/errors.js +0 -88
  246. package/dist/errors.js.map +0 -1
  247. package/dist/failover/failover.module.d.ts +0 -1
  248. package/dist/failover/failover.module.js +0 -18
  249. package/dist/failover/failover.module.js.map +0 -1
  250. package/dist/failover/models/failover-strategy.d.ts +0 -6
  251. package/dist/failover/models/failover-strategy.js +0 -11
  252. package/dist/failover/models/failover-strategy.js.map +0 -1
  253. package/dist/failover/models/index.d.ts +0 -1
  254. package/dist/failover/models/index.js +0 -18
  255. package/dist/failover/models/index.js.map +0 -1
  256. package/dist/headers/headers.module.d.ts +0 -1
  257. package/dist/headers/headers.module.js +0 -18
  258. package/dist/headers/headers.module.js.map +0 -1
  259. package/dist/headers/services/headers-extract.service.d.ts +0 -9
  260. package/dist/headers/services/headers-extract.service.js +0 -30
  261. package/dist/headers/services/headers-extract.service.js.map +0 -1
  262. package/dist/headers/services/headers-get-cookie.service.d.ts +0 -3
  263. package/dist/headers/services/headers-get-cookie.service.js +0 -17
  264. package/dist/headers/services/headers-get-cookie.service.js.map +0 -1
  265. package/dist/headers/services/index.d.ts +0 -2
  266. package/dist/headers/services/index.js +0 -19
  267. package/dist/headers/services/index.js.map +0 -1
  268. package/dist/ips/ips.module.d.ts +0 -1
  269. package/dist/ips/ips.module.js +0 -18
  270. package/dist/ips/ips.module.js.map +0 -1
  271. package/dist/ips/services/index.d.ts +0 -1
  272. package/dist/ips/services/index.js +0 -18
  273. package/dist/ips/services/index.js.map +0 -1
  274. package/dist/ips/services/ips-extract.service.d.ts +0 -5
  275. package/dist/ips/services/ips-extract.service.js +0 -50
  276. package/dist/ips/services/ips-extract.service.js.map +0 -1
  277. package/dist/logger/logger.module.d.ts +0 -2
  278. package/dist/logger/logger.module.js +0 -19
  279. package/dist/logger/logger.module.js.map +0 -1
  280. package/dist/logger/models/index.d.ts +0 -1
  281. package/dist/logger/models/index.js +0 -18
  282. package/dist/logger/models/index.js.map +0 -1
  283. package/dist/logger/models/logging-parameters.d.ts +0 -7
  284. package/dist/logger/models/logging-parameters.js +0 -3
  285. package/dist/logger/models/logging-parameters.js.map +0 -1
  286. package/dist/logger/services/index.d.ts +0 -4
  287. package/dist/logger/services/index.js +0 -21
  288. package/dist/logger/services/index.js.map +0 -1
  289. package/dist/logger/services/logger-error-formatter.service.d.ts +0 -3
  290. package/dist/logger/services/logger-error-formatter.service.js +0 -10
  291. package/dist/logger/services/logger-error-formatter.service.js.map +0 -1
  292. package/dist/logger/services/logger-request-formatter.service.d.ts +0 -4
  293. package/dist/logger/services/logger-request-formatter.service.js +0 -16
  294. package/dist/logger/services/logger-request-formatter.service.js.map +0 -1
  295. package/dist/logger/services/logger-response-formatter.service.d.ts +0 -3
  296. package/dist/logger/services/logger-response-formatter.service.js +0 -10
  297. package/dist/logger/services/logger-response-formatter.service.js.map +0 -1
  298. package/dist/logger/services/logger.service.d.ts +0 -4
  299. package/dist/logger/services/logger.service.js +0 -25
  300. package/dist/logger/services/logger.service.js.map +0 -1
  301. package/dist/models/action.d.ts +0 -5
  302. package/dist/models/action.js +0 -10
  303. package/dist/models/action.js.map +0 -1
  304. package/dist/models/authenticate-result.d.ts +0 -18
  305. package/dist/models/authenticate-result.js +0 -3
  306. package/dist/models/authenticate-result.js.map +0 -1
  307. package/dist/models/device.d.ts +0 -3
  308. package/dist/models/device.js +0 -3
  309. package/dist/models/device.js.map +0 -1
  310. package/dist/models/events.d.ts +0 -17
  311. package/dist/models/events.js +0 -23
  312. package/dist/models/events.js.map +0 -1
  313. package/dist/models/index.d.ts +0 -8
  314. package/dist/models/index.js +0 -25
  315. package/dist/models/index.js.map +0 -1
  316. package/dist/models/list-item.d.ts +0 -15
  317. package/dist/models/list-item.js +0 -3
  318. package/dist/models/list-item.js.map +0 -1
  319. package/dist/models/list.d.ts +0 -11
  320. package/dist/models/list.js +0 -3
  321. package/dist/models/list.js.map +0 -1
  322. package/dist/models/risk-policy.d.ts +0 -9
  323. package/dist/models/risk-policy.js +0 -3
  324. package/dist/models/risk-policy.js.map +0 -1
  325. package/dist/models/signals.d.ts +0 -3
  326. package/dist/models/signals.js +0 -3
  327. package/dist/models/signals.js.map +0 -1
  328. package/dist/payload/models/address_payload.d.ts +0 -8
  329. package/dist/payload/models/address_payload.js +0 -3
  330. package/dist/payload/models/address_payload.js.map +0 -1
  331. package/dist/payload/models/device_payload.d.ts +0 -7
  332. package/dist/payload/models/device_payload.js +0 -3
  333. package/dist/payload/models/device_payload.js.map +0 -1
  334. package/dist/payload/models/event_payload.d.ts +0 -89
  335. package/dist/payload/models/event_payload.js +0 -29
  336. package/dist/payload/models/event_payload.js.map +0 -1
  337. package/dist/payload/models/event_response.d.ts +0 -346
  338. package/dist/payload/models/event_response.js +0 -51
  339. package/dist/payload/models/event_response.js.map +0 -1
  340. package/dist/payload/models/filter_payload.d.ts +0 -68
  341. package/dist/payload/models/filter_payload.js +0 -3
  342. package/dist/payload/models/filter_payload.js.map +0 -1
  343. package/dist/payload/models/index.d.ts +0 -11
  344. package/dist/payload/models/index.js +0 -28
  345. package/dist/payload/models/index.js.map +0 -1
  346. package/dist/payload/models/list-payload.d.ts +0 -26
  347. package/dist/payload/models/list-payload.js +0 -3
  348. package/dist/payload/models/list-payload.js.map +0 -1
  349. package/dist/payload/models/list_item_payload.d.ts +0 -45
  350. package/dist/payload/models/list_item_payload.js +0 -3
  351. package/dist/payload/models/list_item_payload.js.map +0 -1
  352. package/dist/payload/models/log_payload.d.ts +0 -42
  353. package/dist/payload/models/log_payload.js +0 -3
  354. package/dist/payload/models/log_payload.js.map +0 -1
  355. package/dist/payload/models/payload.d.ts +0 -15
  356. package/dist/payload/models/payload.js +0 -3
  357. package/dist/payload/models/payload.js.map +0 -1
  358. package/dist/payload/models/privacy_payload.d.ts +0 -8
  359. package/dist/payload/models/privacy_payload.js +0 -3
  360. package/dist/payload/models/privacy_payload.js.map +0 -1
  361. package/dist/payload/models/risk_payload.d.ts +0 -75
  362. package/dist/payload/models/risk_payload.js +0 -3
  363. package/dist/payload/models/risk_payload.js.map +0 -1
  364. package/dist/payload/payload.module.d.ts +0 -2
  365. package/dist/payload/payload.module.js +0 -19
  366. package/dist/payload/payload.module.js.map +0 -1
  367. package/dist/payload/services/index.d.ts +0 -1
  368. package/dist/payload/services/index.js +0 -18
  369. package/dist/payload/services/index.js.map +0 -1
  370. package/dist/payload/services/payload-prepare-service.d.ts +0 -13
  371. package/dist/payload/services/payload-prepare-service.js +0 -15
  372. package/dist/payload/services/payload-prepare-service.js.map +0 -1
  373. package/dist/validator/services/index.d.ts +0 -1
  374. package/dist/validator/services/index.js +0 -18
  375. package/dist/validator/services/index.js.map +0 -1
  376. package/dist/validator/services/validator-present.service.d.ts +0 -3
  377. package/dist/validator/services/validator-present.service.js +0 -15
  378. package/dist/validator/services/validator-present.service.js.map +0 -1
  379. package/dist/validator/validator.module.d.ts +0 -1
  380. package/dist/validator/validator.module.js +0 -18
  381. package/dist/validator/validator.module.js.map +0 -1
package/README.md CHANGED
@@ -1,60 +1,381 @@
1
1
  # Castle SDK for Node
2
2
 
3
- **[Castle](https://castle.io) analyzes user behavior in web and mobile apps to stop fraud before it happens.**
3
+ [![Test](https://github.com/castle/castle-node/actions/workflows/test.yml/badge.svg)](https://github.com/castle/castle-node/actions/workflows/test.yml)
4
+ [![Lint](https://github.com/castle/castle-node/actions/workflows/lint.yml/badge.svg)](https://github.com/castle/castle-node/actions/workflows/lint.yml)
5
+ [![npm version](https://img.shields.io/npm/v/@castleio/sdk.svg)](https://www.npmjs.com/package/@castleio/sdk)
4
6
 
5
- ## Usage
7
+ The official Node.js SDK for [Castle](https://castle.io). Castle analyzes user behavior in web and mobile apps to stop fraud before it happens.
6
8
 
7
- See the [documentation](https://docs.castle.io) for how to use this SDK with the Castle APIs
9
+ This package is a thin, dependency-light wrapper around the [Castle HTTP API](https://reference.castle.io). It exposes:
8
10
 
9
- ## Installation
11
+ - **Risk assessment** — `POST /v1/risk`, `POST /v1/filter`
12
+ - **Event logging** — `POST /v1/log` (fire-and-forget, no verdict)
13
+ - **Lists & List Items** — full CRUD + search + count + batch
14
+ - **Privacy / GDPR** — `POST` and `DELETE /v1/privacy/users` (Article 15 & 17)
15
+ - **Events** (enterprise) — search, group, and schema
16
+ - **Webhook signature verification** — validate `X-Castle-Signature`
17
+ - **Secure mode** — sign user IDs sent from the browser
18
+
19
+ A full list of supported events and the JSON shape of every payload is documented at <https://reference.castle.io>.
20
+
21
+ ## Requirements
10
22
 
11
- Add the `@castleio/sdk` package to your `package.json`.
23
+ - Node.js `>= 20` (the SDK uses the built-in global `fetch` / `AbortSignal`)
24
+ - A [Castle](https://dashboard.castle.io) API secret
25
+
26
+ The package ships both ESM and CommonJS builds, so both `import` and `require` work out of the box.
27
+
28
+ ## Installation
12
29
 
13
- ### yarn
30
+ ```bash
31
+ npm install --save @castleio/sdk
32
+ ```
14
33
 
15
34
  ```bash
16
35
  yarn add @castleio/sdk
17
36
  ```
18
37
 
19
- ### npm
38
+ ## Quick start
20
39
 
21
- ```bash
22
- npm install --save @castleio/sdk
40
+ ```js
41
+ import { Castle, ContextPrepareService } from '@castleio/sdk';
42
+
43
+ const castle = new Castle({ apiSecret: process.env.CASTLE_API_SECRET });
44
+
45
+ const context = ContextPrepareService.call(
46
+ req,
47
+ undefined,
48
+ castle.configuration
49
+ );
50
+
51
+ const verdict = await castle.risk({
52
+ type: '$login',
53
+ status: '$succeeded',
54
+ request_token: req.body.castle_request_token,
55
+ user: { id: '12345', email: 'user@example.com' },
56
+ context,
57
+ });
58
+
59
+ switch (verdict.policy?.action) {
60
+ case 'deny':
61
+ // block the user
62
+ break;
63
+ case 'challenge':
64
+ // send 2FA / additional verification
65
+ break;
66
+ default:
67
+ // allow
68
+ }
69
+ ```
70
+
71
+ With CommonJS:
72
+
73
+ ```js
74
+ const { Castle, ContextPrepareService } = require('@castleio/sdk');
23
75
  ```
24
76
 
77
+ `ContextPrepareService.call(request, options, configuration)` extracts the IP and headers that Castle needs from a Node `request` object. See [Advanced configuration](#advanced-configuration) for how header allow/deny lists and proxy chains are resolved.
78
+
25
79
  ## Configuration
26
80
 
27
- ### Framework configuration
81
+ The library is configured per `Castle` instance:
82
+
83
+ ```js
84
+ import { Castle, FailoverStrategy } from '@castleio/sdk';
85
+
86
+ const castle = new Castle({
87
+ apiSecret: process.env.CASTLE_API_SECRET,
88
+
89
+ // Automatic verdict from `risk`/`filter` when Castle is unreachable or
90
+ // times out. One of FailoverStrategy.allow (default), .deny, .challenge.
91
+ failoverStrategy: FailoverStrategy.allow,
92
+
93
+ // Request timeout in milliseconds before the failover strategy kicks in.
94
+ timeout: 1500,
95
+
96
+ // Logs Castle API requests and responses; must respond to `info`.
97
+ logger: console,
98
+ });
99
+ ```
100
+
101
+ ### Config options
102
+
103
+ | Option | Type | Default | Description |
104
+ | ------------------- | ---------------------- | -------------------------- | --------------------------------------------------------------------------------------------------------------- |
105
+ | `apiSecret` | `string` | | API secret from the [dashboard](https://dashboard.castle.io/settings/general). |
106
+ | `timeout` | `number` | `1500` | Time in ms before returning the failover strategy. |
107
+ | `failoverStrategy` | `FailoverStrategy` | `FailoverStrategy.allow` | Automatic `risk` response on timeout: `allow`, `deny`, or `challenge`. |
108
+ | `logger` | `object` | | Logs Castle API requests/responses; must respond to `info`. |
109
+ | `doNotTrack` | `boolean` | `false` | When `true`, suppresses all requests and triggers failover on `risk`. Useful in development and testing. |
110
+ | `allowlisted` | `string[]` | `[]` | Strict header allow-list (see [Header allow/deny lists](#header-allowdeny-lists)). |
111
+ | `denylisted` | `string[]` | `[]` | Headers to always scrub, in addition to the always-blocked `Cookie` / `Authorization`. |
112
+ | `ipHeaders` | `string[]` | `[]` | Custom headers to read the client IP from (see [Client IP detection](#client-ip-detection)). |
113
+ | `trustedProxies` | `(string \| RegExp)[]` | `[]` | Known proxy IPs (strings or regexes). Pick this **or** `trustedProxyDepth`, never both. |
114
+ | `trustedProxyDepth` | `number` | `0` | Number of known trusted proxies in the chain. Pick this **or** `trustedProxies`, never both. |
115
+ | `trustProxyChain` | `boolean` | `false` | Trust the entire `X-Forwarded-For` chain. **Warning:** promiscuous — a malicious proxy can spoof the client IP. |
116
+ | `baseUrl` | `string` | `https://api.castle.io/v1` | Base Castle API URL. |
117
+
118
+ ### Multi-environment / multi-tenant
119
+
120
+ Each `Castle` instance carries its own configuration, so multiple environments or tenants are just multiple instances:
121
+
122
+ ```js
123
+ const castleTenantA = new Castle({
124
+ apiSecret: process.env.CASTLE_API_SECRET_TENANT_A,
125
+ });
126
+ const castleTenantB = new Castle({
127
+ apiSecret: process.env.CASTLE_API_SECRET_TENANT_B,
128
+ });
129
+ ```
130
+
131
+ ## Usage
132
+
133
+ All endpoints are async methods on a `Castle` instance.
134
+
135
+ ### Risk
136
+
137
+ Evaluates high-risk events (logins, registrations, password resets, transactions). Returns a verdict (`policy.action`) plus risk scores and signals.
138
+
139
+ ```js
140
+ await castle.risk({
141
+ type: '$login',
142
+ status: '$succeeded',
143
+ request_token: req.body.castle_request_token,
144
+ user: { id: '12345', email: 'user@example.com' },
145
+ context,
146
+ });
147
+ ```
148
+
149
+ ### Filter
150
+
151
+ Blocks bots and bad traffic early in the chain (typically registration). Same response shape as Risk.
152
+
153
+ ```js
154
+ await castle.filter({
155
+ type: '$registration',
156
+ status: '$attempted',
157
+ request_token: req.body.castle_request_token,
158
+ params: { email: 'user@example.com' },
159
+ context,
160
+ });
161
+ ```
162
+
163
+ ### Log
164
+
165
+ Fire-and-forget event logging; no verdict is returned. Useful for events that should be visible in the dashboard but don't need a real-time decision.
166
+
167
+ ```js
168
+ await castle.log({
169
+ type: '$profile_update',
170
+ status: '$succeeded',
171
+ user: { id: '12345' },
172
+ context,
173
+ });
174
+ ```
175
+
176
+ ### Lists & List Items
177
+
178
+ Lists let you organize users, IPs, transactions, or any custom property and use them in policies as allow/deny lists:
179
+
180
+ ```js
181
+ const list = await castle.createList({
182
+ name: 'Trusted IPs',
183
+ color: 'green',
184
+ primary_field: 'ip.address',
185
+ });
186
+
187
+ await castle.createListItem({
188
+ list_id: list.id,
189
+ primary_value: '1.2.3.4',
190
+ author: { type: '$analyst_email', identifier: 'analyst@example.com' },
191
+ });
192
+
193
+ await castle.searchListItems({
194
+ list_id: list.id,
195
+ filters: [{ field: 'primary_value', op: '$eq', value: '1.2.3.4' }],
196
+ });
197
+ ```
198
+
199
+ Available methods: `createList`, `fetchAllLists`, `fetchList`, `updateList`, `deleteList`, `searchLists`, `createListItem`, `batchUpdateListItems`, `fetchListItem`, `searchListItems`, `countListItems`, `updateListItem`, `archiveListItem`, `unarchiveListItem`.
200
+
201
+ ### Privacy (GDPR)
202
+
203
+ Supports GDPR Articles 15 (right of access) and 17 (right to be forgotten) via `/v1/privacy/users`. Both take an `identifier` and `identifier_type` (`$id` or `$email`):
204
+
205
+ ```js
206
+ await castle.requestUserData({
207
+ identifier: 'rhea@example.org',
208
+ identifier_type: '$email',
209
+ });
210
+
211
+ await castle.deleteUserData({
212
+ identifier: 'user_42',
213
+ identifier_type: '$id',
214
+ });
215
+ ```
216
+
217
+ ### Events (enterprise)
218
+
219
+ Query, group, and inspect the schema of stored events. Use `queryEvents`,
220
+ `groupEvents`, and `eventsSchema`:
221
+
222
+ ```js
223
+ await castle.queryEvents({
224
+ filters: [
225
+ /* ... */
226
+ ],
227
+ });
228
+ await castle.groupEvents({
229
+ filters: [],
230
+ group_by: { fields: [] },
231
+ columns: [],
232
+ });
233
+ await castle.eventsSchema();
234
+ ```
235
+
236
+ `searchEvents` and `getEventsSchema` are also available as aliases of
237
+ `queryEvents` and `eventsSchema`.
238
+
239
+ ### Webhook signature verification
240
+
241
+ Castle signs every webhook with an `X-Castle-Signature` header. Verify it against the **raw** request body before trusting the payload — `verifyWebhookSignature` throws a `WebhookVerificationError` on mismatch:
242
+
243
+ ```js
244
+ import express from 'express';
245
+ import { WebhookVerificationError } from '@castleio/sdk';
246
+
247
+ const app = express();
248
+
249
+ // The signature is computed over the raw body, so capture it as a Buffer.
250
+ app.post(
251
+ '/castle/webhooks',
252
+ express.raw({ type: 'application/json' }),
253
+ (req, res) => {
254
+ try {
255
+ castle.verifyWebhookSignature(req.body, req.get('x-castle-signature'));
256
+ } catch (err) {
257
+ if (err instanceof WebhookVerificationError) {
258
+ return res.sendStatus(400);
259
+ }
260
+ throw err;
261
+ }
262
+
263
+ const event = JSON.parse(req.body.toString());
264
+ // signature is valid; proceed
265
+ res.sendStatus(200);
266
+ }
267
+ );
268
+ ```
269
+
270
+ ### Secure mode
271
+
272
+ Secure mode signs the user id server-side so it can't be tampered with in the browser. Pass the signature to the client-side `castle.js` SDK:
273
+
274
+ ```js
275
+ const signature = castle.secureModeSignature('user_123');
276
+ ```
277
+
278
+ The signature is a hex HMAC-SHA256 of the user id keyed with your API secret.
28
279
 
29
- Load and configure the library with your Castle API secret in an initializer or similar.
280
+ ## Advanced configuration
281
+
282
+ The defaults are good for most deployments. The options below only matter if you have a non-trivial proxy chain or strict header policies.
283
+
284
+ ### Header allow/deny lists
285
+
286
+ By default the SDK sends every HTTP header except `Cookie` and `Authorization`. Castle uses these headers to fingerprint the request, so the broader the better.
30
287
 
31
288
  ```js
32
- import { Castle } from '@castleio/sdk';
289
+ import { DEFAULT_ALLOWLIST } from '@castleio/sdk';
290
+
291
+ const castle = new Castle({
292
+ apiSecret: process.env.CASTLE_API_SECRET,
33
293
 
34
- const castle = new Castle({ apiSecret: 'YOUR SECRET HERE' });
294
+ // Always-blocked headers (in addition to Cookie/Authorization).
295
+ denylisted: ['X-Internal-Header'],
296
+
297
+ // Strict allow-list mode. Headers outside the list are sent with scrubbed
298
+ // values, except User-Agent which is always preserved. If you must use an
299
+ // allow list, we recommend starting from the curated default.
300
+ allowlisted: DEFAULT_ALLOWLIST,
301
+ });
35
302
  ```
36
303
 
37
- When using setup without the modules:
304
+ Header names are case-insensitive and accept both `_` and `-` as separators. A leading `HTTP_` prefix is stripped automatically.
305
+
306
+ ### Client IP detection
307
+
308
+ Castle needs the original client IP, not the IP of your proxy or load balancer. The SDK reads `X-Forwarded-For` and `Remote-Addr` by default; pick **one** of the strategies below depending on your infrastructure:
38
309
 
39
310
  ```js
40
- const { Castle } = require('@castleio/sdk');
311
+ const castle = new Castle({
312
+ apiSecret: process.env.CASTLE_API_SECRET,
41
313
 
42
- const castle = new Castle({ apiSecret: 'YOUR SECRET HERE' });
314
+ // 1. Custom header (e.g. Cloudflare's Cf-Connecting-Ip).
315
+ ipHeaders: ['Cf-Connecting-Ip'],
316
+
317
+ // 2. Static, known proxy IPs.
318
+ trustedProxies: ['10.0.0.1'],
319
+
320
+ // 3. Ephemeral proxies but known chain depth.
321
+ trustedProxyDepth: 2,
322
+
323
+ // 4. Last resort: trust the entire X-Forwarded-For chain.
324
+ // Warning: vulnerable to header spoofing if a malicious proxy is in path.
325
+ trustProxyChain: false,
326
+ });
43
327
  ```
44
328
 
45
- #### Config options
329
+ Pick **either** `trustedProxies` **or** `trustedProxyDepth`, never both. Private/loopback ranges in the exported `TRUSTED_PROXIES` constant are always considered trusted.
330
+
331
+ ## Errors
332
+
333
+ All HTTP/API exceptions inherit from `APIError`. `ConfigurationError` (setup problems) and `WebhookVerificationError` (webhook signature mismatch) extend `Error` directly. The most useful ones:
334
+
335
+ | Class | Raised when |
336
+ | -------------------------- | ------------------------------------------------------- |
337
+ | `ConfigurationError` | The SDK is misconfigured (missing API secret, bad URL). |
338
+ | `BadRequestError` | `400` response. |
339
+ | `UnauthorizedError` | `401` — bad API secret. |
340
+ | `ForbiddenError` | `403` response. |
341
+ | `NotFoundError` | `404` response. |
342
+ | `InvalidParametersError` | `422` response with validation details. |
343
+ | `InvalidRequestTokenError` | `422` — the `request_token` is missing or invalid. |
344
+ | `RateLimitError` | `429` — back off and retry. |
345
+ | `InternalServerError` | `5xx` response from Castle. |
346
+ | `WebhookVerificationError` | A webhook signature did not match. |
347
+
348
+ The full list lives in [`src/errors.ts`](src/errors.ts).
349
+
350
+ ## Upgrading to 3.0.0
351
+
352
+ `3.0.0` is a modernization release. The public API (the `Castle` class and its
353
+ methods) is unchanged — most projects can upgrade without code changes.
354
+
355
+ What changed:
356
+
357
+ - **Legacy endpoints removed.** `authenticate`, `track`, and the device
358
+ endpoints (`getDevice`, `getDevicesForUser`, `approveDevice`, `reportDevice`)
359
+ are gone — use `risk`, `filter`, and `log` instead. The matching payload types
360
+ (`Payload`, `DevicePayload`, `UserDevicePayload`, `AuthenticateResult`) were
361
+ removed too.
362
+ - If you previously used `reportDevice` / `approveDevice`, manage device
363
+ approvals and reports with the **Lists API** instead (e.g.
364
+ `createListItem` / `archiveListItem`). See
365
+ [Reporting devices using Lists](https://docs.castle.io/docs/reporting-devices-using-lists).
366
+ - **Node.js `>= 20` is now required.** The SDK uses the runtime's built-in
367
+ `fetch` and `AbortSignal` instead of `node-fetch` / `abort-controller`, which
368
+ are no longer dependencies.
369
+ - **Dual ESM + CommonJS build.** The package now exposes a proper `exports` map
370
+ with separate `import` and `require` entry points and type definitions. Deep
371
+ imports into `dist/` were never supported and remain unsupported; import from
372
+ the package root (`@castleio/sdk`).
373
+ - The `lodash.*` micro-dependencies were removed in favor of native JavaScript;
374
+ this is internal and does not affect behavior.
375
+
376
+ If you previously relied on a custom `overrideFetch`, it still works — pass any
377
+ `fetch`-compatible implementation.
378
+
379
+ ## License
46
380
 
47
- | Config option | Type | Default | Explanation |
48
- | ----------------- | ------------------ | -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
49
- | apiSecret | `string` | | API key which can be found in the Castle dashboard https://dashboard.castle.io/settings/general |
50
- | timeout | `number` | 1500 | Time before returning the failover strategy. |
51
- | allowlisted | `string[]` | [] | by default, the SDK sends all HTTP headers, except for Cookie and Authorization. <br/><br/> If you decide to use a allowlist, the SDK will:<br/>- always send the User-Agent header<br/>- send scrubbed values of non-allowlisted headers<br/>- send proper values of allowlisted headers.<br/><br/>We highly suggest using denylist instead of allowlist, so that Castle can use as many data points as possible to secure your users. If you want to use the allowlist, this is the minimal amount of headers we recommend: DEFAULT_ALLOWLIST |
52
- | denylisted | `string[]` | [] | Denylisted headers take precedence over allowlisted elements. We always denylist Cookie and Authentication headers. If you use any other headers that might contain sensitive information, you should denylist them |
53
- | failoverStrategy | `FailoverStrategy` | `FailoverStrategy.allow` | If the request to our service would for some reason time out, this is where you select the automatic response from `authenticate`. Options are `FailoverStrategy.allow`, `FailoverStrategy.deny`, `FailoverStrategy.challenge`. |
54
- | logger | `any` | | Logs Castle API requests and responses, has to respond to `info` method. |
55
- | doNotTrack | `boolean` | False | setting it to true turns off all requests and triggers automatic failover on `authenticate`. Used for development and testing. |
56
- | ipHeaders | `string[]` | [] | Castle needs the original IP of the client, not the IP of your proxy or load balancer. The SDK will only trust the proxy chain as defined in the configuration.We try to fetch the client IP based on X-Forwarded-For or Remote-Addr headers in that order, but sometimes the client IP may be stored in a different header or order. The SDK can be configured to look for the client IP address in headers that you specify.<br/>Sometimes, Cloud providers do not use consistent IP addresses to proxy requests. In this case, the client IP is usually preserved in a custom header. <br/>Example: Cloudflare preserves the client request in the 'Cf-Connecting-Ip' header. |
57
- | trustedProxies | `string[]` | [] | If the specified header or X-Forwarded-For default contains a proxy chain with public IP addresses, then you must choose only one of the following (but not both): <br/>1. The trusted_proxies value must match the known proxy IPs. This option is preferable if the IP is static. <br/>2. The trusted_proxy_depth value must be set to the number of known trusted proxies in the chain (see below).This option is preferable if the IPs are ephemeral, but the depth is consistent. <br/>Additionally to make X-Forwarded-For and other headers work better discovering client ip address,and not the address of a reverse proxy server, you can define trusted proxies which will help to fetch proper ip from those headers. <br/>In order to extract the client IP of the X-Forwarded-For header and not the address of a reverse proxy server, you must define all trusted public proxies you can achieve this by listing all the proxies ip defined by string or regular expressions in the trusted_proxies setting <br/> |
58
- | trustedProxyDepth | `number` | 0 | ...or by providing number of trusted proxies used in the chain, (note that you must pick one approach over the other. either trustProxyChain orr trustedProxies) |
59
- | trustProxyChain | `boolean` | False | If there is no possibility to define options above and there is no other header that holds the client IP, then you may set this option to True to trust all of the proxy IPs in X-Forwarded-For , _Warning_: this mode is highly promiscuous and could lead to wrongly trusting a spoofed IP if the request passes through a malicious proxy |
60
- | baseUrl | `string` | `https://api.castle.io/v1` | base Castle API url |
381
+ Available as open source under the terms of the [MIT License](LICENSE).