fix: sync code not transferring identity when encryption enabled

_getAllData() was reading raw storage which contains encrypted blobs
when at-rest encryption is enabled. The sync code export would send
{ _ssLocalEncrypted: true, data: <blob> } instead of actual identity
data. The importing browser couldn't use these blobs.

Fixed _getAllData() to use Storage._readSecure() which decrypts
transparently. Fixed _applyData() to use Storage._writeSecure()
so imported data gets encrypted on the receiving end.

Also: hide the Auto-Sync Folder section entirely in browsers that
don't support File System Access API (Firefox, Brave, Safari)
instead of showing a broken-looking error message.

https://claude.ai/code/session_01SWSwDfMVij53bCTNSCLMwn
This commit is contained in:
Claude
2026-03-27 03:57:53 +00:00
parent 511ee321a7
commit 0870c050cb
3 changed files with 34 additions and 11 deletions
+26 -10
View File
@@ -791,25 +791,41 @@ const SilentSendSync = {
// ----------------------------------------------------------------
async _getAllData() {
const result = await api.storage.local.get(null);
// Use dynamic import to avoid circular dependency
const StorageModule = (await import('./storage.js')).default;
const identity = await StorageModule._readSecure('ss_identity');
const mappings = await StorageModule._readSecure('ss_mappings');
const settings = await StorageModule._readSecure('ss_settings');
const result = await api.storage.local.get('ss_lastModified');
return {
version: '1',
lastModified: result.ss_lastModified || Date.now(),
identity: result.ss_identity || {},
mappings: result.ss_mappings || [],
settings: result.ss_settings || {},
identity: identity || {},
mappings: mappings || [],
settings: settings || {},
};
},
async _applyData(data, source = 'unknown') {
const toSet = {
const StorageModule = (await import('./storage.js')).default;
// Write through Storage module so data gets encrypted if at-rest
// encryption is enabled
if (data.identity !== undefined) {
await StorageModule._writeSecure('ss_identity', data.identity);
}
if (data.mappings !== undefined) {
await StorageModule._writeSecure('ss_mappings', data.mappings);
}
if (data.settings !== undefined) {
await StorageModule._writeSecure('ss_settings', data.settings);
}
// Metadata stays plaintext
await api.storage.local.set({
ss_lastModified: data.lastModified,
ss_sync_notification: { source, time: Date.now() },
};
if (data.identity !== undefined) toSet.ss_identity = data.identity;
if (data.mappings !== undefined) toSet.ss_mappings = data.mappings;
if (data.settings !== undefined) toSet.ss_settings = data.settings;
await api.storage.local.set(toSet);
});
},
async _getSyncChunkKeys() {