@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.
- package/LICENSE +21 -0
- package/README.md +362 -2
- package/bin/xtandard-permissions.mjs +3 -0
- package/dist/better-auth-Bp9YVyQa.d.cts +56 -0
- package/dist/better-auth-DHyW5-yt.cjs +91 -0
- package/dist/better-auth-DHyW5-yt.cjs.map +1 -0
- package/dist/better-auth-NO40ZqSM.mjs +74 -0
- package/dist/better-auth-NO40ZqSM.mjs.map +1 -0
- package/dist/better-auth-NSXgt6ZU.d.mts +56 -0
- package/dist/catalog-DA_d1SdC.d.cts +153 -0
- package/dist/catalog-DJcJ3ycq.d.mts +153 -0
- package/dist/catalog.cjs +198 -0
- package/dist/catalog.cjs.map +1 -0
- package/dist/catalog.d.cts +3 -0
- package/dist/catalog.d.mts +3 -0
- package/dist/catalog.mjs +141 -0
- package/dist/catalog.mjs.map +1 -0
- package/dist/chunk-DakpK96I.cjs +43 -0
- package/dist/cli.cjs +548 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.cts +28 -0
- package/dist/cli.d.mts +28 -0
- package/dist/cli.mjs +544 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/contract-BMiOmg2f.d.cts +50 -0
- package/dist/contract-Bpy8yPrS.cjs +70 -0
- package/dist/contract-Bpy8yPrS.cjs.map +1 -0
- package/dist/contract-CNgMXr2u.d.cts +46 -0
- package/dist/contract-CNgMXr2u.d.mts +46 -0
- package/dist/contract-CPmJVoRx.cjs +70 -0
- package/dist/contract-CPmJVoRx.cjs.map +1 -0
- package/dist/contract-D32H1t0u.d.mts +50 -0
- package/dist/contract-DTdTXZtJ.mjs +47 -0
- package/dist/contract-DTdTXZtJ.mjs.map +1 -0
- package/dist/contract-DUzgB-He.d.mts +375 -0
- package/dist/contract-Dk6d2ylD.d.cts +375 -0
- package/dist/contract-RMkmERhT.d.cts +2 -0
- package/dist/contract-RMkmERhT.d.mts +2 -0
- package/dist/contract-Yc5AZuvv.mjs +47 -0
- package/dist/contract-Yc5AZuvv.mjs.map +1 -0
- package/dist/create-fetch-handler-BHDU4chu.d.mts +77 -0
- package/dist/create-fetch-handler-BtX64_rS.d.cts +77 -0
- package/dist/create-fetch-handler-C-WyaRCR.cjs +653 -0
- package/dist/create-fetch-handler-C-WyaRCR.cjs.map +1 -0
- package/dist/create-fetch-handler-ojjpk1Iw.mjs +636 -0
- package/dist/create-fetch-handler-ojjpk1Iw.mjs.map +1 -0
- package/dist/elysia-shared-BM6cPoCU.mjs +78 -0
- package/dist/elysia-shared-BM6cPoCU.mjs.map +1 -0
- package/dist/elysia-shared-BUTFTeal.cjs +101 -0
- package/dist/elysia-shared-BUTFTeal.cjs.map +1 -0
- package/dist/elysia-shared-DtKViycb.d.cts +58 -0
- package/dist/elysia-shared-g8zsb_pU.d.mts +58 -0
- package/dist/engine-Bufv0TbD.mjs +574 -0
- package/dist/engine-Bufv0TbD.mjs.map +1 -0
- package/dist/engine-CGGVDCqi.d.cts +296 -0
- package/dist/engine-DpFIcbgh.d.mts +296 -0
- package/dist/engine-bMoz3iW-.cjs +587 -0
- package/dist/engine-bMoz3iW-.cjs.map +1 -0
- package/dist/entry-auth-basic.cjs +40 -0
- package/dist/entry-auth-basic.cjs.map +1 -0
- package/dist/entry-auth-basic.d.cts +24 -0
- package/dist/entry-auth-basic.d.mts +24 -0
- package/dist/entry-auth-basic.mjs +26 -0
- package/dist/entry-auth-basic.mjs.map +1 -0
- package/dist/entry-auth-better-auth.cjs +12 -0
- package/dist/entry-auth-better-auth.d.cts +5 -0
- package/dist/entry-auth-better-auth.d.mts +5 -0
- package/dist/entry-auth-better-auth.mjs +4 -0
- package/dist/entry-auth-delegated.cjs +8 -0
- package/dist/entry-auth-delegated.d.cts +2 -0
- package/dist/entry-auth-delegated.d.mts +2 -0
- package/dist/entry-auth-delegated.mjs +2 -0
- package/dist/entry-auth-jwt.cjs +116 -0
- package/dist/entry-auth-jwt.cjs.map +1 -0
- package/dist/entry-auth-jwt.d.cts +65 -0
- package/dist/entry-auth-jwt.d.mts +65 -0
- package/dist/entry-auth-jwt.mjs +108 -0
- package/dist/entry-auth-jwt.mjs.map +1 -0
- package/dist/entry-auth-none.cjs +14 -0
- package/dist/entry-auth-none.d.cts +2 -0
- package/dist/entry-auth-none.d.mts +2 -0
- package/dist/entry-auth-none.mjs +2 -0
- package/dist/entry-auth-session.cjs +82 -0
- package/dist/entry-auth-session.cjs.map +1 -0
- package/dist/entry-auth-session.d.cts +20 -0
- package/dist/entry-auth-session.d.mts +20 -0
- package/dist/entry-auth-session.mjs +75 -0
- package/dist/entry-auth-session.mjs.map +1 -0
- package/dist/entry-authorization-delegated.cjs +31 -0
- package/dist/entry-authorization-delegated.cjs.map +1 -0
- package/dist/entry-authorization-delegated.d.cts +27 -0
- package/dist/entry-authorization-delegated.d.mts +27 -0
- package/dist/entry-authorization-delegated.mjs +30 -0
- package/dist/entry-authorization-delegated.mjs.map +1 -0
- package/dist/entry-authorization-none.cjs +29 -0
- package/dist/entry-authorization-none.cjs.map +1 -0
- package/dist/entry-authorization-none.d.cts +17 -0
- package/dist/entry-authorization-none.d.mts +17 -0
- package/dist/entry-authorization-none.mjs +28 -0
- package/dist/entry-authorization-none.mjs.map +1 -0
- package/dist/entry-authorization-permissions.cjs +4 -0
- package/dist/entry-authorization-permissions.d.cts +49 -0
- package/dist/entry-authorization-permissions.d.mts +49 -0
- package/dist/entry-authorization-permissions.mjs +2 -0
- package/dist/entry-authorization-roles.cjs +9 -0
- package/dist/entry-authorization-roles.d.cts +37 -0
- package/dist/entry-authorization-roles.d.mts +37 -0
- package/dist/entry-authorization-roles.mjs +3 -0
- package/dist/entry-better-auth-client.cjs +31 -0
- package/dist/entry-better-auth-client.cjs.map +1 -0
- package/dist/entry-better-auth-client.d.cts +63 -0
- package/dist/entry-better-auth-client.d.mts +63 -0
- package/dist/entry-better-auth-client.mjs +29 -0
- package/dist/entry-better-auth-client.mjs.map +1 -0
- package/dist/entry-better-auth.cjs +289 -0
- package/dist/entry-better-auth.cjs.map +1 -0
- package/dist/entry-better-auth.d.cts +3 -0
- package/dist/entry-better-auth.d.mts +3 -0
- package/dist/entry-better-auth.mjs +284 -0
- package/dist/entry-better-auth.mjs.map +1 -0
- package/dist/entry-bridges-audit.cjs +106 -0
- package/dist/entry-bridges-audit.cjs.map +1 -0
- package/dist/entry-bridges-audit.d.cts +58 -0
- package/dist/entry-bridges-audit.d.mts +58 -0
- package/dist/entry-bridges-audit.mjs +105 -0
- package/dist/entry-bridges-audit.mjs.map +1 -0
- package/dist/entry-bridges-webhooks.cjs +90 -0
- package/dist/entry-bridges-webhooks.cjs.map +1 -0
- package/dist/entry-bridges-webhooks.d.cts +46 -0
- package/dist/entry-bridges-webhooks.d.mts +46 -0
- package/dist/entry-bridges-webhooks.mjs +88 -0
- package/dist/entry-bridges-webhooks.mjs.map +1 -0
- package/dist/entry-bun.cjs +33 -0
- package/dist/entry-bun.cjs.map +1 -0
- package/dist/entry-bun.d.cts +31 -0
- package/dist/entry-bun.d.mts +31 -0
- package/dist/entry-bun.mjs +30 -0
- package/dist/entry-bun.mjs.map +1 -0
- package/dist/entry-drizzle-mysql.cjs +34 -0
- package/dist/entry-drizzle-mysql.cjs.map +1 -0
- package/dist/entry-drizzle-mysql.d.cts +20 -0
- package/dist/entry-drizzle-mysql.d.mts +20 -0
- package/dist/entry-drizzle-mysql.mjs +33 -0
- package/dist/entry-drizzle-mysql.mjs.map +1 -0
- package/dist/entry-drizzle-pg.cjs +44 -0
- package/dist/entry-drizzle-pg.cjs.map +1 -0
- package/dist/entry-drizzle-pg.d.cts +20 -0
- package/dist/entry-drizzle-pg.d.mts +20 -0
- package/dist/entry-drizzle-pg.mjs +43 -0
- package/dist/entry-drizzle-pg.mjs.map +1 -0
- package/dist/entry-drizzle-sqlite.cjs +34 -0
- package/dist/entry-drizzle-sqlite.cjs.map +1 -0
- package/dist/entry-drizzle-sqlite.d.cts +15 -0
- package/dist/entry-drizzle-sqlite.d.mts +15 -0
- package/dist/entry-drizzle-sqlite.mjs +33 -0
- package/dist/entry-drizzle-sqlite.mjs.map +1 -0
- package/dist/entry-elysia.cjs +117 -0
- package/dist/entry-elysia.cjs.map +1 -0
- package/dist/entry-elysia.d.cts +446 -0
- package/dist/entry-elysia.d.mts +446 -0
- package/dist/entry-elysia.mjs +113 -0
- package/dist/entry-elysia.mjs.map +1 -0
- package/dist/entry-elysia2.cjs +117 -0
- package/dist/entry-elysia2.cjs.map +1 -0
- package/dist/entry-elysia2.d.cts +571 -0
- package/dist/entry-elysia2.d.mts +571 -0
- package/dist/entry-elysia2.mjs +113 -0
- package/dist/entry-elysia2.mjs.map +1 -0
- package/dist/entry-express.cjs +101 -0
- package/dist/entry-express.cjs.map +1 -0
- package/dist/entry-express.d.cts +36 -0
- package/dist/entry-express.d.mts +36 -0
- package/dist/entry-express.mjs +97 -0
- package/dist/entry-express.mjs.map +1 -0
- package/dist/entry-hono.cjs +63 -0
- package/dist/entry-hono.cjs.map +1 -0
- package/dist/entry-hono.d.cts +40 -0
- package/dist/entry-hono.d.mts +40 -0
- package/dist/entry-hono.mjs +60 -0
- package/dist/entry-hono.mjs.map +1 -0
- package/dist/entry-hooks-log.cjs +39 -0
- package/dist/entry-hooks-log.cjs.map +1 -0
- package/dist/entry-hooks-log.d.cts +19 -0
- package/dist/entry-hooks-log.d.mts +19 -0
- package/dist/entry-hooks-log.mjs +36 -0
- package/dist/entry-hooks-log.mjs.map +1 -0
- package/dist/entry-next.cjs +67 -0
- package/dist/entry-next.cjs.map +1 -0
- package/dist/entry-next.d.cts +60 -0
- package/dist/entry-next.d.mts +60 -0
- package/dist/entry-next.mjs +57 -0
- package/dist/entry-next.mjs.map +1 -0
- package/dist/entry-react.cjs +401 -0
- package/dist/entry-react.cjs.map +1 -0
- package/dist/entry-react.d.cts +206 -0
- package/dist/entry-react.d.mts +206 -0
- package/dist/entry-react.mjs +388 -0
- package/dist/entry-react.mjs.map +1 -0
- package/dist/entry-storage-cloudflare-kv.cjs +8 -0
- package/dist/entry-storage-cloudflare-kv.d.cts +2 -0
- package/dist/entry-storage-cloudflare-kv.d.mts +2 -0
- package/dist/entry-storage-cloudflare-kv.mjs +2 -0
- package/dist/entry-storage-drizzle.cjs +71 -0
- package/dist/entry-storage-drizzle.cjs.map +1 -0
- package/dist/entry-storage-drizzle.d.cts +27 -0
- package/dist/entry-storage-drizzle.d.mts +27 -0
- package/dist/entry-storage-drizzle.mjs +68 -0
- package/dist/entry-storage-drizzle.mjs.map +1 -0
- package/dist/entry-storage-file.cjs +54 -0
- package/dist/entry-storage-file.cjs.map +1 -0
- package/dist/entry-storage-file.d.cts +24 -0
- package/dist/entry-storage-file.d.mts +24 -0
- package/dist/entry-storage-file.mjs +46 -0
- package/dist/entry-storage-file.mjs.map +1 -0
- package/dist/entry-storage-libsql.cjs +64 -0
- package/dist/entry-storage-libsql.cjs.map +1 -0
- package/dist/entry-storage-libsql.d.cts +28 -0
- package/dist/entry-storage-libsql.d.mts +28 -0
- package/dist/entry-storage-libsql.mjs +61 -0
- package/dist/entry-storage-libsql.mjs.map +1 -0
- package/dist/entry-storage-memory.cjs +3 -0
- package/dist/entry-storage-memory.d.cts +25 -0
- package/dist/entry-storage-memory.d.mts +25 -0
- package/dist/entry-storage-memory.mjs +2 -0
- package/dist/entry-storage-mongodb.cjs +61 -0
- package/dist/entry-storage-mongodb.cjs.map +1 -0
- package/dist/entry-storage-mongodb.d.cts +25 -0
- package/dist/entry-storage-mongodb.d.mts +25 -0
- package/dist/entry-storage-mongodb.mjs +58 -0
- package/dist/entry-storage-mongodb.mjs.map +1 -0
- package/dist/entry-storage-postgres.cjs +62 -0
- package/dist/entry-storage-postgres.cjs.map +1 -0
- package/dist/entry-storage-postgres.d.cts +29 -0
- package/dist/entry-storage-postgres.d.mts +29 -0
- package/dist/entry-storage-postgres.mjs +58 -0
- package/dist/entry-storage-postgres.mjs.map +1 -0
- package/dist/entry-storage-redis.cjs +76 -0
- package/dist/entry-storage-redis.cjs.map +1 -0
- package/dist/entry-storage-redis.d.cts +29 -0
- package/dist/entry-storage-redis.d.mts +29 -0
- package/dist/entry-storage-redis.mjs +72 -0
- package/dist/entry-storage-redis.mjs.map +1 -0
- package/dist/entry-storage-sqlite.cjs +46 -0
- package/dist/entry-storage-sqlite.cjs.map +1 -0
- package/dist/entry-storage-sqlite.d.cts +22 -0
- package/dist/entry-storage-sqlite.d.mts +22 -0
- package/dist/entry-storage-sqlite.mjs +43 -0
- package/dist/entry-storage-sqlite.mjs.map +1 -0
- package/dist/entry-storage-unstorage.cjs +8 -0
- package/dist/entry-storage-unstorage.d.cts +2 -0
- package/dist/entry-storage-unstorage.d.mts +2 -0
- package/dist/entry-storage-unstorage.mjs +2 -0
- package/dist/error-codes-9MRMSSMQ.cjs +49 -0
- package/dist/error-codes-9MRMSSMQ.cjs.map +1 -0
- package/dist/error-codes-CCKuDDu7.mjs +44 -0
- package/dist/error-codes-CCKuDDu7.mjs.map +1 -0
- package/dist/errors-bL3XQLfE.mjs +54 -0
- package/dist/errors-bL3XQLfE.mjs.map +1 -0
- package/dist/errors-vVYic8gz.cjs +89 -0
- package/dist/errors-vVYic8gz.cjs.map +1 -0
- package/dist/events-AE4Ytqmz.d.cts +6 -0
- package/dist/events-AE4Ytqmz.d.mts +6 -0
- package/dist/events-DYZShrYB.mjs +15 -0
- package/dist/events-DYZShrYB.mjs.map +1 -0
- package/dist/events-FJ2K0wly.cjs +26 -0
- package/dist/events-FJ2K0wly.cjs.map +1 -0
- package/dist/guard-BOx5cnMP.mjs +141 -0
- package/dist/guard-BOx5cnMP.mjs.map +1 -0
- package/dist/guard-C3o7V14m.d.cts +62 -0
- package/dist/guard-DCbTnqPz.d.mts +62 -0
- package/dist/guard-nwdOYe90.cjs +188 -0
- package/dist/guard-nwdOYe90.cjs.map +1 -0
- package/dist/index-BVVgDSdq.d.cts +1 -0
- package/dist/index-BVVgDSdq.d.mts +1 -0
- package/dist/index.cjs +240 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +195 -0
- package/dist/index.d.mts +195 -0
- package/dist/index.mjs +60 -0
- package/dist/index.mjs.map +1 -0
- package/dist/kit-C7tepDB2.cjs +76 -0
- package/dist/kit-C7tepDB2.cjs.map +1 -0
- package/dist/kit-DMVBLBI9.d.mts +57 -0
- package/dist/kit-fzXHYb1l.mjs +65 -0
- package/dist/kit-fzXHYb1l.mjs.map +1 -0
- package/dist/kit-qAROuhOI.d.cts +57 -0
- package/dist/memory-BbBbbY8-.mjs +32 -0
- package/dist/memory-BbBbbY8-.mjs.map +1 -0
- package/dist/memory-knijqKw_.cjs +39 -0
- package/dist/memory-knijqKw_.cjs.map +1 -0
- package/dist/permissions-C9PjftY6.mjs +59 -0
- package/dist/permissions-C9PjftY6.mjs.map +1 -0
- package/dist/permissions-Cxri_P_k.cjs +70 -0
- package/dist/permissions-Cxri_P_k.cjs.map +1 -0
- package/dist/policy-BQmlo2lu.mjs +3 -0
- package/dist/policy-CGA6QD0a.d.mts +4 -0
- package/dist/policy-DFq_SYR3.d.cts +4 -0
- package/dist/react-embed.js +18710 -0
- package/dist/react.css +1 -0
- package/dist/relationships-BLYEJ9tc.cjs +907 -0
- package/dist/relationships-BLYEJ9tc.cjs.map +1 -0
- package/dist/relationships-BfLonEMI.mjs +756 -0
- package/dist/relationships-BfLonEMI.mjs.map +1 -0
- package/dist/roles-DBk4i8b5.mjs +69 -0
- package/dist/roles-DBk4i8b5.mjs.map +1 -0
- package/dist/roles-a8B5uZ35.cjs +104 -0
- package/dist/roles-a8B5uZ35.cjs.map +1 -0
- package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
- package/dist/routes-DtRb3EO0.mjs +1001 -0
- package/dist/routes-DtRb3EO0.mjs.map +1 -0
- package/dist/routes-irNuuZqo.cjs +1049 -0
- package/dist/routes-irNuuZqo.cjs.map +1 -0
- package/dist/server-C2F4H6bR.d.cts +886 -0
- package/dist/server-CJ7AIJpO.d.mts +886 -0
- package/dist/table-DA98mVVT.d.cts +2 -0
- package/dist/table-DA98mVVT.d.mts +2 -0
- package/dist/testing.cjs +59 -0
- package/dist/testing.cjs.map +1 -0
- package/dist/testing.d.cts +37 -0
- package/dist/testing.d.mts +37 -0
- package/dist/testing.mjs +57 -0
- package/dist/testing.mjs.map +1 -0
- package/dist/types-elysia2/adapters/elysia-shared.d.ts +71 -0
- package/dist/types-elysia2/adapters/elysia2.d.ts +432 -0
- package/dist/types-elysia2/adapters/guard.d.ts +140 -0
- package/dist/types-elysia2/auth/contract.d.ts +9 -0
- package/dist/types-elysia2/auth-provider/contract.d.ts +57 -0
- package/dist/types-elysia2/auth-provider/kit.d.ts +57 -0
- package/dist/types-elysia2/authorization/contract.d.ts +53 -0
- package/dist/types-elysia2/authorization/permissions.d.ts +54 -0
- package/dist/types-elysia2/catalog.d.ts +197 -0
- package/dist/types-elysia2/engine.d.ts +192 -0
- package/dist/types-elysia2/entry-elysia2.d.ts +9 -0
- package/dist/types-elysia2/errors.d.ts +47 -0
- package/dist/types-elysia2/hooks/contract.d.ts +100 -0
- package/dist/types-elysia2/keys.d.ts +78 -0
- package/dist/types-elysia2/policy.d.ts +13 -0
- package/dist/types-elysia2/relationships.d.ts +162 -0
- package/dist/types-elysia2/schema.d.ts +299 -0
- package/dist/types-elysia2/server/cors.d.ts +8 -0
- package/dist/types-elysia2/server/create-fetch-handler.d.ts +87 -0
- package/dist/types-elysia2/server/openapi.d.ts +29 -0
- package/dist/types-elysia2/server/routes.d.ts +132 -0
- package/dist/types-elysia2/server/validation.d.ts +205 -0
- package/dist/types-elysia2/storage/contract.d.ts +18 -0
- package/dist/types-react/catalog.d.ts +197 -0
- package/dist/types-react/engine.d.ts +192 -0
- package/dist/types-react/entry-react-embed.d.ts +20 -0
- package/dist/types-react/errors.d.ts +47 -0
- package/dist/types-react/hooks/contract.d.ts +100 -0
- package/dist/types-react/keys.d.ts +78 -0
- package/dist/types-react/policy.d.ts +13 -0
- package/dist/types-react/react-embed.d.ts +37 -0
- package/dist/types-react/relationships.d.ts +162 -0
- package/dist/types-react/schema.d.ts +299 -0
- package/dist/types-react/storage/contract.d.ts +18 -0
- package/dist/types-react/ui/App.d.ts +23 -0
- package/dist/types-react/ui/api.d.ts +73 -0
- package/dist/types-react/ui/components/perm-bits.d.ts +64 -0
- package/dist/types-react/ui/lib/queries.d.ts +46 -0
- package/dist/types-react/ui/theme.d.ts +10 -0
- package/dist/types-react/ui/types.d.ts +109 -0
- package/dist/types-react/ui/views/CatalogView.d.ts +3 -0
- package/dist/types-react/ui/views/HistoryView.d.ts +6 -0
- package/dist/types-react/ui/views/PlaygroundView.d.ts +14 -0
- package/dist/types-react/ui/views/RelationshipsView.d.ts +6 -0
- package/dist/types-react/ui/views/SubjectDetailView.d.ts +7 -0
- package/dist/types-react/ui/views/SubjectsView.d.ts +6 -0
- package/dist/ui/apple-touch-icon.png +0 -0
- package/dist/ui/assets/index-DCPZRo-Z.css +1 -0
- package/dist/ui/assets/index-uXGOtyuj.js +104 -0
- package/dist/ui/favicon.ico +0 -0
- package/dist/ui/favicon.svg +15 -0
- package/dist/ui/index.html +20 -0
- package/package.json +587 -4
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
import { a as CheckExplanation } from "./policy-DFq_SYR3.cjs";
|
|
2
|
+
import { HookDeniedError, HookErrorReporter, Hooks, HooksInput, normalizeHooks, runAfter, runBefore } from "@xtandard/kit/hooks";
|
|
3
|
+
import { Actor } from "@xtandard/kit/util";
|
|
4
|
+
import * as v from "valibot";
|
|
5
|
+
|
|
6
|
+
//#region src/schema.d.ts
|
|
7
|
+
/** A permission granted to one subject. Stored at `perm/grants/{subject}/{permission}`. */
|
|
8
|
+
interface Grant<P extends string = string> {
|
|
9
|
+
/** The subject id. */
|
|
10
|
+
subject: string;
|
|
11
|
+
/** The permission (one of the catalog's `assignable`). */
|
|
12
|
+
permission: P;
|
|
13
|
+
/** The actor id that granted it: plain data, never a reference (ADR 0003). */
|
|
14
|
+
grantedBy: string | null;
|
|
15
|
+
/** ISO-8601. */
|
|
16
|
+
grantedAt: string;
|
|
17
|
+
/** Why it was granted. */
|
|
18
|
+
reason?: string;
|
|
19
|
+
/** ISO-8601; the grant stops counting at this instant. `null` / absent: never expires. */
|
|
20
|
+
expiresAt?: string | null;
|
|
21
|
+
}
|
|
22
|
+
/** Optional per-subject data. Stored at `perm/subjects/{subject}`. */
|
|
23
|
+
interface SubjectRecord {
|
|
24
|
+
id: string;
|
|
25
|
+
/** A stored role assignment; when absent, the auth provider's role (or `defaultRole`) applies. */
|
|
26
|
+
role?: string;
|
|
27
|
+
name?: string;
|
|
28
|
+
email?: string;
|
|
29
|
+
/** ISO-8601. */
|
|
30
|
+
updatedAt: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A stored relationship (ReBAC tuple, ADR 0013): `subject` has `relation` on `object`. Stored at
|
|
34
|
+
* `perm/rel/{objectType}/{objectId}/{relation}/{subject}`, plus a reverse key for listing.
|
|
35
|
+
*/
|
|
36
|
+
interface Relationship {
|
|
37
|
+
/** The object: `"doc:1"`. */
|
|
38
|
+
object: string;
|
|
39
|
+
/** A relation of the object's type: `"viewer"`. */
|
|
40
|
+
relation: string;
|
|
41
|
+
/** Who: `"user:ana"`, a userset `"group:eng#member"`, or a wildcard `"user:*"`. */
|
|
42
|
+
subject: string;
|
|
43
|
+
/** The actor id that wrote it: plain data, never a reference (ADR 0003). */
|
|
44
|
+
createdBy: string | null;
|
|
45
|
+
/** ISO-8601. */
|
|
46
|
+
createdAt: string;
|
|
47
|
+
/** Why it was written. */
|
|
48
|
+
reason?: string;
|
|
49
|
+
}
|
|
50
|
+
/** The kinds of {@link HistoryEntry}. */
|
|
51
|
+
type HistoryType = "grant" | "revoke" | "role" | "relate" | "unrelate";
|
|
52
|
+
/**
|
|
53
|
+
* One append-only history entry. Stored at `perm/history/{subject}/{at}-{id}`; for `relate` /
|
|
54
|
+
* `unrelate` the subject is the tuple's subject reference (`user:ana`, `group:eng#member`).
|
|
55
|
+
*/
|
|
56
|
+
interface HistoryEntry {
|
|
57
|
+
id: string;
|
|
58
|
+
type: HistoryType;
|
|
59
|
+
subject: string;
|
|
60
|
+
/** For `relate` / `unrelate`: the tuple's object. */
|
|
61
|
+
object?: string;
|
|
62
|
+
/** For `relate` / `unrelate`: the tuple's relation. */
|
|
63
|
+
relation?: string;
|
|
64
|
+
/** For `grant` / `revoke`. */
|
|
65
|
+
permission?: string;
|
|
66
|
+
/** For `role`: the new role, `null` when the assignment was cleared. */
|
|
67
|
+
role?: string | null;
|
|
68
|
+
/** For `role`: the role before the change (`null`: none was stored). */
|
|
69
|
+
previousRole?: string | null;
|
|
70
|
+
/** For `grant`: the expiry the grant was created with. */
|
|
71
|
+
expiresAt?: string | null;
|
|
72
|
+
/** The actor id. */
|
|
73
|
+
actor: string | null;
|
|
74
|
+
reason?: string;
|
|
75
|
+
/** ISO-8601. */
|
|
76
|
+
at: string;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Why a check came out the way it did (ADR 0005):
|
|
80
|
+
*
|
|
81
|
+
* - `grant`: `directGrants` is on and a non-expired grant named like the path allowed it;
|
|
82
|
+
* - `role-rule`: the role's rule allowed it;
|
|
83
|
+
* - `denied-by-rule`: the role's rule denied it (a `false` constant or a predicate that did not
|
|
84
|
+
* return `true`);
|
|
85
|
+
* - `rule-threw`: the rule threw (denied);
|
|
86
|
+
* - `unknown-path`: the role has no rule at that path (denied).
|
|
87
|
+
*/
|
|
88
|
+
type CheckReason = "grant" | "role-rule" | "denied-by-rule" | "rule-threw" | "unknown-path";
|
|
89
|
+
/** The outcome of `check()`. */
|
|
90
|
+
interface CheckResult<R extends string = string, P extends string = string> {
|
|
91
|
+
allowed: boolean;
|
|
92
|
+
/** The permix path, e.g. `"post.publish"`. */
|
|
93
|
+
path: string;
|
|
94
|
+
/** The subject id, `null` for a guest. */
|
|
95
|
+
subject: string | null;
|
|
96
|
+
/** The effective role the rules ran as. */
|
|
97
|
+
role: R;
|
|
98
|
+
reason: CheckReason;
|
|
99
|
+
/** The lib's `explain()` detail of the rule alone (role, permissions seen, what decided). */
|
|
100
|
+
explanation: CheckExplanation<R, P>;
|
|
101
|
+
}
|
|
102
|
+
/** The serializable state a client needs to rebuild a subject's ability (React, SSR). */
|
|
103
|
+
interface PermissionsSnapshot<R extends string = string, P extends string = string> {
|
|
104
|
+
subject: {
|
|
105
|
+
id: string | null;
|
|
106
|
+
role: R;
|
|
107
|
+
};
|
|
108
|
+
/** The non-expired, assignable granted permissions. */
|
|
109
|
+
permissions: P[];
|
|
110
|
+
}
|
|
111
|
+
/** Who performs a write: an actor id, an {@link Actor}, or `null` (system). */
|
|
112
|
+
declare const actorSchema: v.NullableSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>, v.ObjectSchema<{
|
|
113
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
|
|
114
|
+
readonly type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
115
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
116
|
+
readonly email: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
117
|
+
}, undefined>], undefined>, undefined>;
|
|
118
|
+
/** Input of `grant()`. */
|
|
119
|
+
declare const grantInputSchema: v.ObjectSchema<{
|
|
120
|
+
readonly subject: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
|
|
121
|
+
readonly permission: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
|
|
122
|
+
readonly actor: v.OptionalSchema<v.NullableSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>, v.ObjectSchema<{
|
|
123
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
|
|
124
|
+
readonly type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
125
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
126
|
+
readonly email: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
127
|
+
}, undefined>], undefined>, undefined>, undefined>;
|
|
128
|
+
readonly reason: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 1000, "must be at most 1000 characters">]>, undefined>; /** ISO string, `Date` or unix ms; `null` = never. */
|
|
129
|
+
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>;
|
|
130
|
+
}, undefined>;
|
|
131
|
+
/** Input of `revoke()`. */
|
|
132
|
+
declare const revokeInputSchema: v.ObjectSchema<{
|
|
133
|
+
readonly subject: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
|
|
134
|
+
readonly permission: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
|
|
135
|
+
readonly actor: v.OptionalSchema<v.NullableSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>, v.ObjectSchema<{
|
|
136
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
|
|
137
|
+
readonly type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
138
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
139
|
+
readonly email: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
140
|
+
}, undefined>], undefined>, undefined>, undefined>;
|
|
141
|
+
readonly reason: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 1000, "must be at most 1000 characters">]>, undefined>;
|
|
142
|
+
}, undefined>;
|
|
143
|
+
/** Input of `setRole()`; `role: null` clears the stored assignment. */
|
|
144
|
+
declare const setRoleInputSchema: v.ObjectSchema<{
|
|
145
|
+
readonly subject: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
|
|
146
|
+
readonly role: v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>, undefined>;
|
|
147
|
+
readonly actor: v.OptionalSchema<v.NullableSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>, v.ObjectSchema<{
|
|
148
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
|
|
149
|
+
readonly type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
150
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
151
|
+
readonly email: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
152
|
+
}, undefined>], undefined>, undefined>, undefined>;
|
|
153
|
+
readonly reason: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 1000, "must be at most 1000 characters">]>, undefined>;
|
|
154
|
+
}, undefined>;
|
|
155
|
+
/** Input of `upsertSubject()`. `null` clears a field. */
|
|
156
|
+
declare const upsertSubjectInputSchema: v.ObjectSchema<{
|
|
157
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
|
|
158
|
+
readonly name: v.OptionalSchema<v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 500, undefined>]>, undefined>, undefined>;
|
|
159
|
+
readonly email: v.OptionalSchema<v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 500, undefined>]>, undefined>, undefined>;
|
|
160
|
+
}, undefined>;
|
|
161
|
+
/** Query of `list()`. */
|
|
162
|
+
declare const listQuerySchema: v.ObjectSchema<{
|
|
163
|
+
readonly subject: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>, undefined>;
|
|
164
|
+
readonly permission: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>, undefined>;
|
|
165
|
+
readonly includeExpired: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
166
|
+
}, undefined>;
|
|
167
|
+
/** Input of `writeRelationship()` / `deleteRelationship()`. */
|
|
168
|
+
declare const relationshipInputSchema: v.ObjectSchema<{
|
|
169
|
+
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)">]>;
|
|
170
|
+
readonly relation: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
|
|
171
|
+
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:*\"">]>;
|
|
172
|
+
readonly actor: v.OptionalSchema<v.NullableSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>, v.ObjectSchema<{
|
|
173
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
|
|
174
|
+
readonly type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
175
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
176
|
+
readonly email: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
177
|
+
}, undefined>], undefined>, undefined>, undefined>;
|
|
178
|
+
readonly reason: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 1000, "must be at most 1000 characters">]>, undefined>;
|
|
179
|
+
}, undefined>;
|
|
180
|
+
/** Query of `readRelationships()`. */
|
|
181
|
+
declare const relationshipQuerySchema: v.ObjectSchema<{
|
|
182
|
+
/** `type:id`, or just `type` for every object of a type. */readonly object: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>, undefined>;
|
|
183
|
+
readonly relation: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>, undefined>;
|
|
184
|
+
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>;
|
|
185
|
+
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>;
|
|
186
|
+
readonly cursor: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
187
|
+
}, undefined>;
|
|
188
|
+
/** Input of `checkRelation()`. */
|
|
189
|
+
declare const relationCheckSchema: v.ObjectSchema<{
|
|
190
|
+
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:*\"">]>;
|
|
191
|
+
readonly relation: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
|
|
192
|
+
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)">]>;
|
|
193
|
+
}, undefined>;
|
|
194
|
+
/** Query of `listObjects()`. */
|
|
195
|
+
declare const listObjectsQuerySchema: v.ObjectSchema<{
|
|
196
|
+
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:*\"">]>;
|
|
197
|
+
readonly relation: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
|
|
198
|
+
readonly type: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
|
|
199
|
+
}, undefined>;
|
|
200
|
+
/** Query of `listRelationSubjects()`. */
|
|
201
|
+
declare const listRelationSubjectsQuerySchema: v.ObjectSchema<{
|
|
202
|
+
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)">]>;
|
|
203
|
+
readonly relation: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>; /** Only subjects of this type. */
|
|
204
|
+
readonly type: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>, undefined>;
|
|
205
|
+
}, undefined>;
|
|
206
|
+
/** Query of `history()`. */
|
|
207
|
+
declare const historyQuerySchema: v.ObjectSchema<{
|
|
208
|
+
readonly subject: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>, undefined>;
|
|
209
|
+
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>;
|
|
210
|
+
readonly cursor: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
211
|
+
}, undefined>;
|
|
212
|
+
/** An ISO string, `Date` or unix ms. */
|
|
213
|
+
type InstantInput = string | Date | number;
|
|
214
|
+
/** Input of `grant()`, typed with the catalog's permissions. */
|
|
215
|
+
interface GrantInput<P extends string = string> {
|
|
216
|
+
subject: string;
|
|
217
|
+
permission: P;
|
|
218
|
+
actor?: string | Actor | null;
|
|
219
|
+
reason?: string;
|
|
220
|
+
/** When the grant stops counting; `null` / absent = never. */
|
|
221
|
+
expiresAt?: InstantInput | null;
|
|
222
|
+
}
|
|
223
|
+
/** Input of `revoke()`. */
|
|
224
|
+
interface RevokeInput<P extends string = string> {
|
|
225
|
+
subject: string;
|
|
226
|
+
permission: P;
|
|
227
|
+
actor?: string | Actor | null;
|
|
228
|
+
reason?: string;
|
|
229
|
+
}
|
|
230
|
+
/** Input of `setRole()`. */
|
|
231
|
+
interface SetRoleInput<R extends string = string> {
|
|
232
|
+
subject: string;
|
|
233
|
+
/** `null` clears the stored role (the auth provider's role, or `defaultRole`, applies again). */
|
|
234
|
+
role: R | null;
|
|
235
|
+
actor?: string | Actor | null;
|
|
236
|
+
reason?: string;
|
|
237
|
+
}
|
|
238
|
+
/** Input of `upsertSubject()`. A field left out is kept; `null` clears it. */
|
|
239
|
+
interface UpsertSubjectInput {
|
|
240
|
+
id: string;
|
|
241
|
+
name?: string | null;
|
|
242
|
+
email?: string | null;
|
|
243
|
+
}
|
|
244
|
+
/** Query of `list()`. Neither: every grant. */
|
|
245
|
+
interface ListQuery<P extends string = string> {
|
|
246
|
+
subject?: string;
|
|
247
|
+
permission?: P;
|
|
248
|
+
/** Include grants whose `expiresAt` has passed. Default `false`. */
|
|
249
|
+
includeExpired?: boolean;
|
|
250
|
+
}
|
|
251
|
+
/** Query of `history()`. */
|
|
252
|
+
interface HistoryQuery {
|
|
253
|
+
/** One subject's history; absent = everyone's. */
|
|
254
|
+
subject?: string;
|
|
255
|
+
/** Page size, 1–1000. Default 50. */
|
|
256
|
+
limit?: number;
|
|
257
|
+
/** The `nextCursor` of the previous page. */
|
|
258
|
+
cursor?: string;
|
|
259
|
+
}
|
|
260
|
+
/** Input of `writeRelationship()` / `deleteRelationship()`. */
|
|
261
|
+
interface RelationshipInput {
|
|
262
|
+
object: string;
|
|
263
|
+
relation: string;
|
|
264
|
+
subject: string;
|
|
265
|
+
actor?: string | Actor | null;
|
|
266
|
+
reason?: string;
|
|
267
|
+
}
|
|
268
|
+
/** Query of `readRelationships()`. Every field narrows; none: every relationship. */
|
|
269
|
+
interface RelationshipQuery {
|
|
270
|
+
/** `"doc:1"`, or a bare type (`"doc"`) for every object of that type. */
|
|
271
|
+
object?: string;
|
|
272
|
+
relation?: string;
|
|
273
|
+
/** Exactly this subject reference (`user:ana`, `group:eng#member`, `user:*`). */
|
|
274
|
+
subject?: string;
|
|
275
|
+
/** Page size, 1–1000. Default 100. */
|
|
276
|
+
limit?: number;
|
|
277
|
+
/** The `nextCursor` of the previous page. */
|
|
278
|
+
cursor?: string;
|
|
279
|
+
}
|
|
280
|
+
/** A page of relationships, sorted by object, relation, subject. */
|
|
281
|
+
interface RelationshipPage {
|
|
282
|
+
relationships: Relationship[];
|
|
283
|
+
/** Pass as `cursor` for the next page; `null` at the end. */
|
|
284
|
+
nextCursor: string | null;
|
|
285
|
+
}
|
|
286
|
+
/** A page of history, newest first. */
|
|
287
|
+
interface HistoryPage {
|
|
288
|
+
entries: HistoryEntry[];
|
|
289
|
+
/** Pass as `cursor` for the next (older) page; `null` at the end. */
|
|
290
|
+
nextCursor: string | null;
|
|
291
|
+
}
|
|
292
|
+
//#endregion
|
|
293
|
+
//#region src/hooks/contract.d.ts
|
|
294
|
+
/** Events delivered to `before` hooks (the write has not happened yet). */
|
|
295
|
+
type BeforeEvent = {
|
|
296
|
+
type: "grant.create";
|
|
297
|
+
subject: string;
|
|
298
|
+
grant: Grant;
|
|
299
|
+
actor: Actor | null;
|
|
300
|
+
} | {
|
|
301
|
+
type: "grant.revoke";
|
|
302
|
+
subject: string;
|
|
303
|
+
grant: Grant;
|
|
304
|
+
actor: Actor | null;
|
|
305
|
+
reason?: string;
|
|
306
|
+
} | {
|
|
307
|
+
type: "role.set";
|
|
308
|
+
subject: string; /** The new role; `null` clears the stored assignment. */
|
|
309
|
+
role: string | null;
|
|
310
|
+
previous: string | null;
|
|
311
|
+
actor: Actor | null;
|
|
312
|
+
reason?: string;
|
|
313
|
+
} | {
|
|
314
|
+
type: "relationship.write"; /** The tuple's subject reference (`user:ana`, `group:eng#member`). */
|
|
315
|
+
subject: string;
|
|
316
|
+
relationship: Relationship;
|
|
317
|
+
actor: Actor | null;
|
|
318
|
+
} | {
|
|
319
|
+
type: "relationship.delete";
|
|
320
|
+
subject: string;
|
|
321
|
+
relationship: Relationship;
|
|
322
|
+
actor: Actor | null;
|
|
323
|
+
reason?: string;
|
|
324
|
+
};
|
|
325
|
+
/** Events delivered to `after` hooks (committed). */
|
|
326
|
+
type AfterEvent = {
|
|
327
|
+
type: "grant.created";
|
|
328
|
+
subject: string;
|
|
329
|
+
grant: Grant;
|
|
330
|
+
actor: Actor | null;
|
|
331
|
+
at: string;
|
|
332
|
+
} | {
|
|
333
|
+
type: "grant.revoked";
|
|
334
|
+
subject: string;
|
|
335
|
+
grant: Grant;
|
|
336
|
+
actor: Actor | null;
|
|
337
|
+
reason?: string;
|
|
338
|
+
at: string;
|
|
339
|
+
} | {
|
|
340
|
+
type: "role.changed";
|
|
341
|
+
subject: string;
|
|
342
|
+
role: string | null;
|
|
343
|
+
previous: string | null;
|
|
344
|
+
record: SubjectRecord;
|
|
345
|
+
actor: Actor | null;
|
|
346
|
+
reason?: string;
|
|
347
|
+
at: string;
|
|
348
|
+
} | {
|
|
349
|
+
type: "relationship.written";
|
|
350
|
+
subject: string;
|
|
351
|
+
relationship: Relationship;
|
|
352
|
+
actor: Actor | null;
|
|
353
|
+
at: string;
|
|
354
|
+
} | {
|
|
355
|
+
type: "relationship.deleted";
|
|
356
|
+
subject: string;
|
|
357
|
+
relationship: Relationship;
|
|
358
|
+
actor: Actor | null;
|
|
359
|
+
reason?: string;
|
|
360
|
+
at: string;
|
|
361
|
+
};
|
|
362
|
+
/** The discriminant strings of {@link BeforeEvent} / {@link AfterEvent}. */
|
|
363
|
+
type BeforeEventType = BeforeEvent["type"];
|
|
364
|
+
type AfterEventType = AfterEvent["type"];
|
|
365
|
+
/** A hook: implement either side or both. */
|
|
366
|
+
type PermissionsHooks = Hooks<BeforeEvent, AfterEvent>;
|
|
367
|
+
/** Accepts a single hook, an array, or nothing. */
|
|
368
|
+
type PermissionsHooksInput = HooksInput<BeforeEvent, AfterEvent>;
|
|
369
|
+
/** Reports an error thrown by an `after` hook. */
|
|
370
|
+
type HookErrorReporter$1 = HookErrorReporter<AfterEvent>;
|
|
371
|
+
/** Default `after`-hook error reporter: warn with the `[@xtandard/permissions]` prefix, never throw. */
|
|
372
|
+
declare const defaultHookErrorReporter: HookErrorReporter$1;
|
|
373
|
+
//#endregion
|
|
374
|
+
export { SetRoleInput as A, relationshipInputSchema as B, ListQuery as C, RelationshipPage as D, RelationshipInput as E, historyQuerySchema as F, revokeInputSchema as H, listObjectsQuerySchema as I, listQuerySchema as L, UpsertSubjectInput as M, actorSchema as N, RelationshipQuery as O, grantInputSchema as P, listRelationSubjectsQuerySchema as R, InstantInput as S, Relationship as T, setRoleInputSchema as U, relationshipQuerySchema as V, upsertSubjectInputSchema as W, GrantInput as _, HookDeniedError as a, HistoryQuery as b, PermissionsHooksInput as c, runAfter as d, runBefore as f, Grant as g, CheckResult as h, BeforeEventType as i, SubjectRecord as j, RevokeInput as k, defaultHookErrorReporter as l, CheckReason as m, AfterEventType as n, HookErrorReporter$1 as o, Actor as p, BeforeEvent as r, PermissionsHooks as s, AfterEvent as t, normalizeHooks as u, HistoryEntry as v, PermissionsSnapshot as w, HistoryType as x, HistoryPage as y, relationCheckSchema as z };
|
|
375
|
+
//# sourceMappingURL=contract-Dk6d2ylD.d.cts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { CompareAndSwapKvStorage as CompareAndSwapPermissionsStorage, KvStorage as PermissionsStorage, StorageChangeEvent, TransactionalKvStorage as TransactionalPermissionsStorage, WatchableKvStorage as WatchablePermissionsStorage, isCompareAndSwap, isTransactional, isWatchable } from "@xtandard/kit/storage";
|
|
2
|
+
export { WatchablePermissionsStorage as a, isWatchable as c, TransactionalPermissionsStorage as i, PermissionsStorage as n, isCompareAndSwap as o, StorageChangeEvent as r, isTransactional as s, CompareAndSwapPermissionsStorage as t };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { CompareAndSwapKvStorage as CompareAndSwapPermissionsStorage, KvStorage as PermissionsStorage, StorageChangeEvent, TransactionalKvStorage as TransactionalPermissionsStorage, WatchableKvStorage as WatchablePermissionsStorage, isCompareAndSwap, isTransactional, isWatchable } from "@xtandard/kit/storage";
|
|
2
|
+
export { WatchablePermissionsStorage as a, isWatchable as c, TransactionalPermissionsStorage as i, PermissionsStorage as n, isCompareAndSwap as o, StorageChangeEvent as r, isTransactional as s, CompareAndSwapPermissionsStorage as t };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//#region src/auth-provider/contract.ts
|
|
2
|
+
/**
|
|
3
|
+
* Normalize a raw role value: a string is split on commas (better-auth stores `"admin,user"`), an
|
|
4
|
+
* array is flattened the same way, entries are trimmed and empties dropped. Non-strings are
|
|
5
|
+
* ignored.
|
|
6
|
+
*/
|
|
7
|
+
function splitRoles(raw) {
|
|
8
|
+
const out = [];
|
|
9
|
+
const add = (value) => {
|
|
10
|
+
if (typeof value !== "string") return;
|
|
11
|
+
for (const part of value.split(",")) {
|
|
12
|
+
const role = part.trim();
|
|
13
|
+
if (role) out.push(role);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
if (Array.isArray(raw)) for (const value of raw) add(value);
|
|
17
|
+
else add(raw);
|
|
18
|
+
return out;
|
|
19
|
+
}
|
|
20
|
+
/** {@link splitRoles} then {@link RoleMapper}; `null` when nothing is left. */
|
|
21
|
+
function normalizeRoles(raw, mapRole) {
|
|
22
|
+
const roles = [];
|
|
23
|
+
for (const role of splitRoles(raw)) {
|
|
24
|
+
const mapped = mapRole === void 0 ? role : typeof mapRole === "function" ? mapRole(role) : Object.hasOwn(mapRole, role) ? mapRole[role] : role;
|
|
25
|
+
if (typeof mapped === "string" && mapped !== "" && !roles.includes(mapped)) roles.push(mapped);
|
|
26
|
+
}
|
|
27
|
+
return roles.length ? roles : null;
|
|
28
|
+
}
|
|
29
|
+
/** A string field of an unknown record, or `undefined`. */
|
|
30
|
+
function stringField(source, key) {
|
|
31
|
+
if (!source || typeof source !== "object") return void 0;
|
|
32
|
+
const value = source[key];
|
|
33
|
+
return typeof value === "string" && value !== "" ? value : void 0;
|
|
34
|
+
}
|
|
35
|
+
/** Build an identity, leaving out empty optional fields (exactOptionalPropertyTypes-friendly). */
|
|
36
|
+
function identity(fields) {
|
|
37
|
+
const out = { id: fields.id };
|
|
38
|
+
if (fields.role !== void 0) out.role = fields.role;
|
|
39
|
+
if (fields.name) out.name = fields.name;
|
|
40
|
+
if (fields.email) out.email = fields.email;
|
|
41
|
+
if (fields.attributes && Object.keys(fields.attributes).length) out.attributes = fields.attributes;
|
|
42
|
+
return out;
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
export { stringField as i, normalizeRoles as n, splitRoles as r, identity as t };
|
|
46
|
+
|
|
47
|
+
//# sourceMappingURL=contract-Yc5AZuvv.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-Yc5AZuvv.mjs","names":[],"sources":["../src/auth-provider/contract.ts"],"sourcesContent":["/**\n * The auth provider contract (ADR 0006). Answers two questions for the engine, the panel and the\n * router: \"who is calling, and what role does their auth library give them?\" and \"may they manage\n * grants?\".\n *\n * `@xtandard/permissions` ships `auth/better-auth`, `auth/session` and `auth/jwt` implementations;\n * any object satisfying {@link PermissionsAuthProvider} works. {@link toKitAuth} adapts one to the\n * kit's `AuthProvider` + `AuthorizationProvider`.\n *\n * @module\n */\n\nimport type { PermissionsSubject, SubjectIdentity } from \"../catalog.ts\";\n\nexport type { PermissionsSubject, SubjectIdentity };\n\n/** Resolves the caller of a request. Implement it once per auth library. */\nexport interface PermissionsAuthProvider {\n /**\n * Who is calling? `null` = no session (the guest role for checks, 401 for manage routes). A throw\n * is a server error (500), never \"no session\". The id must not be empty.\n */\n getSubject(request: Request): Promise<SubjectIdentity | null> | SubjectIdentity | null;\n /**\n * May this subject grant, revoke and set roles? `subject.role` is the effective role. Default:\n * the role is one of the catalog's `managerRoles`.\n */\n canManage?(subject: PermissionsSubject, request: Request): boolean | Promise<boolean>;\n}\n\n/**\n * Renames raw roles from the auth library before the catalog parses them: a map\n * (`{ user: \"member\", \"org:admin\": \"admin\" }`, unmapped roles pass through) or a function\n * (return `null`/`undefined` to drop a role).\n */\nexport type RoleMapper =\n | Readonly<Record<string, string>>\n | ((role: string) => string | null | undefined);\n\n/** Options every bundled provider accepts. */\nexport interface ProviderRoleOptions {\n /** Rename the library's roles to catalog roles. */\n mapRole?: RoleMapper;\n /** Override who may manage grants (see {@link PermissionsAuthProvider.canManage}). */\n canManage?: PermissionsAuthProvider[\"canManage\"];\n}\n\n/**\n * Normalize a raw role value: a string is split on commas (better-auth stores `\"admin,user\"`), an\n * array is flattened the same way, entries are trimmed and empties dropped. Non-strings are\n * ignored.\n */\nexport function splitRoles(raw: unknown): string[] {\n const out: string[] = [];\n const add = (value: unknown) => {\n if (typeof value !== \"string\") return;\n for (const part of value.split(\",\")) {\n const role = part.trim();\n if (role) out.push(role);\n }\n };\n if (Array.isArray(raw)) for (const value of raw) add(value);\n else add(raw);\n return out;\n}\n\n/** {@link splitRoles} then {@link RoleMapper}; `null` when nothing is left. */\nexport function normalizeRoles(raw: unknown, mapRole?: RoleMapper): string[] | null {\n const roles: string[] = [];\n for (const role of splitRoles(raw)) {\n const mapped =\n mapRole === undefined\n ? role\n : typeof mapRole === \"function\"\n ? mapRole(role)\n : Object.hasOwn(mapRole, role)\n ? mapRole[role]\n : role;\n if (typeof mapped === \"string\" && mapped !== \"\" && !roles.includes(mapped)) roles.push(mapped);\n }\n return roles.length ? roles : null;\n}\n\n/** A string field of an unknown record, or `undefined`. */\nexport function stringField(source: unknown, key: string): string | undefined {\n if (!source || typeof source !== \"object\") return undefined;\n const value = (source as Record<string, unknown>)[key];\n return typeof value === \"string\" && value !== \"\" ? value : undefined;\n}\n\n/** Build an identity, leaving out empty optional fields (exactOptionalPropertyTypes-friendly). */\nexport function identity(fields: {\n id: string;\n role?: string | readonly string[] | null | undefined;\n name?: string | null | undefined;\n email?: string | null | undefined;\n attributes?: Record<string, unknown> | undefined;\n}): SubjectIdentity {\n const out: SubjectIdentity = { id: fields.id };\n if (fields.role !== undefined) out.role = fields.role;\n if (fields.name) out.name = fields.name;\n if (fields.email) out.email = fields.email;\n if (fields.attributes && Object.keys(fields.attributes).length) {\n out.attributes = fields.attributes;\n }\n return out;\n}\n"],"mappings":";;;;;;AAoDA,SAAgB,WAAW,KAAwB;CACjD,MAAM,MAAgB,CAAC;CACvB,MAAM,OAAO,UAAmB;EAC9B,IAAI,OAAO,UAAU,UAAU;EAC/B,KAAK,MAAM,QAAQ,MAAM,MAAM,GAAG,GAAG;GACnC,MAAM,OAAO,KAAK,KAAK;GACvB,IAAI,MAAM,IAAI,KAAK,IAAI;EACzB;CACF;CACA,IAAI,MAAM,QAAQ,GAAG,GAAG,KAAK,MAAM,SAAS,KAAK,IAAI,KAAK;MACrD,IAAI,GAAG;CACZ,OAAO;AACT;;AAGA,SAAgB,eAAe,KAAc,SAAuC;CAClF,MAAM,QAAkB,CAAC;CACzB,KAAK,MAAM,QAAQ,WAAW,GAAG,GAAG;EAClC,MAAM,SACJ,YAAY,KAAA,IACR,OACA,OAAO,YAAY,aACjB,QAAQ,IAAI,IACZ,OAAO,OAAO,SAAS,IAAI,IACzB,QAAQ,QACR;EACV,IAAI,OAAO,WAAW,YAAY,WAAW,MAAM,CAAC,MAAM,SAAS,MAAM,GAAG,MAAM,KAAK,MAAM;CAC/F;CACA,OAAO,MAAM,SAAS,QAAQ;AAChC;;AAGA,SAAgB,YAAY,QAAiB,KAAiC;CAC5E,IAAI,CAAC,UAAU,OAAO,WAAW,UAAU,OAAO,KAAA;CAClD,MAAM,QAAS,OAAmC;CAClD,OAAO,OAAO,UAAU,YAAY,UAAU,KAAK,QAAQ,KAAA;AAC7D;;AAGA,SAAgB,SAAS,QAML;CAClB,MAAM,MAAuB,EAAE,IAAI,OAAO,GAAG;CAC7C,IAAI,OAAO,SAAS,KAAA,GAAW,IAAI,OAAO,OAAO;CACjD,IAAI,OAAO,MAAM,IAAI,OAAO,OAAO;CACnC,IAAI,OAAO,OAAO,IAAI,QAAQ,OAAO;CACrC,IAAI,OAAO,cAAc,OAAO,KAAK,OAAO,UAAU,EAAE,QACtD,IAAI,aAAa,OAAO;CAE1B,OAAO;AACT"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { s as Definition } from "./policy-CGA6QD0a.mjs";
|
|
2
|
+
import { h as SubjectIdentity } from "./catalog-DJcJ3ycq.mjs";
|
|
3
|
+
import { t as PermissionsAuthProvider } from "./contract-D32H1t0u.mjs";
|
|
4
|
+
import { r as ToKitAuthOptions } from "./kit-DMVBLBI9.mjs";
|
|
5
|
+
import { n as AuthorizationProvider } from "./contract-CNgMXr2u.mjs";
|
|
6
|
+
import { i as Permissions, o as PermissionsOptions } from "./engine-DpFIcbgh.mjs";
|
|
7
|
+
import { CorsOptions as PermissionsCorsOptions } from "@xtandard/kit/server";
|
|
8
|
+
import { AuthProvider as AuthProvider$1, Principal as Principal$1 } from "@xtandard/kit/auth";
|
|
9
|
+
|
|
10
|
+
//#region src/server/create-fetch-handler.d.ts
|
|
11
|
+
/** Options for the panel handler (shared by every framework adapter). */
|
|
12
|
+
interface PermissionsPanelOptions<D extends Definition = Definition, R extends string = string, P extends string = string, X = undefined> extends Partial<PermissionsOptions<D, R, P, X>> {
|
|
13
|
+
/**
|
|
14
|
+
* The engine to serve. When omitted, one is built from the engine options on this object
|
|
15
|
+
* (`catalog` and `storage` are then required; `hooks`, `cache`, … as for `createPermissions`).
|
|
16
|
+
*/
|
|
17
|
+
permissions?: Permissions<D, R, P, X>;
|
|
18
|
+
/** Mount prefix, e.g. `"/permissions"`. Default `""` (root). */
|
|
19
|
+
basePath?: string;
|
|
20
|
+
/** Authentication. Default: from `provider`, else anonymous. */
|
|
21
|
+
auth?: AuthProvider$1;
|
|
22
|
+
/** Authorization of the admin routes. Default: from `provider`, else allow all. */
|
|
23
|
+
authorization?: AuthorizationProvider;
|
|
24
|
+
/**
|
|
25
|
+
* A `PermissionsAuthProvider` (`auth/better-auth`, `auth/session`, `auth/jwt`, or your own),
|
|
26
|
+
* adapted with `toKitAuth(provider, engine, providerOptions)`: managers (the catalog's
|
|
27
|
+
* `managerRoles`, or the provider's `canManage`) may use the panel.
|
|
28
|
+
*/
|
|
29
|
+
provider?: PermissionsAuthProvider;
|
|
30
|
+
/** Options for the `toKitAuth` adaptation of `provider`. */
|
|
31
|
+
providerOptions?: ToKitAuthOptions;
|
|
32
|
+
/** Block grants and role changes (423). Also passed to a constructed engine. */
|
|
33
|
+
readonly?: boolean;
|
|
34
|
+
/** UI title. Default `"@xtandard/permissions"`. */
|
|
35
|
+
title?: string;
|
|
36
|
+
/** Logo image URL shown in the navbar in place of the title. */
|
|
37
|
+
logoUrl?: string;
|
|
38
|
+
/** Override the directory the bundled UI is served from (default `./ui` beside this module). */
|
|
39
|
+
uiDir?: string;
|
|
40
|
+
/** Answer CORS preflights and decorate every response. */
|
|
41
|
+
cors?: PermissionsCorsOptions;
|
|
42
|
+
/** The rules' `ctx` for the caller's runtime checks (`POST /api/me/check`). */
|
|
43
|
+
checkContext?: (request: Request, subject: SubjectIdentity) => unknown;
|
|
44
|
+
/** The caller's ReBAC subject for `POST /api/me/relation`. Default `user:{principal id}`. */
|
|
45
|
+
relationSubject?: (principal: Principal$1) => string;
|
|
46
|
+
}
|
|
47
|
+
/** Return shape of {@link createFetchHandler}. */
|
|
48
|
+
interface CreateFetchHandlerResult<D extends Definition = Definition, R extends string = string, P extends string = string, X = undefined> {
|
|
49
|
+
/** Web-standard request handler. */
|
|
50
|
+
fetch(request: Request): Promise<Response>;
|
|
51
|
+
/** The engine (given or constructed): use it in-process for checks. */
|
|
52
|
+
engine: Permissions<D, R, P, X>;
|
|
53
|
+
/** The HTTP API as an OpenAPI 3.1 document (also served at `{basePath}/api/openapi.json`). */
|
|
54
|
+
openapi(): Record<string, unknown>;
|
|
55
|
+
/** Stop the panel's background work (the engine is the caller's to `close()`). */
|
|
56
|
+
close(): void;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Build the panel fetch handler.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* import { createFetchHandler } from "@xtandard/permissions";
|
|
64
|
+
* import { betterAuthProvider } from "@xtandard/permissions/auth/better-auth";
|
|
65
|
+
*
|
|
66
|
+
* const { fetch } = createFetchHandler({
|
|
67
|
+
* permissions: perms,
|
|
68
|
+
* provider: betterAuthProvider(auth, { mapRole: { user: "member" } }),
|
|
69
|
+
* basePath: "/permissions",
|
|
70
|
+
* });
|
|
71
|
+
* Bun.serve({ port: 3000, fetch });
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
declare function createFetchHandler<D extends Definition = Definition, R extends string = string, P extends string = string, X = undefined>(options: PermissionsPanelOptions<D, R, P, X>): CreateFetchHandlerResult<D, R, P, X>;
|
|
75
|
+
//#endregion
|
|
76
|
+
export { AuthProvider$1 as a, PermissionsCorsOptions as i, PermissionsPanelOptions as n, Principal$1 as o, createFetchHandler as r, CreateFetchHandlerResult as t };
|
|
77
|
+
//# sourceMappingURL=create-fetch-handler-BHDU4chu.d.mts.map
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { s as Definition } from "./policy-DFq_SYR3.cjs";
|
|
2
|
+
import { h as SubjectIdentity } from "./catalog-DA_d1SdC.cjs";
|
|
3
|
+
import { t as PermissionsAuthProvider } from "./contract-BMiOmg2f.cjs";
|
|
4
|
+
import { r as ToKitAuthOptions } from "./kit-qAROuhOI.cjs";
|
|
5
|
+
import { n as AuthorizationProvider } from "./contract-CNgMXr2u.cjs";
|
|
6
|
+
import { i as Permissions, o as PermissionsOptions } from "./engine-CGGVDCqi.cjs";
|
|
7
|
+
import { AuthProvider as AuthProvider$1, Principal as Principal$1 } from "@xtandard/kit/auth";
|
|
8
|
+
import { CorsOptions as PermissionsCorsOptions } from "@xtandard/kit/server";
|
|
9
|
+
|
|
10
|
+
//#region src/server/create-fetch-handler.d.ts
|
|
11
|
+
/** Options for the panel handler (shared by every framework adapter). */
|
|
12
|
+
interface PermissionsPanelOptions<D extends Definition = Definition, R extends string = string, P extends string = string, X = undefined> extends Partial<PermissionsOptions<D, R, P, X>> {
|
|
13
|
+
/**
|
|
14
|
+
* The engine to serve. When omitted, one is built from the engine options on this object
|
|
15
|
+
* (`catalog` and `storage` are then required; `hooks`, `cache`, … as for `createPermissions`).
|
|
16
|
+
*/
|
|
17
|
+
permissions?: Permissions<D, R, P, X>;
|
|
18
|
+
/** Mount prefix, e.g. `"/permissions"`. Default `""` (root). */
|
|
19
|
+
basePath?: string;
|
|
20
|
+
/** Authentication. Default: from `provider`, else anonymous. */
|
|
21
|
+
auth?: AuthProvider$1;
|
|
22
|
+
/** Authorization of the admin routes. Default: from `provider`, else allow all. */
|
|
23
|
+
authorization?: AuthorizationProvider;
|
|
24
|
+
/**
|
|
25
|
+
* A `PermissionsAuthProvider` (`auth/better-auth`, `auth/session`, `auth/jwt`, or your own),
|
|
26
|
+
* adapted with `toKitAuth(provider, engine, providerOptions)`: managers (the catalog's
|
|
27
|
+
* `managerRoles`, or the provider's `canManage`) may use the panel.
|
|
28
|
+
*/
|
|
29
|
+
provider?: PermissionsAuthProvider;
|
|
30
|
+
/** Options for the `toKitAuth` adaptation of `provider`. */
|
|
31
|
+
providerOptions?: ToKitAuthOptions;
|
|
32
|
+
/** Block grants and role changes (423). Also passed to a constructed engine. */
|
|
33
|
+
readonly?: boolean;
|
|
34
|
+
/** UI title. Default `"@xtandard/permissions"`. */
|
|
35
|
+
title?: string;
|
|
36
|
+
/** Logo image URL shown in the navbar in place of the title. */
|
|
37
|
+
logoUrl?: string;
|
|
38
|
+
/** Override the directory the bundled UI is served from (default `./ui` beside this module). */
|
|
39
|
+
uiDir?: string;
|
|
40
|
+
/** Answer CORS preflights and decorate every response. */
|
|
41
|
+
cors?: PermissionsCorsOptions;
|
|
42
|
+
/** The rules' `ctx` for the caller's runtime checks (`POST /api/me/check`). */
|
|
43
|
+
checkContext?: (request: Request, subject: SubjectIdentity) => unknown;
|
|
44
|
+
/** The caller's ReBAC subject for `POST /api/me/relation`. Default `user:{principal id}`. */
|
|
45
|
+
relationSubject?: (principal: Principal$1) => string;
|
|
46
|
+
}
|
|
47
|
+
/** Return shape of {@link createFetchHandler}. */
|
|
48
|
+
interface CreateFetchHandlerResult<D extends Definition = Definition, R extends string = string, P extends string = string, X = undefined> {
|
|
49
|
+
/** Web-standard request handler. */
|
|
50
|
+
fetch(request: Request): Promise<Response>;
|
|
51
|
+
/** The engine (given or constructed): use it in-process for checks. */
|
|
52
|
+
engine: Permissions<D, R, P, X>;
|
|
53
|
+
/** The HTTP API as an OpenAPI 3.1 document (also served at `{basePath}/api/openapi.json`). */
|
|
54
|
+
openapi(): Record<string, unknown>;
|
|
55
|
+
/** Stop the panel's background work (the engine is the caller's to `close()`). */
|
|
56
|
+
close(): void;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Build the panel fetch handler.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* import { createFetchHandler } from "@xtandard/permissions";
|
|
64
|
+
* import { betterAuthProvider } from "@xtandard/permissions/auth/better-auth";
|
|
65
|
+
*
|
|
66
|
+
* const { fetch } = createFetchHandler({
|
|
67
|
+
* permissions: perms,
|
|
68
|
+
* provider: betterAuthProvider(auth, { mapRole: { user: "member" } }),
|
|
69
|
+
* basePath: "/permissions",
|
|
70
|
+
* });
|
|
71
|
+
* Bun.serve({ port: 3000, fetch });
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
declare function createFetchHandler<D extends Definition = Definition, R extends string = string, P extends string = string, X = undefined>(options: PermissionsPanelOptions<D, R, P, X>): CreateFetchHandlerResult<D, R, P, X>;
|
|
75
|
+
//#endregion
|
|
76
|
+
export { AuthProvider$1 as a, PermissionsCorsOptions as i, PermissionsPanelOptions as n, Principal$1 as o, createFetchHandler as r, CreateFetchHandlerResult as t };
|
|
77
|
+
//# sourceMappingURL=create-fetch-handler-BtX64_rS.d.cts.map
|