permdock 0.3.0 → 0.4.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 (323) hide show
  1. package/dist/a2a/index.d.ts +7 -5
  2. package/dist/a2a/index.js +14 -21
  3. package/dist/ai-sdk/index.d.ts +18 -6
  4. package/dist/ai-sdk/index.js +8 -5
  5. package/dist/app-data-CV8pqqMi.js +59 -0
  6. package/dist/approvals/index.d.ts +2 -2
  7. package/dist/approvals/index.js +3 -3
  8. package/dist/{approvals-DbYAuNkG.js → approvals-DZL76lKW.js} +35 -19
  9. package/dist/{approvers-DT4AVyIg.js → approvers-CqPOLD-o.js} +1 -1
  10. package/dist/{arazzo-BAgw9ap6.js → arazzo-C4BcskbX.js} +6 -5
  11. package/dist/{arazzo-CKwwqFWz.js → arazzo-CD8d0WLb.js} +2 -2
  12. package/dist/authzen/index.d.ts +3 -3
  13. package/dist/authzen/index.js +161 -23
  14. package/dist/better-auth/index.d.ts +2 -2
  15. package/dist/better-auth/index.js +6 -19
  16. package/dist/better-supabase/index.d.ts +112 -87
  17. package/dist/better-supabase/index.js +257 -156
  18. package/dist/{bind-C_ob3LKa.d.ts → bind-BzqG8SMb.d.ts} +16 -5
  19. package/dist/{bind-CuzGytRf.js → bind-kk-uyCwH.js} +14 -6
  20. package/dist/build-instance-DIIV9DbC.js +51 -0
  21. package/dist/{canonical-json-DemiK4Vp.js → canonical-json-CFKyFOke.js} +1 -3
  22. package/dist/{capability-2kYTMWDv.d.ts → capability-CksyCWDH.d.ts} +2 -2
  23. package/dist/{capability-4qPdO9gk.js → capability-txATtKV4.js} +3 -2
  24. package/dist/catalog/index.d.ts +1 -1
  25. package/dist/catalog/index.js +1 -1
  26. package/dist/catalog-6yWAX6Ps.js +2 -0
  27. package/dist/{catalog-dFZdWCGN.js → catalog-WHG4kBq7.js} +2 -2
  28. package/dist/{catalog-doc-DdGm82XT.js → catalog-doc-DWtg0gGR.js} +17 -10
  29. package/dist/{catalog-DWF5cYqB.js → catalog-tZUyOfOv.js} +4 -4
  30. package/dist/claude-agent/index.d.ts +4 -4
  31. package/dist/claude-agent/index.js +4 -5
  32. package/dist/clerk/index.d.ts +3 -3
  33. package/dist/clerk/index.js +8 -33
  34. package/dist/cli/bin.js +1 -1
  35. package/dist/cli/index.d.ts +3 -3
  36. package/dist/cli/index.js +3 -3
  37. package/dist/cloud/index.d.ts +4 -4
  38. package/dist/cloud/index.js +9 -15
  39. package/dist/{cloud-CB_ELYuX.js → cloud-C7bSDgX4.js} +2 -2
  40. package/dist/{cloud-DWLXO2af.js → cloud-PeBN3IEn.js} +5 -5
  41. package/dist/{collect-DSTE3ml9.js → collect-2SrB7lfk.js} +6 -8
  42. package/dist/collect-Bw2Jdq1q.js +2 -0
  43. package/dist/{collect-DClJsheJ.js → collect-CQx4hX4N.js} +3 -3
  44. package/dist/{commands-DSxCqG9A.js → commands-Cpip4ULx.js} +13 -13
  45. package/dist/{compact-y6vfu2_f.js → compact-CAf557ZB.js} +11 -1
  46. package/dist/compile/index.d.ts +1 -1
  47. package/dist/compile/index.js +1 -1
  48. package/dist/{compile-Ba4blROR.js → compile-CcEu2ZQ1.js} +6 -5
  49. package/dist/{compile-BkRyBDBw.d.ts → compile-CtTP7eur.d.ts} +2 -2
  50. package/dist/{config-BJiM-xAm.js → config-BIjREpyE.js} +4 -4
  51. package/dist/{config-Dnszbv-6.js → config-DLt6BvV7.js} +2 -2
  52. package/dist/{config-report-DMvWKUxL.js → config-report--Xb9APJS.js} +5 -6
  53. package/dist/{connection-CU8MQxRi.js → connection-DUsczpB5.js} +3 -2
  54. package/dist/constants-DcJABbLW.js +20 -0
  55. package/dist/{context-Bcy85rGi.js → context-DieZVJXu.js} +16 -5
  56. package/dist/convex/index.d.ts +4 -4
  57. package/dist/convex/index.js +14 -16
  58. package/dist/create-BBO24vj6.js +324 -0
  59. package/dist/{credential-8P81ff4u.js → credential-kue0qpbm.js} +4 -4
  60. package/dist/deciding-columns-Sq12mEA6.js +123 -0
  61. package/dist/delegation-input-FTxMK3ji.js +19 -0
  62. package/dist/denied-text-DfRk15uw.d.ts +19 -0
  63. package/dist/{describe-DMYiCjJV.d.ts → describe-C3ldA9os.d.ts} +11 -2
  64. package/dist/{describe-B_gVZEVi.js → describe-Cgkp7eP0.js} +5 -4
  65. package/dist/{diff-DBIhz_f2.js → diff-Cnghh_Ip.js} +2 -2
  66. package/dist/{diff-2VaeChzX.js → diff-rpqoe7Ag.js} +9 -9
  67. package/dist/{doctor-BwCAMLx_.js → doctor-CuVJvhV_.js} +2 -2
  68. package/dist/doctor-owlv6ddh.js +2166 -0
  69. package/dist/drizzle/index.d.ts +2 -2
  70. package/dist/drizzle/index.js +6 -14
  71. package/dist/elysia/index.d.ts +4 -4
  72. package/dist/elysia/index.js +7 -7
  73. package/dist/{errors-DPdqI50v.d.ts → errors-OD_4c__H.d.ts} +2 -2
  74. package/dist/{errors-Cz5zn0mW.js → errors-drnfxYtm.js} +3 -3
  75. package/dist/{evaluations-tz6D9A2G.js → evaluations-C9YJsv3H.js} +45 -7
  76. package/dist/eve/index.d.ts +5 -5
  77. package/dist/eve/index.js +5 -5
  78. package/dist/express/index.d.ts +4 -4
  79. package/dist/express/index.js +8 -7
  80. package/dist/fastify/index.d.ts +15 -5
  81. package/dist/fastify/index.js +9 -29
  82. package/dist/fields-fwfXN01n.js +1016 -0
  83. package/dist/{files-DWUN9PzI.js → files-D_JIzUrP.js} +12 -3
  84. package/dist/{fixtures-ht28Cplr.js → fixtures-h2eG2OZV.js} +5 -6
  85. package/dist/{from-snapshot-CTLijvdm.js → from-snapshot-7REQZe0H.js} +32 -22
  86. package/dist/{generate-CH7ThJ14.js → generate-CNU1pIOo.js} +1 -3
  87. package/dist/grantee-CXY-0C87.js +254 -0
  88. package/dist/grantee-conditions-MQs5NIuX.js +270 -0
  89. package/dist/grantee-match-fxYp9Nmt.js +141 -0
  90. package/dist/{helpers-H_KARDVC.js → helpers-C9YmyBIa.js} +7 -6
  91. package/dist/hono/index.d.ts +4 -4
  92. package/dist/hono/index.js +8 -8
  93. package/dist/hosted-CBHgkzDl.js +655 -0
  94. package/dist/{http-SO7qGttf.js → http-BBoKefeS.js} +35 -2
  95. package/dist/{http-BIhmLfCc.js → http-BEbdMZ05.js} +2 -24
  96. package/dist/{rls-import-BTFVk3jH.js → import-BFIlhetD.js} +86 -80
  97. package/dist/{openapi-import-cmwetbzw.js → import-UHk1N7vH.js} +6 -7
  98. package/dist/{index-C8z4RjQV.d.ts → index-BwMe94Xq.d.ts} +1 -1
  99. package/dist/{index-0nNqHspG.d.ts → index-DgM7w96K.d.ts} +2 -2
  100. package/dist/{index-C7Tw7MaW.d.ts → index-Dz7didpC.d.ts} +3 -3
  101. package/dist/{index-BNc7Wer_.d.ts → index-UdVQgq48.d.ts} +105 -38
  102. package/dist/index.d.ts +15 -13
  103. package/dist/index.js +22 -22
  104. package/dist/{instance-options-jARdwfPN.d.ts → instance-options-plkrsAog.d.ts} +1 -1
  105. package/dist/{json-schema-BsAflUGW.js → json-schema-DBkdUuCO.js} +1 -3
  106. package/dist/jwt/index.d.ts +4 -4
  107. package/dist/jwt/index.js +13 -13
  108. package/dist/{kernel-_RRHmnMY.js → kernel-CB3LrIJM.js} +81 -32
  109. package/dist/kysely/index.d.ts +2 -2
  110. package/dist/kysely/index.js +6 -14
  111. package/dist/{live-options-H2eG8dfJ.js → live-options-BaAFCIiu.js} +16 -3
  112. package/dist/load-B_shHrmd.js +2 -0
  113. package/dist/{load-DhWEB9P1.js → load-C3_oTHyO.js} +11 -3
  114. package/dist/{manifest-iaoBXHKc.js → manifest-BngWKryL.js} +5 -18
  115. package/dist/{map-claims-Z4QZOiFF.js → map-claims-AVlBaJoa.js} +7 -16
  116. package/dist/{map-error-pgUWNNtG.js → map-error-BE27PYkE.js} +5 -5
  117. package/dist/{markers-B0hYLvMD.js → markers-CiwAOZtO.js} +6 -2
  118. package/dist/{may-use-DndQ5tQ-.js → may-use-BOn_dR_w.js} +4 -3
  119. package/dist/mcp/index.d.ts +26 -9
  120. package/dist/mcp/index.js +456 -446
  121. package/dist/{rls-migrate-CN4TlJTO.js → migrate-BwlB5-Wk.js} +75 -15
  122. package/dist/nest/index.d.ts +4 -4
  123. package/dist/nest/index.js +11 -12
  124. package/dist/next/index.d.ts +31 -8
  125. package/dist/next/index.js +29 -33
  126. package/dist/next/plugin.d.ts +1 -1
  127. package/dist/next/plugin.js +1 -1
  128. package/dist/node/index.d.ts +4 -4
  129. package/dist/node/index.js +4 -4
  130. package/dist/ocsf-uYFXGVw2.js +115 -0
  131. package/dist/openai/index.d.ts +5 -5
  132. package/dist/openai/index.js +4 -4
  133. package/dist/openapi/index.d.ts +3 -3
  134. package/dist/openapi/index.js +1 -1
  135. package/dist/{openapi-CqqEbHsL.js → openapi-BJdBmYDG.js} +19 -23
  136. package/dist/{openapi-BqRBvAng.js → openapi-DBzHQbov.js} +2 -5
  137. package/dist/{openapi-l0xYHkcv.js → openapi-DcQ1Kg40.js} +3 -3
  138. package/dist/orpc/index.d.ts +5 -5
  139. package/dist/orpc/index.js +9 -11
  140. package/dist/otel/index.d.ts +2 -2
  141. package/dist/otel/index.js +26 -23
  142. package/dist/output-files-CgIsvdSa.js +140 -0
  143. package/dist/{rls-ownership-RuFqaqGz.js → ownership-BgnbOJFT.js} +387 -379
  144. package/dist/{package-root-zGkxO3oN.js → package-root-DtNnpmUd.js} +3 -2
  145. package/dist/{parse-BuyjxhZV.js → parse-CVFQHk6c.js} +3 -3
  146. package/dist/{parse-local-manifest-BrMozJCo.js → parse-local-manifest-C-q02Pal.js} +2 -4
  147. package/dist/{parse-local-manifest-JLnaBH0S.d.ts → parse-local-manifest-DvYUR0QL.d.ts} +1 -1
  148. package/dist/pdp/index.d.ts +2 -2
  149. package/dist/pdp/index.js +8 -9
  150. package/dist/{permdock-CbgvLnuo.js → permdock-L26udHSk.js} +1387 -1220
  151. package/dist/{rls-fields-74oZPXWL.js → permission-keys-B26jeyUv.js} +1289 -2066
  152. package/dist/permission-registry-BsblpB-z.js +385 -0
  153. package/dist/{permissions-DttnqqxC.d.ts → permission-types-Dg39z9Kv.d.ts} +59 -31
  154. package/dist/{permissions-RJrovw98.js → permissions-CCJ6lmxB.js} +3 -3
  155. package/dist/{permissions-CDgvKG5L.d.ts → permissions-COH-KRgT.d.ts} +2 -2
  156. package/dist/{policy-IB6yxpC3.d.ts → policy-types-sp9P1iIV.d.ts} +661 -582
  157. package/dist/{policy-D2W7uv19.d.ts → policy-ur0BBK_e.d.ts} +2 -2
  158. package/dist/{powersync-DliZK_-y.js → powersync-BFSbSElQ.js} +2 -2
  159. package/dist/powersync-DCDgZgfZ.js +2 -0
  160. package/dist/{powersync-BylawD_U.js → powersync-cZe4kzhL.js} +26 -27
  161. package/dist/prisma/index.d.ts +1 -1
  162. package/dist/prisma/index.js +6 -12
  163. package/dist/{problem-B43ztKIm.js → problem-CnWraVhC.js} +8 -7
  164. package/dist/{problem-details-_AMOYz-w.js → problem-details-DECUnXAn.js} +2 -2
  165. package/dist/{problem-details-DX075l9V.d.ts → problem-details-rIIo8B2C.d.ts} +1 -1
  166. package/dist/{protected-BdnIEFkY.d.ts → protected-B3_P7xuw.d.ts} +9 -6
  167. package/dist/{protected-utU-SLuy.js → protected-BN7BUdY1.js} +20 -8
  168. package/dist/{provider-CSQd7m92.js → provider-Bi-0HNL3.js} +23 -10
  169. package/dist/{provider-DZY281jO.d.ts → provider-kwHC9CZD.d.ts} +1 -1
  170. package/dist/{provider-store-Cfbvo4DE.js → provider-store-Ctt-81Ni.js} +6 -3
  171. package/dist/react/index.d.ts +7 -7
  172. package/dist/react/index.js +5 -5
  173. package/dist/react/provider-client.d.ts +1 -1
  174. package/dist/react/provider-client.js +1 -1
  175. package/dist/react-native/index.d.ts +20 -11
  176. package/dist/react-native/index.js +33 -17
  177. package/dist/{refs-KYb4ntaz.js → refs-f3imMjNW.js} +1 -1
  178. package/dist/relation-walk-BXnlLtg2.js +186 -0
  179. package/dist/relations-CvmSpG67.js +163 -0
  180. package/dist/{replay-CYyiLiwO.d.ts → replay-COpmZUfx.d.ts} +1 -1
  181. package/dist/request-context-BVM7aWNs.js +71 -0
  182. package/dist/request-context-C2_1lchh.d.ts +5 -0
  183. package/dist/resource-relations-D1Un3pcz.js +243 -0
  184. package/dist/retire-BFcxL6un.js +240 -0
  185. package/dist/{rls-B4ur8nKQ.js → rls-55DQTuf5.js} +14 -2
  186. package/dist/{rls-DQtdgTHB.js → rls-BEktUaqg.js} +884 -484
  187. package/dist/{policy-xyWg7QdR.js → role-builder-B4GbKM-i.js} +235 -541
  188. package/dist/{rpc-DL9Sqvb1.js → rpc-nYC3cR_u.js} +15 -5
  189. package/dist/{run-DKDbM4Du.js → run-DMcNW_8T.js} +3 -3
  190. package/dist/{runtime-CB8gQFvS.js → runtime-D_tMXnsq.js} +1 -1
  191. package/dist/{saas-DhpJjnBA.js → saas-DtaA4JuW.js} +9 -8
  192. package/dist/{openapi-schema--ARjyfQr.js → schema-Bol6gqXA.js} +3 -5
  193. package/dist/{schema-D3MnDMxa.js → schema-DjQBcAP9.js} +4 -2
  194. package/dist/scim/index.d.ts +1 -1
  195. package/dist/scim/index.js +1 -1
  196. package/dist/{scim-BFGBBAqR.js → scim-vFR1O5oG.js} +6 -12
  197. package/dist/{scopes-CVdPrWN-.js → scopes-tvpa34ep.js} +10 -2
  198. package/dist/server/index.d.ts +18 -8
  199. package/dist/server/index.js +8 -8
  200. package/dist/{server-DlZ28Oz5.js → server-ZYEHtNHS.js} +4 -4
  201. package/dist/{create-B1d519XK.d.ts → server-types-DdqBwZN_.d.ts} +69 -33
  202. package/dist/shared-1uhI-e-b.js +294 -0
  203. package/dist/{shared-DRu8VFVM.js → shared-JhMeOsDF.js} +1 -1
  204. package/dist/{sink-Bd9PSyfq.js → sink-BTtmfPnE.js} +1 -1
  205. package/dist/{sink-B1fZzIMf.d.ts → sink-CPN4zLfs.d.ts} +1 -1
  206. package/dist/{skills-Biq5uup3.js → skills-BZdRQkxs.js} +4 -3
  207. package/dist/{skills-Bx-U0irG.js → skills-Dle4ZoLF.js} +2 -2
  208. package/dist/{snapshot-Enxd0n-s.js → snapshot-Dc9CHPME.js} +116 -13
  209. package/dist/{snapshot-cache-D6jLelln.js → snapshot-cache-Cod40D-X.js} +1 -1
  210. package/dist/{snapshot-cache-B-LxUahj.d.ts → snapshot-cache-J5T7t_vD.d.ts} +1 -1
  211. package/dist/solid/index.d.ts +22 -22
  212. package/dist/solid/index.js +40 -10
  213. package/dist/{sources-4p0-4xQm.js → sources-B1-b-R0t.js} +25 -26
  214. package/dist/{sources-BdOYLw9j.d.ts → sources-Dljy06zL.d.ts} +6 -2
  215. package/dist/{sql-xdg5f4Fi.js → sql-t8teWOfo.js} +19 -3
  216. package/dist/{src-BDwEZWrZ.js → src-Bb7no-hS.js} +194 -123
  217. package/dist/ssf/index.d.ts +3 -3
  218. package/dist/ssf/index.js +58 -61
  219. package/dist/store-9KO4BlkB.d.ts +147 -0
  220. package/dist/{store-DMAWwAJV.js → store-ILkLUj_o.js} +4 -4
  221. package/dist/{store-options-ByhZq1jV.js → store-options-CbUHDoSe.js} +16 -7
  222. package/dist/{stores-BT2pSCub.js → stores-BHXdSbw9.js} +7 -3
  223. package/dist/stores-Cxz_80g-.d.ts +31 -0
  224. package/dist/{stream-DDpvynSB.js → stream-BMui98KK.js} +2 -1
  225. package/dist/{stream-D1RXubw2.d.ts → stream-Dwsg6WwE.d.ts} +2 -2
  226. package/dist/{subject-settings-BwBmCdTR.js → subject-settings-CkEwrw3W.js} +23 -5
  227. package/dist/supabase/index.d.ts +4 -4
  228. package/dist/supabase/index.js +3 -3
  229. package/dist/supabase/middleware.d.ts +11 -5
  230. package/dist/supabase/middleware.js +10 -7
  231. package/dist/{supabase-C0qESOa-.js → supabase-C1TWlnYt.js} +36 -52
  232. package/dist/{supabase-Boqb9a_Y.js → supabase-Dbqr141s.js} +2 -2
  233. package/dist/supabase-hook-BULg7Ut_.js +2 -0
  234. package/dist/{supabase-hook-CSLQ4zJ3.js → supabase-hook-Cva3ikXz.js} +731 -782
  235. package/dist/{supautils-Cn4R4cJ4.js → supautils-B6HYL9eL.js} +2 -2
  236. package/dist/svelte/Protected.svelte +9 -2
  237. package/dist/svelte/index.d.ts +6 -6
  238. package/dist/svelte/index.js +25 -11
  239. package/dist/svelte/runtime.d.ts +10 -3
  240. package/dist/svelte/runtime.js +4 -3
  241. package/dist/svelte/source.d.ts +6 -6
  242. package/dist/svelte/source.js +4 -4
  243. package/dist/{validity-uOp8UpYn.js → tenancy-DshjqY0n.js} +3 -39
  244. package/dist/terminal/index.d.ts +5 -5
  245. package/dist/terminal/index.js +18 -34
  246. package/dist/testing/index.d.ts +89 -77
  247. package/dist/testing/index.js +1276 -1262
  248. package/dist/testing/saas/index.d.ts +4 -4
  249. package/dist/testing/saas/index.js +2 -2
  250. package/dist/testing/saas/permissions.d.ts +1 -1
  251. package/dist/testing/saas/permissions.js +1 -1
  252. package/dist/thenable-QSmvt-vZ.js +65 -0
  253. package/dist/{token-CIWxJOCh.js → token-Bx9qy30p.js} +1 -1
  254. package/dist/tool-refusal-CQ7OEia9.js +41 -0
  255. package/dist/trpc/index.d.ts +5 -5
  256. package/dist/trpc/index.js +7 -8
  257. package/dist/{types-DbjRN55U.d.ts → types-7rJVLWe5.d.ts} +82 -4
  258. package/dist/{types-aqOHTHcp.d.ts → types-Br9IXUBG.d.ts} +1 -1
  259. package/dist/types-ByUo56un.d.ts +88 -0
  260. package/dist/{types-Cq_H8N_X.d.ts → types-C0dee0Qf.d.ts} +2 -2
  261. package/dist/{types-DxiCGmmd.d.ts → types-CIlTojhq.d.ts} +2 -2
  262. package/dist/{types-QCuYJh4q.d.ts → types-CUcFZfpU.d.ts} +1 -1
  263. package/dist/{types-C97IskBw.d.ts → types-CqrjB9o6.d.ts} +1 -1
  264. package/dist/{types-BnIEz1sU.d.ts → types-DHrmBJLH.d.ts} +24 -6
  265. package/dist/{types-Dnemwd77.d.ts → types-DpWfQdSh.d.ts} +5 -1
  266. package/dist/{types-Bvc4oWT6.d.ts → types-DvupZE0w.d.ts} +1 -1
  267. package/dist/unplugin/index.d.ts +1 -1
  268. package/dist/unplugin/index.js +1 -1
  269. package/dist/{usage-GTixvDDU.js → usage-4G6t643F.js} +2 -2
  270. package/dist/{usage-ItS7nLcl.js → usage-CG9nOYZw.js} +7 -7
  271. package/dist/usage-iFLJ0-rr.js +2 -0
  272. package/dist/{validation-error-Ba264OaJ.d.ts → validation-error-BSSw0l_8.d.ts} +1 -1
  273. package/dist/{validation-error-CnjZ4t92.js → validation-error-ZfUHbKvf.js} +1 -1
  274. package/dist/validity-dVrUEPJt.js +62 -0
  275. package/dist/{verifier-BxBo6I44.js → verifier-DMr_Zmb_.js} +51 -15
  276. package/dist/{rls-verify-CVQTHTh5.js → verify-BztUB3GX.js} +668 -239
  277. package/dist/{version-BvacVTZR.js → version-BEogC-rB.js} +1 -1
  278. package/dist/{views-Soe7bGSC.js → views-CJsrBS1f.js} +23 -1
  279. package/dist/{vocabulary-DA8a8zif.d.ts → vocabulary-hhEFLFoL.d.ts} +15 -6
  280. package/dist/vue/index.d.ts +24 -19
  281. package/dist/vue/index.js +24 -8
  282. package/dist/watch-C8TpsAl4.js +2 -0
  283. package/dist/{watch-DVBJ9cBq.js → watch-zeucB7eF.js} +6 -6
  284. package/dist/webmcp/index.d.ts +2 -2
  285. package/dist/webmcp/index.js +13 -37
  286. package/dist/wrap-Cr93qqdP.d.ts +14 -0
  287. package/dist/wrap-DWsU_5Bd.js +26 -0
  288. package/package.json +8 -8
  289. package/schemas/catalog-v1.json +6 -0
  290. package/skills/permdock-credentials/SKILL.md +1 -1
  291. package/skills/permdock-credentials/references/tokens-keys-links.md +7 -2
  292. package/skills/permdock-data/references/queries-and-rls.md +4 -0
  293. package/skills/permdock-tenancy/references/ownership-and-custom-roles.md +1 -0
  294. package/skills/permdock-wire/SKILL.md +2 -2
  295. package/skills/permdock-wire/references/adapters.md +9 -1
  296. package/skills/permdock-wire/references/policy-options.md +10 -1
  297. package/dist/catalog-CRW5Mx_B.js +0 -2
  298. package/dist/collect-DSWOk19R.js +0 -2
  299. package/dist/create-CMwIl-w2.js +0 -253
  300. package/dist/delegation-D8pUEuce.js +0 -103
  301. package/dist/doctor-collect-CHk6XWOA.js +0 -665
  302. package/dist/doctor-igIiM_Hl.js +0 -1194
  303. package/dist/evaluation-items-CfCCejQd.js +0 -40
  304. package/dist/fields-BMl1RxoX.js +0 -26
  305. package/dist/grantee-Cv5Sogfv.js +0 -602
  306. package/dist/hosted-DJQw46hn.js +0 -266
  307. package/dist/instance-options-Dhhcnm3y.js +0 -22
  308. package/dist/load-DwJUafYN.js +0 -2
  309. package/dist/map-AcxK9o_D.js +0 -147
  310. package/dist/permissions-DVoF6dMt.js +0 -662
  311. package/dist/powersync-e_AZrKbg.js +0 -2
  312. package/dist/protected-xAr24FEC.d.ts +0 -40
  313. package/dist/relations-cjOL01hZ.js +0 -505
  314. package/dist/rls-graph-CHwx0V8q.js +0 -435
  315. package/dist/rls-shared-Cewd_-zI.js +0 -495
  316. package/dist/store-jOBYpiXC.d.ts +0 -36
  317. package/dist/stores-C0IMQrGI.d.ts +0 -52
  318. package/dist/supabase-config-BpPXt3x1.js +0 -472
  319. package/dist/supabase-hook-6sYLXg_u.js +0 -2
  320. package/dist/thenable-okc2xDsj.js +0 -10
  321. package/dist/types-CKNSyIf_.d.ts +0 -52
  322. package/dist/usage-DorAJiU_.js +0 -2
  323. package/dist/watch-BwxLTYMZ.js +0 -2
