Skip to content

Commit

Permalink
Merge branch 'v2'
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrienCastex committed Jun 30, 2017
2 parents 9fd5bac + f1ef8b3 commit 52f24bb
Show file tree
Hide file tree
Showing 413 changed files with 16,926 additions and 2,816 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
*.log
test/v2/tests
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ node_js:
- "7"
- "6"
- "5"
- "4"
- "4"
before_script:
- npm i -g typescript
102 changes: 102 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,107 @@
# Changelog

# 2.0.0

### New features
* Version 2!
* Added the body written through the 'writeBody(...)' method as property of the 'RequestContext' class *[266e900](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/266e900)*
* Added the attributes to the stored properties affected by PROPPATCH *[f8f6e00](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/f8f6e00)*
* Added the reverse operation in the PROPPATCH method to fit the RFC (1 error => reverse changes) *[f14cde3](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/f14cde3)*
* Added an error in the 'Errors' bundle to say that the user has not enough privilege *[f488ecc](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/f488ecc)*
* Modified the 'Workflow' class to stop some executions when possible if the workflow ended *[e0e4232](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/e0e4232)*
* Implemented the 'SimplePathPrivilegeManager' class to manage privileges based on the path *[6656596](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/6656596)*
* Implemented the PrivilegeManager [v2] *[4c526b8](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/4c526b8)*
* Implemented the v2 *[6e58ac6](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/6e58ac6)*
* The XML helper will now throw a more meaningful error message when the 'find(...)' method doesn't find the XMLElement, helping for debugging *[b49c35a](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/b49c35a)*
* Added the depth to the 'Lock' class *[fbeeb71](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/fbeeb71)*

### Changes
* Changed to check by reference by default when seeking for a file system *[e39fd71](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/e39fd71)*
* Added the user as argument in the privilege managers *[8908c87](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/8908c87)*
* Splitted the 'RequestContext' class into 'RequestContext', 'ExternalRequestContext' and 'HTTPRequestContext' *[faf8581](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/faf8581)*
* Added a constructor to help unserialization in the 'LocalPropertyManager' class and the 'LocalLockManager' class0e78d10 Fixed the 'PhysicalFileSystem' class *[f8b3b46](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/f8b3b46)*
* The user used by the 'createExternal(...)' static method of the 'RequestContext' class is now a super-admin user unreferenced by the user manager *[50e1194](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/50e1194)*
* Made the callback optional in the 'addSubTree' of the 'FileSystem' class *[d81a883](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/d81a883)*
* Removed the event system from the server *[882ca71](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/882ca71)*
* Made the 'treeFilePath' server option of 'autoLoad' optional (default value is the 'treeFilePath' of 'autoSave') *[386f04a](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/386f04a)*
* Changed the type of the 'privilegeManager' server option from the old 'IPrivilegeManager' to the new 'PrivilegeManager' *[386f04a](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/386f04a)*
* Added the 'CreateExternalContext' method to the server class to ease the creation of external contexts *[358e2ee](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/358e2ee)*
* Changed the type of the 'path' argument of the methods in 'FileSystem', 'ContextualFileSystem' and 'Resource' from 'Path' to 'Path | string' to be more easy to use *[5c987c6](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/5c987c6)*
* Added the 'PrivilegeManagerInfo' interface *[4d29192](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/4d29192)*
* Added the 'destinationPath' to the 'RenameInfo' interface *[4d29192](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/4d29192)*
* Added the 'setCodeFromError' method and the 'defaultStatusCode' method to the 'RequestContext' class *[8cf9a53](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/8cf9a53)*
* Added an error class for unserialization error (when the serializer is not found) *[f488ecc](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/f488ecc)*
* Added some standard errors to the 'Errors' bundle *[37afaaa](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/37afaaa)*

