cicy-desktop 2.1.366 → 2.1.367

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/package.json +1 -1
  2. package/src/main.js +24 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cicy-desktop",
3
- "version": "2.1.366",
3
+ "version": "2.1.367",
4
4
  "description": "CiCy - AI-powered operating system browser",
5
5
  "main": "src/main.js",
6
6
  "bin": {
package/src/main.js CHANGED
@@ -54,14 +54,34 @@ const NPK_SRC = "(function(){try{"
54
54
  + "navigator.credentials.get=function(o){return (o&&o.publicKey)?"
55
55
  + "Promise.reject(new DOMException('The operation either timed out or was not allowed.','NotAllowedError')):g(o)};}"
56
56
  + "}catch(e){}})();";
57
+ // 通行密钥的 get() 可能从**跨域 iframe**(如 accounts.meta.com,独立进程 OOPIF)或**弹窗**里发起,
58
+ // 只在主目标上 addScript 覆盖不到它们(实测:弹窗写着 accounts.meta.com 的通行密钥,框照弹)。
59
+ // 用 Target.setAutoAttach(flatten) 抓下每一个子目标(子框架/弹窗),对每个子会话也 addScript,
60
+ // 并让它继续向下 auto-attach —— 这样无论哪个 origin、哪层 iframe、哪个弹窗都被覆盖。
61
+ async function armSession(dbg, sessionId) {
62
+ // sendCommand(method, params, sessionId?) —— 根会话 sessionId 传 undefined
63
+ const sid = sessionId || undefined;
64
+ try { await dbg.sendCommand("Page.enable", {}, sid); } catch (_) {}
65
+ try { await dbg.sendCommand("Page.addScriptToEvaluateOnNewDocument", { source: NPK_SRC }, sid); } catch (_) {}
66
+ try { await dbg.sendCommand("Target.setAutoAttach", { autoAttach: true, waitForDebuggerOnStart: true, flatten: true }, sid); } catch (_) {}
67
+ }
57
68
  async function armWebviewNoPasskey(wc) {
58
69
  try {
59
70
  if (!wc || wc.isDestroyed() || wc.getType() !== "webview" || wc.__npkArmed) return;
60
71
  wc.__npkArmed = true;
61
- if (!wc.debugger.isAttached()) wc.debugger.attach("1.3");
62
- await wc.debugger.sendCommand("Page.enable");
63
- await wc.debugger.sendCommand("Page.addScriptToEvaluateOnNewDocument", { source: NPK_SRC });
64
- try { await wc.executeJavaScript(NPK_SRC, true); } catch (_) {} // 当前已加载的文档也补一发
72
+ const dbg = wc.debugger;
73
+ if (!dbg.isAttached()) dbg.attach("1.3");
74
+ dbg.on("message", async (_e, method, params, sessionId) => {
75
+ try {
76
+ if (method === "Target.attachedToTarget") {
77
+ const sid = params.sessionId;
78
+ await armSession(dbg, sid); // 子目标(iframe/弹窗)也注入并继续向下
79
+ try { await dbg.sendCommand("Runtime.runIfWaitingForDebugger", {}, sid); } catch (_) {}
80
+ }
81
+ } catch (_) {}
82
+ });
83
+ await armSession(dbg, null); // 主目标
84
+ try { await wc.executeJavaScript(NPK_SRC, true); } catch (_) {} // 当前已加载文档补一发
65
85
  } catch (_) { try { wc.__npkArmed = false; } catch (e) {} }
66
86
  }
67
87
  electronApp.on("web-contents-created", (_e, wc) => {