@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,245 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The cloudflared config: the scan, the derived run copy, and the saved path.
8
+ *
9
+ * Three load-bearing claims. A config with an ingress block but no hostname is
10
+ * "not configured", because reporting it would put a URL on the page that does
11
+ * not resolve. The derived copy rewrites the FIRST hostname rule and only that
12
+ * one — the catch-all 404 rule must stay, or cloudflared refuses to start. And a
13
+ * saved path is written only after it names a runnable config, so the page never
14
+ * shows a path the tunnel cannot use.
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 {
22
+ cloudflaredConfigPath,
23
+ deriveCloudflaredRunConfig,
24
+ readCloudflaredConfig,
25
+ resolveCloudflaredConfigPath,
26
+ saveCloudflaredConfigPath,
27
+ } from '@/server/lib/connect/cloudflared-config.server';
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-'));
34
+ dirs.push(dir);
35
+ return dir;
36
+ }
37
+
38
+ function writeConfig(text: string): string {
39
+ const file = path.join(tempDir(), 'config.yml');
40
+ fs.writeFileSync(file, text);
41
+ return file;
42
+ }
43
+
44
+ const VALID = [
45
+ 'tunnel: 6ff42ae2-765d-4adf-8112-31c55c1551ef',
46
+ 'credentials-file: /home/me/.cloudflared/6ff42ae2.json',
47
+ '',
48
+ 'ingress:',
49
+ ' - hostname: kabmo.example.com',
50
+ ' service: http://localhost:3000',
51
+ ' - service: http_status:404',
52
+ '',
53
+ ].join('\n');
54
+
55
+ afterEach(() => {
56
+ for (const dir of dirs.splice(0)) fs.rmSync(dir, { recursive: true, force: true });
57
+ });
58
+
59
+ describe('readCloudflaredConfig', () => {
60
+ test('reads the tunnel name and the first ingress hostname', () => {
61
+ expect(readCloudflaredConfig(writeConfig(VALID))).toEqual({
62
+ tunnel: '6ff42ae2-765d-4adf-8112-31c55c1551ef',
63
+ hostname: 'kabmo.example.com',
64
+ });
65
+ });
66
+
67
+ test('strips quotes around a value', () => {
68
+ const file = writeConfig(['tunnel: "my-tunnel"', 'ingress:', ' - hostname: "a.example.com"'].join('\n'));
69
+ expect(readCloudflaredConfig(file)).toEqual({ tunnel: 'my-tunnel', hostname: 'a.example.com' });
70
+ });
71
+
72
+ test('answers null for a file with neither field', () => {
73
+ expect(readCloudflaredConfig(writeConfig('metrics: 127.0.0.1:20241\n'))).toBeNull();
74
+ });
75
+
76
+ test('answers null for a missing file', () => {
77
+ expect(readCloudflaredConfig(path.join(os.tmpdir(), 'kabmo-does-not-exist.yml'))).toBeNull();
78
+ });
79
+
80
+ test('does not read a hostname from outside the ingress block', () => {
81
+ const file = writeConfig(['tunnel: t', 'hostname: not-ingress.example.com', 'ingress:', ' - service: http_status:404'].join('\n'));
82
+ expect(readCloudflaredConfig(file)).toEqual({ tunnel: 't', hostname: null });
83
+ });
84
+ });
85
+
86
+ describe('deriveCloudflaredRunConfig', () => {
87
+ test('rewrites the first hostname rule to this port and keeps the fallback rule', () => {
88
+ const derived = deriveCloudflaredRunConfig(VALID, 5173);
89
+
90
+ expect(derived).not.toBeNull();
91
+ expect(derived).toContain(' service: http://127.0.0.1:5173');
92
+ expect(derived).not.toContain('http://localhost:3000');
93
+ expect(derived).toContain(' - service: http_status:404');
94
+ expect(derived).toContain('credentials-file: /home/me/.cloudflared/6ff42ae2.json');
95
+ expect(derived).toContain('tunnel: 6ff42ae2-765d-4adf-8112-31c55c1551ef');
96
+ });
97
+
98
+ test('adds a service to a hostname rule that has none', () => {
99
+ const derived = deriveCloudflaredRunConfig(
100
+ ['ingress:', ' - hostname: kabmo.example.com', ' - service: http_status:404'].join('\n'),
101
+ 4100,
102
+ );
103
+
104
+ expect(derived?.split('\n')).toEqual([
105
+ 'ingress:',
106
+ ' - hostname: kabmo.example.com',
107
+ ' service: http://127.0.0.1:4100',
108
+ ' - service: http_status:404',
109
+ ]);
110
+ });
111
+
112
+ test('skips a leading rule without a hostname', () => {
113
+ const derived = deriveCloudflaredRunConfig(
114
+ [
115
+ 'ingress:',
116
+ ' - service: http_status:404',
117
+ ' - hostname: a.example.com',
118
+ ' service: http://localhost:1',
119
+ ].join('\n'),
120
+ 4200,
121
+ );
122
+
123
+ expect(derived?.split('\n')[1]).toBe(' - service: http_status:404');
124
+ expect(derived).toContain(' service: http://127.0.0.1:4200');
125
+ expect(derived).not.toContain('http://localhost:1');
126
+ });
127
+
128
+ test('leaves an originRequest block under the rule intact', () => {
129
+ const derived = deriveCloudflaredRunConfig(
130
+ [
131
+ 'ingress:',
132
+ ' - hostname: a.example.com',
133
+ ' service: http://localhost:1',
134
+ ' originRequest:',
135
+ ' noTLSVerify: true',
136
+ ' - service: http_status:404',
137
+ ].join('\n'),
138
+ 4300,
139
+ );
140
+
141
+ expect(derived).toContain(' noTLSVerify: true');
142
+ });
143
+
144
+ test('does not mistake a nested list for the next ingress rule', () => {
145
+ const derived = deriveCloudflaredRunConfig(
146
+ [
147
+ 'ingress:',
148
+ ' - hostname: a.example.com',
149
+ ' originRequest:',
150
+ ' ipRules:',
151
+ ' - prefix: 10.0.0.0/8',
152
+ ' ports: [80]',
153
+ ' service: http://localhost:1',
154
+ ' - service: http_status:404',
155
+ ].join('\n'),
156
+ 4350,
157
+ );
158
+
159
+ expect(derived).toContain(' service: http://127.0.0.1:4350');
160
+ expect(derived).not.toContain('http://localhost:1');
161
+ expect(derived).toContain(' - prefix: 10.0.0.0/8');
162
+ });
163
+
164
+ test('answers null without an ingress block', () => {
165
+ expect(deriveCloudflaredRunConfig('tunnel: t\n', 4400)).toBeNull();
166
+ });
167
+
168
+ test('answers null when the ingress block has no hostname', () => {
169
+ expect(deriveCloudflaredRunConfig('ingress:\n - service: http_status:404\n', 4500)).toBeNull();
170
+ });
171
+ });
172
+
173
+ describe('the saved config path', () => {
174
+ let previousEnv: string | undefined;
175
+
176
+ beforeEach(async () => {
177
+ previousEnv = Bun.env.CLOUDFLARED_CONFIG;
178
+ await isolateDb();
179
+ });
180
+
181
+ afterEach(async () => {
182
+ if (previousEnv === undefined) delete Bun.env.CLOUDFLARED_CONFIG;
183
+ else Bun.env.CLOUDFLARED_CONFIG = previousEnv;
184
+ await releaseDb();
185
+ });
186
+
187
+ test('falls back to CLOUDFLARED_CONFIG until a path is saved', async () => {
188
+ const file = writeConfig(VALID);
189
+ Bun.env.CLOUDFLARED_CONFIG = file;
190
+
191
+ expect(cloudflaredConfigPath()).toBe(file);
192
+ expect(await resolveCloudflaredConfigPath()).toBe(file);
193
+ });
194
+
195
+ test('a saved path wins over the environment', async () => {
196
+ const file = writeConfig(VALID);
197
+ Bun.env.CLOUDFLARED_CONFIG = path.join(os.tmpdir(), 'not-this-one.yml');
198
+
199
+ const saved = await saveCloudflaredConfigPath(file);
200
+
201
+ expect(saved).toEqual({ ok: true, path: path.resolve(file), reason: null });
202
+ expect(await resolveCloudflaredConfigPath()).toBe(path.resolve(file));
203
+ });
204
+
205
+ test('an empty string clears the saved path', async () => {
206
+ const file = writeConfig(VALID);
207
+ Bun.env.CLOUDFLARED_CONFIG = file;
208
+ await saveCloudflaredConfigPath(writeConfig(VALID));
209
+
210
+ expect(await saveCloudflaredConfigPath(' ')).toEqual({ ok: true, path: file, reason: null });
211
+ expect(await resolveCloudflaredConfigPath()).toBe(file);
212
+ });
213
+
214
+ test('refuses a relative path', async () => {
215
+ expect(await saveCloudflaredConfigPath('config.yml')).toEqual({
216
+ ok: false,
217
+ path: null,
218
+ reason: 'The config path must be absolute.',
219
+ });
220
+ });
221
+
222
+ test('refuses a file that does not exist', async () => {
223
+ const missing = path.join(os.tmpdir(), 'kabmo-no-config-here.yml');
224
+ const outcome = await saveCloudflaredConfigPath(missing);
225
+
226
+ expect(outcome.ok).toBe(false);
227
+ expect(outcome.reason).toContain(missing);
228
+ });
229
+
230
+ test('refuses a config without an ingress hostname', async () => {
231
+ const file = writeConfig('tunnel: t\ningress:\n - service: http_status:404\n');
232
+ const outcome = await saveCloudflaredConfigPath(file);
233
+
234
+ expect(outcome.ok).toBe(false);
235
+ expect(outcome.reason).toContain('no ingress hostname');
236
+ });
237
+
238
+ test('refuses a non-string path', async () => {
239
+ expect(await saveCloudflaredConfigPath(42)).toEqual({
240
+ ok: false,
241
+ path: null,
242
+ reason: 'Expected a config path.',
243
+ });
244
+ });
245
+ });
@@ -9,9 +9,9 @@
9
9
  * A real named tunnel needs an account, a domain and a credentials file, so the
