@unicitylabs/sphere-sdk 0.14.8 → 0.14.9-dev.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.
@@ -670,6 +670,15 @@ var ListStore = class {
670
670
  return await this.kv.get(this.storeKey) ?? [];
671
671
  }
672
672
  };
673
+ function senderNametagOption(ownNametag) {
674
+ let nametag;
675
+ try {
676
+ nametag = ownNametag?.();
677
+ } catch {
678
+ return {};
679
+ }
680
+ return nametag === void 0 || nametag === "" ? {} : { senderNametag: nametag };
681
+ }
673
682
  var DeliveryJournal = class extends ListStore {
674
683
  constructor(kv) {
675
684
  super(kv, STORE_KEYS.deliveryJournal, (e) => `${e.transferId}:${String(e.opIndex)}`);
@@ -720,7 +729,8 @@ var DeliveryJournal = class extends ListStore {
720
729
  try {
721
730
  await deps.delivery.deliver(entry.recipientPubkey, hexToBytes(entry.blobHex), {
722
731
  transferId: entry.transferId,
723
- ...entry.memo !== void 0 ? { memo: entry.memo } : {}
732
+ ...entry.memo !== void 0 ? { memo: entry.memo } : {},
733
+ ...senderNametagOption(deps.ownNametag)
724
734
  });
725
735
  await this.remove(entry.transferId, entry.opIndex);
726
736
  stats.delivered += 1;
@@ -1027,7 +1037,11 @@ var TransferMachine = class {
1027
1037
  const journaled = committed.filter((o) => o.error === void 0 && o.recipientBlob !== void 0);
1028
1038
  let pending = journaled.length < committed.length;
1029
1039
  if (journaled.length === 0) return pending;
1030
- const options = { transferId, ...memo !== void 0 ? { memo } : {} };
1040
+ const options = {
1041
+ transferId,
1042
+ ...memo !== void 0 ? { memo } : {},
1043
+ ...senderNametagOption(this.deps.ownNametag)
1044
+ };
1031
1045
  if (await this.tryBatchDeposit(recipientPubkey, journaled, options)) return pending;
1032
1046
  for (const outcome of journaled) {
1033
1047
  const stillPending = await this.deliverOne(recipientPubkey, outcome, options);
@@ -1461,6 +1475,9 @@ var Converger = class {
1461
1475
  return {
1462
1476
  delivery: this.deps.delivery,
1463
1477
  now: () => this.deps.now(),
1478
+ // sphere#487: a replayed leg carries the sender's name too — the machine
1479
+ // deps hold the one live getter, so replay can never drift from a send.
1480
+ ...this.deps.machineDeps.ownNametag !== void 0 ? { ownNametag: this.deps.machineDeps.ownNametag } : {},
1464
1481
  attention: (transferId, code, detail) => {
1465
1482
  this.deps.emit(
1466
1483
  "transfer:attention",
@@ -4046,6 +4063,9 @@ function buildMachineDeps(deps, hooks, historyStore) {
4046
4063
  decryptPayload: async (envelope) => JSON.parse(decryptField(deps.fieldKey, envelope)),
4047
4064
  signComplete: deps.signComplete,
4048
4065
  ownPubkey: hexToBytes(deps.ownPubkey),
4066
+ // sphere#487: the same live getter Requests uses — the delivery envelope is
4067
+ // the recipient's ONLY source for the sender's Unicity ID.
4068
+ ...deps.ownNametag !== void 0 ? { ownNametag: deps.ownNametag } : {},
4049
4069
  emit: deps.emit,
4050
4070
  now: deps.now ?? Date.now,
4051
4071
  recordHistory: async ({ transferId, payload, committedAmount }) => {