alepha 0.15.0 → 0.15.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 (551) hide show
  1. package/README.md +43 -98
  2. package/dist/api/audits/index.d.ts +630 -653
  3. package/dist/api/audits/index.d.ts.map +1 -1
  4. package/dist/api/audits/index.js +12 -35
  5. package/dist/api/audits/index.js.map +1 -1
  6. package/dist/api/files/index.d.ts +365 -358
  7. package/dist/api/files/index.d.ts.map +1 -1
  8. package/dist/api/files/index.js +12 -5
  9. package/dist/api/files/index.js.map +1 -1
  10. package/dist/api/jobs/index.d.ts +255 -248
  11. package/dist/api/jobs/index.d.ts.map +1 -1
  12. package/dist/api/jobs/index.js +10 -3
  13. package/dist/api/jobs/index.js.map +1 -1
  14. package/dist/api/keys/index.d.ts +413 -0
  15. package/dist/api/keys/index.d.ts.map +1 -0
  16. package/dist/api/keys/index.js +476 -0
  17. package/dist/api/keys/index.js.map +1 -0
  18. package/dist/api/notifications/index.browser.js +4 -4
  19. package/dist/api/notifications/index.browser.js.map +1 -1
  20. package/dist/api/notifications/index.d.ts +84 -78
  21. package/dist/api/notifications/index.d.ts.map +1 -1
  22. package/dist/api/notifications/index.js +14 -8
  23. package/dist/api/notifications/index.js.map +1 -1
  24. package/dist/api/parameters/index.d.ts +528 -535
  25. package/dist/api/parameters/index.d.ts.map +1 -1
  26. package/dist/api/parameters/index.js +30 -37
  27. package/dist/api/parameters/index.js.map +1 -1
  28. package/dist/api/users/index.d.ts +1221 -910
  29. package/dist/api/users/index.d.ts.map +1 -1
  30. package/dist/api/users/index.js +2556 -248
  31. package/dist/api/users/index.js.map +1 -1
  32. package/dist/api/verifications/index.d.ts +142 -136
  33. package/dist/api/verifications/index.d.ts.map +1 -1
  34. package/dist/api/verifications/index.js +12 -4
  35. package/dist/api/verifications/index.js.map +1 -1
  36. package/dist/batch/index.d.ts +142 -162
  37. package/dist/batch/index.d.ts.map +1 -1
  38. package/dist/batch/index.js +31 -44
  39. package/dist/batch/index.js.map +1 -1
  40. package/dist/bucket/index.d.ts +595 -171
  41. package/dist/bucket/index.d.ts.map +1 -1
  42. package/dist/bucket/index.js +1856 -12
  43. package/dist/bucket/index.js.map +1 -1
  44. package/dist/cache/core/index.d.ts +225 -53
  45. package/dist/cache/core/index.d.ts.map +1 -1
  46. package/dist/cache/core/index.js +213 -7
  47. package/dist/cache/core/index.js.map +1 -1
  48. package/dist/cache/redis/index.d.ts +1 -0
  49. package/dist/cache/redis/index.d.ts.map +1 -1
  50. package/dist/cache/redis/index.js +6 -2
  51. package/dist/cache/redis/index.js.map +1 -1
  52. package/dist/cli/index.d.ts +834 -226
  53. package/dist/cli/index.d.ts.map +1 -1
  54. package/dist/cli/index.js +2872 -417
  55. package/dist/cli/index.js.map +1 -1
  56. package/dist/command/index.d.ts +458 -310
  57. package/dist/command/index.d.ts.map +1 -1
  58. package/dist/command/index.js +2011 -76
  59. package/dist/command/index.js.map +1 -1
  60. package/dist/core/index.browser.js +309 -97
  61. package/dist/core/index.browser.js.map +1 -1
  62. package/dist/core/index.d.ts +796 -701
  63. package/dist/core/index.d.ts.map +1 -1
  64. package/dist/core/index.js +329 -97
  65. package/dist/core/index.js.map +1 -1
  66. package/dist/core/index.native.js +309 -97
  67. package/dist/core/index.native.js.map +1 -1
  68. package/dist/datetime/index.d.ts +59 -44
  69. package/dist/datetime/index.d.ts.map +1 -1
  70. package/dist/datetime/index.js +15 -0
  71. package/dist/datetime/index.js.map +1 -1
  72. package/dist/email/index.d.ts +314 -19
  73. package/dist/email/index.d.ts.map +1 -1
  74. package/dist/email/index.js +1852 -7
  75. package/dist/email/index.js.map +1 -1
  76. package/dist/fake/index.d.ts +5500 -5418
  77. package/dist/fake/index.d.ts.map +1 -1
  78. package/dist/fake/index.js +113 -42
  79. package/dist/fake/index.js.map +1 -1
  80. package/dist/lock/core/index.d.ts +219 -212
  81. package/dist/lock/core/index.d.ts.map +1 -1
  82. package/dist/lock/core/index.js +11 -4
  83. package/dist/lock/core/index.js.map +1 -1
  84. package/dist/lock/redis/index.d.ts.map +1 -1
  85. package/dist/logger/index.d.ts +41 -90
  86. package/dist/logger/index.d.ts.map +1 -1
  87. package/dist/logger/index.js +15 -68
  88. package/dist/logger/index.js.map +1 -1
  89. package/dist/mcp/index.d.ts +228 -230
  90. package/dist/mcp/index.d.ts.map +1 -1
  91. package/dist/mcp/index.js +32 -31
  92. package/dist/mcp/index.js.map +1 -1
  93. package/dist/orm/index.browser.js +12 -12
  94. package/dist/orm/index.browser.js.map +1 -1
  95. package/dist/orm/index.bun.js +90 -80
  96. package/dist/orm/index.bun.js.map +1 -1
  97. package/dist/orm/index.d.ts +1434 -1459
  98. package/dist/orm/index.d.ts.map +1 -1
  99. package/dist/orm/index.js +112 -130
  100. package/dist/orm/index.js.map +1 -1
  101. package/dist/queue/core/index.d.ts +262 -254
  102. package/dist/queue/core/index.d.ts.map +1 -1
  103. package/dist/queue/core/index.js +14 -6
  104. package/dist/queue/core/index.js.map +1 -1
  105. package/dist/queue/redis/index.d.ts.map +1 -1
  106. package/dist/react/auth/index.browser.js +108 -0
  107. package/dist/react/auth/index.browser.js.map +1 -0
  108. package/dist/react/auth/index.d.ts +100 -0
  109. package/dist/react/auth/index.d.ts.map +1 -0
  110. package/dist/react/auth/index.js +145 -0
  111. package/dist/react/auth/index.js.map +1 -0
  112. package/dist/react/core/index.d.ts +469 -0
  113. package/dist/react/core/index.d.ts.map +1 -0
  114. package/dist/react/core/index.js +464 -0
  115. package/dist/react/core/index.js.map +1 -0
  116. package/dist/react/form/index.d.ts +232 -0
  117. package/dist/react/form/index.d.ts.map +1 -0
  118. package/dist/react/form/index.js +432 -0
  119. package/dist/react/form/index.js.map +1 -0
  120. package/dist/react/head/index.browser.js +423 -0
  121. package/dist/react/head/index.browser.js.map +1 -0
  122. package/dist/react/head/index.d.ts +288 -0
  123. package/dist/react/head/index.d.ts.map +1 -0
  124. package/dist/react/head/index.js +465 -0
  125. package/dist/react/head/index.js.map +1 -0
  126. package/dist/react/i18n/index.d.ts +175 -0
  127. package/dist/react/i18n/index.d.ts.map +1 -0
  128. package/dist/react/i18n/index.js +224 -0
  129. package/dist/react/i18n/index.js.map +1 -0
  130. package/dist/react/router/index.browser.js +1980 -0
  131. package/dist/react/router/index.browser.js.map +1 -0
  132. package/dist/react/router/index.d.ts +2068 -0
  133. package/dist/react/router/index.d.ts.map +1 -0
  134. package/dist/react/router/index.js +4932 -0
  135. package/dist/react/router/index.js.map +1 -0
  136. package/dist/react/websocket/index.d.ts +117 -0
  137. package/dist/react/websocket/index.d.ts.map +1 -0
  138. package/dist/react/websocket/index.js +107 -0
  139. package/dist/react/websocket/index.js.map +1 -0
  140. package/dist/redis/index.bun.js +4 -0
  141. package/dist/redis/index.bun.js.map +1 -1
  142. package/dist/redis/index.d.ts +127 -130
  143. package/dist/redis/index.d.ts.map +1 -1
  144. package/dist/redis/index.js +16 -25
  145. package/dist/redis/index.js.map +1 -1
  146. package/dist/retry/index.d.ts +80 -71
  147. package/dist/retry/index.d.ts.map +1 -1
  148. package/dist/retry/index.js +11 -2
  149. package/dist/retry/index.js.map +1 -1
  150. package/dist/router/index.d.ts +6 -6
  151. package/dist/router/index.d.ts.map +1 -1
  152. package/dist/scheduler/index.d.ts +119 -28
  153. package/dist/scheduler/index.d.ts.map +1 -1
  154. package/dist/scheduler/index.js +404 -3
  155. package/dist/scheduler/index.js.map +1 -1
  156. package/dist/security/index.d.ts +642 -228
  157. package/dist/security/index.d.ts.map +1 -1
  158. package/dist/security/index.js +1579 -37
  159. package/dist/security/index.js.map +1 -1
  160. package/dist/server/auth/index.d.ts +1141 -111
  161. package/dist/server/auth/index.d.ts.map +1 -1
  162. package/dist/server/auth/index.js +1261 -25
  163. package/dist/server/auth/index.js.map +1 -1
  164. package/dist/server/cache/index.d.ts +63 -78
  165. package/dist/server/cache/index.d.ts.map +1 -1
  166. package/dist/server/cache/index.js +7 -22
  167. package/dist/server/cache/index.js.map +1 -1
  168. package/dist/server/compress/index.d.ts +13 -5
  169. package/dist/server/compress/index.d.ts.map +1 -1
  170. package/dist/server/compress/index.js +10 -2
  171. package/dist/server/compress/index.js.map +1 -1
  172. package/dist/server/cookies/index.d.ts +46 -22
  173. package/dist/server/cookies/index.d.ts.map +1 -1
  174. package/dist/server/cookies/index.js +7 -5
  175. package/dist/server/cookies/index.js.map +1 -1
  176. package/dist/server/core/index.d.ts +307 -196
  177. package/dist/server/core/index.d.ts.map +1 -1
  178. package/dist/server/core/index.js +271 -38
  179. package/dist/server/core/index.js.map +1 -1
  180. package/dist/server/cors/index.d.ts +24 -34
  181. package/dist/server/cors/index.d.ts.map +1 -1
  182. package/dist/server/cors/index.js +7 -21
  183. package/dist/server/cors/index.js.map +1 -1
  184. package/dist/server/health/index.d.ts +25 -19
  185. package/dist/server/health/index.d.ts.map +1 -1
  186. package/dist/server/health/index.js +8 -2
  187. package/dist/server/health/index.js.map +1 -1
  188. package/dist/server/helmet/index.d.ts +13 -5
  189. package/dist/server/helmet/index.d.ts.map +1 -1
  190. package/dist/server/helmet/index.js +11 -3
  191. package/dist/server/helmet/index.js.map +1 -1
  192. package/dist/server/links/index.browser.js +9 -1
  193. package/dist/server/links/index.browser.js.map +1 -1
  194. package/dist/server/links/index.d.ts +133 -128
  195. package/dist/server/links/index.d.ts.map +1 -1
  196. package/dist/server/links/index.js +24 -11
  197. package/dist/server/links/index.js.map +1 -1
  198. package/dist/server/metrics/index.d.ts +524 -4
  199. package/dist/server/metrics/index.d.ts.map +1 -1
  200. package/dist/server/metrics/index.js +4472 -7
  201. package/dist/server/metrics/index.js.map +1 -1
  202. package/dist/server/multipart/index.d.ts +15 -9
  203. package/dist/server/multipart/index.d.ts.map +1 -1
  204. package/dist/server/multipart/index.js +9 -3
  205. package/dist/server/multipart/index.js.map +1 -1
  206. package/dist/server/proxy/index.d.ts +110 -104
  207. package/dist/server/proxy/index.d.ts.map +1 -1
  208. package/dist/server/proxy/index.js +8 -2
  209. package/dist/server/proxy/index.js.map +1 -1
  210. package/dist/server/rate-limit/index.d.ts +46 -51
  211. package/dist/server/rate-limit/index.d.ts.map +1 -1
  212. package/dist/server/rate-limit/index.js +18 -55
  213. package/dist/server/rate-limit/index.js.map +1 -1
  214. package/dist/server/static/index.d.ts +181 -48
  215. package/dist/server/static/index.d.ts.map +1 -1
  216. package/dist/server/static/index.js +1848 -5
  217. package/dist/server/static/index.js.map +1 -1
  218. package/dist/server/swagger/index.d.ts +348 -53
  219. package/dist/server/swagger/index.d.ts.map +1 -1
  220. package/dist/server/swagger/index.js +1849 -6
  221. package/dist/server/swagger/index.js.map +1 -1
  222. package/dist/sms/index.d.ts +312 -18
  223. package/dist/sms/index.d.ts.map +1 -1
  224. package/dist/sms/index.js +1854 -10
  225. package/dist/sms/index.js.map +1 -1
  226. package/dist/system/index.browser.js +496 -0
  227. package/dist/system/index.browser.js.map +1 -0
  228. package/dist/system/index.d.ts +1158 -0
  229. package/dist/system/index.d.ts.map +1 -0
  230. package/dist/{file → system}/index.js +412 -20
  231. package/dist/system/index.js.map +1 -0
  232. package/dist/thread/index.d.ts +82 -73
  233. package/dist/thread/index.d.ts.map +1 -1
  234. package/dist/thread/index.js +13 -4
  235. package/dist/thread/index.js.map +1 -1
  236. package/dist/topic/core/index.d.ts +330 -323
  237. package/dist/topic/core/index.d.ts.map +1 -1
  238. package/dist/topic/core/index.js +12 -5
  239. package/dist/topic/core/index.js.map +1 -1
  240. package/dist/topic/redis/index.d.ts +6 -6
  241. package/dist/topic/redis/index.d.ts.map +1 -1
  242. package/dist/vite/index.d.ts +163 -5825
  243. package/dist/vite/index.d.ts.map +1 -1
  244. package/dist/vite/index.js +130 -477
  245. package/dist/vite/index.js.map +1 -1
  246. package/dist/websocket/index.browser.js +3 -3
  247. package/dist/websocket/index.browser.js.map +1 -1
  248. package/dist/websocket/index.d.ts +287 -283
  249. package/dist/websocket/index.d.ts.map +1 -1
  250. package/dist/websocket/index.js +15 -11
  251. package/dist/websocket/index.js.map +1 -1
  252. package/package.json +86 -17
  253. package/src/api/audits/index.ts +10 -33
  254. package/src/api/files/__tests__/$bucket.spec.ts +1 -1
  255. package/src/api/files/controllers/AdminFileStatsController.spec.ts +1 -1
  256. package/src/api/files/controllers/FileController.spec.ts +1 -1
  257. package/src/api/files/index.ts +10 -3
  258. package/src/api/files/jobs/FileJobs.spec.ts +1 -1
  259. package/src/api/files/services/FileService.spec.ts +1 -1
  260. package/src/api/jobs/index.ts +10 -3
  261. package/src/api/keys/controllers/AdminApiKeyController.ts +75 -0
  262. package/src/api/keys/controllers/ApiKeyController.ts +103 -0
  263. package/src/api/keys/entities/apiKeyEntity.ts +41 -0
  264. package/src/api/keys/index.ts +49 -0
  265. package/src/api/keys/schemas/adminApiKeyQuerySchema.ts +7 -0
  266. package/src/api/keys/schemas/adminApiKeyResourceSchema.ts +17 -0
  267. package/src/api/keys/schemas/createApiKeyBodySchema.ts +7 -0
  268. package/src/api/keys/schemas/createApiKeyResponseSchema.ts +11 -0
  269. package/src/api/keys/schemas/listApiKeyResponseSchema.ts +15 -0
  270. package/src/api/keys/schemas/revokeApiKeyParamsSchema.ts +5 -0
  271. package/src/api/keys/schemas/revokeApiKeyResponseSchema.ts +5 -0
  272. package/src/api/keys/services/ApiKeyService.spec.ts +553 -0
  273. package/src/api/keys/services/ApiKeyService.ts +306 -0
  274. package/src/api/logs/TODO.md +52 -0
  275. package/src/api/notifications/index.ts +10 -4
  276. package/src/api/parameters/index.ts +9 -30
  277. package/src/api/parameters/primitives/$config.ts +12 -4
  278. package/src/api/parameters/services/ConfigStore.ts +9 -3
  279. package/src/api/users/__tests__/ApiKeys-integration.spec.ts +1035 -0
  280. package/src/api/users/__tests__/ApiKeys.spec.ts +401 -0
  281. package/src/api/users/index.ts +14 -3
  282. package/src/api/users/primitives/$realm.ts +33 -5
  283. package/src/api/users/providers/RealmProvider.ts +1 -12
  284. package/src/api/users/services/SessionService.ts +1 -11
  285. package/src/api/verifications/controllers/VerificationController.ts +2 -0
  286. package/src/api/verifications/index.ts +10 -4
  287. package/src/batch/index.ts +9 -36
  288. package/src/batch/primitives/$batch.ts +0 -8
  289. package/src/batch/providers/BatchProvider.ts +29 -2
  290. package/src/bucket/__tests__/shared.ts +1 -1
  291. package/src/bucket/index.ts +13 -6
  292. package/src/bucket/primitives/$bucket.ts +1 -1
  293. package/src/bucket/providers/LocalFileStorageProvider.ts +1 -1
  294. package/src/bucket/providers/MemoryFileStorageProvider.ts +1 -1
  295. package/src/cache/core/__tests__/shared.ts +30 -0
  296. package/src/cache/core/index.ts +11 -6
  297. package/src/cache/core/primitives/$cache.spec.ts +5 -0
  298. package/src/cache/core/providers/CacheProvider.ts +17 -0
  299. package/src/cache/core/providers/MemoryCacheProvider.ts +300 -1
  300. package/src/cache/redis/__tests__/cache-redis.spec.ts +5 -0
  301. package/src/cache/redis/providers/RedisCacheProvider.ts +9 -0
  302. package/src/cli/apps/AlephaCli.ts +3 -16
  303. package/src/cli/apps/AlephaPackageBuilderCli.ts +10 -2
  304. package/src/cli/atoms/appEntryOptions.ts +13 -0
  305. package/src/cli/atoms/buildOptions.ts +1 -1
  306. package/src/cli/atoms/changelogOptions.ts +1 -1
  307. package/src/cli/commands/build.ts +64 -52
  308. package/src/cli/commands/db.ts +17 -11
  309. package/src/cli/commands/deploy.ts +1 -1
  310. package/src/cli/commands/dev.ts +13 -49
  311. package/src/cli/commands/gen/env.ts +6 -3
  312. package/src/cli/commands/gen/openapi.ts +5 -2
  313. package/src/cli/commands/init.spec.ts +544 -0
  314. package/src/cli/commands/init.ts +101 -58
  315. package/src/cli/commands/lint.ts +8 -2
  316. package/src/cli/commands/typecheck.ts +11 -0
  317. package/src/cli/defineConfig.ts +9 -0
  318. package/src/cli/index.ts +2 -1
  319. package/src/cli/providers/AppEntryProvider.ts +131 -0
  320. package/src/cli/providers/ViteBuildProvider.ts +40 -0
  321. package/src/cli/providers/ViteDevServerProvider.ts +378 -0
  322. package/src/cli/services/AlephaCliUtils.ts +39 -93
  323. package/src/cli/services/PackageManagerUtils.ts +140 -17
  324. package/src/cli/services/ProjectScaffolder.ts +169 -101
  325. package/src/cli/services/ViteUtils.ts +82 -0
  326. package/src/cli/{assets/claudeMd.ts → templates/agentMd.ts} +41 -28
  327. package/src/cli/{assets → templates}/apiHelloControllerTs.ts +2 -1
  328. package/src/cli/{assets → templates}/biomeJson.ts +2 -1
  329. package/src/cli/{assets → templates}/dummySpecTs.ts +2 -1
  330. package/src/cli/{assets → templates}/editorconfig.ts +2 -1
  331. package/src/cli/templates/gitignore.ts +39 -0
  332. package/src/cli/{assets → templates}/mainBrowserTs.ts +2 -1
  333. package/src/cli/templates/mainCss.ts +33 -0
  334. package/src/cli/templates/mainServerTs.ts +33 -0
  335. package/src/cli/{assets → templates}/tsconfigJson.ts +2 -1
  336. package/src/cli/templates/webAppRouterTs.ts +50 -0
  337. package/src/cli/templates/webHelloComponentTsx.ts +20 -0
  338. package/src/command/helpers/Runner.spec.ts +4 -0
  339. package/src/command/helpers/Runner.ts +3 -21
  340. package/src/command/index.ts +12 -4
  341. package/src/command/providers/CliProvider.spec.ts +1067 -0
  342. package/src/command/providers/CliProvider.ts +203 -40
  343. package/src/core/Alepha.ts +3 -9
  344. package/src/core/__tests__/Alepha-start.spec.ts +4 -4
  345. package/src/core/helpers/jsonSchemaToTypeBox.spec.ts +771 -0
  346. package/src/core/helpers/jsonSchemaToTypeBox.ts +62 -10
  347. package/src/core/index.shared.ts +1 -0
  348. package/src/core/index.ts +20 -0
  349. package/src/core/primitives/$module.ts +12 -0
  350. package/src/core/providers/EventManager.spec.ts +0 -71
  351. package/src/core/providers/EventManager.ts +3 -15
  352. package/src/core/providers/Json.ts +2 -14
  353. package/src/core/providers/KeylessJsonSchemaCodec.spec.ts +257 -0
  354. package/src/core/providers/KeylessJsonSchemaCodec.ts +396 -14
  355. package/src/core/providers/SchemaValidator.spec.ts +236 -0
  356. package/src/datetime/index.ts +15 -0
  357. package/src/email/index.ts +10 -5
  358. package/src/email/providers/LocalEmailProvider.spec.ts +1 -1
  359. package/src/email/providers/LocalEmailProvider.ts +1 -1
  360. package/src/fake/__tests__/keyName.example.ts +1 -1
  361. package/src/fake/__tests__/keyName.spec.ts +5 -5
  362. package/src/fake/index.ts +9 -6
  363. package/src/fake/providers/FakeProvider.spec.ts +258 -40
  364. package/src/fake/providers/FakeProvider.ts +133 -19
  365. package/src/lock/core/index.ts +11 -4
  366. package/src/logger/index.ts +17 -66
  367. package/src/logger/providers/PrettyFormatterProvider.ts +0 -9
  368. package/src/mcp/errors/McpError.ts +30 -0
  369. package/src/mcp/index.ts +13 -27
  370. package/src/mcp/transports/SseMcpTransport.ts +6 -7
  371. package/src/orm/__tests__/PostgresProvider.spec.ts +2 -2
  372. package/src/orm/index.browser.ts +2 -2
  373. package/src/orm/index.bun.ts +4 -2
  374. package/src/orm/index.ts +21 -47
  375. package/src/orm/providers/DrizzleKitProvider.ts +3 -5
  376. package/src/orm/providers/drivers/BunSqliteProvider.ts +1 -0
  377. package/src/orm/services/Repository.ts +18 -3
  378. package/src/queue/core/index.ts +14 -6
  379. package/src/react/auth/__tests__/$auth.spec.ts +202 -0
  380. package/src/react/auth/hooks/useAuth.ts +32 -0
  381. package/src/react/auth/index.browser.ts +13 -0
  382. package/src/react/auth/index.shared.ts +2 -0
  383. package/src/react/auth/index.ts +48 -0
  384. package/src/react/auth/providers/ReactAuthProvider.ts +16 -0
  385. package/src/react/auth/services/ReactAuth.ts +135 -0
  386. package/src/react/core/__tests__/Router.spec.tsx +169 -0
  387. package/src/react/core/components/ClientOnly.tsx +49 -0
  388. package/src/react/core/components/ErrorBoundary.tsx +73 -0
  389. package/src/react/core/contexts/AlephaContext.ts +7 -0
  390. package/src/react/core/contexts/AlephaProvider.tsx +42 -0
  391. package/src/react/core/hooks/useAction.browser.spec.tsx +569 -0
  392. package/src/react/core/hooks/useAction.ts +480 -0
  393. package/src/react/core/hooks/useAlepha.ts +26 -0
  394. package/src/react/core/hooks/useClient.ts +17 -0
  395. package/src/react/core/hooks/useEvents.ts +51 -0
  396. package/src/react/core/hooks/useInject.ts +12 -0
  397. package/src/react/core/hooks/useStore.ts +52 -0
  398. package/src/react/core/index.ts +90 -0
  399. package/src/react/form/components/FormState.tsx +17 -0
  400. package/src/react/form/errors/FormValidationError.ts +18 -0
  401. package/src/react/form/hooks/useForm.browser.spec.tsx +366 -0
  402. package/src/react/form/hooks/useForm.ts +47 -0
  403. package/src/react/form/hooks/useFormState.ts +130 -0
  404. package/src/react/form/index.ts +44 -0
  405. package/src/react/form/services/FormModel.ts +614 -0
  406. package/src/react/head/helpers/SeoExpander.spec.ts +203 -0
  407. package/src/react/head/helpers/SeoExpander.ts +142 -0
  408. package/src/react/head/hooks/useHead.spec.tsx +288 -0
  409. package/src/react/head/hooks/useHead.ts +62 -0
  410. package/src/react/head/index.browser.ts +26 -0
  411. package/src/react/head/index.ts +44 -0
  412. package/src/react/head/interfaces/Head.ts +105 -0
  413. package/src/react/head/primitives/$head.ts +25 -0
  414. package/src/react/head/providers/BrowserHeadProvider.browser.spec.ts +196 -0
  415. package/src/react/head/providers/BrowserHeadProvider.ts +212 -0
  416. package/src/react/head/providers/HeadProvider.ts +168 -0
  417. package/src/react/head/providers/ServerHeadProvider.ts +31 -0
  418. package/src/react/i18n/__tests__/integration.spec.tsx +239 -0
  419. package/src/react/i18n/components/Localize.spec.tsx +357 -0
  420. package/src/react/i18n/components/Localize.tsx +35 -0
  421. package/src/react/i18n/hooks/useI18n.browser.spec.tsx +438 -0
  422. package/src/react/i18n/hooks/useI18n.ts +18 -0
  423. package/src/react/i18n/index.ts +41 -0
  424. package/src/react/i18n/primitives/$dictionary.ts +69 -0
  425. package/src/react/i18n/providers/I18nProvider.spec.ts +389 -0
  426. package/src/react/i18n/providers/I18nProvider.ts +278 -0
  427. package/src/react/router/__tests__/page-head-browser.browser.spec.ts +95 -0
  428. package/src/react/router/__tests__/page-head.spec.ts +48 -0
  429. package/src/react/router/__tests__/seo-head.spec.ts +125 -0
  430. package/src/react/router/atoms/ssrManifestAtom.ts +58 -0
  431. package/src/react/router/components/ErrorViewer.tsx +872 -0
  432. package/src/react/router/components/Link.tsx +23 -0
  433. package/src/react/router/components/NestedView.tsx +223 -0
  434. package/src/react/router/components/NotFound.tsx +30 -0
  435. package/src/react/router/constants/PAGE_PRELOAD_KEY.ts +6 -0
  436. package/src/react/router/contexts/RouterLayerContext.ts +12 -0
  437. package/src/react/router/errors/Redirection.ts +28 -0
  438. package/src/react/router/hooks/useActive.ts +52 -0
  439. package/src/react/router/hooks/useQueryParams.ts +63 -0
  440. package/src/react/router/hooks/useRouter.ts +20 -0
  441. package/src/react/router/hooks/useRouterState.ts +11 -0
  442. package/src/react/router/index.browser.ts +45 -0
  443. package/src/react/router/index.shared.ts +19 -0
  444. package/src/react/router/index.ts +142 -0
  445. package/src/react/router/primitives/$page.browser.spec.tsx +851 -0
  446. package/src/react/router/primitives/$page.spec.tsx +708 -0
  447. package/src/react/router/primitives/$page.ts +497 -0
  448. package/src/react/router/providers/ReactBrowserProvider.ts +309 -0
  449. package/src/react/router/providers/ReactBrowserRendererProvider.ts +25 -0
  450. package/src/react/router/providers/ReactBrowserRouterProvider.ts +168 -0
  451. package/src/react/router/providers/ReactPageProvider.ts +726 -0
  452. package/src/react/router/providers/ReactServerProvider.spec.tsx +316 -0
  453. package/src/react/router/providers/ReactServerProvider.ts +558 -0
  454. package/src/react/router/providers/ReactServerTemplateProvider.ts +979 -0
  455. package/src/react/router/providers/SSRManifestProvider.ts +334 -0
  456. package/src/react/router/services/ReactPageServerService.ts +48 -0
  457. package/src/react/router/services/ReactPageService.ts +27 -0
  458. package/src/react/router/services/ReactRouter.ts +262 -0
  459. package/src/react/websocket/hooks/useRoom.tsx +242 -0
  460. package/src/react/websocket/index.ts +7 -0
  461. package/src/redis/__tests__/redis.spec.ts +13 -0
  462. package/src/redis/index.ts +9 -25
  463. package/src/redis/providers/BunRedisProvider.ts +9 -0
  464. package/src/redis/providers/NodeRedisProvider.ts +8 -0
  465. package/src/redis/providers/RedisProvider.ts +16 -0
  466. package/src/retry/index.ts +11 -2
  467. package/src/router/index.ts +15 -0
  468. package/src/scheduler/index.ts +11 -2
  469. package/src/security/__tests__/BasicAuth.spec.ts +2 -0
  470. package/src/security/__tests__/ServerSecurityProvider.spec.ts +13 -5
  471. package/src/security/index.ts +15 -10
  472. package/src/security/interfaces/IssuerResolver.ts +27 -0
  473. package/src/security/primitives/$issuer.ts +55 -0
  474. package/src/security/providers/SecurityProvider.ts +179 -0
  475. package/src/security/providers/ServerBasicAuthProvider.ts +6 -2
  476. package/src/security/providers/ServerSecurityProvider.ts +36 -22
  477. package/src/server/auth/index.ts +12 -7
  478. package/src/server/cache/index.ts +7 -22
  479. package/src/server/compress/index.ts +10 -2
  480. package/src/server/cookies/index.ts +7 -5
  481. package/src/server/cookies/primitives/$cookie.ts +33 -11
  482. package/src/server/core/index.ts +17 -7
  483. package/src/server/core/interfaces/ServerRequest.ts +83 -1
  484. package/src/server/core/primitives/$action.spec.ts +1 -1
  485. package/src/server/core/primitives/$action.ts +8 -3
  486. package/src/server/core/providers/BunHttpServerProvider.ts +1 -1
  487. package/src/server/core/providers/NodeHttpServerProvider.spec.ts +125 -0
  488. package/src/server/core/providers/NodeHttpServerProvider.ts +77 -22
  489. package/src/server/core/providers/ServerLoggerProvider.ts +2 -2
  490. package/src/server/core/providers/ServerProvider.ts +9 -12
  491. package/src/server/core/services/ServerRequestParser.spec.ts +520 -0
  492. package/src/server/core/services/ServerRequestParser.ts +306 -13
  493. package/src/server/cors/index.ts +7 -21
  494. package/src/server/cors/primitives/$cors.ts +6 -2
  495. package/src/server/health/index.ts +8 -2
  496. package/src/server/helmet/index.ts +11 -3
  497. package/src/server/links/atoms/apiLinksAtom.ts +7 -0
  498. package/src/server/links/index.browser.ts +2 -0
  499. package/src/server/links/index.ts +13 -6
  500. package/src/server/metrics/index.ts +10 -3
  501. package/src/server/multipart/index.ts +9 -3
  502. package/src/server/proxy/index.ts +8 -2
  503. package/src/server/rate-limit/index.ts +21 -25
  504. package/src/server/rate-limit/primitives/$rateLimit.ts +6 -2
  505. package/src/server/rate-limit/providers/ServerRateLimitProvider.spec.ts +38 -14
  506. package/src/server/rate-limit/providers/ServerRateLimitProvider.ts +22 -56
  507. package/src/server/static/index.ts +8 -2
  508. package/src/server/static/providers/ServerStaticProvider.ts +1 -1
  509. package/src/server/swagger/index.ts +9 -4
  510. package/src/server/swagger/providers/ServerSwaggerProvider.ts +1 -1
  511. package/src/sms/index.ts +9 -5
  512. package/src/sms/providers/LocalSmsProvider.spec.ts +1 -1
  513. package/src/sms/providers/LocalSmsProvider.ts +1 -1
  514. package/src/system/index.browser.ts +11 -0
  515. package/src/system/index.ts +62 -0
  516. package/src/{file → system}/providers/FileSystemProvider.ts +16 -0
  517. package/src/{file → system}/providers/MemoryFileSystemProvider.ts +116 -3
  518. package/src/system/providers/MemoryShellProvider.ts +164 -0
  519. package/src/{file → system}/providers/NodeFileSystemProvider.spec.ts +2 -2
  520. package/src/{file → system}/providers/NodeFileSystemProvider.ts +36 -0
  521. package/src/system/providers/NodeShellProvider.ts +184 -0
  522. package/src/system/providers/ShellProvider.ts +74 -0
  523. package/src/{file → system}/services/FileDetector.spec.ts +2 -2
  524. package/src/thread/index.ts +11 -2
  525. package/src/topic/core/index.ts +12 -5
  526. package/src/vite/index.ts +3 -2
  527. package/src/vite/tasks/buildClient.ts +2 -8
  528. package/src/vite/tasks/buildServer.ts +84 -21
  529. package/src/vite/tasks/copyAssets.ts +5 -4
  530. package/src/vite/tasks/generateSitemap.ts +64 -23
  531. package/src/vite/tasks/index.ts +0 -2
  532. package/src/vite/tasks/prerenderPages.ts +49 -24
  533. package/src/websocket/index.ts +12 -8
  534. package/dist/file/index.d.ts +0 -839
  535. package/dist/file/index.d.ts.map +0 -1
  536. package/dist/file/index.js.map +0 -1
  537. package/src/cli/assets/indexHtml.ts +0 -15
  538. package/src/cli/assets/mainServerTs.ts +0 -24
  539. package/src/cli/assets/webAppRouterTs.ts +0 -15
  540. package/src/cli/assets/webHelloComponentTsx.ts +0 -16
  541. package/src/cli/commands/format.ts +0 -23
  542. package/src/file/index.ts +0 -43
  543. package/src/vite/helpers/boot.ts +0 -117
  544. package/src/vite/plugins/viteAlephaDev.ts +0 -177
  545. package/src/vite/tasks/devServer.ts +0 -71
  546. package/src/vite/tasks/runAlepha.ts +0 -270
  547. /package/dist/orm/{chunk-DtkW-qnP.js → chunk-DH6iiROE.js} +0 -0
  548. /package/src/cli/{assets → templates}/apiIndexTs.ts +0 -0
  549. /package/src/cli/{assets → templates}/webIndexTs.ts +0 -0
  550. /package/src/{file → system}/errors/FileError.ts +0 -0
  551. /package/src/{file → system}/services/FileDetector.ts +0 -0
