MCPcopy Index your code
hub / github.com/MatterAIOrg/OrbCode / getBaseUrlFromToken

Function getBaseUrlFromToken

src/auth/auth.ts:7–24  ·  view source on GitHub ↗
(token?: string)

Source from the content-addressed store, hash-verified

5export const API_GATEWAY_PATH = "https://api2.matterai.so/v1/web/";
6
7export function getBaseUrlFromToken(token?: string): string {
8 if (token) {
9 try {
10 const payloadString = token.split(".")[1];
11 if (payloadString) {
12 const payload = JSON.parse(
13 Buffer.from(payloadString, "base64").toString(),
14 );
15 // UNTRUSTED payload: only used to detect the development environment,
16 // never to read URLs directly.
17 if (payload.env === "development") return "http://localhost:3000";
18 }
19 } catch {
20 // fall through to production URL
21 }
22 }
23 return DEFAULT_BACKEND_URL;
24}
25
26/** Re-host targetUrl onto the backend resolved from the token. */
27export function getUrlFromToken(targetUrl: string, token?: string): string {

Callers 1

getUrlFromTokenFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected