@konemono/nostr-login 1.9.13 → 1.10.0

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.
@@ -15,6 +15,7 @@ class ModalManager extends EventEmitter {
15
15
  private accounts: Info[] = [];
16
16
  private recents: RecentType[] = [];
17
17
  private opt?: NostrLoginOptions;
18
+ private customNip46Relays: string[] = ['wss://relay.nsec.app/', 'wss://ephemeral.snowflare.cc/'];
18
19
 
19
20
  constructor(params: NostrParams, authNostrService: AuthNostrService, extensionManager: NostrExtensionService) {
20
21
  super();
@@ -27,7 +28,7 @@ class ModalManager extends EventEmitter {
27
28
  if (this.launcherPromise) {
28
29
  try {
29
30
  await this.launcherPromise;
30
- } catch { }
31
+ } catch {}
31
32
  this.launcherPromise = undefined;
32
33
  }
33
34
  }
@@ -141,7 +142,7 @@ class ModalManager extends EventEmitter {
141
142
  }
142
143
 
143
144
  try {
144
- if (!options || options.start) this.authNostrService.startAuth();
145
+ if (!options || options.start) await this.authNostrService.startAuth();
145
146
  await body();
146
147
  if (!options || options.end) await done(ok);
147
148
  } catch (e: any) {
@@ -161,7 +162,7 @@ class ModalManager extends EventEmitter {
161
162
  const bunkerUrl = await getBunkerUrl(name, this.params.optionsModal);
162
163
 
163
164
  // connect to bunker by url
164
- await this.authNostrService.authNip46('login', { name, bunkerUrl, domain });
165
+ await this.authNostrService.authNip46('login', { name, bunkerUrl, domain, customRelays: this.customNip46Relays });
165
166
  });
166
167
  };
167
168
 
@@ -203,8 +204,8 @@ class ModalManager extends EventEmitter {
203
204
 
204
205
  const nostrConnect = async (cs?: ConnectionString) => {
205
206
  await exec(async () => {
206
- const { relays, domain, link, iframeUrl } = cs || {};
207
- console.log('nostrConnect', cs, relays, domain, link, iframeUrl);
207
+ const { relay, domain, link, iframeUrl } = cs || {};
208
+ console.log('nostrConnect', cs, relay, domain, link, iframeUrl);
208
209
 
209
210
  if (this.modal) {
210
211
  if (iframeUrl) {
@@ -218,7 +219,7 @@ class ModalManager extends EventEmitter {
218
219
  if (!cs) this.modal.isLoading = false;
219
220
  }
220
221
 
221
- await this.authNostrService.nostrConnect(relays, { domain, link, iframeUrl });
222
+ await this.authNostrService.nostrConnect(relay, { domain, link, iframeUrl });
222
223
  });
223
224
  };
224
225
 
@@ -330,6 +331,11 @@ class ModalManager extends EventEmitter {
330
331
  login(event.detail);
331
332
  });
332
333
 
334
+ this.modal.addEventListener('nlRelaysChanged', (event: any) => {
335
+ this.customNip46Relays = event.detail;
336
+ console.log('Custom Nip46 relays updated:', this.customNip46Relays);
337
+ });
338
+
333
339
  this.modal.addEventListener('nlSignup', (event: any) => {
334
340
  signup(event.detail);
335
341
  });
@@ -402,9 +408,6 @@ class ModalManager extends EventEmitter {
402
408
  } else if (userInfo.authMethod === 'extension') {
403
409
  await this.extensionService.trySetExtensionForPubkey(userInfo.pubkey);
404
410
  dialog.close();
405
- } else if (userInfo.authMethod === ('amber' as any)) {
406
- this.authNostrService.setAmber(userInfo);
407
- dialog.close();
408
411
  } else {
409
412
  const input = userInfo.bunkerUrl || userInfo.nip05;
410
413
  if (!input) throw new Error('Bad connect info');
@@ -532,7 +535,8 @@ class ModalManager extends EventEmitter {
532
535
  this.modal.isLoading = false;
533
536
  }
534
537
 
535
- // this.authNostrService.cancelListenNostrConnect();
538
+ // キャンセル処理を呼び出す
539
+ this.authNostrService.cancelSignerInit();
536
540
 
537
541
  dialog.close();
538
542
  err(new Error('Cancelled'));