Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Update error messages
Leendert de Borstd18c2957ec79
diff --git a/apps/browser-extension/src/entrypoints/background/AuthHandler.ts b/apps/browser-extension/src/entrypoints/background/AuthHandler.tsindex 98e57f89c..6b9ffb367 100644--- a/apps/browser-extension/src/entrypoints/background/AuthHandler.ts+++ b/apps/browser-extension/src/entrypoints/background/AuthHandler.ts@@ -94,24 +94,29 @@ async function failureResult(context: string, err: unknown, options?: AuthErrorO}/**- * Check the server status before an unlock. Returns whether the server is reachable, or the logout this client needs.+ * Check the server status before an unlock. Returns whether the unlock can go online and whether the server is unreachable,+ * or the logout this client needs. A server that predates the v2 API is reachable but unlocks locally, so the upgrade+ * page can tell the user it needs updating.*/-async function checkServerStatus(webApi: WebApiService): Promise<{ online: boolean } | { logout: BackgroundAuthResult }> {+async function checkServerStatus(webApi: WebApiService): Promise<{ online: boolean; offline: boolean } | { logout: BackgroundAuthResult }> {try {const status = await webApi.getStatus();if (status.serverVersion === '0.0.0') {- return { online: false };+ return { online: false, offline: true };}const statusError = webApi.validateStatusResponse(status);if (statusError !== null) {return { logout: { status: 'logout', reasonKey: logoutReasonKey(statusError) } };}- return { online: true };+ return { online: true, offline: false };} catch (err) {if (err instanceof ClientUpgradeRequiredError) {return { logout: { status: 'logout', reasonKey: 'common.errors.clientNotSupported' } };}+ if (err instanceof ServerUpdateRequiredError) {+ return { online: false, offline: false };+ }// Any other error is an auth failure: the server is reachable but the session is gone.logExpected('[Auth] Status check failed during unlock', err);@@ -167,11 +172,11 @@ export function handleUnlockWithPassword(data: { password: string }): Promise<BaaccountKey = await VaultKeyService.verifyUnlockKey(unlockKey);}- await storeAccountKey(accountKey, !status.online, true);+ await storeAccountKey(accountKey, status.offline, true);await resetFailedAttempts();await LocalPreferencesService.resetPasswordUnlockFailedAttempts();await LocalPreferencesService.setLastUsedUnlockMethod('password');- return { status: 'success', offline: !status.online };+ return { status: 'success', offline: status.offline };} catch (err) {const message = await describeAuthError(err, { uncodedIsWrongPassword: true });if (message.wrongPassword) {@@ -199,9 +204,9 @@ export function handleUnlockWithPin(data: { pin: string }): Promise<BackgroundAureturn status.logout;}- await storeAccountKey(accountKey, !status.online, true);+ await storeAccountKey(accountKey, status.offline, true);await LocalPreferencesService.setLastUsedUnlockMethod('pin');- return { status: 'success', offline: !status.online };+ return { status: 'success', offline: status.offline };} catch (err) {if (err instanceof PinLockedError) {return { status: 'pinFailed', reason: 'locked' };diff --git a/apps/browser-extension/src/entrypoints/popup/pages/auth/Unlock.tsx b/apps/browser-extension/src/entrypoints/popup/pages/auth/Unlock.tsxindex 45b04a603..bb8512017 100644--- a/apps/browser-extension/src/entrypoints/popup/pages/auth/Unlock.tsx+++ b/apps/browser-extension/src/entrypoints/popup/pages/auth/Unlock.tsx@@ -1,4 +1,5 @@import { ClientUpgradeRequiredError } from '@aliasvault/client/api/errors/ClientUpgradeRequiredError';+import { ServerUpdateRequiredError } from '@aliasvault/client/api/errors/ServerUpdateRequiredError';import { VaultVersionIncompatibleError } from '@aliasvault/client/api/errors/VaultVersionIncompatibleError';import { describeAuthError, formatErrorMessage } from '@aliasvault/client/auth/AuthErrorMessage';import { VaultKeyService } from '@aliasvault/client/auth/VaultKeyService';@@ -122,6 +123,16 @@ const Unlock: React.FC = () => {return { online: false, error: 'clientVersionNotSupported' };}+ /**+ * The server is not compatible with this client (e.g. has not been updated to include V2 API required for manifest-v1 migration).+ * Disable offline mode and let the main app UI explain the issue.+ */+ if (err instanceof ServerUpdateRequiredError) {+ setIsInitialLoading(false);+ await dbContext.setIsOffline(false);+ return { online: false, error: null };+ }+/*** Non-network errors (e.g., session expired, auth failures) are thrown by getStatus().* The logout event is already emitted by the WebApiService, so we just return an errordiff --git a/apps/browser-extension/src/entrypoints/popup/pages/auth/Upgrade.tsx b/apps/browser-extension/src/entrypoints/popup/pages/auth/Upgrade.tsxindex c47426817..ff9d449be 100644--- a/apps/browser-extension/src/entrypoints/popup/pages/auth/Upgrade.tsx+++ b/apps/browser-extension/src/entrypoints/popup/pages/auth/Upgrade.tsx@@ -88,7 +88,6 @@ const Upgrade: React.FC = () => {const [stage, setStage] = useState<Stage>('classifying');const [kind, setKind] = useState<UpgradeKind | null>(null);const [error, setError] = useState<string | null>(null);- const [errorDetail, setErrorDetail] = useState<string | null>(null);const [currentVersion, setCurrentVersion] = useState<VaultVersion | null>(null);const [latestVersion, setLatestVersion] = useState<VaultVersion | null>(null);const [showSelfHostedWarning, setShowSelfHostedWarning] = useState(false);@@ -158,7 +157,6 @@ const Upgrade: React.FC = () => {*/const runManifestMigration = useCallback(async (migrationKind: UpgradeKind): Promise<void> => {setError(null);- setErrorDetail(null);setKind(migrationKind);setStage('upgrading');@@ -167,9 +165,7 @@ const Upgrade: React.FC = () => {if (!result.success) {// Back to the consent screen, where the same button retries and the error says why it has to.logFailure('[Upgrade] Vault manifest migration failed', result);- const message = syncErrorMessage(result, t) ?? t('common.errors.unknownError');- setError(message);- setErrorDetail(result.error && result.error !== message ? result.error : null);+ setError(syncErrorMessage(result, t) ?? t('common.errors.unknownError'));setStage('consent');setIsInitialLoading(false);return;@@ -244,7 +240,6 @@ const Upgrade: React.FC = () => {}setError(null);- setErrorDetail(null);setStage('upgrading');try {@@ -416,9 +411,6 @@ const Upgrade: React.FC = () => {{error && (<div className="mb-4 text-red-500 dark:text-red-400 break-words">{error}- {errorDetail && (- <div className="mt-1 text-xs text-gray-500 dark:text-gray-400 break-all">{errorDetail}</div>- )}</div>)}diff --git a/apps/mobile-app/app/upgrade.tsx b/apps/mobile-app/app/upgrade.tsxindex c7d8f366e..3aa5f8f53 100644--- a/apps/mobile-app/app/upgrade.tsx+++ b/apps/mobile-app/app/upgrade.tsx@@ -1,4 +1,4 @@-import { AppErrorCode, extractErrorCode, formatErrorWithCode, getErrorTranslationKey } from '@aliasvault/client/api/errors/AppErrorCodes';+import { AppErrorCode, extractErrorCode, formatErrorWithCode, getErrorTranslationKey, hasOwnErrorMessage } from '@aliasvault/client/api/errors/AppErrorCodes';import { VaultVersionIncompatibleError } from '@aliasvault/client/api/errors/VaultVersionIncompatibleError';import { AppInfo } from '@aliasvault/client/platform/AppInfo';import { DEFAULT_VAULT_MUTATION_SCOPE } from '@aliasvault/client/sync/VaultMutationScope';@@ -121,7 +121,7 @@ export default function UpgradeScreen() : React.ReactNode {/*** Show a failed step on the consent screen, where the same button retries. Failures that end the session log out instead.* @param code - the error code- * @param detail - the technical detail, shown under the translated message when it adds something+ * @param detail - the technical detail, shown under the translated message only for a code without a message of its own*/const failStep = useCallback(async (code: AppErrorCode, detail: string | null): Promise<void> => {const message = formatErrorWithCode(t(getErrorTranslationKey(code)), code);@@ -130,7 +130,7 @@ export default function UpgradeScreen() : React.ReactNode {return;}setError(message);- setErrorDetail(detail && detail !== message ? detail : null);+ setErrorDetail(detail && detail !== message && !hasOwnErrorMessage(code) ? detail : null);setStage('consent');}, [app, t]);diff --git a/core/build-and-distribute.sh b/core/build-and-distribute.shindex 0c479af42..c9f0c42f5 100755--- a/core/build-and-distribute.sh+++ b/core/build-and-distribute.sh@@ -17,10 +17,6 @@ while [[ $# -gt 0 ]]; do[[ " $BROWSER_TARGETS " == *" ${1#--} "* ]] || BROWSER_TARGETS="$BROWSER_TARGETS ${1#--}"shift;;- --browser)- echo "Error: --browser was split into --web (size-optimized) and --browser-extension (speed-optimized)"- exit 1- ;;--ios)BUILD_IOS=trueshiftdiff --git a/core/client/src/api/WebApiService.ts b/core/client/src/api/WebApiService.tsindex f6e09f204..c84e7a111 100644--- a/core/client/src/api/WebApiService.ts+++ b/core/client/src/api/WebApiService.ts@@ -11,6 +11,7 @@ import { logFailure } from './errors/ExpectedFailure';import { NetworkError } from './errors/NetworkError';import { PayloadTooLargeError } from './errors/PayloadTooLargeError';import { RequestTimeoutError } from './errors/RequestTimeoutError';+import { ServerUpdateRequiredError } from './errors/ServerUpdateRequiredError';import { logoutEventEmitter } from './LogoutEventEmitter';import type { LogoutReason } from '../sync/VaultSyncEngine';@@ -391,8 +392,9 @@ export class WebApiService {/*** Calls the status endpoint to check if the auth tokens are still valid, app is supported and the vault is up to date.- * Returns offline indicator (serverVersion: '0.0.0') for network failures and server errors (5xx, 404, etc.).- * Auth errors (ApiAuthError) are re-thrown to be handled appropriately (e.g., trigger logout).+ * Returns offline indicator (serverVersion: '0.0.0') for network failures and server errors (5xx, etc.).+ * Auth errors (ApiAuthError) are re-thrown to be handled appropriately (e.g., trigger logout), and an uncoded 404+ * (a server that predates the v2 API) throws {@link ServerUpdateRequiredError}, like the Rust sync engine.*/public async getStatus(): Promise<StatusResponseV2> {try {@@ -419,6 +421,9 @@ export class WebApiService {if (error instanceof ClientUpgradeRequiredError) {throw error;}+ if (error instanceof ApiRequestError && error.statusCode === 404 && !error.apiErrorCode) {+ throw new ServerUpdateRequiredError();+ }return {clientVersionSupported: true,serverVersion: '0.0.0',diff --git a/core/client/src/api/errors/AppErrorCodes.ts b/core/client/src/api/errors/AppErrorCodes.tsindex 434698275..c6791bf04 100644--- a/core/client/src/api/errors/AppErrorCodes.ts+++ b/core/client/src/api/errors/AppErrorCodes.ts@@ -207,6 +207,14 @@ export function getErrorTranslationKey(code: AppErrorCode): TranslationKey {return ERROR_TRANSLATION_KEYS[code] ?? 'common.errors.unexpectedErrorContactSupport';}+/**+ * Whether the code has a message of its own instead of the generic "unexpected error" message.+ * @param code - the error code+ */+export function hasOwnErrorMessage(code: AppErrorCode): boolean {+ return ERROR_TRANSLATION_KEYS[code] !== undefined;+}+/*** The translated message for an error that carries a code, with the code appended, or null when it carries none.*diff --git a/core/client/src/sync/SyncErrorMessage.ts b/core/client/src/sync/SyncErrorMessage.tsindex 4146e2b05..460a0929f 100644--- a/core/client/src/sync/SyncErrorMessage.ts+++ b/core/client/src/sync/SyncErrorMessage.ts@@ -1,4 +1,4 @@-import { AppErrorCode, formatErrorWithCode, getErrorTranslationKey, isErrorCode } from '../api/errors/AppErrorCodes';+import { AppErrorCode, formatErrorWithCode, getErrorTranslationKey, hasOwnErrorMessage, isErrorCode } from '../api/errors/AppErrorCodes';import { hasSyncError, logoutReasonKey, type SyncErrorDetail } from './VaultSync';@@ -18,7 +18,8 @@ export function toSyncErrorDetail(value: unknown): SyncErrorDetail | null {}/**- * The message to show for a failed sync, or undefined when the outcome names no failure.+ * The message to show for a failed sync, or undefined when the outcome names no failure. The engine's technical+ * detail is only appended to a code that has no message of its own.* @param detail - the sync outcome* @param t - the renderer's translation function*/@@ -29,7 +30,7 @@ export function syncErrorMessage(detail: SyncErrorDetail, t: (key: string) => stif (detail.errorCode) {const code = isErrorCode(detail.errorCode) ? detail.errorCode : AppErrorCode.UNKNOWN_ERROR;const message = formatErrorWithCode(t(getErrorTranslationKey(code)), code);- return detail.error ? `${message}\n${detail.error}` : message;+ return detail.error && !hasOwnErrorMessage(code) ? `${message}\n${detail.error}` : message;}return detail.error;}