smartssh/dist/smartssh.classes.js

107 lines
10 KiB
JavaScript
Raw Normal View History

2016-04-25 02:06:20 +00:00
"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 = optionsArg.sshDir;
this.sshDir ?
this.sshKeys = helpers.sshKeyArrayFromDir(this.sshDir)
: void (0);
this.sync = optionsArg.sync;
}
;
return ssh;
}());
exports.ssh = ssh;
var sshConfig = (function () {
function sshConfig() {
}
return sshConfig;
}());
exports.sshConfig = sshConfig;
var sshKey = (function () {
function sshKey(optionsArg) {
if (!optionsArg)
optionsArg = { private: undefined, public: undefined };
this.privKey = optionsArg.private;
this.pubKey = optionsArg.public;
}
;
Object.defineProperty(sshKey.prototype, "privateKey", {
// getters
get: function () {
return this.privKey;
},
// setters
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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3NoLmNsYXNzZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDRDQUE0QztBQUM1QyxJQUFPLE9BQU8sV0FBVyxvQkFBb0IsQ0FBQyxDQUFDO0FBQy9DLElBQU8sT0FBTyxXQUFXLDRCQUE0QixDQUFDLENBQUM7QUFFdkQ7SUFJSSxhQUFZLFVBQTRDO1FBQTVDLDBCQUE0QyxHQUE1QyxlQUE0QztRQUNwRCxJQUFJLENBQUMsTUFBTSxHQUFHLFVBQVUsQ0FBQyxNQUFNLENBQUE7UUFDL0IsSUFBSSxDQUFDLE1BQU07WUFDUCxJQUFJLENBQUMsT0FBTyxHQUFHLE9BQU8sQ0FBQyxrQkFBa0IsQ0FBQyxJQUFJLENBQUMsTUFBTSxDQUFDO2NBQ3BELEtBQUksQ0FBQyxDQUFDLENBQUMsQ0FBQztRQUNkLElBQUksQ0FBQyxJQUFJLEdBQUcsVUFBVSxDQUFDLElBQUksQ0FBQztJQUNoQyxDQUFDOztJQUVMLFVBQUM7QUFBRCxDQVpBLEFBWUMsSUFBQTtBQVpZLFdBQUcsTUFZZixDQUFBO0FBRUQ7SUFDSTtJQUVBLENBQUM7SUFDTCxnQkFBQztBQUFELENBSkEsQUFJQyxJQUFBO0FBSlksaUJBQVMsWUFJckIsQ0FBQTtBQUVEO0lBR0ksZ0JBQVksVUFBeUM7UUFDakQsRUFBRSxDQUFBLENBQUMsQ0FBQyxVQUFVLENBQUM7WUFBQyxVQUFVLEdBQUcsRUF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