channel-worker 1.0.6 → 1.0.7

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.
Files changed (2) hide show
  1. package/lib/nst-manager.js +33 -0
  2. package/package.json +3 -2
@@ -128,6 +128,39 @@ class NstManager {
128
128
  console.log(`[nst] Starting browser for profile: ${profileId}`);
129
129
  const res = await this.client.browsers().startBrowser(profileId);
130
130
  console.log(`[nst] Browser started`);
131
+
132
+ // Set nstProfileId in chrome.storage via CDP
133
+ try {
134
+ // Wait for browser to fully start
135
+ await new Promise(r => setTimeout(r, 3000));
136
+
137
+ const debugInfo = await this.client.browsers().getBrowserDebugger(profileId);
138
+ const wsUrl = debugInfo?.data?.webSocketDebuggerUrl;
139
+ if (wsUrl) {
140
+ const WebSocket = require('ws');
141
+ const ws = new WebSocket(wsUrl);
142
+ await new Promise((resolve, reject) => {
143
+ const timeout = setTimeout(() => { ws.close(); reject(new Error('CDP timeout')); }, 10000);
144
+ ws.on('open', () => {
145
+ // Navigate a new tab to set storage
146
+ ws.send(JSON.stringify({
147
+ id: 1,
148
+ method: 'Runtime.evaluate',
149
+ params: {
150
+ expression: `chrome.storage && chrome.storage.local ? chrome.storage.local.set({nstProfileId: "${profileIdOrName}"}) : null`,
151
+ awaitPromise: true,
152
+ },
153
+ }));
154
+ setTimeout(() => { clearTimeout(timeout); ws.close(); resolve(); }, 2000);
155
+ });
156
+ ws.on('error', (e) => { clearTimeout(timeout); reject(e); });
157
+ });
158
+ console.log(`[nst] Profile ID "${profileIdOrName}" set in extension storage`);
159
+ }
160
+ } catch (e) {
161
+ console.log(`[nst] Could not set profile ID in storage: ${e.message}`);
162
+ }
163
+
131
164
  return { profileId, response: res };
132
165
  }
133
166
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "channel-worker",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "Channel Manager worker daemon — runs on remote machines to execute video pipeline jobs",
5
5
  "main": "lib/daemon.js",
6
6
  "bin": {
@@ -16,7 +16,8 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "node-fetch": "^3.3.2",
19
- "nstbrowser-sdk-node": "^0.1.1"
19
+ "nstbrowser-sdk-node": "^0.1.1",
20
+ "ws": "^8.18.0"
20
21
  },
21
22
  "engines": {
22
23
  "node": ">=18"