[
  {
    "path": ".eslintignore",
    "content": "index.js\nindex.ts\nindex.d.ts"
  },
  {
    "path": ".eslintrc.js",
    "content": "module.exports = {\n  parser: '@typescript-eslint/parser',\n  parserOptions: {\n    project: 'tsconfig.json',\n    sourceType: 'module',\n  },\n  plugins: ['@typescript-eslint/eslint-plugin'],\n  extends: [\n    'plugin:@typescript-eslint/eslint-recommended',\n    'plugin:@typescript-eslint/recommended',\n    'prettier',\n    'prettier/@typescript-eslint',\n  ],\n  root: true,\n  env: {\n    node: true,\n    jest: true,\n  },\n  rules: {\n    '@typescript-eslint/interface-name-prefix': 'off',\n    '@typescript-eslint/explicit-function-return-type': 'off',\n    '@typescript-eslint/no-explicit-any': 'off',\n    'semi': ['error', 'always'],\n  },\n};\n"
  },
  {
    "path": ".gitignore",
    "content": "# compiled output\n/dist\n/node_modules\n\n# Logs\nlogs\n*.log\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\nlerna-debug.log*\n\n# OS\n.DS_Store\n\n# Tests\n/coverage\n/.nyc_output\n\n# IDEs and editors\n/.idea\n.project\n.classpath\n.c9/\n*.launch\n.settings/\n*.sublime-workspace\n\n# IDE - VSCode\n.vscode/*\n!.vscode/settings.json\n!.vscode/tasks.json\n!.vscode/launch.json\n!.vscode/extensions.json"
  },
  {
    "path": ".prettierrc",
    "content": "{\n  \"singleQuote\": true,\n  \"trailingComma\": \"all\"\n}"
  },
  {
    "path": "README.md",
    "content": "# WebDAV CLI\n\n<a href=\"https://www.npmjs.com/package/webdav-cli\"><img src=\"https://img.shields.io/npm/v/webdav-cli.svg\" alt=\"NPM Version\" /></a>\n<a href=\"https://www.npmjs.com/package/webdav-cli\"><img src=\"https://img.shields.io/npm/l/webdav-cli.svg\" alt=\"Package License\" /></a>\n\n## Table of Contents\n\n- [Description](#description)\n- [Installation](#installation)\n- [Examples](#examples)\n- [TLS/SSL](#tlsssl)\n- [License](#license)\n\n## Description\nA simple zero-configuration command-line webdav server\n\n## Installation\n\n#### Globally via `npm`\n\n```bash\nnpm install --global webdav-cli\n```\n\n#### Running on-demand:\n\n```bash\nnpx webdav-cli [options]\n```\n\n## Examples\n\n```bash\nnpx webdav-cli --help\n```\n\n```bash\n    'usage: webdav-cli [options]',\n    '',\n    'options:',\n    '  --path       Path to folder [process.cwd()]',\n    '  --host       Host to use [127.0.0.1]',\n    '  --port       Port to use [1900]',\n    '  --digest     Enable digest authentication [basic]',\n    '  --username   Username for basic/digest authentication [random]',\n    '  --password   Password for basic/digest authentication [random]',\n    '  --directory  Show directory listings [false]',\n    '  --autoIndex  Display autoIndex [false]',\n    '  --ssl        Enable https [false]',\n    '  --sslKey     Path to ssl key file [self-signed]',\n    '  --sslCert    Path to ssl cert file [self-signed]',\n    '  --help       Print this list and exit',\n    '  --version    Print the version and exit.',\n    '  --rights     Comma separated values without spaces [all]', `\n        'all', 'canCreate', 'canDelete', 'canMove', 'canRename', \n        'canAppend', 'canWrite', 'canRead', 'canSource', \n        'canGetMimeType', 'canGetSize', 'canListLocks', \n        'canSetLock', 'canRemoveLock', 'canGetAvailableLocks', \n        'canGetLock', 'canAddChild', 'canRemoveChild', \n        'canGetChildren', 'canSetProperty', 'canGetProperty', \n        'canGetProperties', 'canRemoveProperty', 'canGetCreationDate', \n        'canGetLastModifiedDate', 'canGetWebName', 'canGetType'`,\n    'env:',\n    '  WEBDAV_CLI_PATH, WEBDAV_CLI_HOST, WEBDAV_CLI_PORT,',\n    '  WEBDAV_CLI_USERNAME, WEBDAV_CLI_PASSWORD, WEBDAV_CLI_DIGEST,',\n    '  WEBDAV_CLI_SSL, WEBDAV_CLI_SSL_KEY, WEBDAV_CLI_SSL_CERT,',\n    '  WEBDAV_CLI_DIRECTORY, WEBDAV_CLI_AUTO_INDEX, WEBDAV_CLI_RIGHTS',\n    '  WEBDAV_CLI_DISABLE_AUTHENTICATION',\n```\n\n## TLS/SSL\n\nFirst, you need to make sure that openssl is installed correctly, and you have `key.pem` and `cert.pem` files. You can generate them using this command:\n```bash\nopenssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key.pem -out cert.pem\n```\nUse `127.0.0.1` as value for `Common name` if you want to be able to install the certificate in your OS's root certificate store or browser so that it is trusted.\n\nThen you need to run the server with `--ssl` for enabling SSL and `--sslKey=key.pem --sslCert=cert.pem` for your certificate files.\n\n## License\n\nMIT\n"
  },
  {
    "path": "certs/self-signed.cert.pem",
    "content": "-----BEGIN CERTIFICATE-----\nMIIDOzCCAiOgAwIBAgIUMeTYKq547CQcDyNj5Sj5ZwcxDN8wDQYJKoZIhvcNAQEL\nBQAwLTELMAkGA1UEBhMCVUExDTALBgNVBAgMBEt5aXYxDzANBgNVBAoMBnN2dHNs\ndjAeFw0yMDAzMDIyMjUxNDBaFw0zMDAyMjgyMjUxNDBaMC0xCzAJBgNVBAYTAlVB\nMQ0wCwYDVQQIDARLeWl2MQ8wDQYDVQQKDAZzdnRzbHYwggEiMA0GCSqGSIb3DQEB\nAQUAA4IBDwAwggEKAoIBAQDBxLjsrteSkjSsT+NnlDM8hJxDI7YGEMOwyJodTNT1\n8raXt3iD0LKViqDCxHn5szuwdPo/YlY9o2g5z1xJn7QlzVdRAqtMoxFz9sj8vAqY\nsAv/jvkJYlcwIamgJhYYmAZM0Lban2x2bDo5oeyUGjk8gtk0V6Y4sfgPm7uJpoE4\npNoFfTA7fN+JQZetaKLfsXazYvUjUn9QFS0AsLZX7mhx7t5ASDCuOmlVRqmD9xiX\nx6oo8/qGC/sMTEnWeJzpGzyIKXpwMrN/oKxn3/JCgFcDKt+iIEhDQ6YJN23DVBIp\nmayZ/PWuQ5g1cCWXqZQ7nEMGgW3cSo7xzKb4QNwDLgm/AgMBAAGjUzBRMB0GA1Ud\nDgQWBBQz4DMPb30ovUO0zd+ECY4M5r1T9zAfBgNVHSMEGDAWgBQz4DMPb30ovUO0\nzd+ECY4M5r1T9zAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQBN\npE0Z3Jf3TSVCxygjh/ylrVLnXuUi3QbrXgKhXVA6a4qHIUnmcAzZCF2YKwZb2p4p\n27+DDPGEvVd9nulN8hDQ561B4mggch1KuTZTW7X028AEFIns/+BQJj9v2YnAwn8L\nIVnmhcqxaerLgKq4KRobLIPIxKeIPBcEcgBlDL244cMDnwOnYp7v5BYxN/s1L5OU\n5wCGs6FEt6Nzcw8x777xvVxvAe6TRen0Y0PheCHkoELsJ1Q0UGZHFnXxUP3c3THD\nWgGG3DuSoc4VNbSGz3yr+08YY2VgNJpYhSQUrBpNEjgeKHTtht1Vi20pb9inSxLj\nkYXUCOt+RRoAqiulwFLy\n-----END CERTIFICATE-----\n"
  },
  {
    "path": "certs/self-signed.key.pem",
    "content": "-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDBxLjsrteSkjSs\nT+NnlDM8hJxDI7YGEMOwyJodTNT18raXt3iD0LKViqDCxHn5szuwdPo/YlY9o2g5\nz1xJn7QlzVdRAqtMoxFz9sj8vAqYsAv/jvkJYlcwIamgJhYYmAZM0Lban2x2bDo5\noeyUGjk8gtk0V6Y4sfgPm7uJpoE4pNoFfTA7fN+JQZetaKLfsXazYvUjUn9QFS0A\nsLZX7mhx7t5ASDCuOmlVRqmD9xiXx6oo8/qGC/sMTEnWeJzpGzyIKXpwMrN/oKxn\n3/JCgFcDKt+iIEhDQ6YJN23DVBIpmayZ/PWuQ5g1cCWXqZQ7nEMGgW3cSo7xzKb4\nQNwDLgm/AgMBAAECggEAbQFCFsP1OdtODnGSuD5C5JSlY4+/YoIj1FvFdx4133Z/\nCbKI9X5+OGoYLflhtPsDZS0pambjpSE8DOl+PVy+d1Wg/U3HGAHUW6xFPQh73ZGL\n7mR77K+J5OXLCvDiFUvQn336n9p3pdcUmj9hW5+0+zmQ/0UfmV1k80LkqXcl0rrP\nwEWp8jY5+SzbM6btuPF2JF4vVtGp4sEBDO4ypCC2bypUbdM4FkoNzP9+rBoHFk1q\nTqXa2o1eh3+Qmw3y+a/AXUR6pzYIxB3jLj6DOaHhz/BaKTccm+1PMEFyMIvx3Uy2\nBzHD/db5V4gsIyMMiIeYjmBXc3aCfmNRpHg1Ywf6AQKBgQDmY4zfxZKAmYG2kud6\nvT4k1iY2joesi4ei1n4BW50TjLOIus9NW1n5GAPdnCSOuCzn1Pyhqf11EqVW6nhf\nmDHVmSDGSgj6gX2WuL1EWtBj7AAj30xVcL2VK23ZANpCvSEvkEaxxiKiQNdK3UZa\nNuYAWTRXHqXdv1HJuv9BYsXQwQKBgQDXTwVvfGLF7fPJqHltBFINTarRYLUnczxw\nUiS2ItFpOjeddPn4yHzru4QY5maqwajrhHzSe4KWKXAe7Tup1af6cDyBEsyYEI+i\nI+OJfcZBrjDpolKWulipCI5gR4CK80V/pkCBg5BCinWOExP8zkXD3xhU9SbGjLw+\n7LJUMe/6fwKBgQDOfb0+twMW1f8nl0V3gfQX6gR384lwweJAtcRcDTOc2Qf07ZJt\nwAnFM5wLXS566GH/K6t+bjCoZJziaOaYr31C96sjbinb9IGOvGeOw2JxnI2HmVT+\nYzzYXQNoctYs6Py8d7CVF4PlLv6HsAmlQ/0jpNA/oU2CkT6J81tizFeGQQKBgGFx\nJeiaxqkFU/vD/5BTED9tEw3HUrUT9hpvUqYLg/K3okvkkO0C72ZQayxJudU16BkO\n0N8Bfswu3MtiWko2o9s3yGox894uQJME4wlqnrtC9mgGSpJkq5N0h9sTAR3hk2Z9\n+1uiCzvSJfmysK0NPY2z/fMVMANT1i40OVDZeN5JAoGBAMgeJgeP8+K7Z0ecd4TL\nQONJ9j27mLsHCjSpxdaM98xM7Dw82KxQ4SJ74ZB0LPbSLtkhJhorRmXsAMCDih4Q\nBGyGnC11c8h1qRCuu2evXkXn6gK8OLcZxZJGTe/3vNR/hn1HCYlAX/sjEyaVVCbL\nbluIUqnVB577qS3yfxP9dWhu\n-----END PRIVATE KEY-----\n"
  },
  {
    "path": "index.d.ts",
    "content": "export * from './dist';\n"
  },
  {
    "path": "index.js",
    "content": "\"use strict\";\nfunction __export(m) {\n    for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\n}\nexports.__esModule = true;\n__export(require(\"./dist\"));\n"
  },
  {
    "path": "index.ts",
    "content": "export * from './dist';\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"webdav-cli\",\n  \"version\": \"2.0.0\",\n  \"description\": \"A simple zero-configuration command-line webdav server\",\n  \"author\": \"Sviatoslav H\",\n  \"license\": \"MIT\",\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"https://github.com/svtslv/webdav-cli\"\n  },\n  \"keywords\": [\n    \"cli\",\n    \"command\",\n    \"webdav\",\n    \"server\"\n  ],\n  \"files\": [\n    \"dist\",\n    \"certs\",\n    \"index.js\",\n    \"index.d.ts\"\n  ],\n  \"bin\": {\n    \"webdav-cli\": \"./dist/webdav-cli.cli.js\"\n  },\n  \"preferGlobal\": true,\n  \"main\": \"dist/index.js\",\n  \"scripts\": {\n    \"fix\": \"rm -rf node_modules && rm package-lock.json && npm install\",\n    \"build\": \"rm -rf dist && tsc -p tsconfig.build.json\",\n    \"format\": \"prettier --write \\\"**/*.ts\\\"\",\n    \"lint\": \"eslint 'lib/**/*.ts' --fix\",\n    \"test\": \"jest --config ./test/jest.config.json --runInBand\",\n    \"prepublish:npm\": \"npm run build\",\n    \"publish:npm\": \"npm publish --access public\",\n    \"prepublish:test\": \"npm run build\",\n    \"publish:test\": \"npm publish --access public --tag test\",\n    \"prerelease\": \"npm run build\",\n    \"release\": \"release-it\"\n  },\n  \"dependencies\": {\n    \"chalk\": \"^4.0.0\",\n    \"figlet\": \"^1.3.0\",\n    \"minimist\": \"^1.2.5\",\n    \"webdav-server\": \"^2.6.2\"\n  },\n  \"devDependencies\": {\n    \"@types/figlet\": \"^1.2.0\",\n    \"@types/jest\": \"^26.0.5\",\n    \"@types/minimist\": \"^1.2.0\",\n    \"@types/node\": \"^13.9.1\",\n    \"@types/supertest\": \"^2.0.8\",\n    \"@typescript-eslint/eslint-plugin\": \"^2.24.0\",\n    \"@typescript-eslint/parser\": \"^2.24.0\",\n    \"eslint\": \"^6.8.0\",\n    \"eslint-config-prettier\": \"^6.10.0\",\n    \"eslint-plugin-import\": \"^2.20.1\",\n    \"jest\": \"^26.1.0\",\n    \"prettier\": \"^1.19.1\",\n    \"reflect-metadata\": \"^0.1.13\",\n    \"release-it\": \"^15.5.0\",\n    \"supertest\": \"^4.0.2\",\n    \"ts-jest\": \"^26.1.3\",\n    \"ts-loader\": \"^9.4.2\",\n    \"ts-node\": \"^8.6.2\",\n    \"tsconfig-paths\": \"^3.9.0\",\n    \"typescript\": \"^3.8.3\"\n  }\n}\n"
  },
  {
    "path": "src/index.ts",
    "content": "export * from './webdav-cli.constants';\nexport * from './webdav-cli.interfaces';\nexport * from './webdav-cli.server';\nexport * from './webdav-cli.utils';"
  },
  {
    "path": "src/webdav-cli.cli.ts",
    "content": "#!/usr/bin/env node\n\nimport * as chalk from 'chalk';\nimport * as figlet from 'figlet';\nimport * as minimist from 'minimist';\nimport { WebdavCli } from './webdav-cli.server';\nimport { HOMEPAGE } from './webdav-cli.constants';\n\nconst argv = minimist(process.argv.slice(2));\nconsole.log(chalk.green(figlet.textSync('webdav-cli', { horizontalLayout: 'full' })));\nconsole.log(chalk.green(`Homepage: ${ HOMEPAGE }\\n`));\n\nif (argv.help) {\n  console.log([\n    'usage: webdav-cli [options]',\n    '',\n    'options:',\n    '  --path       Path to folder [process.cwd()]',\n    '  --host       Host to use [127.0.0.1]',\n    '  --port       Port to use [1900]',\n    '  --digest     Enable digest authentication [basic]',\n    '  --username   Username for basic/digest authentication [random]',\n    '  --password   Password for basic/digest authentication [random]',\n    '  --directory  Show directory listings [false]',\n    '  --autoIndex  Display autoIndex [false]',\n    '  --ssl        Enable https [false]',\n    '  --sslKey     Path to ssl key file [self-signed]',\n    '  --sslCert    Path to ssl cert file [self-signed]',\n    '  --help       Print this list and exit',\n    '  --version    Print the version and exit.',\n    '  --rights     Comma separated values without spaces [all]', `\n    'all', 'canCreate', 'canDelete', 'canMove', 'canRename', \n    'canAppend', 'canWrite', 'canRead', 'canSource', \n    'canGetMimeType', 'canGetSize', 'canListLocks', \n    'canSetLock', 'canRemoveLock', 'canGetAvailableLocks', \n    'canGetLock', 'canAddChild', 'canRemoveChild', \n    'canGetChildren', 'canSetProperty', 'canGetProperty', \n    'canGetProperties', 'canRemoveProperty', 'canGetCreationDate', \n    'canGetLastModifiedDate', 'canGetWebName', 'canGetType'`,\n    '',\n    'env:',\n    '  WEBDAV_CLI_PATH, WEBDAV_CLI_HOST, WEBDAV_CLI_PORT,',\n    '  WEBDAV_CLI_USERNAME, WEBDAV_CLI_PASSWORD, WEBDAV_CLI_DIGEST,',\n    '  WEBDAV_CLI_SSL, WEBDAV_CLI_SSL_KEY, WEBDAV_CLI_SSL_CERT,',\n    '  WEBDAV_CLI_DIRECTORY, WEBDAV_CLI_AUTO_INDEX, WEBDAV_CLI_RIGHTS',\n    '  WEBDAV_CLI_DISABLE_AUTHENTICATION',\n    '',\n  ].join('\\n'));\n  process.exit();\n}\n\nif (argv.version) {\n  console.log('Version: ' + require('../package.json').version, '\\n');\n  process.exit();\n}\n\nconst argvRights = argv.rights && typeof argv.rights === 'string' ? argv.rights.split(',') : undefined;\nconst envRights = process.env.WEBDAV_CLI_RIGHTS ? process.env.WEBDAV_CLI_RIGHTS.split(',') : undefined;\n\nconst config = {\n  path: argv.path || process.env.WEBDAV_CLI_PATH,\n  host: argv.host || process.env.WEBDAV_CLI_HOST,\n  port: argv.port || parseInt(process.env.WEBDAV_CLI_PORT),\n  digest: argv.digest || Boolean(process.env.WEBDAV_CLI_DIGEST),\n  username: argv.username || process.env.WEBDAV_CLI_USERNAME,\n  password: argv.password || process.env.WEBDAV_CLI_PASSWORD,\n  directory: argv.directory || process.env.WEBDAV_CLI_DIRECTORY,\n  autoIndex: argv.autoIndex || process.env.WEBDAV_CLI_AUTO_INDEX,\n  ssl: argv.ssl || Boolean(process.env.WEBDAV_CLI_SSL),\n  sslKey: argv.sslKey || process.env.WEBDAV_CLI_SSL_KEY,\n  sslCert: argv.sslCert || process.env.WEBDAV_CLI_SSL_CERT,\n  disableAuthentication: argv.disableAuthentication || process.env.WEBDAV_CLI_DISABLE_AUTHENTICATION,\n  rights: (argvRights || envRights) as any,\n};\n\nconst run = async() => {\n  const webdavCli = new WebdavCli(config);\n  const webdavCliServer = await webdavCli.start();\n  webdavCliServer.on('log', (ctx, fs, path, log) => console.log(log));\n};\n\nrun();\n\n"
  },
  {
    "path": "src/webdav-cli.constants.ts",
    "content": "import { WebdavCliRights } from './webdav-cli.interfaces';\n\nexport const HOMEPAGE = 'https://github.com/svtslv/webdav-cli';\n\nexport const RIGHTS: WebdavCliRights = [\n  'all', 'canCreate', 'canDelete', 'canMove', 'canRename',\n  'canAppend', 'canWrite', 'canRead', 'canSource',\n  'canGetMimeType', 'canGetSize', 'canListLocks',\n  'canSetLock', 'canRemoveLock', 'canGetAvailableLocks',\n  'canGetLock', 'canAddChild', 'canRemoveChild',\n  'canGetChildren', 'canSetProperty', 'canGetProperty',\n  'canGetProperties', 'canRemoveProperty', 'canGetCreationDate',\n  'canGetLastModifiedDate', 'canGetWebName', 'canGetType',\n];"
  },
  {
    "path": "src/webdav-cli.interfaces.ts",
    "content": "import { BasicPrivilege, v2 as webdav } from 'webdav-server';\n\nexport type WebdavCliRights = BasicPrivilege[];\n\nexport interface WebdavCliConfig {\n  path: string,\n  host: string,\n  port: number,\n  digest: boolean,\n  username: string,\n  password: string,\n  ssl: boolean,\n  sslKey: string,\n  sslCert: string,\n  rights: WebdavCliRights,\n  disableAuthentication?: boolean,\n  url?: string,\n  directory?: boolean,\n  autoIndex?: boolean,\n}\n\nexport interface WebdavCliServer extends webdav.WebDAVServer {\n  config: WebdavCliConfig,\n}"
  },
  {
    "path": "src/webdav-cli.server.ts",
    "content": "import * as fs from 'fs';\nimport { join } from 'path';\nimport { v2 as webdav } from 'webdav-server';\nimport { getRandomString } from './webdav-cli.utils';\nimport { RIGHTS } from './webdav-cli.constants';\nimport { WebdavCliServer, WebdavCliConfig, WebdavCliRights  } from './webdav-cli.interfaces';\n\nexport class WebdavCli {\n  config: WebdavCliConfig;\n\n  constructor(config: Partial<WebdavCliConfig>) {\n    this.config = this.getConfig(config);\n  }\n\n  getConfig(config: Partial<WebdavCliConfig>): WebdavCliConfig {\n    const selfSignedKey = join(__dirname, '/../certs/self-signed.key.pem');\n    const selfSignedCert = join(__dirname, '/../certs/self-signed.cert.pem');\n\n    const path = config.path || process.cwd();\n    const host = config.host || '127.0.0.1';\n    const port = config.port || 1900;\n\n    const digest = Boolean(config.digest);\n    let username = (config.username || getRandomString(16)).toString();\n    let password = (config.password || getRandomString(16)).toString();\n\n    const ssl = Boolean(config.ssl);\n    const sslKey = ssl ? fs.readFileSync(config.sslKey || selfSignedKey).toString() : '';\n    const sslCert = ssl ? fs.readFileSync(config.sslCert || selfSignedCert).toString() : '';\n\n    const disableAuthentication = Boolean(config.disableAuthentication);\n\n    if(disableAuthentication) {\n      config.rights = config.rights || ['canRead'];\n      username = '';\n      password = '';\n    }\n\n    const rights = (config.rights || ['all']).filter((item: WebdavCliRights[number]) => RIGHTS.includes(item));\n    const url = `${ ssl ? 'https' : 'http' }://${ host }:${ port }`;\n\n    const directory = Boolean(config.directory);\n    const autoIndex = Boolean(config.autoIndex);\n\n    return { \n      host, path, port, username, digest, password, ssl, sslCert, \n      sslKey, rights, url, disableAuthentication, directory, autoIndex,\n    };\n  }\n\n  async start(): Promise<WebdavCliServer> {\n    const config = this.config;\n\n    const userManager = new webdav.SimpleUserManager();\n    const user = userManager.addUser(config.username, config.password, false);\n\n    const privilegeManager = new webdav.SimplePathPrivilegeManager();\n    privilegeManager.setRights(user, '/', config.rights);\n\n    const authentication = config.digest ? 'HTTPDigestAuthentication' : 'HTTPBasicAuthentication';\n\n    const server = new webdav.WebDAVServer({\n      httpAuthentication: config.disableAuthentication ? { \n        askForAuthentication: () => ({}),\n        getUser: (ctx, gotUserCallback) => { \n          userManager.getDefaultUser((defaultUser) => { \n            privilegeManager.setRights(defaultUser, '/', config.rights);\n            gotUserCallback(null, defaultUser);\n          });\n        }\n      } : new webdav[authentication](userManager, 'Default realm'),\n      privilegeManager: privilegeManager,\n      https: config.ssl ? { cert: config.sslCert, key: config.sslKey } : null,\n      port: config.port,\n      hostname: config.host,\n    }) as WebdavCliServer;\n\n    server.config = config;\n\n    server.beforeRequest(async (ctx, next) => {\n      if (config.directory) {\n        const isBrowser = ctx.request.headers['user-agent'].search('Mozilla/5.0') !== -1;\n        if(isBrowser) {\n          try {\n            const resource = await server.getResourceAsync(ctx, ctx.requested.uri);\n            const list = await resource.readDirAsync();\n            const uri = ctx.requested.uri.slice(-1) === '/' ? ctx.requested.uri : ctx.requested.uri + '/';\n            if(config.autoIndex && list.includes('index.html')) {\n              ctx.requested.path = `${uri}index.html` as any;\n            } else {\n              const up =  `<a href=\"${ uri.split('/').slice(0, -2).join('/') || '/' }\">..</a><br/>`;\n              const html = up + list.map(item => `<a href=\"${ uri + item }\">${ item }</a><br/>`).join('');\n              // ctx.response.setHeader('Content-Type', 'text/html;charset=UTF-8');\n              ctx.response.end(`<html><head><meta charset=\"UTF-8\"></head><body>${html}</body></html>`);\n            }\n          } catch {}\n        }\n      }\n      next();\n    });\n\n    server.afterRequest((arg, next) => {\n      const log =  `>> ${ arg.request.method } ${ arg.requested.uri } > ${ arg.response.statusCode } ${ arg.response.statusMessage }`;\n      server.emit('log', null, null, '/', log);\n      next();\n    });\n\n    await server.setFileSystemAsync('/', new webdav.PhysicalFileSystem(config.path));\n    await server.startAsync(config.port);\n\n    const logs = [\n      `Server running at ${ config.url }`,\n      `[rights]: ${ config.rights }`,\n      `[digest]: ${ config.digest }`,\n      `username: ${ config.username }`,\n      `password: ${ config.password }`,\n      'Hit CTRL-C to stop the server',\n      'Run with --help to print help'\n    ];\n\n    console.log(logs.join('\\n'));\n\n    return server;\n  }\n}\n"
  },
  {
    "path": "src/webdav-cli.utils.ts",
    "content": "export function getRandomString(length: number) {\n  return [...Array(Math.ceil(length / 8))].map(() => Math.random().toString(36).slice(-8)).join('').slice(-length);\n}"
  },
  {
    "path": "test/index.spec.ts",
    "content": "import * as index from '../src/index';\n\ndescribe('Index', () => {\n  test('should return 4 exports', () => {\n    expect(Object.keys(index)).toHaveLength(4);\n  });\n});"
  },
  {
    "path": "test/jest.config.json",
    "content": "{\n  \"moduleFileExtensions\": [\"js\", \"json\", \"ts\"],\n  \"rootDir\": \".\",\n  \"testEnvironment\": \"node\",\n  \"testRegex\": \".spec.ts$\",\n  \"transform\": {\n    \"^.+\\\\.(t|j)s$\": \"ts-jest\"\n  }\n}"
  },
  {
    "path": "tsconfig.build.json",
    "content": "{\n  \"extends\": \"./tsconfig.json\",\n  \"exclude\": [\"node_modules\", \"test\", \"dist\", \"**/*spec.ts\"]\n}\n"
  },
  {
    "path": "tsconfig.json",
    "content": "{\n  \"compilerOptions\": {\n    \"module\": \"commonjs\",\n    \"declaration\": true,\n    \"removeComments\": true,\n    \"emitDecoratorMetadata\": true,\n    \"experimentalDecorators\": true,\n    \"target\": \"es2017\",\n    \"sourceMap\": false,\n    \"outDir\": \"./dist\",\n    \"baseUrl\": \"./\",\n    \"skipLibCheck\": true\n  },\n  \"include\": [\"src/**/*\", \"test/**/*\"],\n  \"exclude\": [\"node_modules\", \"dist\"]\n}\n"
  }
]