smartssh/dist/smartssh.classes.sshkey.js

115 lines
10 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 = {}; }
2016-06-25 00:29:34 +00:00
this._privKey = optionsArg.private;
this._pubKey = optionsArg.public;
this._hostVar = optionsArg.host;
this._authorized = optionsArg.authorized;
}
;
Object.defineProperty(SshKey.prototype, "host", {
2016-06-25 00:29:34 +00:00
// this.host
get: function () {
2016-06-25 00:29:34 +00:00
return this._hostVar;
},
set: function (hostArg) {
2016-06-25 00:29:34 +00:00
this._hostVar = hostArg;
},
enumerable: true,
configurable: true
});
;
2016-06-25 00:29:34 +00:00
;
Object.defineProperty(SshKey.prototype, "privKey", {
// this.privKey
get: function () {
2016-06-25 00:29:34 +00:00
return this._privKey;
},
set: function (privateKeyArg) {
2016-06-25 00:29:34 +00:00
this._privKey = privateKeyArg;
},
enumerable: true,
configurable: true
});
;
2016-06-25 00:29:34 +00:00
;
Object.defineProperty(SshKey.prototype, "privKeyBase64", {
// this.privKeyBase64
get: function () {
2016-06-25 00:29:34 +00:00
return plugins.base64.encode(this._privKey);
},
2016-06-13 22:11:20 +00:00
set: function (privateKeyArg) {
2016-06-25 00:29:34 +00:00
this._privKey = plugins.base64.decode(privateKeyArg);
2016-06-13 22:11:20 +00:00
},
enumerable: true,
configurable: true
});
2016-06-25 00:29:34 +00:00
Object.defineProperty(SshKey.prototype, "pubKey", {
// this.pubKey
get: function () {
2016-06-25 00:29:34 +00:00
return this._pubKey;
},
set: function (publicKeyArg) {
2016-06-25 00:29:34 +00:00
this._pubKey = publicKeyArg;
},
enumerable: true,
configurable: true
});
2016-06-25 00:29:34 +00:00
;
Object.defineProperty(SshKey.prototype, "pubKeyBase64", {
// this.pubKeyBase64
get: function () {
2016-06-25 00:29:34 +00:00
return plugins.base64.encode(this._pubKey);
},
2016-06-13 22:11:20 +00:00
set: function (publicKeyArg) {
2016-06-25 00:29:34 +00:00
this._pubKey = plugins.base64.decode(publicKeyArg);
2016-06-13 22:11:20 +00:00
},
enumerable: true,
configurable: true
});
Object.defineProperty(SshKey.prototype, "type", {
get: function () {
2016-06-25 00:29:34 +00:00
if (this._privKey && this._pubKey) {
return "duplex";
}
2016-06-25 00:29:34 +00:00
else if (this._privKey) {
return "private";
}
2016-06-25 00:29:34 +00:00
else if (this._pubKey) {
return "public";
}
},
2016-06-25 00:29:34 +00:00
set: function (someVlueArg) {
console.log("the type of an SshKey connot be set. This value is autpcomputed.");
},
enumerable: true,
configurable: true
});
;
2016-06-25 00:29:34 +00:00
// methods
SshKey.prototype.read = function (filePathArg) {
};
SshKey.prototype.store = function (filePathArg) {
var filePathObj = plugins.path.parse(filePathArg);
if (filePathObj.ext = ".priv") {
2016-06-25 00:29:34 +00:00
plugins.smartfile.memory.toFsSync(this._privKey, filePathArg);
}
else if (filePathObj.ext = ".pub") {
2016-06-25 00:29:34 +00:00
plugins.smartfile.memory.toFsSync(this._pubKey, filePathArg);
}
else {
plugins.fs.ensureDirSync(filePathObj.dir);
this.store(plugins.path.join(filePathObj.dir, "key.priv")); // call this function recursivly
2016-06-13 22:27:55 +00:00
this.store(plugins.path.join(filePathObj.dir, "key.pub")); // call this function recursivly
}
};
return SshKey;
}());
exports.SshKey = SshKey;
2016-06-25 00:29:34 +00:00
var testKey = new SshKey();
2016-06-25 00:29:34 +00:00
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3NoLmNsYXNzZXMuc3Noa2V5LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFDeEIsSUFBWSxPQUFPLFdBQU0sb0JBQW9CLENBQUMsQ0FBQTtBQUc5QztJQUtJLGdCQUFZLFVBQStFO1FBQS9FLDBCQUErRSxHQUEvRSxlQUErRTtRQUN2RixJQUFJLENBQUMsU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