@kabmo-labs/kabmo 0.33.0 → 0.35.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/client/index.html +1 -1
- package/dist/client/index.js +785 -624
- package/dist/client/static/js/{CsvGrid-fncjbg6j.js → CsvGrid-0amzgtd7.js} +2 -2
- package/dist/client/static/js/{DocxView-c9v2vr3r.js → DocxView-bxjhzxe9.js} +5 -5
- package/dist/client/static/js/{DrawioView-vxjksm12.js → DrawioView-7s1yqsf4.js} +2 -2
- package/dist/client/static/js/{ImageView-a3g5k226.js → ImageView-ycfbn66h.js} +1 -1
- package/dist/client/static/js/{LayoutWrapper-hnjfwsjh.js → LayoutWrapper-tw1q1x0g.js} +2 -2
- package/dist/client/static/js/Modal-wqjactyd.js +38 -0
- package/dist/client/static/js/{PdfView-ksaes53y.js → PdfView-x6dmtwvr.js} +1 -1
- package/dist/client/static/js/{SessionsView-30vcr95v.js → SessionsView-t85wq0me.js} +1 -1
- package/dist/client/static/js/{SheetView-vc484scg.js → SheetView-n52nvz8s.js} +25 -25
- package/dist/client/static/js/{SvgPreview-tph89jet.js → SvgPreview-59z7syme.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-xbar278c.js → abnfDiagram-O67JEVCF-91gnt049.js} +1 -1
- package/dist/client/static/js/architecture-7GRP2DOG-bajpnvy7.js +1 -0
- package/dist/client/static/js/{architectureDiagram-NJMV4G6O-s171n2z6.js → architectureDiagram-NJMV4G6O-5b9qtff2.js} +4 -4
- package/dist/client/static/js/{astro-80bs6hvg.js → astro-31cbyw7b.js} +1 -1
- package/dist/client/static/js/bash-0h36tk0k.js +1 -0
- package/dist/client/static/js/{blockDiagram-BEXU5L5S-gzx6rv9n.js → blockDiagram-BEXU5L5S-6f23fjkn.js} +3 -3
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-7f00skch.js → c4Diagram-YGBWAQC7-76t6d3am.js} +5 -5
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-j79v95nc.js → classDiagram-v2-NBCMYWYE-f9tb19xm.js} +3 -3
- package/dist/client/static/js/{cose-bilkent-JH36ORCC-5fkn7ee5.js → cose-bilkent-JH36ORCC-t6nwrbwj.js} +1 -1
- package/dist/client/static/js/cpp-4wp9sy20.js +1 -0
- package/dist/client/static/js/css-c9nsbkh6.js +1 -0
- package/dist/client/static/js/cynefin-OW5HDTMX-8q9e90m8.js +1 -0
- package/dist/client/static/js/{cynefinDiagram-VND7K2PF-cfs1yvrd.js → cynefinDiagram-VND7K2PF-69gc244j.js} +1 -1
- package/dist/client/static/js/{dagre-6A5THRUB-44bgc48p.js → dagre-6A5THRUB-54bry3ey.js} +2 -2
- package/dist/client/static/js/{diagram-22UHCM2B-a4g4x83k.js → diagram-22UHCM2B-gfkebye6.js} +11 -11
- package/dist/client/static/js/{diagram-3UASUU5V-gm4rg5na.js → diagram-3UASUU5V-a1mr319f.js} +1 -1
- package/dist/client/static/js/{diagram-ATOU4E4O-a95y41vk.js → diagram-ATOU4E4O-tkyk0qbe.js} +3 -3
- package/dist/client/static/js/{diagram-CDSNMT55-t3j93mmc.js → diagram-CDSNMT55-np0hc9m2.js} +4 -4
- package/dist/client/static/js/{diagram-MLGK6HIB-c2wdez02.js → diagram-MLGK6HIB-nh06fshp.js} +2 -2
- package/dist/client/static/js/{diagram-MPIPVDR6-gya9jhs5.js → diagram-MPIPVDR6-27q2veks.js} +2 -2
- package/dist/client/static/js/{dockerfile-a7q6174s.js → dockerfile-4rtt6c0f.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-jjhkza6t.js → ebnfDiagram-ZINNZB2B-x9p9jqe8.js} +1 -1
- package/dist/client/static/js/{elk-276RUBZZ-f7re45mw.js → elk-276RUBZZ-fw7waks3.js} +1 -1
- package/dist/client/static/js/{erDiagram-OPXOYQCR-tpm9g5te.js → erDiagram-OPXOYQCR-fdfgzr5d.js} +5 -5
- package/dist/client/static/js/{erlang-qt876zrq.js → erlang-trjm07as.js} +1 -1
- package/dist/client/static/js/eventmodeling-NTZA5JFV-kn4hsm3p.js +1 -0
- package/dist/client/static/js/flowDiagram-KWPJA3E3-ah8cvps1.js +1 -0
- package/dist/client/static/js/{ganttDiagram-FUAMR5RP-fz43n12d.js → ganttDiagram-FUAMR5RP-2avbqgdr.js} +3 -3
- package/dist/client/static/js/gitGraph-4MIJSDKK-hvavh16n.js +1 -0
- package/dist/client/static/js/{gitGraphDiagram-X574FWY7-f61hgbn6.js → gitGraphDiagram-X574FWY7-9jmc0a3g.js} +12 -12
- package/dist/client/static/js/graphql-hbkmxsty.js +1 -0
- package/dist/client/static/js/{index-8239j2v1.js → index-0v34a7wf.js} +1 -1
- package/dist/client/static/js/{index-vtbbfwx0.js → index-1wjp16f0.js} +2 -2
- package/dist/client/static/js/index-2mx9ej4k.css +1 -0
- package/dist/client/static/js/{index-q2w6s8n7.js → index-2v1nmxwr.js} +6 -6
- package/dist/client/static/js/{index-apvkd37e.js → index-3ecsp1rx.js} +3 -3
- package/dist/client/static/js/{index-1y9r4frb.js → index-43qpbxjv.js} +2 -2
- package/dist/client/static/js/{index-w0fwb80e.js → index-4vybd9e7.js} +1 -1
- package/dist/client/static/js/{index-ahv9y42z.js → index-6f6cmcbq.js} +2 -2
- package/dist/client/static/js/{index-9fjt5anh.js → index-7ct7qrsp.js} +2 -2
- package/dist/client/static/js/{index-ajs3jj6j.js → index-7q02xnvq.js} +1 -1
- package/dist/client/static/js/{index-rytaa8ca.js → index-7smwzkvq.js} +2 -2
- package/dist/client/static/js/{index-rg8jpbsw.js → index-8acv5b77.js} +2 -2
- package/dist/client/static/js/{index-gs6f0qwa.js → index-8f9x7ev8.js} +2 -2
- package/dist/client/static/js/{index-7y6rpsrp.js → index-8mwragbj.js} +2 -2
- package/dist/client/static/js/{index-gcs49f3p.js → index-8x9ecxb0.js} +1 -1
- package/dist/client/static/js/{index-3rcjx70v.js → index-9ketbkh6.js} +1 -1
- package/dist/client/static/js/{index-ypx3qmhq.js → index-a628fg4m.js} +2 -2
- package/dist/client/static/js/{index-e4p4cd3r.js → index-a8ffattk.js} +2 -2
- package/dist/client/static/js/{index-js7t1vb1.js → index-b8s3xraa.js} +6 -6
- package/dist/client/static/js/index-btr2w8cq.js +12 -0
- package/dist/client/static/js/index-dfzrpy54.js +2 -0
- package/dist/client/static/js/{index-pxv2nw9w.js → index-ee2p07eg.js} +1 -1
- package/dist/client/static/js/{index-03h3bkcf.js → index-ek2e773p.js} +1 -1
- package/dist/client/static/js/{index-1xqs14fr.js → index-fvc0x6nx.js} +3 -3
- package/dist/client/static/js/{index-3zc1b0dv.js → index-jc1yagmk.js} +2 -2
- package/dist/client/static/js/{index-d495kfm0.js → index-jmxqefe3.js} +1 -1
- package/dist/client/static/js/{index-2x5f66t6.js → index-k7q01ye4.js} +2 -2
- package/dist/client/static/js/{index-5tgq7aqx.js → index-kdkfyrja.js} +2 -2
- package/dist/client/static/js/{index-m73za75e.js → index-mc4nefs7.js} +3 -3
- package/dist/client/static/js/{index-trm9x02n.js → index-nb8tp4mj.js} +30 -30
- package/dist/client/static/js/{index-zt75xpq0.js → index-ncrenheb.js} +206 -206
- package/dist/client/static/js/{index-qsm2z36d.js → index-p16scjt7.js} +2 -2
- package/dist/client/static/js/{index-sdtye3jy.js → index-pc6eg8h2.js} +2 -2
- package/dist/client/static/js/{index-zvfvqvn9.js → index-pnt0vc59.js} +2 -2
- package/dist/client/static/js/{index-pbe4yed4.js → index-py2k8std.js} +2 -2
- package/dist/client/static/js/{index-dbe6afkf.js → index-pzbssnsc.js} +2 -2
- package/dist/client/static/js/{index-qckv9nte.js → index-qqz6bcdd.js} +2 -2
- package/dist/client/static/js/{index-xj9649ac.js → index-ray2czf6.js} +7 -7
- package/dist/client/static/js/{index-0tf0arsp.js → index-rbgemjsp.js} +3 -3
- package/dist/client/static/js/{index-vw4brsdx.js → index-rkn0bxxt.js} +1 -1
- package/dist/client/static/js/{index-76zb4m0n.js → index-rv89xpaf.js} +2 -2
- package/dist/client/static/js/index-sbd5e816.js +1 -0
- package/dist/client/static/js/{index-eyzeya95.js → index-sdby39w4.js} +5 -5
- package/dist/client/static/js/{index-0n5wwe60.js → index-t6c0pd43.js} +2 -2
- package/dist/client/static/js/{index-km2zb6wk.js → index-tp7yb3bv.js} +2 -2
- package/dist/client/static/js/{index-vw5k8csz.js → index-vnw3hbeg.js} +56 -56
- package/dist/client/static/js/{index-354mqqra.js → index-vq6wts05.js} +2 -2
- package/dist/client/static/js/{index-14vndmcr.js → index-w5373tg1.js} +2 -2
- package/dist/client/static/js/{index-0e40xskg.js → index-w7tpgt46.js} +1 -1
- package/dist/client/static/js/{index-djmg1d7h.js → index-whbtxmwh.js} +2 -2
- package/dist/client/static/js/{index-2svnq5gg.js → index-xs1m0bpt.js} +1 -1
- package/dist/client/static/js/{index-9y3gjdj7.js → index-xxtsm2rb.js} +2 -2
- package/dist/client/static/js/{index-hf52f59k.js → index-y3ms153k.js} +2 -2
- package/dist/client/static/js/{index-1a0zkj8h.js → index-yq39qbs1.js} +2 -2
- package/dist/client/static/js/{index-j0r5hj0j.js → index-zh2jj56s.js} +2 -2
- package/dist/client/static/js/info-A6RAGUB7-fmjz8qwg.js +1 -0
- package/dist/client/static/js/{infoDiagram-VRGFBTTK-1qj804sn.js → infoDiagram-VRGFBTTK-g2dky5xg.js} +2 -2
- package/dist/client/static/js/ini-72yrpvd4.js +1 -0
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-4j4qsnzw.js → ishikawaDiagram-OU5B5YK6-exrcjwp1.js} +6 -6
- package/dist/client/static/js/java-ab5tb2ra.js +1 -0
- package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-j0brnfft.js → journeyDiagram-ZHPQQLJL-pn752qa5.js} +4 -4
- package/dist/client/static/js/jsx-25zj9j3k.js +1 -0
- package/dist/client/static/js/{julia-4ghmfy3e.js → julia-evn99h2m.js} +1 -1
- package/dist/client/static/js/{kanban-definition-PNTS6WVX-qqc22br0.js → kanban-definition-PNTS6WVX-v8nvr373.js} +5 -5
- package/dist/client/static/js/lua-j5w0c9wm.js +1 -0
- package/dist/client/static/js/markdown-j6hn4377.js +1 -0
- package/dist/client/static/js/{mermaid.core-vv3wbe65.js → mermaid.core-egzv89zv.js} +6 -6
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-y5b2z8zp.js → mindmap-definition-NLK3R4M7-t9njmv2w.js} +8 -8
- package/dist/client/static/js/one-dark-pro-bm3r4js7.js +1 -0
- package/dist/client/static/js/one-light-e07dt7sy.js +1 -0
- package/dist/client/static/js/packet-AYTQ26CC-cwr6n1cm.js +1 -0
- package/dist/client/static/js/{pegDiagram-GJSIUBJH-0be07mqs.js → pegDiagram-GJSIUBJH-zhycy2b7.js} +1 -1
- package/dist/client/static/js/{perl-sd00t4b4.js → perl-506fy8m8.js} +1 -1
- package/dist/client/static/js/{php-2zfyqa61.js → php-axtsvxck.js} +1 -1
- package/dist/client/static/js/pie-WAS4IAKB-h1ebfzgt.js +1 -0
- package/dist/client/static/js/{pieDiagram-5QR66LMP-544w86jk.js → pieDiagram-5QR66LMP-sgctvma2.js} +2 -2
- package/dist/client/static/js/properties-q8njes42.js +1 -0
- package/dist/client/static/js/python-vqxc7181.js +1 -0
- package/dist/client/static/js/{quadrantDiagram-O4NWA36T-p09e7z5s.js → quadrantDiagram-O4NWA36T-kzzhdcph.js} +5 -5
- package/dist/client/static/js/r-0k5eej8m.js +1 -0
- package/dist/client/static/js/radar-RG4KPBEZ-k7p1m364.js +1 -0
- package/dist/client/static/js/railroad-74A4TZTK-d08dw3t0.js +1 -0
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-txnjycgk.js +1 -0
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-p0r3cv6w.js +1 -0
- package/dist/client/static/js/railroad-peg-WCYAUIDC-sryk900a.js +1 -0
- package/dist/client/static/js/{railroadDiagram-XR7U4H2S-de830ed2.js → railroadDiagram-XR7U4H2S-nzjffwxm.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-b47d74p1.js → requirementDiagram-PLB6GJNP-tz4xxn4d.js} +2 -2
- package/dist/client/static/js/{ruby-v9qaqhby.js → ruby-qp7zfk2m.js} +1 -1
- package/dist/client/static/js/{rust-fkt0qyrs.js → rust-fz913fvw.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-6ezc2fpj.js → sankeyDiagram-IPEJSGJF-2wcb0xr6.js} +4 -4
- package/dist/client/static/js/{sass-9bxped7y.js → sass-gnk9vsyp.js} +1 -1
- package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-by5zqj6w.js → sequenceDiagram-PO4LG4MO-vqgebfns.js} +18 -18
- package/dist/client/static/js/{sizeCapture-INFHLROL-q85r06j6.js → sizeCapture-INFHLROL-xc314tes.js} +1 -1
- package/dist/client/static/js/sql-0e9mnrda.js +1 -0
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-ep5pyexs.js → stateDiagram-v2-GCMORJYK-8bd9b1h8.js} +3 -3
- package/dist/client/static/js/{svelte-mwtx07d9.js → svelte-brpgzrtv.js} +1 -1
- package/dist/client/static/js/{swimlanes-2SLR337P-95fcqkh8.js → swimlanes-2SLR337P-t6hbdzcw.js} +1 -1
- package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-c1czc7kv.js +8 -0
- package/dist/client/static/js/{timeline-definition-EJHVYXUP-461e615g.js → timeline-definition-EJHVYXUP-2txxasx5.js} +4 -4
- package/dist/client/static/js/treeView-Q6P3EWNA-77kj68p1.js +1 -0
- package/dist/client/static/js/treemap-WGGIJYW6-rw94xc82.js +1 -0
- package/dist/client/static/js/tsx-yd5wt250.js +1 -0
- package/dist/client/static/js/typescript-v7z7crfe.js +1 -0
- package/dist/client/static/js/{usecaseDiagram-POWQR4AR-ftqfnvhg.js → usecaseDiagram-POWQR4AR-3x353hn4.js} +17 -17
- package/dist/client/static/js/{vennDiagram-UO4OBE2U-7t96h6ez.js → vennDiagram-UO4OBE2U-cerpss8e.js} +7 -7
- package/dist/client/static/js/{vue-j8vb9d7r.js → vue-apnkw9qy.js} +1 -1
- package/dist/client/static/js/wardley-WFR3VGLG-18xe4fhz.js +1 -0
- package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-0de8w8c6.js → wardleyDiagram-VNRHLVJA-cx6jfsbf.js} +4 -4
- package/dist/client/static/js/xml-94fhzrfs.js +1 -0
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-dez9phkf.js → xychartDiagram-PMCCYNJV-tgn23xj1.js} +5 -5
- package/dist/client/static/js/yaml-s8af9rnw.js +1 -0
- package/package.json +4 -1
- package/src/client/components/auth/login-screen/index.tsx +1 -0
- package/src/client/components/common/MarkdownRenderer.tsx +9 -12
- package/src/client/components/settings/Modal.tsx +14 -84
- package/src/client/components/settings/Sidebar.tsx +3 -1
- package/src/client/components/settings/categories/ConnectSettings.tsx +105 -0
- package/src/client/components/settings/categories/connect-settings/DeviceTable.tsx +145 -0
- package/src/client/components/settings/categories/connect-settings/PairDialog.test.tsx +159 -0
- package/src/client/components/settings/categories/connect-settings/PairDialog.tsx +189 -0
- package/src/client/components/settings/categories/connect-settings/QrCode.tsx +56 -0
- package/src/client/components/settings/categories/connect-settings/ServerCard.tsx +94 -0
- package/src/client/components/settings/categories/connect-settings/TunnelRow.tsx +127 -0
- package/src/client/components/settings/categories/connect-settings/qr-image.ts +76 -0
- package/src/client/components/settings/category-content.tsx +116 -0
- package/src/client/components/workspace/chat-timeline/ChangedFilesSummary.test.tsx +120 -0
- package/src/client/components/workspace/chat-timeline/ChangedFilesSummary.tsx +56 -20
- package/src/client/components/workspace/chat-timeline/RunFooter.tsx +1 -0
- package/src/client/components/workspace/git-panel/init-state.test.ts +5 -0
- package/src/client/hooks/chat/composer/speech-to-text.ts +24 -17
- package/src/client/hooks/chat/timeline/change-stats.ts +57 -0
- package/src/client/hooks/connect/use-connect-status.ts +116 -0
- package/src/client/hooks/connect/use-pairing.ts +100 -0
- package/src/client/hooks/editor/file-actions.ts +3 -11
- package/src/client/hooks/editor/font.test.ts +2 -1
- package/src/client/hooks/editor/use-file-transfer.ts +2 -1
- package/src/client/hooks/ui/clipboard.ts +26 -0
- package/src/client/lib/browser/download.ts +22 -0
- package/src/client/tailwind.css +5 -0
- package/src/server/index.ts +2 -0
- package/src/server/lib/assets/font-css.server.test.ts +19 -0
- package/src/server/lib/auth/client-address.test.ts +58 -0
- package/src/server/lib/auth/client-address.ts +37 -3
- package/src/server/lib/auth/guard.ts +31 -4
- package/src/server/lib/auth/rate-limit.test.ts +25 -8
- package/src/server/lib/auth/rate-limit.ts +8 -5
- package/src/server/lib/connect/cloudflared.lifecycle.test.ts +88 -0
- package/src/server/lib/connect/cloudflared.server.test.ts +65 -0
- package/src/server/lib/connect/cloudflared.server.ts +206 -0
- package/src/server/lib/connect/devices.server.ts +192 -0
- package/src/server/lib/connect/identity.server.ts +81 -0
- package/src/server/lib/connect/pairing.server.test.ts +56 -0
- package/src/server/lib/connect/pairing.server.ts +113 -0
- package/src/server/lib/connect/qr.roundtrip.test.ts +106 -0
- package/src/server/lib/connect/qr.server.ts +36 -0
- package/src/server/lib/connect/run.server.ts +101 -0
- package/src/server/lib/connect/status.server.ts +177 -0
- package/src/server/lib/connect/tailscale.server.test.ts +117 -0
- package/src/server/lib/connect/tailscale.server.ts +172 -0
- package/src/server/lib/db/schema.ts +4 -0
- package/src/server/lib/omp/session/changes.test.ts +64 -1
- package/src/server/lib/omp/session/changes.ts +94 -1
- package/src/server/routes/connect/devices.ts +56 -0
- package/src/server/routes/connect/index.ts +15 -0
- package/src/server/routes/connect/pair-page.ts +177 -0
- package/src/server/routes/connect/pair.ts +158 -0
- package/src/server/routes/connect/status.ts +19 -0
- package/src/server/routes/connect/tunnels.ts +76 -0
- package/src/server/routes/health/probe.ts +5 -0
- package/src/server/routes/index.ts +2 -0
- package/src/server/routes/sessions/changes.test.ts +12 -3
- package/src/server/routes/sessions/changes.ts +27 -3
- package/src/server/routes/sessions/index.ts +2 -1
- package/src/shared/lib/connect/payload.test.ts +144 -0
- package/src/shared/lib/connect/payload.ts +229 -0
- package/src/shared/lib/connect/tier.test.ts +73 -0
- package/src/shared/lib/connect/tier.ts +105 -0
- package/src/shared/lib/connect/types.ts +99 -0
- package/src/shared/lib/dictation/capture-failure.test.ts +46 -0
- package/src/shared/lib/dictation/capture-failure.ts +36 -0
- package/src/shared/lib/markdown/fira-code-fonts.css +65 -6
- package/src/shared/lib/markdown/marked.ts +7 -4
- package/src/shared/lib/markdown/mermaid-actions.test.ts +78 -0
- package/src/shared/lib/markdown/mermaid-actions.ts +45 -0
- package/src/shared/lib/markdown/mermaid.ts +41 -7
- package/src/shared/lib/settings/sections.ts +6 -1
- package/src/shared/types/session-changes.ts +6 -0
- package/src/shared/types/settings/state.ts +2 -0
- package/dist/client/static/js/Modal-qtftcp2t.js +0 -38
- package/dist/client/static/js/architecture-7GRP2DOG-tavtgb8a.js +0 -1
- package/dist/client/static/js/bash-b3rwyg5p.js +0 -1
- package/dist/client/static/js/cpp-y0t6mynx.js +0 -1
- package/dist/client/static/js/css-6vj0d308.js +0 -1
- package/dist/client/static/js/cynefin-OW5HDTMX-cdh3n2z2.js +0 -1
- package/dist/client/static/js/eventmodeling-NTZA5JFV-as97tpyp.js +0 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-ggm06d12.js +0 -1
- package/dist/client/static/js/gitGraph-4MIJSDKK-eqz7p9ng.js +0 -1
- package/dist/client/static/js/graphql-n43pd5fs.js +0 -1
- package/dist/client/static/js/index-at6bhjyf.js +0 -1
- package/dist/client/static/js/index-bkye8mz4.js +0 -2
- package/dist/client/static/js/index-e94a1en0.css +0 -1
- package/dist/client/static/js/index-sffjtm5w.js +0 -12
- package/dist/client/static/js/info-A6RAGUB7-4pkzh1qx.js +0 -1
- package/dist/client/static/js/ini-j5dyq6gm.js +0 -1
- package/dist/client/static/js/java-g4dgwbfd.js +0 -1
- package/dist/client/static/js/jsx-7t5ecz9s.js +0 -1
- package/dist/client/static/js/lua-1g6w30de.js +0 -1
- package/dist/client/static/js/markdown-afx21x8c.js +0 -1
- package/dist/client/static/js/one-dark-pro-hm3f56n1.js +0 -1
- package/dist/client/static/js/one-light-xrz49rct.js +0 -1
- package/dist/client/static/js/packet-AYTQ26CC-yg71sp88.js +0 -1
- package/dist/client/static/js/pie-WAS4IAKB-89wd6np0.js +0 -1
- package/dist/client/static/js/properties-thd83wey.js +0 -1
- package/dist/client/static/js/python-264ns4xw.js +0 -1
- package/dist/client/static/js/r-qw82kkv9.js +0 -1
- package/dist/client/static/js/radar-RG4KPBEZ-avn0b8r9.js +0 -1
- package/dist/client/static/js/railroad-74A4TZTK-de27xv5w.js +0 -1
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-rg4zzj7x.js +0 -1
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-d84fhj8v.js +0 -1
- package/dist/client/static/js/railroad-peg-WCYAUIDC-dvf8xrmc.js +0 -1
- package/dist/client/static/js/sql-g8wcshpc.js +0 -1
- package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-xs2en5dv.js +0 -8
- package/dist/client/static/js/treeView-Q6P3EWNA-mham0bh6.js +0 -1
- package/dist/client/static/js/treemap-WGGIJYW6-mxrxax86.js +0 -1
- package/dist/client/static/js/tsx-nm94hed6.js +0 -1
- package/dist/client/static/js/typescript-0s2t05jj.js +0 -1
- package/dist/client/static/js/wardley-WFR3VGLG-8vrvh9p3.js +0 -1
- package/dist/client/static/js/xml-dz51p1m3.js +0 -1
- package/dist/client/static/js/yaml-2cfkd30t.js +0 -1
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
import { hashPassword, deriveCredentialKey, readSessionSecret, writeSessionSecret, type ActiveAuthConfig } from '@/server/lib/auth/config';
|
|
31
31
|
import { readSessionCookie, verifySessionToken } from '@/server/lib/auth/token';
|
|
32
32
|
import { agentTokenScopeForPath, bearerToken, verifyAgentToken } from '@/server/lib/sessions/agent-token.server';
|
|
33
|
+
import { verifyDeviceToken, readDeviceCookie } from '@/server/lib/connect/devices.server';
|
|
33
34
|
import { rememberClientAddress } from '@/server/lib/auth/client-address';
|
|
34
35
|
import type { CredentialHandover } from '@/shared/lib/auth/handover';
|
|
35
36
|
|
|
@@ -56,6 +57,13 @@ const PUBLIC_EXACT = new Set([
|
|
|
56
57
|
'/api/auth/state',
|
|
57
58
|
'/api/auth/login',
|
|
58
59
|
'/api/auth/logout',
|
|
60
|
+
// A device redeeming a pairing code has no cookie yet — the one-time secret in
|
|
61
|
+
// the code IS its credential. Minting a code stays gated; only the redemption
|
|
62
|
+
// is public, and it is single-use with a two-minute life.
|
|
63
|
+
'/api/connect/pair/claim',
|
|
64
|
+
// The page a phone's camera opens. It carries no session and no data of its
|
|
65
|
+
// own: it reads the pairing payload from the URL fragment and posts it once.
|
|
66
|
+
'/pair',
|
|
59
67
|
LOGIN_PATH,
|
|
60
68
|
'/robots.txt',
|
|
61
69
|
'/sw.js',
|
|
@@ -237,10 +245,20 @@ export function isAuthEnabled(): boolean {
|
|
|
237
245
|
*/
|
|
238
246
|
export function isAuthenticatedRequest(request: Request): boolean {
|
|
239
247
|
if (!active) return true;
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
248
|
+
if (
|
|
249
|
+
verifySessionToken(readSessionCookie(request), {
|
|
250
|
+
sessionSecret: active.sessionSecret,
|
|
251
|
+
credentialKey: active.credentialKey,
|
|
252
|
+
})
|
|
253
|
+
) {
|
|
254
|
+
return true;
|
|
255
|
+
}
|
|
256
|
+
// A paired device carries its own token, and the gate accepts it for every
|
|
257
|
+
// path — so this must agree, or the shell renders the login screen to a device
|
|
258
|
+
// that is already authenticated. Measured: after pairing, the cookie was set
|
|
259
|
+
// and every API call answered 200, while the document still drew the password
|
|
260
|
+
// form because this function only knew about session cookies.
|
|
261
|
+
return verifyDeviceToken(bearerToken(request)) !== null || verifyDeviceToken(readDeviceCookie(request)) !== null;
|
|
244
262
|
}
|
|
245
263
|
|
|
246
264
|
/** JSON body for a rejected API call, or a redirect for a document request. */
|
|
@@ -305,6 +323,15 @@ export function authGate(request: Request, clientAddress?: string): Response | u
|
|
|
305
323
|
if (agentSession && (scope === 'any' || scope === agentSession)) return undefined;
|
|
306
324
|
}
|
|
307
325
|
|
|
326
|
+
// A paired device carries its own token, and it is good for the whole console
|
|
327
|
+
// rather than one path: the device is a browser, not a subprocess. Revoking
|
|
328
|
+
// the device removes the hash from the cache, so the next request fails here.
|
|
329
|
+
// The cookie form is what a webview can actually send — it cannot attach a
|
|
330
|
+
// header to its own page requests or to a WebSocket upgrade.
|
|
331
|
+
if (verifyDeviceToken(bearerToken(request)) || verifyDeviceToken(readDeviceCookie(request))) {
|
|
332
|
+
return undefined;
|
|
333
|
+
}
|
|
334
|
+
|
|
308
335
|
const wantsHtml = (request.headers.get('accept') ?? '').includes('text/html');
|
|
309
336
|
return rejectionResponse(pathname, wantsHtml);
|
|
310
337
|
}
|
|
@@ -91,10 +91,15 @@ describe('login rate limit', () => {
|
|
|
91
91
|
describe('the rate limit cannot be evaded by a forged forwarding header', () => {
|
|
92
92
|
// Verified against a live server: 8 attempts with rotating `x-forwarded-for`
|
|
93
93
|
// and `x-real-ip` values all answered 429. This pins the REASON, against the
|
|
94
|
-
// real gate rather than a stand-in:
|
|
95
|
-
// records, and a caller-supplied header is never
|
|
96
|
-
// changed, a caller could present a fresh identity per
|
|
97
|
-
// straight through the budget — invisible until exploited.
|
|
94
|
+
// real gate rather than a stand-in: for a DIRECT connection the key is the
|
|
95
|
+
// socket address the gate records, and a caller-supplied header is never
|
|
96
|
+
// consulted. If that ever changed, a caller could present a fresh identity per
|
|
97
|
+
// attempt and walk straight through the budget — invisible until exploited.
|
|
98
|
+
//
|
|
99
|
+
// The socket here is a LAN address on purpose. A loopback socket is the one
|
|
100
|
+
// case where the header IS read (see the tunnel test below), because a tunnel
|
|
101
|
+
// connects from 127.0.0.1 and every client behind it would otherwise share one
|
|
102
|
+
// budget — which let an attacker anywhere lock the owner out for 15 minutes.
|
|
98
103
|
const loginRequest = (forwardedFor: string) => new Request('http://127.0.0.1/api/auth/login', {
|
|
99
104
|
method: 'POST',
|
|
100
105
|
headers: { 'content-type': 'application/json', 'x-forwarded-for': forwardedFor, 'x-real-ip': forwardedFor },
|
|
@@ -103,9 +108,9 @@ describe('the rate limit cannot be evaded by a forged forwarding header', () =>
|
|
|
103
108
|
test('a forged forwarding header does not become the rate-limit key', async () => {
|
|
104
109
|
const request = loginRequest('10.0.0.1');
|
|
105
110
|
// The gate records the socket address it was handed…
|
|
106
|
-
await authGate(request, '
|
|
111
|
+
await authGate(request, '192.168.18.50');
|
|
107
112
|
// …and that is what the login route throttles on, not the header.
|
|
108
|
-
expect(clientAddressFor(request)).toBe('
|
|
113
|
+
expect(clientAddressFor(request)).toBe('192.168.18.50');
|
|
109
114
|
expect(clientAddressFor(request)).not.toBe('10.0.0.1');
|
|
110
115
|
});
|
|
111
116
|
|
|
@@ -113,12 +118,24 @@ describe('the rate limit cannot be evaded by a forged forwarding header', () =>
|
|
|
113
118
|
const keys = new Set<string>();
|
|
114
119
|
for (let attempt = 0; attempt < 5; attempt += 1) {
|
|
115
120
|
const request = loginRequest(`10.0.0.${attempt}`);
|
|
116
|
-
await authGate(request, '
|
|
121
|
+
await authGate(request, '192.168.18.50');
|
|
117
122
|
keys.add(clientAddressFor(request));
|
|
118
123
|
}
|
|
119
124
|
// Five different forged identities, one key.
|
|
120
125
|
expect(keys.size).toBe(1);
|
|
121
|
-
expect([...keys][0]).toBe('
|
|
126
|
+
expect([...keys][0]).toBe('192.168.18.50');
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
test('behind a tunnel the forwarded address IS the key, so one client cannot lock out the rest', async () => {
|
|
130
|
+
// `cloudflared` and `tailscale serve` both connect from loopback. Keying on
|
|
131
|
+
// the socket there gave every client on the internet one shared budget: ten
|
|
132
|
+
// failures from an attacker locked the owner out for fifteen minutes.
|
|
133
|
+
const attacker = loginRequest('203.0.113.9');
|
|
134
|
+
const owner = loginRequest('198.51.100.4');
|
|
135
|
+
await authGate(attacker, '127.0.0.1');
|
|
136
|
+
await authGate(owner, '127.0.0.1');
|
|
137
|
+
expect(clientAddressFor(attacker)).toBe('203.0.113.9');
|
|
138
|
+
expect(clientAddressFor(owner)).toBe('198.51.100.4');
|
|
122
139
|
});
|
|
123
140
|
|
|
124
141
|
test('an unidentifiable caller falls back to the shared key, not a fresh one', async () => {
|
|
@@ -16,11 +16,14 @@
|
|
|
16
16
|
* cleared by hand after a restart, and the process is only reachable at all
|
|
17
17
|
* because someone chose to expose it.
|
|
18
18
|
*
|
|
19
|
-
* The key is the SOCKET address (`requestIP`),
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
19
|
+
* The key is the SOCKET address (`requestIP`), except when the socket is
|
|
20
|
+
* loopback — the case a tunnel creates. `cloudflared` and `tailscale serve`
|
|
21
|
+
* connect from `127.0.0.1`, so every client behind one shares a single address
|
|
22
|
+
* and ten failures from an attacker anywhere would lock the owner out. In that
|
|
23
|
+
* one case the forwarded address is used instead; see
|
|
24
|
+
* `effectiveClientAddress` in `client-address.ts` for why the socket, not the
|
|
25
|
+
* header, is the condition. A direct remote connection still keys on its own
|
|
26
|
+
* socket address, which a caller cannot forge.
|
|
24
27
|
*/
|
|
25
28
|
|
|
26
29
|
/** Sliding window an attempt count is measured over. */
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The cloudflared lifecycle, driven through a stand-in.
|
|
8
|
+
*
|
|
9
|
+
* A real named tunnel needs an account, a domain and a credentials file, so the
|
|
10
|
+
* start path is unreachable on a machine that has none — which is exactly the
|
|
11
|
+
* path that would otherwise ship untested. The stand-in is a script that stays
|
|
12
|
+
* alive, which is all `startCloudflared` requires: it records the process, derives
|
|
13
|
+
* the public URL from the config's hostname, and reports liveness from the
|
|
14
|
+
* process's own exit code.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { afterEach, describe, expect, test } from 'bun:test';
|
|
18
|
+
import fs from 'fs';
|
|
19
|
+
import os from 'os';
|
|
20
|
+
import path from 'path';
|
|
21
|
+
import {
|
|
22
|
+
cloudflaredAlive,
|
|
23
|
+
runningTunnelUrl,
|
|
24
|
+
startCloudflared,
|
|
25
|
+
stopCloudflared,
|
|
26
|
+
} from '@/server/lib/connect/cloudflared.server';
|
|
27
|
+
|
|
28
|
+
// The stand-in is a `#!/bin/sh` script, so the cases that spawn it are
|
|
29
|
+
// POSIX-only: Windows cannot execute it, and they would fail on the spawn
|
|
30
|
+
// instead of on the lifecycle they exist to measure. The Linux gate covers it.
|
|
31
|
+
const posixOnly = process.platform !== 'win32';
|
|
32
|
+
|
|
33
|
+
const dirs: string[] = [];
|
|
34
|
+
|
|
35
|
+
function fakeCloudflared(): string {
|
|
36
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'kabmo-cf-bin-'));
|
|
37
|
+
dirs.push(dir);
|
|
38
|
+
const file = path.join(dir, 'cloudflared');
|
|
39
|
+
// Stays alive until killed, like the real `tunnel run`.
|
|
40
|
+
fs.writeFileSync(file, '#!/bin/sh\nexec sleep 30\n');
|
|
41
|
+
fs.chmodSync(file, 0o755);
|
|
42
|
+
return file;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
afterEach(() => {
|
|
46
|
+
for (const dir of dirs.splice(0)) fs.rmSync(dir, { recursive: true, force: true });
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
describe('cloudflared lifecycle', () => {
|
|
50
|
+
test.skipIf(!posixOnly)('starting records the public URL and reports the process alive', async () => {
|
|
51
|
+
const binary = fakeCloudflared();
|
|
52
|
+
const port = 39_101;
|
|
53
|
+
const outcome = await startCloudflared(binary, '/tmp/config.yml', 'kabmo.example.com', port);
|
|
54
|
+
|
|
55
|
+
expect(outcome.ok).toBe(true);
|
|
56
|
+
expect(outcome.url).toBe('https://kabmo.example.com');
|
|
57
|
+
expect(runningTunnelUrl(port)).toBe('https://kabmo.example.com');
|
|
58
|
+
expect(cloudflaredAlive(port)).toBe(true);
|
|
59
|
+
|
|
60
|
+
stopCloudflared(port);
|
|
61
|
+
expect(cloudflaredAlive(port)).toBe(false);
|
|
62
|
+
expect(runningTunnelUrl(port)).toBeNull();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test.skipIf(!posixOnly)('starting twice for one port reuses the running tunnel', async () => {
|
|
66
|
+
const binary = fakeCloudflared();
|
|
67
|
+
const port = 39_102;
|
|
68
|
+
await startCloudflared(binary, '/tmp/config.yml', 'a.example.com', port);
|
|
69
|
+
const second = await startCloudflared(binary, '/tmp/config.yml', 'b.example.com', port);
|
|
70
|
+
|
|
71
|
+
// The second call must not spawn a second process, and must not claim a
|
|
72
|
+
// different hostname than the one actually running.
|
|
73
|
+
expect(second.url).toBe('https://a.example.com');
|
|
74
|
+
stopCloudflared(port);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test('stopping a tunnel that was never started is not an error', () => {
|
|
78
|
+
expect(stopCloudflared(39_103)).toEqual({ ok: true, reason: null });
|
|
79
|
+
expect(cloudflaredAlive(39_103)).toBe(false);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test('a binary that cannot be spawned reports the reason', async () => {
|
|
83
|
+
const outcome = await startCloudflared('/nonexistent/cloudflared', '/tmp/config.yml', 'x.example.com', 39_104);
|
|
84
|
+
expect(outcome.ok).toBe(false);
|
|
85
|
+
expect(outcome.reason).toBeTruthy();
|
|
86
|
+
expect(cloudflaredAlive(39_104)).toBe(false);
|
|
87
|
+
});
|
|
88
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The cloudflared config scan.
|
|
8
|
+
*
|
|
9
|
+
* A line scan is only safe if it refuses the shapes it cannot read. The case
|
|
10
|
+
* that matters is a config with an ingress block but no hostname: reporting a
|
|
11
|
+
* tunnel as configured there would put a URL on the page that does not exist.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { describe, expect, test } from 'bun:test';
|
|
15
|
+
import fs from 'fs';
|
|
16
|
+
import os from 'os';
|
|
17
|
+
import path from 'path';
|
|
18
|
+
import { readCloudflaredConfig } from '@/server/lib/connect/cloudflared.server';
|
|
19
|
+
|
|
20
|
+
function writeConfig(text: string): string {
|
|
21
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'kabmo-cf-'));
|
|
22
|
+
const file = path.join(dir, 'config.yml');
|
|
23
|
+
fs.writeFileSync(file, text);
|
|
24
|
+
return file;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
describe('readCloudflaredConfig', () => {
|
|
28
|
+
test('reads the tunnel name and the first ingress hostname', () => {
|
|
29
|
+
const file = writeConfig(
|
|
30
|
+
[
|
|
31
|
+
'tunnel: 6ff42ae2-765d-4adf-8112-31c55c1551ef',
|
|
32
|
+
'credentials-file: /home/me/.cloudflared/6ff42ae2.json',
|
|
33
|
+
'',
|
|
34
|
+
'ingress:',
|
|
35
|
+
' - hostname: kabmo.example.com',
|
|
36
|
+
' service: http://localhost:3000',
|
|
37
|
+
' - service: http_status:404',
|
|
38
|
+
'',
|
|
39
|
+
].join('\n'),
|
|
40
|
+
);
|
|
41
|
+
expect(readCloudflaredConfig(file)).toEqual({
|
|
42
|
+
tunnel: '6ff42ae2-765d-4adf-8112-31c55c1551ef',
|
|
43
|
+
hostname: 'kabmo.example.com',
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test('strips quotes around a value', () => {
|
|
48
|
+
const file = writeConfig(['tunnel: "my-tunnel"', 'ingress:', ' - hostname: "a.example.com"'].join('\n'));
|
|
49
|
+
expect(readCloudflaredConfig(file)).toEqual({ tunnel: 'my-tunnel', hostname: 'a.example.com' });
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test('answers null for a file with neither field', () => {
|
|
53
|
+
const file = writeConfig('metrics: 127.0.0.1:20241\n');
|
|
54
|
+
expect(readCloudflaredConfig(file)).toBeNull();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('answers null for a missing file', () => {
|
|
58
|
+
expect(readCloudflaredConfig(path.join(os.tmpdir(), 'kabmo-does-not-exist.yml'))).toBeNull();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test('does not read a hostname from outside the ingress block', () => {
|
|
62
|
+
const file = writeConfig(['tunnel: t', 'hostname: not-ingress.example.com', 'ingress:', ' - service: http_status:404'].join('\n'));
|
|
63
|
+
expect(readCloudflaredConfig(file)).toEqual({ tunnel: 't', hostname: null });
|
|
64
|
+
});
|
|
65
|
+
});
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Cloudflare Tunnel, named only.
|
|
8
|
+
*
|
|
9
|
+
* Quick tunnels are deliberately NOT supported. Two measured facts make them
|
|
10
|
+
* unusable for this product: they buffer Server-Sent Events (cloudflared #1449 —
|
|
11
|
+
* the maintainer confirms named tunnels stream correctly and quick tunnels do
|
|
12
|
+
* not), and Kabmo has six SSE endpoints including the chat stream, so a quick
|
|
13
|
+
* tunnel would make every answer arrive in one burst at the end. They also cap
|
|
14
|
+
* at 200 in-flight requests and change hostname on every start.
|
|
15
|
+
*
|
|
16
|
+
* A named tunnel needs an account and a domain, which is why it is the second
|
|
17
|
+
* route rather than the first. It is also the one route where a third party
|
|
18
|
+
* reads the traffic: TLS terminates at Cloudflare's edge, so the console's
|
|
19
|
+
* password and every prompt cross their machines in plaintext. The Connect page
|
|
20
|
+
* says so on the card rather than in a wiki.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import fs from 'fs';
|
|
24
|
+
import os from 'os';
|
|
25
|
+
import path from 'path';
|
|
26
|
+
import { which } from '@/server/lib/connect/run.server';
|
|
27
|
+
|
|
28
|
+
export interface CloudflaredPresence {
|
|
29
|
+
binary: string | null;
|
|
30
|
+
configPath: string | null;
|
|
31
|
+
/** Why it cannot be used, in one sentence, when it cannot. */
|
|
32
|
+
reason: string | null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface CloudflaredConfig {
|
|
36
|
+
/** The tunnel name or UUID from `tunnel:`. */
|
|
37
|
+
tunnel: string | null;
|
|
38
|
+
/** The first public hostname in the ingress list. */
|
|
39
|
+
hostname: string | null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Where cloudflared looks for its config, honouring the documented override. */
|
|
43
|
+
export function cloudflaredConfigPath(): string {
|
|
44
|
+
const override = (Bun.env.CLOUDFLARED_CONFIG ?? '').trim();
|
|
45
|
+
if (override) return override;
|
|
46
|
+
return path.join(os.homedir(), '.cloudflared', 'config.yml');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Read the two facts this page needs out of the YAML.
|
|
51
|
+
*
|
|
52
|
+
* A line scan rather than a YAML parser: the file is written by
|
|
53
|
+
* `cloudflared tunnel create` and by hand, and the only fields read here are a
|
|
54
|
+
* top-level `tunnel:` and the first `hostname:` under `ingress:`. Pulling in a
|
|
55
|
+
* parser for two scalars would be a dependency the rest of the server does not
|
|
56
|
+
* have, and a malformed file must degrade to "not configured" rather than throw.
|
|
57
|
+
*/
|
|
58
|
+
export function readCloudflaredConfig(file: string): CloudflaredConfig | null {
|
|
59
|
+
let text: string;
|
|
60
|
+
try {
|
|
61
|
+
text = fs.readFileSync(file, 'utf8');
|
|
62
|
+
} catch {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
let tunnel: string | null = null;
|
|
67
|
+
let hostname: string | null = null;
|
|
68
|
+
let inIngress = false;
|
|
69
|
+
for (const rawLine of text.split('\n')) {
|
|
70
|
+
const line = rawLine.replace(/\s+#.*$/, '');
|
|
71
|
+
if (/^tunnel:\s*/.test(line)) {
|
|
72
|
+
tunnel = line.replace(/^tunnel:\s*/, '').trim().replace(/^["']|["']$/g, '') || null;
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
if (/^ingress:\s*$/.test(line)) {
|
|
76
|
+
inIngress = true;
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
if (inIngress && /^\S/.test(line)) {
|
|
80
|
+
// A new top-level key ends the ingress block.
|
|
81
|
+
inIngress = false;
|
|
82
|
+
}
|
|
83
|
+
if (inIngress && hostname === null) {
|
|
84
|
+
const match = /^\s*-\s*hostname:\s*(\S+)/.exec(line) ?? /^\s*hostname:\s*(\S+)/.exec(line);
|
|
85
|
+
if (match?.[1]) hostname = match[1].replace(/^["']|["']$/g, '');
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (!tunnel && !hostname) return null;
|
|
90
|
+
return { tunnel, hostname };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Locate the binary and a usable config. */
|
|
94
|
+
export function findCloudflared(): CloudflaredPresence {
|
|
95
|
+
const binary = which('cloudflared');
|
|
96
|
+
const configPath = cloudflaredConfigPath();
|
|
97
|
+
if (!binary) {
|
|
98
|
+
return {
|
|
99
|
+
binary: null,
|
|
100
|
+
configPath: null,
|
|
101
|
+
reason: 'The cloudflared command was not found. Install it with `brew install cloudflared`.',
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
const config = readCloudflaredConfig(configPath);
|
|
105
|
+
if (!config) {
|
|
106
|
+
return {
|
|
107
|
+
binary,
|
|
108
|
+
configPath: null,
|
|
109
|
+
reason: `No cloudflared config at ${configPath}. A named tunnel needs an account and a domain.`,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
if (!config.hostname) {
|
|
113
|
+
return {
|
|
114
|
+
binary,
|
|
115
|
+
configPath,
|
|
116
|
+
reason: `The config at ${configPath} has no ingress hostname, so there is no public URL to show.`,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
return { binary, configPath, reason: null };
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
interface RunningTunnel {
|
|
123
|
+
proc: Bun.Subprocess<'ignore', 'ignore', 'pipe'>;
|
|
124
|
+
url: string;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
declare global {
|
|
128
|
+
// eslint-disable-next-line no-var
|
|
129
|
+
var __kabmoCloudflared: Map<number, RunningTunnel> | undefined;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function running(): Map<number, RunningTunnel> {
|
|
133
|
+
globalThis.__kabmoCloudflared ??= new Map();
|
|
134
|
+
return globalThis.__kabmoCloudflared;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** The public origin of a running tunnel for `port`, or null. */
|
|
138
|
+
export function runningTunnelUrl(port: number): string | null {
|
|
139
|
+
return running().get(port)?.url ?? null;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Start the named tunnel for `port`.
|
|
144
|
+
*
|
|
145
|
+
* `--url` overrides the config's ingress service so the tunnel points at THIS
|
|
146
|
+
* instance's port rather than whatever the config was written for; without it a
|
|
147
|
+
* second Kabmo on another port would silently share the first one.
|
|
148
|
+
*/
|
|
149
|
+
export async function startCloudflared(
|
|
150
|
+
binary: string,
|
|
151
|
+
configPath: string,
|
|
152
|
+
hostname: string,
|
|
153
|
+
port: number,
|
|
154
|
+
): Promise<{ ok: boolean; url: string | null; reason: string | null }> {
|
|
155
|
+
if (running().has(port)) {
|
|
156
|
+
return { ok: true, url: runningTunnelUrl(port), reason: null };
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
let proc: Bun.Subprocess<'ignore', 'ignore', 'pipe'>;
|
|
160
|
+
try {
|
|
161
|
+
proc = Bun.spawn({
|
|
162
|
+
cmd: [binary, 'tunnel', '--config', configPath, 'run', '--url', `http://127.0.0.1:${port}`],
|
|
163
|
+
stdin: 'ignore',
|
|
164
|
+
stdout: 'ignore',
|
|
165
|
+
stderr: 'pipe',
|
|
166
|
+
env: { ...Bun.env },
|
|
167
|
+
});
|
|
168
|
+
} catch (error) {
|
|
169
|
+
return {
|
|
170
|
+
ok: false,
|
|
171
|
+
url: null,
|
|
172
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const url = `https://${hostname}`;
|
|
177
|
+
running().set(port, { proc, url });
|
|
178
|
+
|
|
179
|
+
// The process is long-lived; a failure after this point is reported by the
|
|
180
|
+
// status read (the process is gone), not by this call.
|
|
181
|
+
proc.exited.then(() => {
|
|
182
|
+
running().delete(port);
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
return { ok: true, url, reason: null };
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/** Stop the tunnel for `port`, if this process started one. */
|
|
189
|
+
export function stopCloudflared(port: number): { ok: boolean; reason: string | null } {
|
|
190
|
+
const entry = running().get(port);
|
|
191
|
+
if (!entry) return { ok: true, reason: null };
|
|
192
|
+
try {
|
|
193
|
+
entry.proc.kill('SIGTERM');
|
|
194
|
+
} catch {
|
|
195
|
+
// Already gone.
|
|
196
|
+
}
|
|
197
|
+
running().delete(port);
|
|
198
|
+
return { ok: true, reason: null };
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/** Whether a tunnel this process started is still alive. */
|
|
202
|
+
export function cloudflaredAlive(port: number): boolean {
|
|
203
|
+
const entry = running().get(port);
|
|
204
|
+
if (!entry) return false;
|
|
205
|
+
return entry.proc.exitCode === null;
|
|
206
|
+
}
|