0.0.9 • Published 2 years ago

filezilla-js v0.0.9

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

FileZillaJS - Interface for reading sitemanager.xml into js objects

Examples

Instantiating siteManager

The SiteManager class can be instantiated in two different ways.

Either using the default XML file (found using your current environment variables):

import {getDefaultSiteManager} from "filezilla-js";

const siteManager = getDefaultSiteManager();

Or by using a specific sitemanager.xml path by using getSiteManager instead of getDefaultSiteManager:

import {getSiteManager} from "filezilla-js";

// Point at the custom sitemanager.xml file
const siteManager = getSiteManager(path.join(__dirname, 'fixtures/sitemanager.xml'));

Fetching servers

Getting a single server by root path

Use siteManager.getServerByPath(path) to get a single Server object or NULL if it wasn't found:

import {getDefaultSiteManager} from "filezilla-js";

const siteManager = getDefaultSiteManager();

// Get server by path "SFTP (root location)" (a server with that name, in the root of the sitemanager.xml)
const server = siteManager.getServerByPath(`SFTP (root location)`);

if (!server) {
    console.error(`Error: Could not find server by path ${serverPath}`);
} else {
    console.log(`${serverPath} (host: ${server.properties.host}:${server.properties.port})`);
}

Getting a single server by sub paths

Use siteManager.getServerByPath(path) to get a single Server object or NULL if it wasn't found:

import {getDefaultSiteManager} from "filezilla-js";

const siteManager = getDefaultSiteManager();

// Get server by path "Rebex/SFTP" (a server with that the name "SFTP" in the "Rebex" folder)
const server = siteManager.getServerByPath(`Rebex/SFTP`);

if (!server) {
    console.error(`Error: Could not find server by path ${serverPath}`);
} else {
    console.log(`${serverPath} (host: ${server.properties.host}:${server.properties.port})`);
}

Getting all servers in an array

Use siteManager.getServers() to get a list of Server objects:

import {getDefaultSiteManager} from "filezilla-js";

const siteManager = getDefaultSiteManager();

const servers = siteManager.getServers();

for (let server of servers) {
    console.log(`${server.path} (host: ${server.properties.host}:${server.properties.port})`);
}

Classes

Server

The main object returned from siteManager.getServer is a Server. It has the following properties: path: string;

Properties

PropertyProperty typeDescription
pathstringThe path of the server (eg. Rebex/SFTP)
propertiesServerPropertiesThe raw properties of the FileZilla server (see below)

Methods

Server.getRemoteDirectory(defaultRemoteDirectory:string = ''):

Gets a human readable path (instead of the raw FileZilla path).

Example:

<RemoteDir>1 0 3 pub 7 example</RemoteDir>
           ^ ^ ^ ^   ^ ^
           | | | |   | |
           | | | |   | \-- The name of the sub folder
           | | | |   \-- The length of the sub folder ("example".length)
           | | | \-- The name of the main folder
           | | \-- The length of the main folder ("pub".length)
           | \-- The length of the prefix
           \-- The ServerType (see the definition)

In the instance above, the output of Server.getRemoteDirectory() would be /pub/example

Definitions

ServerProperties

PropertyProperty typeDescription
hoststringThe server host
portnumberThe server port
protocolServerProtocolThe server protocol (ServerProtocol)
typeServerTypeThe server type (ServerType)
userstringThe server username
passwordstringThe server password
keyFilestringThe path to the server key file
logonTypeLogonTypeThe server logon type (LogonType)
timezoneOffsetnumberThe timezone offset
passiveModePasvModeThe passive mode for this server (PassiveMode - only relevant for FTP servers)
maximumMultipleConnectionsnumberThe maximum concurrent connections to the server - 0 means no limit
encodingTypeCharsetEncodingThe server encoding type (CharsetEncoding)
bypassProxybooleanWhether or not to bypass the proxy
namestringThe server name in FileZilla
commentsstringThe server comments
localDirectorystringThe initial local directory
remoteDirectorystringThe initial remote directory (raw)
synchronizedBrowsingbooleanWhether or not to use synchronized browsing
directoryComparisonbooleanWhether or not to use directory comparison

Enums

Note: A lot of these enums can be found in the Filezilla sourcecode's server.h file

CharsetEncoding

EnumValueDescription
ENCODING_AUTO0
ENCODING_UTF81
ENCODING_CUSTOM2

LogonType

EnumValueDescription
ANONYMOUS0
NORMAL1
ASK2ask should not be sent to the engine, it's intended to be used by the interface
INTERACTIVE3
ACCOUNT4
KEY5
PROFILE6
COUNT7

PasvMode

EnumValueDescription
MODE_DEFAULTMODE_DEFAULT
MODE_ACTIVEMODE_ACTIVE
MODE_PASSIVEMODE_PASSIVE

ServerFormat

EnumValueDescription
HOST_ONLY0
WITH_OPTIONAL_PORT1
WITH_USER_AND_OPTIONAL_PORT2
URL3
URL_WITH_PASSWORD4

ServerProtocol

EnumValueDescription
UNKNOWN-1
FTP0FTP, attempts AUTH TLS
SFTP1
HTTP2
FTPS3Implicit SSL
FTPES4Explicit SSL
HTTPS5
INSECURE_FTP6Insecure, as the name suggests
S37Amazon S3 or compatible
STORJ8
WEBDAV9
AZURE_FILE10
AZURE_BLOB11
SWIFT12
GOOGLE_CLOUD13
GOOGLE_DRIVE14
DROPBOX15
ONEDRIVE16
B217
BOX18
INSECURE_WEBDAV19
RACKSPACE20
STORJ_GRANT21

ServerType

EnumValueDescription
DEFAULT0
UNIX1
VMS2
DOS3Backslashes as preferred separator
MVS4
VXWORKS5
ZVM6
HPNONSTOP7
DOS_VIRTUAL8
CYGWIN9
DOS_FWD_SLASHES10Forwardslashes as preferred separator
SERVERTYPE_MAX11
0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago