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,16 @@
|
|
|
1
|
+
import { t as packageRoot } from "./package-root-zGkxO3oN.js";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
//#region src/cli/version.ts
|
|
5
|
+
function cliVersion() {
|
|
6
|
+
return JSON.parse(readFileSync(join(packageRoot(), "package.json"), "utf8")).version;
|
|
7
|
+
}
|
|
8
|
+
function generatorBanner() {
|
|
9
|
+
return `permdock@${cliVersion()}`;
|
|
10
|
+
}
|
|
11
|
+
const CATALOG_SCHEMA = "https://permdock.dev/schemas/catalog-v1.json";
|
|
12
|
+
const SUPABASE_MANIFEST_SCHEMA = "https://permdock.dev/schemas/supabase-manifest-v1.json";
|
|
13
|
+
const USAGE_REPORT_SCHEMA = "https://permdock.dev/schemas/usage-report-v1.json";
|
|
14
|
+
const DOCTOR_REPORT_SCHEMA = "https://permdock.dev/schemas/doctor-report-v1.json";
|
|
15
|
+
//#endregion
|
|
16
|
+
export { cliVersion as a, USAGE_REPORT_SCHEMA as i, DOCTOR_REPORT_SCHEMA as n, generatorBanner as o, SUPABASE_MANIFEST_SCHEMA as r, CATALOG_SCHEMA as t };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { n as ActionMeta } from "./permissions-B4apnahQ.js";
|
|
2
|
+
//#region src/core/vocabulary.d.ts
|
|
3
|
+
declare const ROLE_KIND: "role";
|
|
4
|
+
declare const PLAN_KIND: "plan";
|
|
5
|
+
/**
|
|
6
|
+
* A role's metadata. `audience` names the surface its holders use (`'staff'`,
|
|
7
|
+
* `'portal'`, `'platform'`); `permdock.audiences()` lists the distinct
|
|
8
|
+
* audiences of the roles held in the active scope.
|
|
9
|
+
*/
|
|
10
|
+
type RoleMeta = ActionMeta & {
|
|
11
|
+
readonly audience?: string;
|
|
12
|
+
};
|
|
13
|
+
type Role<K extends string = string> = {
|
|
14
|
+
readonly key: K;
|
|
15
|
+
/** A declared scope name, or the `tenant` / `team` alias. */
|
|
16
|
+
readonly on?: string;
|
|
17
|
+
readonly assignable: boolean;
|
|
18
|
+
readonly meta: RoleMeta;
|
|
19
|
+
readonly kind: typeof ROLE_KIND;
|
|
20
|
+
};
|
|
21
|
+
type Plan<K extends string = string> = {
|
|
22
|
+
readonly key: K;
|
|
23
|
+
readonly meta: ActionMeta;
|
|
24
|
+
readonly kind: typeof PLAN_KIND;
|
|
25
|
+
};
|
|
26
|
+
type RoleInit = {
|
|
27
|
+
/** A declared scope name, or the `tenant` / `team` alias. */
|
|
28
|
+
readonly on?: string;
|
|
29
|
+
readonly assignable?: boolean;
|
|
30
|
+
readonly meta?: RoleMeta;
|
|
31
|
+
};
|
|
32
|
+
type PlanInit = {
|
|
33
|
+
readonly meta?: ActionMeta;
|
|
34
|
+
};
|
|
35
|
+
type RoleTree = {
|
|
36
|
+
readonly [key: string]: Role;
|
|
37
|
+
};
|
|
38
|
+
type PlanTree = {
|
|
39
|
+
readonly [key: string]: Plan;
|
|
40
|
+
};
|
|
41
|
+
type Vocabulary = {
|
|
42
|
+
readonly permissions?: unknown;
|
|
43
|
+
readonly roles?: RoleTree;
|
|
44
|
+
readonly plans?: PlanTree;
|
|
45
|
+
};
|
|
46
|
+
type InferRoleTree<Input> = { readonly [K in keyof Input & string]: Role<K>; };
|
|
47
|
+
type InferPlanTree<Input> = { readonly [K in keyof Input & string]: Plan<K>; };
|
|
48
|
+
declare function isRole(value: unknown): value is Role;
|
|
49
|
+
declare function isPlan(value: unknown): value is Plan;
|
|
50
|
+
declare function defineRoles<const Input extends Record<string, RoleInit>>(input: Input): InferRoleTree<Input>;
|
|
51
|
+
declare function definePlans<const Input extends Record<string, PlanInit>>(input: Input): InferPlanTree<Input>;
|
|
52
|
+
declare function listRoles(tree: RoleTree | undefined): readonly Role[];
|
|
53
|
+
declare function listPlans(tree: PlanTree | undefined): readonly Plan[];
|
|
54
|
+
declare function findRole(tree: RoleTree | undefined, key: string): Role | undefined;
|
|
55
|
+
//#endregion
|
|
56
|
+
export { RoleTree as a, defineRoles as c, isRole as d, listPlans as f, RoleMeta as i, findRole as l, PlanTree as n, Vocabulary as o, listRoles as p, Role as r, definePlans as s, Plan as t, isPlan as u };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Et as TokenVerifier, Mn as Decision, gt as Snapshot, pr as Membership } from "../policy-CInmNGkM.js";
|
|
2
|
+
import { d as Permission } from "../permissions-B4apnahQ.js";
|
|
3
|
+
import { r as Role } from "../vocabulary-Dk0fs-Jk.js";
|
|
4
|
+
import { a as requiredPlans, i as describe } from "../describe-DernyItf.js";
|
|
5
|
+
import { t as approvalHeaders } from "../headers-C8SHQccD.js";
|
|
6
|
+
import { a as FilterResult, c as PermissionState, d as TenantView, f as UseRolesOptions, i as ClientStatus, n as ApprovalState, r as ClientPermDock, s as PermissionSet, t as ApprovalHandle, u as SubjectView } from "../types-DbWdEfcm.js";
|
|
7
|
+
import { ComputedRef, DefineComponent, MaybeRefOrGetter, Plugin } from "vue";
|
|
8
|
+
//#region src/vue/types.d.ts
|
|
9
|
+
type PermDockPluginOptions = {
|
|
10
|
+
/**
|
|
11
|
+
* A ref or getter re-hydrates the store when it changes; a promise keeps
|
|
12
|
+
* the store `pending` until it settles (await the same promise in an async
|
|
13
|
+
* `setup` under `<Suspense>`).
|
|
14
|
+
*/
|
|
15
|
+
readonly snapshot: MaybeRefOrGetter<Snapshot | string> | PromiseLike<Snapshot | string>;
|
|
16
|
+
readonly endpoint?: string;
|
|
17
|
+
readonly approvals?: string;
|
|
18
|
+
readonly tenant?: string;
|
|
19
|
+
readonly fetch?: typeof fetch;
|
|
20
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
21
|
+
readonly maxAge?: number;
|
|
22
|
+
readonly verifier?: TokenVerifier;
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/vue/composables.d.ts
|
|
26
|
+
export declare function usePermDock(): ClientPermDock;
|
|
27
|
+
export declare function usePermission(permission: MaybeRefOrGetter<Permission>, data?: MaybeRefOrGetter<unknown>): {
|
|
28
|
+
readonly allowed: ComputedRef<boolean>;
|
|
29
|
+
readonly status: ComputedRef<PermissionState["status"]>;
|
|
30
|
+
readonly decision: ComputedRef<Decision>;
|
|
31
|
+
};
|
|
32
|
+
export declare function usePermissions(permissions: MaybeRefOrGetter<readonly Permission[]>, data?: MaybeRefOrGetter<unknown>): ComputedRef<PermissionSet>;
|
|
33
|
+
export declare function useFilter<T>(permission: Permission<string, T, "instance">, rows: MaybeRefOrGetter<readonly T[]>): ComputedRef<FilterResult<T>>;
|
|
34
|
+
export declare function useTenant(): ComputedRef<TenantView>;
|
|
35
|
+
export declare function useMemberships(): ComputedRef<readonly Membership[]>;
|
|
36
|
+
export declare function useRoles(options?: MaybeRefOrGetter<UseRolesOptions>): ComputedRef<{
|
|
37
|
+
readonly roles: readonly Role[];
|
|
38
|
+
}>;
|
|
39
|
+
export declare function useAssignableRoles(): ComputedRef<readonly Role[]>;
|
|
40
|
+
export declare function useAssignablePermissions(options?: {
|
|
41
|
+
readonly tenant?: string;
|
|
42
|
+
}): ComputedRef<readonly Permission[]>;
|
|
43
|
+
export declare function useSubject(): ComputedRef<SubjectView>;
|
|
44
|
+
export declare function useApproval(decision: MaybeRefOrGetter<Decision>): ComputedRef<ApprovalHandle>;
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/vue/plugin.d.ts
|
|
47
|
+
export declare const permdockPlugin: Plugin<PermDockPluginOptions>;
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/vue/protected.d.ts
|
|
50
|
+
type ProtectedProps = {
|
|
51
|
+
readonly permission: Permission;
|
|
52
|
+
readonly data?: unknown;
|
|
53
|
+
readonly tenant?: string;
|
|
54
|
+
};
|
|
55
|
+
export declare const Protected: DefineComponent<ProtectedProps>;
|
|
56
|
+
//#endregion
|
|
57
|
+
export { type ApprovalHandle, type ApprovalState, type ClientPermDock, type ClientStatus, type FilterResult, type PermDockPluginOptions, type PermissionSet, type PermissionState, type SubjectView, type TenantView, type UseRolesOptions, approvalHeaders, describe, requiredPlans };
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { t as compact } from "../compact-y6vfu2_f.js";
|
|
2
|
+
import { n as requiredPlans, t as describe } from "../describe-Bt1YD5uS.js";
|
|
3
|
+
import { t as emptySnapshot } from "../from-snapshot-BMGnhmgv.js";
|
|
4
|
+
import { t as approvalHeaders } from "../headers-B5RRv3Xm.js";
|
|
5
|
+
import { t as createClientStore } from "../store-C6hFW6ta.js";
|
|
6
|
+
import { t as isPromiseLike } from "../source-DoBBYJi2.js";
|
|
7
|
+
import { computed, defineComponent, effectScope, inject, isRef, onScopeDispose, shallowRef, toValue, watch } from "vue";
|
|
8
|
+
//#region src/vue/context.ts
|
|
9
|
+
const permDockKey = Symbol("permdock");
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/vue/composables.ts
|
|
12
|
+
function useStore() {
|
|
13
|
+
const store = inject(permDockKey);
|
|
14
|
+
if (store === void 0) throw new Error("PermDock: composables require permdockPlugin.");
|
|
15
|
+
return store;
|
|
16
|
+
}
|
|
17
|
+
function useTick(store) {
|
|
18
|
+
const tick = shallowRef(0);
|
|
19
|
+
onScopeDispose(store.subscribe(() => {
|
|
20
|
+
tick.value += 1;
|
|
21
|
+
}));
|
|
22
|
+
return computed(() => {
|
|
23
|
+
tick.value;
|
|
24
|
+
return store.get();
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function usePermDock() {
|
|
28
|
+
const permdock = useTick(useStore());
|
|
29
|
+
return new Proxy({}, { get(_target, prop, _receiver) {
|
|
30
|
+
return Reflect.get(permdock.value, prop);
|
|
31
|
+
} });
|
|
32
|
+
}
|
|
33
|
+
function usePermission(permission, data) {
|
|
34
|
+
const store = useStore();
|
|
35
|
+
const permdock = useTick(store);
|
|
36
|
+
const state = computed(() => {
|
|
37
|
+
permdock.value;
|
|
38
|
+
return store.permissionState(toValue(permission), toValue(data));
|
|
39
|
+
});
|
|
40
|
+
return {
|
|
41
|
+
allowed: computed(() => state.value.allowed),
|
|
42
|
+
status: computed(() => state.value.status),
|
|
43
|
+
decision: computed(() => state.value.decision)
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function usePermissions(permissions, data) {
|
|
47
|
+
const store = useStore();
|
|
48
|
+
const permdock = useTick(store);
|
|
49
|
+
return computed(() => {
|
|
50
|
+
permdock.value;
|
|
51
|
+
const granted = [];
|
|
52
|
+
const byKey = {};
|
|
53
|
+
for (const permission of toValue(permissions)) {
|
|
54
|
+
const next = store.permissionState(permission, toValue(data));
|
|
55
|
+
byKey[permission.key] = next;
|
|
56
|
+
if (next.allowed) granted.push(permission);
|
|
57
|
+
}
|
|
58
|
+
return new Proxy({
|
|
59
|
+
granted,
|
|
60
|
+
get(permission) {
|
|
61
|
+
return byKey[permission.key];
|
|
62
|
+
}
|
|
63
|
+
}, { get(target, prop, receiver) {
|
|
64
|
+
if (typeof prop === "string" && Object.hasOwn(byKey, prop)) return byKey[prop];
|
|
65
|
+
return Reflect.get(target, prop, receiver);
|
|
66
|
+
} });
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
function useFilter(permission, rows) {
|
|
70
|
+
const permdock = useTick(useStore());
|
|
71
|
+
return computed(() => {
|
|
72
|
+
const result = [...permdock.value.filter(permission, toValue(rows))];
|
|
73
|
+
result.partial = permdock.value.where(permission).partial;
|
|
74
|
+
return result;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
function useTenant() {
|
|
78
|
+
const permdock = useTick(useStore());
|
|
79
|
+
return computed(() => ({
|
|
80
|
+
tenant: permdock.value.subject.principal?.tenant ?? null,
|
|
81
|
+
tenants: permdock.value.tenants(),
|
|
82
|
+
switchTo: (id) => permdock.value.refresh({ tenant: id }),
|
|
83
|
+
status: permdock.value.status()
|
|
84
|
+
}));
|
|
85
|
+
}
|
|
86
|
+
function useMemberships() {
|
|
87
|
+
const permdock = useTick(useStore());
|
|
88
|
+
return computed(() => permdock.value.memberships());
|
|
89
|
+
}
|
|
90
|
+
function useRoles(options = {}) {
|
|
91
|
+
const permdock = useTick(useStore());
|
|
92
|
+
return computed(() => {
|
|
93
|
+
const next = toValue(options);
|
|
94
|
+
return { roles: (next.team === void 0 ? permdock.value : permdock.value.team(next.team)).heldRoles(next.tenant === void 0 ? void 0 : { tenant: next.tenant }) };
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
function useAssignableRoles() {
|
|
98
|
+
const permdock = useTick(useStore());
|
|
99
|
+
return computed(() => permdock.value.assignableRoles());
|
|
100
|
+
}
|
|
101
|
+
function useAssignablePermissions(options = {}) {
|
|
102
|
+
const permdock = useTick(useStore());
|
|
103
|
+
return computed(() => permdock.value.assignablePermissions(options));
|
|
104
|
+
}
|
|
105
|
+
function useSubject() {
|
|
106
|
+
const permdock = useTick(useStore());
|
|
107
|
+
return computed(() => {
|
|
108
|
+
const snapshot = permdock.value.snapshot();
|
|
109
|
+
const simulated = typeof snapshot === "object" && snapshot !== null && "simulated" in snapshot && snapshot.simulated === true;
|
|
110
|
+
return {
|
|
111
|
+
principal: permdock.value.subject.principal,
|
|
112
|
+
actor: permdock.value.subject.actor,
|
|
113
|
+
delegation: permdock.value.subject.delegation,
|
|
114
|
+
expiresAt: permdock.value.subject.expiresAt,
|
|
115
|
+
simulated
|
|
116
|
+
};
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
function useApproval(decision) {
|
|
120
|
+
const store = useStore();
|
|
121
|
+
const permdock = useTick(store);
|
|
122
|
+
return computed(() => {
|
|
123
|
+
permdock.value;
|
|
124
|
+
const next = toValue(decision);
|
|
125
|
+
return {
|
|
126
|
+
state: store.approvalState(next),
|
|
127
|
+
token: next.outcome === "approval-required" ? next.token : void 0,
|
|
128
|
+
request: (note) => store.requestApproval(next, note)
|
|
129
|
+
};
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region src/vue/plugin.ts
|
|
134
|
+
const permdockPlugin = { install(app, options) {
|
|
135
|
+
const source = options.snapshot;
|
|
136
|
+
const promised = isPromiseLike(source);
|
|
137
|
+
const store = createClientStore(compact({
|
|
138
|
+
snapshot: promised ? emptySnapshot() : toValue(source),
|
|
139
|
+
endpoint: options.endpoint,
|
|
140
|
+
approvals: options.approvals,
|
|
141
|
+
tenant: options.tenant,
|
|
142
|
+
fetch: options.fetch,
|
|
143
|
+
headers: options.headers,
|
|
144
|
+
maxAge: options.maxAge,
|
|
145
|
+
verifier: options.verifier
|
|
146
|
+
}));
|
|
147
|
+
if (promised) store.follow(source);
|
|
148
|
+
else if (isRef(source) || typeof source === "function") {
|
|
149
|
+
const scope = effectScope(true);
|
|
150
|
+
scope.run(() => {
|
|
151
|
+
watch(() => toValue(source), (next) => {
|
|
152
|
+
store.replace(next);
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
app.onUnmount(() => {
|
|
156
|
+
scope.stop();
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
app.provide(permDockKey, store);
|
|
160
|
+
} };
|
|
161
|
+
//#endregion
|
|
162
|
+
//#region src/vue/protected.ts
|
|
163
|
+
const Protected = defineComponent({
|
|
164
|
+
name: "Protected",
|
|
165
|
+
props: {
|
|
166
|
+
permission: {
|
|
167
|
+
type: Object,
|
|
168
|
+
required: true
|
|
169
|
+
},
|
|
170
|
+
data: {
|
|
171
|
+
type: Object,
|
|
172
|
+
required: false
|
|
173
|
+
},
|
|
174
|
+
tenant: {
|
|
175
|
+
type: String,
|
|
176
|
+
required: false
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
setup(props, { slots }) {
|
|
180
|
+
const local = usePermission(() => props.permission, () => props.data);
|
|
181
|
+
const root = usePermDock();
|
|
182
|
+
return () => {
|
|
183
|
+
const scoped = props.tenant === void 0 ? {
|
|
184
|
+
allowed: local.allowed.value,
|
|
185
|
+
status: local.status.value,
|
|
186
|
+
decision: local.decision.value
|
|
187
|
+
} : tenantView(root.tenant(props.tenant), props.permission, props.data);
|
|
188
|
+
if (scoped.status === "pending") return slots["pending"]?.() ?? null;
|
|
189
|
+
if (!scoped.allowed || scoped.decision.outcome !== "granted") return slots["fallback"]?.({ decision: scoped.decision }) ?? null;
|
|
190
|
+
return slots["default"]?.({ decision: scoped.decision }) ?? null;
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
function tenantView(permdock, permission, data) {
|
|
195
|
+
const decision = permdock.decide(permission, data);
|
|
196
|
+
return {
|
|
197
|
+
allowed: decision.outcome === "granted",
|
|
198
|
+
status: "ready",
|
|
199
|
+
decision
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
//#endregion
|
|
203
|
+
export { Protected, approvalHeaders, describe, permdockPlugin, requiredPlans, useApproval, useAssignablePermissions, useAssignableRoles, useFilter, useMemberships, usePermDock, usePermission, usePermissions, useRoles, useSubject, useTenant };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Mn as Decision, gt as Snapshot } from "../policy-CInmNGkM.js";
|
|
2
|
+
import { d as Permission, p as PermissionTree } from "../permissions-B4apnahQ.js";
|
|
3
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
4
|
+
//#region src/webmcp/types.d.ts
|
|
5
|
+
type WebMcpClientStatus = "ready" | "pending" | "stale" | "server-only";
|
|
6
|
+
type WebMcpPermDock = {
|
|
7
|
+
can(permission: Permission, data?: unknown): boolean;
|
|
8
|
+
decide(permission: Permission, data?: unknown): Decision;
|
|
9
|
+
snapshot(): Snapshot | string | Promise<Snapshot | string>;
|
|
10
|
+
tenant?(id: string): WebMcpPermDock;
|
|
11
|
+
subscribe?(listener: () => void): () => void;
|
|
12
|
+
status?(permission?: Permission, data?: unknown): WebMcpClientStatus;
|
|
13
|
+
};
|
|
14
|
+
type WebMcpToolContent = {
|
|
15
|
+
readonly type: "text";
|
|
16
|
+
readonly text: string;
|
|
17
|
+
};
|
|
18
|
+
type WebMcpToolResult = {
|
|
19
|
+
readonly isError?: boolean;
|
|
20
|
+
readonly content: readonly WebMcpToolContent[];
|
|
21
|
+
readonly structuredContent?: Readonly<Record<string, unknown>>;
|
|
22
|
+
};
|
|
23
|
+
type WebMcpToolCall = {
|
|
24
|
+
/** Validated arguments with the tenant key bound. */
|
|
25
|
+
readonly input: unknown;
|
|
26
|
+
/** The decision token; send it as `PermDock-Approval` so the server resumes. */
|
|
27
|
+
readonly token: string | undefined;
|
|
28
|
+
};
|
|
29
|
+
type WebMcpToolHandler = (call: WebMcpToolCall) => Promise<unknown>;
|
|
30
|
+
type WebMcpToolAnnotations = {
|
|
31
|
+
readonly readOnlyHint?: boolean;
|
|
32
|
+
readonly untrustedContentHint?: boolean;
|
|
33
|
+
};
|
|
34
|
+
type WebMcpRegisteredTool = {
|
|
35
|
+
readonly name: string;
|
|
36
|
+
readonly title?: string;
|
|
37
|
+
readonly description?: string;
|
|
38
|
+
readonly inputSchema?: Readonly<Record<string, unknown>>;
|
|
39
|
+
readonly annotations?: WebMcpToolAnnotations;
|
|
40
|
+
execute(input: unknown): Promise<WebMcpToolResult>;
|
|
41
|
+
};
|
|
42
|
+
type ModelContext = {
|
|
43
|
+
registerTool(tool: WebMcpRegisteredTool, options?: {
|
|
44
|
+
readonly signal?: AbortSignal;
|
|
45
|
+
}): {
|
|
46
|
+
readonly unregister?: () => void;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
type WebMcpApprovalRequest = {
|
|
50
|
+
readonly permission: Permission;
|
|
51
|
+
readonly decision: Extract<Decision, {
|
|
52
|
+
readonly outcome: "approval-required";
|
|
53
|
+
}>;
|
|
54
|
+
readonly input: unknown;
|
|
55
|
+
};
|
|
56
|
+
type RegisterToolsOptions = {
|
|
57
|
+
readonly permdock: WebMcpPermDock;
|
|
58
|
+
readonly handlers?: Readonly<Record<string, WebMcpToolHandler>>;
|
|
59
|
+
readonly signal?: AbortSignal;
|
|
60
|
+
readonly tenant?: string;
|
|
61
|
+
readonly tenantKey?: string;
|
|
62
|
+
readonly schema?: StandardSchemaV1;
|
|
63
|
+
readonly untrustedContentHint?: boolean;
|
|
64
|
+
readonly onApprovalRequired?: (request: WebMcpApprovalRequest) => Promise<boolean | undefined>;
|
|
65
|
+
readonly warn?: (message: string) => void;
|
|
66
|
+
};
|
|
67
|
+
type RegisterToolsHandle = {
|
|
68
|
+
readonly unregister: () => void;
|
|
69
|
+
};
|
|
70
|
+
type PermissionGroup = PermissionTree | Permission;
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/webmcp/register.d.ts
|
|
73
|
+
export declare function registerTools(modelContext: ModelContext | null | undefined, group: PermissionGroup, options: RegisterToolsOptions): RegisterToolsHandle;
|
|
74
|
+
//#endregion
|
|
75
|
+
export type { ModelContext, PermissionGroup, RegisterToolsHandle, RegisterToolsOptions, WebMcpApprovalRequest, WebMcpClientStatus, WebMcpPermDock, WebMcpRegisteredTool, WebMcpToolAnnotations, WebMcpToolCall, WebMcpToolHandler, WebMcpToolResult };
|