@konemono/nostr-login 1.7.20 → 1.7.22
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 +1 -1
- package/src/index.ts +3 -2
- package/src/modules/AuthNostrService.ts +24 -8
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -94,9 +94,10 @@ export class NostrLoginInitializer {
|
|
|
94
94
|
});
|
|
95
95
|
|
|
96
96
|
this.authNostrService.on('timeout', () => {
|
|
97
|
-
console.log('nostr-login: timeout event received
|
|
97
|
+
console.log('nostr-login: timeout event received');
|
|
98
98
|
this.bannerManager.onCallTimeout();
|
|
99
|
-
|
|
99
|
+
// Don't cancel the connection on timeout - user may want to retry
|
|
100
|
+
// this.authNostrService.cancelNostrConnect();
|
|
100
101
|
});
|
|
101
102
|
|
|
102
103
|
this.modalManager.on('onAuthUrlClick', url => {
|
|
@@ -708,17 +708,33 @@ class AuthNostrService extends EventEmitter implements Signer {
|
|
|
708
708
|
}
|
|
709
709
|
|
|
710
710
|
public async signEvent(event: any) {
|
|
711
|
+
console.log('AuthNostrService.signEvent called', {
|
|
712
|
+
hasLocalSigner: !!this.localSigner,
|
|
713
|
+
hasSigner: !!this.signer,
|
|
714
|
+
signerRemotePubkey: this.signer?.remotePubkey,
|
|
715
|
+
eventBefore: JSON.parse(JSON.stringify(event))
|
|
716
|
+
});
|
|
717
|
+
|
|
718
|
+
// Create a copy to avoid mutating the original event on timeout
|
|
719
|
+
const eventToSign = { ...event };
|
|
720
|
+
|
|
711
721
|
if (this.localSigner) {
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
722
|
+
eventToSign.pubkey = getPublicKey(this.localSigner.privateKey!);
|
|
723
|
+
eventToSign.id = getEventHash(eventToSign);
|
|
724
|
+
eventToSign.sig = await this.localSigner.sign(eventToSign);
|
|
715
725
|
} else {
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
726
|
+
if (!this.signer) {
|
|
727
|
+
console.error('No signer available!');
|
|
728
|
+
throw new Error('No signer available');
|
|
729
|
+
}
|
|
730
|
+
eventToSign.pubkey = this.signer.remotePubkey;
|
|
731
|
+
eventToSign.id = getEventHash(eventToSign);
|
|
732
|
+
console.log('Calling signer.sign with event:', eventToSign);
|
|
733
|
+
eventToSign.sig = await this.signer.sign(eventToSign);
|
|
734
|
+
console.log('Received signature:', eventToSign.sig);
|
|
719
735
|
}
|
|
720
|
-
console.log('signed', { event });
|
|
721
|
-
return
|
|
736
|
+
console.log('signed event:', { event: eventToSign });
|
|
737
|
+
return eventToSign;
|
|
722
738
|
}
|
|
723
739
|
|
|
724
740
|
private async codec_call(method: string, pubkey: string, param: string) {
|