@konemono/nostr-login 1.7.38 → 1.7.39

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.7.38",
3
+ "version": "1.7.39",
4
4
  "description": "",
5
5
  "main": "./dist/index.esm.js",
6
6
  "types": "./dist/index.d.ts",
@@ -1,3 +1,4 @@
1
+ //AuthNostrService.ts
1
2
  import { localStorageAddAccount, bunkerUrlToInfo, isBunkerUrl, fetchProfile, getBunkerUrl, localStorageRemoveCurrentAccount, createProfile, getIcon } from '../utils';
2
3
  import { ConnectionString, Info } from 'nostr-login-components/dist/types/types';
3
4
  import { generatePrivateKey, getEventHash, getPublicKey, nip19 } from 'nostr-tools';
@@ -153,13 +154,6 @@ class AuthNostrService extends EventEmitter implements Signer {
153
154
  }
154
155
 
155
156
  public async createNostrConnect(relays?: string[]) {
156
- /*const relayList = relays
157
- ? relays
158
- .split(",")
159
- .map(r => r.trim().replace(/['"]/g, ""))
160
- .filter(r => r.length > 0)
161
- : [];*/
162
-
163
157
  this.nostrConnectKey = generatePrivateKey();
164
158
  this.nostrConnectSecret = Math.random().toString(36).substring(7);
165
159
 
@@ -175,20 +169,9 @@ class AuthNostrService extends EventEmitter implements Signer {
175
169
  }
176
170
 
177
171
  public async getNostrConnectServices(): Promise<[string, ConnectionString[]]> {
178
- const nostrconnect = await this.createNostrConnect();
172
+ const nostrconnect = await this.createNostrConnect(DEFAULT_NOSTRCONNECT_RELAYS);
179
173
 
180
- // copy defaults
181
174
  const apps = NOSTRCONNECT_APPS.map(a => ({ ...a }));
182
- // if (this.params.optionsModal.dev) {
183
- // apps.push({
184
- // name: 'Dev.Nsec.app',
185
- // domain: 'new.nsec.app',
186
- // canImport: true,
187
- // img: 'https://new.nsec.app/assets/favicon.ico',
188
- // link: 'https://dev.nsec.app/<nostrconnect>',
189
- // relay: 'wss://relay.nsec.app/',
190
- // });
191
- // }
192
175
 
193
176
  for (const a of apps) {
194
177
  let relays: string[] = [...DEFAULT_NOSTRCONNECT_RELAYS];
@@ -210,18 +193,12 @@ class AuthNostrService extends EventEmitter implements Signer {
210
193
  }
211
194
  }
212
195
 
213
- const relayParams = relays
214
- .map(r => r.replace(/['"]/g, ''))
215
- .map(r => `&relay=${encodeURIComponent(r)}`)
216
- .join('');
217
-
218
- const nc = nostrconnect + relayParams;
196
+ // nostrconnectから既存のリレーを削除して新しいリレーを追加
197
+ const baseUrl = nostrconnect.split('&relay=')[0];
198
+ const relayParams = relays.map(r => `&relay=${encodeURIComponent(r)}`).join('');
199
+ const nc = baseUrl + relayParams;
219
200
 
220
- if (a.iframeUrl) {
221
- a.link = nc;
222
- } else {
223
- a.link = a.link.replace('<nostrconnect>', nc);
224
- }
201
+ a.link = a.iframeUrl ? nc : a.link.replace('<nostrconnect>', nc);
225
202
  }
226
203
 
227
204
  return [nostrconnect, apps];
@@ -1,3 +1,4 @@
1
+ //Nip46.ts
1
2
  import NDK, {
2
3
  NDKEvent,
3
4
  NDKFilter,