started structure

This commit is contained in:
Philipp Kunz 2016-04-25 04:06:20 +02:00
parent 3a21584c70
commit f1babafd38
12 changed files with 247 additions and 1 deletions

3
dist/index.js vendored Normal file
View File

@ -0,0 +1,3 @@
"use strict";
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsImZpbGUiOiJpbmRleC5qcyIsInNvdXJjZXNDb250ZW50IjpbXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=

7
dist/smartssh.classes.helpers.js vendored Normal file
View File

@ -0,0 +1,7 @@
"use strict";
exports.sshKeyArrayFromDir = function (dirArg) {
var sshKeyArray = [];
return sshKeyArray;
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3NoLmNsYXNzZXMuaGVscGVycy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBSVcsMEJBQWtCLEdBQUcsVUFBUyxNQUFhO0lBQ2xELElBQUksV0FBVyxHQUFHLEVBQUUsQ0FBQztJQUNyQixNQUFNLENBQUMsV0FBVyxDQUFDO0FBQ3ZCLENBQUMsQ0FBQSIsImZpbGUiOiJzbWFydHNzaC5jbGFzc2VzLmhlbHBlcnMuanMiLCJzb3VyY2VzQ29udGVudCI6WyIvLy8gPHJlZmVyZW5jZSBwYXRoPVwiLi90eXBpbmdzL21haW4uZC50c1wiIC8+XG5pbXBvcnQgcGx1Z2lucyA9IHJlcXVpcmUoXCIuL3NtYXJ0c3NoLnBsdWdpbnNcIik7XG5pbXBvcnQgY2xhc3NlcyA9IHJlcXVpcmUoXCIuL3NtYXJ0c3NoLmNsYXNzZXNcIik7XG5cbmV4cG9ydCBsZXQgc3NoS2V5QXJyYXlGcm9tRGlyID0gZnVuY3Rpb24oZGlyQXJnOnN0cmluZyk6Y2xhc3Nlcy5zc2hLZXlbXXtcbiAgICBsZXQgc3NoS2V5QXJyYXkgPSBbXTtcbiAgICByZXR1cm4gc3NoS2V5QXJyYXk7XG59Il0sInNvdXJjZVJvb3QiOiIvc291cmNlLyJ9

106
dist/smartssh.classes.js vendored Normal file

File diff suppressed because one or more lines are too long

9
dist/smartssh.plugins.js vendored Normal file
View File

@ -0,0 +1,9 @@
"use strict";
/// <reference path="./typings/main.d.ts" />
exports.beautylog = require("beautylog");
exports.base64 = require("js-base64").Base64;
exports.fs = require("fs-extra");
exports.path = require("path");
exports.smartfile = require("smartfile");
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3NoLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDRDQUE0QztBQUNqQyxpQkFBUyxHQUFHLE9BQU8sQ0FBQyxXQUFXLENBQUMsQ0FBQztBQUNqQyxjQUFNLEdBQUcsT0FBTyxDQUFDLFdBQVcsQ0FBQyxDQUFDLE1BQU0sQ0FBQztBQUNyQyxVQUFFLEdBQUcsT0FBTyxDQUFDLFVBQVUsQ0FBQyxDQUFDO0FBQ3pCLFlBQUksR0FBRyxPQUFPLENBQUMsTUFBTSxDQUFDLENBQUM7QUFDdkIsaUJBQVMsR0FBRyxPQUFPLENBQUMsV0FBVyxDQUFDLENBQUMiLCJmaWxlIjoic21hcnRzc2gucGx1Z2lucy5qcyIsInNvdXJjZXNDb250ZW50IjpbIi8vLyA8cmVmZXJlbmNlIHBhdGg9XCIuL3R5cGluZ3MvbWFpbi5kLnRzXCIgLz5cbmV4cG9ydCBsZXQgYmVhdXR5bG9nID0gcmVxdWlyZShcImJlYXV0eWxvZ1wiKTtcbmV4cG9ydCBsZXQgYmFzZTY0ID0gcmVxdWlyZShcImpzLWJhc2U2NFwiKS5CYXNlNjQ7XG5leHBvcnQgbGV0IGZzID0gcmVxdWlyZShcImZzLWV4dHJhXCIpO1xuZXhwb3J0IGxldCBwYXRoID0gcmVxdWlyZShcInBhdGhcIik7XG5leHBvcnQgbGV0IHNtYXJ0ZmlsZSA9IHJlcXVpcmUoXCJzbWFydGZpbGVcIik7Il0sInNvdXJjZVJvb3QiOiIvc291cmNlLyJ9

View File

@ -20,5 +20,15 @@
"bugs": { "bugs": {
"url": "https://github.com/pushrocks/smartssh/issues" "url": "https://github.com/pushrocks/smartssh/issues"
}, },
"homepage": "https://github.com/pushrocks/smartssh#readme" "homepage": "https://github.com/pushrocks/smartssh#readme",
"dependencies": {
"beautylog": "^4.1.2",
"fs-extra": "^0.28.0",
"js-base64": "^2.1.9",
"smartfile": "^3.0.5"
},
"devDependencies": {
"npmts": "^5.0.4",
"should": "^8.3.1"
}
} }

