@dropgate/core 2.1.0 → 2.2.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/index.browser.js +1 -1
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +290 -199
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +32 -7
- package/dist/index.d.ts +32 -7
- package/dist/index.js +290 -199
- package/dist/index.js.map +1 -1
- package/dist/p2p/index.cjs +54 -15
- package/dist/p2p/index.cjs.map +1 -1
- package/dist/p2p/index.d.cts +13 -2
- package/dist/p2p/index.d.ts +13 -2
- package/dist/p2p/index.js +54 -15
- package/dist/p2p/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -154,6 +154,18 @@ interface UploadResult {
|
|
|
154
154
|
/** Base64-encoded encryption key (only present if encrypted). */
|
|
155
155
|
keyB64?: string;
|
|
156
156
|
}
|
|
157
|
+
/**
|
|
158
|
+
* Upload session with cancellation support.
|
|
159
|
+
* Returned by uploadFile() to allow cancelling uploads in progress.
|
|
160
|
+
*/
|
|
161
|
+
interface UploadSession {
|
|
162
|
+
/** Promise that resolves with upload result when complete. */
|
|
163
|
+
result: Promise<UploadResult>;
|
|
164
|
+
/** Cancel the upload. */
|
|
165
|
+
cancel: (reason?: string) => void;
|
|
166
|
+
/** Get current upload status. */
|
|
167
|
+
getStatus: () => 'initializing' | 'uploading' | 'completing' | 'completed' | 'cancelled' | 'error';
|
|
168
|
+
}
|
|
157
169
|
/**
|
|
158
170
|
* Result of a client/server compatibility check.
|
|
159
171
|
*/
|
|
@@ -266,12 +278,14 @@ interface UploadOptions extends ServerTarget {
|
|
|
266
278
|
file: FileSource;
|
|
267
279
|
/** File lifetime in milliseconds (0 = server default). */
|
|
268
280
|
lifetimeMs: number;
|
|
269
|
-
/** Whether to encrypt the file with E2EE. */
|
|
270
|
-
encrypt
|
|
281
|
+
/** Whether to encrypt the file with E2EE. Defaults to true if server supports E2EE. */
|
|
282
|
+
encrypt?: boolean;
|
|
271
283
|
/** Override the filename sent to the server. */
|
|
272
284
|
filenameOverride?: string;
|
|
273
285
|
/** Callback for progress updates. */
|
|
274
286
|
onProgress?: (evt: UploadProgressEvent) => void;
|
|
287
|
+
/** Callback when upload is cancelled by user. */
|
|
288
|
+
onCancel?: () => void;
|
|
275
289
|
/** AbortSignal to cancel the upload. */
|
|
276
290
|
signal?: AbortSignal;
|
|
277
291
|
/** Timeout settings for various upload phases. */
|
|
@@ -314,8 +328,8 @@ interface ValidateUploadOptions {
|
|
|
314
328
|
file: FileSource;
|
|
315
329
|
/** Requested file lifetime in milliseconds. */
|
|
316
330
|
lifetimeMs: number;
|
|
317
|
-
/** Whether encryption will be used. */
|
|
318
|
-
encrypt
|
|
331
|
+
/** Whether encryption will be used. Defaults to true if server supports E2EE. */
|
|
332
|
+
encrypt?: boolean;
|
|
319
333
|
/** Server info containing capabilities to validate against. */
|
|
320
334
|
serverInfo: ServerInfo;
|
|
321
335
|
}
|
|
@@ -567,7 +581,7 @@ declare class DropgateClient {
|
|
|
567
581
|
* @throws {DropgateProtocolError} If the server returns an error.
|
|
568
582
|
* @throws {DropgateAbortError} If the upload is cancelled.
|
|
569
583
|
*/
|
|
570
|
-
uploadFile(opts: UploadOptions): Promise<
|
|
584
|
+
uploadFile(opts: UploadOptions): Promise<UploadSession>;
|
|
571
585
|
/**
|
|
572
586
|
* Download a file from the server with optional decryption.
|
|
573
587
|
*
|
|
@@ -608,11 +622,11 @@ declare function getDefaultFetch(): FetchFn | undefined;
|
|
|
608
622
|
* Finite state machine states for P2P send sessions.
|
|
609
623
|
* Prevents race conditions and ensures callbacks fire in correct order.
|
|
610
624
|
*/
|
|
611
|
-
type P2PSendState = 'initializing' | 'listening' | 'negotiating' | 'transferring' | 'finishing' | 'completed' | 'closed';
|
|
625
|
+
type P2PSendState = 'initializing' | 'listening' | 'negotiating' | 'transferring' | 'finishing' | 'completed' | 'cancelled' | 'closed';
|
|
612
626
|
/**
|
|
613
627
|
* Finite state machine states for P2P receive sessions.
|
|
614
628
|
*/
|
|
615
|
-
type P2PReceiveState = 'initializing' | 'connecting' | 'negotiating' | 'transferring' | 'completed' | 'closed';
|
|
629
|
+
type P2PReceiveState = 'initializing' | 'connecting' | 'negotiating' | 'transferring' | 'completed' | 'cancelled' | 'closed';
|
|
616
630
|
/**
|
|
617
631
|
* PeerJS Peer constructor interface.
|
|
618
632
|
* Consumer must provide this constructor to P2P functions.
|
|
@@ -722,6 +736,13 @@ interface P2PReceiveCompleteEvent {
|
|
|
722
736
|
received: number;
|
|
723
737
|
total: number;
|
|
724
738
|
}
|
|
739
|
+
/** Cancellation event for P2P operations. */
|
|
740
|
+
interface P2PCancellationEvent {
|
|
741
|
+
/** Who cancelled the transfer ('sender' or 'receiver'). */
|
|
742
|
+
cancelledBy: 'sender' | 'receiver';
|
|
743
|
+
/** Optional cancellation message. */
|
|
744
|
+
message?: string;
|
|
745
|
+
}
|
|
725
746
|
/**
|
|
726
747
|
* Options for starting a P2P send session.
|
|
727
748
|
*/
|
|
@@ -760,6 +781,8 @@ interface P2PSendOptions extends P2PServerConfig {
|
|
|
760
781
|
onError?: (err: Error) => void;
|
|
761
782
|
/** Callback when receiver disconnects. */
|
|
762
783
|
onDisconnect?: () => void;
|
|
784
|
+
/** Callback when transfer is cancelled by either party. */
|
|
785
|
+
onCancel?: (evt: P2PCancellationEvent) => void;
|
|
763
786
|
}
|
|
764
787
|
/**
|
|
765
788
|
* Return value from startP2PSend containing session control.
|
|
@@ -820,6 +843,8 @@ interface P2PReceiveOptions extends P2PServerConfig {
|
|
|
820
843
|
onError?: (err: Error) => void;
|
|
821
844
|
/** Callback when sender disconnects. */
|
|
822
845
|
onDisconnect?: () => void;
|
|
846
|
+
/** Callback when transfer is cancelled by either party. */
|
|
847
|
+
onCancel?: (evt: P2PCancellationEvent) => void;
|
|
823
848
|
}
|
|
824
849
|
/**
|
|
825
850
|
* Return value from startP2PReceive containing session control.
|
package/dist/index.d.ts
CHANGED
|
@@ -154,6 +154,18 @@ interface UploadResult {
|
|
|
154
154
|
/** Base64-encoded encryption key (only present if encrypted). */
|
|
155
155
|
keyB64?: string;
|
|
156
156
|
}
|
|
157
|
+
/**
|
|
158
|
+
* Upload session with cancellation support.
|
|
159
|
+
* Returned by uploadFile() to allow cancelling uploads in progress.
|
|
160
|
+
*/
|
|
161
|
+
interface UploadSession {
|
|
162
|
+
/** Promise that resolves with upload result when complete. */
|
|
163
|
+
result: Promise<UploadResult>;
|
|
164
|
+
/** Cancel the upload. */
|
|
165
|
+
cancel: (reason?: string) => void;
|
|
166
|
+
/** Get current upload status. */
|
|
167
|
+
getStatus: () => 'initializing' | 'uploading' | 'completing' | 'completed' | 'cancelled' | 'error';
|
|
168
|
+
}
|
|
157
169
|
/**
|
|
158
170
|
* Result of a client/server compatibility check.
|
|
159
171
|
*/
|
|
@@ -266,12 +278,14 @@ interface UploadOptions extends ServerTarget {
|
|
|
266
278
|
file: FileSource;
|
|
267
279
|
/** File lifetime in milliseconds (0 = server default). */
|
|
268
280
|
lifetimeMs: number;
|
|
269
|
-
/** Whether to encrypt the file with E2EE. */
|
|
270
|
-
encrypt
|
|
281
|
+
/** Whether to encrypt the file with E2EE. Defaults to true if server supports E2EE. */
|
|
282
|
+
encrypt?: boolean;
|
|
271
283
|
/** Override the filename sent to the server. */
|
|
272
284
|
filenameOverride?: string;
|
|
273
285
|
/** Callback for progress updates. */
|
|
274
286
|
onProgress?: (evt: UploadProgressEvent) => void;
|
|
287
|
+
/** Callback when upload is cancelled by user. */
|
|
288
|
+
onCancel?: () => void;
|
|
275
289
|
/** AbortSignal to cancel the upload. */
|
|
276
290
|
signal?: AbortSignal;
|
|
277
291
|
/** Timeout settings for various upload phases. */
|
|
@@ -314,8 +328,8 @@ interface ValidateUploadOptions {
|
|
|
314
328
|
file: FileSource;
|
|
315
329
|
/** Requested file lifetime in milliseconds. */
|
|
316
330
|
lifetimeMs: number;
|
|
317
|
-
/** Whether encryption will be used. */
|
|
318
|
-
encrypt
|
|
331
|
+
/** Whether encryption will be used. Defaults to true if server supports E2EE. */
|
|
332
|
+
encrypt?: boolean;
|
|
319
333
|
/** Server info containing capabilities to validate against. */
|
|
320
334
|
serverInfo: ServerInfo;
|
|
321
335
|
}
|
|
@@ -567,7 +581,7 @@ declare class DropgateClient {
|
|
|
567
581
|
* @throws {DropgateProtocolError} If the server returns an error.
|
|
568
582
|
* @throws {DropgateAbortError} If the upload is cancelled.
|
|
569
583
|
*/
|
|
570
|
-
uploadFile(opts: UploadOptions): Promise<
|
|
584
|
+
uploadFile(opts: UploadOptions): Promise<UploadSession>;
|
|
571
585
|
/**
|
|
572
586
|
* Download a file from the server with optional decryption.
|
|
573
587
|
*
|
|
@@ -608,11 +622,11 @@ declare function getDefaultFetch(): FetchFn | undefined;
|
|
|
608
622
|
* Finite state machine states for P2P send sessions.
|
|
609
623
|
* Prevents race conditions and ensures callbacks fire in correct order.
|
|
610
624
|
*/
|
|
611
|
-
type P2PSendState = 'initializing' | 'listening' | 'negotiating' | 'transferring' | 'finishing' | 'completed' | 'closed';
|
|
625
|
+
type P2PSendState = 'initializing' | 'listening' | 'negotiating' | 'transferring' | 'finishing' | 'completed' | 'cancelled' | 'closed';
|
|
612
626
|
/**
|
|
613
627
|
* Finite state machine states for P2P receive sessions.
|
|
614
628
|
*/
|
|
615
|
-
type P2PReceiveState = 'initializing' | 'connecting' | 'negotiating' | 'transferring' | 'completed' | 'closed';
|
|
629
|
+
type P2PReceiveState = 'initializing' | 'connecting' | 'negotiating' | 'transferring' | 'completed' | 'cancelled' | 'closed';
|
|
616
630
|
/**
|
|
617
631
|
* PeerJS Peer constructor interface.
|
|
618
632
|
* Consumer must provide this constructor to P2P functions.
|
|
@@ -722,6 +736,13 @@ interface P2PReceiveCompleteEvent {
|
|
|
722
736
|
received: number;
|
|
723
737
|
total: number;
|
|
724
738
|
}
|
|
739
|
+
/** Cancellation event for P2P operations. */
|
|
740
|
+
interface P2PCancellationEvent {
|
|
741
|
+
/** Who cancelled the transfer ('sender' or 'receiver'). */
|
|
742
|
+
cancelledBy: 'sender' | 'receiver';
|
|
743
|
+
/** Optional cancellation message. */
|
|
744
|
+
message?: string;
|
|
745
|
+
}
|
|
725
746
|
/**
|
|
726
747
|
* Options for starting a P2P send session.
|
|
727
748
|
*/
|
|
@@ -760,6 +781,8 @@ interface P2PSendOptions extends P2PServerConfig {
|
|
|
760
781
|
onError?: (err: Error) => void;
|
|
761
782
|
/** Callback when receiver disconnects. */
|
|
762
783
|
onDisconnect?: () => void;
|
|
784
|
+
/** Callback when transfer is cancelled by either party. */
|
|
785
|
+
onCancel?: (evt: P2PCancellationEvent) => void;
|
|
763
786
|
}
|
|
764
787
|
/**
|
|
765
788
|
* Return value from startP2PSend containing session control.
|
|
@@ -820,6 +843,8 @@ interface P2PReceiveOptions extends P2PServerConfig {
|
|
|
820
843
|
onError?: (err: Error) => void;
|
|
821
844
|
/** Callback when sender disconnects. */
|
|
822
845
|
onDisconnect?: () => void;
|
|
846
|
+
/** Callback when transfer is cancelled by either party. */
|
|
847
|
+
onCancel?: (evt: P2PCancellationEvent) => void;
|
|
823
848
|
}
|
|
824
849
|
/**
|
|
825
850
|
* Return value from startP2PReceive containing session control.
|