### Documentation
* Upgraded the README *[29086af](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/29086af)*
* Fixed the README example *[77c44cd](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/77c44cd)*
* Fixed the example 'Web Resource' *[75ff834](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/75ff834)*
* Deprecated the v1 'WebDAVServer' class *[2c609e7](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/2c609e7)*
* Added the 'webResource' example for the v2 *[d406d81](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/d406d81)*
* Splitted the 'examples' folder into 'v1' and 'v2' :
* *[24718da](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/24718da)*
* *[7518929](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/7518929)*

### Tests
* Fixed the tests to use the new 'RequestContext' implementation *[6d41b1b](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/6d41b1b)*
* Added a 'nbReservedSocketPerTest' in the test framework of the v2 *[72696ad](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/72696ad)*
* Added tests for the PROPPATCH method [v2] *[2be8b93](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/2be8b93)*
* Added test for the MOVE and COPY methods [v2] *[0c5e114](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/0c5e114)*
* Added tests for the 'addSubTree' method of the server/file systems [v2] *[5d5d3a2](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/5d5d3a2)*
* Added tests for the HEAD method *[651f797](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/651f797)*
* Added tests for the MKCOL method *[d895732](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/d895732)*
* Added tests for the DELETE method *[59e4201](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/59e4201)*
* Upgraded the test framework of the v2 *[a9edc7e](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/a9edc7e)*
* Added test for the persistence [v2] *[deb443b](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/deb443b)*
* Added test for the LOCK and UNLOCK methods [v2] *[37f17a0](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/37f17a0)*
* Fixed the tests for node.js:5 and node.js:4 *[b43ba41](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/b43ba41)*
* Modified the tests to use 'server.rootFileSystem()' method instead of the removed 'server.rootFileSystem' property *[7c7874c](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/7c7874c)*
* Updated the test commands to compile the TypeScript, run the tests for the v2, then run the tests for the v2 *[3f6c274](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/3f6c274)*
* Added tests for the lock/unlock methods (v2) *[70717b2](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/70717b2)*
* Added tests for the OPTIONS method (v2) *[6e5981a](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/6e5981a)*
* Added tests for the readDir/propfind on a directory (v2) *[9ce23d1](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/9ce23d1)*
* Added tests for the read/write get/put methods (v2) *[b801535](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/b801535)*
* Added tests for the server management (v2) *[735e2ed](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/735e2ed)*
* Added TypeScript tests for better test developments *[f5b48a7](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/f5b48a7)*
* Upgraded the test framework to be more clean and ease the making of new tests *[74c381c](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/74c381c)*
* Splitted the 'test' folder into 'v1' and 'v2' *[ac88f11](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/ac88f11)*

### Other
* Cleaned the code *[1a46154](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/1a46154)*
* Updated the '@types/node' dev dependency *[6491270](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/6491270)*
* Exported the 'PrivilegeManager' class and the 'SimplePathPrivilegeManager' class *[f258c99](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/f258c99)*
* Added the 'Forbidden' standard error *[a209249](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/a209249)*
* Implemented the lock check *[0b41e28](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/0b41e28)*
* Implemented the privilege checks *[0b41e28](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/0b41e28)*
* Removed the FTP packages in the npm dependencies *[3733df7](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/3733df7)*
* Removed the old files from when the v2 was contained in one file *[04762e9](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/04762e9)*
* Removed the empty 'requirePrivilege' methods in the 'RequestContext' class *[8cf9a53](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/8cf9a53)*
* Moved the 'FTPFileSystem' class to the '@webdav-server/ftp' package *[5c04125](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/5c04125)*
* Exported the v1 within the v1 scope too *[1cc4a03](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/1cc4a03)*
* Exported the v2 *[90a6556](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/90a6556)*
* Fixed Travis CI missing 'tsc' *[d4850b7](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/d4850b7)*
* Modified the 'tsconfig.json' file to make TypeScript compile with comments by default *[6e7acd8](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/6e7acd8)*
* Added the TS types for the 'request' package *[3f6c274](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/3f6c274)*
* Added the 'ftp' package in the dependencies *[3f6c274](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/3f6c274)*
* Updated the .gitignore to ignore the transcripted code folder in the tests *[e83b463](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/e83b463)*

