Skip to content

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

Update family sharing delete confirm UI (#2469)

Leendert de Borst12212138fd89
diff --git a/apps/browser-extension/src/entrypoints/popup/components/LoadingSpinnerFullScreen.tsx b/apps/browser-extension/src/entrypoints/popup/components/LoadingSpinnerFullScreen.tsx
index b1620d3fe..bc6890333 100644
--- a/apps/browser-extension/src/entrypoints/popup/components/LoadingSpinnerFullScreen.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/components/LoadingSpinnerFullScreen.tsx
@@ -38,7 +38,7 @@ const LoadingSpinnerFullScreen: React.FC = () => {
);
return (
- <div className="fixed inset-0 w-full h-full z-50 bg-gray-200 dark:bg-gray-500 bg-opacity-90 flex items-center justify-center">
+ <div className="fixed inset-0 w-full h-full z-[100] bg-gray-200 dark:bg-gray-500 bg-opacity-90 flex items-center justify-center">
<div className="relative">
{spinner}
</div>
diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/MainActivity.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/MainActivity.kt
index 99dffb486..64fbb1203 100644
--- a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/MainActivity.kt
+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/MainActivity.kt
@@ -244,8 +244,10 @@ class MainActivity : ReactActivity() {
// Check both promise types - one for showPasswordUnlock() and one for authenticateUser()
val passwordPromise = net.aliasvault.app.nativevaultmanager.NativeVaultManager.passwordUnlockPromise
val authPromise = net.aliasvault.app.nativevaultmanager.NativeVaultManager.pendingActivityResultPromise
+ val returnUnlockKey = net.aliasvault.app.nativevaultmanager.NativeVaultManager.passwordUnlockReturnsKey
net.aliasvault.app.nativevaultmanager.NativeVaultManager.passwordUnlockPromise = null
+ net.aliasvault.app.nativevaultmanager.NativeVaultManager.passwordUnlockReturnsKey = false
net.aliasvault.app.nativevaultmanager.NativeVaultManager.pendingActivityResultPromise = null
net.aliasvault.app.nativevaultmanager.NativeVaultManager.pendingAuthContext = null
@@ -275,8 +277,8 @@ class MainActivity : ReactActivity() {
// Unlock the vault with the key now in memory
vaultStore.unlockVault()
- // For both showPasswordUnlock() and authenticateUser(), resolve with success (true)
- passwordPromise?.resolve(true)
+ // showPasswordUnlockForKey() resolves with the unlock key, showPasswordUnlock() and authenticateUser() with true
+ passwordPromise?.resolve(if (returnUnlockKey) unlockKeyBase64 else true)
authPromise?.resolve(true)
} catch (e: Exception) {
android.util.Log.e("MainActivity", "Failed to unlock vault with password", e)
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 27fad1538..6f76e2b6e 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
@@ -100,6 +100,12 @@ class NativeVaultManager(reactContext: ReactApplicationContext) :
@Volatile
var passwordUnlockPromise: Promise? = null
+ /**
+ * Whether the pending password unlock resolves with the unlock key instead of true.
+ */
+ @Volatile
+ var passwordUnlockReturnsKey: Boolean = false
+
/**
* Static holder for authentication context (title, subtitle) to support password fallback
* when PIN is cancelled in authenticateUser flow.
@@ -1738,14 +1744,33 @@ class NativeVaultManager(reactContext: ReactApplicationContext) :
/**
* Show native password unlock screen.
- * Returns encryption key (base64) if successful, null if cancelled.
+ * Returns true if successful, null if cancelled.
*
* @param title Custom title for the password unlock screen. If null or empty, uses default.
* @param subtitle Custom subtitle for the password unlock screen. If null or empty, uses default.
- * @param promise The promise to resolve with encryption key or null.
+ * @param promise The promise to resolve with true or null.
*/
@ReactMethod
override fun showPasswordUnlock(title: String?, subtitle: String?, buttonText: String?, promise: Promise) {
+ presentPasswordUnlock(title, subtitle, buttonText, false, promise)
+ }
+
+ /**
+ * Show native password unlock screen and resolve with the unlock key (base64), or null if cancelled.
+ *
+ * @param title Custom title for the password unlock screen. If null or empty, uses default.
+ * @param subtitle Custom subtitle for the password unlock screen. If null or empty, uses default.
+ * @param promise The promise to resolve with the unlock key or null.
+ */
+ @ReactMethod
+ override fun showPasswordUnlockForKey(title: String?, subtitle: String?, buttonText: String?, promise: Promise) {
+ presentPasswordUnlock(title, subtitle, buttonText, true, promise)
+ }
+
+ /**
+ * Launch the password unlock activity for showPasswordUnlock and showPasswordUnlockForKey.
+ */
+ private fun presentPasswordUnlock(title: String?, subtitle: String?, buttonText: String?, returnUnlockKey: Boolean, promise: Promise) {
val activity = currentActivity
if (activity == null) {
promise.reject("NO_ACTIVITY", "No activity available", null)
@@ -1754,6 +1779,7 @@ class NativeVaultManager(reactContext: ReactApplicationContext) :
// Store promise in static companion object so MainActivity can resolve it directly
passwordUnlockPromise = promise
+ passwordUnlockReturnsKey = returnUnlockKey
// Launch password unlock activity
val intent = Intent(activity, net.aliasvault.app.passwordunlock.PasswordUnlockActivity::class.java)
diff --git a/apps/mobile-app/app/(tabs)/settings/family-sharing.tsx b/apps/mobile-app/app/(tabs)/settings/family-sharing.tsx
index 5eaec070f..6536571f2 100644
--- a/apps/mobile-app/app/(tabs)/settings/family-sharing.tsx
+++ b/apps/mobile-app/app/(tabs)/settings/family-sharing.tsx
@@ -1,4 +1,5 @@
import { apiErrorCodeOf } from '@aliasvault/client/api/errors/ApiRequestError';
+import { SrpAuthService } from '@aliasvault/client/auth/SrpAuthService';
import { canAdministerGroup, describeMemberAccess, familySharingText, holdsManifestKey, ownUserIdIn, roleLabel, sharingErrorMessage } from '@aliasvault/client/sharing/FamilySharingView';
import { multiManifestRendering } from '@aliasvault/client/sharing/MultiManifestRendering';
import { SharingService } from '@aliasvault/client/sharing/SharingService';
@@ -13,9 +14,9 @@ import ContextMenu from 'react-native-context-menu-view';
import { folderRoute } from '@/utils/FolderRoute';
import { HapticsUtility } from '@/utils/HapticsUtility';
-import { VaultUnlockHelper } from '@/utils/VaultUnlockHelper';
import { useColors } from '@/hooks/useColorScheme';
+import { useLogout } from '@/hooks/useLogout';
import { useMinDurationLoading } from '@/hooks/useMinDurationLoading';
import { useVaultSync } from '@/hooks/useVaultSync';
@@ -47,6 +48,7 @@ export default function FamilySharingScreen(): React.ReactNode {
const { t } = useTranslation();
const router = useRouter();
const { username } = useApp();
+ const { logoutForced } = useLogout();
const { sqliteClient } = useDb();
const { isEnabled, isLoaded } = useCapabilityContext();
const { showConfirm } = useDialog();
@@ -240,20 +242,32 @@ export default function FamilySharingScreen(): React.ReactNode {
};
/**
- * Delete a shared manifest behind the native password prompt. The server wants proof of the master password, which
- * the native layer answers with the unlock key of the open session.
+ * Delete a shared manifest behind the native password prompt, whose unlock key answers the server's SRP challenge.
* @param group - the group the shared manifest belongs to.
* @param manifest - the shared manifest to delete.
*/
const deleteSharedVault = async (group: GroupInfo, manifest: SharedManifestInfo): Promise<void> => {
- const authenticated = await VaultUnlockHelper.authenticateForAction(familySharingText.deleteVault, familySharingText.deleteVaultPasswordPrompt(vaultLabel(manifest)), null, t('common.delete'));
- if (!authenticated) {
+ let unlockKey: string | null;
+ try {
+ unlockKey = await NativeVaultManager.showPasswordUnlockForKey(familySharingText.deleteVault, familySharingText.deleteVaultPasswordPrompt(vaultLabel(manifest)), t('common.delete'));
+ } catch (err) {
+ // Too many wrong passwords: the native layer cleared the vault, so log out.
+ if (err && typeof err === 'object' && 'code' in err && err.code === 'MAX_ATTEMPTS_REACHED') {
+ await logoutForced();
+ }
+ return;
+ }
+
+ if (!unlockKey) {
return;
}
await run(async () => {
try {
- await SharingService.deleteSharedManifest(webApi, group.groupId, manifest.manifestId, challenge => NativeVaultManager.deriveSrpProof(challenge.salt, challenge.srpIdentity, challenge.serverEphemeral));
+ await SharingService.deleteSharedManifest(webApi, group.groupId, manifest.manifestId, async challenge => {
+ const passwordHash = await SrpAuthService.srpPasswordHash(unlockKey, challenge.encryptionType);
+ return SrpAuthService.deriveClientProof(challenge.salt, challenge.srpIdentity, passwordHash, challenge.serverEphemeral);
+ });
} catch (deleteError) {
// Local unlock key could mismatch what is actually stored on server (recent password change on other device), if so we show a incorrect password error.
if (apiErrorCodeOf(deleteError) === 'PASSWORD_MISMATCH') {
diff --git a/apps/mobile-app/ios/NativeVaultManager/RCTNativeVaultManager.mm b/apps/mobile-app/ios/NativeVaultManager/RCTNativeVaultManager.mm
index b28b7edd2..caee9b454 100644
--- a/apps/mobile-app/ios/NativeVaultManager/RCTNativeVaultManager.mm
+++ b/apps/mobile-app/ios/NativeVaultManager/RCTNativeVaultManager.mm
@@ -357,6 +357,10 @@
[vaultManager showPasswordUnlock:title subtitle:subtitle buttonText:buttonText resolver:resolve rejecter:reject];
}
+- (void)showPasswordUnlockForKey:(NSString *)title subtitle:(NSString *)subtitle buttonText:(NSString *)buttonText resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
+ [vaultManager showPasswordUnlockForKey:title subtitle:subtitle buttonText:buttonText resolver:resolve rejecter:reject];
+}
+
// MARK: - Mobile Login
- (void)encryptAccountKeyForMobileLogin:(NSString *)publicKeyJWK 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 132e5b05f..9b864a51f 100644
--- a/apps/mobile-app/ios/NativeVaultManager/VaultManager.swift
+++ b/apps/mobile-app/ios/NativeVaultManager/VaultManager.swift
@@ -1019,6 +1019,25 @@ public class VaultManager: NSObject {
buttonText: String?,
resolver resolve: @escaping RCTPromiseResolveBlock,
rejecter reject: @escaping RCTPromiseRejectBlock) {
+ presentPasswordUnlock(title, subtitle: subtitle, buttonText: buttonText, returnUnlockKey: false, resolver: resolve, rejecter: reject)
+ }
+
+ /// Show the password unlock screen and resolve with the unlock key, for callers that answer an SRP challenge with it.
+ @objc
+ func showPasswordUnlockForKey(_ title: String?,
+ subtitle: String?,
+ buttonText: String?,
+ resolver resolve: @escaping RCTPromiseResolveBlock,
+ rejecter reject: @escaping RCTPromiseRejectBlock) {
+ presentPasswordUnlock(title, subtitle: subtitle, buttonText: buttonText, returnUnlockKey: true, resolver: resolve, rejecter: reject)
+ }
+
+ private func presentPasswordUnlock(_ title: String?,
+ subtitle: String?,
+ buttonText: String?,
+ returnUnlockKey: Bool,
+ resolver resolve: @escaping RCTPromiseResolveBlock,
+ rejecter reject: @escaping RCTPromiseRejectBlock) {
DispatchQueue.main.async { [weak self] in
guard let self = self else {
reject("INTERNAL_ERROR", "VaultManager instance deallocated", nil)
@@ -1057,7 +1076,7 @@ public class VaultManager: NSObject {
await MainActor.run {
rootVC.dismiss(animated: true) {
- resolve(true)
+ resolve(returnUnlockKey ? unlockKeyBase64 : true)
}
}
},
diff --git a/apps/mobile-app/specs/NativeVaultManager.ts b/apps/mobile-app/specs/NativeVaultManager.ts
index f908dc9b2..448b1ad23 100644
--- a/apps/mobile-app/specs/NativeVaultManager.ts
+++ b/apps/mobile-app/specs/NativeVaultManager.ts
@@ -141,6 +141,8 @@ export interface Spec extends TurboModule {
// If title/subtitle are null/empty, defaults to "Unlock Vault" context.
// If buttonText is null/empty, defaults to "Unlock".
showPasswordUnlock(title: string | null, subtitle: string | null, buttonText: string | null): Promise<boolean | null>;
+ // Same screen, but returns the unlock key (base64) for answering an SRP challenge, null if cancelled. Use only when the key is needed.
+ showPasswordUnlockForKey(title: string | null, subtitle: string | null, buttonText: string | null): Promise<string | null>;
// Mobile login methods
encryptAccountKeyForMobileLogin(publicKeyJWK: string): Promise<string>;
diff --git a/apps/web/src/pages/settings/FamilySharing.tsx b/apps/web/src/pages/settings/FamilySharing.tsx
index 8e7d1ba2f..189965116 100644
--- a/apps/web/src/pages/settings/FamilySharing.tsx
+++ b/apps/web/src/pages/settings/FamilySharing.tsx
@@ -209,17 +209,22 @@ const FamilySharing: React.FC = () => {
* Create another shared manifest for the family. The sync that follows pushes it to the server.
* @param group - the family to create it for.
*/
- const createSharedVault = (group: GroupInfo): Promise<void> => {
+ const createSharedVault = async (group: GroupInfo): Promise<void> => {
const name = (newVaultNames[group.groupId] ?? '').trim();
if (name.length === 0) {
- return Promise.resolve();
+ return;
}
- return run(async () => {
- unwrap(await vaultStore.createSharedManifest(group.groupId, name), familySharingText.errors.createVaultFailed);
- setNewVaultNames(previous => ({ ...previous, [group.groupId]: '' }));
- await syncAndReload();
- }, familySharingText.errors.createVaultFailed);
+ showLoading();
+ try {
+ await run(async () => {
+ unwrap(await vaultStore.createSharedManifest(group.groupId, name), familySharingText.errors.createVaultFailed);
+ setNewVaultNames(previous => ({ ...previous, [group.groupId]: '' }));
+ await syncAndReload();
+ }, familySharingText.errors.createVaultFailed);
+ } finally {
+ hideLoading();
+ }
};
/**