@@ -1,16 +1,19 @@
1
- import { t as compact } from "./compact-y6vfu2_f.js";
1
+ import { r as isRecord, t as compact } from "./compact-CAf557ZB.js";
2
2
  import { n as freezeDeep } from "./freeze-CrU8nQeX.js";
3
- import { i as findPermission } from "./permissions-DVoF6dMt.js";
4
- import { b as assertSqlFunctionArg, i as declaredRoleNames, s as grantList, u as levelNames, v as normalizeWhere, x as assertSqlFunctionName, y as assertPortableTwin } from "./policy-xyWg7QdR.js";
5
- import { d as scopeList, m as tenantOf } from "./scopes-CVdPrWN-.js";
6
- import { r as snapshotGrant, t as buildSnapshot } from "./snapshot-Enxd0n-s.js";
7
- import { T as listPlans, s as flattenGrantee } from "./grantee-Cv5Sogfv.js";
8
- import { t as canonicalJson } from "./canonical-json-DemiK4Vp.js";
3
+ import { n as isThenable, s as ownGet } from "./thenable-QSmvt-vZ.js";
4
+ import { _ as assertSqlFunctionName, g as assertSqlFunctionArg, h as assertPortableTwin, m as normalizeWhere } from "./role-builder-B4GbKM-i.js";
5
+ import { d as scopeList, m as tenantOf } from "./scopes-tvpa34ep.js";
6
+ import { r as snapshotGrant, t as buildSnapshot } from "./snapshot-Dc9CHPME.js";
7
+ import { d as attachRegistry, i as getRegistry, n as findPermission, p as walk, r as formerByKey, t as assertKeys } from "./permission-registry-BsblpB-z.js";
8
+ import { c as isEdgeRelation, m as restrictedStops, o as groupEntries, r as assertGraphTargets, s as isComputedRelation, u as isPrincipalRelation } from "./resource-relations-D1Un3pcz.js";
9
+ import { _ as listPlans, o as flattenGrantee } from "./grantee-CXY-0C87.js";
10
+ import { t as canonicalJson } from "./canonical-json-CFKyFOke.js";
11
+ import { m as tenantsOf } from "./tenancy-DshjqY0n.js";
12
+ import { a as declaredRoleNames, l as levelNames, s as grantList } from "./hosted-CBHgkzDl.js";
9
13
  import { n as sha256, t as bytesToBase64Url } from "./sha256-BO0swRXL.js";
