@konemono/nostr-login 1.13.0 → 1.13.2

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.13.0",
3
+ "version": "1.13.2",
4
4
  "description": "Extended fork of nostr-login with multi-relay support, QR scanner, and improved stability",
5
5
  "main": "./dist/index.esm.js",
6
6
  "types": "./dist/index.d.ts",
@@ -30,7 +30,7 @@
30
30
  "@rollup/plugin-commonjs": "^25.0.7",
31
31
  "@rollup/plugin-node-resolve": "^15.2.3",
32
32
  "@rollup/plugin-terser": "^0.4.4",
33
- "@konemono/nostr-login-components": "^1.2.0",
33
+ "@konemono/nostr-login-components": "^1.2.2",
34
34
  "prettier": "^3.2.2",
35
35
  "rollup": "^4.9.6",
36
36
  "rollup-plugin-typescript2": "^0.36.0"
@@ -676,8 +676,8 @@ class AuthNostrService extends EventEmitter implements Signer {
676
676
  await this.signer!.initUserPubkey(info.pubkey);
677
677
  }
678
678
 
679
- info.pubkey = this.signer!.userPubkey;
680
- info.signerPubkey = this.signer!.remotePubkey;
679
+ info.pubkey = this.signer!.userPubkey as string;
680
+ info.signerPubkey = this.signer!.bunkerPubkey;
681
681
 
682
682
  console.log('Signer initialized successfully. User pubkey:', info.pubkey, 'Signer pubkey:', info.signerPubkey);
683
683
 
@@ -756,7 +756,7 @@ class AuthNostrService extends EventEmitter implements Signer {
756
756
  throw new Error('Signer is not initialized. Please reconnect.');
757
757
  }
758
758
  await this.ensureRelayConnection();
759
- event.pubkey = this.signer.remotePubkey;
759
+ event.pubkey = this.signer.bunkerPubkey;
760
760
  event.id = getEventHash(event);
761
761
  event.sig = await this.signer?.sign(event);
762
762
  console.log('signed', { event, attempt });
