Skip to content

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

Update change password screen in web app to include key rotate option (#2524)

Leendert de Borstc2627e3b1a9f
diff --git a/apps/web/src/pages/settings/security/ChangePassword.tsx b/apps/web/src/pages/settings/security/ChangePassword.tsx
index 343faf057..60a5bdbd2 100644
--- a/apps/web/src/pages/settings/security/ChangePassword.tsx
+++ b/apps/web/src/pages/settings/security/ChangePassword.tsx
@@ -1,40 +1,64 @@
import { apiErrorMessage } from '@aliasvault/client/api/errors/ApiErrorMessage';
import { IncorrectPasswordError, MasterPasswordService, PasswordChangedElsewhereError } from '@aliasvault/client/auth/MasterPasswordService';
+import { syncErrorMessage } from '@aliasvault/client/sync/SyncErrorMessage';
import { MIN_ACCEPTED_PASSWORD_LENGTH } from '@aliasvault/client/utilities/PasswordStrength';
import React, { useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
+import { useNavigate } from 'react-router-dom';
+import WarningBox from '@/components/alerts/WarningBox';
import PasswordInputField from '@/components/auth/PasswordInputField';
import SettingsPageHeader from '@/components/settings/SettingsPageHeader';
import Card from '@/components/shared/Card';
import FormLabel from '@/components/shared/FormLabel';
import PasswordStrengthIndicator from '@/components/shared/PasswordStrengthIndicator';
+import { useAuth } from '@/context/AuthContext';
import { useDb } from '@/context/DbContext';
import { useLoading } from '@/context/LoadingContext';
import { useNotifications } from '@/context/NotificationContext';
import { useWebApi } from '@/context/WebApiContext';
import { usePageTitle } from '@/hooks/usePageTitle';
import { useVaultSync } from '@/hooks/useVaultSync';
+import { WebAuthnService } from '@/utils/WebAuthnService';
+import { vaultStore } from '@/vault/VaultStore';
+
+import type { KeyRotationOperationResult } from '@aliasvault/client/sync/VaultSync';
+import type { VaultSyncKeyRotationRefusal } from '@aliasvault/client/sync/VaultSyncEngine';
+import type { TranslationKey } from '@aliasvault/i18n';
const VALIDATION_DEBOUNCE_MS = 800;
+/** What the page tells the user for each reason the engine did not run the rotation. */
+const REFUSAL_KEYS: Record<VaultSyncKeyRotationRefusal, TranslationKey> = {
+ vaultOutOfDate: 'apiErrors.VAULT_NOT_UP_TO_DATE',
+ serverStateChanged: 'apiErrors.VAULT_NOT_UP_TO_DATE',
+ sharedVaultKeyUnavailable: 'common.errors.unexpectedErrorContactSupport',
+ vaultUpgradeRequired: 'content.vaultUpgradeRequired',
+};
+
/**
- * The change master password page.
+ * The change master password page. A regular change keeps the encryption keys; behind the advanced options the user
+ * can also replace every encryption key along with the password, after acknowledging the risks and signing out their other devices.
*/
const ChangePassword: React.FC = () => {
const { t } = useTranslation();
+ const navigate = useNavigate();
+ const auth = useAuth();
const dbContext = useDb();
const webApi = useWebApi();
const notifications = useNotifications();
const { showLoading, hideLoading } = useLoading();
const { syncVault } = useVaultSync();
-
+
usePageTitle(t('settings.securitySettings.changeMasterPassword'));
+ const [showAdvanced, setShowAdvanced] = useState(false);
+ const [rotateKeys, setRotateKeys] = useState(false);
const [currentPassword, setCurrentPassword] = useState('');
const [newPassword, setNewPassword] = useState('');
const [newPasswordConfirm, setNewPasswordConfirm] = useState('');
const [validationError, setValidationError] = useState('');
+ const [acknowledged, setAcknowledged] = useState(false);
const debounceTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
/**
@@ -72,10 +96,55 @@ const ChangePassword: React.FC = () => {
validate(newPassword, value);
};
- const isSubmitEnabled = currentPassword.trim().length > 0 && newPassword.trim().length > 0 && newPasswordConfirm.trim().length > 0 && newPassword === newPasswordConfirm && validationError.length === 0 && newPassword.length >= MIN_ACCEPTED_PASSWORD_LENGTH;
+ const passwordsValid = currentPassword.trim().length > 0 && newPassword.trim().length > 0 && newPasswordConfirm.trim().length > 0 && newPassword === newPasswordConfirm && validationError.length === 0 && newPassword.length >= MIN_ACCEPTED_PASSWORD_LENGTH;
+ const rotationReady = !rotateKeys || (acknowledged && !dbContext.isOffline);
+ const isSubmitEnabled = passwordsValid && rotationReady;
+
+ /**
+ * The message for a rotation the engine refused or failed, or null when it went through.
+ */
+ const rotationOutcomeMessage = (result: KeyRotationOperationResult): string | null => {
+ if (result.success) {
+ return null;
+ }
+ if (result.refusal) {
+ return t(REFUSAL_KEYS[result.refusal]);
+ }
+ const detail = syncErrorMessage(result, t);
+ return detail ? `${t('settings.securitySettings.changePassword.failedToChangePassword')}\n${detail}` : t('settings.securitySettings.changePassword.failedToChangePassword');
+ };
/**
- * Submit password change.
+ * Change the password and rotate every key; on success the page moves on to the settings overview.
+ */
+ const changePasswordAndRotateKeys = async (): Promise<void> => {
+ // The engine refuses a vault out of step with the server, so sync first.
+ if (!await syncVault()) {
+ notifications.addErrorMessage(t('apiErrors.VAULT_NOT_UP_TO_DATE'), true);
+ return;
+ }
+
+ const result = await MasterPasswordService.changePasswordAndRotateKeys(webApi, params => vaultStore.rotateAccountKeys(params), currentPassword, newPassword);
+ if (result.requiresLogout) {
+ await auth.logout({ errorMessage: syncErrorMessage(result, t) });
+ return;
+ }
+
+ const message = rotationOutcomeMessage(result);
+ if (message) {
+ notifications.addErrorMessage(message, true);
+ return;
+ }
+
+ // The passkey unlock on this browser holds the old Account Key.
+ WebAuthnService.disable();
+ await dbContext.loadStoredDatabase();
+ notifications.addSuccessMessage(t('settings.securitySettings.changePassword.passwordChangedSuccessfully'));
+ navigate('/settings');
+ };
+
+ /**
+ * Submit the change.
*/
const changePassword = async (e: React.FormEvent): Promise<void> => {
e.preventDefault();
@@ -88,6 +157,10 @@ const ChangePassword: React.FC = () => {
showLoading(t('settings.securitySettings.changePassword.changingPasswordMessage'));
notifications.clearMessages();
try {
+ if (rotateKeys) {
+ await changePasswordAndRotateKeys();
+ return;
+ }
await MasterPasswordService.changePassword(webApi, currentPassword, newPassword);
setCurrentPassword('');
setNewPassword('');
@@ -130,9 +203,43 @@ const ChangePassword: React.FC = () => {
<FormLabel htmlFor="newPasswordConfirm">{t('settings.securitySettings.changePassword.confirmNewPassword')}</FormLabel>
<PasswordInputField id="newPasswordConfirm" value={newPasswordConfirm} onValueChange={onConfirmChange} placeholder={t('settings.securitySettings.changePassword.confirmNewPassword')} />
</div>
+
{validationError.length > 0 && <div className="mt-2 text-sm text-red-600 dark:text-red-400">{validationError}</div>}
- <button type="submit" disabled={!isSubmitEnabled} className={`w-full bg-primary-500 text-white py-2 px-4 rounded-md hover:bg-primary-600 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2 transition duration-150 ease-in-out ${isSubmitEnabled ? '' : 'opacity-50 cursor-not-allowed'}`}>
- {t('settings.securitySettings.changePassword.changePassword')}
+
+ <button type="button" onClick={() => setShowAdvanced(!showAdvanced)} aria-expanded={showAdvanced} className="text-sm text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200">
+ {showAdvanced ? '\u25BE' : '\u25B8'} {t('app.loginSettings.advancedSettings')}
+ </button>
+
+ {showAdvanced && (
+ <label className="flex items-start gap-2 text-sm text-gray-700 dark:text-gray-300">
+ <input type="checkbox" className="mt-0.5 h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300 rounded dark:bg-gray-700 dark:border-gray-600" checked={rotateKeys} onChange={e => setRotateKeys(e.target.checked)} />
+ <span>
+ <span className="block font-medium">{t('settings.securitySettings.keyRotation.optionRotateKeys')}</span>
+ <span className="block text-gray-600 dark:text-gray-400">{t('settings.securitySettings.keyRotation.optionRotateKeysDescription')}</span>
+ </span>
+ </label>
+ )}
+
+ {rotateKeys && (
+ <>
+ <WarningBox icon="exclamation">
+ <p><span className="font-semibold">{t('common.highRiskAction')}</span> {t('common.beforeYouContinue')}</p>
+ <ul className="list-disc pl-5 mt-2 space-y-1">
+ <li>{t('settings.securitySettings.keyRotation.riskSignOut')}</li>
+ <li>{t('settings.securitySettings.keyRotation.riskBackup')}</li>
+ <li>{t('settings.securitySettings.keyRotation.riskAfterwards')}</li>
+ </ul>
+ </WarningBox>
+
+ <label className="flex items-start gap-2 text-sm text-gray-700 dark:text-gray-300">
+ <input type="checkbox" className="mt-0.5 h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300 rounded dark:bg-gray-700 dark:border-gray-600" checked={acknowledged} onChange={e => setAcknowledged(e.target.checked)} />
+ <span>{t('settings.securitySettings.keyRotation.acknowledge')}</span>
+ </label>
+ </>
+ )}
+
+ <button type="submit" disabled={!isSubmitEnabled} className={`w-full text-white py-2 px-4 rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2 transition duration-150 ease-in-out ${rotateKeys ? 'bg-red-600 hover:bg-red-700 focus:ring-red-500' : 'bg-primary-500 hover:bg-primary-600 focus:ring-primary-500'} ${isSubmitEnabled ? '' : 'opacity-50 cursor-not-allowed'}`}>
+ {rotateKeys ? t('settings.securitySettings.keyRotation.changePasswordAndRotate') : t('settings.securitySettings.changePassword.changePassword')}
</button>
</form>
</Card>
diff --git a/apps/web/src/vault/VaultStore.ts b/apps/web/src/vault/VaultStore.ts
index cda37a8bd..358d39048 100644
--- a/apps/web/src/vault/VaultStore.ts
+++ b/apps/web/src/vault/VaultStore.ts
@@ -10,8 +10,8 @@ import { getPlatform } from '@aliasvault/client/platform';
import { clearDirtyScopes, getDirtyScopes } from '@aliasvault/client/sync/VaultDirtyState';
import { vaultRequiresManifestMigration, VaultMigrationKind } from '@aliasvault/client/sync/VaultManifestMigration';
import { DEFAULT_VAULT_MUTATION_SCOPE, hasUserVisibleScope, type VaultMutationScope } from '@aliasvault/client/sync/VaultMutationScope';
-import { hasSyncError, syncResult, VaultSync, type FullVaultSyncResult, type SharedManifestDetails, type SharingOperationResult, type VaultManifestMigrationResult } from '@aliasvault/client/sync/VaultSync';
-import { type IVaultSyncEngineHost, type VaultSyncOptions, type VaultSyncPhase as EngineSyncPhase, type VaultSyncStoreOutcome, type VaultSyncStoreRequest } from '@aliasvault/client/sync/VaultSyncEngine';
+import { hasSyncError, syncResult, VaultSync, type FullVaultSyncResult, type KeyRotationOperationResult, type SharedManifestDetails, type SharingOperationResult, type VaultManifestMigrationResult } from '@aliasvault/client/sync/VaultSync';
+import { type IVaultSyncEngineHost, type VaultSyncKeyRotationParams, type VaultSyncOptions, type VaultSyncPhase as EngineSyncPhase, type VaultSyncStoreOutcome, type VaultSyncStoreRequest } from '@aliasvault/client/sync/VaultSyncEngine';
import { getVaultSyncHoldReason } from '@aliasvault/client/sync/VaultSyncHold';
import i18n from '@/i18n/i18n';
@@ -526,4 +526,17 @@ export const vaultStore = {
updateSharedManifest(groupId: string, manifestId: string, details: SharedManifestDetails): Promise<SharingOperationResult> {
return vaultSync.updateSharedManifest(groupId, manifestId, details);
},
+
+ /**
+ * Rotate the account's encryption keys and re-encrypt the personal vault under them.
+ * @param params - the password proof and the new unlock method and keypair
+ */
+ async rotateAccountKeys(params: VaultSyncKeyRotationParams): Promise<KeyRotationOperationResult> {
+ const result = await vaultSync.rotateAccountKeys(params);
+ if (result.success) {
+ // The engine stored the vault under the new key; the cached client still holds the old one.
+ cleanupCachedSqliteClient();
+ }
+ return result;
+ },
};
diff --git a/core/client/src/auth/MasterPasswordService.ts b/core/client/src/auth/MasterPasswordService.ts
index e4f364f8b..537ce6843 100644
--- a/core/client/src/auth/MasterPasswordService.ts
+++ b/core/client/src/auth/MasterPasswordService.ts
@@ -1,6 +1,8 @@
-import { VaultKeyAlgorithm, type PasswordChangeInitiateResponse, type PasswordChangeRequest } from '@aliasvault/models/webapi';
+import { VaultKeyAlgorithm, type KeyRotationInitiateResponse, type PasswordChangeInitiateResponse, type PasswordChangeRequest } from '@aliasvault/models/webapi';
+import { AppErrorCode, extractErrorCode } from '../api/errors/AppErrorCodes';
import { StorageKeys } from '../constants/StorageKeys';
+import { EncryptionUtility } from '../crypto/EncryptionUtility';
import { getPlatform } from '../platform/ClientPlatform';
import { reencryptAccountKey } from '../rust/RustCore';
import { VaultSyncHoldReason, withVaultSyncHold } from '../sync/VaultSyncHold';
@@ -9,6 +11,8 @@ import { SrpAuthService, type SrpClientProof } from './SrpAuthService';
import { VaultKeyService } from './VaultKeyService';
import type { WebApiService } from '../api/WebApiService';
+import type { KeyRotationOperationResult } from '../sync/VaultSync';
+import type { VaultSyncKeyRotationParams } from '../sync/VaultSyncEngine';
import type { UnlockKeyDerivationParams } from '@aliasvault/models/metadata';
/**
@@ -51,8 +55,11 @@ export type SrpChallengeAnswer = {
srpIdentity: string;
};
+/** Runs the engine's key rotation operation, supplied by the host that owns the engine. */
+export type RunKeyRotation = (params: VaultSyncKeyRotationParams) => Promise<KeyRotationOperationResult>;
+
/**
- * MasterPasswordService handling all master password operations.
+ * MasterPasswordService handling all master password operations: a password change, optionally together with a rotation of every encryption key.
*/
export class MasterPasswordService {
/**
@@ -161,6 +168,79 @@ export class MasterPasswordService {
// Persist the new Account Key and its derivation parameters.
await VaultKeyService.persistNewAccountKey(newEncryptedAccountKey, { salt: next.salt, encryptionType: next.encryptionType, encryptionSettings: next.encryptionSettings }, accountKey);
}
+
+ /**
+ * Change the master password and rotate every encryption key: a new Account Key, personal vault key, account keypair and
+ * signing keypair, with the personal vault re-encrypted and every shared-vault grant rewrapped. The Rust engine does the rotation.
+ * @param webApi - the API client to use
+ * @param runRotation - runs the engine's rotation operation
+ * @param currentPassword - the current master password
+ * @param newPassword - the new master password
+ * @throws {IncorrectPasswordError} when the current password is wrong (detected locally).
+ * @throws {PasswordChangedElsewhereError} when the password was changed on another device.
+ * @throws {ApiRequestError} when the server refuses the initiate call.
+ */
+ public static async changePasswordAndRotateKeys(webApi: WebApiService, runRotation: RunKeyRotation, currentPassword: string, newPassword: string): Promise<KeyRotationOperationResult> {
+ return withVaultSyncHold(VaultSyncHoldReason.KeyRotation, () => MasterPasswordService.performRotation(webApi, runRotation, currentPassword, newPassword));
+ }
+
+ /**
+ * Prove the current password, derive the new unlock method, generate the new account keypair and run the rotation.
+ * @param webApi - the API client to use
+ * @param runRotation - runs the engine's rotation operation
+ * @param currentPassword - the current master password
+ * @param newPassword - the new master password
+ */
+ private static async performRotation(webApi: WebApiService, runRotation: RunKeyRotation, currentPassword: string, newPassword: string): Promise<KeyRotationOperationResult> {
+ const storedParams = await MasterPasswordService.getStoredDerivationParams();
+ if (!storedParams || !await VaultKeyService.hasLocalVaultKey()) {
+ throw new Error('Key rotation requires an unlocked account-key vault');
+ }
+
+ const challenge = await webApi.get<KeyRotationInitiateResponse>('KeyRotation/initiate');
+ await MasterPasswordService.assertSaltUnchanged(challenge.salt);
+
+ const current = await MasterPasswordService.answerSrpChallenge(challenge, currentPassword);
+ await MasterPasswordService.assertPasswordOpensChain(current.unlockKeyBase64);
+ const next = await SrpAuthService.prepareNewPassword(newPassword, current.srpIdentity);
+ const keyPair = await EncryptionUtility.generateRsaKeyPair();
+
+ const result = await runRotation({
+ userId: challenge.userId,
+ currentClientPublicEphemeral: current.proof.clientPublicEphemeral,
+ currentClientSessionProof: current.proof.clientSessionProof,
+ accountKeyVersion: challenge.accountKeyVersion,
+ manifestKeyVersion: challenge.manifestKeyVersion,
+ newUnlockKey: next.unlockKeyBase64,
+ newSalt: next.salt,
+ newVerifier: next.verifier,
+ newEncryptionType: next.encryptionType,
+ newEncryptionSettings: next.encryptionSettings,
+ newAccountPublicKey: keyPair.publicKey,
+ newAccountPrivateKey: keyPair.privateKey,
+ });
+
+ if (result.success && result.accountKey) {
+ await getPlatform().storage.set(StorageKeys.ACCOUNT_KEY, result.accountKey);
+ }
+ return result;
+ }
+
+ /**
+ * Check locally that the typed password opens the cached chain, so a wrong password never reaches the server (and the lockout counter).
+ * @param unlockKeyBase64 - the unlock key derived from the typed password
+ * @throws {IncorrectPasswordError} when it does not.
+ */
+ private static async assertPasswordOpensChain(unlockKeyBase64: string): Promise<void> {
+ try {
+ await VaultKeyService.openKeyChain(unlockKeyBase64);
+ } catch (error) {
+ if (error instanceof Error && extractErrorCode(error.message) === AppErrorCode.UNLOCK_KEY_REJECTED) {
+ throw new IncorrectPasswordError();
+ }
+ throw error;
+ }
+ }
}
export default MasterPasswordService;
diff --git a/core/client/src/sync/VaultSync.ts b/core/client/src/sync/VaultSync.ts
index fd7df50d3..66ddbac05 100644
--- a/core/client/src/sync/VaultSync.ts
+++ b/core/client/src/sync/VaultSync.ts
@@ -20,7 +20,7 @@ import { devError, devLog, devWarn } from '../platform/Logger';
import { VaultMigrationKind } from './VaultManifestMigration';
import { buildVaultSyncRequest, runVaultSyncEngine } from './VaultSyncEngine';
-import type { IVaultSyncEngineHost, LogoutReason, VaultSyncEmailDomains, VaultSyncEngineRequest, VaultSyncEngineResult, VaultSyncEngineResultBase, VaultSyncMigrateManifestResult, VaultSyncMigrationStatusResult, VaultSyncOperation, VaultSyncOptions, VaultSyncSharingParams, VaultSyncSharingResult } from './VaultSyncEngine';
+import type { IVaultSyncEngineHost, LogoutReason, VaultSyncEmailDomains, VaultSyncEngineRequest, VaultSyncEngineResult, VaultSyncEngineResultBase, VaultSyncKeyRotationParams, VaultSyncKeyRotationRefusal, VaultSyncKeyRotationResult, VaultSyncMigrateManifestResult, VaultSyncMigrationStatusResult, VaultSyncOperation, VaultSyncOptions, VaultSyncSharingParams, VaultSyncSharingResult } from './VaultSyncEngine';
import type { SqliteClient } from '../database/SqliteClient';
import type { TranslationKey } from '@aliasvault/i18n';
@@ -63,6 +63,16 @@ export type SharedManifestDetails = {
name?: string;
};
+/**
+ * Result of a key rotation as the UI reads it.
+ */
+export type KeyRotationOperationResult = SyncErrorDetail & {
+ success: boolean;
+ accountKey?: string;
+ refusal?: VaultSyncKeyRotationRefusal;
+ requiresLogout: boolean;
+};
+
/**
* Result of a sharing operation as the UI reads it.
*/
@@ -199,6 +209,22 @@ export class VaultSync {
return this.runSharingOperation('updateSharedManifest', { groupId, manifestId, ...details });
}
+ /**
+ * Rotate the account's keys: the engine re-encrypts the personal vault and rewraps every grant under new keys, which
+ * the server applies in one transaction. On success the vault and the cached chain are stored under the new keys. Never throws.
+ * @param params - the password proof and the new unlock method and keypair
+ */
+ public async rotateAccountKeys(params: VaultSyncKeyRotationParams): Promise<KeyRotationOperationResult> {
+ try {
+ const result = await this.run<VaultSyncKeyRotationResult>('rotateAccountKeys', {}, { keyRotation: params });
+ return { success: result.success, accountKey: result.accountKey, refusal: result.refusal, requiresLogout: result.requiresLogout, ...VaultSync.syncError(result) };
+ } catch (error) {
+ const detail = VaultSync.driverError(error);
+ devError(`[KeyRotation] Rotation failed (${detail.errorCode ?? 'no code'}): ${detail.error ?? 'no detail'}`);
+ return { success: false, requiresLogout: false, ...detail };
+ }
+ }
+
/**
* Run one sharing operation.
* @param operation - the operation
@@ -260,7 +286,7 @@ export class VaultSync {
* @param options - what the caller asks beyond what the engine decides
* @param overrides - what one operation sets on the request itself: the unlock key resolveVaultKey runs on, or the target of a sharing operation
*/
- private run<T extends VaultSyncEngineResultBase>(operation: VaultSyncOperation, options: VaultSyncOptions = {}, overrides: Partial<Pick<VaultSyncEngineRequest, 'encryptionKey' | 'sharing'>> = {}): Promise<T> {
+ private run<T extends VaultSyncEngineResultBase>(operation: VaultSyncOperation, options: VaultSyncOptions = {}, overrides: Partial<Pick<VaultSyncEngineRequest, 'encryptionKey' | 'sharing' | 'keyRotation'>> = {}): Promise<T> {
const run = this.queue.then(async () => {
const request = { ...await buildVaultSyncRequest(operation, options), ...overrides };
const result = await runVaultSyncEngine<T>(this.host, request, this.webApi);
diff --git a/core/client/src/sync/VaultSyncEngine.ts b/core/client/src/sync/VaultSyncEngine.ts
index 83fcf1ed8..8c109f1ec 100644
--- a/core/client/src/sync/VaultSyncEngine.ts
+++ b/core/client/src/sync/VaultSyncEngine.ts
@@ -20,7 +20,23 @@ import type { StorageKey } from '../platform/KeyValueStore';
import type { ISqliteDatabase, SqliteValue } from '../platform/SqliteEngine';
/** The operations the engine runs. */
-export type VaultSyncOperation = 'fullSync' | 'migrationStatus' | 'migrateManifest' | 'statusCheck' | 'resolveVaultKey' | 'createSharedManifest' | 'inviteToSharedManifest' | 'updateSharedManifest';
+export type VaultSyncOperation = 'fullSync' | 'migrationStatus' | 'migrateManifest' | 'statusCheck' | 'resolveVaultKey' | 'createSharedManifest' | 'inviteToSharedManifest' | 'updateSharedManifest' | 'rotateAccountKeys';
+
+/** What a key rotation works with (the Rust `KeyRotationParams`): the password proof and the new unlock method come from the host. */
+export type VaultSyncKeyRotationParams = {
+ userId: string;
+ currentClientPublicEphemeral: string;
+ currentClientSessionProof: string;
+ accountKeyVersion: number;
+ manifestKeyVersion: number;
+ newUnlockKey: string;
+ newSalt: string;
+ newVerifier: string;
+ newEncryptionType: string;
+ newEncryptionSettings: string;
+ newAccountPublicKey: string;
+ newAccountPrivateKey: string;
+};
/** What a sharing operation acts on (the Rust `SharingParams`). */
export type VaultSyncSharingParams = {
@@ -46,6 +62,7 @@ export type VaultSyncEngineRequest = {
minServerVersion: string;
isOfflineMode: boolean;
sharing?: VaultSyncSharingParams;
+ keyRotation?: VaultSyncKeyRotationParams;
};
/** The email domains the server serves; hidden private domains are also in the private list. */
@@ -98,6 +115,22 @@ export type VaultSyncMigrateManifestResult = VaultSyncEngineResultBase & {
requiresLogout: boolean;
};
+/** Why a key rotation did not run (the Rust `KeyRotationRefusal`). */
+export type VaultSyncKeyRotationRefusal = 'vaultOutOfDate' | 'serverStateChanged' | 'sharedVaultKeyUnavailable' | 'vaultUpgradeRequired';
+
+/** Outcome of a key rotation (the Rust `KeyRotationResult`). */
+export type VaultSyncKeyRotationResult = VaultSyncEngineResultBase & {
+ success: boolean;
+ accountKey?: string;
+ encryptionKey?: string;
+ refusal?: VaultSyncKeyRotationRefusal;
+ error?: string;
+ errorCode?: string;
+ apiErrorCode?: string;
+ logoutReason?: LogoutReason;
+ requiresLogout: boolean;
+};
+
/** Outcome of a sharing operation (the Rust `SharingOperationResult`). */
export type VaultSyncSharingResult = VaultSyncEngineResultBase & {
success: boolean;
diff --git a/core/i18n/hints.json b/core/i18n/hints.json
index 3698afee9..f6fdc5a0e 100644
--- a/core/i18n/hints.json
+++ b/core/i18n/hints.json
@@ -565,5 +565,6 @@
"web.welcome.tutorialStepTitle": "Default tutorial step title",
"web.welcome.twoFactorTipContent": "Content for two-factor authentication tip",
"web.welcome.twoFactorTipTitle": "Title for two-factor authentication tip",
- "web.welcome.welcomeMessage": "Welcome message on the first tutorial step"
+ "web.welcome.welcomeMessage": "Welcome message on the first tutorial step",
+ "settings.securitySettings.keyRotation.optionRotateKeys": "Checkbox under the collapsed advanced options of the change password page: the password change also replaces every encryption key"
}
diff --git a/core/i18n/locales/en.json b/core/i18n/locales/en.json
index 6bede1704..545752aac 100644
--- a/core/i18n/locales/en.json
+++ b/core/i18n/locales/en.json
@@ -218,6 +218,7 @@
"attachments": "Attachments",
"back": "Back",
"backspace": "Backspace",
+ "beforeYouContinue": "Before you continue:",
"cancel": "Cancel",
"clipboardCountdown": {
"clearClipboardButton": "Clear Clipboard"
@@ -284,6 +285,7 @@
"hide": "Hide",
"hideDetails": "Hide details",
"hidePassword": "Hide password",
+ "highRiskAction": "This is a high-risk action.",
"home": "Home",
"loadMore": "Load more",
"loading": "Loading...",
@@ -1361,7 +1363,7 @@
"failedToChange": "Failed to change password. Please try again.",
"failedToChangePassword": "Failed to change password. Please refresh the page and try again.",
"fillAllFields": "Please fill in all fields",
- "headerText": "Changing your master password also changes the vault encryption keys. It is advised to periodically change your master password to keep your vaults secure.",
+ "headerText": "Changing your master password signs out your other devices. Your encryption keys stay the same unless you rotate them under the advanced settings.",
"initiatingChange": "Initiating password change...",
"newPassword": "New Password",
"passwordChangedSuccessfully": "Password changed successfully",
@@ -1416,6 +1418,15 @@
"verificationCodePlaceholder": "Enter verification code",
"verifyAndEnableButton": "Verify and Enable"
},
+ "keyRotation": {
+ "acknowledge": "I have backed up my vault and signed out of my other devices",
+ "changePasswordAndRotate": "Change password and rotate keys",
+ "optionRotateKeys": "Also rotate all encryption keys",
+ "optionRotateKeysDescription": "Only needed if you suspect your keys were exposed, for example if your device was compromised or stolen. Re-encrypts your vault and signs out all other devices.",
+ "riskAfterwards": "Afterwards, log in again on your other devices and set up PIN, passkey or biometric unlock again.",
+ "riskBackup": "Export a backup of your vault first (Settings > Import / Export). A key rotation operation cannot be undone.",
+ "riskSignOut": "Let your other devices finish syncing, then sign out from them. Unsynced changes on devices that stay signed in are lost."
+ },
"passkeyUnlock": {
"disableButton": "Disable Passkey Unlock",
"disabledDescription": "By default, reloading the AliasVault page or tab requires you to enter your master password again. With a passkey, you can unlock your vault instantly. When enabled, your master password is locally encrypted using the passkey's PRF extension. Note: the passkey will only work for the current device and browser that you enable it on.",