Remove unused DittoSignup module

environments/review-ditto-auth-csh1vn/deployments/4454
Alex Gleason 2024-03-16 15:08:48 -05:00
rodzic 5b23166fb7
commit 77f766ff64
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
1 zmienionych plików z 0 dodań i 55 usunięć

Wyświetl plik

@ -1,55 +0,0 @@
import { NRelay, NostrEvent, NostrSigner } from '@soapbox/nspec';
interface DittoSignupRequestOpts {
dvm: string;
url: string;
relay: NRelay;
signer: NostrSigner;
signal?: AbortSignal;
}
export class DittoSignup {
static async request(opts: DittoSignupRequestOpts): Promise<NostrEvent> {
const { dvm, url, relay, signer, signal } = opts;
const pubkey = await signer.getPublicKey();
const event = await signer.signEvent({
kind: 5951,
content: '',
tags: [
['i', url, 'text'],
['p', dvm],
],
created_at: Math.floor(Date.now() / 1000),
});
const subscription = relay.req(
[{ kinds: [7000, 6951], authors: [dvm], '#p': [pubkey], '#e': [event.id] }],
{ signal },
);
await relay.event(event, { signal });
for await (const msg of subscription) {
if (msg[0] === 'EVENT') {
return msg[2];
}
}
throw new Error('DittoSignup: no response');
}
static async check(opts: Omit<DittoSignupRequestOpts, 'url'>): Promise<NostrEvent | undefined> {
const { dvm, relay, signer, signal } = opts;
const pubkey = await signer.getPublicKey();
const [event] = await relay.query(
[{ kinds: [7000, 6951], authors: [dvm], '#p': [pubkey] }],
{ signal },
);
return event;
}
}