@zero-transfer/classic 0.4.0 → 0.4.6
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 +12 -2
- package/dist/index.cjs +23 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +258 -10
- package/dist/index.d.ts +258 -10
- package/dist/index.mjs +22 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -8,14 +8,21 @@
|
|
|
8
8
|
npm install @zero-transfer/classic
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
Installing this package automatically pulls in [`@zero-transfer/core`](https://www.npmjs.com/package/@zero-transfer/core) as a transitive dependency. The full core surface (`createTransferClient`, `uploadFile`, `downloadFile`, profiles, errors, sync planner, …) is re-exported from this package, so a single `import { … } from "@zero-transfer/classic"` is all you need. If your app uses multiple protocols, install the umbrella [`@zero-transfer/sdk`](https://www.npmjs.com/package/@zero-transfer/sdk) instead of multiple scoped packages.
|
|
12
|
+
|
|
11
13
|
## Overview
|
|
12
14
|
|
|
13
|
-
Bundle of the three classic providers: FTP, FTPS, and SFTP. Wire `createFtpProviderFactory()`, `createFtpsProviderFactory()`, and `createSftpProviderFactory()` into a single `TransferClient` to talk to traditional file servers. Zero runtime dependencies
|
|
15
|
+
Bundle of the three classic providers: FTP, FTPS, and SFTP. Wire `createFtpProviderFactory()`, `createFtpsProviderFactory()`, and `createSftpProviderFactory()` into a single `TransferClient` to talk to traditional file servers. Zero runtime dependencies - SFTP is implemented on top of the first-party native SSH stack.
|
|
14
16
|
|
|
15
17
|
## Usage
|
|
16
18
|
|
|
17
19
|
```ts
|
|
18
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
createTransferClient,
|
|
22
|
+
uploadFile,
|
|
23
|
+
downloadFile,
|
|
24
|
+
createFtpProviderFactory,
|
|
25
|
+
} from "@zero-transfer/classic";
|
|
19
26
|
```
|
|
20
27
|
|
|
21
28
|
## Public surface
|
|
@@ -36,7 +43,10 @@ This package publishes a narrowed surface of **6** exports. These symbols are al
|
|
|
36
43
|
| Example | What it shows |
|
|
37
44
|
| ---------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- |
|
|
38
45
|
| [`examples/sftp-private-key.ts`](https://github.com/tonywied17/zero-transfer/blob/main/examples/sftp-private-key.ts) | SFTP private-key authentication example with host-key pinning. |
|
|
46
|
+
| [`examples/sftp-directory-ops.ts`](https://github.com/tonywied17/zero-transfer/blob/main/examples/sftp-directory-ops.ts) | SFTP directory operations: list, stat, mkdir, rename, remove, rmdir. |
|
|
39
47
|
| [`examples/ftps-client-certificate.ts`](https://github.com/tonywied17/zero-transfer/blob/main/examples/ftps-client-certificate.ts) | FTPS client-certificate (mutual TLS) example with certificate pinning. |
|
|
48
|
+
| [`examples/ftps-directory-ops.ts`](https://github.com/tonywied17/zero-transfer/blob/main/examples/ftps-directory-ops.ts) | FTPS directory operations: list, stat, mkdir, rename, remove, rmdir. |
|
|
49
|
+
| [`examples/ftp-directory-ops.ts`](https://github.com/tonywied17/zero-transfer/blob/main/examples/ftp-directory-ops.ts) | FTP directory operations: list, stat, mkdir, rename, remove, rmdir. |
|
|
40
50
|
|
|
41
51
|
## Documentation
|
|
42
52
|
|
package/dist/index.cjs
CHANGED
|
@@ -86,6 +86,7 @@ __export(classic_exports, {
|
|
|
86
86
|
importOpenSshConfig: () => importOpenSshConfig,
|
|
87
87
|
importWinScpSessions: () => importWinScpSessions,
|
|
88
88
|
isClassicProviderId: () => isClassicProviderId,
|
|
89
|
+
isMainModule: () => isMainModule,
|
|
89
90
|
isSensitiveKey: () => isSensitiveKey,
|
|
90
91
|
joinRemotePath: () => joinRemotePath,
|
|
91
92
|
matchKnownHosts: () => matchKnownHosts,
|
|
@@ -4901,6 +4902,19 @@ function isModifiedAtDifferent2(source, destination, toleranceMs) {
|
|
|
4901
4902
|
return Math.abs(sourceTime - destinationTime) > toleranceMs;
|
|
4902
4903
|
}
|
|
4903
4904
|
|
|
4905
|
+
// src/utils/mainModule.ts
|
|
4906
|
+
var import_node_url = require("url");
|
|
4907
|
+
function isMainModule(importMetaUrl) {
|
|
4908
|
+
if (typeof process === "undefined" || !process.argv || process.argv.length < 2) {
|
|
4909
|
+
return false;
|
|
4910
|
+
}
|
|
4911
|
+
try {
|
|
4912
|
+
return process.argv[1] === (0, import_node_url.fileURLToPath)(importMetaUrl);
|
|
4913
|
+
} catch {
|
|
4914
|
+
return false;
|
|
4915
|
+
}
|
|
4916
|
+
}
|
|
4917
|
+
|
|
4904
4918
|
// src/providers/classic/ftp/FtpProvider.ts
|
|
4905
4919
|
var import_node_buffer6 = require("buffer");
|
|
4906
4920
|
var import_node_net = require("net");
|
|
@@ -8847,7 +8861,7 @@ var SshTransportPacketUnprotector = class {
|
|
|
8847
8861
|
}
|
|
8848
8862
|
/**
|
|
8849
8863
|
* Feeds raw encrypted bytes from the socket and returns any fully decoded payloads.
|
|
8850
|
-
* Maintains internal framing state across calls
|
|
8864
|
+
* Maintains internal framing state across calls - pass each `data` event chunk directly.
|
|
8851
8865
|
*/
|
|
8852
8866
|
pushBytes(chunk) {
|
|
8853
8867
|
this.framePendingRaw = import_node_buffer17.Buffer.concat([this.framePendingRaw, chunk]);
|
|
@@ -9355,7 +9369,7 @@ var SshTransportConnection = class {
|
|
|
9355
9369
|
assertConnected() {
|
|
9356
9370
|
if (!this.connected) {
|
|
9357
9371
|
throw new ProtocolError({
|
|
9358
|
-
message: "SshTransportConnection is not yet connected
|
|
9372
|
+
message: "SshTransportConnection is not yet connected - call connect() first",
|
|
9359
9373
|
protocol: "sftp",
|
|
9360
9374
|
retryable: false
|
|
9361
9375
|
});
|
|
@@ -9695,14 +9709,14 @@ function sftpStatusToError(status, path2) {
|
|
|
9695
9709
|
case SFTP_STATUS.NO_SUCH_FILE:
|
|
9696
9710
|
return new PathNotFoundError({
|
|
9697
9711
|
details: { path: path2, sftpMessage: status.errorMessage },
|
|
9698
|
-
message: `SFTP: no such file or directory${path2 !== void 0 ? `
|
|
9712
|
+
message: `SFTP: no such file or directory${path2 !== void 0 ? ` - ${path2}` : ""}`,
|
|
9699
9713
|
protocol: "sftp",
|
|
9700
9714
|
retryable: false
|
|
9701
9715
|
});
|
|
9702
9716
|
case SFTP_STATUS.PERMISSION_DENIED:
|
|
9703
9717
|
return new PermissionDeniedError({
|
|
9704
9718
|
details: { path: path2, sftpMessage: status.errorMessage },
|
|
9705
|
-
message: `SFTP: permission denied${path2 !== void 0 ? `
|
|
9719
|
+
message: `SFTP: permission denied${path2 !== void 0 ? ` - ${path2}` : ""}`,
|
|
9706
9720
|
protocol: "sftp",
|
|
9707
9721
|
retryable: false
|
|
9708
9722
|
});
|
|
@@ -9710,21 +9724,21 @@ function sftpStatusToError(status, path2) {
|
|
|
9710
9724
|
case SFTP_STATUS.CONNECTION_LOST:
|
|
9711
9725
|
return new ConnectionError({
|
|
9712
9726
|
details: { sftpMessage: status.errorMessage, statusCode: status.statusCode },
|
|
9713
|
-
message: `SFTP: connection error
|
|
9727
|
+
message: `SFTP: connection error - ${status.errorMessage}`,
|
|
9714
9728
|
protocol: "sftp",
|
|
9715
9729
|
retryable: true
|
|
9716
9730
|
});
|
|
9717
9731
|
case SFTP_STATUS.OP_UNSUPPORTED:
|
|
9718
9732
|
return new UnsupportedFeatureError({
|
|
9719
9733
|
details: { sftpMessage: status.errorMessage },
|
|
9720
|
-
message: `SFTP: operation unsupported
|
|
9734
|
+
message: `SFTP: operation unsupported - ${status.errorMessage}`,
|
|
9721
9735
|
protocol: "sftp",
|
|
9722
9736
|
retryable: false
|
|
9723
9737
|
});
|
|
9724
9738
|
case SFTP_STATUS.BAD_MESSAGE:
|
|
9725
9739
|
return new ProtocolError({
|
|
9726
9740
|
details: { sftpMessage: status.errorMessage },
|
|
9727
|
-
message: `SFTP: bad message
|
|
9741
|
+
message: `SFTP: bad message - ${status.errorMessage}`,
|
|
9728
9742
|
protocol: "sftp",
|
|
9729
9743
|
retryable: false
|
|
9730
9744
|
});
|
|
@@ -9732,7 +9746,7 @@ function sftpStatusToError(status, path2) {
|
|
|
9732
9746
|
return new ZeroTransferError({
|
|
9733
9747
|
code: "SFTP_FAILURE",
|
|
9734
9748
|
details: { sftpMessage: status.errorMessage, statusCode: status.statusCode },
|
|
9735
|
-
message: `SFTP: operation failed (status ${status.statusCode})
|
|
9749
|
+
message: `SFTP: operation failed (status ${status.statusCode}) - ${status.errorMessage}`,
|
|
9736
9750
|
protocol: "sftp",
|
|
9737
9751
|
retryable: false
|
|
9738
9752
|
});
|
|
@@ -10856,6 +10870,7 @@ function validateNativeSftpOptions(options) {
|
|
|
10856
10870
|
importOpenSshConfig,
|
|
10857
10871
|
importWinScpSessions,
|
|
10858
10872
|
isClassicProviderId,
|
|
10873
|
+
isMainModule,
|
|
10859
10874
|
isSensitiveKey,
|
|
10860
10875
|
joinRemotePath,
|
|
10861
10876
|
matchKnownHosts,
|