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.5.2 to 1.5.3

5

CHANGELOG.md
# WebDAV-client changelog
## 1.5.2
_2018-03-25_
* Fix bug where requesting directory contents at paths with trailing slashes would return parent directory in results
## 1.5.1

@@ -4,0 +9,0 @@ _2018-03-23_

28

dist/factory.js

@@ -38,2 +38,8 @@ "use strict";

/**
* Options with headers and format
* @typedef {OptionsWithHeaders} OptionsHeadersAndFormat
* @property {String} format - The format to use (text/binary)
*/
/**
* Create a client adapter

@@ -43,2 +49,3 @@ * @param {String} remoteURL The remote address of the webdav server

* @param {String=} password Optional password for authentication
* @param {Agent} agent Optional http(s).Agent instance, allows custom proxy, certificate etc. Gets passed to node-fetch
* @returns {ClientInterface} A new client interface instance

@@ -61,8 +68,10 @@ * @module WebDAV

* console.log(contents);
* }); */
function createClient(remoteURL, username, password) {
* });
*/
function createClient(remoteURL, username, password, agent) {
var baseOptions = {
headers: {},
remotePath: urlTools.extractURLPath(remoteURL),
remoteURL: remoteURL
remoteURL: remoteURL,
agent: agent ? agent : undefined
};

@@ -215,2 +224,15 @@

/**
* Get the upload link
* Only supported for Basic authentication or unauthenticated connections.
* @param {String} remoteFilename The path of the remote file location
* @param {PutOptions=} options The options for the request
* @memberof ClientInterface
* @returns {String} A upload URL
*/
getFileUploadLink: function getFileUploadLink(remoteFilename, options) {
var putOptions = merge(baseOptions, options || {});
return putFile.getFileUploadLink(remoteFilename, putOptions);
},
/**
* Stat a remote object

@@ -217,0 +239,0 @@ * @param {String} remotePath The path of the item

3

dist/interface/copyFile.js

@@ -20,3 +20,4 @@ "use strict";

Destination: joinURL(options.remoteURL, destination)
}, options.headers)
}, options.headers),
agent: options.agent
};

@@ -23,0 +24,0 @@ return fetch(fetchURL, fetchOptions).then(responseHandlers.handleResponseCode);

@@ -13,3 +13,4 @@ "use strict";

method: "MKCOL",
headers: options.headers
headers: options.headers,
agent: options.agent
};

@@ -16,0 +17,0 @@ return fetch(fetchURL, fetchOptions).then(responseHandlers.handleResponseCode);

@@ -43,3 +43,4 @@ "use strict";

headers: headers,
body: writeStream
body: writeStream,
agent: options.agent
};

@@ -62,3 +63,4 @@ fetch(fetchURL, fetchOptions);

method: "GET",
headers: options.headers
headers: options.headers,
agent: options.agent
};

@@ -65,0 +67,0 @@ return fetch(fetchURL, fetchOptions).then(responseHandlers.handleResponseCode).then(function __mapResultToStream(res) {

@@ -13,3 +13,4 @@ "use strict";

method: "DELETE",
headers: options.headers
headers: options.headers,
agent: options.agent
};

@@ -16,0 +17,0 @@ return fetch(fetchURL, fetchOptions).then(responseHandlers.handleResponseCode);

@@ -29,3 +29,4 @@ "use strict";

Depth: 1
}, options.headers)
}, options.headers),
agent: options.agent
};

@@ -58,4 +59,2 @@ return fetch(fetchURL, fetchOptions).then(responseHandlers.handleResponseCode).then(function __handleResponseFormat(res) {

href = urlTools.normaliseHREF(href);
href = decodeURI(href);
href = urlTools.normalisePath(href);
// Each item should contain a stat object

@@ -65,3 +64,3 @@ var propStat = getSingleValue(getValueForKey("propstat", item));

// Process the true full filename (minus the base server path)
var filename = serverBasePath === "/" ? href : urlTools.normalisePath(path.relative(serverBasePath, href));
var filename = serverBasePath === "/" ? urlTools.normalisePath(href) : urlTools.normalisePath(path.relative(serverBasePath, href));
return davTools.propsToStat(props, filename);

@@ -68,0 +67,0 @@ });

@@ -25,3 +25,4 @@ "use strict";

method: "GET",
headers: options.headers
headers: options.headers,
agent: options.agent
};

@@ -28,0 +29,0 @@ return fetch(fetchURL, fetchOptions).then(responseHandlers.handleResponseCode);

@@ -19,3 +19,4 @@ "use strict";

Destination: joinURL(options.remoteURL, destination)
}, options.headers)
}, options.headers),
agent: options.agent
};

@@ -22,0 +23,0 @@ return fetch(fetchURL, fetchOptions).then(responseHandlers.handleResponseCode);

@@ -31,3 +31,4 @@ "use strict";

headers: putOptions.headers,
body: data
body: data,
agent: options.agent
};

@@ -37,4 +38,20 @@ return fetch(fetchURL, fetchOptions).then(responseHandlers.handleResponseCode);

function getFileUploadLink(filePath, options) {
var fetchURL = joinURL(options.remoteURL, encodePath(filePath));
fetchURL += "?Content-Type=application/octet-stream";
var protocol = /^https:/i.test(fetchURL) ? "https" : "http";
if (options.headers.Authorization) {
if (/^Basic /i.test(options.headers.Authorization) === false) {
throw new Error("Failed retrieving download link: Invalid authorisation method");
}
var authPart = options.headers.Authorization.replace(/^Basic /i, "").trim();
var authContents = Buffer.from(authPart, "base64").toString("utf8");
fetchURL = fetchURL.replace(/^https?:\/\//, `${protocol}://${authContents}@`);
}
return fetchURL;
}
module.exports = {
putFileContents: putFileContents
getFileUploadLink,
putFileContents
};

@@ -20,3 +20,4 @@ "use strict";

method: "PROPFIND",
headers: merge({ Depth: 0 }, options.headers)
headers: merge({ Depth: 0 }, options.headers),
agent: options.agent
};

@@ -23,0 +24,0 @@ fetchURL = fetchURL.replace(/\/+$/g, "/");

@@ -23,3 +23,4 @@ "use strict";

method: "PROPFIND",
headers: merge({ Depth: 0 }, options.headers)
headers: merge({ Depth: 0 }, options.headers),
agent: options.agent
};

@@ -26,0 +27,0 @@ return fetch(fetchURL, fetchOptions).then(responseHandlers.handleResponseCode).then(function __convertToText(res) {

{
"name": "webdav",
"version": "1.5.2",
"version": "1.5.3",
"description": "WebDAV client for NodeJS",

@@ -55,22 +55,22 @@ "main": "dist/index.js",

"babel-preset-env": "~1.6.1",
"buffer-equals": "~1.0.4",
"buffer-equals": "^1.0.4",
"chai": "^4.1.2",
"copy-dir": "~0.3.0",
"copy-dir": "^0.3.0",
"directory-exists": "^1.0.1",
"exists-file": "~3.0.2",
"husky": "~0.14.3",
"exists-file": "^3.0.2",
"husky": "^0.14.3",
"jsdoc-to-markdown": "^4.0.1",
"lint-staged": "~7.0.0",
"lint-staged": "^7.2.0",
"mkdirp": "^0.5.1",
"mocha": "^5.0.1",
"nock": "~9.2.3",
"nodemon": "~1.15.1",
"npm-run-all": "~4.1.2",
"prettier": "~1.10.2",
"prettier-check": "~2.0.0",
"rimraf": "~2.6.1",
"nock": "^9.2.3",
"nodemon": "^1.15.1",
"npm-run-all": "^4.1.3",
"prettier": "^1.10.2",
"prettier-check": "^2.0.0",
"rimraf": "^2.6.1",
"sinon": "^3.0.0",
"wait-on": "^2.0.2",
"webdav-server": "~2.3.15"
"webdav-server": "~2.3.22"
}
}

@@ -72,2 +72,11 @@ ![WebDAV](https://raw.githubusercontent.com/perry-mitchell/webdav-client/master/webdav.jpg)

##### options.range
Optionally request part of the remote file by specifying the `start` and `end` byte positions. The `end` byte position is optional and the rest of the file from `start` onwards will be streamed.
```javascript
var stream = client.createReadStream("/test/image.png", {
range: { start: 0, end: 499 } // first 500 bytes
});
```
#### createWriteStream(remotePath _[, options]_)

@@ -111,3 +120,3 @@ Creates a writeable stream to a remote path.

client
.getFileContents("/doc.txt", "text")
.getFileContents("/doc.txt", { format: "text" })
.then(function(text) {

@@ -125,34 +134,2 @@ console.log(text);

#### getFileStream(remotePath _[, options]_)
Get a readable stream on a remote file. Returns a Promise that resolves with a readable stream instance.
_This is the underlying method to `createReadStream` (uses a `PassThrough` stream to delay the data). Due to the requirement of waiting on the request to complete before being able to get the **true** read stream, a Promise is returned that resolves when it becomes available. `createReadStream` simply creates and returns a `PassThrough` stream immediately and writes to it once this method resolves._
```js
var fs = require("fs");
client
.getFileStream("/test/image.png")
.then(function(imageStream) {
imageStream.pipe(fs.createWriteStream("./image.png"));
});
```
`options` is an object that may look like the following:
```json
{
"headers": {}
}
```
##### options.range
Optionally request part of the remote file by specifying the `start` and `end` byte positions. The `end` byte position is optional and the rest of the file from `start` onwards will be streamed.
```javascript
var stream = client.getFileStream("/test/image.png", {
range: { start: 0, end: 499 } // first 500 bytes
});
```
#### getQuota(_[options]_)

@@ -159,0 +136,0 @@ Get quota information. Returns `null` upon failure or an object like so:

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