forked from wavetermdev/waveterm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauthkey.ts
More file actions
23 lines (19 loc) · 826 Bytes
/
authkey.ts
File metadata and controls
23 lines (19 loc) · 826 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Copyright 2025, Command Line Inc.
// SPDX-License-Identifier: Apache-2.0
import { ipcMain } from "electron";
import { getWebServerEndpoint, getWSServerEndpoint } from "../frontend/util/endpoints";
const AuthKeyHeader = "X-AuthKey";
export const WaveAuthKeyEnv = "WAVETERM_AUTH_KEY";
export const AuthKey = crypto.randomUUID();
ipcMain.on("get-auth-key", (event) => {
event.returnValue = AuthKey;
});
export function configureAuthKeyRequestInjection(session: Electron.Session) {
const filter: Electron.WebRequestFilter = {
urls: [`${getWebServerEndpoint()}/*`, `${getWSServerEndpoint()}/*`],
};
session.webRequest.onBeforeSendHeaders(filter, (details, callback) => {
details.requestHeaders[AuthKeyHeader] = AuthKey;
callback({ requestHeaders: details.requestHeaders });
});
}