46415895f157
merge duplicate TRIGGER_SYNC + START_PAIRING_SERVER cases; remove dead startSubnetScan stub and activeDesktopPairing vars
- time
- 2026-05-07 14:39 UTC · 5 months ago
- machine
- koh2
- parent
- 0cee4e9ef31c
↓ peach-browser-46415895.tar.gzatlas at this save
files changed1 file
src/background/messages.ts+3 −32src/background/messages.ts+3 −32
@@ -695,12 +695,6 @@695695 696696 return { ok: true, data: { pairedDevices, trustedNetworks, status, lastSyncAt, isPro: pro } };697697 }698- case "TRIGGER_SYNC": {699- const gate = await requirePro("sync");700- if (!gate.allowed) return { ok: false, error: "pro_required" };701- if (!vault.isUnlocked()) return { ok: false, error: "vault_locked" };702- return { ok: false, error: "no_native_host" };703- }704698 case "START_PAIRING": {705699 const gate = await requirePro("sync");706700 if (!gate.allowed) return { ok: false, error: "pro_required" };@@ -976,6 +970,9 @@976970 }977971 }978972 case "TRIGGER_SYNC": {973+ const gate = await requirePro("sync");974+ if (!gate.allowed) return { ok: false, error: "pro_required" };975+ if (!vault.isUnlocked()) return { ok: false, error: "vault_locked" };979976 if (isNativePlatform()) {980977 bridge?.ensureServerRunning?.();981978 return { ok: true, data: { syncedCount: 0, mode: "server" as const } };@@ -1023,19 +1020,6 @@10231020 const { ip } = (await bridge?.getLocalIp?.()) ?? { ip: "" };10241021 return { ok: true, data: { ip } };10251022 }1026- // Desktop: generates a pairing token and starts the subnet scan for QR pairing.1027- case "START_PAIRING_SERVER": {1028- if (isNativePlatform()) {1029- return { ok: false, error: "desktop_only" };1030- }1031- const arr = new Uint32Array(1);1032- crypto.getRandomValues(arr);1033- const token = String(100000 + (arr[0] % 900000));1034- activeDesktopPairingToken = token;1035- activeDesktopPairingExpiry = Date.now() + 5 * 60 * 1000;1036- startSubnetScan(token, { getLocalAddress: () => null });1037- return { ok: true, data: { token, expiresIn: 300 } };1038- }10391023 case "GET_IDENTITY_SUGGESTIONS": {10401024 if (!vault.isUnlocked()) return { ok: false, error: "vault_locked" };10411025 const entries = vault.getEntries();@@ -1071,16 +1055,6 @@10711055 return { ok: true, syncedCount: 0 };10721056 }10731057 1074-// Desktop: starts background subnet scan for QR pairing.1075-function startSubnetScan(1076- token: string,1077- _deps: {1078- getLocalAddress: () => string | null;1079- }1080-): void {1081- // TODO: implement subnet scan and WebSocket pairing server1082-}1083-10841058 // Android: populates the in-memory vault used by PeachAutofillService.10851059 async function publishInMemoryVault(entries: VaultEntry[]): Promise<void> {10861060 // eslint-disable-next-line @typescript-eslint/no-explicit-any@@ -1129,9 +1103,6 @@11291103 11301104 // eslint-disable-next-line @typescript-eslint/no-explicit-any11311105 const isNativePlatform = (): boolean => typeof (globalThis as any).Capacitor !== "undefined" && (globalThis as any).isNativePlatform();1132-1133-let activeDesktopPairingToken: string | null = null;1134-let activeDesktopPairingExpiry = 0;11351106 11361107 /** Notify all content scripts that the vault just became available. */11371108 function broadcastToContentScripts(message: { type: string }): void {