@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,101 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_create_fetch_handler = require("./create-fetch-handler-BHT4vSZs.cjs");
3
+ const require_guard = require("./guard-DvaoUgjk.cjs");
4
+ let _xtandard_kit_adapters_express = require("@xtandard/kit/adapters/express");
5
+ let _xtandard_kit_adapters_node = require("@xtandard/kit/adapters/node");
6
+ //#region src/adapters/express.ts
7
+ /**
8
+ * Express adapter. {@link permissionsPanel} bridges Node's `req` / `res` to the web-standard
9
+ * handler (the kit's Node bridge); {@link requirePermission} is a middleware answering `401` /
10
+ * `403` JSON for denials and setting `req.permission` (and `res.locals.permission`). No `express`
11
+ * import at runtime, only its types.
12
+ *
13
+ * Mount the panel before body-parser middleware (or let the bridge re-serialise parsed bodies):
14
+ *
15
+ * ```ts
16
+ * import { permissionsPanel, requirePermission } from "@xtandard/permissions/express";
17
+ *
18
+ * app.use("/permissions", permissionsPanel({ permissions: perms, provider, basePath: "/permissions" }));
19
+ * app.post(
20
+ * "/refunds",
21
+ * requirePermission(perms, "billing.refund", { provider }),
22
+ * (req, res) => res.json({ ok: true }),
23
+ * );
24
+ * ```
25
+ *
26
+ * @module
27
+ */
28
+ /** Create an Express handler serving the panel. Use with `app.use(path, handler)`. */
29
+ function permissionsPanel(options) {
30
+ const handler = require_create_fetch_handler.createFetchHandler(options);
31
+ return Object.assign((0, _xtandard_kit_adapters_express.toExpressMiddleware)(handler.fetch), {
32
+ engine: handler.engine,
33
+ openapi: handler.openapi,
34
+ close: handler.close
35
+ });
36
+ }
37
+ /** A body-less web `Request` with the Express request's method, URL and headers (for providers). */
38
+ function requestOf(req) {
39
+ const host = req.get("host") ?? "localhost";
40
+ return new Request(`${req.protocol}://${host}${req.originalUrl}`, {
41
+ method: req.method,
42
+ headers: (0, _xtandard_kit_adapters_node.headersFrom)(req)
43
+ });
44
+ }
45
+ /**
46
+ * Express middleware guarding a route with a permission path: `401` / `403` JSON for denials;
47
+ * otherwise sets `req.permission` (and `res.locals.permission`) and calls `next()`.
48
+ */
49
+ function requirePermission(engine, path, options) {
50
+ return (req, res, next) => {
51
+ (async () => {
52
+ const outcome = await require_guard.evaluateGuard(require_guard.guardEngine(engine), path, options, req, requestOf);
53
+ if (outcome.allowed) {
54
+ req.permission = outcome.result;
55
+ res.locals.permission = outcome.result;
56
+ next();
57
+ return;
58
+ }
59
+ const { status, body, result } = outcome;
60
+ if (options.onDenied) {
61
+ await (0, _xtandard_kit_adapters_node.writeWebResponse)(res, await options.onDenied({
62
+ status,
63
+ body,
64
+ result
65
+ }, req));
66
+ return;
67
+ }
68
+ res.status(status).json(body);
69
+ })().catch(next);
70
+ };
71
+ }
72
+ /**
73
+ * Express middleware guarding a route with a relationship (ReBAC): the caller (`user:{id}` unless
74
+ * `subjectRef`) must have `relation` on the object (`(req) => \`doc:${req.params.id}\``). `401` /
75
+ * `403` JSON for denials; otherwise sets `req.relation` (and `res.locals.relation`).
76
+ */
77
+ function requireRelation(engine, relation, object, options) {
78
+ return (req, res, next) => {
79
+ (async () => {
80
+ const outcome = await require_guard.evaluateRelationGuard(require_guard.relationGuardEngine(engine), relation, object, options, req, requestOf);
81
+ if (outcome.allowed) {
82
+ req.relation = outcome.result;
83
+ res.locals.relation = outcome.result;
84
+ next();
85
+ return;
86
+ }
87
+ if (options.onDenied) {
88
+ await (0, _xtandard_kit_adapters_node.writeWebResponse)(res, await require_guard.relationOutcomeResponse(outcome, options, req));
89
+ return;
90
+ }
91
+ res.status(outcome.status).json(outcome.body);
92
+ })().catch(next);
93
+ };
94
+ }
95
+ //#endregion
96
+ exports.permissionsPanel = permissionsPanel;
97
+ exports.requestOf = requestOf;
98
+ exports.requirePermission = requirePermission;
99
+ exports.requireRelation = requireRelation;
100
+
101
+ //# sourceMappingURL=entry-express.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entry-express.cjs","names":["createFetchHandler","evaluateGuard","guardEngine","evaluateRelationGuard","relationGuardEngine","relationOutcomeResponse"],"sources":["../src/adapters/express.ts"],"sourcesContent":["/**\n * Express adapter. {@link permissionsPanel} bridges Node's `req` / `res` to the web-standard\n * handler (the kit's Node bridge); {@link requirePermission} is a middleware answering `401` /\n * `403` JSON for denials and setting `req.permission` (and `res.locals.permission`). No `express`\n * import at runtime, only its types.\n *\n * Mount the panel before body-parser middleware (or let the bridge re-serialise parsed bodies):\n *\n * ```ts\n * import { permissionsPanel, requirePermission } from \"@xtandard/permissions/express\";\n *\n * app.use(\"/permissions\", permissionsPanel({ permissions: perms, provider, basePath: \"/permissions\" }));\n * app.post(\n * \"/refunds\",\n * requirePermission(perms, \"billing.refund\", { provider }),\n * (req, res) => res.json({ ok: true }),\n * );\n * ```\n *\n * @module\n */\n\nimport { toExpressMiddleware } from \"@xtandard/kit/adapters/express\";\nimport { headersFrom, writeWebResponse } from \"@xtandard/kit/adapters/node\";\nimport type { NextFunction, Request as ExRequest, Response as ExResponse } from \"express\";\nimport type { AnyPermissions } from \"../engine.ts\";\nimport type { Definition } from \"../policy.ts\";\nimport type { CheckResult } from \"../schema.ts\";\nimport {\n createFetchHandler,\n type CreateFetchHandlerResult,\n type PermissionsPanelOptions,\n} from \"../server/create-fetch-handler.ts\";\nimport {\n evaluateGuard,\n guardEngine,\n evaluateRelationGuard,\n relationGuardEngine,\n relationOutcomeResponse,\n type RelationDecision,\n type RelationObjectInput,\n type RequireRelationOptions,\n type PathOf,\n type RequirePermissionOptions,\n} from \"./guard.ts\";\n\n/** An Express handler with the panel's `engine` + `openapi` attached. */\nexport type ExpressPermissionsHandler<\n D extends Definition = Definition,\n R extends string = string,\n P extends string = string,\n X = undefined,\n> = ((req: ExRequest, res: ExResponse, next: NextFunction) => void) & {\n engine: CreateFetchHandlerResult<D, R, P, X>[\"engine\"];\n openapi: CreateFetchHandlerResult<D, R, P, X>[\"openapi\"];\n close: CreateFetchHandlerResult<D, R, P, X>[\"close\"];\n};\n\n/** An Express request carrying the guard's decision. */\nexport type PermissionRequest = ExRequest & { permission?: CheckResult };\n\n/** Create an Express handler serving the panel. Use with `app.use(path, handler)`. */\nexport function permissionsPanel<\n D extends Definition = Definition,\n R extends string = string,\n P extends string = string,\n X = undefined,\n>(options: PermissionsPanelOptions<D, R, P, X>): ExpressPermissionsHandler<D, R, P, X> {\n const handler = createFetchHandler(options);\n return Object.assign(toExpressMiddleware(handler.fetch), {\n engine: handler.engine,\n openapi: handler.openapi,\n close: handler.close,\n });\n}\n\n/** A body-less web `Request` with the Express request's method, URL and headers (for providers). */\nexport function requestOf(req: ExRequest): Request {\n const host = req.get(\"host\") ?? \"localhost\";\n return new Request(`${req.protocol}://${host}${req.originalUrl}`, {\n method: req.method,\n headers: headersFrom(req),\n });\n}\n\n/**\n * Express middleware guarding a route with a permission path: `401` / `403` JSON for denials;\n * otherwise sets `req.permission` (and `res.locals.permission`) and calls `next()`.\n */\nexport function requirePermission<E extends AnyPermissions>(\n engine: E,\n path: PathOf<E>,\n options: RequirePermissionOptions<ExRequest>,\n): (req: ExRequest, res: ExResponse, next: NextFunction) => void {\n return (req, res, next) => {\n (async () => {\n const outcome = await evaluateGuard(guardEngine(engine), path, options, req, requestOf);\n if (outcome.allowed) {\n (req as PermissionRequest).permission = outcome.result;\n res.locals.permission = outcome.result;\n next();\n return;\n }\n const { status, body, result } = outcome;\n if (options.onDenied) {\n await writeWebResponse(res, await options.onDenied({ status, body, result }, req));\n return;\n }\n res.status(status).json(body);\n })().catch(next);\n };\n}\n\n/**\n * Express middleware guarding a route with a relationship (ReBAC): the caller (`user:{id}` unless\n * `subjectRef`) must have `relation` on the object (`(req) => \\`doc:${req.params.id}\\``). `401` /\n * `403` JSON for denials; otherwise sets `req.relation` (and `res.locals.relation`).\n */\nexport function requireRelation<E extends AnyPermissions>(\n engine: E,\n relation: string,\n object: RelationObjectInput<ExRequest>,\n options: RequireRelationOptions<ExRequest>,\n): (req: ExRequest, res: ExResponse, next: NextFunction) => void {\n return (req, res, next) => {\n (async () => {\n const outcome = await evaluateRelationGuard(\n relationGuardEngine(engine),\n relation,\n object,\n options,\n req,\n requestOf,\n );\n if (outcome.allowed) {\n (req as ExRequest & { relation?: RelationDecision }).relation = outcome.result;\n res.locals.relation = outcome.result;\n next();\n return;\n }\n if (options.onDenied) {\n await writeWebResponse(res, await relationOutcomeResponse(outcome, options, req));\n return;\n }\n res.status(outcome.status).json(outcome.body);\n })().catch(next);\n };\n}\n\nexport type {\n PermissionsPanelOptions,\n RelationDecision,\n RelationObjectInput,\n RequirePermissionOptions,\n RequireRelationOptions,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,SAAgB,iBAKd,SAAqF;CACrF,MAAM,UAAUA,6BAAAA,mBAAmB,OAAO;CAC1C,OAAO,OAAO,QAAA,GAAA,+BAAA,qBAA2B,QAAQ,KAAK,GAAG;EACvD,QAAQ,QAAQ;EAChB,SAAS,QAAQ;EACjB,OAAO,QAAQ;CACjB,CAAC;AACH;;AAGA,SAAgB,UAAU,KAAyB;CACjD,MAAM,OAAO,IAAI,IAAI,MAAM,KAAK;CAChC,OAAO,IAAI,QAAQ,GAAG,IAAI,SAAS,KAAK,OAAO,IAAI,eAAe;EAChE,QAAQ,IAAI;EACZ,UAAA,GAAA,4BAAA,aAAqB,GAAG;CAC1B,CAAC;AACH;;;;;AAMA,SAAgB,kBACd,QACA,MACA,SAC+D;CAC/D,QAAQ,KAAK,KAAK,SAAS;EACzB,CAAC,YAAY;GACX,MAAM,UAAU,MAAMC,cAAAA,cAAcC,cAAAA,YAAY,MAAM,GAAG,MAAM,SAAS,KAAK,SAAS;GACtF,IAAI,QAAQ,SAAS;IACnB,IAA2B,aAAa,QAAQ;IAChD,IAAI,OAAO,aAAa,QAAQ;IAChC,KAAK;IACL;GACF;GACA,MAAM,EAAE,QAAQ,MAAM,WAAW;GACjC,IAAI,QAAQ,UAAU;IACpB,OAAA,GAAA,4BAAA,kBAAuB,KAAK,MAAM,QAAQ,SAAS;KAAE;KAAQ;KAAM;IAAO,GAAG,GAAG,CAAC;IACjF;GACF;GACA,IAAI,OAAO,MAAM,EAAE,KAAK,IAAI;EAC9B,GAAG,EAAE,MAAM,IAAI;CACjB;AACF;;;;;;AAOA,SAAgB,gBACd,QACA,UACA,QACA,SAC+D;CAC/D,QAAQ,KAAK,KAAK,SAAS;EACzB,CAAC,YAAY;GACX,MAAM,UAAU,MAAMC,cAAAA,sBACpBC,cAAAA,oBAAoB,MAAM,GAC1B,UACA,QACA,SACA,KACA,SACF;GACA,IAAI,QAAQ,SAAS;IACnB,IAAqD,WAAW,QAAQ;IACxE,IAAI,OAAO,WAAW,QAAQ;IAC9B,KAAK;IACL;GACF;GACA,IAAI,QAAQ,UAAU;IACpB,OAAA,GAAA,4BAAA,kBAAuB,KAAK,MAAMC,cAAAA,wBAAwB,SAAS,SAAS,GAAG,CAAC;IAChF;GACF;GACA,IAAI,OAAO,QAAQ,MAAM,EAAE,KAAK,QAAQ,IAAI;EAC9C,GAAG,EAAE,MAAM,IAAI;CACjB;AACF"}
@@ -0,0 +1,36 @@
1
+ import { s as Definition } from "./policy-DFq_SYR3.cjs";
2
+ import { h as CheckResult } from "./contract-CXPMGuHk.cjs";
3
+ import { t as AnyPermissions } from "./engine-BTgwbHeO.cjs";
4
+ import { n as PermissionsPanelOptions, t as CreateFetchHandlerResult } from "./create-fetch-handler-DxhvXuBA.cjs";
5
+ import { a as RequireRelationOptions, i as RequirePermissionOptions, n as RelationDecision, r as RelationObjectInput, t as PathOf } from "./guard-VEK0W8ug.cjs";
6
+ import { NextFunction, Request as Request$1, Response } from "express";
7
+
8
+ //#region src/adapters/express.d.ts
9
+ /** An Express handler with the panel's `engine` + `openapi` attached. */
10
+ type ExpressPermissionsHandler<D extends Definition = Definition, R extends string = string, P extends string = string, X = undefined> = ((req: Request$1, res: Response, next: NextFunction) => void) & {
11
+ engine: CreateFetchHandlerResult<D, R, P, X>["engine"];
12
+ openapi: CreateFetchHandlerResult<D, R, P, X>["openapi"];
13
+ close: CreateFetchHandlerResult<D, R, P, X>["close"];
14
+ };
15
+ /** An Express request carrying the guard's decision. */
16
+ type PermissionRequest = Request$1 & {
17
+ permission?: CheckResult;
18
+ };
19
+ /** Create an Express handler serving the panel. Use with `app.use(path, handler)`. */
20
+ declare function permissionsPanel<D extends Definition = Definition, R extends string = string, P extends string = string, X = undefined>(options: PermissionsPanelOptions<D, R, P, X>): ExpressPermissionsHandler<D, R, P, X>;
21
+ /** A body-less web `Request` with the Express request's method, URL and headers (for providers). */
22
+ declare function requestOf(req: Request$1): Request;
23
+ /**
24
+ * Express middleware guarding a route with a permission path: `401` / `403` JSON for denials;
25
+ * otherwise sets `req.permission` (and `res.locals.permission`) and calls `next()`.
26
+ */
27
+ declare function requirePermission<E extends AnyPermissions>(engine: E, path: PathOf<E>, options: RequirePermissionOptions<Request$1>): (req: Request$1, res: Response, next: NextFunction) => void;
28
+ /**
29
+ * Express middleware guarding a route with a relationship (ReBAC): the caller (`user:{id}` unless
30
+ * `subjectRef`) must have `relation` on the object (`(req) => \`doc:${req.params.id}\``). `401` /
31
+ * `403` JSON for denials; otherwise sets `req.relation` (and `res.locals.relation`).
32
+ */
33
+ declare function requireRelation<E extends AnyPermissions>(engine: E, relation: string, object: RelationObjectInput<Request$1>, options: RequireRelationOptions<Request$1>): (req: Request$1, res: Response, next: NextFunction) => void;
34
+ //#endregion
35
+ export { ExpressPermissionsHandler, PermissionRequest, type PermissionsPanelOptions, type RelationDecision, type RelationObjectInput, type RequirePermissionOptions, type RequireRelationOptions, permissionsPanel, requestOf, requirePermission, requireRelation };
36
+ //# sourceMappingURL=entry-express.d.cts.map
@@ -0,0 +1,36 @@
1
+ import { s as Definition } from "./policy-CGA6QD0a.mjs";
2
+ import { h as CheckResult } from "./contract-DhS23Pcp.mjs";
3
+ import { t as AnyPermissions } from "./engine-C3xHfi3q.mjs";
4
+ import { n as PermissionsPanelOptions, t as CreateFetchHandlerResult } from "./create-fetch-handler-B711wb64.mjs";
5
+ import { a as RequireRelationOptions, i as RequirePermissionOptions, n as RelationDecision, r as RelationObjectInput, t as PathOf } from "./guard-k7A71SWC.mjs";
6
+ import { NextFunction, Request as Request$1, Response } from "express";
7
+
8
+ //#region src/adapters/express.d.ts
9
+ /** An Express handler with the panel's `engine` + `openapi` attached. */
10
+ type ExpressPermissionsHandler<D extends Definition = Definition, R extends string = string, P extends string = string, X = undefined> = ((req: Request$1, res: Response, next: NextFunction) => void) & {
11
+ engine: CreateFetchHandlerResult<D, R, P, X>["engine"];
12
+ openapi: CreateFetchHandlerResult<D, R, P, X>["openapi"];
13
+ close: CreateFetchHandlerResult<D, R, P, X>["close"];
14
+ };
15
+ /** An Express request carrying the guard's decision. */
16
+ type PermissionRequest = Request$1 & {
17
+ permission?: CheckResult;
18
+ };
19
+ /** Create an Express handler serving the panel. Use with `app.use(path, handler)`. */
20
+ declare function permissionsPanel<D extends Definition = Definition, R extends string = string, P extends string = string, X = undefined>(options: PermissionsPanelOptions<D, R, P, X>): ExpressPermissionsHandler<D, R, P, X>;
21
+ /** A body-less web `Request` with the Express request's method, URL and headers (for providers). */
22
+ declare function requestOf(req: Request$1): Request;
23
+ /**
24
+ * Express middleware guarding a route with a permission path: `401` / `403` JSON for denials;
25
+ * otherwise sets `req.permission` (and `res.locals.permission`) and calls `next()`.
26
+ */
27
+ declare function requirePermission<E extends AnyPermissions>(engine: E, path: PathOf<E>, options: RequirePermissionOptions<Request$1>): (req: Request$1, res: Response, next: NextFunction) => void;
28
+ /**
29
+ * Express middleware guarding a route with a relationship (ReBAC): the caller (`user:{id}` unless
30
+ * `subjectRef`) must have `relation` on the object (`(req) => \`doc:${req.params.id}\``). `401` /
31
+ * `403` JSON for denials; otherwise sets `req.relation` (and `res.locals.relation`).
32
+ */
33
+ declare function requireRelation<E extends AnyPermissions>(engine: E, relation: string, object: RelationObjectInput<Request$1>, options: RequireRelationOptions<Request$1>): (req: Request$1, res: Response, next: NextFunction) => void;
34
+ //#endregion
35
+ export { ExpressPermissionsHandler, PermissionRequest, type PermissionsPanelOptions, type RelationDecision, type RelationObjectInput, type RequirePermissionOptions, type RequireRelationOptions, permissionsPanel, requestOf, requirePermission, requireRelation };
36
+ //# sourceMappingURL=entry-express.d.mts.map
@@ -0,0 +1,97 @@
1
+ import { t as createFetchHandler } from "./create-fetch-handler-B0twltQL.mjs";
2
+ import { c as relationOutcomeResponse, n as evaluateRelationGuard, r as guardEngine, s as relationGuardEngine, t as evaluateGuard } from "./guard-Bj8zk23F.mjs";
3
+ import { toExpressMiddleware } from "@xtandard/kit/adapters/express";
4
+ import { headersFrom, writeWebResponse } from "@xtandard/kit/adapters/node";
5
+ //#region src/adapters/express.ts
6
+ /**
7
+ * Express adapter. {@link permissionsPanel} bridges Node's `req` / `res` to the web-standard
8
+ * handler (the kit's Node bridge); {@link requirePermission} is a middleware answering `401` /
9
+ * `403` JSON for denials and setting `req.permission` (and `res.locals.permission`). No `express`
10
+ * import at runtime, only its types.
11
+ *
12
+ * Mount the panel before body-parser middleware (or let the bridge re-serialise parsed bodies):
13
+ *
14
+ * ```ts
15
+ * import { permissionsPanel, requirePermission } from "@xtandard/permissions/express";
16
+ *
17
+ * app.use("/permissions", permissionsPanel({ permissions: perms, provider, basePath: "/permissions" }));
18
+ * app.post(
19
+ * "/refunds",
20
+ * requirePermission(perms, "billing.refund", { provider }),
21
+ * (req, res) => res.json({ ok: true }),
22
+ * );
23
+ * ```
24
+ *
25
+ * @module
26
+ */
27
+ /** Create an Express handler serving the panel. Use with `app.use(path, handler)`. */
28
+ function permissionsPanel(options) {
29
+ const handler = createFetchHandler(options);
30
+ return Object.assign(toExpressMiddleware(handler.fetch), {
31
+ engine: handler.engine,
32
+ openapi: handler.openapi,
33
+ close: handler.close
34
+ });
35
+ }
36
+ /** A body-less web `Request` with the Express request's method, URL and headers (for providers). */
37
+ function requestOf(req) {
38
+ const host = req.get("host") ?? "localhost";
39
+ return new Request(`${req.protocol}://${host}${req.originalUrl}`, {
40
+ method: req.method,
41
+ headers: headersFrom(req)
42
+ });
43
+ }
44
+ /**
45
+ * Express middleware guarding a route with a permission path: `401` / `403` JSON for denials;
46
+ * otherwise sets `req.permission` (and `res.locals.permission`) and calls `next()`.
47
+ */
48
+ function requirePermission(engine, path, options) {
49
+ return (req, res, next) => {
50
+ (async () => {
51
+ const outcome = await evaluateGuard(guardEngine(engine), path, options, req, requestOf);
52
+ if (outcome.allowed) {
53
+ req.permission = outcome.result;
54
+ res.locals.permission = outcome.result;
55
+ next();
56
+ return;
57
+ }
58
+ const { status, body, result } = outcome;
59
+ if (options.onDenied) {
60
+ await writeWebResponse(res, await options.onDenied({
61
+ status,
62
+ body,
63
+ result
64
+ }, req));
65
+ return;
66
+ }
67
+ res.status(status).json(body);
68
+ })().catch(next);
69
+ };
70
+ }
71
+ /**
72
+ * Express middleware guarding a route with a relationship (ReBAC): the caller (`user:{id}` unless
73
+ * `subjectRef`) must have `relation` on the object (`(req) => \`doc:${req.params.id}\``). `401` /
74
+ * `403` JSON for denials; otherwise sets `req.relation` (and `res.locals.relation`).
75
+ */
76
+ function requireRelation(engine, relation, object, options) {
77
+ return (req, res, next) => {
78
+ (async () => {
79
+ const outcome = await evaluateRelationGuard(relationGuardEngine(engine), relation, object, options, req, requestOf);
80
+ if (outcome.allowed) {
81
+ req.relation = outcome.result;
82
+ res.locals.relation = outcome.result;
83
+ next();
84
+ return;
85
+ }
86
+ if (options.onDenied) {
87
+ await writeWebResponse(res, await relationOutcomeResponse(outcome, options, req));
88
+ return;
89
+ }
90
+ res.status(outcome.status).json(outcome.body);
91
+ })().catch(next);
92
+ };
93
+ }
94
+ //#endregion
95
+ export { permissionsPanel, requestOf, requirePermission, requireRelation };
96
+
97
+ //# sourceMappingURL=entry-express.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entry-express.mjs","names":[],"sources":["../src/adapters/express.ts"],"sourcesContent":["/**\n * Express adapter. {@link permissionsPanel} bridges Node's `req` / `res` to the web-standard\n * handler (the kit's Node bridge); {@link requirePermission} is a middleware answering `401` /\n * `403` JSON for denials and setting `req.permission` (and `res.locals.permission`). No `express`\n * import at runtime, only its types.\n *\n * Mount the panel before body-parser middleware (or let the bridge re-serialise parsed bodies):\n *\n * ```ts\n * import { permissionsPanel, requirePermission } from \"@xtandard/permissions/express\";\n *\n * app.use(\"/permissions\", permissionsPanel({ permissions: perms, provider, basePath: \"/permissions\" }));\n * app.post(\n * \"/refunds\",\n * requirePermission(perms, \"billing.refund\", { provider }),\n * (req, res) => res.json({ ok: true }),\n * );\n * ```\n *\n * @module\n */\n\nimport { toExpressMiddleware } from \"@xtandard/kit/adapters/express\";\nimport { headersFrom, writeWebResponse } from \"@xtandard/kit/adapters/node\";\nimport type { NextFunction, Request as ExRequest, Response as ExResponse } from \"express\";\nimport type { AnyPermissions } from \"../engine.ts\";\nimport type { Definition } from \"../policy.ts\";\nimport type { CheckResult } from \"../schema.ts\";\nimport {\n createFetchHandler,\n type CreateFetchHandlerResult,\n type PermissionsPanelOptions,\n} from \"../server/create-fetch-handler.ts\";\nimport {\n evaluateGuard,\n guardEngine,\n evaluateRelationGuard,\n relationGuardEngine,\n relationOutcomeResponse,\n type RelationDecision,\n type RelationObjectInput,\n type RequireRelationOptions,\n type PathOf,\n type RequirePermissionOptions,\n} from \"./guard.ts\";\n\n/** An Express handler with the panel's `engine` + `openapi` attached. */\nexport type ExpressPermissionsHandler<\n D extends Definition = Definition,\n R extends string = string,\n P extends string = string,\n X = undefined,\n> = ((req: ExRequest, res: ExResponse, next: NextFunction) => void) & {\n engine: CreateFetchHandlerResult<D, R, P, X>[\"engine\"];\n openapi: CreateFetchHandlerResult<D, R, P, X>[\"openapi\"];\n close: CreateFetchHandlerResult<D, R, P, X>[\"close\"];\n};\n\n/** An Express request carrying the guard's decision. */\nexport type PermissionRequest = ExRequest & { permission?: CheckResult };\n\n/** Create an Express handler serving the panel. Use with `app.use(path, handler)`. */\nexport function permissionsPanel<\n D extends Definition = Definition,\n R extends string = string,\n P extends string = string,\n X = undefined,\n>(options: PermissionsPanelOptions<D, R, P, X>): ExpressPermissionsHandler<D, R, P, X> {\n const handler = createFetchHandler(options);\n return Object.assign(toExpressMiddleware(handler.fetch), {\n engine: handler.engine,\n openapi: handler.openapi,\n close: handler.close,\n });\n}\n\n/** A body-less web `Request` with the Express request's method, URL and headers (for providers). */\nexport function requestOf(req: ExRequest): Request {\n const host = req.get(\"host\") ?? \"localhost\";\n return new Request(`${req.protocol}://${host}${req.originalUrl}`, {\n method: req.method,\n headers: headersFrom(req),\n });\n}\n\n/**\n * Express middleware guarding a route with a permission path: `401` / `403` JSON for denials;\n * otherwise sets `req.permission` (and `res.locals.permission`) and calls `next()`.\n */\nexport function requirePermission<E extends AnyPermissions>(\n engine: E,\n path: PathOf<E>,\n options: RequirePermissionOptions<ExRequest>,\n): (req: ExRequest, res: ExResponse, next: NextFunction) => void {\n return (req, res, next) => {\n (async () => {\n const outcome = await evaluateGuard(guardEngine(engine), path, options, req, requestOf);\n if (outcome.allowed) {\n (req as PermissionRequest).permission = outcome.result;\n res.locals.permission = outcome.result;\n next();\n return;\n }\n const { status, body, result } = outcome;\n if (options.onDenied) {\n await writeWebResponse(res, await options.onDenied({ status, body, result }, req));\n return;\n }\n res.status(status).json(body);\n })().catch(next);\n };\n}\n\n/**\n * Express middleware guarding a route with a relationship (ReBAC): the caller (`user:{id}` unless\n * `subjectRef`) must have `relation` on the object (`(req) => \\`doc:${req.params.id}\\``). `401` /\n * `403` JSON for denials; otherwise sets `req.relation` (and `res.locals.relation`).\n */\nexport function requireRelation<E extends AnyPermissions>(\n engine: E,\n relation: string,\n object: RelationObjectInput<ExRequest>,\n options: RequireRelationOptions<ExRequest>,\n): (req: ExRequest, res: ExResponse, next: NextFunction) => void {\n return (req, res, next) => {\n (async () => {\n const outcome = await evaluateRelationGuard(\n relationGuardEngine(engine),\n relation,\n object,\n options,\n req,\n requestOf,\n );\n if (outcome.allowed) {\n (req as ExRequest & { relation?: RelationDecision }).relation = outcome.result;\n res.locals.relation = outcome.result;\n next();\n return;\n }\n if (options.onDenied) {\n await writeWebResponse(res, await relationOutcomeResponse(outcome, options, req));\n return;\n }\n res.status(outcome.status).json(outcome.body);\n })().catch(next);\n };\n}\n\nexport type {\n PermissionsPanelOptions,\n RelationDecision,\n RelationObjectInput,\n RequirePermissionOptions,\n RequireRelationOptions,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,SAAgB,iBAKd,SAAqF;CACrF,MAAM,UAAU,mBAAmB,OAAO;CAC1C,OAAO,OAAO,OAAO,oBAAoB,QAAQ,KAAK,GAAG;EACvD,QAAQ,QAAQ;EAChB,SAAS,QAAQ;EACjB,OAAO,QAAQ;CACjB,CAAC;AACH;;AAGA,SAAgB,UAAU,KAAyB;CACjD,MAAM,OAAO,IAAI,IAAI,MAAM,KAAK;CAChC,OAAO,IAAI,QAAQ,GAAG,IAAI,SAAS,KAAK,OAAO,IAAI,eAAe;EAChE,QAAQ,IAAI;EACZ,SAAS,YAAY,GAAG;CAC1B,CAAC;AACH;;;;;AAMA,SAAgB,kBACd,QACA,MACA,SAC+D;CAC/D,QAAQ,KAAK,KAAK,SAAS;EACzB,CAAC,YAAY;GACX,MAAM,UAAU,MAAM,cAAc,YAAY,MAAM,GAAG,MAAM,SAAS,KAAK,SAAS;GACtF,IAAI,QAAQ,SAAS;IACnB,IAA2B,aAAa,QAAQ;IAChD,IAAI,OAAO,aAAa,QAAQ;IAChC,KAAK;IACL;GACF;GACA,MAAM,EAAE,QAAQ,MAAM,WAAW;GACjC,IAAI,QAAQ,UAAU;IACpB,MAAM,iBAAiB,KAAK,MAAM,QAAQ,SAAS;KAAE;KAAQ;KAAM;IAAO,GAAG,GAAG,CAAC;IACjF;GACF;GACA,IAAI,OAAO,MAAM,EAAE,KAAK,IAAI;EAC9B,GAAG,EAAE,MAAM,IAAI;CACjB;AACF;;;;;;AAOA,SAAgB,gBACd,QACA,UACA,QACA,SAC+D;CAC/D,QAAQ,KAAK,KAAK,SAAS;EACzB,CAAC,YAAY;GACX,MAAM,UAAU,MAAM,sBACpB,oBAAoB,MAAM,GAC1B,UACA,QACA,SACA,KACA,SACF;GACA,IAAI,QAAQ,SAAS;IACnB,IAAqD,WAAW,QAAQ;IACxE,IAAI,OAAO,WAAW,QAAQ;IAC9B,KAAK;IACL;GACF;GACA,IAAI,QAAQ,UAAU;IACpB,MAAM,iBAAiB,KAAK,MAAM,wBAAwB,SAAS,SAAS,GAAG,CAAC;IAChF;GACF;GACA,IAAI,OAAO,QAAQ,MAAM,EAAE,KAAK,QAAQ,IAAI;EAC9C,GAAG,EAAE,MAAM,IAAI;CACjB;AACF"}
@@ -0,0 +1,63 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_create_fetch_handler = require("./create-fetch-handler-BHT4vSZs.cjs");
3
+ const require_guard = require("./guard-DvaoUgjk.cjs");
4
+ let _xtandard_kit_adapters_hono = require("@xtandard/kit/adapters/hono");
5
+ let hono = require("hono");
6
+ //#region src/adapters/hono.ts
7
+ /**
8
+ * Hono adapter. {@link permissionsPanel} returns a `Hono` sub-app whose catch-all delegates to the
9
+ * panel handler (`app.route(path, panel)`); {@link requirePermission} is a middleware answering
10
+ * `401` / `403` JSON for denials and setting `c.var.permission` to the allowing decision.
11
+ *
12
+ * ```ts
13
+ * import { permissionsPanel, requirePermission } from "@xtandard/permissions/hono";
14
+ *
15
+ * app.route("/permissions", permissionsPanel({ permissions: perms, provider, basePath: "/permissions" }));
16
+ * app.post(
17
+ * "/posts/:id/publish",
18
+ * requirePermission(perms, "post.publish", { provider, data: (c) => c.get("post") }),
19
+ * (c) => c.json({ ok: true, reason: c.var.permission.reason }),
20
+ * );
21
+ * ```
22
+ *
23
+ * @module
24
+ */
25
+ /** Create a Hono sub-app serving the panel. */
26
+ function permissionsPanel(options) {
27
+ const handler = require_create_fetch_handler.createFetchHandler(options);
28
+ const app = (0, _xtandard_kit_adapters_hono.mountPanel)(new hono.Hono(), handler.fetch);
29
+ return Object.assign(app, {
30
+ engine: handler.engine,
31
+ openapi: handler.openapi,
32
+ close: handler.close
33
+ });
34
+ }
35
+ /** Hono middleware guarding a route with a permission path. Resolvers receive the `Context`. */
36
+ function requirePermission(engine, path, options) {
37
+ return async (c, next) => {
38
+ const ctx = c;
39
+ const outcome = await require_guard.evaluateGuard(require_guard.guardEngine(engine), path, options, ctx, (x) => x.req.raw);
40
+ if (!outcome.allowed) return require_guard.outcomeResponse(outcome, options, ctx);
41
+ c.set("permission", outcome.result);
42
+ await next();
43
+ };
44
+ }
45
+ /**
46
+ * Hono middleware guarding a route with a relationship (ReBAC): the caller (`user:{id}` unless
47
+ * `subjectRef`) must have `relation` on the object (`(c) => \`doc:${c.req.param("id")}\``).
48
+ */
49
+ function requireRelation(engine, relation, object, options) {
50
+ return async (c, next) => {
51
+ const ctx = c;
52
+ const outcome = await require_guard.evaluateRelationGuard(require_guard.relationGuardEngine(engine), relation, object, options, ctx, (x) => x.req.raw);
53
+ if (!outcome.allowed) return require_guard.relationOutcomeResponse(outcome, options, ctx);
54
+ c.set("relation", outcome.result);
55
+ await next();
56
+ };
57
+ }
58
+ //#endregion
59
+ exports.permissionsPanel = permissionsPanel;
60
+ exports.requirePermission = requirePermission;
61
+ exports.requireRelation = requireRelation;
62
+
63
+ //# sourceMappingURL=entry-hono.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entry-hono.cjs","names":["createFetchHandler","Hono","evaluateGuard","guardEngine","outcomeResponse","evaluateRelationGuard","relationGuardEngine","relationOutcomeResponse"],"sources":["../src/adapters/hono.ts"],"sourcesContent":["/**\n * Hono adapter. {@link permissionsPanel} returns a `Hono` sub-app whose catch-all delegates to the\n * panel handler (`app.route(path, panel)`); {@link requirePermission} is a middleware answering\n * `401` / `403` JSON for denials and setting `c.var.permission` to the allowing decision.\n *\n * ```ts\n * import { permissionsPanel, requirePermission } from \"@xtandard/permissions/hono\";\n *\n * app.route(\"/permissions\", permissionsPanel({ permissions: perms, provider, basePath: \"/permissions\" }));\n * app.post(\n * \"/posts/:id/publish\",\n * requirePermission(perms, \"post.publish\", { provider, data: (c) => c.get(\"post\") }),\n * (c) => c.json({ ok: true, reason: c.var.permission.reason }),\n * );\n * ```\n *\n * @module\n */\n\nimport { mountPanel } from \"@xtandard/kit/adapters/hono\";\nimport { Hono, type Context, type MiddlewareHandler } from \"hono\";\nimport type { AnyPermissions } from \"../engine.ts\";\nimport type { Definition } from \"../policy.ts\";\nimport type { CheckResult } from \"../schema.ts\";\nimport {\n createFetchHandler,\n type CreateFetchHandlerResult,\n type PermissionsPanelOptions,\n} from \"../server/create-fetch-handler.ts\";\nimport {\n evaluateGuard,\n guardEngine,\n outcomeResponse,\n evaluateRelationGuard,\n relationGuardEngine,\n relationOutcomeResponse,\n type RelationDecision,\n type RelationObjectInput,\n type RequireRelationOptions,\n type PathOf,\n type RequirePermissionOptions,\n} from \"./guard.ts\";\n\n/** The Hono sub-app {@link permissionsPanel} returns, with the engine attached. */\nexport type HonoPermissionsPanel<\n D extends Definition = Definition,\n R extends string = string,\n P extends string = string,\n X = undefined,\n> = Hono & {\n engine: CreateFetchHandlerResult<D, R, P, X>[\"engine\"];\n openapi: CreateFetchHandlerResult<D, R, P, X>[\"openapi\"];\n close: CreateFetchHandlerResult<D, R, P, X>[\"close\"];\n};\n\n/** Create a Hono sub-app serving the panel. */\nexport function permissionsPanel<\n D extends Definition = Definition,\n R extends string = string,\n P extends string = string,\n X = undefined,\n>(options: PermissionsPanelOptions<D, R, P, X>): HonoPermissionsPanel<D, R, P, X> {\n const handler = createFetchHandler(options);\n const app = mountPanel(new Hono(), handler.fetch);\n return Object.assign(app, {\n engine: handler.engine,\n openapi: handler.openapi,\n close: handler.close,\n });\n}\n\n/** Context variables set by {@link requirePermission}. */\nexport interface PermissionVariables {\n /** The allowing decision for the guarded path. */\n permission: CheckResult;\n}\n\n/** Hono middleware guarding a route with a permission path. Resolvers receive the `Context`. */\nexport function requirePermission<E extends AnyPermissions>(\n engine: E,\n path: PathOf<E>,\n options: RequirePermissionOptions<Context>,\n): MiddlewareHandler<{ Variables: PermissionVariables }> {\n return async (c, next) => {\n const ctx = c as unknown as Context;\n const outcome = await evaluateGuard(guardEngine(engine), path, options, ctx, (x) => x.req.raw);\n if (!outcome.allowed) return outcomeResponse(outcome, options, ctx);\n c.set(\"permission\", outcome.result);\n await next();\n };\n}\n\n/** Context variables set by {@link requireRelation}. */\nexport interface RelationVariables {\n /** The allowing relationship decision. */\n relation: RelationDecision;\n}\n\n/**\n * Hono middleware guarding a route with a relationship (ReBAC): the caller (`user:{id}` unless\n * `subjectRef`) must have `relation` on the object (`(c) => \\`doc:${c.req.param(\"id\")}\\``).\n */\nexport function requireRelation<E extends AnyPermissions>(\n engine: E,\n relation: string,\n object: RelationObjectInput<Context>,\n options: RequireRelationOptions<Context>,\n): MiddlewareHandler<{ Variables: RelationVariables }> {\n return async (c, next) => {\n const ctx = c as unknown as Context;\n const outcome = await evaluateRelationGuard(\n relationGuardEngine(engine),\n relation,\n object,\n options,\n ctx,\n (x) => x.req.raw,\n );\n if (!outcome.allowed) return relationOutcomeResponse(outcome, options, ctx);\n c.set(\"relation\", outcome.result);\n await next();\n };\n}\n\nexport type {\n PermissionsPanelOptions,\n RelationDecision,\n RelationObjectInput,\n RequirePermissionOptions,\n RequireRelationOptions,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAwDA,SAAgB,iBAKd,SAAgF;CAChF,MAAM,UAAUA,6BAAAA,mBAAmB,OAAO;CAC1C,MAAM,OAAA,GAAA,4BAAA,YAAiB,IAAIC,KAAAA,KAAK,GAAG,QAAQ,KAAK;CAChD,OAAO,OAAO,OAAO,KAAK;EACxB,QAAQ,QAAQ;EAChB,SAAS,QAAQ;EACjB,OAAO,QAAQ;CACjB,CAAC;AACH;;AASA,SAAgB,kBACd,QACA,MACA,SACuD;CACvD,OAAO,OAAO,GAAG,SAAS;EACxB,MAAM,MAAM;EACZ,MAAM,UAAU,MAAMC,cAAAA,cAAcC,cAAAA,YAAY,MAAM,GAAG,MAAM,SAAS,MAAM,MAAM,EAAE,IAAI,GAAG;EAC7F,IAAI,CAAC,QAAQ,SAAS,OAAOC,cAAAA,gBAAgB,SAAS,SAAS,GAAG;EAClE,EAAE,IAAI,cAAc,QAAQ,MAAM;EAClC,MAAM,KAAK;CACb;AACF;;;;;AAYA,SAAgB,gBACd,QACA,UACA,QACA,SACqD;CACrD,OAAO,OAAO,GAAG,SAAS;EACxB,MAAM,MAAM;EACZ,MAAM,UAAU,MAAMC,cAAAA,sBACpBC,cAAAA,oBAAoB,MAAM,GAC1B,UACA,QACA,SACA,MACC,MAAM,EAAE,IAAI,GACf;EACA,IAAI,CAAC,QAAQ,SAAS,OAAOC,cAAAA,wBAAwB,SAAS,SAAS,GAAG;EAC1E,EAAE,IAAI,YAAY,QAAQ,MAAM;EAChC,MAAM,KAAK;CACb;AACF"}
@@ -0,0 +1,40 @@
1
+ import { s as Definition } from "./policy-DFq_SYR3.cjs";
2
+ import { h as CheckResult } from "./contract-CXPMGuHk.cjs";
3
+ import { t as AnyPermissions } from "./engine-BTgwbHeO.cjs";
4
+ import { n as PermissionsPanelOptions, t as CreateFetchHandlerResult } from "./create-fetch-handler-DxhvXuBA.cjs";
5
+ import { a as RequireRelationOptions, i as RequirePermissionOptions, n as RelationDecision, r as RelationObjectInput, t as PathOf } from "./guard-VEK0W8ug.cjs";
6
+ import { Context, Hono, MiddlewareHandler } from "hono";
7
+
8
+ //#region src/adapters/hono.d.ts
9
+ /** The Hono sub-app {@link permissionsPanel} returns, with the engine attached. */
10
+ type HonoPermissionsPanel<D extends Definition = Definition, R extends string = string, P extends string = string, X = undefined> = Hono & {
11
+ engine: CreateFetchHandlerResult<D, R, P, X>["engine"];
12
+ openapi: CreateFetchHandlerResult<D, R, P, X>["openapi"];
13
+ close: CreateFetchHandlerResult<D, R, P, X>["close"];
14
+ };
15
+ /** Create a Hono sub-app serving the panel. */
16
+ declare function permissionsPanel<D extends Definition = Definition, R extends string = string, P extends string = string, X = undefined>(options: PermissionsPanelOptions<D, R, P, X>): HonoPermissionsPanel<D, R, P, X>;
17
+ /** Context variables set by {@link requirePermission}. */
18
+ interface PermissionVariables {
19
+ /** The allowing decision for the guarded path. */
20
+ permission: CheckResult;
21
+ }
22
+ /** Hono middleware guarding a route with a permission path. Resolvers receive the `Context`. */
23
+ declare function requirePermission<E extends AnyPermissions>(engine: E, path: PathOf<E>, options: RequirePermissionOptions<Context>): MiddlewareHandler<{
24
+ Variables: PermissionVariables;
25
+ }>;
26
+ /** Context variables set by {@link requireRelation}. */
27
+ interface RelationVariables {
28
+ /** The allowing relationship decision. */
29
+ relation: RelationDecision;
30
+ }
31
+ /**
32
+ * Hono middleware guarding a route with a relationship (ReBAC): the caller (`user:{id}` unless
33
+ * `subjectRef`) must have `relation` on the object (`(c) => \`doc:${c.req.param("id")}\``).
34
+ */
35
+ declare function requireRelation<E extends AnyPermissions>(engine: E, relation: string, object: RelationObjectInput<Context>, options: RequireRelationOptions<Context>): MiddlewareHandler<{
36
+ Variables: RelationVariables;
37
+ }>;
38
+ //#endregion
39
+ export { HonoPermissionsPanel, PermissionVariables, type PermissionsPanelOptions, type RelationDecision, type RelationObjectInput, RelationVariables, type RequirePermissionOptions, type RequireRelationOptions, permissionsPanel, requirePermission, requireRelation };
40
+ //# sourceMappingURL=entry-hono.d.cts.map
@@ -0,0 +1,40 @@
1
+ import { s as Definition } from "./policy-CGA6QD0a.mjs";
2
+ import { h as CheckResult } from "./contract-DhS23Pcp.mjs";
3
+ import { t as AnyPermissions } from "./engine-C3xHfi3q.mjs";
4
+ import { n as PermissionsPanelOptions, t as CreateFetchHandlerResult } from "./create-fetch-handler-B711wb64.mjs";
5
+ import { a as RequireRelationOptions, i as RequirePermissionOptions, n as RelationDecision, r as RelationObjectInput, t as PathOf } from "./guard-k7A71SWC.mjs";
6
+ import { Context, Hono, MiddlewareHandler } from "hono";
7
+
8
+ //#region src/adapters/hono.d.ts
9
+ /** The Hono sub-app {@link permissionsPanel} returns, with the engine attached. */
10
+ type HonoPermissionsPanel<D extends Definition = Definition, R extends string = string, P extends string = string, X = undefined> = Hono & {
11
+ engine: CreateFetchHandlerResult<D, R, P, X>["engine"];
12
+ openapi: CreateFetchHandlerResult<D, R, P, X>["openapi"];
13
+ close: CreateFetchHandlerResult<D, R, P, X>["close"];
14
+ };
15
+ /** Create a Hono sub-app serving the panel. */
16
+ declare function permissionsPanel<D extends Definition = Definition, R extends string = string, P extends string = string, X = undefined>(options: PermissionsPanelOptions<D, R, P, X>): HonoPermissionsPanel<D, R, P, X>;
17
+ /** Context variables set by {@link requirePermission}. */
18
+ interface PermissionVariables {
19
+ /** The allowing decision for the guarded path. */
20
+ permission: CheckResult;
21
+ }
22
+ /** Hono middleware guarding a route with a permission path. Resolvers receive the `Context`. */
23
+ declare function requirePermission<E extends AnyPermissions>(engine: E, path: PathOf<E>, options: RequirePermissionOptions<Context>): MiddlewareHandler<{
24
+ Variables: PermissionVariables;
25
+ }>;
26
+ /** Context variables set by {@link requireRelation}. */
27
+ interface RelationVariables {
28
+ /** The allowing relationship decision. */
29
+ relation: RelationDecision;
30
+ }
31
+ /**
32
+ * Hono middleware guarding a route with a relationship (ReBAC): the caller (`user:{id}` unless
33
+ * `subjectRef`) must have `relation` on the object (`(c) => \`doc:${c.req.param("id")}\``).
34
+ */
35
+ declare function requireRelation<E extends AnyPermissions>(engine: E, relation: string, object: RelationObjectInput<Context>, options: RequireRelationOptions<Context>): MiddlewareHandler<{
36
+ Variables: RelationVariables;
37
+ }>;
38
+ //#endregion
39
+ export { HonoPermissionsPanel, PermissionVariables, type PermissionsPanelOptions, type RelationDecision, type RelationObjectInput, RelationVariables, type RequirePermissionOptions, type RequireRelationOptions, permissionsPanel, requirePermission, requireRelation };
40
+ //# sourceMappingURL=entry-hono.d.mts.map
@@ -0,0 +1,60 @@
1
+ import { t as createFetchHandler } from "./create-fetch-handler-B0twltQL.mjs";
2
+ import { c as relationOutcomeResponse, n as evaluateRelationGuard, o as outcomeResponse, r as guardEngine, s as relationGuardEngine, t as evaluateGuard } from "./guard-Bj8zk23F.mjs";
3
+ import { mountPanel } from "@xtandard/kit/adapters/hono";
4
+ import { Hono } from "hono";
5
+ //#region src/adapters/hono.ts
6
+ /**
7
+ * Hono adapter. {@link permissionsPanel} returns a `Hono` sub-app whose catch-all delegates to the
8
+ * panel handler (`app.route(path, panel)`); {@link requirePermission} is a middleware answering
9
+ * `401` / `403` JSON for denials and setting `c.var.permission` to the allowing decision.
10
+ *
11
+ * ```ts
12
+ * import { permissionsPanel, requirePermission } from "@xtandard/permissions/hono";
13
+ *
14
+ * app.route("/permissions", permissionsPanel({ permissions: perms, provider, basePath: "/permissions" }));
15
+ * app.post(
16
+ * "/posts/:id/publish",
17
+ * requirePermission(perms, "post.publish", { provider, data: (c) => c.get("post") }),
18
+ * (c) => c.json({ ok: true, reason: c.var.permission.reason }),
19
+ * );
20
+ * ```
21
+ *
22
+ * @module
23
+ */
24
+ /** Create a Hono sub-app serving the panel. */
25
+ function permissionsPanel(options) {
26
+ const handler = createFetchHandler(options);
27
+ const app = mountPanel(new Hono(), handler.fetch);
28
+ return Object.assign(app, {
29
+ engine: handler.engine,
30
+ openapi: handler.openapi,
31
+ close: handler.close
32
+ });
33
+ }
34
+ /** Hono middleware guarding a route with a permission path. Resolvers receive the `Context`. */
35
+ function requirePermission(engine, path, options) {
36
+ return async (c, next) => {
37
+ const ctx = c;
38
+ const outcome = await evaluateGuard(guardEngine(engine), path, options, ctx, (x) => x.req.raw);
39
+ if (!outcome.allowed) return outcomeResponse(outcome, options, ctx);
40
+ c.set("permission", outcome.result);
41
+ await next();
42
+ };
43
+ }
44
+ /**
45
+ * Hono middleware guarding a route with a relationship (ReBAC): the caller (`user:{id}` unless
46
+ * `subjectRef`) must have `relation` on the object (`(c) => \`doc:${c.req.param("id")}\``).
47
+ */
48
+ function requireRelation(engine, relation, object, options) {
49
+ return async (c, next) => {
50
+ const ctx = c;
51
+ const outcome = await evaluateRelationGuard(relationGuardEngine(engine), relation, object, options, ctx, (x) => x.req.raw);
52
+ if (!outcome.allowed) return relationOutcomeResponse(outcome, options, ctx);
53
+ c.set("relation", outcome.result);
54
+ await next();
55
+ };
56
+ }
57
+ //#endregion
58
+ export { permissionsPanel, requirePermission, requireRelation };
59
+
60
+ //# sourceMappingURL=entry-hono.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entry-hono.mjs","names":[],"sources":["../src/adapters/hono.ts"],"sourcesContent":["/**\n * Hono adapter. {@link permissionsPanel} returns a `Hono` sub-app whose catch-all delegates to the\n * panel handler (`app.route(path, panel)`); {@link requirePermission} is a middleware answering\n * `401` / `403` JSON for denials and setting `c.var.permission` to the allowing decision.\n *\n * ```ts\n * import { permissionsPanel, requirePermission } from \"@xtandard/permissions/hono\";\n *\n * app.route(\"/permissions\", permissionsPanel({ permissions: perms, provider, basePath: \"/permissions\" }));\n * app.post(\n * \"/posts/:id/publish\",\n * requirePermission(perms, \"post.publish\", { provider, data: (c) => c.get(\"post\") }),\n * (c) => c.json({ ok: true, reason: c.var.permission.reason }),\n * );\n * ```\n *\n * @module\n */\n\nimport { mountPanel } from \"@xtandard/kit/adapters/hono\";\nimport { Hono, type Context, type MiddlewareHandler } from \"hono\";\nimport type { AnyPermissions } from \"../engine.ts\";\nimport type { Definition } from \"../policy.ts\";\nimport type { CheckResult } from \"../schema.ts\";\nimport {\n createFetchHandler,\n type CreateFetchHandlerResult,\n type PermissionsPanelOptions,\n} from \"../server/create-fetch-handler.ts\";\nimport {\n evaluateGuard,\n guardEngine,\n outcomeResponse,\n evaluateRelationGuard,\n relationGuardEngine,\n relationOutcomeResponse,\n type RelationDecision,\n type RelationObjectInput,\n type RequireRelationOptions,\n type PathOf,\n type RequirePermissionOptions,\n} from \"./guard.ts\";\n\n/** The Hono sub-app {@link permissionsPanel} returns, with the engine attached. */\nexport type HonoPermissionsPanel<\n D extends Definition = Definition,\n R extends string = string,\n P extends string = string,\n X = undefined,\n> = Hono & {\n engine: CreateFetchHandlerResult<D, R, P, X>[\"engine\"];\n openapi: CreateFetchHandlerResult<D, R, P, X>[\"openapi\"];\n close: CreateFetchHandlerResult<D, R, P, X>[\"close\"];\n};\n\n/** Create a Hono sub-app serving the panel. */\nexport function permissionsPanel<\n D extends Definition = Definition,\n R extends string = string,\n P extends string = string,\n X = undefined,\n>(options: PermissionsPanelOptions<D, R, P, X>): HonoPermissionsPanel<D, R, P, X> {\n const handler = createFetchHandler(options);\n const app = mountPanel(new Hono(), handler.fetch);\n return Object.assign(app, {\n engine: handler.engine,\n openapi: handler.openapi,\n close: handler.close,\n });\n}\n\n/** Context variables set by {@link requirePermission}. */\nexport interface PermissionVariables {\n /** The allowing decision for the guarded path. */\n permission: CheckResult;\n}\n\n/** Hono middleware guarding a route with a permission path. Resolvers receive the `Context`. */\nexport function requirePermission<E extends AnyPermissions>(\n engine: E,\n path: PathOf<E>,\n options: RequirePermissionOptions<Context>,\n): MiddlewareHandler<{ Variables: PermissionVariables }> {\n return async (c, next) => {\n const ctx = c as unknown as Context;\n const outcome = await evaluateGuard(guardEngine(engine), path, options, ctx, (x) => x.req.raw);\n if (!outcome.allowed) return outcomeResponse(outcome, options, ctx);\n c.set(\"permission\", outcome.result);\n await next();\n };\n}\n\n/** Context variables set by {@link requireRelation}. */\nexport interface RelationVariables {\n /** The allowing relationship decision. */\n relation: RelationDecision;\n}\n\n/**\n * Hono middleware guarding a route with a relationship (ReBAC): the caller (`user:{id}` unless\n * `subjectRef`) must have `relation` on the object (`(c) => \\`doc:${c.req.param(\"id\")}\\``).\n */\nexport function requireRelation<E extends AnyPermissions>(\n engine: E,\n relation: string,\n object: RelationObjectInput<Context>,\n options: RequireRelationOptions<Context>,\n): MiddlewareHandler<{ Variables: RelationVariables }> {\n return async (c, next) => {\n const ctx = c as unknown as Context;\n const outcome = await evaluateRelationGuard(\n relationGuardEngine(engine),\n relation,\n object,\n options,\n ctx,\n (x) => x.req.raw,\n );\n if (!outcome.allowed) return relationOutcomeResponse(outcome, options, ctx);\n c.set(\"relation\", outcome.result);\n await next();\n };\n}\n\nexport type {\n PermissionsPanelOptions,\n RelationDecision,\n RelationObjectInput,\n RequirePermissionOptions,\n RequireRelationOptions,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAwDA,SAAgB,iBAKd,SAAgF;CAChF,MAAM,UAAU,mBAAmB,OAAO;CAC1C,MAAM,MAAM,WAAW,IAAI,KAAK,GAAG,QAAQ,KAAK;CAChD,OAAO,OAAO,OAAO,KAAK;EACxB,QAAQ,QAAQ;EAChB,SAAS,QAAQ;EACjB,OAAO,QAAQ;CACjB,CAAC;AACH;;AASA,SAAgB,kBACd,QACA,MACA,SACuD;CACvD,OAAO,OAAO,GAAG,SAAS;EACxB,MAAM,MAAM;EACZ,MAAM,UAAU,MAAM,cAAc,YAAY,MAAM,GAAG,MAAM,SAAS,MAAM,MAAM,EAAE,IAAI,GAAG;EAC7F,IAAI,CAAC,QAAQ,SAAS,OAAO,gBAAgB,SAAS,SAAS,GAAG;EAClE,EAAE,IAAI,cAAc,QAAQ,MAAM;EAClC,MAAM,KAAK;CACb;AACF;;;;;AAYA,SAAgB,gBACd,QACA,UACA,QACA,SACqD;CACrD,OAAO,OAAO,GAAG,SAAS;EACxB,MAAM,MAAM;EACZ,MAAM,UAAU,MAAM,sBACpB,oBAAoB,MAAM,GAC1B,UACA,QACA,SACA,MACC,MAAM,EAAE,IAAI,GACf;EACA,IAAI,CAAC,QAAQ,SAAS,OAAO,wBAAwB,SAAS,SAAS,GAAG;EAC1E,EAAE,IAAI,YAAY,QAAQ,MAAM;EAChC,MAAM,KAAK;CACb;AACF"}
@@ -0,0 +1,39 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_chunk = require("./chunk-DakpK96I.cjs");
3
+ let _xtandard_kit_hooks_log = require("@xtandard/kit/hooks/log");
4
+ _xtandard_kit_hooks_log = require_chunk.__toESM(_xtandard_kit_hooks_log, 1);
5
+ //#region src/hooks/log.ts
6
+ /**
7
+ * `@xtandard/permissions/hooks/log` — a reference hook that logs control-plane
8
+ * events (grants, revokes, role changes).
9
+ *
10
+ * The simplest possible consumer of the hooks seam: useful as a starting point
11
+ * for your own `after` side effects, and handy for local debugging or piping
12
+ * admin activity to a log aggregator (`json: true` prints one JSON object per
13
+ * line). Zero dependencies.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * import { createPermissions } from "@xtandard/permissions";
18
+ * import { createLogHook } from "@xtandard/permissions/hooks/log";
19
+ *
20
+ * createPermissions({ catalog, storage, hooks: createLogHook({ json: true }) });
21
+ * ```
22
+ *
23
+ * @module
24
+ */
25
+ /**
26
+ * Build a hook that logs each control-plane event. Never throws from `before`,
27
+ * so it never denies a mutation — it is a pure observer.
28
+ */
29
+ function createLogHook(options = {}) {
30
+ return _xtandard_kit_hooks_log.createLogHook({
31
+ ...options,
32
+ source: "@xtandard/permissions",
33
+ describe: (event) => event.subject
34
+ });
35
+ }
36
+ //#endregion
37
+ exports.createLogHook = createLogHook;
38
+
39
+ //# sourceMappingURL=entry-hooks-log.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entry-hooks-log.cjs","names":["kit"],"sources":["../src/hooks/log.ts"],"sourcesContent":["/**\n * `@xtandard/permissions/hooks/log` — a reference hook that logs control-plane\n * events (grants, revokes, role changes).\n *\n * The simplest possible consumer of the hooks seam: useful as a starting point\n * for your own `after` side effects, and handy for local debugging or piping\n * admin activity to a log aggregator (`json: true` prints one JSON object per\n * line). Zero dependencies.\n *\n * @example\n * ```ts\n * import { createPermissions } from \"@xtandard/permissions\";\n * import { createLogHook } from \"@xtandard/permissions/hooks/log\";\n *\n * createPermissions({ catalog, storage, hooks: createLogHook({ json: true }) });\n * ```\n *\n * @module\n */\n\nimport * as kit from \"@xtandard/kit/hooks/log\";\nimport type { AfterEvent, BeforeEvent, PermissionsHooks } from \"./contract.ts\";\n\n/**\n * Options for {@link createLogHook}: `log` (default `console.log`),\n * `includeBefore` (default `false`), `json` (one `{ source, phase, ...event }`\n * object per line) and `format`. The default text line is\n * `[@xtandard/permissions] <phase> <type> <subject>` + the JSON payload.\n */\nexport type LogHookOptions = Omit<\n kit.LogHookOptions<BeforeEvent, AfterEvent>,\n \"source\" | \"describe\"\n>;\n\n/**\n * Build a hook that logs each control-plane event. Never throws from `before`,\n * so it never denies a mutation — it is a pure observer.\n */\nexport function createLogHook(options: LogHookOptions = {}): PermissionsHooks {\n return kit.createLogHook<BeforeEvent, AfterEvent>({\n ...options,\n source: \"@xtandard/permissions\",\n describe: (event) => event.subject,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,SAAgB,cAAc,UAA0B,CAAC,GAAqB;CAC5E,OAAOA,wBAAI,cAAuC;EAChD,GAAG;EACH,QAAQ;EACR,WAAW,UAAU,MAAM;CAC7B,CAAC;AACH"}
@@ -0,0 +1,19 @@
1
+ import { r as BeforeEvent, s as PermissionsHooks, t as AfterEvent } from "./contract-CXPMGuHk.cjs";
2
+ import * as kit from "@xtandard/kit/hooks/log";
3
+
4
+ //#region src/hooks/log.d.ts
5
+ /**
6
+ * Options for {@link createLogHook}: `log` (default `console.log`),
7
+ * `includeBefore` (default `false`), `json` (one `{ source, phase, ...event }`
8
+ * object per line) and `format`. The default text line is
9
+ * `[@xtandard/permissions] <phase> <type> <subject>` + the JSON payload.
10
+ */
11
+ type LogHookOptions = Omit<kit.LogHookOptions<BeforeEvent, AfterEvent>, "source" | "describe">;
12
+ /**
13
+ * Build a hook that logs each control-plane event. Never throws from `before`,
14
+ * so it never denies a mutation — it is a pure observer.
15
+ */
16
+ declare function createLogHook(options?: LogHookOptions): PermissionsHooks;
17
+ //#endregion
18
+ export { LogHookOptions, createLogHook };
19
+ //# sourceMappingURL=entry-hooks-log.d.cts.map
@@ -0,0 +1,19 @@
1
+ import { r as BeforeEvent, s as PermissionsHooks, t as AfterEvent } from "./contract-DhS23Pcp.mjs";
2
+ import * as kit from "@xtandard/kit/hooks/log";
3
+
4
+ //#region src/hooks/log.d.ts
5
+ /**
6
+ * Options for {@link createLogHook}: `log` (default `console.log`),
7
+ * `includeBefore` (default `false`), `json` (one `{ source, phase, ...event }`
8
+ * object per line) and `format`. The default text line is
9
+ * `[@xtandard/permissions] <phase> <type> <subject>` + the JSON payload.
10
+ */
11
+ type LogHookOptions = Omit<kit.LogHookOptions<BeforeEvent, AfterEvent>, "source" | "describe">;
12
+ /**
13
+ * Build a hook that logs each control-plane event. Never throws from `before`,
14
+ * so it never denies a mutation — it is a pure observer.
15
+ */
16
+ declare function createLogHook(options?: LogHookOptions): PermissionsHooks;
17
+ //#endregion
18
+ export { LogHookOptions, createLogHook };
19
+ //# sourceMappingURL=entry-hooks-log.d.mts.map