Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Clear CredentialIdentityStore contents on logout (#520)

Leendert de Borst99dc808de48f
diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/nativevaultmanager/NativeVaultManager.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/nativevaultmanager/NativeVaultManager.kt
index dc833606f..542dcd690 100644
--- a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/nativevaultmanager/NativeVaultManager.kt
+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/nativevaultmanager/NativeVaultManager.kt
@@ -1033,6 +1033,27 @@ class NativeVaultManager(reactContext: ReactApplicationContext) :
}.start()
}
+ /**
+ * Remove all credential identities from the credential identity store.
+ * Called during logout to clear all locally stored credential metadata.
+ * @param promise The promise to resolve.
+ */
+ @ReactMethod
+ override fun removeCredentialIdentities(promise: Promise) {
+ try {
+ Log.d(TAG, "Removing all credential identities from Android store")
+ val identityStore = net.aliasvault.app.credentialprovider.CredentialIdentityStore.getInstance(
+ reactApplicationContext,
+ )
+ identityStore.removeAllCredentialIdentities()
+ Log.d(TAG, "Successfully removed all credential identities")
+ promise.resolve(null)
+ } catch (e: Exception) {
+ Log.e(TAG, "Error removing credential identities", e)
+ promise.reject("CREDENTIAL_REMOVAL_ERROR", "Failed to remove credential identities: ${e.message}", e)
+ }
+ }
+
// MARK: - Username Management
/**
diff --git a/apps/mobile-app/app/unlock.tsx b/apps/mobile-app/app/unlock.tsx
index 5f503d521..b5b9384ea 100644
--- a/apps/mobile-app/app/unlock.tsx
+++ b/apps/mobile-app/app/unlock.tsx
@@ -107,8 +107,10 @@ export default function UnlockScreen() : React.ReactNode {
return;
}
- // Navigate to initialize page which will handle vault sync and then navigate to credentials
- // This ensures we always check for vault updates even after local unlock
+ /*
+ * Navigate to initialize page which will handle vault sync and then navigate to credentials
+ * This ensures we always check for vault updates even after local unlock
+ */
router.replace('/initialize');
} else {
Alert.alert(t('common.error'), t('auth.errors.incorrectPassword'));
diff --git a/apps/mobile-app/context/AuthContext.tsx b/apps/mobile-app/context/AuthContext.tsx
index 8c056cac2..f55a42e25 100644
--- a/apps/mobile-app/context/AuthContext.tsx
+++ b/apps/mobile-app/context/AuthContext.tsx
@@ -206,6 +206,14 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children
await AsyncStorage.removeItem('refreshToken');
await AsyncStorage.removeItem('authMethods');
+ // Clear credential identity store (passkey metadata)
+ try {
+ await NativeVaultManager.removeCredentialIdentities();
+ } catch (error) {
+ console.error('Failed to remove credential identities:', error);
+ // Non-fatal error - continue with logout
+ }
+
dbContext?.clearDatabase();
if (errorMessage) {
diff --git a/apps/mobile-app/ios/NativeVaultManager/RCTNativeVaultManager.mm b/apps/mobile-app/ios/NativeVaultManager/RCTNativeVaultManager.mm
index 989d93441..eb10887ce 100644
--- a/apps/mobile-app/ios/NativeVaultManager/RCTNativeVaultManager.mm
+++ b/apps/mobile-app/ios/NativeVaultManager/RCTNativeVaultManager.mm
@@ -171,6 +171,10 @@
[vaultManager registerCredentialIdentities:resolve rejecter:reject];
}
+- (void)removeCredentialIdentities:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
+ [vaultManager removeCredentialIdentities:resolve rejecter:reject];
+}
+
// MARK: - WebAPI Configuration
- (void)setApiUrl:(NSString *)url resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
diff --git a/apps/mobile-app/ios/NativeVaultManager/VaultManager.swift b/apps/mobile-app/ios/NativeVaultManager/VaultManager.swift
index 63b097a39..3067ab56c 100644
--- a/apps/mobile-app/ios/NativeVaultManager/VaultManager.swift
+++ b/apps/mobile-app/ios/NativeVaultManager/VaultManager.swift
@@ -476,6 +476,26 @@ public class VaultManager: NSObject {
}
}
+ @objc
+ func removeCredentialIdentities(_ resolve: @escaping RCTPromiseResolveBlock,
+ rejecter reject: @escaping RCTPromiseRejectBlock) {
+ Task {
+ do {
+ print("VaultManager: Removing all credential identities from iOS store")
+ try await CredentialIdentityStore.shared.removeAllCredentialIdentities()
+ await MainActor.run {
+ print("VaultManager: Successfully removed all credential identities")
+ resolve(nil)
+ }
+ } catch {
+ print("VaultManager: Failed to remove credential identities: \(error)")
+ await MainActor.run {
+ reject("CREDENTIAL_REMOVAL_ERROR", "Failed to remove credential identities: \(error.localizedDescription)", error)
+ }
+ }
+ }
+ }
+
// MARK: - WebAPI Configuration
@objc
diff --git a/apps/mobile-app/specs/NativeVaultManager.ts b/apps/mobile-app/specs/NativeVaultManager.ts
index 896b00e1f..955c216af 100644
--- a/apps/mobile-app/specs/NativeVaultManager.ts
+++ b/apps/mobile-app/specs/NativeVaultManager.ts
@@ -55,6 +55,7 @@ export interface Spec extends TurboModule {
// Credential identity management
registerCredentialIdentities(): Promise<void>;
+ removeCredentialIdentities(): Promise<void>;
// WebAPI configuration and token management
setApiUrl(url: string): Promise<void>;