@konemono/nostr-login 1.10.5 → 1.10.7

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.10.5",
3
+ "version": "1.10.7",
4
4
  "description": "",
5
5
  "main": "./dist/index.esm.js",
6
6
  "types": "./dist/index.d.ts",
@@ -168,7 +168,7 @@ class AuthNostrService extends EventEmitter implements Signer {
168
168
  return info;
169
169
  }
170
170
 
171
- public async createNostrConnect(relays?: string[]) {
171
+ public async createNostrConnect() {
172
172
  this.nostrConnectKey = generatePrivateKey();
173
173
  this.nostrConnectSecret = Math.random().toString(36).substring(7);
174
174
 
@@ -180,12 +180,11 @@ class AuthNostrService extends EventEmitter implements Signer {
180
180
  perms: encodeURIComponent(this.params.optionsModal.perms || ''),
181
181
  };
182
182
 
183
- const relayParams = relays && relays.length > 0 ? relays.map(r => `&relay=${encodeURIComponent(r)}`).join('') : '';
184
- return `nostrconnect://${pubkey}?image=${meta.icon}&url=${meta.url}&name=${meta.name}&perms=${meta.perms}&secret=${this.nostrConnectSecret}${relayParams}`;
183
+ return `nostrconnect://${pubkey}?image=${meta.icon}&url=${meta.url}&name=${meta.name}&perms=${meta.perms}&secret=${this.nostrConnectSecret}`;
185
184
  }
186
185
 
187
186
  public async getNostrConnectServices(customRelays?: string[]): Promise<[string, ConnectionString[]]> {
188
- const nostrconnect = await this.createNostrConnect(customRelays);
187
+ const nostrconnect = await this.createNostrConnect();
189
188
 
190
189
  // copy defaults
191
190
  const apps = NOSTRCONNECT_APPS.map(a => ({ ...a }));
@@ -194,7 +194,7 @@ class ModalManager extends EventEmitter {
194
194
  // we pass the link down to iframe so it could open it
195
195
  this.modal.authUrl = cs.link;
196
196
  this.modal.iframeUrl = iframeUrl;
197
- this.modal.isLoading = false;
197
+ // Don't set isLoading = false here, let exec handle it
198
198
  console.log('nostrconnect authUrl', this.modal.authUrl, this.modal.iframeUrl);
199
199
  }
200
200
 
@@ -207,16 +207,12 @@ class ModalManager extends EventEmitter {
207
207
  const { relay, domain, link, iframeUrl } = cs || {};
208
208
  console.log('nostrConnect', cs, relay, domain, link, iframeUrl);
209
209
 
210
- if (this.modal) {
211
- if (iframeUrl) {
212
- // we pass the link down to iframe so it could open it
213
- this.modal.authUrl = link;
214
- this.modal.iframeUrl = iframeUrl;
215
- this.modal.isLoading = false;
216
- console.log('nostrconnect authUrl', this.modal.authUrl, this.modal.iframeUrl);
217
- }
218
-
219
- if (!cs) this.modal.isLoading = false;
210
+ if (this.modal && iframeUrl) {
211
+ // we pass the link down to iframe so it could open it
212
+ this.modal.authUrl = link;
213
+ this.modal.iframeUrl = iframeUrl;
214
+ // Don't set isLoading = false here, let exec handle it
215
+ console.log('nostrconnect authUrl', this.modal.authUrl, this.modal.iframeUrl);
220
216
  }
221
217
 
222
218
  await this.authNostrService.nostrConnect(relay, { domain, link, iframeUrl, customRelays: this.customNip46Relays });
@@ -331,9 +327,13 @@ class ModalManager extends EventEmitter {
331
327
  login(event.detail);
332
328
  });
333
329
 
334
- this.modal.addEventListener('nlRelaysChanged', (event: any) => {
330
+ this.modal.addEventListener('nlRelaysChanged', async (event: any) => {
335
331
  this.customNip46Relays = event.detail;
336
332
  console.log('Custom Nip46 relays updated:', this.customNip46Relays);
333
+ // Regenerate connection services with new relays
334
+ if (this.modal) {
335
+ [this.modal.connectionString, this.modal.connectionStringServices] = await this.authNostrService.getNostrConnectServices(this.customNip46Relays);
336
+ }
337
337
  });
338
338
 
339
339
  this.modal.addEventListener('nlSignup', (event: any) => {