permdock 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +106 -47
- package/dist/a2a/index.d.ts +7 -16
- package/dist/a2a/index.js +59 -98
- package/dist/adapter-context-mlWsVGGg.js +23 -0
- package/dist/ai-sdk/index.d.ts +37 -16
- package/dist/ai-sdk/index.js +30 -13
- package/dist/approvals/index.d.ts +3 -3
- package/dist/approvals/index.js +5 -4
- package/dist/{approvals-DaxY-Bdg.js → approvals-DbYAuNkG.js} +17 -11
- package/dist/approvers-DT4AVyIg.js +52 -0
- package/dist/{arazzo-CTeVuXr5.js → arazzo-BAgw9ap6.js} +2 -2
- package/dist/{arazzo-aoTkqYsJ.js → arazzo-CKwwqFWz.js} +2 -2
- package/dist/authzen/index.d.ts +4 -13
- package/dist/authzen/index.js +16 -50
- package/dist/better-auth/index.d.ts +20 -3
- package/dist/better-auth/index.js +27 -7
- package/dist/better-supabase/index.d.ts +223 -0
- package/dist/better-supabase/index.js +648 -0
- package/dist/bind-C_ob3LKa.d.ts +25 -0
- package/dist/bind-CuzGytRf.js +97 -0
- package/dist/boundary-BM8a_P6E.js +13 -0
- package/dist/boundary-BmHxVH1J.d.ts +15 -0
- package/dist/canonical-json-DemiK4Vp.js +26 -0
- package/dist/{capability-BDG_nkxt.d.ts → capability-2kYTMWDv.d.ts} +2 -2
- package/dist/{capability-B68OFnZx.js → capability-4qPdO9gk.js} +7 -5
- package/dist/catalog/index.d.ts +1 -1
- package/dist/catalog/index.js +1 -1
- package/dist/catalog-CRW5Mx_B.js +2 -0
- package/dist/{catalog-H-vFGwWK.js → catalog-DWF5cYqB.js} +4 -4
- package/dist/{catalog-B0E6bggc.js → catalog-dFZdWCGN.js} +2 -2
- package/dist/{catalog-doc-BSo_Q_-6.js → catalog-doc-DdGm82XT.js} +20 -32
- package/dist/claude-agent/index.d.ts +5 -14
- package/dist/claude-agent/index.js +4 -10
- package/dist/clerk/index.d.ts +12 -3
- package/dist/clerk/index.js +26 -5
- package/dist/cli/bin.js +1 -1
- package/dist/cli/index.d.ts +3 -3
- package/dist/cli/index.js +2 -2
- package/dist/clients-C7zLFuWT.d.ts +12 -0
- package/dist/clients-DjU5ABMy.js +23 -0
- package/dist/cloud/index.d.ts +4 -5
- package/dist/cloud/index.js +20 -6
- package/dist/{cloud-BNQTrmrr.js → cloud-CB_ELYuX.js} +2 -2
- package/dist/{cloud-Cuxr6Czw.js → cloud-DWLXO2af.js} +7 -6
- package/dist/collect-DClJsheJ.js +83 -0
- package/dist/{collect-O-tOtbnk.js → collect-DSTE3ml9.js} +194 -42
- package/dist/collect-DSWOk19R.js +2 -0
- package/dist/{commands-BMh_Etm2.js → commands-DSxCqG9A.js} +16 -12
- package/dist/compile/index.d.ts +3 -0
- package/dist/compile/index.js +2 -0
- package/dist/{compile-D22iwvuV.js → compile-Ba4blROR.js} +85 -30
- package/dist/compile-BkRyBDBw.d.ts +94 -0
- package/dist/config-BJiM-xAm.js +157 -0
- package/dist/config-Dnszbv-6.js +36 -0
- package/dist/config-report-DMvWKUxL.js +44 -0
- package/dist/{connection-JvqwHODC.js → connection-CU8MQxRi.js} +1 -1
- package/dist/{context-CKEAabd7.js → context-Bcy85rGi.js} +36 -27
- package/dist/convex/index.d.ts +9 -4
- package/dist/convex/index.js +14 -4
- package/dist/create-B1d519XK.d.ts +245 -0
- package/dist/create-CMwIl-w2.js +253 -0
- package/dist/{credential-B_rkUNlY.js → credential-8P81ff4u.js} +26 -46
- package/dist/delegation-D8pUEuce.js +103 -0
- package/dist/{describe-Bt1YD5uS.js → describe-B_gVZEVi.js} +10 -15
- package/dist/{describe-DernyItf.d.ts → describe-DMYiCjJV.d.ts} +9 -10
- package/dist/{diff-x5Il8LVa.js → diff-2VaeChzX.js} +44 -11
- package/dist/{diff-BUzf5Poi.js → diff-DBIhz_f2.js} +2 -2
- package/dist/{doctor-Bqo6FwUa.js → doctor-BwCAMLx_.js} +2 -2
- package/dist/doctor-collect-CHk6XWOA.js +665 -0
- package/dist/doctor-igIiM_Hl.js +1194 -0
- package/dist/drizzle/index.d.ts +4 -3
- package/dist/drizzle/index.js +3 -3
- package/dist/elysia/index.d.ts +6 -28
- package/dist/elysia/index.js +16 -60
- package/dist/{errors-DSMnAVNa.js → errors-CWfoNg9N.js} +8 -4
- package/dist/{errors-Iy71s7Oj.js → errors-Cz5zn0mW.js} +17 -71
- package/dist/{errors-DbZ1YOnb.d.ts → errors-DPdqI50v.d.ts} +8 -21
- package/dist/{errors-m3u9TmDu.js → errors-DRnGZHzF.js} +4 -1
- package/dist/evaluation-items-CfCCejQd.js +40 -0
- package/dist/{evaluations-DsAU9ppl.js → evaluations-tz6D9A2G.js} +28 -46
- package/dist/eve/index.d.ts +6 -15
- package/dist/eve/index.js +7 -12
- package/dist/expiry-BoBJ8Tvc.js +7 -0
- package/dist/express/index.d.ts +6 -29
- package/dist/express/index.js +28 -58
- package/dist/fastify/index.d.ts +6 -29
- package/dist/fastify/index.js +16 -65
- package/dist/fields-BMl1RxoX.js +26 -0
- package/dist/{files-B_wAGYmt.js → files-DWUN9PzI.js} +5 -1
- package/dist/{fixtures-Cvaw0gDG.js → fixtures-ht28Cplr.js} +5 -2
- package/dist/{freeze-y1_jQL4v.js → freeze-CrU8nQeX.js} +31 -2
- package/dist/{from-snapshot-BMGnhmgv.js → from-snapshot-CTLijvdm.js} +66 -48
- package/dist/{grantee-Bv04_Vzf.js → grantee-Cv5Sogfv.js} +88 -7
- package/dist/graph-sql-B-dsAT6j.d.ts +29 -0
- package/dist/{headers-B5RRv3Xm.js → headers-BZSDieNT.js} +1 -1
- package/dist/{headers-C8SHQccD.d.ts → headers-Cf-zWvsO.d.ts} +1 -1
- package/dist/helpers-H_KARDVC.js +421 -0
- package/dist/hono/index.d.ts +6 -28
- package/dist/hono/index.js +11 -43
- package/dist/{hosted-BwKQ1BTA.js → hosted-DJQw46hn.js} +6 -5
- package/dist/{http-GgVApX1k.js → http-BIhmLfCc.js} +4 -20
- package/dist/http-SO7qGttf.js +44 -0
- package/dist/ids-DC4V4CFu.js +18 -0
- package/dist/index-0nNqHspG.d.ts +6 -0
- package/dist/{index-xIxJLwOQ.d.ts → index-BNc7Wer_.d.ts} +75 -7
- package/dist/{index-CltcQ4Bf.d.ts → index-C7Tw7MaW.d.ts} +68 -5
- package/dist/{index-LF_hS-yn.d.ts → index-C8z4RjQV.d.ts} +1 -1
- package/dist/index.d.ts +14 -9
- package/dist/index.js +22 -17
- package/dist/instance-options-Dhhcnm3y.js +22 -0
- package/dist/instance-options-jARdwfPN.d.ts +11 -0
- package/dist/{parse-DPfIvFMU.js → json-schema-BsAflUGW.js} +28 -57
- package/dist/jwt/index.d.ts +10 -6
- package/dist/jwt/index.js +32 -13
- package/dist/kernel-_RRHmnMY.js +208 -0
- package/dist/kysely/index.d.ts +4 -3
- package/dist/kysely/index.js +3 -3
- package/dist/live-options-H2eG8dfJ.js +60 -0
- package/dist/{load-BZ24CpZP.js → load-DhWEB9P1.js} +16 -10
- package/dist/load-DwJUafYN.js +2 -0
- package/dist/manifest-iaoBXHKc.js +783 -0
- package/dist/manifest-uDS9y5de.d.ts +206 -0
- package/dist/{map-DowSO96j.js → map-AcxK9o_D.js} +4 -15
- package/dist/{map-claims-B_6I1Rn-.js → map-claims-Z4QZOiFF.js} +13 -4
- package/dist/map-error-pgUWNNtG.js +23 -0
- package/dist/may-use-DndQ5tQ-.js +77 -0
- package/dist/mcp/index.d.ts +54 -22
- package/dist/mcp/index.js +218 -178
- package/dist/nest/index.d.ts +26 -31
- package/dist/nest/index.js +75 -84
- package/dist/next/client.d.ts +7 -8
- package/dist/next/client.js +11 -9
- package/dist/next/index.d.ts +30 -47
- package/dist/next/index.js +45 -60
- package/dist/next/plugin.d.ts +1 -1
- package/dist/next/plugin.js +32 -1
- package/dist/node/index.d.ts +9 -28
- package/dist/node/index.js +11 -43
- package/dist/openai/index.d.ts +6 -15
- package/dist/openai/index.js +7 -20
- package/dist/openapi/index.d.ts +87 -4
- package/dist/openapi/index.js +3 -3
- package/dist/{openapi-DcqM8nU7.js → openapi-BqRBvAng.js} +237 -5
- package/dist/{openapi-DWD0Uc_4.js → openapi-CqqEbHsL.js} +5 -5
- package/dist/{openapi-import-BWRUNNeW.js → openapi-import-cmwetbzw.js} +1 -1
- package/dist/{openapi-CwePaF7C.js → openapi-l0xYHkcv.js} +3 -3
- package/dist/{openapi-schema-D8j_T9tO.js → openapi-schema--ARjyfQr.js} +2 -2
- package/dist/orpc/index.d.ts +15 -28
- package/dist/orpc/index.js +74 -117
- package/dist/otel/index.d.ts +2 -2
- package/dist/parse-BuyjxhZV.js +53 -0
- package/dist/parse-local-manifest-BrMozJCo.js +36 -0
- package/dist/parse-local-manifest-JLnaBH0S.d.ts +10 -0
- package/dist/pdp/index.d.ts +2 -2
- package/dist/pdp/index.js +14 -127
- package/dist/{permdock-yoZ7EjxX.js → permdock-CbgvLnuo.js} +672 -149
- package/dist/{permissions-B8vCg_bI.d.ts → permissions-CDgvKG5L.d.ts} +2 -2
- package/dist/{permissions-DC7GROPA.js → permissions-DVoF6dMt.js} +77 -15
- package/dist/{permissions-B4apnahQ.d.ts → permissions-DttnqqxC.d.ts} +34 -5
- package/dist/{permissions-CofRqesP.js → permissions-RJrovw98.js} +3 -3
- package/dist/{pins-CqE1jZuF.js → pins-8ILTftC9.js} +2 -2
- package/dist/{policy-Cq2fB8Q5.d.ts → policy-D2W7uv19.d.ts} +2 -2
- package/dist/{policy-CInmNGkM.d.ts → policy-IB6yxpC3.d.ts} +351 -42
- package/dist/{policy-ANp36PnI.js → policy-xyWg7QdR.js} +173 -22
- package/dist/powersync-BylawD_U.js +540 -0
- package/dist/powersync-DliZK_-y.js +62 -0
- package/dist/powersync-e_AZrKbg.js +2 -0
- package/dist/prisma/index.d.ts +3 -2
- package/dist/prisma/index.js +45 -20
- package/dist/{problem-Cgp9-KZA.js → problem-B43ztKIm.js} +74 -109
- package/dist/problem-details-DX075l9V.d.ts +7 -0
- package/dist/problem-details-_AMOYz-w.js +144 -0
- package/dist/{protected-BuPAycJT.d.ts → protected-BdnIEFkY.d.ts} +5 -4
- package/dist/protected-utU-SLuy.js +100 -0
- package/dist/protected-xAr24FEC.d.ts +40 -0
- package/dist/provider-CSQd7m92.js +52 -0
- package/dist/{provider-wTAUda2v.d.ts → provider-DZY281jO.d.ts} +1 -1
- package/dist/provider-store-Cfbvo4DE.js +43 -0
- package/dist/react/index.d.ts +7 -5
- package/dist/react/index.js +5 -4
- package/dist/react/provider-client.d.ts +1 -1
- package/dist/react/provider-client.js +1 -1
- package/dist/react-native/index.d.ts +166 -10
- package/dist/react-native/index.js +607 -85
- package/dist/{refs-ChLSxbST.js → refs-KYb4ntaz.js} +4 -3
- package/dist/{relations-r4soIFZB.js → relations-cjOL01hZ.js} +110 -31
- package/dist/replay-BsOyTrdV.js +28 -0
- package/dist/replay-CYyiLiwO.d.ts +5 -0
- package/dist/resource-ref-CaS9yVPi.js +20 -0
- package/dist/revocations-Bhr0aMIC.js +27 -0
- package/dist/{rls-BOFU3chG.js → rls-B4ur8nKQ.js} +8 -3
- package/dist/rls-DQtdgTHB.js +2521 -0
- package/dist/rls-fields-74oZPXWL.js +3582 -0
- package/dist/{rls-graph-DxQ39PJj.js → rls-graph-CHwx0V8q.js} +100 -36
- package/dist/{rls-import-CXV6LBlS.js → rls-import-BTFVk3jH.js} +7 -6
- package/dist/{rls-migrate-DrFPbf8p.js → rls-migrate-CN4TlJTO.js} +6 -5
- package/dist/rls-ownership-RuFqaqGz.js +843 -0
- package/dist/rls-shared-Cewd_-zI.js +495 -0
- package/dist/rls-verify-CVQTHTh5.js +746 -0
- package/dist/{row-check-BajTgQZ-.d.ts → row-check-Dt35czLy.d.ts} +12 -15
- package/dist/row-conditions-h2HythXQ.js +27 -0
- package/dist/rpc-DL9Sqvb1.js +89 -0
- package/dist/{run-CJ6UvS3a.js → run-DKDbM4Du.js} +31 -12
- package/dist/runtime-CB8gQFvS.js +11 -0
- package/dist/{saas-BRrZzJkM.js → saas-DhpJjnBA.js} +17 -7
- package/dist/{schema-P8yoma__.js → schema-D3MnDMxa.js} +8 -4
- package/dist/scim/index.d.ts +1 -1
- package/dist/scim/index.js +1 -1
- package/dist/{scim-9NFa0XVZ.js → scim-BFGBBAqR.js} +1 -1
- package/dist/{scopes-cKVp_WTw.js → scopes-CVdPrWN-.js} +35 -8
- package/dist/server/index.d.ts +22 -11
- package/dist/server/index.js +11 -8
- package/dist/{credentials-BgRX3WEg.js → server-DlZ28Oz5.js} +1 -1
- package/dist/shared-DRu8VFVM.js +123 -0
- package/dist/{sink-Cfr9-7YC.d.ts → sink-B1fZzIMf.d.ts} +1 -1
- package/dist/skills-Biq5uup3.js +192 -0
- package/dist/{skills-C_lpV4Jx.js → skills-Bx-U0irG.js} +10 -4
- package/dist/{snapshot-DE8dE_hz.js → snapshot-Enxd0n-s.js} +138 -214
- package/dist/snapshot-cache-B-LxUahj.d.ts +45 -0
- package/dist/snapshot-cache-D6jLelln.js +44 -0
- package/dist/solid/index.d.ts +39 -9
- package/dist/solid/index.js +76 -85
- package/dist/sources-4p0-4xQm.js +545 -0
- package/dist/sources-BdOYLw9j.d.ts +192 -0
- package/dist/{sql-Bll1d7y0.js → sql-xdg5f4Fi.js} +6 -1
- package/dist/{src-CTNT-PBW.js → src-BDwEZWrZ.js} +149 -11
- package/dist/ssf/index.d.ts +3 -2
- package/dist/ssf/index.js +3 -29
- package/dist/store-DMAWwAJV.js +371 -0
- package/dist/{store-Bq90395i.d.ts → store-jOBYpiXC.d.ts} +13 -4
- package/dist/store-options-ByhZq1jV.js +716 -0
- package/dist/{stores-CkG2HrSg.js → stores-BT2pSCub.js} +10 -63
- package/dist/{stores-CvOnu_2T.d.ts → stores-C0IMQrGI.d.ts} +20 -9
- package/dist/{stream-BhMfZOwr.d.ts → stream-D1RXubw2.d.ts} +2 -2
- package/dist/{stream-Q_xlB6Ko.js → stream-DDpvynSB.js} +16 -2
- package/dist/subject-settings-BwBmCdTR.js +128 -0
- package/dist/supabase/index.d.ts +133 -6
- package/dist/supabase/index.js +4 -3
- package/dist/supabase/middleware.d.ts +32 -27
- package/dist/supabase/middleware.js +56 -22
- package/dist/{supabase-D8UlBA7Z.js → supabase-Boqb9a_Y.js} +3 -3
- package/dist/{supabase-DTxGtYdi.js → supabase-C0qESOa-.js} +347 -367
- package/dist/supabase-config-BpPXt3x1.js +472 -0
- package/dist/supabase-hook-6sYLXg_u.js +2 -0
- package/dist/{supabase-hook-D_OqGb_V.js → supabase-hook-CSLQ4zJ3.js} +1037 -705
- package/dist/supautils-Cn4R4cJ4.js +91 -0
- package/dist/svelte/PermissionBoundary.svelte +37 -0
- package/dist/svelte/Protected.svelte +8 -2
- package/dist/svelte/index.d.ts +9 -6
- package/dist/svelte/index.js +61 -7
- package/dist/svelte/runtime.d.ts +4 -3
- package/dist/svelte/runtime.js +4 -3
- package/dist/svelte/source.d.ts +9 -6
- package/dist/svelte/source.js +7 -4
- package/dist/terminal/index.d.ts +6 -14
- package/dist/terminal/index.js +44 -32
- package/dist/testing/index.d.ts +105 -16
- package/dist/testing/index.js +504 -40
- package/dist/testing/saas/index.d.ts +4 -4
- package/dist/testing/saas/index.js +2 -2
- package/dist/testing/saas/permissions.d.ts +1 -1
- package/dist/testing/saas/permissions.js +1 -1
- package/dist/token-CIWxJOCh.js +50 -0
- package/dist/trpc/index.d.ts +7 -26
- package/dist/trpc/index.js +17 -100
- package/dist/types-BnIEz1sU.d.ts +48 -0
- package/dist/{types-CxquUByI.d.ts → types-Bvc4oWT6.d.ts} +1 -1
- package/dist/{sources-DOpW5Ila.d.ts → types-C97IskBw.d.ts} +86 -127
- package/dist/types-CKNSyIf_.d.ts +52 -0
- package/dist/types-Cq_H8N_X.d.ts +197 -0
- package/dist/{types-D6Z6-rKJ.d.ts → types-DbjRN55U.d.ts} +273 -22
- package/dist/{types-BBK-exvJ.d.ts → types-Dnemwd77.d.ts} +7 -1
- package/dist/{types-BvBk1wgn.d.ts → types-DxiCGmmd.d.ts} +5 -3
- package/dist/{types-B9dmiiab.d.ts → types-QCuYJh4q.d.ts} +1 -1
- package/dist/{types-B8w5PFtS.d.ts → types-aqOHTHcp.d.ts} +17 -1
- package/dist/unplugin/index.d.ts +1 -1
- package/dist/unplugin/index.js +10 -9
- package/dist/usage-DorAJiU_.js +2 -0
- package/dist/{usage-1ozMubLY.js → usage-GTixvDDU.js} +2 -2
- package/dist/{usage-CUnK6Ou9.js → usage-ItS7nLcl.js} +225 -62
- package/dist/validation-error-Ba264OaJ.d.ts +26 -0
- package/dist/validation-error-CnjZ4t92.js +33 -0
- package/dist/{validity-D0uRmJKJ.js → validity-uOp8UpYn.js} +57 -36
- package/dist/{verifier-B90agnhl.js → verifier-BxBo6I44.js} +10 -5
- package/dist/version-BvacVTZR.js +17 -0
- package/dist/views-Soe7bGSC.js +95 -0
- package/dist/{vocabulary-Dk0fs-Jk.d.ts → vocabulary-DA8a8zif.d.ts} +1 -1
- package/dist/vue/index.d.ts +35 -13
- package/dist/vue/index.js +86 -93
- package/dist/watch-BwxLTYMZ.js +2 -0
- package/dist/watch-DVBJ9cBq.js +128 -0
- package/dist/webmcp/index.d.ts +2 -2
- package/dist/webmcp/index.js +7 -13
- package/package.json +62 -36
- package/schemas/approval-request-v1.json +175 -0
- package/schemas/catalog-v1.json +29 -1
- package/schemas/supabase-claims-v1.json +6 -1
- package/schemas/supabase-manifest-v1.json +150 -6
- package/skills/permdock/SKILL.md +7 -7
- package/skills/permdock-agents/SKILL.md +5 -5
- package/skills/permdock-agents/references/runtimes.md +12 -10
- package/skills/permdock-approvals/SKILL.md +4 -4
- package/skills/permdock-approvals/references/stores-and-resume.md +15 -4
- package/skills/permdock-audit/SKILL.md +3 -3
- package/skills/permdock-credentials/SKILL.md +4 -4
- package/skills/permdock-credentials/references/tokens-keys-links.md +7 -2
- package/skills/permdock-data/SKILL.md +4 -4
- package/skills/permdock-data/references/queries-and-rls.md +14 -6
- package/skills/permdock-data/references/relationships.md +5 -3
- package/skills/permdock-tenancy/SKILL.md +9 -6
- package/skills/permdock-tenancy/references/ownership-and-custom-roles.md +14 -8
- package/skills/permdock-wire/SKILL.md +4 -4
- package/skills/permdock-wire/references/adapters.md +42 -30
- package/skills/permdock-wire/references/policy-options.md +5 -3
- package/dist/approvers-aH0PJkmf.js +0 -20
- package/dist/catalog-idsHc0vo.js +0 -2
- package/dist/collect-B7_TIfmg.js +0 -49
- package/dist/collect-fRPAQIWb.js +0 -2
- package/dist/compile-CQbvyIBr.d.ts +0 -30
- package/dist/config-BPYmjTOp.js +0 -26
- package/dist/context-gtAwAILx.js +0 -6
- package/dist/create-BKF3dgFk.d.ts +0 -162
- package/dist/create-CSkhDU9T.js +0 -222
- package/dist/doctor-BGle8Gqi.js +0 -1314
- package/dist/helpers-DnSOrhB9.js +0 -682
- package/dist/index-fG6NSXlc.d.ts +0 -9
- package/dist/kernel-YOGCWNLf.js +0 -211
- package/dist/load-QOOm1z70.js +0 -2
- package/dist/manifest-DDQbC6K0.d.ts +0 -118
- package/dist/map-error-RJ3ZsUyA.js +0 -16
- package/dist/may-use-CnFEjVEp.js +0 -37
- package/dist/pg-4GJWDUxG.js +0 -953
- package/dist/plugin-4gr7IxFJ.js +0 -65
- package/dist/protected-B4K3BKoX.js +0 -138
- package/dist/protected-wY7nXhY9.d.ts +0 -23
- package/dist/provider-_wx46HpB.js +0 -48
- package/dist/rls-CJVja9Ww.js +0 -2119
- package/dist/rls-helpers-BxRuif0l.js +0 -1346
- package/dist/runtime-DP9ttFh1.js +0 -27
- package/dist/skills-Dx3QLnMY.js +0 -110
- package/dist/source-DoBBYJi2.js +0 -6
- package/dist/sources-DVHM3Mwq.js +0 -284
- package/dist/store-C6hFW6ta.js +0 -508
- package/dist/subject-settings-xt7V845g.js +0 -82
- package/dist/supabase-hook-DW-xP4hU.js +0 -2
- package/dist/types-DbWdEfcm.d.ts +0 -87
- package/dist/types-bva3i4Gf.d.ts +0 -98
- package/dist/types-i4BAOvdb.d.ts +0 -97
- package/dist/usage-PyEor6GA.js +0 -2
- package/dist/version-CnSh33Fj.js +0 -16
package/dist/jwt/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as JsonWebKeySet, c as JwtJwks, d as MappedSubject, i as JoseTokenVerifierOptions, l as JwtPrincipal, n as DpopProofResult, o as JwtAlgorithm, r as JoseTokenSignerOptions, s as JwtClaimPaths, t as DiscoveryInput, u as JwtSubjectOptions } from "../types-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { Ft as TokenVerifier, Nr as Principal, Nt as TokenFailureCause, Pr as Subject, Pt as TokenSigner, ct as JwtClaims, et as AuthEvent } from "../policy-IB6yxpC3.js";
|
|
2
|
+
import { a as JsonWebKeySet, c as JwtJwks, d as MappedSubject, g as ReplayStore, i as JoseTokenVerifierOptions, l as JwtPrincipal, n as DpopProofResult, o as JwtAlgorithm, r as JoseTokenSignerOptions, s as JwtClaimPaths, t as DiscoveryInput, u as JwtSubjectOptions } from "../types-Cq_H8N_X.js";
|
|
3
|
+
import { i as LinkPolicy, o as LinkPrincipal, t as Capability } from "../capability-2kYTMWDv.js";
|
|
4
|
+
import { t as memoryReplayStore } from "../replay-CYyiLiwO.js";
|
|
5
5
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
6
6
|
//#region src/jwt/capability.d.ts
|
|
7
7
|
/** `on('auth')` causes: a verification failure, or one of the three capability checks. */
|
|
@@ -69,7 +69,11 @@ type CiOidcPrincipal = Principal & {
|
|
|
69
69
|
export declare function subjectFromCiOidc(token: string | undefined | null, options: CiOidcSubjectOptions): Promise<Subject<CiOidcPrincipal> | Subject>;
|
|
70
70
|
//#endregion
|
|
71
71
|
//#region src/jwt/dpop.d.ts
|
|
72
|
-
|
|
72
|
+
type DpopProofOptions = {
|
|
73
|
+
/** Rejects a proof whose `jti` this key already used within the 60-second window. */
|
|
74
|
+
readonly replay?: ReplayStore;
|
|
75
|
+
};
|
|
76
|
+
export declare function verifyDpopProof(request: Request, claims: JwtClaims, accessToken?: string, options?: DpopProofOptions): Promise<DpopProofResult>;
|
|
73
77
|
//#endregion
|
|
74
78
|
//#region src/jwt/introspection.d.ts
|
|
75
79
|
export declare function subjectFromIntrospection(response: unknown, options?: JwtSubjectOptions): MappedSubject;
|
|
@@ -84,4 +88,4 @@ export declare function createJwtSubjectResolver(options: JwtSubjectOptions): (t
|
|
|
84
88
|
//#region src/jwt/verifier.d.ts
|
|
85
89
|
export declare function joseTokenVerifier(options: JoseTokenVerifierOptions): TokenVerifier;
|
|
86
90
|
//#endregion
|
|
87
|
-
export type
|
|
91
|
+
export { type CapabilityFailureCause, type CapabilitySubjectOptions, type CiOidcPrincipal, type CiOidcProvider, type CiOidcSubjectOptions, type DiscoveryInput, type DpopProofOptions, type DpopProofResult, type JoseTokenSignerOptions, type JoseTokenVerifierOptions, type JsonWebKeySet, type JwtAlgorithm, type JwtClaimPaths, type JwtJwks, type JwtPrincipal, type JwtSubjectOptions, type MappedSubject, type ReplayStore, memoryReplayStore };
|
package/dist/jwt/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { t as compact } from "../compact-y6vfu2_f.js";
|
|
2
|
-
import { n as freezeDeep } from "../freeze-
|
|
2
|
+
import { n as freezeDeep } from "../freeze-CrU8nQeX.js";
|
|
3
3
|
import { n as sha256, t as bytesToBase64Url } from "../sha256-BO0swRXL.js";
|
|
4
4
|
import { t as anonymousSubject } from "../subject-C6dLxqHU.js";
|
|
5
|
-
import { i as linkPolicyViolation, o as parseCapability, s as redeemerAllows, t as capabilitySubject } from "../capability-
|
|
6
|
-
import { a as decodeHeader, i as issuerFromDiscovery, n as assertSubjectConfig, o as normalizeTyp, r as fail, t as joseTokenVerifier } from "../verifier-
|
|
5
|
+
import { i as linkPolicyViolation, o as parseCapability, s as redeemerAllows, t as capabilitySubject } from "../capability-4qPdO9gk.js";
|
|
6
|
+
import { a as decodeHeader, i as issuerFromDiscovery, n as assertSubjectConfig, o as normalizeTyp, r as fail, t as joseTokenVerifier } from "../verifier-BxBo6I44.js";
|
|
7
7
|
import { t as loadJose } from "../load-jose-BL6LH4bL.js";
|
|
8
|
-
import { n as mapClaimsToSubject, r as validateCustomClaims, t as acceptMismatch } from "../map-claims-
|
|
8
|
+
import { n as mapClaimsToSubject, r as validateCustomClaims, t as acceptMismatch } from "../map-claims-Z4QZOiFF.js";
|
|
9
|
+
import { t as memoryReplayStore } from "../replay-BsOyTrdV.js";
|
|
9
10
|
//#region src/jwt/capability.ts
|
|
10
11
|
function emit(options, reason, cause, token) {
|
|
11
12
|
if (options.onAuth === void 0) return;
|
|
@@ -237,15 +238,23 @@ const PRIVATE_MEMBERS = [
|
|
|
237
238
|
function headerOf(request) {
|
|
238
239
|
return request.headers.get("DPoP") ?? request.headers.get("dpop");
|
|
239
240
|
}
|
|
240
|
-
function
|
|
241
|
-
|
|
241
|
+
function withoutQuery(value) {
|
|
242
|
+
if (typeof value !== "string" || !URL.canParse(value)) return null;
|
|
243
|
+
const url = new URL(value);
|
|
244
|
+
url.search = "";
|
|
242
245
|
url.hash = "";
|
|
243
246
|
return url.href;
|
|
244
247
|
}
|
|
245
|
-
function
|
|
246
|
-
return
|
|
248
|
+
async function claimJti(replay, key, expiresAt) {
|
|
249
|
+
if (replay.claim !== void 0) return replay.claim(key, expiresAt);
|
|
250
|
+
if (await replay.seen(key)) return false;
|
|
251
|
+
await replay.remember(key, expiresAt);
|
|
252
|
+
return true;
|
|
253
|
+
}
|
|
254
|
+
function verifyDpopProof(request, claims, accessToken, options = {}) {
|
|
255
|
+
return verify(request, claims, accessToken, options);
|
|
247
256
|
}
|
|
248
|
-
async function verify(request, claims, accessToken) {
|
|
257
|
+
async function verify(request, claims, accessToken, options) {
|
|
249
258
|
const proof = headerOf(request);
|
|
250
259
|
if (proof === null || proof.length === 0) return {
|
|
251
260
|
ok: false,
|
|
@@ -273,13 +282,15 @@ async function verify(request, claims, accessToken) {
|
|
|
273
282
|
typ: "dpop+jwt",
|
|
274
283
|
maxTokenAge: DPOP_WINDOW_SECONDS
|
|
275
284
|
});
|
|
276
|
-
|
|
285
|
+
const jkt = await jose.calculateJwkThumbprint(jwk, "sha256");
|
|
286
|
+
if (jkt !== expectedJkt) return {
|
|
277
287
|
ok: false,
|
|
278
288
|
cause: "dpop-proof-invalid"
|
|
279
289
|
};
|
|
280
290
|
const htm = result.payload["htm"];
|
|
281
291
|
const htu = result.payload["htu"];
|
|
282
|
-
|
|
292
|
+
const expectedHtu = withoutQuery(request.url);
|
|
293
|
+
if (htm !== request.method || expectedHtu === null || withoutQuery(htu) !== expectedHtu) return {
|
|
283
294
|
ok: false,
|
|
284
295
|
cause: "dpop-proof-invalid"
|
|
285
296
|
};
|
|
@@ -290,6 +301,14 @@ async function verify(request, claims, accessToken) {
|
|
|
290
301
|
cause: "dpop-proof-invalid"
|
|
291
302
|
};
|
|
292
303
|
}
|
|
304
|
+
if (options.replay !== void 0) {
|
|
305
|
+
const jti = result.payload.jti;
|
|
306
|
+
const iat = result.payload.iat;
|
|
307
|
+
if (typeof jti !== "string" || jti === "" || typeof iat !== "number" || !await claimJti(options.replay, `dpop\u0000${jkt}\u0000${jti}`, iat + DPOP_WINDOW_SECONDS)) return {
|
|
308
|
+
ok: false,
|
|
309
|
+
cause: "dpop-proof-invalid"
|
|
310
|
+
};
|
|
311
|
+
}
|
|
293
312
|
return { ok: true };
|
|
294
313
|
} catch {
|
|
295
314
|
return {
|
|
@@ -541,7 +560,7 @@ async function resolveSubject(token, options, request) {
|
|
|
541
560
|
const proof = request === void 0 ? {
|
|
542
561
|
ok: false,
|
|
543
562
|
cause: "dpop-proof-invalid"
|
|
544
|
-
} : await verifyDpopProof(request, verified.claims, token);
|
|
563
|
+
} : await verifyDpopProof(request, verified.claims, token, compact({ replay: options.replay }));
|
|
545
564
|
if (!proof.ok) {
|
|
546
565
|
emitAuth(options, proof.cause, token);
|
|
547
566
|
return anonymousSubject();
|
|
@@ -568,4 +587,4 @@ async function resolveSubject(token, options, request) {
|
|
|
568
587
|
return extraMemberships(options, mapped.subject, mapped.subject.principal.tenant);
|
|
569
588
|
}
|
|
570
589
|
//#endregion
|
|
571
|
-
export { createJwtSubjectResolver, joseTokenSigner, joseTokenVerifier, subjectFromCapability, subjectFromCiOidc, subjectFromIntrospection, subjectFromJwt, verifyDpopProof };
|
|
590
|
+
export { createJwtSubjectResolver, joseTokenSigner, joseTokenVerifier, memoryReplayStore, subjectFromCapability, subjectFromCiOidc, subjectFromIntrospection, subjectFromJwt, verifyDpopProof };
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { t as compact } from "./compact-y6vfu2_f.js";
|
|
2
|
+
import { t as describe } from "./describe-B_gVZEVi.js";
|
|
3
|
+
import { a as deniedMessage } from "./errors-Cz5zn0mW.js";
|
|
4
|
+
import { t as createPermDock } from "./permdock-CbgvLnuo.js";
|
|
5
|
+
import { n as resourceRef } from "./resource-ref-CaS9yVPi.js";
|
|
6
|
+
import { t as mayUse } from "./may-use-DndQ5tQ-.js";
|
|
7
|
+
import { l as storedApprovalToken, s as resumeDecision } from "./helpers-H_KARDVC.js";
|
|
8
|
+
import { t as instanceOptions } from "./instance-options-Dhhcnm3y.js";
|
|
9
|
+
import { n as tenantScope, t as actorFrom } from "./adapter-context-mlWsVGGg.js";
|
|
10
|
+
//#region src/agent/reason.ts
|
|
11
|
+
function modelReason(decision, permission, subjectId) {
|
|
12
|
+
if (decision.outcome === "denied") return deniedMessage(permission?.key ?? "unknown", subjectId, decision.denials, decision.alternatives.map((leaf) => leaf.key));
|
|
13
|
+
return describe(decision).detail;
|
|
14
|
+
}
|
|
15
|
+
function unmappedReason(toolName) {
|
|
16
|
+
return `Denied: unmapped tool ${toolName}.`;
|
|
17
|
+
}
|
|
18
|
+
function thrownReason(toolName) {
|
|
19
|
+
return `Denied: ${toolName} failed closed.`;
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/agent/kernel.ts
|
|
23
|
+
/** The resume token an agent run carries under the namespaced `permdockApproval` key. */
|
|
24
|
+
function approvalTokenOf(context) {
|
|
25
|
+
if (context === null || typeof context !== "object") return;
|
|
26
|
+
const token = context.permdockApproval;
|
|
27
|
+
return typeof token === "string" && token !== "" ? token : void 0;
|
|
28
|
+
}
|
|
29
|
+
function runDecide(permdock, permission, data, how) {
|
|
30
|
+
return permdock.decide(permission, data, how);
|
|
31
|
+
}
|
|
32
|
+
function createAgentKernel(policy, options) {
|
|
33
|
+
const cache = /* @__PURE__ */ new WeakMap();
|
|
34
|
+
const instance = (context) => {
|
|
35
|
+
if (typeof context === "object" && context !== null) {
|
|
36
|
+
const hit = cache.get(context);
|
|
37
|
+
if (hit !== void 0) return hit;
|
|
38
|
+
}
|
|
39
|
+
const built = (async () => {
|
|
40
|
+
let user = null;
|
|
41
|
+
try {
|
|
42
|
+
user = await options.subject(context);
|
|
43
|
+
} catch {
|
|
44
|
+
user = null;
|
|
45
|
+
}
|
|
46
|
+
const actor = await actorFrom(options.actor, context);
|
|
47
|
+
let delegation;
|
|
48
|
+
if (options.delegation !== void 0) try {
|
|
49
|
+
delegation = await options.delegation(context);
|
|
50
|
+
} catch {
|
|
51
|
+
delegation = void 0;
|
|
52
|
+
}
|
|
53
|
+
const { tenant } = await tenantScope(options.tenant, context);
|
|
54
|
+
const created = await createPermDock(policy, user, compact({
|
|
55
|
+
tenant,
|
|
56
|
+
actor,
|
|
57
|
+
delegation,
|
|
58
|
+
...instanceOptions(options)
|
|
59
|
+
}));
|
|
60
|
+
return options.wrap?.(created) ?? created;
|
|
61
|
+
})();
|
|
62
|
+
if (typeof context === "object" && context !== null) {
|
|
63
|
+
cache.set(context, built);
|
|
64
|
+
const release = () => {
|
|
65
|
+
if (cache.get(context) === built) cache.delete(context);
|
|
66
|
+
};
|
|
67
|
+
built.then(release, release);
|
|
68
|
+
}
|
|
69
|
+
return built;
|
|
70
|
+
};
|
|
71
|
+
const boundary = options.boundary ?? "tool-args";
|
|
72
|
+
const tools = options.tools ?? {};
|
|
73
|
+
const run = async (binding, args, context, how) => {
|
|
74
|
+
let permdock;
|
|
75
|
+
try {
|
|
76
|
+
permdock = await instance(context);
|
|
77
|
+
let data;
|
|
78
|
+
if (binding.data !== void 0) {
|
|
79
|
+
try {
|
|
80
|
+
data = await binding.data(args);
|
|
81
|
+
} catch {
|
|
82
|
+
return {
|
|
83
|
+
ok: false,
|
|
84
|
+
failure: "load-failed",
|
|
85
|
+
permdock
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
if (binding.permission.kind === "instance" && (data === null || data === void 0)) return {
|
|
89
|
+
ok: false,
|
|
90
|
+
failure: "no-data",
|
|
91
|
+
permdock
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
const raw = runDecide(permdock, binding.permission, data, {
|
|
95
|
+
adapter: options.adapter,
|
|
96
|
+
boundary,
|
|
97
|
+
source: how.source
|
|
98
|
+
});
|
|
99
|
+
const decision = how.resume ? await resumeDecision({
|
|
100
|
+
decision: raw,
|
|
101
|
+
permission: binding.permission,
|
|
102
|
+
subject: permdock.subject,
|
|
103
|
+
store: options.store,
|
|
104
|
+
resource: resourceRef(binding.permission, data),
|
|
105
|
+
adapter: options.adapter,
|
|
106
|
+
token: how.decideOptions.resumeToken ?? await storedApprovalToken(options.store, raw, { denyPending: how.decideOptions.denyPending === true })
|
|
107
|
+
}) : raw;
|
|
108
|
+
return {
|
|
109
|
+
ok: true,
|
|
110
|
+
permdock,
|
|
111
|
+
data,
|
|
112
|
+
raw,
|
|
113
|
+
decision
|
|
114
|
+
};
|
|
115
|
+
} catch {
|
|
116
|
+
return compact({
|
|
117
|
+
ok: false,
|
|
118
|
+
failure: "failed",
|
|
119
|
+
permdock
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
const check = (binding, args, context, checkOptions = {}) => run(binding, args, context, {
|
|
124
|
+
resume: checkOptions.simulate !== true,
|
|
125
|
+
source: checkOptions.simulate === true ? "simulate" : "adapter",
|
|
126
|
+
decideOptions: checkOptions
|
|
127
|
+
});
|
|
128
|
+
const evaluate = async (binding, toolName, args, context, decideOptions = {}) => {
|
|
129
|
+
const checked = await check(binding, args, context, decideOptions);
|
|
130
|
+
if (!checked.ok) {
|
|
131
|
+
if (checked.failure !== "no-data" || checked.permdock === void 0) return {
|
|
132
|
+
outcome: "denied",
|
|
133
|
+
decision: null,
|
|
134
|
+
permission: binding.permission,
|
|
135
|
+
reason: thrownReason(toolName)
|
|
136
|
+
};
|
|
137
|
+
const decision = {
|
|
138
|
+
outcome: "denied",
|
|
139
|
+
denials: [{
|
|
140
|
+
role: null,
|
|
141
|
+
reason: "validation"
|
|
142
|
+
}],
|
|
143
|
+
alternatives: []
|
|
144
|
+
};
|
|
145
|
+
return {
|
|
146
|
+
outcome: "denied",
|
|
147
|
+
decision,
|
|
148
|
+
permission: binding.permission,
|
|
149
|
+
reason: modelReason(decision, binding.permission, checked.permdock.subject.principal?.id)
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
const { permdock, decision, data } = checked;
|
|
153
|
+
if (decision.outcome === "granted") return {
|
|
154
|
+
outcome: "granted",
|
|
155
|
+
decision,
|
|
156
|
+
permission: binding.permission,
|
|
157
|
+
data
|
|
158
|
+
};
|
|
159
|
+
if (decision.outcome === "approval-required") return {
|
|
160
|
+
outcome: "approval-required",
|
|
161
|
+
decision,
|
|
162
|
+
permission: binding.permission,
|
|
163
|
+
data,
|
|
164
|
+
token: decision.token,
|
|
165
|
+
summary: modelReason(decision, binding.permission, permdock.subject.principal?.id)
|
|
166
|
+
};
|
|
167
|
+
return {
|
|
168
|
+
outcome: "denied",
|
|
169
|
+
decision,
|
|
170
|
+
permission: binding.permission,
|
|
171
|
+
reason: modelReason(decision, binding.permission, permdock.subject.principal?.id)
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
const tokenFor = async (binding, args, context) => {
|
|
175
|
+
const checked = await run(binding, args, context, {
|
|
176
|
+
resume: false,
|
|
177
|
+
source: "adapter",
|
|
178
|
+
decideOptions: {}
|
|
179
|
+
});
|
|
180
|
+
return checked.ok && checked.raw.outcome === "approval-required" ? checked.raw.token : void 0;
|
|
181
|
+
};
|
|
182
|
+
const decideTool = (toolName, args, context, decideOptions = {}) => {
|
|
183
|
+
const binding = Object.hasOwn(tools, toolName) ? tools[toolName] : void 0;
|
|
184
|
+
if (binding === void 0) return Promise.resolve({
|
|
185
|
+
outcome: "denied",
|
|
186
|
+
decision: null,
|
|
187
|
+
permission: void 0,
|
|
188
|
+
reason: unmappedReason(toolName)
|
|
189
|
+
});
|
|
190
|
+
return evaluate(binding, toolName, args, context, decideOptions);
|
|
191
|
+
};
|
|
192
|
+
const allowedToolNames = async (context) => {
|
|
193
|
+
const permdock = await instance(context);
|
|
194
|
+
const allowed = /* @__PURE__ */ new Set();
|
|
195
|
+
for (const [name, binding] of Object.entries(tools)) if (mayUse(permdock, binding.permission)) allowed.add(name);
|
|
196
|
+
return allowed;
|
|
197
|
+
};
|
|
198
|
+
return {
|
|
199
|
+
instance,
|
|
200
|
+
decideTool,
|
|
201
|
+
evaluate,
|
|
202
|
+
check,
|
|
203
|
+
tokenFor,
|
|
204
|
+
allowedToolNames
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
//#endregion
|
|
208
|
+
export { createAgentKernel as n, approvalTokenOf as t };
|
package/dist/kysely/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { Ir as Condition, Pr as Subject, mn as WhereResult } from "../policy-IB6yxpC3.js";
|
|
2
|
+
import { r as RelationsMapping } from "../graph-sql-B-dsAT6j.js";
|
|
3
|
+
import { s as MembershipsMapping } from "../compile-BkRyBDBw.js";
|
|
4
|
+
import { n as WithSubjectOptions, t as RowCheck } from "../row-check-Dt35czLy.js";
|
|
4
5
|
//#region src/kysely/types.d.ts
|
|
5
6
|
type KyselySelectQuery = {
|
|
6
7
|
select(expr: unknown): KyselySelectQuery;
|
package/dist/kysely/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as compact } from "../compact-y6vfu2_f.js";
|
|
2
|
-
import {
|
|
3
|
-
import { n as escapeLike, t as compileWhere } from "../compile-
|
|
4
|
-
import { i as rowCheckFrom, r as subjectStatements, t as statementTemplate } from "../subject-settings-
|
|
2
|
+
import { w as assertSafeKey } from "../permissions-DVoF6dMt.js";
|
|
3
|
+
import { n as escapeLike, t as compileWhere } from "../compile-Ba4blROR.js";
|
|
4
|
+
import { i as rowCheckFrom, r as subjectStatements, t as statementTemplate } from "../subject-settings-BwBmCdTR.js";
|
|
5
5
|
//#region src/kysely/to-where.ts
|
|
6
6
|
function ident(name) {
|
|
7
7
|
assertSafeKey(name, "sql identifier");
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { createContext, useLayoutEffect, useRef, useState } from "react";
|
|
2
|
+
//#region src/react/context.ts
|
|
3
|
+
const PermDockStoreContext = createContext(null);
|
|
4
|
+
const PermDockSnapshotPromiseContext = createContext(null);
|
|
5
|
+
//#endregion
|
|
6
|
+
//#region src/react/keyed.ts
|
|
7
|
+
/**
|
|
8
|
+
* `create()` once per distinct `inputs`, held in state: React may drop a
|
|
9
|
+
* `useMemo` value and rebuild it, and a rebuilt store loses its answers,
|
|
10
|
+
* polls and followed snapshot.
|
|
11
|
+
*/
|
|
12
|
+
function useKeyed(create, inputs) {
|
|
13
|
+
const [held, setHeld] = useState(() => ({
|
|
14
|
+
inputs,
|
|
15
|
+
value: create()
|
|
16
|
+
}));
|
|
17
|
+
if (held.inputs.length === inputs.length && held.inputs.every((input, index) => Object.is(input, inputs[index]))) return held.value;
|
|
18
|
+
const next = {
|
|
19
|
+
inputs,
|
|
20
|
+
value: create()
|
|
21
|
+
};
|
|
22
|
+
setHeld(next);
|
|
23
|
+
return next.value;
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/react/live-options.ts
|
|
27
|
+
function sameHeaders(a, b) {
|
|
28
|
+
if (a === b) return true;
|
|
29
|
+
if (a === void 0 || b === void 0) return false;
|
|
30
|
+
const keys = Object.keys(a);
|
|
31
|
+
return keys.length === Object.keys(b).length && keys.every((key) => Object.hasOwn(b, key) && a[key] === b[key]);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Store options whose identity survives a re-render, so an inline `headers`
|
|
35
|
+
* object or `fetch` arrow does not rebuild the store and drop its snapshot.
|
|
36
|
+
* `headers` compare by value, unless `headersByValue` is `false` for a store
|
|
37
|
+
* that only reads `readHeaders`; `fetch` and `verifier` call the latest prop.
|
|
38
|
+
*/
|
|
39
|
+
function useLiveOptions(props, headersByValue = true) {
|
|
40
|
+
const latest = useRef(props);
|
|
41
|
+
useLayoutEffect(() => {
|
|
42
|
+
latest.current = props;
|
|
43
|
+
});
|
|
44
|
+
const [headers, setHeaders] = useState(props.headers);
|
|
45
|
+
if (headersByValue && !sameHeaders(headers, props.headers)) setHeaders(props.headers);
|
|
46
|
+
const [readHeaders] = useState(() => () => latest.current.headers);
|
|
47
|
+
const [liveFetch] = useState(() => (...args) => (latest.current.fetch ?? fetch)(...args));
|
|
48
|
+
const [liveVerifier] = useState(() => ({ verify: (token, expectations) => {
|
|
49
|
+
const verifier = latest.current.verifier;
|
|
50
|
+
return verifier === void 0 ? Promise.reject(/* @__PURE__ */ new Error("PermDock: the verifier prop was removed.")) : verifier.verify(token, expectations);
|
|
51
|
+
} }));
|
|
52
|
+
return {
|
|
53
|
+
headers,
|
|
54
|
+
readHeaders,
|
|
55
|
+
fetch: liveFetch,
|
|
56
|
+
verifier: props.verifier === void 0 ? void 0 : liveVerifier
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
export { PermDockStoreContext as i, useKeyed as n, PermDockSnapshotPromiseContext as r, useLiveOptions as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as listPermissions } from "./permissions-DVoF6dMt.js";
|
|
2
2
|
import { dirname, resolve } from "node:path";
|
|
3
3
|
import { pathToFileURL } from "node:url";
|
|
4
4
|
import { createJiti } from "jiti";
|
|
@@ -19,6 +19,15 @@ function loadsWithJiti(error) {
|
|
|
19
19
|
const code = error !== null && typeof error === "object" && "code" in error ? error.code : void 0;
|
|
20
20
|
return typeof code === "string" && NOT_NATIVE.has(code);
|
|
21
21
|
}
|
|
22
|
+
function importWithJiti(abs, fresh) {
|
|
23
|
+
return createJiti(import.meta.url, {
|
|
24
|
+
interopDefault: false,
|
|
25
|
+
jsx: true,
|
|
26
|
+
tsconfigPaths: dirname(abs),
|
|
27
|
+
moduleCache: !fresh,
|
|
28
|
+
fsCache: !fresh
|
|
29
|
+
}).import(abs);
|
|
30
|
+
}
|
|
22
31
|
/**
|
|
23
32
|
* Imports a project module the way its bundler would. Node's own `import()`
|
|
24
33
|
* comes first; a module it cannot resolve or parse (tsconfig `paths`
|
|
@@ -26,17 +35,14 @@ function loadsWithJiti(error) {
|
|
|
26
35
|
* with the `paths` of the nearest `tsconfig.json` above it. Exports are
|
|
27
36
|
* returned as written; `default` is not merged into the namespace.
|
|
28
37
|
*/
|
|
29
|
-
async function loadModule(abs) {
|
|
38
|
+
async function loadModule(abs, options) {
|
|
30
39
|
let loaded;
|
|
31
|
-
|
|
40
|
+
if (options?.fresh === true) loaded = await importWithJiti(abs, true);
|
|
41
|
+
else try {
|
|
32
42
|
loaded = await import(pathToFileURL(abs).href);
|
|
33
43
|
} catch (error) {
|
|
34
44
|
if (!loadsWithJiti(error)) throw error;
|
|
35
|
-
loaded = await
|
|
36
|
-
interopDefault: false,
|
|
37
|
-
jsx: true,
|
|
38
|
-
tsconfigPaths: dirname(abs)
|
|
39
|
-
}).import(abs);
|
|
45
|
+
loaded = await importWithJiti(abs, false);
|
|
40
46
|
}
|
|
41
47
|
if (loaded === null || typeof loaded !== "object") throw new Error(`PermDock CLI: module '${abs}' did not export an object`);
|
|
42
48
|
return loaded;
|
|
@@ -57,10 +63,10 @@ function leavesOf(tree) {
|
|
|
57
63
|
return listPermissions(tree);
|
|
58
64
|
}
|
|
59
65
|
/** The configured policy export, or `undefined` when unset or unloadable. */
|
|
60
|
-
async function loadConfiguredPolicy(cwd, path) {
|
|
66
|
+
async function loadConfiguredPolicy(cwd, path, options) {
|
|
61
67
|
if (path === void 0) return;
|
|
62
68
|
try {
|
|
63
|
-
return asPolicy(pickNamed(await loadModule(resolve(cwd, path)), ["policy"]));
|
|
69
|
+
return asPolicy(pickNamed(await loadModule(resolve(cwd, path), options), ["policy"]));
|
|
64
70
|
} catch {
|
|
65
71
|
return;
|
|
66
72
|
}
|