alepha 0.13.0 → 0.13.2

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 (461) hide show
  1. package/README.md +1 -1
  2. package/dist/api-files/index.d.ts +28 -91
  3. package/dist/api-files/index.js +10 -755
  4. package/dist/api-files/index.js.map +1 -1
  5. package/dist/api-jobs/index.d.ts +67 -67
  6. package/dist/api-jobs/index.js +13 -13
  7. package/dist/api-jobs/index.js.map +1 -1
  8. package/dist/api-notifications/index.d.ts +129 -146
  9. package/dist/api-notifications/index.js +17 -39
  10. package/dist/api-notifications/index.js.map +1 -1
  11. package/dist/api-parameters/index.d.ts +21 -22
  12. package/dist/api-parameters/index.js +22 -22
  13. package/dist/api-parameters/index.js.map +1 -1
  14. package/dist/api-users/index.d.ts +224 -2001
  15. package/dist/api-users/index.js +914 -4787
  16. package/dist/api-users/index.js.map +1 -1
  17. package/dist/api-verifications/index.d.ts +96 -96
  18. package/dist/batch/index.d.ts +13 -13
  19. package/dist/batch/index.js +8 -8
  20. package/dist/batch/index.js.map +1 -1
  21. package/dist/bucket/index.d.ts +14 -14
  22. package/dist/bucket/index.js +12 -12
  23. package/dist/bucket/index.js.map +1 -1
  24. package/dist/cache/index.d.ts +11 -11
  25. package/dist/cache/index.js +9 -9
  26. package/dist/cache/index.js.map +1 -1
  27. package/dist/cli/{dist-Sz2EXvQX.cjs → dist-Dl9Vl7Ur.js} +17 -13
  28. package/dist/cli/{dist-BBPjuQ56.js.map → dist-Dl9Vl7Ur.js.map} +1 -1
  29. package/dist/cli/index.d.ts +31 -37
  30. package/dist/cli/index.js +152 -83
  31. package/dist/cli/index.js.map +1 -1
  32. package/dist/command/index.d.ts +19 -19
  33. package/dist/command/index.js +25 -25
  34. package/dist/command/index.js.map +1 -1
  35. package/dist/core/index.browser.js +218 -218
  36. package/dist/core/index.browser.js.map +1 -1
  37. package/dist/core/index.d.ts +232 -232
  38. package/dist/core/index.js +218 -218
  39. package/dist/core/index.js.map +1 -1
  40. package/dist/core/{index.cjs → index.native.js} +304 -455
  41. package/dist/core/index.native.js.map +1 -0
  42. package/dist/datetime/index.d.ts +9 -9
  43. package/dist/datetime/index.js +7 -7
  44. package/dist/datetime/index.js.map +1 -1
  45. package/dist/email/index.d.ts +16 -16
  46. package/dist/email/index.js +80 -82
  47. package/dist/email/index.js.map +1 -1
  48. package/dist/file/index.js +1 -1
  49. package/dist/file/index.js.map +1 -1
  50. package/dist/lock/index.d.ts +9 -9
  51. package/dist/lock/index.js +8 -8
  52. package/dist/lock/index.js.map +1 -1
  53. package/dist/lock-redis/index.js +3 -66
  54. package/dist/lock-redis/index.js.map +1 -1
  55. package/dist/logger/index.d.ts +5 -5
  56. package/dist/logger/index.js +8 -8
  57. package/dist/logger/index.js.map +1 -1
  58. package/dist/orm/index.browser.js +114 -114
  59. package/dist/orm/index.browser.js.map +1 -1
  60. package/dist/orm/index.d.ts +219 -219
  61. package/dist/orm/index.js +46 -46
  62. package/dist/orm/index.js.map +1 -1
  63. package/dist/queue/index.d.ts +25 -25
  64. package/dist/queue/index.js +20 -20
  65. package/dist/queue/index.js.map +1 -1
  66. package/dist/queue-redis/index.d.ts +2 -2
  67. package/dist/redis/index.d.ts +10 -10
  68. package/dist/retry/index.d.ts +20 -20
  69. package/dist/retry/index.js +9 -9
  70. package/dist/retry/index.js.map +1 -1
  71. package/dist/scheduler/index.d.ts +12 -12
  72. package/dist/scheduler/index.js +9 -9
  73. package/dist/scheduler/index.js.map +1 -1
  74. package/dist/security/index.d.ts +53 -53
  75. package/dist/security/index.js +32 -32
  76. package/dist/security/index.js.map +1 -1
  77. package/dist/server/index.browser.js +1 -1
  78. package/dist/server/index.browser.js.map +1 -1
  79. package/dist/server/index.d.ts +101 -101
  80. package/dist/server/index.js +17 -17
  81. package/dist/server/index.js.map +1 -1
  82. package/dist/server-auth/index.browser.js +4 -982
  83. package/dist/server-auth/index.browser.js.map +1 -1
  84. package/dist/server-auth/index.d.ts +204 -785
  85. package/dist/server-auth/index.js +47 -1239
  86. package/dist/server-auth/index.js.map +1 -1
  87. package/dist/server-cache/index.d.ts +10 -10
  88. package/dist/server-cache/index.js +2 -2
  89. package/dist/server-cache/index.js.map +1 -1
  90. package/dist/server-compress/index.d.ts +4 -4
  91. package/dist/server-compress/index.js +1 -1
  92. package/dist/server-compress/index.js.map +1 -1
  93. package/dist/server-cookies/index.browser.js +8 -8
  94. package/dist/server-cookies/index.browser.js.map +1 -1
  95. package/dist/server-cookies/index.d.ts +17 -17
  96. package/dist/server-cookies/index.js +10 -10
  97. package/dist/server-cookies/index.js.map +1 -1
  98. package/dist/server-cors/index.d.ts +17 -17
  99. package/dist/server-cors/index.js +9 -9
  100. package/dist/server-cors/index.js.map +1 -1
  101. package/dist/server-health/index.d.ts +2 -2
  102. package/dist/server-helmet/index.d.ts +1 -1
  103. package/dist/server-links/index.browser.js +12 -12
  104. package/dist/server-links/index.browser.js.map +1 -1
  105. package/dist/server-links/index.d.ts +59 -251
  106. package/dist/server-links/index.js +23 -502
  107. package/dist/server-links/index.js.map +1 -1
  108. package/dist/server-metrics/index.d.ts +4 -4
  109. package/dist/server-metrics/index.js +170 -174
  110. package/dist/server-metrics/index.js.map +1 -1
  111. package/dist/server-multipart/index.d.ts +2 -2
  112. package/dist/server-proxy/index.d.ts +12 -12
  113. package/dist/server-proxy/index.js +10 -10
  114. package/dist/server-proxy/index.js.map +1 -1
  115. package/dist/server-rate-limit/index.d.ts +22 -22
  116. package/dist/server-rate-limit/index.js +12 -12
  117. package/dist/server-rate-limit/index.js.map +1 -1
  118. package/dist/server-security/index.d.ts +24 -24
  119. package/dist/server-security/index.js +15 -15
  120. package/dist/server-security/index.js.map +1 -1
  121. package/dist/server-static/index.d.ts +14 -14
  122. package/dist/server-static/index.js +8 -8
  123. package/dist/server-static/index.js.map +1 -1
  124. package/dist/server-swagger/index.d.ts +25 -184
  125. package/dist/server-swagger/index.js +21 -724
  126. package/dist/server-swagger/index.js.map +1 -1
  127. package/dist/sms/index.d.ts +14 -14
  128. package/dist/sms/index.js +9 -9
  129. package/dist/sms/index.js.map +1 -1
  130. package/dist/thread/index.d.ts +11 -11
  131. package/dist/thread/index.js +17 -17
  132. package/dist/thread/index.js.map +1 -1
  133. package/dist/topic/index.d.ts +26 -26
  134. package/dist/topic/index.js +16 -16
  135. package/dist/topic/index.js.map +1 -1
  136. package/dist/topic-redis/index.d.ts +1 -1
  137. package/dist/vite/index.d.ts +3 -3
  138. package/dist/vite/index.js +12 -13
  139. package/dist/vite/index.js.map +1 -1
  140. package/dist/websocket/index.browser.js +11 -11
  141. package/dist/websocket/index.browser.js.map +1 -1
  142. package/dist/websocket/index.d.ts +51 -51
  143. package/dist/websocket/index.js +13 -13
  144. package/dist/websocket/index.js.map +1 -1
  145. package/package.json +62 -52
  146. package/src/api-files/services/FileService.ts +5 -7
  147. package/src/api-jobs/index.ts +1 -1
  148. package/src/api-jobs/{descriptors → primitives}/$job.ts +8 -8
  149. package/src/api-jobs/providers/JobProvider.ts +9 -9
  150. package/src/api-jobs/services/JobService.ts +5 -5
  151. package/src/api-notifications/index.ts +5 -15
  152. package/src/api-notifications/{descriptors → primitives}/$notification.ts +10 -10
  153. package/src/api-notifications/services/NotificationSenderService.ts +3 -3
  154. package/src/api-parameters/index.ts +1 -1
  155. package/src/api-parameters/{descriptors → primitives}/$config.ts +7 -12
  156. package/src/api-users/index.ts +1 -1
  157. package/src/api-users/{descriptors → primitives}/$userRealm.ts +8 -8
  158. package/src/api-users/providers/UserRealmProvider.ts +1 -1
  159. package/src/batch/index.ts +3 -3
  160. package/src/batch/{descriptors → primitives}/$batch.ts +13 -16
  161. package/src/bucket/index.ts +8 -8
  162. package/src/bucket/{descriptors → primitives}/$bucket.ts +8 -8
  163. package/src/bucket/providers/LocalFileStorageProvider.ts +3 -3
  164. package/src/cache/index.ts +4 -4
  165. package/src/cache/{descriptors → primitives}/$cache.ts +15 -15
  166. package/src/cli/apps/AlephaPackageBuilderCli.ts +30 -3
  167. package/src/cli/assets/appRouterTs.ts +9 -0
  168. package/src/cli/assets/indexHtml.ts +2 -1
  169. package/src/cli/assets/mainBrowserTs.ts +10 -0
  170. package/src/cli/commands/CoreCommands.ts +6 -5
  171. package/src/cli/commands/DrizzleCommands.ts +69 -61
  172. package/src/cli/commands/VerifyCommands.ts +2 -2
  173. package/src/cli/commands/ViteCommands.ts +6 -1
  174. package/src/cli/services/ProjectUtils.ts +78 -41
  175. package/src/command/index.ts +5 -5
  176. package/src/command/{descriptors → primitives}/$command.ts +9 -12
  177. package/src/command/providers/CliProvider.ts +10 -10
  178. package/src/core/Alepha.ts +30 -33
  179. package/src/core/constants/KIND.ts +1 -1
  180. package/src/core/constants/OPTIONS.ts +1 -1
  181. package/src/core/helpers/{descriptor.ts → primitive.ts} +18 -18
  182. package/src/core/helpers/ref.ts +1 -1
  183. package/src/core/index.shared.ts +8 -8
  184. package/src/core/{descriptors → primitives}/$context.ts +5 -5
  185. package/src/core/{descriptors → primitives}/$hook.ts +4 -4
  186. package/src/core/{descriptors → primitives}/$inject.ts +2 -2
  187. package/src/core/{descriptors → primitives}/$module.ts +9 -9
  188. package/src/core/{descriptors → primitives}/$use.ts +2 -2
  189. package/src/core/providers/CodecManager.ts +1 -1
  190. package/src/core/providers/JsonSchemaCodec.ts +1 -1
  191. package/src/core/providers/StateManager.ts +2 -2
  192. package/src/datetime/index.ts +3 -3
  193. package/src/datetime/{descriptors → primitives}/$interval.ts +6 -6
  194. package/src/email/index.ts +4 -4
  195. package/src/email/{descriptors → primitives}/$email.ts +8 -8
  196. package/src/file/index.ts +1 -1
  197. package/src/lock/index.ts +3 -3
  198. package/src/lock/{descriptors → primitives}/$lock.ts +10 -10
  199. package/src/logger/index.ts +8 -8
  200. package/src/logger/{descriptors → primitives}/$logger.ts +2 -2
  201. package/src/logger/services/Logger.ts +1 -1
  202. package/src/orm/constants/PG_SYMBOLS.ts +2 -2
  203. package/src/orm/index.browser.ts +2 -2
  204. package/src/orm/index.ts +8 -8
  205. package/src/orm/{descriptors → primitives}/$entity.ts +11 -11
  206. package/src/orm/{descriptors → primitives}/$repository.ts +2 -2
  207. package/src/orm/{descriptors → primitives}/$sequence.ts +8 -8
  208. package/src/orm/{descriptors → primitives}/$transaction.ts +4 -4
  209. package/src/orm/providers/DrizzleKitProvider.ts +1 -1
  210. package/src/orm/providers/PostgresTypeProvider.ts +3 -3
  211. package/src/orm/providers/RepositoryProvider.ts +4 -4
  212. package/src/orm/providers/drivers/DatabaseProvider.ts +7 -7
  213. package/src/orm/services/ModelBuilder.ts +9 -9
  214. package/src/orm/services/PgRelationManager.ts +2 -2
  215. package/src/orm/services/PostgresModelBuilder.ts +5 -5
  216. package/src/orm/services/Repository.ts +7 -7
  217. package/src/orm/services/SqliteModelBuilder.ts +5 -5
  218. package/src/queue/index.ts +7 -7
  219. package/src/queue/{descriptors → primitives}/$consumer.ts +15 -15
  220. package/src/queue/{descriptors → primitives}/$queue.ts +12 -12
  221. package/src/queue/providers/WorkerProvider.ts +7 -7
  222. package/src/retry/index.ts +3 -3
  223. package/src/retry/{descriptors → primitives}/$retry.ts +19 -17
  224. package/src/scheduler/index.ts +3 -3
  225. package/src/scheduler/{descriptors → primitives}/$scheduler.ts +9 -9
  226. package/src/scheduler/providers/CronProvider.ts +1 -1
  227. package/src/security/index.ts +9 -9
  228. package/src/security/{descriptors → primitives}/$permission.ts +7 -7
  229. package/src/security/{descriptors → primitives}/$realm.ts +6 -12
  230. package/src/security/{descriptors → primitives}/$role.ts +12 -12
  231. package/src/security/{descriptors → primitives}/$serviceAccount.ts +8 -8
  232. package/src/server/index.browser.ts +1 -1
  233. package/src/server/index.ts +14 -14
  234. package/src/server/{descriptors → primitives}/$action.ts +13 -13
  235. package/src/server/{descriptors → primitives}/$route.ts +9 -9
  236. package/src/server/providers/NodeHttpServerProvider.ts +2 -2
  237. package/src/server/services/HttpClient.ts +1 -1
  238. package/src/server-auth/index.browser.ts +1 -1
  239. package/src/server-auth/index.ts +6 -6
  240. package/src/server-auth/{descriptors → primitives}/$auth.ts +10 -10
  241. package/src/server-auth/{descriptors → primitives}/$authCredentials.ts +4 -4
  242. package/src/server-auth/{descriptors → primitives}/$authGithub.ts +4 -4
  243. package/src/server-auth/{descriptors → primitives}/$authGoogle.ts +4 -4
  244. package/src/server-auth/providers/ServerAuthProvider.ts +4 -4
  245. package/src/server-cache/providers/ServerCacheProvider.ts +7 -7
  246. package/src/server-compress/providers/ServerCompressProvider.ts +3 -3
  247. package/src/server-cookies/index.browser.ts +2 -2
  248. package/src/server-cookies/index.ts +5 -5
  249. package/src/server-cookies/{descriptors → primitives}/$cookie.browser.ts +12 -12
  250. package/src/server-cookies/{descriptors → primitives}/$cookie.ts +13 -13
  251. package/src/server-cookies/providers/ServerCookiesProvider.ts +4 -4
  252. package/src/server-cookies/services/CookieParser.ts +1 -1
  253. package/src/server-cors/index.ts +3 -3
  254. package/src/server-cors/{descriptors → primitives}/$cors.ts +11 -13
  255. package/src/server-cors/providers/ServerCorsProvider.ts +5 -5
  256. package/src/server-links/index.browser.ts +5 -5
  257. package/src/server-links/index.ts +9 -9
  258. package/src/server-links/{descriptors → primitives}/$remote.ts +11 -11
  259. package/src/server-links/providers/LinkProvider.ts +7 -7
  260. package/src/server-links/providers/{RemoteDescriptorProvider.ts → RemotePrimitiveProvider.ts} +6 -6
  261. package/src/server-links/providers/ServerLinksProvider.ts +3 -3
  262. package/src/server-proxy/index.ts +3 -3
  263. package/src/server-proxy/{descriptors → primitives}/$proxy.ts +8 -8
  264. package/src/server-proxy/providers/ServerProxyProvider.ts +4 -4
  265. package/src/server-rate-limit/index.ts +6 -6
  266. package/src/server-rate-limit/{descriptors → primitives}/$rateLimit.ts +13 -13
  267. package/src/server-rate-limit/providers/ServerRateLimitProvider.ts +5 -5
  268. package/src/server-security/index.ts +3 -3
  269. package/src/server-security/{descriptors → primitives}/$basicAuth.ts +13 -13
  270. package/src/server-security/providers/ServerBasicAuthProvider.ts +5 -5
  271. package/src/server-security/providers/ServerSecurityProvider.ts +4 -4
  272. package/src/server-static/index.ts +3 -3
  273. package/src/server-static/{descriptors → primitives}/$serve.ts +8 -10
  274. package/src/server-static/providers/ServerStaticProvider.ts +6 -6
  275. package/src/server-swagger/index.ts +5 -5
  276. package/src/server-swagger/{descriptors → primitives}/$swagger.ts +9 -9
  277. package/src/server-swagger/providers/ServerSwaggerProvider.ts +11 -10
  278. package/src/sms/index.ts +4 -4
  279. package/src/sms/{descriptors → primitives}/$sms.ts +8 -8
  280. package/src/thread/index.ts +3 -3
  281. package/src/thread/{descriptors → primitives}/$thread.ts +13 -13
  282. package/src/thread/providers/ThreadProvider.ts +7 -9
  283. package/src/topic/index.ts +5 -5
  284. package/src/topic/{descriptors → primitives}/$subscriber.ts +14 -14
  285. package/src/topic/{descriptors → primitives}/$topic.ts +10 -10
  286. package/src/topic/providers/TopicProvider.ts +4 -4
  287. package/src/vite/helpers/boot.ts +3 -3
  288. package/src/vite/tasks/copyAssets.ts +1 -1
  289. package/src/vite/tasks/generateSitemap.ts +3 -3
  290. package/src/vite/tasks/prerenderPages.ts +2 -2
  291. package/src/vite/tasks/runAlepha.ts +2 -2
  292. package/src/websocket/index.browser.ts +3 -3
  293. package/src/websocket/index.shared.ts +2 -2
  294. package/src/websocket/index.ts +4 -4
  295. package/src/websocket/interfaces/WebSocketInterfaces.ts +3 -3
  296. package/src/websocket/{descriptors → primitives}/$channel.ts +10 -10
  297. package/src/websocket/{descriptors → primitives}/$websocket.ts +8 -8
  298. package/src/websocket/providers/NodeWebSocketServerProvider.ts +7 -7
  299. package/src/websocket/providers/WebSocketServerProvider.ts +3 -3
  300. package/src/websocket/services/WebSocketClient.ts +5 -5
  301. package/dist/api-files/index.cjs +0 -1293
  302. package/dist/api-files/index.cjs.map +0 -1
  303. package/dist/api-files/index.d.cts +0 -829
  304. package/dist/api-jobs/index.cjs +0 -274
  305. package/dist/api-jobs/index.cjs.map +0 -1
  306. package/dist/api-jobs/index.d.cts +0 -654
  307. package/dist/api-notifications/index.cjs +0 -380
  308. package/dist/api-notifications/index.cjs.map +0 -1
  309. package/dist/api-notifications/index.d.cts +0 -289
  310. package/dist/api-parameters/index.cjs +0 -66
  311. package/dist/api-parameters/index.cjs.map +0 -1
  312. package/dist/api-parameters/index.d.cts +0 -84
  313. package/dist/api-users/index.cjs +0 -6009
  314. package/dist/api-users/index.cjs.map +0 -1
  315. package/dist/api-users/index.d.cts +0 -4740
  316. package/dist/api-verifications/index.cjs +0 -407
  317. package/dist/api-verifications/index.cjs.map +0 -1
  318. package/dist/api-verifications/index.d.cts +0 -207
  319. package/dist/batch/index.cjs +0 -408
  320. package/dist/batch/index.cjs.map +0 -1
  321. package/dist/batch/index.d.cts +0 -330
  322. package/dist/bin/index.cjs +0 -17
  323. package/dist/bin/index.cjs.map +0 -1
  324. package/dist/bin/index.d.cts +0 -1
  325. package/dist/bucket/index.cjs +0 -303
  326. package/dist/bucket/index.cjs.map +0 -1
  327. package/dist/bucket/index.d.cts +0 -355
  328. package/dist/cache/index.cjs +0 -241
  329. package/dist/cache/index.cjs.map +0 -1
  330. package/dist/cache/index.d.cts +0 -202
  331. package/dist/cache-redis/index.cjs +0 -84
  332. package/dist/cache-redis/index.cjs.map +0 -1
  333. package/dist/cache-redis/index.d.cts +0 -40
  334. package/dist/cli/chunk-DSlc6foC.cjs +0 -43
  335. package/dist/cli/dist-BBPjuQ56.js +0 -2778
  336. package/dist/cli/dist-Sz2EXvQX.cjs.map +0 -1
  337. package/dist/cli/index.cjs +0 -1241
  338. package/dist/cli/index.cjs.map +0 -1
  339. package/dist/cli/index.d.cts +0 -422
  340. package/dist/command/index.cjs +0 -693
  341. package/dist/command/index.cjs.map +0 -1
  342. package/dist/command/index.d.cts +0 -340
  343. package/dist/core/index.cjs.map +0 -1
  344. package/dist/core/index.d.cts +0 -1927
  345. package/dist/datetime/index.cjs +0 -318
  346. package/dist/datetime/index.cjs.map +0 -1
  347. package/dist/datetime/index.d.cts +0 -145
  348. package/dist/email/index.cjs +0 -10874
  349. package/dist/email/index.cjs.map +0 -1
  350. package/dist/email/index.d.cts +0 -186
  351. package/dist/fake/index.cjs +0 -34641
  352. package/dist/fake/index.cjs.map +0 -1
  353. package/dist/fake/index.d.cts +0 -74
  354. package/dist/file/index.cjs +0 -1212
  355. package/dist/file/index.cjs.map +0 -1
  356. package/dist/file/index.d.cts +0 -698
  357. package/dist/lock/index.cjs +0 -226
  358. package/dist/lock/index.cjs.map +0 -1
  359. package/dist/lock/index.d.cts +0 -361
  360. package/dist/lock-redis/index.cjs +0 -113
  361. package/dist/lock-redis/index.cjs.map +0 -1
  362. package/dist/lock-redis/index.d.cts +0 -24
  363. package/dist/logger/index.cjs +0 -521
  364. package/dist/logger/index.cjs.map +0 -1
  365. package/dist/logger/index.d.cts +0 -281
  366. package/dist/orm/index.cjs +0 -2986
  367. package/dist/orm/index.cjs.map +0 -1
  368. package/dist/orm/index.d.cts +0 -2213
  369. package/dist/queue/index.cjs +0 -1044
  370. package/dist/queue/index.cjs.map +0 -1
  371. package/dist/queue/index.d.cts +0 -1265
  372. package/dist/queue-redis/index.cjs +0 -873
  373. package/dist/queue-redis/index.cjs.map +0 -1
  374. package/dist/queue-redis/index.d.cts +0 -82
  375. package/dist/redis/index.cjs +0 -153
  376. package/dist/redis/index.cjs.map +0 -1
  377. package/dist/redis/index.d.cts +0 -82
  378. package/dist/retry/index.cjs +0 -146
  379. package/dist/retry/index.cjs.map +0 -1
  380. package/dist/retry/index.d.cts +0 -172
  381. package/dist/router/index.cjs +0 -111
  382. package/dist/router/index.cjs.map +0 -1
  383. package/dist/router/index.d.cts +0 -46
  384. package/dist/scheduler/index.cjs +0 -576
  385. package/dist/scheduler/index.cjs.map +0 -1
  386. package/dist/scheduler/index.d.cts +0 -145
  387. package/dist/security/index.cjs +0 -2402
  388. package/dist/security/index.cjs.map +0 -1
  389. package/dist/security/index.d.cts +0 -598
  390. package/dist/server/index.cjs +0 -1680
  391. package/dist/server/index.cjs.map +0 -1
  392. package/dist/server/index.d.cts +0 -810
  393. package/dist/server-auth/index.cjs +0 -3146
  394. package/dist/server-auth/index.cjs.map +0 -1
  395. package/dist/server-auth/index.d.cts +0 -1164
  396. package/dist/server-cache/index.cjs +0 -252
  397. package/dist/server-cache/index.cjs.map +0 -1
  398. package/dist/server-cache/index.d.cts +0 -164
  399. package/dist/server-compress/index.cjs +0 -141
  400. package/dist/server-compress/index.cjs.map +0 -1
  401. package/dist/server-compress/index.d.cts +0 -38
  402. package/dist/server-cookies/index.cjs +0 -234
  403. package/dist/server-cookies/index.cjs.map +0 -1
  404. package/dist/server-cookies/index.d.cts +0 -144
  405. package/dist/server-cors/index.cjs +0 -201
  406. package/dist/server-cors/index.cjs.map +0 -1
  407. package/dist/server-cors/index.d.cts +0 -140
  408. package/dist/server-health/index.cjs +0 -62
  409. package/dist/server-health/index.cjs.map +0 -1
  410. package/dist/server-health/index.d.cts +0 -58
  411. package/dist/server-helmet/index.cjs +0 -131
  412. package/dist/server-helmet/index.cjs.map +0 -1
  413. package/dist/server-helmet/index.d.cts +0 -97
  414. package/dist/server-links/index.cjs +0 -992
  415. package/dist/server-links/index.cjs.map +0 -1
  416. package/dist/server-links/index.d.cts +0 -513
  417. package/dist/server-metrics/index.cjs +0 -4535
  418. package/dist/server-metrics/index.cjs.map +0 -1
  419. package/dist/server-metrics/index.d.cts +0 -35
  420. package/dist/server-multipart/index.cjs +0 -237
  421. package/dist/server-multipart/index.cjs.map +0 -1
  422. package/dist/server-multipart/index.d.cts +0 -50
  423. package/dist/server-proxy/index.cjs +0 -186
  424. package/dist/server-proxy/index.cjs.map +0 -1
  425. package/dist/server-proxy/index.d.cts +0 -234
  426. package/dist/server-rate-limit/index.cjs +0 -241
  427. package/dist/server-rate-limit/index.cjs.map +0 -1
  428. package/dist/server-rate-limit/index.d.cts +0 -183
  429. package/dist/server-security/index.cjs +0 -316
  430. package/dist/server-security/index.cjs.map +0 -1
  431. package/dist/server-security/index.d.cts +0 -173
  432. package/dist/server-static/index.cjs +0 -170
  433. package/dist/server-static/index.cjs.map +0 -1
  434. package/dist/server-static/index.d.cts +0 -121
  435. package/dist/server-swagger/index.cjs +0 -1021
  436. package/dist/server-swagger/index.cjs.map +0 -1
  437. package/dist/server-swagger/index.d.cts +0 -382
  438. package/dist/sms/index.cjs +0 -221
  439. package/dist/sms/index.cjs.map +0 -1
  440. package/dist/sms/index.d.cts +0 -130
  441. package/dist/thread/index.cjs +0 -350
  442. package/dist/thread/index.cjs.map +0 -1
  443. package/dist/thread/index.d.cts +0 -260
  444. package/dist/topic/index.cjs +0 -282
  445. package/dist/topic/index.cjs.map +0 -1
  446. package/dist/topic/index.d.cts +0 -523
  447. package/dist/topic-redis/index.cjs +0 -71
  448. package/dist/topic-redis/index.cjs.map +0 -1
  449. package/dist/topic-redis/index.d.cts +0 -42
  450. package/dist/vite/index.cjs +0 -1077
  451. package/dist/vite/index.cjs.map +0 -1
  452. package/dist/vite/index.d.cts +0 -542
  453. package/dist/websocket/index.cjs +0 -1117
  454. package/dist/websocket/index.cjs.map +0 -1
  455. package/dist/websocket/index.d.cts +0 -861
  456. package/src/api-notifications/providers/MemorySmsProvider.ts +0 -20
  457. package/src/api-notifications/providers/SmsProvider.ts +0 -8
  458. /package/src/core/{descriptors → primitives}/$atom.ts +0 -0
  459. /package/src/core/{descriptors → primitives}/$env.ts +0 -0
  460. /package/src/server-auth/{descriptors → primitives}/$authApple.ts +0 -0
  461. /package/src/server-links/{descriptors → primitives}/$client.ts +0 -0
