@kabmo-labs/kabmo 0.35.0 → 0.36.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 (216) 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-1h3bcak7.js} +2 -2
  4. package/dist/client/static/js/{DocxView-bxjhzxe9.js → DocxView-ndca8jch.js} +2 -2
  5. package/dist/client/static/js/{DrawioView-7s1yqsf4.js → DrawioView-kpzd6y0b.js} +2 -2
  6. package/dist/client/static/js/{ImageView-ycfbn66h.js → ImageView-79prn3dg.js} +1 -1
  7. package/dist/client/static/js/{LayoutWrapper-tw1q1x0g.js → LayoutWrapper-v2wn2sb2.js} +2 -2
  8. package/dist/client/static/js/{Modal-wqjactyd.js → Modal-99j0zz3z.js} +16 -16
  9. package/dist/client/static/js/{PdfView-x6dmtwvr.js → PdfView-2rjd87ay.js} +1 -1
  10. package/dist/client/static/js/{SessionsView-t85wq0me.js → SessionsView-t7f3s71b.js} +1 -1
  11. package/dist/client/static/js/{SheetView-n52nvz8s.js → SheetView-ehb976st.js} +13 -13
  12. package/dist/client/static/js/{SvgPreview-59z7syme.js → SvgPreview-de2bbba6.js} +1 -1
  13. package/dist/client/static/js/{abnfDiagram-O67JEVCF-91gnt049.js → abnfDiagram-O67JEVCF-nx9jzn7m.js} +1 -1
  14. package/dist/client/static/js/architecture-7GRP2DOG-aqft2erp.js +1 -0
  15. package/dist/client/static/js/{architectureDiagram-NJMV4G6O-5b9qtff2.js → architectureDiagram-NJMV4G6O-170v67rr.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-16q285n1.js} +2 -2
  19. package/dist/client/static/js/{c4Diagram-YGBWAQC7-76t6d3am.js → c4Diagram-YGBWAQC7-rn3qt45h.js} +2 -2
  20. package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-f9tb19xm.js → classDiagram-v2-NBCMYWYE-r26wg74e.js} +1 -1
  21. package/dist/client/static/js/{cose-bilkent-JH36ORCC-t6nwrbwj.js → cose-bilkent-JH36ORCC-82kwe7ha.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-v2sz60t6.js +1 -0
  25. package/dist/client/static/js/{cynefinDiagram-VND7K2PF-69gc244j.js → cynefinDiagram-VND7K2PF-tcxdn6pa.js} +1 -1
  26. package/dist/client/static/js/{dagre-6A5THRUB-54bry3ey.js → dagre-6A5THRUB-g833ata3.js} +2 -2
  27. package/dist/client/static/js/{diagram-22UHCM2B-gfkebye6.js → diagram-22UHCM2B-f1fq8xec.js} +3 -3
  28. package/dist/client/static/js/{diagram-3UASUU5V-a1mr319f.js → diagram-3UASUU5V-6j2w016f.js} +1 -1
  29. package/dist/client/static/js/{diagram-ATOU4E4O-tkyk0qbe.js → diagram-ATOU4E4O-6t2qxsk4.js} +3 -3
  30. package/dist/client/static/js/{diagram-CDSNMT55-np0hc9m2.js → diagram-CDSNMT55-7abar8s7.js} +2 -2
  31. package/dist/client/static/js/{diagram-MLGK6HIB-nh06fshp.js → diagram-MLGK6HIB-s68rgy16.js} +1 -1
  32. package/dist/client/static/js/{diagram-MPIPVDR6-27q2veks.js → diagram-MPIPVDR6-azgkm6w8.js} +1 -1
  33. package/dist/client/static/js/{dockerfile-4rtt6c0f.js → dockerfile-47e33kqa.js} +1 -1
  34. package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-x9p9jqe8.js → ebnfDiagram-ZINNZB2B-esrjz750.js} +1 -1
  35. package/dist/client/static/js/{elk-276RUBZZ-fw7waks3.js → elk-276RUBZZ-fhr4b4jj.js} +1 -1
  36. package/dist/client/static/js/{erDiagram-OPXOYQCR-fdfgzr5d.js → erDiagram-OPXOYQCR-5r3fmdnz.js} +4 -4
  37. package/dist/client/static/js/{erlang-trjm07as.js → erlang-bh5cbm8m.js} +1 -1
  38. package/dist/client/static/js/eventmodeling-NTZA5JFV-8qbefe4m.js +1 -0
  39. package/dist/client/static/js/flowDiagram-KWPJA3E3-krsvgcq7.js +1 -0
  40. package/dist/client/static/js/{ganttDiagram-FUAMR5RP-2avbqgdr.js → ganttDiagram-FUAMR5RP-j4pf6rdn.js} +1 -1
  41. package/dist/client/static/js/gitGraph-4MIJSDKK-9bx1a38k.js +1 -0
  42. package/dist/client/static/js/{gitGraphDiagram-X574FWY7-9jmc0a3g.js → gitGraphDiagram-X574FWY7-x5epk0gr.js} +2 -2
  43. package/dist/client/static/js/graphql-xnpp5gn9.js +1 -0
  44. package/dist/client/static/js/{index-nb8tp4mj.js → index-0b1kwsam.js} +8 -8
  45. package/dist/client/static/js/{index-43qpbxjv.js → index-1y9r4frb.js} +2 -2
  46. package/dist/client/static/js/{index-8x9ecxb0.js → index-3kgrcaq1.js} +1 -1
  47. package/dist/client/static/js/{index-a628fg4m.js → index-3vdmwpbh.js} +2 -2
  48. package/dist/client/static/js/{index-jc1yagmk.js → index-3zc1b0dv.js} +2 -2
  49. package/dist/client/static/js/{index-ee2p07eg.js → index-40ve7zzv.js} +1 -1
  50. package/dist/client/static/js/{index-xxtsm2rb.js → index-44qrckd2.js} +2 -2
  51. package/dist/client/static/js/{index-qqz6bcdd.js → index-55pqvh82.js} +2 -2
  52. package/dist/client/static/js/{index-kdkfyrja.js → index-5kjpacvd.js} +2 -2
  53. package/dist/client/static/js/{index-t6c0pd43.js → index-5rzk1226.js} +2 -2
  54. package/dist/client/static/js/{index-jmxqefe3.js → index-60ceydzn.js} +1 -1
  55. package/dist/client/static/js/{index-ek2e773p.js → index-63c6t75t.js} +1 -1
  56. package/dist/client/static/js/{index-6f6cmcbq.js → index-63jbb4kf.js} +2 -2
  57. package/dist/client/static/js/{index-8f9x7ev8.js → index-6xzfta4b.js} +1 -1
  58. package/dist/client/static/js/{index-ncrenheb.js → index-75haaj8g.js} +125 -125
  59. package/dist/client/static/js/{index-4vybd9e7.js → index-7r1hw2gd.js} +1 -1
  60. package/dist/client/static/js/{index-y3ms153k.js → index-8cy3x2y8.js} +2 -2
  61. package/dist/client/static/js/{index-7ct7qrsp.js → index-8e15fzax.js} +2 -2
  62. package/dist/client/static/js/{index-rkn0bxxt.js → index-97t3mv1v.js} +1 -1
  63. package/dist/client/static/js/{index-tp7yb3bv.js → index-982jyfsb.js} +2 -2
  64. package/dist/client/static/js/{index-py2k8std.js → index-9gf8b73w.js} +2 -2
  65. package/dist/client/static/js/{index-pzbssnsc.js → index-af24nes6.js} +2 -2
  66. package/dist/client/static/js/{index-w5373tg1.js → index-b48p8d1j.js} +2 -2
  67. package/dist/client/static/js/{index-w7tpgt46.js → index-be6gevq8.js} +1 -1
  68. package/dist/client/static/js/index-c09a5s1n.js +12 -0
  69. package/dist/client/static/js/{index-7q02xnvq.js → index-c1j0xb0w.js} +1 -1
  70. package/dist/client/static/js/{index-vnw3hbeg.js → index-ctgefatv.js} +27 -27
  71. package/dist/client/static/js/{index-2v1nmxwr.js → index-d2km9egp.js} +5 -5
  72. package/dist/client/static/js/index-dh1vd0d9.js +1 -0
  73. package/dist/client/static/js/{index-zh2jj56s.js → index-dmgawfhw.js} +2 -2
  74. package/dist/client/static/js/{index-k7q01ye4.js → index-h1e1abpt.js} +2 -2
  75. package/dist/client/static/js/{index-0v34a7wf.js → index-htt8qxm3.js} +1 -1
  76. package/dist/client/static/js/{index-a8ffattk.js → index-k1xt92h4.js} +2 -2
  77. package/dist/client/static/js/{index-p16scjt7.js → index-ktvbsj6w.js} +2 -2
  78. package/dist/client/static/js/{index-b8s3xraa.js → index-ky0prc71.js} +5 -5
  79. package/dist/client/static/js/{index-xs1m0bpt.js → index-mm1rf116.js} +1 -1
  80. package/dist/client/static/js/index-nws03exw.js +2 -0
  81. package/dist/client/static/js/{index-rbgemjsp.js → index-pyx8n25s.js} +3 -3
  82. package/dist/client/static/js/{index-3ecsp1rx.js → index-q5t4sy22.js} +3 -3
  83. package/dist/client/static/js/{index-rv89xpaf.js → index-r8pckaqe.js} +2 -2
  84. package/dist/client/static/js/{index-fvc0x6nx.js → index-sar2ggde.js} +3 -3
  85. package/dist/client/static/js/{index-sdby39w4.js → index-skm6k5w2.js} +3 -3
  86. package/dist/client/static/js/{index-whbtxmwh.js → index-v5t761a1.js} +2 -2
  87. package/dist/client/static/js/{index-8mwragbj.js → index-v8qd8ypc.js} +2 -2
  88. package/dist/client/static/js/{index-1wjp16f0.js → index-vtbbfwx0.js} +2 -2
  89. package/dist/client/static/js/{index-vq6wts05.js → index-w3n97x4b.js} +2 -2
  90. package/dist/client/static/js/{index-mc4nefs7.js → index-ydvfc9td.js} +1 -1
  91. package/dist/client/static/js/{index-9ketbkh6.js → index-ye450a7z.js} +1 -1
  92. package/dist/client/static/js/{index-7smwzkvq.js → index-z6g74h7g.js} +2 -2
  93. package/dist/client/static/js/{index-yq39qbs1.js → index-zdtsvnpq.js} +2 -2
  94. package/dist/client/static/js/{index-pc6eg8h2.js → index-zp73zexp.js} +2 -2
  95. package/dist/client/static/js/{index-pnt0vc59.js → index-zvfvqvn9.js} +2 -2
  96. package/dist/client/static/js/info-A6RAGUB7-j51t7jhh.js +1 -0
  97. package/dist/client/static/js/{infoDiagram-VRGFBTTK-g2dky5xg.js → infoDiagram-VRGFBTTK-ktc8nb8g.js} +1 -1
  98. package/dist/client/static/js/ini-ygfyhprj.js +1 -0
  99. package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-exrcjwp1.js → ishikawaDiagram-OU5B5YK6-n3dk6227.js} +1 -1
  100. package/dist/client/static/js/java-gm49vw59.js +1 -0
  101. package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-pn752qa5.js → journeyDiagram-ZHPQQLJL-f0p1h8qn.js} +2 -2
  102. package/dist/client/static/js/jsx-ksxw1byz.js +1 -0
  103. package/dist/client/static/js/{julia-evn99h2m.js → julia-73zjh2w6.js} +1 -1
  104. package/dist/client/static/js/{kanban-definition-PNTS6WVX-v8nvr373.js → kanban-definition-PNTS6WVX-7jdt7dv1.js} +1 -1
  105. package/dist/client/static/js/lua-53gzb9bx.js +1 -0
  106. package/dist/client/static/js/markdown-tk3cd3vs.js +1 -0
  107. package/dist/client/static/js/{mermaid.core-egzv89zv.js → mermaid.core-e8rzrjt9.js} +6 -6
  108. package/dist/client/static/js/{mindmap-definition-NLK3R4M7-t9njmv2w.js → mindmap-definition-NLK3R4M7-7shv6ge0.js} +2 -2
  109. package/dist/client/static/js/one-dark-pro-39bt34v9.js +1 -0
  110. package/dist/client/static/js/one-light-xec0sehr.js +1 -0
  111. package/dist/client/static/js/packet-AYTQ26CC-n83gfj2g.js +1 -0
  112. package/dist/client/static/js/{pegDiagram-GJSIUBJH-zhycy2b7.js → pegDiagram-GJSIUBJH-17ak2zx3.js} +1 -1
  113. package/dist/client/static/js/{perl-506fy8m8.js → perl-8z46dmze.js} +1 -1
  114. package/dist/client/static/js/{php-axtsvxck.js → php-6qvnp2t6.js} +1 -1
  115. package/dist/client/static/js/pie-WAS4IAKB-5c5pctwz.js +1 -0
  116. package/dist/client/static/js/{pieDiagram-5QR66LMP-sgctvma2.js → pieDiagram-5QR66LMP-at4x1g4q.js} +1 -1
  117. package/dist/client/static/js/properties-2tcybqjk.js +1 -0
  118. package/dist/client/static/js/python-qph3dntq.js +1 -0
  119. package/dist/client/static/js/{quadrantDiagram-O4NWA36T-kzzhdcph.js → quadrantDiagram-O4NWA36T-apzhwrn4.js} +1 -1
  120. package/dist/client/static/js/r-gd26x93y.js +1 -0
  121. package/dist/client/static/js/radar-RG4KPBEZ-52e5n99a.js +1 -0
  122. package/dist/client/static/js/railroad-74A4TZTK-44nqxxpy.js +1 -0
  123. package/dist/client/static/js/railroad-abnf-HS5TGJTU-25jxgwg7.js +1 -0
  124. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-64pqpf2y.js +1 -0
  125. package/dist/client/static/js/railroad-peg-WCYAUIDC-0p5sxzpx.js +1 -0
  126. package/dist/client/static/js/{railroadDiagram-XR7U4H2S-nzjffwxm.js → railroadDiagram-XR7U4H2S-rw8cj5f3.js} +1 -1
  127. package/dist/client/static/js/{requirementDiagram-PLB6GJNP-tz4xxn4d.js → requirementDiagram-PLB6GJNP-qyrse7mb.js} +1 -1
  128. package/dist/client/static/js/{ruby-qp7zfk2m.js → ruby-qy8mhstq.js} +1 -1
  129. package/dist/client/static/js/{rust-fz913fvw.js → rust-fpshqnk0.js} +1 -1
  130. package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-2wcb0xr6.js → sankeyDiagram-IPEJSGJF-254qr59q.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-y9xjxfc5.js} +5 -5
  133. package/dist/client/static/js/{sizeCapture-INFHLROL-xc314tes.js → sizeCapture-INFHLROL-sc5e60t3.js} +1 -1
  134. package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-8bd9b1h8.js → stateDiagram-v2-GCMORJYK-r134s4xr.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-xc7rbawt.js} +1 -1
  137. package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-kdcdamkj.js +8 -0
  138. package/dist/client/static/js/{timeline-definition-EJHVYXUP-2txxasx5.js → timeline-definition-EJHVYXUP-cgjd8shk.js} +2 -2
  139. package/dist/client/static/js/treeView-Q6P3EWNA-8j14nnd1.js +1 -0
  140. package/dist/client/static/js/treemap-WGGIJYW6-esf993kk.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-9qsmjhm6.js} +2 -2
  144. package/dist/client/static/js/{vennDiagram-UO4OBE2U-cerpss8e.js → vennDiagram-UO4OBE2U-4grw9awx.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-v4dxm2sb.js +1 -0
  147. package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-cx6jfsbf.js → wardleyDiagram-VNRHLVJA-8gxy0wat.js} +1 -1
  148. package/dist/client/static/js/xml-0py2vkw7.js +1 -0
  149. package/dist/client/static/js/{xychartDiagram-PMCCYNJV-tgn23xj1.js → xychartDiagram-PMCCYNJV-5sh7tdrx.js} +2 -2
  150. package/dist/client/static/js/yaml-vghdz0f0.js +1 -0
  151. package/package.json +1 -1
  152. package/src/client/components/settings/categories/ConnectSettings.tsx +8 -1
  153. package/src/client/components/settings/categories/connect-settings/CloudflareConfig.test.tsx +84 -0
  154. package/src/client/components/settings/categories/connect-settings/CloudflareConfig.tsx +68 -0
  155. package/src/client/components/settings/categories/connect-settings/PairDialog.test.tsx +49 -49
  156. package/src/client/components/settings/categories/connect-settings/PairDialog.tsx +12 -8
  157. package/src/client/components/settings/categories/connect-settings/QrCode.tsx +19 -2
  158. package/src/client/hooks/connect/use-connect-status.ts +44 -19
  159. package/src/client/hooks/connect/use-pairing.ts +5 -0
  160. package/src/client/lib/notifications/watch.ts +4 -1
  161. package/src/server/lib/connect/cloudflared-config.server.ts +236 -0
  162. package/src/server/lib/connect/cloudflared-config.test.ts +245 -0
  163. package/src/server/lib/connect/cloudflared.lifecycle.test.ts +116 -15
  164. package/src/server/lib/connect/cloudflared.server.ts +53 -66
  165. package/src/server/lib/connect/pairing.server.ts +33 -0
  166. package/src/server/lib/connect/qr-png.server.test.ts +93 -0
  167. package/src/server/lib/connect/qr-png.server.ts +119 -0
  168. package/src/server/lib/connect/status.server.ts +10 -4
  169. package/src/server/routes/connect/index.ts +2 -0
  170. package/src/server/routes/connect/pair-qr.test.ts +72 -0
  171. package/src/server/routes/connect/pair-qr.ts +44 -0
  172. package/src/server/routes/connect/pair.ts +8 -2
  173. package/src/server/routes/connect/tunnels.test.ts +141 -0
  174. package/src/server/routes/connect/tunnels.ts +32 -7
  175. package/src/server/routes/notifications/stream.ts +11 -2
  176. package/src/shared/lib/connect/types.ts +7 -0
  177. package/dist/client/static/js/architecture-7GRP2DOG-bajpnvy7.js +0 -1
  178. package/dist/client/static/js/bash-0h36tk0k.js +0 -1
  179. package/dist/client/static/js/cpp-4wp9sy20.js +0 -1
  180. package/dist/client/static/js/css-c9nsbkh6.js +0 -1
  181. package/dist/client/static/js/cynefin-OW5HDTMX-8q9e90m8.js +0 -1
  182. package/dist/client/static/js/eventmodeling-NTZA5JFV-kn4hsm3p.js +0 -1
  183. package/dist/client/static/js/flowDiagram-KWPJA3E3-ah8cvps1.js +0 -1
  184. package/dist/client/static/js/gitGraph-4MIJSDKK-hvavh16n.js +0 -1
  185. package/dist/client/static/js/graphql-hbkmxsty.js +0 -1
  186. package/dist/client/static/js/index-btr2w8cq.js +0 -12
  187. package/dist/client/static/js/index-dfzrpy54.js +0 -2
  188. package/dist/client/static/js/index-sbd5e816.js +0 -1
  189. package/dist/client/static/js/info-A6RAGUB7-fmjz8qwg.js +0 -1
  190. package/dist/client/static/js/ini-72yrpvd4.js +0 -1
  191. package/dist/client/static/js/java-ab5tb2ra.js +0 -1
  192. package/dist/client/static/js/jsx-25zj9j3k.js +0 -1
  193. package/dist/client/static/js/lua-j5w0c9wm.js +0 -1
  194. package/dist/client/static/js/markdown-j6hn4377.js +0 -1
  195. package/dist/client/static/js/one-dark-pro-bm3r4js7.js +0 -1
  196. package/dist/client/static/js/one-light-e07dt7sy.js +0 -1
  197. package/dist/client/static/js/packet-AYTQ26CC-cwr6n1cm.js +0 -1
  198. package/dist/client/static/js/pie-WAS4IAKB-h1ebfzgt.js +0 -1
  199. package/dist/client/static/js/properties-q8njes42.js +0 -1
  200. package/dist/client/static/js/python-vqxc7181.js +0 -1
  201. package/dist/client/static/js/r-0k5eej8m.js +0 -1
  202. package/dist/client/static/js/radar-RG4KPBEZ-k7p1m364.js +0 -1
  203. package/dist/client/static/js/railroad-74A4TZTK-d08dw3t0.js +0 -1
  204. package/dist/client/static/js/railroad-abnf-HS5TGJTU-txnjycgk.js +0 -1
  205. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-p0r3cv6w.js +0 -1
  206. package/dist/client/static/js/railroad-peg-WCYAUIDC-sryk900a.js +0 -1
  207. package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-c1czc7kv.js +0 -8
  208. package/dist/client/static/js/treeView-Q6P3EWNA-77kj68p1.js +0 -1
  209. package/dist/client/static/js/treemap-WGGIJYW6-rw94xc82.js +0 -1
  210. package/dist/client/static/js/tsx-yd5wt250.js +0 -1
  211. package/dist/client/static/js/typescript-v7z7crfe.js +0 -1
  212. package/dist/client/static/js/wardley-WFR3VGLG-18xe4fhz.js +0 -1
  213. package/dist/client/static/js/xml-94fhzrfs.js +0 -1
  214. package/dist/client/static/js/yaml-s8af9rnw.js +0 -1
  215. package/src/client/components/settings/categories/connect-settings/qr-image.ts +0 -76
  216. package/src/server/lib/connect/cloudflared.server.test.ts +0 -65
