diff --git a/abstract-relay.ts b/abstract-relay.ts index 454feee..631bfdb 100644 --- a/abstract-relay.ts +++ b/abstract-relay.ts @@ -252,16 +252,20 @@ export class AbstractRelay { if (this.authPromise) return this.authPromise this.authPromise = new Promise(async (resolve, reject) => { - const evt = await signAuthEvent(makeAuthEvent(this.url, challenge)) - const timeout = setTimeout(() => { - const ep = this.openEventPublishes.get(evt.id) as EventPublishResolver - if (ep) { - ep.reject(new Error('auth timed out')) - this.openEventPublishes.delete(evt.id) - } - }, this.publishTimeout) - this.openEventPublishes.set(evt.id, { resolve, reject, timeout }) - this.send('["AUTH",' + JSON.stringify(evt) + ']') + try { + let evt = await signAuthEvent(makeAuthEvent(this.url, challenge)) + let timeout = setTimeout(() => { + let ep = this.openEventPublishes.get(evt.id) as EventPublishResolver + if (ep) { + ep.reject(new Error('auth timed out')) + this.openEventPublishes.delete(evt.id) + } + }, this.publishTimeout) + this.openEventPublishes.set(evt.id, { resolve, reject, timeout }) + this.send('["AUTH",' + JSON.stringify(evt) + ']') + } catch (err) { + console.warn('subscribe auth function failed:', err) + } }) return this.authPromise } diff --git a/jsr.json b/jsr.json index 63e76d4..e4b7307 100644 --- a/jsr.json +++ b/jsr.json @@ -1,6 +1,6 @@ { "name": "@nostr/tools", - "version": "2.14.3", + "version": "2.15.0", "exports": { ".": "./index.ts", "./core": "./core.ts", diff --git a/package.json b/package.json index 890dd85..7ff8f86 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "type": "module", "name": "nostr-tools", - "version": "2.14.3", + "version": "2.15.0", "description": "Tools for making a Nostr client.", "repository": { "type": "git",