New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

basic-ftp

Package Overview
Dependencies
Maintainers
1
Versions
112
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

basic-ftp - npm Package Compare versions

Comparing version 2.9.0 to 2.9.1

test/fileInfoSpec.js

5

CHANGELOG.md
# Changelog
## 2.9.1
- Mention regression in Node.js negatively affecting upload progress reporting.
- Small fixes in documentation.
## 2.9.0

@@ -4,0 +9,0 @@

7

lib/ftp.js

@@ -108,3 +108,3 @@ "use strict";

this.ftp.tlsOptions = options; // Keep the TLS options for later data connections that should use the same options.
this.ftp.log("Control socket is using " + this.ftp.socket.getProtocol());
this.ftp.log(`Control socket is using: ${describeTLS(this.ftp.socket)}`);
return ret;

@@ -274,3 +274,4 @@ }

const writable = new StringWriter(this.ftp.encoding);
await download(this.ftp, nullObject(), writable, "LIST");
const nullTracker = nullObject(); // Don't track progress of list transfers.
await download(this.ftp, nullTracker, writable, "LIST");
this.ftp.log(writable.text);

@@ -562,2 +563,3 @@ return this.parseList(writable.text);

* @param {FTPContext} ftp
* @param {ProgressTracker} progress
* @param {stream.Readable} readableStream

@@ -599,2 +601,3 @@ * @param {string} remoteFilename

* @param {FTPContext} ftp
* @param {ProgressTracker} progress
* @param {stream.Writable} writableStream

@@ -601,0 +604,0 @@ * @param {string} command

@@ -209,6 +209,6 @@ "use strict";

if (socket) {
socket.destroy();
socket.removeAllListeners();
socket.destroy();
}
}
};
{
"name": "basic-ftp",
"version": "2.9.0",
"version": "2.9.1",
"description": "FTP client for Node.js with support for explicit FTPS over TLS.",

@@ -24,2 +24,5 @@ "main": "./lib/ftp",

],
"engines": {
"node": ">=7.6.0"
},
"devDependencies": {

@@ -26,0 +29,0 @@ "eslint": "4.18.1",

@@ -107,3 +107,3 @@ # Basic FTP

`remove(filename): Promise<Response>`
`remove(filename, ignoreErrorCodes = false): Promise<Response>`

@@ -148,21 +148,21 @@ Remove a file from the working directory.

```
```js
// Log progress for any transfer from now on.
client.trackProgress(info => {
console.log("File", info.name);
console.log("Type", info.type);
console.log("Transferred", info.bytes);
console.log("Transferred Overall", info.bytesOverall);
});
console.log("File", info.name)
console.log("Type", info.type)
console.log("Transferred", info.bytes)
console.log("Transferred Overall", info.bytesOverall)
})
// Transfer some data
await client.upload(someStream, "test.txt");
await client.upload(someOtherStream, "test2.txt");
await client.upload(someStream, "test.txt")
await client.upload(someOtherStream, "test2.txt")
// Reset overall counter
client.trackProgress(info => console.log(info.bytesOverall));
await client.downloadDir("local/path");
client.trackProgress(info => console.log(info.bytesOverall))
await client.downloadDir("local/path")
// Stop logging
client.trackProgress();
client.trackProgress()
```

@@ -174,5 +174,7 @@

**Important:** Due to a bug in Node.js since version 9.7.0, the reported number of uploaded bytes might be too low. The issue has been confirmed and [is tracked by the Node.js project](https://github.com/nodejs/node/issues/19562).
## Error Handling
Errors originating from a connection or described by a server response as well as timeouts will reject the associated Promise aka raise an exception. Use `try-catch` when using async-await or `catch()` when using Promises. The error will be described by an object literal depending on the type of error.
Errors originating from a connection or described by a server response as well as timeouts will reject the associated Promise aka raise an exception. Use `try-catch` when using async-await or `catch()` when using Promises. The error will be described by an object depending on the type of error.

@@ -183,3 +185,3 @@ ### Timeout

{
error: "Timeout"
error: "Timeout control socket"
}

@@ -186,0 +188,0 @@ ```

@@ -150,2 +150,41 @@ const assert = require("assert");

});
it("can connect", function() {
client.ftp.socket.connect = (port, host) => {
assert.equal(host, "host", "Socket host");
assert.equal(port, 22, "Socket port");
setTimeout(() => client.ftp.socket.emit("data", Buffer.from("200 OK")));
}
return client.connect("host", 22).then(result => assert.deepEqual(result, { code: 200, message: "200 OK"}));
});
it("declines connect for code 120", function() {
client.ftp.socket.connect = () => {
setTimeout(() => client.ftp.socket.emit("data", Buffer.from("120 Ready in 5 hours")));
}
return client.connect("host", 22).catch(result => assert.deepEqual(result, { code: 120, message: "120 Ready in 5 hours"}));
});
it("can login", function() {
let step = 1;
client.ftp.socket.on("didSend", buf => {
if (step === 1) {
step = 2;
assert.equal(buf.toString().trim(), "USER user");
client.ftp.socket.emit("data", Buffer.from("331 Go on"));
}
else if (step === 2) {
assert.equal(buf.toString().trim(), "PASS pass");
client.ftp.socket.emit("data", Buffer.from("200 OK"));
}
});
return client.login("user", "pass").then(result => assert.deepEqual(result, { code: 200, message: "200 OK" }));
});
it("declines login on '332 Account needed'", function() {
client.ftp.socket.once("didSend", buf => {
client.ftp.socket.emit("data", Buffer.from("332 Account needed"));
});
return client.login("user", "pass").catch(result => assert.deepEqual(result, { code: 332, message: "332 Account needed" }));
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc