Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Replace react native password-confirm with new native password unlock views (#1776)
Leendert de Borst6d140f615315
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.ktindex d23305501..035702cd3 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@@ -1438,7 +1438,7 @@ class NativeVaultManager(reactContext: ReactApplicationContext) :* @param promise The promise to resolve with encryption key or null.*/@ReactMethod- override fun showPasswordUnlock(title: String?, subtitle: String?, promise: Promise) {+ override fun showPasswordUnlock(title: String?, subtitle: String?, buttonText: String?, promise: Promise) {val activity = currentActivityif (activity == null) {promise.reject("NO_ACTIVITY", "No activity available", null)@@ -1456,6 +1456,9 @@ class NativeVaultManager(reactContext: ReactApplicationContext) :if (!subtitle.isNullOrEmpty()) {intent.putExtra(net.aliasvault.app.passwordunlock.PasswordUnlockActivity.EXTRA_CUSTOM_SUBTITLE, subtitle)}+ if (!buttonText.isNullOrEmpty()) {+ intent.putExtra(net.aliasvault.app.passwordunlock.PasswordUnlockActivity.EXTRA_CUSTOM_BUTTON_TEXT, buttonText)+ }activity.startActivityForResult(intent, PASSWORD_UNLOCK_REQUEST_CODE)}@@ -1496,19 +1499,28 @@ class NativeVaultManager(reactContext: ReactApplicationContext) :}@ReactMethod- override fun authenticateUser(title: String?, subtitle: String?, promise: Promise) {+ override fun authenticateUser(title: String?, subtitle: String?, allowedMethods: ReadableArray?, buttonText: String?, promise: Promise) {CoroutineScope(Dispatchers.Main).launch {try {// Get enabled authentication methodsval authMethods = vaultStore.getAuthMethods()- val isBiometricEnabled = authMethods.contains("faceid")- val pinEnabled = vaultStore.isPinEnabled()- // Check if password auth is available as fallback- val hasPasswordFallback = authMethods.contains("password")+ // Convert ReadableArray to Set<String> for filtering+ val allowedMethodsSet: Set<String>? = allowedMethods?.let { array ->+ val set = mutableSetOf<String>()+ for (i in 0 until array.size()) {+ array.getString(i)?.let { set.add(it) }+ }+ set.takeIf { it.isNotEmpty() }+ }++ // Filter by allowed methods if specified+ val isBiometricEnabled = authMethods.contains("faceid") && (allowedMethodsSet == null || allowedMethodsSet.contains("biometric"))+ val isPinAllowed = vaultStore.isPinEnabled() && (allowedMethodsSet == null || allowedMethodsSet.contains("pin"))+ val isPasswordAllowed = authMethods.contains("password") && (allowedMethodsSet == null || allowedMethodsSet.contains("password"))- // If PIN is enabled, prefer PIN (with biometric first if available)- if (pinEnabled) {+ // If PIN is enabled and allowed, prefer PIN (with biometric first if available)+ if (isPinAllowed) {// Try biometric authentication first if enabledif (isBiometricEnabled) {try {@@ -1530,7 +1542,7 @@ class NativeVaultManager(reactContext: ReactApplicationContext) :pendingActivityResultPromise = promise// Store auth context in case PIN is cancelled and we need to fall back to password- if (hasPasswordFallback) {+ if (isPasswordAllowed) {pendingAuthContext = Pair(title, subtitle)}@@ -1575,7 +1587,13 @@ class NativeVaultManager(reactContext: ReactApplicationContext) :}}- // Show password unlock (either as primary or fallback from biometric)+ // Show password unlock if allowed (either as primary or fallback from biometric)+ if (!isPasswordAllowed) {+ // Password not allowed and we've exhausted other options+ promise.resolve(false)+ return@launch+ }+try {// Store promise for later resolution by MainActivity// Use pendingActivityResultPromise to match PIN unlock behavior (returns boolean)@@ -1589,13 +1607,16 @@ class NativeVaultManager(reactContext: ReactApplicationContext) :}val intent = Intent(activity, net.aliasvault.app.passwordunlock.PasswordUnlockActivity::class.java)- // Add custom title/subtitle if provided+ // Add custom title/subtitle/buttonText if providedif (!title.isNullOrEmpty()) {intent.putExtra(net.aliasvault.app.passwordunlock.PasswordUnlockActivity.EXTRA_CUSTOM_TITLE, title)}if (!subtitle.isNullOrEmpty()) {intent.putExtra(net.aliasvault.app.passwordunlock.PasswordUnlockActivity.EXTRA_CUSTOM_SUBTITLE, subtitle)}+ if (!buttonText.isNullOrEmpty()) {+ intent.putExtra(net.aliasvault.app.passwordunlock.PasswordUnlockActivity.EXTRA_CUSTOM_BUTTON_TEXT, buttonText)+ }activity.startActivityForResult(intent, PASSWORD_UNLOCK_REQUEST_CODE)} catch (e: Exception) {Log.e(TAG, "Password authentication failed", e)diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/passwordunlock/PasswordUnlockActivity.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/passwordunlock/PasswordUnlockActivity.ktindex 0e8d0c3ad..687b4e358 100644--- a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/passwordunlock/PasswordUnlockActivity.kt+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/passwordunlock/PasswordUnlockActivity.kt@@ -53,6 +53,9 @@ class PasswordUnlockActivity : AppCompatActivity() {/** Intent extra key for custom subtitle (optional). */const val EXTRA_CUSTOM_SUBTITLE = "custom_subtitle"++ /** Intent extra key for custom button text (optional). */+ const val EXTRA_CUSTOM_BUTTON_TEXT = "custom_button_text"}private lateinit var vaultStore: VaultStore@@ -91,15 +94,16 @@ class PasswordUnlockActivity : AppCompatActivity() {AndroidStorageProvider(this),)- // Get custom title/subtitle from intent+ // Get custom title/subtitle/buttonText from intentval customTitle = intent.getStringExtra(EXTRA_CUSTOM_TITLE)val customSubtitle = intent.getStringExtra(EXTRA_CUSTOM_SUBTITLE)+ val customButtonText = intent.getStringExtra(EXTRA_CUSTOM_BUTTON_TEXT)// Initialize views- initializeViews(customTitle, customSubtitle)+ initializeViews(customTitle, customSubtitle, customButtonText)}- private fun initializeViews(customTitle: String?, customSubtitle: String?) {+ private fun initializeViews(customTitle: String?, customSubtitle: String?, customButtonText: String?) {titleTextView = findViewById(R.id.titleTextView)subtitleTextView = findViewById(R.id.subtitleTextView)passwordEditText = findViewById(R.id.passwordEditText)@@ -110,7 +114,7 @@ class PasswordUnlockActivity : AppCompatActivity() {loadingOverlay = findViewById(R.id.loadingOverlay)progressBar = findViewById(R.id.progressBar)- // Set custom title/subtitle if provided+ // Set custom title/subtitle/buttonText if providedif (!customTitle.isNullOrEmpty()) {titleTextView.text = customTitle} else {@@ -123,6 +127,12 @@ class PasswordUnlockActivity : AppCompatActivity() {subtitleTextView.text = getString(R.string.password_unlock_subtitle)}+ if (!customButtonText.isNullOrEmpty()) {+ unlockButton.text = customButtonText+ } else {+ unlockButton.text = getString(R.string.password_unlock_button)+ }+// Setup button statesunlockButton.isEnabled = falsediff --git a/apps/mobile-app/app/(tabs)/settings/_layout.tsx b/apps/mobile-app/app/(tabs)/settings/_layout.tsxindex 410881f63..83c31f4fd 100644--- a/apps/mobile-app/app/(tabs)/settings/_layout.tsx+++ b/apps/mobile-app/app/(tabs)/settings/_layout.tsx@@ -156,14 +156,6 @@ export default function SettingsLayout(): React.ReactNode {...defaultHeaderOptions,}}/>- <Stack.Screen- name="password-confirm"- options={{- title: t('settings.passwordConfirm.title'),- headerBackTitle: t('settings.importExport'),- ...defaultHeaderOptions,- }}- /></Stack>);}\ No newline at end of filediff --git a/apps/mobile-app/app/(tabs)/settings/import-export.tsx b/apps/mobile-app/app/(tabs)/settings/import-export.tsxindex 4c820b1b8..d6273631c 100644--- a/apps/mobile-app/app/(tabs)/settings/import-export.tsx+++ b/apps/mobile-app/app/(tabs)/settings/import-export.tsx@@ -8,7 +8,6 @@ import type { Item } from '@/utils/dist/core/models/vault';import { getFieldValue, itemToCredential } from '@/utils/dist/core/models/vault';import { useColors } from '@/hooks/useColorScheme';-import { usePasswordConfirm } from '@/hooks/usePasswordConfirm';import { useTranslation } from '@/hooks/useTranslation';import LoadingOverlay from '@/components/LoadingOverlay';@@ -17,6 +16,7 @@ import { ThemedScrollView } from '@/components/themed/ThemedScrollView';import { ThemedText } from '@/components/themed/ThemedText';import { useDb } from '@/context/DbContext';import { useDialog } from '@/context/DialogContext';+import NativeVaultManager from '@/specs/NativeVaultManager';/*** CSV record for Credential objects (matching server format).@@ -48,7 +48,6 @@ export default function ImportExportScreen(): React.ReactNode {const { t } = useTranslation();const dbContext = useDb();const { showAlert, showConfirm } = useDialog();- const { requestPasswordConfirm } = usePasswordConfirm();const [isExporting, setIsExporting] = useState(false);/**@@ -196,18 +195,29 @@ export default function ImportExportScreen(): React.ReactNode {t('settings.exportWarning'),t('common.confirm'),async () => {- // Request password confirmation via modal page- const passwordHash = await requestPasswordConfirm({- description: t('settings.passwordConfirm.exportDescription'),- });+ try {+ /*+ * Request password authentication using native unlock screen+ * Only allow password method (no biometric or PIN) for sensitive export operation+ */+ const authenticated = await NativeVaultManager.authenticateUser(+ t('settings.exportConfirmTitle'),+ t('settings.passwordConfirm.exportDescription'),+ ['password'], // Only allow password authentication+ t('common.confirm')+ );++ if (!authenticated) {+ // User cancelled or authentication failed+ return;+ }- if (!passwordHash) {- // User cancelled- return;+ // Password verified, proceed with export+ await handleExport();+ } catch (error) {+ console.error('Authentication error during CSV export:', error);+ showAlert(t('common.error'), t('common.errors.unknownError'));}-- // Password verified, proceed with export- await handleExport();},{ confirmStyle: 'destructive' });diff --git a/apps/mobile-app/app/(tabs)/settings/password-confirm.tsx b/apps/mobile-app/app/(tabs)/settings/password-confirm.tsxdeleted file mode 100644index 300629657..000000000--- a/apps/mobile-app/app/(tabs)/settings/password-confirm.tsx+++ /dev/null@@ -1,166 +0,0 @@-import { router, useLocalSearchParams } from 'expo-router';-import { useState, useEffect, useRef } from 'react';-import { StyleSheet, View, KeyboardAvoidingView, Platform } from 'react-native';--import { useColors } from '@/hooks/useColorScheme';-import { useTranslation } from '@/hooks/useTranslation';--import LoadingOverlay from '@/components/LoadingOverlay';-import { ThemedButton } from '@/components/themed/ThemedButton';-import { ThemedContainer } from '@/components/themed/ThemedContainer';-import { ThemedScrollView } from '@/components/themed/ThemedScrollView';-import { ThemedText } from '@/components/themed/ThemedText';-import { ThemedTextInput } from '@/components/themed/ThemedTextInput';-import { useAuth } from '@/context/AuthContext';-import { passwordConfirmEmitter } from '@/events/PasswordConfirmEmitter';--/**- * Password confirmation screen.- * This screen can be used to confirm the user's password before performing- * sensitive operations like exporting vault data.- *- * Usage:- * 1. Navigate to this screen with optional description param- * 2. Listen to passwordConfirmEmitter for 'confirmed' or 'cancelled' events- * 3. On 'confirmed', the password hash is passed as the event payload- * 4. Back navigation (swipe/button) automatically emits 'cancelled'- */-export default function PasswordConfirmScreen(): React.ReactNode {- const colors = useColors();- const { t } = useTranslation();- const authContext = useAuth();- const params = useLocalSearchParams<{- description?: string;- }>();-- const [password, setPassword] = useState('');- const [error, setError] = useState('');- const [isVerifying, setIsVerifying] = useState(false);-- // Track if we've already emitted a result (confirmed or cancelled)- const hasEmittedResult = useRef(false);-- const description = params.description ?? t('settings.passwordConfirm.defaultDescription');-- // Emit 'cancelled' when component unmounts (back navigation) if no result was emitted- useEffect(() => {- return (): void => {- if (!hasEmittedResult.current) {- passwordConfirmEmitter.emit('cancelled');- }- };- }, []);-- /**- * Handle password verification.- */- const handleVerify = async (): Promise<void> => {- if (!password) {- setError(t('validation.required'));- return;- }-- setError('');- setIsVerifying(true);-- try {- const passwordHashBase64 = await authContext.verifyPassword(password);- if (!passwordHashBase64) {- setError(t('auth.errors.incorrectPassword'));- return;- }-- // Password verified - emit success and go back- hasEmittedResult.current = true;- passwordConfirmEmitter.emit('confirmed', passwordHashBase64);- router.back();- } catch (err) {- console.error('Password verification error:', err);- setError(t('common.errors.unknownError'));- } finally {- setIsVerifying(false);- }- };-- const styles = StyleSheet.create({- button: {- marginTop: 8,- },- errorText: {- color: colors.red,- fontSize: 13,- marginTop: 8,- },- form: {- backgroundColor: colors.accentBackground,- borderRadius: 10,- marginTop: 20,- padding: 16,- },- headerText: {- color: colors.textMuted,- fontSize: 13,- lineHeight: 20,- },- inputContainer: {- marginBottom: 16,- },- keyboardAvoidingView: {- flex: 1,- },- label: {- color: colors.text,- fontSize: 16,- marginBottom: 8,- },- });-- return (- <>- {isVerifying && (- <LoadingOverlay status={t('settings.securitySettings.deleteAccount.verifyingPassword')} />- )}- <KeyboardAvoidingView- behavior={Platform.OS === 'ios' ? 'padding' : 'height'}- style={styles.keyboardAvoidingView}- >- <ThemedContainer testID="password-confirm-screen">- <ThemedScrollView>- <ThemedText style={styles.headerText}>- {description}- </ThemedText>-- <View style={styles.form}>- <View style={styles.inputContainer}>- <ThemedText style={styles.label}>- {t('auth.password')}- </ThemedText>- <ThemedTextInput- testID="password-confirm-input"- secureTextEntry- value={password}- onChangeText={setPassword}- placeholder={t('auth.enterPasswordPlaceholder')}- editable={!isVerifying}- autoFocus- />- {error ? (- <ThemedText style={styles.errorText}>{error}</ThemedText>- ) : null}- </View>-- <ThemedButton- testID="password-confirm-button"- title={t('common.confirm')}- onPress={handleVerify}- loading={isVerifying}- disabled={!password || isVerifying}- style={styles.button}- />- </View>- </ThemedScrollView>- </ThemedContainer>- </KeyboardAvoidingView>- </>- );-}diff --git a/apps/mobile-app/app/unlock.tsx b/apps/mobile-app/app/unlock.tsxindex 4bb81488d..71154db63 100644--- a/apps/mobile-app/app/unlock.tsx+++ b/apps/mobile-app/app/unlock.tsx@@ -107,7 +107,8 @@ export default function UnlockScreen() : React.ReactNode {const unlocked = await NativeVaultManager.showPasswordUnlock(t('auth.unlockVault'),- t('auth.enterPassword')+ t('auth.enterPassword'),+ null);if (!unlocked) {@@ -175,7 +176,8 @@ export default function UnlockScreen() : React.ReactNode {// Show native password unlock screenconst unlocked = await NativeVaultManager.showPasswordUnlock(t('auth.unlockVault'),- t('auth.enterPassword')+ t('auth.enterPassword'),+ null);// User cancelleddiff --git a/apps/mobile-app/events/PasswordConfirmEmitter.ts b/apps/mobile-app/events/PasswordConfirmEmitter.tsdeleted file mode 100644index 69673cfff..000000000--- a/apps/mobile-app/events/PasswordConfirmEmitter.ts+++ /dev/null@@ -1,60 +0,0 @@-/**- * Event emitter for password confirmation results.- */--type PasswordConfirmEvent = 'confirmed' | 'cancelled';-type ConfirmedListener = (passwordHash: string) => void;-type CancelledListener = () => void;--class PasswordConfirmEmitter {- private confirmedListeners: ConfirmedListener[] = [];- private cancelledListeners: CancelledListener[] = [];-- /**- * Subscribe to the 'confirmed' event.- * Called when password is successfully verified.- * @param listener - Receives the password hash (base64)- * @returns Unsubscribe function- */- onConfirmed(listener: ConfirmedListener): () => void {- this.confirmedListeners.push(listener);- return () => {- this.confirmedListeners = this.confirmedListeners.filter(l => l !== listener);- };- }-- /**- * Subscribe to the 'cancelled' event.- * Called when user cancels password confirmation.- * @returns Unsubscribe function- */- onCancelled(listener: CancelledListener): () => void {- this.cancelledListeners.push(listener);- return () => {- this.cancelledListeners = this.cancelledListeners.filter(l => l !== listener);- };- }-- /**- * Emit an event.- * @param event - The event type- * @param payload - Optional payload (password hash for 'confirmed')- */- emit(event: PasswordConfirmEvent, payload?: string): void {- if (event === 'confirmed' && payload) {- this.confirmedListeners.forEach(listener => listener(payload));- } else if (event === 'cancelled') {- this.cancelledListeners.forEach(listener => listener());- }- }-- /**- * Remove all listeners. Useful for cleanup.- */- removeAllListeners(): void {- this.confirmedListeners = [];- this.cancelledListeners = [];- }-}--export const passwordConfirmEmitter = new PasswordConfirmEmitter();diff --git a/apps/mobile-app/hooks/usePasswordConfirm.ts b/apps/mobile-app/hooks/usePasswordConfirm.tsdeleted file mode 100644index cda571d8d..000000000--- a/apps/mobile-app/hooks/usePasswordConfirm.ts+++ /dev/null@@ -1,108 +0,0 @@-import { useCallback, useEffect, useRef } from 'react';-import { Platform } from 'react-native';-import { router } from 'expo-router';--import { passwordConfirmEmitter } from '@/events/PasswordConfirmEmitter';--/**- * Delay in ms before navigating to password confirm screen.- * This allows the previous dialog/alert to dismiss before the modal appears.- * iOS needs a longer delay because the native Alert has a dismiss animation.- */-const NAVIGATION_DELAY_MS = Platform.OS === 'ios' ? 350 : 100;--type PasswordConfirmOptions = {- /**- * Custom description for the password confirm screen.- * If not provided, uses default translation.- */- description?: string;-};--type UsePasswordConfirmReturn = {- /**- * Request password confirmation from the user.- * Opens the password-confirm modal and returns a promise that resolves- * with the password hash if confirmed, or null if cancelled.- *- * @param options - Optional title and description for the modal- * @returns Promise<string | null> - Password hash (base64) or null if cancelled- */- requestPasswordConfirm: (options?: PasswordConfirmOptions) => Promise<string | null>;-};--/**- * Hook for requesting password confirmation from the user.- * Opens a modal screen where the user enters their password, which is then- * verified before returning the password hash.- *- * This is useful for sensitive operations like:- * - Exporting vault data- * - Vault reset operations- * - Other security-sensitive actions- *- * Usage:- * ```ts- * const { requestPasswordConfirm } = usePasswordConfirm();- *- * const handleSensitiveAction = async () => {- * const passwordHash = await requestPasswordConfirm({- * description: 'Enter your password to continue.',- * });- *- * if (!passwordHash) {- * // User cancelled- * return;- * }- *- * // Proceed with sensitive action using passwordHash- * };- * ```- */-export function usePasswordConfirm(): UsePasswordConfirmReturn {- // Store resolve function to call when we receive emitter events- const resolveRef = useRef<((value: string | null) => void) | null>(null);-- // Subscribe to emitter events on mount- useEffect(() => {- const unsubscribeConfirmed = passwordConfirmEmitter.onConfirmed((passwordHash) => {- if (resolveRef.current) {- resolveRef.current(passwordHash);- resolveRef.current = null;- }- });-- const unsubscribeCancelled = passwordConfirmEmitter.onCancelled(() => {- if (resolveRef.current) {- resolveRef.current(null);- resolveRef.current = null;- }- });-- return () => {- unsubscribeConfirmed();- unsubscribeCancelled();- };- }, []);-- const requestPasswordConfirm = useCallback((options?: PasswordConfirmOptions): Promise<string | null> => {- return new Promise((resolve) => {- resolveRef.current = resolve;-- // Add a small delay to allow the previous dialog to dismiss before navigating- setTimeout(() => {- // Navigate to password-confirm screen with optional params- router.push({- pathname: '/(tabs)/settings/password-confirm',- params: {- ...(options?.description && { description: options.description }),- },- });- }, NAVIGATION_DELAY_MS);- });- }, []);-- return {- requestPasswordConfirm,- };-}diff --git a/apps/mobile-app/ios/NativeVaultManager/RCTNativeVaultManager.mm b/apps/mobile-app/ios/NativeVaultManager/RCTNativeVaultManager.mmindex 5a672365c..5761ed44b 100644--- a/apps/mobile-app/ios/NativeVaultManager/RCTNativeVaultManager.mm+++ b/apps/mobile-app/ios/NativeVaultManager/RCTNativeVaultManager.mm@@ -281,8 +281,8 @@[vaultManager showPinSetup:resolve rejecter:reject];}-- (void)showPasswordUnlock:(NSString *)title subtitle:(NSString *)subtitle resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {- [vaultManager showPasswordUnlock:title subtitle:subtitle resolver:resolve rejecter:reject];+- (void)showPasswordUnlock:(NSString *)title subtitle:(NSString *)subtitle buttonText:(NSString *)buttonText resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {+ [vaultManager showPasswordUnlock:title subtitle:subtitle buttonText:buttonText resolver:resolve rejecter:reject];}// MARK: - Mobile Login@@ -293,8 +293,8 @@// MARK: - Re-authentication-- (void)authenticateUser:(NSString *)title subtitle:(NSString *)subtitle resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {- [vaultManager authenticateUser:title subtitle:subtitle resolver:resolve rejecter:reject];+- (void)authenticateUser:(NSString *)title subtitle:(NSString *)subtitle allowedMethods:(NSArray<NSString *> *)allowedMethods buttonText:(NSString *)buttonText resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {+ [vaultManager authenticateUser:title subtitle:subtitle allowedMethods:allowedMethods buttonText:buttonText resolver:resolve rejecter:reject];}// MARK: - QR Code Scannerdiff --git a/apps/mobile-app/ios/NativeVaultManager/VaultManager.swift b/apps/mobile-app/ios/NativeVaultManager/VaultManager.swiftindex fe6c8143a..23b8de498 100644--- a/apps/mobile-app/ios/NativeVaultManager/VaultManager.swift+++ b/apps/mobile-app/ios/NativeVaultManager/VaultManager.swift@@ -811,6 +811,7 @@ public class VaultManager: NSObject {@objcfunc showPasswordUnlock(_ title: String?,subtitle: String?,+ buttonText: String?,resolver resolve: @escaping RCTPromiseResolveBlock,rejecter reject: @escaping RCTPromiseRejectBlock) {DispatchQueue.main.async { [weak self] in@@ -828,9 +829,11 @@ public class VaultManager: NSObject {// Create password unlock view with ViewModellet customTitle = (title?.isEmpty == false) ? title : nillet customSubtitle = (subtitle?.isEmpty == false) ? subtitle : nil+ let customButtonText = (buttonText?.isEmpty == false) ? buttonText : nillet viewModel = PasswordUnlockViewModel(customTitle: customTitle,customSubtitle: customSubtitle,+ customButtonText: customButtonText,unlockHandler: { [weak self] password inguard let self = self else {throw NSError(domain: "VaultManager", code: -1, userInfo: [NSLocalizedDescriptionKey: "VaultManager instance deallocated"])@@ -973,15 +976,22 @@ public class VaultManager: NSObject {@objcfunc authenticateUser(_ title: String?,subtitle: String?,+ allowedMethods: [String]?,+ buttonText: String?,resolver resolve: @escaping RCTPromiseResolveBlock,rejecter reject: @escaping RCTPromiseRejectBlock) {// Get enabled authentication methodslet authMethods = vaultStore.getAuthMethods()- let isBiometricEnabled = authMethods.contains(.faceID)let pinEnabled = vaultStore.isPinEnabled()- // If PIN is enabled, prefer PIN (with biometric first if available)- if pinEnabled {+ // Filter by allowed methods if specified+ let allowedMethodsSet: Set<String>? = allowedMethods.map { Set($0) }+ let isBiometricEnabled = authMethods.contains(.faceID) && (allowedMethodsSet == nil || allowedMethodsSet!.contains("biometric"))+ let isPinAllowed = pinEnabled && (allowedMethodsSet == nil || allowedMethodsSet!.contains("pin"))+ let isPasswordAllowed = authMethods.contains(.password) && (allowedMethodsSet == nil || allowedMethodsSet!.contains("password"))++ // If PIN is enabled and allowed, prefer PIN (with biometric first if available)+ if isPinAllowed {// Try biometric authentication first if enabledif isBiometricEnabled {let authenticated = vaultStore.issueBiometricAuthentication(title: title)@@ -1062,8 +1072,8 @@ public class VaultManager: NSObject {return}- // If PIN was cancelled and password auth is available, fall back to password- if pinWasCancelled && authMethods.contains(.password) {+ // If PIN was cancelled and password auth is available and allowed, fall back to password+ if pinWasCancelled && isPasswordAllowed {// Fall through to password unlock below} else {// No password fallback available, resolve with false@@ -1072,7 +1082,7 @@ public class VaultManager: NSObject {}}- // No PIN enabled - check for biometric + password+ // No PIN enabled or allowed - check for biometric + passwordif isBiometricEnabled {let authenticated = vaultStore.issueBiometricAuthentication(title: title)if authenticated {@@ -1082,7 +1092,14 @@ public class VaultManager: NSObject {// Biometric failed or cancelled - fall through to password fallback if available}- // Show password unlock (either as primary or fallback from biometric)+ // Show password unlock if allowed (either as primary or fallback from biometric)+ if !isPasswordAllowed {+ // Password not allowed and we've exhausted other options+ resolve(false)+ return+ }++ // Show password unlockDispatchQueue.main.async { [weak self] inguard let self = self else {reject("INTERNAL_ERROR", "VaultManager instance deallocated", nil)@@ -1096,12 +1113,14 @@ public class VaultManager: NSObject {}// Create password unlock view with ViewModel- // Use custom title/subtitle if provided, otherwise use defaults+ // Use custom title/subtitle/buttonText if provided, otherwise use defaultslet customTitle = (title?.isEmpty == false) ? title : nillet customSubtitle = (subtitle?.isEmpty == false) ? subtitle : nil+ let customButtonText = (buttonText?.isEmpty == false) ? buttonText : nillet viewModel = PasswordUnlockViewModel(customTitle: customTitle,customSubtitle: customSubtitle,+ customButtonText: customButtonText,unlockHandler: { [weak self] password inguard let self = self else {throw NSError(domain: "VaultManager", code: -1, userInfo: [NSLocalizedDescriptionKey: "VaultManager instance deallocated"])diff --git a/apps/mobile-app/ios/VaultUI/Auth/PasswordUnlockView.swift b/apps/mobile-app/ios/VaultUI/Auth/PasswordUnlockView.swiftindex c6b25f94e..4d7d01587 100644--- a/apps/mobile-app/ios/VaultUI/Auth/PasswordUnlockView.swift+++ b/apps/mobile-app/ios/VaultUI/Auth/PasswordUnlockView.swift@@ -148,7 +148,7 @@ public struct PasswordUnlockView: View {.frame(height: 54)} else {HStack(spacing: 8) {- Text(String(localized: "unlock", bundle: locBundle))+ Text(viewModel.customButtonText ?? String(localized: "unlock", bundle: locBundle)).font(.system(size: 17, weight: .semibold))Image(systemName: "arrow.right").font(.system(size: 14, weight: .semibold))diff --git a/apps/mobile-app/ios/VaultUI/Auth/PasswordUnlockViewModel.swift b/apps/mobile-app/ios/VaultUI/Auth/PasswordUnlockViewModel.swiftindex 4739e4454..df05663b4 100644--- a/apps/mobile-app/ios/VaultUI/Auth/PasswordUnlockViewModel.swift+++ b/apps/mobile-app/ios/VaultUI/Auth/PasswordUnlockViewModel.swift@@ -12,6 +12,7 @@ public class PasswordUnlockViewModel: ObservableObject {public let customTitle: String?public let customSubtitle: String?+ public let customButtonText: String?private let unlockHandler: (String) async throws -> Voidprivate let cancelHandler: () -> Void@@ -19,11 +20,13 @@ public class PasswordUnlockViewModel: ObservableObject {public init(customTitle: String?,customSubtitle: String?,+ customButtonText: String?,unlockHandler: @escaping (String) async throws -> Void,cancelHandler: @escaping () -> Void) {self.customTitle = customTitleself.customSubtitle = customSubtitle+ self.customButtonText = customButtonTextself.unlockHandler = unlockHandlerself.cancelHandler = cancelHandler}diff --git a/apps/mobile-app/specs/NativeVaultManager.ts b/apps/mobile-app/specs/NativeVaultManager.tsindex bfeff58b8..a99c1933d 100644--- a/apps/mobile-app/specs/NativeVaultManager.ts+++ b/apps/mobile-app/specs/NativeVaultManager.ts@@ -100,14 +100,17 @@ export interface Spec extends TurboModule {// Password unlock method. Shows native password unlock screen.// Returns true if successful, null if cancelled.// If title/subtitle are null/empty, defaults to "Unlock Vault" context.- showPasswordUnlock(title: string | null, subtitle: string | null): Promise<boolean | null>;+ // If buttonText is null/empty, defaults to "Unlock".+ showPasswordUnlock(title: string | null, subtitle: string | null, buttonText: string | null): Promise<boolean | null>;// Mobile login methodsencryptDecryptionKeyForMobileLogin(publicKeyJWK: string): Promise<string>;// Re-authentication methods// Authenticate user with biometric or PIN. If title/subtitle are null/empty, defaults to "Unlock Vault" context.- authenticateUser(title: string | null, subtitle: string | null): Promise<boolean>;+ // allowedMethods: Optional array of allowed methods ('biometric', 'pin', 'password'). If null/empty, all enabled methods are allowed.+ // buttonText: Optional custom text for the unlock/confirm button. If null/empty, defaults to "Unlock".+ authenticateUser(title: string | null, subtitle: string | null, allowedMethods: string[] | null, buttonText: string | null): Promise<boolean>;// QR code scanner// Scan a QR code and return the scanned data. Returns null if cancelled or failed.diff --git a/apps/mobile-app/utils/VaultUnlockHelper.ts b/apps/mobile-app/utils/VaultUnlockHelper.tsindex 489be787e..2136b0001 100644--- a/apps/mobile-app/utils/VaultUnlockHelper.ts+++ b/apps/mobile-app/utils/VaultUnlockHelper.ts@@ -109,14 +109,18 @@ export class VaultUnlockHelper {** @param title Authentication prompt title* @param subtitle Authentication prompt subtitle+ * @param allowedMethods Optional array of allowed auth methods ('biometric', 'pin', 'password'). If null, all enabled methods are allowed.+ * @param buttonText Optional custom text for the unlock/confirm button. If null, defaults to "Unlock".* @returns Promise<boolean> indicating if authentication succeeded*/static async authenticateForAction(title: string,- subtitle: string+ subtitle: string,+ allowedMethods: string[] | null = null,+ buttonText: string | null = null): Promise<boolean> {try {- const authenticated = await NativeVaultManager.authenticateUser(title, subtitle);+ const authenticated = await NativeVaultManager.authenticateUser(title, subtitle, allowedMethods, buttonText);return authenticated;} catch (error) {console.error('Authentication error:', error);