@konemono/nostr-login 1.16.0 → 1.16.1
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
|
@@ -702,14 +702,25 @@ class AuthNostrService extends EventEmitter implements Signer {
|
|
|
702
702
|
await this.signer!.initUserPubkey(info.pubkey);
|
|
703
703
|
}
|
|
704
704
|
|
|
705
|
-
// NIP-46 Spec: 接続確立後に switch_relays
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
this.pool.
|
|
705
|
+
// NIP-46 Spec: 接続確立後に switch_relays を即時送信(should、非致命的)
|
|
706
|
+
try {
|
|
707
|
+
const newRelays = await this.signer!.switchRelays();
|
|
708
|
+
if (newRelays && newRelays.length > 0) {
|
|
709
|
+
// 一時的にリレーゼロにならないよう、先に追加してから削除
|
|
710
|
+
const oldRelays = this.pool.relayUrls;
|
|
711
|
+
for (const r of newRelays) {
|
|
712
|
+
this.pool.addRelay(r);
|
|
713
|
+
}
|
|
714
|
+
// 古いリレーを削除(新規に含まれないものを除外)
|
|
715
|
+
for (const r of oldRelays) {
|
|
716
|
+
if (!newRelays.includes(r)) {
|
|
717
|
+
this.pool.removeRelay(r);
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
this.signer!.rpc.resubscribe();
|
|
711
721
|
}
|
|
712
|
-
|
|
722
|
+
} catch (e) {
|
|
723
|
+
console.warn('NIP-46 switch_relays failed (non-fatal):', e);
|
|
713
724
|
}
|
|
714
725
|
|
|
715
726
|
info.pubkey = this.signer!.userPubkey as string;
|
|
@@ -158,7 +158,7 @@ export class Nip46Signer extends EventEmitter {
|
|
|
158
158
|
return new Promise<boolean>((resolve, reject) => {
|
|
159
159
|
this.rpc.sendRequest(this.bunkerPubkey, 'ping', [], 24133, (response: RpcResponse) => {
|
|
160
160
|
if (response.error) {
|
|
161
|
-
reject(new Nip46Error(response.error, '
|
|
161
|
+
reject(new Nip46Error(response.error, 'SIGNER_REJECTED'));
|
|
162
162
|
} else {
|
|
163
163
|
resolve(response.result === 'pong');
|
|
164
164
|
}
|
|
@@ -174,7 +174,7 @@ export class Nip46Signer extends EventEmitter {
|
|
|
174
174
|
return new Promise<string[] | null>((resolve, reject) => {
|
|
175
175
|
this.rpc.sendRequest(this.bunkerPubkey, 'switch_relays', [], 24133, (response: RpcResponse) => {
|
|
176
176
|
if (response.error) {
|
|
177
|
-
reject(new Nip46Error(response.error, '
|
|
177
|
+
reject(new Nip46Error(response.error, 'SIGNER_REJECTED'));
|
|
178
178
|
} else {
|
|
179
179
|
// result は JSON 文字列: ["wss://...", ...] または "null"
|
|
180
180
|
try {
|
|
@@ -195,7 +195,7 @@ export class Nip46Signer extends EventEmitter {
|
|
|
195
195
|
return new Promise<void>((resolve, reject) => {
|
|
196
196
|
this.rpc.sendRequest(this.bunkerPubkey, 'logout', [], 24133, (response: RpcResponse) => {
|
|
197
197
|
if (response.error) {
|
|
198
|
-
reject(new Nip46Error(response.error, '
|
|
198
|
+
reject(new Nip46Error(response.error, 'SIGNER_REJECTED'));
|
|
199
199
|
} else {
|
|
200
200
|
resolve();
|
|
201
201
|
}
|