@@ -30,6 +30,7 @@ export interface UseConnectStatusResult {
30
30
  busy: string | null;
31
31
  refresh: () => Promise<void>;
32
32
  setTunnel: (provider: TunnelProvider, verb: TunnelVerb) => Promise<string | null>;
33
+ setCloudflareConfig: (path: string) => Promise<string | null>;
33
34
  revoke: (id: string) => Promise<string | null>;
34
35
  }
35
36
 
@@ -38,6 +39,34 @@ interface StatusEnvelope {
38
39
  error?: string;
39
40
  }
40
41
 
42
+ interface PostOutcome {
43
+ payload: StatusEnvelope | null;
44
+ message: string | null;
45
+ }
46
+
47
+ async function postTunnel(body: Record<string, unknown>): Promise<PostOutcome> {
48
+ try {
49
+ const response = await fetch('/api/connect/tunnels', {
50
+ method: 'POST',
51
+ headers: { 'content-type': 'application/json' },
52
+ body: JSON.stringify(body),
53
+ });
54
+ const payload = (await response.json().catch(() => null)) as StatusEnvelope | null;
55
+ if (!response.ok) {
56
+ return {
57
+ payload,
58
+ message: payload?.error ?? `The tunnel did not change (HTTP ${response.status}).`,
59
+ };
60
+ }
61
+ return { payload, message: null };
62
+ } catch (cause) {
63
+ return {
64
+ payload: null,
65
+ message: cause instanceof Error ? cause.message : 'The tunnel did not change.',
66
+ };
67
+ }
68
+ }
69
+
41
70
  export function useConnectStatus(): UseConnectStatusResult {
42
71
  const [status, setStatus] = useState<ConnectStatus | null>(null);
43
72
  const [error, setError] = useState<string | null>(null);
@@ -61,26 +90,12 @@ export function useConnectStatus(): UseConnectStatusResult {
61
90
  void refresh();
62
91
  }, [refresh]);
