@yuriai/web 0.3.2-beta.10 → 0.3.2-beta.12
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.
- package/dist/assets/{AgentAvatar-x96Bnfsu.js → AgentAvatar-BJffjMB2.js} +1 -1
- package/dist/assets/{AssistantConversationSurface-Fb-zSPo9.js → AssistantConversationSurface--yxDjnQu.js} +3 -3
- package/dist/assets/{AssistantSessionCard-CoCLydJP.js → AssistantSessionCard-DdPqL_g8.js} +2 -2
- package/dist/assets/{AssistantUnreadBadge-rZCi09a_.js → AssistantUnreadBadge-DM_fwozo.js} +1 -1
- package/dist/assets/{AssistantView-swsUejpX.js → AssistantView-dUWmrucP.js} +1 -1
- package/dist/assets/{DiagramView-CLS0pLZO.js → DiagramView-CpoBNbaR.js} +1 -1
- package/dist/assets/{FadeInOnReveal-CI-IPVEK.js → FadeInOnReveal-CJqre5kV.js} +1 -1
- package/dist/assets/{GuiPluginPage-CAJB88Hr.js → GuiPluginPage-CM-Sop6a.js} +1 -1
- package/dist/assets/{GuiPluginSurface-BS2r8oXR.js → GuiPluginSurface-CAN_zgP3.js} +1 -1
- package/dist/assets/{GuiPluginWindow-FOzqLIZ3.js → GuiPluginWindow-unA50cUu.js} +1 -1
- package/dist/assets/{Icon-DmIDd0Q3.js → Icon-DSX7wjSw.js} +1 -1
- package/dist/assets/{ImageLoadingPlaceholder-trn5U_et.js → ImageLoadingPlaceholder-PLO0B9my.js} +1 -1
- package/dist/assets/{LoadingImage-C4d5T4hV.js → LoadingImage-BAUw--5b.js} +1 -1
- package/dist/assets/{MarkdownRenderer-BVwZ1pA4.js → MarkdownRenderer-C-hlqlA0.js} +2 -2
- package/dist/assets/{MarkdownRendererImpl-DS0zWiLN.js → MarkdownRendererImpl-CA9zIauD.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-jAsInIUo.js → MarkstreamRendererImpl-CwsjUaGC.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-C5cGr0_z.js → MobileDetailNavigation-FfSrd8rW.js} +1 -1
- package/dist/assets/{MobileResizableSheet-C1mMUPUi.js → MobileResizableSheet-_VhodKQ3.js} +1 -1
- package/dist/assets/{MobileShareBridge-WMVB0JDL.js → MobileShareBridge-DtCqMWXT.js} +1 -1
- package/dist/assets/{MobileSurface-DvKk_z56.js → MobileSurface-34aws7qB.js} +1 -1
- package/dist/assets/{MultiRunWindow-sY6Pm1xj.js → MultiRunWindow-DCCjgHNE.js} +1 -1
- package/dist/assets/{OnboardingScreen-BklzeM5-.js → OnboardingScreen-D7YC-sBK.js} +1 -1
- package/dist/assets/{OverlayScrollbar-CCiU1O4G.js → OverlayScrollbar-Ce9Mr4_V.js} +1 -1
- package/dist/assets/{RemoteAssistantSessionCard-B51iN77P.js → RemoteAssistantSessionCard-Csb19vol.js} +1 -1
- package/dist/assets/{SettingsView-DIjOyLKA.js → SettingsView-BF-DV5jC.js} +1 -1
- package/dist/assets/{SettingsWindow-CImW4cF3.js → SettingsWindow-BGec9rhJ.js} +1 -1
- package/dist/assets/{SetupTourDialog-BKQ3z7Y2.js → SetupTourDialog-Du963bwh.js} +1 -1
- package/dist/assets/{TerminalView-B2vccUH6.js → TerminalView-BLmis6W4.js} +1 -1
- package/dist/assets/{ToolOutputDialog-Ce0eoysA.js → ToolOutputDialog-D5vUeeCg.js} +1 -1
- package/dist/assets/{VoiceSettings-GiwhoPor.js → VoiceSettings-Cz4DTeu1.js} +1 -1
- package/dist/assets/{YuriLogo-DNvrroBa.js → YuriLogo-BKdnDJwl.js} +1 -1
- package/dist/assets/{YuriWordmark-bJX68f2Y.js → YuriWordmark-jFHGvbDP.js} +1 -1
- package/dist/assets/{assistant-attachment-cache-zu9sz4ex.js → assistant-attachment-cache-BYvIyn1x.js} +1 -1
- package/dist/assets/{capgoAdapter-CDggXiqU.js → capgoAdapter-vcXrgtcl.js} +1 -1
- package/dist/assets/{checkbox-1rYH2bTD.js → checkbox-lnltTd4O.js} +1 -1
- package/dist/assets/{client-CgAFd1ew.js → client-BsLh14yh.js} +1 -1
- package/dist/assets/{collapsible-c8Ibgdp0.js → collapsible-B3_mc5eD.js} +1 -1
- package/dist/assets/{context-menu-BImF2R_w.js → context-menu-CeBwB9rZ.js} +1 -1
- package/dist/assets/{desktopHosts-135cuRCE.js → desktopHosts-BsTrBVja.js} +1 -1
- package/dist/assets/{desktopRelayRestore-1aUztDPU.js → desktopRelayRestore-BxbRKak_.js} +1 -1
- package/dist/assets/{device-C8ZHblkr.js → device-BlmHHWT1.js} +1 -1
- package/dist/assets/{diagram-DgoUJTH7.js → diagram-DUBp-_Yd.js} +1 -1
- package/dist/assets/{dialog-BC7o8gDY.js → dialog-f0jnPiqM.js} +1 -1
- package/dist/assets/{fileMentionTouchSelection-C4Bcy0x9.js → fileMentionTouchSelection-D5yvbxbi.js} +1 -1
- package/dist/assets/{fileReferenceActions-DX-Stroq.js → fileReferenceActions-DLTUzjwi.js} +1 -1
- package/dist/assets/{gitApi-v_nr2noV.js → gitApi-BMcLfk7G.js} +1 -1
- package/dist/assets/{gitApiHttp-BEMPJCIG.js → gitApiHttp-Dk5fNrOy.js} +1 -1
- package/dist/assets/{gui-BMN3-WPc.js → gui-KxRdG4j0.js} +1 -1
- package/dist/assets/{historyImportQueries-eR7Bj6VN.js → historyImportQueries-DiGQ8duS.js} +1 -1
- package/dist/assets/{host-iM7aLAip.js → host-BBp7NPZz.js} +1 -1
- package/dist/assets/{i18n-OsFhnlRH.js → i18n-BvjeIWrT.js} +1 -1
- package/dist/assets/{image-loading-ZB1bYt51.js → image-loading-Dlh4FIPJ.js} +1 -1
- package/dist/assets/{input-Be95umzN.js → input-CTFR9La6.js} +1 -1
- package/dist/assets/{input-store-DRTu4uZc.js → input-store-wWToFdzi.js} +1 -1
- package/dist/assets/{insertionBoundaries-B6Qmm9AF.js → insertionBoundaries-CVbCae7y.js} +1 -1
- package/dist/assets/main-BJ6CmPDc.js +169 -0
- package/dist/assets/{main-B_c29S7v.js → main-CUu7EunU.js} +2 -2
- package/dist/assets/{markdownHeightCache-DRCM6uIv.js → markdownHeightCache-BXL8JbYG.js} +1 -1
- package/dist/assets/{mcpQueries-ar057Rgj.js → mcpQueries-CvgW0Bl6.js} +1 -1
- package/dist/assets/miniChat-J9pxSQyx.js +2 -0
- package/dist/assets/mobile-DYjeIixi.js +2 -0
- package/dist/assets/{mobileBackNavigation-D5OGRKSr.js → mobileBackNavigation-hjJm8naw.js} +1 -1
- package/dist/assets/{mobileConnections-ha4M0S0e.js → mobileConnections-BEr-iBDA.js} +2 -2
- package/dist/assets/{multirun-_MbBN5TJ.js → multirun-CntRJAjm.js} +1 -1
- package/dist/assets/{native-config-nNPVev0-.js → native-config-DdAtv91r.js} +1 -1
- package/dist/assets/{navigation-DcR3_z8w.js → navigation-XRMYLkiK.js} +2 -2
- package/dist/assets/{openRemoteProjectSession-b-2cofYh.js → openRemoteProjectSession-C9_o5Yvr.js} +1 -1
- package/dist/assets/{platform-wF65ZFgV.js → platform-CiUKDeXd.js} +1 -1
- package/dist/assets/{project-preview-BhNspxqe.js → project-preview-BjTq299L.js} +1 -1
- package/dist/assets/{projectActions-50e_f9dI.js → projectActions-BPmI9_mW.js} +1 -1
- package/dist/assets/{projectMeta-D53IRKNO.js → projectMeta-DyXicvG2.js} +1 -1
- package/dist/assets/{prompt-attachment-upload-8bssUUT3.js → prompt-attachment-upload-Bem87nmm.js} +1 -1
- package/dist/assets/{pwa-BVfdVkx_.js → pwa-B8e09BUU.js} +2 -2
- package/dist/assets/{queue-abort-optimistic-DNMz6oUq.js → queue-abort-optimistic-Buq-SBlq.js} +1 -1
- package/dist/assets/{react-GVgpPWOu.js → react-DAdu4yTi.js} +1 -1
- package/dist/assets/readiness-Bxbkh3nB.js +2 -0
- package/dist/assets/{reference-history-DhW8i1Bj.js → reference-history-DtWYTywa.js} +1 -1
- package/dist/assets/{remote-input-store-DFBMyVS-.js → remote-input-store-BvlOGMu_.js} +1 -1
- package/dist/assets/{remoteProjectQueries-8giIAvzL.js → remoteProjectQueries-B-IcENvi.js} +1 -1
- package/dist/assets/{remoteSessionReference-2EzJ0HAI.js → remoteSessionReference-BEtE3Q92.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-BSeoyBNY.js → renderElectronMiniChatApp-Dp6stG7q.js} +2 -2
- package/dist/assets/{renderMobileApp-B8zNPX8J.js → renderMobileApp-YITzRrOh.js} +4 -4
- package/dist/assets/{runtime-auth-mjIpsk3N.js → runtime-auth-DA-qfGHk.js} +1 -1
- package/dist/assets/{runtime-fetch-DKZOpfzo.js → runtime-fetch-V-iMWR8t.js} +1 -1
- package/dist/assets/{runtime-file-download-Dc459c9e.js → runtime-file-download-DxL4XbME.js} +1 -1
- package/dist/assets/{runtime-file-resource-DnhWnndu.js → runtime-file-resource-CKQQEwNv.js} +1 -1
- package/dist/assets/{runtime-switch-BMjl5Y5W.js → runtime-switch-DEPKHgdL.js} +1 -1
- package/dist/assets/{runtimeConfig-B5mZw-WN.js → runtimeConfig-Ccbs_U5j.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-xsh9V5vl.js → runtimeEndpointReset-CcoaDynZ.js} +5 -5
- package/dist/assets/{scheduledTaskNavigation-Bi7sRiFW.js → scheduledTaskNavigation-CdBHn9ti.js} +1 -1
- package/dist/assets/{select-BRjmw6pb.js → select-CWX5Iu4G.js} +1 -1
- package/dist/assets/{sessionLookup-BBqXTJRj.js → sessionLookup-Cc1qteBf.js} +1 -1
- package/dist/assets/{sortable-tabs-strip-DL4TMS9r.js → sortable-tabs-strip-Dr7EhUHW.js} +1 -1
- package/dist/assets/{speechSettingsQueries-DKopd_iw.js → speechSettingsQueries-C9SqPtzI.js} +1 -1
- package/dist/assets/src-BNTtvddA.css +2 -0
- package/dist/assets/{terminalApi-eR_918UZ.js → terminalApi-Bk77qMTK.js} +1 -1
- package/dist/assets/{textarea-BJ8C3aZh.js → textarea-C9CubBIs.js} +1 -1
- package/dist/assets/{tooltip-C88IVUw5.js → tooltip-Bk9lQalb.js} +1 -1
- package/dist/assets/{types-jqOiAN4j.js → types-Dhselvhe.js} +1 -1
- package/dist/assets/{useAppFontEffects-C28vxpqk.js → useAppFontEffects-C7rRTGhP.js} +48 -48
- package/dist/assets/{useAssistantUIStore-CphyXHEY.js → useAssistantUIStore-CI42fWZh.js} +1 -1
- package/dist/assets/{useDesktopWindowControlsLayout-Dm8OZBQF.js → useDesktopWindowControlsLayout-PzEwONdf.js} +1 -1
- package/dist/assets/{useDictation-Do12BpsS.js → useDictation-CLxZQYs_.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-6o2SvpVe.js → useEffectiveDirectory-D0EiFP2j.js} +1 -1
- package/dist/assets/{useFontPreferences-DFF-uEAD.js → useFontPreferences-DthR4yan.js} +1 -1
- package/dist/assets/{useMobileHtmlPreviewStore-DUquFMmd.js → useMobileHtmlPreviewStore-DzzgY1eS.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-zEWQLkBM.js → useMobileNavigationStore-CWShXc31.js} +6 -6
- package/dist/assets/{usePluginsStore-CJNc92gY.js → usePluginsStore-CEq5xgbZ.js} +1 -1
- package/dist/assets/{useProjectRuntimeAPIs-D6zSDR6i.js → useProjectRuntimeAPIs-BDy_DoSn.js} +1 -1
- package/dist/assets/{useStreamingTextThrottle-DBPv5MtB.js → useStreamingTextThrottle-BZuJKyrE.js} +1 -1
- package/dist/assets/{useUIStore-CYex4rbF.js → useUIStore-DjizmHAt.js} +1 -1
- package/dist/index.html +20 -20
- package/dist/mini-chat.html +20 -20
- package/dist/mobile.html +2 -2
- package/package.json +1 -1
- package/server/lib/gui-network/DOCUMENTATION.md +9 -1
- package/server/lib/realtime-proxy.js +4 -2
- package/server/lib/realtime-proxy.test.js +5 -4
- package/server/lib/relay/tunnel-host.js +3 -2
- package/server/lib/remote-hosts/DOCUMENTATION.md +8 -2
- package/server/lib/remote-hosts/routes.js +1 -1
- package/server/lib/remote-hosts/routes.test.js +75 -7
- package/server/lib/remote-hosts/transport.js +1 -1
- package/server/lib/ui-auth/ui-auth.js +1 -1
- package/server/lib/ui-auth/ui-auth.test.js +3 -0
- package/dist/assets/main-DehtDyHn.js +0 -169
- package/dist/assets/miniChat-Ba-eW2E2.js +0 -2
- package/dist/assets/mobile-CteFNdYr.js +0 -2
- package/dist/assets/readiness-BLhjWepK.js +0 -2
- package/dist/assets/src-DRyZ4dLj.css +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { afterEach, describe, expect, it } from '
|
|
1
|
+
import { afterEach, describe, expect, it } from 'vitest';
|
|
2
2
|
import express from 'express';
|
|
3
3
|
import http from 'node:http';
|
|
4
4
|
import { WebSocket, WebSocketServer } from 'ws';
|
|
@@ -190,7 +190,7 @@ describe('realtime proxy', () => {
|
|
|
190
190
|
}
|
|
191
191
|
});
|
|
192
192
|
|
|
193
|
-
it('
|
|
193
|
+
it.each(['/api/global/event/ws', '/api/gui-network/ws', '/api/hosts/remote-a/api/gui-network/ws'])('proxies %s with runtime headers and target Origin', async pathname => {
|
|
194
194
|
let upstreamRequest = null;
|
|
195
195
|
const upstreamServer = http.createServer();
|
|
196
196
|
const upstreamWs = new WebSocketServer({ server: upstreamServer });
|
|
@@ -204,7 +204,7 @@ describe('realtime proxy', () => {
|
|
|
204
204
|
const { origin, runtime } = await startProxyServer({ apiBaseUrl: upstreamOrigin });
|
|
205
205
|
|
|
206
206
|
try {
|
|
207
|
-
const target = `${upstreamOrigin.replace(/^http:/, 'ws:')}
|
|
207
|
+
const target = `${upstreamOrigin.replace(/^http:/, 'ws:')}${pathname}?lastEventId=evt-1`;
|
|
208
208
|
const client = new WebSocket(buildRealtimeProxyWsUrl(origin, target), {
|
|
209
209
|
headers: { Origin: 'yuri-ui://app' },
|
|
210
210
|
});
|
|
@@ -219,8 +219,9 @@ describe('realtime proxy', () => {
|
|
|
219
219
|
});
|
|
220
220
|
|
|
221
221
|
expect(message).toBe('echo:ping');
|
|
222
|
-
expect(upstreamRequest?.url).toBe(
|
|
222
|
+
expect(upstreamRequest?.url).toBe(`${pathname}?lastEventId=evt-1`);
|
|
223
223
|
expect(upstreamRequest?.headers['x-proxy-auth']).toBe('secret');
|
|
224
|
+
expect(upstreamRequest?.headers.origin).toBe(upstreamOrigin);
|
|
224
225
|
client.close();
|
|
225
226
|
upstreamWs.close();
|
|
226
227
|
} finally {
|
|
@@ -51,7 +51,7 @@ const PREVIEW_PROXY_WS_PATH_PREFIX = '/api/preview/proxy/';
|
|
|
51
51
|
*/
|
|
52
52
|
export const isTunnelWsPathAllowed = (path) => {
|
|
53
53
|
if (typeof path !== 'string' || !path) return false;
|
|
54
|
-
if (/^\/api\/hosts\/[^/]+\/api\/(?:terminal\/ws(?:\?|$)|preview\/proxy\/)/.test(path)) return true;
|
|
54
|
+
if (/^\/api\/hosts\/[^/]+\/api\/(?:(?:terminal|gui-network)\/ws(?:\?|$)|preview\/proxy\/)/.test(path)) return true;
|
|
55
55
|
// Path only (no query) — tunnel open payload already splits query.
|
|
56
56
|
if (ALLOWED_WS_PATHS.has(path)) return true;
|
|
57
57
|
try {
|
|
@@ -413,7 +413,8 @@ export const createTunnelHost = ({
|
|
|
413
413
|
for (const frame of encodeFragmentedMessage(frameType, streamId, bytes)) {
|
|
414
414
|
await waitForBackpressure(null);
|
|
415
415
|
if (streams.get(streamId) !== stream || closed) return;
|
|
416
|
-
await send(frame, open.path === '/api/remote-desktop/ws' || open.path === '/api/gui-network/ws'
|
|
416
|
+
await send(frame, open.path === '/api/remote-desktop/ws' || open.path === '/api/gui-network/ws'
|
|
417
|
+
|| /^\/api\/hosts\/[^/]+\/api\/gui-network\/ws$/.test(open.path));
|
|
417
418
|
}
|
|
418
419
|
});
|
|
419
420
|
});
|
|
@@ -185,7 +185,8 @@ short reads in `finally` and retain background watch demand until settlement.
|
|
|
185
185
|
`x-yuri-mime` and `x-yuri-filename` along with their original body bytes; size
|
|
186
186
|
and digest validation still execute on the Remote. These allowlisted metadata
|
|
187
187
|
headers never replace Remote authentication or forward Hub credentials.
|
|
188
|
-
- `/api/hosts/:hostId/api/terminal/ws
|
|
188
|
+
- `/api/hosts/:hostId/api/terminal/ws`, `/api/hosts/:hostId/api/gui-network/ws`
|
|
189
|
+
and `/api/hosts/:hostId/api/preview/proxy/*`
|
|
189
190
|
mount real upgrades, mirrored in Relay and URL-token allowlists. Host removal
|
|
190
191
|
closes direct sockets and Relay substreams, including pending handshakes.
|
|
191
192
|
Client revocation tracks the raw upgrade socket before waiting for the upstream;
|
|
@@ -198,7 +199,12 @@ short reads in `finally` and retain background watch demand until settlement.
|
|
|
198
199
|
authorization check and client upgrade. Overflow fails the upgrade and closes
|
|
199
200
|
the upstream; revocation, socket closure and failure discard the queue.
|
|
200
201
|
Direct and E2EE Relay use the same admission path. No greeting is synthesized
|
|
201
|
-
|
|
202
|
+
and no terminal handshake timeout is extended to conceal missing frames.
|
|
203
|
+
GUI TCP routes reuse the same credential, Origin and revocation gates for
|
|
204
|
+
Browser sessions belonging to a Remote Project. Direct server-to-server
|
|
205
|
+
upgrades set Origin to the admitted target's origin, never the Hub page's
|
|
206
|
+
origin. Hub URL tokens are stripped; the Remote transport supplies its own
|
|
207
|
+
saved credential. This does not open generic GUI-network HTTP forwarding.
|
|
202
208
|
|
|
203
209
|
The target-side local authority is `GET/POST /api/projects` and `PATCH
|
|
204
210
|
/api/projects/:id`. It only returns local projects. Authenticated
|
|
@@ -10,7 +10,7 @@ import { projectRemoteConfiguration } from './configuration.js';
|
|
|
10
10
|
import { RUNTIME_CONTRACT_MIN_VERIFIED } from '../opencode/runtime-contract.js';
|
|
11
11
|
import { parseFilePreviewPath, replaceFilePreviewUrlAuthToken } from '../preview/file-preview-path.js';
|
|
12
12
|
|
|
13
|
-
const websocketPath = (path) => path === '/api/terminal/ws' || path.startsWith('/api/preview/proxy/');
|
|
13
|
+
const websocketPath = (path) => path === '/api/terminal/ws' || path === '/api/gui-network/ws' || path.startsWith('/api/preview/proxy/');
|
|
14
14
|
const safeRoute = (route, method) => {
|
|
15
15
|
if (!route.startsWith('/api/') || /[\\\r\n]/.test(route)) return false;
|
|
16
16
|
const pathname = new URL(route, 'http://remote.invalid').pathname;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
2
2
|
import express from 'express';
|
|
3
3
|
import http from 'node:http';
|
|
4
|
+
import net from 'node:net';
|
|
4
5
|
import fs from 'node:fs/promises';
|
|
5
6
|
import path from 'node:path';
|
|
6
7
|
import os from 'node:os';
|
|
@@ -26,6 +27,9 @@ import { createTerminalRuntime } from '../terminal/runtime.js';
|
|
|
26
27
|
import { readTerminalWsControlFrame, createTerminalWsControlFrame } from '../terminal/terminal-ws-protocol.js';
|
|
27
28
|
import { createTranscriptCacheService } from '../transcript-cache/service.js';
|
|
28
29
|
import { runRemoteProjectOperation } from '../gui-customization/projects-remote.js';
|
|
30
|
+
import { attachGuiNetwork } from '../gui-network/runtime.js';
|
|
31
|
+
import { createRequestSecurityRuntime } from '../security/request-security.js';
|
|
32
|
+
import { createBrowserSocksGateway } from '../../../../electron/browser-socks-gateway.mjs';
|
|
29
33
|
|
|
30
34
|
const require = createRequire(import.meta.url);
|
|
31
35
|
const disposers = [];
|
|
@@ -33,7 +37,7 @@ afterEach(async () => { for (const dispose of disposers.splice(0).reverse()) awa
|
|
|
33
37
|
const wait = async (test) => { await vi.waitFor(test, { timeout: 5000, interval: 10 }); };
|
|
34
38
|
|
|
35
39
|
async function host({ adapter = null, supportedRemote = true, failHubWrite = false, requestTimeoutMs = 500,
|
|
36
|
-
operationTimeoutMs = requestTimeoutMs, indexStats, requireClientAuth = false, productionTerminal = false, terminalFrames = [] } = {}) {
|
|
40
|
+
operationTimeoutMs = requestTimeoutMs, indexStats, requireClientAuth = false, productionTerminal = false, terminalFrames = [], productionGuiNetwork = false } = {}) {
|
|
37
41
|
const directory = await fs.mkdtemp(path.join(os.tmpdir(), 'yuri-remote-host-test-'));
|
|
38
42
|
const clients = createRemoteClientAuthRuntime({ fsPromises: fs, path, crypto, storePath: path.join(directory, 'clients.json') });
|
|
39
43
|
const issued = await clients.createClient({ clientKind: 'desktop-local', authMethod: 'pairing', pairingId: 'test-pairing' });
|
|
@@ -73,8 +77,9 @@ async function host({ adapter = null, supportedRemote = true, failHubWrite = fal
|
|
|
73
77
|
app.get('/auth/session', auth.handleSessionStatus);
|
|
74
78
|
app.post('/auth/url-token', auth.handleUrlAuthToken);
|
|
75
79
|
app.use('/api', auth.requireAuth);
|
|
80
|
+
const security = createRequestSecurityRuntime({ readSettingsFromDiskMigrated: async () => ({}) });
|
|
76
81
|
runtime = registerRemoteHostRoutes(app, { gateway, getAuth: () => auth, server,
|
|
77
|
-
isRequestOriginAllowed: () => true, remoteClientAuthRuntime: clients,
|
|
82
|
+
isRequestOriginAllowed: productionGuiNetwork ? security.isRequestOriginAllowed : () => true, remoteClientAuthRuntime: clients,
|
|
78
83
|
readSettings: async () => settings,
|
|
79
84
|
persistSettings: async (update) => { settings = { ...settings, ...update(settings) }; return settings; },
|
|
80
85
|
validateDirectoryPath: async (value) => typeof value === 'string' && value.startsWith('/')
|
|
@@ -90,6 +95,7 @@ async function host({ adapter = null, supportedRemote = true, failHubWrite = fal
|
|
|
90
95
|
isRequestOriginAllowed: async () => true, rejectWebSocketUpgrade: (socket) => socket.destroy(),
|
|
91
96
|
TERMINAL_INPUT_WS_HEARTBEAT_INTERVAL_MS: 30000, TERMINAL_INPUT_WS_REBIND_WINDOW_MS: 1000,
|
|
92
97
|
TERMINAL_INPUT_WS_MAX_REBINDS_PER_WINDOW: 3 }) : null;
|
|
98
|
+
const guiNetwork = productionGuiNetwork ? attachGuiNetwork({ server, uiAuthController: auth, isRequestOriginAllowed: security.isRequestOriginAllowed }) : null;
|
|
93
99
|
const terminal = new WebSocketServer({ noServer: true });
|
|
94
100
|
server.on('upgrade', async (req, socket, head) => {
|
|
95
101
|
if (productionTerminal) return;
|
|
@@ -148,7 +154,7 @@ async function host({ adapter = null, supportedRemote = true, failHubWrite = fal
|
|
|
148
154
|
const url = `http://127.0.0.1:${server.address().port}`;
|
|
149
155
|
const headers = { Authorization: `Bearer ${issued.token}`, 'Content-Type': 'application/json' };
|
|
150
156
|
disposers.push(async () => {
|
|
151
|
-
runtime.stop(); terminal.close(); transcript.close(); auth.dispose();
|
|
157
|
+
guiNetwork?.stop(); runtime.stop(); terminal.close(); transcript.close(); auth.dispose();
|
|
152
158
|
await terminalRuntime?.shutdown();
|
|
153
159
|
for (const socket of sockets) socket.destroy();
|
|
154
160
|
await new Promise((resolve) => server.close(resolve));
|
|
@@ -174,7 +180,7 @@ async function host({ adapter = null, supportedRemote = true, failHubWrite = fal
|
|
|
174
180
|
|
|
175
181
|
async function aggregate(options = {}) {
|
|
176
182
|
const remote = await host({ requireClientAuth: options.requireClientAuth, productionTerminal: options.productionTerminal,
|
|
177
|
-
terminalFrames: options.terminalFrames });
|
|
183
|
+
terminalFrames: options.terminalFrames, productionGuiNetwork: options.productionGuiNetwork });
|
|
178
184
|
let hosts = [{ id: 'remote-1', label: 'Remote', source: 'direct', apiUrl: remote.url, clientToken: remote.issued.token }];
|
|
179
185
|
const listeners = new Set();
|
|
180
186
|
const adapter = { listHosts: async () => hosts, subscribe(fn) { listeners.add(fn); return () => listeners.delete(fn); } };
|
|
@@ -182,7 +188,68 @@ async function aggregate(options = {}) {
|
|
|
182
188
|
return { hub, remote, setHosts(next) { hosts = next; for (const fn of listeners) fn(); } };
|
|
183
189
|
}
|
|
184
190
|
|
|
191
|
+
async function assertBrowserTcp(hub, route, remote) {
|
|
192
|
+
const token = (await (await hub.call('/auth/url-token', 'POST')).json()).token;
|
|
193
|
+
const address = `${hub.url.replace('http:', 'ws:')}${route}?yuri_url_token=${token}`;
|
|
194
|
+
const rejectUpgrade = (url, origin) => new Promise((resolve, reject) => {
|
|
195
|
+
const ws = new WebSocket(url, { headers: { Origin: origin } });
|
|
196
|
+
ws.on('error', () => {});
|
|
197
|
+
ws.on('unexpected-response', (_req, res) => { res.resume(); ws.terminate(); resolve(res.statusCode); });
|
|
198
|
+
ws.on('open', () => { ws.terminate(); reject(new Error('Unexpected admission')); });
|
|
199
|
+
});
|
|
200
|
+
expect(await rejectUpgrade(address, 'https://untrusted.example')).toBe(403);
|
|
201
|
+
expect(await rejectUpgrade(address.replace(token, 'invalid'), hub.url)).toBe(403);
|
|
202
|
+
const ws = new WebSocket(address, { headers: { Origin: hub.url } });
|
|
203
|
+
ws.on('error', () => {});
|
|
204
|
+
let ready;
|
|
205
|
+
const socks = createBrowserSocksGateway({ send: value => {
|
|
206
|
+
if (ws.readyState !== WebSocket.OPEN) return false;
|
|
207
|
+
ws.send(Buffer.isBuffer(value) ? value : JSON.stringify(value)); return true;
|
|
208
|
+
} });
|
|
209
|
+
ws.on('message', (bytes, binary) => {
|
|
210
|
+
if (!binary && JSON.parse(bytes).type === 'ready') { ready = JSON.parse(bytes); return; }
|
|
211
|
+
socks.receive(binary ? bytes : bytes.toString());
|
|
212
|
+
});
|
|
213
|
+
let browser;
|
|
214
|
+
const connections = new Set();
|
|
215
|
+
const destination = net.createServer(socket => {
|
|
216
|
+
connections.add(socket); socket.once('close', () => connections.delete(socket));
|
|
217
|
+
socket.on('data', bytes => socket.write(bytes));
|
|
218
|
+
});
|
|
219
|
+
try {
|
|
220
|
+
destination.listen(0, '127.0.0.1'); await once(destination, 'listening');
|
|
221
|
+
if (ws.readyState === WebSocket.CONNECTING) await once(ws, 'open');
|
|
222
|
+
await wait(() => expect(ready?.httpOrigin).toBe(`http://localhost:${remote.server.address().port}`));
|
|
223
|
+
const { port } = await socks.start();
|
|
224
|
+
browser = net.connect(port, '127.0.0.1');
|
|
225
|
+
browser.on('error', () => {});
|
|
226
|
+
await once(browser, 'connect');
|
|
227
|
+
const read = length => new Promise(resolve => {
|
|
228
|
+
const receive = () => { const bytes = browser.read(length); if (bytes) { browser.off('readable', receive); resolve(bytes); } };
|
|
229
|
+
browser.on('readable', receive); receive();
|
|
230
|
+
});
|
|
231
|
+
browser.write(Buffer.from([5, 1, 0]));
|
|
232
|
+
expect(await read(2)).toEqual(Buffer.from([5, 0]));
|
|
233
|
+
const request = Buffer.from([5, 1, 0, 1, 127, 0, 0, 1, 0, 0]);
|
|
234
|
+
request.writeUInt16BE(destination.address().port, 8); browser.write(request);
|
|
235
|
+
expect((await read(10))[1]).toBe(0);
|
|
236
|
+
const bytes = crypto.randomBytes(512 * 1024);
|
|
237
|
+
browser.write(bytes);
|
|
238
|
+
expect(await read(bytes.length)).toEqual(bytes);
|
|
239
|
+
ws.close();
|
|
240
|
+
await wait(() => expect(connections.size).toBe(0));
|
|
241
|
+
} finally {
|
|
242
|
+
browser?.destroy(); await socks.close(); ws.terminate();
|
|
243
|
+
for (const socket of connections) socket.destroy();
|
|
244
|
+
await new Promise(resolve => destination.close(resolve));
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
185
248
|
describe('Remote Host production HTTP contract', () => {
|
|
249
|
+
it('routes Browser SOCKS to the Remote Project Host with URL auth and real Origin checks', async () => {
|
|
250
|
+
const { hub, remote } = await aggregate({ productionGuiNetwork: true, requireClientAuth: true, requestTimeoutMs: 5000 });
|
|
251
|
+
await assertBrowserTcp(hub, '/api/hosts/remote-1/api/gui-network/ws', remote);
|
|
252
|
+
});
|
|
186
253
|
it('forwards metadata writes with their directory and patch, but rejects other methods and stale targets', async () => {
|
|
187
254
|
const { hub, remote } = await aggregate();
|
|
188
255
|
const writes = [];
|
|
@@ -1407,7 +1474,7 @@ describe('Remote Host production HTTP contract', () => {
|
|
|
1407
1474
|
|
|
1408
1475
|
it.each([0, 1, 2])('uses the real E2EE Relay client for Relay-only hosts, including terminal forwarding (%i)', async (iteration) => {
|
|
1409
1476
|
const productionTerminal = iteration === 2;
|
|
1410
|
-
const remote = await host({ requireClientAuth: true, productionTerminal });
|
|
1477
|
+
const remote = await host({ requireClientAuth: true, productionTerminal, productionGuiNetwork: true });
|
|
1411
1478
|
const relay = createPrivateRelayServer({ host: '127.0.0.1', port: 0 });
|
|
1412
1479
|
await relay.start();
|
|
1413
1480
|
const encryption = await generateEcdhKeyPair();
|
|
@@ -1428,7 +1495,8 @@ describe('Remote Host production HTTP contract', () => {
|
|
|
1428
1495
|
const paired = await remote.clients.createClient({ clientKind: 'desktop', authMethod: 'pairing', pairingId: 'relay-pair', usesRelay: true });
|
|
1429
1496
|
const descriptor = { id: 'relay-only', name: 'Relay Host', source: 'relay', clientToken: paired.token,
|
|
1430
1497
|
relay: { relayUrl, serverId, hostEncPubJwk: identity.hostEncPubJwk } };
|
|
1431
|
-
const hub = await host({ adapter: { listHosts: async () => [descriptor] }, requestTimeoutMs: 5000 });
|
|
1498
|
+
const hub = await host({ adapter: { listHosts: async () => [descriptor] }, requestTimeoutMs: 5000, productionGuiNetwork: true });
|
|
1499
|
+
if (iteration === 1) await assertBrowserTcp(hub, '/api/hosts/relay-only/api/gui-network/ws', remote);
|
|
1432
1500
|
if (productionTerminal) {
|
|
1433
1501
|
const authorize = hub.auth.resolveAuthContext;
|
|
1434
1502
|
let upgrades = 0;
|
|
@@ -1458,7 +1526,7 @@ describe('Remote Host production HTTP contract', () => {
|
|
|
1458
1526
|
.toMatchObject({ created: true, session: { sessionID: 'ses_relay_new', directory: registered.project.path, target } });
|
|
1459
1527
|
expect(createSession).toHaveBeenCalledOnce();
|
|
1460
1528
|
await wait(() => expect(remote.statusStreams).toBe(1));
|
|
1461
|
-
const socket = new WebSocket(`${hub.url.replace('http:', 'ws:')}/api/hosts/relay-only/api/terminal/ws`, { headers: hub.headers });
|
|
1529
|
+
const socket = new WebSocket(`${hub.url.replace('http:', 'ws:')}/api/hosts/relay-only/api/terminal/ws`, { headers: { ...hub.headers, Origin: hub.url } });
|
|
1462
1530
|
disposers.push(() => socket.terminate());
|
|
1463
1531
|
const frames = [];
|
|
1464
1532
|
if (productionTerminal) socket.on('message', (data) => frames.push(readTerminalWsControlFrame(data)));
|
|
@@ -69,7 +69,7 @@ export async function createRemoteTransport(host, { fetchImpl = fetch, signal }
|
|
|
69
69
|
if (closed) throw failure('stale_host', 409);
|
|
70
70
|
const url = new URL(route, base);
|
|
71
71
|
url.protocol = url.protocol === 'https:' ? 'wss:' : 'ws:';
|
|
72
|
-
const socket = new WebSocket(url, protocols, { headers });
|
|
72
|
+
const socket = new WebSocket(url, protocols, { headers: { ...headers, Origin: base.origin } });
|
|
73
73
|
socket.onmessage = onMessage || null;
|
|
74
74
|
sockets.add(socket);
|
|
75
75
|
socket.once('close', () => sockets.delete(socket));
|
|
@@ -320,7 +320,7 @@ const isUrlAuthReadableHttpPath = (pathname) => {
|
|
|
320
320
|
export const isUrlAuthWebSocketPath = (pathname) => {
|
|
321
321
|
if (typeof pathname !== 'string' || !pathname) return false;
|
|
322
322
|
if (parseFilePreviewPath(pathname)) return false;
|
|
323
|
-
const remote = /^\/api\/hosts\/[^/]+(\/api\/(?:terminal\/ws|preview\/proxy\/.*))$/.exec(pathname);
|
|
323
|
+
const remote = /^\/api\/hosts\/[^/]+(\/api\/(?:terminal\/ws|gui-network\/ws|preview\/proxy\/.*))$/.exec(pathname);
|
|
324
324
|
if (remote) return isUrlAuthWebSocketPath(remote[1]);
|
|
325
325
|
return pathname === '/api/event/ws'
|
|
326
326
|
|| pathname === '/api/global/event/ws'
|
|
@@ -58,6 +58,9 @@ describe('isUrlAuthWebSocketPath', () => {
|
|
|
58
58
|
expect(isUrlAuthWebSocketPath('/api/preview/proxy/abc123/')).toBe(true);
|
|
59
59
|
expect(isUrlAuthWebSocketPath('/api/preview/proxy/abc123/@vite')).toBe(true);
|
|
60
60
|
expect(isUrlAuthWebSocketPath('/api/terminal/ws')).toBe(true);
|
|
61
|
+
expect(isUrlAuthWebSocketPath('/api/hosts/remote-a/api/gui-network/ws')).toBe(true);
|
|
62
|
+
expect(isUrlAuthWebSocketPath('/api/hosts/remote-a/api/gui-network/ws/extra')).toBe(false);
|
|
63
|
+
expect(isUrlAuthWebSocketPath('/api/hosts/remote-a/api/hosts/remote-b/api/gui-network/ws')).toBe(false);
|
|
61
64
|
expect(isUrlAuthWebSocketPath('/api/dictation/ws')).toBe(true);
|
|
62
65
|
expect(isUrlAuthWebSocketPath('/api/event/ws')).toBe(true);
|
|
63
66
|
expect(isUrlAuthWebSocketPath('/api/global/event/ws')).toBe(true);
|