cairn work

This commit is contained in:
2026-01-21 01:56:40 -05:00
parent 0d006e8260
commit 5fc082178c
12 changed files with 1716 additions and 4 deletions

23
src/server/cairn-auth.ts Normal file
View File

@@ -0,0 +1,23 @@
import { jwtVerify } from "jose";
import { env } from "~/env/server";
export type CairnAuthPayload = {
sub: string;
exp?: number;
iat?: number;
};
export async function verifyCairnToken(
token: string
): Promise<CairnAuthPayload> {
const secret = new TextEncoder().encode(env.CAIRN_JWT_SECRET);
const { payload } = await jwtVerify(token, secret, {
algorithms: ["HS256"]
});
return {
sub: payload.sub as string,
exp: payload.exp as number | undefined,
iat: payload.iat as number | undefined
};
}