permdock 0.21.0 → 0.22.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 (359) hide show
  1. package/README.md +2 -1
  2. package/dist/a2a/index.d.ts +5 -5
  3. package/dist/a2a/index.js +5 -4
  4. package/dist/{adoption-scan-UkQisAqe.js → adoption-scan-_bHLMnVQ.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 +4 -4
  8. package/dist/ai-sdk/index.js +3 -3
  9. package/dist/app/index.d.ts +85 -0
  10. package/dist/app/index.js +91 -0
  11. package/dist/app-DIvM65Mv.js +24 -0
  12. package/dist/{approval-policies-CKlByf5o.d.ts → approval-policies-UnDSxT__.d.ts} +2 -2
  13. package/dist/{approval-prompt-CQFiO1KE.d.ts → approval-prompt-2hTqo6IM.d.ts} +2 -2
  14. package/dist/approvals/index.d.ts +3 -3
  15. package/dist/approvals/index.js +3 -3
  16. package/dist/{approvals-CuXILe52.js → approvals-B_sn4Wrn.js} +6 -6
  17. package/dist/{arazzo-CUthH61H.js → arazzo-BXD-VJU_.js} +1 -1
  18. package/dist/{arazzo-BC3uLIZy.js → arazzo-Ct0PGblq.js} +3 -3
  19. package/dist/astro/index.d.ts +6 -6
  20. package/dist/astro/index.js +2 -2
  21. package/dist/{audience-BUonniPx.js → audience-5Xx1hdIv.js} +1 -1
  22. package/dist/{auth-j3Eu-j4h.js → auth-BxXHxWRy.js} +1 -1
  23. package/dist/authzen/index.d.ts +5 -5
  24. package/dist/authzen/index.js +4 -4
  25. package/dist/{automation-CpOk7Tlu.d.ts → automation-B20_8UoT.d.ts} +3 -3
  26. package/dist/{automation-x3KEUusw.js → automation-BueW05db.js} +2 -2
  27. package/dist/better-auth/index.d.ts +2 -2
  28. package/dist/better-auth/index.js +1 -1
  29. package/dist/better-supabase/index.d.ts +113 -56
  30. package/dist/better-supabase/index.js +200 -62
  31. package/dist/better-supabase-DF8f8oly.js +194 -0
  32. package/dist/{bind-CJf7S-Jd.js → bind-B4Z0U2Gr.js} +5 -5
  33. package/dist/{bind-XvnD_SUz.d.ts → bind-CnOMjazH.d.ts} +7 -7
  34. package/dist/{build-instance-CkRKgjSj.js → build-instance-B0vsViF5.js} +3 -25
  35. package/dist/{capability-zN6T9fxe.js → capability-CenWwTMR.js} +1 -1
  36. package/dist/{capability-v2xZB7us.d.ts → capability-YkRMUAsF.d.ts} +2 -2
  37. package/dist/{casbin-BOZN1P2Y.js → casbin-D5evU3lX.js} +1 -1
  38. package/dist/{casbin-v9Xo_XPa.js → casbin-imBS3UIf.js} +1 -1
  39. package/dist/catalog/index.d.ts +5 -5
  40. package/dist/catalog/index.js +5 -5
  41. package/dist/catalog-C462QC3A.js +1 -0
  42. package/dist/{catalog-DjDc87R2.js → catalog-CoyKnU5c.js} +1 -1
  43. package/dist/{catalog-s0waIrfY.js → catalog-Y4CjN8NA.js} +4 -4
  44. package/dist/{catalog-operations-BD22drQf.js → catalog-operations-Do1eD-Rt.js} +1 -1
  45. package/dist/{challenge-DbkpCx_v.js → challenge-B__LcNve.js} +3 -3
  46. package/dist/chat/index.d.ts +1 -1
  47. package/dist/chat/index.js +3 -2
  48. package/dist/chat-sdk/index.d.ts +3 -3
  49. package/dist/claude-agent/index.d.ts +3 -3
  50. package/dist/claude-agent/index.js +2 -2
  51. package/dist/clerk/index.d.ts +3 -3
  52. package/dist/cli/bin.js +1 -1
  53. package/dist/cli/index.d.ts +8 -7
  54. package/dist/cli/index.js +3 -3
  55. package/dist/cloud/index.d.ts +8 -8
  56. package/dist/cloud/index.js +3 -3
  57. package/dist/{cloud-CB0btByh.js → cloud-DWCeStPH.js} +2 -2
  58. package/dist/{codemod-C3a3Iz_w.js → codemod-B7QKJ_ak.js} +2 -2
  59. package/dist/{codemod-B-duJDFD.js → codemod-BaPmaCYQ.js} +13 -6
  60. package/dist/{collect-DN_x7hvV.js → collect-Cr71JA7z.js} +8 -7
  61. package/dist/{collect-DMQ6Sxr6.js → collect-ScSG05VJ.js} +2 -2
  62. package/dist/collect-W9i7REKT.js +1 -0
  63. package/dist/compile/index.d.ts +1 -1
  64. package/dist/compile/index.js +1 -1
  65. package/dist/{compile-B_oJqmIg.js → compile-Cvru58id.js} +2 -2
  66. package/dist/{compile-DonvwG9x.d.ts → compile-DC-BrhH1.d.ts} +3 -3
  67. package/dist/{completion-6IshPaPd.js → completion-DOUMyCwa.js} +1 -1
  68. package/dist/{delegation-aK4T_5WU.js → condition-evaluate-bVVRSdzq.js} +159 -159
  69. package/dist/{config-C45X7mpm.js → config-DRp-E8Ly.js} +1 -1
  70. package/dist/{config-D2oXUwos.js → config-DyNanTjZ.js} +10 -8
  71. package/dist/{config-report-Bmo62RRr.js → config-report-Bh_nLdAE.js} +2 -2
  72. package/dist/{config-shape-D9paLhEX.js → config-shape-C4zqzG2K.js} +9 -2
  73. package/dist/{context-YhyXyqBI.js → context-Cem4QafV.js} +2 -2
  74. package/dist/convex/index.d.ts +5 -5
  75. package/dist/convex/index.js +2 -2
  76. package/dist/{core-Dxkwz4xR.js → core-CUjhfz0W.js} +6 -6
  77. package/dist/{core-9KbhurkH.d.ts → core-D2JNg5jA.d.ts} +3 -3
  78. package/dist/coverage-D8jBJdgD.d.ts +114 -0
  79. package/dist/coverage-Dh2W_DmF.js +211 -0
  80. package/dist/{create-DH4ZD0A7.d.ts → create-B2tdOygC.d.ts} +7 -7
  81. package/dist/{create-Q0wF9Elt.js → create-BJ2_8NDO.js} +5 -5
  82. package/dist/{create-BRiRVNUO.js → create-BsL5lCWR.js} +8 -7
  83. package/dist/{create-BzgDDamI.d.ts → create-CPDSbK1a.d.ts} +5 -5
  84. package/dist/{create-BQOQkYYg.d.ts → create-oMCcZV4X.d.ts} +9 -9
  85. package/dist/{credential-B3Hj4puZ.js → credential-Bap3HClV.js} +4 -4
  86. package/dist/{server-D0PW6ZCw.js → credentials-BXV0oz56.js} +3 -146
  87. package/dist/credentials-DPX140fN.d.ts +125 -0
  88. package/dist/delivery/index.d.ts +4 -4
  89. package/dist/delivery/index.js +1 -1
  90. package/dist/{denied-text-De8cw3MW.d.ts → denied-text-BXQkWU7d.d.ts} +2 -2
  91. package/dist/{describe-DibQM6g-.d.ts → describe-DVobr5FX.d.ts} +2 -2
  92. package/dist/{diff-BJv7I3GR.js → diff-BR9JArxz.js} +6 -6
  93. package/dist/{diff-3fpwo3UD.js → diff-Jc_kbDz-.js} +1 -1
  94. package/dist/{doctor-Bz7s3JYD.js → doctor-BBMW5ZT_.js} +310 -36
  95. package/dist/{doctor-keoa9DpH.js → doctor-DhqSiPkq.js} +3 -3
  96. package/dist/drizzle/index.d.ts +3 -3
  97. package/dist/drizzle/index.js +1 -1
  98. package/dist/elysia/index.d.ts +5 -5
  99. package/dist/elysia/index.js +3 -3
  100. package/dist/{errors-OTE9u4Wk.d.ts → errors-D_JIQJYb.d.ts} +1 -1
  101. package/dist/{evaluate-Dcq_U2TV.js → evaluate-B5yZHmts.js} +16 -16
  102. package/dist/{evaluations-CNMVJVD6.js → evaluations-BzTDWO4m.js} +57 -57
  103. package/dist/{evaluations-OCm_Z-8V.d.ts → evaluations-DQYfh4Jh.d.ts} +3 -3
  104. package/dist/eve/index.d.ts +5 -5
  105. package/dist/eve/index.js +3 -3
  106. package/dist/express/index.d.ts +5 -5
  107. package/dist/express/index.js +3 -3
  108. package/dist/fastify/index.d.ts +5 -5
  109. package/dist/fastify/index.js +3 -3
  110. package/dist/{fetch-adapter-BlL-ZhHq.d.ts → fetch-adapter-DxqsIXSO.d.ts} +4 -4
  111. package/dist/{fetch-adapter-4EB3cLgB.js → fetch-adapter-MoYZ-vF5.js} +3 -3
  112. package/dist/{fields-D_TfExiI.js → fields-CVyOk-f1.js} +2 -2
  113. package/dist/{fixtures-Cemqurt8.js → fixtures-BVZc7OCF.js} +1 -1
  114. package/dist/{from-snapshot-DHnb8Fh4.js → from-snapshot-oR_N97dM.js} +346 -14
  115. package/dist/{gen-DYF4LKUP.js → gen-DXXoFjyf.js} +1 -1
  116. package/dist/{gen-Cf7nQsOb.js → gen-WdycZ_-b.js} +5 -5
  117. package/dist/{grantee-conditions-DX4K_gGI.js → grantee-conditions-Dzprappv.js} +1 -1
  118. package/dist/{grantee-match-BP-k4vRJ.js → grantee-match-8J2y60MF.js} +3 -3
  119. package/dist/h3/index.d.ts +4 -4
  120. package/dist/h3/index.js +3 -3
  121. package/dist/{helpers-D-MXwkOF.js → helpers-DzBIfL1N.js} +25 -25
  122. package/dist/hono/index.d.ts +5 -5
  123. package/dist/hono/index.js +3 -3
  124. package/dist/{hosted-C2Pmhy2x.js → hosted-C5I2TSXm.js} +4 -4
  125. package/dist/{hosted-yhyAuQkL.d.ts → hosted-DXq1plaP.d.ts} +1 -1
  126. package/dist/{http-DhMWeB_h.js → http-dptLQzPP.js} +1 -1
  127. package/dist/{expiry-6XByK0dm.js → ids-DzhJaCUj.js} +23 -23
  128. package/dist/{import-CQ_kH_Ny.js → import-BE5sDazm.js} +2 -2
  129. package/dist/{import-C2ExjVvv.js → import-CvXswHDy.js} +2 -2
  130. package/dist/index-BcS8c_2S.d.ts +101 -0
  131. package/dist/{index--AwSBzJC.d.ts → index-BdZpqhJK.d.ts} +2 -2
  132. package/dist/{index-CLbGOPBr.d.ts → index-C-R8lBPb.d.ts} +3 -3
  133. package/dist/{index-Do7FqHEr.d.ts → index-C_8uxAlv.d.ts} +5 -5
  134. package/dist/{index-tuR-kZoJ.d.ts → index-Cjfa1Uwr.d.ts} +21 -40
  135. package/dist/{index-BqzpT-90.d.ts → index-iIsqXFVu.d.ts} +6 -6
  136. package/dist/index.d.ts +19 -20
  137. package/dist/index.js +25 -24
  138. package/dist/{init-kTFkEu8S.js → init-B_S8Xdz1.js} +4 -4
  139. package/dist/{init-DvkvbvZ_.js → init-CqGHcvyR.js} +2 -2
  140. package/dist/{instance-options-Cq66kEeR.d.ts → instance-options-C6gEDOts.d.ts} +1 -1
  141. package/dist/instance-options-URVwqpMW.js +24 -0
  142. package/dist/{instance-snapshot-Bi4-dJk0.js → instance-snapshot-D_dGTq--.js} +9 -9
  143. package/dist/jwt/index.d.ts +4 -4
  144. package/dist/jwt/index.js +2 -2
  145. package/dist/{kernel-CLEzDmbv.js → kernel-NmxiWII2.js} +8 -8
  146. package/dist/kysely/index.d.ts +3 -3
  147. package/dist/kysely/index.js +1 -1
  148. package/dist/limits-CAhpRrhk.js +167 -0
  149. package/dist/{load-BaEamml-.js → load-C4p4VgwR.js} +2 -2
  150. package/dist/load-DiBUJx77.js +1 -0
  151. package/dist/{login-9ycIcJZH.js → login-CzwlsBEO.js} +4 -4
  152. package/dist/{login-CM_etiLM.js → login-DoLxv1s5.js} +3 -3
  153. package/dist/{manifest-CCd-xrM3.js → manifest-BAf7cgRx.js} +35 -35
  154. package/dist/{map-claims-PQwHynxV.js → map-claims-CAa_bQt9.js} +1 -1
  155. package/dist/{map-error-EOhahOVA.js → map-error-p4ROJ_26.js} +1 -1
  156. package/dist/mcp/index.d.ts +9 -9
  157. package/dist/mcp/index.js +9 -8
  158. package/dist/{migrate-CkLHdwuH.js → migrate-DVsxeE0y.js} +1 -1
  159. package/dist/{module-values-BYuNtdK5.js → module-values-BLiVlO1X.js} +3 -3
  160. package/dist/nest/index.d.ts +5 -5
  161. package/dist/nest/index.js +3 -3
  162. package/dist/next/index.d.ts +43 -17
  163. package/dist/next/index.js +54 -21
  164. package/dist/next/plugin.d.ts +1 -1
  165. package/dist/next/plugin.js +1 -1
  166. package/dist/node/index.d.ts +5 -5
  167. package/dist/node/index.js +2 -2
  168. package/dist/openai/index.d.ts +5 -5
  169. package/dist/openai/index.js +3 -3
  170. package/dist/openapi/index.d.ts +5 -59
  171. package/dist/openapi/index.js +3 -2
  172. package/dist/{openapi-BOsx0xn9.js → openapi-Cc-aS9xC.js} +6 -135
  173. package/dist/{openapi-QnnU2A1c.js → openapi-DroBcLJZ.js} +2 -2
  174. package/dist/{openapi-DA7FVG2F.js → openapi-EmvKwuWj.js} +4 -4
  175. package/dist/{operations-Ci_rT6Uo.d.ts → operations-BMPx7HyO.d.ts} +1 -1
  176. package/dist/optional-8TKc-0j4.js +47 -0
  177. package/dist/orpc/index.d.ts +7 -7
  178. package/dist/orpc/index.js +4 -4
  179. package/dist/otel/index.d.ts +3 -3
  180. package/dist/otel/index.js +1 -1
  181. package/dist/{output-KT0a3B3H.js → output-CYgfpT6o.js} +1 -1
  182. package/dist/{ownership-CeNOtQMV.js → ownership-adPAsUwY.js} +15 -13
  183. package/dist/{parse-CXTT7hBq.js → parse-CORUNcCo.js} +1 -1
  184. package/dist/{parse-local-manifest-CE4tgFsj.d.ts → parse-local-manifest-BaCqsqwC.d.ts} +1 -1
  185. package/dist/pdp/index.d.ts +3 -3
  186. package/dist/pdp/index.js +4 -3
  187. package/dist/{permdock-DbAq8_Fp.js → permdock-B5LyNVgn.js} +70 -34
  188. package/dist/{permdock-CsrvbzHk.d.ts → permdock-BaB-KQqn.d.ts} +46 -9
  189. package/dist/{permissions-Dz79qsFw.js → permissions-COpRGKt7.js} +1 -1
  190. package/dist/{permissions-Bx6UI8n1.d.ts → permissions-DriWkV7q.d.ts} +1 -2
  191. package/dist/{policy-from-catalog-BtqfxytV.js → policy-from-catalog-Cy103lsm.js} +8 -8
  192. package/dist/{policy-types-BI9C5Sp5.d.ts → policy-types-rNfz7t0M.d.ts} +9 -3
  193. package/dist/{policy-CaAME-Rh.js → policy-wGzbAPQF.js} +7 -7
  194. package/dist/{policy-Dh9WVSVz.d.ts → policy-x8RBKW8d.d.ts} +2 -2
  195. package/dist/{postgrest-CWCCbaxm.d.ts → postgrest-Cn0Res25.d.ts} +9 -21
  196. package/dist/powersync-BdoR7nwS.js +1 -0
  197. package/dist/{powersync-CWsN-QaK.js → powersync-BeI0VmEK.js} +2 -2
  198. package/dist/{powersync-DiqY3VBG.js → powersync-Dpa5AnnN.js} +11 -11
  199. package/dist/preset/index.js +1 -1
  200. package/dist/{preset-pPrVyGU5.js → preset-Bn5Z54cH.js} +5 -6
  201. package/dist/prisma/index.d.ts +2 -2
  202. package/dist/prisma/index.js +1 -1
  203. package/dist/{protected-action-CuG0xz4P.d.ts → protected-action-C4aj1KjO.d.ts} +6 -7
  204. package/dist/{protected-action-CD1HXwQK.js → protected-action-E7Sdt_Dt.js} +1 -1
  205. package/dist/{provider-ihxuJbMi.d.ts → provider-B-1DlOGM.d.ts} +1 -1
  206. package/dist/{provider-qESIf_C0.js → provider-DKO9KHua.js} +2 -2
  207. package/dist/{provider-store-BTHGJH9j.js → provider-store-D4PU1my_.js} +2 -2
  208. package/dist/{pull-B4EhSqOG.js → pull-3tkn25ll.js} +5 -5
  209. package/dist/pull-D90HqWNP.js +1 -0
  210. package/dist/{push-DYOI4bPf.js → push-dMyKdlEm.js} +6 -6
  211. package/dist/{pushed-policy-Dszouliu.js → pushed-policy-Bi5-il4C.js} +2 -2
  212. package/dist/{pushed-policy-P0hgyLBh.d.ts → pushed-policy-P55cJNx5.d.ts} +1 -1
  213. package/dist/react/index.d.ts +6 -6
  214. package/dist/react/index.js +3 -3
  215. package/dist/react/provider-client.d.ts +1 -1
  216. package/dist/react/provider-client.js +1 -1
  217. package/dist/react-native/index.d.ts +9 -9
  218. package/dist/react-native/index.js +7 -7
  219. package/dist/{relation-walk-DK_gkgL7.js → relation-walk-BDTaTKTM.js} +1 -1
  220. package/dist/{relations-BxvRvDHK.js → relations-CMsJ1ARY.js} +1 -1
  221. package/dist/{replay-DYXI4gRN.d.ts → replay-DKhFvt0L.d.ts} +1 -1
  222. package/dist/{request-context-VjeXst1z.js → request-context-5gl_oxO1.js} +2 -2
  223. package/dist/resend/index.d.ts +4 -4
  224. package/dist/resend/index.js +2 -2
  225. package/dist/{resolve-names-BIHnWL_L.js → resolve-names-BnGJU88N.js} +4 -4
  226. package/dist/{rls-C7qXye9M.js → rls-DIYSRnDZ.js} +1 -1
  227. package/dist/{rls-CMFZWosz.js → rls-qrehUPf_.js} +45 -18
  228. package/dist/{role-builder-C5AgaC1x.js → role-builder-boQiUvfo.js} +3 -3
  229. package/dist/{rpc-CYXICjM1.d.ts → rpc-BqRiVpbP.d.ts} +2 -2
  230. package/dist/{rpc-BNIQwEB6.js → rpc-Dhi55Whd.js} +2 -2
  231. package/dist/run-elFdnSZx.js +1 -0
  232. package/dist/{run-CMJX9x7b.js → run-oNqBe0gc.js} +3 -3
  233. package/dist/{run-ticket-CjvXr6wj.js → run-ticket-Ddxt9OuU.js} +2 -2
  234. package/dist/{run-ticket-BXYqQ9dy.d.ts → run-ticket-Dulj4RQk.d.ts} +2 -2
  235. package/dist/{saas-DHFfthXv.js → saas-DABv6vjy.js} +6 -5
  236. package/dist/{scan-CSOkcNdl.js → scan-BYXqcgON.js} +1 -1
  237. package/dist/{schema-7pXCaRYB.js → schema-Wf-SvlHG.js} +1 -1
  238. package/dist/scim/index.d.ts +1 -1
  239. package/dist/scim/index.js +1 -1
  240. package/dist/{scopes-BSdYaGHs.js → scopes-gdH__vDZ.js} +1 -1
  241. package/dist/server/index.d.ts +11 -10
  242. package/dist/server/index.js +7 -6
  243. package/dist/server-CKjFooaJ.js +147 -0
  244. package/dist/{server-types-Bfl-IrzZ.d.ts → server-types--_Hann81.d.ts} +9 -9
  245. package/dist/{shared-sW3VYchq.js → shared-DfaIWvIJ.js} +11 -2
  246. package/dist/{sink-RwmP7ZHs.d.ts → sink-Cs6z34AX.d.ts} +4 -4
  247. package/dist/{skills-DAjg-rgF.js → skills-417bOj4o.js} +1 -1
  248. package/dist/{skills-DrX83QBK.js → skills-B9U465B7.js} +2 -2
  249. package/dist/{snapshot-DHPih65J.js → snapshot-C2j96x97.js} +4 -4
  250. package/dist/{snapshot-cache-MPinwwgZ.d.ts → snapshot-cache-Cc7VNabe.d.ts} +1 -1
  251. package/dist/solid/index.d.ts +6 -7
  252. package/dist/solid/index.js +2 -2
  253. package/dist/solid-start/index.d.ts +6 -6
  254. package/dist/solid-start/index.js +3 -3
  255. package/dist/{sources-sgQlMfmz.d.ts → sources-BfTza0zT.d.ts} +1 -1
  256. package/dist/{src-Cop53_X1.js → src-BG9YJM3Q.js} +96 -247
  257. package/dist/ssf/index.d.ts +3 -3
  258. package/dist/ssf/index.js +3 -3
  259. package/dist/{standard-webhooks-CFZIYtBF.d.ts → standard-webhooks-CJBgfl7y.d.ts} +2 -2
  260. package/dist/{store-CSOsXd5s.js → store-BpKH-pLm.js} +2 -2
  261. package/dist/{store-CRQ5VrWR.d.ts → store-DSyjHD5-.d.ts} +5 -5
  262. package/dist/{store-options-CDvoX52-.js → store-options-CXv6BHH6.js} +5 -6
  263. package/dist/{stores-PpYVQ5yF.js → stores-BuqAHjp_.js} +1 -1
  264. package/dist/{stores-pEBMy94l.d.ts → stores-C6-7TPTV.d.ts} +6 -7
  265. package/dist/{postgrest-BrjrckDG.js → subject-BqFwS6l3.js} +214 -319
  266. package/dist/subject-cache-BT1fGuea.js +193 -0
  267. package/dist/subject-cache-d_Z4KAnm.d.ts +144 -0
  268. package/dist/supabase/index.d.ts +6 -5
  269. package/dist/supabase/index.js +3 -2
  270. package/dist/supabase/middleware.d.ts +6 -6
  271. package/dist/supabase/middleware.js +6 -6
  272. package/dist/{supabase-Cbl2orB2.js → supabase-D0J99yqL.js} +2 -2
  273. package/dist/{supabase-CVZuytCC.js → supabase-DnazO6W4.js} +3 -3
  274. package/dist/{supabase-hook-BUcu3vPM.js → supabase-hook-Bh5syR9N.js} +174 -62
  275. package/dist/supabase-hook-CVAenq-w.js +1 -0
  276. package/dist/{supautils-a_253u1X.js → supautils-ChXR-4Or.js} +302 -43
  277. package/dist/{support-session-BsmPCbz8.js → support-session-BGeEYDSq.js} +2 -2
  278. package/dist/svelte/index.d.ts +5 -5
  279. package/dist/svelte/index.js +3 -3
  280. package/dist/svelte/runtime.d.ts +3 -3
  281. package/dist/svelte/runtime.js +1 -1
  282. package/dist/svelte/source.d.ts +5 -5
  283. package/dist/svelte/source.js +2 -2
  284. package/dist/sveltekit/index.d.ts +6 -6
  285. package/dist/sveltekit/index.js +2 -2
  286. package/dist/{tables-XrvffTMj.js → tables-CbEOy2Ma.js} +137 -55
  287. package/dist/tanstack-start/index.d.ts +6 -6
  288. package/dist/tanstack-start/index.js +2 -2
  289. package/dist/{tenancy-DvOHHk3-.js → tenancy-BlxY5T0q.js} +2 -2
  290. package/dist/terminal/index.d.ts +6 -6
  291. package/dist/terminal/index.js +6 -6
  292. package/dist/testing/core.d.ts +1 -1
  293. package/dist/testing/core.js +1 -1
  294. package/dist/testing/fixtures/index.d.ts +35 -2
  295. package/dist/testing/fixtures/index.js +39 -2
  296. package/dist/testing/index.d.ts +41 -25
  297. package/dist/testing/index.js +114 -26
  298. package/dist/testing/saas/index.d.ts +5 -5
  299. package/dist/testing/saas/index.js +2 -2
  300. package/dist/testing/saas/permissions.d.ts +1 -1
  301. package/dist/testing/saas/permissions.js +1 -1
  302. package/dist/trpc/index.d.ts +6 -6
  303. package/dist/trpc/index.js +4 -4
  304. package/dist/{type-helpers-BjOLGVy1.d.ts → type-helpers-iXJEIDe7.d.ts} +3 -4
  305. package/dist/{types-p8mhWTcR.d.ts → types-B9F0EZAF.d.ts} +3 -3
  306. package/dist/{types-DZwEOsK1.d.ts → types-BSNZMp5b.d.ts} +1 -1
  307. package/dist/{types-MixnvXQ5.d.ts → types-BpxdxaRD.d.ts} +5 -5
  308. package/dist/{types-C3C9ien9.d.ts → types-CD1qmxdx.d.ts} +4 -4
  309. package/dist/{types-D1NjjwI4.d.ts → types-CS1DI_Ke.d.ts} +40 -9
  310. package/dist/{types-zh4WGQcP.d.ts → types-C_a44wSr.d.ts} +3 -3
  311. package/dist/{types-DBVSljAx.d.ts → types-Cq2rvv-C.d.ts} +3 -3
  312. package/dist/{types--_lpWUGV.d.ts → types-CuDXvyIT.d.ts} +5 -5
  313. package/dist/{types-7Vlz1Wi2.d.ts → types-DAyp592k.d.ts} +2 -2
  314. package/dist/{types-DjGZAU64.d.ts → types-NikV1pND.d.ts} +4 -4
  315. package/dist/{types-BzxA2OAD.d.ts → types-ZfjQB0KC.d.ts} +2 -2
  316. package/dist/{types-DotXrris.d.ts → types-_pi9kxS2.d.ts} +2 -2
  317. package/dist/unplugin/index.d.ts +1 -1
  318. package/dist/unplugin/index.js +1 -1
  319. package/dist/{usage-DPbdI3Vi.js → usage-0wsl83uw.js} +10 -10
  320. package/dist/{usage-DHsqp4lN.js → usage-Bl-BkXEq.js} +1 -1
  321. package/dist/usage-CmyGbo4e.js +1 -0
  322. package/dist/{validation-error-DkOK9zUE.d.ts → validation-error-DLAYFlkr.d.ts} +1 -1
  323. package/dist/{verify-C0jGJrmb.js → verify-BSLotSa0.js} +41 -24
  324. package/dist/version-sources-BC3hf2ME.js +34 -0
  325. package/dist/{permission-types-CAY-GU7e.d.ts → vocabulary-DeZvUaTw.d.ts} +69 -1
  326. package/dist/vue/index.d.ts +6 -7
  327. package/dist/vue/index.js +2 -2
  328. package/dist/{waiter-BjVI_Byg.d.ts → waiter-cbK1CBhT.d.ts} +2 -2
  329. package/dist/{watch-Dz2LNM1R.js → watch-BigZ260i.js} +2 -2
  330. package/dist/watch-CHURMgrv.js +1 -0
  331. package/dist/webmcp/index.d.ts +2 -2
  332. package/dist/{who-can-CZeAwQZD.js → who-can-CjfMP9a4.js} +8 -8
  333. package/dist/workflow/index.d.ts +3 -3
  334. package/dist/workflow/index.js +6 -5
  335. package/dist/workflow-sdk/index.d.ts +5 -5
  336. package/dist/{wrap-EQ6Or2Hi.d.ts → wrap-B-k2qHJx.d.ts} +2 -2
  337. package/package.json +16 -4
  338. package/skills/permdock-wire/references/presets-and-recipes.md +2 -2
  339. package/dist/better-supabase-ayun1IKE.js +0 -122
  340. package/dist/catalog-BTPySmbp.js +0 -1
  341. package/dist/collect-eSTXOZDC.js +0 -1
  342. package/dist/index-DuOF7OqS.d.ts +0 -222
  343. package/dist/load-CjnlPxpL.js +0 -1
  344. package/dist/powersync-CWCirKAJ.js +0 -1
  345. package/dist/pull-VzcECZ-R.js +0 -1
  346. package/dist/run-D2e1tybu.js +0 -1
  347. package/dist/supabase-hook-QWphWBnG.js +0 -1
  348. package/dist/usage-dmSjKx-Z.js +0 -1
  349. package/dist/version-cache-q5cpaDSt.d.ts +0 -57
  350. package/dist/vocabulary-DEJ5j4mR.d.ts +0 -70
  351. package/dist/watch-CS69ftMP.js +0 -1
  352. package/dist/where-scope-BAyOsPQW.js +0 -332
  353. package/dist/{approval-normalize-hlfO9BJv.js → approval-normalize-DNLW0zOM.js} +1 -1
  354. package/dist/{body-C9JbIoqb.js → body-B3ylkmmE.js} +1 -1
  355. package/dist/{catalog-doc-nrgfbh8I.js → catalog-doc-Zi0jRpyH.js} +2 -2
  356. package/dist/{device-BwbJNmb2.js → device-BkSynWdg.js} +1 -1
  357. package/dist/{prompt-BYc6drYW.js → prompt-D1Gj1W4Y.js} +1 -1
  358. package/dist/{scim-C30QBBoF.js → scim-BG6uPUeW.js} +1 -1
  359. package/dist/{wrap-C5PWzgkq.js → wrap-BKU5Arsu.js} +1 -1
@@ -1,40 +1,43 @@
1
1
  import { r as isRecord, t as compact } from "../compact-CAf557ZB.js";
2
2
  import { n as freezeDeep } from "../freeze-jjan0lCv.js";
3
3
  import { a as flattenApprovers, i as approverManagerKey, o as holder, r as approverLeaves } from "../approvers-BaNwKYgd.js";
4
+ import { a as permissionStates } from "../checks-fyDOhcz0.js";
4
5
  import { t as loadPrincipal } from "../principal-source-C6N60GtM.js";
5
- import { a as isId, r as idList } from "../expiry-6XByK0dm.js";
6
6
  import { c as listPermissions, n as findPermission, o as isPermission } from "../permission-registry-B8tYxPIt.js";
7
+ import { o as flattenGrantee } from "../grantee-Dke-9rd1.js";
7
8
  import { i as dateAt, m as rfc3339, p as nowSeconds, u as isoAt } from "../time-nR1JesoH.js";
9
+ import { r as isId, t as idList } from "../ids-DzhJaCUj.js";
10
+ import { d as scopeList } from "../scopes-gdH__vDZ.js";
8
11
  import { t as canonicalJson } from "../canonical-json-DwilZ1iB.js";
9
12
  import { r as sha256Digest } from "../sha256-C-4WXKIu.js";
10
- import { t as decideSupportSession } from "../support-session-BsmPCbz8.js";
11
- import { d as scopeList } from "../scopes-BSdYaGHs.js";
12
- import { o as flattenGrantee } from "../grantee-Dke-9rd1.js";
13
- import { n as asApprover } from "../approval-normalize-hlfO9BJv.js";
13
+ import { a as delegatedScopeMap, s as scopesReaching } from "../permdock-B5LyNVgn.js";
14
+ import { t as decideSupportSession } from "../support-session-BGeEYDSq.js";
15
+ import { n as asApprover } from "../approval-normalize-DNLW0zOM.js";
14
16
  import { n as isOperationEffect } from "../operations-Bm9HFecz.js";
15
17
  import { r as isSubject, t as anonymousSubject } from "../subject-C7RddW0G.js";
16
- import { I as decisionTenant } from "../evaluate-Dcq_U2TV.js";
17
- import { _ as claimsFirst } from "../instance-snapshot-Bi4-dJk0.js";
18
- import { a as permissionStates } from "../checks-fyDOhcz0.js";
19
- import { a as delegatedScopeMap, s as scopesReaching } from "../permdock-DbAq8_Fp.js";
18
+ import { I as decisionTenant } from "../evaluate-B5yZHmts.js";
19
+ import { n as readSubjectRecord } from "../subject-cache-BT1fGuea.js";
20
+ import { n as appOf } from "../app-DIvM65Mv.js";
21
+ import { i as linkPolicyViolation, n as capabilityOf, r as capabilitySubject } from "../capability-CenWwTMR.js";
22
+ import { r as credentialSubject, s as parseCredential } from "../credential-Bap3HClV.js";
20
23
  import { s as ApprovalError } from "../types-CcUXciSj.js";
21
- import { t as applyApprovalVerdict } from "../store-CSOsXd5s.js";
22
- import { i as linkPolicyViolation, n as capabilityOf, r as capabilitySubject } from "../capability-zN6T9fxe.js";
23
- import { r as credentialSubject, s as parseCredential } from "../credential-B3Hj4puZ.js";
24
- import { g as managerKeys, s as resumeDecision } from "../helpers-D-MXwkOF.js";
24
+ import { t as applyApprovalVerdict } from "../store-BpKH-pLm.js";
25
+ import { t as instanceOptions } from "../instance-options-URVwqpMW.js";
26
+ import { t as versionSources } from "../version-sources-BC3hf2ME.js";
27
+ import { t as buildInstance } from "../build-instance-B0vsViF5.js";
28
+ import { n as NO_GRANT } from "../decision-CaG5_eNJ.js";
29
+ import { n as parseApprovalHeader } from "../approval-header-8QV6MU4H.js";
30
+ import { h as managerKeys, s as resumeDecision } from "../helpers-DzBIfL1N.js";
25
31
  import { t as AccessReviewError } from "../errors-BDUwg2qC.js";
26
32
  import { t as parseApprovalRequest } from "../parse-request-DOBVaeiQ.js";
27
- import { n as parseApprovalHeader } from "../approval-header-8QV6MU4H.js";
28
33
  import { i as snapshotTag } from "../snapshot-cache-B66h7FBK.js";
29
- import { t as buildInstance } from "../build-instance-CkRKgjSj.js";
30
- import { n as NO_GRANT } from "../decision-CaG5_eNJ.js";
31
34
  import { t as policyRowConditionKeys } from "../row-conditions-BAGHOmVq.js";
32
- import { n as subscribersFor } from "../audience-BUonniPx.js";
35
+ import { n as subscribersFor } from "../audience-5Xx1hdIv.js";
33
36
  import { i as qualifySqlTable, l as sqlIdent, s as quoteSqlLiteral } from "../sql-0WjxIp9g.js";
34
37
  import { o as junctionMembershipSource } from "../sources-C4vkzZJV.js";
35
- import { c as subjectFromSupabaseSession, t as callRpc } from "../postgrest-BrjrckDG.js";
38
+ import { a as callRpc, i as subjectFromSupabaseSession } from "../subject-BqFwS6l3.js";
36
39
  import { n as parseSupabaseManifest, t as hasTokenHook } from "../manifest-BdzBobNK.js";
37
- import { t as parseCatalog } from "../parse-CXTT7hBq.js";
40
+ import { t as parseCatalog } from "../parse-CORUNcCo.js";
38
41
  import { n as activeTenantMismatch, t as activeOrganizationFrom } from "../active-tenant-DVee32-T.js";
39
42
  import { AsyncResult, dbError } from "better-supabase";
40
43
  //#region src/better-supabase/access-reviews.ts
@@ -785,6 +788,99 @@ function subjectFromBetterSupabase(session, options = {}) {
785
788
  });
786
789
  }
787
790
  //#endregion
791
+ //#region src/better-supabase/version-cache.ts
792
+ const DEFAULT_MAX_STALE_MS = 3e4;
793
+ const adapters = /* @__PURE__ */ new WeakMap();
794
+ function isFiniteVersion(value) {
795
+ return typeof value === "number" && Number.isFinite(value);
796
+ }
797
+ function quiet(call) {
798
+ try {
799
+ Promise.resolve(call()).catch(() => void 0);
800
+ } catch {}
801
+ }
802
+ /** better-supabase's cache is the one shape with `get` and no `current`. */
803
+ function isBetterSupabaseVersionCache(value) {
804
+ return isRecord(value) && typeof value["get"] === "function" && typeof value["current"] !== "function";
805
+ }
806
+ /**
807
+ * A PermDock `VersionCache` over better-supabase's `createVersionCache`, so
808
+ * `claimsFirst(source, { versions })` and the cache `createNext({ versions })`
809
+ * evicts are one store. A read answers from `get`; a version PermDock reads is
810
+ * seeded back, and a failing cache reads the version itself.
811
+ */
812
+ function betterSupabaseVersionCache(cache, options = {}) {
813
+ const known = adapters.get(cache);
814
+ if (known !== void 0) return known;
815
+ const inFlight = /* @__PURE__ */ new Map();
816
+ const counts = {
817
+ reads: 0,
818
+ shared: 0,
819
+ storeHits: 0,
820
+ hits: 0,
821
+ evictions: 0
822
+ };
823
+ const seed = (id, version) => {
824
+ if (isFiniteVersion(version) && cache.seed !== void 0) {
825
+ const { seed: put } = cache;
826
+ quiet(() => put.call(cache, id, version));
827
+ }
828
+ };
829
+ const read = async (id, load) => {
830
+ counts.reads += 1;
831
+ const version = await load();
832
+ seed(id, version);
833
+ return version;
834
+ };
835
+ const adapter = Object.freeze({
836
+ name: "better-supabase",
837
+ maxStaleMs: options.maxStaleMs ?? DEFAULT_MAX_STALE_MS,
838
+ async current(principal, load, { live }) {
839
+ if (live) return read(principal.id, load);
840
+ try {
841
+ const cached = await cache.get(principal.id);
842
+ if (isFiniteVersion(cached)) {
843
+ counts.hits += 1;
844
+ return cached;
845
+ }
846
+ } catch {}
847
+ const pending = inFlight.get(principal.id);
848
+ if (pending !== void 0) {
849
+ counts.shared += 1;
850
+ return pending;
851
+ }
852
+ const started = read(principal.id, load);
853
+ inFlight.set(principal.id, started);
854
+ const settle = () => {
855
+ if (inFlight.get(principal.id) === started) inFlight.delete(principal.id);
856
+ };
857
+ started.then(settle, settle);
858
+ return started;
859
+ },
860
+ seed(principal, version) {
861
+ if (Number.isFinite(version)) seed(principal, version);
862
+ },
863
+ evict(principal) {
864
+ counts.evictions += 1;
865
+ inFlight.delete(principal);
866
+ quiet(() => cache.evict(principal));
867
+ },
868
+ stats() {
869
+ return {
870
+ ...counts,
871
+ size: 0
872
+ };
873
+ }
874
+ });
875
+ adapters.set(cache, adapter);
876
+ return adapter;
877
+ }
878
+ /** `versions` as a PermDock `VersionCache`, whichever shape it has. */
879
+ function versionCacheOf(versions) {
880
+ if (versions === void 0) return;
881
+ return isBetterSupabaseVersionCache(versions) ? betterSupabaseVersionCache(versions) : versions;
882
+ }
883
+ //#endregion
788
884
  //#region src/better-supabase/permdock-for.ts
