diff --git a/modules/rwallet/components/folk-wallet-viewer.ts b/modules/rwallet/components/folk-wallet-viewer.ts index 4f84352..b3753c3 100644 --- a/modules/rwallet/components/folk-wallet-viewer.ts +++ b/modules/rwallet/components/folk-wallet-viewer.ts @@ -247,9 +247,10 @@ class FolkWalletViewer extends HTMLElement { const res = await fetch(`${base}/api/crdt-tokens/my-balances`, { headers: { "Authorization": `Bearer ${token}` }, }); - if (!res.ok) return; - const data = await res.json(); - this.crdtBalances = data.balances || []; + if (res.ok) { + const data = await res.json(); + this.crdtBalances = data.balances || []; + } } catch {} this.crdtLoading = false; this.render(); diff --git a/modules/rwallet/mod.ts b/modules/rwallet/mod.ts index 16405ea..f9f5ee1 100644 --- a/modules/rwallet/mod.ts +++ b/modules/rwallet/mod.ts @@ -10,6 +10,7 @@ import { renderShell } from "../../server/shell"; import { getModuleInfoList } from "../../shared/module"; import type { RSpaceModule } from "../../shared/module"; import { renderLanding } from "./landing"; +import { verifyEncryptIDToken, extractToken } from "@encryptid/sdk/server"; const routes = new Hono(); @@ -220,15 +221,11 @@ async function rpcCall(rpcUrl: string, method: string, params: any[]): Promise { - const authorization = c.req.header("Authorization"); - if (!authorization?.startsWith("Bearer ")) return null; + const token = extractToken(c.req.raw.headers); + if (!token) return null; try { - // Import verify dynamically to avoid adding hono/jwt as a module-level dep - const { verify } = await import("hono/jwt"); - const secret = process.env.JWT_SECRET; - if (!secret) return null; - const payload = await verify(authorization.slice(7), secret, "HS256"); - return payload as any; + const claims = await verifyEncryptIDToken(token); + return claims as any; } catch { return null; } @@ -435,6 +432,11 @@ const POPULAR_TOKENS: Record({ if ( url.pathname.startsWith("/api/") || url.pathname.startsWith("/data/") || + url.pathname.startsWith("/encryptid/") || url.pathname.startsWith("/.well-known/") || url.pathname === "/about" || url.pathname === "/admin" ||