45 Commits

Author SHA1 Message Date
742bf694e4 1.1.3 2016-06-26 04:07:37 +02:00
38165f11db some updates 2016-06-26 04:07:03 +02:00
ef2b31b4b2 1.1.2 2016-06-25 15:31:03 +02:00
5b1f800067 update structure 2016-06-25 15:30:57 +02:00
6339a3ed9b update SshKey.store() 2016-06-25 14:13:26 +02:00
bf27aaf167 update structure 2016-06-25 13:07:24 +02:00
9bc3aea59c 1.1.1 2016-06-25 02:53:09 +02:00
f5ff302d4d updated structure of SshConfig 2016-06-25 02:53:05 +02:00
cac8203bf5 1.1.0 2016-06-25 02:29:51 +02:00
e4532271cc major structural update 2016-06-25 02:29:34 +02:00
faf6c91199 update 2016-06-25 02:10:53 +02:00
d0009e7a9c update stucture 2016-06-24 20:58:55 +02:00
da76df2c3e 1.0.7 2016-06-24 02:50:02 +02:00
a43976110a update structure 2016-06-24 02:49:55 +02:00
c3ee35a699 1.0.6 2016-06-14 00:34:07 +02:00
a0ce759552 update links in package.json to point to gitlab 2016-06-14 00:33:59 +02:00
201d5cc6d7 some restructuring 2016-06-14 00:27:55 +02:00
e5bdfff743 added ability to add keys as base 64 2016-06-14 00:11:20 +02:00
967c9fd9d1 now using legacy tag in gitlab-ci.yml 2016-06-13 23:31:41 +02:00
35da2f0b73 strip pages from gitlab-ci for now 2016-06-13 23:29:37 +02:00
5e991a4e4f update gitlab ci base image 2016-06-13 23:26:54 +02:00
0f75f5238c update dependencies 2016-06-13 23:26:36 +02:00
e8f3047ac0 1.0.5 2016-06-01 05:18:08 +02:00
812d28ee3d add typings to package.json 2016-06-01 05:17:49 +02:00
fa301eea71 improved tests and reached 80% coverage milestone. 2016-06-01 05:09:20 +02:00
48ccf317d6 update some cosmetics 2016-06-01 04:25:59 +02:00
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
f4f60a685d 1.0.3 2016-06-01 02:48:45 +02:00
904129706c add some tests 2016-06-01 02:48:38 +02:00
9a96bbd266 update gitlab ci yml 2016-06-01 02:35:12 +02:00
39abfd760b start tests 2016-06-01 02:31:29 +02:00
1b30aa428e update gitlab-ci yml 2016-06-01 01:00:29 +02:00
41613c0b93 update ci yml 2016-06-01 00:59:02 +02:00
2d14617b13 rename Ssh class to SshInstance 2016-06-01 00:56:24 +02:00
3106945b47 update gitlab ci yml 2016-05-31 19:50:43 +02:00
2284620387 1.0.2 2016-05-31 19:16:52 +02:00
cd6bcb974c made all classes start with capital letters 2016-05-31 19:16:45 +02:00
eb66ed0244 restructure class files 2016-05-31 19:00:52 +02:00
d12c7ab621 update typings to use typings-global and typings-test, update dependencies 2016-05-31 18:48:46 +02:00
84374299cf latest status 2016-04-28 00:09:17 +02:00
b73928109b improve sync triggering 2016-04-26 05:09:03 +02:00
1d17dd1b84 add removeKey and replaceKey methods 2016-04-26 05:04:36 +02:00
1663d9a266 add some logic 2016-04-26 04:44:50 +02:00
33 changed files with 935 additions and 230 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@ docs/
ts/typings/
ts/*.js
ts/*.js.map
test/temp/

38
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,38 @@
image: hosttoday/ht-docker-node:npmts
stages:
- test
- release
- page
testLTS:
stage: test
script:
- npmci test lts
tags:
- docker
- lossless
testSTABLE:
stage: test
script:
- npmci test stable
tags:
- docker
- lossless
testLEGACY:
stage: test
script:
- npmci test legacy
allow_failure: true
release:
stage: release
script:
- npmci publish
only:
- tags
tags:
- docker
- lossless

5
Dockerfile Normal file
View File

@ -0,0 +1,5 @@
FROM hosttoday/ht-docker-node:npmts
COPY ./ /node-app
WORKDIR /node-app
RUN npm install
RUN npmts

View File

@ -2,7 +2,6 @@
setups SSH quickly and in a painless manner
> Attention: This is still alpha, so some things won't work, not all things are inplemented.
I (Phil from Lossless) expect this to be ready 2016/05/01.
## Usage
@ -16,18 +15,20 @@ var sshInstance = new smartssh.sshInstance({
sshInstance.addKey(new smartssh.sshKey({
private: "somestring",
public: "somestring", // optional
for:"github.com",
host:"github.com",
encoding: "base64" // optional, defaults to "utf8", can be "utf8" or "base64", useful for reading ssh keys from environment variables
}));
sshInstance.removeKey(sshInstance.getKey("github.com")); // removes key for host "github.com" is present
sshInstance.createKey({
for:"gitlab.com" // returns new key in the form sshKey, read more about the sshKey class below
host:"gitlab.com" // returns new key in the form sshKey, read more about the sshKey class below
})
sshInstance.getKey({ // returns ssh key in the form sshKey, read more about the sshKey class below
for:"github.com"
host:"github.com"
});
sshInstance.getKeys() // returns array of all available getKeys. Each key is in form of class sshKey
```
```

5
dist/index.d.ts vendored Normal file
View File

@ -0,0 +1,5 @@
import "typings-global";
export { SshInstance } from "./smartssh.classes.sshinstance";
export { SshKey } from "./smartssh.classes.sshkey";
export { SshDir } from "./smartssh.classes.sshdir";
export { SshConfig } from "./smartssh.classes.sshconfig";

11
dist/index.js vendored
View File

@ -1,3 +1,12 @@
"use strict";
require("typings-global");
var smartssh_classes_sshinstance_1 = require("./smartssh.classes.sshinstance");
exports.SshInstance = smartssh_classes_sshinstance_1.SshInstance;
var smartssh_classes_sshkey_1 = require("./smartssh.classes.sshkey");
exports.SshKey = smartssh_classes_sshkey_1.SshKey;
var smartssh_classes_sshdir_1 = require("./smartssh.classes.sshdir");
exports.SshDir = smartssh_classes_sshdir_1.SshDir;
var smartssh_classes_sshconfig_1 = require("./smartssh.classes.sshconfig");
exports.SshConfig = smartssh_classes_sshconfig_1.SshConfig;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsImZpbGUiOiJpbmRleC5qcyIsInNvdXJjZXNDb250ZW50IjpbXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUNQLENBQUMsQ0FEc0I7QUFHdkIsNkNBQTBCLGdDQUFnQyxDQUFDO0FBQW5ELGlFQUFtRDtBQUMzRCx3Q0FBcUIsMkJBQTJCLENBQUM7QUFBekMsa0RBQXlDO0FBQ2pELHdDQUFxQiwyQkFBMkIsQ0FBQztBQUF6QyxrREFBeUM7QUFDakQsMkNBQXdCLDhCQUE4QixDQUFDO0FBQS9DLDJEQUErQyIsImZpbGUiOiJpbmRleC5qcyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBcInR5cGluZ3MtZ2xvYmFsXCJcbmltcG9ydCAqIGFzIHBsdWdpbnMgZnJvbSBcIi4vc21hcnRzc2gucGx1Z2luc1wiO1xuXG5leHBvcnQge1NzaEluc3RhbmNlfSBmcm9tIFwiLi9zbWFydHNzaC5jbGFzc2VzLnNzaGluc3RhbmNlXCI7XG5leHBvcnQge1NzaEtleX0gZnJvbSBcIi4vc21hcnRzc2guY2xhc3Nlcy5zc2hrZXlcIjtcbmV4cG9ydCB7U3NoRGlyfSBmcm9tIFwiLi9zbWFydHNzaC5jbGFzc2VzLnNzaGRpclwiO1xuZXhwb3J0IHtTc2hDb25maWd9IGZyb20gXCIuL3NtYXJ0c3NoLmNsYXNzZXMuc3NoY29uZmlnXCI7Il19

3
dist/smartssh.classes.helpers.d.ts vendored Normal file
View File

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

View File

@ -1,7 +1,8 @@
"use strict";
require("typings-global");
exports.sshKeyArrayFromDir = function (dirArg) {
var sshKeyArray = [];
var sshKeyArray = []; //TODO
return sshKeyArray;
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3NoLmNsYXNzZXMuaGVscGVycy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBSVcsMEJBQWtC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yBmcm9tIFwiLi9zbWFydHNzaC5wbHVnaW5zXCI7XG5pbXBvcnQge1NzaEtleX0gZnJvbSBcIi4vc21hcnRzc2guY2xhc3Nlcy5zc2hrZXlcIjtcblxuZXhwb3J0IGxldCBzc2hLZXlBcnJheUZyb21EaXIgPSBmdW5jdGlvbihkaXJBcmc6c3RyaW5nKTpTc2hLZXlbXXtcbiAgICBsZXQgc3NoS2V5QXJyYXkgPSBbXTsgLy9UT0RPXG4gICAgcmV0dXJuIHNzaEtleUFycmF5O1xufSJdfQ==

File diff suppressed because one or more lines are too long

16
dist/smartssh.classes.sshconfig.d.ts vendored Normal file
View File

@ -0,0 +1,16 @@
import "typings-global";
import { SshKey } from "./smartssh.classes.sshkey";
export declare class SshConfig {
sshKeyArray: SshKey[];
constructor(sshKeyArrayArg: SshKey[]);
/**
* stores a config file
*/
store(dirPathArg: string): any;
read(dirPathArg: any): any;
}
export interface configObject {
configString: string;
authorized: boolean;
sshKey: SshKey;
}

