@konemono/nostr-login 1.10.4 → 1.10.6

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.4",
3
+ "version": "1.10.6",
4
4
  "description": "",
5
5
  "main": "./dist/index.esm.js",
6
6
  "types": "./dist/index.d.ts",
@@ -9,9 +9,9 @@ import { Signer } from './Nostr';
9
9
  import { Nip44 } from '../utils/nip44';
10
10
  import { IframeNostrRpc, Nip46Signer, ReadyListener } from './Nip46';
11
11
  import { PrivateKeySigner } from './Signer';
12
+ import { DEFAULT_NIP46_RELAYS } from '../const';
12
13
 
13
14
  const OUTBOX_RELAYS = ['wss://user.kindpag.es', 'wss://purplepag.es', 'wss://relay.nos.social'];
14
- const DEFAULT_NOSTRCONNECT_RELAY = 'wss://relay.nsec.app/';
15
15
  const NOSTRCONNECT_APPS: ConnectionString[] = [
16
16
  {
17
17
  name: 'Nsec.app',
@@ -19,19 +19,16 @@ const NOSTRCONNECT_APPS: ConnectionString[] = [
19
19
  canImport: true,
20
20
  img: 'https://nsec.app/assets/favicon.ico',
21
21
  link: 'https://use.nsec.app/<nostrconnect>',
22
- relay: 'wss://relay.nsec.app/',
23
22
  },
24
23
  {
25
24
  name: 'Amber',
26
25
  img: 'https://raw.githubusercontent.com/greenart7c3/Amber/refs/heads/master/assets/android-icon.svg',
27
26
  link: '<nostrconnect>',
28
- relay: 'wss://relay.nsec.app/',
29
27
  },
30
28
  {
31
29
  name: 'Other key stores',
32
30
  img: '',
33
31
  link: '<nostrconnect>',
34
- relay: 'wss://relay.nsec.app/',
35
32
  },
36
33
  ];
37
34
 
@@ -138,7 +135,7 @@ class AuthNostrService extends EventEmitter implements Signer {
138
135
  } = {},
139
136
  ) {
140
137
  // カスタムリレーが指定されていれば使用、そうでなければ単一リレーまたはデフォルト
141
- const relays = customRelays && customRelays.length > 0 ? customRelays : [relay || DEFAULT_NOSTRCONNECT_RELAY];
138
+ const relays = customRelays && customRelays.length > 0 ? customRelays : relay ? [relay] : DEFAULT_NIP46_RELAYS;
142
139
 
143
140
  const info: Info = {
144
141
  authMethod: 'connect',
@@ -171,7 +168,7 @@ class AuthNostrService extends EventEmitter implements Signer {
171
168
  return info;
172
169
  }
173
170
 
174
- public async createNostrConnect(relays?: string[]) {
171
+ public async createNostrConnect() {
175
172
  this.nostrConnectKey = generatePrivateKey();
176
173
  this.nostrConnectSecret = Math.random().toString(36).substring(7);
177
174
 
@@ -183,12 +180,11 @@ class AuthNostrService extends EventEmitter implements Signer {
183
180
  perms: encodeURIComponent(this.params.optionsModal.perms || ''),
184
181
  };
185
182
 
186
- const relayParams = relays && relays.length > 0 ? relays.map(r => `&relay=${encodeURIComponent(r)}`).join('') : '';
187
- 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}`;
188
184
  }
189
185
 
190
186
  public async getNostrConnectServices(customRelays?: string[]): Promise<[string, ConnectionString[]]> {
191
- const nostrconnect = await this.createNostrConnect(customRelays);
187
+ const nostrconnect = await this.createNostrConnect();
192
188
 
193
189
  // copy defaults
194
190
  const apps = NOSTRCONNECT_APPS.map(a => ({ ...a }));
@@ -204,7 +200,7 @@ class AuthNostrService extends EventEmitter implements Signer {
204
200
  // }
205
201
 
206
202
  for (const a of apps) {
207
- let relays = customRelays && customRelays.length > 0 ? customRelays : [DEFAULT_NOSTRCONNECT_RELAY];
203
+ let relays = customRelays && customRelays.length > 0 ? customRelays : DEFAULT_NIP46_RELAYS;
208
204
  if (a.link.startsWith('https://')) {
209
205
  let domain = a.domain || new URL(a.link).hostname;
210
206
  try {
@@ -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 });