Expose the Ditto pubkey to the policy worker

This commit is contained in:
Alex Gleason 2024-10-04 19:21:56 -05:00
parent a2e8de6c36
commit 3b5b4cbd6b
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
2 changed files with 5 additions and 5 deletions

View file

@ -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}`);

View file

@ -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<void> {
async init({ path, databaseUrl, pubkey }: PolicyInit): Promise<void> {
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 });
}
}