@xtandard/permissions 0.0.0-stage → 0.1.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 +362 -2
  3. package/bin/xtandard-permissions.mjs +3 -0
  4. package/dist/better-auth-Bp9YVyQa.d.cts +56 -0
  5. package/dist/better-auth-DHyW5-yt.cjs +91 -0
  6. package/dist/better-auth-DHyW5-yt.cjs.map +1 -0
  7. package/dist/better-auth-NO40ZqSM.mjs +74 -0
  8. package/dist/better-auth-NO40ZqSM.mjs.map +1 -0
  9. package/dist/better-auth-NSXgt6ZU.d.mts +56 -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 +548 -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 +544 -0
  24. package/dist/cli.mjs.map +1 -0
  25. package/dist/contract-BMiOmg2f.d.cts +50 -0
  26. package/dist/contract-Bpy8yPrS.cjs +70 -0
  27. package/dist/contract-Bpy8yPrS.cjs.map +1 -0
  28. package/dist/contract-CNgMXr2u.d.cts +46 -0
  29. package/dist/contract-CNgMXr2u.d.mts +46 -0
  30. package/dist/contract-CPmJVoRx.cjs +70 -0
  31. package/dist/contract-CPmJVoRx.cjs.map +1 -0
  32. package/dist/contract-D32H1t0u.d.mts +50 -0
  33. package/dist/contract-DTdTXZtJ.mjs +47 -0
  34. package/dist/contract-DTdTXZtJ.mjs.map +1 -0
  35. package/dist/contract-DUzgB-He.d.mts +375 -0
  36. package/dist/contract-Dk6d2ylD.d.cts +375 -0
  37. package/dist/contract-RMkmERhT.d.cts +2 -0
  38. package/dist/contract-RMkmERhT.d.mts +2 -0
  39. package/dist/contract-Yc5AZuvv.mjs +47 -0
  40. package/dist/contract-Yc5AZuvv.mjs.map +1 -0
  41. package/dist/create-fetch-handler-BHDU4chu.d.mts +77 -0
  42. package/dist/create-fetch-handler-BtX64_rS.d.cts +77 -0
  43. package/dist/create-fetch-handler-C-WyaRCR.cjs +653 -0
  44. package/dist/create-fetch-handler-C-WyaRCR.cjs.map +1 -0
  45. package/dist/create-fetch-handler-ojjpk1Iw.mjs +636 -0
  46. package/dist/create-fetch-handler-ojjpk1Iw.mjs.map +1 -0
  47. package/dist/elysia-shared-BM6cPoCU.mjs +78 -0
  48. package/dist/elysia-shared-BM6cPoCU.mjs.map +1 -0
  49. package/dist/elysia-shared-BUTFTeal.cjs +101 -0
  50. package/dist/elysia-shared-BUTFTeal.cjs.map +1 -0
  51. package/dist/elysia-shared-DtKViycb.d.cts +58 -0
  52. package/dist/elysia-shared-g8zsb_pU.d.mts +58 -0
  53. package/dist/engine-Bufv0TbD.mjs +574 -0
  54. package/dist/engine-Bufv0TbD.mjs.map +1 -0
  55. package/dist/engine-CGGVDCqi.d.cts +296 -0
  56. package/dist/engine-DpFIcbgh.d.mts +296 -0
  57. package/dist/engine-bMoz3iW-.cjs +587 -0
  58. package/dist/engine-bMoz3iW-.cjs.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 +12 -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 +116 -0
  74. package/dist/entry-auth-jwt.cjs.map +1 -0
  75. package/dist/entry-auth-jwt.d.cts +65 -0
  76. package/dist/entry-auth-jwt.d.mts +65 -0
  77. package/dist/entry-auth-jwt.mjs +108 -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 +82 -0
  84. package/dist/entry-auth-session.cjs.map +1 -0
  85. package/dist/entry-auth-session.d.cts +20 -0
  86. package/dist/entry-auth-session.d.mts +20 -0
  87. package/dist/entry-auth-session.mjs +75 -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-bL3XQLfE.mjs +54 -0
  258. package/dist/errors-bL3XQLfE.mjs.map +1 -0
  259. package/dist/errors-vVYic8gz.cjs +89 -0
  260. package/dist/errors-vVYic8gz.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-BOx5cnMP.mjs +141 -0
  268. package/dist/guard-BOx5cnMP.mjs.map +1 -0
  269. package/dist/guard-C3o7V14m.d.cts +62 -0
  270. package/dist/guard-DCbTnqPz.d.mts +62 -0
  271. package/dist/guard-nwdOYe90.cjs +188 -0
  272. package/dist/guard-nwdOYe90.cjs.map +1 -0
  273. package/dist/index-BVVgDSdq.d.cts +1 -0
  274. package/dist/index-BVVgDSdq.d.mts +1 -0
  275. package/dist/index.cjs +240 -0
  276. package/dist/index.cjs.map +1 -0
  277. package/dist/index.d.cts +195 -0
  278. package/dist/index.d.mts +195 -0
  279. package/dist/index.mjs +60 -0
  280. package/dist/index.mjs.map +1 -0
  281. package/dist/kit-C7tepDB2.cjs +76 -0
  282. package/dist/kit-C7tepDB2.cjs.map +1 -0
  283. package/dist/kit-DMVBLBI9.d.mts +57 -0
  284. package/dist/kit-fzXHYb1l.mjs +65 -0
  285. package/dist/kit-fzXHYb1l.mjs.map +1 -0
  286. package/dist/kit-qAROuhOI.d.cts +57 -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-C9PjftY6.mjs +59 -0
  292. package/dist/permissions-C9PjftY6.mjs.map +1 -0
  293. package/dist/permissions-Cxri_P_k.cjs +70 -0
  294. package/dist/permissions-Cxri_P_k.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 +18710 -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-DtRb3EO0.mjs +1001 -0
  310. package/dist/routes-DtRb3EO0.mjs.map +1 -0
  311. package/dist/routes-irNuuZqo.cjs +1049 -0
  312. package/dist/routes-irNuuZqo.cjs.map +1 -0
  313. package/dist/server-C2F4H6bR.d.cts +886 -0
  314. package/dist/server-CJ7AIJpO.d.mts +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 +57 -0
  328. package/dist/types-elysia2/auth-provider/kit.d.ts +57 -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 +192 -0
  333. package/dist/types-elysia2/entry-elysia2.d.ts +9 -0
  334. package/dist/types-elysia2/errors.d.ts +47 -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 +299 -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 +132 -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 +192 -0
  348. package/dist/types-react/entry-react-embed.d.ts +20 -0
  349. package/dist/types-react/errors.d.ts +47 -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 +299 -0
  356. package/dist/types-react/storage/contract.d.ts +18 -0
  357. package/dist/types-react/ui/App.d.ts +23 -0
  358. package/dist/types-react/ui/api.d.ts +73 -0
  359. package/dist/types-react/ui/components/perm-bits.d.ts +64 -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 +109 -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-uXGOtyuj.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,37 @@
1
+ /**
2
+ * `@xtandard/permissions/react/embed` — the admin panel as a React component,
3
+ * for hosts that want it inside their own React tree instead of the bundled
4
+ * SPA the adapters serve.
5
+ *
6
+ * ```tsx
7
+ * import { PermissionsDashboard } from "@xtandard/permissions/react/embed";
8
+ * import "@xtandard/permissions/react/styles.css";
9
+ *
10
+ * <PermissionsDashboard apiBaseUrl="/permissions" />
11
+ * ```
12
+ *
13
+ * `react` and `react-dom` are peers; everything else (TanStack Query, Base UI,
14
+ * styles) is bundled. The stylesheet is scoped under `.xtandard-permissions`, so
15
+ * it cannot leak into the host. For gating your own UI (`useCan`, `<Can>`), use
16
+ * the much smaller `@xtandard/permissions/react` instead.
17
+ *
18
+ * @module
19
+ */
20
+ import type { FetchLike } from "@xtandard/kit/ui";
21
+ import { type EmbedBaseProps } from "@xtandard/kit/ui/embed";
22
+ import "./ui/styles.css";
23
+ export type { EmbedRouting, EmbedTheme } from "@xtandard/kit/ui/embed";
24
+ /**
25
+ * Props for {@link PermissionsDashboard}: `apiBaseUrl` (where the panel is mounted), `credentials`
26
+ * (`"include"` for a cross-origin cookie embed, with `cors` on the panel), a custom `fetch`, a
27
+ * `queryClient`, `theme` (`"auto"` | `"inherit"` | `"light"` | `"dark"`), `routing` (`"hash"` by
28
+ * default, `"browser"` under `routerBase`, `"memory"`, or a wouter hook), `logoUrl` and `className`.
29
+ */
30
+ export interface PermissionsDashboardProps extends EmbedBaseProps {
31
+ }
32
+ /** The admin panel (Subjects, Catalog, Check, History) as a React component. */
33
+ export declare const PermissionsDashboard: React.FC<PermissionsDashboardProps>;
34
+ export { setApiBase, setApiToken } from "./ui/api.ts";
35
+ export type { FetchLike };
36
+ export { setThemePref, getThemePref, detectHostTheme, type ThemePref, type ResolvedTheme, } from "./ui/theme.ts";
37
+ export default PermissionsDashboard;
@@ -0,0 +1,162 @@
1
+ /**
2
+ * Relationships (ReBAC, ADR 0013): the tuple store, the tuple reader the lib's checker plugs into,
3
+ * `checkRelation`, `listObjects`, `listRelationSubjects` and the synchronous preload for rules.
4
+ * **The lib evaluates** (`@xtandard/lib/policy/rebac`: schema, `check`, `explain`, reverse edges);
5
+ * this module stores, indexes and lists. The engine (`createPermissions`) mixes these methods in.
6
+ *
7
+ * Storage: one forward key per tuple, `perm/rel/{objectType}/{objectId}/{relation}/{subject}`
8
+ * (unique on every driver, so writes are idempotent), plus a reverse key per tuple under
9
+ * `perm/relrev/{subjectType}/{subjectId}/{_ | #relation}/…` for listing. A write sets the forward
10
+ * key, then the reverse key; a delete removes the reverse key, then the forward key. So a crash
11
+ * between the two leaves a forward key without its reverse (listing misses the tuple; checks still
12
+ * see it), never the other way round; `repairRelationships()` restores the invariant.
13
+ *
14
+ * @module
15
+ */
16
+ import type { Actor } from "@xtandard/kit/util";
17
+ import { type HookErrorReporter, type PermissionsHooks } from "./hooks/contract.ts";
18
+ import { type ObjectRef, type RelationExplanation, type RelationExpr, type RelationSchema, type RelationTuple, type SubjectRef, type TupleReadContext } from "./policy.ts";
19
+ import { type HistoryEntry, type Relationship, type RelationshipInput, type RelationshipPage, type RelationshipQuery } from "./schema.ts";
20
+ import { type PermissionsStorage } from "./storage/contract.ts";
21
+ /** A relationship check: does `subject` have `relation` on `object`? */
22
+ export interface RelationCheckQuery<S extends RelationSchema = RelationSchema> {
23
+ /** `"user:ana"`, or a userset such as `"group:eng#member"`. */
24
+ subject: SubjectRef<S>;
25
+ /** A relation of the object's type. */
26
+ relation: string;
27
+ /** `"doc:1"`. */
28
+ object: ObjectRef<S>;
29
+ }
30
+ /** What `checkRelation()` returns: the lib's explanation (the chain of relations that granted it). */
31
+ export type RelationCheckResult = RelationExplanation;
32
+ /** Query of `listObjects()`: the objects of `type` on which `subject` has `relation`. */
33
+ export interface ListObjectsQuery<S extends RelationSchema = RelationSchema> {
34
+ subject: SubjectRef<S>;
35
+ relation: string;
36
+ type: keyof S & string;
37
+ }
38
+ /** Query of `listRelationSubjects()`: who has `relation` on `object`. */
39
+ export interface ListRelationSubjectsQuery<S extends RelationSchema = RelationSchema> {
40
+ object: ObjectRef<S>;
41
+ relation: string;
42
+ /** Only subjects of this type (`"user"`). */
43
+ type?: keyof S & string;
44
+ }
45
+ /** What `writeRelationship()` returns. */
46
+ export interface WriteRelationshipResult {
47
+ relationship: Relationship;
48
+ /** `false` when the tuple was already stored (no history, no hooks). */
49
+ created: boolean;
50
+ }
51
+ /** What `deleteRelationship()` returns. */
52
+ export interface DeleteRelationshipResult {
53
+ /** `false` when there was nothing to delete. */
54
+ removed: boolean;
55
+ relationship: Relationship | null;
56
+ }
57
+ /** What `repairRelationships()` found and fixed. */
58
+ export interface RepairReport {
59
+ /** Forward keys scanned. */
60
+ scanned: number;
61
+ /** Reverse keys written for forward keys that had none. */
62
+ restored: number;
63
+ /** Reverse keys removed because their forward key is gone. */
64
+ removed: number;
65
+ }
66
+ /**
67
+ * Relationships preloaded for synchronous checks (inside permix rules, which stay synchronous,
68
+ * ADR 0005). Built by `loadRelations(objects)`: every tuple of those objects and of every object
69
+ * reachable from them (usersets, `from` parents) is in memory, so checks against those objects
70
+ * need no I/O. A check against an object that was not loaded sees no tuples (denied).
71
+ */
72
+ export interface RelationFacts<S extends RelationSchema = RelationSchema> {
73
+ /** `true` when `subject` has `relation` on `object` (synchronous). */
74
+ check(query: RelationCheckQuery<S>): boolean;
75
+ /** `check` with the chain of relations that granted it. */
76
+ explain(query: RelationCheckQuery<S>): RelationExplanation;
77
+ /** Shorthand for rules: `relation("user:ana", "editor", "doc:1")`. */
78
+ relation(subject: SubjectRef<S>, relation: string, object: ObjectRef<S>): boolean;
79
+ /** The loaded tuples. */
80
+ tuples(): RelationTuple[];
81
+ }
82
+ /** Options of `loadRelations()`. */
83
+ export interface LoadRelationsOptions {
84
+ /** Stop after loading this many objects (default 1 000). */
85
+ maxObjects?: number;
86
+ }
87
+ /** ReBAC options of the engine. */
88
+ export interface RelationsOptions {
89
+ /** Maximum relation hops per check and per listing walk (the lib's `maxDepth`). Default 25. */
90
+ maxDepth?: number;
91
+ }
92
+ /** The relationship methods of the engine. */
93
+ export interface RelationshipsApi<S extends RelationSchema = RelationSchema> {
94
+ /**
95
+ * Store a relationship. Validated against the catalog's relation schema (`isAllowedTuple`).
96
+ * Idempotent: a stored tuple comes back with `created: false` (no history, no hooks).
97
+ *
98
+ * @throws {RelationSchemaError} no `relations` in the catalog, or a tuple the schema doesn't
99
+ * allow. `ValidationError` malformed input. `ReadonlyError`.
100
+ */
101
+ writeRelationship(input: RelationshipInput): Promise<WriteRelationshipResult>;
102
+ /** Delete a relationship. Idempotent (`removed: false` when absent). */
103
+ deleteRelationship(input: RelationshipInput): Promise<DeleteRelationshipResult>;
104
+ /**
105
+ * Stored relationships by object (`doc:1`, or a bare type `doc`), relation and/or subject,
106
+ * sorted by key (object type, id, relation, subject), paginated by `cursor`.
107
+ */
108
+ readRelationships(query?: RelationshipQuery): Promise<RelationshipPage>;
109
+ /** Does `subject` have `relation` on `object`? With the chain of relations that decided it. */
110
+ checkRelation(query: RelationCheckQuery<S>, context?: TupleReadContext): Promise<RelationCheckResult>;
111
+ /**
112
+ * The objects of `type` on which `subject` has `relation`, sorted: a walk backwards over the
113
+ * reverse index (bounded by `maxDepth`); candidates reached through an intersection or an
114
+ * exclusion are confirmed with `checkRelation`.
115
+ */
116
+ listObjects(query: ListObjectsQuery<S>): Promise<string[]>;
117
+ /**
118
+ * The subjects (plain objects and `type:*` wildcards; usersets are expanded) that have
119
+ * `relation` on `object`, sorted. Candidates under an intersection or an exclusion are
120
+ * confirmed with `checkRelation`.
121
+ */
122
+ listRelationSubjects(query: ListRelationSubjectsQuery<S>): Promise<string[]>;
123
+ /** Preload the tuples around `objects` for synchronous checks (see {@link RelationFacts}). */
124
+ loadRelations(objects: readonly ObjectRef<S>[], options?: LoadRelationsOptions): Promise<RelationFacts<S>>;
125
+ /** Restore the forward ⊇ reverse key invariant after a crash or a partial copy. */
126
+ repairRelationships(): Promise<RepairReport>;
127
+ }
128
+ /** What the engine hands this module. */
129
+ export interface RelationshipsDeps {
130
+ storage: PermissionsStorage;
131
+ schema: RelationSchema | null;
132
+ options: RelationsOptions | undefined;
133
+ hooks: PermissionsHooks[];
134
+ onHookError: HookErrorReporter;
135
+ nowIso: () => string;
136
+ assertWritable: (operation: string) => void;
137
+ withLock: <T>(key: string, fn: () => Promise<T>) => Promise<T>;
138
+ appendHistory: (entry: Omit<HistoryEntry, "id" | "at">, at: string) => Promise<void>;
139
+ toActor: (actor: string | Actor | null | undefined) => Actor | null;
140
+ }
141
+ /** Build the relationship methods over the engine's plumbing. */
142
+ export declare function createRelationships<S extends RelationSchema>(deps: RelationshipsDeps): RelationshipsApi<S>;
143
+ /** One relation of a type, as the panel shows it. */
144
+ export interface RelationView {
145
+ name: string;
146
+ /**
147
+ * What may be stored on it (`"user"`, `"group#member"`, `"user:*"`); empty for a relation that
148
+ * is only computed (it can't be written).
149
+ */
150
+ subjects: string[];
151
+ /** A one-line rendering of the rule: `[user, group#member] or editor or viewer from parent`. */
152
+ rule: string;
153
+ }
154
+ /** One object type and its relations. */
155
+ export interface RelationTypeView {
156
+ type: string;
157
+ relations: RelationView[];
158
+ }
159
+ /** Render a relation expression on one line. */
160
+ export declare function describeRelation(expr: RelationExpr): string;
161
+ /** The relation schema as plain data (types, relations, writable subject types, rules). */
162
+ export declare function relationSchemaView(schema: RelationSchema): RelationTypeView[];
@@ -0,0 +1,299 @@
1
+ /**
2
+ * The data model (what is stored and what checks return) and the valibot
3
+ * schemas of the engine's write inputs. The engine validates every write with
4
+ * them, and the HTTP layer reuses them for request bodies.
5
+ *
6
+ * @module schema
7
+ */
8
+ import type { Actor } from "@xtandard/kit/util";
9
+ import * as v from "valibot";
10
+ import type { CheckExplanation } from "./policy.ts";
11
+ export type { Actor };
12
+ /** A permission granted to one subject. Stored at `perm/grants/{subject}/{permission}`. */
13
+ export interface Grant<P extends string = string> {
14
+ /** The subject id. */
15
+ subject: string;
16
+ /** The permission (one of the catalog's `assignable`). */
17
+ permission: P;
18
+ /** The actor id that granted it: plain data, never a reference (ADR 0003). */
19
+ grantedBy: string | null;
20
+ /** ISO-8601. */
21
+ grantedAt: string;
22
+ /** Why it was granted. */
23
+ reason?: string;
24
+ /** ISO-8601; the grant stops counting at this instant. `null` / absent: never expires. */
25
+ expiresAt?: string | null;
26
+ }
27
+ /** Optional per-subject data. Stored at `perm/subjects/{subject}`. */
28
+ export interface SubjectRecord {
29
+ id: string;
30
+ /** A stored role assignment; when absent, the auth provider's role (or `defaultRole`) applies. */
31
+ role?: string;
32
+ name?: string;
33
+ email?: string;
34
+ /** ISO-8601. */
35
+ updatedAt: string;
36
+ }
37
+ /**
38
+ * A stored relationship (ReBAC tuple, ADR 0013): `subject` has `relation` on `object`. Stored at
39
+ * `perm/rel/{objectType}/{objectId}/{relation}/{subject}`, plus a reverse key for listing.
40
+ */
41
+ export interface Relationship {
42
+ /** The object: `"doc:1"`. */
43
+ object: string;
44
+ /** A relation of the object's type: `"viewer"`. */
45
+ relation: string;
46
+ /** Who: `"user:ana"`, a userset `"group:eng#member"`, or a wildcard `"user:*"`. */
47
+ subject: string;
48
+ /** The actor id that wrote it: plain data, never a reference (ADR 0003). */
49
+ createdBy: string | null;
50
+ /** ISO-8601. */
51
+ createdAt: string;
52
+ /** Why it was written. */
53
+ reason?: string;
54
+ }
55
+ /** The kinds of {@link HistoryEntry}. */
56
+ export type HistoryType = "grant" | "revoke" | "role" | "relate" | "unrelate";
57
+ /**
58
+ * One append-only history entry. Stored at `perm/history/{subject}/{at}-{id}`; for `relate` /
59
+ * `unrelate` the subject is the tuple's subject reference (`user:ana`, `group:eng#member`).
60
+ */
61
+ export interface HistoryEntry {
62
+ id: string;
63
+ type: HistoryType;
64
+ subject: string;
65
+ /** For `relate` / `unrelate`: the tuple's object. */
66
+ object?: string;
67
+ /** For `relate` / `unrelate`: the tuple's relation. */
68
+ relation?: string;
69
+ /** For `grant` / `revoke`. */
70
+ permission?: string;
71
+ /** For `role`: the new role, `null` when the assignment was cleared. */
72
+ role?: string | null;
73
+ /** For `role`: the role before the change (`null`: none was stored). */
74
+ previousRole?: string | null;
75
+ /** For `grant`: the expiry the grant was created with. */
76
+ expiresAt?: string | null;
77
+ /** The actor id. */
78
+ actor: string | null;
79
+ reason?: string;
80
+ /** ISO-8601. */
81
+ at: string;
82
+ }
83
+ /**
84
+ * Why a check came out the way it did (ADR 0005):
85
+ *
86
+ * - `grant`: `directGrants` is on and a non-expired grant named like the path allowed it;
87
+ * - `role-rule`: the role's rule allowed it;
88
+ * - `denied-by-rule`: the role's rule denied it (a `false` constant or a predicate that did not
89
+ * return `true`);
90
+ * - `rule-threw`: the rule threw (denied);
91
+ * - `unknown-path`: the role has no rule at that path (denied).
92
+ */
93
+ export type CheckReason = "grant" | "role-rule" | "denied-by-rule" | "rule-threw" | "unknown-path";
94
+ /** The outcome of `check()`. */
95
+ export interface CheckResult<R extends string = string, P extends string = string> {
96
+ allowed: boolean;
97
+ /** The permix path, e.g. `"post.publish"`. */
98
+ path: string;
99
+ /** The subject id, `null` for a guest. */
100
+ subject: string | null;
101
+ /** The effective role the rules ran as. */
102
+ role: R;
103
+ reason: CheckReason;
104
+ /** The lib's `explain()` detail of the rule alone (role, permissions seen, what decided). */
105
+ explanation: CheckExplanation<R, P>;
106
+ }
107
+ /** The serializable state a client needs to rebuild a subject's ability (React, SSR). */
108
+ export interface PermissionsSnapshot<R extends string = string, P extends string = string> {
109
+ subject: {
110
+ id: string | null;
111
+ role: R;
112
+ };
113
+ /** The non-expired, assignable granted permissions. */
114
+ permissions: P[];
115
+ }
116
+ /** Who performs a write: an actor id, an {@link Actor}, or `null` (system). */
117
+ export declare const actorSchema: v.NullableSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>, v.ObjectSchema<{
118
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
119
+ readonly type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
120
+ readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
121
+ readonly email: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
122
+ }, undefined>], undefined>, undefined>;
123
+ /** Input of `grant()`. */
124
+ export declare const grantInputSchema: v.ObjectSchema<{
125
+ readonly subject: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
126
+ readonly permission: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
127
+ readonly actor: v.OptionalSchema<v.NullableSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>, v.ObjectSchema<{
128
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
129
+ readonly type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
130
+ readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
131
+ readonly email: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
132
+ }, undefined>], undefined>, undefined>, undefined>;
133
+ readonly reason: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 1000, "must be at most 1000 characters">]>, undefined>;
134
+ /** ISO string, `Date` or unix ms; `null` = never. */
135
+ readonly expiresAt: v.OptionalSchema<v.NullableSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "must be an ISO-8601 date">]>, v.SchemaWithPipe<readonly [v.DateSchema<undefined>, v.CheckAction<Date, "must be a valid date">]>, v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>]>], undefined>, undefined>, undefined>;
136
+ }, undefined>;
137
+ /** Input of `revoke()`. */
138
+ export declare const revokeInputSchema: v.ObjectSchema<{
139
+ readonly subject: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
140
+ readonly permission: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
141
+ readonly actor: v.OptionalSchema<v.NullableSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>, v.ObjectSchema<{
142
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
143
+ readonly type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
144
+ readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
145
+ readonly email: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
146
+ }, undefined>], undefined>, undefined>, undefined>;
147
+ readonly reason: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 1000, "must be at most 1000 characters">]>, undefined>;
148
+ }, undefined>;
149
+ /** Input of `setRole()`; `role: null` clears the stored assignment. */
150
+ export declare const setRoleInputSchema: v.ObjectSchema<{
151
+ readonly subject: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
152
+ readonly role: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>, undefined>;
153
+ readonly actor: v.OptionalSchema<v.NullableSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>, v.ObjectSchema<{
154
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
155
+ readonly type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
156
+ readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
157
+ readonly email: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
158
+ }, undefined>], undefined>, undefined>, undefined>;
159
+ readonly reason: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 1000, "must be at most 1000 characters">]>, undefined>;
160
+ }, undefined>;
161
+ /** Input of `upsertSubject()`. `null` clears a field. */
162
+ export declare const upsertSubjectInputSchema: v.ObjectSchema<{
163
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
164
+ readonly name: v.OptionalSchema<v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 500, undefined>]>, undefined>, undefined>;
165
+ readonly email: v.OptionalSchema<v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 500, undefined>]>, undefined>, undefined>;
166
+ }, undefined>;
167
+ /** Query of `list()`. */
168
+ export declare const listQuerySchema: v.ObjectSchema<{
169
+ readonly subject: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>, undefined>;
170
+ readonly permission: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>, undefined>;
171
+ readonly includeExpired: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
172
+ }, undefined>;
173
+ /** Input of `writeRelationship()` / `deleteRelationship()`. */
174
+ export declare const relationshipInputSchema: v.ObjectSchema<{
175
+ readonly object: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 512, "must be at most 512 characters">, v.RegexAction<string, "must be \"type:id\" (no \"#\" in the id)">]>;
176
+ readonly relation: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
177
+ readonly subject: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 512, "must be at most 512 characters">, v.RegexAction<string, "must be \"type:id\", \"type:id#relation\" or \"type:*\"">]>;
178
+ readonly actor: v.OptionalSchema<v.NullableSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>, v.ObjectSchema<{
179
+ readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
180
+ readonly type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
181
+ readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
182
+ readonly email: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
183
+ }, undefined>], undefined>, undefined>, undefined>;
184
+ readonly reason: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 1000, "must be at most 1000 characters">]>, undefined>;
185
+ }, undefined>;
186
+ /** Query of `readRelationships()`. */
187
+ export declare const relationshipQuerySchema: v.ObjectSchema<{
188
+ /** `type:id`, or just `type` for every object of a type. */
189
+ readonly object: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>, undefined>;
190
+ readonly relation: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>, undefined>;
191
+ readonly subject: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 512, "must be at most 512 characters">, v.RegexAction<string, "must be \"type:id\", \"type:id#relation\" or \"type:*\"">]>, undefined>;
192
+ readonly limit: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>, v.MaxValueAction<number, 1000, undefined>]>, undefined>;
193
+ readonly cursor: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
194
+ }, undefined>;
195
+ /** Input of `checkRelation()`. */
196
+ export declare const relationCheckSchema: v.ObjectSchema<{
197
+ readonly subject: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 512, "must be at most 512 characters">, v.RegexAction<string, "must be \"type:id\", \"type:id#relation\" or \"type:*\"">]>;
198
+ readonly relation: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
199
+ readonly object: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 512, "must be at most 512 characters">, v.RegexAction<string, "must be \"type:id\" (no \"#\" in the id)">]>;
200
+ }, undefined>;
201
+ /** Query of `listObjects()`. */
202
+ export declare const listObjectsQuerySchema: v.ObjectSchema<{
203
+ readonly subject: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 512, "must be at most 512 characters">, v.RegexAction<string, "must be \"type:id\", \"type:id#relation\" or \"type:*\"">]>;
204
+ readonly relation: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
205
+ readonly type: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
206
+ }, undefined>;
207
+ /** Query of `listRelationSubjects()`. */
208
+ export declare const listRelationSubjectsQuerySchema: v.ObjectSchema<{
209
+ readonly object: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 512, "must be at most 512 characters">, v.RegexAction<string, "must be \"type:id\" (no \"#\" in the id)">]>;
210
+ readonly relation: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
211
+ /** Only subjects of this type. */
212
+ readonly type: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>, undefined>;
213
+ }, undefined>;
214
+ /** Query of `history()`. */
215
+ export declare const historyQuerySchema: v.ObjectSchema<{
216
+ readonly subject: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>, undefined>;
217
+ readonly limit: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>, v.MaxValueAction<number, 1000, undefined>]>, undefined>;
218
+ readonly cursor: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
219
+ }, undefined>;
220
+ /** An ISO string, `Date` or unix ms. */
221
+ export type InstantInput = string | Date | number;
222
+ /** Input of `grant()`, typed with the catalog's permissions. */
223
+ export interface GrantInput<P extends string = string> {
224
+ subject: string;
225
+ permission: P;
226
+ actor?: string | Actor | null;
227
+ reason?: string;
228
+ /** When the grant stops counting; `null` / absent = never. */
229
+ expiresAt?: InstantInput | null;
230
+ }
231
+ /** Input of `revoke()`. */
232
+ export interface RevokeInput<P extends string = string> {
233
+ subject: string;
234
+ permission: P;
235
+ actor?: string | Actor | null;
236
+ reason?: string;
237
+ }
238
+ /** Input of `setRole()`. */
239
+ export interface SetRoleInput<R extends string = string> {
240
+ subject: string;
241
+ /** `null` clears the stored role (the auth provider's role, or `defaultRole`, applies again). */
242
+ role: R | null;
243
+ actor?: string | Actor | null;
244
+ reason?: string;
245
+ }
246
+ /** Input of `upsertSubject()`. A field left out is kept; `null` clears it. */
247
+ export interface UpsertSubjectInput {
248
+ id: string;
249
+ name?: string | null;
250
+ email?: string | null;
251
+ }
252
+ /** Query of `list()`. Neither: every grant. */
253
+ export interface ListQuery<P extends string = string> {
254
+ subject?: string;
255
+ permission?: P;
256
+ /** Include grants whose `expiresAt` has passed. Default `false`. */
257
+ includeExpired?: boolean;
258
+ }
259
+ /** Query of `history()`. */
260
+ export interface HistoryQuery {
261
+ /** One subject's history; absent = everyone's. */
262
+ subject?: string;
263
+ /** Page size, 1–1000. Default 50. */
264
+ limit?: number;
265
+ /** The `nextCursor` of the previous page. */
266
+ cursor?: string;
267
+ }
268
+ /** Input of `writeRelationship()` / `deleteRelationship()`. */
269
+ export interface RelationshipInput {
270
+ object: string;
271
+ relation: string;
272
+ subject: string;
273
+ actor?: string | Actor | null;
274
+ reason?: string;
275
+ }
276
+ /** Query of `readRelationships()`. Every field narrows; none: every relationship. */
277
+ export interface RelationshipQuery {
278
+ /** `"doc:1"`, or a bare type (`"doc"`) for every object of that type. */
279
+ object?: string;
280
+ relation?: string;
281
+ /** Exactly this subject reference (`user:ana`, `group:eng#member`, `user:*`). */
282
+ subject?: string;
283
+ /** Page size, 1–1000. Default 100. */
284
+ limit?: number;
285
+ /** The `nextCursor` of the previous page. */
286
+ cursor?: string;
287
+ }
288
+ /** A page of relationships, sorted by object, relation, subject. */
289
+ export interface RelationshipPage {
290
+ relationships: Relationship[];
291
+ /** Pass as `cursor` for the next page; `null` at the end. */
292
+ nextCursor: string | null;
293
+ }
294
+ /** A page of history, newest first. */
295
+ export interface HistoryPage {
296
+ entries: HistoryEntry[];
297
+ /** Pass as `cursor` for the next (older) page; `null` at the end. */
298
+ nextCursor: string | null;
299
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Storage contracts. The base {@link PermissionsStorage} is intentionally tiny — four
3
+ * async methods — so users can bring their own backend. Optional capabilities
4
+ * (watch, transactions, compare-and-swap) are separate interfaces that adapters
5
+ * may implement and the core feature-detects.
6
+ *
7
+ * The neutral contract lives in `@xtandard/kit/storage`; these are the
8
+ * permissions names for it.
9
+ *
10
+ * @module
11
+ */
12
+ export type { CompareAndSwapKvStorage as CompareAndSwapPermissionsStorage, KvStorage as PermissionsStorage, StorageChangeEvent, TransactionalKvStorage as TransactionalPermissionsStorage, WatchableKvStorage as WatchablePermissionsStorage, } from "@xtandard/kit/storage";
13
+ export { isCompareAndSwap, isTransactional, isWatchable } from "@xtandard/kit/storage";
14
+ /**
15
+ * Helper for adapters whose subpath requires an optional peer dependency. Throws
16
+ * a clear, actionable error when the peer is missing.
17
+ */
18
+ export declare function requirePeer(name: string, subpath: string): never;
@@ -0,0 +1,23 @@
1
+ import React from "react";
2
+ import { type ShellAppProps } from "@xtandard/kit/ui";
3
+ import type { PanelAction, PanelConfig } from "./types.ts";
4
+ /** Everything a view needs from the shell. */
5
+ export interface ShellContext {
6
+ config: PanelConfig;
7
+ readonly: boolean;
8
+ /** Navigate in-app (consults the nav guard). */
9
+ go: (path: string, params?: Record<string, string>) => void;
10
+ /** The principal may run `action` (always `true` when `/config` lists no actions). */
11
+ can: (action: PanelAction) => boolean;
12
+ /** `can(action)` and the panel is not read-only: show the write UI. */
13
+ canWrite: (action: "grants:write" | "roles:write" | "relationships:write") => boolean;
14
+ }
15
+ /** The path of a subject's detail view. */
16
+ export declare const subjectPath: (id: string) => string;
17
+ /**
18
+ * The admin panel, wrapped in a wouter {@link Router}. `locationHook` + `base`
19
+ * make routing pluggable: the bundled SPA uses browser history (clean paths,
20
+ * served by the handler's SPA catch-all), while the embed defaults to hash
21
+ * routing so it never touches the host app's router.
22
+ */
23
+ export declare function App({ locationHook, searchHook, base, logoUrl, showThemeToggle, }: ShellAppProps): React.ReactElement;
@@ -0,0 +1,73 @@
1
+ /**
2
+ * The SPA's client for the panel's JSON API (ADR 0008; the OpenAPI document is
3
+ * served at `api/openapi.json`). Paths are relative (resolved against the
4
+ * injected `<base href>`) unless the React embed points the client elsewhere
5
+ * with {@link setApiBase}.
6
+ *
7
+ * @module
8
+ */
9
+ import { type ApiClient } from "@xtandard/kit/ui";
10
+ import type { CatalogView, CheckBody, CheckResult, Grant, GrantBody, HistoryPage, PanelConfig, RelationCheckResult, Relationship, RelationshipBody, RelationshipPage, SubjectDetail, SubjectRecord, SubjectSummary, SubjectUpdateBody } from "./types.ts";
11
+ export type { ApiClientOptions, FetchLike } from "@xtandard/kit/ui";
12
+ /** Point the API client at a base URL (used by `@xtandard/permissions/react/embed`). */
13
+ export declare const setApiBase: ApiClient["setApiBase"];
14
+ /** Attach a bearer token on every request (`null` clears it). */
15
+ export declare const setApiToken: ApiClient["setApiToken"];
16
+ /** The attached bearer token, if any. */
17
+ export declare const getApiToken: ApiClient["getApiToken"];
18
+ /** The URL for an API path under the current base (the OpenAPI link). */
19
+ export declare const apiUrl: ApiClient["apiUrl"];
20
+ export declare function getConfig(): Promise<PanelConfig>;
21
+ export declare function getCatalog(): Promise<CatalogView>;
22
+ export declare function listSubjects(): Promise<SubjectSummary[]>;
23
+ export declare function getSubject(id: string): Promise<SubjectDetail>;
24
+ export declare function updateSubject(id: string, body: SubjectUpdateBody): Promise<SubjectDetail>;
25
+ export declare function listGrants(params?: {
26
+ subject?: string;
27
+ permission?: string;
28
+ }): Promise<Grant[]>;
29
+ export declare function grant(body: GrantBody): Promise<{
30
+ grant: Grant;
31
+ created: boolean;
32
+ }>;
33
+ export declare function revoke(subject: string, permission: string, reason?: string): Promise<{
34
+ removed: boolean;
35
+ grant: Grant | null;
36
+ }>;
37
+ export declare function listHistory(params?: {
38
+ subject?: string;
39
+ limit?: number;
40
+ cursor?: string;
41
+ }): Promise<HistoryPage>;
42
+ export declare function runCheck(body: CheckBody): Promise<CheckResult>;
43
+ export declare function readRelationships(params?: {
44
+ object?: string;
45
+ relation?: string;
46
+ subject?: string;
47
+ limit?: number;
48
+ cursor?: string;
49
+ }): Promise<RelationshipPage>;
50
+ export declare function writeRelationship(body: RelationshipBody): Promise<{
51
+ relationship: Relationship;
52
+ created: boolean;
53
+ }>;
54
+ export declare function deleteRelationship(body: RelationshipBody): Promise<{
55
+ removed: boolean;
56
+ relationship: Relationship | null;
57
+ }>;
58
+ export declare function checkRelation(body: {
59
+ subject: string;
60
+ relation: string;
61
+ object: string;
62
+ }): Promise<RelationCheckResult>;
63
+ export declare function listObjects(params: {
64
+ subject: string;
65
+ relation: string;
66
+ type: string;
67
+ }): Promise<string[]>;
68
+ export declare function listRelationSubjects(params: {
69
+ object: string;
70
+ relation: string;
71
+ type?: string;
72
+ }): Promise<string[]>;
73
+ export type { SubjectRecord };