dp-worker 0.1.1 → 0.1.3
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/dist/agent/agent.d.ts +6 -13
- package/dist/agent/agent.js +9 -19
- package/dist/agent/agent.js.map +1 -1
- package/dist/browser/chrome-process.d.ts +3 -0
- package/dist/browser/chrome-process.js +174 -25
- package/dist/browser/chrome-process.js.map +1 -1
- package/dist/browser/manager.d.ts +4 -4
- package/dist/browser/manager.js +94 -44
- package/dist/browser/manager.js.map +1 -1
- package/dist/center/session-sync.d.ts +16 -77
- package/dist/center/session-sync.js +62 -302
- package/dist/center/session-sync.js.map +1 -1
- package/dist/chrome-extension/omni-flow/background.js +561 -0
- package/dist/chrome-extension/omni-flow/content.js +29 -0
- package/dist/chrome-extension/omni-flow/icon.png +0 -0
- package/dist/chrome-extension/omni-flow/inject.js +173 -0
- package/dist/chrome-extension/omni-flow/manifest.json +44 -0
- package/dist/chrome-extension/omni-flow/popup.css +819 -0
- package/dist/chrome-extension/omni-flow/popup.html +284 -0
- package/dist/chrome-extension/omni-flow/popup.js +1021 -0
- package/dist/chrome-extension/omni-flow/usage_guide.md +139 -0
- package/dist/index.js +15 -45
- package/dist/index.js.map +1 -1
- package/node_modules/dp-shared/dist/domain.d.ts +4 -4
- package/node_modules/dp-shared/dist/domain.d.ts.map +1 -1
- package/node_modules/dp-shared/dist/domain.js +4 -4
- package/node_modules/dp-shared/dist/domain.js.map +1 -1
- package/node_modules/dp-shared/dist/identities.d.ts +22 -0
- package/node_modules/dp-shared/dist/identities.d.ts.map +1 -1
- package/node_modules/dp-shared/dist/identities.js +3 -0
- package/node_modules/dp-shared/dist/identities.js.map +1 -1
- package/node_modules/dp-shared/dist/index.d.ts +1 -0
- package/node_modules/dp-shared/dist/index.d.ts.map +1 -1
- package/node_modules/dp-shared/dist/index.js +1 -0
- package/node_modules/dp-shared/dist/index.js.map +1 -1
- package/node_modules/dp-shared/dist/omni-flow-session.d.ts +85 -0
- package/node_modules/dp-shared/dist/omni-flow-session.d.ts.map +1 -0
- package/node_modules/dp-shared/dist/omni-flow-session.js +59 -0
- package/node_modules/dp-shared/dist/omni-flow-session.js.map +1 -0
- package/node_modules/dp-shared/dist/rest-contracts.d.ts +12 -1
- package/node_modules/dp-shared/dist/rest-contracts.d.ts.map +1 -1
- package/node_modules/dp-shared/dist/rest-contracts.js +5 -3
- package/node_modules/dp-shared/dist/rest-contracts.js.map +1 -1
- package/node_modules/dp-shared/dist/ws-protocol.d.ts +4 -4
- package/node_modules/dp-shared/src/admin-broadcast.ts +38 -0
- package/node_modules/dp-shared/src/audit-contracts.ts +33 -0
- package/node_modules/dp-shared/src/configs-contracts.ts +206 -0
- package/node_modules/dp-shared/src/db-rows.ts +280 -0
- package/node_modules/dp-shared/src/deploy-contracts.ts +38 -0
- package/node_modules/dp-shared/src/domain.ts +124 -0
- package/node_modules/dp-shared/src/identities.ts +36 -0
- package/node_modules/dp-shared/src/index.ts +25 -0
- package/node_modules/dp-shared/src/omni-flow-session.ts +80 -0
- package/node_modules/dp-shared/src/rest-contracts.ts +409 -0
- package/node_modules/dp-shared/src/task-history-contracts.ts +115 -0
- package/node_modules/dp-shared/src/worker-detail-contracts.ts +230 -0
- package/node_modules/dp-shared/src/ws-protocol.ts +435 -0
- package/package.json +2 -4
|
@@ -0,0 +1,561 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OmniFlow - Background Service Worker (Manifest V3)
|
|
3
|
+
* Handles proxy configuration lifecycle, WebRTC leak blocking, and quiet background proxy authentication.
|
|
4
|
+
* ENFORCED SAFE MODE: Always runs in Proxy Mode. Uses IP Leak Lock if proxy is unconfigured.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// Cached proxy credentials in memory for synchronous access during onAuthRequired challenges
|
|
8
|
+
let activeProxyConfig = null;
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
importScripts("dipclaw-config.js");
|
|
12
|
+
} catch (err) {
|
|
13
|
+
// Optional runtime bootstrap generated by dp-worker/dipclaw.
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Initialize settings on service worker startup
|
|
17
|
+
async function init() {
|
|
18
|
+
registerStealthInjection();
|
|
19
|
+
await setDipclawReady({ status: "starting", source: "dipclaw" });
|
|
20
|
+
try {
|
|
21
|
+
const bootstrap = getDipclawBootstrap();
|
|
22
|
+
if (bootstrap && bootstrap.sessionFile) {
|
|
23
|
+
await importDipclawSession(bootstrap);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Enforced Safe Mode: proxyEnabled is implicitly true. Without a
|
|
28
|
+
// Dipclaw-provided session file, use whatever OmniFlow already has in
|
|
29
|
+
// extension storage; a fresh profile falls back to IP Leak Lock.
|
|
30
|
+
let data = await storageGet([
|
|
31
|
+
'proxyConfig',
|
|
32
|
+
'timezoneEnabled',
|
|
33
|
+
'spoofTimezone',
|
|
34
|
+
'webrtcDisabled',
|
|
35
|
+
'languagesEnabled',
|
|
36
|
+
'hardwareMaskingEnabled',
|
|
37
|
+
'antiBotEnabled'
|
|
38
|
+
]);
|
|
39
|
+
data = await applyDipclawBootstrap(data);
|
|
40
|
+
activeProxyConfig = data.proxyConfig || null;
|
|
41
|
+
await applyProxySettings(activeProxyConfig);
|
|
42
|
+
|
|
43
|
+
// Default WebRTC protection to enabled (true)
|
|
44
|
+
const blockWebRTC = data.webrtcDisabled !== false;
|
|
45
|
+
await applyWebRTCSettings(blockWebRTC);
|
|
46
|
+
await setDipclawReady({
|
|
47
|
+
status: "ready",
|
|
48
|
+
source: "dipclaw",
|
|
49
|
+
sessionHash: null,
|
|
50
|
+
cookieCount: 0,
|
|
51
|
+
importedAt: new Date().toISOString()
|
|
52
|
+
});
|
|
53
|
+
} catch (err) {
|
|
54
|
+
const message = err && err.message ? err.message : String(err);
|
|
55
|
+
console.log("OmniFlow: Dipclaw bootstrap failed:", message);
|
|
56
|
+
await setDipclawReady({
|
|
57
|
+
status: "error",
|
|
58
|
+
source: "dipclaw",
|
|
59
|
+
error: message,
|
|
60
|
+
importedAt: new Date().toISOString()
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Listen for storage changes from the popup UI
|
|
66
|
+
chrome.storage.onChanged.addListener((changes, area) => {
|
|
67
|
+
if (area === 'local') {
|
|
68
|
+
let proxyConfigChanged = 'proxyConfig' in changes;
|
|
69
|
+
let webrtcChanged = 'webrtcDisabled' in changes;
|
|
70
|
+
|
|
71
|
+
if (proxyConfigChanged) {
|
|
72
|
+
chrome.storage.local.get(['proxyConfig'], (data) => {
|
|
73
|
+
activeProxyConfig = data.proxyConfig || null;
|
|
74
|
+
void applyProxySettings(activeProxyConfig);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (webrtcChanged) {
|
|
79
|
+
void applyWebRTCSettings(changes.webrtcDisabled.newValue);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
function getDipclawBootstrap() {
|
|
85
|
+
const bootstrap = globalThis.OMNI_FLOW_BOOTSTRAP_CONFIG;
|
|
86
|
+
if (!bootstrap || bootstrap.source !== "dipclaw") {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
return bootstrap;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
async function applyDipclawBootstrap(data) {
|
|
93
|
+
const bootstrap = getDipclawBootstrap();
|
|
94
|
+
if (!bootstrap) {
|
|
95
|
+
return data;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const next = { ...data };
|
|
99
|
+
const writes = {};
|
|
100
|
+
const removals = [];
|
|
101
|
+
|
|
102
|
+
if ("proxyConfig" in bootstrap) {
|
|
103
|
+
if (bootstrap.proxyConfig && bootstrap.proxyConfig.host && bootstrap.proxyConfig.port) {
|
|
104
|
+
next.proxyConfig = bootstrap.proxyConfig;
|
|
105
|
+
writes.proxyConfig = bootstrap.proxyConfig;
|
|
106
|
+
} else {
|
|
107
|
+
delete next.proxyConfig;
|
|
108
|
+
removals.push("proxyConfig");
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
for (const key of [
|
|
113
|
+
"timezoneEnabled",
|
|
114
|
+
"spoofTimezone",
|
|
115
|
+
"webrtcDisabled",
|
|
116
|
+
"languagesEnabled",
|
|
117
|
+
"hardwareMaskingEnabled",
|
|
118
|
+
"antiBotEnabled"
|
|
119
|
+
]) {
|
|
120
|
+
if (key in bootstrap) {
|
|
121
|
+
next[key] = bootstrap[key];
|
|
122
|
+
writes[key] = bootstrap[key];
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (Object.keys(writes).length > 0) {
|
|
127
|
+
await storageSet(writes);
|
|
128
|
+
}
|
|
129
|
+
if (removals.length > 0) {
|
|
130
|
+
await storageRemove(removals);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return next;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
async function importDipclawSession(bootstrap) {
|
|
137
|
+
await setDipclawReady({
|
|
138
|
+
status: "importing",
|
|
139
|
+
source: "dipclaw",
|
|
140
|
+
sessionHash: bootstrap.expectedSessionHash || null
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
const { payload, raw, hash } = await loadSessionPayload(bootstrap.sessionFile);
|
|
144
|
+
if (bootstrap.expectedSessionHash && hash !== bootstrap.expectedSessionHash) {
|
|
145
|
+
throw new Error(
|
|
146
|
+
`session hash mismatch: expected ${bootstrap.expectedSessionHash}, got ${hash}`
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
await clearAllCookies();
|
|
151
|
+
await storageClear();
|
|
152
|
+
|
|
153
|
+
const importedStorage = sanitizeImportedStorage(payload.extensionStorage);
|
|
154
|
+
await storageSet(importedStorage);
|
|
155
|
+
await setCookies(payload.cookies);
|
|
156
|
+
|
|
157
|
+
activeProxyConfig = importedStorage.proxyConfig || null;
|
|
158
|
+
await applyProxySettings(activeProxyConfig);
|
|
159
|
+
await applyWebRTCSettings(importedStorage.webrtcDisabled !== false);
|
|
160
|
+
|
|
161
|
+
await setDipclawReady({
|
|
162
|
+
status: "ready",
|
|
163
|
+
source: "dipclaw",
|
|
164
|
+
sessionHash: hash,
|
|
165
|
+
expectedSessionHash: bootstrap.expectedSessionHash || null,
|
|
166
|
+
cookieCount: payload.cookies.length,
|
|
167
|
+
importedAt: new Date().toISOString()
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
async function loadSessionPayload(filename) {
|
|
172
|
+
const url = chrome.runtime.getURL(filename);
|
|
173
|
+
const res = await fetch(url, { cache: "no-store" });
|
|
174
|
+
if (!res.ok) {
|
|
175
|
+
throw new Error(`failed to read bundled session ${filename}: ${res.status}`);
|
|
176
|
+
}
|
|
177
|
+
const raw = await res.text();
|
|
178
|
+
const hash = await sha256Hex(raw);
|
|
179
|
+
let payload;
|
|
180
|
+
try {
|
|
181
|
+
payload = JSON.parse(raw);
|
|
182
|
+
} catch (err) {
|
|
183
|
+
throw new Error("bundled OmniFlow session is not valid JSON");
|
|
184
|
+
}
|
|
185
|
+
validateSessionPayload(payload);
|
|
186
|
+
return { payload, raw, hash };
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function validateSessionPayload(payload) {
|
|
190
|
+
if (!payload || payload.app !== "OmniFlow") {
|
|
191
|
+
throw new Error("bundled session is not an OmniFlow export");
|
|
192
|
+
}
|
|
193
|
+
if (!payload.extensionStorage || typeof payload.extensionStorage !== "object") {
|
|
194
|
+
throw new Error("bundled session is missing extensionStorage");
|
|
195
|
+
}
|
|
196
|
+
if (!Array.isArray(payload.cookies)) {
|
|
197
|
+
throw new Error("bundled session cookies must be an array");
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function sanitizeImportedStorage(storage) {
|
|
202
|
+
const next = { ...storage };
|
|
203
|
+
delete next.formDraft;
|
|
204
|
+
delete next.dipclawReady;
|
|
205
|
+
delete next.standaloneWindowId;
|
|
206
|
+
return next;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
async function clearAllCookies() {
|
|
210
|
+
const allCookies = await cookiesGetAll({});
|
|
211
|
+
await Promise.all(allCookies.map((cookie) => removeCookieSafe(cookie)));
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
async function setCookies(cookies) {
|
|
215
|
+
await Promise.all(cookies.map((cookie) => setCookieSafe(cookie)));
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
async function removeCookieSafe(cookie) {
|
|
219
|
+
try {
|
|
220
|
+
await cookieRemove({
|
|
221
|
+
url: cookieUrl(cookie),
|
|
222
|
+
name: cookie.name,
|
|
223
|
+
...(cookie.storeId ? { storeId: cookie.storeId } : {})
|
|
224
|
+
});
|
|
225
|
+
} catch (err) {
|
|
226
|
+
// Some browser/system cookies cannot be removed by extensions. Keep
|
|
227
|
+
// import best-effort, matching the manual popup importer behavior.
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
async function setCookieSafe(cookie) {
|
|
232
|
+
try {
|
|
233
|
+
const setDetails = {
|
|
234
|
+
url: cookieUrl(cookie),
|
|
235
|
+
name: cookie.name,
|
|
236
|
+
value: cookie.value,
|
|
237
|
+
domain: cookie.domain,
|
|
238
|
+
path: cookie.path || "/",
|
|
239
|
+
secure: cookie.secure,
|
|
240
|
+
httpOnly: cookie.httpOnly,
|
|
241
|
+
sameSite: cookie.sameSite,
|
|
242
|
+
expirationDate: cookie.expirationDate,
|
|
243
|
+
...(cookie.storeId ? { storeId: cookie.storeId } : {})
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
if (cookie.session || !cookie.expirationDate) {
|
|
247
|
+
delete setDetails.expirationDate;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
await cookieSet(setDetails);
|
|
251
|
+
} catch (err) {
|
|
252
|
+
const message = err && err.message ? err.message : String(err);
|
|
253
|
+
console.log("OmniFlow Cookie Restorer:", message);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function cookieUrl(cookie) {
|
|
258
|
+
const domainName = String(cookie.domain || "").replace(/^\./, "");
|
|
259
|
+
const protocol = cookie.secure ? "https://" : "http://";
|
|
260
|
+
const path = cookie.path || "/";
|
|
261
|
+
return protocol + domainName + path;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function storageGet(keys) {
|
|
265
|
+
return new Promise((resolve) => {
|
|
266
|
+
chrome.storage.local.get(keys, (data) => resolve(data || {}));
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function storageSet(values) {
|
|
271
|
+
return new Promise((resolve, reject) => {
|
|
272
|
+
chrome.storage.local.set(values, () => {
|
|
273
|
+
if (chrome.runtime.lastError) reject(new Error(chrome.runtime.lastError.message));
|
|
274
|
+
else resolve();
|
|
275
|
+
});
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function storageRemove(keys) {
|
|
280
|
+
return new Promise((resolve, reject) => {
|
|
281
|
+
chrome.storage.local.remove(keys, () => {
|
|
282
|
+
if (chrome.runtime.lastError) reject(new Error(chrome.runtime.lastError.message));
|
|
283
|
+
else resolve();
|
|
284
|
+
});
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
function storageClear() {
|
|
289
|
+
return new Promise((resolve, reject) => {
|
|
290
|
+
chrome.storage.local.clear(() => {
|
|
291
|
+
if (chrome.runtime.lastError) reject(new Error(chrome.runtime.lastError.message));
|
|
292
|
+
else resolve();
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
function cookiesGetAll(details) {
|
|
298
|
+
return new Promise((resolve, reject) => {
|
|
299
|
+
chrome.cookies.getAll(details, (cookies) => {
|
|
300
|
+
if (chrome.runtime.lastError) reject(new Error(chrome.runtime.lastError.message));
|
|
301
|
+
else resolve(cookies || []);
|
|
302
|
+
});
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
function cookieRemove(details) {
|
|
307
|
+
return new Promise((resolve, reject) => {
|
|
308
|
+
chrome.cookies.remove(details, () => {
|
|
309
|
+
if (chrome.runtime.lastError) reject(new Error(chrome.runtime.lastError.message));
|
|
310
|
+
else resolve();
|
|
311
|
+
});
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
function cookieSet(details) {
|
|
316
|
+
return new Promise((resolve, reject) => {
|
|
317
|
+
chrome.cookies.set(details, (cookie) => {
|
|
318
|
+
if (chrome.runtime.lastError) reject(new Error(chrome.runtime.lastError.message));
|
|
319
|
+
else resolve(cookie);
|
|
320
|
+
});
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
async function setDipclawReady(state) {
|
|
325
|
+
globalThis.OMNI_FLOW_READY_STATE = state;
|
|
326
|
+
try {
|
|
327
|
+
await storageSet({ dipclawReady: state });
|
|
328
|
+
} catch (err) {
|
|
329
|
+
// The in-memory state is enough for dp-worker's startup waiter. Storage
|
|
330
|
+
// is only a secondary observable for diagnostics.
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
async function sha256Hex(text) {
|
|
335
|
+
const bytes = new TextEncoder().encode(text);
|
|
336
|
+
const hash = await crypto.subtle.digest("SHA-256", bytes);
|
|
337
|
+
return Array.from(new Uint8Array(hash))
|
|
338
|
+
.map((b) => b.toString(16).padStart(2, "0"))
|
|
339
|
+
.join("");
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Apply proxy settings. If unconfigured, deploy "IP Leak Lock" dummy proxy to prevent domestic IP leak!
|
|
344
|
+
* @param {Object} config
|
|
345
|
+
*/
|
|
346
|
+
function applyProxySettings(config) {
|
|
347
|
+
if (!config || !config.host || !config.port) {
|
|
348
|
+
const leakLockRules = {
|
|
349
|
+
mode: "fixed_servers",
|
|
350
|
+
rules: {
|
|
351
|
+
singleProxy: {
|
|
352
|
+
scheme: "http",
|
|
353
|
+
host: "127.0.0.1",
|
|
354
|
+
port: 65535 // Refused port to completely lock network access
|
|
355
|
+
},
|
|
356
|
+
bypassList: [
|
|
357
|
+
"localhost",
|
|
358
|
+
"127.0.0.1",
|
|
359
|
+
"<local>",
|
|
360
|
+
"ipinfo.io",
|
|
361
|
+
"*.ipinfo.io",
|
|
362
|
+
"ipapi.co",
|
|
363
|
+
"*.ipapi.co",
|
|
364
|
+
"ip-api.com",
|
|
365
|
+
"*.ip-api.com",
|
|
366
|
+
"freeipapi.com",
|
|
367
|
+
"*.freeipapi.com",
|
|
368
|
+
"api.ip.sb",
|
|
369
|
+
"*.api.ip.sb"
|
|
370
|
+
]
|
|
371
|
+
}
|
|
372
|
+
};
|
|
373
|
+
return new Promise((resolve, reject) => {
|
|
374
|
+
chrome.proxy.settings.set(
|
|
375
|
+
{ value: leakLockRules, scope: 'regular' },
|
|
376
|
+
() => {
|
|
377
|
+
if (chrome.runtime.lastError) {
|
|
378
|
+
reject(new Error(chrome.runtime.lastError.message));
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
console.log("OmniFlow: [IP LEAK LOCK ACTIVE] Proxy is unconfigured. Raw internet access blocked to prevent IP leaks.");
|
|
382
|
+
resolve();
|
|
383
|
+
}
|
|
384
|
+
);
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
// Create fixed servers proxy rule
|
|
389
|
+
const proxyRules = {
|
|
390
|
+
mode: "fixed_servers",
|
|
391
|
+
rules: {
|
|
392
|
+
singleProxy: {
|
|
393
|
+
scheme: config.type.toLowerCase(), // 'socks5' or 'http'
|
|
394
|
+
host: config.host,
|
|
395
|
+
port: parseInt(config.port, 10)
|
|
396
|
+
},
|
|
397
|
+
bypassList: ["localhost", "127.0.0.1", "<local>"]
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
return new Promise((resolve, reject) => {
|
|
402
|
+
chrome.proxy.settings.set(
|
|
403
|
+
{ value: proxyRules, scope: 'regular' },
|
|
404
|
+
() => {
|
|
405
|
+
if (chrome.runtime.lastError) {
|
|
406
|
+
reject(new Error(chrome.runtime.lastError.message));
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
console.log(`OmniFlow: Proxy enabled. Mode: ${config.type}, Server: ${config.host}:${config.port}`);
|
|
410
|
+
resolve();
|
|
411
|
+
}
|
|
412
|
+
);
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Configure WebRTC IP handling policy to block raw local/public IP leaks
|
|
418
|
+
* @param {boolean} block
|
|
419
|
+
*/
|
|
420
|
+
function applyWebRTCSettings(block) {
|
|
421
|
+
if (chrome.privacy && chrome.privacy.network && chrome.privacy.network.webRTCIPHandlingPolicy) {
|
|
422
|
+
const policy = block ? 'disable_non_proxied_udp' : 'default';
|
|
423
|
+
return new Promise((resolve, reject) => {
|
|
424
|
+
chrome.privacy.network.webRTCIPHandlingPolicy.set({ value: policy }, () => {
|
|
425
|
+
if (chrome.runtime.lastError) {
|
|
426
|
+
reject(new Error(chrome.runtime.lastError.message));
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
console.log(`OmniFlow: WebRTC Leak Protection set to -> ${policy}`);
|
|
430
|
+
resolve();
|
|
431
|
+
});
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
return Promise.resolve();
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Silent proxy authentication using the webRequest API
|
|
439
|
+
*/
|
|
440
|
+
chrome.webRequest.onAuthRequired.addListener(
|
|
441
|
+
(details) => {
|
|
442
|
+
if (details.isProxy) {
|
|
443
|
+
if (activeProxyConfig && activeProxyConfig.username && activeProxyConfig.password) {
|
|
444
|
+
console.log("OmniFlow: Automatically authenticating proxy connection.");
|
|
445
|
+
return {
|
|
446
|
+
authCredentials: {
|
|
447
|
+
username: activeProxyConfig.username,
|
|
448
|
+
password: activeProxyConfig.password
|
|
449
|
+
}
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
return {};
|
|
454
|
+
},
|
|
455
|
+
{ urls: ["<all_urls>"] },
|
|
456
|
+
["blocking"]
|
|
457
|
+
);
|
|
458
|
+
|
|
459
|
+
// Call initialization
|
|
460
|
+
init();
|
|
461
|
+
|
|
462
|
+
// Register stealth injection script in the MAIN world (100% invisible to DOM & Performance audits)
|
|
463
|
+
function registerStealthInjection() {
|
|
464
|
+
if (chrome.scripting && chrome.scripting.registerContentScripts) {
|
|
465
|
+
chrome.scripting.getRegisteredContentScripts({ ids: ["omniShield"] }, (scripts) => {
|
|
466
|
+
if (scripts && scripts.length > 0) {
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
chrome.scripting.registerContentScripts([{
|
|
470
|
+
id: "omniShield",
|
|
471
|
+
js: ["inject.js"],
|
|
472
|
+
matches: ["<all_urls>"],
|
|
473
|
+
runAt: "document_start",
|
|
474
|
+
world: "MAIN"
|
|
475
|
+
}], () => {
|
|
476
|
+
if (chrome.runtime.lastError) {
|
|
477
|
+
console.log("OmniFlow: Failed to register stealth injection:", chrome.runtime.lastError.message);
|
|
478
|
+
} else {
|
|
479
|
+
console.log("OmniFlow: Stealth injection registered successfully.");
|
|
480
|
+
}
|
|
481
|
+
});
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
// ============================================================================
|
|
487
|
+
// Standalone Window Front-Focus Manager (Stealth Recall UX) - Persistent State Machine
|
|
488
|
+
// ============================================================================
|
|
489
|
+
|
|
490
|
+
// 1. Initial State Alignment on Service Worker Startup / Browser Restarts:
|
|
491
|
+
// Bypasses the MV3 service worker "memory loss" bug by auditing the persistent storage.
|
|
492
|
+
chrome.storage.local.get(['standaloneWindowId'], (data) => {
|
|
493
|
+
const winId = data.standaloneWindowId;
|
|
494
|
+
if (winId) {
|
|
495
|
+
chrome.windows.get(winId, (win) => {
|
|
496
|
+
if (chrome.runtime.lastError || !win) {
|
|
497
|
+
// The standalone window was closed while the background worker was asleep or browser restarted
|
|
498
|
+
chrome.storage.local.remove(['standaloneWindowId'], () => {
|
|
499
|
+
chrome.action.setPopup({ popup: "popup.html" }); // Re-enable default dropdown popup
|
|
500
|
+
console.log("OmniFlow Startup: Standalone window not found. Restored default popup.");
|
|
501
|
+
});
|
|
502
|
+
} else {
|
|
503
|
+
// Window exists! Keep the popup cleared so clicking the icon fires action onClicked
|
|
504
|
+
chrome.action.setPopup({ popup: "" });
|
|
505
|
+
console.log("OmniFlow Startup: Standalone window is active. Front-focus trigger enabled.");
|
|
506
|
+
}
|
|
507
|
+
});
|
|
508
|
+
} else {
|
|
509
|
+
chrome.action.setPopup({ popup: "popup.html" });
|
|
510
|
+
}
|
|
511
|
+
});
|
|
512
|
+
|
|
513
|
+
// 2. Listen for standalone window registration message
|
|
514
|
+
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
|
515
|
+
if (message && message.action === "dipclaw:getReady") {
|
|
516
|
+
sendResponse(globalThis.OMNI_FLOW_READY_STATE || null);
|
|
517
|
+
return false;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
if (message && message.action === "registerStandaloneWindow") {
|
|
521
|
+
const targetWinId = message.windowId;
|
|
522
|
+
chrome.storage.local.set({ standaloneWindowId: targetWinId }, () => {
|
|
523
|
+
// Clear default popup action so clicking the extension toolbar icon fires onClicked event!
|
|
524
|
+
chrome.action.setPopup({ popup: "" });
|
|
525
|
+
console.log("OmniFlow: Standalone window registered & persisted:", targetWinId);
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
return false;
|
|
529
|
+
});
|
|
530
|
+
|
|
531
|
+
// 3. Watch for standalone window close to restore normal dropdown popup behavior
|
|
532
|
+
chrome.windows.onRemoved.addListener((windowId) => {
|
|
533
|
+
chrome.storage.local.get(['standaloneWindowId'], (data) => {
|
|
534
|
+
if (data.standaloneWindowId === windowId) {
|
|
535
|
+
chrome.storage.local.remove(['standaloneWindowId'], () => {
|
|
536
|
+
chrome.action.setPopup({ popup: "popup.html" }); // Re-enable default dropdown popup
|
|
537
|
+
console.log("OmniFlow: Standalone window closed. Restored default popup.");
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
});
|
|
541
|
+
});
|
|
542
|
+
|
|
543
|
+
// 4. Bring existing standalone window instantly to the front if toolbar icon is clicked!
|
|
544
|
+
chrome.action.onClicked.addListener((tab) => {
|
|
545
|
+
chrome.storage.local.get(['standaloneWindowId'], (data) => {
|
|
546
|
+
const targetWinId = data.standaloneWindowId;
|
|
547
|
+
if (targetWinId) {
|
|
548
|
+
chrome.windows.update(targetWinId, { focused: true }, () => {
|
|
549
|
+
if (chrome.runtime.lastError) {
|
|
550
|
+
// Safe recovery if the window was closed silently without background capturing it
|
|
551
|
+
chrome.storage.local.remove(['standaloneWindowId'], () => {
|
|
552
|
+
chrome.action.setPopup({ popup: "popup.html" });
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
});
|
|
556
|
+
} else {
|
|
557
|
+
// Safe fallback recovery if we catch a click event but no window exists
|
|
558
|
+
chrome.action.setPopup({ popup: "popup.html" });
|
|
559
|
+
}
|
|
560
|
+
});
|
|
561
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OmniFlow - Content Script (Manifest V3)
|
|
3
|
+
* Reads settings from chrome storage and delegates injection safely to inject.js
|
|
4
|
+
* in the page's MAIN context, bypassing site Content Security Policy (CSP) headers.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
chrome.storage.local.get([
|
|
8
|
+
'spoofTimezone',
|
|
9
|
+
'timezoneEnabled',
|
|
10
|
+
'languagesEnabled',
|
|
11
|
+
'hardwareMaskingEnabled',
|
|
12
|
+
'antiBotEnabled'
|
|
13
|
+
], (data) => {
|
|
14
|
+
const doc = document.documentElement;
|
|
15
|
+
|
|
16
|
+
if (data.timezoneEnabled && data.spoofTimezone) {
|
|
17
|
+
doc.dataset.omniTz = data.spoofTimezone;
|
|
18
|
+
}
|
|
19
|
+
if (data.languagesEnabled !== false) {
|
|
20
|
+
doc.dataset.omniLang = "true";
|
|
21
|
+
}
|
|
22
|
+
if (data.hardwareMaskingEnabled !== false) {
|
|
23
|
+
doc.dataset.omniHardware = "true";
|
|
24
|
+
}
|
|
25
|
+
if (data.antiBotEnabled !== false) {
|
|
26
|
+
doc.dataset.omniBot = "true";
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
});
|
|
Binary file
|