47
dist/smartssh.classes.sshconfig.js vendored Normal file
View File

@ -0,0 +1,47 @@
"use strict";
require("typings-global");
var plugins = require("./smartssh.plugins");
var SshConfig = (function () {
function SshConfig(sshKeyArrayArg) {
this.sshKeyArray = sshKeyArrayArg;
}
/**
* stores a config file
*/
SshConfig.prototype.store = function (dirPathArg) {
var done = plugins.q.defer();
var configArray;
var configString;
for (var key in this.sshKeyArray) {
var sshKey = this.sshKeyArray[key];
if (sshKey.host) {
configString = "Host " + sshKey.host + "\n" +
" HostName " + sshKey.host + "\n" +
" IdentityFile ~/.ssh/" + sshKey.host + "\n";
}
configArray.push({
configString: configString,
authorized: sshKey.authorized,
sshKey: sshKey
});
}
var configFile = "";
for (var key in configArray) {
configFile = configFile + configArray[key].configString + "\n";
}
;
plugins.smartfile.memory.toFsSync(configFile, dirPathArg);
return done.promise;
};
SshConfig.prototype.read = function (dirPathArg) {
var done = plugins.q.defer();
var configArray;
return done.promise;
};
return SshConfig;
}());
exports.SshConfig = SshConfig;
;
;
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Fzc2VzLnNzaGtleVwiXG5cbmV4cG9ydCBjbGFzcyBTc2hDb25maWcge1xuICAgIHNzaEtleUFycmF5OlNzaEtleVtdO1xuICAgIGNvbnN0cnVjdG9yKHNzaEtleUFycmF5QXJnOlNzaEtleVtdKXtcbiAgICAgICAgdGhpcy5zc2hLZXlBcnJheSA9IHNzaEtleUFycmF5QXJnO1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIHN0b3JlcyBhIGNvbmZpZyBmaWxlXG4gICAgICovXG4gICAgc3RvcmUoZGlyUGF0aEFyZzpzdHJpbmcpe1xuICAgICAgICBsZXQgZG9uZSA9IHBsdWdpbnMucS5kZWZlcigpO1xuICAgICAgICBsZXQgY29uZmlnQXJyYXk6Y29uZmlnT2JqZWN0W107XG4gICAgICAgIGxldCBjb25maWdTdHJpbmc7XG4gICAgICAgIGZvcihsZXQga2V5IGluIHRoaXMuc3NoS2V5QXJyYXkpe1xuICAgICAgICAgICAgbGV0IHNzaEtleSA9IHRoaXMuc3NoS2V5QXJyYXlba2V5XTtcbiAgICAgICAgICAgIGlmKHNzaEtleS5ob3N0KXtcbiAgICAgICAgICAgICAgICBjb25maWdTdHJpbmcgPSBcIkhvc3QgXCIgKyBzc2hLZXkuaG9zdCArIFwiXFxuXCIgK1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcIiAgSG9zdE5hbWUgXCIgKyBzc2hLZXkuaG9zdCArIFwiXFxuXCIgK1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcIiAgSWRlbnRpdHlGaWxlIH4vLnNzaC9cIiArIHNzaEtleS5ob3N0ICsgXCJcXG5cIlxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgY29uZmlnQXJyYXkucHVzaCh7XG4gICAgICAgICAgICAgICAgY29uZmlnU3RyaW5nOmNvbmZpZ1N0cmluZyxcbiAgICAgICAgICAgICAgICBhdXRob3JpemVkOiBzc2hLZXkuYXV0aG9yaXplZCxcbiAgICAgICAgICAgICAgICBzc2hLZXk6IHNzaEtleVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICAgICAgbGV0IGNvbmZpZ0ZpbGU6c3RyaW5nID0gXCJcIjtcbiAgICAgICAgZm9yKGxldCBrZXkgaW4gY29uZmlnQXJyYXkpe1xuICAgICAgICAgICAgY29uZmlnRmlsZSA9IGNvbmZpZ0ZpbGUgKyBjb25maWdBcnJheVtrZXldLmNvbmZpZ1N0cmluZyArIFwiXFxuXCI7XG4gICAgICAgIH07XG4gICAgICAgIHBsdWdpbnMuc21hcnRmaWxlLm1lbW9yeS50b0ZzU3luYyhjb25maWdGaWxlLGRpclBhdGhBcmcpO1xuICAgICAgICByZXR1cm4gZG9uZS5wcm9taXNlO1xuICAgIH1cbiAgICByZWFkKGRpclBhdGhBcmcpe1xuICAgICAgICBsZXQgZG9uZSA9IHBsdWdpbnMucS5kZWZlcigpO1xuICAgICAgICBsZXQgY29uZmlnQXJyYXk6Y29uZmlnT2JqZWN0W107XG4gICAgICAgIFxuICAgICAgICByZXR1cm4gZG9uZS5wcm9taXNlO1xuICAgIH1cbn07XG5cbmV4cG9ydCBpbnRlcmZhY2UgY29uZmlnT2JqZWN0IHtcbiAgICBjb25maWdTdHJpbmc6c3RyaW5nO1xuICAgIGF1dGhvcml6ZWQ6Ym9vbGVhbjtcbiAgICBzc2hLZXk6U3NoS2V5O1xufTtcblxuIl19