10
- import { g as tenantsOf } from "./validity-uOp8UpYn.js";
11
- import { n as isThenable } from "./thenable-okc2xDsj.js";
12
- import { a as collectSnapshotGrants, c as rankRoles, l as usesAssigns, m as ceilingGrants, n as resolveSubject, o as snapshotOf, s as snapshotScopes, u as declaredRoleNames$1, y as resolveCustomRole } from "./permdock-CbgvLnuo.js";
13
- import { n as LOCAL_CUSTOM_ROLE } from "./parse-local-manifest-BrMozJCo.js";
14
+ import { c as collectSnapshotGrants, l as rankRoles, m as ceilingGrants, n as resolveSubject, o as snapshotOf, s as snapshotScopes, u as usesAssigns, y as resolveCustomRole } from "./permdock-L26udHSk.js";
15
+ import { n as relationId } from "./relations-CvmSpG67.js";
16
+ import { n as LOCAL_CUSTOM_ROLE } from "./parse-local-manifest-C-q02Pal.js";
14
17
  //#region src/conditions/sql-function.ts
15
18
  function sqlFunction(name, options) {
16
19
  assertSqlFunctionName(name);
@@ -26,7 +29,7 @@ function sqlFunction(name, options) {
26
29
  });
27
30
  }
28
31
  //#endregion
