Create monorepo from known-good production state
This commit is contained in:
commit
c034824338
651 changed files with 120469 additions and 0 deletions
15
app/lib/jwt.ts
Normal file
15
app/lib/jwt.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
// lib/jwt.ts
|
||||
export function jwtExp(token?: string | null): number | null {
|
||||
if (!token) return null;
|
||||
try {
|
||||
const payload = JSON.parse(Buffer.from(token.split(".")[1], "base64").toString("utf8"));
|
||||
return typeof payload?.exp === "number" ? payload.exp : null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function isJwtValid(token?: string | null): boolean {
|
||||
const exp = jwtExp(token);
|
||||
return !!exp && exp * 1000 > Date.now();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue