New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

webdav

Package Overview
Dependencies
Maintainers
1
Versions
101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webdav - npm Package Compare versions

Comparing version 1.0.0-rc1 to 1.0.0

.eslintrc

118

API.md

@@ -0,7 +1,12 @@

## Modules
<dl>
<dt><a href="#module_WebDAV">WebDAV</a> ⇒ <code><a href="#ClientInterface">ClientInterface</a></code></dt>
<dd><p>Create a client adapter</p>
</dd>
</dl>
## Functions
<dl>
<dt><a href="#request">request(url, options)</a> ⇒ <code>Promise</code></dt>
<dd><p>Perform a request</p>
</dd>
<dt><a href="#setFetchMethod">setFetchMethod(fn)</a></dt>

@@ -11,8 +16,2 @@ <dd><p>Set the fetch method to use when making requests

</dd>
<dt><a href="#getQuota">getQuota([options])</a> ⇒ <code>null</code> | <code>Object</code></dt>
<dd><p>Get quota information</p>
</dd>
<dt><a href="#createWebDAVClient">createWebDAVClient(remoteURL)</a> ⇒ <code>Object</code></dt>
<dd><p>Create a webdav client interface</p>
</dd>
</dl>

@@ -24,22 +23,35 @@

<dt><a href="#ClientInterface">ClientInterface</a> : <code>Object</code></dt>
<dd></dd>
<dd><p>Client adapter</p>
</dd>
<dt><a href="#OptionsWithHeaders">OptionsWithHeaders</a> : <code>Object</code></dt>
<dd></dd>
<dt><a href="#OptionsHeadersAndFormat">OptionsHeadersAndFormat</a> : <code><a href="#OptionsWithHeaders">OptionsWithHeaders</a></code></dt>
<dd></dd>
<dd><p>Options with header object</p>
</dd>
<dt><a href="#PutOptions">PutOptions</a> : <code><a href="#OptionsWithHeaders">OptionsWithHeaders</a></code></dt>
<dd><p>Options for creating a resource</p>
</dd>
</dl>
<a name="request"></a>
<a name="module_WebDAV"></a>
## request(url, options) ⇒ <code>Promise</code>
Perform a request
## WebDAV ⇒ <code>[ClientInterface](#ClientInterface)</code>
Create a client adapter
**Kind**: global function
**Returns**: <code>Promise</code> - A promise that resolves with the result
**Returns**: <code>[ClientInterface](#ClientInterface)</code> - A new client interface instance
| Param | Type | Description |
| --- | --- | --- |
| url | <code>String</code> | The URL to fetch |
| options | <code>Object</code> | Fetch options |
| remoteURL | <code>String</code> | The remote address of the webdav server |
| [username] | <code>String</code> | Optional username for authentication |
| [password] | <code>String</code> | Optional password for authentication |
**Example**
```js
const createClient = require("webdav");
const client = createClient(url, username, password);
client
.getDirectoryContents("/")
.then(contents => {
console.log(contents);
});
```
<a name="setFetchMethod"></a>

@@ -57,31 +69,12 @@

<a name="getQuota"></a>
## getQuota([options]) ⇒ <code>null</code> &#124; <code>Object</code>
Get quota information
**Kind**: global function
**Returns**: <code>null</code> &#124; <code>Object</code> - Returns null if failed, or an object with `used` and `available`
| Param | Type | Description |
| --- | --- | --- |
| [options] | <code>[OptionsHeadersAndFormat](#OptionsHeadersAndFormat)</code> | Options for the request |
<a name="createWebDAVClient"></a>
## createWebDAVClient(remoteURL) ⇒ <code>Object</code>
Create a webdav client interface
**Kind**: global function
**Returns**: <code>Object</code> - The client interface
**Access:** public
**See**: createClient
| Param | Type | Description |
| --- | --- | --- |
| remoteURL | <code>String</code> | The target URL |
**Example**
```js
const createClient = require("webdav");
createClient.setFetchMethod(window.fetch);
```
<a name="ClientInterface"></a>
## ClientInterface : <code>Object</code>
Client adapter
**Kind**: global typedef

@@ -96,2 +89,3 @@

* [.getFileContents(remoteFilename, [options])](#ClientInterface.getFileContents) ⇒ <code>Promise.&lt;(Buffer\|String)&gt;</code>
* [.getQuota([options])](#ClientInterface.getQuota) ⇒ <code>null</code> &#124; <code>Object</code>
* [.moveFile(remotePath, targetRemotePath, [options])](#ClientInterface.moveFile) ⇒ <code>Promise</code>

@@ -125,3 +119,3 @@ * [.putFileContents(remoteFilename, data, [options])](#ClientInterface.putFileContents) ⇒ <code>Promise</code>

| remoteFilename | <code>String</code> | The file to stream |
| [options] | <code>[OptionsHeadersAndFormat](#OptionsHeadersAndFormat)</code> | Options for the request |
| [options] | <code>[OptionsWithHeaders](#OptionsWithHeaders)</code> | Options for the request |

@@ -139,3 +133,3 @@ <a name="ClientInterface.createWriteStream"></a>

| remoteFilename | <code>String</code> | The file to write to |
| [options] | <code>[OptionsHeadersAndFormat](#OptionsHeadersAndFormat)</code> | Options for the request |
| [options] | <code>[PutOptions](#PutOptions)</code> | Options for the request |

@@ -179,4 +173,16 @@ <a name="ClientInterface.deleteFile"></a>

| remoteFilename | <code>String</code> | The file to fetch |
| [options] | <code>[OptionsHeadersAndFormat](#OptionsHeadersAndFormat)</code> | Options for the request |
| [options] | <code>OptionsHeadersAndFormat</code> | Options for the request |
<a name="ClientInterface.getQuota"></a>
### ClientInterface.getQuota([options]) ⇒ <code>null</code> &#124; <code>Object</code>
Get quota information
**Kind**: static method of <code>[ClientInterface](#ClientInterface)</code>
**Returns**: <code>null</code> &#124; <code>Object</code> - Returns null if failed, or an object with `used` and `available`
| Param | Type | Description |
| --- | --- | --- |
| [options] | <code>OptionsHeadersAndFormat</code> | Options for the request |
<a name="ClientInterface.moveFile"></a>

@@ -208,3 +214,3 @@

| data | <code>String</code> &#124; <code>Buffer</code> | The data to write |
| [options] | <code>[OptionsHeadersAndFormat](#OptionsHeadersAndFormat)</code> | The options for the request |
| [options] | <code>[PutOptions](#PutOptions)</code> | The options for the request |

@@ -227,2 +233,4 @@ <a name="ClientInterface.stat"></a>

## OptionsWithHeaders : <code>Object</code>
Options with header object
**Kind**: global typedef

@@ -233,7 +241,9 @@ **Properties**

| --- | --- | --- |
| headers | <code>Object</code> | Optional headers to send with the request |
| headers | <code>Object</code> | Headers key-value list |
<a name="OptionsHeadersAndFormat"></a>
<a name="PutOptions"></a>
## OptionsHeadersAndFormat : <code>[OptionsWithHeaders](#OptionsWithHeaders)</code>
## PutOptions : <code>[OptionsWithHeaders](#OptionsWithHeaders)</code>
Options for creating a resource
**Kind**: global typedef

@@ -244,3 +254,3 @@ **Properties**

| --- | --- | --- |
| format | <code>String</code> | Format of request/response payload (binary/text) |
| overwrite | <code>Boolean</code> | Whether or not to overwrite existing files (default: true) |
# WebDAV-client changelog
## **1.0.0**
_2017-08-06_
* Complete rewrite of the project
* Better testing setup with webdav-server
* **Bugfixes**:
* [Directory contents parse bug](https://github.com/perry-mitchell/webdav-client/issues/54)
## 1.0.0-rc1
_2017-07-01_
* URI encoding for special characters
* Writeable streams
* Internal `fetch` override support
* Quota support
* Remove duplicate methods
* Optimise `stat` depth
## 0.10.0

@@ -4,0 +22,0 @@ _2017-06-24_

{
"name": "webdav",
"version": "1.0.0-rc1",
"version": "1.0.0",
"description": "WebDAV client for NodeJS",

@@ -8,3 +8,5 @@ "main": "source/index.js",

"generate:docs": "jsdoc2md 'source/**/*.js' > API.md",
"test": "mocha -r test/specs/index.js test/specs/*.spec.js test/specs/integration/*.spec.js"
"test": "npm run test:lint && npm run test:unit",
"test:lint": "eslint source/ && eslint test/specs/",
"test:unit": "mocha -r test/specs/index.js test/specs/**/*.spec.js"
},

@@ -28,18 +30,23 @@ "repository": {

"dependencies": {
"deepmerge": "^1.3.1",
"node-fetch": "^1.6.3",
"xml2js": "^0.4.17"
"deepmerge": "~1.3.1",
"node-fetch": "~1.6.3",
"url-join": "~2.0.2",
"url-parse": "~1.1.9",
"xml2js": "~0.4.17"
},
"devDependencies": {
"buffer-equals": "~1.0.4",
"chai": "^3.5.0",
"copy-dir": "~0.3.0",
"directory-exists": "^1.0.1",
"file-exists": "^2.0.0",
"jsDAV": "^0.3.4",
"eslint": "~4.4.0",
"exists-file": "~3.0.2",
"jsdoc-to-markdown": "^2.0.1",
"mkdirp": "^0.5.1",
"mocha": "^3.1.0",
"rimraf": "^2.5.4",
"rimraf": "~2.6.1",
"sinon": "^2.3.5",
"wait-on": "^2.0.2"
"wait-on": "^2.0.2",
"webdav-server": "~2.2.2"
}
}
# WebDAV client
A WebDAV client written in JavaScript for NodeJS.
[![Build Status](https://travis-ci.org/perry-mitchell/webdav-client.svg?branch=master)](https://travis-ci.org/perry-mitchell/webdav-client)
[![Build Status](https://travis-ci.org/perry-mitchell/webdav-client.svg?branch=master)](https://travis-ci.org/perry-mitchell/webdav-client) [![npm version](https://badge.fury.io/js/webdav.svg)](https://www.npmjs.com/package/webdav) ![monthly downloads](https://img.shields.io/npm/dm/webdav.svg)
[![NPM](https://nodei.co/npm/webdav.png?downloads=true&downloadRank=true&stars=true)](https://www.npmjs.com/package/webdav) [![NPM](https://nodei.co/npm-dl/webdav.png?months=6&height=2)](https://www.npmjs.com/package/webdav)
## About

@@ -13,2 +11,12 @@ This client was branched from [webdav-fs](https://github.com/perry-mitchell/webdav-fs) as the core functionality deserved its own repository. As **webdav-fs**' API was designed to resemble NodeJS' fs API, little could be done to improve the adapter interface for regular use.

## Installation
To install for use with NodeJS, execute the following shell command:
```shell
npm install webdav --save
```
### Webpack / Browserify
WebDAV-client is browser friendly, after being transpiled. Refer to the use of WebDAV-fs in the [Buttercup mobile compatibility library](https://github.com/buttercup/buttercup-mobile-compat) or the [Buttercup browser extension](https://github.com/buttercup/buttercup-browser-extension) for guidance on preparation for the web.
## Usage

@@ -227,1 +235,10 @@ Usage is very simple ([API](API.md)) - the main exported object is a factory to create adapter instances:

| mime | String | Files only | Mime type - for file items only |
## Compatibility
This library has been tested to work with the following WebDAV servers or applications:
* [ownCloud](https://owncloud.org/)
* [Nextcloud](https://nextcloud.com/)
* [Yandex.ru](https://yandex.ru/)
* [jsDAV](https://github.com/mikedeboer/jsDAV)
* [webdav-server](https://github.com/OpenMarshal/npm-WebDAV-Server)

@@ -0,7 +1,7 @@

function generateBasicAuthHeader(username, password) {
return "Basic " + (new Buffer(username + ":" + password)).toString("base64");
}
module.exports = {
generateAuthHeader: function generateAuthHeader(username, password) {
return "Basic " + (new Buffer(username + ":" + password)).toString("base64");
}
generateBasicAuthHeader
};

@@ -1,17 +0,6 @@

var factory = require("./clientFactory.js"),
setFetchMethod = require("./adapter/request.js").setFetchMethod;
var setFetchMethod = require("./request.js").setFetchMethod,
createClient = require("./factory.js").createClient;
/**
* Create a webdav client interface
* @see createClient
* @returns {Object} The client interface
* @public
* @param {String} remoteURL The target URL
*/
function createWebDAVClient(remoteURL, username, password) {
return factory.createClient(remoteURL, username, password);
};
createClient.setFetchMethod = setFetchMethod;
createWebDAVClient.setFetchMethod = setFetchMethod;
module.exports = createWebDAVClient;
module.exports = createClient;

@@ -1,20 +0,32 @@

module.exports = {
var URL = require("url-parse");
implantCredentials: function(url, username, password) {
return (username && username.length > 0) ?
url.replace(
/(https?:\/\/)/i,
"$1" + encodeURIComponent(username) + ":" + encodeURIComponent(password) + "@"
) : url;
},
function extractURLPath(fullURL) {
var url = new URL(fullURL),
urlPath = url.pathname;
if (urlPath.length <= 0) {
urlPath = "/";
}
return normalisePath(urlPath);
}
/**
* Strips the end slash off of a URL
*/
sanitiseBaseURL: function(url) {
return url
.trim()
.replace(/\/$/, "");
function normaliseHREF(href) {
var normalisedHref = href.replace(/^https?:\/\/[^\/]+/, "");
return normalisedHref;
}
function normalisePath(pathStr) {
var normalisedPath = pathStr;
if (normalisedPath[0] !== "/") {
normalisedPath = "/" + normalisedPath;
}
if (/^.+\/$/.test(normalisedPath)) {
normalisedPath = normalisedPath.substr(0, normalisedPath.length - 1);
}
return normalisedPath;
}
module.exports = {
extractURLPath: extractURLPath,
normaliseHREF: normaliseHREF,
normalisePath: normalisePath
};

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc