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.
Files changed (290) hide show
  1. package/README.md +268 -1
  2. package/dist/a2a/index.d.ts +178 -0
  3. package/dist/a2a/index.js +271 -0
  4. package/dist/ai-sdk/index.d.ts +74 -0
  5. package/dist/ai-sdk/index.js +137 -0
  6. package/dist/approval-required-TzNB9oQA.js +6 -0
  7. package/dist/approvals/index.d.ts +3 -0
  8. package/dist/approvals/index.js +4 -0
  9. package/dist/approvals-DaxY-Bdg.js +218 -0
  10. package/dist/approvers-aH0PJkmf.js +20 -0
  11. package/dist/arazzo-CTeVuXr5.js +70 -0
  12. package/dist/arazzo-aoTkqYsJ.js +54 -0
  13. package/dist/authzen/index.d.ts +48 -0
  14. package/dist/authzen/index.js +336 -0
  15. package/dist/better-auth/index.d.ts +92 -0
  16. package/dist/better-auth/index.js +324 -0
  17. package/dist/budget-JqcRqyhK.d.ts +11 -0
  18. package/dist/budget-NbEtbJC_.js +11 -0
  19. package/dist/capability-B68OFnZx.js +171 -0
  20. package/dist/capability-BDG_nkxt.d.ts +99 -0
  21. package/dist/catalog/index.d.ts +12 -0
  22. package/dist/catalog/index.js +2 -0
  23. package/dist/catalog-B0E6bggc.js +48 -0
  24. package/dist/catalog-H-vFGwWK.js +55 -0
  25. package/dist/catalog-doc-BSo_Q_-6.js +298 -0
  26. package/dist/catalog-idsHc0vo.js +2 -0
  27. package/dist/catalog-path-CnI0XTFK.js +12 -0
  28. package/dist/claude-agent/index.d.ts +81 -0
  29. package/dist/claude-agent/index.js +83 -0
  30. package/dist/clerk/index.d.ts +56 -0
  31. package/dist/clerk/index.js +280 -0
  32. package/dist/cli/bin.d.ts +1 -0
  33. package/dist/cli/bin.js +20 -0
  34. package/dist/cli/index.d.ts +46 -0
  35. package/dist/cli/index.js +5 -0
  36. package/dist/cloud/index.d.ts +91 -0
  37. package/dist/cloud/index.js +390 -0
  38. package/dist/cloud-BNQTrmrr.js +50 -0
  39. package/dist/cloud-Cuxr6Czw.js +117 -0
  40. package/dist/collect-B7_TIfmg.js +49 -0
  41. package/dist/collect-O-tOtbnk.js +350 -0
  42. package/dist/collect-fRPAQIWb.js +2 -0
  43. package/dist/commands-BMh_Etm2.js +93 -0
  44. package/dist/compact-y6vfu2_f.js +19 -0
  45. package/dist/compare-pfyVnBjE.js +12 -0
  46. package/dist/compile-CQbvyIBr.d.ts +30 -0
  47. package/dist/compile-D22iwvuV.js +558 -0
  48. package/dist/config-BPYmjTOp.js +26 -0
  49. package/dist/connection-JvqwHODC.js +194 -0
  50. package/dist/context-CKEAabd7.js +73 -0
  51. package/dist/context-gtAwAILx.js +6 -0
  52. package/dist/convex/index.d.ts +40 -0
  53. package/dist/convex/index.js +55 -0
  54. package/dist/create-BKF3dgFk.d.ts +162 -0
  55. package/dist/create-CSkhDU9T.js +222 -0
  56. package/dist/credential-B_rkUNlY.js +326 -0
  57. package/dist/credentials-BgRX3WEg.js +268 -0
  58. package/dist/describe-Bt1YD5uS.js +99 -0
  59. package/dist/describe-DernyItf.d.ts +37 -0
  60. package/dist/diff-BUzf5Poi.js +48 -0
  61. package/dist/diff-x5Il8LVa.js +418 -0
  62. package/dist/digest-B3kc_PgQ.d.ts +19 -0
  63. package/dist/digest-BI-6aa6d.js +27 -0
  64. package/dist/doctor-BGle8Gqi.js +1314 -0
  65. package/dist/doctor-Bqo6FwUa.js +53 -0
  66. package/dist/drizzle/index.d.ts +72 -0
  67. package/dist/drizzle/index.js +160 -0
  68. package/dist/duration-xK2jGFVc.js +25 -0
  69. package/dist/elysia/index.d.ts +71 -0
  70. package/dist/elysia/index.js +103 -0
  71. package/dist/errors-DSMnAVNa.js +43 -0
  72. package/dist/errors-DbZ1YOnb.d.ts +138 -0
  73. package/dist/errors-Iy71s7Oj.js +177 -0
  74. package/dist/errors-m3u9TmDu.js +27 -0
  75. package/dist/evaluations-DsAU9ppl.js +479 -0
  76. package/dist/eve/index.d.ts +95 -0
  77. package/dist/eve/index.js +181 -0
  78. package/dist/express/index.d.ts +46 -0
  79. package/dist/express/index.js +108 -0
  80. package/dist/fastify/index.d.ts +56 -0
  81. package/dist/fastify/index.js +141 -0
  82. package/dist/files-B_wAGYmt.js +121 -0
  83. package/dist/fixtures-Cvaw0gDG.js +64 -0
  84. package/dist/freeze-y1_jQL4v.js +31 -0
  85. package/dist/from-snapshot-BMGnhmgv.js +552 -0
  86. package/dist/generate-CH7ThJ14.js +173 -0
  87. package/dist/grantee-Bv04_Vzf.js +521 -0
  88. package/dist/headers-B5RRv3Xm.js +6 -0
  89. package/dist/headers-C8SHQccD.d.ts +6 -0
  90. package/dist/helpers-DnSOrhB9.js +682 -0
  91. package/dist/hono/index.d.ts +70 -0
  92. package/dist/hono/index.js +131 -0
  93. package/dist/hosted-BwKQ1BTA.js +265 -0
  94. package/dist/http-DPuDaChb.d.ts +13 -0
  95. package/dist/http-GgVApX1k.js +111 -0
  96. package/dist/index-CltcQ4Bf.d.ts +138 -0
  97. package/dist/index-LF_hS-yn.d.ts +177 -0
  98. package/dist/index-fG6NSXlc.d.ts +9 -0
  99. package/dist/index-xIxJLwOQ.d.ts +415 -0
  100. package/dist/index.d.ts +11 -0
  101. package/dist/index.js +21 -0
  102. package/dist/jwt/index.d.ts +87 -0
  103. package/dist/jwt/index.js +571 -0
  104. package/dist/kernel-YOGCWNLf.js +211 -0
  105. package/dist/kysely/index.d.ts +77 -0
  106. package/dist/kysely/index.js +129 -0
  107. package/dist/load-BZ24CpZP.js +69 -0
  108. package/dist/load-QOOm1z70.js +2 -0
  109. package/dist/load-jose-BL6LH4bL.js +11 -0
  110. package/dist/lru-8q4WZjBV.js +28 -0
  111. package/dist/manifest-DDQbC6K0.d.ts +118 -0
  112. package/dist/map-DowSO96j.js +158 -0
  113. package/dist/map-claims-B_6I1Rn-.js +360 -0
  114. package/dist/map-error-RJ3ZsUyA.js +16 -0
  115. package/dist/markers-B0hYLvMD.js +60 -0
  116. package/dist/may-use-CnFEjVEp.js +37 -0
  117. package/dist/mcp/index.d.ts +127 -0
  118. package/dist/mcp/index.js +563 -0
  119. package/dist/nest/index.d.ts +80 -0
  120. package/dist/nest/index.js +270 -0
  121. package/dist/next/client.d.ts +24 -0
  122. package/dist/next/client.js +31 -0
  123. package/dist/next/index.d.ts +110 -0
  124. package/dist/next/index.js +195 -0
  125. package/dist/next/plugin.d.ts +14 -0
  126. package/dist/next/plugin.js +2 -0
  127. package/dist/node/index.d.ts +43 -0
  128. package/dist/node/index.js +66 -0
  129. package/dist/openai/index.d.ts +71 -0
  130. package/dist/openai/index.js +105 -0
  131. package/dist/openapi/index.d.ts +93 -0
  132. package/dist/openapi/index.js +3 -0
  133. package/dist/openapi-CwePaF7C.js +164 -0
  134. package/dist/openapi-DWD0Uc_4.js +250 -0
  135. package/dist/openapi-DcqM8nU7.js +306 -0
  136. package/dist/openapi-import-BWRUNNeW.js +5959 -0
  137. package/dist/openapi-schema-D8j_T9tO.js +6902 -0
  138. package/dist/orpc/index.d.ts +64 -0
  139. package/dist/orpc/index.js +188 -0
  140. package/dist/otel/index.d.ts +13 -0
  141. package/dist/otel/index.js +202 -0
  142. package/dist/package-root-zGkxO3oN.js +30 -0
  143. package/dist/parse-DPfIvFMU.js +135 -0
  144. package/dist/pdp/index.d.ts +22 -0
  145. package/dist/pdp/index.js +795 -0
  146. package/dist/peer-BOr_kJE1.js +31 -0
  147. package/dist/permdock-yoZ7EjxX.js +2956 -0
  148. package/dist/permissions-B4apnahQ.d.ts +185 -0
  149. package/dist/permissions-B8vCg_bI.d.ts +52 -0
  150. package/dist/permissions-CofRqesP.js +142 -0
  151. package/dist/permissions-DC7GROPA.js +600 -0
  152. package/dist/pg-4GJWDUxG.js +953 -0
  153. package/dist/pins-CqE1jZuF.js +12 -0
  154. package/dist/plugin-4gr7IxFJ.js +65 -0
  155. package/dist/policy-ANp36PnI.js +971 -0
  156. package/dist/policy-CInmNGkM.d.ts +1959 -0
  157. package/dist/policy-Cq2fB8Q5.d.ts +20 -0
  158. package/dist/prisma/index.d.ts +135 -0
  159. package/dist/prisma/index.js +430 -0
  160. package/dist/problem-Cgp9-KZA.js +226 -0
  161. package/dist/prompt-CXYhLfsS.js +32 -0
  162. package/dist/protected-B4K3BKoX.js +138 -0
  163. package/dist/protected-BuPAycJT.d.ts +26 -0
  164. package/dist/protected-wY7nXhY9.d.ts +23 -0
  165. package/dist/provider-_wx46HpB.js +48 -0
  166. package/dist/provider-wTAUda2v.d.ts +6 -0
  167. package/dist/react/index.d.ts +6 -0
  168. package/dist/react/index.js +6 -0
  169. package/dist/react/provider-client.d.ts +2 -0
  170. package/dist/react/provider-client.js +3 -0
  171. package/dist/react-native/index.d.ts +42 -0
  172. package/dist/react-native/index.js +174 -0
  173. package/dist/refs-ChLSxbST.js +90 -0
  174. package/dist/relations-r4soIFZB.js +426 -0
  175. package/dist/revocations-Cy06JNx2.d.ts +21 -0
  176. package/dist/rls-BOFU3chG.js +233 -0
  177. package/dist/rls-CJVja9Ww.js +2119 -0
  178. package/dist/rls-graph-DxQ39PJj.js +371 -0
  179. package/dist/rls-helpers-BxRuif0l.js +1346 -0
  180. package/dist/rls-import-CXV6LBlS.js +942 -0
  181. package/dist/rls-migrate-DrFPbf8p.js +366 -0
  182. package/dist/row-check-BajTgQZ-.d.ts +43 -0
  183. package/dist/run-CJ6UvS3a.js +155 -0
  184. package/dist/runtime-DP9ttFh1.js +27 -0
  185. package/dist/saas-BRrZzJkM.js +1193 -0
  186. package/dist/schema-P8yoma__.js +296 -0
  187. package/dist/scim/index.d.ts +2 -0
  188. package/dist/scim/index.js +2 -0
  189. package/dist/scim-9NFa0XVZ.js +1445 -0
  190. package/dist/scopes-cKVp_WTw.js +212 -0
  191. package/dist/server/index.d.ts +123 -0
  192. package/dist/server/index.js +8 -0
  193. package/dist/sha256-BO0swRXL.js +150 -0
  194. package/dist/sink-Bd9PSyfq.js +141 -0
  195. package/dist/sink-Cfr9-7YC.d.ts +104 -0
  196. package/dist/skills-C_lpV4Jx.js +50 -0
  197. package/dist/skills-Dx3QLnMY.js +110 -0
  198. package/dist/snapshot-DE8dE_hz.js +1051 -0
  199. package/dist/solid/index.d.ts +63 -0
  200. package/dist/solid/index.js +197 -0
  201. package/dist/source-DoBBYJi2.js +6 -0
  202. package/dist/sources-DOpW5Ila.d.ts +347 -0
  203. package/dist/sources-DVHM3Mwq.js +284 -0
  204. package/dist/sql-Bll1d7y0.js +22 -0
  205. package/dist/src-CTNT-PBW.js +430 -0
  206. package/dist/ssf/index.d.ts +3 -0
  207. package/dist/ssf/index.js +622 -0
  208. package/dist/store-Bq90395i.d.ts +27 -0
  209. package/dist/store-C6hFW6ta.js +508 -0
  210. package/dist/stores-CkG2HrSg.js +140 -0
  211. package/dist/stores-CvOnu_2T.d.ts +41 -0
  212. package/dist/stream-BhMfZOwr.d.ts +12 -0
  213. package/dist/stream-Q_xlB6Ko.js +52 -0
  214. package/dist/style-CTm1AXDT.js +22 -0
  215. package/dist/subject-C6dLxqHU.js +24 -0
  216. package/dist/subject-settings-xt7V845g.js +82 -0
  217. package/dist/supabase/index.d.ts +67 -0
  218. package/dist/supabase/index.js +4 -0
  219. package/dist/supabase/middleware.d.ts +77 -0
  220. package/dist/supabase/middleware.js +68 -0
  221. package/dist/supabase-D8UlBA7Z.js +83 -0
  222. package/dist/supabase-DTxGtYdi.js +796 -0
  223. package/dist/supabase-hook-DW-xP4hU.js +2 -0
  224. package/dist/supabase-hook-D_OqGb_V.js +1528 -0
  225. package/dist/svelte/Protected.svelte +34 -0
  226. package/dist/svelte/index.d.ts +10 -0
  227. package/dist/svelte/index.js +53 -0
  228. package/dist/svelte/runtime.d.ts +6 -0
  229. package/dist/svelte/runtime.js +3 -0
  230. package/dist/svelte/source.d.ts +10 -0
  231. package/dist/svelte/source.js +8 -0
  232. package/dist/terminal/index.d.ts +171 -0
  233. package/dist/terminal/index.js +821 -0
  234. package/dist/testing/index.d.ts +656 -0
  235. package/dist/testing/index.js +3208 -0
  236. package/dist/testing/saas/index.d.ts +194 -0
  237. package/dist/testing/saas/index.js +3 -0
  238. package/dist/testing/saas/permissions.d.ts +2 -0
  239. package/dist/testing/saas/permissions.js +2 -0
  240. package/dist/text-diff-BdkkYSbi.js +15 -0
  241. package/dist/thenable-okc2xDsj.js +10 -0
  242. package/dist/timeout-D51niuQP.js +8 -0
  243. package/dist/trpc/index.d.ts +80 -0
  244. package/dist/trpc/index.js +205 -0
  245. package/dist/types-B8w5PFtS.d.ts +141 -0
  246. package/dist/types-B9dmiiab.d.ts +66 -0
  247. package/dist/types-BBK-exvJ.d.ts +177 -0
  248. package/dist/types-BvBk1wgn.d.ts +118 -0
  249. package/dist/types-CxquUByI.d.ts +9 -0
  250. package/dist/types-D6Z6-rKJ.d.ts +312 -0
  251. package/dist/types-DbWdEfcm.d.ts +87 -0
  252. package/dist/types-bva3i4Gf.d.ts +98 -0
  253. package/dist/types-i4BAOvdb.d.ts +97 -0
  254. package/dist/unplugin/index.d.ts +7 -0
  255. package/dist/unplugin/index.js +30 -0
  256. package/dist/usage-1ozMubLY.js +42 -0
  257. package/dist/usage-CUnK6Ou9.js +530 -0
  258. package/dist/usage-PyEor6GA.js +2 -0
  259. package/dist/validity-D0uRmJKJ.js +224 -0
  260. package/dist/verifier-B90agnhl.js +461 -0
  261. package/dist/version-CnSh33Fj.js +16 -0
  262. package/dist/vocabulary-Dk0fs-Jk.d.ts +56 -0
  263. package/dist/vue/index.d.ts +57 -0
  264. package/dist/vue/index.js +203 -0
  265. package/dist/webmcp/index.d.ts +75 -0
  266. package/dist/webmcp/index.js +313 -0
  267. package/package.json +423 -4
  268. package/rulesets/permdock.yaml +29 -0
  269. package/schemas/catalog-v1.json +507 -0
  270. package/schemas/openapi/oas-3.1.json +1298 -0
  271. package/schemas/openapi/oas-3.2.json +1516 -0
  272. package/schemas/openapi/overlay-1.1.json +79 -0
  273. package/schemas/supabase-claims-v1.json +139 -0
  274. package/schemas/supabase-manifest-v1.json +217 -0
  275. package/skills/permdock/SKILL.md +66 -0
  276. package/skills/permdock-agents/SKILL.md +77 -0
  277. package/skills/permdock-agents/references/runtimes.md +211 -0
  278. package/skills/permdock-approvals/SKILL.md +80 -0
  279. package/skills/permdock-approvals/references/stores-and-resume.md +83 -0
  280. package/skills/permdock-audit/SKILL.md +67 -0
  281. package/skills/permdock-credentials/SKILL.md +55 -0
  282. package/skills/permdock-credentials/references/tokens-keys-links.md +127 -0
  283. package/skills/permdock-data/SKILL.md +57 -0
  284. package/skills/permdock-data/references/queries-and-rls.md +54 -0
  285. package/skills/permdock-data/references/relationships.md +65 -0
  286. package/skills/permdock-tenancy/SKILL.md +77 -0
  287. package/skills/permdock-tenancy/references/ownership-and-custom-roles.md +83 -0
  288. package/skills/permdock-wire/SKILL.md +116 -0
  289. package/skills/permdock-wire/references/adapters.md +480 -0
  290. package/skills/permdock-wire/references/policy-options.md +43 -0