@@ -903,7 +903,7 @@ class AuthNostrService extends EventEmitter implements Signer {
903
903
 
904
904
  private async codec_call(method: string, pubkey: string, param: string) {
905
905
  return new Promise<string>((resolve, reject) => {
906
- this.signer!.rpc.sendRequest(this.signer!.remotePubkey!, method, [pubkey, param], 24133, (response: NDKRpcResponse) => {
906
+ this.signer!.rpc.sendRequest(this.signer!.bunkerPubkey!, method, [pubkey, param], 24133, (response: NDKRpcResponse) => {
907
907
  if (!response.error) {
908
908
  resolve(response.result);
909
909
  } else {
@@ -445,11 +445,13 @@ export class ReadyListener {
445
445
  }
446
446
 
447
447
  export class Nip46Signer extends NDKNip46Signer {
448
- private _userPubkey: string = '';
449
448
  private _rpc: IframeNostrRpc;
450
449
 
451
450
  constructor(ndk: NDK, localSigner: PrivateKeySigner, signerPubkey: string, iframeOrigin?: string) {
452
- super(ndk, signerPubkey, localSigner);
451
+ // Pass `false` to skip NDK's built-in init (nip05Init/bunkerFlowInit/nostrconnectFlowInit)
452
+ // because we manage bunkerPubkey and RPC ourselves.
453
+ super(ndk, false as any, localSigner);
454
+ this.bunkerPubkey = signerPubkey;
453
455
 
454
456
  this._rpc = new IframeNostrRpc(ndk, localSigner, iframeOrigin);
455
457
  this._rpc.setUseNip44(true);
@@ -460,14 +462,10 @@ export class Nip46Signer extends NDKNip46Signer {
460
462
  this.rpc = this._rpc;
461
463
  }
462
464
 
463
- get userPubkey() {
464
- return this._userPubkey;
465
- }
466
-
467
465
  private async setSignerPubkey(signerPubkey: string, sameAsUser: boolean = false) {
468
466
  console.log('setSignerPubkey', signerPubkey);
469
467
 
470
- this.remotePubkey = signerPubkey;
468
+ this.bunkerPubkey = signerPubkey;
471
469
 
472
470
  this._rpc.on(`iframeRestart-${signerPubkey}`, () => {
473
471
  this.emit('iframeRestart');
@@ -477,28 +475,28 @@ export class Nip46Signer extends NDKNip46Signer {
477
475
  }
478
476
 
479
477
  public async initUserPubkey(hintPubkey?: string) {
480
- if (this._userPubkey) {
481
- console.warn('initUserPubkey already called, pubkey:', this._userPubkey);
478
+ if (this.userPubkey) {
479
+ console.warn('initUserPubkey already called, pubkey:', this.userPubkey);
482
480
  return;
483
481
  }
484
482
 
485
483
  if (hintPubkey) {
486
- this._userPubkey = hintPubkey;
487
- console.log('User pubkey set from hint:', this._userPubkey);
484
+ this.userPubkey = hintPubkey;
485
+ console.log('User pubkey set from hint:', this.userPubkey);
488
486
  return;
489
487
  }
490
488
 
491
- console.log('Requesting user pubkey from signer:', this.remotePubkey);
489
+ console.log('Requesting user pubkey from signer:', this.bunkerPubkey);
492
490
 
493
- this._userPubkey = await new Promise<string>((ok, err) => {
494
- if (!this.remotePubkey) throw new Error('Signer pubkey not set');
491
+ this.userPubkey = await new Promise<string>((ok, err) => {
492
+ if (!this.bunkerPubkey) throw new Error('Signer pubkey not set');
495
493
 
496
494
  const timeout = setTimeout(() => {
497
495
  err(new Error('Timeout getting user pubkey'));
498
496
  }, 30000);
499
497
 
500
- console.log('get_public_key', this.remotePubkey);
501
- this._rpc.sendRequest(this.remotePubkey, 'get_public_key', [], 24133, (response: NDKRpcResponse) => {
498
+ console.log('get_public_key', this.bunkerPubkey);
499
+ this._rpc.sendRequest(this.bunkerPubkey, 'get_public_key', [], 24133, (response: NDKRpcResponse) => {
502
500
  clearTimeout(timeout);
503
501
 
504
502
  if (response.error) {
@@ -517,9 +515,9 @@ export class Nip46Signer extends NDKNip46Signer {
517
515
  }
518
516
 
519
517
  public async connect(token?: string, perms?: string) {
520
- if (!this.remotePubkey) throw new Error('No signer pubkey');
521
- await this._rpc.connect(this.remotePubkey, token, perms);
522
- await this.setSignerPubkey(this.remotePubkey);
518
+ if (!this.bunkerPubkey) throw new Error('No signer pubkey');
519
+ await this._rpc.connect(this.bunkerPubkey, token, perms);
520
+ await this.setSignerPubkey(this.bunkerPubkey);
523
521
  }
524
522
 
525
523
  public async setListenReply(reply: any, nostrConnectSecret: string) {
@@ -4,15 +4,15 @@ import { getPublicKey } from 'nostr-tools';
4
4
 
5
5
  export class PrivateKeySigner extends NDKPrivateKeySigner {
6
6
  private nip44: Nip44 = new Nip44();
7
- private _pubkey: string;
7
+ private _derivedPubkey: string;
8
8
 
9
9
  constructor(privateKey: string) {
10
10
  super(privateKey);
11
- this._pubkey = getPublicKey(privateKey);
11
+ this._derivedPubkey = getPublicKey(privateKey);
12
12
  }
13
13
 
14
- get pubkey() {
15
- return this._pubkey;
14
+ override get pubkey() {
15
+ return this._derivedPubkey;
16
16
  }
17
17
 
18
18
  encryptNip44(recipient: NDKUser, value: string): Promise<string> {