5
test/test.js Normal file
View File

@ -0,0 +1,5 @@
/// <reference path="../ts/typings/main.d.ts" />
var should = require("should");
var smartssh = require("../dist/index.js");
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsZ0RBQWdEO0FBQ2hELElBQUksTUFBTSxHQUFHLE9BQU8sQ0FBQyxRQUFRLENBQUMsQ0FBQztBQUMvQixJQUFJLFFBQVEsR0FBRyxPQUFPLENBQUMsa0JBQWtCLENBQUMsQ0FBQyIsImZpbGUiOiJ0ZXN0LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4uL3RzL3R5cGluZ3MvbWFpbi5kLnRzXCIgLz5cbmxldCBzaG91bGQgPSByZXF1aXJlKFwic2hvdWxkXCIpO1xubGV0IHNtYXJ0c3NoID0gcmVxdWlyZShcIi4uL2Rpc3QvaW5kZXguanNcIik7XG4iXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=

3
test/test.ts Normal file
View File

@ -0,0 +1,3 @@
/// <reference path="../ts/typings/main.d.ts" />
let should = require("should");
let smartssh = require("../dist/index.js");

3
ts/index.ts Normal file
View File

@ -0,0 +1,3 @@
/// <reference path="./typings/main.d.ts" />
import plugins = require("./smartssh.plugins");
import classes = require("./smartssh.classes");

View File

@ -0,0 +1,8 @@
/// <reference path="./typings/main.d.ts" />
import plugins = require("./smartssh.plugins");
import classes = require("./smartssh.classes");
export let sshKeyArrayFromDir = function(dirArg:string):classes.sshKey[]{
let sshKeyArray = [];
return sshKeyArray;
}

78
ts/smartssh.classes.ts Normal file
View File

@ -0,0 +1,78 @@
/// <reference path="./typings/main.d.ts" />
import plugins = require("./smartssh.plugins");
import helpers = require("./smartssh.classes.helpers");
export class ssh {
private sshDir:string;
private sshKeys:sshKey[];
private sync:boolean; // if set to true, the ssh dir will be kept in sync automatically
constructor(optionsArg:{sshDir?:string,sync?:boolean}={}){
this.sshDir = optionsArg.sshDir
this.sshDir ?
this.sshKeys = helpers.sshKeyArrayFromDir(this.sshDir)
: void(0);
this.sync = optionsArg.sync;
};
}
export class sshConfig {
constructor(){
}
}
export class sshKey {
private privKey:string;
private pubKey:string;
constructor(optionsArg:{private:string,public:string}){
if(!optionsArg) optionsArg = {private:undefined,public:undefined};
this.privKey = optionsArg.private;
this.pubKey = optionsArg.public;
};
// getters
get privateKey(){
return this.privKey;
};
get privateKeyBase64(){
return plugins.base64.encode(this.privKey);
}
get publicKey(){
return this.publicKey;
}
get publicKeyBase64(){
return plugins.base64.encode(this.pubKey);
}
get type(){
if(this.privKey && this.pubKey){
return "duplex";
} else if(this.privKey){
return "private";
} else if(this.pubKey){
return "public";
}
};
// setters
set privateKey(privateKeyArg:string){
this.privKey = privateKeyArg;
};
// setters
set publicKey(publicKeyArg:string){
this.pubKey = publicKeyArg;
};
store(filePathArg?:string){
let 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 { //we assume we are given a directory as filePathArg, so we store the whole key
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
}
}
}

6
ts/smartssh.plugins.ts Normal file
View File

@ -0,0 +1,6 @@
/// <reference path="./typings/main.d.ts" />
export let beautylog = require("beautylog");
export let base64 = require("js-base64").Base64;
export let fs = require("fs-extra");
export let path = require("path");
export let smartfile = require("smartfile");

8
ts/typings.json Normal file
View File

@ -0,0 +1,8 @@
{
"version": false,
"dependencies": {},
"ambientDependencies": {
"colors": "registry:dt/colors#0.6.0-1+20160317120654",
"node": "registry:dt/node#4.0.0+20160423143914"
}
}