@konemono/nostr-login 1.7.11 → 1.7.13
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/dist/index.esm.js +2 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/unpkg.js +2 -2
- package/package.json +1 -1
- package/src/index.ts +4 -0
- package/src/modules/AuthNostrService.ts +6 -0
- package/src/modules/Nip46.ts +4 -0
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -93,6 +93,10 @@ export class NostrLoginInitializer {
|
|
|
93
93
|
this.bannerManager.onUserInfo(info);
|
|
94
94
|
});
|
|
95
95
|
|
|
96
|
+
this.authNostrService.on('timeout', () => {
|
|
97
|
+
this.bannerManager.onCallTimeout();
|
|
98
|
+
});
|
|
99
|
+
|
|
96
100
|
this.modalManager.on('onAuthUrlClick', url => {
|
|
97
101
|
this.openPopup(url);
|
|
98
102
|
});
|
|
@@ -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 () => {
|
package/src/modules/Nip46.ts
CHANGED
|
@@ -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
|
}
|