* use import_map.json instead of per-file import * remove test_deps.ts in favor of import_map * remove common/deps.ts in favor of import_map * use import_map instead of server/deps.ts * make all plug-api files usable without an import_map * make all lib files usable without an import_map * remove web/deps.ts in favor of import_map * fix plug build * remove plug-api/deps.ts in favor of lib/deps.ts * fix server deps bundled in client deps
23 lines
706 B
TypeScript
23 lines
706 B
TypeScript
import type { SysCallMapping } from "../system.ts";
|
|
import { ProxyFetchRequest, ProxyFetchResponse } from "../../proxy_fetch.ts";
|
|
import { base64Encode } from "../../crypto.ts";
|
|
|
|
export function sandboxFetchSyscalls(): SysCallMapping {
|
|
return {
|
|
"sandboxFetch.fetch": async (
|
|
_ctx,
|
|
url: string,
|
|
options: ProxyFetchRequest,
|
|
): Promise<ProxyFetchResponse> => {
|
|
// console.log("Got sandbox fetch ", url);
|
|
const resp = await fetch(url, options);
|
|
return {
|
|
status: resp.status,
|
|
ok: resp.ok,
|
|
headers: Object.fromEntries(resp.headers.entries()),
|
|
base64Body: base64Encode(new Uint8Array(await resp.arrayBuffer())),
|
|
};
|
|
},
|
|
};
|
|
}
|