@unicitylabs/sphere-sdk 0.14.1-dev.2 → 0.14.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 (39) hide show
  1. package/dist/connect/index.cjs +1 -1
  2. package/dist/connect/index.cjs.map +1 -1
  3. package/dist/connect/index.js +1 -1
  4. package/dist/connect/index.js.map +1 -1
  5. package/dist/core/index.cjs +69 -27
  6. package/dist/core/index.cjs.map +1 -1
  7. package/dist/core/index.d.cts +21 -1
  8. package/dist/core/index.d.ts +21 -1
  9. package/dist/core/index.js +69 -27
  10. package/dist/core/index.js.map +1 -1
  11. package/dist/impl/browser/connect/index.cjs +1 -1
  12. package/dist/impl/browser/connect/index.cjs.map +1 -1
  13. package/dist/impl/browser/connect/index.js +1 -1
  14. package/dist/impl/browser/connect/index.js.map +1 -1
  15. package/dist/impl/browser/index.cjs +33 -0
  16. package/dist/impl/browser/index.cjs.map +1 -1
  17. package/dist/impl/browser/index.js +33 -0
  18. package/dist/impl/browser/index.js.map +1 -1
  19. package/dist/impl/nodejs/index.cjs +33 -0
  20. package/dist/impl/nodejs/index.cjs.map +1 -1
  21. package/dist/impl/nodejs/index.d.cts +41 -1
  22. package/dist/impl/nodejs/index.d.ts +41 -1
  23. package/dist/impl/nodejs/index.js +33 -0
  24. package/dist/impl/nodejs/index.js.map +1 -1
  25. package/dist/impl/shared/wallet-api/index.d.cts +21 -1
  26. package/dist/impl/shared/wallet-api/index.d.ts +21 -1
  27. package/dist/index.cjs +69 -27
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.d.cts +21 -1
  30. package/dist/index.d.ts +21 -1
  31. package/dist/index.js +69 -27
  32. package/dist/index.js.map +1 -1
  33. package/dist/modules/payments-v2/index.cjs +36 -26
  34. package/dist/modules/payments-v2/index.cjs.map +1 -1
  35. package/dist/modules/payments-v2/index.d.cts +16 -6
  36. package/dist/modules/payments-v2/index.d.ts +16 -6
  37. package/dist/modules/payments-v2/index.js +35 -26
  38. package/dist/modules/payments-v2/index.js.map +1 -1
  39. package/package.json +1 -1
@@ -31,6 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var payments_v2_exports = {};
32
32
  __export(payments_v2_exports, {
33
33
  ATTENTION_MINT_UNRESOLVED: () => ATTENTION_MINT_UNRESOLVED,
34
+ ATTENTION_RECIPIENT_NETWORK_UNVERIFIED: () => ATTENTION_RECIPIENT_NETWORK_UNVERIFIED,
34
35
  ATTENTION_RESEED_REJECTED: () => ATTENTION_RESEED_REJECTED,
35
36
  HEARTBEAT_CAP_MS: () => HEARTBEAT_CAP_MS,
36
37
  HEARTBEAT_SEED_MS: () => HEARTBEAT_SEED_MS,
@@ -1520,6 +1521,31 @@ function distinctOpCount(entries) {
1520
1521
  return new Set(entries.map((entry) => entry.opIndex)).size;
1521
1522
  }
1522
1523
 
1524
+ // modules/payments-v2/recipient.ts
1525
+ var ATTENTION_RECIPIENT_NETWORK_UNVERIFIED = "recipient:network-unverified";
1526
+ async function requireSameNetworkRecipient(deps, identifier) {
1527
+ const recipient = await deps.resolveRecipient(identifier);
1528
+ if (recipient === null || recipient.chainPubkey === "") {
1529
+ throw new SphereError(`Recipient ${identifier} has no published chain pubkey`, "INVALID_RECIPIENT");
1530
+ }
1531
+ if (recipient.network === null) {
1532
+ deps.emit("transfer:attention", {
1533
+ transferId: "",
1534
+ // the gate precedes plan allocation — no transferId exists yet
1535
+ code: ATTENTION_RECIPIENT_NETWORK_UNVERIFIED,
1536
+ detail: `could not verify the network of recipient ${identifier} \u2014 assuming this session's "${deps.network}"`
1537
+ });
1538
+ return recipient;
1539
+ }
1540
+ if (recipient.network !== deps.network) {
1541
+ throw new SphereError(
1542
+ `Recipient ${identifier} is on network "${recipient.network}" but this session is on "${deps.network}" \u2014 a cross-network deposit is unrecoverable`,
1543
+ "INVALID_RECIPIENT"
1544
+ );
1545
+ }
1546
+ return recipient;
1547
+ }
1548
+
1523
1549
  // modules/payments-v2/restore.ts
1524
1550
  var ATTENTION_RESEED_REJECTED = "intent:reseed-rejected";
1525
1551
  var ALL_STREAMS = ["inventory", "mailbox", "payment_requests", "history"];
@@ -4054,6 +4080,10 @@ var PaymentsFacade = class {
4054
4080
  history(page) {
4055
4081
  return this.historyStore.page(page ?? {});
4056
4082
  }
4083
+ /** §4: read through to the session — the same value `connection:status` carries (sphere#473). No session ⇒ 'offline'. */
4084
+ connectionStatus() {
4085
+ return this.started ? this.deps.session.status() : "offline";
4086
+ }
4057
4087
  /** §4 pending-transfers UI surface — derived on read, never cached (convergence.ts). */
4058
4088
  pendingTransfers() {
4059
4089
  return derivePendingTransfers(this.machineStores, this.machineDeps.decryptPayload);
@@ -4128,7 +4158,7 @@ var PaymentsFacade = class {
4128
4158
  this.deps.emit("transfer:updated", failed);
4129
4159
  }
4130
4160
  async sendWithPolicy(request, run) {
4131
- const recipient = await this.requireSameNetworkRecipient(request.recipient);
4161
+ const recipient = await requireSameNetworkRecipient(this.deps, request.recipient);
4132
4162
  for (let attempt = 0; ; attempt++) {
4133
4163
  let ctx;
4134
4164
  try {
@@ -4151,20 +4181,6 @@ var PaymentsFacade = class {
4151
4181
  if (surfaced !== null) return surfaced;
4152
4182
  }
4153
4183
  }
4154
- /** §5.6 cross-network deposit trap: refused BEFORE any reserve/certification. */
4155
- async requireSameNetworkRecipient(identifier) {
4156
- const recipient = await this.deps.resolveRecipient(identifier);
4157
- if (recipient === null || recipient.chainPubkey === "") {
4158
- throw new SphereError(`Recipient ${identifier} has no published chain pubkey`, "INVALID_RECIPIENT");
4159
- }
4160
- if (recipient.network !== this.deps.network) {
4161
- throw new SphereError(
4162
- `Recipient ${identifier} is on network "${recipient.network}" but this session is on "${this.deps.network}" \u2014 a cross-network deposit is unrecoverable`,
4163
- "INVALID_RECIPIENT"
4164
- );
4165
- }
4166
- return recipient;
4167
- }
4168
4184
  async runAttempt(ctx) {
4169
4185
  this.activeMoneyOps.add(ctx.transferId);
4170
4186
  try {
@@ -4541,19 +4557,12 @@ var PaymentsFacade = class {
4541
4557
  }
4542
4558
  toUiToken(tokenId, coinId, amount) {
4543
4559
  const now = this.nowMs();
4544
- return toToken(
4545
- tokenId,
4546
- { assets: [], createdAt: now, updatedAt: now },
4547
- { coinId, amount: amount.toString() },
4548
- this.deps.registry,
4549
- { transferring: true, suspectedSpent: false }
4550
- );
4560
+ const snapshot = { assets: [], createdAt: now, updatedAt: now };
4561
+ const flags = { transferring: true, suspectedSpent: false };
4562
+ return toToken(tokenId, snapshot, { coinId, amount: amount.toString() }, this.deps.registry, flags);
4551
4563
  }
4552
4564
  track(op) {
4553
- const settled = op.then(
4554
- () => void 0,
4555
- () => void 0
4556
- );
4565
+ const settled = op.then(() => void 0, () => void 0);
4557
4566
  this.pendingOps.add(settled);
4558
4567
  void settled.finally(() => this.pendingOps.delete(settled));
4559
4568
  return op;
@@ -4565,6 +4574,7 @@ var PaymentsFacade = class {
4565
4574
  // Annotate the CommonJS export names for ESM import in node:
4566
4575
  0 && (module.exports = {
4567
4576
  ATTENTION_MINT_UNRESOLVED,
4577
+ ATTENTION_RECIPIENT_NETWORK_UNVERIFIED,
4568
4578
  ATTENTION_RESEED_REJECTED,
4569
4579
  HEARTBEAT_CAP_MS,
4570
4580
  HEARTBEAT_SEED_MS,