ssh2-sftp-client 10.0.0 → 10.0.3

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
@@ -1,67 +1,67 @@
1
- - [Overview](#org4821cd9)
2
- - [Version 10.0.0 Changes](#org196e8b6)
3
- - [Installation](#orgeac23df)
4
- - [Basic Usage](#orgda0ed58)
5
- - [Documentation](#orgd0ca540)
6
- - [Specifying Paths](#orgabfbdff)
7
- - [Methods](#org35528cc)
8
- - [new SftpClient(name) ===> SFTP client object](#org6d917af)
9
- - [connect(config) ===> SFTP object](#org3ca98bb)
10
- - [list(path, filter) ==> Array[object]](#org067b5c0)
11
- - [exists(path) ==> boolean](#orgfde631c)
12
- - [stat(path) ==> object](#orge6ccca9)
13
- - [get(path, dst, options) ==> String|Stream|Buffer](#org63cf95f)
14
- - [fastGet(remotePath, localPath, options) ===> string](#orga32496c)
15
- - [put(src, remotePath, options) ==> string](#org6bdfd59)
16
- - [fastPut(localPath, remotePath, options) ==> string](#org4296214)
17
- - [append(input, remotePath, options) ==> string](#org01aa427)
18
- - [mkdir(path, recursive) ==> string](#orge74ab72)
19
- - [rmdir(path, recursive) ==> string](#org2692b91)
20
- - [delete(path, noErrorOK) ==> string](#org59254a5)
21
- - [rename(fromPath, toPath) ==> string](#org287873a)
22
- - [posixRename(fromPath, toPath) ==> string](#orgb7290ba)
23
- - [chmod(path, mode) ==> string](#org0e57abe)
24
- - [realPath(path) ===> string](#org52444ca)
25
- - [cwd() ==> string](#org34966e3)
26
- - [uploadDir(srcDir, dstDir, options) ==> string](#org5c58fad)
27
- - [downloadDir(srcDir, dstDir, options) ==> string](#orgb346779)
28
- - [createReadStream(remotePath, options)) ==> stream object](#orga0edaaf)
29
- - [createWriteStream(remotePath, options) ==> stream object](#org7287ad7)
30
- - [rcopy(srcPath, dstPath) ==> string](#org4b84e95)
31
- - [end() ==> boolean](#org6af9411)
32
- - [Add and Remove Listeners](#org79d7176)
33
- - [Platform Quirks & Warnings](#org8815934)
34
- - [Server Capabilities](#orgcf08239)
35
- - [Issues with `fastPut()` and `fastGet()` Methods](#org92f1dc4)
36
- - [Promises, Events & Managing Exceptions](#org27f104a)
37
- - [Adding Custom Handlers](#orgd903953)
38
- - [Windows Based Servers](#orged5ee01)
39
- - [Don't Re-use SftpClient Objects](#orgfafec91)
40
- - [FAQ](#orgbe306ce)
41
- - [Remote server drops connections with only an end event](#org9377d69)
42
- - [How can I pass writeable stream as dst for get method?](#org0cf3ed0)
43
- - [How can I upload files without having to specify a password?](#org14d1415)
44
- - [How can I connect through a Socks Proxy](#org118bb9f)
45
- - [Timeout while waiting for handshake or handshake errors](#orgc720a77)
46
- - [How can I limit upload/download speed](#orge322728)
47
- - [Connection hangs or fails for larger files](#org4164c6c)
48
- - [Typescript definition file out of date](#orgd28c1e8)
49
- - [Examples](#orgfab3156)
50
- - [Troubleshooting](#orga11079b)
51
- - [Common Errors](#org0372c41)
52
- - [Not returning the promise in a `then()` block](#org0d8dc85)
53
- - [Mixing Promise Chains and Async/Await](#org199b814)
54
- - [Try/catch and Error Handlers](#org46e5412)
55
- - [Server Differences](#org8a2ebba)
56
- - [Avoid Concurrent Operations](#org24c4235)
57
- - [Debugging Support](#org1d067af)
58
- - [Logging Issues](#orgdc52f71)
59
- - [Pull Requests](#orge4e0c24)
60
- - [Contributors](#org7f7c9a1)
61
-
62
-
63
-
64
- <a id="org4821cd9"></a>
1
+ - [Overview](#orga044be2)
2
+ - [Version 10.0.0 Changes](#org5a95165)
3
+ - [Installation](#org4295c8d)
4
+ - [Basic Usage](#org7c7ac64)
5
+ - [Documentation](#org47c8184)
6
+ - [Specifying Paths](#org3436700)
7
+ - [Methods](#org8effeda)
8
+ - [new SftpClient(name) ===> SFTP client object](#orgb641cd7)
9
+ - [connect(config) ===> SFTP object](#org054724c)
10
+ - [list(path, filter) ==> Array[object]](#org241650c)
11
+ - [exists(path) ==> boolean](#orgec95901)
12
+ - [stat(path) ==> object](#org1cb80c9)
13
+ - [get(path, dst, options) ==> String|Stream|Buffer](#org5248523)
14
+ - [fastGet(remotePath, localPath, options) ===> string](#org49ee6bb)
15
+ - [put(src, remotePath, options) ==> string](#org90c60ca)
16
+ - [fastPut(localPath, remotePath, options) ==> string](#org3f737cf)
17
+ - [append(input, remotePath, options) ==> string](#orgec4dff5)
18
+ - [mkdir(path, recursive) ==> string](#orgc0728b6)
19
+ - [rmdir(path, recursive) ==> string](#org6927e29)
20
+ - [delete(path, noErrorOK) ==> string](#orgcf3a9b7)
21
+ - [rename(fromPath, toPath) ==> string](#org9a3f834)
22
+ - [posixRename(fromPath, toPath) ==> string](#orgf428194)
23
+ - [chmod(path, mode) ==> string](#orgcc1d70a)
24
+ - [realPath(path) ===> string](#org0b200a7)
25
+ - [cwd() ==> string](#orgae0fe4e)
26
+ - [uploadDir(srcDir, dstDir, options) ==> string](#org451886d)
27
+ - [downloadDir(srcDir, dstDir, options) ==> string](#org49e357f)
28
+ - [createReadStream(remotePath, options)) ==> stream object](#orga25bbd5)
29
+ - [createWriteStream(remotePath, options) ==> stream object](#orgc593764)
30
+ - [rcopy(srcPath, dstPath) ==> string](#orgfaaf765)
31
+ - [end() ==> boolean](#orgd1c464a)
32
+ - [Add and Remove Listeners](#orgccff405)
33
+ - [Platform Quirks & Warnings](#org17e30f1)
34
+ - [Server Capabilities](#org25b6c01)
35
+ - [Issues with `fastPut()` and `fastGet()` Methods](#orgae85e0b)
36
+ - [Promises, Events & Managing Exceptions](#org2511fe9)
37
+ - [Adding Custom Handlers](#orgb041e8e)
38
+ - [Windows Based Servers](#org279eef7)
39
+ - [Don't Re-use SftpClient Objects](#org1d1a2ce)
40
+ - [FAQ](#orgcc893b5)
41
+ - [Remote server drops connections with only an end event](#orgb5071b8)
42
+ - [How can I pass writeable stream as dst for get method?](#org85632d7)
43
+ - [How can I upload files without having to specify a password?](#org783398b)
44
+ - [How can I connect through a Socks Proxy](#org1ade32e)
45
+ - [Timeout while waiting for handshake or handshake errors](#org98434f2)
46
+ - [How can I limit upload/download speed](#orgb24e42e)
47
+ - [Connection hangs or fails for larger files](#org9603b10)
48
+ - [Typescript definition file out of date](#orgc04a5c5)
49
+ - [Examples](#orgd9ac19e)
50
+ - [Troubleshooting](#org80d0f58)
51
+ - [Common Errors](#orgd5409ee)
52
+ - [Not returning the promise in a `then()` block](#org1087cbf)
53
+ - [Mixing Promise Chains and Async/Await](#org2bab537)
54
+ - [Try/catch and Error Handlers](#org0a6ff84)
55
+ - [Server Differences](#orgd2993cc)
56
+ - [Avoid Concurrent Operations](#org4db9137)
57
+ - [Debugging Support](#org04b7c4c)
58
+ - [Logging Issues](#orgfa0c326)
59
+ - [Pull Requests](#org455cc3e)
60
+ - [Contributors](#org0408f3a)
61
+
62
+
63
+
64
+ <a id="orga044be2"></a>
65
65
 
66
66
  # Overview
67
67
 
@@ -69,14 +69,16 @@ an SFTP client for node.js, a wrapper around [SSH2](https://github.com/mscdex/ss
69
69
 
70
70
  Documentation on the methods and available options in the underlying modules can be found on the [SSH2](https://github.com/mscdex/ssh2) project pages. As this module is really just a wrapper around the `ssh2` module, you will find lots of useful information, tips and examples in the `ssh2` repository.
71
71
 
72
- Current stable release is \*v10.0.0.
72
+ Current stable release is \*v10.0.3
73
73
 
74
74
  Code has been tested against Node versions 16.20.2, 18.18.2, 20.10.0 and 21.5.0. However, only versions from v18 are actively supported. It should also be noted that a significant performance improvement has been observed with versions >= 18. Version v16 is significantly slower.
75
75
 
76
76
  Node versions < 16.x are not supported.
77
77
 
78
+ If you find this module useful and you would like to support the on-going maintenance and support of users, please consider making a small [donation](https://square.link/u/gB2kSdkY?src=embed).
78
79
 
79
- <a id="org196e8b6"></a>
80
+
81
+ <a id="org5a95165"></a>
80
82
 
81
83
  ## Version 10.0.0 Changes
82
84
 
@@ -84,7 +86,7 @@ Node versions < 16.x are not supported.
84
86
  - Various minor documentation fixes and some minor fixes for typos in option property names.
85
87
 
86
88
 
87
- <a id="orgeac23df"></a>
89
+ <a id="org4295c8d"></a>
88
90
 
89
91
  # Installation
90
92
 
@@ -93,7 +95,7 @@ npm install ssh2-sftp-client
93
95
  ```
94
96
 
95
97
 
96
- <a id="orgda0ed58"></a>
98
+ <a id="org7c7ac64"></a>
97
99
 
98
100
  # Basic Usage
99
101
 
@@ -116,7 +118,7 @@ sftp.connect({
116
118
  ```
117
119
 
118
120
 
119
- <a id="orgd0ca540"></a>
121
+ <a id="org47c8184"></a>
120
122
 
121
123
  # Documentation
122
124
 
@@ -127,7 +129,7 @@ All the methods will return a Promise, except for `on(), ~removeListener()`, `cr
127
129
  Note that I don't use Typescript and I don't maintain any typescript definition files. There are some typescript type definition files for this module, but they are maintained separately and have nothing to do with this project. Therefore, please do not log any issues arising from the use of these definition files with this project. Instead, refer your issues to the maintainers of those modules.
128
130
 
129
131
 
130
- <a id="orgabfbdff"></a>
132
+ <a id="org3436700"></a>
131
133
 
132
134
  ## Specifying Paths
133
135
 
@@ -160,12 +162,12 @@ client.put('/home/fred/test.txt', '/remote/dir/test-copy.txt');
160
162
  This will copy the local file `test.txt` to the remote file `test-copy.txt` in the directory `/remote/dir`.
161
163
 
162
164
 
163
- <a id="org35528cc"></a>
165
+ <a id="org8effeda"></a>
164
166
 
165
167
  ## Methods
166
168
 
167
169
 
168
- <a id="org6d917af"></a>
170
+ <a id="orgb641cd7"></a>
169
171
 
170
172
  ### new SftpClient(name) ===> SFTP client object
171
173
 
@@ -204,7 +206,7 @@ Constructor to create a new `ssh2-sftp-client` object. An optional `name` string
204
206
  ```
205
207
 
206
208
 
207
- <a id="org3ca98bb"></a>
209
+ <a id="org054724c"></a>
208
210
 
209
211
  ### connect(config) ===> SFTP object
210
212
 
@@ -273,7 +275,7 @@ Connect to an sftp server. Full documentation for connection options is availabl
273
275
  ```
274
276
 
275
277
 
276
- <a id="org067b5c0"></a>
278
+ <a id="org241650c"></a>
277
279
 
278
280
  ### list(path, filter) ==> Array[object]
279
281
 
@@ -334,7 +336,7 @@ Retrieves a directory listing. This method returns a Promise, which once realise
334
336
  ```
335
337
 
336
338
 
337
- <a id="orgfde631c"></a>
339
+ <a id="orgec95901"></a>
338
340
 
339
341
  ### exists(path) ==> boolean
340
342
 
@@ -370,7 +372,7 @@ Tests to see if remote file or directory exists. Returns type of remote object i
370
372
  ```
371
373
 
372
374
 
373
- <a id="orge6ccca9"></a>
375
+ <a id="org1cb80c9"></a>
374
376
 
375
377
  ### stat(path) ==> object
376
378
 
@@ -421,7 +423,7 @@ Returns the attributes associated with the object pointed to by `path`.
421
423
  ```
422
424
 
423
425
 
424
- <a id="org63cf95f"></a>
426
+ <a id="org5248523"></a>
425
427
 
426
428
  ### get(path, dst, options) ==> String|Stream|Buffer
427
429
 
@@ -477,7 +479,7 @@ In general, if you're going to pass in a string as the destination, you are bett
477
479
  - **Tip:** See examples file in the Git repository for more examples. You can pass any writeable stream in as the destination. For example, if you pass in `zlib.createGunzip()` writeable stream, you can both download and decompress a gzip file 'on the fly'.
478
480
 
479
481
 
480
- <a id="orga32496c"></a>
482
+ <a id="org49ee6bb"></a>
481
483
 
482
484
  ### fastGet(remotePath, localPath, options) ===> string
483
485
 
@@ -522,7 +524,7 @@ Bottom line, when it works, it tends to work reliably. However, for many servers
522
524
  ```
523
525
 
524
526
 
525
- <a id="org6bdfd59"></a>
527
+ <a id="org90c60ca"></a>
526
528
 
527
529
  ### put(src, remotePath, options) ==> string
528
530
 
@@ -572,7 +574,7 @@ Upload data from local system to remote server. If the `src` argument is a strin
572
574
  - **Tip:** If the src argument is a path string, consider just using `fastPut()`.
573
575
 
574
576
 
575
- <a id="org4296214"></a>
577
+ <a id="org3f737cf"></a>
576
578
 
577
579
  ### fastPut(localPath, remotePath, options) ==> string
578
580
 
@@ -618,7 +620,7 @@ Bottom line, when it works, it tends to work well. However, when it doesn't work
618
620
  ```
619
621
 
620
622
 
621
- <a id="org01aa427"></a>
623
+ <a id="orgec4dff5"></a>
622
624
 
623
625
  ### append(input, remotePath, options) ==> string
624
626
 
@@ -662,7 +664,7 @@ Append the `input` data to an existing remote file. There is no integrity checki
662
664
  ```
663
665
 
664
666
 
665
- <a id="orge74ab72"></a>
667
+ <a id="orgc0728b6"></a>
666
668
 
667
669
  ### mkdir(path, recursive) ==> string
668
670
 
@@ -690,7 +692,7 @@ Create a new directory. If the recursive flag is set to true, the method will cr
690
692
  ```
691
693
 
692
694
 
693
- <a id="org2692b91"></a>
695
+ <a id="org6927e29"></a>
694
696
 
695
697
  ### rmdir(path, recursive) ==> string
696
698
 
@@ -720,7 +722,7 @@ Remove a directory. If removing a directory and recursive flag is set to `true`,
720
722
  ```
721
723
 
722
724
 
723
- <a id="org59254a5"></a>
725
+ <a id="orgcf3a9b7"></a>
724
726
 
725
727
  ### delete(path, noErrorOK) ==> string
726
728
 
@@ -749,7 +751,7 @@ Delete a file on the remote server.
749
751
  ```
750
752
 
751
753
 
752
- <a id="org287873a"></a>
754
+ <a id="org9a3f834"></a>
753
755
 
754
756
  ### rename(fromPath, toPath) ==> string
755
757
 
@@ -778,7 +780,7 @@ Rename a file or directory from `fromPath` to `toPath`. You must have the necess
778
780
  ```
779
781
 
780
782
 
781
- <a id="orgb7290ba"></a>
783
+ <a id="orgf428194"></a>
782
784
 
783
785
  ### posixRename(fromPath, toPath) ==> string
784
786
 
@@ -805,7 +807,7 @@ client.connect(config)
805
807
  ```
806
808
 
807
809
 
808
- <a id="org0e57abe"></a>
810
+ <a id="orgcc1d70a"></a>
809
811
 
810
812
  ### chmod(path, mode) ==> string
811
813
 
@@ -834,7 +836,7 @@ Change the mode (read, write or execute permissions) of a remote file or directo
834
836
  ```
835
837
 
836
838
 
837
- <a id="org52444ca"></a>
839
+ <a id="org0b200a7"></a>
838
840
 
839
841
  ### realPath(path) ===> string
840
842
 
@@ -845,14 +847,14 @@ Converts a relative path to an absolute path on the remote server. This method i
845
847
  - **path:** A file path, either relative or absolute. Can handle '.' and '..', but does not expand '~'.
846
848
 
847
849
 
848
- <a id="org34966e3"></a>
850
+ <a id="orgae0fe4e"></a>
849
851
 
850
852
  ### cwd() ==> string
851
853
 
852
854
  Returns what the server believes is the current remote working directory.
853
855
 
854
856
 
855
- <a id="org5c58fad"></a>
857
+ <a id="org451886d"></a>
856
858
 
857
859
  ### uploadDir(srcDir, dstDir, options) ==> string
858
860
 
@@ -921,7 +923,7 @@ The `useFastput` option is a boolean option. If `true`, the method will use the
921
923
  ```
922
924
 
923
925
 
924
- <a id="orgb346779"></a>
926
+ <a id="org49e357f"></a>
925
927
 
926
928
  ### downloadDir(srcDir, dstDir, options) ==> string
927
929
 
@@ -986,7 +988,7 @@ If the `useFastget` property is set to `true`, the method will use `fastGet()` t
986
988
  ```
987
989
 
988
990
 
989
- <a id="orga0edaaf"></a>
991
+ <a id="orga25bbd5"></a>
990
992
 
991
993
  ### createReadStream(remotePath, options)) ==> stream object
992
994
 
@@ -1003,7 +1005,7 @@ Returns a read stream object which is attached to the remote file specified by t
1003
1005
  - **end:** Position to stop reading bytes (inclusive).
1004
1006
 
1005
1007
 
1006
- <a id="org7287ad7"></a>
1008
+ <a id="orgc593764"></a>
1007
1009
 
1008
1010
  ### createWriteStream(remotePath, options) ==> stream object
1009
1011
 
@@ -1018,7 +1020,7 @@ Returns a write stream object which is attached to the remote file specified in
1018
1020
  - **start:** Byte position to start writing from (inclusive). May require changing flag to 'r+'.
1019
1021
 
1020
1022
 
1021
- <a id="org4b84e95"></a>
1023
+ <a id="orgfaaf765"></a>
1022
1024
 
1023
1025
  ### rcopy(srcPath, dstPath) ==> string
1024
1026
 
@@ -1028,7 +1030,7 @@ Perform a remote file copy. The file identified by the `srcPath` argument will b
1028
1030
  - **dstPath:** Path to where the copy will be created specified as a string
1029
1031
 
1030
1032
 
1031
- <a id="org6af9411"></a>
1033
+ <a id="orgd1c464a"></a>
1032
1034
 
1033
1035
  ### end() ==> boolean
1034
1036
 
@@ -1052,7 +1054,7 @@ Ends the current client session, releasing the client socket and associated reso
1052
1054
  ```
1053
1055
 
1054
1056
 
1055
- <a id="org79d7176"></a>
1057
+ <a id="orgccff405"></a>
1056
1058
 
1057
1059
  ### Add and Remove Listeners
1058
1060
 
@@ -1073,12 +1075,12 @@ Although normally not required, you can add and remove custom listeners on the s
1073
1075
  Removes the specified listener from the event specified in eventType. Note that the `end()` method automatically removes all listeners from the client object.
1074
1076
 
1075
1077
 
1076
- <a id="org8815934"></a>
1078
+ <a id="org17e30f1"></a>
1077
1079
 
1078
1080
  # Platform Quirks & Warnings
1079
1081
 
1080
1082
 
1081
- <a id="orgcf08239"></a>
1083
+ <a id="org25b6c01"></a>
1082
1084
 
1083
1085
  ## Server Capabilities
1084
1086
 
@@ -1087,7 +1089,7 @@ All SFTP servers and platforms are not equal. Some facilities provided by `ssh2-
1087
1089
  One way to determine whether an issue you are encountering is due to `ssh2-sftp-client` or due to the remote server or server platform is to use a simple CLI sftp program, such as openSSH's sftp command. If you observe the same behaviour using plain `sftp` on the command line, the issue is likely due to server or remote platform limitations. Note that you should not use a GUI sftp client, like `Filezilla` or `winSCP` as such GUI programs often attempt to hide these server and platform incompatibilities and will take additional steps to simulate missing functionality etc. You want to use a CLI program which does as little as possible.
1088
1090
 
1089
1091
 
1090
- <a id="org92f1dc4"></a>
1092
+ <a id="orgae85e0b"></a>
1091
1093
 
1092
1094
  ## Issues with `fastPut()` and `fastGet()` Methods
1093
1095
 
@@ -1096,7 +1098,7 @@ The `fastPut()` and `fastGet()` methods are known to be somewhat dependent on SF
1096
1098
  To see an example of the type of issues you can observe with `fastPut()` or `fastGet()`, have a look at [issue 407](https://github.com/theophilusx/ssh2-sftp-client/issues/407), which describes the experiences of one user. Bottom line, when it works, it tends to work well and be significantly faster than using just `get()` or `put()`. However, when developing code to run against different SFTP servers, especially where you are unable to test against each server, you are likely better off just using `get()` and `put()` or structuring your code so that users can select which method to use (this is what `ssh2-sftp-client` does - for example, see the `!downloadDir()` and `uploadDir()` methods.
1097
1099
 
1098
1100
 
1099
- <a id="org27f104a"></a>
1101
+ <a id="org2511fe9"></a>
1100
1102
 
1101
1103
  ## Promises, Events & Managing Exceptions
1102
1104
 
@@ -1115,14 +1117,14 @@ The other area where additional events are fired is during the end() call. To de
1115
1117
  In addition to the promise based event handlers, `ssh2-sftp-client` also implements global event handlers which will catch any `error`, `end` or `close` events. Essentially, these global handlers only reset the `sftp` property of the client object, effectively ensuring any subsequent calls are rejected and in the case of an error, send the error to the console.
1116
1118
 
1117
1119
 
1118
- <a id="orgd903953"></a>
1120
+ <a id="orgb041e8e"></a>
1119
1121
 
1120
1122
  ### Adding Custom Handlers
1121
1123
 
1122
1124
  While the above strategies appear to work for the majority of use cases, there are always going to be edge cases which require more flexible or powerful event handling. To support this, the `on()` and `removeListener()` methods are provided. Any event listener added using the `on()` method will be added at the beginning of the list of handlers for that event, ensuring it will be called before any global or promise local events. See the documentation for the `on()` method for details.
1123
1125
 
1124
1126
 
1125
- <a id="orged5ee01"></a>
1127
+ <a id="org279eef7"></a>
1126
1128
 
1127
1129
  ## Windows Based Servers
1128
1130
 
@@ -1131,7 +1133,7 @@ It appears that when the sftp server is running on Windows, a *ECONNRESET* error
1131
1133
  The best way to avoid this issue is to not re-use client objects. Always generate a new sftp client object for each new connection.
1132
1134
 
1133
1135
 
1134
- <a id="orgfafec91"></a>
1136
+ <a id="org1d1a2ce"></a>
1135
1137
 
1136
1138
  ## Don't Re-use SftpClient Objects
1137
1139
 
@@ -1140,12 +1142,12 @@ Due to an issue with *ECONNRESET* error signals when connecting to Windows based
1140
1142
  To avoid this problem, don't re-use SftpClient objects. Generate a new SftpClient object for each connection. You can perform multiple actions with a single connection e.g. upload multiple files, download multiple files etc, but after you have called end(), you should not try to re-use the object with a further connect() call. Create a new object instead.
1141
1143
 
1142
1144
 
1143
- <a id="orgbe306ce"></a>
1145
+ <a id="orgcc893b5"></a>
1144
1146
 
1145
1147
  # FAQ
1146
1148
 
1147
1149
 
1148
- <a id="org9377d69"></a>
1150
+ <a id="orgb5071b8"></a>
1149
1151
 
1150
1152
  ## Remote server drops connections with only an end event
1151
1153
 
@@ -1156,7 +1158,7 @@ Clients first make an unauthenticated connection to the SFTP server to begin neg
1156
1158
  One way to avoid this type of issue is to add a delay between connection attempts. It does not need to be a very long delay - just sufficient to permit the previous connection to be authenticated. In fact, the default setting for openSSH is `10:30:60`, so you really just need to have enough delay to ensure that the 1st connection has completed authentication before the 11th connection is attempted.
1157
1159
 
1158
1160
 
1159
- <a id="org0cf3ed0"></a>
1161
+ <a id="org85632d7"></a>
1160
1162
 
1161
1163
  ## How can I pass writeable stream as dst for get method?
1162
1164
 
@@ -1215,7 +1217,7 @@ sftp
1215
1217
  ```
1216
1218
 
1217
1219
 
1218
- <a id="org14d1415"></a>
1220
+ <a id="org783398b"></a>
1219
1221
 
1220
1222
  ## How can I upload files without having to specify a password?
1221
1223
 
@@ -1250,7 +1252,7 @@ sftp.connect({
1250
1252
  ```
1251
1253
 
1252
1254
 
1253
- <a id="org118bb9f"></a>
1255
+ <a id="org1ade32e"></a>
1254
1256
 
1255
1257
  ## How can I connect through a Socks Proxy
1256
1258
 
@@ -1287,7 +1289,7 @@ client.connect({
1287
1289
  ```
1288
1290
 
1289
1291
 
1290
- <a id="orgc720a77"></a>
1292
+ <a id="org98434f2"></a>
1291
1293
 
1292
1294
  ## Timeout while waiting for handshake or handshake errors
1293
1295
 
@@ -1296,7 +1298,7 @@ Some users have encountered the error 'Timeout while waiting for handshake' or '
1296
1298
  When encountering this type of problem, one worthwhile approach is to use openSSH's CLI sftp program with the `-v` switch to raise logging levels. This will show you what algorithms the CLI is using. You can then use this information to match the names with the accepted algorithm names documented in the `ssh2` README to set the properties in the `algorithms` object.
1297
1299
 
1298
1300
 
1299
- <a id="orge322728"></a>
1301
+ <a id="orgb24e42e"></a>
1300
1302
 
1301
1303
  ## How can I limit upload/download speed
1302
1304
 
@@ -1336,7 +1338,7 @@ try {
1336
1338
  ```
1337
1339
 
1338
1340
 
1339
- <a id="org4164c6c"></a>
1341
+ <a id="org9603b10"></a>
1340
1342
 
1341
1343
  ## Connection hangs or fails for larger files
1342
1344
 
@@ -1347,21 +1349,21 @@ A symptom of this issue is that you are able to upload small files, but uploadin
1347
1349
  For more explanation, see [issue #342](https://github.com/theophilusx/ssh2-sftp-client/issues/342).
1348
1350
 
1349
1351
 
1350
- <a id="orgd28c1e8"></a>
1352
+ <a id="orgc04a5c5"></a>
1351
1353
 
1352
1354
  ## Typescript definition file out of date
1353
1355
 
1354
1356
  This project does not use Typescript. However, typescript definition files are provided by other 3rd parties. Sometimes, these definition files have not stayed up-to-date with the current version of this module. If you encounter this issue, you need to report it to the party responsible for the definition file, not this project.
1355
1357
 
1356
1358
 
1357
- <a id="orgfab3156"></a>
1359
+ <a id="orgd9ac19e"></a>
1358
1360
 
1359
1361
  # Examples
1360
1362
 
1361
1363
  I have started collecting example scripts in the example directory of the repository. These are mainly scripts I have put together in order to investigate issues or provide samples for users. They are not robust, lack adequate error handling and may contain errors. However, I think they are still useful for helping developers see how the module and API can be used.
1362
1364
 
1363
1365
 
1364
- <a id="orga11079b"></a>
1366
+ <a id="org80d0f58"></a>
1365
1367
 
1366
1368
  # Troubleshooting
1367
1369
 
@@ -1376,14 +1378,14 @@ Note also that in the repository there are two useful directories. The first is
1376
1378
  The second directory is the validation directory. I have some very simple scripts in this directory which perform basic tasks using only the `ssh2` modules (no `ssh2-sftp-client` module). These can be useful when trying to determine if the issue is with the underlying `ssh2` module or the `ssh2-sftp-client` wrapper module.
1377
1379
 
1378
1380
 
1379
- <a id="org0372c41"></a>
1381
+ <a id="orgd5409ee"></a>
1380
1382
 
1381
1383
  ## Common Errors
1382
1384
 
1383
1385
  There are some common errors people tend to make when using Promises or Async/Await. These are by far the most common problem found in issues logged against this module. Please check for some of these before logging your issue.
1384
1386
 
1385
1387
 
1386
- <a id="org0d8dc85"></a>
1388
+ <a id="org1087cbf"></a>
1387
1389
 
1388
1390
  ### Not returning the promise in a `then()` block
1389
1391
 
@@ -1420,7 +1422,7 @@ Note the `return` statements. These ensure that the Promise returned by the clie
1420
1422
  A common symptom of this type of error is for file uploads or download to fail to complete or for data in those files to be truncated. What is happening is that the connection is being ended before the transfer has completed.
1421
1423
 
1422
1424
 
1423
- <a id="org199b814"></a>
1425
+ <a id="org2bab537"></a>
1424
1426
 
1425
1427
  ### Mixing Promise Chains and Async/Await
1426
1428
 
@@ -1480,7 +1482,7 @@ async function doSftp() {
1480
1482
  ```
1481
1483
 
1482
1484
 
1483
- <a id="org46e5412"></a>
1485
+ <a id="org0a6ff84"></a>
1484
1486
 
1485
1487
  ### Try/catch and Error Handlers
1486
1488
 
@@ -1491,14 +1493,14 @@ The basic problem is that the try/catch block will have completed execution befo
1491
1493
  Error events are essentially asynchronous code. You don't know when such events will fire. Therefore, you cannot use a try/catch block to catch such event errors. Even creating an error handler which then throws an exception won't help as the key problem is that your try/catch block has already executed. There are a number of alternative ways to deal with this situation. However, the key symptom is that you see occasional uncaught error exceptions that cause your script to exit abnormally despite having try/catch blocks in your script. What you need to do is look at your code and find where errors are raised asynchronously and use an event handler or some other mechanism to manage any errors raised.
1492
1494
 
1493
1495
 
1494
- <a id="org8a2ebba"></a>
1496
+ <a id="orgd2993cc"></a>
1495
1497
 
1496
1498
  ### Server Differences
1497
1499
 
1498
1500
  Not all SFTP servers are the same. Like most standards, the SFTP protocol has some level of interpretation and allows different levels of compliance. This means there can be differences in behaviour between different servers and code which works with one server will not work the same with another. For example, the value returned by *realpath* for non-existent objects can differ significantly. Some servers will throw an error for a particular operation while others will just return null, some servers support concurrent operations (such as used by fastGet/fastPut) while others will not and of course, the text of error messages can vary significantly. In particular, we have noticed significant differences across different platforms. It is therefore advisable to do comprehensive testing when the SFTP server is moved to a new platform. This includes moving from to a cloud based service even if the underlying platform remains the same. I have noticed that some cloud platforms can generate unexpected events, possibly related to additional functionality or features associated with the cloud implementation. For example, it appears SFTP servers running under Azure will generate an error event when the connection is closed even when the client has requested the connection be terminated. The same SFTP server running natively on Windows does not appear to exhibit such behaviour.
1499
1501
 
1500
1502
 
1501
- <a id="org24c4235"></a>
1503
+ <a id="org4db9137"></a>
1502
1504
 
1503
1505
  ### Avoid Concurrent Operations
1504
1506
 
@@ -1507,7 +1509,7 @@ Technically, SFTP should be able to perform multiple operations concurrently. As
1507
1509
  If you are going to try and perform concurrent operations, you need to test extensively and ensure you are using data which is large enough that context switching does occur (i.e. the request is not completed in a single run). Some SFTP servers will handle concurrent operations better than others.
1508
1510
 
1509
1511
 
1510
- <a id="org1d067af"></a>
1512
+ <a id="org04b7c4c"></a>
1511
1513
 
1512
1514
  ## Debugging Support
1513
1515
 
@@ -1540,7 +1542,7 @@ If you just want to see debug messages from `ssh2-sftp-client` and exclude debug
1540
1542
  ```
1541
1543
 
1542
1544
 
1543
- <a id="orgdc52f71"></a>
1545
+ <a id="orgfa0c326"></a>
1544
1546
 
1545
1547
  # Logging Issues
1546
1548
 
@@ -1557,7 +1559,7 @@ I am happy to try and help diagnose and fix any issues you encounter while using
1557
1559
  Perhaps the best assistance is a minimal reproducible example of the issue. Once the issue can be readily reproduced, it can usually be fixed very quickly.
1558
1560
 
1559
1561
 
1560
- <a id="orge4e0c24"></a>
1562
+ <a id="org455cc3e"></a>
1561
1563
 
1562
1564
  # Pull Requests
1563
1565
 
@@ -1574,7 +1576,7 @@ This module will adopt a standard semantic versioning policy. Please indicate in
1574
1576
  - **Bug Fix:** No change to functionality or features. Simple fix of an existing bug.
1575
1577
 
1576
1578
 
1577
- <a id="org7f7c9a1"></a>
1579
+ <a id="org0408f3a"></a>
1578
1580
 
1579
1581
  # Contributors
1580
1582
 
package/README.org CHANGED
@@ -11,7 +11,7 @@ be found on the [[https://github.com/mscdex/ssh2][SSH2]] project pages. As this
11
11
  ~ssh2~ module, you will find lots of useful information, tips and examples in the ~ssh2~
12
12
  repository.
13
13
 
14
- Current stable release is *v10.0.0.
14
+ Current stable release is *v10.0.3
15
15
 
16
16
  Code has been tested against Node versions 16.20.2, 18.18.2, 20.10.0 and 21.5.0. However,
17
17
  only versions from v18 are actively supported. It should also be noted that a significant
@@ -20,6 +20,9 @@ significantly slower.
20
20
 
21
21
  Node versions < 16.x are not supported.
22
22
 
23
+ If you find this module useful and you would like to support the on-going maintenance and
24
+ support of users, please consider making a small [[https://square.link/u/gB2kSdkY?src=embed][donation]].
25
+
23
26
  ** Version 10.0.0 Changes
24
27
 
25
28
  - The main change in this version is adding of limits on the number of promises which can
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ssh2-sftp-client",
3
- "version": "10.0.0",
3
+ "version": "10.0.3",
4
4
  "description": "ssh2 sftp client for node",
5
5
  "main": "src/index.js",
6
6
  "repository": {
@@ -22,6 +22,10 @@
22
22
  },
23
23
  "author": "Tim Cross",
24
24
  "email": "theophilusx@gmail.com",
25
+ "funding": {
26
+ "type": "individual",
27
+ "url": "https://square.link/u/4g7sPflL"
28
+ },
25
29
  "contributors": [
26
30
  {
27
31
  "name": "见见 (original author)",
package/src/index.js CHANGED
@@ -20,7 +20,7 @@ const { errorCode } = require('./constants');
20
20
 
21
21
  class SftpClient {
22
22
  constructor(clientName) {
23
- this.version = '10.0.0';
23
+ this.version = '10.0.3';
24
24
  this.client = new Client();
25
25
  this.sftp = undefined;
26
26
  this.clientName = clientName || 'sftp';