Skip to content

Commit

Permalink
fix: Fix Trezor signing and connecting
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Gudahtt committed Sep 4, 2024
1 parent 1801174 commit 11d653e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
32 changes: 28 additions & 4 deletions .yarn/patches/@trezor-connect-web-npm-9.3.0-040ab10d9a.patch
Original file line number Diff line number Diff line change
@@ -1,27 +1,38 @@
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 {
this._log.enabled = !!this._settings.debug;
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,
Expand All @@ -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 }),
});
});
}
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 11d653e

Please sign in to comment.