mirror of
https://github.com/MetaFam/TheGame.git
synced 2026-01-14 08:58:02 -05:00
* 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>
37 lines
880 B
TypeScript
37 lines
880 B
TypeScript
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: 'metagame’s-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);
|