mirror of
https://github.com/Novaloop-AG/healthchat-web.git
synced 2026-12-03 12:49:30 +00:00
e4da468d07
* Avoid destroying a still-valid session when the OS keychain is temporarily unreadable SafeStorageWriter.get() previously caught a decrypt failure and returned undefined, indistinguishable from "no secret stored". When the OS keychain is briefly locked or its ACL is invalidated by an app re-sign/update, an existing valid pickle key read as absent, so the renderer fell back to the default key and createPickleKey then overwrote the still-valid ciphertext - turning a transient hiccup into permanent session and encryption-key loss. Distinguish absent from present-but-undecryptable with a typed SafeStorageDecryptionError, and never overwrite an existing undecryptable secret, so the session recovers on a later launch once the keychain is readable again. * Fail closed when a stored secret cannot be read, and defer the basic_text migration instead of poisoning skipped secrets - isSecretUndecryptable now treats any error reading an existing secret as undecryptable, so an unexpected storage-layer error can never re-enable the destructive pickle-key overwrite. - migrateBasicTextToPlaintext decrypts all secrets before writing anything: if any secret cannot be decrypted the migration is aborted and the app sticks with the basic_text backend (safeStorageBackendOverride) instead of recording the store as plaintext while a secret is still ciphertext - which would make the next launch re-encrypt that ciphertext as though it were the secret, silently corrupting it and defeating the overwrite guard. * Fix the safeStorage tests so they run under CI store.ts reads getConfig().brand when it raises a degraded-mode dialog, and the real config module only populates itself in loadConfig(), which these tests never call. Stubbing it lets the tests reach the dialog they are actually about instead of dying on an undefined brand. The ElectronStore fake also carried a constructor whose only job was to swallow the options object. oxlint's no-useless-constructor is an error here, and it was the one genuine failure on this branch, so the fake now leans on the implicit default constructor - which ignores its arguments just as happily.