Merge remote-tracking branch 'origin/master'

# Conflicts:
#	package.json
This commit is contained in:
kuehnelbs
2019-08-04 12:43:59 +02:00
4 changed files with 47 additions and 13 deletions

View File

@ -1,11 +1,20 @@
# node-red-contrib-nextcloud changelog # node-red-contrib-nextcloud changelog
## 0.1,1 ## 0.1.3
_2019-08-04_
* security fixes and package updates
## 0.1.2
_2018-11-11_ _2018-11-11_
* merged pull request * merged pull request
* fixed errors parsing caldav events * fixed errors parsing caldav events
* switched to ical-expander parser * switched to ical-expander parser
## 0.1.1
_2018-05-01
* added checkbox to accept self signed server certificates to credentials
* added support for self signed certificates to WebDAV nodes (needs [webdav](https://github.com/perry-mitchell/webdav-client) package to be updated to 1.5.3 or newer)
* removed debug output in node WebDAV list
## 0.1.0 ## 0.1.0
_2018-04-30_ _2018-04-30_

View File

@ -3,7 +3,8 @@
category: 'config', category: 'config',
defaults: { defaults: {
cname: {value: '', required: false}, cname: {value: '', required: false},
address: {value: 'https://your.server.com', required: true} address: {value: 'https://your.server.com', required: true},
insecure: {value: '', required: false}
}, },
credentials: { credentials: {
user: {type:'text'}, user: {type:'text'},
@ -27,6 +28,12 @@
<label for="node-config-input-address"><i class="fa fa-server"></i> Server</label> <label for="node-config-input-address"><i class="fa fa-server"></i> Server</label>
<input type="text" id="node-config-input-address"> <input type="text" id="node-config-input-address">
</div> </div>
<div class="form-row">
<label for="node-config-input-insecure"><i class="fa fa-server"></i> Security</label>
<input type="checkbox" value="1" id="node-config-input-insecure"
style="display: inline-block; width: auto; vertical-align: top">
<span style="width: 70%">Accept self signed certificates</span>
</div>
<div class="form-row"> <div class="form-row">
<label for="node-config-input-user"><i class="fa fa-server"></i> Username</label> <label for="node-config-input-user"><i class="fa fa-server"></i> Username</label>
<input type="text" id="node-config-input-user"> <input type="text" id="node-config-input-user">
@ -379,4 +386,4 @@
<dt class="optional">timeout <span class="property-type">number</span></dt> <dt class="optional">timeout <span class="property-type">number</span></dt>
<dd> Should be 0 in case of success</dd> <dd> Should be 0 in case of success</dd>
</dl> </dl>
</script> </script>

View File

@ -4,10 +4,12 @@ module.exports = function (RED) {
const fs = require('fs') const fs = require('fs')
const IcalExpander = require('ical-expander') const IcalExpander = require('ical-expander')
const moment = require('moment') const moment = require('moment')
const https = require('https')
function NextcloudConfigNode (config) { function NextcloudConfigNode (config) {
RED.nodes.createNode(this, config) RED.nodes.createNode(this, config)
this.address = config.address this.address = config.address
this.insecure = n.insecure
} }
RED.nodes.registerType('nextcloud-credentials', NextcloudConfigNode, { RED.nodes.registerType('nextcloud-credentials', NextcloudConfigNode, {
credentials: { credentials: {
@ -197,7 +199,12 @@ module.exports = function (RED) {
} }
directory = directory.replace('//', '/') directory = directory.replace('//', '/')
client.getDirectoryContents(directory) // check option for self signed certs
const option = {}
if (node.server.insecure) {
option.agent = new https.Agent({ rejectUnauthorized: false })
}
client.getDirectoryContents(directory, option)
.then(function (contents) { .then(function (contents) {
node.send({ 'payload': contents }) node.send({ 'payload': contents })
}, function (error) { }, function (error) {
@ -226,8 +233,13 @@ module.exports = function (RED) {
return return
} }
filename = filename.replace('//', '/') filename = filename.replace('//', '/')
node.warn(filename)
client.getFileContents(filename) // check option for self signed certs
const option = {}
if (node.server.insecure) {
option.agent = new https.Agent({ rejectUnauthorized: false })
}
client.getFileContents(filename, option)
.then(function (contents) { .then(function (contents) {
node.send({ 'payload': contents }) node.send({ 'payload': contents })
}, function (error) { }, function (error) {
@ -264,7 +276,13 @@ module.exports = function (RED) {
const webDavUri = node.server.address + '/remote.php/webdav/' const webDavUri = node.server.address + '/remote.php/webdav/'
const client = webdav(webDavUri, node.server.credentials.user, node.server.credentials.pass) const client = webdav(webDavUri, node.server.credentials.user, node.server.credentials.pass)
client.putFileContents(directory + name, file, { format: 'binary' }) // check option for self signed certs
const option = {}
if (node.server.insecure) {
option.agent = new https.Agent({ rejectUnauthorized: false })
}
client.putFileContents(directory + name, file, { format: 'binary' }, option)
.then(function (contents) { .then(function (contents) {
console.log(contents) console.log(contents)
node.send({ 'payload': JSON.parse(contents) }) node.send({ 'payload': JSON.parse(contents) })

View File

@ -1,6 +1,6 @@
{ {
"name": "node-red-contrib-nextcloud", "name": "node-red-contrib-nextcloud",
"version": "0.1.2", "version": "0.1.3",
"description": "Collection of node-red nodes to download Calendars (CalDAV) and Contacts (CardDAV) and up- / download / list files (WebDAV) from / to nextcloud", "description": "Collection of node-red nodes to download Calendars (CalDAV) and Contacts (CardDAV) and up- / download / list files (WebDAV) from / to nextcloud",
"main": "nextcloud.js", "main": "nextcloud.js",
"node-red": { "node-red": {
@ -19,15 +19,15 @@
"dependencies": { "dependencies": {
"dav": "^1.8.0", "dav": "^1.8.0",
"ical-expander": "^2.0.0", "ical-expander": "^2.0.0",
"moment": "^2.22.2", "moment": "^2.24.0",
"webdav": "^1.6.1" "webdav": "^2.9.1"
}, },
"devDependencies": { "devDependencies": {
"eslint": "^5.6.0", "eslint": "^5.16.0",
"eslint-config-standard": "^12.0.0", "eslint-config-standard": "^12.0.0",
"eslint-plugin-import": "^2.14.0", "eslint-plugin-import": "^2.18.2",
"eslint-plugin-node": "^7.0.1", "eslint-plugin-node": "^7.0.1",
"eslint-plugin-promise": "^4.0.1", "eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.0" "eslint-plugin-standard": "^4.0.0"
}, },
"scripts": { "scripts": {