@unicitylabs/sphere-sdk 0.6.8-dev.1 → 0.6.8-dev.3

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 (44) hide show
  1. package/README.md +30 -0
  2. package/dist/connect/index.cjs +2 -0
  3. package/dist/connect/index.cjs.map +1 -1
  4. package/dist/connect/index.js +2 -0
  5. package/dist/connect/index.js.map +1 -1
  6. package/dist/core/index.cjs +151 -6
  7. package/dist/core/index.cjs.map +1 -1
  8. package/dist/core/index.d.cts +20 -0
  9. package/dist/core/index.d.ts +20 -0
  10. package/dist/core/index.js +151 -6
  11. package/dist/core/index.js.map +1 -1
  12. package/dist/impl/browser/connect/index.cjs +2 -0
  13. package/dist/impl/browser/connect/index.cjs.map +1 -1
  14. package/dist/impl/browser/connect/index.js +2 -0
  15. package/dist/impl/browser/connect/index.js.map +1 -1
  16. package/dist/impl/browser/index.cjs +66 -0
  17. package/dist/impl/browser/index.cjs.map +1 -1
  18. package/dist/impl/browser/index.js +66 -0
  19. package/dist/impl/browser/index.js.map +1 -1
  20. package/dist/impl/browser/ipfs.cjs +2 -0
  21. package/dist/impl/browser/ipfs.cjs.map +1 -1
  22. package/dist/impl/browser/ipfs.js +2 -0
  23. package/dist/impl/browser/ipfs.js.map +1 -1
  24. package/dist/impl/nodejs/connect/index.cjs +2 -0
  25. package/dist/impl/nodejs/connect/index.cjs.map +1 -1
  26. package/dist/impl/nodejs/connect/index.js +2 -0
  27. package/dist/impl/nodejs/connect/index.js.map +1 -1
  28. package/dist/impl/nodejs/index.cjs +66 -0
  29. package/dist/impl/nodejs/index.cjs.map +1 -1
  30. package/dist/impl/nodejs/index.d.cts +15 -0
  31. package/dist/impl/nodejs/index.d.ts +15 -0
  32. package/dist/impl/nodejs/index.js +66 -0
  33. package/dist/impl/nodejs/index.js.map +1 -1
  34. package/dist/index.cjs +151 -6
  35. package/dist/index.cjs.map +1 -1
  36. package/dist/index.d.cts +20 -0
  37. package/dist/index.d.ts +20 -0
  38. package/dist/index.js +151 -6
  39. package/dist/index.js.map +1 -1
  40. package/dist/l1/index.cjs +2 -0
  41. package/dist/l1/index.cjs.map +1 -1
  42. package/dist/l1/index.js +2 -0
  43. package/dist/l1/index.js.map +1 -1
  44. package/package.json +1 -1
