@unicitylabs/sphere-sdk 0.14.8 → 0.14.9

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.
@@ -625,6 +625,15 @@ var ListStore = class {
625
625
  return await this.kv.get(this.storeKey) ?? [];
626
626
  }
627
627
  };
628
+ function senderNametagOption(ownNametag) {
629
+ let nametag;
630
+ try {
631
+ nametag = ownNametag?.();
632
+ } catch {
633
+ return {};
634
+ }
635
+ return nametag === void 0 || nametag === "" ? {} : { senderNametag: nametag };
636
+ }
628
637
  var DeliveryJournal = class extends ListStore {
629
638
  constructor(kv) {
630
639
  super(kv, STORE_KEYS.deliveryJournal, (e) => `${e.transferId}:${String(e.opIndex)}`);
@@ -675,7 +684,8 @@ var DeliveryJournal = class extends ListStore {
675
684
  try {
676
685
  await deps.delivery.deliver(entry.recipientPubkey, hexToBytes(entry.blobHex), {
677
686
  transferId: entry.transferId,
678
- ...entry.memo !== void 0 ? { memo: entry.memo } : {}
687
+ ...entry.memo !== void 0 ? { memo: entry.memo } : {},
688
+ ...senderNametagOption(deps.ownNametag)
679
689
  });
680
690
  await this.remove(entry.transferId, entry.opIndex);
681
691
  stats.delivered += 1;
@@ -982,7 +992,11 @@ var TransferMachine = class {
982
992
  const journaled = committed.filter((o) => o.error === void 0 && o.recipientBlob !== void 0);
983
993
  let pending = journaled.length < committed.length;
984
994
  if (journaled.length === 0) return pending;
985
- const options = { transferId, ...memo !== void 0 ? { memo } : {} };
995
+ const options = {
996
+ transferId,
997
+ ...memo !== void 0 ? { memo } : {},
998
+ ...senderNametagOption(this.deps.ownNametag)
999
+ };
986
1000
  if (await this.tryBatchDeposit(recipientPubkey, journaled, options)) return pending;
987
1001
  for (const outcome of journaled) {
988
1002
  const stillPending = await this.deliverOne(recipientPubkey, outcome, options);
@@ -1416,6 +1430,9 @@ var Converger = class {
1416
1430
  return {
1417
1431
  delivery: this.deps.delivery,
1418
1432
  now: () => this.deps.now(),
1433
+ // sphere#487: a replayed leg carries the sender's name too — the machine
1434
+ // deps hold the one live getter, so replay can never drift from a send.
1435
+ ...this.deps.machineDeps.ownNametag !== void 0 ? { ownNametag: this.deps.machineDeps.ownNametag } : {},
1419
1436
  attention: (transferId, code, detail) => {
1420
1437
  this.deps.emit(
1421
1438
  "transfer:attention",
@@ -4001,6 +4018,9 @@ function buildMachineDeps(deps, hooks, historyStore) {
4001
4018
  decryptPayload: async (envelope) => JSON.parse(decryptField(deps.fieldKey, envelope)),
4002
4019
  signComplete: deps.signComplete,
4003
4020
  ownPubkey: hexToBytes(deps.ownPubkey),
4021
+ // sphere#487: the same live getter Requests uses — the delivery envelope is
4022
+ // the recipient's ONLY source for the sender's Unicity ID.
4023
+ ...deps.ownNametag !== void 0 ? { ownNametag: deps.ownNametag } : {},
4004
4024
  emit: deps.emit,
4005
4025
  now: deps.now ?? Date.now,
4006
4026
  recordHistory: async ({ transferId, payload, committedAmount }) => {