@kabmo-labs/kabmo 0.35.0 → 0.37.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.
Files changed (229) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +435 -432
  3. package/dist/client/static/js/{CsvGrid-0amzgtd7.js → CsvGrid-xb429wvb.js} +2 -2
  4. package/dist/client/static/js/{DocxView-bxjhzxe9.js → DocxView-g58e0bs7.js} +2 -2
  5. package/dist/client/static/js/{DrawioView-7s1yqsf4.js → DrawioView-1j66avvy.js} +2 -2
  6. package/dist/client/static/js/{ImageView-ycfbn66h.js → ImageView-kraqkypn.js} +1 -1
  7. package/dist/client/static/js/{LayoutWrapper-tw1q1x0g.js → LayoutWrapper-85dhbn62.js} +2 -2
  8. package/dist/client/static/js/{Modal-wqjactyd.js → Modal-f0nfya07.js} +16 -16
  9. package/dist/client/static/js/{PdfView-x6dmtwvr.js → PdfView-nddkrky9.js} +1 -1
  10. package/dist/client/static/js/{SessionsView-t85wq0me.js → SessionsView-a595m6g1.js} +1 -1
  11. package/dist/client/static/js/{SheetView-n52nvz8s.js → SheetView-s2p4sk6b.js} +13 -13
  12. package/dist/client/static/js/{SvgPreview-59z7syme.js → SvgPreview-ppdx4yb9.js} +1 -1
  13. package/dist/client/static/js/{abnfDiagram-O67JEVCF-91gnt049.js → abnfDiagram-O67JEVCF-5cjzxcaq.js} +1 -1
  14. package/dist/client/static/js/architecture-7GRP2DOG-7ewrw5vc.js +1 -0
  15. package/dist/client/static/js/{architectureDiagram-NJMV4G6O-5b9qtff2.js → architectureDiagram-NJMV4G6O-62mygavm.js} +3 -3
  16. package/dist/client/static/js/{astro-31cbyw7b.js → astro-80bs6hvg.js} +1 -1
  17. package/dist/client/static/js/bash-b3rwyg5p.js +1 -0
  18. package/dist/client/static/js/{blockDiagram-BEXU5L5S-6f23fjkn.js → blockDiagram-BEXU5L5S-s5yz9hcd.js} +2 -2
  19. package/dist/client/static/js/{c4Diagram-YGBWAQC7-76t6d3am.js → c4Diagram-YGBWAQC7-rf9xkmrm.js} +2 -2
  20. package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-f9tb19xm.js → classDiagram-v2-NBCMYWYE-zfm2cj2a.js} +1 -1
  21. package/dist/client/static/js/{cose-bilkent-JH36ORCC-t6nwrbwj.js → cose-bilkent-JH36ORCC-fmgpv55e.js} +1 -1
  22. package/dist/client/static/js/cpp-y0t6mynx.js +1 -0
  23. package/dist/client/static/js/css-r2nhvzff.js +1 -0
  24. package/dist/client/static/js/cynefin-OW5HDTMX-yyyx3px0.js +1 -0
  25. package/dist/client/static/js/{cynefinDiagram-VND7K2PF-69gc244j.js → cynefinDiagram-VND7K2PF-468r5xc2.js} +1 -1
  26. package/dist/client/static/js/{dagre-6A5THRUB-54bry3ey.js → dagre-6A5THRUB-w370qmgj.js} +2 -2
  27. package/dist/client/static/js/{diagram-22UHCM2B-gfkebye6.js → diagram-22UHCM2B-sfvfjjsy.js} +3 -3
  28. package/dist/client/static/js/{diagram-3UASUU5V-a1mr319f.js → diagram-3UASUU5V-3r2c8s14.js} +1 -1
  29. package/dist/client/static/js/{diagram-ATOU4E4O-tkyk0qbe.js → diagram-ATOU4E4O-yathy97a.js} +3 -3
  30. package/dist/client/static/js/{diagram-CDSNMT55-np0hc9m2.js → diagram-CDSNMT55-kk437kxq.js} +2 -2
  31. package/dist/client/static/js/{diagram-MLGK6HIB-nh06fshp.js → diagram-MLGK6HIB-qdxfjjhf.js} +1 -1
  32. package/dist/client/static/js/{diagram-MPIPVDR6-27q2veks.js → diagram-MPIPVDR6-dfqeqa1d.js} +1 -1
  33. package/dist/client/static/js/{dockerfile-4rtt6c0f.js → dockerfile-yxrt509r.js} +1 -1
  34. package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-x9p9jqe8.js → ebnfDiagram-ZINNZB2B-s0b0vv4k.js} +1 -1
  35. package/dist/client/static/js/{elk-276RUBZZ-fw7waks3.js → elk-276RUBZZ-mtpw0spa.js} +1 -1
  36. package/dist/client/static/js/{erDiagram-OPXOYQCR-fdfgzr5d.js → erDiagram-OPXOYQCR-agjdsm1b.js} +4 -4
  37. package/dist/client/static/js/{erlang-trjm07as.js → erlang-6m6tpt72.js} +1 -1
  38. package/dist/client/static/js/eventmodeling-NTZA5JFV-cx3ztxfz.js +1 -0
  39. package/dist/client/static/js/flowDiagram-KWPJA3E3-267mw6sv.js +1 -0
  40. package/dist/client/static/js/{ganttDiagram-FUAMR5RP-2avbqgdr.js → ganttDiagram-FUAMR5RP-z6ywqqc1.js} +1 -1
  41. package/dist/client/static/js/gitGraph-4MIJSDKK-eg9r85ak.js +1 -0
  42. package/dist/client/static/js/{gitGraphDiagram-X574FWY7-9jmc0a3g.js → gitGraphDiagram-X574FWY7-bvbmfw6h.js} +2 -2
  43. package/dist/client/static/js/graphql-skw5krjr.js +1 -0
  44. package/dist/client/static/js/{index-a8ffattk.js → index-059qyaj0.js} +2 -2
  45. package/dist/client/static/js/{index-8f9x7ev8.js → index-09gx6edj.js} +1 -1
  46. package/dist/client/static/js/index-0mvcbbmy.js +12 -0
  47. package/dist/client/static/js/{index-fvc0x6nx.js → index-0sqa91wb.js} +3 -3
  48. package/dist/client/static/js/{index-8mwragbj.js → index-15zn3sns.js} +2 -2
  49. package/dist/client/static/js/{index-4vybd9e7.js → index-1tyvk778.js} +1 -1
  50. package/dist/client/static/js/{index-43qpbxjv.js → index-1y9r4frb.js} +2 -2
  51. package/dist/client/static/js/{index-a628fg4m.js → index-21b3zyrd.js} +2 -2
  52. package/dist/client/static/js/{index-vnw3hbeg.js → index-302d35e5.js} +27 -27
  53. package/dist/client/static/js/{index-jc1yagmk.js → index-3zc1b0dv.js} +2 -2
  54. package/dist/client/static/js/{index-t6c0pd43.js → index-49dhv8ry.js} +2 -2
  55. package/dist/client/static/js/{index-xxtsm2rb.js → index-5fn0agag.js} +2 -2
  56. package/dist/client/static/js/{index-yq39qbs1.js → index-64mb65wx.js} +2 -2
  57. package/dist/client/static/js/{index-xs1m0bpt.js → index-6q80csr0.js} +1 -1
  58. package/dist/client/static/js/{index-pc6eg8h2.js → index-72t6kqjx.js} +2 -2
  59. package/dist/client/static/js/{index-y3ms153k.js → index-7fdp9c7m.js} +2 -2
  60. package/dist/client/static/js/{index-py2k8std.js → index-7sa2e8mn.js} +2 -2
  61. package/dist/client/static/js/{index-7q02xnvq.js → index-83ts8zmk.js} +1 -1
  62. package/dist/client/static/js/{index-9ketbkh6.js → index-8e0s9p45.js} +1 -1
  63. package/dist/client/static/js/{index-tp7yb3bv.js → index-a0bdavdr.js} +2 -2
  64. package/dist/client/static/js/{index-7ct7qrsp.js → index-actppd4z.js} +2 -2
  65. package/dist/client/static/js/{index-k7q01ye4.js → index-cx89yk15.js} +2 -2
  66. package/dist/client/static/js/{index-vq6wts05.js → index-dt7e1328.js} +2 -2
  67. package/dist/client/static/js/{index-w7tpgt46.js → index-es3pt29g.js} +1 -1
  68. package/dist/client/static/js/{index-pzbssnsc.js → index-gbfg0anm.js} +2 -2
  69. package/dist/client/static/js/{index-qqz6bcdd.js → index-h7pn9qw6.js} +2 -2
  70. package/dist/client/static/js/{index-kdkfyrja.js → index-hbtk0c12.js} +2 -2
  71. package/dist/client/static/js/index-j7r414hf.js +2 -0
  72. package/dist/client/static/js/{index-ee2p07eg.js → index-jpkj6vqp.js} +1 -1
  73. package/dist/client/static/js/{index-nb8tp4mj.js → index-k06med7d.js} +30 -30
  74. package/dist/client/static/js/{index-8x9ecxb0.js → index-kzhtmrh0.js} +1 -1
  75. package/dist/client/static/js/{index-3ecsp1rx.js → index-m3j5yx5f.js} +3 -3
  76. package/dist/client/static/js/{index-sdby39w4.js → index-m87yykre.js} +3 -3
  77. package/dist/client/static/js/{index-ek2e773p.js → index-nmc30xaz.js} +1 -1
  78. package/dist/client/static/js/{index-p16scjt7.js → index-ntxm8pw3.js} +2 -2
  79. package/dist/client/static/js/{index-0v34a7wf.js → index-pd0140dx.js} +1 -1
  80. package/dist/client/static/js/{index-zh2jj56s.js → index-qkscve6n.js} +2 -2
  81. package/dist/client/static/js/{index-whbtxmwh.js → index-qz8mbxm9.js} +2 -2
  82. package/dist/client/static/js/{index-ncrenheb.js → index-qznwd6g8.js} +160 -160
  83. package/dist/client/static/js/{index-6f6cmcbq.js → index-sa9cp6km.js} +2 -2
  84. package/dist/client/static/js/{index-jmxqefe3.js → index-sezz011q.js} +1 -1
  85. package/dist/client/static/js/{index-rbgemjsp.js → index-t07b31ny.js} +3 -3
  86. package/dist/client/static/js/index-tcegdd2t.js +1 -0
  87. package/dist/client/static/js/{index-1wjp16f0.js → index-vtbbfwx0.js} +2 -2
  88. package/dist/client/static/js/{index-2v1nmxwr.js → index-w9zxmev3.js} +5 -5
  89. package/dist/client/static/js/{index-w5373tg1.js → index-we1rpftn.js} +2 -2
  90. package/dist/client/static/js/{index-b8s3xraa.js → index-xearvz2z.js} +5 -5
  91. package/dist/client/static/js/{index-rv89xpaf.js → index-xya34x4v.js} +2 -2
  92. package/dist/client/static/js/{index-mc4nefs7.js → index-z0frtyje.js} +1 -1
  93. package/dist/client/static/js/{index-7smwzkvq.js → index-z6g74h7g.js} +2 -2
  94. package/dist/client/static/js/{index-rkn0bxxt.js → index-z7qnffwj.js} +1 -1
  95. package/dist/client/static/js/{index-pnt0vc59.js → index-zvfvqvn9.js} +2 -2
  96. package/dist/client/static/js/info-A6RAGUB7-7qhah7fs.js +1 -0
  97. package/dist/client/static/js/{infoDiagram-VRGFBTTK-g2dky5xg.js → infoDiagram-VRGFBTTK-58bv28d4.js} +1 -1
  98. package/dist/client/static/js/ini-cg0a5wm3.js +1 -0
  99. package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-exrcjwp1.js → ishikawaDiagram-OU5B5YK6-tz6b0caw.js} +1 -1
  100. package/dist/client/static/js/java-vcck089n.js +1 -0
  101. package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-pn752qa5.js → journeyDiagram-ZHPQQLJL-ydamm17a.js} +2 -2
  102. package/dist/client/static/js/jsx-ht9zyzwa.js +1 -0
  103. package/dist/client/static/js/{julia-evn99h2m.js → julia-v7j460gw.js} +1 -1
  104. package/dist/client/static/js/{kanban-definition-PNTS6WVX-v8nvr373.js → kanban-definition-PNTS6WVX-7jxfsf17.js} +1 -1
  105. package/dist/client/static/js/lua-ke895s2q.js +1 -0
  106. package/dist/client/static/js/markdown-gwmsh53r.js +1 -0
  107. package/dist/client/static/js/{mermaid.core-egzv89zv.js → mermaid.core-vty0aq6f.js} +6 -6
  108. package/dist/client/static/js/{mindmap-definition-NLK3R4M7-t9njmv2w.js → mindmap-definition-NLK3R4M7-ra4wrts4.js} +2 -2
  109. package/dist/client/static/js/one-dark-pro-2pywnqrh.js +1 -0
  110. package/dist/client/static/js/one-light-vfgdt4wf.js +1 -0
  111. package/dist/client/static/js/packet-AYTQ26CC-ag2g7tbk.js +1 -0
  112. package/dist/client/static/js/{pegDiagram-GJSIUBJH-zhycy2b7.js → pegDiagram-GJSIUBJH-ydjcfea9.js} +1 -1
  113. package/dist/client/static/js/{perl-506fy8m8.js → perl-gg4jdkcr.js} +1 -1
  114. package/dist/client/static/js/{php-axtsvxck.js → php-2q8fm6k8.js} +1 -1
  115. package/dist/client/static/js/pie-WAS4IAKB-nqcyj3x1.js +1 -0
  116. package/dist/client/static/js/{pieDiagram-5QR66LMP-sgctvma2.js → pieDiagram-5QR66LMP-wh04y7wp.js} +1 -1
  117. package/dist/client/static/js/properties-mzvvbqg5.js +1 -0
  118. package/dist/client/static/js/python-3w64wsyd.js +1 -0
  119. package/dist/client/static/js/{quadrantDiagram-O4NWA36T-kzzhdcph.js → quadrantDiagram-O4NWA36T-4mhbag8n.js} +1 -1
  120. package/dist/client/static/js/r-32re2zwb.js +1 -0
  121. package/dist/client/static/js/radar-RG4KPBEZ-60gby7be.js +1 -0
  122. package/dist/client/static/js/railroad-74A4TZTK-cnkmcjse.js +1 -0
  123. package/dist/client/static/js/railroad-abnf-HS5TGJTU-qgfdnazd.js +1 -0
  124. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-609h6cpx.js +1 -0
  125. package/dist/client/static/js/railroad-peg-WCYAUIDC-xqnytjhg.js +1 -0
  126. package/dist/client/static/js/{railroadDiagram-XR7U4H2S-nzjffwxm.js → railroadDiagram-XR7U4H2S-pagmr4hc.js} +1 -1
  127. package/dist/client/static/js/{requirementDiagram-PLB6GJNP-tz4xxn4d.js → requirementDiagram-PLB6GJNP-jhfhp4eq.js} +1 -1
  128. package/dist/client/static/js/{ruby-qp7zfk2m.js → ruby-vag6a82m.js} +1 -1
  129. package/dist/client/static/js/{rust-fz913fvw.js → rust-yntkm6hw.js} +1 -1
  130. package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-2wcb0xr6.js → sankeyDiagram-IPEJSGJF-qrfxzvp3.js} +2 -2
  131. package/dist/client/static/js/{sass-gnk9vsyp.js → sass-kbwea482.js} +1 -1
  132. package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-vqgebfns.js → sequenceDiagram-PO4LG4MO-fpznwnva.js} +5 -5
  133. package/dist/client/static/js/{sizeCapture-INFHLROL-xc314tes.js → sizeCapture-INFHLROL-3hz930jg.js} +1 -1
  134. package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-8bd9b1h8.js → stateDiagram-v2-GCMORJYK-2m99syxm.js} +2 -2
  135. package/dist/client/static/js/{svelte-brpgzrtv.js → svelte-mwtx07d9.js} +1 -1
  136. package/dist/client/static/js/{swimlanes-2SLR337P-t6hbdzcw.js → swimlanes-2SLR337P-hmhd360r.js} +1 -1
  137. package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-a8b7z74e.js +8 -0
  138. package/dist/client/static/js/{timeline-definition-EJHVYXUP-2txxasx5.js → timeline-definition-EJHVYXUP-765y3ssa.js} +2 -2
  139. package/dist/client/static/js/treeView-Q6P3EWNA-8djqab8k.js +1 -0
  140. package/dist/client/static/js/treemap-WGGIJYW6-hdztnffk.js +1 -0
  141. package/dist/client/static/js/tsx-nm94hed6.js +1 -0
  142. package/dist/client/static/js/typescript-0s2t05jj.js +1 -0
  143. package/dist/client/static/js/{usecaseDiagram-POWQR4AR-3x353hn4.js → usecaseDiagram-POWQR4AR-rex2j507.js} +2 -2
  144. package/dist/client/static/js/{vennDiagram-UO4OBE2U-cerpss8e.js → vennDiagram-UO4OBE2U-wd51qq26.js} +1 -1
  145. package/dist/client/static/js/{vue-apnkw9qy.js → vue-j8vb9d7r.js} +1 -1
  146. package/dist/client/static/js/wardley-WFR3VGLG-avby77vv.js +1 -0
  147. package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-cx6jfsbf.js → wardleyDiagram-VNRHLVJA-6jdqn8f7.js} +1 -1
  148. package/dist/client/static/js/xml-81hxjjt4.js +1 -0
  149. package/dist/client/static/js/{xychartDiagram-PMCCYNJV-tgn23xj1.js → xychartDiagram-PMCCYNJV-kcz8y04e.js} +2 -2
  150. package/dist/client/static/js/yaml-yssayv8a.js +1 -0
  151. package/package.json +1 -1
  152. package/src/client/components/settings/apply-side-effects.test.ts +5 -4
  153. package/src/client/components/settings/categories/ConnectSettings.tsx +8 -1
  154. package/src/client/components/settings/categories/connect-settings/CloudflareConfig.test.tsx +84 -0
  155. package/src/client/components/settings/categories/connect-settings/CloudflareConfig.tsx +68 -0
  156. package/src/client/components/settings/categories/connect-settings/PairDialog.test.tsx +49 -49
  157. package/src/client/components/settings/categories/connect-settings/PairDialog.tsx +12 -8
  158. package/src/client/components/settings/categories/connect-settings/QrCode.tsx +19 -2
  159. package/src/client/hooks/connect/use-connect-status.ts +44 -19
  160. package/src/client/hooks/connect/use-pairing.ts +5 -0
  161. package/src/client/hooks/ui/icon-style.ts +7 -4
  162. package/src/client/hooks/ui/style-attributes.test.ts +11 -11
  163. package/src/client/hooks/ui/surface-style.ts +8 -5
  164. package/src/client/lib/notifications/watch.ts +4 -1
  165. package/src/server/lib/assets/shell-attributes.server.ts +12 -9
  166. package/src/server/lib/assets/shell-attributes.test.ts +18 -13
  167. package/src/server/lib/connect/cloudflared-config.server.ts +236 -0
  168. package/src/server/lib/connect/cloudflared-config.test.ts +245 -0
  169. package/src/server/lib/connect/cloudflared.lifecycle.test.ts +116 -15
  170. package/src/server/lib/connect/cloudflared.server.ts +53 -66
  171. package/src/server/lib/connect/pairing.server.ts +33 -0
  172. package/src/server/lib/connect/qr-png.server.test.ts +93 -0
  173. package/src/server/lib/connect/qr-png.server.ts +119 -0
  174. package/src/server/lib/connect/status.server.ts +10 -4
  175. package/src/server/routes/connect/index.ts +2 -0
  176. package/src/server/routes/connect/pair-qr.test.ts +72 -0
  177. package/src/server/routes/connect/pair-qr.ts +44 -0
  178. package/src/server/routes/connect/pair.ts +8 -2
  179. package/src/server/routes/connect/tunnels.test.ts +141 -0
  180. package/src/server/routes/connect/tunnels.ts +32 -7
  181. package/src/server/routes/notifications/stream.ts +11 -2
  182. package/src/shared/lib/connect/types.ts +7 -0
  183. package/src/shared/lib/icons/icon-paint-authority.ts +5 -3
  184. package/src/shared/lib/theme/icon-style.test.ts +8 -5
  185. package/src/shared/lib/theme/icon-style.ts +15 -7
  186. package/src/shared/lib/theme/surface-style.test.ts +8 -5
  187. package/src/shared/lib/theme/surface-style.ts +17 -7
  188. package/src/shared/lib/workspace/sidebar-style.test.ts +7 -8
  189. package/src/shared/lib/workspace/sidebar-style.ts +7 -8
  190. package/dist/client/static/js/architecture-7GRP2DOG-bajpnvy7.js +0 -1
  191. package/dist/client/static/js/bash-0h36tk0k.js +0 -1
  192. package/dist/client/static/js/cpp-4wp9sy20.js +0 -1
  193. package/dist/client/static/js/css-c9nsbkh6.js +0 -1
  194. package/dist/client/static/js/cynefin-OW5HDTMX-8q9e90m8.js +0 -1
  195. package/dist/client/static/js/eventmodeling-NTZA5JFV-kn4hsm3p.js +0 -1
  196. package/dist/client/static/js/flowDiagram-KWPJA3E3-ah8cvps1.js +0 -1
  197. package/dist/client/static/js/gitGraph-4MIJSDKK-hvavh16n.js +0 -1
  198. package/dist/client/static/js/graphql-hbkmxsty.js +0 -1
  199. package/dist/client/static/js/index-btr2w8cq.js +0 -12
  200. package/dist/client/static/js/index-dfzrpy54.js +0 -2
  201. package/dist/client/static/js/index-sbd5e816.js +0 -1
  202. package/dist/client/static/js/info-A6RAGUB7-fmjz8qwg.js +0 -1
  203. package/dist/client/static/js/ini-72yrpvd4.js +0 -1
  204. package/dist/client/static/js/java-ab5tb2ra.js +0 -1
  205. package/dist/client/static/js/jsx-25zj9j3k.js +0 -1
  206. package/dist/client/static/js/lua-j5w0c9wm.js +0 -1
  207. package/dist/client/static/js/markdown-j6hn4377.js +0 -1
  208. package/dist/client/static/js/one-dark-pro-bm3r4js7.js +0 -1
  209. package/dist/client/static/js/one-light-e07dt7sy.js +0 -1
  210. package/dist/client/static/js/packet-AYTQ26CC-cwr6n1cm.js +0 -1
  211. package/dist/client/static/js/pie-WAS4IAKB-h1ebfzgt.js +0 -1
  212. package/dist/client/static/js/properties-q8njes42.js +0 -1
  213. package/dist/client/static/js/python-vqxc7181.js +0 -1
  214. package/dist/client/static/js/r-0k5eej8m.js +0 -1
  215. package/dist/client/static/js/radar-RG4KPBEZ-k7p1m364.js +0 -1
  216. package/dist/client/static/js/railroad-74A4TZTK-d08dw3t0.js +0 -1
  217. package/dist/client/static/js/railroad-abnf-HS5TGJTU-txnjycgk.js +0 -1
  218. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-p0r3cv6w.js +0 -1
  219. package/dist/client/static/js/railroad-peg-WCYAUIDC-sryk900a.js +0 -1
  220. package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-c1czc7kv.js +0 -8
  221. package/dist/client/static/js/treeView-Q6P3EWNA-77kj68p1.js +0 -1
  222. package/dist/client/static/js/treemap-WGGIJYW6-rw94xc82.js +0 -1
  223. package/dist/client/static/js/tsx-yd5wt250.js +0 -1
  224. package/dist/client/static/js/typescript-v7z7crfe.js +0 -1
  225. package/dist/client/static/js/wardley-WFR3VGLG-18xe4fhz.js +0 -1
  226. package/dist/client/static/js/xml-94fhzrfs.js +0 -1
  227. package/dist/client/static/js/yaml-s8af9rnw.js +0 -1
  228. package/src/client/components/settings/categories/connect-settings/qr-image.ts +0 -76
  229. package/src/server/lib/connect/cloudflared.server.test.ts +0 -65
