[PR #7564] feat(siwe): allow linking SIWE wallets to existing accounts #15650

Open
opened 2026-04-13 10:09:21 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7564
Author: @META-DREAMER
Created: 1/23/2026
Status: 🔄 Open

Base: nextHead: feat/siwe-account-linking


📝 Commits (7)

  • d778b60 refactor(siwe): improve code organization with extracted utilities and error codes
  • 39e6a61 feat(siwe): add wallet account linking for authenticated users
  • fcd9e11 feat(siwe): add cascading deletion of wallet addresses on account unlinking
  • 449003d fix(siwe): enforce email requirement when anonymous option is disabled
  • cee5f55 docs(siwe): document wallet account linking feature
  • 6f7dd69 fix(siwe): use parseUserOutput and ctx.context.trustedProviders for consistency
  • 779dd9c fix(siwe): update chainId validation and test after upstream rebase

📊 Changes

4 files changed (+1745 additions, -852 deletions)

View changed files

📝 docs/content/docs/plugins/siwe.mdx (+38 -0)
packages/better-auth/src/plugins/siwe/error-codes.ts (+8 -0)
📝 packages/better-auth/src/plugins/siwe/index.ts (+290 -197)
📝 packages/better-auth/src/plugins/siwe/siwe.test.ts (+1409 -655)

📄 Description

Summary

Currently, there is no way to add SIWE as an additional authentication method on an existing account. This PR adds account linking support to the SIWE plugin, as well as refactoring the code to be a bit cleaner and expanding test coverage.

  • Implements wallet account linking functionality for SIWE authentication
  • Allows users to link their Ethereum wallets to existing accounts
  • Adds proper error handling and validation for wallet linking
  • Includes cascading deletion of wallet addresses on account unlinking
  • Enforces email requirement when anonymous option is disabled

Changes

  • Add wallet linking API endpoints
  • Implement proper error codes (WALLET_ALREADY_LINKED, SESSION_CREATION_FAILED)
  • Add documentation for wallet account linking
  • Update tests to cover wallet linking scenarios
  • Implement cascading deletion for wallet addresses

Reimplementation of https://github.com/better-auth/better-auth/pull/6685 with cleaner commit history and more readable code.

Test plan

  • Run SIWE test suite: vitest packages/better-auth/src/plugins/siwe/siwe.test.ts
  • Verify account linking with trustedProviders config
  • Verify linking existing wallet for different user fails
  • Verify cascading deletion on account unlink
  • Verify anonymous mode email validation

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/7564 **Author:** [@META-DREAMER](https://github.com/META-DREAMER) **Created:** 1/23/2026 **Status:** 🔄 Open **Base:** `next` ← **Head:** `feat/siwe-account-linking` --- ### 📝 Commits (7) - [`d778b60`](https://github.com/better-auth/better-auth/commit/d778b60e4f6e32fb244aab4d773b8f363b1f2ee7) refactor(siwe): improve code organization with extracted utilities and error codes - [`39e6a61`](https://github.com/better-auth/better-auth/commit/39e6a618b6f12ab73fcd4cdd3864111b9f056137) feat(siwe): add wallet account linking for authenticated users - [`fcd9e11`](https://github.com/better-auth/better-auth/commit/fcd9e11c755b41bee2d64c0bde7b75c9c7e5734b) feat(siwe): add cascading deletion of wallet addresses on account unlinking - [`449003d`](https://github.com/better-auth/better-auth/commit/449003d5fc3fd783b9956392eae4e1ac8bf09d4e) fix(siwe): enforce email requirement when anonymous option is disabled - [`cee5f55`](https://github.com/better-auth/better-auth/commit/cee5f55f958d165612ed187224fe7bcb8ff06a13) docs(siwe): document wallet account linking feature - [`6f7dd69`](https://github.com/better-auth/better-auth/commit/6f7dd692809fcf52ac036bb1207addaa800279a6) fix(siwe): use parseUserOutput and ctx.context.trustedProviders for consistency - [`779dd9c`](https://github.com/better-auth/better-auth/commit/779dd9cd20021126e5043744db0feef867ba51eb) fix(siwe): update chainId validation and test after upstream rebase ### 📊 Changes **4 files changed** (+1745 additions, -852 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/plugins/siwe.mdx` (+38 -0) ➕ `packages/better-auth/src/plugins/siwe/error-codes.ts` (+8 -0) 📝 `packages/better-auth/src/plugins/siwe/index.ts` (+290 -197) 📝 `packages/better-auth/src/plugins/siwe/siwe.test.ts` (+1409 -655) </details> ### 📄 Description ## Summary Currently, there is no way to add SIWE as an additional authentication method on an existing account. This PR adds account linking support to the SIWE plugin, as well as refactoring the code to be a bit cleaner and expanding test coverage. - Implements wallet account linking functionality for SIWE authentication - Allows users to link their Ethereum wallets to existing accounts - Adds proper error handling and validation for wallet linking - Includes cascading deletion of wallet addresses on account unlinking - Enforces email requirement when anonymous option is disabled ## Changes - Add wallet linking API endpoints - Implement proper error codes (WALLET_ALREADY_LINKED, SESSION_CREATION_FAILED) - Add documentation for wallet account linking - Update tests to cover wallet linking scenarios - Implement cascading deletion for wallet addresses Reimplementation of https://github.com/better-auth/better-auth/pull/6685 with cleaner commit history and more readable code. ## Test plan - [x] Run SIWE test suite: vitest packages/better-auth/src/plugins/siwe/siwe.test.ts - [x] Verify account linking with trustedProviders config - [x] Verify linking existing wallet for different user fails - [x] Verify cascading deletion on account unlink - [x] Verify anonymous mode email validation --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-13 10:09:21 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#15650