@trokky/trokky 2.0.3

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 (639) hide show
  1. package/dist/adapters/filesystem/filesystem-adapter.d.ts +80 -0
  2. package/dist/adapters/filesystem/filesystem-adapter.d.ts.map +1 -0
  3. package/dist/adapters/filesystem/filesystem-adapter.js +1370 -0
  4. package/dist/adapters/filesystem/filesystem-adapter.js.map +1 -0
  5. package/dist/adapters/filesystem/index.d.ts +29 -0
  6. package/dist/adapters/filesystem/index.d.ts.map +1 -0
  7. package/dist/adapters/filesystem/index.js +31 -0
  8. package/dist/adapters/filesystem/index.js.map +1 -0
  9. package/dist/adapters/filesystem/types.d.ts +111 -0
  10. package/dist/adapters/filesystem/types.d.ts.map +1 -0
  11. package/dist/adapters/filesystem/types.js +2 -0
  12. package/dist/adapters/filesystem/types.js.map +1 -0
  13. package/dist/adapters/filesystem-data/filesystem-data-adapter.d.ts +111 -0
  14. package/dist/adapters/filesystem-data/filesystem-data-adapter.d.ts.map +1 -0
  15. package/dist/adapters/filesystem-data/filesystem-data-adapter.js +1363 -0
  16. package/dist/adapters/filesystem-data/filesystem-data-adapter.js.map +1 -0
  17. package/dist/adapters/filesystem-data/index.d.ts +3 -0
  18. package/dist/adapters/filesystem-data/index.d.ts.map +1 -0
  19. package/dist/adapters/filesystem-data/index.js +13 -0
  20. package/dist/adapters/filesystem-data/index.js.map +1 -0
  21. package/dist/adapters/filesystem-data/types.d.ts +147 -0
  22. package/dist/adapters/filesystem-data/types.d.ts.map +1 -0
  23. package/dist/adapters/filesystem-data/types.js +2 -0
  24. package/dist/adapters/filesystem-data/types.js.map +1 -0
  25. package/dist/adapters/filesystem-media/filesystem-media-adapter.d.ts +32 -0
  26. package/dist/adapters/filesystem-media/filesystem-media-adapter.d.ts.map +1 -0
  27. package/dist/adapters/filesystem-media/filesystem-media-adapter.js +639 -0
  28. package/dist/adapters/filesystem-media/filesystem-media-adapter.js.map +1 -0
  29. package/dist/adapters/filesystem-media/index.d.ts +3 -0
  30. package/dist/adapters/filesystem-media/index.d.ts.map +1 -0
  31. package/dist/adapters/filesystem-media/index.js +13 -0
  32. package/dist/adapters/filesystem-media/index.js.map +1 -0
  33. package/dist/adapters/filesystem-media/types.d.ts +76 -0
  34. package/dist/adapters/filesystem-media/types.d.ts.map +1 -0
  35. package/dist/adapters/filesystem-media/types.js +2 -0
  36. package/dist/adapters/filesystem-media/types.js.map +1 -0
  37. package/dist/adapters/postgres-data/index.d.ts +3 -0
  38. package/dist/adapters/postgres-data/index.d.ts.map +1 -0
  39. package/dist/adapters/postgres-data/index.js +13 -0
  40. package/dist/adapters/postgres-data/index.js.map +1 -0
  41. package/dist/adapters/postgres-data/postgres-data-adapter.d.ts +154 -0
  42. package/dist/adapters/postgres-data/postgres-data-adapter.d.ts.map +1 -0
  43. package/dist/adapters/postgres-data/postgres-data-adapter.js +1432 -0
  44. package/dist/adapters/postgres-data/postgres-data-adapter.js.map +1 -0
  45. package/dist/adapters/postgres-data/types.d.ts +139 -0
  46. package/dist/adapters/postgres-data/types.d.ts.map +1 -0
  47. package/dist/adapters/postgres-data/types.js +2 -0
  48. package/dist/adapters/postgres-data/types.js.map +1 -0
  49. package/dist/core/adapters/registry.d.ts +79 -0
  50. package/dist/core/adapters/registry.d.ts.map +1 -0
  51. package/dist/core/adapters/registry.js +149 -0
  52. package/dist/core/adapters/registry.js.map +1 -0
  53. package/dist/core/core/engine.d.ts +551 -0
  54. package/dist/core/core/engine.d.ts.map +1 -0
  55. package/dist/core/core/engine.js +1074 -0
  56. package/dist/core/core/engine.js.map +1 -0
  57. package/dist/core/crypto/adapter.d.ts +63 -0
  58. package/dist/core/crypto/adapter.d.ts.map +1 -0
  59. package/dist/core/crypto/adapter.js +63 -0
  60. package/dist/core/crypto/adapter.js.map +1 -0
  61. package/dist/core/crypto/fallback-adapter.d.ts +23 -0
  62. package/dist/core/crypto/fallback-adapter.d.ts.map +1 -0
  63. package/dist/core/crypto/fallback-adapter.js +195 -0
  64. package/dist/core/crypto/fallback-adapter.js.map +1 -0
  65. package/dist/core/crypto/node-adapter.d.ts +20 -0
  66. package/dist/core/crypto/node-adapter.d.ts.map +1 -0
  67. package/dist/core/crypto/node-adapter.js +85 -0
  68. package/dist/core/crypto/node-adapter.js.map +1 -0
  69. package/dist/core/crypto/password-hash.d.ts +73 -0
  70. package/dist/core/crypto/password-hash.d.ts.map +1 -0
  71. package/dist/core/crypto/password-hash.js +244 -0
  72. package/dist/core/crypto/password-hash.js.map +1 -0
  73. package/dist/core/crypto/webcrypto-adapter.d.ts +24 -0
  74. package/dist/core/crypto/webcrypto-adapter.d.ts.map +1 -0
  75. package/dist/core/crypto/webcrypto-adapter.js +158 -0
  76. package/dist/core/crypto/webcrypto-adapter.js.map +1 -0
  77. package/dist/core/errors/index.d.ts +30 -0
  78. package/dist/core/errors/index.d.ts.map +1 -0
  79. package/dist/core/errors/index.js +61 -0
  80. package/dist/core/errors/index.js.map +1 -0
  81. package/dist/core/events/event-bus.d.ts +121 -0
  82. package/dist/core/events/event-bus.d.ts.map +1 -0
  83. package/dist/core/events/event-bus.js +631 -0
  84. package/dist/core/events/event-bus.js.map +1 -0
  85. package/dist/core/events/index.d.ts +17 -0
  86. package/dist/core/events/index.d.ts.map +1 -0
  87. package/dist/core/events/index.js +22 -0
  88. package/dist/core/events/index.js.map +1 -0
  89. package/dist/core/events/memory-storage.d.ts +57 -0
  90. package/dist/core/events/memory-storage.d.ts.map +1 -0
  91. package/dist/core/events/memory-storage.js +175 -0
  92. package/dist/core/events/memory-storage.js.map +1 -0
  93. package/dist/core/events/types.d.ts +434 -0
  94. package/dist/core/events/types.d.ts.map +1 -0
  95. package/dist/core/events/types.js +9 -0
  96. package/dist/core/events/types.js.map +1 -0
  97. package/dist/core/events/utils.d.ts +134 -0
  98. package/dist/core/events/utils.d.ts.map +1 -0
  99. package/dist/core/events/utils.js +333 -0
  100. package/dist/core/events/utils.js.map +1 -0
  101. package/dist/core/fields/conditional.d.ts +115 -0
  102. package/dist/core/fields/conditional.d.ts.map +1 -0
  103. package/dist/core/fields/conditional.js +296 -0
  104. package/dist/core/fields/conditional.js.map +1 -0
  105. package/dist/core/fields/field-type.d.ts +218 -0
  106. package/dist/core/fields/field-type.d.ts.map +1 -0
  107. package/dist/core/fields/field-type.js +17 -0
  108. package/dist/core/fields/field-type.js.map +1 -0
  109. package/dist/core/fields/helpers.d.ts +86 -0
  110. package/dist/core/fields/helpers.d.ts.map +1 -0
  111. package/dist/core/fields/helpers.js +260 -0
  112. package/dist/core/fields/helpers.js.map +1 -0
  113. package/dist/core/fields/index.d.ts +5 -0
  114. package/dist/core/fields/index.d.ts.map +1 -0
  115. package/dist/core/fields/index.js +6 -0
  116. package/dist/core/fields/index.js.map +1 -0
  117. package/dist/core/fields/registry.d.ts +78 -0
  118. package/dist/core/fields/registry.d.ts.map +1 -0
  119. package/dist/core/fields/registry.js +185 -0
  120. package/dist/core/fields/registry.js.map +1 -0
  121. package/dist/core/index.d.ts +39 -0
  122. package/dist/core/index.d.ts.map +1 -0
  123. package/dist/core/index.js +57 -0
  124. package/dist/core/index.js.map +1 -0
  125. package/dist/core/media/image-processor.d.ts +24 -0
  126. package/dist/core/media/image-processor.d.ts.map +1 -0
  127. package/dist/core/media/image-processor.js +69 -0
  128. package/dist/core/media/image-processor.js.map +1 -0
  129. package/dist/core/media/processors/cloudflare-images.d.ts +83 -0
  130. package/dist/core/media/processors/cloudflare-images.d.ts.map +1 -0
  131. package/dist/core/media/processors/cloudflare-images.js +241 -0
  132. package/dist/core/media/processors/cloudflare-images.js.map +1 -0
  133. package/dist/core/media/processors/cloudflare-transform-store.d.ts +127 -0
  134. package/dist/core/media/processors/cloudflare-transform-store.d.ts.map +1 -0
  135. package/dist/core/media/processors/cloudflare-transform-store.js +237 -0
  136. package/dist/core/media/processors/cloudflare-transform-store.js.map +1 -0
  137. package/dist/core/media/processors/cloudflare-transformations.d.ts +81 -0
  138. package/dist/core/media/processors/cloudflare-transformations.d.ts.map +1 -0
  139. package/dist/core/media/processors/cloudflare-transformations.js +144 -0
  140. package/dist/core/media/processors/cloudflare-transformations.js.map +1 -0
  141. package/dist/core/media/processors/index.d.ts +9 -0
  142. package/dist/core/media/processors/index.d.ts.map +1 -0
  143. package/dist/core/media/processors/index.js +13 -0
  144. package/dist/core/media/processors/index.js.map +1 -0
  145. package/dist/core/media/processors/noop.d.ts +22 -0
  146. package/dist/core/media/processors/noop.d.ts.map +1 -0
  147. package/dist/core/media/processors/noop.js +38 -0
  148. package/dist/core/media/processors/noop.js.map +1 -0
  149. package/dist/core/media/processors/sharp.d.ts +30 -0
  150. package/dist/core/media/processors/sharp.d.ts.map +1 -0
  151. package/dist/core/media/processors/sharp.js +126 -0
  152. package/dist/core/media/processors/sharp.js.map +1 -0
  153. package/dist/core/media/processors/types.d.ts +67 -0
  154. package/dist/core/media/processors/types.d.ts.map +1 -0
  155. package/dist/core/media/processors/types.js +42 -0
  156. package/dist/core/media/processors/types.js.map +1 -0
  157. package/dist/core/media/processors/workers-images.d.ts +112 -0
  158. package/dist/core/media/processors/workers-images.d.ts.map +1 -0
  159. package/dist/core/media/processors/workers-images.js +257 -0
  160. package/dist/core/media/processors/workers-images.js.map +1 -0
  161. package/dist/core/schema/registry.d.ts +41 -0
  162. package/dist/core/schema/registry.d.ts.map +1 -0
  163. package/dist/core/schema/registry.js +248 -0
  164. package/dist/core/schema/registry.js.map +1 -0
  165. package/dist/core/schema/singleton.d.ts +107 -0
  166. package/dist/core/schema/singleton.d.ts.map +1 -0
  167. package/dist/core/schema/singleton.js +180 -0
  168. package/dist/core/schema/singleton.js.map +1 -0
  169. package/dist/core/security/auth.d.ts +120 -0
  170. package/dist/core/security/auth.d.ts.map +1 -0
  171. package/dist/core/security/auth.js +274 -0
  172. package/dist/core/security/auth.js.map +1 -0
  173. package/dist/core/security/captcha/index.d.ts +21 -0
  174. package/dist/core/security/captcha/index.d.ts.map +1 -0
  175. package/dist/core/security/captcha/index.js +34 -0
  176. package/dist/core/security/captcha/index.js.map +1 -0
  177. package/dist/core/security/captcha/recaptcha.d.ts +41 -0
  178. package/dist/core/security/captcha/recaptcha.d.ts.map +1 -0
  179. package/dist/core/security/captcha/recaptcha.js +89 -0
  180. package/dist/core/security/captcha/recaptcha.js.map +1 -0
  181. package/dist/core/security/captcha/turnstile.d.ts +41 -0
  182. package/dist/core/security/captcha/turnstile.d.ts.map +1 -0
  183. package/dist/core/security/captcha/turnstile.js +90 -0
  184. package/dist/core/security/captcha/turnstile.js.map +1 -0
  185. package/dist/core/security/captcha/types.d.ts +66 -0
  186. package/dist/core/security/captcha/types.d.ts.map +1 -0
  187. package/dist/core/security/captcha/types.js +7 -0
  188. package/dist/core/security/captcha/types.js.map +1 -0
  189. package/dist/core/security/mfa/email-otp.d.ts +91 -0
  190. package/dist/core/security/mfa/email-otp.d.ts.map +1 -0
  191. package/dist/core/security/mfa/email-otp.js +264 -0
  192. package/dist/core/security/mfa/email-otp.js.map +1 -0
  193. package/dist/core/security/mfa/index.d.ts +8 -0
  194. package/dist/core/security/mfa/index.d.ts.map +1 -0
  195. package/dist/core/security/mfa/index.js +8 -0
  196. package/dist/core/security/mfa/index.js.map +1 -0
  197. package/dist/core/security/mfa/totp.d.ts +87 -0
  198. package/dist/core/security/mfa/totp.d.ts.map +1 -0
  199. package/dist/core/security/mfa/totp.js +293 -0
  200. package/dist/core/security/mfa/totp.js.map +1 -0
  201. package/dist/core/security/middleware.d.ts +102 -0
  202. package/dist/core/security/middleware.d.ts.map +1 -0
  203. package/dist/core/security/middleware.js +261 -0
  204. package/dist/core/security/middleware.js.map +1 -0
  205. package/dist/core/security/oauth/google.d.ts +76 -0
  206. package/dist/core/security/oauth/google.d.ts.map +1 -0
  207. package/dist/core/security/oauth/google.js +154 -0
  208. package/dist/core/security/oauth/google.js.map +1 -0
  209. package/dist/core/security/oauth/index.d.ts +8 -0
  210. package/dist/core/security/oauth/index.d.ts.map +1 -0
  211. package/dist/core/security/oauth/index.js +7 -0
  212. package/dist/core/security/oauth/index.js.map +1 -0
  213. package/dist/core/security/oauth2/authorization-server.d.ts +195 -0
  214. package/dist/core/security/oauth2/authorization-server.d.ts.map +1 -0
  215. package/dist/core/security/oauth2/authorization-server.js +569 -0
  216. package/dist/core/security/oauth2/authorization-server.js.map +1 -0
  217. package/dist/core/security/oauth2/index.d.ts +9 -0
  218. package/dist/core/security/oauth2/index.d.ts.map +1 -0
  219. package/dist/core/security/oauth2/index.js +9 -0
  220. package/dist/core/security/oauth2/index.js.map +1 -0
  221. package/dist/core/security/rate-limiter.d.ts +15 -0
  222. package/dist/core/security/rate-limiter.d.ts.map +1 -0
  223. package/dist/core/security/rate-limiter.js +48 -0
  224. package/dist/core/security/rate-limiter.js.map +1 -0
  225. package/dist/core/security/validation.d.ts +20 -0
  226. package/dist/core/security/validation.d.ts.map +1 -0
  227. package/dist/core/security/validation.js +273 -0
  228. package/dist/core/security/validation.js.map +1 -0
  229. package/dist/core/services/auth-service.d.ts +128 -0
  230. package/dist/core/services/auth-service.d.ts.map +1 -0
  231. package/dist/core/services/auth-service.js +530 -0
  232. package/dist/core/services/auth-service.js.map +1 -0
  233. package/dist/core/services/captcha-service.d.ts +44 -0
  234. package/dist/core/services/captcha-service.d.ts.map +1 -0
  235. package/dist/core/services/captcha-service.js +82 -0
  236. package/dist/core/services/captcha-service.js.map +1 -0
  237. package/dist/core/services/document-service.d.ts +59 -0
  238. package/dist/core/services/document-service.d.ts.map +1 -0
  239. package/dist/core/services/document-service.js +269 -0
  240. package/dist/core/services/document-service.js.map +1 -0
  241. package/dist/core/services/media-service.d.ts +40 -0
  242. package/dist/core/services/media-service.d.ts.map +1 -0
  243. package/dist/core/services/media-service.js +396 -0
  244. package/dist/core/services/media-service.js.map +1 -0
  245. package/dist/core/services/mfa-service.d.ts +123 -0
  246. package/dist/core/services/mfa-service.d.ts.map +1 -0
  247. package/dist/core/services/mfa-service.js +606 -0
  248. package/dist/core/services/mfa-service.js.map +1 -0
  249. package/dist/core/services/oauth-service.d.ts +58 -0
  250. package/dist/core/services/oauth-service.d.ts.map +1 -0
  251. package/dist/core/services/oauth-service.js +253 -0
  252. package/dist/core/services/oauth-service.js.map +1 -0
  253. package/dist/core/services/oauth2-server-service.d.ts +61 -0
  254. package/dist/core/services/oauth2-server-service.d.ts.map +1 -0
  255. package/dist/core/services/oauth2-server-service.js +259 -0
  256. package/dist/core/services/oauth2-server-service.js.map +1 -0
  257. package/dist/core/services/passkey-service.d.ts +59 -0
  258. package/dist/core/services/passkey-service.d.ts.map +1 -0
  259. package/dist/core/services/passkey-service.js +238 -0
  260. package/dist/core/services/passkey-service.js.map +1 -0
  261. package/dist/core/services/token-service.d.ts +31 -0
  262. package/dist/core/services/token-service.d.ts.map +1 -0
  263. package/dist/core/services/token-service.js +132 -0
  264. package/dist/core/services/token-service.js.map +1 -0
  265. package/dist/core/services/trusted-device-service.d.ts +39 -0
  266. package/dist/core/services/trusted-device-service.d.ts.map +1 -0
  267. package/dist/core/services/trusted-device-service.js +123 -0
  268. package/dist/core/services/trusted-device-service.js.map +1 -0
  269. package/dist/core/services/user-service.d.ts +38 -0
  270. package/dist/core/services/user-service.d.ts.map +1 -0
  271. package/dist/core/services/user-service.js +265 -0
  272. package/dist/core/services/user-service.js.map +1 -0
  273. package/dist/core/studio/integration.d.ts +54 -0
  274. package/dist/core/studio/integration.d.ts.map +1 -0
  275. package/dist/core/studio/integration.js +326 -0
  276. package/dist/core/studio/integration.js.map +1 -0
  277. package/dist/core/types/index.d.ts +282 -0
  278. package/dist/core/types/index.d.ts.map +1 -0
  279. package/dist/core/types/index.js +83 -0
  280. package/dist/core/types/index.js.map +1 -0
  281. package/dist/core/types/mail.d.ts +90 -0
  282. package/dist/core/types/mail.d.ts.map +1 -0
  283. package/dist/core/types/mail.js +7 -0
  284. package/dist/core/types/mail.js.map +1 -0
  285. package/dist/core/types/oauth2.d.ts +9 -0
  286. package/dist/core/types/oauth2.d.ts.map +1 -0
  287. package/dist/core/types/oauth2.js +7 -0
  288. package/dist/core/types/oauth2.js.map +1 -0
  289. package/dist/core/types/storage-adapters.d.ts +611 -0
  290. package/dist/core/types/storage-adapters.d.ts.map +1 -0
  291. package/dist/core/types/storage-adapters.js +14 -0
  292. package/dist/core/types/storage-adapters.js.map +1 -0
  293. package/dist/core/types/user.d.ts +10 -0
  294. package/dist/core/types/user.d.ts.map +1 -0
  295. package/dist/core/types/user.js +45 -0
  296. package/dist/core/types/user.js.map +1 -0
  297. package/dist/core/utils/id-generator.d.ts +16 -0
  298. package/dist/core/utils/id-generator.d.ts.map +1 -0
  299. package/dist/core/utils/id-generator.js +61 -0
  300. package/dist/core/utils/id-generator.js.map +1 -0
  301. package/dist/core/utils/logger.d.ts +100 -0
  302. package/dist/core/utils/logger.d.ts.map +1 -0
  303. package/dist/core/utils/logger.js +212 -0
  304. package/dist/core/utils/logger.js.map +1 -0
  305. package/dist/core/utils/reference-expander.d.ts +57 -0
  306. package/dist/core/utils/reference-expander.d.ts.map +1 -0
  307. package/dist/core/utils/reference-expander.js +192 -0
  308. package/dist/core/utils/reference-expander.js.map +1 -0
  309. package/dist/core/utils/universal-crypto.d.ts +46 -0
  310. package/dist/core/utils/universal-crypto.d.ts.map +1 -0
  311. package/dist/core/utils/universal-crypto.js +171 -0
  312. package/dist/core/utils/universal-crypto.js.map +1 -0
  313. package/dist/core/validation/validator.d.ts +11 -0
  314. package/dist/core/validation/validator.d.ts.map +1 -0
  315. package/dist/core/validation/validator.js +164 -0
  316. package/dist/core/validation/validator.js.map +1 -0
  317. package/dist/i18n/config.d.ts +4077 -0
  318. package/dist/i18n/config.d.ts.map +1 -0
  319. package/dist/i18n/config.js +116 -0
  320. package/dist/i18n/config.js.map +1 -0
  321. package/dist/i18n/hooks.d.ts +86 -0
  322. package/dist/i18n/hooks.d.ts.map +1 -0
  323. package/dist/i18n/hooks.js +122 -0
  324. package/dist/i18n/hooks.js.map +1 -0
  325. package/dist/i18n/index.d.ts +39 -0
  326. package/dist/i18n/index.d.ts.map +1 -0
  327. package/dist/i18n/index.js +40 -0
  328. package/dist/i18n/index.js.map +1 -0
  329. package/dist/i18n/locales/en/auth.json +108 -0
  330. package/dist/i18n/locales/en/common.json +100 -0
  331. package/dist/i18n/locales/en/errors.json +55 -0
  332. package/dist/i18n/locales/en/fields.json +456 -0
  333. package/dist/i18n/locales/en/studio.json +1329 -0
  334. package/dist/i18n/locales/fr/auth.json +108 -0
  335. package/dist/i18n/locales/fr/common.json +100 -0
  336. package/dist/i18n/locales/fr/errors.json +55 -0
  337. package/dist/i18n/locales/fr/fields.json +456 -0
  338. package/dist/i18n/locales/fr/studio.json +1274 -0
  339. package/dist/i18n/provider.d.ts +45 -0
  340. package/dist/i18n/provider.d.ts.map +1 -0
  341. package/dist/i18n/provider.js +49 -0
  342. package/dist/i18n/provider.js.map +1 -0
  343. package/dist/i18n/types.d.ts +8 -0
  344. package/dist/i18n/types.d.ts.map +1 -0
  345. package/dist/i18n/types.js +7 -0
  346. package/dist/i18n/types.js.map +1 -0
  347. package/dist/index.d.ts +15 -0
  348. package/dist/index.d.ts.map +1 -0
  349. package/dist/index.js +16 -0
  350. package/dist/index.js.map +1 -0
  351. package/dist/integrations/express/adapter.d.ts +33 -0
  352. package/dist/integrations/express/adapter.d.ts.map +1 -0
  353. package/dist/integrations/express/adapter.js +203 -0
  354. package/dist/integrations/express/adapter.js.map +1 -0
  355. package/dist/integrations/express/config.d.ts +599 -0
  356. package/dist/integrations/express/config.d.ts.map +1 -0
  357. package/dist/integrations/express/config.js +166 -0
  358. package/dist/integrations/express/config.js.map +1 -0
  359. package/dist/integrations/express/index.d.ts +10 -0
  360. package/dist/integrations/express/index.d.ts.map +1 -0
  361. package/dist/integrations/express/index.js +9 -0
  362. package/dist/integrations/express/index.js.map +1 -0
  363. package/dist/integrations/express/integration.d.ts +111 -0
  364. package/dist/integrations/express/integration.d.ts.map +1 -0
  365. package/dist/integrations/express/integration.js +730 -0
  366. package/dist/integrations/express/integration.js.map +1 -0
  367. package/dist/integrations/express/media-rewrite-middleware.d.ts +78 -0
  368. package/dist/integrations/express/media-rewrite-middleware.d.ts.map +1 -0
  369. package/dist/integrations/express/media-rewrite-middleware.js +211 -0
  370. package/dist/integrations/express/media-rewrite-middleware.js.map +1 -0
  371. package/dist/integrations/express/media-url-generator.d.ts +52 -0
  372. package/dist/integrations/express/media-url-generator.d.ts.map +1 -0
  373. package/dist/integrations/express/media-url-generator.js +107 -0
  374. package/dist/integrations/express/media-url-generator.js.map +1 -0
  375. package/dist/integrations/express/middleware.d.ts +25 -0
  376. package/dist/integrations/express/middleware.d.ts.map +1 -0
  377. package/dist/integrations/express/middleware.js +130 -0
  378. package/dist/integrations/express/middleware.js.map +1 -0
  379. package/dist/integrations/express/server.d.ts +99 -0
  380. package/dist/integrations/express/server.d.ts.map +1 -0
  381. package/dist/integrations/express/server.js +597 -0
  382. package/dist/integrations/express/server.js.map +1 -0
  383. package/dist/integrations/express/types.d.ts +106 -0
  384. package/dist/integrations/express/types.d.ts.map +1 -0
  385. package/dist/integrations/express/types.js +2 -0
  386. package/dist/integrations/express/types.js.map +1 -0
  387. package/dist/mail/adapters/console.d.ts +30 -0
  388. package/dist/mail/adapters/console.d.ts.map +1 -0
  389. package/dist/mail/adapters/console.js +169 -0
  390. package/dist/mail/adapters/console.js.map +1 -0
  391. package/dist/mail/adapters/resend.d.ts +18 -0
  392. package/dist/mail/adapters/resend.d.ts.map +1 -0
  393. package/dist/mail/adapters/resend.js +148 -0
  394. package/dist/mail/adapters/resend.js.map +1 -0
  395. package/dist/mail/adapters/smtp.d.ts +22 -0
  396. package/dist/mail/adapters/smtp.d.ts.map +1 -0
  397. package/dist/mail/adapters/smtp.js +180 -0
  398. package/dist/mail/adapters/smtp.js.map +1 -0
  399. package/dist/mail/index.d.ts +15 -0
  400. package/dist/mail/index.d.ts.map +1 -0
  401. package/dist/mail/index.js +13 -0
  402. package/dist/mail/index.js.map +1 -0
  403. package/dist/mail/mail-service.d.ts +180 -0
  404. package/dist/mail/mail-service.d.ts.map +1 -0
  405. package/dist/mail/mail-service.js +370 -0
  406. package/dist/mail/mail-service.js.map +1 -0
  407. package/dist/mail/notification-service.d.ts +82 -0
  408. package/dist/mail/notification-service.d.ts.map +1 -0
  409. package/dist/mail/notification-service.js +262 -0
  410. package/dist/mail/notification-service.js.map +1 -0
  411. package/dist/mail/templates/built-in-templates.d.ts +47 -0
  412. package/dist/mail/templates/built-in-templates.d.ts.map +1 -0
  413. package/dist/mail/templates/built-in-templates.js +416 -0
  414. package/dist/mail/templates/built-in-templates.js.map +1 -0
  415. package/dist/mail/templates/custom-template-renderer.d.ts +115 -0
  416. package/dist/mail/templates/custom-template-renderer.d.ts.map +1 -0
  417. package/dist/mail/templates/custom-template-renderer.js +225 -0
  418. package/dist/mail/templates/custom-template-renderer.js.map +1 -0
  419. package/dist/mail/types.d.ts +7 -0
  420. package/dist/mail/types.d.ts.map +1 -0
  421. package/dist/mail/types.js +7 -0
  422. package/dist/mail/types.js.map +1 -0
  423. package/dist/routes/auth/captcha.d.ts +33 -0
  424. package/dist/routes/auth/captcha.d.ts.map +1 -0
  425. package/dist/routes/auth/captcha.js +102 -0
  426. package/dist/routes/auth/captcha.js.map +1 -0
  427. package/dist/routes/auth/change-password.d.ts +17 -0
  428. package/dist/routes/auth/change-password.d.ts.map +1 -0
  429. package/dist/routes/auth/change-password.js +121 -0
  430. package/dist/routes/auth/change-password.js.map +1 -0
  431. package/dist/routes/auth/index.d.ts +13 -0
  432. package/dist/routes/auth/index.d.ts.map +1 -0
  433. package/dist/routes/auth/index.js +35 -0
  434. package/dist/routes/auth/index.js.map +1 -0
  435. package/dist/routes/auth/mfa.d.ts +121 -0
  436. package/dist/routes/auth/mfa.d.ts.map +1 -0
  437. package/dist/routes/auth/mfa.js +1143 -0
  438. package/dist/routes/auth/mfa.js.map +1 -0
  439. package/dist/routes/auth/oauth.d.ts +37 -0
  440. package/dist/routes/auth/oauth.d.ts.map +1 -0
  441. package/dist/routes/auth/oauth.js +420 -0
  442. package/dist/routes/auth/oauth.js.map +1 -0
  443. package/dist/routes/auth/oauth2-server.d.ts +70 -0
  444. package/dist/routes/auth/oauth2-server.d.ts.map +1 -0
  445. package/dist/routes/auth/oauth2-server.js +775 -0
  446. package/dist/routes/auth/oauth2-server.js.map +1 -0
  447. package/dist/routes/auth/passkey.d.ts +65 -0
  448. package/dist/routes/auth/passkey.d.ts.map +1 -0
  449. package/dist/routes/auth/passkey.js +910 -0
  450. package/dist/routes/auth/passkey.js.map +1 -0
  451. package/dist/routes/auth/password-reset.d.ts +23 -0
  452. package/dist/routes/auth/password-reset.d.ts.map +1 -0
  453. package/dist/routes/auth/password-reset.js +336 -0
  454. package/dist/routes/auth/password-reset.js.map +1 -0
  455. package/dist/routes/handlers/audit.d.ts +21 -0
  456. package/dist/routes/handlers/audit.d.ts.map +1 -0
  457. package/dist/routes/handlers/audit.js +124 -0
  458. package/dist/routes/handlers/audit.js.map +1 -0
  459. package/dist/routes/handlers/auth.d.ts +150 -0
  460. package/dist/routes/handlers/auth.d.ts.map +1 -0
  461. package/dist/routes/handlers/auth.js +512 -0
  462. package/dist/routes/handlers/auth.js.map +1 -0
  463. package/dist/routes/handlers/base.d.ts +34 -0
  464. package/dist/routes/handlers/base.d.ts.map +1 -0
  465. package/dist/routes/handlers/base.js +366 -0
  466. package/dist/routes/handlers/base.js.map +1 -0
  467. package/dist/routes/handlers/config.d.ts +31 -0
  468. package/dist/routes/handlers/config.d.ts.map +1 -0
  469. package/dist/routes/handlers/config.js +483 -0
  470. package/dist/routes/handlers/config.js.map +1 -0
  471. package/dist/routes/handlers/documents.d.ts +50 -0
  472. package/dist/routes/handlers/documents.d.ts.map +1 -0
  473. package/dist/routes/handlers/documents.js +708 -0
  474. package/dist/routes/handlers/documents.js.map +1 -0
  475. package/dist/routes/handlers/index.d.ts +12 -0
  476. package/dist/routes/handlers/index.d.ts.map +1 -0
  477. package/dist/routes/handlers/index.js +11 -0
  478. package/dist/routes/handlers/index.js.map +1 -0
  479. package/dist/routes/handlers/media.d.ts +24 -0
  480. package/dist/routes/handlers/media.d.ts.map +1 -0
  481. package/dist/routes/handlers/media.js +432 -0
  482. package/dist/routes/handlers/media.js.map +1 -0
  483. package/dist/routes/handlers/search.d.ts +10 -0
  484. package/dist/routes/handlers/search.d.ts.map +1 -0
  485. package/dist/routes/handlers/search.js +153 -0
  486. package/dist/routes/handlers/search.js.map +1 -0
  487. package/dist/routes/handlers/tokens.d.ts +14 -0
  488. package/dist/routes/handlers/tokens.d.ts.map +1 -0
  489. package/dist/routes/handlers/tokens.js +109 -0
  490. package/dist/routes/handlers/tokens.js.map +1 -0
  491. package/dist/routes/handlers/types.d.ts +13 -0
  492. package/dist/routes/handlers/types.d.ts.map +1 -0
  493. package/dist/routes/handlers/types.js +5 -0
  494. package/dist/routes/handlers/types.js.map +1 -0
  495. package/dist/routes/handlers/users.d.ts +16 -0
  496. package/dist/routes/handlers/users.d.ts.map +1 -0
  497. package/dist/routes/handlers/users.js +198 -0
  498. package/dist/routes/handlers/users.js.map +1 -0
  499. package/dist/routes/handlers/webhooks.d.ts +37 -0
  500. package/dist/routes/handlers/webhooks.d.ts.map +1 -0
  501. package/dist/routes/handlers/webhooks.js +343 -0
  502. package/dist/routes/handlers/webhooks.js.map +1 -0
  503. package/dist/routes/index.d.ts +5 -0
  504. package/dist/routes/index.d.ts.map +1 -0
  505. package/dist/routes/index.js +5 -0
  506. package/dist/routes/index.js.map +1 -0
  507. package/dist/routes/routes.d.ts +29 -0
  508. package/dist/routes/routes.d.ts.map +1 -0
  509. package/dist/routes/routes.js +531 -0
  510. package/dist/routes/routes.js.map +1 -0
  511. package/dist/routes/slug-processor.d.ts +32 -0
  512. package/dist/routes/slug-processor.d.ts.map +1 -0
  513. package/dist/routes/slug-processor.js +328 -0
  514. package/dist/routes/slug-processor.js.map +1 -0
  515. package/dist/routes/types.d.ts +31 -0
  516. package/dist/routes/types.d.ts.map +1 -0
  517. package/dist/routes/types.js +7 -0
  518. package/dist/routes/types.js.map +1 -0
  519. package/dist/routes/users/index.d.ts +7 -0
  520. package/dist/routes/users/index.d.ts.map +1 -0
  521. package/dist/routes/users/index.js +7 -0
  522. package/dist/routes/users/index.js.map +1 -0
  523. package/dist/structure/builder/StructureBuilder.d.ts +209 -0
  524. package/dist/structure/builder/StructureBuilder.d.ts.map +1 -0
  525. package/dist/structure/builder/StructureBuilder.js +425 -0
  526. package/dist/structure/builder/StructureBuilder.js.map +1 -0
  527. package/dist/structure/builder/index.d.ts +8 -0
  528. package/dist/structure/builder/index.d.ts.map +1 -0
  529. package/dist/structure/builder/index.js +6 -0
  530. package/dist/structure/builder/index.js.map +1 -0
  531. package/dist/structure/builder/navigation-tree-builder.d.ts +33 -0
  532. package/dist/structure/builder/navigation-tree-builder.d.ts.map +1 -0
  533. package/dist/structure/builder/navigation-tree-builder.js +284 -0
  534. package/dist/structure/builder/navigation-tree-builder.js.map +1 -0
  535. package/dist/structure/errors/index.d.ts +72 -0
  536. package/dist/structure/errors/index.d.ts.map +1 -0
  537. package/dist/structure/errors/index.js +136 -0
  538. package/dist/structure/errors/index.js.map +1 -0
  539. package/dist/structure/index.d.ts +14 -0
  540. package/dist/structure/index.d.ts.map +1 -0
  541. package/dist/structure/index.js +16 -0
  542. package/dist/structure/index.js.map +1 -0
  543. package/dist/structure/types/filters.d.ts +167 -0
  544. package/dist/structure/types/filters.d.ts.map +1 -0
  545. package/dist/structure/types/filters.js +38 -0
  546. package/dist/structure/types/filters.js.map +1 -0
  547. package/dist/structure/types/index.d.ts +11 -0
  548. package/dist/structure/types/index.d.ts.map +1 -0
  549. package/dist/structure/types/index.js +7 -0
  550. package/dist/structure/types/index.js.map +1 -0
  551. package/dist/structure/types/permissions.d.ts +159 -0
  552. package/dist/structure/types/permissions.d.ts.map +1 -0
  553. package/dist/structure/types/permissions.js +49 -0
  554. package/dist/structure/types/permissions.js.map +1 -0
  555. package/dist/structure/types/structure.d.ts +342 -0
  556. package/dist/structure/types/structure.d.ts.map +1 -0
  557. package/dist/structure/types/structure.js +6 -0
  558. package/dist/structure/types/structure.js.map +1 -0
  559. package/dist/structure/types/views.d.ts +278 -0
  560. package/dist/structure/types/views.d.ts.map +1 -0
  561. package/dist/structure/types/views.js +6 -0
  562. package/dist/structure/types/views.js.map +1 -0
  563. package/dist/structure/utils/hash.d.ts +61 -0
  564. package/dist/structure/utils/hash.d.ts.map +1 -0
  565. package/dist/structure/utils/hash.js +118 -0
  566. package/dist/structure/utils/hash.js.map +1 -0
  567. package/dist/structure/utils/index.d.ts +10 -0
  568. package/dist/structure/utils/index.d.ts.map +1 -0
  569. package/dist/structure/utils/index.js +7 -0
  570. package/dist/structure/utils/index.js.map +1 -0
  571. package/dist/structure/utils/permission-checker.d.ts +57 -0
  572. package/dist/structure/utils/permission-checker.d.ts.map +1 -0
  573. package/dist/structure/utils/permission-checker.js +286 -0
  574. package/dist/structure/utils/permission-checker.js.map +1 -0
  575. package/dist/structure/utils/query-builder.d.ts +82 -0
  576. package/dist/structure/utils/query-builder.d.ts.map +1 -0
  577. package/dist/structure/utils/query-builder.js +489 -0
  578. package/dist/structure/utils/query-builder.js.map +1 -0
  579. package/dist/structure/utils/structure-merger.d.ts +91 -0
  580. package/dist/structure/utils/structure-merger.d.ts.map +1 -0
  581. package/dist/structure/utils/structure-merger.js +445 -0
  582. package/dist/structure/utils/structure-merger.js.map +1 -0
  583. package/dist/structure/validation/schemas.d.ts +3107 -0
  584. package/dist/structure/validation/schemas.d.ts.map +1 -0
  585. package/dist/structure/validation/schemas.js +436 -0
  586. package/dist/structure/validation/schemas.js.map +1 -0
  587. package/dist/types/api-requests.d.ts +334 -0
  588. package/dist/types/api-requests.d.ts.map +1 -0
  589. package/dist/types/api-requests.js +8 -0
  590. package/dist/types/api-requests.js.map +1 -0
  591. package/dist/types/auth.d.ts +394 -0
  592. package/dist/types/auth.d.ts.map +1 -0
  593. package/dist/types/auth.js +8 -0
  594. package/dist/types/auth.js.map +1 -0
  595. package/dist/types/document.d.ts +49 -0
  596. package/dist/types/document.d.ts.map +1 -0
  597. package/dist/types/document.js +6 -0
  598. package/dist/types/document.js.map +1 -0
  599. package/dist/types/field-system.d.ts +197 -0
  600. package/dist/types/field-system.d.ts.map +1 -0
  601. package/dist/types/field-system.js +8 -0
  602. package/dist/types/field-system.js.map +1 -0
  603. package/dist/types/fields.d.ts +17 -0
  604. package/dist/types/fields.d.ts.map +1 -0
  605. package/dist/types/fields.js +21 -0
  606. package/dist/types/fields.js.map +1 -0
  607. package/dist/types/http.d.ts +162 -0
  608. package/dist/types/http.d.ts.map +1 -0
  609. package/dist/types/http.js +8 -0
  610. package/dist/types/http.js.map +1 -0
  611. package/dist/types/i18n.d.ts +56 -0
  612. package/dist/types/i18n.d.ts.map +1 -0
  613. package/dist/types/i18n.js +25 -0
  614. package/dist/types/i18n.js.map +1 -0
  615. package/dist/types/index.d.ts +22 -0
  616. package/dist/types/index.d.ts.map +1 -0
  617. package/dist/types/index.js +10 -0
  618. package/dist/types/index.js.map +1 -0
  619. package/dist/types/mail.d.ts +224 -0
  620. package/dist/types/mail.d.ts.map +1 -0
  621. package/dist/types/mail.js +8 -0
  622. package/dist/types/mail.js.map +1 -0
  623. package/dist/types/media.d.ts +56 -0
  624. package/dist/types/media.d.ts.map +1 -0
  625. package/dist/types/media.js +6 -0
  626. package/dist/types/media.js.map +1 -0
  627. package/dist/types/oauth2.d.ts +287 -0
  628. package/dist/types/oauth2.d.ts.map +1 -0
  629. package/dist/types/oauth2.js +43 -0
  630. package/dist/types/oauth2.js.map +1 -0
  631. package/dist/types/passkey.d.ts +217 -0
  632. package/dist/types/passkey.d.ts.map +1 -0
  633. package/dist/types/passkey.js +8 -0
  634. package/dist/types/passkey.js.map +1 -0
  635. package/dist/types/slug.d.ts +99 -0
  636. package/dist/types/slug.d.ts.map +1 -0
  637. package/dist/types/slug.js +8 -0
  638. package/dist/types/slug.js.map +1 -0
  639. package/package.json +183 -0
