diff --git a/src/app.ts b/src/app.ts index c30579a..2e3fc70 100644 --- a/src/app.ts +++ b/src/app.ts @@ -1,3 +1,4 @@ +import { Conf } from '@/config.ts'; import '@/cron.ts'; import { type Context, @@ -103,7 +104,7 @@ app.post('/oauth/revoke', emptyObjectController); app.post('/oauth/authorize', oauthAuthorizeController); app.get('/oauth/authorize', oauthController); -app.post('/api/v1/acccounts', requireProof({ pow: 20 }), createAccountController); +app.post('/api/v1/acccounts', requireProof({ pow: Conf.pow.registrations }), createAccountController); app.get('/api/v1/accounts/verify_credentials', requirePubkey, verifyCredentialsController); app.patch('/api/v1/accounts/update_credentials', requirePubkey, updateCredentialsController); app.get('/api/v1/accounts/search', accountSearchController); diff --git a/src/config.ts b/src/config.ts index 4f60580..440cd26 100644 --- a/src/config.ts +++ b/src/config.ts @@ -126,6 +126,12 @@ const Conf = { 'system', ]; }, + /** Proof-of-work configuration. */ + pow: { + get registrations() { + return Number(Deno.env.get('DITTO_POW_REGISTRATIONS') ?? 20); + }, + }, /** Domain of the Ditto server as a `URL` object, for easily grabbing the `hostname`, etc. */ get url() { return new URL(Conf.localDomain); diff --git a/src/controllers/api/instance.ts b/src/controllers/api/instance.ts index b30c753..8ef38a7 100644 --- a/src/controllers/api/instance.ts +++ b/src/controllers/api/instance.ts @@ -53,6 +53,9 @@ const instanceController: AppController = (c) => { nostr: { pubkey: Conf.pubkey, relay: `${wsProtocol}//${host}/relay`, + pow: { + registrations: Conf.pow.registrations, + }, }, rules: [], });