From 184732c2a5cd908f79096b12fe57fb5b7f82e8ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl?= Date: Fri, 27 Feb 2026 17:58:15 -0300 Subject: [PATCH] Fix backend TS: npub decode type guard for login-npub Made-with: Cursor --- backend/src/routes/auth.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/src/routes/auth.ts b/backend/src/routes/auth.ts index d0d3561..986f438 100644 --- a/backend/src/routes/auth.ts +++ b/backend/src/routes/auth.ts @@ -20,12 +20,12 @@ router.post("/login-npub", (req: Request, res: Response) => { return; } try { - const decoded = nip19.decode(raw); - if (decoded.type !== "npub") { + const decoded = nip19.decode(raw) as { type: string; data: unknown }; + if (decoded.type !== "npub" || typeof decoded.data !== "string") { res.status(400).json({ code: "invalid_npub", message: "Expected an npub-encoded public key." }); return; } - const pubkey = decoded.data as string; + const pubkey = decoded.data; const token = signJwt(pubkey, "npub"); res.json({ token, pubkey, method: "npub" }); } catch {