12
dist/smartssh.classes.sshdir.d.ts vendored Normal file
View File

@ -0,0 +1,12 @@
import "typings-global";
import { SshKey } from "./smartssh.classes.sshkey";
import { SshConfig } from "./smartssh.classes.sshconfig";
export declare class SshDir {
path: string;
private sshKeyArray;
private sshConfig;
constructor(sshKeyArray: SshKey[], sshConfig: SshConfig, sshDirPathArg?: string);
writeToDir(): void;
readFromDir(): void;
getKeys(): SshKey[];
}

33
dist/smartssh.classes.sshdir.js vendored Normal file
View File

@ -0,0 +1,33 @@
"use strict";
require("typings-global");
var plugins = require("./smartssh.plugins");
var helpers = require("./smartssh.classes.helpers");
var SshDir = (function () {
function SshDir(sshKeyArray, sshConfig, sshDirPathArg) {
this.sshKeyArray = sshKeyArray;
if (sshDirPathArg) {
this.path = sshDirPathArg;
}
else {
this.path = plugins.path.join(plugins.smartpath.get.home(), ".ssh/");
}
;
}
SshDir.prototype.writeToDir = function () {
var _this = this;
this.sshKeyArray.forEach(function (sshKeyArg) {
sshKeyArg.store(_this.path);
});
this.sshConfig.store(this.path);
};
;
SshDir.prototype.readFromDir = function () {
};
SshDir.prototype.getKeys = function () {
return helpers.sshKeyArrayFromDir(this.path);
};
return SshDir;
}());
exports.SshDir = SshDir;
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3NoLmNsYXNzZXMuc3NoZGlyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFDeEIsSUFBWSxPQUFPLFdBQU0sb0JBQW9CLENBQUMsQ0FBQTtBQUM5QyxJQUFZLE9BQU8sV0FBTSw0QkFBNEIsQ0FBQyxDQUFBO0FBSXREO0lBSUksZ0JBQVksV0FBb0IsRUFBQyxTQUFtQixFQUFDLGFBQXFCO1FBQ3RFLElBQUksQ0FBQyxXQUFXLEdBQUcsV0FBVyxDQUFDO1FBQy9CLEVBQUUsQ0FBQSxDQUFDLGFBQWEsQ0FBQyxDQUFBLENBQUM7WUFDZCxJQUFJLENBQUMsSUFBSSxHQUFHLGFBQWEsQ0FBQztRQUM5QixDQUFDO1FBQUMsSUFBSSxDQUFDLENBQUM7WUFDSixJQUFJLENBQUMsSUFBSSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxTQUFTLENBQUMsR0FBRyxDQUFDLElBQUksRUFBRSxFQUFDLE9BQU8sQ0FBQyxDQUFDO1FBQ3hFLENBQUM7UUFBQSxDQUFDO0lBQ04sQ0FB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0iXX0=

34
dist/smartssh.classes.sshinstance.d.ts vendored Normal file
View File

@ -0,0 +1,34 @@
import "typings-global";
import { SshKey } from "./smartssh.classes.sshkey";
export declare class SshInstance {
private _sshKeyArray;
private _sshConfig;
private _sshDir;
private _sshSync;
constructor(optionsArg?: {
sshDirPath?: string;
sshSync?: boolean;
});
addKey(sshKeyArg: SshKey): void;
removeKey(sshKeyArg: SshKey): void;
replaceKey(sshKeyOldArg: SshKey, sshKeyNewArg: SshKey): void;
getKey(hostArg: string): SshKey;
sshKeys: SshKey[];
/**
* write SshInstance to disk
*/
writeToDisk(): void;
/**
* read ab SshInstance from disk
*/
readFromDisk(): void;
private _makeConfig();
/**
* method to invoke SshInstance _sync automatically when sshSync is true
*/
private _syncAuto(directionArg);
/**
* private method to sync SshInstance
*/
private _sync(directionArg);
}

105
dist/smartssh.classes.sshinstance.js vendored Normal file

File diff suppressed because one or more lines are too long

22
dist/smartssh.classes.sshkey.d.ts vendored Normal file
View File

@ -0,0 +1,22 @@
import "typings-global";
export declare class SshKey {
private _privKey;
private _pubKey;
private _hostVar;
private _authorized;
constructor(optionsArg?: {
private?: string;
public?: string;
host?: string;
authorized?: boolean;
});
host: string;
privKey: string;
privKeyBase64: string;
pubKey: string;
pubKeyBase64: string;
authorized: boolean;
type: any;
read(filePathArg: any): void;
store(dirPathArg: string): void;
}

