@unicitylabs/sphere-sdk 0.2.5 → 0.3.0

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
@@ -2,6 +2,73 @@ import { Token as Token$1 } from '@unicitylabs/state-transition-sdk/lib/token/To
2
2
  import elliptic from 'elliptic';
3
3
  export { areSameNametag, hashNametag, isPhoneNumber, normalizeNametag } from '@unicitylabs/nostr-js-sdk';
4
4
 
5
+ /**
6
+ * Group Chat Types (NIP-29)
7
+ * Plain interfaces for SDK consumers — no classes, no UI helpers.
8
+ */
9
+ declare const GroupRole: {
10
+ readonly ADMIN: "ADMIN";
11
+ readonly MODERATOR: "MODERATOR";
12
+ readonly MEMBER: "MEMBER";
13
+ };
14
+ type GroupRole = (typeof GroupRole)[keyof typeof GroupRole];
15
+ declare const GroupVisibility: {
16
+ readonly PUBLIC: "PUBLIC";
17
+ readonly PRIVATE: "PRIVATE";
18
+ };
19
+ type GroupVisibility = (typeof GroupVisibility)[keyof typeof GroupVisibility];
20
+ interface GroupData {
21
+ id: string;
22
+ relayUrl: string;
23
+ name: string;
24
+ description?: string;
25
+ picture?: string;
26
+ visibility: GroupVisibility;
27
+ createdAt: number;
28
+ updatedAt?: number;
29
+ memberCount?: number;
30
+ unreadCount?: number;
31
+ lastMessageTime?: number;
32
+ lastMessageText?: string;
33
+ /** When the current user joined this group locally (used to filter old events) */
34
+ localJoinedAt?: number;
35
+ }
36
+ interface GroupMessageData {
37
+ id?: string;
38
+ groupId: string;
39
+ content: string;
40
+ timestamp: number;
41
+ senderPubkey: string;
42
+ senderNametag?: string;
43
+ replyToId?: string;
44
+ previousIds?: string[];
45
+ }
46
+ interface GroupMemberData {
47
+ pubkey: string;
48
+ groupId: string;
49
+ role: GroupRole;
50
+ nametag?: string;
51
+ joinedAt: number;
52
+ }
53
+ interface GroupChatModuleConfig {
54
+ /** Override relay URLs (default: from network config) */
55
+ relays?: string[];
56
+ /** Default message fetch limit (default: 50) */
57
+ defaultMessageLimit?: number;
58
+ /** Max previous message IDs in ordering tags (default: 3) */
59
+ maxPreviousTags?: number;
60
+ /** Reconnect delay in ms (default: 3000) */
61
+ reconnectDelayMs?: number;
62
+ /** Max reconnect attempts (default: 5) */
63
+ maxReconnectAttempts?: number;
64
+ }
65
+ interface CreateGroupOptions {
66
+ name: string;
67
+ description?: string;
68
+ picture?: string;
69
+ visibility?: GroupVisibility;
70
+ }
71
+
5
72
  /**
6
73
  * Cryptographic utilities for SDK2
7
74
  *
@@ -311,11 +378,12 @@ interface TxfMeta$1 {
311
378
  interface TxfStorageData {
312
379
  _meta: TxfMeta$1;
313
380
  _nametag?: NametagData;
381
+ _nametags?: NametagData[];
314
382
  _tombstones?: TombstoneEntry[];
315
383
  _invalidatedNametags?: InvalidatedNametagEntry[];
316
384
  _outbox?: OutboxEntry[];
317
385
  _mintOutbox?: MintOutboxEntry[];
318
- [key: string]: TxfToken | TxfMeta$1 | NametagData | TombstoneEntry[] | InvalidatedNametagEntry[] | OutboxEntry[] | MintOutboxEntry[] | undefined;
386
+ [key: string]: TxfToken | TxfMeta$1 | NametagData | NametagData[] | TombstoneEntry[] | InvalidatedNametagEntry[] | OutboxEntry[] | MintOutboxEntry[] | undefined;
319
387
  }
320
388
  interface ValidationIssue {
321
389
  tokenId: string;
@@ -1094,7 +1162,7 @@ interface TrackedAddress extends TrackedAddressEntry {
1094
1162
  /** Primary nametag (from nametag cache, without @ prefix) */
1095
1163
  readonly nametag?: string;
1096
1164
  }
1097
- 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';
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';
1098
1166
  interface SphereEventMap {
1099
1167
  'transfer:incoming': IncomingTransfer;
1100
1168
  'transfer:confirmed': TransferResult;
@@ -1161,6 +1229,26 @@ interface SphereEventMap {
1161
1229
  added: number;
1162
1230
  removed: number;
1163
1231
  };
1232
+ 'groupchat:message': GroupMessageData;
1233
+ 'groupchat:joined': {
1234
+ groupId: string;
1235
+ groupName: string;
1236
+ };
1237
+ 'groupchat:left': {
1238
+ groupId: string;
1239
+ };
1240
+ 'groupchat:kicked': {
1241
+ groupId: string;
1242
+ groupName: string;
1243
+ };
1244
+ 'groupchat:group_deleted': {
1245
+ groupId: string;
1246
+ groupName: string;
1247
+ };
1248
+ 'groupchat:updated': Record<string, never>;
1249
+ 'groupchat:connection': {
1250
+ connected: boolean;
1251
+ };
1164
1252
  }
1165
1253
  type SphereEventHandler<T extends SphereEventType> = (data: SphereEventMap[T]) => void;
1166
1254
  interface SphereConfig {
@@ -1853,22 +1941,6 @@ interface TokenStorageProvider<TData = unknown> extends BaseProvider {
1853
1941
  * Subscribe to storage events
1854
1942
  */
1855
1943
  onEvent?(callback: StorageEventCallback): () => void;
1856
- /**
1857
- * Save individual token (for file-based storage like lottery pattern)
1858
- */
1859
- saveToken?(tokenId: string, tokenData: unknown): Promise<void>;
1860
- /**
1861
- * Get individual token
1862
- */
1863
- getToken?(tokenId: string): Promise<unknown | null>;
1864
- /**
1865
- * List all token IDs
1866
- */
1867
- listTokenIds?(): Promise<string[]>;
1868
- /**
1869
- * Delete individual token
1870
- */
1871
- deleteToken?(tokenId: string): Promise<void>;
1872
1944
  }
1873
1945
  type StorageEventType = 'storage:saving' | 'storage:saved' | 'storage:loading' | 'storage:loaded' | 'storage:error' | 'storage:remote-updated' | 'sync:started' | 'sync:completed' | 'sync:conflict' | 'sync:error';
1874
1946
  interface StorageEvent {
@@ -2279,7 +2351,7 @@ declare class PaymentsModule {
2279
2351
  private archivedTokens;
2280
2352
  private forkedTokens;
2281
2353
  private transactionHistory;
2282
- private nametag;
2354
+ private nametags;
2283
2355
  private paymentRequests;
2284
2356
  private paymentRequestHandlers;
2285
2357
  private outgoingPaymentRequests;
@@ -2637,17 +2709,6 @@ declare class PaymentsModule {
2637
2709
  * @returns `true` if the token was added, `false` if rejected as duplicate or tombstoned.
2638
2710
  */
2639
2711
  addToken(token: Token, skipHistory?: boolean): Promise<boolean>;
2640
- /**
2641
- * Save token as individual file to token storage providers
2642
- * Similar to lottery's saveReceivedToken() pattern
2643
- */
2644
- private saveTokenToFileStorage;
2645
- /**
2646
- * Load tokens from file storage providers (lottery compatibility)
2647
- * This loads tokens from file-based storage that may have been saved
2648
- * by other applications using the same storage directory.
2649
- */
2650
- private loadTokensFromFileStorage;
2651
2712
  /**
2652
2713
  * Update an existing token or add it if not found.
2653
2714
  *
@@ -2669,11 +2730,6 @@ declare class PaymentsModule {
2669
2730
  * @param skipHistory - When `true`, skip creating a transaction history entry (default `false`).
2670
2731
  */
2671
2732
  removeToken(tokenId: string, recipientNametag?: string, skipHistory?: boolean): Promise<void>;
2672
- /**
2673
- * Delete physical token file(s) from all storage providers.
2674
- * Finds files by matching the SDK token ID prefix in the filename.
2675
- */
2676
- private deleteTokenFiles;
2677
2733
  /**
2678
2734
  * Get all tombstone entries.
2679
2735
  *
@@ -2801,11 +2857,17 @@ declare class PaymentsModule {
2801
2857
  */
2802
2858
  setNametag(nametag: NametagData): Promise<void>;
2803
2859
  /**
2804
- * Get the current nametag data.
2860
+ * Get the current (first) nametag data.
2805
2861
  *
2806
2862
  * @returns The nametag data, or `null` if no nametag is set.
2807
2863
  */
2808
2864
  getNametag(): NametagData | null;
2865
+ /**
2866
+ * Get all nametag data entries.
2867
+ *
2868
+ * @returns A copy of the nametags array.
2869
+ */
2870
+ getNametags(): NametagData[];
2809
2871
  /**
2810
2872
  * Check whether a nametag is currently set.
2811
2873
  *
@@ -2813,19 +2875,9 @@ declare class PaymentsModule {
2813
2875
  */
2814
2876
  hasNametag(): boolean;
2815
2877
  /**
2816
- * Remove the current nametag data from memory and storage.
2878
+ * Remove all nametag data from memory and storage.
2817
2879
  */
2818
2880
  clearNametag(): Promise<void>;
2819
- /**
2820
- * Save nametag to file storage for lottery compatibility
2821
- * Creates file: nametag-{name}.json
2822
- */
2823
- private saveNametagToFileStorage;
2824
- /**
2825
- * Load nametag from file storage (lottery compatibility)
2826
- * Looks for file: nametag-{name}.json
2827
- */
2828
- private loadNametagFromFileStorage;
2829
2881
  /**
2830
2882
  * Mint a nametag token on-chain (like Sphere wallet and lottery)
2831
2883
  * This creates the nametag token required for receiving tokens via PROXY addresses
@@ -3060,6 +3112,127 @@ declare class CommunicationsModule {
3060
3112
  }
3061
3113
  declare function createCommunicationsModule(config?: CommunicationsModuleConfig): CommunicationsModule;
3062
3114
 
3115
+ /**
3116
+ * Group Chat Module (NIP-29)
3117
+ *
3118
+ * Relay-based group chat using NIP-29 protocol on a dedicated Nostr relay.
3119
+ * Embeds its own NostrClient — does NOT share the wallet's TransportProvider.
3120
+ */
3121
+
3122
+ interface GroupChatModuleDependencies {
3123
+ identity: FullIdentity;
3124
+ storage: StorageProvider;
3125
+ emitEvent: <T extends SphereEventType>(type: T, data: SphereEventMap[T]) => void;
3126
+ }
3127
+ declare class GroupChatModule {
3128
+ private config;
3129
+ private deps;
3130
+ private client;
3131
+ private keyManager;
3132
+ private connected;
3133
+ private connecting;
3134
+ private connectPromise;
3135
+ private reconnectAttempts;
3136
+ private reconnectTimer;
3137
+ private subscriptionIds;
3138
+ private groups;
3139
+ private messages;
3140
+ private members;
3141
+ private processedEventIds;
3142
+ private pendingLeaves;
3143
+ private persistTimer;
3144
+ private persistPromise;
3145
+ private relayAdminPubkeys;
3146
+ private relayAdminFetchPromise;
3147
+ private messageHandlers;
3148
+ constructor(config?: GroupChatModuleConfig);
3149
+ initialize(deps: GroupChatModuleDependencies): void;
3150
+ load(): Promise<void>;
3151
+ destroy(): void;
3152
+ private destroyConnection;
3153
+ connect(): Promise<void>;
3154
+ getConnectionStatus(): boolean;
3155
+ private doConnect;
3156
+ private scheduleReconnect;
3157
+ private subscribeToJoinedGroups;
3158
+ private subscribeToGroup;
3159
+ private handleGroupEvent;
3160
+ private handleMetadataEvent;
3161
+ private handleModerationEvent;
3162
+ private updateMembersFromEvent;
3163
+ private updateAdminsFromEvent;
3164
+ private restoreJoinedGroups;
3165
+ fetchAvailableGroups(): Promise<GroupData[]>;
3166
+ joinGroup(groupId: string, inviteCode?: string): Promise<boolean>;
3167
+ leaveGroup(groupId: string): Promise<boolean>;
3168
+ createGroup(options: CreateGroupOptions): Promise<GroupData | null>;
3169
+ deleteGroup(groupId: string): Promise<boolean>;
3170
+ createInvite(groupId: string): Promise<string | null>;
3171
+ sendMessage(groupId: string, content: string, replyToId?: string): Promise<GroupMessageData | null>;
3172
+ fetchMessages(groupId: string, since?: number, limit?: number): Promise<GroupMessageData[]>;
3173
+ getGroups(): GroupData[];
3174
+ getGroup(groupId: string): GroupData | null;
3175
+ getMessages(groupId: string): GroupMessageData[];
3176
+ getMembers(groupId: string): GroupMemberData[];
3177
+ getMember(groupId: string, pubkey: string): GroupMemberData | null;
3178
+ getTotalUnreadCount(): number;
3179
+ markGroupAsRead(groupId: string): void;
3180
+ kickUser(groupId: string, userPubkey: string, reason?: string): Promise<boolean>;
3181
+ deleteMessage(groupId: string, messageId: string): Promise<boolean>;
3182
+ isCurrentUserAdmin(groupId: string): boolean;
3183
+ isCurrentUserModerator(groupId: string): boolean;
3184
+ /**
3185
+ * Check if current user can moderate a group:
3186
+ * - Group admin/moderator can always moderate their group
3187
+ * - Relay admins can moderate public groups
3188
+ */
3189
+ canModerateGroup(groupId: string): Promise<boolean>;
3190
+ isCurrentUserRelayAdmin(): Promise<boolean>;
3191
+ getCurrentUserRole(groupId: string): GroupRole | null;
3192
+ onMessage(handler: (message: GroupMessageData) => void): () => void;
3193
+ getRelayUrls(): string[];
3194
+ getMyPublicKey(): string | null;
3195
+ private fetchRelayAdmins;
3196
+ private doFetchRelayAdmins;
3197
+ private fetchGroupMetadataInternal;
3198
+ private fetchAndSaveMembers;
3199
+ private fetchGroupMembersInternal;
3200
+ private fetchGroupAdminsInternal;
3201
+ private saveMessageToMemory;
3202
+ private deleteMessageFromMemory;
3203
+ private saveMemberToMemory;
3204
+ private removeMemberFromMemory;
3205
+ private removeGroupFromMemory;
3206
+ private updateGroupLastMessage;
3207
+ private updateMemberNametag;
3208
+ private addProcessedEventId;
3209
+ /** Schedule a debounced persist (coalesces rapid event bursts). */
3210
+ private schedulePersist;
3211
+ /** Persist immediately (for explicit flush points). */
3212
+ private persistAll;
3213
+ private doPersistAll;
3214
+ private persistGroups;
3215
+ private persistMessages;
3216
+ private persistMembers;
3217
+ private persistProcessedEvents;
3218
+ private checkAndClearOnRelayChange;
3219
+ private wrapMessageContent;
3220
+ private unwrapMessageContent;
3221
+ private getGroupIdFromEvent;
3222
+ private getGroupIdFromMetadataEvent;
3223
+ private extractReplyTo;
3224
+ private extractPreviousIds;
3225
+ private parseGroupMetadata;
3226
+ /** Subscribe and track the subscription ID for cleanup. */
3227
+ private trackSubscription;
3228
+ /** Subscribe for a one-shot fetch, auto-unsubscribe on EOSE or timeout. */
3229
+ private oneshotSubscription;
3230
+ private ensureInitialized;
3231
+ private ensureConnected;
3232
+ private randomId;
3233
+ }
3234
+ declare function createGroupChatModule(config?: GroupChatModuleConfig): GroupChatModule;
3235
+
3063
3236
  /**
3064
3237
  * SDK2 Constants
3065
3238
  * Default configuration values and storage keys
@@ -3104,6 +3277,16 @@ declare const STORAGE_KEYS: {
3104
3277
  readonly TRACKED_ADDRESSES: "tracked_addresses";
3105
3278
  /** Last processed Nostr wallet event timestamp (unix seconds), keyed per pubkey */
3106
3279
  readonly LAST_WALLET_EVENT_TS: "last_wallet_event_ts";
3280
+ /** Group chat: joined groups */
3281
+ readonly GROUP_CHAT_GROUPS: "group_chat_groups";
3282
+ /** Group chat: messages */
3283
+ readonly GROUP_CHAT_MESSAGES: "group_chat_messages";
3284
+ /** Group chat: members */
3285
+ readonly GROUP_CHAT_MEMBERS: "group_chat_members";
3286
+ /** Group chat: processed event IDs for deduplication */
3287
+ readonly GROUP_CHAT_PROCESSED_EVENTS: "group_chat_processed_events";
3288
+ /** Group chat: last used relay URL (stale data detection) */
3289
+ readonly GROUP_CHAT_RELAY_URL: "group_chat_relay_url";
3107
3290
  };
3108
3291
  /** Default Nostr relays */
3109
3292
  declare const DEFAULT_NOSTR_RELAYS: readonly ["wss://relay.unicity.network", "wss://relay.damus.io", "wss://nos.lol", "wss://relay.nostr.band"];
@@ -3122,6 +3305,44 @@ declare const NOSTR_EVENT_KINDS: {
3122
3305
  /** Public broadcast */
3123
3306
  readonly BROADCAST: 1;
3124
3307
  };
3308
+ /**
3309
+ * NIP-29 Event Kinds for relay-based group chat
3310
+ * https://github.com/nostr-protocol/nips/blob/master/29.md
3311
+ */
3312
+ declare const NIP29_KINDS: {
3313
+ /** Chat message sent to group */
3314
+ readonly CHAT_MESSAGE: 9;
3315
+ /** Thread root message */
3316
+ readonly THREAD_ROOT: 11;
3317
+ /** Thread reply message */
3318
+ readonly THREAD_REPLY: 12;
3319
+ /** User join request */
3320
+ readonly JOIN_REQUEST: 9021;
3321
+ /** User leave request */
3322
+ readonly LEAVE_REQUEST: 9022;
3323
+ /** Admin: add/update user */
3324
+ readonly PUT_USER: 9000;
3325
+ /** Admin: remove user */
3326
+ readonly REMOVE_USER: 9001;
3327
+ /** Admin: edit group metadata */
3328
+ readonly EDIT_METADATA: 9002;
3329
+ /** Admin: delete event */
3330
+ readonly DELETE_EVENT: 9005;
3331
+ /** Admin: create group */
3332
+ readonly CREATE_GROUP: 9007;
3333
+ /** Admin: delete group */
3334
+ readonly DELETE_GROUP: 9008;
3335
+ /** Admin: create invite code */
3336
+ readonly CREATE_INVITE: 9009;
3337
+ /** Relay-signed group metadata */
3338
+ readonly GROUP_METADATA: 39000;
3339
+ /** Relay-signed group admins */
3340
+ readonly GROUP_ADMINS: 39001;
3341
+ /** Relay-signed group members */
3342
+ readonly GROUP_MEMBERS: 39002;
3343
+ /** Relay-signed group roles */
3344
+ readonly GROUP_ROLES: 39003;
3345
+ };
3125
3346
  /**
3126
3347
  * Default aggregator URL
3127
3348
  * Note: The aggregator is conceptually an oracle - a trusted service that provides
@@ -3153,6 +3374,8 @@ declare const DEFAULT_ELECTRUM_URL: "wss://fulcrum.alpha.unicity.network:50004";
3153
3374
  declare const TEST_ELECTRUM_URL: "wss://fulcrum.alpha.testnet.unicity.network:50004";
3154
3375
  /** Testnet Nostr relays */
3155
3376
  declare const TEST_NOSTR_RELAYS: readonly ["wss://nostr-relay.testnet.unicity.network"];
3377
+ /** Default group chat relays (NIP-29 Zooid relay) */
3378
+ declare const DEFAULT_GROUP_RELAYS: readonly ["wss://sphere-relay.unicity.network"];
3156
3379
  /** Network configurations */
3157
3380
  declare const NETWORKS: {
3158
3381
  readonly mainnet: {
@@ -3161,6 +3384,7 @@ declare const NETWORKS: {
3161
3384
  readonly nostrRelays: readonly ["wss://relay.unicity.network", "wss://relay.damus.io", "wss://nos.lol", "wss://relay.nostr.band"];
3162
3385
  readonly ipfsGateways: readonly ["https://ipfs.unicity.network", "https://dweb.link", "https://ipfs.io"];
3163
3386
  readonly electrumUrl: "wss://fulcrum.alpha.unicity.network:50004";
3387
+ readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
3164
3388
  };
3165
3389
  readonly testnet: {
3166
3390
  readonly name: "Testnet";
@@ -3168,6 +3392,7 @@ declare const NETWORKS: {
3168
3392
  readonly nostrRelays: readonly ["wss://nostr-relay.testnet.unicity.network"];
3169
3393
  readonly ipfsGateways: readonly ["https://ipfs.unicity.network", "https://dweb.link", "https://ipfs.io"];
3170
3394
  readonly electrumUrl: "wss://fulcrum.alpha.testnet.unicity.network:50004";
3395
+ readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
3171
3396
  };
3172
3397
  readonly dev: {
3173
3398
  readonly name: "Development";
@@ -3175,6 +3400,7 @@ declare const NETWORKS: {
3175
3400
  readonly nostrRelays: readonly ["wss://nostr-relay.testnet.unicity.network"];
3176
3401
  readonly ipfsGateways: readonly ["https://ipfs.unicity.network", "https://dweb.link", "https://ipfs.io"];
3177
3402
  readonly electrumUrl: "wss://fulcrum.alpha.testnet.unicity.network:50004";
3403
+ readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
3178
3404
  };
3179
3405
  };
3180
3406
  type NetworkType = keyof typeof NETWORKS;
@@ -3352,6 +3578,8 @@ interface SphereCreateOptions {
3352
3578
  * Use createBrowserProviders({ network: 'testnet' }) to set up testnet providers.
3353
3579
  */
3354
3580
  network?: NetworkType;
3581
+ /** Group chat configuration (NIP-29). Omit to disable groupchat. */
3582
+ groupChat?: GroupChatModuleConfig | boolean;
3355
3583
  }
3356
3584
  /** Options for loading existing wallet */
3357
3585
  interface SphereLoadOptions {
@@ -3373,6 +3601,8 @@ interface SphereLoadOptions {
3373
3601
  * Use createBrowserProviders({ network: 'testnet' }) to set up testnet providers.
3374
3602
  */
3375
3603
  network?: NetworkType;
3604
+ /** Group chat configuration (NIP-29). Omit to disable groupchat. */
3605
+ groupChat?: GroupChatModuleConfig | boolean;
3376
3606
  }
3377
3607
  /** Options for importing a wallet */
3378
3608
  interface SphereImportOptions {
@@ -3402,6 +3632,8 @@ interface SphereImportOptions {
3402
3632
  l1?: L1Config;
3403
3633
  /** Optional price provider for fiat conversion */
3404
3634
  price?: PriceProvider;
3635
+ /** Group chat configuration (NIP-29). Omit to disable groupchat. */
3636
+ groupChat?: GroupChatModuleConfig | boolean;
3405
3637
  }
3406
3638
  /** L1 (ALPHA blockchain) configuration */
3407
3639
  interface L1Config {
@@ -3440,6 +3672,13 @@ interface SphereInitOptions {
3440
3672
  * Use createBrowserProviders({ network: 'testnet' }) to set up testnet providers.
3441
3673
  */
3442
3674
  network?: NetworkType;
3675
+ /**
3676
+ * Group chat configuration (NIP-29).
3677
+ * - `true`: Enable with network-default relays
3678
+ * - `GroupChatModuleConfig`: Enable with custom config
3679
+ * - Omit/undefined: No groupchat module
3680
+ */
3681
+ groupChat?: GroupChatModuleConfig | boolean;
3443
3682
  }
3444
3683
  /** Result of init operation */
3445
3684
  interface SphereInitResult {
@@ -3475,6 +3714,7 @@ declare class Sphere {
3475
3714
  private _priceProvider;
3476
3715
  private _payments;
3477
3716
  private _communications;
3717
+ private _groupChat;
3478
3718
  private eventHandlers;
3479
3719
  private constructor();
3480
3720
  /**
@@ -3507,6 +3747,18 @@ declare class Sphere {
3507
3747
  * ```
3508
3748
  */
3509
3749
  static init(options: SphereInitOptions): Promise<SphereInitResult>;
3750
+ /**
3751
+ * Resolve groupChat config from init/create/load options.
3752
+ * - `true` → use network-default relays
3753
+ * - `GroupChatModuleConfig` → pass through
3754
+ * - `undefined` → no groupchat
3755
+ */
3756
+ /**
3757
+ * Resolve GroupChat config from Sphere.init() options.
3758
+ * Note: impl/shared/resolvers.ts has a similar resolver for provider-level config
3759
+ * (different input shape: { enabled?, relays? }). Both fill relay URLs from network defaults.
3760
+ */
3761
+ private static resolveGroupChatConfig;
3510
3762
  /**
3511
3763
  * Create new wallet with mnemonic
3512
3764
  */
@@ -3563,6 +3815,8 @@ declare class Sphere {
3563
3815
  get payments(): PaymentsModule;
3564
3816
  /** Communications module */
3565
3817
  get communications(): CommunicationsModule;
3818
+ /** Group chat module (NIP-29). Null if not configured. */
3819
+ get groupChat(): GroupChatModule | null;
3566
3820
  /** Current identity (public info only) */
3567
3821
  get identity(): Identity | null;
3568
3822
  /** Is ready */
@@ -4350,7 +4604,7 @@ declare function txfToToken(tokenId: string, txf: TxfToken): Token;
4350
4604
  * Build TXF storage data from tokens and metadata
4351
4605
  */
4352
4606
  declare function buildTxfStorageData(tokens: Token[], meta: Omit<TxfMeta$1, 'formatVersion'>, options?: {
4353
- nametag?: NametagData;
4607
+ nametags?: NametagData[];
4354
4608
  tombstones?: TombstoneEntry[];
4355
4609
  archivedTokens?: Map<string, TxfToken>;
4356
4610
  forkedTokens?: Map<string, TxfToken>;
@@ -4361,7 +4615,7 @@ declare function buildTxfStorageData(tokens: Token[], meta: Omit<TxfMeta$1, 'for
4361
4615
  interface ParsedStorageData {
4362
4616
  tokens: Token[];
4363
4617
  meta: TxfMeta$1 | null;
4364
- nametag: NametagData | null;
4618
+ nametags: NametagData[];
4365
4619
  tombstones: TombstoneEntry[];
4366
4620
  archivedTokens: Map<string, TxfToken>;
4367
4621
  forkedTokens: Map<string, TxfToken>;
@@ -5407,4 +5661,4 @@ declare function getCoinIdBySymbol(symbol: string): string | undefined;
5407
5661
  */
5408
5662
  declare function getCoinIdByName(name: string): string | undefined;
5409
5663
 
5410
- 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, CoinGeckoPriceProvider, CommunicationsModule, type CommunicationsModuleConfig, type CommunicationsModuleDependencies, DEFAULT_AGGREGATOR_TIMEOUT, DEFAULT_AGGREGATOR_URL, DEFAULT_DERIVATION_PATH, DEFAULT_ELECTRUM_URL, DEFAULT_IPFS_BOOTSTRAP_PEERS, DEFAULT_IPFS_GATEWAYS, DEFAULT_NOSTR_RELAYS, DEV_AGGREGATOR_URL, type DecryptionProgressCallback, type DerivationMode, type DirectMessage, type ExtendedValidationResult, type FullIdentity, 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, NOSTR_EVENT_KINDS, type NametagData, 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 ProviderStatus, type ReceiveOptions, type ReceiveResult, type RegistryNetwork, STORAGE_KEYS, STORAGE_PREFIX, type SaveResult, type ScanAddressProgress, type ScanAddressesOptions, type ScanAddressesResult, type ScannedAddressResult, 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 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, countCommittedTransactions, createAddress, createCommunicationsModule, 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 };
5664
+ 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, 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 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 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 ProviderStatus, type ReceiveOptions, type ReceiveResult, type RegistryNetwork, STORAGE_KEYS, STORAGE_PREFIX, type SaveResult, type ScanAddressProgress, type ScanAddressesOptions, type ScanAddressesResult, type ScannedAddressResult, 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 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, 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 };