@xtandard/permissions 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (375) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +364 -2
  3. package/bin/xtandard-permissions.mjs +3 -0
  4. package/dist/better-auth-BEmX8qyz.mjs +94 -0
  5. package/dist/better-auth-BEmX8qyz.mjs.map +1 -0
  6. package/dist/better-auth-DQET1sXa.d.mts +75 -0
  7. package/dist/better-auth-MR7dBtpo.cjs +111 -0
  8. package/dist/better-auth-MR7dBtpo.cjs.map +1 -0
  9. package/dist/better-auth-vgRYgjYK.d.cts +75 -0
  10. package/dist/catalog-DA_d1SdC.d.cts +153 -0
  11. package/dist/catalog-DJcJ3ycq.d.mts +153 -0
  12. package/dist/catalog.cjs +198 -0
  13. package/dist/catalog.cjs.map +1 -0
  14. package/dist/catalog.d.cts +3 -0
  15. package/dist/catalog.d.mts +3 -0
  16. package/dist/catalog.mjs +141 -0
  17. package/dist/catalog.mjs.map +1 -0
  18. package/dist/chunk-DakpK96I.cjs +43 -0
  19. package/dist/cli.cjs +554 -0
  20. package/dist/cli.cjs.map +1 -0
  21. package/dist/cli.d.cts +28 -0
  22. package/dist/cli.d.mts +28 -0
  23. package/dist/cli.mjs +550 -0
  24. package/dist/cli.mjs.map +1 -0
  25. package/dist/contract-BAisPHBw.d.cts +78 -0
  26. package/dist/contract-BganM0fx.mjs +79 -0
  27. package/dist/contract-BganM0fx.mjs.map +1 -0
  28. package/dist/contract-Bpy8yPrS.cjs +70 -0
  29. package/dist/contract-Bpy8yPrS.cjs.map +1 -0
  30. package/dist/contract-Brnu9XXo.cjs +114 -0
  31. package/dist/contract-Brnu9XXo.cjs.map +1 -0
  32. package/dist/contract-CNgMXr2u.d.cts +46 -0
  33. package/dist/contract-CNgMXr2u.d.mts +46 -0
  34. package/dist/contract-CXPMGuHk.d.cts +391 -0
  35. package/dist/contract-D6j-yrBL.d.mts +78 -0
  36. package/dist/contract-DTdTXZtJ.mjs +47 -0
  37. package/dist/contract-DTdTXZtJ.mjs.map +1 -0
  38. package/dist/contract-DhS23Pcp.d.mts +391 -0
  39. package/dist/contract-RMkmERhT.d.cts +2 -0
  40. package/dist/contract-RMkmERhT.d.mts +2 -0
  41. package/dist/create-fetch-handler-B0twltQL.mjs +673 -0
  42. package/dist/create-fetch-handler-B0twltQL.mjs.map +1 -0
  43. package/dist/create-fetch-handler-B711wb64.d.mts +77 -0
  44. package/dist/create-fetch-handler-BHT4vSZs.cjs +690 -0
  45. package/dist/create-fetch-handler-BHT4vSZs.cjs.map +1 -0
  46. package/dist/create-fetch-handler-DxhvXuBA.d.cts +77 -0
  47. package/dist/elysia-shared-BFcWzfc9.cjs +101 -0
  48. package/dist/elysia-shared-BFcWzfc9.cjs.map +1 -0
  49. package/dist/elysia-shared-BwUYg0Ln.mjs +78 -0
  50. package/dist/elysia-shared-BwUYg0Ln.mjs.map +1 -0
  51. package/dist/elysia-shared-C2LnDOj3.d.cts +58 -0
  52. package/dist/elysia-shared-WuDr0jco.d.mts +58 -0
  53. package/dist/engine--C7zo-4M.cjs +667 -0
  54. package/dist/engine--C7zo-4M.cjs.map +1 -0
  55. package/dist/engine-BTgwbHeO.d.cts +336 -0
  56. package/dist/engine-C3xHfi3q.d.mts +336 -0
  57. package/dist/engine-CR75K253.mjs +654 -0
  58. package/dist/engine-CR75K253.mjs.map +1 -0
  59. package/dist/entry-auth-basic.cjs +40 -0
  60. package/dist/entry-auth-basic.cjs.map +1 -0
  61. package/dist/entry-auth-basic.d.cts +24 -0
  62. package/dist/entry-auth-basic.d.mts +24 -0
  63. package/dist/entry-auth-basic.mjs +26 -0
  64. package/dist/entry-auth-basic.mjs.map +1 -0
  65. package/dist/entry-auth-better-auth.cjs +15 -0
  66. package/dist/entry-auth-better-auth.d.cts +5 -0
  67. package/dist/entry-auth-better-auth.d.mts +5 -0
  68. package/dist/entry-auth-better-auth.mjs +4 -0
  69. package/dist/entry-auth-delegated.cjs +8 -0
  70. package/dist/entry-auth-delegated.d.cts +2 -0
  71. package/dist/entry-auth-delegated.d.mts +2 -0
  72. package/dist/entry-auth-delegated.mjs +2 -0
  73. package/dist/entry-auth-jwt.cjs +120 -0
  74. package/dist/entry-auth-jwt.cjs.map +1 -0
  75. package/dist/entry-auth-jwt.d.cts +71 -0
  76. package/dist/entry-auth-jwt.d.mts +71 -0
  77. package/dist/entry-auth-jwt.mjs +109 -0
  78. package/dist/entry-auth-jwt.mjs.map +1 -0
  79. package/dist/entry-auth-none.cjs +14 -0
  80. package/dist/entry-auth-none.d.cts +2 -0
  81. package/dist/entry-auth-none.d.mts +2 -0
  82. package/dist/entry-auth-none.mjs +2 -0
  83. package/dist/entry-auth-session.cjs +86 -0
  84. package/dist/entry-auth-session.cjs.map +1 -0
  85. package/dist/entry-auth-session.d.cts +25 -0
  86. package/dist/entry-auth-session.d.mts +25 -0
  87. package/dist/entry-auth-session.mjs +76 -0
  88. package/dist/entry-auth-session.mjs.map +1 -0
  89. package/dist/entry-authorization-delegated.cjs +31 -0
  90. package/dist/entry-authorization-delegated.cjs.map +1 -0
  91. package/dist/entry-authorization-delegated.d.cts +27 -0
  92. package/dist/entry-authorization-delegated.d.mts +27 -0
  93. package/dist/entry-authorization-delegated.mjs +30 -0
  94. package/dist/entry-authorization-delegated.mjs.map +1 -0
  95. package/dist/entry-authorization-none.cjs +29 -0
  96. package/dist/entry-authorization-none.cjs.map +1 -0
  97. package/dist/entry-authorization-none.d.cts +17 -0
  98. package/dist/entry-authorization-none.d.mts +17 -0
  99. package/dist/entry-authorization-none.mjs +28 -0
  100. package/dist/entry-authorization-none.mjs.map +1 -0
  101. package/dist/entry-authorization-permissions.cjs +4 -0
  102. package/dist/entry-authorization-permissions.d.cts +49 -0
  103. package/dist/entry-authorization-permissions.d.mts +49 -0
  104. package/dist/entry-authorization-permissions.mjs +2 -0
  105. package/dist/entry-authorization-roles.cjs +9 -0
  106. package/dist/entry-authorization-roles.d.cts +37 -0
  107. package/dist/entry-authorization-roles.d.mts +37 -0
  108. package/dist/entry-authorization-roles.mjs +3 -0
  109. package/dist/entry-better-auth-client.cjs +31 -0
  110. package/dist/entry-better-auth-client.cjs.map +1 -0
  111. package/dist/entry-better-auth-client.d.cts +63 -0
  112. package/dist/entry-better-auth-client.d.mts +63 -0
  113. package/dist/entry-better-auth-client.mjs +29 -0
  114. package/dist/entry-better-auth-client.mjs.map +1 -0
  115. package/dist/entry-better-auth.cjs +289 -0
  116. package/dist/entry-better-auth.cjs.map +1 -0
  117. package/dist/entry-better-auth.d.cts +3 -0
  118. package/dist/entry-better-auth.d.mts +3 -0
  119. package/dist/entry-better-auth.mjs +284 -0
  120. package/dist/entry-better-auth.mjs.map +1 -0
  121. package/dist/entry-bridges-audit.cjs +106 -0
  122. package/dist/entry-bridges-audit.cjs.map +1 -0
  123. package/dist/entry-bridges-audit.d.cts +58 -0
  124. package/dist/entry-bridges-audit.d.mts +58 -0
  125. package/dist/entry-bridges-audit.mjs +105 -0
  126. package/dist/entry-bridges-audit.mjs.map +1 -0
  127. package/dist/entry-bridges-webhooks.cjs +90 -0
  128. package/dist/entry-bridges-webhooks.cjs.map +1 -0
  129. package/dist/entry-bridges-webhooks.d.cts +46 -0
  130. package/dist/entry-bridges-webhooks.d.mts +46 -0
  131. package/dist/entry-bridges-webhooks.mjs +88 -0
  132. package/dist/entry-bridges-webhooks.mjs.map +1 -0
  133. package/dist/entry-bun.cjs +33 -0
  134. package/dist/entry-bun.cjs.map +1 -0
  135. package/dist/entry-bun.d.cts +31 -0
  136. package/dist/entry-bun.d.mts +31 -0
  137. package/dist/entry-bun.mjs +30 -0
  138. package/dist/entry-bun.mjs.map +1 -0
  139. package/dist/entry-drizzle-mysql.cjs +34 -0
  140. package/dist/entry-drizzle-mysql.cjs.map +1 -0
  141. package/dist/entry-drizzle-mysql.d.cts +20 -0
  142. package/dist/entry-drizzle-mysql.d.mts +20 -0
  143. package/dist/entry-drizzle-mysql.mjs +33 -0
  144. package/dist/entry-drizzle-mysql.mjs.map +1 -0
  145. package/dist/entry-drizzle-pg.cjs +44 -0
  146. package/dist/entry-drizzle-pg.cjs.map +1 -0
  147. package/dist/entry-drizzle-pg.d.cts +20 -0
  148. package/dist/entry-drizzle-pg.d.mts +20 -0
  149. package/dist/entry-drizzle-pg.mjs +43 -0
  150. package/dist/entry-drizzle-pg.mjs.map +1 -0
  151. package/dist/entry-drizzle-sqlite.cjs +34 -0
  152. package/dist/entry-drizzle-sqlite.cjs.map +1 -0
  153. package/dist/entry-drizzle-sqlite.d.cts +15 -0
  154. package/dist/entry-drizzle-sqlite.d.mts +15 -0
  155. package/dist/entry-drizzle-sqlite.mjs +33 -0
  156. package/dist/entry-drizzle-sqlite.mjs.map +1 -0
  157. package/dist/entry-elysia.cjs +117 -0
  158. package/dist/entry-elysia.cjs.map +1 -0
  159. package/dist/entry-elysia.d.cts +446 -0
  160. package/dist/entry-elysia.d.mts +446 -0
  161. package/dist/entry-elysia.mjs +113 -0
  162. package/dist/entry-elysia.mjs.map +1 -0
  163. package/dist/entry-elysia2.cjs +117 -0
  164. package/dist/entry-elysia2.cjs.map +1 -0
  165. package/dist/entry-elysia2.d.cts +571 -0
  166. package/dist/entry-elysia2.d.mts +571 -0
  167. package/dist/entry-elysia2.mjs +113 -0
  168. package/dist/entry-elysia2.mjs.map +1 -0
  169. package/dist/entry-express.cjs +101 -0
  170. package/dist/entry-express.cjs.map +1 -0
  171. package/dist/entry-express.d.cts +36 -0
  172. package/dist/entry-express.d.mts +36 -0
  173. package/dist/entry-express.mjs +97 -0
  174. package/dist/entry-express.mjs.map +1 -0
  175. package/dist/entry-hono.cjs +63 -0
  176. package/dist/entry-hono.cjs.map +1 -0
  177. package/dist/entry-hono.d.cts +40 -0
  178. package/dist/entry-hono.d.mts +40 -0
  179. package/dist/entry-hono.mjs +60 -0
  180. package/dist/entry-hono.mjs.map +1 -0
  181. package/dist/entry-hooks-log.cjs +39 -0
  182. package/dist/entry-hooks-log.cjs.map +1 -0
  183. package/dist/entry-hooks-log.d.cts +19 -0
  184. package/dist/entry-hooks-log.d.mts +19 -0
  185. package/dist/entry-hooks-log.mjs +36 -0
  186. package/dist/entry-hooks-log.mjs.map +1 -0
  187. package/dist/entry-next.cjs +67 -0
  188. package/dist/entry-next.cjs.map +1 -0
  189. package/dist/entry-next.d.cts +60 -0
  190. package/dist/entry-next.d.mts +60 -0
  191. package/dist/entry-next.mjs +57 -0
  192. package/dist/entry-next.mjs.map +1 -0
  193. package/dist/entry-react.cjs +401 -0
  194. package/dist/entry-react.cjs.map +1 -0
  195. package/dist/entry-react.d.cts +206 -0
  196. package/dist/entry-react.d.mts +206 -0
  197. package/dist/entry-react.mjs +388 -0
  198. package/dist/entry-react.mjs.map +1 -0
  199. package/dist/entry-storage-cloudflare-kv.cjs +8 -0
  200. package/dist/entry-storage-cloudflare-kv.d.cts +2 -0
  201. package/dist/entry-storage-cloudflare-kv.d.mts +2 -0
  202. package/dist/entry-storage-cloudflare-kv.mjs +2 -0
  203. package/dist/entry-storage-drizzle.cjs +71 -0
  204. package/dist/entry-storage-drizzle.cjs.map +1 -0
  205. package/dist/entry-storage-drizzle.d.cts +27 -0
  206. package/dist/entry-storage-drizzle.d.mts +27 -0
  207. package/dist/entry-storage-drizzle.mjs +68 -0
  208. package/dist/entry-storage-drizzle.mjs.map +1 -0
  209. package/dist/entry-storage-file.cjs +54 -0
  210. package/dist/entry-storage-file.cjs.map +1 -0
  211. package/dist/entry-storage-file.d.cts +24 -0
  212. package/dist/entry-storage-file.d.mts +24 -0
  213. package/dist/entry-storage-file.mjs +46 -0
  214. package/dist/entry-storage-file.mjs.map +1 -0
  215. package/dist/entry-storage-libsql.cjs +64 -0
  216. package/dist/entry-storage-libsql.cjs.map +1 -0
  217. package/dist/entry-storage-libsql.d.cts +28 -0
  218. package/dist/entry-storage-libsql.d.mts +28 -0
  219. package/dist/entry-storage-libsql.mjs +61 -0
  220. package/dist/entry-storage-libsql.mjs.map +1 -0
  221. package/dist/entry-storage-memory.cjs +3 -0
  222. package/dist/entry-storage-memory.d.cts +25 -0
  223. package/dist/entry-storage-memory.d.mts +25 -0
  224. package/dist/entry-storage-memory.mjs +2 -0
  225. package/dist/entry-storage-mongodb.cjs +61 -0
  226. package/dist/entry-storage-mongodb.cjs.map +1 -0
  227. package/dist/entry-storage-mongodb.d.cts +25 -0
  228. package/dist/entry-storage-mongodb.d.mts +25 -0
  229. package/dist/entry-storage-mongodb.mjs +58 -0
  230. package/dist/entry-storage-mongodb.mjs.map +1 -0
  231. package/dist/entry-storage-postgres.cjs +62 -0
  232. package/dist/entry-storage-postgres.cjs.map +1 -0
  233. package/dist/entry-storage-postgres.d.cts +29 -0
  234. package/dist/entry-storage-postgres.d.mts +29 -0
  235. package/dist/entry-storage-postgres.mjs +58 -0
  236. package/dist/entry-storage-postgres.mjs.map +1 -0
  237. package/dist/entry-storage-redis.cjs +76 -0
  238. package/dist/entry-storage-redis.cjs.map +1 -0
  239. package/dist/entry-storage-redis.d.cts +29 -0
  240. package/dist/entry-storage-redis.d.mts +29 -0
  241. package/dist/entry-storage-redis.mjs +72 -0
  242. package/dist/entry-storage-redis.mjs.map +1 -0
  243. package/dist/entry-storage-sqlite.cjs +46 -0
  244. package/dist/entry-storage-sqlite.cjs.map +1 -0
  245. package/dist/entry-storage-sqlite.d.cts +22 -0
  246. package/dist/entry-storage-sqlite.d.mts +22 -0
  247. package/dist/entry-storage-sqlite.mjs +43 -0
  248. package/dist/entry-storage-sqlite.mjs.map +1 -0
  249. package/dist/entry-storage-unstorage.cjs +8 -0
  250. package/dist/entry-storage-unstorage.d.cts +2 -0
  251. package/dist/entry-storage-unstorage.d.mts +2 -0
  252. package/dist/entry-storage-unstorage.mjs +2 -0
  253. package/dist/error-codes-9MRMSSMQ.cjs +49 -0
  254. package/dist/error-codes-9MRMSSMQ.cjs.map +1 -0
  255. package/dist/error-codes-CCKuDDu7.mjs +44 -0
  256. package/dist/error-codes-CCKuDDu7.mjs.map +1 -0
  257. package/dist/errors-CG_OLEEv.mjs +64 -0
  258. package/dist/errors-CG_OLEEv.mjs.map +1 -0
  259. package/dist/errors-CjpymzFj.cjs +105 -0
  260. package/dist/errors-CjpymzFj.cjs.map +1 -0
  261. package/dist/events-AE4Ytqmz.d.cts +6 -0
  262. package/dist/events-AE4Ytqmz.d.mts +6 -0
  263. package/dist/events-DYZShrYB.mjs +15 -0
  264. package/dist/events-DYZShrYB.mjs.map +1 -0
  265. package/dist/events-FJ2K0wly.cjs +26 -0
  266. package/dist/events-FJ2K0wly.cjs.map +1 -0
  267. package/dist/guard-Bj8zk23F.mjs +141 -0
  268. package/dist/guard-Bj8zk23F.mjs.map +1 -0
  269. package/dist/guard-DvaoUgjk.cjs +188 -0
  270. package/dist/guard-DvaoUgjk.cjs.map +1 -0
  271. package/dist/guard-VEK0W8ug.d.cts +62 -0
  272. package/dist/guard-k7A71SWC.d.mts +62 -0
  273. package/dist/index-BVVgDSdq.d.cts +1 -0
  274. package/dist/index-BVVgDSdq.d.mts +1 -0
  275. package/dist/index.cjs +243 -0
  276. package/dist/index.cjs.map +1 -0
  277. package/dist/index.d.cts +213 -0
  278. package/dist/index.d.mts +213 -0
  279. package/dist/index.mjs +60 -0
  280. package/dist/index.mjs.map +1 -0
  281. package/dist/kit-51JtMxsn.d.mts +62 -0
  282. package/dist/kit-BM3uosfV.mjs +80 -0
  283. package/dist/kit-BM3uosfV.mjs.map +1 -0
  284. package/dist/kit-BrqnCcDw.cjs +97 -0
  285. package/dist/kit-BrqnCcDw.cjs.map +1 -0
  286. package/dist/kit-DLF7DZrp.d.cts +62 -0
  287. package/dist/memory-BbBbbY8-.mjs +32 -0
  288. package/dist/memory-BbBbbY8-.mjs.map +1 -0
  289. package/dist/memory-knijqKw_.cjs +39 -0
  290. package/dist/memory-knijqKw_.cjs.map +1 -0
  291. package/dist/permissions-CeV6M3v7.mjs +62 -0
  292. package/dist/permissions-CeV6M3v7.mjs.map +1 -0
  293. package/dist/permissions-DDEkHNvN.cjs +73 -0
  294. package/dist/permissions-DDEkHNvN.cjs.map +1 -0
  295. package/dist/policy-BQmlo2lu.mjs +3 -0
  296. package/dist/policy-CGA6QD0a.d.mts +4 -0
  297. package/dist/policy-DFq_SYR3.d.cts +4 -0
  298. package/dist/react-embed.js +18735 -0
  299. package/dist/react.css +1 -0
  300. package/dist/relationships-BLYEJ9tc.cjs +907 -0
  301. package/dist/relationships-BLYEJ9tc.cjs.map +1 -0
  302. package/dist/relationships-BfLonEMI.mjs +756 -0
  303. package/dist/relationships-BfLonEMI.mjs.map +1 -0
  304. package/dist/roles-DBk4i8b5.mjs +69 -0
  305. package/dist/roles-DBk4i8b5.mjs.map +1 -0
  306. package/dist/roles-a8B5uZ35.cjs +104 -0
  307. package/dist/roles-a8B5uZ35.cjs.map +1 -0
  308. package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
  309. package/dist/routes-B2LrYpT0.cjs +1055 -0
  310. package/dist/routes-B2LrYpT0.cjs.map +1 -0
  311. package/dist/routes-Cx-kl4PY.mjs +1007 -0
  312. package/dist/routes-Cx-kl4PY.mjs.map +1 -0
  313. package/dist/server-Bn643UOy.d.mts +886 -0
  314. package/dist/server-YdH25OEA.d.cts +886 -0
  315. package/dist/table-DA98mVVT.d.cts +2 -0
  316. package/dist/table-DA98mVVT.d.mts +2 -0
  317. package/dist/testing.cjs +59 -0
  318. package/dist/testing.cjs.map +1 -0
  319. package/dist/testing.d.cts +37 -0
  320. package/dist/testing.d.mts +37 -0
  321. package/dist/testing.mjs +57 -0
  322. package/dist/testing.mjs.map +1 -0
  323. package/dist/types-elysia2/adapters/elysia-shared.d.ts +71 -0
  324. package/dist/types-elysia2/adapters/elysia2.d.ts +432 -0
  325. package/dist/types-elysia2/adapters/guard.d.ts +140 -0
  326. package/dist/types-elysia2/auth/contract.d.ts +9 -0
  327. package/dist/types-elysia2/auth-provider/contract.d.ts +85 -0
  328. package/dist/types-elysia2/auth-provider/kit.d.ts +62 -0
  329. package/dist/types-elysia2/authorization/contract.d.ts +53 -0
  330. package/dist/types-elysia2/authorization/permissions.d.ts +54 -0
  331. package/dist/types-elysia2/catalog.d.ts +197 -0
  332. package/dist/types-elysia2/engine.d.ts +233 -0
  333. package/dist/types-elysia2/entry-elysia2.d.ts +9 -0
  334. package/dist/types-elysia2/errors.d.ts +55 -0
  335. package/dist/types-elysia2/hooks/contract.d.ts +100 -0
  336. package/dist/types-elysia2/keys.d.ts +78 -0
  337. package/dist/types-elysia2/policy.d.ts +13 -0
  338. package/dist/types-elysia2/relationships.d.ts +162 -0
  339. package/dist/types-elysia2/schema.d.ts +315 -0
  340. package/dist/types-elysia2/server/cors.d.ts +8 -0
  341. package/dist/types-elysia2/server/create-fetch-handler.d.ts +87 -0
  342. package/dist/types-elysia2/server/openapi.d.ts +29 -0
  343. package/dist/types-elysia2/server/routes.d.ts +143 -0
  344. package/dist/types-elysia2/server/validation.d.ts +205 -0
  345. package/dist/types-elysia2/storage/contract.d.ts +18 -0
  346. package/dist/types-react/catalog.d.ts +197 -0
  347. package/dist/types-react/engine.d.ts +233 -0
  348. package/dist/types-react/entry-react-embed.d.ts +20 -0
  349. package/dist/types-react/errors.d.ts +55 -0
  350. package/dist/types-react/hooks/contract.d.ts +100 -0
  351. package/dist/types-react/keys.d.ts +78 -0
  352. package/dist/types-react/policy.d.ts +13 -0
  353. package/dist/types-react/react-embed.d.ts +37 -0
  354. package/dist/types-react/relationships.d.ts +162 -0
  355. package/dist/types-react/schema.d.ts +315 -0
  356. package/dist/types-react/storage/contract.d.ts +18 -0
  357. package/dist/types-react/ui/App.d.ts +28 -0
  358. package/dist/types-react/ui/api.d.ts +73 -0
  359. package/dist/types-react/ui/components/perm-bits.d.ts +68 -0
  360. package/dist/types-react/ui/lib/queries.d.ts +46 -0
  361. package/dist/types-react/ui/theme.d.ts +10 -0
  362. package/dist/types-react/ui/types.d.ts +118 -0
  363. package/dist/types-react/ui/views/CatalogView.d.ts +3 -0
  364. package/dist/types-react/ui/views/HistoryView.d.ts +6 -0
  365. package/dist/types-react/ui/views/PlaygroundView.d.ts +14 -0
  366. package/dist/types-react/ui/views/RelationshipsView.d.ts +6 -0
  367. package/dist/types-react/ui/views/SubjectDetailView.d.ts +7 -0
  368. package/dist/types-react/ui/views/SubjectsView.d.ts +6 -0
  369. package/dist/ui/apple-touch-icon.png +0 -0
  370. package/dist/ui/assets/index-DCPZRo-Z.css +1 -0
  371. package/dist/ui/assets/index-DdvxpphI.js +104 -0
  372. package/dist/ui/favicon.ico +0 -0
  373. package/dist/ui/favicon.svg +15 -0
  374. package/dist/ui/index.html +20 -0
  375. package/package.json +587 -4