@@ -0,0 +1,64 @@
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 { n as RevocationFeed } from "../revocations-Cy06JNx2.js";
5
+ import { r as PdpFactory } from "../types-BvBk1wgn.js";
6
+ import { S as ConnectionOptions, b as Connection, h as WebBotAuthVerifier, n as OpenApiHooks, o as TenantOption } from "../create-BKF3dgFk.js";
7
+ import { t as StreamProtectOptions } from "../stream-BhMfZOwr.js";
8
+ import { Middleware } from "@orpc/server";
9
+ //#region src/orpc/create.d.ts
10
+ type OrpcMiddlewareOpts<TCtx extends object = object, TInput = unknown> = {
11
+ readonly context: TCtx;
12
+ readonly input?: TInput;
13
+ readonly path?: readonly string[];
14
+ readonly next: (opts?: {
15
+ readonly context: TCtx;
16
+ }) => Promise<unknown>;
17
+ };
18
+ type OrpcMiddleware<TCtx extends object = object, TInput = unknown, V extends PolicyVocabulary = PolicyVocabulary> = Middleware<TCtx, TCtx & {
19
+ readonly permdock: PermDock<V>;
20
+ readonly permdockData?: unknown;
21
+ }, TInput, unknown, Record<never, never>>;
22
+ type OrpcPermDockOptions<TCtx extends object = object, TUser = unknown> = {
23
+ readonly subject: (opts: OrpcMiddlewareOpts<TCtx>) => TUser | Promise<TUser>;
24
+ readonly tenant?: TenantOption<OrpcMiddlewareOpts<TCtx>>;
25
+ /** The Web `Request` behind a context; defaults to `context.request` or `context.req`. */
26
+ readonly request?: (context: TCtx) => Request | null | undefined;
27
+ readonly memberships?: MembershipSource | readonly MembershipSource[];
28
+ /** The object graph for relation grants that walk a parent chain; without it they deny. */
29
+ readonly relations?: RelationSource;
30
+ readonly entitlements?: EntitlementSource;
31
+ readonly customRoles?: RoleSource;
32
+ /** Hosted grants, read once per instance; see `PolicySource`. */
33
+ readonly policies?: PolicySource;
34
+ readonly store?: ApprovalStore;
35
+ readonly sink?: DecisionSink;
36
+ readonly limits?: LimitStore;
37
+ /** `createPermDock` from `permdock/pdp`; `protect` then decides delegated permissions remotely. */
38
+ readonly pdp?: PdpFactory;
39
+ /** Accepted for adapter parity; not read by this adapter. */
40
+ readonly snapshots?: SnapshotSource;
41
+ /** `(request) => verifyWebBotAuth(request, options)`; a verified bot becomes the actor. */
42
+ readonly webBotAuth?: WebBotAuthVerifier;
43
+ /** Ends or revalidates open event iterators. */
44
+ readonly revocations?: RevocationFeed;
45
+ };
46
+ type OrpcOpenApiHooks<TCtx extends object = object, V extends PolicyVocabulary = PolicyVocabulary> = {
47
+ readonly protect: (permission: Permission, loadData?: (opts: OrpcMiddlewareOpts<TCtx>) => unknown, protectOptions?: StreamProtectOptions) => OrpcMiddleware<TCtx, unknown, V>;
48
+ readonly security: (permission: Permission) => {
49
+ readonly security: readonly Record<string, readonly string[]>[];
50
+ readonly "x-permdock-permissions": readonly string[];
51
+ };
52
+ readonly securitySchemes: OpenApiHooks["securitySchemes"];
53
+ };
54
+ type OrpcPermDock<TCtx extends object = object, V extends PolicyVocabulary = PolicyVocabulary> = {
55
+ readonly permdock: () => OrpcMiddleware<TCtx, unknown, V>;
56
+ readonly protect: (permission: Permission, loadData?: (opts: OrpcMiddlewareOpts<TCtx>) => unknown, protectOptions?: StreamProtectOptions) => OrpcMiddleware<TCtx, unknown, V>;
57
+ /** A long-lived connection for the request behind `context`. */
58
+ readonly connection: (opts: OrpcMiddlewareOpts<TCtx>, connectionOptions?: ConnectionOptions) => Promise<Connection>;
59
+ readonly permdockHandler: (request: Request) => Promise<Response>;
60
+ readonly openapi: OrpcOpenApiHooks<TCtx, V>;
61
+ };
62
+ export declare function createPermDock<TCtx extends object = object, TUser = unknown, TPrincipal extends Principal = Principal, V extends PolicyVocabulary = PolicyVocabulary>(policy: Policy<TUser, TPrincipal, V>, options: OrpcPermDockOptions<TCtx, TUser>): OrpcPermDock<TCtx, V>;
63
+ //#endregion
64
+ export type { OrpcMiddleware, OrpcMiddlewareOpts, OrpcOpenApiHooks, OrpcPermDock, OrpcPermDockOptions };
@@ -0,0 +1,188 @@
1
+ import { t as compact } from "../compact-y6vfu2_f.js";
2
+ import { o as invalidSignatureResponse } from "../evaluations-DsAU9ppl.js";
3
+ import { r as tenantScope, t as createKernel } from "../create-CSkhDU9T.js";
4
+ import { t as problemFromError } from "../map-error-RJ3ZsUyA.js";
5
+ import { n as guardIterable, r as isAsyncIterable } from "../stream-Q_xlB6Ko.js";
6
+ import { ORPCError } from "@orpc/server";
7
+ //#region src/orpc/create.ts
8
+ function hasBoundPermDock(context) {
9
+ return context !== null && typeof context === "object" && "permdock" in context && context.permdock !== void 0;
10
+ }
11
+ function requestFromCtx(ctx) {
12
+ if ("request" in ctx && ctx.request instanceof Request) return ctx.request;
13
+ if ("req" in ctx && ctx.req instanceof Request) return ctx.req;
14
+ }
15
+ function toOpts(mw, input, next) {
16
+ return compact({
17
+ context: mw.context,
18
+ input,
19
+ path: mw.path,
20
+ next
21
+ });
22
+ }
23
+ function problemMessage(cause, fallback) {
24
+ if (cause !== null && typeof cause === "object" && "detail" in cause && typeof cause.detail === "string" && cause.detail.length > 0) return cause.detail;
25
+ return fallback;
26
+ }
27
+ function orpcCode(status) {
28
+ switch (status) {
29
+ case 400: return "BAD_REQUEST";
30
+ case 401: return "UNAUTHORIZED";
31
+ case 404: return "NOT_FOUND";
32
+ case 429: return "TOO_MANY_REQUESTS";
33
+ case 503: return "SERVICE_UNAVAILABLE";
34
+ default: return "FORBIDDEN";
35
+ }
36
+ }
37
+ function orpcErrorFrom(error) {
38
+ const problem = error.toProblemDetails();
39
+ return new ORPCError(orpcCode(problem.status), {
40
+ message: error.code,
41
+ data: problem
42
+ });
43
+ }
44
+ async function throwOrpcError(response) {
45
+ let data;
46
+ try {
47
+ data = await response.json();
48
+ } catch {
49
+ data = { status: response.status };
50
+ }
51
+ const code = orpcCode(response.status);
52
+ throw new ORPCError(code, {
53
+ message: problemMessage(data, code),
54
+ data
55
+ });
56
+ }
57
+ /** A PermDock error thrown further down (an `assert` in a handler) becomes the ORPCError `protect` throws. */
58
+ function mapDownstream(run) {
59
+ return new Promise((resolve) => {
60
+ resolve(run());
61
+ }).catch((error) => {
62
+ const mapped = problemFromError(error);
63
+ if (mapped === void 0) throw error;
64
+ return throwOrpcError(mapped);
65
+ });
66
+ }
67
+ function createPermDock(policy, options) {
68
+ const optsByRequest = /* @__PURE__ */ new WeakMap();
69
+ const requestByCtx = /* @__PURE__ */ new WeakMap();
70
+ const kernel = createKernel(policy, compact({
71
+ subject: (request) => {
72
+ const opts = optsByRequest.get(request);
73
+ return opts === void 0 ? null : options.subject(opts);
74
+ },
75
+ memberships: options.memberships,
76
+ relations: options.relations,
77
+ entitlements: options.entitlements,
78
+ customRoles: options.customRoles,
79
+ policies: options.policies,
80
+ store: options.store,
81
+ sink: options.sink,
82
+ limits: options.limits,
83
+ pdp: options.pdp,
84
+ webBotAuth: options.webBotAuth,
85
+ revocations: options.revocations,
86
+ adapter: "orpc"
87
+ }));
88
+ const requestOf = (ctx) => {
89
+ if (options.request !== void 0) try {
90
+ return options.request(ctx) ?? void 0;
91
+ } catch {
92
+ return;
93
+ }
94
+ return requestFromCtx(ctx);
95
+ };
96
+ /**
97
+ * One `Request` per HTTP request, shared by every procedure in a batch. The
98
+ * subject reads the first procedure's opts; the tenant is resolved from each
99
+ * procedure's own opts in `scopeOf`, never through the shared `Request`.
100
+ */
101
+ const bind = (opts) => {
102
+ const ctx = opts.context;
103
+ const hit = requestByCtx.get(ctx);
104
+ if (hit !== void 0) return hit;
105
+ const path = opts.path?.join(".") ?? "orpc";
106
+ const request = requestOf(opts.context) ?? new Request(`http://localhost/orpc/${path}`, { method: "POST" });
107
+ requestByCtx.set(ctx, request);
108
+ if (!optsByRequest.has(request)) optsByRequest.set(request, opts);
109
+ return request;
110
+ };
111
+ const scopeOf = (opts) => tenantScope(options.tenant, opts);
112
+ const attach = (ctx, request) => {
113
+ requestByCtx.set(ctx, request);
114
+ };
115
+ const permdock = () => ((mwOptions, input) => {
116
+ const opts = toOpts(mwOptions, input, mwOptions.next);
117
+ if (hasBoundPermDock(opts.context)) return mwOptions.next({ context: opts.context });
118
+ const request = bind(opts);
119
+ return scopeOf(opts).then((scope) => kernel.permdock(request, scope)).then((instance) => {
120
+ const nextCtx = {
121
+ ...opts.context,
122
+ permdock: instance
123
+ };
124
+ attach(nextCtx, request);
125
+ return mapDownstream(() => mwOptions.next({ context: nextCtx }));
126
+ }, (error) => {
127
+ const response = invalidSignatureResponse(error);
128
+ if (response !== void 0) return throwOrpcError(response);
129
+ throw error;
130
+ });
131
+ });
132
+ const connection = async (opts, connectionOptions) => kernel.connection(bind(opts), connectionOptions, await scopeOf(opts));
133
+ /** Wraps an event iterator so revocation ends it and unreadable items drop. */
134
+ const guardOutput = async (result, opts, permission, loadData, protectOptions) => {
135
+ const output = result !== null && typeof result === "object" && "output" in result ? result.output : void 0;
136
+ if (!isAsyncIterable(output)) return result;
137
+ const conn = await connection(opts, compact({
138
+ permission,
139
+ data: loadData
140
+ }));
141
+ return {
142
+ ...result,
143
+ output: guardIterable(output, conn, compact({
144
+ items: protectOptions?.items,
145
+ onRevoked: orpcErrorFrom
146
+ }))
147
+ };
148
+ };
149
+ const protect = (permission, loadData, protectOptions) => (async (mwOptions, input) => {
150
+ const opts = toOpts(mwOptions, input, mwOptions.next);
151
+ const request = bind(opts);
152
+ const guard = await kernel.protect(permission, loadData === void 0 ? void 0 : () => loadData(opts), protectOptions)(request, await scopeOf(opts));
153
+ if (guard.ok) {
154
+ const nextCtx = {
155
+ ...opts.context,
156
+ permdock: guard.permdock,
157
+ permdockData: guard.data
158
+ };
159
+ attach(nextCtx, request);
160
+ return guardOutput(await mapDownstream(() => mwOptions.next({ context: nextCtx })), opts, permission, loadData === void 0 ? void 0 : () => loadData(opts), protectOptions);
161
+ }
162
+ return throwOrpcError(guard.response);
163
+ });
164
+ const permdockHandler = (request) => {
165
+ const opts = {
166
+ context: { req: request },
167
+ path: ["permdock"],
168
+ next: (nextOpts) => Promise.resolve(nextOpts ?? { context: { req: request } })
169
+ };
170
+ bind(opts);
171
+ const { POST, GET } = kernel.permdockHandler(() => scopeOf(opts));
172
+ return Promise.resolve(request.method === "GET" ? GET(request) : POST(request));
173
+ };
174
+ const kernelOpenApi = kernel.openapi;
175
+ return {
176
+ permdock,
177
+ protect,
178
+ connection,
179
+ permdockHandler,
180
+ openapi: {
181
+ protect,
182
+ security: kernelOpenApi.security,
183
+ securitySchemes: kernelOpenApi.securitySchemes
184
+ }
185
+ };
186
+ }
187
+ //#endregion
188
+ export { createPermDock };
@@ -0,0 +1,13 @@
1
+ import { E as PolicyVocabulary, Zt as PermDock } from "../policy-CInmNGkM.js";
2
+ import { a as OtelOptions, i as OtelApi, n as GEN_AI_TOOL_CALL_ID, o as OtelWrap, r as GEN_AI_TOOL_NAME, s as StructuralLogger, t as GENAI_SEMCONV_PIN } from "../types-B9dmiiab.js";
3
+ //#region src/otel/instrument.d.ts
4
+ /**
5
+ * Listens on one instance. Spans carry no duration and no histogram is
6
+ * recorded, because a listener only sees a decision after it is made; use
7
+ * `withOtel` for timings and for `tenant()` / `team()` derived instances.
8
+ */
9
+ export declare function instrument(permdock: PermDock, options?: OtelOptions): () => void;
10
+ /** Returns an instrumented instance: timed spans and histogram, derived instances included. */
11
+ export declare function withOtel<V extends PolicyVocabulary = PolicyVocabulary>(permdock: PermDock<V>, options?: OtelOptions): PermDock<V>;
12
+ //#endregion
13
+ export { GENAI_SEMCONV_PIN, GEN_AI_TOOL_CALL_ID, GEN_AI_TOOL_NAME, type OtelApi, type OtelOptions, type OtelWrap, type StructuralLogger };
@@ -0,0 +1,202 @@
1
+ import { t as compact } from "../compact-y6vfu2_f.js";
2
+ //#region src/otel/types.ts
3
+ const GENAI_SEMCONV_PIN = "1.37.0";
4
+ const GEN_AI_TOOL_NAME = "gen_ai.tool.name";
5
+ const GEN_AI_TOOL_CALL_ID = "gen_ai.tool.call.id";
6
+ //#endregion
7
+ //#region src/otel/instrument.ts
8
+ const FORBIDDEN = /* @__PURE__ */ new Set([
9
+ "__proto__",
10
+ "constructor",
11
+ "prototype"
12
+ ]);
13
+ const SPAN_STATUS_ERROR = 2;
14
+ const OTEL_REGISTRY = Symbol.for("opentelemetry.js.api.1");
15
+ const OTEL_SPAN_KEY = Symbol.for("OpenTelemetry Context Key SPAN");
16
+ function registry() {
17
+ const value = globalThis[OTEL_REGISTRY];
18
+ return typeof value === "object" && value !== null ? value : void 0;
19
+ }
20
+ const NOOP_TRACER = { startSpan: () => ({}) };
21
+ const registryApi = {
22
+ trace: {
23
+ getTracer: (name) => registry()?.trace?.getTracer?.(name) ?? NOOP_TRACER,
24
+ getActiveSpan: () => registry()?.context?.active?.()?.getValue?.(OTEL_SPAN_KEY)
25
+ },
26
+ metrics: { getMeter: (name) => registry()?.metrics?.getMeter?.(name) ?? {
27
+ createCounter: () => ({ add: () => void 0 }),
28
+ createHistogram: () => ({ record: () => void 0 })
29
+ } }
30
+ };
31
+ function resolveApi(injected) {
32
+ if (injected !== void 0) return injected;
33
+ return registry() === void 0 ? void 0 : registryApi;
34
+ }
35
+ function safeCall(fn, logger) {
36
+ try {
37
+ fn();
38
+ } catch (error) {
39
+ if (logger?.error !== void 0) try {
40
+ logger.error("permdock.otel", { cause: String(error) });
41
+ } catch {}
42
+ }
43
+ }
44
+ function omitPath(attributes, path) {
45
+ if (Object.hasOwn(attributes, path)) {
46
+ const next = {};
47
+ for (const key of Object.keys(attributes)) if (key !== path) next[key] = attributes[key];
48
+ return {
49
+ attributes: next,
50
+ matched: true
51
+ };
52
+ }
53
+ const parts = path.split(".");
54
+ if (parts.some((part) => FORBIDDEN.has(part))) return {
55
+ attributes,
56
+ matched: false
57
+ };
58
+ const [head, ...rest] = parts;
59
+ if (head === void 0 || rest.length === 0 || !Object.hasOwn(attributes, head)) return {
60
+ attributes,
61
+ matched: false
62
+ };
63
+ const nested = attributes[head];
64
+ if (nested === null || typeof nested !== "object") return {
65
+ attributes,
66
+ matched: false
67
+ };
68
+ const child = omitPath(nested, rest.join("."));
69
+ if (!child.matched) return {
70
+ attributes,
71
+ matched: false
72
+ };
73
+ return {
74
+ attributes: {
75
+ ...attributes,
76
+ [head]: child.attributes
77
+ },
78
+ matched: true
79
+ };
80
+ }
81
+ function attributesOf(event, options, parent) {
82
+ const extra = options.attributes === void 0 ? {} : options.attributes(event);
83
+ let redacted = compact({
84
+ "permdock.outcome": event.outcome,
85
+ "permdock.permission": event.permission,
86
+ "permdock.scope": event.scope,
87
+ "permdock.resource.type": event.resource.type,
88
+ "permdock.resource.id": event.resource.id,
89
+ "permdock.subject.id": event.subject.principal?.id,
90
+ "permdock.actor.id": event.subject.actor?.id,
91
+ "permdock.actor.kind": event.subject.actor?.kind,
92
+ "permdock.delegation.scopes": event.subject.delegation?.scopes?.join(","),
93
+ "permdock.matched.role": event.matched?.role,
94
+ "permdock.denials.count": event.denials?.length,
95
+ "permdock.token": event.token,
96
+ "permdock.validate": event.trusted ? "trusted" : "boundary",
97
+ "permdock.adapter": event.adapter,
98
+ "permdock.filter.total": event.counts === void 0 ? void 0 : event.counts.granted + event.counts.denied + event.counts.approvalRequired,
99
+ "permdock.filter.kept": event.counts?.granted,
100
+ [GEN_AI_TOOL_NAME]: parent?.attributes?.[GEN_AI_TOOL_NAME],
101
+ [GEN_AI_TOOL_CALL_ID]: parent?.attributes?.[GEN_AI_TOOL_CALL_ID],
102
+ ...extra
103
+ });
104
+ const unmatched = [];
105
+ for (const path of options.redact ?? []) {
106
+ const result = omitPath(redacted, path);
107
+ redacted = result.attributes;
108
+ if (!result.matched) unmatched.push(path);
109
+ }
110
+ if (unmatched.length > 0) safeCall(() => {
111
+ options.logger?.warn(`permdock.otel unmatched redact: ${unmatched.join(", ")}`);
112
+ }, options.logger);
113
+ return redacted;
114
+ }
115
+ /** Epoch milliseconds with sub-millisecond precision, the OTel `TimeInput` form. */
116
+ function now() {
117
+ return performance.timeOrigin + performance.now();
118
+ }
119
+ function recordSignals(event, options, api, timing) {
120
+ const parent = api?.trace.getActiveSpan?.();
121
+ const attributes = attributesOf(event, options, parent);
122
+ if (options.logger !== void 0) safeCall(() => {
123
+ options.logger?.info("permdock.decision", attributes);
124
+ }, options.logger);
125
+ if (api === void 0) return;
126
+ const name = options.tracer ?? "permdock";
127
+ const span = api.trace.getTracer(name).startSpan("permdock.decide", timing === void 0 ? void 0 : { startTime: timing.start });
128
+ if (span.isRecording?.() === false) safeCall(() => {
129
+ options.logger?.warn("permdock.otel: @opentelemetry/api is present but no provider is registered");
130
+ }, options.logger);
131
+ span.setAttributes?.(attributes);
132
+ if (event.outcome === "denied") {
133
+ span.addEvent?.("permdock.denied", compact({
134
+ role: event.denials?.map((denial) => denial.role).join(","),
135
+ reason: event.denials?.map((denial) => denial.reason).join(","),
136
+ alternatives: event.alternatives?.join(",")
137
+ }));
138
+ if (event.denials?.some((denial) => denial.reason === "validation") === true) span.recordException?.(/* @__PURE__ */ new Error("validation"));
139
+ if (options.errorOnDeny === true) span.setStatus?.({ code: SPAN_STATUS_ERROR });
140
+ }
141
+ span.end?.(timing?.end);
142
+ const meter = api.metrics?.getMeter(name);
143
+ const counterAttrs = compact({
144
+ "permdock.outcome": event.outcome,
145
+ "permdock.permission": event.permission,
146
+ "permdock.adapter": event.adapter
147
+ });
148
+ meter?.createCounter("permdock.decisions").add(1, counterAttrs);
149
+ if (timing !== void 0) meter?.createHistogram("permdock.decide.duration", { unit: "s" }).record((timing.end - timing.start) / 1e3, counterAttrs);
150
+ }
151
+ function listen(permdock, options, api, startedAt) {
152
+ return permdock.on("decision", (payload) => {
153
+ const end = now();
154
+ const start = startedAt();
155
+ const event = payload;
156
+ safeCall(() => {
157
+ recordSignals(event, options, api, start === void 0 ? void 0 : {
158
+ start,
159
+ end
160
+ });
161
+ }, options.logger);
162
+ });
163
+ }
164
+ /**
165
+ * Listens on one instance. Spans carry no duration and no histogram is
166
+ * recorded, because a listener only sees a decision after it is made; use
167
+ * `withOtel` for timings and for `tenant()` / `team()` derived instances.
168
+ */
169
+ function instrument(permdock, options = {}) {
170
+ return listen(permdock, options, resolveApi(options.api), () => void 0);
171
+ }
172
+ function instrumented(permdock, options, api) {
173
+ let started;
174
+ listen(permdock, options, api, () => started);
175
+ const timed = (fn) => (...args) => {
176
+ const outer = started === void 0;
177
+ if (outer) started = now();
178
+ try {
179
+ return fn(...args);
180
+ } finally {
181
+ if (outer) started = void 0;
182
+ }
183
+ };
184
+ return Object.freeze({
185
+ ...permdock,
186
+ can: timed(permdock.can),
187
+ decide: timed(permdock.decide),
188
+ assert: timed(permdock.assert),
189
+ explain: timed(permdock.explain),
190
+ filter: timed(permdock.filter),
191
+ pick: timed(permdock.pick),
192
+ actions: timed(permdock.actions),
193
+ tenant: (id) => instrumented(permdock.tenant(id), options, api),
194
+ team: (id) => instrumented(permdock.team(id), options, api)
195
+ });
196
+ }
197
+ /** Returns an instrumented instance: timed spans and histogram, derived instances included. */
198
+ function withOtel(permdock, options = {}) {
199
+ return instrumented(permdock, options, resolveApi(options.api));
200
+ }
201
+ //#endregion
202
+ export { GENAI_SEMCONV_PIN, GEN_AI_TOOL_CALL_ID, GEN_AI_TOOL_NAME, instrument, withOtel };
@@ -0,0 +1,30 @@
1
+ import { existsSync, readFileSync } from "node:fs";
2
+ import { dirname, join } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ //#region src/cli/package-root.ts
5
+ let cached;
6
+ /**
7
+ * The `permdock` package directory. The bundler may place this module in
8
+ * `dist/cli/` or in a shared chunk at `dist/`, so walk up instead of
9
+ * assuming a depth.
10
+ */
11
+ function packageRoot() {
12
+ cached ??= findPackageRoot(dirname(fileURLToPath(import.meta.url)));
13
+ return cached;
14
+ }
15
+ /** The nearest directory at or above `start` whose `package.json` is named `permdock`. */
16
+ function findPackageRoot(start) {
17
+ let dir = start;
18
+ for (;;) {
19
+ const manifest = join(dir, "package.json");
20
+ if (existsSync(manifest)) {
21
+ const { name } = JSON.parse(readFileSync(manifest, "utf8"));
22
+ if (name === "permdock") return dir;
23
+ }
24
+ const parent = dirname(dir);
25
+ if (parent === dir) throw new Error("PermDock CLI: cannot find the permdock package root");
26
+ dir = parent;
27
+ }
28
+ }
29
+ //#endregion
30
+ export { packageRoot as t };
@@ -0,0 +1,135 @@
1
+ import { n as freezeDeep } from "./freeze-y1_jQL4v.js";
2
+ import { i as PermDockValidationError } from "./errors-Iy71s7Oj.js";
3
+ import { t as catalogSchema } from "./schema-P8yoma__.js";
4
+ //#region src/catalog/parse.ts
5
+ function issue(issues, path, message) {
6
+ issues.push({
7
+ message,
8
+ path: [...path]
9
+ });
10
+ }
11
+ function isRecord(value) {
12
+ return value !== null && typeof value === "object" && !Array.isArray(value);
13
+ }
14
+ /**
15
+ * A plain-data copy built from own enumerable keys, so `__proto__` stays an
16
+ * ordinary key and nothing the input inherits is read. Anything JSON cannot
17
+ * carry is an issue.
18
+ */
19
+ function copyJson(value, path, issues, ancestors) {
20
+ if (value === null || typeof value === "string" || typeof value === "boolean") return value;
21
+ if (typeof value === "number") {
22
+ if (!Number.isFinite(value)) issue(issues, path, "Expected a finite number");
23
+ return value;
24
+ }
25
+ if (typeof value !== "object") {
26
+ issue(issues, path, `Expected JSON, got ${typeof value}`);
27
+ return;
28
+ }
29
+ if (ancestors.has(value)) {
30
+ issue(issues, path, "Expected JSON, got a cycle");
31
+ return;
32
+ }
33
+ ancestors.add(value);
34
+ try {
35
+ if (Array.isArray(value)) return value.map((item, index) => copyJson(item, [...path, index], issues, ancestors));
36
+ const proto = Object.getPrototypeOf(value);
37
+ if (proto !== Object.prototype && proto !== null) {
38
+ issue(issues, path, "Expected a plain object");
39
+ return;
40
+ }
41
+ return Object.fromEntries(Object.keys(value).map((key) => [key, copyJson(Reflect.get(value, key), [...path, key], issues, ancestors)]));
42
+ } finally {
43
+ ancestors.delete(value);
44
+ }
45
+ }
46
+ function typeMatches(type, value) {
47
+ switch (type) {
48
+ case "object": return isRecord(value);
49
+ case "array": return Array.isArray(value);
50
+ case "string": return typeof value === "string";
51
+ case "boolean": return typeof value === "boolean";
52
+ case "integer": return Number.isInteger(value);
53
+ default: return type;
54
+ }
55
+ }
56
+ /** The subset of JSON Schema 2020-12 `CatalogSchemaNode` names, over a `copyJson` result. */
57
+ function checkSchema(node, value, path, issues) {
58
+ if ("const" in node && value !== node.const) {
59
+ issue(issues, path, `Expected ${JSON.stringify(node.const)}`);
60
+ return;
61
+ }
62
+ if (node.enum !== void 0 && !node.enum.includes(value)) {
63
+ issue(issues, path, `Expected one of ${node.enum.map((item) => JSON.stringify(item)).join(", ")}`);
64
+ return;
65
+ }
66
+ if (node.type !== void 0 && !typeMatches(node.type, value)) {
67
+ issue(issues, path, `Expected ${node.type}`);
68
+ return;
69
+ }
70
+ if (node.pattern !== void 0 && typeof value === "string" && !new RegExp(node.pattern, "u").test(value)) issue(issues, path, `Expected a string matching ${node.pattern}`);
71
+ if (node.minimum !== void 0 && typeof value === "number" && value < node.minimum) issue(issues, path, `Expected at least ${String(node.minimum)}`);
72
+ if (node.oneOf !== void 0) {
73
+ if (node.oneOf.filter((option) => {
74
+ const scratch = [];
75
+ checkSchema(option, value, path, scratch);
76
+ return scratch.length === 0;
77
+ }).length !== 1) issue(issues, path, "Expected exactly one matching form");
78
+ }
79
+ if (Array.isArray(value) && node.items !== void 0) for (const [index, item] of value.entries()) checkSchema(node.items, item, [...path, index], issues);
80
+ if (!isRecord(value)) return;
81
+ for (const key of node.required ?? []) if (!Object.hasOwn(value, key)) issue(issues, [...path, key], "Required");
82
+ const properties = node.properties ?? {};
83
+ for (const key of Object.keys(value)) {
84
+ const child = Object.hasOwn(properties, key) ? properties[key] : node.additionalProperties;
85
+ if (child !== void 0) checkSchema(child, value[key], [...path, key], issues);
86
+ }
87
+ }
88
+ function invalid(issues) {
89
+ const [first] = issues;
90
+ const where = first?.path === void 0 || first.path.length === 0 ? "" : ` at ${first.path.map(String).join(".")}`;
91
+ const more = issues.length > 1 ? ` (and ${String(issues.length - 1)} more)` : "";
92
+ throw new PermDockValidationError({
93
+ code: "invalid-data",
94
+ permission: "",
95
+ resource: "",
96
+ boundary: "catalog",
97
+ issues,
98
+ message: `PermDock: invalid catalog${where}: ${first?.message ?? "unknown"}${more}`
99
+ });
100
+ }
101
+ /**
102
+ * Reads a `permissions.catalog.json` document (parsed, or the JSON text) and
103
+ * validates it against `schemas/catalog-v1.json`. Returns a deep-frozen copy
104
+ * built from own keys; throws `PermDockValidationError` with every issue.
105
+ */
106
+ function parseCatalog(json) {
107
+ const issues = [];
108
+ let input = json;
109
+ if (typeof json === "string") try {
110
+ input = JSON.parse(json);
111
+ } catch (error) {
112
+ invalid([{
113
+ message: `Expected JSON text: ${error instanceof Error ? error.message : String(error)}`,
114
+ path: []
115
+ }]);
116
+ }
117
+ let copy;
118
+ try {
119
+ copy = copyJson(input, [], issues, /* @__PURE__ */ new Set());
120
+ } catch (error) {
121
+ invalid([{
122
+ message: `Could not read the input: ${error instanceof Error ? error.message : String(error)}`,
123
+ path: []
124
+ }]);
125
+ }
126
+ if (issues.length === 0) checkSchema(catalogSchema, copy, [], issues);
127
+ if (issues.length > 0) invalid(issues);
128
+ return freezeDeep(copy);
129
+ }
130
+ /** Keys of the permissions the catalog marks `rowConditions: true`: the SQL helpers alone cannot enforce them. */
131
+ function rowConditionKeys(catalog) {
132
+ return new Set(catalog.permissions.filter((permission) => permission.rowConditions === true).map((permission) => permission.key));
133
+ }
134
+ //#endregion
135
+ export { rowConditionKeys as n, parseCatalog as t };
@@ -0,0 +1,22 @@
1
+ import { C as Policy, E as PolicyVocabulary, Q as DecisionProvider, Qt as PermDockOptions, mr as Principal } from "../policy-CInmNGkM.js";
2
+ import { a as RelationMap, c as RemotePdpEndpoints, d as SpiceDbCheck, f as SpiceDbOptions, i as PdpPermDock, l as RemotePdpMapping, n as OpenFgaTuple, o as RemotePdpAuth, r as PdpFactory, s as RemotePdpCache, t as OpenFgaOptions, u as RemotePdpOptions } from "../types-BvBk1wgn.js";
3
+ //#region src/pdp/create.d.ts
4
+ export declare function createPermDock<TUser, TPrincipal extends Principal = Principal, V extends PolicyVocabulary = PolicyVocabulary>(policy: Policy<TUser, TPrincipal, V>, user: TUser | null, options?: PermDockOptions): Promise<PdpPermDock<V>>;
5
+ //#endregion
6
+ //#region src/pdp/relations.d.ts
7
+ /**
8
+ * An OpenFGA store as a decision provider: `check` decides one row and
9
+ * `list-objects` lists the ids `filter` and `where` use.
10
+ */
11
+ export declare function openfga(options: OpenFgaOptions): DecisionProvider;
12
+ /**
13
+ * A SpiceDB HTTP gateway as a decision provider: `CheckPermission` decides
14
+ * one row and `LookupResources` lists the ids `filter` and `where` use. A
15
+ * conditional permissionship (a caveat missing context) is a denial.
16
+ */
17
+ export declare function spicedb(options: SpiceDbOptions): DecisionProvider;
18
+ //#endregion
19
+ //#region src/pdp/remote.d.ts
20
+ export declare function remotePdp(options: RemotePdpOptions): DecisionProvider;
21
+ //#endregion
22
+ export type { OpenFgaOptions, OpenFgaTuple, PdpFactory, PdpPermDock, RelationMap, RemotePdpAuth, RemotePdpCache, RemotePdpEndpoints, RemotePdpMapping, RemotePdpOptions, SpiceDbCheck, SpiceDbOptions };