{"_id":"@amirniaki/ftp-srv","name":"@amirniaki/ftp-srv","dist-tags":{"latest":"0.0.7"},"versions":{"0.0.7":{"name":"@amirniaki/ftp-srv","version":"0.0.7","description":"Modern, extensible FTP Server","keywords":["ftp","ftp-server","ftp-srv","ftp-svr","ftpd","ftpserver","server"],"license":"MIT","main":"ftp-srv.js","bin":{"ftp-srv":"bin/index.js"},"types":"./ftp-srv.d.ts","repository":{"type":"git","url":"git+https://github.com/AmirSoleimani/ftp-srv.git"},"scripts":{"pre-release":"npm run verify","semantic-release":"semantic-release","test":"mocha test/**/*.spec.js test/*.spec.js --ui bdd","verify":"eslint src/**/*.js test/**/*.js bin/**/*.js"},"release":{"verifyConditions":"condition-circle"},"husky":{"hooks":{"pre-commit":"lint-staged","commit-msg":"commitlint -E HUSKY_GIT_PARAMS"}},"lint-staged":{"*.js":["eslint --fix","git add"]},"commitlint":{"extends":["@commitlint/config-conventional"]},"eslintConfig":{"extends":"eslint:recommended","env":{"node":true,"mocha":true,"es6":true},"parserOptions":{"ecmaVersion":6,"sourceType":"module"}},"dependencies":{"bluebird":"^3.5.1","bunyan":"^1.8.12","ip":"^1.1.5","lodash":"^4.17.15","moment":"^2.22.1","uuid":"^3.2.1","yargs":"^11.0.0"},"devDependencies":{"@commitlint/cli":"^8.1.0","@commitlint/config-conventional":"^8.1.0","@icetee/ftp":"^1.0.2","chai":"^4.2.0","condition-circle":"^2.0.2","eslint":"^5.14.1","husky":"^1.3.1","lint-staged":"^8.1.4","mocha":"^5.2.0","rimraf":"^2.6.1","semantic-release":"^15.13.24","sinon":"^2.3.5"},"engines":{"node":">=6.x"},"bugs":{"url":"https://github.com/AmirSoleimani/ftp-srv/issues"},"homepage":"https://github.com/AmirSoleimani/ftp-srv#readme","directories":{"test":"test"},"author":"","_id":"@amirniaki/ftp-srv@0.0.7","gitHead":"5a1cc1b2e5280cd6b767817363476f82137393db","_nodeVersion":"20.12.2","_npmVersion":"10.5.0","dist":{"integrity":"sha512-DakkneO95rXzFaLMXvtGHZXrC2HOPkiCQw+Y8lqp0BSKbpVy4cogVj2iSmgD5SNRXG3NdueMIbo4jwatBlXHDg==","shasum":"1d569c3cf8b075ad764215854c8f125ae28e3e84","tarball":"https://registry.npmjs.org/@amirniaki/ftp-srv/-/ftp-srv-0.0.7.tgz","fileCount":62,"unpackedSize":85284,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIG8tsNH+YyvHpFzdFJp/wVRTTT6rYiYg0cj83fIYbiIGAiAmhN3mxRmkB7CIVhMvVP/Cd6KCm8u5Scbf0En6WgS4lQ=="}]},"_npmUser":{"name":"amirniaki","email":"amir.so@icloud.com"},"maintainers":[{"name":"amirniaki","email":"amir.so@icloud.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ftp-srv_0.0.7_1717279433543_0.21782005207605692"},"_hasShrinkwrap":false}},"time":{"created":"2024-06-01T22:03:53.462Z","0.0.7":"2024-06-01T22:03:53.744Z","modified":"2024-06-01T22:03:54.009Z"},"maintainers":[{"name":"amirniaki","email":"amir.so@icloud.com"}],"description":"Modern, extensible FTP Server","homepage":"https://github.com/AmirSoleimani/ftp-srv#readme","keywords":["ftp","ftp-server","ftp-srv","ftp-svr","ftpd","ftpserver","server"],"repository":{"type":"git","url":"git+https://github.com/AmirSoleimani/ftp-srv.git"},"bugs":{"url":"https://github.com/AmirSoleimani/ftp-srv/issues"},"license":"MIT","readme":"<p align=\"center\">\n  <a href=\"https://github.com/autovance/ftp-srv\">\n    <img alt=\"ftp-srv\" src=\"logo.png\" width=\"600px\"  />\n  </a>\n</p>\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/autovance/workflows/ftp-srv/tree/master\">\n    <img alt=\"circleci\" src=\"https://img.shields.io/circleci/project/github/autovance/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\n`ftp-srv` is a modern and extensible FTP server designed to be simple yet configurable.\n\n## Features\n\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\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({ options ... });\n\nftpServer.on('login', (data, resolve, reject) => { ... });\n...\n\nftpServer.listen()\n.then(() => { ... });\n```\n\n## API\n\n### `new FtpSrv({options})`\n\n#### url\n\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\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#### `pasv_url`\n\nThe hostname to provide a client when attempting a passive connection (`PASV`).  \nIf not provided, clients can only connect using an `Active` connection.\n\n#### `pasv_min`\n\nTne starting port to accept passive connections.  \n**Default:** `1024`\n\n#### `pasv_max`\n\nThe ending port to accept passive connections.  \nThe range is then queried for an available port to use when required.  \n**Default:** `65535`\n\n#### `greeting`\n\nA human readable array of lines or string to send when a client connects.  \n**Default:** `null`\n\n#### `tls`\n\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`\n\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`\n\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`\n\nArray of commands that are only allowed.  \nResponse code `502` is sent to clients sending any other command.  \n**Default:** `[]`\n\n#### `file_format`\n\nSets the format to use for file stat queries such as `LIST`.  \n**Default:** `\"ls\"`  \n**Allowable values:**\n\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`\n\nA [bunyan logger](https://github.com/trentm/node-bunyan) instance. Created by default.\n\n#### `timeout`\n\nSets the timeout (in ms) after that an idle connection is closed by the server  \n**Default:** `0`\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#### `--pasv_url`\n\nThe hostname to provide a client when attempting a passive connection (`PASV`).  \nIf not provided, clients can only connect using an `Active` connection.\n\n#### `--pasv_min`\n\nThe starting port to accept passive connections.  \n**Default:** `1024`\n\n#### `--pasv_max`\n\nThe ending port to accept passive connections.  \nThe range is then queried for an available port to use when required.  \n**Default:** `65535`\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#### `--read-only`\n\nDisable write actions such as upload, delete, etc.\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\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\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\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\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\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### `RNTO`\n\n```js\nconnection.on('RNTO', (error, fileName) => { ... });\n```\n\nOccurs when a file is renamed.\n\n`error` if successful, will be `null`  \n`fileName` name of the file that was renamed\n\n## Supported Commands\n\nSee the [command registry](src/commands/registration) for a list of all implemented FTP commands.\n\n## File System\n\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\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\n#### [`currentDirectory()`](src/fs.js#L40)\n\nReturns a string of the current working directory  \n**Used in:** `PWD`\n\n#### [`get(fileName)`](src/fs.js#L44)\n\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#L50)\n\nReturns array of file and directory stat objects  \n**Used in:** `LIST`, `NLST`, `STAT`\n\n#### [`chdir(path)`](src/fs.js#L67)\n\nReturns new directory relative to current directory  \n**Used in:** `CWD`, `CDUP`\n\n#### [`mkdir(path)`](src/fs.js#L114)\n\nReturns a path to a newly created directory  \n**Used in:** `MKD`\n\n#### [`write(fileName, {append, start})`](src/fs.js#L79)\n\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#L90)\n\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#L105)\n\nDelete a file or directory  \n**Used in:** `DELE`\n\n#### [`rename(from, to)`](src/fs.js#L120)\n\nRenames a file or directory  \n**Used in:** `RNFR`, `RNTO`\n\n#### [`chmod(path)`](src/fs.js#L126)\n\nModifies a file or directory's permissions  \n**Used in:** `SITE CHMOD`\n\n#### [`getUniqueName()`](src/fs.js#L131)\n\nReturns a unique file name to write to  \n**Used in:** `STOU`\n\n## Contributing\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md).\n\n## Contributors\n\n- [OzairP](https://github.com/OzairP)\n- [TimLuq](https://github.com/TimLuq)\n- [crabl](https://github.com/crabl)\n- [hirviid](https://github.com/hirviid)\n- [DiegoRBaquero](https://github.com/DiegoRBaquero)\n- [edin-m](https://github.com/edin-m)\n- [voxsoftware](https://github.com/voxsoftware)\n- [jorinvo](https://github.com/jorinvo)\n- [Johnnyrook777](https://github.com/Johnnyrook777)\n- [qchar](https://github.com/qchar)\n- [mikejestes](https://github.com/mikejestes)\n- [pkeuter](https://github.com/pkeuter)\n- [qiansc](https://github.com/qiansc)\n- [broofa](https://github.com/broofa)\n- [lafin](https://github.com/lafin)\n- [alancnet](https://github.com/alancnet)\n- [zgwit](https://github.com/zgwit)\n\n## License\n\nThis software is licensed under the MIT Licence. See [LICENSE](LICENSE).\n\n## References\n\n- [https://cr.yp.to/ftp.html](https://cr.yp.to/ftp.html)\n\n## TODO\n\nSupport this:\n\n```\n220 FTP Server ready.\n\nUSER\n test\n\n331 Username ok, send password.\n\nPASS\n pass\n\n230 Login successful.\n\nTYPE\n I\n\n200 Type set to: Binary.\n\nPASV\n\n\n227 Entering passive mode (172,20,0,65,212,110).\n\nCWD\n /.\n\n250 \"/\" is the current directory.\n\nDELE\n diag-EFLX_023-20200818T154530530.aes\n\n550 No such file or directory.\n\nSTOR\n diag-EFLX_023-20200818T154530530.aes\n\n125 Data connection already open. Transfer starting.\n\nQUIT\n226 Transfer complete.\n\n\n\n221 Goodbye.\n```\n\n```\n00000000: 3031 302e 3034 302e 3030 322e 3234 352e  010.040.002.245.\n00000010: 3032 3632 312d 3031 302e 3134 322e 3030  02621-010.142.00\n00000020: 302e 3031 312e 3532 3134 373a 2032 3230  0.011.52147: 220\n00000030: 2052 6561 6479 0d0a 0a30 3130 2e31 3432   Ready...010.142\n00000040: 2e30 3030 2e30 3131 2e35 3231 3437 2d30  .000.011.52147-0\n00000050: 3130 2e30 3430 2e30 3032 2e32 3435 2e30  10.040.002.245.0\n00000060: 3236 3231 3a20 5553 4552 204e 4c45 464c  2621: USER NLEFL\n00000070: 5a41 5054 4543 5445 5354 3457 5353 0d0a  ZAPTECTEST4WSS..\n00000080: 0a30 3130 2e30 3430 2e30 3032 2e32 3435  .010.040.002.245\n00000090: 2e30 3236 3231 2d30 3130 2e31 3432 2e30  .02621-010.142.0\n000000a0: 3030 2e30 3131 2e35 3231 3437 3a20 3333  00.011.52147: 33\n000000b0: 3120 5573 6572 6e61 6d65 206f 6b61 792c  1 Username okay,\n000000c0: 2061 7761 6974 696e 6720 7061 7373 776f   awaiting passwo\n000000d0: 7264 0d0a 0a30 3130 2e31 3432 2e30 3030  rd...010.142.000\n000000e0: 2e30 3131 2e35 3231 3437 2d30 3130 2e30  .011.52147-010.0\n000000f0: 3430 2e30 3032 2e32 3435 2e30 3236 3231  40.002.245.02621\n00000100: 3a20 5041 5353 2066 3536 3636 3162 3630  : PASS f56661b60\n```\n\n```\n00000000: 3232 3020 4654 5020 5365 7276 6572 2072  220 FTP Server r\n00000010: 6561 6479 2e0d 0a0a 5553 4552 0a20 7465  eady....USER. te\n00000020: 7374 0d0a 0a33 3331 2055 7365 726e 616d  st...331 Usernam\n00000030: 6520 6f6b 2c20 7365 6e64 2070 6173 7377  e ok, send passw\n00000040: 6f72 642e 0d0a 0a50 4153 530a 2070 6173  ord....PASS. pas\n00000050: 730d 0a0a 3233 3020 4c6f 6769 6e20 7375  s...230 Login su\n00000060: 6363 6573 7366 756c 2e0d 0a0a 5459 5045  ccessful....TYPE\n00000070: 0a20 490d 0a0a 3230 3020 5479 7065 2073  . I...200 Type s\n00000080: 6574 2074 6f3a 2042 696e 6172 792e 0d0a  et to: Binary...\n00000090: 0a50 4153 560a 0d0a 0a32 3237 2045 6e74  .PASV....227 Ent\n000000a0: 6572 696e 6720 7061 7373 6976 6520 6d6f  ering passive mo\n000000b0: 6465 2028 3137 322c 3230 2c30 2c36 352c  de (172,20,0,65,\n000000c0: 3231 342c 3637 292e 0d0a 0a43 5744 0a20  214,67)....CWD.\n000000d0: 2f2e 0d0a 0a32 3530 2022 2f22 2069 7320  /....250 \"/\" is\n000000e0: 7468 6520 6375 7272 656e 7420 6469 7265  the current dire\n000000f0: 6374 6f72 792e 0d0a 0a44 454c 450a 2064  ctory....DELE. d\n00000100: 6961 672d 4546 4c58 5f30 3233 2d32 3032  iag-EFLX_023-202\n00000110: 3030 3831 3854 3135 3534 3434 3038 342e  00818T155444084.\n00000120: 6165 730d 0a0a 3535 3020 4e6f 2073 7563  aes...550 No suc\n00000130: 6820 6669 6c65 206f 7220 6469 7265 6374  h file or direct\n00000140: 6f72 792e 0d0a 0a53 544f 520a 2064 6961  ory....STOR. dia\n00000150: 672d 4546 4c58 5f30 3233 2d32 3032 3030  g-EFLX_023-20200\n00000160: 3831 3854 3135 3534 3434 3038 342e 6165  818T155444084.ae\n00000170: 730d 0a0a 3132 3520 4461 7461 2063 6f6e  s...125 Data con\n00000180: 6e65 6374 696f 6e20 616c 7265 6164 7920  nection already\n00000190: 6f70 656e 2e20 5472 616e 7366 6572 2073  open. Transfer s\n000001a0: 7461 7274 696e 672e 0d0a 0a31 3235 2044  tarting....125 D\n000001b0: 6174 6120 636f 6e6e 6563 7469 6f6e 2061  ata connection a\n000001c0: 6c72 6561 6479 206f 7065 6e2e 2054 7261  lready open. Tra\n000001d0: 6e73 6665 7220 7374 6172 7469 6e67 2e0d  nsfer starting..\n```\n","readmeFilename":"README.md"}