Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Update key type docs references (#2468)
Leendert de Borst35689bbb0a2f
diff --git a/apps/browser-extension/src/entrypoints/popup/pages/auth/Login.tsx b/apps/browser-extension/src/entrypoints/popup/pages/auth/Login.tsxindex 1a491e2b7..822a4685a 100644--- a/apps/browser-extension/src/entrypoints/popup/pages/auth/Login.tsx+++ b/apps/browser-extension/src/entrypoints/popup/pages/auth/Login.tsx@@ -354,8 +354,8 @@ const Login: React.FC = () => {app.clearGlobalMessage();setIsInitialLoading(false);- // The mobile device sends the unlock key.- await handleSuccessfulAuth(result.username, result.token, result.refreshToken, result.unlockKey, result);+ // The mobile device sends its Account Key.+ await handleSuccessfulAuth(result.username, result.token, result.refreshToken, result.accountKey, result);} catch (err) {await showLoginError('Mobile login error', err);hideLoading();diff --git a/apps/browser-extension/src/entrypoints/popup/pages/auth/Unlock.tsx b/apps/browser-extension/src/entrypoints/popup/pages/auth/Unlock.tsxindex bb8512017..94e443ad6 100644--- a/apps/browser-extension/src/entrypoints/popup/pages/auth/Unlock.tsx+++ b/apps/browser-extension/src/entrypoints/popup/pages/auth/Unlock.tsx@@ -471,7 +471,7 @@ const Unlock: React.FC = () => {await authContext.setAuthTokens(result.username, result.token, result.refreshToken);// The mobile device sends its stored key.- const accountKey = await VaultKeyService.refreshKeyChain(result.unlockKey, webApi);+ const accountKey = await VaultKeyService.refreshKeyChain(result.accountKey, webApi);// Store the Account Key and derivation paramsawait dbContext.storeAccountKey(accountKey);diff --git a/apps/browser-extension/src/entrypoints/popup/pages/settings/VaultUnlockSettings.tsx b/apps/browser-extension/src/entrypoints/popup/pages/settings/VaultUnlockSettings.tsxindex 4f8bbecd6..d8ce7a9f1 100644--- a/apps/browser-extension/src/entrypoints/popup/pages/settings/VaultUnlockSettings.tsx+++ b/apps/browser-extension/src/entrypoints/popup/pages/settings/VaultUnlockSettings.tsx@@ -136,7 +136,7 @@ const VaultUnlockSettings: React.FC = () => {return;}- /* Setup PIN with the unlock key */+ /* Setup PIN with the Account Key */await setupPin(newPin, accountKey);/*diff --git a/apps/browser-extension/src/events/VaultStateEvents.ts b/apps/browser-extension/src/events/VaultStateEvents.tsindex 56fed2f33..60a2047db 100644--- a/apps/browser-extension/src/events/VaultStateEvents.ts+++ b/apps/browser-extension/src/events/VaultStateEvents.ts@@ -6,14 +6,14 @@ type Unsubscribe = () => void;type Listener = () => void;/**- * Last unlock-key value this window wrote, used to ignore our own+ * Last Account Key value this window wrote, used to ignore our own* storage events. Reset to null whenever the key is removed (any lock), so a* subsequent unlock in another window is detected as a foreign write.*/let lastOwnAccountKey: string | null = null;/**- * Record an unlock-key value that THIS window is about to write. Must be+ * Record an Account Key value that THIS window is about to write. Must be* called BEFORE the actual write so the storage watcher can skip the* resulting self-event. The popup unlock/login flows call this via* `DbContext.storeAccountKey`.diff --git a/apps/browser-extension/src/utils/constants/storageKeys.ts b/apps/browser-extension/src/utils/constants/storageKeys.tsindex e83584ff8..ec207b303 100644--- a/apps/browser-extension/src/utils/constants/storageKeys.ts+++ b/apps/browser-extension/src/utils/constants/storageKeys.ts@@ -111,7 +111,7 @@ export const StorageKeys = {/** Keys that hold auth tokens, ephemeral error state and account-scoped server state. Cleared on any logout. */export const AUTH_STORAGE_KEYS: readonly StorageKey[] = CORE_AUTH_STORAGE_KEYS;-/** Keys holding the PIN unlock material: the PIN-encrypted unlock key and the parameters that unwrap it. */+/** Keys holding the PIN unlock material: the PIN-encrypted Account Key and the parameters that unwrap it. */export const PIN_STORAGE_KEYS: readonly StorageKey[] = [StorageKeys.PIN_ENABLED,StorageKeys.PIN_ENCRYPTED_KEY,@@ -120,7 +120,7 @@ export const PIN_STORAGE_KEYS: readonly StorageKey[] = [StorageKeys.PIN_FAILED_ATTEMPTS,];-/** Keys that must not survive a vault lock: the encryption key plus anything derived from decrypted data. */+/** Keys that must not survive a vault lock: the Account Key plus anything derived from decrypted data. */export const VAULT_LOCK_STORAGE_KEYS: readonly StorageKey[] = [...CORE_VAULT_LOCK_STORAGE_KEYS,StorageKeys.PERSISTED_FORM_VALUES,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 1bf2119d0..e1e9afd2c 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@@ -352,7 +352,7 @@ class NativeVaultManager(reactContext: ReactApplicationContext) :/*** Resolve and store the vault key right after login from the unlock key (see VaultStore.resolveVaultKey).- * Resolves with the vault key; rejects with the native error code when the chain does not open or the session is gone.+ * Resolves with no value; rejects with the native error code when the chain does not open or the session is gone.* @param base64DerivedKey The password-derived key as base64* @param promise The promise to resolve*/@@ -360,8 +360,8 @@ class NativeVaultManager(reactContext: ReactApplicationContext) :override fun resolveVaultKey(base64DerivedKey: String, promise: Promise) {CoroutineScope(Dispatchers.IO).launch {try {- val key = vaultStore.resolveVaultKey(webApiService, base64DerivedKey)- withContext(Dispatchers.Main) { promise.resolve(key) }+ vaultStore.resolveVaultKey(webApiService, base64DerivedKey)+ withContext(Dispatchers.Main) { promise.resolve(null) }} catch (e: AppError) {withContext(Dispatchers.Main) { promise.reject(e.code, e.message, e) }} catch (e: Exception) {@@ -1645,9 +1645,8 @@ class NativeVaultManager(reactContext: ReactApplicationContext) :/*** Show native PIN setup UI.- * Launches the native PinUnlockActivity in setup mode.- * Gets the Account Key from memory (vault must be unlocked): the PIN protects that- * key, never the vault key.+ * Launches the native PinUnlockActivity in setup mode once the session is open (vault must be unlocked);+ * the activity reads the Account Key from the session: the PIN protects that key, never the vault key.* @param promise The promise to resolve when setup completes or rejects if cancelled/error.*/@ReactMethod@@ -1667,7 +1666,6 @@ class NativeVaultManager(reactContext: ReactApplicationContext) :// Launch PIN setup activityval intent = android.content.Intent(activity, net.aliasvault.app.pinunlock.PinUnlockActivity::class.java)intent.putExtra(net.aliasvault.app.pinunlock.PinUnlockActivity.EXTRA_MODE, net.aliasvault.app.pinunlock.PinUnlockActivity.MODE_SETUP)- intent.putExtra(net.aliasvault.app.pinunlock.PinUnlockActivity.EXTRA_SETUP_ACCOUNT_KEY, accountKey)activity.startActivityForResult(intent, PIN_SETUP_REQUEST_CODE)} catch (e: Exception) {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 05bd183c0..d6c9e959c 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@@ -127,15 +127,9 @@ class PinViewModel(return PinResult.Mismatch(context.getString(R.string.pin_mismatch))}- // Setup the PIN+ // Setup the PIN with the Account Key of the unlocked sessiontry {- if (setupAccountKey == null) {- return PinResult.Error(- "Account Key required for PIN setup",- shouldClear = false,- )- }- vaultStore.setupPin(pin, setupAccountKey)+ vaultStore.setupPin(pin)PinResult.Success(null)} catch (e: Exception) {PinResult.Error(errorMessage(e) ?: "Failed to setup PIN", shouldClear = false)diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/VaultSync.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/VaultSync.ktindex 756e6b377..151894c91 100644--- a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/VaultSync.kt+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/VaultSync.kt@@ -105,15 +105,15 @@ class VaultSync(/*** Resolve the vault key right after login: the account's key chain is opened with the unlock key* and cached as-is. The session then opens from that chain like every later unlock, and the session keeps the- * Account Key. Returns the vault key (base64).+ * Account Key.*/- suspend fun resolveVaultKey(webApiService: WebApiService, derivedKeyBase64: String): String {+ suspend fun resolveVaultKey(webApiService: WebApiService, derivedKeyBase64: String) {val result = run("resolveVaultKey", webApiService, encryptionKey = derivedKeyBase64)if (!result.optBoolean("success", false)) {throw syncError(result)}vaultStore.storeAccountKey(derivedKeyBase64)- return vaultStore.getEncryptionKeyBase64() ?: derivedKeyBase64+ vaultStore.encryptionKey}/**diff --git a/apps/mobile-app/ios/NativeVaultManager/NativeVaultManager.swift b/apps/mobile-app/ios/NativeVaultManager/NativeVaultManager.swiftindex f545da9ee..223e60d64 100644--- a/apps/mobile-app/ios/NativeVaultManager/NativeVaultManager.swift+++ b/apps/mobile-app/ios/NativeVaultManager/NativeVaultManager.swift@@ -149,8 +149,8 @@ public class NativeVaultManager: NSObject {rejecter reject: @escaping RCTPromiseRejectBlock) {Task {do {- let key = try await vaultStore.resolveVaultKey(using: webApiService, derivedKeyBase64: base64DerivedKey)- await MainActor.run { resolve(key) }+ try await vaultStore.resolveVaultKey(using: webApiService, derivedKeyBase64: base64DerivedKey)+ await MainActor.run { resolve(nil) }} catch let vaultError as AppError {await MainActor.run { reject(vaultError.code, vaultError.message, vaultError) }} catch {diff --git a/apps/mobile-app/ios/VaultStoreKit/Services/VaultSync.swift b/apps/mobile-app/ios/VaultStoreKit/Services/VaultSync.swiftindex ea9a93471..643f5ff11 100644--- a/apps/mobile-app/ios/VaultStoreKit/Services/VaultSync.swift+++ b/apps/mobile-app/ios/VaultStoreKit/Services/VaultSync.swift@@ -5,11 +5,7 @@ import VaultUtils/// The vault sync wrapper: one method per engine operation, persisting what the engine reported, and the mapping of/// its failures into the native error. The driver below it is VaultSyncEngine, which turns the Rust engine's/// commands into host actions.-///-/// When updating this logic, make sure to update the same logic on the other platforms:-/// - core/client/src/sync/VaultSync.ts (shared core client for web apps)-/// - apps/mobile-app/ios/VaultStoreKit/Services/VaultSync.swift (this file)-/// - apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/VaultSync.kt+/// Other platform implementations: VaultSync.kt (Android), VaultSync.ts (core/client).internal final class VaultSync {private let vaultStore: VaultStoreprivate var lastRun: Task<Void, Never>?@@ -77,14 +73,14 @@ internal final class VaultSync {/// Resolve the vault key right after login: the account's key chain is opened with the unlock key (the password's/// Argon2id output) and cached as-is. The session then opens from that chain like every later unlock, and the session- /// keeps the Account Key. Returns the vault key (base64).- func resolveVaultKey(using webApiService: WebApiService, derivedKeyBase64: String) async throws -> String {+ /// keeps the Account Key. Throws when the vault key does not open from the new session.+ func resolveVaultKey(using webApiService: WebApiService, derivedKeyBase64: String) async throws {let result = try await run("resolveVaultKey", using: webApiService, encryptionKey: derivedKeyBase64)guard result["success"] as? Bool == true else {throw Self.syncError(from: result)}try vaultStore.storeAccountKey(base64Key: derivedKeyBase64)- return try vaultStore.getEncryptionKeyBase64()+ _ = try vaultStore.getEncryptionKey()}/// Classify the pending manifest migration as the engine sees it: `none`, `schemaRebuild` (runs unattended) ordiff --git a/apps/mobile-app/ios/VaultStoreKit/VaultStore+Sync.swift b/apps/mobile-app/ios/VaultStoreKit/VaultStore+Sync.swiftindex 0840aa10d..6ad013e57 100644--- a/apps/mobile-app/ios/VaultStoreKit/VaultStore+Sync.swift+++ b/apps/mobile-app/ios/VaultStoreKit/VaultStore+Sync.swift@@ -38,8 +38,8 @@ extension VaultStore {}/// Resolve and store the vault key right after login from the password-derived key (see VaultSync.resolveVaultKey).- public func resolveVaultKey(using webApiService: WebApiService, derivedKeyBase64: String) async throws -> String {- return try await sync.resolveVaultKey(using: webApiService, derivedKeyBase64: derivedKeyBase64)+ public func resolveVaultKey(using webApiService: WebApiService, derivedKeyBase64: String) async throws {+ try await sync.resolveVaultKey(using: webApiService, derivedKeyBase64: derivedKeyBase64)}/// Classify the pending manifest migration (see VaultSync.getVaultMigrationStatus).diff --git a/apps/mobile-app/specs/NativeVaultManager.ts b/apps/mobile-app/specs/NativeVaultManager.tsindex c07099fa3..903f1628c 100644--- a/apps/mobile-app/specs/NativeVaultManager.ts+++ b/apps/mobile-app/specs/NativeVaultManager.ts@@ -69,7 +69,7 @@ export interface Spec extends TurboModule {storeUnlockKeyDerivationParams(keyDerivationParams: string): Promise<void>;getUnlockKeyDerivationParams(): Promise<string | null>;getAccountKeyChain(): Promise<string | null>;- resolveVaultKey(base64DerivedKey: string): Promise<string>;+ resolveVaultKey(base64DerivedKey: string): Promise<void>;getPersonalManifestId(): Promise<string | null>;decryptInvitationName(encryptedName: string): Promise<string | null>;hasEncryptedDatabase(): Promise<boolean>;diff --git a/apps/server/AliasVault.Admin/Main/Pages/Users/View/Index.razor b/apps/server/AliasVault.Admin/Main/Pages/Users/View/Index.razorindex 0ba0d0504..4c6c0fefa 100644--- a/apps/server/AliasVault.Admin/Main/Pages/Users/View/Index.razor+++ b/apps/server/AliasVault.Admin/Main/Pages/Users/View/Index.razor@@ -741,11 +741,10 @@ Do you want to proceed with the revert?"))await writeContext.AliasVaultUsers.Where(x => x.Id == User!.Id).ExecuteUpdateAsync(s => s.SetProperty(x => x.PasswordChangedAt, now));await writeContext.AliasVaultUserRefreshTokens.Where(x => x.UserId == User!.Id).ExecuteDeleteAsync();-- // Archive what is being replaced so the revert itself can be undone, then restore and consume the entry.- writeContext.UserUnlockKeysHistory.Add(UserUnlockKeysHistory.CreateFrom(target, now, "admin-revert"));- source.RestoreOnto(target, now);writeContext.UserUnlockKeysHistory.Remove(source);+ await writeContext.SaveChangesAsync();+ await UnlockKeyHistoryPolicy.ArchiveAsync(writeContext, target, UnlockKeyHistoryRetentionDays, now, "admin-revert");+ source.RestoreOnto(target, now);await writeContext.SaveChangesAsync();await transaction.CommitAsync();