{"_id":"@alancnet/ftp-srv","_rev":"1-39e4722e101d2cc77b3d4a793027cbf7","name":"@alancnet/ftp-srv","dist-tags":{"latest":"0.0.0-development"},"versions":{"0.0.0-development":{"name":"@alancnet/ftp-srv","version":"0.0.0-development","description":"Modern, extensible FTP Server","keywords":["ftp","ftp-server","ftp-srv","ftp-svr","ftpd","ftpserver","server"],"license":"MIT","files":["src","bin","ftp-srv.d.ts"],"main":"ftp-srv.js","bin":{"ftp-srv":"./bin/index.js"},"types":"./ftp-srv.d.ts","repository":{"type":"git","url":"git+https://github.com/trs/ftp-srv.git"},"scripts":{"pre-release":"npm run verify","commitmsg":"cz-customizable-ghooks","dev":"cross-env NODE_ENV=development npm run verify:watch","prepush":"npm-run-all verify test:unit:once --silent","semantic-release":"semantic-release","start":"npm run dev","test":"npm run test:unit","test:unit":"cross-env NODE_ENV=test mocha --opts config/testUnit/mocha.opts -w","test:unit:once":"cross-env NODE_ENV=test mocha --opts config/testUnit/mocha.opts","verify":"npm run verify:js --silent","verify:js":"eslint -c config/verify/.eslintrc \"src/**/*.js\" \"test/**/*.js\" \"config/**/*.js\" && echo ✅ verify:js success","verify:js:fix":"eslint --fix -c config/verify/.eslintrc \"src/**/*.js\" \"test/**/*.js\" \"config/**/*.js\" && echo ✅ verify:js:fix success","verify:js:watch":"chokidar 'src/**/*.js' 'test/**/*.js' 'config/**/*.js' -c 'npm run verify:js:fix' --initial --silent","verify:watch":"npm run verify:js:watch --silent"},"release":{"verifyConditions":"condition-circle"},"config":{"commitizen":{"path":"node_modules/cz-customizable"},"cz-customizable":{"config":"config/release/commitMessageConfig.js"}},"dependencies":{"bluebird":"^3.5.1","bunyan":"^1.8.12","ip":"^1.1.5","lodash":"^4.17.10","moment":"^2.22.1","uuid":"^3.2.1","yargs":"^11.0.0"},"devDependencies":{"@icetee/ftp":"^1.0.2","chai":"^4.0.2","chokidar-cli":"1.2.0","condition-circle":"^1.6.0","cross-env":"3.1.4","cz-customizable":"5.2.0","cz-customizable-ghooks":"1.5.0","dotenv":"^4.0.0","eslint":"4.5.0","eslint-config-google":"0.8.0","eslint-friendly-formatter":"3.0.0","eslint-plugin-mocha":"^4.11.0","eslint-plugin-node":"5.1.1","husky":"0.13.3","istanbul":"0.4.5","mocha":"3.5.0","mocha-junit-reporter":"1.13.0","mocha-multi-reporters":"1.1.5","npm-run-all":"^4.1.3","rimraf":"2.6.1","semantic-release":"^11.0.2","sinon":"^2.3.5"},"engines":{"node":">=6.x","npm":">=5.x"},"gitHead":"73b45b4ce1d178d3be4cc9f9bdb5cb8fadb562c1","bugs":{"url":"https://github.com/trs/ftp-srv/issues"},"homepage":"https://github.com/trs/ftp-srv#readme","_id":"@alancnet/ftp-srv@0.0.0-development","_npmVersion":"6.0.1","_nodeVersion":"9.7.1","_npmUser":{"name":"alancnet","email":"npm@alanc.net"},"dist":{"integrity":"sha512-Tn2Q6vo2LTs4fNeH1o+9bRiHBgBiXP3hNXFmge9S77V2nOf2s/UCr0fgvc68xzyPlmWhQ3WtXtF91YA2mdZ13A==","shasum":"a4541b02bb2a79d49bdd6515323dbd8bd20a5a00","tarball":"https://registry.npmjs.org/@alancnet/ftp-srv/-/ftp-srv-0.0.0-development.tgz","fileCount":61,"unpackedSize":76802,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbGdZ1CRA9TVsSAnZWagAAuvcP/2F681SJFptXvZ4UblB3\nY+1+7H3kOtq0+zRf/7kPMiblG3o7dpaplSGWRu396QYGBxmlzsf35ic0hNlr\nsV76k8bMaH59rYIPzWSo5+1Eywkcwm904UyDgmoPxcaDLZWTOmEDHexIk0Rj\ntbHy98DDB4DNafEGvg9u+dL23sn8wuXAwgrEOOal94K/OpnkB2Lf8aIACi/F\nQuHcEjAqyG/HHIRAMlXt2xPytNaybilHSQykb7S2Hq7aXoLQ1rgFlYpC3A7t\nCInWhsE7yFah4ePM7jb4A+aS1BulY64tMQ8WXg7rYjQ65xz2ox2skJnUTt08\nNcacddU4qJPBmNk3F0up+Kxj0IJ96IEFiTX8T2HmS7DxUOongAMZ5HLW7AH2\nhx/tWsHxTi3tczqnEBIDVXtIC3KbUWqM/8/QhpO+/6jkWiuy36HQOMZbwRfE\nb/EEWGq+3tTmFeK2LEyzkwV0XQELtRqYhUUJjut2n9PNe/c5ZeayLdKYvOU8\nLyePUSMi0SOw4yT5vgogFo9irk/4hIeyJ1dPeVyUE445MKD5iXB/AYE3GhkL\ny759lujD0U8VCukWsL6RsZMRKv74Bh+ylYjtdxhHz+/OOV8mWI4tVnGtdNUF\nov8fomkpyftTEMV9iu163dKVrvx+318VjI2Mttht8wtHPMVMPCrg98etAL0n\n4vJ9\r\n=l5r0\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDJVuqBBbrje2+PVVD6TUi/TDVByoq9F3PONJLAmSQERQIhAI3R9MCSZWipiXbvkNBVsdFt3ppQNsrftyFYViQGrq91"}]},"maintainers":[{"name":"alancnet","email":"npm@alanc.net"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ftp-srv_0.0.0-development_1528419954334_0.27958015590652274"},"_hasShrinkwrap":false}},"time":{"created":"2018-06-08T01:05:54.016Z","0.0.0-development":"2018-06-08T01:05:55.943Z","modified":"2022-04-04T12:32:59.320Z"},"maintainers":[{"name":"alancnet","email":"npm@alanc.net"}],"description":"Modern, extensible FTP Server","homepage":"https://github.com/trs/ftp-srv#readme","keywords":["ftp","ftp-server","ftp-srv","ftp-svr","ftpd","ftpserver","server"],"repository":{"type":"git","url":"git+https://github.com/trs/ftp-srv.git"},"bugs":{"url":"https://github.com/trs/ftp-srv/issues"},"license":"MIT","readme":"<p align=\"center\">\n  <a href=\"https://github.com/trs/ftp-srv\">\n    <img alt=\"ftp-srv\" src=\"logo.png\" width=\"600px\"  />\n  </a>\n</p>\n\n\n<p align=\"center\">\n  Modern, extensible FTP Server\n</p>\n\n<p align=\"center\">\n  <a href=\"https://www.npmjs.com/package/ftp-srv\">\n    <img alt=\"npm\" src=\"https://img.shields.io/npm/dm/ftp-srv.svg?style=for-the-badge\" />\n  </a>\n\n  <a href=\"https://circleci.com/gh/trs/workflows/ftp-srv/tree/master\">\n    <img alt=\"circleci\" src=\"https://img.shields.io/circleci/project/github/trs/ftp-srv/master.svg?style=for-the-badge\" />\n  </a>\n</p>\n\n---\n\n- [Overview](#overview)\n- [Features](#features)\n- [Install](#install)\n- [Usage](#usage)\n  - [API](#api)\n  - [CLI](#cli)\n  - [Events](#events)\n  - [Supported Commands](#supported-commands)\n  - [File System](#file-system)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Overview\n`ftp-srv` is a modern and extensible FTP server designed to be simple yet configurable.\n\n## Features\n- Extensible [file systems](#file-system) per connection\n- Passive and active transfers\n- [Explicit](https://en.wikipedia.org/wiki/FTPS#Explicit) & [Implicit](https://en.wikipedia.org/wiki/FTPS#Implicit) TLS connections\n- Promise based API\n\n## Install\n`npm install ftp-srv --save`\n\n## Usage\n\n```js\n// Quick start\n\nconst FtpSrv = require('ftp-srv');\nconst ftpServer = new FtpSrv('ftp://0.0.0.0:9876', { options ... });\n\nftpServer.on('login', (data, resolve, reject) => { ... });\n...\n\nftpServer.listen()\n.then(() => { ... });\n```\n\n## API\n\n### `new FtpSrv(url, [{options}])`\n#### url\n[URL string](https://nodejs.org/api/url.html#url_url_strings_and_url_objects) indicating the protocol, hostname, and port to listen on for connections.\nSupported protocols:\n- `ftp` Plain FTP\n- `ftps` Implicit FTP over TLS\n\n_Note:_ The hostname must be the external IP address to accept external connections. `0.0.0.0` will listen on any available hosts for server and passive connections.  \n__Default:__ `\"ftp://127.0.0.1:21\"`\n\n#### options\n\n##### `pasv_url`\nThe hostname to provide a client when attempting a passive connection (`PASV`). This defaults to the provided `url` hostname.\n\n_Note:_ If set to `0.0.0.0`, this will automatically resolve to the external IP of the box.  \n__Default:__ `\"127.0.0.1\"`\n\n##### `pasv_range`\nA starting port (eg `8000`) or a range (eg `\"8000-9000\"`) to accept passive connections.  \nThis range is then queried for an available port to use when required.  \n__Default:__ `22`\n\n##### `greeting`\nA human readable array of lines or string to send when a client connects.  \n__Default:__ `null`\n\n##### `tls`\nNode [TLS secure context object](https://nodejs.org/api/tls.html#tls_tls_createsecurecontext_options) used for implicit (`ftps` protocol) or explicit (`AUTH TLS`) connections.  \n__Default:__ `false`\n\n##### `anonymous`\nIf true, will allow clients to authenticate using the username `anonymous`, not requiring a password from the user.  \nCan also set as a string which allows users to authenticate using the username provided.  \nThe `login` event is then sent with the provided username and `@anonymous` as the password.  \n__Default:__ `false`\n\n##### `blacklist`\nArray of commands that are not allowed.  \nResponse code `502` is sent to clients sending one of these commands.  \n__Example:__ `['RMD', 'RNFR', 'RNTO']` will not allow users to delete directories or rename any files.  \n__Default:__ `[]`\n\n##### `whitelist`\nArray of commands that are only allowed.  \nResponse code `502` is sent to clients sending any other command.  \n__Default:__ `[]`\n\n##### `file_format`\nSets the format to use for file stat queries such as `LIST`.  \n__Default:__ `\"ls\"`  \n__Allowable values:__\n  - `ls` [bin/ls format](https://cr.yp.to/ftp/list/binls.html)\n  - `ep` [Easily Parsed LIST format](https://cr.yp.to/ftp/list/eplf.html)\n  - `function () {}` A custom function returning a format or promise for one.\n    - Only one argument is passed in: a node [file stat](https://nodejs.org/api/fs.html#fs_class_fs_stats) object with additional file `name` parameter\n\n##### `log`\nA [bunyan logger](https://github.com/trentm/node-bunyan) instance. Created by default.\n\n## CLI\n\n`ftp-srv` also comes with a builtin CLI.\n\n```bash\n$ ftp-srv [url] [options]\n```\n\n```bash\n$ ftp-srv ftp://0.0.0.0:9876 --root ~/Documents\n```\n\n#### `url`\n\nSet the listening URL.\n\nDefaults to `ftp://127.0.0.1:21`\n\n#### `--root` / `-r`\n\nSet the default root directory for users.\n\nDefaults to the current directory.\n\n#### `--credentials` / `-c`\n\nSet the path to a json credentials file.\n\nFormat:\n\n```js\n[\n  {\n    \"username\": \"...\",\n    \"password\": \"...\",\n    \"root\": \"...\" // Root directory\n  },\n  ...\n]\n```\n\n#### `--username`\n\nSet the username for the only user. Do not provide an argument to allow anonymous login.\n\n#### `--password`\n\nSet the password for the given `username`.\n\n## Events\n\nThe `FtpSrv` class extends the [node net.Server](https://nodejs.org/api/net.html#net_class_net_server). Some custom events can be resolved or rejected, such as `login`.\n\n### `login`\n```js\nftpServer.on('login', ({connection, username, password}, resolve, reject) => { ... });\n```\n\nOccurs when a client is attempting to login. Here you can resolve the login request by username and password.\n\n`connection` [client class object](src/connection.js)  \n`username` string of username from `USER` command  \n`password` string of password from `PASS` command  \n`resolve` takes an object of arguments:  \n- `fs`\n  - Set a custom file system class for this connection to use.\n  - See [File System](#file-system) for implementation details.\n- `root`\n  - If `fs` is not provided, this will set the root directory for the connection.\n  - The user cannot traverse lower than this directory.\n- `cwd`\n  - If `fs` is not provided, will set the starting directory for the connection\n  - This is relative to the `root` directory.\n- `blacklist`\n  - Commands that are forbidden for only this connection\n- `whitelist`\n  - If set, this connection will only be able to use the provided commands\n\n`reject` takes an error object\n\n### `client-error`\n```js\nftpServer.on('client-error', ({connection, context, error}) => { ... });\n```\n\nOccurs when an error arises in the client connection.\n\n`connection` [client class object](src/connection.js)  \n`context` string of where the error occurred  \n`error` error object\n\n### `RETR`\n```js\nconnection.on('RETR', (error, filePath) => { ... });\n```\n\nOccurs when a file is downloaded.\n\n`error` if successful, will be `null`  \n`filePath` location to which file was downloaded\n\n### `STOR`\n```js\nconnection.on('STOR', (error, fileName) => { ... });\n```\n\nOccurs when a file is uploaded.\n\n`error` if successful, will be `null`  \n`fileName` name of the file that was uploaded\n\n## Supported Commands\n\nSee the [command registry](src/commands/registration) for a list of all implemented FTP commands.\n\n## File System\nThe default [file system](src/fs.js) can be overwritten to use your own implementation.  \nThis can allow for virtual file systems, and more.  \nEach connection can set it's own file system based on the user.  \n\nThe default file system is exported and can be extended as needed:  \n```js\nconst {FtpSrv, FileSystem} = require('ftp-srv');\n\nclass MyFileSystem extends FileSystem {\n  constructor() {\n    super(...arguments);\n  }\n\n  get(fileName) {\n    ...\n  }\n}\n```\n\nCustom file systems can implement the following variables depending on the developers needs:\n\n### Methods\n#### [`currentDirectory()`](src/fs.js#L29)\nReturns a string of the current working directory  \n__Used in:__ `PWD`\n\n#### [`get(fileName)`](src/fs.js#L33)\nReturns a file stat object of file or directory  \n__Used in:__ `LIST`, `NLST`, `STAT`, `SIZE`, `RNFR`, `MDTM`\n\n#### [`list(path)`](src/fs.js#L39)\nReturns array of file and directory stat objects  \n__Used in:__ `LIST`, `NLST`, `STAT`\n\n#### [`chdir(path)`](src/fs.js#L56)\nReturns new directory relative to current directory  \n__Used in:__ `CWD`, `CDUP`\n\n#### [`mkdir(path)`](src/fs.js#L96)\nReturns a path to a newly created directory  \n__Used in:__ `MKD`\n\n#### [`write(fileName, {append, start})`](src/fs.js#L68)\nReturns a writable stream  \nOptions:  \n `append` if true, append to existing file  \n `start` if set, specifies the byte offset to write to  \n__Used in:__ `STOR`, `APPE`\n\n#### [`read(fileName, {start})`](src/fs.js#L75)\nReturns a readable stream  \nOptions:  \n `start` if set, specifies the byte offset to read from  \n__Used in:__ `RETR`\n\n#### [`delete(path)`](src/fs.js#L87)\nDelete a file or directory  \n__Used in:__ `DELE`\n\n#### [`rename(from, to)`](src/fs.js#L102)\nRenames a file or directory  \n__Used in:__ `RNFR`, `RNTO`\n\n#### [`chmod(path)`](src/fs.js#L108)\nModifies a file or directory's permissions  \n__Used in:__ `SITE CHMOD`\n\n#### [`getUniqueName()`](src/fs.js#L113)\nReturns a unique file name to write to  \n__Used in:__ `STOU`\n\n<!--[RM_CONTRIBUTING]-->\n## Contributing\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md).\n\n<!--[]-->\n\n## Contributors\n\n- [OzairP](https://github.com/OzairP)\n- [qchar](https://github.com/qchar)\n- [jorinvo](https://github.com/jorinvo)\n- [voxsoftware](https://github.com/voxsoftware)\n- [pkeuter](https://github.com/pkeuter)\n- [TimLuq](https://github.com/TimLuq)\n- [edin-mg](https://github.com/edin-m)\n- [DiegoRBaquero](https://github.com/DiegoRBaquero)\n\n<!--[RM_LICENSE]-->\n## License\n\nThis software is licensed under the MIT Licence. See [LICENSE](LICENSE).\n\n<!--[]-->\n\n## References\n\n- [https://cr.yp.to/ftp.html](https://cr.yp.to/ftp.html)\n","readmeFilename":"README.md"}