"use strict"; /// 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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3NoLmNsYXNzZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDRDQUE0QztBQUM1QyxJQUFPLE9BQU8sV0FBVyxvQkFBb0IsQ0FBQyxDQUFDO0FBQy9DLElBQU8sT0FBTyxXQUFXLDRCQUE0QixDQUFDLENBQUM7QUFFdkQ7SUFJSSxhQUFZLFVBQTRDO1FBQTVDLDBCQUE0QyxHQUE1QyxlQUE0QztRQUNwRCxJQUFJLENBQUMsTUFBTSxHQUFHLFVBQVUsQ0FBQyxNQUFNLENBQUE7UUFDL0IsSUFBSSxDQUFDLE1BQU07WUFDUCxJQUFJLENBQUMsT0FBTyxHQUFHLE9BQU8sQ0FBQyxrQkFBa0IsQ0FBQyxJQUFJLENBQUMsTUFBTSxDQUFDO2NBQ3BELEtBQUksQ0FBQyxDQUFDLENBQUMsQ0FBQztRQUNkLElBQUksQ0FBQyxJQUFJLEdBQUcsVUFBVSxDQUFDLElBQUksQ0FBQztJQUNoQyxDQUFDOztJQUVMLFVBQUM7QUFBRCxDQVpBLEFBWUMsSUFBQTtBQVpZLFdBQUcsTUFZZixDQUFBO0FBRUQ7SUFDSTtJQUVBLENBQUM7SUFDTCxnQkFBQztBQUFELENBSkEsQUFJQyxJQUFBO0FBSlksaUJBQVMsWUFJckIsQ0FBQTtBQUVEO0lBR0ksZ0JBQVksVUFBeUM7UUFDakQsRUFBRSxDQUFBLENBQUMsQ0FBQyxVQUFVLENBQUM7WUFBQyxVQUFVLEdBQUcsRUFBQyxPQUFPLEVBQUMsU0FBUyxFQUFDLE1BQU0sRUFBQyxTQUFTLEVBQUMsQ0FBQztRQUNsRSxJQUFJLENBQUMsT0FBTyxHQUFHLFVBQVUsQ0FBQyxPQUFPLENBQUM7UUFDbEMsSUFBSSxDQUFDLE1BQU0s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