Files
TheGame/packages/web/lib/ironSession.ts
Sero 38c3dc059e Sero/wc v2 (#1735)
* wc/wagmi/viem

* replace

* profile

* replace context (,:

* testing, clean up

* wallet connect deploy

* connect

* remove type slive

* podcast

* podcast

* heck yeah

* feat: connect button

* chore

* trying siwe, network switch

* redirect

* prettying, cleaning up SIWE endpoints, & passing linting 🕊

* switching minting to Optimism & converting `ethers` to `wagmi` for contract access 🥧

* simplified onboarding & successfully minted 

* typo

* api key

---------

Co-authored-by: Udit Takkar <udit222001@gmail.com>
Co-authored-by: dysbulic <dys@dhappy.org>
2024-03-21 06:09:12 -04:00

37 lines
880 B
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { getIronSession } from 'iron-session';
import {
NextApiRequest as NextAPIRequest,
NextApiResponse as NextAPIResponse,
} from 'next';
export const ironSessionConfig = {
password:
process.env.SESSION_SECRET ??
(() => {
throw new Error('No `$SESSION_SECRET`.');
})(),
cookieName: 'metagames-mymeta-iron-session',
cookieOptions: {
sameSite: 'none',
partitioned: true,
// httpOnly: false,
// secure: Boolean(Deno.env.get('SECURE_SESSION') ?? false),
} as const,
};
export type IronSession = {
destroy: () => void;
get: (key: string) => unknown;
set: (key: string, value: unknown) => void;
save: () => void;
nonce: string;
siwe: {
data: {
address: string;
};
};
};
export const getSession = (req: NextAPIRequest, res: NextAPIResponse) =>
getIronSession<IronSession>(req, res, ironSessionConfig);