permdock 0.16.0 → 0.17.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 (374) hide show
  1. package/dist/a2a/index.d.ts +4 -4
  2. package/dist/a2a/index.js +3 -3
  3. package/dist/{adapter-context-CIQpQxbE.js → adapter-context-OHikyRqV.js} +1 -1
  4. package/dist/{adoption-scan-C2BCiUEG.js → adoption-scan-Ci0xiJ3T.js} +1 -1
  5. package/dist/agent/index.d.ts +2 -2
  6. package/dist/agent/index.js +1 -1
  7. package/dist/ai-sdk/index.d.ts +3 -3
  8. package/dist/ai-sdk/index.js +3 -3
  9. package/dist/approval-normalize-4KxMRdJC.js +189 -0
  10. package/dist/approval-policies-9VagPixq.d.ts +138 -0
  11. package/dist/{approval-prompt-3BqWczTt.d.ts → approval-prompt-BSh-yxbH.d.ts} +1 -1
  12. package/dist/approvals/index.d.ts +5 -4
  13. package/dist/approvals/index.js +7 -6
  14. package/dist/{approvals-DnIBTuXE.js → approvals-DdFcTncq.js} +3 -3
  15. package/dist/{approvers-B4r0N_Uz.js → approvers-CNtl4Vc5.js} +22 -1
  16. package/dist/{arazzo-CHoYnQXO.js → arazzo-7kbeh1yi.js} +2 -2
  17. package/dist/{arazzo-ClYz2Z0W.js → arazzo-_zUmT8ZT.js} +4 -4
  18. package/dist/{args-0FrVs5EH.js → args-iafbHiXn.js} +2 -5
  19. package/dist/astro/index.d.ts +4 -4
  20. package/dist/astro/index.js +2 -2
  21. package/dist/{audience-DTjR8xet.js → audience-jRO819i3.js} +1 -1
  22. package/dist/{auth--yPyZNgr.js → auth-j3Eu-j4h.js} +1 -1
  23. package/dist/authz-topic-Dbc-HDOS.js +15 -0
  24. package/dist/authzen/index.d.ts +5 -5
  25. package/dist/authzen/index.js +2 -2
  26. package/dist/{automation-C6Jg75xq.d.ts → automation-DCWuVKtd.d.ts} +1 -1
  27. package/dist/better-auth/index.d.ts +1 -1
  28. package/dist/better-auth/index.js +10 -8
  29. package/dist/better-supabase/index.d.ts +273 -38
  30. package/dist/better-supabase/index.js +493 -102
  31. package/dist/{better-supabase-Dirf_8Ec.js → better-supabase-BJtQ-kNf.js} +26 -10
  32. package/dist/{bind-BNQA9JK9.js → bind-BJFeLX1V.js} +6 -6
  33. package/dist/{bind-YYjvfpB9.d.ts → bind-DjFNX0Pq.d.ts} +7 -7
  34. package/dist/{budget-BELja5A9.js → budget-BBCPDOGP.js} +1 -1
  35. package/dist/{budget-hYsPz_yE.d.ts → budget-CNLsV2SL.d.ts} +1 -1
  36. package/dist/{build-instance-BWXqwQYU.js → build-instance-lye7oEqf.js} +3 -2
  37. package/dist/{capability-Di9tiUvi.d.ts → capability-BzjWdKmP.d.ts} +1 -1
  38. package/dist/{capability-BqX94r07.js → capability-zN6T9fxe.js} +2 -3
  39. package/dist/{casbin-C9EvElBb.js → casbin-C3O_O9nu.js} +2 -2
  40. package/dist/{casbin-D_rVQ31U.js → casbin-DFzk_so3.js} +2 -2
  41. package/dist/{casl-C4OINZHI.js → casl-CjBVJj8R.js} +2 -2
  42. package/dist/{casl-CHHoCldP.js → casl-CkBssiB1.js} +1 -1
  43. package/dist/catalog/index.d.ts +5 -5
  44. package/dist/catalog/index.js +6 -6
  45. package/dist/catalog-BpnjesqX.js +1 -0
  46. package/dist/{catalog-CGlSwU6j.js → catalog-DGDd_ww1.js} +5 -5
  47. package/dist/{catalog-amPDr0JQ.js → catalog-DJJIkR9P.js} +3 -3
  48. package/dist/{catalog-doc-DjMKzJp9.js → catalog-doc-C4DGfJCO.js} +3 -3
  49. package/dist/{catalog-operations-DeHTrJSV.js → catalog-operations-DVI5QO5R.js} +3 -3
  50. package/dist/{challenge-DImNcR7B.js → challenge-M_ghKJnT.js} +2 -2
  51. package/dist/chat/index.d.ts +1 -1
  52. package/dist/chat/index.js +2 -2
  53. package/dist/chat-sdk/index.d.ts +3 -3
  54. package/dist/{checks-CGkP3Z7A.js → checks-fyDOhcz0.js} +33 -1
  55. package/dist/claude-agent/index.d.ts +3 -3
  56. package/dist/claude-agent/index.js +2 -2
  57. package/dist/clerk/index.d.ts +2 -2
  58. package/dist/clerk/index.js +10 -7
  59. package/dist/cli/bin.js +1 -1
  60. package/dist/cli/index.d.ts +5 -5
  61. package/dist/cli/index.js +3 -3
  62. package/dist/cloud/index.d.ts +8 -8
  63. package/dist/cloud/index.js +1 -1
  64. package/dist/{cloud-DdaJ7ILM.js → cloud-DYqzmh5i.js} +4 -4
  65. package/dist/{codemod-ammy6wv4.js → codemod-DNGMGqBS.js} +395 -8
  66. package/dist/{codemod-B1USJS7a.js → codemod-DqB9klYI.js} +3 -3
  67. package/dist/{collect-DnXL4B8c.js → collect-C44RrKCI.js} +4 -4
  68. package/dist/collect-CAibhmCi.js +1 -0
  69. package/dist/{collect-WCl8cJQV.js → collect-HfJXl8Tr.js} +4 -4
  70. package/dist/compile/index.d.ts +1 -1
  71. package/dist/compile/index.js +1 -1
  72. package/dist/{compile-EzEMB-7v.js → compile-B_oJqmIg.js} +4 -4
  73. package/dist/{compile-BEklRUYo.d.ts → compile-BxiwRotu.d.ts} +2 -2
  74. package/dist/{completion--Y4YItFZ.js → completion-pwVjJlek.js} +3 -3
  75. package/dist/{config-CcLlvEYW.js → config-COHmivz9.js} +4 -4
  76. package/dist/{config-BQ77xMZk.js → config-DnfH6_eT.js} +2 -2
  77. package/dist/{config-report-DVMOLJ7F.js → config-report-C1jl7Na-.js} +2 -2
  78. package/dist/{context-BnIzxTNE.js → context-DeammvFl.js} +2 -2
  79. package/dist/convex/index.d.ts +4 -4
  80. package/dist/convex/index.js +3 -3
  81. package/dist/{core-CFepFiDP.d.ts → core-0iYZ5HUx.d.ts} +2 -2
  82. package/dist/{core-lxoANyai.js → core-W5f4Rjt0.js} +7 -7
  83. package/dist/{create-DBvUsgzK.d.ts → create-DNN3OtsO.d.ts} +4 -4
  84. package/dist/{create-CDd9c22W.d.ts → create-DrHUmKvG.d.ts} +6 -6
  85. package/dist/{create-BPUopdfL.d.ts → create-bzQlBzG4.d.ts} +7 -7
  86. package/dist/{create-Coq5fIrq.js → create-gqtDb1nU.js} +5 -5
  87. package/dist/{create-BLPKnJKa.js → create-jCPwPWXf.js} +6 -5
  88. package/dist/{credential-CyyyvCsL.js → credential-B3Hj4puZ.js} +4 -3
  89. package/dist/{credentials-CdDxp7jN.js → credentials-dkycUsY3.js} +1 -1
  90. package/dist/decision-CaG5_eNJ.js +21 -0
  91. package/dist/{delegation-CDB6_keF.js → delegation-aK4T_5WU.js} +3 -3
  92. package/dist/delivery/index.d.ts +4 -4
  93. package/dist/delivery/index.js +1 -1
  94. package/dist/{denied-text-DHldhVUv.d.ts → denied-text-DyzWwxEB.d.ts} +1 -1
  95. package/dist/{describe-Bb4hGK5d.js → describe-CogP1loh.js} +2 -1
  96. package/dist/{describe-BbFPBSms.d.ts → describe-nalX_HHE.d.ts} +1 -1
  97. package/dist/{diff-DfmYaIhB.js → diff-BTsLiW59.js} +7 -7
  98. package/dist/{diff-CxtbOi2l.js → diff-CcxYooMu.js} +2 -2
  99. package/dist/{doctor-CwYc2lJb.js → doctor-BNRhJegR.js} +3 -3
  100. package/dist/{doctor-D1Xnmy6u.js → doctor-DS-9ApID.js} +195 -30
  101. package/dist/drizzle/index.d.ts +3 -3
  102. package/dist/drizzle/index.js +1 -1
  103. package/dist/elysia/index.d.ts +4 -4
  104. package/dist/elysia/index.js +3 -3
  105. package/dist/{errors-Vpu6rKHl.js → errors-BhRkoNS7.js} +0 -2
  106. package/dist/{errors-BIM4MFsJ.d.ts → errors-Dc9FdamT.d.ts} +1 -1
  107. package/dist/{evaluate-BAmf_AQd.js → evaluate-CsjXeLRo.js} +18 -15
  108. package/dist/{evaluations-DOWuBpWv.d.ts → evaluations-BasA9zXp.d.ts} +3 -3
  109. package/dist/{evaluations-IBceAeKT.js → evaluations-DG40eSJa.js} +3 -22
  110. package/dist/eve/index.d.ts +4 -4
  111. package/dist/eve/index.js +3 -3
  112. package/dist/express/index.d.ts +4 -4
  113. package/dist/express/index.js +3 -3
  114. package/dist/fastify/index.d.ts +4 -4
  115. package/dist/fastify/index.js +3 -3
  116. package/dist/{fetch-adapter-BIbBAtPZ.d.ts → fetch-adapter-BgqpOOpd.d.ts} +2 -2
  117. package/dist/{fetch-adapter-dPTgJVHd.js → fetch-adapter-UZOW0PRC.js} +2 -2
  118. package/dist/{fields-DI8s3cPl.js → fields-CrjL6A49.js} +3 -3
  119. package/dist/{files-B3AA05f1.js → files-CfiRtQ-m.js} +1 -1
  120. package/dist/{fixtures-Bm4_K1ke.js → fixtures-0VTW5oNq.js} +2 -2
  121. package/dist/{flags-DXjoTVbS.js → flags-BlmpmXoY.js} +2 -2
  122. package/dist/{from-snapshot-DCakWRsr.js → from-snapshot-DMlSSo9b.js} +14 -12
  123. package/dist/{gen-DwgCSC6V.js → gen-CNCzG4sB.js} +2 -2
  124. package/dist/{gen-DuAhghDw.js → gen-DnpZwQPo.js} +9 -9
  125. package/dist/{generate-CRVV5V7l.js → generate-BqkZq8Dr.js} +2 -2
  126. package/dist/{grantee-conditions-BrYPe-w0.js → grantee-conditions-DX4K_gGI.js} +1 -1
  127. package/dist/{grantee-match-7RZZvoT_.js → grantee-match-BP-k4vRJ.js} +2 -2
  128. package/dist/h3/index.d.ts +4 -4
  129. package/dist/h3/index.js +3 -3
  130. package/dist/{helpers-DJicaG6f.js → helpers-DNnZffrI.js} +76 -12
  131. package/dist/hono/index.d.ts +4 -4
  132. package/dist/hono/index.js +3 -3
  133. package/dist/{hosted-DVxlLZMe.d.ts → hosted-DxRLLiFU.d.ts} +1 -1
  134. package/dist/{hosted-D0IzESu_.js → hosted-tPZnyjQS.js} +12 -10
  135. package/dist/{http-DOL33cO0.js → http-DhMWeB_h.js} +1 -1
  136. package/dist/{import-Dfe2unKO.js → import-BYVbSKx0.js} +3 -3
  137. package/dist/{import-CNBF96hB.js → import-C1XXpG_m.js} +4 -4
  138. package/dist/{index-Cay5-Kvx.d.ts → index-Bt-UoBWu.d.ts} +11 -10
  139. package/dist/{index-DJwEgYzA.d.ts → index-CXXUFWtG.d.ts} +17 -11
  140. package/dist/{index-Dj2qF9VC.d.ts → index-CZ5mixHO.d.ts} +1 -1
  141. package/dist/{index-ymept53A.d.ts → index-DFwUOkvt.d.ts} +4 -4
  142. package/dist/{index-CV-7DWeD.d.ts → index-DtGtDzjb.d.ts} +4 -4
  143. package/dist/{index-BinlXeU-.d.ts → index-z44pfWar.d.ts} +2 -2
  144. package/dist/index.d.ts +18 -16
  145. package/dist/index.js +20 -18
  146. package/dist/{init-C6cWP3xW.js → init-Dr1qAStu.js} +5 -5
  147. package/dist/{init-BUo2G-FI.js → init-YSDySeMy.js} +5 -5
  148. package/dist/{instance-options-CoHn-0e8.d.ts → instance-options-BOCRxEFb.d.ts} +2 -2
  149. package/dist/{instance-snapshot-DuWf1cT3.js → instance-snapshot-BgOGtyCy.js} +15 -12
  150. package/dist/jwt/index.d.ts +4 -4
  151. package/dist/jwt/index.js +3 -3
  152. package/dist/{kernel-BD8QuMnv.js → kernel-CDDU93dI.js} +10 -10
  153. package/dist/kysely/index.d.ts +3 -3
  154. package/dist/kysely/index.js +1 -1
  155. package/dist/{load-DjSU5KXO.js → load-BaEamml-.js} +1 -1
  156. package/dist/load-CjnlPxpL.js +1 -0
  157. package/dist/{login-D1MHOomI.js → login-CXgEKLaW.js} +4 -4
  158. package/dist/{login-DCKE5pVy.js → login-DEVXDTX8.js} +4 -4
  159. package/dist/{manifest-Cft51TLK.js → manifest-Dij1U0hx.js} +37 -37
  160. package/dist/{map-claims-C-nv08_n.js → map-claims-PQwHynxV.js} +25 -11
  161. package/dist/{map-error-pasIGqMT.js → map-error-B_f3C5cs.js} +1 -1
  162. package/dist/mcp/index.d.ts +8 -8
  163. package/dist/mcp/index.js +9 -9
  164. package/dist/{migrate-BJHxQqT5.js → migrate-BbY5-Khy.js} +4 -4
  165. package/dist/{module-values-B1EVTkHP.js → module-values-B8tNIxdd.js} +2 -2
  166. package/dist/nest/index.d.ts +4 -4
  167. package/dist/nest/index.js +3 -3
  168. package/dist/next/index.d.ts +32 -13
  169. package/dist/next/index.js +43 -25
  170. package/dist/next/plugin.d.ts +1 -1
  171. package/dist/next/plugin.js +2 -2
  172. package/dist/node/index.d.ts +4 -4
  173. package/dist/node/index.js +2 -2
  174. package/dist/openai/index.d.ts +4 -4
  175. package/dist/openai/index.js +3 -3
  176. package/dist/openapi/index.d.ts +2 -2
  177. package/dist/{openapi-BwWkHxvW.js → openapi-D3wkvOoU.js} +4 -4
  178. package/dist/{openapi-DSzQN7Zu.js → openapi-GM-kTdkq.js} +5 -5
  179. package/dist/orpc/index.d.ts +5 -5
  180. package/dist/orpc/index.js +3 -3
  181. package/dist/otel/index.d.ts +3 -3
  182. package/dist/otel/index.js +1 -1
  183. package/dist/{output-DlICTjBh.js → output-DhTpe8v1.js} +1 -1
  184. package/dist/output-files-BYscrQl-.js +1 -0
  185. package/dist/{output-files-BIQ_9pIs.js → output-files-CM0BnH05.js} +1 -1
  186. package/dist/{ownership-qqBuGJXr.js → ownership-moSRhxl_.js} +6 -6
  187. package/dist/{parse-1_ZheTW5.js → parse-UTC-sDrt.js} +2 -2
  188. package/dist/{parse-local-manifest-CCmbhnxP.d.ts → parse-local-manifest-BgTYdR3q.d.ts} +1 -1
  189. package/dist/{parse-request-CwCZpyjV.js → parse-request-DOBVaeiQ.js} +1 -1
  190. package/dist/pdp/index.d.ts +3 -3
  191. package/dist/pdp/index.js +3 -3
  192. package/dist/{peer-Q0fuZ6hx.js → peer-BuK9F53f.js} +1 -1
  193. package/dist/{peer-C9LvBCcb.js → peer-n-swIV4H.js} +1 -1
  194. package/dist/{permdock-CprAPN3w.d.ts → permdock-DUWZEOLR.d.ts} +88 -131
  195. package/dist/{permdock-BvjivVb9.js → permdock-DdzMv5-F.js} +195 -102
  196. package/dist/{permissions-CYcHj_w7.js → permissions-CvpPtz5O.js} +1 -1
  197. package/dist/{pg-DQTqRrou.js → pg-Ddxsd5ZB.js} +2 -2
  198. package/dist/{policy-BycVKnXv.d.ts → policy-CTNl7pvN.d.ts} +1 -1
  199. package/dist/{policy-CLQ8__GF.js → policy-DxQyHKPB.js} +5 -4
  200. package/dist/{policy-from-catalog-CU3An8uP.js → policy-from-catalog-DVa1faOr.js} +8 -7
  201. package/dist/{policy-types-DGIO_gxq.d.ts → policy-types-IRJVABmm.d.ts} +63 -19
  202. package/dist/{postgrest-D5nUGm-c.d.ts → postgrest-B_cEDd4e.d.ts} +12 -7
  203. package/dist/{postgrest-DAxFltvO.js → postgrest-BrjrckDG.js} +74 -19
  204. package/dist/{powersync-DAfo0EL5.js → powersync-BZxw_v-A.js} +3 -3
  205. package/dist/{powersync-CBhTBhG2.js → powersync-C0nsyULQ.js} +15 -15
  206. package/dist/powersync-Cqzx25dI.js +1 -0
  207. package/dist/preset/index.js +1 -1
  208. package/dist/{preset-BjLzeFpp.js → preset-pPrVyGU5.js} +74 -7
  209. package/dist/prisma/index.d.ts +2 -2
  210. package/dist/prisma/index.js +1 -1
  211. package/dist/{protected-action-DUYqb-Ma.js → protected-action-B6n6w7Rl.js} +1 -1
  212. package/dist/{protected-action-D8x73IGm.d.ts → protected-action-D3S9U4nc.d.ts} +14 -7
  213. package/dist/{protected-action-QEA8arRB.js → protected-action-qowj6nxN.js} +15 -5
  214. package/dist/{provider-C55OGXJ7.js → provider-CY4TSSJo.js} +2 -2
  215. package/dist/{provider-DfLeek9O.d.ts → provider-CjAu39fJ.d.ts} +1 -1
  216. package/dist/{provider-store-CaTv00tr.js → provider-store-BQP_pp8s.js} +2 -2
  217. package/dist/pull-CUVdB04v.js +1 -0
  218. package/dist/{pull-CQCGy1gv.js → pull-DVoZ0V9_.js} +6 -6
  219. package/dist/{push-Dq_ca4-j.js → push-eJl1Tvqm.js} +7 -7
  220. package/dist/{pushed-policy-CryQheKq.d.ts → pushed-policy-CUQuvlS3.d.ts} +1 -1
  221. package/dist/{pushed-policy-CDuOL2de.js → pushed-policy-DMXAOmEW.js} +1 -1
  222. package/dist/react/index.d.ts +8 -8
  223. package/dist/react/index.js +6 -6
  224. package/dist/react/provider-client.d.ts +1 -1
  225. package/dist/react/provider-client.js +1 -1
  226. package/dist/react-native/index.d.ts +10 -10
  227. package/dist/react-native/index.js +9 -9
  228. package/dist/refresh-on-L9UOwATg.d.ts +49 -0
  229. package/dist/{replay-Bs9Df2fQ.d.ts → replay-Dc3d8LhG.d.ts} +1 -1
  230. package/dist/{request-context-Duzdf0cd.js → request-context-Ch052blg.js} +2 -2
  231. package/dist/{request-schema-DhX7UbfQ.js → request-schema-CMP8Cmxd.js} +5 -0
  232. package/dist/resend/index.d.ts +4 -4
  233. package/dist/{resolve-names-Y1Cb22cp.js → resolve-names-1nCei24V.js} +6 -6
  234. package/dist/{rls-C5ZGzR_B.js → rls-BVzoZCn3.js} +4 -4
  235. package/dist/{rls-tHu7N_Pe.js → rls-ClJRblnR.js} +19 -19
  236. package/dist/{role-builder-BK2-T6oD.js → role-builder-BrmOcXch.js} +3 -157
  237. package/dist/{rpc-vHIwyXCp.js → rpc-BOu3FD6X.js} +2 -2
  238. package/dist/{run-DUq1xU4K.js → run-CnCaTjWX.js} +8 -40
  239. package/dist/run-D9N6V5WQ.js +1 -0
  240. package/dist/{run-ticket-ylovhyFQ.d.ts → run-ticket-C6lXvHM_.d.ts} +2 -2
  241. package/dist/{run-ticket-DfnZCh-u.js → run-ticket-CjvXr6wj.js} +1 -1
  242. package/dist/{runtime-BGnrOkVH.js → runtime-CBXkOcg9.js} +1 -1
  243. package/dist/{saas-DK4V-3Is.js → saas-BqM9mJkk.js} +13 -10
  244. package/dist/{scan-C3HRH9Fs.js → scan-CepUXrFt.js} +1 -1
  245. package/dist/{schema-DvXvxPhQ.js → schema-9_NDz8fx.js} +1 -1
  246. package/dist/{schema-BOJjqlWL.js → schema-CuX70xgH.js} +15 -2
  247. package/dist/scim/index.d.ts +1 -1
  248. package/dist/scim/index.js +1 -1
  249. package/dist/{scim-jJBJ7g1Z.js → scim-C30QBBoF.js} +2 -1
  250. package/dist/{scim-D8YupzX1.js → scim-CovliQUg.js} +2 -2
  251. package/dist/{scopes-0Up_UA2t.js → scopes-BSdYaGHs.js} +9 -40
  252. package/dist/server/index.d.ts +11 -11
  253. package/dist/server/index.js +8 -8
  254. package/dist/{server-3cVlTLde.js → server-D0PW6ZCw.js} +2 -2
  255. package/dist/{server-types-CyRN0-Cd.d.ts → server-types-Bw-lWqzR.d.ts} +8 -8
  256. package/dist/{shared-l0oGGetg.js → shared-BRmCJxDK.js} +2 -2
  257. package/dist/{shared-DrGLwM3s.js → shared-DyYVEjKC.js} +2 -2
  258. package/dist/{sink-B5zoUW_O.d.ts → sink-DUzt0e4B.d.ts} +2 -2
  259. package/dist/{skills-Celu2W6v.js → skills-BUuH-QFt.js} +2 -2
  260. package/dist/{skills-B2qTbaQa.js → skills-a4N6Y2Xm.js} +2 -2
  261. package/dist/{snapshot-CXlzi69u.js → snapshot-DN_8J27z.js} +6 -2
  262. package/dist/{snapshot-cache-Bx_4xC_6.js → snapshot-cache-B66h7FBK.js} +25 -8
  263. package/dist/{snapshot-cache-BjAWkchD.d.ts → snapshot-cache-Dbk-Gnij.d.ts} +20 -6
  264. package/dist/solid/index.d.ts +7 -7
  265. package/dist/solid/index.js +6 -6
  266. package/dist/solid-start/index.d.ts +4 -4
  267. package/dist/solid-start/index.js +3 -3
  268. package/dist/{sources-oB1Hg1Fm.d.ts → sources-CXY05xtB.d.ts} +1 -1
  269. package/dist/{src-C_pi2Rnh.js → src-nYNBfmgq.js} +187 -39
  270. package/dist/ssf/index.d.ts +3 -3
  271. package/dist/ssf/index.js +1 -1
  272. package/dist/{standard-webhooks-DOYEuOLx.d.ts → standard-webhooks-BFeEpjxy.d.ts} +2 -2
  273. package/dist/{store-RNFvaJJv.js → store-XgBMbfDy.js} +13 -7
  274. package/dist/{types-tQB2CEnY.d.ts → store-g5ctUrOI.d.ts} +114 -113
  275. package/dist/{store-options-Dil3lraY.js → store-options--zWn48PK.js} +76 -7
  276. package/dist/{stores-DxZWDXCs.js → stores-53_kOwPi.js} +3 -3
  277. package/dist/{stores-DZJvxFIZ.d.ts → stores-BtdN3eDO.d.ts} +5 -6
  278. package/dist/{stream-9y9qw51m.d.ts → stream-BMJg56jU.d.ts} +1 -1
  279. package/dist/{subject-BGoM5o8B.js → subject-C7RddW0G.js} +8 -1
  280. package/dist/supabase/client.d.ts +31 -0
  281. package/dist/supabase/client.js +21 -0
  282. package/dist/supabase/index.d.ts +37 -6
  283. package/dist/supabase/index.js +5 -4
  284. package/dist/supabase/middleware.d.ts +8 -7
  285. package/dist/supabase/middleware.js +6 -6
  286. package/dist/{supabase-DYWnT800.js → supabase-C6FyUeSh.js} +3 -3
  287. package/dist/{supabase-CDHMsDD0.js → supabase-C8cNzp4i.js} +31 -8
  288. package/dist/supabase-hook-CPBX4dy5.js +1 -0
  289. package/dist/{supabase-hook-HPgwYb9V.js → supabase-hook-Cj85nccs.js} +167 -21
  290. package/dist/{supautils-SwE642N1.js → supautils-BP_5WAIc.js} +12 -12
  291. package/dist/svelte/index.d.ts +7 -7
  292. package/dist/svelte/index.js +8 -8
  293. package/dist/svelte/runtime.d.ts +3 -3
  294. package/dist/svelte/runtime.js +3 -3
  295. package/dist/svelte/source.d.ts +7 -7
  296. package/dist/svelte/source.js +5 -5
  297. package/dist/sveltekit/index.d.ts +4 -4
  298. package/dist/sveltekit/index.js +2 -2
  299. package/dist/{tables-DimBcVWY.js → tables-BsGE6HBR.js} +7 -7
  300. package/dist/tanstack-start/index.d.ts +4 -4
  301. package/dist/tanstack-start/index.js +2 -2
  302. package/dist/{tenancy-5d1zVBvK.js → tenancy-DvOHHk3-.js} +1 -1
  303. package/dist/terminal/index.d.ts +5 -5
  304. package/dist/terminal/index.js +6 -6
  305. package/dist/testing/core.d.ts +1 -1
  306. package/dist/testing/core.js +1 -1
  307. package/dist/testing/fixtures/index.d.ts +1 -1
  308. package/dist/testing/fixtures/index.js +1 -1
  309. package/dist/testing/index.d.ts +29 -22
  310. package/dist/testing/index.js +118 -46
  311. package/dist/testing/saas/index.d.ts +3 -3
  312. package/dist/testing/saas/index.js +2 -2
  313. package/dist/testing/saas/permissions.js +1 -1
  314. package/dist/token-D6pWn8Uj.d.ts +11 -0
  315. package/dist/{token-DC9EQiet.js → token-DaMnIU9O.js} +24 -8
  316. package/dist/{tool-refusal-Qpjs_W6M.js → tool-refusal-C1UlhU0V.js} +1 -1
  317. package/dist/trpc/index.d.ts +5 -5
  318. package/dist/trpc/index.js +3 -3
  319. package/dist/{type-helpers-c7Xo_2Cu.d.ts → type-helpers-C_OnZW8c.d.ts} +1 -1
  320. package/dist/{types-B2efzoSX.d.ts → types-AOP5HQku.d.ts} +1 -1
  321. package/dist/{types-DlelvQk4.d.ts → types-B3BOcI0J.d.ts} +2 -2
  322. package/dist/{types-DLvhVm1r.d.ts → types-BvBbkAu1.d.ts} +16 -7
  323. package/dist/{types-BB-zWDcR.d.ts → types-CA-A33Q5.d.ts} +5 -5
  324. package/dist/{types-Cklw5hJo.d.ts → types-CAAN7evk.d.ts} +24 -1
  325. package/dist/{types-DsHGPtkR.d.ts → types-CJC1aaoJ.d.ts} +2 -2
  326. package/dist/{types-CWBsAwqn.d.ts → types-D29K5ZNP.d.ts} +4 -4
  327. package/dist/{types-CEinc15V.d.ts → types-DVZNTkU0.d.ts} +3 -4
  328. package/dist/{types-ZzRGoViD.d.ts → types-NYoj8JBm.d.ts} +2 -2
  329. package/dist/{types-B6ExllNo.d.ts → types-Sj1U8HMm.d.ts} +2 -2
  330. package/dist/{types-CN0LsqbK.d.ts → types-UfpcY575.d.ts} +3 -3
  331. package/dist/{types-rCRV4Ge-.d.ts → types-e82uzrTn.d.ts} +4 -4
  332. package/dist/unplugin/index.d.ts +1 -1
  333. package/dist/unplugin/index.js +2 -2
  334. package/dist/{usage-CPXeuAdT.js → usage-COsGLht5.js} +6 -6
  335. package/dist/{usage-CfZCQd0F.js → usage-CqcMeQgX.js} +2 -2
  336. package/dist/usage-D1cpHO7p.js +1 -0
  337. package/dist/{validation-error-uvp-kyfO.d.ts → validation-error-DpvsBwZJ.d.ts} +1 -1
  338. package/dist/{verify-DfT0QYNh.js → verify-C8G8D5mk.js} +19 -19
  339. package/dist/{version-cache-Df11C2Qp.d.ts → version-cache-9Vq5QVFC.d.ts} +9 -3
  340. package/dist/{views-CD8wuL4Z.js → views-TrZYlDnM.js} +1 -1
  341. package/dist/vue/index.d.ts +7 -7
  342. package/dist/vue/index.js +6 -6
  343. package/dist/{waiter-CqUKX6CY.d.ts → waiter-C2cXXLFZ.d.ts} +2 -2
  344. package/dist/{watch-DAkjm75Y.js → watch-DXRDBSCu.js} +3 -3
  345. package/dist/watch-DnymTAfe.js +1 -0
  346. package/dist/webmcp/index.d.ts +1 -1
  347. package/dist/webmcp/index.js +1 -1
  348. package/dist/{where-scope-DlCdCM_8.js → where-scope-BKrqUDVk.js} +5 -5
  349. package/dist/{who-can-BoDJm0Nc.js → who-can-BY5d3HPw.js} +4 -4
  350. package/dist/workflow/index.d.ts +3 -3
  351. package/dist/workflow/index.js +5 -4
  352. package/dist/workflow-sdk/index.d.ts +4 -4
  353. package/dist/{wrap-B2wziJI_.js → wrap-C5PWzgkq.js} +1 -1
  354. package/dist/{wrap-DxXB54Wu.d.ts → wrap-DpZAbxuD.d.ts} +2 -2
  355. package/package.json +8 -5
  356. package/schemas/approval-request-v1.json +5 -0
  357. package/schemas/catalog-v1.json +18 -2
  358. package/schemas/cli-result-v1.json +0 -2
  359. package/schemas/snapshot-v1.json +9 -0
  360. package/skills/permdock-approvals/SKILL.md +8 -8
  361. package/skills/permdock-approvals/references/stores-and-resume.md +7 -3
  362. package/skills/permdock-audit/SKILL.md +1 -1
  363. package/dist/action-result-BcudBQOF.d.ts +0 -19
  364. package/dist/catalog-D3oS2GH3.js +0 -1
  365. package/dist/collect-D-eroIfV.js +0 -1
  366. package/dist/load-Dm0pSYH3.js +0 -1
  367. package/dist/output-files-BHOIlrfD.js +0 -1
  368. package/dist/powersync-0QVP_DuR.js +0 -1
  369. package/dist/pull-CCAChKuy.js +0 -1
  370. package/dist/renames-CGj7YwcQ.js +0 -175
  371. package/dist/run-C5P3x1EI.js +0 -1
  372. package/dist/supabase-hook-qsewAVZY.js +0 -1
  373. package/dist/usage-DmmO_xjJ.js +0 -1
  374. package/dist/watch-CuPz0D2M.js +0 -1
