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,195 @@
|
|
|
1
|
+
import { t as compact } from "../compact-y6vfu2_f.js";
|
|
2
|
+
import { t as createPermDock$1 } from "../permdock-yoZ7EjxX.js";
|
|
3
|
+
import { t as emptySnapshot } from "../from-snapshot-BMGnhmgv.js";
|
|
4
|
+
import { n as createEvaluationsHandler } from "../evaluations-DsAU9ppl.js";
|
|
5
|
+
import { cache } from "react";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
import { io } from "next/cache";
|
|
8
|
+
import { forbidden, unauthorized, unstable_rethrow } from "next/navigation";
|
|
9
|
+
import { after } from "next/server";
|
|
10
|
+
import { PermDockProvider } from "../react/provider-client.js";
|
|
11
|
+
//#region src/next/cache-life.ts
|
|
12
|
+
/**
|
|
13
|
+
* `{ stale }` for `cacheLife()` inside an app-owned `'use cache: private'` function: `max` when the
|
|
14
|
+
* value never expires, otherwise the seconds left, clamped to `[min, max]`. A value with less than
|
|
15
|
+
* `min` seconds left gets its real remainder, so Next.js leaves it out of prefetches instead of
|
|
16
|
+
* serving it past `expiresAt`.
|
|
17
|
+
*/
|
|
18
|
+
function cacheLifeFor(value, options = {}) {
|
|
19
|
+
const min = options.min ?? 30;
|
|
20
|
+
const max = Math.max(options.max ?? 300, min);
|
|
21
|
+
const expiresAt = value?.expiresAt;
|
|
22
|
+
if (expiresAt === void 0 || expiresAt === null) return { stale: max };
|
|
23
|
+
const issuedAt = value?.issuedAt !== void 0 && value.issuedAt > 0 ? value.issuedAt : void 0;
|
|
24
|
+
const now = options.now ?? issuedAt ?? Math.floor(Date.now() / 1e3);
|
|
25
|
+
const remaining = Math.floor(expiresAt - now);
|
|
26
|
+
if (remaining < min) return { stale: Math.max(0, remaining) };
|
|
27
|
+
return { stale: Math.min(max, remaining) };
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/next/provider.tsx
|
|
31
|
+
function renderClientProvider(options) {
|
|
32
|
+
return /* @__PURE__ */ jsx(PermDockProvider, {
|
|
33
|
+
...compact({
|
|
34
|
+
snapshotPromise: options.snapshotPromise,
|
|
35
|
+
endpoint: options.endpoint,
|
|
36
|
+
tenant: options.tenant
|
|
37
|
+
}),
|
|
38
|
+
children: options.children
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/next/create.ts
|
|
43
|
+
const DENIED = {
|
|
44
|
+
outcome: "denied",
|
|
45
|
+
denials: [{
|
|
46
|
+
role: null,
|
|
47
|
+
reason: "no-grant"
|
|
48
|
+
}],
|
|
49
|
+
alternatives: []
|
|
50
|
+
};
|
|
51
|
+
function assertServerOnly() {
|
|
52
|
+
if (globalThis.document !== void 0) throw new TypeError("permdock/next is server-only. Import hooks and Protected from permdock/react.");
|
|
53
|
+
}
|
|
54
|
+
async function readTenant(tenant) {
|
|
55
|
+
if (tenant === void 0 || typeof tenant === "string") return tenant;
|
|
56
|
+
try {
|
|
57
|
+
return await tenant();
|
|
58
|
+
} catch (error) {
|
|
59
|
+
unstable_rethrow(error);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/** False outside a request or prerender scope, where `after()` throws. */
|
|
64
|
+
function defer(task) {
|
|
65
|
+
try {
|
|
66
|
+
after(task);
|
|
67
|
+
return true;
|
|
68
|
+
} catch {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function ignore() {}
|
|
73
|
+
/**
|
|
74
|
+
* Keeps the function alive until the sink has written and flushed: every
|
|
75
|
+
* pending write and one `flush()` per render run in `after()`, so serverless
|
|
76
|
+
* runtimes do not freeze with events still buffered.
|
|
77
|
+
*/
|
|
78
|
+
function afterResponse(sink) {
|
|
79
|
+
const flush = sink.flush?.bind(sink);
|
|
80
|
+
const scheduleFlush = cache(() => flush === void 0 ? false : defer(flush));
|
|
81
|
+
return {
|
|
82
|
+
write(events) {
|
|
83
|
+
const written = sink.write(events);
|
|
84
|
+
if (written !== void 0) defer(Promise.resolve(written).then(ignore, ignore));
|
|
85
|
+
scheduleFlush();
|
|
86
|
+
return written;
|
|
87
|
+
},
|
|
88
|
+
...flush === void 0 ? {} : { flush }
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function wrapInstance(permdock, onDenied) {
|
|
92
|
+
if (onDenied === void 0) return permdock;
|
|
93
|
+
const assert = ((permission, data, options) => permdock.assert(permission, data, compact({
|
|
94
|
+
...options,
|
|
95
|
+
onDenied: options?.onDenied ?? onDenied
|
|
96
|
+
})));
|
|
97
|
+
return {
|
|
98
|
+
...permdock,
|
|
99
|
+
assert
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function createPermDock(policy, options) {
|
|
103
|
+
assertServerOnly();
|
|
104
|
+
const sink = options.sink === void 0 ? void 0 : afterResponse(options.sink);
|
|
105
|
+
const resolveSubject = cache(async () => {
|
|
106
|
+
try {
|
|
107
|
+
return await options.subject();
|
|
108
|
+
} catch (error) {
|
|
109
|
+
unstable_rethrow(error);
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
const resolveFallbackTenant = cache(() => readTenant(options.tenant));
|
|
114
|
+
const instantiate = cache(async (tenantKey) => {
|
|
115
|
+
const tenant = tenantKey === "" ? void 0 : tenantKey;
|
|
116
|
+
const user = await resolveSubject();
|
|
117
|
+
await io();
|
|
118
|
+
const built = await createPermDock$1(policy, user, compact({
|
|
119
|
+
tenant,
|
|
120
|
+
memberships: options.memberships,
|
|
121
|
+
relations: options.relations,
|
|
122
|
+
entitlements: options.entitlements,
|
|
123
|
+
customRoles: options.customRoles,
|
|
124
|
+
policies: options.policies,
|
|
125
|
+
sink,
|
|
126
|
+
limits: options.limits
|
|
127
|
+
}));
|
|
128
|
+
return wrapInstance(options.otel === void 0 ? built : options.otel(built), options.onDenied);
|
|
129
|
+
});
|
|
130
|
+
const getPermDock = async (query) => {
|
|
131
|
+
const tenant = query?.tenant ?? await resolveFallbackTenant();
|
|
132
|
+
return instantiate(tenant ?? "");
|
|
133
|
+
};
|
|
134
|
+
const getPermission = async (permission, data) => {
|
|
135
|
+
try {
|
|
136
|
+
const decision = (await getPermDock()).decide(permission, data);
|
|
137
|
+
return {
|
|
138
|
+
allowed: decision.outcome === "granted",
|
|
139
|
+
status: "ready",
|
|
140
|
+
decision
|
|
141
|
+
};
|
|
142
|
+
} catch {
|
|
143
|
+
return {
|
|
144
|
+
allowed: false,
|
|
145
|
+
status: "ready",
|
|
146
|
+
decision: DENIED
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
const requireAccess = async (input) => {
|
|
151
|
+
const permdock = await getPermDock(input.tenant === void 0 ? void 0 : { tenant: input.tenant });
|
|
152
|
+
const assert = permdock.assert;
|
|
153
|
+
return assert(input.permission, input.data, { onDenied: (decision) => {
|
|
154
|
+
if (decision.outcome !== "denied" || decision.denials.some((denial) => denial.reason === "validation")) return;
|
|
155
|
+
if (permdock.subject.principal === null) unauthorized();
|
|
156
|
+
forbidden();
|
|
157
|
+
} });
|
|
158
|
+
};
|
|
159
|
+
const PermDockProvider = (props) => {
|
|
160
|
+
const snapshotPromise = getPermDock(props.tenant === void 0 ? void 0 : { tenant: props.tenant }).then((permdock) => permdock.snapshot(compact({
|
|
161
|
+
include: props.include,
|
|
162
|
+
tenants: props.tenants
|
|
163
|
+
}))).catch(() => emptySnapshot());
|
|
164
|
+
return renderClientProvider(compact({
|
|
165
|
+
snapshotPromise,
|
|
166
|
+
endpoint: props.endpoint ?? options.endpoint ?? "/api/permdock",
|
|
167
|
+
tenant: props.tenant,
|
|
168
|
+
children: props.children
|
|
169
|
+
}));
|
|
170
|
+
};
|
|
171
|
+
const permdockHandler = () => createEvaluationsHandler(compact({
|
|
172
|
+
policy,
|
|
173
|
+
getPermDock,
|
|
174
|
+
store: options.store
|
|
175
|
+
}));
|
|
176
|
+
return {
|
|
177
|
+
getPermDock,
|
|
178
|
+
getPermission,
|
|
179
|
+
requireAccess,
|
|
180
|
+
PermDockProvider,
|
|
181
|
+
permdockHandler
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
//#endregion
|
|
185
|
+
//#region src/next/snapshot-tag.ts
|
|
186
|
+
/**
|
|
187
|
+
* The `cacheTag` for one subject's cached snapshots: `permdock:<sub>`, or `permdock:anon`
|
|
188
|
+
* without a subject. Tag the private cache with it and pass it to `updateTag` or
|
|
189
|
+
* `revalidateTag` on every write that changes the subject's snapshot.
|
|
190
|
+
*/
|
|
191
|
+
function snapshotTag(sub) {
|
|
192
|
+
return `permdock:${sub === void 0 || sub === null || sub === "" ? "anon" : sub}`;
|
|
193
|
+
}
|
|
194
|
+
//#endregion
|
|
195
|
+
export { cacheLifeFor, createPermDock, snapshotTag };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { a as PermDockPluginOptions } from "../types-D6Z6-rKJ.js";
|
|
2
|
+
//#region src/cli/plugin.d.ts
|
|
3
|
+
/** Any object: Next's `NextConfig` is an interface, so no index signature. */
|
|
4
|
+
type NextConfigLike = object;
|
|
5
|
+
/** What `next.config` may export: an object, or a function of the phase. */
|
|
6
|
+
type NextConfigInput<T extends NextConfigLike> = T | ((phase: string, context: NextConfigContext) => T | Promise<T>);
|
|
7
|
+
type NextConfigContext = {
|
|
8
|
+
readonly defaultConfig?: unknown;
|
|
9
|
+
};
|
|
10
|
+
/** Next's config function: Next calls it with the phase constant. */
|
|
11
|
+
type NextConfigFunction<T extends NextConfigLike> = (phase: string, context: NextConfigContext) => Promise<T>;
|
|
12
|
+
export declare function createPermDockPlugin(options?: PermDockPluginOptions): <T extends NextConfigLike>(nextConfig: NextConfigInput<T>) => NextConfigFunction<T>;
|
|
13
|
+
//#endregion
|
|
14
|
+
export type { NextConfigContext, NextConfigFunction, NextConfigInput, NextConfigLike, PermDockPluginOptions };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { $ as DecisionSink, C as Policy, E as PolicyVocabulary, Zt as PermDock, at as LimitStore, ct as MembershipSource, ft as RelationSource, mr as Principal, pt as RoleSource, sn as PolicySource, tt as EntitlementSource, xt as SnapshotSource } from "../policy-CInmNGkM.js";
|
|
2
|
+
import { d as Permission } from "../permissions-B4apnahQ.js";
|
|
3
|
+
import { f as ApprovalStore } from "../types-B8w5PFtS.js";
|
|
4
|
+
import { o as OtelWrap } from "../types-B9dmiiab.js";
|
|
5
|
+
import { r as PdpFactory } from "../types-BvBk1wgn.js";
|
|
6
|
+
import { g as discoverViaSignatureAgent, h as WebBotAuthVerifier, n as OpenApiHooks, o as TenantOption, r as ProtectOptions, t as Guard, u as InvalidSignatureError, y as verifyWebBotAuth } from "../create-BKF3dgFk.js";
|
|
7
|
+
import { a as toRequest, i as sendResponse, n as fromResponse, r as isServerResponse, t as NodeRequest } from "../http-DPuDaChb.js";
|
|
8
|
+
import { IncomingMessage, ServerResponse } from "node:http";
|
|
9
|
+
//#region src/node/create.d.ts
|
|
10
|
+
type NodePermDockOptions<TUser = unknown> = {
|
|
11
|
+
readonly subject: (req: NodeRequest) => TUser | Promise<TUser>;
|
|
12
|
+
readonly tenant?: TenantOption<NodeRequest>;
|
|
13
|
+
readonly memberships?: MembershipSource | readonly MembershipSource[];
|
|
14
|
+
/** The object graph for relation grants that walk a parent chain; without it they deny. */
|
|
15
|
+
readonly relations?: RelationSource;
|
|
16
|
+
readonly entitlements?: EntitlementSource;
|
|
17
|
+
readonly customRoles?: RoleSource;
|
|
18
|
+
/** Hosted grants, read once per instance; see `PolicySource`. */
|
|
19
|
+
readonly policies?: PolicySource;
|
|
20
|
+
readonly store?: ApprovalStore;
|
|
21
|
+
readonly sink?: DecisionSink;
|
|
22
|
+
readonly limits?: LimitStore;
|
|
23
|
+
/** `createPermDock` from `permdock/pdp`; `protect` then decides delegated permissions remotely. */
|
|
24
|
+
readonly pdp?: PdpFactory;
|
|
25
|
+
/** Accepted for adapter parity; not read by this adapter. */
|
|
26
|
+
readonly snapshots?: SnapshotSource;
|
|
27
|
+
/** `(permdock) => withOtel(permdock, options)` from `permdock/otel`. */
|
|
28
|
+
readonly otel?: OtelWrap;
|
|
29
|
+
/** `(request) => verifyWebBotAuth(request, options)`; a verified bot becomes the actor. */
|
|
30
|
+
readonly webBotAuth?: WebBotAuthVerifier;
|
|
31
|
+
};
|
|
32
|
+
type NodePermDock<V extends PolicyVocabulary = PolicyVocabulary> = {
|
|
33
|
+
readonly permdock: (req: IncomingMessage) => Promise<PermDock<V>>;
|
|
34
|
+
readonly protect: (permission: Permission, loadData?: (req: NodeRequest) => unknown, protectOptions?: ProtectOptions) => (req: IncomingMessage) => Promise<Guard>;
|
|
35
|
+
readonly send: typeof sendResponse;
|
|
36
|
+
readonly permdockHandler: () => (req: IncomingMessage, res: ServerResponse) => Promise<void>;
|
|
37
|
+
readonly toRequest: typeof toRequest;
|
|
38
|
+
readonly fromResponse: typeof fromResponse;
|
|
39
|
+
readonly openapi: OpenApiHooks;
|
|
40
|
+
};
|
|
41
|
+
export declare function createPermDock<TUser, TPrincipal extends Principal = Principal, V extends PolicyVocabulary = PolicyVocabulary>(policy: Policy<TUser, TPrincipal, V>, options: NodePermDockOptions<TUser>): NodePermDock<V>;
|
|
42
|
+
//#endregion
|
|
43
|
+
export { InvalidSignatureError, type NodePermDock, type NodePermDockOptions, type NodeRequest, discoverViaSignatureAgent, fromResponse, isServerResponse, sendResponse, toRequest, verifyWebBotAuth };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { t as compact } from "../compact-y6vfu2_f.js";
|
|
2
|
+
import { i as discoverViaSignatureAgent, r as InvalidSignatureError, s as verifyWebBotAuth } from "../evaluations-DsAU9ppl.js";
|
|
3
|
+
import { r as tenantScope, t as createKernel } from "../create-CSkhDU9T.js";
|
|
4
|
+
import { i as toRequest, n as isServerResponse, r as sendResponse, t as fromResponse } from "../http-GgVApX1k.js";
|
|
5
|
+
//#region src/node/create.ts
|
|
6
|
+
function createPermDock(policy, options) {
|
|
7
|
+
const contexts = /* @__PURE__ */ new WeakMap();
|
|
8
|
+
const bound = /* @__PURE__ */ new WeakMap();
|
|
9
|
+
const kernel = createKernel(policy, compact({
|
|
10
|
+
subject: (request) => {
|
|
11
|
+
const req = contexts.get(request);
|
|
12
|
+
return req === void 0 ? null : options.subject(req);
|
|
13
|
+
},
|
|
14
|
+
memberships: options.memberships,
|
|
15
|
+
relations: options.relations,
|
|
16
|
+
entitlements: options.entitlements,
|
|
17
|
+
customRoles: options.customRoles,
|
|
18
|
+
policies: options.policies,
|
|
19
|
+
store: options.store,
|
|
20
|
+
sink: options.sink,
|
|
21
|
+
limits: options.limits,
|
|
22
|
+
pdp: options.pdp,
|
|
23
|
+
webBotAuth: options.webBotAuth,
|
|
24
|
+
adapter: "node",
|
|
25
|
+
wrap: options.otel
|
|
26
|
+
}));
|
|
27
|
+
const bind = (req) => {
|
|
28
|
+
const hit = bound.get(req);
|
|
29
|
+
if (hit !== void 0) return hit;
|
|
30
|
+
const nodeReq = req;
|
|
31
|
+
const request = toRequest(nodeReq);
|
|
32
|
+
bound.set(req, request);
|
|
33
|
+
contexts.set(request, nodeReq);
|
|
34
|
+
return request;
|
|
35
|
+
};
|
|
36
|
+
const scopeOf = (req) => tenantScope(options.tenant, req);
|
|
37
|
+
const permdock = async (req) => kernel.permdock(bind(req), await scopeOf(req));
|
|
38
|
+
const protect = (permission, loadData, protectOptions) => async (req) => kernel.protect(permission, loadData === void 0 ? void 0 : () => loadData(req), protectOptions)(bind(req), await scopeOf(req));
|
|
39
|
+
const permdockHandler = () => {
|
|
40
|
+
const { POST, GET } = kernel.permdockHandler((request) => {
|
|
41
|
+
const req = contexts.get(request);
|
|
42
|
+
return req === void 0 ? { tenant: void 0 } : scopeOf(req);
|
|
43
|
+
});
|
|
44
|
+
return async (req, res) => {
|
|
45
|
+
if (req.method === "GET" || req.method === "HEAD") {
|
|
46
|
+
await sendResponse(res, await GET(bind(req)));
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const nodeReq = req;
|
|
50
|
+
const request = toRequest(nodeReq);
|
|
51
|
+
contexts.set(request, nodeReq);
|
|
52
|
+
await sendResponse(res, await POST(request));
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
return {
|
|
56
|
+
permdock,
|
|
57
|
+
protect,
|
|
58
|
+
send: sendResponse,
|
|
59
|
+
permdockHandler,
|
|
60
|
+
toRequest,
|
|
61
|
+
fromResponse,
|
|
62
|
+
openapi: kernel.openapi
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
export { InvalidSignatureError, createPermDock, discoverViaSignatureAgent, fromResponse, isServerResponse, sendResponse, toRequest, verifyWebBotAuth };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { $ as DecisionSink, C as Policy, E as PolicyVocabulary, Zt as PermDock, at as LimitStore, ct as MembershipSource, ft as RelationSource, mr as Principal, pt as RoleSource, sn as PolicySource, tt as EntitlementSource, ur as Delegation, xt as SnapshotSource } from "../policy-CInmNGkM.js";
|
|
2
|
+
import { d as Permission } from "../permissions-B4apnahQ.js";
|
|
3
|
+
import { c as ApprovalRequest, f as ApprovalStore } from "../types-B8w5PFtS.js";
|
|
4
|
+
import { t as ToolMap } from "../types-CxquUByI.js";
|
|
5
|
+
//#region src/openai/create.d.ts
|
|
6
|
+
/** The app context passed to `run(agent, input, { context })`. */
|
|
7
|
+
type OpenAiContext = {
|
|
8
|
+
readonly user?: unknown;
|
|
9
|
+
readonly agentId?: string;
|
|
10
|
+
readonly permdockApproval?: string;
|
|
11
|
+
readonly [key: string]: unknown;
|
|
12
|
+
};
|
|
13
|
+
/** Structural `RunContext` from `@openai/agents`: the app context sits under `context`. */
|
|
14
|
+
type OpenAiRunContext = {
|
|
15
|
+
readonly context?: unknown;
|
|
16
|
+
};
|
|
17
|
+
type OpenAiPermDockOptions<TUser = unknown> = {
|
|
18
|
+
readonly subject: (context: OpenAiContext) => TUser | Promise<TUser>;
|
|
19
|
+
readonly actor?: (context: OpenAiContext) => unknown;
|
|
20
|
+
readonly delegation?: (context: OpenAiContext) => Delegation | undefined | Promise<Delegation | undefined>;
|
|
21
|
+
readonly tenant?: string | ((context: OpenAiContext) => string | undefined | Promise<string | undefined>);
|
|
22
|
+
readonly tools: ToolMap;
|
|
23
|
+
readonly memberships?: MembershipSource | readonly MembershipSource[];
|
|
24
|
+
/** The object graph for relation grants that walk a parent chain; without it they deny. */
|
|
25
|
+
readonly relations?: RelationSource;
|
|
26
|
+
readonly entitlements?: EntitlementSource;
|
|
27
|
+
readonly customRoles?: RoleSource;
|
|
28
|
+
/** Hosted grants, read once per instance; see `PolicySource`. */
|
|
29
|
+
readonly policies?: PolicySource;
|
|
30
|
+
readonly store?: ApprovalStore;
|
|
31
|
+
readonly sink?: DecisionSink;
|
|
32
|
+
readonly limits?: LimitStore;
|
|
33
|
+
readonly snapshots?: SnapshotSource;
|
|
34
|
+
};
|
|
35
|
+
type OpenAiTool = {
|
|
36
|
+
readonly name: string;
|
|
37
|
+
};
|
|
38
|
+
/** Structural `RunToolApprovalItem` from `@openai/agents`. */
|
|
39
|
+
type OpenAiInterruption = {
|
|
40
|
+
readonly type?: string;
|
|
41
|
+
readonly name?: string | undefined;
|
|
42
|
+
readonly arguments?: string | undefined;
|
|
43
|
+
readonly rawItem?: {
|
|
44
|
+
readonly type?: string;
|
|
45
|
+
readonly callId?: string;
|
|
46
|
+
readonly name?: string;
|
|
47
|
+
readonly arguments?: unknown;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
/** Structural `RunState` from `@openai/agents`. */
|
|
51
|
+
type OpenAiRunState<TItem> = {
|
|
52
|
+
approve(item: TItem, options?: {
|
|
53
|
+
alwaysApprove?: boolean;
|
|
54
|
+
}): unknown;
|
|
55
|
+
reject(item: TItem, options?: {
|
|
56
|
+
alwaysReject?: boolean;
|
|
57
|
+
message?: string;
|
|
58
|
+
}): unknown;
|
|
59
|
+
};
|
|
60
|
+
type OpenAiPermDock<V extends PolicyVocabulary = PolicyVocabulary> = {
|
|
61
|
+
/** A `ToolApprovalFunction`: pass it as a tool's `needsApproval`. */
|
|
62
|
+
readonly needsApproval: (permission: Permission) => (runContext: OpenAiRunContext | undefined, input: unknown, callId?: string) => Promise<boolean>;
|
|
63
|
+
readonly guardTools: <T extends OpenAiTool>(tools: readonly T[], context: OpenAiContext) => Promise<readonly T[]>;
|
|
64
|
+
readonly resolveInterruptions: <TItem extends OpenAiInterruption>(state: OpenAiRunState<TItem>, interruptions: readonly TItem[], options: {
|
|
65
|
+
readonly context: OpenAiContext;
|
|
66
|
+
}) => Promise<readonly ApprovalRequest[]>;
|
|
67
|
+
readonly permdock: (context: OpenAiContext) => Promise<PermDock<V>>;
|
|
68
|
+
};
|
|
69
|
+
export declare function createPermDock<TUser, TPrincipal extends Principal = Principal, V extends PolicyVocabulary = PolicyVocabulary>(policy: Policy<TUser, TPrincipal, V>, options: OpenAiPermDockOptions<TUser>): OpenAiPermDock<V>;
|
|
70
|
+
//#endregion
|
|
71
|
+
export type { OpenAiContext, OpenAiInterruption, OpenAiPermDock, OpenAiPermDockOptions, OpenAiRunState, OpenAiTool };
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { t as compact } from "../compact-y6vfu2_f.js";
|
|
2
|
+
import { p as memoryApprovalStore } from "../helpers-DnSOrhB9.js";
|
|
3
|
+
import { n as createAgentKernel, t as approvalTokenOf } from "../kernel-YOGCWNLf.js";
|
|
4
|
+
//#region src/openai/create.ts
|
|
5
|
+
function appContext(runContext) {
|
|
6
|
+
const context = runContext?.context;
|
|
7
|
+
return typeof context === "object" && context !== null ? context : {};
|
|
8
|
+
}
|
|
9
|
+
function parseCall(item) {
|
|
10
|
+
const name = item.name ?? item.rawItem?.name;
|
|
11
|
+
if (typeof name !== "string") return { ok: false };
|
|
12
|
+
const raw = item.arguments ?? item.rawItem?.arguments;
|
|
13
|
+
if (typeof raw !== "string") return typeof raw === "object" && raw !== null ? {
|
|
14
|
+
ok: true,
|
|
15
|
+
name,
|
|
16
|
+
args: raw
|
|
17
|
+
} : { ok: false };
|
|
18
|
+
try {
|
|
19
|
+
return {
|
|
20
|
+
ok: true,
|
|
21
|
+
name,
|
|
22
|
+
args: JSON.parse(raw)
|
|
23
|
+
};
|
|
24
|
+
} catch {
|
|
25
|
+
return { ok: false };
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function createPermDock(policy, options) {
|
|
29
|
+
const store = options.store ?? memoryApprovalStore();
|
|
30
|
+
const kernel = createAgentKernel(policy, {
|
|
31
|
+
...compact({
|
|
32
|
+
actor: options.actor,
|
|
33
|
+
delegation: options.delegation,
|
|
34
|
+
tenant: options.tenant,
|
|
35
|
+
memberships: options.memberships,
|
|
36
|
+
relations: options.relations,
|
|
37
|
+
entitlements: options.entitlements,
|
|
38
|
+
customRoles: options.customRoles,
|
|
39
|
+
policies: options.policies,
|
|
40
|
+
sink: options.sink,
|
|
41
|
+
limits: options.limits,
|
|
42
|
+
snapshots: options.snapshots
|
|
43
|
+
}),
|
|
44
|
+
subject: options.subject,
|
|
45
|
+
tools: options.tools,
|
|
46
|
+
store,
|
|
47
|
+
adapter: "openai"
|
|
48
|
+
});
|
|
49
|
+
const byPermission = /* @__PURE__ */ new Map();
|
|
50
|
+
for (const [name, binding] of Object.entries(options.tools)) byPermission.set(binding.permission.key, name);
|
|
51
|
+
const needsApproval = (permission) => async (runContext, input) => {
|
|
52
|
+
const toolName = byPermission.get(permission.key);
|
|
53
|
+
if (toolName === void 0) return true;
|
|
54
|
+
const context = appContext(runContext);
|
|
55
|
+
const binding = options.tools[toolName];
|
|
56
|
+
if (binding === void 0) return true;
|
|
57
|
+
try {
|
|
58
|
+
const can = (await kernel.instance(context)).can;
|
|
59
|
+
if (binding.data === void 0) return !can(permission);
|
|
60
|
+
const data = await binding.data(input);
|
|
61
|
+
if (data === null || data === void 0) return true;
|
|
62
|
+
return !can(permission, data);
|
|
63
|
+
} catch {
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const guardTools = async (tools, context) => {
|
|
68
|
+
const allowed = await kernel.allowedToolNames(context);
|
|
69
|
+
return tools.filter((tool) => allowed.has(tool.name));
|
|
70
|
+
};
|
|
71
|
+
const resolveOne = async (state, item, context) => {
|
|
72
|
+
const call = parseCall(item);
|
|
73
|
+
if (!call.ok) {
|
|
74
|
+
await state.reject(item, { message: "Denied: unreadable tool call." });
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
const verdict = await kernel.decideTool(call.name, call.args, context, compact({ resumeToken: approvalTokenOf(context) }));
|
|
78
|
+
if (verdict.outcome === "granted") {
|
|
79
|
+
await state.approve(item);
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
if (verdict.outcome === "denied") {
|
|
83
|
+
await state.reject(item, { message: verdict.reason });
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
return await store.get(verdict.token);
|
|
88
|
+
} catch {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
const resolveInterruptions = async (state, interruptions, resolveOptions) => {
|
|
93
|
+
const resolved = [];
|
|
94
|
+
for (const item of interruptions) resolved.push(await resolveOne(state, item, resolveOptions.context));
|
|
95
|
+
return resolved.filter((record) => record !== null);
|
|
96
|
+
};
|
|
97
|
+
return {
|
|
98
|
+
needsApproval,
|
|
99
|
+
guardTools,
|
|
100
|
+
resolveInterruptions,
|
|
101
|
+
permdock: (context) => kernel.instance(context)
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
//#endregion
|
|
105
|
+
export { createPermDock };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { C as Policy, _r as Condition, mr as Principal } from "../policy-CInmNGkM.js";
|
|
2
|
+
import { d as Permission } from "../permissions-B4apnahQ.js";
|
|
3
|
+
//#region src/openapi/types.d.ts
|
|
4
|
+
type OpenApiTarget = "3.1" | "3.2" | "3.3";
|
|
5
|
+
type OverlayVersion = "1.1" | "1.2";
|
|
6
|
+
type SecurityProfileName = "fapi2";
|
|
7
|
+
type SchemeType = "oauth2" | "openIdConnect" | "http" | "apiKey" | "gnap";
|
|
8
|
+
type OpenApiSchemeOptions = {
|
|
9
|
+
readonly name: string;
|
|
10
|
+
readonly type: SchemeType;
|
|
11
|
+
readonly oauth2MetadataUrl?: string;
|
|
12
|
+
readonly flows?: {
|
|
13
|
+
readonly authorizationCode?: Readonly<Record<string, unknown>>;
|
|
14
|
+
readonly clientCredentials?: Readonly<Record<string, unknown>>;
|
|
15
|
+
readonly deviceAuthorization?: Readonly<Record<string, unknown>>;
|
|
16
|
+
};
|
|
17
|
+
readonly openIdConnectUrl?: string;
|
|
18
|
+
readonly ref?: string;
|
|
19
|
+
/** Retires the scheme: `deprecated` on 3.2 and 3.3, `x-oai-deprecated` on 3.1. */
|
|
20
|
+
readonly deprecated?: boolean;
|
|
21
|
+
};
|
|
22
|
+
type OpenApiDocsHints = {
|
|
23
|
+
readonly badges?: boolean;
|
|
24
|
+
};
|
|
25
|
+
type OpenApiPermDockOptions = {
|
|
26
|
+
readonly scheme: OpenApiSchemeOptions;
|
|
27
|
+
readonly target?: OpenApiTarget;
|
|
28
|
+
readonly securityProfile?: SecurityProfileName;
|
|
29
|
+
readonly profileScheme?: string;
|
|
30
|
+
readonly docsHints?: OpenApiDocsHints;
|
|
31
|
+
};
|
|
32
|
+
type OpenApiSecurityRequirement = Readonly<Record<string, readonly string[]>>;
|
|
33
|
+
type OpenApiDescribe = {
|
|
34
|
+
readonly security: readonly OpenApiSecurityRequirement[];
|
|
35
|
+
readonly "x-permdock-permissions": readonly string[];
|
|
36
|
+
/** Keyed by permission key: the portable conditions of its allow grants. */
|
|
37
|
+
readonly "x-permdock-conditions"?: Readonly<Record<string, Condition>>;
|
|
38
|
+
/** Keyed by permission key: the permissions whose grants need an approval. */
|
|
39
|
+
readonly "x-permdock-approval"?: Readonly<Record<string, {
|
|
40
|
+
readonly reason: "human";
|
|
41
|
+
}>>;
|
|
42
|
+
readonly "x-permdock-securityProfile"?: SecurityProfileName;
|
|
43
|
+
readonly "x-badges"?: readonly {
|
|
44
|
+
readonly name: string;
|
|
45
|
+
}[];
|
|
46
|
+
};
|
|
47
|
+
/** One operation the Overlay targets, joined by `operationId`. */
|
|
48
|
+
type OverlayOperation = {
|
|
49
|
+
readonly operationId: string;
|
|
50
|
+
readonly permissions: readonly Permission[];
|
|
51
|
+
};
|
|
52
|
+
type OpenApiOverlayOptions = {
|
|
53
|
+
readonly extends?: string;
|
|
54
|
+
readonly version?: OverlayVersion;
|
|
55
|
+
/** The operations to cover; without them, one per permission whose `operationId` is the permission key. */
|
|
56
|
+
readonly operations?: readonly OverlayOperation[];
|
|
57
|
+
};
|
|
58
|
+
type OpenApiPermDock = {
|
|
59
|
+
readonly securitySchemes: () => Readonly<Record<string, unknown>>;
|
|
60
|
+
readonly security: (permission: Permission | readonly Permission[], options?: {
|
|
61
|
+
readonly anyOf?: boolean;
|
|
62
|
+
}) => readonly OpenApiSecurityRequirement[];
|
|
63
|
+
readonly describe: (permission: Permission | readonly Permission[], options?: {
|
|
64
|
+
readonly anyOf?: boolean;
|
|
65
|
+
}) => OpenApiDescribe;
|
|
66
|
+
readonly spec: (permission: Permission | readonly Permission[]) => (operation: Readonly<Record<string, unknown>>) => Record<string, unknown>;
|
|
67
|
+
readonly overlay: (options?: OpenApiOverlayOptions) => Record<string, unknown>;
|
|
68
|
+
/** One requirement per distinct scope set; without `scopeSets`, one per permission. */
|
|
69
|
+
readonly securityProfileRequirements: (scopeSets?: readonly (readonly string[])[]) => Readonly<Record<string, unknown>> | undefined;
|
|
70
|
+
readonly catalog: () => Record<string, unknown>;
|
|
71
|
+
};
|
|
72
|
+
type OpenApiFactory = <TUser, TPrincipal extends Principal = Principal>(policy: Policy<TUser, TPrincipal>, options: OpenApiPermDockOptions) => OpenApiPermDock;
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region src/openapi/create.d.ts
|
|
75
|
+
export declare const createPermDock: OpenApiFactory;
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/openapi/pins.d.ts
|
|
78
|
+
export declare const DRAFT_PINS: {
|
|
79
|
+
readonly oas: "3.3-dev@2026-09-01";
|
|
80
|
+
readonly securityProfiles: "oai-discussion-5304@2026-09-01";
|
|
81
|
+
readonly overlay: "1.2-dev@edd4adea";
|
|
82
|
+
};
|
|
83
|
+
export declare const PROFILE_NAMES: {
|
|
84
|
+
readonly fapi2: "fapi-20-security-profile";
|
|
85
|
+
};
|
|
86
|
+
export declare const GNAP_RESERVED = "scheme.type 'gnap' is reserved and emits nothing. See https://permdock.dev/docs/standards/watch-list#gnap";
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/openapi/emit.d.ts
|
|
89
|
+
export declare function securitySchemesOf(policy: Policy, options: OpenApiPermDockOptions): Record<string, unknown>;
|
|
90
|
+
export declare function catalogOf(options: OpenApiPermDockOptions, extraDrafts?: Readonly<Record<string, string>>): Record<string, unknown>;
|
|
91
|
+
export declare function openapiVersion(target: OpenApiTarget): string;
|
|
92
|
+
//#endregion
|
|
93
|
+
export type { OpenApiDescribe, OpenApiDocsHints, OpenApiFactory, OpenApiOverlayOptions, OpenApiPermDock, OpenApiPermDockOptions, OpenApiSchemeOptions, OpenApiSecurityRequirement, OpenApiTarget, OverlayOperation, OverlayVersion, SchemeType, SecurityProfileName };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { n as GNAP_RESERVED, r as PROFILE_NAMES, t as DRAFT_PINS } from "../pins-CqE1jZuF.js";
|
|
2
|
+
import { i as securitySchemesOf, n as catalogOf, r as openapiVersion, t as createPermDock } from "../openapi-DcqM8nU7.js";
|
|
3
|
+
export { DRAFT_PINS, GNAP_RESERVED, PROFILE_NAMES, catalogOf, createPermDock, openapiVersion, securitySchemesOf };
|