@@ -1,407 +0,0 @@
1
- let alepha = require("alepha");
2
- let alepha_server = require("alepha/server");
3
- let node_crypto = require("node:crypto");
4
- let alepha_datetime = require("alepha/datetime");
5
- let alepha_logger = require("alepha/logger");
6
- let alepha_orm = require("alepha/orm");
7
- let alepha_scheduler = require("alepha/scheduler");
8
-
9
- //#region src/api-verifications/schemas/requestVerificationCodeResponseSchema.ts
10
- const requestVerificationCodeResponseSchema = alepha.t.object({
11
- token: alepha.t.string({ description: "The verification token (6-digit code for phone, UUID for email). The caller should send this to the user via their preferred notification method." }),
12
- codeExpiration: alepha.t.integer({ description: "Time in seconds before your verification token expires." }),
13
- verificationCooldown: alepha.t.integer({ description: "Cooldown period in seconds before you can request another verification." }),
14
- maxVerificationAttempts: alepha.t.integer({ description: "Maximum number of verification attempts allowed before the token is locked." })
15
- });
16
-
17
- //#endregion
18
- //#region src/api-verifications/schemas/validateVerificationCodeResponseSchema.ts
19
- const validateVerificationCodeResponseSchema = alepha.t.object({
20
- ok: alepha.t.boolean({ description: "Indicates whether the verification was successful." }),
21
- alreadyVerified: alepha.t.optional(alepha.t.boolean({ description: "Indicates whether the target was already verified." }))
22
- });
23
-
24
- //#endregion
25
- //#region src/api-verifications/schemas/verificationTypeEnumSchema.ts
26
- const verificationTypeEnumSchema = alepha.t.enum(["code", "link"]);
27
-
28
- //#endregion
29
- //#region src/api-verifications/entities/verifications.ts
30
- const verifications = (0, alepha_orm.$entity)({
31
- name: "verification",
32
- schema: alepha.t.object({
33
- id: alepha_orm.pg.primaryKey(alepha.t.bigint()),
34
- createdAt: alepha_orm.pg.createdAt(),
35
- updatedAt: alepha_orm.pg.updatedAt(),
36
- version: alepha_orm.pg.version(),
37
- type: verificationTypeEnumSchema,
38
- target: alepha.t.text({ description: "Can be a phone (E.164 format) or email address" }),
39
- code: alepha.t.text({ description: "Hashed verification token (n-digit code or UUID)" }),
40
- verifiedAt: alepha.t.optional(alepha.t.datetime({ description: "When it was successfully verified" })),
41
- attempts: alepha_orm.pg.default(alepha.t.integer({ description: "Number of failed attempts (to prevent brute-force)" }), 0)
42
- }),
43
- indexes: ["createdAt", { columns: ["target", "code"] }]
44
- });
45
- const verificationEntitySchema = verifications.schema;
46
- const verificationEntityInsertSchema = verifications.insertSchema;
47
-
48
- //#endregion
49
- //#region src/api-verifications/schemas/verificationSettingsSchema.ts
50
- const verificationSettingsSchema = alepha.t.object({
51
- code: alepha.t.object({
52
- maxAttempts: alepha.t.integer({
53
- description: "Maximum number of attempts before locking the verification.",
54
- minimum: 1,
55
- maximum: 10
56
- }),
57
- codeLength: alepha.t.integer({
58
- description: "Length of the verification code.",
59
- minimum: 4,
60
- maximum: 12
61
- }),
62
- codeExpiration: alepha.t.integer({
63
- description: "Time in seconds before the verification code expires.",
64
- minimum: 60,
65
- maximum: 3600
66
- }),
67
- verificationCooldown: alepha.t.integer({
68
- description: "Cooldown period in seconds after a request verification.",
69
- minimum: 0,
70
- maximum: 3600
71
- }),
72
- limitPerDay: alepha.t.integer({
73
- description: "Maximum number of verification requests per day for one entry.",
74
- minimum: 1,
75
- maximum: 100
76
- })
77
- }, { description: "Settings specific to code verifications." }),
78
- link: alepha.t.object({
79
- maxAttempts: alepha.t.integer({
80
- description: "Maximum number of attempts before locking the verification.",
81
- minimum: 1,
82
- maximum: 10
83
- }),
84
- codeExpiration: alepha.t.integer({
85
- description: "Time in seconds before the verification token expires.",
86
- minimum: 60,
87
- maximum: 7200
88
- }),
89
- verificationCooldown: alepha.t.integer({
90
- description: "Cooldown period in seconds after a request verification.",
91
- minimum: 0,
92
- maximum: 3600
93
- }),
94
- limitPerDay: alepha.t.integer({
95
- description: "Maximum number of verification requests per day for one entry.",
96
- minimum: 1,
97
- maximum: 100
98
- })
99
- }, { description: "Settings specific to link verifications." }),
100
- purgeDays: alepha.t.integer({
101
- description: "Number of days after which expired verifications are automatically deleted. Set to 0 to disable auto-deletion.",
102
- minimum: 0,
103
- maximum: 365
104
- })
105
- });
106
-
107
- //#endregion
108
- //#region src/api-verifications/parameters/VerificationParameters.ts
109
- /**
110
- * Verification settings configuration atom
111
- */
112
- const verificationOptions = (0, alepha.$atom)({
113
- name: "alepha.api.verifications.options",
114
- schema: verificationSettingsSchema,
115
- default: {
116
- code: {
117
- maxAttempts: 5,
118
- codeLength: 6,
119
- codeExpiration: 300,
120
- verificationCooldown: 90,
121
- limitPerDay: 10
122
- },
123
- link: {
124
- maxAttempts: 3,
125
- codeExpiration: 1800,
126
- verificationCooldown: 90,
127
- limitPerDay: 10
128
- },
129
- purgeDays: 1
130
- }
131
- });
132
- var VerificationParameters = class {
133
- options = (0, alepha.$use)(verificationOptions);
134
- get(key) {
135
- return this.options[key];
136
- }
137
- };
138
-
139
- //#endregion
140
- //#region src/api-verifications/services/VerificationService.ts
141
- var VerificationService = class {
142
- log = (0, alepha_logger.$logger)();
143
- dateTimeProvider = (0, alepha.$inject)(alepha_datetime.DateTimeProvider);
144
- verificationParameters = (0, alepha.$inject)(VerificationParameters);
145
- verificationRepository = (0, alepha_orm.$repository)(verifications);
146
- async findByEntry(entry) {
147
- this.log.trace("Finding verification by entry", {
148
- type: entry.type,
149
- target: entry.target
150
- });
151
- const results = await this.verificationRepository.findMany({
152
- limit: 1,
153
- orderBy: {
154
- column: "createdAt",
155
- direction: "desc"
156
- },
157
- where: {
158
- type: { eq: entry.type },
159
- target: { eq: entry.target }
160
- }
161
- });
162
- if (results.length === 0) {
163
- this.log.debug("Verification entry not found", {
164
- type: entry.type,
165
- target: entry.target
166
- });
167
- throw new alepha_server.NotFoundError("Verification entry not found");
168
- }
169
- this.log.debug("Verification entry found", {
170
- id: results[0].id,
171
- type: entry.type,
172
- target: entry.target
173
- });
174
- return results[0];
175
- }
176
- findRecentsByEntry(entry) {
177
- this.log.trace("Finding recent verifications by entry", {
178
- type: entry.type,
179
- target: entry.target
180
- });
181
- return this.verificationRepository.findMany({
182
- orderBy: {
183
- column: "createdAt",
184
- direction: "desc"
185
- },
186
- where: {
187
- type: { eq: entry.type },
188
- target: { eq: entry.target },
189
- createdAt: { gte: this.dateTimeProvider.now().startOf("day").toISOString() }
190
- }
191
- });
192
- }
193
- /**
194
- * Creates a verification entry and returns the token.
195
- * The caller is responsible for sending notifications with the token.
196
- * This allows for context-specific notifications (e.g., password reset vs email verification).
197
- */
198
- async createVerification(entry) {
199
- this.log.trace("Creating verification", {
200
- type: entry.type,
201
- target: entry.target
202
- });
203
- const settings = this.verificationParameters.get(entry.type);
204
- const recents = await this.findRecentsByEntry(entry);
205
- if (recents.length >= settings.limitPerDay) {
206
- this.log.warn("Daily verification limit reached", {
207
- type: entry.type,
208
- target: entry.target,
209
- limit: settings.limitPerDay,
210
- count: recents.length
211
- });
212
- throw new alepha_server.BadRequestError(`Maximum number of verification requests per day reached (${settings.limitPerDay})`);
213
- }
214
- const existingVerification = recents[0];
215
- if (existingVerification) {
216
- const diffSec = this.dateTimeProvider.now().unix() - this.dateTimeProvider.of(existingVerification.createdAt).unix();
217
- if (diffSec < settings.verificationCooldown) {
218
- const remainingCooldown = Math.floor(settings.verificationCooldown - diffSec);
219
- this.log.debug("Verification on cooldown", {
220
- type: entry.type,
221
- target: entry.target,
222
- remainingSeconds: remainingCooldown
223
- });
224
- throw new alepha_server.BadRequestError(`Verification is on cooldown for ${remainingCooldown} seconds`);
225
- }
226
- }
227
- const token = this.generateToken(entry.type);
228
- const verification = await this.verificationRepository.create({
229
- type: entry.type,
230
- target: entry.target,
231
- code: this.hashCode(token)
232
- });
233
- this.log.info("Verification created", {
234
- id: verification.id,
235
- type: entry.type,
236
- target: entry.target,
237
- expiresInSeconds: settings.codeExpiration
238
- });
239
- return {
240
- token,
241
- codeExpiration: settings.codeExpiration,
242
- verificationCooldown: settings.verificationCooldown,
243
- maxVerificationAttempts: settings.maxAttempts
244
- };
245
- }
246
- async verifyCode(entry, code) {
247
- this.log.trace("Verifying code", {
248
- type: entry.type,
249
- target: entry.target
250
- });
251
- const settings = this.verificationParameters.get(entry.type);
252
- const verification = await this.findByEntry(entry);
253
- if (verification.verifiedAt) {
254
- this.log.debug("Verification already verified", {
255
- id: verification.id,
256
- type: entry.type,
257
- target: entry.target,
258
- verifiedAt: verification.verifiedAt
259
- });
260
- return {
261
- ok: true,
262
- alreadyVerified: true
263
- };
264
- }
265
- const now = this.dateTimeProvider.now();
266
- const expirationDate = this.dateTimeProvider.of(verification.createdAt).add(settings.codeExpiration, "seconds");
267
- if (now > expirationDate) {
268
- this.log.warn("Verification code expired", {
269
- id: verification.id,
270
- type: entry.type,
271
- target: entry.target,
272
- createdAt: verification.createdAt,
273
- expiredAt: expirationDate.toISOString()
274
- });
275
- throw new alepha_server.BadRequestError("Verification code has expired");
276
- }
277
- if (verification.attempts >= settings.maxAttempts) {
278
- this.log.warn("Verification locked due to max attempts", {
279
- id: verification.id,
280
- type: entry.type,
281
- target: entry.target,
282
- attempts: verification.attempts,
283
- maxAttempts: settings.maxAttempts
284
- });
285
- throw new alepha_server.BadRequestError("Maximum number of attempts reached - verification is locked");
286
- }
287
- if (verification.code !== this.hashCode(code)) {
288
- const newAttempts = verification.attempts + 1;
289
- this.log.warn("Invalid verification code", {
290
- id: verification.id,
291
- type: entry.type,
292
- target: entry.target,
293
- attempts: newAttempts,
294
- maxAttempts: settings.maxAttempts
295
- });
296
- await this.verificationRepository.updateById(verification.id, { attempts: newAttempts });
297
- throw new alepha_server.BadRequestError("Invalid verification code");
298
- }
299
- await this.verificationRepository.updateById(verification.id, { verifiedAt: this.dateTimeProvider.nowISOString() });
300
- this.log.info("Verification code verified", {
301
- id: verification.id,
302
- type: entry.type,
303
- target: entry.target
304
- });
305
- return { ok: true };
306
- }
307
- hashCode(code) {
308
- return (0, node_crypto.createHash)("sha256").update(code).digest("hex");
309
- }
310
- generateToken(type) {
311
- if (type === "code") {
312
- const settings = this.verificationParameters.get("code");
313
- return (0, node_crypto.randomInt)(0, 1e6).toString().padStart(settings.codeLength, "0");
314
- } else if (type === "link") return (0, node_crypto.randomUUID)();
315
- throw new alepha_server.BadRequestError(`Invalid verification type: ${type}`);
316
- }
317
- };
318
-
319
- //#endregion
320
- //#region src/api-verifications/controllers/VerificationController.ts
321
- var VerificationController = class {
322
- verificationService = (0, alepha.$inject)(VerificationService);
323
- url = "/verifications";
324
- group = "verifications";
325
- requestVerificationCode = (0, alepha_server.$action)({
326
- path: `${this.url}/:type`,
327
- group: this.group,
328
- method: "POST",
329
- schema: {
330
- params: alepha.t.object({ type: verificationTypeEnumSchema }),
331
- body: alepha.t.object({ target: alepha.t.text() }),
332
- response: requestVerificationCodeResponseSchema
333
- },
334
- handler: async ({ body, params }) => {
335
- return await this.verificationService.createVerification({
336
- type: params.type,
337
- target: body.target
338
- });
339
- }
340
- });
341
- validateVerificationCode = (0, alepha_server.$action)({
342
- path: `${this.url}/:type/validate`,
343
- group: this.group,
344
- method: "POST",
345
- schema: {
346
- params: alepha.t.object({ type: verificationTypeEnumSchema }),
347
- body: alepha.t.object({
348
- target: alepha.t.text(),
349
- token: alepha.t.text({ description: "The verification token (6-digit code for phone, UUID for email)." })
350
- }),
351
- response: validateVerificationCodeResponseSchema
352
- },
353
- handler: async ({ body, params }) => {
354
- return this.verificationService.verifyCode({
355
- type: params.type,
356
- target: body.target
357
- }, body.token);
358
- }
359
- });
360
- };
361
-
362
- //#endregion
363
- //#region src/api-verifications/jobs/VerificationJobs.ts
364
- var VerificationJobs = class {
365
- verificationRepository = (0, alepha_orm.$repository)(verifications);
366
- verificationParameters = (0, alepha.$inject)(VerificationParameters);
367
- dateTimeProvider = (0, alepha.$inject)(alepha_datetime.DateTimeProvider);
368
- cleanExpired = (0, alepha_scheduler.$scheduler)({
369
- cron: "0 0 * * *",
370
- description: "Clean expired verifications",
371
- handler: async () => {
372
- const purgeDays = this.verificationParameters.get("purgeDays");
373
- if (purgeDays <= 0) return;
374
- const purgeThreshold = Date.now() - purgeDays * (1440 * 60 * 1e3);
375
- await this.verificationRepository.deleteMany({ createdAt: { lt: this.dateTimeProvider.of(purgeThreshold).toISOString() } });
376
- }
377
- });
378
- };
379
-
380
- //#endregion
381
- //#region src/api-verifications/index.ts
382
- /**
383
- * Provides email/phone verification management API endpoints for Alepha applications.
384
- *
385
- * This module includes verification code generation, validation,
386
- * and related functionalities. Notifications are handled by the consuming module
387
- * (e.g., api-users) for context-specific messaging.
388
- *
389
- * @module alepha.api.verifications
390
- */
391
- const AlephaApiVerification = (0, alepha.$module)({
392
- name: "alepha.api.verifications",
393
- services: [
394
- VerificationController,
395
- VerificationJobs,
396
- VerificationService
397
- ]
398
- });
399
-
400
- //#endregion
401
- exports.AlephaApiVerification = AlephaApiVerification;
402
- exports.VerificationController = VerificationController;
403
- exports.VerificationService = VerificationService;
404
- exports.requestVerificationCodeResponseSchema = requestVerificationCodeResponseSchema;
405
- exports.validateVerificationCodeResponseSchema = validateVerificationCodeResponseSchema;
406
- exports.verificationTypeEnumSchema = verificationTypeEnumSchema;
407
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","names":["t","t","t","t","pg","t","DateTimeProvider","NotFoundError","BadRequestError","t","DateTimeProvider"],"sources":["../../src/api-verifications/schemas/requestVerificationCodeResponseSchema.ts","../../src/api-verifications/schemas/validateVerificationCodeResponseSchema.ts","../../src/api-verifications/schemas/verificationTypeEnumSchema.ts","../../src/api-verifications/entities/verifications.ts","../../src/api-verifications/schemas/verificationSettingsSchema.ts","../../src/api-verifications/parameters/VerificationParameters.ts","../../src/api-verifications/services/VerificationService.ts","../../src/api-verifications/controllers/VerificationController.ts","../../src/api-verifications/jobs/VerificationJobs.ts","../../src/api-verifications/index.ts"],"sourcesContent":["import type { Static } from \"alepha\";\nimport { t } from \"alepha\";\n\nexport const requestVerificationCodeResponseSchema = t.object({\n token: t.string({\n description:\n \"The verification token (6-digit code for phone, UUID for email). The caller should send this to the user via their preferred notification method.\",\n }),\n codeExpiration: t.integer({\n description: \"Time in seconds before your verification token expires.\",\n }),\n verificationCooldown: t.integer({\n description:\n \"Cooldown period in seconds before you can request another verification.\",\n }),\n maxVerificationAttempts: t.integer({\n description:\n \"Maximum number of verification attempts allowed before the token is locked.\",\n }),\n});\n\nexport type RequestVerificationResponse = Static<\n typeof requestVerificationCodeResponseSchema\n>;\n","import type { Static } from \"alepha\";\nimport { t } from \"alepha\";\n\nexport const validateVerificationCodeResponseSchema = t.object({\n ok: t.boolean({\n description: \"Indicates whether the verification was successful.\",\n }),\n alreadyVerified: t.optional(\n t.boolean({\n description: \"Indicates whether the target was already verified.\",\n }),\n ),\n});\n\nexport type ValidateVerificationCodeResponse = Static<\n typeof validateVerificationCodeResponseSchema\n>;\n","import type { Static } from \"alepha\";\nimport { t } from \"alepha\";\n\nexport const verificationTypeEnumSchema = t.enum([\"code\", \"link\"]);\nexport type VerificationTypeEnum = Static<typeof verificationTypeEnumSchema>;\n","import type { Static } from \"alepha\";\nimport { t } from \"alepha\";\nimport { $entity, pg } from \"alepha/orm\";\nimport { verificationTypeEnumSchema } from \"../schemas/verificationTypeEnumSchema.ts\";\n\nexport const verifications = $entity({\n name: \"verification\",\n schema: t.object({\n id: pg.primaryKey(t.bigint()),\n\n createdAt: pg.createdAt(),\n\n updatedAt: pg.updatedAt(),\n\n version: pg.version(),\n\n type: verificationTypeEnumSchema,\n\n target: t.text({\n description: \"Can be a phone (E.164 format) or email address\",\n }),\n\n code: t.text({\n description: \"Hashed verification token (n-digit code or UUID)\",\n }),\n\n verifiedAt: t.optional(\n t.datetime({\n description: \"When it was successfully verified\",\n }),\n ),\n\n attempts: pg.default(\n t.integer({\n description: \"Number of failed attempts (to prevent brute-force)\",\n }),\n 0,\n ),\n }),\n indexes: [\n \"createdAt\",\n {\n columns: [\"target\", \"code\"],\n },\n ],\n});\n\nexport const verificationEntitySchema = verifications.schema;\nexport const verificationEntityInsertSchema = verifications.insertSchema;\nexport type VerificationEntity = Static<typeof verifications.schema>;\n","import type { Static } from \"alepha\";\nimport { t } from \"alepha\";\n\nexport const verificationSettingsSchema = t.object({\n code: t.object(\n {\n maxAttempts: t.integer({\n description:\n \"Maximum number of attempts before locking the verification.\",\n minimum: 1,\n maximum: 10,\n }),\n codeLength: t.integer({\n description: \"Length of the verification code.\",\n minimum: 4,\n maximum: 12,\n }),\n codeExpiration: t.integer({\n description: \"Time in seconds before the verification code expires.\",\n minimum: 60, // 1 minute\n maximum: 3600, // 1 hour\n }),\n verificationCooldown: t.integer({\n description: \"Cooldown period in seconds after a request verification.\",\n minimum: 0,\n maximum: 3600, // 1 hour\n }),\n limitPerDay: t.integer({\n description:\n \"Maximum number of verification requests per day for one entry.\",\n minimum: 1,\n maximum: 100,\n }),\n },\n {\n description: \"Settings specific to code verifications.\",\n },\n ),\n link: t.object(\n {\n maxAttempts: t.integer({\n description:\n \"Maximum number of attempts before locking the verification.\",\n minimum: 1,\n maximum: 10,\n }),\n codeExpiration: t.integer({\n description: \"Time in seconds before the verification token expires.\",\n minimum: 60, // 1 minute\n maximum: 7200, // 2 hours\n }),\n verificationCooldown: t.integer({\n description: \"Cooldown period in seconds after a request verification.\",\n minimum: 0,\n maximum: 3600, // 1 hour\n }),\n limitPerDay: t.integer({\n description:\n \"Maximum number of verification requests per day for one entry.\",\n minimum: 1,\n maximum: 100,\n }),\n },\n {\n description: \"Settings specific to link verifications.\",\n },\n ),\n purgeDays: t.integer({\n description:\n \"Number of days after which expired verifications are automatically deleted. Set to 0 to disable auto-deletion.\",\n minimum: 0,\n maximum: 365,\n }),\n});\n\nexport type VerificationSettings = Static<typeof verificationSettingsSchema>;\n","import { $atom, $use, type Static } from \"alepha\";\nimport {\n type VerificationSettings,\n verificationSettingsSchema,\n} from \"../schemas/verificationSettingsSchema.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n/**\n * Verification settings configuration atom\n */\nexport const verificationOptions = $atom({\n name: \"alepha.api.verifications.options\",\n schema: verificationSettingsSchema,\n default: {\n code: {\n maxAttempts: 5,\n codeLength: 6,\n codeExpiration: 300, // 5 minutes\n verificationCooldown: 90,\n limitPerDay: 10,\n },\n link: {\n maxAttempts: 3, // Lower since UUIDs are harder to guess\n codeExpiration: 1800, // 30 minutes\n verificationCooldown: 90,\n limitPerDay: 10,\n },\n purgeDays: 1,\n },\n});\n\nexport type VerificationOptions = Static<typeof verificationOptions.schema>;\n\ndeclare module \"alepha\" {\n interface State {\n [verificationOptions.key]: VerificationOptions;\n }\n}\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport class VerificationParameters {\n protected readonly options = $use(verificationOptions);\n\n public get<K extends keyof VerificationSettings>(\n key: K,\n ): VerificationSettings[K] {\n return this.options[key];\n }\n}\n","import { createHash, randomInt, randomUUID } from \"node:crypto\";\nimport { $inject } from \"alepha\";\nimport { DateTimeProvider } from \"alepha/datetime\";\nimport { $logger } from \"alepha/logger\";\nimport { $repository } from \"alepha/orm\";\nimport { BadRequestError, NotFoundError } from \"alepha/server\";\nimport {\n type VerificationEntity,\n verifications,\n} from \"../entities/verifications.ts\";\nimport { VerificationParameters } from \"../parameters/VerificationParameters.ts\";\nimport type { RequestVerificationResponse } from \"../schemas/requestVerificationCodeResponseSchema.ts\";\nimport type { ValidateVerificationCodeResponse } from \"../schemas/validateVerificationCodeResponseSchema.ts\";\nimport type { VerificationTypeEnum } from \"../schemas/verificationTypeEnumSchema.ts\";\n\nexport class VerificationService {\n protected readonly log = $logger();\n protected readonly dateTimeProvider = $inject(DateTimeProvider);\n protected readonly verificationParameters = $inject(VerificationParameters);\n protected readonly verificationRepository = $repository(verifications);\n\n public async findByEntry(\n entry: VerificationEntry,\n ): Promise<VerificationEntity> {\n this.log.trace(\"Finding verification by entry\", {\n type: entry.type,\n target: entry.target,\n });\n\n const results = await this.verificationRepository.findMany({\n limit: 1, // only need the most recent entry\n orderBy: {\n column: \"createdAt\",\n direction: \"desc\",\n },\n where: {\n type: { eq: entry.type },\n target: { eq: entry.target },\n },\n });\n\n if (results.length === 0) {\n this.log.debug(\"Verification entry not found\", {\n type: entry.type,\n target: entry.target,\n });\n throw new NotFoundError(\"Verification entry not found\");\n }\n\n this.log.debug(\"Verification entry found\", {\n id: results[0].id,\n type: entry.type,\n target: entry.target,\n });\n\n return results[0];\n }\n\n public findRecentsByEntry(entry: VerificationEntry) {\n this.log.trace(\"Finding recent verifications by entry\", {\n type: entry.type,\n target: entry.target,\n });\n\n return this.verificationRepository.findMany({\n orderBy: {\n column: \"createdAt\",\n direction: \"desc\",\n },\n where: {\n type: { eq: entry.type },\n target: { eq: entry.target },\n createdAt: {\n gte: this.dateTimeProvider.now().startOf(\"day\").toISOString(),\n },\n },\n });\n }\n\n /**\n * Creates a verification entry and returns the token.\n * The caller is responsible for sending notifications with the token.\n * This allows for context-specific notifications (e.g., password reset vs email verification).\n */\n public async createVerification(\n entry: VerificationEntry,\n ): Promise<RequestVerificationResponse> {\n this.log.trace(\"Creating verification\", {\n type: entry.type,\n target: entry.target,\n });\n\n const settings = this.verificationParameters.get(entry.type);\n\n const recents = await this.findRecentsByEntry(entry);\n if (recents.length >= settings.limitPerDay) {\n this.log.warn(\"Daily verification limit reached\", {\n type: entry.type,\n target: entry.target,\n limit: settings.limitPerDay,\n count: recents.length,\n });\n throw new BadRequestError(\n `Maximum number of verification requests per day reached (${settings.limitPerDay})`,\n );\n }\n\n const existingVerification = recents[0];\n if (existingVerification) {\n const nowSec = this.dateTimeProvider.now().unix();\n const createdAtSec = this.dateTimeProvider\n .of(existingVerification.createdAt)\n .unix();\n\n const diffSec = nowSec - createdAtSec;\n if (diffSec < settings.verificationCooldown) {\n const remainingCooldown = Math.floor(\n settings.verificationCooldown - diffSec,\n );\n this.log.debug(\"Verification on cooldown\", {\n type: entry.type,\n target: entry.target,\n remainingSeconds: remainingCooldown,\n });\n throw new BadRequestError(\n `Verification is on cooldown for ${remainingCooldown} seconds`,\n );\n }\n }\n\n const token = this.generateToken(entry.type);\n\n const verification = await this.verificationRepository.create({\n type: entry.type,\n target: entry.target,\n code: this.hashCode(token),\n });\n\n this.log.info(\"Verification created\", {\n id: verification.id,\n type: entry.type,\n target: entry.target,\n expiresInSeconds: settings.codeExpiration,\n });\n\n return {\n token,\n codeExpiration: settings.codeExpiration,\n verificationCooldown: settings.verificationCooldown,\n maxVerificationAttempts: settings.maxAttempts,\n };\n }\n\n public async verifyCode(\n entry: VerificationEntry,\n code: string,\n ): Promise<ValidateVerificationCodeResponse> {\n this.log.trace(\"Verifying code\", {\n type: entry.type,\n target: entry.target,\n });\n\n const settings = this.verificationParameters.get(entry.type);\n\n const verification = await this.findByEntry(entry);\n if (verification.verifiedAt) {\n this.log.debug(\"Verification already verified\", {\n id: verification.id,\n type: entry.type,\n target: entry.target,\n verifiedAt: verification.verifiedAt,\n });\n return { ok: true, alreadyVerified: true };\n }\n\n // DO NOT DELETE THE VERIFICATION WHEN IT IS REJECTED,\n // or we won't be able to cooldown the verification\n\n const now = this.dateTimeProvider.now();\n const expirationDate = this.dateTimeProvider\n .of(verification.createdAt)\n .add(settings.codeExpiration, \"seconds\");\n\n if (now > expirationDate) {\n this.log.warn(\"Verification code expired\", {\n id: verification.id,\n type: entry.type,\n target: entry.target,\n createdAt: verification.createdAt,\n expiredAt: expirationDate.toISOString(),\n });\n throw new BadRequestError(\"Verification code has expired\");\n }\n\n if (verification.attempts >= settings.maxAttempts) {\n this.log.warn(\"Verification locked due to max attempts\", {\n id: verification.id,\n type: entry.type,\n target: entry.target,\n attempts: verification.attempts,\n maxAttempts: settings.maxAttempts,\n });\n throw new BadRequestError(\n \"Maximum number of attempts reached - verification is locked\",\n );\n }\n\n if (verification.code !== this.hashCode(code)) {\n const newAttempts = verification.attempts + 1;\n this.log.warn(\"Invalid verification code\", {\n id: verification.id,\n type: entry.type,\n target: entry.target,\n attempts: newAttempts,\n maxAttempts: settings.maxAttempts,\n });\n await this.verificationRepository.updateById(verification.id, {\n attempts: newAttempts,\n });\n throw new BadRequestError(\"Invalid verification code\");\n }\n\n await this.verificationRepository.updateById(verification.id, {\n verifiedAt: this.dateTimeProvider.nowISOString(),\n });\n\n this.log.info(\"Verification code verified\", {\n id: verification.id,\n type: entry.type,\n target: entry.target,\n });\n\n return { ok: true };\n }\n\n public hashCode(code: string): string {\n return createHash(\"sha256\").update(code).digest(\"hex\");\n }\n\n public generateToken(type: VerificationTypeEnum): string {\n if (type === \"code\") {\n const settings = this.verificationParameters.get(\"code\");\n return randomInt(0, 1_000_000)\n .toString()\n .padStart(settings.codeLength, \"0\");\n } else if (type === \"link\") {\n return randomUUID();\n }\n\n throw new BadRequestError(`Invalid verification type: ${type}`);\n }\n}\n\nexport interface VerificationEntry {\n type: VerificationTypeEnum;\n target: string;\n}\n","import { $inject, t } from \"alepha\";\nimport { $action } from \"alepha/server\";\nimport { requestVerificationCodeResponseSchema } from \"../schemas/requestVerificationCodeResponseSchema.ts\";\nimport { validateVerificationCodeResponseSchema } from \"../schemas/validateVerificationCodeResponseSchema.ts\";\nimport { verificationTypeEnumSchema } from \"../schemas/verificationTypeEnumSchema.ts\";\nimport { VerificationService } from \"../services/VerificationService.ts\";\n\nexport class VerificationController {\n protected readonly verificationService = $inject(VerificationService);\n\n public readonly url = \"/verifications\";\n public readonly group = \"verifications\";\n\n public readonly requestVerificationCode = $action({\n path: `${this.url}/:type`,\n group: this.group,\n method: \"POST\",\n schema: {\n params: t.object({\n type: verificationTypeEnumSchema,\n }),\n body: t.object({\n target: t.text(),\n }),\n response: requestVerificationCodeResponseSchema,\n },\n handler: async ({ body, params }) => {\n return await this.verificationService.createVerification({\n type: params.type,\n target: body.target,\n });\n },\n });\n\n public readonly validateVerificationCode = $action({\n path: `${this.url}/:type/validate`,\n group: this.group,\n method: \"POST\",\n schema: {\n params: t.object({\n type: verificationTypeEnumSchema,\n }),\n body: t.object({\n target: t.text(),\n token: t.text({\n description:\n \"The verification token (6-digit code for phone, UUID for email).\",\n }),\n }),\n response: validateVerificationCodeResponseSchema,\n },\n handler: async ({ body, params }) => {\n return this.verificationService.verifyCode(\n {\n type: params.type,\n target: body.target,\n },\n body.token,\n );\n },\n });\n}\n","import { $inject } from \"alepha\";\nimport { DateTimeProvider } from \"alepha/datetime\";\nimport { $repository } from \"alepha/orm\";\nimport { $scheduler } from \"alepha/scheduler\";\nimport { verifications } from \"../entities/verifications.ts\";\nimport { VerificationParameters } from \"../parameters/VerificationParameters.ts\";\n\nexport class VerificationJobs {\n protected readonly verificationRepository = $repository(verifications);\n protected readonly verificationParameters = $inject(VerificationParameters);\n protected readonly dateTimeProvider = $inject(DateTimeProvider);\n\n public readonly cleanExpired = $scheduler({\n cron: \"0 0 * * *\", // Every day at midnight\n description: \"Clean expired verifications\",\n handler: async () => {\n const purgeDays = this.verificationParameters.get(\"purgeDays\");\n if (purgeDays <= 0) {\n return; // Auto deletion is disabled\n }\n\n const dayMs = 24 * 60 * 60 * 1000;\n const purgeThreshold = Date.now() - purgeDays * dayMs;\n\n await this.verificationRepository.deleteMany({\n createdAt: {\n lt: this.dateTimeProvider.of(purgeThreshold).toISOString(),\n },\n });\n },\n });\n}\n","import { $module } from \"alepha\";\nimport { VerificationController } from \"./controllers/VerificationController.ts\";\nimport { VerificationJobs } from \"./jobs/VerificationJobs.ts\";\nimport { VerificationService } from \"./services/VerificationService.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport * from \"./controllers/VerificationController.ts\";\nexport * from \"./schemas/requestVerificationCodeResponseSchema.ts\";\nexport * from \"./schemas/validateVerificationCodeResponseSchema.ts\";\nexport * from \"./schemas/verificationTypeEnumSchema.ts\";\nexport * from \"./services/VerificationService.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\n/**\n * Provides email/phone verification management API endpoints for Alepha applications.\n *\n * This module includes verification code generation, validation,\n * and related functionalities. Notifications are handled by the consuming module\n * (e.g., api-users) for context-specific messaging.\n *\n * @module alepha.api.verifications\n */\nexport const AlephaApiVerification = $module({\n name: \"alepha.api.verifications\",\n services: [VerificationController, VerificationJobs, VerificationService],\n});\n"],"mappings":";;;;;;;;;AAGA,MAAa,wCAAwCA,SAAE,OAAO;CAC5D,OAAOA,SAAE,OAAO,EACd,aACE,qJACH,CAAC;CACF,gBAAgBA,SAAE,QAAQ,EACxB,aAAa,2DACd,CAAC;CACF,sBAAsBA,SAAE,QAAQ,EAC9B,aACE,2EACH,CAAC;CACF,yBAAyBA,SAAE,QAAQ,EACjC,aACE,+EACH,CAAC;CACH,CAAC;;;;AChBF,MAAa,yCAAyCC,SAAE,OAAO;CAC7D,IAAIA,SAAE,QAAQ,EACZ,aAAa,sDACd,CAAC;CACF,iBAAiBA,SAAE,SACjBA,SAAE,QAAQ,EACR,aAAa,sDACd,CAAC,CACH;CACF,CAAC;;;;ACTF,M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,MAAM,EACjB,CAAC;GACF,UAAU;GACX;EACD,SAAS,OAAO,EAAE,MAAM,aAAa;AACnC,UAAO,MAAM,KAAK,oBAAoB,mBAAmB;IACvD,MAAM,OAAO;IACb,QAAQ,KAAK;IACd,CAAC;;EAEL,CAAC;CAEF,AAAgB,sDAAmC;EACjD,MAAM,GAAG,KAAK,IAAI;EAClB,OAAO,KAAK;EACZ,QAAQ;EACR,QAAQ;GACN,QAAQA,SAAE,OAAO,EACf,MAAM,4BACP,CAAC;GACF,MAAMA,SAAE,OAAO;IACb,QAAQA,SAAE,MAAM;IAChB,OAAOA,SAAE,KAAK,EACZ,aACE,oEACH,CAAC;IACH,CAAC;GACF,UAAU;GACX;EACD,SAAS,OAAO,EAAE,MAAM,aAAa;AACnC,UAAO,KAAK,oBAAoB,WAC9B;IACE,MAAM,OAAO;IACb,QAAQ,KAAK;IACd,EACD,KAAK,MACN;;EAEJ,CAAC;;;;;ACrDJ,IAAa,mBAAb,MAA8B;CAC5B,AAAmB,qDAAqC,cAAc;CACtE,AAAmB,6CAAiC,uBAAuB;CAC3E,AAAmB,uCAA2BC,iCAAiB;CAE/D,AAAgB,gDAA0B;EACxC,MAAM;EACN,aAAa;EACb,SAAS,YAAY;GACnB,MAAM,YAAY,KAAK,uBAAuB,IAAI,YAAY;AAC9D,OAAI,aAAa,EACf;GAIF,MAAM,iBAAiB,KAAK,KAAK,GAAG,aADtB,OAAU,KAAK;AAG7B,SAAM,KAAK,uBAAuB,WAAW,EAC3C,WAAW,EACT,IAAI,KAAK,iBAAiB,GAAG,eAAe,CAAC,aAAa,EAC3D,EACF,CAAC;;EAEL,CAAC;;;;;;;;;;;;;;ACNJ,MAAa,4CAAgC;CAC3C,MAAM;CACN,UAAU;EAAC;EAAwB;EAAkB;EAAoB;CAC1E,CAAC"}
@@ -1,207 +0,0 @@
1
- import * as alepha76 from "alepha";
2
- import { Static } from "alepha";
3
- import * as alepha_server0 from "alepha/server";
4
- import * as alepha_logger0 from "alepha/logger";
5
- import * as alepha_orm56 from "alepha/orm";
6
- import { DateTimeProvider } from "alepha/datetime";
7
-
8
- //#region src/api-verifications/entities/verifications.d.ts
9
- declare const verifications: alepha_orm56.EntityDescriptor<alepha76.TObject<{
10
- id: alepha_orm56.PgAttr<alepha_orm56.PgAttr<alepha76.TString, typeof alepha_orm56.PG_PRIMARY_KEY>, typeof alepha_orm56.PG_DEFAULT>;
11
- createdAt: alepha_orm56.PgAttr<alepha_orm56.PgAttr<alepha76.TString, typeof alepha_orm56.PG_CREATED_AT>, typeof alepha_orm56.PG_DEFAULT>;
12
- updatedAt: alepha_orm56.PgAttr<alepha_orm56.PgAttr<alepha76.TString, typeof alepha_orm56.PG_UPDATED_AT>, typeof alepha_orm56.PG_DEFAULT>;
13
- version: alepha_orm56.PgAttr<alepha_orm56.PgAttr<alepha76.TInteger, typeof alepha_orm56.PG_VERSION>, typeof alepha_orm56.PG_DEFAULT>;
14
- type: alepha76.TUnsafe<"link" | "code">;
15
- target: alepha76.TString;
16
- code: alepha76.TString;
17
- verifiedAt: alepha76.TOptional<alepha76.TString>;
18
- attempts: alepha_orm56.PgAttr<alepha76.TInteger, typeof alepha_orm56.PG_DEFAULT>;
19
- }>>;
20
- type VerificationEntity = Static<typeof verifications.schema>;
21
- //#endregion
22
- //#region src/api-verifications/schemas/verificationSettingsSchema.d.ts
23
- declare const verificationSettingsSchema: alepha76.TObject<{
24
- code: alepha76.TObject<{
25
- maxAttempts: alepha76.TInteger;
26
- codeLength: alepha76.TInteger;
27
- codeExpiration: alepha76.TInteger;
28
- verificationCooldown: alepha76.TInteger;
29
- limitPerDay: alepha76.TInteger;
30
- }>;
31
- link: alepha76.TObject<{
32
- maxAttempts: alepha76.TInteger;
33
- codeExpiration: alepha76.TInteger;
34
- verificationCooldown: alepha76.TInteger;
35
- limitPerDay: alepha76.TInteger;
36
- }>;
37
- purgeDays: alepha76.TInteger;
38
- }>;
39
- type VerificationSettings = Static<typeof verificationSettingsSchema>;
40
- //#endregion
41
- //#region src/api-verifications/parameters/VerificationParameters.d.ts
42
- /**
43
- * Verification settings configuration atom
44
- */
45
- declare const verificationOptions: alepha76.Atom<alepha76.TObject<{
46
- code: alepha76.TObject<{
47
- maxAttempts: alepha76.TInteger;
48
- codeLength: alepha76.TInteger;
49
- codeExpiration: alepha76.TInteger;
50
- verificationCooldown: alepha76.TInteger;
51
- limitPerDay: alepha76.TInteger;
52
- }>;
53
- link: alepha76.TObject<{
54
- maxAttempts: alepha76.TInteger;
55
- codeExpiration: alepha76.TInteger;
56
- verificationCooldown: alepha76.TInteger;
57
- limitPerDay: alepha76.TInteger;
58
- }>;
59
- purgeDays: alepha76.TInteger;
60
- }>, "alepha.api.verifications.options">;
61
- type VerificationOptions = Static<typeof verificationOptions.schema>;
62
- declare module "alepha" {
63
- interface State {
64
- [verificationOptions.key]: VerificationOptions;
65
- }
66
- }
67
- declare class VerificationParameters {
68
- protected readonly options: Readonly<{
69
- link: {
70
- codeExpiration: number;
71
- verificationCooldown: number;
72
- maxAttempts: number;
73
- limitPerDay: number;
74
- };
75
- code: {
76
- codeExpiration: number;
77
- verificationCooldown: number;
78
- maxAttempts: number;
79
- codeLength: number;
80
- limitPerDay: number;
81
- };
82
- purgeDays: number;
83
- }>;
84
- get<K extends keyof VerificationSettings>(key: K): VerificationSettings[K];
85
- }
86
- //#endregion
87
- //#region src/api-verifications/schemas/requestVerificationCodeResponseSchema.d.ts
88
- declare const requestVerificationCodeResponseSchema: alepha76.TObject<{
89
- token: alepha76.TString;
90
- codeExpiration: alepha76.TInteger;
91
- verificationCooldown: alepha76.TInteger;
92
- maxVerificationAttempts: alepha76.TInteger;
93
- }>;
94
- type RequestVerificationResponse = Static<typeof requestVerificationCodeResponseSchema>;
95
- //#endregion
96
- //#region src/api-verifications/schemas/validateVerificationCodeResponseSchema.d.ts
97
- declare const validateVerificationCodeResponseSchema: alepha76.TObject<{
98
- ok: alepha76.TBoolean;
99
- alreadyVerified: alepha76.TOptional<alepha76.TBoolean>;
100
- }>;
101
- type ValidateVerificationCodeResponse = Static<typeof validateVerificationCodeResponseSchema>;
102
- //#endregion
103
- //#region src/api-verifications/schemas/verificationTypeEnumSchema.d.ts
104
- declare const verificationTypeEnumSchema: alepha76.TUnsafe<"link" | "code">;
105
- type VerificationTypeEnum = Static<typeof verificationTypeEnumSchema>;
106
- //#endregion
107
- //#region src/api-verifications/services/VerificationService.d.ts
108
- declare class VerificationService {
109
- protected readonly log: alepha_logger0.Logger;
110
- protected readonly dateTimeProvider: DateTimeProvider;
111
- protected readonly verificationParameters: VerificationParameters;
112
- protected readonly verificationRepository: alepha_orm56.Repository<alepha76.TObject<{
113
- id: alepha_orm56.PgAttr<alepha_orm56.PgAttr<alepha76.TString, typeof alepha_orm56.PG_PRIMARY_KEY>, typeof alepha_orm56.PG_DEFAULT>;
114
- createdAt: alepha_orm56.PgAttr<alepha_orm56.PgAttr<alepha76.TString, typeof alepha_orm56.PG_CREATED_AT>, typeof alepha_orm56.PG_DEFAULT>;
115
- updatedAt: alepha_orm56.PgAttr<alepha_orm56.PgAttr<alepha76.TString, typeof alepha_orm56.PG_UPDATED_AT>, typeof alepha_orm56.PG_DEFAULT>;
116
- version: alepha_orm56.PgAttr<alepha_orm56.PgAttr<alepha76.TInteger, typeof alepha_orm56.PG_VERSION>, typeof alepha_orm56.PG_DEFAULT>;
117
- type: alepha76.TUnsafe<"link" | "code">;
118
- target: alepha76.TString;
119
- code: alepha76.TString;
120
- verifiedAt: alepha76.TOptional<alepha76.TString>;
121
- attempts: alepha_orm56.PgAttr<alepha76.TInteger, typeof alepha_orm56.PG_DEFAULT>;
122
- }>>;
123
- findByEntry(entry: VerificationEntry): Promise<VerificationEntity>;
124
- findRecentsByEntry(entry: VerificationEntry): Promise<alepha_orm56.PgStatic<alepha76.TObject<{
125
- id: alepha_orm56.PgAttr<alepha_orm56.PgAttr<alepha76.TString, typeof alepha_orm56.PG_PRIMARY_KEY>, typeof alepha_orm56.PG_DEFAULT>;
126
- createdAt: alepha_orm56.PgAttr<alepha_orm56.PgAttr<alepha76.TString, typeof alepha_orm56.PG_CREATED_AT>, typeof alepha_orm56.PG_DEFAULT>;
127
- updatedAt: alepha_orm56.PgAttr<alepha_orm56.PgAttr<alepha76.TString, typeof alepha_orm56.PG_UPDATED_AT>, typeof alepha_orm56.PG_DEFAULT>;
128
- version: alepha_orm56.PgAttr<alepha_orm56.PgAttr<alepha76.TInteger, typeof alepha_orm56.PG_VERSION>, typeof alepha_orm56.PG_DEFAULT>;
129
- type: alepha76.TUnsafe<"link" | "code">;
130
- target: alepha76.TString;
131
- code: alepha76.TString;
132
- verifiedAt: alepha76.TOptional<alepha76.TString>;
133
- attempts: alepha_orm56.PgAttr<alepha76.TInteger, typeof alepha_orm56.PG_DEFAULT>;
134
- }>, alepha_orm56.PgRelationMap<alepha76.TObject<{
135
- id: alepha_orm56.PgAttr<alepha_orm56.PgAttr<alepha76.TString, typeof alepha_orm56.PG_PRIMARY_KEY>, typeof alepha_orm56.PG_DEFAULT>;
136
- createdAt: alepha_orm56.PgAttr<alepha_orm56.PgAttr<alepha76.TString, typeof alepha_orm56.PG_CREATED_AT>, typeof alepha_orm56.PG_DEFAULT>;
137
- updatedAt: alepha_orm56.PgAttr<alepha_orm56.PgAttr<alepha76.TString, typeof alepha_orm56.PG_UPDATED_AT>, typeof alepha_orm56.PG_DEFAULT>;
138
- version: alepha_orm56.PgAttr<alepha_orm56.PgAttr<alepha76.TInteger, typeof alepha_orm56.PG_VERSION>, typeof alepha_orm56.PG_DEFAULT>;
139
- type: alepha76.TUnsafe<"link" | "code">;
140
- target: alepha76.TString;
141
- code: alepha76.TString;
142
- verifiedAt: alepha76.TOptional<alepha76.TString>;
143
- attempts: alepha_orm56.PgAttr<alepha76.TInteger, typeof alepha_orm56.PG_DEFAULT>;
144
- }>>>[]>;
145
- /**
146
- * Creates a verification entry and returns the token.
147
- * The caller is responsible for sending notifications with the token.
148
- * This allows for context-specific notifications (e.g., password reset vs email verification).
149
- */
150
- createVerification(entry: VerificationEntry): Promise<RequestVerificationResponse>;
151
- verifyCode(entry: VerificationEntry, code: string): Promise<ValidateVerificationCodeResponse>;
152
- hashCode(code: string): string;
153
- generateToken(type: VerificationTypeEnum): string;
154
- }
155
- interface VerificationEntry {
156
- type: VerificationTypeEnum;
157
- target: string;
158
- }
159
- //#endregion
160
- //#region src/api-verifications/controllers/VerificationController.d.ts
161
- declare class VerificationController {
162
- protected readonly verificationService: VerificationService;
163
- readonly url = "/verifications";
164
- readonly group = "verifications";
165
- readonly requestVerificationCode: alepha_server0.ActionDescriptorFn<{
166
- params: alepha76.TObject<{
167
- type: alepha76.TUnsafe<"link" | "code">;
168
- }>;
169
- body: alepha76.TObject<{
170
- target: alepha76.TString;
171
- }>;
172
- response: alepha76.TObject<{
173
- token: alepha76.TString;
174
- codeExpiration: alepha76.TInteger;
175
- verificationCooldown: alepha76.TInteger;
176
- maxVerificationAttempts: alepha76.TInteger;
177
- }>;
178
- }>;
179
- readonly validateVerificationCode: alepha_server0.ActionDescriptorFn<{
180
- params: alepha76.TObject<{
181
- type: alepha76.TUnsafe<"link" | "code">;
182
- }>;
183
- body: alepha76.TObject<{
184
- target: alepha76.TString;
185
- token: alepha76.TString;
186
- }>;
187
- response: alepha76.TObject<{
188
- ok: alepha76.TBoolean;
189
- alreadyVerified: alepha76.TOptional<alepha76.TBoolean>;
190
- }>;
191
- }>;
192
- }
193
- //#endregion
194
- //#region src/api-verifications/index.d.ts
195
- /**
196
- * Provides email/phone verification management API endpoints for Alepha applications.
197
- *
198
- * This module includes verification code generation, validation,
199
- * and related functionalities. Notifications are handled by the consuming module
200
- * (e.g., api-users) for context-specific messaging.
201
- *
202
- * @module alepha.api.verifications
203
- */
204
- declare const AlephaApiVerification: alepha76.Service<alepha76.Module>;
205
- //#endregion
206
- export { AlephaApiVerification, RequestVerificationResponse, ValidateVerificationCodeResponse, VerificationController, VerificationEntry, VerificationService, VerificationTypeEnum, requestVerificationCodeResponseSchema, validateVerificationCodeResponseSchema, verificationTypeEnumSchema };
207
- //# sourceMappingURL=index.d.cts.map