feat: autopass-based cross-device sync for Holesail Browser
CI / Build & Test (push) Successful in 4m27s
CI / Build & Test (push) Successful in 4m27s
- Native host: add autopass + corestore deps, sync-manager (createInvite, pairWithInvite, push/pull) - Apply synced state via same flow as backup restore (state.json only, no certs) - Holesail-manager: setOnStateSaved hook for sync push - Extension: Sync dashboard page, getSyncStatus/createSyncInvite/pairWithInvite, syncApplied event - Docs: NATIVE-HOST.md sync commands, SYNC.md
This commit is contained in:
@@ -25,6 +25,17 @@ function emit(event, payload) { if (eventEmit) eventEmit(event, payload); }
|
||||
// ── Shared saveState snapshot ─────────────────────────────────────────────────
|
||||
// Collects current state from all sub-modules and persists it.
|
||||
|
||||
let onStateSaved = null;
|
||||
|
||||
/**
|
||||
* Register a callback invoked after each saveState() with the snapshot object.
|
||||
* Used by sync-manager to push state to autopass.
|
||||
* @param {Function} fn - (snapshot: object) => void
|
||||
*/
|
||||
function setOnStateSaved(fn) {
|
||||
onStateSaved = typeof fn === 'function' ? fn : null;
|
||||
}
|
||||
|
||||
function saveState() {
|
||||
const serversList = serversModule.getServers().map(s => ({
|
||||
id: s.id, port: s.port, host: s.host, secure: s.secure, udp: s.udp || false, label: s.label || ''
|
||||
@@ -34,7 +45,7 @@ function saveState() {
|
||||
const serviceTunnelsList = svcModule.getServiceTunnels().map(t => ({
|
||||
id: t.id, label: t.label, hsUrl: t.hsUrl, localPort: t.localPort
|
||||
}));
|
||||
stateModule.saveStateSync({
|
||||
const snapshot = {
|
||||
version: 2,
|
||||
settings: settingsModule.getSettings(),
|
||||
nextServerId: serversModule.getNextServerId(),
|
||||
@@ -44,7 +55,9 @@ function saveState() {
|
||||
serviceTunnels: serviceTunnelsList,
|
||||
sshConnections: connectionsModule.getSshConnections(),
|
||||
rdpConnections: connectionsModule.getRdpConnections()
|
||||
});
|
||||
};
|
||||
stateModule.saveStateSync(snapshot);
|
||||
if (onStateSaved) onStateSaved(snapshot);
|
||||
}
|
||||
|
||||
// Inject the shared saveState and emit callbacks into each sub-module
|
||||
@@ -113,6 +126,7 @@ module.exports = {
|
||||
// Storage
|
||||
setStoragePath,
|
||||
ensureStorageDir,
|
||||
setOnStateSaved,
|
||||
// Settings
|
||||
getSettings: settingsModule.getSettings,
|
||||
updateSettings: settingsModule.updateSettings,
|
||||
|
||||
Reference in New Issue
Block a user