Socket
Socket
Sign inDemoInstall

cwdav

Package Overview
Dependencies
7
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    cwdav

Start a preconfigured WebDAV server using cryptography and compression


Version published
Weekly downloads
19
increased by26.67%
Maintainers
1
Install size
1.62 MB
Created
Weekly downloads
 

Readme

Source

Crypted WebDAV Server

Start a preconfigured WebDAV server (based on webdav-server), which store files in a folder, encrypt and compress them. The encryption is AES256 CBC using a master password.

Install

npm i -g cwdav

Usage

cwdav [<config-file-json>]
cwdav2 [<config-file-v2-json>]

# Load the file './cwdav.json' or, if it doesn't exist,
# load a default configuration (store all in the './data'
# folder, creates it if it doesn't exist).
cwdav

# Create a crypted webdav server for local use, using
# default settings.
cwdav2

# Load a specific configuration file
cwdav "/home/dev/path/config/.cwdav.json"
cwdav .cwdav.json

cwdav2 "/home/dev/path/config/.cwdav.json"
cwdav2 .cwdav.json

Configuration

Verison 1

The default configuration file name is cwdav.json.

The string values can refer to another value with the $(...) pattern.

KeyDefault valueDescription
hostname'::'Scope of the server (localhost, 0.0.0.0, ::, etc...)
port1900Port of the server
container'./data'Folder to store the crypted data
treeFile'$(container)/tree'File path in which store the resource tree
tempTreeFile'$(container)/tree.tmp'File path to the temporary resource tree
treeSeed'tree'Seed to use to mix with the global IV to encrypt/decrypt the resource tree file
salt'this is the salt of the world'The salt to use to encrypt/decrypt
cipher'aes-256-cbc'Cipher to use to encrypt/decrypt
cipherIvSize16IV size of the cipher
hash'sha256'Hash algorithm to use for password derivation
masterNbIteration80000Number of hash iteration to get the master key/IV
minorNbIteration1000Number of hash iteration to get the file-specific IV
keyLen256Encryption/descryption key size
isVerbosefalseTell the server to display some information on its own

Here is an example of a configuration file :

{
    "port": 1900,
    "container": "./data",
    "treeFile": "$(container)/tree",
    "tempTreeFile": "$(container)/tree.tmp",
    "treeSeed": "tree"
}

Version 2

KeyDefault valueDescription
webdavServerOptionsundefinedSettings of the webdav-server package
dataFolderPath'.data'Folder to store the crypted data
masterFilePath'data.json'File path in which store the resource tree
masterKeyIteration100000Number of hash iteration to get the master key/IV
fileKeyIteration1000Number of hash iteration to get the file-specific key/IV
keySize32Encryption/descryption key size
ivSize16Encryption/descryption IV size
cipherAlgorithm'aes-256-cbc'Algorithm to use for encryption/decryption
hashAlgorithm'sha256'Algorithm to use for the hashes
multiUserfalseDefine if the system must use a multi user system

Here is an example of a configuration file :

{
    "webdavServerOptions": {
        "port": 1900
    },
    "container": "./data",
    "masterFilePath": ".cwdav-tree"
}

Note

For an unkown reason yet, if you set the hostname to 'localhost' or '127.0.0.1', the Windows embedded WebDAV client will be slower requesting to this server.

As a module

cwdav.execute

cwdav.execute(callback : (webDAVServer, httpServer) => void)

Execute is a simple macro to start, quickly, from your code, a webdav server.

const cwdav = require('cwdav');

cwdav.execute(() => {
    console.log('READY');
})

Is equivalent to :

const cwdav = require('cwdav'),
      readline = require('readline-sync');

function execute(callback)
{
    // Load the configuration from the argument file, from the local 'cwdav.json' file or from the default values
    cwdav.config.load(process.argv[2], (e, config) => {
        if(e)
            throw e;
        
        // Ask to password to the user
        const password = readline.question('Password : ', {
            hideEchoBack: true
        });

        // Initialize the server with the password and its configuration
        cwdav.init(password, config);
        // Load the saved state of the server or create a new one
        cwdav.load(() => {
            // Start the webdav server and bind an auto-saver for some HTTP methods
            cwdav.start((config, webDAVServer, httpServer) => {
                if(callback)
                    callback(config, webDAVServer, httpServer);
            })
        })
    })
}

execute(() => {
    console.log('READY');
})

What to do with a WebDAV Server?

You can use it as a virtual repository to store data and allow other softwares to access to it.

For instance (Windows uses \\localhost@<port>\DavWWWRoot\ to connect to the server ; Linux will need to mount the server or to use a webdav client) :

const cwdav = require('cwdav'),
      fs = require('fs');

cwdav.execute((config) => {
    fs.writeFile('\\\\localhost@' + config.port + '\\DavWWWRoot\\data.json', JSON.stringify({ myData: 'data' }), (e) => {
        // ...
    })

    // or
    
    fs.readFile('\\\\localhost@' + config.port + '\\DavWWWRoot\\data.json', (e, data) => {
        data = JSON.parse(data.toString());
        // ...
    })
})

Keywords

FAQs

Last updated on 17 Nov 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc