@zero-transfer/sftp 0.4.2 → 0.4.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/README.md +23 -20
- package/dist/index.cjs +25 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +17 -11
- package/dist/index.d.ts +17 -11
- package/dist/index.mjs +24 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -10,37 +10,40 @@ npm install @zero-transfer/sftp
|
|
|
10
10
|
|
|
11
11
|
## Overview
|
|
12
12
|
|
|
13
|
-
Zero-dependency SFTP over SSH built on a first-party SSH transport stack: Ed25519 / RSA-SHA2-256/512 / ECDSA P-256/384/521 host keys, password / keyboard-interactive / public-key (Ed25519 + RSA) auth, host-key pinning, OpenSSH `known_hosts` (hashed/plain, `[host]:port`, `@revoked`), handshake timeout, and idle NAT keepalive.
|
|
13
|
+
Zero-dependency SFTP over SSH built on a first-party SSH transport stack: Ed25519 / RSA-SHA2-256/512 / ECDSA P-256/384/521 host keys, password / keyboard-interactive / public-key (Ed25519 + RSA) auth, host-key pinning, OpenSSH `known_hosts` (hashed/plain, `[host]:port`, `@revoked`), handshake timeout, and idle NAT keepalive.
|
|
14
14
|
|
|
15
15
|
## Usage
|
|
16
16
|
|
|
17
17
|
```ts
|
|
18
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
createTransferClient,
|
|
20
|
+
uploadFile,
|
|
21
|
+
downloadFile,
|
|
22
|
+
createSftpProviderFactory,
|
|
23
|
+
} from "@zero-transfer/sftp";
|
|
19
24
|
```
|
|
20
25
|
|
|
21
26
|
## Public surface
|
|
22
27
|
|
|
23
|
-
This package publishes a narrowed surface of **
|
|
24
|
-
|
|
25
|
-
| Symbol | Kind
|
|
26
|
-
| --------------------------------------------------------------------------------------------------------------------------------------- |
|
|
27
|
-
| `
|
|
28
|
-
| `
|
|
29
|
-
| `
|
|
30
|
-
| [`
|
|
31
|
-
| [`
|
|
32
|
-
| [`
|
|
33
|
-
| [`
|
|
34
|
-
| [`
|
|
35
|
-
| [`parseKnownHosts`](https://github.com/tonywied17/zero-transfer/blob/main/docs/api-md/functions/parseKnownHosts.md) | Function | See API reference. |
|
|
36
|
-
| [`KnownHostsEntry`](https://github.com/tonywied17/zero-transfer/blob/main/docs/api-md/interfaces/KnownHostsEntry.md) | Interface | See API reference. |
|
|
37
|
-
| [`KnownHostsMarker`](https://github.com/tonywied17/zero-transfer/blob/main/docs/api-md/type-aliases/KnownHostsMarker.md) | Type | See API reference. |
|
|
28
|
+
This package publishes a narrowed surface of **8** exports. These symbols are also available from [`@zero-transfer/sdk`](https://www.npmjs.com/package/@zero-transfer/sdk); the table below links into the full API reference:
|
|
29
|
+
|
|
30
|
+
| Symbol | Kind | Notes |
|
|
31
|
+
| --------------------------------------------------------------------------------------------------------------------------------------- | --------- | ------------------ |
|
|
32
|
+
| [`createSftpProviderFactory`](https://github.com/tonywied17/zero-transfer/blob/main/docs/api-md/functions/createSftpProviderFactory.md) | Function | See API reference. |
|
|
33
|
+
| [`SftpProviderOptions`](https://github.com/tonywied17/zero-transfer/blob/main/docs/api-md/interfaces/SftpProviderOptions.md) | Interface | See API reference. |
|
|
34
|
+
| [`SftpRawSession`](https://github.com/tonywied17/zero-transfer/blob/main/docs/api-md/interfaces/SftpRawSession.md) | Interface | See API reference. |
|
|
35
|
+
| [`matchKnownHosts`](https://github.com/tonywied17/zero-transfer/blob/main/docs/api-md/functions/matchKnownHosts.md) | Function | See API reference. |
|
|
36
|
+
| [`matchKnownHostsEntry`](https://github.com/tonywied17/zero-transfer/blob/main/docs/api-md/functions/matchKnownHostsEntry.md) | Function | See API reference. |
|
|
37
|
+
| [`parseKnownHosts`](https://github.com/tonywied17/zero-transfer/blob/main/docs/api-md/functions/parseKnownHosts.md) | Function | See API reference. |
|
|
38
|
+
| [`KnownHostsEntry`](https://github.com/tonywied17/zero-transfer/blob/main/docs/api-md/interfaces/KnownHostsEntry.md) | Interface | See API reference. |
|
|
39
|
+
| [`KnownHostsMarker`](https://github.com/tonywied17/zero-transfer/blob/main/docs/api-md/type-aliases/KnownHostsMarker.md) | Type | See API reference. |
|
|
38
40
|
|
|
39
41
|
## Examples
|
|
40
42
|
|
|
41
|
-
| Example
|
|
42
|
-
|
|
|
43
|
-
| [`examples/sftp-private-key.ts`](https://github.com/tonywied17/zero-transfer/blob/main/examples/sftp-private-key.ts)
|
|
43
|
+
| Example | What it shows |
|
|
44
|
+
| ------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------- |
|
|
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. |
|
|
44
47
|
|
|
45
48
|
## Documentation
|
|
46
49
|
|
package/dist/index.cjs
CHANGED
|
@@ -62,14 +62,13 @@ __export(sftp_exports, {
|
|
|
62
62
|
createBandwidthThrottle: () => createBandwidthThrottle,
|
|
63
63
|
createLocalProviderFactory: () => createLocalProviderFactory,
|
|
64
64
|
createMemoryProviderFactory: () => createMemoryProviderFactory,
|
|
65
|
-
createNativeSftpProviderFactory: () => createNativeSftpProviderFactory,
|
|
66
65
|
createOAuthTokenSecretSource: () => createOAuthTokenSecretSource,
|
|
67
66
|
createPooledTransferClient: () => createPooledTransferClient,
|
|
68
67
|
createProgressEvent: () => createProgressEvent,
|
|
69
68
|
createProviderTransferExecutor: () => createProviderTransferExecutor,
|
|
70
69
|
createRemoteBrowser: () => createRemoteBrowser,
|
|
71
70
|
createRemoteManifest: () => createRemoteManifest,
|
|
72
|
-
createSftpProviderFactory: () =>
|
|
71
|
+
createSftpProviderFactory: () => createSftpProviderFactory,
|
|
73
72
|
createSyncPlan: () => createSyncPlan,
|
|
74
73
|
createTransferClient: () => createTransferClient,
|
|
75
74
|
createTransferJobsFromPlan: () => createTransferJobsFromPlan,
|
|
@@ -84,6 +83,7 @@ __export(sftp_exports, {
|
|
|
84
83
|
importOpenSshConfig: () => importOpenSshConfig,
|
|
85
84
|
importWinScpSessions: () => importWinScpSessions,
|
|
86
85
|
isClassicProviderId: () => isClassicProviderId,
|
|
86
|
+
isMainModule: () => isMainModule,
|
|
87
87
|
isSensitiveKey: () => isSensitiveKey,
|
|
88
88
|
joinRemotePath: () => joinRemotePath,
|
|
89
89
|
matchKnownHosts: () => matchKnownHosts,
|
|
@@ -4892,6 +4892,19 @@ function isModifiedAtDifferent2(source, destination, toleranceMs) {
|
|
|
4892
4892
|
return Math.abs(sourceTime - destinationTime) > toleranceMs;
|
|
4893
4893
|
}
|
|
4894
4894
|
|
|
4895
|
+
// src/utils/mainModule.ts
|
|
4896
|
+
var import_node_url = require("url");
|
|
4897
|
+
function isMainModule(importMetaUrl) {
|
|
4898
|
+
if (typeof process === "undefined" || !process.argv || process.argv.length < 2) {
|
|
4899
|
+
return false;
|
|
4900
|
+
}
|
|
4901
|
+
try {
|
|
4902
|
+
return process.argv[1] === (0, import_node_url.fileURLToPath)(importMetaUrl);
|
|
4903
|
+
} catch {
|
|
4904
|
+
return false;
|
|
4905
|
+
}
|
|
4906
|
+
}
|
|
4907
|
+
|
|
4895
4908
|
// src/providers/native/sftp/NativeSftpProvider.ts
|
|
4896
4909
|
var import_node_buffer20 = require("buffer");
|
|
4897
4910
|
var import_node_crypto9 = require("crypto");
|
|
@@ -7172,7 +7185,7 @@ var SshTransportPacketUnprotector = class {
|
|
|
7172
7185
|
}
|
|
7173
7186
|
/**
|
|
7174
7187
|
* Feeds raw encrypted bytes from the socket and returns any fully decoded payloads.
|
|
7175
|
-
* Maintains internal framing state across calls
|
|
7188
|
+
* Maintains internal framing state across calls - pass each `data` event chunk directly.
|
|
7176
7189
|
*/
|
|
7177
7190
|
pushBytes(chunk) {
|
|
7178
7191
|
this.framePendingRaw = import_node_buffer16.Buffer.concat([this.framePendingRaw, chunk]);
|
|
@@ -7680,7 +7693,7 @@ var SshTransportConnection = class {
|
|
|
7680
7693
|
assertConnected() {
|
|
7681
7694
|
if (!this.connected) {
|
|
7682
7695
|
throw new ProtocolError({
|
|
7683
|
-
message: "SshTransportConnection is not yet connected
|
|
7696
|
+
message: "SshTransportConnection is not yet connected - call connect() first",
|
|
7684
7697
|
protocol: "sftp",
|
|
7685
7698
|
retryable: false
|
|
7686
7699
|
});
|
|
@@ -8020,14 +8033,14 @@ function sftpStatusToError(status, path2) {
|
|
|
8020
8033
|
case SFTP_STATUS.NO_SUCH_FILE:
|
|
8021
8034
|
return new PathNotFoundError({
|
|
8022
8035
|
details: { path: path2, sftpMessage: status.errorMessage },
|
|
8023
|
-
message: `SFTP: no such file or directory${path2 !== void 0 ? `
|
|
8036
|
+
message: `SFTP: no such file or directory${path2 !== void 0 ? ` - ${path2}` : ""}`,
|
|
8024
8037
|
protocol: "sftp",
|
|
8025
8038
|
retryable: false
|
|
8026
8039
|
});
|
|
8027
8040
|
case SFTP_STATUS.PERMISSION_DENIED:
|
|
8028
8041
|
return new PermissionDeniedError({
|
|
8029
8042
|
details: { path: path2, sftpMessage: status.errorMessage },
|
|
8030
|
-
message: `SFTP: permission denied${path2 !== void 0 ? `
|
|
8043
|
+
message: `SFTP: permission denied${path2 !== void 0 ? ` - ${path2}` : ""}`,
|
|
8031
8044
|
protocol: "sftp",
|
|
8032
8045
|
retryable: false
|
|
8033
8046
|
});
|
|
@@ -8035,21 +8048,21 @@ function sftpStatusToError(status, path2) {
|
|
|
8035
8048
|
case SFTP_STATUS.CONNECTION_LOST:
|
|
8036
8049
|
return new ConnectionError({
|
|
8037
8050
|
details: { sftpMessage: status.errorMessage, statusCode: status.statusCode },
|
|
8038
|
-
message: `SFTP: connection error
|
|
8051
|
+
message: `SFTP: connection error - ${status.errorMessage}`,
|
|
8039
8052
|
protocol: "sftp",
|
|
8040
8053
|
retryable: true
|
|
8041
8054
|
});
|
|
8042
8055
|
case SFTP_STATUS.OP_UNSUPPORTED:
|
|
8043
8056
|
return new UnsupportedFeatureError({
|
|
8044
8057
|
details: { sftpMessage: status.errorMessage },
|
|
8045
|
-
message: `SFTP: operation unsupported
|
|
8058
|
+
message: `SFTP: operation unsupported - ${status.errorMessage}`,
|
|
8046
8059
|
protocol: "sftp",
|
|
8047
8060
|
retryable: false
|
|
8048
8061
|
});
|
|
8049
8062
|
case SFTP_STATUS.BAD_MESSAGE:
|
|
8050
8063
|
return new ProtocolError({
|
|
8051
8064
|
details: { sftpMessage: status.errorMessage },
|
|
8052
|
-
message: `SFTP: bad message
|
|
8065
|
+
message: `SFTP: bad message - ${status.errorMessage}`,
|
|
8053
8066
|
protocol: "sftp",
|
|
8054
8067
|
retryable: false
|
|
8055
8068
|
});
|
|
@@ -8057,7 +8070,7 @@ function sftpStatusToError(status, path2) {
|
|
|
8057
8070
|
return new ZeroTransferError({
|
|
8058
8071
|
code: "SFTP_FAILURE",
|
|
8059
8072
|
details: { sftpMessage: status.errorMessage, statusCode: status.statusCode },
|
|
8060
|
-
message: `SFTP: operation failed (status ${status.statusCode})
|
|
8073
|
+
message: `SFTP: operation failed (status ${status.statusCode}) - ${status.errorMessage}`,
|
|
8061
8074
|
protocol: "sftp",
|
|
8062
8075
|
retryable: false
|
|
8063
8076
|
});
|
|
@@ -8467,7 +8480,7 @@ function buildNativeSftpCapabilities(maxConcurrency) {
|
|
|
8467
8480
|
var NATIVE_SFTP_PROVIDER_CAPABILITIES = buildNativeSftpCapabilities(
|
|
8468
8481
|
NATIVE_SFTP_DEFAULT_MAX_CONCURRENCY
|
|
8469
8482
|
);
|
|
8470
|
-
function
|
|
8483
|
+
function createSftpProviderFactory(options = {}) {
|
|
8471
8484
|
validateNativeSftpOptions(options);
|
|
8472
8485
|
const capabilities = buildNativeSftpCapabilities(
|
|
8473
8486
|
options.maxConcurrency ?? NATIVE_SFTP_DEFAULT_MAX_CONCURRENCY
|
|
@@ -9157,7 +9170,6 @@ function validateNativeSftpOptions(options) {
|
|
|
9157
9170
|
createBandwidthThrottle,
|
|
9158
9171
|
createLocalProviderFactory,
|
|
9159
9172
|
createMemoryProviderFactory,
|
|
9160
|
-
createNativeSftpProviderFactory,
|
|
9161
9173
|
createOAuthTokenSecretSource,
|
|
9162
9174
|
createPooledTransferClient,
|
|
9163
9175
|
createProgressEvent,
|
|
@@ -9179,6 +9191,7 @@ function validateNativeSftpOptions(options) {
|
|
|
9179
9191
|
importOpenSshConfig,
|
|
9180
9192
|
importWinScpSessions,
|
|
9181
9193
|
isClassicProviderId,
|
|
9194
|
+
isMainModule,
|
|
9182
9195
|
isSensitiveKey,
|
|
9183
9196
|
joinRemotePath,
|
|
9184
9197
|
matchKnownHosts,
|