diff --git a/README.md b/README.md index b9d5b36..0f996aa 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,7 @@ Copy and paste the following code into a new file in your project: // lib/ironOptions.ts import { IronSessionOptions } from 'iron-session'; +import { Address } from 'wagmi'; if (!process.env.IRON_SESSION_PASSWORD) throw new Error('IRON_SESSION_PASSWORD must be set'); @@ -75,7 +76,7 @@ const ironOptions: IronSessionOptions = { declare module "iron-session" { interface IronSessionData { - address?: string | undefined; + address?: Address | undefined; nonce?: string | undefined; } } diff --git a/src/api.ts b/src/api.ts index fae1e76..c10ec24 100644 --- a/src/api.ts +++ b/src/api.ts @@ -1,5 +1,6 @@ import type { IncomingMessage, ServerResponse } from 'http'; import { generateNonce, SiweMessage } from 'siwe'; +import { Address } from 'wagmi'; import { fromZodError } from 'zod-validation-error'; import { GetSessionResponse, signInRequestSchema, SignInResponse, SignOutResponse } from './types.js'; @@ -55,7 +56,7 @@ export const signIn: RequestHandler = async (req, res) => { if (!success) return res.status(500).send("Unknown Error"); req.session.nonce = undefined; - req.session.address = data.address; + req.session.address = data.address as Address; await req.session.save(); return res.send("OK"); diff --git a/src/types.ts b/src/types.ts index 902f820..b1a7dc8 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,9 +1,10 @@ import "iron-session"; +import { Address } from "wagmi"; import { z } from "zod"; declare module "iron-session" { interface IronSessionData { - address?: string | undefined; + address?: Address | undefined; nonce?: string | undefined; } } @@ -30,8 +31,8 @@ export const signInRequestSchema = z.object({ export type GetSessionResponse = { authenticated: boolean, - address?: string, - nonce?: string + address?: Address, + nonce?: string, }; export type SignInRequest = z.infer;