permdock 0.25.1 → 0.27.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 (969) hide show
  1. package/README.md +1 -1
  2. package/dist/2020-bJfT8aIA.js +6760 -0
  3. package/dist/a2a/index.d.ts +5 -9
  4. package/dist/a2a/index.js +13 -15
  5. package/dist/adapter-context-lHq_i_77.js +28 -0
  6. package/dist/adoption-scan-CMghLDUG.js +106 -0
  7. package/dist/agent/index.d.ts +2 -2
  8. package/dist/agent/index.js +1 -1
  9. package/dist/ai-sdk/index.d.ts +4 -6
  10. package/dist/ai-sdk/index.js +6 -7
  11. package/dist/annotate-doc-BCOCOrq_.js +214 -0
  12. package/dist/annotate-routes-BvSuEht3.js +75 -0
  13. package/dist/annotate-uZVGIRym.js +25 -0
  14. package/dist/app/index.d.ts +2 -103
  15. package/dist/app/index.js +1 -114
  16. package/dist/app-data-DbSPSPIl.js +62 -0
  17. package/dist/approval-header-BvszJE3l.js +25 -0
  18. package/dist/approval-normalize-Cpp8R0rY.js +190 -0
  19. package/dist/approval-prompt-C-vjNZyd.d.ts +57 -0
  20. package/dist/approval-prompt-Covyx_DB.js +60 -0
  21. package/dist/approval-required-B-R4Yw3J.js +5 -0
  22. package/dist/approvals/index.d.ts +5 -5
  23. package/dist/approvals/index.js +8 -8
  24. package/dist/approvals-7jHYXocE.js +1039 -0
  25. package/dist/approvers-BkY_ZfWl.js +76 -0
  26. package/dist/arazzo-B8heXoYy.js +76 -0
  27. package/dist/arazzo-DdJBVrsy.js +35 -0
  28. package/dist/args-0EWFk-4S.js +311 -0
  29. package/dist/astro/index.d.ts +6 -8
  30. package/dist/astro/index.js +3 -4
  31. package/dist/audience-DauhRBNg.js +54 -0
  32. package/dist/auth-WHKYWtnS.js +187 -0
  33. package/dist/authz-topic-D8x24Jv-.js +14 -0
  34. package/dist/authzen/index.d.ts +37 -22
  35. package/dist/authzen/index.js +69 -27
  36. package/dist/automation-CUcWz8uu.d.ts +122 -0
  37. package/dist/automation-CpPdFX91.js +157 -0
  38. package/dist/base-url--yJPQlIK.js +8 -0
  39. package/dist/better-auth/index.d.ts +2 -8
  40. package/dist/better-auth/index.js +10 -13
  41. package/dist/better-supabase/index.d.ts +141 -95
  42. package/dist/better-supabase/index.js +239 -794
  43. package/dist/better-supabase-DSbs4MtQ.js +201 -0
  44. package/dist/bind-B3MHrzw4.d.ts +56 -0
  45. package/dist/bind-up3QptTt.js +124 -0
  46. package/dist/body-W1_8r6Tw.js +9 -0
  47. package/dist/body-text-B-m3p-qY.js +55 -0
  48. package/dist/boundary--5Swp7sN.js +18 -0
  49. package/dist/boundary-DJqHADKu.d.ts +22 -0
  50. package/dist/budget-5LJ8kfZk.d.ts +12 -0
  51. package/dist/budget-BH81q2cj.js +19 -0
  52. package/dist/build-instance-hLKYe3-E.js +30 -0
  53. package/dist/canonical-json-BibZkXtE.js +28 -0
  54. package/dist/capability-CVt3lpVK.d.ts +128 -0
  55. package/dist/capability-_ZsyfYxU.js +204 -0
  56. package/dist/casbin-BHYVxJDD.js +29 -0
  57. package/dist/casbin-D33ZeUf5.js +241 -0
  58. package/dist/casl-CrltbDPa.js +23 -0
  59. package/dist/casl-D7n7yE-h.js +307 -0
  60. package/dist/catalog/index.d.ts +6 -20
  61. package/dist/catalog/index.js +13 -15
  62. package/dist/catalog-B3MJShnZ.js +51 -0
  63. package/dist/catalog-CgK_L4Qf.js +1 -0
  64. package/dist/catalog-DyC3LKc7.js +130 -0
  65. package/dist/catalog-doc-Bp5khmCG.js +352 -0
  66. package/dist/catalog-fingerprint-DAWZARy6.js +31 -0
  67. package/dist/catalog-operations-dxuOZr4J.js +59 -0
  68. package/dist/catalog-path-bG0XxHMu.js +11 -0
  69. package/dist/challenge-CjwmjcuX.js +518 -0
  70. package/dist/chat/index.d.ts +1 -1
  71. package/dist/chat/index.js +10 -13
  72. package/dist/chat-sdk/index.d.ts +3 -11
  73. package/dist/chat-sdk/index.js +7 -11
  74. package/dist/checks-DSm45qH7.js +71 -0
  75. package/dist/claims-map-BGbpbvGD.js +15 -0
  76. package/dist/claims-map-CLKQWxJG.d.ts +33 -0
  77. package/dist/claims-size-DcjhvUv5.js +58 -0
  78. package/dist/claude-agent/index.d.ts +3 -5
  79. package/dist/claude-agent/index.js +4 -5
  80. package/dist/clerk/index.d.ts +4 -8
  81. package/dist/clerk/index.js +7 -8
  82. package/dist/cli/bin.js +6 -7
  83. package/dist/cli/generate/watch-worker.d.ts +20 -0
  84. package/dist/cli/generate/watch-worker.js +69 -0
  85. package/dist/cli/index.d.ts +11 -20
  86. package/dist/cli/index.js +8 -8
  87. package/dist/cli/plugins/app.d.ts +24 -0
  88. package/dist/cli/plugins/app.js +36 -0
  89. package/dist/cli/plugins/better-supabase.d.ts +10 -0
  90. package/dist/cli/plugins/better-supabase.js +18 -0
  91. package/dist/cli/plugins/openapi.d.ts +19 -0
  92. package/dist/cli/plugins/openapi.js +40 -0
  93. package/dist/cli/plugins/powersync.d.ts +7 -0
  94. package/dist/cli/plugins/powersync.js +29 -0
  95. package/dist/cli/plugins/rls.d.ts +8 -0
  96. package/dist/cli/plugins/rls.js +27 -0
  97. package/dist/cli/plugins/schemas.d.ts +13 -0
  98. package/dist/cli/plugins/schemas.js +23 -0
  99. package/dist/cli/plugins/scim.d.ts +10 -0
  100. package/dist/cli/plugins/scim.js +32 -0
  101. package/dist/cli/plugins/supabase-hook.d.ts +13 -0
  102. package/dist/cli/plugins/supabase-hook.js +40 -0
  103. package/dist/cli/plugins/supabase.d.ts +27 -0
  104. package/dist/cli/plugins/supabase.js +69 -0
  105. package/dist/cli/plugins/ui.d.ts +11 -0
  106. package/dist/cli/plugins/ui.js +19 -0
  107. package/dist/client-V95IvZsF.d.ts +43 -0
  108. package/dist/client-subject-v89t811z.d.ts +25 -0
  109. package/dist/clients-Bb_33pRE.js +22 -0
  110. package/dist/clients-DGcyFDCc.d.ts +10 -0
  111. package/dist/cloud/index.d.ts +8 -26
  112. package/dist/cloud/index.js +22 -28
  113. package/dist/cloud-BmQrcTvx.js +85 -0
  114. package/dist/codemod-BpjMjxly.js +2159 -0
  115. package/dist/codemod-C_NKj01W.js +35 -0
  116. package/dist/collect-BJZsuBW4.js +535 -0
  117. package/dist/collect-CPvCXMQ-.js +1 -0
  118. package/dist/collect-CpGnmGpL.js +54 -0
  119. package/dist/command-9GAzSI7E.js +5 -0
  120. package/dist/compact-C4LFuqbW.js +28 -0
  121. package/dist/compare-dfHDj8kT.js +11 -0
  122. package/dist/compile/index.d.ts +2 -2
  123. package/dist/compile/index.js +1 -1
  124. package/dist/compile-BUKXrueE.js +685 -0
  125. package/dist/compile-D8c1nFGy.d.ts +118 -0
  126. package/dist/compile-Dy3zMRxo.js +724 -0
  127. package/dist/completion-CSncf6cX.js +150 -0
  128. package/dist/conditions-CkHgXoZB.js +385 -0
  129. package/dist/config-iyy90IOU.js +143 -0
  130. package/dist/config-report-D607UDnv.js +55 -0
  131. package/dist/config-shape-B6tdyBju.js +149 -0
  132. package/dist/config-xiX3R65I.js +25 -0
  133. package/dist/connection-BnoSqYU1.js +196 -0
  134. package/dist/connector-schema-BSRMyq4M.js +433 -0
  135. package/dist/constants-PCJiir_3.js +19 -0
  136. package/dist/context-DmH-Eyvx.js +95 -0
  137. package/dist/convex/index.d.ts +5 -9
  138. package/dist/convex/index.js +7 -8
  139. package/dist/core-CnC47rSf.d.ts +200 -0
  140. package/dist/core-DKqrD_xW.js +338 -0
  141. package/dist/coverage-DL7JCZmb.d.ts +133 -0
  142. package/dist/coverage-nFSMjFxH.js +42 -0
  143. package/dist/create-BAMPoEga.js +133 -0
  144. package/dist/create-BsRcXm_m.d.ts +125 -0
  145. package/dist/create-D3oXoXxM.js +373 -0
  146. package/dist/create-DeQ5t8mZ.d.ts +124 -0
  147. package/dist/create-sGl1ccTp.d.ts +185 -0
  148. package/dist/credential-ke0KMQeB.js +430 -0
  149. package/dist/credentials-6ZWbJ-Re.js +72 -0
  150. package/dist/credentials-BfzdL5kv.d.ts +123 -0
  151. package/dist/credentials-DOeqknte.js +309 -0
  152. package/dist/decide-set-CgNcE6pP.js +99 -0
  153. package/dist/deciding-columns-BnglEKqU.js +143 -0
  154. package/dist/decision-hHv4UZgy.js +20 -0
  155. package/dist/define-permdock-BLpQ0m95.d.ts +99 -0
  156. package/dist/define-permdock-CIxHBykk.js +148 -0
  157. package/dist/definition-options-9o8Hdww3.js +370 -0
  158. package/dist/delegation-BaUNCrE_.js +263 -0
  159. package/dist/delegation-input-7Y5Rlja7.js +18 -0
  160. package/dist/delivery/index.d.ts +4 -4
  161. package/dist/delivery/index.js +5 -5
  162. package/dist/delivery-Cb3VCij5.js +555 -0
  163. package/dist/delivery-event-D5b9yhaJ.js +39 -0
  164. package/dist/denied-text-D6JJTDr3.d.ts +20 -0
  165. package/dist/describe-B7EosIKA.js +100 -0
  166. package/dist/describe-lAafaRQQ.d.ts +43 -0
  167. package/dist/device-f3JEnqa0.js +195 -0
  168. package/dist/diff-BIqibFnm.js +464 -0
  169. package/dist/diff-n6LONVwL.js +36 -0
  170. package/dist/digest-BaP8bQzX.js +26 -0
  171. package/dist/digest-BcIZRYvp.d.ts +17 -0
  172. package/dist/doctor-BhoJiHi0.js +4847 -0
  173. package/dist/doctor-CoKSRLhf.js +53 -0
  174. package/dist/drizzle/index.d.ts +5 -9
  175. package/dist/drizzle/index.js +5 -6
  176. package/dist/elysia/index.d.ts +6 -8
  177. package/dist/elysia/index.js +6 -7
  178. package/dist/env-hbYumkRp.js +7 -0
  179. package/dist/errors-DOSkVeTC.js +127 -0
  180. package/dist/errors-DUJ7wLlE.d.ts +137 -0
  181. package/dist/errors-Da88YLm5.js +26 -0
  182. package/dist/errors-DgLOqc6j.js +148 -0
  183. package/dist/errors-KngVdJT9.d.ts +12 -0
  184. package/dist/evaluate-D8SdfP3h.js +1948 -0
  185. package/dist/evaluations-BQkpE7hC.js +609 -0
  186. package/dist/evaluations-K9qglDP7.d.ts +36 -0
  187. package/dist/evaluator-Dlhn2d7D.js +2 -0
  188. package/dist/evaluator-eager-UuJK6NX_.js +8 -0
  189. package/dist/eve/index.d.ts +11 -10
  190. package/dist/eve/index.js +7 -8
  191. package/dist/event-time-ChIrhzy5.js +26 -0
  192. package/dist/execute-CyQLisIB.js +166 -0
  193. package/dist/express/index.d.ts +6 -8
  194. package/dist/express/index.js +6 -7
  195. package/dist/fastify/index.d.ts +5 -11
  196. package/dist/fastify/index.js +6 -8
  197. package/dist/fetch-adapter-gmTCu4FR.d.ts +32 -0
  198. package/dist/fetch-adapter-ovZdSvlT.js +124 -0
  199. package/dist/fields-6d1j-q3c.js +502 -0
  200. package/dist/fields-C0L2FoZk.js +25 -0
  201. package/dist/files-DAR51W3J.js +157 -0
  202. package/dist/files-DuV7wRim.js +139 -0
  203. package/dist/fixtures-Bm0G0A7H.js +79 -0
  204. package/dist/flags-C0e-BzGW.js +112 -0
  205. package/dist/freeze-DGfJq_j2.js +86 -0
  206. package/dist/from-snapshot-CCDF_ihX.js +173 -0
  207. package/dist/gen-CJE3Xud5.js +1168 -0
  208. package/dist/gen-WzJbAcMJ.js +1 -0
  209. package/dist/gen-kind-DFQnQwFN.d.ts +13 -0
  210. package/dist/gen-kind-DGQxmID0.js +69 -0
  211. package/dist/generate-5_kz2309.js +305 -0
  212. package/dist/generate-DF6Y8ncI.js +67 -0
  213. package/dist/generate-DIZNzMuk.js +2339 -0
  214. package/dist/generate-DhP0jQDR.js +97 -0
  215. package/dist/generate-options-CLPUvgVW.js +1185 -0
  216. package/dist/grantee-BPUG6f0r.js +109 -0
  217. package/dist/grantee-conditions-Dob6QQAc.js +270 -0
  218. package/dist/grantee-match-CFQ-LRcL.js +147 -0
  219. package/dist/grants-BzjbUCdR.js +139 -0
  220. package/dist/graph-sql-Ds3nbevr.d.ts +27 -0
  221. package/dist/h3/index.d.ts +4 -6
  222. package/dist/h3/index.js +4 -5
  223. package/dist/headers-D1oRr-js.d.ts +8 -0
  224. package/dist/helpers-DSmj6SHi.js +533 -0
  225. package/dist/hono/index.d.ts +6 -8
  226. package/dist/hono/index.js +7 -8
  227. package/dist/hook-sql-FSets5NB.js +3412 -0
  228. package/dist/hosted-DMJKJPoc.js +361 -0
  229. package/dist/hosted-DUbuh0Td.d.ts +100 -0
  230. package/dist/http-BUIYu1Kc.d.ts +10 -0
  231. package/dist/http-BbX_Ou3_.js +48 -0
  232. package/dist/http-C9jDw_bZ.js +82 -0
  233. package/dist/http-dNltTpC8.js +71 -0
  234. package/dist/ids-0QDIxtxL.js +53 -0
  235. package/dist/import-BqoDHpFt.js +1158 -0
  236. package/dist/import-DemSCI1R.js +318 -0
  237. package/dist/index-BXz-XXC3.d.ts +1108 -0
  238. package/dist/index-CVuc3E1O.d.ts +196 -0
  239. package/dist/index-Cq9N5B92.d.ts +506 -0
  240. package/dist/index-D8A1d_Tt.d.ts +214 -0
  241. package/dist/index-DegTwZxD.d.ts +93 -0
  242. package/dist/index-O0qbI8Ha.d.ts +221 -0
  243. package/dist/index.d.ts +24 -25
  244. package/dist/index.js +47 -46
  245. package/dist/init-BlYRZRnQ.js +94 -0
  246. package/dist/init-CgoOwXtk.js +95 -0
  247. package/dist/instance-options-B4MD2wgl.d.ts +9 -0
  248. package/dist/instance-options-CLErhA76.js +23 -0
  249. package/dist/instance-snapshot-DdGOpSfN.js +716 -0
  250. package/dist/instant-Ih5riY_A.js +18 -0
  251. package/dist/interactive-only-BZu9rLpa.js +1567 -0
  252. package/dist/internals-D58TnmDB.js +19 -0
  253. package/dist/json-schema-SDkWXxhu.d.ts +38 -0
  254. package/dist/json-schema-jtX26ydD.js +148 -0
  255. package/dist/jwt/index.d.ts +6 -24
  256. package/dist/jwt/index.js +18 -26
  257. package/dist/kernel-Dn6pKMAF.js +423 -0
  258. package/dist/kysely/index.d.ts +5 -9
  259. package/dist/kysely/index.js +5 -6
  260. package/dist/lazy-provider-CydlnKkS.d.ts +4 -0
  261. package/dist/lazy-provider-DG5rMeqL.js +28 -0
  262. package/dist/limits-DpTxX6N4.js +166 -0
  263. package/dist/live-options-CIUmc-YQ.js +70 -0
  264. package/dist/load-BPzIqlGB.js +1 -0
  265. package/dist/load-CZnlAyZ8.js +98 -0
  266. package/dist/load-jose-CjzIBSKI.js +7 -0
  267. package/dist/login-CNQJN8Fy.js +67 -0
  268. package/dist/login-TwrSjf6k.js +255 -0
  269. package/dist/lru-Cp-AEvpR.js +27 -0
  270. package/dist/manifest-B-8d2lhG.js +45 -0
  271. package/dist/manifest-CRHphHxo.d.ts +362 -0
  272. package/dist/manifest-XIXxXYty.js +399 -0
  273. package/dist/manifest-json-DMaBWmcG.js +8 -0
  274. package/dist/manifest-schema-DJY5Q_pR.js +507 -0
  275. package/dist/map-claims-BKdnPwep.js +386 -0
  276. package/dist/map-error-DTi_JZT8.js +22 -0
  277. package/dist/markers-C-kThnKN.js +79 -0
  278. package/dist/may-use-Died1tNU.js +233 -0
  279. package/dist/mcp/index.d.ts +11 -21
  280. package/dist/mcp/index.js +56 -43
  281. package/dist/membership-filter-CSKH48eD.js +66 -0
  282. package/dist/migrate-CmTMk7rd.js +536 -0
  283. package/dist/model-B4EKVHMK.js +188 -0
  284. package/dist/module-values-Ddx0GLaJ.js +106 -0
  285. package/dist/nest/index.d.ts +7 -13
  286. package/dist/nest/index.js +12 -15
  287. package/dist/next/client.d.ts +1 -3
  288. package/dist/next/client.js +2 -3
  289. package/dist/next/index.d.ts +36 -16
  290. package/dist/next/index.js +161 -31
  291. package/dist/next/plugin.d.ts +1 -3
  292. package/dist/next/plugin.js +3 -4
  293. package/dist/node/index.d.ts +6 -8
  294. package/dist/node/index.js +4 -5
  295. package/dist/oauth-security-C8fjzFRF.js +25 -0
  296. package/dist/ocsf-DKRQc6uv.js +135 -0
  297. package/dist/openai/index.d.ts +5 -7
  298. package/dist/openai/index.js +5 -6
  299. package/dist/openapi/index.d.ts +4 -16
  300. package/dist/openapi/index.js +4 -3
  301. package/dist/openapi-CH9Dh5UX.js +260 -0
  302. package/dist/openapi-CrCBEFEm.js +95 -0
  303. package/dist/openapi-D2dmyWZK.js +411 -0
  304. package/dist/openapi-document-CJO6cUS1.js +35 -0
  305. package/dist/operation-findings-D5Uo-dcm.js +35 -0
  306. package/dist/operation-risks-BD-j14dj.js +12 -0
  307. package/dist/operations-B0yO77Zz.js +290 -0
  308. package/dist/operations-BS8ExH5A.d.ts +58 -0
  309. package/dist/operations-De3F7tlf.js +88 -0
  310. package/dist/optional-CaQWp9HA.js +46 -0
  311. package/dist/orpc/index.d.ts +8 -12
  312. package/dist/orpc/index.js +10 -12
  313. package/dist/otel/index.d.ts +3 -5
  314. package/dist/otel/index.js +5 -7
  315. package/dist/output-CU7OppLv.js +244 -0
  316. package/dist/output-files-C5LFnQa4.js +1 -0
  317. package/dist/output-files-DNid6TBl.js +197 -0
  318. package/dist/ownership-BBQe7GZp.js +558 -0
  319. package/dist/parse-local-manifest-BGLWVchi.d.ts +8 -0
  320. package/dist/parse-local-manifest-CfMjZAFi.js +67 -0
  321. package/dist/parse-nfHSt1Wy.js +149 -0
  322. package/dist/parse-request-IEEzVFM8.js +24 -0
  323. package/dist/parse-sink-events-B6nZx41L.js +125 -0
  324. package/dist/paths-CeS_gpHf.js +44 -0
  325. package/dist/pdp/index.d.ts +3 -9
  326. package/dist/pdp/index.js +22 -18
  327. package/dist/peer-BWTpSLs2.js +1 -0
  328. package/dist/peer-D77JpXe-.js +978 -0
  329. package/dist/perf-token-dFGVP14-.js +155 -0
  330. package/dist/permdock-BueSeg7X.js +1514 -0
  331. package/dist/permdock-Dz3yzWrp.d.ts +853 -0
  332. package/dist/permission-registry-DMYRZVcn.js +413 -0
  333. package/dist/permissions-CQW3cr2S.js +17 -0
  334. package/dist/permissions-DWULToSb.d.ts +52 -0
  335. package/dist/permissions-ijDw4sO1.js +144 -0
  336. package/dist/pg-CA651850.js +59 -0
  337. package/dist/pins-CXXkVEiD.js +14 -0
  338. package/dist/pipeline-CXuwijr2.js +307 -0
  339. package/dist/pkce-DdsRBK7n.js +20 -0
  340. package/dist/plugin-1XW5OfAZ.d.ts +221 -0
  341. package/dist/plugin-MQVfUBUS.js +93 -0
  342. package/dist/plugin-outputs-BE2YCiMj.js +28 -0
  343. package/dist/policy-C-Lzp3Zh.d.ts +18 -0
  344. package/dist/policy-DFD2J5o_.js +476 -0
  345. package/dist/policy-FrCL4wDQ.js +37 -0
  346. package/dist/policy-bundle-1Znzdxse.js +82 -0
  347. package/dist/policy-from-catalog-YKaTeaco.js +452 -0
  348. package/dist/policy-module-Bp4HvsRg.js +107 -0
  349. package/dist/policy-types-93NwI8iI.d.ts +2855 -0
  350. package/dist/postgres-store-CYFvw98w.js +1023 -0
  351. package/dist/postgrest-DyrYo_XT.d.ts +138 -0
  352. package/dist/powersync-DVgkPQKM.js +1 -0
  353. package/dist/powersync-Y-_z8V5X.js +40 -0
  354. package/dist/powersync-pbvC5g6K.js +1630 -0
  355. package/dist/preset/index.d.ts +0 -12
  356. package/dist/preset/index.js +1 -1
  357. package/dist/preset-BcFDaeqd.js +1849 -0
  358. package/dist/principal-source-BIcukkB3.js +102 -0
  359. package/dist/prisma/index.d.ts +4 -12
  360. package/dist/prisma/index.js +10 -14
  361. package/dist/problem-BZB7zPC7.js +202 -0
  362. package/dist/problem-details-EJHcvYCz.js +154 -0
  363. package/dist/problem-types-81BEw0IN.js +7 -0
  364. package/dist/prompt-CSXHcJxy.js +931 -0
  365. package/dist/protected-action-BMb0ftEu.js +241 -0
  366. package/dist/protected-action-D6T3eJyW.d.ts +73 -0
  367. package/dist/protected-action-DiXulRVj.js +78 -0
  368. package/dist/provider-BnnFjtWI.js +893 -0
  369. package/dist/provider-ClD4rfgT.js +11 -0
  370. package/dist/provider-CydlnKkS.d.ts +4 -0
  371. package/dist/provider-store-atQUfsVO.js +51 -0
  372. package/dist/provider-with-CSw4mBDU.js +70 -0
  373. package/dist/public-api-DIMZmzWi.js +5579 -0
  374. package/dist/pull-C3_fCkgX.js +1 -0
  375. package/dist/pull-CpLyeY2p.js +252 -0
  376. package/dist/push-Cb7PqXdO.js +158 -0
  377. package/dist/pushed-policy-pH-EFWyx.d.ts +61 -0
  378. package/dist/pushed-policy-rpB6k77P.js +240 -0
  379. package/dist/quote-BKrTBbcH.js +36 -0
  380. package/dist/rbac-B-49toAp.js +90 -0
  381. package/dist/react/index.d.ts +10 -9
  382. package/dist/react/index.js +8 -7
  383. package/dist/react/lazy.d.ts +10 -12
  384. package/dist/react/lazy.js +8 -35
  385. package/dist/react/provider-client-lazy.d.ts +2 -0
  386. package/dist/react/provider-client-lazy.js +2 -0
  387. package/dist/react/provider-client.d.ts +1 -1
  388. package/dist/react/provider-client.js +1 -1
  389. package/dist/react-native/index.d.ts +12 -30
  390. package/dist/react-native/index.js +31 -41
  391. package/dist/read-memberships-BkePIa1F.js +63 -0
  392. package/dist/refresh-on-C1zIMtJr.d.ts +47 -0
  393. package/dist/refresh-online-CYGZNo6V.js +19 -0
  394. package/dist/refresh-online-vtUfV6dk.d.ts +10 -0
  395. package/dist/refs-Cix9Zjis.js +103 -0
  396. package/dist/relation-walk-BlWy9gBK.js +188 -0
  397. package/dist/relations-CIgB5KPJ.js +162 -0
  398. package/dist/replay-ClGIMp5p.d.ts +3 -0
  399. package/dist/replay-X2m6moK1.js +28 -0
  400. package/dist/request-context-CVJodWx8.js +70 -0
  401. package/dist/request-context-E3-ps-H_.d.ts +3 -0
  402. package/dist/request-schema-DzEoR310.js +155 -0
  403. package/dist/resend/index.d.ts +4 -10
  404. package/dist/resend/index.js +14 -17
  405. package/dist/resolve-names-Ca4ClMU2.js +266 -0
  406. package/dist/resolver-kdZ4HrpC.js +404 -0
  407. package/dist/resource-ref-BiQtFK-I.js +19 -0
  408. package/dist/resource-relations-Ck5sjYQR.js +251 -0
  409. package/dist/retire-BNiXnbBR.js +248 -0
  410. package/dist/revocations-3jyzniOz.js +26 -0
  411. package/dist/revocations-ku_f2d2y.d.ts +24 -0
  412. package/dist/rls-CmyxiQsS.js +321 -0
  413. package/dist/rls-DY5ITGzf.js +946 -0
  414. package/dist/rls-files-BtaUXVp-.js +114 -0
  415. package/dist/rls-options-CEpg5nDP.d.ts +26 -0
  416. package/dist/role-builder-DhsGEVq-.js +501 -0
  417. package/dist/role-grants-Bk6ZsaS0.js +46 -0
  418. package/dist/roles-B29psCem.js +29 -0
  419. package/dist/rolldown-runtime-B8NLbhFH.js +3 -0
  420. package/dist/row-conditions-DwIJocfQ.js +27 -0
  421. package/dist/row-pair-CxEhErJU.js +33 -0
  422. package/dist/rpc-B-4IZOiU.js +111 -0
  423. package/dist/rpc-DjgxFbjK.d.ts +18 -0
  424. package/dist/run-BoVUFspr.js +726 -0
  425. package/dist/run-BriRChKE.js +1 -0
  426. package/dist/run-ticket-D6T39Xdi.js +370 -0
  427. package/dist/run-ticket-DXwrko2J.d.ts +157 -0
  428. package/dist/runtime-Cl6xSbEq.js +13 -0
  429. package/dist/saas-DzjKUQr5.js +1218 -0
  430. package/dist/scan-C4x8UqS7.js +28 -0
  431. package/dist/schema-BeY3croo.js +403 -0
  432. package/dist/schema-Zfpbku8U.js +133 -0
  433. package/dist/scim/index.d.ts +2 -2
  434. package/dist/scim/index.js +2 -2
  435. package/dist/scim-B9QyJ23q.js +1046 -0
  436. package/dist/scopes-B-KX9EI8.js +238 -0
  437. package/dist/seed-sql-CjF7u0aX.js +60 -0
  438. package/dist/seeds/index.d.ts +2 -0
  439. package/dist/seeds/index.js +1 -0
  440. package/dist/seeds-BDTG7xl-.js +53 -0
  441. package/dist/seeds-uG196Ev4.d.ts +73 -0
  442. package/dist/server/index.d.ts +13 -13
  443. package/dist/server/index.js +14 -14
  444. package/dist/server-Co9CYGqk.js +146 -0
  445. package/dist/server-types-BrHOGAYx.d.ts +318 -0
  446. package/dist/sha256-DFsnyVPo.js +157 -0
  447. package/dist/shared-BOsJIQf4.js +124 -0
  448. package/dist/shared-BdF5DJDQ.js +330 -0
  449. package/dist/signals-a1NxAP0X.js +31 -0
  450. package/dist/sink-BD34OS8T.d.ts +247 -0
  451. package/dist/sink-Bgvf9lIz.js +966 -0
  452. package/dist/size-DF7xQ-nH.js +95 -0
  453. package/dist/skills-B0cLRZ7w.js +202 -0
  454. package/dist/skills-DiGdMvMw.js +50 -0
  455. package/dist/snapshot-DckMnHk8.js +352 -0
  456. package/dist/snapshot-cache-DTTEfmxv.js +69 -0
  457. package/dist/snapshot-cache-DoP3avLl.d.ts +68 -0
  458. package/dist/snapshot-compact-CwAop_6C.js +119 -0
  459. package/dist/snapshot-empty-DZ6sZ83n.js +17 -0
  460. package/dist/snapshot-evaluate-9RGy7J3N.js +552 -0
  461. package/dist/snapshot-reads-D775amTL.js +65 -0
  462. package/dist/snapshot-size-D-pCR8x0.js +139 -0
  463. package/dist/snapshot-size-DU7CvpMt.js +1 -0
  464. package/dist/solid/index.d.ts +18 -20
  465. package/dist/solid/index.js +15 -19
  466. package/dist/solid-start/index.d.ts +6 -8
  467. package/dist/solid-start/index.js +4 -5
  468. package/dist/sources-BbSUNmFX.js +10 -0
  469. package/dist/sources-DnjJPGfb.js +657 -0
  470. package/dist/sources-NQio1yFq.d.ts +727 -0
  471. package/dist/sql-BYYNi1lu.d.ts +8 -0
  472. package/dist/sql-T4GaBh9X.js +93 -0
  473. package/dist/src-D6_T4zd7.js +1811 -0
  474. package/dist/ssf/index.d.ts +3 -3
  475. package/dist/ssf/index.js +20 -31
  476. package/dist/standard-webhooks-B3MQihcP.d.ts +86 -0
  477. package/dist/standard-webhooks-BtIkXclH.js +227 -0
  478. package/dist/storage-BhGDhsXm.js +131 -0
  479. package/dist/store-AH8bmaxW.js +377 -0
  480. package/dist/store-core-eqG8jijs.d.ts +306 -0
  481. package/dist/store-options-C8x39AHa.js +1034 -0
  482. package/dist/stores-4DOaL4ZP.d.ts +58 -0
  483. package/dist/stores-DoA7ACkz.js +127 -0
  484. package/dist/stream-DdF94h7T.js +73 -0
  485. package/dist/style-CQDaLJtP.js +24 -0
  486. package/dist/style-Crf-90o6.js +1 -0
  487. package/dist/subject-DkxY-AhF.js +23 -0
  488. package/dist/subject-cache-BZeSj4Xf.d.ts +156 -0
  489. package/dist/subject-settings-BO-frcYx.js +147 -0
  490. package/dist/subject-settings-C9F1sU1d.d.ts +48 -0
  491. package/dist/supabase/client.d.ts +1 -1
  492. package/dist/supabase/client.js +2 -3
  493. package/dist/supabase/index.d.ts +77 -24
  494. package/dist/supabase/index.js +9 -8
  495. package/dist/supabase/middleware.d.ts +27 -9
  496. package/dist/supabase/middleware.js +51 -21
  497. package/dist/supabase-B7Q5bO-P.js +30 -0
  498. package/dist/supabase-BI5ZhzLl.js +792 -0
  499. package/dist/supabase-config-mXcggV5I.js +890 -0
  500. package/dist/supabase-hook-C7FNwQ1p.js +2 -0
  501. package/dist/supabase-hook-loL2iJVb.js +405 -0
  502. package/dist/supabase-outcome-CMLuLW-V.js +9 -0
  503. package/dist/supautils-DXzJ2E2Q.js +96 -0
  504. package/dist/support-session-B8xrW28B.js +157 -0
  505. package/dist/svelte/index.d.ts +8 -10
  506. package/dist/svelte/index.js +12 -15
  507. package/dist/svelte/runtime.d.ts +4 -6
  508. package/dist/svelte/runtime.js +4 -4
  509. package/dist/svelte/source.d.ts +8 -10
  510. package/dist/svelte/source.js +6 -7
  511. package/dist/sveltekit/index.d.ts +6 -8
  512. package/dist/sveltekit/index.js +3 -4
  513. package/dist/tables-C8IwkTHq.js +3249 -0
  514. package/dist/tanstack-start/index.d.ts +6 -8
  515. package/dist/tanstack-start/index.js +3 -4
  516. package/dist/target-BGpxgKsN.js +50 -0
  517. package/dist/tenancy-B5Xxt9Sc.js +223 -0
  518. package/dist/terminal/index.d.ts +6 -16
  519. package/dist/terminal/index.js +18 -23
  520. package/dist/testing/core.d.ts +1 -1
  521. package/dist/testing/core.js +1 -1
  522. package/dist/testing/fixtures/index.d.ts +12 -10
  523. package/dist/testing/fixtures/index.js +48 -25
  524. package/dist/testing/index.d.ts +85 -85
  525. package/dist/testing/index.js +226 -115
  526. package/dist/testing/saas/index.d.ts +5 -15
  527. package/dist/testing/saas/index.js +2 -2
  528. package/dist/testing/saas/permissions.d.ts +1 -1
  529. package/dist/testing/saas/permissions.js +1 -1
  530. package/dist/text-D704xHVl.js +7 -0
  531. package/dist/text-diff-CsglY49A.js +440 -0
  532. package/dist/thenable-BxMy2v8w.js +39 -0
  533. package/dist/time-r0CKBm57.js +94 -0
  534. package/dist/timeout-nOqLpU2I.js +7 -0
  535. package/dist/token-BgswTQzt.d.ts +9 -0
  536. package/dist/token-CSljQqzA.js +76 -0
  537. package/dist/tool-refusal-DzCSbjp8.js +43 -0
  538. package/dist/trpc/index.d.ts +7 -9
  539. package/dist/trpc/index.js +7 -8
  540. package/dist/type-helpers-DHCQEPj8.d.ts +47 -0
  541. package/dist/types-3pRMqcvw.d.ts +84 -0
  542. package/dist/types-BFtFaI1W.d.ts +66 -0
  543. package/dist/types-BdNdMix7.d.ts +263 -0
  544. package/dist/types-C7QtRn3n.d.ts +66 -0
  545. package/dist/types-CVCRFYY_.d.ts +102 -0
  546. package/dist/types-CWmBZtQN.d.ts +274 -0
  547. package/dist/types-Cakw89Wx.d.ts +372 -0
  548. package/dist/types-D3tjoLwT.d.ts +124 -0
  549. package/dist/types-DFZKovb3.js +77 -0
  550. package/dist/types-DONLJQjY.d.ts +134 -0
  551. package/dist/types-OzSal_K_.d.ts +178 -0
  552. package/dist/types-XSfi6ihL.d.ts +65 -0
  553. package/dist/types-nXo_oQYk.d.ts +1235 -0
  554. package/dist/unplugin/index.d.ts +1 -3
  555. package/dist/unplugin/index.js +3 -4
  556. package/dist/usage-BgNAgZfj.js +31 -0
  557. package/dist/usage-D6HUlfvP.js +1 -0
  558. package/dist/usage-llSQehNg.js +761 -0
  559. package/dist/validation-error-BAO1W1yk.d.ts +27 -0
  560. package/dist/validation-error-CgDOA6VS.js +35 -0
  561. package/dist/validity-YNEEm2MZ.js +56 -0
  562. package/dist/verifier-BIYkGcJc.js +530 -0
  563. package/dist/verify-nMTdEqBB.js +1102 -0
  564. package/dist/version-CU6e2wxV.js +7 -0
  565. package/dist/version-D-jWyJb9.js +46 -0
  566. package/dist/version-DcZCjWXb.js +1 -0
  567. package/dist/version-cache-BXkl7-Fz.js +462 -0
  568. package/dist/views-Dpr1uB16.js +164 -0
  569. package/dist/vocabulary-CE2k7s1a.js +157 -0
  570. package/dist/vocabulary-FYgI_NoI.d.ts +400 -0
  571. package/dist/vue/index.d.ts +18 -20
  572. package/dist/vue/index.js +13 -18
  573. package/dist/waiter-DKdFHKVZ.js +66 -0
  574. package/dist/waiter-hYLJXA7r.d.ts +37 -0
  575. package/dist/watch-BecZtEdU.js +155 -0
  576. package/dist/watch-CiN6WU9k.js +221 -0
  577. package/dist/watch-NAUnUXph.js +1 -0
  578. package/dist/webmcp/index.d.ts +2 -6
  579. package/dist/webmcp/index.js +8 -9
  580. package/dist/who-can-rUSZfLvI.js +366 -0
  581. package/dist/wire-delegation-DC5Cyec4.js +35 -0
  582. package/dist/wire-denial-BcRQnA7p.js +26 -0
  583. package/dist/workflow/index.d.ts +3 -3
  584. package/dist/workflow/index.js +12 -14
  585. package/dist/workflow-sdk/index.d.ts +6 -8
  586. package/dist/workflow-sdk/index.js +2 -3
  587. package/dist/wrap-CsfsaJhd.js +32 -0
  588. package/dist/wrap-D-KvhzaC.d.ts +16 -0
  589. package/package.json +83 -39
  590. package/schemas/catalog-v2.json +665 -0
  591. package/schemas/cli-commands-v1.json +1 -1
  592. package/schemas/cli-result-v2.json +163 -0
  593. package/schemas/cloud-api-v1.json +1 -1
  594. package/schemas/snapshot-v1.json +26 -0
  595. package/schemas/supabase-claims-v1.json +5 -1
  596. package/schemas/supabase-manifest-v1.json +11 -2
  597. package/skills/permdock/SKILL.md +1 -1
  598. package/skills/permdock-data/references/queries-and-rls.md +2 -1
  599. package/skills/permdock-wire/references/adapters.md +5 -3
  600. package/dist/2020-CJbO8Bvz.js +0 -6773
  601. package/dist/active-tenant-DVee32-T.js +0 -39
  602. package/dist/adapter-context-OHikyRqV.js +0 -29
  603. package/dist/adoption-scan-8F9VSQrK.js +0 -107
  604. package/dist/app-J9PE1LNm.js +0 -24
  605. package/dist/app-data-UNNm07jV.js +0 -63
  606. package/dist/approval-header-8QV6MU4H.js +0 -26
  607. package/dist/approval-normalize-KfhzpD93.js +0 -196
  608. package/dist/approval-policies-BiXMlYBu.d.ts +0 -138
  609. package/dist/approval-prompt-B8hQY69x.js +0 -61
  610. package/dist/approval-prompt-j5PTItiy.d.ts +0 -59
  611. package/dist/approval-required-TzNB9oQA.js +0 -6
  612. package/dist/approvals-BfzI8Foe.js +0 -1048
  613. package/dist/approvers-BaNwKYgd.js +0 -77
  614. package/dist/arazzo-BUVqRmaJ.js +0 -36
  615. package/dist/arazzo-CWmM8pWw.js +0 -77
  616. package/dist/args-iafbHiXn.js +0 -311
  617. package/dist/audience-DLoopY4q.js +0 -55
  618. package/dist/auth-BxXHxWRy.js +0 -189
  619. package/dist/authz-topic-Dbc-HDOS.js +0 -15
  620. package/dist/automation-BueW05db.js +0 -158
  621. package/dist/automation-_iGeP54L.d.ts +0 -124
  622. package/dist/base-url-BQbddZO5.js +0 -9
  623. package/dist/better-supabase-DF8f8oly.js +0 -194
  624. package/dist/bind-CTj4dHc1.d.ts +0 -58
  625. package/dist/bind-LQ6zbARV.js +0 -125
  626. package/dist/body-Cy9S8zhw.js +0 -10
  627. package/dist/body-text-DQhcmqdY.js +0 -56
  628. package/dist/boundary-BV3O1eud.js +0 -19
  629. package/dist/boundary-C9ck-3uK.d.ts +0 -24
  630. package/dist/budget-BBCPDOGP.js +0 -14
  631. package/dist/budget-CNLsV2SL.d.ts +0 -14
  632. package/dist/build-instance-Bq8wkJ4i.js +0 -31
  633. package/dist/canonical-json-DwilZ1iB.js +0 -29
  634. package/dist/capability-CenWwTMR.js +0 -205
  635. package/dist/capability-DqCyFGip.d.ts +0 -130
  636. package/dist/casbin-DIvUMac7.js +0 -242
  637. package/dist/casbin-qpG_ZphP.js +0 -30
  638. package/dist/casl-CjBVJj8R.js +0 -24
  639. package/dist/casl-CkBssiB1.js +0 -308
  640. package/dist/catalog-B1MAmRQI.js +0 -131
  641. package/dist/catalog-BCVIH7kq.js +0 -1
  642. package/dist/catalog-CaZoXBD8.js +0 -52
  643. package/dist/catalog-doc-DnQDviXY.js +0 -353
  644. package/dist/catalog-fingerprint-e6aCWosn.js +0 -157
  645. package/dist/catalog-operations-Do1eD-Rt.js +0 -60
  646. package/dist/catalog-path-CnI0XTFK.js +0 -12
  647. package/dist/challenge-DKJpP-5P.js +0 -521
  648. package/dist/checks-fyDOhcz0.js +0 -72
  649. package/dist/claims-map-CKkoAAYF.js +0 -16
  650. package/dist/claims-map-D1Pb5oRq.d.ts +0 -35
  651. package/dist/client-JK504UCq.d.ts +0 -45
  652. package/dist/clients-C_NOET3z.d.ts +0 -12
  653. package/dist/clients-DYr3U86j.js +0 -23
  654. package/dist/cloud-CXgE1qpa.js +0 -86
  655. package/dist/codemod-BJ0Kgv9b.js +0 -36
  656. package/dist/codemod-DjgVx3RQ.js +0 -2800
  657. package/dist/collect-BG-SXFQv.js +0 -537
  658. package/dist/collect-CxPJRjoc.js +0 -55
  659. package/dist/collect-ZLgHgujd.js +0 -1
  660. package/dist/command-L8EstFNm.js +0 -6
  661. package/dist/compact-CAf557ZB.js +0 -29
  662. package/dist/compare-DTfyUunF.js +0 -12
  663. package/dist/compile-Cvru58id.js +0 -661
  664. package/dist/compile-Dh9pW_Co.d.ts +0 -120
  665. package/dist/completion-DUHSRdoQ.js +0 -152
  666. package/dist/config-CgA_Z5Ts.js +0 -26
  667. package/dist/config-DC7aiuhP.js +0 -116
  668. package/dist/config-report-B31MnuKf.js +0 -56
  669. package/dist/config-shape-ChhsuGSV.js +0 -147
  670. package/dist/connection-zoAgwdsD.js +0 -197
  671. package/dist/connector-schema-CYLQNMYq.js +0 -434
  672. package/dist/constants-DcJABbLW.js +0 -20
  673. package/dist/context-BXM0MDB0.js +0 -95
  674. package/dist/core-BTJlqWsv.js +0 -341
  675. package/dist/core-BhZEo5Le.d.ts +0 -206
  676. package/dist/coverage-BuGlwUms.d.ts +0 -135
  677. package/dist/coverage-CGu_Kovx.js +0 -261
  678. package/dist/create--q7-j0hX.d.ts +0 -127
  679. package/dist/create-C5IQw_-i.d.ts +0 -191
  680. package/dist/create-CYj0cjTu.d.ts +0 -128
  681. package/dist/create-D7D94oNh.js +0 -376
  682. package/dist/create-DaddhCIg.js +0 -134
  683. package/dist/credential-BMsbcaeP.js +0 -431
  684. package/dist/credentials-BZU7Twpt.js +0 -310
  685. package/dist/credentials-Bq-Xa7Vq.d.ts +0 -125
  686. package/dist/credentials-dkycUsY3.js +0 -74
  687. package/dist/decide-set-DXEPepY1.js +0 -100
  688. package/dist/deciding-columns-NB4wcyBf.js +0 -134
  689. package/dist/decision-CaG5_eNJ.js +0 -21
  690. package/dist/delegation-CrdqnesZ.js +0 -262
  691. package/dist/delegation-input-DcXhiMkf.js +0 -19
  692. package/dist/delivery-BupfvJIV.js +0 -560
  693. package/dist/delivery-event-JioK5YbS.js +0 -40
  694. package/dist/denied-text-B6s29jcf.d.ts +0 -22
  695. package/dist/describe-BZAlPHxT.js +0 -101
  696. package/dist/describe-DwcoWMLB.d.ts +0 -45
  697. package/dist/device-BkSynWdg.js +0 -196
  698. package/dist/diff-BnYHpRSI.js +0 -466
  699. package/dist/diff-H75YU6Q-.js +0 -37
  700. package/dist/digest-8Yx2CchM.d.ts +0 -19
  701. package/dist/digest-BI-6aa6d.js +0 -27
  702. package/dist/doctor-Dvt1_ROJ.js +0 -3560
  703. package/dist/doctor-JLouRSQt.js +0 -54
  704. package/dist/env-DJZrPjRi.js +0 -8
  705. package/dist/errors-BDUwg2qC.js +0 -27
  706. package/dist/errors-BhRkoNS7.js +0 -145
  707. package/dist/errors-CHwoRRpB.d.ts +0 -14
  708. package/dist/errors-D_SnqcRn.d.ts +0 -141
  709. package/dist/errors-ynga1EQy.js +0 -128
  710. package/dist/evaluate-BQ2nWOki.js +0 -1905
  711. package/dist/evaluations-BVtY66lF.d.ts +0 -38
  712. package/dist/evaluations-Bj5xw0EM.js +0 -612
  713. package/dist/evaluator-CDl2YUd_.js +0 -2
  714. package/dist/evaluator-eager-CULtQ8t6.js +0 -9
  715. package/dist/event-time-BGy48400.js +0 -27
  716. package/dist/fetch-adapter-BJ76IZZg.d.ts +0 -34
  717. package/dist/fetch-adapter-CXeBg4CH.js +0 -124
  718. package/dist/fields-D9PIYlJy.js +0 -504
  719. package/dist/fields-DlKwZYiy.js +0 -26
  720. package/dist/files-BSjrtIHw.js +0 -141
  721. package/dist/files-CfiRtQ-m.js +0 -140
  722. package/dist/fixtures-BVZc7OCF.js +0 -80
  723. package/dist/flags-BlmpmXoY.js +0 -86
  724. package/dist/freeze-jjan0lCv.js +0 -63
  725. package/dist/from-snapshot-FdVXG_QZ.js +0 -159
  726. package/dist/gen-D17P8vo0.js +0 -827
  727. package/dist/gen-YA3SK59O.js +0 -58
  728. package/dist/generate-BqkZq8Dr.js +0 -165
  729. package/dist/generate-CezbCaTI.js +0 -275
  730. package/dist/grantee-OG4klcNr.js +0 -110
  731. package/dist/grantee-conditions-Dzprappv.js +0 -271
  732. package/dist/grantee-match-CPQ9zV-H.js +0 -148
  733. package/dist/graph-sql-BwFC4Qjs.d.ts +0 -29
  734. package/dist/headers-B9jQxjtW.d.ts +0 -10
  735. package/dist/helpers-CO2hDpBU.js +0 -537
  736. package/dist/hosted-CQW_YNx7.js +0 -362
  737. package/dist/hosted-D5StFpKa.d.ts +0 -102
  738. package/dist/http-B_LphE5Y.d.ts +0 -12
  739. package/dist/http-DH94eh6f.js +0 -72
  740. package/dist/http-DKLXrFGk.js +0 -83
  741. package/dist/http-dptLQzPP.js +0 -49
  742. package/dist/ids-DzhJaCUj.js +0 -55
  743. package/dist/import-B8zbuskR.js +0 -5950
  744. package/dist/import-BYYXmHvP.js +0 -1143
  745. package/dist/index-B1-tE0Kx.d.ts +0 -1159
  746. package/dist/index-BwSEp_O5.d.ts +0 -210
  747. package/dist/index-CB_eM-qx.d.ts +0 -101
  748. package/dist/index-CvcE9mYP.d.ts +0 -234
  749. package/dist/index-D7sMtTf6.d.ts +0 -542
  750. package/dist/index-d7f0hNss.d.ts +0 -233
  751. package/dist/init-BdgWNuc3.js +0 -96
  752. package/dist/init-DKRhYiGW.js +0 -95
  753. package/dist/instance-options-DhQVCuhT.d.ts +0 -11
  754. package/dist/instance-options-URVwqpMW.js +0 -24
  755. package/dist/instance-snapshot-DyG_5ASl.js +0 -693
  756. package/dist/instant-DK3Iz83e.js +0 -19
  757. package/dist/internals-B3IgHrvo.js +0 -20
  758. package/dist/json-schema-BPGa-RjQ.js +0 -149
  759. package/dist/json-schema-BfXgnRNT.d.ts +0 -40
  760. package/dist/kernel-D9AxUqmz.js +0 -427
  761. package/dist/limits-CAhpRrhk.js +0 -167
  762. package/dist/live-options-BBIT68le.js +0 -73
  763. package/dist/load-C4p4VgwR.js +0 -99
  764. package/dist/load-DiBUJx77.js +0 -1
  765. package/dist/load-jose-DZ4dnjri.js +0 -8
  766. package/dist/login-DEvccJwP.js +0 -68
  767. package/dist/login-IIUDSAYW.js +0 -257
  768. package/dist/lru-8q4WZjBV.js +0 -28
  769. package/dist/manifest-BoCYBbQL.js +0 -46
  770. package/dist/manifest-C6eFl3Vo.d.ts +0 -349
  771. package/dist/manifest-CZ-GmsOL.js +0 -401
  772. package/dist/manifest-json-CAGzls-C.js +0 -9
  773. package/dist/manifest-schema-svAkgqMc.js +0 -501
  774. package/dist/map-claims-CAa_bQt9.js +0 -387
  775. package/dist/map-error-BCdb2Nrp.js +0 -23
  776. package/dist/markers-BeHZ4x9Q.js +0 -80
  777. package/dist/may-use-WDhFPqGG.js +0 -125
  778. package/dist/membership-filter-BWnfRQzo.js +0 -68
  779. package/dist/migrate-DVsxeE0y.js +0 -537
  780. package/dist/module-values-CdaVwrab.js +0 -107
  781. package/dist/oauth-security-X7Em8DbH.js +0 -26
  782. package/dist/ocsf-TcjRBgIs.js +0 -136
  783. package/dist/openapi-BFUnL8Yi.js +0 -137
  784. package/dist/openapi-Cc-aS9xC.js +0 -416
  785. package/dist/openapi-DcjyfR1g.js +0 -256
  786. package/dist/operation-findings-CVwJHEu_.js +0 -36
  787. package/dist/operation-risks-BKOcTv8J.js +0 -13
  788. package/dist/operations-BMPx7HyO.d.ts +0 -62
  789. package/dist/operations-Bm9HFecz.js +0 -89
  790. package/dist/optional-8TKc-0j4.js +0 -47
  791. package/dist/output-LDciF_4t.js +0 -96
  792. package/dist/output-files-BYscrQl-.js +0 -1
  793. package/dist/output-files-CM0BnH05.js +0 -150
  794. package/dist/ownership-DvK6INyx.js +0 -1062
  795. package/dist/parse-CORUNcCo.js +0 -151
  796. package/dist/parse-local-manifest-Ce2N-Opr.js +0 -69
  797. package/dist/parse-local-manifest-w_ksIkB9.d.ts +0 -10
  798. package/dist/parse-request-DOBVaeiQ.js +0 -25
  799. package/dist/paths-CUvURzHp.js +0 -45
  800. package/dist/peer-BuK9F53f.js +0 -982
  801. package/dist/peer-n-swIV4H.js +0 -1
  802. package/dist/permdock-B3zE16To.js +0 -1203
  803. package/dist/permdock-DV3opaI3.d.ts +0 -674
  804. package/dist/permission-registry-B8tYxPIt.js +0 -398
  805. package/dist/permissions-BaoLxy66.js +0 -18
  806. package/dist/permissions-D-M48hW-.js +0 -146
  807. package/dist/permissions-DriWkV7q.d.ts +0 -54
  808. package/dist/pg-Ddxsd5ZB.js +0 -60
  809. package/dist/pins-nqarl3oE.js +0 -15
  810. package/dist/pkce-CnmmYqUZ.js +0 -21
  811. package/dist/policy-DIHfTqm6.d.ts +0 -20
  812. package/dist/policy-DnNOTENd.js +0 -430
  813. package/dist/policy-from-catalog-Z0hvSffr.js +0 -454
  814. package/dist/policy-module-xym9fnSq.js +0 -95
  815. package/dist/policy-types-DU389Elz.d.ts +0 -2809
  816. package/dist/postgres-store-DcyrPS-r.js +0 -1028
  817. package/dist/postgrest-3dE9SGx9.d.ts +0 -124
  818. package/dist/powersync-B5YjtUGd.js +0 -1532
  819. package/dist/powersync-BgUsk2Nf.js +0 -1
  820. package/dist/powersync-Dx7odzyw.js +0 -62
  821. package/dist/preset-Bn5Z54cH.js +0 -1858
  822. package/dist/principal-source-C6N60GtM.js +0 -103
  823. package/dist/problem-CPB8kqk7.js +0 -203
  824. package/dist/problem-details-CLDgX1KV.js +0 -156
  825. package/dist/problem-types-DSsRfONQ.js +0 -8
  826. package/dist/prompt-D1Gj1W4Y.js +0 -938
  827. package/dist/protected-action-CjSUoPGx.d.ts +0 -76
  828. package/dist/protected-action-D41o5LvP.js +0 -244
  829. package/dist/protected-action-OpOxtTsN.js +0 -80
  830. package/dist/provider-Bzzux0TR.js +0 -12
  831. package/dist/provider-D1jsNJ85.d.ts +0 -6
  832. package/dist/provider-store-tIAwP4aW.js +0 -52
  833. package/dist/provider-with-Do28DhxP.js +0 -69
  834. package/dist/pull-Pde1lapF.js +0 -257
  835. package/dist/pull-a4RpDxk8.js +0 -1
  836. package/dist/push-sJ5dy46a.js +0 -162
  837. package/dist/pushed-policy-Db651nih.d.ts +0 -63
  838. package/dist/pushed-policy-UZyQinrL.js +0 -241
  839. package/dist/refresh-on-L9UOwATg.d.ts +0 -49
  840. package/dist/refs-C8BKxc_e.js +0 -105
  841. package/dist/relation-walk-BDTaTKTM.js +0 -189
  842. package/dist/relations-CMsJ1ARY.js +0 -163
  843. package/dist/replay-BU09ad4L.js +0 -29
  844. package/dist/replay-BpmpY2ev.d.ts +0 -5
  845. package/dist/request-context-C2_1lchh.d.ts +0 -5
  846. package/dist/request-context-dyCY4V1t.js +0 -71
  847. package/dist/request-schema-CMP8Cmxd.js +0 -156
  848. package/dist/resolve-names-D5_kABup.js +0 -206
  849. package/dist/resource-ref-CaS9yVPi.js +0 -20
  850. package/dist/resource-relations-8-pCScBO.js +0 -252
  851. package/dist/retire-B2xffQgY.js +0 -249
  852. package/dist/revocations-BaUXHM1N.d.ts +0 -26
  853. package/dist/revocations-Bhr0aMIC.js +0 -27
  854. package/dist/rls-BI687j8q.js +0 -2700
  855. package/dist/rls-CKLHLcRl.js +0 -367
  856. package/dist/role-builder-BXdhhQcB.js +0 -507
  857. package/dist/rolldown-runtime-C3I60J0A.js +0 -4
  858. package/dist/row-conditions-BAGHOmVq.js +0 -28
  859. package/dist/row-pair-DglMdRFh.js +0 -34
  860. package/dist/rpc-BdFGYcWm.js +0 -112
  861. package/dist/rpc-DKRQobOX.d.ts +0 -22
  862. package/dist/run-B4heHtD1.js +0 -1
  863. package/dist/run-BG2kPruh.js +0 -694
  864. package/dist/run-ticket-Ddxt9OuU.js +0 -371
  865. package/dist/run-ticket-o4RxoaEN.d.ts +0 -159
  866. package/dist/runtime-rf0ZuyF3.js +0 -14
  867. package/dist/saas-D9maBt0q.js +0 -1223
  868. package/dist/scan-BvTBo9-D.js +0 -29
  869. package/dist/schema-BlnU_TzE.js +0 -414
  870. package/dist/schema-grK6TTBH.js +0 -134
  871. package/dist/scim-BG6uPUeW.js +0 -1056
  872. package/dist/scim-CovliQUg.js +0 -44
  873. package/dist/scopes-gdH__vDZ.js +0 -239
  874. package/dist/server-CKjFooaJ.js +0 -147
  875. package/dist/server-types-C4q8_8MM.d.ts +0 -325
  876. package/dist/sha256-C-4WXKIu.js +0 -158
  877. package/dist/shared-BRmCJxDK.js +0 -125
  878. package/dist/shared-DfaIWvIJ.js +0 -354
  879. package/dist/signals-B1vHR3fN.js +0 -32
  880. package/dist/sink-C3KDccl9.d.ts +0 -249
  881. package/dist/sink-D9_vh372.js +0 -968
  882. package/dist/skills-DzNdLezx.js +0 -51
  883. package/dist/skills-nPLVGtGH.js +0 -204
  884. package/dist/snapshot-D0VOanxQ.js +0 -334
  885. package/dist/snapshot-cache-B66h7FBK.js +0 -70
  886. package/dist/snapshot-cache-C1mN0pXe.d.ts +0 -70
  887. package/dist/snapshot-compact-CUtXsx6i.js +0 -75
  888. package/dist/snapshot-empty-F7d5BRlc.js +0 -18
  889. package/dist/snapshot-evaluate-C3ZA35O_.js +0 -501
  890. package/dist/snapshot-reads-CNNmp1cK.js +0 -66
  891. package/dist/sources-2virTxHt.d.ts +0 -721
  892. package/dist/sources-C4vkzZJV.js +0 -660
  893. package/dist/sources-qoIJQrJv.js +0 -11
  894. package/dist/sql-0WjxIp9g.js +0 -80
  895. package/dist/sql-B80DFdpG.d.ts +0 -10
  896. package/dist/src-ieIv22BA.js +0 -2080
  897. package/dist/standard-webhooks-B2g_yWK8.d.ts +0 -88
  898. package/dist/standard-webhooks-D67a3nzk.js +0 -228
  899. package/dist/storage-C2bWdvJH.js +0 -132
  900. package/dist/store-DXO0aVgf.js +0 -380
  901. package/dist/store-core-BI-9ZU-5.d.ts +0 -311
  902. package/dist/store-options-BYKNX_JG.js +0 -993
  903. package/dist/stores-DtM8pt8o.js +0 -128
  904. package/dist/stores-DwGfIcmq.d.ts +0 -57
  905. package/dist/stream-DQ3rbO3J.js +0 -74
  906. package/dist/style-DblOtSga.js +0 -1
  907. package/dist/style-Ds11Hmk4.js +0 -25
  908. package/dist/subject-C7RddW0G.js +0 -24
  909. package/dist/subject-cache-BT1fGuea.js +0 -193
  910. package/dist/subject-cache-TY2tw-k9.d.ts +0 -144
  911. package/dist/subject-jG6o8eKo.js +0 -556
  912. package/dist/subject-settings-8sH5HlII.js +0 -150
  913. package/dist/subject-settings-vNW8qmUH.d.ts +0 -52
  914. package/dist/supabase-BlAqmxD8.js +0 -723
  915. package/dist/supabase-dk1kB9bJ.js +0 -92
  916. package/dist/supabase-hook-Bu5gkzix.js +0 -1
  917. package/dist/supabase-hook-Cf9zKz8T.js +0 -4263
  918. package/dist/supautils-BREOPaHY.js +0 -1186
  919. package/dist/support-session-BGeEYDSq.js +0 -158
  920. package/dist/tables-DnNACfAr.js +0 -4003
  921. package/dist/target-qdEAnnhU.js +0 -51
  922. package/dist/tenancy-BlxY5T0q.js +0 -224
  923. package/dist/text-BMFRfBqc.js +0 -8
  924. package/dist/text-diff-BtfSmdUo.js +0 -444
  925. package/dist/thenable-BNSM1U2R.js +0 -40
  926. package/dist/time-nR1JesoH.js +0 -95
  927. package/dist/timeout-D51niuQP.js +0 -8
  928. package/dist/token-D6pWn8Uj.d.ts +0 -11
  929. package/dist/token-DaMnIU9O.js +0 -77
  930. package/dist/tool-refusal-D4spOJ7I.js +0 -44
  931. package/dist/type-helpers-tDoGEIsd.d.ts +0 -49
  932. package/dist/types-61f3KMtI.d.ts +0 -1136
  933. package/dist/types-BDgMzK1i.d.ts +0 -368
  934. package/dist/types-BIvkpVoc.d.ts +0 -180
  935. package/dist/types-BWjNPQkS.d.ts +0 -67
  936. package/dist/types-Bq4AU68k.d.ts +0 -105
  937. package/dist/types-BsqLNNvG.d.ts +0 -68
  938. package/dist/types-CH67RMvL.d.ts +0 -136
  939. package/dist/types-CcUXciSj.js +0 -79
  940. package/dist/types-DAyp592k.d.ts +0 -276
  941. package/dist/types-DEDocm4c.d.ts +0 -81
  942. package/dist/types-DQQkzF97.d.ts +0 -126
  943. package/dist/types-DdeivUBP.d.ts +0 -68
  944. package/dist/types-X40XNxRP.d.ts +0 -265
  945. package/dist/usage-BkDU1dYf.js +0 -762
  946. package/dist/usage-DNj42KHA.js +0 -32
  947. package/dist/usage-DrB_tDNk.js +0 -1
  948. package/dist/validation-error-CV0nV6_L.d.ts +0 -29
  949. package/dist/validation-error-CYg2kJEw.js +0 -36
  950. package/dist/validity-IcjQSR7I.js +0 -57
  951. package/dist/verifier-DUV6pLqZ.js +0 -519
  952. package/dist/verify-Boehaks6.js +0 -1736
  953. package/dist/version-DMQ0dnN5.js +0 -48
  954. package/dist/version-DizhmD72.js +0 -1
  955. package/dist/version-sources-BRb9ZteH.js +0 -34
  956. package/dist/views-MWmJ6Y4P.js +0 -147
  957. package/dist/vocabulary-BuYFWeCU.js +0 -158
  958. package/dist/vocabulary-DeZvUaTw.d.ts +0 -401
  959. package/dist/waiter-BophA4BT.d.ts +0 -39
  960. package/dist/waiter-aBLM63_f.js +0 -67
  961. package/dist/watch-CJKYQYNb.js +0 -167
  962. package/dist/watch-Cv-xvI6e.js +0 -1
  963. package/dist/who-can-Yh9WdiwK.js +0 -367
  964. package/dist/wire-delegation-Cv3W2eaM.js +0 -36
  965. package/dist/wire-denial-C7PaVYEM.js +0 -27
  966. package/dist/wrap-Bq9fHwuT.d.ts +0 -18
  967. package/dist/wrap-C5PWzgkq.js +0 -33
  968. package/schemas/catalog-v1.json +0 -679
  969. package/schemas/cli-result-v1.json +0 -95
