@unicitylabs/sphere-sdk 0.3.5 → 0.3.7

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.
package/dist/index.d.ts CHANGED
@@ -1162,7 +1162,7 @@ interface TrackedAddress extends TrackedAddressEntry {
1162
1162
  /** Primary nametag (from nametag cache, without @ prefix) */
1163
1163
  readonly nametag?: string;
1164
1164
  }
1165
- type SphereEventType = 'transfer:incoming' | 'transfer:confirmed' | 'transfer:failed' | 'payment_request:incoming' | 'payment_request:accepted' | 'payment_request:rejected' | 'payment_request:paid' | 'payment_request:response' | 'message:dm' | 'message:broadcast' | 'sync:started' | 'sync:completed' | 'sync:provider' | 'sync:error' | 'connection:changed' | 'nametag:registered' | 'nametag:recovered' | 'identity:changed' | 'address:activated' | 'address:hidden' | 'address:unhidden' | 'sync:remote-update' | 'groupchat:message' | 'groupchat:joined' | 'groupchat:left' | 'groupchat:kicked' | 'groupchat:group_deleted' | 'groupchat:updated' | 'groupchat:connection';
1165
+ type SphereEventType = 'transfer:incoming' | 'transfer:confirmed' | 'transfer:failed' | 'payment_request:incoming' | 'payment_request:accepted' | 'payment_request:rejected' | 'payment_request:paid' | 'payment_request:response' | 'message:dm' | 'message:read' | 'message:typing' | 'message:broadcast' | 'sync:started' | 'sync:completed' | 'sync:provider' | 'sync:error' | 'connection:changed' | 'nametag:registered' | 'nametag:recovered' | 'identity:changed' | 'address:activated' | 'address:hidden' | 'address:unhidden' | 'sync:remote-update' | 'groupchat:message' | 'groupchat:joined' | 'groupchat:left' | 'groupchat:kicked' | 'groupchat:group_deleted' | 'groupchat:updated' | 'groupchat:connection';
1166
1166
  interface SphereEventMap {
1167
1167
  'transfer:incoming': IncomingTransfer;
1168
1168
  'transfer:confirmed': TransferResult;
@@ -1173,6 +1173,15 @@ interface SphereEventMap {
1173
1173
  'payment_request:paid': IncomingPaymentRequest$1;
1174
1174
  'payment_request:response': PaymentRequestResponse;
1175
1175
  'message:dm': DirectMessage;
1176
+ 'message:read': {
1177
+ messageIds: string[];
1178
+ peerPubkey: string;
1179
+ };
1180
+ 'message:typing': {
1181
+ senderPubkey: string;
1182
+ senderNametag?: string;
1183
+ timestamp: number;
1184
+ };
1176
1185
  'message:broadcast': BroadcastMessage;
1177
1186
  'sync:started': {
1178
1187
  source: string;
@@ -1542,6 +1551,27 @@ interface TransportProvider extends BaseProvider {
1542
1551
  * @returns Unsubscribe function
1543
1552
  */
1544
1553
  onPaymentRequestResponse?(handler: PaymentRequestResponseHandler): () => void;
1554
+ /**
1555
+ * Send a read receipt for a message
1556
+ * @param recipientTransportPubkey - Transport pubkey of the message sender
1557
+ * @param messageEventId - Event ID of the message being acknowledged
1558
+ */
1559
+ sendReadReceipt?(recipientTransportPubkey: string, messageEventId: string): Promise<void>;
1560
+ /**
1561
+ * Subscribe to incoming read receipts
1562
+ * @returns Unsubscribe function
1563
+ */
1564
+ onReadReceipt?(handler: ReadReceiptHandler): () => void;
1565
+ /**
1566
+ * Send typing indicator to a recipient
1567
+ * @param recipientTransportPubkey - Transport pubkey of the conversation partner
1568
+ */
1569
+ sendTypingIndicator?(recipientTransportPubkey: string): Promise<void>;
1570
+ /**
1571
+ * Subscribe to incoming typing indicators
1572
+ * @returns Unsubscribe function
1573
+ */
1574
+ onTypingIndicator?(handler: TypingIndicatorHandler): () => void;
1545
1575
  /**
1546
1576
  * Get list of configured relay URLs
1547
1577
  */
@@ -1631,6 +1661,10 @@ interface IncomingMessage {
1631
1661
  content: string;
1632
1662
  timestamp: number;
1633
1663
  encrypted: boolean;
1664
+ /** Set when this is a self-wrap replay (sent message recovered from relay) */
1665
+ isSelfWrap?: boolean;
1666
+ /** Recipient pubkey — only present on self-wrap replays */
1667
+ recipientTransportPubkey?: string;
1634
1668
  }
1635
1669
  type MessageHandler = (message: IncomingMessage) => void;
1636
1670
  interface TokenTransferPayload {
@@ -1752,6 +1786,24 @@ interface PeerInfo {
1752
1786
  /** Event timestamp */
1753
1787
  timestamp: number;
1754
1788
  }
1789
+ interface IncomingReadReceipt {
1790
+ /** Transport-specific pubkey of the sender who read the message */
1791
+ senderTransportPubkey: string;
1792
+ /** Event ID of the message that was read */
1793
+ messageEventId: string;
1794
+ /** Timestamp */
1795
+ timestamp: number;
1796
+ }
1797
+ type ReadReceiptHandler = (receipt: IncomingReadReceipt) => void;
1798
+ interface IncomingTypingIndicator {
1799
+ /** Transport-specific pubkey of the sender who is typing */
1800
+ senderTransportPubkey: string;
1801
+ /** Sender's nametag (if known) */
1802
+ senderNametag?: string;
1803
+ /** Timestamp */
1804
+ timestamp: number;
1805
+ }
1806
+ type TypingIndicatorHandler = (indicator: IncomingTypingIndicator) => void;
1755
1807
 
1756
1808
  /**
1757
1809
  * L1 Payments Sub-Module
@@ -3170,6 +3222,10 @@ declare class CommunicationsModule {
3170
3222
  * Get unread count
3171
3223
  */
3172
3224
  getUnreadCount(peerPubkey?: string): number;
3225
+ /**
3226
+ * Send typing indicator to a peer
3227
+ */
3228
+ sendTypingIndicator(peerPubkey: string): Promise<void>;
3173
3229
  /**
3174
3230
  * Subscribe to incoming DMs
3175
3231
  */
@@ -3320,6 +3376,155 @@ declare class GroupChatModule {
3320
3376
  }
3321
3377
  declare function createGroupChatModule(config?: GroupChatModuleConfig): GroupChatModule;
3322
3378
 
3379
+ /**
3380
+ * Market Module Types
3381
+ * Intent bulletin board for posting and discovering intents,
3382
+ * plus real-time feed subscription.
3383
+ */
3384
+ type IntentType = 'buy' | 'sell' | 'service' | 'announcement' | 'other' | (string & {});
3385
+ type IntentStatus = 'active' | 'closed' | 'expired';
3386
+ interface MarketModuleConfig {
3387
+ /** Market API base URL (default: https://market-api.unicity.network) */
3388
+ apiUrl?: string;
3389
+ /** Request timeout in ms (default: 30000) */
3390
+ timeout?: number;
3391
+ }
3392
+ interface MarketModuleDependencies {
3393
+ identity: FullIdentity;
3394
+ emitEvent: <T extends SphereEventType>(type: T, data: SphereEventMap[T]) => void;
3395
+ }
3396
+ interface PostIntentRequest {
3397
+ description: string;
3398
+ intentType: IntentType;
3399
+ category?: string;
3400
+ price?: number;
3401
+ currency?: string;
3402
+ location?: string;
3403
+ contactHandle?: string;
3404
+ expiresInDays?: number;
3405
+ }
3406
+ interface PostIntentResult {
3407
+ intentId: string;
3408
+ message: string;
3409
+ expiresAt: string;
3410
+ }
3411
+ interface MarketIntent {
3412
+ id: string;
3413
+ intentType: IntentType;
3414
+ category?: string;
3415
+ price?: string;
3416
+ currency: string;
3417
+ location?: string;
3418
+ status: IntentStatus;
3419
+ createdAt: string;
3420
+ expiresAt: string;
3421
+ }
3422
+ interface SearchIntentResult {
3423
+ id: string;
3424
+ score: number;
3425
+ agentNametag?: string;
3426
+ agentPublicKey: string;
3427
+ description: string;
3428
+ intentType: IntentType;
3429
+ category?: string;
3430
+ price?: number;
3431
+ currency: string;
3432
+ location?: string;
3433
+ contactMethod: string;
3434
+ contactHandle?: string;
3435
+ createdAt: string;
3436
+ expiresAt: string;
3437
+ }
3438
+ interface SearchFilters {
3439
+ intentType?: IntentType;
3440
+ category?: string;
3441
+ minPrice?: number;
3442
+ maxPrice?: number;
3443
+ location?: string;
3444
+ /** Minimum similarity score (0–1). Results below this threshold are excluded (client-side). */
3445
+ minScore?: number;
3446
+ }
3447
+ interface SearchOptions {
3448
+ filters?: SearchFilters;
3449
+ limit?: number;
3450
+ }
3451
+ interface SearchResult {
3452
+ intents: SearchIntentResult[];
3453
+ count: number;
3454
+ }
3455
+ /** A listing broadcast on the live feed */
3456
+ interface FeedListing {
3457
+ id: string;
3458
+ title: string;
3459
+ descriptionPreview: string;
3460
+ agentName: string;
3461
+ agentId: number;
3462
+ type: IntentType;
3463
+ createdAt: string;
3464
+ }
3465
+ /** WebSocket message: initial batch of recent listings */
3466
+ interface FeedInitialMessage {
3467
+ type: 'initial';
3468
+ listings: FeedListing[];
3469
+ }
3470
+ /** WebSocket message: single new listing */
3471
+ interface FeedNewMessage {
3472
+ type: 'new';
3473
+ listing: FeedListing;
3474
+ }
3475
+ type FeedMessage = FeedInitialMessage | FeedNewMessage;
3476
+ /** Callback for live feed events */
3477
+ type FeedListener = (message: FeedMessage) => void;
3478
+
3479
+ /**
3480
+ * Market Module
3481
+ *
3482
+ * Intent bulletin board — post and discover intents (buy, sell,
3483
+ * service, announcement, other) with secp256k1-signed requests
3484
+ * tied to the wallet identity. Includes real-time feed via WebSocket.
3485
+ */
3486
+
3487
+ declare class MarketModule {
3488
+ private readonly apiUrl;
3489
+ private readonly timeout;
3490
+ private identity;
3491
+ private registered;
3492
+ constructor(config?: MarketModuleConfig);
3493
+ /** Called by Sphere after construction */
3494
+ initialize(deps: MarketModuleDependencies): void;
3495
+ /** No-op — stateless module */
3496
+ load(): Promise<void>;
3497
+ /** No-op — stateless module */
3498
+ destroy(): void;
3499
+ /** Post a new intent (agent is auto-registered on first post) */
3500
+ postIntent(intent: PostIntentRequest): Promise<PostIntentResult>;
3501
+ /** Semantic search for intents (public — no auth required) */
3502
+ search(query: string, opts?: SearchOptions): Promise<SearchResult>;
3503
+ /** List own intents (authenticated) */
3504
+ getMyIntents(): Promise<MarketIntent[]>;
3505
+ /** Close (delete) an intent */
3506
+ closeIntent(intentId: string): Promise<void>;
3507
+ /** Fetch the most recent listings via REST (public — no auth required) */
3508
+ getRecentListings(): Promise<FeedListing[]>;
3509
+ /**
3510
+ * Subscribe to the live listing feed via WebSocket.
3511
+ * Returns an unsubscribe function that closes the connection.
3512
+ *
3513
+ * Requires a WebSocket implementation — works natively in browsers
3514
+ * and in Node.js 21+ (or with the `ws` package).
3515
+ */
3516
+ subscribeFeed(listener: FeedListener): () => void;
3517
+ private ensureIdentity;
3518
+ /** Register the agent's public key with the server (idempotent) */
3519
+ private ensureRegistered;
3520
+ private parseResponse;
3521
+ private apiPost;
3522
+ private apiGet;
3523
+ private apiDelete;
3524
+ private apiPublicPost;
3525
+ }
3526
+ declare function createMarketModule(config?: MarketModuleConfig): MarketModule;
3527
+
3323
3528
  /**
3324
3529
  * SDK2 Constants
3325
3530
  * Default configuration values and storage keys
@@ -3374,6 +3579,10 @@ declare const STORAGE_KEYS: {
3374
3579
  readonly GROUP_CHAT_PROCESSED_EVENTS: "group_chat_processed_events";
3375
3580
  /** Group chat: last used relay URL (stale data detection) */
3376
3581
  readonly GROUP_CHAT_RELAY_URL: "group_chat_relay_url";
3582
+ /** Cached token registry JSON (fetched from remote) */
3583
+ readonly TOKEN_REGISTRY_CACHE: "token_registry_cache";
3584
+ /** Timestamp of last token registry cache update (ms since epoch) */
3585
+ readonly TOKEN_REGISTRY_CACHE_TS: "token_registry_cache_ts";
3377
3586
  };
3378
3587
  /** Default Nostr relays */
3379
3588
  declare const DEFAULT_NOSTR_RELAYS: readonly ["wss://relay.unicity.network", "wss://relay.damus.io", "wss://nos.lol", "wss://relay.nostr.band"];
@@ -3472,6 +3681,7 @@ declare const NETWORKS: {
3472
3681
  readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
3473
3682
  readonly electrumUrl: "wss://fulcrum.alpha.unicity.network:50004";
3474
3683
  readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
3684
+ readonly tokenRegistryUrl: "https://raw.githubusercontent.com/unicitynetwork/unicity-ids/refs/heads/main/unicity-ids.testnet.json";
3475
3685
  };
3476
3686
  readonly testnet: {
3477
3687
  readonly name: "Testnet";
@@ -3480,6 +3690,7 @@ declare const NETWORKS: {
3480
3690
  readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
3481
3691
  readonly electrumUrl: "wss://fulcrum.alpha.testnet.unicity.network:50004";
3482
3692
  readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
3693
+ readonly tokenRegistryUrl: "https://raw.githubusercontent.com/unicitynetwork/unicity-ids/refs/heads/main/unicity-ids.testnet.json";
3483
3694
  };
3484
3695
  readonly dev: {
3485
3696
  readonly name: "Development";
@@ -3488,6 +3699,7 @@ declare const NETWORKS: {
3488
3699
  readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
3489
3700
  readonly electrumUrl: "wss://fulcrum.alpha.testnet.unicity.network:50004";
3490
3701
  readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
3702
+ readonly tokenRegistryUrl: "https://raw.githubusercontent.com/unicitynetwork/unicity-ids/refs/heads/main/unicity-ids.testnet.json";
3491
3703
  };
3492
3704
  };
3493
3705
  type NetworkType = keyof typeof NETWORKS;
@@ -3504,6 +3716,8 @@ declare const TIMEOUTS: {
3504
3716
  /** Sync interval */
3505
3717
  readonly SYNC_INTERVAL: 60000;
3506
3718
  };
3719
+ /** Default Market API URL (intent bulletin board) */
3720
+ declare const DEFAULT_MARKET_API_URL: "https://market-api.unicity.network";
3507
3721
  /** Validation limits */
3508
3722
  declare const LIMITS: {
3509
3723
  /** Min nametag length */
@@ -3669,6 +3883,8 @@ interface SphereCreateOptions {
3669
3883
  groupChat?: GroupChatModuleConfig | boolean;
3670
3884
  /** Optional password to encrypt the wallet. If omitted, mnemonic is stored as plaintext. */
3671
3885
  password?: string;
3886
+ /** Market module configuration. true = enable with defaults, object = custom config. */
3887
+ market?: MarketModuleConfig | boolean;
3672
3888
  }
3673
3889
  /** Options for loading existing wallet */
3674
3890
  interface SphereLoadOptions {
@@ -3694,6 +3910,8 @@ interface SphereLoadOptions {
3694
3910
  groupChat?: GroupChatModuleConfig | boolean;
3695
3911
  /** Optional password to decrypt the wallet. Must match the password used during creation. */
3696
3912
  password?: string;
3913
+ /** Market module configuration. true = enable with defaults, object = custom config. */
3914
+ market?: MarketModuleConfig | boolean;
3697
3915
  }
3698
3916
  /** Options for importing a wallet */
3699
3917
  interface SphereImportOptions {
@@ -3727,6 +3945,8 @@ interface SphereImportOptions {
3727
3945
  groupChat?: GroupChatModuleConfig | boolean;
3728
3946
  /** Optional password to encrypt the wallet. If omitted, mnemonic/key is stored as plaintext. */
3729
3947
  password?: string;
3948
+ /** Market module configuration. true = enable with defaults, object = custom config. */
3949
+ market?: MarketModuleConfig | boolean;
3730
3950
  }
3731
3951
  /** L1 (ALPHA blockchain) configuration */
3732
3952
  interface L1Config {
@@ -3774,6 +3994,8 @@ interface SphereInitOptions {
3774
3994
  groupChat?: GroupChatModuleConfig | boolean;
3775
3995
  /** Optional password to encrypt/decrypt the wallet. If omitted, mnemonic is stored as plaintext. */
3776
3996
  password?: string;
3997
+ /** Market module configuration. true = enable with defaults, object = custom config. */
3998
+ market?: MarketModuleConfig | boolean;
3777
3999
  }
3778
4000
  /** Result of init operation */
3779
4001
  interface SphereInitResult {
@@ -3811,6 +4033,7 @@ declare class Sphere {
3811
4033
  private _payments;
3812
4034
  private _communications;
3813
4035
  private _groupChat;
4036
+ private _market;
3814
4037
  private eventHandlers;
3815
4038
  private _disabledProviders;
3816
4039
  private _providerEventCleanups;
@@ -3858,6 +4081,13 @@ declare class Sphere {
3858
4081
  * (different input shape: { enabled?, relays? }). Both fill relay URLs from network defaults.
3859
4082
  */
3860
4083
  private static resolveGroupChatConfig;
4084
+ /**
4085
+ * Resolve market module config from Sphere.init() options.
4086
+ * - `true` → enable with default API URL
4087
+ * - `MarketModuleConfig` → pass through with defaults
4088
+ * - `undefined` → no market module
4089
+ */
4090
+ private static resolveMarketConfig;
3861
4091
  /**
3862
4092
  * Create new wallet with mnemonic
3863
4093
  */
@@ -3916,6 +4146,8 @@ declare class Sphere {
3916
4146
  get communications(): CommunicationsModule;
3917
4147
  /** Group chat module (NIP-29). Null if not configured. */
3918
4148
  get groupChat(): GroupChatModule | null;
4149
+ /** Market module (intent bulletin board). Null if not configured. */
4150
+ get market(): MarketModule | null;
3919
4151
  /** Current identity (public info only) */
3920
4152
  get identity(): Identity | null;
3921
4153
  /** Is ready */
@@ -5704,8 +5936,9 @@ declare namespace index {
5704
5936
  * Token Registry
5705
5937
  *
5706
5938
  * Provides token definitions (metadata) for known tokens on the Unicity network.
5707
- * Uses bundled static data for offline access and consistency.
5939
+ * Fetches from a remote URL, caches in StorageProvider, and refreshes periodically.
5708
5940
  */
5941
+
5709
5942
  /**
5710
5943
  * Icon entry for token
5711
5944
  */
@@ -5737,18 +5970,45 @@ interface TokenDefinition {
5737
5970
  * Network type for registry lookup
5738
5971
  */
5739
5972
  type RegistryNetwork = 'testnet' | 'mainnet' | 'dev';
5973
+ /**
5974
+ * Configuration options for remote registry refresh
5975
+ */
5976
+ interface TokenRegistryConfig {
5977
+ /** Remote URL to fetch token definitions from */
5978
+ remoteUrl?: string;
5979
+ /** StorageProvider for persistent caching */
5980
+ storage?: StorageProvider;
5981
+ /** Refresh interval in ms (default: 1 hour) */
5982
+ refreshIntervalMs?: number;
5983
+ /** Start auto-refresh immediately (default: true) */
5984
+ autoRefresh?: boolean;
5985
+ }
5740
5986
  /**
5741
5987
  * Token Registry service
5742
5988
  *
5743
5989
  * Provides lookup functionality for token definitions by coin ID.
5744
5990
  * Uses singleton pattern for efficient memory usage.
5745
5991
  *
5992
+ * Data flow:
5993
+ * 1. On `configure()`: load cached definitions from StorageProvider (if fresh)
5994
+ * 2. Fetch from remote URL in background
5995
+ * 3. On successful fetch: update in-memory maps + persist to StorageProvider
5996
+ * 4. Repeat every `refreshIntervalMs` (default 1 hour)
5997
+ *
5998
+ * If no cache and no network — registry is empty (lookup methods return fallbacks).
5999
+ *
5746
6000
  * @example
5747
6001
  * ```ts
5748
6002
  * import { TokenRegistry } from '@unicitylabs/sphere-sdk';
5749
6003
  *
6004
+ * // Usually called automatically by createBrowserProviders / createNodeProviders
6005
+ * TokenRegistry.configure({
6006
+ * remoteUrl: 'https://raw.githubusercontent.com/.../unicity-ids.testnet.json',
6007
+ * storage: myStorageProvider,
6008
+ * });
6009
+ *
5750
6010
  * const registry = TokenRegistry.getInstance();
5751
- * const def = registry.getDefinition('455ad8720656b08e8dbd5bac1f3c73eeea5431565f6c1c3af742b1aa12d41d89');
6011
+ * const def = registry.getDefinition('455ad87...');
5752
6012
  * console.log(def?.symbol); // 'UCT'
5753
6013
  * ```
5754
6014
  */
@@ -5757,19 +6017,79 @@ declare class TokenRegistry {
5757
6017
  private readonly definitionsById;
5758
6018
  private readonly definitionsBySymbol;
5759
6019
  private readonly definitionsByName;
6020
+ private remoteUrl;
6021
+ private storage;
6022
+ private refreshIntervalMs;
6023
+ private refreshTimer;
6024
+ private lastRefreshAt;
6025
+ private refreshPromise;
5760
6026
  private constructor();
5761
6027
  /**
5762
6028
  * Get singleton instance of TokenRegistry
5763
6029
  */
5764
6030
  static getInstance(): TokenRegistry;
5765
6031
  /**
5766
- * Reset the singleton instance (useful for testing)
6032
+ * Configure remote registry refresh with persistent caching.
6033
+ *
6034
+ * On first call:
6035
+ * 1. Loads cached data from StorageProvider (if available and fresh)
6036
+ * 2. Starts periodic remote fetch (if autoRefresh is true, which is default)
6037
+ *
6038
+ * @param options - Configuration options
6039
+ * @param options.remoteUrl - Remote URL to fetch definitions from
6040
+ * @param options.storage - StorageProvider for persistent caching
6041
+ * @param options.refreshIntervalMs - Refresh interval in ms (default: 1 hour)
6042
+ * @param options.autoRefresh - Start auto-refresh immediately (default: true)
6043
+ */
6044
+ static configure(options: TokenRegistryConfig): void;
6045
+ /**
6046
+ * Reset the singleton instance (useful for testing).
6047
+ * Stops auto-refresh if running.
5767
6048
  */
5768
6049
  static resetInstance(): void;
5769
6050
  /**
5770
- * Load registry data from bundled JSON
6051
+ * Destroy the singleton: stop auto-refresh and reset.
6052
+ */
6053
+ static destroy(): void;
6054
+ /**
6055
+ * Load definitions from StorageProvider cache.
6056
+ * Only applies if cache exists and is fresh (within refreshIntervalMs).
6057
+ */
6058
+ private loadFromCache;
6059
+ /**
6060
+ * Save definitions to StorageProvider cache.
6061
+ */
6062
+ private saveToCache;
6063
+ /**
6064
+ * Apply an array of token definitions to the internal maps.
6065
+ * Clears existing data before applying.
6066
+ */
6067
+ private applyDefinitions;
6068
+ /**
6069
+ * Validate that data is an array of objects with 'id' field
6070
+ */
6071
+ private isValidDefinitionsArray;
6072
+ /**
6073
+ * Fetch token definitions from the remote URL and update the registry.
6074
+ * On success, also persists to StorageProvider cache.
6075
+ * Returns true on success, false on failure. On failure, existing data is preserved.
6076
+ * Concurrent calls are deduplicated — only one fetch runs at a time.
6077
+ */
6078
+ refreshFromRemote(): Promise<boolean>;
6079
+ private doRefresh;
6080
+ /**
6081
+ * Start periodic auto-refresh from the remote URL.
6082
+ * Does an immediate fetch, then repeats at the configured interval.
6083
+ */
6084
+ startAutoRefresh(intervalMs?: number): void;
6085
+ /**
6086
+ * Stop periodic auto-refresh
6087
+ */
6088
+ stopAutoRefresh(): void;
6089
+ /**
6090
+ * Timestamp of the last successful remote refresh (0 if never refreshed)
5771
6091
  */
5772
- private loadRegistry;
6092
+ getLastRefreshAt(): number;
5773
6093
  /**
5774
6094
  * Get token definition by hex coin ID
5775
6095
  * @param coinId - 64-character hex string
@@ -5897,4 +6217,4 @@ declare function getCoinIdBySymbol(symbol: string): string | undefined;
5897
6217
  */
5898
6218
  declare function getCoinIdByName(name: string): string | undefined;
5899
6219
 
5900
- export { type AddressInfo, type AddressMode, type AggregatorClient, type AggregatorEvent, type AggregatorEventCallback, type AggregatorEventType, type AggregatorProvider, type AggregatorProviderConfig, type Asset, type BackgroundProgressStatus, type BaseProvider, type BroadcastHandler, type BroadcastMessage, type CMasterKeyData, COIN_TYPES, type CheckNetworkHealthOptions, CoinGeckoPriceProvider, CommunicationsModule, type CommunicationsModuleConfig, type CommunicationsModuleDependencies, type CreateGroupOptions, DEFAULT_AGGREGATOR_TIMEOUT, DEFAULT_AGGREGATOR_URL, DEFAULT_DERIVATION_PATH, DEFAULT_ELECTRUM_URL, DEFAULT_GROUP_RELAYS, DEFAULT_IPFS_BOOTSTRAP_PEERS, DEFAULT_IPFS_GATEWAYS, DEFAULT_NOSTR_RELAYS, DEV_AGGREGATOR_URL, type DecryptionProgressCallback, type DerivationMode, type DirectMessage, type ExtendedValidationResult, type FullIdentity, GroupChatModule, type GroupChatModuleConfig, type GroupChatModuleDependencies, type GroupData, type GroupMemberData, type GroupMessageData, GroupRole, GroupVisibility, type HealthCheckFn, type Identity, type IdentityConfig, type InclusionProof, type IncomingBroadcast, type IncomingMessage, type IncomingPaymentRequest$1 as IncomingPaymentRequest, type IncomingTokenTransfer, type IncomingTransfer, type InstantSplitBundle, type InstantSplitBundleV4, type InstantSplitBundleV5, type InstantSplitOptions, type InstantSplitProcessResult, type InstantSplitResult, type InstantSplitV5RecoveryMetadata, type InvalidatedNametagEntry, index as L1, type L1Balance, L1PaymentsModule, type L1PaymentsModuleConfig, type L1PaymentsModuleDependencies, type L1SendRequest, type L1SendResult, type L1Transaction, type L1Utxo, LIMITS, type LegacyFileImportOptions, type LegacyFileInfo, type LegacyFileParseResult, type LegacyFileParsedData, type LegacyFileType, type LoadResult, type LoggingConfig, type MessageHandler, type MintOutboxEntry, type MintParams, type MintResult, NETWORKS, NIP29_KINDS, NOSTR_EVENT_KINDS, type NametagData, type NetworkHealthResult, type NetworkType, type OracleEvent, type OracleEventCallback, type OracleEventType, type OracleProvider, type OutboxEntry, type OutgoingPaymentRequest, type ParsedStorageData, type PaymentRequest, type PaymentRequestHandler$1 as PaymentRequestHandler, type PaymentRequestResponse, type PaymentRequestResponseHandler$1 as PaymentRequestResponseHandler, type PaymentRequestResponseType$1 as PaymentRequestResponseType, type PaymentRequestResult, type PaymentRequestStatus, type PaymentSession, type PaymentSessionDirection, type PaymentSessionError, type PaymentSessionErrorCode, type PaymentSessionStatus, PaymentsModule, type PaymentsModuleConfig, type PaymentsModuleDependencies, type PeerInfo, type PendingV5Finalization, type PricePlatform, type PriceProvider, type PriceProviderConfig, type ProviderMetadata, type ProviderRole, type ProviderStatus, type ProviderStatusInfo, type ReceiveOptions, type ReceiveResult, type RegistryNetwork, STORAGE_KEYS, STORAGE_PREFIX, type SaveResult, type ScanAddressProgress, type ScanAddressesOptions, type ScanAddressesResult, type ScannedAddressResult, type ServiceHealthResult, type SpentTokenInfo, type SpentTokenResult, Sphere, type SphereConfig, type SphereCreateOptions, SphereError, type SphereErrorCode, type SphereEventHandler, type SphereEventMap, type SphereEventType, type SphereInitOptions, type SphereInitResult, type SphereLoadOptions, type SphereStatus, type SplitPaymentSession, type SplitRecoveryResult, type StorageEvent, type StorageEventCallback, type StorageEventType, type StorageProvider, type StorageProviderConfig, type SubmitResult, type SyncResult, TEST_AGGREGATOR_URL, TEST_ELECTRUM_URL, TEST_NOSTR_RELAYS, TIMEOUTS, type Token, type TokenDefinition, type TokenIcon, type TokenPrice, TokenRegistry, type TokenState, type TokenStatus, type TokenStorageProvider, type TokenTransferDetail, type TokenTransferHandler, type TokenTransferPayload, type ValidationResult as TokenValidationResult, TokenValidator, type TombstoneEntry, type TrackedAddress, type TrackedAddressEntry, type TransactionHistoryEntry, type TransferCommitment, type TransferMode, type TransferRequest, type TransferResult, type TransferStatus, type TransportEvent, type TransportEventCallback, type TransportEventType, type TransportProvider, type TransportProviderConfig, type TrustBaseLoader, type TxfAuthenticator, type TxfGenesis, type TxfGenesisData, type TxfInclusionProof, type TxfIntegrity, type TxfInvalidEntry, type TxfMerkleStep, type TxfMerkleTreePath, type TxfMeta, type TxfOutboxEntry, type TxfSentEntry, type TxfState, type TxfStorageData, type TxfStorageDataBase, type TxfToken, type TxfTombstone, type TxfTransaction, type UnconfirmedResolutionResult, type V5FinalizationStage, type ValidationAction, type ValidationIssue, type ValidationResult$1 as ValidationResult, type WaitOptions, type WalletDatInfo, type WalletInfo, type WalletJSON$1 as WalletJSON, type WalletJSONExportOptions$1 as WalletJSONExportOptions, type WalletSource, archivedKeyFromTokenId, base58Decode, base58Encode, buildTxfStorageData, bytesToHex, checkNetworkHealth, countCommittedTransactions, createAddress, createCommunicationsModule, createGroupChatModule, createKeyPair, createL1PaymentsModule, createPaymentSession, createPaymentSessionError, createPaymentsModule, createPriceProvider, createSphere, createSplitPaymentSession, createTokenValidator, decodeBech32, decryptCMasterKey, decryptPrivateKey, decryptTextFormatKey, deriveAddressInfo, deriveChildKey$1 as deriveChildKey, deriveKeyAtPath$1 as deriveKeyAtPath, doubleSha256, encodeBech32, extractFromText, findPattern, forkedKeyFromTokenIdAndState, formatAmount, generateMasterKey, generateMnemonic, getAddressHrp, getCoinIdByName, getCoinIdBySymbol, getCurrentStateHash, getPublicKey, getSphere, getTokenDecimals, getTokenDefinition, getTokenIconUrl, getTokenId, getTokenName, getTokenSymbol, hasMissingNewStateHash, hasUncommittedTransactions, hasValidTxfData, hash160, hexToBytes, identityFromMnemonicSync, initSphere, isArchivedKey, isForkedKey, isInstantSplitBundle, isInstantSplitBundleV4, isInstantSplitBundleV5, isKnownToken, isPaymentSessionTerminal, isPaymentSessionTimedOut, isSQLiteDatabase, isTextWalletEncrypted, isTokenKey, isValidBech32, isValidNametag, isValidPrivateKey, isValidTokenId, isWalletDatEncrypted, isWalletTextFormat, keyFromTokenId, loadSphere, mnemonicToSeedSync, normalizeSdkTokenToStorage, objectToTxf, parseAndDecryptWalletDat, parseAndDecryptWalletText, parseForkedKey, parseTxfStorageData, parseWalletDat, parseWalletText, randomBytes, randomHex, randomUUID, ripemd160, sha256, sleep, sphereExists, toHumanReadable, toSmallestUnit, tokenIdFromArchivedKey, tokenIdFromKey, tokenToTxf, txfToToken, validateMnemonic };
6220
+ export { type AddressInfo, type AddressMode, type AggregatorClient, type AggregatorEvent, type AggregatorEventCallback, type AggregatorEventType, type AggregatorProvider, type AggregatorProviderConfig, type Asset, type BackgroundProgressStatus, type BaseProvider, type BroadcastHandler, type BroadcastMessage, type CMasterKeyData, COIN_TYPES, type CheckNetworkHealthOptions, CoinGeckoPriceProvider, CommunicationsModule, type CommunicationsModuleConfig, type CommunicationsModuleDependencies, type CreateGroupOptions, DEFAULT_AGGREGATOR_TIMEOUT, DEFAULT_AGGREGATOR_URL, DEFAULT_DERIVATION_PATH, DEFAULT_ELECTRUM_URL, DEFAULT_GROUP_RELAYS, DEFAULT_IPFS_BOOTSTRAP_PEERS, DEFAULT_IPFS_GATEWAYS, DEFAULT_MARKET_API_URL, DEFAULT_NOSTR_RELAYS, DEV_AGGREGATOR_URL, type DecryptionProgressCallback, type DerivationMode, type DirectMessage, type ExtendedValidationResult, type FullIdentity, GroupChatModule, type GroupChatModuleConfig, type GroupChatModuleDependencies, type GroupData, type GroupMemberData, type GroupMessageData, GroupRole, GroupVisibility, type HealthCheckFn, type Identity, type IdentityConfig, type InclusionProof, type IncomingBroadcast, type IncomingMessage, type IncomingPaymentRequest$1 as IncomingPaymentRequest, type IncomingTokenTransfer, type IncomingTransfer, type InstantSplitBundle, type InstantSplitBundleV4, type InstantSplitBundleV5, type InstantSplitOptions, type InstantSplitProcessResult, type InstantSplitResult, type InstantSplitV5RecoveryMetadata, type IntentStatus, type IntentType, type InvalidatedNametagEntry, index as L1, type L1Balance, L1PaymentsModule, type L1PaymentsModuleConfig, type L1PaymentsModuleDependencies, type L1SendRequest, type L1SendResult, type L1Transaction, type L1Utxo, LIMITS, type LegacyFileImportOptions, type LegacyFileInfo, type LegacyFileParseResult, type LegacyFileParsedData, type LegacyFileType, type LoadResult, type LoggingConfig, type MarketIntent, MarketModule, type MarketModuleConfig, type MarketModuleDependencies, type MessageHandler, type MintOutboxEntry, type MintParams, type MintResult, NETWORKS, NIP29_KINDS, NOSTR_EVENT_KINDS, type NametagData, type NetworkHealthResult, type NetworkType, type OracleEvent, type OracleEventCallback, type OracleEventType, type OracleProvider, type OutboxEntry, type OutgoingPaymentRequest, type ParsedStorageData, type PaymentRequest, type PaymentRequestHandler$1 as PaymentRequestHandler, type PaymentRequestResponse, type PaymentRequestResponseHandler$1 as PaymentRequestResponseHandler, type PaymentRequestResponseType$1 as PaymentRequestResponseType, type PaymentRequestResult, type PaymentRequestStatus, type PaymentSession, type PaymentSessionDirection, type PaymentSessionError, type PaymentSessionErrorCode, type PaymentSessionStatus, PaymentsModule, type PaymentsModuleConfig, type PaymentsModuleDependencies, type PeerInfo, type PendingV5Finalization, type PostIntentRequest, type PostIntentResult, type PricePlatform, type PriceProvider, type PriceProviderConfig, type ProviderMetadata, type ProviderRole, type ProviderStatus, type ProviderStatusInfo, type ReceiveOptions, type ReceiveResult, type RegistryNetwork, STORAGE_KEYS, STORAGE_PREFIX, type SaveResult, type ScanAddressProgress, type ScanAddressesOptions, type ScanAddressesResult, type ScannedAddressResult, type SearchFilters, type SearchIntentResult, type SearchOptions, type SearchResult, type ServiceHealthResult, type SpentTokenInfo, type SpentTokenResult, Sphere, type SphereConfig, type SphereCreateOptions, SphereError, type SphereErrorCode, type SphereEventHandler, type SphereEventMap, type SphereEventType, type SphereInitOptions, type SphereInitResult, type SphereLoadOptions, type SphereStatus, type SplitPaymentSession, type SplitRecoveryResult, type StorageEvent, type StorageEventCallback, type StorageEventType, type StorageProvider, type StorageProviderConfig, type SubmitResult, type SyncResult, TEST_AGGREGATOR_URL, TEST_ELECTRUM_URL, TEST_NOSTR_RELAYS, TIMEOUTS, type Token, type TokenDefinition, type TokenIcon, type TokenPrice, TokenRegistry, type TokenState, type TokenStatus, type TokenStorageProvider, type TokenTransferDetail, type TokenTransferHandler, type TokenTransferPayload, type ValidationResult as TokenValidationResult, TokenValidator, type TombstoneEntry, type TrackedAddress, type TrackedAddressEntry, type TransactionHistoryEntry, type TransferCommitment, type TransferMode, type TransferRequest, type TransferResult, type TransferStatus, type TransportEvent, type TransportEventCallback, type TransportEventType, type TransportProvider, type TransportProviderConfig, type TrustBaseLoader, type TxfAuthenticator, type TxfGenesis, type TxfGenesisData, type TxfInclusionProof, type TxfIntegrity, type TxfInvalidEntry, type TxfMerkleStep, type TxfMerkleTreePath, type TxfMeta, type TxfOutboxEntry, type TxfSentEntry, type TxfState, type TxfStorageData, type TxfStorageDataBase, type TxfToken, type TxfTombstone, type TxfTransaction, type UnconfirmedResolutionResult, type V5FinalizationStage, type ValidationAction, type ValidationIssue, type ValidationResult$1 as ValidationResult, type WaitOptions, type WalletDatInfo, type WalletInfo, type WalletJSON$1 as WalletJSON, type WalletJSONExportOptions$1 as WalletJSONExportOptions, type WalletSource, archivedKeyFromTokenId, base58Decode, base58Encode, buildTxfStorageData, bytesToHex, checkNetworkHealth, countCommittedTransactions, createAddress, createCommunicationsModule, createGroupChatModule, createKeyPair, createL1PaymentsModule, createMarketModule, createPaymentSession, createPaymentSessionError, createPaymentsModule, createPriceProvider, createSphere, createSplitPaymentSession, createTokenValidator, decodeBech32, decryptCMasterKey, decryptPrivateKey, decryptTextFormatKey, deriveAddressInfo, deriveChildKey$1 as deriveChildKey, deriveKeyAtPath$1 as deriveKeyAtPath, doubleSha256, encodeBech32, extractFromText, findPattern, forkedKeyFromTokenIdAndState, formatAmount, generateMasterKey, generateMnemonic, getAddressHrp, getCoinIdByName, getCoinIdBySymbol, getCurrentStateHash, getPublicKey, getSphere, getTokenDecimals, getTokenDefinition, getTokenIconUrl, getTokenId, getTokenName, getTokenSymbol, hasMissingNewStateHash, hasUncommittedTransactions, hasValidTxfData, hash160, hexToBytes, identityFromMnemonicSync, initSphere, isArchivedKey, isForkedKey, isInstantSplitBundle, isInstantSplitBundleV4, isInstantSplitBundleV5, isKnownToken, isPaymentSessionTerminal, isPaymentSessionTimedOut, isSQLiteDatabase, isTextWalletEncrypted, isTokenKey, isValidBech32, isValidNametag, isValidPrivateKey, isValidTokenId, isWalletDatEncrypted, isWalletTextFormat, keyFromTokenId, loadSphere, mnemonicToSeedSync, normalizeSdkTokenToStorage, objectToTxf, parseAndDecryptWalletDat, parseAndDecryptWalletText, parseForkedKey, parseTxfStorageData, parseWalletDat, parseWalletText, randomBytes, randomHex, randomUUID, ripemd160, sha256, sleep, sphereExists, toHumanReadable, toSmallestUnit, tokenIdFromArchivedKey, tokenIdFromKey, tokenToTxf, txfToToken, validateMnemonic };