Remove X-Nostr-Sign header support

This commit is contained in:
Alex Gleason 2024-04-05 17:39:33 -05:00
parent 4b2b658685
commit 55ba4a3a9b
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 3 additions and 10 deletions

View File

@ -12,7 +12,7 @@ import { createAdminEvent } from '@/utils/api.ts';
* Sign Nostr event using the app context. * Sign Nostr event using the app context.
* *
* - If a secret key is provided, it will be used to sign the event. * - If a secret key is provided, it will be used to sign the event.
* - If `X-Nostr-Sign` is passed, it will use NIP-46 to sign the event. * - Otherwise, it will use NIP-46 to sign the event.
*/ */
export class APISigner implements NostrSigner { export class APISigner implements NostrSigner {
#c: AppContext; #c: AppContext;
@ -34,21 +34,14 @@ export class APISigner implements NostrSigner {
async signEvent(event: Omit<NostrEvent, 'id' | 'pubkey' | 'sig'>): Promise<NostrEvent> { async signEvent(event: Omit<NostrEvent, 'id' | 'pubkey' | 'sig'>): Promise<NostrEvent> {
const seckey = this.#c.get('seckey'); const seckey = this.#c.get('seckey');
const header = this.#c.req.header('x-nostr-sign');
if (seckey) { if (seckey) {
this.#console.debug(`Signing Event<${event.kind}> with secret key`); this.#console.debug(`Signing Event<${event.kind}> with secret key`);
return new NSecSigner(seckey).signEvent(event); return new NSecSigner(seckey).signEvent(event);
} }
if (header) { this.#console.debug(`Signing Event<${event.kind}> with NIP-46`);
this.#console.debug(`Signing Event<${event.kind}> with NIP-46`); return await this.#signNostrConnect(event);
return await this.#signNostrConnect(event);
}
throw new HTTPException(400, {
res: this.#c.json({ id: 'ditto.sign', error: 'Unable to sign event' }, 400),
});
} }
/** Sign event with NIP-46, waiting in the background for the signed event. */ /** Sign event with NIP-46, waiting in the background for the signed event. */