permdock 0.0.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +327 -1
- package/dist/a2a/index.d.ts +169 -0
- package/dist/a2a/index.js +232 -0
- package/dist/adapter-context-mlWsVGGg.js +23 -0
- package/dist/ai-sdk/index.d.ts +95 -0
- package/dist/ai-sdk/index.js +154 -0
- package/dist/approval-required-TzNB9oQA.js +6 -0
- package/dist/approvals/index.d.ts +3 -0
- package/dist/approvals/index.js +5 -0
- package/dist/approvals-DbYAuNkG.js +224 -0
- package/dist/approvers-DT4AVyIg.js +52 -0
- package/dist/arazzo-BAgw9ap6.js +70 -0
- package/dist/arazzo-cmvX2jDe.js +54 -0
- package/dist/authzen/index.d.ts +39 -0
- package/dist/authzen/index.js +302 -0
- package/dist/better-auth/index.d.ts +109 -0
- package/dist/better-auth/index.js +344 -0
- package/dist/better-supabase/index.d.ts +206 -0
- package/dist/better-supabase/index.js +620 -0
- package/dist/bind-CVy3Espv.d.ts +25 -0
- package/dist/bind-VnYn2HKq.js +97 -0
- package/dist/boundary-BM8a_P6E.js +13 -0
- package/dist/boundary-BmHxVH1J.d.ts +15 -0
- package/dist/budget-JqcRqyhK.d.ts +11 -0
- package/dist/budget-NbEtbJC_.js +11 -0
- package/dist/canonical-json-DemiK4Vp.js +26 -0
- package/dist/capability-4qPdO9gk.js +173 -0
- package/dist/capability-Dq43tT1u.d.ts +99 -0
- package/dist/catalog/index.d.ts +12 -0
- package/dist/catalog/index.js +2 -0
- package/dist/catalog-BjZSovXQ.js +2 -0
- package/dist/catalog-doc-Dsc9y7sd.js +309 -0
- package/dist/catalog-h2tlKFkq.js +48 -0
- package/dist/catalog-path-CnI0XTFK.js +12 -0
- package/dist/catalog-z8q6bi_r.js +55 -0
- package/dist/claude-agent/index.d.ts +72 -0
- package/dist/claude-agent/index.js +77 -0
- package/dist/clerk/index.d.ts +65 -0
- package/dist/clerk/index.js +301 -0
- package/dist/cli/bin.d.ts +1 -0
- package/dist/cli/bin.js +20 -0
- package/dist/cli/index.d.ts +46 -0
- package/dist/cli/index.js +5 -0
- package/dist/clients-C7zLFuWT.d.ts +12 -0
- package/dist/clients-DjU5ABMy.js +23 -0
- package/dist/cloud/index.d.ts +90 -0
- package/dist/cloud/index.js +404 -0
- package/dist/cloud-BGhHS-lY.js +50 -0
- package/dist/cloud-Bo3e9Ak3.js +118 -0
- package/dist/collect-DDDv_ESs.js +502 -0
- package/dist/collect-DLlujdHC.js +83 -0
- package/dist/collect-rG2IQ3t0.js +2 -0
- package/dist/commands-DWOrSQic.js +97 -0
- package/dist/compact-y6vfu2_f.js +19 -0
- package/dist/compare-pfyVnBjE.js +12 -0
- package/dist/compile/index.d.ts +3 -0
- package/dist/compile/index.js +2 -0
- package/dist/compile-Ba4blROR.js +613 -0
- package/dist/compile-CNnl6uIt.d.ts +94 -0
- package/dist/config-BJiM-xAm.js +157 -0
- package/dist/config-Bn00Z3ks.js +36 -0
- package/dist/config-report-Dw_JcUqT.js +44 -0
- package/dist/connection-CU8MQxRi.js +194 -0
- package/dist/context-Ttp0ekMT.js +82 -0
- package/dist/convex/index.d.ts +45 -0
- package/dist/convex/index.js +65 -0
- package/dist/create-BWyx3jua.d.ts +245 -0
- package/dist/create-CPhDL6qx.js +253 -0
- package/dist/credential-8P81ff4u.js +306 -0
- package/dist/delegation-D8pUEuce.js +103 -0
- package/dist/describe-B_gVZEVi.js +94 -0
- package/dist/describe-PdoqESvg.d.ts +36 -0
- package/dist/diff-B8Tunc3o.js +451 -0
- package/dist/diff-CzqLxZ77.js +48 -0
- package/dist/digest-B3kc_PgQ.d.ts +19 -0
- package/dist/digest-BI-6aa6d.js +27 -0
- package/dist/doctor-WpvG6p4k.js +1194 -0
- package/dist/doctor-collect-ByfYlNv1.js +664 -0
- package/dist/doctor-rOr-4ZfS.js +53 -0
- package/dist/drizzle/index.d.ts +73 -0
- package/dist/drizzle/index.js +160 -0
- package/dist/duration-xK2jGFVc.js +25 -0
- package/dist/elysia/index.d.ts +49 -0
- package/dist/elysia/index.js +59 -0
- package/dist/errors-CWfoNg9N.js +47 -0
- package/dist/errors-Cz5zn0mW.js +123 -0
- package/dist/errors-DAqevpNk.d.ts +125 -0
- package/dist/errors-DRnGZHzF.js +30 -0
- package/dist/evaluation-items-CfCCejQd.js +40 -0
- package/dist/evaluations-tz6D9A2G.js +461 -0
- package/dist/eve/index.d.ts +86 -0
- package/dist/eve/index.js +176 -0
- package/dist/expiry-BoBJ8Tvc.js +7 -0
- package/dist/express/index.d.ts +23 -0
- package/dist/express/index.js +78 -0
- package/dist/fastify/index.d.ts +33 -0
- package/dist/fastify/index.js +92 -0
- package/dist/fields-BMl1RxoX.js +26 -0
- package/dist/files-DWUN9PzI.js +125 -0
- package/dist/fixtures-ht28Cplr.js +67 -0
- package/dist/freeze-CrU8nQeX.js +60 -0
- package/dist/from-snapshot-C3sHpZNS.js +569 -0
- package/dist/generate-CH7ThJ14.js +173 -0
- package/dist/grantee-Cv5Sogfv.js +602 -0
- package/dist/graph-sql-B-dsAT6j.d.ts +29 -0
- package/dist/headers-BZSDieNT.js +6 -0
- package/dist/headers-Cf-zWvsO.d.ts +6 -0
- package/dist/helpers-H_KARDVC.js +421 -0
- package/dist/hono/index.d.ts +48 -0
- package/dist/hono/index.js +99 -0
- package/dist/hosted-DJQw46hn.js +266 -0
- package/dist/http-BIhmLfCc.js +95 -0
- package/dist/http-DPuDaChb.d.ts +13 -0
- package/dist/http-SO7qGttf.js +44 -0
- package/dist/ids-DC4V4CFu.js +18 -0
- package/dist/index-A0YNL8jZ.d.ts +177 -0
- package/dist/index-CtE07CBF.d.ts +6 -0
- package/dist/index-D3vbkoSI.d.ts +483 -0
- package/dist/index-D6_cSa1z.d.ts +201 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +26 -0
- package/dist/instance-options-BK_rNOSC.d.ts +11 -0
- package/dist/instance-options-Dhhcnm3y.js +22 -0
- package/dist/json-schema-BsAflUGW.js +106 -0
- package/dist/jwt/index.d.ts +91 -0
- package/dist/jwt/index.js +590 -0
- package/dist/kernel-GSQnMz3O.js +208 -0
- package/dist/kysely/index.d.ts +78 -0
- package/dist/kysely/index.js +129 -0
- package/dist/live-options-H2eG8dfJ.js +60 -0
- package/dist/load-DhWEB9P1.js +75 -0
- package/dist/load-DwJUafYN.js +2 -0
- package/dist/load-jose-BL6LH4bL.js +11 -0
- package/dist/lru-8q4WZjBV.js +28 -0
- package/dist/manifest-iaoBXHKc.js +783 -0
- package/dist/manifest-uDS9y5de.d.ts +206 -0
- package/dist/map-AcxK9o_D.js +147 -0
- package/dist/map-claims-Z4QZOiFF.js +369 -0
- package/dist/map-error-pgUWNNtG.js +23 -0
- package/dist/markers-B0hYLvMD.js +60 -0
- package/dist/may-use-DndQ5tQ-.js +77 -0
- package/dist/mcp/index.d.ts +159 -0
- package/dist/mcp/index.js +603 -0
- package/dist/nest/index.d.ts +75 -0
- package/dist/nest/index.js +261 -0
- package/dist/next/client.d.ts +23 -0
- package/dist/next/client.js +33 -0
- package/dist/next/index.d.ts +93 -0
- package/dist/next/index.js +180 -0
- package/dist/next/plugin.d.ts +14 -0
- package/dist/next/plugin.js +33 -0
- package/dist/node/index.d.ts +24 -0
- package/dist/node/index.js +34 -0
- package/dist/openai/index.d.ts +62 -0
- package/dist/openai/index.js +92 -0
- package/dist/openapi/index.d.ts +176 -0
- package/dist/openapi/index.js +3 -0
- package/dist/openapi-Bbg4wGVL.js +164 -0
- package/dist/openapi-BqRBvAng.js +538 -0
- package/dist/openapi-CqqEbHsL.js +250 -0
- package/dist/openapi-import-cmwetbzw.js +5959 -0
- package/dist/openapi-schema--ARjyfQr.js +6902 -0
- package/dist/orpc/index.d.ts +51 -0
- package/dist/orpc/index.js +145 -0
- package/dist/otel/index.d.ts +13 -0
- package/dist/otel/index.js +202 -0
- package/dist/package-root-zGkxO3oN.js +30 -0
- package/dist/parse-BuyjxhZV.js +53 -0
- package/dist/parse-local-manifest-BkGQNzAh.d.ts +10 -0
- package/dist/parse-local-manifest-BrMozJCo.js +36 -0
- package/dist/pdp/index.d.ts +22 -0
- package/dist/pdp/index.js +682 -0
- package/dist/peer-BOr_kJE1.js +31 -0
- package/dist/permdock-CzqXjCpU.js +3471 -0
- package/dist/permissions-CDgvKG5L.d.ts +52 -0
- package/dist/permissions-CpZrivYv.js +142 -0
- package/dist/permissions-DVoF6dMt.js +662 -0
- package/dist/permissions-DttnqqxC.d.ts +214 -0
- package/dist/pins-8ILTftC9.js +12 -0
- package/dist/policy-CFZAr_Al.d.ts +2252 -0
- package/dist/policy-D8UFyERw.d.ts +20 -0
- package/dist/policy-xyWg7QdR.js +1122 -0
- package/dist/powersync-A8x_Yyvh.js +2 -0
- package/dist/powersync-C7kLglqX.js +540 -0
- package/dist/powersync-yW1UUFzp.js +62 -0
- package/dist/prisma/index.d.ts +136 -0
- package/dist/prisma/index.js +455 -0
- package/dist/problem-B43ztKIm.js +191 -0
- package/dist/problem-details-CkL50EEf.d.ts +7 -0
- package/dist/problem-details-_AMOYz-w.js +144 -0
- package/dist/prompt-CXYhLfsS.js +32 -0
- package/dist/protected-CNsMzrVd.d.ts +27 -0
- package/dist/protected-Cs6kTaHo.js +100 -0
- package/dist/protected-bZs6rbT1.d.ts +40 -0
- package/dist/provider-Cjr62YMV.d.ts +6 -0
- package/dist/provider-DLzpb2Xz.js +52 -0
- package/dist/provider-store-DNyC1y48.js +43 -0
- package/dist/react/index.d.ts +8 -0
- package/dist/react/index.js +7 -0
- package/dist/react/provider-client.d.ts +2 -0
- package/dist/react/provider-client.js +3 -0
- package/dist/react-native/index.d.ts +198 -0
- package/dist/react-native/index.js +696 -0
- package/dist/refs-KYb4ntaz.js +91 -0
- package/dist/relations-cjOL01hZ.js +505 -0
- package/dist/replay-BsOyTrdV.js +28 -0
- package/dist/replay-sqBGMnNs.d.ts +5 -0
- package/dist/resource-ref-CaS9yVPi.js +20 -0
- package/dist/revocations-Bhr0aMIC.js +27 -0
- package/dist/revocations-Cy06JNx2.d.ts +21 -0
- package/dist/rls-BMNydpHk.js +2521 -0
- package/dist/rls-CEvs64Kj.js +238 -0
- package/dist/rls-fields-BMasREhR.js +3502 -0
- package/dist/rls-graph-pc9fuXYm.js +435 -0
- package/dist/rls-import-D8F7j35Q.js +943 -0
- package/dist/rls-migrate-7wikfrVI.js +367 -0
- package/dist/rls-ownership-B5Lkq62W.js +843 -0
- package/dist/rls-shared-aOQ4hGTO.js +493 -0
- package/dist/rls-verify-D8B7dOTh.js +745 -0
- package/dist/row-check-Dt35czLy.d.ts +40 -0
- package/dist/rpc-DOK54_CS.js +89 -0
- package/dist/run-YXCJDNYk.js +174 -0
- package/dist/runtime-CB8gQFvS.js +11 -0
- package/dist/saas-Bj_FFkjN.js +1203 -0
- package/dist/schema-D3MnDMxa.js +300 -0
- package/dist/scim/index.d.ts +2 -0
- package/dist/scim/index.js +2 -0
- package/dist/scim-BFGBBAqR.js +1445 -0
- package/dist/scopes-CVdPrWN-.js +239 -0
- package/dist/server/index.d.ts +134 -0
- package/dist/server/index.js +11 -0
- package/dist/server-DlZ28Oz5.js +268 -0
- package/dist/sha256-BO0swRXL.js +150 -0
- package/dist/shared-DRu8VFVM.js +123 -0
- package/dist/sink-Bd9PSyfq.js +141 -0
- package/dist/sink-Gs6TTVa-.d.ts +104 -0
- package/dist/skills-Biq5uup3.js +192 -0
- package/dist/skills-JaymNCdK.js +56 -0
- package/dist/snapshot-Enxd0n-s.js +975 -0
- package/dist/snapshot-cache-D6jLelln.js +44 -0
- package/dist/snapshot-cache-DwQH8ufx.d.ts +45 -0
- package/dist/solid/index.d.ts +93 -0
- package/dist/solid/index.js +188 -0
- package/dist/sources-B0UvrJ21.js +534 -0
- package/dist/sources-BcJgw0lt.d.ts +192 -0
- package/dist/sql-xdg5f4Fi.js +27 -0
- package/dist/src-CSbUiozF.js +568 -0
- package/dist/ssf/index.d.ts +4 -0
- package/dist/ssf/index.js +596 -0
- package/dist/store-DMAWwAJV.js +371 -0
- package/dist/store-D_pjn91-.d.ts +36 -0
- package/dist/store-options-yO0V6gRn.js +716 -0
- package/dist/stores-4_sqiOA1.js +87 -0
- package/dist/stores-DVR5NHLE.d.ts +52 -0
- package/dist/stream-DDpvynSB.js +66 -0
- package/dist/stream-DlvG2hs-.d.ts +12 -0
- package/dist/style-CTm1AXDT.js +22 -0
- package/dist/subject-C6dLxqHU.js +24 -0
- package/dist/subject-settings-BwBmCdTR.js +128 -0
- package/dist/supabase/index.d.ts +183 -0
- package/dist/supabase/index.js +5 -0
- package/dist/supabase/middleware.d.ts +82 -0
- package/dist/supabase/middleware.js +102 -0
- package/dist/supabase-CwafwxxF.js +83 -0
- package/dist/supabase-DTBaC20O.js +774 -0
- package/dist/supabase-config-Bs44dare.js +472 -0
- package/dist/supabase-hook-BuxLQLpU.js +1814 -0
- package/dist/supabase-hook-D5qVd_D8.js +2 -0
- package/dist/supautils-DYZnzRWV.js +91 -0
- package/dist/svelte/PermissionBoundary.svelte +37 -0
- package/dist/svelte/Protected.svelte +40 -0
- package/dist/svelte/index.d.ts +13 -0
- package/dist/svelte/index.js +107 -0
- package/dist/svelte/runtime.d.ts +7 -0
- package/dist/svelte/runtime.js +4 -0
- package/dist/svelte/source.d.ts +13 -0
- package/dist/svelte/source.js +11 -0
- package/dist/terminal/index.d.ts +163 -0
- package/dist/terminal/index.js +833 -0
- package/dist/testing/index.d.ts +745 -0
- package/dist/testing/index.js +3672 -0
- package/dist/testing/saas/index.d.ts +194 -0
- package/dist/testing/saas/index.js +3 -0
- package/dist/testing/saas/permissions.d.ts +2 -0
- package/dist/testing/saas/permissions.js +2 -0
- package/dist/text-diff-BdkkYSbi.js +15 -0
- package/dist/thenable-okc2xDsj.js +10 -0
- package/dist/timeout-D51niuQP.js +8 -0
- package/dist/token-CIWxJOCh.js +50 -0
- package/dist/trpc/index.d.ts +61 -0
- package/dist/trpc/index.js +122 -0
- package/dist/types-9AWO9EGt.d.ts +197 -0
- package/dist/types-BPxgszlT.d.ts +550 -0
- package/dist/types-BVyImy5I.d.ts +120 -0
- package/dist/types-Bvc4oWT6.d.ts +9 -0
- package/dist/types-C3s9xVJG.d.ts +48 -0
- package/dist/types-Dnemwd77.d.ts +183 -0
- package/dist/types-kxznc7cn.d.ts +52 -0
- package/dist/types-vKyAMtcX.d.ts +157 -0
- package/dist/types-vNSDF7Dq.d.ts +66 -0
- package/dist/types-yF5LmQVD.d.ts +306 -0
- package/dist/unplugin/index.d.ts +7 -0
- package/dist/unplugin/index.js +31 -0
- package/dist/usage-D07N9QJ3.js +42 -0
- package/dist/usage-D82l1CwK.js +2 -0
- package/dist/usage-DG1oeCca.js +693 -0
- package/dist/validation-error-CnjZ4t92.js +33 -0
- package/dist/validation-error-CtF23SrC.d.ts +26 -0
- package/dist/validity-uOp8UpYn.js +245 -0
- package/dist/verifier-BxBo6I44.js +466 -0
- package/dist/version-BvacVTZR.js +17 -0
- package/dist/views-Soe7bGSC.js +95 -0
- package/dist/vocabulary-DA8a8zif.d.ts +56 -0
- package/dist/vue/index.d.ts +79 -0
- package/dist/vue/index.js +196 -0
- package/dist/watch-Etoa_Mvr.js +2 -0
- package/dist/watch-UihESpsJ.js +128 -0
- package/dist/webmcp/index.d.ts +75 -0
- package/dist/webmcp/index.js +307 -0
- package/package.json +450 -5
- package/rulesets/permdock.yaml +29 -0
- package/schemas/approval-request-v1.json +175 -0
- package/schemas/catalog-v1.json +535 -0
- package/schemas/openapi/oas-3.1.json +1298 -0
- package/schemas/openapi/oas-3.2.json +1516 -0
- package/schemas/openapi/overlay-1.1.json +79 -0
- package/schemas/supabase-claims-v1.json +144 -0
- package/schemas/supabase-manifest-v1.json +361 -0
- package/skills/permdock/SKILL.md +66 -0
- package/skills/permdock-agents/SKILL.md +77 -0
- package/skills/permdock-agents/references/runtimes.md +213 -0
- package/skills/permdock-approvals/SKILL.md +80 -0
- package/skills/permdock-approvals/references/stores-and-resume.md +94 -0
- package/skills/permdock-audit/SKILL.md +67 -0
- package/skills/permdock-credentials/SKILL.md +55 -0
- package/skills/permdock-credentials/references/tokens-keys-links.md +132 -0
- package/skills/permdock-data/SKILL.md +57 -0
- package/skills/permdock-data/references/queries-and-rls.md +62 -0
- package/skills/permdock-data/references/relationships.md +67 -0
- package/skills/permdock-tenancy/SKILL.md +80 -0
- package/skills/permdock-tenancy/references/ownership-and-custom-roles.md +89 -0
- package/skills/permdock-wire/SKILL.md +116 -0
- package/skills/permdock-wire/references/adapters.md +492 -0
- package/skills/permdock-wire/references/policy-options.md +45 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { c as subjectView, i as permissionSet, l as tenantView, n as filterResult, o as rolesView, r as livePermDock, t as approvalHandle } from "./views-Soe7bGSC.js";
|
|
2
|
+
import { n as providePermDock, t as getStore } from "./context-Ttp0ekMT.js";
|
|
3
|
+
import { readable, toStore } from "svelte/store";
|
|
4
|
+
//#region src/svelte/stores.ts
|
|
5
|
+
function fromStore(store, compute) {
|
|
6
|
+
return readable(compute(), (set) => {
|
|
7
|
+
const offStore = store.subscribe(() => {
|
|
8
|
+
set(compute());
|
|
9
|
+
});
|
|
10
|
+
const offRunes = toStore(compute).subscribe(set);
|
|
11
|
+
return () => {
|
|
12
|
+
offStore();
|
|
13
|
+
offRunes();
|
|
14
|
+
};
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function sveltePermDock(store) {
|
|
18
|
+
return livePermDock(() => store.get());
|
|
19
|
+
}
|
|
20
|
+
function setPermDock(options) {
|
|
21
|
+
return sveltePermDock(providePermDock(options));
|
|
22
|
+
}
|
|
23
|
+
function getPermDock() {
|
|
24
|
+
return sveltePermDock(getStore());
|
|
25
|
+
}
|
|
26
|
+
function permission(reference, data) {
|
|
27
|
+
return permissionFor(getStore(), reference, data);
|
|
28
|
+
}
|
|
29
|
+
function permissionFor(store, reference, data) {
|
|
30
|
+
return fromStore(store, () => store.permissionState(reference, data?.()));
|
|
31
|
+
}
|
|
32
|
+
function permissions(references, data) {
|
|
33
|
+
return permissionsFor(getStore(), references, data);
|
|
34
|
+
}
|
|
35
|
+
function permissionsFor(store, references, data) {
|
|
36
|
+
return fromStore(store, () => permissionSet(store, references(), data?.()));
|
|
37
|
+
}
|
|
38
|
+
function filtered(reference, rows) {
|
|
39
|
+
return filteredFor(getStore(), reference, rows);
|
|
40
|
+
}
|
|
41
|
+
function filteredFor(store, reference, rows) {
|
|
42
|
+
return fromStore(store, () => filterResult(store.get(), reference, rows()));
|
|
43
|
+
}
|
|
44
|
+
function tenant() {
|
|
45
|
+
return tenantFor(getStore());
|
|
46
|
+
}
|
|
47
|
+
function tenantFor(store) {
|
|
48
|
+
return fromStore(store, () => tenantView(store.get()));
|
|
49
|
+
}
|
|
50
|
+
function memberships() {
|
|
51
|
+
return membershipsFor(getStore());
|
|
52
|
+
}
|
|
53
|
+
function membershipsFor(store) {
|
|
54
|
+
return fromStore(store, () => store.get().memberships());
|
|
55
|
+
}
|
|
56
|
+
function roles(options = () => ({})) {
|
|
57
|
+
return rolesFor(getStore(), options);
|
|
58
|
+
}
|
|
59
|
+
function rolesFor(store, options = () => ({})) {
|
|
60
|
+
return fromStore(store, () => rolesView(store.get(), options()));
|
|
61
|
+
}
|
|
62
|
+
function assignable() {
|
|
63
|
+
return assignableFor(getStore());
|
|
64
|
+
}
|
|
65
|
+
function assignableFor(store) {
|
|
66
|
+
return fromStore(store, () => store.get().assignableRoles());
|
|
67
|
+
}
|
|
68
|
+
function assignablePermissions(options = {}) {
|
|
69
|
+
return assignablePermissionsFor(getStore(), options);
|
|
70
|
+
}
|
|
71
|
+
function assignablePermissionsFor(store, options = {}) {
|
|
72
|
+
return fromStore(store, () => store.get().assignablePermissions(typeof options === "function" ? options() : options));
|
|
73
|
+
}
|
|
74
|
+
function subject() {
|
|
75
|
+
return subjectFor(getStore());
|
|
76
|
+
}
|
|
77
|
+
function subjectFor(store) {
|
|
78
|
+
return fromStore(store, () => subjectView(store.get()));
|
|
79
|
+
}
|
|
80
|
+
function approval(decision) {
|
|
81
|
+
return approvalFor(getStore(), decision);
|
|
82
|
+
}
|
|
83
|
+
function approvalFor(store, decision) {
|
|
84
|
+
return fromStore(store, () => approvalHandle(store, decision()));
|
|
85
|
+
}
|
|
86
|
+
//#endregion
|
|
87
|
+
export { getPermDock as a, permissions as c, subject as d, tenant as f, filtered as i, roles as l, assignable as n, memberships as o, assignablePermissions as r, permission as s, approval as t, setPermDock as u };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Ft as TokenVerifier, Mr as Membership, Tt as Snapshot, Yn as Decision } from "./policy-CFZAr_Al.js";
|
|
2
|
+
import { f as Permission } from "./permissions-DttnqqxC.js";
|
|
3
|
+
import { r as Role } from "./vocabulary-DA8a8zif.js";
|
|
4
|
+
import { a as FilterResult, c as SubjectView, l as TenantView, o as PermissionSet, r as ClientPermDock, s as PermissionState, t as ApprovalHandle, u as UseRolesOptions } from "./types-kxznc7cn.js";
|
|
5
|
+
import { Readable } from "svelte/store";
|
|
6
|
+
//#region src/svelte/types.d.ts
|
|
7
|
+
type PermDockSvelteOptions = {
|
|
8
|
+
/**
|
|
9
|
+
* A getter (`() => data.snapshot`) or a readable store re-hydrates the
|
|
10
|
+
* store when it changes; a promise keeps the store `pending` until it
|
|
11
|
+
* settles (render the same promise with `{#await}`).
|
|
12
|
+
*/
|
|
13
|
+
readonly snapshot: Snapshot | string | (() => Snapshot | string) | Readable<Snapshot | string> | PromiseLike<Snapshot | string>;
|
|
14
|
+
/**
|
|
15
|
+
* The AuthZEN evaluations endpoint for checks the snapshot cannot answer.
|
|
16
|
+
* `false` never calls one: such a check is denied with reason `server-only`.
|
|
17
|
+
*/
|
|
18
|
+
readonly endpoint?: string | false;
|
|
19
|
+
/** Where `refresh()` fetches a fresh snapshot. Defaults to `endpoint`. */
|
|
20
|
+
readonly snapshotUrl?: string;
|
|
21
|
+
readonly approvals?: string;
|
|
22
|
+
/** A getter (`() => page.params.org`) switches the active tenant (`refresh({ tenant })`) when it changes. */
|
|
23
|
+
readonly tenant?: string | (() => string | undefined);
|
|
24
|
+
readonly fetch?: typeof fetch;
|
|
25
|
+
/** A getter is read on every request, so a rotated token applies without a new store. */
|
|
26
|
+
readonly headers?: Readonly<Record<string, string>> | (() => Readonly<Record<string, string>> | undefined);
|
|
27
|
+
readonly maxAge?: number;
|
|
28
|
+
readonly verifier?: TokenVerifier;
|
|
29
|
+
};
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/svelte/stores.d.ts
|
|
32
|
+
declare function setPermDock(options: PermDockSvelteOptions): ClientPermDock;
|
|
33
|
+
declare function getPermDock(): ClientPermDock;
|
|
34
|
+
declare function permission(reference: Permission, data?: () => unknown): Readable<PermissionState>;
|
|
35
|
+
declare function permissions(references: () => readonly Permission[], data?: () => unknown): Readable<PermissionSet>;
|
|
36
|
+
declare function filtered<T>(reference: Permission<string, T, "instance">, rows: () => readonly T[]): Readable<FilterResult<T>>;
|
|
37
|
+
declare function tenant(): Readable<TenantView>;
|
|
38
|
+
declare function memberships(): Readable<readonly Membership[]>;
|
|
39
|
+
declare function roles(options?: () => UseRolesOptions): Readable<{
|
|
40
|
+
readonly roles: readonly Role[];
|
|
41
|
+
}>;
|
|
42
|
+
declare function assignable(): Readable<readonly Role[]>;
|
|
43
|
+
type AssignableOptions = {
|
|
44
|
+
readonly tenant?: string;
|
|
45
|
+
} | (() => {
|
|
46
|
+
readonly tenant?: string;
|
|
47
|
+
});
|
|
48
|
+
declare function assignablePermissions(options?: AssignableOptions): Readable<readonly Permission[]>;
|
|
49
|
+
declare function subject(): Readable<SubjectView>;
|
|
50
|
+
declare function approval(decision: () => Decision): Readable<ApprovalHandle>;
|
|
51
|
+
//#endregion
|
|
52
|
+
export { getPermDock as a, permissions as c, subject as d, tenant as f, filtered as i, roles as l, assignable as n, memberships as o, PermDockSvelteOptions as p, assignablePermissions as r, permission as s, approval as t, setPermDock as u };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { r as PermDockRevokedError } from "./errors-Cz5zn0mW.js";
|
|
2
|
+
//#region src/server/stream.ts
|
|
3
|
+
function isAsyncIterable(value) {
|
|
4
|
+
return value !== null && typeof value === "object" && typeof value[Symbol.asyncIterator] === "function";
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Yields `source` until `connection.signal` aborts, dropping items the
|
|
8
|
+
* subscriber can no longer read. The connection closes when iteration ends.
|
|
9
|
+
*/
|
|
10
|
+
async function* guardIterable(source, connection, options) {
|
|
11
|
+
const iterator = source[Symbol.asyncIterator]();
|
|
12
|
+
const aborted = new Promise((_resolve, reject) => {
|
|
13
|
+
const fail = () => {
|
|
14
|
+
reject(connection.signal.reason instanceof PermDockRevokedError ? connection.signal.reason : new PermDockRevokedError({ code: "denied" }));
|
|
15
|
+
};
|
|
16
|
+
if (connection.signal.aborted) fail();
|
|
17
|
+
else connection.signal.addEventListener("abort", fail, { once: true });
|
|
18
|
+
});
|
|
19
|
+
aborted.catch(() => void 0);
|
|
20
|
+
try {
|
|
21
|
+
for (;;) {
|
|
22
|
+
const next = await Promise.race([iterator.next(), aborted]);
|
|
23
|
+
if (next.done === true) return next.value;
|
|
24
|
+
const row = options.unwrap === void 0 ? next.value : options.unwrap(next.value);
|
|
25
|
+
if (options.items === void 0 || connection.check(options.items, row).outcome === "granted") yield next.value;
|
|
26
|
+
}
|
|
27
|
+
} catch (error) {
|
|
28
|
+
if (error instanceof PermDockRevokedError) throw options.onRevoked(error);
|
|
29
|
+
throw error;
|
|
30
|
+
} finally {
|
|
31
|
+
connection.close();
|
|
32
|
+
const closing = iterator.return?.();
|
|
33
|
+
if (closing !== void 0) Promise.resolve(closing).catch(() => void 0);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The connection loader for a stream `protect` already admitted: the first
|
|
38
|
+
* read returns the row `protect` loaded, and each revalidation reloads it.
|
|
39
|
+
*/
|
|
40
|
+
function reloadAfter(loaded, load) {
|
|
41
|
+
let first = true;
|
|
42
|
+
return () => {
|
|
43
|
+
if (first) {
|
|
44
|
+
first = false;
|
|
45
|
+
return loaded;
|
|
46
|
+
}
|
|
47
|
+
return load();
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/** WebSocket close code for a policy violation (RFC 6455 section 7.4.1). */
|
|
51
|
+
const POLICY_VIOLATION = 1008;
|
|
52
|
+
/** The Problem Details for an aborted connection signal. */
|
|
53
|
+
function revokedProblem(signal) {
|
|
54
|
+
const reason = signal.reason;
|
|
55
|
+
return (reason instanceof PermDockRevokedError ? reason : new PermDockRevokedError({ code: "denied" })).toProblemDetails();
|
|
56
|
+
}
|
|
57
|
+
/** Runs `end` once when the connection aborts, or now if it already has. */
|
|
58
|
+
function onRevoked(connection, end) {
|
|
59
|
+
const fire = () => {
|
|
60
|
+
end(revokedProblem(connection.signal));
|
|
61
|
+
};
|
|
62
|
+
if (connection.signal.aborted) fire();
|
|
63
|
+
else connection.signal.addEventListener("abort", fire, { once: true });
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
export { reloadAfter as a, onRevoked as i, guardIterable as n, isAsyncIterable as r, POLICY_VIOLATION as t };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { f as Permission } from "./permissions-DttnqqxC.js";
|
|
2
|
+
import { i as ProtectOptions } from "./create-BWyx3jua.js";
|
|
3
|
+
//#region src/server/stream.d.ts
|
|
4
|
+
type StreamProtectOptions = ProtectOptions & {
|
|
5
|
+
/**
|
|
6
|
+
* For a procedure that returns an async iterable: each outbound item is
|
|
7
|
+
* checked against this permission and dropped when the subscriber cannot read it.
|
|
8
|
+
*/
|
|
9
|
+
readonly items?: Permission<string, unknown, "instance">;
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
12
|
+
export { StreamProtectOptions as t };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { styleText } from "node:util";
|
|
2
|
+
//#region src/cli/style.ts
|
|
3
|
+
function createStyle(color) {
|
|
4
|
+
const paint = (format, text) => color ? styleText(format, text, { validateStream: false }) : text;
|
|
5
|
+
return {
|
|
6
|
+
color,
|
|
7
|
+
paint,
|
|
8
|
+
errorMark: color ? paint("red", "✖") : "error",
|
|
9
|
+
warnMark: color ? paint("yellow", "⚠") : "warn"
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Whether a stream takes colour. On a TTY `hasColors()` honours `NO_COLOR`,
|
|
14
|
+
* `FORCE_COLOR` and `TERM`; a pipe colours only under a non-zero `FORCE_COLOR`.
|
|
15
|
+
*/
|
|
16
|
+
function streamHasColors(stream, env = process.env) {
|
|
17
|
+
if (stream.isTTY === true) return stream.hasColors(env);
|
|
18
|
+
const force = env["FORCE_COLOR"];
|
|
19
|
+
return force !== void 0 && force !== "0" && force !== "false";
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { streamHasColors as n, createStyle as t };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region src/core/subject.ts
|
|
2
|
+
function isPrincipal(value) {
|
|
3
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
|
|
4
|
+
if ("principal" in value && "context" in value) return false;
|
|
5
|
+
const record = value;
|
|
6
|
+
if (typeof record.id !== "string") return false;
|
|
7
|
+
return Array.isArray(record.roles) || Array.isArray(record.memberships) || record.kind === "user" || record.kind === "service" || record.kind === "workload" || record.kind === "link" || typeof record.issuer === "string";
|
|
8
|
+
}
|
|
9
|
+
function isSubject(value) {
|
|
10
|
+
return value !== null && typeof value === "object" && "principal" in value && "context" in value && typeof value.context === "object";
|
|
11
|
+
}
|
|
12
|
+
function isActor(value) {
|
|
13
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
|
|
14
|
+
const record = value;
|
|
15
|
+
return typeof record.id === "string" && typeof record.kind === "string";
|
|
16
|
+
}
|
|
17
|
+
function anonymousSubject(context = {}) {
|
|
18
|
+
return Object.freeze({
|
|
19
|
+
principal: null,
|
|
20
|
+
context: Object.freeze({ ...context })
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { isSubject as i, isActor as n, isPrincipal as r, anonymousSubject as t };
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
//#region src/conditions/row-check.ts
|
|
2
|
+
const MISSING = Object.freeze({ found: false });
|
|
3
|
+
const GRANTED = Object.freeze({
|
|
4
|
+
found: true,
|
|
5
|
+
granted: true
|
|
6
|
+
});
|
|
7
|
+
const DENIED = Object.freeze({
|
|
8
|
+
found: true,
|
|
9
|
+
granted: false
|
|
10
|
+
});
|
|
11
|
+
function rowCheckOf(found, granted) {
|
|
12
|
+
return found ? granted ? GRANTED : DENIED : MISSING;
|
|
13
|
+
}
|
|
14
|
+
/** Reads `select <filter> as granted ... where <key> limit 2`; only a boolean `true` or `1` grants. */
|
|
15
|
+
function rowCheckFrom(rows) {
|
|
16
|
+
if (rows.length > 1) throw new Error("PermDock: checkRow key matches more than one row");
|
|
17
|
+
const [row] = rows;
|
|
18
|
+
return rowCheckOf(row !== void 0, row?.granted === true || row?.granted === 1);
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/conditions/subject-settings.ts
|
|
22
|
+
const NAME = /^[a-z_][a-z0-9_]*$/u;
|
|
23
|
+
function settingName(name, what) {
|
|
24
|
+
if (!NAME.test(name)) throw new Error(`PermDock: unsafe ${what} '${name}'`);
|
|
25
|
+
return name;
|
|
26
|
+
}
|
|
27
|
+
function isRecord(value) {
|
|
28
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
29
|
+
}
|
|
30
|
+
function strings(value) {
|
|
31
|
+
return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The credential a principal acts through. Entries limited to `ids` are left
|
|
35
|
+
* out of `scopes`: the claim has no per-row form, so the database allows less.
|
|
36
|
+
*/
|
|
37
|
+
function heldCredential(principal) {
|
|
38
|
+
const credential = Reflect.get(principal, "credential");
|
|
39
|
+
if (!isRecord(credential) || typeof credential["id"] !== "string" || credential["kind"] !== "user" && credential["kind"] !== "service" || !Array.isArray(credential["permissions"])) return;
|
|
40
|
+
const scopes = credential["permissions"].flatMap((entry) => isRecord(entry) && typeof entry["permission"] === "string" && entry["ids"] === void 0 ? [entry["permission"]] : []);
|
|
41
|
+
const tenant = credential["tenant"];
|
|
42
|
+
return {
|
|
43
|
+
id: credential["id"],
|
|
44
|
+
kind: credential["kind"],
|
|
45
|
+
tenant: typeof tenant === "string" && tenant !== "" ? tenant : void 0,
|
|
46
|
+
roles: strings(credential["roles"]),
|
|
47
|
+
scopes
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function field(name, fallback) {
|
|
51
|
+
return settingName(name ?? fallback, "API-key claim field");
|
|
52
|
+
}
|
|
53
|
+
function apiKeyClaim(held, options = {}) {
|
|
54
|
+
const claim = {
|
|
55
|
+
id: held.id,
|
|
56
|
+
[field(options.scopes, "scopes")]: held.scopes
|
|
57
|
+
};
|
|
58
|
+
if (held.tenant !== void 0) claim[field(options.tenant, "tenant")] = held.tenant;
|
|
59
|
+
if (held.kind === "service") claim[field(options.roles, "roles")] = held.roles;
|
|
60
|
+
return [field(options.claim, "api_key"), claim];
|
|
61
|
+
}
|
|
62
|
+
function setConfigs(settings) {
|
|
63
|
+
if (settings.length === 0) return [];
|
|
64
|
+
const parts = [];
|
|
65
|
+
let open = "select ";
|
|
66
|
+
for (const [name] of settings) {
|
|
67
|
+
parts.push(`${open}set_config('${name}', `);
|
|
68
|
+
open = ", true), ";
|
|
69
|
+
}
|
|
70
|
+
parts.push(", true)");
|
|
71
|
+
return [{
|
|
72
|
+
strings: parts,
|
|
73
|
+
values: settings.map(([, value]) => value)
|
|
74
|
+
}];
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The transaction preamble that makes Postgres see `permdock.subject`: one `select set_config(…)`
|
|
78
|
+
* that sets the role, then the claims the generated policies read. Runs inside the caller's
|
|
79
|
+
* transaction, so every setting is local to it.
|
|
80
|
+
*/
|
|
81
|
+
function subjectStatements(permdock, options = {}) {
|
|
82
|
+
const principal = permdock.subject.principal;
|
|
83
|
+
const role = options.role ?? (principal === null ? "anon" : "authenticated");
|
|
84
|
+
if (role !== false && role !== "authenticated" && role !== "anon") throw new Error(`PermDock: withSubject sets role authenticated or anon, not '${String(role)}'`);
|
|
85
|
+
const tenantClaim = settingName(options.tenantClaim ?? "tenant_id", "tenant claim");
|
|
86
|
+
const claims = Object.fromEntries(Object.entries(options.claims ?? {}).filter(([name]) => name !== "sub" && name !== "role" && name !== tenantClaim));
|
|
87
|
+
if (principal !== null) {
|
|
88
|
+
const held = heldCredential(principal);
|
|
89
|
+
claims["sub"] = held?.kind === "service" ? "" : principal.id;
|
|
90
|
+
if (principal.tenant !== void 0) claims[tenantClaim] = principal.tenant;
|
|
91
|
+
if (held !== void 0) {
|
|
92
|
+
const [name, value] = apiKeyClaim(held, options.apiKeys);
|
|
93
|
+
claims[name] = value;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (role !== false) claims["role"] = role;
|
|
97
|
+
const subjectId = typeof claims["sub"] === "string" ? claims["sub"] : "";
|
|
98
|
+
const settings = role === false ? [] : [["role", role]];
|
|
99
|
+
const dialect = options.dialect ?? "supabase";
|
|
100
|
+
switch (dialect) {
|
|
101
|
+
case "supabase":
|
|
102
|
+
case "neon":
|
|
103
|
+
settings.push(["request.jwt.claims", JSON.stringify(claims)]);
|
|
104
|
+
return setConfigs(settings);
|
|
105
|
+
case "guc": {
|
|
106
|
+
const prefix = settingName(options.gucPrefix ?? "app", "setting prefix");
|
|
107
|
+
settings.push([`${prefix}.user_id`, subjectId]);
|
|
108
|
+
for (const [name, value] of Object.entries(claims)) {
|
|
109
|
+
if (name === "sub") continue;
|
|
110
|
+
settings.push([`${prefix}.${settingName(name, "claim name")}`, typeof value === "string" ? value : JSON.stringify(value)]);
|
|
111
|
+
}
|
|
112
|
+
return setConfigs(settings);
|
|
113
|
+
}
|
|
114
|
+
default: return dialect;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/** A statement as text with `$1`, `$2` placeholders, for raw executors. */
|
|
118
|
+
function statementText(statement) {
|
|
119
|
+
let text = "";
|
|
120
|
+
for (const [index, part] of statement.strings.entries()) text = index === 0 ? part : `${text}$${String(index)}${part}`;
|
|
121
|
+
return text;
|
|
122
|
+
}
|
|
123
|
+
/** A statement as a template-strings array, for `sql` tags. */
|
|
124
|
+
function statementTemplate(statement) {
|
|
125
|
+
return Object.assign([...statement.strings], { raw: [...statement.strings] });
|
|
126
|
+
}
|
|
127
|
+
//#endregion
|
|
128
|
+
export { rowCheckOf as a, rowCheckFrom as i, statementText as n, subjectStatements as r, statementTemplate as t };
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { C as Policy, Dr as CustomRole, Mr as Membership, Pr as Subject, gt as MembershipSource, mt as MemberEntry, xt as RoleSource } from "../policy-CFZAr_Al.js";
|
|
2
|
+
import { c as ApprovalRequest, f as ApprovalStore } from "../types-vKyAMtcX.js";
|
|
3
|
+
import { C as SupabaseClaimsSchema, E as supabaseClaims, S as SupabaseClaimsOptions, T as SupabasePermDockClaims, _ as SupabaseSuspendedMembership, a as SupabaseActorResult, b as SupabaseActClaim, c as SupabaseMembershipTable, d as SupabaseRealtime, f as SupabaseRlsConfig, g as SupabaseSubjectOptions, h as SupabaseStorage, i as SupabaseActor, l as SupabasePermissionRef, m as SupabaseSessionLike, n as RoleThrough, o as SupabaseDelegation, p as SupabaseRlsOptions, r as SupabaseActiveRow, s as SupabaseInclude, t as AuthorizeSqlOptions, u as SupabasePrincipal, v as SupabaseSuspendedScope, w as SupabaseMembershipClaim, x as SupabaseClaims, y as SupabaseSuspension } from "../types-yF5LmQVD.js";
|
|
4
|
+
import { a as SupabaseManifestHelper, c as SupabaseManifestRls, d as SupabaseManifestValue, f as parseSupabaseManifest, i as SupabaseManifestColumn, l as SupabaseManifestRole, n as SupabaseHookManifest, o as SupabaseManifestMembership, r as SupabaseManifestActiveRow, s as SupabaseManifestRequires, t as SupabaseHookClaim, u as SupabaseManifestThrough } from "../manifest-uDS9y5de.js";
|
|
5
|
+
import { a as MembershipTableOptions, c as SupabasePostgres, d as fromSupabasePostgres, f as fromTable, i as MembershipSql, l as authzVersion, n as MembershipHolders, o as SqlMembershipSource, r as MembershipJunctionOptions, s as SqlQuery, t as AUTHZ_VERSION_TABLE, u as fromJunction } from "../sources-BcJgw0lt.js";
|
|
6
|
+
import { n as supabaseTenantClaim, t as supabaseMembershipsBudget } from "../budget-JqcRqyhK.js";
|
|
7
|
+
//#region src/supabase/capability.d.ts
|
|
8
|
+
type ExchangeCapabilityOptions = {
|
|
9
|
+
/**
|
|
10
|
+
* The key Supabase verifies with: a private JWK imported into the project's
|
|
11
|
+
* JWT signing keys (`ES256` or `RS256`, with its `kid`), or the legacy JWT
|
|
12
|
+
* secret (`HS256`).
|
|
13
|
+
*/
|
|
14
|
+
readonly key: Record<string, unknown> | {
|
|
15
|
+
readonly secret: string;
|
|
16
|
+
};
|
|
17
|
+
/** Default `ES256`, Supabase's asymmetric signing key; the legacy secret needs `HS256` named. */
|
|
18
|
+
readonly alg?: "ES256" | "RS256" | "HS256";
|
|
19
|
+
readonly kid?: string;
|
|
20
|
+
readonly issuer?: string;
|
|
21
|
+
/** Lifetime in seconds, capped by the capability's own expiry. Default 300. */
|
|
22
|
+
readonly ttl?: number;
|
|
23
|
+
readonly now?: number;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Exchanges a verified link subject (from `subjectFromCapability`) for a
|
|
27
|
+
* short-lived Supabase access token with role `anon` and the capability in a
|
|
28
|
+
* `capability` claim, which `permdock rls generate --capabilities` policies
|
|
29
|
+
* read. `undefined` for any subject that is not a live link.
|
|
30
|
+
*/
|
|
31
|
+
export declare function exchangeCapability(subject: Subject, options: ExchangeCapabilityOptions): Promise<string | undefined>;
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/supabase/postgrest.d.ts
|
|
34
|
+
/** What a supabase-js `rpc` call resolves to: `data` or an `error` with a message. */
|
|
35
|
+
type SupabaseRpcResult = {
|
|
36
|
+
readonly data: unknown;
|
|
37
|
+
readonly error: {
|
|
38
|
+
readonly message: string;
|
|
39
|
+
} | null;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* The part of a supabase-js client `postgrestSources` calls:
|
|
43
|
+
* `client.schema(name).rpc(fn, args)`. Pass a client that may execute the
|
|
44
|
+
* function, such as a `service_role` client after the grant the docs show.
|
|
45
|
+
*/
|
|
46
|
+
type SupabaseRpcClient = {
|
|
47
|
+
schema(name: string): {
|
|
48
|
+
rpc(fn: string, args: Readonly<Record<string, unknown>>): PromiseLike<SupabaseRpcResult>;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
type SupabaseRpcCaller = {
|
|
52
|
+
schema(name: never): {
|
|
53
|
+
rpc(fn: never, args: never): PromiseLike<SupabaseRpcResult>;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
type PostgrestSourcesOptions = {
|
|
57
|
+
/** Schema of the functions. Default `permdock`, where the hook generates `subject_for` and `members_of`. */
|
|
58
|
+
readonly schema?: string;
|
|
59
|
+
/** Function name, for a wrapper in an exposed schema. Default `subject_for`. */
|
|
60
|
+
readonly fn?: string;
|
|
61
|
+
readonly membersFn?: string;
|
|
62
|
+
/** The version-only function `memberships.version` calls. Default `authz_version_for`. */
|
|
63
|
+
readonly versionFn?: string;
|
|
64
|
+
/**
|
|
65
|
+
* The policy whose declared roles tell custom roles apart. With it,
|
|
66
|
+
* `customRoles` reads nothing while every role the subject holds is
|
|
67
|
+
* declared, and `memberships.version` reads the whole subject in one call
|
|
68
|
+
* when the token claims a custom role, which the custom roles need anyway.
|
|
69
|
+
*/
|
|
70
|
+
readonly policy?: Policy;
|
|
71
|
+
};
|
|
72
|
+
/** One user as `subject_for(p_user)` returns it. */
|
|
73
|
+
type SubjectRecord = {
|
|
74
|
+
readonly id: string;
|
|
75
|
+
/** `false` for a suspended user, who holds no roles or memberships. */
|
|
76
|
+
readonly active: boolean;
|
|
77
|
+
readonly roles: readonly string[];
|
|
78
|
+
readonly memberships: readonly Membership[];
|
|
79
|
+
readonly customRoles: readonly CustomRole[];
|
|
80
|
+
readonly authzVersion?: number;
|
|
81
|
+
};
|
|
82
|
+
type PostgrestSources = {
|
|
83
|
+
/**
|
|
84
|
+
* Memberships and the authorization version of any principal, and `list`,
|
|
85
|
+
* the live members of one scope instance through `members_of`, for
|
|
86
|
+
* `countHolders` and `whoCan`. Wrap it in `claimsFirst` to read only when
|
|
87
|
+
* the token was truncated.
|
|
88
|
+
*/
|
|
89
|
+
readonly memberships: MembershipSource & {
|
|
90
|
+
list(query: {
|
|
91
|
+
readonly scope: string;
|
|
92
|
+
readonly id: string;
|
|
93
|
+
}): Promise<MemberEntry[]>;
|
|
94
|
+
};
|
|
95
|
+
/** The custom roles `principal` holds, for `createPermDock`'s `customRoles`. */
|
|
96
|
+
customRoles(principal: {
|
|
97
|
+
readonly id: string;
|
|
98
|
+
}): RoleSource;
|
|
99
|
+
/** The subject the hook would mint for `userId`: anonymous when the user is unknown or suspended. */
|
|
100
|
+
subject(userId: string): Promise<Subject>;
|
|
101
|
+
/** The raw record, `undefined` for an unknown user. */
|
|
102
|
+
record(userId: string): Promise<SubjectRecord | undefined>;
|
|
103
|
+
};
|
|
104
|
+
/** Reads `subject_for`'s JSON; anything it cannot read is left out, and a malformed record is no record. */
|
|
105
|
+
export declare function readSubjectRecord(value: unknown): SubjectRecord | undefined;
|
|
106
|
+
/**
|
|
107
|
+
* Membership, custom-role and subject sources over the `subject_for(p_user)`,
|
|
108
|
+
* `authz_version_for(p_user)` and `members_of(p_scope, p_id)` functions
|
|
109
|
+
* `permdock supabase hook generate` writes, for a backend that reaches
|
|
110
|
+
* Postgres only through PostgREST. `memberships.version` reads only the
|
|
111
|
+
* version, so `claimsFirst` with `onStale: 'reread'` reads the full subject
|
|
112
|
+
* only for a stale token; when the version function is missing it falls back
|
|
113
|
+
* to `subject_for`. With `policy`, a token that claims a custom role has its
|
|
114
|
+
* subject read in one `subject_for` call instead, and custom roles are read
|
|
115
|
+
* only for a subject that holds one. Each user and each instance is read once per
|
|
116
|
+
* `postgrestSources` call, so create it per request or per job.
|
|
117
|
+
*/
|
|
118
|
+
export declare function postgrestSources(client: SupabaseRpcCaller, options?: PostgrestSourcesOptions): PostgrestSources;
|
|
119
|
+
//#endregion
|
|
120
|
+
//#region src/supabase/approval-store.d.ts
|
|
121
|
+
type SupabaseApprovalStoreOptions = {
|
|
122
|
+
/** Schema of the generated store functions (`rls.schema`). Default `permdock`. */
|
|
123
|
+
readonly schema?: string;
|
|
124
|
+
/** How long a request stays open when the caller sets no `ttl`, in milliseconds. */
|
|
125
|
+
readonly ttl?: number;
|
|
126
|
+
/**
|
|
127
|
+
* Runs once per stored request, after the call that stored it, with the
|
|
128
|
+
* stored request: notify the approvers, or cancel the requests this one
|
|
129
|
+
* replaces. A repeated ask that finds the request still open does not run
|
|
130
|
+
* it again. A throw fails the open, so the caller does not run the action.
|
|
131
|
+
*/
|
|
132
|
+
readonly onOpen?: (request: ApprovalRequest) => void | Promise<void>;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* An `ApprovalStore` over the table and functions `rls.approvals` generates,
|
|
136
|
+
* called through supabase-js (`client.schema(schema).rpc(...)`) with a
|
|
137
|
+
* client that may execute them, such as a `service_role` client. Each method
|
|
138
|
+
* is one atomic statement in the database: a repeated ask keeps the open
|
|
139
|
+
* request, two racing approvers both count towards a quorum, and two racing
|
|
140
|
+
* resumes never both consume an approval.
|
|
141
|
+
*/
|
|
142
|
+
export declare function supabaseApprovalStore(client: SupabaseRpcCaller, options?: SupabaseApprovalStoreOptions): ApprovalStore;
|
|
143
|
+
//#endregion
|
|
144
|
+
//#region src/supabase/rls.d.ts
|
|
145
|
+
export declare function supabaseRls(options?: SupabaseRlsOptions): SupabaseRlsConfig;
|
|
146
|
+
/**
|
|
147
|
+
* `authorize(requested_permission, requested_tenant text default null)` for Supabase's RBAC
|
|
148
|
+
* scaffold, over the `role_permissions (role, permission, grant_key, scope, effect)` table that
|
|
149
|
+
* `permdock rls generate` seeds. `database` reads `user_roles` (and the memberships table for a
|
|
150
|
+
* tenant) on every call; `jwt` reads the hook-injected `user_role` and `memberships` claims. A
|
|
151
|
+
* tenant request with no memberships source is denied, never answered from global roles. It
|
|
152
|
+
* answers "does a role hold this permission" without seeing a row: an allow with row conditions
|
|
153
|
+
* does not count, and a deny the user's tenant or global roles hold overrides every allow.
|
|
154
|
+
* Generated policies call the per-statement RLS helpers (`permdock_has`, `permitted_<scope>_ids`)
|
|
155
|
+
* instead. Only `authenticated` may execute it.
|
|
156
|
+
*/
|
|
157
|
+
export declare function authorizeSql(options?: AuthorizeSqlOptions): string;
|
|
158
|
+
//#endregion
|
|
159
|
+
//#region src/supabase/subject.d.ts
|
|
160
|
+
/**
|
|
161
|
+
* Who acts for the user: the outermost `sub` of an RFC 8693 `act` chain (the current
|
|
162
|
+
* actor; nested levels are prior actors, kept on `chain` for audit), else the
|
|
163
|
+
* OAuth `client_id` of a third-party app. The outer level's `kind` names the actor:
|
|
164
|
+
* none is `oauth-client`, `support` a support session, `impersonation` an admin acting as the
|
|
165
|
+
* user. Reads only `act` and `client_id`; the caller applies the role rule first (`anon` and
|
|
166
|
+
* `service_role` are anonymous and carry no actor). An `act` that is not a chain of objects each
|
|
167
|
+
* with a non-empty `sub`, that names another `kind`, or a support level without `session_id`,
|
|
168
|
+
* is `{ ok: false }` and must deny.
|
|
169
|
+
*/
|
|
170
|
+
export declare function actorOf(claims: unknown): SupabaseActorResult;
|
|
171
|
+
/**
|
|
172
|
+
* The OAuth `scope` claim (a space-separated string or a list) as `scopes`,
|
|
173
|
+
* without the OpenID Connect identity scopes; `undefined` when none is left.
|
|
174
|
+
*/
|
|
175
|
+
export declare function delegationOf(claims: unknown): SupabaseDelegation | undefined;
|
|
176
|
+
export declare function subjectFromSupabase(claims: unknown, options?: SupabaseSubjectOptions): Subject<SupabasePrincipal>;
|
|
177
|
+
/**
|
|
178
|
+
* A verified session object (`{ kind, claims }`) in, `Subject` out.
|
|
179
|
+
* Only `kind: 'user'` sessions map; `anon`, `service`, `invalid` and anything else are anonymous.
|
|
180
|
+
*/
|
|
181
|
+
export declare function subjectFromSupabaseSession(session: SupabaseSessionLike | null | undefined, options?: SupabaseSubjectOptions): Subject<SupabasePrincipal>;
|
|
182
|
+
//#endregion
|
|
183
|
+
export { AUTHZ_VERSION_TABLE, type AuthorizeSqlOptions, type ExchangeCapabilityOptions, type MembershipHolders, type MembershipJunctionOptions, type MembershipSql, type MembershipTableOptions, type PostgrestSources, type PostgrestSourcesOptions, type RoleThrough, type SqlMembershipSource, type SqlQuery, type SubjectRecord, type SupabaseActClaim, type SupabaseActiveRow, type SupabaseActor, type SupabaseActorResult, type SupabaseApprovalStoreOptions, type SupabaseClaims, type SupabaseClaimsOptions, type SupabaseClaimsSchema, type SupabaseDelegation, type SupabaseHookClaim, type SupabaseHookManifest, type SupabaseInclude, type SupabaseManifestActiveRow, type SupabaseManifestColumn, type SupabaseManifestHelper, type SupabaseManifestMembership, type SupabaseManifestRequires, type SupabaseManifestRls, type SupabaseManifestRole, type SupabaseManifestThrough, type SupabaseManifestValue, type SupabaseMembershipClaim, type SupabaseMembershipTable, type SupabasePermDockClaims, type SupabasePermissionRef, type SupabasePostgres, type SupabasePrincipal, type SupabaseRealtime, type SupabaseRlsConfig, type SupabaseRlsOptions, type SupabaseRpcCaller, type SupabaseRpcClient, type SupabaseRpcResult, type SupabaseSessionLike, type SupabaseStorage, type SupabaseSubjectOptions, type SupabaseSuspendedMembership, type SupabaseSuspendedScope, type SupabaseSuspension, authzVersion, fromJunction, fromSupabasePostgres, fromTable, parseSupabaseManifest, supabaseClaims, supabaseMembershipsBudget, supabaseTenantClaim };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { a as readSubjectRecord, i as postgrestSources, n as supabaseRls, o as supabaseClaims, r as supabaseApprovalStore, s as exchangeCapability, t as authorizeSql } from "../supabase-DTBaC20O.js";
|
|
2
|
+
import { n as supabaseTenantClaim, t as supabaseMembershipsBudget } from "../budget-NbEtbJC_.js";
|
|
3
|
+
import { a as fromSupabasePostgres, i as fromJunction, o as fromTable, r as authzVersion, t as AUTHZ_VERSION_TABLE } from "../sources-B0UvrJ21.js";
|
|
4
|
+
import { a as subjectFromSupabase, n as actorOf, o as subjectFromSupabaseSession, r as delegationOf, t as parseSupabaseManifest } from "../manifest-iaoBXHKc.js";
|
|
5
|
+
export { AUTHZ_VERSION_TABLE, actorOf, authorizeSql, authzVersion, delegationOf, exchangeCapability, fromJunction, fromSupabasePostgres, fromTable, parseSupabaseManifest, postgrestSources, readSubjectRecord, subjectFromSupabase, subjectFromSupabaseSession, supabaseApprovalStore, supabaseClaims, supabaseMembershipsBudget, supabaseRls, supabaseTenantClaim };
|