@konemono/nostr-login 1.10.2 → 1.10.3

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.2",
3
+ "version": "1.10.3",
4
4
  "description": "",
5
5
  "main": "./dist/index.esm.js",
6
6
  "types": "./dist/index.d.ts",
@@ -128,14 +128,17 @@ class AuthNostrService extends EventEmitter implements Signer {
128
128
  link = '',
129
129
  iframeUrl = '',
130
130
  importConnect = false,
131
+ customRelays,
131
132
  }: {
132
133
  domain?: string;
133
134
  link?: string;
134
135
  importConnect?: boolean;
135
136
  iframeUrl?: string;
137
+ customRelays?: string[];
136
138
  } = {},
137
139
  ) {
138
- relay = relay || DEFAULT_NOSTRCONNECT_RELAY;
140
+ // カスタムリレーが指定されていれば使用、そうでなければ単一リレーまたはデフォルト
141
+ const relays = customRelays && customRelays.length > 0 ? customRelays : [relay || DEFAULT_NOSTRCONNECT_RELAY];
139
142
 
140
143
  const info: Info = {
141
144
  authMethod: 'connect',
@@ -143,7 +146,7 @@ class AuthNostrService extends EventEmitter implements Signer {
143
146
  signerPubkey: '', // unknown too!
144
147
  sk: this.nostrConnectKey,
145
148
  domain: domain,
146
- relays: [relay],
149
+ relays: relays,
147
150
  iframeUrl,
148
151
  };
149
152
 
@@ -158,7 +161,9 @@ class AuthNostrService extends EventEmitter implements Signer {
158
161
  // signer learns the remote pubkey
159
162
  if (!info.pubkey || !info.signerPubkey) throw new Error('Bad remote pubkey');
160
163
 
161
- info.bunkerUrl = `bunker://${info.signerPubkey}?relay=${relay}`;
164
+ // bunkerUrl\u306b\u5168\u30ea\u30ec\u30fc\u3092\u542b\u3081\u308b
165
+ const relayParams = relays.map(r => `relay=${encodeURIComponent(r)}`).join('&');
166
+ info.bunkerUrl = `bunker://${info.signerPubkey}?${relayParams}`;
162
167
 
163
168
  // callback
164
169
  if (!importConnect) this.onAuth('login', info);
@@ -219,7 +219,7 @@ class ModalManager extends EventEmitter {
219
219
  if (!cs) this.modal.isLoading = false;
220
220
  }
221
221
 
222
- await this.authNostrService.nostrConnect(relay, { domain, link, iframeUrl });
222
+ await this.authNostrService.nostrConnect(relay, { domain, link, iframeUrl, customRelays: this.customNip46Relays });
223
223
  });
224
224
  };
225
225