Merge branch 'rm-x-nostr-sign' into 'main'
Remove X-Nostr-Sign header support See merge request soapbox-pub/ditto!132
This commit is contained in:
commit
8801debb1a
|
@ -12,7 +12,7 @@ import { createAdminEvent } from '@/utils/api.ts';
|
|||
* Sign Nostr event using the app context.
|
||||
*
|
||||
* - 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 {
|
||||
#c: AppContext;
|
||||
|
@ -34,23 +34,16 @@ export class APISigner implements NostrSigner {
|
|||
|
||||
async signEvent(event: Omit<NostrEvent, 'id' | 'pubkey' | 'sig'>): Promise<NostrEvent> {
|
||||
const seckey = this.#c.get('seckey');
|
||||
const header = this.#c.req.header('x-nostr-sign');
|
||||
|
||||
if (seckey) {
|
||||
this.#console.debug(`Signing Event<${event.kind}> with secret key`);
|
||||
return new NSecSigner(seckey).signEvent(event);
|
||||
}
|
||||
|
||||
if (header) {
|
||||
this.#console.debug(`Signing Event<${event.kind}> with NIP-46`);
|
||||
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. */
|
||||
async #signNostrConnect(event: Omit<NostrEvent, 'id' | 'pubkey' | 'sig'>): Promise<NostrEvent> {
|
||||
const pubkey = this.#c.get('pubkey');
|
||||
|
|
Loading…
Reference in New Issue