@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
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Devices that have redeemed a pairing code, and the tokens they hold.
|
|
8
|
+
*
|
|
9
|
+
* A device token is NOT the UI password and never becomes one. The password is
|
|
10
|
+
* a single shared secret typed by a human; a device token is per-device, so
|
|
11
|
+
* revoking one phone does not sign out the laptop, and a token that leaks
|
|
12
|
+
* identifies exactly which device leaked it.
|
|
13
|
+
*
|
|
14
|
+
* Only the SHA-256 of a token is stored, for the same reason the agent tokens
|
|
15
|
+
* are hashed: a copy of the database must not be replayable as a credential.
|
|
16
|
+
* The gate runs on every request and is synchronous, so verified hashes are
|
|
17
|
+
* mirrored in memory and a restart re-reads the table.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import type { DbClient } from '@/server/lib/db/client';
|
|
21
|
+
import { getDb } from '@/server/db.server';
|
|
22
|
+
import type { ConnectRouteKind, PairedDevice } from '@/shared/lib/connect/types';
|
|
23
|
+
|
|
24
|
+
interface DeviceRow {
|
|
25
|
+
id: string;
|
|
26
|
+
name: string;
|
|
27
|
+
platform: string;
|
|
28
|
+
token_hash: string;
|
|
29
|
+
route: string | null;
|
|
30
|
+
rtt_ms: number | null;
|
|
31
|
+
created_at: number;
|
|
32
|
+
last_seen_at: number | null;
|
|
33
|
+
revoked_at: number | null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
declare global {
|
|
37
|
+
// eslint-disable-next-line no-var
|
|
38
|
+
var __kabmoDeviceTokens: Map<string, string> | undefined;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function tokenCache(): Map<string, string> {
|
|
42
|
+
globalThis.__kabmoDeviceTokens ??= new Map();
|
|
43
|
+
return globalThis.__kabmoDeviceTokens;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export async function ensureConnectSchema(db: DbClient): Promise<void> {
|
|
47
|
+
await db.exec(`
|
|
48
|
+
CREATE TABLE IF NOT EXISTS paired_devices (
|
|
49
|
+
id TEXT PRIMARY KEY,
|
|
50
|
+
name TEXT NOT NULL,
|
|
51
|
+
platform TEXT NOT NULL,
|
|
52
|
+
token_hash TEXT NOT NULL UNIQUE,
|
|
53
|
+
route TEXT,
|
|
54
|
+
rtt_ms INTEGER,
|
|
55
|
+
created_at INTEGER NOT NULL,
|
|
56
|
+
last_seen_at INTEGER,
|
|
57
|
+
revoked_at INTEGER
|
|
58
|
+
);
|
|
59
|
+
CREATE INDEX IF NOT EXISTS idx_paired_devices_token
|
|
60
|
+
ON paired_devices (token_hash);
|
|
61
|
+
`);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function hashToken(token: string): string {
|
|
65
|
+
return new Bun.CryptoHasher('sha256').update(token).digest('hex');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Load every live token hash into the gate's cache. Call once at boot. */
|
|
69
|
+
export async function initDeviceTokens(): Promise<void> {
|
|
70
|
+
try {
|
|
71
|
+
const db = await getDb();
|
|
72
|
+
const rows = (await db.all(
|
|
73
|
+
'SELECT id, token_hash FROM paired_devices WHERE revoked_at IS NULL',
|
|
74
|
+
)) as { id: string; token_hash: string }[];
|
|
75
|
+
const next = new Map<string, string>();
|
|
76
|
+
for (const row of rows) next.set(row.token_hash, row.id);
|
|
77
|
+
globalThis.__kabmoDeviceTokens = next;
|
|
78
|
+
} catch {
|
|
79
|
+
// A database opened before this table existed has no device credentials;
|
|
80
|
+
// the browser path is unaffected.
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** The device id a bearer token belongs to, or null. Synchronous: the gate. */
|
|
85
|
+
export function verifyDeviceToken(token: string | null): string | null {
|
|
86
|
+
if (!token) return null;
|
|
87
|
+
return tokenCache().get(hashToken(token)) ?? null;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* The cookie a shell sets after pairing.
|
|
92
|
+
*
|
|
93
|
+
* A webview cannot attach an `Authorization` header to the requests it makes —
|
|
94
|
+
* the page's own `fetch`, the WebSocket upgrades, the image loads. A cookie is
|
|
95
|
+
* the one credential the platform sends on all of them, so the shell writes this
|
|
96
|
+
* one for the server's origin and the gate reads it here.
|
|
97
|
+
*
|
|
98
|
+
* `HttpOnly` is set by the shell, not by this server: the value is written
|
|
99
|
+
* through the platform's cookie store, which is the only place a webview cookie
|
|
100
|
+
* can be created from native code.
|
|
101
|
+
*/
|
|
102
|
+
export const DEVICE_COOKIE = 'kabmo_device';
|
|
103
|
+
|
|
104
|
+
/** The device token carried as a cookie, or null. */
|
|
105
|
+
export function readDeviceCookie(request: Request): string | null {
|
|
106
|
+
const header = request.headers.get('cookie');
|
|
107
|
+
if (!header) return null;
|
|
108
|
+
for (const segment of header.split(';')) {
|
|
109
|
+
const index = segment.indexOf('=');
|
|
110
|
+
if (index === -1) continue;
|
|
111
|
+
if (segment.slice(0, index).trim() !== DEVICE_COOKIE) continue;
|
|
112
|
+
const value = segment.slice(index + 1).trim();
|
|
113
|
+
if (!value) return null;
|
|
114
|
+
try {
|
|
115
|
+
return decodeURIComponent(value);
|
|
116
|
+
} catch {
|
|
117
|
+
return value;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** Mint a token for a device that just redeemed a pairing code. */
|
|
124
|
+
export async function mintDeviceToken(input: {
|
|
125
|
+
name: string;
|
|
126
|
+
platform: string;
|
|
127
|
+
}): Promise<{ id: string; token: string }> {
|
|
128
|
+
const id = crypto.randomUUID();
|
|
129
|
+
const token = `kabmo_device_${crypto.randomUUID().replace(/-/g, '')}`;
|
|
130
|
+
const hash = hashToken(token);
|
|
131
|
+
const db = await getDb();
|
|
132
|
+
await db.run(
|
|
133
|
+
`INSERT INTO paired_devices (id, name, platform, token_hash, created_at)
|
|
134
|
+
VALUES (?, ?, ?, ?, ?)`,
|
|
135
|
+
[id, input.name.trim() || 'Device', input.platform.trim() || 'unknown', hash, Date.now()],
|
|
136
|
+
);
|
|
137
|
+
tokenCache().set(hash, id);
|
|
138
|
+
return { id, token };
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** Every device, newest first, revoked ones included so the page can say so. */
|
|
142
|
+
export async function listPairedDevices(): Promise<PairedDevice[]> {
|
|
143
|
+
const db = await getDb();
|
|
144
|
+
const rows = (await db.all(
|
|
145
|
+
`SELECT id, name, platform, route, rtt_ms, created_at, last_seen_at, revoked_at
|
|
146
|
+
FROM paired_devices
|
|
147
|
+
WHERE revoked_at IS NULL
|
|
148
|
+
ORDER BY created_at DESC`,
|
|
149
|
+
)) as DeviceRow[];
|
|
150
|
+
return rows.map((row) => ({
|
|
151
|
+
id: row.id,
|
|
152
|
+
name: row.name,
|
|
153
|
+
platform: row.platform,
|
|
154
|
+
route: (row.route as ConnectRouteKind | null) ?? null,
|
|
155
|
+
rttMs: row.rtt_ms,
|
|
156
|
+
lastSeenAt: row.last_seen_at ? new Date(row.last_seen_at).toISOString() : null,
|
|
157
|
+
createdAt: new Date(row.created_at).toISOString(),
|
|
158
|
+
}));
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** Cut a device off. The token stops verifying on the next request. */
|
|
162
|
+
export async function revokeDevice(id: string): Promise<boolean> {
|
|
163
|
+
const db = await getDb();
|
|
164
|
+
const row = (await db.get('SELECT token_hash FROM paired_devices WHERE id = ?', [id])) as
|
|
165
|
+
| { token_hash: string }
|
|
166
|
+
| undefined;
|
|
167
|
+
if (!row) return false;
|
|
168
|
+
await db.run('UPDATE paired_devices SET revoked_at = ? WHERE id = ?', [Date.now(), id]);
|
|
169
|
+
tokenCache().delete(row.token_hash);
|
|
170
|
+
return true;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Record the route a device reported, so the page can show which one it uses.
|
|
175
|
+
*
|
|
176
|
+
* Best-effort: a failed write must not fail the request that carried it, and the
|
|
177
|
+
* column is a display fact rather than a security one.
|
|
178
|
+
*/
|
|
179
|
+
export async function touchDevice(
|
|
180
|
+
id: string,
|
|
181
|
+
report: { route: ConnectRouteKind; rttMs: number } | null,
|
|
182
|
+
): Promise<void> {
|
|
183
|
+
try {
|
|
184
|
+
const db = await getDb();
|
|
185
|
+
await db.run(
|
|
186
|
+
'UPDATE paired_devices SET last_seen_at = ?, route = COALESCE(?, route), rtt_ms = COALESCE(?, rtt_ms) WHERE id = ?',
|
|
187
|
+
[Date.now(), report?.route ?? null, report?.rttMs ?? null, id],
|
|
188
|
+
);
|
|
189
|
+
} catch {
|
|
190
|
+
// See above: a display fact, not a credential.
|
|
191
|
+
}
|
|
192
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* This server's stable identity, and why it is a key rather than a hostname.
|
|
8
|
+
*
|
|
9
|
+
* A paired device pins `serverId` and refuses a candidate that answers with a
|
|
10
|
+
* different one. That check is what stops a LAN address reassigned by DHCP from
|
|
11
|
+
* receiving a device's token: the address is not the identity, and a hostname is
|
|
12
|
+
* not either (two machines can be called `macbook`).
|
|
13
|
+
*
|
|
14
|
+
* The id is derived from a random key persisted in the data directory, so it
|
|
15
|
+
* survives a restart, a port change and a LAN address change — the three things
|
|
16
|
+
* that must NOT invalidate a pairing. It is deliberately not derived from the
|
|
17
|
+
* machine's hardware id: that would make two installs on one machine share an
|
|
18
|
+
* identity, and a copied data directory is already the case the relay-style
|
|
19
|
+
* designs have to handle explicitly.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import fs from 'fs';
|
|
23
|
+
import path from 'path';
|
|
24
|
+
import { getDataDir } from '@/server/lib/lifecycle/paths';
|
|
25
|
+
|
|
26
|
+
interface IdentityFile {
|
|
27
|
+
v: 1;
|
|
28
|
+
/** base64url of 32 random bytes. Never leaves the machine. */
|
|
29
|
+
key: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface Identity {
|
|
33
|
+
serverId: string;
|
|
34
|
+
key: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
declare global {
|
|
38
|
+
// eslint-disable-next-line no-var
|
|
39
|
+
var __kabmoConnectIdentity: Identity | undefined;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function deriveServerId(key: string): string {
|
|
43
|
+
return new Bun.CryptoHasher('sha256').update(key).digest('base64url');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The identity, minted on first read.
|
|
48
|
+
*
|
|
49
|
+
* A corrupt or unreadable file is REPLACED rather than treated as first run
|
|
50
|
+
* silently: the caller gets a new id, and every paired device will refuse it
|
|
51
|
+
* until it is paired again. That is the honest outcome — the alternative is a
|
|
52
|
+
* server that cannot answer its own identity at all.
|
|
53
|
+
*/
|
|
54
|
+
export function connectIdentity(): Identity {
|
|
55
|
+
const cached = globalThis.__kabmoConnectIdentity;
|
|
56
|
+
if (cached) return cached;
|
|
57
|
+
|
|
58
|
+
const file = path.join(getDataDir(), 'connect-identity.json');
|
|
59
|
+
try {
|
|
60
|
+
const parsed = JSON.parse(fs.readFileSync(file, 'utf8')) as Partial<IdentityFile>;
|
|
61
|
+
if (typeof parsed.key === 'string' && parsed.key.length >= 32) {
|
|
62
|
+
const identity = { key: parsed.key, serverId: deriveServerId(parsed.key) };
|
|
63
|
+
globalThis.__kabmoConnectIdentity = identity;
|
|
64
|
+
return identity;
|
|
65
|
+
}
|
|
66
|
+
} catch {
|
|
67
|
+
// Absent or unreadable: minted below.
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const key = Buffer.from(crypto.getRandomValues(new Uint8Array(32))).toString('base64url');
|
|
71
|
+
const identity = { key, serverId: deriveServerId(key) };
|
|
72
|
+
try {
|
|
73
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
74
|
+
fs.writeFileSync(file, JSON.stringify({ v: 1, key } satisfies IdentityFile), { mode: 0o600 });
|
|
75
|
+
} catch {
|
|
76
|
+
// A read-only data directory still gets a working identity for this process;
|
|
77
|
+
// it just will not survive a restart, and the next boot mints another.
|
|
78
|
+
}
|
|
79
|
+
globalThis.__kabmoConnectIdentity = identity;
|
|
80
|
+
return identity;
|
|
81
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* One-time pairing secrets.
|
|
8
|
+
*
|
|
9
|
+
* The property that matters is single use: a code that can be redeemed twice
|
|
10
|
+
* enrols a second device from a QR someone photographed. The second property is
|
|
11
|
+
* that a wrong secret does NOT consume the code — otherwise a mistyped paste
|
|
12
|
+
* would invalidate the code on screen.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { afterEach, describe, expect, test } from 'bun:test';
|
|
16
|
+
import { consumePairing, createPairing, resetPairings } from '@/server/lib/connect/pairing.server';
|
|
17
|
+
|
|
18
|
+
const CANDIDATES = [{ kind: 'lan' as const, url: 'http://192.168.18.76:3000' }];
|
|
19
|
+
|
|
20
|
+
afterEach(() => {
|
|
21
|
+
resetPairings();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
describe('pairing secrets', () => {
|
|
25
|
+
test('redeems once and refuses the second attempt', () => {
|
|
26
|
+
const { pairingId, secret } = createPairing(CANDIDATES);
|
|
27
|
+
expect(consumePairing(pairingId, secret).ok).toBe(true);
|
|
28
|
+
|
|
29
|
+
const second = consumePairing(pairingId, secret);
|
|
30
|
+
expect(second.ok).toBe(false);
|
|
31
|
+
if (!second.ok) expect(second.reason).toContain('already used');
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test('a wrong secret does not consume the code', () => {
|
|
35
|
+
const { pairingId, secret } = createPairing(CANDIDATES);
|
|
36
|
+
expect(consumePairing(pairingId, 'not-the-secret').ok).toBe(false);
|
|
37
|
+
expect(consumePairing(pairingId, secret).ok).toBe(true);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test('an unknown pairing id is refused', () => {
|
|
41
|
+
expect(consumePairing('nope', 'anything').ok).toBe(false);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test('carries the candidates the code was minted with', () => {
|
|
45
|
+
const { pairingId, secret } = createPairing(CANDIDATES);
|
|
46
|
+
const consumed = consumePairing(pairingId, secret);
|
|
47
|
+
expect(consumed.ok && consumed.candidates).toEqual(CANDIDATES);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test('mints a distinct secret per code', () => {
|
|
51
|
+
const first = createPairing(CANDIDATES);
|
|
52
|
+
const second = createPairing(CANDIDATES);
|
|
53
|
+
expect(first.secret).not.toBe(second.secret);
|
|
54
|
+
expect(first.pairingId).not.toBe(second.pairingId);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* One-time pairing secrets.
|
|
8
|
+
*
|
|
9
|
+
* A secret is minted when the QR is drawn, lives for two minutes, and is
|
|
10
|
+
* consumed by the first successful claim. It is held in memory rather than in
|
|
11
|
+
* the database on purpose: a pairing that outlives the process that offered it
|
|
12
|
+
* is a pairing nobody is looking at, and a restart should invalidate the code on
|
|
13
|
+
* screen rather than leave a window open.
|
|
14
|
+
*
|
|
15
|
+
* The secret is compared by hash, so a heap dump or a log line that captured the
|
|
16
|
+
* stored value cannot be replayed as a credential.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import type { ConnectCandidate } from '@/shared/lib/connect/types';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* How long a code stays valid.
|
|
23
|
+
*
|
|
24
|
+
* Five minutes, not two. A camera scan takes seconds, but the image path does
|
|
25
|
+
* not: screenshot the dialog, send it to the other device, open the login screen,
|
|
26
|
+
* pick the file. Measured on this machine, that round trip took 6–16 seconds when
|
|
27
|
+
* scripted and minutes when a human does it — and a code that expires mid-transfer
|
|
28
|
+
* reads as "this QR is not a Kabmo code", which is the wrong diagnosis.
|
|
29
|
+
*
|
|
30
|
+
* The window is still short enough that a photographed code is worthless by the
|
|
31
|
+
* time anyone could act on it, and it is single-use regardless.
|
|
32
|
+
*/
|
|
33
|
+
export const PAIRING_TTL_MS = 5 * 60 * 1000;
|
|
34
|
+
|
|
35
|
+
export interface PendingPairing {
|
|
36
|
+
pairingId: string;
|
|
37
|
+
secretHash: string;
|
|
38
|
+
candidates: ConnectCandidate[];
|
|
39
|
+
expiresAt: number;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
declare global {
|
|
43
|
+
// eslint-disable-next-line no-var
|
|
44
|
+
var __kabmoPairings: Map<string, PendingPairing> | undefined;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function store(): Map<string, PendingPairing> {
|
|
48
|
+
globalThis.__kabmoPairings ??= new Map();
|
|
49
|
+
return globalThis.__kabmoPairings;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function hashSecret(secret: string): string {
|
|
53
|
+
return new Bun.CryptoHasher('sha256').update(secret).digest('hex');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Drop expired entries. Called on every mint and claim, so the map stays small. */
|
|
57
|
+
function sweep(now: number): void {
|
|
58
|
+
for (const [id, entry] of store()) {
|
|
59
|
+
if (entry.expiresAt <= now) store().delete(id);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Mint a pairing and return the plaintext secret exactly once. */
|
|
64
|
+
export function createPairing(candidates: ConnectCandidate[]): {
|
|
65
|
+
pairingId: string;
|
|
66
|
+
secret: string;
|
|
67
|
+
expiresAt: string;
|
|
68
|
+
} {
|
|
69
|
+
const now = Date.now();
|
|
70
|
+
sweep(now);
|
|
71
|
+
const pairingId = crypto.randomUUID();
|
|
72
|
+
const secret = Buffer.from(crypto.getRandomValues(new Uint8Array(32))).toString('base64url');
|
|
73
|
+
const expiresAt = now + PAIRING_TTL_MS;
|
|
74
|
+
store().set(pairingId, {
|
|
75
|
+
pairingId,
|
|
76
|
+
secretHash: hashSecret(secret),
|
|
77
|
+
candidates,
|
|
78
|
+
expiresAt,
|
|
79
|
+
});
|
|
80
|
+
return { pairingId, secret, expiresAt: new Date(expiresAt).toISOString() };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Consume a pairing, or answer why it cannot be consumed.
|
|
85
|
+
*
|
|
86
|
+
* Single use is enforced by DELETING the entry before the caller does anything
|
|
87
|
+
* with it: a claim that fails afterwards (a database error) costs the user a new
|
|
88
|
+
* QR, which is the safe direction. The alternative — delete after success —
|
|
89
|
+
* leaves a window where two devices redeem the same code.
|
|
90
|
+
*/
|
|
91
|
+
export function consumePairing(
|
|
92
|
+
pairingId: string,
|
|
93
|
+
secret: string,
|
|
94
|
+
): { ok: true; candidates: ConnectCandidate[] } | { ok: false; reason: string } {
|
|
95
|
+
const now = Date.now();
|
|
96
|
+
sweep(now);
|
|
97
|
+
const entry = store().get(pairingId);
|
|
98
|
+
if (!entry) return { ok: false, reason: 'This pairing code has expired or was already used.' };
|
|
99
|
+
if (entry.expiresAt <= now) {
|
|
100
|
+
store().delete(pairingId);
|
|
101
|
+
return { ok: false, reason: 'This pairing code has expired.' };
|
|
102
|
+
}
|
|
103
|
+
if (entry.secretHash !== hashSecret(secret)) {
|
|
104
|
+
return { ok: false, reason: 'This pairing code does not match the one this server issued.' };
|
|
105
|
+
}
|
|
106
|
+
store().delete(pairingId);
|
|
107
|
+
return { ok: true, candidates: entry.candidates };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Drop every pending pairing. The tests use it; a running server has no reason to. */
|
|
111
|
+
export function resetPairings(): void {
|
|
112
|
+
globalThis.__kabmoPairings = undefined;
|
|
113
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The QR the server draws, decoded back.
|
|
8
|
+
*
|
|
9
|
+
* This is the one claim the pairing feature cannot afford to be wrong about: a
|
|
10
|
+
* code that renders but does not scan is indistinguishable from a broken camera,
|
|
11
|
+
* and the user's next move — rescan, restart the app — is the wrong one. The
|
|
12
|
+
* round trip is checked with the SAME decoder the login screen uses (`jsQR`), so
|
|
13
|
+
* a change to the encoder, the error-correction level or the payload size that
|
|
14
|
+
* pushes the code past what a phone can read fails here instead of in a hand.
|
|
15
|
+
*
|
|
16
|
+
* The matrix is expanded to RGBA by hand rather than through a PNG: the encoder
|
|
17
|
+
* produces modules, and going through an image format would test the image
|
|
18
|
+
* library instead of the code.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { describe, expect, test } from 'bun:test';
|
|
22
|
+
import jsQR from 'jsqr';
|
|
23
|
+
import { qrMatrix } from '@/server/lib/connect/qr.server';
|
|
24
|
+
import { encodePairingFragment, encodePairingPayload } from '@/shared/lib/connect/payload';
|
|
25
|
+
|
|
26
|
+
/** Modules per side of the quiet zone a scanner needs. */
|
|
27
|
+
const QUIET = 4;
|
|
28
|
+
/** Pixels per module. A phone camera needs a few; 4 is what the dialog draws. */
|
|
29
|
+
const SCALE = 4;
|
|
30
|
+
|
|
31
|
+
/** The matrix as RGBA pixels, black on white, with its quiet zone. */
|
|
32
|
+
function pixelsOf(rows: string[], size: number): { data: Uint8ClampedArray; width: number; height: number } {
|
|
33
|
+
const span = (size + QUIET * 2) * SCALE;
|
|
34
|
+
const data = new Uint8ClampedArray(span * span * 4).fill(255);
|
|
35
|
+
for (let row = 0; row < size; row += 1) {
|
|
36
|
+
const line = rows[row] ?? '';
|
|
37
|
+
for (let column = 0; column < size; column += 1) {
|
|
38
|
+
if (line[column] !== '1') continue;
|
|
39
|
+
for (let dy = 0; dy < SCALE; dy += 1) {
|
|
40
|
+
for (let dx = 0; dx < SCALE; dx += 1) {
|
|
41
|
+
const x = (column + QUIET) * SCALE + dx;
|
|
42
|
+
const y = (row + QUIET) * SCALE + dy;
|
|
43
|
+
const index = (y * span + x) * 4;
|
|
44
|
+
data[index] = 0;
|
|
45
|
+
data[index + 1] = 0;
|
|
46
|
+
data[index + 2] = 0;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return { data, width: span, height: span };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function decode(text: string): string | null {
|
|
55
|
+
const matrix = qrMatrix(text);
|
|
56
|
+
const pixels = pixelsOf(matrix.rows, matrix.size);
|
|
57
|
+
return jsQR(pixels.data, pixels.width, pixels.height)?.data ?? null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
describe('the pairing QR decodes', () => {
|
|
61
|
+
test('a browser link with one candidate', () => {
|
|
62
|
+
const fragment = encodePairingFragment({
|
|
63
|
+
v: 1,
|
|
64
|
+
pairingId: 'pair-1',
|
|
65
|
+
secret: 's'.repeat(43),
|
|
66
|
+
serverId: 'server-1',
|
|
67
|
+
label: 'rajeb-macbook',
|
|
68
|
+
expiresAt: new Date(Date.now() + 120_000).toISOString(),
|
|
69
|
+
candidates: [{ kind: 'tailscale', url: 'https://node.tailnet.ts.net' }],
|
|
70
|
+
});
|
|
71
|
+
const link = `https://node.tailnet.ts.net/pair#${fragment}`;
|
|
72
|
+
expect(decode(link)).toBe(link);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test('a browser link with four LAN candidates — the widest payload the page mints', () => {
|
|
76
|
+
const fragment = encodePairingFragment({
|
|
77
|
+
v: 1,
|
|
78
|
+
pairingId: 'c823cb3b-3baf-4913-84bc-d23a927a00a3',
|
|
79
|
+
secret: 'nchQ2h-p_F6e91pYoTH67sHVx6wRFZUHGPKlpgP07yQ',
|
|
80
|
+
serverId: 'AIJ2AIfUYpTIIt4uHx0iQvL7dQ5m5VkXZWy3PmhbVHQ',
|
|
81
|
+
label: 'Wijanarkos-Mac-mini',
|
|
82
|
+
expiresAt: new Date(Date.now() + 120_000).toISOString(),
|
|
83
|
+
candidates: [
|
|
84
|
+
{ kind: 'lan', url: 'http://192.168.18.79:3990' },
|
|
85
|
+
{ kind: 'lan', url: 'http://100.98.171.79:3990' },
|
|
86
|
+
{ kind: 'lan', url: 'http://192.168.139.3:3990' },
|
|
87
|
+
{ kind: 'lan', url: 'http://172.16.102.251:3990' },
|
|
88
|
+
],
|
|
89
|
+
});
|
|
90
|
+
const link = `http://192.168.18.79:3990/pair#${fragment}`;
|
|
91
|
+
expect(decode(link)).toBe(link);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
test('the deep link a native shell registers', () => {
|
|
95
|
+
const link = encodePairingPayload({
|
|
96
|
+
v: 1,
|
|
97
|
+
pairingId: 'pair-2',
|
|
98
|
+
secret: 'x'.repeat(43),
|
|
99
|
+
serverId: 'server-2',
|
|
100
|
+
label: 'desk',
|
|
101
|
+
expiresAt: new Date(Date.now() + 120_000).toISOString(),
|
|
102
|
+
candidates: [{ kind: 'cloudflare', url: 'https://kabmo.example.com' }],
|
|
103
|
+
});
|
|
104
|
+
expect(decode(link)).toBe(link);
|
|
105
|
+
});
|
|
106
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The QR matrix, as rows of `0`/`1`.
|
|
8
|
+
*
|
|
9
|
+
* A matrix rather than an SVG string: the client draws `<rect>`s from it, so the
|
|
10
|
+
* pairing dialog never injects server-produced markup into the page. The payload
|
|
11
|
+
* is a deep link carrying a one-time secret, and `dangerouslySetInnerHTML` on a
|
|
12
|
+
* string built from it is exactly the kind of shortcut that turns a QR renderer
|
|
13
|
+
* into an injection point.
|
|
14
|
+
*
|
|
15
|
+
* Error correction is `M` (~15%): the code is shown on a screen and scanned at
|
|
16
|
+
* arm's length, so a little tolerance is worth the extra modules.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import qrcode from 'qrcode-generator';
|
|
20
|
+
import type { QrMatrix } from '@/shared/lib/connect/types';
|
|
21
|
+
|
|
22
|
+
export function qrMatrix(text: string): QrMatrix {
|
|
23
|
+
const qr = qrcode(0, 'M');
|
|
24
|
+
qr.addData(text);
|
|
25
|
+
qr.make();
|
|
26
|
+
const size = qr.getModuleCount();
|
|
27
|
+
const rows: string[] = [];
|
|
28
|
+
for (let row = 0; row < size; row += 1) {
|
|
29
|
+
let line = '';
|
|
30
|
+
for (let column = 0; column < size; column += 1) {
|
|
31
|
+
line += qr.isDark(row, column) ? '1' : '0';
|
|
32
|
+
}
|
|
33
|
+
rows.push(line);
|
|
34
|
+
}
|
|
35
|
+
return { size, rows };
|
|
36
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* One argv spawn for the Connect page's provider CLIs.
|
|
8
|
+
*
|
|
9
|
+
* `tailscale` and `cloudflared` are both invoked as argv, never through a shell:
|
|
10
|
+
* the only variable part is a port number this process chose, and a shell would
|
|
11
|
+
* add an expansion surface for no benefit. The timeout is mandatory at every
|
|
12
|
+
* call site because both CLIs can block on a daemon that is not answering —
|
|
13
|
+
* `tailscale status` against a stopped daemon hangs, and a settings page that
|
|
14
|
+
* waits on it looks like a broken server.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export interface RunResult {
|
|
18
|
+
ok: boolean;
|
|
19
|
+
stdout: string;
|
|
20
|
+
stderr: string;
|
|
21
|
+
code: number | null;
|
|
22
|
+
/** Set when the binary could not be spawned at all. */
|
|
23
|
+
error: string | null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface RunOptions {
|
|
27
|
+
timeoutMs?: number;
|
|
28
|
+
env?: Record<string, string>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Run `argv` and collect both streams. Never throws. */
|
|
32
|
+
export async function run(argv: string[], options: RunOptions = {}): Promise<RunResult> {
|
|
33
|
+
const timeoutMs = options.timeoutMs ?? 5_000;
|
|
34
|
+
let proc: Bun.Subprocess<'ignore', 'pipe', 'pipe'>;
|
|
35
|
+
try {
|
|
36
|
+
proc = Bun.spawn({
|
|
37
|
+
cmd: argv,
|
|
38
|
+
stdin: 'ignore',
|
|
39
|
+
stdout: 'pipe',
|
|
40
|
+
stderr: 'pipe',
|
|
41
|
+
env: { ...Bun.env, ...options.env },
|
|
42
|
+
});
|
|
43
|
+
} catch (error) {
|
|
44
|
+
return {
|
|
45
|
+
ok: false,
|
|
46
|
+
stdout: '',
|
|
47
|
+
stderr: '',
|
|
48
|
+
code: null,
|
|
49
|
+
error: error instanceof Error ? error.message : String(error),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const timer = setTimeout(() => {
|
|
54
|
+
try {
|
|
55
|
+
proc.kill('SIGKILL');
|
|
56
|
+
} catch {
|
|
57
|
+
// Already gone: the command finished inside its own timeout.
|
|
58
|
+
}
|
|
59
|
+
}, timeoutMs);
|
|
60
|
+
|
|
61
|
+
// The timeout must SETTLE the call, not merely kill the process. A CLI that
|
|
62
|
+
// spawns a helper holding the pipe open leaves `Response(proc.stdout).text()`
|
|
63
|
+
// pending forever, and the settings page then waits on a request that never
|
|
64
|
+
// answers — measured with `tailscale serve --bg`, which hung the route for the
|
|
65
|
+
// full three minutes the smoke test allowed.
|
|
66
|
+
const deadline = Promise.withResolvers<RunResult>();
|
|
67
|
+
setTimeout(() => {
|
|
68
|
+
deadline.resolve({
|
|
69
|
+
ok: false,
|
|
70
|
+
stdout: '',
|
|
71
|
+
stderr: '',
|
|
72
|
+
code: null,
|
|
73
|
+
error: `timed out after ${timeoutMs} ms`,
|
|
74
|
+
});
|
|
75
|
+
}, timeoutMs + 250);
|
|
76
|
+
|
|
77
|
+
try {
|
|
78
|
+
return await Promise.race([
|
|
79
|
+
(async (): Promise<RunResult> => {
|
|
80
|
+
const [stdout, stderr] = await Promise.all([
|
|
81
|
+
new Response(proc.stdout).text(),
|
|
82
|
+
new Response(proc.stderr).text(),
|
|
83
|
+
]);
|
|
84
|
+
const code = await proc.exited;
|
|
85
|
+
return { ok: code === 0, stdout, stderr, code, error: null };
|
|
86
|
+
})(),
|
|
87
|
+
deadline.promise,
|
|
88
|
+
]);
|
|
89
|
+
} finally {
|
|
90
|
+
clearTimeout(timer);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** The absolute path of a binary on PATH, or null. */
|
|
95
|
+
export function which(binary: string): string | null {
|
|
96
|
+
try {
|
|
97
|
+
return Bun.which(binary) ?? null;
|
|
98
|
+
} catch {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
}
|