permdock 0.7.0 → 0.9.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 (483) hide show
  1. package/README.md +1 -3
  2. package/dist/a2a/index.d.ts +7 -7
  3. package/dist/a2a/index.js +8 -8
  4. package/dist/action-result-BcudBQOF.d.ts +19 -0
  5. package/dist/{adapter-context-CRhqyzCk.js → adapter-context-CIQpQxbE.js} +8 -2
  6. package/dist/{adoption-scan-D-feE7BE.js → adoption-scan-Ch07MdxN.js} +5 -5
  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 +19 -13
  10. package/dist/ai-sdk/index.js +6 -6
  11. package/dist/{app-data-MuyzVqX8.js → app-data-UNNm07jV.js} +10 -7
  12. package/dist/{approval-header-CJACtHkv.js → approval-header-8QV6MU4H.js} +6 -3
  13. package/dist/{approval-prompt-K0faOLFp.d.ts → approval-prompt-3BqWczTt.d.ts} +13 -11
  14. package/dist/{approval-prompt-Dg5LeAcT.js → approval-prompt-B8hQY69x.js} +5 -6
  15. package/dist/approvals/index.d.ts +4 -4
  16. package/dist/approvals/index.js +6 -6
  17. package/dist/{approvals-CMRfsbBh.js → approvals-DnIBTuXE.js} +66 -42
  18. package/dist/{approvers-CqPOLD-o.js → approvers-B4r0N_Uz.js} +8 -2
  19. package/dist/{arazzo-ClrF3PVb.js → arazzo-BpS7LnV0.js} +2 -2
  20. package/dist/{arazzo-rdeJ8n1J.js → arazzo-CmQaGPkM.js} +6 -6
  21. package/dist/{args-CC3OwyHW.js → args-0FrVs5EH.js} +14 -7
  22. package/dist/astro/index.d.ts +30 -12
  23. package/dist/astro/index.js +2 -2
  24. package/dist/{audience-BrMs8c4o.js → audience-DTjR8xet.js} +8 -8
  25. package/dist/{auth-CscUX8Sy.js → auth--yPyZNgr.js} +19 -7
  26. package/dist/authzen/index.d.ts +34 -28
  27. package/dist/authzen/index.js +23 -20
  28. package/dist/{automation-DOtAFWdy.d.ts → automation-C6Jg75xq.d.ts} +42 -32
  29. package/dist/{automation-ySsxp_Yp.js → automation-x3KEUusw.js} +22 -21
  30. package/dist/better-auth/index.d.ts +2 -2
  31. package/dist/better-auth/index.js +13 -7
  32. package/dist/better-supabase/index.d.ts +357 -227
  33. package/dist/better-supabase/index.js +219 -140
  34. package/dist/{bind-D1nO6fiC.js → bind-BNQA9JK9.js} +26 -10
  35. package/dist/{bind-JDuvxjuW.d.ts → bind-YYjvfpB9.d.ts} +32 -12
  36. package/dist/{body-CH5of8Ne.js → body-CJQwYVa8.js} +3 -3
  37. package/dist/{body-text-QcXok_SI.js → body-text-DQhcmqdY.js} +8 -4
  38. package/dist/{boundary-BM8a_P6E.js → boundary-BV3O1eud.js} +8 -2
  39. package/dist/{boundary-BmHxVH1J.d.ts → boundary-C9ck-3uK.d.ts} +13 -4
  40. package/dist/{budget-NbEtbJC_.js → budget-BELja5A9.js} +6 -3
  41. package/dist/{budget-JqcRqyhK.d.ts → budget-hYsPz_yE.d.ts} +6 -3
  42. package/dist/{build-instance-DxE7czo9.js → build-instance-BWXqwQYU.js} +3 -3
  43. package/dist/{capability-L7NnfhiE.js → capability-BqX94r07.js} +31 -25
  44. package/dist/{capability-D4UC9TTW.d.ts → capability-Di9tiUvi.d.ts} +41 -29
  45. package/dist/{casbin-BHijLuHY.js → casbin-B7_yS-oo.js} +2 -2
  46. package/dist/{casbin-BW9pS47J.js → casbin-bHyIxTNQ.js} +16 -8
  47. package/dist/{casl-CmJlgziS.js → casl-C4OINZHI.js} +2 -2
  48. package/dist/{casl-UbI8v-Wq.js → casl-CHHoCldP.js} +19 -10
  49. package/dist/catalog/index.d.ts +51 -30
  50. package/dist/catalog/index.js +18 -15
  51. package/dist/{catalog-D69WhFii.js → catalog-CGlSwU6j.js} +20 -19
  52. package/dist/catalog-D3oS2GH3.js +1 -0
  53. package/dist/{catalog-BaMQfQ6Y.js → catalog-amPDr0JQ.js} +3 -3
  54. package/dist/{catalog-doc-CV9s6B1S.js → catalog-doc-DjMKzJp9.js} +28 -14
  55. package/dist/{catalog-fingerprint-C144oW4M.js → catalog-fingerprint-e6aCWosn.js} +18 -14
  56. package/dist/catalog-operations-DeHTrJSV.js +60 -0
  57. package/dist/{challenge-nGWma08S.js → challenge-DImNcR7B.js} +48 -27
  58. package/dist/chat/index.d.ts +1 -1
  59. package/dist/chat/index.js +13 -10
  60. package/dist/chat-sdk/index.d.ts +44 -26
  61. package/dist/chat-sdk/index.js +17 -17
  62. package/dist/{checks-BC_0mPIq.js → checks-CGkP3Z7A.js} +4 -1
  63. package/dist/{claims-map-7oQ3ue4X.js → claims-map-CKkoAAYF.js} +5 -2
  64. package/dist/{claims-map-Ca-QX8C6.d.ts → claims-map-D1Pb5oRq.d.ts} +8 -5
  65. package/dist/claude-agent/index.d.ts +6 -6
  66. package/dist/claude-agent/index.js +6 -3
  67. package/dist/clerk/index.d.ts +11 -7
  68. package/dist/clerk/index.js +6 -6
  69. package/dist/cli/bin.js +4 -4
  70. package/dist/cli/index.d.ts +82 -7
  71. package/dist/cli/index.js +6 -6
  72. package/dist/{clients-C7zLFuWT.d.ts → clients-C_NOET3z.d.ts} +5 -5
  73. package/dist/{clients-DjU5ABMy.js → clients-DYr3U86j.js} +3 -3
  74. package/dist/cloud/index.d.ts +84 -52
  75. package/dist/cloud/index.js +53 -39
  76. package/dist/{cloud-CO8pYtwr.js → cloud-3kWfjnYy.js} +4 -5
  77. package/dist/{codemod-BP6n8N9L.js → codemod-Bv5i-Mzo.js} +523 -201
  78. package/dist/{codemod-i4N2BhDc.js → codemod-D9Aiii1r.js} +3 -4
  79. package/dist/{collect-DNm3oKOk.js → collect-B80GYEot.js} +4 -5
  80. package/dist/collect-D-eroIfV.js +1 -0
  81. package/dist/{collect-BaWeMjwV.js → collect-WCl8cJQV.js} +26 -63
  82. package/dist/{compare-pfyVnBjE.js → compare-DTfyUunF.js} +2 -2
  83. package/dist/compile/index.d.ts +2 -2
  84. package/dist/compile/index.js +1 -1
  85. package/dist/{compile-COM2VKuN.d.ts → compile-BEklRUYo.d.ts} +36 -12
  86. package/dist/{compile-BAEO5bOk.js → compile-EzEMB-7v.js} +77 -33
  87. package/dist/{completion-BNdVf7X2.js → completion-_bc0OUQ-.js} +17 -8
  88. package/dist/config-BwPBfN0t.js +108 -0
  89. package/dist/{config-DGZzMV1B.js → config-D5XrLWpk.js} +2 -2
  90. package/dist/{config-report-Cm7UITNA.js → config-report-BmWIskD7.js} +9 -6
  91. package/dist/config-shape-ykV0Vm2n.js +134 -0
  92. package/dist/{connection-DjhIJSs2.js → connection-B72dg5Q2.js} +23 -22
  93. package/dist/{connector-schema-_VCSsdtD.js → connector-schema-CYLQNMYq.js} +3 -2
  94. package/dist/{context--uM9V3Ui.js → context-BnIzxTNE.js} +4 -3
  95. package/dist/convex/index.d.ts +13 -7
  96. package/dist/convex/index.js +9 -6
  97. package/dist/{core-CQkE8Esr.d.ts → core-CFepFiDP.d.ts} +49 -22
  98. package/dist/{core-B5-w6Kw9.js → core-DzVINFbU.js} +26 -20
  99. package/dist/{create-Cb86Z8Im.js → create-6EwRQlig.js} +10 -7
  100. package/dist/{create-DJrlhEp9.js → create-BLPKnJKa.js} +35 -25
  101. package/dist/{create-UTnUVETj.d.ts → create-BPUopdfL.d.ts} +70 -37
  102. package/dist/{create-QHuuPw3q.d.ts → create-BamXmeob.d.ts} +37 -29
  103. package/dist/{create-B2-CQqCI.d.ts → create-DBvUsgzK.d.ts} +49 -28
  104. package/dist/{credential-CIM7wHwA.js → credential-CyyyvCsL.js} +41 -38
  105. package/dist/{credentials-BpuTwd7a.js → credentials-CdDxp7jN.js} +6 -6
  106. package/dist/{deciding-columns-DRo2QM6E.js → deciding-columns-NB4wcyBf.js} +2 -2
  107. package/dist/{delegation-C5rOdTp5.js → delegation-CDB6_keF.js} +31 -22
  108. package/dist/delivery/index.d.ts +4 -4
  109. package/dist/delivery/index.js +5 -5
  110. package/dist/{delivery-rwOKLWRm.js → delivery-BupfvJIV.js} +34 -22
  111. package/dist/{delivery-event-xX4obB8F.js → delivery-event-JioK5YbS.js} +6 -6
  112. package/dist/denied-text-DHldhVUv.d.ts +22 -0
  113. package/dist/{describe-DZlnEtLy.js → describe-Bb4hGK5d.js} +5 -5
  114. package/dist/{describe-O0SwYIK8.d.ts → describe-BbFPBSms.d.ts} +5 -5
  115. package/dist/{device-BARQ8eYG.js → device-BwbJNmb2.js} +11 -8
  116. package/dist/{diff-Btr1c1Ow.js → diff-BwR1JdP2.js} +2 -2
  117. package/dist/{diff-DzT-xD13.js → diff-CQegtBAo.js} +22 -13
  118. package/dist/{digest-B3kc_PgQ.d.ts → digest-8Yx2CchM.d.ts} +3 -3
  119. package/dist/{doctor-BU1szn63.js → doctor-ClRVAtXQ.js} +287 -135
  120. package/dist/{doctor-BoK_y0KO.js → doctor-LPMYjSqO.js} +4 -4
  121. package/dist/drizzle/index.d.ts +33 -19
  122. package/dist/drizzle/index.js +17 -9
  123. package/dist/elysia/index.d.ts +17 -11
  124. package/dist/elysia/index.js +5 -5
  125. package/dist/{errors-BKy0EfhN.js → errors-B6R_lg2a.js} +13 -4
  126. package/dist/{errors-B_Qg9D3e.d.ts → errors-BIM4MFsJ.d.ts} +22 -6
  127. package/dist/{errors-BWXBMaKK.d.ts → errors-CHwoRRpB.d.ts} +4 -1
  128. package/dist/{errors-DpP_U6Bf.js → errors-Vpu6rKHl.js} +13 -10
  129. package/dist/{evaluate-B_oqFbWC.js → evaluate-BAmf_AQd.js} +153 -82
  130. package/dist/{evaluations-BCddEOfO.d.ts → evaluations-DOWuBpWv.d.ts} +11 -5
  131. package/dist/{evaluations-DReoiVBw.js → evaluations-IBceAeKT.js} +40 -19
  132. package/dist/eve/index.d.ts +9 -6
  133. package/dist/eve/index.js +4 -4
  134. package/dist/{event-time-CsegxXxB.js → event-time-BGy48400.js} +8 -4
  135. package/dist/{expiry-D4_YKRKD.js → expiry-6XByK0dm.js} +8 -5
  136. package/dist/express/index.d.ts +9 -6
  137. package/dist/express/index.js +9 -6
  138. package/dist/fastify/index.d.ts +16 -10
  139. package/dist/fastify/index.js +8 -5
  140. package/dist/{fetch-adapter-CuhyYwC1.d.ts → fetch-adapter-BIbBAtPZ.d.ts} +9 -6
  141. package/dist/{fetch-adapter-De-u6vhJ.js → fetch-adapter-dPTgJVHd.js} +14 -11
  142. package/dist/fields-D0vUI6dq.js +498 -0
  143. package/dist/{files-acUbNwWt.js → files-B3AA05f1.js} +8 -5
  144. package/dist/{files-D_JIzUrP.js → files-BSjrtIHw.js} +11 -4
  145. package/dist/{fixtures-BTMW6zgU.js → fixtures-A1_sp_tR.js} +15 -6
  146. package/dist/{flags-aaeRAdiD.js → flags-DXjoTVbS.js} +2 -2
  147. package/dist/{freeze-CrU8nQeX.js → freeze-jjan0lCv.js} +4 -1
  148. package/dist/{from-snapshot-Bz469dIh.js → from-snapshot-DCakWRsr.js} +18 -15
  149. package/dist/gen-BFfzZSLH.js +58 -0
  150. package/dist/gen-BtfFWGbz.js +827 -0
  151. package/dist/{generate-3FNO5P5Q.js → generate-CRVV5V7l.js} +14 -8
  152. package/dist/generate-CezbCaTI.js +275 -0
  153. package/dist/{grantee-BrRANrpT.js → grantee-Dke-9rd1.js} +4 -4
  154. package/dist/{grantee-conditions-C6P1Tvol.js → grantee-conditions-BrYPe-w0.js} +12 -12
  155. package/dist/{grantee-match-0RtHWQDx.js → grantee-match-7RZZvoT_.js} +12 -6
  156. package/dist/{graph-sql-B-dsAT6j.d.ts → graph-sql-BwFC4Qjs.d.ts} +3 -3
  157. package/dist/h3/index.d.ts +10 -7
  158. package/dist/h3/index.js +3 -3
  159. package/dist/headers-B9jQxjtW.d.ts +10 -0
  160. package/dist/{helpers-DY3vXuGs.js → helpers-DJicaG6f.js} +40 -28
  161. package/dist/hono/index.d.ts +16 -10
  162. package/dist/hono/index.js +5 -5
  163. package/dist/{hosted-XBgU6RGT.js → hosted-D0IzESu_.js} +42 -21
  164. package/dist/{hosted-BmjzxQhp.d.ts → hosted-DVxlLZMe.d.ts} +33 -21
  165. package/dist/{http-ujKm0JXE.js → http-DH94eh6f.js} +4 -4
  166. package/dist/{http-BBoKefeS.js → http-DKLXrFGk.js} +13 -7
  167. package/dist/{http-Ca3Sr5x1.js → http-DOL33cO0.js} +11 -8
  168. package/dist/{import-DB2EG_iy.js → import-ACkOrv6g.js} +6 -6
  169. package/dist/{import-Bz0GefWg.js → import-CST57XLp.js} +64 -51
  170. package/dist/{index-CMiPH2Tv.d.ts → index-BinlXeU-.d.ts} +64 -37
  171. package/dist/{index-BSfRl0hZ.d.ts → index-CV-7DWeD.d.ts} +64 -52
  172. package/dist/{index-BE8y3moU.d.ts → index-DJwEgYzA.d.ts} +127 -82
  173. package/dist/{index-DH9DUDEM.d.ts → index-Dj2qF9VC.d.ts} +54 -30
  174. package/dist/{index-BTkwrK7v.d.ts → index-vYjMrXyK.d.ts} +336 -173
  175. package/dist/{index-DLwcuCN_.d.ts → index-ymept53A.d.ts} +51 -30
  176. package/dist/index.d.ts +22 -22
  177. package/dist/index.js +34 -34
  178. package/dist/{init-B-4t1NzC.js → init-BjuFDYT1.js} +10 -10
  179. package/dist/{init-5TXNji88.js → init-txYTuW9u.js} +5 -5
  180. package/dist/{instance-options-CU0YQCLH.d.ts → instance-options-CoHn-0e8.d.ts} +4 -4
  181. package/dist/{instance-snapshot-CjcwnEiV.js → instance-snapshot-DuWf1cT3.js} +86 -61
  182. package/dist/{instant-BluqDvyS.js → instant-DK3Iz83e.js} +2 -2
  183. package/dist/{internals-Dk8A8fX3.js → internals-B3IgHrvo.js} +6 -3
  184. package/dist/{json-schema-B-vAwlde.js → json-schema-BPGa-RjQ.js} +9 -3
  185. package/dist/{json-schema-CN_iLFH2.d.ts → json-schema-BfXgnRNT.d.ts} +4 -4
  186. package/dist/jwt/index.d.ts +57 -27
  187. package/dist/jwt/index.js +24 -21
  188. package/dist/{kernel-DVExUwkp.js → kernel-qv4cr9w8.js} +32 -23
  189. package/dist/kysely/index.d.ts +49 -33
  190. package/dist/kysely/index.js +9 -7
  191. package/dist/{live-options-BaAFCIiu.js → live-options-BBIT68le.js} +2 -2
  192. package/dist/{load-DxroEzH1.js → load-DjSU5KXO.js} +6 -6
  193. package/dist/load-Dm0pSYH3.js +1 -0
  194. package/dist/{login-ClSJh5t5.js → login-CfImTJGb.js} +4 -4
  195. package/dist/{login-WC9HPJpU.js → login-CgfCTO3F.js} +16 -9
  196. package/dist/{manifest-Dv6q4i5s.js → manifest-B2QPh19C.js} +49 -38
  197. package/dist/{manifest-BVhExYhw.d.ts → manifest-CzzWtnAb.d.ts} +126 -31
  198. package/dist/{manifest-schema-Cv492Qev.js → manifest-schema-2r37XRhD.js} +44 -3
  199. package/dist/{manifest-B79YuF2T.js → manifest-wg8WkkpD.js} +6 -6
  200. package/dist/{map-claims-etGIS_Dv.js → map-claims-C-nv08_n.js} +16 -9
  201. package/dist/{map-error-BQGyDm_M.js → map-error-pasIGqMT.js} +7 -7
  202. package/dist/{markers-C6joDI3o.js → markers-BeHZ4x9Q.js} +20 -5
  203. package/dist/mcp/index.d.ts +114 -61
  204. package/dist/mcp/index.js +70 -40
  205. package/dist/{migrate-Dodel0IJ.js → migrate-B7oP_sQU.js} +35 -17
  206. package/dist/module-values-BJTBdo6y.js +107 -0
  207. package/dist/nest/index.d.ts +23 -13
  208. package/dist/nest/index.js +18 -11
  209. package/dist/next/client.d.ts +5 -2
  210. package/dist/next/client.js +1 -1
  211. package/dist/next/index.d.ts +79 -26
  212. package/dist/next/index.js +121 -10
  213. package/dist/next/plugin.d.ts +1 -1
  214. package/dist/next/plugin.js +4 -3
  215. package/dist/node/index.d.ts +5 -5
  216. package/dist/node/index.js +3 -3
  217. package/dist/{ocsf-BFp-PZZA.js → ocsf-TcjRBgIs.js} +15 -5
  218. package/dist/openai/index.d.ts +13 -7
  219. package/dist/openai/index.js +3 -3
  220. package/dist/openapi/index.d.ts +51 -30
  221. package/dist/openapi/index.js +2 -2
  222. package/dist/{openapi-ztVaux6j.js → openapi-BGeuunWC.js} +23 -14
  223. package/dist/{openapi-DMocl1bh.js → openapi-BIpw3Mb7.js} +4 -5
  224. package/dist/{openapi-Ddb4628T.js → openapi-BOsx0xn9.js} +33 -18
  225. package/dist/{operation-findings-kRcEp8lE.js → operation-findings-CXtFzlKJ.js} +3 -3
  226. package/dist/{operations-BNLes61x.d.ts → operations-Ci_rT6Uo.d.ts} +10 -7
  227. package/dist/orpc/index.d.ts +68 -14
  228. package/dist/orpc/index.js +62 -13
  229. package/dist/otel/index.d.ts +7 -4
  230. package/dist/otel/index.js +8 -5
  231. package/dist/{output-DgSDLrta.js → output-DV5dwOTs.js} +9 -5
  232. package/dist/output-files-BHOIlrfD.js +1 -0
  233. package/dist/{output-files-CCMdcFWb.js → output-files-BIQ_9pIs.js} +29 -17
  234. package/dist/ownership-DA5YdYTm.js +1059 -0
  235. package/dist/{parse-Ddhz2xf4.js → parse-1_ZheTW5.js} +16 -13
  236. package/dist/parse-local-manifest-CCmbhnxP.d.ts +10 -0
  237. package/dist/{parse-local-manifest-T1Q8X3A2.js → parse-local-manifest-DEiCF4ah.js} +19 -7
  238. package/dist/{parse-request-D_tUXG6M.js → parse-request-CwCZpyjV.js} +7 -8
  239. package/dist/{paths-DXSHAMIa.js → paths-CUvURzHp.js} +4 -1
  240. package/dist/pdp/index.d.ts +9 -6
  241. package/dist/pdp/index.js +20 -13
  242. package/dist/{peer-DOzzMfZL.js → peer-C9LvBCcb.js} +1 -1
  243. package/dist/{peer-12Q5I_RH.js → peer-Q0fuZ6hx.js} +9 -3
  244. package/dist/{permdock-BfWEeMqk.js → permdock-BvjivVb9.js} +200 -140
  245. package/dist/{permdock-Dco6dyCK.d.ts → permdock-CprAPN3w.d.ts} +260 -129
  246. package/dist/{permission-registry-DpPtSKNZ.js → permission-registry-B8tYxPIt.js} +23 -10
  247. package/dist/{permission-types-DhNEmoRG.d.ts → permission-types-CAY-GU7e.d.ts} +127 -41
  248. package/dist/{permissions-CoqCOfJ3.d.ts → permissions-Bx6UI8n1.d.ts} +6 -3
  249. package/dist/{permissions-CyH2MV_B.js → permissions-CVXmRILq.js} +3 -3
  250. package/dist/{permissions-DArULThq.js → permissions-CYcHj_w7.js} +8 -5
  251. package/dist/pg-DQTqRrou.js +60 -0
  252. package/dist/{pins-8ILTftC9.js → pins-nqarl3oE.js} +4 -1
  253. package/dist/{pkce-5h8NgMQJ.js → pkce-CnmmYqUZ.js} +1 -1
  254. package/dist/{policy-B7dg_yzu.d.ts → policy-BycVKnXv.d.ts} +5 -5
  255. package/dist/{policy-DaJy4nK4.js → policy-CLQ8__GF.js} +43 -23
  256. package/dist/{policy-from-catalog-DFWYkNdu.js → policy-from-catalog-CU3An8uP.js} +28 -25
  257. package/dist/{policy-module-CTlwMvLI.js → policy-module-xym9fnSq.js} +12 -6
  258. package/dist/{policy-types-B-F-qAZk.d.ts → policy-types-DGIO_gxq.d.ts} +782 -357
  259. package/dist/{postgres-store-BL9M_CA1.js → postgres-store-DcyrPS-r.js} +43 -16
  260. package/dist/{postgrest-r5faDIzD.js → postgrest-5Dr3W64L.js} +84 -86
  261. package/dist/{postgrest-CYacM_u7.d.ts → postgrest-D5nUGm-c.d.ts} +55 -35
  262. package/dist/powersync-B701tvhE.js +1 -0
  263. package/dist/{powersync-13odBwiM.js → powersync-Bg8u-JcR.js} +3 -3
  264. package/dist/{powersync-53ryOZip.js → powersync-CJrT1DSc.js} +127 -69
  265. package/dist/preset/index.d.ts +38 -28
  266. package/dist/preset/index.js +1 -1
  267. package/dist/{preset-CHTbd-DQ.js → preset-BjLzeFpp.js} +56 -32
  268. package/dist/{principal-source-pHneukrx.js → principal-source-C6N60GtM.js} +10 -10
  269. package/dist/prisma/index.d.ts +69 -41
  270. package/dist/prisma/index.js +21 -17
  271. package/dist/{problem-CTviyH5L.js → problem-BVLHFK33.js} +41 -21
  272. package/dist/{problem-details-cn5X30gZ.js → problem-details-CLDgX1KV.js} +13 -4
  273. package/dist/{problem-types-CJ2325SZ.js → problem-types-DSsRfONQ.js} +4 -1
  274. package/dist/{prompt-DwtVemER.js → prompt-BYc6drYW.js} +4 -1
  275. package/dist/protected-action-D8x73IGm.d.ts +58 -0
  276. package/dist/protected-action-DUYqb-Ma.js +80 -0
  277. package/dist/{protected-DXE3cQYg.js → protected-action-QEA8arRB.js} +48 -14
  278. package/dist/{provider-BQsTYYy0.js → provider-C55OGXJ7.js} +5 -4
  279. package/dist/{provider-Csk-THAn.d.ts → provider-DfLeek9O.d.ts} +1 -1
  280. package/dist/{provider-store-IgqQipCO.js → provider-store-CaTv00tr.js} +13 -9
  281. package/dist/{pull-CN5OLxrF.js → pull-2nJr0qg_.js} +12 -11
  282. package/dist/pull-C3EEGzSw.js +1 -0
  283. package/dist/{push-tVdG8dUL.js → push-Bn-lMEmI.js} +19 -13
  284. package/dist/{pushed-policy-CmYeSQqq.js → pushed-policy-CDuOL2de.js} +10 -7
  285. package/dist/{pushed-policy-BbcY9r_4.d.ts → pushed-policy-CryQheKq.d.ts} +12 -6
  286. package/dist/react/index.d.ts +9 -8
  287. package/dist/react/index.js +7 -6
  288. package/dist/react/provider-client.d.ts +1 -1
  289. package/dist/react/provider-client.js +1 -1
  290. package/dist/react-native/index.d.ts +94 -55
  291. package/dist/react-native/index.js +200 -61
  292. package/dist/{refs-CNJBiTFo.js → refs-C8BKxc_e.js} +2 -2
  293. package/dist/{relation-walk-3OyDBF0S.js → relation-walk-DK_gkgL7.js} +12 -9
  294. package/dist/{relations-BnCWnJGI.js → relations-BxvRvDHK.js} +3 -3
  295. package/dist/{replay-Du1tJjG7.js → replay-BU09ad4L.js} +1 -1
  296. package/dist/{replay-DCDD_ZfL.d.ts → replay-Bs9Df2fQ.d.ts} +1 -1
  297. package/dist/{request-context-BykKLmyE.js → request-context-Duzdf0cd.js} +8 -8
  298. package/dist/{request-schema-CMreVuFM.js → request-schema-DhX7UbfQ.js} +4 -1
  299. package/dist/resend/index.d.ts +34 -28
  300. package/dist/resend/index.js +29 -29
  301. package/dist/resolve-names-ConCSj1y.js +201 -0
  302. package/dist/{resource-relations-D_jw0BFx.js → resource-relations-8-pCScBO.js} +18 -9
  303. package/dist/{retire-Wj6dkyDE.js → retire-B2xffQgY.js} +15 -6
  304. package/dist/{revocations-R07lFBnX.d.ts → revocations-BaUXHM1N.d.ts} +6 -3
  305. package/dist/{rls-Ck_PocSp.js → rls-Ba9wN0SP.js} +13 -6
  306. package/dist/{rls-CxBZb4rZ.js → rls-Cx0dtsB7.js} +310 -128
  307. package/dist/{role-builder-C1VJzvcr.js → role-builder-BK2-T6oD.js} +41 -20
  308. package/dist/{row-conditions-h2HythXQ.js → row-conditions-BAGHOmVq.js} +4 -3
  309. package/dist/{rpc-Bk1bE-ch.js → rpc-vHIwyXCp.js} +8 -5
  310. package/dist/run-Ck22anC2.js +1 -0
  311. package/dist/{run-uLD2aWuO.js → run-PbRlXTfh.js} +26 -23
  312. package/dist/{run-ticket-BpNi7BCi.d.ts → run-ticket-B2o2Kxz8.d.ts} +29 -14
  313. package/dist/{run-ticket-B5d_63Ma.js → run-ticket-Dv7aF7Dk.js} +9 -9
  314. package/dist/{runtime-Vif3_-zf.js → runtime-BGnrOkVH.js} +5 -2
  315. package/dist/{saas-Az_Kz-4D.js → saas-DK4V-3Is.js} +42 -29
  316. package/dist/{scan-DSljDE1Y.js → scan-CRTj6fke.js} +1 -1
  317. package/dist/{schema-B4v0Qrac.js → schema-BOJjqlWL.js} +3 -2
  318. package/dist/{schema-gIcCx7zM.js → schema-BTsE1WRT.js} +8 -4
  319. package/dist/scim/index.d.ts +2 -2
  320. package/dist/scim/index.js +2 -2
  321. package/dist/{scim-C7JYhySg.js → scim-D8YupzX1.js} +2 -2
  322. package/dist/{scim-YNieBO1U.js → scim-jJBJ7g1Z.js} +33 -15
  323. package/dist/{scopes-BHsc-wp-.js → scopes-0Up_UA2t.js} +41 -23
  324. package/dist/server/index.d.ts +11 -11
  325. package/dist/server/index.js +12 -12
  326. package/dist/{server-Bnga6I50.js → server-3cVlTLde.js} +31 -31
  327. package/dist/{server-types-C4gZUEZy.d.ts → server-types-CyRN0-Cd.d.ts} +88 -46
  328. package/dist/{sha256-D9ihqmvd.js → sha256-C-4WXKIu.js} +4 -3
  329. package/dist/{shared-fMKOv8hP.js → shared-Afctg7B0.js} +65 -32
  330. package/dist/{shared-C8LjUdVU.js → shared-l0oGGetg.js} +9 -6
  331. package/dist/{signals-D3NcTKUS.js → signals-B1vHR3fN.js} +2 -2
  332. package/dist/{sink-Cp_Eot9W.d.ts → sink-B5zoUW_O.d.ts} +44 -20
  333. package/dist/{sink-BEZSlMS_.js → sink-D9_vh372.js} +32 -21
  334. package/dist/{skills-g_3BS9NC.js → skills-C9uKfSF5.js} +3 -3
  335. package/dist/{skills-Dcjw9_1C.js → skills-CQQcuGBi.js} +12 -8
  336. package/dist/{snapshot-CbGmYiJx.js → snapshot-CXlzi69u.js} +21 -18
  337. package/dist/{snapshot-cache-Pahd3IYJ.d.ts → snapshot-cache-BjAWkchD.d.ts} +21 -12
  338. package/dist/{snapshot-cache-DT2Kx1F8.js → snapshot-cache-Bx_4xC_6.js} +14 -11
  339. package/dist/solid/index.d.ts +55 -16
  340. package/dist/solid/index.js +46 -12
  341. package/dist/solid-start/index.d.ts +30 -12
  342. package/dist/solid-start/index.js +3 -3
  343. package/dist/{sources-B-zYB4GS.js → sources-CMAM-2A3.js} +46 -27
  344. package/dist/{sources-DEEuGb8S.d.ts → sources-CWG32C0G.d.ts} +126 -53
  345. package/dist/{sql-B96movIM.js → sql-0WjxIp9g.js} +28 -7
  346. package/dist/{sql-CDEPCA0g.d.ts → sql-B80DFdpG.d.ts} +2 -2
  347. package/dist/{src-DLFrtrrC.js → src-C_pi2Rnh.js} +292 -101
  348. package/dist/ssf/index.d.ts +3 -3
  349. package/dist/ssf/index.js +47 -35
  350. package/dist/{standard-webhooks-DgFFD-Ga.js → standard-webhooks-D67a3nzk.js} +5 -5
  351. package/dist/{standard-webhooks-B_qRg0ws.d.ts → standard-webhooks-DOYEuOLx.d.ts} +7 -7
  352. package/dist/{store-DSP9oGvh.js → store-RNFvaJJv.js} +32 -26
  353. package/dist/{store-options-B_poyYvg.js → store-options-Dil3lraY.js} +105 -15
  354. package/dist/stores-DZJvxFIZ.d.ts +59 -0
  355. package/dist/{stores-BqEuHC05.js → stores-DxZWDXCs.js} +42 -5
  356. package/dist/{stream-2Vwhl7Er.d.ts → stream-9y9qw51m.d.ts} +4 -3
  357. package/dist/{stream-CvdUS9V1.js → stream-CDvF0sJm.js} +5 -5
  358. package/dist/{style-Ds1gNm77.js → style-DblOtSga.js} +1 -1
  359. package/dist/{style-Cqo7-73x.js → style-Ds11Hmk4.js} +2 -1
  360. package/dist/{subject-settings-CkEwrw3W.js → subject-settings-8sH5HlII.js} +8 -4
  361. package/dist/{row-check-Dt35czLy.d.ts → subject-settings-vNW8qmUH.d.ts} +30 -18
  362. package/dist/supabase/index.d.ts +48 -38
  363. package/dist/supabase/index.js +5 -5
  364. package/dist/supabase/middleware.d.ts +19 -13
  365. package/dist/supabase/middleware.js +7 -7
  366. package/dist/{supabase--0aJdLEd.js → supabase-DnMMg5Fn.js} +79 -35
  367. package/dist/{supabase-Bqp7iIY2.js → supabase-SBs3MYUE.js} +3 -3
  368. package/dist/supabase-hook-C0FyEACZ.js +1 -0
  369. package/dist/{supabase-hook-Dg0SrQWR.js → supabase-hook-CrgU06WH.js} +175 -196
  370. package/dist/{supautils-MESd81bF.js → supautils-ByezN3b8.js} +385 -219
  371. package/dist/{support-session-Cna49-3f.js → support-session-BsmPCbz8.js} +21 -21
  372. package/dist/svelte/PermissionBoundary.svelte +2 -6
  373. package/dist/svelte/Protected.svelte +2 -8
  374. package/dist/svelte/index.d.ts +9 -8
  375. package/dist/svelte/index.js +10 -9
  376. package/dist/svelte/runtime.d.ts +4 -4
  377. package/dist/svelte/runtime.js +4 -4
  378. package/dist/svelte/source.d.ts +9 -8
  379. package/dist/svelte/source.js +6 -5
  380. package/dist/sveltekit/index.d.ts +30 -12
  381. package/dist/sveltekit/index.js +2 -2
  382. package/dist/{ownership-Z2LpxsGa.js → tables-BqrxBCir.js} +641 -1104
  383. package/dist/tanstack-start/index.d.ts +22 -10
  384. package/dist/tanstack-start/index.js +2 -2
  385. package/dist/{target-Bw37TFNA.js → target-qdEAnnhU.js} +6 -6
  386. package/dist/{tenancy-CmeBQ6Nv.js → tenancy-5d1zVBvK.js} +25 -19
  387. package/dist/terminal/index.d.ts +23 -14
  388. package/dist/terminal/index.js +17 -20
  389. package/dist/testing/core.d.ts +1 -1
  390. package/dist/testing/core.js +1 -1
  391. package/dist/testing/fixtures/index.d.ts +8 -5
  392. package/dist/testing/fixtures/index.js +78 -17
  393. package/dist/testing/index.d.ts +225 -141
  394. package/dist/testing/index.js +352 -234
  395. package/dist/testing/saas/index.d.ts +43 -27
  396. package/dist/testing/saas/index.js +2 -2
  397. package/dist/testing/saas/permissions.d.ts +1 -1
  398. package/dist/testing/saas/permissions.js +1 -1
  399. package/dist/{text-diff-DhITNCnD.js → text-diff-BtfSmdUo.js} +2 -2
  400. package/dist/{thenable-yD7SabqG.js → thenable-BNSM1U2R.js} +12 -3
  401. package/dist/{time-DkWjdL98.js → time-nR1JesoH.js} +32 -8
  402. package/dist/{token-2qYDvXz2.js → token-DC9EQiet.js} +14 -12
  403. package/dist/{tool-refusal-reAhIzdl.js → tool-refusal-Qpjs_W6M.js} +5 -2
  404. package/dist/trpc/index.d.ts +11 -8
  405. package/dist/trpc/index.js +15 -9
  406. package/dist/type-helpers-c7Xo_2Cu.d.ts +50 -0
  407. package/dist/{types-CfiKC5aN.d.ts → types-B2efzoSX.d.ts} +14 -11
  408. package/dist/{types-CIeZcG8v.d.ts → types-B6ExllNo.d.ts} +2 -2
  409. package/dist/{types-DBHftjgS.d.ts → types-BB-zWDcR.d.ts} +45 -33
  410. package/dist/{types-BfVmNJO5.d.ts → types-BMVDHvI0.d.ts} +128 -50
  411. package/dist/{types-DXmwu78Z.d.ts → types-CEinc15V.d.ts} +31 -14
  412. package/dist/{types-g7Oy6Zg4.d.ts → types-CN0LsqbK.d.ts} +47 -24
  413. package/dist/{types-CeIscIKp.d.ts → types-CWBsAwqn.d.ts} +23 -12
  414. package/dist/{types-DqzsnlSA.js → types-CcUXciSj.js} +17 -5
  415. package/dist/{types-BWZybqs9.d.ts → types-CzOeVvcC.d.ts} +384 -203
  416. package/dist/{types-DC44-hqb.d.ts → types-DLvhVm1r.d.ts} +59 -32
  417. package/dist/{types-D3A19w4A.d.ts → types-DlelvQk4.d.ts} +22 -13
  418. package/dist/{types-cTos-H7p.d.ts → types-DsHGPtkR.d.ts} +68 -32
  419. package/dist/{types-BXMYB7BY.d.ts → types-ZzRGoViD.d.ts} +77 -24
  420. package/dist/{types-CQVEQawv.d.ts → types-rCRV4Ge-.d.ts} +24 -14
  421. package/dist/types-tQB2CEnY.d.ts +262 -0
  422. package/dist/unplugin/index.d.ts +1 -1
  423. package/dist/unplugin/index.js +2 -2
  424. package/dist/usage-0hjZPIRX.js +1 -0
  425. package/dist/{usage-Bybmck7f.js → usage-B9EtHWLa.js} +50 -26
  426. package/dist/{usage-CDaLXCfL.js → usage-CBzgwfIs.js} +2 -2
  427. package/dist/{validation-error-ZfUHbKvf.js → validation-error-CYg2kJEw.js} +4 -1
  428. package/dist/{validation-error-CQpoquwj.d.ts → validation-error-uvp-kyfO.d.ts} +5 -2
  429. package/dist/{validity-CZ7-y0Cj.js → validity-Buc7w8E9.js} +13 -10
  430. package/dist/{verifier-DHuh-okk.js → verifier-DUV6pLqZ.js} +10 -4
  431. package/dist/{verify-pe8rL_Qw.js → verify-DlUcTDBz.js} +148 -487
  432. package/dist/version-DMQ0dnN5.js +48 -0
  433. package/dist/version-DizhmD72.js +1 -0
  434. package/dist/{views-BB8E9dTP.js → views-CD8wuL4Z.js} +19 -6
  435. package/dist/{vocabulary-Bg3eeT2H.d.ts → vocabulary-DEJ5j4mR.d.ts} +7 -4
  436. package/dist/vue/index.d.ts +71 -22
  437. package/dist/vue/index.js +50 -13
  438. package/dist/{waiter-DwEyouan.d.ts → waiter-CqUKX6CY.d.ts} +13 -10
  439. package/dist/{waiter-BGUtGYoU.js → waiter-aBLM63_f.js} +1 -1
  440. package/dist/{watch-C-4VmFlL.js → watch-BFDKqmUa.js} +8 -8
  441. package/dist/watch-ClLuO2TL.js +1 -0
  442. package/dist/webmcp/index.d.ts +11 -11
  443. package/dist/webmcp/index.js +8 -5
  444. package/dist/{where-scope-wq2coopv.js → where-scope-DlCdCM_8.js} +24 -18
  445. package/dist/{who-can-BwNsI_Js.js → who-can-BoDJm0Nc.js} +23 -20
  446. package/dist/workflow/index.d.ts +3 -3
  447. package/dist/workflow/index.js +13 -13
  448. package/dist/workflow-sdk/index.d.ts +19 -13
  449. package/dist/workflow-sdk/index.js +6 -6
  450. package/dist/{wrap-CiSc_KCq.js → wrap-B2wziJI_.js} +4 -4
  451. package/dist/{wrap-B6R0cMRL.d.ts → wrap-DxXB54Wu.d.ts} +8 -5
  452. package/package.json +8 -8
  453. package/schemas/catalog-v1.json +3 -0
  454. package/schemas/supabase-manifest-v1.json +33 -1
  455. package/skills/permdock-credentials/references/tokens-keys-links.md +8 -6
  456. package/skills/permdock-data/references/queries-and-rls.md +2 -1
  457. package/skills/permdock-tenancy/references/ownership-and-custom-roles.md +2 -2
  458. package/skills/permdock-wire/references/adapters.md +16 -23
  459. package/dist/catalog-BCCjSAdH.js +0 -1
  460. package/dist/collect-k_Dulxr5.js +0 -1
  461. package/dist/config-CoQHDrDi.js +0 -166
  462. package/dist/denied-text-D4qkEtFz.d.ts +0 -19
  463. package/dist/fields-ClcQLrVc.js +0 -238
  464. package/dist/generate-CNU1pIOo.js +0 -171
  465. package/dist/headers-BIjfMaoC.js +0 -8
  466. package/dist/headers-CIbDTUTK.d.ts +0 -7
  467. package/dist/load-DrMHXzgN.js +0 -1
  468. package/dist/output-files-DPAY7-GX.js +0 -1
  469. package/dist/package-root-Dk_ETdkp.js +0 -31
  470. package/dist/parse-local-manifest-e4mdwAKd.d.ts +0 -10
  471. package/dist/policies-B2lZIurj.js +0 -295
  472. package/dist/powersync-CExtTLyA.js +0 -1
  473. package/dist/problem-details-Tcfmj3bV.d.ts +0 -7
  474. package/dist/protected-BwZYL1X_.d.ts +0 -39
  475. package/dist/pull-Cty6Ovyu.js +0 -1
  476. package/dist/run-Bz7DXGEv.js +0 -1
  477. package/dist/stores-BAZwSYZA.d.ts +0 -31
  478. package/dist/supabase-hook-DJxC4PoP.js +0 -1
  479. package/dist/types-CKV71kKh.d.ts +0 -172
  480. package/dist/usage-y-kBNdqs.js +0 -1
  481. package/dist/version-CEbQ5UeM.js +0 -18
  482. package/dist/version-DXkYUISx.js +0 -1
  483. package/dist/watch-Bd9mx3rd.js +0 -1
