From 35aae7cd46a5992acab8e514a3b0b2d097deeef6 Mon Sep 17 00:00:00 2001 From: vian Date: Sat, 26 Sep 2026 23:26:23 +0530 Subject: [PATCH] feat: expose video call APIs through RocketChatDesktop --- docs/pexip-auth-credentials.md | 4 ++-- src/servers/main/preloadCoverage.main.spec.ts | 6 +++++- src/videoCallWindow/preload/index.ts | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/pexip-auth-credentials.md b/docs/pexip-auth-credentials.md index f0cd54bda4..0bb4e54afb 100644 --- a/docs/pexip-auth-credentials.md +++ b/docs/pexip-auth-credentials.md @@ -15,7 +15,7 @@ When a Pexip video call is opened from the Rocket.Chat Electron desktop app, the │ └── Opens Pexip in a dedicated video call window │ ├──────────────────────────────────────────────────────────┤ │ Pexip Page (inside video call window) │ -│ └── Calls window.videoCallWindow.getAuthCredentials() │ +│ └── Calls window.RocketChatDesktop.getAuthCredentials() │ │ → Returns { userId, authToken, serverUrl } │ │ └── Uses credentials to authenticate the RC iframe │ └──────────────────────────────────────────────────────────┘ @@ -23,7 +23,7 @@ When a Pexip video call is opened from the Rocket.Chat Electron desktop app, the ## API -### `window.videoCallWindow.getAuthCredentials()` +### `window.RocketChatDesktop.getAuthCredentials()` Returns a Promise that resolves to the user's credentials or `null`. diff --git a/src/servers/main/preloadCoverage.main.spec.ts b/src/servers/main/preloadCoverage.main.spec.ts index 8f96864151..c92b20f719 100644 --- a/src/servers/main/preloadCoverage.main.spec.ts +++ b/src/servers/main/preloadCoverage.main.spec.ts @@ -669,9 +669,13 @@ describe('preload modules coverage (node env)', () => { }); require('../../videoCallWindow/preload/index'); const api = exposeInMainWorld.mock.calls.find( - ([name]) => name === 'videoCallWindow' + ([name]) => name === 'RocketChatDesktop' )?.[1]; expect(api).toBeDefined(); + expect(exposeInMainWorld).not.toHaveBeenCalledWith( + 'videoCallWindow', + expect.anything() + ); api.openInMainWindow('/channel/general'); api.openInMainWindow('https://evil.example'); api.openInMainWindow('//host'); diff --git a/src/videoCallWindow/preload/index.ts b/src/videoCallWindow/preload/index.ts index f7e2a913a3..6dbc5e25a2 100644 --- a/src/videoCallWindow/preload/index.ts +++ b/src/videoCallWindow/preload/index.ts @@ -11,7 +11,7 @@ const isRelativeRoute = (path: unknown): path is string => !path.startsWith('/\\'); // Expose any necessary APIs to the webview content -contextBridge.exposeInMainWorld('videoCallWindow', { +contextBridge.exposeInMainWorld('RocketChatDesktop', { // Navigate the main app window to an in-app route and bring it to the front. // `path` is a server-relative route, e.g. "/channel/general". openInMainWindow: (path: string) => {