@unicitylabs/sphere-sdk 0.4.6 → 0.4.8

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.
@@ -373,6 +373,14 @@ interface TransportProvider extends BaseProvider {
373
373
  * @returns PeerInfo or null if no binding found
374
374
  */
375
375
  resolveTransportPubkeyInfo?(transportPubkey: string): Promise<PeerInfo | null>;
376
+ /**
377
+ * Batch-resolve multiple transport pubkeys to peer info.
378
+ * Used for HD address discovery: derives transport pubkeys for indices 0..N
379
+ * and queries binding events in a single batch.
380
+ * @param transportPubkeys - Array of transport-specific pubkeys to look up
381
+ * @returns Array of PeerInfo for pubkeys that have binding events (may be shorter than input)
382
+ */
383
+ discoverAddresses?(transportPubkeys: string[]): Promise<PeerInfo[]>;
376
384
  /**
377
385
  * Recover nametag for current identity by decrypting stored encrypted nametag
378
386
  * Used after wallet import to recover associated nametag
@@ -861,6 +869,11 @@ declare class NostrTransportProvider implements TransportProvider {
861
869
  * Queries binding events authored by the given pubkey.
862
870
  */
863
871
  resolveTransportPubkeyInfo(transportPubkey: string): Promise<PeerInfo | null>;
872
+ /**
873
+ * Batch-resolve multiple transport pubkeys to peer info.
874
+ * Used for HD address discovery — single relay query with multi-author filter.
875
+ */
876
+ discoverAddresses(transportPubkeys: string[]): Promise<PeerInfo[]>;
864
877
  /**
865
878
  * Recover nametag for the current identity by searching for encrypted nametag events
866
879
  * Used after wallet import to recover associated nametag
@@ -1186,7 +1199,7 @@ declare const NETWORKS: {
1186
1199
  readonly aggregatorUrl: "https://aggregator.unicity.network/rpc";
1187
1200
  readonly nostrRelays: readonly ["wss://relay.unicity.network", "wss://relay.damus.io", "wss://nos.lol", "wss://relay.nostr.band"];
1188
1201
  readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
1189
- readonly electrumUrl: "wss://fulcrum.alpha.unicity.network:50004";
1202
+ readonly electrumUrl: "wss://fulcrum.unicity.network:50004";
1190
1203
  readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
1191
1204
  readonly tokenRegistryUrl: "https://raw.githubusercontent.com/unicitynetwork/unicity-ids/refs/heads/main/unicity-ids.testnet.json";
1192
1205
  };
@@ -1195,7 +1208,7 @@ declare const NETWORKS: {
1195
1208
  readonly aggregatorUrl: "https://goggregator-test.unicity.network";
1196
1209
  readonly nostrRelays: readonly ["wss://nostr-relay.testnet.unicity.network"];
1197
1210
  readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
1198
- readonly electrumUrl: "wss://fulcrum.alpha.testnet.unicity.network:50004";
1211
+ readonly electrumUrl: "wss://fulcrum.unicity.network:50004";
1199
1212
  readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
1200
1213
  readonly tokenRegistryUrl: "https://raw.githubusercontent.com/unicitynetwork/unicity-ids/refs/heads/main/unicity-ids.testnet.json";
1201
1214
  };
@@ -1204,7 +1217,7 @@ declare const NETWORKS: {
1204
1217
  readonly aggregatorUrl: "https://dev-aggregator.dyndns.org/rpc";
1205
1218
  readonly nostrRelays: readonly ["wss://nostr-relay.testnet.unicity.network"];
1206
1219
  readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
1207
- readonly electrumUrl: "wss://fulcrum.alpha.testnet.unicity.network:50004";
1220
+ readonly electrumUrl: "wss://fulcrum.unicity.network:50004";
1208
1221
  readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
1209
1222
  readonly tokenRegistryUrl: "https://raw.githubusercontent.com/unicitynetwork/unicity-ids/refs/heads/main/unicity-ids.testnet.json";
1210
1223
  };
@@ -373,6 +373,14 @@ interface TransportProvider extends BaseProvider {
373
373
  * @returns PeerInfo or null if no binding found
374
374
  */
375
375
  resolveTransportPubkeyInfo?(transportPubkey: string): Promise<PeerInfo | null>;
376
+ /**
377
+ * Batch-resolve multiple transport pubkeys to peer info.
378
+ * Used for HD address discovery: derives transport pubkeys for indices 0..N
379
+ * and queries binding events in a single batch.
380
+ * @param transportPubkeys - Array of transport-specific pubkeys to look up
381
+ * @returns Array of PeerInfo for pubkeys that have binding events (may be shorter than input)
382
+ */
383
+ discoverAddresses?(transportPubkeys: string[]): Promise<PeerInfo[]>;
376
384
  /**
377
385
  * Recover nametag for current identity by decrypting stored encrypted nametag
378
386
  * Used after wallet import to recover associated nametag
@@ -861,6 +869,11 @@ declare class NostrTransportProvider implements TransportProvider {
861
869
  * Queries binding events authored by the given pubkey.
862
870
  */
863
871
  resolveTransportPubkeyInfo(transportPubkey: string): Promise<PeerInfo | null>;
872
+ /**
873
+ * Batch-resolve multiple transport pubkeys to peer info.
874
+ * Used for HD address discovery — single relay query with multi-author filter.
875
+ */
876
+ discoverAddresses(transportPubkeys: string[]): Promise<PeerInfo[]>;
864
877
  /**
865
878
  * Recover nametag for the current identity by searching for encrypted nametag events
866
879
  * Used after wallet import to recover associated nametag
@@ -1186,7 +1199,7 @@ declare const NETWORKS: {
1186
1199
  readonly aggregatorUrl: "https://aggregator.unicity.network/rpc";
1187
1200
  readonly nostrRelays: readonly ["wss://relay.unicity.network", "wss://relay.damus.io", "wss://nos.lol", "wss://relay.nostr.band"];
1188
1201
  readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
1189
- readonly electrumUrl: "wss://fulcrum.alpha.unicity.network:50004";
1202
+ readonly electrumUrl: "wss://fulcrum.unicity.network:50004";
1190
1203
  readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
1191
1204
  readonly tokenRegistryUrl: "https://raw.githubusercontent.com/unicitynetwork/unicity-ids/refs/heads/main/unicity-ids.testnet.json";
1192
1205
  };
@@ -1195,7 +1208,7 @@ declare const NETWORKS: {
1195
1208
  readonly aggregatorUrl: "https://goggregator-test.unicity.network";
1196
1209
  readonly nostrRelays: readonly ["wss://nostr-relay.testnet.unicity.network"];
1197
1210
  readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
1198
- readonly electrumUrl: "wss://fulcrum.alpha.testnet.unicity.network:50004";
1211
+ readonly electrumUrl: "wss://fulcrum.unicity.network:50004";
1199
1212
  readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
1200
1213
  readonly tokenRegistryUrl: "https://raw.githubusercontent.com/unicitynetwork/unicity-ids/refs/heads/main/unicity-ids.testnet.json";
1201
1214
  };
@@ -1204,7 +1217,7 @@ declare const NETWORKS: {
1204
1217
  readonly aggregatorUrl: "https://dev-aggregator.dyndns.org/rpc";
1205
1218
  readonly nostrRelays: readonly ["wss://nostr-relay.testnet.unicity.network"];
1206
1219
  readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
1207
- readonly electrumUrl: "wss://fulcrum.alpha.testnet.unicity.network:50004";
1220
+ readonly electrumUrl: "wss://fulcrum.unicity.network:50004";
1208
1221
  readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
1209
1222
  readonly tokenRegistryUrl: "https://raw.githubusercontent.com/unicitynetwork/unicity-ids/refs/heads/main/unicity-ids.testnet.json";
1210
1223
  };
@@ -119,8 +119,8 @@ function getIpfsGatewayUrls(isSecure) {
119
119
  }
120
120
  var DEFAULT_BASE_PATH = "m/44'/0'/0'";
121
121
  var DEFAULT_DERIVATION_PATH = `${DEFAULT_BASE_PATH}/0/0`;
122
- var DEFAULT_ELECTRUM_URL = "wss://fulcrum.alpha.unicity.network:50004";
123
- var TEST_ELECTRUM_URL = "wss://fulcrum.alpha.testnet.unicity.network:50004";
122
+ var DEFAULT_ELECTRUM_URL = "wss://fulcrum.unicity.network:50004";
123
+ var TEST_ELECTRUM_URL = "wss://fulcrum.unicity.network:50004";
124
124
  var TOKEN_REGISTRY_URL = "https://raw.githubusercontent.com/unicitynetwork/unicity-ids/refs/heads/main/unicity-ids.testnet.json";
125
125
  var TOKEN_REGISTRY_REFRESH_INTERVAL = 36e5;
126
126
  var TEST_NOSTR_RELAYS = [
@@ -1820,6 +1820,44 @@ var NostrTransportProvider = class {
1820
1820
  };
1821
1821
  }
1822
1822
  }
1823
+ /**
1824
+ * Batch-resolve multiple transport pubkeys to peer info.
1825
+ * Used for HD address discovery — single relay query with multi-author filter.
1826
+ */
1827
+ async discoverAddresses(transportPubkeys) {
1828
+ this.ensureConnected();
1829
+ if (transportPubkeys.length === 0) return [];
1830
+ const events = await this.queryEvents({
1831
+ kinds: [EVENT_KINDS.NAMETAG_BINDING],
1832
+ authors: transportPubkeys,
1833
+ limit: transportPubkeys.length * 2
1834
+ });
1835
+ if (events.length === 0) return [];
1836
+ const byAuthor = /* @__PURE__ */ new Map();
1837
+ for (const event of events) {
1838
+ const existing = byAuthor.get(event.pubkey);
1839
+ if (!existing || event.created_at > existing.created_at) {
1840
+ byAuthor.set(event.pubkey, event);
1841
+ }
1842
+ }
1843
+ const results = [];
1844
+ for (const [pubkey, event] of byAuthor) {
1845
+ try {
1846
+ const content = JSON.parse(event.content);
1847
+ results.push({
1848
+ nametag: content.nametag || void 0,
1849
+ transportPubkey: pubkey,
1850
+ chainPubkey: content.public_key || "",
1851
+ l1Address: content.l1_address || "",
1852
+ directAddress: content.direct_address || "",
1853
+ proxyAddress: content.proxy_address || void 0,
1854
+ timestamp: event.created_at * 1e3
1855
+ });
1856
+ } catch {
1857
+ }
1858
+ }
1859
+ return results;
1860
+ }
1823
1861
  /**
1824
1862
  * Recover nametag for the current identity by searching for encrypted nametag events
1825
1863
  * Used after wallet import to recover associated nametag