permdock 0.0.0 → 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/README.md +268 -1
- package/dist/a2a/index.d.ts +178 -0
- package/dist/a2a/index.js +271 -0
- package/dist/ai-sdk/index.d.ts +74 -0
- package/dist/ai-sdk/index.js +137 -0
- package/dist/approval-required-TzNB9oQA.js +6 -0
- package/dist/approvals/index.d.ts +3 -0
- package/dist/approvals/index.js +4 -0
- package/dist/approvals-DaxY-Bdg.js +218 -0
- package/dist/approvers-aH0PJkmf.js +20 -0
- package/dist/arazzo-CTeVuXr5.js +70 -0
- package/dist/arazzo-aoTkqYsJ.js +54 -0
- package/dist/authzen/index.d.ts +48 -0
- package/dist/authzen/index.js +336 -0
- package/dist/better-auth/index.d.ts +92 -0
- package/dist/better-auth/index.js +324 -0
- package/dist/budget-JqcRqyhK.d.ts +11 -0
- package/dist/budget-NbEtbJC_.js +11 -0
- package/dist/capability-B68OFnZx.js +171 -0
- package/dist/capability-BDG_nkxt.d.ts +99 -0
- package/dist/catalog/index.d.ts +12 -0
- package/dist/catalog/index.js +2 -0
- package/dist/catalog-B0E6bggc.js +48 -0
- package/dist/catalog-H-vFGwWK.js +55 -0
- package/dist/catalog-doc-BSo_Q_-6.js +298 -0
- package/dist/catalog-idsHc0vo.js +2 -0
- package/dist/catalog-path-CnI0XTFK.js +12 -0
- package/dist/claude-agent/index.d.ts +81 -0
- package/dist/claude-agent/index.js +83 -0
- package/dist/clerk/index.d.ts +56 -0
- package/dist/clerk/index.js +280 -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/cloud/index.d.ts +91 -0
- package/dist/cloud/index.js +390 -0
- package/dist/cloud-BNQTrmrr.js +50 -0
- package/dist/cloud-Cuxr6Czw.js +117 -0
- package/dist/collect-B7_TIfmg.js +49 -0
- package/dist/collect-O-tOtbnk.js +350 -0
- package/dist/collect-fRPAQIWb.js +2 -0
- package/dist/commands-BMh_Etm2.js +93 -0
- package/dist/compact-y6vfu2_f.js +19 -0
- package/dist/compare-pfyVnBjE.js +12 -0
- package/dist/compile-CQbvyIBr.d.ts +30 -0
- package/dist/compile-D22iwvuV.js +558 -0
- package/dist/config-BPYmjTOp.js +26 -0
- package/dist/connection-JvqwHODC.js +194 -0
- package/dist/context-CKEAabd7.js +73 -0
- package/dist/context-gtAwAILx.js +6 -0
- package/dist/convex/index.d.ts +40 -0
- package/dist/convex/index.js +55 -0
- package/dist/create-BKF3dgFk.d.ts +162 -0
- package/dist/create-CSkhDU9T.js +222 -0
- package/dist/credential-B_rkUNlY.js +326 -0
- package/dist/credentials-BgRX3WEg.js +268 -0
- package/dist/describe-Bt1YD5uS.js +99 -0
- package/dist/describe-DernyItf.d.ts +37 -0
- package/dist/diff-BUzf5Poi.js +48 -0
- package/dist/diff-x5Il8LVa.js +418 -0
- package/dist/digest-B3kc_PgQ.d.ts +19 -0
- package/dist/digest-BI-6aa6d.js +27 -0
- package/dist/doctor-BGle8Gqi.js +1314 -0
- package/dist/doctor-Bqo6FwUa.js +53 -0
- package/dist/drizzle/index.d.ts +72 -0
- package/dist/drizzle/index.js +160 -0
- package/dist/duration-xK2jGFVc.js +25 -0
- package/dist/elysia/index.d.ts +71 -0
- package/dist/elysia/index.js +103 -0
- package/dist/errors-DSMnAVNa.js +43 -0
- package/dist/errors-DbZ1YOnb.d.ts +138 -0
- package/dist/errors-Iy71s7Oj.js +177 -0
- package/dist/errors-m3u9TmDu.js +27 -0
- package/dist/evaluations-DsAU9ppl.js +479 -0
- package/dist/eve/index.d.ts +95 -0
- package/dist/eve/index.js +181 -0
- package/dist/express/index.d.ts +46 -0
- package/dist/express/index.js +108 -0
- package/dist/fastify/index.d.ts +56 -0
- package/dist/fastify/index.js +141 -0
- package/dist/files-B_wAGYmt.js +121 -0
- package/dist/fixtures-Cvaw0gDG.js +64 -0
- package/dist/freeze-y1_jQL4v.js +31 -0
- package/dist/from-snapshot-BMGnhmgv.js +552 -0
- package/dist/generate-CH7ThJ14.js +173 -0
- package/dist/grantee-Bv04_Vzf.js +521 -0
- package/dist/headers-B5RRv3Xm.js +6 -0
- package/dist/headers-C8SHQccD.d.ts +6 -0
- package/dist/helpers-DnSOrhB9.js +682 -0
- package/dist/hono/index.d.ts +70 -0
- package/dist/hono/index.js +131 -0
- package/dist/hosted-BwKQ1BTA.js +265 -0
- package/dist/http-DPuDaChb.d.ts +13 -0
- package/dist/http-GgVApX1k.js +111 -0
- package/dist/index-CltcQ4Bf.d.ts +138 -0
- package/dist/index-LF_hS-yn.d.ts +177 -0
- package/dist/index-fG6NSXlc.d.ts +9 -0
- package/dist/index-xIxJLwOQ.d.ts +415 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +21 -0
- package/dist/jwt/index.d.ts +87 -0
- package/dist/jwt/index.js +571 -0
- package/dist/kernel-YOGCWNLf.js +211 -0
- package/dist/kysely/index.d.ts +77 -0
- package/dist/kysely/index.js +129 -0
- package/dist/load-BZ24CpZP.js +69 -0
- package/dist/load-QOOm1z70.js +2 -0
- package/dist/load-jose-BL6LH4bL.js +11 -0
- package/dist/lru-8q4WZjBV.js +28 -0
- package/dist/manifest-DDQbC6K0.d.ts +118 -0
- package/dist/map-DowSO96j.js +158 -0
- package/dist/map-claims-B_6I1Rn-.js +360 -0
- package/dist/map-error-RJ3ZsUyA.js +16 -0
- package/dist/markers-B0hYLvMD.js +60 -0
- package/dist/may-use-CnFEjVEp.js +37 -0
- package/dist/mcp/index.d.ts +127 -0
- package/dist/mcp/index.js +563 -0
- package/dist/nest/index.d.ts +80 -0
- package/dist/nest/index.js +270 -0
- package/dist/next/client.d.ts +24 -0
- package/dist/next/client.js +31 -0
- package/dist/next/index.d.ts +110 -0
- package/dist/next/index.js +195 -0
- package/dist/next/plugin.d.ts +14 -0
- package/dist/next/plugin.js +2 -0
- package/dist/node/index.d.ts +43 -0
- package/dist/node/index.js +66 -0
- package/dist/openai/index.d.ts +71 -0
- package/dist/openai/index.js +105 -0
- package/dist/openapi/index.d.ts +93 -0
- package/dist/openapi/index.js +3 -0
- package/dist/openapi-CwePaF7C.js +164 -0
- package/dist/openapi-DWD0Uc_4.js +250 -0
- package/dist/openapi-DcqM8nU7.js +306 -0
- package/dist/openapi-import-BWRUNNeW.js +5959 -0
- package/dist/openapi-schema-D8j_T9tO.js +6902 -0
- package/dist/orpc/index.d.ts +64 -0
- package/dist/orpc/index.js +188 -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-DPfIvFMU.js +135 -0
- package/dist/pdp/index.d.ts +22 -0
- package/dist/pdp/index.js +795 -0
- package/dist/peer-BOr_kJE1.js +31 -0
- package/dist/permdock-yoZ7EjxX.js +2956 -0
- package/dist/permissions-B4apnahQ.d.ts +185 -0
- package/dist/permissions-B8vCg_bI.d.ts +52 -0
- package/dist/permissions-CofRqesP.js +142 -0
- package/dist/permissions-DC7GROPA.js +600 -0
- package/dist/pg-4GJWDUxG.js +953 -0
- package/dist/pins-CqE1jZuF.js +12 -0
- package/dist/plugin-4gr7IxFJ.js +65 -0
- package/dist/policy-ANp36PnI.js +971 -0
- package/dist/policy-CInmNGkM.d.ts +1959 -0
- package/dist/policy-Cq2fB8Q5.d.ts +20 -0
- package/dist/prisma/index.d.ts +135 -0
- package/dist/prisma/index.js +430 -0
- package/dist/problem-Cgp9-KZA.js +226 -0
- package/dist/prompt-CXYhLfsS.js +32 -0
- package/dist/protected-B4K3BKoX.js +138 -0
- package/dist/protected-BuPAycJT.d.ts +26 -0
- package/dist/protected-wY7nXhY9.d.ts +23 -0
- package/dist/provider-_wx46HpB.js +48 -0
- package/dist/provider-wTAUda2v.d.ts +6 -0
- package/dist/react/index.d.ts +6 -0
- package/dist/react/index.js +6 -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 +42 -0
- package/dist/react-native/index.js +174 -0
- package/dist/refs-ChLSxbST.js +90 -0
- package/dist/relations-r4soIFZB.js +426 -0
- package/dist/revocations-Cy06JNx2.d.ts +21 -0
- package/dist/rls-BOFU3chG.js +233 -0
- package/dist/rls-CJVja9Ww.js +2119 -0
- package/dist/rls-graph-DxQ39PJj.js +371 -0
- package/dist/rls-helpers-BxRuif0l.js +1346 -0
- package/dist/rls-import-CXV6LBlS.js +942 -0
- package/dist/rls-migrate-DrFPbf8p.js +366 -0
- package/dist/row-check-BajTgQZ-.d.ts +43 -0
- package/dist/run-CJ6UvS3a.js +155 -0
- package/dist/runtime-DP9ttFh1.js +27 -0
- package/dist/saas-BRrZzJkM.js +1193 -0
- package/dist/schema-P8yoma__.js +296 -0
- package/dist/scim/index.d.ts +2 -0
- package/dist/scim/index.js +2 -0
- package/dist/scim-9NFa0XVZ.js +1445 -0
- package/dist/scopes-cKVp_WTw.js +212 -0
- package/dist/server/index.d.ts +123 -0
- package/dist/server/index.js +8 -0
- package/dist/sha256-BO0swRXL.js +150 -0
- package/dist/sink-Bd9PSyfq.js +141 -0
- package/dist/sink-Cfr9-7YC.d.ts +104 -0
- package/dist/skills-C_lpV4Jx.js +50 -0
- package/dist/skills-Dx3QLnMY.js +110 -0
- package/dist/snapshot-DE8dE_hz.js +1051 -0
- package/dist/solid/index.d.ts +63 -0
- package/dist/solid/index.js +197 -0
- package/dist/source-DoBBYJi2.js +6 -0
- package/dist/sources-DOpW5Ila.d.ts +347 -0
- package/dist/sources-DVHM3Mwq.js +284 -0
- package/dist/sql-Bll1d7y0.js +22 -0
- package/dist/src-CTNT-PBW.js +430 -0
- package/dist/ssf/index.d.ts +3 -0
- package/dist/ssf/index.js +622 -0
- package/dist/store-Bq90395i.d.ts +27 -0
- package/dist/store-C6hFW6ta.js +508 -0
- package/dist/stores-CkG2HrSg.js +140 -0
- package/dist/stores-CvOnu_2T.d.ts +41 -0
- package/dist/stream-BhMfZOwr.d.ts +12 -0
- package/dist/stream-Q_xlB6Ko.js +52 -0
- package/dist/style-CTm1AXDT.js +22 -0
- package/dist/subject-C6dLxqHU.js +24 -0
- package/dist/subject-settings-xt7V845g.js +82 -0
- package/dist/supabase/index.d.ts +67 -0
- package/dist/supabase/index.js +4 -0
- package/dist/supabase/middleware.d.ts +77 -0
- package/dist/supabase/middleware.js +68 -0
- package/dist/supabase-D8UlBA7Z.js +83 -0
- package/dist/supabase-DTxGtYdi.js +796 -0
- package/dist/supabase-hook-DW-xP4hU.js +2 -0
- package/dist/supabase-hook-D_OqGb_V.js +1528 -0
- package/dist/svelte/Protected.svelte +34 -0
- package/dist/svelte/index.d.ts +10 -0
- package/dist/svelte/index.js +53 -0
- package/dist/svelte/runtime.d.ts +6 -0
- package/dist/svelte/runtime.js +3 -0
- package/dist/svelte/source.d.ts +10 -0
- package/dist/svelte/source.js +8 -0
- package/dist/terminal/index.d.ts +171 -0
- package/dist/terminal/index.js +821 -0
- package/dist/testing/index.d.ts +656 -0
- package/dist/testing/index.js +3208 -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/trpc/index.d.ts +80 -0
- package/dist/trpc/index.js +205 -0
- package/dist/types-B8w5PFtS.d.ts +141 -0
- package/dist/types-B9dmiiab.d.ts +66 -0
- package/dist/types-BBK-exvJ.d.ts +177 -0
- package/dist/types-BvBk1wgn.d.ts +118 -0
- package/dist/types-CxquUByI.d.ts +9 -0
- package/dist/types-D6Z6-rKJ.d.ts +312 -0
- package/dist/types-DbWdEfcm.d.ts +87 -0
- package/dist/types-bva3i4Gf.d.ts +98 -0
- package/dist/types-i4BAOvdb.d.ts +97 -0
- package/dist/unplugin/index.d.ts +7 -0
- package/dist/unplugin/index.js +30 -0
- package/dist/usage-1ozMubLY.js +42 -0
- package/dist/usage-CUnK6Ou9.js +530 -0
- package/dist/usage-PyEor6GA.js +2 -0
- package/dist/validity-D0uRmJKJ.js +224 -0
- package/dist/verifier-B90agnhl.js +461 -0
- package/dist/version-CnSh33Fj.js +16 -0
- package/dist/vocabulary-Dk0fs-Jk.d.ts +56 -0
- package/dist/vue/index.d.ts +57 -0
- package/dist/vue/index.js +203 -0
- package/dist/webmcp/index.d.ts +75 -0
- package/dist/webmcp/index.js +313 -0
- package/package.json +423 -4
- package/rulesets/permdock.yaml +29 -0
- package/schemas/catalog-v1.json +507 -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 +139 -0
- package/schemas/supabase-manifest-v1.json +217 -0
- package/skills/permdock/SKILL.md +66 -0
- package/skills/permdock-agents/SKILL.md +77 -0
- package/skills/permdock-agents/references/runtimes.md +211 -0
- package/skills/permdock-approvals/SKILL.md +80 -0
- package/skills/permdock-approvals/references/stores-and-resume.md +83 -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 +127 -0
- package/skills/permdock-data/SKILL.md +57 -0
- package/skills/permdock-data/references/queries-and-rls.md +54 -0
- package/skills/permdock-data/references/relationships.md +65 -0
- package/skills/permdock-tenancy/SKILL.md +77 -0
- package/skills/permdock-tenancy/references/ownership-and-custom-roles.md +83 -0
- package/skills/permdock-wire/SKILL.md +116 -0
- package/skills/permdock-wire/references/adapters.md +480 -0
- package/skills/permdock-wire/references/policy-options.md +43 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { E as PolicyVocabulary, Z as DecisionEvent, Zt as PermDock } from "./policy-CInmNGkM.js";
|
|
2
|
+
//#region src/otel/types.d.ts
|
|
3
|
+
declare const GENAI_SEMCONV_PIN = "1.37.0";
|
|
4
|
+
declare const GEN_AI_TOOL_NAME = "gen_ai.tool.name";
|
|
5
|
+
declare const GEN_AI_TOOL_CALL_ID = "gen_ai.tool.call.id";
|
|
6
|
+
type StructuralLogger = {
|
|
7
|
+
readonly debug?: (message: string, attributes?: Record<string, unknown>) => void;
|
|
8
|
+
readonly info: (message: string, attributes?: Record<string, unknown>) => void;
|
|
9
|
+
readonly warn: (message: string, attributes?: Record<string, unknown>) => void;
|
|
10
|
+
readonly error?: (message: string, attributes?: Record<string, unknown>) => void;
|
|
11
|
+
};
|
|
12
|
+
type OtelSpan = {
|
|
13
|
+
readonly setAttribute?: (key: string, value: unknown) => void;
|
|
14
|
+
readonly setAttributes?: (attributes: Record<string, unknown>) => void;
|
|
15
|
+
readonly addEvent?: (name: string, attributes?: Record<string, unknown>) => void;
|
|
16
|
+
readonly recordException?: (error: unknown) => void;
|
|
17
|
+
readonly setStatus?: (status: {
|
|
18
|
+
readonly code: number;
|
|
19
|
+
}) => void;
|
|
20
|
+
readonly end?: (endTime?: number) => void;
|
|
21
|
+
readonly isRecording?: () => boolean;
|
|
22
|
+
readonly attributes?: Record<string, unknown>;
|
|
23
|
+
};
|
|
24
|
+
type OtelTracer = {
|
|
25
|
+
readonly startSpan: (name: string, options?: {
|
|
26
|
+
readonly startTime?: number;
|
|
27
|
+
}) => OtelSpan;
|
|
28
|
+
};
|
|
29
|
+
type OtelCounter = {
|
|
30
|
+
readonly add: (value: number, attributes?: Record<string, unknown>) => void;
|
|
31
|
+
};
|
|
32
|
+
type OtelHistogram = {
|
|
33
|
+
readonly record: (value: number, attributes?: Record<string, unknown>) => void;
|
|
34
|
+
};
|
|
35
|
+
type OtelMeter = {
|
|
36
|
+
readonly createCounter: (name: string) => OtelCounter;
|
|
37
|
+
readonly createHistogram: (name: string, options?: {
|
|
38
|
+
readonly unit?: string;
|
|
39
|
+
readonly description?: string;
|
|
40
|
+
}) => OtelHistogram;
|
|
41
|
+
};
|
|
42
|
+
type OtelApi = {
|
|
43
|
+
readonly trace: {
|
|
44
|
+
readonly getTracer: (name: string) => OtelTracer;
|
|
45
|
+
readonly getActiveSpan?: () => OtelSpan | undefined;
|
|
46
|
+
};
|
|
47
|
+
readonly metrics?: {
|
|
48
|
+
readonly getMeter: (name: string) => OtelMeter;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
type OtelOptions = {
|
|
52
|
+
readonly tracer?: string;
|
|
53
|
+
readonly logger?: StructuralLogger;
|
|
54
|
+
readonly attributes?: (event: DecisionEvent) => Record<string, unknown>;
|
|
55
|
+
readonly redact?: readonly string[];
|
|
56
|
+
readonly errorOnDeny?: boolean;
|
|
57
|
+
readonly api?: OtelApi;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* An adapter's `otel` option: wraps each request-scoped instance, usually
|
|
61
|
+
* `(permdock) => withOtel(permdock, options)` from `permdock/otel`, so an app
|
|
62
|
+
* without it does not bundle the instrumentation.
|
|
63
|
+
*/
|
|
64
|
+
type OtelWrap = <V extends PolicyVocabulary>(permdock: PermDock<V>) => PermDock<V>;
|
|
65
|
+
//#endregion
|
|
66
|
+
export { OtelOptions as a, OtelApi as i, GEN_AI_TOOL_CALL_ID as n, OtelWrap as o, GEN_AI_TOOL_NAME as r, StructuralLogger as s, GENAI_SEMCONV_PIN as t };
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { b as ResourceRelation } from "./permissions-B4apnahQ.js";
|
|
2
|
+
//#region src/catalog/types.d.ts
|
|
3
|
+
type CatalogUsage = {
|
|
4
|
+
readonly file: string;
|
|
5
|
+
readonly line: number;
|
|
6
|
+
readonly call: string;
|
|
7
|
+
};
|
|
8
|
+
type CatalogPermission = {
|
|
9
|
+
readonly key: string;
|
|
10
|
+
readonly scope: string;
|
|
11
|
+
readonly resource: string;
|
|
12
|
+
readonly action: string;
|
|
13
|
+
readonly arity: "instance" | "collection";
|
|
14
|
+
readonly meta: Readonly<Record<string, unknown>>;
|
|
15
|
+
readonly usages: readonly CatalogUsage[];
|
|
16
|
+
/** Keys the permission was renamed from (`definePermissions` `renamed`), sorted; absent when none. */
|
|
17
|
+
readonly renamedFrom?: readonly string[];
|
|
18
|
+
/** Present only when the policy lists the permission in `hostable`. */
|
|
19
|
+
readonly hostable?: true;
|
|
20
|
+
/**
|
|
21
|
+
* `true` when a code grant for the key has a condition beyond role and
|
|
22
|
+
* scope, so the SQL helpers alone cannot enforce it, and when the catalog
|
|
23
|
+
* was built without the policy, which leaves it unknown.
|
|
24
|
+
*/
|
|
25
|
+
readonly rowConditions: boolean;
|
|
26
|
+
/** The approvals code allows on this permission require; a hosted grant must meet each. */
|
|
27
|
+
readonly approvals?: readonly CatalogApproval[];
|
|
28
|
+
/** Present when a `breakGlass` override targets this permission. */
|
|
29
|
+
readonly breakGlass?: CatalogBreakGlass;
|
|
30
|
+
};
|
|
31
|
+
/** A break-glass override as the catalog carries it. */
|
|
32
|
+
type CatalogBreakGlass = {
|
|
33
|
+
readonly overrides: readonly string[];
|
|
34
|
+
readonly purpose?: readonly string[];
|
|
35
|
+
readonly reason: boolean;
|
|
36
|
+
readonly maxDuration?: string;
|
|
37
|
+
readonly obligations: readonly string[];
|
|
38
|
+
};
|
|
39
|
+
type CatalogApproval = "human" | {
|
|
40
|
+
readonly by?: unknown;
|
|
41
|
+
readonly mode?: "any" | "all" | "sequential";
|
|
42
|
+
readonly stages?: readonly {
|
|
43
|
+
readonly by: unknown;
|
|
44
|
+
readonly quorum?: number;
|
|
45
|
+
}[];
|
|
46
|
+
readonly distinct?: boolean;
|
|
47
|
+
readonly staleOn?: "resource-change";
|
|
48
|
+
readonly quorum?: number;
|
|
49
|
+
readonly ttl?: string;
|
|
50
|
+
readonly escalation?: {
|
|
51
|
+
readonly after: string;
|
|
52
|
+
readonly to: unknown;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
type CatalogResource = {
|
|
56
|
+
readonly id: string;
|
|
57
|
+
readonly schema: unknown;
|
|
58
|
+
readonly definedIn?: string;
|
|
59
|
+
readonly relations?: Readonly<Record<string, ResourceRelation>>;
|
|
60
|
+
/** The row field an `approval: { staleOn: 'resource-change' }` binds to. */
|
|
61
|
+
readonly version?: string;
|
|
62
|
+
/** The boolean column that keeps ancestor grants out of a row. */
|
|
63
|
+
readonly restricted?: string;
|
|
64
|
+
};
|
|
65
|
+
type CatalogRole = {
|
|
66
|
+
readonly key: string;
|
|
67
|
+
/** A declared scope name, or `resource`; absent for a global role. */
|
|
68
|
+
readonly on?: string;
|
|
69
|
+
readonly assignable?: boolean;
|
|
70
|
+
/** Fewest holders per scope instance; absent when 0. */
|
|
71
|
+
readonly min?: number;
|
|
72
|
+
readonly max?: number;
|
|
73
|
+
readonly transferOnly?: true;
|
|
74
|
+
readonly assigns?: readonly string[];
|
|
75
|
+
/** Membership kinds (`via`) that may hold the role. */
|
|
76
|
+
readonly for?: readonly string[];
|
|
77
|
+
readonly exclusiveWith?: readonly string[];
|
|
78
|
+
readonly audience?: string;
|
|
79
|
+
/** Present when the role is eligible-only and activated with `permdock.activate`. */
|
|
80
|
+
readonly activation?: CatalogActivation;
|
|
81
|
+
/** Present when the role is a `supportAccess` role. */
|
|
82
|
+
readonly supportAccess?: CatalogSupportAccess;
|
|
83
|
+
};
|
|
84
|
+
/** A role activation as the catalog carries it. */
|
|
85
|
+
type CatalogActivation = {
|
|
86
|
+
readonly maxDuration?: string;
|
|
87
|
+
readonly justification: "required" | "optional";
|
|
88
|
+
readonly approval?: boolean;
|
|
89
|
+
readonly assurance?: {
|
|
90
|
+
readonly maxAge?: number;
|
|
91
|
+
readonly acr?: readonly string[];
|
|
92
|
+
readonly amr?: readonly string[];
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
/** A support-access role as the catalog carries it. */
|
|
96
|
+
type CatalogSupportAccess = {
|
|
97
|
+
readonly actorRequired: boolean;
|
|
98
|
+
readonly group: string;
|
|
99
|
+
readonly durations: readonly string[];
|
|
100
|
+
};
|
|
101
|
+
/** One declared scope, in declaration order. */
|
|
102
|
+
type CatalogScope = {
|
|
103
|
+
readonly name: string;
|
|
104
|
+
readonly key: string;
|
|
105
|
+
readonly within?: string;
|
|
106
|
+
};
|
|
107
|
+
/** A grant's `validFrom` / `validUntil` window in Unix seconds. */
|
|
108
|
+
type CatalogValidity = {
|
|
109
|
+
readonly from?: number;
|
|
110
|
+
readonly until?: number;
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* One code grant as the catalog carries it: the normalised shape
|
|
114
|
+
* `definePolicy` produced, minus closures. `permdock diff` compares these;
|
|
115
|
+
* a hosted document is authored against them.
|
|
116
|
+
*/
|
|
117
|
+
type CatalogGrant = {
|
|
118
|
+
readonly permission: string;
|
|
119
|
+
readonly effect: "allow" | "deny";
|
|
120
|
+
/** The role binding the grant came from; `null` for a top-level grant. */
|
|
121
|
+
readonly role: string | null;
|
|
122
|
+
/** The grantee selector, or an array for an intersection, in its JSON form. */
|
|
123
|
+
readonly to: unknown;
|
|
124
|
+
/** `global`, a declared scope name, or `{ resource }`. */
|
|
125
|
+
readonly scope: string | {
|
|
126
|
+
readonly resource: string;
|
|
127
|
+
};
|
|
128
|
+
/** Portable condition on the current row; absent on a non-portable grant. */
|
|
129
|
+
readonly where?: unknown;
|
|
130
|
+
/** Portable condition on the next row; absent on a non-portable grant. */
|
|
131
|
+
readonly check?: unknown;
|
|
132
|
+
readonly approval?: CatalogApproval;
|
|
133
|
+
readonly fields?: readonly string[];
|
|
134
|
+
readonly validity?: CatalogValidity;
|
|
135
|
+
readonly name?: string;
|
|
136
|
+
readonly purpose?: readonly string[];
|
|
137
|
+
readonly limit?: {
|
|
138
|
+
readonly count: number;
|
|
139
|
+
readonly per: string;
|
|
140
|
+
readonly mode?: "hard" | "soft";
|
|
141
|
+
};
|
|
142
|
+
/** Present when the grant is a closure, reads the relation graph or is opaque; `where` and `check` are then omitted. */
|
|
143
|
+
readonly portable?: false;
|
|
144
|
+
};
|
|
145
|
+
/** `permissions.catalog.json`, validated by `schemas/catalog-v1.json`. */
|
|
146
|
+
type CatalogDocument = {
|
|
147
|
+
readonly $schema: string;
|
|
148
|
+
readonly version: 1;
|
|
149
|
+
readonly generatedAt: string;
|
|
150
|
+
readonly generator: string;
|
|
151
|
+
/** `catalogFingerprint` of this document; what hosted documents pin as `catalog`. */
|
|
152
|
+
readonly fingerprint?: string;
|
|
153
|
+
readonly resources: Readonly<Record<string, CatalogResource>>;
|
|
154
|
+
readonly permissions: readonly CatalogPermission[];
|
|
155
|
+
/** The policy's scopes in order; absent when it declares none. */
|
|
156
|
+
readonly scopes?: readonly CatalogScope[];
|
|
157
|
+
readonly roles?: readonly CatalogRole[];
|
|
158
|
+
readonly plans?: readonly {
|
|
159
|
+
readonly key: string;
|
|
160
|
+
}[];
|
|
161
|
+
/** Every code grant, canonically ordered; present when the catalog was built with the policy. */
|
|
162
|
+
readonly grants?: readonly CatalogGrant[];
|
|
163
|
+
/** The policy's standing delegations, canonically ordered; present when the policy declares any. */
|
|
164
|
+
readonly delegations?: readonly CatalogDelegation[];
|
|
165
|
+
};
|
|
166
|
+
/** One `definePolicy({ delegations })` entry: who hands over, to which actor, which permission keys, and when. */
|
|
167
|
+
type CatalogDelegation = {
|
|
168
|
+
readonly from: unknown;
|
|
169
|
+
readonly to: {
|
|
170
|
+
readonly kind: string;
|
|
171
|
+
readonly id?: string;
|
|
172
|
+
};
|
|
173
|
+
readonly permissions: readonly string[];
|
|
174
|
+
readonly validity?: CatalogValidity;
|
|
175
|
+
};
|
|
176
|
+
//#endregion
|
|
177
|
+
export { CatalogDocument as a, CatalogResource as c, CatalogSupportAccess as d, CatalogUsage as f, CatalogDelegation as i, CatalogRole as l, CatalogApproval as n, CatalogGrant as o, CatalogValidity as p, CatalogBreakGlass as r, CatalogPermission as s, CatalogActivation as t, CatalogScope as u };
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { C as Policy, Cn as ArazzoPlan, E as PolicyVocabulary, In as ExplainedDecision, Mn as Decision, Qt as PermDockOptions, Xt as DecideOptions, Zt as PermDock, en as SimulateOptions, hr as Subject, mr as Principal, pr as Membership, tn as WhereResult, wn as ArazzoSimulateInput } from "./policy-CInmNGkM.js";
|
|
2
|
+
import { d as Permission, p as PermissionTree } from "./permissions-B4apnahQ.js";
|
|
3
|
+
//#region src/pdp/types.d.ts
|
|
4
|
+
type RemotePdpAuth = {
|
|
5
|
+
readonly bearer: string | (() => string | Promise<string>);
|
|
6
|
+
};
|
|
7
|
+
type RemotePdpMapping = {
|
|
8
|
+
readonly subject?: (subject: Subject) => {
|
|
9
|
+
readonly type?: string;
|
|
10
|
+
readonly id?: string;
|
|
11
|
+
readonly properties?: Readonly<Record<string, unknown>>;
|
|
12
|
+
};
|
|
13
|
+
readonly resource?: (permission: Permission, data: unknown) => {
|
|
14
|
+
readonly type?: string;
|
|
15
|
+
readonly id?: string;
|
|
16
|
+
readonly properties?: unknown;
|
|
17
|
+
};
|
|
18
|
+
readonly action?: (permission: Permission) => {
|
|
19
|
+
readonly name?: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
type RemotePdpEndpoints = {
|
|
23
|
+
readonly evaluation?: string;
|
|
24
|
+
readonly evaluations?: string;
|
|
25
|
+
readonly searchResource?: string;
|
|
26
|
+
};
|
|
27
|
+
type RemotePdpCache = {
|
|
28
|
+
readonly ttl: number | `${number}s` | `${number}ms`;
|
|
29
|
+
};
|
|
30
|
+
type RemotePdpOptions = {
|
|
31
|
+
readonly url: string;
|
|
32
|
+
readonly auth?: RemotePdpAuth;
|
|
33
|
+
readonly permissions?: readonly (Permission | PermissionTree)[];
|
|
34
|
+
readonly mapping?: RemotePdpMapping;
|
|
35
|
+
readonly timeout?: number;
|
|
36
|
+
readonly cache?: RemotePdpCache;
|
|
37
|
+
readonly endpoints?: RemotePdpEndpoints;
|
|
38
|
+
readonly fetch?: typeof fetch;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* One tuple callback per delegated permission. The callback receives the
|
|
42
|
+
* row for a check and `undefined` for a listing; returning `null` denies
|
|
43
|
+
* with `pdp-denied`, throwing denies with `pdp-invalid-response`.
|
|
44
|
+
*/
|
|
45
|
+
type RelationMap<T> = readonly (readonly [Permission, (subject: Subject, data: unknown) => T | null])[];
|
|
46
|
+
type OpenFgaTuple = {
|
|
47
|
+
/** `user:anne`, `team:eng#member`. */
|
|
48
|
+
readonly user: string;
|
|
49
|
+
readonly relation: string;
|
|
50
|
+
readonly type: string;
|
|
51
|
+
/** Required for a check; ignored for `list-objects`. */
|
|
52
|
+
readonly id?: string;
|
|
53
|
+
};
|
|
54
|
+
type OpenFgaOptions = {
|
|
55
|
+
readonly url: string;
|
|
56
|
+
readonly storeId: string;
|
|
57
|
+
readonly authorizationModelId?: string;
|
|
58
|
+
readonly map: RelationMap<OpenFgaTuple>;
|
|
59
|
+
readonly auth?: RemotePdpAuth;
|
|
60
|
+
readonly timeout?: number;
|
|
61
|
+
readonly cache?: RemotePdpCache;
|
|
62
|
+
readonly fetch?: typeof fetch;
|
|
63
|
+
};
|
|
64
|
+
type SpiceDbCheck = {
|
|
65
|
+
readonly subject: {
|
|
66
|
+
readonly type: string;
|
|
67
|
+
readonly id: string;
|
|
68
|
+
readonly relation?: string;
|
|
69
|
+
};
|
|
70
|
+
readonly permission: string;
|
|
71
|
+
/** `id` is required for a check; ignored for `LookupResources`. */
|
|
72
|
+
readonly resource: {
|
|
73
|
+
readonly type: string;
|
|
74
|
+
readonly id?: string;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
type SpiceDbOptions = {
|
|
78
|
+
/** The SpiceDB HTTP gateway origin. */
|
|
79
|
+
readonly url: string;
|
|
80
|
+
readonly token: RemotePdpAuth["bearer"];
|
|
81
|
+
readonly map: RelationMap<SpiceDbCheck>;
|
|
82
|
+
readonly consistency?: "minimize-latency" | "fully-consistent";
|
|
83
|
+
readonly timeout?: number;
|
|
84
|
+
readonly cache?: RemotePdpCache;
|
|
85
|
+
readonly fetch?: typeof fetch;
|
|
86
|
+
};
|
|
87
|
+
type PdpPermDock<V extends PolicyVocabulary = PolicyVocabulary> = Omit<PermDock<V>, "can" | "decide" | "assert" | "explain" | "filter" | "where" | "simulate" | "tenant" | "team"> & {
|
|
88
|
+
/**
|
|
89
|
+
* For a delegated permission whose provider lists ids, an `in` over them
|
|
90
|
+
* (AND the local condition when local grants exist); otherwise the local
|
|
91
|
+
* `where`, or an always-false `partial` result.
|
|
92
|
+
*/
|
|
93
|
+
readonly where: (permission: Permission) => Promise<WhereResult>;
|
|
94
|
+
readonly can: (permission: Permission, data?: unknown, options?: DecideOptions) => Promise<boolean>;
|
|
95
|
+
readonly decide: (permission: Permission, data?: unknown, options?: DecideOptions) => Promise<Decision>;
|
|
96
|
+
readonly assert: (permission: Permission, data?: unknown, options?: DecideOptions) => Promise<Extract<Decision, {
|
|
97
|
+
readonly outcome: "granted";
|
|
98
|
+
}>>;
|
|
99
|
+
/** `decide` with a trace of the local grants; a decision the remote PDP made carries an empty trace. */
|
|
100
|
+
readonly explain: (permission: Permission, data?: unknown, options?: Omit<DecideOptions, "explain">) => Promise<ExplainedDecision>;
|
|
101
|
+
readonly filter: <T>(permission: Permission<string, T, "instance">, rows: readonly T[], options?: DecideOptions) => Promise<T[]>;
|
|
102
|
+
readonly simulate: {
|
|
103
|
+
(checks: readonly (readonly [Permission, unknown?])[], options?: SimulateOptions): Promise<readonly Decision[]>;
|
|
104
|
+
(plan: ArazzoSimulateInput): ArazzoPlan;
|
|
105
|
+
(preview: {
|
|
106
|
+
readonly roles?: readonly (string | {
|
|
107
|
+
readonly key: string;
|
|
108
|
+
})[];
|
|
109
|
+
readonly memberships?: readonly Membership[];
|
|
110
|
+
readonly tenant?: string;
|
|
111
|
+
}): PdpPermDock<V>;
|
|
112
|
+
};
|
|
113
|
+
readonly tenant: (id: string) => PdpPermDock<V>;
|
|
114
|
+
readonly team: (id: string) => PdpPermDock<V>;
|
|
115
|
+
};
|
|
116
|
+
type PdpFactory = <TUser, TPrincipal extends Principal = Principal, V extends PolicyVocabulary = PolicyVocabulary>(policy: Policy<TUser, TPrincipal, V>, user: TUser | null, options?: PermDockOptions) => Promise<PdpPermDock<V>>;
|
|
117
|
+
//#endregion
|
|
118
|
+
export { RelationMap as a, RemotePdpEndpoints as c, SpiceDbCheck as d, SpiceDbOptions as f, PdpPermDock as i, RemotePdpMapping as l, OpenFgaTuple as n, RemotePdpAuth as o, PdpFactory as r, RemotePdpCache as s, OpenFgaOptions as t, RemotePdpOptions as u };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { d as Permission } from "./permissions-B4apnahQ.js";
|
|
2
|
+
//#region src/agent/types.d.ts
|
|
3
|
+
type ToolBinding = {
|
|
4
|
+
readonly permission: Permission;
|
|
5
|
+
readonly data?: (args: unknown) => unknown;
|
|
6
|
+
};
|
|
7
|
+
type ToolMap = Readonly<Record<string, ToolBinding>>;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { ToolMap as t };
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import { a as SqlMembershipSource } from "./sources-DOpW5Ila.js";
|
|
2
|
+
//#region src/cli/types.d.ts
|
|
3
|
+
type CollectConfig = {
|
|
4
|
+
readonly srcPath?: readonly string[];
|
|
5
|
+
readonly out?: string;
|
|
6
|
+
readonly barrel?: boolean | string;
|
|
7
|
+
};
|
|
8
|
+
type CatalogConfig = {
|
|
9
|
+
readonly out?: string;
|
|
10
|
+
};
|
|
11
|
+
type RlsDialect = "supabase" | "neon" | "guc";
|
|
12
|
+
type RlsTarget = "sql" | "drizzle" | "prisma";
|
|
13
|
+
type RlsMembershipTable = {
|
|
14
|
+
readonly table: string;
|
|
15
|
+
readonly user: string;
|
|
16
|
+
readonly role: string;
|
|
17
|
+
/** Per scope name, the column holding that scope's id: the table's own scope and its ancestors. */
|
|
18
|
+
readonly columns?: Readonly<Record<string, string>>;
|
|
19
|
+
/** Column of the first scope's id; shorthand for `columns[<first scope>]`. */
|
|
20
|
+
readonly tenant?: string;
|
|
21
|
+
/** Column of the second scope's id; shorthand for `columns[<second scope>]`. */
|
|
22
|
+
readonly team?: string;
|
|
23
|
+
readonly id?: string;
|
|
24
|
+
readonly expiresAt?: string;
|
|
25
|
+
/** Column holding the membership kind (`Membership.via`); roles with `for` need it. */
|
|
26
|
+
readonly via?: string;
|
|
27
|
+
};
|
|
28
|
+
type RlsMemberships = {
|
|
29
|
+
/** The membership table of each named scope. */
|
|
30
|
+
readonly scopes?: Readonly<Record<string, RlsMembershipTable>>;
|
|
31
|
+
/** The first scope's table; shorthand for `scopes[<first scope>]`. */
|
|
32
|
+
readonly tenant?: RlsMembershipTable;
|
|
33
|
+
/** The second scope's table; shorthand for `scopes[<second scope>]`. */
|
|
34
|
+
readonly team?: RlsMembershipTable;
|
|
35
|
+
readonly resource?: Readonly<Record<string, RlsMembershipTable>>;
|
|
36
|
+
};
|
|
37
|
+
/** A table whose row says whether a user or a scope instance is active. A missing row counts as suspended. */
|
|
38
|
+
type RlsActiveRow = {
|
|
39
|
+
readonly table: string;
|
|
40
|
+
/** Column holding the user id or the scope instance id. */
|
|
41
|
+
readonly id: string;
|
|
42
|
+
/** Nullable timestamp column; a row with a value is suspended. */
|
|
43
|
+
readonly disabledAt?: string;
|
|
44
|
+
/** Status column; only a row whose value is in `active` counts as active. */
|
|
45
|
+
readonly status?: string;
|
|
46
|
+
readonly active?: readonly string[];
|
|
47
|
+
};
|
|
48
|
+
type RlsSuspension = {
|
|
49
|
+
/** A suspended user holds no role and no membership. */
|
|
50
|
+
readonly users?: RlsActiveRow;
|
|
51
|
+
/** Per scope name: a suspended instance voids its memberships and every membership nested under it. */
|
|
52
|
+
readonly scopes?: Readonly<Record<string, RlsActiveRow>>;
|
|
53
|
+
};
|
|
54
|
+
type RlsFunctionMapping = {
|
|
55
|
+
readonly twin: unknown;
|
|
56
|
+
readonly args?: readonly string[];
|
|
57
|
+
};
|
|
58
|
+
type RlsConfig = {
|
|
59
|
+
readonly tables?: Readonly<Record<string, string>>;
|
|
60
|
+
readonly dialect?: RlsDialect;
|
|
61
|
+
readonly memberships?: RlsMemberships;
|
|
62
|
+
/**
|
|
63
|
+
* `database` mode: the `fromTable` / `fromJunction` sources the helpers
|
|
64
|
+
* read for every scope `memberships` maps no table for. Default
|
|
65
|
+
* `supabase.hook.memberships`, so the helpers and the token hook run the
|
|
66
|
+
* same SQL. Setting it selects `database` mode.
|
|
67
|
+
*/
|
|
68
|
+
readonly membershipSources?: readonly SqlMembershipSource[];
|
|
69
|
+
/** Tables the helpers, `authorize()` and the token hook read to drop suspended users and scope instances. */
|
|
70
|
+
readonly suspension?: RlsSuspension;
|
|
71
|
+
readonly functions?: Readonly<Record<string, RlsFunctionMapping>>;
|
|
72
|
+
readonly inlineFunctions?: boolean;
|
|
73
|
+
/** Emit FORCE ROW LEVEL SECURITY so the table owner is subject to the policies. */
|
|
74
|
+
readonly force?: boolean;
|
|
75
|
+
readonly fixtures?: string;
|
|
76
|
+
readonly tenantClaim?: string;
|
|
77
|
+
/** Postgres type of tenant columns (`uuid` by default); the tenant claim and helper results are cast to it. */
|
|
78
|
+
readonly tenantType?: string;
|
|
79
|
+
/** Postgres type of team columns; defaults to `tenantType`. */
|
|
80
|
+
readonly teamType?: string;
|
|
81
|
+
/** Postgres type of each named scope's id column; overrides `tenantType` / `teamType`. */
|
|
82
|
+
readonly scopeTypes?: Readonly<Record<string, string>>;
|
|
83
|
+
readonly roleClaim?: string;
|
|
84
|
+
readonly gucPrefix?: string;
|
|
85
|
+
readonly out?: string;
|
|
86
|
+
/** `--target drizzle`: where each policy's `.link()` finds its table. */
|
|
87
|
+
readonly drizzle?: {
|
|
88
|
+
/** Module exporting the tables, as imported from `out`. Default `./schema`. */
|
|
89
|
+
readonly schema?: string;
|
|
90
|
+
/** Export name per table name; defaults to the camelCased table name. */
|
|
91
|
+
readonly exports?: Readonly<Record<string, string>>;
|
|
92
|
+
};
|
|
93
|
+
/** `--target prisma`: the model each table maps to. */
|
|
94
|
+
readonly prisma?: {
|
|
95
|
+
/** Model name per table name; defaults to the PascalCased table name. */
|
|
96
|
+
readonly models?: Readonly<Record<string, string>>;
|
|
97
|
+
};
|
|
98
|
+
/** Schema of `role_permissions` and the RLS helpers (`permdock_has`, `permitted_<scope>_ids`, `member_<scope>_ids`) (and the RBAC scaffold). Default `permdock`; keep it out of `[api] schemas`. */
|
|
99
|
+
readonly schema?: string;
|
|
100
|
+
/** Where the helpers read roles and memberships: `database` tables or `jwt` claims. */
|
|
101
|
+
readonly authorize?: "database" | "jwt";
|
|
102
|
+
/** One policy per role and permission instead of one per table and command. */
|
|
103
|
+
readonly policyPerRole?: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Resolve tenant-defined custom roles in the helpers: `custom_role_permissions` and
|
|
106
|
+
* `custom_role_includes` in `database` mode, the `memberships[].grants` claim in `jwt` mode,
|
|
107
|
+
* always intersected with the `permdock_ceiling` view. Off by default.
|
|
108
|
+
*/
|
|
109
|
+
readonly customRoles?: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Let link capabilities reach resource-scoped grants: `anon` policies that call
|
|
112
|
+
* `permdock_capability_ids`, which reads the `capability` claim `exchangeCapability`
|
|
113
|
+
* mints. Off by default.
|
|
114
|
+
*/
|
|
115
|
+
readonly capabilities?: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* `'deny'` (Supabase only): a token with `is_anonymous: true` reaches no grant
|
|
118
|
+
* but those to `anyone()`. Supabase gives an anonymous sign-in the
|
|
119
|
+
* `authenticated` role, so without it the grants to roles and to
|
|
120
|
+
* `authenticated()` reach it. The subject mapper has to refuse it in process
|
|
121
|
+
* too. Off by default.
|
|
122
|
+
*/
|
|
123
|
+
readonly anonymousSignIns?: "deny";
|
|
124
|
+
/**
|
|
125
|
+
* `'views'`: one `security_invoker` view `<table>_visible` per table with field-limited
|
|
126
|
+
* read grants, whose restricted columns are `case when <permitted> then col end`. Off by default.
|
|
127
|
+
*/
|
|
128
|
+
readonly fields?: "views";
|
|
129
|
+
/**
|
|
130
|
+
* With `fields: 'views'`, grant `anon` and `authenticated` only the unrestricted columns of
|
|
131
|
+
* the base table, so restricted columns are read through the view. Breaks `select *`.
|
|
132
|
+
*/
|
|
133
|
+
readonly revokeColumns?: boolean;
|
|
134
|
+
/** Policy name template: `{table}`, `{op}`, plus `{role}` and `{permission}` with `policyPerRole`. */
|
|
135
|
+
readonly policyName?: string;
|
|
136
|
+
/** `rls generate --rbac supabase` defaults; flags override. */
|
|
137
|
+
readonly rbac?: {
|
|
138
|
+
readonly schema?: string;
|
|
139
|
+
readonly authorize?: "database" | "jwt";
|
|
140
|
+
};
|
|
141
|
+
/** The global-roles table `permdock_has` reads in `database` mode. Default `<schema>.user_roles (user_id, role)`, which the helpers create. */
|
|
142
|
+
readonly roles?: GlobalRoles;
|
|
143
|
+
/**
|
|
144
|
+
* The SQL command each action verb compiles to, merged over the defaults
|
|
145
|
+
* (`read`, `list`, `get` → `select`; `create` → `insert`; `update`; `delete`).
|
|
146
|
+
* `'none'` compiles no policy. Every granted action is seeded into
|
|
147
|
+
* `role_permissions` either way, so `permdock_has` answers for it.
|
|
148
|
+
*/
|
|
149
|
+
readonly actions?: RlsActions;
|
|
150
|
+
/** Emit only the helpers, their seeds and the scaffold; the table policies stay hand-written. */
|
|
151
|
+
readonly helpersOnly?: boolean;
|
|
152
|
+
/** `rls migrate`: how existing helper calls map onto the generated helpers. */
|
|
153
|
+
readonly migrate?: RlsMigrateConfig;
|
|
154
|
+
/**
|
|
155
|
+
* Emit a wrapper under each `migrate.helpers` name that answers from the
|
|
156
|
+
* generated helpers, for legacy SQL `rls migrate` leaves alone. `true` puts
|
|
157
|
+
* them in `public`. Off by default; `--shims` turns it on.
|
|
158
|
+
*/
|
|
159
|
+
readonly shims?: boolean | RlsShimsConfig;
|
|
160
|
+
};
|
|
161
|
+
/** `rls.shims`: where the legacy-named wrappers go. */
|
|
162
|
+
type RlsShimsConfig = {
|
|
163
|
+
/** Schema of the legacy helpers. Default `public`. */
|
|
164
|
+
readonly schema?: string;
|
|
165
|
+
};
|
|
166
|
+
/** An action verb's SQL command, or `'none'` for a verb that only `permdock_has` answers. */
|
|
167
|
+
type RlsActions = Readonly<Record<string, "select" | "insert" | "update" | "delete" | "none">>;
|
|
168
|
+
/**
|
|
169
|
+
* One existing SQL helper `rls migrate` rewrites. `form` names its arguments:
|
|
170
|
+
* `ids(key)` returns scope ids, `row(id, key)` and `membership(id)` test one id,
|
|
171
|
+
* `scoped(scope, id, key)` takes the scope as a literal, `global(key)` returns a boolean.
|
|
172
|
+
*/
|
|
173
|
+
type RlsMigrateHelper = {
|
|
174
|
+
readonly form: "ids" | "row" | "membership";
|
|
175
|
+
readonly scope: string;
|
|
176
|
+
} | {
|
|
177
|
+
readonly form: "scoped";
|
|
178
|
+
} | {
|
|
179
|
+
readonly form: "global";
|
|
180
|
+
};
|
|
181
|
+
type RlsMigrateConfig = {
|
|
182
|
+
/** By function name, without the schema. */
|
|
183
|
+
readonly helpers: Readonly<Record<string, RlsMigrateHelper>>;
|
|
184
|
+
/** Exact key renames, checked before `prefixes`. */
|
|
185
|
+
readonly keys?: Readonly<Record<string, string>>;
|
|
186
|
+
/** Key prefix renames, longest first: `{ 'organization.': '' }`. */
|
|
187
|
+
readonly prefixes?: Readonly<Record<string, string>>;
|
|
188
|
+
/** For `scoped` helpers, the scope literals that mean a global check, such as `system`. */
|
|
189
|
+
readonly globalScopes?: readonly string[];
|
|
190
|
+
/** For `scoped` helpers, a scope literal's PermDock scope when the names differ. */
|
|
191
|
+
readonly scopes?: Readonly<Record<string, string>>;
|
|
192
|
+
};
|
|
193
|
+
/**
|
|
194
|
+
* The role column of a global-roles table that holds a foreign key: the role
|
|
195
|
+
* key is `column` of `through`, joined on `on` (`{ role_id: 'id' }`).
|
|
196
|
+
*/
|
|
197
|
+
type RoleThrough = {
|
|
198
|
+
/** The roles table; unqualified, it is in the global-roles table's schema. */
|
|
199
|
+
readonly through: string;
|
|
200
|
+
/** One entry: the global-roles column to the roles table column it references. */
|
|
201
|
+
readonly on: Readonly<Record<string, string>>;
|
|
202
|
+
/** The roles table column that holds the role key. */
|
|
203
|
+
readonly column: string;
|
|
204
|
+
};
|
|
205
|
+
/** Where global roles live: `table (user, role)`. Defaults `user_id` and `role`. */
|
|
206
|
+
type GlobalRoles = {
|
|
207
|
+
readonly table: string;
|
|
208
|
+
readonly user?: string;
|
|
209
|
+
readonly role?: string | RoleThrough;
|
|
210
|
+
};
|
|
211
|
+
/** `permdock supabase hook generate` input. */
|
|
212
|
+
type SupabaseHookConfig = {
|
|
213
|
+
/** The same `fromTable` / `fromJunction` sources the app passes as `memberships`. */
|
|
214
|
+
readonly memberships: readonly SqlMembershipSource[];
|
|
215
|
+
/** Schema of the hook and the version table. Default `rls.schema`, else `permdock`. */
|
|
216
|
+
readonly schema?: string;
|
|
217
|
+
/** Global roles: `user_role` and `roles`. Default `rls.roles`, else the `<schema>.user_roles (user_id, role)` table; `false` for none. */
|
|
218
|
+
readonly roles?: GlobalRoles | false;
|
|
219
|
+
/**
|
|
220
|
+
* Where the active first-scope id comes from: `app_metadata.<key>` (default
|
|
221
|
+
* `app_metadata.active_<first scope>`), `<table>.<column>` joined on `id`, or
|
|
222
|
+
* `{ table, id, column }`.
|
|
223
|
+
*/
|
|
224
|
+
readonly activeFrom?: string | {
|
|
225
|
+
readonly table: string;
|
|
226
|
+
readonly id?: string;
|
|
227
|
+
readonly column: string;
|
|
228
|
+
};
|
|
229
|
+
/**
|
|
230
|
+
* The `attrs` claim, for attribute conditions such as
|
|
231
|
+
* `principal.claims.attrs.region`: allow-listed columns of a server-owned
|
|
232
|
+
* table (`table`, joined on `id`), and `app_metadata.<key>` entries. Never
|
|
233
|
+
* `user_metadata`; the migration fails when clients can write a column.
|
|
234
|
+
*/
|
|
235
|
+
readonly attrs?: {
|
|
236
|
+
readonly table?: string;
|
|
237
|
+
readonly id?: string;
|
|
238
|
+
readonly columns: readonly string[];
|
|
239
|
+
};
|
|
240
|
+
/**
|
|
241
|
+
* Claims other packages own, each `claim: '<schema>.<function>'`, for
|
|
242
|
+
* example `{ features: 'better_supabase.feature_claims' }`. The function
|
|
243
|
+
* takes the user id (`uuid`) and returns `jsonb`; `null` omits the claim.
|
|
244
|
+
* Reserved names are refused, the claims sit outside `budget`, and a
|
|
245
|
+
* suspended user gets none.
|
|
246
|
+
*/
|
|
247
|
+
readonly claims?: Readonly<Record<string, string>>;
|
|
248
|
+
/** Bytes of JSON the `memberships` claim may use. Default `supabaseMembershipsBudget` (1024). */
|
|
249
|
+
readonly budget?: number;
|
|
250
|
+
/** Keep `permdock_authz_version` and write the `authz_ver` claim. Default `true`. */
|
|
251
|
+
readonly version?: boolean;
|
|
252
|
+
/** The `jwt_expiry` the printed `config.toml` block sets. Default 900. */
|
|
253
|
+
readonly jwtExpiry?: number;
|
|
254
|
+
/** Suspended users get empty claims. Default `rls.suspension`. */
|
|
255
|
+
readonly suspension?: RlsSuspension;
|
|
256
|
+
readonly out?: string;
|
|
257
|
+
};
|
|
258
|
+
type SupabaseConfig = {
|
|
259
|
+
readonly hook?: SupabaseHookConfig;
|
|
260
|
+
};
|
|
261
|
+
type DoctorConfig = {
|
|
262
|
+
readonly sensitiveActions?: readonly string[];
|
|
263
|
+
readonly memberships?: string;
|
|
264
|
+
/** A JSON fixture `{ credentials?, settings? }` of API-key credentials and per-tenant settings (the `memorySettings` input) for PD029. */
|
|
265
|
+
readonly credentials?: string;
|
|
266
|
+
/** Globs or directories whose files are client entries for PD001, for frameworks with no `'use client'` convention. */
|
|
267
|
+
readonly clientEntries?: readonly string[];
|
|
268
|
+
/** Globs or directories of SQL migrations PD022 scans for views; defaults to the usual migration folders. */
|
|
269
|
+
readonly migrations?: readonly string[];
|
|
270
|
+
/** A JSON array of sample decoded token claims; PD039 measures each `supabase.hook.claims` entry in it. */
|
|
271
|
+
readonly claims?: string;
|
|
272
|
+
};
|
|
273
|
+
type PermDockConfig = {
|
|
274
|
+
readonly permissions?: string;
|
|
275
|
+
readonly policy?: string;
|
|
276
|
+
readonly collect?: CollectConfig;
|
|
277
|
+
readonly catalog?: CatalogConfig;
|
|
278
|
+
readonly openapi?: {
|
|
279
|
+
readonly doc?: readonly string[];
|
|
280
|
+
};
|
|
281
|
+
readonly rls?: RlsConfig;
|
|
282
|
+
readonly supabase?: SupabaseConfig;
|
|
283
|
+
readonly doctor?: DoctorConfig;
|
|
284
|
+
};
|
|
285
|
+
type CliIo = {
|
|
286
|
+
readonly stdout: (text: string) => void;
|
|
287
|
+
readonly stderr: (text: string) => void;
|
|
288
|
+
readonly now?: () => Date;
|
|
289
|
+
readonly fetch?: typeof fetch;
|
|
290
|
+
readonly env?: Readonly<Record<string, string | undefined>>;
|
|
291
|
+
/** Styled human output; `--no-color` turns it off. Unset is plain. */
|
|
292
|
+
readonly color?: boolean;
|
|
293
|
+
/** A person at a terminal: commands may prompt. Unset never prompts. */
|
|
294
|
+
readonly interactive?: boolean;
|
|
295
|
+
};
|
|
296
|
+
type RunResult = {
|
|
297
|
+
readonly code: 0 | 1 | 2;
|
|
298
|
+
readonly stdout: string;
|
|
299
|
+
readonly stderr: string;
|
|
300
|
+
};
|
|
301
|
+
type PermDockPluginOptions = {
|
|
302
|
+
readonly collect?: CollectConfig;
|
|
303
|
+
readonly onDrift?: "error" | "warn";
|
|
304
|
+
/**
|
|
305
|
+
* Unplugin only: compare instead of write in `buildStart`, failing the
|
|
306
|
+
* build on drift (as `permdock collect --check` does). The Next plugin
|
|
307
|
+
* checks in `phase-production-build` unless `PERMDOCK_COLLECT=write`.
|
|
308
|
+
*/
|
|
309
|
+
readonly check?: boolean;
|
|
310
|
+
};
|
|
311
|
+
//#endregion
|
|
312
|
+
export { PermDockPluginOptions as a, RlsDialect as c, RlsMemberships as d, RlsSuspension as f, PermDockConfig as i, RlsFunctionMapping as l, RunResult as m, CliIo as n, RlsActiveRow as o, RlsTarget as p, CollectConfig as r, RlsConfig as s, CatalogConfig as t, RlsMembershipTable as u };
|