@unicitylabs/sphere-sdk 0.15.0 → 0.16.0-dev.2

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.
Files changed (50) hide show
  1. package/README.md +15 -5
  2. package/dist/connect/index.cjs +26 -25
  3. package/dist/connect/index.cjs.map +1 -1
  4. package/dist/connect/index.d.cts +4 -0
  5. package/dist/connect/index.d.ts +4 -0
  6. package/dist/connect/index.js +26 -25
  7. package/dist/connect/index.js.map +1 -1
  8. package/dist/core/index.cjs +728 -227
  9. package/dist/core/index.cjs.map +1 -1
  10. package/dist/core/index.d.cts +174 -23
  11. package/dist/core/index.d.ts +174 -23
  12. package/dist/core/index.js +728 -226
  13. package/dist/core/index.js.map +1 -1
  14. package/dist/impl/browser/connect/index.cjs +16 -25
  15. package/dist/impl/browser/connect/index.cjs.map +1 -1
  16. package/dist/impl/browser/connect/index.js +16 -25
  17. package/dist/impl/browser/connect/index.js.map +1 -1
  18. package/dist/impl/browser/index.cjs +333 -506
  19. package/dist/impl/browser/index.cjs.map +1 -1
  20. package/dist/impl/browser/index.js +333 -506
  21. package/dist/impl/browser/index.js.map +1 -1
  22. package/dist/impl/nodejs/connect/index.cjs +15 -24
  23. package/dist/impl/nodejs/connect/index.cjs.map +1 -1
  24. package/dist/impl/nodejs/connect/index.js +15 -24
  25. package/dist/impl/nodejs/connect/index.js.map +1 -1
  26. package/dist/impl/nodejs/index.cjs +300 -571
  27. package/dist/impl/nodejs/index.cjs.map +1 -1
  28. package/dist/impl/nodejs/index.d.cts +92 -15
  29. package/dist/impl/nodejs/index.d.ts +92 -15
  30. package/dist/impl/nodejs/index.js +300 -571
  31. package/dist/impl/nodejs/index.js.map +1 -1
  32. package/dist/impl/shared/wallet-api/index.d.cts +54 -2
  33. package/dist/impl/shared/wallet-api/index.d.ts +54 -2
  34. package/dist/index.cjs +730 -227
  35. package/dist/index.cjs.map +1 -1
  36. package/dist/index.d.cts +229 -110
  37. package/dist/index.d.ts +229 -110
  38. package/dist/index.js +730 -226
  39. package/dist/index.js.map +1 -1
  40. package/dist/modules/payments-v2/index.cjs +11 -7
  41. package/dist/modules/payments-v2/index.cjs.map +1 -1
  42. package/dist/modules/payments-v2/index.d.cts +56 -3
  43. package/dist/modules/payments-v2/index.d.ts +56 -3
  44. package/dist/modules/payments-v2/index.js +11 -7
  45. package/dist/modules/payments-v2/index.js.map +1 -1
  46. package/dist/token-engine/index.cjs +46 -0
  47. package/dist/token-engine/index.cjs.map +1 -1
  48. package/dist/token-engine/index.js +46 -0
  49. package/dist/token-engine/index.js.map +1 -1
  50. package/package.json +1 -1
