permdock 0.21.0 → 0.22.1
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 +2 -1
- package/dist/a2a/index.d.ts +5 -5
- package/dist/a2a/index.js +5 -4
- package/dist/{adoption-scan-UkQisAqe.js → adoption-scan-DzX5Gqcg.js} +1 -1
- package/dist/agent/index.d.ts +2 -2
- package/dist/agent/index.js +1 -1
- package/dist/ai-sdk/index.d.ts +4 -4
- package/dist/ai-sdk/index.js +3 -3
- package/dist/app/index.d.ts +85 -0
- package/dist/app/index.js +91 -0
- package/dist/app-DIvM65Mv.js +24 -0
- package/dist/{approval-policies-CKlByf5o.d.ts → approval-policies-UnDSxT__.d.ts} +2 -2
- package/dist/{approval-prompt-CQFiO1KE.d.ts → approval-prompt-2hTqo6IM.d.ts} +2 -2
- package/dist/approvals/index.d.ts +3 -3
- package/dist/approvals/index.js +3 -3
- package/dist/{approvals-CuXILe52.js → approvals-B_sn4Wrn.js} +6 -6
- package/dist/{arazzo-CUthH61H.js → arazzo-BkjyGVF0.js} +1 -1
- package/dist/{arazzo-BC3uLIZy.js → arazzo-CTx11zFc.js} +3 -3
- package/dist/astro/index.d.ts +6 -6
- package/dist/astro/index.js +2 -2
- package/dist/{audience-BUonniPx.js → audience-5Xx1hdIv.js} +1 -1
- package/dist/{auth-j3Eu-j4h.js → auth-BxXHxWRy.js} +1 -1
- package/dist/authzen/index.d.ts +5 -5
- package/dist/authzen/index.js +4 -4
- package/dist/{automation-CpOk7Tlu.d.ts → automation-B20_8UoT.d.ts} +3 -3
- package/dist/{automation-x3KEUusw.js → automation-BueW05db.js} +2 -2
- package/dist/better-auth/index.d.ts +2 -2
- package/dist/better-auth/index.js +1 -1
- package/dist/better-supabase/index.d.ts +113 -56
- package/dist/better-supabase/index.js +213 -69
- package/dist/better-supabase-DF8f8oly.js +194 -0
- package/dist/{bind-CJf7S-Jd.js → bind-B4Z0U2Gr.js} +5 -5
- package/dist/{bind-XvnD_SUz.d.ts → bind-CnOMjazH.d.ts} +7 -7
- package/dist/{build-instance-CkRKgjSj.js → build-instance-B0vsViF5.js} +3 -25
- package/dist/{capability-zN6T9fxe.js → capability-CenWwTMR.js} +1 -1
- package/dist/{capability-v2xZB7us.d.ts → capability-YkRMUAsF.d.ts} +2 -2
- package/dist/{casbin-v9Xo_XPa.js → casbin-BFOuRptJ.js} +1 -1
- package/dist/{casbin-BOZN1P2Y.js → casbin-BpS9ABSO.js} +1 -1
- package/dist/catalog/index.d.ts +5 -5
- package/dist/catalog/index.js +5 -5
- package/dist/catalog-C462QC3A.js +1 -0
- package/dist/{catalog-DjDc87R2.js → catalog-CoyKnU5c.js} +1 -1
- package/dist/{catalog-s0waIrfY.js → catalog-Y4CjN8NA.js} +4 -4
- package/dist/{catalog-operations-BD22drQf.js → catalog-operations-Do1eD-Rt.js} +1 -1
- package/dist/{challenge-DbkpCx_v.js → challenge-B__LcNve.js} +3 -3
- package/dist/chat/index.d.ts +1 -1
- package/dist/chat/index.js +3 -2
- package/dist/chat-sdk/index.d.ts +3 -3
- package/dist/claude-agent/index.d.ts +3 -3
- package/dist/claude-agent/index.js +2 -2
- package/dist/clerk/index.d.ts +3 -3
- package/dist/cli/bin.js +1 -1
- package/dist/cli/index.d.ts +8 -7
- package/dist/cli/index.js +3 -3
- package/dist/cloud/index.d.ts +8 -8
- package/dist/cloud/index.js +3 -3
- package/dist/{cloud-CB0btByh.js → cloud-DXcQXWDi.js} +2 -2
- package/dist/{codemod-B-duJDFD.js → codemod-CxyKuniX.js} +13 -6
- package/dist/{codemod-C3a3Iz_w.js → codemod-DJ0WqXWk.js} +2 -2
- package/dist/{collect-DN_x7hvV.js → collect-Cr71JA7z.js} +8 -7
- package/dist/{collect-DMQ6Sxr6.js → collect-ScSG05VJ.js} +2 -2
- package/dist/collect-W9i7REKT.js +1 -0
- package/dist/compile/index.d.ts +1 -1
- package/dist/compile/index.js +1 -1
- package/dist/{compile-B_oJqmIg.js → compile-Cvru58id.js} +2 -2
- package/dist/{compile-DonvwG9x.d.ts → compile-DC-BrhH1.d.ts} +3 -3
- package/dist/{completion-6IshPaPd.js → completion-BHVvAJ6Q.js} +1 -1
- package/dist/{delegation-aK4T_5WU.js → condition-evaluate-bVVRSdzq.js} +159 -159
- package/dist/{config-C45X7mpm.js → config-2grt3oll.js} +1 -1
- package/dist/{config-D2oXUwos.js → config-DyNanTjZ.js} +10 -8
- package/dist/{config-report-Bmo62RRr.js → config-report-Cg5Y5j0h.js} +2 -2
- package/dist/{config-shape-D9paLhEX.js → config-shape-C4zqzG2K.js} +9 -2
- package/dist/{context-YhyXyqBI.js → context-Cem4QafV.js} +2 -2
- package/dist/convex/index.d.ts +5 -5
- package/dist/convex/index.js +2 -2
- package/dist/{core-Dxkwz4xR.js → core-CUjhfz0W.js} +6 -6
- package/dist/{core-9KbhurkH.d.ts → core-D2JNg5jA.d.ts} +3 -3
- package/dist/coverage-D8jBJdgD.d.ts +114 -0
- package/dist/coverage-Dh2W_DmF.js +211 -0
- package/dist/{create-DH4ZD0A7.d.ts → create-B2tdOygC.d.ts} +7 -7
- package/dist/{create-Q0wF9Elt.js → create-BJ2_8NDO.js} +5 -5
- package/dist/{create-BRiRVNUO.js → create-BsL5lCWR.js} +8 -7
- package/dist/{create-BzgDDamI.d.ts → create-CPDSbK1a.d.ts} +5 -5
- package/dist/{create-BQOQkYYg.d.ts → create-oMCcZV4X.d.ts} +9 -9
- package/dist/{credential-B3Hj4puZ.js → credential-Bap3HClV.js} +4 -4
- package/dist/{server-D0PW6ZCw.js → credentials-BXV0oz56.js} +3 -146
- package/dist/credentials-DPX140fN.d.ts +125 -0
- package/dist/delivery/index.d.ts +4 -4
- package/dist/delivery/index.js +1 -1
- package/dist/{denied-text-De8cw3MW.d.ts → denied-text-BXQkWU7d.d.ts} +2 -2
- package/dist/{describe-DibQM6g-.d.ts → describe-DVobr5FX.d.ts} +2 -2
- package/dist/{diff-BJv7I3GR.js → diff-BR9JArxz.js} +6 -6
- package/dist/{diff-3fpwo3UD.js → diff-Jc_kbDz-.js} +1 -1
- package/dist/{doctor-Bz7s3JYD.js → doctor-DaRoSPT0.js} +310 -36
- package/dist/{doctor-keoa9DpH.js → doctor-iIbdUK8F.js} +3 -3
- package/dist/drizzle/index.d.ts +3 -3
- package/dist/drizzle/index.js +1 -1
- package/dist/elysia/index.d.ts +5 -5
- package/dist/elysia/index.js +3 -3
- package/dist/{errors-OTE9u4Wk.d.ts → errors-D_JIQJYb.d.ts} +1 -1
- package/dist/{evaluate-Dcq_U2TV.js → evaluate-B5yZHmts.js} +16 -16
- package/dist/{evaluations-CNMVJVD6.js → evaluations-BzTDWO4m.js} +57 -57
- package/dist/{evaluations-OCm_Z-8V.d.ts → evaluations-DQYfh4Jh.d.ts} +3 -3
- package/dist/eve/index.d.ts +5 -5
- package/dist/eve/index.js +3 -3
- package/dist/express/index.d.ts +5 -5
- package/dist/express/index.js +3 -3
- package/dist/fastify/index.d.ts +5 -5
- package/dist/fastify/index.js +3 -3
- package/dist/{fetch-adapter-BlL-ZhHq.d.ts → fetch-adapter-DxqsIXSO.d.ts} +4 -4
- package/dist/{fetch-adapter-4EB3cLgB.js → fetch-adapter-MoYZ-vF5.js} +3 -3
- package/dist/{fields-D_TfExiI.js → fields-CVyOk-f1.js} +2 -2
- package/dist/{fixtures-Cemqurt8.js → fixtures-BVZc7OCF.js} +1 -1
- package/dist/{from-snapshot-DHnb8Fh4.js → from-snapshot-oR_N97dM.js} +346 -14
- package/dist/{gen-Cf7nQsOb.js → gen-Cw8goef4.js} +5 -5
- package/dist/{gen-DYF4LKUP.js → gen-DFpWGJWF.js} +1 -1
- package/dist/{grantee-conditions-DX4K_gGI.js → grantee-conditions-Dzprappv.js} +1 -1
- package/dist/{grantee-match-BP-k4vRJ.js → grantee-match-8J2y60MF.js} +3 -3
- package/dist/h3/index.d.ts +4 -4
- package/dist/h3/index.js +3 -3
- package/dist/{helpers-D-MXwkOF.js → helpers-DzBIfL1N.js} +25 -25
- package/dist/hono/index.d.ts +5 -5
- package/dist/hono/index.js +3 -3
- package/dist/{hosted-C2Pmhy2x.js → hosted-C5I2TSXm.js} +4 -4
- package/dist/{hosted-yhyAuQkL.d.ts → hosted-DXq1plaP.d.ts} +1 -1
- package/dist/{http-DhMWeB_h.js → http-dptLQzPP.js} +1 -1
- package/dist/{expiry-6XByK0dm.js → ids-DzhJaCUj.js} +23 -23
- package/dist/{import-C2ExjVvv.js → import-CvXswHDy.js} +2 -2
- package/dist/{import-CQ_kH_Ny.js → import-DDegvwDI.js} +2 -2
- package/dist/index-BcS8c_2S.d.ts +101 -0
- package/dist/{index--AwSBzJC.d.ts → index-BdZpqhJK.d.ts} +2 -2
- package/dist/{index-CLbGOPBr.d.ts → index-C-R8lBPb.d.ts} +3 -3
- package/dist/{index-Do7FqHEr.d.ts → index-C_8uxAlv.d.ts} +5 -5
- package/dist/{index-tuR-kZoJ.d.ts → index-Cjfa1Uwr.d.ts} +21 -40
- package/dist/{index-BqzpT-90.d.ts → index-iIsqXFVu.d.ts} +6 -6
- package/dist/index.d.ts +19 -20
- package/dist/index.js +25 -24
- package/dist/{init-DvkvbvZ_.js → init-D_T_zgFg.js} +2 -2
- package/dist/{init-kTFkEu8S.js → init-Dz552ZPp.js} +4 -4
- package/dist/{instance-options-Cq66kEeR.d.ts → instance-options-C6gEDOts.d.ts} +1 -1
- package/dist/instance-options-URVwqpMW.js +24 -0
- package/dist/{instance-snapshot-Bi4-dJk0.js → instance-snapshot-D_dGTq--.js} +9 -9
- package/dist/jwt/index.d.ts +4 -4
- package/dist/jwt/index.js +2 -2
- package/dist/{kernel-CLEzDmbv.js → kernel-NmxiWII2.js} +8 -8
- package/dist/kysely/index.d.ts +3 -3
- package/dist/kysely/index.js +1 -1
- package/dist/limits-CAhpRrhk.js +167 -0
- package/dist/{load-BaEamml-.js → load-C4p4VgwR.js} +2 -2
- package/dist/load-DiBUJx77.js +1 -0
- package/dist/{login-9ycIcJZH.js → login-B2usNw0X.js} +4 -4
- package/dist/{login-CM_etiLM.js → login-DIVe6QdP.js} +3 -3
- package/dist/{manifest-B5yF3CIq.d.ts → manifest-C6eFl3Vo.d.ts} +1 -0
- package/dist/{manifest-CCd-xrM3.js → manifest-CbHnl4I_.js} +35 -35
- package/dist/{manifest-BdzBobNK.js → manifest-D44OkoLk.js} +1 -1
- package/dist/{manifest-schema-CsFsYLF-.js → manifest-schema-DUheHWcp.js} +4 -0
- package/dist/{map-claims-PQwHynxV.js → map-claims-CAa_bQt9.js} +1 -1
- package/dist/{map-error-EOhahOVA.js → map-error-p4ROJ_26.js} +1 -1
- package/dist/mcp/index.d.ts +9 -9
- package/dist/mcp/index.js +9 -8
- package/dist/{migrate-CkLHdwuH.js → migrate-DVsxeE0y.js} +1 -1
- package/dist/{module-values-BYuNtdK5.js → module-values-BLiVlO1X.js} +3 -3
- package/dist/nest/index.d.ts +5 -5
- package/dist/nest/index.js +3 -3
- package/dist/next/index.d.ts +43 -17
- package/dist/next/index.js +54 -21
- package/dist/next/plugin.d.ts +1 -1
- package/dist/next/plugin.js +1 -1
- package/dist/node/index.d.ts +5 -5
- package/dist/node/index.js +2 -2
- package/dist/openai/index.d.ts +5 -5
- package/dist/openai/index.js +3 -3
- package/dist/openapi/index.d.ts +5 -59
- package/dist/openapi/index.js +3 -2
- package/dist/{openapi-DA7FVG2F.js → openapi-5moP9sTG.js} +4 -4
- package/dist/{openapi-BOsx0xn9.js → openapi-Cc-aS9xC.js} +6 -135
- package/dist/{openapi-QnnU2A1c.js → openapi-DcvNnLFa.js} +2 -2
- package/dist/{operations-Ci_rT6Uo.d.ts → operations-BMPx7HyO.d.ts} +1 -1
- package/dist/optional-8TKc-0j4.js +47 -0
- package/dist/orpc/index.d.ts +7 -7
- package/dist/orpc/index.js +4 -4
- package/dist/otel/index.d.ts +3 -3
- package/dist/otel/index.js +1 -1
- package/dist/{output-KT0a3B3H.js → output-RIUEs3_S.js} +1 -1
- package/dist/{ownership-CeNOtQMV.js → ownership-adPAsUwY.js} +15 -13
- package/dist/{parse-CXTT7hBq.js → parse-CORUNcCo.js} +1 -1
- package/dist/{parse-local-manifest-CE4tgFsj.d.ts → parse-local-manifest-BaCqsqwC.d.ts} +1 -1
- package/dist/pdp/index.d.ts +3 -3
- package/dist/pdp/index.js +4 -3
- package/dist/{permdock-DbAq8_Fp.js → permdock-B5LyNVgn.js} +70 -34
- package/dist/{permdock-CsrvbzHk.d.ts → permdock-BaB-KQqn.d.ts} +46 -9
- package/dist/{permissions-Dz79qsFw.js → permissions-COpRGKt7.js} +1 -1
- package/dist/{permissions-Bx6UI8n1.d.ts → permissions-DriWkV7q.d.ts} +1 -2
- package/dist/{policy-from-catalog-BtqfxytV.js → policy-from-catalog-Cy103lsm.js} +8 -8
- package/dist/{policy-types-BI9C5Sp5.d.ts → policy-types-rNfz7t0M.d.ts} +9 -3
- package/dist/{policy-CaAME-Rh.js → policy-wGzbAPQF.js} +7 -7
- package/dist/{policy-Dh9WVSVz.d.ts → policy-x8RBKW8d.d.ts} +2 -2
- package/dist/{postgrest-CWCCbaxm.d.ts → postgrest-Cn0Res25.d.ts} +9 -21
- package/dist/{powersync-DiqY3VBG.js → powersync-BUO5uQve.js} +11 -11
- package/dist/{powersync-CWsN-QaK.js → powersync-C5_aFFaU.js} +2 -2
- package/dist/powersync-DhspazC8.js +1 -0
- package/dist/preset/index.js +1 -1
- package/dist/{preset-pPrVyGU5.js → preset-Bn5Z54cH.js} +5 -6
- package/dist/prisma/index.d.ts +2 -2
- package/dist/prisma/index.js +1 -1
- package/dist/{protected-action-CuG0xz4P.d.ts → protected-action-C4aj1KjO.d.ts} +6 -7
- package/dist/{protected-action-CD1HXwQK.js → protected-action-E7Sdt_Dt.js} +1 -1
- package/dist/{provider-ihxuJbMi.d.ts → provider-B-1DlOGM.d.ts} +1 -1
- package/dist/{provider-qESIf_C0.js → provider-DKO9KHua.js} +2 -2
- package/dist/{provider-store-BTHGJH9j.js → provider-store-D4PU1my_.js} +2 -2
- package/dist/{pull-B4EhSqOG.js → pull-BkT7tTKb.js} +6 -6
- package/dist/pull-COPm1W-l.js +1 -0
- package/dist/{push-DYOI4bPf.js → push-CEPcWdTJ.js} +7 -7
- package/dist/{pushed-policy-Dszouliu.js → pushed-policy-Bi5-il4C.js} +2 -2
- package/dist/{pushed-policy-P0hgyLBh.d.ts → pushed-policy-P55cJNx5.d.ts} +1 -1
- package/dist/react/index.d.ts +6 -6
- package/dist/react/index.js +3 -3
- package/dist/react/provider-client.d.ts +1 -1
- package/dist/react/provider-client.js +1 -1
- package/dist/react-native/index.d.ts +9 -9
- package/dist/react-native/index.js +7 -7
- package/dist/{relation-walk-DK_gkgL7.js → relation-walk-BDTaTKTM.js} +1 -1
- package/dist/{relations-BxvRvDHK.js → relations-CMsJ1ARY.js} +1 -1
- package/dist/{replay-DYXI4gRN.d.ts → replay-DKhFvt0L.d.ts} +1 -1
- package/dist/{request-context-VjeXst1z.js → request-context-5gl_oxO1.js} +2 -2
- package/dist/resend/index.d.ts +4 -4
- package/dist/resend/index.js +2 -2
- package/dist/{resolve-names-BIHnWL_L.js → resolve-names-bzYlAXRt.js} +11 -6
- package/dist/{rls-CMFZWosz.js → rls-DTf8X__h.js} +45 -18
- package/dist/{rls-C7qXye9M.js → rls-v6V75yf_.js} +1 -1
- package/dist/{role-builder-C5AgaC1x.js → role-builder-boQiUvfo.js} +3 -3
- package/dist/{rpc-CYXICjM1.d.ts → rpc-BqRiVpbP.d.ts} +2 -2
- package/dist/{rpc-BNIQwEB6.js → rpc-Dhi55Whd.js} +2 -2
- package/dist/{run-CMJX9x7b.js → run-CgSQS9RF.js} +3 -3
- package/dist/run-ItR_bQGz.js +1 -0
- package/dist/{run-ticket-CjvXr6wj.js → run-ticket-Ddxt9OuU.js} +2 -2
- package/dist/{run-ticket-BXYqQ9dy.d.ts → run-ticket-Dulj4RQk.d.ts} +2 -2
- package/dist/{saas-DHFfthXv.js → saas-DABv6vjy.js} +6 -5
- package/dist/{scan-CSOkcNdl.js → scan-BY3Pp1PS.js} +1 -1
- package/dist/{schema-7pXCaRYB.js → schema-B_HsJKm2.js} +1 -1
- package/dist/scim/index.d.ts +1 -1
- package/dist/scim/index.js +1 -1
- package/dist/{scopes-BSdYaGHs.js → scopes-gdH__vDZ.js} +1 -1
- package/dist/server/index.d.ts +11 -10
- package/dist/server/index.js +7 -6
- package/dist/server-CKjFooaJ.js +147 -0
- package/dist/{server-types-Bfl-IrzZ.d.ts → server-types--_Hann81.d.ts} +9 -9
- package/dist/{shared-sW3VYchq.js → shared-DfaIWvIJ.js} +11 -2
- package/dist/{sink-RwmP7ZHs.d.ts → sink-Cs6z34AX.d.ts} +4 -4
- package/dist/{skills-DrX83QBK.js → skills-Bj2wk38p.js} +2 -2
- package/dist/{skills-DAjg-rgF.js → skills-Clo4qYLn.js} +1 -1
- package/dist/{snapshot-DHPih65J.js → snapshot-C2j96x97.js} +4 -4
- package/dist/{snapshot-cache-MPinwwgZ.d.ts → snapshot-cache-Cc7VNabe.d.ts} +1 -1
- package/dist/solid/index.d.ts +6 -7
- package/dist/solid/index.js +2 -2
- package/dist/solid-start/index.d.ts +6 -6
- package/dist/solid-start/index.js +3 -3
- package/dist/{sources-sgQlMfmz.d.ts → sources-CdYZBVcW.d.ts} +2 -2
- package/dist/{src-Cop53_X1.js → src-BG9YJM3Q.js} +96 -247
- package/dist/ssf/index.d.ts +3 -3
- package/dist/ssf/index.js +3 -3
- package/dist/{standard-webhooks-CFZIYtBF.d.ts → standard-webhooks-CJBgfl7y.d.ts} +2 -2
- package/dist/{store-CSOsXd5s.js → store-BpKH-pLm.js} +2 -2
- package/dist/{store-CRQ5VrWR.d.ts → store-DSyjHD5-.d.ts} +5 -5
- package/dist/{store-options-CDvoX52-.js → store-options-CXv6BHH6.js} +5 -6
- package/dist/{stores-PpYVQ5yF.js → stores-BuqAHjp_.js} +1 -1
- package/dist/{stores-pEBMy94l.d.ts → stores-C6-7TPTV.d.ts} +6 -7
- package/dist/{postgrest-BrjrckDG.js → subject-BqFwS6l3.js} +214 -319
- package/dist/subject-cache-BT1fGuea.js +193 -0
- package/dist/subject-cache-d_Z4KAnm.d.ts +144 -0
- package/dist/supabase/index.d.ts +7 -6
- package/dist/supabase/index.js +4 -3
- package/dist/supabase/middleware.d.ts +6 -6
- package/dist/supabase/middleware.js +6 -6
- package/dist/{supabase-Cbl2orB2.js → supabase-CJv6K3iz.js} +2 -2
- package/dist/{supabase-CVZuytCC.js → supabase-DnazO6W4.js} +3 -3
- package/dist/{supabase-hook-BUcu3vPM.js → supabase-hook-DLQMugW8.js} +174 -62
- package/dist/supabase-hook-vZADjjfN.js +1 -0
- package/dist/{supautils-a_253u1X.js → supautils-BHKsP7l-.js} +302 -43
- package/dist/{support-session-BsmPCbz8.js → support-session-BGeEYDSq.js} +2 -2
- package/dist/svelte/index.d.ts +5 -5
- package/dist/svelte/index.js +3 -3
- package/dist/svelte/runtime.d.ts +3 -3
- package/dist/svelte/runtime.js +1 -1
- package/dist/svelte/source.d.ts +5 -5
- package/dist/svelte/source.js +2 -2
- package/dist/sveltekit/index.d.ts +6 -6
- package/dist/sveltekit/index.js +2 -2
- package/dist/{tables-XrvffTMj.js → tables-CbEOy2Ma.js} +137 -55
- package/dist/tanstack-start/index.d.ts +6 -6
- package/dist/tanstack-start/index.js +2 -2
- package/dist/{tenancy-DvOHHk3-.js → tenancy-BlxY5T0q.js} +2 -2
- package/dist/terminal/index.d.ts +6 -6
- package/dist/terminal/index.js +6 -6
- package/dist/testing/core.d.ts +1 -1
- package/dist/testing/core.js +1 -1
- package/dist/testing/fixtures/index.d.ts +36 -3
- package/dist/testing/fixtures/index.js +40 -3
- package/dist/testing/index.d.ts +42 -26
- package/dist/testing/index.js +115 -27
- package/dist/testing/saas/index.d.ts +5 -5
- 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/trpc/index.d.ts +6 -6
- package/dist/trpc/index.js +4 -4
- package/dist/{type-helpers-BjOLGVy1.d.ts → type-helpers-iXJEIDe7.d.ts} +3 -4
- package/dist/{types-p8mhWTcR.d.ts → types-B9F0EZAF.d.ts} +3 -3
- package/dist/{types-DZwEOsK1.d.ts → types-BSNZMp5b.d.ts} +1 -1
- package/dist/{types-MixnvXQ5.d.ts → types-BpxdxaRD.d.ts} +5 -5
- package/dist/{types-C3C9ien9.d.ts → types-CD1qmxdx.d.ts} +4 -4
- package/dist/{types-zh4WGQcP.d.ts → types-C_a44wSr.d.ts} +3 -3
- package/dist/{types-DBVSljAx.d.ts → types-Cq2rvv-C.d.ts} +3 -3
- package/dist/{types--_lpWUGV.d.ts → types-CuDXvyIT.d.ts} +5 -5
- package/dist/{types-7Vlz1Wi2.d.ts → types-DAyp592k.d.ts} +2 -2
- package/dist/{types-DjGZAU64.d.ts → types-NikV1pND.d.ts} +4 -4
- package/dist/{types-BzxA2OAD.d.ts → types-ZfjQB0KC.d.ts} +2 -2
- package/dist/{types-DotXrris.d.ts → types-_pi9kxS2.d.ts} +2 -2
- package/dist/{types-D1NjjwI4.d.ts → types-cNZhj0UF.d.ts} +40 -9
- package/dist/unplugin/index.d.ts +1 -1
- package/dist/unplugin/index.js +1 -1
- package/dist/{usage-DHsqp4lN.js → usage-BUUXeKwk.js} +1 -1
- package/dist/{usage-DPbdI3Vi.js → usage-DlOllyPi.js} +10 -10
- package/dist/usage-NmH5QXKC.js +1 -0
- package/dist/{validation-error-DkOK9zUE.d.ts → validation-error-DLAYFlkr.d.ts} +1 -1
- package/dist/{verify-C0jGJrmb.js → verify-CfmvQjVw.js} +41 -24
- package/dist/version-sources-BC3hf2ME.js +34 -0
- package/dist/{permission-types-CAY-GU7e.d.ts → vocabulary-DeZvUaTw.d.ts} +69 -1
- package/dist/vue/index.d.ts +6 -7
- package/dist/vue/index.js +2 -2
- package/dist/{waiter-BjVI_Byg.d.ts → waiter-cbK1CBhT.d.ts} +2 -2
- package/dist/{watch-Dz2LNM1R.js → watch-BigZ260i.js} +2 -2
- package/dist/watch-CHURMgrv.js +1 -0
- package/dist/webmcp/index.d.ts +2 -2
- package/dist/{who-can-CZeAwQZD.js → who-can-CjfMP9a4.js} +8 -8
- package/dist/workflow/index.d.ts +3 -3
- package/dist/workflow/index.js +6 -5
- package/dist/workflow-sdk/index.d.ts +5 -5
- package/dist/{wrap-EQ6Or2Hi.d.ts → wrap-B-k2qHJx.d.ts} +2 -2
- package/package.json +16 -4
- package/schemas/supabase-manifest-v1.json +6 -0
- package/skills/permdock-wire/references/presets-and-recipes.md +2 -2
- package/dist/better-supabase-ayun1IKE.js +0 -122
- package/dist/catalog-BTPySmbp.js +0 -1
- package/dist/collect-eSTXOZDC.js +0 -1
- package/dist/index-DuOF7OqS.d.ts +0 -222
- package/dist/load-CjnlPxpL.js +0 -1
- package/dist/powersync-CWCirKAJ.js +0 -1
- package/dist/pull-VzcECZ-R.js +0 -1
- package/dist/run-D2e1tybu.js +0 -1
- package/dist/supabase-hook-QWphWBnG.js +0 -1
- package/dist/usage-dmSjKx-Z.js +0 -1
- package/dist/version-cache-q5cpaDSt.d.ts +0 -57
- package/dist/vocabulary-DEJ5j4mR.d.ts +0 -70
- package/dist/watch-CS69ftMP.js +0 -1
- package/dist/where-scope-BAyOsPQW.js +0 -332
- package/dist/{approval-normalize-hlfO9BJv.js → approval-normalize-DNLW0zOM.js} +1 -1
- package/dist/{body-C9JbIoqb.js → body-B3ylkmmE.js} +1 -1
- package/dist/{catalog-doc-nrgfbh8I.js → catalog-doc-Zi0jRpyH.js} +2 -2
- package/dist/{device-BwbJNmb2.js → device-BkSynWdg.js} +1 -1
- package/dist/{prompt-BYc6drYW.js → prompt-D1Gj1W4Y.js} +1 -1
- package/dist/{scim-C30QBBoF.js → scim-BG6uPUeW.js} +1 -1
- package/dist/{wrap-C5PWzgkq.js → wrap-BKU5Arsu.js} +1 -1
|
@@ -3,10 +3,223 @@ import { n as freezeDeep } from "./freeze-jjan0lCv.js";
|
|
|
3
3
|
import { r as validateRecord } from "./thenable-BNSM1U2R.js";
|
|
4
4
|
import { f as nowMillis } from "./time-nR1JesoH.js";
|
|
5
5
|
import { t as anonymousSubject } from "./subject-C7RddW0G.js";
|
|
6
|
+
import { n as readSubjectRecord, r as readMemberships } from "./subject-cache-BT1fGuea.js";
|
|
7
|
+
import { r as withApp } from "./app-DIvM65Mv.js";
|
|
6
8
|
import { t as readClaim } from "./claims-map-CKkoAAYF.js";
|
|
7
9
|
import { t as clientNameOf } from "./clients-DYr3U86j.js";
|
|
8
10
|
import "./budget-BBCPDOGP.js";
|
|
9
11
|
import { a as hookApiNames } from "./sources-C4vkzZJV.js";
|
|
12
|
+
//#region src/supabase/postgrest.ts
|
|
13
|
+
function callRpc(client, schema, fn, args) {
|
|
14
|
+
return client.schema(schema).rpc(fn, args);
|
|
15
|
+
}
|
|
16
|
+
function readMemberEntries(value) {
|
|
17
|
+
if (!Array.isArray(value)) return [];
|
|
18
|
+
return value.flatMap((item) => {
|
|
19
|
+
if (!isRecord(item) || !isRecord(item["principal"])) return [];
|
|
20
|
+
const id = item["principal"]["id"];
|
|
21
|
+
const [membership] = readMemberships([item["membership"]]).memberships;
|
|
22
|
+
return typeof id === "string" && id !== "" && membership !== void 0 ? [{
|
|
23
|
+
principal: { id },
|
|
24
|
+
membership
|
|
25
|
+
}] : [];
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function versionOf(value) {
|
|
29
|
+
const version = typeof value === "string" ? Number(value) : value;
|
|
30
|
+
return typeof version === "number" && Number.isFinite(version) ? version : void 0;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Uncached version reads of one principal closer together than this count as
|
|
34
|
+
* one request reading the version more than once.
|
|
35
|
+
*/
|
|
36
|
+
const REPEAT_WINDOW_MS = 1e3;
|
|
37
|
+
const REPEAT_TRACKED = 1e3;
|
|
38
|
+
/** Read through `globalThis` so the entry loads on runtimes without `process`. */
|
|
39
|
+
function isDevelopment() {
|
|
40
|
+
const proc = Reflect.get(globalThis, "process");
|
|
41
|
+
if (typeof proc !== "object" || proc === null) return false;
|
|
42
|
+
const env = Reflect.get(proc, "env");
|
|
43
|
+
return typeof env === "object" && env !== null && Reflect.get(env, "NODE_ENV") === "development";
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* In development, warns once when one principal's version is read twice within
|
|
47
|
+
* `REPEAT_WINDOW_MS`: a request that builds its instance more than once instead
|
|
48
|
+
* of sharing it through `instanceCache` or `permdockFor`.
|
|
49
|
+
*/
|
|
50
|
+
function repeatedVersionReads() {
|
|
51
|
+
if (!isDevelopment()) return () => void 0;
|
|
52
|
+
const last = /* @__PURE__ */ new Map();
|
|
53
|
+
let warned = false;
|
|
54
|
+
return (userId) => {
|
|
55
|
+
if (warned) return;
|
|
56
|
+
const at = nowMillis();
|
|
57
|
+
const previous = last.get(userId);
|
|
58
|
+
if (previous !== void 0 && at - previous < REPEAT_WINDOW_MS) {
|
|
59
|
+
warned = true;
|
|
60
|
+
last.clear();
|
|
61
|
+
console.warn("PermDock: the authorization version of one user was read more than once within a second. Share one instance per request through instanceCache and permdockFor, or pass version: { known }.");
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (last.size >= REPEAT_TRACKED) last.clear();
|
|
65
|
+
last.set(userId, at);
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Membership, custom-role and subject sources over the `subject_for(p_user)`,
|
|
70
|
+
* `authz_version_for(p_user)` and `members_of(p_scope, p_id)` functions
|
|
71
|
+
* `permdock supabase hook generate` writes, for a backend that reaches Postgres
|
|
72
|
+
* only through PostgREST. `memberships.version` reads only the version, so
|
|
73
|
+
* `claimsFirst` with `onStale: 'reread'` reads the full subject only for a
|
|
74
|
+
* stale token; a missing version function throws, and `permdock doctor` PD083
|
|
75
|
+
* reports it. With `policy`, a token that claims a custom role has its subject
|
|
76
|
+
* read in one `subject_for` call instead, and custom roles are read only for a
|
|
77
|
+
* subject that holds one. It keeps no answers: create it once at module scope,
|
|
78
|
+
* and `getPermDock` shares each read within one instance. Pass `claimsFirst(…,
|
|
79
|
+
* { versions })` to share version reads across instances.
|
|
80
|
+
*/
|
|
81
|
+
function postgrestSources(client, given = {}) {
|
|
82
|
+
const options = given.policy === void 0 ? given : withApp(given.policy, given);
|
|
83
|
+
const api = options.api;
|
|
84
|
+
const names = api === void 0 ? void 0 : hookApiNames(api.prefix);
|
|
85
|
+
const schema = options.schema ?? (api === void 0 ? "permdock" : api.schema ?? "public");
|
|
86
|
+
const fn = options.fn ?? names?.subjectFor ?? "subject_for";
|
|
87
|
+
const membersFn = options.membersFn ?? names?.membersOf ?? "members_of";
|
|
88
|
+
const versionFn = options.versionFn ?? names?.authzVersionFor ?? "authz_version_for";
|
|
89
|
+
const declared = options.policy === void 0 ? void 0 : options.policy.index.declaredRoles;
|
|
90
|
+
const onlyDeclared = (held) => declared !== void 0 && held?.every((name) => declared.has(name)) === true;
|
|
91
|
+
const hook = options.onSourceCall;
|
|
92
|
+
const subjects = options.subjects;
|
|
93
|
+
/**
|
|
94
|
+
* The version each instance (its memo) read, which a cached record must
|
|
95
|
+
* match.
|
|
96
|
+
*/
|
|
97
|
+
const resolved = /* @__PURE__ */ new WeakMap();
|
|
98
|
+
const noteVersionRead = repeatedVersionReads();
|
|
99
|
+
const once = (memo, method, key, read) => {
|
|
100
|
+
let ran = false;
|
|
101
|
+
const started = performance.now();
|
|
102
|
+
const run = () => {
|
|
103
|
+
ran = true;
|
|
104
|
+
return read();
|
|
105
|
+
};
|
|
106
|
+
const answer = memo === void 0 ? run() : memo(key, run);
|
|
107
|
+
if (hook === void 0) return answer;
|
|
108
|
+
return answer.finally(() => {
|
|
109
|
+
try {
|
|
110
|
+
hook({
|
|
111
|
+
source: "postgrest",
|
|
112
|
+
method,
|
|
113
|
+
durationMs: performance.now() - started,
|
|
114
|
+
cached: !ran
|
|
115
|
+
});
|
|
116
|
+
} catch {}
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
const members = async (query) => {
|
|
120
|
+
const result = await callRpc(client, schema, membersFn, {
|
|
121
|
+
p_scope: query.scope,
|
|
122
|
+
p_id: query.id
|
|
123
|
+
});
|
|
124
|
+
if (result.error !== null) throw new Error(`PermDock: ${schema}.${membersFn} failed: ${result.error.message}`);
|
|
125
|
+
return readMemberEntries(result.data);
|
|
126
|
+
};
|
|
127
|
+
const list = (query) => once(void 0, `${schema}.${membersFn}`, "", () => members(query));
|
|
128
|
+
const record = (userId, memo) => once(memo, `${schema}.${fn}`, `${schema}.${fn}:${userId}`, async () => {
|
|
129
|
+
const cached = await subjects?.record(userId, memo === void 0 ? void 0 : resolved.get(memo)?.get(userId) ?? memo.version);
|
|
130
|
+
if (cached !== null && cached !== void 0) return cached;
|
|
131
|
+
const result = await callRpc(client, schema, fn, { p_user: userId });
|
|
132
|
+
if (result.error !== null) throw new Error(`PermDock: ${schema}.${fn} failed: ${result.error.message}`);
|
|
133
|
+
const read = readSubjectRecord(result.data);
|
|
134
|
+
if (read !== void 0) await subjects?.seed(read);
|
|
135
|
+
return read;
|
|
136
|
+
});
|
|
137
|
+
const version = (userId, memo) => once(memo, `${schema}.${versionFn}`, `${schema}.${versionFn}:${userId}`, async () => {
|
|
138
|
+
noteVersionRead(userId);
|
|
139
|
+
const result = await callRpc(client, schema, versionFn, { p_user: userId });
|
|
140
|
+
if (result.error !== null) throw new Error(`PermDock: ${schema}.${versionFn} failed: ${result.error.message}`);
|
|
141
|
+
const current = versionOf(result.data);
|
|
142
|
+
if (memo !== void 0 && current !== void 0) {
|
|
143
|
+
const versions = resolved.get(memo) ?? /* @__PURE__ */ new Map();
|
|
144
|
+
versions.set(userId, current);
|
|
145
|
+
resolved.set(memo, versions);
|
|
146
|
+
}
|
|
147
|
+
return current;
|
|
148
|
+
});
|
|
149
|
+
const live = async (userId, memo) => {
|
|
150
|
+
const found = await record(userId, memo);
|
|
151
|
+
return found?.active === true ? found : void 0;
|
|
152
|
+
};
|
|
153
|
+
return {
|
|
154
|
+
memberships: {
|
|
155
|
+
async membershipsFor(principal, query) {
|
|
156
|
+
return [...(await live(principal.id, query.memo))?.memberships ?? []];
|
|
157
|
+
},
|
|
158
|
+
version(principal, context) {
|
|
159
|
+
return declared !== void 0 && !onlyDeclared([...principal.roles ?? [], ...(principal.memberships ?? []).flatMap((membership) => membership.roles)]) ? record(principal.id, context?.memo).then((found) => found?.authzVersion) : version(principal.id, context?.memo);
|
|
160
|
+
},
|
|
161
|
+
list,
|
|
162
|
+
async globalRolesFor(principal, context) {
|
|
163
|
+
return [...(await live(principal.id, context?.memo))?.roles ?? []];
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
customRoles(principal) {
|
|
167
|
+
const held = async (context, keep) => onlyDeclared(context?.held) ? [] : ((await live(principal.id, context?.memo))?.customRoles ?? []).filter(keep);
|
|
168
|
+
return {
|
|
169
|
+
rolesFor: (tenant, context) => held(context, (role) => role.tenant === tenant),
|
|
170
|
+
globalRoles: (context) => held(context, (role) => role.scope === "global"),
|
|
171
|
+
sharedRoles: (context) => held(context, (role) => role.shared === true)
|
|
172
|
+
};
|
|
173
|
+
},
|
|
174
|
+
async subject(userId) {
|
|
175
|
+
const found = await live(userId);
|
|
176
|
+
if (found === void 0) return {
|
|
177
|
+
principal: null,
|
|
178
|
+
context: {}
|
|
179
|
+
};
|
|
180
|
+
return {
|
|
181
|
+
principal: compact({
|
|
182
|
+
id: found.id,
|
|
183
|
+
roles: found.roles,
|
|
184
|
+
memberships: found.memberships,
|
|
185
|
+
authzVersion: found.authzVersion,
|
|
186
|
+
claims: found.claims
|
|
187
|
+
}),
|
|
188
|
+
context: {}
|
|
189
|
+
};
|
|
190
|
+
},
|
|
191
|
+
async refresh(subject) {
|
|
192
|
+
const current = subject.principal;
|
|
193
|
+
if (current === null) return subject;
|
|
194
|
+
const found = await live(current.id);
|
|
195
|
+
if (found === void 0) {
|
|
196
|
+
const { stale: _stale, ...kept } = subject;
|
|
197
|
+
return {
|
|
198
|
+
...kept,
|
|
199
|
+
principal: null
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
const { membershipsTruncated: _truncated, ...rest } = current;
|
|
203
|
+
const { stale: _stale, ...kept } = subject;
|
|
204
|
+
const principal = compact({
|
|
205
|
+
...rest,
|
|
206
|
+
roles: found.roles,
|
|
207
|
+
memberships: found.memberships,
|
|
208
|
+
authzVersion: found.authzVersion,
|
|
209
|
+
claims: found.claims === void 0 ? rest["claims"] : {
|
|
210
|
+
...isRecord(rest["claims"]) ? rest["claims"] : {},
|
|
211
|
+
...found.claims
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
return {
|
|
215
|
+
...kept,
|
|
216
|
+
principal
|
|
217
|
+
};
|
|
218
|
+
},
|
|
219
|
+
record: (userId) => record(userId)
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
//#endregion
|
|
10
223
|
//#region src/supabase/subject.ts
|
|
11
224
|
const REGISTERED = /* @__PURE__ */ new Set([
|
|
12
225
|
"sub",
|
|
@@ -52,63 +265,6 @@ function asRoles(value, declared) {
|
|
|
52
265
|
const allowed = new Set(declared);
|
|
53
266
|
return raw.filter((role) => allowed.has(role));
|
|
54
267
|
}
|
|
55
|
-
/**
|
|
56
|
-
* Reads the `memberships` claim; an entry it cannot read is dropped and its
|
|
57
|
-
* index reported.
|
|
58
|
-
*/
|
|
59
|
-
function readMemberships(value) {
|
|
60
|
-
if (!Array.isArray(value)) return {
|
|
61
|
-
memberships: [],
|
|
62
|
-
dropped: []
|
|
63
|
-
};
|
|
64
|
-
const out = [];
|
|
65
|
-
const dropped = [];
|
|
66
|
-
for (const [index, item] of value.entries()) {
|
|
67
|
-
const membership = asMembership(item);
|
|
68
|
-
if (membership === void 0) dropped.push(index);
|
|
69
|
-
else out.push(membership);
|
|
70
|
-
}
|
|
71
|
-
return {
|
|
72
|
-
memberships: out,
|
|
73
|
-
dropped
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
function asMembership(item) {
|
|
77
|
-
if (!isRecord(item) || !Array.isArray(item["roles"])) return;
|
|
78
|
-
const roles = item["roles"].filter((role) => typeof role === "string");
|
|
79
|
-
if (roles.length === 0) return;
|
|
80
|
-
const scope = typeof item["scope"] === "string" ? item["scope"] : void 0;
|
|
81
|
-
const id = typeof item["id"] === "string" ? item["id"] : void 0;
|
|
82
|
-
const within = isRecord(item["within"]) ? Object.fromEntries(Object.entries(item["within"]).filter((entry) => typeof entry[1] === "string")) : void 0;
|
|
83
|
-
const onRecord = isRecord(item["on"]) ? item["on"] : void 0;
|
|
84
|
-
const on = onRecord !== void 0 && typeof onRecord["resource"] === "string" && typeof onRecord["id"] === "string" ? {
|
|
85
|
-
resource: onRecord["resource"],
|
|
86
|
-
id: onRecord["id"]
|
|
87
|
-
} : void 0;
|
|
88
|
-
if ((scope === void 0 || id === void 0) && on === void 0) return;
|
|
89
|
-
const keep = item["keep"];
|
|
90
|
-
if (keep !== void 0 && (!Array.isArray(keep) || !keep.every((key) => typeof key === "string" && key !== ""))) return;
|
|
91
|
-
return compact({
|
|
92
|
-
roles,
|
|
93
|
-
scope,
|
|
94
|
-
id,
|
|
95
|
-
within,
|
|
96
|
-
on,
|
|
97
|
-
via: typeof item["via"] === "string" ? item["via"] : void 0,
|
|
98
|
-
expiresAt: typeof item["expires_at"] === "number" ? item["expires_at"] : void 0,
|
|
99
|
-
grantedBy: typeof item["granted_by"] === "string" ? item["granted_by"] : void 0,
|
|
100
|
-
reason: typeof item["reason"] === "string" ? item["reason"] : void 0,
|
|
101
|
-
member: memberOf(item["member"]),
|
|
102
|
-
managedBy: item["managed_by"] === "idp" ? "idp" : void 0,
|
|
103
|
-
entitlements: Array.isArray(item["entitlements"]) ? item["entitlements"].filter((seat) => typeof seat === "string") : void 0,
|
|
104
|
-
keep: keep === void 0 ? void 0 : asStrings(keep)
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
function memberOf(value) {
|
|
108
|
-
if (value === null || typeof value !== "object" || !Object.hasOwn(value, "group")) return;
|
|
109
|
-
const group = value.group;
|
|
110
|
-
return typeof group === "string" && group !== "" ? { group } : void 0;
|
|
111
|
-
}
|
|
112
268
|
function asStrings(value) {
|
|
113
269
|
return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
114
270
|
}
|
|
@@ -397,265 +553,4 @@ function subjectFromSupabaseSession(session, options = {}) {
|
|
|
397
553
|
}
|
|
398
554
|
}
|
|
399
555
|
//#endregion
|
|
400
|
-
|
|
401
|
-
function callRpc(client, schema, fn, args) {
|
|
402
|
-
return client.schema(schema).rpc(fn, args);
|
|
403
|
-
}
|
|
404
|
-
function strings(value) {
|
|
405
|
-
return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
406
|
-
}
|
|
407
|
-
function grantOf(value) {
|
|
408
|
-
if (!isRecord(value) || typeof value["permission"] !== "string") return;
|
|
409
|
-
return compact({
|
|
410
|
-
permission: value["permission"],
|
|
411
|
-
effect: value["effect"] === "deny" ? "deny" : "allow",
|
|
412
|
-
level: typeof value["level"] === "string" ? value["level"] : void 0
|
|
413
|
-
});
|
|
414
|
-
}
|
|
415
|
-
function customRoleOf(value) {
|
|
416
|
-
if (!isRecord(value) || typeof value["name"] !== "string") return;
|
|
417
|
-
const grants = Array.isArray(value["grants"]) ? value["grants"].flatMap((item) => {
|
|
418
|
-
const grant = grantOf(item);
|
|
419
|
-
return grant === void 0 ? [] : [grant];
|
|
420
|
-
}) : [];
|
|
421
|
-
const includes = strings(value["includes"]);
|
|
422
|
-
const body = {
|
|
423
|
-
name: value["name"],
|
|
424
|
-
grants,
|
|
425
|
-
...includes.length === 0 ? {} : { includes }
|
|
426
|
-
};
|
|
427
|
-
if (value["scope"] === "global") return value["tenant"] === void 0 && value["shared"] === void 0 ? {
|
|
428
|
-
...body,
|
|
429
|
-
scope: "global"
|
|
430
|
-
} : void 0;
|
|
431
|
-
if (value["shared"] === true) return value["tenant"] === void 0 && value["id"] === void 0 ? compact({
|
|
432
|
-
...body,
|
|
433
|
-
shared: true,
|
|
434
|
-
scope: typeof value["scope"] === "string" ? value["scope"] : void 0
|
|
435
|
-
}) : void 0;
|
|
436
|
-
if (typeof value["tenant"] !== "string") return;
|
|
437
|
-
return compact({
|
|
438
|
-
...body,
|
|
439
|
-
tenant: value["tenant"],
|
|
440
|
-
scope: typeof value["scope"] === "string" ? value["scope"] : void 0,
|
|
441
|
-
id: typeof value["id"] === "string" ? value["id"] : void 0
|
|
442
|
-
});
|
|
443
|
-
}
|
|
444
|
-
function readMemberEntries(value) {
|
|
445
|
-
if (!Array.isArray(value)) return [];
|
|
446
|
-
return value.flatMap((item) => {
|
|
447
|
-
if (!isRecord(item) || !isRecord(item["principal"])) return [];
|
|
448
|
-
const id = item["principal"]["id"];
|
|
449
|
-
const [membership] = readMemberships([item["membership"]]).memberships;
|
|
450
|
-
return typeof id === "string" && id !== "" && membership !== void 0 ? [{
|
|
451
|
-
principal: { id },
|
|
452
|
-
membership
|
|
453
|
-
}] : [];
|
|
454
|
-
});
|
|
455
|
-
}
|
|
456
|
-
function versionOf(value) {
|
|
457
|
-
const version = typeof value === "string" ? Number(value) : value;
|
|
458
|
-
return typeof version === "number" && Number.isFinite(version) ? version : void 0;
|
|
459
|
-
}
|
|
460
|
-
/**
|
|
461
|
-
* Reads `subject_for`'s JSON; anything it cannot read is left out, and a
|
|
462
|
-
* malformed record is no record.
|
|
463
|
-
*/
|
|
464
|
-
function readSubjectRecord(value) {
|
|
465
|
-
if (!isRecord(value) || typeof value["id"] !== "string") return;
|
|
466
|
-
if (value["active"] !== true) return {
|
|
467
|
-
id: value["id"],
|
|
468
|
-
active: false,
|
|
469
|
-
roles: [],
|
|
470
|
-
memberships: [],
|
|
471
|
-
customRoles: []
|
|
472
|
-
};
|
|
473
|
-
const version = value["authzVersion"];
|
|
474
|
-
return compact({
|
|
475
|
-
id: value["id"],
|
|
476
|
-
active: true,
|
|
477
|
-
roles: strings(value["roles"]),
|
|
478
|
-
memberships: readMemberships(value["memberships"]).memberships,
|
|
479
|
-
customRoles: Array.isArray(value["customRoles"]) ? value["customRoles"].flatMap((item) => {
|
|
480
|
-
const role = customRoleOf(item);
|
|
481
|
-
return role === void 0 ? [] : [role];
|
|
482
|
-
}) : [],
|
|
483
|
-
authzVersion: typeof version === "number" && Number.isFinite(version) ? version : void 0,
|
|
484
|
-
claims: isRecord(value["claims"]) && Object.keys(value["claims"]).length > 0 ? value["claims"] : void 0
|
|
485
|
-
});
|
|
486
|
-
}
|
|
487
|
-
/**
|
|
488
|
-
* Uncached version reads of one principal closer together than this count as
|
|
489
|
-
* one request reading the version more than once.
|
|
490
|
-
*/
|
|
491
|
-
const REPEAT_WINDOW_MS = 1e3;
|
|
492
|
-
const REPEAT_TRACKED = 1e3;
|
|
493
|
-
/** Read through `globalThis` so the entry loads on runtimes without `process`. */
|
|
494
|
-
function isDevelopment() {
|
|
495
|
-
const proc = Reflect.get(globalThis, "process");
|
|
496
|
-
if (typeof proc !== "object" || proc === null) return false;
|
|
497
|
-
const env = Reflect.get(proc, "env");
|
|
498
|
-
return typeof env === "object" && env !== null && Reflect.get(env, "NODE_ENV") === "development";
|
|
499
|
-
}
|
|
500
|
-
/**
|
|
501
|
-
* In development, warns once when one principal's version is read twice within
|
|
502
|
-
* `REPEAT_WINDOW_MS`: a request that builds its instance more than once instead
|
|
503
|
-
* of sharing it through `instanceCache` or `permdockFor`.
|
|
504
|
-
*/
|
|
505
|
-
function repeatedVersionReads() {
|
|
506
|
-
if (!isDevelopment()) return () => void 0;
|
|
507
|
-
const last = /* @__PURE__ */ new Map();
|
|
508
|
-
let warned = false;
|
|
509
|
-
return (userId) => {
|
|
510
|
-
if (warned) return;
|
|
511
|
-
const at = nowMillis();
|
|
512
|
-
const previous = last.get(userId);
|
|
513
|
-
if (previous !== void 0 && at - previous < REPEAT_WINDOW_MS) {
|
|
514
|
-
warned = true;
|
|
515
|
-
last.clear();
|
|
516
|
-
console.warn("PermDock: the authorization version of one user was read more than once within a second. Share one instance per request through instanceCache and permdockFor, or pass version: { known }.");
|
|
517
|
-
return;
|
|
518
|
-
}
|
|
519
|
-
if (last.size >= REPEAT_TRACKED) last.clear();
|
|
520
|
-
last.set(userId, at);
|
|
521
|
-
};
|
|
522
|
-
}
|
|
523
|
-
/**
|
|
524
|
-
* Membership, custom-role and subject sources over the `subject_for(p_user)`,
|
|
525
|
-
* `authz_version_for(p_user)` and `members_of(p_scope, p_id)` functions
|
|
526
|
-
* `permdock supabase hook generate` writes, for a backend that reaches Postgres
|
|
527
|
-
* only through PostgREST. `memberships.version` reads only the version, so
|
|
528
|
-
* `claimsFirst` with `onStale: 'reread'` reads the full subject only for a
|
|
529
|
-
* stale token; a missing version function throws, and `permdock doctor` PD083
|
|
530
|
-
* reports it. With `policy`, a token that claims a custom role has its subject
|
|
531
|
-
* read in one `subject_for` call instead, and custom roles are read only for a
|
|
532
|
-
* subject that holds one. It keeps no answers: create it once at module scope,
|
|
533
|
-
* and `getPermDock` shares each read within one instance. Pass `claimsFirst(…,
|
|
534
|
-
* { versions })` to share version reads across instances.
|
|
535
|
-
*/
|
|
536
|
-
function postgrestSources(client, options = {}) {
|
|
537
|
-
const api = options.api;
|
|
538
|
-
const names = api === void 0 ? void 0 : hookApiNames(api.prefix);
|
|
539
|
-
const schema = options.schema ?? (api === void 0 ? "permdock" : api.schema ?? "public");
|
|
540
|
-
const fn = options.fn ?? names?.subjectFor ?? "subject_for";
|
|
541
|
-
const membersFn = options.membersFn ?? names?.membersOf ?? "members_of";
|
|
542
|
-
const versionFn = options.versionFn ?? names?.authzVersionFor ?? "authz_version_for";
|
|
543
|
-
const declared = options.policy === void 0 ? void 0 : options.policy.index.declaredRoles;
|
|
544
|
-
const onlyDeclared = (held) => declared !== void 0 && held?.every((name) => declared.has(name)) === true;
|
|
545
|
-
const hook = options.onSourceCall;
|
|
546
|
-
const noteVersionRead = repeatedVersionReads();
|
|
547
|
-
const once = (memo, method, key, read) => {
|
|
548
|
-
let ran = false;
|
|
549
|
-
const started = performance.now();
|
|
550
|
-
const run = () => {
|
|
551
|
-
ran = true;
|
|
552
|
-
return read();
|
|
553
|
-
};
|
|
554
|
-
const answer = memo === void 0 ? run() : memo(key, run);
|
|
555
|
-
if (hook === void 0) return answer;
|
|
556
|
-
return answer.finally(() => {
|
|
557
|
-
try {
|
|
558
|
-
hook({
|
|
559
|
-
source: "postgrest",
|
|
560
|
-
method,
|
|
561
|
-
durationMs: performance.now() - started,
|
|
562
|
-
cached: !ran
|
|
563
|
-
});
|
|
564
|
-
} catch {}
|
|
565
|
-
});
|
|
566
|
-
};
|
|
567
|
-
const members = async (query) => {
|
|
568
|
-
const result = await callRpc(client, schema, membersFn, {
|
|
569
|
-
p_scope: query.scope,
|
|
570
|
-
p_id: query.id
|
|
571
|
-
});
|
|
572
|
-
if (result.error !== null) throw new Error(`PermDock: ${schema}.${membersFn} failed: ${result.error.message}`);
|
|
573
|
-
return readMemberEntries(result.data);
|
|
574
|
-
};
|
|
575
|
-
const list = (query) => once(void 0, `${schema}.${membersFn}`, "", () => members(query));
|
|
576
|
-
const record = (userId, memo) => once(memo, `${schema}.${fn}`, `${schema}.${fn}:${userId}`, async () => {
|
|
577
|
-
const result = await callRpc(client, schema, fn, { p_user: userId });
|
|
578
|
-
if (result.error !== null) throw new Error(`PermDock: ${schema}.${fn} failed: ${result.error.message}`);
|
|
579
|
-
return readSubjectRecord(result.data);
|
|
580
|
-
});
|
|
581
|
-
const version = (userId, memo) => once(memo, `${schema}.${versionFn}`, `${schema}.${versionFn}:${userId}`, async () => {
|
|
582
|
-
noteVersionRead(userId);
|
|
583
|
-
const result = await callRpc(client, schema, versionFn, { p_user: userId });
|
|
584
|
-
if (result.error !== null) throw new Error(`PermDock: ${schema}.${versionFn} failed: ${result.error.message}`);
|
|
585
|
-
return versionOf(result.data);
|
|
586
|
-
});
|
|
587
|
-
const live = async (userId, memo) => {
|
|
588
|
-
const found = await record(userId, memo);
|
|
589
|
-
return found?.active === true ? found : void 0;
|
|
590
|
-
};
|
|
591
|
-
return {
|
|
592
|
-
memberships: {
|
|
593
|
-
async membershipsFor(principal, query) {
|
|
594
|
-
return [...(await live(principal.id, query.memo))?.memberships ?? []];
|
|
595
|
-
},
|
|
596
|
-
version(principal, context) {
|
|
597
|
-
return declared !== void 0 && !onlyDeclared([...principal.roles ?? [], ...(principal.memberships ?? []).flatMap((membership) => membership.roles)]) ? record(principal.id, context?.memo).then((found) => found?.authzVersion) : version(principal.id, context?.memo);
|
|
598
|
-
},
|
|
599
|
-
list,
|
|
600
|
-
async globalRolesFor(principal, context) {
|
|
601
|
-
return [...(await live(principal.id, context?.memo))?.roles ?? []];
|
|
602
|
-
}
|
|
603
|
-
},
|
|
604
|
-
customRoles(principal) {
|
|
605
|
-
const held = async (context, keep) => onlyDeclared(context?.held) ? [] : ((await live(principal.id, context?.memo))?.customRoles ?? []).filter(keep);
|
|
606
|
-
return {
|
|
607
|
-
rolesFor: (tenant, context) => held(context, (role) => role.tenant === tenant),
|
|
608
|
-
globalRoles: (context) => held(context, (role) => role.scope === "global"),
|
|
609
|
-
sharedRoles: (context) => held(context, (role) => role.shared === true)
|
|
610
|
-
};
|
|
611
|
-
},
|
|
612
|
-
async subject(userId) {
|
|
613
|
-
const found = await live(userId);
|
|
614
|
-
if (found === void 0) return {
|
|
615
|
-
principal: null,
|
|
616
|
-
context: {}
|
|
617
|
-
};
|
|
618
|
-
return {
|
|
619
|
-
principal: compact({
|
|
620
|
-
id: found.id,
|
|
621
|
-
roles: found.roles,
|
|
622
|
-
memberships: found.memberships,
|
|
623
|
-
authzVersion: found.authzVersion,
|
|
624
|
-
claims: found.claims
|
|
625
|
-
}),
|
|
626
|
-
context: {}
|
|
627
|
-
};
|
|
628
|
-
},
|
|
629
|
-
async refresh(subject) {
|
|
630
|
-
const current = subject.principal;
|
|
631
|
-
if (current === null) return subject;
|
|
632
|
-
const found = await live(current.id);
|
|
633
|
-
if (found === void 0) {
|
|
634
|
-
const { stale: _stale, ...kept } = subject;
|
|
635
|
-
return {
|
|
636
|
-
...kept,
|
|
637
|
-
principal: null
|
|
638
|
-
};
|
|
639
|
-
}
|
|
640
|
-
const { membershipsTruncated: _truncated, ...rest } = current;
|
|
641
|
-
const { stale: _stale, ...kept } = subject;
|
|
642
|
-
const principal = compact({
|
|
643
|
-
...rest,
|
|
644
|
-
roles: found.roles,
|
|
645
|
-
memberships: found.memberships,
|
|
646
|
-
authzVersion: found.authzVersion,
|
|
647
|
-
claims: found.claims === void 0 ? rest["claims"] : {
|
|
648
|
-
...isRecord(rest["claims"]) ? rest["claims"] : {},
|
|
649
|
-
...found.claims
|
|
650
|
-
}
|
|
651
|
-
});
|
|
652
|
-
return {
|
|
653
|
-
...kept,
|
|
654
|
-
principal
|
|
655
|
-
};
|
|
656
|
-
},
|
|
657
|
-
record: (userId) => record(userId)
|
|
658
|
-
};
|
|
659
|
-
}
|
|
660
|
-
//#endregion
|
|
661
|
-
export { delegationOf as a, subjectFromSupabaseSession as c, actorOf as i, postgrestSources as n, readMemberships as o, readSubjectRecord as r, subjectFromSupabase as s, callRpc as t };
|
|
556
|
+
export { callRpc as a, subjectFromSupabaseSession as i, delegationOf as n, postgrestSources as o, subjectFromSupabase as r, actorOf as t };
|