ssh2-sftp-client 9.0.4 → 9.1.0

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.org CHANGED
@@ -9,81 +9,21 @@ convenience abstraction as well as a Promise based API.
9
9
  Documentation on the methods and available options in the underlying modules can
10
10
  be found on the [[https://github.com/mscdex/ssh2][SSH2]] project pages.
11
11
 
12
- Current stable release is *v9.0.4*.
12
+ Current stable release is *v9.1.0.
13
13
 
14
- Code has been tested against Node versions 14.20.0, 16.17.2 and 18.8.0
14
+ Code has been tested against Node versions 14.21.3, 16.19.1, 18.16.0 and 20.0.0
15
15
 
16
16
  Node versions < 14.x are not supported.
17
17
 
18
- ** Version 9.x Changes
19
- - Fix bug in ~connect()~ method when private key data was corrupted. The method was not
20
- handling errors fro corrupted ssh private keys and would hang indefinitely without
21
- reporting any error. Now reports that it was unable to parse the private key.
22
- - Fix bug in ~end()~ method where it was possible for the module to attempt calling
23
- the underlying ssh2 ~end()~ method when ssh2 has not been initialised. This could
24
- lead to undefined reference errors.
25
- - Fix bug in ~get()~ method where supplied destination streams were not close, creating
26
- a possible resource leak. If the remote file did not exist, the method would return
27
- an error, but failed to close any passed in stream supplied as the destination for
28
- the data in the ~get()~ call.
29
- - Change the default end and close handlers not to throw error or reject
30
- promises. Previously, an end or close event would cause an error to be raised or a
31
- promise to be rejected if the event was deemed to be /unexpected/. However,
32
- classification of events as being unexpected was unreliable and didn't add much real
33
- value. Both these handlers will now invalidate the SFTP connection object and log that
34
- the event fired and nothing else.
35
- - Changed when event handled flags are reset. Now they are reset after a new set of
36
- temporary listeners are added.
37
- - Don't throw an error when calling end() if there is no active SFTP connection. It does
38
- no harm to call end() when there is no connection, so no need to raise an error.
39
- - Use nullish coalescing when setting retry parameters instead of or'ing with
40
- defaults. Allows setting values to 0.
41
- - *Breaking Change*: This version uses syntax not supported in node versions
42
- prior to v14. Therefore, node versions less than v14 will not work.
43
- - *Breaking Change*: This ~list()~ method no longer accepts a regular expression
44
- for filtering the entries to be returned. You can now specify a filter
45
- function instead. The function is called for each item in the list of items
46
- to be returned, passing in the item object as its only argument.
47
- Essentially, this is just a call to ~Array.filter()~, so the filter function
48
- should behave in the same way i.e. return true for items to be retained and
49
- false for those to be dropped.
50
- - *Breaking Change*: The ability to set ~autoClose~ on read and write streams and
51
- the ability to set ~end~ on ~pipe~ operations has been removed. These options
52
- caused confusion for users and were too easy to get wrong, plus it made the
53
- methods overly complicated. For those use-cases where you want to control
54
- streams at a low level, two new methods have been added, ~createReadStream()~ and
55
- ~createWriteStream()~. However, it should be noted that client code is 100%
56
- responsible for managing streams obtained using these methods. Use at your
57
- own risk!
58
- - *Breaking Change*: The 3rd argument to ~uploadDir()~ and ~downloadDir()~ methods
59
- has been change. Previously, the argument was a filter function used to
60
- select which directories and files to be transferred. The 3rd argument is
61
- now an options object with two supported properties, ~filter~ and ~useFastput~
62
- (for ~uploadDir()~) or ~useFastget~ (for ~downloadDir()~). If ~useFastput~ is true,
63
- the ~fastPut()~ method will be used to upload files. If ~false~ or missing, the
64
- slower, but better supported, ~put()~ method will be used. Likewise, the
65
- ~useFastget~ options can be set to ~true~ to use the ~fastGet()~ method for
66
- downloading files, otherwise the slower, but more reliable, ~get()~ method
67
- will be used.
68
- - The ~uploadDir()~ and ~downloadDir()~ methods now use asynchronous processes to
69
- upload/download files. This should result in improved performance for these
70
- two methods.
71
- - New Methods: Two new methods, ~createWriteStream()~ and ~createReadStream()~
72
- have been added. These methods will return a stream object connected to a
73
- remote file on the ~SFTP~ server. Client code is responsible for managing
74
- these stream objects. This includes adding any necessary event listeners and
75
- disposing of the objects once finished with them.
76
- - Re-factoring of Listeners: The library manages temporary listeners in order
77
- to provide a way to catch events and processes them inside a ~Promise~
78
- context. Previously, every method added its own set of temporary listeners.
79
- However, this could result in multiple sets of listeners being added,
80
- especially for methods which call other methods as part of their processing
81
- e.g. ~rmdir(),~ ~uploadDir()~ and ~dowqnloadDir()~. To avoid this, /internal only/
82
- versions of each method have been created. These internal methods use an
83
- /underscore/ ~_~ prefix. Client code should not use these methods directly.
84
- - New method: Added ~rcopy()~ method to perform a remote copy of a file on the remote SFTP server.
85
- - Bumped ssh2 version to 1.11.0
18
+ ** Version 9.1.0 Changes
86
19
 
20
+ - Added lstat() method
21
+ - Fixed bug in option hadnling which was preventing setting file mode in get() and put()
22
+ methods
23
+ - Fixed bug where a loss of network connections between establishment of the connection
24
+ and calling various sftp methods was not handled and could result in an event causing
25
+ the node process to exit with an error.
26
+
87
27
  * Installation
88
28
 
89
29
  #+begin_src shell
@@ -92,7 +32,7 @@ Node versions < 14.x are not supported.
92
32
 
93
33
  * Basic Usage
94
34
 
95
- #+begin_src javascript
35
+ #+begin_src js
96
36
  let Client = require('ssh2-sftp-client');
97
37
  let sftp = new Client();
98
38
 
@@ -250,12 +190,12 @@ for that package for an explanation of these values.
250
190
  privateKey: fs.readFileSync('/path/to/key'), // Buffer or string that contains
251
191
  passphrase: 'a pass phrase', // string - For an encrypted private key
252
192
  readyTimeout: 20000, // integer How long (in ms) to wait for the SSH handshake
253
- strictVendor: true // boolean - Performs a strict server vendor check
254
- debug: myDebug // function - Set this to a function that receives a single
193
+ strictVendor: true, // boolean - Performs a strict server vendor check
194
+ debug: myDebug,// function - Set this to a function that receives a single
255
195
  // string argument to get detailed (local) debug information.
256
- retries: 2 // integer. Number of times to retry connecting
257
- retry_factor: 2 // integer. Time factor used to calculate time between retries
258
- retry_minTimeout: 2000 // integer. Minimum timeout between attempts
196
+ retries: 2, // integer. Number of times to retry connecting
197
+ retry_factor: 2, // integer. Time factor used to calculate time between retries
198
+ retry_minTimeout: 2000, // integer. Minimum timeout between attempts
259
199
  };
260
200
 
261
201
  // rarely used options
@@ -282,7 +222,7 @@ for that package for an explanation of these values.
282
222
 
283
223
  #+begin_src javascript
284
224
  sftp.connect({
285
- host: example.com,
225
+ host: 'example.com',
286
226
  port: 22,
287
227
  username: 'donald',
288
228
  password: 'youarefired'
@@ -313,7 +253,7 @@ directory.
313
253
  password: 'my-secret'
314
254
  };
315
255
 
316
- let sftp = new Client;
256
+ let sftp = new Client();
317
257
 
318
258
  sftp.connect(config)
319
259
  .then(() => {
@@ -336,19 +276,19 @@ The objects in the array returned by ~list()~ have the following properties;
336
276
 
337
277
  #+begin_src javascript
338
278
  {
339
- type: // file type(-, d, l)
340
- name: // file name
341
- size: // file size
342
- modifyTime: // file timestamp of modified time
343
- accessTime: // file timestamp of access time
279
+ type: '-', // file type(-, d, l)
280
+ name: 'example.txt', // file name
281
+ size: 43, // file size
282
+ modifyTime: 1675645360000, // file timestamp of modified time
283
+ accessTime: 1675645360000, // file timestamp of access time
344
284
  rights: {
345
- user:
346
- group:
347
- other:
285
+ user: 'rw',
286
+ group: 'r',
287
+ other: 'r',
348
288
  },
349
- owner: // user ID
350
- group: // group ID
351
- longname: // like ls -l line
289
+ owner: 1000, // user ID
290
+ group: 1000, // group ID
291
+ longname: '-rw-r--r-- 1 fred fred 43 Feb 6 12:02 exaple.txt', // like ls -l line
352
292
  }
353
293
  #+end_src
354
294
 
@@ -369,7 +309,7 @@ if it exists or false if it does not.
369
309
  password: 'my-secret'
370
310
  };
371
311
 
372
- let sftp = new Client;
312
+ let sftp = new Client();
373
313
 
374
314
  sftp.connect(config)
375
315
  .then(() => {
@@ -1176,6 +1116,7 @@ Removes the specified listener from the event specified in eventType. Note that
1176
1116
  the ~end()~ method automatically removes all listeners from the client object.
1177
1117
 
1178
1118
  * Platform Quirks & Warnings
1119
+
1179
1120
  ** Server Capabilities
1180
1121
 
1181
1122
  All SFTP servers and platforms are not equal. Some facilities provided by
@@ -1544,6 +1485,7 @@ the =ssh2= README to set the properties in the =algorithms= object.
1544
1485
  await client.end();
1545
1486
  }
1546
1487
  #+end_src
1488
+
1547
1489
  ** Connection hangs or fails for larger files
1548
1490
 
1549
1491
  This was contributed by Ladislav Jacho. Thanks.
@@ -1557,6 +1499,13 @@ the =ssh2= README to set the properties in the =algorithms= object.
1557
1499
 
1558
1500
  For more explanation, see [[https://github.com/theophilusx/ssh2-sftp-client/issues/342][issue #342]].
1559
1501
 
1502
+ ** Typescript definition file out of date
1503
+
1504
+ This project does not use Typescript. However, typescript definition files are provided by
1505
+ other 3rd parties. Sometimes, these definition files have not stayed up-to-date with the
1506
+ current version of this module. If you encounter this issue, you need to report it to the
1507
+ party responsible for the definition file, not this project.
1508
+
1560
1509
  * Examples
1561
1510
 
1562
1511
  I have started collecting example scripts in the example directory of the
@@ -1730,7 +1679,7 @@ the ~ssh2-sftp-client~ wrapper module.
1730
1679
  await sftp.fastGet(`${d}/foo.txt`, 'bat.txt');
1731
1680
  } catch (e) {
1732
1681
  console.error(e.message);
1733
- } finally () {
1682
+ } finally {
1734
1683
  await sftp.end();
1735
1684
  }
1736
1685
  }
@@ -1836,6 +1785,7 @@ based on messages which start with 'CLIENT' e.g.
1836
1785
  }
1837
1786
  }
1838
1787
  #+end_src
1788
+
1839
1789
  * Logging Issues
1840
1790
 
1841
1791
  Please log an issue for all bugs, questions, feature and enhancement
@@ -1880,8 +1830,10 @@ your pull request what level of change it represents i.e.
1880
1830
 
1881
1831
  - Major :: Change to API or major change in functionality which will require an
1882
1832
  increase in major version number.
1833
+
1883
1834
  - Minor :: Minor change, enhancement or new feature which does not change
1884
1835
  existing API and will not break existing client code.
1836
+
1885
1837
  - Bug Fix :: No change to functionality or features. Simple fix of an existing
1886
1838
  bug.
1887
1839
 
@@ -1913,3 +1865,4 @@ Thanks to the following for their contributions -
1913
1865
  Also included test to check for this regression in future.
1914
1866
  - cakemasher :: Contributed fix for removeTempListeners().
1915
1867
 
1868
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ssh2-sftp-client",
3
- "version": "9.0.4",
3
+ "version": "9.1.0",
4
4
  "description": "ssh2 sftp client for node",
5
5
  "main": "src/index.js",
6
6
  "repository": {
@@ -40,7 +40,7 @@
40
40
  "eslint-plugin-mocha": "^10.0.3",
41
41
  "eslint-plugin-node": "^11.1.0",
42
42
  "eslint-plugin-promise": "^6.0.0",
43
- "eslint-plugin-unicorn": "^43.0.2",
43
+ "eslint-plugin-unicorn": "^46.0.0",
44
44
  "mocha": "^10.0.0",
45
45
  "moment": "^2.29.1",
46
46
  "nyc": "^15.1.0",
@@ -51,6 +51,6 @@
51
51
  "dependencies": {
52
52
  "concat-stream": "^2.0.0",
53
53
  "promise-retry": "^2.0.1",
54
- "ssh2": "^1.11.0"
54
+ "ssh2": "^1.12.0"
55
55
  }
56
56
  }