File tree 3 files changed +333
-112
lines changed
app/api/auth/[...nextauth] 3 files changed +333
-112
lines changed Original file line number Diff line number Diff line change @@ -2,10 +2,11 @@ import NextAuth from 'next-auth';
2
2
import credentialsProvider from 'next-auth/providers/credentials' ;
3
3
import {
4
4
type SIWESession ,
5
- verifySignature ,
5
+ /* verifySignature, */
6
6
getChainIdFromMessage ,
7
7
getAddressFromMessage
8
8
} from '@reown/appkit-siwe'
9
+ import { createPublicClient , http } from 'viem'
9
10
10
11
declare module 'next-auth' {
11
12
interface Session extends SIWESession {
@@ -48,13 +49,28 @@ const providers = [
48
49
const address = getAddressFromMessage ( message ) ;
49
50
const chainId = getChainIdFromMessage ( message ) ;
50
51
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({
52
54
address,
53
55
message,
54
56
signature,
55
57
chainId,
56
58
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 } `
57
72
} ) ;
73
+ // end o view verifyMessage
58
74
59
75
if ( isValid ) {
60
76
return {
Original file line number Diff line number Diff line change 10
10
},
11
11
"dependencies" : {
12
12
"@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 " ,
16
16
"next" : " 14.2.7" ,
17
17
"next-auth" : " ^4.24.7" ,
18
18
"react" : " ^18" ,
You can’t perform that action at this time.
0 commit comments