@@ -15,6 +15,10 @@ interface NetworkInfo {
15
15
  * the legacy `testnet` alias is intentionally not surfaced.
16
16
  */
17
17
  declare const SPHERE_NETWORKS: {
18
+ readonly mainnet: {
19
+ readonly id: number;
20
+ readonly name: "mainnet";
21
+ };
18
22
  readonly testnet2: {
19
23
  readonly id: number;
20
24
  readonly name: "testnet2";
@@ -15,6 +15,10 @@ interface NetworkInfo {
15
15
  * the legacy `testnet` alias is intentionally not surfaced.
16
16
  */
17
17
  declare const SPHERE_NETWORKS: {
18
+ readonly mainnet: {
19
+ readonly id: number;
20
+ readonly name: "mainnet";
21
+ };
18
22
  readonly testnet2: {
19
23
  readonly id: number;
20
24
  readonly name: "testnet2";
@@ -181,17 +181,8 @@ var NETWORK_SCOPED_ADDRESS_PREFIXES = [
181
181
  "inv_ledger:"
182
182
  // AccountingModule INV_LEDGER_PREFIX
183
183
  ];
184
- var DEFAULT_NOSTR_RELAYS = [
185
- "wss://relay.unicity.network",
186
- "wss://relay.damus.io",
187
- "wss://nos.lol",
188
- "wss://relay.nostr.band"
189
- ];
190
- var DEFAULT_AGGREGATOR_URL = "https://aggregator.unicity.network/rpc";
191
- var DEV_AGGREGATOR_URL = "https://dev-aggregator.dyndns.org/rpc";
192
184
  var DEFAULT_BASE_PATH = "m/44'/0'/0'";
193
185
  var DEFAULT_DERIVATION_PATH = `${DEFAULT_BASE_PATH}/0/0`;
194
- var TOKEN_REGISTRY_URL = "https://raw.githubusercontent.com/unicitynetwork/unicity-ids/refs/heads/main/unicity-ids.testnet.json";
195
186
  var TEST_NOSTR_RELAYS = [
196
187
  "wss://nostr-relay.testnet.unicity.network"
197
188
  ];
@@ -201,16 +192,25 @@ var DEFAULT_GROUP_RELAYS = [
201
192
  var NETWORKS = {
202
193
  mainnet: {
203
194
  name: "Mainnet",
204
- aggregatorUrl: DEFAULT_AGGREGATOR_URL,
205
- nostrRelays: DEFAULT_NOSTR_RELAYS,
195
+ networkId: 1,
196
+ // v3 state-transition gateway (networkId 1 comes from the trust base). apiKey is env-injected;
197
+ // unlike testnet2's, a mainnet gateway key is a SECRET — never commit one.
198
+ aggregatorUrl: "https://gateway.mainnet.unicity.network",
199
+ // Mainnet has no relay of its own yet — it shares the testnet relay until one is stood up.
200
+ // Consequence while shared: nametag bindings for both networks live in ONE namespace, and
201
+ // since bindings carry no network the cross-network recipient guard can only signal (#734).
202
+ nostrRelays: TEST_NOSTR_RELAYS,
206
203
  groupRelays: DEFAULT_GROUP_RELAYS,
207
- tokenRegistryUrl: TOKEN_REGISTRY_URL
204
+ // Published, but currently only the non-fungible base token type — no fungible
205
+ // coins yet, so those still miss the registry (decimals 0, symbol falls back to
206
+ // six hex chars). Presentation only: the money path treats coinId as opaque bytes.
207
+ tokenRegistryUrl: "https://raw.githubusercontent.com/unicitynetwork/unicity-ids/refs/heads/main/unicity-ids.mainnet.json"
208
208
  },
209
209
  // v1 cutover: 'testnet' now POINTS AT TESTNET2 (the v2 gateway network). The
210
210
  // old goggregator testnet spoke the removed v1 protocol — a v2 engine cannot
211
211
  // run against it. 'testnet2' stays as an alias of the same configuration.
212
212
  testnet: {
213
- name: "Testnet2",
213
+ name: "Testnet",
214
214
  networkId: 4,
215
215
  // v2 state-transition gateway (networkId 4 comes from the trust base). apiKey is env-injected.
216
216
  aggregatorUrl: "https://gateway.testnet2.unicity.network",
@@ -220,7 +220,7 @@ var NETWORKS = {
220
220
  tokenRegistryUrl: "https://raw.githubusercontent.com/unicitynetwork/unicity-ids/refs/heads/main/unicity-ids.testnet2.json"
221
221
  },
222
222
  testnet2: {
223
- name: "Testnet2",
223
+ name: "Testnet",
224
224
  networkId: 4,
225
225
  // v2 state-transition gateway (networkId 4 comes from the trust base). apiKey is env-injected.
226
226
  aggregatorUrl: "https://gateway.testnet2.unicity.network",
@@ -228,19 +228,10 @@ var NETWORKS = {
228
228
  // reuse testnet infra (shared relays/ipfs)
229
229
  groupRelays: DEFAULT_GROUP_RELAYS,
230
230
  tokenRegistryUrl: "https://raw.githubusercontent.com/unicitynetwork/unicity-ids/refs/heads/main/unicity-ids.testnet2.json"
231
- },
232
- // NOTE: mainnet/dev still point at v1-era aggregators. The v2 engine cannot
233
- // operate against them until their gateways are cut over to the v2 protocol —
234
- // wallet operations on these networks fail loudly (AGGREGATOR_ERROR) until then.
235
- dev: {
236
- name: "Development",
237
- aggregatorUrl: DEV_AGGREGATOR_URL,
238
- nostrRelays: TEST_NOSTR_RELAYS,
239
- groupRelays: DEFAULT_GROUP_RELAYS,
240
- tokenRegistryUrl: TOKEN_REGISTRY_URL
241
231
  }
242
232
  };
243
233
  var SPHERE_NETWORKS = {
234
+ mainnet: { id: NETWORKS.mainnet.networkId, name: "mainnet" },
244
235
  testnet2: { id: NETWORKS.testnet2.networkId, name: "testnet2" }
245
236
  };
246
237
  var HOST_READY_TYPE = "sphere-connect:host-ready";
@@ -406,7 +397,7 @@ function checkCompatibility(input) {
406
397
  }
407
398
 
408
399
  // connect/version.ts
409
- var SDK_VERSION = "0.15.0";
400
+ var SDK_VERSION = "0.16.0-dev.2";
410
401
 
411
402
  // connect/permissions.ts
412
403
  var PERMISSION_SCOPES = {
@@ -857,6 +848,16 @@ var ConnectHost = class {
857
848
  return;
858
849
  }
859
850
  if (this._walletState === "live") {
851
+ if (this.session?.active && (this.snapshot.networkId ?? null) !== (next.networkId ?? null)) {
852
+ logger.warn(
853
+ "ConnectHost",
854
+ `Network changed under a live session \u2014 revoking instead of rebinding (origin=${this.config.origin ?? "unverified"})`
855
+ );
856
+ this.sphere = next;
857
+ this.snapshot = buildWalletSnapshot(next);
858
+ this.revokeSession();
859
+ return;
860
+ }
860
861
  this.sphere = next;
861
862
  this.snapshot = buildWalletSnapshot(next);
862
863
  const existing = this.eventSubscriptions.get(WALLET_EVENTS.IDENTITY_CHANGED);