@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/testing.cjs
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_engine = require("./engine-bMoz3iW-.cjs");
|
|
3
|
+
const require_memory = require("./memory-knijqKw_.cjs");
|
|
4
|
+
//#region src/testing.ts
|
|
5
|
+
/**
|
|
6
|
+
* Test helpers: an engine on in-memory storage with a controllable clock, so
|
|
7
|
+
* tests can cross grant expiries deterministically, plus every `after` hook
|
|
8
|
+
* event in order.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { createTestPermissions } from "@xtandard/permissions/testing";
|
|
13
|
+
*
|
|
14
|
+
* const { perms, clock, events } = createTestPermissions({ catalog, now: "2026-12-01T00:00:00Z" });
|
|
15
|
+
* await perms.grant({ subject: "u1", permission: "post:moderate", expiresAt: "2026-12-01T01:00:00Z" });
|
|
16
|
+
* clock.advance(2 * 60 * 60 * 1000); // the grant has expired
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @module testing
|
|
20
|
+
*/
|
|
21
|
+
/** Create a {@link TestClock} starting at `start` (default: real now). */
|
|
22
|
+
function createTestClock(start = Date.now()) {
|
|
23
|
+
let t = typeof start === "string" ? Date.parse(start) : start;
|
|
24
|
+
return {
|
|
25
|
+
now: () => t,
|
|
26
|
+
set: (at) => {
|
|
27
|
+
t = typeof at === "string" ? Date.parse(at) : at;
|
|
28
|
+
},
|
|
29
|
+
advance: (ms) => {
|
|
30
|
+
t += ms;
|
|
31
|
+
},
|
|
32
|
+
iso: () => new Date(t).toISOString()
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* An engine on in-memory storage (unless `storage` is given) with a test clock and the cache
|
|
37
|
+
* off, collecting `after` hook events. User hooks still run.
|
|
38
|
+
*/
|
|
39
|
+
function createTestPermissions(options) {
|
|
40
|
+
const clock = createTestClock(options.now);
|
|
41
|
+
const events = [];
|
|
42
|
+
const userHooks = options.hooks ? Array.isArray(options.hooks) ? options.hooks : [options.hooks] : [];
|
|
43
|
+
return {
|
|
44
|
+
perms: require_engine.createPermissions({
|
|
45
|
+
cache: false,
|
|
46
|
+
...options,
|
|
47
|
+
storage: options.storage ?? require_memory.createMemoryStorage(),
|
|
48
|
+
now: clock.now,
|
|
49
|
+
hooks: [...userHooks, { after: (e) => void events.push(e) }]
|
|
50
|
+
}),
|
|
51
|
+
clock,
|
|
52
|
+
events
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
//#endregion
|
|
56
|
+
exports.createTestClock = createTestClock;
|
|
57
|
+
exports.createTestPermissions = createTestPermissions;
|
|
58
|
+
|
|
59
|
+
//# sourceMappingURL=testing.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.cjs","names":["createPermissions","createMemoryStorage"],"sources":["../src/testing.ts"],"sourcesContent":["/**\n * Test helpers: an engine on in-memory storage with a controllable clock, so\n * tests can cross grant expiries deterministically, plus every `after` hook\n * event in order.\n *\n * @example\n * ```ts\n * import { createTestPermissions } from \"@xtandard/permissions/testing\";\n *\n * const { perms, clock, events } = createTestPermissions({ catalog, now: \"2026-12-01T00:00:00Z\" });\n * await perms.grant({ subject: \"u1\", permission: \"post:moderate\", expiresAt: \"2026-12-01T01:00:00Z\" });\n * clock.advance(2 * 60 * 60 * 1000); // the grant has expired\n * ```\n *\n * @module testing\n */\n\nimport { createPermissions, type Permissions, type PermissionsOptions } from \"./engine.ts\";\nimport type { AfterEvent } from \"./hooks/contract.ts\";\nimport type { Definition } from \"./policy.ts\";\nimport { createMemoryStorage } from \"./storage/memory.ts\";\n\n/** A controllable clock. */\nexport interface TestClock {\n /** Current time (unix ms) — pass as `now`. */\n now(): number;\n /** Set the time (ISO string or unix ms). */\n set(at: string | number): void;\n /** Move forward by `ms`. */\n advance(ms: number): void;\n /** Current time as ISO. */\n iso(): string;\n}\n\n/** Create a {@link TestClock} starting at `start` (default: real now). */\nexport function createTestClock(start: string | number = Date.now()): TestClock {\n let t = typeof start === \"string\" ? Date.parse(start) : start;\n return {\n now: () => t,\n set: (at) => {\n t = typeof at === \"string\" ? Date.parse(at) : at;\n },\n advance: (ms) => {\n t += ms;\n },\n iso: () => new Date(t).toISOString(),\n };\n}\n\n/** Options for {@link createTestPermissions}: the engine's, with `storage` optional. */\nexport type TestPermissionsOptions<\n D extends Definition,\n R extends string,\n P extends string,\n X,\n> = Omit<PermissionsOptions<D, R, P, X>, \"now\" | \"storage\"> &\n Partial<Pick<PermissionsOptions<D, R, P, X>, \"storage\">> & {\n /** Start time. Default: real now. */\n now?: string | number;\n };\n\n/** What {@link createTestPermissions} returns. */\nexport interface TestPermissions<D extends Definition, R extends string, P extends string, X> {\n perms: Permissions<D, R, P, X>;\n clock: TestClock;\n /** Every `after` hook event, in order. */\n events: AfterEvent[];\n}\n\n/**\n * An engine on in-memory storage (unless `storage` is given) with a test clock and the cache\n * off, collecting `after` hook events. User hooks still run.\n */\nexport function createTestPermissions<D extends Definition, R extends string, P extends string, X>(\n options: TestPermissionsOptions<D, R, P, X>,\n): TestPermissions<D, R, P, X> {\n const clock = createTestClock(options.now);\n const events: AfterEvent[] = [];\n const userHooks = options.hooks\n ? Array.isArray(options.hooks)\n ? options.hooks\n : [options.hooks]\n : [];\n const perms = createPermissions<D, R, P, X>({\n cache: false,\n ...options,\n storage: options.storage ?? createMemoryStorage(),\n now: clock.now,\n hooks: [...userHooks, { after: (e: AfterEvent) => void events.push(e) }],\n });\n return { perms, clock, events };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAmCA,SAAgB,gBAAgB,QAAyB,KAAK,IAAI,GAAc;CAC9E,IAAI,IAAI,OAAO,UAAU,WAAW,KAAK,MAAM,KAAK,IAAI;CACxD,OAAO;EACL,WAAW;EACX,MAAM,OAAO;GACX,IAAI,OAAO,OAAO,WAAW,KAAK,MAAM,EAAE,IAAI;EAChD;EACA,UAAU,OAAO;GACf,KAAK;EACP;EACA,WAAW,IAAI,KAAK,CAAC,EAAE,YAAY;CACrC;AACF;;;;;AA0BA,SAAgB,sBACd,SAC6B;CAC7B,MAAM,QAAQ,gBAAgB,QAAQ,GAAG;CACzC,MAAM,SAAuB,CAAC;CAC9B,MAAM,YAAY,QAAQ,QACtB,MAAM,QAAQ,QAAQ,KAAK,IACzB,QAAQ,QACR,CAAC,QAAQ,KAAK,IAChB,CAAC;CAQL,OAAO;EAAE,OAPKA,eAAAA,kBAA8B;GAC1C,OAAO;GACP,GAAG;GACH,SAAS,QAAQ,WAAWC,eAAAA,oBAAoB;GAChD,KAAK,MAAM;GACX,OAAO,CAAC,GAAG,WAAW,EAAE,QAAQ,MAAkB,KAAK,OAAO,KAAK,CAAC,EAAE,CAAC;EACzE,CACa;EAAG;EAAO;CAAO;AAChC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { s as Definition } from "./policy-DFq_SYR3.cjs";
|
|
2
|
+
import { t as AfterEvent } from "./contract-Dk6d2ylD.cjs";
|
|
3
|
+
import { i as Permissions, o as PermissionsOptions } from "./engine-CGGVDCqi.cjs";
|
|
4
|
+
|
|
5
|
+
//#region src/testing.d.ts
|
|
6
|
+
/** A controllable clock. */
|
|
7
|
+
interface TestClock {
|
|
8
|
+
/** Current time (unix ms) — pass as `now`. */
|
|
9
|
+
now(): number;
|
|
10
|
+
/** Set the time (ISO string or unix ms). */
|
|
11
|
+
set(at: string | number): void;
|
|
12
|
+
/** Move forward by `ms`. */
|
|
13
|
+
advance(ms: number): void;
|
|
14
|
+
/** Current time as ISO. */
|
|
15
|
+
iso(): string;
|
|
16
|
+
}
|
|
17
|
+
/** Create a {@link TestClock} starting at `start` (default: real now). */
|
|
18
|
+
declare function createTestClock(start?: string | number): TestClock;
|
|
19
|
+
/** Options for {@link createTestPermissions}: the engine's, with `storage` optional. */
|
|
20
|
+
type TestPermissionsOptions<D extends Definition, R extends string, P extends string, X> = Omit<PermissionsOptions<D, R, P, X>, "now" | "storage"> & Partial<Pick<PermissionsOptions<D, R, P, X>, "storage">> & {
|
|
21
|
+
/** Start time. Default: real now. */now?: string | number;
|
|
22
|
+
};
|
|
23
|
+
/** What {@link createTestPermissions} returns. */
|
|
24
|
+
interface TestPermissions<D extends Definition, R extends string, P extends string, X> {
|
|
25
|
+
perms: Permissions<D, R, P, X>;
|
|
26
|
+
clock: TestClock;
|
|
27
|
+
/** Every `after` hook event, in order. */
|
|
28
|
+
events: AfterEvent[];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* An engine on in-memory storage (unless `storage` is given) with a test clock and the cache
|
|
32
|
+
* off, collecting `after` hook events. User hooks still run.
|
|
33
|
+
*/
|
|
34
|
+
declare function createTestPermissions<D extends Definition, R extends string, P extends string, X>(options: TestPermissionsOptions<D, R, P, X>): TestPermissions<D, R, P, X>;
|
|
35
|
+
//#endregion
|
|
36
|
+
export { TestClock, TestPermissions, TestPermissionsOptions, createTestClock, createTestPermissions };
|
|
37
|
+
//# sourceMappingURL=testing.d.cts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { s as Definition } from "./policy-CGA6QD0a.mjs";
|
|
2
|
+
import { t as AfterEvent } from "./contract-DUzgB-He.mjs";
|
|
3
|
+
import { i as Permissions, o as PermissionsOptions } from "./engine-DpFIcbgh.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/testing.d.ts
|
|
6
|
+
/** A controllable clock. */
|
|
7
|
+
interface TestClock {
|
|
8
|
+
/** Current time (unix ms) — pass as `now`. */
|
|
9
|
+
now(): number;
|
|
10
|
+
/** Set the time (ISO string or unix ms). */
|
|
11
|
+
set(at: string | number): void;
|
|
12
|
+
/** Move forward by `ms`. */
|
|
13
|
+
advance(ms: number): void;
|
|
14
|
+
/** Current time as ISO. */
|
|
15
|
+
iso(): string;
|
|
16
|
+
}
|
|
17
|
+
/** Create a {@link TestClock} starting at `start` (default: real now). */
|
|
18
|
+
declare function createTestClock(start?: string | number): TestClock;
|
|
19
|
+
/** Options for {@link createTestPermissions}: the engine's, with `storage` optional. */
|
|
20
|
+
type TestPermissionsOptions<D extends Definition, R extends string, P extends string, X> = Omit<PermissionsOptions<D, R, P, X>, "now" | "storage"> & Partial<Pick<PermissionsOptions<D, R, P, X>, "storage">> & {
|
|
21
|
+
/** Start time. Default: real now. */now?: string | number;
|
|
22
|
+
};
|
|
23
|
+
/** What {@link createTestPermissions} returns. */
|
|
24
|
+
interface TestPermissions<D extends Definition, R extends string, P extends string, X> {
|
|
25
|
+
perms: Permissions<D, R, P, X>;
|
|
26
|
+
clock: TestClock;
|
|
27
|
+
/** Every `after` hook event, in order. */
|
|
28
|
+
events: AfterEvent[];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* An engine on in-memory storage (unless `storage` is given) with a test clock and the cache
|
|
32
|
+
* off, collecting `after` hook events. User hooks still run.
|
|
33
|
+
*/
|
|
34
|
+
declare function createTestPermissions<D extends Definition, R extends string, P extends string, X>(options: TestPermissionsOptions<D, R, P, X>): TestPermissions<D, R, P, X>;
|
|
35
|
+
//#endregion
|
|
36
|
+
export { TestClock, TestPermissions, TestPermissionsOptions, createTestClock, createTestPermissions };
|
|
37
|
+
//# sourceMappingURL=testing.d.mts.map
|
package/dist/testing.mjs
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { t as createPermissions } from "./engine-Bufv0TbD.mjs";
|
|
2
|
+
import { t as createMemoryStorage } from "./memory-BbBbbY8-.mjs";
|
|
3
|
+
//#region src/testing.ts
|
|
4
|
+
/**
|
|
5
|
+
* Test helpers: an engine on in-memory storage with a controllable clock, so
|
|
6
|
+
* tests can cross grant expiries deterministically, plus every `after` hook
|
|
7
|
+
* event in order.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { createTestPermissions } from "@xtandard/permissions/testing";
|
|
12
|
+
*
|
|
13
|
+
* const { perms, clock, events } = createTestPermissions({ catalog, now: "2026-12-01T00:00:00Z" });
|
|
14
|
+
* await perms.grant({ subject: "u1", permission: "post:moderate", expiresAt: "2026-12-01T01:00:00Z" });
|
|
15
|
+
* clock.advance(2 * 60 * 60 * 1000); // the grant has expired
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @module testing
|
|
19
|
+
*/
|
|
20
|
+
/** Create a {@link TestClock} starting at `start` (default: real now). */
|
|
21
|
+
function createTestClock(start = Date.now()) {
|
|
22
|
+
let t = typeof start === "string" ? Date.parse(start) : start;
|
|
23
|
+
return {
|
|
24
|
+
now: () => t,
|
|
25
|
+
set: (at) => {
|
|
26
|
+
t = typeof at === "string" ? Date.parse(at) : at;
|
|
27
|
+
},
|
|
28
|
+
advance: (ms) => {
|
|
29
|
+
t += ms;
|
|
30
|
+
},
|
|
31
|
+
iso: () => new Date(t).toISOString()
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* An engine on in-memory storage (unless `storage` is given) with a test clock and the cache
|
|
36
|
+
* off, collecting `after` hook events. User hooks still run.
|
|
37
|
+
*/
|
|
38
|
+
function createTestPermissions(options) {
|
|
39
|
+
const clock = createTestClock(options.now);
|
|
40
|
+
const events = [];
|
|
41
|
+
const userHooks = options.hooks ? Array.isArray(options.hooks) ? options.hooks : [options.hooks] : [];
|
|
42
|
+
return {
|
|
43
|
+
perms: createPermissions({
|
|
44
|
+
cache: false,
|
|
45
|
+
...options,
|
|
46
|
+
storage: options.storage ?? createMemoryStorage(),
|
|
47
|
+
now: clock.now,
|
|
48
|
+
hooks: [...userHooks, { after: (e) => void events.push(e) }]
|
|
49
|
+
}),
|
|
50
|
+
clock,
|
|
51
|
+
events
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
export { createTestClock, createTestPermissions };
|
|
56
|
+
|
|
57
|
+
//# sourceMappingURL=testing.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.mjs","names":[],"sources":["../src/testing.ts"],"sourcesContent":["/**\n * Test helpers: an engine on in-memory storage with a controllable clock, so\n * tests can cross grant expiries deterministically, plus every `after` hook\n * event in order.\n *\n * @example\n * ```ts\n * import { createTestPermissions } from \"@xtandard/permissions/testing\";\n *\n * const { perms, clock, events } = createTestPermissions({ catalog, now: \"2026-12-01T00:00:00Z\" });\n * await perms.grant({ subject: \"u1\", permission: \"post:moderate\", expiresAt: \"2026-12-01T01:00:00Z\" });\n * clock.advance(2 * 60 * 60 * 1000); // the grant has expired\n * ```\n *\n * @module testing\n */\n\nimport { createPermissions, type Permissions, type PermissionsOptions } from \"./engine.ts\";\nimport type { AfterEvent } from \"./hooks/contract.ts\";\nimport type { Definition } from \"./policy.ts\";\nimport { createMemoryStorage } from \"./storage/memory.ts\";\n\n/** A controllable clock. */\nexport interface TestClock {\n /** Current time (unix ms) — pass as `now`. */\n now(): number;\n /** Set the time (ISO string or unix ms). */\n set(at: string | number): void;\n /** Move forward by `ms`. */\n advance(ms: number): void;\n /** Current time as ISO. */\n iso(): string;\n}\n\n/** Create a {@link TestClock} starting at `start` (default: real now). */\nexport function createTestClock(start: string | number = Date.now()): TestClock {\n let t = typeof start === \"string\" ? Date.parse(start) : start;\n return {\n now: () => t,\n set: (at) => {\n t = typeof at === \"string\" ? Date.parse(at) : at;\n },\n advance: (ms) => {\n t += ms;\n },\n iso: () => new Date(t).toISOString(),\n };\n}\n\n/** Options for {@link createTestPermissions}: the engine's, with `storage` optional. */\nexport type TestPermissionsOptions<\n D extends Definition,\n R extends string,\n P extends string,\n X,\n> = Omit<PermissionsOptions<D, R, P, X>, \"now\" | \"storage\"> &\n Partial<Pick<PermissionsOptions<D, R, P, X>, \"storage\">> & {\n /** Start time. Default: real now. */\n now?: string | number;\n };\n\n/** What {@link createTestPermissions} returns. */\nexport interface TestPermissions<D extends Definition, R extends string, P extends string, X> {\n perms: Permissions<D, R, P, X>;\n clock: TestClock;\n /** Every `after` hook event, in order. */\n events: AfterEvent[];\n}\n\n/**\n * An engine on in-memory storage (unless `storage` is given) with a test clock and the cache\n * off, collecting `after` hook events. User hooks still run.\n */\nexport function createTestPermissions<D extends Definition, R extends string, P extends string, X>(\n options: TestPermissionsOptions<D, R, P, X>,\n): TestPermissions<D, R, P, X> {\n const clock = createTestClock(options.now);\n const events: AfterEvent[] = [];\n const userHooks = options.hooks\n ? Array.isArray(options.hooks)\n ? options.hooks\n : [options.hooks]\n : [];\n const perms = createPermissions<D, R, P, X>({\n cache: false,\n ...options,\n storage: options.storage ?? createMemoryStorage(),\n now: clock.now,\n hooks: [...userHooks, { after: (e: AfterEvent) => void events.push(e) }],\n });\n return { perms, clock, events };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmCA,SAAgB,gBAAgB,QAAyB,KAAK,IAAI,GAAc;CAC9E,IAAI,IAAI,OAAO,UAAU,WAAW,KAAK,MAAM,KAAK,IAAI;CACxD,OAAO;EACL,WAAW;EACX,MAAM,OAAO;GACX,IAAI,OAAO,OAAO,WAAW,KAAK,MAAM,EAAE,IAAI;EAChD;EACA,UAAU,OAAO;GACf,KAAK;EACP;EACA,WAAW,IAAI,KAAK,CAAC,EAAE,YAAY;CACrC;AACF;;;;;AA0BA,SAAgB,sBACd,SAC6B;CAC7B,MAAM,QAAQ,gBAAgB,QAAQ,GAAG;CACzC,MAAM,SAAuB,CAAC;CAC9B,MAAM,YAAY,QAAQ,QACtB,MAAM,QAAQ,QAAQ,KAAK,IACzB,QAAQ,QACR,CAAC,QAAQ,KAAK,IAChB,CAAC;CAQL,OAAO;EAAE,OAPK,kBAA8B;GAC1C,OAAO;GACP,GAAG;GACH,SAAS,QAAQ,WAAW,oBAAoB;GAChD,KAAK,MAAM;GACX,OAAO,CAAC,GAAG,WAAW,EAAE,QAAQ,MAAkB,KAAK,OAAO,KAAK,CAAC,EAAE,CAAC;EACzE,CACa;EAAG;EAAO;CAAO;AAChC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Elysia-version-agnostic pieces shared by the 1.x (`./elysia.ts`) and 2.x (`./elysia2.ts`)
|
|
3
|
+
* adapters. Must not import `elysia`: each adapter's types are built against a different major.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { type PassContext } from "@xtandard/kit/adapters/elysia";
|
|
8
|
+
import type { AnyPermissions } from "../engine.ts";
|
|
9
|
+
import type { Definition } from "../policy.ts";
|
|
10
|
+
import type { CheckResult } from "../schema.ts";
|
|
11
|
+
import { type CreateFetchHandlerResult, type PermissionsPanelOptions } from "../server/create-fetch-handler.ts";
|
|
12
|
+
import { type RelationDecision, type RelationObjectInput, type RequireRelationOptions, type PathOf, type RequirePermissionOptions } from "./guard.ts";
|
|
13
|
+
/** A web-standard fetch handler with `engine` + `openapi()` attached. */
|
|
14
|
+
export interface ElysiaPermissionsHandler<D extends Definition = Definition, R extends string = string, P extends string = string, X = undefined> {
|
|
15
|
+
/** Handle a request (what `Elysia.mount(path, handler)` calls). */
|
|
16
|
+
(request: Request): Promise<Response>;
|
|
17
|
+
/** The engine (given or constructed). */
|
|
18
|
+
engine: CreateFetchHandlerResult<D, R, P, X>["engine"];
|
|
19
|
+
/** The HTTP API as an OpenAPI 3.1 document. */
|
|
20
|
+
openapi(): Record<string, unknown>;
|
|
21
|
+
/** Stop the panel's background work. */
|
|
22
|
+
close(): void;
|
|
23
|
+
}
|
|
24
|
+
/** Create a panel handler suitable for `Elysia.mount(path, handler)`. */
|
|
25
|
+
export declare function permissionsPanel<D extends Definition = Definition, R extends string = string, P extends string = string, X = undefined>(options: PermissionsPanelOptions<D, R, P, X>): ElysiaPermissionsHandler<D, R, P, X>;
|
|
26
|
+
/** Options for `permissionsElysia`. */
|
|
27
|
+
export interface PermissionsElysiaOptions<D extends Definition = Definition, R extends string = string, P extends string = string, X = undefined> extends PermissionsPanelOptions<D, R, P, X> {
|
|
28
|
+
/** Mount prefix; also the panel basePath. Default `"/permissions"`. */
|
|
29
|
+
prefix?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The handlers every declared route delegates to. Elysia parses the body of declared routes
|
|
33
|
+
* (draining the stream); `pass` rebuilds the Request from the parsed body before delegating.
|
|
34
|
+
*/
|
|
35
|
+
export declare function createPass(options: PermissionsElysiaOptions): {
|
|
36
|
+
prefix: string;
|
|
37
|
+
handler: CreateFetchHandlerResult;
|
|
38
|
+
pass: (ctx: PassContext) => Promise<Response>;
|
|
39
|
+
};
|
|
40
|
+
/** The minimal Elysia context the guard reads / writes (both majors). */
|
|
41
|
+
export interface ElysiaGuardContext {
|
|
42
|
+
request: Request;
|
|
43
|
+
/** Set by the guard to the allowing decision. */
|
|
44
|
+
permission?: CheckResult;
|
|
45
|
+
/** Set by `requireRelation` to the allowing relationship decision. */
|
|
46
|
+
relation?: RelationDecision;
|
|
47
|
+
[key: string]: unknown;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* An Elysia `beforeHandle` guard (1.x and 2.x): `401` / `403` JSON for denials; for an allowed
|
|
51
|
+
* request it sets `ctx.permission` and lets the handler run.
|
|
52
|
+
*
|
|
53
|
+
* ```ts
|
|
54
|
+
* app.post("/refund", ({ permission }) => ({ ok: true }), {
|
|
55
|
+
* beforeHandle: requirePermission(perms, "billing.refund", { provider }),
|
|
56
|
+
* });
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare function requirePermission<E extends AnyPermissions, Ctx extends ElysiaGuardContext = ElysiaGuardContext>(engine: E, path: PathOf<E>, options: RequirePermissionOptions<Ctx>): (ctx: Ctx) => Promise<Response | undefined>;
|
|
60
|
+
/**
|
|
61
|
+
* An Elysia `beforeHandle` guard (1.x and 2.x) for a relationship (ReBAC): the caller
|
|
62
|
+
* (`user:{id}` unless `subjectRef`) must have `relation` on the object; sets `ctx.relation`.
|
|
63
|
+
*
|
|
64
|
+
* ```ts
|
|
65
|
+
* app.put("/docs/:id", handler, {
|
|
66
|
+
* beforeHandle: requireRelation(perms, "editor", (c) => `doc:${c.params.id}`, { provider }),
|
|
67
|
+
* });
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export declare function requireRelation<E extends AnyPermissions, Ctx extends ElysiaGuardContext = ElysiaGuardContext>(engine: E, relation: string, object: RelationObjectInput<Ctx>, options: RequireRelationOptions<Ctx>): (ctx: Ctx) => Promise<Response | undefined>;
|
|
71
|
+
export type { PermissionsPanelOptions, RelationDecision, RelationObjectInput, RequirePermissionOptions, RequireRelationOptions, };
|