Fix cross-browser GitHub Gist sync when encryption is enabled
Two bugs prevented sync from working between different browsers sharing the same GitHub token and encryption password: 1. pullFromGist failed immediately with "No Gist ID stored" on any browser that had not previously pushed, because ss_gist_id lives in browser.storage.local (isolated per browser). Fix: when no local Gist ID is found, search the authenticated user's Gists for one containing silent-send-sync.json and cache the result. 2. When the pulled data was encrypted with a different salt (each browser generates its own random salt on setup), pullFromGist returned needsAuth:true but the UI never set window.__ssPendingSyncImport, so the auth prompt fell through to reverifyWithPassword instead of authenticateForSync, and the pull was never retried after the user entered their password. Fix: set window.__ssPendingSyncImport before showing the auth prompt for both Gist pull and custom-URL pull, matching how sync-code import already handled this flow. https://claude.ai/code/session_01QJnEnLfbXKR5FSCQ3Qfs53
This commit is contained in:
+36
-2
@@ -189,7 +189,24 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||
const r = await SilentSendSync.pullFromGist(token);
|
||||
if (r.needsAuth) {
|
||||
setGistSyncStatus('Authentication required to decrypt.', 'warn');
|
||||
showSyncAuthPrompt();
|
||||
window.__ssPendingSyncImport = async () => {
|
||||
const r2 = await SilentSendSync.pullFromGist(token);
|
||||
if (r2.needsAuth) {
|
||||
setGistSyncStatus('Authentication failed — wrong password?', 'error');
|
||||
} else if (!r2.success) {
|
||||
setGistSyncStatus('Pull failed: ' + r2.reason, 'error');
|
||||
} else if (r2.imported) {
|
||||
setGistSyncStatus(`Pulled (${r2.time}). Refreshing…`, 'ok');
|
||||
mappings = await Storage.getMappings();
|
||||
settings = await Storage.getSettings();
|
||||
renderMappings();
|
||||
renderDomains();
|
||||
renderLog();
|
||||
} else {
|
||||
setGistSyncStatus('Already up to date.', 'ok');
|
||||
}
|
||||
};
|
||||
showSyncAuthPrompt('decrypt');
|
||||
} else if (!r.success) {
|
||||
setGistSyncStatus('Pull failed: ' + r.reason, 'error');
|
||||
} else if (r.imported) {
|
||||
@@ -229,7 +246,24 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||
const r = await SilentSendSync.pullFromUrl({ url, headers });
|
||||
if (r.needsAuth) {
|
||||
setUrlSyncStatus('Authentication required to decrypt.', 'warn');
|
||||
showSyncAuthPrompt();
|
||||
window.__ssPendingSyncImport = async () => {
|
||||
const r2 = await SilentSendSync.pullFromUrl({ url, headers });
|
||||
if (r2.needsAuth) {
|
||||
setUrlSyncStatus('Authentication failed — wrong password?', 'error');
|
||||
} else if (!r2.success) {
|
||||
setUrlSyncStatus('Pull failed: ' + r2.reason, 'error');
|
||||
} else if (r2.imported) {
|
||||
setUrlSyncStatus(`Pulled (${r2.time}). Refreshing…`, 'ok');
|
||||
mappings = await Storage.getMappings();
|
||||
settings = await Storage.getSettings();
|
||||
renderMappings();
|
||||
renderDomains();
|
||||
renderLog();
|
||||
} else {
|
||||
setUrlSyncStatus('Already up to date.', 'ok');
|
||||
}
|
||||
};
|
||||
showSyncAuthPrompt('decrypt');
|
||||
} else if (!r.success) {
|
||||
setUrlSyncStatus('Pull failed: ' + r.reason, 'error');
|
||||
} else if (r.imported) {
|
||||
|
||||
Reference in New Issue
Block a user