feat(ext/messages): add create_vault, attach_vault, get_vault_status (Plan C Phase 3 prep)
Adds the request shapes + response interfaces. POPUP_ONLY_TYPES set grows by three. SW handlers in service-worker/vault.ts land in the next tasks. The new union members would make popup-only.ts's exhaustive handle() switch non-total (TS2366), so a default case is added returning an explicit "unhandled popup message" error. create_vault/attach_vault get real cases in Tasks 3.2-3.3; get_vault_status in Dev-C's Phase 6. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -627,6 +627,12 @@ export async function handle(
|
|||||||
return { ok: false, error: (e as Error).message };
|
return { ok: false, error: (e as Error).message };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// create_vault / attach_vault land in Phase 3 Tasks 3.2-3.3; get_vault_status
|
||||||
|
// in Phase 6 (Dev-C). Until each case lands, an unhandled popup message
|
||||||
|
// returns an explicit error rather than falling through with no return.
|
||||||
|
default:
|
||||||
|
return { ok: false, error: `unhandled popup message: ${(msg as { type: string }).type}` };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,12 @@ export type PopupMessage =
|
|||||||
| { type: 'import_lastpass_commit'; items: Item[] }
|
| { type: 'import_lastpass_commit'; items: Item[] }
|
||||||
| { type: 'preview_totp_from_secret'; secret_b32: string }
|
| { type: 'preview_totp_from_secret'; secret_b32: string }
|
||||||
| { type: 'generate_recovery_qr'; passphrase: string }
|
| { type: 'generate_recovery_qr'; passphrase: string }
|
||||||
| { type: 'unwrap_recovery_qr'; payload_b64: string; passphrase: string };
|
| { type: 'unwrap_recovery_qr'; payload_b64: string; passphrase: string }
|
||||||
|
| { type: 'create_vault'; config: VaultConfig; passphrase: string;
|
||||||
|
carrierImageBytes: ArrayBuffer; deviceName: string }
|
||||||
|
| { type: 'attach_vault'; config: VaultConfig; passphrase: string;
|
||||||
|
referenceImageBytes: ArrayBuffer; deviceName: string }
|
||||||
|
| { type: 'get_vault_status' };
|
||||||
|
|
||||||
// --- Messages a content script may send ---
|
// --- Messages a content script may send ---
|
||||||
|
|
||||||
@@ -176,6 +181,7 @@ export const POPUP_ONLY_TYPES: ReadonlySet<PopupMessage['type']> = new Set([
|
|||||||
'parse_lastpass_csv', 'import_lastpass_commit',
|
'parse_lastpass_csv', 'import_lastpass_commit',
|
||||||
'preview_totp_from_secret',
|
'preview_totp_from_secret',
|
||||||
'generate_recovery_qr', 'unwrap_recovery_qr',
|
'generate_recovery_qr', 'unwrap_recovery_qr',
|
||||||
|
'create_vault', 'attach_vault', 'get_vault_status',
|
||||||
] as PopupMessage['type'][]);
|
] as PopupMessage['type'][]);
|
||||||
|
|
||||||
export interface ExportBackupResponse extends Extract<Response, { ok: true }> {
|
export interface ExportBackupResponse extends Extract<Response, { ok: true }> {
|
||||||
@@ -201,6 +207,20 @@ export interface ImportLastPassCommitResponse extends Extract<Response, { ok: tr
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface CreateVaultResponse extends Extract<Response, { ok: true }> {
|
||||||
|
data: { referenceImageBytes: Uint8Array; deviceName: string;
|
||||||
|
recoveryQrAvailable: true };
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AttachVaultResponse extends Extract<Response, { ok: true }> {
|
||||||
|
data: { deviceName: string };
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GetVaultStatusResponse extends Extract<Response, { ok: true }> {
|
||||||
|
data: { ahead: number; behind: number; lastSyncAt: number | null;
|
||||||
|
pendingItems: number };
|
||||||
|
}
|
||||||
|
|
||||||
export const CONTENT_CALLABLE_TYPES: ReadonlySet<ContentMessage['type']> = new Set([
|
export const CONTENT_CALLABLE_TYPES: ReadonlySet<ContentMessage['type']> = new Set([
|
||||||
'get_autofill_candidates', 'get_credentials', 'check_credential', 'blacklist_site',
|
'get_autofill_candidates', 'get_credentials', 'check_credential', 'blacklist_site',
|
||||||
'capture_save_login',
|
'capture_save_login',
|
||||||
|
|||||||
Reference in New Issue
Block a user