Skip to content

feat: trezor web connect library upgrade. #33834

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 24 commits into
base: main
Choose a base branch
from

Conversation

dawnseeker8
Copy link
Contributor

@dawnseeker8 dawnseeker8 commented Jun 23, 2025

Description

This PR will upgrade trezor/connect-web library based on trezor team suggestion. please refer to plan https://github.com/MetaMask/accounts-planning/issues/936 for details.

This PR will add a appName parameter to manifest to initialise TrezorSDK.

Open in GitHub Codespaces

Related issues

Fixes: https://github.com/MetaMask/accounts-planning/issues/936

Manual testing steps

All trezor flows will need to tested to make sure nothing broken.

Screenshots/Recordings

Before

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

- Bump @trezor/connect-web version from 9.4.7 to 9.6.0 in package.json and yarn.lock.
- Update @emurgo/cardano-serialization-lib-browser and @emurgo/cardano-serialization-lib-nodejs to version 13.2.0 in yarn.lock.
- Add manifest name 'MetaMask' to Trezor SDK initialization in trezor.ts for better identification.
Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

Copy link

socket-security bot commented Jun 30, 2025

Copy link

socket-security bot commented Jun 30, 2025

All alerts resolved. Learn more about Socket for GitHub.

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

Ignoring alerts on:

View full report

@dawnseeker8
Copy link
Contributor Author

@metamaskbot update-policies

@metamaskbot
Copy link
Collaborator

Policies updated.
👀 Please review the diff for suspicious new powers.

🧠 Learn how: https://lavamoat.github.io/guides/policy-diff/#what-to-look-for-when-reviewing-a-policy-diff

@metamaskbot
Copy link
Collaborator

metamaskbot commented Jun 30, 2025

✨ Files requiring CODEOWNER review ✨

🧩 @MetaMask/extension-devs (4 files, +136 -36)
  • 📁 lavamoat/
    • 📁 browserify/
      • 📁 beta/
        • 📄 policy.json +34 -9
      • 📁 experimental/
        • 📄 policy.json +34 -9
      • 📁 flask/
        • 📄 policy.json +34 -9
      • 📁 main/
        • 📄 policy.json +34 -9

📜 @MetaMask/policy-reviewers (4 files, +136 -36)
  • 📁 lavamoat/
    • 📁 browserify/
      • 📁 beta/
        • 📄 policy.json +34 -9
      • 📁 experimental/
        • 📄 policy.json +34 -9
      • 📁 flask/
        • 📄 policy.json +34 -9
      • 📁 main/
        • 📄 policy.json +34 -9

Tip

Follow the policy review process outlined in the LavaMoat Policy Review Process doc before expecting an approval from Policy Reviewers.


🔗 @MetaMask/supply-chain (4 files, +136 -36)
  • 📁 lavamoat/
    • 📁 browserify/
      • 📁 beta/
        • 📄 policy.json +34 -9
      • 📁 experimental/
        • 📄 policy.json +34 -9
      • 📁 flask/
        • 📄 policy.json +34 -9
      • 📁 main/
        • 📄 policy.json +34 -9

@dawnseeker8
Copy link
Contributor Author

@metamaskbot update-policies

@metamaskbot
Copy link
Collaborator

Policies updated.
👀 Please review the diff for suspicious new powers.

🧠 Learn how: https://lavamoat.github.io/guides/policy-diff/#what-to-look-for-when-reviewing-a-policy-diff

@dawnseeker8
Copy link
Contributor Author

Caution

Review the following alerts detected in dependencies.

According to your organization's Security Policy, you must resolve all "Block" alerts before proceeding. Learn more about Socket for GitHub.

Action Severity Alert (click for details)
Block Medium
@solana/[email protected] has Network access.
Block Medium
@stellar/[email protected] has Network access.
Block Medium
[email protected] has Network access.
Block Medium
[email protected] has Network access.
Block Medium
[email protected] has Network access.
Block Medium
[email protected] has Network access.
Block Low
@solana-program/[email protected] has a New author.
Block Low
@solana-program/[email protected] has a New author.
Block Low
@solana/[email protected] has a New author.
Block Low
@xrplf/[email protected] has a New author.
Block Low
[email protected] has a New author.
View full report

All those alerts from Trezor/connect-web library upgrade and those network access libraries is required to access trezor dapp external to complete the trezor funciton. therefore we need those libraries otherwise, trezor feature will not work.

@SocketSecurity ignore-all

@dawnseeker8
Copy link
Contributor Author

@SocketSecurity ignore-all

@dawnseeker8
Copy link
Contributor Author

@metamaskbot update-policies

@metamaskbot
Copy link
Collaborator

Policies updated.
👀 Please review the diff for suspicious new powers.

🧠 Learn how: https://lavamoat.github.io/guides/policy-diff/#what-to-look-for-when-reviewing-a-policy-diff

Root Cause: The webpack configuration was trying to process all vendor JavaScript files (including Trezor library files) through the ecmaLoader, which uses SWC configured for ES modules.
The Problem: Some files in @trezor/connect-web version 9.6.0 still use CommonJS format (exports.something = value), but SWC was trying to process them as ES modules where exports isn't available.
The Solution: By excluding @trezor packages from the SWC loader (just like @lavamoat/snow was already excluded), webpack will use its default JavaScript processing which can handle mixed module formats better.
@metamaskbot
Copy link
Collaborator

Builds ready [e0ae2b0]
UI Startup Metrics (1195 ± 64 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1195107714026412301323
load101692011855610521128
domContentLoaded100991511805510461116
domInteractive18144671740
firstPaint70480119840010351092
backgroundConnect84293812
firstReactRender23175152435
getState176102142234
initialActions001001
loadScripts80071096853834907
setupStore953541017
WebpackHomeuiStartup22231738280922123342648
load16701311225219317782004
domContentLoaded16641307224719117721994
domInteractive181289151457
firstPaint1616246876174314
backgroundConnect2813283372640
firstReactRender26490429123392412
getState1345181525
initialActions218135
loadScripts16611305223719017701986
setupStore207322312135
FirefoxBrowserifyHomeuiStartup13891205188012814581655
load1211105415309212731383
domContentLoaded1211105315309212731382
domInteractive1163550769130189
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect2613126202568
firstReactRender25215952533
getState16526534967
initialActions001001
loadScripts1188103615179112551356
setupStore104171181031
WebpackHomeuiStartup16331389240819317322001
load14051194185415314841756
domContentLoaded14051194185415314831755
domInteractive1073551369101280
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect22155872436
firstReactRender433111084549
getState12675101131
initialActions001011
loadScripts13861178181615214561738
setupStore15526033961
Benchmark value 18 exceeds gate value 15 for chrome browserify home mean getState
Benchmark value 34 exceeds gate value 33 for chrome browserify home p95 getState
Benchmark value 2223 exceeds gate value 2192 for chrome webpack home mean uiStartup
Benchmark value 264 exceeds gate value 235 for chrome webpack home mean firstReactRender
Benchmark value 2648 exceeds gate value 2454 for chrome webpack home p95 uiStartup
Benchmark value 58 exceeds gate value 57 for chrome webpack home p95 domInteractive
Benchmark value 412 exceeds gate value 370 for chrome webpack home p95 firstReactRender
Benchmark value 1986 exceeds gate value 1970 for chrome webpack home p95 loadScripts
Benchmark value 116 exceeds gate value 110 for firefox browserify home mean domInteractive
Benchmark value 26 exceeds gate value 25 for firefox browserify home mean backgroundConnect
Benchmark value 26 exceeds gate value 25 for firefox browserify home mean firstReactRender
Benchmark value 17 exceeds gate value 11 for firefox browserify home mean getState
Benchmark value 11 exceeds gate value 9 for firefox browserify home mean setupStore
Benchmark value 67 exceeds gate value 24 for firefox browserify home p95 getState
Benchmark value 31 exceeds gate value 27 for firefox browserify home p95 setupStore
Benchmark value 1634 exceeds gate value 1615 for firefox webpack home mean uiStartup
Benchmark value 1406 exceeds gate value 1380 for firefox webpack home mean load
Benchmark value 1406 exceeds gate value 1380 for firefox webpack home mean domContentLoaded
Benchmark value 107 exceeds gate value 100 for firefox webpack home mean domInteractive
Benchmark value 43 exceeds gate value 38 for firefox webpack home mean firstReactRender
Benchmark value 1386 exceeds gate value 1360 for firefox webpack home mean loadScripts
Benchmark value 16 exceeds gate value 13 for firefox webpack home mean setupStore
Benchmark value 2001 exceeds gate value 1935 for firefox webpack home p95 uiStartup
Benchmark value 1756 exceeds gate value 1660 for firefox webpack home p95 load
Benchmark value 1755 exceeds gate value 1660 for firefox webpack home p95 domContentLoaded
Benchmark value 280 exceeds gate value 156 for firefox webpack home p95 domInteractive
Benchmark value 1738 exceeds gate value 1630 for firefox webpack home p95 loadScripts
Benchmark value 61 exceeds gate value 28 for firefox webpack home p95 setupStore
Sum of mean exceeds: 191ms | Sum of p95 exceeds: 823ms
Sum of all benchmark exceeds: 1014ms

Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 380 Bytes (0.01%)
  • ui: 4 Bytes (0%)
  • common: 38.78 KiB (0.45%)

@dawnseeker8
Copy link
Contributor Author

@metamaskbot update-policies

// never process `@lavamoat/snow/**.*`
exclude: /^.*\/node_modules\/@lavamoat\/snow\/.*$/u,
// never process `@lavamoat/snow/**.*` and `@trezor/**.*`
exclude: /^.*\/node_modules\/(@lavamoat\/snow|@trezor)\/.*$/u,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line will fix the webpack build .
Root Cause: The webpack configuration was trying to process all vendor JavaScript files (including Trezor library files) through the ecmaLoader, which uses SWC configured for ES modules.
The Problem: Some files in @trezor/connect-web version 9.6.0 still use CommonJS format (exports.something = value), but SWC was trying to process them as ES modules where exports isn't available.
The Solution: By excluding https://github.com/trezor packages from the SWC loader (just like @lavamoat/snow was already excluded), webpack will use its default JavaScript processing which can handle mixed module formats better.

@metamaskbot
Copy link
Collaborator

Policies updated.
👀 Please review the diff for suspicious new powers.

🧠 Learn how: https://lavamoat.github.io/guides/policy-diff/#what-to-look-for-when-reviewing-a-policy-diff

@metamaskbot
Copy link
Collaborator

Builds ready [57f8ab7]
UI Startup Metrics (1274 ± 56 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1274117814525613091377
load109699812735411311188
domContentLoaded108898512595311211181
domInteractive18145051831
firstPaint75688127142911101182
backgroundConnect94365926
firstReactRender23174662439
getState1763982332
initialActions001001
loadScripts82773099652862910
setupStore1063051123
WebpackHomeuiStartup22561752292725323802789
load16871254214320217932070
domContentLoaded16801250213220017892055
domInteractive181292151563
firstPaint1686642566194293
backgroundConnect2910347432955
firstReactRender26892420123393413
getState15469111739
initialActions319136
loadScripts16771249212119917882044
setupStore227281292358
FirefoxBrowserifyHomeuiStartup13891215197414014711668
load1210105715639612831355
domContentLoaded1210105715639612821354
domInteractive1243646281130318
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect2413153192356
firstReactRender25214932529
getState15521730972
initialActions001001
loadScripts1190104114559212621340
setupStore1048214850
WebpackHomeuiStartup16651420239921017722140
load14271223188015815251763
domContentLoaded14261222187915815251762
domInteractive110395118096307
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect2816217222846
firstReactRender44375344751
getState155144191136
initialActions001011
loadScripts14051203184915715071741
setupStore12610516936
Benchmark value 1274 exceeds gate value 1234 for chrome browserify home mean uiStartup
Benchmark value 1096 exceeds gate value 1070 for chrome browserify home mean load
Benchmark value 1088 exceeds gate value 1061 for chrome browserify home mean domContentLoaded
Benchmark value 24 exceeds gate value 23 for chrome browserify home mean firstReactRender
Benchmark value 18 exceeds gate value 15 for chrome browserify home mean getState
Benchmark value 1377 exceeds gate value 1365 for chrome browserify home p95 uiStartup
Benchmark value 1182 exceeds gate value 1180 for chrome browserify home p95 domContentLoaded
Benchmark value 1183 exceeds gate value 1180 for chrome browserify home p95 firstPaint
Benchmark value 27 exceeds gate value 18 for chrome browserify home p95 backgroundConnect
Benchmark value 23 exceeds gate value 17 for chrome browserify home p95 setupStore
Benchmark value 2256 exceeds gate value 2192 for chrome webpack home mean uiStartup
Benchmark value 269 exceeds gate value 235 for chrome webpack home mean firstReactRender
Benchmark value 2790 exceeds gate value 2454 for chrome webpack home p95 uiStartup
Benchmark value 2071 exceeds gate value 2030 for chrome webpack home p95 load
Benchmark value 2055 exceeds gate value 2005 for chrome webpack home p95 domContentLoaded
Benchmark value 63 exceeds gate value 57 for chrome webpack home p95 domInteractive
Benchmark value 413 exceeds gate value 370 for chrome webpack home p95 firstReactRender
Benchmark value 2044 exceeds gate value 1970 for chrome webpack home p95 loadScripts
Benchmark value 125 exceeds gate value 110 for firefox browserify home mean domInteractive
Benchmark value 16 exceeds gate value 11 for firefox browserify home mean getState
Benchmark value 11 exceeds gate value 9 for firefox browserify home mean setupStore
Benchmark value 1668 exceeds gate value 1660 for firefox browserify home p95 uiStartup
Benchmark value 318 exceeds gate value 195 for firefox browserify home p95 domInteractive
Benchmark value 72 exceeds gate value 24 for firefox browserify home p95 getState
Benchmark value 50 exceeds gate value 27 for firefox browserify home p95 setupStore
Benchmark value 1665 exceeds gate value 1615 for firefox webpack home mean uiStartup
Benchmark value 1427 exceeds gate value 1380 for firefox webpack home mean load
Benchmark value 1427 exceeds gate value 1380 for firefox webpack home mean domContentLoaded
Benchmark value 110 exceeds gate value 100 for firefox webpack home mean domInteractive
Benchmark value 28 exceeds gate value 26 for firefox webpack home mean backgroundConnect
Benchmark value 44 exceeds gate value 38 for firefox webpack home mean firstReactRender
Benchmark value 16 exceeds gate value 15 for firefox webpack home mean getState
Benchmark value 1406 exceeds gate value 1360 for firefox webpack home mean loadScripts
Benchmark value 2140 exceeds gate value 1935 for firefox webpack home p95 uiStartup
Benchmark value 1763 exceeds gate value 1660 for firefox webpack home p95 load
Benchmark value 1762 exceeds gate value 1660 for firefox webpack home p95 domContentLoaded
Benchmark value 307 exceeds gate value 156 for firefox webpack home p95 domInteractive
Benchmark value 51 exceeds gate value 50 for firefox webpack home p95 firstReactRender
Benchmark value 36 exceeds gate value 32 for firefox webpack home p95 getState
Benchmark value 1741 exceeds gate value 1630 for firefox webpack home p95 loadScripts
Benchmark value 36 exceeds gate value 28 for firefox webpack home p95 setupStore
Sum of mean exceeds: 426ms | Sum of p95 exceeds: 1469ms
Sum of all benchmark exceeds: 1895ms

Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 375 Bytes (0.01%)
  • ui: -616 Bytes (-0.01%)
  • common: 38.74 KiB (0.45%)

@dawnseeker8 dawnseeker8 marked this pull request as ready for review July 4, 2025 13:40
@dawnseeker8 dawnseeker8 requested review from a team as code owners July 4, 2025 13:40
@metamaskbot metamaskbot added the INVALID-PR-TEMPLATE PR's body doesn't match template label Jul 4, 2025
@metamaskbot
Copy link
Collaborator

Builds ready [791d8dd]
UI Startup Metrics (1234 ± 60 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1234111014326012681348
load106096011685210931147
domContentLoaded105395411625110851134
domInteractive18144471740
firstPaint713143116941910811144
backgroundConnect84142813
firstReactRender23174952435
getState1463771930
initialActions50276817
loadScripts80470891050836887
setupStore85284818
WebpackHomeuiStartup22311706279521123342682
load16971228212216317592012
domContentLoaded16901224209916117521998
domInteractive191277161465
firstPaint1636541168200298
backgroundConnect23105192842
firstReactRender26589416122382401
getState1457191834
initialActions10317318934
loadScripts16861222208815917501984
setupStore1573861926
FirefoxBrowserifyHomeuiStartup14121214222016114701752
load12331080158710112861408
domContentLoaded12321080158710112861408
domInteractive1173646273122309
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect2213104152147
firstReactRender25225052532
getState15525134942
initialActions508815218
loadScripts1214106714919712721394
setupStore13425332851
WebpackHomeuiStartup16551388238519717502034
load14311201203115915381687
domContentLoaded14301201203115915381686
domInteractive1134549279104303
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect231477102344
firstReactRender42326854549
getState13698111231
initialActions50599425
loadScripts14111183200815815181667
setupStore12520321928
Benchmark value 6 exceeds gate value 1 for chrome browserify home mean initialActions
Benchmark value 17 exceeds gate value 1.2 for chrome browserify home p95 initialActions
Benchmark value 18 exceeds gate value 17 for chrome browserify home p95 setupStore
Benchmark value 2231 exceeds gate value 2192 for chrome webpack home mean uiStartup
Benchmark value 266 exceeds gate value 235 for chrome webpack home mean firstReactRender
Benchmark value 11 exceeds gate value 7 for chrome webpack home mean initialActions
Benchmark value 2683 exceeds gate value 2454 for chrome webpack home p95 uiStartup
Benchmark value 65 exceeds gate value 57 for chrome webpack home p95 domInteractive
Benchmark value 401 exceeds gate value 370 for chrome webpack home p95 firstReactRender
Benchmark value 34 exceeds gate value 7 for chrome webpack home p95 initialActions
Benchmark value 1984 exceeds gate value 1970 for chrome webpack home p95 loadScripts
Benchmark value 1412 exceeds gate value 1405 for firefox browserify home mean uiStartup
Benchmark value 118 exceeds gate value 110 for firefox browserify home mean domInteractive
Benchmark value 26 exceeds gate value 25 for firefox browserify home mean firstReactRender
Benchmark value 16 exceeds gate value 11 for firefox browserify home mean getState
Benchmark value 5 exceeds gate value 1 for firefox browserify home mean initialActions
Benchmark value 13 exceeds gate value 9 for firefox browserify home mean setupStore
Benchmark value 1752 exceeds gate value 1660 for firefox browserify home p95 uiStartup
Benchmark value 309 exceeds gate value 195 for firefox browserify home p95 domInteractive
Benchmark value 42 exceeds gate value 24 for firefox browserify home p95 getState
Benchmark value 18 exceeds gate value 2 for firefox browserify home p95 initialActions
Benchmark value 51 exceeds gate value 27 for firefox browserify home p95 setupStore
Benchmark value 1655 exceeds gate value 1615 for firefox webpack home mean uiStartup
Benchmark value 1431 exceeds gate value 1380 for firefox webpack home mean load
Benchmark value 1431 exceeds gate value 1380 for firefox webpack home mean domContentLoaded
Benchmark value 113 exceeds gate value 100 for firefox webpack home mean domInteractive
Benchmark value 43 exceeds gate value 38 for firefox webpack home mean firstReactRender
Benchmark value 6 exceeds gate value 1 for firefox webpack home mean initialActions
Benchmark value 1412 exceeds gate value 1360 for firefox webpack home mean loadScripts
Benchmark value 2034 exceeds gate value 1935 for firefox webpack home p95 uiStartup
Benchmark value 1687 exceeds gate value 1660 for firefox webpack home p95 load
Benchmark value 1686 exceeds gate value 1660 for firefox webpack home p95 domContentLoaded
Benchmark value 303 exceeds gate value 156 for firefox webpack home p95 domInteractive
Benchmark value 25 exceeds gate value 2 for firefox webpack home p95 initialActions
Benchmark value 1667 exceeds gate value 1630 for firefox webpack home p95 loadScripts
Sum of mean exceeds: 325ms | Sum of p95 exceeds: 948.8ms
Sum of all benchmark exceeds: 1273.8ms

Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 384 Bytes (0.01%)
  • ui: 1 Bytes (0%)
  • common: 38.67 KiB (0.45%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
INVALID-PR-TEMPLATE PR's body doesn't match template team-hardware-wallets
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants