Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 05c962d46f | |||
| cf3fef6936 | |||
| 8c878b3718 | |||
| 389f00e85c |
@@ -14,7 +14,7 @@ crate-type = ["staticlib", "cdylib", "rlib"]
|
|||||||
tauri-build = { version = "2", features = [] }
|
tauri-build = { version = "2", features = [] }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tauri = { version = "2", features = [] }
|
tauri = { version = "2", features = ["devtools"] }
|
||||||
tauri-plugin-notification = "2"
|
tauri-plugin-notification = "2"
|
||||||
tauri-plugin-sql = { version = "2", features = ["sqlite"] }
|
tauri-plugin-sql = { version = "2", features = ["sqlite"] }
|
||||||
tauri-plugin-stronghold = "2"
|
tauri-plugin-stronghold = "2"
|
||||||
|
|||||||
@@ -15,6 +15,14 @@
|
|||||||
"updater:allow-check",
|
"updater:allow-check",
|
||||||
"updater:allow-download",
|
"updater:allow-download",
|
||||||
"updater:allow-install",
|
"updater:allow-install",
|
||||||
"updater:allow-download-and-install"
|
"updater:allow-download-and-install",
|
||||||
|
"stronghold:default",
|
||||||
|
"stronghold:allow-initialize",
|
||||||
|
"stronghold:allow-load-client",
|
||||||
|
"stronghold:allow-create-client",
|
||||||
|
"stronghold:allow-save",
|
||||||
|
"stronghold:allow-get-store-record",
|
||||||
|
"stronghold:allow-save-store-record",
|
||||||
|
"stronghold:allow-remove-store-record"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://schema.tauri.app/config/2",
|
"$schema": "https://schema.tauri.app/config/2",
|
||||||
"productName": "ChatApp",
|
"productName": "ChatApp",
|
||||||
"version": "0.3.0",
|
"version": "0.3.4",
|
||||||
"identifier": "com.meinname.chatapp",
|
"identifier": "com.meinname.chatapp",
|
||||||
"build": {
|
"build": {
|
||||||
"beforeDevCommand": "pnpm vite:dev",
|
"beforeDevCommand": "pnpm vite:dev",
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ export function AuthProvider({ children }: { children: ReactNode }) {
|
|||||||
const status = (error as { status?: number }).status;
|
const status = (error as { status?: number }).status;
|
||||||
if (status === 401 || status === 403) {
|
if (status === 401 || status === 403) {
|
||||||
// Token genuinely invalid — wipe.
|
// Token genuinely invalid — wipe.
|
||||||
await supabase.auth.signOut().catch(() => {
|
await supabase.auth.signOut({ scope: 'local' }).catch(() => {
|
||||||
/* ignore */
|
/* ignore */
|
||||||
});
|
});
|
||||||
setSession(null);
|
setSession(null);
|
||||||
|
|||||||
@@ -39,12 +39,22 @@ export async function setSecretStoreUser(userId: string | null): Promise<void> {
|
|||||||
|
|
||||||
if (userId && isTauriRuntime()) {
|
if (userId && isTauriRuntime()) {
|
||||||
const stronghold = makeStrongholdStore(userId);
|
const stronghold = makeStrongholdStore(userId);
|
||||||
|
try {
|
||||||
|
// 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;
|
activeBackend = stronghold;
|
||||||
try {
|
try {
|
||||||
await migrateLocalStorageToStronghold(userId, PREFIX);
|
await migrateLocalStorageToStronghold(userId, PREFIX);
|
||||||
} catch (err: unknown) {
|
} catch (err: unknown) {
|
||||||
console.warn('stronghold migration failed', err);
|
console.warn('stronghold migration failed', err);
|
||||||
}
|
}
|
||||||
|
} catch (err: unknown) {
|
||||||
|
console.warn('stronghold init failed — falling back to localStorage', err);
|
||||||
|
activeBackend = localStore;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
activeBackend = localStore;
|
activeBackend = localStore;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,7 +86,11 @@ export async function completeSessionFromUrl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function signOut(client: AppSupabaseClient): Promise<void> {
|
export async function signOut(client: AppSupabaseClient): Promise<void> {
|
||||||
const { error } = await client.auth.signOut();
|
// `scope: 'local'` only ends the session in THIS client. Without it Supabase
|
||||||
|
// defaults to 'global', which invalidates the user's refresh tokens
|
||||||
|
// everywhere — meaning a logout in the browser would also kick the desktop
|
||||||
|
// app (and vice versa) the next time it tries to refresh its token.
|
||||||
|
const { error } = await client.auth.signOut({ scope: 'local' });
|
||||||
if (error) throw error;
|
if (error) throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user