package/dist/index.d.cts CHANGED
@@ -1995,6 +1995,14 @@ interface TransportProvider extends BaseProvider {
1995
1995
  * @param sinceSeconds - Unix timestamp in seconds
1996
1996
  */
1997
1997
  setFallbackSince?(sinceSeconds: number): void;
1998
+ /**
1999
+ * Set fallback 'since' timestamp for DM (gift-wrap) subscriptions.
2000
+ * Used when no persisted DM timestamp exists in storage (e.g. first connect).
2001
+ * Consumed once by the next subscription setup, then cleared.
2002
+ *
2003
+ * @param sinceSeconds - Unix timestamp in seconds
2004
+ */
2005
+ setFallbackDmSince?(sinceSeconds: number): void;
1998
2006
  /**
1999
2007
  * Fetch pending events from transport (one-shot query).
2000
2008
  * Creates a temporary subscription, processes events through normal handlers,
@@ -3960,6 +3968,8 @@ declare const STORAGE_KEYS_GLOBAL: {
3960
3968
  readonly TRACKED_ADDRESSES: "tracked_addresses";
3961
3969
  /** Last processed Nostr wallet event timestamp (unix seconds), keyed per pubkey */
3962
3970
  readonly LAST_WALLET_EVENT_TS: "last_wallet_event_ts";
3971
+ /** Last processed Nostr DM (gift-wrap) event timestamp (unix seconds), keyed per pubkey */
3972
+ readonly LAST_DM_EVENT_TS: "last_dm_event_ts";
3963
3973
  /** Group chat: last used relay URL (stale data detection) — global, same relay for all addresses */
3964
3974
  readonly GROUP_CHAT_RELAY_URL: "group_chat_relay_url";
3965
3975
  /** Cached token registry JSON (fetched from remote) */
@@ -4055,6 +4065,8 @@ declare const STORAGE_KEYS: {
4055
4065
  readonly TRACKED_ADDRESSES: "tracked_addresses";
4056
4066
  /** Last processed Nostr wallet event timestamp (unix seconds), keyed per pubkey */
4057
4067
  readonly LAST_WALLET_EVENT_TS: "last_wallet_event_ts";
4068
+ /** Last processed Nostr DM (gift-wrap) event timestamp (unix seconds), keyed per pubkey */
4069
+ readonly LAST_DM_EVENT_TS: "last_dm_event_ts";
4058
4070
  /** Group chat: last used relay URL (stale data detection) — global, same relay for all addresses */
4059
4071
  readonly GROUP_CHAT_RELAY_URL: "group_chat_relay_url";
4060
4072
  /** Cached token registry JSON (fetched from remote) */
@@ -4606,6 +4618,12 @@ interface SphereInitOptions {
4606
4618
  * - false/undefined: no auto-discovery (default)
4607
4619
  */
4608
4620
  discoverAddresses?: boolean | DiscoverAddressesOptions;
4621
+ /**
4622
+ * Fallback 'since' timestamp (unix seconds) for the DM (gift-wrap) subscription.
4623
+ * Used when no persisted DM timestamp exists in storage (e.g. first connect).
4624
+ * Without this, a fresh wallet starts from "now" and misses older DMs.
4625
+ */
4626
+ dmSince?: number;
4609
4627
  /** Enable debug logging (default: false) */
4610
4628
  debug?: boolean;
4611
4629
  /** Optional callback to report initialization progress steps */
@@ -4650,6 +4668,8 @@ declare class Sphere {
4650
4668
  private _market;
4651
4669
  private _addressModules;
4652
4670
  private _transportMux;
4671
+ /** Fallback DM since timestamp from init options, forwarded to mux on creation. */
4672
+ private _dmSince;
4653
4673
  private _l1Config;
4654
4674
  private _groupChatConfig;
4655
4675
  private _marketConfig;
package/dist/index.d.ts CHANGED
@@ -1995,6 +1995,14 @@ interface TransportProvider extends BaseProvider {
1995
1995
  * @param sinceSeconds - Unix timestamp in seconds
1996
1996
  */
1997
1997
  setFallbackSince?(sinceSeconds: number): void;
1998
+ /**
1999
+ * Set fallback 'since' timestamp for DM (gift-wrap) subscriptions.
2000
+ * Used when no persisted DM timestamp exists in storage (e.g. first connect).
2001
+ * Consumed once by the next subscription setup, then cleared.
2002
+ *
2003
+ * @param sinceSeconds - Unix timestamp in seconds
2004
+ */
2005
+ setFallbackDmSince?(sinceSeconds: number): void;
1998
2006
  /**
1999
2007
  * Fetch pending events from transport (one-shot query).
2000
2008
  * Creates a temporary subscription, processes events through normal handlers,
@@ -3960,6 +3968,8 @@ declare const STORAGE_KEYS_GLOBAL: {
3960
3968
  readonly TRACKED_ADDRESSES: "tracked_addresses";
3961
3969
  /** Last processed Nostr wallet event timestamp (unix seconds), keyed per pubkey */
3962
3970
  readonly LAST_WALLET_EVENT_TS: "last_wallet_event_ts";
3971
+ /** Last processed Nostr DM (gift-wrap) event timestamp (unix seconds), keyed per pubkey */
3972
+ readonly LAST_DM_EVENT_TS: "last_dm_event_ts";
3963
3973
  /** Group chat: last used relay URL (stale data detection) — global, same relay for all addresses */
3964
3974
  readonly GROUP_CHAT_RELAY_URL: "group_chat_relay_url";
3965
3975
  /** Cached token registry JSON (fetched from remote) */
@@ -4055,6 +4065,8 @@ declare const STORAGE_KEYS: {
4055
4065
  readonly TRACKED_ADDRESSES: "tracked_addresses";
4056
4066
  /** Last processed Nostr wallet event timestamp (unix seconds), keyed per pubkey */
4057
4067
  readonly LAST_WALLET_EVENT_TS: "last_wallet_event_ts";
4068
+ /** Last processed Nostr DM (gift-wrap) event timestamp (unix seconds), keyed per pubkey */
4069
+ readonly LAST_DM_EVENT_TS: "last_dm_event_ts";
4058
4070
  /** Group chat: last used relay URL (stale data detection) — global, same relay for all addresses */
4059
4071
  readonly GROUP_CHAT_RELAY_URL: "group_chat_relay_url";
4060
4072
  /** Cached token registry JSON (fetched from remote) */
@@ -4606,6 +4618,12 @@ interface SphereInitOptions {
4606
4618
  * - false/undefined: no auto-discovery (default)
4607
4619
  */
4608
4620
  discoverAddresses?: boolean | DiscoverAddressesOptions;
4621
+ /**
4622
+ * Fallback 'since' timestamp (unix seconds) for the DM (gift-wrap) subscription.
4623
+ * Used when no persisted DM timestamp exists in storage (e.g. first connect).
4624
+ * Without this, a fresh wallet starts from "now" and misses older DMs.
4625
+ */
4626
+ dmSince?: number;
4609
4627
  /** Enable debug logging (default: false) */
4610
4628
  debug?: boolean;
4611
4629
  /** Optional callback to report initialization progress steps */
@@ -4650,6 +4668,8 @@ declare class Sphere {
4650
4668
  private _market;
4651
4669
  private _addressModules;
4652
4670
  private _transportMux;
4671
+ /** Fallback DM since timestamp from init options, forwarded to mux on creation. */
4672
+ private _dmSince;
4653
4673
  private _l1Config;
4654
4674
  private _groupChatConfig;
4655
4675
  private _marketConfig;
package/dist/index.js CHANGED
@@ -179,6 +179,8 @@ var init_constants = __esm({
179
179
  TRACKED_ADDRESSES: "tracked_addresses",
180
180
  /** Last processed Nostr wallet event timestamp (unix seconds), keyed per pubkey */
181
181
  LAST_WALLET_EVENT_TS: "last_wallet_event_ts",
182
+ /** Last processed Nostr DM (gift-wrap) event timestamp (unix seconds), keyed per pubkey */
183
+ LAST_DM_EVENT_TS: "last_dm_event_ts",
182
184
  /** Group chat: last used relay URL (stale data detection) — global, same relay for all addresses */
183
185
  GROUP_CHAT_RELAY_URL: "group_chat_relay_url",
184
186
  /** Cached token registry JSON (fetched from remote) */
@@ -1261,8 +1263,12 @@ var NostrTransportProvider = class _NostrTransportProvider {
1261
1263
  storage = null;
1262
1264
  /** In-memory max event timestamp to avoid read-before-write races in updateLastEventTimestamp. */
1263
1265
  lastEventTs = 0;
1266
+ /** In-memory max DM (gift-wrap) event timestamp. */
1267
+ lastDmEventTs = 0;
1264
1268
  /** Fallback 'since' timestamp for first-time address subscriptions (consumed once). */
1265
1269
  fallbackSince = null;
1270
+ /** Fallback 'since' timestamp for DM (gift-wrap) subscriptions (consumed once). */
1271
+ fallbackDmSince = null;
1266
1272
  identity = null;
1267
1273
  keyManager = null;
1268
1274
  status = "disconnected";
@@ -1517,6 +1523,8 @@ var NostrTransportProvider = class _NostrTransportProvider {
1517
1523
  this.identity = identity;
1518
1524
  this.processedEventIds.clear();
1519
1525
  this.lastEventTs = 0;
1526
+ this.lastDmEventTs = 0;
1527
+ this.fallbackDmSince = null;
1520
1528
  const secretKey = Buffer2.from(identity.privateKey, "hex");
1521
1529
  this.keyManager = NostrKeyManager.fromPrivateKey(secretKey);
1522
1530
  const nostrPubkey = this.keyManager.getPublicKeyHex();
@@ -1562,6 +1570,9 @@ var NostrTransportProvider = class _NostrTransportProvider {
1562
1570
  setFallbackSince(sinceSeconds) {
1563
1571
  this.fallbackSince = sinceSeconds;
1564
1572
  }
1573
+ setFallbackDmSince(sinceSeconds) {
1574
+ this.fallbackDmSince = sinceSeconds;
1575
+ }
1565
1576
  /**
1566
1577
  * Get the Nostr-format public key (32 bytes / 64 hex chars)
1567
1578
  * This is the x-coordinate only, without the 02/03 prefix.
@@ -2096,6 +2107,17 @@ var NostrTransportProvider = class _NostrTransportProvider {
2096
2107
  logger.debug("Nostr", "Failed to save last event timestamp:", err);
2097
2108
  });
2098
2109
  }
2110
+ /** Persist the max DM (gift-wrap) event timestamp for the since filter on next connect. */
2111
+ updateLastDmEventTimestamp(createdAt) {
2112
+ if (!this.storage || !this.keyManager) return;
2113
+ if (createdAt <= this.lastDmEventTs) return;
2114
+ this.lastDmEventTs = createdAt;
2115
+ const pubkey = this.keyManager.getPublicKeyHex();
2116
+ const storageKey = `${STORAGE_KEYS_GLOBAL.LAST_DM_EVENT_TS}_${pubkey.slice(0, 16)}`;
2117
+ this.storage.set(storageKey, createdAt.toString()).catch((err) => {
2118
+ logger.debug("Nostr", "Failed to save last DM event timestamp:", err);
2119
+ });
2120
+ }
2099
2121
  async handleDirectMessage(event) {
2100
2122
  logger.debug("Nostr", "Ignoring NIP-04 kind 4 event (DMs use NIP-17):", event.id?.slice(0, 12));
2101
2123
  }
@@ -2106,6 +2128,9 @@ var NostrTransportProvider = class _NostrTransportProvider {
2106
2128
  }
2107
2129
  try {
2108
2130
  const pm = NIP17.unwrap(event, this.keyManager);
2131
+ if (event.created_at) {
2132
+ this.updateLastDmEventTimestamp(event.created_at);
2133
+ }
2109
2134
  logger.debug("Nostr", "Gift wrap unwrapped, sender:", pm.senderPubkey?.slice(0, 16), "kind:", pm.kind);
2110
2135
  if (pm.senderPubkey === this.keyManager.getPublicKeyHex()) {
2111
2136
  try {
@@ -2552,9 +2577,50 @@ var NostrTransportProvider = class _NostrTransportProvider {
2552
2577
  }
2553
2578
  });
2554
2579
  logger.debug("Nostr", "Wallet subscription created, subId:", this.walletSubscriptionId);
2580
+ let dmSince;
2581
+ if (this.storage) {
2582
+ const dmStorageKey = `${STORAGE_KEYS_GLOBAL.LAST_DM_EVENT_TS}_${nostrPubkey.slice(0, 16)}`;
2583
+ try {
2584
+ const stored = await this.storage.get(dmStorageKey);
2585
+ const parsed = stored ? parseInt(stored, 10) : NaN;
2586
+ if (Number.isFinite(parsed)) {
2587
+ dmSince = parsed;
2588
+ this.lastDmEventTs = dmSince;
2589
+ this.fallbackDmSince = null;
2590
+ logger.debug("Nostr", "DM resuming from stored timestamp:", dmSince);
2591
+ } else if (this.fallbackDmSince !== null) {
2592
+ dmSince = this.fallbackDmSince;
2593
+ this.lastDmEventTs = dmSince;
2594
+ this.fallbackDmSince = null;
2595
+ logger.debug("Nostr", "DM using fallback since timestamp:", dmSince);
2596
+ } else {
2597
+ dmSince = Math.floor(Date.now() / 1e3);
2598
+ logger.debug("Nostr", "No stored DM timestamp, starting from now:", dmSince);
2599
+ }
2600
+ } catch (err) {
2601
+ if (this.fallbackDmSince !== null) {
2602
+ dmSince = this.fallbackDmSince;
2603
+ this.lastDmEventTs = dmSince;
2604
+ this.fallbackDmSince = null;
2605
+ logger.debug("Nostr", "Storage read failed, using DM fallback since:", dmSince, err);
2606
+ } else {
2607
+ dmSince = Math.floor(Date.now() / 1e3);
2608
+ logger.debug("Nostr", "Failed to read last DM event timestamp, falling back to now:", err);
2609
+ }
2610
+ }
2611
+ } else if (this.fallbackDmSince !== null) {
2612
+ dmSince = this.fallbackDmSince;
2613
+ this.lastDmEventTs = dmSince;
2614
+ this.fallbackDmSince = null;
2615
+ logger.debug("Nostr", "No storage adapter for DM, using fallback since:", dmSince);
2616
+ } else {
2617
+ dmSince = Math.floor(Date.now() / 1e3);
2618
+ logger.debug("Nostr", "No storage adapter for DM, starting from now:", dmSince);
2619
+ }
2555
2620
  const chatFilter = new Filter();
2556
2621
  chatFilter.kinds = [EventKinds.GIFT_WRAP];
2557
2622
  chatFilter["#p"] = [nostrPubkey];
2623
+ chatFilter.since = dmSince;
2558
2624
  this.chatSubscriptionId = this.nostrClient.subscribe(chatFilter, {
2559
2625
  onEvent: (event) => {
2560
2626
  logger.debug("Nostr", "Received chat event kind:", event.kind, "id:", event.id?.slice(0, 12));
@@ -2799,7 +2865,9 @@ var MultiAddressTransportMux = class {
2799
2865
  nostrPubkey,
2800
2866
  adapter,
2801
2867
  lastEventTs: 0,
2802
- fallbackSince: null
2868
+ lastDmEventTs: 0,
2869
+ fallbackSince: null,
2870
+ fallbackDmSince: null
2803
2871
  };
2804
2872
  this.addresses.set(index, entry);
2805
2873
  this.pubkeyToIndex.set(nostrPubkey, index);
@@ -2841,6 +2909,12 @@ var MultiAddressTransportMux = class {
2841
2909
  entry.fallbackSince = sinceSeconds;
2842
2910
  }
2843
2911
  }
2912
+ setFallbackDmSince(index, sinceSeconds) {
2913
+ const entry = this.addresses.get(index);
2914
+ if (entry) {
2915
+ entry.fallbackDmSince = sinceSeconds;
2916
+ }
2917
+ }
2844
2918
  // ===========================================================================
2845
2919
  // Connection Management (delegated from adapters)
2846
2920
  // ===========================================================================
@@ -2976,11 +3050,20 @@ var MultiAddressTransportMux = class {
2976
3050
  }
2977
3051
  logger.debug("Mux", `Subscribing for ${allPubkeys.length} address(es):`, allPubkeys.map((p) => p.slice(0, 12)).join(", "));
2978
3052
  let globalSince = Math.floor(Date.now() / 1e3);
2979
- for (const entry of this.addresses.values()) {
2980
- const since = await this.getAddressSince(entry);
2981
- if (since < globalSince) {
2982
- globalSince = since;
2983
- }
3053
+ let globalDmSince = Math.floor(Date.now() / 1e3);
3054
+ const entries = [...this.addresses.values()];
3055
+ const sinceResults = await Promise.all(
3056
+ entries.map(async (entry) => {
3057
+ const [walletSince, dmSince] = await Promise.all([
3058
+ this.getAddressSince(entry),
3059
+ this.getAddressDmSince(entry)
3060
+ ]);
3061
+ return { walletSince, dmSince };
3062
+ })
3063
+ );
3064
+ for (const { walletSince, dmSince } of sinceResults) {
3065
+ if (walletSince < globalSince) globalSince = walletSince;
3066
+ if (dmSince < globalDmSince) globalDmSince = dmSince;
2984
3067
  }
2985
3068
  const walletFilter = new Filter2();
2986
3069
  walletFilter.kinds = [
@@ -3013,6 +3096,7 @@ var MultiAddressTransportMux = class {
3013
3096
  const chatFilter = new Filter2();
3014
3097
  chatFilter.kinds = [EventKinds2.GIFT_WRAP];
3015
3098
  chatFilter["#p"] = allPubkeys;
3099
+ chatFilter.since = globalDmSince;
3016
3100
  this.chatSubscriptionId = this.nostrClient.subscribe(chatFilter, {
3017
3101
  onEvent: (event) => {
3018
3102
  this.handleEvent({
@@ -3119,6 +3203,9 @@ var MultiAddressTransportMux = class {
3119
3203
  for (const entry of this.addresses.values()) {
3120
3204
  try {
3121
3205
  const pm = NIP172.unwrap(event, entry.keyManager);
3206
+ if (event.created_at) {
3207
+ this.updateLastDmEventTimestamp(entry, event.created_at);
3208
+ }
3122
3209
  logger.debug("Mux", `Gift wrap decrypted by address ${entry.index}, sender: ${pm.senderPubkey?.slice(0, 16)}`);
3123
3210
  if (pm.senderPubkey === entry.nostrPubkey) {
3124
3211
  try {
@@ -3475,6 +3562,47 @@ var MultiAddressTransportMux = class {
3475
3562
  logger.debug("Mux", "Failed to save last event timestamp:", err);
3476
3563
  });
3477
3564
  }
3565
+ updateLastDmEventTimestamp(entry, createdAt) {
3566
+ if (!this.storage) return;
3567
+ if (createdAt <= entry.lastDmEventTs) return;
3568
+ entry.lastDmEventTs = createdAt;
3569
+ const storageKey = `${STORAGE_KEYS_GLOBAL.LAST_DM_EVENT_TS}_${entry.nostrPubkey.slice(0, 16)}`;
3570
+ this.storage.set(storageKey, createdAt.toString()).catch((err) => {
3571
+ logger.debug("Mux", "Failed to save last DM event timestamp:", err);
3572
+ });
3573
+ }
3574
+ async getAddressDmSince(entry) {
3575
+ if (this.storage) {
3576
+ const storageKey = `${STORAGE_KEYS_GLOBAL.LAST_DM_EVENT_TS}_${entry.nostrPubkey.slice(0, 16)}`;
3577
+ try {
3578
+ const stored = await this.storage.get(storageKey);
3579
+ const parsed = stored ? parseInt(stored, 10) : NaN;
3580
+ if (Number.isFinite(parsed)) {
3581
+ entry.lastDmEventTs = parsed;
3582
+ entry.fallbackDmSince = null;
3583
+ return parsed;
3584
+ } else if (entry.fallbackDmSince !== null) {
3585
+ const ts = entry.fallbackDmSince;
3586
+ entry.lastDmEventTs = ts;
3587
+ entry.fallbackDmSince = null;
3588
+ return ts;
3589
+ }
3590
+ } catch {
3591
+ if (entry.fallbackDmSince !== null) {
3592
+ const ts = entry.fallbackDmSince;
3593
+ entry.lastDmEventTs = ts;
3594
+ entry.fallbackDmSince = null;
3595
+ return ts;
3596
+ }
3597
+ }
3598
+ } else if (entry.fallbackDmSince !== null) {
3599
+ const ts = entry.fallbackDmSince;
3600
+ entry.lastDmEventTs = ts;
3601
+ entry.fallbackDmSince = null;
3602
+ return ts;
3603
+ }
3604
+ return Math.floor(Date.now() / 1e3);
3605
+ }
3478
3606
  // ===========================================================================
3479
3607
  // Mux-level event system
3480
3608
  // ===========================================================================
@@ -3771,6 +3899,9 @@ var AddressTransportAdapter = class {
3771
3899
  setFallbackSince(sinceSeconds) {
3772
3900
  this.mux.setFallbackSince(this.addressIndex, sinceSeconds);
3773
3901
  }
3902
+ setFallbackDmSince(sinceSeconds) {
3903
+ this.mux.setFallbackDmSince(this.addressIndex, sinceSeconds);
3904
+ }
3774
3905
  async fetchPendingEvents() {
3775
3906
  }
3776
3907
  onChatReady(handler) {
@@ -16590,6 +16721,8 @@ var Sphere = class _Sphere {
16590
16721
  // Per-address module instances (Phase 2: independent parallel operation)
16591
16722
  _addressModules = /* @__PURE__ */ new Map();
16592
16723
  _transportMux = null;
16724
+ /** Fallback DM since timestamp from init options, forwarded to mux on creation. */
16725
+ _dmSince = null;
16593
16726
  // Stored configs for creating per-address modules
16594
16727
  _l1Config;
16595
16728
  _groupChatConfig;
@@ -16691,6 +16824,9 @@ var Sphere = class _Sphere {
16691
16824
  discoverAddresses: options.discoverAddresses,
16692
16825
  onProgress: options.onProgress
16693
16826
  });
16827
+ if (options.dmSince != null) {
16828
+ sphere2._dmSince = options.dmSince;
16829
+ }
16694
16830
  return { sphere: sphere2, created: false };
16695
16831
  }
16696
16832
  let mnemonic = options.mnemonic;
@@ -16722,6 +16858,9 @@ var Sphere = class _Sphere {
16722
16858
  discoverAddresses: options.discoverAddresses,
16723
16859
  onProgress: options.onProgress
16724
16860
  });
16861
+ if (options.dmSince != null) {
16862
+ sphere._dmSince = options.dmSince;
16863
+ }
16725
16864
  return { sphere, created: true, generatedMnemonic };
16726
16865
  }
16727
16866
  /**
@@ -17995,6 +18134,9 @@ var Sphere = class _Sphere {
17995
18134
  const emitEvent = this.emitEvent.bind(this);
17996
18135
  const adapter = await this.ensureTransportMux(index, identity);
17997
18136
  const addressTransport = adapter ?? this._transport;
18137
+ if (!adapter && this._dmSince != null && addressTransport.setFallbackDmSince) {
18138
+ addressTransport.setFallbackDmSince(this._dmSince);
18139
+ }
17998
18140
  const payments = createPaymentsModule({ l1: this._l1Config });
17999
18141
  const communications = createCommunicationsModule();
18000
18142
  const groupChat = this._groupChatConfig ? createGroupChatModule(this._groupChatConfig) : null;
@@ -18078,6 +18220,9 @@ var Sphere = class _Sphere {
18078
18220
  }
18079
18221
  logger.debug("Sphere", "Transport mux created and connected");
18080
18222
  }
18223
+ if (this._dmSince != null) {
18224
+ this._transportMux.setFallbackDmSince(index, this._dmSince);
18225
+ }
18081
18226
  const adapter = await this._transportMux.addAddress(index, identity, this._transport);
18082
18227
  return adapter;
18083
18228
  }