@unicitylabs/sphere-sdk 0.3.9 → 0.4.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 (43) hide show
  1. package/dist/connect/index.cjs +79 -3
  2. package/dist/connect/index.cjs.map +1 -1
  3. package/dist/connect/index.d.cts +16 -0
  4. package/dist/connect/index.d.ts +16 -0
  5. package/dist/connect/index.js +79 -3
  6. package/dist/connect/index.js.map +1 -1
  7. package/dist/core/index.cjs +2686 -56
  8. package/dist/core/index.cjs.map +1 -1
  9. package/dist/core/index.d.cts +228 -3
  10. package/dist/core/index.d.ts +228 -3
  11. package/dist/core/index.js +2682 -52
  12. package/dist/core/index.js.map +1 -1
  13. package/dist/impl/browser/connect/index.cjs +11 -2
  14. package/dist/impl/browser/connect/index.cjs.map +1 -1
  15. package/dist/impl/browser/connect/index.js +11 -2
  16. package/dist/impl/browser/connect/index.js.map +1 -1
  17. package/dist/impl/browser/index.cjs +467 -47
  18. package/dist/impl/browser/index.cjs.map +1 -1
  19. package/dist/impl/browser/index.js +468 -47
  20. package/dist/impl/browser/index.js.map +1 -1
  21. package/dist/impl/nodejs/connect/index.cjs +11 -2
  22. package/dist/impl/nodejs/connect/index.cjs.map +1 -1
  23. package/dist/impl/nodejs/connect/index.js +11 -2
  24. package/dist/impl/nodejs/connect/index.js.map +1 -1
  25. package/dist/impl/nodejs/index.cjs +152 -8
  26. package/dist/impl/nodejs/index.cjs.map +1 -1
  27. package/dist/impl/nodejs/index.d.cts +47 -0
  28. package/dist/impl/nodejs/index.d.ts +47 -0
  29. package/dist/impl/nodejs/index.js +153 -8
  30. package/dist/impl/nodejs/index.js.map +1 -1
  31. package/dist/index.cjs +2703 -56
  32. package/dist/index.cjs.map +1 -1
  33. package/dist/index.d.cts +326 -5
  34. package/dist/index.d.ts +326 -5
  35. package/dist/index.js +2692 -52
  36. package/dist/index.js.map +1 -1
  37. package/dist/l1/index.cjs +5 -1
  38. package/dist/l1/index.cjs.map +1 -1
  39. package/dist/l1/index.d.cts +2 -1
  40. package/dist/l1/index.d.ts +2 -1
  41. package/dist/l1/index.js +5 -1
  42. package/dist/l1/index.js.map +1 -1
  43. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -1132,6 +1132,11 @@ interface BroadcastMessage {
1132
1132
  readonly timestamp: number;
1133
1133
  readonly tags?: string[];
1134
1134
  }
1135
+ interface ComposingIndicator {
1136
+ readonly senderPubkey: string;
1137
+ readonly senderNametag?: string;
1138
+ readonly expiresIn: number;
1139
+ }
1135
1140
  /**
1136
1141
  * Minimal data stored in persistent storage for a tracked address.
1137
1142
  * Only contains user state — derived fields are computed on load.
@@ -1162,7 +1167,7 @@ interface TrackedAddress extends TrackedAddressEntry {
1162
1167
  /** Primary nametag (from nametag cache, without @ prefix) */
1163
1168
  readonly nametag?: string;
1164
1169
  }
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';
1170
+ 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' | 'composing:started' | '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
1171
  interface SphereEventMap {
1167
1172
  'transfer:incoming': IncomingTransfer;
1168
1173
  'transfer:confirmed': TransferResult;
@@ -1182,6 +1187,7 @@ interface SphereEventMap {
1182
1187
  senderNametag?: string;
1183
1188
  timestamp: number;
1184
1189
  };
1190
+ 'composing:started': ComposingIndicator;
1185
1191
  'message:broadcast': BroadcastMessage;
1186
1192
  'sync:started': {
1187
1193
  source: string;
@@ -1572,6 +1578,17 @@ interface TransportProvider extends BaseProvider {
1572
1578
  * @returns Unsubscribe function
1573
1579
  */
1574
1580
  onTypingIndicator?(handler: TypingIndicatorHandler): () => void;
1581
+ /**
1582
+ * Send composing indicator to a recipient using NIP-44 encrypted gift wrap
1583
+ * @param recipientTransportPubkey - Transport pubkey of the conversation partner
1584
+ * @param content - JSON payload with senderNametag and expiresIn
1585
+ */
1586
+ sendComposingIndicator?(recipientTransportPubkey: string, content: string): Promise<void>;
1587
+ /**
1588
+ * Subscribe to incoming composing indicators
1589
+ * @returns Unsubscribe function
1590
+ */
1591
+ onComposing?(handler: ComposingHandler): () => void;
1575
1592
  /**
1576
1593
  * Get list of configured relay URLs
1577
1594
  */
@@ -1804,6 +1821,7 @@ interface IncomingTypingIndicator {
1804
1821
  timestamp: number;
1805
1822
  }
1806
1823
  type TypingIndicatorHandler = (indicator: IncomingTypingIndicator) => void;
1824
+ type ComposingHandler = (indicator: ComposingIndicator) => void;
1807
1825
 
1808
1826
  /**
1809
1827
  * L1 Payments Sub-Module
@@ -3045,6 +3063,13 @@ declare class PaymentsModule {
3045
3063
  * Remove all nametag data from memory and storage.
3046
3064
  */
3047
3065
  clearNametag(): Promise<void>;
3066
+ /**
3067
+ * Reload nametag data from storage providers into memory.
3068
+ *
3069
+ * Used as a recovery mechanism when `this.nametags` is unexpectedly empty
3070
+ * (e.g., wiped by sync or race condition) but nametag data exists in storage.
3071
+ */
3072
+ private reloadNametagsFromStorage;
3048
3073
  /**
3049
3074
  * Mint a nametag token on-chain (like Sphere wallet and lottery)
3050
3075
  * This creates the nametag token required for receiving tokens via PROXY addresses
@@ -3136,6 +3161,11 @@ declare class PaymentsModule {
3136
3161
  * Create SigningService from identity private key
3137
3162
  */
3138
3163
  private createSigningService;
3164
+ /**
3165
+ * Get the wallet's signing public key (used for token ownership predicates).
3166
+ * This is the key that token state predicates are checked against.
3167
+ */
3168
+ getSigningPublicKey(): Promise<Uint8Array>;
3139
3169
  /**
3140
3170
  * Create DirectAddress from a public key using UnmaskedPredicateReference
3141
3171
  */
@@ -3201,11 +3231,24 @@ declare function createPaymentsModule(config?: PaymentsModuleConfig): PaymentsMo
3201
3231
  interface CommunicationsModuleConfig {
3202
3232
  /** Auto-save messages */
3203
3233
  autoSave?: boolean;
3204
- /** Max messages in memory */
3234
+ /** Max messages in memory (global cap) */
3205
3235
  maxMessages?: number;
3236
+ /** Max messages per conversation (default: 200) */
3237
+ maxPerConversation?: number;
3206
3238
  /** Enable read receipts */
3207
3239
  readReceipts?: boolean;
3208
3240
  }
3241
+ interface ConversationPage {
3242
+ messages: DirectMessage[];
3243
+ hasMore: boolean;
3244
+ oldestTimestamp: number | null;
3245
+ }
3246
+ interface GetConversationPageOptions {
3247
+ /** Max messages to return (default: 20) */
3248
+ limit?: number;
3249
+ /** Return messages older than this timestamp */
3250
+ before?: number;
3251
+ }
3209
3252
  interface CommunicationsModuleDependencies {
3210
3253
  identity: FullIdentity;
3211
3254
  storage: StorageProvider;
@@ -3218,8 +3261,10 @@ declare class CommunicationsModule {
3218
3261
  private messages;
3219
3262
  private broadcasts;
3220
3263
  private unsubscribeMessages;
3264
+ private unsubscribeComposing;
3221
3265
  private broadcastSubscriptions;
3222
3266
  private dmHandlers;
3267
+ private composingHandlers;
3223
3268
  private broadcastHandlers;
3224
3269
  constructor(config?: CommunicationsModuleConfig);
3225
3270
  /**
@@ -3227,7 +3272,10 @@ declare class CommunicationsModule {
3227
3272
  */
3228
3273
  initialize(deps: CommunicationsModuleDependencies): void;
3229
3274
  /**
3230
- * Load messages from storage
3275
+ * Load messages from storage.
3276
+ * Uses per-address key (STORAGE_KEYS_ADDRESS.MESSAGES) which is automatically
3277
+ * scoped by LocalStorageProvider to sphere_DIRECT_xxx_yyy_messages.
3278
+ * Falls back to legacy global 'direct_messages' key for migration.
3231
3279
  */
3232
3280
  load(): Promise<void>;
3233
3281
  /**
@@ -3254,10 +3302,28 @@ declare class CommunicationsModule {
3254
3302
  * Get unread count
3255
3303
  */
3256
3304
  getUnreadCount(peerPubkey?: string): number;
3305
+ /**
3306
+ * Get a page of messages from a conversation (for lazy loading).
3307
+ * Returns messages in chronological order with a cursor for loading older messages.
3308
+ */
3309
+ getConversationPage(peerPubkey: string, options?: GetConversationPageOptions): ConversationPage;
3310
+ /**
3311
+ * Delete all messages in a conversation with a peer
3312
+ */
3313
+ deleteConversation(peerPubkey: string): Promise<void>;
3257
3314
  /**
3258
3315
  * Send typing indicator to a peer
3259
3316
  */
3260
3317
  sendTypingIndicator(peerPubkey: string): Promise<void>;
3318
+ /**
3319
+ * Send a composing indicator to a peer.
3320
+ * Fire-and-forget — does not save to message history.
3321
+ */
3322
+ sendComposingIndicator(recipientPubkeyOrNametag: string): Promise<void>;
3323
+ /**
3324
+ * Subscribe to incoming composing indicators
3325
+ */
3326
+ onComposingIndicator(handler: (indicator: ComposingIndicator) => void): () => void;
3261
3327
  /**
3262
3328
  * Subscribe to incoming DMs
3263
3329
  */
@@ -3279,6 +3345,7 @@ declare class CommunicationsModule {
3279
3345
  */
3280
3346
  onBroadcast(handler: (message: BroadcastMessage) => void): () => void;
3281
3347
  private handleIncomingMessage;
3348
+ private handleComposingIndicator;
3282
3349
  private handleIncomingBroadcast;
3283
3350
  private save;
3284
3351
  private pruneIfNeeded;
@@ -3408,12 +3475,233 @@ declare class GroupChatModule {
3408
3475
  }
3409
3476
  declare function createGroupChatModule(config?: GroupChatModuleConfig): GroupChatModule;
3410
3477
 
3478
+ /**
3479
+ * Market Module Types
3480
+ * Intent bulletin board for posting and discovering intents,
3481
+ * plus real-time feed subscription.
3482
+ */
3483
+ type IntentType = 'buy' | 'sell' | 'service' | 'announcement' | 'other' | (string & {});
3484
+ type IntentStatus = 'active' | 'closed' | 'expired';
3485
+ interface MarketModuleConfig {
3486
+ /** Market API base URL (default: https://market-api.unicity.network) */
3487
+ apiUrl?: string;
3488
+ /** Request timeout in ms (default: 30000) */
3489
+ timeout?: number;
3490
+ }
3491
+ interface MarketModuleDependencies {
3492
+ identity: FullIdentity;
3493
+ emitEvent: <T extends SphereEventType>(type: T, data: SphereEventMap[T]) => void;
3494
+ }
3495
+ interface PostIntentRequest {
3496
+ description: string;
3497
+ intentType: IntentType;
3498
+ category?: string;
3499
+ price?: number;
3500
+ currency?: string;
3501
+ location?: string;
3502
+ contactHandle?: string;
3503
+ expiresInDays?: number;
3504
+ }
3505
+ interface PostIntentResult {
3506
+ intentId: string;
3507
+ message: string;
3508
+ expiresAt: string;
3509
+ }
3510
+ interface MarketIntent {
3511
+ id: string;
3512
+ intentType: IntentType;
3513
+ category?: string;
3514
+ price?: string;
3515
+ currency: string;
3516
+ location?: string;
3517
+ status: IntentStatus;
3518
+ createdAt: string;
3519
+ expiresAt: string;
3520
+ }
3521
+ interface SearchIntentResult {
3522
+ id: string;
3523
+ score: number;
3524
+ agentNametag?: string;
3525
+ agentPublicKey: string;
3526
+ description: string;
3527
+ intentType: IntentType;
3528
+ category?: string;
3529
+ price?: number;
3530
+ currency: string;
3531
+ location?: string;
3532
+ contactMethod: string;
3533
+ contactHandle?: string;
3534
+ createdAt: string;
3535
+ expiresAt: string;
3536
+ }
3537
+ interface SearchFilters {
3538
+ intentType?: IntentType;
3539
+ category?: string;
3540
+ minPrice?: number;
3541
+ maxPrice?: number;
3542
+ location?: string;
3543
+ /** Minimum similarity score (0–1). Results below this threshold are excluded (client-side). */
3544
+ minScore?: number;
3545
+ }
3546
+ interface SearchOptions {
3547
+ filters?: SearchFilters;
3548
+ limit?: number;
3549
+ }
3550
+ interface SearchResult {
3551
+ intents: SearchIntentResult[];
3552
+ count: number;
3553
+ }
3554
+ /** A listing broadcast on the live feed */
3555
+ interface FeedListing {
3556
+ id: string;
3557
+ title: string;
3558
+ descriptionPreview: string;
3559
+ agentName: string;
3560
+ agentId: number;
3561
+ type: IntentType;
3562
+ createdAt: string;
3563
+ }
3564
+ /** WebSocket message: initial batch of recent listings */
3565
+ interface FeedInitialMessage {
3566
+ type: 'initial';
3567
+ listings: FeedListing[];
3568
+ }
3569
+ /** WebSocket message: single new listing */
3570
+ interface FeedNewMessage {
3571
+ type: 'new';
3572
+ listing: FeedListing;
3573
+ }
3574
+ type FeedMessage = FeedInitialMessage | FeedNewMessage;
3575
+ /** Callback for live feed events */
3576
+ type FeedListener = (message: FeedMessage) => void;
3577
+
3578
+ /**
3579
+ * Market Module
3580
+ *
3581
+ * Intent bulletin board — post and discover intents (buy, sell,
3582
+ * service, announcement, other) with secp256k1-signed requests
3583
+ * tied to the wallet identity. Includes real-time feed via WebSocket.
3584
+ */
3585
+ /** Default Market API URL (intent bulletin board) */
3586
+ declare const DEFAULT_MARKET_API_URL = "https://market-api.unicity.network";
3587
+
3588
+ declare class MarketModule {
3589
+ private readonly apiUrl;
3590
+ private readonly timeout;
3591
+ private identity;
3592
+ private registered;
3593
+ constructor(config?: MarketModuleConfig);
3594
+ /** Called by Sphere after construction */
3595
+ initialize(deps: MarketModuleDependencies): void;
3596
+ /** No-op — stateless module */
3597
+ load(): Promise<void>;
3598
+ /** No-op — stateless module */
3599
+ destroy(): void;
3600
+ /** Post a new intent (agent is auto-registered on first post) */
3601
+ postIntent(intent: PostIntentRequest): Promise<PostIntentResult>;
3602
+ /** Semantic search for intents (public — no auth required) */
3603
+ search(query: string, opts?: SearchOptions): Promise<SearchResult>;
3604
+ /** List own intents (authenticated) */
3605
+ getMyIntents(): Promise<MarketIntent[]>;
3606
+ /** Close (delete) an intent */
3607
+ closeIntent(intentId: string): Promise<void>;
3608
+ /** Fetch the most recent listings via REST (public — no auth required) */
3609
+ getRecentListings(): Promise<FeedListing[]>;
3610
+ /**
3611
+ * Subscribe to the live listing feed via WebSocket.
3612
+ * Returns an unsubscribe function that closes the connection.
3613
+ *
3614
+ * Requires a WebSocket implementation — works natively in browsers
3615
+ * and in Node.js 21+ (or with the `ws` package).
3616
+ */
3617
+ subscribeFeed(listener: FeedListener): () => void;
3618
+ private ensureIdentity;
3619
+ /** Register the agent's public key with the server (idempotent) */
3620
+ private ensureRegistered;
3621
+ private parseResponse;
3622
+ private apiPost;
3623
+ private apiGet;
3624
+ private apiDelete;
3625
+ private apiPublicPost;
3626
+ }
3627
+ declare function createMarketModule(config?: MarketModuleConfig): MarketModule;
3628
+
3411
3629
  /**
3412
3630
  * SDK2 Constants
3413
3631
  * Default configuration values and storage keys
3414
3632
  */
3415
3633
  /** Default prefix for all storage keys */
3416
3634
  declare const STORAGE_PREFIX: "sphere_";
3635
+ /**
3636
+ * Global storage keys (one per wallet, no address index)
3637
+ * Final key format: sphere_{key}
3638
+ */
3639
+ declare const STORAGE_KEYS_GLOBAL: {
3640
+ /** Encrypted BIP39 mnemonic */
3641
+ readonly MNEMONIC: "mnemonic";
3642
+ /** Encrypted master private key */
3643
+ readonly MASTER_KEY: "master_key";
3644
+ /** BIP32 chain code */
3645
+ readonly CHAIN_CODE: "chain_code";
3646
+ /** HD derivation path (full path like m/44'/0'/0'/0/0) */
3647
+ readonly DERIVATION_PATH: "derivation_path";
3648
+ /** Base derivation path (like m/44'/0'/0' without chain/index) */
3649
+ readonly BASE_PATH: "base_path";
3650
+ /** Derivation mode: bip32, wif_hmac, legacy_hmac */
3651
+ readonly DERIVATION_MODE: "derivation_mode";
3652
+ /** Wallet source: mnemonic, file, unknown */
3653
+ readonly WALLET_SOURCE: "wallet_source";
3654
+ /** Wallet existence flag */
3655
+ readonly WALLET_EXISTS: "wallet_exists";
3656
+ /** Current active address index */
3657
+ readonly CURRENT_ADDRESS_INDEX: "current_address_index";
3658
+ /** Nametag cache per address (separate from tracked addresses registry) */
3659
+ readonly ADDRESS_NAMETAGS: "address_nametags";
3660
+ /** Active addresses registry (JSON: TrackedAddressesStorage) */
3661
+ readonly TRACKED_ADDRESSES: "tracked_addresses";
3662
+ /** Last processed Nostr wallet event timestamp (unix seconds), keyed per pubkey */
3663
+ readonly LAST_WALLET_EVENT_TS: "last_wallet_event_ts";
3664
+ /** Group chat: joined groups */
3665
+ readonly GROUP_CHAT_GROUPS: "group_chat_groups";
3666
+ /** Group chat: messages */
3667
+ readonly GROUP_CHAT_MESSAGES: "group_chat_messages";
3668
+ /** Group chat: members */
3669
+ readonly GROUP_CHAT_MEMBERS: "group_chat_members";
3670
+ /** Group chat: processed event IDs for deduplication */
3671
+ readonly GROUP_CHAT_PROCESSED_EVENTS: "group_chat_processed_events";
3672
+ /** Group chat: last used relay URL (stale data detection) */
3673
+ readonly GROUP_CHAT_RELAY_URL: "group_chat_relay_url";
3674
+ /** Cached token registry JSON (fetched from remote) */
3675
+ readonly TOKEN_REGISTRY_CACHE: "token_registry_cache";
3676
+ /** Timestamp of last token registry cache update (ms since epoch) */
3677
+ readonly TOKEN_REGISTRY_CACHE_TS: "token_registry_cache_ts";
3678
+ /** Cached price data JSON (from CoinGecko or other provider) */
3679
+ readonly PRICE_CACHE: "price_cache";
3680
+ /** Timestamp of last price cache update (ms since epoch) */
3681
+ readonly PRICE_CACHE_TS: "price_cache_ts";
3682
+ };
3683
+ /**
3684
+ * Per-address storage keys (one per derived address)
3685
+ * Final key format: sphere_{DIRECT_xxx_yyy}_{key}
3686
+ * Example: sphere_DIRECT_abc123_xyz789_pending_transfers
3687
+ *
3688
+ * Note: Token data (tokens, tombstones, archived, forked) is stored via
3689
+ * TokenStorageProvider, not here. This avoids duplication.
3690
+ */
3691
+ declare const STORAGE_KEYS_ADDRESS: {
3692
+ /** Pending transfers for this address */
3693
+ readonly PENDING_TRANSFERS: "pending_transfers";
3694
+ /** Transfer outbox for this address */
3695
+ readonly OUTBOX: "outbox";
3696
+ /** Conversations for this address */
3697
+ readonly CONVERSATIONS: "conversations";
3698
+ /** Messages for this address */
3699
+ readonly MESSAGES: "messages";
3700
+ /** Transaction history for this address */
3701
+ readonly TRANSACTION_HISTORY: "transaction_history";
3702
+ /** Pending V5 finalization tokens (unconfirmed instant split tokens) */
3703
+ readonly PENDING_V5_TOKENS: "pending_v5_tokens";
3704
+ };
3417
3705
  /** @deprecated Use STORAGE_KEYS_GLOBAL and STORAGE_KEYS_ADDRESS instead */
3418
3706
  declare const STORAGE_KEYS: {
3419
3707
  /** Pending transfers for this address */
@@ -3471,6 +3759,20 @@ declare const STORAGE_KEYS: {
3471
3759
  /** Timestamp of last price cache update (ms since epoch) */
3472
3760
  readonly PRICE_CACHE_TS: "price_cache_ts";
3473
3761
  };
3762
+ /**
3763
+ * Build a per-address storage key using address identifier
3764
+ * @param addressId - Short identifier for the address (e.g., first 8 chars of pubkey hash, or direct address hash)
3765
+ * @param key - The key from STORAGE_KEYS_ADDRESS
3766
+ * @returns Key in format: "{addressId}_{key}" e.g., "a1b2c3d4_tokens"
3767
+ */
3768
+ declare function getAddressStorageKey(addressId: string, key: string): string;
3769
+ /**
3770
+ * Create a readable address identifier from directAddress or chainPubkey
3771
+ * Format: DIRECT_first6_last6 (sanitized for filesystem/storage)
3772
+ * @param directAddress - The L3 direct address (DIRECT:xxx) or chainPubkey
3773
+ * @returns Sanitized identifier like "DIRECT_abc123_xyz789"
3774
+ */
3775
+ declare function getAddressId(directAddress: string): string;
3474
3776
  /** Default Nostr relays */
3475
3777
  declare const DEFAULT_NOSTR_RELAYS: readonly ["wss://relay.unicity.network", "wss://relay.damus.io", "wss://nos.lol", "wss://relay.nostr.band"];
3476
3778
  /** Nostr event kinds used by SDK - must match @unicitylabs/nostr-js-sdk */
@@ -3766,6 +4068,8 @@ interface SphereCreateOptions {
3766
4068
  network?: NetworkType;
3767
4069
  /** Group chat configuration (NIP-29). Omit to disable groupchat. */
3768
4070
  groupChat?: GroupChatModuleConfig | boolean;
4071
+ /** Market module configuration. true = enable with defaults, object = custom config. */
4072
+ market?: MarketModuleConfig | boolean;
3769
4073
  /** Optional password to encrypt the wallet. If omitted, mnemonic is stored as plaintext. */
3770
4074
  password?: string;
3771
4075
  }
@@ -3791,6 +4095,8 @@ interface SphereLoadOptions {
3791
4095
  network?: NetworkType;
3792
4096
  /** Group chat configuration (NIP-29). Omit to disable groupchat. */
3793
4097
  groupChat?: GroupChatModuleConfig | boolean;
4098
+ /** Market module configuration. true = enable with defaults, object = custom config. */
4099
+ market?: MarketModuleConfig | boolean;
3794
4100
  /** Optional password to decrypt the wallet. Must match the password used during creation. */
3795
4101
  password?: string;
3796
4102
  }
@@ -3824,6 +4130,8 @@ interface SphereImportOptions {
3824
4130
  price?: PriceProvider;
3825
4131
  /** Group chat configuration (NIP-29). Omit to disable groupchat. */
3826
4132
  groupChat?: GroupChatModuleConfig | boolean;
4133
+ /** Market module configuration. true = enable with defaults, object = custom config. */
4134
+ market?: MarketModuleConfig | boolean;
3827
4135
  /** Optional password to encrypt the wallet. If omitted, mnemonic/key is stored as plaintext. */
3828
4136
  password?: string;
3829
4137
  }
@@ -3871,6 +4179,8 @@ interface SphereInitOptions {
3871
4179
  * - Omit/undefined: No groupchat module
3872
4180
  */
3873
4181
  groupChat?: GroupChatModuleConfig | boolean;
4182
+ /** Market module configuration. true = enable with defaults, object = custom config. */
4183
+ market?: MarketModuleConfig | boolean;
3874
4184
  /** Optional password to encrypt/decrypt the wallet. If omitted, mnemonic is stored as plaintext. */
3875
4185
  password?: string;
3876
4186
  }
@@ -3910,6 +4220,7 @@ declare class Sphere {
3910
4220
  private _payments;
3911
4221
  private _communications;
3912
4222
  private _groupChat;
4223
+ private _market;
3913
4224
  private eventHandlers;
3914
4225
  private _disabledProviders;
3915
4226
  private _providerEventCleanups;
@@ -3957,6 +4268,13 @@ declare class Sphere {
3957
4268
  * (different input shape: { enabled?, relays? }). Both fill relay URLs from network defaults.
3958
4269
  */
3959
4270
  private static resolveGroupChatConfig;
4271
+ /**
4272
+ * Resolve market module config from Sphere.init() options.
4273
+ * - `true` → enable with default API URL
4274
+ * - `MarketModuleConfig` → pass through
4275
+ * - `undefined` → no market module
4276
+ */
4277
+ private static resolveMarketConfig;
3960
4278
  /**
3961
4279
  * Configure TokenRegistry in the main bundle context.
3962
4280
  *
@@ -4025,6 +4343,8 @@ declare class Sphere {
4025
4343
  get communications(): CommunicationsModule;
4026
4344
  /** Group chat module (NIP-29). Null if not configured. */
4027
4345
  get groupChat(): GroupChatModule | null;
4346
+ /** Market module (intent bulletin board). Null if not configured. */
4347
+ get market(): MarketModule | null;
4028
4348
  /** Current identity (public info only) */
4029
4349
  get identity(): Identity | null;
4030
4350
  /** Is ready */
@@ -5537,7 +5857,8 @@ declare class VestingClassifier {
5537
5857
  private storeName;
5538
5858
  private db;
5539
5859
  /**
5540
- * Initialize IndexedDB for persistent caching
5860
+ * Initialize IndexedDB for persistent caching.
5861
+ * In Node.js (no IndexedDB), silently falls back to memory-only caching.
5541
5862
  */
5542
5863
  initDB(): Promise<void>;
5543
5864
  /**
@@ -6107,4 +6428,4 @@ declare function getCoinIdBySymbol(symbol: string): string | undefined;
6107
6428
  */
6108
6429
  declare function getCoinIdByName(name: string): string | undefined;
6109
6430
 
6110
- 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 };
6431
+ 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 ComposingIndicator, type ConversationPage, 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, type GetConversationPageOptions, 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_KEYS_ADDRESS, STORAGE_KEYS_GLOBAL, 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, getAddressId, getAddressStorageKey, 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 };