@@ -0,0 +1,2855 @@
1
+ import { E as PermissionTree, J as MetaValue, K as AppData, P as ResourceNode, T as PermissionKind, U as POLICY_SCOPES, a as RoleTree, i as RoleMeta, n as PlanTree, q as AppDataSchema, r as Role, t as Plan, w as Permission } from "./vocabulary-FYgI_NoI.js";
2
+ type ConditionRef = {
3
+ readonly ref: string;
4
+ };
5
+ type ConditionDate = {
6
+ readonly date: string;
7
+ };
8
+ type ConditionValue = string | number | boolean | null | readonly ConditionValue[] | ConditionRef | ConditionDate;
9
+ type ComparisonOp = "eq" | "ne" | "gt" | "gte" | "lt" | "lte" | "contains";
10
+ type ComparisonCondition = {
11
+ readonly op: ComparisonOp;
12
+ readonly field: string;
13
+ readonly value: ConditionValue;
14
+ };
15
+ type InCondition = {
16
+ readonly op: "in" | "notIn";
17
+ readonly field: string;
18
+ readonly value: readonly ConditionValue[] | ConditionRef;
19
+ };
20
+ type IsNullCondition = {
21
+ readonly op: "isNull";
22
+ readonly field: string;
23
+ readonly value: boolean;
24
+ };
25
+ type AndCondition = {
26
+ readonly op: "and";
27
+ readonly conditions: readonly Condition[];
28
+ };
29
+ type OrCondition = {
30
+ readonly op: "or";
31
+ readonly conditions: readonly Condition[];
32
+ };
33
+ type NotCondition = {
34
+ readonly op: "not";
35
+ readonly condition: Condition;
36
+ };
37
+ type MemberOfCondition = {
38
+ readonly op: "memberOf";
39
+ /** A declared scope name (or the `tenant` / `team` alias), or `'resource'`. */
40
+ readonly scope: string;
41
+ readonly field: string;
42
+ readonly roles: readonly string[];
43
+ readonly resource?: string;
44
+ readonly parents?: readonly MemberOfParent[];
45
+ };
46
+ /**
47
+ * A row field holding an ancestor's id. The keyed form matches only a
48
+ * membership on that resource; a bare field name matches a membership on any
49
+ * resource whose id equals the field.
50
+ */
51
+ type MemberOfParent = string | {
52
+ readonly field: string;
53
+ readonly resource: string;
54
+ };
55
+ /**
56
+ * The subject holds `relation` on the `resource` instance whose id the row's
57
+ * `field` holds, or on one of its ancestors within `depth` parent hops.
58
+ * Evaluated through a `RelationSource` in process, the closure table in RLS,
59
+ * and, given relation mappings, a subquery in the `toWhere` compilers.
60
+ */
61
+ type RelatedCondition = {
62
+ readonly op: "related";
63
+ readonly resource: string;
64
+ readonly relation: string;
65
+ /**
66
+ * The row's own id field, or (with `parent` or `hops`) the field holding the
67
+ * next instance's id.
68
+ */
69
+ readonly field: string;
70
+ /**
71
+ * Parent hops walked above the first `resource` instance; `0` reads only that
72
+ * instance.
73
+ */
74
+ readonly depth: number;
75
+ /** The row is a child of `resource`, reached through `field`. */
76
+ readonly parent?: true;
77
+ /**
78
+ * To-one links from the row to `resource`: `field` points at the first hop's
79
+ * resource, each later hop follows `link` on the resource before it, and the
80
+ * last hop's resource is `resource`.
81
+ */
82
+ readonly hops?: readonly RelatedHop[];
83
+ /**
84
+ * The `resource` instances the subject holds a resource role on; replaces the
85
+ * `relation` lookup (`relation` is then empty).
86
+ */
87
+ readonly ids?: readonly string[];
88
+ readonly permission?: string;
89
+ /**
90
+ * The row's boolean column that keeps ancestor grants out: with `parent` or
91
+ * `hops`, a restricted row matches nothing; without, the walk stops at the
92
+ * row.
93
+ */
94
+ readonly restricted?: string;
95
+ readonly restrictedAncestors?: RestrictedAncestors;
96
+ readonly passRestricted?: true;
97
+ };
98
+ type RestrictedAncestors = {
99
+ readonly resource: string;
100
+ readonly id: string;
101
+ readonly parent: string;
102
+ readonly depth: number;
103
+ readonly field: string;
104
+ };
105
+ type RelatedHop = {
106
+ readonly link: string;
107
+ readonly resource: string;
108
+ };
109
+ type OpaqueCondition = {
110
+ readonly op: "opaque";
111
+ readonly sql: string;
112
+ readonly fingerprint: string;
113
+ };
114
+ type SqlFunctionField = {
115
+ readonly field: string;
116
+ };
117
+ type SqlFunctionArg = ConditionValue | SqlFunctionField;
118
+ type SqlFunctionCondition = {
119
+ readonly op: "sqlFunction";
120
+ readonly name: string;
121
+ readonly args: readonly SqlFunctionArg[];
122
+ /**
123
+ * The set form: the row's `column` must be one of the ids the function
124
+ * returns, called once per statement as `"column" in (select name(args))`.
125
+ * Row-field args are not passed to the function.
126
+ */
127
+ readonly set?: {
128
+ readonly column: string;
129
+ };
130
+ readonly twin: Condition;
131
+ };
132
+ /**
133
+ * The request's session was checked against the Auth server while the subject
134
+ * was resolved (`liveSession: true`), not only verified from the token: a
135
+ * revoked session still verifies until `exp`. Written `{ subject: { session: {
136
+ * live: true } } }`.
137
+ */
138
+ type LiveSessionCondition = {
139
+ readonly op: "liveSession";
140
+ };
141
+ type Condition = ComparisonCondition | InCondition | IsNullCondition | AndCondition | OrCondition | NotCondition | MemberOfCondition | RelatedCondition | OpaqueCondition | SqlFunctionCondition | LiveSessionCondition;
142
+ declare function isConditionRef(value: unknown): value is ConditionRef;
143
+ declare function isConditionDate(value: unknown): value is ConditionDate;
144
+ declare function isCondition(value: unknown): value is Condition;
145
+ declare function isSqlFunctionField(value: unknown): value is SqlFunctionField;
146
+ declare function hasConditionOp(condition: Condition | undefined, op: Condition["op"]): boolean;
147
+ type FieldOperator = {
148
+ readonly eq?: unknown;
149
+ readonly ne?: unknown;
150
+ readonly gt?: unknown;
151
+ readonly gte?: unknown;
152
+ readonly lt?: unknown;
153
+ readonly lte?: unknown;
154
+ readonly contains?: unknown;
155
+ readonly in?: unknown;
156
+ readonly notIn?: unknown;
157
+ readonly isNull?: boolean;
158
+ };
159
+ type WhereShorthand<T = Record<string, unknown>> = unknown extends T ? RowWhere<Record<string, unknown>> : RowWhere<T>;
160
+ type RowWhere<T> = {
161
+ readonly and?: readonly WhereShorthand<T>[];
162
+ readonly or?: readonly WhereShorthand<T>[];
163
+ readonly not?: WhereShorthand<T>;
164
+ } & ("subject" extends keyof T ? { readonly [K in keyof T as Exclude<K, "subject">]?: FieldWhere<T[K]>; } & {
165
+ readonly subject?: SubjectWhere | FieldWhere<T["subject"]>;
166
+ } : { readonly [K in keyof T]?: FieldWhere<T[K]>; } & {
167
+ /**
168
+ * Holds only when the resolver checked the session live (`liveSession:
169
+ * true`).
170
+ */
171
+ readonly subject?: SubjectWhere;
172
+ });
173
+ type SubjectWhere = {
174
+ readonly session: {
175
+ readonly live: true;
176
+ };
177
+ };
178
+ type FieldWhere<V> = V | FieldOperator | {
179
+ readonly ref: string;
180
+ };
181
+ /**
182
+ * A string union that stays open: the listed values autocomplete, and an
183
+ * integrator may pass its own. Only for ids that core compares for equality,
184
+ * where an unknown value can only fail to match. A union whose members core
185
+ * interprets one by one (denial reasons, approval modes, condition operators,
186
+ * credential kinds, delivery channels) stays closed.
187
+ */
188
+ type OpenUnion<T extends string> = T | (string & NonNullable<unknown>);
189
+ /**
190
+ * `actor.kind`: the values PermDock's adapters set, or an integrator's own; a
191
+ * policy delegation matches it by equality.
192
+ */
193
+ type ActorKind = OpenUnion<"mcp-client" | "oauth-client" | "support" | "impersonation" | "ai-sdk" | "claude-agent" | "openai-agent" | "eve" | "terminal" | "web-bot-auth" | "a2a-agent" | "automation" | "job" | "caller" | "workload">;
194
+ /**
195
+ * The adapter a decision event names: a PermDock entry, or an integrator's own
196
+ * adapter.
197
+ */
198
+ type AdapterId = OpenUnion<"server" | "next" | "hono" | "express" | "fastify" | "elysia" | "nest" | "node" | "h3" | "sveltekit" | "astro" | "solid-start" | "tanstack-start" | "trpc" | "orpc" | "supabase-middleware" | "better-supabase" | "convex" | "authzen" | "mcp" | "a2a" | "agent" | "ai-sdk" | "claude-agent" | "openai" | "eve" | "terminal" | "webmcp" | "workflow" | "chat" | "delivery">;
199
+ /**
200
+ * How a membership was obtained (`membership.via`); `viaOnly` and support rules
201
+ * match it by equality.
202
+ */
203
+ type MembershipVia = OpenUnion<"direct" | "contact" | "credential" | "elevated" | "feed" | "link" | "share" | "support" | "support-session" | "scim">;
204
+ type JsonWebKeyLike = {
205
+ readonly kty?: string;
206
+ readonly [key: string]: unknown;
207
+ };
208
+ type Binding = {
209
+ readonly jkt?: string;
210
+ readonly "x5t#S256"?: string;
211
+ readonly jwk?: JsonWebKeyLike;
212
+ readonly kid?: string;
213
+ };
214
+ /**
215
+ * One OpenID Connect for Identity Assurance `verified_claims` entry, kept as
216
+ * the issuer sent it: opaque, frozen evidence for conditions and audit.
217
+ */
218
+ type VerifiedClaims = {
219
+ readonly verification: Readonly<Record<string, unknown>> & {
220
+ readonly trust_framework: string;
221
+ };
222
+ readonly claims: Readonly<Record<string, unknown>>;
223
+ };
224
+ type Assurance = {
225
+ readonly acr?: string;
226
+ readonly amr?: readonly string[];
227
+ readonly authTime?: number;
228
+ readonly verified?: readonly VerifiedClaims[];
229
+ };
230
+ /**
231
+ * Roles held in one scope instance (`scope` + `id`, with the id of every
232
+ * ancestor scope in `within`) or on one resource (`on`). Evaluation only sees
233
+ * the canonical form; `tenant` / `team` are accepted as input for the first and
234
+ * second declared scope and normalised away.
235
+ */
236
+ type Membership = {
237
+ readonly scope?: string;
238
+ readonly id?: string;
239
+ readonly within?: Readonly<Record<string, string>>;
240
+ readonly on?: {
241
+ readonly resource: string;
242
+ readonly id: string;
243
+ };
244
+ readonly roles: readonly string[];
245
+ /**
246
+ * Roles the holder may activate here but does not hold; `permdock.activate`
247
+ * writes an elevated membership.
248
+ */
249
+ readonly eligible?: readonly string[];
250
+ readonly via?: MembershipVia;
251
+ readonly expiresAt?: number;
252
+ /**
253
+ * The principal id that wrote this membership: who elevated, consented to or
254
+ * granted the access.
255
+ */
256
+ readonly grantedBy?: string;
257
+ /**
258
+ * Free text recording why the membership was written: the activation or
259
+ * consent justification.
260
+ */
261
+ readonly reason?: string;
262
+ /**
263
+ * A subgroup the holder belongs to inside the instance (`vendor-support`); a
264
+ * `junctionMembershipSource` group column fills it.
265
+ */
266
+ readonly member?: {
267
+ readonly group: string;
268
+ };
269
+ /**
270
+ * `idp`: the identity provider (SCIM) owns this membership; the application
271
+ * must not edit it.
272
+ */
273
+ readonly managedBy?: "idp";
274
+ /**
275
+ * Seats this membership holds (`dev-mode`, `editor`); `plan()` grantees match
276
+ * them inside the active tenant.
277
+ */
278
+ readonly entitlements?: readonly string[];
279
+ /**
280
+ * Set when the instance or an ancestor instance is suspended: the permission
281
+ * keys the membership still grants (`suspension.scopes.<scope>.keep`). Every
282
+ * other grant, allow or deny, ignores it, and so do role listings.
283
+ */
284
+ readonly keep?: readonly string[];
285
+ /**
286
+ * Data the application owns about this membership (a department, a seat
287
+ * label). Plain JSON from a trusted membership source, checked by
288
+ * `definePolicy(…, { x: { membership } })`. Never read in evaluation,
289
+ * conditions or RLS, and never written into token claims.
290
+ */
291
+ readonly x?: AppData;
292
+ };
293
+ /**
294
+ * One permission a custom role adds or removes. It names a declared permission
295
+ * key and carries no condition, approval or limit of its own.
296
+ */
297
+ type CustomRoleGrant = {
298
+ readonly permission: string;
299
+ readonly effect?: "allow" | "deny";
300
+ /**
301
+ * A level the permission's resource declares (`resource(…, { levels })`);
302
+ * allows only.
303
+ */
304
+ readonly level?: string;
305
+ };
306
+ type CustomRoleBody = {
307
+ readonly name: string;
308
+ readonly includes?: readonly string[];
309
+ readonly grants?: readonly CustomRoleGrant[];
310
+ /**
311
+ * Display text and app data, carried onto the role leaf `assignableRoles()`
312
+ * returns. `x` is checked by the role tree's `defineRoles(…, { x })` schema;
313
+ * an invalid `x` is dropped, not the role.
314
+ */
315
+ readonly meta?: RoleMeta;
316
+ };
317
+ /** A role a tenant defines, held on memberships inside that tenant. */
318
+ type TenantCustomRole = CustomRoleBody & {
319
+ /** The instance of the first scope that owns the role. */
320
+ readonly tenant: string;
321
+ /**
322
+ * The scope the role is held at; defaults to the first scope. Its ceiling is
323
+ * that scope's assignable roles.
324
+ */
325
+ readonly scope?: string;
326
+ /** Pins the role to one instance of `scope`. */
327
+ readonly id?: string;
328
+ /** Input only: `scope` = the second scope, `id` = this team. */
329
+ readonly team?: string;
330
+ readonly shared?: undefined;
331
+ };
332
+ /**
333
+ * A role the platform defines, held through `principal.roles` like a declared
334
+ * global role. Its ceiling is the allows of the declared global roles marked
335
+ * `assignable`.
336
+ */
337
+ type GlobalCustomRole = CustomRoleBody & {
338
+ readonly scope: "global";
339
+ readonly tenant?: undefined;
340
+ readonly id?: undefined;
341
+ readonly team?: undefined;
342
+ readonly shared?: undefined;
343
+ };
344
+ /**
345
+ * A role the platform defines once for every tenant, held on memberships of its
346
+ * scope in any tenant. Tenant admins assign it but never edit it. Its ceiling
347
+ * is the assignable declared roles of its scope; its name wins over a tenant
348
+ * custom role of the same name.
349
+ */
350
+ type SharedCustomRole = CustomRoleBody & {
351
+ readonly shared: true;
352
+ /**
353
+ * The scope the role is held at, never `'global'`; defaults to the first
354
+ * scope.
355
+ */
356
+ readonly scope?: string;
357
+ readonly tenant?: undefined;
358
+ readonly id?: undefined;
359
+ readonly team?: undefined;
360
+ };
361
+ type CustomRole = TenantCustomRole | SharedCustomRole | GlobalCustomRole;
362
+ type Principal = {
363
+ readonly id: string;
364
+ readonly issuer?: string;
365
+ /**
366
+ * `contact`: an external person (a customer contact, a portal user). Only its
367
+ * `{ on }` memberships count; it never approves, creates keys or publishes,
368
+ * and is read-only unless a role whose `for` lists `contact` grants the
369
+ * write.
370
+ */
371
+ readonly kind?: "user" | "service" | "workload" | "link" | "feed" | "contact";
372
+ readonly roles?: readonly string[];
373
+ readonly plans?: readonly string[];
374
+ readonly memberships?: readonly Membership[];
375
+ /**
376
+ * The token dropped memberships to stay under its size budget; a
377
+ * `claimsFirst` source reads the rest.
378
+ */
379
+ readonly membershipsTruncated?: boolean;
380
+ /** The authorization version the token was minted at (`authz_ver`). */
381
+ readonly authzVersion?: number;
382
+ /**
383
+ * The custom-role version of the token's active tenant when it was minted
384
+ * (`custom_roles_ver`): one counter per tenant that every edit of a custom
385
+ * role raises.
386
+ */
387
+ readonly customRolesVersion?: number;
388
+ readonly tenant?: string;
389
+ /**
390
+ * Set by core when a requested tenant is not one the subject holds: the
391
+ * denial is then `no-membership`, not `no-tenant`. Never read from a token.
392
+ */
393
+ readonly unheldTenant?: string;
394
+ readonly assurance?: Assurance;
395
+ readonly binding?: Binding;
396
+ readonly [key: string]: unknown;
397
+ };
398
+ type Actor = {
399
+ readonly id: string;
400
+ readonly kind: ActorKind;
401
+ readonly binding?: Binding;
402
+ /**
403
+ * `true` denies every permission without `readOnlyHint` (`not-delegated`),
404
+ * with or without a policy delegation.
405
+ */
406
+ readonly readOnly?: boolean;
407
+ /**
408
+ * The stable name the application gives this OAuth client (`ClientNames`),
409
+ * set by the subject resolver from the verified client id; policy delegations
410
+ * match it with `to: { kind, client }`.
411
+ */
412
+ readonly client?: string;
413
+ readonly [key: string]: unknown;
414
+ };
415
+ type AuthorizationDetail = {
416
+ readonly type: string;
417
+ readonly actions?: readonly string[];
418
+ readonly [key: string]: unknown;
419
+ };
420
+ type GnapAccess = string | Readonly<Record<string, unknown>>;
421
+ type Delegation = {
422
+ readonly scopes?: readonly string[];
423
+ readonly authorizationDetails?: readonly AuthorizationDetail[];
424
+ readonly access?: readonly GnapAccess[];
425
+ readonly chain?: unknown;
426
+ };
427
+ type Subject<TPrincipal extends Principal = Principal> = {
428
+ readonly principal: TPrincipal | null;
429
+ readonly actor?: Actor;
430
+ readonly delegation?: Delegation;
431
+ readonly context: Readonly<Record<string, unknown>>;
432
+ readonly session?: string;
433
+ readonly expiresAt?: number;
434
+ /**
435
+ * When the verified token was issued (`iat`), in seconds since the epoch. A
436
+ * `VersionCache` trusts the token's `authzVersion` for its `maxStaleMs` after
437
+ * it.
438
+ */
439
+ readonly issuedAt?: number;
440
+ /**
441
+ * The token's memberships are behind the source's authorization version:
442
+ * `fresh` permissions deny.
443
+ */
444
+ readonly stale?: true;
445
+ /**
446
+ * The resolver checked the session against the Auth server for this request
447
+ * (`liveSession: true`), so `{ subject: { session: { live: true } } }` holds.
448
+ * Never read from claims.
449
+ */
450
+ readonly liveSession?: true;
451
+ };
452
+ type DenialReason = "no-grant" | "condition" | "deny" | "inactive-grant" | "closure-error" | "opaque-condition" | "server-only" | "anonymous" | "not-delegated" | "no-delegation" | "agent-tool-not-delegated" | "insufficient-user-authentication" | "not-entitled" | "purpose" | "reason-required" | "actor-required" | "limit" | "limit-unavailable" | "relation-depth" | "relation-unavailable" | "validation" | "tenant-mismatch" | "no-membership" | "no-tenant" | "scope" | "expired-membership" | "stale-credentials" | "unknown-role" | "last-holder" | "max-holders" | "transfer-only" | "not-assignable-by" | "self-demotion" | "externally-managed" | "not-allowed-for-membership" | "conflicting-role" | "approval" | "stale-approval" | "pdp-denied" | "pdp-unavailable" | "pdp-invalid-response" | "undocumented" | "unsupported" | "exceeds-creator" | "credential-policy";
453
+ /**
454
+ * The `detail` each denial reason carries, where PermDock sets a structured
455
+ * one.
456
+ */
457
+ type DenialDetails = {
458
+ readonly limit: LimitDetail;
459
+ /** The window the inactive allow applies in. */
460
+ readonly "inactive-grant": WireValidity;
461
+ /** The matching deny's declared `name`. */
462
+ readonly deny: {
463
+ readonly name?: string;
464
+ };
465
+ };
466
+ /**
467
+ * Why a candidate grant did not apply. `Denial<"limit">` types `detail` for a
468
+ * reason in `DenialDetails`; any other reason's detail is `unknown`.
469
+ */
470
+ type Denial<R extends DenialReason = DenialReason> = {
471
+ readonly role: string | null;
472
+ readonly reason: R;
473
+ readonly detail?: [R] extends [keyof DenialDetails] ? DenialDetails[R] : unknown;
474
+ readonly to?: Grantee | readonly Grantee[];
475
+ };
476
+ type MatchedGrant = {
477
+ readonly role: string | null;
478
+ readonly permission: string;
479
+ /** The grant's declared `name`, when it has one. */
480
+ readonly name?: string;
481
+ /** The grant's declared `meta`, when it has one; PermDock never reads it. */
482
+ readonly meta?: GrantMeta;
483
+ readonly to?: Grantee | readonly Grantee[];
484
+ readonly where?: Grant["where"];
485
+ readonly check?: Grant["check"];
486
+ readonly approval?: "human" | ApprovalRequirement;
487
+ readonly provider?: string;
488
+ /**
489
+ * The hosted policy document fingerprint and grant id, when a hosted grant
490
+ * matched.
491
+ */
492
+ readonly hosted?: HostedGrantRef;
493
+ /** A break-glass grant overrode a matching deny. */
494
+ readonly breakGlass?: true;
495
+ };
496
+ /**
497
+ * Something the caller owes alongside a granted action. `over-limit`: a soft
498
+ * `limit` was past its count; `near-limit`: usage reached `alertAt`. `notify` /
499
+ * `review`: a break-glass grant's declared follow-ups. `justify`: the
500
+ * break-glass reason, carried so audit records why. `app`: a follow-up the
501
+ * application declared on the grant (`allow(p, { obligations })`); PermDock
502
+ * carries it and never acts on it.
503
+ */
504
+ type Obligation = {
505
+ readonly kind: "over-limit" | "near-limit" | "notify" | "review";
506
+ } | {
507
+ readonly kind: "justify";
508
+ readonly reason: string;
509
+ } | AppObligation;
510
+ /** An obligation the application declares on an allow and handles itself. */
511
+ type AppObligation = {
512
+ readonly kind: "app";
513
+ /** Lower case letters, digits, `_` and `-`, starting with a letter. */
514
+ readonly name: string;
515
+ readonly detail?: MetaValue;
516
+ };
517
+ /** What is left of the `limit` that applied; `resetsAt` is RFC 3339. */
518
+ type Quota = {
519
+ readonly remaining: number;
520
+ readonly resetsAt: string;
521
+ };
522
+ /**
523
+ * The `detail` of a `limit` denial: the grant's `count`, its `per` window in
524
+ * seconds and when the window resets (RFC 3339).
525
+ */
526
+ type LimitDetail = {
527
+ readonly count: number;
528
+ readonly per: number;
529
+ readonly resetsAt: string;
530
+ };
531
+ /**
532
+ * Why a candidate grant for the permission was passed over before its condition
533
+ * ran: `via-only` (the subject holds no membership of its kind), `purpose` (no
534
+ * asserted purpose it lists), `field` (its `fields` do not cover the requested
535
+ * field), `grantee` (its `to` did not match and added no denial), `role` (a
536
+ * role it names is not held), `validity` (a deny outside its `validFrom` /
537
+ * `validUntil`; an inactive allow adds an `inactive-grant` denial instead),
538
+ * `break-glass-inactive` (a break-glass grant with no asserted purpose).
539
+ */
540
+ type TraceSkipReason = "via-only" | "purpose" | "field" | "grantee" | "role" | "validity" | "unknown-level" | "break-glass-inactive";
541
+ type TraceSkip = {
542
+ readonly role: string | null;
543
+ readonly permission: string;
544
+ readonly effect: "allow" | "deny";
545
+ readonly why: TraceSkipReason;
546
+ /**
547
+ * The level a custom role names that its resource does not declare, for
548
+ * `unknown-level`.
549
+ */
550
+ readonly level?: string;
551
+ };
552
+ /**
553
+ * What `explain` saw: how many candidate grants it examined before the outcome,
554
+ * which allows matched (including the ones a deny overrode), which denies
555
+ * matched, and which grants it passed over. `denies[0]` is the deny that
556
+ * produced a `deny` outcome, or the deny a break-glass grant lifted. Pure local
557
+ * computation; never on a decision event.
558
+ */
559
+ type Trace = {
560
+ readonly evaluated: number;
561
+ readonly allows: readonly MatchedGrant[];
562
+ readonly denies: readonly MatchedGrant[];
563
+ readonly skipped: readonly TraceSkip[];
564
+ };
565
+ type GrantedDecision = {
566
+ readonly outcome: "granted";
567
+ readonly subject: Subject;
568
+ readonly matched: MatchedGrant;
569
+ readonly token: string;
570
+ readonly obligations?: readonly Obligation[];
571
+ readonly quota?: Quota;
572
+ /**
573
+ * The membership `permdock.activate` produced for the app to write: an
574
+ * elevated, time-bound, attributed row. Set only by `activate`; a plain
575
+ * `decide` never writes memberships.
576
+ */
577
+ readonly elevation?: Membership;
578
+ /** Present only with `explain: true`. */
579
+ readonly trace?: Trace;
580
+ };
581
+ type DeniedDecision = {
582
+ readonly outcome: "denied";
583
+ /**
584
+ * The key of the permission that was checked. Absent on a denial for a check
585
+ * that named no declared permission.
586
+ */
587
+ readonly permission?: string;
588
+ readonly denials: readonly Denial[];
589
+ readonly alternatives: readonly Permission[];
590
+ /** Present only with `explain: true`. */
591
+ readonly trace?: Trace;
592
+ };
593
+ type ApprovalRequiredDecision = {
594
+ readonly outcome: "approval-required";
595
+ readonly grant: MatchedGrant;
596
+ readonly reason: "human";
597
+ readonly token: string;
598
+ /**
599
+ * The `fingerprint` the call passed, bound into `token`; the request it opens
600
+ * records it, and a resume under another fingerprint is refused.
601
+ */
602
+ readonly fingerprint?: string;
603
+ /** Present only with `explain: true`. */
604
+ readonly trace?: Trace;
605
+ };
606
+ /** A decision from `explain`: the same union, with the trace always present. */
607
+ type ExplainedDecision = Decision & {
608
+ readonly trace: Trace;
609
+ };
610
+ type Decision = GrantedDecision | DeniedDecision | ApprovalRequiredDecision;
611
+ type RoleGrantee = {
612
+ readonly kind: "role";
613
+ readonly role: string;
614
+ /** `'global'`, a scope name, or one resource. */
615
+ readonly scope: string | {
616
+ readonly resource: string;
617
+ };
618
+ };
619
+ type AnyoneGrantee = {
620
+ readonly kind: "anyone";
621
+ };
622
+ type AuthenticatedGrantee = {
623
+ readonly kind: "authenticated";
624
+ };
625
+ type RelationGrantee = {
626
+ readonly kind: "relation";
627
+ readonly resource: string;
628
+ readonly relation: string;
629
+ /**
630
+ * `'parent'`: follow the row's `parent` chain upward to `resource`, then its
631
+ * own parents. A list of link names: follow those to-one links from the row
632
+ * to `resource`, then walk its parents only when `depth` is set.
633
+ */
634
+ readonly through?: "parent" | readonly string[];
635
+ /**
636
+ * Parent hops walked above the first `resource` instance; absent means
637
+ * `DEFAULT_RELATION_DEPTH` for `'parent'` and `0` for links.
638
+ */
639
+ readonly depth?: number;
640
+ };
641
+ type PlanGrantee = {
642
+ readonly kind: "plan";
643
+ readonly plan: string;
644
+ };
645
+ type ActorGrantee = {
646
+ readonly kind: "actor";
647
+ readonly actor: string;
648
+ };
649
+ type AssuranceGrantee = {
650
+ readonly kind: "assurance";
651
+ readonly acr?: readonly string[];
652
+ readonly amr?: readonly string[];
653
+ readonly maxAge?: number;
654
+ };
655
+ type InheritGrantee = {
656
+ readonly kind: "inherit";
657
+ readonly permission: string;
658
+ readonly resource: string;
659
+ readonly through: "parent" | readonly string[];
660
+ };
661
+ type Grantee = RoleGrantee | InheritGrantee | AnyoneGrantee | AuthenticatedGrantee | RelationGrantee | PlanGrantee | ActorGrantee | AssuranceGrantee;
662
+ type GranteeInput = Grantee | Role | Plan | string | readonly GranteeInput[];
663
+ declare function anyone(): AnyoneGrantee;
664
+ declare function authenticated(): AuthenticatedGrantee;
665
+ declare function relation(resource: Permission | PermissionTree, name: string, options?: {
666
+ readonly through?: "parent" | readonly string[];
667
+ readonly depth?: number;
668
+ }): RelationGrantee;
669
+ declare function inherit(permission: Permission, options: {
670
+ readonly through: "parent" | readonly string[];
671
+ }): InheritGrantee;
672
+ declare function plan(name: Plan | string): PlanGrantee;
673
+ declare function actor(kind: string): ActorGrantee;
674
+ declare function assurance(options: {
675
+ readonly acr?: string | readonly string[];
676
+ readonly amr?: string | readonly string[];
677
+ readonly maxAge?: number;
678
+ }): AssuranceGrantee;
679
+ /** One named approver, by principal id. */
680
+ type UserApprover = {
681
+ readonly kind: "user";
682
+ readonly id: string;
683
+ };
684
+ /**
685
+ * Whoever holds `permission` in the request's tenant, through any role, custom
686
+ * roles included. Checked only through verdict facts
687
+ * (`ApprovalVerdict.permissions`) that the handler computes from the approver's
688
+ * own instance.
689
+ */
690
+ type PermissionApprover = {
691
+ readonly kind: "permission";
692
+ readonly permission: string;
693
+ };
694
+ /**
695
+ * The requester's manager, or anyone up the chain within `levels` (default 1),
696
+ * read from the `manager` relation on the requester's `user` record. Checked
697
+ * only through verdict facts (`ApprovalVerdict.relations`) that the handler
698
+ * reads from its `RelationSource`.
699
+ */
700
+ type ManagerApprover = {
701
+ readonly kind: "manager";
702
+ readonly levels?: number;
703
+ };
704
+ /**
705
+ * An approver who matches at least one item; an item that is a list matches
706
+ * when every entry does.
707
+ */
708
+ type AnyOfApprover = {
709
+ readonly kind: "any-of";
710
+ readonly of: readonly (Approver | readonly Approver[])[];
711
+ };
712
+ /**
713
+ * Who may approve: a subject-only grantee, a `relation()` the approver holds on
714
+ * the requested row (checked when the verdict is given), `user(id)`,
715
+ * `holder(permission)`, `manager()`, or `anyOf(...)`. A list (or `allOf(...)`)
716
+ * matches an approver who satisfies every item.
717
+ */
718
+ type Approver = Grantee | UserApprover | PermissionApprover | ManagerApprover | AnyOfApprover;
719
+ type ApproverInput = GranteeInput | UserApprover | PermissionApprover | ManagerApprover | {
720
+ readonly kind: "any-of";
721
+ readonly of: readonly ApproverInput[];
722
+ } | readonly ApproverInput[];
723
+ /**
724
+ * Approves when the approver holds `permission` in the request's tenant (any
725
+ * role, custom roles included).
726
+ */
727
+ declare function holder(permission: Permission): PermissionApprover;
728
+ /** Approves when the approver matches any one of `items`. */
729
+ declare function anyOf(...items: readonly ApproverInput[]): {
730
+ readonly kind: "any-of";
731
+ readonly of: readonly ApproverInput[];
732
+ };
733
+ /** Approves when the approver matches every one of `items`; the same as a list. */
734
+ declare function allOf(...items: readonly ApproverInput[]): readonly ApproverInput[];
735
+ /** A named approver for `approval.by`, matched on the approver's principal id. */
736
+ declare function user(id: string): UserApprover;
737
+ /**
738
+ * Approves when the approver manages the requester, directly or within `levels`
739
+ * steps up the chain (1 to `MAX_MANAGER_LEVELS`, default 1).
740
+ */
741
+ declare function manager(options?: {
742
+ readonly levels?: number;
743
+ }): ManagerApprover;
744
+ /**
745
+ * One entry of `definePolicy({ scopes })`: the row field holding the scope id,
746
+ * and its parent scope.
747
+ */
748
+ type ScopeDeclaration = {
749
+ readonly key: string;
750
+ readonly within?: string;
751
+ };
752
+ type PolicyScopesInput = Readonly<Record<string, ScopeDeclaration>>;
753
+ /**
754
+ * A declared scope, in declaration order. `key` is absent only on the implicit
755
+ * `tenant` / `team` pair of a policy that declares no scopes.
756
+ */
757
+ type Scope = {
758
+ readonly name: string;
759
+ readonly key?: string;
760
+ readonly within?: string;
761
+ };
762
+ /**
763
+ * The names `role(..., { on })`, `memberOf` and memberships may use: declared
764
+ * names plus the aliases.
765
+ */
766
+ type ScopeNames<S> = [S] extends [PolicyScopesInput] ? string extends keyof S ? string : (keyof S & string) | "tenant" | "team" : string;
767
+ /**
768
+ * A delegation as every PermDock wire form carries it: OAuth `scope` (RFC 6749,
769
+ * space-separated) and RFC 9396 `authorization_details`. An empty `scope` is an
770
+ * empty scope list, which delegates nothing.
771
+ */
772
+ type WireDelegation = {
773
+ readonly scope?: string;
774
+ readonly authorization_details?: readonly AuthorizationDetail[];
775
+ readonly access?: readonly GnapAccess[];
776
+ };
777
+ /**
778
+ * A denial as it leaves the process: in a decision event, a Problem Details
779
+ * body, an MCP or WebMCP refusal and the decision endpoint. `detail` is a JSON
780
+ * value (a string, or `LimitDetail` on `limit`); what a closure threw and a
781
+ * validation error stay in process.
782
+ */
783
+ type WireDenial = {
784
+ readonly role: string | null;
785
+ readonly reason: DenialReason;
786
+ readonly to?: Grantee | readonly Grantee[];
787
+ readonly detail?: unknown;
788
+ };
789
+ /**
790
+ * A `Decision` whose denials are `WireDenial`s, as the decision endpoint sends
791
+ * it.
792
+ */
793
+ type WireDecision = GrantedDecision | ApprovalRequiredDecision | (Omit<DeniedDecision, "denials"> & {
794
+ readonly denials: readonly WireDenial[];
795
+ });
796
+ type DirectoryEvent = {
797
+ readonly type: "directory";
798
+ readonly at: string;
799
+ /** `scim`, or an integrator's own directory sync. */
800
+ readonly source: OpenUnion<"scim">;
801
+ readonly operation: "create" | "replace" | "patch" | "delete";
802
+ readonly tenant: string;
803
+ readonly resource: {
804
+ readonly type: "User" | "Group";
805
+ readonly id: string;
806
+ };
807
+ readonly credential: {
808
+ readonly kind: "token";
809
+ } | {
810
+ readonly kind: "jwt";
811
+ readonly iss?: string;
812
+ };
813
+ readonly active?: boolean;
814
+ /**
815
+ * The application's own data, set where the event is built; plain JSON, never
816
+ * read by a decision.
817
+ */
818
+ readonly x?: AppData;
819
+ };
820
+ type MembershipEvent = {
821
+ readonly type: "membership";
822
+ readonly at: string;
823
+ readonly source: string;
824
+ readonly operation: "added" | "removed" | "changed";
825
+ readonly principal: {
826
+ readonly id: string;
827
+ };
828
+ /**
829
+ * A declared scope name, or the `tenant` / `team` alias; absent for a global
830
+ * role change.
831
+ */
832
+ readonly scope?: string;
833
+ /** The scope instance; present exactly when `scope` is. */
834
+ readonly id?: string;
835
+ /** The id of every ancestor scope, keyed by scope name. */
836
+ readonly within?: Readonly<Record<string, string>>;
837
+ readonly via?: MembershipVia;
838
+ /** When the membership lapses, an RFC 3339 instant. */
839
+ readonly expiresAt?: string;
840
+ readonly roles: {
841
+ readonly added: readonly string[];
842
+ readonly removed: readonly string[];
843
+ };
844
+ readonly by?: {
845
+ readonly id: string;
846
+ readonly kind: string;
847
+ };
848
+ /**
849
+ * The application's own data, set where the event is built; plain JSON, never
850
+ * read by a decision.
851
+ */
852
+ readonly x?: AppData;
853
+ };
854
+ /**
855
+ * An API key's lifecycle: `created`, `rotated` and `revoked` from the
856
+ * application or a credential store, `used` from `subjectFromApiKey`. A `used`
857
+ * event carries `sample`, the fraction of uses reported.
858
+ */
859
+ type CredentialEvent = {
860
+ readonly type: "credential";
861
+ readonly at: string;
862
+ readonly source: string;
863
+ readonly operation: "created" | "used" | "rotated" | "revoked";
864
+ readonly credential: {
865
+ readonly id: string;
866
+ readonly kind: CredentialKind;
867
+ };
868
+ readonly principal: {
869
+ readonly id: string;
870
+ };
871
+ readonly tenant?: string;
872
+ /** When the key expires, an RFC 3339 instant. */
873
+ readonly expiresAt?: string;
874
+ readonly by?: {
875
+ readonly id: string;
876
+ readonly kind: string;
877
+ };
878
+ readonly sample?: number;
879
+ /**
880
+ * The application's own data, set where the event is built; plain JSON, never
881
+ * read by a decision.
882
+ */
883
+ readonly x?: AppData;
884
+ };
885
+ /**
886
+ * An automation's lifecycle: `published`, `changed` (a new version) and
887
+ * `revoked` from the application, `run` when a run starts. It records the
888
+ * delegation for access review; it never decides.
889
+ */
890
+ type AutomationEvent = {
891
+ readonly type: "automation";
892
+ readonly at: string;
893
+ readonly source: string;
894
+ readonly operation: "published" | "changed" | "revoked" | "run";
895
+ readonly automation: {
896
+ readonly id: string;
897
+ readonly version: number | string;
898
+ readonly mode: "publisher" | "service";
899
+ readonly name?: string;
900
+ };
901
+ /** The principal each run acts as. */
902
+ readonly principal: {
903
+ readonly id: string;
904
+ };
905
+ readonly publishedBy: string;
906
+ readonly tenant?: string;
907
+ readonly roles?: readonly string[];
908
+ /** The delegated permission keys. */
909
+ readonly permissions: readonly string[];
910
+ /** Set on `run` events only. */
911
+ readonly run?: {
912
+ readonly id: string;
913
+ };
914
+ readonly by?: {
915
+ readonly id: string;
916
+ readonly kind: string;
917
+ };
918
+ /**
919
+ * The application's own data, set where the event is built; plain JSON, never
920
+ * read by a decision.
921
+ */
922
+ readonly x?: AppData;
923
+ };
924
+ type SinkEvent = DecisionEvent | DirectoryEvent | MembershipEvent | CredentialEvent | AccessEvent | AutomationEvent | DeliveryEvent;
925
+ /** A delivery channel: an email, a chat message or an outbound webhook. */
926
+ type DeliveryChannel = "email" | "chat" | "webhook";
927
+ /** What an email is for; only `notification` mail carries `List-Unsubscribe`. */
928
+ type EmailCategory = "transactional" | "notification" | "security" | "approval";
929
+ /**
930
+ * Why a delivery failed. `denied` and `unlinked` are the router's refusals of a
931
+ * recipient; the rest come from a transport or a provider webhook.
932
+ */
933
+ type DeliveryFailureCause = "denied" | "unlinked" | "no-transport" | "no-message" | "invalid-recipient" | "invalid-message" | "rate-limited" | "quota-exceeded" | "unauthorized" | "unavailable" | "suppressed" | "rejected";
934
+ /**
935
+ * One recipient's delivery: `sent` when a transport accepted it, then
936
+ * `delivered`, `bounced` or `complained` from the provider, or `failed`. It
937
+ * carries no address, only the principal the router checked.
938
+ */
939
+ type DeliveryEvent = {
940
+ readonly type: "delivery";
941
+ readonly at: string;
942
+ readonly source: string;
943
+ readonly operation: "sent" | "delivered" | "bounced" | "complained" | "failed";
944
+ readonly channel: DeliveryChannel;
945
+ /** The delivery's id and this recipient's key, sent as the `Idempotency-Key`. */
946
+ readonly delivery: {
947
+ readonly id: string;
948
+ readonly key: string;
949
+ };
950
+ /**
951
+ * The checked principal, or `trusted` for an address the server loaded
952
+ * itself.
953
+ */
954
+ readonly recipient?: {
955
+ readonly principal?: {
956
+ readonly id: string;
957
+ };
958
+ readonly trusted?: true;
959
+ };
960
+ /** The permission the recipient was checked for. */
961
+ readonly permission?: string;
962
+ readonly tenant?: string;
963
+ readonly category?: EmailCategory;
964
+ /** The approval request a prompt was delivered for. */
965
+ readonly approval?: string;
966
+ /** The transport or provider, and its message id. */
967
+ readonly provider?: {
968
+ readonly name: string;
969
+ readonly id?: string;
970
+ };
971
+ /** Set on `failed` only. */
972
+ readonly cause?: DeliveryFailureCause;
973
+ /** Set on `failed` only: whether a retry with the same key may succeed. */
974
+ readonly retryable?: boolean;
975
+ /** The denial reason when `cause` is `denied`. */
976
+ readonly reason?: string;
977
+ /**
978
+ * The application's own data, set where the event is built; plain JSON, never
979
+ * read by a decision.
980
+ */
981
+ readonly x?: AppData;
982
+ };
983
+ /**
984
+ * A support-access session lifecycle event: a tenant consented to vendor
985
+ * support (`started`), the session lapsed (`ended`), or the tenant pulled
986
+ * consent early (`revoked`). It never decides; it records what happened for
987
+ * audit and revocation.
988
+ */
989
+ type AccessEvent = {
990
+ readonly type: "access";
991
+ readonly at: string;
992
+ readonly source: string;
993
+ readonly operation: "started" | "ended" | "revoked";
994
+ readonly tenant: string;
995
+ readonly principal: {
996
+ readonly id: string;
997
+ };
998
+ /** The membership kind the session runs under (`support`). */
999
+ readonly via: MembershipVia;
1000
+ readonly roles: readonly string[];
1001
+ readonly member?: {
1002
+ readonly group: string;
1003
+ };
1004
+ /** When the session lapses, an RFC 3339 instant. */
1005
+ readonly expiresAt?: string;
1006
+ /** The tenant principal that consented. */
1007
+ readonly grantedBy?: string;
1008
+ readonly reason?: string;
1009
+ readonly actor?: {
1010
+ readonly id: string;
1011
+ readonly kind: string;
1012
+ };
1013
+ /** A `SupportSession`: its id and the principal the staff member views as. */
1014
+ readonly session?: {
1015
+ readonly id: string;
1016
+ readonly principal: string;
1017
+ };
1018
+ /** A `SupportSession`'s permission keys. */
1019
+ readonly permissions?: readonly string[];
1020
+ /**
1021
+ * The application's own data, set where the event is built; plain JSON, never
1022
+ * read by a decision.
1023
+ */
1024
+ readonly x?: AppData;
1025
+ };
1026
+ type DecisionEvent = {
1027
+ readonly type: "decision";
1028
+ /** An RFC 3339 instant. */
1029
+ readonly at: string;
1030
+ readonly outcome: "granted" | "denied" | "approval-required";
1031
+ readonly permission: string;
1032
+ readonly scope: string;
1033
+ readonly resource: {
1034
+ readonly type: string;
1035
+ readonly id?: string;
1036
+ };
1037
+ readonly subject: {
1038
+ readonly principal: {
1039
+ readonly id: string;
1040
+ readonly roles: readonly string[];
1041
+ readonly tenant?: string;
1042
+ } | null;
1043
+ readonly actor?: {
1044
+ readonly id: string;
1045
+ readonly kind: string;
1046
+ };
1047
+ /**
1048
+ * OAuth `scope` and RFC 9396 `authorization_details`, as every wire form
1049
+ * carries a delegation.
1050
+ */
1051
+ readonly delegation?: WireDelegation;
1052
+ /** The API key the subject came from. */
1053
+ readonly credential?: {
1054
+ readonly id: string;
1055
+ readonly kind: CredentialKind;
1056
+ };
1057
+ /**
1058
+ * The support session the subject came from: the `id` its `access` events
1059
+ * carry as `session.id`.
1060
+ */
1061
+ readonly supportSession?: {
1062
+ readonly id: string;
1063
+ };
1064
+ };
1065
+ readonly tenant?: string;
1066
+ /** The membership that answered, with `expiresAt` as an RFC 3339 instant. */
1067
+ readonly membership?: Omit<Membership, "expiresAt"> & {
1068
+ readonly expiresAt?: string;
1069
+ };
1070
+ readonly via?: string | null;
1071
+ readonly matched?: {
1072
+ readonly role: string | null;
1073
+ readonly permission: string;
1074
+ /** The grant's declared `name`. */
1075
+ readonly name?: string;
1076
+ /** The grant's declared `meta`; PermDock never reads it. */
1077
+ readonly meta?: GrantMeta;
1078
+ readonly to?: Grantee | readonly Grantee[];
1079
+ readonly hosted?: HostedGrantRef;
1080
+ readonly breakGlass?: true;
1081
+ };
1082
+ /** What a granted decision owes, as on `GrantedDecision.obligations`. */
1083
+ readonly obligations?: readonly Obligation[];
1084
+ /**
1085
+ * Purposes of use the caller asserted (`context.purpose`); present when any
1086
+ * was.
1087
+ */
1088
+ readonly purpose?: readonly string[];
1089
+ /** The justification the caller supplied (`context.reason`); present when set. */
1090
+ readonly reason?: string;
1091
+ readonly denials?: readonly WireDenial[];
1092
+ readonly alternatives?: readonly string[];
1093
+ readonly token?: string;
1094
+ readonly trusted: boolean;
1095
+ /** The call that produced the decision. */
1096
+ readonly call: "can" | "decide" | "assert" | "filter" | "endpoint" | "adapter" | "approval" | "simulate" | "explain";
1097
+ readonly adapter?: AdapterId;
1098
+ /**
1099
+ * The model id the agent model gate decided, or the model that drove the
1100
+ * call.
1101
+ */
1102
+ readonly model?: string;
1103
+ /** Set on an approval lifecycle event (`com.permdock.approval.<phase>`). */
1104
+ readonly phase?: "requested" | "resolved" | "expired" | "cancelled";
1105
+ readonly counts?: {
1106
+ readonly granted: number;
1107
+ readonly denied: number;
1108
+ readonly approvalRequired: number;
1109
+ };
1110
+ /**
1111
+ * The application's own data, set where the event is built; plain JSON, never
1112
+ * read by a decision.
1113
+ */
1114
+ readonly x?: AppData;
1115
+ };
1116
+ type AuthEvent = {
1117
+ readonly reason: "invalid-token" | "schema" | "unknown-role" | "groups-overflow" | "source-threw";
1118
+ readonly cause?: string;
1119
+ readonly source: string;
1120
+ /** The `name` of the source that threw, when it has one. */
1121
+ readonly name?: string;
1122
+ readonly kid?: string;
1123
+ readonly alg?: string;
1124
+ readonly typ?: string;
1125
+ readonly issuer?: string;
1126
+ readonly requestId?: string;
1127
+ };
1128
+ /**
1129
+ * The tenants a snapshot lists: `'all'` for every tenant the subject belongs
1130
+ * to, or the named tenants among them. A name with no membership is dropped.
1131
+ */
1132
+ type SnapshotTenants = "all" | readonly string[];
1133
+ /**
1134
+ * The flat form the evaluator reads: one entry per grant, each with its full
1135
+ * terms. Not public.
1136
+ */
1137
+ type ExpandedSnapshot = {
1138
+ readonly v: 1;
1139
+ /**
1140
+ * RFC 3339. The epoch for a snapshot built without a clock. Signed, it is the
1141
+ * token's `iat`.
1142
+ */
1143
+ readonly issuedAt: string;
1144
+ readonly subject: {
1145
+ readonly principal: {
1146
+ readonly id: string;
1147
+ readonly roles: readonly string[];
1148
+ readonly plans?: readonly string[];
1149
+ readonly tenant?: string;
1150
+ readonly memberships?: readonly Membership[];
1151
+ } | null;
1152
+ /**
1153
+ * OAuth `scope` and RFC 9396 `authorization_details`, as the token carried
1154
+ * them.
1155
+ */
1156
+ readonly delegation?: WireDelegation;
1157
+ readonly context: Readonly<Record<string, unknown>>;
1158
+ };
1159
+ /** Roles held in the active tenant, in rank order. */
1160
+ readonly roles: readonly string[];
1161
+ /**
1162
+ * The distinct `meta.audience` values of `roles`, in rank order; absent when
1163
+ * none has one.
1164
+ */
1165
+ readonly audiences?: readonly string[];
1166
+ readonly grants: readonly SnapshotGrant[];
1167
+ readonly tenants: readonly string[];
1168
+ readonly include?: readonly string[];
1169
+ readonly simulated?: true;
1170
+ /** RFC 3339. Signed, it is the token's `exp`. */
1171
+ readonly expiresAt?: string;
1172
+ readonly vocabulary?: {
1173
+ readonly roles?: Readonly<Record<string, Role>>;
1174
+ readonly plans?: Readonly<Record<string, Plan>>;
1175
+ };
1176
+ /**
1177
+ * The policy's scopes in order, so a client checks the row against each
1178
+ * membership's instance.
1179
+ */
1180
+ readonly scopes?: readonly SnapshotScope[];
1181
+ /**
1182
+ * One entry per tenant in `tenants`: what the subject may hand out there.
1183
+ * Absent without tenants.
1184
+ */
1185
+ readonly assignable?: readonly SnapshotAssignable[];
1186
+ /**
1187
+ * Allow grants of held roles that only a plan the subject lacks keeps from
1188
+ * applying; they grant nothing and name the plan a denial asks for.
1189
+ */
1190
+ readonly notEntitled?: readonly SnapshotNotEntitled[];
1191
+ /**
1192
+ * The row id field per resource whose `id` option is not `id`, for the grants
1193
+ * in `grants`. Absent when every one reads `id`.
1194
+ */
1195
+ readonly ids?: Readonly<Record<string, string>>;
1196
+ /**
1197
+ * The permission keys the policy's delegations let the actor use for the
1198
+ * principal, sorted; present only when one applies. Outside it a check is
1199
+ * `not-delegated`; inside it a token delegation, when there is one, must
1200
+ * still cover.
1201
+ */
1202
+ readonly delegated?: readonly string[];
1203
+ /**
1204
+ * The token's authorization version (`authz_ver`) the snapshot was built
1205
+ * from. A client compares it with the version in a refresh signal.
1206
+ */
1207
+ readonly authzVersion?: number;
1208
+ /**
1209
+ * Set by a local snapshot. Assignable permissions from it are `server-only`:
1210
+ * the device list is a hint and the server decides what may be handed out.
1211
+ */
1212
+ readonly local?: true;
1213
+ /** The Auth session (`session_id`) the snapshot was built for. */
1214
+ readonly sessionId?: string;
1215
+ /**
1216
+ * What a check with no row, team or field answers in the active tenant, so a
1217
+ * client renders `usePermission(permission)` without loading its evaluator.
1218
+ * Every key not listed is denied. Absent when an answer depends on the clock
1219
+ * (a grant `validity`, a membership `expiresAt`) or on the server alone.
1220
+ */
1221
+ readonly typeLevel?: SnapshotTypeLevel;
1222
+ };
1223
+ /**
1224
+ * What a grant says apart from its permission key: its effect, role, grantee,
1225
+ * conditions, scope and membership. A `Snapshot` lists each distinct set once
1226
+ * in `conditions`.
1227
+ */
1228
+ type SnapshotGrantTerms = Omit<SnapshotGrant, "permission">;
1229
+ /**
1230
+ * The wire form `snapshot()` returns and every client takes: `conditions` holds
1231
+ * each distinct set of grant terms once and a grant is `{ permission, cond }`,
1232
+ * `cond` indexing it. `parseSnapshot` validates it; the evaluator expands it
1233
+ * into an `ExpandedSnapshot` it alone reads.
1234
+ */
1235
+ type Snapshot = Omit<ExpandedSnapshot, "grants"> & {
1236
+ readonly conditions: readonly SnapshotGrantTerms[];
1237
+ /**
1238
+ * Grants the snapshot leaves to a `ClientBundle`, built with `omitStatic`.
1239
+ * Absent when every grant is inline.
1240
+ */
1241
+ readonly static?: SnapshotStatic;
1242
+ readonly grants: readonly {
1243
+ readonly permission: string;
1244
+ /**
1245
+ * Indexes into `conditions`: one, or a list for consecutive grants of the
1246
+ * same permission, in grant order.
1247
+ */
1248
+ readonly cond: number | readonly number[];
1249
+ }[];
1250
+ };
1251
+ /**
1252
+ * The role grants a snapshot refers to instead of carrying. `held` lists one
1253
+ * `[role, membership]` per group: the role's bundle grants with that entry of
1254
+ * `subject.principal.memberships` attached, or none for a global role.
1255
+ * `digests` pins the bundle each role was checked against; a client whose
1256
+ * bundle differs resolves nothing for that role.
1257
+ */
1258
+ type SnapshotStatic = {
1259
+ readonly held: readonly (readonly [string, number | null])[];
1260
+ readonly digests: Readonly<Record<string, string>>;
1261
+ };
1262
+ /**
1263
+ * The static grants of declared roles, written once per policy by
1264
+ * `clientBundle(policy)` and shipped as a cached script instead of in every
1265
+ * snapshot. A role's grants are what a holder of only that role receives.
1266
+ */
1267
+ type ClientBundle = {
1268
+ readonly v: 1;
1269
+ readonly conditions: readonly SnapshotGrantTerms[];
1270
+ readonly roles: Readonly<Record<string, {
1271
+ readonly digest: string;
1272
+ readonly grants: readonly {
1273
+ readonly permission: string;
1274
+ readonly cond: number | readonly number[];
1275
+ }[];
1276
+ }>>;
1277
+ };
1278
+ /** The permission keys a rowless check grants or sends to an approver. */
1279
+ type SnapshotTypeLevel = {
1280
+ readonly granted: readonly string[];
1281
+ readonly approval?: readonly string[];
1282
+ /** Keys whose rowless answer needs the evaluations endpoint. */
1283
+ readonly endpoint?: readonly string[];
1284
+ };
1285
+ /**
1286
+ * A grant the subject would hold on another plan: its permission, role and
1287
+ * `to`.
1288
+ */
1289
+ type SnapshotNotEntitled = {
1290
+ readonly permission: string;
1291
+ readonly role: string | null;
1292
+ readonly to: Grantee | readonly Grantee[];
1293
+ };
1294
+ /** One declared scope as a snapshot carries it. */
1295
+ type SnapshotScope = {
1296
+ readonly name: string;
1297
+ readonly key: string;
1298
+ readonly within?: string;
1299
+ /**
1300
+ * Resources whose rows this scope's key partitions, from their `memberOf`
1301
+ * relations.
1302
+ */
1303
+ readonly resources?: readonly string[];
1304
+ /**
1305
+ * Resource name to the field holding this scope's id, for a resource whose
1306
+ * field is not `key` (its own `id`).
1307
+ */
1308
+ readonly fields?: Readonly<Record<string, string>>;
1309
+ };
1310
+ /**
1311
+ * The declared roles and the custom-role ceiling the subject may assign in one
1312
+ * tenant.
1313
+ */
1314
+ type SnapshotAssignable = {
1315
+ readonly tenant: string;
1316
+ readonly roles: readonly string[];
1317
+ readonly permissions: readonly Permission[];
1318
+ /**
1319
+ * Permission key to the levels the subject may hand out; only permissions
1320
+ * whose resource declares levels.
1321
+ */
1322
+ readonly levels?: Readonly<Record<string, readonly string[]>>;
1323
+ };
1324
+ type SnapshotGrant = {
1325
+ readonly permission: string;
1326
+ readonly effect: "allow" | "deny";
1327
+ readonly role: string | null;
1328
+ readonly to: Grantee | readonly Grantee[];
1329
+ readonly where?: Condition;
1330
+ readonly check?: Condition;
1331
+ readonly approval?: "human" | ApprovalRequirement;
1332
+ /** A scope name or one resource; absent for a global grant. */
1333
+ readonly scope?: string | {
1334
+ readonly resource: string;
1335
+ };
1336
+ readonly membership?: Membership;
1337
+ readonly portable?: false;
1338
+ readonly fields?: readonly string[];
1339
+ /**
1340
+ * When the grant applies (RFC 3339, `from` inclusive, `until` exclusive);
1341
+ * absent means always.
1342
+ */
1343
+ readonly validity?: WireValidity;
1344
+ /** The grant's declared `name`. */
1345
+ readonly name?: string;
1346
+ /** The grant's declared `meta`; visible to the client that holds the snapshot. */
1347
+ readonly meta?: GrantMeta;
1348
+ /** The app obligations an allow declares, emitted on a granted decision. */
1349
+ readonly obligations?: readonly AppObligation[];
1350
+ };
1351
+ /**
1352
+ * What a policy grants, as JSON a client builds snapshots from without the
1353
+ * policy: `localSnapshotManifest(policy)` writes it, `localSnapshot` in
1354
+ * `permdock/react-native` reads it.
1355
+ */
1356
+ type LocalSnapshotManifest = {
1357
+ readonly v: 1;
1358
+ readonly scopes?: readonly SnapshotScope[];
1359
+ readonly vocabulary?: ExpandedSnapshot["vocabulary"];
1360
+ /** Declared role names; a custom role cannot take one. */
1361
+ readonly roles: readonly string[];
1362
+ /** Declared role names in rank order, when an `assigns` graph ranks them. */
1363
+ readonly rank?: readonly string[];
1364
+ /** Every declared grant, without a membership. */
1365
+ readonly grants: readonly SnapshotGrant[];
1366
+ /**
1367
+ * Per custom-role scope (`global` for platform roles): the grants each entry
1368
+ * resolves to.
1369
+ */
1370
+ readonly custom: Readonly<Record<string, LocalCustomRoleTable>>;
1371
+ /**
1372
+ * The synced tables a device reads the user's memberships, roles and custom
1373
+ * roles from; `permdock powersync generate` adds it.
1374
+ */
1375
+ readonly rows?: LocalSnapshotRows;
1376
+ /**
1377
+ * What a device needs to compute `Snapshot.assignable` for the active tenant
1378
+ * the way `assignableIn` does on the server.
1379
+ */
1380
+ readonly assignable?: LocalAssignable;
1381
+ };
1382
+ /**
1383
+ * The hand-out rules of a policy, as a device evaluates them over its synced
1384
+ * memberships and custom roles.
1385
+ */
1386
+ type LocalAssignable = {
1387
+ /**
1388
+ * Declared roles a tenant admin may hand out or compose, in rank order, with
1389
+ * the scope each sits on and its allow keys.
1390
+ */
1391
+ readonly roles: readonly {
1392
+ readonly name: string;
1393
+ readonly on: string;
1394
+ readonly allows: readonly string[];
1395
+ }[];
1396
+ /** Declared role names and permission keys with `meta.manageRoles: true`. */
1397
+ readonly manage: {
1398
+ readonly roles: readonly string[];
1399
+ readonly permissions: readonly string[];
1400
+ };
1401
+ /**
1402
+ * Declared role name to the roles it assigns, when any role declares
1403
+ * `assigns`.
1404
+ */
1405
+ readonly assigns?: Readonly<Record<string, readonly string[]>>;
1406
+ /** The first scope's custom-role ceiling, in declaration order. */
1407
+ readonly permissions: readonly Permission[];
1408
+ /** Permission key to its level names, in declaration order. */
1409
+ readonly levels?: Readonly<Record<string, readonly string[]>>;
1410
+ /** Index of an allow in `grants` to the levels a holder of it may hand out. */
1411
+ readonly grants?: Readonly<Record<string, readonly string[]>>;
1412
+ };
1413
+ /** A column of a synced table, or a value every row has. */
1414
+ type LocalRowValue = {
1415
+ readonly column: string;
1416
+ } | {
1417
+ readonly value: string;
1418
+ };
1419
+ /**
1420
+ * A column that holds a role key or user id: the value itself, the `column` of
1421
+ * the synced `through` table whose `id` it references, or a value each maps to
1422
+ * a role key (`null` for no role). A composite reference lists every pair in
1423
+ * `on` (row column to `through` column); a `through` row matches only when all
1424
+ * of them do, and the row holds the value of every match.
1425
+ */
1426
+ type LocalRowColumn = {
1427
+ readonly column: string;
1428
+ } | {
1429
+ readonly column: string;
1430
+ readonly through: {
1431
+ readonly table: string;
1432
+ readonly id: string;
1433
+ readonly column: string;
1434
+ readonly on?: Readonly<Record<string, string>>;
1435
+ };
1436
+ } | {
1437
+ readonly column: string;
1438
+ readonly map: Readonly<Record<string, string | null>>;
1439
+ };
1440
+ /** One synced membership table. Table names are the device's table names. */
1441
+ type LocalMembershipRows = {
1442
+ readonly table: string;
1443
+ readonly user: LocalRowColumn;
1444
+ readonly scope: LocalRowValue;
1445
+ readonly id: string;
1446
+ /**
1447
+ * The role columns (the row holds every non-null key), or the fixed roles
1448
+ * every row holds.
1449
+ */
1450
+ readonly roles: readonly LocalRowColumn[] | {
1451
+ readonly value: readonly string[];
1452
+ };
1453
+ readonly via?: LocalRowValue;
1454
+ /** A row with a value in one of these columns is no membership on the device. */
1455
+ readonly expiresAt?: string;
1456
+ readonly disabledAt?: string;
1457
+ };
1458
+ type LocalSnapshotRows = {
1459
+ readonly memberships: readonly LocalMembershipRows[];
1460
+ /** The global roles table: one row per user and role. */
1461
+ readonly roles?: {
1462
+ readonly table: string;
1463
+ readonly user: string;
1464
+ /** The role columns; the row holds every non-null key. */
1465
+ readonly roles: readonly LocalRowColumn[];
1466
+ };
1467
+ /**
1468
+ * The custom-role tables (`tenant_id`, `scope`, `scope_id`, `role`, and
1469
+ * `permission`, `effect`, `level` or `include_role`).
1470
+ */
1471
+ readonly customRoles?: {
1472
+ readonly permissions: string;
1473
+ readonly includes: string;
1474
+ };
1475
+ /**
1476
+ * The user's authorization version row (`permdock_authz_version`), the value
1477
+ * the token hook stamps `authz_ver` from.
1478
+ */
1479
+ readonly version?: {
1480
+ readonly table: string;
1481
+ readonly user: string;
1482
+ readonly version: string;
1483
+ };
1484
+ };
1485
+ /**
1486
+ * Grants a custom role entry resolves to, held by a placeholder role the client
1487
+ * renames.
1488
+ */
1489
+ type LocalCustomRoleTable = {
1490
+ /**
1491
+ * `{ permission }` per permission key, and `{ permission, level }` per
1492
+ * declared level.
1493
+ */
1494
+ readonly permissions: Readonly<Record<string, {
1495
+ readonly all: readonly SnapshotGrant[];
1496
+ readonly levels?: Readonly<Record<string, readonly SnapshotGrant[]>>;
1497
+ /** The levels a holder of `all` may hand out. */
1498
+ readonly reach?: readonly string[];
1499
+ /** Level to the levels a holder of `levels[level]` may hand out. */
1500
+ readonly levelReach?: Readonly<Record<string, readonly string[]>>;
1501
+ }>>;
1502
+ /** `includes: [role]` per declared role. */
1503
+ readonly includes: Readonly<Record<string, readonly SnapshotGrant[]>>;
1504
+ /**
1505
+ * Declared role to permission key to the levels a holder of its included
1506
+ * grants may hand out.
1507
+ */
1508
+ readonly includeReach?: Readonly<Record<string, Readonly<Record<string, readonly string[]>>>>;
1509
+ };
1510
+ /**
1511
+ * The one time rule: NumericDate (whole seconds) for JWT registered claims and
1512
+ * the claims SQL reads, RFC 3339 for every other JSON field, integer seconds
1513
+ * for durations, and an `Instant` for every runtime `now`.
1514
+ */
1515
+ /**
1516
+ * The part of a `Temporal.Instant` PermDock reads. Public options take it
1517
+ * structurally so their declarations compile under a TypeScript lib without
1518
+ * `Temporal` (5.9); every `Temporal.Instant` satisfies it.
1519
+ */
1520
+ type Instant = {
1521
+ readonly epochMilliseconds: number;
1522
+ };
1523
+ /**
1524
+ * Any instance a feature function accepts: a server `PermDock`, one built from
1525
+ * a snapshot, or an adapter's wrapper such as `PdpPermDock`.
1526
+ */
1527
+ type InstanceHandle = {
1528
+ readonly subject: Subject;
1529
+ };
1530
+ type CredentialKind = "user" | "service" | "feed";
1531
+ /**
1532
+ * A feed id: lowercase, so a mail system that lowercases a local part still
1533
+ * matches. At most 16 characters, so `pdfeed_<id>_<secret>` fits an email local
1534
+ * part.
1535
+ */
1536
+ declare function isFeedId(value: string): boolean;
1537
+ /**
1538
+ * One permission (a key) a credential may use: on every instance, or only on
1539
+ * `ids`.
1540
+ */
1541
+ type CredentialPermission = {
1542
+ readonly permission: string;
1543
+ readonly ids?: readonly string[];
1544
+ };
1545
+ /**
1546
+ * Credential v1: what a verified API key stands for, never the secret. A `user`
1547
+ * credential acts as its owner (`principal`) narrowed to `permissions`, and to
1548
+ * the memberships inside `tenant` when it names one; a `service` credential is
1549
+ * its own `service` principal holding `roles` in `tenant`, narrowed the same
1550
+ * way.
1551
+ */
1552
+ type Credential = {
1553
+ readonly v: 1;
1554
+ readonly id: string;
1555
+ readonly kind: CredentialKind;
1556
+ /** The owner of a `user` credential, or the id of the service principal. */
1557
+ readonly principal: string;
1558
+ /**
1559
+ * The instance of the first scope the key is held to. Required on a service
1560
+ * credential, where its roles are held; optional on a user credential, where
1561
+ * it keeps only the owner's memberships inside it.
1562
+ */
1563
+ readonly tenant?: string;
1564
+ /**
1565
+ * Service: the roles it holds in `tenant`. Feed: the resource roles it holds
1566
+ * on `on`.
1567
+ */
1568
+ readonly roles?: readonly string[];
1569
+ /** Feed only: the resource instance the roles are held on. */
1570
+ readonly on?: {
1571
+ readonly resource: string;
1572
+ readonly id: string;
1573
+ };
1574
+ readonly permissions: readonly CredentialPermission[];
1575
+ readonly createdBy: string;
1576
+ /** RFC 3339. */
1577
+ readonly createdAt: string;
1578
+ /** RFC 3339; absent only where a credential policy allows it. */
1579
+ readonly expiresAt?: string;
1580
+ readonly name?: string;
1581
+ };
1582
+ type ApiKeyPrincipal = Principal & {
1583
+ readonly credential: Credential;
1584
+ };
1585
+ /**
1586
+ * What one scope instance allows for API keys created in it. Every rule only
1587
+ * tightens; several policies must all hold.
1588
+ */
1589
+ type CredentialPolicy = {
1590
+ /** Longest a key may live, in seconds from `createdAt`. */
1591
+ readonly maxTtl?: number;
1592
+ /** Kinds that may be created. */
1593
+ readonly kinds?: readonly CredentialKind[];
1594
+ /** Creating a key is `approval-required`. */
1595
+ readonly approval?: boolean;
1596
+ /** A key may omit `expiresAt`; without it every key must expire. */
1597
+ readonly allowNoExpiry?: boolean;
1598
+ };
1599
+ type CredentialPolicyViolation = "kind" | "no-expiry" | "ttl";
1600
+ type CredentialPermissionInput = Permission | {
1601
+ readonly permission: Permission;
1602
+ readonly ids: readonly string[];
1603
+ };
1604
+ type CredentialRequestBase = {
1605
+ readonly id: string;
1606
+ readonly permissions: readonly CredentialPermissionInput[];
1607
+ /** RFC 3339; must be after `now`. */
1608
+ readonly expiresAt?: string;
1609
+ readonly name?: string;
1610
+ };
1611
+ type CredentialRequest = (CredentialRequestBase & {
1612
+ readonly kind: "user";
1613
+ /** Holds the key to the creator's memberships inside this tenant. */
1614
+ readonly tenant?: string;
1615
+ }) | (CredentialRequestBase & {
1616
+ readonly kind: "service";
1617
+ /** The service principal's id; defaults to the credential id. */
1618
+ readonly principal?: string;
1619
+ readonly tenant: string;
1620
+ readonly roles: readonly string[];
1621
+ }) | (CredentialRequestBase & {
1622
+ readonly kind: "feed";
1623
+ readonly on: {
1624
+ readonly resource: Permission | PermissionTree;
1625
+ readonly id: string;
1626
+ };
1627
+ readonly roles: readonly string[];
1628
+ /** A row the server loaded. Each permission must be granted on it. */
1629
+ readonly row: unknown;
1630
+ });
1631
+ type CredentialDecision = {
1632
+ readonly outcome: "granted";
1633
+ readonly credential: Credential;
1634
+ } | {
1635
+ readonly outcome: "approval-required";
1636
+ readonly credential: Credential;
1637
+ /**
1638
+ * Bound to the credential's content and its creator; pass it as
1639
+ * `approved` to resume.
1640
+ */
1641
+ readonly token: string;
1642
+ } | {
1643
+ readonly outcome: "denied";
1644
+ readonly denials: readonly Denial[];
1645
+ };
1646
+ type DecideCredentialOptions = {
1647
+ /**
1648
+ * Where the tenant's `credentials` policy comes from. Without it, only the
1649
+ * no-expiry rule applies.
1650
+ */
1651
+ readonly settings?: SettingsSource;
1652
+ /** The `token` of an approval the application consumed for this request. */
1653
+ readonly approved?: string;
1654
+ /** The creation time; defaults to the clock. */
1655
+ readonly now?: Instant;
1656
+ };
1657
+ /**
1658
+ * The first rule of `policy` the credential breaks, or `undefined`. A key
1659
+ * without `expiresAt` passes only when some policy sets `allowNoExpiry` and
1660
+ * none sets `maxTtl`; an empty list therefore refuses it.
1661
+ */
1662
+ declare function credentialPolicyViolation(credential: Credential, policy: CredentialPolicy | readonly CredentialPolicy[]): CredentialPolicyViolation | undefined;
1663
+ /**
1664
+ * Validates an untrusted credential record and returns a frozen copy with only
1665
+ * the v1 fields, or `undefined`. Unknown fields are dropped; a wrong type in a
1666
+ * known field, a service credential without `tenant` and `roles`, or a user
1667
+ * credential with `roles`, rejects the whole record.
1668
+ */
1669
+ declare function parseCredential(input: unknown): Credential | undefined;
1670
+ /**
1671
+ * The delegation a credential narrows its principal to: OAuth scopes for
1672
+ * permissions on every instance, one RFC 9396 entry per id otherwise. A key the
1673
+ * definitions no longer declare is dropped, so a credential whose every key is
1674
+ * gone delegates nothing and every check is denied.
1675
+ */
1676
+ declare function credentialDelegation(credential: Credential, permissions: PermissionTree): Delegation;
1677
+ /**
1678
+ * Decides whether the subject of `permdock` may create the credential in
1679
+ * `request`. The creator must be a signed-in user or service that is not itself
1680
+ * a link or a credential; a delegated creator hands out only what its
1681
+ * delegation covers. A key's tenant must be one the creator is a member of; a
1682
+ * service key's roles among the creator's `assignableRoles` there and its
1683
+ * permissions within `assignablePermissions` there (`exceeds-creator`). The
1684
+ * `credentials` policy of the key's tenant (its own, or for a user key without
1685
+ * one the creator's active tenant) then applies (`credential-policy`; a
1686
+ * settings source that throws denies with `rule: 'unavailable'`), and
1687
+ * `approval` makes the result `approval-required` until `approved` carries its
1688
+ * token. PermDock never stores the credential; the application does, after a
1689
+ * `granted` result.
1690
+ */
1691
+ /**
1692
+ * Decides whether the subject of `permdock` may create the credential in
1693
+ * `request`: the creator's own reach, the `credentials` policy of the key's
1694
+ * tenant (the call's `settings`, else the instance's), and `approval`. PermDock
1695
+ * never stores the credential; the application does, after a `granted` result.
1696
+ * An instance built from a snapshot denies with `unsupported`.
1697
+ */
1698
+ declare function decideCredential(permdock: InstanceHandle, request: CredentialRequest, options?: DecideCredentialOptions): Promise<CredentialDecision>;
1699
+ /**
1700
+ * SupportSession v1: a support staff member (`actor`, kind `support`) viewing
1701
+ * the app as `principal` in `tenant`, for a stated `reason`. Each request in
1702
+ * the session acts as `principal` with their live rights, narrowed to
1703
+ * `permissions`.
1704
+ */
1705
+ type SupportSession = {
1706
+ readonly v: 1;
1707
+ readonly id: string;
1708
+ /** The person the session views the app as. */
1709
+ readonly principal: string;
1710
+ /** The support staff member running the session. */
1711
+ readonly actor: string;
1712
+ readonly tenant: string;
1713
+ readonly reason: string;
1714
+ /** The delegation: permission keys, read-only unless listed on purpose. */
1715
+ readonly permissions: readonly string[];
1716
+ /** RFC 3339. */
1717
+ readonly startedAt: string;
1718
+ /** RFC 3339. */
1719
+ readonly expiresAt: string;
1720
+ /** Who approved the session; never `actor`. */
1721
+ readonly approvedBy?: string;
1722
+ /** The application's ticket or case id. */
1723
+ readonly reference?: string;
1724
+ };
1725
+ /** A tenant's rules for support sessions. Every field only tightens. */
1726
+ type SupportSessionPolicy = {
1727
+ /** No session may start in this tenant. */
1728
+ readonly disabled?: boolean;
1729
+ /** Longest a session may last, in seconds. */
1730
+ readonly maxTtl?: number;
1731
+ /** Only `readOnlyHint` permissions, whatever the request lists. */
1732
+ readonly readOnly?: boolean;
1733
+ };
1734
+ type SupportSessionRequest = {
1735
+ readonly id: string;
1736
+ /** The person to view the app as. */
1737
+ readonly principal: string;
1738
+ /** Defaults to the actor's active tenant. */
1739
+ readonly tenant?: string;
1740
+ /** Required: why the session is needed. */
1741
+ readonly reason: string;
1742
+ /** Defaults to every `readOnlyHint` permission the actor can use. */
1743
+ readonly permissions?: readonly Permission[];
1744
+ /** Seconds the session lasts. Defaults to 3600; at most 86400. */
1745
+ readonly expiresIn?: number;
1746
+ readonly reference?: string;
1747
+ };
1748
+ type SupportSessionDecision = {
1749
+ readonly outcome: "granted";
1750
+ readonly session: SupportSession;
1751
+ } | {
1752
+ readonly outcome: "approval-required";
1753
+ readonly session: SupportSession;
1754
+ /** Bound to the request and the actor; pass it as `approved` to resume. */
1755
+ readonly token: string;
1756
+ } | {
1757
+ readonly outcome: "denied";
1758
+ readonly denials: readonly Denial[];
1759
+ };
1760
+ type DecideSupportSessionOptions = {
1761
+ /** Where the tenant's `supportSessions` policy comes from. */
1762
+ readonly settings?: SettingsSource;
1763
+ /** Approval is required unless this is `false`. */
1764
+ readonly approval?: boolean;
1765
+ /** The `token` of an approval the application consumed for this request. */
1766
+ readonly approved?: string;
1767
+ /**
1768
+ * The principal id that approved; required with `approved` and never the
1769
+ * actor.
1770
+ */
1771
+ readonly approvedBy?: string;
1772
+ /** The start time; defaults to the clock. */
1773
+ readonly now?: Instant;
1774
+ };
1775
+ /**
1776
+ * Validates an untrusted support-session record and returns a frozen copy with
1777
+ * only the v1 fields, or `undefined`.
1778
+ */
1779
+ declare function parseSupportSession(input: unknown): SupportSession | undefined;
1780
+ /**
1781
+ * Decides whether the subject of `permdock` may start the support session in
1782
+ * `request`. The actor must be a signed-in person acting for themselves
1783
+ * (`exceeds-creator` otherwise), give a `reason` (`reason-required`), be a
1784
+ * member of the tenant (`tenant-mismatch`) and be able to use every permission
1785
+ * (`exceeds-creator`). Without `permissions` the session gets the actor's
1786
+ * read-only permissions. The tenant's `supportSessions` policy then applies,
1787
+ * and the result is `approval-required` until `approved` carries its token and
1788
+ * `approvedBy` names someone other than the actor.
1789
+ */
1790
+ /**
1791
+ * Decides whether the subject of `permdock` may start the support session in
1792
+ * `request` and returns the record to sign: a stated reason, membership of the
1793
+ * tenant, the actor's own reach, the tenant's `supportSessions` policy and
1794
+ * approval by someone else. An instance built from a snapshot denies with
1795
+ * `unsupported`.
1796
+ */
1797
+ declare function decideSupportSession(permdock: InstanceHandle, request: SupportSessionRequest, options?: DecideSupportSessionOptions): Promise<SupportSessionDecision>;
1798
+ type DecisionProvider = {
1799
+ readonly name: string;
1800
+ handles: (permission: Permission) => boolean;
1801
+ decide: (request: {
1802
+ readonly permission: Permission;
1803
+ readonly data?: unknown;
1804
+ readonly subject: Subject;
1805
+ readonly local: Decision;
1806
+ }) => Promise<Decision>;
1807
+ /**
1808
+ * Ids of the resources of `permission.resource` the subject may act on.
1809
+ * `null` means the provider could not answer and every row is denied;
1810
+ * `undefined` means it cannot list, and each row is decided on its own.
1811
+ */
1812
+ permitted?: (request: {
1813
+ readonly permission: Permission;
1814
+ readonly subject: Subject;
1815
+ }) => Promise<readonly string[] | null | undefined>;
1816
+ };
1817
+ /**
1818
+ * Shares one read per key within one `getPermDock` call: the first call runs
1819
+ * `read`, every later call with the same key gets its answer. A source created
1820
+ * once at module scope uses it so the reads of one instance share a single
1821
+ * query and no answer outlives the instance.
1822
+ */
1823
+ type SourceMemo = (<T>(key: string, read: () => T) => T) & {
1824
+ /**
1825
+ * The authorization version the instance was told it already holds
1826
+ * (`version.known`). A source that caches records by version answers from it
1827
+ * without reading the version.
1828
+ */
1829
+ readonly version?: number;
1830
+ };
1831
+ /**
1832
+ * One read a source made, for an `onSourceCall` hook: `cached` is `true` when
1833
+ * the instance's `SourceMemo` answered it without a query.
1834
+ */
1835
+ type SourceCall = {
1836
+ readonly source: string;
1837
+ readonly method: string;
1838
+ readonly durationMs: number;
1839
+ readonly cached: boolean;
1840
+ };
1841
+ /** What `getPermDock` passes to every source call besides its query. */
1842
+ type SourceContext = {
1843
+ /** Absent when the source is called outside `getPermDock`. */
1844
+ readonly memo?: SourceMemo;
1845
+ };
1846
+ /**
1847
+ * Whether an instance answers reads or writes: `read` may judge a token fresh
1848
+ * from a shared `VersionCache` within its `maxStaleMs`; `write` reads the
1849
+ * version live.
1850
+ */
1851
+ type Intent = "read" | "write";
1852
+ /** The custom-role sources' second argument. */
1853
+ type CustomRoleContext = SourceContext & {
1854
+ readonly held: readonly string[];
1855
+ };
1856
+ type CustomRoleSource = {
1857
+ /** Names the implementation in errors and events. */
1858
+ readonly name?: string;
1859
+ /**
1860
+ * The custom roles of one tenant. `getPermDock` passes `held`, the role names
1861
+ * the subject's live memberships hold there, declared or not, so a source can
1862
+ * skip its read when none of them is a custom role.
1863
+ */
1864
+ rolesFor: (tenant: string, context?: CustomRoleContext) => CustomRole[] | Promise<CustomRole[]>;
1865
+ assignable?: (tenant: string) => string[] | Promise<string[]>;
1866
+ /**
1867
+ * Platform custom roles (`scope: 'global'`), read once per signed-in subject,
1868
+ * with `held`, the global role names the subject holds. A role here with a
1869
+ * tenant is ignored.
1870
+ */
1871
+ globalRoles?: (context?: CustomRoleContext) => CustomRole[] | Promise<CustomRole[]>;
1872
+ /**
1873
+ * Shared custom roles (`shared: true`), defined once for every tenant and
1874
+ * read once per subject with a tenant membership, with `held`, the role names
1875
+ * its live memberships hold in any tenant. A role here without `shared: true`
1876
+ * is ignored.
1877
+ */
1878
+ sharedRoles?: (context?: CustomRoleContext) => CustomRole[] | Promise<CustomRole[]>;
1879
+ };
1880
+ /**
1881
+ * A `CustomRoleSource` built for the subject the instance serves, for an
1882
+ * adapter option shared by every request: it gets the resolved subject
1883
+ * (principal, actor and delegation) and returns that subject's source, or
1884
+ * `undefined` for none. A throw reads no custom roles and reports
1885
+ * `source-threw`.
1886
+ */
1887
+ type CustomRoleSourceFactory = (subject: Subject) => CustomRoleSource | undefined;
1888
+ /**
1889
+ * The principal `MembershipSource.version` is asked about: what its token
1890
+ * claims.
1891
+ */
1892
+ type VersionQuery = {
1893
+ readonly id: string;
1894
+ readonly roles?: readonly string[];
1895
+ readonly memberships?: readonly Membership[];
1896
+ readonly authzVersion?: number;
1897
+ /** The custom-role version the token claims for its active tenant. */
1898
+ readonly customRolesVersion?: number;
1899
+ /** When the token was issued, in seconds since the epoch (`iat`). */
1900
+ readonly issuedAt?: number;
1901
+ };
1902
+ /** `MembershipSource.version`'s second argument. */
1903
+ type VersionContext = SourceContext & {
1904
+ /** Absent outside `getPermDock`, where the read is live. */
1905
+ readonly intent?: Intent;
1906
+ };
1907
+ /** One member of a scope instance, as `MembershipSource.list` returns it. */
1908
+ type MemberEntry = {
1909
+ readonly principal: {
1910
+ readonly id: string;
1911
+ };
1912
+ readonly membership: Membership;
1913
+ };
1914
+ type MembershipSource = {
1915
+ /** Names the implementation in errors and events. */
1916
+ readonly name?: string;
1917
+ membershipsFor: (principal: {
1918
+ readonly id: string;
1919
+ readonly kind?: string;
1920
+ }, options: SourceContext & {
1921
+ readonly tenant?: string;
1922
+ }) => Membership[] | Promise<Membership[]>;
1923
+ /**
1924
+ * Every membership held in one scope instance, for member lists and access
1925
+ * reviews.
1926
+ */
1927
+ list?: (query: {
1928
+ readonly scope: string;
1929
+ readonly id: string;
1930
+ }) => MemberEntry[] | Promise<MemberEntry[]>;
1931
+ /**
1932
+ * The custom-role version of one tenant, raised by every edit of a custom
1933
+ * role in it (and of a shared or platform role). A token that holds a custom
1934
+ * role is current while its `customRolesVersion` has reached this and its
1935
+ * `authzVersion` has reached `version`; without this method, or without the
1936
+ * claim, such a token is read live. `undefined` when the version cannot be
1937
+ * read.
1938
+ */
1939
+ customRolesVersion?: (query: {
1940
+ readonly id: string;
1941
+ readonly tenant: string;
1942
+ }, context?: VersionContext) => number | undefined | Promise<number | undefined>;
1943
+ /**
1944
+ * The principal's current authorization version, bumped on every membership
1945
+ * change. A token whose `authzVersion` is behind it is stale for the policy's
1946
+ * `fresh` permissions. `roles` and `memberships` are what the token claims,
1947
+ * so a source can read more than the version in the same call when the claims
1948
+ * show it will be needed. `authzVersion` and `issuedAt` (seconds) are the
1949
+ * token's, for a `VersionCache`.
1950
+ */
1951
+ version?: (principal: VersionQuery, context?: VersionContext) => number | undefined | Promise<number | undefined>;
1952
+ /**
1953
+ * The global roles the principal holds now. With `onStale: 'reread'`, a stale
1954
+ * token's `principal.roles` is replaced by this answer, so a revoked platform
1955
+ * role is lost with the memberships. A throw or rejection leaves no global
1956
+ * roles. Without it, a reread keeps the token's roles.
1957
+ */
1958
+ globalRolesFor?: (principal: {
1959
+ readonly id: string;
1960
+ readonly kind?: string;
1961
+ }, context?: SourceContext) => readonly string[] | Promise<readonly string[]>;
1962
+ /**
1963
+ * Keep the memberships the verified token carries and read this source only
1964
+ * when the token says they were truncated (`claimsFirst`).
1965
+ */
1966
+ readonly claimsFirst?: boolean;
1967
+ /**
1968
+ * What a token behind `version` gets. Only permissions the policy marks
1969
+ * `fresh` look at staleness: `'deny'` (the default) denies those with
1970
+ * `stale-credentials` and leaves every other permission on the token's
1971
+ * claims; `'reread'` replaces the token's memberships (and global roles, when
1972
+ * the source has `globalRolesFor`) with a live read for the whole subject, so
1973
+ * no decision keeps a revoked grant.
1974
+ */
1975
+ readonly onStale?: "deny" | "reread";
1976
+ };
1977
+ /** An object's parent chain, as `RelationSource.ancestors` returns it. */
1978
+ type RelationChain = {
1979
+ /** Whether the object itself is restricted: nothing above it reaches it. */
1980
+ readonly restricted?: boolean;
1981
+ /**
1982
+ * Ancestors nearest first, at most `depth`; a restricted one ends the walk
1983
+ * after itself.
1984
+ */
1985
+ readonly ancestors: readonly {
1986
+ readonly id: string;
1987
+ readonly restricted?: boolean;
1988
+ }[];
1989
+ /** The chain goes on above the last entry. */
1990
+ readonly truncated?: boolean;
1991
+ };
1992
+ type HolderPeriod = {
1993
+ /** Seconds since the epoch; before it the relation does not hold yet. */
1994
+ readonly startsAt?: number;
1995
+ /** Seconds since the epoch; from it on the relation no longer holds. */
1996
+ readonly expiresAt?: number;
1997
+ };
1998
+ /**
1999
+ * A group holding a relation on an object: whoever holds `relation` on the
2000
+ * group's instance holds it too.
2001
+ */
2002
+ type RelationGroup = {
2003
+ readonly resource: string;
2004
+ readonly id: string;
2005
+ readonly relation: string;
2006
+ };
2007
+ /**
2008
+ * One holder of a relation on an object, as `RelationSource.related` returns
2009
+ * it: a principal, or a group (an edge row whose `groups` column names one).
2010
+ */
2011
+ type RelationHolder = HolderPeriod & ({
2012
+ readonly principal: {
2013
+ readonly id: string;
2014
+ };
2015
+ } | {
2016
+ readonly group: RelationGroup;
2017
+ });
2018
+ /**
2019
+ * The object graph: parent chains, links and who holds a relation on an object.
2020
+ * A source answers facts and never decides; a thrown or rejected call, or a
2021
+ * Promise the instance has not loaded, denies with `relation-unavailable`.
2022
+ */
2023
+ type RelationSource = {
2024
+ /** Names the implementation in errors and events. */
2025
+ readonly name?: string;
2026
+ /**
2027
+ * With `through: 'parent'`, the parent chain; with a link name, the one
2028
+ * instance that link points to (`depth` is then 1).
2029
+ */
2030
+ ancestors: (query: {
2031
+ readonly resource: string;
2032
+ readonly id: string;
2033
+ readonly through: string;
2034
+ readonly depth: number;
2035
+ }) => RelationChain | Promise<RelationChain>;
2036
+ related: (query: {
2037
+ readonly resource: string;
2038
+ readonly id: string;
2039
+ readonly relation: string;
2040
+ }) => RelationHolder[] | Promise<RelationHolder[]>;
2041
+ row?: (query: {
2042
+ readonly resource: string;
2043
+ readonly id: string;
2044
+ }) => Readonly<Record<string, unknown>> | null | undefined | Promise<Readonly<Record<string, unknown>> | null | undefined>;
2045
+ };
2046
+ /**
2047
+ * Plan and seat names a principal holds in a tenant, from billing (Stripe
2048
+ * Entitlements, a table).
2049
+ */
2050
+ type EntitlementSource = {
2051
+ /** Names the implementation in errors and events. */
2052
+ readonly name?: string;
2053
+ entitlementsFor: (principal: {
2054
+ readonly id: string;
2055
+ }, options: {
2056
+ readonly tenant?: string;
2057
+ }) => string[] | Promise<string[]>;
2058
+ };
2059
+ type JwtClaims = {
2060
+ readonly iss?: string;
2061
+ readonly sub?: string;
2062
+ readonly aud?: string | readonly string[];
2063
+ readonly exp?: number;
2064
+ readonly nbf?: number;
2065
+ readonly iat?: number;
2066
+ readonly [key: string]: unknown;
2067
+ };
2068
+ type TokenFailureCause = "invalid-signature" | "expired" | "not-yet-valid" | "wrong-audience" | "wrong-issuer" | "wrong-token-type" | "alg-not-allowed" | "alg-none" | "unknown-kid" | "malformed" | "encrypted-token" | "dpop-proof-invalid" | "mtls-binding-mismatch" | "sender-constraint-required" | "token-in-query" | "invalid-claims" | "invalid-chain" | "jwks-unavailable" | "discovery-unavailable" | "discovery-mismatch";
2069
+ type VerifiedToken<TClaims extends JwtClaims = JwtClaims> = {
2070
+ readonly ok: true;
2071
+ readonly claims: TClaims;
2072
+ readonly header: {
2073
+ readonly alg: string;
2074
+ readonly kid?: string;
2075
+ readonly typ?: string;
2076
+ };
2077
+ };
2078
+ type VerificationFailure = {
2079
+ readonly ok: false;
2080
+ readonly reason: "invalid-token";
2081
+ readonly cause: TokenFailureCause;
2082
+ };
2083
+ type TokenVerifier<TClaims extends JwtClaims = JwtClaims> = {
2084
+ /** Names the implementation in errors and events. */
2085
+ readonly name?: string;
2086
+ verify: (token: string, expectations: {
2087
+ readonly typ?: string | readonly string[];
2088
+ readonly audience?: string | readonly string[];
2089
+ readonly issuer?: string;
2090
+ readonly clockTolerance?: number;
2091
+ }) => Promise<VerifiedToken<TClaims> | VerificationFailure>;
2092
+ };
2093
+ type TokenSigner = {
2094
+ /** Names the implementation in errors and events. */
2095
+ readonly name?: string;
2096
+ sign: (payload: Readonly<Record<string, unknown>>, options: {
2097
+ readonly typ: "vnd.permdock.snapshot+jwt" | "vnd.permdock.approval+jwt" | "vnd.permdock.policy+jwt" | "vnd.permdock.capability+jwt" | "vnd.permdock.run+jwt" | "vnd.permdock.support-session+jwt" | "vnd.permdock.evidence+jwt" | "at+jwt" | "secevent+jwt";
2098
+ /** `aud`; a signer with no default audience refuses to sign without one. */
2099
+ readonly audience?: string | readonly string[];
2100
+ /** `exp`, a NumericDate; one hour after `iat` when absent. */
2101
+ readonly expiresAt?: number;
2102
+ /**
2103
+ * `iat`, a NumericDate: the artefact's issue time. The signer's clock
2104
+ * when absent.
2105
+ */
2106
+ readonly issuedAt?: number;
2107
+ /** `jti`: the artefact's id. A fresh UUID when absent. */
2108
+ readonly jti?: string;
2109
+ }) => Promise<string>;
2110
+ readonly kid?: string;
2111
+ jwks?: () => Promise<{
2112
+ readonly keys: readonly JsonWebKeyLike[];
2113
+ }>;
2114
+ };
2115
+ type SubjectResolver<TInput, TPrincipal extends Principal = Principal> = (input: TInput, options?: {
2116
+ readonly tenant?: string;
2117
+ }) => Subject<TPrincipal> | Promise<Subject<TPrincipal>>;
2118
+ type SnapshotSource = {
2119
+ /** Names the implementation in errors and events. */
2120
+ readonly name?: string;
2121
+ get: () => Promise<Snapshot | string> | Snapshot | string;
2122
+ subscribe?: (listener: () => void) => () => void;
2123
+ };
2124
+ type WhereCompiler<TTarget, TOptions = unknown> = (condition: Condition, target: TTarget, options?: TOptions) => unknown;
2125
+ type LimitConsumeInput = {
2126
+ readonly key: string;
2127
+ readonly subjectId: string;
2128
+ readonly count: number;
2129
+ /** The window in seconds; windows are aligned to the epoch. */
2130
+ readonly per: number;
2131
+ /** The decision clock; the store reads the clock when absent. */
2132
+ readonly now?: Instant;
2133
+ /** The active tenant; a quota counts per subject and tenant. */
2134
+ readonly tenant?: string;
2135
+ };
2136
+ type LimitRemaining = {
2137
+ readonly remaining: number;
2138
+ };
2139
+ type LimitStore = {
2140
+ /** Names the implementation in errors and events. */
2141
+ readonly name?: string;
2142
+ consume: (input: LimitConsumeInput) => Promise<LimitRemaining> | LimitRemaining;
2143
+ remaining: (input: LimitConsumeInput) => LimitRemaining | undefined;
2144
+ };
2145
+ type DecisionSink = {
2146
+ /** Names the implementation in errors and events. */
2147
+ readonly name?: string;
2148
+ write: (events: readonly SinkEvent[]) => Promise<void> | void;
2149
+ flush?: () => Promise<void>;
2150
+ };
2151
+ /**
2152
+ * Looks up the credential an API key stands for. `null` for a key that is
2153
+ * malformed, unknown, revoked or whose secret does not match; never throws for
2154
+ * bad input. Verification is the application's (or `apiKeyVerifier`'s), never
2155
+ * core's.
2156
+ */
2157
+ type CredentialVerifier = {
2158
+ /** Names the implementation in errors and events. */
2159
+ readonly name?: string;
2160
+ verify: (secret: string) => Credential | null | Promise<Credential | null>;
2161
+ /**
2162
+ * Records a successful use at `at`, for a `lastUsedAt` column. Called after a
2163
+ * key resolved and not awaited; a throw or a rejection is ignored, so it
2164
+ * never changes the subject.
2165
+ */
2166
+ touch?: (id: string, at: Instant) => void | Promise<void>;
2167
+ };
2168
+ /** What one tenant configures for itself. Every field only tightens. */
2169
+ type TenantSettings = {
2170
+ /** Rules for API keys created in, or used against, this tenant. */
2171
+ readonly credentials?: CredentialPolicy;
2172
+ /** Rules for support sessions started in this tenant. */
2173
+ readonly supportSessions?: SupportSessionPolicy;
2174
+ };
2175
+ /**
2176
+ * Per-tenant settings, a subject input like `CustomRoleSource`: they tighten
2177
+ * what a key may be and never grant. A throw denies.
2178
+ */
2179
+ type SettingsSource = {
2180
+ /** Names the implementation in errors and events. */
2181
+ readonly name?: string;
2182
+ settingsFor: (tenant: string) => TenantSettings | undefined | Promise<TenantSettings | undefined>;
2183
+ };
2184
+ declare const POLICY_X: unique symbol;
2185
+ /**
2186
+ * What every custom-role resolution of one policy shares, built with the policy
2187
+ * so a resolution never rescans the grant list.
2188
+ */
2189
+ type ResolveIndex = {
2190
+ /** Allows of assignable declared roles by scope name: the custom-role ceiling. */
2191
+ readonly ceilings: ReadonlyMap<string, readonly Grant[]>;
2192
+ readonly ceilingSets: ReadonlyMap<string, ReadonlySet<Grant>>;
2193
+ readonly ceilingKeys: ReadonlyMap<string, ReadonlySet<string>>;
2194
+ /** Every grant that is not hosted. */
2195
+ readonly all: readonly Grant[];
2196
+ /** The non-hosted grants whose grantee is exactly one role, by role name. */
2197
+ readonly byRole: ReadonlyMap<string, readonly Grant[]>;
2198
+ };
2199
+ type ClosureContext = {
2200
+ readonly subject: {
2201
+ readonly principal: Principal | null;
2202
+ readonly actor?: unknown;
2203
+ readonly delegation?: unknown;
2204
+ readonly context: Readonly<Record<string, unknown>>;
2205
+ };
2206
+ readonly actor?: unknown;
2207
+ readonly delegation?: unknown;
2208
+ readonly context: Readonly<Record<string, unknown>>;
2209
+ };
2210
+ type ClosureGrantFn<T = unknown> = (data: T, ctx: ClosureContext) => boolean;
2211
+ /** Who else may approve once a request has waited `after`. */
2212
+ type ApprovalEscalation = {
2213
+ /** Seconds from the request's creation. */
2214
+ readonly after: number;
2215
+ readonly to: Approver | readonly Approver[];
2216
+ };
2217
+ /** One group of approvers; `quorum` distinct approvers of `by` complete it. */
2218
+ type ApprovalStage = {
2219
+ readonly by: Approver | readonly Approver[];
2220
+ /** Absent means 1. */
2221
+ readonly quorum?: number;
2222
+ /**
2223
+ * After `after`, `to` may approve this stage as well as `by`; other stages
2224
+ * are unaffected.
2225
+ */
2226
+ readonly escalation?: ApprovalEscalation;
2227
+ };
2228
+ /**
2229
+ * `'any'`: `quorum` approvers from `by`. `'all'`: every stage completes, in any
2230
+ * order. `'sequential'`: stages complete in order; an approver signs only the
2231
+ * first incomplete stage. An approver signs once per request.
2232
+ */
2233
+ type ApprovalCombine = "any" | "all" | "sequential";
2234
+ /**
2235
+ * `'authorize'` (the default): someone other than the request's principal
2236
+ * approves. `'confirm'`: the principal may approve their own request. Neither
2237
+ * is met by an approver acting through an agent or a delegated token.
2238
+ */
2239
+ type ApprovalMode = "confirm" | "authorize";
2240
+ /**
2241
+ * What an `'authorize'` approval does when nobody else can approve: `'confirm'`
2242
+ * lets the request's principal approve it, but only while the handler's
2243
+ * `approverDirectory` lists no other eligible approver. Without a directory, or
2244
+ * when it answers `null`, the principal stays refused.
2245
+ */
2246
+ type ApprovalFallback = "confirm";
2247
+ type ApprovalRequirement = {
2248
+ /** Set when `combine` is `'any'` (the default); absent under `stages`. */
2249
+ readonly by?: Approver | readonly Approver[];
2250
+ /** Absent means `'any'`. */
2251
+ readonly combine?: ApprovalCombine;
2252
+ /** Set when `combine` is `'all'` or `'sequential'`. */
2253
+ readonly stages?: readonly ApprovalStage[];
2254
+ /** Absent means `'authorize'`. */
2255
+ readonly mode?: ApprovalMode;
2256
+ /** Absent means no fallback; see `ApprovalFallback`. */
2257
+ readonly fallback?: ApprovalFallback;
2258
+ /** `'resource-change'` binds the approval to the row's `version` field. */
2259
+ readonly staleOn?: "resource-change";
2260
+ /**
2261
+ * Distinct approvers a request needs before it is approved under `by`; absent
2262
+ * means 1.
2263
+ */
2264
+ readonly quorum?: number;
2265
+ /**
2266
+ * Seconds a request stays open; the store's default when absent, and never
2267
+ * longer than it.
2268
+ */
2269
+ readonly ttl?: number;
2270
+ readonly escalation?: ApprovalEscalation;
2271
+ };
2272
+ type ApprovalOption = "human" | {
2273
+ readonly by?: ApproverInput;
2274
+ /**
2275
+ * `'all'` or `'sequential'` with `stages`; absent means `'any'` with
2276
+ * `by`.
2277
+ */
2278
+ readonly combine?: ApprovalCombine;
2279
+ readonly stages?: readonly {
2280
+ readonly by: ApproverInput;
2281
+ readonly quorum?: number;
2282
+ /** After `after` seconds, `to` may approve this stage as well as `by`. */
2283
+ readonly escalation?: {
2284
+ readonly after: number;
2285
+ readonly to: ApproverInput;
2286
+ };
2287
+ }[];
2288
+ /**
2289
+ * `'confirm'` lets the request's principal approve it; absent means
2290
+ * `'authorize'`.
2291
+ */
2292
+ readonly mode?: ApprovalMode;
2293
+ /**
2294
+ * `'confirm'` lets the request's principal approve it when no other
2295
+ * eligible approver exists; see `ApprovalFallback`.
2296
+ */
2297
+ readonly fallback?: ApprovalFallback;
2298
+ /**
2299
+ * `'resource-change'`: the approval covers the row as it was when it was
2300
+ * requested. The resource must declare `version`; once that field
2301
+ * changes, resuming denies with `stale-approval`.
2302
+ */
2303
+ readonly staleOn?: "resource-change";
2304
+ /**
2305
+ * Distinct approvers needed (an integer of at least 1); the same approver
2306
+ * counts once. Absent means 1.
2307
+ */
2308
+ readonly quorum?: number;
2309
+ /**
2310
+ * Seconds the request stays open (`1800`); caps the approval store's
2311
+ * default.
2312
+ */
2313
+ readonly ttl?: number;
2314
+ /**
2315
+ * After `after` seconds (`14_400`), `to` may approve as well as `by`, at
2316
+ * any open stage; same kinds as `by`.
2317
+ */
2318
+ readonly escalation?: {
2319
+ readonly after: number;
2320
+ readonly to: ApproverInput;
2321
+ };
2322
+ };
2323
+ /**
2324
+ * A quota on a grant. `hard` (the default) denies past `count`; `soft` grants
2325
+ * with an `over-limit` obligation. `alertAt` (a fraction of `count`, above 0
2326
+ * and at most 1) adds a `near-limit` obligation once usage reaches it.
2327
+ */
2328
+ type GrantLimit = {
2329
+ readonly count: number;
2330
+ /** The window in seconds (`3600` for an hour), aligned to the epoch. */
2331
+ readonly per: number;
2332
+ readonly mode?: "hard" | "soft";
2333
+ readonly alertAt?: number;
2334
+ };
2335
+ /** How fresh the subject's authentication must be for an elevated grant. */
2336
+ type AssuranceRequirement = {
2337
+ /** Seconds since the subject last authenticated (`assurance.authTime`). */
2338
+ readonly maxAge?: number;
2339
+ /** Authentication context class references, any of which satisfies it. */
2340
+ readonly acr?: readonly string[];
2341
+ /** Authentication methods, all of which must be present. */
2342
+ readonly amr?: readonly string[];
2343
+ };
2344
+ /**
2345
+ * Time-boxed role activation. A role with `activation` is never held directly:
2346
+ * a membership lists it under `eligible`, and `permdock.activate` mints the
2347
+ * elevated membership to write.
2348
+ */
2349
+ type ActivationOption = {
2350
+ /** The longest an activation may last, in seconds (`14_400`). */
2351
+ readonly maxDuration?: number;
2352
+ /** `'required'` denies an activation without a reason. */
2353
+ readonly justification?: "required" | "optional";
2354
+ /**
2355
+ * When set, `activate` returns `approval-required` before the membership can
2356
+ * be written.
2357
+ */
2358
+ readonly approval?: ApprovalOption;
2359
+ /** How fresh the activator's authentication must be. */
2360
+ readonly assurance?: AssuranceRequirement;
2361
+ };
2362
+ type ActivationSpec = {
2363
+ readonly maxDuration?: number;
2364
+ readonly justification: "required" | "optional";
2365
+ readonly approval?: "human" | ApprovalRequirement;
2366
+ readonly assurance?: AssuranceRequirement;
2367
+ };
2368
+ /** What a break-glass grant demands before it overrides a deny. */
2369
+ type BreakGlassRequirements = {
2370
+ /** Purposes of use (`context.purpose`), any of which engages break-glass. */
2371
+ readonly purpose?: readonly string[];
2372
+ /** `true` denies unless the caller supplies `context.reason`. */
2373
+ readonly reason?: boolean;
2374
+ readonly assurance?: AssuranceRequirement;
2375
+ };
2376
+ type BreakGlassOptions = {
2377
+ /** Names of the deny grants this override lifts; every other deny still wins. */
2378
+ readonly overrides?: readonly string[];
2379
+ readonly requires?: BreakGlassRequirements;
2380
+ /** The longest a break-glass session may last, in seconds. */
2381
+ readonly maxDuration?: number;
2382
+ /** Follow-ups the grant owes: each becomes an obligation on the decision. */
2383
+ readonly obligations?: readonly ("notify" | "review")[];
2384
+ };
2385
+ /** The normalized break-glass spec carried on a grant. */
2386
+ type BreakGlassSpec = {
2387
+ readonly overrides: readonly string[];
2388
+ readonly purpose?: readonly string[];
2389
+ readonly reason: boolean;
2390
+ readonly assurance?: AssuranceRequirement;
2391
+ readonly maxDuration?: number;
2392
+ readonly obligations: readonly ("notify" | "review")[];
2393
+ };
2394
+ /** How a tenant consents to support access, and for how long. */
2395
+ type SupportConsent = {
2396
+ readonly by: GranteeInput;
2397
+ /** The durations a tenant owner may pick, in seconds. */
2398
+ readonly durations: readonly number[];
2399
+ };
2400
+ type SupportAccessOptions<S extends string = string> = {
2401
+ /** The role a consented support membership holds. */
2402
+ readonly role: string;
2403
+ /** The scope the support membership sits in; defaults to `tenant`. */
2404
+ readonly on?: S;
2405
+ /**
2406
+ * Every decision under the support membership denies with `actor-required`
2407
+ * without an `act`.
2408
+ */
2409
+ readonly actorRequired?: boolean;
2410
+ readonly consent: SupportConsent;
2411
+ /**
2412
+ * Permissions a support session never reaches, compiled to deny grants scoped
2413
+ * to `via: 'support'`.
2414
+ */
2415
+ readonly forbid?: readonly (Permission | PermissionTree)[];
2416
+ /** The subgroup a consented membership records under `member.group`. */
2417
+ readonly group?: string;
2418
+ };
2419
+ type SupportSpec = {
2420
+ readonly role: string;
2421
+ readonly actorRequired: boolean;
2422
+ readonly consent: {
2423
+ readonly by: Grantee | readonly Grantee[];
2424
+ readonly durations: readonly number[];
2425
+ };
2426
+ readonly group: string;
2427
+ };
2428
+ type GrantOptions<T = Record<string, unknown>> = {
2429
+ readonly to?: GranteeInput;
2430
+ readonly where?: WhereShorthand<T> | Condition;
2431
+ readonly check?: WhereShorthand<T> | Condition;
2432
+ readonly approval?: ApprovalOption;
2433
+ readonly limit?: GrantLimit;
2434
+ readonly reason?: string;
2435
+ readonly fields?: readonly (unknown extends T ? string : keyof T & string)[];
2436
+ /**
2437
+ * A stable name for the grant. On a deny, a `breakGlass` override may lift
2438
+ * it; on any grant, it is reported on `decision.matched.name` and on decision
2439
+ * events.
2440
+ */
2441
+ readonly name?: string;
2442
+ readonly group?: string;
2443
+ /**
2444
+ * Display text and app data for the grant, reported on
2445
+ * `decision.matched.meta`; never read in evaluation.
2446
+ */
2447
+ readonly meta?: GrantMeta;
2448
+ /**
2449
+ * Follow-ups the application owes when this allow grants: each becomes a `{
2450
+ * kind: 'app', name, detail? }` obligation on the decision. Allows only.
2451
+ */
2452
+ readonly obligations?: readonly ObligationInput[];
2453
+ /**
2454
+ * Purposes of use (`context.purpose`) that make the grant apply;
2455
+ * non-portable.
2456
+ */
2457
+ readonly purpose?: readonly string[];
2458
+ /**
2459
+ * The grant applies from this instant on (RFC 3339 or an `Instant`); before
2460
+ * it an allow denies with `inactive-grant` and a deny does not apply.
2461
+ */
2462
+ readonly validFrom?: string | Instant;
2463
+ /**
2464
+ * The grant stops applying at this instant (exclusive; RFC 3339 or an
2465
+ * `Instant`).
2466
+ */
2467
+ readonly validUntil?: string | Instant;
2468
+ /**
2469
+ * An allow on an instance action counts only on rows whose scope instance (or
2470
+ * the whole app, globally) is one where the subject also holds this
2471
+ * permission through a role grant without a row condition.
2472
+ */
2473
+ readonly requires?: Permission | readonly Permission[];
2474
+ };
2475
+ /**
2476
+ * A grant's metadata. PermDock carries it to decisions, events, snapshots and
2477
+ * the catalog and never reads `x`.
2478
+ */
2479
+ type GrantMeta = {
2480
+ readonly description?: string;
2481
+ /**
2482
+ * Data the application owns. Plain JSON, checked by `definePolicy(…, { x: {
2483
+ * grant } })`.
2484
+ */
2485
+ readonly x?: AppData;
2486
+ };
2487
+ /** An app obligation as declared on an allow: its name, or its name and detail. */
2488
+ type ObligationInput = string | {
2489
+ readonly name: string;
2490
+ readonly detail?: MetaValue;
2491
+ };
2492
+ /**
2493
+ * When a grant applies, in Unix seconds. `from` is inclusive, `until`
2494
+ * exclusive; either may be absent. Portable: `where()` drops an inactive grant
2495
+ * at the decision clock and generated RLS compares against `now()`.
2496
+ */
2497
+ type GrantValidity = {
2498
+ readonly from?: number;
2499
+ readonly until?: number;
2500
+ };
2501
+ /**
2502
+ * A grant's validity in JSON (snapshots, catalogs, `inactive-grant` details):
2503
+ * RFC 3339 bounds.
2504
+ */
2505
+ type WireValidity = {
2506
+ readonly from?: string;
2507
+ readonly until?: string;
2508
+ };
2509
+ /**
2510
+ * The actor a policy delegation is for: an actor kind, narrowed to one id when
2511
+ * `id` is set, or to one named client when `client` is set (the name the
2512
+ * subject resolver gives a verified client id through `clients`).
2513
+ */
2514
+ type DelegationTarget = {
2515
+ readonly kind: ActorKind;
2516
+ readonly id?: string;
2517
+ readonly client?: string;
2518
+ };
2519
+ /**
2520
+ * A normalised policy delegation: holders of `from` let actors matching `to`
2521
+ * use `permissions` (keys) on their behalf while `validity` holds, without a
2522
+ * token saying so. Attenuation only: the principal's grants still decide.
2523
+ */
2524
+ type PolicyDelegation = {
2525
+ readonly from: Grantee | readonly Grantee[];
2526
+ readonly to: DelegationTarget;
2527
+ readonly permissions: readonly string[];
2528
+ /**
2529
+ * The keys of `permissions` whose `readOnlyHint` is true: all a `readOnly`
2530
+ * actor may use.
2531
+ */
2532
+ readonly readOnly: readonly string[];
2533
+ readonly validity?: GrantValidity;
2534
+ };
2535
+ type DelegationInput = {
2536
+ /**
2537
+ * Who hands over: the same subject-only selectors as `approval.by` (a role,
2538
+ * `authenticated()`, a plan, `assurance()`); not `relation()`.
2539
+ */
2540
+ readonly from: GranteeInput;
2541
+ /**
2542
+ * Which actor may act: `actor('eve')`, an actor kind, `{ kind, id }` for one
2543
+ * agent, or `{ kind, client }` for one named OAuth client.
2544
+ */
2545
+ readonly to: ActorGrantee | string | DelegationTarget;
2546
+ /** The leaves or subtrees the actor may use; a deny grant still applies. */
2547
+ readonly permissions: readonly (Permission | PermissionTree)[];
2548
+ readonly validFrom?: string | Instant;
2549
+ readonly validUntil?: string | Instant;
2550
+ };
2551
+ /**
2552
+ * A declared scope name (or the `tenant` / `team` alias), or the resource a
2553
+ * role is held on.
2554
+ */
2555
+ type RoleScope<S extends string = string> = S | Permission | PermissionTree | readonly (Permission | PermissionTree)[];
2556
+ type RoleOptions<S extends string = string> = {
2557
+ readonly on?: RoleScope<S>;
2558
+ readonly assignable?: boolean;
2559
+ /** Roles nobody may hold together with this one in the same scope instance. */
2560
+ readonly exclusiveWith?: readonly string[];
2561
+ /**
2562
+ * Fewest holders a scope instance keeps (checked at commit); default 0. Needs
2563
+ * a named-scope `on`.
2564
+ */
2565
+ readonly min?: number;
2566
+ /** Most holders a scope instance may have. Needs a named-scope `on`. */
2567
+ readonly max?: number;
2568
+ /**
2569
+ * The holder count of a scope instance never changes: the role only moves by
2570
+ * transfer.
2571
+ */
2572
+ readonly transferOnly?: boolean;
2573
+ /**
2574
+ * Roles a holder may assign and revoke. Once any role declares `assigns`, a
2575
+ * role nobody lists is assigned only by `meta.manageRoles` holders.
2576
+ */
2577
+ readonly assigns?: readonly string[];
2578
+ /**
2579
+ * Membership kinds (`via`) that may hold the role; others hold it for
2580
+ * nothing.
2581
+ */
2582
+ readonly for?: readonly string[];
2583
+ readonly meta?: RoleMeta;
2584
+ /**
2585
+ * Time-boxed activation: the role becomes eligible-only and `activate` mints
2586
+ * its membership.
2587
+ */
2588
+ readonly activation?: ActivationOption;
2589
+ /** Reserved for restricted credentials; setting it throws until it ships. */
2590
+ readonly restricted?: never;
2591
+ };
2592
+ /** Where a grant applies: `'global'`, a declared scope name, or one resource. */
2593
+ type GrantScope = string | {
2594
+ readonly resource: string;
2595
+ };
2596
+ type Grant = {
2597
+ readonly permission: Permission;
2598
+ readonly effect: "allow" | "deny";
2599
+ readonly to: Grantee | readonly Grantee[];
2600
+ readonly role: string | null;
2601
+ readonly where?: Condition;
2602
+ readonly check?: Condition;
2603
+ readonly approval?: "human" | ApprovalRequirement;
2604
+ readonly portable: boolean;
2605
+ /**
2606
+ * Set when `portable` is false only because the grant reads the relation
2607
+ * graph.
2608
+ */
2609
+ readonly graph?: true;
2610
+ readonly closure?: ClosureGrantFn;
2611
+ readonly limit?: GrantLimit;
2612
+ readonly fields?: readonly string[];
2613
+ readonly scope: GrantScope;
2614
+ /**
2615
+ * The grant's stable name: a `breakGlass` override lifts a named deny, and
2616
+ * `decision.matched.name` reports it.
2617
+ */
2618
+ readonly name?: string;
2619
+ readonly group?: string;
2620
+ readonly meta?: GrantMeta;
2621
+ /** App obligations an allow adds to its granted decision. */
2622
+ readonly obligations?: readonly AppObligation[];
2623
+ /**
2624
+ * Purposes of use that make the grant apply (`context.purpose`);
2625
+ * non-portable.
2626
+ */
2627
+ readonly purpose?: readonly string[];
2628
+ /**
2629
+ * Set on a break-glass allow: it overrides named denies and carries
2630
+ * obligations.
2631
+ */
2632
+ readonly breakGlass?: BreakGlassSpec;
2633
+ /**
2634
+ * The membership kind (`via`) this grant applies under; others never match
2635
+ * it.
2636
+ */
2637
+ readonly viaOnly?: MembershipVia;
2638
+ /** Set only on a grant merged from a hosted policy document. */
2639
+ readonly hosted?: HostedGrantRef;
2640
+ /** When the grant applies; absent means always. */
2641
+ readonly validity?: GrantValidity;
2642
+ /**
2643
+ * Set on a custom-role grant narrowed by a resource level
2644
+ * (`CustomRoleGrant.level`).
2645
+ */
2646
+ readonly level?: string;
2647
+ /**
2648
+ * The permission key the subject must also hold, through a role, on the row's
2649
+ * scope instance or globally.
2650
+ */
2651
+ readonly requires?: readonly string[];
2652
+ };
2653
+ /** Which hosted policy document and grant a merged grant came from. */
2654
+ type HostedGrantRef = {
2655
+ readonly document: string;
2656
+ readonly grant: string;
2657
+ };
2658
+ type RoleBinding<S extends string = string> = {
2659
+ readonly name: string;
2660
+ readonly grants: readonly Grant[];
2661
+ readonly on?: RoleScope<S>;
2662
+ readonly assignable: boolean;
2663
+ readonly exclusiveWith?: readonly string[];
2664
+ readonly min?: number;
2665
+ readonly max?: number;
2666
+ readonly transferOnly?: boolean;
2667
+ readonly assigns?: readonly string[];
2668
+ readonly for?: readonly string[];
2669
+ readonly meta?: RoleMeta;
2670
+ /**
2671
+ * Time-boxed activation: the role is eligible-only, and `activate` mints its
2672
+ * membership.
2673
+ */
2674
+ readonly activation?: ActivationSpec;
2675
+ /**
2676
+ * Support access: consent and `actorRequired` for a vendor-support
2677
+ * membership.
2678
+ */
2679
+ readonly support?: SupportSpec;
2680
+ };
2681
+ type ValidateMode = "boundary" | "always" | "never";
2682
+ /**
2683
+ * The declared scopes, in declaration order; empty when the policy declares
2684
+ * none.
2685
+ */
2686
+ type PolicyScopes = readonly Scope[];
2687
+ type PolicyVocabulary = {
2688
+ readonly permissions: PermissionTree;
2689
+ readonly roles?: RoleTree;
2690
+ readonly plans?: PlanTree;
2691
+ };
2692
+ type VocabularyFromInput<Input> = Input extends PolicyVocabulary ? Input : {
2693
+ readonly permissions: Input & PermissionTree;
2694
+ readonly roles?: RoleTree;
2695
+ readonly plans?: PlanTree;
2696
+ };
2697
+ type Policy<TUser = unknown, TPrincipal extends Principal = Principal, V extends PolicyVocabulary = PolicyVocabulary, S extends PolicyScopesInput = PolicyScopesInput> = {
2698
+ readonly permissions: V["permissions"];
2699
+ readonly roles: readonly RoleBinding[];
2700
+ readonly rolesByName: ReadonlyMap<string, RoleBinding>;
2701
+ readonly grants: readonly Grant[];
2702
+ readonly vocabulary: V;
2703
+ readonly scopes: PolicyScopes;
2704
+ principal(user: TUser): TPrincipal | null;
2705
+ subject(user: TUser): TPrincipal | null;
2706
+ context?(user: TUser): Readonly<Record<string, unknown>> | Promise<Readonly<Record<string, unknown>>>;
2707
+ readonly validate: ValidateMode;
2708
+ readonly onDenied?: (decision: unknown) => never | void;
2709
+ readonly fingerprint: string;
2710
+ readonly resources: ReadonlyMap<string, ResourceNode>;
2711
+ /**
2712
+ * The app data schemas `definePolicy` was given; symbol-keyed so freezing the
2713
+ * policy leaves the schemas alone.
2714
+ */
2715
+ readonly [POLICY_X]?: PolicyAppDataSchemas;
2716
+ readonly [POLICY_SCOPES]?: S;
2717
+ readonly providers?: readonly DecisionProvider[];
2718
+ /**
2719
+ * Permission keys a hosted policy document may grant or deny; empty by
2720
+ * default.
2721
+ */
2722
+ readonly hostable: readonly string[];
2723
+ /**
2724
+ * Permission keys that deny with `stale-credentials` when the subject's token
2725
+ * is behind the source.
2726
+ */
2727
+ readonly fresh?: readonly string[];
2728
+ /**
2729
+ * Policy delegations in declaration order; absent or empty when the policy
2730
+ * declares none.
2731
+ */
2732
+ readonly delegations?: readonly PolicyDelegation[];
2733
+ /**
2734
+ * Grant levels by resource (`resource(…, { levels })`), normalised; absent
2735
+ * when none are declared.
2736
+ */
2737
+ readonly levels?: PolicyLevels;
2738
+ /** Resources declared with `orderedLevels: true`, sorted; absent when none. */
2739
+ readonly orderedLevels?: readonly string[];
2740
+ /**
2741
+ * Coarse OAuth scopes in declaration order; absent when the policy declares
2742
+ * none.
2743
+ */
2744
+ readonly oauthScopes?: readonly PolicyOAuthScope[];
2745
+ readonly index: PolicyIndex;
2746
+ };
2747
+ /**
2748
+ * A coarse OAuth scope an authorization server issues (`mcp:read`) and the
2749
+ * permission keys it covers, with their own scopes (`task:read`).
2750
+ */
2751
+ type PolicyOAuthScope = {
2752
+ readonly scope: string;
2753
+ readonly permissions: readonly string[];
2754
+ readonly scopes: readonly string[];
2755
+ };
2756
+ /**
2757
+ * Lookups built once per policy, so a decision does not rescan every role and
2758
+ * grant.
2759
+ */
2760
+ type PolicyIndex = {
2761
+ readonly declaredRoles: ReadonlySet<string>;
2762
+ readonly supports: readonly SupportSpec[];
2763
+ /** The grants `grantList` returns, by permission key, in the same order. */
2764
+ readonly grantsByKey: ReadonlyMap<string, readonly Grant[]>;
2765
+ /** What custom-role resolution shares: ceilings and grants by role. */
2766
+ readonly resolve: ResolveIndex;
2767
+ /**
2768
+ * `clientBundle(policy)` and the canonical grants it was built from, filled
2769
+ * on first use under the policy itself. A `WeakMap`, so freezing the index
2770
+ * leaves it writable.
2771
+ */
2772
+ readonly bundle: WeakMap<object, BundleMemo>;
2773
+ };
2774
+ /** What `clientBundle` derives once per policy. */
2775
+ type BundleMemo = {
2776
+ readonly bundle: ClientBundle;
2777
+ readonly expected: ReadonlyMap<string, readonly string[]>;
2778
+ };
2779
+ type GrantCondition<T, K extends PermissionKind> = K extends "collection" ? Omit<GrantOptions<T>, "where" | "fields"> | ClosureGrantFn<T> : GrantOptions<T> | ClosureGrantFn<T>;
2780
+ /** Resource name to level name to its normalised condition. */
2781
+ type PolicyLevels = Readonly<Record<string, Readonly<Record<string, Condition>>>>;
2782
+ /**
2783
+ * Standard Schemas for the app data a policy carries. `grant` checks every
2784
+ * grant's `meta.x` at `definePolicy` and throws on invalid data; `membership`
2785
+ * checks `Membership.x` as each subject resolves, dropping an invalid `x`
2786
+ * (never the membership) with an `on('auth')` event of reason `schema`.
2787
+ */
2788
+ type PolicyAppDataSchemas = {
2789
+ readonly grant?: AppDataSchema<unknown>;
2790
+ readonly membership?: AppDataSchema<unknown>;
2791
+ };
2792
+ type PolicyOptions<TUser, TPrincipal extends Principal, S extends PolicyScopesInput = PolicyScopesInput> = {
2793
+ readonly x?: PolicyAppDataSchemas;
2794
+ readonly roles?: readonly RoleBinding<ScopeNames<S>>[];
2795
+ readonly grants?: readonly (Omit<Grant, "role" | "scope"> | readonly Omit<Grant, "role" | "scope">[] | Grant)[];
2796
+ /**
2797
+ * Named scopes in order, each with the row field holding its id and an
2798
+ * optional parent (`within`, an earlier scope). `tenant` and `team` alias the
2799
+ * first and second scope.
2800
+ */
2801
+ readonly scopes?: S;
2802
+ /**
2803
+ * Maps the application's user to the principal PermDock decides for; `null`
2804
+ * is anonymous.
2805
+ */
2806
+ readonly subject: (user: TUser) => TPrincipal | null;
2807
+ readonly context?: (user: TUser) => Readonly<Record<string, unknown>> | Promise<Readonly<Record<string, unknown>>>;
2808
+ readonly validate?: ValidateMode;
2809
+ readonly onDenied?: (decision: unknown) => never | void;
2810
+ readonly providers?: readonly DecisionProvider[];
2811
+ /**
2812
+ * Leaves or subtrees a hosted policy document (`PolicySource`) may touch. The
2813
+ * default is none, so a policy without it ignores every hosted grant.
2814
+ */
2815
+ readonly hostable?: readonly (Permission | PermissionTree)[];
2816
+ /**
2817
+ * Sensitive permissions that need an up-to-date token: when the subject's
2818
+ * memberships come from a token behind the `MembershipSource` version, they
2819
+ * deny with `stale-credentials`.
2820
+ */
2821
+ readonly fresh?: readonly (Permission | PermissionTree)[];
2822
+ /**
2823
+ * Standing delegations: holders of `from` let actors matching `to` use
2824
+ * `permissions` for them without a token saying so. A token delegation on the
2825
+ * call still applies as well; both must cover.
2826
+ */
2827
+ readonly delegations?: readonly DelegationInput[];
2828
+ /**
2829
+ * Coarse OAuth scopes the authorization server issues, each covering
2830
+ * permissions: a token holding `mcp:read` is delegated every permission
2831
+ * listed under it, as if it held each permission's own scope. Scope
2832
+ * challenges name the first coarse scope that covers the permission.
2833
+ */
2834
+ readonly oauthScopes?: Readonly<Record<string, readonly (Permission | PermissionTree)[]>>;
2835
+ };
2836
+ type MembershipFixture = {
2837
+ readonly principal?: string;
2838
+ readonly tenant?: string;
2839
+ readonly roles: readonly string[];
2840
+ };
2841
+ type SeparationConflict = {
2842
+ readonly principal: string;
2843
+ readonly tenant?: string;
2844
+ readonly roles: readonly [string, string];
2845
+ };
2846
+ type PrincipalOf<P> = P extends Policy<unknown, infer TPrincipal> ? TPrincipal : Principal;
2847
+ type SubjectOf<P> = {
2848
+ readonly principal: PrincipalOf<P> | null;
2849
+ readonly actor?: Actor;
2850
+ readonly delegation?: Delegation;
2851
+ readonly context: Readonly<Record<string, unknown>>;
2852
+ readonly session?: string;
2853
+ readonly expiresAt?: number;
2854
+ };
2855
+ export { JwtClaims as $, Denial as $n, LocalSnapshotManifest as $t, PolicyOAuthScope as A, ApproverInput as An, ConditionRef as Ar, parseSupportSession as At, SupportAccessOptions as B, GranteeInput as Bn, hasConditionOp as Br, DecideCredentialOptions as Bt, GrantValidity as C, WireDelegation as Cn, SharedCustomRole as Cr, WhereCompiler as Ct, Policy as D, ScopeNames as Dn, AdapterId as Dr, SupportSessionPolicy as Dt, ObligationInput as E, ScopeDeclaration as En, ActorKind as Er, SupportSessionDecision as Et, RoleBinding as F, anyOf as Fn, RelatedCondition as Fr, CredentialPermission as Ft, CredentialVerifier as G, assurance as Gn, parseCredential as Gt, ValidateMode as H, RelationGrantee as Hn, isConditionDate as Hr, credentialPolicyViolation as Ht, RoleOptions as I, holder as In, RelatedHop as Ir, CredentialPermissionInput as It, CustomRoleSourceFactory as J, plan as Jn, ClientBundle as Jt, CustomRoleContext as K, authenticated as Kn, InstanceHandle as Kt, RoleScope as L, manager as Ln, RestrictedAncestors as Lr, CredentialPolicy as Lt, PolicyScopes as M, PermissionApprover as Mn, MemberOfCondition as Mr, Credential as Mt, PolicyVocabulary as N, UserApprover as Nn, MemberOfParent as Nr, CredentialDecision as Nt, PolicyAppDataSchemas as O, AnyOfApprover as On, MembershipVia as Or, SupportSessionRequest as Ot, PrincipalOf as P, allOf as Pn, OpaqueCondition as Pr, CredentialKind as Pt, Intent as Q, Decision as Qn, LocalRowValue as Qt, SeparationConflict as R, user as Rn, SqlFunctionArg as Rr, CredentialPolicyViolation as Rt, GrantScope as S, WireDenial as Sn, Principal as Sr, VersionQuery as St, MembershipFixture as T, Scope as Tn, VerifiedClaims as Tr, SupportSession as Tt, VocabularyFromInput as U, actor as Un, isConditionRef as Ur, decideCredential as Ut, SupportConsent as V, InheritGrantee as Vn, isCondition as Vr, credentialDelegation as Vt, WireValidity as W, anyone as Wn, isSqlFunctionField as Wr, isFeedId as Wt, DecisionSink as X, AppObligation as Xn, LocalMembershipRows as Xt, DecisionProvider as Y, relation as Yn, LocalCustomRoleTable as Yt, EntitlementSource as Z, ApprovalRequiredDecision as Zn, LocalRowColumn as Zt, Grant as _, DirectoryEvent as _n, CustomRoleGrant as _r, TokenSigner as _t, ApprovalMode as a, SnapshotNotEntitled as an, LimitDetail as ar, RelationChain as at, GrantMeta as b, SinkEvent as bn, JsonWebKeyLike as br, VerifiedToken as bt, ApprovalStage as c, SnapshotTenants as cn, Quota as cr, RelationSource as ct, BreakGlassRequirements as d, AutomationEvent as dn, TraceSkipReason as dr, SourceCall as dt, LocalSnapshotRows as en, DenialDetails as er, LimitConsumeInput as et, BreakGlassSpec as f, CredentialEvent as fn, Actor as fr, SourceContext as ft, DelegationTarget as g, DeliveryFailureCause as gn, CustomRole as gr, TokenFailureCause as gt, DelegationInput as h, DeliveryEvent as hn, Binding as hr, TenantSettings as ht, ApprovalFallback as i, SnapshotGrantTerms as in, GrantedDecision as ir, MembershipSource as it, PolicyOptions as j, ManagerApprover as jn, ConditionValue as jr, ApiKeyPrincipal as jt, PolicyDelegation as k, Approver as kn, Condition as kr, decideSupportSession as kt, AssuranceRequirement as l, AccessEvent as ln, Trace as lr, SettingsSource as lt, ClosureGrantFn as m, DeliveryChannel as mn, AuthorizationDetail as mr, SubjectResolver as mt, ApprovalCombine as n, SnapshotAssignable as nn, DeniedDecision as nr, LimitStore as nt, ApprovalOption as o, SnapshotScope as on, MatchedGrant as or, RelationGroup as ot, ClosureContext as p, DecisionEvent as pn, Assurance as pr, SourceMemo as pt, CustomRoleSource as q, inherit as qn, Instant as qt, ApprovalEscalation as r, SnapshotGrant as rn, ExplainedDecision as rr, MemberEntry as rt, ApprovalRequirement as s, SnapshotStatic as sn, Obligation as sr, RelationHolder as st, ActivationOption as t, Snapshot as tn, DenialReason as tr, LimitRemaining as tt, BreakGlassOptions as u, AuthEvent as un, TraceSkip as ur, SnapshotSource as ut, GrantCondition as v, EmailCategory as vn, Delegation as vr, TokenVerifier as vt, HostedGrantRef as w, PolicyScopesInput as wn, Subject as wr, DecideSupportSessionOptions as wt, GrantOptions as x, WireDecision as xn, Membership as xr, VersionContext as xt, GrantLimit as y, MembershipEvent as yn, GnapAccess as yr, VerificationFailure as yt, SubjectOf as z, Grantee as zn, SqlFunctionCondition as zr, CredentialRequest as zt };