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.
- package/dist/a2a/index.d.ts +7 -5
- package/dist/a2a/index.js +14 -21
- package/dist/ai-sdk/index.d.ts +18 -6
- package/dist/ai-sdk/index.js +8 -5
- package/dist/app-data-CV8pqqMi.js +59 -0
- package/dist/approvals/index.d.ts +2 -2
- package/dist/approvals/index.js +3 -3
- package/dist/{approvals-DbYAuNkG.js → approvals-DZL76lKW.js} +35 -19
- package/dist/{approvers-DT4AVyIg.js → approvers-CqPOLD-o.js} +1 -1
- package/dist/{arazzo-BAgw9ap6.js → arazzo-C4BcskbX.js} +6 -5
- package/dist/{arazzo-CKwwqFWz.js → arazzo-CD8d0WLb.js} +2 -2
- package/dist/authzen/index.d.ts +3 -3
- package/dist/authzen/index.js +161 -23
- package/dist/better-auth/index.d.ts +2 -2
- package/dist/better-auth/index.js +6 -19
- package/dist/better-supabase/index.d.ts +112 -87
- package/dist/better-supabase/index.js +257 -156
- package/dist/{bind-C_ob3LKa.d.ts → bind-BzqG8SMb.d.ts} +16 -5
- package/dist/{bind-CuzGytRf.js → bind-kk-uyCwH.js} +14 -6
- package/dist/build-instance-DIIV9DbC.js +51 -0
- package/dist/{canonical-json-DemiK4Vp.js → canonical-json-CFKyFOke.js} +1 -3
- package/dist/{capability-2kYTMWDv.d.ts → capability-CksyCWDH.d.ts} +2 -2
- package/dist/{capability-4qPdO9gk.js → capability-txATtKV4.js} +3 -2
- package/dist/catalog/index.d.ts +1 -1
- package/dist/catalog/index.js +1 -1
- package/dist/catalog-6yWAX6Ps.js +2 -0
- package/dist/{catalog-dFZdWCGN.js → catalog-WHG4kBq7.js} +2 -2
- package/dist/{catalog-doc-DdGm82XT.js → catalog-doc-DWtg0gGR.js} +17 -10
- package/dist/{catalog-DWF5cYqB.js → catalog-tZUyOfOv.js} +4 -4
- package/dist/claude-agent/index.d.ts +4 -4
- package/dist/claude-agent/index.js +4 -5
- package/dist/clerk/index.d.ts +3 -3
- package/dist/clerk/index.js +8 -33
- package/dist/cli/bin.js +1 -1
- package/dist/cli/index.d.ts +3 -3
- package/dist/cli/index.js +3 -3
- package/dist/cloud/index.d.ts +4 -4
- package/dist/cloud/index.js +9 -15
- package/dist/{cloud-CB_ELYuX.js → cloud-C7bSDgX4.js} +2 -2
- package/dist/{cloud-DWLXO2af.js → cloud-PeBN3IEn.js} +5 -5
- package/dist/{collect-DSTE3ml9.js → collect-2SrB7lfk.js} +6 -8
- package/dist/collect-Bw2Jdq1q.js +2 -0
- package/dist/{collect-DClJsheJ.js → collect-CQx4hX4N.js} +3 -3
- package/dist/{commands-DSxCqG9A.js → commands-Cpip4ULx.js} +13 -13
- package/dist/{compact-y6vfu2_f.js → compact-CAf557ZB.js} +11 -1
- package/dist/compile/index.d.ts +1 -1
- package/dist/compile/index.js +1 -1
- package/dist/{compile-Ba4blROR.js → compile-CcEu2ZQ1.js} +6 -5
- package/dist/{compile-BkRyBDBw.d.ts → compile-CtTP7eur.d.ts} +2 -2
- package/dist/{config-BJiM-xAm.js → config-BIjREpyE.js} +4 -4
- package/dist/{config-Dnszbv-6.js → config-DLt6BvV7.js} +2 -2
- package/dist/{config-report-DMvWKUxL.js → config-report--Xb9APJS.js} +5 -6
- package/dist/{connection-CU8MQxRi.js → connection-DUsczpB5.js} +3 -2
- package/dist/constants-DcJABbLW.js +20 -0
- package/dist/{context-Bcy85rGi.js → context-DieZVJXu.js} +16 -5
- package/dist/convex/index.d.ts +4 -4
- package/dist/convex/index.js +14 -16
- package/dist/create-BBO24vj6.js +324 -0
- package/dist/{credential-8P81ff4u.js → credential-kue0qpbm.js} +4 -4
- package/dist/deciding-columns-Sq12mEA6.js +123 -0
- package/dist/delegation-input-FTxMK3ji.js +19 -0
- package/dist/denied-text-DfRk15uw.d.ts +19 -0
- package/dist/{describe-DMYiCjJV.d.ts → describe-C3ldA9os.d.ts} +11 -2
- package/dist/{describe-B_gVZEVi.js → describe-Cgkp7eP0.js} +5 -4
- package/dist/{diff-DBIhz_f2.js → diff-Cnghh_Ip.js} +2 -2
- package/dist/{diff-2VaeChzX.js → diff-rpqoe7Ag.js} +9 -9
- package/dist/{doctor-BwCAMLx_.js → doctor-CuVJvhV_.js} +2 -2
- package/dist/doctor-owlv6ddh.js +2166 -0
- package/dist/drizzle/index.d.ts +2 -2
- package/dist/drizzle/index.js +6 -14
- package/dist/elysia/index.d.ts +4 -4
- package/dist/elysia/index.js +7 -7
- package/dist/{errors-DPdqI50v.d.ts → errors-OD_4c__H.d.ts} +2 -2
- package/dist/{errors-Cz5zn0mW.js → errors-drnfxYtm.js} +3 -3
- package/dist/{evaluations-tz6D9A2G.js → evaluations-C9YJsv3H.js} +45 -7
- package/dist/eve/index.d.ts +5 -5
- package/dist/eve/index.js +5 -5
- package/dist/express/index.d.ts +4 -4
- package/dist/express/index.js +8 -7
- package/dist/fastify/index.d.ts +15 -5
- package/dist/fastify/index.js +9 -29
- package/dist/fields-fwfXN01n.js +1016 -0
- package/dist/{files-DWUN9PzI.js → files-D_JIzUrP.js} +12 -3
- package/dist/{fixtures-ht28Cplr.js → fixtures-h2eG2OZV.js} +5 -6
- package/dist/{from-snapshot-CTLijvdm.js → from-snapshot-7REQZe0H.js} +32 -22
- package/dist/{generate-CH7ThJ14.js → generate-CNU1pIOo.js} +1 -3
- package/dist/grantee-CXY-0C87.js +254 -0
- package/dist/grantee-conditions-MQs5NIuX.js +270 -0
- package/dist/grantee-match-fxYp9Nmt.js +141 -0
- package/dist/{helpers-H_KARDVC.js → helpers-C9YmyBIa.js} +7 -6
- package/dist/hono/index.d.ts +4 -4
- package/dist/hono/index.js +8 -8
- package/dist/hosted-CBHgkzDl.js +655 -0
- package/dist/{http-SO7qGttf.js → http-BBoKefeS.js} +35 -2
- package/dist/{http-BIhmLfCc.js → http-BEbdMZ05.js} +2 -24
- package/dist/{rls-import-BTFVk3jH.js → import-BFIlhetD.js} +86 -80
- package/dist/{openapi-import-cmwetbzw.js → import-UHk1N7vH.js} +6 -7
- package/dist/{index-C8z4RjQV.d.ts → index-BwMe94Xq.d.ts} +1 -1
- package/dist/{index-0nNqHspG.d.ts → index-DgM7w96K.d.ts} +2 -2
- package/dist/{index-C7Tw7MaW.d.ts → index-Dz7didpC.d.ts} +3 -3
- package/dist/{index-BNc7Wer_.d.ts → index-UdVQgq48.d.ts} +105 -38
- package/dist/index.d.ts +15 -13
- package/dist/index.js +22 -22
- package/dist/{instance-options-jARdwfPN.d.ts → instance-options-plkrsAog.d.ts} +1 -1
- package/dist/{json-schema-BsAflUGW.js → json-schema-DBkdUuCO.js} +1 -3
- package/dist/jwt/index.d.ts +4 -4
- package/dist/jwt/index.js +13 -13
- package/dist/{kernel-_RRHmnMY.js → kernel-CB3LrIJM.js} +81 -32
- package/dist/kysely/index.d.ts +2 -2
- package/dist/kysely/index.js +6 -14
- package/dist/{live-options-H2eG8dfJ.js → live-options-BaAFCIiu.js} +16 -3
- package/dist/load-B_shHrmd.js +2 -0
- package/dist/{load-DhWEB9P1.js → load-C3_oTHyO.js} +11 -3
- package/dist/{manifest-iaoBXHKc.js → manifest-BngWKryL.js} +5 -18
- package/dist/{map-claims-Z4QZOiFF.js → map-claims-AVlBaJoa.js} +7 -16
- package/dist/{map-error-pgUWNNtG.js → map-error-BE27PYkE.js} +5 -5
- package/dist/{markers-B0hYLvMD.js → markers-CiwAOZtO.js} +6 -2
- package/dist/{may-use-DndQ5tQ-.js → may-use-BOn_dR_w.js} +4 -3
- package/dist/mcp/index.d.ts +26 -9
- package/dist/mcp/index.js +456 -446
- package/dist/{rls-migrate-CN4TlJTO.js → migrate-BwlB5-Wk.js} +75 -15
- package/dist/nest/index.d.ts +4 -4
- package/dist/nest/index.js +11 -12
- package/dist/next/index.d.ts +31 -8
- package/dist/next/index.js +29 -33
- package/dist/next/plugin.d.ts +1 -1
- package/dist/next/plugin.js +1 -1
- package/dist/node/index.d.ts +4 -4
- package/dist/node/index.js +4 -4
- package/dist/ocsf-uYFXGVw2.js +115 -0
- package/dist/openai/index.d.ts +5 -5
- package/dist/openai/index.js +4 -4
- package/dist/openapi/index.d.ts +3 -3
- package/dist/openapi/index.js +1 -1
- package/dist/{openapi-CqqEbHsL.js → openapi-BJdBmYDG.js} +19 -23
- package/dist/{openapi-BqRBvAng.js → openapi-DBzHQbov.js} +2 -5
- package/dist/{openapi-l0xYHkcv.js → openapi-DcQ1Kg40.js} +3 -3
- package/dist/orpc/index.d.ts +5 -5
- package/dist/orpc/index.js +9 -11
- package/dist/otel/index.d.ts +2 -2
- package/dist/otel/index.js +26 -23
- package/dist/output-files-CgIsvdSa.js +140 -0
- package/dist/{rls-ownership-RuFqaqGz.js → ownership-BgnbOJFT.js} +387 -379
- package/dist/{package-root-zGkxO3oN.js → package-root-DtNnpmUd.js} +3 -2
- package/dist/{parse-BuyjxhZV.js → parse-CVFQHk6c.js} +3 -3
- package/dist/{parse-local-manifest-BrMozJCo.js → parse-local-manifest-C-q02Pal.js} +2 -4
- package/dist/{parse-local-manifest-JLnaBH0S.d.ts → parse-local-manifest-DvYUR0QL.d.ts} +1 -1
- package/dist/pdp/index.d.ts +2 -2
- package/dist/pdp/index.js +8 -9
- package/dist/{permdock-CbgvLnuo.js → permdock-L26udHSk.js} +1387 -1220
- package/dist/{rls-fields-74oZPXWL.js → permission-keys-B26jeyUv.js} +1289 -2066
- package/dist/permission-registry-BsblpB-z.js +385 -0
- package/dist/{permissions-DttnqqxC.d.ts → permission-types-Dg39z9Kv.d.ts} +59 -31
- package/dist/{permissions-RJrovw98.js → permissions-CCJ6lmxB.js} +3 -3
- package/dist/{permissions-CDgvKG5L.d.ts → permissions-COH-KRgT.d.ts} +2 -2
- package/dist/{policy-IB6yxpC3.d.ts → policy-types-sp9P1iIV.d.ts} +661 -582
- package/dist/{policy-D2W7uv19.d.ts → policy-ur0BBK_e.d.ts} +2 -2
- package/dist/{powersync-DliZK_-y.js → powersync-BFSbSElQ.js} +2 -2
- package/dist/powersync-DCDgZgfZ.js +2 -0
- package/dist/{powersync-BylawD_U.js → powersync-cZe4kzhL.js} +26 -27
- package/dist/prisma/index.d.ts +1 -1
- package/dist/prisma/index.js +6 -12
- package/dist/{problem-B43ztKIm.js → problem-CnWraVhC.js} +8 -7
- package/dist/{problem-details-_AMOYz-w.js → problem-details-DECUnXAn.js} +2 -2
- package/dist/{problem-details-DX075l9V.d.ts → problem-details-rIIo8B2C.d.ts} +1 -1
- package/dist/{protected-BdnIEFkY.d.ts → protected-B3_P7xuw.d.ts} +9 -6
- package/dist/{protected-utU-SLuy.js → protected-BN7BUdY1.js} +20 -8
- package/dist/{provider-CSQd7m92.js → provider-Bi-0HNL3.js} +23 -10
- package/dist/{provider-DZY281jO.d.ts → provider-kwHC9CZD.d.ts} +1 -1
- package/dist/{provider-store-Cfbvo4DE.js → provider-store-Ctt-81Ni.js} +6 -3
- package/dist/react/index.d.ts +7 -7
- package/dist/react/index.js +5 -5
- package/dist/react/provider-client.d.ts +1 -1
- package/dist/react/provider-client.js +1 -1
- package/dist/react-native/index.d.ts +20 -11
- package/dist/react-native/index.js +33 -17
- package/dist/{refs-KYb4ntaz.js → refs-f3imMjNW.js} +1 -1
- package/dist/relation-walk-BXnlLtg2.js +186 -0
- package/dist/relations-CvmSpG67.js +163 -0
- package/dist/{replay-CYyiLiwO.d.ts → replay-COpmZUfx.d.ts} +1 -1
- package/dist/request-context-BVM7aWNs.js +71 -0
- package/dist/request-context-C2_1lchh.d.ts +5 -0
- package/dist/resource-relations-D1Un3pcz.js +243 -0
- package/dist/retire-BFcxL6un.js +240 -0
- package/dist/{rls-B4ur8nKQ.js → rls-55DQTuf5.js} +14 -2
- package/dist/{rls-DQtdgTHB.js → rls-BEktUaqg.js} +884 -484
- package/dist/{policy-xyWg7QdR.js → role-builder-B4GbKM-i.js} +235 -541
- package/dist/{rpc-DL9Sqvb1.js → rpc-nYC3cR_u.js} +15 -5
- package/dist/{run-DKDbM4Du.js → run-DMcNW_8T.js} +3 -3
- package/dist/{runtime-CB8gQFvS.js → runtime-D_tMXnsq.js} +1 -1
- package/dist/{saas-DhpJjnBA.js → saas-DtaA4JuW.js} +9 -8
- package/dist/{openapi-schema--ARjyfQr.js → schema-Bol6gqXA.js} +3 -5
- package/dist/{schema-D3MnDMxa.js → schema-DjQBcAP9.js} +4 -2
- package/dist/scim/index.d.ts +1 -1
- package/dist/scim/index.js +1 -1
- package/dist/{scim-BFGBBAqR.js → scim-vFR1O5oG.js} +6 -12
- package/dist/{scopes-CVdPrWN-.js → scopes-tvpa34ep.js} +10 -2
- package/dist/server/index.d.ts +18 -8
- package/dist/server/index.js +8 -8
- package/dist/{server-DlZ28Oz5.js → server-ZYEHtNHS.js} +4 -4
- package/dist/{create-B1d519XK.d.ts → server-types-DdqBwZN_.d.ts} +69 -33
- package/dist/shared-1uhI-e-b.js +294 -0
- package/dist/{shared-DRu8VFVM.js → shared-JhMeOsDF.js} +1 -1
- package/dist/{sink-Bd9PSyfq.js → sink-BTtmfPnE.js} +1 -1
- package/dist/{sink-B1fZzIMf.d.ts → sink-CPN4zLfs.d.ts} +1 -1
- package/dist/{skills-Biq5uup3.js → skills-BZdRQkxs.js} +4 -3
- package/dist/{skills-Bx-U0irG.js → skills-Dle4ZoLF.js} +2 -2
- package/dist/{snapshot-Enxd0n-s.js → snapshot-Dc9CHPME.js} +116 -13
- package/dist/{snapshot-cache-D6jLelln.js → snapshot-cache-Cod40D-X.js} +1 -1
- package/dist/{snapshot-cache-B-LxUahj.d.ts → snapshot-cache-J5T7t_vD.d.ts} +1 -1
- package/dist/solid/index.d.ts +22 -22
- package/dist/solid/index.js +40 -10
- package/dist/{sources-4p0-4xQm.js → sources-B1-b-R0t.js} +25 -26
- package/dist/{sources-BdOYLw9j.d.ts → sources-Dljy06zL.d.ts} +6 -2
- package/dist/{sql-xdg5f4Fi.js → sql-t8teWOfo.js} +19 -3
- package/dist/{src-BDwEZWrZ.js → src-Bb7no-hS.js} +194 -123
- package/dist/ssf/index.d.ts +3 -3
- package/dist/ssf/index.js +58 -61
- package/dist/store-9KO4BlkB.d.ts +147 -0
- package/dist/{store-DMAWwAJV.js → store-ILkLUj_o.js} +4 -4
- package/dist/{store-options-ByhZq1jV.js → store-options-CbUHDoSe.js} +16 -7
- package/dist/{stores-BT2pSCub.js → stores-BHXdSbw9.js} +7 -3
- package/dist/stores-Cxz_80g-.d.ts +31 -0
- package/dist/{stream-DDpvynSB.js → stream-BMui98KK.js} +2 -1
- package/dist/{stream-D1RXubw2.d.ts → stream-Dwsg6WwE.d.ts} +2 -2
- package/dist/{subject-settings-BwBmCdTR.js → subject-settings-CkEwrw3W.js} +23 -5
- package/dist/supabase/index.d.ts +4 -4
- package/dist/supabase/index.js +3 -3
- package/dist/supabase/middleware.d.ts +11 -5
- package/dist/supabase/middleware.js +10 -7
- package/dist/{supabase-C0qESOa-.js → supabase-C1TWlnYt.js} +36 -52
- package/dist/{supabase-Boqb9a_Y.js → supabase-Dbqr141s.js} +2 -2
- package/dist/supabase-hook-BULg7Ut_.js +2 -0
- package/dist/{supabase-hook-CSLQ4zJ3.js → supabase-hook-Cva3ikXz.js} +731 -782
- package/dist/{supautils-Cn4R4cJ4.js → supautils-B6HYL9eL.js} +2 -2
- package/dist/svelte/Protected.svelte +9 -2
- package/dist/svelte/index.d.ts +6 -6
- package/dist/svelte/index.js +25 -11
- package/dist/svelte/runtime.d.ts +10 -3
- package/dist/svelte/runtime.js +4 -3
- package/dist/svelte/source.d.ts +6 -6
- package/dist/svelte/source.js +4 -4
- package/dist/{validity-uOp8UpYn.js → tenancy-DshjqY0n.js} +3 -39
- package/dist/terminal/index.d.ts +5 -5
- package/dist/terminal/index.js +18 -34
- package/dist/testing/index.d.ts +89 -77
- package/dist/testing/index.js +1276 -1262
- package/dist/testing/saas/index.d.ts +4 -4
- package/dist/testing/saas/index.js +2 -2
- package/dist/testing/saas/permissions.d.ts +1 -1
- package/dist/testing/saas/permissions.js +1 -1
- package/dist/thenable-QSmvt-vZ.js +65 -0
- package/dist/{token-CIWxJOCh.js → token-Bx9qy30p.js} +1 -1
- package/dist/tool-refusal-CQ7OEia9.js +41 -0
- package/dist/trpc/index.d.ts +5 -5
- package/dist/trpc/index.js +7 -8
- package/dist/{types-DbjRN55U.d.ts → types-7rJVLWe5.d.ts} +82 -4
- package/dist/{types-aqOHTHcp.d.ts → types-Br9IXUBG.d.ts} +1 -1
- package/dist/types-ByUo56un.d.ts +88 -0
- package/dist/{types-Cq_H8N_X.d.ts → types-C0dee0Qf.d.ts} +2 -2
- package/dist/{types-DxiCGmmd.d.ts → types-CIlTojhq.d.ts} +2 -2
- package/dist/{types-QCuYJh4q.d.ts → types-CUcFZfpU.d.ts} +1 -1
- package/dist/{types-C97IskBw.d.ts → types-CqrjB9o6.d.ts} +1 -1
- package/dist/{types-BnIEz1sU.d.ts → types-DHrmBJLH.d.ts} +24 -6
- package/dist/{types-Dnemwd77.d.ts → types-DpWfQdSh.d.ts} +5 -1
- package/dist/{types-Bvc4oWT6.d.ts → types-DvupZE0w.d.ts} +1 -1
- package/dist/unplugin/index.d.ts +1 -1
- package/dist/unplugin/index.js +1 -1
- package/dist/{usage-GTixvDDU.js → usage-4G6t643F.js} +2 -2
- package/dist/{usage-ItS7nLcl.js → usage-CG9nOYZw.js} +7 -7
- package/dist/usage-iFLJ0-rr.js +2 -0
- package/dist/{validation-error-Ba264OaJ.d.ts → validation-error-BSSw0l_8.d.ts} +1 -1
- package/dist/{validation-error-CnjZ4t92.js → validation-error-ZfUHbKvf.js} +1 -1
- package/dist/validity-dVrUEPJt.js +62 -0
- package/dist/{verifier-BxBo6I44.js → verifier-DMr_Zmb_.js} +51 -15
- package/dist/{rls-verify-CVQTHTh5.js → verify-BztUB3GX.js} +668 -239
- package/dist/{version-BvacVTZR.js → version-BEogC-rB.js} +1 -1
- package/dist/{views-Soe7bGSC.js → views-CJsrBS1f.js} +23 -1
- package/dist/{vocabulary-DA8a8zif.d.ts → vocabulary-hhEFLFoL.d.ts} +15 -6
- package/dist/vue/index.d.ts +24 -19
- package/dist/vue/index.js +24 -8
- package/dist/watch-C8TpsAl4.js +2 -0
- package/dist/{watch-DVBJ9cBq.js → watch-zeucB7eF.js} +6 -6
- package/dist/webmcp/index.d.ts +2 -2
- package/dist/webmcp/index.js +13 -37
- package/dist/wrap-Cr93qqdP.d.ts +14 -0
- package/dist/wrap-DWsU_5Bd.js +26 -0
- package/package.json +8 -8
- package/schemas/catalog-v1.json +6 -0
- package/skills/permdock-credentials/SKILL.md +1 -1
- package/skills/permdock-credentials/references/tokens-keys-links.md +7 -2
- package/skills/permdock-data/references/queries-and-rls.md +4 -0
- package/skills/permdock-tenancy/references/ownership-and-custom-roles.md +1 -0
- package/skills/permdock-wire/SKILL.md +2 -2
- package/skills/permdock-wire/references/adapters.md +9 -1
- package/skills/permdock-wire/references/policy-options.md +10 -1
- package/dist/catalog-CRW5Mx_B.js +0 -2
- package/dist/collect-DSWOk19R.js +0 -2
- package/dist/create-CMwIl-w2.js +0 -253
- package/dist/delegation-D8pUEuce.js +0 -103
- package/dist/doctor-collect-CHk6XWOA.js +0 -665
- package/dist/doctor-igIiM_Hl.js +0 -1194
- package/dist/evaluation-items-CfCCejQd.js +0 -40
- package/dist/fields-BMl1RxoX.js +0 -26
- package/dist/grantee-Cv5Sogfv.js +0 -602
- package/dist/hosted-DJQw46hn.js +0 -266
- package/dist/instance-options-Dhhcnm3y.js +0 -22
- package/dist/load-DwJUafYN.js +0 -2
- package/dist/map-AcxK9o_D.js +0 -147
- package/dist/permissions-DVoF6dMt.js +0 -662
- package/dist/powersync-e_AZrKbg.js +0 -2
- package/dist/protected-xAr24FEC.d.ts +0 -40
- package/dist/relations-cjOL01hZ.js +0 -505
- package/dist/rls-graph-CHwx0V8q.js +0 -435
- package/dist/rls-shared-Cewd_-zI.js +0 -495
- package/dist/store-jOBYpiXC.d.ts +0 -36
- package/dist/stores-C0IMQrGI.d.ts +0 -52
- package/dist/supabase-config-BpPXt3x1.js +0 -472
- package/dist/supabase-hook-6sYLXg_u.js +0 -2
- package/dist/thenable-okc2xDsj.js +0 -10
- package/dist/types-CKNSyIf_.d.ts +0 -52
- package/dist/usage-DorAJiU_.js +0 -2
- package/dist/watch-BwxLTYMZ.js +0 -2
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { t as compact } from "./compact-
|
|
2
|
-
import { i as isPromiseLike } from "./store-options-
|
|
3
|
-
import { n as switchTenant, t as providerStore } from "./provider-store-
|
|
1
|
+
import { t as compact } from "./compact-CAf557ZB.js";
|
|
2
|
+
import { i as isPromiseLike } from "./store-options-CbUHDoSe.js";
|
|
3
|
+
import { n as switchTenant, t as providerStore } from "./provider-store-Ctt-81Ni.js";
|
|
4
4
|
import { getContext, onDestroy, setContext } from "svelte";
|
|
5
5
|
import { toStore } from "svelte/store";
|
|
6
6
|
//#region src/svelte/context.ts
|
|
7
7
|
const permDockKey = Symbol("permdock");
|
|
8
|
+
const permDockUiKey = Symbol("permdock-ui");
|
|
8
9
|
function isReadable(value) {
|
|
9
10
|
return typeof value === "object" && value !== null && "subscribe" in value && typeof value.subscribe === "function";
|
|
10
11
|
}
|
|
@@ -32,7 +33,10 @@ function connectSvelteStore(options) {
|
|
|
32
33
|
snapshotUrl: options.snapshotUrl,
|
|
33
34
|
approvals: options.approvals,
|
|
34
35
|
tenant: typeof tenant === "function" ? tenant() : tenant,
|
|
35
|
-
maxAge: options.maxAge
|
|
36
|
+
maxAge: options.maxAge,
|
|
37
|
+
onSnapshot: options.onSnapshot,
|
|
38
|
+
onClear: options.onClear,
|
|
39
|
+
approvalInterval: options.approvalInterval
|
|
36
40
|
}), () => ({
|
|
37
41
|
headers: typeof headers === "function" ? headers() : headers,
|
|
38
42
|
fetch: options.fetch,
|
|
@@ -71,12 +75,19 @@ function providePermDock(options) {
|
|
|
71
75
|
store.dispose();
|
|
72
76
|
});
|
|
73
77
|
setContext(permDockKey, store);
|
|
78
|
+
setContext(permDockUiKey, {
|
|
79
|
+
defaults: options.defaults,
|
|
80
|
+
messages: options.messages
|
|
81
|
+
});
|
|
74
82
|
return store;
|
|
75
83
|
}
|
|
84
|
+
function getUi() {
|
|
85
|
+
return getContext(permDockUiKey) ?? {};
|
|
86
|
+
}
|
|
76
87
|
function getStore() {
|
|
77
88
|
const store = getContext(permDockKey);
|
|
78
89
|
if (store === void 0) throw new Error("PermDock: stores require setPermDock.");
|
|
79
90
|
return store;
|
|
80
91
|
}
|
|
81
92
|
//#endregion
|
|
82
|
-
export {
|
|
93
|
+
export { getUi as n, providePermDock as r, getStore as t };
|
package/dist/convex/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { a as ProblemDetails, r as PermDockDeniedError } from "../errors-
|
|
4
|
-
import { t as InstanceOptions } from "../instance-options-
|
|
1
|
+
import { E as Policy, Or as Principal, j as PolicyVocabulary, jt as PermDock } from "../policy-types-sp9P1iIV.js";
|
|
2
|
+
import { d as Permission } from "../permission-types-Dg39z9Kv.js";
|
|
3
|
+
import { a as ProblemDetails, r as PermDockDeniedError } from "../errors-OD_4c__H.js";
|
|
4
|
+
import { t as InstanceOptions } from "../instance-options-plkrsAog.js";
|
|
5
5
|
//#region src/convex/types.d.ts
|
|
6
6
|
type ConvexCtxLike = {
|
|
7
7
|
readonly auth?: {
|
package/dist/convex/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { t as compact } from "../compact-
|
|
2
|
-
import { n as PermDockValidationError } from "../validation-error-
|
|
3
|
-
import { n as PermDockDeniedError, t as PermDockApprovalRequiredError } from "../errors-
|
|
4
|
-
import { t as
|
|
5
|
-
import { t as instanceOptions } from "../instance-options-Dhhcnm3y.js";
|
|
1
|
+
import { t as compact } from "../compact-CAf557ZB.js";
|
|
2
|
+
import { n as PermDockValidationError } from "../validation-error-ZfUHbKvf.js";
|
|
3
|
+
import { n as PermDockDeniedError, t as PermDockApprovalRequiredError } from "../errors-drnfxYtm.js";
|
|
4
|
+
import { n as resolveOrNull, t as buildInstance } from "../build-instance-DIIV9DbC.js";
|
|
6
5
|
import { n as tenantScope, t as actorFrom } from "../adapter-context-mlWsVGGg.js";
|
|
7
6
|
//#region src/convex/create.ts
|
|
8
7
|
/** Convex's runtime sends `data` to the client only for an error carrying this symbol. */
|
|
@@ -23,17 +22,16 @@ function toConvexError(error) {
|
|
|
23
22
|
function createPermDock(policy, options) {
|
|
24
23
|
const withPermDock = (handler) => {
|
|
25
24
|
return async (ctx, args) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}));
|
|
25
|
+
const user = await resolveOrNull(() => options.subject(ctx));
|
|
26
|
+
const { permdock } = await buildInstance({
|
|
27
|
+
policy,
|
|
28
|
+
user,
|
|
29
|
+
sources: options,
|
|
30
|
+
scope: {
|
|
31
|
+
tenant: (await tenantScope(options.tenant, ctx)).tenant,
|
|
32
|
+
actor: await actorFrom(options.actor, ctx)
|
|
33
|
+
}
|
|
34
|
+
});
|
|
37
35
|
const next = {
|
|
38
36
|
...ctx,
|
|
39
37
|
permdock
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
import { t as compact } from "./compact-CAf557ZB.js";
|
|
2
|
+
import { n as freezeDeep } from "./freeze-CrU8nQeX.js";
|
|
3
|
+
import { n as problemDetails } from "./problem-details-DECUnXAn.js";
|
|
4
|
+
import { c as listPermissions } from "./permission-registry-BsblpB-z.js";
|
|
5
|
+
import { r as challengeScope } from "./permdock-L26udHSk.js";
|
|
6
|
+
import { n as resourceRef } from "./resource-ref-CaS9yVPi.js";
|
|
7
|
+
import { r as hasCredentials } from "./http-BBoKefeS.js";
|
|
8
|
+
import { i as decisionResponse, o as notFoundProblem, s as problemFromDecision, t as ANONYMOUS, u as unauthenticatedProblem } from "./problem-CnWraVhC.js";
|
|
9
|
+
import { n as resolveOrNull } from "./build-instance-DIIV9DbC.js";
|
|
10
|
+
import { n as createEvaluationsHandler, r as InvalidSignatureError, t as applyApprovalResume } from "./evaluations-C9YJsv3H.js";
|
|
11
|
+
import { n as tenantScope, t as actorFrom } from "./adapter-context-mlWsVGGg.js";
|
|
12
|
+
import { n as requestContext, t as buildReportingInstance } from "./request-context-BVM7aWNs.js";
|
|
13
|
+
//#region src/server/kernel-problems.ts
|
|
14
|
+
const NOT_DELEGATED = freezeDeep({
|
|
15
|
+
outcome: "denied",
|
|
16
|
+
denials: [{
|
|
17
|
+
role: null,
|
|
18
|
+
reason: "not-delegated"
|
|
19
|
+
}],
|
|
20
|
+
alternatives: []
|
|
21
|
+
});
|
|
22
|
+
const LOAD_FAILED = freezeDeep({
|
|
23
|
+
outcome: "denied",
|
|
24
|
+
denials: [{
|
|
25
|
+
role: null,
|
|
26
|
+
reason: "validation"
|
|
27
|
+
}],
|
|
28
|
+
alternatives: []
|
|
29
|
+
});
|
|
30
|
+
/** The `403` for a loader that threw: the check fails closed, as on MCP. */
|
|
31
|
+
function loadFailedProblem(permission) {
|
|
32
|
+
const key = permission?.key ?? "the route";
|
|
33
|
+
return decisionResponse(problemDetails(compact({
|
|
34
|
+
decision: LOAD_FAILED,
|
|
35
|
+
detail: `${key} failed closed: the row could not be loaded`,
|
|
36
|
+
permission: permission?.key
|
|
37
|
+
})), LOAD_FAILED);
|
|
38
|
+
}
|
|
39
|
+
/** The `403` `insufficient_scope` for a token that holds none of a route's OAuth scopes. */
|
|
40
|
+
function scopeProblem(permission, subject, credentials, scope) {
|
|
41
|
+
return permission === null ? decisionResponse(problemDetails(compact({
|
|
42
|
+
decision: NOT_DELEGATED,
|
|
43
|
+
detail: `the token holds none of the OAuth scopes this route needs, such as ${String(scope)}`,
|
|
44
|
+
scope
|
|
45
|
+
})), NOT_DELEGATED, compact({
|
|
46
|
+
credentials,
|
|
47
|
+
scope
|
|
48
|
+
})) : problemFromDecision(NOT_DELEGATED, permission, subject, compact({
|
|
49
|
+
credentials,
|
|
50
|
+
scope
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
function problemFor(decision, init, approval) {
|
|
54
|
+
if (init?.permission !== void 0) return problemFromDecision(decision, init.permission, void 0, compact({
|
|
55
|
+
instance: init.instance,
|
|
56
|
+
approval
|
|
57
|
+
}));
|
|
58
|
+
if (decision.outcome === "granted") return new Response(null, { status: 204 });
|
|
59
|
+
return decisionResponse(problemDetails(compact({
|
|
60
|
+
decision,
|
|
61
|
+
detail: decision.outcome,
|
|
62
|
+
instance: init?.instance
|
|
63
|
+
})), decision);
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/server/route-guard.ts
|
|
67
|
+
function routeScopes(value) {
|
|
68
|
+
if (value === void 0) return;
|
|
69
|
+
const scopes = Array.isArray(value) ? value : [];
|
|
70
|
+
const names = scopes.filter((scope) => typeof scope === "string" && scope !== "");
|
|
71
|
+
if (names.length === 0 || names.length !== scopes.length) throw new TypeError("PermDock: oauthScopes must be a non-empty list of scope names");
|
|
72
|
+
return names;
|
|
73
|
+
}
|
|
74
|
+
async function refused(hook, fallback, decision, request, report) {
|
|
75
|
+
if (hook === void 0) return {
|
|
76
|
+
ok: false,
|
|
77
|
+
response: fallback,
|
|
78
|
+
decision
|
|
79
|
+
};
|
|
80
|
+
try {
|
|
81
|
+
const result = await hook({
|
|
82
|
+
decision,
|
|
83
|
+
problem: await fallback.clone().json(),
|
|
84
|
+
request
|
|
85
|
+
});
|
|
86
|
+
if (result === void 0) return {
|
|
87
|
+
ok: false,
|
|
88
|
+
response: fallback,
|
|
89
|
+
decision
|
|
90
|
+
};
|
|
91
|
+
const status = result.status;
|
|
92
|
+
if (typeof status !== "number" || status < 300) throw new TypeError(`PermDock: onDenied returned status ${String(status)}; a refusal keeps a status of 300 or more`);
|
|
93
|
+
return {
|
|
94
|
+
ok: false,
|
|
95
|
+
response: result instanceof Response ? result : new Response(JSON.stringify(result), {
|
|
96
|
+
status,
|
|
97
|
+
headers: fallback.headers
|
|
98
|
+
}),
|
|
99
|
+
decision
|
|
100
|
+
};
|
|
101
|
+
} catch (error) {
|
|
102
|
+
report(error);
|
|
103
|
+
return {
|
|
104
|
+
ok: false,
|
|
105
|
+
response: fallback,
|
|
106
|
+
decision
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
async function guardOn(deps, instance, remote, report, request, permission, load, protectOptions) {
|
|
111
|
+
const declared = routeScopes(protectOptions.oauthScopes ?? (request === void 0 ? void 0 : deps.options.operations?.oauthScopesForRequest(request.method, new URL(request.url).pathname)));
|
|
112
|
+
const credentials = request === void 0 ? false : hasCredentials(request);
|
|
113
|
+
if (permission === null) {
|
|
114
|
+
if (declared === void 0) throw new TypeError(request === void 0 ? "PermDock: protect(null) needs oauthScopes" : `PermDock: protect(null) needs oauthScopes, and no operation declares them for ${request.method} ${new URL(request.url).pathname}`);
|
|
115
|
+
if (instance.subject.principal === null) return refused(deps.options.onDenied, unauthenticatedProblem(credentials), ANONYMOUS, request, report);
|
|
116
|
+
}
|
|
117
|
+
const { actor, delegation } = instance.subject;
|
|
118
|
+
const held = permission === null && (actor !== void 0 || delegation !== void 0) ? delegation?.scopes ?? [] : delegation?.scopes;
|
|
119
|
+
if (declared !== void 0 && held !== void 0 && !declared.some((granted) => held.includes(granted))) return refused(deps.options.onDenied, scopeProblem(permission, instance.subject, credentials, declared[0]), NOT_DELEGATED, request, report);
|
|
120
|
+
let data;
|
|
121
|
+
if (load !== void 0) {
|
|
122
|
+
let loaded;
|
|
123
|
+
try {
|
|
124
|
+
loaded = await load();
|
|
125
|
+
} catch (error) {
|
|
126
|
+
report(error);
|
|
127
|
+
return refused(deps.options.onDenied, loadFailedProblem(permission), LOAD_FAILED, request, report);
|
|
128
|
+
}
|
|
129
|
+
if (loaded === null || loaded === void 0) return {
|
|
130
|
+
ok: false,
|
|
131
|
+
response: notFoundProblem()
|
|
132
|
+
};
|
|
133
|
+
data = loaded;
|
|
134
|
+
}
|
|
135
|
+
if (permission === null) return {
|
|
136
|
+
ok: true,
|
|
137
|
+
permdock: instance,
|
|
138
|
+
data
|
|
139
|
+
};
|
|
140
|
+
const decideOptions = compact({
|
|
141
|
+
source: "adapter",
|
|
142
|
+
adapter: deps.adapter,
|
|
143
|
+
field: protectOptions.field,
|
|
144
|
+
explain: protectOptions.explain,
|
|
145
|
+
...protectOptions.trusted === true ? { trusted: true } : {
|
|
146
|
+
trusted: false,
|
|
147
|
+
boundary: "http-body"
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
const raw = remote === void 0 ? instance.decide(permission, data, decideOptions) : await remote.decide(permission, data, decideOptions).catch(() => ({
|
|
151
|
+
outcome: "denied",
|
|
152
|
+
denials: [{
|
|
153
|
+
role: null,
|
|
154
|
+
reason: "pdp-unavailable"
|
|
155
|
+
}],
|
|
156
|
+
alternatives: []
|
|
157
|
+
}));
|
|
158
|
+
const decision = await applyApprovalResume(raw, permission, instance, deps.options.store, request, resourceRef(permission, data), deps.adapter);
|
|
159
|
+
if (decision.outcome === "granted") return {
|
|
160
|
+
ok: true,
|
|
161
|
+
permdock: instance,
|
|
162
|
+
decision,
|
|
163
|
+
data
|
|
164
|
+
};
|
|
165
|
+
return refused(deps.options.onDenied, problemFromDecision(decision, permission, instance.subject, compact({
|
|
166
|
+
approval: deps.options.approval,
|
|
167
|
+
credentials,
|
|
168
|
+
scope: declared?.[0] ?? challengeScope(deps.policy, permission),
|
|
169
|
+
disclosure: data === void 0 ? void 0 : deps.policy.resources.get(permission.resource)?.disclosure
|
|
170
|
+
})), decision, request, report);
|
|
171
|
+
}
|
|
172
|
+
//#endregion
|
|
173
|
+
//#region src/server/create.ts
|
|
174
|
+
async function resolveActor(request, options) {
|
|
175
|
+
return (options.webBotAuth === void 0 ? void 0 : await options.webBotAuth(request)) ?? actorFrom(options.actor, request);
|
|
176
|
+
}
|
|
177
|
+
const NO_TENANT = "\0";
|
|
178
|
+
function createPermDock(policy, options) {
|
|
179
|
+
return createServerKernel(policy, options);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* The kernel behind every HTTP adapter. The subject and actor are resolved
|
|
183
|
+
* once per `Request`; one instance is cached per `(Request, tenant)`, so a
|
|
184
|
+
* global middleware and a later tenant-scoped `protect` never share a tenant.
|
|
185
|
+
*/
|
|
186
|
+
function createServerKernel(policy, options) {
|
|
187
|
+
const adapter = options.adapter ?? "server";
|
|
188
|
+
const subjects = /* @__PURE__ */ new WeakMap();
|
|
189
|
+
const instances = /* @__PURE__ */ new WeakMap();
|
|
190
|
+
const freshSubject = async (request) => {
|
|
191
|
+
const actor = await resolveActor(request, options);
|
|
192
|
+
const errors = [];
|
|
193
|
+
const context = await requestContext(options.context, request, errors);
|
|
194
|
+
return {
|
|
195
|
+
user: await resolveOrNull(() => options.subject(request)),
|
|
196
|
+
actor,
|
|
197
|
+
context,
|
|
198
|
+
errors
|
|
199
|
+
};
|
|
200
|
+
};
|
|
201
|
+
const resolveSubject = (request) => {
|
|
202
|
+
const hit = subjects.get(request);
|
|
203
|
+
if (hit !== void 0) return hit;
|
|
204
|
+
const resolved = freshSubject(request);
|
|
205
|
+
subjects.set(request, resolved);
|
|
206
|
+
return resolved;
|
|
207
|
+
};
|
|
208
|
+
const reporters = /* @__PURE__ */ new WeakMap();
|
|
209
|
+
const instanceFor = async ({ user, actor, context, errors }, tenant) => {
|
|
210
|
+
const built = await buildReportingInstance({
|
|
211
|
+
policy,
|
|
212
|
+
user,
|
|
213
|
+
sources: options,
|
|
214
|
+
scope: {
|
|
215
|
+
tenant,
|
|
216
|
+
actor,
|
|
217
|
+
context
|
|
218
|
+
},
|
|
219
|
+
errors,
|
|
220
|
+
wrap: options.wrap
|
|
221
|
+
});
|
|
222
|
+
const remote = options.pdp === void 0 ? void 0 : await options.pdp(policy, user, built.options);
|
|
223
|
+
reporters.set(built.permdock, built.report);
|
|
224
|
+
return {
|
|
225
|
+
permdock: built.permdock,
|
|
226
|
+
remote,
|
|
227
|
+
report: built.report
|
|
228
|
+
};
|
|
229
|
+
};
|
|
230
|
+
const build = async (request, scope) => {
|
|
231
|
+
const { tenant } = scope ?? await tenantScope(options.tenant, request);
|
|
232
|
+
let byTenant = instances.get(request);
|
|
233
|
+
if (byTenant === void 0) {
|
|
234
|
+
byTenant = /* @__PURE__ */ new Map();
|
|
235
|
+
instances.set(request, byTenant);
|
|
236
|
+
}
|
|
237
|
+
const key = tenant ?? NO_TENANT;
|
|
238
|
+
const hit = byTenant.get(key);
|
|
239
|
+
if (hit !== void 0) return hit;
|
|
240
|
+
const built = (async () => instanceFor(await resolveSubject(request), tenant))();
|
|
241
|
+
byTenant.set(key, built);
|
|
242
|
+
return built;
|
|
243
|
+
};
|
|
244
|
+
const connection = async (request, connectionOptions = {}, scope) => {
|
|
245
|
+
const { tenant } = scope ?? await tenantScope(options.tenant, request);
|
|
246
|
+
const { openConnection } = await import("./connection-DUsczpB5.js");
|
|
247
|
+
return openConnection({
|
|
248
|
+
open: async () => (await build(request, { tenant })).permdock,
|
|
249
|
+
rebuild: async () => (await instanceFor(await freshSubject(request), tenant)).permdock,
|
|
250
|
+
tenant,
|
|
251
|
+
...options.revocations === void 0 ? {} : { feed: options.revocations },
|
|
252
|
+
adapter,
|
|
253
|
+
options: connectionOptions
|
|
254
|
+
});
|
|
255
|
+
};
|
|
256
|
+
const permdock = async (request, scope) => (await build(request, scope)).permdock;
|
|
257
|
+
const getSnapshot = async (request, query = {}) => {
|
|
258
|
+
return (await permdock(request, query.tenant === void 0 ? void 0 : { tenant: query.tenant })).snapshot(compact({
|
|
259
|
+
include: query.include,
|
|
260
|
+
tenants: query.tenants
|
|
261
|
+
}));
|
|
262
|
+
};
|
|
263
|
+
const deps = {
|
|
264
|
+
policy,
|
|
265
|
+
options,
|
|
266
|
+
adapter
|
|
267
|
+
};
|
|
268
|
+
const protectRoute = (permission, loadData, protectOptions = {}) => {
|
|
269
|
+
if (permission === null && routeScopes(protectOptions.oauthScopes) === void 0 && options.operations === void 0) throw new TypeError("PermDock: protect(null) needs oauthScopes, in its options or an operations entry");
|
|
270
|
+
return async (request, scope) => {
|
|
271
|
+
let instance;
|
|
272
|
+
let remote;
|
|
273
|
+
let report;
|
|
274
|
+
try {
|
|
275
|
+
({permdock: instance, remote, report} = await build(request, scope));
|
|
276
|
+
} catch (error) {
|
|
277
|
+
if (error instanceof InvalidSignatureError) return {
|
|
278
|
+
ok: false,
|
|
279
|
+
response: error.response
|
|
280
|
+
};
|
|
281
|
+
throw error;
|
|
282
|
+
}
|
|
283
|
+
return guardOn(deps, instance, remote, report, request, permission, loadData === void 0 ? void 0 : () => loadData(request), protectOptions);
|
|
284
|
+
};
|
|
285
|
+
};
|
|
286
|
+
const protect = protectRoute;
|
|
287
|
+
const openapi = {
|
|
288
|
+
security: (permission) => ({
|
|
289
|
+
security: [{ oauth2: [permission.scope] }],
|
|
290
|
+
"x-permdock-permissions": [permission.key]
|
|
291
|
+
}),
|
|
292
|
+
securitySchemes: () => {
|
|
293
|
+
const scopes = {};
|
|
294
|
+
for (const leaf of listPermissions(policy.permissions)) scopes[leaf.scope] = leaf.meta.title ?? leaf.key;
|
|
295
|
+
return { oauth2: {
|
|
296
|
+
type: "oauth2",
|
|
297
|
+
flows: {},
|
|
298
|
+
scopes
|
|
299
|
+
} };
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
const permdockHandler = (scope) => createEvaluationsHandler(compact({
|
|
303
|
+
policy,
|
|
304
|
+
resolve: scope === void 0 ? permdock : async (request) => permdock(request, await scope(request)),
|
|
305
|
+
store: options.store,
|
|
306
|
+
adapter
|
|
307
|
+
}));
|
|
308
|
+
return {
|
|
309
|
+
permdock,
|
|
310
|
+
getSnapshot,
|
|
311
|
+
protect,
|
|
312
|
+
protectOn: (instance, permission, load, protectOptions = {}, request) => guardOn(deps, instance, void 0, reporters.get(instance) ?? (() => void 0), request, permission, load, protectOptions),
|
|
313
|
+
connection,
|
|
314
|
+
shareSubject: (from, to) => {
|
|
315
|
+
const resolved = subjects.get(from);
|
|
316
|
+
if (resolved !== void 0 && !subjects.has(to)) subjects.set(to, resolved);
|
|
317
|
+
},
|
|
318
|
+
problem: (decision, init) => problemFor(decision, init, options.approval),
|
|
319
|
+
openapi,
|
|
320
|
+
permdockHandler
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
//#endregion
|
|
324
|
+
export { createServerKernel as n, createPermDock as t };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { n as isReadonlyArray, t as compact } from "./compact-
|
|
1
|
+
import { n as isReadonlyArray, t as compact } from "./compact-CAf557ZB.js";
|
|
2
2
|
import { n as freezeDeep } from "./freeze-CrU8nQeX.js";
|
|
3
|
-
import {
|
|
3
|
+
import { s as coveredByDelegation } from "./snapshot-Dc9CHPME.js";
|
|
4
|
+
import { c as listPermissions, h as formerKeys } from "./permission-registry-BsblpB-z.js";
|
|
4
5
|
import { n as sha256, t as bytesToBase64Url } from "./sha256-BO0swRXL.js";
|
|
5
|
-
import { t as coveredByDelegation } from "./delegation-D8pUEuce.js";
|
|
6
6
|
import { t as anonymousSubject } from "./subject-C6dLxqHU.js";
|
|
7
|
-
import { a as ownRecord, n as idList, r as isId } from "./capability-
|
|
7
|
+
import { a as ownRecord, n as idList, r as isId } from "./capability-txATtKV4.js";
|
|
8
8
|
//#region src/core/credential.ts
|
|
9
9
|
const MAX_NAME = 256;
|
|
10
10
|
function policies(policy) {
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
//#region src/cli/sql/statements.ts
|
|
2
|
+
function blankComments(sql) {
|
|
3
|
+
return sql.replaceAll(/--[^\n]*/gu, (comment) => " ".repeat(comment.length)).replaceAll(/\/\*[\s\S]*?\*\//gu, (comment) => comment.replaceAll(/[^\n]/gu, " "));
|
|
4
|
+
}
|
|
5
|
+
/** Split on `;` outside string literals and dollar-quoted bodies. */
|
|
6
|
+
function sqlStatements(sql) {
|
|
7
|
+
const text = blankComments(sql);
|
|
8
|
+
const statements = [];
|
|
9
|
+
const push = (start, end) => {
|
|
10
|
+
const body = text.slice(start, end);
|
|
11
|
+
const lead = body.length - body.trimStart().length;
|
|
12
|
+
const trimmed = body.trim();
|
|
13
|
+
if (trimmed !== "") statements.push({
|
|
14
|
+
line: text.slice(0, start + lead).split("\n").length,
|
|
15
|
+
text: trimmed
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
let start = 0;
|
|
19
|
+
let index = 0;
|
|
20
|
+
while (index < text.length) {
|
|
21
|
+
const char = text[index];
|
|
22
|
+
if (char === "'") {
|
|
23
|
+
const end = text.indexOf("'", index + 1);
|
|
24
|
+
index = end === -1 ? text.length : end + 1;
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
if (char === "$") {
|
|
28
|
+
const tag = /^\$[A-Za-z_]*\$/u.exec(text.slice(index, index + 64));
|
|
29
|
+
if (tag !== null) {
|
|
30
|
+
const end = text.indexOf(tag[0], index + tag[0].length);
|
|
31
|
+
index = end === -1 ? text.length : end + tag[0].length;
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (char === ";") {
|
|
36
|
+
push(start, index);
|
|
37
|
+
start = index + 1;
|
|
38
|
+
}
|
|
39
|
+
index += 1;
|
|
40
|
+
}
|
|
41
|
+
push(start, text.length);
|
|
42
|
+
return statements;
|
|
43
|
+
}
|
|
44
|
+
/** Capture group `index` of a match, or '' when an optional group took no part. */
|
|
45
|
+
function group(match, index) {
|
|
46
|
+
return match[index] ?? "";
|
|
47
|
+
}
|
|
48
|
+
const VIEW = /^create\s+(?:or\s+replace\s+)?view\s+(?<name>\S+?)(?:\s+with\s*\((?<options>[^)]*)\))?\s+as\b/iu;
|
|
49
|
+
const PRIVILEGE = /^(?:grant|revoke)\s[\s\S]*?\son\s+(?<target>[\s\S]+?)\s+(?:to|from)\s/iu;
|
|
50
|
+
const UNDIFFED_TARGET = /^(?:schema|function|procedure|routine|all\s+(?:functions|procedures|routines)\s+in\s+schema)\s/iu;
|
|
51
|
+
function privilegeTable(target) {
|
|
52
|
+
return target.replace(/^table\s+/iu, "").trim();
|
|
53
|
+
}
|
|
54
|
+
function splitUndiffed(sql) {
|
|
55
|
+
const statements = sqlStatements(sql);
|
|
56
|
+
const views = /* @__PURE__ */ new Set();
|
|
57
|
+
const moved = [];
|
|
58
|
+
let kept = sql;
|
|
59
|
+
for (const { text } of statements) {
|
|
60
|
+
const view = VIEW.exec(text)?.groups;
|
|
61
|
+
if (view !== void 0) {
|
|
62
|
+
views.add(view["name"] ?? "");
|
|
63
|
+
if (view["options"] !== void 0) moved.push(`alter view ${view["name"] ?? ""} set (${view["options"]});`);
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
const target = PRIVILEGE.exec(text)?.groups?.["target"];
|
|
67
|
+
if (target !== void 0 && (UNDIFFED_TARGET.test(target) || views.has(privilegeTable(target)))) {
|
|
68
|
+
moved.push(`${text};`);
|
|
69
|
+
kept = kept.replace(`${text};\n`, "");
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
kept,
|
|
74
|
+
moved
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region src/cli/sql/deciding-columns.ts
|
|
79
|
+
/** `schema.table`, unquoted and lower case; `public` when unqualified. */
|
|
80
|
+
function tableKey(name) {
|
|
81
|
+
const parts = name.split(".").map((part) => part.replaceAll("\"", ""));
|
|
82
|
+
return (parts.length === 1 ? ["public", ...parts] : parts).join(".").toLowerCase();
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* The columns of each membership source's table that decide who holds which
|
|
86
|
+
* membership (user, scope, id, `within`, role, `via`, expiry), and the id and
|
|
87
|
+
* value columns of a table a role or user column references, keyed by
|
|
88
|
+
* {@link tableKey}. A client that can write one can give itself a membership.
|
|
89
|
+
*/
|
|
90
|
+
function membershipColumns(config) {
|
|
91
|
+
const sources = config.supabase?.hook?.memberships ?? config.rls?.membershipSources ?? [];
|
|
92
|
+
const byTable = /* @__PURE__ */ new Map();
|
|
93
|
+
for (const source of sources) {
|
|
94
|
+
const table = tableKey(source.sql.table);
|
|
95
|
+
const columns = byTable.get(table) ?? /* @__PURE__ */ new Set();
|
|
96
|
+
for (const column of source.sql.columns) columns.add(column);
|
|
97
|
+
byTable.set(table, columns);
|
|
98
|
+
for (const through of [...source.sql.throughs, ...source.sql.userThrough === void 0 ? [] : [source.sql.userThrough]]) {
|
|
99
|
+
const keys = tableKey(through.table);
|
|
100
|
+
byTable.set(keys, /* @__PURE__ */ new Set([
|
|
101
|
+
...byTable.get(keys) ?? [],
|
|
102
|
+
through.id,
|
|
103
|
+
through.key
|
|
104
|
+
]));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return byTable;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Every `schema.table.column` a claim or a membership is computed from: the
|
|
111
|
+
* membership columns and the `attrs` table columns. Sorted.
|
|
112
|
+
*/
|
|
113
|
+
function decidingColumns(config, attrs) {
|
|
114
|
+
const entries = /* @__PURE__ */ new Set();
|
|
115
|
+
for (const [table, columns] of membershipColumns(config)) for (const column of columns) entries.add(`${table}.${column}`);
|
|
116
|
+
if (attrs?.table !== void 0) {
|
|
117
|
+
const table = tableKey(attrs.table);
|
|
118
|
+
for (const column of attrs.columns) entries.add(`${table}.${column}`);
|
|
119
|
+
}
|
|
120
|
+
return [...entries].toSorted();
|
|
121
|
+
}
|
|
122
|
+
//#endregion
|
|
123
|
+
export { splitUndiffed as a, group as i, membershipColumns as n, sqlStatements as o, tableKey as r, decidingColumns as t };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { t as compact } from "./compact-CAf557ZB.js";
|
|
2
|
+
//#region src/core/delegation-input.ts
|
|
3
|
+
/**
|
|
4
|
+
* RFC 9396 entries a token verifier put in `extra`, under
|
|
5
|
+
* `authorizationDetails` or the claim's own `authorization_details`.
|
|
6
|
+
*/
|
|
7
|
+
function authorizationDetailsOf(extra) {
|
|
8
|
+
const details = extra?.["authorizationDetails"] ?? extra?.["authorization_details"];
|
|
9
|
+
return Array.isArray(details) ? details : void 0;
|
|
10
|
+
}
|
|
11
|
+
/** The delegation a verified token's scopes and `extra` carry. */
|
|
12
|
+
function delegationFrom(scopes, extra) {
|
|
13
|
+
return compact({
|
|
14
|
+
scopes,
|
|
15
|
+
authorizationDetails: authorizationDetailsOf(extra)
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { delegationFrom as t };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ir as Decision } from "./policy-types-sp9P1iIV.js";
|
|
2
|
+
import { d as Permission } from "./permission-types-Dg39z9Kv.js";
|
|
3
|
+
//#region src/agent/denied-text.d.ts
|
|
4
|
+
/** What an agent adapter's `onDenied` receives: the refusal and the text PermDock wrote for it. */
|
|
5
|
+
type DeniedTextEvent = {
|
|
6
|
+
readonly decision: Exclude<Decision, {
|
|
7
|
+
readonly outcome: "granted";
|
|
8
|
+
}> | null;
|
|
9
|
+
readonly permission: Permission | undefined;
|
|
10
|
+
readonly text: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Replaces the human-readable text of a refusal, and nothing else: the
|
|
14
|
+
* outcome, `isError`, the structured content and the approval token stay.
|
|
15
|
+
* `undefined` keeps PermDock's text.
|
|
16
|
+
*/
|
|
17
|
+
type OnDeniedText = (event: DeniedTextEvent) => string | undefined;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { OnDeniedText as n, DeniedTextEvent as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { cr as DeniedDecision, ir as Decision, sr as DenialReason } from "./policy-types-sp9P1iIV.js";
|
|
2
|
+
import { d as Permission } from "./permission-types-Dg39z9Kv.js";
|
|
3
3
|
//#region src/core/describe.d.ts
|
|
4
4
|
type DecisionDescription = {
|
|
5
5
|
readonly kind: "granted" | "denied" | "approval" | "tenant" | "delegation" | "server-only" | "upgrade";
|
|
@@ -30,6 +30,15 @@ type DescribeMessages = {
|
|
|
30
30
|
};
|
|
31
31
|
type DescribeOptions = {
|
|
32
32
|
readonly messages?: DescribeMessages;
|
|
33
|
+
/**
|
|
34
|
+
* The permission the decision is about. Its `meta.title` replaces the key in
|
|
35
|
+
* the `granted` and `approval` text, and is what the message functions get.
|
|
36
|
+
*/
|
|
37
|
+
readonly permission?: Pick<Permission, "key"> & {
|
|
38
|
+
readonly meta?: {
|
|
39
|
+
readonly title?: string;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
33
42
|
};
|
|
34
43
|
declare function describe(decision: Decision, options?: DescribeOptions): DecisionDescription;
|
|
35
44
|
//#endregion
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as flattenApprovers } from "./approvers-
|
|
2
|
-
import { r as requiredPlans } from "./problem-details-
|
|
1
|
+
import { i as flattenApprovers } from "./approvers-CqPOLD-o.js";
|
|
2
|
+
import { r as requiredPlans } from "./problem-details-DECUnXAn.js";
|
|
3
3
|
//#region src/core/describe.ts
|
|
4
4
|
const TENANT_REASONS = /* @__PURE__ */ new Set([
|
|
5
5
|
"tenant-mismatch",
|
|
@@ -51,9 +51,10 @@ function approvalDetail(permission, labels) {
|
|
|
51
51
|
}
|
|
52
52
|
function describe(decision, options) {
|
|
53
53
|
const messages = options?.messages;
|
|
54
|
+
const labelOf = (key) => options?.permission?.key === key ? options.permission.meta?.title ?? key : key;
|
|
54
55
|
const titleOf = (kind) => messages?.titles?.[kind] ?? TITLES[kind];
|
|
55
56
|
if (decision.outcome === "granted") {
|
|
56
|
-
const
|
|
57
|
+
const permission = labelOf(decision.matched.permission);
|
|
57
58
|
return {
|
|
58
59
|
kind: "granted",
|
|
59
60
|
title: titleOf("granted"),
|
|
@@ -62,7 +63,7 @@ function describe(decision, options) {
|
|
|
62
63
|
};
|
|
63
64
|
}
|
|
64
65
|
if (decision.outcome === "approval-required") {
|
|
65
|
-
const
|
|
66
|
+
const permission = labelOf(decision.grant.permission);
|
|
66
67
|
const labels = approvers(decision.grant.approval);
|
|
67
68
|
return {
|
|
68
69
|
kind: "approval",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as globalArgs, s as stringArg, t as COMMAND_DESCRIPTIONS } from "./commands-
|
|
1
|
+
import { i as globalArgs, s as stringArg, t as COMMAND_DESCRIPTIONS } from "./commands-Cpip4ULx.js";
|
|
2
2
|
import { defineCommand } from "citty";
|
|
3
3
|
//#region src/cli/commands/diff.ts
|
|
4
4
|
function diff(ctx) {
|
|
@@ -30,7 +30,7 @@ function diff(ctx) {
|
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
32
|
async run({ args: parsed }) {
|
|
33
|
-
const result = await (await import("./diff-
|
|
33
|
+
const result = await (await import("./diff-rpqoe7Ag.js")).runDiff({
|
|
34
34
|
cwd: ctx.cwd,
|
|
35
35
|
config: ctx.config,
|
|
36
36
|
sources: parsed._,
|