Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat: send token to services ws (#335)

gbirman8e8edcf356ac
diff --git a/js/app/packages/service-storage/websocket.ts b/js/app/packages/service-storage/websocket.ts
index c43a15e571..4d07c922e2 100644
--- a/js/app/packages/service-storage/websocket.ts
+++ b/js/app/packages/service-storage/websocket.ts
@@ -1,6 +1,8 @@
import { SERVER_HOSTS } from '@core/constant/servers';
+import { getMacroApiToken } from '@service-auth/fetch';
import {
ConstantBackoff,
+ type UrlResolver,
type Websocket,
WebsocketBuilder,
WebsocketEvent,
@@ -20,7 +22,13 @@ const HEARTBEAT_INTERVAL = 300000;
*/
const HEARTBEAT_TIMEOUT = 5000;
-export const ws = new WebsocketBuilder(SERVER_HOSTS['websocket-service'])
+const getUrl: UrlResolver = async () => {
+ const token = await getMacroApiToken();
+ const baseUrl = SERVER_HOSTS['websocket-service'];
+ return `${baseUrl}?token=${token}`;
+};
+
+export const ws = new WebsocketBuilder(getUrl)
.withBackoff(new ConstantBackoff(1500))
.withHeartbeat({
pingMessage: JSON.stringify({ action: 'wsping' }),