fix(secretStore): fall back to localStorage when stronghold init fails
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "ChatApp",
|
||||
"version": "0.3.2",
|
||||
"version": "0.3.3",
|
||||
"identifier": "com.meinname.chatapp",
|
||||
"build": {
|
||||
"beforeDevCommand": "pnpm vite:dev",
|
||||
|
||||
@@ -39,11 +39,21 @@ export async function setSecretStoreUser(userId: string | null): Promise<void> {
|
||||
|
||||
if (userId && isTauriRuntime()) {
|
||||
const stronghold = makeStrongholdStore(userId);
|
||||
activeBackend = stronghold;
|
||||
try {
|
||||
await migrateLocalStorageToStronghold(userId, PREFIX);
|
||||
// Force a tiny round-trip to verify Stronghold can actually open the
|
||||
// vault on this machine. If not (broken vault file, bundled rust crate
|
||||
// mismatch, etc.) we fall back to localStorage so the rest of the app
|
||||
// remains usable instead of bricking device registration.
|
||||
await stronghold.getSecret('__probe');
|
||||
activeBackend = stronghold;
|
||||
try {
|
||||
await migrateLocalStorageToStronghold(userId, PREFIX);
|
||||
} catch (err: unknown) {
|
||||
console.warn('stronghold migration failed', err);
|
||||
}
|
||||
} catch (err: unknown) {
|
||||
console.warn('stronghold migration failed', err);
|
||||
console.warn('stronghold init failed — falling back to localStorage', err);
|
||||
activeBackend = localStore;
|
||||
}
|
||||
} else {
|
||||
activeBackend = localStore;
|
||||
|
||||
Reference in New Issue
Block a user