63
92
 
64
- const setTunnel = useCallback(
65
- async (provider: TunnelProvider, verb: TunnelVerb): Promise<string | null> => {
66
- setBusy(`${provider}:${verb}`);
93
+ const applyTunnel = useCallback(
94
+ async (busyKey: string, body: Record<string, unknown>): Promise<string | null> => {
95
+ setBusy(busyKey);
67
96
  try {
68
- const response = await fetch('/api/connect/tunnels', {
69
- method: 'POST',
70
- headers: { 'content-type': 'application/json' },
71
- body: JSON.stringify({ provider, action: verb }),
72
- });
73
- const payload = (await response.json().catch(() => null)) as StatusEnvelope | null;
97
+ const { payload, message } = await postTunnel(body);
74
98
  if (payload?.status) setStatus(payload.status);
75
- if (!response.ok) {
76
- const message = payload?.error ?? `The tunnel did not change (HTTP ${response.status}).`;
77
- setError(message);
78
- return message;
79
- }
80
- setError(null);
81
- return null;
82
- } catch (cause) {
83
- const message = cause instanceof Error ? cause.message : 'The tunnel did not change.';
84
99
  setError(message);
85
100
  return message;
86
101
  } finally {
@@ -90,6 +105,16 @@ export function useConnectStatus(): UseConnectStatusResult {
90
105
  [],
91
106
  );
92
107
 
108
+ const setTunnel = useCallback(
109
+ (provider: TunnelProvider, verb: TunnelVerb) => applyTunnel(`${provider}:${verb}`, { provider, action: verb }),
110
+ [applyTunnel],
111
+ );
112
+
113
+ const setCloudflareConfig = useCallback(
114
+ (path: string) => applyTunnel('cloudflare:config', { provider: 'cloudflare', action: 'config', path }),
115
+ [applyTunnel],
116
+ );
117
+
93
118
  const revoke = useCallback(async (id: string): Promise<string | null> => {
94
119
  setBusy(`device:${id}`);
95
120
  try {
@@ -112,5 +137,5 @@ export function useConnectStatus(): UseConnectStatusResult {
112
137
  }
113
138
  }, []);
114
139
 
115
- return { status, error, busy, refresh, setTunnel, revoke };
140
+ return { status, error, busy, refresh, setTunnel, setCloudflareConfig, revoke };
116
141
  }
@@ -22,6 +22,8 @@ export interface PairingCode {
22
22
  link: string;
23
23
  /** The `https://…/pair#…` link a browser can open. This is what the QR holds. */
24
24
  webLink: string;
25
+ /** The same code as a downloadable PNG, served by this origin. */
26
+ qrUrl: string;
25
27
  candidates: ConnectCandidate[];
26
28
  qr: { size: number; rows: string[] };
27
29
  }
@@ -66,6 +68,9 @@ export function usePairing(): UsePairingResult {
66
68
  expiresAt: payload.expiresAt ?? '',
67
69
  link: payload.link,
68
70
  webLink: payload.webLink ?? payload.link,
71
+ // A server too old to serve the PNG still mints a scannable code; the
72
+ // dialog then leaves the download out rather than pointing it at nothing.
73
+ qrUrl: payload.qrUrl ?? '',
69
74
  candidates: payload.candidates ?? [],
70
75
  qr: payload.qr,
71
76
  });
@@ -9,7 +9,10 @@
9
9
  * The event switches live in the server's settings, and the shell has no page
10
10
  * to ask once the app is backgrounded — so the answer is pushed to it here, on
11
11
  * boot and whenever a switch changes. The shell persists it and starts its
12
- * watcher from `onStop` only when it is armed.
12
+ * watcher from that command, while the console is still visible (Android 12+
13
+ * refuses a foreground-service start from the background); it also refuses to
14
+ * start when the OS notification permission is missing, and `MainActivity`
15
+ * re-arms on the next resume once the grant exists.
13
16
  *
14
17
  * A no-op outside a phone shell: the desktop shells and a browser have no
15
18
  * background watcher, and their notifications are posted by the page itself.
@@ -0,0 +1,236 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The cloudflared config: where it is, what it says, and the copy cloudflared
8
+ * actually runs.
9
+ *
10
+ * Two facts decide the tunnel's destination. The config path is a stored
11
+ * preference (page), an environment override (`CLOUDFLARED_CONFIG`) or the
12
+ * documented default; the ingress `service:` is what cloudflared dials, and it
13
+ * must be THIS instance's port or a second Kabmo silently gets the first one's
14
+ * traffic. `--url` cannot fix that — see `deriveCloudflaredRunConfig`.
15
+ */
16
+
17
+ import fs from 'fs';
18
+ import os from 'os';
19
+ import path from 'path';
20
+ import { getDb } from '@/server/db.server';
21
+ import { readSettingsJson, writeSettingsJson } from '@/server/lib/db/settings-store';
22
+
23
+ /** `app_settings` key holding the config path chosen on the Connect page. */
24
+ const CLOUDFLARE_CONFIG_KEY = 'connect.cloudflareConfigPath';
25
+
26
+ export interface CloudflaredConfig {
27
+ /** The tunnel name or UUID from `tunnel:`. */
28
+ tunnel: string | null;
29
+ /** The first public hostname in the ingress list. */
30
+ hostname: string | null;
31
+ }
32
+
33
+ /** Where cloudflared looks for its config, honouring the documented override. */
34
+ export function cloudflaredConfigPath(): string {
35
+ const override = (Bun.env.CLOUDFLARED_CONFIG ?? '').trim();
36
+ if (override) return override;
37
+ return path.join(os.homedir(), '.cloudflared', 'config.yml');
38
+ }
39
+
40
+ function expandHome(value: string): string {
41
+ if (value === '~') return os.homedir();
42
+ if (value.startsWith('~/')) return path.join(os.homedir(), value.slice(2));
43
+ return value;
44
+ }
45
+
46
+ /**
47
+ * The config the Connect page and the start path agree on.
48
+ *
49
+ * A path saved on the page wins over `CLOUDFLARED_CONFIG`, which wins over
50
+ * `~/.cloudflared/config.yml`. The page allows the override because a config
51
+ * kept outside the home directory (a secret store, a work profile) is a normal
52
+ * setup, and editing an environment variable before every start is not.
53
+ */
54
+ export async function resolveCloudflaredConfigPath(): Promise<string> {
55
+ const db = await getDb();
56
+ const stored = await readSettingsJson<unknown>(db, CLOUDFLARE_CONFIG_KEY, null);
57
+ if (typeof stored === 'string' && stored.trim()) return stored.trim();
58
+ return cloudflaredConfigPath();
59
+ }
60
+
61
+ export interface SaveConfigOutcome {
62
+ ok: boolean;
63
+ /** The path now in effect, when the save succeeded. */
64
+ path: string | null;
65
+ reason: string | null;
66
+ }
67
+
68
+ /**
69
+ * Persist a config path after proving cloudflared could run from it.
70
+ *
71
+ * A saved path that is missing or has no ingress hostname would put a dead
72
+ * switch on the page, so the write is refused with the reason the reader can
73
+ * act on. An empty string resets to the environment/default path.
74
+ */
75
+ export async function saveCloudflaredConfigPath(raw: unknown): Promise<SaveConfigOutcome> {
76
+ if (typeof raw !== 'string') {
77
+ return { ok: false, path: null, reason: 'Expected a config path.' };
78
+ }
79
+ const db = await getDb();
80
+ const trimmed = raw.trim();
81
+ if (!trimmed) {
82
+ await writeSettingsJson(db, CLOUDFLARE_CONFIG_KEY, null);
83
+ return { ok: true, path: cloudflaredConfigPath(), reason: null };
84
+ }
85
+
86
+ const expanded = expandHome(trimmed);
87
+ if (!path.isAbsolute(expanded)) {
88
+ return { ok: false, path: null, reason: 'The config path must be absolute.' };
89
+ }
90
+ const resolved = path.resolve(expanded);
91
+ let isFile = false;
92
+ try {
93
+ isFile = fs.statSync(resolved).isFile();
94
+ } catch {
95
+ return { ok: false, path: null, reason: `No config file at ${resolved}.` };
96
+ }
97
+ if (!isFile) {
98
+ return { ok: false, path: null, reason: `${resolved} is not a file.` };
99
+ }
100
+
101
+ const config = readCloudflaredConfig(resolved);
102
+ if (!config) {
103
+ return {
104
+ ok: false,
105
+ path: null,
106
+ reason: `${resolved} is not a cloudflared config: it has no tunnel: or ingress: entry.`,
107
+ };
108
+ }
109
+ if (!config.hostname) {
110
+ return {
111
+ ok: false,
112
+ path: null,
113
+ reason: `The config at ${resolved} has no ingress hostname, so there is no public URL to show.`,
114
+ };
115
+ }
116
+
117
+ await writeSettingsJson(db, CLOUDFLARE_CONFIG_KEY, resolved);
118
+ return { ok: true, path: resolved, reason: null };
119
+ }
120
+
121
+ /**
122
+ * Read the two facts this page needs out of the YAML.
123
+ *
124
+ * A line scan rather than a YAML parser: the file is written by
125
+ * `cloudflared tunnel create` and by hand, and the only fields read here are a
126
+ * top-level `tunnel:` and the first `hostname:` under `ingress:`. Pulling in a
127
+ * parser for two scalars would be a dependency the rest of the server does not
128
+ * have, and a malformed file must degrade to "not configured" rather than throw.
129
+ */
130
+ export function readCloudflaredConfig(file: string): CloudflaredConfig | null {
131
+ let text: string;
132
+ try {
133
+ text = fs.readFileSync(file, 'utf8');
134
+ } catch {
135
+ return null;
136
+ }
137
+
138
+ let tunnel: string | null = null;
139
+ let hostname: string | null = null;
140
+ let inIngress = false;
141
+ for (const rawLine of text.split('\n')) {
142
+ const line = rawLine.replace(/\s+#.*$/, '');
143
+ if (/^tunnel:\s*/.test(line)) {
144
+ tunnel = line.replace(/^tunnel:\s*/, '').trim().replace(/^["']|["']$/g, '') || null;
145
+ continue;
146
+ }
147
+ if (/^ingress:\s*$/.test(line)) {
148
+ inIngress = true;
149
+ continue;
150
+ }
151
+ if (inIngress && /^\S/.test(line)) {
152
+ // A new top-level key ends the ingress block.
153
+ inIngress = false;
154
+ }
155
+ if (inIngress && hostname === null) {
156
+ const match = /^\s*-\s*hostname:\s*(\S+)/.exec(line) ?? /^\s*hostname:\s*(\S+)/.exec(line);
157
+ if (match?.[1]) hostname = match[1].replace(/^["']|["']$/g, '');
158
+ }
159
+ }
160
+
161
+ if (!tunnel && !hostname) return null;
162
+ return { tunnel, hostname };
163
+ }
164
+
165
+ /**
166
+ * The config cloudflared actually runs with, pointed at this instance's port.
167
+ *
168
+ * `--url` does NOT override an `ingress:` block: cloudflared parses the config's
169
+ * rules first and only falls back to the CLI origin when `ingress` is empty
170
+ * (`ingress.ParseIngressFromConfigAndCLI`). Kabmo refuses a config without an
171
+ * ingress hostname, so every config it accepts would ignore `--url` and send
172
+ * traffic to whatever `service:` names — often a different port or a different
173
+ * app. The first rule that names a hostname therefore gets its `service:`
174
+ * rewritten in a runtime copy; the user's file is never touched.
175
+ *
176
+ * Returns null when there is no ingress rule with a hostname to rewrite.
177
+ */
178
+ export function deriveCloudflaredRunConfig(text: string, port: number): string | null {
179
+ const lines = text.split('\n');
180
+ const ingressAt = lines.findIndex((line) => /^ingress:\s*$/.test(line.replace(/\s+#.*$/, '')));
181
+ if (ingressAt === -1) return null;
182
+
183
+ // A new top-level key ends the ingress block.
184
+ let end = lines.length;
185
+ for (let i = ingressAt + 1; i < lines.length; i++) {
186
+ if (/^\S/.test(lines[i])) {
187
+ end = i;
188
+ break;
189
+ }
190
+ }
191
+
192
+ // Only items at the first rule's indentation start a new rule; a nested
193
+ // `ipRules:` list under `originRequest` must not cut the rule in two.
194
+ const itemPattern = /^(\s*)-\s/;
195
+ const items: Array<{ at: number; indent: string }> = [];
196
+ for (let i = ingressAt + 1; i < end; i++) {
197
+ const item = itemPattern.exec(lines[i]);
198
+ if (item) items.push({ at: i, indent: item[1] });
199
+ }
200
+ if (items.length === 0) return null;
201
+ const ruleIndent = items[0].indent;
202
+ const starts = items.filter((item) => item.indent === ruleIndent).map((item) => item.at);
203
+
204
+ const hostnamePattern = /^(\s*)(-\s*)?hostname:\s*(\S+)/;
205
+ const servicePattern = /^(\s*)service:\s*/;
206
+ for (let rule = 0; rule < starts.length; rule++) {
207
+ const from = starts[rule];
208
+ const to = rule + 1 < starts.length ? starts[rule + 1] : end;
209
+ let hostnameAt = -1;
210
+ for (let i = from; i < to; i++) {
211
+ if (hostnamePattern.test(lines[i])) {
212
+ hostnameAt = i;
213
+ break;
214
+ }
215
+ }
216
+ if (hostnameAt === -1) continue;
217
+
218
+ const copy = lines.slice();
219
+ for (let i = from; i < to; i++) {
220
+ const service = servicePattern.exec(lines[i]);
221
+ if (!service) continue;
222
+ const cr = lines[i].endsWith('\r') ? '\r' : '';
223
+ copy[i] = `${service[1]}service: http://127.0.0.1:${port}${cr}`;
224
+ return copy.join('\n');
225
+ }
226
+
227
+ // The rule has a hostname but no service of its own: add one beside it.
228
+ const hostname = hostnamePattern.exec(lines[hostnameAt]) as RegExpExecArray;
229
+ const indent = hostname[1] + (hostname[2] ? ' ' : '');
230
+ const cr = lines[hostnameAt].endsWith('\r') ? '\r' : '';
231
+ copy.splice(hostnameAt + 1, 0, `${indent}service: http://127.0.0.1:${port}${cr}`);
232
+ return copy.join('\n');
233
+ }
234
+
235
+ return null;
236
+ }
@@ -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
+ });