Skip to content

Commit 4006b4c

Browse files
committed
update to latest and fix verify signature
1 parent 8bc7c32 commit 4006b4c

File tree

3 files changed

+333
-112
lines changed

3 files changed

+333
-112
lines changed

dapps/appkit-siwe/next/app/api/auth/[...nextauth]/route.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import NextAuth from 'next-auth';
22
import credentialsProvider from 'next-auth/providers/credentials';
33
import {
44
type SIWESession,
5-
verifySignature,
5+
/* verifySignature, */
66
getChainIdFromMessage,
77
getAddressFromMessage
88
} from '@reown/appkit-siwe'
9+
import { createPublicClient, http } from 'viem'
910

1011
declare module 'next-auth' {
1112
interface Session extends SIWESession {
@@ -48,13 +49,28 @@ const providers = [
4849
const address = getAddressFromMessage(message);
4950
const chainId = getChainIdFromMessage(message);
5051

51-
const isValid = await verifySignature({
52+
// for the moment, the verifySignature is not working with social logins and emails with non deployed smart accounts
53+
/* const isValid = await verifySignature({
5254
address,
5355
message,
5456
signature,
5557
chainId,
5658
projectId,
59+
}); */
60+
// we are going to use https://viem.sh/docs/actions/public/verifyMessage.html
61+
const publicClient = createPublicClient(
62+
{
63+
transport: http(
64+
`https://rpc.walletconnect.org/v1/?chainId=${chainId}&projectId=${projectId}`
65+
)
66+
}
67+
);
68+
const isValid = await publicClient.verifyMessage({
69+
message,
70+
address: address as `0x${string}`,
71+
signature: signature as `0x${string}`
5772
});
73+
// end o view verifyMessage
5874

5975
if (isValid) {
6076
return {

dapps/appkit-siwe/next/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
},
1111
"dependencies": {
1212
"@tanstack/react-query": "^5.53.1",
13-
"@reown/appkit-siwe": "1.5.2",
14-
"@reown/appkit": "1.5.2",
15-
"@reown/appkit-adapter-wagmi": "1.5.2",
13+
"@reown/appkit-siwe": "1.6.4",
14+
"@reown/appkit": "1.6.4",
15+
"@reown/appkit-adapter-wagmi": "1.6.4",
1616
"next": "14.2.7",
1717
"next-auth": "^4.24.7",
1818
"react": "^18",

0 commit comments

Comments
 (0)