@@ -0,0 +1,150 @@
1
+ /**
2
+ * AuthRoutes - Authentication, OAuth, passkey, MFA and OAuth2 server route handlers
3
+ */
4
+ import type { RouteDefinition } from '../types.js';
5
+ import { BaseRoutes } from './base.js';
6
+ export declare class AuthRoutes extends BaseRoutes {
7
+ getRoutes(): RouteDefinition[];
8
+ private login;
9
+ private logout;
10
+ private getMe;
11
+ private validateToken;
12
+ private refreshToken;
13
+ /**
14
+ * Request password reset
15
+ * POST /auth/request-reset
16
+ */
17
+ private requestPasswordReset;
18
+ /**
19
+ * Reset password with token
20
+ * POST /auth/reset-password
21
+ */
22
+ private resetPassword;
23
+ /**
24
+ * Verify reset token validity
25
+ * POST /auth/verify-reset-token
26
+ */
27
+ private verifyResetToken;
28
+ /**
29
+ * Change password (authenticated users)
30
+ * POST /auth/change-password
31
+ */
32
+ private changePassword;
33
+ /**
34
+ * Initialize Google OAuth flow
35
+ * POST /auth/oauth/google/init
36
+ */
37
+ private initGoogleOAuth;
38
+ /**
39
+ * Handle Google OAuth callback
40
+ * POST /auth/oauth/google/callback
41
+ */
42
+ private handleGoogleOAuthCallback;
43
+ /**
44
+ * Unlink Google account
45
+ * DELETE /auth/oauth/google/unlink
46
+ */
47
+ private unlinkGoogleAccount;
48
+ /**
49
+ * Get OAuth status
50
+ * GET /auth/oauth/status
51
+ */
52
+ private getOAuthStatus;
53
+ /**
54
+ * Get passkey status
55
+ * GET /auth/passkey/status
56
+ */
57
+ private getPasskeyStatus;
58
+ /**
59
+ * Get passkey registration options
60
+ * POST /auth/passkey/register/options
61
+ */
62
+ private getPasskeyRegistrationOptions;
63
+ /**
64
+ * Verify passkey registration
65
+ * POST /auth/passkey/register/verify
66
+ */
67
+ private verifyPasskeyRegistration;
68
+ /**
69
+ * Get passkey login options
70
+ * POST /auth/passkey/login/options
71
+ */
72
+ private getPasskeyLoginOptions;
73
+ /**
74
+ * Verify passkey login
75
+ * POST /auth/passkey/login/verify
76
+ */
77
+ private verifyPasskeyLogin;
78
+ /**
79
+ * List passkey credentials
80
+ * GET /auth/passkey/credentials
81
+ */
82
+ private listPasskeyCredentials;
83
+ /**
84
+ * Update passkey credential
85
+ * PATCH /auth/passkey/credentials/:credentialId
86
+ */
87
+ private updatePasskeyCredential;
88
+ /**
89
+ * Delete passkey credential
90
+ * DELETE /auth/passkey/credentials/:credentialId
91
+ */
92
+ private deletePasskeyCredential;
93
+ /**
94
+ * Get CAPTCHA status and configuration
95
+ * GET /auth/captcha/status
96
+ */
97
+ private getCaptchaStatus;
98
+ private verifyMFA;
99
+ private verifyMFABackup;
100
+ private sendMFACode;
101
+ private initTOTPSetup;
102
+ private verifyTOTPSetup;
103
+ private initEmailOTPSetup;
104
+ private verifyEmailOTPSetup;
105
+ private disableMFA;
106
+ private disableAllMFA;
107
+ private regenerateBackupCodes;
108
+ private getMFAStatus;
109
+ private getTrustedDevices;
110
+ private revokeTrustedDevice;
111
+ private revokeAllTrustedDevices;
112
+ private adminResetUserMFA;
113
+ /**
114
+ * Start Device Authorization Flow
115
+ * POST /auth/device
116
+ * No authentication required - called by CLI
117
+ */
118
+ private startDeviceAuthorization;
119
+ /**
120
+ * Get Device Code Info (for verification page)
121
+ * GET /auth/device/verify?code=XXXX-XXXX
122
+ * Authentication required - called by Studio
123
+ */
124
+ private getDeviceCodeInfo;
125
+ /**
126
+ * Verify (Authorize/Deny) Device Code
127
+ * POST /auth/device/verify
128
+ * Authentication required - called by Studio
129
+ */
130
+ private verifyDeviceCode;
131
+ /**
132
+ * OAuth2 Token Endpoint
133
+ * POST /auth/token
134
+ * Handles device code exchange, authorization code exchange, and token refresh
135
+ */
136
+ private handleOAuth2TokenRequest;
137
+ /**
138
+ * Validate Authorization Request (for consent page)
139
+ * GET /auth/authorize
140
+ * Authentication optional - if authenticated, checks for existing consent
141
+ */
142
+ private validateAuthorizationRequest;
143
+ /**
144
+ * Handle Authorization Decision (approve/deny)
145
+ * POST /auth/authorize
146
+ * Authentication required - called when user approves/denies
147
+ */
148
+ private handleAuthorizationDecision;
149
+ }
150
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/routes/handlers/auth.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAA6B,eAAe,EAA+B,MAAM,aAAa,CAAA;AAC1G,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAEtC,qBAAa,UAAW,SAAQ,UAAU;IACjC,SAAS,IAAI,eAAe,EAAE;YAkDvB,KAAK;YAyEL,MAAM;YAUN,KAAK;YA0BL,aAAa;YA6Bb,YAAY;IAwB1B;;;OAGG;YACW,oBAAoB;IAMlC;;;OAGG;YACW,aAAa;IAM3B;;;OAGG;YACW,gBAAgB;IAM9B;;;OAGG;YACW,cAAc;IAS5B;;;OAGG;YACW,eAAe;IAW7B;;;OAGG;YACW,yBAAyB;IAevC;;;OAGG;YACW,mBAAmB;IAMjC;;;OAGG;YACW,cAAc;IAK5B;;;OAGG;YACW,gBAAgB;IAK9B;;;OAGG;YACW,6BAA6B;IAM3C;;;OAGG;YACW,yBAAyB;IAMvC;;;OAGG;YACW,sBAAsB;IAKpC;;;OAGG;YACW,kBAAkB;IAKhC;;;OAGG;YACW,sBAAsB;IAMpC;;;OAGG;YACW,uBAAuB;IAMrC;;;OAGG;YACW,uBAAuB;IAMrC;;;OAGG;YACW,gBAAgB;YAKhB,SAAS;YAKT,eAAe;YAKf,WAAW;YAKX,aAAa;YASb,eAAe;YASf,iBAAiB;YASjB,mBAAmB;YASnB,UAAU;YAMV,aAAa;YAMb,qBAAqB;YAMrB,YAAY;YAMZ,iBAAiB;YAMjB,mBAAmB;YAMnB,uBAAuB;YAMvB,iBAAiB;IAU/B;;;;OAIG;YACW,wBAAwB;IAKtC;;;;OAIG;YACW,iBAAiB;IAM/B;;;;OAIG;YACW,gBAAgB;IAM9B;;;;OAIG;YACW,wBAAwB;IAKtC;;;;OAIG;YACW,4BAA4B;IAY1C;;;;OAIG;YACW,2BAA2B;CAM1C"}
@@ -0,0 +1,512 @@
1
+ /**
2
+ * AuthRoutes - Authentication, OAuth, passkey, MFA and OAuth2 server route handlers
3
+ */
4
+ import { SecurityValidator, InvalidInputError } from '../../core/index.js';
5
+ import { BaseRoutes } from './base.js';
6
+ export class AuthRoutes extends BaseRoutes {
7
+ getRoutes() {
8
+ const basePath = this.config.basePath || '';
9
+ return this.defineRoutes([
10
+ ['POST', `${basePath}/auth/login`, this.login.bind(this)],
11
+ ['POST', `${basePath}/auth/logout`, this.logout.bind(this)],
12
+ ['GET', `${basePath}/auth/me`, this.getMe.bind(this)],
13
+ ['POST', `${basePath}/auth/validate`, this.validateToken.bind(this)],
14
+ ['POST', `${basePath}/auth/refresh`, this.refreshToken.bind(this)],
15
+ ['POST', `${basePath}/auth/request-reset`, this.requestPasswordReset.bind(this)],
16
+ ['POST', `${basePath}/auth/reset-password`, this.resetPassword.bind(this)],
17
+ ['POST', `${basePath}/auth/verify-reset-token`, this.verifyResetToken.bind(this)],
18
+ ['POST', `${basePath}/auth/change-password`, this.changePassword.bind(this)],
19
+ ['POST', `${basePath}/auth/oauth/google/init`, this.initGoogleOAuth.bind(this)],
20
+ ['POST', `${basePath}/auth/oauth/google/callback`, this.handleGoogleOAuthCallback.bind(this)],
21
+ ['DELETE', `${basePath}/auth/oauth/google/unlink`, this.unlinkGoogleAccount.bind(this)],
22
+ ['GET', `${basePath}/auth/oauth/status`, this.getOAuthStatus.bind(this)],
23
+ ['GET', `${basePath}/auth/passkey/status`, this.getPasskeyStatus.bind(this)],
24
+ ['POST', `${basePath}/auth/passkey/register/options`, this.getPasskeyRegistrationOptions.bind(this)],
25
+ ['POST', `${basePath}/auth/passkey/register/verify`, this.verifyPasskeyRegistration.bind(this)],
26
+ ['POST', `${basePath}/auth/passkey/login/options`, this.getPasskeyLoginOptions.bind(this)],
27
+ ['POST', `${basePath}/auth/passkey/login/verify`, this.verifyPasskeyLogin.bind(this)],
28
+ ['GET', `${basePath}/auth/passkey/credentials`, this.listPasskeyCredentials.bind(this)],
29
+ ['PATCH', `${basePath}/auth/passkey/credentials/:credentialId`, this.updatePasskeyCredential.bind(this)],
30
+ ['DELETE', `${basePath}/auth/passkey/credentials/:credentialId`, this.deletePasskeyCredential.bind(this)],
31
+ ['GET', `${basePath}/auth/captcha/status`, this.getCaptchaStatus.bind(this)],
32
+ ['POST', `${basePath}/auth/mfa/verify`, this.verifyMFA.bind(this)],
33
+ ['POST', `${basePath}/auth/mfa/verify-backup`, this.verifyMFABackup.bind(this)],
34
+ ['POST', `${basePath}/auth/mfa/send-code`, this.sendMFACode.bind(this)],
35
+ ['POST', `${basePath}/auth/mfa/setup/totp`, this.initTOTPSetup.bind(this)],
36
+ ['POST', `${basePath}/auth/mfa/setup/totp/verify`, this.verifyTOTPSetup.bind(this)],
37
+ ['POST', `${basePath}/auth/mfa/setup/email`, this.initEmailOTPSetup.bind(this)],
38
+ ['POST', `${basePath}/auth/mfa/setup/email/verify`, this.verifyEmailOTPSetup.bind(this)],
39
+ ['POST', `${basePath}/auth/mfa/disable`, this.disableMFA.bind(this)],
40
+ ['POST', `${basePath}/auth/mfa/disable-all`, this.disableAllMFA.bind(this)],
41
+ ['POST', `${basePath}/auth/mfa/backup-codes/regenerate`, this.regenerateBackupCodes.bind(this)],
42
+ ['GET', `${basePath}/auth/mfa/status`, this.getMFAStatus.bind(this)],
43
+ ['GET', `${basePath}/auth/mfa/trusted-devices`, this.getTrustedDevices.bind(this)],
44
+ ['DELETE', `${basePath}/auth/mfa/trusted-devices/:deviceId`, this.revokeTrustedDevice.bind(this)],
45
+ ['DELETE', `${basePath}/auth/mfa/trusted-devices`, this.revokeAllTrustedDevices.bind(this)],
46
+ ['POST', `${basePath}/admin/users/:userId/mfa/reset`, this.adminResetUserMFA.bind(this)],
47
+ ['POST', `${basePath}/auth/device`, this.startDeviceAuthorization.bind(this)],
48
+ ['GET', `${basePath}/auth/device/verify`, this.getDeviceCodeInfo.bind(this)],
49
+ ['POST', `${basePath}/auth/device/verify`, this.verifyDeviceCode.bind(this)],
50
+ ['POST', `${basePath}/auth/token`, this.handleOAuth2TokenRequest.bind(this)],
51
+ ['GET', `${basePath}/auth/authorize`, this.validateAuthorizationRequest.bind(this)],
52
+ ['POST', `${basePath}/auth/authorize`, this.handleAuthorizationDecision.bind(this)]
53
+ ]);
54
+ }
55
+ // Authentication handlers
56
+ async login(request) {
57
+ try {
58
+ // SECURITY: Validate request body structure
59
+ if (!request.body || typeof request.body !== 'object') {
60
+ throw new InvalidInputError('Request body is required', 'body');
61
+ }
62
+ const body = request.body;
63
+ // Validate required fields
64
+ if (!body.username || !body.password) {
65
+ throw new InvalidInputError('Username and password are required', 'body');
66
+ }
67
+ SecurityValidator.validateUsername(body.username);
68
+ // Validate CAPTCHA if required
69
+ const { validateCaptcha, getClientIp } = await import('../auth/captcha.js');
70
+ await validateCaptcha(this.core, body.captchaToken, getClientIp(request), 'login');
71
+ // Use core engine's authentication method (handles all validation internally)
72
+ const authResult = await this.core.authenticateUser(body.username, body.password, {
73
+ rememberMe: body.rememberMe,
74
+ deviceId: body.deviceId
75
+ });
76
+ if (!authResult) {
77
+ throw new InvalidInputError('Invalid credentials', 'credentials');
78
+ }
79
+ // Handle different authentication result types
80
+ if (authResult.type === 'mfa_required') {
81
+ // User has MFA configured - need to verify
82
+ return this.successResponse({
83
+ success: true,
84
+ requiresMFA: true,
85
+ mfaToken: authResult.mfaToken,
86
+ methods: authResult.methods,
87
+ expiresIn: authResult.expiresIn
88
+ });
89
+ }
90
+ if (authResult.type === 'mfa_setup_required') {
91
+ // Organization requires MFA but user hasn't set it up
92
+ return this.successResponse({
93
+ success: true,
94
+ requiresMFASetup: true,
95
+ setupToken: authResult.setupToken,
96
+ allowedMethods: authResult.allowedMethods,
97
+ message: authResult.message,
98
+ expiresIn: authResult.expiresIn
99
+ });
100
+ }
101
+ // Normal successful authentication (type: 'success')
102
+ const { user: authenticatedUser, token, refreshToken } = authResult;
103
+ // Get token expiration time
104
+ const session = await this.core.verifyAuthToken(token);
105
+ const response = {
106
+ success: true,
107
+ token,
108
+ refreshToken,
109
+ user: authenticatedUser,
110
+ expiresAt: session?.expiresAt
111
+ };
112
+ return this.successResponse(response);
113
+ }
114
+ catch (error) {
115
+ return this.errorResponse(error);
116
+ }
117
+ }
118
+ async logout(request) {
119
+ try {
120
+ // For now, logout is client-side token removal
121
+ // In a full implementation, we'd invalidate the token server-side
122
+ return this.successResponse({ message: 'Logged out successfully' });
123
+ }
124
+ catch (error) {
125
+ return this.errorResponse(error);
126
+ }
127
+ }
128
+ async getMe(request) {
129
+ try {
130
+ // SECURITY: Validate authentication and get current user session
131
+ await this.validateAuthentication(request);
132
+ const sessionUser = await this.getCurrentUser(request);
133
+ if (!sessionUser) {
134
+ throw new Error('User session not found');
135
+ }
136
+ // Fetch full user data from storage using the user ID from session
137
+ const fullUser = await this.core.getUser(sessionUser.id);
138
+ if (!fullUser) {
139
+ throw new Error('User not found in database');
140
+ }
141
+ // Remove password hash from response for security
142
+ const { passwordHash, ...safeUser } = fullUser;
143
+ return this.successResponse(safeUser);
144
+ }
145
+ catch (error) {
146
+ return this.errorResponse(error);
147
+ }
148
+ }
149
+ async validateToken(request) {
150
+ try {
151
+ // SECURITY: Validate request body structure
152
+ if (!request.body || typeof request.body !== 'object') {
153
+ throw new InvalidInputError('Request body is required', 'body');
154
+ }
155
+ const body = request.body;
156
+ if (!('token' in body) || !body.token || typeof body.token !== 'string') {
157
+ throw new InvalidInputError('Token is required', 'token');
158
+ }
159
+ const { token } = body;
160
+ // Validate token using core engine's JWT verification
161
+ const session = await this.core.verifyAuthToken(token);
162
+ const isValid = session !== null;
163
+ return this.successResponse({
164
+ valid: isValid,
165
+ message: isValid ? 'Token is valid' : 'Token is invalid',
166
+ session: isValid ? session : undefined
167
+ });
168
+ }
169
+ catch (error) {
170
+ return this.errorResponse(error);
171
+ }
172
+ }
173
+ // Authentication Routes
174
+ async refreshToken(request) {
175
+ try {
176
+ if (!request.body || typeof request.body !== 'object') {
177
+ return this.errorResponse(new InvalidInputError('Request body is required'));
178
+ }
179
+ const body = request.body;
180
+ const { refreshToken } = body;
181
+ if (!refreshToken) {
182
+ return this.errorResponse(new InvalidInputError('Refresh token is required'));
183
+ }
184
+ // TODO: Core method exists but may not be implemented yet
185
+ const result = await this.core.refreshAuthToken(refreshToken);
186
+ if (!result) {
187
+ return this.errorResponse(new Error('Invalid or expired refresh token'), 401);
188
+ }
189
+ return this.successResponse(result);
190
+ }
191
+ catch (error) {
192
+ return this.errorResponse(error);
193
+ }
194
+ }
195
+ /**
196
+ * Request password reset
197
+ * POST /auth/request-reset
198
+ */
199
+ async requestPasswordReset(request) {
200
+ // Import password reset handler dynamically
201
+ const { requestPasswordReset: handler } = await import('../auth/password-reset.js');
202
+ return handler(request, this.core);
203
+ }
204
+ /**
205
+ * Reset password with token
206
+ * POST /auth/reset-password
207
+ */
208
+ async resetPassword(request) {
209
+ // Import password reset handler dynamically
210
+ const { resetPassword: handler } = await import('../auth/password-reset.js');
211
+ return handler(request, this.core);
212
+ }
213
+ /**
214
+ * Verify reset token validity
215
+ * POST /auth/verify-reset-token
216
+ */
217
+ async verifyResetToken(request) {
218
+ // Import password reset handler dynamically
219
+ const { verifyResetToken: handler } = await import('../auth/password-reset.js');
220
+ return handler(request, this.core);
221
+ }
222
+ /**
223
+ * Change password (authenticated users)
224
+ * POST /auth/change-password
225
+ */
226
+ async changePassword(request) {
227
+ // SECURITY: Validate authentication and populate request.user
228
+ await this.validateAuthentication(request);
229
+ // Import change password handler dynamically
230
+ const { changePassword: handler } = await import('../auth/change-password.js');
231
+ return handler(request, this.core);
232
+ }
233
+ /**
234
+ * Initialize Google OAuth flow
235
+ * POST /auth/oauth/google/init
236
+ */
237
+ async initGoogleOAuth(request) {
238
+ // For link mode, validate authentication
239
+ const body = request.body;
240
+ if (body?.mode === 'link') {
241
+ await this.validateAuthentication(request);
242
+ }
243
+ const { initGoogleOAuth: handler } = await import('../auth/oauth.js');
244
+ return handler(this.core, request);
245
+ }
246
+ /**
247
+ * Handle Google OAuth callback
248
+ * POST /auth/oauth/google/callback
249
+ */
250
+ async handleGoogleOAuthCallback(request) {
251
+ // For link mode, validate authentication
252
+ const body = request.body;
253
+ if (body?.mode === 'link') {
254
+ try {
255
+ await this.validateAuthentication(request);
256
+ }
257
+ catch {
258
+ // Ignore auth errors for link mode - the handler will check
259
+ }
260
+ }
261
+ const { handleGoogleOAuthCallback: handler } = await import('../auth/oauth.js');
262
+ return handler(this.core, request);
263
+ }
264
+ /**
265
+ * Unlink Google account
266
+ * DELETE /auth/oauth/google/unlink
267
+ */
268
+ async unlinkGoogleAccount(request) {
269
+ await this.validateAuthentication(request);
270
+ const { unlinkGoogleAccount: handler } = await import('../auth/oauth.js');
271
+ return handler(this.core, request);
272
+ }
273
+ /**
274
+ * Get OAuth status
275
+ * GET /auth/oauth/status
276
+ */
277
+ async getOAuthStatus(request) {
278
+ const { getOAuthStatus: handler } = await import('../auth/oauth.js');
279
+ return handler(this.core, request);
280
+ }
281
+ /**
282
+ * Get passkey status
283
+ * GET /auth/passkey/status
284
+ */
285
+ async getPasskeyStatus(request) {
286
+ const { getPasskeyStatus: handler } = await import('../auth/passkey.js');
287
+ return handler(this.core, request);
288
+ }
289
+ /**
290
+ * Get passkey registration options
291
+ * POST /auth/passkey/register/options
292
+ */
293
+ async getPasskeyRegistrationOptions(request) {
294
+ await this.validateAuthentication(request);
295
+ const { getPasskeyRegistrationOptions: handler } = await import('../auth/passkey.js');
296
+ return handler(this.core, request);
297
+ }
298
+ /**
299
+ * Verify passkey registration
300
+ * POST /auth/passkey/register/verify
301
+ */
302
+ async verifyPasskeyRegistration(request) {
303
+ await this.validateAuthentication(request);
304
+ const { verifyPasskeyRegistration: handler } = await import('../auth/passkey.js');
305
+ return handler(this.core, request);
306
+ }
307
+ /**
308
+ * Get passkey login options
309
+ * POST /auth/passkey/login/options
310
+ */
311
+ async getPasskeyLoginOptions(request) {
312
+ const { getPasskeyAuthenticationOptions: handler } = await import('../auth/passkey.js');
313
+ return handler(this.core, request);
314
+ }
315
+ /**
316
+ * Verify passkey login
317
+ * POST /auth/passkey/login/verify
318
+ */
319
+ async verifyPasskeyLogin(request) {
320
+ const { verifyPasskeyAuthentication: handler } = await import('../auth/passkey.js');
321
+ return handler(this.core, request);
322
+ }
323
+ /**
324
+ * List passkey credentials
325
+ * GET /auth/passkey/credentials
326
+ */
327
+ async listPasskeyCredentials(request) {
328
+ await this.validateAuthentication(request);
329
+ const { listPasskeyCredentials: handler } = await import('../auth/passkey.js');
330
+ return handler(this.core, request);
331
+ }
332
+ /**
333
+ * Update passkey credential
334
+ * PATCH /auth/passkey/credentials/:credentialId
335
+ */
336
+ async updatePasskeyCredential(request) {
337
+ await this.validateAuthentication(request);
338
+ const { updatePasskeyCredential: handler } = await import('../auth/passkey.js');
339
+ return handler(this.core, request);
340
+ }
341
+ /**
342
+ * Delete passkey credential
343
+ * DELETE /auth/passkey/credentials/:credentialId
344
+ */
345
+ async deletePasskeyCredential(request) {
346
+ await this.validateAuthentication(request);
347
+ const { deletePasskeyCredential: handler } = await import('../auth/passkey.js');
348
+ return handler(this.core, request);
349
+ }
350
+ /**
351
+ * Get CAPTCHA status and configuration
352
+ * GET /auth/captcha/status
353
+ */
354
+ async getCaptchaStatus(request) {
355
+ const { getCaptchaStatus: handler } = await import('../auth/captcha.js');
356
+ return handler(request, this.core);
357
+ }
358
+ async verifyMFA(request) {
359
+ const { verifyMFA: handler } = await import('../auth/mfa.js');
360
+ return handler(request, this.core);
361
+ }
362
+ async verifyMFABackup(request) {
363
+ const { verifyMFABackup: handler } = await import('../auth/mfa.js');
364
+ return handler(request, this.core);
365
+ }
366
+ async sendMFACode(request) {
367
+ const { sendMFACode: handler } = await import('../auth/mfa.js');
368
+ return handler(request, this.core);
369
+ }
370
+ async initTOTPSetup(request) {
371
+ // Allow either auth token or MFA setup token (for login flow)
372
+ if (!request.headers['x-mfa-setup-token']) {
373
+ await this.validateAuthentication(request);
374
+ }
375
+ const { initTOTPSetup: handler } = await import('../auth/mfa.js');
376
+ return handler(request, this.core);
377
+ }
378
+ async verifyTOTPSetup(request) {
379
+ // Allow either auth token or MFA setup token (for login flow)
380
+ if (!request.headers['x-mfa-setup-token']) {
381
+ await this.validateAuthentication(request);
382
+ }
383
+ const { verifyTOTPSetup: handler } = await import('../auth/mfa.js');
384
+ return handler(request, this.core);
385
+ }
386
+ async initEmailOTPSetup(request) {
387
+ // Allow either auth token or MFA setup token (for login flow)
388
+ if (!request.headers['x-mfa-setup-token']) {
389
+ await this.validateAuthentication(request);
390
+ }
391
+ const { initEmailOTPSetup: handler } = await import('../auth/mfa.js');
392
+ return handler(request, this.core);
393
+ }
394
+ async verifyEmailOTPSetup(request) {
395
+ // Allow either auth token or MFA setup token (for login flow)
396
+ if (!request.headers['x-mfa-setup-token']) {
397
+ await this.validateAuthentication(request);
398
+ }
399
+ const { verifyEmailOTPSetup: handler } = await import('../auth/mfa.js');
400
+ return handler(request, this.core);
401
+ }
402
+ async disableMFA(request) {
403
+ await this.validateAuthentication(request);
404
+ const { disableMFA: handler } = await import('../auth/mfa.js');
405
+ return handler(request, this.core);
406
+ }
407
+ async disableAllMFA(request) {
408
+ await this.validateAuthentication(request);
409
+ const { disableAllMFA: handler } = await import('../auth/mfa.js');
410
+ return handler(request, this.core);
411
+ }
412
+ async regenerateBackupCodes(request) {
413
+ await this.validateAuthentication(request);
414
+ const { regenerateBackupCodes: handler } = await import('../auth/mfa.js');
415
+ return handler(request, this.core);
416
+ }
417
+ async getMFAStatus(request) {
418
+ await this.validateAuthentication(request);
419
+ const { getMFAStatus: handler } = await import('../auth/mfa.js');
420
+ return handler(request, this.core);
421
+ }
422
+ async getTrustedDevices(request) {
423
+ await this.validateAuthentication(request);
424
+ const { getTrustedDevices: handler } = await import('../auth/mfa.js');
425
+ return handler(request, this.core);
426
+ }
427
+ async revokeTrustedDevice(request) {
428
+ await this.validateAuthentication(request);
429
+ const { revokeTrustedDevice: handler } = await import('../auth/mfa.js');
430
+ return handler(request, this.core);
431
+ }
432
+ async revokeAllTrustedDevices(request) {
433
+ await this.validateAuthentication(request);
434
+ const { revokeAllTrustedDevices: handler } = await import('../auth/mfa.js');
435
+ return handler(request, this.core);
436
+ }
437
+ async adminResetUserMFA(request) {
438
+ await this.validateAuthentication(request);
439
+ // Require admin role for MFA reset
440
+ if (request.user?.role !== 'admin') {
441
+ return this.errorResponse(new InvalidInputError('Admin access required', 'permissions'), 403);
442
+ }
443
+ const { adminResetUserMFA: handler } = await import('../auth/mfa.js');
444
+ return handler(request, this.core);
445
+ }
446
+ /**
447
+ * Start Device Authorization Flow
448
+ * POST /auth/device
449
+ * No authentication required - called by CLI
450
+ */
451
+ async startDeviceAuthorization(request) {
452
+ const { startDeviceAuthorization: handler } = await import('../auth/oauth2-server.js');
453
+ return handler(this.core, request);
454
+ }
455
+ /**
456
+ * Get Device Code Info (for verification page)
457
+ * GET /auth/device/verify?code=XXXX-XXXX
458
+ * Authentication required - called by Studio
459
+ */
460
+ async getDeviceCodeInfo(request) {
461
+ await this.validateAuthentication(request);
462
+ const { getDeviceCodeInfo: handler } = await import('../auth/oauth2-server.js');
463
+ return handler(this.core, request);
464
+ }
465
+ /**
466
+ * Verify (Authorize/Deny) Device Code
467
+ * POST /auth/device/verify
468
+ * Authentication required - called by Studio
469
+ */
470
+ async verifyDeviceCode(request) {
471
+ await this.validateAuthentication(request);
472
+ const { verifyDeviceCode: handler } = await import('../auth/oauth2-server.js');
473
+ return handler(this.core, request);
474
+ }
475
+ /**
476
+ * OAuth2 Token Endpoint
477
+ * POST /auth/token
478
+ * Handles device code exchange, authorization code exchange, and token refresh
479
+ */
480
+ async handleOAuth2TokenRequest(request) {
481
+ const { handleTokenRequest: handler } = await import('../auth/oauth2-server.js');
482
+ return handler(this.core, request);
483
+ }
484
+ /**
485
+ * Validate Authorization Request (for consent page)
486
+ * GET /auth/authorize
487
+ * Authentication optional - if authenticated, checks for existing consent
488
+ */
489
+ async validateAuthorizationRequest(request) {
490
+ // Try to authenticate, but don't fail if no token present
491
+ // This allows consent checking for logged-in users
492
+ try {
493
+ await this.validateAuthentication(request);
494
+ }
495
+ catch {
496
+ // Ignore auth errors - user just won't get auto-approval
497
+ }
498
+ const { validateAuthorizationRequest: handler } = await import('../auth/oauth2-server.js');
499
+ return handler(this.core, request);
500
+ }
501
+ /**
502
+ * Handle Authorization Decision (approve/deny)
503
+ * POST /auth/authorize
504
+ * Authentication required - called when user approves/denies
505
+ */
506
+ async handleAuthorizationDecision(request) {
507
+ await this.validateAuthentication(request);
508
+ const { handleAuthorizationDecision: handler } = await import('../auth/oauth2-server.js');
509
+ return handler(this.core, request);
510
+ }
511
+ }
512
+ //# sourceMappingURL=auth.js.map