@@ -0,0 +1,111 @@
1
+ const require_contract = require("./contract-Brnu9XXo.cjs");
2
+ //#region src/auth-provider/better-auth.ts
3
+ /**
4
+ * better-auth as a {@link PermissionsAuthProvider} (ADR 0006/0007). The subject is the better-auth
5
+ * user; the role comes from the admin plugin's `user.role` (comma-separated, e.g. `"admin,user"`)
6
+ * or, with `roleSource: "organization"`, from the caller's member role in the active organization.
7
+ *
8
+ * No runtime import of better-auth: `auth` is typed structurally, so any `betterAuth()` instance
9
+ * (with or without plugins) is accepted.
10
+ *
11
+ * @module
12
+ */
13
+ /** Narrow better-auth's `getSession` result. */
14
+ function asBetterAuthSession(value) {
15
+ if (!value || typeof value !== "object") return null;
16
+ const { user, session } = value;
17
+ if (!require_contract.stringField(user, "id") || !session || typeof session !== "object") return null;
18
+ return value;
19
+ }
20
+ /**
21
+ * Resolve the raw role for a better-auth session (shared with the server plugin).
22
+ * @internal
23
+ */
24
+ async function betterAuthRole(auth, session, headers, options) {
25
+ if (options.roleSource !== "organization") return require_contract.normalizeRoles(session.user.role, options.mapRole);
26
+ if (!session.session.activeOrganizationId) return null;
27
+ return require_contract.normalizeRoles((await auth.api.getActiveMemberRole({ headers }))?.role, options.mapRole);
28
+ }
29
+ /**
30
+ * The subject identity of a better-auth session (shared with the server plugin).
31
+ * @internal
32
+ */
33
+ async function betterAuthIdentity(auth, session, headers, options) {
34
+ const attributes = {};
35
+ const org = session.session.activeOrganizationId;
36
+ if (typeof org === "string" && org) attributes.activeOrganizationId = org;
37
+ Object.assign(attributes, options.attributes?.(session));
38
+ return require_contract.identity({
39
+ id: session.user.id,
40
+ role: await betterAuthRole(auth, session, headers, options),
41
+ name: require_contract.stringField(session.user, "name"),
42
+ email: require_contract.stringField(session.user, "email"),
43
+ attributes
44
+ });
45
+ }
46
+ /** Throw early when `roleSource: "organization"` is used without the organization plugin. */
47
+ function assertRoleSource(auth, options) {
48
+ if (options.roleSource === "organization" && typeof auth.api.getActiveMemberRole !== "function") throw new TypeError("betterAuthProvider: roleSource \"organization\" needs better-auth's organization plugin (auth.api.getActiveMemberRole)");
49
+ }
50
+ /**
51
+ * The identity of a better-auth user looked up by id (shared with tests).
52
+ * @internal
53
+ */
54
+ async function betterAuthLookup(auth, id, options) {
55
+ if (!auth.$context) throw new TypeError("betterAuthProvider: lookupSubject needs auth.$context (pass the betterAuth() instance)");
56
+ const user = await (await auth.$context).internalAdapter.findUserById(id);
57
+ const userId = require_contract.stringField(user, "id");
58
+ if (!userId) return null;
59
+ const raw = user.role;
60
+ return require_contract.identity({
61
+ id: userId,
62
+ role: options.roleSource === "organization" ? null : require_contract.normalizeRoles(raw, options.mapRole),
63
+ name: require_contract.stringField(user, "name"),
64
+ email: require_contract.stringField(user, "email")
65
+ });
66
+ }
67
+ /**
68
+ * A {@link PermissionsAuthProvider} over a `betterAuth()` instance, with `lookupSubject` (ADR 0014).
69
+ *
70
+ * @example
71
+ * ```ts
72
+ * import { betterAuthProvider } from "@xtandard/permissions/auth/better-auth";
73
+ *
74
+ * const provider = betterAuthProvider(auth, { mapRole: { user: "member" } });
75
+ * const { auth: kitAuth, authorization } = toKitAuth(provider, perms);
76
+ * ```
77
+ */
78
+ function betterAuthProvider(auth, options = {}) {
79
+ assertRoleSource(auth, options);
80
+ const provider = {
81
+ async getSubject(request) {
82
+ const session = asBetterAuthSession(await auth.api.getSession({ headers: request.headers }));
83
+ if (!session) return null;
84
+ return betterAuthIdentity(auth, session, request.headers, options);
85
+ },
86
+ lookupSubject: (id) => betterAuthLookup(auth, id, options)
87
+ };
88
+ if (options.canManage) provider.canManage = options.canManage;
89
+ return provider;
90
+ }
91
+ //#endregion
92
+ Object.defineProperty(exports, "asBetterAuthSession", {
93
+ enumerable: true,
94
+ get: function() {
95
+ return asBetterAuthSession;
96
+ }
97
+ });
98
+ Object.defineProperty(exports, "betterAuthIdentity", {
99
+ enumerable: true,
100
+ get: function() {
101
+ return betterAuthIdentity;
102
+ }
103
+ });
104
+ Object.defineProperty(exports, "betterAuthProvider", {
105
+ enumerable: true,
106
+ get: function() {
107
+ return betterAuthProvider;
108
+ }
109
+ });
110
+
111
+ //# sourceMappingURL=better-auth-MR7dBtpo.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"better-auth-MR7dBtpo.cjs","names":["stringField","normalizeRoles","identity"],"sources":["../src/auth-provider/better-auth.ts"],"sourcesContent":["/**\n * better-auth as a {@link PermissionsAuthProvider} (ADR 0006/0007). The subject is the better-auth\n * user; the role comes from the admin plugin's `user.role` (comma-separated, e.g. `\"admin,user\"`)\n * or, with `roleSource: \"organization\"`, from the caller's member role in the active organization.\n *\n * No runtime import of better-auth: `auth` is typed structurally, so any `betterAuth()` instance\n * (with or without plugins) is accepted.\n *\n * @module\n */\n\nimport {\n identity,\n normalizeRoles,\n stringField,\n type PermissionsAuthProvider,\n type ProviderRoleOptions,\n type SubjectIdentity,\n} from \"./contract.ts\";\n\n/** The part of a `betterAuth()` instance this provider calls (structural). */\nexport interface BetterAuthLike {\n api: {\n /** `auth.api.getSession({ headers })` → `{ session, user } | null`. */\n getSession(context: { headers: Headers }): Promise<unknown>;\n /** Organization plugin: `auth.api.getActiveMemberRole({ headers })` → `{ role }`. */\n getActiveMemberRole?(context: { headers: Headers }): Promise<unknown>;\n };\n /**\n * `auth.$context`: its `internalAdapter.findUserById(id)` backs `lookupSubject` (server-side, no\n * headers). Every `betterAuth()` instance has it.\n */\n $context?: PromiseLike<{\n internalAdapter: { findUserById(id: string): Promise<unknown> };\n }>;\n}\n\n/** {@link betterAuthProvider}'s provider: `lookupSubject` is always there. */\nexport interface BetterAuthPermissionsProvider extends PermissionsAuthProvider {\n /**\n * The better-auth user by id (`internalAdapter.findUserById`), its admin-plugin `user.role` split\n * and mapped like `getSubject`'s; `null` for an unknown id. With `roleSource: \"organization\"`\n * the role is `null` (an organization role needs a session's active organization).\n */\n lookupSubject(id: string): Promise<SubjectIdentity | null>;\n}\n\n/** The session shape the provider reads (a structural subset of better-auth's). */\nexport interface BetterAuthSessionLike {\n user: {\n id: string;\n name?: string | null;\n email?: string | null;\n role?: string | string[] | null;\n [key: string]: unknown;\n };\n session: { activeOrganizationId?: string | null; [key: string]: unknown };\n}\n\n/** Options for {@link betterAuthProvider}. */\nexport interface BetterAuthProviderOptions extends ProviderRoleOptions {\n /**\n * Where the raw role comes from. `\"user\"` (default): the admin plugin's `user.role`.\n * `\"organization\"`: the caller's role in `session.activeOrganizationId` (organization plugin);\n * without an active organization the role is empty (the catalog's `defaultRole`).\n */\n roleSource?: \"user\" | \"organization\";\n /** Extra subject attributes from the session (merged after `activeOrganizationId`). */\n attributes?(session: BetterAuthSessionLike): Record<string, unknown> | undefined;\n}\n\n/** Narrow better-auth's `getSession` result. */\nexport function asBetterAuthSession(value: unknown): BetterAuthSessionLike | null {\n if (!value || typeof value !== \"object\") return null;\n const { user, session } = value as { user?: unknown; session?: unknown };\n if (!stringField(user, \"id\") || !session || typeof session !== \"object\") return null;\n return value as BetterAuthSessionLike;\n}\n\n/**\n * Resolve the raw role for a better-auth session (shared with the server plugin).\n * @internal\n */\nexport async function betterAuthRole(\n auth: BetterAuthLike,\n session: BetterAuthSessionLike,\n headers: Headers,\n options: BetterAuthProviderOptions,\n): Promise<string[] | null> {\n if (options.roleSource !== \"organization\")\n return normalizeRoles(session.user.role, options.mapRole);\n if (!session.session.activeOrganizationId) return null;\n const member = await auth.api.getActiveMemberRole!({ headers });\n return normalizeRoles((member as { role?: unknown } | null)?.role, options.mapRole);\n}\n\n/**\n * The subject identity of a better-auth session (shared with the server plugin).\n * @internal\n */\nexport async function betterAuthIdentity(\n auth: BetterAuthLike,\n session: BetterAuthSessionLike,\n headers: Headers,\n options: BetterAuthProviderOptions,\n) {\n const attributes: Record<string, unknown> = {};\n const org = session.session.activeOrganizationId;\n if (typeof org === \"string\" && org) attributes.activeOrganizationId = org;\n Object.assign(attributes, options.attributes?.(session));\n return identity({\n id: session.user.id,\n role: await betterAuthRole(auth, session, headers, options),\n name: stringField(session.user, \"name\"),\n email: stringField(session.user, \"email\"),\n attributes,\n });\n}\n\n/** Throw early when `roleSource: \"organization\"` is used without the organization plugin. */\nexport function assertRoleSource(auth: BetterAuthLike, options: BetterAuthProviderOptions): void {\n if (options.roleSource === \"organization\" && typeof auth.api.getActiveMemberRole !== \"function\") {\n throw new TypeError(\n 'betterAuthProvider: roleSource \"organization\" needs better-auth\\'s organization plugin (auth.api.getActiveMemberRole)',\n );\n }\n}\n\n/**\n * The identity of a better-auth user looked up by id (shared with tests).\n * @internal\n */\nexport async function betterAuthLookup(\n auth: BetterAuthLike,\n id: string,\n options: BetterAuthProviderOptions,\n): Promise<SubjectIdentity | null> {\n if (!auth.$context) {\n throw new TypeError(\n \"betterAuthProvider: lookupSubject needs auth.$context (pass the betterAuth() instance)\",\n );\n }\n const context = await auth.$context;\n const user = await context.internalAdapter.findUserById(id);\n const userId = stringField(user, \"id\");\n if (!userId) return null;\n const raw = (user as { role?: unknown }).role;\n return identity({\n id: userId,\n role: options.roleSource === \"organization\" ? null : normalizeRoles(raw, options.mapRole),\n name: stringField(user, \"name\"),\n email: stringField(user, \"email\"),\n });\n}\n\n/**\n * A {@link PermissionsAuthProvider} over a `betterAuth()` instance, with `lookupSubject` (ADR 0014).\n *\n * @example\n * ```ts\n * import { betterAuthProvider } from \"@xtandard/permissions/auth/better-auth\";\n *\n * const provider = betterAuthProvider(auth, { mapRole: { user: \"member\" } });\n * const { auth: kitAuth, authorization } = toKitAuth(provider, perms);\n * ```\n */\nexport function betterAuthProvider(\n auth: BetterAuthLike,\n options: BetterAuthProviderOptions = {},\n): BetterAuthPermissionsProvider {\n assertRoleSource(auth, options);\n const provider: BetterAuthPermissionsProvider = {\n async getSubject(request) {\n const session = asBetterAuthSession(await auth.api.getSession({ headers: request.headers }));\n if (!session) return null;\n return betterAuthIdentity(auth, session, request.headers, options);\n },\n lookupSubject: (id) => betterAuthLookup(auth, id, options),\n };\n if (options.canManage) provider.canManage = options.canManage;\n return provider;\n}\n"],"mappings":";;;;;;;;;;;;;AAwEA,SAAgB,oBAAoB,OAA8C;CAChF,IAAI,CAAC,SAAS,OAAO,UAAU,UAAU,OAAO;CAChD,MAAM,EAAE,MAAM,YAAY;CAC1B,IAAI,CAACA,iBAAAA,YAAY,MAAM,IAAI,KAAK,CAAC,WAAW,OAAO,YAAY,UAAU,OAAO;CAChF,OAAO;AACT;;;;;AAMA,eAAsB,eACpB,MACA,SACA,SACA,SAC0B;CAC1B,IAAI,QAAQ,eAAe,gBACzB,OAAOC,iBAAAA,eAAe,QAAQ,KAAK,MAAM,QAAQ,OAAO;CAC1D,IAAI,CAAC,QAAQ,QAAQ,sBAAsB,OAAO;CAElD,OAAOA,iBAAAA,gBAAgB,MADF,KAAK,IAAI,oBAAqB,EAAE,QAAQ,CAAC,IACD,MAAM,QAAQ,OAAO;AACpF;;;;;AAMA,eAAsB,mBACpB,MACA,SACA,SACA,SACA;CACA,MAAM,aAAsC,CAAC;CAC7C,MAAM,MAAM,QAAQ,QAAQ;CAC5B,IAAI,OAAO,QAAQ,YAAY,KAAK,WAAW,uBAAuB;CACtE,OAAO,OAAO,YAAY,QAAQ,aAAa,OAAO,CAAC;CACvD,OAAOC,iBAAAA,SAAS;EACd,IAAI,QAAQ,KAAK;EACjB,MAAM,MAAM,eAAe,MAAM,SAAS,SAAS,OAAO;EAC1D,MAAMF,iBAAAA,YAAY,QAAQ,MAAM,MAAM;EACtC,OAAOA,iBAAAA,YAAY,QAAQ,MAAM,OAAO;EACxC;CACF,CAAC;AACH;;AAGA,SAAgB,iBAAiB,MAAsB,SAA0C;CAC/F,IAAI,QAAQ,eAAe,kBAAkB,OAAO,KAAK,IAAI,wBAAwB,YACnF,MAAM,IAAI,UACR,wHACF;AAEJ;;;;;AAMA,eAAsB,iBACpB,MACA,IACA,SACiC;CACjC,IAAI,CAAC,KAAK,UACR,MAAM,IAAI,UACR,wFACF;CAGF,MAAM,OAAO,OAAM,MADG,KAAK,UACA,gBAAgB,aAAa,EAAE;CAC1D,MAAM,SAASA,iBAAAA,YAAY,MAAM,IAAI;CACrC,IAAI,CAAC,QAAQ,OAAO;CACpB,MAAM,MAAO,KAA4B;CACzC,OAAOE,iBAAAA,SAAS;EACd,IAAI;EACJ,MAAM,QAAQ,eAAe,iBAAiB,OAAOD,iBAAAA,eAAe,KAAK,QAAQ,OAAO;EACxF,MAAMD,iBAAAA,YAAY,MAAM,MAAM;EAC9B,OAAOA,iBAAAA,YAAY,MAAM,OAAO;CAClC,CAAC;AACH;;;;;;;;;;;;AAaA,SAAgB,mBACd,MACA,UAAqC,CAAC,GACP;CAC/B,iBAAiB,MAAM,OAAO;CAC9B,MAAM,WAA0C;EAC9C,MAAM,WAAW,SAAS;GACxB,MAAM,UAAU,oBAAoB,MAAM,KAAK,IAAI,WAAW,EAAE,SAAS,QAAQ,QAAQ,CAAC,CAAC;GAC3F,IAAI,CAAC,SAAS,OAAO;GACrB,OAAO,mBAAmB,MAAM,SAAS,QAAQ,SAAS,OAAO;EACnE;EACA,gBAAgB,OAAO,iBAAiB,MAAM,IAAI,OAAO;CAC3D;CACA,IAAI,QAAQ,WAAW,SAAS,YAAY,QAAQ;CACpD,OAAO;AACT"}
@@ -0,0 +1,75 @@
1
+ import { h as SubjectIdentity } from "./catalog-DA_d1SdC.cjs";
2
+ import { n as ProviderRoleOptions, t as PermissionsAuthProvider } from "./contract-BAisPHBw.cjs";
3
+
4
+ //#region src/auth-provider/better-auth.d.ts
5
+ /** The part of a `betterAuth()` instance this provider calls (structural). */
6
+ interface BetterAuthLike {
7
+ api: {
8
+ /** `auth.api.getSession({ headers })` → `{ session, user } | null`. */getSession(context: {
9
+ headers: Headers;
10
+ }): Promise<unknown>; /** Organization plugin: `auth.api.getActiveMemberRole({ headers })` → `{ role }`. */
11
+ getActiveMemberRole?(context: {
12
+ headers: Headers;
13
+ }): Promise<unknown>;
14
+ };
15
+ /**
16
+ * `auth.$context`: its `internalAdapter.findUserById(id)` backs `lookupSubject` (server-side, no
17
+ * headers). Every `betterAuth()` instance has it.
18
+ */
19
+ $context?: PromiseLike<{
20
+ internalAdapter: {
21
+ findUserById(id: string): Promise<unknown>;
22
+ };
23
+ }>;
24
+ }
25
+ /** {@link betterAuthProvider}'s provider: `lookupSubject` is always there. */
26
+ interface BetterAuthPermissionsProvider extends PermissionsAuthProvider {
27
+ /**
28
+ * The better-auth user by id (`internalAdapter.findUserById`), its admin-plugin `user.role` split
29
+ * and mapped like `getSubject`'s; `null` for an unknown id. With `roleSource: "organization"`
30
+ * the role is `null` (an organization role needs a session's active organization).
31
+ */
32
+ lookupSubject(id: string): Promise<SubjectIdentity | null>;
33
+ }
34
+ /** The session shape the provider reads (a structural subset of better-auth's). */
35
+ interface BetterAuthSessionLike {
36
+ user: {
37
+ id: string;
38
+ name?: string | null;
39
+ email?: string | null;
40
+ role?: string | string[] | null;
41
+ [key: string]: unknown;
42
+ };
43
+ session: {
44
+ activeOrganizationId?: string | null;
45
+ [key: string]: unknown;
46
+ };
47
+ }
48
+ /** Options for {@link betterAuthProvider}. */
49
+ interface BetterAuthProviderOptions extends ProviderRoleOptions {
50
+ /**
51
+ * Where the raw role comes from. `"user"` (default): the admin plugin's `user.role`.
52
+ * `"organization"`: the caller's role in `session.activeOrganizationId` (organization plugin);
53
+ * without an active organization the role is empty (the catalog's `defaultRole`).
54
+ */
55
+ roleSource?: "user" | "organization";
56
+ /** Extra subject attributes from the session (merged after `activeOrganizationId`). */
57
+ attributes?(session: BetterAuthSessionLike): Record<string, unknown> | undefined;
58
+ }
59
+ /** Narrow better-auth's `getSession` result. */
60
+ declare function asBetterAuthSession(value: unknown): BetterAuthSessionLike | null;
61
+ /**
62
+ * A {@link PermissionsAuthProvider} over a `betterAuth()` instance, with `lookupSubject` (ADR 0014).
63
+ *
64
+ * @example
65
+ * ```ts
66
+ * import { betterAuthProvider } from "@xtandard/permissions/auth/better-auth";
67
+ *
68
+ * const provider = betterAuthProvider(auth, { mapRole: { user: "member" } });
69
+ * const { auth: kitAuth, authorization } = toKitAuth(provider, perms);
70
+ * ```
71
+ */
72
+ declare function betterAuthProvider(auth: BetterAuthLike, options?: BetterAuthProviderOptions): BetterAuthPermissionsProvider;
73
+ //#endregion
74
+ export { asBetterAuthSession as a, BetterAuthSessionLike as i, BetterAuthPermissionsProvider as n, betterAuthProvider as o, BetterAuthProviderOptions as r, BetterAuthLike as t };
75
+ //# sourceMappingURL=better-auth-vgRYgjYK.d.cts.map
@@ -0,0 +1,153 @@
1
+ import { i as AuthorizationConfig, p as RelationSchema, r as Authorization, s as Definition } from "./policy-DFq_SYR3.cjs";
2
+
3
+ //#region src/catalog.d.ts
4
+ /** A catalog without relations (ReBAC off): no object type, so no relation query type-checks. */
5
+ type NoRelations = Record<never, never>;
6
+ /** The user the rules see: the engine passes the subject with its effective `role`. */
7
+ interface PermissionsSubject {
8
+ /** The subject id (a user id in 0.1). */
9
+ id: string;
10
+ /** The effective role (stored assignment, else the auth provider's, else `defaultRole`). */
11
+ role: string;
12
+ name?: string;
13
+ email?: string;
14
+ /** Extra facts from the auth provider (claims, profile fields). */
15
+ attributes?: Record<string, unknown>;
16
+ }
17
+ /**
18
+ * Who a check is for, as an auth provider reports it. `role` may be one role, several (the most
19
+ * privileged known one wins, see {@link PermissionsCatalog.effectiveRole}) or missing
20
+ * (`defaultRole`); a stored role assignment overrides it.
21
+ */
22
+ interface SubjectIdentity {
23
+ id: string;
24
+ role?: string | readonly string[] | null;
25
+ name?: string;
26
+ email?: string;
27
+ attributes?: Record<string, unknown>;
28
+ }
29
+ /** A human label: a string, or a label with a description. */
30
+ type LabelInput = string | {
31
+ label: string;
32
+ description?: string;
33
+ };
34
+ /** A normalized label. */
35
+ interface Label {
36
+ label: string;
37
+ description?: string;
38
+ }
39
+ /** What `definePermissions` adds on top of the lib's `AuthorizationConfig`. */
40
+ interface CatalogMeta<R extends string, P extends string, S extends RelationSchema = NoRelations> {
41
+ /**
42
+ * The relation schema (ReBAC, ADR 0013), built with `defineRelations` and the `direct` /
43
+ * `computed` / `from` / `union` / `intersection` / `exclusion` builders. Validated again here.
44
+ * Without it, relationship writes and checks throw `RelationSchemaError`.
45
+ */
46
+ relations?: S;
47
+ /**
48
+ * Roles that may grant / revoke / assign roles by default (an auth provider can override it).
49
+ * Default: the most privileged role (the last of `roles`).
50
+ */
51
+ managerRoles?: readonly R[];
52
+ /** Labels and descriptions for the admin panel. Missing entries default to the key. */
53
+ labels?: {
54
+ roles?: Partial<Record<R, LabelInput>>;
55
+ permissions?: Partial<Record<P, LabelInput>>;
56
+ };
57
+ /**
58
+ * When `true`, a non-expired grant whose name equals the checked path allows it outright
59
+ * (`reason: "grant"`), for catalogs whose assignable names are paths. Default `false`: grants
60
+ * only matter through the rules (ADR 0005).
61
+ */
62
+ directGrants?: boolean;
63
+ }
64
+ /**
65
+ * The configuration of {@link definePermissions}: the lib's `AuthorizationConfig` (roles ordered
66
+ * **least → most privileged**, `guestRole`, `defaultRole`, `assignable`, `rules`) without
67
+ * `getRole` (the engine sets the role), plus {@link CatalogMeta}.
68
+ */
69
+ type PermissionsConfig<D extends Definition, R extends string, P extends string, X, S extends RelationSchema = NoRelations> = Omit<AuthorizationConfig<D, R, P, PermissionsSubject, X>, "getRole"> & CatalogMeta<NoInfer<R>, NoInfer<P>, S>;
70
+ /** A catalog: the wrapped lib `Authorization` plus the product metadata. */
71
+ interface PermissionsCatalog<D extends Definition = Definition, R extends string = string, P extends string = string, X = undefined, S extends RelationSchema = RelationSchema> {
72
+ /** The lib authorization (`createAbility`, `createRules`, `parseRole`, …). */
73
+ readonly authorization: Authorization<D, R, P, PermissionsSubject, X>;
74
+ /** Every role, least → most privileged. */
75
+ readonly roles: readonly R[];
76
+ /** The role of a request without a subject. */
77
+ readonly guestRole: R;
78
+ /** The role of a signed-in subject whose role is missing or unknown. */
79
+ readonly defaultRole: R;
80
+ /** The assignable permissions. */
81
+ readonly assignable: readonly P[];
82
+ /** Roles that may manage permissions by default. */
83
+ readonly managerRoles: readonly R[];
84
+ /** Labels for every role and permission (defaulting to the key). */
85
+ readonly labels: {
86
+ readonly roles: Readonly<Record<R, Label>>;
87
+ readonly permissions: Readonly<Record<P, Label>>;
88
+ };
89
+ /** See {@link CatalogMeta.directGrants}. */
90
+ readonly directGrants: boolean;
91
+ /** The relation schema (ReBAC), `null` when the catalog declares none. */
92
+ readonly relations: S | null;
93
+ /** True when `value` is one of `roles`. */
94
+ isRole(value: unknown): value is R;
95
+ /** True when `value` is one of `assignable`. */
96
+ isAssignable(value: unknown): value is P;
97
+ /** True when `role` is one of `managerRoles`. */
98
+ isManagerRole(role: unknown): boolean;
99
+ /** A signed-in subject's role: `value` when it is a known non-guest role, else `defaultRole`. */
100
+ parseRole(value: unknown): R;
101
+ /**
102
+ * The effective role of a signed-in subject from what an auth provider reports: one role, several
103
+ * (an array, or a comma-separated string as better-auth's admin plugin stores them) → the most
104
+ * privileged known one; none known (or missing) → `defaultRole`. Never the guest role.
105
+ */
106
+ effectiveRole(raw: string | readonly string[] | null | undefined): R;
107
+ }
108
+ /**
109
+ * The permission type of a catalog: the `assignable` union, or `string` for a roles-only catalog
110
+ * (`assignable: []` infers `never`, which no generic `AnyPermissionsCatalog` slot accepts because
111
+ * rules are contravariant in it). Every permission is still rejected at runtime there.
112
+ */
113
+ type PermissionUnion<P extends string> = [P] extends [never] ? string : P;
114
+ /** Any catalog (for generic constraints). */
115
+ type AnyPermissionsCatalog = PermissionsCatalog<any, any, any, any, any>;
116
+ /** The permix definition of a catalog. */
117
+ type DefinitionOf<C> = C extends PermissionsCatalog<infer D, any, any, any, any> ? D : never;
118
+ /** The role union of a catalog. */
119
+ type RoleOf<C> = C extends {
120
+ readonly roles: readonly (infer R)[];
121
+ } ? R : never;
122
+ /** The assignable-permission union of a catalog. */
123
+ type PermissionOf<C> = C extends {
124
+ readonly assignable: readonly (infer P)[];
125
+ } ? P : never;
126
+ /** The rule context (`ctx`) type of a catalog. */
127
+ type CtxOf<C> = C extends PermissionsCatalog<any, any, any, infer X, any> ? X : never;
128
+ /** The relation schema of a catalog. */
129
+ type RelationsOf<C> = C extends PermissionsCatalog<any, any, any, any, infer S> ? S : never;
130
+ /**
131
+ * Define the catalog. Curried like the lib's `defineAuthorization`: the permix definition and the
132
+ * rule context type go in the first call, the roles and permissions are inferred by the second:
133
+ * `definePermissions<Definition, Ctx>()({ ... })`.
134
+ *
135
+ * Rules are synchronous (a rule that returns a Promise denies and throws `AsyncRuleError`); load
136
+ * what they need first and pass it as `ctx` or as the checked data. A rule wrapped in the lib's
137
+ * `asyncRule()` is evaluated only by the engine's async `check()` / `can()`, never by the
138
+ * synchronous `ability()` (ADR 0005).
139
+ *
140
+ * @throws {Error} When `guestRole`, `defaultRole` or a `managerRoles` entry is not in `roles`, a
141
+ * role has no rules, or the guest role is a manager role.
142
+ */
143
+ declare function definePermissions<D extends Definition, X = undefined>(): <const R extends string, const P extends string, const S extends RelationSchema = NoRelations>(config: PermissionsConfig<D, R, P, X, S>) => PermissionsCatalog<D, R, PermissionUnion<P>, X, S>;
144
+ /**
145
+ * Wrap an existing lib `Authorization` (from `defineAuthorization`) as a catalog. Its config is
146
+ * re-defined with `getRole: (subject) => subject.role`, so its rules receive a
147
+ * {@link PermissionsSubject} (`{ id, role, name?, email?, attributes? }`) as `user`; rules that read
148
+ * other user fields must move them into `attributes` or `ctx`.
149
+ */
150
+ declare function fromAuthorization<D extends Definition, R extends string, P extends string, X, const S extends RelationSchema = NoRelations>(authorization: Authorization<D, R, P, any, X>, meta?: CatalogMeta<NoInfer<R>, NoInfer<P>, S>): PermissionsCatalog<D, R, P, X, S>;
151
+ //#endregion
152
+ export { fromAuthorization as _, Label as a, PermissionOf as c, PermissionsConfig as d, PermissionsSubject as f, definePermissions as g, SubjectIdentity as h, DefinitionOf as i, PermissionUnion as l, RoleOf as m, CatalogMeta as n, LabelInput as o, RelationsOf as p, CtxOf as r, NoRelations as s, AnyPermissionsCatalog as t, PermissionsCatalog as u };
153
+ //# sourceMappingURL=catalog-DA_d1SdC.d.cts.map
@@ -0,0 +1,153 @@
1
+ import { i as AuthorizationConfig, p as RelationSchema, r as Authorization, s as Definition } from "./policy-CGA6QD0a.mjs";
2
+
3
+ //#region src/catalog.d.ts
4
+ /** A catalog without relations (ReBAC off): no object type, so no relation query type-checks. */
5
+ type NoRelations = Record<never, never>;
6
+ /** The user the rules see: the engine passes the subject with its effective `role`. */
7
+ interface PermissionsSubject {
8
+ /** The subject id (a user id in 0.1). */
9
+ id: string;
10
+ /** The effective role (stored assignment, else the auth provider's, else `defaultRole`). */
11
+ role: string;
12
+ name?: string;
13
+ email?: string;
14
+ /** Extra facts from the auth provider (claims, profile fields). */
15
+ attributes?: Record<string, unknown>;
16
+ }
17
+ /**
18
+ * Who a check is for, as an auth provider reports it. `role` may be one role, several (the most
19
+ * privileged known one wins, see {@link PermissionsCatalog.effectiveRole}) or missing
20
+ * (`defaultRole`); a stored role assignment overrides it.
21
+ */
22
+ interface SubjectIdentity {
23
+ id: string;
24
+ role?: string | readonly string[] | null;
25
+ name?: string;
26
+ email?: string;
27
+ attributes?: Record<string, unknown>;
28
+ }
29
+ /** A human label: a string, or a label with a description. */
30
+ type LabelInput = string | {
31
+ label: string;
32
+ description?: string;
33
+ };
34
+ /** A normalized label. */
35
+ interface Label {
36
+ label: string;
37
+ description?: string;
38
+ }
39
+ /** What `definePermissions` adds on top of the lib's `AuthorizationConfig`. */
40
+ interface CatalogMeta<R extends string, P extends string, S extends RelationSchema = NoRelations> {
41
+ /**
42
+ * The relation schema (ReBAC, ADR 0013), built with `defineRelations` and the `direct` /
43
+ * `computed` / `from` / `union` / `intersection` / `exclusion` builders. Validated again here.
44
+ * Without it, relationship writes and checks throw `RelationSchemaError`.
45
+ */
46
+ relations?: S;
47
+ /**
48
+ * Roles that may grant / revoke / assign roles by default (an auth provider can override it).
49
+ * Default: the most privileged role (the last of `roles`).
50
+ */
51
+ managerRoles?: readonly R[];
52
+ /** Labels and descriptions for the admin panel. Missing entries default to the key. */
53
+ labels?: {
54
+ roles?: Partial<Record<R, LabelInput>>;
55
+ permissions?: Partial<Record<P, LabelInput>>;
56
+ };
57
+ /**
58
+ * When `true`, a non-expired grant whose name equals the checked path allows it outright
59
+ * (`reason: "grant"`), for catalogs whose assignable names are paths. Default `false`: grants
60
+ * only matter through the rules (ADR 0005).
61
+ */
62
+ directGrants?: boolean;
63
+ }
64
+ /**
65
+ * The configuration of {@link definePermissions}: the lib's `AuthorizationConfig` (roles ordered
66
+ * **least → most privileged**, `guestRole`, `defaultRole`, `assignable`, `rules`) without
67
+ * `getRole` (the engine sets the role), plus {@link CatalogMeta}.
68
+ */
69
+ type PermissionsConfig<D extends Definition, R extends string, P extends string, X, S extends RelationSchema = NoRelations> = Omit<AuthorizationConfig<D, R, P, PermissionsSubject, X>, "getRole"> & CatalogMeta<NoInfer<R>, NoInfer<P>, S>;
70
+ /** A catalog: the wrapped lib `Authorization` plus the product metadata. */
71
+ interface PermissionsCatalog<D extends Definition = Definition, R extends string = string, P extends string = string, X = undefined, S extends RelationSchema = RelationSchema> {
72
+ /** The lib authorization (`createAbility`, `createRules`, `parseRole`, …). */
73
+ readonly authorization: Authorization<D, R, P, PermissionsSubject, X>;
74
+ /** Every role, least → most privileged. */
75
+ readonly roles: readonly R[];
76
+ /** The role of a request without a subject. */
77
+ readonly guestRole: R;
78
+ /** The role of a signed-in subject whose role is missing or unknown. */
79
+ readonly defaultRole: R;
80
+ /** The assignable permissions. */
81
+ readonly assignable: readonly P[];
82
+ /** Roles that may manage permissions by default. */
83
+ readonly managerRoles: readonly R[];
84
+ /** Labels for every role and permission (defaulting to the key). */
85
+ readonly labels: {
86
+ readonly roles: Readonly<Record<R, Label>>;
87
+ readonly permissions: Readonly<Record<P, Label>>;
88
+ };
89
+ /** See {@link CatalogMeta.directGrants}. */
90
+ readonly directGrants: boolean;
91
+ /** The relation schema (ReBAC), `null` when the catalog declares none. */
92
+ readonly relations: S | null;
93
+ /** True when `value` is one of `roles`. */
94
+ isRole(value: unknown): value is R;
95
+ /** True when `value` is one of `assignable`. */
96
+ isAssignable(value: unknown): value is P;
97
+ /** True when `role` is one of `managerRoles`. */
98
+ isManagerRole(role: unknown): boolean;
99
+ /** A signed-in subject's role: `value` when it is a known non-guest role, else `defaultRole`. */
100
+ parseRole(value: unknown): R;
101
+ /**
102
+ * The effective role of a signed-in subject from what an auth provider reports: one role, several
103
+ * (an array, or a comma-separated string as better-auth's admin plugin stores them) → the most
104
+ * privileged known one; none known (or missing) → `defaultRole`. Never the guest role.
105
+ */
106
+ effectiveRole(raw: string | readonly string[] | null | undefined): R;
107
+ }
108
+ /**
109
+ * The permission type of a catalog: the `assignable` union, or `string` for a roles-only catalog
110
+ * (`assignable: []` infers `never`, which no generic `AnyPermissionsCatalog` slot accepts because
111
+ * rules are contravariant in it). Every permission is still rejected at runtime there.
112
+ */
113
+ type PermissionUnion<P extends string> = [P] extends [never] ? string : P;
114
+ /** Any catalog (for generic constraints). */
115
+ type AnyPermissionsCatalog = PermissionsCatalog<any, any, any, any, any>;
116
+ /** The permix definition of a catalog. */
117
+ type DefinitionOf<C> = C extends PermissionsCatalog<infer D, any, any, any, any> ? D : never;
118
+ /** The role union of a catalog. */
119
+ type RoleOf<C> = C extends {
120
+ readonly roles: readonly (infer R)[];
121
+ } ? R : never;
122
+ /** The assignable-permission union of a catalog. */
123
+ type PermissionOf<C> = C extends {
124
+ readonly assignable: readonly (infer P)[];
125
+ } ? P : never;
126
+ /** The rule context (`ctx`) type of a catalog. */
127
+ type CtxOf<C> = C extends PermissionsCatalog<any, any, any, infer X, any> ? X : never;
128
+ /** The relation schema of a catalog. */
129
+ type RelationsOf<C> = C extends PermissionsCatalog<any, any, any, any, infer S> ? S : never;
130
+ /**
131
+ * Define the catalog. Curried like the lib's `defineAuthorization`: the permix definition and the
132
+ * rule context type go in the first call, the roles and permissions are inferred by the second:
133
+ * `definePermissions<Definition, Ctx>()({ ... })`.
134
+ *
135
+ * Rules are synchronous (a rule that returns a Promise denies and throws `AsyncRuleError`); load
136
+ * what they need first and pass it as `ctx` or as the checked data. A rule wrapped in the lib's
137
+ * `asyncRule()` is evaluated only by the engine's async `check()` / `can()`, never by the
138
+ * synchronous `ability()` (ADR 0005).
139
+ *
140
+ * @throws {Error} When `guestRole`, `defaultRole` or a `managerRoles` entry is not in `roles`, a
141
+ * role has no rules, or the guest role is a manager role.
142
+ */
143
+ declare function definePermissions<D extends Definition, X = undefined>(): <const R extends string, const P extends string, const S extends RelationSchema = NoRelations>(config: PermissionsConfig<D, R, P, X, S>) => PermissionsCatalog<D, R, PermissionUnion<P>, X, S>;
144
+ /**
145
+ * Wrap an existing lib `Authorization` (from `defineAuthorization`) as a catalog. Its config is
146
+ * re-defined with `getRole: (subject) => subject.role`, so its rules receive a
147
+ * {@link PermissionsSubject} (`{ id, role, name?, email?, attributes? }`) as `user`; rules that read
148
+ * other user fields must move them into `attributes` or `ctx`.
149
+ */
150
+ declare function fromAuthorization<D extends Definition, R extends string, P extends string, X, const S extends RelationSchema = NoRelations>(authorization: Authorization<D, R, P, any, X>, meta?: CatalogMeta<NoInfer<R>, NoInfer<P>, S>): PermissionsCatalog<D, R, P, X, S>;
151
+ //#endregion
152
+ export { fromAuthorization as _, Label as a, PermissionOf as c, PermissionsConfig as d, PermissionsSubject as f, definePermissions as g, SubjectIdentity as h, DefinitionOf as i, PermissionUnion as l, RoleOf as m, CatalogMeta as n, LabelInput as o, RelationsOf as p, CtxOf as r, NoRelations as s, AnyPermissionsCatalog as t, PermissionsCatalog as u };
153
+ //# sourceMappingURL=catalog-DJcJ3ycq.d.mts.map