@@ -1,10 +1,8 @@
1
1
  import * as alepha3 from "alepha";
2
2
  import { Alepha, KIND, Primitive, Static } from "alepha";
3
3
  import { FetchOptions, ServerRequest, ServerRouterProvider, UnauthorizedError } from "alepha/server";
4
- import * as alepha_logger2 from "alepha/logger";
4
+ import * as alepha_logger0 from "alepha/logger";
5
5
  import { DateTimeProvider, Duration, DurationLike } from "alepha/datetime";
6
- import { CryptoKey, FlattenedJWSInput, JSONWebKeySet, JWSHeaderParameters, JWTHeaderParameters, JWTPayload, JWTVerifyResult, KeyObject } from "jose";
7
- import { JWTVerifyOptions } from "jose/jwt/verify";
8
6
 
9
7
  //#region ../../src/security/schemas/userAccountInfoSchema.d.ts
10
8
  declare const userAccountInfoSchema: alepha3.TObject<{
@@ -26,17 +24,17 @@ type UserAccount = Static<typeof userAccountInfoSchema>;
26
24
  */
27
25
  interface UserAccountToken extends UserAccount {
28
26
  /**
29
- * Access token for the user.
30
- */
27
+ * Access token for the user.
28
+ */
31
29
  token?: string;
32
30
  /**
33
- * Realm name of the user.
34
- */
31
+ * Realm name of the user.
32
+ */
35
33
  realm?: string;
36
34
  /**
37
- * Is user dedicated to his own resources for this scope ?
38
- * Mostly, Admin is false and Customer is true.
39
- */
35
+ * Is user dedicated to his own resources for this scope ?
36
+ * Mostly, Admin is false and Customer is true.
37
+ */
40
38
  ownership?: string | boolean;
41
39
  }
42
40
  //#endregion
@@ -63,56 +61,84 @@ declare class SecurityError extends Error {
63
61
  readonly status = 403;
64
62
  }
65
63
  //#endregion
64
+ //#region ../../src/security/interfaces/IssuerResolver.d.ts
65
+ /**
66
+ * User info that a resolver returns.
67
+ * This is the input to `SecurityProvider.createUser()`.
68
+ */
69
+ type UserInfo = Omit<UserAccount, "sessionId"> & {
70
+ sessionId?: string;
71
+ };
72
+ /**
73
+ * Resolver definition for authenticating users from requests.
74
+ */
75
+ interface IssuerResolver {
76
+ /**
77
+ * Priority (lower = first). Default: 100
78
+ */
79
+ priority?: number;
80
+ /**
81
+ * Resolve user from HTTP request.
82
+ * Return UserInfo if authenticated, null to try next resolver.
83
+ * Throw UnauthorizedError to stop chain.
84
+ */
85
+ onRequest: (req: ServerRequest) => Promise<UserInfo | null>;
86
+ }
87
+ //#endregion
66
88
  //#region ../../src/security/providers/ServerBasicAuthProvider.d.ts
67
89
  interface BasicAuthOptions {
68
90
  username: string;
69
91
  password: string;
70
92
  }
71
93
  interface BasicAuthPrimitiveConfig extends BasicAuthOptions {
72
- /** Name identifier for this basic auth (default: property key) */
94
+ /**
95
+ * Name identifier for this basic auth (default: property key).
96
+ */
73
97
  name?: string;
74
- /** Path patterns to match (supports wildcards like /devtools/*) */
98
+ /**
99
+ * Path patterns to match (supports wildcards like /devtools/*).
100
+ */
75
101
  paths?: string[];
76
102
  }
77
103
  declare class ServerBasicAuthProvider {
78
104
  protected readonly alepha: Alepha;
79
- protected readonly log: alepha_logger2.Logger;
105
+ protected readonly log: alepha_logger0.Logger;
80
106
  protected readonly routerProvider: ServerRouterProvider;
81
107
  protected readonly realm = "Secure Area";
82
108
  /**
83
- * Registered basic auth primitives with their configurations
84
- */
109
+ * Registered basic auth primitives with their configurations
110
+ */
85
111
  readonly registeredAuths: BasicAuthPrimitiveConfig[];
86
112
  /**
87
- * Register a basic auth configuration (called by primitives)
88
- */
113
+ * Register a basic auth configuration (called by primitives)
114
+ */
89
115
  registerAuth(config: BasicAuthPrimitiveConfig): void;
90
116
  readonly onStart: alepha3.HookPrimitive<"start">;
91
117
  /**
92
- * Hook into server:onRequest to check basic auth
93
- */
118
+ * Hook into server:onRequest to check basic auth
119
+ */
94
120
  readonly onRequest: alepha3.HookPrimitive<"server:onRequest">;
95
121
  /**
96
- * Hook into action:onRequest to check basic auth for actions
97
- */
122
+ * Hook into action:onRequest to check basic auth for actions
123
+ */
98
124
  readonly onActionRequest: alepha3.HookPrimitive<"action:onRequest">;
99
125
  /**
100
- * Check basic authentication
101
- */
126
+ * Check basic authentication
127
+ */
102
128
  checkAuth(request: ServerRequest, options: BasicAuthOptions): void;
103
129
  /**
104
- * Performs a timing-safe comparison of credentials to prevent timing attacks.
105
- * Always compares both username and password to avoid leaking which one is wrong.
106
- */
130
+ * Performs a timing-safe comparison of credentials to prevent timing attacks.
131
+ * Always compares both username and password to avoid leaking which one is wrong.
132
+ */
107
133
  protected timingSafeCredentialCheck(inputUsername: string, inputPassword: string, expectedUsername: string, expectedPassword: string): boolean;
108
134
  /**
109
- * Compares two buffers in constant time, handling different lengths safely.
110
- * Returns 1 if equal, 0 if not equal.
111
- */
135
+ * Compares two buffers in constant time, handling different lengths safely.
136
+ * Returns 1 if equal, 0 if not equal.
137
+ */
112
138
  protected safeCompare(input: Buffer, expected: Buffer): number;
113
139
  /**
114
- * Send WWW-Authenticate header
115
- */
140
+ * Send WWW-Authenticate header
141
+ */
116
142
  protected sendAuthRequired(request: ServerRequest): void;
117
143
  }
118
144
  declare const isBasicAuth: (value: unknown) => value is {
@@ -138,51 +164,376 @@ declare class BasicAuthPrimitive extends Primitive<BasicAuthPrimitiveConfig> imp
138
164
  get name(): string;
139
165
  protected onInit(): void;
140
166
  /**
141
- * Checks basic auth for the given request using this primitive's configuration.
142
- */
167
+ * Checks basic auth for the given request using this primitive's configuration.
168
+ */
143
169
  check(request: ServerRequest, options?: BasicAuthOptions): void;
144
170
  }
145
171
  //#endregion
172
+ //#region ../../../../node_modules/jose/dist/types/types.d.ts
173
+ /** Generic JSON Web Key Parameters. */
174
+ interface JWKParameters {
175
+ /** JWK "kty" (Key Type) Parameter */
176
+ kty?: string;
177
+ /**
178
+ * JWK "alg" (Algorithm) Parameter
179
+ *
180
+ * @see {@link https://github.com/panva/jose/issues/210 Algorithm Key Requirements}
181
+ */
182
+ alg?: string;
183
+ /** JWK "key_ops" (Key Operations) Parameter */
184
+ key_ops?: string[];
185
+ /** JWK "ext" (Extractable) Parameter */
186
+ ext?: boolean;
187
+ /** JWK "use" (Public Key Use) Parameter */
188
+ use?: string;
189
+ /** JWK "x5c" (X.509 Certificate Chain) Parameter */
190
+ x5c?: string[];
191
+ /** JWK "x5t" (X.509 Certificate SHA-1 Thumbprint) Parameter */
192
+ x5t?: string;
193
+ /** JWK "x5t#S256" (X.509 Certificate SHA-256 Thumbprint) Parameter */
194
+ 'x5t#S256'?: string;
195
+ /** JWK "x5u" (X.509 URL) Parameter */
196
+ x5u?: string;
197
+ /** JWK "kid" (Key ID) Parameter */
198
+ kid?: string;
199
+ }
200
+ /**
201
+ * JSON Web Key ({@link https://www.rfc-editor.org/rfc/rfc7517 JWK}). "RSA", "EC", "OKP", "AKP", and
202
+ * "oct" key types are supported.
203
+ *
204
+ * @see {@link JWK_AKP_Public}
205
+ * @see {@link JWK_AKP_Private}
206
+ * @see {@link JWK_OKP_Public}
207
+ * @see {@link JWK_OKP_Private}
208
+ * @see {@link JWK_EC_Public}
209
+ * @see {@link JWK_EC_Private}
210
+ * @see {@link JWK_RSA_Public}
211
+ * @see {@link JWK_RSA_Private}
212
+ * @see {@link JWK_oct}
213
+ */
214
+ interface JWK extends JWKParameters {
215
+ /**
216
+ * - EC JWK "crv" (Curve) Parameter
217
+ * - OKP JWK "crv" (The Subtype of Key Pair) Parameter
218
+ */
219
+ crv?: string;
220
+ /**
221
+ * - Private RSA JWK "d" (Private Exponent) Parameter
222
+ * - Private EC JWK "d" (ECC Private Key) Parameter
223
+ * - Private OKP JWK "d" (The Private Key) Parameter
224
+ */
225
+ d?: string;
226
+ /** Private RSA JWK "dp" (First Factor CRT Exponent) Parameter */
227
+ dp?: string;
228
+ /** Private RSA JWK "dq" (Second Factor CRT Exponent) Parameter */
229
+ dq?: string;
230
+ /** RSA JWK "e" (Exponent) Parameter */
231
+ e?: string;
232
+ /** Oct JWK "k" (Key Value) Parameter */
233
+ k?: string;
234
+ /** RSA JWK "n" (Modulus) Parameter */
235
+ n?: string;
236
+ /** Private RSA JWK "p" (First Prime Factor) Parameter */
237
+ p?: string;
238
+ /** Private RSA JWK "q" (Second Prime Factor) Parameter */
239
+ q?: string;
240
+ /** Private RSA JWK "qi" (First CRT Coefficient) Parameter */
241
+ qi?: string;
242
+ /**
243
+ * - EC JWK "x" (X Coordinate) Parameter
244
+ * - OKP JWK "x" (The public key) Parameter
245
+ */
246
+ x?: string;
247
+ /** EC JWK "y" (Y Coordinate) Parameter */
248
+ y?: string;
249
+ /** AKP JWK "pub" (Public Key) Parameter */
250
+ pub?: string;
251
+ /** AKP JWK "priv" (Private key) Parameter */
252
+ priv?: string;
253
+ }
254
+ /**
255
+ * Flattened JWS definition for verify function inputs, allows payload as {@link !Uint8Array} for
256
+ * detached signature validation.
257
+ */
258
+ interface FlattenedJWSInput {
259
+ /**
260
+ * The "header" member MUST be present and contain the value JWS Unprotected Header when the JWS
261
+ * Unprotected Header value is non- empty; otherwise, it MUST be absent. This value is represented
262
+ * as an unencoded JSON object, rather than as a string. These Header Parameter values are not
263
+ * integrity protected.
264
+ */
265
+ header?: JWSHeaderParameters;
266
+ /**
267
+ * The "payload" member MUST be present and contain the value BASE64URL(JWS Payload). When RFC7797
268
+ * "b64": false is used the value passed may also be a {@link !Uint8Array}.
269
+ */
270
+ payload: string | Uint8Array;
271
+ /**
272
+ * The "protected" member MUST be present and contain the value BASE64URL(UTF8(JWS Protected
273
+ * Header)) when the JWS Protected Header value is non-empty; otherwise, it MUST be absent. These
274
+ * Header Parameter values are integrity protected.
275
+ */
276
+ protected?: string;
277
+ /** The "signature" member MUST be present and contain the value BASE64URL(JWS Signature). */
278
+ signature: string;
279
+ }
280
+ /** Header Parameters common to JWE and JWS */
281
+ interface JoseHeaderParameters {
282
+ /** "kid" (Key ID) Header Parameter */
283
+ kid?: string;
284
+ /** "x5t" (X.509 Certificate SHA-1 Thumbprint) Header Parameter */
285
+ x5t?: string;
286
+ /** "x5c" (X.509 Certificate Chain) Header Parameter */
287
+ x5c?: string[];
288
+ /** "x5u" (X.509 URL) Header Parameter */
289
+ x5u?: string;
290
+ /** "jku" (JWK Set URL) Header Parameter */
291
+ jku?: string;
292
+ /** "jwk" (JSON Web Key) Header Parameter */
293
+ jwk?: Pick<JWK, 'kty' | 'crv' | 'x' | 'y' | 'e' | 'n' | 'alg' | 'pub'>;
294
+ /** "typ" (Type) Header Parameter */
295
+ typ?: string;
296
+ /** "cty" (Content Type) Header Parameter */
297
+ cty?: string;
298
+ }
299
+ /** Recognized JWS Header Parameters, any other Header Members may also be present. */
300
+ interface JWSHeaderParameters extends JoseHeaderParameters {
301
+ /**
302
+ * JWS "alg" (Algorithm) Header Parameter
303
+ *
304
+ * @see {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}
305
+ */
306
+ alg?: string;
307
+ /**
308
+ * This JWS Extension Header Parameter modifies the JWS Payload representation and the JWS Signing
309
+ * Input computation as per {@link https://www.rfc-editor.org/rfc/rfc7797 RFC7797}.
310
+ */
311
+ b64?: boolean;
312
+ /** JWS "crit" (Critical) Header Parameter */
313
+ crit?: string[];
314
+ /** Any other JWS Header member. */
315
+ [propName: string]: unknown;
316
+ }
317
+ /** Shared Interface with a "crit" property for all sign, verify, encrypt and decrypt operations. */
318
+ interface CritOption {
319
+ /**
320
+ * An object with keys representing recognized "crit" (Critical) Header Parameter names. The value
321
+ * for those is either `true` or `false`. `true` when the Header Parameter MUST be integrity
322
+ * protected, `false` when it's irrelevant.
323
+ *
324
+ * This makes the "Extension Header Parameter "..." is not recognized" error go away.
325
+ *
326
+ * Use this when a given JWS/JWT/JWE profile requires the use of proprietary non-registered "crit"
327
+ * (Critical) Header Parameters. This will only make sure the Header Parameter is syntactically
328
+ * correct when provided and that it is optionally integrity protected. It will not process the
329
+ * Header Parameter in any way or reject the operation if it is missing. You MUST still verify the
330
+ * Header Parameter was present and process it according to the profile's validation steps after
331
+ * the operation succeeds.
332
+ *
333
+ * The JWS extension Header Parameter `b64` is always recognized and processed properly. No other
334
+ * registered Header Parameters that need this kind of default built-in treatment are currently
335
+ * available.
336
+ */
337
+ crit?: {
338
+ [propName: string]: boolean;
339
+ };
340
+ }
341
+ /** JWT Claims Set verification options. */
342
+ interface JWTClaimVerificationOptions {
343
+ /**
344
+ * Expected JWT "aud" (Audience) Claim value(s).
345
+ *
346
+ * This option makes the JWT "aud" (Audience) Claim presence required.
347
+ */
348
+ audience?: string | string[];
349
+ /**
350
+ * Clock skew tolerance
351
+ *
352
+ * - In seconds when number (e.g. 5)
353
+ * - Resolved into a number of seconds when a string (e.g. "5 seconds", "10 minutes", "2 hours").
354
+ *
355
+ * Used when validating the JWT "nbf" (Not Before) and "exp" (Expiration Time) claims, and when
356
+ * validating the "iat" (Issued At) claim if the {@link maxTokenAge `maxTokenAge` option} is set.
357
+ */
358
+ clockTolerance?: string | number;
359
+ /**
360
+ * Expected JWT "iss" (Issuer) Claim value(s).
361
+ *
362
+ * This option makes the JWT "iss" (Issuer) Claim presence required.
363
+ */
364
+ issuer?: string | string[];
365
+ /**
366
+ * Maximum time elapsed (in seconds) from the JWT "iat" (Issued At) Claim value.
367
+ *
368
+ * - In seconds when number (e.g. 5)
369
+ * - Resolved into a number of seconds when a string (e.g. "5 seconds", "10 minutes", "2 hours").
370
+ *
371
+ * This option makes the JWT "iat" (Issued At) Claim presence required.
372
+ */
373
+ maxTokenAge?: string | number;
374
+ /**
375
+ * Expected JWT "sub" (Subject) Claim value.
376
+ *
377
+ * This option makes the JWT "sub" (Subject) Claim presence required.
378
+ */
379
+ subject?: string;
380
+ /**
381
+ * Expected JWT "typ" (Type) Header Parameter value.
382
+ *
383
+ * This option makes the JWT "typ" (Type) Header Parameter presence required.
384
+ */
385
+ typ?: string;
386
+ /** Date to use when comparing NumericDate claims, defaults to `new Date()`. */
387
+ currentDate?: Date;
388
+ /**
389
+ * Array of required Claim Names that must be present in the JWT Claims Set. Default is that: if
390
+ * the {@link issuer `issuer` option} is set, then JWT "iss" (Issuer) Claim must be present; if the
391
+ * {@link audience `audience` option} is set, then JWT "aud" (Audience) Claim must be present; if
392
+ * the {@link subject `subject` option} is set, then JWT "sub" (Subject) Claim must be present; if
393
+ * the {@link maxTokenAge `maxTokenAge` option} is set, then JWT "iat" (Issued At) Claim must be
394
+ * present.
395
+ */
396
+ requiredClaims?: string[];
397
+ }
398
+ /** JWS Verification options. */
399
+ interface VerifyOptions extends CritOption {
400
+ /**
401
+ * A list of accepted JWS "alg" (Algorithm) Header Parameter values. By default all "alg"
402
+ * (Algorithm) values applicable for the used key/secret are allowed.
403
+ *
404
+ * > [!NOTE]\
405
+ * > Unsecured JWTs (`{ "alg": "none" }`) are never accepted by this API.
406
+ */
407
+ algorithms?: string[];
408
+ }
409
+ /** Recognized JWT Claims Set members, any other members may also be present. */
410
+ interface JWTPayload {
411
+ /**
412
+ * JWT Issuer
413
+ *
414
+ * @see {@link https://www.rfc-editor.org/rfc/rfc7519#section-4.1.1 RFC7519#section-4.1.1}
415
+ */
416
+ iss?: string;
417
+ /**
418
+ * JWT Subject
419
+ *
420
+ * @see {@link https://www.rfc-editor.org/rfc/rfc7519#section-4.1.2 RFC7519#section-4.1.2}
421
+ */
422
+ sub?: string;
423
+ /**
424
+ * JWT Audience
425
+ *
426
+ * @see {@link https://www.rfc-editor.org/rfc/rfc7519#section-4.1.3 RFC7519#section-4.1.3}
427
+ */
428
+ aud?: string | string[];
429
+ /**
430
+ * JWT ID
431
+ *
432
+ * @see {@link https://www.rfc-editor.org/rfc/rfc7519#section-4.1.7 RFC7519#section-4.1.7}
433
+ */
434
+ jti?: string;
435
+ /**
436
+ * JWT Not Before
437
+ *
438
+ * @see {@link https://www.rfc-editor.org/rfc/rfc7519#section-4.1.5 RFC7519#section-4.1.5}
439
+ */
440
+ nbf?: number;
441
+ /**
442
+ * JWT Expiration Time
443
+ *
444
+ * @see {@link https://www.rfc-editor.org/rfc/rfc7519#section-4.1.4 RFC7519#section-4.1.4}
445
+ */
446
+ exp?: number;
447
+ /**
448
+ * JWT Issued At
449
+ *
450
+ * @see {@link https://www.rfc-editor.org/rfc/rfc7519#section-4.1.6 RFC7519#section-4.1.6}
451
+ */
452
+ iat?: number;
453
+ /** Any other JWT Claim Set member. */
454
+ [propName: string]: unknown;
455
+ }
456
+ /** Signed JSON Web Token (JWT) verification result */
457
+ interface JWTVerifyResult<PayloadType = JWTPayload> {
458
+ /** JWT Claims Set. */
459
+ payload: PayloadType & JWTPayload;
460
+ /** JWS Protected Header. */
461
+ protectedHeader: JWTHeaderParameters;
462
+ }
463
+ /** Recognized Compact JWS Header Parameters, any other Header Members may also be present. */
464
+ interface CompactJWSHeaderParameters extends JWSHeaderParameters {
465
+ alg: string;
466
+ }
467
+ /** Recognized Signed JWT Header Parameters, any other Header Members may also be present. */
468
+ interface JWTHeaderParameters extends CompactJWSHeaderParameters {
469
+ b64?: true;
470
+ }
471
+ /** JSON Web Key Set */
472
+ interface JSONWebKeySet {
473
+ keys: JWK[];
474
+ }
475
+ /**
476
+ * {@link !KeyObject} is a representation of a key/secret available in the Node.js runtime. You may
477
+ * use the Node.js runtime APIs {@link !createPublicKey}, {@link !createPrivateKey}, and
478
+ * {@link !createSecretKey} to obtain a {@link !KeyObject} from your existing key material.
479
+ */
480
+ interface KeyObject {
481
+ type: string;
482
+ }
483
+ /**
484
+ * {@link !CryptoKey} is a representation of a key/secret available in all supported runtimes. In
485
+ * addition to the {@link key/import Key Import Functions} you may use the
486
+ * {@link !SubtleCrypto.importKey} API to obtain a {@link !CryptoKey} from your existing key
487
+ * material.
488
+ */
489
+ type CryptoKey = Extract<Awaited<ReturnType<typeof crypto.subtle.generateKey>>, {
490
+ type: string;
491
+ }>;
492
+ //#endregion
493
+ //#region ../../../../node_modules/jose/dist/types/jwt/verify.d.ts
494
+ /** Combination of JWS Verification options and JWT Claims Set verification options. */
495
+ interface JWTVerifyOptions extends VerifyOptions, JWTClaimVerificationOptions {}
496
+ //#endregion
146
497
  //#region ../../src/security/providers/JwtProvider.d.ts
147
498
  /**
148
499
  * Provides utilities for working with JSON Web Tokens (JWT).
149
500
  */
150
501
  declare class JwtProvider {
151
- protected readonly log: alepha_logger2.Logger;
502
+ protected readonly log: alepha_logger0.Logger;
152
503
  protected readonly keystore: KeyLoaderHolder[];
153
504
  protected readonly dateTimeProvider: DateTimeProvider;
154
505
  protected readonly encoder: TextEncoder;
155
506
  /**
156
- * Adds a key loader to the embedded keystore.
157
- *
158
- * @param name
159
- * @param secretKeyOrJwks
160
- */
507
+ * Adds a key loader to the embedded keystore.
508
+ *
509
+ * @param name
510
+ * @param secretKeyOrJwks
511
+ */
161
512
  setKeyLoader(name: string, secretKeyOrJwks: string | JSONWebKeySet): void;
162
513
  /**
163
- * Retrieves the payload from a JSON Web Token (JWT).
164
- *
165
- * @param token - The JWT to extract the payload from.
166
- *
167
- * @return A Promise that resolves with the payload object from the token.
168
- */
514
+ * Retrieves the payload from a JSON Web Token (JWT).
515
+ *
516
+ * @param token - The JWT to extract the payload from.
517
+ *
518
+ * @return A Promise that resolves with the payload object from the token.
519
+ */
169
520
  parse(token: string, keyName?: string, options?: JWTVerifyOptions): Promise<JwtParseResult>;
170
521
  /**
171
- * Creates a JWT token with the provided payload and secret key.
172
- *
173
- * @param payload - The payload to be encoded in the token.
174
- * It should include the `realm_access` property which contains an array of roles.
175
- * @param keyName - The name of the key to use when signing the token.
176
- *
177
- * @returns The signed JWT token.
178
- */
522
+ * Creates a JWT token with the provided payload and secret key.
523
+ *
524
+ * @param payload - The payload to be encoded in the token.
525
+ * It should include the `realm_access` property which contains an array of roles.
526
+ * @param keyName - The name of the key to use when signing the token.
527
+ *
528
+ * @returns The signed JWT token.
529
+ */
179
530
  create(payload: ExtendedJWTPayload, keyName?: string, signOptions?: JwtSignOptions): Promise<string>;
180
531
  /**
181
- * Determines if the provided key is a secret key.
182
- *
183
- * @param key
184
- * @protected
185
- */
532
+ * Determines if the provided key is a secret key.
533
+ *
534
+ * @param key
535
+ * @protected
536
+ */
186
537
  protected isSecretKey(key: string): boolean;
187
538
  }
188
539
  type KeyLoader = (protectedHeader?: JWSHeaderParameters, token?: FlattenedJWSInput) => Promise<CryptoKey | KeyObject>;
@@ -244,7 +595,7 @@ declare class SecurityProvider {
244
595
  protected readonly UNKNOWN_USER_NAME = "Anonymous User";
245
596
  protected readonly PERMISSION_REGEXP: RegExp;
246
597
  protected readonly PERMISSION_REGEXP_WILDCARD: RegExp;
247
- protected readonly log: alepha_logger2.Logger;
598
+ protected readonly log: alepha_logger0.Logger;
248
599
  protected readonly jwt: JwtProvider;
249
600
  protected readonly env: {
250
601
  APP_SECRET: string;
@@ -252,122 +603,162 @@ declare class SecurityProvider {
252
603
  protected readonly alepha: Alepha;
253
604
  get secretKey(): string;
254
605
  /**
255
- * The permissions configured for the security provider.
256
- */
606
+ * The permissions configured for the security provider.
607
+ */
257
608
  protected readonly permissions: Permission[];
258
609
  /**
259
- * The realms configured for the security provider.
260
- */
610
+ * The realms configured for the security provider.
611
+ */
261
612
  protected readonly realms: Realm[];
262
613
  protected start: alepha3.HookPrimitive<"start">;
263
614
  /**
264
- * Adds a role to one or more realms.
265
- *
266
- * @param role
267
- * @param realms
268
- */
615
+ * Creates a default JWT resolver for a realm.
616
+ */
617
+ protected createDefaultJwtResolver(realmName: string): IssuerResolver;
618
+ /**
619
+ * Adds a role to one or more realms.
620
+ *
621
+ * @param role
622
+ * @param realms
623
+ */
269
624
  createRole(role: Role, ...realms: string[]): Role;
270
625
  /**
271
- * Adds a permission to the security provider.
272
- *
273
- * @param raw - The permission to add.
274
- */
626
+ * Adds a permission to the security provider.
627
+ *
628
+ * @param raw - The permission to add.
629
+ */
275
630
  createPermission(raw: Permission | string): Permission;
276
631
  createRealm(realm: Realm): void;
277
632
  /**
278
- * Updates the roles for a realm then synchronizes the user account provider if available.
279
- *
280
- * Only available when the app is started.
281
- *
282
- * @param realm - The realm to update the roles for.
283
- * @param roles - The roles to update.
284
- */
633
+ * Updates the roles for a realm then synchronizes the user account provider if available.
634
+ *
635
+ * Only available when the app is started.
636
+ *
637
+ * @param realm - The realm to update the roles for.
638
+ * @param roles - The roles to update.
639
+ */
285
640
  updateRealm(realm: string, roles: Role[]): Promise<void>;
286
641
  /**
287
- * Creates a user account from the provided payload.
288
- *
289
- * @param payload - The payload to create the user account from.
290
- * @param [realmName] - The realm containing the roles. Default is all.
291
- *
292
- * @returns The user info created from the payload.
293
- */
642
+ * Creates a user account from the provided payload.
643
+ *
644
+ * @param payload - The payload to create the user account from.
645
+ * @param [realmName] - The realm containing the roles. Default is all.
646
+ *
647
+ * @returns The user info created from the payload.
648
+ */
294
649
  createUserFromPayload(payload: JWTPayload, realmName?: string): UserAccount;
295
650
  /**
296
- * Checks if the user has the specified permission.
297
- *
298
- * Bonus: we check also if the user has "ownership" flag.
299
- *
300
- * @param permissionLike - The permission to check for.
301
- * @param roleEntries - The roles to check for the permission.
302
- */
651
+ * Generic user creation from any source (JWT, API key, etc.).
652
+ * Handles permission checking, ownership, default roles.
653
+ */
654
+ createUser(userInfo: UserInfo, options?: {
655
+ realm?: string;
656
+ permission?: Permission | string;
657
+ }): UserAccountToken;
658
+ /**
659
+ * Register a resolver to a realm.
660
+ * Resolvers are sorted by priority (lower = first).
661
+ */
662
+ registerResolver(resolver: IssuerResolver, realmName?: string): void;
663
+ /**
664
+ * Get a realm by name.
665
+ * Throws if realm not found.
666
+ */
667
+ getRealm(realmName?: string): Realm;
668
+ /**
669
+ * Resolve user from request using registered resolvers.
670
+ * Returns undefined if no resolver could authenticate (no auth provided).
671
+ * Throws UnauthorizedError if auth was provided but invalid.
672
+ *
673
+ * Note: This method tries resolvers from ALL realms to find a match,
674
+ * regardless of the `realm` option. The `realm` option is only used for
675
+ * permission checking after the user is resolved.
676
+ */
677
+ resolveUserFromServerRequest(req: {
678
+ url: URL | string;
679
+ headers: {
680
+ authorization?: string;
681
+ };
682
+ }, options?: {
683
+ realm?: string;
684
+ permission?: Permission | string;
685
+ }): Promise<UserAccountToken | undefined>;
686
+ /**
687
+ * Checks if the user has the specified permission.
688
+ *
689
+ * Bonus: we check also if the user has "ownership" flag.
690
+ *
691
+ * @param permissionLike - The permission to check for.
692
+ * @param roleEntries - The roles to check for the permission.
693
+ */
303
694
  checkPermission(permissionLike: string | Permission, ...roleEntries: string[]): SecurityCheckResult;
304
695
  /**
305
- * Creates a user account from the provided payload.
306
- */
696
+ * Creates a user account from the provided payload.
697
+ */
307
698
  createUserFromToken(headerOrToken?: string, options?: {
308
699
  permission?: Permission | string;
309
700
  realm?: string;
310
701
  verify?: JWTVerifyOptions;
311
702
  }): Promise<UserAccountToken>;
312
703
  /**
313
- * Checks if a user has a specific role.
314
- *
315
- * @param roleName - The role to check for.
316
- * @param permission - The permission to check for.
317
- * @returns True if the user has the role, false otherwise.
318
- */
704
+ * Checks if a user has a specific role.
705
+ *
706
+ * @param roleName - The role to check for.
707
+ * @param permission - The permission to check for.
708
+ * @returns True if the user has the role, false otherwise.
709
+ */
319
710
  can(roleName: string, permission: string | Permission): boolean;
320
711
  /**
321
- * Checks if a user has ownership of a specific permission.
322
- */
712
+ * Checks if a user has ownership of a specific permission.
713
+ */
323
714
  ownership(roleName: string, permission: string | Permission): string | boolean | undefined;
324
715
  /**
325
- * Converts a permission object to a string.
326
- *
327
- * @param permission
328
- */
716
+ * Converts a permission object to a string.
717
+ *
718
+ * @param permission
719
+ */
329
720
  permissionToString(permission: Permission | string): string;
330
721
  getRealms(): Realm[];
331
722
  /**
332
- * Retrieves the user account from the provided user ID.
333
- *
334
- * @param realm
335
- */
723
+ * Retrieves the user account from the provided user ID.
724
+ *
725
+ * @param realm
726
+ */
336
727
  getRoles(realm?: string): Role[];
337
728
  /**
338
- * Returns all permissions.
339
- *
340
- * @param user - Filter permissions by user.
341
- *
342
- * @return An array containing all permissions.
343
- */
729
+ * Returns all permissions.
730
+ *
731
+ * @param user - Filter permissions by user.
732
+ *
733
+ * @return An array containing all permissions.
734
+ */
344
735
  getPermissions(user?: {
345
736
  roles?: Array<Role | string>;
346
737
  realm?: string;
347
738
  }): Permission[];
348
739
  /**
349
- * Retrieves the user ID from the provided payload object.
350
- *
351
- * @param payload - The payload object from which to extract the user ID.
352
- * @return The user ID as a string.
353
- */
740
+ * Retrieves the user ID from the provided payload object.
741
+ *
742
+ * @param payload - The payload object from which to extract the user ID.
743
+ * @return The user ID as a string.
744
+ */
354
745
  getIdFromPayload(payload: Record<string, any>): string;
355
746
  getSessionIdFromPayload(payload: Record<string, any>): string | undefined;
356
747
  /**
357
- * Retrieves the roles from the provided payload object.
358
- * @param payload - The payload object from which to extract the roles.
359
- * @return An array of role strings.
360
- */
748
+ * Retrieves the roles from the provided payload object.
749
+ * @param payload - The payload object from which to extract the roles.
750
+ * @return An array of role strings.
751
+ */
361
752
  getRolesFromPayload(payload: Record<string, any>): string[];
362
753
  getPictureFromPayload(payload: Record<string, any>): string | undefined;
363
754
  getUsernameFromPayload(payload: Record<string, any>): string | undefined;
364
755
  getEmailFromPayload(payload: Record<string, any>): string | undefined;
365
756
  /**
366
- * Returns the name from the given payload.
367
- *
368
- * @param payload - The payload object.
369
- * @returns The name extracted from the payload, or an empty string if the payload is falsy or no name is found.
370
- */
757
+ * Returns the name from the given payload.
758
+ *
759
+ * @param payload - The payload object.
760
+ * @returns The name extracted from the payload, or an empty string if the payload is falsy or no name is found.
761
+ */
371
762
  getNameFromPayload(payload: Record<string, any>): string;
372
763
  getOrganizationsFromPayload(payload: Record<string, any>): string[] | undefined;
373
764
  }
@@ -378,16 +769,20 @@ interface Realm {
378
769
  name: string;
379
770
  roles: Role[];
380
771
  /**
381
- * The secret key for the realm.
382
- *
383
- * Can be also a JWKS URL.
384
- */
772
+ * The secret key for the realm.
773
+ *
774
+ * Can be also a JWKS URL.
775
+ */
385
776
  secret?: string | JSONWebKeySet | (() => string);
386
777
  /**
387
- * Create the user account info based on the raw JWT payload.
388
- * By default, SecurityProvider has his own implementation, but this method allow to override it.
389
- */
778
+ * Create the user account info based on the raw JWT payload.
779
+ * By default, SecurityProvider has his own implementation, but this method allow to override it.
780
+ */
390
781
  profile?: (raw: Record<string, any>) => UserAccount;
782
+ /**
783
+ * Custom resolvers for this realm (sorted by priority).
784
+ */
785
+ resolvers?: IssuerResolver[];
391
786
  }
392
787
  interface SecurityCheckResult {
393
788
  isAuthorized: boolean;
@@ -407,40 +802,44 @@ declare const $issuer: {
407
802
  };
408
803
  type IssuerPrimitiveOptions = {
409
804
  /**
410
- * Define the issuer name.
411
- * If not provided, it will use the property key.
412
- */
805
+ * Define the issuer name.
806
+ * If not provided, it will use the property key.
807
+ */
413
808
  name?: string;
414
809
  /**
415
- * Short description about the issuer.
416
- */
810
+ * Short description about the issuer.
811
+ */
417
812
  description?: string;
418
813
  /**
419
- * All roles available in the issuer. Role is a string (role name) or a Role object (embedded role).
420
- */
814
+ * All roles available in the issuer. Role is a string (role name) or a Role object (embedded role).
815
+ */
421
816
  roles?: Array<string | Role>;
422
817
  /**
423
- * Issuer settings.
424
- */
818
+ * Issuer settings.
819
+ */
425
820
  settings?: IssuerSettings;
426
821
  /**
427
- * Parse the JWT payload to create a user account info.
428
- */
822
+ * Parse the JWT payload to create a user account info.
823
+ */
429
824
  profile?: (jwtPayload: Record<string, any>) => UserAccount;
825
+ /**
826
+ * Custom resolvers (in addition to default JWT resolver).
827
+ */
828
+ resolvers?: IssuerResolver[];
430
829
  } & (IssuerInternal | IssuerExternal);
431
830
  interface IssuerSettings {
432
831
  accessToken?: {
433
832
  /**
434
- * Lifetime of the access token.
435
- * @default 15 minutes
436
- */
833
+ * Lifetime of the access token.
834
+ * @default 15 minutes
835
+ */
437
836
  expiration?: DurationLike;
438
837
  };
439
838
  refreshToken?: {
440
839
  /**
441
- * Lifetime of the refresh token.
442
- * @default 30 days
443
- */
840
+ * Lifetime of the refresh token.
841
+ * @default 30 days
842
+ */
444
843
  expiration?: DurationLike;
445
844
  };
446
845
  onCreateSession?: (user: UserAccount, config: {
@@ -458,41 +857,50 @@ interface IssuerSettings {
458
857
  }
459
858
  type IssuerInternal = {
460
859
  /**
461
- * Internal secret to sign JWT tokens and verify them.
462
- */
860
+ * Internal secret to sign JWT tokens and verify them.
861
+ */
463
862
  secret: string;
464
863
  };
465
864
  interface IssuerExternal {
466
865
  /**
467
- * URL to the JWKS (JSON Web Key Set) to verify JWT tokens from external providers.
468
- */
866
+ * URL to the JWKS (JSON Web Key Set) to verify JWT tokens from external providers.
867
+ */
469
868
  jwks: (() => string) | JSONWebKeySet;
470
869
  }
471
870
  declare class IssuerPrimitive extends Primitive<IssuerPrimitiveOptions> {
472
871
  protected readonly securityProvider: SecurityProvider;
473
872
  protected readonly dateTimeProvider: DateTimeProvider;
474
873
  protected readonly jwt: JwtProvider;
475
- protected readonly log: alepha_logger2.Logger;
874
+ protected readonly log: alepha_logger0.Logger;
476
875
  get name(): string;
477
876
  get accessTokenExpiration(): Duration;
478
877
  get refreshTokenExpiration(): Duration;
479
878
  protected onInit(): void;
480
879
  /**
481
- * Get all roles in the issuer.
482
- */
880
+ * Creates the default JWT resolver.
881
+ */
882
+ protected createJwtResolver(): IssuerResolver;
883
+ /**
884
+ * Register a resolver to this issuer.
885
+ * Resolvers are sorted by priority (lower = first).
886
+ */
887
+ registerResolver(resolver: IssuerResolver): void;
888
+ /**
889
+ * Get all roles in the issuer.
890
+ */
483
891
  getRoles(): Role[];
484
892
  /**
485
- * Set all roles in the issuer.
486
- */
893
+ * Set all roles in the issuer.
894
+ */
487
895
  setRoles(roles: Role[]): Promise<void>;
488
896
  /**
489
- * Get a role by name, throws an error if not found.
490
- */
897
+ * Get a role by name, throws an error if not found.
898
+ */
491
899
  getRoleByName(name: string): Role;
492
900
  parseToken(token: string): Promise<JWTPayload>;
493
901
  /**
494
- * Create a token for the subject.
495
- */
902
+ * Create a token for the subject.
903
+ */
496
904
  createToken(user: UserAccount, refreshToken?: {
497
905
  sid?: string;
498
906
  refresh_token?: string;
@@ -528,16 +936,16 @@ declare const $permission: {
528
936
  };
529
937
  interface PermissionPrimitiveOptions {
530
938
  /**
531
- * Name of the permission. Use Property name is not provided.
532
- */
939
+ * Name of the permission. Use Property name is not provided.
940
+ */
533
941
  name?: string;
534
942
  /**
535
- * Group of the permission. Use Class name is not provided.
536
- */
943
+ * Group of the permission. Use Class name is not provided.
944
+ */
537
945
  group?: string;
538
946
  /**
539
- * Describe the permission.
540
- */
947
+ * Describe the permission.
948
+ */
541
949
  description?: string;
542
950
  }
543
951
  declare class PermissionPrimitive extends Primitive<PermissionPrimitiveOptions> {
@@ -547,8 +955,8 @@ declare class PermissionPrimitive extends Primitive<PermissionPrimitiveOptions>
547
955
  toString(): string;
548
956
  protected onInit(): void;
549
957
  /**
550
- * Check if the user has the permission.
551
- */
958
+ * Check if the user has the permission.
959
+ */
552
960
  can(user?: UserAccount): boolean;
553
961
  }
554
962
  //#endregion
@@ -562,12 +970,12 @@ declare const $role: {
562
970
  };
563
971
  interface RolePrimitiveOptions {
564
972
  /**
565
- * Name of the role.
566
- */
973
+ * Name of the role.
974
+ */
567
975
  name?: string;
568
976
  /**
569
- * Describe the role.
570
- */
977
+ * Describe the role.
978
+ */
571
979
  description?: string;
572
980
  issuer?: string | IssuerPrimitive;
573
981
  permissions?: Array<string | {
@@ -581,8 +989,8 @@ declare class RolePrimitive extends Primitive<RolePrimitiveOptions> {
581
989
  get name(): string;
582
990
  protected onInit(): void;
583
991
  /**
584
- * Get the issuer of the role.
585
- */
992
+ * Get the issuer of the role.
993
+ */
586
994
  get issuer(): string | IssuerPrimitive | undefined;
587
995
  can(permission: string | PermissionPrimitive): boolean;
588
996
  check(permission: string | PermissionPrimitive): SecurityCheckResult;
@@ -628,16 +1036,16 @@ type ServiceAccountPrimitiveOptions = {
628
1036
  });
629
1037
  interface Oauth2ServiceAccountPrimitiveOptions {
630
1038
  /**
631
- * Get Token URL.
632
- */
1039
+ * Get Token URL.
1040
+ */
633
1041
  url: string;
634
1042
  /**
635
- * Client ID.
636
- */
1043
+ * Client ID.
1044
+ */
637
1045
  clientId: string;
638
1046
  /**
639
- * Client Secret.
640
- */
1047
+ * Client Secret.
1048
+ */
641
1049
  clientSecret: string;
642
1050
  }
643
1051
  interface ServiceAccountPrimitive {
@@ -656,25 +1064,26 @@ declare class CryptoProvider {
656
1064
  //#endregion
657
1065
  //#region ../../src/security/providers/ServerSecurityProvider.d.ts
658
1066
  declare class ServerSecurityProvider {
659
- protected readonly log: alepha_logger2.Logger;
1067
+ protected readonly log: alepha_logger0.Logger;
660
1068
  protected readonly securityProvider: SecurityProvider;
661
1069
  protected readonly jwtProvider: JwtProvider;
662
1070
  protected readonly alepha: Alepha;
1071
+ protected readonly resolvers: Array<ServerSecurityUserResolver>;
663
1072
  protected readonly onConfigure: alepha3.HookPrimitive<"configure">;
664
1073
  protected readonly onActionRequest: alepha3.HookPrimitive<"action:onRequest">;
665
1074
  protected readonly onRequest: alepha3.HookPrimitive<"server:onRequest">;
666
1075
  protected check(user: UserAccountToken, secure: ServerRouteSecure): void;
667
1076
  /**
668
- * Get the user account token for a local action call.
669
- * There are three possible sources for the user:
670
- * - `options.user`: the user passed in the options
671
- * - `"system"`: the system user from the state (you MUST set state `server.security.system.user`)
672
- * - `"context"`: the user from the request context (you MUST be in an HTTP request context)
673
- *
674
- * Priority order: `options.user` > `"system"` > `"context"`.
675
- *
676
- * In testing environment, if no user is provided, a test user is created based on the SecurityProvider's roles.
677
- */
1077
+ * Get the user account token for a local action call.
1078
+ * There are three possible sources for the user:
1079
+ * - `options.user`: the user passed in the options
1080
+ * - `"system"`: the system user from the state (you MUST set state `server.security.system.user`)
1081
+ * - `"context"`: the user from the request context (you MUST be in an HTTP request context)
1082
+ *
1083
+ * Priority order: `options.user` > `"system"` > `"context"`.
1084
+ *
1085
+ * In testing environment, if no user is provided, a test user is created based on the SecurityProvider's roles.
1086
+ */
678
1087
  protected createUserFromLocalFunctionContext(options: {
679
1088
  user?: UserAccountToken | "system" | "context";
680
1089
  }, permission?: Permission): UserAccountToken;
@@ -685,6 +1094,7 @@ type ServerRouteSecure = {
685
1094
  realm?: string;
686
1095
  basic?: BasicAuthOptions;
687
1096
  };
1097
+ type ServerSecurityUserResolver = (request: ServerRequest) => Promise<UserAccountToken | undefined>;
688
1098
  //#endregion
689
1099
  //#region ../../src/security/index.d.ts
690
1100
  declare module "alepha" {
@@ -696,17 +1106,17 @@ declare module "alepha" {
696
1106
  }
697
1107
  interface State {
698
1108
  /**
699
- * Real (or fake) user account, used for internal actions.
700
- *
701
- * If you define this, you assume that all actions are executed by this user by default.
702
- * > To force a different user, you need to pass it explicitly in the options.
703
- */
1109
+ * Real (or fake) user account, used for internal actions.
1110
+ *
1111
+ * If you define this, you assume that all actions are executed by this user by default.
1112
+ * > To force a different user, you need to pass it explicitly in the options.
1113
+ */
704
1114
  "alepha.server.security.system.user"?: UserAccountToken;
705
1115
  /**
706
- * The authenticated user account attached to the server request state.
707
- *
708
- * @internal
709
- */
1116
+ * The authenticated user account attached to the server request state.
1117
+ *
1118
+ * @internal
1119
+ */
710
1120
  "alepha.server.request.user"?: UserAccount;
711
1121
  }
712
1122
  }
@@ -719,36 +1129,40 @@ declare module "alepha/server" {
719
1129
  }
720
1130
  interface ServerRoute {
721
1131
  /**
722
- * If true, the route will be protected by the security provider.
723
- * All actions are secure by default, but you can disable it for specific actions.
724
- */
1132
+ * If true, the route will be protected by the security provider.
1133
+ * All actions are secure by default, but you can disable it for specific actions.
1134
+ */
725
1135
  secure?: boolean | ServerRouteSecure;
726
1136
  }
727
1137
  interface ClientRequestOptions extends FetchOptions {
728
1138
  /**
729
- * Forward user from the previous request.
730
- * If "system", use system user. @see {ServerSecurityProvider.localSystemUser}
731
- * If "context", use the user from the current context (e.g. request).
732
- *
733
- * @default "system" if provided, else "context" if available.
734
- */
1139
+ * Forward user from the previous request.
1140
+ * If "system", use system user. @see {ServerSecurityProvider.localSystemUser}
1141
+ * If "context", use the user from the current context (e.g. request).
1142
+ *
1143
+ * @default "system" if provided, else "context" if available.
1144
+ */
735
1145
  user?: UserAccountToken | "system" | "context";
736
1146
  }
737
1147
  }
738
1148
  /**
739
- * Provides comprehensive authentication and authorization capabilities with JWT tokens, role-based access control, and user management.
1149
+ * | type | quality | stability |
1150
+ * |------|---------|-----------|
1151
+ * | backend | epic | stable |
740
1152
  *
741
- * The security module enables building secure applications using primitives like `$issuer`, `$role`, and `$permission`
742
- * on class properties. It offers JWT-based authentication, fine-grained permissions, service accounts, and seamless
743
- * integration with various authentication providers and user management systems.
1153
+ * Complete authentication and authorization system with JWT, RBAC, and multi-issuer support.
744
1154
  *
745
- * When used with `AlephaServer`, this module automatically registers `ServerSecurityProvider` and `ServerBasicAuthProvider`
746
- * to protect HTTP routes and actions with JWT and Basic Auth.
1155
+ * **Features:**
1156
+ * - JWT token issuer with role definitions
1157
+ * - Role-based access control (RBAC)
1158
+ * - Fine-grained permissions
1159
+ * - HTTP Basic Authentication
1160
+ * - Service-to-service authentication
1161
+ * - Multi-issuer support for federated auth
1162
+ * - JWKS (JSON Web Key Set) for external issuers
1163
+ * - Token refresh logic
1164
+ * - User profile extraction from JWT
747
1165
  *
748
- * @see {@link $issuer}
749
- * @see {@link $role}
750
- * @see {@link $permission}
751
- * @see {@link $basicAuth}
752
1166
  * @module alepha.security
753
1167
  */
754
1168
  declare const AlephaSecurity: alepha3.Service<alepha3.Module>;
@@ -757,5 +1171,5 @@ declare const AlephaSecurity: alepha3.Service<alepha3.Module>;
757
1171
  */
758
1172
  declare const AlephaServerSecurity: alepha3.Service<alepha3.Module>;
759
1173
  //#endregion
760
- export { $basicAuth, $issuer, $permission, $role, $serviceAccount, AbstractBasicAuthPrimitive, AccessTokenResponse, AlephaSecurity, AlephaServerSecurity, BasicAuthOptions, BasicAuthPrimitive, BasicAuthPrimitiveConfig, CreateTokenOptions, CryptoProvider, DEFAULT_APP_SECRET, ExtendedJWTPayload, InvalidCredentialsError, InvalidPermissionError, IssuerExternal, IssuerInternal, IssuerPrimitive, IssuerPrimitiveOptions, IssuerSettings, JwtParseResult, JwtProvider, JwtSignOptions, KeyLoader, KeyLoaderHolder, Oauth2ServiceAccountPrimitiveOptions, Permission, PermissionPrimitive, PermissionPrimitiveOptions, Realm, Role, RolePrimitive, RolePrimitiveOptions, SecurityCheckResult, SecurityError, SecurityProvider, ServerBasicAuthProvider, ServerRouteSecure, ServerSecurityProvider, ServiceAccountPrimitive, ServiceAccountPrimitiveOptions, ServiceAccountStore, UserAccount, UserAccountToken, isBasicAuth, permissionSchema, roleSchema, userAccountInfoSchema };
1174
+ export { $basicAuth, $issuer, $permission, $role, $serviceAccount, AbstractBasicAuthPrimitive, AccessTokenResponse, AlephaSecurity, AlephaServerSecurity, BasicAuthOptions, BasicAuthPrimitive, BasicAuthPrimitiveConfig, CreateTokenOptions, CryptoProvider, DEFAULT_APP_SECRET, ExtendedJWTPayload, InvalidCredentialsError, InvalidPermissionError, IssuerExternal, IssuerInternal, IssuerPrimitive, IssuerPrimitiveOptions, IssuerResolver, IssuerSettings, JwtParseResult, JwtProvider, JwtSignOptions, KeyLoader, KeyLoaderHolder, Oauth2ServiceAccountPrimitiveOptions, Permission, PermissionPrimitive, PermissionPrimitiveOptions, Realm, Role, RolePrimitive, RolePrimitiveOptions, SecurityCheckResult, SecurityError, SecurityProvider, ServerBasicAuthProvider, ServerRouteSecure, ServerSecurityProvider, ServerSecurityUserResolver, ServiceAccountPrimitive, ServiceAccountPrimitiveOptions, ServiceAccountStore, UserAccount, UserAccountToken, UserInfo, isBasicAuth, permissionSchema, roleSchema, userAccountInfoSchema };
761
1175
  //# sourceMappingURL=index.d.ts.map