- authenticated WebSocket link (dependency-free RFC6455 + stream mux), pairing codes, per-device keys (hashed), revoke/remove - /r/<device>/ proxy of the full DSH UI (HTTP, Remote WebSocket, SSE) with per-device cookie minting; slave->slave relay through the master - Devices sidebar panel (all devices' sessions, new session on device), Remote devices settings page, finished-session toasts - plugin + config sync master->slave: registry bundles via pluginManager, link: plugins as tarballs, cordis.patch.yml into a managed bundle layer (!!js preserved), allow/deny, opt-in per-secret credential sync - deploy helpers + e2e probes, unit tests
29 lines
1.4 KiB
JavaScript
29 lines
1.4 KiB
JavaScript
#!/usr/bin/env node
|
|
// E2E probe: open the DSH Remote stream WebSocket of a device THROUGH the local
|
|
// /r/<device>/api/remote.mux proxy and check that the remote DSH answers.
|
|
// node deploy/e2e-ws.mjs <device> [port]
|
|
import fs from 'node:fs'
|
|
import os from 'node:os'
|
|
import path from 'node:path'
|
|
import { connect } from '../lib/ws.mjs'
|
|
import { mintCookie } from '../lib/auth-cookie.mjs'
|
|
|
|
const device = process.argv[2] || 'ai-pc'
|
|
const port = process.argv[3] || process.env.DSH_PORT || '3081'
|
|
const home = process.env.DSH_HOME || path.join(os.homedir(), '.dsh')
|
|
const secret = fs.readFileSync(path.join(home, '.credentials.yaml'), 'utf8').match(/browser-session:[\s\S]*?secret:\s*([A-Za-z0-9_-]{43})/)[1]
|
|
const authority = `127.0.0.1:${port}`
|
|
const cookie = mintCookie(authority, secret, 1)
|
|
const t0 = Date.now()
|
|
const ws = await connect(`ws://${authority}/r/${device}/api/remote.mux`, { headers: { cookie, origin: `http://${authority}` } })
|
|
console.log(`ws open through /r/${device}/ in ${Date.now() - t0} ms`)
|
|
const got = await new Promise((resolve) => {
|
|
const timer = setTimeout(() => resolve('(no frame within 4s: connection stays open, server waits for client frames)'), 4000)
|
|
ws.on('message', (m) => { clearTimeout(timer); resolve(`first frame: ${String(m).slice(0, 160)}`) })
|
|
ws.on('close', (c, r) => { clearTimeout(timer); resolve(`closed ${c} ${r}`) })
|
|
})
|
|
console.log(got)
|
|
console.log(`still open: ${ws.open}`)
|
|
ws.close()
|
|
process.exit(0)
|