@@ -1,149 +1,85 @@
1
- import { $n as Quota, G as CustomRoleSource, J as DecisionSink, Jn as ExplainedDecision, K as CustomRoleSourceFactory, Qn as Obligation, T as Policy, Un as Decision, Wt as Instant, X as Intent, Xn as LimitDetail, Y as EntitlementSource, Zt as Snapshot, _ as GrantLimit, br as Condition, et as LimitStore, fr as Membership, h as Grant, hr as Subject, i as ApprovalOption, j as PolicyVocabulary, lr as Delegation, mt as TokenSigner, nt as MembershipSource, on as DecisionEvent, ot as RelationSource, pr as Principal, rn as AuthEvent, rr as Actor, st as SettingsSource, vn as Scope, vr as AdapterId } from "./policy-types-DGIO_gxq.js";
1
+ import { $t as Snapshot, E as Policy, K as CustomRoleSource, Kt as Instant, M as PolicyVocabulary, Qn as ExplainedDecision, Sr as AdapterId, X as EntitlementSource, Y as DecisionSink, Z as Intent, _r as Principal, bn as Scope, cn as DecisionEvent, ct as SettingsSource, er as LimitDetail, gr as Membership, gt as TokenSigner, nr as Obligation, pr as Delegation, q as CustomRoleSourceFactory, qn as Decision, rr as Quota, rt as MembershipSource, sr as Actor, st as RelationSource, tt as LimitStore, v as GrantLimit, wr as Condition, yr as Subject } from "./policy-types-IRJVABmm.js";
2
2
  import { D as RowOf, M as AppData, b as ResourceNode, u as Permission } from "./permission-types-CAY-GU7e.js";
