Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions lib/config/config-schema.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,47 @@
{
"encryption": {
"title": "Mode of connection encryption",
"description": "Specifies the way in which server list is saved",
"type": "string",
"default": "encrypted",
"enum": [{
"value": "encrypted",
"description": "Encrypted"
},
{
"value": "plain",
"description": "Not encrypted"
}
],
"order": 1
},
"config": {
"title": "Encrypted Connection",
"description": "This are the encrypted connection information about your servers. Don't edit this!",
"type": "string",
"default": "",
"order": 1
"order": 2
},
"password": {
"title": "Encrypted Password",
"description": "This is the encrypted password. Don't edit this!",
"type": "string",
"default": "",
"order": 2
"order": 3
},
"allowedConsumers": {
"title": "Whitelisted Consumers (encrypted)",
"description": "You can clear this to disallow access to your server configuration for all third-party packages.",
"type": "string",
"default": "",
"order": 3
"order": 4
},
"disallowedConsumers": {
"title": "Blacklisted Consumers (encrypted)",
"description": "You can clear this to allow all third-party packages to request access to your server configuration.",
"type": "string",
"default": "",
"order": 4
"order": 5
},
"tree": {
"type": "object",
Expand Down
2 changes: 1 addition & 1 deletion lib/connectors/ftp.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default class Ftp extends EventEmitter {
host: connection.host,
port: (connection.port) ? connection.port : 21,
user: connection.user,
password: connection.password,
password: connection.passwordDecrypted,
};

// TLS
Expand Down
6 changes: 3 additions & 3 deletions lib/connectors/sftp.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default class Sftp extends EventEmitter {
}
}
if (pw && connection.privateKey && !connection.passphrase) {
connection.passphrase = connection.password;
connection.passphrase = connection.passwordDecrypted;
}

connection.debug = (msg) => {
Expand Down Expand Up @@ -217,7 +217,7 @@ export default class Sftp extends EventEmitter {
let input = FileSystem.createReadStream(localPath);
input.pause();

// Declare events
// Declare events
const progressEvent = (progress) => {
queueItem.changeProgress(progress.transferred);
self.emit('data', progress.transferred);
Expand Down Expand Up @@ -320,7 +320,7 @@ export default class Sftp extends EventEmitter {
let promise = new Promise((resolve, reject) => {
let str = progress({ time: 100 });

// Declare events
// Declare events
const progressEvent = (progress) => {
self.emit('debug', 'sftp:get:client.get:progress');
queueItem.changeProgress(progress.transferred);
Expand Down
112 changes: 63 additions & 49 deletions lib/ftp-remote-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,17 @@ class FtpRemoteEdit {
}
}
});

atom.config.onDidChange('ftp-remote-edit.encryption', ({ newValue, oldValue }) => {
if (!Storage.hasPassword()) {
self.promptPassword().then(() => {
Storage.save();
});
} else {
Storage.save();
}
});

}

init() {
Expand Down Expand Up @@ -261,6 +272,10 @@ class FtpRemoteEdit {
}
}

isPasswordProvided() {
return atom.config.get('ftp-remote-edit.encryption') != 'encrypted' || Storage.hasPassword();
}

getCurrentServerName() {
const self = this;

Expand Down Expand Up @@ -291,7 +306,7 @@ class FtpRemoteEdit {
return;
}

if (!Storage.hasPassword()) {
if (!self.isPasswordProvided()) {
reject('nopassword');
return;
}
Expand All @@ -313,39 +328,39 @@ class FtpRemoteEdit {
detail: reasonForRequest + '\n-------------------------------\n' + caution,
dismissable: true,
buttons: [{
text: 'Always',
onDidClick: () => {
buttondismiss = true;
notif.dismiss();
addToWhiteList(Storage.getPassword(), reasonForRequest);
resolve(root.config);
}
},
{
text: 'Accept',
onDidClick: () => {
buttondismiss = true;
notif.dismiss();
resolve(root.config);
}
},
{
text: 'Decline',
onDidClick: () => {
buttondismiss = true;
notif.dismiss();
reject('userdeclined');
}
},
{
text: 'Never',
onDidClick: () => {
buttondismiss = true;
notif.dismiss();
addToBlackList(Storage.getPassword(), reasonForRequest);
reject('userdeclined');
}
},
text: 'Always',
onDidClick: () => {
buttondismiss = true;
notif.dismiss();
addToWhiteList(Storage.getPassword(), reasonForRequest);
resolve(root.config);
}
},
{
text: 'Accept',
onDidClick: () => {
buttondismiss = true;
notif.dismiss();
resolve(root.config);
}
},
{
text: 'Decline',
onDidClick: () => {
buttondismiss = true;
notif.dismiss();
reject('userdeclined');
}
},
{
text: 'Never',
onDidClick: () => {
buttondismiss = true;
notif.dismiss();
addToBlackList(Storage.getPassword(), reasonForRequest);
reject('userdeclined');
}
},
]
});

Expand Down Expand Up @@ -378,6 +393,7 @@ class FtpRemoteEdit {
resolve(true);
} else {
dialog.showError('Wrong password, try again!');
reject();
}
});

Expand Down Expand Up @@ -451,7 +467,7 @@ class FtpRemoteEdit {

self.init();

if (!Storage.hasPassword()) {
if (!self.isPasswordProvided()) {
if (!checkPasswordExists()) {
self.changePassword('add').then((returnValue) => {
if (returnValue) {
Expand Down Expand Up @@ -481,8 +497,7 @@ class FtpRemoteEdit {
const self = this;

self.init();

if (!Storage.hasPassword()) {
if (!self.isPasswordProvided()) {
self.toggle();
} else {
self.getTreeViewInstance().toggleFocus();
Expand All @@ -499,8 +514,7 @@ class FtpRemoteEdit {
const self = this;

self.init();

if (!Storage.hasPassword()) {
if (!self.isPasswordProvided()) {
self.toggle();
} else {
self.getTreeViewInstance().show();
Expand All @@ -522,7 +536,7 @@ class FtpRemoteEdit {
root = selected.view().getRoot();
};

if (!Storage.hasPassword()) {
if (!self.isPasswordProvided()) {
self.promptPassword().then(() => {
if (Storage.load()) {
self.getConfigurationViewInstance().reload(root);
Expand Down Expand Up @@ -683,7 +697,7 @@ class FtpRemoteEdit {
if (!FileSystem.existsSync(fullLocalPath)) {
createLocalPath(fullLocalPath);
}
} catch (err) { }
} catch (err) {}

directory.getConnector().existsDirectory(fullRelativePath).then((result) => {
showMessage('Directory ' + relativePath.trim() + ' already exists', 'error');
Expand Down Expand Up @@ -919,7 +933,7 @@ class FtpRemoteEdit {
if (FileSystem.existsSync(fullLocalPath)) {
FileSystem.unlinkSync(fullLocalPath);
}
} catch (err) { }
} catch (err) {}

file.parent.select();
file.destroy();
Expand Down Expand Up @@ -1039,7 +1053,7 @@ class FtpRemoteEdit {
const selected = self.getTreeViewInstance().list.find('.selected');

if (selected.length === 0) return;
if (!Storage.hasPassword()) return;
if (!self.isPasswordProvided()) return;

let element = selected.view();
if (element.is('.file')) {
Expand All @@ -1056,7 +1070,7 @@ class FtpRemoteEdit {
const selected = self.getTreeViewInstance().list.find('.selected');

if (selected.length === 0) return;
if (!Storage.hasPassword()) return;
if (!self.isPasswordProvided()) return;

let element = selected.view();

Expand All @@ -1072,7 +1086,7 @@ class FtpRemoteEdit {
const selected = self.getTreeViewInstance().list.find('.selected');

if (selected.length === 0) return;
if (!Storage.hasPassword()) return;
if (!self.isPasswordProvided()) return;

let destObject = selected.view();
if (destObject.is('.file')) {
Expand Down Expand Up @@ -1162,7 +1176,7 @@ class FtpRemoteEdit {
const selected = self.getTreeViewInstance().list.find('.selected');

if (selected.length === 0) return;
if (!Storage.hasPassword()) return;
if (!self.isPasswordProvided()) return;

let destObject = selected.view();
if (destObject.is('.file')) {
Expand Down Expand Up @@ -1237,7 +1251,7 @@ class FtpRemoteEdit {
const selected = self.getTreeViewInstance().list.find('.selected');

if (selected.length === 0) return;
if (!Storage.hasPassword()) return;
if (!self.isPasswordProvided()) return;

let destObject = selected.view();
if (destObject.is('.file')) {
Expand Down Expand Up @@ -1299,7 +1313,7 @@ class FtpRemoteEdit {
const selected = self.getTreeViewInstance().list.find('.selected');

if (selected.length === 0) return;
if (!Storage.hasPassword()) return;
if (!self.isPasswordProvided()) return;

let defaultPath = self.currentDownloadPath;
if (['project', 'desktop', 'downloads'].includes(defaultPath) === false && FileSystem.existsSync(defaultPath) === false) {
Expand Down Expand Up @@ -1962,7 +1976,7 @@ class FtpRemoteEdit {

editor.saveObject.removeClass('open');
});
} catch (err) { }
} catch (err) {}
}).catch((err) => {
showMessage(err.message, 'error');
});
Expand Down
Loading