29
- //#region src/core/interfaces.ts
32
+ //#region src/core/memory-sources.ts
30
33
  function memoryEntitlementSource(entries) {
31
34
  return { entitlementsFor(_principal, options) {
32
35
  return options.tenant === void 0 ? [] : [...entries[options.tenant] ?? []];
@@ -129,6 +132,169 @@ function fromStripeEntitlements(options) {
129
132
  } };
130
133
  }
131
134
  //#endregion
135
+ //#region src/core/memory-relations.ts
136
+ /** The holders one edge-table row names for `spec`: none when the row does not belong to it. */
137
+ function tableHolders(resourceName, spec, row, id) {
138
+ if (relationId(ownGet(row, spec.object ?? `${resourceName}_id`)) !== id) return [];
139
+ for (const [column, value] of Object.entries(spec.match ?? {})) if (ownGet(row, column) !== value) return [];
140
+ const expiresAt = spec.expiresAt === void 0 ? void 0 : seconds(ownGet(row, spec.expiresAt));
141
+ const period = expiresAt === void 0 ? {} : { expiresAt };
142
+ const groups = spec.groups;
143
+ const direct = relationId(ownGet(row, spec.subject ?? "user_id"));
144
+ if (groups === void 0) return direct === void 0 ? [] : [{
145
+ principal: { id: direct },
146
+ ...period
147
+ }];
148
+ if (groups.column === void 0) {
149
+ const out = direct === void 0 ? [] : [{
150
+ principal: { id: direct },
151
+ ...period
152
+ }];
153
+ for (const group of groupEntries(spec)) {
154
+ const groupId = relationId(ownGet(row, group.subject));
155
+ if (groupId !== void 0) out.push({
156
+ group: {
157
+ resource: group.resource,
158
+ id: groupId,
159
+ relation: group.relation
160
+ },
161
+ ...period
162
+ });
163
+ }
164
+ return out;
165
+ }
166
+ const kind = ownGet(row, groups.column);
167
+ if (kind === null || kind === void 0 || kind === groups.direct) return direct === void 0 ? [] : [{
168
+ principal: { id: direct },
169
+ ...period
170
+ }];
171
+ const group = groupEntries(spec).find((entry) => entry.resource === kind);
172
+ const groupId = group === void 0 ? void 0 : relationId(ownGet(row, group.subject));
173
+ return group === void 0 || groupId === void 0 ? [] : [{
174
+ group: {
175
+ resource: group.resource,
176
+ id: groupId,
177
+ relation: group.relation
178
+ },
179
+ ...period
180
+ }];
181
+ }
182
+ function seconds(value) {
183
+ if (value instanceof Date) {
184
+ const time = value.getTime();
185
+ return Number.isNaN(time) ? void 0 : time / 1e3;
186
+ }
187
+ if (typeof value === "number" && Number.isFinite(value)) return value;
188
+ if (typeof value === "string") {
189
+ const parsed = Date.parse(value);
190
+ return Number.isNaN(parsed) ? void 0 : parsed / 1e3;
191
+ }
192
+ }
193
+ function restrictedOf(node, row) {
194
+ return node.restricted !== void 0 && row !== void 0 && ownGet(row, node.restricted) === true;
195
+ }
196
+ function edgeHolder(edge) {
197
+ const holder = { principal: { id: edge.principal } };
198
+ if (edge.startsAt !== void 0) holder.startsAt = edge.startsAt;
199
+ if (edge.expiresAt !== void 0) holder.expiresAt = edge.expiresAt;
200
+ return holder;
201
+ }
202
+ /**
203
+ * An in-process `RelationSource` over plain rows and edges, read against the
204
+ * resource definitions in `permissions`. For tests, fixtures and small apps.
205
+ */
206
+ function memoryRelations(permissions, data = {}) {
207
+ const registry = getRegistry(permissions);
208
+ const byId = /* @__PURE__ */ new Map();
209
+ for (const [name, rows] of Object.entries(data.rows ?? {})) {
210
+ const node = registry.get(name);
211
+ const index = /* @__PURE__ */ new Map();
212
+ for (const row of rows) {
213
+ const id = relationId(ownGet(row, node?.id ?? "id"));
214
+ if (id !== void 0) index.set(id, row);
215
+ }
216
+ byId.set(name, index);
217
+ }
218
+ const rowOf = (resource, id) => byId.get(resource)?.get(id);
219
+ return {
220
+ row({ resource, id }) {
221
+ return rowOf(resource, id) ?? null;
222
+ },
223
+ ancestors({ resource, id, depth, through }) {
224
+ const node = registry.get(resource);
225
+ const start = rowOf(resource, id);
226
+ if (node === void 0 || start === void 0) return { ancestors: [] };
227
+ if (through !== "parent") {
228
+ const link = Object.hasOwn(node.links, through) ? node.links[through] : void 0;
229
+ const next = link === void 0 ? void 0 : relationId(ownGet(start, link.field));
230
+ if (next === void 0 || depth < 1) return { ancestors: [] };
231
+ return { ancestors: [{ id: next }] };
232
+ }
233
+ const restricted = restrictedOf(node, start);
234
+ const stops = restrictedStops(node, "parent");
235
+ if (restricted && stops || node.parent === void 0 || node.parent.resource !== resource) return restricted ? {
236
+ restricted: true,
237
+ ancestors: []
238
+ } : { ancestors: [] };
239
+ const field = node.parent.field;
240
+ const seen = /* @__PURE__ */ new Set([id]);
241
+ const ancestors = [];
242
+ let next = relationId(ownGet(start, field));
243
+ while (next !== void 0 && ancestors.length < depth) {
244
+ const row = rowOf(resource, next);
245
+ if (row === void 0) {
246
+ next = void 0;
247
+ break;
248
+ }
249
+ const hidden = restrictedOf(node, row);
250
+ ancestors.push(hidden ? {
251
+ id: next,
252
+ restricted: true
253
+ } : { id: next });
254
+ if (seen.has(next) || hidden && stops) {
255
+ next = void 0;
256
+ break;
257
+ }
258
+ seen.add(next);
259
+ next = relationId(ownGet(row, field));
260
+ }
261
+ const chain = restricted ? {
262
+ restricted: true,
263
+ ancestors
264
+ } : { ancestors };
265
+ return next === void 0 || rowOf(resource, next) === void 0 ? chain : {
266
+ ...chain,
267
+ truncated: true
268
+ };
269
+ },
270
+ related({ resource, id, relation }) {
271
+ const spec = registry.get(resource)?.relations[relation];
272
+ if (spec === void 0 || isComputedRelation(spec)) return [];
273
+ if (isEdgeRelation(spec)) {
274
+ const table = data.tables?.[spec.edge];
275
+ if (table !== void 0) return table.flatMap((row) => tableHolders(resource, spec, row, id));
276
+ return (data.edges?.[resource]?.[relation] ?? []).filter((edge) => edge.id === id).map(edgeHolder);
277
+ }
278
+ const row = rowOf(resource, id);
279
+ if (row === void 0) return [];
280
+ if (isPrincipalRelation(spec)) {
281
+ const holder = relationId(ownGet(row, spec.principal));
282
+ if (holder === void 0) return [];
283
+ const startsAt = spec.period?.startsAt === void 0 ? void 0 : seconds(ownGet(row, spec.period.startsAt));
284
+ const expiresAt = spec.period?.expiresAt === void 0 ? void 0 : seconds(ownGet(row, spec.period.expiresAt));
285
+ return [{
286
+ principal: { id: holder },
287
+ ...startsAt === void 0 ? {} : { startsAt },
288
+ ...expiresAt === void 0 ? {} : { expiresAt }
289
+ }];
290
+ }
291
+ if (spec.memberOf !== void 0) return [];
292
+ const holder = relationId(ownGet(row, spec.field));
293
+ return holder === void 0 ? [] : [{ principal: { id: holder } }];
294
+ }
295
+ };
296
+ }
297
+ //#endregion
132
298
  //#region src/core/local-manifest.ts
133
299
  /** A relation grantee needs the relation graph, which a device does not hold: the grant decides on the server only. */
134
300
  function localGrant(grant) {
@@ -229,7 +395,7 @@ function mayAccess(policy, user, permission, options = {}) {
229
395
  const principal = resolved.principal;
230
396
  const relevant = policy.index.grantsByKey.get(permission.key) ?? [];
231
397
  if (principal !== null) {
232
- const declared = declaredRoleNames$1(policy);
398
+ const declared = declaredRoleNames(policy);
233
399
  if (heldRoleNames(principal).some((name) => !declared.has(name))) return true;
234
400
  if ((principal.memberships ?? []).length === 0 && relevant.some((grant) => grant.scope !== "global")) return true;
235
401
  }
@@ -315,6 +481,20 @@ function snapshotFor(policy, user, options = {}) {
315
481
  }));
316
482
  }
317
483
  //#endregion
484
+ //#region src/core/permissions.ts
485
+ function definePermissions(input, options) {
486
+ const registry = /* @__PURE__ */ new Map();
487
+ const leaves = [];
488
+ const former = formerByKey(options?.renamed);
489
+ const tree = walk(input, [], registry, leaves, 0, {
490
+ former,
491
+ x: options?.x
492
+ });
493
+ assertKeys(leaves, former);
494
+ assertGraphTargets(registry);
495
+ return freezeDeep(attachRegistry(tree, registry, leaves));
496
+ }
497
+ //#endregion
318
498
  //#region src/core/presets.ts
319
499
  const CRUD_ACTIONS = {
320
500
  read: { readOnly: true },
@@ -390,112 +570,6 @@ function writable(options) {
390
570
  return finishPreset(WRITABLE_ACTIONS, WRITABLE_COLLECTION, options);
391
571
  }
392
572
  //#endregion
393
- //#region src/core/ocsf.ts
394
- /** The OCSF schema version `toOcsf` emits. */
395
- const OCSF_VERSION = "1.3.0";
396
- function status(outcome) {
397
- switch (outcome) {
398
- case "granted": return {
399
- status_id: 1,
400
- status: "Success"
401
- };
402
- case "denied": return {
403
- status_id: 2,
404
- status: "Failure"
405
- };
406
- case "approval-required": return {
407
- status_id: 99,
408
- status: "Other"
409
- };
410
- default: return unknownStatus(outcome);
411
- }
412
- }
413
- /** An outcome this build does not know, from a newer producer, is reported as OCSF Unknown. */
414
- function unknownStatus(_outcome) {
415
- return {
416
- status_id: 0,
417
- status: "Unknown"
418
- };
419
- }
420
- /** Projects a decision or approval event onto OCSF Authorize Session; the event itself is unchanged. */
421
- function toOcsf(event) {
422
- const principal = event.subject.principal;
423
- const actor = event.subject.actor;
424
- const breakGlass = event.matched?.breakGlass === true;
425
- const detail = event.outcome === "approval-required" ? "approval-required" : event.denials?.map((denial) => denial.reason).join(",");
426
- const time = Date.parse(event.at);
427
- return compact({
428
- class_uid: 3003,
429
- category_uid: 3,
430
- activity_id: 1,
431
- type_uid: 300301,
432
- severity_id: breakGlass ? 4 : 1,
433
- time: Number.isNaN(time) ? 0 : time,
434
- ...status(event.outcome),
435
- status_detail: detail === "" ? void 0 : detail,
436
- message: `${event.permission} ${event.outcome}`,
437
- privileges: [event.permission],
438
- user: principal === null ? { name: "anonymous" } : { uid: principal.id },
439
- actor: actor === void 0 ? void 0 : compact({
440
- user: principal === null ? void 0 : { uid: principal.id },
441
- app_name: actor.id
442
- }),
443
- metadata: compact({
444
- version: OCSF_VERSION,
445
- product: compact({
446
- name: "PermDock",
447
- vendor_name: "PermDock",
448
- feature: event.adapter === void 0 ? void 0 : { name: event.adapter }
449
- }),
450
- tenant_uid: event.tenant,
451
- correlation_uid: event.token
452
- }),
453
- unmapped: compact({
454
- outcome: event.outcome,
455
- scope: event.scope,
456
- resource: event.resource,
457
- source: event.source,
458
- phase: event.phase,
459
- role: event.matched?.role,
460
- via: event.via,
461
- breakGlass: breakGlass ? true : void 0,
462
- purpose: event.purpose,
463
- reason: event.reason
464
- })
465
- });
466
- }
467
- function accessToOcsf(event) {
468
- const time = Date.parse(event.at);
469
- const enable = event.operation === "started";
470
- return compact({
471
- class_uid: 3001,
472
- category_uid: 3,
473
- activity_id: enable ? 2 : 5,
474
- type_uid: enable ? 300102 : 300105,
475
- severity_id: 4,
476
- time: Number.isNaN(time) ? 0 : time,
477
- message: `support access ${event.operation}`,
478
- user: { uid: event.principal.id },
479
- actor: event.actor === void 0 ? void 0 : { user: { uid: event.actor.id } },
480
- metadata: {
481
- version: OCSF_VERSION,
482
- product: {
483
- name: "PermDock",
484
- vendor_name: "PermDock"
485
- },
486
- tenant_uid: event.tenant
487
- },
488
- unmapped: compact({
489
- operation: event.operation,
490
- via: event.via,
491
- roles: event.roles,
492
- member: event.member,
493
- grantedBy: event.grantedBy,
494
- reason: event.reason
495
- })
496
- });
497
- }
498
- //#endregion
499
573
  //#region src/core/csv.ts
500
574
  /** The CSV export columns, in order; the header row of every CSV file. */
501
575
  const CSV_COLUMNS = Object.freeze([
@@ -539,9 +613,6 @@ const OMITTED_TOP_LEVEL = /* @__PURE__ */ new Set([
539
613
  "generator",
540
614
  "fingerprint"
541
615
  ]);
542
- function isRecord(value) {
543
- return value !== null && typeof value === "object" && !Array.isArray(value);
544
- }
545
616
  function fingerprintInput(catalog) {
546
617
  const out = {};
547
618
  for (const [key, value] of Object.entries(catalog)) {
@@ -565,4 +636,4 @@ function catalogFingerprint(catalog) {
565
636
  return bytesToBase64Url(sha256(canonicalJson(fingerprintInput(catalog))));
566
637
  }
567
638
  //#endregion
568
- export { memoryRoleSource as _, accessToOcsf as a, sqlFunction as b, readable as c, customRoleSource as d, mayAccess as f, memoryMembershipSource as g, memoryEntitlementSource as h, OCSF_VERSION as i, writable as l, fromStripeEntitlements as m, CSV_COLUMNS as n, toOcsf as o, localSnapshotManifest as p, toCsvRow as r, crud as s, catalogFingerprint as t, snapshotFor as u, memorySettings as v, memorySnapshotSource as y };
639
+ export { memorySettings as _, readable as a, snapshotFor as c, localSnapshotManifest as d, memoryRelations as f, memoryRoleSource as g, memoryMembershipSource as h, crud as i, customRoleSource as l, memoryEntitlementSource as m, CSV_COLUMNS as n, writable as o, fromStripeEntitlements as p, toCsvRow as r, definePermissions as s, catalogFingerprint as t, mayAccess as u, memorySnapshotSource as v, sqlFunction as y };
@@ -1,4 +1,4 @@
1
- import { C as SsfPermDock, D as SsfSubjectMapper, E as SsfSubject, S as SsfOnEvent, T as SsfReceiver, _ as SetSubject, b as SsfEventInput, f as CaepEventName, g as ReplayStore, h as PollResult, m as PollOptions, p as PollHandle, v as SsfAuditEvent, w as SsfPermDockOptions, x as SsfEventListener, y as SsfEventHandler } from "../types-Cq_H8N_X.js";
2
- import { t as memoryReplayStore } from "../replay-CYyiLiwO.js";
3
- import { t as createPermDock } from "../index-0nNqHspG.js";
1
+ import { C as SsfPermDock, D as SsfSubjectMapper, E as SsfSubject, S as SsfOnEvent, T as SsfReceiver, _ as SetSubject, b as SsfEventInput, f as CaepEventName, g as ReplayStore, h as PollResult, m as PollOptions, p as PollHandle, v as SsfAuditEvent, w as SsfPermDockOptions, x as SsfEventListener, y as SsfEventHandler } from "../types-C0dee0Qf.js";
2
+ import { t as memoryReplayStore } from "../replay-COpmZUfx.js";
3
+ import { t as createPermDock } from "../index-DgM7w96K.js";
4
4
  export { type CaepEventName, type PollHandle, type PollOptions, type PollResult, type ReplayStore, type SetSubject, type SsfAuditEvent, type SsfEventHandler, type SsfEventInput, type SsfEventListener, type SsfOnEvent, type SsfPermDock, type SsfPermDockOptions, type SsfReceiver, type SsfSubject, type SsfSubjectMapper, createPermDock, memoryReplayStore };
package/dist/ssf/index.js CHANGED
@@ -1,66 +1,8 @@
1
- import { t as compact } from "../compact-y6vfu2_f.js";
2
- import { t as cancelApprovals } from "../helpers-H_KARDVC.js";
3
- import { i as issuerFromDiscovery, t as joseTokenVerifier } from "../verifier-BxBo6I44.js";
1
+ import { r as isRecord, t as compact } from "../compact-CAf557ZB.js";
2
+ import { t as cancelApprovals } from "../helpers-C9YmyBIa.js";
3
+ import { i as issuerFromDiscovery, t as joseTokenVerifier } from "../verifier-DMr_Zmb_.js";
4
4
  import { t as memoryReplayStore } from "../replay-BsOyTrdV.js";
5
5
  import { t as timeoutSignal } from "../timeout-D51niuQP.js";
6
- //#region src/ssf/wire.ts
7
- const SET_TYP = "secevent+jwt";
8
- const LOGOUT_TYP = "logout+jwt";
9
- function jsonResponse(status, body) {
10
- return new Response(JSON.stringify(body), {
11
- status,
12
- headers: { "content-type": "application/json" }
13
- });
14
- }
15
- function rfc8935(status, err, description) {
16
- return jsonResponse(status, {
17
- err,
18
- description
19
- });
20
- }
21
- function errForCause(cause) {
22
- switch (cause) {
23
- case "invalid-signature":
24
- case "unknown-kid":
25
- case "alg-not-allowed":
26
- case "alg-none": return "invalid_key";
27
- case "wrong-issuer": return "invalid_issuer";
28
- case "wrong-audience": return "invalid_audience";
29
- case "expired":
30
- case "not-yet-valid":
31
- case "wrong-token-type":
32
- case "malformed":
33
- case "encrypted-token":
34
- case "dpop-proof-invalid":
35
- case "mtls-binding-mismatch":
36
- case "sender-constraint-required":
37
- case "token-in-query":
38
- case "invalid-claims":
39
- case "invalid-chain":
40
- case "jwks-unavailable":
41
- case "discovery-unavailable":
42
- case "discovery-mismatch": return "invalid_request";
43
- default: return cause;
44
- }
45
- }
46
- function isRecord(value) {
47
- return value !== null && typeof value === "object" && !Array.isArray(value);
48
- }
49
- function contentType(request) {
50
- return (request.headers.get("content-type") ?? "").split(";", 1)[0]?.trim().toLowerCase() ?? "";
51
- }
52
- function parseEvery(every) {
53
- if (typeof every === "number") {
54
- if (!Number.isFinite(every) || every <= 0) throw new TypeError("PermDock: poll every must be a positive interval.");
55
- return every;
56
- }
57
- const match = /^(\d+)(ms|s|m)$/u.exec(every);
58
- if (match?.[2] === void 0) throw new TypeError(`PermDock: invalid poll interval '${every}'.`);
59
- const unit = match[2];
60
- const scale = unit === "ms" ? 1 : unit === "s" ? 1e3 : 6e4;
61
- return Number(match[1]) * scale;
62
- }
63
- //#endregion
64
6
  //#region src/ssf/claims.ts
65
7
  function asSubject(mapped, session, issuer) {
66
8
  if (typeof mapped === "string") return compact({
@@ -180,6 +122,61 @@ async function pollOnce(input) {
180
122
  return processed;
181
123
  }
182
124
  //#endregion
125
+ //#region src/ssf/wire.ts
126
+ const SET_TYP = "secevent+jwt";
127
+ const LOGOUT_TYP = "logout+jwt";
128
+ function jsonResponse(status, body) {
129
+ return new Response(JSON.stringify(body), {
130
+ status,
131
+ headers: { "content-type": "application/json" }
132
+ });
133
+ }
134
+ function rfc8935(status, err, description) {
135
+ return jsonResponse(status, {
136
+ err,
137
+ description
138
+ });
139
+ }
140
+ function errForCause(cause) {
141
+ switch (cause) {
142
+ case "invalid-signature":
143
+ case "unknown-kid":
144
+ case "alg-not-allowed":
145
+ case "alg-none": return "invalid_key";
146
+ case "wrong-issuer": return "invalid_issuer";
147
+ case "wrong-audience": return "invalid_audience";
148
+ case "expired":
149
+ case "not-yet-valid":
150
+ case "wrong-token-type":
151
+ case "malformed":
152
+ case "encrypted-token":
153
+ case "dpop-proof-invalid":
154
+ case "mtls-binding-mismatch":
155
+ case "sender-constraint-required":
156
+ case "token-in-query":
157
+ case "invalid-claims":
158
+ case "invalid-chain":
159
+ case "jwks-unavailable":
160
+ case "discovery-unavailable":
161
+ case "discovery-mismatch": return "invalid_request";
162
+ default: return cause;
163
+ }
164
+ }
165
+ function contentType(request) {
166
+ return (request.headers.get("content-type") ?? "").split(";", 1)[0]?.trim().toLowerCase() ?? "";
167
+ }
168
+ function parseEvery(every) {
169
+ if (typeof every === "number") {
170
+ if (!Number.isFinite(every) || every <= 0) throw new TypeError("PermDock: poll every must be a positive interval.");
171
+ return every;
172
+ }
173
+ const match = /^(\d+)(ms|s|m)$/u.exec(every);
174
+ if (match?.[2] === void 0) throw new TypeError(`PermDock: invalid poll interval '${every}'.`);
175
+ const unit = match[2];
176
+ const scale = unit === "ms" ? 1 : unit === "s" ? 1e3 : 6e4;
177
+ return Number(match[1]) * scale;
178
+ }
179
+ //#endregion
183
180
  //#region src/ssf/receiver.ts
184
181
  const CHANGED_EVENTS = /* @__PURE__ */ new Set([
185
182
  "credential-change",
@@ -0,0 +1,147 @@
1
+ import { Or as Principal, an as Snapshot, ir as Decision, j as PolicyVocabulary, jt as PermDock, ut as TokenVerifier, vr as Actor, wr as Delegation } from "./policy-types-sp9P1iIV.js";
2
+ import { d as Permission } from "./permission-types-Dg39z9Kv.js";
3
+ import { n as DescribeMessages } from "./describe-C3ldA9os.js";
4
+ //#region src/client/types.d.ts
5
+ type ClientStatus = "ready" | "pending" | "stale" | "server-only";
6
+ type PermissionState = {
7
+ readonly allowed: boolean;
8
+ readonly status: ClientStatus;
9
+ readonly decision: Decision;
10
+ };
11
+ type PermissionSet = {
12
+ readonly granted: readonly Permission[];
13
+ get(permission: Permission): PermissionState | undefined;
14
+ };
15
+ type ClientPermDock<V extends PolicyVocabulary = PolicyVocabulary> = PermDock<V> & {
16
+ status(permission?: Permission, data?: unknown): ClientStatus;
17
+ invalidate(ref: Permission | {
18
+ readonly [key: string]: unknown;
19
+ }): void;
20
+ refresh(options?: {
21
+ readonly tenant?: string;
22
+ }): Promise<void>;
23
+ clear(): void;
24
+ subscribe(listener: () => void): () => void;
25
+ };
26
+ type ApprovalState = "not-needed" | "required" | "pending" | "approved" | "rejected" | "expired";
27
+ type ApprovalHandle = {
28
+ readonly state: ApprovalState;
29
+ readonly token: string | undefined;
30
+ readonly request: (note?: string) => Promise<void>;
31
+ };
32
+ type SubjectView = {
33
+ readonly principal: Principal | null;
34
+ readonly actor: Actor | undefined;
35
+ readonly delegation: Delegation | undefined;
36
+ readonly expiresAt: number | undefined;
37
+ readonly simulated: boolean;
38
+ };
39
+ type TenantView = {
40
+ readonly tenant: string | null;
41
+ readonly tenants: readonly string[];
42
+ readonly switchTo: (id: string) => Promise<void>;
43
+ readonly status: ClientStatus;
44
+ };
45
+ type FilterResult<T> = readonly T[] & {
46
+ readonly partial: boolean;
47
+ };
48
+ type UseRolesOptions = {
49
+ readonly tenant?: string;
50
+ readonly team?: string;
51
+ };
52
+ /** The provider options Vue, Svelte and Solid share; each adds its own reactive `snapshot`, `tenant`, `headers`, `verifier` and `defaults`. */
53
+ type ProviderOptionsBase = {
54
+ /**
55
+ * The AuthZEN evaluations endpoint for checks the snapshot cannot answer.
56
+ * `false` never calls one: such a check is denied with reason `server-only`.
57
+ */
58
+ readonly endpoint?: string | false;
59
+ /** Where `refresh()` fetches a fresh snapshot. Defaults to `endpoint`. */
60
+ readonly snapshotUrl?: string;
61
+ readonly approvals?: string;
62
+ /** Read on every request, so a new `fetch` applies without a new store. */
63
+ readonly fetch?: typeof fetch;
64
+ readonly maxAge?: number;
65
+ /** Localised text for the describe helper. */
66
+ readonly messages?: DescribeMessages;
67
+ /** Called with each snapshot the store accepts. */
68
+ readonly onSnapshot?: NonNullable<ClientStoreOptions["onSnapshot"]>;
69
+ /** Called when the store drops its snapshot. */
70
+ readonly onClear?: () => void;
71
+ /** Milliseconds between approval status polls. Defaults to 2000. */
72
+ readonly approvalInterval?: number;
73
+ };
74
+ //#endregion
75
+ //#region src/client/request.d.ts
76
+ type StoreHeaders = Readonly<Record<string, string>>;
77
+ //#endregion
78
+ //#region src/client/store.d.ts
79
+ type ClientStoreOptions = {
80
+ readonly snapshot: Snapshot | string;
81
+ readonly endpoint?: string;
82
+ readonly snapshotUrl?: string;
83
+ readonly approvals?: string;
84
+ readonly tenant?: string;
85
+ readonly fetch?: typeof fetch;
86
+ /** Request headers, or a getter read on every request so a rotated token needs no new store. */
87
+ readonly headers?: StoreHeaders | (() => StoreHeaders | undefined);
88
+ readonly maxAge?: number;
89
+ readonly verifier?: TokenVerifier;
90
+ /** `raw` is the compact JWS the snapshot was verified from, so a signed snapshot can be persisted signed. */
91
+ readonly onSnapshot?: (snapshot: Snapshot, tenant: string | undefined, raw: string | undefined) => void;
92
+ readonly onClear?: () => void;
93
+ /** Called once per key the snapshot cannot answer when there is no `endpoint` to ask. */
94
+ readonly onServerOnly?: (permission: Permission) => void;
95
+ /**
96
+ * `true` while rendering on the server: endpoint checks answer `pending`
97
+ * without a request. Defaults to `typeof window === 'undefined'`.
98
+ */
99
+ readonly server?: boolean;
100
+ /** Milliseconds between approval status polls. Defaults to 2000. */
101
+ readonly approvalInterval?: number;
102
+ /** Start `pending`: the snapshot arrives later through `track()`. */
103
+ readonly awaiting?: boolean;
104
+ /**
105
+ * The first snapshot that hydrates with a principal is a persisted copy:
106
+ * `stale` until a refresh or a `replace()` lands.
107
+ */
108
+ readonly stale?: boolean;
109
+ /**
110
+ * Reuse decisions for the same row object until the next microtask. Only for
111
+ * renderers that do not track the fields a check reads (React): Vue, Svelte
112
+ * and Solid would stop re-running when a reactive row changes in place.
113
+ */
114
+ readonly passCache?: boolean;
115
+ };
116
+ type ClientStore = {
117
+ get(): ClientPermDock;
118
+ subscribe(listener: () => void): () => void;
119
+ permissionState(permission: Permission, data?: unknown): PermissionState;
120
+ requestApproval(decision: Decision, note?: string): Promise<void>;
121
+ /** Hydrate from a pushed snapshot; a compact JWS goes through the verifier. */
122
+ replace(value: unknown): void;
123
+ /** Stay `pending` until `value` settles, then hydrate; a rejection fails closed. */
124
+ follow(value: PromiseLike<Snapshot | string>): void;
125
+ /**
126
+ * `follow()` once per `value`, without suspending. A thenable React already
127
+ * settled (`status: 'fulfilled'`) hydrates at once.
128
+ */
129
+ track(value: PromiseLike<Snapshot | string>): void;
130
+ /**
131
+ * The approval state for a decision. While something subscribes, an
132
+ * `approval-required` decision is polled at `<approvals>/<token>`.
133
+ */
134
+ approvalState(decision: Decision): ApprovalState;
135
+ /**
136
+ * Hydrate from a resolved `snapshotPromise` during render. Idempotent per `source`;
137
+ * subscribers are notified in a microtask, never synchronously inside render.
138
+ */
139
+ adopt(value: Snapshot | string, source: object): void;
140
+ snapshot(): Snapshot;
141
+ /** The tenant the store currently answers for. */
142
+ tenant(): string | undefined;
143
+ /** Stops polls, drops in-flight results and persistence; the store keeps answering from its last snapshot. */
144
+ dispose(): void;
145
+ };
146
+ //#endregion
147
+ export { ClientPermDock as a, PermissionSet as c, SubjectView as d, TenantView as f, ApprovalState as i, PermissionState as l, ClientStoreOptions as n, ClientStatus as o, UseRolesOptions as p, ApprovalHandle as r, FilterResult as s, ClientStore as t, ProviderOptionsBase as u };
@@ -1,9 +1,9 @@
1
- import { t as compact } from "./compact-y6vfu2_f.js";
1
+ import { t as compact } from "./compact-CAf557ZB.js";
2
2
  import { n as freezeDeep } from "./freeze-CrU8nQeX.js";
3
- import { i as flattenApprovers } from "./approvers-DT4AVyIg.js";
4
- import { s as rootMembershipId } from "./scopes-CVdPrWN-.js";
3
+ import { i as flattenApprovers } from "./approvers-CqPOLD-o.js";
4
+ import { s as rootMembershipId } from "./scopes-tvpa34ep.js";
5
5
  import { t as parseDuration } from "./duration-xK2jGFVc.js";
6
- import { d as matchGrantee } from "./grantee-Cv5Sogfv.js";
6
+ import { n as matchGrantee } from "./grantee-match-fxYp9Nmt.js";
7
7
  import { t as ApprovalError } from "./errors-DRnGZHzF.js";
8
8
  //#region src/approvals/types.ts
9
9
  const APPROVAL_HEADER = "PermDock-Approval";