-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Further restrict web worker permissions
- Loading branch information
Showing
6 changed files
with
65 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,44 @@ | ||
import type { ProjectSource } from "../util.ts"; | ||
import type { ISandbox } from "./sandbox.ts"; | ||
import { WebWorkerSandbox } from "./webWorker/webWorkerSandbox.ts"; | ||
import { | ||
type Permissions, | ||
WebWorkerSandbox, | ||
} from "./webWorker/webWorkerSandbox.ts"; | ||
|
||
export * from "./sandbox.ts"; | ||
export * from "./mockSandbox.ts"; | ||
export * from "./unsafeSandbox.ts"; | ||
|
||
export function getDefaultSandbox(path: string): Promise<ISandbox> { | ||
const IPFS_PERMISSIONS: Permissions = { | ||
allowRead: false, | ||
allowFFI: false, | ||
}; | ||
|
||
const LOCAL_PERMISSIONS: Permissions = { | ||
allowRead: true, | ||
allowFFI: true, | ||
}; | ||
|
||
function getPermisionsForSource(source: ProjectSource): Permissions { | ||
switch (source) { | ||
case "local": | ||
return LOCAL_PERMISSIONS; | ||
case "ipfs": | ||
return IPFS_PERMISSIONS; | ||
default: | ||
throw new Error( | ||
`Unable to set permissions for unknown source: ${source}`, | ||
); | ||
} | ||
} | ||
|
||
export function getDefaultSandbox( | ||
path: string, | ||
source: ProjectSource, | ||
): Promise<ISandbox> { | ||
// return UnsafeSandbox.create(path); | ||
return WebWorkerSandbox.create(path); | ||
const permissions = getPermisionsForSource(source); | ||
return WebWorkerSandbox.create(path, permissions); | ||
} | ||
|
||
export { WebWorkerSandbox }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters