@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
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { a as computed, b as union, d as exclusion, f as from, g as intersection, i as checkRulesAtPath, l as defineRelations, m as hasPermission, n as RelationDepthError, p as hasAssignedPermission, r as RelationSchemaError, t as AsyncRuleError, u as direct, y as toPermissionSet } from "./policy-BQmlo2lu.mjs";
|
|
2
|
+
import { definePermissions, fromAuthorization } from "./catalog.mjs";
|
|
3
|
+
import { A as revokeInputSchema, C as historyQuerySchema, D as relationCheckSchema, E as listRelationSubjectsQuerySchema, M as upsertSubjectInputSchema, O as relationshipInputSchema, S as grantInputSchema, T as listQuerySchema, _ as defaultHookErrorReporter, a as isWatchable, b as runBefore, g as HookDeniedError, i as isTransactional, j as setRoleInputSchema, k as relationshipQuerySchema, o as ROOT, r as isCompareAndSwap, v as normalizeHooks, w as listObjectsQuerySchema, x as actorSchema, y as runAfter } from "./relationships-BfLonEMI.mjs";
|
|
4
|
+
import { a as UnknownPermissionError, i as ReadonlyError, n as NoSubjectError, o as UnknownRoleError, r as NotFoundError, s as ValidationError, t as ForbiddenError } from "./errors-bL3XQLfE.mjs";
|
|
5
|
+
import { t as createPermissions } from "./engine-Bufv0TbD.mjs";
|
|
6
|
+
import { n as normalizeRoles, r as splitRoles } from "./contract-Yc5AZuvv.mjs";
|
|
7
|
+
import { n as toKitAuth, t as subjectOf } from "./kit-fzXHYb1l.mjs";
|
|
8
|
+
import { i as isMutatingAction, n as MUTATING_ACTIONS, t as ALL_ACTIONS } from "./contract-DTdTXZtJ.mjs";
|
|
9
|
+
import { c as serializeCheck, i as catalogView, n as CONFIG_PATHS, o as mapError, r as catalogPaths, t as API_ROUTES } from "./routes-DtRb3EO0.mjs";
|
|
10
|
+
import { r as buildOpenApiDocument, t as createFetchHandler } from "./create-fetch-handler-ojjpk1Iw.mjs";
|
|
11
|
+
import { pgListenNotify as pgListenNotify$1, withWatch } from "@xtandard/kit/storage";
|
|
12
|
+
//#region src/storage/watch.ts
|
|
13
|
+
/**
|
|
14
|
+
* Composable change-notifications. `watch` (push-based snapshot refresh in the
|
|
15
|
+
* engine cache) is **orthogonal** to which storage you use, so rather
|
|
16
|
+
* than bake it into each adapter, {@link withWatch} wraps *any* {@link PermissionsStorage}
|
|
17
|
+
* with a {@link WatchSubscribe} source you provide — Postgres `LISTEN`/`NOTIFY`,
|
|
18
|
+
* Redis pub/sub, an ORM after-write hook, a websocket, an `EventEmitter`, etc.
|
|
19
|
+
*
|
|
20
|
+
* This gives `watch` to adapters that don't implement it themselves (postgres,
|
|
21
|
+
* drizzle, mongodb, unstorage, cloudflare-kv, …), driven by whatever change
|
|
22
|
+
* signal your infrastructure already has.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* import { withWatch } from "@xtandard/permissions";
|
|
27
|
+
* import { createDrizzleStorage } from "@xtandard/permissions/storage/drizzle";
|
|
28
|
+
*
|
|
29
|
+
* const storage = withWatch(createDrizzleStorage({ db, table }), (notify) => {
|
|
30
|
+
* const sub = redis.subscribe("permission-changes", (m) => notify(m.key));
|
|
31
|
+
* return () => sub.unsubscribe();
|
|
32
|
+
* });
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* Both helpers come from `@xtandard/kit/storage`; {@link pgListenNotify} keeps
|
|
36
|
+
* the permissions default channel `"xtandard_permissions"`.
|
|
37
|
+
*
|
|
38
|
+
* @module
|
|
39
|
+
*/
|
|
40
|
+
/**
|
|
41
|
+
* A {@link WatchSubscribe} backed by Postgres `LISTEN`/`NOTIFY`. Pair with
|
|
42
|
+
* {@link withWatch} for the postgres or drizzle-over-pg adapters. Your migration
|
|
43
|
+
* owns the trigger that `pg_notify`s `channel` with the changed key as payload;
|
|
44
|
+
* this only `LISTEN`s.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* import { Client } from "pg";
|
|
49
|
+
* const listener = new Client({ connectionString: process.env.DATABASE_URL });
|
|
50
|
+
* await listener.connect();
|
|
51
|
+
* const storage = withWatch(base, pgListenNotify(listener, "xtandard_permissions"));
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
function pgListenNotify(client, channel = "xtandard_permissions") {
|
|
55
|
+
return pgListenNotify$1(client, channel);
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
export { ALL_ACTIONS, API_ROUTES, AsyncRuleError, CONFIG_PATHS, ForbiddenError, HookDeniedError, ROOT as KEY_ROOT, MUTATING_ACTIONS, NoSubjectError, NotFoundError, ReadonlyError, RelationDepthError, RelationSchemaError, UnknownPermissionError, UnknownRoleError, ValidationError, actorSchema, buildOpenApiDocument, catalogPaths, catalogView, checkRulesAtPath, computed, createFetchHandler, createPermissions, defaultHookErrorReporter, definePermissions, defineRelations, direct, exclusion, from, fromAuthorization, grantInputSchema, hasAssignedPermission, hasPermission, historyQuerySchema, intersection, isCompareAndSwap, isMutatingAction, isTransactional, isWatchable, listObjectsQuerySchema, listQuerySchema, listRelationSubjectsQuerySchema, mapError, normalizeHooks, normalizeRoles, pgListenNotify, relationCheckSchema, relationshipInputSchema, relationshipQuerySchema, revokeInputSchema, runAfter, runBefore, serializeCheck, setRoleInputSchema, splitRoles, subjectOf, toKitAuth, toPermissionSet, union, upsertSubjectInputSchema, withWatch };
|
|
59
|
+
|
|
60
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["kitPgListenNotify"],"sources":["../src/storage/watch.ts"],"sourcesContent":["/**\n * Composable change-notifications. `watch` (push-based snapshot refresh in the\n * engine cache) is **orthogonal** to which storage you use, so rather\n * than bake it into each adapter, {@link withWatch} wraps *any* {@link PermissionsStorage}\n * with a {@link WatchSubscribe} source you provide — Postgres `LISTEN`/`NOTIFY`,\n * Redis pub/sub, an ORM after-write hook, a websocket, an `EventEmitter`, etc.\n *\n * This gives `watch` to adapters that don't implement it themselves (postgres,\n * drizzle, mongodb, unstorage, cloudflare-kv, …), driven by whatever change\n * signal your infrastructure already has.\n *\n * @example\n * ```ts\n * import { withWatch } from \"@xtandard/permissions\";\n * import { createDrizzleStorage } from \"@xtandard/permissions/storage/drizzle\";\n *\n * const storage = withWatch(createDrizzleStorage({ db, table }), (notify) => {\n * const sub = redis.subscribe(\"permission-changes\", (m) => notify(m.key));\n * return () => sub.unsubscribe();\n * });\n * ```\n *\n * Both helpers come from `@xtandard/kit/storage`; {@link pgListenNotify} keeps\n * the permissions default channel `\"xtandard_permissions\"`.\n *\n * @module\n */\n\nimport {\n pgListenNotify as kitPgListenNotify,\n type PgNotificationClient,\n type WatchSubscribe,\n} from \"@xtandard/kit/storage\";\n\nexport { withWatch, type PgNotificationClient, type WatchSubscribe } from \"@xtandard/kit/storage\";\n\n/**\n * A {@link WatchSubscribe} backed by Postgres `LISTEN`/`NOTIFY`. Pair with\n * {@link withWatch} for the postgres or drizzle-over-pg adapters. Your migration\n * owns the trigger that `pg_notify`s `channel` with the changed key as payload;\n * this only `LISTEN`s.\n *\n * @example\n * ```ts\n * import { Client } from \"pg\";\n * const listener = new Client({ connectionString: process.env.DATABASE_URL });\n * await listener.connect();\n * const storage = withWatch(base, pgListenNotify(listener, \"xtandard_permissions\"));\n * ```\n */\nexport function pgListenNotify(\n client: PgNotificationClient,\n channel = \"xtandard_permissions\",\n): WatchSubscribe {\n return kitPgListenNotify(client, channel);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,SAAgB,eACd,QACA,UAAU,wBACM;CAChB,OAAOA,iBAAkB,QAAQ,OAAO;AAC1C"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
const require_errors = require("./errors-vVYic8gz.cjs");
|
|
2
|
+
//#region src/auth-provider/kit.ts
|
|
3
|
+
const DEFAULT_MUTATING = new Set(["grants:write", "roles:write"]);
|
|
4
|
+
/** The `PermissionsSubject` a kit principal built by {@link toKitAuth} carries, if any. */
|
|
5
|
+
function subjectOf(principal) {
|
|
6
|
+
return (principal?.metadata)?.subject ?? null;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Build the kit `auth` + `authorization` pair from a provider and the engine.
|
|
10
|
+
*
|
|
11
|
+
* - `auth.authenticate` → principal `{ id, name, email, roles: [effectiveRole], metadata: { subject } }`.
|
|
12
|
+
* - `authorization.authorize` → no principal: deny; mutating actions: `canManage`; read actions:
|
|
13
|
+
* `canRead` (default `canManage`).
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* const { auth, authorization } = toKitAuth(betterAuthProvider(auth), perms);
|
|
18
|
+
* createFetchHandler({ permissions: perms, auth, authorization });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
function toKitAuth(provider, perms, options = {}) {
|
|
22
|
+
const isMutating = options.isMutating ?? ((action) => DEFAULT_MUTATING.has(action));
|
|
23
|
+
const subject = async (request) => {
|
|
24
|
+
const found = await provider.getSubject(request);
|
|
25
|
+
if (found === null || found === void 0) return null;
|
|
26
|
+
if (typeof found.id !== "string" || found.id === "") throw new require_errors.NoSubjectError("the auth provider returned an identity with an empty id");
|
|
27
|
+
const { subject: resolved } = await perms.snapshot(found);
|
|
28
|
+
const out = {
|
|
29
|
+
id: found.id,
|
|
30
|
+
role: resolved.role
|
|
31
|
+
};
|
|
32
|
+
if (found.name !== void 0) out.name = found.name;
|
|
33
|
+
if (found.email !== void 0) out.email = found.email;
|
|
34
|
+
if (found.attributes !== void 0) out.attributes = found.attributes;
|
|
35
|
+
return out;
|
|
36
|
+
};
|
|
37
|
+
const canManage = async (s, request) => provider.canManage ? await provider.canManage(s, request) === true : perms.catalog.isManagerRole(s.role);
|
|
38
|
+
const canRead = async (s, request) => options.canRead ? await options.canRead(s, request) === true : canManage(s, request);
|
|
39
|
+
return {
|
|
40
|
+
auth: { async authenticate(request) {
|
|
41
|
+
const s = await subject(request);
|
|
42
|
+
if (!s) return null;
|
|
43
|
+
const principal = {
|
|
44
|
+
id: s.id,
|
|
45
|
+
roles: [s.role],
|
|
46
|
+
metadata: { subject: s }
|
|
47
|
+
};
|
|
48
|
+
if (s.name !== void 0) principal.name = s.name;
|
|
49
|
+
if (s.email !== void 0) principal.email = s.email;
|
|
50
|
+
return principal;
|
|
51
|
+
} },
|
|
52
|
+
authorization: { async authorize({ principal, action, request }) {
|
|
53
|
+
if (!principal) return false;
|
|
54
|
+
const s = subjectOf(principal) ?? await subject(request);
|
|
55
|
+
if (!s) return false;
|
|
56
|
+
return isMutating(action) ? canManage(s, request) : canRead(s, request);
|
|
57
|
+
} },
|
|
58
|
+
subject,
|
|
59
|
+
canManage
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
Object.defineProperty(exports, "subjectOf", {
|
|
64
|
+
enumerable: true,
|
|
65
|
+
get: function() {
|
|
66
|
+
return subjectOf;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
Object.defineProperty(exports, "toKitAuth", {
|
|
70
|
+
enumerable: true,
|
|
71
|
+
get: function() {
|
|
72
|
+
return toKitAuth;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
//# sourceMappingURL=kit-C7tepDB2.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kit-C7tepDB2.cjs","names":["NoSubjectError"],"sources":["../src/auth-provider/kit.ts"],"sourcesContent":["/**\n * Adapt a {@link PermissionsAuthProvider} to the kit's `AuthProvider` + `AuthorizationProvider`, so\n * the panel, the router and the framework adapters use it unchanged (ADR 0006).\n *\n * @module\n */\n\nimport type { AuthProvider, Principal } from \"@xtandard/kit/auth\";\nimport type { AuthorizationProvider, AuthorizeInput } from \"@xtandard/kit/authorization\";\nimport { NoSubjectError } from \"../errors.ts\";\nimport type { PermissionsAuthProvider, PermissionsSubject, SubjectIdentity } from \"./contract.ts\";\n\n/** What {@link toKitAuth} needs from the engine (structural, so a test double works too). */\nexport interface KitAuthEngine {\n readonly catalog: { isManagerRole(role: unknown): boolean };\n /** Resolves the effective role: the stored role if any, else the provider's, parsed. */\n snapshot(subject: SubjectIdentity): Promise<{ subject: { id: string | null; role: string } }>;\n}\n\n/** Options for {@link toKitAuth}. */\nexport interface ToKitAuthOptions {\n /**\n * May this subject use the panel's read actions (catalog, subjects, grants, history, the check\n * playground)? Default: the same answer as `canManage` — the panel shows every subject's grants.\n */\n canRead?(subject: PermissionsSubject, request: Request): boolean | Promise<boolean>;\n /** Which actions write state. Default: `grants:write` and `roles:write` (ADR 0008). */\n isMutating?(action: string): boolean;\n}\n\n/** The kit providers built by {@link toKitAuth}. */\nexport interface KitAuth {\n auth: AuthProvider;\n authorization: AuthorizationProvider;\n /** Resolve the caller as a {@link PermissionsSubject} (effective role), or `null`. */\n subject(request: Request): Promise<PermissionsSubject | null>;\n /** The resolved manage decision for a subject (provider `canManage`, else `managerRoles`). */\n canManage(subject: PermissionsSubject, request: Request): Promise<boolean>;\n}\n\nconst DEFAULT_MUTATING: ReadonlySet<string> = new Set([\"grants:write\", \"roles:write\"]);\n\n/** The `PermissionsSubject` a kit principal built by {@link toKitAuth} carries, if any. */\nexport function subjectOf(principal: Principal | null | undefined): PermissionsSubject | null {\n const meta = principal?.metadata as { subject?: PermissionsSubject } | undefined;\n return meta?.subject ?? null;\n}\n\n/**\n * Build the kit `auth` + `authorization` pair from a provider and the engine.\n *\n * - `auth.authenticate` → principal `{ id, name, email, roles: [effectiveRole], metadata: { subject } }`.\n * - `authorization.authorize` → no principal: deny; mutating actions: `canManage`; read actions:\n * `canRead` (default `canManage`).\n *\n * @example\n * ```ts\n * const { auth, authorization } = toKitAuth(betterAuthProvider(auth), perms);\n * createFetchHandler({ permissions: perms, auth, authorization });\n * ```\n */\nexport function toKitAuth(\n provider: PermissionsAuthProvider,\n perms: KitAuthEngine,\n options: ToKitAuthOptions = {},\n): KitAuth {\n const isMutating = options.isMutating ?? ((action: string) => DEFAULT_MUTATING.has(action));\n\n const subject = async (request: Request): Promise<PermissionsSubject | null> => {\n const found = await provider.getSubject(request);\n if (found === null || found === undefined) return null;\n if (typeof found.id !== \"string\" || found.id === \"\") {\n throw new NoSubjectError(\"the auth provider returned an identity with an empty id\");\n }\n const { subject: resolved } = await perms.snapshot(found);\n const out: PermissionsSubject = { id: found.id, role: resolved.role };\n if (found.name !== undefined) out.name = found.name;\n if (found.email !== undefined) out.email = found.email;\n if (found.attributes !== undefined) out.attributes = found.attributes;\n return out;\n };\n\n const canManage = async (s: PermissionsSubject, request: Request): Promise<boolean> =>\n provider.canManage\n ? (await provider.canManage(s, request)) === true\n : perms.catalog.isManagerRole(s.role);\n\n const canRead = async (s: PermissionsSubject, request: Request): Promise<boolean> =>\n options.canRead ? (await options.canRead(s, request)) === true : canManage(s, request);\n\n const auth: AuthProvider = {\n async authenticate(request) {\n const s = await subject(request);\n if (!s) return null;\n const principal: Principal = { id: s.id, roles: [s.role], metadata: { subject: s } };\n if (s.name !== undefined) principal.name = s.name;\n if (s.email !== undefined) principal.email = s.email;\n return principal;\n },\n };\n\n const authorization: AuthorizationProvider = {\n async authorize({ principal, action, request }: AuthorizeInput) {\n if (!principal) return false;\n const s = subjectOf(principal) ?? (await subject(request));\n if (!s) return false;\n return isMutating(action) ? canManage(s, request) : canRead(s, request);\n },\n };\n\n return { auth, authorization, subject, canManage };\n}\n"],"mappings":";;AAwCA,MAAM,mBAAwC,IAAI,IAAI,CAAC,gBAAgB,aAAa,CAAC;;AAGrF,SAAgB,UAAU,WAAoE;CAE5F,QADa,WAAW,WACX,WAAW;AAC1B;;;;;;;;;;;;;;AAeA,SAAgB,UACd,UACA,OACA,UAA4B,CAAC,GACpB;CACT,MAAM,aAAa,QAAQ,gBAAgB,WAAmB,iBAAiB,IAAI,MAAM;CAEzF,MAAM,UAAU,OAAO,YAAyD;EAC9E,MAAM,QAAQ,MAAM,SAAS,WAAW,OAAO;EAC/C,IAAI,UAAU,QAAQ,UAAU,KAAA,GAAW,OAAO;EAClD,IAAI,OAAO,MAAM,OAAO,YAAY,MAAM,OAAO,IAC/C,MAAM,IAAIA,eAAAA,eAAe,yDAAyD;EAEpF,MAAM,EAAE,SAAS,aAAa,MAAM,MAAM,SAAS,KAAK;EACxD,MAAM,MAA0B;GAAE,IAAI,MAAM;GAAI,MAAM,SAAS;EAAK;EACpE,IAAI,MAAM,SAAS,KAAA,GAAW,IAAI,OAAO,MAAM;EAC/C,IAAI,MAAM,UAAU,KAAA,GAAW,IAAI,QAAQ,MAAM;EACjD,IAAI,MAAM,eAAe,KAAA,GAAW,IAAI,aAAa,MAAM;EAC3D,OAAO;CACT;CAEA,MAAM,YAAY,OAAO,GAAuB,YAC9C,SAAS,YACJ,MAAM,SAAS,UAAU,GAAG,OAAO,MAAO,OAC3C,MAAM,QAAQ,cAAc,EAAE,IAAI;CAExC,MAAM,UAAU,OAAO,GAAuB,YAC5C,QAAQ,UAAW,MAAM,QAAQ,QAAQ,GAAG,OAAO,MAAO,OAAO,UAAU,GAAG,OAAO;CAsBvF,OAAO;EAAE,MAAA,EAnBP,MAAM,aAAa,SAAS;GAC1B,MAAM,IAAI,MAAM,QAAQ,OAAO;GAC/B,IAAI,CAAC,GAAG,OAAO;GACf,MAAM,YAAuB;IAAE,IAAI,EAAE;IAAI,OAAO,CAAC,EAAE,IAAI;IAAG,UAAU,EAAE,SAAS,EAAE;GAAE;GACnF,IAAI,EAAE,SAAS,KAAA,GAAW,UAAU,OAAO,EAAE;GAC7C,IAAI,EAAE,UAAU,KAAA,GAAW,UAAU,QAAQ,EAAE;GAC/C,OAAO;EACT,EAYU;EAAG,eAAA,EARb,MAAM,UAAU,EAAE,WAAW,QAAQ,WAA2B;GAC9D,IAAI,CAAC,WAAW,OAAO;GACvB,MAAM,IAAI,UAAU,SAAS,KAAM,MAAM,QAAQ,OAAO;GACxD,IAAI,CAAC,GAAG,OAAO;GACf,OAAO,WAAW,MAAM,IAAI,UAAU,GAAG,OAAO,IAAI,QAAQ,GAAG,OAAO;EACxE,EAGyB;EAAG;EAAS;CAAU;AACnD"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { f as PermissionsSubject, h as SubjectIdentity } from "./catalog-DJcJ3ycq.mjs";
|
|
2
|
+
import { t as PermissionsAuthProvider } from "./contract-D32H1t0u.mjs";
|
|
3
|
+
import { AuthorizationProvider } from "@xtandard/kit/authorization";
|
|
4
|
+
import { AuthProvider, Principal } from "@xtandard/kit/auth";
|
|
5
|
+
|
|
6
|
+
//#region src/auth-provider/kit.d.ts
|
|
7
|
+
/** What {@link toKitAuth} needs from the engine (structural, so a test double works too). */
|
|
8
|
+
interface KitAuthEngine {
|
|
9
|
+
readonly catalog: {
|
|
10
|
+
isManagerRole(role: unknown): boolean;
|
|
11
|
+
};
|
|
12
|
+
/** Resolves the effective role: the stored role if any, else the provider's, parsed. */
|
|
13
|
+
snapshot(subject: SubjectIdentity): Promise<{
|
|
14
|
+
subject: {
|
|
15
|
+
id: string | null;
|
|
16
|
+
role: string;
|
|
17
|
+
};
|
|
18
|
+
}>;
|
|
19
|
+
}
|
|
20
|
+
/** Options for {@link toKitAuth}. */
|
|
21
|
+
interface ToKitAuthOptions {
|
|
22
|
+
/**
|
|
23
|
+
* May this subject use the panel's read actions (catalog, subjects, grants, history, the check
|
|
24
|
+
* playground)? Default: the same answer as `canManage` — the panel shows every subject's grants.
|
|
25
|
+
*/
|
|
26
|
+
canRead?(subject: PermissionsSubject, request: Request): boolean | Promise<boolean>;
|
|
27
|
+
/** Which actions write state. Default: `grants:write` and `roles:write` (ADR 0008). */
|
|
28
|
+
isMutating?(action: string): boolean;
|
|
29
|
+
}
|
|
30
|
+
/** The kit providers built by {@link toKitAuth}. */
|
|
31
|
+
interface KitAuth {
|
|
32
|
+
auth: AuthProvider;
|
|
33
|
+
authorization: AuthorizationProvider;
|
|
34
|
+
/** Resolve the caller as a {@link PermissionsSubject} (effective role), or `null`. */
|
|
35
|
+
subject(request: Request): Promise<PermissionsSubject | null>;
|
|
36
|
+
/** The resolved manage decision for a subject (provider `canManage`, else `managerRoles`). */
|
|
37
|
+
canManage(subject: PermissionsSubject, request: Request): Promise<boolean>;
|
|
38
|
+
}
|
|
39
|
+
/** The `PermissionsSubject` a kit principal built by {@link toKitAuth} carries, if any. */
|
|
40
|
+
declare function subjectOf(principal: Principal | null | undefined): PermissionsSubject | null;
|
|
41
|
+
/**
|
|
42
|
+
* Build the kit `auth` + `authorization` pair from a provider and the engine.
|
|
43
|
+
*
|
|
44
|
+
* - `auth.authenticate` → principal `{ id, name, email, roles: [effectiveRole], metadata: { subject } }`.
|
|
45
|
+
* - `authorization.authorize` → no principal: deny; mutating actions: `canManage`; read actions:
|
|
46
|
+
* `canRead` (default `canManage`).
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* const { auth, authorization } = toKitAuth(betterAuthProvider(auth), perms);
|
|
51
|
+
* createFetchHandler({ permissions: perms, auth, authorization });
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
declare function toKitAuth(provider: PermissionsAuthProvider, perms: KitAuthEngine, options?: ToKitAuthOptions): KitAuth;
|
|
55
|
+
//#endregion
|
|
56
|
+
export { toKitAuth as a, subjectOf as i, KitAuthEngine as n, ToKitAuthOptions as r, KitAuth as t };
|
|
57
|
+
//# sourceMappingURL=kit-DMVBLBI9.d.mts.map
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { n as NoSubjectError } from "./errors-bL3XQLfE.mjs";
|
|
2
|
+
//#region src/auth-provider/kit.ts
|
|
3
|
+
const DEFAULT_MUTATING = new Set(["grants:write", "roles:write"]);
|
|
4
|
+
/** The `PermissionsSubject` a kit principal built by {@link toKitAuth} carries, if any. */
|
|
5
|
+
function subjectOf(principal) {
|
|
6
|
+
return (principal?.metadata)?.subject ?? null;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Build the kit `auth` + `authorization` pair from a provider and the engine.
|
|
10
|
+
*
|
|
11
|
+
* - `auth.authenticate` → principal `{ id, name, email, roles: [effectiveRole], metadata: { subject } }`.
|
|
12
|
+
* - `authorization.authorize` → no principal: deny; mutating actions: `canManage`; read actions:
|
|
13
|
+
* `canRead` (default `canManage`).
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* const { auth, authorization } = toKitAuth(betterAuthProvider(auth), perms);
|
|
18
|
+
* createFetchHandler({ permissions: perms, auth, authorization });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
function toKitAuth(provider, perms, options = {}) {
|
|
22
|
+
const isMutating = options.isMutating ?? ((action) => DEFAULT_MUTATING.has(action));
|
|
23
|
+
const subject = async (request) => {
|
|
24
|
+
const found = await provider.getSubject(request);
|
|
25
|
+
if (found === null || found === void 0) return null;
|
|
26
|
+
if (typeof found.id !== "string" || found.id === "") throw new NoSubjectError("the auth provider returned an identity with an empty id");
|
|
27
|
+
const { subject: resolved } = await perms.snapshot(found);
|
|
28
|
+
const out = {
|
|
29
|
+
id: found.id,
|
|
30
|
+
role: resolved.role
|
|
31
|
+
};
|
|
32
|
+
if (found.name !== void 0) out.name = found.name;
|
|
33
|
+
if (found.email !== void 0) out.email = found.email;
|
|
34
|
+
if (found.attributes !== void 0) out.attributes = found.attributes;
|
|
35
|
+
return out;
|
|
36
|
+
};
|
|
37
|
+
const canManage = async (s, request) => provider.canManage ? await provider.canManage(s, request) === true : perms.catalog.isManagerRole(s.role);
|
|
38
|
+
const canRead = async (s, request) => options.canRead ? await options.canRead(s, request) === true : canManage(s, request);
|
|
39
|
+
return {
|
|
40
|
+
auth: { async authenticate(request) {
|
|
41
|
+
const s = await subject(request);
|
|
42
|
+
if (!s) return null;
|
|
43
|
+
const principal = {
|
|
44
|
+
id: s.id,
|
|
45
|
+
roles: [s.role],
|
|
46
|
+
metadata: { subject: s }
|
|
47
|
+
};
|
|
48
|
+
if (s.name !== void 0) principal.name = s.name;
|
|
49
|
+
if (s.email !== void 0) principal.email = s.email;
|
|
50
|
+
return principal;
|
|
51
|
+
} },
|
|
52
|
+
authorization: { async authorize({ principal, action, request }) {
|
|
53
|
+
if (!principal) return false;
|
|
54
|
+
const s = subjectOf(principal) ?? await subject(request);
|
|
55
|
+
if (!s) return false;
|
|
56
|
+
return isMutating(action) ? canManage(s, request) : canRead(s, request);
|
|
57
|
+
} },
|
|
58
|
+
subject,
|
|
59
|
+
canManage
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
export { toKitAuth as n, subjectOf as t };
|
|
64
|
+
|
|
65
|
+
//# sourceMappingURL=kit-fzXHYb1l.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kit-fzXHYb1l.mjs","names":[],"sources":["../src/auth-provider/kit.ts"],"sourcesContent":["/**\n * Adapt a {@link PermissionsAuthProvider} to the kit's `AuthProvider` + `AuthorizationProvider`, so\n * the panel, the router and the framework adapters use it unchanged (ADR 0006).\n *\n * @module\n */\n\nimport type { AuthProvider, Principal } from \"@xtandard/kit/auth\";\nimport type { AuthorizationProvider, AuthorizeInput } from \"@xtandard/kit/authorization\";\nimport { NoSubjectError } from \"../errors.ts\";\nimport type { PermissionsAuthProvider, PermissionsSubject, SubjectIdentity } from \"./contract.ts\";\n\n/** What {@link toKitAuth} needs from the engine (structural, so a test double works too). */\nexport interface KitAuthEngine {\n readonly catalog: { isManagerRole(role: unknown): boolean };\n /** Resolves the effective role: the stored role if any, else the provider's, parsed. */\n snapshot(subject: SubjectIdentity): Promise<{ subject: { id: string | null; role: string } }>;\n}\n\n/** Options for {@link toKitAuth}. */\nexport interface ToKitAuthOptions {\n /**\n * May this subject use the panel's read actions (catalog, subjects, grants, history, the check\n * playground)? Default: the same answer as `canManage` — the panel shows every subject's grants.\n */\n canRead?(subject: PermissionsSubject, request: Request): boolean | Promise<boolean>;\n /** Which actions write state. Default: `grants:write` and `roles:write` (ADR 0008). */\n isMutating?(action: string): boolean;\n}\n\n/** The kit providers built by {@link toKitAuth}. */\nexport interface KitAuth {\n auth: AuthProvider;\n authorization: AuthorizationProvider;\n /** Resolve the caller as a {@link PermissionsSubject} (effective role), or `null`. */\n subject(request: Request): Promise<PermissionsSubject | null>;\n /** The resolved manage decision for a subject (provider `canManage`, else `managerRoles`). */\n canManage(subject: PermissionsSubject, request: Request): Promise<boolean>;\n}\n\nconst DEFAULT_MUTATING: ReadonlySet<string> = new Set([\"grants:write\", \"roles:write\"]);\n\n/** The `PermissionsSubject` a kit principal built by {@link toKitAuth} carries, if any. */\nexport function subjectOf(principal: Principal | null | undefined): PermissionsSubject | null {\n const meta = principal?.metadata as { subject?: PermissionsSubject } | undefined;\n return meta?.subject ?? null;\n}\n\n/**\n * Build the kit `auth` + `authorization` pair from a provider and the engine.\n *\n * - `auth.authenticate` → principal `{ id, name, email, roles: [effectiveRole], metadata: { subject } }`.\n * - `authorization.authorize` → no principal: deny; mutating actions: `canManage`; read actions:\n * `canRead` (default `canManage`).\n *\n * @example\n * ```ts\n * const { auth, authorization } = toKitAuth(betterAuthProvider(auth), perms);\n * createFetchHandler({ permissions: perms, auth, authorization });\n * ```\n */\nexport function toKitAuth(\n provider: PermissionsAuthProvider,\n perms: KitAuthEngine,\n options: ToKitAuthOptions = {},\n): KitAuth {\n const isMutating = options.isMutating ?? ((action: string) => DEFAULT_MUTATING.has(action));\n\n const subject = async (request: Request): Promise<PermissionsSubject | null> => {\n const found = await provider.getSubject(request);\n if (found === null || found === undefined) return null;\n if (typeof found.id !== \"string\" || found.id === \"\") {\n throw new NoSubjectError(\"the auth provider returned an identity with an empty id\");\n }\n const { subject: resolved } = await perms.snapshot(found);\n const out: PermissionsSubject = { id: found.id, role: resolved.role };\n if (found.name !== undefined) out.name = found.name;\n if (found.email !== undefined) out.email = found.email;\n if (found.attributes !== undefined) out.attributes = found.attributes;\n return out;\n };\n\n const canManage = async (s: PermissionsSubject, request: Request): Promise<boolean> =>\n provider.canManage\n ? (await provider.canManage(s, request)) === true\n : perms.catalog.isManagerRole(s.role);\n\n const canRead = async (s: PermissionsSubject, request: Request): Promise<boolean> =>\n options.canRead ? (await options.canRead(s, request)) === true : canManage(s, request);\n\n const auth: AuthProvider = {\n async authenticate(request) {\n const s = await subject(request);\n if (!s) return null;\n const principal: Principal = { id: s.id, roles: [s.role], metadata: { subject: s } };\n if (s.name !== undefined) principal.name = s.name;\n if (s.email !== undefined) principal.email = s.email;\n return principal;\n },\n };\n\n const authorization: AuthorizationProvider = {\n async authorize({ principal, action, request }: AuthorizeInput) {\n if (!principal) return false;\n const s = subjectOf(principal) ?? (await subject(request));\n if (!s) return false;\n return isMutating(action) ? canManage(s, request) : canRead(s, request);\n },\n };\n\n return { auth, authorization, subject, canManage };\n}\n"],"mappings":";;AAwCA,MAAM,mBAAwC,IAAI,IAAI,CAAC,gBAAgB,aAAa,CAAC;;AAGrF,SAAgB,UAAU,WAAoE;CAE5F,QADa,WAAW,WACX,WAAW;AAC1B;;;;;;;;;;;;;;AAeA,SAAgB,UACd,UACA,OACA,UAA4B,CAAC,GACpB;CACT,MAAM,aAAa,QAAQ,gBAAgB,WAAmB,iBAAiB,IAAI,MAAM;CAEzF,MAAM,UAAU,OAAO,YAAyD;EAC9E,MAAM,QAAQ,MAAM,SAAS,WAAW,OAAO;EAC/C,IAAI,UAAU,QAAQ,UAAU,KAAA,GAAW,OAAO;EAClD,IAAI,OAAO,MAAM,OAAO,YAAY,MAAM,OAAO,IAC/C,MAAM,IAAI,eAAe,yDAAyD;EAEpF,MAAM,EAAE,SAAS,aAAa,MAAM,MAAM,SAAS,KAAK;EACxD,MAAM,MAA0B;GAAE,IAAI,MAAM;GAAI,MAAM,SAAS;EAAK;EACpE,IAAI,MAAM,SAAS,KAAA,GAAW,IAAI,OAAO,MAAM;EAC/C,IAAI,MAAM,UAAU,KAAA,GAAW,IAAI,QAAQ,MAAM;EACjD,IAAI,MAAM,eAAe,KAAA,GAAW,IAAI,aAAa,MAAM;EAC3D,OAAO;CACT;CAEA,MAAM,YAAY,OAAO,GAAuB,YAC9C,SAAS,YACJ,MAAM,SAAS,UAAU,GAAG,OAAO,MAAO,OAC3C,MAAM,QAAQ,cAAc,EAAE,IAAI;CAExC,MAAM,UAAU,OAAO,GAAuB,YAC5C,QAAQ,UAAW,MAAM,QAAQ,QAAQ,GAAG,OAAO,MAAO,OAAO,UAAU,GAAG,OAAO;CAsBvF,OAAO;EAAE,MAAA,EAnBP,MAAM,aAAa,SAAS;GAC1B,MAAM,IAAI,MAAM,QAAQ,OAAO;GAC/B,IAAI,CAAC,GAAG,OAAO;GACf,MAAM,YAAuB;IAAE,IAAI,EAAE;IAAI,OAAO,CAAC,EAAE,IAAI;IAAG,UAAU,EAAE,SAAS,EAAE;GAAE;GACnF,IAAI,EAAE,SAAS,KAAA,GAAW,UAAU,OAAO,EAAE;GAC7C,IAAI,EAAE,UAAU,KAAA,GAAW,UAAU,QAAQ,EAAE;GAC/C,OAAO;EACT,EAYU;EAAG,eAAA,EARb,MAAM,UAAU,EAAE,WAAW,QAAQ,WAA2B;GAC9D,IAAI,CAAC,WAAW,OAAO;GACvB,MAAM,IAAI,UAAU,SAAS,KAAM,MAAM,QAAQ,OAAO;GACxD,IAAI,CAAC,GAAG,OAAO;GACf,OAAO,WAAW,MAAM,IAAI,UAAU,GAAG,OAAO,IAAI,QAAQ,GAAG,OAAO;EACxE,EAGyB;EAAG;EAAS;CAAU;AACnD"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { f as PermissionsSubject, h as SubjectIdentity } from "./catalog-DA_d1SdC.cjs";
|
|
2
|
+
import { t as PermissionsAuthProvider } from "./contract-BMiOmg2f.cjs";
|
|
3
|
+
import { AuthProvider, Principal } from "@xtandard/kit/auth";
|
|
4
|
+
import { AuthorizationProvider } from "@xtandard/kit/authorization";
|
|
5
|
+
|
|
6
|
+
//#region src/auth-provider/kit.d.ts
|
|
7
|
+
/** What {@link toKitAuth} needs from the engine (structural, so a test double works too). */
|
|
8
|
+
interface KitAuthEngine {
|
|
9
|
+
readonly catalog: {
|
|
10
|
+
isManagerRole(role: unknown): boolean;
|
|
11
|
+
};
|
|
12
|
+
/** Resolves the effective role: the stored role if any, else the provider's, parsed. */
|
|
13
|
+
snapshot(subject: SubjectIdentity): Promise<{
|
|
14
|
+
subject: {
|
|
15
|
+
id: string | null;
|
|
16
|
+
role: string;
|
|
17
|
+
};
|
|
18
|
+
}>;
|
|
19
|
+
}
|
|
20
|
+
/** Options for {@link toKitAuth}. */
|
|
21
|
+
interface ToKitAuthOptions {
|
|
22
|
+
/**
|
|
23
|
+
* May this subject use the panel's read actions (catalog, subjects, grants, history, the check
|
|
24
|
+
* playground)? Default: the same answer as `canManage` — the panel shows every subject's grants.
|
|
25
|
+
*/
|
|
26
|
+
canRead?(subject: PermissionsSubject, request: Request): boolean | Promise<boolean>;
|
|
27
|
+
/** Which actions write state. Default: `grants:write` and `roles:write` (ADR 0008). */
|
|
28
|
+
isMutating?(action: string): boolean;
|
|
29
|
+
}
|
|
30
|
+
/** The kit providers built by {@link toKitAuth}. */
|
|
31
|
+
interface KitAuth {
|
|
32
|
+
auth: AuthProvider;
|
|
33
|
+
authorization: AuthorizationProvider;
|
|
34
|
+
/** Resolve the caller as a {@link PermissionsSubject} (effective role), or `null`. */
|
|
35
|
+
subject(request: Request): Promise<PermissionsSubject | null>;
|
|
36
|
+
/** The resolved manage decision for a subject (provider `canManage`, else `managerRoles`). */
|
|
37
|
+
canManage(subject: PermissionsSubject, request: Request): Promise<boolean>;
|
|
38
|
+
}
|
|
39
|
+
/** The `PermissionsSubject` a kit principal built by {@link toKitAuth} carries, if any. */
|
|
40
|
+
declare function subjectOf(principal: Principal | null | undefined): PermissionsSubject | null;
|
|
41
|
+
/**
|
|
42
|
+
* Build the kit `auth` + `authorization` pair from a provider and the engine.
|
|
43
|
+
*
|
|
44
|
+
* - `auth.authenticate` → principal `{ id, name, email, roles: [effectiveRole], metadata: { subject } }`.
|
|
45
|
+
* - `authorization.authorize` → no principal: deny; mutating actions: `canManage`; read actions:
|
|
46
|
+
* `canRead` (default `canManage`).
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* const { auth, authorization } = toKitAuth(betterAuthProvider(auth), perms);
|
|
51
|
+
* createFetchHandler({ permissions: perms, auth, authorization });
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
declare function toKitAuth(provider: PermissionsAuthProvider, perms: KitAuthEngine, options?: ToKitAuthOptions): KitAuth;
|
|
55
|
+
//#endregion
|
|
56
|
+
export { toKitAuth as a, subjectOf as i, KitAuthEngine as n, ToKitAuthOptions as r, KitAuth as t };
|
|
57
|
+
//# sourceMappingURL=kit-qAROuhOI.d.cts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as kit from "@xtandard/kit/storage/memory";
|
|
2
|
+
//#region src/storage/memory.ts
|
|
3
|
+
/**
|
|
4
|
+
* In-memory storage adapter. Zero deps. Useful for tests, dev, and as the
|
|
5
|
+
* default `runtimeStorage` fallback. Values are deep-cloned on write and read so
|
|
6
|
+
* callers cannot mutate stored state by reference.
|
|
7
|
+
*
|
|
8
|
+
* The driver is `@xtandard/kit/storage/memory`.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Create an in-memory storage implementing both `watch` (callbacks fire on the
|
|
14
|
+
* next microtask after a write/remove) and `compareAndSwap` (structural
|
|
15
|
+
* equality; race-free in-process).
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { createMemoryStorage } from "@xtandard/permissions/storage/memory";
|
|
20
|
+
*
|
|
21
|
+
* const storage = createMemoryStorage();
|
|
22
|
+
* // Optionally seed with pre-existing data:
|
|
23
|
+
* // const storage = createMemoryStorage({ initial: { "my-key": { value: 1 } } });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
function createMemoryStorage(options = {}) {
|
|
27
|
+
return kit.createMemoryStorage(options);
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { createMemoryStorage as t };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=memory-BbBbbY8-.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-BbBbbY8-.mjs","names":[],"sources":["../src/storage/memory.ts"],"sourcesContent":["/**\n * In-memory storage adapter. Zero deps. Useful for tests, dev, and as the\n * default `runtimeStorage` fallback. Values are deep-cloned on write and read so\n * callers cannot mutate stored state by reference.\n *\n * The driver is `@xtandard/kit/storage/memory`.\n *\n * @module\n */\n\nimport * as kit from \"@xtandard/kit/storage/memory\";\n\n/** Options for {@link createMemoryStorage}. */\nexport type MemoryStorageOptions = kit.MemoryStorageOptions;\n\n/** The memory storage: watchable and compare-and-swap capable. */\nexport type MemoryPermissionsStorage = kit.MemoryKvStorage;\n\n/**\n * Create an in-memory storage implementing both `watch` (callbacks fire on the\n * next microtask after a write/remove) and `compareAndSwap` (structural\n * equality; race-free in-process).\n *\n * @example\n * ```ts\n * import { createMemoryStorage } from \"@xtandard/permissions/storage/memory\";\n *\n * const storage = createMemoryStorage();\n * // Optionally seed with pre-existing data:\n * // const storage = createMemoryStorage({ initial: { \"my-key\": { value: 1 } } });\n * ```\n */\nexport function createMemoryStorage(options: MemoryStorageOptions = {}): MemoryPermissionsStorage {\n return kit.createMemoryStorage(options);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,SAAgB,oBAAoB,UAAgC,CAAC,GAA6B;CAChG,OAAO,IAAI,oBAAoB,OAAO;AACxC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const require_chunk = require("./chunk-DakpK96I.cjs");
|
|
2
|
+
let _xtandard_kit_storage_memory = require("@xtandard/kit/storage/memory");
|
|
3
|
+
_xtandard_kit_storage_memory = require_chunk.__toESM(_xtandard_kit_storage_memory, 1);
|
|
4
|
+
//#region src/storage/memory.ts
|
|
5
|
+
/**
|
|
6
|
+
* In-memory storage adapter. Zero deps. Useful for tests, dev, and as the
|
|
7
|
+
* default `runtimeStorage` fallback. Values are deep-cloned on write and read so
|
|
8
|
+
* callers cannot mutate stored state by reference.
|
|
9
|
+
*
|
|
10
|
+
* The driver is `@xtandard/kit/storage/memory`.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Create an in-memory storage implementing both `watch` (callbacks fire on the
|
|
16
|
+
* next microtask after a write/remove) and `compareAndSwap` (structural
|
|
17
|
+
* equality; race-free in-process).
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { createMemoryStorage } from "@xtandard/permissions/storage/memory";
|
|
22
|
+
*
|
|
23
|
+
* const storage = createMemoryStorage();
|
|
24
|
+
* // Optionally seed with pre-existing data:
|
|
25
|
+
* // const storage = createMemoryStorage({ initial: { "my-key": { value: 1 } } });
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
function createMemoryStorage(options = {}) {
|
|
29
|
+
return _xtandard_kit_storage_memory.createMemoryStorage(options);
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
Object.defineProperty(exports, "createMemoryStorage", {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function() {
|
|
35
|
+
return createMemoryStorage;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=memory-knijqKw_.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-knijqKw_.cjs","names":["kit"],"sources":["../src/storage/memory.ts"],"sourcesContent":["/**\n * In-memory storage adapter. Zero deps. Useful for tests, dev, and as the\n * default `runtimeStorage` fallback. Values are deep-cloned on write and read so\n * callers cannot mutate stored state by reference.\n *\n * The driver is `@xtandard/kit/storage/memory`.\n *\n * @module\n */\n\nimport * as kit from \"@xtandard/kit/storage/memory\";\n\n/** Options for {@link createMemoryStorage}. */\nexport type MemoryStorageOptions = kit.MemoryStorageOptions;\n\n/** The memory storage: watchable and compare-and-swap capable. */\nexport type MemoryPermissionsStorage = kit.MemoryKvStorage;\n\n/**\n * Create an in-memory storage implementing both `watch` (callbacks fire on the\n * next microtask after a write/remove) and `compareAndSwap` (structural\n * equality; race-free in-process).\n *\n * @example\n * ```ts\n * import { createMemoryStorage } from \"@xtandard/permissions/storage/memory\";\n *\n * const storage = createMemoryStorage();\n * // Optionally seed with pre-existing data:\n * // const storage = createMemoryStorage({ initial: { \"my-key\": { value: 1 } } });\n * ```\n */\nexport function createMemoryStorage(options: MemoryStorageOptions = {}): MemoryPermissionsStorage {\n return kit.createMemoryStorage(options);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,SAAgB,oBAAoB,UAAgC,CAAC,GAA6B;CAChG,OAAOA,6BAAI,oBAAoB,OAAO;AACxC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { t as subjectOf } from "./kit-fzXHYb1l.mjs";
|
|
2
|
+
import { delegatedAuthorization } from "@xtandard/kit/authorization/delegated";
|
|
3
|
+
//#region src/authorization/permissions.ts
|
|
4
|
+
/**
|
|
5
|
+
* The subject identity of a kit principal: the one `toKitAuth` attached, else the principal's own
|
|
6
|
+
* id, roles, name and email.
|
|
7
|
+
*/
|
|
8
|
+
function principalIdentity(principal) {
|
|
9
|
+
const attached = subjectOf(principal);
|
|
10
|
+
const out = {
|
|
11
|
+
id: principal.id,
|
|
12
|
+
role: principal.roles ?? null
|
|
13
|
+
};
|
|
14
|
+
if (attached && attached.id === principal.id) {
|
|
15
|
+
out.role = attached.role;
|
|
16
|
+
if (attached.attributes !== void 0) out.attributes = attached.attributes;
|
|
17
|
+
}
|
|
18
|
+
const name = attached?.name ?? principal.name;
|
|
19
|
+
const email = attached?.email ?? principal.email;
|
|
20
|
+
if (name !== void 0) out.name = name;
|
|
21
|
+
if (email !== void 0) out.email = email;
|
|
22
|
+
return out;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Build a kit `AuthorizationProvider` that decides another panel's actions with this catalog.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* import { permissionsAuthorization } from "@xtandard/permissions/authorization/permissions";
|
|
30
|
+
* import { createFetchHandler as webhooksPanel } from "@xtandard/webhooks";
|
|
31
|
+
*
|
|
32
|
+
* webhooksPanel({
|
|
33
|
+
* auth, // the same kit auth, e.g. toKitAuth(betterAuthProvider(auth), perms).auth
|
|
34
|
+
* authorization: permissionsAuthorization(perms, {
|
|
35
|
+
* "endpoint:read": "webhooks.read",
|
|
36
|
+
* "endpoint:write": "webhooks.manage",
|
|
37
|
+
* }),
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
function permissionsAuthorization(perms, map, options = {}) {
|
|
42
|
+
return delegatedAuthorization({ async authorize(input) {
|
|
43
|
+
if (!input.principal) return false;
|
|
44
|
+
const target = typeof map === "function" ? await map(input) : Object.hasOwn(map, input.action) ? map[input.action] : void 0;
|
|
45
|
+
if (!target) return false;
|
|
46
|
+
const { path, data } = typeof target === "string" ? {
|
|
47
|
+
path: target,
|
|
48
|
+
data: void 0
|
|
49
|
+
} : target;
|
|
50
|
+
const subject = options.subject ? await options.subject(input.principal, input) : principalIdentity(input.principal);
|
|
51
|
+
if (!subject) return false;
|
|
52
|
+
const facts = options.ctx ? [{ ctx: options.ctx(input) }] : [];
|
|
53
|
+
return (await (await perms.ability(subject, ...facts)).checkAsync(path, data)).allowed;
|
|
54
|
+
} });
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
export { principalIdentity as n, permissionsAuthorization as t };
|
|
58
|
+
|
|
59
|
+
//# sourceMappingURL=permissions-C9PjftY6.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permissions-C9PjftY6.mjs","names":[],"sources":["../src/authorization/permissions.ts"],"sourcesContent":["/**\n * Authorize **another** xtandard panel (webhooks, flags, audit, entitlements…) with this catalog\n * (ADR 0011): {@link permissionsAuthorization} maps each of that panel's actions to a permission\n * path of your catalog and asks the engine, through the kit's `delegatedAuthorization`.\n *\n * The principal becomes the subject: the identity `toKitAuth` attached (`metadata.subject`) when\n * present, else `{ id, role: principal.roles, name, email }`. An unmapped action is denied.\n *\n * @module\n */\n\nimport type { Principal } from \"@xtandard/kit/auth\";\nimport type { AuthorizationProvider, AuthorizeInput } from \"@xtandard/kit/authorization\";\nimport { delegatedAuthorization } from \"@xtandard/kit/authorization/delegated\";\nimport { subjectOf } from \"../auth-provider/kit.ts\";\nimport type { SubjectIdentity } from \"../catalog.ts\";\nimport type { AnyPermissions } from \"../engine.ts\";\n\n/** What one panel action maps to: a path, a path plus the data its rule reads, or deny. */\nexport type PermissionTarget = string | { path: string; data?: unknown } | null | undefined | false;\n\n/**\n * Panel action → permission path. A record (`{ \"endpoint:write\": \"webhooks.manage\" }`) or a\n * function of the full input (to pass the resource as the rule's data).\n */\nexport type PermissionsAuthorizationMap<Action extends string, Resource> =\n | Partial<Record<Action, PermissionTarget>>\n | ((input: AuthorizeInput<Action, Resource>) => PermissionTarget | Promise<PermissionTarget>);\n\n/** Options for {@link permissionsAuthorization}. */\nexport interface PermissionsAuthorizationOptions<Action extends string, Resource> {\n /** Override how a principal becomes a subject (default: see the module doc). */\n subject?(\n principal: Principal,\n input: AuthorizeInput<Action, Resource>,\n ): SubjectIdentity | null | Promise<SubjectIdentity | null>;\n /** The rules' `ctx`, for catalogs that need app facts. */\n ctx?(input: AuthorizeInput<Action, Resource>): unknown;\n}\n\n/**\n * The subject identity of a kit principal: the one `toKitAuth` attached, else the principal's own\n * id, roles, name and email.\n */\nexport function principalIdentity(principal: Principal): SubjectIdentity {\n const attached = subjectOf(principal);\n const out: SubjectIdentity = { id: principal.id, role: principal.roles ?? null };\n if (attached && attached.id === principal.id) {\n out.role = attached.role;\n if (attached.attributes !== undefined) out.attributes = attached.attributes;\n }\n const name = attached?.name ?? principal.name;\n const email = attached?.email ?? principal.email;\n if (name !== undefined) out.name = name;\n if (email !== undefined) out.email = email;\n return out;\n}\n\n/**\n * Build a kit `AuthorizationProvider` that decides another panel's actions with this catalog.\n *\n * @example\n * ```ts\n * import { permissionsAuthorization } from \"@xtandard/permissions/authorization/permissions\";\n * import { createFetchHandler as webhooksPanel } from \"@xtandard/webhooks\";\n *\n * webhooksPanel({\n * auth, // the same kit auth, e.g. toKitAuth(betterAuthProvider(auth), perms).auth\n * authorization: permissionsAuthorization(perms, {\n * \"endpoint:read\": \"webhooks.read\",\n * \"endpoint:write\": \"webhooks.manage\",\n * }),\n * });\n * ```\n */\nexport function permissionsAuthorization<Action extends string = string, Resource = unknown>(\n perms: AnyPermissions,\n map: PermissionsAuthorizationMap<Action, Resource>,\n options: PermissionsAuthorizationOptions<Action, Resource> = {},\n): AuthorizationProvider<Action, Resource> {\n return delegatedAuthorization<Action, Resource>({\n async authorize(input) {\n if (!input.principal) return false;\n const target =\n typeof map === \"function\"\n ? await map(input)\n : Object.hasOwn(map, input.action)\n ? map[input.action]\n : undefined;\n if (!target) return false;\n const { path, data } =\n typeof target === \"string\" ? { path: target, data: undefined } : target;\n const subject = options.subject\n ? await options.subject(input.principal, input)\n : principalIdentity(input.principal);\n if (!subject) return false;\n const facts = options.ctx ? [{ ctx: options.ctx(input) }] : [];\n const ability = await perms.ability(subject, ...(facts as []));\n return (await ability.checkAsync(path, data)).allowed;\n },\n });\n}\n"],"mappings":";;;;;;;AA4CA,SAAgB,kBAAkB,WAAuC;CACvE,MAAM,WAAW,UAAU,SAAS;CACpC,MAAM,MAAuB;EAAE,IAAI,UAAU;EAAI,MAAM,UAAU,SAAS;CAAK;CAC/E,IAAI,YAAY,SAAS,OAAO,UAAU,IAAI;EAC5C,IAAI,OAAO,SAAS;EACpB,IAAI,SAAS,eAAe,KAAA,GAAW,IAAI,aAAa,SAAS;CACnE;CACA,MAAM,OAAO,UAAU,QAAQ,UAAU;CACzC,MAAM,QAAQ,UAAU,SAAS,UAAU;CAC3C,IAAI,SAAS,KAAA,GAAW,IAAI,OAAO;CACnC,IAAI,UAAU,KAAA,GAAW,IAAI,QAAQ;CACrC,OAAO;AACT;;;;;;;;;;;;;;;;;;AAmBA,SAAgB,yBACd,OACA,KACA,UAA6D,CAAC,GACrB;CACzC,OAAO,uBAAyC,EAC9C,MAAM,UAAU,OAAO;EACrB,IAAI,CAAC,MAAM,WAAW,OAAO;EAC7B,MAAM,SACJ,OAAO,QAAQ,aACX,MAAM,IAAI,KAAK,IACf,OAAO,OAAO,KAAK,MAAM,MAAM,IAC7B,IAAI,MAAM,UACV,KAAA;EACR,IAAI,CAAC,QAAQ,OAAO;EACpB,MAAM,EAAE,MAAM,SACZ,OAAO,WAAW,WAAW;GAAE,MAAM;GAAQ,MAAM,KAAA;EAAU,IAAI;EACnE,MAAM,UAAU,QAAQ,UACpB,MAAM,QAAQ,QAAQ,MAAM,WAAW,KAAK,IAC5C,kBAAkB,MAAM,SAAS;EACrC,IAAI,CAAC,SAAS,OAAO;EACrB,MAAM,QAAQ,QAAQ,MAAM,CAAC,EAAE,KAAK,QAAQ,IAAI,KAAK,EAAE,CAAC,IAAI,CAAC;EAE7D,QAAQ,OAAM,MADQ,MAAM,QAAQ,SAAS,GAAI,KAAY,GACvC,WAAW,MAAM,IAAI,GAAG;CAChD,EACF,CAAC;AACH"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
const require_kit = require("./kit-C7tepDB2.cjs");
|
|
2
|
+
let _xtandard_kit_authorization_delegated = require("@xtandard/kit/authorization/delegated");
|
|
3
|
+
//#region src/authorization/permissions.ts
|
|
4
|
+
/**
|
|
5
|
+
* The subject identity of a kit principal: the one `toKitAuth` attached, else the principal's own
|
|
6
|
+
* id, roles, name and email.
|
|
7
|
+
*/
|
|
8
|
+
function principalIdentity(principal) {
|
|
9
|
+
const attached = require_kit.subjectOf(principal);
|
|
10
|
+
const out = {
|
|
11
|
+
id: principal.id,
|
|
12
|
+
role: principal.roles ?? null
|
|
13
|
+
};
|
|
14
|
+
if (attached && attached.id === principal.id) {
|
|
15
|
+
out.role = attached.role;
|
|
16
|
+
if (attached.attributes !== void 0) out.attributes = attached.attributes;
|
|
17
|
+
}
|
|
18
|
+
const name = attached?.name ?? principal.name;
|
|
19
|
+
const email = attached?.email ?? principal.email;
|
|
20
|
+
if (name !== void 0) out.name = name;
|
|
21
|
+
if (email !== void 0) out.email = email;
|
|
22
|
+
return out;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Build a kit `AuthorizationProvider` that decides another panel's actions with this catalog.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* import { permissionsAuthorization } from "@xtandard/permissions/authorization/permissions";
|
|
30
|
+
* import { createFetchHandler as webhooksPanel } from "@xtandard/webhooks";
|
|
31
|
+
*
|
|
32
|
+
* webhooksPanel({
|
|
33
|
+
* auth, // the same kit auth, e.g. toKitAuth(betterAuthProvider(auth), perms).auth
|
|
34
|
+
* authorization: permissionsAuthorization(perms, {
|
|
35
|
+
* "endpoint:read": "webhooks.read",
|
|
36
|
+
* "endpoint:write": "webhooks.manage",
|
|
37
|
+
* }),
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
function permissionsAuthorization(perms, map, options = {}) {
|
|
42
|
+
return (0, _xtandard_kit_authorization_delegated.delegatedAuthorization)({ async authorize(input) {
|
|
43
|
+
if (!input.principal) return false;
|
|
44
|
+
const target = typeof map === "function" ? await map(input) : Object.hasOwn(map, input.action) ? map[input.action] : void 0;
|
|
45
|
+
if (!target) return false;
|
|
46
|
+
const { path, data } = typeof target === "string" ? {
|
|
47
|
+
path: target,
|
|
48
|
+
data: void 0
|
|
49
|
+
} : target;
|
|
50
|
+
const subject = options.subject ? await options.subject(input.principal, input) : principalIdentity(input.principal);
|
|
51
|
+
if (!subject) return false;
|
|
52
|
+
const facts = options.ctx ? [{ ctx: options.ctx(input) }] : [];
|
|
53
|
+
return (await (await perms.ability(subject, ...facts)).checkAsync(path, data)).allowed;
|
|
54
|
+
} });
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
Object.defineProperty(exports, "permissionsAuthorization", {
|
|
58
|
+
enumerable: true,
|
|
59
|
+
get: function() {
|
|
60
|
+
return permissionsAuthorization;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
Object.defineProperty(exports, "principalIdentity", {
|
|
64
|
+
enumerable: true,
|
|
65
|
+
get: function() {
|
|
66
|
+
return principalIdentity;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
//# sourceMappingURL=permissions-Cxri_P_k.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permissions-Cxri_P_k.cjs","names":["subjectOf"],"sources":["../src/authorization/permissions.ts"],"sourcesContent":["/**\n * Authorize **another** xtandard panel (webhooks, flags, audit, entitlements…) with this catalog\n * (ADR 0011): {@link permissionsAuthorization} maps each of that panel's actions to a permission\n * path of your catalog and asks the engine, through the kit's `delegatedAuthorization`.\n *\n * The principal becomes the subject: the identity `toKitAuth` attached (`metadata.subject`) when\n * present, else `{ id, role: principal.roles, name, email }`. An unmapped action is denied.\n *\n * @module\n */\n\nimport type { Principal } from \"@xtandard/kit/auth\";\nimport type { AuthorizationProvider, AuthorizeInput } from \"@xtandard/kit/authorization\";\nimport { delegatedAuthorization } from \"@xtandard/kit/authorization/delegated\";\nimport { subjectOf } from \"../auth-provider/kit.ts\";\nimport type { SubjectIdentity } from \"../catalog.ts\";\nimport type { AnyPermissions } from \"../engine.ts\";\n\n/** What one panel action maps to: a path, a path plus the data its rule reads, or deny. */\nexport type PermissionTarget = string | { path: string; data?: unknown } | null | undefined | false;\n\n/**\n * Panel action → permission path. A record (`{ \"endpoint:write\": \"webhooks.manage\" }`) or a\n * function of the full input (to pass the resource as the rule's data).\n */\nexport type PermissionsAuthorizationMap<Action extends string, Resource> =\n | Partial<Record<Action, PermissionTarget>>\n | ((input: AuthorizeInput<Action, Resource>) => PermissionTarget | Promise<PermissionTarget>);\n\n/** Options for {@link permissionsAuthorization}. */\nexport interface PermissionsAuthorizationOptions<Action extends string, Resource> {\n /** Override how a principal becomes a subject (default: see the module doc). */\n subject?(\n principal: Principal,\n input: AuthorizeInput<Action, Resource>,\n ): SubjectIdentity | null | Promise<SubjectIdentity | null>;\n /** The rules' `ctx`, for catalogs that need app facts. */\n ctx?(input: AuthorizeInput<Action, Resource>): unknown;\n}\n\n/**\n * The subject identity of a kit principal: the one `toKitAuth` attached, else the principal's own\n * id, roles, name and email.\n */\nexport function principalIdentity(principal: Principal): SubjectIdentity {\n const attached = subjectOf(principal);\n const out: SubjectIdentity = { id: principal.id, role: principal.roles ?? null };\n if (attached && attached.id === principal.id) {\n out.role = attached.role;\n if (attached.attributes !== undefined) out.attributes = attached.attributes;\n }\n const name = attached?.name ?? principal.name;\n const email = attached?.email ?? principal.email;\n if (name !== undefined) out.name = name;\n if (email !== undefined) out.email = email;\n return out;\n}\n\n/**\n * Build a kit `AuthorizationProvider` that decides another panel's actions with this catalog.\n *\n * @example\n * ```ts\n * import { permissionsAuthorization } from \"@xtandard/permissions/authorization/permissions\";\n * import { createFetchHandler as webhooksPanel } from \"@xtandard/webhooks\";\n *\n * webhooksPanel({\n * auth, // the same kit auth, e.g. toKitAuth(betterAuthProvider(auth), perms).auth\n * authorization: permissionsAuthorization(perms, {\n * \"endpoint:read\": \"webhooks.read\",\n * \"endpoint:write\": \"webhooks.manage\",\n * }),\n * });\n * ```\n */\nexport function permissionsAuthorization<Action extends string = string, Resource = unknown>(\n perms: AnyPermissions,\n map: PermissionsAuthorizationMap<Action, Resource>,\n options: PermissionsAuthorizationOptions<Action, Resource> = {},\n): AuthorizationProvider<Action, Resource> {\n return delegatedAuthorization<Action, Resource>({\n async authorize(input) {\n if (!input.principal) return false;\n const target =\n typeof map === \"function\"\n ? await map(input)\n : Object.hasOwn(map, input.action)\n ? map[input.action]\n : undefined;\n if (!target) return false;\n const { path, data } =\n typeof target === \"string\" ? { path: target, data: undefined } : target;\n const subject = options.subject\n ? await options.subject(input.principal, input)\n : principalIdentity(input.principal);\n if (!subject) return false;\n const facts = options.ctx ? [{ ctx: options.ctx(input) }] : [];\n const ability = await perms.ability(subject, ...(facts as []));\n return (await ability.checkAsync(path, data)).allowed;\n },\n });\n}\n"],"mappings":";;;;;;;AA4CA,SAAgB,kBAAkB,WAAuC;CACvE,MAAM,WAAWA,YAAAA,UAAU,SAAS;CACpC,MAAM,MAAuB;EAAE,IAAI,UAAU;EAAI,MAAM,UAAU,SAAS;CAAK;CAC/E,IAAI,YAAY,SAAS,OAAO,UAAU,IAAI;EAC5C,IAAI,OAAO,SAAS;EACpB,IAAI,SAAS,eAAe,KAAA,GAAW,IAAI,aAAa,SAAS;CACnE;CACA,MAAM,OAAO,UAAU,QAAQ,UAAU;CACzC,MAAM,QAAQ,UAAU,SAAS,UAAU;CAC3C,IAAI,SAAS,KAAA,GAAW,IAAI,OAAO;CACnC,IAAI,UAAU,KAAA,GAAW,IAAI,QAAQ;CACrC,OAAO;AACT;;;;;;;;;;;;;;;;;;AAmBA,SAAgB,yBACd,OACA,KACA,UAA6D,CAAC,GACrB;CACzC,QAAA,GAAA,sCAAA,wBAAgD,EAC9C,MAAM,UAAU,OAAO;EACrB,IAAI,CAAC,MAAM,WAAW,OAAO;EAC7B,MAAM,SACJ,OAAO,QAAQ,aACX,MAAM,IAAI,KAAK,IACf,OAAO,OAAO,KAAK,MAAM,MAAM,IAC7B,IAAI,MAAM,UACV,KAAA;EACR,IAAI,CAAC,QAAQ,OAAO;EACpB,MAAM,EAAE,MAAM,SACZ,OAAO,WAAW,WAAW;GAAE,MAAM;GAAQ,MAAM,KAAA;EAAU,IAAI;EACnE,MAAM,UAAU,QAAQ,UACpB,MAAM,QAAQ,QAAQ,MAAM,WAAW,KAAK,IAC5C,kBAAkB,MAAM,SAAS;EACrC,IAAI,CAAC,SAAS,OAAO;EACrB,MAAM,QAAQ,QAAQ,MAAM,CAAC,EAAE,KAAK,QAAQ,IAAI,KAAK,EAAE,CAAC,IAAI,CAAC;EAE7D,QAAQ,OAAM,MADQ,MAAM,QAAQ,SAAS,GAAI,KAAY,GACvC,WAAW,MAAM,IAAI,GAAG;CAChD,EACF,CAAC;AACH"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { AsyncRuleError, checkRulesAtPath, defineAuthorization, hasAssignedPermission, hasPermission, toPermissionSet } from "@xtandard/lib/policy/permix";
|
|
2
|
+
import { RelationDepthError, RelationSchemaError, computed, createMemoryTuples, createRelationChecker, defineRelations, direct, exclusion, from, hasRelation, intersection, isAllowedTuple, relationEdges, union } from "@xtandard/lib/policy/rebac";
|
|
3
|
+
export { isAllowedTuple as _, computed as a, union as b, defineAuthorization as c, exclusion as d, from as f, intersection as g, hasRelation as h, checkRulesAtPath as i, defineRelations as l, hasPermission as m, RelationDepthError as n, createMemoryTuples as o, hasAssignedPermission as p, RelationSchemaError as r, createRelationChecker as s, AsyncRuleError as t, direct as u, relationEdges as v, toPermissionSet as y };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Ability, AsyncRuleError, Authorization, AuthorizationConfig, CheckExplanation, Definition, PermissionPath, RuleContext, RuleHelpers, Rules, RulesPaths, checkRulesAtPath, hasAssignedPermission, hasPermission, toPermissionSet } from "@xtandard/lib/policy/permix";
|
|
2
|
+
import { ObjectRef, RelationDepthError, RelationExplanation, RelationExpr, RelationSchema, RelationSchemaError, RelationTuple, SubjectRef, TupleReadContext, computed, defineRelations, direct, exclusion, from, intersection, union } from "@xtandard/lib/policy/rebac";
|
|
3
|
+
import { DataAtPath } from "permix";
|
|
4
|
+
export { intersection as A, computed as C, from as D, exclusion as E, union as M, hasAssignedPermission as O, checkRulesAtPath as S, direct as T, RuleHelpers as _, CheckExplanation as a, SubjectRef as b, ObjectRef as c, RelationExplanation as d, RelationExpr as f, RuleContext as g, RelationTuple as h, AuthorizationConfig as i, toPermissionSet as j, hasPermission as k, PermissionPath as l, RelationSchemaError as m, AsyncRuleError as n, DataAtPath as o, RelationSchema as p, Authorization as r, Definition as s, Ability as t, RelationDepthError as u, Rules as v, defineRelations as w, TupleReadContext as x, RulesPaths as y };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Ability, AsyncRuleError, Authorization, AuthorizationConfig, CheckExplanation, Definition, PermissionPath, RuleContext, RuleHelpers, Rules, RulesPaths, checkRulesAtPath, hasAssignedPermission, hasPermission, toPermissionSet } from "@xtandard/lib/policy/permix";
|
|
2
|
+
import { DataAtPath } from "permix";
|
|
3
|
+
import { ObjectRef, RelationDepthError, RelationExplanation, RelationExpr, RelationSchema, RelationSchemaError, RelationTuple, SubjectRef, TupleReadContext, computed, defineRelations, direct, exclusion, from, intersection, union } from "@xtandard/lib/policy/rebac";
|
|
4
|
+
export { intersection as A, computed as C, from as D, exclusion as E, union as M, hasAssignedPermission as O, checkRulesAtPath as S, direct as T, RuleHelpers as _, CheckExplanation as a, SubjectRef as b, ObjectRef as c, RelationExplanation as d, RelationExpr as f, RuleContext as g, RelationTuple as h, AuthorizationConfig as i, toPermissionSet as j, hasPermission as k, PermissionPath as l, RelationSchemaError as m, AsyncRuleError as n, DataAtPath as o, RelationSchema as p, Authorization as r, Definition as s, Ability as t, RelationDepthError as u, Rules as v, defineRelations as w, TupleReadContext as x, RulesPaths as y };
|