@dropgate/core 2.0.0-beta.2 → 2.1.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 +76 -15
- package/dist/index.browser.js +1 -1
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +385 -138
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +182 -120
- package/dist/index.d.ts +182 -120
- package/dist/index.js +383 -138
- package/dist/index.js.map +1 -1
- package/dist/p2p/index.cjs +268 -62
- package/dist/p2p/index.cjs.map +1 -1
- package/dist/p2p/index.d.cts +154 -92
- package/dist/p2p/index.d.ts +154 -92
- package/dist/p2p/index.js +267 -62
- package/dist/p2p/index.js.map +1 -1
- package/package.json +88 -88
package/dist/index.d.ts
CHANGED
|
@@ -114,16 +114,26 @@ interface ServerInfo {
|
|
|
114
114
|
/** Server capabilities. */
|
|
115
115
|
capabilities?: ServerCapabilities;
|
|
116
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* Base progress event with common fields for all transfer operations.
|
|
119
|
+
* Provides a consistent interface for upload, download, and P2P progress tracking.
|
|
120
|
+
*/
|
|
121
|
+
interface BaseProgressEvent {
|
|
122
|
+
/** Completion percentage (0-100). */
|
|
123
|
+
percent: number;
|
|
124
|
+
/** Bytes processed so far (sent, received, or uploaded). */
|
|
125
|
+
processedBytes: number;
|
|
126
|
+
/** Total bytes expected (may be 0 if unknown). */
|
|
127
|
+
totalBytes: number;
|
|
128
|
+
}
|
|
117
129
|
/**
|
|
118
130
|
* Progress event emitted during upload operations.
|
|
119
131
|
*/
|
|
120
|
-
interface
|
|
121
|
-
/** Current phase of the operation
|
|
122
|
-
phase:
|
|
132
|
+
interface UploadProgressEvent extends BaseProgressEvent {
|
|
133
|
+
/** Current phase of the operation. */
|
|
134
|
+
phase: 'server-info' | 'server-compat' | 'crypto' | 'init' | 'chunk' | 'complete' | 'done' | 'retry-wait' | 'retry';
|
|
123
135
|
/** Human-readable status text. */
|
|
124
136
|
text?: string;
|
|
125
|
-
/** Completion percentage (0-100). */
|
|
126
|
-
percent?: number;
|
|
127
137
|
/** Current chunk index (0-based). */
|
|
128
138
|
chunkIndex?: number;
|
|
129
139
|
/** Total number of chunks. */
|
|
@@ -261,7 +271,7 @@ interface UploadOptions extends ServerTarget {
|
|
|
261
271
|
/** Override the filename sent to the server. */
|
|
262
272
|
filenameOverride?: string;
|
|
263
273
|
/** Callback for progress updates. */
|
|
264
|
-
onProgress?: (evt:
|
|
274
|
+
onProgress?: (evt: UploadProgressEvent) => void;
|
|
265
275
|
/** AbortSignal to cancel the upload. */
|
|
266
276
|
signal?: AbortSignal;
|
|
267
277
|
/** Timeout settings for various upload phases. */
|
|
@@ -293,6 +303,8 @@ interface GetServerInfoOptions extends ServerTarget {
|
|
|
293
303
|
timeoutMs?: number;
|
|
294
304
|
/** AbortSignal to cancel the request. */
|
|
295
305
|
signal?: AbortSignal;
|
|
306
|
+
/** Custom fetch implementation (uses global fetch by default). */
|
|
307
|
+
fetchFn?: FetchFn;
|
|
296
308
|
}
|
|
297
309
|
/**
|
|
298
310
|
* Options for validating upload inputs before starting an upload.
|
|
@@ -323,17 +335,11 @@ interface FileMetadata {
|
|
|
323
335
|
/**
|
|
324
336
|
* Download progress event.
|
|
325
337
|
*/
|
|
326
|
-
interface DownloadProgressEvent {
|
|
338
|
+
interface DownloadProgressEvent extends BaseProgressEvent {
|
|
327
339
|
/** Current phase of the download. */
|
|
328
|
-
phase: 'metadata' | 'downloading' | 'decrypting' | 'complete';
|
|
340
|
+
phase: 'server-info' | 'server-compat' | 'metadata' | 'downloading' | 'decrypting' | 'complete';
|
|
329
341
|
/** Human-readable status text. */
|
|
330
342
|
text?: string;
|
|
331
|
-
/** Bytes received so far. */
|
|
332
|
-
receivedBytes: number;
|
|
333
|
-
/** Total bytes expected (may be 0 if unknown). */
|
|
334
|
-
totalBytes: number;
|
|
335
|
-
/** Completion percentage (0-100). */
|
|
336
|
-
percent: number;
|
|
337
343
|
}
|
|
338
344
|
/**
|
|
339
345
|
* Options for downloading a file.
|
|
@@ -491,6 +497,17 @@ declare function encryptFilenameToBase64(cryptoObj: CryptoAdapter, filename: str
|
|
|
491
497
|
* Estimate total upload size including encryption overhead.
|
|
492
498
|
*/
|
|
493
499
|
declare function estimateTotalUploadSizeBytes(fileSizeBytes: number, totalChunks: number, isEncrypted: boolean): number;
|
|
500
|
+
/**
|
|
501
|
+
* Fetch server information from the /api/info endpoint.
|
|
502
|
+
* @param opts - Server target and request options.
|
|
503
|
+
* @returns The server base URL and server info object.
|
|
504
|
+
* @throws {DropgateNetworkError} If the server cannot be reached.
|
|
505
|
+
* @throws {DropgateProtocolError} If the server returns an invalid response.
|
|
506
|
+
*/
|
|
507
|
+
declare function getServerInfo(opts: GetServerInfoOptions): Promise<{
|
|
508
|
+
baseUrl: string;
|
|
509
|
+
serverInfo: ServerInfo;
|
|
510
|
+
}>;
|
|
494
511
|
/**
|
|
495
512
|
* Headless, environment-agnostic client for Dropgate file uploads.
|
|
496
513
|
* Handles server communication, encryption, and chunked uploads.
|
|
@@ -514,17 +531,6 @@ declare class DropgateClient {
|
|
|
514
531
|
* @throws {DropgateValidationError} If clientVersion is missing or invalid.
|
|
515
532
|
*/
|
|
516
533
|
constructor(opts: DropgateClientOptions);
|
|
517
|
-
/**
|
|
518
|
-
* Fetch server information from the /api/info endpoint.
|
|
519
|
-
* @param opts - Server target and request options.
|
|
520
|
-
* @returns The server base URL and server info object.
|
|
521
|
-
* @throws {DropgateNetworkError} If the server cannot be reached.
|
|
522
|
-
* @throws {DropgateProtocolError} If the server returns an invalid response.
|
|
523
|
-
*/
|
|
524
|
-
getServerInfo(opts: GetServerInfoOptions): Promise<{
|
|
525
|
-
baseUrl: string;
|
|
526
|
-
serverInfo: ServerInfo;
|
|
527
|
-
}>;
|
|
528
534
|
/**
|
|
529
535
|
* Resolve a user-entered sharing code or URL via the server.
|
|
530
536
|
* @param value - The sharing code or URL to resolve.
|
|
@@ -535,10 +541,16 @@ declare class DropgateClient {
|
|
|
535
541
|
resolveShareTarget(value: string, opts: GetServerInfoOptions): Promise<ShareTargetResult>;
|
|
536
542
|
/**
|
|
537
543
|
* Check version compatibility between this client and a server.
|
|
538
|
-
*
|
|
539
|
-
* @
|
|
544
|
+
* Fetches server info internally using getServerInfo.
|
|
545
|
+
* @param opts - Server target and request options.
|
|
546
|
+
* @returns Compatibility result with status, message, and server info.
|
|
547
|
+
* @throws {DropgateNetworkError} If the server cannot be reached.
|
|
548
|
+
* @throws {DropgateProtocolError} If the server returns an invalid response.
|
|
540
549
|
*/
|
|
541
|
-
checkCompatibility(
|
|
550
|
+
checkCompatibility(opts: GetServerInfoOptions): Promise<CompatibilityResult & {
|
|
551
|
+
serverInfo: ServerInfo;
|
|
552
|
+
baseUrl: string;
|
|
553
|
+
}>;
|
|
542
554
|
/**
|
|
543
555
|
* Validate file and upload settings against server capabilities.
|
|
544
556
|
* @param opts - Validation options containing file, settings, and server info.
|
|
@@ -592,6 +604,15 @@ declare function getDefaultCrypto(): CryptoAdapter | undefined;
|
|
|
592
604
|
*/
|
|
593
605
|
declare function getDefaultFetch(): FetchFn | undefined;
|
|
594
606
|
|
|
607
|
+
/**
|
|
608
|
+
* Finite state machine states for P2P send sessions.
|
|
609
|
+
* Prevents race conditions and ensures callbacks fire in correct order.
|
|
610
|
+
*/
|
|
611
|
+
type P2PSendState = 'initializing' | 'listening' | 'negotiating' | 'transferring' | 'finishing' | 'completed' | 'closed';
|
|
612
|
+
/**
|
|
613
|
+
* Finite state machine states for P2P receive sessions.
|
|
614
|
+
*/
|
|
615
|
+
type P2PReceiveState = 'initializing' | 'connecting' | 'negotiating' | 'transferring' | 'completed' | 'closed';
|
|
595
616
|
/**
|
|
596
617
|
* PeerJS Peer constructor interface.
|
|
597
618
|
* Consumer must provide this constructor to P2P functions.
|
|
@@ -619,16 +640,20 @@ interface PeerOptions {
|
|
|
619
640
|
/** PeerJS debug level (0-3). */
|
|
620
641
|
debug?: number;
|
|
621
642
|
}
|
|
643
|
+
/** Event handlers for PeerInstance. */
|
|
644
|
+
interface PeerInstanceEvents {
|
|
645
|
+
open: (id: string) => void;
|
|
646
|
+
connection: (conn: DataConnection) => void;
|
|
647
|
+
error: (err: Error) => void;
|
|
648
|
+
close: () => void;
|
|
649
|
+
}
|
|
622
650
|
/**
|
|
623
651
|
* PeerJS Peer instance interface.
|
|
624
652
|
* Represents a connection to the PeerJS signaling server.
|
|
625
653
|
*/
|
|
626
654
|
interface PeerInstance {
|
|
627
655
|
/** Register an event handler. */
|
|
628
|
-
on(event:
|
|
629
|
-
on(event: 'connection', callback: (conn: DataConnection) => void): void;
|
|
630
|
-
on(event: 'error', callback: (err: Error) => void): void;
|
|
631
|
-
on(event: 'close', callback: () => void): void;
|
|
656
|
+
on<K extends keyof PeerInstanceEvents>(event: K, callback: PeerInstanceEvents[K]): void;
|
|
632
657
|
on(event: string, callback: (...args: unknown[]) => void): void;
|
|
633
658
|
/** Connect to another peer by ID. */
|
|
634
659
|
connect(peerId: string, options?: {
|
|
@@ -637,16 +662,20 @@ interface PeerInstance {
|
|
|
637
662
|
/** Destroy this peer and close all connections. */
|
|
638
663
|
destroy(): void;
|
|
639
664
|
}
|
|
665
|
+
/** Event handlers for DataConnection. */
|
|
666
|
+
interface DataConnectionEvents {
|
|
667
|
+
open: () => void;
|
|
668
|
+
data: (data: unknown) => void;
|
|
669
|
+
close: () => void;
|
|
670
|
+
error: (err: Error) => void;
|
|
671
|
+
}
|
|
640
672
|
/**
|
|
641
673
|
* PeerJS DataConnection interface.
|
|
642
674
|
* Represents a WebRTC data channel connection between peers.
|
|
643
675
|
*/
|
|
644
676
|
interface DataConnection {
|
|
645
677
|
/** Register an event handler. */
|
|
646
|
-
on(event:
|
|
647
|
-
on(event: 'data', callback: (data: unknown) => void): void;
|
|
648
|
-
on(event: 'close', callback: () => void): void;
|
|
649
|
-
on(event: 'error', callback: (err: Error) => void): void;
|
|
678
|
+
on<K extends keyof DataConnectionEvents>(event: K, callback: DataConnectionEvents[K]): void;
|
|
650
679
|
on(event: string, callback: (...args: unknown[]) => void): void;
|
|
651
680
|
/** Send data to the connected peer. */
|
|
652
681
|
send(data: unknown): void;
|
|
@@ -656,58 +685,81 @@ interface DataConnection {
|
|
|
656
685
|
_dc?: RTCDataChannel;
|
|
657
686
|
}
|
|
658
687
|
/**
|
|
659
|
-
*
|
|
688
|
+
* Common server configuration for P2P connections.
|
|
660
689
|
*/
|
|
661
|
-
interface
|
|
662
|
-
/**
|
|
663
|
-
file: FileSource;
|
|
664
|
-
/** PeerJS Peer constructor - REQUIRED */
|
|
665
|
-
Peer: PeerConstructor;
|
|
666
|
-
/** Server info (optional, for capability checking) */
|
|
667
|
-
serverInfo?: ServerInfo;
|
|
668
|
-
/** PeerJS server host */
|
|
690
|
+
interface P2PServerConfig {
|
|
691
|
+
/** PeerJS server host. */
|
|
669
692
|
host?: string;
|
|
670
|
-
/** PeerJS server port */
|
|
693
|
+
/** PeerJS server port. */
|
|
671
694
|
port?: number;
|
|
672
|
-
/** PeerJS server path (default: /peerjs) */
|
|
695
|
+
/** PeerJS server path (default: /peerjs). */
|
|
673
696
|
peerjsPath?: string;
|
|
674
|
-
/** Whether to use secure connection */
|
|
697
|
+
/** Whether to use secure connection. */
|
|
675
698
|
secure?: boolean;
|
|
676
|
-
/** ICE servers for WebRTC */
|
|
699
|
+
/** ICE servers for WebRTC. */
|
|
677
700
|
iceServers?: RTCIceServer[];
|
|
678
|
-
|
|
701
|
+
}
|
|
702
|
+
/** Status event for P2P operations. */
|
|
703
|
+
interface P2PStatusEvent {
|
|
704
|
+
phase: string;
|
|
705
|
+
message: string;
|
|
706
|
+
}
|
|
707
|
+
/** Progress event for P2P send operations. */
|
|
708
|
+
interface P2PSendProgressEvent extends BaseProgressEvent {
|
|
709
|
+
}
|
|
710
|
+
/** Progress event for P2P receive operations. */
|
|
711
|
+
interface P2PReceiveProgressEvent extends BaseProgressEvent {
|
|
712
|
+
}
|
|
713
|
+
/** Metadata event when receiving a file. */
|
|
714
|
+
interface P2PMetadataEvent {
|
|
715
|
+
name: string;
|
|
716
|
+
total: number;
|
|
717
|
+
/** Call this to signal the sender to begin transfer (when autoReady is false). */
|
|
718
|
+
sendReady?: () => void;
|
|
719
|
+
}
|
|
720
|
+
/** Completion event for P2P receive operations. */
|
|
721
|
+
interface P2PReceiveCompleteEvent {
|
|
722
|
+
received: number;
|
|
723
|
+
total: number;
|
|
724
|
+
}
|
|
725
|
+
/**
|
|
726
|
+
* Options for starting a P2P send session.
|
|
727
|
+
*/
|
|
728
|
+
interface P2PSendOptions extends P2PServerConfig {
|
|
729
|
+
/** File to send. */
|
|
730
|
+
file: FileSource;
|
|
731
|
+
/** PeerJS Peer constructor - REQUIRED. */
|
|
732
|
+
Peer: PeerConstructor;
|
|
733
|
+
/** Server info (optional, for capability checking). */
|
|
734
|
+
serverInfo?: ServerInfo;
|
|
735
|
+
/** Custom code generator function. */
|
|
679
736
|
codeGenerator?: (cryptoObj?: CryptoAdapter) => string;
|
|
680
|
-
/** Crypto object for secure code generation */
|
|
737
|
+
/** Crypto object for secure code generation. */
|
|
681
738
|
cryptoObj?: CryptoAdapter;
|
|
682
|
-
/** Max attempts to register a peer ID */
|
|
739
|
+
/** Max attempts to register a peer ID. */
|
|
683
740
|
maxAttempts?: number;
|
|
684
|
-
/** Chunk size for data transfer */
|
|
741
|
+
/** Chunk size for data transfer. */
|
|
685
742
|
chunkSize?: number;
|
|
686
|
-
/** Timeout waiting for
|
|
687
|
-
readyTimeoutMs?: number;
|
|
688
|
-
/** Timeout waiting for end acknowledgment */
|
|
743
|
+
/** Timeout waiting for end acknowledgment. */
|
|
689
744
|
endAckTimeoutMs?: number;
|
|
690
|
-
/** Buffer high water mark for flow control */
|
|
745
|
+
/** Buffer high water mark for flow control. */
|
|
691
746
|
bufferHighWaterMark?: number;
|
|
692
|
-
/** Buffer low water mark for flow control */
|
|
747
|
+
/** Buffer low water mark for flow control. */
|
|
693
748
|
bufferLowWaterMark?: number;
|
|
694
|
-
/**
|
|
749
|
+
/** Heartbeat interval in ms for long transfers (default: 5000, 0 to disable). */
|
|
750
|
+
heartbeatIntervalMs?: number;
|
|
751
|
+
/** Callback when code is generated. */
|
|
695
752
|
onCode?: (code: string, attempt: number) => void;
|
|
696
|
-
/** Callback for status updates */
|
|
697
|
-
onStatus?: (evt:
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
/** Callback for progress updates */
|
|
702
|
-
onProgress?: (evt: {
|
|
703
|
-
sent: number;
|
|
704
|
-
total: number;
|
|
705
|
-
percent: number;
|
|
706
|
-
}) => void;
|
|
707
|
-
/** Callback when transfer completes */
|
|
753
|
+
/** Callback for status updates. */
|
|
754
|
+
onStatus?: (evt: P2PStatusEvent) => void;
|
|
755
|
+
/** Callback for progress updates. */
|
|
756
|
+
onProgress?: (evt: P2PSendProgressEvent) => void;
|
|
757
|
+
/** Callback when transfer completes. */
|
|
708
758
|
onComplete?: () => void;
|
|
709
|
-
/** Callback on error */
|
|
759
|
+
/** Callback on error. */
|
|
710
760
|
onError?: (err: Error) => void;
|
|
761
|
+
/** Callback when receiver disconnects. */
|
|
762
|
+
onDisconnect?: () => void;
|
|
711
763
|
}
|
|
712
764
|
/**
|
|
713
765
|
* Return value from startP2PSend containing session control.
|
|
@@ -717,55 +769,56 @@ interface P2PSendSession {
|
|
|
717
769
|
peer: PeerInstance;
|
|
718
770
|
/** The generated sharing code. */
|
|
719
771
|
code: string;
|
|
772
|
+
/** The unique session ID for this transfer. */
|
|
773
|
+
sessionId: string;
|
|
720
774
|
/** Stop the session and clean up resources. */
|
|
721
775
|
stop: () => void;
|
|
776
|
+
/** Get the current session state. */
|
|
777
|
+
getStatus: () => P2PSendState;
|
|
778
|
+
/** Get the number of bytes sent so far. */
|
|
779
|
+
getBytesSent: () => number;
|
|
780
|
+
/** Get the connected receiver's peer ID (if connected). */
|
|
781
|
+
getConnectedPeerId: () => string | null;
|
|
722
782
|
}
|
|
723
783
|
/**
|
|
724
784
|
* Options for starting a P2P receive session.
|
|
725
785
|
*/
|
|
726
|
-
interface P2PReceiveOptions {
|
|
727
|
-
/** Sharing code to connect to */
|
|
786
|
+
interface P2PReceiveOptions extends P2PServerConfig {
|
|
787
|
+
/** Sharing code to connect to. */
|
|
728
788
|
code: string;
|
|
729
|
-
/** PeerJS Peer constructor - REQUIRED */
|
|
789
|
+
/** PeerJS Peer constructor - REQUIRED. */
|
|
730
790
|
Peer: PeerConstructor;
|
|
731
|
-
/** Server info (optional, for capability checking) */
|
|
791
|
+
/** Server info (optional, for capability checking). */
|
|
732
792
|
serverInfo?: ServerInfo;
|
|
733
|
-
/**
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
/** Callback when data chunk is received - consumer handles file writing */
|
|
793
|
+
/**
|
|
794
|
+
* Whether to automatically send the "ready" signal after receiving metadata.
|
|
795
|
+
* Default: true.
|
|
796
|
+
* Set to false to show a preview and manually control when the transfer starts.
|
|
797
|
+
* When false, call the sendReady function passed to onMeta to start the transfer.
|
|
798
|
+
*/
|
|
799
|
+
autoReady?: boolean;
|
|
800
|
+
/**
|
|
801
|
+
* Timeout in ms for detecting dead connections (no data received).
|
|
802
|
+
* Default: 15000 (15 seconds). Set to 0 to disable.
|
|
803
|
+
*/
|
|
804
|
+
watchdogTimeoutMs?: number;
|
|
805
|
+
/** Callback for status updates. */
|
|
806
|
+
onStatus?: (evt: P2PStatusEvent) => void;
|
|
807
|
+
/**
|
|
808
|
+
* Callback when file metadata is received.
|
|
809
|
+
* When autoReady is false, this callback receives a sendReady function
|
|
810
|
+
* that must be called to signal the sender to begin the transfer.
|
|
811
|
+
*/
|
|
812
|
+
onMeta?: (evt: P2PMetadataEvent) => void;
|
|
813
|
+
/** Callback when data chunk is received - consumer handles file writing. */
|
|
754
814
|
onData?: (chunk: Uint8Array) => Promise<void> | void;
|
|
755
|
-
/** Callback for progress updates */
|
|
756
|
-
onProgress?: (evt:
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
}) => void;
|
|
761
|
-
/** Callback when transfer completes */
|
|
762
|
-
onComplete?: (evt: {
|
|
763
|
-
received: number;
|
|
764
|
-
total: number;
|
|
765
|
-
}) => void;
|
|
766
|
-
/** Callback on error */
|
|
815
|
+
/** Callback for progress updates. */
|
|
816
|
+
onProgress?: (evt: P2PReceiveProgressEvent) => void;
|
|
817
|
+
/** Callback when transfer completes. */
|
|
818
|
+
onComplete?: (evt: P2PReceiveCompleteEvent) => void;
|
|
819
|
+
/** Callback on error. */
|
|
767
820
|
onError?: (err: Error) => void;
|
|
768
|
-
/** Callback when sender disconnects */
|
|
821
|
+
/** Callback when sender disconnects. */
|
|
769
822
|
onDisconnect?: () => void;
|
|
770
823
|
}
|
|
771
824
|
/**
|
|
@@ -776,6 +829,14 @@ interface P2PReceiveSession {
|
|
|
776
829
|
peer: PeerInstance;
|
|
777
830
|
/** Stop the session and clean up resources. */
|
|
778
831
|
stop: () => void;
|
|
832
|
+
/** Get the current session state. */
|
|
833
|
+
getStatus: () => P2PReceiveState;
|
|
834
|
+
/** Get the number of bytes received so far. */
|
|
835
|
+
getBytesReceived: () => number;
|
|
836
|
+
/** Get the expected total bytes (0 if metadata not received). */
|
|
837
|
+
getTotalBytes: () => number;
|
|
838
|
+
/** Get the current session ID (if received from sender). */
|
|
839
|
+
getSessionId: () => string | null;
|
|
779
840
|
}
|
|
780
841
|
|
|
781
842
|
/**
|
|
@@ -854,17 +915,18 @@ declare function generateP2PCode(cryptoObj?: CryptoAdapter): string;
|
|
|
854
915
|
*/
|
|
855
916
|
declare function isP2PCodeLike(code: string): boolean;
|
|
856
917
|
|
|
857
|
-
interface BuildPeerOptionsInput {
|
|
858
|
-
host?: string;
|
|
859
|
-
port?: number;
|
|
860
|
-
peerjsPath?: string;
|
|
861
|
-
secure?: boolean;
|
|
862
|
-
iceServers?: RTCIceServer[];
|
|
863
|
-
}
|
|
864
918
|
/**
|
|
865
|
-
*
|
|
919
|
+
* Resolve P2P server configuration from user options and server capabilities.
|
|
920
|
+
* User-provided values take precedence over server capabilities.
|
|
921
|
+
*/
|
|
922
|
+
declare function resolvePeerConfig(userConfig: P2PServerConfig, serverCaps?: P2PCapabilities): {
|
|
923
|
+
path: string;
|
|
924
|
+
iceServers: RTCIceServer[];
|
|
925
|
+
};
|
|
926
|
+
/**
|
|
927
|
+
* Build PeerJS connection options from P2P server configuration.
|
|
866
928
|
*/
|
|
867
|
-
declare function buildPeerOptions(
|
|
929
|
+
declare function buildPeerOptions(config?: P2PServerConfig): PeerOptions;
|
|
868
930
|
interface CreatePeerWithRetriesOptions {
|
|
869
931
|
code?: string | null;
|
|
870
932
|
codeGenerator: () => string;
|
|
@@ -880,4 +942,4 @@ declare function createPeerWithRetries(opts: CreatePeerWithRetriesOptions): Prom
|
|
|
880
942
|
code: string;
|
|
881
943
|
}>;
|
|
882
944
|
|
|
883
|
-
export { AES_GCM_IV_BYTES, AES_GCM_TAG_BYTES, type AbortSignalWithCleanup, type Base64Adapter, type CompatibilityResult, type CryptoAdapter, DEFAULT_CHUNK_SIZE, type DataConnection, type DownloadOptions, type DownloadProgressEvent, type DownloadResult, DropgateAbortError, DropgateClient, type DropgateClientOptions, DropgateError, type DropgateErrorOptions, DropgateNetworkError, DropgateProtocolError, DropgateTimeoutError, DropgateValidationError, ENCRYPTION_OVERHEAD_PER_CHUNK, type FetchFn, type FetchJsonOptions, type FetchJsonResult, type FileMetadata, type FileSource, type GetServerInfoOptions, type LoggerFn, type P2PCapabilities, type P2PReceiveOptions, type P2PReceiveSession, type P2PSendOptions, type P2PSendSession, type PeerConstructor, type PeerInstance, type
|
|
945
|
+
export { AES_GCM_IV_BYTES, AES_GCM_TAG_BYTES, type AbortSignalWithCleanup, type Base64Adapter, type BaseProgressEvent, type CompatibilityResult, type CryptoAdapter, DEFAULT_CHUNK_SIZE, type DataConnection, type DataConnectionEvents, type DownloadOptions, type DownloadProgressEvent, type DownloadResult, DropgateAbortError, DropgateClient, type DropgateClientOptions, DropgateError, type DropgateErrorOptions, DropgateNetworkError, DropgateProtocolError, DropgateTimeoutError, DropgateValidationError, ENCRYPTION_OVERHEAD_PER_CHUNK, type FetchFn, type FetchJsonOptions, type FetchJsonResult, type FileMetadata, type FileSource, type GetServerInfoOptions, type LoggerFn, type P2PCapabilities, type P2PMetadataEvent, type P2PReceiveCompleteEvent, type P2PReceiveOptions, type P2PReceiveProgressEvent, type P2PReceiveSession, type P2PSendOptions, type P2PSendProgressEvent, type P2PSendSession, type P2PServerConfig, type P2PStatusEvent, type PeerConstructor, type PeerInstance, type PeerInstanceEvents, type PeerOptions, type SemverParts, type ServerCapabilities, type ServerInfo, type ServerTarget, type ShareTargetResult, type UploadCapabilities, type UploadOptions, type UploadProgressEvent, type UploadResult, type ValidateUploadOptions, type WebUICapabilities, arrayBufferToBase64, base64ToBytes, buildBaseUrl, buildPeerOptions, bytesToBase64, createPeerWithRetries, decryptChunk, decryptFilenameFromBase64, encryptFilenameToBase64, encryptToBlob, estimateTotalUploadSizeBytes, exportKeyBase64, fetchJson, generateAesGcmKey, generateP2PCode, getDefaultBase64, getDefaultCrypto, getDefaultFetch, getServerInfo, importKeyFromBase64, isLocalhostHostname, isP2PCodeLike, isSecureContextForP2P, lifetimeToMs, makeAbortSignal, parseSemverMajorMinor, parseServerUrl, resolvePeerConfig, sha256Hex, sleep, startP2PReceive, startP2PSend, validatePlainFilename };
|