mirror of
https://github.com/aljazceru/ditto.git
synced 2025-12-19 06:24:21 +01:00
Run the custom policy in a worker for security
This commit is contained in:
23
src/workers/policy.ts
Normal file
23
src/workers/policy.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import * as Comlink from 'comlink';
|
||||
|
||||
import { Conf } from '@/config.ts';
|
||||
import type { CustomPolicy } from '@/workers/policy.worker.ts';
|
||||
|
||||
const policyDir = new URL('../../data/policy', import.meta.url).pathname;
|
||||
|
||||
export const policyWorker = Comlink.wrap<CustomPolicy>(
|
||||
new Worker(
|
||||
new URL('./policy.worker.ts', import.meta.url),
|
||||
{
|
||||
type: 'module',
|
||||
deno: {
|
||||
permissions: {
|
||||
read: [Conf.policy, policyDir],
|
||||
write: [policyDir],
|
||||
net: 'inherit',
|
||||
env: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
),
|
||||
);
|
||||
Reference in New Issue
Block a user