@konemono/nostr-login 1.7.16 → 1.7.18
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/modules/Nip46.d.ts +2 -0
- package/dist/unpkg.js +2 -2
- package/package.json +1 -1
- package/src/modules/BannerManager.ts +4 -0
- package/src/modules/Nip46.ts +1 -1
- package/src/modules/ProcessManager.ts +19 -6
- package/src/utils/index.ts +1 -1
package/package.json
CHANGED
|
@@ -47,11 +47,15 @@ class BannerManager extends EventEmitter {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
public onCallTimeout() {
|
|
50
|
+
console.log('BannerManager.onCallTimeout called, banner:', this.banner);
|
|
50
51
|
if (this.banner) {
|
|
52
|
+
console.log('Setting banner isLoading=false and notify=timeout');
|
|
51
53
|
this.banner.isLoading = false;
|
|
52
54
|
this.banner.notify = {
|
|
53
55
|
mode: 'timeout',
|
|
54
56
|
};
|
|
57
|
+
} else {
|
|
58
|
+
console.log('Banner is null, cannot set timeout notification');
|
|
55
59
|
}
|
|
56
60
|
}
|
|
57
61
|
|
package/src/modules/Nip46.ts
CHANGED
|
@@ -199,7 +199,7 @@ class NostrRpc extends NDKNostrRpc {
|
|
|
199
199
|
this.removeListener(`response-${id}`, responseHandler);
|
|
200
200
|
console.log('nostr-login: NIP-46 request timeout, emitting timeout event');
|
|
201
201
|
this.emit('timeout');
|
|
202
|
-
reject('Request timed out');
|
|
202
|
+
reject('[Nip46] Request timed out');
|
|
203
203
|
}
|
|
204
204
|
}, 30000);
|
|
205
205
|
});
|
|
@@ -23,19 +23,29 @@ class ProcessManager extends EventEmitter {
|
|
|
23
23
|
|
|
24
24
|
public async wait<T>(cb: () => Promise<T>): Promise<T> {
|
|
25
25
|
// FIXME only allow 1 parallel req
|
|
26
|
+
console.log('ProcessManager.wait called, callTimer exists:', !!this.callTimer, 'callCount:', this.callCount);
|
|
26
27
|
|
|
27
28
|
let timeoutReject: ((reason?: any) => void) | undefined;
|
|
29
|
+
let isTimedOut = false;
|
|
30
|
+
let localTimer: NodeJS.Timeout | undefined;
|
|
31
|
+
|
|
28
32
|
const timeoutPromise = new Promise<T>((_, reject) => {
|
|
29
33
|
timeoutReject = reject;
|
|
30
34
|
});
|
|
31
35
|
|
|
32
36
|
if (!this.callTimer) {
|
|
33
|
-
|
|
37
|
+
console.log('Setting up timeout timer for', CALL_TIMEOUT, 'ms');
|
|
38
|
+
localTimer = setTimeout(() => {
|
|
39
|
+
console.log('ProcessManager: timeout reached, emitting onCallTimeout');
|
|
40
|
+
isTimedOut = true;
|
|
34
41
|
this.emit('onCallTimeout');
|
|
35
42
|
if (timeoutReject) {
|
|
36
|
-
timeoutReject(new Error('Request timed out'));
|
|
43
|
+
timeoutReject(new Error('[ProcessManager] Request timed out'));
|
|
37
44
|
}
|
|
38
45
|
}, CALL_TIMEOUT);
|
|
46
|
+
this.callTimer = localTimer;
|
|
47
|
+
} else {
|
|
48
|
+
console.log('Timer already exists, not setting up new one');
|
|
39
49
|
}
|
|
40
50
|
|
|
41
51
|
if (!this.callCount) {
|
|
@@ -55,14 +65,17 @@ class ProcessManager extends EventEmitter {
|
|
|
55
65
|
|
|
56
66
|
this.callCount--;
|
|
57
67
|
|
|
58
|
-
|
|
68
|
+
// Only emit onCallEnd if not timed out (timeout already handled cleanup)
|
|
69
|
+
if (!isTimedOut) {
|
|
70
|
+
this.emit('onCallEnd');
|
|
71
|
+
}
|
|
59
72
|
|
|
60
|
-
if
|
|
73
|
+
// Clear the timer if it's the one we created
|
|
74
|
+
if (this.callTimer === localTimer) {
|
|
61
75
|
clearTimeout(this.callTimer);
|
|
76
|
+
this.callTimer = undefined;
|
|
62
77
|
}
|
|
63
78
|
|
|
64
|
-
this.callTimer = undefined;
|
|
65
|
-
|
|
66
79
|
if (error) {
|
|
67
80
|
throw error;
|
|
68
81
|
}
|
package/src/utils/index.ts
CHANGED
|
@@ -139,7 +139,7 @@ export const getBunkerUrl = async (value: string, optionsModal: NostrLoginOption
|
|
|
139
139
|
return `bunker://${userPubkey}?relay=${bunkerRelays[0]}`;
|
|
140
140
|
} catch (e: any) {
|
|
141
141
|
if (e.name === 'AbortError') {
|
|
142
|
-
throw new Error('Request timed out');
|
|
142
|
+
throw new Error('[getBunkerUrl] Request timed out');
|
|
143
143
|
}
|
|
144
144
|
throw e;
|
|
145
145
|
} finally {
|