permdock 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/a2a/index.d.ts +7 -5
- package/dist/a2a/index.js +14 -21
- package/dist/ai-sdk/index.d.ts +18 -6
- package/dist/ai-sdk/index.js +8 -5
- package/dist/app-data-CV8pqqMi.js +59 -0
- package/dist/approvals/index.d.ts +2 -2
- package/dist/approvals/index.js +3 -3
- package/dist/{approvals-DbYAuNkG.js → approvals-DZL76lKW.js} +35 -19
- package/dist/{approvers-DT4AVyIg.js → approvers-CqPOLD-o.js} +1 -1
- package/dist/{arazzo-BAgw9ap6.js → arazzo-C4BcskbX.js} +6 -5
- package/dist/{arazzo-CKwwqFWz.js → arazzo-CD8d0WLb.js} +2 -2
- package/dist/authzen/index.d.ts +3 -3
- package/dist/authzen/index.js +161 -23
- package/dist/better-auth/index.d.ts +2 -2
- package/dist/better-auth/index.js +6 -19
- package/dist/better-supabase/index.d.ts +112 -87
- package/dist/better-supabase/index.js +257 -156
- package/dist/{bind-C_ob3LKa.d.ts → bind-BzqG8SMb.d.ts} +16 -5
- package/dist/{bind-CuzGytRf.js → bind-kk-uyCwH.js} +14 -6
- package/dist/build-instance-DIIV9DbC.js +51 -0
- package/dist/{canonical-json-DemiK4Vp.js → canonical-json-CFKyFOke.js} +1 -3
- package/dist/{capability-2kYTMWDv.d.ts → capability-CksyCWDH.d.ts} +2 -2
- package/dist/{capability-4qPdO9gk.js → capability-txATtKV4.js} +3 -2
- package/dist/catalog/index.d.ts +1 -1
- package/dist/catalog/index.js +1 -1
- package/dist/catalog-6yWAX6Ps.js +2 -0
- package/dist/{catalog-dFZdWCGN.js → catalog-WHG4kBq7.js} +2 -2
- package/dist/{catalog-doc-DdGm82XT.js → catalog-doc-DWtg0gGR.js} +17 -10
- package/dist/{catalog-DWF5cYqB.js → catalog-tZUyOfOv.js} +4 -4
- package/dist/claude-agent/index.d.ts +4 -4
- package/dist/claude-agent/index.js +4 -5
- package/dist/clerk/index.d.ts +3 -3
- package/dist/clerk/index.js +8 -33
- package/dist/cli/bin.js +1 -1
- package/dist/cli/index.d.ts +3 -3
- package/dist/cli/index.js +3 -3
- package/dist/cloud/index.d.ts +4 -4
- package/dist/cloud/index.js +9 -15
- package/dist/{cloud-CB_ELYuX.js → cloud-C7bSDgX4.js} +2 -2
- package/dist/{cloud-DWLXO2af.js → cloud-PeBN3IEn.js} +5 -5
- package/dist/{collect-DSTE3ml9.js → collect-2SrB7lfk.js} +6 -8
- package/dist/collect-Bw2Jdq1q.js +2 -0
- package/dist/{collect-DClJsheJ.js → collect-CQx4hX4N.js} +3 -3
- package/dist/{commands-DSxCqG9A.js → commands-Cpip4ULx.js} +13 -13
- package/dist/{compact-y6vfu2_f.js → compact-CAf557ZB.js} +11 -1
- package/dist/compile/index.d.ts +1 -1
- package/dist/compile/index.js +1 -1
- package/dist/{compile-Ba4blROR.js → compile-CcEu2ZQ1.js} +6 -5
- package/dist/{compile-BkRyBDBw.d.ts → compile-CtTP7eur.d.ts} +2 -2
- package/dist/{config-BJiM-xAm.js → config-BIjREpyE.js} +4 -4
- package/dist/{config-Dnszbv-6.js → config-DLt6BvV7.js} +2 -2
- package/dist/{config-report-DMvWKUxL.js → config-report--Xb9APJS.js} +5 -6
- package/dist/{connection-CU8MQxRi.js → connection-DUsczpB5.js} +3 -2
- package/dist/constants-DcJABbLW.js +20 -0
- package/dist/{context-Bcy85rGi.js → context-DieZVJXu.js} +16 -5
- package/dist/convex/index.d.ts +4 -4
- package/dist/convex/index.js +14 -16
- package/dist/create-BBO24vj6.js +324 -0
- package/dist/{credential-8P81ff4u.js → credential-kue0qpbm.js} +4 -4
- package/dist/deciding-columns-Sq12mEA6.js +123 -0
- package/dist/delegation-input-FTxMK3ji.js +19 -0
- package/dist/denied-text-DfRk15uw.d.ts +19 -0
- package/dist/{describe-DMYiCjJV.d.ts → describe-C3ldA9os.d.ts} +11 -2
- package/dist/{describe-B_gVZEVi.js → describe-Cgkp7eP0.js} +5 -4
- package/dist/{diff-DBIhz_f2.js → diff-Cnghh_Ip.js} +2 -2
- package/dist/{diff-2VaeChzX.js → diff-rpqoe7Ag.js} +9 -9
- package/dist/{doctor-BwCAMLx_.js → doctor-CuVJvhV_.js} +2 -2
- package/dist/doctor-owlv6ddh.js +2166 -0
- package/dist/drizzle/index.d.ts +2 -2
- package/dist/drizzle/index.js +6 -14
- package/dist/elysia/index.d.ts +4 -4
- package/dist/elysia/index.js +7 -7
- package/dist/{errors-DPdqI50v.d.ts → errors-OD_4c__H.d.ts} +2 -2
- package/dist/{errors-Cz5zn0mW.js → errors-drnfxYtm.js} +3 -3
- package/dist/{evaluations-tz6D9A2G.js → evaluations-C9YJsv3H.js} +45 -7
- package/dist/eve/index.d.ts +5 -5
- package/dist/eve/index.js +5 -5
- package/dist/express/index.d.ts +4 -4
- package/dist/express/index.js +8 -7
- package/dist/fastify/index.d.ts +15 -5
- package/dist/fastify/index.js +9 -29
- package/dist/fields-fwfXN01n.js +1016 -0
- package/dist/{files-DWUN9PzI.js → files-D_JIzUrP.js} +12 -3
- package/dist/{fixtures-ht28Cplr.js → fixtures-h2eG2OZV.js} +5 -6
- package/dist/{from-snapshot-CTLijvdm.js → from-snapshot-7REQZe0H.js} +32 -22
- package/dist/{generate-CH7ThJ14.js → generate-CNU1pIOo.js} +1 -3
- package/dist/grantee-CXY-0C87.js +254 -0
- package/dist/grantee-conditions-MQs5NIuX.js +270 -0
- package/dist/grantee-match-fxYp9Nmt.js +141 -0
- package/dist/{helpers-H_KARDVC.js → helpers-C9YmyBIa.js} +7 -6
- package/dist/hono/index.d.ts +4 -4
- package/dist/hono/index.js +8 -8
- package/dist/hosted-CBHgkzDl.js +655 -0
- package/dist/{http-SO7qGttf.js → http-BBoKefeS.js} +35 -2
- package/dist/{http-BIhmLfCc.js → http-BEbdMZ05.js} +2 -24
- package/dist/{rls-import-BTFVk3jH.js → import-BFIlhetD.js} +86 -80
- package/dist/{openapi-import-cmwetbzw.js → import-UHk1N7vH.js} +6 -7
- package/dist/{index-C8z4RjQV.d.ts → index-BwMe94Xq.d.ts} +1 -1
- package/dist/{index-0nNqHspG.d.ts → index-DgM7w96K.d.ts} +2 -2
- package/dist/{index-C7Tw7MaW.d.ts → index-Dz7didpC.d.ts} +3 -3
- package/dist/{index-BNc7Wer_.d.ts → index-UdVQgq48.d.ts} +105 -38
- package/dist/index.d.ts +15 -13
- package/dist/index.js +22 -22
- package/dist/{instance-options-jARdwfPN.d.ts → instance-options-plkrsAog.d.ts} +1 -1
- package/dist/{json-schema-BsAflUGW.js → json-schema-DBkdUuCO.js} +1 -3
- package/dist/jwt/index.d.ts +4 -4
- package/dist/jwt/index.js +13 -13
- package/dist/{kernel-_RRHmnMY.js → kernel-CB3LrIJM.js} +81 -32
- package/dist/kysely/index.d.ts +2 -2
- package/dist/kysely/index.js +6 -14
- package/dist/{live-options-H2eG8dfJ.js → live-options-BaAFCIiu.js} +16 -3
- package/dist/load-B_shHrmd.js +2 -0
- package/dist/{load-DhWEB9P1.js → load-C3_oTHyO.js} +11 -3
- package/dist/{manifest-iaoBXHKc.js → manifest-BngWKryL.js} +5 -18
- package/dist/{map-claims-Z4QZOiFF.js → map-claims-AVlBaJoa.js} +7 -16
- package/dist/{map-error-pgUWNNtG.js → map-error-BE27PYkE.js} +5 -5
- package/dist/{markers-B0hYLvMD.js → markers-CiwAOZtO.js} +6 -2
- package/dist/{may-use-DndQ5tQ-.js → may-use-BOn_dR_w.js} +4 -3
- package/dist/mcp/index.d.ts +26 -9
- package/dist/mcp/index.js +456 -446
- package/dist/{rls-migrate-CN4TlJTO.js → migrate-BwlB5-Wk.js} +75 -15
- package/dist/nest/index.d.ts +4 -4
- package/dist/nest/index.js +11 -12
- package/dist/next/index.d.ts +31 -8
- package/dist/next/index.js +29 -33
- package/dist/next/plugin.d.ts +1 -1
- package/dist/next/plugin.js +1 -1
- package/dist/node/index.d.ts +4 -4
- package/dist/node/index.js +4 -4
- package/dist/ocsf-uYFXGVw2.js +115 -0
- package/dist/openai/index.d.ts +5 -5
- package/dist/openai/index.js +4 -4
- package/dist/openapi/index.d.ts +3 -3
- package/dist/openapi/index.js +1 -1
- package/dist/{openapi-CqqEbHsL.js → openapi-BJdBmYDG.js} +19 -23
- package/dist/{openapi-BqRBvAng.js → openapi-DBzHQbov.js} +2 -5
- package/dist/{openapi-l0xYHkcv.js → openapi-DcQ1Kg40.js} +3 -3
- package/dist/orpc/index.d.ts +5 -5
- package/dist/orpc/index.js +9 -11
- package/dist/otel/index.d.ts +2 -2
- package/dist/otel/index.js +26 -23
- package/dist/output-files-CgIsvdSa.js +140 -0
- package/dist/{rls-ownership-RuFqaqGz.js → ownership-BgnbOJFT.js} +387 -379
- package/dist/{package-root-zGkxO3oN.js → package-root-DtNnpmUd.js} +3 -2
- package/dist/{parse-BuyjxhZV.js → parse-CVFQHk6c.js} +3 -3
- package/dist/{parse-local-manifest-BrMozJCo.js → parse-local-manifest-C-q02Pal.js} +2 -4
- package/dist/{parse-local-manifest-JLnaBH0S.d.ts → parse-local-manifest-DvYUR0QL.d.ts} +1 -1
- package/dist/pdp/index.d.ts +2 -2
- package/dist/pdp/index.js +8 -9
- package/dist/{permdock-CbgvLnuo.js → permdock-L26udHSk.js} +1387 -1220
- package/dist/{rls-fields-74oZPXWL.js → permission-keys-B26jeyUv.js} +1289 -2066
- package/dist/permission-registry-BsblpB-z.js +385 -0
- package/dist/{permissions-DttnqqxC.d.ts → permission-types-Dg39z9Kv.d.ts} +59 -31
- package/dist/{permissions-RJrovw98.js → permissions-CCJ6lmxB.js} +3 -3
- package/dist/{permissions-CDgvKG5L.d.ts → permissions-COH-KRgT.d.ts} +2 -2
- package/dist/{policy-IB6yxpC3.d.ts → policy-types-sp9P1iIV.d.ts} +661 -582
- package/dist/{policy-D2W7uv19.d.ts → policy-ur0BBK_e.d.ts} +2 -2
- package/dist/{powersync-DliZK_-y.js → powersync-BFSbSElQ.js} +2 -2
- package/dist/powersync-DCDgZgfZ.js +2 -0
- package/dist/{powersync-BylawD_U.js → powersync-cZe4kzhL.js} +26 -27
- package/dist/prisma/index.d.ts +1 -1
- package/dist/prisma/index.js +6 -12
- package/dist/{problem-B43ztKIm.js → problem-CnWraVhC.js} +8 -7
- package/dist/{problem-details-_AMOYz-w.js → problem-details-DECUnXAn.js} +2 -2
- package/dist/{problem-details-DX075l9V.d.ts → problem-details-rIIo8B2C.d.ts} +1 -1
- package/dist/{protected-BdnIEFkY.d.ts → protected-B3_P7xuw.d.ts} +9 -6
- package/dist/{protected-utU-SLuy.js → protected-BN7BUdY1.js} +20 -8
- package/dist/{provider-CSQd7m92.js → provider-Bi-0HNL3.js} +23 -10
- package/dist/{provider-DZY281jO.d.ts → provider-kwHC9CZD.d.ts} +1 -1
- package/dist/{provider-store-Cfbvo4DE.js → provider-store-Ctt-81Ni.js} +6 -3
- package/dist/react/index.d.ts +7 -7
- package/dist/react/index.js +5 -5
- package/dist/react/provider-client.d.ts +1 -1
- package/dist/react/provider-client.js +1 -1
- package/dist/react-native/index.d.ts +20 -11
- package/dist/react-native/index.js +33 -17
- package/dist/{refs-KYb4ntaz.js → refs-f3imMjNW.js} +1 -1
- package/dist/relation-walk-BXnlLtg2.js +186 -0
- package/dist/relations-CvmSpG67.js +163 -0
- package/dist/{replay-CYyiLiwO.d.ts → replay-COpmZUfx.d.ts} +1 -1
- package/dist/request-context-BVM7aWNs.js +71 -0
- package/dist/request-context-C2_1lchh.d.ts +5 -0
- package/dist/resource-relations-D1Un3pcz.js +243 -0
- package/dist/retire-BFcxL6un.js +240 -0
- package/dist/{rls-B4ur8nKQ.js → rls-55DQTuf5.js} +14 -2
- package/dist/{rls-DQtdgTHB.js → rls-BEktUaqg.js} +884 -484
- package/dist/{policy-xyWg7QdR.js → role-builder-B4GbKM-i.js} +235 -541
- package/dist/{rpc-DL9Sqvb1.js → rpc-nYC3cR_u.js} +15 -5
- package/dist/{run-DKDbM4Du.js → run-DMcNW_8T.js} +3 -3
- package/dist/{runtime-CB8gQFvS.js → runtime-D_tMXnsq.js} +1 -1
- package/dist/{saas-DhpJjnBA.js → saas-DtaA4JuW.js} +9 -8
- package/dist/{openapi-schema--ARjyfQr.js → schema-Bol6gqXA.js} +3 -5
- package/dist/{schema-D3MnDMxa.js → schema-DjQBcAP9.js} +4 -2
- package/dist/scim/index.d.ts +1 -1
- package/dist/scim/index.js +1 -1
- package/dist/{scim-BFGBBAqR.js → scim-vFR1O5oG.js} +6 -12
- package/dist/{scopes-CVdPrWN-.js → scopes-tvpa34ep.js} +10 -2
- package/dist/server/index.d.ts +18 -8
- package/dist/server/index.js +8 -8
- package/dist/{server-DlZ28Oz5.js → server-ZYEHtNHS.js} +4 -4
- package/dist/{create-B1d519XK.d.ts → server-types-DdqBwZN_.d.ts} +69 -33
- package/dist/shared-1uhI-e-b.js +294 -0
- package/dist/{shared-DRu8VFVM.js → shared-JhMeOsDF.js} +1 -1
- package/dist/{sink-Bd9PSyfq.js → sink-BTtmfPnE.js} +1 -1
- package/dist/{sink-B1fZzIMf.d.ts → sink-CPN4zLfs.d.ts} +1 -1
- package/dist/{skills-Biq5uup3.js → skills-BZdRQkxs.js} +4 -3
- package/dist/{skills-Bx-U0irG.js → skills-Dle4ZoLF.js} +2 -2
- package/dist/{snapshot-Enxd0n-s.js → snapshot-Dc9CHPME.js} +116 -13
- package/dist/{snapshot-cache-D6jLelln.js → snapshot-cache-Cod40D-X.js} +1 -1
- package/dist/{snapshot-cache-B-LxUahj.d.ts → snapshot-cache-J5T7t_vD.d.ts} +1 -1
- package/dist/solid/index.d.ts +22 -22
- package/dist/solid/index.js +40 -10
- package/dist/{sources-4p0-4xQm.js → sources-B1-b-R0t.js} +25 -26
- package/dist/{sources-BdOYLw9j.d.ts → sources-Dljy06zL.d.ts} +6 -2
- package/dist/{sql-xdg5f4Fi.js → sql-t8teWOfo.js} +19 -3
- package/dist/{src-BDwEZWrZ.js → src-Bb7no-hS.js} +194 -123
- package/dist/ssf/index.d.ts +3 -3
- package/dist/ssf/index.js +58 -61
- package/dist/store-9KO4BlkB.d.ts +147 -0
- package/dist/{store-DMAWwAJV.js → store-ILkLUj_o.js} +4 -4
- package/dist/{store-options-ByhZq1jV.js → store-options-CbUHDoSe.js} +16 -7
- package/dist/{stores-BT2pSCub.js → stores-BHXdSbw9.js} +7 -3
- package/dist/stores-Cxz_80g-.d.ts +31 -0
- package/dist/{stream-DDpvynSB.js → stream-BMui98KK.js} +2 -1
- package/dist/{stream-D1RXubw2.d.ts → stream-Dwsg6WwE.d.ts} +2 -2
- package/dist/{subject-settings-BwBmCdTR.js → subject-settings-CkEwrw3W.js} +23 -5
- package/dist/supabase/index.d.ts +4 -4
- package/dist/supabase/index.js +3 -3
- package/dist/supabase/middleware.d.ts +11 -5
- package/dist/supabase/middleware.js +10 -7
- package/dist/{supabase-C0qESOa-.js → supabase-C1TWlnYt.js} +36 -52
- package/dist/{supabase-Boqb9a_Y.js → supabase-Dbqr141s.js} +2 -2
- package/dist/supabase-hook-BULg7Ut_.js +2 -0
- package/dist/{supabase-hook-CSLQ4zJ3.js → supabase-hook-Cva3ikXz.js} +731 -782
- package/dist/{supautils-Cn4R4cJ4.js → supautils-B6HYL9eL.js} +2 -2
- package/dist/svelte/Protected.svelte +9 -2
- package/dist/svelte/index.d.ts +6 -6
- package/dist/svelte/index.js +25 -11
- package/dist/svelte/runtime.d.ts +10 -3
- package/dist/svelte/runtime.js +4 -3
- package/dist/svelte/source.d.ts +6 -6
- package/dist/svelte/source.js +4 -4
- package/dist/{validity-uOp8UpYn.js → tenancy-DshjqY0n.js} +3 -39
- package/dist/terminal/index.d.ts +5 -5
- package/dist/terminal/index.js +18 -34
- package/dist/testing/index.d.ts +89 -77
- package/dist/testing/index.js +1276 -1262
- package/dist/testing/saas/index.d.ts +4 -4
- package/dist/testing/saas/index.js +2 -2
- package/dist/testing/saas/permissions.d.ts +1 -1
- package/dist/testing/saas/permissions.js +1 -1
- package/dist/thenable-QSmvt-vZ.js +65 -0
- package/dist/{token-CIWxJOCh.js → token-Bx9qy30p.js} +1 -1
- package/dist/tool-refusal-CQ7OEia9.js +41 -0
- package/dist/trpc/index.d.ts +5 -5
- package/dist/trpc/index.js +7 -8
- package/dist/{types-DbjRN55U.d.ts → types-7rJVLWe5.d.ts} +82 -4
- package/dist/{types-aqOHTHcp.d.ts → types-Br9IXUBG.d.ts} +1 -1
- package/dist/types-ByUo56un.d.ts +88 -0
- package/dist/{types-Cq_H8N_X.d.ts → types-C0dee0Qf.d.ts} +2 -2
- package/dist/{types-DxiCGmmd.d.ts → types-CIlTojhq.d.ts} +2 -2
- package/dist/{types-QCuYJh4q.d.ts → types-CUcFZfpU.d.ts} +1 -1
- package/dist/{types-C97IskBw.d.ts → types-CqrjB9o6.d.ts} +1 -1
- package/dist/{types-BnIEz1sU.d.ts → types-DHrmBJLH.d.ts} +24 -6
- package/dist/{types-Dnemwd77.d.ts → types-DpWfQdSh.d.ts} +5 -1
- package/dist/{types-Bvc4oWT6.d.ts → types-DvupZE0w.d.ts} +1 -1
- package/dist/unplugin/index.d.ts +1 -1
- package/dist/unplugin/index.js +1 -1
- package/dist/{usage-GTixvDDU.js → usage-4G6t643F.js} +2 -2
- package/dist/{usage-ItS7nLcl.js → usage-CG9nOYZw.js} +7 -7
- package/dist/usage-iFLJ0-rr.js +2 -0
- package/dist/{validation-error-Ba264OaJ.d.ts → validation-error-BSSw0l_8.d.ts} +1 -1
- package/dist/{validation-error-CnjZ4t92.js → validation-error-ZfUHbKvf.js} +1 -1
- package/dist/validity-dVrUEPJt.js +62 -0
- package/dist/{verifier-BxBo6I44.js → verifier-DMr_Zmb_.js} +51 -15
- package/dist/{rls-verify-CVQTHTh5.js → verify-BztUB3GX.js} +668 -239
- package/dist/{version-BvacVTZR.js → version-BEogC-rB.js} +1 -1
- package/dist/{views-Soe7bGSC.js → views-CJsrBS1f.js} +23 -1
- package/dist/{vocabulary-DA8a8zif.d.ts → vocabulary-hhEFLFoL.d.ts} +15 -6
- package/dist/vue/index.d.ts +24 -19
- package/dist/vue/index.js +24 -8
- package/dist/watch-C8TpsAl4.js +2 -0
- package/dist/{watch-DVBJ9cBq.js → watch-zeucB7eF.js} +6 -6
- package/dist/webmcp/index.d.ts +2 -2
- package/dist/webmcp/index.js +13 -37
- package/dist/wrap-Cr93qqdP.d.ts +14 -0
- package/dist/wrap-DWsU_5Bd.js +26 -0
- package/package.json +8 -8
- package/schemas/catalog-v1.json +6 -0
- package/skills/permdock-credentials/SKILL.md +1 -1
- package/skills/permdock-credentials/references/tokens-keys-links.md +7 -2
- package/skills/permdock-data/references/queries-and-rls.md +4 -0
- package/skills/permdock-tenancy/references/ownership-and-custom-roles.md +1 -0
- package/skills/permdock-wire/SKILL.md +2 -2
- package/skills/permdock-wire/references/adapters.md +9 -1
- package/skills/permdock-wire/references/policy-options.md +10 -1
- package/dist/catalog-CRW5Mx_B.js +0 -2
- package/dist/collect-DSWOk19R.js +0 -2
- package/dist/create-CMwIl-w2.js +0 -253
- package/dist/delegation-D8pUEuce.js +0 -103
- package/dist/doctor-collect-CHk6XWOA.js +0 -665
- package/dist/doctor-igIiM_Hl.js +0 -1194
- package/dist/evaluation-items-CfCCejQd.js +0 -40
- package/dist/fields-BMl1RxoX.js +0 -26
- package/dist/grantee-Cv5Sogfv.js +0 -602
- package/dist/hosted-DJQw46hn.js +0 -266
- package/dist/instance-options-Dhhcnm3y.js +0 -22
- package/dist/load-DwJUafYN.js +0 -2
- package/dist/map-AcxK9o_D.js +0 -147
- package/dist/permissions-DVoF6dMt.js +0 -662
- package/dist/powersync-e_AZrKbg.js +0 -2
- package/dist/protected-xAr24FEC.d.ts +0 -40
- package/dist/relations-cjOL01hZ.js +0 -505
- package/dist/rls-graph-CHwx0V8q.js +0 -435
- package/dist/rls-shared-Cewd_-zI.js +0 -495
- package/dist/store-jOBYpiXC.d.ts +0 -36
- package/dist/stores-C0IMQrGI.d.ts +0 -52
- package/dist/supabase-config-BpPXt3x1.js +0 -472
- package/dist/supabase-hook-6sYLXg_u.js +0 -2
- package/dist/thenable-okc2xDsj.js +0 -10
- package/dist/types-CKNSyIf_.d.ts +0 -52
- package/dist/usage-DorAJiU_.js +0 -2
- package/dist/watch-BwxLTYMZ.js +0 -2
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { _ as listPermissions, a as formerKeys, o as formerScopes } from "./permissions-DVoF6dMt.js";
|
|
2
|
-
//#region src/server/evaluation-items.ts
|
|
3
|
-
function firstWins(map, name, leaf) {
|
|
4
|
-
if (!map.has(name)) map.set(name, leaf);
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Indexes `tree` once. The lookup tries `action` as a permission key or
|
|
8
|
-
* scope, then `<resource.type>.<action>`, then the leaf with that resource
|
|
9
|
-
* and action; current names win over former ones and earlier leaves over
|
|
10
|
-
* later ones. Anything else is `undefined`, which the caller denies.
|
|
11
|
-
*/
|
|
12
|
-
function permissionLookup(tree) {
|
|
13
|
-
const current = /* @__PURE__ */ new Map();
|
|
14
|
-
const former = /* @__PURE__ */ new Map();
|
|
15
|
-
const byPair = /* @__PURE__ */ new Map();
|
|
16
|
-
for (const leaf of listPermissions(tree)) {
|
|
17
|
-
firstWins(current, leaf.key, leaf);
|
|
18
|
-
firstWins(current, leaf.scope, leaf);
|
|
19
|
-
for (const name of [...formerKeys(leaf), ...formerScopes(leaf)]) firstWins(former, name, leaf);
|
|
20
|
-
firstWins(byPair, `${leaf.resource}\u0000${leaf.action}`, leaf);
|
|
21
|
-
}
|
|
22
|
-
const named = (name) => current.get(name) ?? former.get(name);
|
|
23
|
-
return (action, resource) => {
|
|
24
|
-
if (action === void 0) return;
|
|
25
|
-
const byKey = named(action);
|
|
26
|
-
if (byKey !== void 0) return byKey;
|
|
27
|
-
const type = typeof resource?.type === "string" ? resource.type : void 0;
|
|
28
|
-
if (type === void 0) return;
|
|
29
|
-
return named(`${type}.${action}`) ?? byPair.get(`${type}\u0000${action}`);
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
/** The row an item's resource describes: its `properties`, else `{ id }`. */
|
|
33
|
-
function itemResourceData(resource) {
|
|
34
|
-
const properties = resource?.properties;
|
|
35
|
-
if (properties !== null && typeof properties === "object") return properties;
|
|
36
|
-
const id = resource?.id;
|
|
37
|
-
if (typeof id === "string" || typeof id === "number") return { id: String(id) };
|
|
38
|
-
}
|
|
39
|
-
//#endregion
|
|
40
|
-
export { permissionLookup as n, itemResourceData as t };
|
package/dist/fields-BMl1RxoX.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { n as freezeDeep } from "./freeze-CrU8nQeX.js";
|
|
2
|
-
import { D as ownKeys, E as ownGet, T as isForbiddenKey } from "./permissions-DVoF6dMt.js";
|
|
3
|
-
//#region src/core/fields.ts
|
|
4
|
-
function sanitizeFields(fields) {
|
|
5
|
-
if (fields === void 0) return;
|
|
6
|
-
return fields.filter((field) => field.length > 0 && !isForbiddenKey(field));
|
|
7
|
-
}
|
|
8
|
-
function grantCoversField(fields, field, effect) {
|
|
9
|
-
if (fields === void 0) return true;
|
|
10
|
-
if (fields.length === 0) return false;
|
|
11
|
-
if (field === void 0) return effect === "allow";
|
|
12
|
-
return fields.includes(field);
|
|
13
|
-
}
|
|
14
|
-
function pickVisible(row, canField) {
|
|
15
|
-
const out = {};
|
|
16
|
-
for (const key of ownKeys(row)) if (canField(key)) out[key] = ownGet(row, key);
|
|
17
|
-
return freezeDeep(out);
|
|
18
|
-
}
|
|
19
|
-
function sanitizeContext(value) {
|
|
20
|
-
if (value === null || typeof value !== "object" || Array.isArray(value)) return {};
|
|
21
|
-
const out = {};
|
|
22
|
-
for (const key of ownKeys(value)) out[key] = ownGet(value, key);
|
|
23
|
-
return out;
|
|
24
|
-
}
|
|
25
|
-
//#endregion
|
|
26
|
-
export { sanitizeFields as i, pickVisible as n, sanitizeContext as r, grantCoversField as t };
|
package/dist/grantee-Cv5Sogfv.js
DELETED
|
@@ -1,602 +0,0 @@
|
|
|
1
|
-
import { r as sole, t as compact } from "./compact-y6vfu2_f.js";
|
|
2
|
-
import { n as freezeDeep } from "./freeze-CrU8nQeX.js";
|
|
3
|
-
import { C as restrictedStops, D as ownKeys, S as restrictedFor, T as isForbiddenKey, _ as listPermissions, d as isEdgeRelation, f as isFieldRelation, g as isSelfParented, m as isPrincipalRelation, p as isPermission, r as expandRelation, u as isComputedRelation, w as assertSafeKey } from "./permissions-DVoF6dMt.js";
|
|
4
|
-
import { c as rootScope, d as scopeList, o as resolveScope, t as activeFor } from "./scopes-CVdPrWN-.js";
|
|
5
|
-
//#region src/core/vocabulary.ts
|
|
6
|
-
const ROLE_KIND = "role";
|
|
7
|
-
const PLAN_KIND = "plan";
|
|
8
|
-
function makeRole(key, init) {
|
|
9
|
-
assertSafeKey(key, "role");
|
|
10
|
-
const on = init.on;
|
|
11
|
-
const leaf = {
|
|
12
|
-
key,
|
|
13
|
-
assignable: init.assignable ?? on !== void 0,
|
|
14
|
-
meta: freezeDeep({ ...init.meta })
|
|
15
|
-
};
|
|
16
|
-
if (on !== void 0) Object.assign(leaf, { on });
|
|
17
|
-
Object.defineProperty(leaf, "kind", {
|
|
18
|
-
value: ROLE_KIND,
|
|
19
|
-
enumerable: false,
|
|
20
|
-
writable: false,
|
|
21
|
-
configurable: false
|
|
22
|
-
});
|
|
23
|
-
return Object.freeze(leaf);
|
|
24
|
-
}
|
|
25
|
-
function makePlan(key, init) {
|
|
26
|
-
assertSafeKey(key, "plan");
|
|
27
|
-
const leaf = {
|
|
28
|
-
key,
|
|
29
|
-
meta: freezeDeep({ ...init.meta })
|
|
30
|
-
};
|
|
31
|
-
Object.defineProperty(leaf, "kind", {
|
|
32
|
-
value: PLAN_KIND,
|
|
33
|
-
enumerable: false,
|
|
34
|
-
writable: false,
|
|
35
|
-
configurable: false
|
|
36
|
-
});
|
|
37
|
-
return Object.freeze(leaf);
|
|
38
|
-
}
|
|
39
|
-
function isRole(value) {
|
|
40
|
-
return value !== null && typeof value === "object" && "key" in value && typeof value.key === "string" && value.kind === "role";
|
|
41
|
-
}
|
|
42
|
-
function isPlan(value) {
|
|
43
|
-
return value !== null && typeof value === "object" && "key" in value && typeof value.key === "string" && value.kind === "plan";
|
|
44
|
-
}
|
|
45
|
-
function defineRoles(input) {
|
|
46
|
-
const tree = {};
|
|
47
|
-
for (const key of Object.keys(input)) {
|
|
48
|
-
if (isForbiddenKey(key)) throw new Error(`PermDock: forbidden role key '${key}'`);
|
|
49
|
-
tree[key] = makeRole(key, input[key] ?? {});
|
|
50
|
-
}
|
|
51
|
-
return freezeDeep(tree);
|
|
52
|
-
}
|
|
53
|
-
function definePlans(input) {
|
|
54
|
-
const tree = {};
|
|
55
|
-
for (const key of Object.keys(input)) {
|
|
56
|
-
if (isForbiddenKey(key)) throw new Error(`PermDock: forbidden plan key '${key}'`);
|
|
57
|
-
tree[key] = makePlan(key, input[key] ?? {});
|
|
58
|
-
}
|
|
59
|
-
return freezeDeep(tree);
|
|
60
|
-
}
|
|
61
|
-
function listRoles(tree) {
|
|
62
|
-
if (tree === void 0) return [];
|
|
63
|
-
return ownKeys(tree).flatMap((key) => {
|
|
64
|
-
const leaf = tree[key];
|
|
65
|
-
return leaf === void 0 ? [] : [leaf];
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
function listPlans(tree) {
|
|
69
|
-
if (tree === void 0) return [];
|
|
70
|
-
return ownKeys(tree).flatMap((key) => {
|
|
71
|
-
const leaf = tree[key];
|
|
72
|
-
return leaf === void 0 ? [] : [leaf];
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
function findRole(tree, key) {
|
|
76
|
-
if (tree === void 0 || isForbiddenKey(key)) return;
|
|
77
|
-
return tree[key];
|
|
78
|
-
}
|
|
79
|
-
function synthesiseRole(key, options) {
|
|
80
|
-
const on = options?.on;
|
|
81
|
-
const assignable = options?.assignable ?? false;
|
|
82
|
-
const meta = options?.meta;
|
|
83
|
-
if (on === void 0) return makeRole(key, meta === void 0 ? { assignable } : {
|
|
84
|
-
assignable,
|
|
85
|
-
meta
|
|
86
|
-
});
|
|
87
|
-
return makeRole(key, meta === void 0 ? {
|
|
88
|
-
on,
|
|
89
|
-
assignable
|
|
90
|
-
} : {
|
|
91
|
-
on,
|
|
92
|
-
assignable,
|
|
93
|
-
meta
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
//#endregion
|
|
97
|
-
//#region src/core/grantee.ts
|
|
98
|
-
const DEFAULT_RELATION_DEPTH = 16;
|
|
99
|
-
function isGrantee(value) {
|
|
100
|
-
return value !== null && typeof value === "object" && "kind" in value && typeof value.kind === "string";
|
|
101
|
-
}
|
|
102
|
-
function anyone() {
|
|
103
|
-
return freezeDeep({ kind: "anyone" });
|
|
104
|
-
}
|
|
105
|
-
function authenticated() {
|
|
106
|
-
return freezeDeep({ kind: "authenticated" });
|
|
107
|
-
}
|
|
108
|
-
function relation(resource, name, options) {
|
|
109
|
-
const resourceName = listPermissions(resource)[0]?.resource;
|
|
110
|
-
if (resourceName === void 0) throw new Error("PermDock: relation() requires a resource tree");
|
|
111
|
-
const through = options?.through;
|
|
112
|
-
if (Array.isArray(through)) {
|
|
113
|
-
if (through.length === 0) throw new Error("PermDock: relation() through needs at least one link");
|
|
114
|
-
for (const link of through) if (typeof link !== "string" || link === "" || link === "parent") throw new Error("PermDock: relation() through lists link names; walk parents with through: 'parent' or depth");
|
|
115
|
-
} else if (through !== void 0 && through !== "parent") throw new Error(`PermDock: relation() through must be 'parent' or a list of link names (got '${String(through)}')`);
|
|
116
|
-
const depth = options?.depth;
|
|
117
|
-
if (depth !== void 0) {
|
|
118
|
-
if (through === void 0) throw new Error("PermDock: relation() depth needs through: 'parent' or a link list");
|
|
119
|
-
const hops = Array.isArray(through) ? through.length : 0;
|
|
120
|
-
if (!Number.isInteger(depth) || depth < 0 || depth + hops > 32) throw new Error(`PermDock: relation() depth must be an integer from 0 to 32, counting each link`);
|
|
121
|
-
}
|
|
122
|
-
return freezeDeep(compact({
|
|
123
|
-
kind: "relation",
|
|
124
|
-
resource: resourceName,
|
|
125
|
-
relation: name,
|
|
126
|
-
through: through === void 0 || through === "parent" ? through : [...through],
|
|
127
|
-
depth
|
|
128
|
-
}));
|
|
129
|
-
}
|
|
130
|
-
function inherit(permission, options) {
|
|
131
|
-
if (!isPermission(permission) || permission.kind === "collection") throw new Error("PermDock: inherit() takes an instance permission leaf");
|
|
132
|
-
const through = options.through;
|
|
133
|
-
const links = Array.isArray(through) ? through : void 0;
|
|
134
|
-
if (through !== "parent" && (links === void 0 || links.length === 0 || !links.every((link) => typeof link === "string" && link !== "" && link !== "parent"))) throw new Error("PermDock: inherit() through must be 'parent' or a non-empty list of link names");
|
|
135
|
-
return freezeDeep({
|
|
136
|
-
kind: "inherit",
|
|
137
|
-
permission: permission.key,
|
|
138
|
-
resource: permission.resource,
|
|
139
|
-
through: links === void 0 ? "parent" : links.map(String)
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
function plan(name) {
|
|
143
|
-
return freezeDeep({
|
|
144
|
-
kind: "plan",
|
|
145
|
-
plan: typeof name === "string" ? name : name.key
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
function actor(kind) {
|
|
149
|
-
return freezeDeep({
|
|
150
|
-
kind: "actor",
|
|
151
|
-
actor: kind
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
function assurance(options) {
|
|
155
|
-
const acr = options.acr === void 0 ? void 0 : typeof options.acr === "string" ? [options.acr] : options.acr;
|
|
156
|
-
const amr = options.amr === void 0 ? void 0 : typeof options.amr === "string" ? [options.amr] : options.amr;
|
|
157
|
-
return freezeDeep(compact({
|
|
158
|
-
kind: "assurance",
|
|
159
|
-
acr,
|
|
160
|
-
amr,
|
|
161
|
-
maxAge: options.maxAge
|
|
162
|
-
}));
|
|
163
|
-
}
|
|
164
|
-
function resolveRoleScope(on) {
|
|
165
|
-
return typeof on === "string" ? on : "global";
|
|
166
|
-
}
|
|
167
|
-
function asGrantee(input) {
|
|
168
|
-
if (Array.isArray(input)) {
|
|
169
|
-
const items = [];
|
|
170
|
-
for (const item of input) items.push(...flattenGrantee(asGrantee(item)));
|
|
171
|
-
return items;
|
|
172
|
-
}
|
|
173
|
-
if (typeof input === "string") return freezeDeep({
|
|
174
|
-
kind: "role",
|
|
175
|
-
role: input,
|
|
176
|
-
scope: "global"
|
|
177
|
-
});
|
|
178
|
-
if (isRole(input)) return freezeDeep({
|
|
179
|
-
kind: "role",
|
|
180
|
-
role: input.key,
|
|
181
|
-
scope: resolveRoleScope(input.on)
|
|
182
|
-
});
|
|
183
|
-
if (isPlan(input)) return freezeDeep({
|
|
184
|
-
kind: "plan",
|
|
185
|
-
plan: input.key
|
|
186
|
-
});
|
|
187
|
-
if (isGrantee(input)) return input;
|
|
188
|
-
throw new Error("PermDock: invalid grantee");
|
|
189
|
-
}
|
|
190
|
-
function flattenGrantee(input) {
|
|
191
|
-
if (input === void 0) return [];
|
|
192
|
-
if (Array.isArray(input)) return input;
|
|
193
|
-
return [input];
|
|
194
|
-
}
|
|
195
|
-
function roleNameOf(to) {
|
|
196
|
-
for (const item of flattenGrantee(to)) if (item.kind === "role") return item.role;
|
|
197
|
-
return null;
|
|
198
|
-
}
|
|
199
|
-
function roleScopeOf(to, fallback = "global") {
|
|
200
|
-
for (const item of flattenGrantee(to)) if (item.kind === "role") return item.scope;
|
|
201
|
-
return fallback;
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* Where a graph relation starts on the row: its own id when the relation is
|
|
205
|
-
* on the row's resource, the parent field when it is on the parent resource.
|
|
206
|
-
* `undefined` when `through` cannot reach the relation's resource.
|
|
207
|
-
*/
|
|
208
|
-
function relationStart(grantee, resource, target) {
|
|
209
|
-
if (resource === void 0 || target === void 0 || Array.isArray(grantee.through)) return;
|
|
210
|
-
const walks = grantee.through === "parent" && isSelfParented(target);
|
|
211
|
-
const requested = grantee.depth ?? DEFAULT_RELATION_DEPTH;
|
|
212
|
-
const depth = walks ? Number.isInteger(requested) ? Math.min(Math.max(requested, 0), 32) : 0 : 0;
|
|
213
|
-
if (target.name === resource.name) return {
|
|
214
|
-
field: resource.id,
|
|
215
|
-
parent: false,
|
|
216
|
-
depth
|
|
217
|
-
};
|
|
218
|
-
if (grantee.through === "parent" && resource.parent?.resource === target.name) return {
|
|
219
|
-
field: resource.parent.field,
|
|
220
|
-
parent: true,
|
|
221
|
-
depth
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* A resource role held on self-parented `membershipResource` instances
|
|
226
|
-
* (`ids`) reaches rows below them: the row itself when it is of that
|
|
227
|
-
* resource, its parent field when its parent is, walked up to the default
|
|
228
|
-
* depth. `undefined` when the row is not on such a chain.
|
|
229
|
-
*/
|
|
230
|
-
function resourceRoleCondition(resource, membershipResource, ids, resources) {
|
|
231
|
-
if (resource === void 0 || !isSelfParented(resources.get(membershipResource))) return;
|
|
232
|
-
const start = resource.name === membershipResource ? {
|
|
233
|
-
field: resource.id,
|
|
234
|
-
parent: false
|
|
235
|
-
} : resource.parent?.resource === membershipResource ? {
|
|
236
|
-
field: resource.parent.field,
|
|
237
|
-
parent: true
|
|
238
|
-
} : void 0;
|
|
239
|
-
if (start === void 0) return;
|
|
240
|
-
return compact({
|
|
241
|
-
op: "related",
|
|
242
|
-
resource: membershipResource,
|
|
243
|
-
relation: "",
|
|
244
|
-
ids: [...new Set(ids)].toSorted(),
|
|
245
|
-
field: start.field,
|
|
246
|
-
depth: DEFAULT_RELATION_DEPTH,
|
|
247
|
-
parent: start.parent ? true : void 0,
|
|
248
|
-
restricted: restrictedFor(resource, "parent"),
|
|
249
|
-
passRestricted: passesRestricted(resources.get(membershipResource))
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
function passesRestricted(node) {
|
|
253
|
-
return node?.restricted !== void 0 && !restrictedStops(node, "parent") ? true : void 0;
|
|
254
|
-
}
|
|
255
|
-
function linkStop(resource, link) {
|
|
256
|
-
const restricted = restrictedFor(resource, link);
|
|
257
|
-
if (restricted === void 0) return {};
|
|
258
|
-
const parent = resource.parent;
|
|
259
|
-
if (parent === void 0 || !isSelfParented(resource)) return { restricted };
|
|
260
|
-
return {
|
|
261
|
-
restricted,
|
|
262
|
-
restrictedAncestors: {
|
|
263
|
-
resource: resource.name,
|
|
264
|
-
id: resource.id,
|
|
265
|
-
parent: parent.field,
|
|
266
|
-
field: restricted,
|
|
267
|
-
depth: 32
|
|
268
|
-
}
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
/**
|
|
272
|
-
* The link path from the row to the grantee's resource: the row field of
|
|
273
|
-
* the first link and each hop. `undefined` when a link is not declared or
|
|
274
|
-
* the path ends on another resource.
|
|
275
|
-
*/
|
|
276
|
-
function relationHops(grantee, resource, resources) {
|
|
277
|
-
const through = grantee.through;
|
|
278
|
-
if (!Array.isArray(through) || resource === void 0) return;
|
|
279
|
-
const hops = [];
|
|
280
|
-
let current = resource;
|
|
281
|
-
let field;
|
|
282
|
-
for (const link of through) {
|
|
283
|
-
const spec = current !== void 0 && Object.hasOwn(current.links, link) ? current.links[link] : void 0;
|
|
284
|
-
if (spec === void 0) return;
|
|
285
|
-
field ??= spec.field;
|
|
286
|
-
hops.push({
|
|
287
|
-
link,
|
|
288
|
-
resource: spec.resource
|
|
289
|
-
});
|
|
290
|
-
current = resources?.get(spec.resource);
|
|
291
|
-
}
|
|
292
|
-
if (field === void 0 || current === void 0 || current.name !== grantee.resource) return;
|
|
293
|
-
const depth = grantee.depth ?? 0;
|
|
294
|
-
if (depth > 0 && !isSelfParented(current)) return;
|
|
295
|
-
return {
|
|
296
|
-
field,
|
|
297
|
-
hops,
|
|
298
|
-
depth
|
|
299
|
-
};
|
|
300
|
-
}
|
|
301
|
-
/**
|
|
302
|
-
* Whether the grantee needs the relation graph: a `through` walk, an edge
|
|
303
|
-
* table, or an `includes` that reaches one.
|
|
304
|
-
*/
|
|
305
|
-
function isGraphRelation(grantee, resources) {
|
|
306
|
-
if (grantee.through !== void 0) return true;
|
|
307
|
-
const node = resources?.get(grantee.resource);
|
|
308
|
-
return expandRelation(node, grantee.relation).some((name) => isEdgeRelation(node?.relations[name]));
|
|
309
|
-
}
|
|
310
|
-
function periodConditions(spec, now) {
|
|
311
|
-
const out = [];
|
|
312
|
-
const startsAt = spec.period?.startsAt;
|
|
313
|
-
if (startsAt !== void 0) out.push({
|
|
314
|
-
op: "or",
|
|
315
|
-
conditions: [{
|
|
316
|
-
op: "isNull",
|
|
317
|
-
field: startsAt,
|
|
318
|
-
value: true
|
|
319
|
-
}, {
|
|
320
|
-
op: "lte",
|
|
321
|
-
field: startsAt,
|
|
322
|
-
value: now
|
|
323
|
-
}]
|
|
324
|
-
});
|
|
325
|
-
const expiresAt = spec.period?.expiresAt;
|
|
326
|
-
if (expiresAt !== void 0) out.push({
|
|
327
|
-
op: "or",
|
|
328
|
-
conditions: [{
|
|
329
|
-
op: "isNull",
|
|
330
|
-
field: expiresAt,
|
|
331
|
-
value: true
|
|
332
|
-
}, {
|
|
333
|
-
op: "gt",
|
|
334
|
-
field: expiresAt,
|
|
335
|
-
value: now
|
|
336
|
-
}]
|
|
337
|
-
});
|
|
338
|
-
return out;
|
|
339
|
-
}
|
|
340
|
-
function relationCondition(grantee, resource, scopes = scopeList(void 0), options = {}) {
|
|
341
|
-
const target = grantee.resource === resource?.name ? resource : options.resources?.get(grantee.resource);
|
|
342
|
-
if (isGraphRelation(grantee, options.resources ?? targetMap(target))) {
|
|
343
|
-
const spec = target?.relations[grantee.relation];
|
|
344
|
-
if (spec === void 0 || isFieldRelation(spec) && spec.memberOf !== void 0) return;
|
|
345
|
-
if (Array.isArray(grantee.through)) {
|
|
346
|
-
const path = relationHops(grantee, resource, options.resources);
|
|
347
|
-
if (path === void 0 || target === void 0) return;
|
|
348
|
-
return compact({
|
|
349
|
-
op: "related",
|
|
350
|
-
resource: target.name,
|
|
351
|
-
relation: grantee.relation,
|
|
352
|
-
field: path.field,
|
|
353
|
-
depth: path.depth,
|
|
354
|
-
hops: path.hops,
|
|
355
|
-
...resource === void 0 ? {} : linkStop(resource, firstLink(path)),
|
|
356
|
-
passRestricted: path.depth > 0 ? passesRestricted(target) : void 0
|
|
357
|
-
});
|
|
358
|
-
}
|
|
359
|
-
const start = relationStart(grantee, resource, target);
|
|
360
|
-
if (start === void 0 || target === void 0) return;
|
|
361
|
-
return compact({
|
|
362
|
-
op: "related",
|
|
363
|
-
resource: target.name,
|
|
364
|
-
relation: grantee.relation,
|
|
365
|
-
field: start.field,
|
|
366
|
-
depth: start.depth,
|
|
367
|
-
parent: start.parent ? true : void 0,
|
|
368
|
-
restricted: start.parent || start.depth > 0 ? restrictedFor(resource, "parent") : void 0,
|
|
369
|
-
passRestricted: start.depth > 0 ? passesRestricted(target) : void 0
|
|
370
|
-
});
|
|
371
|
-
}
|
|
372
|
-
const spec = resource?.relations?.[grantee.relation];
|
|
373
|
-
if (spec === void 0 || isEdgeRelation(spec)) return;
|
|
374
|
-
if (spec.includes !== void 0 && options.includes !== false) {
|
|
375
|
-
const parts = expandRelation(resource, grantee.relation).flatMap((name) => {
|
|
376
|
-
const part = relationCondition({
|
|
377
|
-
...grantee,
|
|
378
|
-
relation: name
|
|
379
|
-
}, resource, scopes, {
|
|
380
|
-
...options,
|
|
381
|
-
includes: false
|
|
382
|
-
});
|
|
383
|
-
return part === void 0 ? [] : [part];
|
|
384
|
-
});
|
|
385
|
-
return sole(parts) ?? {
|
|
386
|
-
op: "or",
|
|
387
|
-
conditions: parts
|
|
388
|
-
};
|
|
389
|
-
}
|
|
390
|
-
if (isComputedRelation(spec)) return;
|
|
391
|
-
if (isPrincipalRelation(spec)) {
|
|
392
|
-
const owner = {
|
|
393
|
-
op: "eq",
|
|
394
|
-
field: spec.principal,
|
|
395
|
-
value: { ref: "principal.id" }
|
|
396
|
-
};
|
|
397
|
-
const period = periodConditions(spec, options.now ?? { date: (/* @__PURE__ */ new Date()).toISOString() });
|
|
398
|
-
return period.length === 0 ? owner : {
|
|
399
|
-
op: "and",
|
|
400
|
-
conditions: [owner, ...period]
|
|
401
|
-
};
|
|
402
|
-
}
|
|
403
|
-
if (spec.memberOf !== void 0) {
|
|
404
|
-
const scope = resolveScope(scopes, spec.memberOf);
|
|
405
|
-
if (scope === void 0) return {
|
|
406
|
-
op: "or",
|
|
407
|
-
conditions: []
|
|
408
|
-
};
|
|
409
|
-
if (scope === rootScope(scopes)) return {
|
|
410
|
-
op: "eq",
|
|
411
|
-
field: spec.field,
|
|
412
|
-
value: { ref: "principal.tenant" }
|
|
413
|
-
};
|
|
414
|
-
return {
|
|
415
|
-
op: "memberOf",
|
|
416
|
-
scope,
|
|
417
|
-
field: spec.field,
|
|
418
|
-
roles: []
|
|
419
|
-
};
|
|
420
|
-
}
|
|
421
|
-
return {
|
|
422
|
-
op: "eq",
|
|
423
|
-
field: spec.field,
|
|
424
|
-
value: { ref: "principal.id" }
|
|
425
|
-
};
|
|
426
|
-
}
|
|
427
|
-
function inheritCondition(grantee, resource, resources) {
|
|
428
|
-
if (resource === void 0) return;
|
|
429
|
-
if (grantee.through === "parent") {
|
|
430
|
-
const parent = resource.parent;
|
|
431
|
-
if (parent === void 0 || parent.resource !== grantee.resource) return;
|
|
432
|
-
return compact({
|
|
433
|
-
op: "related",
|
|
434
|
-
resource: grantee.resource,
|
|
435
|
-
relation: "",
|
|
436
|
-
permission: grantee.permission,
|
|
437
|
-
field: parent.field,
|
|
438
|
-
depth: 0,
|
|
439
|
-
parent: true,
|
|
440
|
-
restricted: restrictedFor(resource, "parent")
|
|
441
|
-
});
|
|
442
|
-
}
|
|
443
|
-
const path = relationHops({
|
|
444
|
-
kind: "relation",
|
|
445
|
-
resource: grantee.resource,
|
|
446
|
-
relation: "",
|
|
447
|
-
through: grantee.through
|
|
448
|
-
}, resource, resources);
|
|
449
|
-
if (path === void 0) return;
|
|
450
|
-
return compact({
|
|
451
|
-
op: "related",
|
|
452
|
-
resource: grantee.resource,
|
|
453
|
-
relation: "",
|
|
454
|
-
permission: grantee.permission,
|
|
455
|
-
field: path.field,
|
|
456
|
-
depth: 0,
|
|
457
|
-
hops: path.hops,
|
|
458
|
-
...linkStop(resource, firstLink(path))
|
|
459
|
-
});
|
|
460
|
-
}
|
|
461
|
-
function firstLink(path) {
|
|
462
|
-
return path.hops[0]?.link ?? "";
|
|
463
|
-
}
|
|
464
|
-
function targetMap(target) {
|
|
465
|
-
return target === void 0 ? void 0 : /* @__PURE__ */ new Map([[target.name, target]]);
|
|
466
|
-
}
|
|
467
|
-
function combineWhere(left, right) {
|
|
468
|
-
if (left === void 0) return right;
|
|
469
|
-
if (right === void 0) return left;
|
|
470
|
-
return {
|
|
471
|
-
op: "and",
|
|
472
|
-
conditions: [left, right]
|
|
473
|
-
};
|
|
474
|
-
}
|
|
475
|
-
/** Seats (`Membership.entitlements`) held through memberships that apply under the active tenant. */
|
|
476
|
-
function seatsInTenant(subject, scopes) {
|
|
477
|
-
const principal = subject.principal;
|
|
478
|
-
if (principal === null) return [];
|
|
479
|
-
const list = scopeList(scopes);
|
|
480
|
-
return (principal.memberships ?? []).flatMap((membership) => membership.entitlements !== void 0 && activeFor(membership, list, principal.tenant) ? membership.entitlements : []);
|
|
481
|
-
}
|
|
482
|
-
function matchOne(grantee, subject, now, resource, scopes, resources) {
|
|
483
|
-
switch (grantee.kind) {
|
|
484
|
-
case "anyone": return { matched: true };
|
|
485
|
-
case "authenticated": return subject.principal === null ? {
|
|
486
|
-
matched: false,
|
|
487
|
-
reason: "anonymous"
|
|
488
|
-
} : { matched: true };
|
|
489
|
-
case "plan":
|
|
490
|
-
if (subject.principal === null) return {
|
|
491
|
-
matched: false,
|
|
492
|
-
reason: "anonymous"
|
|
493
|
-
};
|
|
494
|
-
return (subject.principal.plans ?? []).includes(grantee.plan) || seatsInTenant(subject, scopes).includes(grantee.plan) ? { matched: true } : {
|
|
495
|
-
matched: false,
|
|
496
|
-
reason: "not-entitled"
|
|
497
|
-
};
|
|
498
|
-
case "actor":
|
|
499
|
-
if (subject.actor === void 0) return {
|
|
500
|
-
matched: false,
|
|
501
|
-
reason: "no-grant"
|
|
502
|
-
};
|
|
503
|
-
return subject.actor.kind === grantee.actor ? { matched: true } : {
|
|
504
|
-
matched: false,
|
|
505
|
-
reason: "no-grant"
|
|
506
|
-
};
|
|
507
|
-
case "assurance": {
|
|
508
|
-
if (subject.principal === null) return {
|
|
509
|
-
matched: false,
|
|
510
|
-
reason: "anonymous"
|
|
511
|
-
};
|
|
512
|
-
const principalAssurance = subject.principal.assurance;
|
|
513
|
-
if (grantee.acr !== void 0 && grantee.acr.length > 0) {
|
|
514
|
-
const acr = principalAssurance?.acr;
|
|
515
|
-
if (acr === void 0 || !grantee.acr.includes(acr)) return {
|
|
516
|
-
matched: false,
|
|
517
|
-
reason: "insufficient-user-authentication"
|
|
518
|
-
};
|
|
519
|
-
}
|
|
520
|
-
if (grantee.amr !== void 0 && grantee.amr.length > 0) {
|
|
521
|
-
const amr = principalAssurance?.amr ?? [];
|
|
522
|
-
if (!grantee.amr.every((method) => amr.includes(method))) return {
|
|
523
|
-
matched: false,
|
|
524
|
-
reason: "insufficient-user-authentication"
|
|
525
|
-
};
|
|
526
|
-
}
|
|
527
|
-
if (grantee.maxAge !== void 0) {
|
|
528
|
-
const authTime = principalAssurance?.authTime;
|
|
529
|
-
if (authTime === void 0 || now - authTime > grantee.maxAge) return {
|
|
530
|
-
matched: false,
|
|
531
|
-
reason: "insufficient-user-authentication"
|
|
532
|
-
};
|
|
533
|
-
}
|
|
534
|
-
return { matched: true };
|
|
535
|
-
}
|
|
536
|
-
case "relation": {
|
|
537
|
-
if (subject.principal === null) return {
|
|
538
|
-
matched: false,
|
|
539
|
-
reason: "anonymous"
|
|
540
|
-
};
|
|
541
|
-
const where = relationCondition(grantee, resource, scopes, {
|
|
542
|
-
resources,
|
|
543
|
-
now: { date: (/* @__PURE__ */ new Date(now * 1e3)).toISOString() }
|
|
544
|
-
});
|
|
545
|
-
if (where === void 0 && resource !== void 0) return {
|
|
546
|
-
matched: false,
|
|
547
|
-
reason: "condition"
|
|
548
|
-
};
|
|
549
|
-
return compact({
|
|
550
|
-
matched: true,
|
|
551
|
-
where
|
|
552
|
-
});
|
|
553
|
-
}
|
|
554
|
-
case "inherit": {
|
|
555
|
-
const where = inheritCondition(grantee, resource, resources);
|
|
556
|
-
return where === void 0 ? {
|
|
557
|
-
matched: false,
|
|
558
|
-
reason: "condition"
|
|
559
|
-
} : {
|
|
560
|
-
matched: true,
|
|
561
|
-
where
|
|
562
|
-
};
|
|
563
|
-
}
|
|
564
|
-
case "role":
|
|
565
|
-
if (subject.principal === null) return {
|
|
566
|
-
matched: false,
|
|
567
|
-
reason: "anonymous"
|
|
568
|
-
};
|
|
569
|
-
return { matched: true };
|
|
570
|
-
default: return unknownGrantee(grantee);
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
/** A kind this build does not know, from a forged snapshot or a newer document, never matches. */
|
|
574
|
-
function unknownGrantee(_grantee) {
|
|
575
|
-
return {
|
|
576
|
-
matched: false,
|
|
577
|
-
reason: "no-grant",
|
|
578
|
-
unknown: true
|
|
579
|
-
};
|
|
580
|
-
}
|
|
581
|
-
function matchGrantee(to, subject, now, resource, scopes, resources, unknownMatches = false) {
|
|
582
|
-
const items = flattenGrantee(to);
|
|
583
|
-
if (items.length === 0) return {
|
|
584
|
-
matched: false,
|
|
585
|
-
reason: "no-grant"
|
|
586
|
-
};
|
|
587
|
-
let where;
|
|
588
|
-
for (const item of items) {
|
|
589
|
-
const result = matchOne(item, subject, now, resource, scopes, resources);
|
|
590
|
-
if (!result.matched) {
|
|
591
|
-
if (unknownMatches && result.unknown === true) continue;
|
|
592
|
-
return result;
|
|
593
|
-
}
|
|
594
|
-
where = combineWhere(where, result.where);
|
|
595
|
-
}
|
|
596
|
-
return compact({
|
|
597
|
-
matched: true,
|
|
598
|
-
where
|
|
599
|
-
});
|
|
600
|
-
}
|
|
601
|
-
//#endregion
|
|
602
|
-
export { isPlan as C, synthesiseRole as D, listRoles as E, findRole as S, listPlans as T, resourceRoleCondition as _, authenticated as a, definePlans as b, inherit as c, matchGrantee as d, plan as f, relationStart as g, relationHops as h, assurance as i, inheritCondition as l, relationCondition as m, anyone as n, combineWhere as o, relation as p, asGrantee as r, flattenGrantee as s, actor as t, isGraphRelation as u, roleNameOf as v, isRole as w, defineRoles as x, roleScopeOf as y };
|