3
3
  import { a as RoleTree, n as PlanTree, r as Role } from "./vocabulary-DEJ5j4mR.js";
4
- import { i as OperationEffect, s as OperationMeta, t as Operation, u as OperationRisk } from "./operations-Ci_rT6Uo.js";
5
- import { a as HostedPolicies } from "./hosted-DVxlLZMe.js";
6
- //#region src/core/approval-policies.d.ts
4
+ import { t as Operation } from "./operations-Ci_rT6Uo.js";
5
+ import { t as ApprovalPolicies } from "./approval-policies-9VagPixq.js";
6
+ import { a as HostedPolicies } from "./hosted-DxRLLiFU.js";
7
+ //#region src/core/checks.d.ts
7
8
  /**
8
- * One approval requirement kept as data, for a tenant or the whole platform. It
9
- * adds to what the code requires and never removes a requirement.
9
+ * One check of `canAll` or `decideAll`: a permission alone, or with the row it
10
+ * is checked on.
10
11
  */
11
- type ApprovalPolicy = {
12
- /**
13
- * The permission key; a former key from `renamed` resolves. Absent: every
14
- * permission, which needs `risk` or `effects`.
15
- */
16
- readonly permission?: string;
17
- /**
18
- * Matches an operation call whose `meta.risk` is one of these; a call that
19
- * names no operation never matches.
20
- */
21
- readonly risk?: readonly OperationRisk[];
22
- /**
23
- * Matches an operation call whose `meta.effects` includes one of these; a
24
- * call that names no operation never matches.
25
- */
26
- readonly effects?: readonly OperationEffect[];
27
- /** Absent: every tenant. */
28
- readonly tenant?: string;
29
- /**
30
- * Actor kinds it applies to (`['agent']`); absent: every call. A call without
31
- * an actor never matches a list.
32
- */
33
- readonly actors?: readonly string[];
34
- /**
35
- * A portable condition over the row; instance permissions only, since a
36
- * collection action has no row.
37
- */
38
- readonly where?: Condition;
39
- /** A portable condition over the call's input (the proposed row). */
40
- readonly check?: Condition;
41
- /**
42
- * The same shape as `allow(..., { approval })`. An `escalation` here widens
43
- * only this entry's stages, never the code's.
44
- */
45
- readonly approval: ApprovalOption;
12
+ type PermissionCheck = Permission | readonly [permission: Permission, data?: unknown];
13
+ /** One entry of `getPermissions`: plain JSON, safe across a cache boundary. */
14
+ type PermissionState = {
15
+ readonly allowed: boolean;
16
+ readonly outcome: Decision["outcome"];
17
+ /** The first denial's reason; absent unless `outcome` is `denied`. */
18
+ readonly reason?: string;
46
19
  };
47
- /**
48
- * Data-driven approval requirements, a subject input like `CustomRoleSource`:
49
- * read once per instance for the subject's tenants (entries without a tenant
50
- * always apply). A throw, a rejected promise or an invalid entry denies every
51
- * call an allow would otherwise permit.
52
- */
53
- type ApprovalPolicySource = {
54
- /** Names the implementation in errors and events. */
55
- readonly name?: string;
56
- approvalPoliciesFor: (query: {
57
- readonly tenants: readonly string[];
58
- }) => readonly ApprovalPolicy[] | Promise<readonly ApprovalPolicy[]>;
20
+ //#endregion
21
+ //#region src/core/instance-cache.d.ts
22
+ type InstanceCacheStats = {
23
+ /** Instances and source answers built or read. */
24
+ readonly builds: number;
25
+ /** Calls answered by a build already in flight. */
26
+ readonly shared: number;
27
+ /** Calls answered from an entry. */
28
+ readonly hits: number;
29
+ readonly evictions: number;
30
+ readonly size: number;
59
31
  };
60
32
  /**
61
- * The denial detail when an `ApprovalPolicySource` fails: every call an allow
62
- * would grant denies with reason `approval`.
63
- */
64
- /**
65
- * The in-process `ApprovalPolicySource`, usable directly as the
66
- * `approvalPolicies` option: it is the source and its feature at once.
33
+ * The key of one cached instance: who it serves, at which authorization
34
+ * version, for which tenant and intent. `parts` holds everything else that
35
+ * shapes the instance (the claims, the request scope); it is hashed.
67
36
  */
68
- declare function memoryApprovalPolicySource(policies: readonly ApprovalPolicy[]): ApprovalPolicySource & ApprovalPolicies;
69
- /** An entry checked against the policy and ready to match. */
70
- type LoadedApprovalPolicy = {
71
- readonly permission?: string;
72
- readonly risk?: ReadonlySet<OperationRisk>;
73
- readonly effects?: ReadonlySet<OperationEffect>;
37
+ type InstanceCacheKey = {
38
+ readonly principal: string;
39
+ readonly version: number;
74
40
  readonly tenant?: string;
75
- readonly actors?: ReadonlySet<string>;
76
- readonly where?: Condition;
77
- readonly check?: Condition;
78
- readonly approval: NonNullable<Grant["approval"]>;
41
+ readonly intent: "read" | "write";
42
+ readonly parts: unknown;
79
43
  };
80
- /** `"failed"`: the source threw or returned something that cannot be applied. */
81
- /** What `tightenApproval` reads besides the code's approval. */
82
- type TightenInput = Parameters<typeof tightenApproval>[2];
83
- /**
84
- * Approval policies loaded for an instance: the tightening the evaluator
85
- * applies to each allow, or `"failed"` when the source threw or returned an
86
- * invalid entry (every allow then denies).
87
- */
88
- type LoadedApprovalPolicies = {
89
- readonly tighten: (code: Grant["approval"], input: TightenInput) => Grant["approval"];
90
- } | "failed";
91
44
  /**
92
- * Approval policies kept as data, as an instance option: `approvalPolicies:
93
- * approvalPolicies(source)`. The loading and tightening code ships only with an
94
- * app that imports this function.
45
+ * Instances shared across requests: a subject at a known authorization version
46
+ * gets the instance built for it, until `maxAgeMs` passes or `evict` drops it.
47
+ * An instance whose version is unknown is never cached.
95
48
  */
96
- type ApprovalPolicies = {
97
- readonly feature: "approval-policies";
98
- readonly load: (policy: Policy, tenants: readonly string[], auth: AuthEvent[]) => LoadedApprovalPolicies | Promise<LoadedApprovalPolicies>;
49
+ type InstanceCache = {
50
+ readonly name?: string;
51
+ /** The longest an instance, a custom role or an entitlement is reused. */
52
+ readonly maxAgeMs: number;
53
+ /**
54
+ * The instance for `key`: a stored one, the build in flight, or `build()`. A
55
+ * rejected build is not stored.
56
+ */
57
+ instance: <T>(key: InstanceCacheKey, owners: readonly unknown[], build: () => Promise<T>) => Promise<T>;
58
+ /** `source` with every answer kept for `maxAgeMs`, keyed by its arguments. */
59
+ customRoles: (source: CustomRoleSource) => CustomRoleSource;
60
+ /** `source` with every answer kept for `maxAgeMs`, per principal and tenant. */
61
+ entitlements: (source: EntitlementSource) => EntitlementSource;
62
+ /** Drops `principal`'s instances and entitlements. */
63
+ evict: (principal: string) => void;
64
+ stats: () => InstanceCacheStats;
99
65
  };
100
- declare function approvalPolicies(source: ApprovalPolicySource): ApprovalPolicies;
101
- /**
102
- * Why an `ApprovalPolicy` entry does not load. `unknown-permission`: the policy
103
- * declares no such key (the entry applies to nothing). `invalid`: a field has
104
- * the wrong shape or the approval option does not normalise.
105
- * `where-on-collection`: `where` reads a row, which a collection action never
106
- * has, so the entry could never match; use `check` over the input.
107
- * `stale-on-without-version`: `staleOn` needs an instance permission whose
108
- * resource declares `version`.
109
- */
110
- type ApprovalPolicyProblem = "unknown-permission" | "invalid" | "where-on-collection" | "stale-on-without-version";
111
- type ApprovalPolicyValidation = {
112
- readonly ok: true;
113
- } | {
114
- readonly ok: false;
115
- readonly problem: ApprovalPolicyProblem;
66
+ type InstanceCacheOptions = {
67
+ /** Entries kept; the least recently used goes first. Default 10,000. */
68
+ readonly maxEntries?: number;
69
+ /**
70
+ * Milliseconds an entry is reused: the longest a custom-role or entitlement
71
+ * change waits to reach an instance. Default 5,000; clamped to 0 to 60,000.
72
+ */
73
+ readonly maxAgeMs?: number;
74
+ /** Epoch milliseconds. */
75
+ readonly now?: () => number;
116
76
  };
117
77
  /**
118
- * Checks one entry against the policy the way `approvalPoliciesFor` loads it,
119
- * for an application to refuse a bad entry when it is saved instead of finding
120
- * every call denied. Never throws.
121
- */
122
- declare function validateApprovalPolicy(policy: Policy, entry: unknown): ApprovalPolicyValidation;
123
- /**
124
- * `code` with every matching entry added as further stages: the result needs
125
- * all of them (`'sequential'` when any part is ordered), keeps the code's
126
- * escalation, the shortest `ttl`, and `distinct` unless every part opts out.
127
- * Without a matching entry, `code` unchanged.
78
+ * An in-process `InstanceCache`: a bounded LRU that shares builds in flight.
79
+ * Create it once at module scope and pass it as `instances` to every adapter of
80
+ * the app; adapters with the same sources and policy share entries.
128
81
  */
129
- declare function tightenApproval(code: Grant["approval"], entries: readonly LoadedApprovalPolicy[], input: {
130
- readonly permission: string;
131
- readonly tenant: string | undefined;
132
- readonly subject: Subject;
133
- readonly current: unknown;
134
- readonly next: unknown;
135
- readonly now: number;
136
- readonly scopes: readonly Scope[];
137
- /** The meta of the operation the call decides, when it names one. */
138
- readonly operation?: OperationMeta | undefined;
139
- }): Grant["approval"];
140
- //#endregion
141
- //#region src/core/checks.d.ts
142
- /**
143
- * One check of `canAll` or `decideAll`: a permission alone, or with the row it
144
- * is checked on.
145
- */
146
- type PermissionCheck = Permission | readonly [permission: Permission, data?: unknown];
82
+ declare function instanceCache(options?: InstanceCacheOptions): InstanceCache;
147
83
  //#endregion
148
84
  //#region src/core/limits.d.ts
149
85
  declare function memoryLimitStore(): LimitStore & {
@@ -325,6 +261,13 @@ type DecideOptions = {
325
261
  * arguments. Never read when deciding.
326
262
  */
327
263
  readonly args?: unknown;
264
+ /**
265
+ * The `approvalFingerprint` of the exact operation the call runs. An
266
+ * `approval-required` token binds it, the request records it, and resuming
267
+ * under another fingerprint denies with `approval-fingerprint-mismatch`.
268
+ * Never read when deciding.
269
+ */
270
+ readonly fingerprint?: string;
328
271
  /**
329
272
  * The application's own data for the decision event (a request id, a route).
330
273
  * Plain JSON; a value that is not is dropped. Never read when deciding.
@@ -602,6 +545,14 @@ type PermDockOptions = {
602
545
  * handlers, never for a mutation.
603
546
  */
604
547
  readonly intent?: Intent;
548
+ /**
549
+ * The principal's authorization version this request already read, such as
550
+ * `bsb.bootstrap()`'s `authz_ver`: the memberships source's `version` is not
551
+ * called. Anything but a non-negative integer is ignored.
552
+ */
553
+ readonly version?: {
554
+ readonly known: number;
555
+ };
605
556
  readonly customRoles?: CustomRoleSource | CustomRoleSourceFactory;
606
557
  /**
607
558
  * Plans and seats from billing, merged into `principal.plans` for the active
@@ -645,6 +596,12 @@ type PermDockOptions = {
645
596
  * into `subject.context`; keys from `policy.context` win on a clash.
646
597
  */
647
598
  readonly context?: Readonly<Record<string, unknown>>;
599
+ /**
600
+ * Reuses the instance built for a subject at a known authorization version
601
+ * across requests, until the version moves or `maxAgeMs` passes: one
602
+ * `instanceCache()` at module scope. `getPermDockSync` ignores it.
603
+ */
604
+ readonly instances?: InstanceCache;
648
605
  };
649
606
  /**
650
607
  * The instance for `user`, built synchronously. Every input must answer
@@ -659,4 +616,4 @@ declare function getPermDockSync<TUser, TPrincipal extends Principal = Principal
659
616
  */
660
617
  declare function getPermDock<TUser, TPrincipal extends Principal = Principal, V extends PolicyVocabulary = PolicyVocabulary>(policy: Policy<TUser, TPrincipal, V>, user: TUser | Subject | null, options?: PermDockOptions): Promise<PermDock<V>>;
661
618
  //#endregion
662
- export { memoryApprovalPolicySource as A, PermissionCheck as C, ApprovalPolicySource as D, ApprovalPolicyProblem as E, ApprovalPolicyValidation as O, memoryLimitStore as S, ApprovalPolicy as T, PrincipalSource as _, PermDock as a, Limits as b, RowPair as c, UncheckedData as d, WhereResult as f, PrincipalIdentityLink as g, PrincipalIdentity as h, LoadedRows as i, validateApprovalPolicy as j, approvalPolicies as k, SimulateOptions as l, getPermDockSync as m, DecideOptions as n, PermDockOptions as o, getPermDock as p, DeriveOptions as r, RowData as s, DecideIdsOptions as t, SnapshotOptions as u, memoryPrincipalSource as v, ApprovalPolicies as w, limits as x, PermittedIdsOptions as y };
619
+ export { InstanceCache as C, instanceCache as D, InstanceCacheStats as E, PermissionCheck as O, memoryLimitStore as S, InstanceCacheOptions as T, PrincipalSource as _, PermDock as a, Limits as b, RowPair as c, UncheckedData as d, WhereResult as f, PrincipalIdentityLink as g, PrincipalIdentity as h, LoadedRows as i, PermissionState as k, SimulateOptions as l, getPermDockSync as m, DecideOptions as n, PermDockOptions as o, getPermDock as p, DeriveOptions as r, RowData as s, DecideIdsOptions as t, SnapshotOptions as u, memoryPrincipalSource as v, InstanceCacheKey as w, limits as x, PermittedIdsOptions as y };
@@ -6,18 +6,18 @@ import { t as attachInternals } from "./internals-B3IgHrvo.js";
6
6
  import { _ as keyToScope, a as getResource, c as listPermissions, g as formerScopes } from "./permission-registry-B8tYxPIt.js";
7
7
  import { n as isThenable } from "./thenable-BNSM1U2R.js";
8
8
  import { i as readAppData } from "./app-data-UNNm07jV.js";
9
- import { f as scopeList, h as tenantOf, o as normalizeMemberships } from "./scopes-0Up_UA2t.js";
9
+ import { d as scopeList, o as normalizeMemberships, p as tenantOf } from "./scopes-BSdYaGHs.js";
10
10
  import { o as pickVisible, s as sanitizeContext } from "./validity-Buc7w8E9.js";
11
11
  import { t as byCodePoint } from "./compare-DTfyUunF.js";
12
- import { c as nowSeconds, d as resolveActiveTenant, m as tenantsOf, p as scopeField, t as heldRoleNamesIn, u as relatesTo } from "./tenancy-5d1zVBvK.js";
13
- import { d as policyX } from "./policy-CLQ8__GF.js";
14
- import { D as emptyListeners, E as emitSafe, N as contactMemberships, O as finish, P as isContact, i as customRolesFor, o as roleSourceFor, r as assignableNamesFor, s as sourceName, t as evaluate, u as customGrantsFor, w as unknownLevelsFor } from "./evaluate-BAmf_AQd.js";
15
- import { c as heldRoleNames, d as audiencesOf, g as asMembershipSource, i as assignableIn, l as roleLeaf, o as collectSnapshotGrants, s as whereGrant, t as snapshotOf, u as applyRoleKinds } from "./instance-snapshot-DuWf1cT3.js";
12
+ import { c as nowSeconds, d as resolveActiveTenant, m as tenantsOf, p as scopeField, t as heldRoleNamesIn, u as relatesTo } from "./tenancy-DvOHHk3-.js";
13
+ import { d as policyX } from "./policy-DxQyHKPB.js";
14
+ import { r as isSubject, t as anonymousSubject } from "./subject-C7RddW0G.js";
15
+ import { D as emptyListeners, E as emitSafe, N as contactMemberships, O as finish, P as isContact, i as customRolesFor, o as roleSourceFor, r as assignableNamesFor, s as sourceName, t as evaluate, u as customGrantsFor, w as unknownLevelsFor } from "./evaluate-CsjXeLRo.js";
16
+ import { c as heldRoleNames, d as audiencesOf, g as asMembershipSource, i as assignableIn, l as roleLeaf, o as collectSnapshotGrants, s as whereGrant, t as snapshotOf, u as applyRoleKinds } from "./instance-snapshot-BgOGtyCy.js";
16
17
  import { r as relationReader, t as pendingRelations } from "./relations-BxvRvDHK.js";
17
- import { i as snapshotGrant } from "./snapshot-CXlzi69u.js";
18
- import { a as decideForTarget, i as permittedIds, o as deniedFor, r as mayUse, s as signSnapshot, t as whereFromGrants } from "./where-scope-DlCdCM_8.js";
19
- import { i as decideAllWith, n as canAllWith } from "./checks-CGkP3Z7A.js";
20
- import { r as isSubject, t as anonymousSubject } from "./subject-BGoM5o8B.js";
18
+ import { i as snapshotGrant } from "./snapshot-DN_8J27z.js";
19
+ import { a as decideForTarget, i as permittedIds, o as deniedFor, r as mayUse, s as signSnapshot, t as whereFromGrants } from "./where-scope-BKrqUDVk.js";
20
+ import { i as decideAllWith, n as canAllWith } from "./checks-fyDOhcz0.js";
21
21
  //#region src/core/app.ts
22
22
  const APP = Symbol.for("permdock.app");
23
23
  /**
@@ -41,6 +41,187 @@ function withApp(policy, options) {
41
41
  return merged;
42
42
  }
43
43
  //#endregion
44
+ //#region src/core/freshness.ts
45
+ function versionQuery(principal, issuedAt) {
46
+ return compact({
47
+ id: principal.id,
48
+ roles: principal.roles,
49
+ memberships: principal.memberships,
50
+ authzVersion: principal.authzVersion,
51
+ issuedAt
52
+ });
53
+ }
54
+ /** `known` when it is a version, otherwise the source's answer. */
55
+ function currentVersion(source, query, context, known) {
56
+ return known !== void 0 && Number.isSafeInteger(known) && known >= 0 ? known : source.version?.(query, context);
57
+ }
58
+ function threw(source, auth) {
59
+ auth.push({
60
+ reason: "source-threw",
61
+ source: "memberships",
62
+ ...sourceName(source)
63
+ });
64
+ }
65
+ /**
66
+ * `onStale: 'reread'`: a token behind the source's version has its memberships
67
+ * (and global roles, with `readRoles`) read live; a version that cannot be read
68
+ * keeps the claims and marks the subject stale.
69
+ */
70
+ function rereadStale(source, principal, issuedAt, context, read, auth, readRoles, known) {
71
+ const claims = principal.memberships ?? [];
72
+ const claimed = principal.authzVersion;
73
+ const judge = (current) => typeof claimed === "number" && current !== void 0 && claimed >= current ? "fresh" : "reread";
74
+ const unknown = () => {
75
+ threw(source, auth);
76
+ return "unknown";
77
+ };
78
+ let freshness;
79
+ try {
80
+ const current = currentVersion(source, versionQuery(principal, issuedAt), context, known);
81
+ freshness = isThenable(current) ? Promise.resolve(current).then(judge, unknown) : judge(current);
82
+ } catch {
83
+ freshness = unknown();
84
+ }
85
+ const failed = () => {
86
+ threw(source, auth);
87
+ return [];
88
+ };
89
+ const rolesOf = (found) => {
90
+ if (found !== "reread" || readRoles === void 0) return;
91
+ try {
92
+ const roles = readRoles();
93
+ return isThenable(roles) ? Promise.resolve(roles).catch(failed) : roles;
94
+ } catch {
95
+ return failed();
96
+ }
97
+ };
98
+ if (isThenable(freshness)) {
99
+ const settled = freshness.then((found) => ({
100
+ found,
101
+ roles: rolesOf(found)
102
+ }));
103
+ return {
104
+ memberships: settled.then(({ found }) => found === "reread" ? read() : claims),
105
+ stale: settled.then(({ found }) => found === "unknown"),
106
+ roles: settled.then(({ roles }) => roles)
107
+ };
108
+ }
109
+ return compact({
110
+ memberships: freshness === "reread" ? read() : claims,
111
+ stale: freshness === "unknown",
112
+ roles: rolesOf(freshness)
113
+ });
114
+ }
115
+ /**
116
+ * Whether the token's memberships are behind the source for `fresh`
117
+ * permissions. Live memberships are never stale; token memberships are stale
118
+ * unless a source reports a version the token's `authzVersion` has reached.
119
+ */
120
+ function staleness(policy, principal, source, given, auth) {
121
+ if ((policy.fresh ?? []).length === 0 || principal === null || given.live) return false;
122
+ if (given.stale !== void 0) return given.stale;
123
+ const claimed = principal.authzVersion;
124
+ if (source?.version === void 0 || typeof claimed !== "number") return true;
125
+ const compare = (current) => current === void 0 || claimed < current;
126
+ try {
127
+ const current = currentVersion(source, versionQuery(principal, given.issuedAt), given.context, given.known);
128
+ return isThenable(current) ? Promise.resolve(current).then(compare, () => {
129
+ threw(source, auth);
130
+ return true;
131
+ }) : compare(current);
132
+ } catch {
133
+ threw(source, auth);
134
+ return true;
135
+ }
136
+ }
137
+ //#endregion
138
+ //#region src/core/cached-instance.ts
139
+ /** Options that shape an instance by value; the rest by identity. */
140
+ const DATA_KEYS = /* @__PURE__ */ new Set([
141
+ "tenant",
142
+ "intent",
143
+ "actor",
144
+ "delegation",
145
+ "session",
146
+ "expiresAt",
147
+ "context"
148
+ ]);
149
+ function principalOf(policy, user) {
150
+ if (user === null || user === void 0) return null;
151
+ if (isSubject(user)) return user.principal === null ? null : compact({
152
+ principal: user.principal,
153
+ issuedAt: user.issuedAt
154
+ });
155
+ try {
156
+ const principal = policy.subject(user);
157
+ return principal === null ? null : { principal };
158
+ } catch {
159
+ return null;
160
+ }
161
+ }
162
+ function isVersion(value) {
163
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
164
+ }
165
+ /**
166
+ * The cache key of an instance, with the options to build it with: the version
167
+ * read for the key is passed on as `version.known`, so the build reads none.
168
+ * `undefined` when the subject or its version is unknown.
169
+ */
170
+ async function cacheKey(policy, user, options) {
171
+ const resolved = principalOf(policy, user);
172
+ if (resolved === null) return;
173
+ const intent = options.intent ?? "write";
174
+ let version = options.version?.known;
175
+ if (!isVersion(version) && options.memberships !== void 0) try {
176
+ version = await asMembershipSource(options.memberships).version?.(versionQuery(resolved.principal, resolved.issuedAt), { intent });
177
+ } catch {
178
+ return;
179
+ }
180
+ if (!isVersion(version)) return;
181
+ const data = {};
182
+ const owners = [policy];
183
+ for (const name of Object.keys(options).toSorted()) {
184
+ const value = Reflect.get(options, name);
185
+ if (DATA_KEYS.has(name)) data[name] = value;
186
+ else if (name !== "version") owners.push(value);
187
+ }
188
+ return {
189
+ key: compact({
190
+ principal: resolved.principal.id,
191
+ version,
192
+ tenant: options.tenant,
193
+ intent,
194
+ parts: {
195
+ user,
196
+ data
197
+ }
198
+ }),
199
+ owners,
200
+ options: {
201
+ ...options,
202
+ version: { known: version }
203
+ }
204
+ };
205
+ }
206
+ function cachedSources(options, instances) {
207
+ const { customRoles, entitlements } = options;
208
+ return {
209
+ ...options,
210
+ ...customRoles === void 0 || typeof customRoles === "function" ? {} : { customRoles: instances.customRoles(customRoles) },
211
+ ...entitlements === void 0 ? {} : { entitlements: instances.entitlements(entitlements) }
212
+ };
213
+ }
214
+ /**
215
+ * `create` through `instances`: a subject whose authorization version is known
216
+ * gets the instance built for it at that version, with the cache's custom-role
217
+ * and entitlement memos; any other subject gets a new one.
218
+ */
219
+ async function cachedInstance(policy, user, options, instances, create) {
220
+ const cached = await cacheKey(policy, user, options);
221
+ if (cached === void 0) return create(options);
222
+ return instances.instance(cached.key, cached.owners, () => Promise.resolve(create(cachedSources(cached.options, instances))));
223
+ }
224
+ //#endregion
44
225
  //#region src/core/assert-decision.ts
45
226
  /**
46
227
  * `assert`'s outcome: the granted decision, or the error a refusal throws after
@@ -512,96 +693,6 @@ function buildInstance(policy, subject, envBase, team) {
512
693
  return Object.freeze(instance);
513
694
  }
514
695
  //#endregion
515
- //#region src/core/freshness.ts
516
- function versionQuery(principal, issuedAt) {
517
- return compact({
518
- id: principal.id,
519
- roles: principal.roles,
520
- memberships: principal.memberships,
521
- authzVersion: principal.authzVersion,
522
- issuedAt
523
- });
524
- }
525
- function threw(source, auth) {
526
- auth.push({
527
- reason: "source-threw",
528
- source: "memberships",
529
- ...sourceName(source)
530
- });
531
- }
532
- /**
533
- * `onStale: 'reread'`: a token behind the source's version has its memberships
534
- * (and global roles, with `readRoles`) read live; a version that cannot be read
535
- * keeps the claims and marks the subject stale.
536
- */
537
- function rereadStale(source, principal, issuedAt, context, read, auth, readRoles) {
538
- const claims = principal.memberships ?? [];
539
- const claimed = principal.authzVersion;
540
- const judge = (current) => typeof claimed === "number" && current !== void 0 && claimed >= current ? "fresh" : "reread";
541
- const unknown = () => {
542
- threw(source, auth);
543
- return "unknown";
544
- };
545
- let freshness;
546
- try {
547
- const current = source.version?.(versionQuery(principal, issuedAt), context);
548
- freshness = isThenable(current) ? Promise.resolve(current).then(judge, unknown) : judge(current);
549
- } catch {
550
- freshness = unknown();
551
- }
552
- const failed = () => {
553
- threw(source, auth);
554
- return [];
555
- };
556
- const rolesOf = (found) => {
557
- if (found !== "reread" || readRoles === void 0) return;
558
- try {
559
- const roles = readRoles();
560
- return isThenable(roles) ? Promise.resolve(roles).catch(failed) : roles;
561
- } catch {
562
- return failed();
563
- }
564
- };
565
- if (isThenable(freshness)) {
566
- const settled = freshness.then((found) => ({
567
- found,
568
- roles: rolesOf(found)
569
- }));
570
- return {
571
- memberships: settled.then(({ found }) => found === "reread" ? read() : claims),
572
- stale: settled.then(({ found }) => found === "unknown"),
573
- roles: settled.then(({ roles }) => roles)
574
- };
575
- }
576
- return compact({
577
- memberships: freshness === "reread" ? read() : claims,
578
- stale: freshness === "unknown",
579
- roles: rolesOf(freshness)
580
- });
581
- }
582
- /**
583
- * Whether the token's memberships are behind the source for `fresh`
584
- * permissions. Live memberships are never stale; token memberships are stale
585
- * unless a source reports a version the token's `authzVersion` has reached.
586
- */
587
- function staleness(policy, principal, source, given, auth) {
588
- if ((policy.fresh ?? []).length === 0 || principal === null || given.live) return false;
589
- if (given.stale !== void 0) return given.stale;
590
- const claimed = principal.authzVersion;
591
- if (source?.version === void 0 || typeof claimed !== "number") return true;
592
- const compare = (current) => current === void 0 || claimed < current;
593
- try {
594
- const current = source.version(versionQuery(principal, given.issuedAt), given.context);
595
- return isThenable(current) ? Promise.resolve(current).then(compare, () => {
596
- threw(source, auth);
597
- return true;
598
- }) : compare(current);
599
- } catch {
600
- threw(source, auth);
601
- return true;
602
- }
603
- }
604
- //#endregion
605
696
  //#region src/core/oauth-scopes.ts
606
697
  /**
607
698
  * Every OAuth scope a token may carry to the permission keys it reaches: each
@@ -763,7 +854,7 @@ function assemblePrincipal(policy, user, options, auth, memo) {
763
854
  }, () => read(source, principal), auth, source.globalRolesFor === void 0 ? void 0 : () => source.globalRolesFor?.(compact({
764
855
  id: principal.id,
765
856
  kind: principal.kind
766
- }), { memo }) ?? []);
857
+ }), { memo }) ?? [], options.version?.known);
767
858
  memberships = reread.memberships;
768
859
  stale = reread.stale;
769
860
  roles = reread.roles;
@@ -942,7 +1033,8 @@ function resolveAssembled(policy, assembled, options, auth, memo) {
942
1033
  context: {
943
1034
  memo,
944
1035
  intent: options.intent ?? "write"
945
- }
1036
+ },
1037
+ known: options.version?.known
946
1038
  }, auth);
947
1039
  const withPlans = (resolved) => entitlementsOf(assembled, activeTenantOf(policy, assembled, applyRoleKinds(policy, assembled.principal?.roles, normalizeMemberships(resolved, scopeList(policy.scopes))).memberships, options), options, auth);
948
1040
  if (isThenable(assembled.context) || isThenable(memberships) || isThenable(stale)) return Promise.all([
@@ -1050,7 +1142,8 @@ function getPermDockSync(policy, user, options = {}) {
1050
1142
  * `getPermDockSync` is the synchronous twin.
1051
1143
  */
1052
1144
  function getPermDock(policy, user, options = {}) {
1053
- return Promise.resolve().then(() => create(policy, user, options));
1145
+ const { instances, ...rest } = options;
1146
+ return Promise.resolve().then(() => instances === void 0 ? create(policy, user, rest) : cachedInstance(policy, user, rest, instances, (cached) => create(policy, user, cached)));
1054
1147
  }
1055
1148
  //#endregion
1056
1149
  export { delegatedScopeMap as a, APP as c, challengeScope as i, withApp as l, getPermDockSync as n, hasScope as o, resolveSubject as r, scopesReaching as s, getPermDock as t };
@@ -1,4 +1,4 @@
1
- import { c as crud } from "./src-C_pi2Rnh.js";
1
+ import { c as crud } from "./src-nYNBfmgq.js";
2
2
  import { v as resource } from "./permission-registry-B8tYxPIt.js";
3
3
  import { f as definePlans, p as defineRoles } from "./grantee-Dke-9rd1.js";
4
4
  import { t as definePermissions } from "./permissions-CVXmRILq.js";
@@ -1,5 +1,5 @@
1
- import { n as CliError } from "./errors-Vpu6rKHl.js";
2
- import { i as requirePeer } from "./peer-Q0fuZ6hx.js";
1
+ import { n as CliError } from "./errors-BhRkoNS7.js";
2
+ import { i as requirePeer } from "./peer-BuK9F53f.js";
3
3
  //#region src/cli/pg.ts
4
4
  const CONNECT_TIMEOUT_MS = 1e4;
5
5
  const STATEMENT_TIMEOUT_MS = 6e4;
@@ -1,4 +1,4 @@
1
- import { T as Policy, hr as Subject, pr as Principal } from "./policy-types-DGIO_gxq.js";
1
+ import { E as Policy, _r as Principal, yr as Subject } from "./policy-types-IRJVABmm.js";
2
2
  import { c as saasPlans, l as saasRoles, s as saasPermissions } from "./permissions-Bx6UI8n1.js";
3
3
  //#region src/testing/saas/policy.d.ts
4
4
  /** Daily API-key quota per subject; the bucket should be per tenant too. */
@@ -1,16 +1,17 @@
1
1
  import { t as compact } from "./compact-CAf557ZB.js";
2
2
  import { n as freezeDeep } from "./freeze-jjan0lCv.js";
3
- import { c as withGrantSchema, d as assertApprovalVersions, i as completeGrant, o as flattenGrants, p as normalizeWhere, s as flattenPermissions, u as assertApprovalRelations } from "./role-builder-BK2-T6oD.js";
3
+ import { c as withGrantSchema, i as completeGrant, l as normalizeWhere, o as flattenGrants, s as flattenPermissions } from "./role-builder-BrmOcXch.js";
4
4
  import { c as listPermissions, i as getRegistry, m as annotationsFor, n as findPermission, s as isRegistryTree } from "./permission-registry-B8tYxPIt.js";
5
5
  import { d as isSelfParented, l as isFieldRelation } from "./resource-relations-8-pCScBO.js";
6
6
  import { t as canonicalJson } from "./canonical-json-DwilZ1iB.js";
7
7
  import { r as sha256Digest } from "./sha256-C-4WXKIu.js";
8
- import { n as defineScopes, s as resolveScope } from "./scopes-0Up_UA2t.js";
8
+ import { n as defineScopes, s as resolveScope } from "./scopes-BSdYaGHs.js";
9
9
  import { o as flattenGrantee, r as asGrantee, v as listRoles } from "./grantee-Dke-9rd1.js";
10
+ import { i as assertApprovalVersions, r as assertApprovalRelations } from "./approval-normalize-4KxMRdJC.js";
10
11
  import { n as normalizeValidity } from "./validity-Buc7w8E9.js";
11
12
  import { t as byCodePoint } from "./compare-DTfyUunF.js";
12
- import { a as relationStart, i as relationHops, n as isGraphRelation, t as inheritCondition } from "./grantee-conditions-BrYPe-w0.js";
13
- import { a as memberOfFields, p as scopeField, u as relatesTo } from "./tenancy-5d1zVBvK.js";
13
+ import { a as relationStart, i as relationHops, n as isGraphRelation, t as inheritCondition } from "./grantee-conditions-DX4K_gGI.js";
14
+ import { a as memberOfFields, p as scopeField, u as relatesTo } from "./tenancy-DvOHHk3-.js";
14
15
  //#region src/core/policy-assertions.ts
15
16
  function assertParentGraph(resources) {
16
17
  for (const node of resources.values()) {