oc-browser-relay 1.0.25 → 1.0.26
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/bundled-relay/index.js
CHANGED
|
@@ -25517,7 +25517,7 @@ function getRuntimeClientIds(targetClientId) {
|
|
|
25517
25517
|
}
|
|
25518
25518
|
return runtimeIds;
|
|
25519
25519
|
}
|
|
25520
|
-
async function requestRuntimeQuery(clientId, queryType) {
|
|
25520
|
+
async function requestRuntimeQuery(clientId, queryType, params) {
|
|
25521
25521
|
const requestId = `runtime_query_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`;
|
|
25522
25522
|
return new Promise(async (resolve4, reject) => {
|
|
25523
25523
|
const timer = setTimeout(() => {
|
|
@@ -25529,7 +25529,7 @@ async function requestRuntimeQuery(clientId, queryType) {
|
|
|
25529
25529
|
type: "runtime.query",
|
|
25530
25530
|
requestId,
|
|
25531
25531
|
timestamp: Date.now(),
|
|
25532
|
-
payload: { queryType }
|
|
25532
|
+
payload: { queryType, ...params || {} }
|
|
25533
25533
|
});
|
|
25534
25534
|
if (!sent) {
|
|
25535
25535
|
clearTimeout(timer);
|
|
@@ -25538,11 +25538,11 @@ async function requestRuntimeQuery(clientId, queryType) {
|
|
|
25538
25538
|
}
|
|
25539
25539
|
});
|
|
25540
25540
|
}
|
|
25541
|
-
async function requestRuntimeQueryAcrossClients(queryType, targetClientId) {
|
|
25541
|
+
async function requestRuntimeQueryAcrossClients(queryType, targetClientId, params) {
|
|
25542
25542
|
const runtimeIds = getRuntimeClientIds(targetClientId);
|
|
25543
25543
|
const results = await Promise.all(runtimeIds.map(async (clientId) => {
|
|
25544
25544
|
try {
|
|
25545
|
-
const payload = await requestRuntimeQuery(clientId, queryType);
|
|
25545
|
+
const payload = await requestRuntimeQuery(clientId, queryType, params);
|
|
25546
25546
|
return {
|
|
25547
25547
|
clientId,
|
|
25548
25548
|
payload
|
|
@@ -25611,6 +25611,24 @@ app.get("/api/tabs", async (req, res) => {
|
|
|
25611
25611
|
res.status(400).json({ success: false, error: err.message });
|
|
25612
25612
|
}
|
|
25613
25613
|
});
|
|
25614
|
+
app.get("/api/cookies", async (req, res) => {
|
|
25615
|
+
try {
|
|
25616
|
+
const targetClientId = typeof req.query.clientId === "string" ? req.query.clientId : void 0;
|
|
25617
|
+
const domain = typeof req.query.domain === "string" ? req.query.domain : void 0;
|
|
25618
|
+
const url = typeof req.query.url === "string" ? req.query.url : void 0;
|
|
25619
|
+
const domainsRaw = typeof req.query.domains === "string" ? req.query.domains : void 0;
|
|
25620
|
+
const domains = domainsRaw ? domainsRaw.split(",").map((d) => d.trim()).filter(Boolean) : void 0;
|
|
25621
|
+
if (!domain && !url && (!domains || domains.length === 0)) {
|
|
25622
|
+
return res.status(400).json({ success: false, error: "domain, url or domains is required" });
|
|
25623
|
+
}
|
|
25624
|
+
const results = await requestRuntimeQueryAcrossClients("get_cookies", targetClientId, { domain, url, domains });
|
|
25625
|
+
const cookies = results.flatMap((result) => result.payload?.items || []);
|
|
25626
|
+
const errors = results.filter((result) => result.error || result.payload?.error).map((result) => ({ clientId: result.clientId, error: result.error || result.payload?.error }));
|
|
25627
|
+
res.json({ success: true, partialSuccess: errors.length > 0, cookies, errors, count: cookies.length });
|
|
25628
|
+
} catch (err) {
|
|
25629
|
+
res.status(400).json({ success: false, error: err.message });
|
|
25630
|
+
}
|
|
25631
|
+
});
|
|
25614
25632
|
app.post("/api/workspaces", (req, res) => {
|
|
25615
25633
|
try {
|
|
25616
25634
|
const { name, rootDir, allowedRoots, targetRuntimeId, sourceClientId } = req.body || {};
|