applesauce-signers 6.2.2 → 6.2.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.
|
@@ -45,7 +45,7 @@ export type ConnectResponseResults = {
|
|
|
45
45
|
[NostrConnectMethod.Nip04Decrypt]: string;
|
|
46
46
|
[NostrConnectMethod.Nip44Encrypt]: string;
|
|
47
47
|
[NostrConnectMethod.Nip44Decrypt]: string;
|
|
48
|
-
[NostrConnectMethod.SwitchRelays]: string[] | null;
|
|
48
|
+
[NostrConnectMethod.SwitchRelays]: string | string[] | null;
|
|
49
49
|
[NostrConnectMethod.Logout]: "ack";
|
|
50
50
|
};
|
|
51
51
|
export type NostrConnectRequest<N extends NostrConnectMethod> = {
|
|
@@ -169,7 +169,7 @@ export class NostrConnectSigner {
|
|
|
169
169
|
else
|
|
170
170
|
p.reject(new Error(response.error));
|
|
171
171
|
}
|
|
172
|
-
else if (response.result) {
|
|
172
|
+
else if (response.result !== undefined) {
|
|
173
173
|
this.log("Got Response", response.id, response.result);
|
|
174
174
|
p.resolve(response.result);
|
|
175
175
|
}
|
|
@@ -334,9 +334,17 @@ export class NostrConnectSigner {
|
|
|
334
334
|
*/
|
|
335
335
|
async switchRelays() {
|
|
336
336
|
await this.requireConnection();
|
|
337
|
-
const
|
|
337
|
+
const response = await this.makeRequest(NostrConnectMethod.SwitchRelays, []);
|
|
338
|
+
// NIP-46 results are strings, so the relay list arrives JSON-stringified
|
|
339
|
+
let result = null;
|
|
340
|
+
try {
|
|
341
|
+
const parsed = typeof response === "string" ? JSON.parse(response) : response;
|
|
342
|
+
if (Array.isArray(parsed))
|
|
343
|
+
result = parsed.filter((relay) => typeof relay === "string");
|
|
344
|
+
}
|
|
345
|
+
catch (e) { }
|
|
338
346
|
// Update local relays if the remote signer provided new ones
|
|
339
|
-
if (result
|
|
347
|
+
if (result && result.length > 0) {
|
|
340
348
|
this.log("Switching relays from", this.relays, "to", result);
|
|
341
349
|
this.relays = result;
|
|
342
350
|
// Restart subscription with new relays
|