150 lines
14 KiB
JavaScript
150 lines
14 KiB
JavaScript
"use strict";
|
|
/// <reference path="./typings/main.d.ts" />
|
|
var plugins = require("./smartssh.plugins");
|
|
var helpers = require("./smartssh.classes.helpers");
|
|
var ssh = (function () {
|
|
function ssh(optionsArg) {
|
|
if (optionsArg === void 0) { optionsArg = {}; }
|
|
this.sshDir = new sshDir(optionsArg.sshDir);
|
|
this.sshKeys = this.sshDir.getKeys();
|
|
this.sshSync = optionsArg.sshSync;
|
|
}
|
|
;
|
|
ssh.prototype.addKey = function (sshKeyArg) {
|
|
this.sshKeys.push(sshKeyArg);
|
|
this.sync();
|
|
};
|
|
;
|
|
ssh.prototype.getKey = function (hostArg) {
|
|
var filteredArray = this.sshKeys.filter(function (keyArg) {
|
|
return (keyArg.host == hostArg);
|
|
});
|
|
if (filteredArray.length > 0) {
|
|
return filteredArray[0];
|
|
}
|
|
else {
|
|
return undefined;
|
|
}
|
|
};
|
|
;
|
|
ssh.prototype.sync = function () {
|
|
this.sshDir.sync(this.sshConfig, this.sshKeys); //call sync method of sshDir class;
|
|
};
|
|
;
|
|
return ssh;
|
|
}());
|
|
exports.ssh = ssh;
|
|
var sshDir = (function () {
|
|
function sshDir(sshDirPathArg) {
|
|
this.path = sshDirPathArg;
|
|
}
|
|
sshDir.prototype.sync = function (sshConfigArg, sshKeysArg) {
|
|
};
|
|
;
|
|
sshDir.prototype.getKeys = function () {
|
|
return helpers.sshKeyArrayFromDir(this.path);
|
|
};
|
|
return sshDir;
|
|
}());
|
|
var sshConfig = (function () {
|
|
function sshConfig() {
|
|
}
|
|
return sshConfig;
|
|
}());
|
|
exports.sshConfig = sshConfig;
|
|
var sshKey = (function () {
|
|
function sshKey(optionsArg) {
|
|
if (optionsArg === void 0) { optionsArg = {}; }
|
|
this.privKey = optionsArg.private;
|
|
this.pubKey = optionsArg.public;
|
|
this.hostVar = optionsArg.host;
|
|
}
|
|
;
|
|
Object.defineProperty(sshKey.prototype, "host", {
|
|
// getters
|
|
get: function () {
|
|
return this.hostVar;
|
|
},
|
|
// setters
|
|
set: function (hostArg) {
|
|
this.hostVar = hostArg;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
;
|
|
Object.defineProperty(sshKey.prototype, "privateKey", {
|
|
get: function () {
|
|
return this.privKey;
|
|
},
|
|
set: function (privateKeyArg) {
|
|
this.privKey = privateKeyArg;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
;
|
|
Object.defineProperty(sshKey.prototype, "privateKeyBase64", {
|
|
get: function () {
|
|
return plugins.base64.encode(this.privKey);
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(sshKey.prototype, "publicKey", {
|
|
get: function () {
|
|
return this.publicKey;
|
|
},
|
|
// setters
|
|
set: function (publicKeyArg) {
|
|
this.pubKey = publicKeyArg;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(sshKey.prototype, "publicKeyBase64", {
|
|
get: function () {
|
|
return plugins.base64.encode(this.pubKey);
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(sshKey.prototype, "type", {
|
|
get: function () {
|
|
if (this.privKey && this.pubKey) {
|
|
return "duplex";
|
|
}
|
|
else if (this.privKey) {
|
|
return "private";
|
|
}
|
|
else if (this.pubKey) {
|
|
return "public";
|
|
}
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
;
|
|
;
|
|
;
|
|
;
|
|
sshKey.prototype.store = function (filePathArg) {
|
|
var filePathObj = plugins.path.parse(filePathArg);
|
|
if (filePathObj.ext = ".priv") {
|
|
plugins.smartfile.memory.toFsSync(this.privKey, { fileName: filePathObj.name + filePathObj.ext, filePath: filePathObj.dir });
|
|
}
|
|
else if (filePathObj.ext = ".pub") {
|
|
plugins.smartfile.memory.toFsSync(this.pubKey, { fileName: filePathObj.name + filePathObj.ext, filePath: filePathObj.dir });
|
|
}
|
|
else {
|
|
plugins.fs.ensureDirSync(filePathObj.dir);
|
|
this.store(plugins.path.join(filePathObj.dir, "key.priv")); // call this function recursivly
|
|
this.store(plugins.path.join(filePathObj.dir, "key.priv")); // call this function recursivly
|
|
}
|
|
};
|
|
return sshKey;
|
|
}());
|
|
exports.sshKey = sshKey;
|
|
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3NoLmNsYXNzZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDRDQUE0QztBQUM1QyxJQUFPLE9BQU8sV0FBVyxvQkFBb0IsQ0FBQyxDQUFDO0FBQy9DLElBQU8sT0FBTyxXQUFXLDRCQUE0QixDQUFDLENBQUM7QUFFdkQ7SUFLSSxhQUFZLFVBQStDO1FBQS9DLDBCQUErQyxHQUEvQyxlQUErQztRQUN2RCxJQUFJLENBQUMsTUFBTSxHQUFHLElBQUksTUFBTSxDQUFDLFVBQVUsQ0FBQyxNQUFNLENBQUMsQ0FBQztRQUM1QyxJQUFJLENBQUMsT0FBTyxHQUFHLElBQUksQ0FBQyxNQUFNLENBQUMsT0FBTyxFQUFFLENBQUM7UUFDckMsSUFBSSxDQUFDLE9BQU8sR0FBRyxVQUFVLENBQUMsT0FBTyxDQUFDO0lBQ3RDLENBQUM7O0lBQ0Qsb0JBQU0sR0FBTixVQUFPLFNBQWdCO1FBQ25CLElBQUksQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxDQUFDO1FBQzdCLElBQUksQ0FBQyxJQUFJLEVBQUUsQ0FBQztJQUNoQixDQUFDOztJQUNELG9CQUFNLEdBQU4sVUFBTyxPQUFjO1FBQ2pCLElBQUksYUFBYSxHQUFHLElBQUksQ0FBQyxPQUFPLENBQUMsTUFBTSxDQUFDLFVBQVMsTUFBTTtZQUNuRCxNQUFNLENBQUMsQ0FBQyxNQUFNLENBQUMsSUFBSSxJQUFJLE9BQU8sQ0FBQyxDQU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gdGhpcy5ob3N0VmFyO1xuICAgIH07XG4gICAgZ2V0IHByaXZhdGVLZXkoKXtcbiAgICAgICAgcmV0dXJuIHRoaXMucHJpdktleTtcbiAgICB9O1xuICAgIGdldCBwcml2YXRlS2V5QmFzZTY0KCl7XG4gICAgICAgIHJldHVybiBwbHVnaW5zLmJhc2U2NC5lbmNvZGUodGhpcy5wcml2S2V5KTtcbiAgICB9XG4gICAgZ2V0IHB1YmxpY0tleSgpe1xuICAgICAgICByZXR1cm4gdGhpcy5wdWJsaWNLZXk7XG4gICAgfVxuICAgIGdldCBwdWJsaWNLZXlCYXNlNjQoKXtcbiAgICAgICAgcmV0dXJuIHBsdWdpbnMuYmFzZTY0LmVuY29kZSh0aGlzLnB1YktleSk7XG4gICAgfVxuICAgIGdldCB0eXBlKCl7XG4gICAgICAgIGlmKHRoaXMucHJpdktleSAmJiB0aGlzLnB1YktleSl7XG4gICAgICAgICAgICByZXR1cm4gXCJkdXBsZXhcIjtcbiAgICAgICAgfSBlbHNlIGlmKHRoaXMucHJpdktleSl7XG4gICAgICAgICAgICByZXR1cm4gXCJwcml2YXRlXCI7XG4gICAgICAgIH0gZWxzZSBpZih0aGlzLnB1YktleSl7XG4gICAgICAgICAgICByZXR1cm4gXCJwdWJsaWNcIjtcbiAgICAgICAgfVxuICAgIH07XG4gICAgXG4gICAgLy8gc2V0dGVyc1xuICAgIHNldCBob3N0KGhvc3RBcmc6c3RyaW5nKXtcbiAgICAgICAgdGhpcy5ob3N0VmFyID0gaG9zdEFyZztcbiAgICB9O1xuICAgIHNldCBwcml2YXRlS2V5KHByaXZhdGVLZXlBcmc6c3RyaW5nKXtcbiAgICAgICAgdGhpcy5wcml2S2V5ID0gcHJpdmF0ZUtleUFyZztcbiAgICB9O1xuICAgIC8vIHNldHRlcnNcbiAgICBzZXQgcHVibGljS2V5KHB1YmxpY0tleUFyZzpzdHJpbmcpe1xuICAgICAgICB0aGlzLnB1YktleSA9IHB1YmxpY0tleUFyZztcbiAgICB9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