Skip to content

Commit

Permalink
fix verifyMsg in SIWE (#801)
Browse files Browse the repository at this point in the history
* fix verifyMsg

* comment unused fn

* update to latest and fix verify signature
  • Loading branch information
rtomas authored Jan 13, 2025
1 parent 7dee4ab commit 01e8ed9
Show file tree
Hide file tree
Showing 9 changed files with 1,159 additions and 324 deletions.
20 changes: 18 additions & 2 deletions dapps/appkit-siwe/next/app/api/auth/[...nextauth]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import NextAuth from 'next-auth';
import credentialsProvider from 'next-auth/providers/credentials';
import {
type SIWESession,
verifySignature,
/* verifySignature, */
getChainIdFromMessage,
getAddressFromMessage
} from '@reown/appkit-siwe'
import { createPublicClient, http } from 'viem'

declare module 'next-auth' {
interface Session extends SIWESession {
Expand Down Expand Up @@ -48,13 +49,28 @@ const providers = [
const address = getAddressFromMessage(message);
const chainId = getChainIdFromMessage(message);

const isValid = await verifySignature({
// for the moment, the verifySignature is not working with social logins and emails with non deployed smart accounts
/* const isValid = await verifySignature({
address,
message,
signature,
chainId,
projectId,
}); */
// we are going to use https://viem.sh/docs/actions/public/verifyMessage.html
const publicClient = createPublicClient(
{
transport: http(
`https://rpc.walletconnect.org/v1/?chainId=${chainId}&projectId=${projectId}`
)
}
);
const isValid = await publicClient.verifyMessage({
message,
address: address as `0x${string}`,
signature: signature as `0x${string}`
});
// end o view verifyMessage

if (isValid) {
return {
Expand Down
6 changes: 3 additions & 3 deletions dapps/appkit-siwe/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
},
"dependencies": {
"@tanstack/react-query": "^5.53.1",
"@reown/appkit-siwe": "1.5.2",
"@reown/appkit": "1.5.2",
"@reown/appkit-adapter-wagmi": "1.5.2",
"@reown/appkit-siwe": "1.6.4",
"@reown/appkit": "1.6.4",
"@reown/appkit-adapter-wagmi": "1.6.4",
"next": "14.2.7",
"next-auth": "^4.24.7",
"react": "^18",
Expand Down
419 changes: 312 additions & 107 deletions dapps/appkit-siwe/next/pnpm-lock.yaml

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dapps/appkit-siwe/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"dependencies": {
"@tanstack/react-query": "^5.53.1",
"@wagmi/core": "^2.13.4",
"@reown/appkit-siwe": "1.5.2",
"@reown/appkit": "1.5.2",
"@reown/appkit-adapter-wagmi": "1.5.2",
"@reown/appkit-siwe": "1.6.4",
"@reown/appkit": "1.6.4",
"@reown/appkit-adapter-wagmi": "1.6.4",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"viem": "^2.21.0",
Expand Down
Loading

0 comments on commit 01e8ed9

Please sign in to comment.