dsh-builtin-browser 1.0.0 → 1.0.3

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 (364) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/README.md +1 -1
  3. package/assets/browser-panel-locales.mjs +37 -5
  4. package/assets/browser-policy.d.mts +29 -0
  5. package/assets/browser-policy.mjs +40 -0
  6. package/desktop-bridge/desktop-discovery.d.mts +1 -1
  7. package/desktop-bridge/desktop-discovery.mjs +59 -9
  8. package/desktop-bridge/desktop-identity.json +12 -0
  9. package/desktop-bridge/install.mjs +14 -7
  10. package/desktop-bridge/plugin-browser-bridge.js +19 -7
  11. package/docs/acceptance-2026-11-27.md +67 -0
  12. package/docs/architecture.md +1 -1
  13. package/docs/development.md +33 -4
  14. package/docs/dsh-0.2.3-host-patch-task.md +34 -0
  15. package/docs/hardcoding-audit.md +28 -8
  16. package/docs/known-issues.md +26 -0
  17. package/docs/limitations.md +6 -2
  18. package/docs/pr64-maintenance.md +1 -1
  19. package/docs/tool-reference.md +1 -1
  20. package/docs/user-guide.md +1 -1
  21. package/docs/v1.1.0-bu-data-batching-task.md +66 -0
  22. package/docs/v1.1.0-compat-hardcoding-task.md +85 -0
  23. package/dsh-builtin-browser-1.0.3-publish.tgz +0 -0
  24. package/dsh-builtin-browser-1.0.3.tgz +0 -0
  25. package/dsh-host-patch/README.md +4 -0
  26. package/dsh-host-patch/apply.mjs +61 -13
  27. package/dsh-host-patch/rc3-revision9.json.gz +0 -0
  28. package/dsh-host-patch/rc5-revision9.json.gz +0 -0
  29. package/dsh-host-patch/sources/main/0001-feat-sidebar-right-add-session-rendering-holds.patch.gz +0 -0
  30. package/dsh-host-patch/sources/main/0002-feat-desktop-load-trusted-profile-main-extensions.patch.gz +0 -0
  31. package/dsh-host-patch/sources/main/0003-feat-desktop-report-resolved-and-running-main-extens.patch.gz +0 -0
  32. package/dsh-host-patch/sources/main/0004-feat-desktop-compose-admitted-native-sidebar-views.patch.gz +0 -0
  33. package/dsh-host-patch/sources/main/0005-fix-client-admit-coded-browser-errors-in-native-comp.patch.gz +0 -0
  34. package/dsh-host-patch/sources/main/0006-fix-desktop-acknowledge-native-same-document-navigat.patch.gz +0 -0
  35. package/dsh-host-patch/sources/main/0007-fix-desktop-restore-auth-in-the-native-lease-partiti.patch.gz +0 -0
  36. package/dsh-host-patch/sources/main/0008-feat-desktop-adopt-native-children-in-admitted-sideb.patch.gz +0 -0
  37. package/dsh-host-patch/sources/main/0009-fix-desktop-publish-complete-native-child-close-reco.patch.gz +0 -0
  38. package/dsh-host-patch/sources/main/0010-fix-desktop-bundle-structured-errors-in-sandboxed-pr.patch.gz +0 -0
  39. package/dsh-host-patch/sources/main/0011-feat-desktop-offer-persistent-Sidebar-sessions-per-D.patch.gz +0 -0
  40. package/dsh-host-patch/sources/main/0012-feat-desktop-retain-sidebar-session-cookies-across-r.patch.gz +0 -0
  41. package/dsh-host-patch/sources/main/0013-fix-desktop-honor-sidebar-session-cookie-sidecar-con.patch.gz +0 -0
  42. package/dsh-host-patch/sources/main/0014-fix-desktop-retry-cookie-protection-without-failing-.patch.gz +0 -0
  43. package/dsh-host-patch/sources/main/0015-fix-desktop-preserve-host-only-cookie-identity-in-se.patch.gz +0 -0
  44. package/dsh-host-patch/sources/main/0016-fix-desktop-restore-session-cookies-before-checkpoin.patch.gz +0 -0
  45. package/dsh-host-patch/sources/main/0017-fix-desktop-restore-sidebar-cookies-once-before-gues.patch.gz +0 -0
  46. package/dsh-host-patch/sources/main/0018-fix-sidebar-right-follow-animated-native-slot-placem.patch.gz +0 -0
  47. package/dsh-host-patch/sources/manifest.json +218 -0
  48. package/dsh-host-patch/sources/rc3/0001-feat-sidebar-right-add-session-rendering-holds.patch.gz +0 -0
  49. package/dsh-host-patch/sources/rc3/0002-feat-desktop-load-trusted-profile-main-extensions.patch.gz +0 -0
  50. package/dsh-host-patch/sources/rc3/0003-feat-desktop-report-resolved-and-running-main-extens.patch.gz +0 -0
  51. package/dsh-host-patch/sources/rc3/0004-feat-desktop-compose-admitted-native-sidebar-views.patch.gz +0 -0
  52. package/dsh-host-patch/sources/rc3/0005-fix-client-admit-coded-browser-errors-in-native-comp.patch.gz +0 -0
  53. package/dsh-host-patch/sources/rc3/0006-fix-desktop-acknowledge-native-same-document-navigat.patch.gz +0 -0
  54. package/dsh-host-patch/sources/rc3/0007-fix-desktop-restore-auth-in-the-native-lease-partiti.patch.gz +0 -0
  55. package/dsh-host-patch/sources/rc3/0008-feat-desktop-adopt-native-children-in-admitted-sideb.patch.gz +0 -0
  56. package/dsh-host-patch/sources/rc3/0009-fix-desktop-publish-complete-native-child-close-reco.patch.gz +0 -0
  57. package/dsh-host-patch/sources/rc3/0010-fix-desktop-bundle-structured-errors-in-sandboxed-pr.patch.gz +0 -0
  58. package/dsh-host-patch/sources/rc3/0011-feat-desktop-offer-persistent-Sidebar-sessions-per-D.patch.gz +0 -0
  59. package/dsh-host-patch/sources/rc3/0012-feat-desktop-retain-sidebar-session-cookies-across-r.patch.gz +0 -0
  60. package/dsh-host-patch/sources/rc3/0013-fix-desktop-honor-sidebar-session-cookie-sidecar-con.patch.gz +0 -0
  61. package/dsh-host-patch/sources/rc3/0014-fix-desktop-retry-cookie-protection-without-failing-.patch.gz +0 -0
  62. package/dsh-host-patch/sources/rc3/0015-fix-desktop-preserve-host-only-cookie-identity-in-se.patch.gz +0 -0
  63. package/dsh-host-patch/sources/rc3/0016-fix-desktop-restore-session-cookies-before-checkpoin.patch.gz +0 -0
  64. package/dsh-host-patch/sources/rc3/0017-fix-desktop-restore-sidebar-cookies-once-before-gues.patch.gz +0 -0
  65. package/dsh-host-patch/sources/rc3/0018-fix-sidebar-right-follow-animated-native-slot-placem.patch.gz +0 -0
  66. package/dsh-host-patch/sources/rc5/0001-feat-sidebar-right-add-session-rendering-holds.patch.gz +0 -0
  67. package/dsh-host-patch/sources/rc5/0002-feat-desktop-load-trusted-profile-main-extensions.patch.gz +0 -0
  68. package/dsh-host-patch/sources/rc5/0003-feat-desktop-report-resolved-and-running-main-extens.patch.gz +0 -0
  69. package/dsh-host-patch/sources/rc5/0004-feat-desktop-compose-admitted-native-sidebar-views.patch.gz +0 -0
  70. package/dsh-host-patch/sources/rc5/0005-fix-client-admit-coded-browser-errors-in-native-comp.patch.gz +0 -0
  71. package/dsh-host-patch/sources/rc5/0006-fix-desktop-acknowledge-native-same-document-navigat.patch.gz +0 -0
  72. package/dsh-host-patch/sources/rc5/0007-fix-desktop-restore-auth-in-the-native-lease-partiti.patch.gz +0 -0
  73. package/dsh-host-patch/sources/rc5/0008-feat-desktop-adopt-native-children-in-admitted-sideb.patch.gz +0 -0
  74. package/dsh-host-patch/sources/rc5/0009-fix-desktop-publish-complete-native-child-close-reco.patch.gz +0 -0
  75. package/dsh-host-patch/sources/rc5/0010-fix-desktop-bundle-structured-errors-in-sandboxed-pr.patch.gz +0 -0
  76. package/dsh-host-patch/sources/rc5/0011-feat-desktop-offer-persistent-Sidebar-sessions-per-D.patch.gz +0 -0
  77. package/dsh-host-patch/sources/rc5/0012-feat-desktop-retain-sidebar-session-cookies-across-r.patch.gz +0 -0
  78. package/dsh-host-patch/sources/rc5/0013-fix-desktop-honor-sidebar-session-cookie-sidecar-con.patch.gz +0 -0
  79. package/dsh-host-patch/sources/rc5/0014-fix-desktop-retry-cookie-protection-without-failing-.patch.gz +0 -0
  80. package/dsh-host-patch/sources/rc5/0015-fix-desktop-preserve-host-only-cookie-identity-in-se.patch.gz +0 -0
  81. package/dsh-host-patch/sources/rc5/0016-fix-desktop-restore-session-cookies-before-checkpoin.patch.gz +0 -0
  82. package/dsh-host-patch/sources/rc5/0017-fix-desktop-restore-sidebar-cookies-once-before-gues.patch.gz +0 -0
  83. package/dsh-host-patch/sources/rc5/0018-fix-sidebar-right-follow-animated-native-slot-placem.patch.gz +0 -0
  84. package/dsh-host-patch/sources/series.json +260 -0
  85. package/dsh-host-patch/tauri/desktop-main.cjs +62 -0
  86. package/dsh-host-patch/tauri/sidebar-session.cjs +104 -0
  87. package/dsh-host-patch/tauri-revision1.json +39 -0
  88. package/dsh-host-patch/tauri.json +43 -0
  89. package/dsh-host-patch/v023-alpha2.json +153 -0
  90. package/lib/browser/anti-bot.js +215 -0
  91. package/lib/browser/deep-dom.js +39 -0
  92. package/lib/browser/runtime.js +15 -0
  93. package/lib/browser/takeover-target.js +13 -6
  94. package/lib/browser/types.js +30 -1
  95. package/lib/browser-electron/authenticated-route.js +16 -2
  96. package/lib/browser-electron/automatic-maintenance.js +16 -10
  97. package/lib/browser-electron/bridge-connection.js +3 -8
  98. package/lib/browser-electron/bridge-install.js +2 -1
  99. package/lib/browser-electron/bridge-status.js +55 -26
  100. package/lib/browser-electron/desktop-bridge-host.js +7 -6
  101. package/lib/browser-electron/desktop-identity.js +28 -5
  102. package/lib/browser-electron/desktop-shell.js +64 -0
  103. package/lib/browser-electron/electron-provision.js +105 -18
  104. package/lib/browser-electron/entry.js +129 -46
  105. package/lib/browser-electron/extension-browser.js +4 -4
  106. package/lib/browser-electron/foreground-watch.js +134 -0
  107. package/lib/browser-electron/guest-cookie-jar.js +13 -13
  108. package/lib/browser-electron/guest-route.js +181 -32
  109. package/lib/browser-electron/guest-runtime.js +61 -10
  110. package/lib/browser-electron/guest-storage.js +2 -2
  111. package/lib/browser-electron/history-store.js +1 -5
  112. package/lib/browser-electron/host-main.js +8 -4
  113. package/lib/browser-electron/host-patch-maintenance.js +14 -8
  114. package/lib/browser-electron/maintenance-route.js +2 -1
  115. package/lib/browser-electron/missing-system-browser.js +5 -9
  116. package/lib/browser-electron/preferred-browser.js +7 -3
  117. package/lib/browser-electron/preview-route.js +9 -13
  118. package/lib/browser-electron/process-ownership.js +1 -1
  119. package/lib/browser-electron/profile-command.js +2 -1
  120. package/lib/browser-electron/profile-extension.js +5 -0
  121. package/lib/browser-electron/profile-lease.js +152 -47
  122. package/lib/browser-electron/provider-core.js +527 -0
  123. package/lib/browser-electron/provider-interaction.js +963 -0
  124. package/lib/browser-electron/provider-media.js +518 -0
  125. package/lib/browser-electron/provider-navigation.js +301 -0
  126. package/lib/browser-electron/provider-observation.js +623 -0
  127. package/lib/browser-electron/provider-tabs.js +372 -0
  128. package/lib/browser-electron/provider.js +150 -3301
  129. package/lib/browser-electron/reference-route.js +9 -18
  130. package/lib/browser-electron/remote-host.js +79 -34
  131. package/lib/browser-electron/runtime-status.js +56 -6
  132. package/lib/browser-electron/settings-store.js +3 -6
  133. package/lib/browser-electron/sidebar-only-host.js +1 -1
  134. package/lib/browser-electron/system-browser.js +539 -172
  135. package/lib/browser-electron/tauri-host.js +208 -0
  136. package/lib/browser-electron/virtual-cursor.js +23 -13
  137. package/lib/browser-reference/service.js +22 -4
  138. package/lib/browser-reference/web-sources.js +1 -1
  139. package/lib/client.js +43409 -0
  140. package/lib/compat/host-features.js +75 -0
  141. package/lib/reference-source.js +1 -1
  142. package/lib/reference-text.js +23 -1
  143. package/lib/takeover-protocol.js +1 -1
  144. package/lib/tool-browser/block-recovery.js +69 -0
  145. package/lib/tool-browser/code-tool.js +170 -19
  146. package/lib/tool-browser/code-worker.js +115 -20
  147. package/lib/tool-browser/errors.js +34 -0
  148. package/lib/tool-browser/index.js +66 -3593
  149. package/lib/tool-browser/page-probe.js +227 -28
  150. package/lib/tool-browser/panel-page.js +2 -1
  151. package/lib/tool-browser/probe-client.js +157 -0
  152. package/lib/tool-browser/screenshot-annotations.js +108 -0
  153. package/lib/tool-browser/state.js +337 -0
  154. package/lib/tool-browser/takeover.js +1 -1
  155. package/lib/tool-browser/tools-debug.js +862 -0
  156. package/lib/tool-browser/tools-interaction.js +993 -0
  157. package/lib/tool-browser/tools-navigation.js +807 -0
  158. package/lib/tool-browser/tools-observation.js +461 -0
  159. package/lib/tool-browser/tools-reference.js +293 -0
  160. package/lib/web-guest.js +1 -0
  161. package/package.json +16 -54
  162. package/README.en.md +0 -89
  163. package/browser-extension/constants.mjs +0 -20
  164. package/browser-extension/controller.mjs +0 -293
  165. package/browser-extension/locales.mjs +0 -15
  166. package/browser-extension/manifest.json +0 -12
  167. package/browser-extension/options.html +0 -14
  168. package/browser-extension/options.mjs +0 -9
  169. package/browser-extension/permission-guard.mjs +0 -13
  170. package/browser-extension/worker.mjs +0 -74
  171. package/dist/client.cjs +0 -43167
  172. package/lib/browser-electron/package-removal.js +0 -5
  173. package/lib/browser-reference/submission-receipts.js +0 -139
  174. package/scripts/build.mjs +0 -66
  175. package/scripts/bundle-host.mjs +0 -28
  176. package/scripts/fix-exports.mjs +0 -50
  177. package/scripts/install-electron.mjs +0 -51
  178. package/scripts/verify-exports.mjs +0 -47
  179. package/scripts/verify-preview-sdk.mjs +0 -93
  180. package/skills/dsh-builtin-browser/SKILL.md +0 -73
  181. package/skills/dsh-builtin-browser/references/batch.md +0 -53
  182. package/skills/dsh-builtin-browser/references/deliver.md +0 -31
  183. package/skills/dsh-builtin-browser/references/locate.md +0 -11
  184. package/skills/dsh-builtin-browser/references/recover.md +0 -11
  185. package/skills/dsh-builtin-browser/references/verify.md +0 -13
  186. package/skills/dsh-debug-host/SKILL.md +0 -56
  187. package/skills/dsh-debug-self/SKILL.md +0 -50
  188. package/src/bridge-compatibility.ts +0 -39
  189. package/src/browser/handles.ts +0 -89
  190. package/src/browser/runtime.ts +0 -560
  191. package/src/browser/takeover-target.ts +0 -36
  192. package/src/browser/types.ts +0 -817
  193. package/src/browser-electron/authenticated-route.ts +0 -84
  194. package/src/browser-electron/automatic-maintenance.ts +0 -726
  195. package/src/browser-electron/bridge-auto.ts +0 -159
  196. package/src/browser-electron/bridge-connection.ts +0 -385
  197. package/src/browser-electron/bridge-endpoint.ts +0 -129
  198. package/src/browser-electron/bridge-install.ts +0 -289
  199. package/src/browser-electron/bridge-maintenance.ts +0 -189
  200. package/src/browser-electron/bridge-status.ts +0 -347
  201. package/src/browser-electron/desktop-bridge-host.ts +0 -251
  202. package/src/browser-electron/desktop-identity.ts +0 -320
  203. package/src/browser-electron/document-readiness.ts +0 -45
  204. package/src/browser-electron/electron-provision.ts +0 -261
  205. package/src/browser-electron/entry.ts +0 -1301
  206. package/src/browser-electron/ephemeral-profile.ts +0 -189
  207. package/src/browser-electron/extension-browser.ts +0 -223
  208. package/src/browser-electron/extension-setup.ts +0 -67
  209. package/src/browser-electron/file-write.ts +0 -31
  210. package/src/browser-electron/guest-cookie-jar.ts +0 -176
  211. package/src/browser-electron/guest-cookie-store.ts +0 -59
  212. package/src/browser-electron/guest-css-runtime.ts +0 -76
  213. package/src/browser-electron/guest-css.ts +0 -68
  214. package/src/browser-electron/guest-route.ts +0 -568
  215. package/src/browser-electron/guest-runtime.ts +0 -357
  216. package/src/browser-electron/guest-storage-runtime.ts +0 -54
  217. package/src/browser-electron/guest-storage.ts +0 -117
  218. package/src/browser-electron/history-store.ts +0 -227
  219. package/src/browser-electron/host-main.ts +0 -1381
  220. package/src/browser-electron/host-patch-maintenance.ts +0 -112
  221. package/src/browser-electron/http-body.ts +0 -65
  222. package/src/browser-electron/json-reply.ts +0 -47
  223. package/src/browser-electron/maintenance-broker.ts +0 -166
  224. package/src/browser-electron/maintenance-lifecycle.ts +0 -91
  225. package/src/browser-electron/maintenance-route.ts +0 -67
  226. package/src/browser-electron/missing-system-browser.ts +0 -113
  227. package/src/browser-electron/open-slot.ts +0 -49
  228. package/src/browser-electron/package-removal.ts +0 -4
  229. package/src/browser-electron/paths.ts +0 -25
  230. package/src/browser-electron/preferred-browser.ts +0 -120
  231. package/src/browser-electron/preview-route.ts +0 -218
  232. package/src/browser-electron/process-ownership.ts +0 -168
  233. package/src/browser-electron/process.ts +0 -23
  234. package/src/browser-electron/profile-checkpoint.ts +0 -187
  235. package/src/browser-electron/profile-command.ts +0 -46
  236. package/src/browser-electron/profile-extension.ts +0 -124
  237. package/src/browser-electron/profile-lease.ts +0 -115
  238. package/src/browser-electron/profile-residue.ts +0 -49
  239. package/src/browser-electron/provider.ts +0 -4571
  240. package/src/browser-electron/reference-route.ts +0 -608
  241. package/src/browser-electron/remote-host.ts +0 -1462
  242. package/src/browser-electron/rpc-input.ts +0 -13
  243. package/src/browser-electron/rpc-ops.ts +0 -41
  244. package/src/browser-electron/runtime-diagnostics.ts +0 -38
  245. package/src/browser-electron/runtime-route.ts +0 -105
  246. package/src/browser-electron/runtime-status.ts +0 -242
  247. package/src/browser-electron/settings-route.ts +0 -64
  248. package/src/browser-electron/settings-store.ts +0 -589
  249. package/src/browser-electron/shortcuts-route.ts +0 -112
  250. package/src/browser-electron/sidebar-only-host.ts +0 -298
  251. package/src/browser-electron/startpage-shortcuts.ts +0 -213
  252. package/src/browser-electron/system-browser.ts +0 -1497
  253. package/src/browser-electron/timing.ts +0 -16
  254. package/src/browser-electron/virtual-cursor.ts +0 -152
  255. package/src/browser-electron/windows-system.ts +0 -24
  256. package/src/browser-reference/delivery.ts +0 -384
  257. package/src/browser-reference/entry.ts +0 -631
  258. package/src/browser-reference/export.ts +0 -339
  259. package/src/browser-reference/import.ts +0 -303
  260. package/src/browser-reference/page-script.ts +0 -1537
  261. package/src/browser-reference/service.ts +0 -1315
  262. package/src/browser-reference/store.ts +0 -172
  263. package/src/browser-reference/submission-receipts.ts +0 -122
  264. package/src/browser-reference/text-quote.ts +0 -219
  265. package/src/browser-reference/types.ts +0 -195
  266. package/src/browser-reference/visible.ts +0 -367
  267. package/src/browser-reference/web-sources.ts +0 -103
  268. package/src/client/browser/BrowserController.ts +0 -693
  269. package/src/client/browser/BrowserFrame.ts +0 -78
  270. package/src/client/browser/BrowserNavigation.ts +0 -169
  271. package/src/client/browser/BrowserPage.ts +0 -23
  272. package/src/client/browser/BrowserPersistence.ts +0 -44
  273. package/src/client/browser/IframeImpl.ts +0 -176
  274. package/src/client/browser/child-tabs.ts +0 -14
  275. package/src/client/browser/iframe-reference.ts +0 -67
  276. package/src/client/browser/initialization.ts +0 -262
  277. package/src/client/browser/omnibox.ts +0 -243
  278. package/src/client/browser/store.ts +0 -38
  279. package/src/client/browser/takeover-channel.ts +0 -72
  280. package/src/client/browser/url.ts +0 -46
  281. package/src/client/browser/web-reference-source.ts +0 -52
  282. package/src/client/css-modules.d.ts +0 -4
  283. package/src/client/definition.tsx +0 -30
  284. package/src/client/electron/ElectronWebViewImpl.ts +0 -364
  285. package/src/client/electron/ElectronWebviewPresentation.ts +0 -138
  286. package/src/client/electron/NativeChildPresentation.ts +0 -45
  287. package/src/client/electron/NativeViewPage.ts +0 -251
  288. package/src/client/electron/pages.ts +0 -23
  289. package/src/client/electron/reference-overlay.ts +0 -53
  290. package/src/client/electron/workspace.ts +0 -33
  291. package/src/client/index.ts +0 -293
  292. package/src/client/locales.ts +0 -857
  293. package/src/client/pages.ts +0 -28
  294. package/src/client/reference/client/BrowserRefLink.tsx +0 -142
  295. package/src/client/reference/client/draft-reference.ts +0 -167
  296. package/src/client/reference/client/index.ts +0 -7
  297. package/src/client/reference/client/ordered-submission.ts +0 -108
  298. package/src/client/reference/client/pending-delivery.ts +0 -216
  299. package/src/client/reference/client/plugin.ts +0 -189
  300. package/src/client/reference/client/production/ReferenceCapsules.tsx +0 -345
  301. package/src/client/reference/client/production/ReferenceDock.module.css +0 -193
  302. package/src/client/reference/client/production/ReferenceDock.tsx +0 -6
  303. package/src/client/reference/client/production/ReferenceFeedback.tsx +0 -15
  304. package/src/client/reference/client/production/ReferenceMath.tsx +0 -44
  305. package/src/client/reference/client/production/ReferenceText.tsx +0 -36
  306. package/src/client/reference/client/production/assembly.ts +0 -471
  307. package/src/client/reference/client/production/asset-store.ts +0 -144
  308. package/src/client/reference/client/production/availability.ts +0 -74
  309. package/src/client/reference/client/production/bytes.ts +0 -36
  310. package/src/client/reference/client/production/delivery-client.ts +0 -211
  311. package/src/client/reference/client/production/draft-adapter.ts +0 -508
  312. package/src/client/reference/client/production/http-transport.ts +0 -217
  313. package/src/client/reference/client/production/production-submission.ts +0 -310
  314. package/src/client/reference/client/production/protocol.ts +0 -231
  315. package/src/client/reference/client/production/reference-card.ts +0 -240
  316. package/src/client/reference/client/production/reference-labels.ts +0 -29
  317. package/src/client/reference/client/production/reply-link-bridge.ts +0 -222
  318. package/src/client/reference/client/production/reveal.ts +0 -215
  319. package/src/client/reference/client/production/runtime.ts +0 -1101
  320. package/src/client/reference/client/production/snapshot-adapter.ts +0 -154
  321. package/src/client/reference/client/production/source-marker.ts +0 -63
  322. package/src/client/reference/client/production/source-opener.ts +0 -55
  323. package/src/client/reference/client/production/styles.ts +0 -104
  324. package/src/client/reference/client/production/user-text-rule.ts +0 -58
  325. package/src/client/reference/client/reveal.ts +0 -107
  326. package/src/client/reference/client/scheme.ts +0 -114
  327. package/src/client/reference/client/types.ts +0 -168
  328. package/src/client/reference/css-modules.d.ts +0 -4
  329. package/src/client/reference/index.ts +0 -11
  330. package/src/client/reference-capture-owner.ts +0 -162
  331. package/src/client/reference-intents.ts +0 -36
  332. package/src/client/settings/index.ts +0 -34
  333. package/src/client/settings/panel.ts +0 -2657
  334. package/src/client/shortcut-open.ts +0 -30
  335. package/src/client/startpage/binding.ts +0 -99
  336. package/src/client/startpage/controller.ts +0 -303
  337. package/src/client/startpage/model.ts +0 -279
  338. package/src/client/view/Browser.module.css +0 -751
  339. package/src/client/view/BrowserBody.tsx +0 -314
  340. package/src/client/view/BrowserPresentation.ts +0 -9
  341. package/src/client/view/BrowserTitle.tsx +0 -17
  342. package/src/client/view/IframePresentation.ts +0 -344
  343. package/src/client/view/StartPage.tsx +0 -597
  344. package/src/client/view/TakeoverBanner.tsx +0 -21
  345. package/src/index.ts +0 -110
  346. package/src/reference-owner.ts +0 -5
  347. package/src/reference-page.ts +0 -9
  348. package/src/reference-source.ts +0 -3
  349. package/src/reference-text.ts +0 -197
  350. package/src/startpage-settings.ts +0 -103
  351. package/src/startpage.ts +0 -71
  352. package/src/takeover-protocol.ts +0 -19
  353. package/src/tool-browser/code-tool.ts +0 -401
  354. package/src/tool-browser/code-worker.ts +0 -639
  355. package/src/tool-browser/element-fields.ts +0 -167
  356. package/src/tool-browser/index.ts +0 -3733
  357. package/src/tool-browser/page-probe.ts +0 -474
  358. package/src/tool-browser/panel-page.ts +0 -124
  359. package/src/tool-browser/screenshot-image.ts +0 -49
  360. package/src/tool-browser/takeover.ts +0 -198
  361. package/src/types/electron-shim.d.ts +0 -144
  362. package/src/types.ts +0 -85
  363. package/src/web-guest.ts +0 -34
  364. package/tools/accept-desktop.mjs +0 -148
