E2E encryption (prototype) (#601)

Prototype E2E encryption
This commit is contained in:
Zef Hemel
2023-12-17 11:46:18 +01:00
committed by GitHub
parent bcf29968ce
commit 5a7a35c759
18 changed files with 702 additions and 210 deletions
+3 -3
View File
@@ -28,15 +28,15 @@ export function sandboxFetchSyscalls(
body: options.base64Body && base64Decode(options.base64Body),
}
: {};
if (!client.remoteSpacePrimitives) {
if (!client.httpSpacePrimitives) {
// No SB server to proxy the fetch available so let's execute the request directly
return performLocalFetch(url, fetchOptions);
}
fetchOptions.headers = fetchOptions.headers
? { ...fetchOptions.headers, "X-Proxy-Request": "true" }
: { "X-Proxy-Request": "true" };
const resp = await client.remoteSpacePrimitives.authenticatedFetch(
`${client.remoteSpacePrimitives.url}/!${url}`,
const resp = await client.httpSpacePrimitives.authenticatedFetch(
`${client.httpSpacePrimitives.url}/!${url}`,
fetchOptions,
);
const body = await resp.arrayBuffer();
+3 -3
View File
@@ -10,11 +10,11 @@ export function shellSyscalls(
cmd: string,
args: string[],
): Promise<{ stdout: string; stderr: string; code: number }> => {
if (!client.remoteSpacePrimitives) {
if (!client.httpSpacePrimitives) {
throw new Error("Not supported in fully local mode");
}
const resp = client.remoteSpacePrimitives.authenticatedFetch(
`${client.remoteSpacePrimitives.url}/.rpc`,
const resp = client.httpSpacePrimitives.authenticatedFetch(
`${client.httpSpacePrimitives.url}/.rpc`,
{
method: "POST",
body: JSON.stringify({
+1 -1
View File
@@ -43,7 +43,7 @@ export function systemSyscalls(
// Proxy to another environment
return proxySyscall(
ctx,
client.remoteSpacePrimitives,
client.httpSpacePrimitives,
"system.invokeFunction",
[fullName, ...args],
);
+1 -1
View File
@@ -7,7 +7,7 @@ export function proxySyscalls(client: Client, names: string[]): SysCallMapping {
const syscalls: SysCallMapping = {};
for (const name of names) {
syscalls[name] = (ctx, ...args: any[]) => {
return proxySyscall(ctx, client.remoteSpacePrimitives, name, args);
return proxySyscall(ctx, client.httpSpacePrimitives, name, args);
};
}
return syscalls;