@zero-transfer/sftp 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 CHANGED
@@ -8,6 +8,8 @@
8
8
  npm install @zero-transfer/sftp
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/sftp"` 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
15
  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. `createSftpProviderFactory` is kept as an alias of `createNativeSftpProviderFactory` for backward compatibility.
@@ -15,7 +17,12 @@ Zero-dependency SFTP over SSH built on a first-party SSH transport stack: Ed2551
15
17
  ## Usage
16
18
 
17
19
  ```ts
18
- import { createNativeSftpProviderFactory } from "@zero-transfer/sftp";
20
+ import {
21
+ createTransferClient,
22
+ uploadFile,
23
+ downloadFile,
24
+ createNativeSftpProviderFactory,
25
+ } from "@zero-transfer/sftp";
19
26
  ```
20
27
 
21
28
  ## Public surface
@@ -24,9 +31,9 @@ This package publishes a narrowed surface of **11** exports. These symbols are a
24
31
 
25
32
  | Symbol | Kind | Notes |
26
33
  | --------------------------------------------------------------------------------------------------------------------------------------- | ------------ | ------------------ |
27
- | `createNativeSftpProviderFactory` | _unresolved_ | |
28
- | `NativeSftpProviderOptions` | _unresolved_ | |
29
- | `NativeSftpRawSession` | _unresolved_ | |
34
+ | `createNativeSftpProviderFactory` | _unresolved_ | - |
35
+ | `NativeSftpProviderOptions` | _unresolved_ | - |
36
+ | `NativeSftpRawSession` | _unresolved_ | - |
30
37
  | [`createSftpProviderFactory`](https://github.com/tonywied17/zero-transfer/blob/main/docs/api-md/functions/createSftpProviderFactory.md) | Function | See API reference. |
31
38
  | [`SftpProviderOptions`](https://github.com/tonywied17/zero-transfer/blob/main/docs/api-md/interfaces/SftpProviderOptions.md) | Interface | See API reference. |
32
39
  | [`SftpRawSession`](https://github.com/tonywied17/zero-transfer/blob/main/docs/api-md/interfaces/SftpRawSession.md) | Interface | See API reference. |
@@ -38,9 +45,10 @@ This package publishes a narrowed surface of **11** exports. These symbols are a
38
45
 
39
46
  ## Examples
40
47
 
41
- | Example | What it shows |
42
- | -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- |
43
- | [`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. |
48
+ | Example | What it shows |
49
+ | ------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------- |
50
+ | [`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. |
51
+ | [`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
52
 
45
53
  ## Documentation
46
54
 
package/dist/index.cjs CHANGED
@@ -84,6 +84,7 @@ __export(sftp_exports, {
84
84
  importOpenSshConfig: () => importOpenSshConfig,
85
85
  importWinScpSessions: () => importWinScpSessions,
86
86
  isClassicProviderId: () => isClassicProviderId,
87
+ isMainModule: () => isMainModule,
87
88
  isSensitiveKey: () => isSensitiveKey,
88
89
  joinRemotePath: () => joinRemotePath,
89
90
  matchKnownHosts: () => matchKnownHosts,
@@ -4892,6 +4893,19 @@ function isModifiedAtDifferent2(source, destination, toleranceMs) {
4892
4893
  return Math.abs(sourceTime - destinationTime) > toleranceMs;
4893
4894
  }
4894
4895
 
4896
+ // src/utils/mainModule.ts
4897
+ var import_node_url = require("url");
4898
+ function isMainModule(importMetaUrl) {
4899
+ if (typeof process === "undefined" || !process.argv || process.argv.length < 2) {
4900
+ return false;
4901
+ }
4902
+ try {
4903
+ return process.argv[1] === (0, import_node_url.fileURLToPath)(importMetaUrl);
4904
+ } catch {
4905
+ return false;
4906
+ }
4907
+ }
4908
+
4895
4909
  // src/providers/native/sftp/NativeSftpProvider.ts
4896
4910
  var import_node_buffer20 = require("buffer");
4897
4911
  var import_node_crypto9 = require("crypto");
@@ -7172,7 +7186,7 @@ var SshTransportPacketUnprotector = class {
7172
7186
  }
7173
7187
  /**
7174
7188
  * Feeds raw encrypted bytes from the socket and returns any fully decoded payloads.
7175
- * Maintains internal framing state across calls pass each `data` event chunk directly.
7189
+ * Maintains internal framing state across calls - pass each `data` event chunk directly.
7176
7190
  */
7177
7191
  pushBytes(chunk) {
7178
7192
  this.framePendingRaw = import_node_buffer16.Buffer.concat([this.framePendingRaw, chunk]);
@@ -7680,7 +7694,7 @@ var SshTransportConnection = class {
7680
7694
  assertConnected() {
7681
7695
  if (!this.connected) {
7682
7696
  throw new ProtocolError({
7683
- message: "SshTransportConnection is not yet connected \u2014 call connect() first",
7697
+ message: "SshTransportConnection is not yet connected - call connect() first",
7684
7698
  protocol: "sftp",
7685
7699
  retryable: false
7686
7700
  });
@@ -8020,14 +8034,14 @@ function sftpStatusToError(status, path2) {
8020
8034
  case SFTP_STATUS.NO_SUCH_FILE:
8021
8035
  return new PathNotFoundError({
8022
8036
  details: { path: path2, sftpMessage: status.errorMessage },
8023
- message: `SFTP: no such file or directory${path2 !== void 0 ? ` \u2014 ${path2}` : ""}`,
8037
+ message: `SFTP: no such file or directory${path2 !== void 0 ? ` - ${path2}` : ""}`,
8024
8038
  protocol: "sftp",
8025
8039
  retryable: false
8026
8040
  });
8027
8041
  case SFTP_STATUS.PERMISSION_DENIED:
8028
8042
  return new PermissionDeniedError({
8029
8043
  details: { path: path2, sftpMessage: status.errorMessage },
8030
- message: `SFTP: permission denied${path2 !== void 0 ? ` \u2014 ${path2}` : ""}`,
8044
+ message: `SFTP: permission denied${path2 !== void 0 ? ` - ${path2}` : ""}`,
8031
8045
  protocol: "sftp",
8032
8046
  retryable: false
8033
8047
  });
@@ -8035,21 +8049,21 @@ function sftpStatusToError(status, path2) {
8035
8049
  case SFTP_STATUS.CONNECTION_LOST:
8036
8050
  return new ConnectionError({
8037
8051
  details: { sftpMessage: status.errorMessage, statusCode: status.statusCode },
8038
- message: `SFTP: connection error \u2014 ${status.errorMessage}`,
8052
+ message: `SFTP: connection error - ${status.errorMessage}`,
8039
8053
  protocol: "sftp",
8040
8054
  retryable: true
8041
8055
  });
8042
8056
  case SFTP_STATUS.OP_UNSUPPORTED:
8043
8057
  return new UnsupportedFeatureError({
8044
8058
  details: { sftpMessage: status.errorMessage },
8045
- message: `SFTP: operation unsupported \u2014 ${status.errorMessage}`,
8059
+ message: `SFTP: operation unsupported - ${status.errorMessage}`,
8046
8060
  protocol: "sftp",
8047
8061
  retryable: false
8048
8062
  });
8049
8063
  case SFTP_STATUS.BAD_MESSAGE:
8050
8064
  return new ProtocolError({
8051
8065
  details: { sftpMessage: status.errorMessage },
8052
- message: `SFTP: bad message \u2014 ${status.errorMessage}`,
8066
+ message: `SFTP: bad message - ${status.errorMessage}`,
8053
8067
  protocol: "sftp",
8054
8068
  retryable: false
8055
8069
  });
@@ -8057,7 +8071,7 @@ function sftpStatusToError(status, path2) {
8057
8071
  return new ZeroTransferError({
8058
8072
  code: "SFTP_FAILURE",
8059
8073
  details: { sftpMessage: status.errorMessage, statusCode: status.statusCode },
8060
- message: `SFTP: operation failed (status ${status.statusCode}) \u2014 ${status.errorMessage}`,
8074
+ message: `SFTP: operation failed (status ${status.statusCode}) - ${status.errorMessage}`,
8061
8075
  protocol: "sftp",
8062
8076
  retryable: false
8063
8077
  });
@@ -9179,6 +9193,7 @@ function validateNativeSftpOptions(options) {
9179
9193
  importOpenSshConfig,
9180
9194
  importWinScpSessions,
9181
9195
  isClassicProviderId,
9196
+ isMainModule,
9182
9197
  isSensitiveKey,
9183
9198
  joinRemotePath,
9184
9199
  matchKnownHosts,