From 11d653e2ad0f3a021c55617481ce567e120f8042 Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Tue, 3 Sep 2024 21:39:15 -0230 Subject: [PATCH] fix: Fix Trezor signing and connecting Trezor signing and connecting was broken in a recent change that included an update to the `@trezor/connect-web` library (in #26143). The patch had to be rewritten as part of that update, but in this rewrite an underscore was missed in referencing a variable (the patch used `this.settings` rather than `this._settings`). Additionally, two more changes have been applied to ensure the modified settings are used everywhere. One was present in the original patch but missing from the patch in #26143. The other was not present in the original patch (#23763) because the affected line was added in the library update, but it seems equally necessary. Fixes #26875 --- ...zor-connect-web-npm-9.3.0-040ab10d9a.patch | 32 ++++++++++++++++--- yarn.lock | 4 +-- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/.yarn/patches/@trezor-connect-web-npm-9.3.0-040ab10d9a.patch b/.yarn/patches/@trezor-connect-web-npm-9.3.0-040ab10d9a.patch index 854707ea51a1..515ff415b4df 100644 --- a/.yarn/patches/@trezor-connect-web-npm-9.3.0-040ab10d9a.patch +++ b/.yarn/patches/@trezor-connect-web-npm-9.3.0-040ab10d9a.patch @@ -1,5 +1,5 @@ diff --git a/lib/impl/core-in-iframe.js b/lib/impl/core-in-iframe.js -index c47cf3bff860d6b1855341c00b80fc6c40f9d6d5..275eb0f312ff396819fa406c154a3562842db49d 100644 +index c47cf3bff860d6b1855341c00b80fc6c40f9d6d5..0151bcaac6689ecb26f1b4575ece4f3760ca1b87 100644 --- a/lib/impl/core-in-iframe.js +++ b/lib/impl/core-in-iframe.js @@ -116,7 +116,9 @@ class CoreInIframe { @@ -7,21 +7,32 @@ index c47cf3bff860d6b1855341c00b80fc6c40f9d6d5..275eb0f312ff396819fa406c154a3562 window.addEventListener('message', this.boundHandleMessage); window.addEventListener('unload', this.boundDispose); - await iframe.init(this._settings); -+ const modifiedSettings = Object.assign({}, this.settings); ++ var modifiedSettings = Object.assign({}, this._settings); + modifiedSettings.env = 'webextension'; + await iframe.init(modifiedSettings); if (this._settings.sharedLogger !== false) { iframe.initIframeLogger(); } +@@ -132,7 +134,9 @@ class CoreInIframe { + } + this._popupManager.request(); + try { +- await this.init(this._settings); ++ var modifiedSettings = Object.assign({}, this._settings); ++ modifiedSettings.env = 'webextension'; ++ await this.init(modifiedSettings); + } + catch (error) { + if (this._popupManager) { diff --git a/lib/popup/index.js b/lib/popup/index.js -index 9b13c370a5ac8b4e4fc0315ed40cdf615d0bb0cb..4dbd97fc28df49beb73379451974ec48a8a42ea7 100644 +index 9b13c370a5ac8b4e4fc0315ed40cdf615d0bb0cb..595a7d9e1aa397b3aa53ba5d75e4ccf22a61bcf1 100644 --- a/lib/popup/index.js +++ b/lib/popup/index.js @@ -229,10 +229,12 @@ class PopupManager extends events_1.default { } else if (message.type === events_2.POPUP.LOADED) { this.handleMessage(message); -+ const modifiedSettings = Object.assign({}, this.settings); ++ var modifiedSettings = Object.assign({}, this.settings); + modifiedSettings.env = 'webextension'; this.channel.postMessage({ type: events_2.POPUP.INIT, @@ -31,3 +42,16 @@ index 9b13c370a5ac8b4e4fc0315ed40cdf615d0bb0cb..4dbd97fc28df49beb73379451974ec48 useCore: true, }, }); +@@ -292,9 +294,11 @@ class PopupManager extends events_1.default { + this.popupPromise = undefined; + } + (_b = this.iframeHandshakePromise) === null || _b === void 0 ? void 0 : _b.promise.then(payload => { ++ var modifiedSettings = Object.assign({}, this.settings); ++ modifiedSettings.env = 'webextension'; + this.channel.postMessage({ + type: events_2.POPUP.INIT, +- payload: Object.assign(Object.assign({}, payload), { settings: this.settings }), ++ payload: Object.assign(Object.assign({}, payload), { settings: modifiedSettings }), + }); + }); + } diff --git a/yarn.lock b/yarn.lock index bae053d68727..89c76ec078df 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9752,14 +9752,14 @@ __metadata: "@trezor/connect-web@patch:@trezor/connect-web@npm%3A9.3.0#~/.yarn/patches/@trezor-connect-web-npm-9.3.0-040ab10d9a.patch": version: 9.3.0 - resolution: "@trezor/connect-web@patch:@trezor/connect-web@npm%3A9.3.0#~/.yarn/patches/@trezor-connect-web-npm-9.3.0-040ab10d9a.patch::version=9.3.0&hash=58af97" + resolution: "@trezor/connect-web@patch:@trezor/connect-web@npm%3A9.3.0#~/.yarn/patches/@trezor-connect-web-npm-9.3.0-040ab10d9a.patch::version=9.3.0&hash=3ffb2f" dependencies: "@trezor/connect": "npm:9.3.0" "@trezor/connect-common": "npm:0.1.0" "@trezor/utils": "npm:9.1.0" peerDependencies: tslib: ^2.6.2 - checksum: 10/63f1c386aa6bb5bbeefe528d2564953e2635c0c549830654d7481dc9130f24593501472d178af2c65577182b2f39928bfd5430e85e836caec3cf74ab666489aa + checksum: 10/58781efa397d2028c0eb6362fb1a8567e0b8c4ab22581633742a20f6ece37e0011e7005a951956dfee3cf3360d6e72f2c7a82549611284897631d39959ccb37f languageName: node linkType: hard