### Bug fix
* Fixed the 'VirtualFileSystem' unserialization *[d43f5c9](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/d43f5c9)*
* Fixed the urls in PROPFIND, PROPPATCH and LOCK responses not being encoded *[7bc8928](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/7bc8928)*
* Added encoding for the url in the PROPPATCH and PROPFIND responses [v1] *[30d5bcc](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/30d5bcc)*
* Fixed the 'SimplePathPrivilegeManager' implementation *[489cf28](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/489cf28)*
* Fixed the 'HTTPDigestAuthentication' implementation *[008af5c](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/008af5c)*
* Changed the default namespace from 'DAV:' to nothing, allowing to keep out-of-namespace tags in the properties *[635ce3f](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/635ce3f)*
* Fixed the 'VirtualFileSystem' *[9d3b03e](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/9d3b03e)*
* Fixed the MOVE method *[2c7a84c](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/2c7a84c)*
* Fixed the PROPFIND method *[2c7a84c](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/2c7a84c)*
* Fixed the response status when the parent was missing *[056df31](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/056df31)*
* Fixed the 'starter' method of the OPTIONS method tests to be more robust if some more tests are added in the future *[6fe546a](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/6fe546a)*
* Fixed the '_delete' method in the 'VirtualFileSystem' class which was not deleting the children of deleted folders *[e529f71](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/e529f71)*
* Fixed an unserialization bug (returning undefined as the unserialized data) *[467e91c](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/467e91c)*
* Fixed the serialization [v2] *[14b6e4c](https://github.com/OpenMarshal/npm-WebDAV-Server/commit/14b6e4c)*

# 1.9.1

### New features
Expand Down
71 changes: 58 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
# WebDAV Server for npm

[![Join the chat at https://gitter.im/npm-WebDAV-Server/Lobby](https://badges.gitter.im/npm-WebDAV-Server/Lobby.svg)](https://gitter.im/npm-WebDAV-Server/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

[![Build Status](https://travis-ci.org/OpenMarshal/npm-WebDAV-Server.svg?branch=master)](https://travis-ci.org/OpenMarshal/npm-WebDAV-Server)
[![Code Climate Rate](https://codeclimate.com/github/OpenMarshal/npm-WebDAV-Server/badges/gpa.svg)](https://codeclimate.com/github/OpenMarshal/npm-WebDAV-Server)
[![bitHound Overall Score](https://www.bithound.io/github/OpenMarshal/npm-WebDAV-Server/badges/score.svg)](https://www.bithound.io/github/OpenMarshal/npm-WebDAV-Server)
[![Dependencies Status](https://img.shields.io/david/OpenMarshal/npm-WebDAV-Server.svg)](https://david-dm.org/OpenMarshal/npm-WebDAV-Server.svg)
[![License](https://img.shields.io/npm/l/webdav-server.svg)](http://unlicense.org/)
[![npm Version](https://img.shields.io/npm/v/webdav-server.svg)](https://www.npmjs.com/package/webdav-server)

[![Join the chat at https://gitter.im/npm-WebDAV-Server/Lobby](https://badges.gitter.im/npm-WebDAV-Server/Lobby.svg)](https://gitter.im/npm-WebDAV-Server/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Join the chat at https://gitter.im/npm-WebDAV-Server/help-v2](https://img.shields.io/badge/chat-help%20v2-blue.svg)](https://gitter.im/npm-WebDAV-Server/help-v2?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Join the chat at https://gitter.im/npm-WebDAV-Server/help-v1](https://img.shields.io/badge/chat-help%20v1-blue.svg)](https://gitter.im/npm-WebDAV-Server/help-v1?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Join the chat at https://gitter.im/npm-WebDAV-Server/file-systems](https://img.shields.io/badge/chat-%40webdav--server-blue.svg)](https://gitter.im/npm-WebDAV-Server/file-systems?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

# Description

This server can use physical resources (files and folders on a hard drive, for instance), virtual resources (in-memory files and folders), processed/computed resources (for instance a file which provide the content of a remote web page), customized resources (whatever you created, whatever you can imagine), and use all of them on the same server instance. And it's easy to integrate in your JavaScript code!
Expand All @@ -27,11 +30,16 @@ Here are some project related links :
* [Issues](https://github.com/OpenMarshal/npm-WebDAV-Server/issues)
* [GitHub](https://github.com/OpenMarshal/npm-WebDAV-Server)
* [Gitter (chat)](https://gitter.im/npm-WebDAV-Server/Lobby)
* [Gitter for version 1](https://gitter.im/npm-WebDAV-Server/help-v1)
* [Gitter for version 2](https://gitter.im/npm-WebDAV-Server/help-v2)
* [Gitter for @webdav-server/...](https://gitter.im/npm-WebDAV-Server/file-systems)

This project rely upon the [RFC4918](http://www.webdav.org/specs/rfc4918.html).

This is an active project. Do not hesitate to post an issue if you have an idea or if you encounter a problem.

The project comes with two versions : the obselete version 1 and the version 2. Prefer using the version 2. At the moment, for compatibility issues, to access the version you must use the `v2` namespace.

# Install

```bash
Expand All @@ -40,27 +48,64 @@ npm install webdav-server

# Quick usage

Very simple usage :

```javascript
// TypeScript
import * as webdav from 'webdav-server'
import { v2 as webdav } from 'webdav-server'
// Javascript
const webdav = require('webdav-server');

const um = new webdav.SimpleUserManager();
const user = um.addUser('myUsername', 'myPassword', false);

const pm = new webdav.SimplePathPrivilegeManager();
pm.setRights(user, '/', [ 'all' ]);
const webdav = require('webdav-server').v2;

const server = new webdav.WebDAVServer({
privilegeManager: pm,
userManager: um,
isVerbose: true,
port: 1900
});

server.start(() => console.log('READY'));
```

With a user manager :

```javascript
// TypeScript
import { v2 as webdav } from 'webdav-server'
// Javascript
const webdav = require('webdav-server').v2;

// User manager (tells who are the users)
const userManager = new webdav.SimpleUserManager();
const user = userManager.addUser('username', 'password', false);

// Privilege manager (tells which users can access which files/folders)
const privilegeManager = new webdav.SimplePathPrivilegeManager();
privilegeManager.setRights(user, '/', [ 'all' ]);

const server = new webdav.WebDAVServer({
// HTTP Digest authentication with the realm 'Default realm'
httpAuthentication: new webdav.HTTPDigestAuthentication(userManager, 'Default realm'),
privilegeManager: privilegeManager,
port: 2000, // Load the server on the port 2000 (if not specified, default is 1900)
autoSave: { // Will automatically save the changes in the 'data.json' file
treeFilePath: 'data.json'
}
});

// Try to load the 'data.json' file
server.autoLoad((e) => {
if(e)
{ // Couldn't load the 'data.json' (file is not accessible or it has invalid content)
server.rootFileSystem().addSubTree(server.createExternalContext(), {
'folder1': { // /folder1
'file1.txt': webdav.ResourceType.File, // /folder1/file1.txt
'file2.txt': webdav.ResourceType.File // /folder1/file2.txt
},
'file0.txt': webdav.ResourceType.File // /file0.txt
})
}

server.start(() => console.log('READY'));
})
```

More examples at the [example page of the wiki](https://github.com/OpenMarshal/npm-WebDAV-Server/wiki/Examples).

More information/possibilities in the [documentation](https://github.com/OpenMarshal/npm-WebDAV-Server/wiki).
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions examples/v2/webResource/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Web Resource

This is an example to show how to make a simple custom resource base on the web. It gets a web content as its own content.

The `ts` file and the `js` file are the same thing. The `js` file displays the example in JavaScript while the `ts` file displays the example in TypeScript.
Loading

0 comments on commit 52f24bb

Please sign in to comment.