@@ -0,0 +1,93 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The pairing QR as a PNG.
8
+ *
9
+ * Two properties decide whether a downloaded file is usable, and neither is
10
+ * visible in an assertion about "a file was produced":
11
+ *
12
+ * - **It is a real PNG.** The first attempt handed the user an SVG, which most
13
+ * image viewers refuse to open — the button looked like it worked and the file
14
+ * was unreadable.
15
+ * - **It still decodes.** The pixels are read back from the encoded bytes (IHDR,
16
+ * the inflate of IDAT, the packed 1-bit rows) and fed to the same `jsQR` the
17
+ * login screen uses. That is the decoder the scan path runs, not a restatement
18
+ * of the encoder.
19
+ */
20
+
21
+ import { describe, expect, test } from 'bun:test';
22
+ import { inflateSync } from 'node:zlib';
23
+ import jsQR from 'jsqr';
24
+ import { qrPng } from '@/server/lib/connect/qr-png.server';
25
+ import { qrMatrix } from '@/server/lib/connect/qr.server';
26
+
27
+ const PAYLOAD = 'https://kabmo.example/pair#eyJwYWlyaW5nSWQiOiJhYmMifQ';
28
+
29
+ /** Read the encoded PNG back into RGBA, the way an image viewer would. */
30
+ function pixelsOf(png: Uint8Array): { data: Uint8ClampedArray; width: number; height: number } {
31
+ const view = new DataView(png.buffer, png.byteOffset, png.byteLength);
32
+ let offset = 8;
33
+ let width = 0;
34
+ let height = 0;
35
+ const idat: Uint8Array[] = [];
36
+ while (offset + 8 <= png.byteLength) {
37
+ const length = view.getUint32(offset);
38
+ const type = new TextDecoder().decode(png.subarray(offset + 4, offset + 8));
39
+ const data = png.subarray(offset + 8, offset + 8 + length);
40
+ if (type === 'IHDR') {
41
+ width = view.getUint32(offset + 8);
42
+ height = view.getUint32(offset + 12);
43
+ expect(data[8]).toBe(1); // bit depth
44
+ expect(data[9]).toBe(0); // greyscale
45
+ }
46
+ if (type === 'IDAT') idat.push(data);
47
+ offset += 12 + length;
48
+ }
49
+
50
+ const rowBytes = Math.ceil(width / 8);
51
+ const raw = inflateSync(Buffer.concat(idat));
52
+ const rgba = new Uint8ClampedArray(width * height * 4);
53
+ for (let y = 0; y < height; y += 1) {
54
+ const start = y * (rowBytes + 1);
55
+ expect(raw[start]).toBe(0); // filter: none
56
+ for (let x = 0; x < width; x += 1) {
57
+ const dark = (raw[start + 1 + (x >> 3)]! & (0x80 >> (x & 7))) === 0;
58
+ const value = dark ? 0 : 255;
59
+ const index = (y * width + x) * 4;
60
+ rgba[index] = value;
61
+ rgba[index + 1] = value;
62
+ rgba[index + 2] = value;
63
+ rgba[index + 3] = 255;
64
+ }
65
+ }
66
+ return { data: rgba, width, height };
67
+ }
68
+
69
+ describe('pairing QR PNG', () => {
70
+ test('is a PNG whose pixels still decode to the payload', () => {
71
+ const matrix = qrMatrix(PAYLOAD);
72
+ const png = qrPng(matrix);
73
+
74
+ // The signature is what a viewer sniffs; a viewer that refuses the file says
75
+ // nothing about the pixels, so this is checked before decoding.
76
+ expect([...png.subarray(0, 8)]).toEqual([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
77
+
78
+ const { data, width, height } = pixelsOf(png);
79
+ // Four modules of quiet zone on each side, ten pixels per module.
80
+ expect(width).toBe((matrix.size + 8) * 10);
81
+ expect(height).toBe(width);
82
+ expect(jsQR(data, width, height)?.data).toBe(PAYLOAD);
83
+ });
84
+
85
+ test('keeps a quiet zone, which is what a scanner needs to find the code at all', () => {
86
+ const png = qrPng(qrMatrix(PAYLOAD));
87
+ const { data, width } = pixelsOf(png);
88
+ // The first module starts at 40 px; the border must still be paper.
89
+ for (let x = 0; x < 40; x += 1) {
90
+ expect(data[(10 * width + x) * 4]).toBe(255);
91
+ }
92
+ });
93
+ });
@@ -0,0 +1,119 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The pairing QR as a PNG the user can open anywhere.
8
+ *
9
+ * The browser draws the code from the same matrix, but a SAVED code has to
10
+ * survive leaving the page: an SVG is unreadable to most image viewers and
11
+ * preview panes, so the file handed to the operating system is a raster PNG at
12
+ * an integer number of pixels per module. PNG is lossless, so the saved pixels
13
+ * are exactly the drawn ones — no resampling of module edges, which is what a
14
+ * binarizer cannot read.
15
+ *
16
+ * Written by hand rather than through an image library: the server already has
17
+ * the module matrix, and the encoding is a signature, three chunks and a zlib
18
+ * stream. `Bun.Image` can only START from an encoded image, so it would need a
19
+ * second format (a BMP) as an intermediate — two encoders for one picture.
20
+ */
21
+
22
+ import { deflateSync } from 'node:zlib';
23
+ import type { QrMatrix } from '@/shared/lib/connect/types';
24
+
25
+ /** Four modules of margin, which is what a scanner requires. */
26
+ const QUIET_ZONE = 4;
27
+
28
+ /**
29
+ * Pixels per module in the saved file.
30
+ *
31
+ * A code shown on screen needs ~4 px per module for a camera to read it
32
+ * (`jsQR` failed on 3 px captures); a FILE is often uploaded from a device with
33
+ * no camera, so the margin is doubled — a larger file cannot be too small to
34
+ * scan.
35
+ */
36
+ const MODULE_PX = 10;
37
+
38
+ const SIGNATURE = Uint8Array.of(0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a);
39
+
40
+ const CRC_TABLE = (() => {
41
+ const table = new Uint32Array(256);
42
+ for (let n = 0; n < 256; n += 1) {
43
+ let c = n;
44
+ for (let bit = 0; bit < 8; bit += 1) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;
45
+ table[n] = c >>> 0;
46
+ }
47
+ return table;
48
+ })();
49
+
50
+ function crc32(bytes: Uint8Array): number {
51
+ let c = 0xffffffff;
52
+ for (const byte of bytes) c = (CRC_TABLE[(c ^ byte) & 0xff]! ^ (c >>> 8)) >>> 0;
53
+ return (c ^ 0xffffffff) >>> 0;
54
+ }
55
+
56
+ function chunk(type: string, data: Uint8Array): Uint8Array {
57
+ const typeBytes = new TextEncoder().encode(type);
58
+ const out = new Uint8Array(12 + data.length);
59
+ const view = new DataView(out.buffer);
60
+ view.setUint32(0, data.length);
61
+ out.set(typeBytes, 4);
62
+ out.set(data, 8);
63
+ view.setUint32(8 + data.length, crc32(out.subarray(4, 8 + data.length)));
64
+ return out;
65
+ }
66
+
67
+ /**
68
+ * A 1-bit greyscale PNG: white paper, black modules.
69
+ *
70
+ * 1 bit per pixel, not 8: the image is two colours, the packing keeps the file
71
+ * a few kilobytes, and nothing between here and the scanner resamples it.
72
+ */
73
+ export function qrPng(matrix: QrMatrix): Uint8Array<ArrayBuffer> {
74
+ const span = matrix.size + QUIET_ZONE * 2;
75
+ const edge = span * MODULE_PX;
76
+ const rowBytes = Math.ceil(edge / 8);
77
+ // One filter byte per scanline, then the packed pixels.
78
+ const raw = new Uint8Array((rowBytes + 1) * edge);
79
+ for (let y = 0; y < edge; y += 1) {
80
+ const start = y * (rowBytes + 1);
81
+ raw[start] = 0; // filter: none
82
+ raw.fill(0xff, start + 1, start + 1 + rowBytes); // paper
83
+ }
84
+
85
+ for (let row = 0; row < matrix.size; row += 1) {
86
+ const line = matrix.rows[row] ?? '';
87
+ for (let column = 0; column < matrix.size; column += 1) {
88
+ if (line[column] !== '1') continue;
89
+ const top = (row + QUIET_ZONE) * MODULE_PX;
90
+ const left = (column + QUIET_ZONE) * MODULE_PX;
91
+ for (let y = top; y < top + MODULE_PX; y += 1) {
92
+ const offset = y * (rowBytes + 1) + 1;
93
+ for (let x = left; x < left + MODULE_PX; x += 1) {
94
+ raw[offset + (x >> 3)]! &= ~(0x80 >> (x & 7));
95
+ }
96
+ }
97
+ }
98
+ }
99
+
100
+ const header = new Uint8Array(13);
101
+ const view = new DataView(header.buffer);
102
+ view.setUint32(0, edge);
103
+ view.setUint32(4, edge);
104
+ header[8] = 1; // bit depth
105
+ header[9] = 0; // colour type: greyscale
106
+ header[10] = 0; // compression: deflate
107
+ header[11] = 0; // filter method: adaptive
108
+ header[12] = 0; // interlace: none
109
+
110
+ const parts = [SIGNATURE, chunk('IHDR', header), chunk('IDAT', deflateSync(raw)), chunk('IEND', new Uint8Array(0))];
111
+ const total = parts.reduce((sum, part) => sum + part.length, 0);
112
+ const out = new Uint8Array(total);
113
+ let offset = 0;
114
+ for (const part of parts) {
115
+ out.set(part, offset);
116
+ offset += part.length;
117
+ }
118
+ return out;
119
+ }
@@ -31,6 +31,7 @@ import {
31
31
  findCloudflared,
32
32
  runningTunnelUrl,
33
33
  } from '@/server/lib/connect/cloudflared.server';
34
+ import { resolveCloudflaredConfigPath } from '@/server/lib/connect/cloudflared-config.server';
34
35
  import type {
35
36
  ConnectAddress,
36
37
  ConnectStatus,
@@ -112,8 +113,8 @@ async function tailscaleState(): Promise<{ tunnel: TunnelState; address: Connect
112
113
  };
113
114
  }
114
115
 
115
- function cloudflareState(port: number): { tunnel: TunnelState; address: ConnectAddress | null } {
116
- const presence = findCloudflared();
116
+ function cloudflareState(port: number, configPath: string): { tunnel: TunnelState; address: ConnectAddress | null } {
117
+ const presence = findCloudflared(configPath);
117
118
  if (presence.reason || !presence.binary || !presence.configPath) {
118
119
  const reason = presence.reason ?? 'cloudflared is not configured.';
119
120
  return {
@@ -148,8 +149,12 @@ function cloudflareState(port: number): { tunnel: TunnelState; address: ConnectA
148
149
  /** The whole page's payload. */
149
150
  export async function connectStatus(): Promise<ConnectStatus> {
150
151
  const port = currentPort();
151
- const [tailscale, devices] = await Promise.all([tailscaleState(), listPairedDevices()]);
152
- const cloudflare = cloudflareState(port);
152
+ const [tailscale, devices, configPath] = await Promise.all([
153
+ tailscaleState(),
154
+ listPairedDevices(),
155
+ resolveCloudflaredConfigPath(),
156
+ ]);
157
+ const cloudflare = cloudflareState(port, configPath);
153
158
 
154
159
  const lanReachable = boundBeyondLoopback();
155
160
  const lan: ConnectAddress[] = lanOrigins(port).map((url) => ({
@@ -172,6 +177,7 @@ export async function connectStatus(): Promise<ConnectStatus> {
172
177
  version: pkg.version,
173
178
  addresses,
174
179
  tunnels: [tailscale.tunnel, cloudflare.tunnel],
180
+ cloudflareConfigPath: configPath,
175
181
  devices,
176
182
  };
177
183
  }
@@ -3,6 +3,7 @@ import * as connectStatus from '@/server/routes/connect/status';
3
3
  import * as connectTunnels from '@/server/routes/connect/tunnels';
4
4
  import * as connectDevices from '@/server/routes/connect/devices';
5
5
  import * as connectPair from '@/server/routes/connect/pair';
6
+ import * as connectPairQr from '@/server/routes/connect/pair-qr';
6
7
  import * as connectPairPage from '@/server/routes/connect/pair-page';
7
8
 
8
9
  export const connectBindings: HandlerBinding[] = [
@@ -10,6 +11,7 @@ export const connectBindings: HandlerBinding[] = [
10
11
  ...bindingsFor(connectTunnels, '/api/connect/tunnels'),
11
12
  ...bindingsFor(connectDevices, '/api/connect/devices'),
12
13
  ...bindingsFor(connectPair, '/api/connect/pair'),
14
+ ...bindingsFor(connectPairQr, '/api/connect/pair/qr.png'),
13
15
  ...bindingsFor(connectPair, '/api/connect/pair/claim'),
14
16
  ...bindingsFor(connectPairPage, '/pair'),
15
17
  ];
@@ -0,0 +1,72 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * `GET /api/connect/pair/qr.png` — the download a host's own machinery fetches.
8
+ *
9
+ * The route exists because a download cannot run the page's renderer: Android's
10
+ * `DownloadManager`, iOS's `WKDownload` and the desktop shells all fetch an
11
+ * `http` URL with the session cookie and hand the bytes to the user. A `blob:`
12
+ * URL the page built is exactly what those paths ignore, which is what made the
13
+ * button do nothing in the shell.
14
+ *
15
+ * The cases pin the two halves of that contract: a live code answers a real PNG
16
+ * with an attachment name, and a code that expired or was redeemed answers a
17
+ * sentence instead of an empty image.
18
+ */
19
+
20
+ import { afterEach, describe, expect, test } from 'bun:test';
21
+ import { loader } from '@/server/routes/connect/pair-qr';
22
+ import { attachPairingQr, createPairing, resetPairings } from '@/server/lib/connect/pairing.server';
23
+ import { qrPng } from '@/server/lib/connect/qr-png.server';
24
+ import { qrMatrix } from '@/server/lib/connect/qr.server';
25
+
26
+ const CANDIDATES = [{ kind: 'lan' as const, url: 'http://192.168.18.76:3000' }];
27
+ const PNG = qrPng(qrMatrix('https://kabmo.example/pair#abc'));
28
+
29
+ async function download(pairingId: string) {
30
+ const url = new URL('http://localhost/api/connect/pair/qr.png');
31
+ url.searchParams.set('pairingId', pairingId);
32
+ return loader({ request: new Request(url) } as never);
33
+ }
34
+
35
+ afterEach(() => {
36
+ resetPairings();
37
+ });
38
+
39
+ describe('pairing QR download', () => {
40
+ test('serves the PNG as an attachment named for the file the user gets', async () => {
41
+ const { pairingId } = createPairing(CANDIDATES);
42
+ attachPairingQr(pairingId, PNG);
43
+
44
+ const response = await download(pairingId);
45
+ expect(response.status).toBe(200);
46
+ expect(response.headers.get('content-type')).toBe('image/png');
47
+ expect(response.headers.get('content-disposition')).toBe('attachment; filename="kabmo-pairing-qr.png"');
48
+ expect(response.headers.get('cache-control')).toBe('no-store');
49
+ expect(new Uint8Array(await response.arrayBuffer())).toEqual(PNG);
50
+ });
51
+
52
+ test('answers an explanation once the code is gone, never an empty file', async () => {
53
+ const { pairingId } = createPairing(CANDIDATES);
54
+ attachPairingQr(pairingId, PNG);
55
+ resetPairings();
56
+
57
+ const response = await download(pairingId);
58
+ expect(response.status).toBe(410);
59
+ expect(await response.text()).toContain('expired');
60
+ });
61
+
62
+ test('a code that was never drawn has nothing to download', async () => {
63
+ const { pairingId } = createPairing(CANDIDATES);
64
+ const response = await download(pairingId);
65
+ expect(response.status).toBe(410);
66
+ });
67
+
68
+ test('a missing pairing id is refused rather than reading the store', async () => {
69
+ const response = await download('');
70
+ expect(response.status).toBe(410);
71
+ });
72
+ });
@@ -0,0 +1,44 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * `GET /api/connect/pair/qr.png?pairingId=…` — the current pairing code as a
8
+ * downloadable PNG.
9
+ *
10
+ * A real HTTP response rather than a Blob the page builds, because a DOWNLOAD is
11
+ * not something every host can do from JavaScript: Android's shell hands an
12
+ * `http` URL to `DownloadManager` (and silently ignores a `blob:` one), iOS's
13
+ * shell turns a non-renderable response into a `WKDownload`, and the desktop
14
+ * shells hand the file to their webview's own download path. A PNG served from
15
+ * this origin is the one shape all of them agree on, and it also means the file
16
+ * the user opens is a real image rather than an SVG their viewer cannot show.
17
+ *
18
+ * Gated like every other API route. The requesting host carries the console's
19
+ * session cookie — `DownloadManager` and `WKDownload` both do — so the image is
20
+ * not readable without the session that minted it.
21
+ */
22
+
23
+ import type { LoaderFunctionArgs } from '@/server/lib/remix-compat';
24
+ import { pairingQr } from '@/server/lib/connect/pairing.server';
25
+
26
+ export async function loader({ request }: LoaderFunctionArgs) {
27
+ const pairingId = new URL(request.url).searchParams.get('pairingId') ?? '';
28
+ const png = pairingId === '' ? null : pairingQr(pairingId);
29
+ if (!png) {
30
+ return new Response('This pairing code has expired or was already used.', {
31
+ status: 410,
32
+ headers: { 'content-type': 'text/plain; charset=utf-8', 'cache-control': 'no-store' },
33
+ });
34
+ }
35
+ return new Response(png, {
36
+ status: 200,
37
+ headers: {
38
+ 'content-type': 'image/png',
39
+ 'content-disposition': 'attachment; filename="kabmo-pairing-qr.png"',
40
+ 'content-length': String(png.byteLength),
41
+ 'cache-control': 'no-store',
42
+ },
43
+ });
44
+ }
@@ -21,10 +21,11 @@
21
21
  import { json, NO_STORE_HEADERS, type ActionFunctionArgs } from '@/server/lib/remix-compat';
22
22
  import { connectIdentity } from '@/server/lib/connect/identity.server';
23
23
  import { connectStatus } from '@/server/lib/connect/status.server';
24
- import { createPairing, consumePairing } from '@/server/lib/connect/pairing.server';
24
+ import { createPairing, attachPairingQr, consumePairing } from '@/server/lib/connect/pairing.server';
25
25
  import { mintDeviceToken, touchDevice, DEVICE_COOKIE } from '@/server/lib/connect/devices.server';
26
26
  import { isSecureRequest } from '@/server/lib/auth/token';
27
27
  import { qrMatrix } from '@/server/lib/connect/qr.server';
28
+ import { qrPng } from '@/server/lib/connect/qr-png.server';
28
29
  import { encodePairingFragment, encodePairingPayload, PAIRING_VERSION } from '@/shared/lib/connect/payload';
29
30
  import { ROUTE_TIER } from '@/shared/lib/connect/tier';
30
31
  import type { ConnectCandidate, ConnectRouteKind } from '@/shared/lib/connect/types';
@@ -143,6 +144,10 @@ export async function action({ request }: ActionFunctionArgs) {
143
144
  // LAN, because the LAN origin is not a secure context.
144
145
  const best = [...candidates].sort((left, right) => ROUTE_TIER[left.kind] - ROUTE_TIER[right.kind])[0];
145
146
  const webLink = `${best.url}/pair#${encodePairingFragment(payload)}`;
147
+ const qr = qrMatrix(webLink);
148
+ // Drawn once, here: the download is an HTTP GET from a host's own download
149
+ // machinery, which cannot run this page's renderer to draw it later.
150
+ attachPairingQr(pairing.pairingId, qrPng(qr));
146
151
 
147
152
  return json(
148
153
  {
@@ -150,8 +155,9 @@ export async function action({ request }: ActionFunctionArgs) {
150
155
  expiresAt: pairing.expiresAt,
151
156
  link,
152
157
  webLink,
158
+ qrUrl: `/api/connect/pair/qr.png?pairingId=${encodeURIComponent(pairing.pairingId)}`,
153
159
  candidates,
154
- qr: qrMatrix(webLink),
160
+ qr,
155
161
  },
156
162
  { headers: NO_STORE_HEADERS },
157
163
  );
@@ -0,0 +1,141 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The tunnels route's config action.
8
+ *
9
+ * The page sends a path, not a flag, because the server owns the "is this a
10
+ * runnable config?" question. The cases pin that contract: a missing file and a
11
+ * hostname-less file are refused with the reason, a good path is persisted and
12
+ * reported back in the same payload, and a running tunnel is stopped when the
13
+ * file underneath it changes — leaving it up would label the page with a path
14
+ * the process is not using.
15
+ */
16
+
17
+ import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
18
+ import fs from 'fs';
19
+ import os from 'os';
20
+ import path from 'path';
21
+ import { action } from '@/server/routes/connect/tunnels';
22
+ import {
23
+ cloudflaredAlive,
24
+ runningTunnelUrl,
25
+ startCloudflared,
26
+ } from '@/server/lib/connect/cloudflared.server';
27
+ import type { ConnectStatus } from '@/shared/lib/connect/types';
28
+ import { isolateDb, releaseDb } from '@/test-support/isolated-db';
29
+
30
+ const dirs: string[] = [];
31
+
32
+ function tempDir(): string {
33
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'kabmo-cf-route-'));
34
+ dirs.push(dir);
35
+ return dir;
36
+ }
37
+
38
+ function writeConfig(): string {
39
+ const file = path.join(tempDir(), 'config.yml');
40
+ fs.writeFileSync(
41
+ file,
42
+ ['tunnel: t', 'ingress:', ' - hostname: kabmo.example.com', ' service: http://localhost:3000', ' - service: http_status:404', ''].join('\n'),
43
+ );
44
+ return file;
45
+ }
46
+
47
+ async function post(body: unknown) {
48
+ const request = new Request('http://localhost/api/connect/tunnels', {
49
+ method: 'POST',
50
+ headers: { 'content-type': 'application/json' },
51
+ body: JSON.stringify(body),
52
+ });
53
+ const response = await action({ request } as never);
54
+ return {
55
+ status: response.status,
56
+ body: (await response.json()) as { ok?: boolean; error?: string; status?: ConnectStatus },
57
+ };
58
+ }
59
+
60
+ let previousConfig: string | undefined;
61
+ let previousDataDir: string | undefined;
62
+
63
+ beforeEach(async () => {
64
+ previousConfig = Bun.env.CLOUDFLARED_CONFIG;
65
+ previousDataDir = Bun.env.KABMO_DATA_DIR;
66
+ Bun.env.KABMO_DATA_DIR = tempDir();
67
+ await isolateDb();
68
+ });
69
+
70
+ afterEach(async () => {
71
+ if (previousConfig === undefined) delete Bun.env.CLOUDFLARED_CONFIG;
72
+ else Bun.env.CLOUDFLARED_CONFIG = previousConfig;
73
+ if (previousDataDir === undefined) delete Bun.env.KABMO_DATA_DIR;
74
+ else Bun.env.KABMO_DATA_DIR = previousDataDir;
75
+ await releaseDb();
76
+ for (const dir of dirs.splice(0)) fs.rmSync(dir, { recursive: true, force: true });
77
+ });
78
+
79
+ describe('POST /api/connect/tunnels config action', () => {
80
+ test('persists a runnable config path and reports it in the payload', async () => {
81
+ const file = writeConfig();
82
+ const { status, body } = await post({ provider: 'cloudflare', action: 'config', path: file });
83
+
84
+ expect(status).toBe(200);
85
+ expect(body.ok).toBe(true);
86
+ expect(body.status?.cloudflareConfigPath).toBe(path.resolve(file));
87
+ });
88
+
89
+ test('refuses a config that does not exist', async () => {
90
+ const missing = path.join(tempDir(), 'nope.yml');
91
+ const { status, body } = await post({ provider: 'cloudflare', action: 'config', path: missing });
92
+
93
+ expect(status).toBe(400);
94
+ expect(body.error).toContain(missing);
95
+ expect(body.status).toBeDefined();
96
+ });
97
+
98
+ test('refuses a config with no ingress hostname', async () => {
99
+ const file = path.join(tempDir(), 'config.yml');
100
+ fs.writeFileSync(file, 'tunnel: t\ningress:\n - service: http_status:404\n');
101
+ const { status, body } = await post({ provider: 'cloudflare', action: 'config', path: file });
102
+
103
+ expect(status).toBe(400);
104
+ expect(body.error).toContain('no ingress hostname');
105
+ });
106
+
107
+ test('refuses a config path for tailscale', async () => {
108
+ const { status, body } = await post({ provider: 'tailscale', action: 'config', path: writeConfig() });
109
+
110
+ expect(status).toBe(400);
111
+ expect(body.error).toBe('Only the Cloudflare tunnel takes a config path.');
112
+ });
113
+
114
+ test('refuses an unknown action', async () => {
115
+ const { status, body } = await post({ provider: 'cloudflare', action: 'restart' });
116
+
117
+ expect(status).toBe(400);
118
+ expect(body.error).toContain('Expected');
119
+ });
120
+
121
+ test.skipIf(process.platform === 'win32')('stops a running tunnel when the config path changes', async () => {
122
+ const first = writeConfig();
123
+ Bun.env.CLOUDFLARED_CONFIG = first;
124
+
125
+ const dir = tempDir();
126
+ const binary = path.join(dir, 'cloudflared');
127
+ fs.writeFileSync(binary, '#!/bin/sh\nexec sleep 30\n');
128
+ fs.chmodSync(binary, 0o755);
129
+
130
+ const port = Number(Bun.env.PORT) || 3000;
131
+ const started = await startCloudflared(binary, first, 'kabmo.example.com', port);
132
+ expect(started.ok).toBe(true);
133
+ expect(cloudflaredAlive(port)).toBe(true);
134
+
135
+ const { status } = await post({ provider: 'cloudflare', action: 'config', path: writeConfig() });
136
+
137
+ expect(status).toBe(200);
138
+ expect(cloudflaredAlive(port)).toBe(false);
139
+ expect(runningTunnelUrl(port)).toBeNull();
140
+ });
141
+ });
@@ -4,11 +4,12 @@
4
4
  */
5
5
 
6
6
  /**
7
- * `POST /api/connect/tunnels` — start or stop one provider.
7
+ * `POST /api/connect/tunnels` — start or stop one provider, or point the
8
+ * Cloudflare row at a different config file.
8
9
  *
9
10
  * The response is the whole status payload rather than a boolean: the page has
10
- * to redraw the address list and the tunnel card together, and a second read
11
- * would let the two disagree for a frame.
11
+ * to redraw the address list, the tunnel card and the config path together, and
12
+ * a second read would let the two disagree for a frame.
12
13
  *
13
14
  * A refusal carries the provider's own sentence. "Tailscale refused: HTTPS is
14
15
  * not enabled for this tailnet" is actionable; `{ ok: false }` is not.
@@ -18,15 +19,21 @@ import { json, NO_STORE_HEADERS, type ActionFunctionArgs } from '@/server/lib/re
18
19
  import { connectStatus, currentPort } from '@/server/lib/connect/status.server';
19
20
  import { findTailscale, startServe, stopServe } from '@/server/lib/connect/tailscale.server';
20
21
  import {
22
+ cloudflaredAlive,
21
23
  findCloudflared,
22
- readCloudflaredConfig,
23
24
  startCloudflared,
24
25
  stopCloudflared,
25
26
  } from '@/server/lib/connect/cloudflared.server';
27
+ import {
28
+ readCloudflaredConfig,
29
+ resolveCloudflaredConfigPath,
30
+ saveCloudflaredConfigPath,
31
+ } from '@/server/lib/connect/cloudflared-config.server';
26
32
 
27
33
  interface TunnelRequest {
28
34
  provider?: unknown;
29
35
  action?: unknown;
36
+ path?: unknown;
30
37
  }
31
38
 
32
39
  export async function action({ request }: ActionFunctionArgs) {
@@ -37,9 +44,16 @@ export async function action({ request }: ActionFunctionArgs) {
37
44
  const body = (await request.json().catch(() => null)) as TunnelRequest | null;
38
45
  const provider = body?.provider;
39
46
  const verb = body?.action;
40
- if ((provider !== 'tailscale' && provider !== 'cloudflare') || (verb !== 'start' && verb !== 'stop')) {
47
+ const knownVerb = verb === 'start' || verb === 'stop' || verb === 'config';
48
+ if ((provider !== 'tailscale' && provider !== 'cloudflare') || !knownVerb) {
49
+ return json(
50
+ { error: 'Expected { provider: "tailscale" | "cloudflare", action: "start" | "stop" | "config" }' },
51
+ { status: 400, headers: NO_STORE_HEADERS },
52
+ );
53
+ }
54
+ if (verb === 'config' && provider !== 'cloudflare') {
41
55
  return json(
42
- { error: 'Expected { provider: "tailscale" | "cloudflare", action: "start" | "stop" }' },
56
+ { error: 'Only the Cloudflare tunnel takes a config path.' },
43
57
  { status: 400, headers: NO_STORE_HEADERS },
44
58
  );
45
59
  }
@@ -57,8 +71,19 @@ export async function action({ request }: ActionFunctionArgs) {
57
71
  }
58
72
  } else if (verb === 'stop') {
59
73
  stopCloudflared(port);
74
+ } else if (verb === 'config') {
75
+ const before = await resolveCloudflaredConfigPath();
76
+ const saved = await saveCloudflaredConfigPath(body?.path);
77
+ if (!saved.ok) {
78
+ failure = saved.reason;
79
+ } else if (saved.path !== before && cloudflaredAlive(port)) {
80
+ // The running process holds the old file; leaving it up would make the
81
+ // page name a path the tunnel is not using.
82
+ stopCloudflared(port);
83
+ }
60
84
  } else {
61
- const presence = findCloudflared();
85
+ const configPath = await resolveCloudflaredConfigPath();
86
+ const presence = findCloudflared(configPath);
62
87
  const config = presence.configPath ? readCloudflaredConfig(presence.configPath) : null;
63
88
  if (presence.reason || !presence.binary || !presence.configPath || !config?.hostname) {
64
89
  failure = presence.reason ?? 'cloudflared is not configured.';
@@ -41,8 +41,17 @@ import {
41
41
  listNotificationEventsAfter,
42
42
  } from '@/server/lib/notifications/store.server';
43
43
 
44
- /** Long enough that a phone's radio sleeps between beats, short enough to notice a dead link. */
45
- const HEARTBEAT_MS = 25_000;
44
+ /**
45
+ * The comment frame that proves the stream is alive.
46
+ *
47
+ * 60 s, not 25: this stream has exactly one consumer — the Android watcher — and
48
+ * every beat is a radio wakeup on a phone that is otherwise asleep. 25 s woke it
49
+ * more than twice as often for the same liveness proof; 60 s lets it idle for
50
+ * most of the interval, and the shell's read timeout (150 s, two and a half
51
+ * beats) still notices a link that died. The page does not use this route: an
52
+ * open page has the realtime socket, whose own heartbeat is separate.
53
+ */
54
+ const HEARTBEAT_MS = 60_000;
46
55
 
47
56
  async function platformEnabled(platform: NotificationPlatform): Promise<boolean> {
48
57
  try {
@@ -81,6 +81,13 @@ export interface ConnectStatus {
81
81
  version: string;
82
82
  addresses: ConnectAddress[];
83
83
  tunnels: TunnelState[];
84
+ /**
85
+ * The cloudflared config the Cloudflare row reads and the start path runs.
86
+ *
87
+ * The page shows it because "which file am I using?" is the question a user
88
+ * with two configs cannot answer from the tunnel's state alone.
89
+ */
90
+ cloudflareConfigPath: string;
84
91
  devices: PairedDevice[];
85
92
  }
86
93