@unicitylabs/sphere-sdk 0.2.3 → 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/README.md +61 -20
- package/dist/core/index.cjs +5764 -3576
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +648 -256
- package/dist/core/index.d.ts +648 -256
- package/dist/core/index.js +5767 -3576
- package/dist/core/index.js.map +1 -1
- package/dist/impl/browser/index.cjs +2118 -185
- package/dist/impl/browser/index.cjs.map +1 -1
- package/dist/impl/browser/index.js +2118 -185
- package/dist/impl/browser/index.js.map +1 -1
- package/dist/impl/browser/ipfs.cjs +1823 -513
- package/dist/impl/browser/ipfs.cjs.map +1 -1
- package/dist/impl/browser/ipfs.js +1823 -513
- package/dist/impl/browser/ipfs.js.map +1 -1
- package/dist/impl/nodejs/index.cjs +2110 -183
- package/dist/impl/nodejs/index.cjs.map +1 -1
- package/dist/impl/nodejs/index.d.cts +86 -23
- package/dist/impl/nodejs/index.d.ts +86 -23
- package/dist/impl/nodejs/index.js +2110 -183
- package/dist/impl/nodejs/index.js.map +1 -1
- package/dist/index.cjs +5782 -3603
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +719 -105
- package/dist/index.d.ts +719 -105
- package/dist/index.js +5780 -3603
- package/dist/index.js.map +1 -1
- package/package.json +28 -6
|
@@ -3,6 +3,19 @@ import { AggregatorClient } from '@unicitylabs/state-transition-sdk/lib/api/Aggr
|
|
|
3
3
|
import { RootTrustBase } from '@unicitylabs/state-transition-sdk/lib/bft/RootTrustBase';
|
|
4
4
|
import { TransferCommitment as TransferCommitment$1 } from '@unicitylabs/state-transition-sdk/lib/transaction/TransferCommitment';
|
|
5
5
|
|
|
6
|
+
interface GroupChatModuleConfig {
|
|
7
|
+
/** Override relay URLs (default: from network config) */
|
|
8
|
+
relays?: string[];
|
|
9
|
+
/** Default message fetch limit (default: 50) */
|
|
10
|
+
defaultMessageLimit?: number;
|
|
11
|
+
/** Max previous message IDs in ordering tags (default: 3) */
|
|
12
|
+
maxPreviousTags?: number;
|
|
13
|
+
/** Reconnect delay in ms (default: 3000) */
|
|
14
|
+
reconnectDelayMs?: number;
|
|
15
|
+
/** Max reconnect attempts (default: 5) */
|
|
16
|
+
maxReconnectAttempts?: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
6
19
|
/**
|
|
7
20
|
* SDK2 Core Types
|
|
8
21
|
* Platform-independent type definitions
|
|
@@ -160,24 +173,8 @@ interface TokenStorageProvider<TData = unknown> extends BaseProvider {
|
|
|
160
173
|
* Subscribe to storage events
|
|
161
174
|
*/
|
|
162
175
|
onEvent?(callback: StorageEventCallback): () => void;
|
|
163
|
-
/**
|
|
164
|
-
* Save individual token (for file-based storage like lottery pattern)
|
|
165
|
-
*/
|
|
166
|
-
saveToken?(tokenId: string, tokenData: unknown): Promise<void>;
|
|
167
|
-
/**
|
|
168
|
-
* Get individual token
|
|
169
|
-
*/
|
|
170
|
-
getToken?(tokenId: string): Promise<unknown | null>;
|
|
171
|
-
/**
|
|
172
|
-
* List all token IDs
|
|
173
|
-
*/
|
|
174
|
-
listTokenIds?(): Promise<string[]>;
|
|
175
|
-
/**
|
|
176
|
-
* Delete individual token
|
|
177
|
-
*/
|
|
178
|
-
deleteToken?(tokenId: string): Promise<void>;
|
|
179
176
|
}
|
|
180
|
-
type StorageEventType = 'storage:saving' | 'storage:saved' | 'storage:loading' | 'storage:loaded' | 'storage:error' | 'sync:started' | 'sync:completed' | 'sync:conflict' | 'sync:error';
|
|
177
|
+
type StorageEventType = 'storage:saving' | 'storage:saved' | 'storage:loading' | 'storage:loaded' | 'storage:error' | 'storage:remote-updated' | 'sync:started' | 'sync:completed' | 'sync:conflict' | 'sync:error';
|
|
181
178
|
interface StorageEvent {
|
|
182
179
|
type: StorageEventType;
|
|
183
180
|
timestamp: number;
|
|
@@ -301,10 +298,6 @@ declare class FileTokenStorageProvider implements TokenStorageProvider<TxfStorag
|
|
|
301
298
|
save(data: TxfStorageDataBase): Promise<SaveResult>;
|
|
302
299
|
sync(localData: TxfStorageDataBase): Promise<SyncResult<TxfStorageDataBase>>;
|
|
303
300
|
clear(): Promise<boolean>;
|
|
304
|
-
deleteToken(tokenId: string): Promise<void>;
|
|
305
|
-
saveToken(tokenId: string, tokenData: unknown): Promise<void>;
|
|
306
|
-
getToken(tokenId: string): Promise<unknown | null>;
|
|
307
|
-
listTokenIds(): Promise<string[]>;
|
|
308
301
|
}
|
|
309
302
|
declare function createFileTokenStorageProvider(config: FileTokenStorageConfig | string): FileTokenStorageProvider;
|
|
310
303
|
|
|
@@ -470,6 +463,12 @@ interface TransportProvider extends BaseProvider {
|
|
|
470
463
|
* @returns Unsubscribe function
|
|
471
464
|
*/
|
|
472
465
|
onInstantSplitReceived?(handler: InstantSplitBundleHandler): () => void;
|
|
466
|
+
/**
|
|
467
|
+
* Fetch pending events from transport (one-shot query).
|
|
468
|
+
* Creates a temporary subscription, processes events through normal handlers,
|
|
469
|
+
* and resolves after EOSE (End Of Stored Events).
|
|
470
|
+
*/
|
|
471
|
+
fetchPendingEvents?(): Promise<void>;
|
|
473
472
|
}
|
|
474
473
|
/**
|
|
475
474
|
* Payload for sending instant split bundles
|
|
@@ -534,7 +533,7 @@ interface IncomingTokenTransfer {
|
|
|
534
533
|
payload: TokenTransferPayload;
|
|
535
534
|
timestamp: number;
|
|
536
535
|
}
|
|
537
|
-
type TokenTransferHandler = (transfer: IncomingTokenTransfer) => void
|
|
536
|
+
type TokenTransferHandler = (transfer: IncomingTokenTransfer) => void | Promise<void>;
|
|
538
537
|
interface PaymentRequestPayload {
|
|
539
538
|
/** Amount requested (in smallest units) */
|
|
540
539
|
amount: string | bigint;
|
|
@@ -719,6 +718,7 @@ declare class NostrTransportProvider implements TransportProvider {
|
|
|
719
718
|
private status;
|
|
720
719
|
private nostrClient;
|
|
721
720
|
private mainSubscriptionId;
|
|
721
|
+
private processedEventIds;
|
|
722
722
|
private messageHandlers;
|
|
723
723
|
private transferHandlers;
|
|
724
724
|
private paymentRequestHandlers;
|
|
@@ -830,6 +830,7 @@ declare class NostrTransportProvider implements TransportProvider {
|
|
|
830
830
|
private createEvent;
|
|
831
831
|
private createEncryptedEvent;
|
|
832
832
|
private publishEvent;
|
|
833
|
+
fetchPendingEvents(): Promise<void>;
|
|
833
834
|
private queryEvents;
|
|
834
835
|
private walletSubscriptionId;
|
|
835
836
|
private chatSubscriptionId;
|
|
@@ -1109,6 +1110,7 @@ declare const NETWORKS: {
|
|
|
1109
1110
|
readonly nostrRelays: readonly ["wss://relay.unicity.network", "wss://relay.damus.io", "wss://nos.lol", "wss://relay.nostr.band"];
|
|
1110
1111
|
readonly ipfsGateways: readonly ["https://ipfs.unicity.network", "https://dweb.link", "https://ipfs.io"];
|
|
1111
1112
|
readonly electrumUrl: "wss://fulcrum.alpha.unicity.network:50004";
|
|
1113
|
+
readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
|
|
1112
1114
|
};
|
|
1113
1115
|
readonly testnet: {
|
|
1114
1116
|
readonly name: "Testnet";
|
|
@@ -1116,6 +1118,7 @@ declare const NETWORKS: {
|
|
|
1116
1118
|
readonly nostrRelays: readonly ["wss://nostr-relay.testnet.unicity.network"];
|
|
1117
1119
|
readonly ipfsGateways: readonly ["https://ipfs.unicity.network", "https://dweb.link", "https://ipfs.io"];
|
|
1118
1120
|
readonly electrumUrl: "wss://fulcrum.alpha.testnet.unicity.network:50004";
|
|
1121
|
+
readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
|
|
1119
1122
|
};
|
|
1120
1123
|
readonly dev: {
|
|
1121
1124
|
readonly name: "Development";
|
|
@@ -1123,6 +1126,7 @@ declare const NETWORKS: {
|
|
|
1123
1126
|
readonly nostrRelays: readonly ["wss://nostr-relay.testnet.unicity.network"];
|
|
1124
1127
|
readonly ipfsGateways: readonly ["https://ipfs.unicity.network", "https://dweb.link", "https://ipfs.io"];
|
|
1125
1128
|
readonly electrumUrl: "wss://fulcrum.alpha.testnet.unicity.network:50004";
|
|
1129
|
+
readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
|
|
1126
1130
|
};
|
|
1127
1131
|
};
|
|
1128
1132
|
type NetworkType = keyof typeof NETWORKS;
|
|
@@ -1322,6 +1326,42 @@ interface BaseProviders {
|
|
|
1322
1326
|
price?: PriceProvider;
|
|
1323
1327
|
}
|
|
1324
1328
|
|
|
1329
|
+
/** IPFS storage provider configuration */
|
|
1330
|
+
interface IpfsStorageConfig {
|
|
1331
|
+
/** Gateway URLs for HTTP API (defaults to Unicity dedicated nodes) */
|
|
1332
|
+
gateways?: string[];
|
|
1333
|
+
/** Content fetch timeout in ms (default: 15000) */
|
|
1334
|
+
fetchTimeoutMs?: number;
|
|
1335
|
+
/** IPNS resolution timeout in ms (default: 10000) */
|
|
1336
|
+
resolveTimeoutMs?: number;
|
|
1337
|
+
/** IPNS publish timeout in ms (default: 30000) */
|
|
1338
|
+
publishTimeoutMs?: number;
|
|
1339
|
+
/** Gateway connectivity test timeout in ms (default: 5000) */
|
|
1340
|
+
connectivityTimeoutMs?: number;
|
|
1341
|
+
/** IPNS record lifetime in ms (default: 99 years) */
|
|
1342
|
+
ipnsLifetimeMs?: number;
|
|
1343
|
+
/** IPNS cache TTL in ms (default: 60000) */
|
|
1344
|
+
ipnsCacheTtlMs?: number;
|
|
1345
|
+
/** Circuit breaker failure threshold (default: 3) */
|
|
1346
|
+
circuitBreakerThreshold?: number;
|
|
1347
|
+
/** Circuit breaker cooldown in ms (default: 60000) */
|
|
1348
|
+
circuitBreakerCooldownMs?: number;
|
|
1349
|
+
/** Known-fresh window in ms (default: 30000) */
|
|
1350
|
+
knownFreshWindowMs?: number;
|
|
1351
|
+
/** Enable debug logging (default: false) */
|
|
1352
|
+
debug?: boolean;
|
|
1353
|
+
/** WebSocket factory for IPNS push subscriptions (cross-platform) */
|
|
1354
|
+
createWebSocket?: WebSocketFactory;
|
|
1355
|
+
/** Override WebSocket URL (auto-derived from gateways if omitted) */
|
|
1356
|
+
wsUrl?: string;
|
|
1357
|
+
/** Fallback polling interval in ms when WS unavailable (default: 90000) */
|
|
1358
|
+
fallbackPollIntervalMs?: number;
|
|
1359
|
+
/** Debounce for push-triggered sync in ms (default: 500) */
|
|
1360
|
+
syncDebounceMs?: number;
|
|
1361
|
+
/** Debounce interval for background flush in ms (default: 2000) */
|
|
1362
|
+
flushDebounceMs?: number;
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1325
1365
|
/**
|
|
1326
1366
|
* Node.js Implementation
|
|
1327
1367
|
* Providers for CLI/Node.js usage
|
|
@@ -1342,6 +1382,18 @@ type NodeOracleConfig = BaseOracleConfig & NodeOracleExtensions;
|
|
|
1342
1382
|
* Same as base
|
|
1343
1383
|
*/
|
|
1344
1384
|
type NodeL1Config = L1Config;
|
|
1385
|
+
/** Node.js IPFS sync configuration */
|
|
1386
|
+
interface NodeIpfsSyncConfig {
|
|
1387
|
+
/** Enable IPFS sync (default: false) */
|
|
1388
|
+
enabled?: boolean;
|
|
1389
|
+
/** IPFS storage provider configuration */
|
|
1390
|
+
config?: IpfsStorageConfig;
|
|
1391
|
+
}
|
|
1392
|
+
/** Node.js token sync configuration */
|
|
1393
|
+
interface NodeTokenSyncConfig {
|
|
1394
|
+
/** IPFS sync backend */
|
|
1395
|
+
ipfs?: NodeIpfsSyncConfig;
|
|
1396
|
+
}
|
|
1345
1397
|
interface NodeProvidersConfig {
|
|
1346
1398
|
/** Network preset: mainnet, testnet, or dev */
|
|
1347
1399
|
network?: NetworkType;
|
|
@@ -1357,6 +1409,13 @@ interface NodeProvidersConfig {
|
|
|
1357
1409
|
l1?: NodeL1Config;
|
|
1358
1410
|
/** Price provider configuration (optional — enables fiat value display) */
|
|
1359
1411
|
price?: BasePriceConfig;
|
|
1412
|
+
/** Token sync backends configuration */
|
|
1413
|
+
tokenSync?: NodeTokenSyncConfig;
|
|
1414
|
+
/** Group chat (NIP-29) configuration. true = enable with defaults, object = custom config */
|
|
1415
|
+
groupChat?: {
|
|
1416
|
+
enabled?: boolean;
|
|
1417
|
+
relays?: string[];
|
|
1418
|
+
} | boolean;
|
|
1360
1419
|
}
|
|
1361
1420
|
interface NodeProviders {
|
|
1362
1421
|
storage: StorageProvider;
|
|
@@ -1367,6 +1426,10 @@ interface NodeProviders {
|
|
|
1367
1426
|
l1?: L1Config;
|
|
1368
1427
|
/** Price provider (optional — enables fiat value display) */
|
|
1369
1428
|
price?: PriceProvider;
|
|
1429
|
+
/** IPFS token storage provider (when tokenSync.ipfs.enabled is true) */
|
|
1430
|
+
ipfsTokenStorage?: TokenStorageProvider<TxfStorageDataBase>;
|
|
1431
|
+
/** Group chat config (resolved, for passing to Sphere.init) */
|
|
1432
|
+
groupChat?: GroupChatModuleConfig | boolean;
|
|
1370
1433
|
}
|
|
1371
1434
|
/**
|
|
1372
1435
|
* Create all Node.js providers with default configuration
|
|
@@ -1406,4 +1469,4 @@ interface NodeProviders {
|
|
|
1406
1469
|
*/
|
|
1407
1470
|
declare function createNodeProviders(config?: NodeProvidersConfig): NodeProviders;
|
|
1408
1471
|
|
|
1409
|
-
export { type BaseOracleConfig, type BaseProviders, type BaseTransportConfig, FileStorageProvider, type FileStorageProviderConfig, type FileTokenStorageConfig, FileTokenStorageProvider, type IWebSocket, type L1Config, type NodeL1Config, type NodeOracleConfig, type NodeProviders, type NodeProvidersConfig, type NodeTransportConfig, NodeTrustBaseLoader, NostrTransportProvider, type NostrTransportProviderConfig, type TrustBaseLoader$1 as TrustBaseLoader, UnicityAggregatorProvider, type UnicityAggregatorProviderConfig, UnicityOracleProvider, type UnicityOracleProviderConfig, type WebSocketFactory, createFileStorageProvider, createFileTokenStorageProvider, createNodeProviders, createNodeTrustBaseLoader, createNodeWebSocketFactory, createNostrTransportProvider, createUnicityAggregatorProvider, createUnicityOracleProvider };
|
|
1472
|
+
export { type BaseOracleConfig, type BaseProviders, type BaseTransportConfig, FileStorageProvider, type FileStorageProviderConfig, type FileTokenStorageConfig, FileTokenStorageProvider, type IWebSocket, type L1Config, type NodeIpfsSyncConfig, type NodeL1Config, type NodeOracleConfig, type NodeProviders, type NodeProvidersConfig, type NodeTokenSyncConfig, type NodeTransportConfig, NodeTrustBaseLoader, NostrTransportProvider, type NostrTransportProviderConfig, type TrustBaseLoader$1 as TrustBaseLoader, UnicityAggregatorProvider, type UnicityAggregatorProviderConfig, UnicityOracleProvider, type UnicityOracleProviderConfig, type WebSocketFactory, createFileStorageProvider, createFileTokenStorageProvider, createNodeProviders, createNodeTrustBaseLoader, createNodeWebSocketFactory, createNostrTransportProvider, createUnicityAggregatorProvider, createUnicityOracleProvider };
|
|
@@ -3,6 +3,19 @@ import { AggregatorClient } from '@unicitylabs/state-transition-sdk/lib/api/Aggr
|
|
|
3
3
|
import { RootTrustBase } from '@unicitylabs/state-transition-sdk/lib/bft/RootTrustBase';
|
|
4
4
|
import { TransferCommitment as TransferCommitment$1 } from '@unicitylabs/state-transition-sdk/lib/transaction/TransferCommitment';
|
|
5
5
|
|
|
6
|
+
interface GroupChatModuleConfig {
|
|
7
|
+
/** Override relay URLs (default: from network config) */
|
|
8
|
+
relays?: string[];
|
|
9
|
+
/** Default message fetch limit (default: 50) */
|
|
10
|
+
defaultMessageLimit?: number;
|
|
11
|
+
/** Max previous message IDs in ordering tags (default: 3) */
|
|
12
|
+
maxPreviousTags?: number;
|
|
13
|
+
/** Reconnect delay in ms (default: 3000) */
|
|
14
|
+
reconnectDelayMs?: number;
|
|
15
|
+
/** Max reconnect attempts (default: 5) */
|
|
16
|
+
maxReconnectAttempts?: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
6
19
|
/**
|
|
7
20
|
* SDK2 Core Types
|
|
8
21
|
* Platform-independent type definitions
|
|
@@ -160,24 +173,8 @@ interface TokenStorageProvider<TData = unknown> extends BaseProvider {
|
|
|
160
173
|
* Subscribe to storage events
|
|
161
174
|
*/
|
|
162
175
|
onEvent?(callback: StorageEventCallback): () => void;
|
|
163
|
-
/**
|
|
164
|
-
* Save individual token (for file-based storage like lottery pattern)
|
|
165
|
-
*/
|
|
166
|
-
saveToken?(tokenId: string, tokenData: unknown): Promise<void>;
|
|
167
|
-
/**
|
|
168
|
-
* Get individual token
|
|
169
|
-
*/
|
|
170
|
-
getToken?(tokenId: string): Promise<unknown | null>;
|
|
171
|
-
/**
|
|
172
|
-
* List all token IDs
|
|
173
|
-
*/
|
|
174
|
-
listTokenIds?(): Promise<string[]>;
|
|
175
|
-
/**
|
|
176
|
-
* Delete individual token
|
|
177
|
-
*/
|
|
178
|
-
deleteToken?(tokenId: string): Promise<void>;
|
|
179
176
|
}
|
|
180
|
-
type StorageEventType = 'storage:saving' | 'storage:saved' | 'storage:loading' | 'storage:loaded' | 'storage:error' | 'sync:started' | 'sync:completed' | 'sync:conflict' | 'sync:error';
|
|
177
|
+
type StorageEventType = 'storage:saving' | 'storage:saved' | 'storage:loading' | 'storage:loaded' | 'storage:error' | 'storage:remote-updated' | 'sync:started' | 'sync:completed' | 'sync:conflict' | 'sync:error';
|
|
181
178
|
interface StorageEvent {
|
|
182
179
|
type: StorageEventType;
|
|
183
180
|
timestamp: number;
|
|
@@ -301,10 +298,6 @@ declare class FileTokenStorageProvider implements TokenStorageProvider<TxfStorag
|
|
|
301
298
|
save(data: TxfStorageDataBase): Promise<SaveResult>;
|
|
302
299
|
sync(localData: TxfStorageDataBase): Promise<SyncResult<TxfStorageDataBase>>;
|
|
303
300
|
clear(): Promise<boolean>;
|
|
304
|
-
deleteToken(tokenId: string): Promise<void>;
|
|
305
|
-
saveToken(tokenId: string, tokenData: unknown): Promise<void>;
|
|
306
|
-
getToken(tokenId: string): Promise<unknown | null>;
|
|
307
|
-
listTokenIds(): Promise<string[]>;
|
|
308
301
|
}
|
|
309
302
|
declare function createFileTokenStorageProvider(config: FileTokenStorageConfig | string): FileTokenStorageProvider;
|
|
310
303
|
|
|
@@ -470,6 +463,12 @@ interface TransportProvider extends BaseProvider {
|
|
|
470
463
|
* @returns Unsubscribe function
|
|
471
464
|
*/
|
|
472
465
|
onInstantSplitReceived?(handler: InstantSplitBundleHandler): () => void;
|
|
466
|
+
/**
|
|
467
|
+
* Fetch pending events from transport (one-shot query).
|
|
468
|
+
* Creates a temporary subscription, processes events through normal handlers,
|
|
469
|
+
* and resolves after EOSE (End Of Stored Events).
|
|
470
|
+
*/
|
|
471
|
+
fetchPendingEvents?(): Promise<void>;
|
|
473
472
|
}
|
|
474
473
|
/**
|
|
475
474
|
* Payload for sending instant split bundles
|
|
@@ -534,7 +533,7 @@ interface IncomingTokenTransfer {
|
|
|
534
533
|
payload: TokenTransferPayload;
|
|
535
534
|
timestamp: number;
|
|
536
535
|
}
|
|
537
|
-
type TokenTransferHandler = (transfer: IncomingTokenTransfer) => void
|
|
536
|
+
type TokenTransferHandler = (transfer: IncomingTokenTransfer) => void | Promise<void>;
|
|
538
537
|
interface PaymentRequestPayload {
|
|
539
538
|
/** Amount requested (in smallest units) */
|
|
540
539
|
amount: string | bigint;
|
|
@@ -719,6 +718,7 @@ declare class NostrTransportProvider implements TransportProvider {
|
|
|
719
718
|
private status;
|
|
720
719
|
private nostrClient;
|
|
721
720
|
private mainSubscriptionId;
|
|
721
|
+
private processedEventIds;
|
|
722
722
|
private messageHandlers;
|
|
723
723
|
private transferHandlers;
|
|
724
724
|
private paymentRequestHandlers;
|
|
@@ -830,6 +830,7 @@ declare class NostrTransportProvider implements TransportProvider {
|
|
|
830
830
|
private createEvent;
|
|
831
831
|
private createEncryptedEvent;
|
|
832
832
|
private publishEvent;
|
|
833
|
+
fetchPendingEvents(): Promise<void>;
|
|
833
834
|
private queryEvents;
|
|
834
835
|
private walletSubscriptionId;
|
|
835
836
|
private chatSubscriptionId;
|
|
@@ -1109,6 +1110,7 @@ declare const NETWORKS: {
|
|
|
1109
1110
|
readonly nostrRelays: readonly ["wss://relay.unicity.network", "wss://relay.damus.io", "wss://nos.lol", "wss://relay.nostr.band"];
|
|
1110
1111
|
readonly ipfsGateways: readonly ["https://ipfs.unicity.network", "https://dweb.link", "https://ipfs.io"];
|
|
1111
1112
|
readonly electrumUrl: "wss://fulcrum.alpha.unicity.network:50004";
|
|
1113
|
+
readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
|
|
1112
1114
|
};
|
|
1113
1115
|
readonly testnet: {
|
|
1114
1116
|
readonly name: "Testnet";
|
|
@@ -1116,6 +1118,7 @@ declare const NETWORKS: {
|
|
|
1116
1118
|
readonly nostrRelays: readonly ["wss://nostr-relay.testnet.unicity.network"];
|
|
1117
1119
|
readonly ipfsGateways: readonly ["https://ipfs.unicity.network", "https://dweb.link", "https://ipfs.io"];
|
|
1118
1120
|
readonly electrumUrl: "wss://fulcrum.alpha.testnet.unicity.network:50004";
|
|
1121
|
+
readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
|
|
1119
1122
|
};
|
|
1120
1123
|
readonly dev: {
|
|
1121
1124
|
readonly name: "Development";
|
|
@@ -1123,6 +1126,7 @@ declare const NETWORKS: {
|
|
|
1123
1126
|
readonly nostrRelays: readonly ["wss://nostr-relay.testnet.unicity.network"];
|
|
1124
1127
|
readonly ipfsGateways: readonly ["https://ipfs.unicity.network", "https://dweb.link", "https://ipfs.io"];
|
|
1125
1128
|
readonly electrumUrl: "wss://fulcrum.alpha.testnet.unicity.network:50004";
|
|
1129
|
+
readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
|
|
1126
1130
|
};
|
|
1127
1131
|
};
|
|
1128
1132
|
type NetworkType = keyof typeof NETWORKS;
|
|
@@ -1322,6 +1326,42 @@ interface BaseProviders {
|
|
|
1322
1326
|
price?: PriceProvider;
|
|
1323
1327
|
}
|
|
1324
1328
|
|
|
1329
|
+
/** IPFS storage provider configuration */
|
|
1330
|
+
interface IpfsStorageConfig {
|
|
1331
|
+
/** Gateway URLs for HTTP API (defaults to Unicity dedicated nodes) */
|
|
1332
|
+
gateways?: string[];
|
|
1333
|
+
/** Content fetch timeout in ms (default: 15000) */
|
|
1334
|
+
fetchTimeoutMs?: number;
|
|
1335
|
+
/** IPNS resolution timeout in ms (default: 10000) */
|
|
1336
|
+
resolveTimeoutMs?: number;
|
|
1337
|
+
/** IPNS publish timeout in ms (default: 30000) */
|
|
1338
|
+
publishTimeoutMs?: number;
|
|
1339
|
+
/** Gateway connectivity test timeout in ms (default: 5000) */
|
|
1340
|
+
connectivityTimeoutMs?: number;
|
|
1341
|
+
/** IPNS record lifetime in ms (default: 99 years) */
|
|
1342
|
+
ipnsLifetimeMs?: number;
|
|
1343
|
+
/** IPNS cache TTL in ms (default: 60000) */
|
|
1344
|
+
ipnsCacheTtlMs?: number;
|
|
1345
|
+
/** Circuit breaker failure threshold (default: 3) */
|
|
1346
|
+
circuitBreakerThreshold?: number;
|
|
1347
|
+
/** Circuit breaker cooldown in ms (default: 60000) */
|
|
1348
|
+
circuitBreakerCooldownMs?: number;
|
|
1349
|
+
/** Known-fresh window in ms (default: 30000) */
|
|
1350
|
+
knownFreshWindowMs?: number;
|
|
1351
|
+
/** Enable debug logging (default: false) */
|
|
1352
|
+
debug?: boolean;
|
|
1353
|
+
/** WebSocket factory for IPNS push subscriptions (cross-platform) */
|
|
1354
|
+
createWebSocket?: WebSocketFactory;
|
|
1355
|
+
/** Override WebSocket URL (auto-derived from gateways if omitted) */
|
|
1356
|
+
wsUrl?: string;
|
|
1357
|
+
/** Fallback polling interval in ms when WS unavailable (default: 90000) */
|
|
1358
|
+
fallbackPollIntervalMs?: number;
|
|
1359
|
+
/** Debounce for push-triggered sync in ms (default: 500) */
|
|
1360
|
+
syncDebounceMs?: number;
|
|
1361
|
+
/** Debounce interval for background flush in ms (default: 2000) */
|
|
1362
|
+
flushDebounceMs?: number;
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1325
1365
|
/**
|
|
1326
1366
|
* Node.js Implementation
|
|
1327
1367
|
* Providers for CLI/Node.js usage
|
|
@@ -1342,6 +1382,18 @@ type NodeOracleConfig = BaseOracleConfig & NodeOracleExtensions;
|
|
|
1342
1382
|
* Same as base
|
|
1343
1383
|
*/
|
|
1344
1384
|
type NodeL1Config = L1Config;
|
|
1385
|
+
/** Node.js IPFS sync configuration */
|
|
1386
|
+
interface NodeIpfsSyncConfig {
|
|
1387
|
+
/** Enable IPFS sync (default: false) */
|
|
1388
|
+
enabled?: boolean;
|
|
1389
|
+
/** IPFS storage provider configuration */
|
|
1390
|
+
config?: IpfsStorageConfig;
|
|
1391
|
+
}
|
|
1392
|
+
/** Node.js token sync configuration */
|
|
1393
|
+
interface NodeTokenSyncConfig {
|
|
1394
|
+
/** IPFS sync backend */
|
|
1395
|
+
ipfs?: NodeIpfsSyncConfig;
|
|
1396
|
+
}
|
|
1345
1397
|
interface NodeProvidersConfig {
|
|
1346
1398
|
/** Network preset: mainnet, testnet, or dev */
|
|
1347
1399
|
network?: NetworkType;
|
|
@@ -1357,6 +1409,13 @@ interface NodeProvidersConfig {
|
|
|
1357
1409
|
l1?: NodeL1Config;
|
|
1358
1410
|
/** Price provider configuration (optional — enables fiat value display) */
|
|
1359
1411
|
price?: BasePriceConfig;
|
|
1412
|
+
/** Token sync backends configuration */
|
|
1413
|
+
tokenSync?: NodeTokenSyncConfig;
|
|
1414
|
+
/** Group chat (NIP-29) configuration. true = enable with defaults, object = custom config */
|
|
1415
|
+
groupChat?: {
|
|
1416
|
+
enabled?: boolean;
|
|
1417
|
+
relays?: string[];
|
|
1418
|
+
} | boolean;
|
|
1360
1419
|
}
|
|
1361
1420
|
interface NodeProviders {
|
|
1362
1421
|
storage: StorageProvider;
|
|
@@ -1367,6 +1426,10 @@ interface NodeProviders {
|
|
|
1367
1426
|
l1?: L1Config;
|
|
1368
1427
|
/** Price provider (optional — enables fiat value display) */
|
|
1369
1428
|
price?: PriceProvider;
|
|
1429
|
+
/** IPFS token storage provider (when tokenSync.ipfs.enabled is true) */
|
|
1430
|
+
ipfsTokenStorage?: TokenStorageProvider<TxfStorageDataBase>;
|
|
1431
|
+
/** Group chat config (resolved, for passing to Sphere.init) */
|
|
1432
|
+
groupChat?: GroupChatModuleConfig | boolean;
|
|
1370
1433
|
}
|
|
1371
1434
|
/**
|
|
1372
1435
|
* Create all Node.js providers with default configuration
|
|
@@ -1406,4 +1469,4 @@ interface NodeProviders {
|
|
|
1406
1469
|
*/
|
|
1407
1470
|
declare function createNodeProviders(config?: NodeProvidersConfig): NodeProviders;
|
|
1408
1471
|
|
|
1409
|
-
export { type BaseOracleConfig, type BaseProviders, type BaseTransportConfig, FileStorageProvider, type FileStorageProviderConfig, type FileTokenStorageConfig, FileTokenStorageProvider, type IWebSocket, type L1Config, type NodeL1Config, type NodeOracleConfig, type NodeProviders, type NodeProvidersConfig, type NodeTransportConfig, NodeTrustBaseLoader, NostrTransportProvider, type NostrTransportProviderConfig, type TrustBaseLoader$1 as TrustBaseLoader, UnicityAggregatorProvider, type UnicityAggregatorProviderConfig, UnicityOracleProvider, type UnicityOracleProviderConfig, type WebSocketFactory, createFileStorageProvider, createFileTokenStorageProvider, createNodeProviders, createNodeTrustBaseLoader, createNodeWebSocketFactory, createNostrTransportProvider, createUnicityAggregatorProvider, createUnicityOracleProvider };
|
|
1472
|
+
export { type BaseOracleConfig, type BaseProviders, type BaseTransportConfig, FileStorageProvider, type FileStorageProviderConfig, type FileTokenStorageConfig, FileTokenStorageProvider, type IWebSocket, type L1Config, type NodeIpfsSyncConfig, type NodeL1Config, type NodeOracleConfig, type NodeProviders, type NodeProvidersConfig, type NodeTokenSyncConfig, type NodeTransportConfig, NodeTrustBaseLoader, NostrTransportProvider, type NostrTransportProviderConfig, type TrustBaseLoader$1 as TrustBaseLoader, UnicityAggregatorProvider, type UnicityAggregatorProviderConfig, UnicityOracleProvider, type UnicityOracleProviderConfig, type WebSocketFactory, createFileStorageProvider, createFileTokenStorageProvider, createNodeProviders, createNodeTrustBaseLoader, createNodeWebSocketFactory, createNostrTransportProvider, createUnicityAggregatorProvider, createUnicityOracleProvider };
|