789
885
  /** The options a `permdockFor` resolver already holds. */
790
886
  const RESOLVER_OWNS = [
@@ -793,6 +889,7 @@ const RESOLVER_OWNS = [
793
889
  "version",
794
890
  "versions",
795
891
  "instances",
892
+ "subjects",
796
893
  "options"
797
894
  ];
798
895
  function isResult(source) {
@@ -807,40 +904,57 @@ function subjectOf(source, result, signedOut, options) {
807
904
  return subjectFromBetterSupabase(source, options);
808
905
  }
809
906
  /**
907
+ * `options` with the `definePermDock` definition of its policy under it:
908
+ * `memberships`, `instances`, `versions` and `subjects` by key, and the other
909
+ * sources and `settings` inside `options.options`. A plain policy changes
910
+ * nothing.
911
+ */
912
+ function withDefinition(options) {
913
+ const app = appOf(options.policy);
914
+ if (app === void 0) return options;
915
+ const { memberships, instances, ...sources } = instanceOptions(app);
916
+ return {
917
+ ...options,
918
+ ...compact({
919
+ memberships: options.memberships ?? memberships,
920
+ instances: options.instances ?? instances,
921
+ versions: options.versions ?? app.versions,
922
+ subjects: options.subjects ?? app.subjects
923
+ }),
924
+ options: {
925
+ ...sources,
926
+ ...compact({ settings: app.settings }),
927
+ ...options.options
928
+ }
929
+ };
930
+ }
931
+ /**
810
932
  * The resolver behind `permdockFor`, the authorizer and the hooks: one sources
811
933
  * object per version cache, so every instance of one subject at one version
812
934
  * shares an `instances` entry.
813
935
  */
814
- function permdockResolver(options) {
815
- const byCache = /* @__PURE__ */ new WeakMap();
816
- let uncached;
817
- const sourcesOf = (versions) => ({
818
- ...options.options,
819
- ...options.instances === void 0 ? {} : { instances: options.instances },
820
- ...options.memberships === void 0 ? {} : { memberships: claimsFirst(options.memberships, {
821
- onStale: "reread",
822
- ...options.version === void 0 ? {} : { version: options.version },
823
- ...versions === void 0 ? {} : { versions }
824
- }) }
825
- });
826
- const sourcesFor = (versions) => {
827
- if (versions === void 0) {
828
- uncached ??= sourcesOf(void 0);
829
- return uncached;
830
- }
831
- const known = byCache.get(versions);
832
- if (known !== void 0) return known;
833
- const created = sourcesOf(versions);
834
- byCache.set(versions, created);
835
- return created;
936
+ function permdockResolver(given) {
937
+ const { versions: anyVersions, ...definition } = withDefinition(given);
938
+ const cache = versionCacheOf(anyVersions);
939
+ const options = {
940
+ ...definition,
941
+ ...cache === void 0 ? {} : { versions: cache }
836
942
  };
943
+ const versionSourcesFor = versionSources(options);
944
+ const sourcesFor = (versions) => versionSourcesFor(versionCacheOf(versions));
837
945
  const resolve = async (source, query, runtimeVersions) => {
838
946
  const result = isResult(source) ? source : void 0;
839
947
  const signedOut = result?.sessionActive === false;
840
948
  const user = subjectOf(source, result, signedOut, options.subject);
841
949
  const tenant = query.tenant ?? result?.tenant ?? void 0;
842
950
  const known = signedOut ? void 0 : knownVersion(result?.authzVersion);
843
- const sources = sourcesFor(runtimeVersions ?? options.versions);
951
+ const sources = sourcesFor(runtimeVersions);
952
+ const id = user.principal?.id;
953
+ if (options.subjects !== void 0 && id !== void 0 && known !== void 0) try {
954
+ await options.subjects.record(id, known);
955
+ const record = result?.subject === void 0 ? void 0 : readSubjectRecord(result.subject);
956
+ if (record?.active === true && record.id === id && record.authzVersion === known) await options.subjects.seed(record);
957
+ } catch {}
844
958
  const { permdock } = await buildInstance({
845
959
  policy: options.policy,
846
960
  user,
@@ -855,8 +969,7 @@ function permdockResolver(options) {
855
969
  });
856
970
  return permdock;
857
971
  };
858
- const sources = (versions) => sourcesFor(versions ?? options.versions);
859
- return Object.freeze(Object.assign(resolve, { sources }));
972
+ return Object.freeze(Object.assign(resolve, { sources: sourcesFor }));
860
973
  }
861
974
  /**
862
975
  * The resolver an adapter builds instances with: the app's `permdockFor`, or
@@ -1066,12 +1179,12 @@ function matches(approvers, userId, permdock, managed) {
1066
1179
  * authorization })`), decided by `policy`. Every hook builds the principal's
1067
1180
  * instance from the claims `claims` loads now, never from the request, and
1068
1181
  * fails closed: a throw, an unknown key and `approval-required` refuse.
1069
- * `automation`, `delegation` and `sessionTags` (`snapshotTag(userId)`, so
1070
- * `evictSession` and sign-out clear PermDock snapshots) are always set;
1071
- * `identities`, `delivery`, `approverOf`, `support` and `tickets` only with the
1072
- * options they read. `delegation.permissions` maps each scope to the keys whose
1073
- * `.scope` it is, was renamed from, or that a policy `oauthScopes` entry
1074
- * covers, and reads no `authorization_details`.
1182
+ * `delegation` and `sessionTags` (`snapshotTag(userId)`, so `evictSession` and
1183
+ * sign-out clear PermDock snapshots) are always set; `automation`, `support`
1184
+ * and `tickets` only with `claims`; `identities`, `delivery` and `approverOf`
1185
+ * only with the options they read. `delegation.permissions` maps each scope to
1186
+ * the keys whose `.scope` it is, was renamed from, or that a policy
1187
+ * `oauthScopes` entry covers, and reads no `authorization_details`.
1075
1188
  */
1076
1189
  function authorizationHooks(options) {
1077
1190
  const { policy } = options;
@@ -1088,8 +1201,10 @@ function authorizationHooks(options) {
1088
1201
  const permdock = await instance(claims, automation.tenant);
1089
1202
  return permdock !== null && automation.permissions.every((key) => grants$1(permdock, key));
1090
1203
  };
1204
+ const loadClaims = options.claims;
1091
1205
  const claimsOf = async (userId, tenant) => {
1092
- const claims = await options.claims(userId, tenant === null || tenant === void 0 ? {} : { tenant });
1206
+ if (loadClaims === void 0) return null;
1207
+ const claims = await loadClaims(userId, tenant === null || tenant === void 0 ? {} : { tenant });
1093
1208
  return isRecord(claims) && claims["sub"] === userId ? claims : null;
1094
1209
  };
1095
1210
  const automation = {
@@ -1162,7 +1277,7 @@ function authorizationHooks(options) {
1162
1277
  apiVersion: 1,
1163
1278
  name: "PermDock",
1164
1279
  sessionTags: (userId) => [snapshotTag(userId)],
1165
- automation: Object.freeze(automation),
1280
+ ...loadClaims === void 0 ? {} : { automation: Object.freeze(automation) },
1166
1281
  delegation: Object.freeze(delegation),
1167
1282
  ...approverOf === void 0 ? {} : { approverOf },
1168
1283
  ...identities === void 0 ? {} : { identities: Object.freeze(identities) },
@@ -1170,11 +1285,11 @@ function authorizationHooks(options) {
1170
1285
  subscribers: fanOut,
1171
1286
  audience: fanOut
1172
1287
  }) },
1173
- ...support === void 0 ? {} : { support: Object.freeze({ authorize: supportPolicy({
1288
+ ...loadClaims === void 0 || support === void 0 ? {} : { support: Object.freeze({ authorize: supportPolicy({
1174
1289
  ...support,
1175
1290
  policy
1176
1291
  }) }) },
1177
- ...tickets === void 0 ? {} : { tickets: Object.freeze({ async subject(ticket) {
1292
+ ...loadClaims === void 0 || tickets === void 0 ? {} : { tickets: Object.freeze({ async subject(ticket) {
1178
1293
  try {
1179
1294
  const found = await tickets(ticket);
1180
1295
  if (!isRecord(found) || typeof found.userId !== "string") return null;
@@ -1833,6 +1948,18 @@ function claimsOf(request) {
1833
1948
  const claims = subject.properties?.["claims"];
1834
1949
  return isRecord(claims) ? claims : void 0;
1835
1950
  }
1951
+ /**
1952
+ * What a bootstrap read for this user, from better-supabase's runtime `seed`:
1953
+ * used only when it names the claims' user and carries a version.
1954
+ */
1955
+ function seedOf(runtime, claims) {
1956
+ if (!isRecord(runtime) || !isRecord(runtime["seed"]) || !isRecord(claims)) return;
1957
+ const { userId, version, subject } = runtime["seed"];
1958
+ return typeof userId === "string" && userId !== "" && userId === claims["sub"] && typeof version === "number" && Number.isSafeInteger(version) && version >= 0 ? {
1959
+ version,
1960
+ subject
1961
+ } : void 0;
1962
+ }
1836
1963
  const tenantOf = (request) => {
1837
1964
  const { tenant } = request.context;
1838
1965
  return typeof tenant === "string" ? tenant : null;
@@ -1857,13 +1984,24 @@ function authorizer(options) {
1857
1984
  return isPermission(request.action) && READ_ACTIONS.has(request.action.action) ? "read" : "write";
1858
1985
  };
1859
1986
  const resolve = resolverOf(options, "authorizer");
1860
- const instanceFor = (claims, tenant, intent, runtime) => resolve(claims === void 0 ? null : {
1861
- kind: "user",
1862
- claims
1863
- }, {
1864
- tenant,
1865
- intent
1866
- }, runtime?.versions);
1987
+ const instanceFor = (claims, tenant, intent, runtime) => {
1988
+ const seed = seedOf(runtime, claims);
1989
+ return resolve(claims === void 0 ? null : seed === void 0 ? {
1990
+ kind: "user",
1991
+ claims
1992
+ } : {
1993
+ session: {
1994
+ kind: "user",
1995
+ claims
1996
+ },
1997
+ tenant,
1998
+ authzVersion: seed.version,
1999
+ subject: seed.subject
2000
+ }, {
2001
+ tenant,
2002
+ intent
2003
+ }, runtime?.versions);
2004
+ };
1867
2005
  const scoped = (claims, tenant, intent, runtime, batch) => {
1868
2006
  const key = `permdock:authorizer:${canonicalJson([
1869
2007
  claims ?? null,
@@ -2489,4 +2627,4 @@ function workflowResource(subject, types) {
2489
2627
  });
2490
2628
  }
2491
2629
  //#endregion
2492
- export { accessReviewApplier, apiKeyClaimOptions, apiKeyVerifier, authorizationHooks, authorizationProvider, authorizer, blockApprovalPolicySource, blockApprovalStore, blockMembershipSource, bucketPolicy, credentialGuard, getPermissions, handlerCan, hookCan, permdockFor, principalFromMemberships, principalSource, roleOrderFromCatalog, subjectFromBetterSupabase, subjectFromShareLink, subscriberPolicy, supportPolicy, toolPolicy, topicPolicy, workflowResource };
2630
+ export { accessReviewApplier, apiKeyClaimOptions, apiKeyVerifier, authorizationHooks, authorizationProvider, authorizer, betterSupabaseVersionCache, blockApprovalPolicySource, blockApprovalStore, blockMembershipSource, bucketPolicy, credentialGuard, getPermissions, handlerCan, hookCan, isBetterSupabaseVersionCache, permdockFor, principalFromMemberships, principalSource, roleOrderFromCatalog, subjectFromBetterSupabase, subjectFromShareLink, subscriberPolicy, supportPolicy, toolPolicy, topicPolicy, workflowResource };
@@ -0,0 +1,194 @@
1
+ import { r as isRecord } from "./compact-CAf557ZB.js";
2
+ import "./budget-BBCPDOGP.js";
3
+ import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
4
+ import { dirname, join, resolve } from "node:path";
5
+ //#region src/cli/shared/doctor-files.ts
6
+ const nodeFiles = Object.freeze({
7
+ exists: (path) => existsSync(path),
8
+ read: (path) => readFileSync(path, "utf8"),
9
+ list: (path) => readdirSync(path),
10
+ isDirectory: (path) => statSync(path, { throwIfNoEntry: false })?.isDirectory() === true
11
+ });
12
+ function filesOf(input) {
13
+ return input.files ?? nodeFiles;
14
+ }
15
+ /** Parses the JSON file at `path`; throws when it is missing or invalid. */
16
+ function readJson(files, path) {
17
+ return JSON.parse(files.read(path));
18
+ }
19
+ //#endregion
20
+ //#region src/cli/shared/workspace.ts
21
+ /**
22
+ * The directories from `cwd` up to the workspace root: the first one with a
23
+ * `pnpm-workspace.yaml`, a `package.json` that declares `workspaces`, or a
24
+ * `.git`. Skills are often installed once at a monorepo's root.
25
+ */
26
+ function workspaceDirs(files, cwd) {
27
+ const dirs = [];
28
+ let dir = resolve(cwd);
29
+ for (;;) {
30
+ dirs.push(dir);
31
+ if (isWorkspaceRoot(files, dir)) return dirs;
32
+ const parent = dirname(dir);
33
+ if (parent === dir) return [resolve(cwd)];
34
+ dir = parent;
35
+ }
36
+ }
37
+ function isWorkspaceRoot(files, dir) {
38
+ if (files.exists(join(dir, "pnpm-workspace.yaml")) || files.exists(join(dir, ".git"))) return true;
39
+ const manifest = join(dir, "package.json");
40
+ if (!files.exists(manifest)) return false;
41
+ try {
42
+ const parsed = readJson(files, manifest);
43
+ return parsed !== null && typeof parsed === "object" && Object.hasOwn(parsed, "workspaces");
44
+ } catch {
45
+ return false;
46
+ }
47
+ }
48
+ //#endregion
49
+ //#region src/cli/project/better-supabase.ts
50
+ const CONFIG_FILES = [
51
+ "better-supabase.config.ts",
52
+ "better-supabase.config.mts",
53
+ "better-supabase.config.js",
54
+ "better-supabase.config.mjs"
55
+ ];
56
+ /**
57
+ * The default export of the project's better-supabase config, if it loads.
58
+ * `betterSupabase.config` in `permdock.config.ts` names it; without that the
59
+ * search starts in `from` (default `cwd`), the directory of
60
+ * `permdock.config.ts`, and goes up to the workspace root, so an app inside a
61
+ * monorepo finds the root's config.
62
+ */
63
+ async function betterSupabaseConfig(input) {
64
+ const files = filesOf(input);
65
+ const path = input.path === void 0 ? workspaceDirs(files, input.from ?? input.cwd).flatMap((dir) => CONFIG_FILES.map((name) => resolve(dir, name))).find((file) => files.exists(file)) : [resolve(input.cwd, input.path)].find((file) => files.exists(file));
66
+ if (path === void 0) return;
67
+ try {
68
+ const { loadModule } = await import("./load-DiBUJx77.js");
69
+ const loaded = (await loadModule(path))["default"];
70
+ return isRecord(loaded) ? loaded : void 0;
71
+ } catch {
72
+ return;
73
+ }
74
+ }
75
+ const DEPENDENCY_FIELDS = [
76
+ "dependencies",
77
+ "devDependencies",
78
+ "peerDependencies",
79
+ "optionalDependencies"
80
+ ];
81
+ function declaresBetterSupabase(files, directory) {
82
+ const manifest = join(directory, "package.json");
83
+ if (!files.exists(manifest)) return false;
84
+ try {
85
+ const parsed = readJson(files, manifest);
86
+ return isRecord(parsed) && DEPENDENCY_FIELDS.some((field) => {
87
+ const group = parsed[field];
88
+ return isRecord(group) && Object.hasOwn(group, "better-supabase");
89
+ });
90
+ } catch {
91
+ return false;
92
+ }
93
+ }
94
+ /** The patterns of `pnpm-workspace.yaml`'s `packages:` list or `workspaces`. */
95
+ function workspacePatterns(files, root) {
96
+ const patterns = [];
97
+ const yaml = join(root, "pnpm-workspace.yaml");
98
+ if (files.exists(yaml)) {
99
+ let inPackages = false;
100
+ for (const line of files.read(yaml).split("\n")) if (/^packages\s*:/u.test(line)) inPackages = true;
101
+ else if (/^\S/u.test(line)) inPackages = false;
102
+ else if (inPackages) {
103
+ const item = /^\s*-\s*["']?([^"'#\s]+)["']?/u.exec(line);
104
+ if (item?.[1] !== void 0) patterns.push(item[1]);
105
+ }
106
+ }
107
+ const manifest = join(root, "package.json");
108
+ if (files.exists(manifest)) try {
109
+ const parsed = readJson(files, manifest);
110
+ const workspaces = isRecord(parsed) ? parsed["workspaces"] : void 0;
111
+ const list = isRecord(workspaces) ? workspaces["packages"] : workspaces;
112
+ if (Array.isArray(list)) patterns.push(...list.filter((entry) => typeof entry === "string"));
113
+ } catch {}
114
+ return patterns;
115
+ }
116
+ /**
117
+ * The package directories a workspace pattern names: `dir/*`, `dir/**` or a
118
+ * path.
119
+ */
120
+ function packageDirs(files, root, pattern) {
121
+ if (pattern.startsWith("!")) return [];
122
+ const base = pattern.replace(/\/\*\*?$/u, "");
123
+ const dir = resolve(root, base);
124
+ if (base === pattern) return [dir];
125
+ return files.isDirectory(dir) ? files.list(dir).filter((name) => name !== "node_modules" && !name.startsWith(".")).map((name) => join(dir, name)).filter((entry) => files.isDirectory(entry)) : [];
126
+ }
127
+ /**
128
+ * Whether the nearest `package.json` (up to the workspace root) or a workspace
129
+ * package depends on `better-supabase`, for a project whose config file sits in
130
+ * another package than `permdock.config.ts`.
131
+ */
132
+ function betterSupabaseInstalled(input) {
133
+ const files = filesOf(input);
134
+ const dirs = workspaceDirs(files, input.from ?? input.cwd);
135
+ if (dirs.some((dir) => declaresBetterSupabase(files, dir))) return true;
136
+ const root = dirs.at(-1);
137
+ return root !== void 0 && workspacePatterns(files, root).flatMap((pattern) => packageDirs(files, root, pattern)).some((dir) => declaresBetterSupabase(files, dir));
138
+ }
139
+ function stringAt(value, ...path) {
140
+ let at = value;
141
+ for (const key of path) {
142
+ if (!isRecord(at)) return void 0;
143
+ at = at[key];
144
+ }
145
+ return typeof at === "string" && at !== "" ? at : void 0;
146
+ }
147
+ /**
148
+ * The claim better-supabase writes the active tenant to: `auth.tenant.claim` in
149
+ * a grouped config, `claims.tenant` in a flat one, then `rls.tenantClaim` and
150
+ * `tenant_id`.
151
+ */
152
+ function betterSupabaseTenantClaim(config, betterSupabase) {
153
+ return stringAt(betterSupabase, "auth", "tenant", "claim") ?? stringAt(betterSupabase, "claims", "tenant") ?? config.rls?.tenantClaim ?? "tenant_id";
154
+ }
155
+ /** better-supabase's server topic for authorization version changes. */
156
+ const BETTER_SUPABASE_AUTHZ_TOPIC = "better_supabase:authz";
157
+ /**
158
+ * Whether better-supabase's sessions block writes its own version table and the
159
+ * `authz:<uid>` receive policy (`blocks.sessions.authzVersions`).
160
+ */
161
+ function betterSupabaseAuthzVersions(betterSupabase) {
162
+ const blocks = betterSupabase["blocks"];
163
+ const sessions = isRecord(blocks) ? blocks["sessions"] : void 0;
164
+ if (!isRecord(sessions)) return false;
165
+ const options = sessions["options"];
166
+ return sessions["authzVersions"] === true || isRecord(options) && options["authzVersions"] === true;
167
+ }
168
+ /**
169
+ * Resolve the hook defaults once for generation, inspection and doctor. With a
170
+ * config, the hook reads its tenant claim and sessions block; with only the
171
+ * dependency (`installed`), it broadcasts on better-supabase's topic and
172
+ * changes nothing else.
173
+ */
174
+ function betterSupabaseDefaults(config, betterSupabase, installed = false) {
175
+ const hook = config.supabase?.hook;
176
+ if (hook === void 0 || betterSupabase === void 0 && !installed) return config;
177
+ const broadcast = hook.broadcast === false ? false : {
178
+ topic: hook.broadcast?.topic ?? "better_supabase:authz",
179
+ receivePolicy: hook.broadcast?.receivePolicy ?? (betterSupabase === void 0 || !betterSupabaseAuthzVersions(betterSupabase))
180
+ };
181
+ return {
182
+ ...config,
183
+ supabase: {
184
+ ...config.supabase,
185
+ hook: {
186
+ ...hook,
187
+ ...betterSupabase === void 0 ? {} : { activeFrom: hook.activeFrom ?? `app_metadata.${betterSupabaseTenantClaim(config, betterSupabase)}` },
188
+ broadcast
189
+ }
190
+ }
191
+ };
192
+ }
193
+ //#endregion
194
+ export { betterSupabaseInstalled as a, filesOf as c, betterSupabaseDefaults as i, nodeFiles as l, betterSupabaseAuthzVersions as n, betterSupabaseTenantClaim as o, betterSupabaseConfig as r, workspaceDirs as s, BETTER_SUPABASE_AUTHZ_TOPIC as t, readJson as u };
@@ -1,10 +1,10 @@
1
1
  import { t as compact } from "./compact-CAf557ZB.js";
2
- import { l as withApp } from "./permdock-DbAq8_Fp.js";
3
- import { t as composeWraps } from "./wrap-C5PWzgkq.js";
4
- import { r as instanceOptions } from "./build-instance-CkRKgjSj.js";
5
- import { f as invalidSignatureResponse } from "./evaluations-CNMVJVD6.js";
2
+ import { r as withApp } from "./app-DIvM65Mv.js";
3
+ import { t as composeWraps } from "./wrap-BKU5Arsu.js";
4
+ import { t as instanceOptions } from "./instance-options-URVwqpMW.js";
6
5
  import { n as tenantScope } from "./adapter-context-OHikyRqV.js";
7
- import { t as createPermDock } from "./create-BRiRVNUO.js";
6
+ import { t as createPermDock } from "./create-BsL5lCWR.js";
7
+ import { h as invalidSignatureResponse } from "./evaluations-BzTDWO4m.js";
8
8
  //#region src/server/bind.ts
9
9
  /**
10
10
  * The server kernel with the subject and actor callbacks reading the context
@@ -1,11 +1,11 @@
1
- import { Q as Intent, xr as Subject } from "./policy-types-BI9C5Sp5.js";
2
- import { m as ApprovalStore } from "./types-BzxA2OAD.js";
3
- import { t as InstanceOptions } from "./instance-options-Cq66kEeR.js";
1
+ import { Q as Intent, xr as Subject } from "./policy-types-rNfz7t0M.js";
2
+ import { m as ApprovalStore } from "./types-ZfjQB0KC.js";
3
+ import { t as InstanceOptions } from "./instance-options-C6gEDOts.js";
4
4
  import { t as RequestContext } from "./request-context-C2_1lchh.js";
5
- import { n as PermDockWrap } from "./wrap-EQ6Or2Hi.js";
6
- import { o as OtelWrap } from "./types-DotXrris.js";
7
- import { r as PdpFactory } from "./types-zh4WGQcP.js";
8
- import { S as TenantOption, _ as WebBotAuthVerifier, t as DeniedResponse } from "./server-types-Bfl-IrzZ.js";
5
+ import { n as PermDockWrap } from "./wrap-B-k2qHJx.js";
6
+ import { o as OtelWrap } from "./types-_pi9kxS2.js";
7
+ import { r as PdpFactory } from "./types-C_a44wSr.js";
8
+ import { S as TenantOption, _ as WebBotAuthVerifier, t as DeniedResponse } from "./server-types--_Hann81.js";
9
9
  //#region src/server/bind.d.ts
10
10
  /**
11
11
  * The options of every framework adapter; `TContext` is what its callbacks
@@ -1,28 +1,6 @@
1
1
  import { t as compact } from "./compact-CAf557ZB.js";
2
- import { t as getPermDock } from "./permdock-DbAq8_Fp.js";
3
- //#region src/core/instance-options.ts
4
- const INSTANCE_KEYS = {
5
- memberships: true,
6
- relations: true,
7
- entitlements: true,
8
- customRoles: true,
9
- policies: true,
10
- approvalPolicies: true,
11
- sink: true,
12
- limits: true,
13
- principals: true,
14
- instances: true
15
- };
16
- /** The `InstanceOptions` set on `options`, without the adapter's own keys. */
17
- function instanceOptions(options) {
18
- const picked = {};
19
- for (const key of Object.keys(INSTANCE_KEYS)) {
20
- const name = key;
21
- if (options[name] !== void 0) picked[name] = options[name];
22
- }
23
- return picked;
24
- }
25
- //#endregion
2
+ import { t as getPermDock } from "./permdock-B5LyNVgn.js";
3
+ import { t as instanceOptions } from "./instance-options-URVwqpMW.js";
26
4
  //#region src/core/build-instance.ts
27
5
  /**
28
6
  * `resolve()`, or `null` when it throws: a subject or delegation that cannot be
@@ -50,4 +28,4 @@ async function buildInstance(input) {
50
28
  };
51
29
  }
52
30
  //#endregion
53
- export { resolveOrNull as n, instanceOptions as r, buildInstance as t };
31
+ export { resolveOrNull as n, buildInstance as t };
@@ -1,9 +1,9 @@
1
1
  import { t as compact } from "./compact-CAf557ZB.js";
2
2
  import { n as freezeDeep } from "./freeze-jjan0lCv.js";
3
3
  import { a as ownRecord } from "./paths-CUvURzHp.js";
4
- import { a as isId, o as sameId, r as idList, t as expiredAt } from "./expiry-6XByK0dm.js";
5
4
  import { c as listPermissions } from "./permission-registry-B8tYxPIt.js";
6
5
  import { o as epochSeconds, p as nowSeconds } from "./time-nR1JesoH.js";
6
+ import { a as expiredAt, i as sameId, r as isId, t as idList } from "./ids-DzhJaCUj.js";
7
7
  import { t as anonymousSubject } from "./subject-C7RddW0G.js";
8
8
  //#region src/core/capability.ts
9
9
  function redeemerKind(redeemer) {
@@ -1,5 +1,5 @@
1
- import { _t as TokenSigner, qt as Instant, yr as Principal } from "./policy-types-BI9C5Sp5.js";
2
- import { f as PermissionTree, u as Permission } from "./permission-types-CAY-GU7e.js";
1
+ import { _t as TokenSigner, qt as Instant, yr as Principal } from "./policy-types-rNfz7t0M.js";
2
+ import { E as PermissionTree, w as Permission } from "./vocabulary-DeZvUaTw.js";
3
3
  //#region src/core/capability.d.ts
4
4
  /**
5
5
  * Who may redeem a capability: anyone holding it, any signed-in principal, one
@@ -1,4 +1,4 @@
1
- import { a as nonEmptyOr } from "./output-KT0a3B3H.js";
1
+ import { a as nonEmptyOr } from "./output-CYgfpT6o.js";
2
2
  import { t as applyFiles } from "./files-CfiRtQ-m.js";
3
3
  import { n as isIdentifier, t as emitPolicyModule } from "./policy-module-xym9fnSq.js";
4
4
  import { existsSync, readFileSync } from "node:fs";