@yousolution/node-red-contrib-you-ftp-sftp 1.9.2 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docker-compose.yml +1 -1
- package/history.md +4 -0
- package/nodes/sftp.html +64 -29
- package/nodes/sftp.js +15 -0
- package/package.json +2 -2
package/docker-compose.yml
CHANGED
package/history.md
ADDED
package/nodes/sftp.html
CHANGED
|
@@ -29,6 +29,18 @@
|
|
|
29
29
|
<label for="node-config-input-password"><i class="fa fa-lock"></i> Password</label>
|
|
30
30
|
<input type="password" id="node-config-input-password">
|
|
31
31
|
</div>
|
|
32
|
+
<div class="form-row">
|
|
33
|
+
<label for="node-config-input-ssh-key-in"><i class="fa fa-lock"></i> SSH-Key file</label>
|
|
34
|
+
<input type="file" id="node-config-input-ssh-key-in">
|
|
35
|
+
</div>
|
|
36
|
+
<div class="form-row">
|
|
37
|
+
<label for="node-config-input-selected-sshkey"><i class="fa fa-lock"></i> Selected SSH-Key file </label>
|
|
38
|
+
<input type="checkbox" disabled id="node-config-input-selected-sshkey">
|
|
39
|
+
</div>
|
|
40
|
+
<div class="form-row">
|
|
41
|
+
<!-- <label for="node-config-input-sshkey"><i class="fa fa-lock"></i> SSH-Key</label> -->
|
|
42
|
+
<textarea id="node-config-input-sshkey" style="display:none;"> </textarea>
|
|
43
|
+
</div>
|
|
32
44
|
<div class="form-row">
|
|
33
45
|
<label for="node-config-input-hmac"><i class="fa fa-wrench"></i>hmac</label>
|
|
34
46
|
<select multiple type="text" id="node-config-input-hmac" size="9">
|
|
@@ -69,18 +81,41 @@
|
|
|
69
81
|
<script type="text/javascript">
|
|
70
82
|
RED.nodes.registerType('sftp', {
|
|
71
83
|
category: 'config',
|
|
72
|
-
color:
|
|
84
|
+
color: 'BurlyWood',
|
|
73
85
|
defaults: {
|
|
74
86
|
host: { value: 'localhost' },
|
|
75
87
|
port: { value: '22' },
|
|
76
88
|
username: { value: '', required: true },
|
|
77
|
-
password: { value: ''
|
|
78
|
-
|
|
79
|
-
|
|
89
|
+
password: { value: '' },
|
|
90
|
+
sshkey: { value: '' },
|
|
91
|
+
hmac: { value: 'hmac-sha2-256,hmac-sha2-512,hmac-sha1', required: true },
|
|
92
|
+
cipher: { value: 'aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm', required: true },
|
|
93
|
+
},
|
|
94
|
+
label: function () {
|
|
95
|
+
return this.host;
|
|
96
|
+
},
|
|
97
|
+
oneditprepare: function () {
|
|
98
|
+
const sshKeyFileIn = document.getElementById('node-config-input-ssh-key-in');
|
|
99
|
+
const sshKeyFile = document.getElementById('node-config-input-sshkey');
|
|
100
|
+
|
|
101
|
+
if (document.getElementById('node-config-input-sshkey').value) {
|
|
102
|
+
$('#node-config-input-selected-sshkey').prop('checked', true);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// node-config-input-selected-sshkey
|
|
106
|
+
|
|
107
|
+
// let fileOutput = document.getElementById("fileOutput");
|
|
108
|
+
sshKeyFileIn.addEventListener('change', function () {
|
|
109
|
+
const fileReader = new FileReader();
|
|
110
|
+
fileReader.onload = function () {
|
|
111
|
+
// console.log(fileReader.result);
|
|
112
|
+
sshKeyFile.value = fileReader.result;
|
|
113
|
+
};
|
|
114
|
+
// console.log({ type: this.files[0].type });
|
|
115
|
+
// console.log({ size: this.files[0].size });
|
|
116
|
+
fileReader.readAsBinaryString(this.files[0]);
|
|
117
|
+
});
|
|
80
118
|
},
|
|
81
|
-
label: function() {
|
|
82
|
-
return this.host
|
|
83
|
-
}
|
|
84
119
|
});
|
|
85
120
|
</script>
|
|
86
121
|
|
|
@@ -129,23 +164,23 @@
|
|
|
129
164
|
</script>
|
|
130
165
|
|
|
131
166
|
<script type="text/x-red" data-help-name="sftp in">
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
167
|
+
<h1>SFTP Client</h1>
|
|
168
|
+
<p>
|
|
169
|
+
<b>Node config:</b>
|
|
170
|
+
process.env.<b>SFTP_SSH_KEY_FILE</b> - If you want to use private SSH key set this environment variable
|
|
171
|
+
<ul>
|
|
172
|
+
<li><b>PUT</b> - Set <code>msg.payload.filedata</code> to the file contents you want pushed and will be uploaded to {GUID}.FileExtension. If you need more changes file request to github.</li>
|
|
173
|
+
<li><b>GET</b> - Set <code>msg.payload.filename</code> to get the file or will use Workdir + Filename in configuration. Leave configuration blank to set in code.</li>
|
|
174
|
+
<li><b>DELETE</b> - Set <code>msg.payload.filename</code> to delete the file or will use Workdir + Filename in configuration. Leave configuration blank to set in code.</li>
|
|
175
|
+
<li><b>LIST</b> - Uses the workdir</li>
|
|
176
|
+
</ul>
|
|
177
|
+
</p>
|
|
143
178
|
</script>
|
|
144
179
|
|
|
145
180
|
<script type="text/javascript">
|
|
146
181
|
RED.nodes.registerType('sftp in', {
|
|
147
182
|
category: 'storage-input',
|
|
148
|
-
color:
|
|
183
|
+
color: 'BurlyWood',
|
|
149
184
|
defaults: {
|
|
150
185
|
sftp: { type: 'sftp', required: true },
|
|
151
186
|
operation: { value: 'list', required: true },
|
|
@@ -155,11 +190,11 @@
|
|
|
155
190
|
fileExtension: { value: '.txt' },
|
|
156
191
|
workdir: { value: '' },
|
|
157
192
|
savedir: { value: '' },
|
|
158
|
-
name: { value: '' }
|
|
193
|
+
name: { value: '' },
|
|
159
194
|
},
|
|
160
195
|
inputs: 1,
|
|
161
196
|
outputs: 1,
|
|
162
|
-
icon:
|
|
197
|
+
icon: 'file.png',
|
|
163
198
|
label: function () {
|
|
164
199
|
var sftpNode = RED.nodes.node(this.sftp);
|
|
165
200
|
return this.name || 'sftp';
|
|
@@ -168,11 +203,11 @@
|
|
|
168
203
|
return this.name ? 'node_label_italic' : '';
|
|
169
204
|
},
|
|
170
205
|
oneditprepare: function () {
|
|
171
|
-
var filename = $(
|
|
172
|
-
var fileContents = $(
|
|
173
|
-
var fileExtension = $(
|
|
174
|
-
$(
|
|
175
|
-
var id = $(
|
|
206
|
+
var filename = $('.input-filename-row');
|
|
207
|
+
var fileContents = $('.input-fileContents-row');
|
|
208
|
+
var fileExtension = $('.input-fileExtension-row');
|
|
209
|
+
$('#node-input-operation').change(function () {
|
|
210
|
+
var id = $('#node-input-operation option:selected').val();
|
|
176
211
|
console.log(id);
|
|
177
212
|
if (id == 'list') {
|
|
178
213
|
filename.hide();
|
|
@@ -181,10 +216,10 @@
|
|
|
181
216
|
filename.show();
|
|
182
217
|
fileContents.hide();
|
|
183
218
|
fileExtension.show();
|
|
184
|
-
} else if (id =='get') {
|
|
219
|
+
} else if (id == 'get') {
|
|
185
220
|
filename.show();
|
|
186
221
|
fileExtension.hide();
|
|
187
|
-
} else if (id =='delete') {
|
|
222
|
+
} else if (id == 'delete') {
|
|
188
223
|
filename.show();
|
|
189
224
|
fileExtension.hide();
|
|
190
225
|
} else {
|
|
@@ -192,6 +227,6 @@
|
|
|
192
227
|
fileExtension.hide();
|
|
193
228
|
}
|
|
194
229
|
});
|
|
195
|
-
}
|
|
230
|
+
},
|
|
196
231
|
});
|
|
197
232
|
</script>
|
package/nodes/sftp.js
CHANGED
|
@@ -40,11 +40,22 @@ module.exports = function (RED) {
|
|
|
40
40
|
RED.nodes.createNode(this, n);
|
|
41
41
|
// var node = this;
|
|
42
42
|
|
|
43
|
+
console.log('SFTP - Config - username: ' + n.username);
|
|
43
44
|
console.log('SFTP - Config - hmac: ' + n.hmac);
|
|
44
45
|
console.log('SFTP - Config - cipher: ' + n.cipher);
|
|
45
46
|
|
|
47
|
+
// console.log('SFTP - Config - ssh-key: ' + n.sshkey);
|
|
48
|
+
|
|
46
49
|
let keyFile = null;
|
|
47
50
|
let keyData = null;
|
|
51
|
+
|
|
52
|
+
if (n.sshkey) {
|
|
53
|
+
keyFile = 'keyFile';
|
|
54
|
+
keyData = n.sshkey;
|
|
55
|
+
console.log('************************');
|
|
56
|
+
console.log(keyData);
|
|
57
|
+
console.log('************************');
|
|
58
|
+
}
|
|
48
59
|
if (process.env.SFTP_SSH_KEY_FILE) {
|
|
49
60
|
keyFile = process.env.SFTP_SSH_KEY_FILE;
|
|
50
61
|
keyFile = require('path').resolve(__dirname, '../../' + keyFile);
|
|
@@ -115,6 +126,10 @@ module.exports = function (RED) {
|
|
|
115
126
|
node.sftpConfig.options.username = msg.user || node.sftpConfig.options.username || '';
|
|
116
127
|
node.sftpConfig.options.password = msg.password || node.sftpConfig.options.password || '';
|
|
117
128
|
|
|
129
|
+
console.log('========');
|
|
130
|
+
console.log(node.sftpConfig.options.privateKey);
|
|
131
|
+
console.log('========');
|
|
132
|
+
|
|
118
133
|
let conn = new sftp();
|
|
119
134
|
|
|
120
135
|
this.sendMsg = function (err, result) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yousolution/node-red-contrib-you-ftp-sftp",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "A node-red node that support FTP and SFTP file transfer using $() environment variables to control the ftp connection details",
|
|
5
5
|
"main": "sftp.js",
|
|
6
6
|
"scripts": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"ftp": "^0.3.10",
|
|
37
37
|
"jsftp": "git+https://github.com/sergi/jsftp.git",
|
|
38
|
-
"ssh2-sftp-client": "^
|
|
38
|
+
"ssh2-sftp-client": "^9.0.4",
|
|
39
39
|
"basic-ftp": "^5.0.2"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|