chore: Migrate SIWE dependency to @signinwithethereum/siwe v4 - #8497
caveman-eth wants to merge 3 commits into
Conversation
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
c500fd3 to
abf04a9
Compare
abf04a9 to
5dc2a17
Compare
5dc2a17 to
0889956
Compare
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.
0889956 to
6b91d4d
Compare
|
Let me know if you guys have any questions around this. |
|
bumping this up |
|
Thanks for the PR @caveman-eth PR looks good to me and hopefully be ready after fixing conflicts 🙏 |
Hey great - I've resolved the conflicts and merged in main |
|
Hey @caveman-eth I think we have two issues here:
Important: the package's runtime behavior is fine (dual CJS/ESM exports are correctly set up, and our Jest tests - which bypass ts-bridge - pass). This is purely a type-declaration packaging gap upstream, not a real incompatibility. Can we publish conditional type declarations (
This PR is from a fork ( When we have fix for the first issue, I can update the version and give another try? |
|
@OGPoyraz, thanks for digging into this.
import → .d.mts + .mjs https://www.npmjs.com/package/@signinwithethereum/siwe/v/4.2.1 Age gate: Core’s Yarn config waits 3 days after publish (npmMinimalAgeGate: 4320). 4.2.1 went up at 2026-09-01 16:50 UTC, so yarn install should accept it around 2026-09-04 16:50 UTC. Happy to bump this PR (or #10049) as soon as that window opens.
|
|
Hey @caveman-eth, thanks for the quick turnaround on The only remaining blocker is the Once that clears I'll bump both Thanks again for staying on top of this 🙏 |
|
@OGPoyraz great, sounds good. I'll ping you here after 2026-09-04 16:50 UTC :) |
|
Should be all clear now @OGPoyraz as of an hour ago |
|
Hey @caveman-eth, just to note PR is in the review now, hoping to merge it soon, fyi |
|
Here is my latest update: As #10049 is merged, I will let teams to update package dependencies because there are some BC other teams need to handle. But naturally this downstream dependency(parser package) will happen in the clients eventually. fyi @caveman-eth |
I was following along, happy to see it, thanks @OGPoyraz 🙏 |
…sk#10049) Reproduction of MetaMask#8497 on a same-repo branch (not a fork) to verify CI, specifically to confirm the TS1479 build failure and rule out fork-only changelog-check failures. ## 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. `@signinwithethereum/siwe` is the official successor TypeScript implementation. ### 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. ### Known issue (reproduced here) `@signinwithethereum/siwe-parser@4.2.0` declares \"type\": \"module\" but only ships a single unconditional `.d.ts` (no separate `.d.cts`). Under this repo's `Node16` module resolution, TypeScript infers the shared `.d.ts` as ESM-only, causing a TS1479 error when `controller-utils` (a CJS package) imports it. This reproduction branch is to confirm that failure in CI independent of the fork-related changelog-check issues seen on MetaMask#8497. ## Package review Supply-chain: `4.2.0->4.2.1` is types-only (`.d.mts`/`.d.cts`, `isUri: boolean`), zero runtime change, deps unchanged (`apg-js`, `@noble/hashes`), no CVEs, owner Ethereum Identity Foundation (active). Minimal risk. CodeQL/Semgrep/zizmor/Socket pass on this PR. Correct split: `controller-utils` -> `siwe-parser` (parse via `ParsedMessage`), `profile-sync-controller` -> `siwe` (construct via `SiweMessage.prepareMessage()`). Parser has no `SiweMessage` export, so swapping profile-sync to parser breaks Build/Tests (TS2307) plus knip (unused/unlisted) and cascades to account-tree/notification/profile-metrics dependents. Fix applied locally (uncommitted): profile-sync back to `siwe@^4.2.1` + `yarn install`. Verified: LSP clean, `lint:misc --check` pass, knip no unused/unlisted, `authentication.test.ts` 28 passed. Backend (`/api/v2/siwe/login`) remains the auth boundary — reviewers confirm nonce single-use, domain/uri/chainId binding, expiry, and EIP-191/1271 verification. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Touches SIWE parsing and profile login message construction on auth-related paths, though APIs are described as backward compatible and server verification remains the trust boundary. > > **Overview** > Migrates unmaintained Spruce SIWE dependencies to the Ethereum Identity Foundation **`@signinwithethereum`** packages, with import and lockfile updates only. > > **`@metamask/controller-utils`** swaps **`@spruceid/siwe-parser`** for **`@signinwithethereum/siwe-parser`** ^4.2.1 (`ParsedMessage` in `detectSIWE` / SIWE origin checks). **v4.2.1** loosens EIP-55 parsing: all-lower or all-upper addresses can parse (optional **`warnings`**); only bad mixed-case checksums still fail. > > **`@metamask/profile-sync-controller`** replaces the **`siwe`** package with **`@signinwithethereum/siwe`** ^4.2.1 for JWT SIWE login message construction in **`flow-siwe.ts`** (`SiweMessage.prepareMessage()` usage unchanged). > > Changelogs document the swap; **`yarn.lock`** drops legacy **`siwe`** / extra Spruce parser entries and adds the new scoped packages. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 6d9bd98. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
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-parserv2.1.0 — used by@metamask/controller-utilsto detect and parse SIWE messages viadetectSIWE()siwev2.3.2 — used by@metamask/profile-sync-controllerto construct SIWE login messages vianew SiweMessage({...}).prepareMessage()The Spruce
siwepackage is no longer actively maintained.Stewardship of the SIWE standard has moved to the Ethereum Identity Foundation (GitHub).
@signinwithethereum/siweis 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
ParsedMessageandSiweMessageclass APIs are identical - same constructors, same fields, same methods. This is purely a dependency swap with import path updates.Files changed:
controller-utilspackage.jsoncontroller-utilssrc/siwe.tscontroller-utilssrc/siwe.test.tsprofile-sync-controllerpackage.jsonprofile-sync-controllersrc/sdk/authentication-jwt-bearer/flow-siwe.tsEIP-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
detectSIWEreturns{ isSIWEMessage: false }and users don't see the specialized SIWE approval screen.@signinwithethereum/siwe-parserv4.2.0 (release notes) relaxes this:warnings: string[]field ofParsedMessageSiweMessageinstances are normalized to EIP-55If the client repos upgrade to this version of
controller-utils, they can delete these patches and any relatedpackage.jsonresolutions:metamask-extension/.yarn/patches/@spruceid-siwe-parser-npm-2.1.0-060b7ede7a.patchmetamask-mobile/patches/@spruceid+siwe-parser+2.1.0.patchReferences
@signinwithethereum/siwe-parseron npm@signinwithethereum/siweon npmChecklist
Note
Medium Risk
Changes SIWE parsing and login message construction on auth-related paths; APIs are intended to be compatible, but v4.2.0 address-checksum behavior differs from the old strict parser.
Overview
Replaces unmaintained Spruce SIWE packages with @signinwithethereum successors (^4.2.0) in
@metamask/controller-utilsand@metamask/profile-sync-controller.controller-utilsswaps@spruceid/siwe-parserfor@signinwithethereum/siwe-parserand updates imports insiwe.ts/ tests.detectSIWEstill usesParsedMessagethe same way.profile-sync-controllerdrops thesiwepackage for@signinwithethereum/siweand updatesflow-siwe.tsso JWT SIWE login still builds messages vianew SiweMessage({...}).prepareMessage().Changelogs note that v4.2.0 relaxes EIP-55 parsing: all-lowercase or all-uppercase addresses parse (with optional
warnings); only bad mixed-case checksums fail. That may let extension/mobile remove local parser patches once they pick up this core release.Reviewed by Cursor Bugbot for commit 0ae4c09. Bugbot is set up for automated code reviews on this repo. Configure here.