121
dist/smartssh.classes.sshkey.js vendored Normal file

File diff suppressed because one or more lines are too long

9
dist/smartssh.plugins.d.ts vendored Normal file
View File

@ -0,0 +1,9 @@
import "typings-global";
export import beautylog = require("beautylog");
export declare let base64: any;
export declare let fs: any;
export declare let minimatch: any;
export import path = require("path");
export declare let q: any;
export import smartfile = require("smartfile");
export import smartpath = require("smartpath");

View File

@ -1,9 +1,12 @@
"use strict";
/// <reference path="./typings/main.d.ts" />
require("typings-global");
exports.beautylog = require("beautylog");
exports.base64 = require("js-base64").Base64;
exports.fs = require("fs-extra");
exports.minimatch = require("minimatch");
exports.path = require("path");
exports.q = require("q");
exports.smartfile = require("smartfile");
exports.smartpath = require("smartpath");
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3NoLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDRDQUE0QztBQUNqQyxpQkFBUyxHQUFHLE9BQU8sQ0FBQyxXQUFXLENBQUMsQ0FBQztBQUNqQyxjQUFNLEdBQUcsT0FBTyxDQUFDLFdBQVcsQ0FBQyxDQUFDLE1BQU0sQ0FBQztBQUNyQyxVQUFFLEdBQUcsT0FBTyxDQUFDLFVBQVUsQ0FBQyxDQUFDO0FBQ3pCLFlBQUksR0FBRyxPQUFPLENBQUMsTUFBTSxDQUFDLENBQUM7QUFDdkIsaUJBQVMsR0FBRyxPQUFPLENBQUMsV0FBVyxDQUFDLENBQUMiLCJmaWxlIjoic21hcnRzc2gucGx1Z2lucy5qcyIsInNvdXJjZXNDb250ZW50IjpbIi8vLyA8cmVmZXJlbmNlIHBhdGg9XCIuL3R5cGluZ3MvbWFpbi5kLnRzXCIgLz5cbmV4cG9ydCBsZXQgYmVhdXR5bG9nID0gcmVxdWlyZShcImJlYXV0eWxvZ1wiKTtcbmV4cG9ydCBsZXQgYmFzZTY0ID0gcmVxdWlyZShcImpzLWJhc2U2NFwiKS5CYXNlNjQ7XG5leHBvcnQgbGV0IGZzID0gcmVxdWlyZShcImZzLWV4dHJhXCIpO1xuZXhwb3J0IGxldCBwYXRoID0gcmVxdWlyZShcInBhdGhcIik7XG5leHBvcnQgbGV0IHNtYXJ0ZmlsZSA9IHJlcXVpcmUoXCJzbWFydGZpbGVcIik7Il0sInNvdXJjZVJvb3QiOiIvc291cmNlLyJ9
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3NoLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8s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Treshold":50
}

