From 058592f5e3d53ec6cb6812b80af683e68880b17c Mon Sep 17 00:00:00 2001 From: Jeff Emmett Date: Thu, 12 Mar 2026 19:40:02 -0700 Subject: [PATCH] fix(rwallet): fix stuck loading, auth, and add Sepolia ERC20 tokens - Add /encryptid/ to subdomain routing passthrough (was 404 on demo.rspace.online) - Replace rwallet's custom JWT verify with SDK's verifyEncryptIDToken (supports remote fallback when JWT_SECRET unavailable in rspace container) - Fix CRDT balance loading stuck spinner (early return skipped crdtLoading=false) - Add Sepolia testnet ERC20 tokens (USDC, WETH, LINK) Co-Authored-By: Claude Opus 4.6 --- .../rwallet/components/folk-wallet-viewer.ts | 7 ++++--- modules/rwallet/mod.ts | 18 ++++++++++-------- server/index.ts | 1 + 3 files changed, 15 insertions(+), 11 deletions(-) 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" ||