feat(ext/sw): export_backup / restore_backup message types

This commit is contained in:
adlee-was-taken
2026-04-28 20:12:07 -04:00
parent 7407fe512f
commit f32c14f939
2 changed files with 25 additions and 1 deletions

View File

@@ -382,6 +382,12 @@ export async function handle(
await chrome.storage.local.set({ session_timeout: msg.config });
return { ok: true };
}
case 'export_backup':
return { ok: false, error: 'export_backup not yet implemented' };
case 'restore_backup':
return { ok: false, error: 'restore_backup not yet implemented' };
}
}

View File

@@ -48,7 +48,14 @@ export type PopupMessage =
| { type: 'purge_all_trash' }
| { type: 'get_field_history'; id: ItemId }
| { type: 'get_session_config' }
| { type: 'update_session_config'; config: SessionTimeoutConfig };
| { type: 'update_session_config'; config: SessionTimeoutConfig }
| { type: 'export_backup'; passphrase: string; includeImage: boolean }
| {
type: 'restore_backup';
bytes: ArrayBuffer;
passphrase: string;
newRemote: { hostType: 'gitea' | 'github'; hostUrl: string; repoPath: string; apiToken: string };
};
// --- Messages a content script may send ---
@@ -153,8 +160,19 @@ export const POPUP_ONLY_TYPES: ReadonlySet<PopupMessage['type']> = new Set([
'list_trashed', 'restore_item', 'purge_item', 'purge_all_trash',
'get_field_history',
'get_session_config', 'update_session_config',
'export_backup', 'restore_backup',
] as PopupMessage['type'][]);
export interface ExportBackupResponse extends Extract<Response, { ok: true }> {
data: { bytes: ArrayBuffer };
}
export interface RestoreBackupResponse extends Extract<Response, { ok: true }> {
data: {
summary: { itemCount: number; attachmentCount: number; hasImage: boolean };
};
}
export const CONTENT_CALLABLE_TYPES: ReadonlySet<ContentMessage['type']> = new Set([
'get_autofill_candidates', 'get_credentials', 'check_credential', 'blacklist_site',
'capture_save_login',