@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,432 @@
1
+ /**
2
+ * Elysia **2.x** adapter. Three pieces:
3
+ *
4
+ * 1. {@link permissionsPanel}: a web-standard handler for `Elysia.mount(path, handler)` (simplest,
5
+ * opaque to Eden).
6
+ *
7
+ * ```ts
8
+ * new Elysia().mount("/permissions", permissionsPanel({ permissions: perms, basePath: "/permissions" }));
9
+ * ```
10
+ *
11
+ * 2. {@link permissionsElysia}: a typed plugin that declares every route, so **Eden treaty**
12
+ * infers them (`client.permissions.api.grants.post({ subject, permission })`). Each handler
13
+ * delegates to the same pipeline (auth, authorization, validation); the engine is decorated as
14
+ * `permissions`.
15
+ *
16
+ * ```ts
17
+ * const app = new Elysia().use(permissionsElysia({ prefix: "/permissions", permissions: perms, provider }));
18
+ * const client = treaty<typeof app>("localhost:3000");
19
+ * await client.permissions.api.me.get();
20
+ * ```
21
+ *
22
+ * 3. {@link requirePermission}: a `beforeHandle` guard answering `401` / `403` JSON for denials and
23
+ * setting `ctx.permission`.
24
+ *
25
+ * Elysia 2.x only; for Elysia 1.x import from `@xtandard/permissions/elysia`.
26
+ *
27
+ * @module
28
+ */
29
+ import type { Definition } from "../policy.ts";
30
+ import { permissionsPanel, requirePermission, requireRelation, type ElysiaGuardContext, type ElysiaPermissionsHandler, type PermissionsElysiaOptions, type PermissionsPanelOptions, type RelationDecision, type RelationObjectInput, type RequirePermissionOptions, type RequireRelationOptions } from "./elysia-shared.ts";
31
+ export { permissionsPanel, requirePermission, requireRelation };
32
+ export type { ElysiaGuardContext, ElysiaPermissionsHandler, PermissionsElysiaOptions, PermissionsPanelOptions, RelationDecision, RelationObjectInput, RequirePermissionOptions, RequireRelationOptions, };
33
+ /**
34
+ * The typed plugin {@link permissionsElysia} returns: its route table is what Eden treaty infers
35
+ * from `typeof app`.
36
+ */
37
+ export type PermissionsElysiaPlugin = ReturnType<typeof permissionsElysiaRoutes>;
38
+ /**
39
+ * Typed Elysia plugin exposing the whole HTTP API for **Eden**. Every handler delegates to the
40
+ * shared fetch pipeline; a catch-all serves the bundled UI.
41
+ */
42
+ export declare function permissionsElysia<D extends Definition = Definition, R extends string = string, P extends string = string, X = undefined>(options: PermissionsElysiaOptions<D, R, P, X>): PermissionsElysiaPlugin;
43
+ /** The route declarations behind {@link permissionsElysia}. @internal */
44
+ declare function permissionsElysiaRoutes(options: PermissionsElysiaOptions): import("elysia/types").AddRoute<string, "local", {
45
+ decorator: {
46
+ permissions: import("../engine.ts").Permissions<Definition, string, string, undefined, import("@xtandard/lib/policy/rebac").RelationSchema>;
47
+ };
48
+ store: {};
49
+ derive: {};
50
+ }, {
51
+ typebox: {};
52
+ error: [];
53
+ }, import("elysia").DefaultMetadata, {
54
+ [x: string]: {
55
+ config: {
56
+ get: {
57
+ body: unknown;
58
+ params: {};
59
+ query: unknown;
60
+ headers: unknown;
61
+ response: {
62
+ 200: Response;
63
+ };
64
+ error: never;
65
+ };
66
+ };
67
+ };
68
+ } & {
69
+ [x: string]: {
70
+ api: {
71
+ config: {
72
+ get: {
73
+ body: unknown;
74
+ params: {};
75
+ query: unknown;
76
+ headers: unknown;
77
+ response: {
78
+ 200: Response;
79
+ };
80
+ error: never;
81
+ };
82
+ };
83
+ };
84
+ };
85
+ } & {
86
+ [x: string]: {
87
+ healthcheck: {
88
+ get: {
89
+ body: unknown;
90
+ params: {};
91
+ query: unknown;
92
+ headers: unknown;
93
+ response: {
94
+ 200: Response;
95
+ };
96
+ error: never;
97
+ };
98
+ };
99
+ };
100
+ } & {
101
+ [x: string]: {
102
+ api: {
103
+ "openapi.json": {
104
+ get: {
105
+ body: unknown;
106
+ params: {};
107
+ query: unknown;
108
+ headers: unknown;
109
+ response: {
110
+ 200: Response;
111
+ };
112
+ error: never;
113
+ };
114
+ };
115
+ };
116
+ };
117
+ } & {
118
+ [x: string]: {
119
+ api: {
120
+ catalog: {
121
+ get: {
122
+ body: unknown;
123
+ params: {};
124
+ query: unknown;
125
+ headers: unknown;
126
+ response: {
127
+ 200: Response;
128
+ };
129
+ error: never;
130
+ };
131
+ };
132
+ };
133
+ };
134
+ } & {
135
+ [x: string]: {
136
+ api: {
137
+ subjects: {
138
+ get: {
139
+ body: unknown;
140
+ params: {};
141
+ query: {
142
+ search?: string | undefined;
143
+ };
144
+ headers: unknown;
145
+ response: {
146
+ 200: Response;
147
+ 422: {
148
+ type: "validation";
149
+ code: "validation";
150
+ title: "Validation Error";
151
+ status: 422;
152
+ detail?: string;
153
+ on: string;
154
+ found?: unknown;
155
+ property?: string;
156
+ expected?: string;
157
+ };
158
+ };
159
+ error: never;
160
+ };
161
+ };
162
+ };
163
+ };
164
+ } & {
165
+ [x: string]: {
166
+ api: {
167
+ subjects: {
168
+ ":id": {
169
+ get: {
170
+ body: unknown;
171
+ params: {
172
+ id: string;
173
+ };
174
+ query: {
175
+ includeExpired?: string | undefined;
176
+ };
177
+ headers: unknown;
178
+ response: {
179
+ 200: Response;
180
+ 422: {
181
+ type: "validation";
182
+ code: "validation";
183
+ title: "Validation Error";
184
+ status: 422;
185
+ detail?: string;
186
+ on: string;
187
+ found?: unknown;
188
+ property?: string;
189
+ expected?: string;
190
+ };
191
+ };
192
+ error: never;
193
+ };
194
+ };
195
+ };
196
+ };
197
+ };
198
+ } & {
199
+ [x: string]: {
200
+ api: {
201
+ subjects: {
202
+ ":id": {
203
+ put: {
204
+ body: {
205
+ name?: string | null | undefined;
206
+ role?: string | null | undefined;
207
+ email?: string | null | undefined;
208
+ reason?: string | undefined;
209
+ };
210
+ params: {
211
+ id: string;
212
+ };
213
+ query: unknown;
214
+ headers: unknown;
215
+ response: {
216
+ 200: Response;
217
+ 422: {
218
+ type: "validation";
219
+ code: "validation";
220
+ title: "Validation Error";
221
+ status: 422;
222
+ detail?: string;
223
+ on: string;
224
+ found?: unknown;
225
+ property?: string;
226
+ expected?: string;
227
+ };
228
+ };
229
+ error: never;
230
+ };
231
+ };
232
+ };
233
+ };
234
+ };
235
+ } & {
236
+ [x: string]: {
237
+ api: {
238
+ grants: {
239
+ get: {
240
+ body: unknown;
241
+ params: {};
242
+ query: {
243
+ subject?: string | undefined;
244
+ permission?: string | undefined;
245
+ includeExpired?: string | undefined;
246
+ };
247
+ headers: unknown;
248
+ response: {
249
+ 200: Response;
250
+ 422: {
251
+ type: "validation";
252
+ code: "validation";
253
+ title: "Validation Error";
254
+ status: 422;
255
+ detail?: string;
256
+ on: string;
257
+ found?: unknown;
258
+ property?: string;
259
+ expected?: string;
260
+ };
261
+ };
262
+ error: never;
263
+ };
264
+ };
265
+ };
266
+ };
267
+ } & {
268
+ [x: string]: {
269
+ api: {
270
+ grants: {
271
+ post: {
272
+ body: {
273
+ reason?: string | undefined;
274
+ expiresAt?: string | number | null | undefined;
275
+ subject: string;
276
+ permission: string;
277
+ };
278
+ params: {};
279
+ query: unknown;
280
+ headers: unknown;
281
+ response: {
282
+ 200: Response;
283
+ 422: {
284
+ type: "validation";
285
+ code: "validation";
286
+ title: "Validation Error";
287
+ status: 422;
288
+ detail?: string;
289
+ on: string;
290
+ found?: unknown;
291
+ property?: string;
292
+ expected?: string;
293
+ };
294
+ };
295
+ error: never;
296
+ };
297
+ };
298
+ };
299
+ };
300
+ } & {
301
+ [x: string]: {
302
+ api: {
303
+ grants: {
304
+ ":subject": {
305
+ ":permission": {
306
+ delete: {
307
+ body: Partial<{
308
+ reason?: string | undefined;
309
+ }> | null | undefined;
310
+ params: {
311
+ subject: string;
312
+ permission: string;
313
+ };
314
+ query: {
315
+ reason?: string | undefined;
316
+ };
317
+ headers: unknown;
318
+ response: {
319
+ 200: Response;
320
+ 422: {
321
+ type: "validation";
322
+ code: "validation";
323
+ title: "Validation Error";
324
+ status: 422;
325
+ detail?: string;
326
+ on: string;
327
+ found?: unknown;
328
+ property?: string;
329
+ expected?: string;
330
+ };
331
+ };
332
+ error: never;
333
+ };
334
+ };
335
+ };
336
+ };
337
+ };
338
+ };
339
+ } & {
340
+ [x: string]: {
341
+ api: {
342
+ history: {
343
+ get: {
344
+ body: unknown;
345
+ params: {};
346
+ query: {
347
+ subject?: string | undefined;
348
+ limit?: string | undefined;
349
+ cursor?: string | undefined;
350
+ };
351
+ headers: unknown;
352
+ response: {
353
+ 200: Response;
354
+ 422: {
355
+ type: "validation";
356
+ code: "validation";
357
+ title: "Validation Error";
358
+ status: 422;
359
+ detail?: string;
360
+ on: string;
361
+ found?: unknown;
362
+ property?: string;
363
+ expected?: string;
364
+ };
365
+ };
366
+ error: never;
367
+ };
368
+ };
369
+ };
370
+ };
371
+ } & {
372
+ [x: string]: {
373
+ api: {
374
+ check: {
375
+ post: {
376
+ body: {
377
+ ctx?: unknown;
378
+ role?: string | undefined;
379
+ subject?: string | null | undefined;
380
+ data?: unknown;
381
+ path: string;
382
+ };
383
+ params: {};
384
+ query: unknown;
385
+ headers: unknown;
386
+ response: {
387
+ 200: Response;
388
+ 422: {
389
+ type: "validation";
390
+ code: "validation";
391
+ title: "Validation Error";
392
+ status: 422;
393
+ detail?: string;
394
+ on: string;
395
+ found?: unknown;
396
+ property?: string;
397
+ expected?: string;
398
+ };
399
+ };
400
+ error: never;
401
+ };
402
+ };
403
+ };
404
+ };
405
+ } & {
406
+ [x: string]: {
407
+ api: {
408
+ me: {
409
+ get: {
410
+ body: unknown;
411
+ params: {};
412
+ query: unknown;
413
+ headers: unknown;
414
+ response: {
415
+ 200: Response;
416
+ };
417
+ error: never;
418
+ };
419
+ };
420
+ };
421
+ };
422
+ }, import("elysia").DefaultEphemeral, import("elysia").DefaultEphemeral, "post", "/api/me/check", import("elysia/types").IntersectIfObjectSchema<import("elysia").UnwrapRoute<{
423
+ body: import("typebox").TObject<{
424
+ path: import("typebox").TString;
425
+ data: import("typebox").TOptional<import("typebox").TUnknown>;
426
+ }>;
427
+ }, {}, `${string}/api/me/check`>, import("elysia/types").MergeScopedSchemas<{}, {}, {}>>, {}, (ctx: import("@xtandard/kit/adapters/elysia").PassContext) => Promise<Response>, {
428
+ body: import("typebox").TObject<{
429
+ path: import("typebox").TString;
430
+ data: import("typebox").TOptional<import("typebox").TUnknown>;
431
+ }>;
432
+ }>;
@@ -0,0 +1,140 @@
1
+ /**
2
+ * Framework-agnostic core of the `requirePermission` guards (ADR 0008): resolve the subject from
3
+ * the framework's request context (your own resolver, or a `PermissionsAuthProvider`), decide the
4
+ * path with the engine, and either hand the decision on or answer the denial as JSON:
5
+ *
6
+ * - allowed → the {@link CheckResult} is attached to the context;
7
+ * - denied with no session → `401` `code: "NO_SUBJECT"` (a guest whose role allows passes);
8
+ * - denied → `403` `code: "FORBIDDEN"` with the decision.
9
+ *
10
+ * Every adapter wraps this; it imports no framework.
11
+ *
12
+ * @module
13
+ */
14
+ import type { PermissionsAuthProvider } from "../auth-provider/contract.ts";
15
+ import type { AnyPermissions, Permissions, SubjectInput } from "../engine.ts";
16
+ import type { RulesPaths } from "../policy.ts";
17
+ import type { CheckResult } from "../schema.ts";
18
+ /** What a guard needs from the engine (any `createPermissions` engine). */
19
+ export interface GuardEngine {
20
+ ability(subject: SubjectInput, ...facts: [] | [{
21
+ ctx?: unknown;
22
+ }]): Promise<{
23
+ checkAsync(path: string, data?: unknown): Promise<CheckResult>;
24
+ }>;
25
+ }
26
+ /** The typed permix paths of an engine's catalog (any string for an untyped engine). */
27
+ export type PathOf<E> = E extends Permissions<infer D, any, any, any> ? RulesPaths<D> : string;
28
+ /** An engine as the guard core sees it. */
29
+ export declare const guardEngine: (engine: AnyPermissions) => GuardEngine;
30
+ /** Options shared by every framework's `requirePermission` guard. */
31
+ export interface RequirePermissionOptions<Ctx> {
32
+ /**
33
+ * The subject of this request: an id, an identity (`{ id, role }`), or `null` / `undefined` for
34
+ * no session (the guest role). Required unless `provider` is given.
35
+ */
36
+ subject?: (ctx: Ctx) => SubjectInput | Promise<SubjectInput>;
37
+ /** Resolve the subject with an auth provider instead (better-auth, session, JWT…). */
38
+ provider?: PermissionsAuthProvider;
39
+ /** The data the rule at the path reads (e.g. the loaded resource). */
40
+ data?: (ctx: Ctx) => unknown;
41
+ /** The rules' `ctx`, for catalogs whose rules read app facts. */
42
+ ctx?: (ctx: Ctx) => unknown;
43
+ /** Build the denial response yourself (e.g. a redirect or an HTML page). */
44
+ onDenied?: (denial: GuardDenial, ctx: Ctx) => Response | Promise<Response>;
45
+ }
46
+ /** A denied guard: the status, the JSON body and the decision. */
47
+ export interface GuardDenial {
48
+ status: 401 | 403;
49
+ body: Record<string, unknown>;
50
+ result: CheckResult;
51
+ }
52
+ /** Outcome of {@link evaluateGuard}. */
53
+ export type GuardOutcome = {
54
+ allowed: true;
55
+ result: CheckResult;
56
+ } | ({
57
+ allowed: false;
58
+ } & GuardDenial);
59
+ /** The JSON status and body of a denied decision. */
60
+ export declare function denialOf(result: CheckResult): GuardDenial;
61
+ /** A web `Response` for a denial. */
62
+ export declare const denialResponse: (denial: GuardDenial) => Response;
63
+ /**
64
+ * Run the guard for one request context. Never throws for a denial; errors from the resolvers,
65
+ * the provider or the engine (an empty subject id: `NoSubjectError`) propagate.
66
+ *
67
+ * @param requestOf How to get a web `Request` from the context (for `provider`).
68
+ */
69
+ export declare function evaluateGuard<Ctx>(engine: GuardEngine, path: string, options: RequirePermissionOptions<Ctx>, ctx: Ctx, requestOf?: (ctx: Ctx) => Request): Promise<GuardOutcome>;
70
+ /** The response for a denied outcome (honoring `onDenied`). */
71
+ export declare function outcomeResponse<Ctx>(outcome: Extract<GuardOutcome, {
72
+ allowed: false;
73
+ }>, options: RequirePermissionOptions<Ctx>, ctx: Ctx): Promise<Response>;
74
+ /**
75
+ * Wrap a web-standard handler `(request, decision, ...extra) => Response` with a guard: the shape
76
+ * `Bun.serve` routes and Next.js route handlers share.
77
+ */
78
+ export declare function guardFetch<Extra extends unknown[] = []>(engine: GuardEngine, path: string, options: RequirePermissionOptions<Request>, handler: (request: Request, decision: CheckResult, ...extra: Extra) => Response | Promise<Response>): (request: Request, ...extra: Extra) => Promise<Response>;
79
+ /** What a relationship guard needs from the engine. */
80
+ export interface RelationGuardEngine {
81
+ checkRelation(query: {
82
+ subject: string;
83
+ relation: string;
84
+ object: string;
85
+ }): Promise<{
86
+ allowed: boolean;
87
+ path: string[];
88
+ }>;
89
+ }
90
+ /** An engine as the relationship guard sees it. */
91
+ export declare const relationGuardEngine: (engine: AnyPermissions) => RelationGuardEngine;
92
+ /** The decision of a relationship guard. */
93
+ export interface RelationDecision {
94
+ allowed: boolean;
95
+ /** The ReBAC subject (`user:ana`), `null` without a session. */
96
+ subject: string | null;
97
+ relation: string;
98
+ object: string;
99
+ /** When allowed, the chain of relations that granted it. */
100
+ path: string[];
101
+ }
102
+ /** The object a relationship guard checks: fixed, or from the request (`doc:${params.id}`). */
103
+ export type RelationObjectInput<Ctx> = string | ((ctx: Ctx) => string | Promise<string>);
104
+ /** Options shared by every framework's `requireRelation` guard. */
105
+ export interface RequireRelationOptions<Ctx> {
106
+ /** The subject of this request (an id or identity; `null` / `undefined`: no session → 401). */
107
+ subject?: (ctx: Ctx) => SubjectInput | Promise<SubjectInput>;
108
+ /** Resolve the subject with an auth provider instead. */
109
+ provider?: PermissionsAuthProvider;
110
+ /** The subject id → its ReBAC reference. Default `user:{id}`. */
111
+ subjectRef?: (id: string) => string;
112
+ /** Build the denial response yourself. */
113
+ onDenied?: (denial: RelationDenial, ctx: Ctx) => Response | Promise<Response>;
114
+ }
115
+ /** A denied relationship guard. */
116
+ export interface RelationDenial {
117
+ status: 401 | 403;
118
+ body: Record<string, unknown>;
119
+ result: RelationDecision;
120
+ }
121
+ /** Outcome of {@link evaluateRelationGuard}. */
122
+ export type RelationGuardOutcome = {
123
+ allowed: true;
124
+ result: RelationDecision;
125
+ } | ({
126
+ allowed: false;
127
+ } & RelationDenial);
128
+ /** The JSON status and body of a denied relationship decision. */
129
+ export declare function relationDenialOf(result: RelationDecision): RelationDenial;
130
+ /**
131
+ * Run a relationship guard for one request context: resolve the subject, map it to a ReBAC
132
+ * reference, resolve the object and `checkRelation`. Never throws for a denial.
133
+ */
134
+ export declare function evaluateRelationGuard<Ctx>(engine: RelationGuardEngine, relation: string, object: RelationObjectInput<Ctx>, options: RequireRelationOptions<Ctx>, ctx: Ctx, requestOf?: (ctx: Ctx) => Request): Promise<RelationGuardOutcome>;
135
+ /** The response for a denied relationship outcome (honoring `onDenied`). */
136
+ export declare function relationOutcomeResponse<Ctx>(outcome: Extract<RelationGuardOutcome, {
137
+ allowed: false;
138
+ }>, options: RequireRelationOptions<Ctx>, ctx: Ctx): Promise<Response>;
139
+ /** Wrap a web-standard handler `(request, decision, ...extra)` with a relationship guard. */
140
+ export declare function guardFetchRelation<Extra extends unknown[] = []>(engine: RelationGuardEngine, relation: string, object: RelationObjectInput<Request>, options: RequireRelationOptions<Request>, handler: (request: Request, decision: RelationDecision, ...extra: Extra) => Response | Promise<Response>): (request: Request, ...extra: Extra) => Promise<Response>;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Authentication contract of the panel. Answers: "Who is this request from?"
3
+ *
4
+ * The kit's `AuthProvider`: `none` / `basic` / `delegated` ship here; a `PermissionsAuthProvider`
5
+ * (better-auth, session, JWT) plugs in through `toKitAuth(provider, perms)` (ADR 0006).
6
+ *
7
+ * @module
8
+ */
9
+ export type { AuthProvider, Principal } from "@xtandard/kit/auth";
@@ -0,0 +1,85 @@
1
+ /**
2
+ * The auth provider contract (ADR 0006). Answers two questions for the engine, the panel and the
3
+ * router: "who is calling, and what role does their auth library give them?" and "may they manage
4
+ * grants?".
5
+ *
6
+ * `@xtandard/permissions` ships `auth/better-auth`, `auth/session` and `auth/jwt` implementations;
7
+ * any object satisfying {@link PermissionsAuthProvider} works. {@link toKitAuth} adapts one to the
8
+ * kit's `AuthProvider` + `AuthorizationProvider`.
9
+ *
10
+ * @module
11
+ */
12
+ import type { PermissionsSubject, SubjectIdentity } from "../catalog.ts";
13
+ export type { PermissionsSubject, SubjectIdentity };
14
+ /** Resolves the caller of a request. Implement it once per auth library. */
15
+ export interface PermissionsAuthProvider {
16
+ /**
17
+ * Who is calling? `null` = no session (the guest role for checks, 401 for manage routes). A throw
18
+ * is a server error (500), never "no session". The id must not be empty.
19
+ */
20
+ getSubject(request: Request): Promise<SubjectIdentity | null> | SubjectIdentity | null;
21
+ /**
22
+ * May this subject grant, revoke and set roles? `subject.role` is the effective role. Default:
23
+ * the role is one of the catalog's `managerRoles`.
24
+ */
25
+ canManage?(subject: PermissionsSubject, request: Request): boolean | Promise<boolean>;
26
+ /**
27
+ * Look a subject up by id, without a request (ADR 0014): the provider's identity, with the role
28
+ * as `getSubject` would report it, or `null` for an unknown id. Pass it to the engine's
29
+ * `lookupSubject` so checks by id and the panel see the provider's role of any subject.
30
+ */
31
+ lookupSubject?(id: string): Promise<SubjectIdentity | null> | SubjectIdentity | null;
32
+ }
33
+ /** A by-id lookup a provider can't do on its own (`sessionProvider` / `jwtProvider` `lookup`). */
34
+ export type SubjectLookupFn = (id: string) => SubjectIdentity | null | undefined | Promise<SubjectIdentity | null | undefined>;
35
+ /**
36
+ * The engine options that hand role ownership to an auth provider (ADR 0014):
37
+ * `{ roleSource: "external", lookupSubject }`.
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * const provider = betterAuthProvider(auth);
42
+ * const perms = createPermissions({ catalog, storage, ...externalRoles(provider) });
43
+ * ```
44
+ */
45
+ export declare function externalRoles(provider: Pick<PermissionsAuthProvider, "lookupSubject">): {
46
+ roleSource: "external";
47
+ lookupSubject: ((id: string) => Promise<SubjectIdentity | null>) | undefined;
48
+ };
49
+ /**
50
+ * Wrap a user-supplied lookup like `getSubject`'s result: roles split and mapped, empty fields
51
+ * dropped. `null` for an unknown id.
52
+ * @internal
53
+ */
54
+ export declare function mappedLookup(lookup: SubjectLookupFn, mapRole: RoleMapper | undefined): (id: string) => Promise<SubjectIdentity | null>;
55
+ /**
56
+ * Renames raw roles from the auth library before the catalog parses them: a map
57
+ * (`{ user: "member", "org:admin": "admin" }`, unmapped roles pass through) or a function
58
+ * (return `null`/`undefined` to drop a role).
59
+ */
60
+ export type RoleMapper = Readonly<Record<string, string>> | ((role: string) => string | null | undefined);
61
+ /** Options every bundled provider accepts. */
62
+ export interface ProviderRoleOptions {
63
+ /** Rename the library's roles to catalog roles. */
64
+ mapRole?: RoleMapper;
65
+ /** Override who may manage grants (see {@link PermissionsAuthProvider.canManage}). */
66
+ canManage?: PermissionsAuthProvider["canManage"];
67
+ }
68
+ /**
69
+ * Normalize a raw role value: a string is split on commas (better-auth stores `"admin,user"`), an
70
+ * array is flattened the same way, entries are trimmed and empties dropped. Non-strings are
71
+ * ignored.
72
+ */
73
+ export declare function splitRoles(raw: unknown): string[];
74
+ /** {@link splitRoles} then {@link RoleMapper}; `null` when nothing is left. */
75
+ export declare function normalizeRoles(raw: unknown, mapRole?: RoleMapper): string[] | null;
76
+ /** A string field of an unknown record, or `undefined`. */
77
+ export declare function stringField(source: unknown, key: string): string | undefined;
78
+ /** Build an identity, leaving out empty optional fields (exactOptionalPropertyTypes-friendly). */
79
+ export declare function identity(fields: {
80
+ id: string;
81
+ role?: string | readonly string[] | null | undefined;
82
+ name?: string | null | undefined;
83
+ email?: string | null | undefined;
84
+ attributes?: Record<string, unknown> | undefined;
85
+ }): SubjectIdentity;