[PR #2579] [MERGED] feat: SIWE plugin #21288

Closed
opened 2026-04-15 20:15:29 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/2579
Author: @rokitgg
Created: 5/7/2025
Status: Merged
Merged: 7/19/2025
Merged by: @Bekacru

Base: v1.3Head: feat/siwe-plugin


📝 Commits (10+)

  • 7a55102 feat: first draft of SIWE plugin
  • c7d2db3 fix: run biome linter
  • 4449ee2 refactor(siwe): rename publicKey to walletAddress for clarity
  • 5ccd6cc fix(siwe): update emailDomainName assignment to use nullish coalescing operator
  • 798eb2e run biome linter
  • 6d98d20 fix(siwe): avatar field is not included in createUser call
  • 8c8e59d refactor(siwe): remove siwe dependency and implement nonce generation and message verification through plugin options
  • 7d3325b feat: add anonymous flag to plugin options
  • 36f5ba6 refactor(siwe): improve test coverage - anonymous flag, missing nonce & other edge cases
  • 5e4a726 feat(siwe): add checksum address validation using keccak256 + test case

📊 Changes

10 files changed (+1393 additions, -18 deletions)

View changed files

📝 docs/components/sidebar-content.tsx (+18 -0)
docs/content/docs/plugins/siwe.mdx (+232 -0)
📝 packages/better-auth/package.json (+15 -1)
packages/better-auth/src/plugins/siwe/client.ts (+11 -0)
packages/better-auth/src/plugins/siwe/index.ts (+303 -0)
packages/better-auth/src/plugins/siwe/schema.ts (+32 -0)
packages/better-auth/src/plugins/siwe/siwe.test.ts (+678 -0)
packages/better-auth/src/plugins/siwe/types.ts (+59 -0)
packages/better-auth/src/utils/hashing.ts (+25 -0)
📝 pnpm-lock.yaml (+20 -17)

📄 Description

Aims to close #41

Tried my best to implement SIWE within the boundaries of better-auth, and seems like this draft may be a good starting point for it! Although I do feel like a bit of discussion is needed on some topics.

Things to consider:

  1. As of this draft, the plugin requires the official siwe npm package as a dependency, which may not be ideal
  2. Comprehensive testing could include mocking a wallet connection to generate a real signature - as of now tests are bit too shy in my opinion, should be improved.
  3. Happy to help with documentation on how to actually implement a web3 login feature using this plugin, which absolutely needs some proper docs to help beginners.

Any feedback/contributions are highly welcomed!


🔄 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/2579 **Author:** [@rokitgg](https://github.com/rokitgg) **Created:** 5/7/2025 **Status:** ✅ Merged **Merged:** 7/19/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `v1.3` ← **Head:** `feat/siwe-plugin` --- ### 📝 Commits (10+) - [`7a55102`](https://github.com/better-auth/better-auth/commit/7a55102f1ae12e75988bb85c679eed253a4e735c) feat: first draft of SIWE plugin - [`c7d2db3`](https://github.com/better-auth/better-auth/commit/c7d2db306c54a92796835dbf10c0bbc1b78dd37c) fix: run biome linter - [`4449ee2`](https://github.com/better-auth/better-auth/commit/4449ee228d9f71d41f26cd11679b2b1a37a112bc) refactor(siwe): rename publicKey to walletAddress for clarity - [`5ccd6cc`](https://github.com/better-auth/better-auth/commit/5ccd6cccaee6dab0153e231b085f3f1a10efcc00) fix(siwe): update emailDomainName assignment to use nullish coalescing operator - [`798eb2e`](https://github.com/better-auth/better-auth/commit/798eb2e035efa979cd3f3a6370b2c314c68e0651) run biome linter - [`6d98d20`](https://github.com/better-auth/better-auth/commit/6d98d20fcfffb092804992bac9d53596225a8b7c) fix(siwe): avatar field is not included in createUser call - [`8c8e59d`](https://github.com/better-auth/better-auth/commit/8c8e59d233093d89390e84f94e23ee0f234deb74) refactor(siwe): remove siwe dependency and implement nonce generation and message verification through plugin options - [`7d3325b`](https://github.com/better-auth/better-auth/commit/7d3325bbed78107e1791a88026fe87d026ce5bcb) feat: add anonymous flag to plugin options - [`36f5ba6`](https://github.com/better-auth/better-auth/commit/36f5ba6f8d2f2e5b912c2d9c4d9a027c2262a1e3) refactor(siwe): improve test coverage - anonymous flag, missing nonce & other edge cases - [`5e4a726`](https://github.com/better-auth/better-auth/commit/5e4a7262a4e4ae9c1f0482466502d2077ccc83c1) feat(siwe): add checksum address validation using keccak256 + test case ### 📊 Changes **10 files changed** (+1393 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `docs/components/sidebar-content.tsx` (+18 -0) ➕ `docs/content/docs/plugins/siwe.mdx` (+232 -0) 📝 `packages/better-auth/package.json` (+15 -1) ➕ `packages/better-auth/src/plugins/siwe/client.ts` (+11 -0) ➕ `packages/better-auth/src/plugins/siwe/index.ts` (+303 -0) ➕ `packages/better-auth/src/plugins/siwe/schema.ts` (+32 -0) ➕ `packages/better-auth/src/plugins/siwe/siwe.test.ts` (+678 -0) ➕ `packages/better-auth/src/plugins/siwe/types.ts` (+59 -0) ➕ `packages/better-auth/src/utils/hashing.ts` (+25 -0) 📝 `pnpm-lock.yaml` (+20 -17) </details> ### 📄 Description Aims to close #41 Tried my best to implement SIWE within the boundaries of better-auth, and seems like this draft may be a good starting point for it! Although I do feel like a bit of discussion is needed on some topics. Things to consider: 1) As of this draft, the plugin requires the official [siwe](https://www.npmjs.com/package/siwe) npm package as a dependency, which may not be ideal 2) Comprehensive testing could include mocking a wallet connection to generate a real signature - as of now tests are bit too shy in my opinion, should be improved. 3) Happy to help with documentation on how to actually implement a web3 login feature using this plugin, which absolutely needs some proper docs to help beginners. Any feedback/contributions are highly welcomed! --- <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-15 20:15:29 -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#21288