10
10
  * start path is unreachable on a machine that has none — which is exactly the
11
11
  * path that would otherwise ship untested. The stand-in is a script that stays
12
- * alive, which is all `startCloudflared` requires: it records the process, derives
13
- * the public URL from the config's hostname, and reports liveness from the
14
- * process's own exit code.
12
+ * alive and records its argv and the config it was handed: the start path must
13
+ * spawn `tunnel --config <runtime copy> run`, the copy must name THIS port, and
14
+ * the copy must be gone once the tunnel stops.
15
15
  */
16
16
 
17
17
  import { afterEach, describe, expect, test } from 'bun:test';
@@ -32,25 +32,84 @@ const posixOnly = process.platform !== 'win32';
32
32
 
33
33
  const dirs: string[] = [];
34
34
 
35
- function fakeCloudflared(): string {
36
- const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'kabmo-cf-bin-'));
35
+ function tempDir(): string {
36
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'kabmo-cf-'));
37
37
  dirs.push(dir);
38
- const file = path.join(dir, 'cloudflared');
39
- // Stays alive until killed, like the real `tunnel run`.
40
- fs.writeFileSync(file, '#!/bin/sh\nexec sleep 30\n');
41
- fs.chmodSync(file, 0o755);
38
+ return dir;
39
+ }
40
+
41
+ const CONFIG = [
42
+ 'tunnel: 6ff42ae2-765d-4adf-8112-31c55c1551ef',
43
+ 'credentials-file: /home/me/.cloudflared/6ff42ae2.json',
44
+ '',
45
+ 'ingress:',
46
+ ' - hostname: kabmo.example.com',
47
+ ' service: http://localhost:3000',
48
+ ' - service: http_status:404',
49
+ '',
50
+ ].join('\n');
51
+
52
+ function writeConfig(text: string): string {
53
+ const file = path.join(tempDir(), 'config.yml');
54
+ fs.writeFileSync(file, text);
42
55
  return file;
43
56
  }
44
57
 
58
+ /** Stays alive until killed, like the real `tunnel run`, and records its argv. */
59
+ function fakeCloudflared(): { binary: string; argsFile: string; configFile: string } {
60
+ const dir = tempDir();
61
+ const binary = path.join(dir, 'cloudflared');
62
+ const argsFile = path.join(dir, 'args.txt');
63
+ const configFile = path.join(dir, 'handed-config.yml');
64
+ fs.writeFileSync(
65
+ binary,
66
+ [
67
+ '#!/bin/sh',
68
+ `args="${argsFile}"`,
69
+ `cfg="${configFile}"`,
70
+ ': > "$args.tmp"',
71
+ 'while [ $# -gt 0 ]; do',
72
+ ' printf \'%s\\n\' "$1" >> "$args.tmp"',
73
+ ' if [ "$1" = "--config" ]; then',
74
+ ' shift',
75
+ ' printf \'%s\\n\' "$1" >> "$args.tmp"',
76
+ ' cp "$1" "$cfg" 2>/dev/null',
77
+ ' fi',
78
+ ' shift',
79
+ 'done',
80
+ // Rename, so the reader never sees a half-written file.
81
+ 'mv "$args.tmp" "$args"',
82
+ 'exec sleep 30',
83
+ '',
84
+ ].join('\n'),
85
+ );
86
+ fs.chmodSync(binary, 0o755);
87
+ return { binary, argsFile, configFile };
88
+ }
89
+
90
+ async function waitForFile(file: string): Promise<void> {
91
+ if (fs.existsSync(file)) return;
92
+ const signal = AbortSignal.timeout(2_000);
93
+ try {
94
+ for await (const event of fs.promises.watch(path.dirname(file), { signal })) {
95
+ void event;
96
+ if (fs.existsSync(file)) return;
97
+ }
98
+ } catch (error) {
99
+ if (signal.aborted) throw new Error(`Timed out waiting for ${file}`);
100
+ throw error;
101
+ }
102
+ }
103
+
45
104
  afterEach(() => {
46
105
  for (const dir of dirs.splice(0)) fs.rmSync(dir, { recursive: true, force: true });
47
106
  });
48
107
 
49
108
  describe('cloudflared lifecycle', () => {
50
109
  test.skipIf(!posixOnly)('starting records the public URL and reports the process alive', async () => {
51
- const binary = fakeCloudflared();
110
+ const { binary } = fakeCloudflared();
52
111
  const port = 39_101;
53
- const outcome = await startCloudflared(binary, '/tmp/config.yml', 'kabmo.example.com', port);
112
+ const outcome = await startCloudflared(binary, writeConfig(CONFIG), 'kabmo.example.com', port);
54
113
 
55
114
  expect(outcome.ok).toBe(true);
56
115
  expect(outcome.url).toBe('https://kabmo.example.com');
@@ -62,11 +121,39 @@ describe('cloudflared lifecycle', () => {
62
121
  expect(runningTunnelUrl(port)).toBeNull();
63
122
  });
64
123
 
124
+ test.skipIf(!posixOnly)('runs a runtime copy pointed at this port, not the file on disk', async () => {
125
+ const { binary, argsFile, configFile } = fakeCloudflared();
126
+ const source = writeConfig(CONFIG);
127
+ const port = 39_105;
128
+
129
+ await startCloudflared(binary, source, 'kabmo.example.com', port);
130
+ await waitForFile(argsFile);
131
+
132
+ const args = fs.readFileSync(argsFile, 'utf8').trim().split('\n');
133
+ expect(args.slice(0, 2)).toEqual(['tunnel', '--config']);
134
+ const runtimePath = args[2];
135
+ expect(args.slice(3)).toEqual(['run']);
136
+ expect(args).not.toContain('--url');
137
+ expect(runtimePath).not.toBe(source);
138
+ expect(fs.existsSync(runtimePath)).toBe(true);
139
+
140
+ const handed = fs.readFileSync(configFile, 'utf8');
141
+ expect(handed).toContain(`service: http://127.0.0.1:${port}`);
142
+ expect(handed).not.toContain('http://localhost:3000');
143
+ expect(handed).toContain('credentials-file: /home/me/.cloudflared/6ff42ae2.json');
144
+ // The user's file is never modified.
145
+ expect(fs.readFileSync(source, 'utf8')).toBe(CONFIG);
146
+
147
+ stopCloudflared(port);
148
+ expect(fs.existsSync(path.dirname(runtimePath))).toBe(false);
149
+ });
150
+
65
151
  test.skipIf(!posixOnly)('starting twice for one port reuses the running tunnel', async () => {
66
- const binary = fakeCloudflared();
152
+ const { binary } = fakeCloudflared();
153
+ const config = writeConfig(CONFIG);
67
154
  const port = 39_102;
68
- await startCloudflared(binary, '/tmp/config.yml', 'a.example.com', port);
69
- const second = await startCloudflared(binary, '/tmp/config.yml', 'b.example.com', port);
155
+ await startCloudflared(binary, config, 'a.example.com', port);
156
+ const second = await startCloudflared(binary, config, 'b.example.com', port);
70
157
 
71
158
  // The second call must not spawn a second process, and must not claim a
72
159
  // different hostname than the one actually running.
@@ -74,13 +161,27 @@ describe('cloudflared lifecycle', () => {
74
161
  stopCloudflared(port);
75
162
  });
76
163
 
164
+ test('a config with no ingress hostname is refused instead of spawned', async () => {
165
+ const { binary } = fakeCloudflared();
166
+ const outcome = await startCloudflared(
167
+ binary,
168
+ writeConfig('tunnel: t\ningress:\n - service: http_status:404\n'),
169
+ 'x.example.com',
170
+ 39_106,
171
+ );
172
+
173
+ expect(outcome.ok).toBe(false);
174
+ expect(outcome.reason).toContain('no ingress rule');
175
+ expect(cloudflaredAlive(39_106)).toBe(false);
176
+ });
177
+
77
178
  test('stopping a tunnel that was never started is not an error', () => {
78
179
  expect(stopCloudflared(39_103)).toEqual({ ok: true, reason: null });
79
180
  expect(cloudflaredAlive(39_103)).toBe(false);
80
181
  });
81
182
 
82
183
  test('a binary that cannot be spawned reports the reason', async () => {
83
- const outcome = await startCloudflared('/nonexistent/cloudflared', '/tmp/config.yml', 'x.example.com', 39_104);
184
+ const outcome = await startCloudflared('/nonexistent/cloudflared', writeConfig(CONFIG), 'x.example.com', 39_104);
84
185
  expect(outcome.ok).toBe(false);
85
186
  expect(outcome.reason).toBeTruthy();
86
187
  expect(cloudflaredAlive(39_104)).toBe(false);
@@ -23,6 +23,10 @@
23
23
  import fs from 'fs';
24
24
  import os from 'os';
25
25
  import path from 'path';
26
+ import {
27
+ deriveCloudflaredRunConfig,
28
+ readCloudflaredConfig,
29
+ } from '@/server/lib/connect/cloudflared-config.server';
26
30
  import { which } from '@/server/lib/connect/run.server';
27
31
 
28
32
  export interface CloudflaredPresence {
@@ -32,68 +36,9 @@ export interface CloudflaredPresence {
32
36
  reason: string | null;
33
37
  }
34
38
 
35
- export interface CloudflaredConfig {
36
- /** The tunnel name or UUID from `tunnel:`. */
37
- tunnel: string | null;
38
- /** The first public hostname in the ingress list. */
39
- hostname: string | null;
40
- }
41
-
42
- /** Where cloudflared looks for its config, honouring the documented override. */
43
- export function cloudflaredConfigPath(): string {
44
- const override = (Bun.env.CLOUDFLARED_CONFIG ?? '').trim();
45
- if (override) return override;
46
- return path.join(os.homedir(), '.cloudflared', 'config.yml');
47
- }
48
-
49
- /**
50
- * Read the two facts this page needs out of the YAML.
51
- *
52
- * A line scan rather than a YAML parser: the file is written by
53
- * `cloudflared tunnel create` and by hand, and the only fields read here are a
54
- * top-level `tunnel:` and the first `hostname:` under `ingress:`. Pulling in a
55
- * parser for two scalars would be a dependency the rest of the server does not
56
- * have, and a malformed file must degrade to "not configured" rather than throw.
57
- */
58
- export function readCloudflaredConfig(file: string): CloudflaredConfig | null {
59
- let text: string;
60
- try {
61
- text = fs.readFileSync(file, 'utf8');
62
- } catch {
63
- return null;
64
- }
65
-
66
- let tunnel: string | null = null;
67
- let hostname: string | null = null;
68
- let inIngress = false;
69
- for (const rawLine of text.split('\n')) {
70
- const line = rawLine.replace(/\s+#.*$/, '');
71
- if (/^tunnel:\s*/.test(line)) {
72
- tunnel = line.replace(/^tunnel:\s*/, '').trim().replace(/^["']|["']$/g, '') || null;
73
- continue;
74
- }
75
- if (/^ingress:\s*$/.test(line)) {
76
- inIngress = true;
77
- continue;
78
- }
79
- if (inIngress && /^\S/.test(line)) {
80
- // A new top-level key ends the ingress block.
81
- inIngress = false;
82
- }
83
- if (inIngress && hostname === null) {
84
- const match = /^\s*-\s*hostname:\s*(\S+)/.exec(line) ?? /^\s*hostname:\s*(\S+)/.exec(line);
85
- if (match?.[1]) hostname = match[1].replace(/^["']|["']$/g, '');
86
- }
87
- }
88
-
89
- if (!tunnel && !hostname) return null;
90
- return { tunnel, hostname };
91
- }
92
-
93
- /** Locate the binary and a usable config. */
94
- export function findCloudflared(): CloudflaredPresence {
39
+ /** Locate the binary and read the config at `configPath`. */
40
+ export function findCloudflared(configPath: string): CloudflaredPresence {
95
41
  const binary = which('cloudflared');
96
- const configPath = cloudflaredConfigPath();
97
42
  if (!binary) {
98
43
  return {
99
44
  binary: null,
@@ -122,6 +67,8 @@ export function findCloudflared(): CloudflaredPresence {
122
67
  interface RunningTunnel {
123
68
  proc: Bun.Subprocess<'ignore', 'ignore', 'pipe'>;
124
69
  url: string;
70
+ /** The temporary directory holding the derived config. */
71
+ runtimeDir: string;
125
72
  }
126
73
 
127
74
  declare global {
@@ -134,6 +81,14 @@ function running(): Map<number, RunningTunnel> {
134
81
  return globalThis.__kabmoCloudflared;
135
82
  }
136
83
 
84
+ function removeRuntimeDir(dir: string): void {
85
+ try {
86
+ fs.rmSync(dir, { recursive: true, force: true });
87
+ } catch {
88
+ // A directory the process cannot remove is not worth failing a stop over.
89
+ }
90
+ }
91
+
137
92
  /** The public origin of a running tunnel for `port`, or null. */
138
93
  export function runningTunnelUrl(port: number): string | null {
139
94
  return running().get(port)?.url ?? null;
@@ -142,9 +97,9 @@ export function runningTunnelUrl(port: number): string | null {
142
97
  /**
143
98
  * Start the named tunnel for `port`.
144
99
  *
145
- * `--url` overrides the config's ingress service so the tunnel points at THIS
146
- * instance's port rather than whatever the config was written for; without it a
147
- * second Kabmo on another port would silently share the first one.
100
+ * cloudflared runs a copy of the config whose ingress `service:` is this
101
+ * instance's port — see `deriveCloudflaredRunConfig` for why `--url` cannot do
102
+ * that job. The copy is deleted when the process exits or is stopped.
148
103
  */
149
104
  export async function startCloudflared(
150
105
  binary: string,
@@ -156,16 +111,46 @@ export async function startCloudflared(
156
111
  return { ok: true, url: runningTunnelUrl(port), reason: null };
157
112
  }
158
113
 
114
+ let text: string;
115
+ try {
116
+ text = fs.readFileSync(configPath, 'utf8');
117
+ } catch {
118
+ return { ok: false, url: null, reason: `Could not read the cloudflared config at ${configPath}.` };
119
+ }
120
+ const derived = deriveCloudflaredRunConfig(text, port);
121
+ if (!derived) {
122
+ return {
123
+ ok: false,
124
+ url: null,
125
+ reason: `The config at ${configPath} has no ingress rule with a hostname to point at port ${port}.`,
126
+ };
127
+ }
128
+
129
+ let runtimeDir: string;
130
+ let runConfigPath: string;
131
+ try {
132
+ runtimeDir = fs.mkdtempSync(path.join(os.tmpdir(), 'kabmo-cloudflared-'));
133
+ runConfigPath = path.join(runtimeDir, 'config.yml');
134
+ fs.writeFileSync(runConfigPath, derived, { mode: 0o600 });
135
+ } catch (error) {
136
+ return {
137
+ ok: false,
138
+ url: null,
139
+ reason: error instanceof Error ? error.message : String(error),
140
+ };
141
+ }
142
+
159
143
  let proc: Bun.Subprocess<'ignore', 'ignore', 'pipe'>;
160
144
  try {
161
145
  proc = Bun.spawn({
162
- cmd: [binary, 'tunnel', '--config', configPath, 'run', '--url', `http://127.0.0.1:${port}`],
146
+ cmd: [binary, 'tunnel', '--config', runConfigPath, 'run'],
163
147
  stdin: 'ignore',
164
148
  stdout: 'ignore',
165
149
  stderr: 'pipe',
166
150
  env: { ...Bun.env },
167
151
  });
168
152
  } catch (error) {
153
+ removeRuntimeDir(runtimeDir);
169
154
  return {
170
155
  ok: false,
171
156
  url: null,
@@ -174,12 +159,13 @@ export async function startCloudflared(
174
159
  }
175
160
 
176
161
  const url = `https://${hostname}`;
177
- running().set(port, { proc, url });
162
+ running().set(port, { proc, url, runtimeDir });
178
163
 
179
164
  // The process is long-lived; a failure after this point is reported by the
180
165
  // status read (the process is gone), not by this call.
181
166
  proc.exited.then(() => {
182
167
  running().delete(port);
168
+ removeRuntimeDir(runtimeDir);
183
169
  });
184
170
 
185
171
  return { ok: true, url, reason: null };
@@ -195,6 +181,7 @@ export function stopCloudflared(port: number): { ok: boolean; reason: string | n
195
181
  // Already gone.
196
182
  }
197
183
  running().delete(port);
184
+ removeRuntimeDir(entry.runtimeDir);
198
185
  return { ok: true, reason: null };
199
186
  }
200
187
 
@@ -37,6 +37,16 @@ export interface PendingPairing {
37
37
  secretHash: string;
38
38
  candidates: ConnectCandidate[];
39
39
  expiresAt: number;
40
+ /**
41
+ * The code as a downloadable PNG, drawn once when the code is minted.
42
+ *
43
+ * Held here because the download is an HTTP request from a shell's own
44
+ * download machinery (or the browser), which can only carry the session
45
+ * cookie — it cannot run the page's renderer. The secret is not stored in a
46
+ * form that can be replayed as a credential, and the bytes carry the same
47
+ * five-minute life as everything else in this entry.
48
+ */
49
+ qrPng: Uint8Array | null;
40
50
  }
41
51
 
42
52
  declare global {
@@ -76,10 +86,33 @@ export function createPairing(candidates: ConnectCandidate[]): {
76
86
  secretHash: hashSecret(secret),
77
87
  candidates,
78
88
  expiresAt,
89
+ qrPng: null,
79
90
  });
80
91
  return { pairingId, secret, expiresAt: new Date(expiresAt).toISOString() };
81
92
  }
82
93
 
94
+ /**
95
+ * Attach the rendered PNG to a pending code.
96
+ *
97
+ * Separate from `createPairing` because the image encodes the browser link,
98
+ * which needs the secret that minting has just produced — the route is the only
99
+ * place that has both.
100
+ */
101
+ export function attachPairingQr(pairingId: string, png: Uint8Array): void {
102
+ const entry = store().get(pairingId);
103
+ if (!entry) return;
104
+ entry.qrPng = png;
105
+ }
106
+
107
+ /** The code's PNG, or null when it was never drawn, expired, or was used. */
108
+ export function pairingQr(pairingId: string): Uint8Array | null {
109
+ const now = Date.now();
110
+ sweep(now);
111
+ const entry = store().get(pairingId);
112
+ if (!entry || entry.expiresAt <= now) return null;
113
+ return entry.qrPng;
114
+ }
115
+
83
116
  /**
84
117
  * Consume a pairing, or answer why it cannot be consumed.
85
118
  *