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.1 to 2.9.2

5

CHANGELOG.md
# Changelog
## 2.9.2
- Improved documentation of client methods.
- Fixed: Reason for error when parsing PASV response was not reported.
## 2.9.1

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

108

lib/ftp.js

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

/**
* FTP client using an FTPContext.
* Client offers an API to interact with an FTP server.
*/

@@ -61,4 +61,4 @@ class Client {

*
* @param {string} host
* @param {number} [port=21]
* @param {string} host Host the client should connect to.
* @param {number} [port=21] Port the client should connect to.
* @return {Promise<PositiveResponse>}

@@ -80,7 +80,10 @@ */

/**
* Send an FTP command. If successful it will return a response object that contains
* the return code as well as the whole message.
* Send an FTP command.
*
* @param {string} command
* @param {boolean} ignoreErrorCodes
* If successful it will return a response object that contains the return code as well
* as the whole message. Ignore FTP error codes if you don't want an exception to be thrown
* if an FTP command didn't succeed.
*
* @param {string} command FTP command to send.
* @param {boolean} [ignoreErrorCodes=false] Whether to ignore FTP error codes in result.
* @return {Promise<PositiveResponse>}

@@ -103,7 +106,7 @@ */

*
* @param {Object} [options] TLS options as in `tls.connect(options)`
* @param {string} [command="AUTH TLS"] Set the authentication command, e.g. "AUTH SSL" instead of "AUTH TLS".
* @param {Object} [options={}] TLS options as in `tls.connect(options)`
* @param {string} [command="AUTH TLS"] Set the authentication command, e.g. "AUTH SSL" instead of "AUTH TLS".
* @return {Promise<PositiveResponse>}
*/
async useTLS(options, command = "AUTH TLS") {
async useTLS(options = {}, command = "AUTH TLS") {
const ret = await this.send(command);

@@ -119,4 +122,4 @@ this.ftp.socket = await upgradeSocket(this.ftp.socket, options);

*
* @param {string} [user="anonymous"]
* @param {string} [password="guest"]
* @param {string} [user="anonymous"] Username to use for login.
* @param {string} [password="guest"] Password to use for login.
* @returns {Promise<PositiveResponse>}

@@ -139,3 +142,8 @@ */

/**
* Set some default settings you should be setting.
* Set the usual default settings.
*
* Settings used:
* * Binary mode (TYPE I)
* * File structure (STRU F)
* * Additional settings for FTPS (PBSZ 0, PROT P)
*/

@@ -162,3 +170,3 @@ async useDefaultSettings() {

/**
* Get the working directory.
* Get the current working directory.
*

@@ -202,3 +210,3 @@ * @returns {Promise<string>}

*
* @param {string} filename
* @param {string} filename Name of the file in the current working directory.
* @returns {Promise<number>}

@@ -214,6 +222,9 @@ */

/**
* Remove a file from the working directory.
* Remove a file from the current working directory.
*
* @param {string} filename
* @param {boolean} ignoreErrorCodes
* You can ignore FTP error return codes which won't throw an exception if e.g.
* the file doesn't exist.
*
* @param {string} filename Name of the file to remove.
* @param {boolean} [ignoreErrorCodes=false] Ignore error return codes.
* @returns {Promise<PositiveResponse>}

@@ -234,7 +245,8 @@ */

/**
* Start reporting transfer progress for any upload or download. This will also reset the
* overall transfer counter that can be used for multiple transfers. Progress information
* will be reported to the given handler. You may use `undefined` to stop any reporting.
* Report transfer progress for any upload or download to a given handler.
*
* @param {((info: ProgressInfo) => void)} [handler] Handler function to call on transfer progress.
* This will also reset the overall transfer counter that can be used for multiple transfers. You can
* also pass `undefined` as a handler to stop reporting to an earlier one.
*
* @param {((info: ProgressInfo) => void)} [handler=undefined] Handler function to call on transfer progress.
*/

@@ -247,7 +259,6 @@ trackProgress(handler) {

/**
* Upload data from a readable stream and store it as a file with
* a given filename in the current working directory.
* Upload data from a readable stream and store it as a file with a given filename in the current working directory.
*
* @param {stream.Readable} readableStream
* @param {string} remoteFilename
* @param {stream.Readable} readableStream The stream to read from.
* @param {string} remoteFilename The filename of the remote file to write to.
* @returns {Promise<PositiveResponse>}

@@ -265,5 +276,5 @@ */

*
* @param {stream.Writable} writableStream
* @param {string} remoteFilename
* @param {number} [startAt=0]
* @param {stream.Writable} writableStream The stream to write to.
* @param {string} remoteFilename The name of the remote file to read from.
* @param {number} [startAt=0] The offset to start at.
* @returns {Promise<PositiveResponse>}

@@ -285,4 +296,4 @@ */

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

@@ -295,3 +306,10 @@ return this.parseList(writable.text);

*
* @param {string} remoteDirPath
* After successfull completion the current working directory will be the parent
* of the removed directory if possible.
*
* @param {string} remoteDirPath The path of the remote directory to delete.
* @example client.removeDir("foo") // Remove directory 'foo' using a relative path.
* @example client.removeDir("foo/bar") // Remove directory 'bar' using a relative path.
* @example client.removeDir("/foo/bar") // Remove directory 'bar' using an absolute path.
* @example client.removeDir("/") // Remove everything.
* @returns {Promise<void>}

@@ -331,7 +349,8 @@ */

/**
* Upload the contents of a local directory to the working directory. You can optionally
* provide a `remoteDirName` to put the contents inside a directory which will be created
* if necessary. This will overwrite existing files with the same names and reuse existing
* directories. Unrelated files and directories will remain untouched.
* Upload the contents of a local directory to the working directory.
*
* You can optionally provide a `remoteDirName` to put the contents inside a directory which
* will be created if necessary. This will overwrite existing files with the same names and
* reuse existing directories. Unrelated files and directories will remain untouched.
*
* @param {string} localDirPath A local path, e.g. "foo/bar" or "../test"

@@ -358,3 +377,3 @@ * @param {string} [remoteDirName] The name of the remote directory. If undefined, directory contents will be uploaded to the working directory.

*
* @param {string} localDirPath
* @param {string} localDirPath The local directory to download to.
*/

@@ -396,11 +415,8 @@ async downloadDir(localDirPath) {

/**
* Resolves a given task if one party has provided a result and another
* one confirmed it. This is used for all FTP transfers. For example when
* downloading, the server might confirm with "226 Transfer complete" when
* in fact the download on the data connection has not finished yet. With
* all transfers we make sure that a) the result arrived and b) has been
* confirmed by e.g. the control connection. We just don't know in which
* order this will happen.
* Resolves a given task if one party has provided a result and another one confirmed it.
*
* This is used internally by the list, upload and download functions.
* This is used internally for all FTP transfers. For example when downloading, the server might confirm
* with "226 Transfer complete" when in fact the download on the data connection has not finished
* yet. With all transfers we make sure that a) the result arrived and b) has been confirmed by
* e.g. the control connection. We just don't know in which order this will happen.
*/

@@ -516,3 +532,3 @@ class TransferResolver {

if (!target) {
task.reject("Can't parse PASV response", res.message);
task.reject("Can't parse PASV response: " + res.message);
return;

@@ -519,0 +535,0 @@ }

{
"name": "basic-ftp",
"version": "2.9.1",
"version": "2.9.2",
"description": "FTP client for Node.js with support for explicit FTPS over TLS.",

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

@@ -9,5 +9,5 @@ # Basic FTP

Provide a foundation that covers the usual needs.
Provide a foundation that covers the basic needs.
FTP is an old protocol, there are many features, quirks and server implementations. It's not a goal to support all of them. Instead, the library should focus on being easy to read, tinker with and extend.
FTP is an old legacy protocol. There are many features, quirks and server implementations. It's not a goal to support all of them. Instead, the library should focus on ways to let users add custom functionality.

@@ -20,3 +20,3 @@ ## Dependencies

`Client` provides an API to interact with an FTP server. The following example shows how to connect, upgrade to TLS, login, get a directory listing and upload a file. Be aware that the FTP protocol doesn't allow multiple requests in parallel.
`Client` provides an API to interact with an FTP server. The following example shows how to connect, upgrade to TLS, login, get a directory listing and upload a file. **Be aware that the FTP protocol doesn't allow multiple requests in parallel.**

@@ -23,0 +23,0 @@ ```js

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