@@ -1,5 +1,5 @@
1
- import { A as MetaValue, O as AppData, b as ResourceNode, d as PermissionKind, f as PermissionTree, k as AppDataSchema, u as Permission } from "./permission-types-DhNEmoRG.js";
2
- import { a as RoleTree, i as RoleMeta, n as PlanTree, r as Role, t as Plan } from "./vocabulary-Bg3eeT2H.js";
1
+ import { M as AppData, N as AppDataSchema, P as MetaValue, b as ResourceNode, d as PermissionKind, f as PermissionTree, k as POLICY_SCOPES, u as Permission } from "./permission-types-CAY-GU7e.js";
2
+ import { a as RoleTree, i as RoleMeta, n as PlanTree, r as Role, t as Plan } from "./vocabulary-DEJ5j4mR.js";
3
3
  //#region src/conditions/ast.d.ts
4
4
  type ConditionRef = {
5
5
  readonly ref: string;
@@ -64,27 +64,34 @@ type RelatedCondition = {
64
64
  readonly op: "related";
65
65
  readonly resource: string;
66
66
  readonly relation: string;
67
- /** The row's own id field, or (with `parent` or `hops`) the field holding the next instance's id. */
67
+ /**
68
+ * The row's own id field, or (with `parent` or `hops`) the field holding the
69
+ * next instance's id.
70
+ */
68
71
  readonly field: string;
69
- /** Parent hops walked above the first `resource` instance; `0` reads only that instance. */
72
+ /**
73
+ * Parent hops walked above the first `resource` instance; `0` reads only that
74
+ * instance.
75
+ */
70
76
  readonly depth: number;
71
77
  /** The row is a child of `resource`, reached through `field`. */
72
78
  readonly parent?: true;
73
79
  /**
74
- * To-one links from the row to `resource`: `field` points at the first
75
- * hop's resource, each later hop follows `link` on the resource before it,
76
- * and the last hop's resource is `resource`.
80
+ * To-one links from the row to `resource`: `field` points at the first hop's
81
+ * resource, each later hop follows `link` on the resource before it, and the
82
+ * last hop's resource is `resource`.
77
83
  */
78
84
  readonly hops?: readonly RelatedHop[];
79
85
  /**
80
- * The `resource` instances the subject holds a resource role on; replaces
81
- * the `relation` lookup (`relation` is then empty).
86
+ * The `resource` instances the subject holds a resource role on; replaces the
87
+ * `relation` lookup (`relation` is then empty).
82
88
  */
83
89
  readonly ids?: readonly string[];
84
90
  readonly permission?: string;
85
91
  /**
86
92
  * The row's boolean column that keeps ancestor grants out: with `parent` or
87
- * `hops`, a restricted row matches nothing; without, the walk stops at the row.
93
+ * `hops`, a restricted row matches nothing; without, the walk stops at the
94
+ * row.
88
95
  */
89
96
  readonly restricted?: string;
90
97
  readonly restrictedAncestors?: RestrictedAncestors;
@@ -117,10 +124,10 @@ type SqlFunctionCondition = {
117
124
  readonly twin: Condition;
118
125
  };
119
126
  /**
120
- * The request's session was checked against the Auth server while the
121
- * subject was resolved (`liveSession: true`), not only verified from the
122
- * token: a revoked session still verifies until `exp`. Written
123
- * `{ subject: { session: { live: true } } }`.
127
+ * The request's session was checked against the Auth server while the subject
128
+ * was resolved (`liveSession: true`), not only verified from the token: a
129
+ * revoked session still verifies until `exp`. Written `{ subject: { session: {
130
+ * live: true } } }`.
124
131
  */
125
132
  type LiveSessionCondition = {
126
133
  readonly op: "liveSession";
@@ -145,14 +152,18 @@ type FieldOperator = {
145
152
  readonly notIn?: unknown;
146
153
  readonly isNull?: boolean;
147
154
  };
148
- type WhereShorthand<T = Record<string, unknown>> = {
155
+ type WhereShorthand<T = Record<string, unknown>> = unknown extends T ? RowWhere<Record<string, unknown>> : RowWhere<T>;
156
+ type RowWhere<T> = {
149
157
  readonly and?: readonly WhereShorthand<T>[];
150
158
  readonly or?: readonly WhereShorthand<T>[];
151
159
  readonly not?: WhereShorthand<T>;
152
160
  } & ("subject" extends keyof T ? { readonly [K in keyof T as Exclude<K, "subject">]?: FieldWhere<T[K]>; } & {
153
161
  readonly subject?: SubjectWhere | FieldWhere<T["subject"]>;
154
162
  } : { readonly [K in keyof T]?: FieldWhere<T[K]>; } & {
155
- /** Holds only when the resolver checked the session live (`liveSession: true`). */
163
+ /**
164
+ * Holds only when the resolver checked the session live (`liveSession:
165
+ * true`).
166
+ */
156
167
  readonly subject?: SubjectWhere;
157
168
  });
158
169
  type SubjectWhere = {
@@ -173,11 +184,20 @@ type FieldWhere<V> = V | FieldOperator | {
173
184
  * credential kinds, delivery channels) stays closed.
174
185
  */
175
186
  type OpenUnion<T extends string> = T | (string & NonNullable<unknown>);
176
- /** `actor.kind`: the values PermDock's adapters set, or an integrator's own; a policy delegation matches it by equality. */
187
+ /**
188
+ * `actor.kind`: the values PermDock's adapters set, or an integrator's own; a
189
+ * policy delegation matches it by equality.
190
+ */
177
191
  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">;
178
- /** The adapter a decision event names: a PermDock entry, or an integrator's own adapter. */
192
+ /**
193
+ * The adapter a decision event names: a PermDock entry, or an integrator's own
194
+ * adapter.
195
+ */
179
196
  type AdapterId = OpenUnion<"server" | "next" | "hono" | "express" | "fastify" | "elysia" | "nest" | "node" | "h3" | "sveltekit" | "astro" | "solid-start" | "tanstack-start" | "trpc" | "orpc" | "supabase-middleware" | "convex" | "authzen" | "mcp" | "a2a" | "agent" | "ai-sdk" | "claude-agent" | "openai" | "eve" | "terminal" | "webmcp" | "workflow" | "chat" | "delivery">;
180
- /** How a membership was obtained (`membership.via`); `viaOnly` and support rules match it by equality. */
197
+ /**
198
+ * How a membership was obtained (`membership.via`); `viaOnly` and support rules
199
+ * match it by equality.
200
+ */
181
201
  type MembershipVia = OpenUnion<"direct" | "contact" | "credential" | "elevated" | "feed" | "link" | "share" | "support" | "support-session" | "scim">;
182
202
  //#endregion
183
203
  //#region src/core/subject.d.ts
@@ -210,8 +230,8 @@ type Assurance = {
210
230
  /**
211
231
  * Roles held in one scope instance (`scope` + `id`, with the id of every
212
232
  * ancestor scope in `within`) or on one resource (`on`). Evaluation only sees
213
- * the canonical form; `tenant` / `team` are accepted as input for the first
214
- * and second declared scope and normalised away.
233
+ * the canonical form; `tenant` / `team` are accepted as input for the first and
234
+ * second declared scope and normalised away.
215
235
  */
216
236
  type Membership = {
217
237
  readonly scope?: string;
@@ -222,26 +242,44 @@ type Membership = {
222
242
  readonly id: string;
223
243
  };
224
244
  readonly roles: readonly string[];
225
- /** Roles the holder may activate here but does not hold; `permdock.activate` writes an elevated membership. */
245
+ /**
246
+ * Roles the holder may activate here but does not hold; `permdock.activate`
247
+ * writes an elevated membership.
248
+ */
226
249
  readonly eligible?: readonly string[];
227
250
  readonly via?: MembershipVia;
228
251
  readonly expiresAt?: number;
229
- /** The principal id that wrote this membership: who elevated, consented to or granted the access. */
252
+ /**
253
+ * The principal id that wrote this membership: who elevated, consented to or
254
+ * granted the access.
255
+ */
230
256
  readonly grantedBy?: string;
231
- /** Free text recording why the membership was written: the activation or consent justification. */
257
+ /**
258
+ * Free text recording why the membership was written: the activation or
259
+ * consent justification.
260
+ */
232
261
  readonly reason?: string;
233
- /** A subgroup the holder belongs to inside the instance (`vendor-support`); a `junctionMembershipSource` group column fills it. */
262
+ /**
263
+ * A subgroup the holder belongs to inside the instance (`vendor-support`); a
264
+ * `junctionMembershipSource` group column fills it.
265
+ */
234
266
  readonly member?: {
235
267
  readonly group: string;
236
268
  };
237
- /** `idp`: the identity provider (SCIM) owns this membership; the application must not edit it. */
269
+ /**
270
+ * `idp`: the identity provider (SCIM) owns this membership; the application
271
+ * must not edit it.
272
+ */
238
273
  readonly managedBy?: "idp";
239
- /** Seats this membership holds (`dev-mode`, `editor`); `plan()` grantees match them inside the active tenant. */
274
+ /**
275
+ * Seats this membership holds (`dev-mode`, `editor`); `plan()` grantees match
276
+ * them inside the active tenant.
277
+ */
240
278
  readonly entitlements?: readonly string[];
241
279
  /**
242
- * Set when the instance or an ancestor instance is suspended: the
243
- * permission keys the membership still grants (`suspension.scopes.<scope>.keep`).
244
- * Every other grant, allow or deny, ignores it, and so do role listings.
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.
245
283
  */
246
284
  readonly keep?: readonly string[];
247
285
  /**
@@ -257,13 +295,16 @@ type Membership = {
257
295
  readonly team?: string;
258
296
  };
259
297
  /**
260
- * One permission a custom role adds or removes. It names a declared
261
- * permission key and carries no condition, approval or limit of its own.
298
+ * One permission a custom role adds or removes. It names a declared permission
299
+ * key and carries no condition, approval or limit of its own.
262
300
  */
263
301
  type CustomRoleGrant = {
264
302
  readonly permission: string;
265
303
  readonly effect?: "allow" | "deny";
266
- /** A level the permission's resource declares (`resource(…, { levels })`); allows only. */
304
+ /**
305
+ * A level the permission's resource declares (`resource(…, { levels })`);
306
+ * allows only.
307
+ */
267
308
  readonly level?: string;
268
309
  };
269
310
  type CustomRoleBody = {
@@ -271,9 +312,9 @@ type CustomRoleBody = {
271
312
  readonly includes?: readonly string[];
272
313
  readonly grants?: readonly CustomRoleGrant[];
273
314
  /**
274
- * Display text and app data, carried onto the role leaf
275
- * `assignableRoles()` returns. `x` is checked by the role tree's
276
- * `defineRoles(…, { x })` schema; an invalid `x` is dropped, not the role.
315
+ * Display text and app data, carried onto the role leaf `assignableRoles()`
316
+ * returns. `x` is checked by the role tree's `defineRoles(…, { x })` schema;
317
+ * an invalid `x` is dropped, not the role.
277
318
  */
278
319
  readonly meta?: RoleMeta;
279
320
  };
@@ -281,7 +322,10 @@ type CustomRoleBody = {
281
322
  type TenantCustomRole = CustomRoleBody & {
282
323
  /** The instance of the first scope that owns the role. */
283
324
  readonly tenant: string;
284
- /** The scope the role is held at; defaults to the first scope. Its ceiling is that scope's assignable roles. */
325
+ /**
326
+ * The scope the role is held at; defaults to the first scope. Its ceiling is
327
+ * that scope's assignable roles.
328
+ */
285
329
  readonly scope?: string;
286
330
  /** Pins the role to one instance of `scope`. */
287
331
  readonly id?: string;
@@ -302,14 +346,17 @@ type GlobalCustomRole = CustomRoleBody & {
302
346
  readonly shared?: undefined;
303
347
  };
304
348
  /**
305
- * A role the platform defines once for every tenant, held on memberships of
306
- * its scope in any tenant. Tenant admins assign it but never edit it. Its
307
- * ceiling is the assignable declared roles of its scope; its name wins over
308
- * a tenant custom role of the same name.
349
+ * A role the platform defines once for every tenant, held on memberships of its
350
+ * scope in any tenant. Tenant admins assign it but never edit it. Its ceiling
351
+ * is the assignable declared roles of its scope; its name wins over a tenant
352
+ * custom role of the same name.
309
353
  */
310
354
  type SharedCustomRole = CustomRoleBody & {
311
355
  readonly shared: true;
312
- /** The scope the role is held at, never `'global'`; defaults to the first scope. */
356
+ /**
357
+ * The scope the role is held at, never `'global'`; defaults to the first
358
+ * scope.
359
+ */
313
360
  readonly scope?: string;
314
361
  readonly tenant?: undefined;
315
362
  readonly id?: undefined;
@@ -320,21 +367,27 @@ type Principal = {
320
367
  readonly id: string;
321
368
  readonly issuer?: string;
322
369
  /**
323
- * `contact`: an external person (a customer contact, a portal user). Only
324
- * its `{ on }` memberships count; it never approves, creates keys or
325
- * publishes, and is read-only unless a role whose `for` lists `contact`
326
- * grants the write.
370
+ * `contact`: an external person (a customer contact, a portal user). Only its
371
+ * `{ on }` memberships count; it never approves, creates keys or publishes,
372
+ * and is read-only unless a role whose `for` lists `contact` grants the
373
+ * write.
327
374
  */
328
375
  readonly kind?: "user" | "service" | "workload" | "link" | "feed" | "contact";
329
376
  readonly roles?: readonly string[];
330
377
  readonly plans?: readonly string[];
331
378
  readonly memberships?: readonly Membership[];
332
- /** The token dropped memberships to stay under its size budget; a `claimsFirst` source reads the rest. */
379
+ /**
380
+ * The token dropped memberships to stay under its size budget; a
381
+ * `claimsFirst` source reads the rest.
382
+ */
333
383
  readonly membershipsTruncated?: boolean;
334
384
  /** The authorization version the token was minted at (`authz_ver`). */
335
385
  readonly authzVersion?: number;
336
386
  readonly tenant?: string;
337
- /** Set by core when a requested tenant is not one the subject holds: the denial is then `no-membership`, not `no-tenant`. Never read from a token. */
387
+ /**
388
+ * Set by core when a requested tenant is not one the subject holds: the
389
+ * denial is then `no-membership`, not `no-tenant`. Never read from a token.
390
+ */
338
391
  readonly unheldTenant?: string;
339
392
  readonly assurance?: Assurance;
340
393
  readonly binding?: Binding;
@@ -344,9 +397,16 @@ type Actor = {
344
397
  readonly id: string;
345
398
  readonly kind: ActorKind;
346
399
  readonly binding?: Binding;
347
- /** `true` denies every permission without `readOnlyHint` (`not-delegated`), with or without a policy delegation. */
400
+ /**
401
+ * `true` denies every permission without `readOnlyHint` (`not-delegated`),
402
+ * with or without a policy delegation.
403
+ */
348
404
  readonly readOnly?: boolean;
349
- /** The stable name the application gives this OAuth client (`ClientNames`), set by the subject resolver from the verified client id; policy delegations match it with `to: { kind, client }`. */
405
+ /**
406
+ * The stable name the application gives this OAuth client (`ClientNames`),
407
+ * set by the subject resolver from the verified client id; policy delegations
408
+ * match it with `to: { kind, client }`.
409
+ */
350
410
  readonly client?: string;
351
411
  readonly [key: string]: unknown;
352
412
  };
@@ -369,7 +429,16 @@ type Subject<TPrincipal extends Principal = Principal> = {
369
429
  readonly context: Readonly<Record<string, unknown>>;
370
430
  readonly session?: string;
371
431
  readonly expiresAt?: number;
372
- /** The token's memberships are behind the source's authorization version: `fresh` permissions deny. */
432
+ /**
433
+ * When the verified token was issued (`iat`), in seconds since the epoch. A
434
+ * `VersionCache` trusts the token's `authzVersion` for its `maxStaleMs` after
435
+ * it.
436
+ */
437
+ readonly issuedAt?: number;
438
+ /**
439
+ * The token's memberships are behind the source's authorization version:
440
+ * `fresh` permissions deny.
441
+ */
373
442
  readonly stale?: true;
374
443
  /**
375
444
  * The resolver checked the session against the Auth server for this request
@@ -381,7 +450,10 @@ type Subject<TPrincipal extends Principal = Principal> = {
381
450
  //#endregion
382
451
  //#region src/core/decision.d.ts
383
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";
384
- /** The `detail` each denial reason carries, where PermDock sets a structured one. */
453
+ /**
454
+ * The `detail` each denial reason carries, where PermDock sets a structured
455
+ * one.
456
+ */
385
457
  type DenialDetails = {
386
458
  readonly limit: LimitDetail;
387
459
  /** The window the inactive allow applies in. */
@@ -413,18 +485,21 @@ type MatchedGrant = {
413
485
  readonly check?: Grant["check"];
414
486
  readonly approval?: "human" | ApprovalRequirement;
415
487
  readonly provider?: string;
416
- /** The hosted policy document fingerprint and grant id, when a hosted grant matched. */
488
+ /**
489
+ * The hosted policy document fingerprint and grant id, when a hosted grant
490
+ * matched.
491
+ */
417
492
  readonly hosted?: HostedGrantRef;
418
493
  /** A break-glass grant overrode a matching deny. */
419
494
  readonly breakGlass?: true;
420
495
  };
421
496
  /**
422
497
  * Something the caller owes alongside a granted action. `over-limit`: a soft
423
- * `limit` was past its count; `near-limit`: usage reached `alertAt`.
424
- * `notify` / `review`: a break-glass grant's declared follow-ups.
425
- * `justify`: the break-glass reason, carried so audit records why.
426
- * `app`: a follow-up the application declared on the grant
427
- * (`allow(p, { obligations })`); PermDock carries it and never acts on it.
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.
428
503
  */
429
504
  type Obligation = {
430
505
  readonly kind: "over-limit" | "near-limit" | "notify" | "review";
@@ -445,8 +520,8 @@ type Quota = {
445
520
  readonly resetsAt: string;
446
521
  };
447
522
  /**
448
- * The `detail` of a `limit` denial: the grant's `count`, its `per` window
449
- * in seconds and when the window resets (RFC 3339).
523
+ * The `detail` of a `limit` denial: the grant's `count`, its `per` window in
524
+ * seconds and when the window resets (RFC 3339).
450
525
  */
451
526
  type LimitDetail = {
452
527
  readonly count: number;
@@ -454,14 +529,13 @@ type LimitDetail = {
454
529
  readonly resetsAt: string;
455
530
  };
456
531
  /**
457
- * Why a candidate grant for the permission was passed over before its
458
- * condition ran: `via-only` (the subject holds no membership of its kind),
459
- * `purpose` (no asserted purpose it lists), `field` (its `fields` do not
460
- * cover the requested field), `grantee` (its `to` did not match and added no
461
- * denial), `role` (a role it names is not held), `validity` (a deny outside
462
- * its `validFrom` / `validUntil`; an inactive allow adds an `inactive-grant`
463
- * denial instead), `break-glass-inactive` (a break-glass grant with no
464
- * asserted purpose).
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).
465
539
  */
466
540
  type TraceSkipReason = "via-only" | "purpose" | "field" | "grantee" | "role" | "validity" | "unknown-level" | "break-glass-inactive";
467
541
  type TraceSkip = {
@@ -469,15 +543,18 @@ type TraceSkip = {
469
543
  readonly permission: string;
470
544
  readonly effect: "allow" | "deny";
471
545
  readonly why: TraceSkipReason;
472
- /** The level a custom role names that its resource does not declare, for `unknown-level`. */
546
+ /**
547
+ * The level a custom role names that its resource does not declare, for
548
+ * `unknown-level`.
549
+ */
473
550
  readonly level?: string;
474
551
  };
475
552
  /**
476
- * What `explain` saw: how many candidate grants it examined before the
477
- * outcome, which allows matched (including the ones a deny overrode), which
478
- * denies matched, and which grants it passed over. `denies[0]` is the deny
479
- * that produced a `deny` outcome, or the deny a break-glass grant lifted.
480
- * Pure local computation; never on a decision event.
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.
481
558
  */
482
559
  type Trace = {
483
560
  readonly evaluated: number;
@@ -504,8 +581,8 @@ type GrantedDecision = {
504
581
  type DeniedDecision = {
505
582
  readonly outcome: "denied";
506
583
  /**
507
- * The key of the permission that was checked. Absent on a denial for a
508
- * check that named no declared permission.
584
+ * The key of the permission that was checked. Absent on a denial for a check
585
+ * that named no declared permission.
509
586
  */
510
587
  readonly permission?: string;
511
588
  readonly denials: readonly Denial[];
@@ -552,7 +629,10 @@ type RelationGrantee = {
552
629
  * to `resource`, then walk its parents only when `depth` is set.
553
630
  */
554
631
  readonly through?: "parent" | readonly string[];
555
- /** Parent hops walked above the first `resource` instance; absent means `DEFAULT_RELATION_DEPTH` for `'parent'` and `0` for links. */
632
+ /**
633
+ * Parent hops walked above the first `resource` instance; absent means
634
+ * `DEFAULT_RELATION_DEPTH` for `'parent'` and `0` for links.
635
+ */
556
636
  readonly depth?: number;
557
637
  };
558
638
  type PlanGrantee = {
@@ -601,23 +681,26 @@ type UserApprover = {
601
681
  readonly id: string;
602
682
  };
603
683
  /**
604
- * Whoever holds `permission` in the request's tenant, through any role,
605
- * custom roles included. Checked only through verdict facts
606
- * (`ApprovalVerdict.permissions`) that the handler computes from the
607
- * approver's own instance.
684
+ * Whoever holds `permission` in the request's tenant, through any role, custom
685
+ * roles included. Checked only through verdict facts
686
+ * (`ApprovalVerdict.permissions`) that the handler computes from the approver's
687
+ * own instance.
608
688
  */
609
689
  type PermissionApprover = {
610
690
  readonly kind: "permission";
611
691
  readonly permission: string;
612
692
  };
613
- /** An approver who matches at least one item; an item that is a list matches when every entry does. */
693
+ /**
694
+ * An approver who matches at least one item; an item that is a list matches
695
+ * when every entry does.
696
+ */
614
697
  type AnyOfApprover = {
615
698
  readonly kind: "any-of";
616
699
  readonly of: readonly (Approver | readonly Approver[])[];
617
700
  };
618
701
  /**
619
- * Who may approve: a subject-only grantee, a `relation()` the approver holds
620
- * on the requested row (checked when the verdict is given), `user(id)`,
702
+ * Who may approve: a subject-only grantee, a `relation()` the approver holds on
703
+ * the requested row (checked when the verdict is given), `user(id)`,
621
704
  * `holder(permission)`, or `anyOf(...)`. A list (or `allOf(...)`) matches an
622
705
  * approver who satisfies every item.
623
706
  */
@@ -626,7 +709,10 @@ type ApproverInput = GranteeInput | UserApprover | PermissionApprover | {
626
709
  readonly kind: "any-of";
627
710
  readonly of: readonly ApproverInput[];
628
711
  } | readonly ApproverInput[];
629
- /** Approves when the approver holds `permission` in the request's tenant (any role, custom roles included). */
712
+ /**
713
+ * Approves when the approver holds `permission` in the request's tenant (any
714
+ * role, custom roles included).
715
+ */
630
716
  declare function holder(permission: Permission): PermissionApprover;
631
717
  /** Approves when the approver matches any one of `items`. */
632
718
  declare function anyOf(...items: readonly ApproverInput[]): {
@@ -639,29 +725,35 @@ declare function allOf(...items: readonly ApproverInput[]): readonly ApproverInp
639
725
  declare function user(id: string): UserApprover;
640
726
  //#endregion
641
727
  //#region src/core/scopes.d.ts
642
- /** One entry of `definePolicy({ scopes })`: the row field holding the scope id, and its parent scope. */
728
+ /**
729
+ * One entry of `definePolicy({ scopes })`: the row field holding the scope id,
730
+ * and its parent scope.
731
+ */
643
732
  type ScopeDeclaration = {
644
733
  readonly key: string;
645
734
  readonly within?: string;
646
735
  };
647
736
  type PolicyScopesInput = Readonly<Record<string, ScopeDeclaration>>;
648
737
  /**
649
- * A declared scope, in declaration order. `key` is absent only on the
650
- * implicit `tenant` / `team` pair of a policy that declares no scopes.
738
+ * A declared scope, in declaration order. `key` is absent only on the implicit
739
+ * `tenant` / `team` pair of a policy that declares no scopes.
651
740
  */
652
741
  type Scope = {
653
742
  readonly name: string;
654
743
  readonly key?: string;
655
744
  readonly within?: string;
656
745
  };
657
- /** The names `role(..., { on })`, `memberOf` and memberships may use: declared names plus the aliases. */
746
+ /**
747
+ * The names `role(..., { on })`, `memberOf` and memberships may use: declared
748
+ * names plus the aliases.
749
+ */
658
750
  type ScopeNames<S> = [S] extends [PolicyScopesInput] ? string extends keyof S ? string : (keyof S & string) | "tenant" | "team" : string;
659
751
  //#endregion
660
752
  //#region src/core/wire-delegation.d.ts
661
753
  /**
662
- * A delegation as every PermDock wire form carries it: OAuth `scope`
663
- * (RFC 6749, space-separated) and RFC 9396 `authorization_details`. An empty
664
- * `scope` is an empty scope list, which delegates nothing.
754
+ * A delegation as every PermDock wire form carries it: OAuth `scope` (RFC 6749,
755
+ * space-separated) and RFC 9396 `authorization_details`. An empty `scope` is an
756
+ * empty scope list, which delegates nothing.
665
757
  */
666
758
  type WireDelegation = {
667
759
  readonly scope?: string;
@@ -672,9 +764,9 @@ type WireDelegation = {
672
764
  //#region src/core/wire-denial.d.ts
673
765
  /**
674
766
  * A denial as it leaves the process: in a decision event, a Problem Details
675
- * body, an MCP or WebMCP refusal and the decision endpoint. `detail` is a
676
- * JSON value (a string, or `LimitDetail` on `limit`); what a closure threw
677
- * and a validation error stay in process.
767
+ * body, an MCP or WebMCP refusal and the decision endpoint. `detail` is a JSON
768
+ * value (a string, or `LimitDetail` on `limit`); what a closure threw and a
769
+ * validation error stay in process.
678
770
  */
679
771
  type WireDenial = {
680
772
  readonly role: string | null;
@@ -682,7 +774,10 @@ type WireDenial = {
682
774
  readonly to?: Grantee | readonly Grantee[];
683
775
  readonly detail?: unknown;
684
776
  };
685
- /** A `Decision` whose denials are `WireDenial`s, as the decision endpoint sends it. */
777
+ /**
778
+ * A `Decision` whose denials are `WireDenial`s, as the decision endpoint sends
779
+ * it.
780
+ */
686
781
  type WireDecision = GrantedDecision | ApprovalRequiredDecision | (Omit<DeniedDecision, "denials"> & {
687
782
  readonly denials: readonly WireDenial[];
688
783
  });
@@ -706,7 +801,10 @@ type DirectoryEvent = {
706
801
  readonly iss?: string;
707
802
  };
708
803
  readonly active?: boolean;
709
- /** The application's own data, set where the event is built; plain JSON, never read by a decision. */
804
+ /**
805
+ * The application's own data, set where the event is built; plain JSON, never
806
+ * read by a decision.
807
+ */
710
808
  readonly x?: AppData;
711
809
  };
712
810
  type MembershipEvent = {
@@ -717,7 +815,10 @@ type MembershipEvent = {
717
815
  readonly principal: {
718
816
  readonly id: string;
719
817
  };
720
- /** A declared scope name, or the `tenant` / `team` alias; absent for a global role change. */
818
+ /**
819
+ * A declared scope name, or the `tenant` / `team` alias; absent for a global
820
+ * role change.
821
+ */
721
822
  readonly scope?: string;
722
823
  /** The scope instance; present exactly when `scope` is. */
723
824
  readonly id?: string;
@@ -734,13 +835,16 @@ type MembershipEvent = {
734
835
  readonly id: string;
735
836
  readonly kind: string;
736
837
  };
737
- /** The application's own data, set where the event is built; plain JSON, never read by a decision. */
838
+ /**
839
+ * The application's own data, set where the event is built; plain JSON, never
840
+ * read by a decision.
841
+ */
738
842
  readonly x?: AppData;
739
843
  };
740
844
  /**
741
845
  * An API key's lifecycle: `created`, `rotated` and `revoked` from the
742
- * application or a credential store, `used` from `subjectFromApiKey`. A
743
- * `used` event carries `sample`, the fraction of uses reported.
846
+ * application or a credential store, `used` from `subjectFromApiKey`. A `used`
847
+ * event carries `sample`, the fraction of uses reported.
744
848
  */
745
849
  type CredentialEvent = {
746
850
  readonly type: "credential";
@@ -762,7 +866,10 @@ type CredentialEvent = {
762
866
  readonly kind: string;
763
867
  };
764
868
  readonly sample?: number;
765
- /** The application's own data, set where the event is built; plain JSON, never read by a decision. */
869
+ /**
870
+ * The application's own data, set where the event is built; plain JSON, never
871
+ * read by a decision.
872
+ */
766
873
  readonly x?: AppData;
767
874
  };
768
875
  /**
@@ -798,7 +905,10 @@ type AutomationEvent = {
798
905
  readonly id: string;
799
906
  readonly kind: string;
800
907
  };
801
- /** The application's own data, set where the event is built; plain JSON, never read by a decision. */
908
+ /**
909
+ * The application's own data, set where the event is built; plain JSON, never
910
+ * read by a decision.
911
+ */
802
912
  readonly x?: AppData;
803
913
  };
804
914
  type SinkEvent = DecisionEvent | DirectoryEvent | MembershipEvent | CredentialEvent | AccessEvent | AutomationEvent | DeliveryEvent;
@@ -807,14 +917,14 @@ type DeliveryChannel = "email" | "chat" | "webhook";
807
917
  /** What an email is for; only `notification` mail carries `List-Unsubscribe`. */
808
918
  type EmailCategory = "transactional" | "notification" | "security" | "approval";
809
919
  /**
810
- * Why a delivery failed. `denied` and `unlinked` are the router's refusals of
811
- * a recipient; the rest come from a transport or a provider webhook.
920
+ * Why a delivery failed. `denied` and `unlinked` are the router's refusals of a
921
+ * recipient; the rest come from a transport or a provider webhook.
812
922
  */
813
923
  type DeliveryFailureCause = "denied" | "unlinked" | "no-transport" | "no-message" | "invalid-recipient" | "invalid-message" | "rate-limited" | "quota-exceeded" | "unauthorized" | "unavailable" | "suppressed" | "rejected";
814
924
  /**
815
925
  * One recipient's delivery: `sent` when a transport accepted it, then
816
- * `delivered`, `bounced` or `complained` from the provider, or `failed`.
817
- * It carries no address, only the principal the router checked.
926
+ * `delivered`, `bounced` or `complained` from the provider, or `failed`. It
927
+ * carries no address, only the principal the router checked.
818
928
  */
819
929
  type DeliveryEvent = {
820
930
  readonly type: "delivery";
@@ -827,7 +937,10 @@ type DeliveryEvent = {
827
937
  readonly id: string;
828
938
  readonly key: string;
829
939
  };
830
- /** The checked principal, or `trusted` for an address the server loaded itself. */
940
+ /**
941
+ * The checked principal, or `trusted` for an address the server loaded
942
+ * itself.
943
+ */
831
944
  readonly recipient?: {
832
945
  readonly principal?: {
833
946
  readonly id: string;
@@ -851,7 +964,10 @@ type DeliveryEvent = {
851
964
  readonly retryable?: boolean;
852
965
  /** The denial reason when `cause` is `denied`. */
853
966
  readonly reason?: string;
854
- /** The application's own data, set where the event is built; plain JSON, never read by a decision. */
967
+ /**
968
+ * The application's own data, set where the event is built; plain JSON, never
969
+ * read by a decision.
970
+ */
855
971
  readonly x?: AppData;
856
972
  };
857
973
  /**
@@ -891,7 +1007,10 @@ type AccessEvent = {
891
1007
  };
892
1008
  /** A `SupportSession`'s permission keys. */
893
1009
  readonly permissions?: readonly string[];
894
- /** The application's own data, set where the event is built; plain JSON, never read by a decision. */
1010
+ /**
1011
+ * The application's own data, set where the event is built; plain JSON, never
1012
+ * read by a decision.
1013
+ */
895
1014
  readonly x?: AppData;
896
1015
  };
897
1016
  type DecisionEvent = {
@@ -915,14 +1034,20 @@ type DecisionEvent = {
915
1034
  readonly id: string;
916
1035
  readonly kind: string;
917
1036
  };
918
- /** OAuth `scope` and RFC 9396 `authorization_details`, as every wire form carries a delegation. */
1037
+ /**
1038
+ * OAuth `scope` and RFC 9396 `authorization_details`, as every wire form
1039
+ * carries a delegation.
1040
+ */
919
1041
  readonly delegation?: WireDelegation;
920
1042
  /** The API key the subject came from. */
921
1043
  readonly credential?: {
922
1044
  readonly id: string;
923
1045
  readonly kind: CredentialKind;
924
1046
  };
925
- /** The support session the subject came from: the `id` its `access` events carry as `session.id`. */
1047
+ /**
1048
+ * The support session the subject came from: the `id` its `access` events
1049
+ * carry as `session.id`.
1050
+ */
926
1051
  readonly supportSession?: {
927
1052
  readonly id: string;
928
1053
  };
@@ -946,7 +1071,10 @@ type DecisionEvent = {
946
1071
  };
947
1072
  /** What a granted decision owes, as on `GrantedDecision.obligations`. */
948
1073
  readonly obligations?: readonly Obligation[];
949
- /** Purposes of use the caller asserted (`context.purpose`); present when any was. */
1074
+ /**
1075
+ * Purposes of use the caller asserted (`context.purpose`); present when any
1076
+ * was.
1077
+ */
950
1078
  readonly purpose?: readonly string[];
951
1079
  /** The justification the caller supplied (`context.reason`); present when set. */
952
1080
  readonly reason?: string;
@@ -957,7 +1085,10 @@ type DecisionEvent = {
957
1085
  /** The call that produced the decision. */
958
1086
  readonly call: "can" | "decide" | "assert" | "filter" | "endpoint" | "adapter" | "approval" | "simulate" | "explain";
959
1087
  readonly adapter?: AdapterId;
960
- /** The model id the agent model gate decided, or the model that drove the call. */
1088
+ /**
1089
+ * The model id the agent model gate decided, or the model that drove the
1090
+ * call.
1091
+ */
961
1092
  readonly model?: string;
962
1093
  /** Set on an approval lifecycle event (`com.permdock.approval.<phase>`). */
963
1094
  readonly phase?: "requested" | "resolved" | "expired" | "cancelled";
@@ -966,7 +1097,10 @@ type DecisionEvent = {
966
1097
  readonly denied: number;
967
1098
  readonly approvalRequired: number;
968
1099
  };
969
- /** The application's own data, set where the event is built; plain JSON, never read by a decision. */
1100
+ /**
1101
+ * The application's own data, set where the event is built; plain JSON, never
1102
+ * read by a decision.
1103
+ */
970
1104
  readonly x?: AppData;
971
1105
  };
972
1106
  type AuthEvent = {
@@ -985,7 +1119,10 @@ type AuthEvent = {
985
1119
  //#region src/core/snapshot-types.d.ts
986
1120
  type Snapshot = {
987
1121
  readonly v: 1;
988
- /** RFC 3339. The epoch for a snapshot built without a clock. Signed, it is the token's `iat`. */
1122
+ /**
1123
+ * RFC 3339. The epoch for a snapshot built without a clock. Signed, it is the
1124
+ * token's `iat`.
1125
+ */
989
1126
  readonly issuedAt: string;
990
1127
  readonly subject: {
991
1128
  readonly principal: {
@@ -995,13 +1132,19 @@ type Snapshot = {
995
1132
  readonly tenant?: string;
996
1133
  readonly memberships?: readonly Membership[];
997
1134
  } | null;
998
- /** OAuth `scope` and RFC 9396 `authorization_details`, as the token carried them. */
1135
+ /**
1136
+ * OAuth `scope` and RFC 9396 `authorization_details`, as the token carried
1137
+ * them.
1138
+ */
999
1139
  readonly delegation?: WireDelegation;
1000
1140
  readonly context: Readonly<Record<string, unknown>>;
1001
1141
  };
1002
1142
  /** Roles held in the active tenant, in rank order. */
1003
1143
  readonly roles: readonly string[];
1004
- /** The distinct `meta.audience` values of `roles`, in rank order; absent when none has one. */
1144
+ /**
1145
+ * The distinct `meta.audience` values of `roles`, in rank order; absent when
1146
+ * none has one.
1147
+ */
1005
1148
  readonly audiences?: readonly string[];
1006
1149
  readonly grants: readonly SnapshotGrant[];
1007
1150
  readonly tenants: readonly string[];
@@ -1013,18 +1156,24 @@ type Snapshot = {
1013
1156
  readonly roles?: Readonly<Record<string, Role>>;
1014
1157
  readonly plans?: Readonly<Record<string, Plan>>;
1015
1158
  };
1016
- /** The policy's scopes in order, so a client checks the row against each membership's instance. */
1159
+ /**
1160
+ * The policy's scopes in order, so a client checks the row against each
1161
+ * membership's instance.
1162
+ */
1017
1163
  readonly scopes?: readonly SnapshotScope[];
1018
- /** One entry per tenant in `tenants`: what the subject may hand out there. Absent without tenants. */
1164
+ /**
1165
+ * One entry per tenant in `tenants`: what the subject may hand out there.
1166
+ * Absent without tenants.
1167
+ */
1019
1168
  readonly assignable?: readonly SnapshotAssignable[];
1020
1169
  /**
1021
- * Allow grants of held roles that only a plan the subject lacks keeps
1022
- * from applying; they grant nothing and name the plan a denial asks for.
1170
+ * Allow grants of held roles that only a plan the subject lacks keeps from
1171
+ * applying; they grant nothing and name the plan a denial asks for.
1023
1172
  */
1024
1173
  readonly notEntitled?: readonly SnapshotNotEntitled[];
1025
1174
  /**
1026
- * The row id field per resource whose `id` option is not `id`, for the
1027
- * grants in `grants`. Absent when every one reads `id`.
1175
+ * The row id field per resource whose `id` option is not `id`, for the grants
1176
+ * in `grants`. Absent when every one reads `id`.
1028
1177
  */
1029
1178
  readonly ids?: Readonly<Record<string, string>>;
1030
1179
  /**
@@ -1035,7 +1184,10 @@ type Snapshot = {
1035
1184
  */
1036
1185
  readonly delegated?: readonly string[];
1037
1186
  };
1038
- /** A grant the subject would hold on another plan: its permission, role and `to`. */
1187
+ /**
1188
+ * A grant the subject would hold on another plan: its permission, role and
1189
+ * `to`.
1190
+ */
1039
1191
  type SnapshotNotEntitled = {
1040
1192
  readonly permission: string;
1041
1193
  readonly role: string | null;
@@ -1046,17 +1198,29 @@ type SnapshotScope = {
1046
1198
  readonly name: string;
1047
1199
  readonly key: string;
1048
1200
  readonly within?: string;
1049
- /** Resources whose rows this scope's key partitions, from their `memberOf` relations. */
1201
+ /**
1202
+ * Resources whose rows this scope's key partitions, from their `memberOf`
1203
+ * relations.
1204
+ */
1050
1205
  readonly resources?: readonly string[];
1051
- /** Resource name to the field holding this scope's id, for a resource whose field is not `key` (its own `id`). */
1206
+ /**
1207
+ * Resource name to the field holding this scope's id, for a resource whose
1208
+ * field is not `key` (its own `id`).
1209
+ */
1052
1210
  readonly fields?: Readonly<Record<string, string>>;
1053
1211
  };
1054
- /** The declared roles and the custom-role ceiling the subject may assign in one tenant. */
1212
+ /**
1213
+ * The declared roles and the custom-role ceiling the subject may assign in one
1214
+ * tenant.
1215
+ */
1055
1216
  type SnapshotAssignable = {
1056
1217
  readonly tenant: string;
1057
1218
  readonly roles: readonly string[];
1058
1219
  readonly permissions: readonly Permission[];
1059
- /** Permission key to the levels the subject may hand out; only permissions whose resource declares levels. */
1220
+ /**
1221
+ * Permission key to the levels the subject may hand out; only permissions
1222
+ * whose resource declares levels.
1223
+ */
1060
1224
  readonly levels?: Readonly<Record<string, readonly string[]>>;
1061
1225
  };
1062
1226
  type SnapshotGrant = {
@@ -1074,7 +1238,10 @@ type SnapshotGrant = {
1074
1238
  readonly membership?: Membership;
1075
1239
  readonly portable?: false;
1076
1240
  readonly fields?: readonly string[];
1077
- /** When the grant applies (RFC 3339, `from` inclusive, `until` exclusive); absent means always. */
1241
+ /**
1242
+ * When the grant applies (RFC 3339, `from` inclusive, `until` exclusive);
1243
+ * absent means always.
1244
+ */
1078
1245
  readonly validity?: WireValidity;
1079
1246
  /** The grant's declared `name`. */
1080
1247
  readonly name?: string;
@@ -1098,10 +1265,52 @@ type LocalSnapshotManifest = {
1098
1265
  readonly rank?: readonly string[];
1099
1266
  /** Every declared grant, without a membership. */
1100
1267
  readonly grants: readonly SnapshotGrant[];
1101
- /** Per custom-role scope (`global` for platform roles): the grants each entry resolves to. */
1268
+ /**
1269
+ * Per custom-role scope (`global` for platform roles): the grants each entry
1270
+ * resolves to.
1271
+ */
1102
1272
  readonly custom: Readonly<Record<string, LocalCustomRoleTable>>;
1103
- /** The synced tables a device reads the user's memberships, roles and custom roles from; `permdock powersync generate` adds it. */
1273
+ /**
1274
+ * The synced tables a device reads the user's memberships, roles and custom
1275
+ * roles from; `permdock powersync generate` adds it.
1276
+ */
1104
1277
  readonly rows?: LocalSnapshotRows;
1278
+ /**
1279
+ * What a device needs to compute `Snapshot.assignable` for the active tenant
1280
+ * the way `assignableIn` does on the server.
1281
+ */
1282
+ readonly assignable?: LocalAssignable;
1283
+ };
1284
+ /**
1285
+ * The hand-out rules of a policy, as a device evaluates them over its synced
1286
+ * memberships and custom roles.
1287
+ */
1288
+ type LocalAssignable = {
1289
+ /**
1290
+ * Declared roles a tenant admin may hand out or compose, in rank order, with
1291
+ * the scope each sits on and its allow keys.
1292
+ */
1293
+ readonly roles: readonly {
1294
+ readonly name: string;
1295
+ readonly on: string;
1296
+ readonly allows: readonly string[];
1297
+ }[];
1298
+ /** Declared role names and permission keys with `meta.manageRoles: true`. */
1299
+ readonly manage: {
1300
+ readonly roles: readonly string[];
1301
+ readonly permissions: readonly string[];
1302
+ };
1303
+ /**
1304
+ * Declared role name to the roles it assigns, when any role declares
1305
+ * `assigns`.
1306
+ */
1307
+ readonly assigns?: Readonly<Record<string, readonly string[]>>;
1308
+ /** The first scope's custom-role ceiling, in declaration order. */
1309
+ readonly permissions: readonly Permission[];
1310
+ /** Permission key to its level names, in declaration order. */
1311
+ readonly levels?: Readonly<Record<string, readonly string[]>>;
1312
+ /** Index of an allow in `grants` to the levels a holder of it may hand out. */
1313
+ readonly grants?: Readonly<Record<string, readonly string[]>>;
1105
1314
  };
1106
1315
  /** A column of a synced table, or a value every row has. */
1107
1316
  type LocalRowValue = {
@@ -1110,9 +1319,9 @@ type LocalRowValue = {
1110
1319
  readonly value: string;
1111
1320
  };
1112
1321
  /**
1113
- * A column that holds a role key or user id: the value itself, the `column`
1114
- * of the synced `through` table whose `id` it references, or a value each
1115
- * maps to a role key (`null` for no role).
1322
+ * A column that holds a role key or user id: the value itself, the `column` of
1323
+ * the synced `through` table whose `id` it references, or a value each maps to
1324
+ * a role key (`null` for no role).
1116
1325
  */
1117
1326
  type LocalRowColumn = {
1118
1327
  readonly column: string;
@@ -1133,7 +1342,10 @@ type LocalMembershipRows = {
1133
1342
  readonly user: LocalRowColumn;
1134
1343
  readonly scope: LocalRowValue;
1135
1344
  readonly id: string;
1136
- /** The role columns (the row holds every non-null key), or the fixed roles every row holds. */
1345
+ /**
1346
+ * The role columns (the row holds every non-null key), or the fixed roles
1347
+ * every row holds.
1348
+ */
1137
1349
  readonly roles: readonly LocalRowColumn[] | {
1138
1350
  readonly value: readonly string[];
1139
1351
  };
@@ -1151,28 +1363,46 @@ type LocalSnapshotRows = {
1151
1363
  /** The role columns; the row holds every non-null key. */
1152
1364
  readonly roles: readonly LocalRowColumn[];
1153
1365
  };
1154
- /** The custom-role tables (`tenant_id`, `scope`, `scope_id`, `role`, and `permission`, `effect`, `level` or `include_role`). */
1366
+ /**
1367
+ * The custom-role tables (`tenant_id`, `scope`, `scope_id`, `role`, and
1368
+ * `permission`, `effect`, `level` or `include_role`).
1369
+ */
1155
1370
  readonly customRoles?: {
1156
1371
  readonly permissions: string;
1157
1372
  readonly includes: string;
1158
1373
  };
1159
1374
  };
1160
- /** Grants a custom role entry resolves to, held by a placeholder role the client renames. */
1375
+ /**
1376
+ * Grants a custom role entry resolves to, held by a placeholder role the client
1377
+ * renames.
1378
+ */
1161
1379
  type LocalCustomRoleTable = {
1162
- /** `{ permission }` per permission key, and `{ permission, level }` per declared level. */
1380
+ /**
1381
+ * `{ permission }` per permission key, and `{ permission, level }` per
1382
+ * declared level.
1383
+ */
1163
1384
  readonly permissions: Readonly<Record<string, {
1164
1385
  readonly all: readonly SnapshotGrant[];
1165
1386
  readonly levels?: Readonly<Record<string, readonly SnapshotGrant[]>>;
1387
+ /** The levels a holder of `all` may hand out. */
1388
+ readonly reach?: readonly string[];
1389
+ /** Level to the levels a holder of `levels[level]` may hand out. */
1390
+ readonly levelReach?: Readonly<Record<string, readonly string[]>>;
1166
1391
  }>>;
1167
1392
  /** `includes: [role]` per declared role. */
1168
1393
  readonly includes: Readonly<Record<string, readonly SnapshotGrant[]>>;
1394
+ /**
1395
+ * Declared role to permission key to the levels a holder of its included
1396
+ * grants may hand out.
1397
+ */
1398
+ readonly includeReach?: Readonly<Record<string, Readonly<Record<string, readonly string[]>>>>;
1169
1399
  };
1170
1400
  //#endregion
1171
1401
  //#region src/core/time.d.ts
1172
1402
  /**
1173
- * The one time rule: NumericDate (whole seconds) for JWT registered claims
1174
- * and the claims SQL reads, RFC 3339 for every other JSON field, integer
1175
- * seconds for durations, and an `Instant` for every runtime `now`.
1403
+ * The one time rule: NumericDate (whole seconds) for JWT registered claims and
1404
+ * the claims SQL reads, RFC 3339 for every other JSON field, integer seconds
1405
+ * for durations, and an `Instant` for every runtime `now`.
1176
1406
  */
1177
1407
  /**
1178
1408
  * The part of a `Temporal.Instant` PermDock reads. Public options take it
@@ -1185,8 +1415,8 @@ type Instant = {
1185
1415
  //#endregion
1186
1416
  //#region src/core/internals.d.ts
1187
1417
  /**
1188
- * Any instance a feature function accepts: a server `PermDock`, one built
1189
- * from a snapshot, or an adapter's wrapper such as `PdpPermDock`.
1418
+ * Any instance a feature function accepts: a server `PermDock`, one built from
1419
+ * a snapshot, or an adapter's wrapper such as `PdpPermDock`.
1190
1420
  */
1191
1421
  type InstanceHandle = {
1192
1422
  readonly subject: Subject;
@@ -1194,19 +1424,26 @@ type InstanceHandle = {
1194
1424
  //#endregion
1195
1425
  //#region src/core/credential.d.ts
1196
1426
  type CredentialKind = "user" | "service" | "feed";
1197
- /** A feed id: lowercase, so a mail system that lowercases a local part still matches. At most 16 characters, so `pdfeed_<id>_<secret>` fits an email local part. */
1427
+ /**
1428
+ * A feed id: lowercase, so a mail system that lowercases a local part still
1429
+ * matches. At most 16 characters, so `pdfeed_<id>_<secret>` fits an email local
1430
+ * part.
1431
+ */
1198
1432
  declare function isFeedId(value: string): boolean;
1199
- /** One permission (a key) a credential may use: on every instance, or only on `ids`. */
1433
+ /**
1434
+ * One permission (a key) a credential may use: on every instance, or only on
1435
+ * `ids`.
1436
+ */
1200
1437
  type CredentialPermission = {
1201
1438
  readonly permission: string;
1202
1439
  readonly ids?: readonly string[];
1203
1440
  };
1204
1441
  /**
1205
- * Credential v1: what a verified API key stands for, never the secret. A
1206
- * `user` credential acts as its owner (`principal`) narrowed to
1207
- * `permissions`, and to the memberships inside `tenant` when it names one;
1208
- * a `service` credential is its own `service` principal holding `roles` in
1209
- * `tenant`, narrowed the same way.
1442
+ * Credential v1: what a verified API key stands for, never the secret. A `user`
1443
+ * credential acts as its owner (`principal`) narrowed to `permissions`, and to
1444
+ * the memberships inside `tenant` when it names one; a `service` credential is
1445
+ * its own `service` principal holding `roles` in `tenant`, narrowed the same
1446
+ * way.
1210
1447
  */
1211
1448
  type Credential = {
1212
1449
  readonly v: 1;
@@ -1215,12 +1452,15 @@ type Credential = {
1215
1452
  /** The owner of a `user` credential, or the id of the service principal. */
1216
1453
  readonly principal: string;
1217
1454
  /**
1218
- * The instance of the first scope the key is held to. Required on a
1219
- * service credential, where its roles are held; optional on a user
1220
- * credential, where it keeps only the owner's memberships inside it.
1455
+ * The instance of the first scope the key is held to. Required on a service
1456
+ * credential, where its roles are held; optional on a user credential, where
1457
+ * it keeps only the owner's memberships inside it.
1221
1458
  */
1222
1459
  readonly tenant?: string;
1223
- /** Service: the roles it holds in `tenant`. Feed: the resource roles it holds on `on`. */
1460
+ /**
1461
+ * Service: the roles it holds in `tenant`. Feed: the resource roles it holds
1462
+ * on `on`.
1463
+ */
1224
1464
  readonly roles?: readonly string[];
1225
1465
  /** Feed only: the resource instance the roles are held on. */
1226
1466
  readonly on?: {
@@ -1290,14 +1530,20 @@ type CredentialDecision = {
1290
1530
  } | {
1291
1531
  readonly outcome: "approval-required";
1292
1532
  readonly credential: Credential;
1293
- /** Bound to the credential's content and its creator; pass it as `approved` to resume. */
1533
+ /**
1534
+ * Bound to the credential's content and its creator; pass it as
1535
+ * `approved` to resume.
1536
+ */
1294
1537
  readonly token: string;
1295
1538
  } | {
1296
1539
  readonly outcome: "denied";
1297
1540
  readonly denials: readonly Denial[];
1298
1541
  };
1299
1542
  type DecideCredentialOptions = {
1300
- /** Where the tenant's `credentials` policy comes from. Without it, only the no-expiry rule applies. */
1543
+ /**
1544
+ * Where the tenant's `credentials` policy comes from. Without it, only the
1545
+ * no-expiry rule applies.
1546
+ */
1301
1547
  readonly settings?: SettingsSource;
1302
1548
  /** The `token` of an approval the application consumed for this request. */
1303
1549
  readonly approved?: string;
@@ -1311,49 +1557,48 @@ type DecideCredentialOptions = {
1311
1557
  */
1312
1558
  declare function credentialPolicyViolation(credential: Credential, policy: CredentialPolicy | readonly CredentialPolicy[]): CredentialPolicyViolation | undefined;
1313
1559
  /**
1314
- * Validates an untrusted credential record and returns a frozen copy with
1315
- * only the v1 fields, or `undefined`. Unknown fields are dropped; a wrong
1316
- * type in a known field, a service credential without `tenant` and `roles`,
1317
- * or a user credential with `roles`, rejects the whole record.
1560
+ * Validates an untrusted credential record and returns a frozen copy with only
1561
+ * the v1 fields, or `undefined`. Unknown fields are dropped; a wrong type in a
1562
+ * known field, a service credential without `tenant` and `roles`, or a user
1563
+ * credential with `roles`, rejects the whole record.
1318
1564
  */
1319
1565
  declare function parseCredential(input: unknown): Credential | undefined;
1320
1566
  /**
1321
1567
  * The delegation a credential narrows its principal to: OAuth scopes for
1322
- * permissions on every instance, one RFC 9396 entry per id otherwise. A key
1323
- * the definitions no longer declare is dropped, so a credential whose every
1324
- * key is gone delegates nothing and every check is denied.
1568
+ * permissions on every instance, one RFC 9396 entry per id otherwise. A key the
1569
+ * definitions no longer declare is dropped, so a credential whose every key is
1570
+ * gone delegates nothing and every check is denied.
1325
1571
  */
1326
1572
  declare function credentialDelegation(credential: Credential, permissions: PermissionTree): Delegation;
1327
1573
  /**
1328
1574
  * Decides whether the subject of `permdock` may create the credential in
1329
- * `request`. The creator must be a signed-in user or service that is not
1330
- * itself a link or a credential; a delegated creator hands out only what its
1331
- * delegation covers. A key's tenant must be one the creator is a member of;
1332
- * a service key's roles among the creator's `assignableRoles` there and its
1575
+ * `request`. The creator must be a signed-in user or service that is not itself
1576
+ * a link or a credential; a delegated creator hands out only what its
1577
+ * delegation covers. A key's tenant must be one the creator is a member of; a
1578
+ * service key's roles among the creator's `assignableRoles` there and its
1333
1579
  * permissions within `assignablePermissions` there (`exceeds-creator`). The
1334
- * `credentials` policy of the key's tenant (its own, or for a user key
1335
- * without one the creator's active tenant) then applies (`credential-policy`; a
1580
+ * `credentials` policy of the key's tenant (its own, or for a user key without
1581
+ * one the creator's active tenant) then applies (`credential-policy`; a
1336
1582
  * settings source that throws denies with `rule: 'unavailable'`), and
1337
- * `approval` makes the result `approval-required` until `approved` carries
1338
- * its token. PermDock never stores the credential; the application does,
1339
- * after a `granted` result.
1583
+ * `approval` makes the result `approval-required` until `approved` carries its
1584
+ * token. PermDock never stores the credential; the application does, after a
1585
+ * `granted` result.
1340
1586
  */
1341
1587
  /**
1342
1588
  * Decides whether the subject of `permdock` may create the credential in
1343
1589
  * `request`: the creator's own reach, the `credentials` policy of the key's
1344
- * tenant (the call's `settings`, else the instance's), and `approval`.
1345
- * PermDock never stores the credential; the application does, after a
1346
- * `granted` result. An instance built from a snapshot denies with
1347
- * `unsupported`.
1590
+ * tenant (the call's `settings`, else the instance's), and `approval`. PermDock
1591
+ * never stores the credential; the application does, after a `granted` result.
1592
+ * An instance built from a snapshot denies with `unsupported`.
1348
1593
  */
1349
1594
  declare function decideCredential(permdock: InstanceHandle, request: CredentialRequest, options?: DecideCredentialOptions): Promise<CredentialDecision>;
1350
1595
  //#endregion
1351
1596
  //#region src/core/support-session.d.ts
1352
1597
  /**
1353
- * SupportSession v1: a support staff member (`actor`, kind `support`)
1354
- * viewing the app as `principal` in `tenant`, for a stated `reason`. Each
1355
- * request in the session acts as `principal` with their live rights,
1356
- * narrowed to `permissions`.
1598
+ * SupportSession v1: a support staff member (`actor`, kind `support`) viewing
1599
+ * the app as `principal` in `tenant`, for a stated `reason`. Each request in
1600
+ * the session acts as `principal` with their live rights, narrowed to
1601
+ * `permissions`.
1357
1602
  */
1358
1603
  type SupportSession = {
1359
1604
  readonly v: 1;
@@ -1417,92 +1662,129 @@ type DecideSupportSessionOptions = {
1417
1662
  readonly approval?: boolean;
1418
1663
  /** The `token` of an approval the application consumed for this request. */
1419
1664
  readonly approved?: string;
1420
- /** The principal id that approved; required with `approved` and never the actor. */
1665
+ /**
1666
+ * The principal id that approved; required with `approved` and never the
1667
+ * actor.
1668
+ */
1421
1669
  readonly approvedBy?: string;
1422
1670
  /** The start time; defaults to the clock. */
1423
1671
  readonly now?: Instant;
1424
1672
  };
1425
1673
  /**
1426
- * Validates an untrusted support-session record and returns a frozen copy
1427
- * with only the v1 fields, or `undefined`.
1674
+ * Validates an untrusted support-session record and returns a frozen copy with
1675
+ * only the v1 fields, or `undefined`.
1428
1676
  */
1429
1677
  declare function parseSupportSession(input: unknown): SupportSession | undefined;
1430
1678
  /**
1431
- * Decides whether the subject of `permdock` may start the support session
1432
- * in `request`. The actor must be a signed-in person acting for themselves
1679
+ * Decides whether the subject of `permdock` may start the support session in
1680
+ * `request`. The actor must be a signed-in person acting for themselves
1433
1681
  * (`exceeds-creator` otherwise), give a `reason` (`reason-required`), be a
1434
- * member of the tenant (`tenant-mismatch`) and be able to use every
1435
- * permission (`exceeds-creator`). Without `permissions` the session gets the
1436
- * actor's read-only permissions. The tenant's `supportSessions` policy then
1437
- * applies, and the result is `approval-required` until `approved` carries
1438
- * its token and `approvedBy` names someone other than the actor.
1682
+ * member of the tenant (`tenant-mismatch`) and be able to use every permission
1683
+ * (`exceeds-creator`). Without `permissions` the session gets the actor's
1684
+ * read-only permissions. The tenant's `supportSessions` policy then applies,
1685
+ * and the result is `approval-required` until `approved` carries its token and
1686
+ * `approvedBy` names someone other than the actor.
1439
1687
  */
1440
1688
  /**
1441
- * Decides whether the subject of `permdock` may start the support session
1442
- * in `request` and returns the record to sign: a stated reason, membership
1443
- * of the tenant, the actor's own reach, the tenant's `supportSessions`
1444
- * policy and approval by someone else. An instance built from a snapshot
1445
- * denies with `unsupported`.
1689
+ * Decides whether the subject of `permdock` may start the support session in
1690
+ * `request` and returns the record to sign: a stated reason, membership of the
1691
+ * tenant, the actor's own reach, the tenant's `supportSessions` policy and
1692
+ * approval by someone else. An instance built from a snapshot denies with
1693
+ * `unsupported`.
1446
1694
  */
1447
1695
  declare function decideSupportSession(permdock: InstanceHandle, request: SupportSessionRequest, options?: DecideSupportSessionOptions): Promise<SupportSessionDecision>;
1448
1696
  //#endregion
1449
1697
  //#region src/core/interfaces.d.ts
1450
1698
  type DecisionProvider = {
1451
1699
  readonly name: string;
1452
- handles(permission: Permission): boolean;
1453
- decide(request: {
1700
+ handles: (permission: Permission) => boolean;
1701
+ decide: (request: {
1454
1702
  readonly permission: Permission;
1455
1703
  readonly data?: unknown;
1456
1704
  readonly subject: Subject;
1457
1705
  readonly local: Decision;
1458
- }): Promise<Decision>;
1706
+ }) => Promise<Decision>;
1459
1707
  /**
1460
1708
  * Ids of the resources of `permission.resource` the subject may act on.
1461
1709
  * `null` means the provider could not answer and every row is denied;
1462
1710
  * `undefined` means it cannot list, and each row is decided on its own.
1463
1711
  */
1464
- permitted?(request: {
1712
+ permitted?: (request: {
1465
1713
  readonly permission: Permission;
1466
1714
  readonly subject: Subject;
1467
- }): Promise<readonly string[] | null | undefined>;
1715
+ }) => Promise<readonly string[] | null | undefined>;
1716
+ };
1717
+ /**
1718
+ * Shares one read per key within one `getPermDock` call: the first call runs
1719
+ * `read`, every later call with the same key gets its answer. A source created
1720
+ * once at module scope uses it so the reads of one instance share a single
1721
+ * query and no answer outlives the instance.
1722
+ */
1723
+ type SourceMemo = <T>(key: string, read: () => T) => T;
1724
+ /** What `getPermDock` passes to every source call besides its query. */
1725
+ type SourceContext = {
1726
+ /** Absent when the source is called outside `getPermDock`. */
1727
+ readonly memo?: SourceMemo;
1728
+ };
1729
+ /**
1730
+ * Whether an instance answers reads or writes: `read` may judge a token fresh
1731
+ * from a shared `VersionCache` within its `maxStaleMs`; `write` reads the
1732
+ * version live.
1733
+ */
1734
+ type Intent = "read" | "write";
1735
+ /** The custom-role sources' second argument. */
1736
+ type CustomRoleContext = SourceContext & {
1737
+ readonly held: readonly string[];
1468
1738
  };
1469
1739
  type CustomRoleSource = {
1470
1740
  /** Names the implementation in errors and events. */
1471
1741
  readonly name?: string;
1472
1742
  /**
1473
- * The custom roles of one tenant. `getPermDock` passes `held`, the role
1474
- * names the subject's live memberships hold there, declared or not, so a
1475
- * source can skip its read when none of them is a custom role.
1743
+ * The custom roles of one tenant. `getPermDock` passes `held`, the role names
1744
+ * the subject's live memberships hold there, declared or not, so a source can
1745
+ * skip its read when none of them is a custom role.
1476
1746
  */
1477
- rolesFor(tenant: string, context?: {
1478
- readonly held: readonly string[];
1479
- }): CustomRole[] | Promise<CustomRole[]>;
1480
- assignable?(tenant: string): string[] | Promise<string[]>;
1747
+ rolesFor: (tenant: string, context?: CustomRoleContext) => CustomRole[] | Promise<CustomRole[]>;
1748
+ assignable?: (tenant: string) => string[] | Promise<string[]>;
1481
1749
  /**
1482
- * Platform custom roles (`scope: 'global'`), read once per signed-in
1483
- * subject, with `held`, the global role names the subject holds. A role
1484
- * here with a tenant is ignored.
1750
+ * Platform custom roles (`scope: 'global'`), read once per signed-in subject,
1751
+ * with `held`, the global role names the subject holds. A role here with a
1752
+ * tenant is ignored.
1485
1753
  */
1486
- globalRoles?(context?: {
1487
- readonly held: readonly string[];
1488
- }): CustomRole[] | Promise<CustomRole[]>;
1754
+ globalRoles?: (context?: CustomRoleContext) => CustomRole[] | Promise<CustomRole[]>;
1489
1755
  /**
1490
1756
  * Shared custom roles (`shared: true`), defined once for every tenant and
1491
- * read once per subject with a tenant membership, with `held`, the role
1492
- * names its live memberships hold in any tenant. A role here without
1493
- * `shared: true` is ignored.
1757
+ * read once per subject with a tenant membership, with `held`, the role names
1758
+ * its live memberships hold in any tenant. A role here without `shared: true`
1759
+ * is ignored.
1494
1760
  */
1495
- sharedRoles?(context?: {
1496
- readonly held: readonly string[];
1497
- }): CustomRole[] | Promise<CustomRole[]>;
1761
+ sharedRoles?: (context?: CustomRoleContext) => CustomRole[] | Promise<CustomRole[]>;
1498
1762
  };
1499
1763
  /**
1500
- * A `CustomRoleSource` built for the subject the instance serves, for an adapter
1501
- * option shared by every request: it gets the resolved subject (principal,
1502
- * actor and delegation) and returns that subject's source, or `undefined`
1503
- * for none. A throw reads no custom roles and reports `source-threw`.
1764
+ * A `CustomRoleSource` built for the subject the instance serves, for an
1765
+ * adapter option shared by every request: it gets the resolved subject
1766
+ * (principal, actor and delegation) and returns that subject's source, or
1767
+ * `undefined` for none. A throw reads no custom roles and reports
1768
+ * `source-threw`.
1504
1769
  */
1505
1770
  type CustomRoleSourceFactory = (subject: Subject) => CustomRoleSource | undefined;
1771
+ /**
1772
+ * The principal `MembershipSource.version` is asked about: what its token
1773
+ * claims.
1774
+ */
1775
+ type VersionQuery = {
1776
+ readonly id: string;
1777
+ readonly roles?: readonly string[];
1778
+ readonly memberships?: readonly Membership[];
1779
+ readonly authzVersion?: number;
1780
+ /** When the token was issued, in seconds since the epoch (`iat`). */
1781
+ readonly issuedAt?: number;
1782
+ };
1783
+ /** `MembershipSource.version`'s second argument. */
1784
+ type VersionContext = SourceContext & {
1785
+ /** Absent outside `getPermDock`, where the read is live. */
1786
+ readonly intent?: Intent;
1787
+ };
1506
1788
  /** One member of a scope instance, as `MembershipSource.list` returns it. */
1507
1789
  type MemberEntry = {
1508
1790
  readonly principal: {
@@ -1513,39 +1795,39 @@ type MemberEntry = {
1513
1795
  type MembershipSource = {
1514
1796
  /** Names the implementation in errors and events. */
1515
1797
  readonly name?: string;
1516
- membershipsFor(principal: {
1798
+ membershipsFor: (principal: {
1517
1799
  readonly id: string;
1518
1800
  readonly kind?: string;
1519
- }, options: {
1801
+ }, options: SourceContext & {
1520
1802
  readonly tenant?: string;
1521
- }): Membership[] | Promise<Membership[]>;
1522
- /** Every membership held in one scope instance, for member lists and access reviews. */
1523
- list?(query: {
1803
+ }) => Membership[] | Promise<Membership[]>;
1804
+ /**
1805
+ * Every membership held in one scope instance, for member lists and access
1806
+ * reviews.
1807
+ */
1808
+ list?: (query: {
1524
1809
  readonly scope: string;
1525
1810
  readonly id: string;
1526
- }): MemberEntry[] | Promise<MemberEntry[]>;
1811
+ }) => MemberEntry[] | Promise<MemberEntry[]>;
1527
1812
  /**
1528
1813
  * The principal's current authorization version, bumped on every membership
1529
- * change. A token whose `authzVersion` is behind it is stale for the
1530
- * policy's `fresh` permissions. `roles` and `memberships` are what the
1531
- * token claims, so a source can read more than the version in the same
1532
- * call when the claims show it will be needed.
1814
+ * change. A token whose `authzVersion` is behind it is stale for the policy's
1815
+ * `fresh` permissions. `roles` and `memberships` are what the token claims,
1816
+ * so a source can read more than the version in the same call when the claims
1817
+ * show it will be needed. `authzVersion` and `issuedAt` (seconds) are the
1818
+ * token's, for a `VersionCache`.
1533
1819
  */
1534
- version?(principal: {
1535
- readonly id: string;
1536
- readonly roles?: readonly string[];
1537
- readonly memberships?: readonly Membership[];
1538
- }): number | undefined | Promise<number | undefined>;
1820
+ version?: (principal: VersionQuery, context?: VersionContext) => number | undefined | Promise<number | undefined>;
1539
1821
  /**
1540
- * The global roles the principal holds now. With `onStale: 'reread'`, a
1541
- * stale token's `principal.roles` is replaced by this answer, so a revoked
1542
- * platform role is lost with the memberships. A throw or rejection leaves
1543
- * no global roles. Without it, a reread keeps the token's roles.
1822
+ * The global roles the principal holds now. With `onStale: 'reread'`, a stale
1823
+ * token's `principal.roles` is replaced by this answer, so a revoked platform
1824
+ * role is lost with the memberships. A throw or rejection leaves no global
1825
+ * roles. Without it, a reread keeps the token's roles.
1544
1826
  */
1545
- globalRolesFor?(principal: {
1827
+ globalRolesFor?: (principal: {
1546
1828
  readonly id: string;
1547
1829
  readonly kind?: string;
1548
- }): readonly string[] | Promise<readonly string[]>;
1830
+ }, context?: SourceContext) => readonly string[] | Promise<readonly string[]>;
1549
1831
  /**
1550
1832
  * Keep the memberships the verified token carries and read this source only
1551
1833
  * when the token says they were truncated (`claimsFirst`).
@@ -1555,9 +1837,9 @@ type MembershipSource = {
1555
1837
  * What a token behind `version` gets. Only permissions the policy marks
1556
1838
  * `fresh` look at staleness: `'deny'` (the default) denies those with
1557
1839
  * `stale-credentials` and leaves every other permission on the token's
1558
- * claims; `'reread'` replaces the token's memberships (and global roles,
1559
- * when the source has `globalRolesFor`) with a live read for the whole
1560
- * subject, so no decision keeps a revoked grant.
1840
+ * claims; `'reread'` replaces the token's memberships (and global roles, when
1841
+ * the source has `globalRolesFor`) with a live read for the whole subject, so
1842
+ * no decision keeps a revoked grant.
1561
1843
  */
1562
1844
  readonly onStale?: "deny" | "reread";
1563
1845
  };
@@ -1565,7 +1847,10 @@ type MembershipSource = {
1565
1847
  type RelationChain = {
1566
1848
  /** Whether the object itself is restricted: nothing above it reaches it. */
1567
1849
  readonly restricted?: boolean;
1568
- /** Ancestors nearest first, at most `depth`; a restricted one ends the walk after itself. */
1850
+ /**
1851
+ * Ancestors nearest first, at most `depth`; a restricted one ends the walk
1852
+ * after itself.
1853
+ */
1569
1854
  readonly ancestors: readonly {
1570
1855
  readonly id: string;
1571
1856
  readonly restricted?: boolean;
@@ -1579,7 +1864,10 @@ type HolderPeriod = {
1579
1864
  /** Seconds since the epoch; from it on the relation no longer holds. */
1580
1865
  readonly expiresAt?: number;
1581
1866
  };
1582
- /** A group holding a relation on an object: whoever holds `relation` on the group's instance holds it too. */
1867
+ /**
1868
+ * A group holding a relation on an object: whoever holds `relation` on the
1869
+ * group's instance holds it too.
1870
+ */
1583
1871
  type RelationGroup = {
1584
1872
  readonly resource: string;
1585
1873
  readonly id: string;
@@ -1597,10 +1885,9 @@ type RelationHolder = HolderPeriod & ({
1597
1885
  readonly group: RelationGroup;
1598
1886
  });
1599
1887
  /**
1600
- * The object graph: parent chains, links and who holds a relation on an
1601
- * object. A source answers facts and never decides; a thrown or rejected
1602
- * call, or a Promise the instance has not loaded, denies with
1603
- * `relation-unavailable`.
1888
+ * The object graph: parent chains, links and who holds a relation on an object.
1889
+ * A source answers facts and never decides; a thrown or rejected call, or a
1890
+ * Promise the instance has not loaded, denies with `relation-unavailable`.
1604
1891
  */
1605
1892
  type RelationSource = {
1606
1893
  /** Names the implementation in errors and events. */
@@ -1609,31 +1896,34 @@ type RelationSource = {
1609
1896
  * With `through: 'parent'`, the parent chain; with a link name, the one
1610
1897
  * instance that link points to (`depth` is then 1).
1611
1898
  */
1612
- ancestors(query: {
1899
+ ancestors: (query: {
1613
1900
  readonly resource: string;
1614
1901
  readonly id: string;
1615
1902
  readonly through: string;
1616
1903
  readonly depth: number;
1617
- }): RelationChain | Promise<RelationChain>;
1618
- related(query: {
1904
+ }) => RelationChain | Promise<RelationChain>;
1905
+ related: (query: {
1619
1906
  readonly resource: string;
1620
1907
  readonly id: string;
1621
1908
  readonly relation: string;
1622
- }): RelationHolder[] | Promise<RelationHolder[]>;
1623
- row?(query: {
1909
+ }) => RelationHolder[] | Promise<RelationHolder[]>;
1910
+ row?: (query: {
1624
1911
  readonly resource: string;
1625
1912
  readonly id: string;
1626
- }): Readonly<Record<string, unknown>> | null | undefined | Promise<Readonly<Record<string, unknown>> | null | undefined>;
1913
+ }) => Readonly<Record<string, unknown>> | null | undefined | Promise<Readonly<Record<string, unknown>> | null | undefined>;
1627
1914
  };
1628
- /** Plan and seat names a principal holds in a tenant, from billing (Stripe Entitlements, a table). */
1915
+ /**
1916
+ * Plan and seat names a principal holds in a tenant, from billing (Stripe
1917
+ * Entitlements, a table).
1918
+ */
1629
1919
  type EntitlementSource = {
1630
1920
  /** Names the implementation in errors and events. */
1631
1921
  readonly name?: string;
1632
- entitlementsFor(principal: {
1922
+ entitlementsFor: (principal: {
1633
1923
  readonly id: string;
1634
1924
  }, options: {
1635
1925
  readonly tenant?: string;
1636
- }): string[] | Promise<string[]>;
1926
+ }) => string[] | Promise<string[]>;
1637
1927
  };
1638
1928
  type JwtClaims = {
1639
1929
  readonly iss?: string;
@@ -1662,29 +1952,32 @@ type VerificationFailure = {
1662
1952
  type TokenVerifier<TClaims extends JwtClaims = JwtClaims> = {
1663
1953
  /** Names the implementation in errors and events. */
1664
1954
  readonly name?: string;
1665
- verify(token: string, expectations: {
1955
+ verify: (token: string, expectations: {
1666
1956
  readonly typ?: string | readonly string[];
1667
1957
  readonly audience?: string | readonly string[];
1668
1958
  readonly issuer?: string;
1669
1959
  readonly clockTolerance?: number;
1670
- }): Promise<VerifiedToken<TClaims> | VerificationFailure>;
1960
+ }) => Promise<VerifiedToken<TClaims> | VerificationFailure>;
1671
1961
  };
1672
1962
  type TokenSigner = {
1673
1963
  /** Names the implementation in errors and events. */
1674
1964
  readonly name?: string;
1675
- sign(payload: Readonly<Record<string, unknown>>, options: {
1965
+ sign: (payload: Readonly<Record<string, unknown>>, options: {
1676
1966
  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";
1677
1967
  /** `aud`; a signer with no default audience refuses to sign without one. */
1678
1968
  readonly audience?: string | readonly string[];
1679
1969
  /** `exp`, a NumericDate; one hour after `iat` when absent. */
1680
1970
  readonly expiresAt?: number;
1681
- /** `iat`, a NumericDate: the artefact's issue time. The signer's clock when absent. */
1971
+ /**
1972
+ * `iat`, a NumericDate: the artefact's issue time. The signer's clock
1973
+ * when absent.
1974
+ */
1682
1975
  readonly issuedAt?: number;
1683
1976
  /** `jti`: the artefact's id. A fresh UUID when absent. */
1684
1977
  readonly jti?: string;
1685
- }): Promise<string>;
1978
+ }) => Promise<string>;
1686
1979
  readonly kid?: string;
1687
- jwks?(): Promise<{
1980
+ jwks?: () => Promise<{
1688
1981
  readonly keys: readonly JsonWebKeyLike[];
1689
1982
  }>;
1690
1983
  };
@@ -1694,8 +1987,8 @@ type SubjectResolver<TInput, TPrincipal extends Principal = Principal> = (input:
1694
1987
  type SnapshotSource = {
1695
1988
  /** Names the implementation in errors and events. */
1696
1989
  readonly name?: string;
1697
- get(): Promise<Snapshot | string> | Snapshot | string;
1698
- subscribe?(listener: () => void): () => void;
1990
+ get: () => Promise<Snapshot | string> | Snapshot | string;
1991
+ subscribe?: (listener: () => void) => () => void;
1699
1992
  };
1700
1993
  type WhereCompiler<TTarget, TOptions = unknown> = (condition: Condition, target: TTarget, options?: TOptions) => unknown;
1701
1994
  type LimitConsumeInput = {
@@ -1715,31 +2008,31 @@ type LimitRemaining = {
1715
2008
  type LimitStore = {
1716
2009
  /** Names the implementation in errors and events. */
1717
2010
  readonly name?: string;
1718
- consume(input: LimitConsumeInput): Promise<LimitRemaining> | LimitRemaining;
1719
- remaining(input: LimitConsumeInput): LimitRemaining | undefined;
2011
+ consume: (input: LimitConsumeInput) => Promise<LimitRemaining> | LimitRemaining;
2012
+ remaining: (input: LimitConsumeInput) => LimitRemaining | undefined;
1720
2013
  };
1721
2014
  type DecisionSink = {
1722
2015
  /** Names the implementation in errors and events. */
1723
2016
  readonly name?: string;
1724
- write(events: readonly SinkEvent[]): Promise<void> | void;
1725
- flush?(): Promise<void>;
2017
+ write: (events: readonly SinkEvent[]) => Promise<void> | void;
2018
+ flush?: () => Promise<void>;
1726
2019
  };
1727
2020
  /**
1728
2021
  * Looks up the credential an API key stands for. `null` for a key that is
1729
- * malformed, unknown, revoked or whose secret does not match; never throws
1730
- * for bad input. Verification is the application's (or `apiKeyVerifier`'s),
1731
- * never core's.
2022
+ * malformed, unknown, revoked or whose secret does not match; never throws for
2023
+ * bad input. Verification is the application's (or `apiKeyVerifier`'s), never
2024
+ * core's.
1732
2025
  */
1733
2026
  type CredentialVerifier = {
1734
2027
  /** Names the implementation in errors and events. */
1735
2028
  readonly name?: string;
1736
- verify(secret: string): Credential | null | Promise<Credential | null>;
2029
+ verify: (secret: string) => Credential | null | Promise<Credential | null>;
1737
2030
  /**
1738
- * Records a successful use at `at`, for a `lastUsedAt` column. Called
1739
- * after a key resolved and not awaited; a throw or a rejection is
1740
- * ignored, so it never changes the subject.
2031
+ * Records a successful use at `at`, for a `lastUsedAt` column. Called after a
2032
+ * key resolved and not awaited; a throw or a rejection is ignored, so it
2033
+ * never changes the subject.
1741
2034
  */
1742
- touch?(id: string, at: Instant): void | Promise<void>;
2035
+ touch?: (id: string, at: Instant) => void | Promise<void>;
1743
2036
  };
1744
2037
  /** What one tenant configures for itself. Every field only tightens. */
1745
2038
  type TenantSettings = {
@@ -1749,13 +2042,13 @@ type TenantSettings = {
1749
2042
  readonly supportSessions?: SupportSessionPolicy;
1750
2043
  };
1751
2044
  /**
1752
- * Per-tenant settings, a subject input like `CustomRoleSource`: they tighten what
1753
- * a key may be and never grant. A throw denies.
2045
+ * Per-tenant settings, a subject input like `CustomRoleSource`: they tighten
2046
+ * what a key may be and never grant. A throw denies.
1754
2047
  */
1755
2048
  type SettingsSource = {
1756
2049
  /** Names the implementation in errors and events. */
1757
2050
  readonly name?: string;
1758
- settingsFor(tenant: string): TenantSettings | undefined | Promise<TenantSettings | undefined>;
2051
+ settingsFor: (tenant: string) => TenantSettings | undefined | Promise<TenantSettings | undefined>;
1759
2052
  };
1760
2053
  //#endregion
1761
2054
  //#region src/core/policy-fingerprint.d.ts
@@ -1785,13 +2078,16 @@ type ApprovalStage = {
1785
2078
  readonly by: Approver | readonly Approver[];
1786
2079
  /** Absent means 1. */
1787
2080
  readonly quorum?: number;
1788
- /** After `after`, `to` may approve this stage as well as `by`; other stages are unaffected. */
2081
+ /**
2082
+ * After `after`, `to` may approve this stage as well as `by`; other stages
2083
+ * are unaffected.
2084
+ */
1789
2085
  readonly escalation?: ApprovalEscalation;
1790
2086
  };
1791
2087
  /**
1792
- * `'any'`: `quorum` approvers from `by`. `'all'`: every stage completes, in
1793
- * any order. `'sequential'`: stages complete in order; an approver signs
1794
- * only the first incomplete stage. An approver signs once per request.
2088
+ * `'any'`: `quorum` approvers from `by`. `'all'`: every stage completes, in any
2089
+ * order. `'sequential'`: stages complete in order; an approver signs only the
2090
+ * first incomplete stage. An approver signs once per request.
1795
2091
  */
1796
2092
  type ApprovalMode = "any" | "all" | "sequential";
1797
2093
  type ApprovalRequirement = {
@@ -1805,15 +2101,24 @@ type ApprovalRequirement = {
1805
2101
  readonly distinct?: boolean;
1806
2102
  /** `'resource-change'` binds the approval to the row's `version` field. */
1807
2103
  readonly staleOn?: "resource-change";
1808
- /** Distinct approvers a request needs before it is approved under `by`; absent means 1. */
2104
+ /**
2105
+ * Distinct approvers a request needs before it is approved under `by`; absent
2106
+ * means 1.
2107
+ */
1809
2108
  readonly quorum?: number;
1810
- /** Seconds a request stays open; the store's default when absent, and never longer than it. */
2109
+ /**
2110
+ * Seconds a request stays open; the store's default when absent, and never
2111
+ * longer than it.
2112
+ */
1811
2113
  readonly ttl?: number;
1812
2114
  readonly escalation?: ApprovalEscalation;
1813
2115
  };
1814
2116
  type ApprovalOption = "human" | {
1815
2117
  readonly by?: ApproverInput;
1816
- /** `'all'` or `'sequential'` with `stages`; absent means `'any'` with `by`. */
2118
+ /**
2119
+ * `'all'` or `'sequential'` with `stages`; absent means `'any'` with
2120
+ * `by`.
2121
+ */
1817
2122
  readonly mode?: ApprovalMode;
1818
2123
  readonly stages?: readonly {
1819
2124
  readonly by: ApproverInput;
@@ -1832,11 +2137,20 @@ type ApprovalOption = "human" | {
1832
2137
  * changes, resuming denies with `stale-approval`.
1833
2138
  */
1834
2139
  readonly staleOn?: "resource-change";
1835
- /** Distinct approvers needed (an integer of at least 1); the same approver counts once. Absent means 1. */
2140
+ /**
2141
+ * Distinct approvers needed (an integer of at least 1); the same approver
2142
+ * counts once. Absent means 1.
2143
+ */
1836
2144
  readonly quorum?: number;
1837
- /** Seconds the request stays open (`1800`); caps the approval store's default. */
2145
+ /**
2146
+ * Seconds the request stays open (`1800`); caps the approval store's
2147
+ * default.
2148
+ */
1838
2149
  readonly ttl?: number;
1839
- /** After `after` seconds (`14_400`), `to` may approve as well as `by`, at any open stage; same kinds as `by`. */
2150
+ /**
2151
+ * After `after` seconds (`14_400`), `to` may approve as well as `by`, at
2152
+ * any open stage; same kinds as `by`.
2153
+ */
1840
2154
  readonly escalation?: {
1841
2155
  readonly after: number;
1842
2156
  readonly to: ApproverInput;
@@ -1864,16 +2178,19 @@ type AssuranceRequirement = {
1864
2178
  readonly amr?: readonly string[];
1865
2179
  };
1866
2180
  /**
1867
- * Time-boxed role activation. A role with `activation` is never held
1868
- * directly: a membership lists it under `eligible`, and `permdock.activate`
1869
- * mints the elevated membership to write.
2181
+ * Time-boxed role activation. A role with `activation` is never held directly:
2182
+ * a membership lists it under `eligible`, and `permdock.activate` mints the
2183
+ * elevated membership to write.
1870
2184
  */
1871
2185
  type ActivationOption = {
1872
2186
  /** The longest an activation may last, in seconds (`14_400`). */
1873
2187
  readonly maxDuration?: number;
1874
2188
  /** `'required'` denies an activation without a reason. */
1875
2189
  readonly justification?: "required" | "optional";
1876
- /** When set, `activate` returns `approval-required` before the membership can be written. */
2190
+ /**
2191
+ * When set, `activate` returns `approval-required` before the membership can
2192
+ * be written.
2193
+ */
1877
2194
  readonly approval?: ApprovalOption;
1878
2195
  /** How fresh the activator's authentication must be. */
1879
2196
  readonly assurance?: AssuranceRequirement;
@@ -1921,10 +2238,16 @@ type SupportAccessOptions<S extends string = string> = {
1921
2238
  readonly role: string;
1922
2239
  /** The scope the support membership sits in; defaults to `tenant`. */
1923
2240
  readonly on?: S;
1924
- /** Every decision under the support membership denies with `actor-required` without an `act`. */
2241
+ /**
2242
+ * Every decision under the support membership denies with `actor-required`
2243
+ * without an `act`.
2244
+ */
1925
2245
  readonly actorRequired?: boolean;
1926
2246
  readonly consent: SupportConsent;
1927
- /** Permissions a support session never reaches, compiled to deny grants scoped to `via: 'support'`. */
2247
+ /**
2248
+ * Permissions a support session never reaches, compiled to deny grants scoped
2249
+ * to `via: 'support'`.
2250
+ */
1928
2251
  readonly forbid?: readonly (Permission | PermissionTree)[];
1929
2252
  /** The subgroup a consented membership records under `member.group`. */
1930
2253
  readonly group?: string;
@@ -1945,38 +2268,56 @@ type GrantOptions<T = Record<string, unknown>> = {
1945
2268
  readonly approval?: ApprovalOption;
1946
2269
  readonly limit?: GrantLimit;
1947
2270
  readonly reason?: string;
1948
- readonly fields?: readonly (keyof T & string)[];
2271
+ readonly fields?: readonly (unknown extends T ? string : keyof T & string)[];
1949
2272
  /**
1950
2273
  * A stable name for the grant. On a deny, a `breakGlass` override may lift
1951
- * it; on any grant, it is reported on `decision.matched.name` and on
1952
- * decision events.
2274
+ * it; on any grant, it is reported on `decision.matched.name` and on decision
2275
+ * events.
1953
2276
  */
1954
2277
  readonly name?: string;
1955
2278
  readonly group?: string;
1956
- /** Display text and app data for the grant, reported on `decision.matched.meta`; never read in evaluation. */
2279
+ /**
2280
+ * Display text and app data for the grant, reported on
2281
+ * `decision.matched.meta`; never read in evaluation.
2282
+ */
1957
2283
  readonly meta?: GrantMeta;
1958
2284
  /**
1959
- * Follow-ups the application owes when this allow grants: each becomes a
1960
- * `{ kind: 'app', name, detail? }` obligation on the decision. Allows only.
2285
+ * Follow-ups the application owes when this allow grants: each becomes a `{
2286
+ * kind: 'app', name, detail? }` obligation on the decision. Allows only.
1961
2287
  */
1962
2288
  readonly obligations?: readonly ObligationInput[];
1963
- /** Purposes of use (`context.purpose`) that make the grant apply; non-portable. */
2289
+ /**
2290
+ * Purposes of use (`context.purpose`) that make the grant apply;
2291
+ * non-portable.
2292
+ */
1964
2293
  readonly purpose?: readonly string[];
1965
- /** The grant applies from this instant on (RFC 3339 or an `Instant`); before it an allow denies with `inactive-grant` and a deny does not apply. */
2294
+ /**
2295
+ * The grant applies from this instant on (RFC 3339 or an `Instant`); before
2296
+ * it an allow denies with `inactive-grant` and a deny does not apply.
2297
+ */
1966
2298
  readonly validFrom?: string | Instant;
1967
- /** The grant stops applying at this instant (exclusive; RFC 3339 or an `Instant`). */
2299
+ /**
2300
+ * The grant stops applying at this instant (exclusive; RFC 3339 or an
2301
+ * `Instant`).
2302
+ */
1968
2303
  readonly validUntil?: string | Instant;
1969
2304
  /**
1970
- * An allow on an instance action counts only on rows whose scope instance
1971
- * (or the whole app, globally) is one where the subject also holds this
2305
+ * An allow on an instance action counts only on rows whose scope instance (or
2306
+ * the whole app, globally) is one where the subject also holds this
1972
2307
  * permission through a role grant without a row condition.
1973
2308
  */
1974
2309
  readonly requires?: Permission | readonly Permission[];
1975
2310
  };
1976
- /** A grant's metadata. PermDock carries it to decisions, events, snapshots and the catalog and never reads `x`. */
2311
+ /**
2312
+ * A grant's metadata. PermDock carries it to decisions, events, snapshots and
2313
+ * the catalog and never reads `x`.
2314
+ */
1977
2315
  type GrantMeta = {
1978
2316
  readonly description?: string;
1979
- /** Data the application owns. Plain JSON, checked by `definePolicy(…, { x: { grant } })`. */
2317
+ /**
2318
+ * Data the application owns. Plain JSON, checked by `definePolicy(…, { x: {
2319
+ * grant } })`.
2320
+ */
1980
2321
  readonly x?: AppData;
1981
2322
  };
1982
2323
  /** An app obligation as declared on an allow: its name, or its name and detail. */
@@ -1986,22 +2327,25 @@ type ObligationInput = string | {
1986
2327
  };
1987
2328
  /**
1988
2329
  * When a grant applies, in Unix seconds. `from` is inclusive, `until`
1989
- * exclusive; either may be absent. Portable: `where()` drops an inactive
1990
- * grant at the decision clock and generated RLS compares against `now()`.
2330
+ * exclusive; either may be absent. Portable: `where()` drops an inactive grant
2331
+ * at the decision clock and generated RLS compares against `now()`.
1991
2332
  */
1992
2333
  type GrantValidity = {
1993
2334
  readonly from?: number;
1994
2335
  readonly until?: number;
1995
2336
  };
1996
- /** A grant's validity in JSON (snapshots, catalogs, `inactive-grant` details): RFC 3339 bounds. */
2337
+ /**
2338
+ * A grant's validity in JSON (snapshots, catalogs, `inactive-grant` details):
2339
+ * RFC 3339 bounds.
2340
+ */
1997
2341
  type WireValidity = {
1998
2342
  readonly from?: string;
1999
2343
  readonly until?: string;
2000
2344
  };
2001
2345
  /**
2002
- * The actor a policy delegation is for: an actor kind, narrowed to one id
2003
- * when `id` is set, or to one named client when `client` is set (the name
2004
- * the subject resolver gives a verified client id through `clients`).
2346
+ * The actor a policy delegation is for: an actor kind, narrowed to one id when
2347
+ * `id` is set, or to one named client when `client` is set (the name the
2348
+ * subject resolver gives a verified client id through `clients`).
2005
2349
  */
2006
2350
  type DelegationTarget = {
2007
2351
  readonly kind: ActorKind;
@@ -2017,42 +2361,66 @@ type PolicyDelegation = {
2017
2361
  readonly from: Grantee | readonly Grantee[];
2018
2362
  readonly to: DelegationTarget;
2019
2363
  readonly permissions: readonly string[];
2020
- /** The keys of `permissions` whose `readOnlyHint` is true: all a `readOnly` actor may use. */
2364
+ /**
2365
+ * The keys of `permissions` whose `readOnlyHint` is true: all a `readOnly`
2366
+ * actor may use.
2367
+ */
2021
2368
  readonly readOnly: readonly string[];
2022
2369
  readonly validity?: GrantValidity;
2023
2370
  };
2024
2371
  type DelegationInput = {
2025
- /** Who hands over: the same subject-only selectors as `approval.by` (a role, `authenticated()`, a plan, `assurance()`); not `relation()`. */
2372
+ /**
2373
+ * Who hands over: the same subject-only selectors as `approval.by` (a role,
2374
+ * `authenticated()`, a plan, `assurance()`); not `relation()`.
2375
+ */
2026
2376
  readonly from: GranteeInput;
2027
- /** Which actor may act: `actor('eve')`, an actor kind, `{ kind, id }` for one agent, or `{ kind, client }` for one named OAuth client. */
2377
+ /**
2378
+ * Which actor may act: `actor('eve')`, an actor kind, `{ kind, id }` for one
2379
+ * agent, or `{ kind, client }` for one named OAuth client.
2380
+ */
2028
2381
  readonly to: ActorGrantee | string | DelegationTarget;
2029
2382
  /** The leaves or subtrees the actor may use; a deny grant still applies. */
2030
2383
  readonly permissions: readonly (Permission | PermissionTree)[];
2031
2384
  readonly validFrom?: string | Instant;
2032
2385
  readonly validUntil?: string | Instant;
2033
2386
  };
2034
- /** A declared scope name (or the `tenant` / `team` alias), or the resource a role is held on. */
2387
+ /**
2388
+ * A declared scope name (or the `tenant` / `team` alias), or the resource a
2389
+ * role is held on.
2390
+ */
2035
2391
  type RoleScope<S extends string = string> = S | Permission | PermissionTree | readonly (Permission | PermissionTree)[];
2036
2392
  type RoleOptions<S extends string = string> = {
2037
2393
  readonly on?: RoleScope<S>;
2038
2394
  readonly assignable?: boolean;
2039
2395
  /** Roles nobody may hold together with this one in the same scope instance. */
2040
2396
  readonly exclusiveWith?: readonly string[];
2041
- /** Fewest holders a scope instance keeps (checked at commit); default 0. Needs a named-scope `on`. */
2397
+ /**
2398
+ * Fewest holders a scope instance keeps (checked at commit); default 0. Needs
2399
+ * a named-scope `on`.
2400
+ */
2042
2401
  readonly min?: number;
2043
2402
  /** Most holders a scope instance may have. Needs a named-scope `on`. */
2044
2403
  readonly max?: number;
2045
- /** The holder count of a scope instance never changes: the role only moves by transfer. */
2404
+ /**
2405
+ * The holder count of a scope instance never changes: the role only moves by
2406
+ * transfer.
2407
+ */
2046
2408
  readonly transferOnly?: boolean;
2047
2409
  /**
2048
- * Roles a holder may assign and revoke. Once any role declares `assigns`,
2049
- * a role nobody lists is assigned only by `meta.manageRoles` holders.
2410
+ * Roles a holder may assign and revoke. Once any role declares `assigns`, a
2411
+ * role nobody lists is assigned only by `meta.manageRoles` holders.
2050
2412
  */
2051
2413
  readonly assigns?: readonly string[];
2052
- /** Membership kinds (`via`) that may hold the role; others hold it for nothing. */
2414
+ /**
2415
+ * Membership kinds (`via`) that may hold the role; others hold it for
2416
+ * nothing.
2417
+ */
2053
2418
  readonly for?: readonly string[];
2054
2419
  readonly meta?: RoleMeta;
2055
- /** Time-boxed activation: the role becomes eligible-only and `activate` mints its membership. */
2420
+ /**
2421
+ * Time-boxed activation: the role becomes eligible-only and `activate` mints
2422
+ * its membership.
2423
+ */
2056
2424
  readonly activation?: ActivationOption;
2057
2425
  /** Reserved for restricted credentials; setting it throws until it ships. */
2058
2426
  readonly restricted?: never;
@@ -2070,31 +2438,52 @@ type Grant = {
2070
2438
  readonly check?: Condition;
2071
2439
  readonly approval?: "human" | ApprovalRequirement;
2072
2440
  readonly portable: boolean;
2073
- /** Set when `portable` is false only because the grant reads the relation graph. */
2441
+ /**
2442
+ * Set when `portable` is false only because the grant reads the relation
2443
+ * graph.
2444
+ */
2074
2445
  readonly graph?: true;
2075
2446
  readonly closure?: ClosureGrantFn;
2076
2447
  readonly limit?: GrantLimit;
2077
2448
  readonly fields?: readonly string[];
2078
2449
  readonly scope: GrantScope;
2079
- /** The grant's stable name: a `breakGlass` override lifts a named deny, and `decision.matched.name` reports it. */
2450
+ /**
2451
+ * The grant's stable name: a `breakGlass` override lifts a named deny, and
2452
+ * `decision.matched.name` reports it.
2453
+ */
2080
2454
  readonly name?: string;
2081
2455
  readonly group?: string;
2082
2456
  readonly meta?: GrantMeta;
2083
2457
  /** App obligations an allow adds to its granted decision. */
2084
2458
  readonly obligations?: readonly AppObligation[];
2085
- /** Purposes of use that make the grant apply (`context.purpose`); non-portable. */
2459
+ /**
2460
+ * Purposes of use that make the grant apply (`context.purpose`);
2461
+ * non-portable.
2462
+ */
2086
2463
  readonly purpose?: readonly string[];
2087
- /** Set on a break-glass allow: it overrides named denies and carries obligations. */
2464
+ /**
2465
+ * Set on a break-glass allow: it overrides named denies and carries
2466
+ * obligations.
2467
+ */
2088
2468
  readonly breakGlass?: BreakGlassSpec;
2089
- /** The membership kind (`via`) this grant applies under; others never match it. */
2469
+ /**
2470
+ * The membership kind (`via`) this grant applies under; others never match
2471
+ * it.
2472
+ */
2090
2473
  readonly viaOnly?: MembershipVia;
2091
2474
  /** Set only on a grant merged from a hosted policy document. */
2092
2475
  readonly hosted?: HostedGrantRef;
2093
2476
  /** When the grant applies; absent means always. */
2094
2477
  readonly validity?: GrantValidity;
2095
- /** Set on a custom-role grant narrowed by a resource level (`CustomRoleGrant.level`). */
2478
+ /**
2479
+ * Set on a custom-role grant narrowed by a resource level
2480
+ * (`CustomRoleGrant.level`).
2481
+ */
2096
2482
  readonly level?: string;
2097
- /** The permission key the subject must also hold, through a role, on the row's scope instance or globally. */
2483
+ /**
2484
+ * The permission key the subject must also hold, through a role, on the row's
2485
+ * scope instance or globally.
2486
+ */
2098
2487
  readonly requires?: readonly string[];
2099
2488
  };
2100
2489
  /** Which hosted policy document and grant a merged grant came from. */
@@ -2114,13 +2503,22 @@ type RoleBinding<S extends string = string> = {
2114
2503
  readonly assigns?: readonly string[];
2115
2504
  readonly for?: readonly string[];
2116
2505
  readonly meta?: RoleMeta;
2117
- /** Time-boxed activation: the role is eligible-only, and `activate` mints its membership. */
2506
+ /**
2507
+ * Time-boxed activation: the role is eligible-only, and `activate` mints its
2508
+ * membership.
2509
+ */
2118
2510
  readonly activation?: ActivationSpec;
2119
- /** Support access: consent and `actorRequired` for a vendor-support membership. */
2511
+ /**
2512
+ * Support access: consent and `actorRequired` for a vendor-support
2513
+ * membership.
2514
+ */
2120
2515
  readonly support?: SupportSpec;
2121
2516
  };
2122
2517
  type ValidateMode = "boundary" | "always" | "never";
2123
- /** The declared scopes, in declaration order; empty when the policy declares none. */
2518
+ /**
2519
+ * The declared scopes, in declaration order; empty when the policy declares
2520
+ * none.
2521
+ */
2124
2522
  type PolicyScopes = readonly Scope[];
2125
2523
  type PolicyVocabulary = {
2126
2524
  readonly permissions: PermissionTree;
@@ -2132,7 +2530,7 @@ type VocabularyFromInput<Input> = Input extends PolicyVocabulary ? Input : {
2132
2530
  readonly roles?: RoleTree;
2133
2531
  readonly plans?: PlanTree;
2134
2532
  };
2135
- type Policy<TUser = unknown, TPrincipal extends Principal = Principal, V extends PolicyVocabulary = PolicyVocabulary> = {
2533
+ type Policy<TUser = unknown, TPrincipal extends Principal = Principal, V extends PolicyVocabulary = PolicyVocabulary, S extends PolicyScopesInput = PolicyScopesInput> = {
2136
2534
  readonly permissions: V["permissions"];
2137
2535
  readonly roles: readonly RoleBinding[];
2138
2536
  readonly rolesByName: ReadonlyMap<string, RoleBinding>;
@@ -2146,18 +2544,39 @@ type Policy<TUser = unknown, TPrincipal extends Principal = Principal, V extends
2146
2544
  readonly onDenied?: (decision: unknown) => never | void;
2147
2545
  readonly fingerprint: string;
2148
2546
  readonly resources: ReadonlyMap<string, ResourceNode>;
2149
- /** The app data schemas `definePolicy` was given; symbol-keyed so freezing the policy leaves the schemas alone. */
2547
+ /**
2548
+ * The app data schemas `definePolicy` was given; symbol-keyed so freezing the
2549
+ * policy leaves the schemas alone.
2550
+ */
2150
2551
  readonly [POLICY_X]?: PolicyAppDataSchemas;
2552
+ readonly [POLICY_SCOPES]?: S;
2151
2553
  readonly providers?: readonly DecisionProvider[];
2152
- /** Permission keys a hosted policy document may grant or deny; empty by default. */
2554
+ /**
2555
+ * Permission keys a hosted policy document may grant or deny; empty by
2556
+ * default.
2557
+ */
2153
2558
  readonly hostable: readonly string[];
2154
- /** Permission keys that deny with `stale-credentials` when the subject's token is behind the source. */
2559
+ /**
2560
+ * Permission keys that deny with `stale-credentials` when the subject's token
2561
+ * is behind the source.
2562
+ */
2155
2563
  readonly fresh?: readonly string[];
2156
- /** Policy delegations in declaration order; absent or empty when the policy declares none. */
2564
+ /**
2565
+ * Policy delegations in declaration order; absent or empty when the policy
2566
+ * declares none.
2567
+ */
2157
2568
  readonly delegations?: readonly PolicyDelegation[];
2158
- /** Grant levels by resource (`resource(…, { levels })`), normalised; absent when none are declared. */
2569
+ /**
2570
+ * Grant levels by resource (`resource(…, { levels })`), normalised; absent
2571
+ * when none are declared.
2572
+ */
2159
2573
  readonly levels?: PolicyLevels;
2160
- /** Coarse OAuth scopes in declaration order; absent when the policy declares none. */
2574
+ /** Resources declared with `orderedLevels: true`, sorted; absent when none. */
2575
+ readonly orderedLevels?: readonly string[];
2576
+ /**
2577
+ * Coarse OAuth scopes in declaration order; absent when the policy declares
2578
+ * none.
2579
+ */
2161
2580
  readonly oauthScopes?: readonly PolicyOAuthScope[];
2162
2581
  readonly index: PolicyIndex;
2163
2582
  };
@@ -2170,7 +2589,10 @@ type PolicyOAuthScope = {
2170
2589
  readonly permissions: readonly string[];
2171
2590
  readonly scopes: readonly string[];
2172
2591
  };
2173
- /** Lookups built once per policy, so a decision does not rescan every role and grant. */
2592
+ /**
2593
+ * Lookups built once per policy, so a decision does not rescan every role and
2594
+ * grant.
2595
+ */
2174
2596
  type PolicyIndex = {
2175
2597
  readonly declaredRoles: ReadonlySet<string>;
2176
2598
  readonly supports: readonly SupportSpec[];
@@ -2196,19 +2618,22 @@ type PolicyOptions<TUser, TPrincipal extends Principal, S extends PolicyScopesIn
2196
2618
  readonly grants?: readonly (Omit<Grant, "role" | "scope"> | readonly Omit<Grant, "role" | "scope">[] | Grant)[];
2197
2619
  /**
2198
2620
  * Named scopes in order, each with the row field holding its id and an
2199
- * optional parent (`within`, an earlier scope). `tenant` and `team` alias
2200
- * the first and second scope.
2621
+ * optional parent (`within`, an earlier scope). `tenant` and `team` alias the
2622
+ * first and second scope.
2201
2623
  */
2202
2624
  readonly scopes?: S;
2203
- /** Maps the application's user to the principal PermDock decides for; `null` is anonymous. */
2625
+ /**
2626
+ * Maps the application's user to the principal PermDock decides for; `null`
2627
+ * is anonymous.
2628
+ */
2204
2629
  readonly subject: (user: TUser) => TPrincipal | null;
2205
2630
  readonly context?: (user: TUser) => Readonly<Record<string, unknown>> | Promise<Readonly<Record<string, unknown>>>;
2206
2631
  readonly validate?: ValidateMode;
2207
2632
  readonly onDenied?: (decision: unknown) => never | void;
2208
2633
  readonly providers?: readonly DecisionProvider[];
2209
2634
  /**
2210
- * Leaves or subtrees a hosted policy document (`PolicySource`) may touch.
2211
- * The default is none, so a policy without it ignores every hosted grant.
2635
+ * Leaves or subtrees a hosted policy document (`PolicySource`) may touch. The
2636
+ * default is none, so a policy without it ignores every hosted grant.
2212
2637
  */
2213
2638
  readonly hostable?: readonly (Permission | PermissionTree)[];
2214
2639
  /**
@@ -2219,8 +2644,8 @@ type PolicyOptions<TUser, TPrincipal extends Principal, S extends PolicyScopesIn
2219
2644
  readonly fresh?: readonly (Permission | PermissionTree)[];
2220
2645
  /**
2221
2646
  * Standing delegations: holders of `from` let actors matching `to` use
2222
- * `permissions` for them without a token saying so. A token delegation on
2223
- * the call still applies as well; both must cover.
2647
+ * `permissions` for them without a token saying so. A token delegation on the
2648
+ * call still applies as well; both must cover.
2224
2649
  */
2225
2650
  readonly delegations?: readonly DelegationInput[];
2226
2651
  /**
@@ -2251,4 +2676,4 @@ type SubjectOf<P> = {
2251
2676
  readonly expiresAt?: number;
2252
2677
  };
2253
2678
  //#endregion
2254
- export { MemberEntry as $, AuthorizationDetail as $n, CredentialEvent as $t, PolicyScopes as A, assurance as An, CredentialRequest as At, ValidateMode as B, DenialReason as Bn, LocalMembershipRows as Bt, MembershipFixture as C, user as Cn, SqlFunctionArg as Cr, Credential as Ct, PolicyDelegation as D, RelationGrantee as Dn, isConditionDate as Dr, CredentialPermissionInput as Dt, PolicyAppDataSchemas as E, InheritGrantee as En, isCondition as Er, CredentialPermission as Et, RoleScope as F, AppObligation as Fn, isFeedId as Ft, CustomRoleSourceFactory as G, MatchedGrant as Gn, Snapshot as Gt, WireValidity as H, ExplainedDecision as Hn, LocalRowValue as Ht, SeparationConflict as I, ApprovalRequiredDecision as In, parseCredential as It, EntitlementSource as J, Trace as Jn, SnapshotNotEntitled as Jt, DecisionProvider as K, Obligation as Kn, SnapshotAssignable as Kt, SubjectOf as L, Decision as Ln, InstanceHandle as Lt, PrincipalOf as M, inherit as Mn, credentialDelegation as Mt, RoleBinding as N, plan as Nn, credentialPolicyViolation as Nt, PolicyOAuthScope as O, actor as On, isConditionRef as Or, CredentialPolicy as Ot, RoleOptions as P, relation as Pn, decideCredential as Pt, LimitStore as Q, Assurance as Qn, AutomationEvent as Qt, SupportAccessOptions as R, Denial as Rn, Instant as Rt, HostedGrantRef as S, holder as Sn, RestrictedAncestors as Sr, ApiKeyPrincipal as St, Policy as T, GranteeInput as Tn, hasConditionOp as Tr, CredentialKind as Tt, CredentialVerifier as U, GrantedDecision as Un, LocalSnapshotManifest as Ut, VocabularyFromInput as V, DeniedDecision as Vn, LocalRowColumn as Vt, CustomRoleSource as W, LimitDetail as Wn, LocalSnapshotRows as Wt, LimitConsumeInput as X, TraceSkipReason as Xn, AccessEvent as Xt, JwtClaims as Y, TraceSkip as Yn, SnapshotScope as Yt, LimitRemaining as Z, Actor as Zn, AuthEvent as Zt, GrantLimit as _, ApproverInput as _n, MemberOfCondition as _r, SupportSessionDecision as _t, ApprovalRequirement as a, EmailCategory as an, JsonWebKeyLike as ar, SettingsSource as at, GrantScope as b, allOf as bn, RelatedCondition as br, decideSupportSession as bt, BreakGlassOptions as c, WireDecision as cn, SharedCustomRole as cr, TenantSettings as ct, ClosureContext as d, PolicyScopesInput as dn, ActorKind as dr, TokenVerifier as dt, DecisionEvent as en, Binding as er, MembershipSource as et, ClosureGrantFn as f, Scope as fn, AdapterId as fr, VerificationFailure as ft, GrantCondition as g, Approver as gn, ConditionValue as gr, SupportSession as gt, Grant as h, AnyOfApprover as hn, ConditionRef as hr, DecideSupportSessionOptions as ht, ApprovalOption as i, DirectoryEvent as in, GnapAccess as ir, RelationSource as it, PolicyVocabulary as j, authenticated as jn, DecideCredentialOptions as jt, PolicyOptions as k, anyone as kn, isSqlFunctionField as kr, CredentialPolicyViolation as kt, BreakGlassRequirements as l, WireDenial as ln, Subject as lr, TokenFailureCause as lt, DelegationTarget as m, ScopeNames as mn, Condition as mr, WhereCompiler as mt, ApprovalEscalation as n, DeliveryEvent as nn, CustomRoleGrant as nr, RelationGroup as nt, ApprovalStage as o, MembershipEvent as on, Membership as or, SnapshotSource as ot, DelegationInput as p, ScopeDeclaration as pn, MembershipVia as pr, VerifiedToken as pt, DecisionSink as q, Quota as qn, SnapshotGrant as qt, ApprovalMode as r, DeliveryFailureCause as rn, Delegation as rr, RelationHolder as rt, AssuranceRequirement as s, SinkEvent as sn, Principal as sr, SubjectResolver as st, ActivationOption as t, DeliveryChannel as tn, CustomRole as tr, RelationChain as tt, BreakGlassSpec as u, WireDelegation as un, VerifiedClaims as ur, TokenSigner as ut, GrantMeta as v, PermissionApprover as vn, MemberOfParent as vr, SupportSessionPolicy as vt, ObligationInput as w, Grantee as wn, SqlFunctionCondition as wr, CredentialDecision as wt, GrantValidity as x, anyOf as xn, RelatedHop as xr, parseSupportSession as xt, GrantOptions as y, UserApprover as yn, OpaqueCondition as yr, SupportSessionRequest as yt, SupportConsent as z, DenialDetails as zn, LocalCustomRoleTable as zt };
2679
+ export { LimitRemaining as $, Quota as $n, SnapshotGrant as $t, PolicyScopes as A, Grantee as An, SqlFunctionCondition as Ar, CredentialDecision as At, ValidateMode as B, relation as Bn, decideCredential as Bt, MembershipFixture as C, ApproverInput as Cn, MemberOfCondition as Cr, SupportSessionDecision as Ct, PolicyDelegation as D, anyOf as Dn, RelatedHop as Dr, parseSupportSession as Dt, PolicyAppDataSchemas as E, allOf as En, RelatedCondition as Er, decideSupportSession as Et, RoleScope as F, anyone as Fn, isSqlFunctionField as Fr, CredentialPolicyViolation as Ft, CustomRoleSource as G, DenialDetails as Gn, LocalCustomRoleTable as Gt, WireValidity as H, ApprovalRequiredDecision as Hn, parseCredential as Ht, SeparationConflict as I, assurance as In, CredentialRequest as It, DecisionSink as J, ExplainedDecision as Jn, LocalRowValue as Jt, CustomRoleSourceFactory as K, DenialReason as Kn, LocalMembershipRows as Kt, SubjectOf as L, authenticated as Ln, DecideCredentialOptions as Lt, PrincipalOf as M, InheritGrantee as Mn, isCondition as Mr, CredentialPermission as Mt, RoleBinding as N, RelationGrantee as Nn, isConditionDate as Nr, CredentialPermissionInput as Nt, PolicyOAuthScope as O, holder as On, RestrictedAncestors as Or, ApiKeyPrincipal as Ot, RoleOptions as P, actor as Pn, isConditionRef as Pr, CredentialPolicy as Pt, LimitConsumeInput as Q, Obligation as Qn, SnapshotAssignable as Qt, SupportAccessOptions as R, inherit as Rn, credentialDelegation as Rt, HostedGrantRef as S, Approver as Sn, ConditionValue as Sr, SupportSession as St, Policy as T, UserApprover as Tn, OpaqueCondition as Tr, SupportSessionRequest as Tt, CredentialVerifier as U, Decision as Un, InstanceHandle as Ut, VocabularyFromInput as V, AppObligation as Vn, isFeedId as Vt, CustomRoleContext as W, Denial as Wn, Instant as Wt, Intent as X, LimitDetail as Xn, LocalSnapshotRows as Xt, EntitlementSource as Y, GrantedDecision as Yn, LocalSnapshotManifest as Yt, JwtClaims as Z, MatchedGrant as Zn, Snapshot as Zt, GrantLimit as _, PolicyScopesInput as _n, ActorKind as _r, VerifiedToken as _t, ApprovalRequirement as a, CredentialEvent as an, AuthorizationDetail as ar, RelationHolder as at, GrantScope as b, ScopeNames as bn, Condition as br, WhereCompiler as bt, BreakGlassOptions as c, DeliveryEvent as cn, CustomRoleGrant as cr, SnapshotSource as ct, ClosureContext as d, EmailCategory as dn, JsonWebKeyLike as dr, SubjectResolver as dt, SnapshotNotEntitled as en, Trace as er, LimitStore as et, ClosureGrantFn as f, MembershipEvent as fn, Membership as fr, TenantSettings as ft, GrantCondition as g, WireDelegation as gn, VerifiedClaims as gr, VerificationFailure as gt, Grant as h, WireDenial as hn, Subject as hr, TokenVerifier as ht, ApprovalOption as i, AutomationEvent as in, Assurance as ir, RelationGroup as it, PolicyVocabulary as j, GranteeInput as jn, hasConditionOp as jr, CredentialKind as jt, PolicyOptions as k, user as kn, SqlFunctionArg as kr, Credential as kt, BreakGlassRequirements as l, DeliveryFailureCause as ln, Delegation as lr, SourceContext as lt, DelegationTarget as m, WireDecision as mn, SharedCustomRole as mr, TokenSigner as mt, ApprovalEscalation as n, AccessEvent as nn, TraceSkipReason as nr, MembershipSource as nt, ApprovalStage as o, DecisionEvent as on, Binding as or, RelationSource as ot, DelegationInput as p, SinkEvent as pn, Principal as pr, TokenFailureCause as pt, DecisionProvider as q, DeniedDecision as qn, LocalRowColumn as qt, ApprovalMode as r, AuthEvent as rn, Actor as rr, RelationChain as rt, AssuranceRequirement as s, DeliveryChannel as sn, CustomRole as sr, SettingsSource as st, ActivationOption as t, SnapshotScope as tn, TraceSkip as tr, MemberEntry as tt, BreakGlassSpec as u, DirectoryEvent as un, GnapAccess as ur, SourceMemo as ut, GrantMeta as v, Scope as vn, AdapterId as vr, VersionContext as vt, ObligationInput as w, PermissionApprover as wn, MemberOfParent as wr, SupportSessionPolicy as wt, GrantValidity as x, AnyOfApprover as xn, ConditionRef as xr, DecideSupportSessionOptions as xt, GrantOptions as y, ScopeDeclaration as yn, MembershipVia as yr, VersionQuery as yt, SupportConsent as z, plan as zn, credentialPolicyViolation as zt };