From 5248bf5ffca4c8b3303de4c73d11c9f7f0cfde13 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 21 Jan 2026 15:00:02 -0800 Subject: redirect on invalid token --- src/lib/utils.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/lib/utils.ts') diff --git a/src/lib/utils.ts b/src/lib/utils.ts index a3d9cd49..f220ed45 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -199,6 +199,20 @@ export const auth = (cookies) => ({ authorization: `Bearer ${cookies.get("token")}`, }); +export const isInvalidTokenError = (e: unknown) => { + const message = (e as Error)?.message || ""; + if (!message) return false; + const normalized = message.toLowerCase(); + return ( + normalized.includes("jwt") || + normalized.includes("invalid token") || + normalized.includes("token expired") || + normalized.includes("expired token") || + normalized.includes("unauthorized") || + normalized.includes("not authorized") + ); +}; + export const btc = (fiat: number, rate: number): number => Math.round((fiat * sats) / rate); -- cgit v1.2.3