Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ export async function GET() {
import { NextRequest, NextResponse } from 'next/server';
import { createPublicClient, http } from 'viem';
import { base } from 'viem/chains';
import { verifySiweMessage } from 'viem/siwe';
import { nonceStore } from '@/lib/nonce-store';

const client = createPublicClient({
Expand All @@ -233,12 +234,15 @@ export async function POST(request: NextRequest) {
);
}

// Verify signature using viem
const valid = await client.verifyMessage({
address: address as `0x${string}`,
message,
signature: signature as `0x${string}`
// Verify signature using viem with SIWE validation
const { isValid } = await verifySiweMessage(client, {
address: address as `0x${string}`,
message,
signature: signature as `0x${string}`,
domain: request.headers.get('host') ?? 'yourapp.com',
nonce: nonce,
});
const valid = isValid;

if (!valid) {
return NextResponse.json(
Expand Down