permdock 0.1.0 → 0.3.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/README.md +106 -47
- package/dist/a2a/index.d.ts +7 -16
- package/dist/a2a/index.js +59 -98
- package/dist/adapter-context-mlWsVGGg.js +23 -0
- package/dist/ai-sdk/index.d.ts +37 -16
- package/dist/ai-sdk/index.js +30 -13
- package/dist/approvals/index.d.ts +3 -3
- package/dist/approvals/index.js +5 -4
- package/dist/{approvals-DaxY-Bdg.js → approvals-DbYAuNkG.js} +17 -11
- package/dist/approvers-DT4AVyIg.js +52 -0
- package/dist/{arazzo-CTeVuXr5.js → arazzo-BAgw9ap6.js} +2 -2
- package/dist/{arazzo-aoTkqYsJ.js → arazzo-CKwwqFWz.js} +2 -2
- package/dist/authzen/index.d.ts +4 -13
- package/dist/authzen/index.js +16 -50
- package/dist/better-auth/index.d.ts +20 -3
- package/dist/better-auth/index.js +27 -7
- package/dist/better-supabase/index.d.ts +223 -0
- package/dist/better-supabase/index.js +648 -0
- package/dist/bind-C_ob3LKa.d.ts +25 -0
- package/dist/bind-CuzGytRf.js +97 -0
- package/dist/boundary-BM8a_P6E.js +13 -0
- package/dist/boundary-BmHxVH1J.d.ts +15 -0
- package/dist/canonical-json-DemiK4Vp.js +26 -0
- package/dist/{capability-BDG_nkxt.d.ts → capability-2kYTMWDv.d.ts} +2 -2
- package/dist/{capability-B68OFnZx.js → capability-4qPdO9gk.js} +7 -5
- package/dist/catalog/index.d.ts +1 -1
- package/dist/catalog/index.js +1 -1
- package/dist/catalog-CRW5Mx_B.js +2 -0
- package/dist/{catalog-H-vFGwWK.js → catalog-DWF5cYqB.js} +4 -4
- package/dist/{catalog-B0E6bggc.js → catalog-dFZdWCGN.js} +2 -2
- package/dist/{catalog-doc-BSo_Q_-6.js → catalog-doc-DdGm82XT.js} +20 -32
- package/dist/claude-agent/index.d.ts +5 -14
- package/dist/claude-agent/index.js +4 -10
- package/dist/clerk/index.d.ts +12 -3
- package/dist/clerk/index.js +26 -5
- package/dist/cli/bin.js +1 -1
- package/dist/cli/index.d.ts +3 -3
- package/dist/cli/index.js +2 -2
- package/dist/clients-C7zLFuWT.d.ts +12 -0
- package/dist/clients-DjU5ABMy.js +23 -0
- package/dist/cloud/index.d.ts +4 -5
- package/dist/cloud/index.js +20 -6
- package/dist/{cloud-BNQTrmrr.js → cloud-CB_ELYuX.js} +2 -2
- package/dist/{cloud-Cuxr6Czw.js → cloud-DWLXO2af.js} +7 -6
- package/dist/collect-DClJsheJ.js +83 -0
- package/dist/{collect-O-tOtbnk.js → collect-DSTE3ml9.js} +194 -42
- package/dist/collect-DSWOk19R.js +2 -0
- package/dist/{commands-BMh_Etm2.js → commands-DSxCqG9A.js} +16 -12
- package/dist/compile/index.d.ts +3 -0
- package/dist/compile/index.js +2 -0
- package/dist/{compile-D22iwvuV.js → compile-Ba4blROR.js} +85 -30
- package/dist/compile-BkRyBDBw.d.ts +94 -0
- package/dist/config-BJiM-xAm.js +157 -0
- package/dist/config-Dnszbv-6.js +36 -0
- package/dist/config-report-DMvWKUxL.js +44 -0
- package/dist/{connection-JvqwHODC.js → connection-CU8MQxRi.js} +1 -1
- package/dist/{context-CKEAabd7.js → context-Bcy85rGi.js} +36 -27
- package/dist/convex/index.d.ts +9 -4
- package/dist/convex/index.js +14 -4
- package/dist/create-B1d519XK.d.ts +245 -0
- package/dist/create-CMwIl-w2.js +253 -0
- package/dist/{credential-B_rkUNlY.js → credential-8P81ff4u.js} +26 -46
- package/dist/delegation-D8pUEuce.js +103 -0
- package/dist/{describe-Bt1YD5uS.js → describe-B_gVZEVi.js} +10 -15
- package/dist/{describe-DernyItf.d.ts → describe-DMYiCjJV.d.ts} +9 -10
- package/dist/{diff-x5Il8LVa.js → diff-2VaeChzX.js} +44 -11
- package/dist/{diff-BUzf5Poi.js → diff-DBIhz_f2.js} +2 -2
- package/dist/{doctor-Bqo6FwUa.js → doctor-BwCAMLx_.js} +2 -2
- package/dist/doctor-collect-CHk6XWOA.js +665 -0
- package/dist/doctor-igIiM_Hl.js +1194 -0
- package/dist/drizzle/index.d.ts +4 -3
- package/dist/drizzle/index.js +3 -3
- package/dist/elysia/index.d.ts +6 -28
- package/dist/elysia/index.js +16 -60
- package/dist/{errors-DSMnAVNa.js → errors-CWfoNg9N.js} +8 -4
- package/dist/{errors-Iy71s7Oj.js → errors-Cz5zn0mW.js} +17 -71
- package/dist/{errors-DbZ1YOnb.d.ts → errors-DPdqI50v.d.ts} +8 -21
- package/dist/{errors-m3u9TmDu.js → errors-DRnGZHzF.js} +4 -1
- package/dist/evaluation-items-CfCCejQd.js +40 -0
- package/dist/{evaluations-DsAU9ppl.js → evaluations-tz6D9A2G.js} +28 -46
- package/dist/eve/index.d.ts +6 -15
- package/dist/eve/index.js +7 -12
- package/dist/expiry-BoBJ8Tvc.js +7 -0
- package/dist/express/index.d.ts +6 -29
- package/dist/express/index.js +28 -58
- package/dist/fastify/index.d.ts +6 -29
- package/dist/fastify/index.js +16 -65
- package/dist/fields-BMl1RxoX.js +26 -0
- package/dist/{files-B_wAGYmt.js → files-DWUN9PzI.js} +5 -1
- package/dist/{fixtures-Cvaw0gDG.js → fixtures-ht28Cplr.js} +5 -2
- package/dist/{freeze-y1_jQL4v.js → freeze-CrU8nQeX.js} +31 -2
- package/dist/{from-snapshot-BMGnhmgv.js → from-snapshot-CTLijvdm.js} +66 -48
- package/dist/{grantee-Bv04_Vzf.js → grantee-Cv5Sogfv.js} +88 -7
- package/dist/graph-sql-B-dsAT6j.d.ts +29 -0
- package/dist/{headers-B5RRv3Xm.js → headers-BZSDieNT.js} +1 -1
- package/dist/{headers-C8SHQccD.d.ts → headers-Cf-zWvsO.d.ts} +1 -1
- package/dist/helpers-H_KARDVC.js +421 -0
- package/dist/hono/index.d.ts +6 -28
- package/dist/hono/index.js +11 -43
- package/dist/{hosted-BwKQ1BTA.js → hosted-DJQw46hn.js} +6 -5
- package/dist/{http-GgVApX1k.js → http-BIhmLfCc.js} +4 -20
- package/dist/http-SO7qGttf.js +44 -0
- package/dist/ids-DC4V4CFu.js +18 -0
- package/dist/index-0nNqHspG.d.ts +6 -0
- package/dist/{index-xIxJLwOQ.d.ts → index-BNc7Wer_.d.ts} +75 -7
- package/dist/{index-CltcQ4Bf.d.ts → index-C7Tw7MaW.d.ts} +68 -5
- package/dist/{index-LF_hS-yn.d.ts → index-C8z4RjQV.d.ts} +1 -1
- package/dist/index.d.ts +14 -9
- package/dist/index.js +22 -17
- package/dist/instance-options-Dhhcnm3y.js +22 -0
- package/dist/instance-options-jARdwfPN.d.ts +11 -0
- package/dist/{parse-DPfIvFMU.js → json-schema-BsAflUGW.js} +28 -57
- package/dist/jwt/index.d.ts +10 -6
- package/dist/jwt/index.js +32 -13
- package/dist/kernel-_RRHmnMY.js +208 -0
- package/dist/kysely/index.d.ts +4 -3
- package/dist/kysely/index.js +3 -3
- package/dist/live-options-H2eG8dfJ.js +60 -0
- package/dist/{load-BZ24CpZP.js → load-DhWEB9P1.js} +16 -10
- package/dist/load-DwJUafYN.js +2 -0
- package/dist/manifest-iaoBXHKc.js +783 -0
- package/dist/manifest-uDS9y5de.d.ts +206 -0
- package/dist/{map-DowSO96j.js → map-AcxK9o_D.js} +4 -15
- package/dist/{map-claims-B_6I1Rn-.js → map-claims-Z4QZOiFF.js} +13 -4
- package/dist/map-error-pgUWNNtG.js +23 -0
- package/dist/may-use-DndQ5tQ-.js +77 -0
- package/dist/mcp/index.d.ts +54 -22
- package/dist/mcp/index.js +218 -178
- package/dist/nest/index.d.ts +26 -31
- package/dist/nest/index.js +75 -84
- package/dist/next/client.d.ts +7 -8
- package/dist/next/client.js +11 -9
- package/dist/next/index.d.ts +30 -47
- package/dist/next/index.js +45 -60
- package/dist/next/plugin.d.ts +1 -1
- package/dist/next/plugin.js +32 -1
- package/dist/node/index.d.ts +9 -28
- package/dist/node/index.js +11 -43
- package/dist/openai/index.d.ts +6 -15
- package/dist/openai/index.js +7 -20
- package/dist/openapi/index.d.ts +87 -4
- package/dist/openapi/index.js +3 -3
- package/dist/{openapi-DcqM8nU7.js → openapi-BqRBvAng.js} +237 -5
- package/dist/{openapi-DWD0Uc_4.js → openapi-CqqEbHsL.js} +5 -5
- package/dist/{openapi-import-BWRUNNeW.js → openapi-import-cmwetbzw.js} +1 -1
- package/dist/{openapi-CwePaF7C.js → openapi-l0xYHkcv.js} +3 -3
- package/dist/{openapi-schema-D8j_T9tO.js → openapi-schema--ARjyfQr.js} +2 -2
- package/dist/orpc/index.d.ts +15 -28
- package/dist/orpc/index.js +74 -117
- package/dist/otel/index.d.ts +2 -2
- package/dist/parse-BuyjxhZV.js +53 -0
- package/dist/parse-local-manifest-BrMozJCo.js +36 -0
- package/dist/parse-local-manifest-JLnaBH0S.d.ts +10 -0
- package/dist/pdp/index.d.ts +2 -2
- package/dist/pdp/index.js +14 -127
- package/dist/{permdock-yoZ7EjxX.js → permdock-CbgvLnuo.js} +672 -149
- package/dist/{permissions-B8vCg_bI.d.ts → permissions-CDgvKG5L.d.ts} +2 -2
- package/dist/{permissions-DC7GROPA.js → permissions-DVoF6dMt.js} +77 -15
- package/dist/{permissions-B4apnahQ.d.ts → permissions-DttnqqxC.d.ts} +34 -5
- package/dist/{permissions-CofRqesP.js → permissions-RJrovw98.js} +3 -3
- package/dist/{pins-CqE1jZuF.js → pins-8ILTftC9.js} +2 -2
- package/dist/{policy-Cq2fB8Q5.d.ts → policy-D2W7uv19.d.ts} +2 -2
- package/dist/{policy-CInmNGkM.d.ts → policy-IB6yxpC3.d.ts} +351 -42
- package/dist/{policy-ANp36PnI.js → policy-xyWg7QdR.js} +173 -22
- package/dist/powersync-BylawD_U.js +540 -0
- package/dist/powersync-DliZK_-y.js +62 -0
- package/dist/powersync-e_AZrKbg.js +2 -0
- package/dist/prisma/index.d.ts +3 -2
- package/dist/prisma/index.js +45 -20
- package/dist/{problem-Cgp9-KZA.js → problem-B43ztKIm.js} +74 -109
- package/dist/problem-details-DX075l9V.d.ts +7 -0
- package/dist/problem-details-_AMOYz-w.js +144 -0
- package/dist/{protected-BuPAycJT.d.ts → protected-BdnIEFkY.d.ts} +5 -4
- package/dist/protected-utU-SLuy.js +100 -0
- package/dist/protected-xAr24FEC.d.ts +40 -0
- package/dist/provider-CSQd7m92.js +52 -0
- package/dist/{provider-wTAUda2v.d.ts → provider-DZY281jO.d.ts} +1 -1
- package/dist/provider-store-Cfbvo4DE.js +43 -0
- package/dist/react/index.d.ts +7 -5
- package/dist/react/index.js +5 -4
- package/dist/react/provider-client.d.ts +1 -1
- package/dist/react/provider-client.js +1 -1
- package/dist/react-native/index.d.ts +166 -10
- package/dist/react-native/index.js +607 -85
- package/dist/{refs-ChLSxbST.js → refs-KYb4ntaz.js} +4 -3
- package/dist/{relations-r4soIFZB.js → relations-cjOL01hZ.js} +110 -31
- package/dist/replay-BsOyTrdV.js +28 -0
- package/dist/replay-CYyiLiwO.d.ts +5 -0
- package/dist/resource-ref-CaS9yVPi.js +20 -0
- package/dist/revocations-Bhr0aMIC.js +27 -0
- package/dist/{rls-BOFU3chG.js → rls-B4ur8nKQ.js} +8 -3
- package/dist/rls-DQtdgTHB.js +2521 -0
- package/dist/rls-fields-74oZPXWL.js +3582 -0
- package/dist/{rls-graph-DxQ39PJj.js → rls-graph-CHwx0V8q.js} +100 -36
- package/dist/{rls-import-CXV6LBlS.js → rls-import-BTFVk3jH.js} +7 -6
- package/dist/{rls-migrate-DrFPbf8p.js → rls-migrate-CN4TlJTO.js} +6 -5
- package/dist/rls-ownership-RuFqaqGz.js +843 -0
- package/dist/rls-shared-Cewd_-zI.js +495 -0
- package/dist/rls-verify-CVQTHTh5.js +746 -0
- package/dist/{row-check-BajTgQZ-.d.ts → row-check-Dt35czLy.d.ts} +12 -15
- package/dist/row-conditions-h2HythXQ.js +27 -0
- package/dist/rpc-DL9Sqvb1.js +89 -0
- package/dist/{run-CJ6UvS3a.js → run-DKDbM4Du.js} +31 -12
- package/dist/runtime-CB8gQFvS.js +11 -0
- package/dist/{saas-BRrZzJkM.js → saas-DhpJjnBA.js} +17 -7
- package/dist/{schema-P8yoma__.js → schema-D3MnDMxa.js} +8 -4
- package/dist/scim/index.d.ts +1 -1
- package/dist/scim/index.js +1 -1
- package/dist/{scim-9NFa0XVZ.js → scim-BFGBBAqR.js} +1 -1
- package/dist/{scopes-cKVp_WTw.js → scopes-CVdPrWN-.js} +35 -8
- package/dist/server/index.d.ts +22 -11
- package/dist/server/index.js +11 -8
- package/dist/{credentials-BgRX3WEg.js → server-DlZ28Oz5.js} +1 -1
- package/dist/shared-DRu8VFVM.js +123 -0
- package/dist/{sink-Cfr9-7YC.d.ts → sink-B1fZzIMf.d.ts} +1 -1
- package/dist/skills-Biq5uup3.js +192 -0
- package/dist/{skills-C_lpV4Jx.js → skills-Bx-U0irG.js} +10 -4
- package/dist/{snapshot-DE8dE_hz.js → snapshot-Enxd0n-s.js} +138 -214
- package/dist/snapshot-cache-B-LxUahj.d.ts +45 -0
- package/dist/snapshot-cache-D6jLelln.js +44 -0
- package/dist/solid/index.d.ts +39 -9
- package/dist/solid/index.js +76 -85
- package/dist/sources-4p0-4xQm.js +545 -0
- package/dist/sources-BdOYLw9j.d.ts +192 -0
- package/dist/{sql-Bll1d7y0.js → sql-xdg5f4Fi.js} +6 -1
- package/dist/{src-CTNT-PBW.js → src-BDwEZWrZ.js} +149 -11
- package/dist/ssf/index.d.ts +3 -2
- package/dist/ssf/index.js +3 -29
- package/dist/store-DMAWwAJV.js +371 -0
- package/dist/{store-Bq90395i.d.ts → store-jOBYpiXC.d.ts} +13 -4
- package/dist/store-options-ByhZq1jV.js +716 -0
- package/dist/{stores-CkG2HrSg.js → stores-BT2pSCub.js} +10 -63
- package/dist/{stores-CvOnu_2T.d.ts → stores-C0IMQrGI.d.ts} +20 -9
- package/dist/{stream-BhMfZOwr.d.ts → stream-D1RXubw2.d.ts} +2 -2
- package/dist/{stream-Q_xlB6Ko.js → stream-DDpvynSB.js} +16 -2
- package/dist/subject-settings-BwBmCdTR.js +128 -0
- package/dist/supabase/index.d.ts +133 -6
- package/dist/supabase/index.js +4 -3
- package/dist/supabase/middleware.d.ts +32 -27
- package/dist/supabase/middleware.js +56 -22
- package/dist/{supabase-D8UlBA7Z.js → supabase-Boqb9a_Y.js} +3 -3
- package/dist/{supabase-DTxGtYdi.js → supabase-C0qESOa-.js} +347 -367
- package/dist/supabase-config-BpPXt3x1.js +472 -0
- package/dist/supabase-hook-6sYLXg_u.js +2 -0
- package/dist/{supabase-hook-D_OqGb_V.js → supabase-hook-CSLQ4zJ3.js} +1037 -705
- package/dist/supautils-Cn4R4cJ4.js +91 -0
- package/dist/svelte/PermissionBoundary.svelte +37 -0
- package/dist/svelte/Protected.svelte +8 -2
- package/dist/svelte/index.d.ts +9 -6
- package/dist/svelte/index.js +61 -7
- package/dist/svelte/runtime.d.ts +4 -3
- package/dist/svelte/runtime.js +4 -3
- package/dist/svelte/source.d.ts +9 -6
- package/dist/svelte/source.js +7 -4
- package/dist/terminal/index.d.ts +6 -14
- package/dist/terminal/index.js +44 -32
- package/dist/testing/index.d.ts +105 -16
- package/dist/testing/index.js +504 -40
- 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/token-CIWxJOCh.js +50 -0
- package/dist/trpc/index.d.ts +7 -26
- package/dist/trpc/index.js +17 -100
- package/dist/types-BnIEz1sU.d.ts +48 -0
- package/dist/{types-CxquUByI.d.ts → types-Bvc4oWT6.d.ts} +1 -1
- package/dist/{sources-DOpW5Ila.d.ts → types-C97IskBw.d.ts} +86 -127
- package/dist/types-CKNSyIf_.d.ts +52 -0
- package/dist/types-Cq_H8N_X.d.ts +197 -0
- package/dist/{types-D6Z6-rKJ.d.ts → types-DbjRN55U.d.ts} +273 -22
- package/dist/{types-BBK-exvJ.d.ts → types-Dnemwd77.d.ts} +7 -1
- package/dist/{types-BvBk1wgn.d.ts → types-DxiCGmmd.d.ts} +5 -3
- package/dist/{types-B9dmiiab.d.ts → types-QCuYJh4q.d.ts} +1 -1
- package/dist/{types-B8w5PFtS.d.ts → types-aqOHTHcp.d.ts} +17 -1
- package/dist/unplugin/index.d.ts +1 -1
- package/dist/unplugin/index.js +10 -9
- package/dist/usage-DorAJiU_.js +2 -0
- package/dist/{usage-1ozMubLY.js → usage-GTixvDDU.js} +2 -2
- package/dist/{usage-CUnK6Ou9.js → usage-ItS7nLcl.js} +225 -62
- package/dist/validation-error-Ba264OaJ.d.ts +26 -0
- package/dist/validation-error-CnjZ4t92.js +33 -0
- package/dist/{validity-D0uRmJKJ.js → validity-uOp8UpYn.js} +57 -36
- package/dist/{verifier-B90agnhl.js → verifier-BxBo6I44.js} +10 -5
- package/dist/version-BvacVTZR.js +17 -0
- package/dist/views-Soe7bGSC.js +95 -0
- package/dist/{vocabulary-Dk0fs-Jk.d.ts → vocabulary-DA8a8zif.d.ts} +1 -1
- package/dist/vue/index.d.ts +35 -13
- package/dist/vue/index.js +86 -93
- package/dist/watch-BwxLTYMZ.js +2 -0
- package/dist/watch-DVBJ9cBq.js +128 -0
- package/dist/webmcp/index.d.ts +2 -2
- package/dist/webmcp/index.js +7 -13
- package/package.json +62 -36
- package/schemas/approval-request-v1.json +175 -0
- package/schemas/catalog-v1.json +29 -1
- package/schemas/supabase-claims-v1.json +6 -1
- package/schemas/supabase-manifest-v1.json +150 -6
- package/skills/permdock/SKILL.md +7 -7
- package/skills/permdock-agents/SKILL.md +5 -5
- package/skills/permdock-agents/references/runtimes.md +12 -10
- package/skills/permdock-approvals/SKILL.md +4 -4
- package/skills/permdock-approvals/references/stores-and-resume.md +15 -4
- package/skills/permdock-audit/SKILL.md +3 -3
- package/skills/permdock-credentials/SKILL.md +4 -4
- package/skills/permdock-credentials/references/tokens-keys-links.md +7 -2
- package/skills/permdock-data/SKILL.md +4 -4
- package/skills/permdock-data/references/queries-and-rls.md +14 -6
- package/skills/permdock-data/references/relationships.md +5 -3
- package/skills/permdock-tenancy/SKILL.md +9 -6
- package/skills/permdock-tenancy/references/ownership-and-custom-roles.md +14 -8
- package/skills/permdock-wire/SKILL.md +4 -4
- package/skills/permdock-wire/references/adapters.md +42 -30
- package/skills/permdock-wire/references/policy-options.md +5 -3
- package/dist/approvers-aH0PJkmf.js +0 -20
- package/dist/catalog-idsHc0vo.js +0 -2
- package/dist/collect-B7_TIfmg.js +0 -49
- package/dist/collect-fRPAQIWb.js +0 -2
- package/dist/compile-CQbvyIBr.d.ts +0 -30
- package/dist/config-BPYmjTOp.js +0 -26
- package/dist/context-gtAwAILx.js +0 -6
- package/dist/create-BKF3dgFk.d.ts +0 -162
- package/dist/create-CSkhDU9T.js +0 -222
- package/dist/doctor-BGle8Gqi.js +0 -1314
- package/dist/helpers-DnSOrhB9.js +0 -682
- package/dist/index-fG6NSXlc.d.ts +0 -9
- package/dist/kernel-YOGCWNLf.js +0 -211
- package/dist/load-QOOm1z70.js +0 -2
- package/dist/manifest-DDQbC6K0.d.ts +0 -118
- package/dist/map-error-RJ3ZsUyA.js +0 -16
- package/dist/may-use-CnFEjVEp.js +0 -37
- package/dist/pg-4GJWDUxG.js +0 -953
- package/dist/plugin-4gr7IxFJ.js +0 -65
- package/dist/protected-B4K3BKoX.js +0 -138
- package/dist/protected-wY7nXhY9.d.ts +0 -23
- package/dist/provider-_wx46HpB.js +0 -48
- package/dist/rls-CJVja9Ww.js +0 -2119
- package/dist/rls-helpers-BxRuif0l.js +0 -1346
- package/dist/runtime-DP9ttFh1.js +0 -27
- package/dist/skills-Dx3QLnMY.js +0 -110
- package/dist/source-DoBBYJi2.js +0 -6
- package/dist/sources-DVHM3Mwq.js +0 -284
- package/dist/store-C6hFW6ta.js +0 -508
- package/dist/subject-settings-xt7V845g.js +0 -82
- package/dist/supabase-hook-DW-xP4hU.js +0 -2
- package/dist/types-DbWdEfcm.d.ts +0 -87
- package/dist/types-bva3i4Gf.d.ts +0 -98
- package/dist/types-i4BAOvdb.d.ts +0 -97
- package/dist/usage-PyEor6GA.js +0 -2
- package/dist/version-CnSh33Fj.js +0 -16
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
//#region src/supabase/manifest.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* What `permdock supabase inspect --json` prints and `--out` writes to
|
|
4
|
+
* `permdock.manifest.json`: the contract between the generated hook and SQL
|
|
5
|
+
* helpers and a package that writes policies or claims next to them.
|
|
6
|
+
* `version` is the major of this shape; a field is only
|
|
7
|
+
* ever added within it. `schemas/supabase-manifest-v1.json` is its JSON Schema.
|
|
8
|
+
*/
|
|
9
|
+
type SupabaseHookManifest = {
|
|
10
|
+
readonly $schema: "https://permdock.com/schemas/supabase-manifest-v1.json";
|
|
11
|
+
readonly version: 1;
|
|
12
|
+
readonly hook: {
|
|
13
|
+
readonly schema: string;
|
|
14
|
+
readonly function: "custom_access_token_hook";
|
|
15
|
+
readonly out: string;
|
|
16
|
+
readonly before?: readonly string[];
|
|
17
|
+
};
|
|
18
|
+
readonly helpers: {
|
|
19
|
+
readonly schema: string;
|
|
20
|
+
/**
|
|
21
|
+
* `permdock_has` and, per declared scope, `permitted_<scope>_ids`, each
|
|
22
|
+
* `(p_grant text)`, the membership-only `member_<scope>_ids()` and, for a
|
|
23
|
+
* scope with a membership source, `member_<scope>_ids_for(p_user uuid)`.
|
|
24
|
+
*/
|
|
25
|
+
readonly functions: readonly string[];
|
|
26
|
+
};
|
|
27
|
+
readonly tenantClaim: string;
|
|
28
|
+
readonly budget: {
|
|
29
|
+
readonly bytes: number;
|
|
30
|
+
readonly measure: string;
|
|
31
|
+
};
|
|
32
|
+
readonly claims: readonly SupabaseHookClaim[];
|
|
33
|
+
readonly authzVersion: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* With `authzVersion`, the function that bumps the listed users' `authz_ver`,
|
|
36
|
+
* for a membership source outside the hook. It is `security definer` and no
|
|
37
|
+
* client role may execute it: call it from a trigger owned by the table's owner.
|
|
38
|
+
*/
|
|
39
|
+
readonly authzVersionBump?: {
|
|
40
|
+
readonly schema: string;
|
|
41
|
+
readonly function: "permdock_bump_authz_version_for";
|
|
42
|
+
readonly args: "p_users uuid[]";
|
|
43
|
+
};
|
|
44
|
+
/** The `supabase.hook.memberships` sources, in the order the hook reads them. */
|
|
45
|
+
readonly memberships: readonly SupabaseManifestMembership[];
|
|
46
|
+
readonly rls: SupabaseManifestRls;
|
|
47
|
+
/**
|
|
48
|
+
* Every `schema.table.column` a membership or an `attrs` claim is computed
|
|
49
|
+
* from. A client role that can insert or update one can grant itself access.
|
|
50
|
+
*/
|
|
51
|
+
readonly decidingColumns: readonly string[];
|
|
52
|
+
/** The majors of the `-- permdock:hook` and `-- permdock:grants` marker lines. */
|
|
53
|
+
readonly markers: {
|
|
54
|
+
readonly hook: "v1";
|
|
55
|
+
readonly grants: "v1";
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* The `supabase/sdk` capability-matrix feature ids the hook, the helpers and
|
|
59
|
+
* `subjectFromSupabase` depend on, as of the `matrix` release tag. A client
|
|
60
|
+
* SDK that lacks one cannot serve this policy.
|
|
61
|
+
*/
|
|
62
|
+
readonly requires?: SupabaseManifestRequires;
|
|
63
|
+
};
|
|
64
|
+
type SupabaseManifestRequires = {
|
|
65
|
+
/** The capability-matrix release tag, `capability-matrix-v1.<minor>.<patch>`. */
|
|
66
|
+
readonly matrix: string;
|
|
67
|
+
/** Sorted three-segment feature ids, such as `auth.session.get_claims`. */
|
|
68
|
+
readonly capabilities: readonly string[];
|
|
69
|
+
};
|
|
70
|
+
type SupabaseHookClaim = {
|
|
71
|
+
readonly name: string;
|
|
72
|
+
/** `permdock`, or the `<schema>.<function>` of a `supabase.hook.claims` entry. */
|
|
73
|
+
readonly source: string;
|
|
74
|
+
/** Whether the claim counts toward `budget.bytes`. */
|
|
75
|
+
readonly budget: boolean;
|
|
76
|
+
};
|
|
77
|
+
type SupabaseManifestColumn = {
|
|
78
|
+
readonly column: string;
|
|
79
|
+
};
|
|
80
|
+
/** A column of the source table, or a value every row has. */
|
|
81
|
+
type SupabaseManifestValue = SupabaseManifestColumn | {
|
|
82
|
+
readonly value: string | readonly string[];
|
|
83
|
+
};
|
|
84
|
+
/** A column that references another table: the value (role key or user id) is `column` of `table`, matched on `id`. */
|
|
85
|
+
type SupabaseManifestThrough = {
|
|
86
|
+
readonly table: string;
|
|
87
|
+
readonly id: string;
|
|
88
|
+
readonly column: string;
|
|
89
|
+
};
|
|
90
|
+
/** A role column (with `through` when it references a roles table), or the fixed roles every row holds. */
|
|
91
|
+
type SupabaseManifestRole = SupabaseManifestValue | (SupabaseManifestColumn & {
|
|
92
|
+
readonly through: SupabaseManifestThrough;
|
|
93
|
+
});
|
|
94
|
+
/** One `fromTable` or `fromJunction` source. */
|
|
95
|
+
type SupabaseManifestMembership = {
|
|
96
|
+
/** `schema.table`, `public` when the source names no schema. */
|
|
97
|
+
readonly table: string;
|
|
98
|
+
/** The user id column, with `through` when it references the table that holds the user id. */
|
|
99
|
+
readonly user: SupabaseManifestColumn | (SupabaseManifestColumn & {
|
|
100
|
+
readonly through: SupabaseManifestThrough;
|
|
101
|
+
});
|
|
102
|
+
/** A column for `fromTable`, the fixed scope for `fromJunction`. */
|
|
103
|
+
readonly scope: SupabaseManifestValue;
|
|
104
|
+
readonly id: SupabaseManifestColumn;
|
|
105
|
+
/** A role column, the fixed roles every row holds, or several role columns whose keys the row holds together. */
|
|
106
|
+
readonly role: SupabaseManifestRole | readonly SupabaseManifestRole[];
|
|
107
|
+
/** A `jsonb` column of ancestor ids keyed by scope, or one column per ancestor scope. */
|
|
108
|
+
readonly within?: SupabaseManifestColumn | {
|
|
109
|
+
readonly columns: Readonly<Record<string, string>>;
|
|
110
|
+
};
|
|
111
|
+
readonly via?: SupabaseManifestValue;
|
|
112
|
+
readonly expiresAt?: SupabaseManifestColumn;
|
|
113
|
+
readonly disabledAt?: SupabaseManifestColumn;
|
|
114
|
+
/** The columns of `table` that decide the membership. */
|
|
115
|
+
readonly columns: readonly string[];
|
|
116
|
+
};
|
|
117
|
+
type SupabaseManifestHelper = {
|
|
118
|
+
readonly name: string;
|
|
119
|
+
/** The argument list, `p_grant text`, or `''` for none. */
|
|
120
|
+
readonly args: string;
|
|
121
|
+
readonly returns: string;
|
|
122
|
+
/** The roles granted `execute`; a field view `anon` reads adds `anon` to the `authenticated` ones. */
|
|
123
|
+
readonly execute: readonly string[];
|
|
124
|
+
};
|
|
125
|
+
/** A table whose row says whether a user or a scope instance is active (`rls.suspension`); a missing row counts as suspended. */
|
|
126
|
+
type SupabaseManifestActiveRow = {
|
|
127
|
+
/** `schema.table`. */
|
|
128
|
+
readonly table: string;
|
|
129
|
+
/** The column holding the user id or the scope instance id. */
|
|
130
|
+
readonly id: string;
|
|
131
|
+
/** A nullable timestamp column; a row with a value is suspended. */
|
|
132
|
+
readonly disabledAt?: string;
|
|
133
|
+
/** A status column; only a row whose value is in `active` is active. */
|
|
134
|
+
readonly status?: string;
|
|
135
|
+
readonly active?: readonly string[];
|
|
136
|
+
/** A scope only: the permission keys members of a suspended instance still hold. */
|
|
137
|
+
readonly keep?: readonly string[];
|
|
138
|
+
};
|
|
139
|
+
type SupabaseManifestRls = {
|
|
140
|
+
readonly schema: string;
|
|
141
|
+
/** Where the helpers read roles and memberships: the claims (`jwt`) or the tables (`database`). */
|
|
142
|
+
readonly mode: "jwt" | "database";
|
|
143
|
+
readonly tenantClaim: string;
|
|
144
|
+
/** The declared scopes, root first, with the Postgres type of their ids. */
|
|
145
|
+
readonly scopes: readonly {
|
|
146
|
+
readonly name: string;
|
|
147
|
+
readonly type: string;
|
|
148
|
+
readonly within?: string;
|
|
149
|
+
}[];
|
|
150
|
+
/**
|
|
151
|
+
* Every function `rls generate` writes for policies and trusted SQL to
|
|
152
|
+
* call: `permdock_has`, `permitted_<scope>_ids`, `member_<scope>_ids` and
|
|
153
|
+
* `permdock_user_id`, the caller's user id; in `database` mode `permdock_has_for`, `permitted_<scope>_ids_for` and
|
|
154
|
+
* `member_<scope>_ids_for`; and when a role declares `assigns`,
|
|
155
|
+
* `permdock_can_assign`, `permdock_can_assign_any` and, with custom roles,
|
|
156
|
+
* `permdock_can_assign_custom_role`, each with its `_for` form where one
|
|
157
|
+
* is written. A helper whose `execute` is empty is for trusted SQL only.
|
|
158
|
+
*/
|
|
159
|
+
readonly helpers: readonly SupabaseManifestHelper[];
|
|
160
|
+
/**
|
|
161
|
+
* The tables `member_<scope>_ids_for` reads: an `rls.memberships` table
|
|
162
|
+
* mapped for the scope, else `rls.membershipSources`, else the hook's
|
|
163
|
+
* `memberships`.
|
|
164
|
+
*/
|
|
165
|
+
readonly memberships: readonly SupabaseManifestMembership[];
|
|
166
|
+
/** Whether custom roles live in the helpers' tables (`rls.customRoles` in `database` mode). */
|
|
167
|
+
readonly customRoles?: boolean;
|
|
168
|
+
/** The global-roles table the hook and the `database` mode helpers read. */
|
|
169
|
+
readonly roles?: {
|
|
170
|
+
readonly table: string;
|
|
171
|
+
readonly user: SupabaseManifestColumn;
|
|
172
|
+
readonly role: SupabaseManifestRole | readonly SupabaseManifestRole[];
|
|
173
|
+
};
|
|
174
|
+
/** `rls.suspension`: a suspended user, or a suspended scope instance, holds nothing but its scope's `keep`. */
|
|
175
|
+
readonly suspension?: {
|
|
176
|
+
readonly users?: SupabaseManifestActiveRow;
|
|
177
|
+
readonly scopes?: Readonly<Record<string, SupabaseManifestActiveRow>>;
|
|
178
|
+
readonly memberships?: {
|
|
179
|
+
readonly keep: readonly string[];
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* `rls.assignments`: the tables whose client writes the assignment
|
|
184
|
+
* triggers check against `permdock_can_assign_any`, so SQL writing rows
|
|
185
|
+
* there needs no role-ceiling check of its own.
|
|
186
|
+
*/
|
|
187
|
+
readonly assignments?: {
|
|
188
|
+
readonly tables: readonly string[];
|
|
189
|
+
};
|
|
190
|
+
readonly apiKeys?: {
|
|
191
|
+
readonly claim: string;
|
|
192
|
+
readonly scopes: string;
|
|
193
|
+
readonly tenant: string;
|
|
194
|
+
readonly roles: string;
|
|
195
|
+
readonly serviceRoles: readonly string[];
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* Reads a `permdock.manifest.json` document (parsed, or the JSON text) and
|
|
200
|
+
* validates it against `schemas/supabase-manifest-v1.json`. Returns a
|
|
201
|
+
* deep-frozen copy built from own keys; throws `PermDockValidationError`
|
|
202
|
+
* with every issue, so a manifest of another major is refused.
|
|
203
|
+
*/
|
|
204
|
+
declare function parseSupabaseManifest(json: unknown): SupabaseHookManifest;
|
|
205
|
+
//#endregion
|
|
206
|
+
export { SupabaseManifestHelper as a, SupabaseManifestRls as c, SupabaseManifestValue as d, parseSupabaseManifest as f, SupabaseManifestColumn as i, SupabaseManifestRole as l, SupabaseHookManifest as n, SupabaseManifestMembership as o, SupabaseManifestActiveRow as r, SupabaseManifestRequires as s, SupabaseHookClaim as t, SupabaseManifestThrough as u };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as compact } from "./compact-y6vfu2_f.js";
|
|
2
|
-
import {
|
|
2
|
+
import { t as itemResourceData } from "./evaluation-items-CfCCejQd.js";
|
|
3
3
|
//#region src/authzen/map.ts
|
|
4
4
|
const UNKNOWN = {
|
|
5
5
|
outcome: "denied",
|
|
@@ -28,22 +28,11 @@ function actionNameOf(item) {
|
|
|
28
28
|
const scope = item.action.properties["scope"];
|
|
29
29
|
return typeof scope === "string" ? scope : void 0;
|
|
30
30
|
}
|
|
31
|
-
function permissionOf(
|
|
32
|
-
|
|
33
|
-
if (actionName === void 0) return;
|
|
34
|
-
const byKey = findPermission(tree, actionName);
|
|
35
|
-
if (byKey !== void 0) return byKey;
|
|
36
|
-
const resource = typeof item.resource?.type === "string" ? item.resource.type : void 0;
|
|
37
|
-
if (resource === void 0) return;
|
|
38
|
-
const dotted = findPermission(tree, `${resource}.${actionName}`);
|
|
39
|
-
if (dotted !== void 0) return dotted;
|
|
40
|
-
return listPermissions(tree).find((leaf) => leaf.resource === resource && leaf.action === actionName);
|
|
31
|
+
function permissionOf(lookup, item) {
|
|
32
|
+
return lookup(actionNameOf(item), item.resource);
|
|
41
33
|
}
|
|
42
34
|
function resourceData(item) {
|
|
43
|
-
|
|
44
|
-
if (properties !== null && typeof properties === "object") return properties;
|
|
45
|
-
const id = item.resource?.id;
|
|
46
|
-
if (typeof id === "string" || typeof id === "number") return { id: String(id) };
|
|
35
|
+
return itemResourceData(item.resource);
|
|
47
36
|
}
|
|
48
37
|
function resourceIdOf(item) {
|
|
49
38
|
const id = item.resource?.id;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { t as compact } from "./compact-y6vfu2_f.js";
|
|
2
|
-
import { n as freezeDeep } from "./freeze-
|
|
3
|
-
import {
|
|
2
|
+
import { n as freezeDeep } from "./freeze-CrU8nQeX.js";
|
|
3
|
+
import { O as readPath, T as isForbiddenKey } from "./permissions-DVoF6dMt.js";
|
|
4
4
|
import { t as ignoreRejection } from "./thenable-okc2xDsj.js";
|
|
5
5
|
import { t as anonymousSubject } from "./subject-C6dLxqHU.js";
|
|
6
|
+
import { t as clientNameOf } from "./clients-DjU5ABMy.js";
|
|
6
7
|
//#region src/jwt/map-claims.ts
|
|
7
8
|
/** OpenID Connect Core section 5.1: profile data the provider owns. */
|
|
8
9
|
const PROFILE_CLAIMS = [
|
|
@@ -118,10 +119,17 @@ function stringRecord(value) {
|
|
|
118
119
|
for (const [key, item] of Object.entries(value)) if (typeof item === "string") out[key] = item;
|
|
119
120
|
return out;
|
|
120
121
|
}
|
|
122
|
+
function keptKeys(value) {
|
|
123
|
+
if (value === void 0) return;
|
|
124
|
+
if (!Array.isArray(value)) return [];
|
|
125
|
+
const keys = value.filter((key) => typeof key === "string" && key !== "");
|
|
126
|
+
return keys.length === value.length ? keys : [];
|
|
127
|
+
}
|
|
121
128
|
function claimExtras(record) {
|
|
122
129
|
return compact({
|
|
123
130
|
via: typeof record["via"] === "string" ? record["via"] : void 0,
|
|
124
|
-
expiresAt: typeof record["expiresAt"] === "number" ? record["expiresAt"] : void 0
|
|
131
|
+
expiresAt: typeof record["expiresAt"] === "number" ? record["expiresAt"] : void 0,
|
|
132
|
+
keep: keptKeys(record["keep"])
|
|
125
133
|
});
|
|
126
134
|
}
|
|
127
135
|
function membershipsFromClaim(value) {
|
|
@@ -204,7 +212,8 @@ function actorFromAct(claims, options) {
|
|
|
204
212
|
status: "ok",
|
|
205
213
|
actor: compact({
|
|
206
214
|
id: act.sub,
|
|
207
|
-
kind: configured?.kind ?? "oauth-client"
|
|
215
|
+
kind: configured?.kind ?? "oauth-client",
|
|
216
|
+
client: clientNameOf(configured?.clients, act.sub)
|
|
208
217
|
}),
|
|
209
218
|
chain: act
|
|
210
219
|
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { t as compact } from "./compact-y6vfu2_f.js";
|
|
2
|
+
import { n as PermDockValidationError } from "./validation-error-CnjZ4t92.js";
|
|
3
|
+
import { n as PermDockDeniedError, r as PermDockRevokedError, t as PermDockApprovalRequiredError } from "./errors-Cz5zn0mW.js";
|
|
4
|
+
import { r as decisionResponse, s as problemResponse } from "./problem-B43ztKIm.js";
|
|
5
|
+
import { r as InvalidSignatureError } from "./evaluations-tz6D9A2G.js";
|
|
6
|
+
//#region src/server/map-error.ts
|
|
7
|
+
/**
|
|
8
|
+
* Turns a thrown PermDock error into its Problem Details response, with the
|
|
9
|
+
* status, `WWW-Authenticate` and rate-limit fields `protect` sends for the
|
|
10
|
+
* same decision. Returns `undefined` for anything else so the framework's own
|
|
11
|
+
* error path takes over.
|
|
12
|
+
*/
|
|
13
|
+
function problemFromError(error, options = {}) {
|
|
14
|
+
if (error instanceof InvalidSignatureError) return error.response;
|
|
15
|
+
if (error instanceof PermDockDeniedError || error instanceof PermDockApprovalRequiredError) return decisionResponse(error.toProblemDetails(compact({ instance: options.instance })), error.decision, compact({
|
|
16
|
+
scope: error.scope,
|
|
17
|
+
credentials: options.credentials
|
|
18
|
+
}));
|
|
19
|
+
if (error instanceof PermDockRevokedError) return problemResponse(error.toProblemDetails(), void 0, error.decision);
|
|
20
|
+
if (error instanceof PermDockValidationError) return problemResponse(error.toProblemDetails(compact({ instance: options.instance })));
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { problemFromError as t };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { d as scopeList, m as tenantOf, o as resolveScope } from "./scopes-CVdPrWN-.js";
|
|
2
|
+
import { a as isMembershipExpired, t as isActive, u as nowSeconds } from "./validity-uOp8UpYn.js";
|
|
3
|
+
import { t as coveredByDelegation } from "./delegation-D8pUEuce.js";
|
|
4
|
+
//#region src/core/may-use.ts
|
|
5
|
+
function delegationMayCover(permission, delegation, hasActor) {
|
|
6
|
+
return [void 0, ...[...delegation?.access ?? [], ...delegation?.authorizationDetails ?? []].flatMap((entry) => typeof entry === "object" && entry !== null && typeof entry["identifier"] === "string" ? [entry["identifier"]] : [])].some((id) => coveredByDelegation(permission, delegation, id, hasActor) === void 0);
|
|
7
|
+
}
|
|
8
|
+
function blocksEveryRow(grant) {
|
|
9
|
+
return grant.effect === "deny" && grant.where === void 0 && grant.check === void 0 && grant.portable !== false && grant.fields === void 0 && (grant.scope === void 0 || grant.scope === "tenant");
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Whether `permission` could be granted to this instance's subject for some
|
|
13
|
+
* row: the grants its snapshot carries for the active tenant, minus an
|
|
14
|
+
* unconditional deny, within its delegation. A listing hint for tools and
|
|
15
|
+
* skills, never a decision; the call itself is decided in full.
|
|
16
|
+
*/
|
|
17
|
+
function mayUse(permdock, permission) {
|
|
18
|
+
try {
|
|
19
|
+
const snapshot = permdock.snapshot();
|
|
20
|
+
if (!("grants" in snapshot)) return false;
|
|
21
|
+
const ceiling = snapshot.delegated;
|
|
22
|
+
if (ceiling !== void 0 && !ceiling.includes(permission.key)) return false;
|
|
23
|
+
if (!delegationMayCover(permission, permdock.subject.delegation, permdock.subject.actor !== void 0 && ceiling === void 0)) return false;
|
|
24
|
+
const tenant = permdock.subject.principal?.tenant;
|
|
25
|
+
const scopes = scopeList(snapshot.scopes);
|
|
26
|
+
const grants = snapshot.grants.filter((grant) => {
|
|
27
|
+
if (grant.permission !== permission.key) return false;
|
|
28
|
+
const owner = grant.membership === void 0 ? void 0 : tenantOf(grant.membership, scopes);
|
|
29
|
+
return owner === void 0 || owner === tenant;
|
|
30
|
+
});
|
|
31
|
+
if (grants.some(blocksEveryRow)) return false;
|
|
32
|
+
return grants.some((grant) => grant.effect === "allow");
|
|
33
|
+
} catch {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function isConditioned(grant) {
|
|
38
|
+
return grant.where !== void 0 || grant.check !== void 0 || grant.validity !== void 0 || grant.portable === false;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The instances of `scope` in which the subject holds `permission`, from its
|
|
42
|
+
* live memberships of exactly that scope, within its delegation: by default
|
|
43
|
+
* those with an allow that carries no row condition (`where`, `check`, a
|
|
44
|
+
* validity window or a non-portable test; a `fields` limit is not a row
|
|
45
|
+
* condition), minus the instances any deny of the permission reaches. The
|
|
46
|
+
* in-process mirror of the SQL `permitted_<scope>_ids_by_permission`. With
|
|
47
|
+
* `conditioned: true` it also lists the instances where a conditioned allow
|
|
48
|
+
* applies, minus only unconditional denies, as
|
|
49
|
+
* `permitted_<scope>_ids_by_permission(p_permission, true)` does. A listing,
|
|
50
|
+
* never a decision: a row's own check still runs `can`.
|
|
51
|
+
*/
|
|
52
|
+
function permittedIds(permdock, permission, scope, options = {}) {
|
|
53
|
+
try {
|
|
54
|
+
const snapshot = permdock.snapshot({ tenants: "all" });
|
|
55
|
+
if (!("grants" in snapshot)) return [];
|
|
56
|
+
const scopes = scopeList(snapshot.scopes);
|
|
57
|
+
const name = resolveScope(scopes, scope);
|
|
58
|
+
const ceiling = snapshot.delegated;
|
|
59
|
+
if (name === void 0 || ceiling !== void 0 && !ceiling.includes(permission.key) || !delegationMayCover(permission, permdock.subject.delegation, permdock.subject.actor !== void 0 && ceiling === void 0)) return [];
|
|
60
|
+
const conditioned = options.conditioned === true;
|
|
61
|
+
const now = nowSeconds();
|
|
62
|
+
const allowed = /* @__PURE__ */ new Set();
|
|
63
|
+
const denied = /* @__PURE__ */ new Set();
|
|
64
|
+
for (const grant of snapshot.grants) {
|
|
65
|
+
const membership = grant.membership;
|
|
66
|
+
if (grant.permission !== permission.key || grant.scope !== name || membership?.scope !== name || membership.id === void 0 || isMembershipExpired(membership, now) || options.within !== void 0 && tenantOf(membership, scopes) !== options.within) continue;
|
|
67
|
+
if (grant.effect === "deny") {
|
|
68
|
+
if (!conditioned || !isConditioned(grant)) denied.add(membership.id);
|
|
69
|
+
} else if ((conditioned || !isConditioned(grant)) && isActive(grant.validity, now)) allowed.add(membership.id);
|
|
70
|
+
}
|
|
71
|
+
return [...allowed].filter((id) => !denied.has(id)).toSorted();
|
|
72
|
+
} catch {
|
|
73
|
+
return [];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
//#endregion
|
|
77
|
+
export { permittedIds as n, mayUse as t };
|
package/dist/mcp/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { f as ApprovalStore } from "../types-
|
|
4
|
-
import { t as ApprovalHint } from "../errors-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { C as Policy, Nr as Principal, Pr as Subject } from "../policy-IB6yxpC3.js";
|
|
2
|
+
import { f as Permission } from "../permissions-DttnqqxC.js";
|
|
3
|
+
import { f as ApprovalStore } from "../types-aqOHTHcp.js";
|
|
4
|
+
import { t as ApprovalHint } from "../errors-DPdqI50v.js";
|
|
5
|
+
import { t as InstanceOptions } from "../instance-options-jARdwfPN.js";
|
|
6
|
+
import { t as ClientNames } from "../clients-C7zLFuWT.js";
|
|
7
|
+
import { u as JwtSubjectOptions } from "../types-Cq_H8N_X.js";
|
|
8
|
+
import { o as OtelWrap } from "../types-QCuYJh4q.js";
|
|
7
9
|
import { CacheHint, Icon, McpServer, PromptCallback, ReadResourceCallback, ReadResourceTemplateCallback, RegisteredPrompt, RegisteredResource, RegisteredResourceTemplate, RegisteredTool, ResourceMetadata, ResourceTemplate, ScopeChallengeHandler, StandardSchemaWithJSON, ToolAnnotations, ToolCallback, Variables } from "@modelcontextprotocol/server";
|
|
8
10
|
//#region src/mcp/types.d.ts
|
|
9
11
|
/** The verified `AuthInfo` the MCP SDK's bearer auth puts on `ctx.http.authInfo`. */
|
|
@@ -36,6 +38,7 @@ type McpToolConfig<TInput extends StandardSchemaWithJSON | undefined = undefined
|
|
|
36
38
|
readonly annotations?: ToolAnnotations;
|
|
37
39
|
readonly icons?: Icon[];
|
|
38
40
|
readonly scopeChallenge?: ScopeChallengeHandler;
|
|
41
|
+
readonly oauthScopes?: readonly string[];
|
|
39
42
|
readonly _meta?: Record<string, unknown>;
|
|
40
43
|
/**
|
|
41
44
|
* Decide again when the handler resolves, without consuming quota, and
|
|
@@ -63,9 +66,38 @@ type GuardedMcpServer = Omit<McpServer, "registerTool" | "registerResource" | "r
|
|
|
63
66
|
registerResource(name: string, template: ResourceTemplate, config: McpResourceConfig<[uri: URL, variables: Variables]>, read: ReadResourceTemplateCallback): RegisteredResourceTemplate;
|
|
64
67
|
registerPrompt<TArgs extends StandardSchemaWithJSON | undefined = undefined>(name: string, config: McpPromptConfig<TArgs>, handler: PromptCallback<TArgs>): RegisteredPrompt;
|
|
65
68
|
};
|
|
66
|
-
|
|
69
|
+
/** A tool config when the tool's own procedure decides: no loader, no re-check. */
|
|
70
|
+
type McpProcedureToolConfig<TInput extends StandardSchemaWithJSON | undefined = undefined, TOutput extends StandardSchemaWithJSON | undefined = undefined> = Omit<McpToolConfig<TInput, TOutput>, "permission" | "data" | "longRunning"> & {
|
|
71
|
+
/** Overrides `permissionFor(name)`. */
|
|
72
|
+
readonly permission?: Permission;
|
|
73
|
+
};
|
|
74
|
+
/** `GuardedMcpServer` whose tools are listed and annotated by permission but decided by the procedure they call. */
|
|
75
|
+
type ProcedureMcpServer = Omit<GuardedMcpServer, "registerTool"> & {
|
|
76
|
+
registerTool<TInput extends StandardSchemaWithJSON | undefined = undefined, TOutput extends StandardSchemaWithJSON | undefined = undefined>(name: string, config: McpProcedureToolConfig<TInput, TOutput>, handler: ToolCallback<TInput>): RegisteredTool;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Tools whose handler calls a procedure that already runs `protect`, such as
|
|
80
|
+
* an oRPC procedure through `call()`. `tools/list` and annotations use the
|
|
81
|
+
* permission; the call itself is not guarded, so each call decides once.
|
|
82
|
+
*/
|
|
83
|
+
type McpProcedureEnforcement = {
|
|
84
|
+
readonly enforce: "procedure";
|
|
85
|
+
/** The permission of the tool `name`; `permissionOf(procedure)` from `permdock/orpc` reads it. `undefined` throws at registration. */
|
|
86
|
+
readonly permissionFor: (name: string) => Permission | undefined;
|
|
87
|
+
readonly oauthScopesFor?: (name: string) => readonly string[] | undefined;
|
|
88
|
+
};
|
|
89
|
+
type McpPermDockOptions<TUser = unknown> = InstanceOptions & {
|
|
67
90
|
/** Receives the verified auth info, or `{}` on a transport without one (stdio). */
|
|
68
91
|
readonly subject: (authInfo: McpAuthInfo) => TUser | Promise<TUser>;
|
|
92
|
+
/**
|
|
93
|
+
* The `kind` of the actor built from `authInfo.clientId`; `'mcp-client'`
|
|
94
|
+
* when absent. `'oauth-client'` decides the token under the kind
|
|
95
|
+
* `subjectFromSupabase`, `subjectFromJwt` and `permdock/a2a` give an OAuth
|
|
96
|
+
* client, so one policy delegation covers the token on every surface.
|
|
97
|
+
*/
|
|
98
|
+
readonly actorKind?: string;
|
|
99
|
+
/** Names for OAuth client ids (`ClientNames`): the actor gets `client` set to the name of `authInfo.clientId`, which a policy delegation matches with `to: { kind, client }`. */
|
|
100
|
+
readonly clients?: ClientNames;
|
|
69
101
|
readonly tenant?: string | ((authInfo: McpAuthInfo) => string | undefined | Promise<string | undefined>);
|
|
70
102
|
/** Deny every call and list nothing when the transport carries no auth info. */
|
|
71
103
|
readonly requireAuthInfo?: boolean;
|
|
@@ -90,23 +122,16 @@ type McpPermDockOptions<TUser = unknown> = {
|
|
|
90
122
|
readonly requestState?: {
|
|
91
123
|
readonly mint: (token: string, context?: never) => Promise<string>;
|
|
92
124
|
};
|
|
93
|
-
readonly memberships?: MembershipSource | readonly MembershipSource[];
|
|
94
|
-
/** The object graph for relation grants that walk a parent chain; without it they deny. */
|
|
95
|
-
readonly relations?: RelationSource;
|
|
96
|
-
readonly entitlements?: EntitlementSource;
|
|
97
|
-
readonly customRoles?: RoleSource;
|
|
98
|
-
/** Hosted grants, read once per instance; see `PolicySource`. */
|
|
99
|
-
readonly policies?: PolicySource;
|
|
100
125
|
readonly store?: ApprovalStore;
|
|
101
|
-
readonly sink?: DecisionSink;
|
|
102
|
-
readonly limits?: LimitStore;
|
|
103
|
-
readonly snapshots?: SnapshotSource;
|
|
104
126
|
/** `(permdock) => withOtel(permdock, options)` from `permdock/otel`. */
|
|
105
127
|
readonly otel?: OtelWrap;
|
|
106
128
|
};
|
|
107
129
|
type McpPermDock = {
|
|
108
130
|
/** Call before registering anything: later `register*` calls must carry a `permission`. */
|
|
109
|
-
readonly protectServer:
|
|
131
|
+
readonly protectServer: {
|
|
132
|
+
(server: McpServer): GuardedMcpServer;
|
|
133
|
+
(server: McpServer, options: McpProcedureEnforcement): ProcedureMcpServer;
|
|
134
|
+
};
|
|
110
135
|
};
|
|
111
136
|
//#endregion
|
|
112
137
|
//#region src/mcp/create.d.ts
|
|
@@ -115,13 +140,20 @@ export declare const APPROVAL_META_KEY = "dev.permdock/approval";
|
|
|
115
140
|
export declare function createPermDock<TUser, TPrincipal extends Principal = Principal>(policy: Policy<TUser, TPrincipal>, options: McpPermDockOptions<TUser>): McpPermDock;
|
|
116
141
|
//#endregion
|
|
117
142
|
//#region src/mcp/subject.d.ts
|
|
118
|
-
type McpSubjectOptions = Pick<JwtSubjectOptions, "claims" | "groupRoles" | "schema" | "delegation"
|
|
143
|
+
type McpSubjectOptions = Pick<JwtSubjectOptions, "claims" | "groupRoles" | "schema" | "delegation"> & {
|
|
144
|
+
/** The `kind` of the actor built from `authInfo.clientId`; `'mcp-client'` when absent. Match `createPermDock`'s `actorKind`. */
|
|
145
|
+
readonly actorKind?: string;
|
|
146
|
+
/** Names for OAuth client ids; match `createPermDock`'s `clients`. */
|
|
147
|
+
readonly clients?: ClientNames;
|
|
148
|
+
};
|
|
119
149
|
/**
|
|
120
150
|
* Maps the `AuthInfo` the MCP SDK's bearer verification produced to a
|
|
121
151
|
* `Subject`: the principal from the verified claims in `extra`, the client
|
|
122
|
-
* as an `mcp-client`
|
|
123
|
-
* verifies and never throws; anything
|
|
152
|
+
* as an actor of kind `actorKind` (`mcp-client` by default), the granted
|
|
153
|
+
* scopes as the delegation. Never verifies and never throws; anything
|
|
154
|
+
* unusable, including an `actorKind` that is not a non-empty string, is
|
|
155
|
+
* the anonymous subject.
|
|
124
156
|
*/
|
|
125
157
|
export declare function subjectFromMcp(authInfo: McpAuthInfo | undefined, options?: McpSubjectOptions): Subject<McpPrincipal>;
|
|
126
158
|
//#endregion
|
|
127
|
-
export type { GuardedMcpServer, McpAuthInfo, McpPermDock, McpPermDockOptions, McpPrincipal, McpPromptConfig, McpResourceConfig, McpSubjectOptions, McpToolConfig };
|
|
159
|
+
export type { GuardedMcpServer, McpAuthInfo, McpPermDock, McpPermDockOptions, McpPrincipal, McpProcedureEnforcement, McpProcedureToolConfig, McpPromptConfig, McpResourceConfig, McpSubjectOptions, McpToolConfig, ProcedureMcpServer };
|