npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cwdav

v2.0.1

Published

Start a preconfigured WebDAV server using cryptography and compression

Downloads

58

Readme

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.

Key | Default value | Description -|-|- hostname | '::' | Scope of the server (localhost, 0.0.0.0, ::, etc...) port | 1900 | Port 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 cipherIvSize | 16 | IV size of the cipher hash | 'sha256' | Hash algorithm to use for password derivation masterNbIteration | 80000 | Number of hash iteration to get the master key/IV minorNbIteration | 1000 | Number of hash iteration to get the file-specific IV keyLen | 256 | Encryption/descryption key size isVerbose | false | Tell 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

Key | Default value | Description -|-|- webdavServerOptions | undefined | Settings of the webdav-server package dataFolderPath | '.data' | Folder to store the crypted data masterFilePath | 'data.json' | File path in which store the resource tree masterKeyIteration | 100000 | Number of hash iteration to get the master key/IV fileKeyIteration | 1000 | Number of hash iteration to get the file-specific key/IV keySize | 32 | Encryption/descryption key size ivSize | 16 | Encryption/descryption IV size cipherAlgorithm | 'aes-256-cbc' | Algorithm to use for encryption/decryption hashAlgorithm | 'sha256' | Algorithm to use for the hashes multiUser | false | Define 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());
        // ...
    })
})