The mailsync engine sometimes dumps Account JSON (e.g. on
ProcessAccountSecretsUpdated) into stderr/log buffers that get surfaced
as Error messages and rawLog strings. The previous redaction only ran in
_spawnAndWait and only stripped values cached on this.account.settings,
so rotated refresh/access tokens that the engine had just generated
would leak through unredacted.
Centralize redaction into _stripSecrets, which now also key-matches
known sensitive JSON fields (refresh_token, access_token, imap_password,
smtp_password) so any value for those keys is replaced regardless of
whether we have it cached. Apply it to sync()'s close handler too, which
previously constructed Errors directly from errBuffer with no scrubbing.
Summary
Refactored and enhanced the secret redaction logic in the mailsync process to better protect sensitive credentials from appearing in UI messages.
Key Changes
stripSecretsfunction from the_spawnAndWaitmethod into a new_stripSecretsinstance method for reusability across the classrefresh_token,access_token,imap_password,smtp_password) regardless of their current cached values, catching secrets that may have been rotated by the engine_stripSecretsmethod to additional error paths in the_spawnAndWaitmethod and the_spawnProcessmethod, ensuring secrets are redacted in more error scenariosImplementation Details
("key"\s*:\s*")(?:\\.|[^"\\])*(")) properly handles escaped quotes within JSON string values_stripSecretsmethodhttps://claude.ai/code/session_01RUsz543z61nZAxsAEqHruD