Skip to content

chore: Migrate SIWE dependency to @signinwithethereum/siwe v4#8497

Open
caveman-eth wants to merge 2 commits intoMetaMask:mainfrom
caveman-eth:update-siwe-dependencies-2
Open

chore: Migrate SIWE dependency to @signinwithethereum/siwe v4#8497
caveman-eth wants to merge 2 commits intoMetaMask:mainfrom
caveman-eth:update-siwe-dependencies-2

Conversation

@caveman-eth
Copy link
Copy Markdown

@caveman-eth caveman-eth commented Apr 16, 2026

Superseeds #8419 (couldn't reopen due to force-push).

Explanation

Current state

The monorepo depends on two SIWE (Sign-In With Ethereum / EIP-4361) packages originally maintained by Spruce:

  • @spruceid/siwe-parser v2.1.0 — used by @metamask/controller-utils to detect and parse SIWE messages via detectSIWE()
  • siwe v2.3.2 — used by @metamask/profile-sync-controller to construct SIWE login messages via new SiweMessage({...}).prepareMessage()

The Spruce siwe package is no longer actively maintained.

Stewardship of the SIWE standard has moved to the Ethereum Identity Foundation (GitHub).
@signinwithethereum/siwe is the official successor TypeScript implementation.

Similar migrations:

x402-foundation/x402 x402-foundation/x402#1917,
magiclabs/magic-js magiclabs/magic-js#1074

What this PR does

Swaps the abandoned packages for the actively maintained successors. The ParsedMessage and SiweMessage class APIs are identical - same constructors, same fields, same methods. This is purely a dependency swap with import path updates.

Files changed:

Package File Change
controller-utils package.json Replaced dependency
controller-utils src/siwe.ts Import path updated
controller-utils src/siwe.test.ts Import path updated
profile-sync-controller package.json Replaced dependency
profile-sync-controller src/sdk/authentication-jwt-bearer/flow-siwe.ts Import path updated

EIP-55 patches in client repos become obsolete

The old version strictly rejected non checksummed Ethereum addresses in SIWE messages. Because many dApps produce lowercase addresses, both MetaMask client repos maintain patches to disable the check — otherwise detectSIWE returns { isSIWEMessage: false } and users don't see the specialized SIWE approval screen.

@signinwithethereum/siwe-parser v4.2.0 (release notes) relaxes this:

  • All-lowercase and all-uppercase addresses now parse successfully with a non-fatal warning on the new warnings: string[] field of ParsedMessage
  • Only mixed-case addresses with an incorrect checksum still fail to parse
  • Verification is case-insensitive for EOA signature recovery
  • Object-constructed SiweMessage instances are normalized to EIP-55

If the client repos upgrade to this version of controller-utils, they can delete these patches and any related package.json resolutions:

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Medium Risk
Medium risk due to swapping SIWE parser/message dependencies, which can subtly change message parsing/validation behavior (notably EIP-55 checksum handling) and impact SIWE detection/login flows.

Overview
Updates @metamask/controller-utils to use @signinwithethereum/siwe-parser (replacing @spruceid/siwe-parser) and adjusts detectSIWE-related imports/tests accordingly.

Updates @metamask/profile-sync-controller to use @signinwithethereum/siwe (replacing siwe) for SIWE login message construction, with corresponding dependency and import changes, plus yarn.lock updates to drop the old transitive packages.

Reviewed by Cursor Bugbot for commit abf04a9. Bugbot is set up for automated code reviews on this repo. Configure here.

@caveman-eth caveman-eth requested review from a team as code owners April 16, 2026 18:42
@socket-security
Copy link
Copy Markdown

socket-security bot commented Apr 16, 2026

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​signinwithethereum/​siwe@​4.2.0751009893100
Added@​signinwithethereum/​siwe-parser@​4.2.0771009493100

View full report

caveman-eth added a commit to caveman-eth/metamask-core that referenced this pull request Apr 16, 2026
Replace placeholder PR links [#XXXX] with the actual PR number [MetaMask#8497] in CHANGELOG.md for packages/controller-utils and packages/profile-sync-controller. These entries document the replacement of the old siwe packages with the @signinwithethereum scoped packages.
Swap SpruceID-maintained SIWE packages for the @signinwithethereum scoped packages and update usages. Update package.json dependencies and imports (controller-utils: siwe.ts, siwe.test.ts; profile-sync-controller: flow-siwe.ts) and add changelog notes describing the migration. Uses @signinwithethereum/siwe-parser and @signinwithethereum/siwe ^4.2.0 — maintained by the Ethereum Identity Foundation and backward-compatible (parser v4.2.0 relaxes EIP-55 checksum enforcement and surfaces non-fatal warnings).
Replace placeholder PR links [#XXXX] with the actual PR number [MetaMask#8497] in CHANGELOG.md for packages/controller-utils and packages/profile-sync-controller. These entries document the replacement of the old siwe packages with the @signinwithethereum scoped packages.
@caveman-eth caveman-eth force-pushed the update-siwe-dependencies-2 branch from c500fd3 to abf04a9 Compare April 17, 2026 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant