WIP: CLI running of plugs
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import type { SysCallMapping } from "../../plugos/system.ts";
|
||||
import {
|
||||
ProxyFetchRequest,
|
||||
ProxyFetchResponse,
|
||||
} from "../../common/proxy_fetch.ts";
|
||||
import { base64Encode } from "../asset_bundle/base64.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())),
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user