1- import { TeeEndpoint as ExpressEndpoint , TeeProxyEndpoint } from "../../types/tee-types" ;
1+ import {
2+ TeeEndpoint as ExpressEndpoint ,
3+ TeeProxyEndpoint ,
4+ } from "../../types/tee-types" ;
25
36export const TEE_BASE = "https://tee.express.magiclabs.com" ;
47
@@ -10,18 +13,21 @@ export const TEE_BASE = "https://tee.express.magiclabs.com";
1013 * @returns Parsed JSON data from the response
1114 * @throws Error if response is not ok or contains error information
1215 */
13- export async function express < T = any > ( path : ExpressEndpoint , jwt : string , init ?: RequestInit ) : Promise < T > {
14- const obj = JSON . parse ( init ?. body as string ) as { chain : string }
16+ export async function express < T = any > (
17+ path : ExpressEndpoint ,
18+ jwt : string ,
19+ init ?: RequestInit
20+ ) : Promise < T > {
21+ const obj = JSON . parse ( init ?. body as string ) as { chain : string } ;
1522 const response = await fetch ( TEE_BASE + path , {
1623 ...init ,
1724 headers : {
1825 "Content-Type" : "application/json" ,
1926 Authorization : `Bearer ${ jwt } ` ,
2027 "X-Magic-Secret-Key" : process . env . MAGIC_API_KEY ?? "" ,
21- "X-OIDC-Provider-ID" : process . env . OIDC_PROVIDER_ID ?? "" ,
28+ "X-OIDC-Provider-ID" : process . env . NEXT_PUBLIC_OIDC_PROVIDER_ID ?? "" ,
2229 "X-Magic-Chain" : obj . chain ,
23- "X-Magic-Referrer" :
24- "https://demo.magic.link" ,
30+ "X-Magic-Referrer" : "https://demo.magic.link" ,
2531 ...( init ?. headers || { } ) ,
2632 } ,
2733 cache : "no-store" ,
@@ -30,7 +36,7 @@ export async function express<T = any>(path: ExpressEndpoint, jwt: string, init?
3036 // Handle response validation and JSON parsing
3137 if ( ! response . ok ) {
3238 const data = await response . json ( ) . catch ( ( ) => ( { } ) ) ;
33-
39+
3440 // For other errors, throw a generic error
3541 throw new Error ( data . error || `HTTP error! status: ${ response . status } ` ) ;
3642 }
0 commit comments