diff --git a/src/App.js b/src/App.js index b1267216..4ee6f872 100644 --- a/src/App.js +++ b/src/App.js @@ -375,8 +375,9 @@ function DefaultComponent({ children }) { // If this is a hardware wallet that has been locked, navigate to the "Wallet Type" screen if (isLockedScreen && LOCAL_STORE.isHardwareWallet()) { + // This exit path bypasses resetStorage, so clear the registered data too. + LOCAL_STORE.cleanWallet({ cleanRegisteredData: true }); // This will redirect the page to Wallet Type screen - LOCAL_STORE.cleanWallet(); return ; } diff --git a/src/storage.js b/src/storage.js index 0b713130..9deac1ad 100644 --- a/src/storage.js +++ b/src/storage.js @@ -271,12 +271,23 @@ export class LocalStorageStore { } /** - * Clean wallet metadata + * Clean wallet metadata. + * + * @param {Object} [options] + * @param {boolean} [options.cleanRegisteredData=false] Also drop the + * wallet-scoped registered tokens, nano contracts and Ledger token + * signatures. Used by exit paths that bypass resetStorage, so this data + * doesn't leak into the next wallet. */ - cleanWallet() { + cleanWallet({ cleanRegisteredData = false } = {}) { this.removeItem(IS_HARDWARE_KEY); this.removeItem(CLOSED_KEY); this.removeItem(ACCESS_DATA_KEY); + if (cleanRegisteredData) { + this.removeItem(REGISTERED_TOKENS_KEY); + this.removeItem(REGISTERED_NANOCONTRACTS_KEY); + this.removeItem(TOKEN_SIGNATURES_KEY); + } delete this._storage; this._storage = null; }