@yuriai/web 0.2.32-beta.4 → 0.2.32-beta.6
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/README.md +18 -0
- package/dist/assets/{AgentAvatar-DG1RbFtI.js → AgentAvatar-BPGtFSJl.js} +1 -1
- package/dist/assets/AssistantContactStatus-aUqr2ugb.js +3 -0
- package/dist/assets/{AssistantUnreadBadge-ByetyaWn.js → AssistantUnreadBadge-DrGzknrO.js} +1 -1
- package/dist/assets/{AssistantView-CHt3RWEC.js → AssistantView-GTh6h8B4.js} +1 -1
- package/dist/assets/{DiagramView-DReVW5q9.js → DiagramView-CLxCIzOU.js} +1 -1
- package/dist/assets/{FadeInOnReveal-Bmxvkrf4.js → FadeInOnReveal-DoQ1DHcy.js} +1 -1
- package/dist/assets/{GuiPluginSurface-CIeyIzIp.js → GuiPluginSurface-Cnyb0Yg6.js} +1 -1
- package/dist/assets/{GuiPluginWindow-CwP_vUoC.js → GuiPluginWindow-CWjwMY19.js} +1 -1
- package/dist/assets/Icon-wD7peplo.js +1 -0
- package/dist/assets/{ImageLoadingPlaceholder-DlosWH_9.js → ImageLoadingPlaceholder-cfSg1uO0.js} +1 -1
- package/dist/assets/{LoadingImage-D9r0ukc0.js → LoadingImage-DTlBKb0t.js} +1 -1
- package/dist/assets/{MarkdownRenderer-D-0KHpNl.js → MarkdownRenderer-QhegFBTR.js} +2 -2
- package/dist/assets/{MarkdownRendererImpl-BEUnj4i_.js → MarkdownRendererImpl-rflXjuIs.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-BufiC_bA.js → MarkstreamRendererImpl-DGuW5ssC.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-32DAi6Mg.js → MobileDetailNavigation-DpEvfH1k.js} +1 -1
- package/dist/assets/{MobileResizableSheet-vAenroLZ.js → MobileResizableSheet-3pSxhm6y.js} +1 -1
- package/dist/assets/{MobileShareBridge-DukFTkwu.js → MobileShareBridge-DiIVhlyc.js} +1 -1
- package/dist/assets/MobileTabPageHeader-eWPfDPR9.js +2 -0
- package/dist/assets/{MultiRunWindow-B2e-JjFb.js → MultiRunWindow-ByORgIWm.js} +1 -1
- package/dist/assets/{OnboardingScreen-DNlK3zfZ.js → OnboardingScreen-De74T2ws.js} +1 -1
- package/dist/assets/{OverlayScrollbar-W17unuIx.js → OverlayScrollbar-C1VJiQk-.js} +1 -1
- package/dist/assets/{SettingsView-DXhstV_y.js → SettingsView-H9vzfUh1.js} +12 -12
- package/dist/assets/{SettingsWindow-D1BRJCx_.js → SettingsWindow-CdUQZdrH.js} +1 -1
- package/dist/assets/SetupTourDialog-DJQC2v_9.js +1 -0
- package/dist/assets/SetupTourDialog-DrL_4ODI.css +1 -0
- package/dist/assets/{TerminalView-B_jqEx8P.js → TerminalView-X8tMXHjR.js} +1 -1
- package/dist/assets/{ToolOutputDialog-BgwsFo9W.js → ToolOutputDialog-DzAxB4FS.js} +1 -1
- package/dist/assets/{VoiceSettings-DXHfWAgl.js → VoiceSettings-CnYY2qY_.js} +2 -2
- package/dist/assets/{YuriLogo-XH6UGXtF.js → YuriLogo-kLl6rb2d.js} +1 -1
- package/dist/assets/YuriWordmark-DHYo0FlR.js +1 -0
- package/dist/assets/{appThemeRegistry-ChXTWoVW.js → appThemeRegistry-DIjRw0x6.js} +1 -1
- package/dist/assets/{button-CyJvQsp5.js → button-DSfiaJr4.js} +1 -1
- package/dist/assets/{capgoAdapter-BAvjN_Nh.js → capgoAdapter-cbndHe7B.js} +1 -1
- package/dist/assets/checkbox-cWs92MsM.js +1 -0
- package/dist/assets/{collapsible-CXjDO6DW.js → collapsible-AUQp4jpe.js} +1 -1
- package/dist/assets/{context-menu-BajfnPcW.js → context-menu-DwQvyFO2.js} +1 -1
- package/dist/assets/{diagram-_Js3imTf.js → diagram-BTa5MQro.js} +1 -1
- package/dist/assets/{dialog-Bapd6e10.js → dialog-gWs6IrfL.js} +1 -1
- package/dist/assets/{es-CBhZ80Z7.js → es-mX3KOqnq.js} +1 -1
- package/dist/assets/{fileMentionTouchSelection-BqGxOZhB.js → fileMentionTouchSelection-plcnc8He.js} +1 -1
- package/dist/assets/{fr-D9s0sHDF.js → fr-DpWAkfly.js} +1 -1
- package/dist/assets/{gitApi-DtXTuozL.js → gitApi-B9CzBfkU.js} +1 -1
- package/dist/assets/historyImportQueries-DXif2xV2.js +1 -0
- package/dist/assets/host-z9PU8q1e.js +1 -0
- package/dist/assets/{input-SCAHBeSU.js → input-D2qPeIPD.js} +1 -1
- package/dist/assets/insertionBoundaries-mB_fOUPv.js +1 -0
- package/dist/assets/{ja-BXQ3ox8H.js → ja-BBtK3t8l.js} +1 -1
- package/dist/assets/{ko-DlUti1wK.js → ko-Cwp3wC4W.js} +1 -1
- package/dist/assets/main-GmcShJwn.js +169 -0
- package/dist/assets/main-PMsuxOz8.js +2 -0
- package/dist/assets/{markdownHeightCache-B3MTnGA8.js → markdownHeightCache-Cinxvo8I.js} +1 -1
- package/dist/assets/{mcpQueries-0BYnsVR6.js → mcpQueries-D4D9YExA.js} +1 -1
- package/dist/assets/miniChat-D6sCXrvt.js +2 -0
- package/dist/assets/mobile-BT_KeI5P.js +2 -0
- package/dist/assets/{mobileBackNavigation-C1Ow2avo.js → mobileBackNavigation-uUEjrscy.js} +1 -1
- package/dist/assets/multirun-T_ppFdUy.js +3 -0
- package/dist/assets/{native-config-DQIb-3qU.js → native-config-BuFjRBaY.js} +1 -1
- package/dist/assets/{pl-B7LIbV2C.js → pl-Ccedjy5w.js} +1 -1
- package/dist/assets/{projectMeta-CSiZ4I85.js → projectMeta-FCtpvvba.js} +1 -1
- package/dist/assets/{pt-BR-DyusczdZ.js → pt-BR-M2O45bRx.js} +1 -1
- package/dist/assets/{pwa-Cm-jO8eR.js → pwa-CT5wGYKz.js} +1 -1
- package/dist/assets/{queue-abort-optimistic-CxF6bGXx.js → queue-abort-optimistic-Dqb0K-4o.js} +1 -1
- package/dist/assets/react-a6PrrNTm.js +1 -0
- package/dist/assets/{readiness-CDywb9dh.js → readiness-B2YFCzzO.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-CiVeccip.js → renderElectronMiniChatApp-oHllm8xZ.js} +2 -2
- package/dist/assets/{renderMobileApp-B9-hpVnc.js → renderMobileApp-BHHmg4QP.js} +7 -7
- package/dist/assets/{runtimeConfig-Rthccc9z.js → runtimeConfig-7V2FCxSF.js} +1 -1
- package/dist/assets/runtimeEndpointReset-RgJe46-h.js +149 -0
- package/dist/assets/{select-BCLecCtX.js → select-BOlDxL_9.js} +1 -1
- package/dist/assets/sessionLookup-Fwx-W5l-.js +1 -0
- package/dist/assets/{sortable-tabs-strip-D474PwS8.js → sortable-tabs-strip-CtkfOIVC.js} +1 -1
- package/dist/assets/{speechSettingsQueries-alV0B1bP.js → speechSettingsQueries-BjBvcUMN.js} +1 -1
- package/dist/assets/src-C5Lsul_L.css +2 -0
- package/dist/assets/{store-Diaywtmi.js → store-BMijqCTE.js} +3 -3
- package/dist/assets/{textarea-CWQIq-Mn.js → textarea-Cspgldlr.js} +1 -1
- package/dist/assets/{tooltip-D3WmiZ7G.js → tooltip-DBb-UCMU.js} +1 -1
- package/dist/assets/tour-DzjTres6.js +1 -0
- package/dist/assets/{types-_2Igbjc0.js → types-C1fTHpjE.js} +1 -1
- package/dist/assets/{uk-BrwM67Dh.js → uk-skNzlwtr.js} +1 -1
- package/dist/assets/{useAppFontEffects-B1n0YPn0.js → useAppFontEffects-BIioYkKK.js} +54 -54
- package/dist/assets/useDesktopWindowControlsLayout-BO0Lolpp.js +1 -0
- package/dist/assets/{useDictation-C-waWdAq.js → useDictation-CwZ6a6i7.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-CvDy8Tyu.js → useEffectiveDirectory-Bqgyt9OS.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-BHAEAnfr.js → useMobileNavigationStore-BGHhBg7N.js} +13 -13
- package/dist/assets/{usePluginsStore-DvvZ8a3q.js → usePluginsStore-DT2-z09d.js} +1 -1
- package/dist/assets/{useWorkerHighlightedLines-DUpdltuG.js → useWorkerHighlightedLines-B8ypYliw.js} +1 -1
- package/dist/assets/{zh-CN-D9NAFloZ.js → zh-CN-KsbHpHjS.js} +1 -1
- package/dist/assets/{zh-TW-tuUKOuhs.js → zh-TW-SdNEiQ7a.js} +1 -1
- package/dist/index.html +6 -6
- package/dist/mini-chat.html +6 -6
- package/dist/mobile.html +6 -6
- package/package.json +1 -1
- package/server/index.js +2 -0
- package/server/lib/client-auth/pairing.js +2 -0
- package/server/lib/client-auth/pairing.test.js +29 -0
- package/server/lib/content-search/DOCUMENTATION.md +9 -0
- package/server/lib/content-search/routes.js +18 -1
- package/server/lib/content-search/routes.test.js +21 -0
- package/server/lib/content-search/runtime.js +7 -3
- package/server/lib/content-search/runtime.test.js +26 -0
- package/server/lib/gui-customization/DOCUMENTATION.md +21 -1
- package/server/lib/gui-customization/session-skill.js +2 -2
- package/server/lib/gui-customization/session-skill.test.js +3 -1
- package/server/lib/gui-customization/skill/SKILL.md +5 -1
- package/server/lib/gui-customization/skill/references/global-pages.md +1 -1
- package/server/lib/gui-customization/skill/references/gui-api.md +4 -1
- package/server/lib/gui-customization/skill/references/icons.md +134 -0
- package/server/lib/gui-customization/skill/references/plugin-styles.md +112 -0
- package/server/lib/gui-customization/skill/references/ui-surfaces.md +2 -0
- package/server/lib/gui-customization/skill/references/work-status.md +110 -0
- package/server/lib/history-import/AGENT_CONNECT_LICENSE +21 -0
- package/server/lib/history-import/DOCUMENTATION.md +214 -0
- package/server/lib/history-import/dev-proxy.integration.test.js +56 -0
- package/server/lib/history-import/events.js +322 -0
- package/server/lib/history-import/events.test.js +110 -0
- package/server/lib/history-import/installations.js +39 -0
- package/server/lib/history-import/installations.test.js +24 -0
- package/server/lib/history-import/native.js +49 -0
- package/server/lib/history-import/native.test.js +42 -0
- package/server/lib/history-import/routes.js +48 -0
- package/server/lib/history-import/routes.test.js +55 -0
- package/server/lib/history-import/service.js +374 -0
- package/server/lib/history-import/service.test.js +508 -0
- package/server/lib/history-import/settings.js +146 -0
- package/server/lib/history-import/settings.test.js +88 -0
- package/server/lib/history-import/sources.js +184 -0
- package/server/lib/history-import/sources.test.js +190 -0
- package/server/lib/history-import/sqlite.js +187 -0
- package/server/lib/history-import/store.js +58 -0
- package/server/lib/history-import/store.test.js +72 -0
- package/server/lib/history-import/targets.js +24 -0
- package/server/lib/host-update/DOCUMENTATION.md +6 -0
- package/server/lib/host-update/routes.test.js +1 -1
- package/server/lib/notifications/native-stream.relay.test.js +1 -0
- package/server/lib/opencode/DOCUMENTATION.md +3 -0
- package/server/lib/opencode/core-routes.js +1 -0
- package/server/lib/opencode/feature-routes-runtime.js +11 -1
- package/server/lib/opencode/yuri-routes.js +1 -1
- package/server/lib/relay/DOCUMENTATION.md +1 -1
- package/server/lib/relay/host-client.js +3 -1
- package/server/lib/relay/host-client.test.js +1 -0
- package/server/lib/relay/reasoning-projection.e2e.test.ts +1 -0
- package/server/lib/relay/relay-server.e2e.test.ts +32 -17
- package/server/lib/relay/service.js +2 -0
- package/server/lib/relay/tunnel-host.js +26 -1
- package/server/lib/relay/tunnel-host.test.js +27 -3
- package/server/lib/remote-desktop/runtime.test.js +2 -2
- package/server/lib/ui-auth/DOCUMENTATION.md +3 -0
- package/server/lib/ui-auth/ui-auth.js +27 -0
- package/server/lib/ui-auth/ui-auth.test.js +42 -1
- package/server/plugin-gui-proxy.test.js +1 -1
- package/dist/assets/AssistantContactStatus-TjmyQVnm.js +0 -3
- package/dist/assets/Icon-BOYrvHyJ.js +0 -1
- package/dist/assets/MobileTabPageHeader-DEXatYlp.js +0 -2
- package/dist/assets/SetupTourDialog-CUzqT2sw.css +0 -1
- package/dist/assets/SetupTourDialog-CxgLkqcj.js +0 -1
- package/dist/assets/YuriWordmark-Cr1vkcue.js +0 -1
- package/dist/assets/host-CBfSyi4l.js +0 -1
- package/dist/assets/insertionBoundaries-DeBppC-3.js +0 -1
- package/dist/assets/main-BEYE305b.js +0 -2
- package/dist/assets/main-CYlSqUaZ.js +0 -169
- package/dist/assets/miniChat-CvclLJoR.js +0 -2
- package/dist/assets/mobile-BU75qxb4.js +0 -2
- package/dist/assets/multirun-4Pn9maGs.js +0 -3
- package/dist/assets/react-Bwr5-XPi.js +0 -1
- package/dist/assets/runtimeEndpointReset-CretKGD9.js +0 -149
- package/dist/assets/sessionLookup-BxPSStyI.js +0 -1
- package/dist/assets/src-CFd7QD5V.css +0 -2
- package/dist/assets/tour-DeA0Ksvj.js +0 -1
- package/dist/assets/useDesktopWindowControlsLayout-CpYYPIUB.js +0 -1
|
@@ -195,10 +195,13 @@ const startOrigin = async (options: { recoveryEvents?: boolean } = {}) => {
|
|
|
195
195
|
const bearerRequests: string[] = [];
|
|
196
196
|
const observedOrigins: string[] = [];
|
|
197
197
|
const sockets = new Set<net.Socket>();
|
|
198
|
+
const pairedClient = { id: 'device-1', authMethod: 'pairing', pairingId: 'fixture-pairing', usesRelay: true };
|
|
199
|
+
const sshClient = { id: 'ssh-client', authMethod: 'password', clientKind: 'desktop-local', usesRelay: false };
|
|
198
200
|
const clientAuthController = {
|
|
201
|
+
listClients: async () => [pairedClient, sshClient],
|
|
199
202
|
authenticateBearerToken: async (token: string) => token === 'client-token'
|
|
200
|
-
? { ok: true, clientId: 'device-1', sessionToken: 'client:device-1' }
|
|
201
|
-
: { ok: false },
|
|
203
|
+
? { ok: true, clientId: 'device-1', sessionToken: 'client:device-1', client: pairedClient }
|
|
204
|
+
: token === 'ssh-token' ? { ok: true, clientId: sshClient.id, client: sshClient } : { ok: false },
|
|
202
205
|
};
|
|
203
206
|
const uiAuth = createUiAuth({ requireClientAuth: true, clientAuthController });
|
|
204
207
|
const requestSecurity = createRequestSecurityRuntime({ readSettingsFromDiskMigrated: async () => ({}) });
|
|
@@ -366,6 +369,7 @@ const startOrigin = async (options: { recoveryEvents?: boolean } = {}) => {
|
|
|
366
369
|
await new Promise<void>((resolve) => server.listen(0, '127.0.0.1', resolve));
|
|
367
370
|
const port = (server.address() as net.AddressInfo).port;
|
|
368
371
|
return {
|
|
372
|
+
authorizeRequest: uiAuth.authorizeRelayRequest,
|
|
369
373
|
port, videoPath, previewPath, previewContent, guiBundle, pluginInventory, guiRequests, bearerRequests, observedOrigins, attachmentAssistant, getHostSubscriptions: () => hostSubscriptions,
|
|
370
374
|
advanceRecoveryRevision: () => { recoveryRevision += 1; return `ses_recovery_${recoveryRevision}`; },
|
|
371
375
|
stop: async () => {
|
|
@@ -484,7 +488,7 @@ describe('private relay compiled-process boundary', () => {
|
|
|
484
488
|
relay = await startCompiledRelay(binary, await freePort());
|
|
485
489
|
origin = await startOrigin();
|
|
486
490
|
const identity = await buildIdentity();
|
|
487
|
-
host = startRelayHost({ relayUrl: relay.url, identity, getLocalPort: () => origin!.port,
|
|
491
|
+
host = startRelayHost({ authorizeRequest: origin.authorizeRequest, relayUrl: relay.url, identity, getLocalPort: () => origin!.port,
|
|
488
492
|
batch: hostBatch, batchWindowMs: 2_000, onStatus() {}, logger: { warn() {}, info() {} } });
|
|
489
493
|
client = createRelayTunnelClient({ relayUrl: relay.url, serverId: identity.serverId, hostEncPubJwk: identity.hostEncPubJwk,
|
|
490
494
|
batch: clientBatch, batchWindowMs: 2_000, pingIntervalMs: 60_000 });
|
|
@@ -526,13 +530,13 @@ describe('private relay compiled-process boundary', () => {
|
|
|
526
530
|
};
|
|
527
531
|
origin = await startOrigin();
|
|
528
532
|
const identity = await buildIdentity();
|
|
529
|
-
host = startRelayHost({ relayUrl, identity, getLocalPort: () => origin!.port,
|
|
533
|
+
host = startRelayHost({ authorizeRequest: origin.authorizeRequest, relayUrl, identity, getLocalPort: () => origin!.port,
|
|
530
534
|
batchWindowMs: 5, onStatus() {}, logger: { warn() {}, info() {} } });
|
|
531
535
|
client = createRelayTunnelClient({ relayUrl, serverId: identity.serverId, hostEncPubJwk: identity.hostEncPubJwk,
|
|
532
536
|
batchWindowMs: 5, helloRetryMs: 50 });
|
|
533
537
|
await eventually(() => host!.getStatus().state === 'connected' && client!.getStatus().state === 'connected', 'Worker E2EE tunnel did not connect');
|
|
534
538
|
|
|
535
|
-
expect((await client.fetch('/api/event')).status).toBe(
|
|
539
|
+
expect((await client.fetch('/api/event')).status).toBe(403);
|
|
536
540
|
const headers = { authorization: 'Bearer client-token' };
|
|
537
541
|
const httpResponse = await client.fetch('/api/e2e/http', { method: 'POST', headers, body: 'worker-stream-body' });
|
|
538
542
|
expect(await httpResponse.json()).toEqual({ body: 'worker-stream-body', hasRelayConnection: true });
|
|
@@ -598,7 +602,7 @@ describe('private relay compiled-process boundary', () => {
|
|
|
598
602
|
relay = await startCompiledRelay(binary, port);
|
|
599
603
|
origin = await startOrigin({ recoveryEvents: true });
|
|
600
604
|
const identity = await buildIdentity();
|
|
601
|
-
const startHost = () => startRelayHost({ relayUrl: relay!.url, identity, getLocalPort: () => origin!.port,
|
|
605
|
+
const startHost = () => startRelayHost({ authorizeRequest: origin!.authorizeRequest, relayUrl: relay!.url, identity, getLocalPort: () => origin!.port,
|
|
602
606
|
onStatus() {}, logger: { warn() {}, info() {} }, reconnectBaseDelayMs: 30, reconnectMaxDelayMs: 100 });
|
|
603
607
|
host = startHost();
|
|
604
608
|
await eventually(() => host!.getStatus().state === 'connected', 'Host did not register');
|
|
@@ -719,7 +723,7 @@ describe('private relay compiled-process boundary', () => {
|
|
|
719
723
|
relay = await startCompiledRelay(binary, port);
|
|
720
724
|
origin = await startOrigin();
|
|
721
725
|
const identity = await buildIdentity();
|
|
722
|
-
host = startRelayHost({ relayUrl: relay.url, identity, getLocalPort: () => origin.port, onStatus: () => {}, logger: { warn: () => {}, info: () => {} } });
|
|
726
|
+
host = startRelayHost({ authorizeRequest: origin.authorizeRequest, relayUrl: relay.url, identity, getLocalPort: () => origin.port, onStatus: () => {}, logger: { warn: () => {}, info: () => {} } });
|
|
723
727
|
let receivedBytes = 0;
|
|
724
728
|
client = createRelayTunnelClient({
|
|
725
729
|
relayUrl: relay.url, serverId: identity.serverId, hostEncPubJwk: identity.hostEncPubJwk,
|
|
@@ -749,6 +753,17 @@ describe('private relay compiled-process boundary', () => {
|
|
|
749
753
|
});
|
|
750
754
|
|
|
751
755
|
await eventually(() => host!.getStatus().state === 'connected' && client!.getStatus().state === 'connected', 'host and TypeScript client did not connect');
|
|
756
|
+
const directSsh = await fetch(`http://127.0.0.1:${origin.port}/auth/url-token`, {
|
|
757
|
+
method: 'POST', headers: { authorization: 'Bearer ssh-token' },
|
|
758
|
+
});
|
|
759
|
+
expect(directSsh.status).toBe(200);
|
|
760
|
+
const sshUrlToken = (await directSsh.json()).token;
|
|
761
|
+
for (const route of ['/auth/session', '/api/e2e/initialization', '/api/e2e/sse']) {
|
|
762
|
+
expect((await client.fetch(route, { headers: { authorization: 'Bearer ssh-token' } })).status).toBe(403);
|
|
763
|
+
}
|
|
764
|
+
const unpairedSocket = client.openWebSocket(`/api/terminal/ws?yuri_url_token=${encodeURIComponent(sshUrlToken)}`);
|
|
765
|
+
await expect(waitSocketOpen(unpairedSocket)).rejects.toThrow();
|
|
766
|
+
expect(origin.observedOrigins).toEqual([]);
|
|
752
767
|
const body = new ReadableStream<Uint8Array>({
|
|
753
768
|
start(controller) { controller.enqueue(new TextEncoder().encode('stream-')); controller.enqueue(new TextEncoder().encode('body')); controller.close(); },
|
|
754
769
|
});
|
|
@@ -774,7 +789,7 @@ describe('private relay compiled-process boundary', () => {
|
|
|
774
789
|
expect(new TextDecoder().decode(Buffer.concat(chunks.map((chunk) => Buffer.from(chunk))))).toBe('data: one\n\ndata: two\n\ndata: three\n\n');
|
|
775
790
|
|
|
776
791
|
const denied = await client.fetch('/api/event');
|
|
777
|
-
expect(denied.status).toBe(
|
|
792
|
+
expect(denied.status).toBe(403);
|
|
778
793
|
const hostEvents = await client.fetch('/api/event', { headers: { authorization: 'Bearer client-token' } });
|
|
779
794
|
expect(hostEvents.status).toBe(200);
|
|
780
795
|
const frames = (await hostEvents.text()).trim().split('\n\n').map((block) => JSON.parse(block.slice(6)));
|
|
@@ -821,7 +836,7 @@ describe('private relay compiled-process boundary', () => {
|
|
|
821
836
|
const assistantID = origin.attachmentAssistant.id;
|
|
822
837
|
const uploadPath = `/api/yuri/assistants/${assistantID}/contact/attachments`;
|
|
823
838
|
for (const headers of [{}, { authorization: 'Bearer invalid-token' }]) {
|
|
824
|
-
expect((await client.fetch(`${uploadPath}/denied`, { method: 'PUT', headers, body: previewPng })).status).toBe(
|
|
839
|
+
expect((await client.fetch(`${uploadPath}/denied`, { method: 'PUT', headers, body: previewPng })).status).toBe(403);
|
|
825
840
|
}
|
|
826
841
|
const attachmentParts: Awaited<ReturnType<typeof uploadAssistantAttachment>>[] = [];
|
|
827
842
|
for (const [index, file] of [
|
|
@@ -839,7 +854,7 @@ describe('private relay compiled-process boundary', () => {
|
|
|
839
854
|
const download = await runtimeFetch(`${uploadPath}/${descriptor.attachmentID}`);
|
|
840
855
|
expect(download.status).toBe(200);
|
|
841
856
|
expect(Buffer.from(await download.arrayBuffer())).toEqual(Buffer.from(await file.arrayBuffer()));
|
|
842
|
-
expect((await client.fetch(`${uploadPath}/${descriptor.attachmentID}`)).status).toBe(
|
|
857
|
+
expect((await client.fetch(`${uploadPath}/${descriptor.attachmentID}`)).status).toBe(403);
|
|
843
858
|
}
|
|
844
859
|
const admission = await runtimeFetch(`/api/yuri/assistants/${assistantID}/messages`, {
|
|
845
860
|
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
|
@@ -854,8 +869,8 @@ describe('private relay compiled-process boundary', () => {
|
|
|
854
869
|
const files = createWebFilesAPI({ getDirectory: () => path.dirname(origin.previewPath) });
|
|
855
870
|
expect(Buffer.byteLength(origin.guiBundle.code)).toBeGreaterThan(2_270_000);
|
|
856
871
|
for (const route of ['/api/plugin', '/api/plugin/gui?id=preview-fixture', `/api/fs/stat?path=${encodeURIComponent(origin.previewPath)}`, `/api/fs/raw?path=${encodeURIComponent(origin.previewPath)}`]) {
|
|
857
|
-
expect((await client.fetch(route)).status).toBe(
|
|
858
|
-
expect((await client.fetch(route, { headers: { authorization: 'Bearer invalid-token' } })).status).toBe(
|
|
872
|
+
expect((await client.fetch(route)).status).toBe(403);
|
|
873
|
+
expect((await client.fetch(route, { headers: { authorization: 'Bearer invalid-token' } })).status).toBe(403);
|
|
859
874
|
}
|
|
860
875
|
expect((await gui.plugin.list()).data).toEqual(origin.pluginInventory);
|
|
861
876
|
expect((await gui.plugin.gui({ id: 'preview-fixture' })).data).toEqual(origin.guiBundle);
|
|
@@ -908,10 +923,10 @@ describe('private relay compiled-process boundary', () => {
|
|
|
908
923
|
});
|
|
909
924
|
try {
|
|
910
925
|
const deniedSpeech = await client.fetch('/api/tts/speak', { method: 'POST' });
|
|
911
|
-
expect(deniedSpeech.status).toBe(
|
|
912
|
-
expect((await client.fetch('/api/voice/session', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: '{"kind":"tts"}' })).status).toBe(
|
|
913
|
-
expect((await client.fetch('/api/voice/volcengine')).status).toBe(
|
|
914
|
-
expect((await client.fetch('/api/voice/volcengine', { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: '{}' })).status).toBe(
|
|
926
|
+
expect(deniedSpeech.status).toBe(403);
|
|
927
|
+
expect((await client.fetch('/api/voice/session', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: '{"kind":"tts"}' })).status).toBe(403);
|
|
928
|
+
expect((await client.fetch('/api/voice/volcengine')).status).toBe(403);
|
|
929
|
+
expect((await client.fetch('/api/voice/volcengine', { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: '{}' })).status).toBe(403);
|
|
915
930
|
const saved = await realFetch(`http://127.0.0.1:${origin.port}/api/voice/settings`, {
|
|
916
931
|
method: 'PUT', headers: { authorization: 'Bearer client-token', 'Content-Type': 'application/json' },
|
|
917
932
|
body: JSON.stringify({ apiKey: 'fixture-speech-key', voice: 'zh_female_vv_uranus_bigtts', showMessageTTSButtons: true, voiceProvider: 'volcengine', dictationEnabled: true, sttProvider: 'volcengine' }),
|
|
@@ -978,7 +993,7 @@ describe('private relay compiled-process boundary', () => {
|
|
|
978
993
|
releaseAsset: async () => { released = true; },
|
|
979
994
|
} });
|
|
980
995
|
const deniedImage = await client.fetch('/api/fs/raw?path=%2Fremote%2Ficons-zoom.png');
|
|
981
|
-
expect(deniedImage.status).toBe(
|
|
996
|
+
expect(deniedImage.status).toBe(403);
|
|
982
997
|
for (const intent of ['inline', 'preview'] as const) {
|
|
983
998
|
received.length = 0;
|
|
984
999
|
ended = false;
|
|
@@ -133,6 +133,7 @@ export const createRelayService = ({
|
|
|
133
133
|
// regeneration — see identity.js/signing-key.js.
|
|
134
134
|
readSettingsStrict,
|
|
135
135
|
getLocalPort,
|
|
136
|
+
authorizeRequest = async () => false,
|
|
136
137
|
// Returns true when any paired device or pending pairing session uses the
|
|
137
138
|
// relay transport. The relay lifecycle is driven purely by this demand.
|
|
138
139
|
hasRelayDemand = async () => false,
|
|
@@ -316,6 +317,7 @@ export const createRelayService = ({
|
|
|
316
317
|
if (hostClients.has(relayUrl)) continue;
|
|
317
318
|
const hostClient = startRelayHost({
|
|
318
319
|
relayUrl,
|
|
320
|
+
authorizeRequest,
|
|
319
321
|
identity,
|
|
320
322
|
getLocalPort,
|
|
321
323
|
logger,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// HTTP streams -> fetch http://127.0.0.1:<port> with streamed duplex bodies;
|
|
4
4
|
// WS streams -> `ws` client to the loopback WebSocket endpoints.
|
|
5
5
|
// The dispatcher NEVER injects credentials: tunneled requests authenticate
|
|
6
|
-
//
|
|
6
|
+
// using bearer/URL tokens, with Relay pairing admission before loopback forwarding.
|
|
7
7
|
// Spec: .opencode/plans/private-relay/01-protocol-spec.md (Layer 3).
|
|
8
8
|
|
|
9
9
|
import { WebSocket } from 'ws';
|
|
@@ -110,6 +110,7 @@ const isWsClosePayload = (parsed) => Boolean(parsed && typeof parsed === 'object
|
|
|
110
110
|
* getLocalPort: () => number,
|
|
111
111
|
* sendFrame: (plaintextFrame: Uint8Array, immediate?: boolean) => void | Promise<void>,
|
|
112
112
|
* getBufferedAmount: () => number,
|
|
113
|
+
* authorizeRequest?: (req: { method: string, url: string, headers: Record<string, string> }) => Promise<boolean>,
|
|
113
114
|
* createWebSocket?: (url: string, protocols: string[] | undefined, options: { headers: Record<string, string> }) => import('ws').WebSocket,
|
|
114
115
|
* }} deps
|
|
115
116
|
*/
|
|
@@ -118,6 +119,7 @@ export const createTunnelHost = ({
|
|
|
118
119
|
getLocalPort,
|
|
119
120
|
sendFrame,
|
|
120
121
|
getBufferedAmount,
|
|
122
|
+
authorizeRequest = async () => false,
|
|
121
123
|
createWebSocket = (url, protocols, options) => new WebSocket(url, protocols, options),
|
|
122
124
|
}) => {
|
|
123
125
|
/** @type {Map<number, { kind: 'http', abort: AbortController, body: ReadableStreamDefaultController | null } | { kind: 'ws', socket: WebSocket, opened: boolean }>} */
|
|
@@ -466,6 +468,29 @@ export const createTunnelHost = ({
|
|
|
466
468
|
if (closed) return;
|
|
467
469
|
const frame = decodeTunnelFrame(plaintextFrame);
|
|
468
470
|
|
|
471
|
+
if (frame.frameType === TunnelFrameType.HttpRequest || frame.frameType === TunnelFrameType.WsOpen) {
|
|
472
|
+
const websocket = frame.frameType === TunnelFrameType.WsOpen;
|
|
473
|
+
let authorized = false;
|
|
474
|
+
try {
|
|
475
|
+
const request = decodeJsonPayload(frame.payload, websocket ? isWsOpenPayload : isHttpRequestPayload);
|
|
476
|
+
authorized = await authorizeRequest({
|
|
477
|
+
method: websocket ? 'GET' : request.method.toUpperCase(),
|
|
478
|
+
url: `${request.path}${request.query ? `?${request.query}` : ''}`,
|
|
479
|
+
headers: websocket
|
|
480
|
+
? { upgrade: 'websocket', 'x-yuri-relay-connection': connectionId }
|
|
481
|
+
: buildRequestHeaders(request.headers),
|
|
482
|
+
}) === true;
|
|
483
|
+
} catch {
|
|
484
|
+
authorized = false;
|
|
485
|
+
}
|
|
486
|
+
if (closed) return;
|
|
487
|
+
if (!authorized) {
|
|
488
|
+
if (websocket) await sendAbort(frame.streamId, 'Relay pairing authorization required');
|
|
489
|
+
else await syntheticResponse(frame.streamId, 403, 'Relay pairing authorization required');
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
|
|
469
494
|
// WS message frames can be fragmented; everything else arrives whole.
|
|
470
495
|
if (frame.frameType === TunnelFrameType.WsText || frame.frameType === TunnelFrameType.WsBinary) {
|
|
471
496
|
const message = assembler.push(frame);
|
|
@@ -22,6 +22,27 @@ import { createTunnelHost, isTunnelWsPathAllowed } from './tunnel-host.js';
|
|
|
22
22
|
const textEncoder = new TextEncoder();
|
|
23
23
|
const textDecoder = new TextDecoder();
|
|
24
24
|
|
|
25
|
+
describe('relay admission before loopback access', () => {
|
|
26
|
+
it('denies HTTP and WebSocket traffic without an authorization provider', async () => {
|
|
27
|
+
const fetchMock = vi.spyOn(globalThis, 'fetch').mockResolvedValue(new Response('{}'));
|
|
28
|
+
const dial = vi.fn(() => new FakeWebSocket('unused'));
|
|
29
|
+
const frames = [];
|
|
30
|
+
const host = createTunnelHost({ connectionId: 'unpaired', getLocalPort: () => 9,
|
|
31
|
+
sendFrame: (frame) => frames.push(decodeTunnelFrame(frame)), getBufferedAmount: () => 0, createWebSocket: dial });
|
|
32
|
+
try {
|
|
33
|
+
await host.handleFrame(encodeTunnelFrame(TunnelFrameType.HttpRequest, 1, encodeJsonPayload({
|
|
34
|
+
method: 'GET', path: '/auth/session', query: '', headers: { authorization: 'Bearer ssh-token' },
|
|
35
|
+
})));
|
|
36
|
+
await host.handleFrame(encodeTunnelFrame(TunnelFrameType.WsOpen, 2, encodeJsonPayload({
|
|
37
|
+
path: '/api/terminal/ws', query: 'yuri_url_token=ssh-url-token',
|
|
38
|
+
})));
|
|
39
|
+
expect(fetchMock).not.toHaveBeenCalled();
|
|
40
|
+
expect(dial).not.toHaveBeenCalled();
|
|
41
|
+
expect(JSON.parse(textDecoder.decode(frames[0].payload)).status).toBe(403);
|
|
42
|
+
} finally { host.close(); fetchMock.mockRestore(); }
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
25
46
|
/** Minimal EventEmitter-shaped fake used only by createTunnelHost tests. */
|
|
26
47
|
class FakeWebSocket {
|
|
27
48
|
static OPEN = 1;
|
|
@@ -83,7 +104,7 @@ describe('negotiated JSON response compression', () => {
|
|
|
83
104
|
headers: { 'content-type': contentType, 'content-length': String(raw.byteLength) },
|
|
84
105
|
}));
|
|
85
106
|
const frames = [];
|
|
86
|
-
const host = createTunnelHost({ connectionId: 'compression-test', getLocalPort: () => 9,
|
|
107
|
+
const host = createTunnelHost({ authorizeRequest: async () => true, connectionId: 'compression-test', getLocalPort: () => 9,
|
|
87
108
|
sendFrame: (frame) => { frames.push(decodeTunnelFrame(frame)); }, getBufferedAmount: () => 0 });
|
|
88
109
|
try {
|
|
89
110
|
await host.handleFrame(encodeTunnelFrame(TunnelFrameType.HttpRequest, 1, encodeJsonPayload({
|
|
@@ -112,7 +133,7 @@ describe('negotiated JSON response compression', () => {
|
|
|
112
133
|
headers: { 'content-type': 'text/event-stream; charset=utf-8' },
|
|
113
134
|
}));
|
|
114
135
|
const frames = [];
|
|
115
|
-
const host = createTunnelHost({ connectionId: 'sse-gzip-test', getLocalPort: () => 9,
|
|
136
|
+
const host = createTunnelHost({ authorizeRequest: async () => true, connectionId: 'sse-gzip-test', getLocalPort: () => 9,
|
|
116
137
|
sendFrame: (frame) => { frames.push(decodeTunnelFrame(frame)); }, getBufferedAmount: () => 0 });
|
|
117
138
|
const bodies = () => frames.filter((frame) => frame.frameType === TunnelFrameType.HttpBody).map((frame) => textDecoder.decode(frame.payload));
|
|
118
139
|
try {
|
|
@@ -135,7 +156,7 @@ describe('remote desktop send scheduling', () => {
|
|
|
135
156
|
it.each(['/api/remote-desktop/ws', '/api/event/ws'])('only remote desktop requests immediate data flushes: %s', async (path) => {
|
|
136
157
|
FakeWebSocket.reset();
|
|
137
158
|
const sent = [];
|
|
138
|
-
const host = createTunnelHost({ connectionId: 'scheduling', getLocalPort: () => 9,
|
|
159
|
+
const host = createTunnelHost({ authorizeRequest: async () => true, connectionId: 'scheduling', getLocalPort: () => 9,
|
|
139
160
|
sendFrame: (frame, immediate) => { sent.push({ ...decodeTunnelFrame(frame), immediate }); },
|
|
140
161
|
getBufferedAmount: () => 0, createWebSocket: (url, protocols) => new FakeWebSocket(url, protocols) });
|
|
141
162
|
try {
|
|
@@ -184,6 +205,7 @@ describe('createTunnelHost WS path allowlist', () => {
|
|
|
184
205
|
/** @type {Uint8Array[]} */
|
|
185
206
|
const outbound = [];
|
|
186
207
|
const host = createTunnelHost({
|
|
208
|
+
authorizeRequest: async () => true,
|
|
187
209
|
connectionId: 'test-conn',
|
|
188
210
|
getLocalPort: () => 9,
|
|
189
211
|
sendFrame: (frame) => {
|
|
@@ -232,6 +254,7 @@ describe('createTunnelHost WS fragment ordering', () => {
|
|
|
232
254
|
};
|
|
233
255
|
|
|
234
256
|
const host = createTunnelHost({
|
|
257
|
+
authorizeRequest: async () => true,
|
|
235
258
|
connectionId: 'test-conn',
|
|
236
259
|
getLocalPort: () => 9,
|
|
237
260
|
sendFrame,
|
|
@@ -314,6 +337,7 @@ describe('createTunnelHost WS fragment ordering', () => {
|
|
|
314
337
|
};
|
|
315
338
|
|
|
316
339
|
const host = createTunnelHost({
|
|
340
|
+
authorizeRequest: async () => true,
|
|
317
341
|
connectionId: 'test-conn',
|
|
318
342
|
getLocalPort: () => 9,
|
|
319
343
|
sendFrame,
|
|
@@ -129,7 +129,7 @@ it('stops native control when the device is revoked', { timeout: 10000 }, async
|
|
|
129
129
|
});
|
|
130
130
|
it('carries screen frames and validated input through the real Relay WS dispatcher and auth gates', async () => {
|
|
131
131
|
const frames = [];
|
|
132
|
-
const host = createTunnelHost({ connectionId: 'desktop-test', getLocalPort: () => port,
|
|
132
|
+
const host = createTunnelHost({ authorizeRequest: async () => true, connectionId: 'desktop-test', getLocalPort: () => port,
|
|
133
133
|
sendFrame: frame => { frames.push(decodeTunnelFrame(frame)); }, getBufferedAmount: () => 0 });
|
|
134
134
|
try {
|
|
135
135
|
await host.handleFrame(encodeTunnelFrame(TunnelFrameType.WsOpen, 2, encodeJsonPayload({ path: '/api/remote-desktop/ws', query: `yuri_url_token=${token}` })));
|
|
@@ -157,7 +157,7 @@ it('carries screen frames and validated input through the real Relay WS dispatch
|
|
|
157
157
|
it('releases failed capture ownership and reconnects through the authenticated Relay dispatcher', async () => {
|
|
158
158
|
adapter.start.mockRejectedValueOnce(Object.assign(new Error('capture_timeout'), { code: 'capture_timeout' }));
|
|
159
159
|
const frames = [];
|
|
160
|
-
const host = createTunnelHost({ connectionId: 'desktop-recovery-test', getLocalPort: () => port,
|
|
160
|
+
const host = createTunnelHost({ authorizeRequest: async () => true, connectionId: 'desktop-recovery-test', getLocalPort: () => port,
|
|
161
161
|
sendFrame: frame => { frames.push(decodeTunnelFrame(frame)); }, getBufferedAmount: () => 0 });
|
|
162
162
|
const open = id => host.handleFrame(encodeTunnelFrame(TunnelFrameType.WsOpen, id,
|
|
163
163
|
encodeJsonPayload({ path: '/api/remote-desktop/ws', query: `yuri_url_token=${token}` })));
|
|
@@ -5,6 +5,8 @@ This module owns Yuri UI authentication for browser access, including password s
|
|
|
5
5
|
|
|
6
6
|
Trusted-device access has one durable credential model: a remote client bearer token stored by `packages/web/server/lib/client-auth/remote-clients.js`. Password, passkey, and Pairing v2 are issuance methods for that credential, not separate credential systems. Issued client tokens are returned once, stored server-side only as hashes, and are later authenticated via `Authorization: Bearer yuri_client_...`.
|
|
7
7
|
|
|
8
|
+
Relay admission additionally requires an active client record with `usesRelay: true`, `authMethod: 'pairing'`, and a pairing ID. `authorizeRelayRequest` enforces this before the tunnel forwards any HTTP/SSE request or WebSocket upgrade, including when the Host has no UI password. SSH/password/passkey credentials, owner cookies, and direct-only pairings do not grant Relay access. URL tokens resolve back to their issuing client and recheck current revocation/expiry and Relay permission. The only pre-credential route is `POST /api/client-auth/pairing/redeem`; its one-time secret validation also requires a Relay-enabled pairing when arriving through Relay. Direct authentication behavior is unchanged.
|
|
9
|
+
|
|
8
10
|
Pairing v2 is implemented by `packages/web/server/lib/client-auth/pairing.js`. It stores short-lived one-time pairing sessions with hashed secrets, exposes create/cancel/redeem routes under `/api/client-auth/pairing/*`, and redeems a valid pairing secret into the same remote client token used by password/passkey trusted-device flows.
|
|
9
11
|
|
|
10
12
|
Client deduplication is scoped by device `dedupeKey`, `usesRelay`, and the pairing's canonical `relayUrl`. The create route records the actual advertised Relay candidate (including a default or environment-selected endpoint), and redemption uses this stored scope even when it arrives over LAN. Re-pairing through the same Relay replaces that connection's credential; another Relay or direct-only pairing retains an independent client record, label, credential, and revocation. The endpoint is internal persistence metadata, not a client-supplied redemption override. Legacy records without `relayUrl` remain readable with an unknown Relay scope; new endpoint-specific pairings preserve them rather than guessing which connection to overwrite. No stored credential conversion is needed.
|
|
@@ -20,6 +22,7 @@ Remote desktop uses the exact `/api/remote-desktop/ws` scoped URL-token path, mi
|
|
|
20
22
|
## Public exports (ui-auth.js)
|
|
21
23
|
- `isUrlAuthWebSocketPath(pathname)`: true when a WebSocket upgrade may authenticate with `yuri_url_token` (exact terminal/dictation/event/realtime-proxy paths, plus prefix `/api/preview/proxy/` for Preview HMR). Keep in sync with tunnel-host `isTunnelWsPathAllowed`.
|
|
22
24
|
- `createUiAuth({ password, cookieName, sessionTtlMs, readSettingsFromDiskMigrated })`: creates UI auth controller with methods:
|
|
25
|
+
- `authorizeRelayRequest(req)`
|
|
23
26
|
- `enabled`
|
|
24
27
|
- `requireAuth(req, res, next)`
|
|
25
28
|
- `handleSessionStatus(req, res)`
|
|
@@ -499,6 +499,31 @@ export const createUiAuth = ({
|
|
|
499
499
|
client: clientAuth?.client || null,
|
|
500
500
|
});
|
|
501
501
|
|
|
502
|
+
const authorizeRelayRequest = async (req) => {
|
|
503
|
+
const pathname = new URL(req.url, 'http://127.0.0.1').pathname;
|
|
504
|
+
// Pairing redeems its one-time secret before a client credential exists.
|
|
505
|
+
if (req.method === 'POST' && pathname === '/api/client-auth/pairing/redeem') return true;
|
|
506
|
+
try {
|
|
507
|
+
const urlAuth = authenticateUrlAuthToken(req);
|
|
508
|
+
let client;
|
|
509
|
+
if (urlAuth) {
|
|
510
|
+
const id = clientAuthClientId(urlAuth);
|
|
511
|
+
const clients = await clientAuthController?.listClients?.();
|
|
512
|
+
client = clients?.find((entry) => entry.id === id);
|
|
513
|
+
} else {
|
|
514
|
+
const token = getBearerTokenFromRequest(req);
|
|
515
|
+
if (!token) return false;
|
|
516
|
+
const result = await clientAuthController?.authenticateBearerToken?.(token, req);
|
|
517
|
+
if (!result?.ok) return false;
|
|
518
|
+
client = result.client;
|
|
519
|
+
}
|
|
520
|
+
return client?.usesRelay === true && client.authMethod === 'pairing' && Boolean(client.pairingId)
|
|
521
|
+
&& !client.revokedAt && (!client.expiresAt || Date.parse(client.expiresAt) > Date.now());
|
|
522
|
+
} catch {
|
|
523
|
+
return false;
|
|
524
|
+
}
|
|
525
|
+
};
|
|
526
|
+
|
|
502
527
|
if (!normalizedPassword) {
|
|
503
528
|
const setSessionCookie = (req, res, token, ttlMs = sessionTtlMs) => {
|
|
504
529
|
const secure = isSecureRequest(req);
|
|
@@ -565,6 +590,7 @@ export const createUiAuth = ({
|
|
|
565
590
|
|
|
566
591
|
return {
|
|
567
592
|
enabled: false,
|
|
593
|
+
authorizeRelayRequest,
|
|
568
594
|
requireAuth,
|
|
569
595
|
requireSessionAuth,
|
|
570
596
|
resolveAuthContext,
|
|
@@ -975,6 +1001,7 @@ export const createUiAuth = ({
|
|
|
975
1001
|
|
|
976
1002
|
return {
|
|
977
1003
|
enabled: true,
|
|
1004
|
+
authorizeRelayRequest,
|
|
978
1005
|
requireAuth,
|
|
979
1006
|
requireSessionAuth,
|
|
980
1007
|
resolveAuthContext,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { afterAll, describe, expect, it } from '
|
|
1
|
+
import { afterAll, describe, expect, it } from 'vitest';
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import os from 'node:os';
|
|
4
4
|
import path from 'node:path';
|
|
@@ -69,6 +69,47 @@ describe('isUrlAuthWebSocketPath', () => {
|
|
|
69
69
|
});
|
|
70
70
|
|
|
71
71
|
describe('ui auth client credential seam', () => {
|
|
72
|
+
for (const password of ['', 'secret']) {
|
|
73
|
+
it(`relay requires a current relay pairing grant for bearer and URL credentials (password=${Boolean(password)})`, async () => {
|
|
74
|
+
const createUiAuth = await loadCreateUiAuth();
|
|
75
|
+
const clients = [
|
|
76
|
+
{ id: 'ssh', clientKind: 'desktop-local', authMethod: 'password', usesRelay: false },
|
|
77
|
+
{ id: 'direct', authMethod: 'pairing', pairingId: 'direct-pairing', usesRelay: false },
|
|
78
|
+
{ id: 'paired', authMethod: 'pairing', pairingId: 'relay-pairing', usesRelay: true },
|
|
79
|
+
{ id: 'legacy', authMethod: 'password', usesRelay: true },
|
|
80
|
+
];
|
|
81
|
+
const auth = createUiAuth({ password, clientAuthController: {
|
|
82
|
+
listClients: async () => clients,
|
|
83
|
+
authenticateBearerToken: async (token) => {
|
|
84
|
+
const client = clients.find((entry) => entry.id === token);
|
|
85
|
+
return client ? { ok: true, clientId: client.id, client } : null;
|
|
86
|
+
},
|
|
87
|
+
} });
|
|
88
|
+
try {
|
|
89
|
+
for (const client of clients) {
|
|
90
|
+
const req = { method: 'GET', url: '/auth/session', headers: { authorization: `Bearer ${client.id}` } };
|
|
91
|
+
expect(await auth.authorizeRelayRequest(req)).toBe(client.id === 'paired');
|
|
92
|
+
const res = createResponse();
|
|
93
|
+
await auth.handleUrlAuthToken(req, res);
|
|
94
|
+
const wsReq = { method: 'GET', url: `/api/terminal/ws?yuri_url_token=${res.body.token}`, headers: { upgrade: 'websocket' } };
|
|
95
|
+
expect(await auth.authorizeRelayRequest(wsReq)).toBe(client.id === 'paired');
|
|
96
|
+
if (client.id === 'paired') {
|
|
97
|
+
client.revokedAt = new Date().toISOString();
|
|
98
|
+
expect(await auth.authorizeRelayRequest(req)).toBe(false);
|
|
99
|
+
expect(await auth.authorizeRelayRequest(wsReq)).toBe(false);
|
|
100
|
+
delete client.revokedAt;
|
|
101
|
+
client.expiresAt = new Date(0).toISOString();
|
|
102
|
+
expect(await auth.authorizeRelayRequest(wsReq)).toBe(false);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
expect(await auth.authorizeRelayRequest({ method: 'GET', url: '/health', headers: {} })).toBe(false);
|
|
106
|
+
expect(await auth.authorizeRelayRequest({ method: 'POST', url: '/auth/session', headers: { cookie: 'yuri_ui_session=owner' } })).toBe(false);
|
|
107
|
+
expect(await auth.authorizeRelayRequest({ method: 'POST', url: '/api/client-auth/pairing/redeem', headers: {} })).toBe(true);
|
|
108
|
+
expect(await auth.authorizeRelayRequest({ method: 'GET', url: '/api/client-auth/pairing/redeem', headers: {} })).toBe(false);
|
|
109
|
+
} finally { auth.dispose(); }
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
72
113
|
it('accepts bearer client credentials when UI password auth is enabled', async () => {
|
|
73
114
|
const createUiAuth = await loadCreateUiAuth();
|
|
74
115
|
const auth = createUiAuth({
|
|
@@ -106,7 +106,7 @@ describe('Web/Electron shared backend GUI response', () => {
|
|
|
106
106
|
const frames = [];
|
|
107
107
|
let finish;
|
|
108
108
|
const ended = new Promise((resolve) => { finish = resolve; });
|
|
109
|
-
const host = createTunnelHost({ connectionId: 'gui-response', getLocalPort: () => port, getBufferedAmount: () => 0,
|
|
109
|
+
const host = createTunnelHost({ authorizeRequest: async () => true, connectionId: 'gui-response', getLocalPort: () => port, getBufferedAmount: () => 0,
|
|
110
110
|
sendFrame: (bytes) => { const frame = decodeTunnelFrame(bytes); frames.push(frame); if (frame.frameType === TunnelFrameType.StreamEnd) finish(); },
|
|
111
111
|
});
|
|
112
112
|
try {
|