@konemono/nostr-login 1.7.12 → 1.7.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@konemono/nostr-login",
3
- "version": "1.7.12",
3
+ "version": "1.7.14",
4
4
  "description": "",
5
5
  "main": "./dist/index.esm.js",
6
6
  "types": "./dist/index.d.ts",
package/src/index.ts CHANGED
@@ -93,6 +93,11 @@ export class NostrLoginInitializer {
93
93
  this.bannerManager.onUserInfo(info);
94
94
  });
95
95
 
96
+ this.authNostrService.on('timeout', () => {
97
+ this.bannerManager.onCallTimeout();
98
+ this.authNostrService.cancelNostrConnect();
99
+ });
100
+
96
101
  this.modalManager.on('onAuthUrlClick', url => {
97
102
  this.openPopup(url);
98
103
  });
@@ -584,6 +584,7 @@ class AuthNostrService extends EventEmitter implements Signer {
584
584
  setTimeout(() => {
585
585
  if (!finished) {
586
586
  finished = true
587
+ this.emit('timeout');
587
588
  reject('Connection timed out')
588
589
  }
589
590
  }, 10000)
@@ -605,6 +606,11 @@ class AuthNostrService extends EventEmitter implements Signer {
605
606
  const localSigner = new PrivateKeySigner(info.sk!);
606
607
  this.signer = new Nip46Signer(this.ndk, localSigner, info.signerPubkey!, iframeOrigin);
607
608
 
609
+ // forward timeout events
610
+ this.signer.on('timeout', () => {
611
+ this.emit('timeout');
612
+ });
613
+
608
614
  // we should notify the banner the same way as
609
615
  // the onAuthUrl does
610
616
  this.signer.on(`iframeRestart`, async () => {
@@ -177,6 +177,7 @@ class NostrRpc extends NDKNostrRpc {
177
177
  if (this.requests.has(id)) {
178
178
  this.requests.delete(id);
179
179
  this.removeListener(`response-${id}`, responseHandler);
180
+ this.emit('timeout');
180
181
  reject('Request timed out');
181
182
  }
182
183
  }, 30000);
@@ -362,6 +363,9 @@ export class Nip46Signer extends NDKNip46Signer {
362
363
  this._rpc.on('authUrl', (url: string) => {
363
364
  this.emit('authUrl', url);
364
365
  });
366
+ this._rpc.on('timeout', () => {
367
+ this.emit('timeout');
368
+ });
365
369
 
366
370
  this.rpc = this._rpc;
367
371
  }