Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 6fdebc1

Browse files
committed
feat: decode base58btc JWK from session token before parsing
1 parent be861c1 commit 6fdebc1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

backend/cf-serve.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { drizzle } from "drizzle-orm/d1";
22
import { D1Database, Fetcher, Request as CFRequest, Response as CFResponse } from "@cloudflare/workers-types";
3+
import { base58btc } from "multiformats/bases/base58";
34
import { CORS, createHandler } from "./create-handler.ts";
45
import { URI } from "@adviser/cement";
56

@@ -21,7 +22,8 @@ export default {
2122
let body: string;
2223
let status = 200;
2324
try {
24-
const jwk = JSON.parse(jwkRaw);
25+
const decodedKey = base58btc.decode(jwkRaw);
26+
const jwk = JSON.parse(decodedKey.toString());
2527
body = JSON.stringify({ keys: [jwk] });
2628
} catch {
2729
body = "Invalid CLOUD_SESSION_TOKEN_PUBLIC";

0 commit comments

Comments
 (0)