@@ -1,13 +0,0 @@
1
- import type { Socket } from 'node:net'
2
- import { createInterface, type Interface } from 'node:readline'
3
-
4
- /** Read RPC lines while keeping transport errors owned by the socket. */
5
- export function createRpcLineReader(socket: Socket, onError: (error: Error) => void): Interface {
6
- socket.on('error', onError)
7
- const reader = createInterface({ input: socket })
8
- // readline forwards input errors as its own 'error' event. The socket
9
- // listener above already reports that same error; receive the forwarded
10
- // event too so a transport failure does not become uncaughtException.
11
- reader.on('error', () => {})
12
- return reader
13
- }
@@ -1,41 +0,0 @@
1
- /**
2
- * The RPC operation vocabulary, in one place.
3
- *
4
- * The child (`host-main.ts`) switches on these names and the parent (`remote-host.ts`) sends
5
- * them. Both spelled them out independently and nothing connected the two, so a rename on one
6
- * side compiled fine and failed at run time as "unknown op" — and this pair has already
7
- * produced one silent failure of that shape (`noteStartFailure`'s dedupe comparison, which was
8
- * never true and meant a log line that never appeared).
9
- *
10
- * The lists are the source of truth for a test that reads both switch statements and asserts
11
- * they agree, which is what makes a one-sided rename fail loudly instead of at run time.
12
- */
13
-
14
- /** Operations the parent asks the child to perform. */
15
- export const RPC_OPS = [
16
- 'ping',
17
- 'createView',
18
- 'destroyView',
19
- 'showView',
20
- 'groupView',
21
- 'focus',
22
- 'command',
23
- 'capture',
24
- 'download',
25
- 'flushAuth',
26
- 'restoreAuth',
27
- 'navigate',
28
- 'new-tab',
29
- 'activate',
30
- 'close',
31
- 'back',
32
- 'forward',
33
- 'reload',
34
- 'userActionError',
35
- ] as const
36
-
37
- /** Notifications the child sends the parent, which carry no reply. */
38
- export const RPC_NOTIFICATIONS = ['userAction', 'viewClosed'] as const
39
-
40
- /** One operation name. */
41
- export type RpcOp = (typeof RPC_OPS)[number]
@@ -1,38 +0,0 @@
1
- /** Versions reported by the running child, never inferred from an npm package or path. */
2
- interface RuntimeVersions {
3
- readonly electron?: string
4
- readonly chrome?: string
5
- readonly node?: string
6
- }
7
-
8
- /**
9
- * Startup diagnostics only: an explicit runtime remains the user's choice.
10
- * Keep this pure so availability checks never spawn Electron or download it.
11
- */
12
- export function electronRuntimeDiagnosticLines(
13
- versions: RuntimeVersions,
14
- stamp = new Date().toISOString(),
15
- ): string[] {
16
- const electron = versions.electron?.trim() || 'unknown'
17
- const lines = [
18
- `${stamp} runtime: electron=${electron} chromium=${versions.chrome?.trim() || 'unknown'} node=${versions.node?.trim() || 'unknown'}`,
19
- ]
20
- const parsed = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/.exec(electron)
21
- const continuing = 'continuing with the selected runtime. Update its installation, or change/remove ELECTRON_PATH if that override selects it.'
22
- if (parsed === null || Number(parsed[1]) !== 44) {
23
- // Other maintained branches can be patched for the advisory below. An
24
- // untested major is a compatibility warning, not a vulnerability claim.
25
- lines.push(`${stamp} warning: Electron ${electron} is not verified for this plugin; expected stable Electron 44.x >=44.9.1; ${continuing}`)
26
- return lines
27
- }
28
- const minor = Number(parsed[2])
29
- const patch = Number(parsed[3])
30
- const prerelease = parsed[4] !== undefined
31
- // A prerelease of 44.9.1 sorts before the patched stable release.
32
- if (minor < 9 || (minor === 9 && (patch < 1 || (patch === 1 && prerelease)))) {
33
- lines.push(`${stamp} warning: Electron ${electron} is below the 44.x security minimum 44.9.1 (GHSA-jr5w-w6x2-84p9); ${continuing}`)
34
- } else if (prerelease) {
35
- lines.push(`${stamp} warning: Electron ${electron} is a prerelease and is not verified for this plugin; expected stable Electron 44.x >=44.9.1; ${continuing}`)
36
- }
37
- return lines
38
- }
@@ -1,105 +0,0 @@
1
- import { RUNTIME_STATUS_ROUTE, RUNTIME_PROVISION_ROUTE } from '../../assets/browser-policy.mjs'
2
- /**
3
- * The readiness endpoints the settings panel reads.
4
- *
5
- * The host authenticates both routes with its signed browser-session cookie. The read returns
6
- * readiness, while a POST starts runtime preparation and also passes the settings write-origin
7
- * checks.
8
- *
9
- * Both answer with the whole report rather than a delta: the panel replaces what it shows with what
10
- * it is told, so a stale poll can never leave a wrong state on screen.
11
- * @module dsh-browser/browser-electron/runtime-route
12
- */
13
- import type { IncomingMessage, ServerResponse } from 'node:http'
14
- import type { ProvisionSnapshot } from './electron-provision.ts'
15
- import { replyJson } from './json-reply.ts'
16
- import { sameOrigin } from './settings-route.ts'
17
- import type { RuntimeStatusReport } from './runtime-status.ts'
18
-
19
- /** Where the panel reads readiness. */
20
- export { RUNTIME_STATUS_ROUTE }
21
-
22
- /**
23
- * Where the panel asks for the bundled runtime.
24
- *
25
- * Non-blocking by design: it starts (or joins) the one background attempt and answers immediately
26
- * with the state that attempt is in, which is `preparing`. A request that waited for the download
27
- * would time out in the browser long before a slow network finished, and would hold a connection
28
- * open for something the panel can poll instead.
29
- */
30
- export { RUNTIME_PROVISION_ROUTE }
31
-
32
- /** What both handlers need. */
33
- export interface RuntimeRouteDeps {
34
- /** The current report; a cheap read, never a spawn. */
35
- readonly report: () => RuntimeStatusReport | Promise<RuntimeStatusReport>
36
- /**
37
- * Start (or join) a provision and return the state it is in now.
38
- *
39
- * Must not throw: a failure belongs in the report as a 200 with a `failed` state, because a user
40
- * looking at a panel needs to read the reason, not an HTTP status.
41
- */
42
- readonly provision: () => ProvisionSnapshot
43
- }
44
-
45
- /**
46
- * Read readiness: `{ ok, runtime }`.
47
- * @param request - the incoming request.
48
- * @param response - the response to write.
49
- * @param deps - the readers.
50
- */
51
- export async function handleRuntimeStatus(
52
- request: IncomingMessage,
53
- response: ServerResponse,
54
- deps: RuntimeRouteDeps,
55
- ): Promise<void> {
56
- if (request.method !== 'GET') {
57
- replyJson(response, 405, { error: 'method-not-allowed' })
58
- return
59
- }
60
- if (!sameOrigin(request)) {
61
- replyJson(response, 403, { error: 'not-same-origin' })
62
- return
63
- }
64
- replyJson(response, 200, { ok: true, runtime: await deps.report() })
65
- }
66
-
67
- /**
68
- * Start (or join) a provision, then answer with the state it is in.
69
- *
70
- * Always 200 once admitted, whatever happened: the state carries `failed` with its reason, and a
71
- * panel that had to distinguish 4xx from 5xx to say "the download failed" would show a network
72
- * error where the user needs the sentence explaining it.
73
- * @param request - the incoming request.
74
- * @param response - the response to write.
75
- * @param deps - the readers.
76
- */
77
- export async function handleRuntimeProvision(
78
- request: IncomingMessage,
79
- response: ServerResponse,
80
- deps: RuntimeRouteDeps,
81
- ): Promise<void> {
82
- if (request.method !== 'POST') {
83
- replyJson(response, 405, { error: 'method-not-allowed' })
84
- return
85
- }
86
- // `true`: starting a download is a write, and is admitted the way a settings write is.
87
- if (!sameOrigin(request, true)) {
88
- replyJson(response, 403, { error: 'not-same-origin' })
89
- return
90
- }
91
- let snapshot: ProvisionSnapshot
92
- try {
93
- snapshot = deps.provision()
94
- } catch (error) {
95
- // `provision` is documented not to throw; if a caller breaks that contract the panel still gets
96
- // an answer it can render, rather than a dropped connection it cannot tell from a hang.
97
- replyJson(response, 200, {
98
- ok: true,
99
- runtime: await deps.report(),
100
- provisionError: String(error),
101
- })
102
- return
103
- }
104
- replyJson(response, 200, { ok: true, runtime: await deps.report(), provision: snapshot })
105
- }
@@ -1,242 +0,0 @@
1
- /**
2
- * One answer to "can I use the browser right now", assembled from the three things that decide it.
3
- *
4
- * WHY THIS EXISTS
5
- * Installing this plugin made the browser work with no setup, and that property got silently
6
- * weaker as the carriers were added: the bundled carrier downloads a ~100 MB Electron runtime on
7
- * first need (issue #41 — the download had to leave `postinstall`), so on a fresh install the first
8
- * browser call can arrive while that download is still running, and the only trace anywhere in the
9
- * product was a log line the settings panel cannot read. A user who saw "cannot locate a spawnable
10
- * Electron binary" had no way to learn that the plugin was already fetching one, and no button to
11
- * retry it once it failed.
12
- *
13
- * So the readiness of each part is computed ONCE here, in a pure function over injectable readers:
14
- * the settings panel renders it, and a test drives it without touching Electron, a desktop install
15
- * or the file system.
16
- *
17
- * Everything here is a cheap environment check. The launch path's own binary probes resolve the
18
- * bundled runtime and installed system browsers; bridge readers inspect the installation and its
19
- * published endpoint. Available files establish availability, while browser calls establish whether
20
- * a particular page can be driven. Nothing spawns anything.
21
- * @module dsh-browser/browser-electron/runtime-status
22
- */
23
- import type { BridgeStatus } from './bridge-status.ts'
24
- import type { BridgeEndpointState } from './bridge-endpoint.ts'
25
- import type { ProvisionSnapshot } from './electron-provision.ts'
26
- import type { ExtensionConnectionStatus } from '../../native-host/client.mjs'
27
- import type { extensionInstallHelp } from './extension-browser.ts'
28
- import { detectBrowser, type BrowserChannel, type DetectedBrowser, type SystemBrowserLaunchDiagnostic } from './system-browser.ts'
29
-
30
- /** The part of the carrier the channel names, in the terms the panel has to explain. */
31
- export type CarrierKind = 'sidebar' | 'bundled' | 'system' | 'extension' | 'cdp' | 'auto'
32
-
33
- /** Whether the chosen carrier's required files or running bridge are available. */
34
- export type Readiness = 'ready' | 'blocked'
35
-
36
- /** The system-browser discovery result, obtained without launching an executable. */
37
- export interface SystemBrowserReadiness {
38
- readonly launch?: SystemBrowserLaunchDiagnostic
39
- /** False for channels that use the sidebar or bundled runtime directly. */
40
- readonly checked: boolean
41
- readonly present: boolean
42
- readonly kind?: DetectedBrowser['kind']
43
- readonly path?: string
44
- /** What was found or which configured product is missing. */
45
- readonly detail: string
46
- }
47
-
48
- /** The Electron runtime's state, as the panel needs it. */
49
- export interface ElectronReadiness {
50
- /** `present` — a launch would find a binary; `preparing` — a download is running now; and so on. */
51
- readonly state: ProvisionSnapshot['state']
52
- /** One line, already user-facing: the provisioning module's own words. */
53
- readonly detail: string
54
- /** When that state was reached, ISO. */
55
- readonly at: string
56
- }
57
-
58
- /** The desktop sidebar bridge, or the honest "there is no desktop here" shape. */
59
- export interface BridgeReadiness {
60
- readonly mainExtension?: BridgeStatus['mainExtension']
61
- readonly code?: string
62
- /** Whether a DSH Desktop install was found at all. */
63
- readonly present: boolean
64
- /** `absent` is reported separately from `missing`: nothing to repair versus something to repair. */
65
- readonly state: BridgeStatus['state'] | 'absent'
66
- /** The plugin's own words about the install tree. */
67
- readonly detail: string
68
- /**
69
- * Whether a shell is RUNNING and answering, as opposed to merely installed.
70
- *
71
- * Install-tree state survives a reboot and says nothing about a process; the published endpoint is
72
- * the only thing that does. Reporting "installed" as "ready" is how a panel goes green while every
73
- * call dials a port nobody owns — the desktop app being closed is the most common broken state
74
- * there is.
75
- */
76
- readonly running: boolean
77
- /** The plugin's own words about the running shell (or about why there is none). */
78
- readonly runningDetail: string
79
- /** The command that installs or repairs it, for a human to run. Never run by the plugin. */
80
- readonly command?: string
81
- }
82
-
83
- /** The whole report. */
84
- export interface RuntimeStatusReport {
85
- readonly nativeHostRegistration?: Record<string, { registered: boolean; detail: string }>
86
- readonly controlledProfile: 'plugin' | 'user' | 'sidebar'
87
- readonly extension?: ExtensionConnectionStatus & { readonly install?: ReturnType<typeof extensionInstallHelp>; readonly registration?: { registered: boolean; detail: string } }
88
- readonly fallbackReason?: string
89
- /** What the settings document says, verbatim: the panel shows the switch it is honouring. */
90
- readonly channel: BrowserChannel
91
- /** What that channel resolves to, in panel terms. */
92
- readonly carrier: CarrierKind
93
- /** The concrete carrier selected by the same discovery priority as the browser provider. */
94
- readonly resolvedCarrier: Exclude<CarrierKind, 'auto'>
95
- /** Whether the carrier's environment requirements are available. */
96
- readonly readiness: Readiness
97
- readonly systemBrowser: SystemBrowserReadiness
98
- /** The system executable selected for the resolved carrier, when applicable. */
99
- readonly executable?: string
100
- readonly electron: ElectronReadiness
101
- readonly bridge: BridgeReadiness
102
- /** Whether "Prepare the bundled browser" is worth offering (it is not while one is running). */
103
- readonly canProvision: boolean
104
- }
105
-
106
- /** Everything the report reads, so a test can answer without any of the real machinery. */
107
- export interface RuntimeStatusDeps {
108
- readonly nativeHostRegistration?: () => NonNullable<RuntimeStatusReport['nativeHostRegistration']>
109
- readonly fallbackReason?: () => string | undefined
110
- readonly systemProfile?: () => 'user' | 'plugin'
111
- readonly extensionConnection?: () => RuntimeStatusReport['extension']
112
- /** The stored `browser.channel`. */
113
- readonly channel: () => BrowserChannel
114
- /** Whether a launch would find an Electron binary — the launch path's own probe. */
115
- readonly hasBinary: () => boolean
116
- /** The provisioning state machine's current state. */
117
- readonly provision: () => ProvisionSnapshot
118
- /** The desktop install's bridge state, or undefined when there is no desktop install. */
119
- readonly bridge: () => BridgeStatus | undefined
120
- readonly bridgeError?: () => string | undefined
121
- /** The endpoint the shell publishes while it runs; undefined when nothing published one. */
122
- readonly endpoint: () => BridgeEndpointState | undefined
123
- /** The launch path's filesystem-only browser discovery; defaults to the production reader. */
124
- readonly detectBrowser?: (channel: BrowserChannel) => DetectedBrowser | undefined
125
- /** The provider's current carrier, including a fallback selected after sidebar loss. */
126
- readonly selectedCarrier?: () => Exclude<CarrierKind, 'auto'> | undefined
127
- readonly systemConnection?: () => { connected: boolean; detail: string; launch?: SystemBrowserLaunchDiagnostic } | undefined
128
- }
129
-
130
- /** Which carrier a channel names. */
131
- function carrierOf(channel: BrowserChannel): CarrierKind {
132
- return channel === 'chrome' || channel === 'edge' ? 'system' : 'sidebar'
133
- }
134
-
135
- /**
136
- * Assemble the report.
137
- *
138
- * The `readiness` field is per carrier on purpose: "the browser is ready" is not a property of this
139
- * plugin, it is a property of the carrier the user chose. A bundled carrier with a finished download
140
- * is ready; the sidebar carrier with no bridge is not, however healthy the bundled runtime is.
141
- * @param deps - the readers; every one of them is a cheap, side-effect-free read.
142
- * @returns the report the panel renders.
143
- */
144
- export function readRuntimeStatus(deps: RuntimeStatusDeps): RuntimeStatusReport {
145
- const channel = deps.channel()
146
- const preferExtension = (channel === 'edge' || channel === 'chrome') && deps.systemProfile?.() === 'user'
147
- const carrier = preferExtension ? 'extension' : carrierOf(channel)
148
- const extension = carrier === 'extension' ? deps.extensionConnection?.() ?? {
149
- state: 'extension-missing' as const, connected: false, browser: channel as 'edge' | 'chrome', detail: 'Optional extension is not connected; managed CDP is available as fallback.',
150
- } : undefined
151
-
152
- // The binary check comes first and wins: a runtime that is on disk is ready whatever the
153
- // provisioning state machine last said, which is also how a runtime installed by hand (or by an
154
- // earlier process) is reported correctly without a restart. The DETAIL has to follow the same
155
- // rule, or the panel shows "present" next to "the runtime has not been asked for yet" — measured
156
- // on a live install, and the kind of contradiction a reader cannot resolve.
157
- const snapshot = deps.provision()
158
- const runnable = deps.hasBinary()
159
- const missingAfterReady = !runnable && (snapshot.state === 'present' || snapshot.state === 'ready')
160
- const state: ElectronReadiness['state'] = runnable ? 'present' : missingAfterReady ? 'failed' : snapshot.state
161
- const electron: ElectronReadiness = {
162
- state,
163
- detail: runnable ? 'an Electron runtime is already available'
164
- : missingAfterReady ? 'the previously prepared Electron runtime is missing; prepare it again' : snapshot.detail,
165
- at: runnable ? new Date().toISOString() : snapshot.at,
166
- }
167
-
168
- const bridgeStatus = deps.bridge()
169
- const endpoint = deps.endpoint()
170
- const installedBridge: BridgeReadiness = bridgeStatus === undefined
171
- ? {
172
- present: false,
173
- state: 'absent',
174
- detail: 'no DSH Desktop install was found on this machine',
175
- running: endpoint?.alive === true,
176
- runningDetail: endpoint?.detail ?? 'no desktop shell has published a bridge endpoint',
177
- }
178
- : {
179
- present: bridgeStatus.present,
180
- state: bridgeStatus.state,
181
- detail: bridgeStatus.detail,
182
- running: endpoint?.alive === true,
183
- runningDetail: endpoint?.detail ?? 'no desktop shell has published a bridge endpoint',
184
- ...bridgeStatus.command === undefined ? {} : { command: bridgeStatus.command },
185
- ...bridgeStatus.mainExtension === undefined ? {} : { mainExtension: bridgeStatus.mainExtension },
186
- ...bridgeStatus.code === undefined ? {} : { code: bridgeStatus.code },
187
- }
188
-
189
- const bridgeError = deps.bridgeError?.()
190
- const bridge: BridgeReadiness = bridgeError === undefined ? installedBridge
191
- : { ...installedBridge, state: 'stale', detail: bridgeError }
192
-
193
- // The sidebar needs BOTH halves: our patch inside the shell it will be driven through, and that
194
- // shell actually running. Either one alone is the false green this report exists to prevent.
195
- const sidebarReady = bridge.state === 'installed' && bridge.running
196
-
197
- const selected = preferExtension ? deps.selectedCarrier?.() ?? (extension?.connected ? 'extension' : 'cdp') : undefined
198
- const checkSystemBrowser = carrier === 'system' || selected === 'cdp'
199
- const detected = checkSystemBrowser ? (deps.detectBrowser ?? detectBrowser)(channel) : undefined
200
- const connection = checkSystemBrowser ? deps.systemConnection?.() : undefined
201
- const systemBrowser: SystemBrowserReadiness = {
202
- ...connection?.launch === undefined ? {} : { launch: connection.launch },
203
- checked: checkSystemBrowser,
204
- present: detected !== undefined,
205
- ...detected === undefined ? {} : { kind: detected.kind, path: detected.path },
206
- detail: detected !== undefined ? connection?.detail ?? 'Browser has not launched; run a browser command to establish CDP. No live CDP connection.'
207
- : !checkSystemBrowser ? `the ${carrier} channel uses its own carrier`
208
- : `the selected ${channel} installation was not found`,
209
- }
210
-
211
- let readiness: Readiness
212
- let resolvedCarrier: RuntimeStatusReport['resolvedCarrier']
213
- if (carrier === 'sidebar') {
214
- resolvedCarrier = 'sidebar'
215
- readiness = sidebarReady ? 'ready' : 'blocked'
216
- } else if (selected === 'cdp') {
217
- resolvedCarrier = 'cdp'
218
- readiness = detected !== undefined && connection?.connected === true ? 'ready' : 'blocked'
219
- } else if (carrier === 'extension') {
220
- resolvedCarrier = 'extension'
221
- readiness = extension?.state === 'connected' && extension.connected ? 'ready' : 'blocked'
222
- } else {
223
- resolvedCarrier = 'system'
224
- readiness = detected !== undefined && connection?.connected === true ? 'ready' : 'blocked'
225
- }
226
-
227
- return {
228
- ...deps.nativeHostRegistration ? { nativeHostRegistration: deps.nativeHostRegistration() } : {},
229
- controlledProfile: resolvedCarrier === 'extension' ? 'user' : resolvedCarrier === 'system' || resolvedCarrier === 'cdp' ? 'plugin' : 'sidebar',
230
- ...(preferExtension && resolvedCarrier === 'cdp' ? { fallbackReason: deps.fallbackReason?.() ?? (extension?.state === 'disabled' ? 'disabled' : 'not-connected') } : {}),
231
- ...extension === undefined ? {} : { extension },
232
- channel,
233
- carrier,
234
- resolvedCarrier,
235
- readiness,
236
- systemBrowser,
237
- ...resolvedCarrier === 'system' && detected !== undefined ? { executable: detected.path } : {},
238
- electron,
239
- bridge,
240
- canProvision: false,
241
- }
242
- }
@@ -1,64 +0,0 @@
1
- /**
2
- * Browser-origin checks used after DSH authenticates each plugin HTTP request.
3
- * Desktop protocol forwarding supplies the host session cookie while Chromium may omit Origin
4
- * and Referer for the custom application scheme. These checks preserve that request shape and
5
- * reject browser requests that explicitly name another web origin.
6
- * @module dsh-browser/browser-electron/settings-route
7
- */
8
- import type { IncomingMessage } from 'node:http'
9
-
10
- /** The shell's own URL schemes. Only the shell can mint a document on one of these. */
11
- const APP_SCHEMES = ['dsh-app:', 'dsh-desktop:']
12
-
13
- /**
14
- * The scheme of a header value, when it names a URL.
15
- * @param value - a raw header value.
16
- * @returns the scheme, or undefined when the value is absent, opaque or unparseable.
17
- */
18
- function schemeOf(value: string): string | undefined {
19
- if (value === '' || value === 'null') return undefined
20
- try {
21
- return new URL(value).protocol
22
- } catch {
23
- return undefined
24
- }
25
- }
26
-
27
- /**
28
- * Whether a request may touch the settings document.
29
- * @param request - the incoming request.
30
- * @param writing - true for PUT/POST, which is held to the stricter rule.
31
- * @returns whether the request is admitted.
32
- */
33
- export function sameOrigin(request: IncomingMessage, writing = false): boolean {
34
- const origin = String(request.headers.origin ?? '').trim()
35
- const site = String(request.headers['sec-fetch-site'] ?? '').toLowerCase()
36
-
37
- // A shell URL, in either the Origin or the referrer: the strongest evidence there is.
38
- if (APP_SCHEMES.includes(schemeOf(origin) ?? '')) return true
39
- if (APP_SCHEMES.includes(schemeOf(String(request.headers.referer ?? '')) ?? '')) return true
40
-
41
- // Desktop custom-scheme requests can omit browser origin metadata. The route's host-cookie
42
- // gate has already authenticated them; the renderer headers retain compatibility with older
43
- // shells that omit Origin while forwarding settings writes.
44
- if (origin === '') {
45
- const agent = String(request.headers['user-agent'] ?? '')
46
- const language = String(request.headers['accept-language'] ?? '')
47
- if (/^Mozilla\/5\.0/.test(agent) && language !== '') return true
48
- // A missing Origin is valid for reads after the host-cookie gate has admitted the caller.
49
- return !writing
50
- }
51
-
52
- // `cross-site` is another origin entirely; `same-site` is another origin of the same site
53
- // (a.example.com -> b.example.com), which is not this panel either. Both are refused.
54
- if (site === 'cross-site' || site === 'same-site') return false
55
- // `Origin: null` is a sandboxed or opaque-origin document. Never this panel.
56
- if (origin === 'null') return false
57
- try {
58
- const parsed = new URL(origin)
59
- // The host comparison is for http(s), where a page and its route share one host.
60
- return parsed.host.toLowerCase() === String(request.headers.host ?? '').trim().toLowerCase()
61
- } catch {
62
- return false
63
- }
64
- }