From 3b5b4cbd6b79799faa9eb5d6c937033d7b9cfdac Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 4 Oct 2024 19:21:56 -0500 Subject: [PATCH] Expose the Ditto pubkey to the policy worker --- src/workers/policy.ts | 2 +- src/workers/policy.worker.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/workers/policy.ts b/src/workers/policy.ts index 941b5cf1..debfe242 100644 --- a/src/workers/policy.ts +++ b/src/workers/policy.ts @@ -50,7 +50,7 @@ class PolicyWorker implements NPolicy { await this.worker.init({ path: Conf.policy, databaseUrl: Conf.databaseUrl, - adminPubkey: Conf.pubkey, + pubkey: Conf.pubkey, }); console.warn(`Using custom policy: ${Conf.policy}`); diff --git a/src/workers/policy.worker.ts b/src/workers/policy.worker.ts index 6b256a21..86cea87c 100644 --- a/src/workers/policy.worker.ts +++ b/src/workers/policy.worker.ts @@ -18,7 +18,7 @@ interface PolicyInit { /** Database URL to connect to. */ databaseUrl: string; /** Admin pubkey to use for EventsDB checks. */ - adminPubkey: string; + pubkey: string; } export class CustomPolicy implements NPolicy { @@ -29,18 +29,18 @@ export class CustomPolicy implements NPolicy { return this.policy.call(event, signal); } - async init({ path, databaseUrl, adminPubkey }: PolicyInit): Promise { + async init({ path, databaseUrl, pubkey }: PolicyInit): Promise { const Policy = (await import(path)).default; const { kysely } = DittoDB.create(databaseUrl, { poolSize: 1 }); const store = new EventsDB({ kysely, - pubkey: adminPubkey, + pubkey, timeout: 1_000, }); - this.policy = new Policy({ store }); + this.policy = new Policy({ store, pubkey }); } }