alepha 0.20.6 → 0.20.8

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 (243) hide show
  1. package/AGENTS.md +0 -1
  2. package/CLAUDE.md +0 -1
  3. package/assets/agents-template.md +0 -1
  4. package/dist/api/audits/index.browser.js +1 -0
  5. package/dist/api/audits/index.browser.js.map +1 -1
  6. package/dist/api/audits/index.d.ts +370 -355
  7. package/dist/api/audits/index.d.ts.map +1 -1
  8. package/dist/api/audits/index.js +1 -0
  9. package/dist/api/audits/index.js.map +1 -1
  10. package/dist/api/files/index.browser.js +1 -0
  11. package/dist/api/files/index.browser.js.map +1 -1
  12. package/dist/api/files/index.d.ts +179 -170
  13. package/dist/api/files/index.d.ts.map +1 -1
  14. package/dist/api/files/index.js +1 -0
  15. package/dist/api/files/index.js.map +1 -1
  16. package/dist/api/jobs/index.browser.js +7 -0
  17. package/dist/api/jobs/index.browser.js.map +1 -1
  18. package/dist/api/jobs/index.d.ts +259 -250
  19. package/dist/api/jobs/index.d.ts.map +1 -1
  20. package/dist/api/jobs/index.js +21 -3
  21. package/dist/api/jobs/index.js.map +1 -1
  22. package/dist/api/keys/index.d.ts +198 -192
  23. package/dist/api/keys/index.d.ts.map +1 -1
  24. package/dist/api/keys/index.js +1 -0
  25. package/dist/api/keys/index.js.map +1 -1
  26. package/dist/api/notifications/index.d.ts +246 -245
  27. package/dist/api/notifications/index.d.ts.map +1 -1
  28. package/dist/api/organizations/index.d.ts +100 -97
  29. package/dist/api/organizations/index.d.ts.map +1 -1
  30. package/dist/api/parameters/index.d.ts +323 -320
  31. package/dist/api/parameters/index.d.ts.map +1 -1
  32. package/dist/api/payments/index.d.ts +431 -376
  33. package/dist/api/payments/index.d.ts.map +1 -1
  34. package/dist/api/payments/index.js +202 -87
  35. package/dist/api/payments/index.js.map +1 -1
  36. package/dist/api/subscriptions/index.d.ts +1695 -0
  37. package/dist/api/subscriptions/index.d.ts.map +1 -0
  38. package/dist/api/subscriptions/index.js +1919 -0
  39. package/dist/api/subscriptions/index.js.map +1 -0
  40. package/dist/api/users/index.d.ts +857 -841
  41. package/dist/api/users/index.d.ts.map +1 -1
  42. package/dist/api/verifications/index.d.ts +128 -127
  43. package/dist/api/verifications/index.d.ts.map +1 -1
  44. package/dist/bucket/index.d.ts +3 -2
  45. package/dist/bucket/index.d.ts.map +1 -1
  46. package/dist/cache/core/index.d.ts +114 -4
  47. package/dist/cache/core/index.d.ts.map +1 -1
  48. package/dist/cache/core/index.js +181 -15
  49. package/dist/cache/core/index.js.map +1 -1
  50. package/dist/cache/core/index.workerd.js +181 -15
  51. package/dist/cache/core/index.workerd.js.map +1 -1
  52. package/dist/cache/database/index.d.ts +20 -19
  53. package/dist/cache/database/index.d.ts.map +1 -1
  54. package/dist/cache/redis/index.d.ts +3 -2
  55. package/dist/cache/redis/index.d.ts.map +1 -1
  56. package/dist/cli/core/index.d.ts +116 -132
  57. package/dist/cli/core/index.d.ts.map +1 -1
  58. package/dist/cli/core/index.js +75 -7
  59. package/dist/cli/core/index.js.map +1 -1
  60. package/dist/cli/devtools/index.d.ts +3 -2
  61. package/dist/cli/devtools/index.d.ts.map +1 -1
  62. package/dist/cli/platform/index.d.ts +346 -290
  63. package/dist/cli/platform/index.d.ts.map +1 -1
  64. package/dist/cli/platform/index.js +105 -6
  65. package/dist/cli/platform/index.js.map +1 -1
  66. package/dist/cli/vendor/index.d.ts +12 -11
  67. package/dist/cli/vendor/index.d.ts.map +1 -1
  68. package/dist/command/index.d.ts +5 -4
  69. package/dist/command/index.d.ts.map +1 -1
  70. package/dist/core/index.browser.js +1 -1
  71. package/dist/core/index.browser.js.map +1 -1
  72. package/dist/core/index.d.ts +119 -118
  73. package/dist/core/index.d.ts.map +1 -1
  74. package/dist/core/index.js +1 -1
  75. package/dist/core/index.js.map +1 -1
  76. package/dist/core/index.native.js +1 -1
  77. package/dist/core/index.native.js.map +1 -1
  78. package/dist/core/index.workerd.js +1 -1
  79. package/dist/core/index.workerd.js.map +1 -1
  80. package/dist/crypto/index.d.ts +3 -2
  81. package/dist/crypto/index.d.ts.map +1 -1
  82. package/dist/email/core/index.d.ts +3 -2
  83. package/dist/email/core/index.d.ts.map +1 -1
  84. package/dist/email/smtp/index.d.ts +7 -6
  85. package/dist/email/smtp/index.d.ts.map +1 -1
  86. package/dist/lock/core/index.d.ts +5 -4
  87. package/dist/lock/core/index.d.ts.map +1 -1
  88. package/dist/logger/index.d.ts +10 -9
  89. package/dist/logger/index.d.ts.map +1 -1
  90. package/dist/mcp/index.d.ts +9 -8
  91. package/dist/mcp/index.d.ts.map +1 -1
  92. package/dist/mcp/index.js +1 -1
  93. package/dist/mcp/index.js.map +1 -1
  94. package/dist/orm/core/index.browser.js +9 -3
  95. package/dist/orm/core/index.browser.js.map +1 -1
  96. package/dist/orm/core/index.bun.js +31 -10
  97. package/dist/orm/core/index.bun.js.map +1 -1
  98. package/dist/orm/core/index.d.ts +33 -14
  99. package/dist/orm/core/index.d.ts.map +1 -1
  100. package/dist/orm/core/index.js +31 -10
  101. package/dist/orm/core/index.js.map +1 -1
  102. package/dist/orm/postgres/index.d.ts +6 -5
  103. package/dist/orm/postgres/index.d.ts.map +1 -1
  104. package/dist/queue/core/index.d.ts +5 -4
  105. package/dist/queue/core/index.d.ts.map +1 -1
  106. package/dist/queue/redis/index.d.ts +3 -2
  107. package/dist/queue/redis/index.d.ts.map +1 -1
  108. package/dist/react/form/index.d.ts +5 -0
  109. package/dist/react/form/index.d.ts.map +1 -1
  110. package/dist/react/form/index.js +6 -4
  111. package/dist/react/form/index.js.map +1 -1
  112. package/dist/react/i18n/index.d.ts +2 -1
  113. package/dist/react/i18n/index.d.ts.map +1 -1
  114. package/dist/react/router/index.d.ts +206 -205
  115. package/dist/react/router/index.d.ts.map +1 -1
  116. package/dist/react/ui/index.d.ts +11 -11
  117. package/dist/react/ui/index.d.ts.map +1 -1
  118. package/dist/scheduler/index.d.ts +3 -2
  119. package/dist/scheduler/index.d.ts.map +1 -1
  120. package/dist/security/index.browser.js +29 -1
  121. package/dist/security/index.browser.js.map +1 -1
  122. package/dist/security/index.d.ts +82 -35
  123. package/dist/security/index.d.ts.map +1 -1
  124. package/dist/security/index.js +56 -3
  125. package/dist/security/index.js.map +1 -1
  126. package/dist/server/auth/index.d.ts +163 -158
  127. package/dist/server/auth/index.d.ts.map +1 -1
  128. package/dist/server/auth/index.js +16 -4
  129. package/dist/server/auth/index.js.map +1 -1
  130. package/dist/server/core/index.d.ts +35 -34
  131. package/dist/server/core/index.d.ts.map +1 -1
  132. package/dist/server/cors/index.d.ts +7 -6
  133. package/dist/server/cors/index.d.ts.map +1 -1
  134. package/dist/server/health/index.d.ts +16 -15
  135. package/dist/server/health/index.d.ts.map +1 -1
  136. package/dist/server/links/index.d.ts +51 -50
  137. package/dist/server/links/index.d.ts.map +1 -1
  138. package/dist/server/rate-limit/index.d.ts +6 -5
  139. package/dist/server/rate-limit/index.d.ts.map +1 -1
  140. package/dist/server/swagger/index.d.ts +2 -1
  141. package/dist/server/swagger/index.d.ts.map +1 -1
  142. package/dist/topic/redis/index.d.ts +3 -2
  143. package/dist/topic/redis/index.d.ts.map +1 -1
  144. package/package.json +16 -32
  145. package/src/api/audits/entities/audits.ts +1 -0
  146. package/src/api/files/entities/files.ts +1 -0
  147. package/src/api/jobs/__tests__/$job.spec.ts +92 -40
  148. package/src/api/jobs/entities/jobExecutionEntity.ts +1 -0
  149. package/src/api/jobs/providers/JobProvider.ts +20 -5
  150. package/src/api/jobs/schemas/jobConfigAtom.ts +5 -0
  151. package/src/api/keys/entities/apiKeyEntity.ts +1 -0
  152. package/src/api/payments/controllers/MockCheckoutController.ts +146 -0
  153. package/src/api/payments/index.ts +3 -0
  154. package/src/api/payments/providers/MemoryPaymentProvider.ts +9 -4
  155. package/src/api/payments/providers/PaymentProvider.ts +25 -9
  156. package/src/api/payments/services/PaymentService.ts +3 -0
  157. package/src/api/subscriptions/__tests__/BillingService.spec.ts +218 -0
  158. package/src/api/subscriptions/__tests__/SubscriptionService.spec.ts +278 -0
  159. package/src/api/subscriptions/controllers/AdminSubscriptionController.ts +212 -0
  160. package/src/api/subscriptions/controllers/SubscriptionController.ts +189 -0
  161. package/src/api/subscriptions/entities/subscriptionEvents.ts +54 -0
  162. package/src/api/subscriptions/entities/subscriptions.ts +68 -0
  163. package/src/api/subscriptions/index.ts +133 -0
  164. package/src/api/subscriptions/jobs/SubscriptionJobs.ts +382 -0
  165. package/src/api/subscriptions/middleware/$requireLimit.ts +50 -0
  166. package/src/api/subscriptions/middleware/$requirePlan.ts +49 -0
  167. package/src/api/subscriptions/notifications/SubscriptionNotifications.ts +110 -0
  168. package/src/api/subscriptions/schemas/cancelSubscriptionSchema.ts +8 -0
  169. package/src/api/subscriptions/schemas/changePlanSchema.ts +9 -0
  170. package/src/api/subscriptions/schemas/createSubscriptionSchema.ts +11 -0
  171. package/src/api/subscriptions/schemas/entitlementsSchema.ts +21 -0
  172. package/src/api/subscriptions/schemas/mrrSchema.ts +13 -0
  173. package/src/api/subscriptions/schemas/planDefinitionSchema.ts +71 -0
  174. package/src/api/subscriptions/schemas/planResourceSchema.ts +25 -0
  175. package/src/api/subscriptions/schemas/subscriptionEventResourceSchema.ts +8 -0
  176. package/src/api/subscriptions/schemas/subscriptionQuerySchema.ts +19 -0
  177. package/src/api/subscriptions/schemas/subscriptionResourceSchema.ts +6 -0
  178. package/src/api/subscriptions/schemas/subscriptionSettingsSchema.ts +32 -0
  179. package/src/api/subscriptions/schemas/subscriptionStatsSchema.ts +23 -0
  180. package/src/api/subscriptions/services/BillingService.ts +437 -0
  181. package/src/api/subscriptions/services/SubscriptionConfig.ts +56 -0
  182. package/src/api/subscriptions/services/SubscriptionService.ts +867 -0
  183. package/src/api/subscriptions/services/UsageService.ts +118 -0
  184. package/src/cache/core/__tests__/$cache.memory.spec.ts +450 -0
  185. package/src/cache/core/__tests__/$cache.swr.spec.ts +394 -0
  186. package/src/cache/core/index.ts +16 -0
  187. package/src/cache/core/primitives/$cache.ts +347 -21
  188. package/src/cli/core/tasks/BuildCloudflareTask.ts +16 -0
  189. package/src/cli/core/templates/agentMd.ts +39 -4
  190. package/src/cli/core/templates/biomeJson.ts +25 -1
  191. package/src/cli/core/templates/saasAdminLayoutTsx.ts +2 -2
  192. package/src/cli/platform/__tests__/CloudflareAdapter.spec.ts +117 -0
  193. package/src/cli/platform/adapters/CloudflareAdapter.ts +104 -7
  194. package/src/cli/platform/atoms/platformOptions.ts +13 -0
  195. package/src/cli/platform/schemas/platform.ts +1 -0
  196. package/src/cli/platform/services/CloudflareApi.ts +61 -0
  197. package/src/cli/platform/services/PlatformOrchestrator.ts +9 -4
  198. package/src/core/__tests__/$module.spec.ts +2 -2
  199. package/src/core/primitives/$module.ts +4 -4
  200. package/src/mcp/providers/McpServerProvider.ts +1 -1
  201. package/src/orm/core/providers/DatabaseTypeProvider.ts +9 -3
  202. package/src/orm/core/providers/drivers/DatabaseProvider.ts +1 -1
  203. package/src/orm/core/schemas/insertSchema.ts +10 -2
  204. package/src/orm/core/services/Repository.ts +27 -7
  205. package/src/react/form/hooks/useFormState.ts +8 -1
  206. package/src/react/form/index.ts +10 -1
  207. package/src/react/form/services/FormModel.ts +9 -3
  208. package/src/security/atoms/currentTenantAtom.ts +34 -0
  209. package/src/security/index.browser.ts +1 -0
  210. package/src/security/index.ts +12 -1
  211. package/src/security/primitives/$issuer.ts +17 -1
  212. package/src/security/providers/SecurityProvider.ts +37 -0
  213. package/src/server/auth/__tests__/validateRedirectUri.spec.ts +78 -0
  214. package/src/server/auth/providers/ServerAuthProvider.ts +21 -5
  215. package/tsconfig.base.json +2 -1
  216. package/dist/react/websocket/index.d.ts +0 -117
  217. package/dist/react/websocket/index.d.ts.map +0 -1
  218. package/dist/react/websocket/index.js +0 -108
  219. package/dist/react/websocket/index.js.map +0 -1
  220. package/dist/websocket/index.browser.js +0 -848
  221. package/dist/websocket/index.browser.js.map +0 -1
  222. package/dist/websocket/index.d.ts +0 -876
  223. package/dist/websocket/index.d.ts.map +0 -1
  224. package/dist/websocket/index.js +0 -1185
  225. package/dist/websocket/index.js.map +0 -1
  226. package/src/react/websocket/hooks/useRoom.tsx +0 -251
  227. package/src/react/websocket/index.ts +0 -7
  228. package/src/websocket/__tests__/$channel.spec.ts +0 -30
  229. package/src/websocket/__tests__/$websocket-new.spec.ts +0 -195
  230. package/src/websocket/__tests__/RoomManager.spec.ts +0 -146
  231. package/src/websocket/__tests__/websocket-integration.spec.ts +0 -951
  232. package/src/websocket/errors/WebSocketError.ts +0 -34
  233. package/src/websocket/index.browser.ts +0 -25
  234. package/src/websocket/index.shared.ts +0 -8
  235. package/src/websocket/index.ts +0 -85
  236. package/src/websocket/interfaces/WebSocketInterfaces.ts +0 -252
  237. package/src/websocket/primitives/$channel.ts +0 -131
  238. package/src/websocket/primitives/$websocket.ts +0 -107
  239. package/src/websocket/providers/NodeWebSocketServerProvider.ts +0 -617
  240. package/src/websocket/providers/WebSocketServerProvider.ts +0 -56
  241. package/src/websocket/services/RoomManager.ts +0 -160
  242. package/src/websocket/services/WebSocketClient.ts +0 -642
  243. package/src/websocket/services/WebSocketTopicService.ts +0 -108
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":["ICronDefinition","Set","seconds","minutes","hours","days","months","weekdays","Cron","ReadonlyArray","Date","Generator","reversed","constructor","findAllowedHour","findAllowedMinute","findAllowedSecond","findAllowedTime","findAllowedDayInMonth","getNextDate","startDate","getNextDates","amount","getNextDatesIterator","endDate","getPrevDate","getPrevDates","getPrevDatesIterator","matchDate","date"],"sources":["../../src/scheduler/constants/CRON.ts","../../../../node_modules/cron-schedule/dist/cron.d.ts","../../src/scheduler/providers/CronProvider.ts","../../src/scheduler/primitives/$scheduler.ts","../../src/scheduler/providers/WorkerdCronProvider.ts","../../src/scheduler/index.ts"],"x_google_ignoreList":[1],"mappings":";;;;;;cAAa,IAAA;;;;;;;;;;;;;;UCIIA,eAAAA;EAAAA,SACJE,OAAAA,EAASD,GAA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,MAAe,OAAA;EHzCtBH;;;EAAAA,mBGuDF,gBAAA,EAd+B,QAAA,CAcf,aAAA;AAAA;;;;YCjDzB,KAAA;IACR,iBAAA;MACE,IAAA;MACA,GAAA,EAAK,QAAA;MACL,OAAA;IAAA;IAGF,mBAAA;MAAuB,IAAA;MAAc,OAAA;IAAA;IAErC,iBAAA;MACE,IAAA;MACA,KAAA,EAAO,KAAA;MACP,OAAA;IAAA;IAGF,eAAA;MAAmB,IAAA;MAAc,OAAA;IAAA;IJzBfA;;;;;;;;;;;;IIuClB,iBAAA;MAAqB,IAAA;IAAA;EAAA;AAAA;;;;;AJjCzB;;;;;;;cIkDa,eAAA,EAAe,QAAA,CAAA,OAAA,CAI1B,QAAA,CAJ0B,MAAA"}
1
+ {"version":3,"file":"index.d.ts","names":["ICronDefinition","Set","seconds","minutes","hours","days","months","weekdays","Cron","ReadonlyArray","Date","Generator","reversed","constructor","findAllowedHour","findAllowedMinute","findAllowedSecond","findAllowedTime","findAllowedDayInMonth","getNextDate","startDate","getNextDates","amount","getNextDatesIterator","endDate","getPrevDate","getPrevDates","getPrevDatesIterator","matchDate","date"],"sources":["../../src/scheduler/constants/CRON.ts","../../../../node_modules/cron-schedule/dist/cron.d.ts","../../src/scheduler/providers/CronProvider.ts","../../src/scheduler/primitives/$scheduler.ts","../../src/scheduler/providers/WorkerdCronProvider.ts","../../src/scheduler/index.ts"],"x_google_ignoreList":[1],"mappings":";;;;;;;cAAa,IAAA;;;;;;;;;;;;;;UCIIA,eAAAA;EAAAA,SACJE,OAAAA,EAASD,GAAAA;EAAAA,SACTE,OAAAA,EAASF,GAAAA;EAAAA,SACTG,KAAAA,EAAOH,GAAAA;EAAAA,SACPI,IAAAA,EAAMJ,GAAAA;EAAAA,SACNK,MAAAA,EAAQL,GAAAA;EAAAA,SACRM,QAAAA,EAAUN,GAAAA;AAAAA;AAAAA,cAEFO,IAAAA;EAAAA,SACRN,OAAAA,EAASO,aAAAA;EAAAA,SACTN,OAAAA,EAAS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AAA;IAAA;IAGF,eAAA;MAAmB,IAAA;MAAc,OAAA;IAAA;IJ1BfN;;;;;;;;;;;;IIwClB,iBAAA;MAAqB,IAAA;IAAA;EAAA;AAAA;;;;;;AJjCzB;;;;;;cIkDa,eAAA,EAAe,QAAA,CAAA,OAAA,CAI1B,QAAA,CAJ0B,MAAA"}
@@ -1,5 +1,33 @@
1
1
  import { $atom, $module, createMiddleware, t } from "alepha";
2
2
  import { UnauthorizedError } from "alepha/server";
3
+ //#region ../../src/security/atoms/currentTenantAtom.ts
4
+ /**
5
+ * Atom storing the active tenant for the current request.
6
+ *
7
+ * Transport-agnostic — works with HTTP, MCP, pipelines, jobs, and any context
8
+ * that sets the atom before calling tenant-scoped logic.
9
+ *
10
+ * Typically set by an app-level middleware that resolves the tenant from the
11
+ * request `Host` header (or another signal) and writes the resolved id to the
12
+ * store. Framework code that reads this atom:
13
+ *
14
+ * - Repository scoping: `withOrganization` / `stampOrganization` prefer this
15
+ * value over `currentUserAtom.organization` so cross-tenant users (admins,
16
+ * agency operators) are scoped to the tenant they are currently acting in
17
+ * rather than the one they belong to.
18
+ * - Session creation: the value is persisted into the JWT as a `tenant` claim,
19
+ * and the issuer resolver rejects tokens whose claim does not match the
20
+ * tenant resolved from the current request.
21
+ *
22
+ * `id` is a free-form string so the framework stays neutral on tenant identity
23
+ * (slug, UUID, composite). Pick whatever matches the column marked with
24
+ * `PG_ORGANIZATION` in your entities.
25
+ */
26
+ const currentTenantAtom = $atom({
27
+ name: "alepha.security.tenant",
28
+ schema: t.optional(t.object({ id: t.text({ description: "Tenant identifier (slug, UUID, or composite)." }) }))
29
+ });
30
+ //#endregion
3
31
  //#region ../../src/security/schemas/userAccountInfoSchema.ts
4
32
  const userAccountInfoSchema = t.object({
5
33
  id: t.text({ description: "Unique identifier for the user." }),
@@ -127,6 +155,6 @@ const roleSchema = t.object({
127
155
  //#region ../../src/security/index.browser.ts
128
156
  const AlephaSecurity = $module({ name: "alepha.security" });
129
157
  //#endregion
130
- export { $secure, AlephaSecurity, InvalidCredentialsError, InvalidPermissionError, SecurityError, currentUserAtom, permissionSchema, roleSchema, userAccountInfoSchema };
158
+ export { $secure, AlephaSecurity, InvalidCredentialsError, InvalidPermissionError, SecurityError, currentTenantAtom, currentUserAtom, permissionSchema, roleSchema, userAccountInfoSchema };
131
159
 
132
160
  //# sourceMappingURL=index.browser.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.browser.js","names":[],"sources":["../../src/security/schemas/userAccountInfoSchema.ts","../../src/security/atoms/currentUserAtom.ts","../../src/security/errors/InvalidCredentialsError.ts","../../src/security/errors/InvalidPermissionError.ts","../../src/security/errors/SecurityError.ts","../../src/security/primitives/$secure.browser.ts","../../src/security/schemas/permissionSchema.ts","../../src/security/schemas/roleSchema.ts","../../src/security/index.browser.ts"],"sourcesContent":["import type { Static } from \"alepha\";\nimport { t } from \"alepha\";\n\nexport const userAccountInfoSchema = t.object({\n id: t.text({\n description: \"Unique identifier for the user.\",\n }),\n\n name: t.optional(\n t.text({\n description: \"Full name of the user.\",\n }),\n ),\n\n email: t.optional(\n t.text({\n description: \"Email address of the user.\",\n format: \"email\",\n }),\n ),\n\n username: t.optional(\n t.text({\n description: \"Preferred username of the user.\",\n }),\n ),\n\n picture: t.optional(\n t.text({\n description: \"URL to the user's profile picture.\",\n }),\n ),\n\n sessionId: t.optional(\n t.text({\n description: \"Session identifier for the user, if applicable.\",\n }),\n ),\n\n // -------------------------------------------------------------------------------------------------------------------\n\n organization: t.optional(\n t.uuid({\n description: \"Organization the user belongs to.\",\n }),\n ),\n\n roles: t.optional(\n t.array(t.text(), {\n description: \"List of roles assigned to the user.\",\n }),\n ),\n\n realm: t.optional(\n t.text({\n description: \"The realm (issuer) the user was authenticated from.\",\n }),\n ),\n});\n\nexport type UserAccount = Static<typeof userAccountInfoSchema>;\n","import { $atom, t } from \"alepha\";\nimport { userAccountInfoSchema } from \"../schemas/userAccountInfoSchema.ts\";\n\n/**\n * Atom storing the current authenticated user.\n *\n * Transport-agnostic — works with HTTP, MCP, pipelines, jobs, and any context\n * that sets the atom before calling secured logic.\n */\nexport const currentUserAtom = $atom({\n name: \"alepha.security.user\",\n schema: t.optional(userAccountInfoSchema),\n});\n","import { UnauthorizedError } from \"alepha/server\";\n\n/**\n * Error thrown when the provided credentials are invalid.\n *\n * Message can not be changed to avoid leaking information.\n * Cause is omitted for the same reason.\n */\nexport class InvalidCredentialsError extends UnauthorizedError {\n readonly name = \"UnauthorizedError\";\n constructor() {\n super(\"Invalid credentials\");\n }\n}\n","export class InvalidPermissionError extends Error {\n constructor(name: string) {\n super(`Permission '${name}' is invalid`);\n }\n}\n","export class SecurityError extends Error {\n public name = \"SecurityError\";\n public readonly status = 403;\n}\n","import { createMiddleware, type Middleware } from \"alepha\";\nimport { currentUserAtom } from \"../atoms/currentUserAtom.ts\";\nimport type { UserAccountToken } from \"../interfaces/UserAccountToken.ts\";\nimport type { SecureOptions } from \"./$secure.ts\";\n\nexport type { SecureOptions };\n\n/**\n * Browser-side middleware that enforces authentication and authorization.\n *\n * Resolves the user from `currentUserAtom` only (no HTTP header resolution).\n * Checks roles from the user object and permissions from the user's roles.\n *\n * In the browser, an unauthenticated or unauthorized user is not an exception —\n * the middleware short-circuits by returning `undefined` and the handler is not called.\n * Components should use `action.can()` to conditionally render UI elements.\n *\n * ```typescript\n * class OrderController {\n * getOrders = $action({\n * use: [$secure()],\n * handler: async ({ query }) => { ... },\n * });\n *\n * deleteOrder = $action({\n * use: [$secure({ permissions: [\"orders:delete\"] })],\n * handler: async ({ params }) => { ... },\n * });\n * }\n * ```\n */\nexport function $secure(options?: SecureOptions): Middleware {\n return createMiddleware({\n name: \"$secure\",\n options: (options as unknown as Record<string, unknown>) ?? undefined,\n handler: ({ alepha, next }) => {\n return async (...args: any[]) => {\n const user: UserAccountToken | undefined =\n alepha.store.get(currentUserAtom);\n\n if (!user) {\n return undefined;\n }\n\n // Issuer check\n if (options?.issuers?.length) {\n if (!user.realm || !options.issuers.includes(user.realm)) {\n return undefined;\n }\n }\n\n // Role check\n if (options?.roles?.length) {\n const hasRole = options.roles.some((role) =>\n user.roles?.includes(role),\n );\n if (!hasRole) {\n return undefined;\n }\n }\n\n // Permission check (browser-side: check against user roles)\n // Server-side permissions are enforced by the API — the browser version\n // trusts that the API registry already filtered actions by permission.\n\n // Custom guard\n if (options?.guard) {\n if (!options.guard(user)) {\n return undefined;\n }\n }\n\n return next(...args);\n };\n },\n });\n}\n","import type { Static } from \"alepha\";\nimport { t } from \"alepha\";\n\nexport const permissionSchema = t.object({\n name: t.text({\n description: \"Name of the permission.\",\n }),\n\n group: t.optional(\n t.text({\n description: \"Group of the permission.\",\n }),\n ),\n\n description: t.optional(\n t.text({\n description: \"Describe the permission.\",\n }),\n ),\n\n // HTTP Only\n\n method: t.optional(\n t.text({\n description: \"HTTP method of the permission. When available.\",\n }),\n ),\n\n path: t.optional(\n t.text({\n description: \"Pathname of the permission. When available.\",\n }),\n ),\n});\n\nexport type Permission = Static<typeof permissionSchema>;\n","import type { Static } from \"alepha\";\nimport { t } from \"alepha\";\n\nexport const roleSchema = t.object({\n name: t.text({\n description: \"Name of the role.\",\n }),\n\n description: t.optional(\n t.text({\n description: \"Describe the role.\",\n }),\n ),\n\n default: t.optional(\n t.boolean({\n description:\n \"If true, this role will be assigned to all users by default.\",\n }),\n ),\n\n permissions: t.array(\n t.object({\n name: t.text({\n description: \"Name of the permission.\",\n }),\n ownership: t.optional(\n t.boolean({\n description:\n \"If true, user will only have access to it's own resources.\",\n }),\n ),\n exclude: t.optional(\n t.array(t.text(), {\n description:\n \"Exclude some permissions. Useful when 'name' is a wildcard.\",\n }),\n ),\n }),\n ),\n});\n\nexport type Role = Static<typeof roleSchema>;\n","import { $module } from \"alepha\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport * from \"./atoms/currentUserAtom.ts\";\nexport * from \"./errors/InvalidCredentialsError.ts\";\nexport * from \"./errors/InvalidPermissionError.ts\";\nexport * from \"./errors/SecurityError.ts\";\nexport * from \"./interfaces/UserAccountToken.ts\";\nexport * from \"./primitives/$secure.browser.ts\";\nexport * from \"./schemas/permissionSchema.ts\";\nexport * from \"./schemas/roleSchema.ts\";\nexport * from \"./schemas/userAccountInfoSchema.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport const AlephaSecurity = $module({\n name: \"alepha.security\",\n});\n"],"mappings":";;;AAGA,MAAa,wBAAwB,EAAE,OAAO;CAC5C,IAAI,EAAE,KAAK,EACT,aAAa,mCACd,CAAC;CAEF,MAAM,EAAE,SACN,EAAE,KAAK,EACL,aAAa,0BACd,CAAC,CACH;CAED,OAAO,EAAE,SACP,EAAE,KAAK;EACL,aAAa;EACb,QAAQ;EACT,CAAC,CACH;CAED,UAAU,EAAE,SACV,EAAE,KAAK,EACL,aAAa,mCACd,CAAC,CACH;CAED,SAAS,EAAE,SACT,EAAE,KAAK,EACL,aAAa,sCACd,CAAC,CACH;CAED,WAAW,EAAE,SACX,EAAE,KAAK,EACL,aAAa,mDACd,CAAC,CACH;CAID,cAAc,EAAE,SACd,EAAE,KAAK,EACL,aAAa,qCACd,CAAC,CACH;CAED,OAAO,EAAE,SACP,EAAE,MAAM,EAAE,MAAM,EAAE,EAChB,aAAa,uCACd,CAAC,CACH;CAED,OAAO,EAAE,SACP,EAAE,KAAK,EACL,aAAa,uDACd,CAAC,CACH;CACF,CAAC;;;;;;;;;ACjDF,MAAa,kBAAkB,MAAM;CACnC,MAAM;CACN,QAAQ,EAAE,SAAS,sBAAsB;CAC1C,CAAC;;;;;;;;;ACJF,IAAa,0BAAb,cAA6C,kBAAkB;CAC7D,OAAgB;CAChB,cAAc;EACZ,MAAM,sBAAsB;;;;;ACXhC,IAAa,yBAAb,cAA4C,MAAM;CAChD,YAAY,MAAc;EACxB,MAAM,eAAe,KAAK,cAAc;;;;;ACF5C,IAAa,gBAAb,cAAmC,MAAM;CACvC,OAAc;CACd,SAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC6B3B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,EAAE,MAAM,EAAE,EAChB,aACE,+DACH,CAAC,CACH;EACF,CAAC,CACH;CACF,CAAC;;;ACxBF,MAAa,iBAAiB,QAAQ,EACpC,MAAM,mBACP,CAAC"}
1
+ {"version":3,"file":"index.browser.js","names":[],"sources":["../../src/security/atoms/currentTenantAtom.ts","../../src/security/schemas/userAccountInfoSchema.ts","../../src/security/atoms/currentUserAtom.ts","../../src/security/errors/InvalidCredentialsError.ts","../../src/security/errors/InvalidPermissionError.ts","../../src/security/errors/SecurityError.ts","../../src/security/primitives/$secure.browser.ts","../../src/security/schemas/permissionSchema.ts","../../src/security/schemas/roleSchema.ts","../../src/security/index.browser.ts"],"sourcesContent":["import { $atom, t } from \"alepha\";\n\n/**\n * Atom storing the active tenant for the current request.\n *\n * Transport-agnostic — works with HTTP, MCP, pipelines, jobs, and any context\n * that sets the atom before calling tenant-scoped logic.\n *\n * Typically set by an app-level middleware that resolves the tenant from the\n * request `Host` header (or another signal) and writes the resolved id to the\n * store. Framework code that reads this atom:\n *\n * - Repository scoping: `withOrganization` / `stampOrganization` prefer this\n * value over `currentUserAtom.organization` so cross-tenant users (admins,\n * agency operators) are scoped to the tenant they are currently acting in\n * rather than the one they belong to.\n * - Session creation: the value is persisted into the JWT as a `tenant` claim,\n * and the issuer resolver rejects tokens whose claim does not match the\n * tenant resolved from the current request.\n *\n * `id` is a free-form string so the framework stays neutral on tenant identity\n * (slug, UUID, composite). Pick whatever matches the column marked with\n * `PG_ORGANIZATION` in your entities.\n */\nexport const currentTenantAtom = $atom({\n name: \"alepha.security.tenant\",\n schema: t.optional(\n t.object({\n id: t.text({\n description: \"Tenant identifier (slug, UUID, or composite).\",\n }),\n }),\n ),\n});\n","import type { Static } from \"alepha\";\nimport { t } from \"alepha\";\n\nexport const userAccountInfoSchema = t.object({\n id: t.text({\n description: \"Unique identifier for the user.\",\n }),\n\n name: t.optional(\n t.text({\n description: \"Full name of the user.\",\n }),\n ),\n\n email: t.optional(\n t.text({\n description: \"Email address of the user.\",\n format: \"email\",\n }),\n ),\n\n username: t.optional(\n t.text({\n description: \"Preferred username of the user.\",\n }),\n ),\n\n picture: t.optional(\n t.text({\n description: \"URL to the user's profile picture.\",\n }),\n ),\n\n sessionId: t.optional(\n t.text({\n description: \"Session identifier for the user, if applicable.\",\n }),\n ),\n\n // -------------------------------------------------------------------------------------------------------------------\n\n organization: t.optional(\n t.uuid({\n description: \"Organization the user belongs to.\",\n }),\n ),\n\n roles: t.optional(\n t.array(t.text(), {\n description: \"List of roles assigned to the user.\",\n }),\n ),\n\n realm: t.optional(\n t.text({\n description: \"The realm (issuer) the user was authenticated from.\",\n }),\n ),\n});\n\nexport type UserAccount = Static<typeof userAccountInfoSchema>;\n","import { $atom, t } from \"alepha\";\nimport { userAccountInfoSchema } from \"../schemas/userAccountInfoSchema.ts\";\n\n/**\n * Atom storing the current authenticated user.\n *\n * Transport-agnostic — works with HTTP, MCP, pipelines, jobs, and any context\n * that sets the atom before calling secured logic.\n */\nexport const currentUserAtom = $atom({\n name: \"alepha.security.user\",\n schema: t.optional(userAccountInfoSchema),\n});\n","import { UnauthorizedError } from \"alepha/server\";\n\n/**\n * Error thrown when the provided credentials are invalid.\n *\n * Message can not be changed to avoid leaking information.\n * Cause is omitted for the same reason.\n */\nexport class InvalidCredentialsError extends UnauthorizedError {\n readonly name = \"UnauthorizedError\";\n constructor() {\n super(\"Invalid credentials\");\n }\n}\n","export class InvalidPermissionError extends Error {\n constructor(name: string) {\n super(`Permission '${name}' is invalid`);\n }\n}\n","export class SecurityError extends Error {\n public name = \"SecurityError\";\n public readonly status = 403;\n}\n","import { createMiddleware, type Middleware } from \"alepha\";\nimport { currentUserAtom } from \"../atoms/currentUserAtom.ts\";\nimport type { UserAccountToken } from \"../interfaces/UserAccountToken.ts\";\nimport type { SecureOptions } from \"./$secure.ts\";\n\nexport type { SecureOptions };\n\n/**\n * Browser-side middleware that enforces authentication and authorization.\n *\n * Resolves the user from `currentUserAtom` only (no HTTP header resolution).\n * Checks roles from the user object and permissions from the user's roles.\n *\n * In the browser, an unauthenticated or unauthorized user is not an exception —\n * the middleware short-circuits by returning `undefined` and the handler is not called.\n * Components should use `action.can()` to conditionally render UI elements.\n *\n * ```typescript\n * class OrderController {\n * getOrders = $action({\n * use: [$secure()],\n * handler: async ({ query }) => { ... },\n * });\n *\n * deleteOrder = $action({\n * use: [$secure({ permissions: [\"orders:delete\"] })],\n * handler: async ({ params }) => { ... },\n * });\n * }\n * ```\n */\nexport function $secure(options?: SecureOptions): Middleware {\n return createMiddleware({\n name: \"$secure\",\n options: (options as unknown as Record<string, unknown>) ?? undefined,\n handler: ({ alepha, next }) => {\n return async (...args: any[]) => {\n const user: UserAccountToken | undefined =\n alepha.store.get(currentUserAtom);\n\n if (!user) {\n return undefined;\n }\n\n // Issuer check\n if (options?.issuers?.length) {\n if (!user.realm || !options.issuers.includes(user.realm)) {\n return undefined;\n }\n }\n\n // Role check\n if (options?.roles?.length) {\n const hasRole = options.roles.some((role) =>\n user.roles?.includes(role),\n );\n if (!hasRole) {\n return undefined;\n }\n }\n\n // Permission check (browser-side: check against user roles)\n // Server-side permissions are enforced by the API — the browser version\n // trusts that the API registry already filtered actions by permission.\n\n // Custom guard\n if (options?.guard) {\n if (!options.guard(user)) {\n return undefined;\n }\n }\n\n return next(...args);\n };\n },\n });\n}\n","import type { Static } from \"alepha\";\nimport { t } from \"alepha\";\n\nexport const permissionSchema = t.object({\n name: t.text({\n description: \"Name of the permission.\",\n }),\n\n group: t.optional(\n t.text({\n description: \"Group of the permission.\",\n }),\n ),\n\n description: t.optional(\n t.text({\n description: \"Describe the permission.\",\n }),\n ),\n\n // HTTP Only\n\n method: t.optional(\n t.text({\n description: \"HTTP method of the permission. When available.\",\n }),\n ),\n\n path: t.optional(\n t.text({\n description: \"Pathname of the permission. When available.\",\n }),\n ),\n});\n\nexport type Permission = Static<typeof permissionSchema>;\n","import type { Static } from \"alepha\";\nimport { t } from \"alepha\";\n\nexport const roleSchema = t.object({\n name: t.text({\n description: \"Name of the role.\",\n }),\n\n description: t.optional(\n t.text({\n description: \"Describe the role.\",\n }),\n ),\n\n default: t.optional(\n t.boolean({\n description:\n \"If true, this role will be assigned to all users by default.\",\n }),\n ),\n\n permissions: t.array(\n t.object({\n name: t.text({\n description: \"Name of the permission.\",\n }),\n ownership: t.optional(\n t.boolean({\n description:\n \"If true, user will only have access to it's own resources.\",\n }),\n ),\n exclude: t.optional(\n t.array(t.text(), {\n description:\n \"Exclude some permissions. Useful when 'name' is a wildcard.\",\n }),\n ),\n }),\n ),\n});\n\nexport type Role = Static<typeof roleSchema>;\n","import { $module } from \"alepha\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport * from \"./atoms/currentTenantAtom.ts\";\nexport * from \"./atoms/currentUserAtom.ts\";\nexport * from \"./errors/InvalidCredentialsError.ts\";\nexport * from \"./errors/InvalidPermissionError.ts\";\nexport * from \"./errors/SecurityError.ts\";\nexport * from \"./interfaces/UserAccountToken.ts\";\nexport * from \"./primitives/$secure.browser.ts\";\nexport * from \"./schemas/permissionSchema.ts\";\nexport * from \"./schemas/roleSchema.ts\";\nexport * from \"./schemas/userAccountInfoSchema.ts\";\n\n// ---------------------------------------------------------------------------------------------------------------------\n\nexport const AlephaSecurity = $module({\n name: \"alepha.security\",\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAa,oBAAoB,MAAM;CACrC,MAAM;CACN,QAAQ,EAAE,SACR,EAAE,OAAO,EACP,IAAI,EAAE,KAAK,EACT,aAAa,iDACd,CAAC,EACH,CAAC,CACH;CACF,CAAC;;;AC9BF,MAAa,wBAAwB,EAAE,OAAO;CAC5C,IAAI,EAAE,KAAK,EACT,aAAa,mCACd,CAAC;CAEF,MAAM,EAAE,SACN,EAAE,KAAK,EACL,aAAa,0BACd,CAAC,CACH;CAED,OAAO,EAAE,SACP,EAAE,KAAK;EACL,aAAa;EACb,QAAQ;EACT,CAAC,CACH;CAED,UAAU,EAAE,SACV,EAAE,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G,KAAK;;;EAGzB,CAAC;;;;ACxEJ,MAAa,mBAAmB,EAAE,OAAO;CACvC,MAAM,EAAE,KAAK,EACX,aAAa,2BACd,CAAC;CAEF,OAAO,EAAE,SACP,EAAE,KAAK,EACL,aAAa,4BACd,CAAC,CACH;CAED,aAAa,EAAE,SACb,EAAE,KAAK,EACL,aAAa,4BACd,CAAC,CACH;CAID,QAAQ,EAAE,SACR,EAAE,KAAK,EACL,aAAa,kDACd,CAAC,CACH;CAED,MAAM,EAAE,SACN,EAAE,KAAK,EACL,aAAa,+CACd,CAAC,CACH;CACF,CAAC;;;AC9BF,MAAa,aAAa,EAAE,OAAO;CACjC,MAAM,EAAE,KAAK,EACX,aAAa,qBACd,CAAC;CAEF,aAAa,EAAE,SACb,EAAE,KAAK,EACL,aAAa,sBACd,CAAC,CACH;CAED,SAAS,EAAE,SACT,EAAE,QAAQ,EACR,aACE,gEACH,CAAC,CACH;CAED,aAAa,EAAE,MACb,EAAE,OAAO;EACP,MAAM,EAAE,KAAK,EACX,aAAa,2BACd,CAAC;EACF,WAAW,EAAE,SACX,EAAE,QAAQ,EACR,aACE,8DACH,CAAC,CACH;EACD,SAAS,EAAE,SACT,EAAE,MAAM,EAAE,MAAM,EAAE,EAChB,aACE,+DACH,CAAC,CACH;EACF,CAAC,CACH;CACF,CAAC;;;ACvBF,MAAa,iBAAiB,QAAQ,EACpC,MAAM,mBACP,CAAC"}
@@ -4,19 +4,20 @@ import { DateTimeProvider, Duration, DurationLike } from "alepha/datetime";
4
4
  import * as _$alepha_logger0 from "alepha/logger";
5
5
  import { SecretProvider } from "alepha/crypto";
6
6
  import { FetchOptions, ServerRequest, UnauthorizedError } from "alepha/server";
7
+ import * as _$typebox from "typebox";
7
8
  export * from "alepha/crypto";
8
9
 
9
10
  //#region ../../src/security/schemas/userAccountInfoSchema.d.ts
10
- declare const userAccountInfoSchema: _$alepha.TObject<{
11
- id: _$alepha.TString;
12
- name: _$alepha.TOptional<_$alepha.TString>;
13
- email: _$alepha.TOptional<_$alepha.TString>;
14
- username: _$alepha.TOptional<_$alepha.TString>;
15
- picture: _$alepha.TOptional<_$alepha.TString>;
16
- sessionId: _$alepha.TOptional<_$alepha.TString>;
17
- organization: _$alepha.TOptional<_$alepha.TString>;
18
- roles: _$alepha.TOptional<_$alepha.TArray<_$alepha.TString>>;
19
- realm: _$alepha.TOptional<_$alepha.TString>;
11
+ declare const userAccountInfoSchema: _$typebox.TObject<{
12
+ id: _$typebox.TString;
13
+ name: _$typebox.TOptional<_$typebox.TString>;
14
+ email: _$typebox.TOptional<_$typebox.TString>;
15
+ username: _$typebox.TOptional<_$typebox.TString>;
16
+ picture: _$typebox.TOptional<_$typebox.TString>;
17
+ sessionId: _$typebox.TOptional<_$typebox.TString>;
18
+ organization: _$typebox.TOptional<_$typebox.TString>;
19
+ roles: _$typebox.TOptional<_$typebox.TArray<_$typebox.TString>>;
20
+ realm: _$typebox.TOptional<_$typebox.TString>;
20
21
  }>;
21
22
  type UserAccount = Static<typeof userAccountInfoSchema>;
22
23
  //#endregion
@@ -41,6 +42,33 @@ interface UserAccountToken extends UserAccount {
41
42
  ownership?: string | boolean;
42
43
  }
43
44
  //#endregion
45
+ //#region ../../src/security/atoms/currentTenantAtom.d.ts
46
+ /**
47
+ * Atom storing the active tenant for the current request.
48
+ *
49
+ * Transport-agnostic — works with HTTP, MCP, pipelines, jobs, and any context
50
+ * that sets the atom before calling tenant-scoped logic.
51
+ *
52
+ * Typically set by an app-level middleware that resolves the tenant from the
53
+ * request `Host` header (or another signal) and writes the resolved id to the
54
+ * store. Framework code that reads this atom:
55
+ *
56
+ * - Repository scoping: `withOrganization` / `stampOrganization` prefer this
57
+ * value over `currentUserAtom.organization` so cross-tenant users (admins,
58
+ * agency operators) are scoped to the tenant they are currently acting in
59
+ * rather than the one they belong to.
60
+ * - Session creation: the value is persisted into the JWT as a `tenant` claim,
61
+ * and the issuer resolver rejects tokens whose claim does not match the
62
+ * tenant resolved from the current request.
63
+ *
64
+ * `id` is a free-form string so the framework stays neutral on tenant identity
65
+ * (slug, UUID, composite). Pick whatever matches the column marked with
66
+ * `PG_ORGANIZATION` in your entities.
67
+ */
68
+ declare const currentTenantAtom: _$alepha.Atom<_$typebox.TOptional<_$typebox.TObject<{
69
+ id: _$typebox.TString;
70
+ }>>, "alepha.security.tenant">;
71
+ //#endregion
44
72
  //#region ../../src/security/atoms/currentUserAtom.d.ts
45
73
  /**
46
74
  * Atom storing the current authenticated user.
@@ -48,16 +76,16 @@ interface UserAccountToken extends UserAccount {
48
76
  * Transport-agnostic — works with HTTP, MCP, pipelines, jobs, and any context
49
77
  * that sets the atom before calling secured logic.
50
78
  */
51
- declare const currentUserAtom: _$alepha.Atom<_$alepha.TOptional<_$alepha.TObject<{
52
- id: _$alepha.TString;
53
- name: _$alepha.TOptional<_$alepha.TString>;
54
- email: _$alepha.TOptional<_$alepha.TString>;
55
- username: _$alepha.TOptional<_$alepha.TString>;
56
- picture: _$alepha.TOptional<_$alepha.TString>;
57
- sessionId: _$alepha.TOptional<_$alepha.TString>;
58
- organization: _$alepha.TOptional<_$alepha.TString>;
59
- roles: _$alepha.TOptional<_$alepha.TArray<_$alepha.TString>>;
60
- realm: _$alepha.TOptional<_$alepha.TString>;
79
+ declare const currentUserAtom: _$alepha.Atom<_$typebox.TOptional<_$typebox.TObject<{
80
+ id: _$typebox.TString;
81
+ name: _$typebox.TOptional<_$typebox.TString>;
82
+ email: _$typebox.TOptional<_$typebox.TString>;
83
+ username: _$typebox.TOptional<_$typebox.TString>;
84
+ picture: _$typebox.TOptional<_$typebox.TString>;
85
+ sessionId: _$typebox.TOptional<_$typebox.TString>;
86
+ organization: _$typebox.TOptional<_$typebox.TString>;
87
+ roles: _$typebox.TOptional<_$typebox.TArray<_$typebox.TString>>;
88
+ realm: _$typebox.TOptional<_$typebox.TString>;
61
89
  }>>, "alepha.security.user">;
62
90
  //#endregion
63
91
  //#region ../../src/security/errors/InvalidCredentialsError.d.ts
@@ -521,24 +549,24 @@ interface JwtParseResult {
521
549
  }
522
550
  //#endregion
523
551
  //#region ../../src/security/schemas/permissionSchema.d.ts
524
- declare const permissionSchema: _$alepha.TObject<{
525
- name: _$alepha.TString;
526
- group: _$alepha.TOptional<_$alepha.TString>;
527
- description: _$alepha.TOptional<_$alepha.TString>;
528
- method: _$alepha.TOptional<_$alepha.TString>;
529
- path: _$alepha.TOptional<_$alepha.TString>;
552
+ declare const permissionSchema: _$typebox.TObject<{
553
+ name: _$typebox.TString;
554
+ group: _$typebox.TOptional<_$typebox.TString>;
555
+ description: _$typebox.TOptional<_$typebox.TString>;
556
+ method: _$typebox.TOptional<_$typebox.TString>;
557
+ path: _$typebox.TOptional<_$typebox.TString>;
530
558
  }>;
531
559
  type Permission = Static<typeof permissionSchema>;
532
560
  //#endregion
533
561
  //#region ../../src/security/schemas/roleSchema.d.ts
534
- declare const roleSchema: _$alepha.TObject<{
535
- name: _$alepha.TString;
536
- description: _$alepha.TOptional<_$alepha.TString>;
537
- default: _$alepha.TOptional<_$alepha.TBoolean>;
538
- permissions: _$alepha.TArray<_$alepha.TObject<{
539
- name: _$alepha.TString;
540
- ownership: _$alepha.TOptional<_$alepha.TBoolean>;
541
- exclude: _$alepha.TOptional<_$alepha.TArray<_$alepha.TString>>;
562
+ declare const roleSchema: _$typebox.TObject<{
563
+ name: _$typebox.TString;
564
+ description: _$typebox.TOptional<_$typebox.TString>;
565
+ default: _$typebox.TOptional<_$typebox.TBoolean>;
566
+ permissions: _$typebox.TArray<_$typebox.TObject<{
567
+ name: _$typebox.TString;
568
+ ownership: _$typebox.TOptional<_$typebox.TBoolean>;
569
+ exclude: _$typebox.TOptional<_$typebox.TArray<_$typebox.TString>>;
542
570
  }>>;
543
571
  }>;
544
572
  type Role = Static<typeof roleSchema>;
@@ -720,6 +748,14 @@ declare class SecurityProvider {
720
748
  */
721
749
  getNameFromPayload(payload: Record<string, any>): string;
722
750
  getOrganizationFromPayload(payload: Record<string, any>): string | undefined;
751
+ /**
752
+ * Extracts the tenant id from the JWT payload, when present.
753
+ *
754
+ * Tokens minted with no active tenant (single-tenant apps, server-to-server
755
+ * calls before any request-scoped middleware runs) omit the claim, in which
756
+ * case the resolver does not enforce a tenant match.
757
+ */
758
+ getTenantFromPayload(payload: Record<string, any>): string | undefined;
723
759
  }
724
760
  /**
725
761
  * A realm definition.
@@ -827,6 +863,7 @@ interface IssuerExternal {
827
863
  jwks: (() => string) | JSONWebKeySet;
828
864
  }
829
865
  declare class IssuerPrimitive extends Primitive<IssuerPrimitiveOptions> {
866
+ protected readonly alepha: Alepha;
830
867
  protected readonly securityProvider: SecurityProvider;
831
868
  protected readonly dateTimeProvider: DateTimeProvider;
832
869
  protected readonly jwt: JwtProvider;
@@ -1124,6 +1161,16 @@ declare module "alepha" {
1124
1161
  * The current authenticated user.
1125
1162
  */
1126
1163
  "alepha.security.user"?: UserAccount;
1164
+ /**
1165
+ * The tenant the current request is acting in.
1166
+ *
1167
+ * Typically set by an app-level middleware from the request `Host`. When
1168
+ * present, `Repository` scoping and session creation prefer this value
1169
+ * over `currentUserAtom.organization`.
1170
+ */
1171
+ "alepha.security.tenant"?: {
1172
+ id: string;
1173
+ };
1127
1174
  }
1128
1175
  }
1129
1176
  declare module "alepha/server" {
@@ -1162,5 +1209,5 @@ declare module "alepha/server" {
1162
1209
  */
1163
1210
  declare const AlephaSecurity: _$alepha.Service<_$alepha.Module>;
1164
1211
  //#endregion
1165
- export { $basicAuth, $issuer, $permission, $role, $secure, $serviceAccount, AccessTokenResponse, AlephaSecurity, BasicAuthOptions, CreateTokenOptions, ExtendedJWTPayload, InvalidCredentialsError, InvalidPermissionError, IssuerExternal, IssuerInternal, IssuerPrimitive, IssuerPrimitiveOptions, IssuerResolver, IssuerSettings, JwtParseResult, JwtProvider, JwtSignOptions, KeyLoader, KeyLoaderHolder, Oauth2ServiceAccountPrimitiveOptions, Permission, PermissionPrimitive, PermissionPrimitiveOptions, Realm, Role, RolePrimitive, RolePrimitiveOptions, SecureOptions, SecurityCheckResult, SecurityError, SecurityProvider, ServerSecurityProvider, ServerSecurityUserResolver, ServiceAccountPrimitive, ServiceAccountPrimitiveOptions, ServiceAccountStore, UserAccount, UserAccountToken, UserInfo, currentUserAtom, permissionSchema, roleSchema, userAccountInfoSchema };
1212
+ export { $basicAuth, $issuer, $permission, $role, $secure, $serviceAccount, AccessTokenResponse, AlephaSecurity, BasicAuthOptions, CreateTokenOptions, ExtendedJWTPayload, InvalidCredentialsError, InvalidPermissionError, IssuerExternal, IssuerInternal, IssuerPrimitive, IssuerPrimitiveOptions, IssuerResolver, IssuerSettings, JwtParseResult, JwtProvider, JwtSignOptions, KeyLoader, KeyLoaderHolder, Oauth2ServiceAccountPrimitiveOptions, Permission, PermissionPrimitive, PermissionPrimitiveOptions, Realm, Role, RolePrimitive, RolePrimitiveOptions, SecureOptions, SecurityCheckResult, SecurityError, SecurityProvider, ServerSecurityProvider, ServerSecurityUserResolver, ServiceAccountPrimitive, ServiceAccountPrimitiveOptions, ServiceAccountStore, UserAccount, UserAccountToken, UserInfo, currentTenantAtom, currentUserAtom, permissionSchema, roleSchema, userAccountInfoSchema };
1166
1213
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":["JWKParameters","kty","alg","key_ops","ext","use","x5c","x5t","x5u","kid","JWK_OKP_Public","crv","x","JWK_OKP_Private","d","JWK_AKP_Public","pub","JWK_AKP_Private","priv","JWK_EC_Public","y","JWK_EC_Private","JWK_RSA_Public","e","n","JWK_RSA_Private","dp","dq","p","q","qi","JWK_oct","k","JWK","GenericGetKeyFunction","IProtectedHeader","IToken","ReturnKeyTypes","Promise","protectedHeader","token","GetKeyFunction","CryptoKey","KeyObject","Uint8Array","FlattenedJWSInput","JWSHeaderParameters","header","payload","protected","signature","GeneralJWSInput","Omit","signatures","FlattenedJWS","Partial","GeneralJWS","JoseHeaderParameters","Pick","jku","jwk","typ","cty","b64","crit","propName","JWEKeyManagementHeaderParameters","apu","apv","p2c","p2s","iv","epk","FlattenedJWE","JWEHeaderParameters","aad","ciphertext","encrypted_key","tag","unprotected","GeneralJWE","recipients","enc","zip","CritOption","DecryptOptions","keyManagementAlgorithms","contentEncryptionAlgorithms","maxPBES2Count","maxDecompressedLength","EncryptOptions","JWTClaimVerificationOptions","Date","audience","clockTolerance","issuer","maxTokenAge","subject","currentDate","requiredClaims","VerifyOptions","algorithms","SignOptions","JWTPayload","iss","sub","aud","jti","nbf","exp","iat","FlattenedDecryptResult","additionalAuthenticatedData","plaintext","sharedUnprotectedHeader","unprotectedHeader","GeneralDecryptResult","CompactDecryptResult","CompactJWEHeaderParameters","FlattenedVerifyResult","GeneralVerifyResult","CompactVerifyResult","CompactJWSHeaderParameters","JWTVerifyResult","PayloadType","JWTHeaderParameters","JWTDecryptResult","ResolvedKey","key","JSONWebKeySet","keys","type","crypto","subtle","generateKey","ReturnType","Awaited","Extract","ProduceJWT","setIssuer","setSubject","setAudience","setJti","jwtId","setNotBefore","input","setExpirationTime","setIssuedAt","types","JWTVerifyOptions","VerifyOptions","JWTClaimVerificationOptions","JWTVerifyGetKey","JWTHeaderParameters","FlattenedJWSInput","CryptoKey","KeyObject","JWK","Uint8Array","GenericGetKeyFunction","jwtVerify","PayloadType","JWTPayload","JWTVerifyResult","Promise","jwt","key","options","ResolvedKey","getKey"],"sources":["../../src/security/schemas/userAccountInfoSchema.ts","../../src/security/interfaces/UserAccountToken.ts","../../src/security/atoms/currentUserAtom.ts","../../src/security/errors/InvalidCredentialsError.ts","../../src/security/errors/InvalidPermissionError.ts","../../src/security/errors/SecurityError.ts","../../src/security/interfaces/IssuerResolver.ts","../../src/security/primitives/$basicAuth.ts","../../../../node_modules/jose/dist/types/types.d.ts","../../../../node_modules/jose/dist/types/jwt/verify.d.ts","../../src/security/providers/JwtProvider.ts","../../src/security/schemas/permissionSchema.ts","../../src/security/schemas/roleSchema.ts","../../src/security/providers/SecurityProvider.ts","../../src/security/primitives/$issuer.ts","../../src/security/primitives/$permission.ts","../../src/security/primitives/$role.ts","../../src/security/primitives/$secure.ts","../../src/security/primitives/$serviceAccount.ts","../../src/security/providers/ServerSecurityProvider.ts","../../src/security/index.ts"],"x_google_ignoreList":[8,9],"mappings":";;;;;;;;;cAGa,qBAAA,WAAqB,OAAA;MAuDhC,QAAA,CAAA,OAAA;;;;;;;;;;KAEU,WAAA,GAAc,MAAA,QAAc,qBAAA;;;;;;;UCtDvB,gBAAA,SAAyB,WAAA;;;;EAIxC,KAAA;EDPW;;;ECYX,KAAA;;;;;EAMA,SAAA;AAAA;;;;;;;;;cCZW,eAAA,EAAe,QAAA,CAAA,IAAA,CAAA,QAAA,CAAA,SAAA,UAAA,OAAA;MAG1B,QAAA,CAAA,OAAA;;;;;;;;;;;;;;;;;;cCJW,uBAAA,SAAgC,iBAAA;EAAA,SAClC,IAAA;;;;;cCTE,sBAAA,SAA+B,KAAA;cAC9B,IAAA;AAAA;;;cCDD,aAAA,SAAsB,KAAA;EAC1B,IAAA;EAAA,SACS,MAAA;AAAA;;;;;;;KCKN,QAAA,GAAW,IAAA,CAAK,WAAA;EAC1B,SAAA;AAAA;;ANLF;;UMWiB,cAAA;EN4Cf;;;EMxCA,QAAA;;;;;;EAOA,SAAA,GAAY,GAAA,EAAK,aAAA,KAAkB,OAAA,CAAQ,QAAA;AAAA;;;UCrB5B,gBAAA;EACf,QAAA;EACA,QAAA;AAAA;;;;;;APHF;;;;;;;;;;iBOqBgB,UAAA,CAAW,OAAA,EAAS,gBAAA,GAAmB,UAAA;;;;UCvBtCA,aAAAA;;EAEfC,GAAAA;;;;;;EAMAC,GAAAA;ERNF;EQQEC,OAAAA;;EAEAC,GAAAA;;EAEAC,GAAAA;;EAEAC,GAAAA;;EAEAC,GAAAA;;EAEA,UAAA;;EAEAC,GAAAA;;EAEAC,GAAAA;AAAAA;;;;;;;;;;;;;;;UA2FewB,GAAAA,SAAYjC,aAAAA;;;;;EAK3BW,GAAAA;;;;;;EAMAG,CAAAA;;EAEAY,EAAAA;;EAE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AA;AAAA;AAAA,UAGe,uBAAA;EACf,KAAA,QAAa,OAAA;AAAA;AAAA,UAGE,mBAAA;EACf,QAAA,GAAW,mBAAA;AAAA;;;cCjLA,sBAAA;EAAA,mBACQ,GAAA,EADc,gBAAA,CACX,MAAA;EAAA,mBACH,gBAAA,EAAgB,gBAAA;EAAA,mBAChB,WAAA,EAAW,WAAA;EAAA,mBACX,MAAA,EAAM,MAAA;EAAA,mBAEN,eAAA,EAFM,QAAA,CAES,aAAA;EAAA,mBA8Bf,eAAA,EA9Be,QAAA,CA8BA,aAAA;EAAA,UA0BxB,cAAA,CAAA,GAAkB,gBAAA;EAAA,mBAQT,eAAA,EARyB,QAAA,CAQV,aAAA;AAAA;AAAA,KAmCxB,0BAAA,IACV,OAAA,EAAS,aAAA,KACN,OAAA,CAAQ,gBAAA;;;;YC/ED,KAAA;IACR,uBAAA;MACE,KAAA;MACA,IAAA,EAAM,WAAA;IAAA;EAAA;EAAA,UAIA,KAAA;;;;;;;IAOR,6BAAA,GAAgC,gBAAA;;;;IAKhC,sBAAA,GAAyB,WAAA;EAAA;AAAA;AAAA;EAAA,UAKjB,aAAA;IACR,IAAA,GAAO,gBAAA;EAAA;EAAA,UAGC,mBAAA;IACR,IAAA,EAAM,gBAAA;EAAA;EAAA,UAGE,oBAAA,SAA6B,YAAA;;;;;;;;IAQrC,IAAA,GAAO,gBAAA;EAAA;AAAA;;;;ApBjBX;;;;;;;;ACtDA;;;;;cmB6Fa,cAAA,EAAc,QAAA,CAAA,OAAA,CAKzB,QAAA,CALyB,MAAA"}
1
+ {"version":3,"file":"index.d.ts","names":["JWKParameters","kty","alg","key_ops","ext","use","x5c","x5t","x5u","kid","JWK_OKP_Public","crv","x","JWK_OKP_Private","d","JWK_AKP_Public","pub","JWK_AKP_Private","priv","JWK_EC_Public","y","JWK_EC_Private","JWK_RSA_Public","e","n","JWK_RSA_Private","dp","dq","p","q","qi","JWK_oct","k","JWK","GenericGetKeyFunction","IProtectedHeader","IToken","ReturnKeyTypes","Promise","protectedHeader","token","GetKeyFunction","CryptoKey","KeyObject","Uint8Array","FlattenedJWSInput","JWSHeaderParameters","header","payload","protected","signature","GeneralJWSInput","Omit","signatures","FlattenedJWS","Partial","GeneralJWS","JoseHeaderParameters","Pick","jku","jwk","typ","cty","b64","crit","propName","JWEKeyManagementHeaderParameters","apu","apv","p2c","p2s","iv","epk","FlattenedJWE","JWEHeaderParameters","aad","ciphertext","encrypted_key","tag","unprotected","GeneralJWE","recipients","enc","zip","CritOption","DecryptOptions","keyManagementAlgorithms","contentEncryptionAlgorithms","maxPBES2Count","maxDecompressedLength","EncryptOptions","JWTClaimVerificationOptions","Date","audience","clockTolerance","issuer","maxTokenAge","subject","currentDate","requiredClaims","VerifyOptions","algorithms","SignOptions","JWTPayload","iss","sub","aud","jti","nbf","exp","iat","FlattenedDecryptResult","additionalAuthenticatedData","plaintext","sharedUnprotectedHeader","unprotectedHeader","GeneralDecryptResult","CompactDecryptResult","CompactJWEHeaderParameters","FlattenedVerifyResult","GeneralVerifyResult","CompactVerifyResult","CompactJWSHeaderParameters","JWTVerifyResult","PayloadType","JWTHeaderParameters","JWTDecryptResult","ResolvedKey","key","JSONWebKeySet","keys","type","crypto","subtle","generateKey","ReturnType","Awaited","Extract","ProduceJWT","setIssuer","setSubject","setAudience","setJti","jwtId","setNotBefore","input","setExpirationTime","setIssuedAt","types","JWTVerifyOptions","VerifyOptions","JWTClaimVerificationOptions","JWTVerifyGetKey","JWTHeaderParameters","FlattenedJWSInput","CryptoKey","KeyObject","JWK","Uint8Array","GenericGetKeyFunction","jwtVerify","PayloadType","JWTPayload","JWTVerifyResult","Promise","jwt","key","options","ResolvedKey","getKey"],"sources":["../../src/security/schemas/userAccountInfoSchema.ts","../../src/security/interfaces/UserAccountToken.ts","../../src/security/atoms/currentTenantAtom.ts","../../src/security/atoms/currentUserAtom.ts","../../src/security/errors/InvalidCredentialsError.ts","../../src/security/errors/InvalidPermissionError.ts","../../src/security/errors/SecurityError.ts","../../src/security/interfaces/IssuerResolver.ts","../../src/security/primitives/$basicAuth.ts","../../../../node_modules/jose/dist/types/types.d.ts","../../../../node_modules/jose/dist/types/jwt/verify.d.ts","../../src/security/providers/JwtProvider.ts","../../src/security/schemas/permissionSchema.ts","../../src/security/schemas/roleSchema.ts","../../src/security/providers/SecurityProvider.ts","../../src/security/primitives/$issuer.ts","../../src/security/primitives/$permission.ts","../../src/security/primitives/$role.ts","../../src/security/primitives/$secure.ts","../../src/security/primitives/$serviceAccount.ts","../../src/security/providers/ServerSecurityProvider.ts","../../src/security/index.ts"],"x_google_ignoreList":[9,10],"mappings":";;;;;;;;;;cAGa,qBAAA,YAAqB,OAAA;MAuDhC,SAAA,CAAA,OAAA;;;;;;;;;;KAEU,WAAA,GAAc,MAAA,QAAc,qBAAA;;;;;;;UCtDvB,gBAAA,SAAyB,WAAA;;;;EAIxC,KAAA;;ADPF;;ECYE,KAAA;ED2CA;;;;ECrCA,SAAA;AAAA;;;;;;;;;;;;;;ADlBF;;;;;;;;;;;cEqBa,iBAAA,EAAiB,QAAA,CAAA,IAAA,CAAA,SAAA,CAAA,SAAA,WAAA,OAAA;MAS5B,SAAA,CAAA,OAAA;AAAA;;;;;;;;;cCxBW,eAAA,EAAe,QAAA,CAAA,IAAA,CAAA,SAAA,CAAA,SAAA,WAAA,OAAA;MAG1B,SAAA,CAAA,OAAA;;;;;;;;;;;;;;;;;;cCJW,uBAAA,SAAgC,iBAAA;EAAA,SAClC,IAAA;;;;;cCTE,sBAAA,SAA+B,KAAA;cAC9B,IAAA;AAAA;;;cCDD,aAAA,SAAsB,KAAA;EAC1B,IAAA;EAAA,SACS,MAAA;AAAA;;;;;;;KCKN,QAAA,GAAW,IAAA,CAAK,WAAA;EAC1B,SAAA;AAAA;;;APLF;UOWiB,cAAA;;;;EAIf,QAAA;;;;;;EAOA,SAAA,GAAY,GAAA,EAAK,aAAA,KAAkB,OAAA,CAAQ,QAAA;AAAA;;;UCrB5B,gBAAA;EACf,QAAA;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AAA;AAAA;EAAA,UAKrB,aAAA;IACR,IAAA,GAAO,gBAAA;EAAA;EAAA,UAGC,mBAAA;IACR,IAAA,EAAM,gBAAA;EAAA;EAAA,UAGE,oBAAA,SAA6B,YAAA;;;;ArBpBzC;;;;IqB4BI,IAAA,GAAO,gBAAA;EAAA;AAAA;;ApBlFX;;;;;;;;;;;;;ACkBA;;cmBsFa,cAAA,EAAc,QAAA,CAAA,OAAA,CAKzB,QAAA,CALyB,MAAA"}
@@ -5,6 +5,34 @@ import { createSecretKey, randomUUID, timingSafeEqual } from "node:crypto";
5
5
  import { SecretProvider } from "alepha/crypto";
6
6
  import { ForbiddenError, HttpError, UnauthorizedError } from "alepha/server";
7
7
  export * from "alepha/crypto";
8
+ //#region ../../src/security/atoms/currentTenantAtom.ts
9
+ /**
10
+ * Atom storing the active tenant for the current request.
11
+ *
12
+ * Transport-agnostic — works with HTTP, MCP, pipelines, jobs, and any context
13
+ * that sets the atom before calling tenant-scoped logic.
14
+ *
15
+ * Typically set by an app-level middleware that resolves the tenant from the
16
+ * request `Host` header (or another signal) and writes the resolved id to the
17
+ * store. Framework code that reads this atom:
18
+ *
19
+ * - Repository scoping: `withOrganization` / `stampOrganization` prefer this
20
+ * value over `currentUserAtom.organization` so cross-tenant users (admins,
21
+ * agency operators) are scoped to the tenant they are currently acting in
22
+ * rather than the one they belong to.
23
+ * - Session creation: the value is persisted into the JWT as a `tenant` claim,
24
+ * and the issuer resolver rejects tokens whose claim does not match the
25
+ * tenant resolved from the current request.
26
+ *
27
+ * `id` is a free-form string so the framework stays neutral on tenant identity
28
+ * (slug, UUID, composite). Pick whatever matches the column marked with
29
+ * `PG_ORGANIZATION` in your entities.
30
+ */
31
+ const currentTenantAtom = $atom({
32
+ name: "alepha.security.tenant",
33
+ schema: t.optional(t.object({ id: t.text({ description: "Tenant identifier (slug, UUID, or composite)." }) }))
34
+ });
35
+ //#endregion
8
36
  //#region ../../src/security/schemas/userAccountInfoSchema.ts
9
37
  const userAccountInfoSchema = t.object({
10
38
  id: t.text({ description: "Unique identifier for the user." }),
@@ -1571,6 +1599,17 @@ var SecurityProvider = class {
1571
1599
  const token = auth.slice(7);
1572
1600
  if (!token.includes(".")) return null;
1573
1601
  const { result } = await this.jwt.parse(token, realmName);
1602
+ const claimTenant = this.getTenantFromPayload(result.payload);
1603
+ if (claimTenant) {
1604
+ const activeTenant = this.alepha.store.get(currentTenantAtom)?.id;
1605
+ if (activeTenant && activeTenant !== claimTenant) {
1606
+ this.log.warn("JWT tenant claim does not match active tenant", {
1607
+ claim: claimTenant,
1608
+ active: activeTenant
1609
+ });
1610
+ return null;
1611
+ }
1612
+ }
1574
1613
  return this.createUserFromPayload(result.payload, realmName);
1575
1614
  }
1576
1615
  };
@@ -2005,6 +2044,17 @@ var SecurityProvider = class {
2005
2044
  if (!payload) return;
2006
2045
  if (typeof payload.organization === "string") return payload.organization;
2007
2046
  }
2047
+ /**
2048
+ * Extracts the tenant id from the JWT payload, when present.
2049
+ *
2050
+ * Tokens minted with no active tenant (single-tenant apps, server-to-server
2051
+ * calls before any request-scoped middleware runs) omit the claim, in which
2052
+ * case the resolver does not enforce a tenant match.
2053
+ */
2054
+ getTenantFromPayload(payload) {
2055
+ if (!payload) return;
2056
+ if (typeof payload.tenant === "string") return payload.tenant;
2057
+ }
2008
2058
  };
2009
2059
  //#endregion
2010
2060
  //#region ../../src/security/primitives/$issuer.ts
@@ -2018,6 +2068,7 @@ const $issuer = (options) => {
2018
2068
  return createPrimitive(IssuerPrimitive, options);
2019
2069
  };
2020
2070
  var IssuerPrimitive = class extends Primitive {
2071
+ alepha = $inject(Alepha);
2021
2072
  securityProvider = $inject(SecurityProvider);
2022
2073
  dateTimeProvider = $inject(DateTimeProvider);
2023
2074
  jwt = $inject(JwtProvider);
@@ -2133,6 +2184,7 @@ var IssuerPrimitive = class extends Primitive {
2133
2184
  iat,
2134
2185
  aud: this.name
2135
2186
  });
2187
+ const tenant = this.alepha.store.get(currentTenantAtom)?.id;
2136
2188
  return {
2137
2189
  access_token: await this.jwt.create({
2138
2190
  sub: user.id,
@@ -2145,7 +2197,8 @@ var IssuerPrimitive = class extends Primitive {
2145
2197
  preferred_username: user.username,
2146
2198
  picture: user.picture,
2147
2199
  organization: user.organization,
2148
- roles: user.roles
2200
+ roles: user.roles,
2201
+ tenant
2149
2202
  }, this.name),
2150
2203
  token_type: "Bearer",
2151
2204
  expires_in: this.accessTokenExpiration.asSeconds(),
@@ -2648,7 +2701,7 @@ const AlephaSecurity = $module({
2648
2701
  $role,
2649
2702
  $permission
2650
2703
  ],
2651
- atoms: [currentUserAtom],
2704
+ atoms: [currentUserAtom, currentTenantAtom],
2652
2705
  services: [
2653
2706
  SecurityProvider,
2654
2707
  JwtProvider,
@@ -2656,6 +2709,6 @@ const AlephaSecurity = $module({
2656
2709
  ]
2657
2710
  });
2658
2711
  //#endregion
2659
- export { $basicAuth, $issuer, $permission, $role, $secure, $serviceAccount, AlephaSecurity, InvalidCredentialsError, InvalidPermissionError, IssuerPrimitive, JwtProvider, PermissionPrimitive, RolePrimitive, SecurityError, SecurityProvider, ServerSecurityProvider, currentUserAtom, permissionSchema, roleSchema, userAccountInfoSchema };
2712
+ export { $basicAuth, $issuer, $permission, $role, $secure, $serviceAccount, AlephaSecurity, InvalidCredentialsError, InvalidPermissionError, IssuerPrimitive, JwtProvider, PermissionPrimitive, RolePrimitive, SecurityError, SecurityProvider, ServerSecurityProvider, currentTenantAtom, currentUserAtom, permissionSchema, roleSchema, userAccountInfoSchema };
2660
2713
 
2661
2714
  //# sourceMappingURL=index.js.map