@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,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Framework-independent CORS for the mounted panel: with a `cors` option, the handler answers
|
|
3
|
+
* `OPTIONS` preflights itself and decorates every response, so a cross-origin SPA (or
|
|
4
|
+
* `/api/me` from another origin) works whatever the host framework does. The kit's.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
export type { CorsOptions as PermissionsCorsOptions } from "@xtandard/kit/server";
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The web-standard fetch handler behind every framework adapter, the CLI's `serve` and the
|
|
3
|
+
* standalone app (ADR 0008): the kit's `createPanelHandler` (healthcheck, static UI, SPA fallback,
|
|
4
|
+
* CORS, OpenAPI) around the permissions API router.
|
|
5
|
+
*
|
|
6
|
+
* Auth plugs in three ways:
|
|
7
|
+
*
|
|
8
|
+
* - `auth` + `authorization`: any kit `AuthProvider` / `AuthorizationProvider` (e.g. `basicAuth` +
|
|
9
|
+
* `rolesAuthorization`, or the pair `toKitAuth(provider, perms)` returns);
|
|
10
|
+
* - `provider`: a `PermissionsAuthProvider` (better-auth, session, JWT), adapted with `toKitAuth`
|
|
11
|
+
* (explicit `auth` / `authorization` still win);
|
|
12
|
+
* - nothing: anonymous, allow-all (embedded / local use only).
|
|
13
|
+
*
|
|
14
|
+
* @module
|
|
15
|
+
*/
|
|
16
|
+
import { type ToKitAuthOptions } from "../auth-provider/kit.ts";
|
|
17
|
+
import type { PermissionsAuthProvider } from "../auth-provider/contract.ts";
|
|
18
|
+
import type { AuthProvider, Principal } from "../auth/contract.ts";
|
|
19
|
+
import type { AuthorizationProvider } from "../authorization/contract.ts";
|
|
20
|
+
import type { SubjectIdentity } from "../catalog.ts";
|
|
21
|
+
import { type Permissions, type PermissionsOptions } from "../engine.ts";
|
|
22
|
+
import type { Definition } from "../policy.ts";
|
|
23
|
+
import type { PermissionsCorsOptions } from "./cors.ts";
|
|
24
|
+
/** Options for the panel handler (shared by every framework adapter). */
|
|
25
|
+
export interface PermissionsPanelOptions<D extends Definition = Definition, R extends string = string, P extends string = string, X = undefined> extends Partial<PermissionsOptions<D, R, P, X>> {
|
|
26
|
+
/**
|
|
27
|
+
* The engine to serve. When omitted, one is built from the engine options on this object
|
|
28
|
+
* (`catalog` and `storage` are then required; `hooks`, `cache`, … as for `createPermissions`).
|
|
29
|
+
*/
|
|
30
|
+
permissions?: Permissions<D, R, P, X>;
|
|
31
|
+
/** Mount prefix, e.g. `"/permissions"`. Default `""` (root). */
|
|
32
|
+
basePath?: string;
|
|
33
|
+
/** Authentication. Default: from `provider`, else anonymous. */
|
|
34
|
+
auth?: AuthProvider;
|
|
35
|
+
/** Authorization of the admin routes. Default: from `provider`, else allow all. */
|
|
36
|
+
authorization?: AuthorizationProvider;
|
|
37
|
+
/**
|
|
38
|
+
* A `PermissionsAuthProvider` (`auth/better-auth`, `auth/session`, `auth/jwt`, or your own),
|
|
39
|
+
* adapted with `toKitAuth(provider, engine, providerOptions)`: managers (the catalog's
|
|
40
|
+
* `managerRoles`, or the provider's `canManage`) may use the panel.
|
|
41
|
+
*/
|
|
42
|
+
provider?: PermissionsAuthProvider;
|
|
43
|
+
/** Options for the `toKitAuth` adaptation of `provider`. */
|
|
44
|
+
providerOptions?: ToKitAuthOptions;
|
|
45
|
+
/** Block grants and role changes (423). Also passed to a constructed engine. */
|
|
46
|
+
readonly?: boolean;
|
|
47
|
+
/** UI title. Default `"@xtandard/permissions"`. */
|
|
48
|
+
title?: string;
|
|
49
|
+
/** Logo image URL shown in the navbar in place of the title. */
|
|
50
|
+
logoUrl?: string;
|
|
51
|
+
/** Override the directory the bundled UI is served from (default `./ui` beside this module). */
|
|
52
|
+
uiDir?: string;
|
|
53
|
+
/** Answer CORS preflights and decorate every response. */
|
|
54
|
+
cors?: PermissionsCorsOptions;
|
|
55
|
+
/** The rules' `ctx` for the caller's runtime checks (`POST /api/me/check`). */
|
|
56
|
+
checkContext?: (request: Request, subject: SubjectIdentity) => unknown;
|
|
57
|
+
/** The caller's ReBAC subject for `POST /api/me/relation`. Default `user:{principal id}`. */
|
|
58
|
+
relationSubject?: (principal: Principal) => string;
|
|
59
|
+
}
|
|
60
|
+
/** Return shape of {@link createFetchHandler}. */
|
|
61
|
+
export interface CreateFetchHandlerResult<D extends Definition = Definition, R extends string = string, P extends string = string, X = undefined> {
|
|
62
|
+
/** Web-standard request handler. */
|
|
63
|
+
fetch(request: Request): Promise<Response>;
|
|
64
|
+
/** The engine (given or constructed): use it in-process for checks. */
|
|
65
|
+
engine: Permissions<D, R, P, X>;
|
|
66
|
+
/** The HTTP API as an OpenAPI 3.1 document (also served at `{basePath}/api/openapi.json`). */
|
|
67
|
+
openapi(): Record<string, unknown>;
|
|
68
|
+
/** Stop the panel's background work (the engine is the caller's to `close()`). */
|
|
69
|
+
close(): void;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Build the panel fetch handler.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* import { createFetchHandler } from "@xtandard/permissions";
|
|
77
|
+
* import { betterAuthProvider } from "@xtandard/permissions/auth/better-auth";
|
|
78
|
+
*
|
|
79
|
+
* const { fetch } = createFetchHandler({
|
|
80
|
+
* permissions: perms,
|
|
81
|
+
* provider: betterAuthProvider(auth, { mapRole: { user: "member" } }),
|
|
82
|
+
* basePath: "/permissions",
|
|
83
|
+
* });
|
|
84
|
+
* Bun.serve({ port: 3000, fetch });
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export 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>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAPI 3.1 description of the panel's HTTP API, served at `GET {basePath}/api/openapi.json`
|
|
3
|
+
* and returned by `createFetchHandler(...).openapi()` (merge it into the host's document).
|
|
4
|
+
*
|
|
5
|
+
* Paths come from the router's own table ({@link API_ROUTES}), so every served route is
|
|
6
|
+
* documented; admin routes carry their action as `x-action`, runtime routes `x-runtime: true`.
|
|
7
|
+
* Component schemas are hand-authored (no generation dependency, the family's precedent).
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
/** Options for {@link buildOpenApiDocument}. */
|
|
12
|
+
export interface OpenApiOptions {
|
|
13
|
+
/** Mount prefix used in the `servers` url (e.g. `"/permissions"`). */
|
|
14
|
+
basePath?: string;
|
|
15
|
+
/** Document title. Default `"@xtandard/permissions"`. */
|
|
16
|
+
title?: string;
|
|
17
|
+
/** Document version. Default `"1"` (the HTTP API version, not the package version). */
|
|
18
|
+
version?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Build the OpenAPI 3.1 document for the panel API.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* import { buildOpenApiDocument } from "@xtandard/permissions";
|
|
26
|
+
* const doc = buildOpenApiDocument({ basePath: "/permissions" });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function buildOpenApiDocument(options?: OpenApiOptions): Record<string, unknown>;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The panel's JSON API (ADR 0008): the route table on the kit's declarative router
|
|
3
|
+
* (`@xtandard/kit/server/router`), wired to authentication, authorization, the readonly switch
|
|
4
|
+
* (423) and valibot body validation. Returns `null` for non-API paths so the panel falls through
|
|
5
|
+
* to static assets / the SPA.
|
|
6
|
+
*
|
|
7
|
+
* Every route is one entry of {@link API_ROUTES}: method, path, action, resource and handler. The
|
|
8
|
+
* OpenAPI document is generated from the same table, so the two cannot drift.
|
|
9
|
+
*
|
|
10
|
+
* Two kinds of routes:
|
|
11
|
+
*
|
|
12
|
+
* - **admin** routes carry an action (`catalog:read`, `subjects:read`, `grants:read`,
|
|
13
|
+
* `history:read`, `check:run`, `relationships:read`, and the mutating `grants:write`,
|
|
14
|
+
* `roles:write`, `relationships:write`) and go through the authorization provider;
|
|
15
|
+
* - **runtime** routes (`GET /api/me`, `POST /api/me/check`, `POST /api/me/relation`) answer for
|
|
16
|
+
* the caller and need only an authenticated principal (401 otherwise): the provider is not
|
|
17
|
+
* consulted.
|
|
18
|
+
*
|
|
19
|
+
* The actor of every write is the authenticated principal.
|
|
20
|
+
*
|
|
21
|
+
* @module
|
|
22
|
+
*/
|
|
23
|
+
import { type ErrorMap } from "@xtandard/kit/server";
|
|
24
|
+
import { type RouteMethod as KitRouteMethod, type RouteQueryParam as KitRouteQueryParam, type RouteSpec as KitRouteSpec, type Router } from "@xtandard/kit/server/router";
|
|
25
|
+
import type { AuthProvider, Principal } from "../auth/contract.ts";
|
|
26
|
+
import { type AuthorizationProvider, type PermissionsAction, type PermissionsResource } from "../authorization/contract.ts";
|
|
27
|
+
import type { AnyPermissionsCatalog, SubjectIdentity } from "../catalog.ts";
|
|
28
|
+
import type { AnyPermissions, SubjectSummary, SubjectView } from "../engine.ts";
|
|
29
|
+
import { type RelationTypeView } from "../relationships.ts";
|
|
30
|
+
import type { CheckResult } from "../schema.ts";
|
|
31
|
+
/** Everything the API router needs. */
|
|
32
|
+
export interface ApiContext {
|
|
33
|
+
engine: AnyPermissions;
|
|
34
|
+
auth: AuthProvider;
|
|
35
|
+
authorization: AuthorizationProvider;
|
|
36
|
+
title: string;
|
|
37
|
+
readonly: boolean;
|
|
38
|
+
basePath: string;
|
|
39
|
+
logoUrl?: string;
|
|
40
|
+
/** The document served at `/api/openapi.json`. */
|
|
41
|
+
openapi?: () => Record<string, unknown>;
|
|
42
|
+
/**
|
|
43
|
+
* The rules' `ctx` for the caller's runtime checks (`/api/me/check`), for catalogs whose rules
|
|
44
|
+
* read app facts. The caller can't supply `ctx` on that route.
|
|
45
|
+
*/
|
|
46
|
+
checkContext?: (request: Request, subject: SubjectIdentity) => unknown;
|
|
47
|
+
/**
|
|
48
|
+
* The ReBAC subject of the caller for `POST /api/me/relation`. Default `user:{principal id}`.
|
|
49
|
+
*/
|
|
50
|
+
relationSubject?: (principal: Principal) => string;
|
|
51
|
+
}
|
|
52
|
+
/** `GET /config` (and `/api/config`): the SPA bootstrap. */
|
|
53
|
+
export interface PanelConfig {
|
|
54
|
+
title: string;
|
|
55
|
+
logoUrl?: string;
|
|
56
|
+
basePath: string;
|
|
57
|
+
readonly: boolean;
|
|
58
|
+
authenticated: boolean;
|
|
59
|
+
/** The caller, with its effective catalog role; `null` when not authenticated. */
|
|
60
|
+
principal: {
|
|
61
|
+
id: string;
|
|
62
|
+
role: string;
|
|
63
|
+
name?: string;
|
|
64
|
+
email?: string;
|
|
65
|
+
} | null;
|
|
66
|
+
/**
|
|
67
|
+
* The ADR 0008 actions the caller may perform. Mutating actions are left out of a readonly
|
|
68
|
+
* panel, so the SPA can hide write UI from this list alone.
|
|
69
|
+
*/
|
|
70
|
+
allowed: PermissionsAction[];
|
|
71
|
+
}
|
|
72
|
+
/** A role or permission with its label. */
|
|
73
|
+
export interface LabeledKey {
|
|
74
|
+
key: string;
|
|
75
|
+
label: string;
|
|
76
|
+
description?: string;
|
|
77
|
+
}
|
|
78
|
+
/** `GET /api/catalog`. */
|
|
79
|
+
export interface CatalogView {
|
|
80
|
+
/** Least → most privileged. */
|
|
81
|
+
roles: LabeledKey[];
|
|
82
|
+
assignable: LabeledKey[];
|
|
83
|
+
guestRole: string;
|
|
84
|
+
defaultRole: string;
|
|
85
|
+
managerRoles: string[];
|
|
86
|
+
directGrants: boolean;
|
|
87
|
+
/** Every leaf permix path of every role's rules tree, sorted (for the playground). */
|
|
88
|
+
paths: string[];
|
|
89
|
+
/** The relation schema (ReBAC), `null` when the catalog declares none. */
|
|
90
|
+
relations: RelationTypeView[] | null;
|
|
91
|
+
}
|
|
92
|
+
/** `GET /api/subjects`. */
|
|
93
|
+
export interface SubjectList {
|
|
94
|
+
subjects: SubjectSummary[];
|
|
95
|
+
}
|
|
96
|
+
/** `GET /api/subjects/:id`: the stored view plus the effective role and active permissions. */
|
|
97
|
+
export interface SubjectDetail extends SubjectView {
|
|
98
|
+
/** The stored role if any, else the catalog's `defaultRole` (the panel has no provider role). */
|
|
99
|
+
effectiveRole: string;
|
|
100
|
+
/** The non-expired, assignable granted permissions. */
|
|
101
|
+
permissions: string[];
|
|
102
|
+
}
|
|
103
|
+
/** Route tags (OpenAPI grouping). */
|
|
104
|
+
export type RouteTag = "panel" | "catalog" | "subjects" | "grants" | "history" | "check" | "relationships" | "runtime";
|
|
105
|
+
/** HTTP methods the router serves. */
|
|
106
|
+
export type RouteMethod = KitRouteMethod;
|
|
107
|
+
/** A query parameter a route documents. */
|
|
108
|
+
export type RouteQueryParam = KitRouteQueryParam;
|
|
109
|
+
/** The documented shape of one route (consumed by the OpenAPI builder). */
|
|
110
|
+
export type RouteSpec = KitRouteSpec<PermissionsAction, RouteTag> & {
|
|
111
|
+
/** Runtime route: needs an authenticated principal, no action. */
|
|
112
|
+
runtime?: boolean;
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Every leaf path of every role's rules tree. The trees are built (never evaluated) with a
|
|
116
|
+
* placeholder subject and no grants; a role whose rules can't be built that way is skipped.
|
|
117
|
+
*/
|
|
118
|
+
export declare function catalogPaths(catalog: AnyPermissionsCatalog): string[];
|
|
119
|
+
/** The catalog view served at `/api/catalog`. */
|
|
120
|
+
export declare function catalogView(catalog: AnyPermissionsCatalog): CatalogView;
|
|
121
|
+
/** A check result as JSON: `explanation.error` (a thrown value) becomes its message. */
|
|
122
|
+
export declare function serializeCheck(result: CheckResult): CheckResult;
|
|
123
|
+
/** The documented route table (every API route, in match order). */
|
|
124
|
+
export declare const API_ROUTES: readonly RouteSpec[];
|
|
125
|
+
/** The paths served as the bootstrap config (not in {@link API_ROUTES}). */
|
|
126
|
+
export declare const CONFIG_PATHS: readonly string[];
|
|
127
|
+
/** Domain errors by name (ADR 0008); see `@xtandard/kit/server` `mapError`. */
|
|
128
|
+
export declare const ERRORS: ErrorMap;
|
|
129
|
+
/** Build the API router for one panel. */
|
|
130
|
+
export declare function createApiRouter(ctx: ApiContext): Router<PermissionsAction, PermissionsResource, ApiContext, never, RouteTag>;
|
|
131
|
+
/** Map domain errors to HTTP responses (ADR 0008), by name across bundles. */
|
|
132
|
+
export declare function mapError(err: unknown): Response;
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Valibot schemas of the HTTP request bodies (docs: the OpenAPI component schemas of the same
|
|
3
|
+
* names). Unknown keys are dropped: the actor of every write is the authenticated principal, never
|
|
4
|
+
* a body field. The engine validates the domain (assignable permission, known role, future expiry).
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import * as v from "valibot";
|
|
9
|
+
/** `POST /api/grants`: `{ subject, permission, reason?, expiresAt? }`. */
|
|
10
|
+
export declare const grantBodySchema: Omit<v.ObjectSchema<{
|
|
11
|
+
readonly subject: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
|
|
12
|
+
readonly permission: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
|
|
13
|
+
readonly actor: v.OptionalSchema<v.NullableSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>, v.ObjectSchema<{
|
|
14
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
|
|
15
|
+
readonly type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
16
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
17
|
+
readonly email: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
18
|
+
}, undefined>], undefined>, undefined>, undefined>;
|
|
19
|
+
readonly reason: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 1000, "must be at most 1000 characters">]>, undefined>;
|
|
20
|
+
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>;
|
|
21
|
+
}, undefined>, "entries" | "~types" | "~run" | "~standard"> & {
|
|
22
|
+
readonly entries: Omit<{
|
|
23
|
+
readonly subject: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
|
|
24
|
+
readonly permission: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
|
|
25
|
+
readonly actor: v.OptionalSchema<v.NullableSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>, v.ObjectSchema<{
|
|
26
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
|
|
27
|
+
readonly type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
28
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
29
|
+
readonly email: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
30
|
+
}, undefined>], undefined>, undefined>, undefined>;
|
|
31
|
+
readonly reason: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 1000, "must be at most 1000 characters">]>, undefined>;
|
|
32
|
+
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>;
|
|
33
|
+
}, "actor">;
|
|
34
|
+
readonly "~standard": v.StandardProps<{
|
|
35
|
+
reason?: string | undefined;
|
|
36
|
+
expiresAt?: string | number | Date | null | undefined;
|
|
37
|
+
subject: string;
|
|
38
|
+
permission: string;
|
|
39
|
+
}, {
|
|
40
|
+
reason?: string | undefined;
|
|
41
|
+
expiresAt?: string | number | Date | null | undefined;
|
|
42
|
+
subject: string;
|
|
43
|
+
permission: string;
|
|
44
|
+
}>;
|
|
45
|
+
readonly "~run": (dataset: v.UnknownDataset, config: v.Config<v.BaseIssue<unknown>>) => v.OutputDataset<{
|
|
46
|
+
reason?: string | undefined;
|
|
47
|
+
expiresAt?: string | number | Date | null | undefined;
|
|
48
|
+
subject: string;
|
|
49
|
+
permission: string;
|
|
50
|
+
}, v.StringIssue | v.MinLengthIssue<string, 1> | v.ObjectIssue | v.MaxLengthIssue<string, 1000> | v.CheckIssue<string> | v.DateIssue | v.CheckIssue<Date> | v.NumberIssue | v.FiniteIssue<number> | v.UnionIssue<v.StringIssue | v.CheckIssue<string> | v.DateIssue | v.CheckIssue<Date> | v.NumberIssue | v.FiniteIssue<number>>>;
|
|
51
|
+
readonly "~types"?: {
|
|
52
|
+
readonly input: {
|
|
53
|
+
reason?: string | undefined;
|
|
54
|
+
expiresAt?: string | number | Date | null | undefined;
|
|
55
|
+
subject: string;
|
|
56
|
+
permission: string;
|
|
57
|
+
};
|
|
58
|
+
readonly output: {
|
|
59
|
+
reason?: string | undefined;
|
|
60
|
+
expiresAt?: string | number | Date | null | undefined;
|
|
61
|
+
subject: string;
|
|
62
|
+
permission: string;
|
|
63
|
+
};
|
|
64
|
+
readonly issue: v.StringIssue | v.MinLengthIssue<string, 1> | v.ObjectIssue | v.MaxLengthIssue<string, 1000> | v.CheckIssue<string> | v.DateIssue | v.CheckIssue<Date> | v.NumberIssue | v.FiniteIssue<number> | v.UnionIssue<v.StringIssue | v.CheckIssue<string> | v.DateIssue | v.CheckIssue<Date> | v.NumberIssue | v.FiniteIssue<number>>;
|
|
65
|
+
} | undefined;
|
|
66
|
+
};
|
|
67
|
+
/** `DELETE /api/grants/:subject/:permission`: optional `{ reason }`. */
|
|
68
|
+
export declare const revokeBodySchema: Omit<v.ObjectSchema<{
|
|
69
|
+
readonly subject: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
|
|
70
|
+
readonly permission: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
|
|
71
|
+
readonly actor: v.OptionalSchema<v.NullableSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>, v.ObjectSchema<{
|
|
72
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
|
|
73
|
+
readonly type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
74
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
75
|
+
readonly email: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
76
|
+
}, undefined>], undefined>, undefined>, undefined>;
|
|
77
|
+
readonly reason: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 1000, "must be at most 1000 characters">]>, undefined>;
|
|
78
|
+
}, undefined>, "entries" | "~types" | "~run" | "~standard"> & {
|
|
79
|
+
readonly entries: Pick<{
|
|
80
|
+
readonly subject: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
|
|
81
|
+
readonly permission: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
|
|
82
|
+
readonly actor: v.OptionalSchema<v.NullableSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>, v.ObjectSchema<{
|
|
83
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
|
|
84
|
+
readonly type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
85
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
86
|
+
readonly email: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
87
|
+
}, undefined>], undefined>, undefined>, undefined>;
|
|
88
|
+
readonly reason: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 1000, "must be at most 1000 characters">]>, undefined>;
|
|
89
|
+
}, "reason">;
|
|
90
|
+
readonly "~standard": v.StandardProps<{
|
|
91
|
+
reason?: string | undefined;
|
|
92
|
+
}, {
|
|
93
|
+
reason?: string | undefined;
|
|
94
|
+
}>;
|
|
95
|
+
readonly "~run": (dataset: v.UnknownDataset, config: v.Config<v.BaseIssue<unknown>>) => v.OutputDataset<{
|
|
96
|
+
reason?: string | undefined;
|
|
97
|
+
}, v.StringIssue | v.ObjectIssue | v.MaxLengthIssue<string, 1000>>;
|
|
98
|
+
readonly "~types"?: {
|
|
99
|
+
readonly input: {
|
|
100
|
+
reason?: string | undefined;
|
|
101
|
+
};
|
|
102
|
+
readonly output: {
|
|
103
|
+
reason?: string | undefined;
|
|
104
|
+
};
|
|
105
|
+
readonly issue: v.StringIssue | v.ObjectIssue | v.MaxLengthIssue<string, 1000>;
|
|
106
|
+
} | undefined;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* `PUT /api/subjects/:id`: any of `role` (`null` clears the stored assignment), `name`, `email`
|
|
110
|
+
* (`null` clears), plus the `reason` recorded with a role change.
|
|
111
|
+
*/
|
|
112
|
+
export declare const subjectUpdateBodySchema: v.ObjectSchema<{
|
|
113
|
+
readonly role: v.OptionalSchema<v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>, undefined>, undefined>;
|
|
114
|
+
readonly name: v.OptionalSchema<v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 500, "must be at most 500 characters">]>, undefined>, undefined>;
|
|
115
|
+
readonly email: v.OptionalSchema<v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 500, "must be at most 500 characters">]>, undefined>, undefined>;
|
|
116
|
+
readonly reason: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 1000, "must be at most 1000 characters">]>, undefined>;
|
|
117
|
+
}, undefined>;
|
|
118
|
+
/**
|
|
119
|
+
* `POST /api/check` (playground): a stored subject, a bare role (no subject, no grants), both (the
|
|
120
|
+
* role is the provider's, a stored role still wins) or neither (a guest).
|
|
121
|
+
*/
|
|
122
|
+
export declare const checkBodySchema: v.ObjectSchema<{
|
|
123
|
+
readonly subject: v.OptionalSchema<v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>, undefined>, undefined>;
|
|
124
|
+
readonly role: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>, undefined>;
|
|
125
|
+
readonly path: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
|
|
126
|
+
readonly data: v.OptionalSchema<v.UnknownSchema, undefined>;
|
|
127
|
+
readonly ctx: v.OptionalSchema<v.UnknownSchema, undefined>;
|
|
128
|
+
}, undefined>;
|
|
129
|
+
/** `POST /api/me/check`: the caller's own check. */
|
|
130
|
+
export declare const meCheckBodySchema: v.ObjectSchema<{
|
|
131
|
+
readonly path: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
|
|
132
|
+
readonly data: v.OptionalSchema<v.UnknownSchema, undefined>;
|
|
133
|
+
}, undefined>;
|
|
134
|
+
/** `POST /api/relationships` and `DELETE /api/relationships`: `{ object, relation, subject, reason? }`. */
|
|
135
|
+
export declare const relationshipBodySchema: Omit<v.ObjectSchema<{
|
|
136
|
+
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)">]>;
|
|
137
|
+
readonly relation: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
|
|
138
|
+
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:*\"">]>;
|
|
139
|
+
readonly actor: v.OptionalSchema<v.NullableSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>, v.ObjectSchema<{
|
|
140
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
|
|
141
|
+
readonly type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
142
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
143
|
+
readonly email: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
144
|
+
}, undefined>], undefined>, undefined>, undefined>;
|
|
145
|
+
readonly reason: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 1000, "must be at most 1000 characters">]>, undefined>;
|
|
146
|
+
}, undefined>, "entries" | "~types" | "~run" | "~standard"> & {
|
|
147
|
+
readonly entries: Omit<{
|
|
148
|
+
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)">]>;
|
|
149
|
+
readonly relation: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
|
|
150
|
+
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:*\"">]>;
|
|
151
|
+
readonly actor: v.OptionalSchema<v.NullableSchema<v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>, v.ObjectSchema<{
|
|
152
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
|
|
153
|
+
readonly type: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
154
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
155
|
+
readonly email: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
156
|
+
}, undefined>], undefined>, undefined>, undefined>;
|
|
157
|
+
readonly reason: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 1000, "must be at most 1000 characters">]>, undefined>;
|
|
158
|
+
}, "actor">;
|
|
159
|
+
readonly "~standard": v.StandardProps<{
|
|
160
|
+
object: string;
|
|
161
|
+
reason?: string | undefined;
|
|
162
|
+
subject: string;
|
|
163
|
+
relation: string;
|
|
164
|
+
}, {
|
|
165
|
+
object: string;
|
|
166
|
+
reason?: string | undefined;
|
|
167
|
+
subject: string;
|
|
168
|
+
relation: string;
|
|
169
|
+
}>;
|
|
170
|
+
readonly "~run": (dataset: v.UnknownDataset, config: v.Config<v.BaseIssue<unknown>>) => v.OutputDataset<{
|
|
171
|
+
object: string;
|
|
172
|
+
reason?: string | undefined;
|
|
173
|
+
subject: string;
|
|
174
|
+
relation: string;
|
|
175
|
+
}, v.StringIssue | v.MinLengthIssue<string, 1> | v.ObjectIssue | v.MaxLengthIssue<string, 1000> | v.MaxLengthIssue<string, 512> | v.RegexIssue<string>>;
|
|
176
|
+
readonly "~types"?: {
|
|
177
|
+
readonly input: {
|
|
178
|
+
object: string;
|
|
179
|
+
reason?: string | undefined;
|
|
180
|
+
subject: string;
|
|
181
|
+
relation: string;
|
|
182
|
+
};
|
|
183
|
+
readonly output: {
|
|
184
|
+
object: string;
|
|
185
|
+
reason?: string | undefined;
|
|
186
|
+
subject: string;
|
|
187
|
+
relation: string;
|
|
188
|
+
};
|
|
189
|
+
readonly issue: v.StringIssue | v.MinLengthIssue<string, 1> | v.ObjectIssue | v.MaxLengthIssue<string, 1000> | v.MaxLengthIssue<string, 512> | v.RegexIssue<string>;
|
|
190
|
+
} | undefined;
|
|
191
|
+
};
|
|
192
|
+
/** `POST /api/relationships/check`: `{ subject, relation, object }`. */
|
|
193
|
+
export declare const relationCheckBodySchema: v.ObjectSchema<{
|
|
194
|
+
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:*\"">]>;
|
|
195
|
+
readonly relation: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
|
|
196
|
+
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)">]>;
|
|
197
|
+
}, undefined>;
|
|
198
|
+
/** `POST /api/me/relation`: the caller's own relationship check. */
|
|
199
|
+
export declare const meRelationBodySchema: v.ObjectSchema<{
|
|
200
|
+
readonly relation: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "must not be empty">]>;
|
|
201
|
+
readonly object: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "must be \"type:id\"">]>;
|
|
202
|
+
}, undefined>;
|
|
203
|
+
export type GrantBody = v.InferOutput<typeof grantBodySchema>;
|
|
204
|
+
export type SubjectUpdateBody = v.InferOutput<typeof subjectUpdateBodySchema>;
|
|
205
|
+
export type CheckBody = v.InferOutput<typeof checkBodySchema>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storage contracts. The base {@link PermissionsStorage} is intentionally tiny — four
|
|
3
|
+
* async methods — so users can bring their own backend. Optional capabilities
|
|
4
|
+
* (watch, transactions, compare-and-swap) are separate interfaces that adapters
|
|
5
|
+
* may implement and the core feature-detects.
|
|
6
|
+
*
|
|
7
|
+
* The neutral contract lives in `@xtandard/kit/storage`; these are the
|
|
8
|
+
* permissions names for it.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
export type { CompareAndSwapKvStorage as CompareAndSwapPermissionsStorage, KvStorage as PermissionsStorage, StorageChangeEvent, TransactionalKvStorage as TransactionalPermissionsStorage, WatchableKvStorage as WatchablePermissionsStorage, } from "@xtandard/kit/storage";
|
|
13
|
+
export { isCompareAndSwap, isTransactional, isWatchable } from "@xtandard/kit/storage";
|
|
14
|
+
/**
|
|
15
|
+
* Helper for adapters whose subpath requires an optional peer dependency. Throws
|
|
16
|
+
* a clear, actionable error when the peer is missing.
|
|
17
|
+
*/
|
|
18
|
+
export declare function requirePeer(name: string, subpath: string): never;
|