export interface RelayResponse { reqId: string; status: number; headers: Record; body: string; // base64-encoded } const callbacks = new Map void>(); export function addPending( reqId: string, cb: ( r: RelayResponse ) => void ): void { callbacks.set( reqId, cb ); } export function resolvePending( resp: RelayResponse ): void { const cb = callbacks.get( resp.reqId ); if ( !cb ) return; callbacks.delete( resp.reqId ); cb( resp ); } export function removePending( reqId: string ): void { callbacks.delete( reqId ); }