@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/core/index.cjs +2779 -152
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +226 -1
- package/dist/core/index.d.ts +226 -1
- package/dist/core/index.js +2775 -148
- package/dist/core/index.js.map +1 -1
- package/dist/impl/browser/index.cjs +552 -36
- package/dist/impl/browser/index.cjs.map +1 -1
- package/dist/impl/browser/index.js +555 -37
- package/dist/impl/browser/index.js.map +1 -1
- package/dist/impl/browser/ipfs.cjs +5 -1
- package/dist/impl/browser/ipfs.cjs.map +1 -1
- package/dist/impl/browser/ipfs.js +5 -1
- package/dist/impl/browser/ipfs.js.map +1 -1
- package/dist/impl/nodejs/index.cjs +499 -8
- package/dist/impl/nodejs/index.cjs.map +1 -1
- package/dist/impl/nodejs/index.d.cts +72 -0
- package/dist/impl/nodejs/index.d.ts +72 -0
- package/dist/impl/nodejs/index.js +502 -9
- package/dist/impl/nodejs/index.js.map +1 -1
- package/dist/index.cjs +2785 -152
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +327 -7
- package/dist/index.d.ts +327 -7
- package/dist/index.js +2778 -148
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -422,6 +422,27 @@ interface TransportProvider extends BaseProvider {
|
|
|
422
422
|
* @returns Unsubscribe function
|
|
423
423
|
*/
|
|
424
424
|
onPaymentRequestResponse?(handler: PaymentRequestResponseHandler): () => void;
|
|
425
|
+
/**
|
|
426
|
+
* Send a read receipt for a message
|
|
427
|
+
* @param recipientTransportPubkey - Transport pubkey of the message sender
|
|
428
|
+
* @param messageEventId - Event ID of the message being acknowledged
|
|
429
|
+
*/
|
|
430
|
+
sendReadReceipt?(recipientTransportPubkey: string, messageEventId: string): Promise<void>;
|
|
431
|
+
/**
|
|
432
|
+
* Subscribe to incoming read receipts
|
|
433
|
+
* @returns Unsubscribe function
|
|
434
|
+
*/
|
|
435
|
+
onReadReceipt?(handler: ReadReceiptHandler): () => void;
|
|
436
|
+
/**
|
|
437
|
+
* Send typing indicator to a recipient
|
|
438
|
+
* @param recipientTransportPubkey - Transport pubkey of the conversation partner
|
|
439
|
+
*/
|
|
440
|
+
sendTypingIndicator?(recipientTransportPubkey: string): Promise<void>;
|
|
441
|
+
/**
|
|
442
|
+
* Subscribe to incoming typing indicators
|
|
443
|
+
* @returns Unsubscribe function
|
|
444
|
+
*/
|
|
445
|
+
onTypingIndicator?(handler: TypingIndicatorHandler): () => void;
|
|
425
446
|
/**
|
|
426
447
|
* Get list of configured relay URLs
|
|
427
448
|
*/
|
|
@@ -511,6 +532,10 @@ interface IncomingMessage {
|
|
|
511
532
|
content: string;
|
|
512
533
|
timestamp: number;
|
|
513
534
|
encrypted: boolean;
|
|
535
|
+
/** Set when this is a self-wrap replay (sent message recovered from relay) */
|
|
536
|
+
isSelfWrap?: boolean;
|
|
537
|
+
/** Recipient pubkey — only present on self-wrap replays */
|
|
538
|
+
recipientTransportPubkey?: string;
|
|
514
539
|
}
|
|
515
540
|
type MessageHandler = (message: IncomingMessage) => void;
|
|
516
541
|
interface TokenTransferPayload {
|
|
@@ -632,6 +657,24 @@ interface PeerInfo {
|
|
|
632
657
|
/** Event timestamp */
|
|
633
658
|
timestamp: number;
|
|
634
659
|
}
|
|
660
|
+
interface IncomingReadReceipt {
|
|
661
|
+
/** Transport-specific pubkey of the sender who read the message */
|
|
662
|
+
senderTransportPubkey: string;
|
|
663
|
+
/** Event ID of the message that was read */
|
|
664
|
+
messageEventId: string;
|
|
665
|
+
/** Timestamp */
|
|
666
|
+
timestamp: number;
|
|
667
|
+
}
|
|
668
|
+
type ReadReceiptHandler = (receipt: IncomingReadReceipt) => void;
|
|
669
|
+
interface IncomingTypingIndicator {
|
|
670
|
+
/** Transport-specific pubkey of the sender who is typing */
|
|
671
|
+
senderTransportPubkey: string;
|
|
672
|
+
/** Sender's nametag (if known) */
|
|
673
|
+
senderNametag?: string;
|
|
674
|
+
/** Timestamp */
|
|
675
|
+
timestamp: number;
|
|
676
|
+
}
|
|
677
|
+
type TypingIndicatorHandler = (indicator: IncomingTypingIndicator) => void;
|
|
635
678
|
|
|
636
679
|
/**
|
|
637
680
|
* WebSocket Abstraction
|
|
@@ -724,6 +767,8 @@ declare class NostrTransportProvider implements TransportProvider {
|
|
|
724
767
|
private transferHandlers;
|
|
725
768
|
private paymentRequestHandlers;
|
|
726
769
|
private paymentRequestResponseHandlers;
|
|
770
|
+
private readReceiptHandlers;
|
|
771
|
+
private typingIndicatorHandlers;
|
|
727
772
|
private broadcastHandlers;
|
|
728
773
|
private eventCallbacks;
|
|
729
774
|
constructor(config: NostrTransportProviderConfig);
|
|
@@ -773,6 +818,10 @@ declare class NostrTransportProvider implements TransportProvider {
|
|
|
773
818
|
onPaymentRequest(handler: PaymentRequestHandler): () => void;
|
|
774
819
|
sendPaymentRequestResponse(recipientPubkey: string, payload: PaymentRequestResponsePayload): Promise<string>;
|
|
775
820
|
onPaymentRequestResponse(handler: PaymentRequestResponseHandler): () => void;
|
|
821
|
+
sendReadReceipt(recipientTransportPubkey: string, messageEventId: string): Promise<void>;
|
|
822
|
+
onReadReceipt(handler: ReadReceiptHandler): () => void;
|
|
823
|
+
sendTypingIndicator(recipientTransportPubkey: string): Promise<void>;
|
|
824
|
+
onTypingIndicator(handler: TypingIndicatorHandler): () => void;
|
|
776
825
|
/**
|
|
777
826
|
* Resolve any identifier to full peer information.
|
|
778
827
|
* Routes to the appropriate specific resolve method based on identifier format.
|
|
@@ -1112,6 +1161,7 @@ declare const NETWORKS: {
|
|
|
1112
1161
|
readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
|
|
1113
1162
|
readonly electrumUrl: "wss://fulcrum.alpha.unicity.network:50004";
|
|
1114
1163
|
readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
|
|
1164
|
+
readonly tokenRegistryUrl: "https://raw.githubusercontent.com/unicitynetwork/unicity-ids/refs/heads/main/unicity-ids.testnet.json";
|
|
1115
1165
|
};
|
|
1116
1166
|
readonly testnet: {
|
|
1117
1167
|
readonly name: "Testnet";
|
|
@@ -1120,6 +1170,7 @@ declare const NETWORKS: {
|
|
|
1120
1170
|
readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
|
|
1121
1171
|
readonly electrumUrl: "wss://fulcrum.alpha.testnet.unicity.network:50004";
|
|
1122
1172
|
readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
|
|
1173
|
+
readonly tokenRegistryUrl: "https://raw.githubusercontent.com/unicitynetwork/unicity-ids/refs/heads/main/unicity-ids.testnet.json";
|
|
1123
1174
|
};
|
|
1124
1175
|
readonly dev: {
|
|
1125
1176
|
readonly name: "Development";
|
|
@@ -1128,6 +1179,7 @@ declare const NETWORKS: {
|
|
|
1128
1179
|
readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
|
|
1129
1180
|
readonly electrumUrl: "wss://fulcrum.alpha.testnet.unicity.network:50004";
|
|
1130
1181
|
readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
|
|
1182
|
+
readonly tokenRegistryUrl: "https://raw.githubusercontent.com/unicitynetwork/unicity-ids/refs/heads/main/unicity-ids.testnet.json";
|
|
1131
1183
|
};
|
|
1132
1184
|
};
|
|
1133
1185
|
type NetworkType = keyof typeof NETWORKS;
|
|
@@ -1312,6 +1364,15 @@ interface BasePriceConfig {
|
|
|
1312
1364
|
/** Enable debug logging */
|
|
1313
1365
|
debug?: boolean;
|
|
1314
1366
|
}
|
|
1367
|
+
/**
|
|
1368
|
+
* Base market module configuration
|
|
1369
|
+
*/
|
|
1370
|
+
interface BaseMarketConfig {
|
|
1371
|
+
/** Market API base URL (default: https://market-api.unicity.network) */
|
|
1372
|
+
apiUrl?: string;
|
|
1373
|
+
/** Request timeout in ms (default: 30000) */
|
|
1374
|
+
timeout?: number;
|
|
1375
|
+
}
|
|
1315
1376
|
/**
|
|
1316
1377
|
* Base providers result
|
|
1317
1378
|
* Common structure for all platforms
|
|
@@ -1327,6 +1388,13 @@ interface BaseProviders {
|
|
|
1327
1388
|
price?: PriceProvider;
|
|
1328
1389
|
}
|
|
1329
1390
|
|
|
1391
|
+
interface MarketModuleConfig {
|
|
1392
|
+
/** Market API base URL (default: https://market-api.unicity.network) */
|
|
1393
|
+
apiUrl?: string;
|
|
1394
|
+
/** Request timeout in ms (default: 30000) */
|
|
1395
|
+
timeout?: number;
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1330
1398
|
/** IPFS storage provider configuration */
|
|
1331
1399
|
interface IpfsStorageConfig {
|
|
1332
1400
|
/** Gateway URLs for HTTP API (defaults to Unicity dedicated nodes) */
|
|
@@ -1419,6 +1487,8 @@ interface NodeProvidersConfig {
|
|
|
1419
1487
|
enabled?: boolean;
|
|
1420
1488
|
relays?: string[];
|
|
1421
1489
|
} | boolean;
|
|
1490
|
+
/** Market module configuration. true = enable with defaults, object = custom config */
|
|
1491
|
+
market?: BaseMarketConfig | boolean;
|
|
1422
1492
|
}
|
|
1423
1493
|
interface NodeProviders {
|
|
1424
1494
|
storage: StorageProvider;
|
|
@@ -1433,6 +1503,8 @@ interface NodeProviders {
|
|
|
1433
1503
|
ipfsTokenStorage?: TokenStorageProvider<TxfStorageDataBase>;
|
|
1434
1504
|
/** Group chat config (resolved, for passing to Sphere.init) */
|
|
1435
1505
|
groupChat?: GroupChatModuleConfig | boolean;
|
|
1506
|
+
/** Market module config (resolved, for passing to Sphere.init) */
|
|
1507
|
+
market?: MarketModuleConfig | boolean;
|
|
1436
1508
|
}
|
|
1437
1509
|
/**
|
|
1438
1510
|
* Create all Node.js providers with default configuration
|
|
@@ -422,6 +422,27 @@ interface TransportProvider extends BaseProvider {
|
|
|
422
422
|
* @returns Unsubscribe function
|
|
423
423
|
*/
|
|
424
424
|
onPaymentRequestResponse?(handler: PaymentRequestResponseHandler): () => void;
|
|
425
|
+
/**
|
|
426
|
+
* Send a read receipt for a message
|
|
427
|
+
* @param recipientTransportPubkey - Transport pubkey of the message sender
|
|
428
|
+
* @param messageEventId - Event ID of the message being acknowledged
|
|
429
|
+
*/
|
|
430
|
+
sendReadReceipt?(recipientTransportPubkey: string, messageEventId: string): Promise<void>;
|
|
431
|
+
/**
|
|
432
|
+
* Subscribe to incoming read receipts
|
|
433
|
+
* @returns Unsubscribe function
|
|
434
|
+
*/
|
|
435
|
+
onReadReceipt?(handler: ReadReceiptHandler): () => void;
|
|
436
|
+
/**
|
|
437
|
+
* Send typing indicator to a recipient
|
|
438
|
+
* @param recipientTransportPubkey - Transport pubkey of the conversation partner
|
|
439
|
+
*/
|
|
440
|
+
sendTypingIndicator?(recipientTransportPubkey: string): Promise<void>;
|
|
441
|
+
/**
|
|
442
|
+
* Subscribe to incoming typing indicators
|
|
443
|
+
* @returns Unsubscribe function
|
|
444
|
+
*/
|
|
445
|
+
onTypingIndicator?(handler: TypingIndicatorHandler): () => void;
|
|
425
446
|
/**
|
|
426
447
|
* Get list of configured relay URLs
|
|
427
448
|
*/
|
|
@@ -511,6 +532,10 @@ interface IncomingMessage {
|
|
|
511
532
|
content: string;
|
|
512
533
|
timestamp: number;
|
|
513
534
|
encrypted: boolean;
|
|
535
|
+
/** Set when this is a self-wrap replay (sent message recovered from relay) */
|
|
536
|
+
isSelfWrap?: boolean;
|
|
537
|
+
/** Recipient pubkey — only present on self-wrap replays */
|
|
538
|
+
recipientTransportPubkey?: string;
|
|
514
539
|
}
|
|
515
540
|
type MessageHandler = (message: IncomingMessage) => void;
|
|
516
541
|
interface TokenTransferPayload {
|
|
@@ -632,6 +657,24 @@ interface PeerInfo {
|
|
|
632
657
|
/** Event timestamp */
|
|
633
658
|
timestamp: number;
|
|
634
659
|
}
|
|
660
|
+
interface IncomingReadReceipt {
|
|
661
|
+
/** Transport-specific pubkey of the sender who read the message */
|
|
662
|
+
senderTransportPubkey: string;
|
|
663
|
+
/** Event ID of the message that was read */
|
|
664
|
+
messageEventId: string;
|
|
665
|
+
/** Timestamp */
|
|
666
|
+
timestamp: number;
|
|
667
|
+
}
|
|
668
|
+
type ReadReceiptHandler = (receipt: IncomingReadReceipt) => void;
|
|
669
|
+
interface IncomingTypingIndicator {
|
|
670
|
+
/** Transport-specific pubkey of the sender who is typing */
|
|
671
|
+
senderTransportPubkey: string;
|
|
672
|
+
/** Sender's nametag (if known) */
|
|
673
|
+
senderNametag?: string;
|
|
674
|
+
/** Timestamp */
|
|
675
|
+
timestamp: number;
|
|
676
|
+
}
|
|
677
|
+
type TypingIndicatorHandler = (indicator: IncomingTypingIndicator) => void;
|
|
635
678
|
|
|
636
679
|
/**
|
|
637
680
|
* WebSocket Abstraction
|
|
@@ -724,6 +767,8 @@ declare class NostrTransportProvider implements TransportProvider {
|
|
|
724
767
|
private transferHandlers;
|
|
725
768
|
private paymentRequestHandlers;
|
|
726
769
|
private paymentRequestResponseHandlers;
|
|
770
|
+
private readReceiptHandlers;
|
|
771
|
+
private typingIndicatorHandlers;
|
|
727
772
|
private broadcastHandlers;
|
|
728
773
|
private eventCallbacks;
|
|
729
774
|
constructor(config: NostrTransportProviderConfig);
|
|
@@ -773,6 +818,10 @@ declare class NostrTransportProvider implements TransportProvider {
|
|
|
773
818
|
onPaymentRequest(handler: PaymentRequestHandler): () => void;
|
|
774
819
|
sendPaymentRequestResponse(recipientPubkey: string, payload: PaymentRequestResponsePayload): Promise<string>;
|
|
775
820
|
onPaymentRequestResponse(handler: PaymentRequestResponseHandler): () => void;
|
|
821
|
+
sendReadReceipt(recipientTransportPubkey: string, messageEventId: string): Promise<void>;
|
|
822
|
+
onReadReceipt(handler: ReadReceiptHandler): () => void;
|
|
823
|
+
sendTypingIndicator(recipientTransportPubkey: string): Promise<void>;
|
|
824
|
+
onTypingIndicator(handler: TypingIndicatorHandler): () => void;
|
|
776
825
|
/**
|
|
777
826
|
* Resolve any identifier to full peer information.
|
|
778
827
|
* Routes to the appropriate specific resolve method based on identifier format.
|
|
@@ -1112,6 +1161,7 @@ declare const NETWORKS: {
|
|
|
1112
1161
|
readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
|
|
1113
1162
|
readonly electrumUrl: "wss://fulcrum.alpha.unicity.network:50004";
|
|
1114
1163
|
readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
|
|
1164
|
+
readonly tokenRegistryUrl: "https://raw.githubusercontent.com/unicitynetwork/unicity-ids/refs/heads/main/unicity-ids.testnet.json";
|
|
1115
1165
|
};
|
|
1116
1166
|
readonly testnet: {
|
|
1117
1167
|
readonly name: "Testnet";
|
|
@@ -1120,6 +1170,7 @@ declare const NETWORKS: {
|
|
|
1120
1170
|
readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
|
|
1121
1171
|
readonly electrumUrl: "wss://fulcrum.alpha.testnet.unicity.network:50004";
|
|
1122
1172
|
readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
|
|
1173
|
+
readonly tokenRegistryUrl: "https://raw.githubusercontent.com/unicitynetwork/unicity-ids/refs/heads/main/unicity-ids.testnet.json";
|
|
1123
1174
|
};
|
|
1124
1175
|
readonly dev: {
|
|
1125
1176
|
readonly name: "Development";
|
|
@@ -1128,6 +1179,7 @@ declare const NETWORKS: {
|
|
|
1128
1179
|
readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
|
|
1129
1180
|
readonly electrumUrl: "wss://fulcrum.alpha.testnet.unicity.network:50004";
|
|
1130
1181
|
readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
|
|
1182
|
+
readonly tokenRegistryUrl: "https://raw.githubusercontent.com/unicitynetwork/unicity-ids/refs/heads/main/unicity-ids.testnet.json";
|
|
1131
1183
|
};
|
|
1132
1184
|
};
|
|
1133
1185
|
type NetworkType = keyof typeof NETWORKS;
|
|
@@ -1312,6 +1364,15 @@ interface BasePriceConfig {
|
|
|
1312
1364
|
/** Enable debug logging */
|
|
1313
1365
|
debug?: boolean;
|
|
1314
1366
|
}
|
|
1367
|
+
/**
|
|
1368
|
+
* Base market module configuration
|
|
1369
|
+
*/
|
|
1370
|
+
interface BaseMarketConfig {
|
|
1371
|
+
/** Market API base URL (default: https://market-api.unicity.network) */
|
|
1372
|
+
apiUrl?: string;
|
|
1373
|
+
/** Request timeout in ms (default: 30000) */
|
|
1374
|
+
timeout?: number;
|
|
1375
|
+
}
|
|
1315
1376
|
/**
|
|
1316
1377
|
* Base providers result
|
|
1317
1378
|
* Common structure for all platforms
|
|
@@ -1327,6 +1388,13 @@ interface BaseProviders {
|
|
|
1327
1388
|
price?: PriceProvider;
|
|
1328
1389
|
}
|
|
1329
1390
|
|
|
1391
|
+
interface MarketModuleConfig {
|
|
1392
|
+
/** Market API base URL (default: https://market-api.unicity.network) */
|
|
1393
|
+
apiUrl?: string;
|
|
1394
|
+
/** Request timeout in ms (default: 30000) */
|
|
1395
|
+
timeout?: number;
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1330
1398
|
/** IPFS storage provider configuration */
|
|
1331
1399
|
interface IpfsStorageConfig {
|
|
1332
1400
|
/** Gateway URLs for HTTP API (defaults to Unicity dedicated nodes) */
|
|
@@ -1419,6 +1487,8 @@ interface NodeProvidersConfig {
|
|
|
1419
1487
|
enabled?: boolean;
|
|
1420
1488
|
relays?: string[];
|
|
1421
1489
|
} | boolean;
|
|
1490
|
+
/** Market module configuration. true = enable with defaults, object = custom config */
|
|
1491
|
+
market?: BaseMarketConfig | boolean;
|
|
1422
1492
|
}
|
|
1423
1493
|
interface NodeProviders {
|
|
1424
1494
|
storage: StorageProvider;
|
|
@@ -1433,6 +1503,8 @@ interface NodeProviders {
|
|
|
1433
1503
|
ipfsTokenStorage?: TokenStorageProvider<TxfStorageDataBase>;
|
|
1434
1504
|
/** Group chat config (resolved, for passing to Sphere.init) */
|
|
1435
1505
|
groupChat?: GroupChatModuleConfig | boolean;
|
|
1506
|
+
/** Market module config (resolved, for passing to Sphere.init) */
|
|
1507
|
+
market?: MarketModuleConfig | boolean;
|
|
1436
1508
|
}
|
|
1437
1509
|
/**
|
|
1438
1510
|
* Create all Node.js providers with default configuration
|