@konemono/nostr-login 1.10.10 → 1.10.12
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
package/src/index.ts
CHANGED
|
@@ -703,6 +703,12 @@ class AuthNostrService extends EventEmitter implements Signer {
|
|
|
703
703
|
event.id = getEventHash(event);
|
|
704
704
|
event.sig = await this.localSigner.sign(event);
|
|
705
705
|
} else {
|
|
706
|
+
// リレー接続を確認・再接続
|
|
707
|
+
if (this.ndk.pool.stats().connected === 0) {
|
|
708
|
+
console.log('NDK relays disconnected, reconnecting...');
|
|
709
|
+
await this.ndk.connect();
|
|
710
|
+
}
|
|
711
|
+
|
|
706
712
|
event.pubkey = this.signer?.remotePubkey;
|
|
707
713
|
event.id = getEventHash(event);
|
|
708
714
|
event.sig = await this.signer?.sign(event);
|
|
@@ -4,11 +4,20 @@ import { CALL_TIMEOUT } from '../const';
|
|
|
4
4
|
class ProcessManager extends EventEmitter {
|
|
5
5
|
private callCount: number = 0;
|
|
6
6
|
private callTimer: NodeJS.Timeout | undefined;
|
|
7
|
+
private pendingCalls: Map<number, { reject: (reason?: any) => void }> = new Map();
|
|
8
|
+
private callIdCounter: number = 0;
|
|
7
9
|
|
|
8
10
|
constructor() {
|
|
9
11
|
super();
|
|
10
12
|
}
|
|
11
13
|
|
|
14
|
+
public cancelAllPendingCalls() {
|
|
15
|
+
for (const [id, { reject }] of this.pendingCalls.entries()) {
|
|
16
|
+
reject(new Error('Cancelled by user'));
|
|
17
|
+
}
|
|
18
|
+
this.pendingCalls.clear();
|
|
19
|
+
}
|
|
20
|
+
|
|
12
21
|
public onAuthUrl() {
|
|
13
22
|
if (Boolean(this.callTimer)) {
|
|
14
23
|
clearTimeout(this.callTimer);
|
|
@@ -34,11 +43,22 @@ class ProcessManager extends EventEmitter {
|
|
|
34
43
|
|
|
35
44
|
this.callCount++;
|
|
36
45
|
|
|
46
|
+
const callId = this.callIdCounter++;
|
|
37
47
|
let error;
|
|
38
48
|
let result;
|
|
39
49
|
|
|
40
50
|
try {
|
|
41
|
-
result = await
|
|
51
|
+
result = await new Promise<T>(async (resolve, reject) => {
|
|
52
|
+
this.pendingCalls.set(callId, { reject });
|
|
53
|
+
try {
|
|
54
|
+
const res = await cb();
|
|
55
|
+
this.pendingCalls.delete(callId);
|
|
56
|
+
resolve(res);
|
|
57
|
+
} catch (e) {
|
|
58
|
+
this.pendingCalls.delete(callId);
|
|
59
|
+
reject(e);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
42
62
|
} catch (e) {
|
|
43
63
|
error = e;
|
|
44
64
|
}
|