View File

@ -1,14 +1,15 @@
{
"name": "smartssh",
"version": "1.0.1",
"version": "1.1.3",
"description": "setups SSH quickly and in a painless manner",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"scripts": {
"test": "(npmts)"
},
"repository": {
"type": "git",
"url": "git+https://github.com/pushrocks/smartssh.git"
"url": "git+https://gitlab.com/pushrocks/smartssh.git"
},
"keywords": [
"SSH",
@ -18,17 +19,22 @@
"author": "Lossless GmbH",
"license": "MIT",
"bugs": {
"url": "https://github.com/pushrocks/smartssh/issues"
"url": "https://gitlab.com/pushrocks/smartssh/issues"
},
"homepage": "https://github.com/pushrocks/smartssh#readme",
"homepage": "https://gitlab.com/pushrocks/smartssh#readme",
"dependencies": {
"beautylog": "^4.1.2",
"fs-extra": "^0.28.0",
"beautylog": "^5.0.12",
"fs-extra": "^0.30.0",
"js-base64": "^2.1.9",
"smartfile": "^3.0.5"
"minimatch": "^3.0.2",
"q": "^1.4.1",
"smartfile": "^4.0.5",
"smartpath": "^3.2.2",
"typings-global": "^1.0.3",
"typings-test": "^1.0.1"
},
"devDependencies": {
"npmts": "^5.0.4",
"should": "^8.3.1"
"npmts-g": "^5.2.6",
"should": "^9.0.2"
}
}

2
test/test.d.ts vendored Normal file
View File

@ -0,0 +1,2 @@
import "typings-test";
import "should";

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,70 @@
/// <reference path="../ts/typings/main.d.ts" />
let should = require("should");
let smartssh = require("../dist/index.js");
import "typings-test"
import "should";
import smartssh = require("../dist/index");
import path = require("path");
describe("smartssh",function(){
let testSshInstance:smartssh.SshInstance;
let testSshKey:smartssh.SshKey;
describe(".SshKey",function(){
it("'new' keyword should create a valid SshKey object",function(){
testSshKey = new smartssh.SshKey({
host:"example.com",
private:"someExamplePrivateKey",
public:"someExamplePublicKey"
});
testSshKey.should.be.instanceof(smartssh.SshKey);
});
it(".type should be a valid type",function(){
testSshKey.type.should.equal("duplex");
});
it(".publicKey should be public key",function(){
testSshKey.pubKey.should.equal("someExamplePublicKey");
});
it(".privateKey should be private key",function(){
testSshKey.privKey.should.equal("someExamplePrivateKey");
});
it(".publicKeyBase64 should be public key base 64 encoded",function(){
testSshKey.pubKeyBase64;
});
it(".store() should store the file to disk",function(){
testSshKey.store(path.join(process.cwd(),"test/temp"));
})
});
describe(".SshInstance",function(){
it("'new' keyword should create a new SshInstance object from class",function(){
testSshInstance = new smartssh.SshInstance();
testSshInstance.should.be.instanceof(smartssh.SshInstance);
});
it(".addKey() should accept a new SshKey object",function(){
testSshInstance.addKey(new smartssh.SshKey({
public:"somePublicKey",
private:"somePrivateKey",
host:"gitlab.com"
}));
testSshInstance.addKey(new smartssh.SshKey({
public:"somePublicKey",
private:"somePrivateKey",
host:"bitbucket.org"
}));
testSshInstance.addKey(new smartssh.SshKey({
public:"someGitHubPublicKey",
private:"someGitHubPrivateKey",
host:"github.com"
}));
});
it(".sshKeys should point to an array of sshKeys",function(){
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").pubKey.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

@ -1,3 +1,7 @@
/// <reference path="./typings/main.d.ts" />
import plugins = require("./smartssh.plugins");
import classes = require("./smartssh.classes");
import "typings-global"
import * as plugins from "./smartssh.plugins";
export {SshInstance} from "./smartssh.classes.sshinstance";
export {SshKey} from "./smartssh.classes.sshkey";
export {SshDir} from "./smartssh.classes.sshdir";
export {SshConfig} from "./smartssh.classes.sshconfig";

View File

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

View File

@ -0,0 +1,52 @@
import "typings-global";
import * as plugins from "./smartssh.plugins";
import * as helpers from "./smartssh.classes.helpers";
import {SshKey} from "./smartssh.classes.sshkey"
export class SshConfig {
sshKeyArray:SshKey[];
constructor(sshKeyArrayArg:SshKey[]){
this.sshKeyArray = sshKeyArrayArg;
}
/**
* stores a config file
*/
store(dirPathArg:string){
let done = plugins.q.defer();
let configArray:configObject[];
let configString;
for(let key in this.sshKeyArray){
let sshKey = this.sshKeyArray[key];
if(sshKey.host){
configString = "Host " + sshKey.host + "\n" +
" HostName " + sshKey.host + "\n" +
" IdentityFile ~/.ssh/" + sshKey.host + "\n"
}
configArray.push({
configString:configString,
authorized: sshKey.authorized,
sshKey: sshKey
});
}
let configFile:string = "";
for(let key in configArray){
configFile = configFile + configArray[key].configString + "\n";
};
plugins.smartfile.memory.toFsSync(configFile,dirPathArg);
return done.promise;
}
read(dirPathArg){
let done = plugins.q.defer();
let configArray:configObject[];
return done.promise;
}
};
export interface configObject {
configString:string;
authorized:boolean;
sshKey:SshKey;
};

View File

@ -0,0 +1,31 @@
import "typings-global";
import * as plugins from "./smartssh.plugins";
import * as helpers from "./smartssh.classes.helpers";
import {SshInstance} from "./smartssh.classes.sshinstance";
import {SshKey} from "./smartssh.classes.sshkey";
import {SshConfig} from "./smartssh.classes.sshconfig";
export class SshDir { // sshDir class -> NOT EXPORTED, ONLY FOR INTERNAL USE
path:string; // the path of the ssh directory
private sshKeyArray:SshKey[];
private sshConfig:SshConfig;
constructor(sshKeyArray:SshKey[],sshConfig:SshConfig,sshDirPathArg?:string){
this.sshKeyArray = sshKeyArray;
if(sshDirPathArg){
this.path = sshDirPathArg;
} else {
this.path = plugins.path.join(plugins.smartpath.get.home(),".ssh/");
};
}
writeToDir(){ // syncs sshInstance to directory
this.sshKeyArray.forEach((sshKeyArg) => {
sshKeyArg.store(this.path);
});
this.sshConfig.store(this.path);
};
readFromDir(){ // syncs sshInstance from directory
}
getKeys(){
return helpers.sshKeyArrayFromDir(this.path);
}
}

View File

@ -0,0 +1,103 @@
import "typings-global"
import * as plugins from "./smartssh.plugins";
import * as helpers from "./smartssh.classes.helpers";
import {SshDir} from "./smartssh.classes.sshdir";
import {SshConfig} from "./smartssh.classes.sshconfig";
import {SshKey} from "./smartssh.classes.sshkey";
export class SshInstance {
private _sshKeyArray:SshKey[]; //holds all ssh keys
private _sshConfig:SshConfig; // sshConfig (e.g. represents ~/.ssh/config)
private _sshDir:SshDir; // points to sshDir class instance.
private _sshSync:boolean; // if set to true, the ssh dir will be kept in sync automatically
constructor(optionsArg:{sshDirPath?:string,sshSync?:boolean}={}){
optionsArg ? void(0) : optionsArg = {};
this._sshKeyArray = [];
this._sshConfig = new SshConfig(this._sshKeyArray);
this._sshDir = new SshDir(this._sshKeyArray,this._sshConfig,optionsArg.sshDirPath);
this._sshSync = optionsArg.sshSync;
};
//altering methods
addKey(sshKeyArg:SshKey){
this._syncAuto("from");
this._sshKeyArray.push(sshKeyArg);
this._syncAuto("to");
};
removeKey(sshKeyArg:SshKey){
this._syncAuto("from");
let filteredArray = this._sshKeyArray.filter((sshKeyArg2:SshKey) => {
return (sshKeyArg != sshKeyArg2);
});
this._sshKeyArray = filteredArray;
this._syncAuto("to");
};
replaceKey(sshKeyOldArg:SshKey,sshKeyNewArg:SshKey){
this._syncAuto("from");
this.removeKey(sshKeyOldArg);
this.addKey(sshKeyNewArg);
this._syncAuto("to");
};
//
getKey(hostArg:string):SshKey{
this._syncAuto("from");
let filteredArray = this._sshKeyArray.filter(function(keyArg){
return (keyArg.host == hostArg);
});
if(filteredArray.length > 0){
return filteredArray[0];
} else {
return undefined;
}
};
get sshKeys():SshKey[] {
this._syncAuto("from");
return this._sshKeyArray;
};
//FS methods
/**
* write SshInstance to disk
*/
writeToDisk(){
this._sync("to");
}
/**
* read ab SshInstance from disk
*/
readFromDisk(){
this._sync("from");
}
/* ===============================================================
========================= Private Methods ========================
================================================================*/
private _makeConfig (){
}
/**
* method to invoke SshInstance _sync automatically when sshSync is true
*/
private _syncAuto(directionArg){
if(this._sshSync) this._sync(directionArg);
}
/**
* private method to sync SshInstance
*/
private _sync(directionArg:string){
if(directionArg == "from"){
this._sshDir.readFromDir(); // call sync method of sshDir class;
} else if(directionArg == "to") {
this._sshDir.writeToDir();
} else {
throw new Error("directionArg not recognised. Must be 'to' or 'from'");
}
};
}

View File

@ -0,0 +1,92 @@
import "typings-global";
import * as plugins from "./smartssh.plugins";
import * as helpers from "./smartssh.classes.helpers";
export class SshKey {
private _privKey:string;
private _pubKey:string;
private _hostVar:string;
private _authorized:boolean;
constructor(optionsArg:{private?:string,public?:string,host?:string,authorized?:boolean}={}){
this._privKey = optionsArg.private;
this._pubKey = optionsArg.public;
this._hostVar = optionsArg.host;
this._authorized = optionsArg.authorized;
};
// this.host
get host(){
return this._hostVar;
};
set host(hostArg:string){
this._hostVar = hostArg;
};
// this.privKey
get privKey(){
return this._privKey;
};
set privKey(privateKeyArg:string){
this._privKey = privateKeyArg;
};
// this.privKeyBase64
get privKeyBase64(){
return plugins.base64.encode(this._privKey);
}
set privKeyBase64(privateKeyArg:string) {
this._privKey = plugins.base64.decode(privateKeyArg);
}
// this.pubKey
get pubKey(){
return this._pubKey;
}
set pubKey(publicKeyArg:string){
this._pubKey = publicKeyArg;
};
// this.pubKeyBase64
get pubKeyBase64(){
return plugins.base64.encode(this._pubKey);
}
set pubKeyBase64(publicKeyArg:string) {
this._pubKey = plugins.base64.decode(publicKeyArg);
}
get authorized(){
return this._authorized;
}
set authorized(authorizedArg:boolean){
this._authorized = authorizedArg;
}
get type(){
if(this._privKey && this._pubKey){
return "duplex";
} else if(this._privKey){
return "private";
} else if(this._pubKey){
return "public";
}
};
set type(someVlueArg:any){
console.log("the type of an SshKey connot be set. This value is autpcomputed.")
}
// methods
read(filePathArg){
}
store(dirPathArg:string){
plugins.fs.ensureDirSync(dirPathArg);
let fileNameBase = this.host;
if(this._privKey){
plugins.smartfile.memory.toFsSync(this._privKey,plugins.path.join(dirPathArg,fileNameBase));
};
if (this._pubKey){
plugins.smartfile.memory.toFsSync(this._pubKey,plugins.path.join(dirPathArg,fileNameBase + ".pub"));
}
}
}
let testKey = new SshKey();

View File

@ -1,78 +0,0 @@
/// <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 sshSync:boolean; // if set to true, the ssh dir will be kept in sync automatically
constructor(optionsArg:{sshDir?:string,sshSync?:boolean}={}){
this.sshDir = optionsArg.sshDir
this.sshDir ?
this.sshKeys = helpers.sshKeyArrayFromDir(this.sshDir)
: void(0);
this.sshSync = optionsArg.sshSync;
};
}
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
}
}
}

View File

@ -1,6 +1,9 @@
/// <reference path="./typings/main.d.ts" />
export let beautylog = require("beautylog");
import "typings-global"
export import 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");
export let minimatch = require("minimatch");
export import path = require("path");
export let q = require("q");
export import smartfile = require("smartfile");
export import smartpath = require("smartpath");

View File

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