diff --git a/src/daemon/run.ts b/src/daemon/run.ts index ca7a90f..eab1a0a 100644 --- a/src/daemon/run.ts +++ b/src/daemon/run.ts @@ -1,4 +1,4 @@ -import NDK, { NDKEvent, NDKNip46Backend, NDKPrivateKeySigner, Nip46PermitCallback, Nip46PermitCallbackParams, NostrEvent } from '@nostr-dev-kit/ndk'; +import NDK, { NDKPrivateKeySigner, Nip46PermitCallback, Nip46PermitCallbackParams } from '@nostr-dev-kit/ndk'; import { nip19 } from 'nostr-tools'; import { Backend } from './backend/index.js'; import { @@ -174,8 +174,6 @@ class Daemon { async startWebAuth() { if (!this.config.authPort) return; - const path = new URL(this.config.baseUrl as string).pathname.replace(/\/+$/, ''); - this.fastify.register(FastifyView, { engine: { handlebars: Handlebars @@ -184,9 +182,9 @@ class Daemon { this.fastify.listen({ port: this.config.authPort }); - this.fastify.get(`${path}/requests/:id`, authorizeRequestWebHandler); - this.fastify.post(`${path}/requests/:id`, processRequestWebHandler); - this.fastify.post(`${path}/register/:id`, processRegistrationWebHandler); + this.fastify.get('/requests/:id', authorizeRequestWebHandler); + this.fastify.post('/requests/:id', processRequestWebHandler); + this.fastify.post('/register/:id', processRegistrationWebHandler); } async startKeys() { @@ -204,7 +202,7 @@ class Daemon { } const nsec = nip19.nsecEncode(settings.key); - await this.loadNsec(keyName, nsec); + this.loadNsec(keyName, nsec); } } diff --git a/src/daemon/web/authorize.ts b/src/daemon/web/authorize.ts index 868e347..8ad7551 100644 --- a/src/daemon/web/authorize.ts +++ b/src/daemon/web/authorize.ts @@ -49,7 +49,7 @@ export async function authorizeRequestWebHandler(request, reply) { const record = await getAndValidateStateOfRequest(request); const url = new URL(request.url, `http://${request.headers.host}`); const callbackUrl = url.searchParams.get("callbackUrl"); - const baseUrl = new URL(request.url).pathname?.split('/')?.[1]?.replace(/\/+$/, '') || '/'; + const baseUrl = new URL(request.url).pathname?.split('/')?.[1]?.replace(/\/+$/, ''); const method = record.method; let nip05: string | undefined; @@ -164,7 +164,7 @@ export async function processRegistrationWebHandler(request, reply) { try { const record = await getAndValidateStateOfRequest(request); const body = request.body; - const baseUrl = new URL(request.url).pathname?.split('/')?.[1]?.replace(/\/+$/, '') || '/'; + const baseUrl = new URL(request.url).pathname?.split('/')?.[1]?.replace(/\/+$/, ''); // we serialize the payload again and store it // along with the allowed flag