WIP Add Nostr auth

This commit is contained in:
2026-04-18 18:36:09 +04:00
parent 2268a607d5
commit f875fc1877
6 changed files with 1110 additions and 3 deletions

View File

@@ -0,0 +1,25 @@
import Service from '@ember/service';
import { RelayPool } from 'applesauce-relay';
export default class NostrRelayService extends Service {
pool = new RelayPool();
// For Phase 1, we hardcode the local relay
relays = ['ws://127.0.0.1:7777'];
async publish(event) {
// The publish method is a wrapper around the event method that returns a Promise<PublishResponse[]>
// and automatically handles reconnecting and retrying.
const responses = await this.pool.publish(this.relays, event);
// Check if at least one relay accepted the event
const success = responses.some((res) => res.ok);
if (!success) {
throw new Error(
`Failed to publish event. Responses: ${JSON.stringify(responses)}`
);
}
return responses;
}
}