Skip to content

Commit

Permalink
update to latest and fix verify signature
Browse files Browse the repository at this point in the history
  • Loading branch information
rtomas committed Jan 11, 2025
1 parent 8bc7c32 commit 4006b4c
Show file tree
Hide file tree
Showing 3 changed files with 333 additions and 112 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
Loading

0 comments on commit 4006b4c

Please sign in to comment.