smartssh/dist/smartssh.classes.sshkey.js

99 lines
9.1 KiB
JavaScript
Raw Normal View History

"use strict";
require("typings-global");
var plugins = require("./smartssh.plugins");
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")); //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