3 Commits

Author SHA1 Message Date
9b3af8a50a 1.0.4 2016-06-01 04:18:40 +02:00
78aa36c2be added more tests 2016-06-01 04:18:31 +02:00
09d96fd94c update directory sync 2016-06-01 03:57:17 +02:00
14 changed files with 138 additions and 88 deletions

View File

@ -1,4 +1,3 @@
import "typings-global"; import "typings-global";
import { SshKey } from "./smartssh.classes.sshkey"; import { SshKey } from "./smartssh.classes.sshkey";
export declare let sshKeyArrayFromDir: (dirArg: string) => SshKey[]; export declare let sshKeyArrayFromDir: (dirArg: string) => SshKey[];
export declare let getKeyIndex: (hostArg: string) => number;

View File

@ -4,8 +4,5 @@ exports.sshKeyArrayFromDir = function (dirArg) {
var sshKeyArray = []; //TODO var sshKeyArray = []; //TODO
return sshKeyArray; return sshKeyArray;
}; };
exports.getKeyIndex = function (hostArg) {
return 0; //TODO
};
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3NoLmNsYXNzZXMuaGVscGVycy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsUUFBTyxnQkFDUCxDQUFDLENBRHNCO0FBSVosMEJBQWtCLEdBQUcsVUFBUyxNQUFhO0lBQ2xELElBQUksV0FBVyxHQUFHLEVBQUUsQ0FBQyxDQUFDLE1BQU07SUFDNUIsTUFBTSxDQUFDLFdBQVcsQ0FBQztBQUN2QixDQUFDLENBQUE7QUFFVSxtQkFBVyxHQUFHLFVBQVMsT0FBYztJQUM1QyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsT0FBTztBQUNyQixDQUFDLENBQUEiLCJmaWxlIjoic21hcnRzc2guY2xhc3Nlcy5oZWxwZXJzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFwidHlwaW5ncy1nbG9iYWxcIlxyXG5pbXBvcnQgKiBhcyBwbHVnaW5zIGZyb20gXCIuL3NtYXJ0c3NoLnBsdWdpbnNcIjtcclxuaW1wb3J0IHt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9ET1xyXG4gICAgcmV0dXJuIHNzaEtleUFycmF5O1xyXG59Il19

View File

@ -3,8 +3,9 @@ import { SshInstance } from "./smartssh.classes.sshinstance";
import { SshKey } from "./smartssh.classes.sshkey"; import { SshKey } from "./smartssh.classes.sshkey";
export declare class SshDir { export declare class SshDir {
path: string; path: string;
constructor(sshDirPathArg: string); sshInstance: SshInstance;
syncToDir(sshInstanceArg: SshInstance): void; constructor(sshInstanceArg: SshInstance, sshDirPathArg?: string);
syncToDir(): void;
syncFromDir(): void; syncFromDir(): void;
getKeys(): SshKey[]; getKeys(): SshKey[];
} }

View File

@ -3,7 +3,7 @@ require("typings-global");
var plugins = require("./smartssh.plugins"); var plugins = require("./smartssh.plugins");
var helpers = require("./smartssh.classes.helpers"); var helpers = require("./smartssh.classes.helpers");
var SshDir = (function () { var SshDir = (function () {
function SshDir(sshDirPathArg) { function SshDir(sshInstanceArg, sshDirPathArg) {
var sshDirPath; var sshDirPath;
if (sshDirPathArg) { if (sshDirPathArg) {
sshDirPath = sshDirPathArg; sshDirPath = sshDirPathArg;
@ -13,7 +13,7 @@ var SshDir = (function () {
} }
this.path = sshDirPath; this.path = sshDirPath;
} }
SshDir.prototype.syncToDir = function (sshInstanceArg) { SshDir.prototype.syncToDir = function () {
}; };
; ;
SshDir.prototype.syncFromDir = function () { SshDir.prototype.syncFromDir = function () {
@ -25,4 +25,4 @@ var SshDir = (function () {
}()); }());
exports.SshDir = SshDir; exports.SshDir = SshDir;
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3NoLmNsYXNzZXMuc3NoZGlyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFDeEIsSUFBWSxPQUFPLFdBQU0sb0JBQW9CLENBQUMsQ0FBQTtBQUM5QyxJQUFZLE9BQU8sV0FBTSw0QkFBNEIsQ0FBQyxDQUFB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XHJcbmltcG9ydCB7U3NoQ29uZmlnfSBmcm9tIFwiLi9zbWFydHNzaC5jbGFzc2VzLnNzaGNvbmZpZ1wiO1xyXG5leHBvcnQgY2xhc3MgU3NoRGlyIHsgLy8gc3NoRGlyIGNsYXNzIC0+IE5PVCBFWFBPUlRFRCwgT05MWSBGT1IgSU5URVJOQUwgVVNFXHJcbiAgICBwYXRoOnN0cmluZzsgLy8gdGhlIHBhdGggb2YgdGhlIHNzaCBkaXJlY3RvcnlcclxuICAgIGNvbnN0cnVjdG9yKHNzaERpclBhdGhBcmc6c3RyaW5nKXtcclxuICAgICAgICBsZXQgc3NoRGlyUGF0aDpzdHJpbmc7XHJcbiAgICAgICAgaWYoc3NoRGlyUGF0aEFyZyl7XHJcbiAgICAgICAgICAgIHNzaERpclBhdGggPSBzc2hEaXJQYXRoQXJnO1xyXG4gICAgICAgIH0gZWxzZSB7XHJcbiAgICAgICAgICAgIHNzaERpclBhdGggPSBwbHVnaW5zLnNtYXJ0cGF0aC5nZXQuaG9tZSgpO1xyXG4gICAgICAgIH1cclxuICAgICAgICB0aGlzLnBhdGggPSBzc2hEaXJQYXRoO1xyXG4gICAgfVxyXG4gICAgc3luY1RvRGlyKHNzaEluc3RhbmNlQXJnOlNzaEluc3RhbmNlKXsgLy9zeW5jcyBcclxuICAgICAgICBcclxuICAgIH07XHJcbiAgICBzeW5jRnJvbURpcigpe1xyXG4gICAgICAgIFxyXG4gICAgfVxyXG4gICAgZ2V0S2V5cygpe1xyXG4gICAgICAgIHJldHVybiBoZWxwZXJzLnNzaEtleUFycmF5RnJvbURpcih0aGlzLnBhdGgpO1xyXG4gICAgfVxyXG59Il19 //# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3NoLmNsYXNzZXMuc3NoZGlyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFDe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c2hpbnN0YW5jZVwiO1xyXG5pbXBvcnQge1NzaEtleX0gZnJvbSBcIi4vc21hcnRzc2guY2xhc3Nlcy5zc2hrZXlcIjtcclxuaW1wb3J0IHtTc2hDb25maWd9IGZyb20gXCIuL3NtYXJ0c3NoLmNsYXNzZXMuc3NoY29uZmlnXCI7XHJcbmV4cG9ydCBjbGFzcyBTc2hEaXIgeyAvLyBzc2hEaXIgY2xhc3MgLT4gTk9UIEVYUE9SVEVELCBPTkxZIEZPUiBJTlRFUk5BTCBVU0VcclxuICAgIHBhdGg6c3RyaW5nOyAvLyB0aGUgcGF0aCBvZiB0aGUgc3NoIGRpcmVjdG9yeVxyXG4gICAgc3NoSW5zdGFuY2U6U3NoSW5zdGFuY2U7XHJcbiAgICBjb25zdHJ1Y3Rvcihzc2hJbnN0YW5jZUFyZzpTc2hJbnN0YW5jZSxzc2hEaXJQYXRoQXJnPzpzdHJpbmcpe1xyXG4gICAgICAgIGxldCBzc2hEaXJQYXRoOnN0cmluZztcclxuICAgICAgICBpZihzc2hEaXJQYXRoQXJnKXtcclxuICAgICAgICAgICAgc3NoRGlyUGF0aCA9IHNzaERpclBhdGhBcmc7XHJcbiAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgc3NoRGlyUGF0aCA9IHBsdWdpbnMuc21hcnRwYXRoLmdldC5ob21lKCk7XHJcbiAgICAgICAgfVxyXG4gICAgICAgIHRoaXMucGF0aCA9IHNzaERpclBhdGg7XHJcbiAgICB9XHJcbiAgICBzeW5jVG9EaXIoKXsgLy9zeW5jcyBcclxuICAgICAgICBcclxuICAgIH07XHJcbiAgICBzeW5jRnJvbURpcigpe1xyXG4gICAgICAgIFxyXG4gICAgfVxyXG4gICAgZ2V0S2V5cygpe1xyXG4gICAgICAgIHJldHVybiBoZWxwZXJzLnNzaEtleUFycmF5RnJvbURpcih0aGlzLnBhdGgpO1xyXG4gICAgfVxyXG59Il19

View File

@ -3,16 +3,16 @@ import { SshKey } from "./smartssh.classes.sshkey";
export declare class SshInstance { export declare class SshInstance {
private sshConfig; private sshConfig;
private sshDir; private sshDir;
private sshKeys; private sshKeyArray;
private sshSync; private sshSync;
constructor(optionsArg?: { constructor(optionsArg?: {
sshDir?: string; sshDirPath?: string;
sshSync?: boolean; sshSync?: boolean;
}); });
addKey(sshKeyArg: SshKey): void; addKey(sshKeyArg: SshKey): void;
getKey(hostArg: string): SshKey;
getKeys(): SshKey[];
removeKey(sshKeyArg: SshKey): void; removeKey(sshKeyArg: SshKey): void;
replaceKey(sshKeyOldArg: SshKey, sshKeyNewArg: SshKey): void; replaceKey(sshKeyOldArg: SshKey, sshKeyNewArg: SshKey): void;
sync(): void; getKey(hostArg: string): SshKey;
sshKeys: SshKey[];
sync(directionArg: string): void;
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{ {
"name": "smartssh", "name": "smartssh",
"version": "1.0.3", "version": "1.0.4",
"description": "setups SSH quickly and in a painless manner", "description": "setups SSH quickly and in a painless manner",
"main": "dist/index.js", "main": "dist/index.js",
"scripts": { "scripts": {

File diff suppressed because one or more lines are too long

View File

@ -5,11 +5,11 @@ describe("smartssh",function(){
let testSshInstance:smartssh.SshInstance; let testSshInstance:smartssh.SshInstance;
let testSshKey:smartssh.SshKey; let testSshKey:smartssh.SshKey;
describe("SshInstance",function(){ describe("SshInstance",function(){
it("should create a new SshInstance object from class",function(){ it("'new' keyword should create a new SshInstance object from class",function(){
testSshInstance = new smartssh.SshInstance(); testSshInstance = new smartssh.SshInstance();
testSshInstance.should.be.instanceof(smartssh.SshInstance); testSshInstance.should.be.instanceof(smartssh.SshInstance);
}); });
it("should accept a new SshKey object",function(){ it(".addKey() should accept a new SshKey object",function(){
testSshInstance.addKey(new smartssh.SshKey({ testSshInstance.addKey(new smartssh.SshKey({
public:"somePublicKey", public:"somePublicKey",
private:"somePrivateKey", private:"somePrivateKey",
@ -21,13 +21,24 @@ describe("smartssh",function(){
host:"bitbucket.org" host:"bitbucket.org"
})); }));
testSshInstance.addKey(new smartssh.SshKey({ testSshInstance.addKey(new smartssh.SshKey({
public:"somePublicKey", public:"someGitHubPublicKey",
private:"somePrivateKey", private:"someGitHubPrivateKey",
host:"github.com" host:"github.com"
})); }));
}); });
it("should return an array of sshKeys",function(){ it(".sshKeys should point to an array of sshKeys",function(){
testSshInstance.getKeys(); let sshKeyArray = testSshInstance.sshKeys;
sshKeyArray.should.be.Array();
sshKeyArray[0].host.should.equal("gitlab.com");
sshKeyArray[1].host.should.equal("bitbucket.org");
sshKeyArray[2].host.should.equal("github.com");
}); });
it(".getKey() should get a specific key selected by host",function(){
testSshInstance.getKey("github.com").publicKey.should.equal("someGitHubPublicKey");
})
it(".removeKey() should remove a key",function(){
testSshInstance.removeKey(testSshInstance.getKey("bitbucket.org"));
testSshInstance.sshKeys[1].host.should.equal("github.com");
})
}) })
}) })

View File

@ -6,7 +6,3 @@ export let sshKeyArrayFromDir = function(dirArg:string):SshKey[]{
let sshKeyArray = []; //TODO let sshKeyArray = []; //TODO
return sshKeyArray; return sshKeyArray;
} }
export let getKeyIndex = function(hostArg:string){
return 0; //TODO
}

View File

@ -6,7 +6,8 @@ import {SshKey} from "./smartssh.classes.sshkey";
import {SshConfig} from "./smartssh.classes.sshconfig"; import {SshConfig} from "./smartssh.classes.sshconfig";
export class SshDir { // sshDir class -> NOT EXPORTED, ONLY FOR INTERNAL USE export class SshDir { // sshDir class -> NOT EXPORTED, ONLY FOR INTERNAL USE
path:string; // the path of the ssh directory path:string; // the path of the ssh directory
constructor(sshDirPathArg:string){ sshInstance:SshInstance;
constructor(sshInstanceArg:SshInstance,sshDirPathArg?:string){
let sshDirPath:string; let sshDirPath:string;
if(sshDirPathArg){ if(sshDirPathArg){
sshDirPath = sshDirPathArg; sshDirPath = sshDirPathArg;
@ -15,7 +16,7 @@ export class SshDir { // sshDir class -> NOT EXPORTED, ONLY FOR INTERNAL USE
} }
this.path = sshDirPath; this.path = sshDirPath;
} }
syncToDir(sshInstanceArg:SshInstance){ //syncs syncToDir(){ //syncs
}; };
syncFromDir(){ syncFromDir(){

View File

@ -9,20 +9,43 @@ import {SshKey} from "./smartssh.classes.sshkey";
export class SshInstance { export class SshInstance {
private sshConfig:SshConfig; // sshConfig (e.g. represents ~/.ssh/config) private sshConfig:SshConfig; // sshConfig (e.g. represents ~/.ssh/config)
private sshDir:SshDir; // points to sshDir class instance. private sshDir:SshDir; // points to sshDir class instance.
private sshKeys:SshKey[]; //holds all ssh keys private sshKeyArray:SshKey[]; //holds all ssh keys
private sshSync:boolean; // if set to true, the ssh dir will be kept in sync automatically private sshSync:boolean; // if set to true, the ssh dir will be kept in sync automatically
constructor(optionsArg:{sshDir?:string,sshSync?:boolean}={}){ constructor(optionsArg:{sshDirPath?:string,sshSync?:boolean}={}){
optionsArg ? void(0) : optionsArg = {}; optionsArg ? void(0) : optionsArg = {};
this.sshDir = new SshDir(optionsArg.sshDir);
this.sshKeys = this.sshDir.getKeys(); this.sshDir = new SshDir(this,optionsArg.sshDirPath);
this.sshKeyArray = this.sshDir.getKeys();
this.sshSync = optionsArg.sshSync; this.sshSync = optionsArg.sshSync;
}; };
//altering methods
addKey(sshKeyArg:SshKey){ addKey(sshKeyArg:SshKey){
this.sshKeys.push(sshKeyArg); this.sync("from");
this.sync(); this.sshKeyArray.push(sshKeyArg);
this.sync("to");
}; };
getKey(hostArg:string){ removeKey(sshKeyArg:SshKey){
let filteredArray = this.sshKeys.filter(function(keyArg){ this.sync("from");
let filteredArray = this.sshKeyArray.filter((sshKeyArg2:SshKey) => {
return (sshKeyArg != sshKeyArg2);
});
this.sshKeyArray = filteredArray;
this.sync("to");
};
replaceKey(sshKeyOldArg:SshKey,sshKeyNewArg:SshKey){
this.sync("from");
let filteredArray = this.sshKeyArray.filter((sshKeyArg:SshKey) => {
return (sshKeyArg.host == "some"); //TODO
});
this.sshKeyArray = filteredArray;
this.sync("to");
};
//
getKey(hostArg:string):SshKey{
this.sync("from");
let filteredArray = this.sshKeyArray.filter(function(keyArg){
return (keyArg.host == hostArg); return (keyArg.host == hostArg);
}); });
if(filteredArray.length > 0){ if(filteredArray.length > 0){
@ -31,24 +54,16 @@ export class SshInstance {
return undefined; return undefined;
} }
}; };
get sshKeys():SshKey[] {
getKeys(){ return this.sshKeyArray;
return this.sshKeys;
} }
sync(directionArg:string){
removeKey(sshKeyArg:SshKey){ if(this.sshSync && directionArg == "from"){
let keyIndex = helpers.getKeyIndex(sshKeyArg.host); this.sshDir.syncFromDir(); // call sync method of sshDir class;
this.sshKeys.splice(keyIndex,1); } else if(this.sshSync && directionArg == "to") {
this.sync(); this.sshDir.syncToDir();
}; } else if(this.sshSync) {
replaceKey(sshKeyOldArg:SshKey,sshKeyNewArg:SshKey){ throw new Error("directionArg not recognised. Must be 'to' or 'from'");
let keyIndex = helpers.getKeyIndex(sshKeyOldArg.host);
this.sshKeys.splice(keyIndex,1,sshKeyNewArg);
this.sync();
};
sync(){
if(this.sshSync){
this.sshDir.sync(this.sshConfig,this.sshKeys); // call sync method of sshDir class;
} }
}; };
} }

View File

@ -23,7 +23,7 @@ export class SshKey {
return plugins.base64.encode(this.privKey); return plugins.base64.encode(this.privKey);
} }
get publicKey(){ get publicKey(){
return this.publicKey; return this.pubKey;
} }
get publicKeyBase64(){ get publicKeyBase64(){
return plugins.base64.encode(this.pubKey); return plugins.base64.encode(this.pubKey);