Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Remove redundant NotConfigured error case (#1340)
Leendert de Borst3cc8c9f5de3d
diff --git a/apps/browser-extension/src/entrypoints/popup/pages/auth/Unlock.tsx b/apps/browser-extension/src/entrypoints/popup/pages/auth/Unlock.tsxindex f6310c718..5b5ca3210 100644--- a/apps/browser-extension/src/entrypoints/popup/pages/auth/Unlock.tsx+++ b/apps/browser-extension/src/entrypoints/popup/pages/auth/Unlock.tsx@@ -27,7 +27,6 @@ import {PinLockedError,IncorrectPinError,InvalidPinFormatError,- PinNotConfiguredError,resetFailedAttempts,unlockWithPin} from '@/utils/PinUnlockService';@@ -341,9 +340,6 @@ const Unlock: React.FC = () => {} else if (err instanceof InvalidPinFormatError) {setError(t('settings.unlockMethod.invalidPinFormat'));setPin('');- } else if (err instanceof PinNotConfiguredError) {- setError(t('settings.unlockMethod.pinNotConfigured'));- setPin('');} else {console.error('PIN unlock failed:', err);setError(t('common.errors.unknownErrorTryAgain'));diff --git a/apps/browser-extension/src/i18n/locales/en.json b/apps/browser-extension/src/i18n/locales/en.jsonindex 1250de8e7..1c0d8a5aa 100644--- a/apps/browser-extension/src/i18n/locales/en.json+++ b/apps/browser-extension/src/i18n/locales/en.json@@ -376,7 +376,6 @@"pinMismatch": "PINs do not match","incorrectPin": "Incorrect PIN. {{attemptsRemaining}} attempts remaining.","incorrectPinSingular": "Incorrect PIN. 1 attempt remaining.",- "pinNotConfigured": "PIN unlock is not configured.","enableSuccess": "PIN unlock enabled successfully!","pinLocked": "PIN unlock has been disabled. Please use your master password to unlock your vault.","unlockVaultFirst": "Please unlock your vault first before setting up PIN.",diff --git a/apps/browser-extension/src/utils/PinUnlockService.ts b/apps/browser-extension/src/utils/PinUnlockService.tsindex 492a998b0..55da35ee4 100644--- a/apps/browser-extension/src/utils/PinUnlockService.ts+++ b/apps/browser-extension/src/utils/PinUnlockService.ts@@ -82,20 +82,6 @@ export class IncorrectPinError extends Error {}}-/**- * Error thrown when PIN unlock is not configured.- * Translation key: settings.unlockMethod.pinNotConfigured- */-export class PinNotConfiguredError extends Error {- /**- * Creates a new instance of PinNotConfiguredError.- */- public constructor() {- super('PIN unlock is not configured');- this.name = 'PinNotConfiguredError';- }-}-/*** Error thrown when encryption key is not available for PIN setup.* Translation key: settings.unlockMethod.unlockVaultFirst@@ -242,7 +228,7 @@ export async function unlockWithPin(pin: string): Promise<string> {]);if (!encryptedKeyBase64 || !saltBase64) {- throw new PinNotConfiguredError();+ throw new PinLockedError();}// Decode encrypted packagediff --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 191b3a27b..f42a96b74 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@@ -1294,7 +1294,7 @@ class NativeVaultManager(reactContext: ReactApplicationContext) :* @param promise The promise to resolve when setup completes or rejects if cancelled/error.*/@ReactMethod- override fun showNativePinSetup(promise: Promise) {+ override fun showPinSetup(promise: Promise) {// Get encryption key firstvaultStore.getEncryptionKey(object : net.aliasvault.app.vaultstore.interfaces.CryptoOperationCallback {override fun onSuccess(encryptionKey: String) {diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/pinunlock/PinViewModel.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/pinunlock/PinViewModel.ktindex d6f343505..2f1d5150c 100644--- a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/pinunlock/PinViewModel.kt+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/pinunlock/PinViewModel.kt@@ -64,12 +64,6 @@ class PinViewModel(PinResult.Success(encryptionKey)} catch (e: PinUnlockException) {when (e) {- is PinUnlockException.NotConfigured -> {- PinResult.Error(- context.getString(R.string.pin_not_configured),- shouldClear = false,- )- }is PinUnlockException.Locked -> {PinResult.PinDisabled}diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/VaultPin.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/VaultPin.ktindex 1f45e6f46..f4710d010 100644--- a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/VaultPin.kt+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/VaultPin.kt@@ -23,9 +23,6 @@ import javax.crypto.spec.SecretKeySpec* UI layer should handle localization based on these exception types.*/sealed class PinUnlockException(message: String) : Exception(message) {- /** PIN is not configured. */- object NotConfigured : PinUnlockException("PIN unlock is not configured")-/** PIN is locked after too many failed attempts. */object Locked : PinUnlockException("PIN locked after too many failed attempts")@@ -38,7 +35,6 @@ sealed class PinUnlockException(message: String) : Exception(message) {/** Get error code for React Native bridge compatibility. */val errorCode: Stringget() = when (this) {- is NotConfigured -> "PIN_NOT_CONFIGURED"is Locked -> "PIN_LOCKED"is IncorrectPin -> "INCORRECT_PIN"}@@ -209,11 +205,6 @@ class VaultPin(@Throws(PinUnlockException::class)@Suppress("SwallowedException") // We intentionally swallow to avoid exposing crypto implementation detailsfun unlockWithPin(pin: String): String {- // Check if PIN is enabled- if (!isPinEnabled()) {- throw PinUnlockException.NotConfigured- }-try {// Retrieve encrypted key and salt from Keystoreval (encryptedKey, salt) = retrievePinDataFromKeystore()diff --git a/apps/mobile-app/android/app/src/main/res/values/strings.xml b/apps/mobile-app/android/app/src/main/res/values/strings.xmlindex 7d64c1d03..7ded86dc2 100644--- a/apps/mobile-app/android/app/src/main/res/values/strings.xml+++ b/apps/mobile-app/android/app/src/main/res/values/strings.xml@@ -78,7 +78,6 @@<string name="pin_enter_to_unlock">Enter your PIN to unlock your vault</string><string name="pin_cancel">Cancel</string><string name="pin_unlock_failed">Unlock failed</string>- <string name="pin_not_configured">PIN unlock is not configured</string><string name="pin_locked_max_attempts">PIN locked after too many failed attempts</string><string name="pin_incorrect_attempts_remaining">Incorrect PIN. %d attempts remaining</string>diff --git a/apps/mobile-app/ios/VaultModels/PinUnlockError.swift b/apps/mobile-app/ios/VaultModels/PinUnlockError.swiftindex 2d35038c7..1ea580598 100644--- a/apps/mobile-app/ios/VaultModels/PinUnlockError.swift+++ b/apps/mobile-app/ios/VaultModels/PinUnlockError.swift@@ -3,9 +3,6 @@ import Foundation/// Error types for PIN unlock operations/// This is in VaultModels so both VaultStoreKit and VaultUI can access it without circular dependenciespublic enum PinUnlockError: Error {- /// PIN is not configured- case notConfigured-/// PIN is locked after too many failed attemptscase locked@@ -15,7 +12,6 @@ public enum PinUnlockError: Error {/// Get error code for React Native bridge compatibilitypublic var code: String {switch self {- case .notConfigured: return "PIN_NOT_CONFIGURED"case .locked: return "PIN_LOCKED"case .incorrectPin: return "INCORRECT_PIN"}diff --git a/apps/mobile-app/ios/VaultStoreKit/VaultStore+Pin.swift b/apps/mobile-app/ios/VaultStoreKit/VaultStore+Pin.swiftindex 800c72cb1..a2502a49d 100644--- a/apps/mobile-app/ios/VaultStoreKit/VaultStore+Pin.swift+++ b/apps/mobile-app/ios/VaultStoreKit/VaultStore+Pin.swift@@ -88,11 +88,6 @@ extension VaultStore {/// - Returns: The decrypted vault encryption key (base64)/// - Throws: PinUnlockError with specific error type and metadatapublic func unlockWithPin(_ pin: String) throws -> String {- // Check if PIN is enabled- guard isPinEnabled() else {- throw PinUnlockError.notConfigured- }-do {// Retrieve encrypted key and salt from keychainlet (encryptedKey, salt) = try retrievePinDataFromKeychain()diff --git a/apps/mobile-app/ios/VaultUI/Auth/PinUnlockView.swift b/apps/mobile-app/ios/VaultUI/Auth/PinUnlockView.swiftindex 9fb4ad986..c1699422b 100644--- a/apps/mobile-app/ios/VaultUI/Auth/PinUnlockView.swift+++ b/apps/mobile-app/ios/VaultUI/Auth/PinUnlockView.swift@@ -281,19 +281,6 @@ public class PinUnlockViewModel: ObservableObject {} catch let pinError as PinUnlockError {// Handle PinUnlockError with localized messagesswitch pinError {- case .notConfigured:- // PIN was disabled/not configured- isUnlocking = false- self.error = String(localized: "pin_not_configured", bundle: locBundle)- triggerErrorFeedback()-- // Wait to let user see the error message- try? await Task.sleep(nanoseconds: 1_000_000_000) // 1 second-- // Clear the error and dismiss- self.error = nil- cancelHandler()- returncase .locked:// PIN locked after too many attemptsdiff --git a/apps/mobile-app/ios/VaultUI/en.lproj/Localizable.strings b/apps/mobile-app/ios/VaultUI/en.lproj/Localizable.stringsindex 14b6b57d6..c2d5a2bdc 100644--- a/apps/mobile-app/ios/VaultUI/en.lproj/Localizable.strings+++ b/apps/mobile-app/ios/VaultUI/en.lproj/Localizable.strings@@ -62,10 +62,8 @@"enter_pin" = "Enter PIN";"enter_pin_to_unlock_vault" = "Enter your PIN to unlock your vault";"unlock_failed" = "Unlock failed";-"unlocking" = "Unlocking...";/* PIN Error Messages */-"pin_not_configured" = "PIN unlock is not configured";"pin_locked_max_attempts" = "PIN locked after too many failed attempts";"pin_incorrect_attempts_remaining" = "Incorrect PIN. %d attempts remaining";