Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
56318f28cf | |||
32b26f21cd | |||
32c2698af7 | |||
27237f14c7 | |||
8f29f234f1 | |||
5091625953 | |||
f74b3a51b0 | |||
062f3ad060 | |||
ecd0fd8fad |
9
.gitignore
vendored
9
.gitignore
vendored
@ -1,8 +1,5 @@
|
||||
.idea/
|
||||
node_modules/
|
||||
coverage/
|
||||
docs/
|
||||
ts/typings/
|
||||
ts/*.js
|
||||
ts/*.js.map
|
||||
test/temp/
|
||||
pages/
|
||||
public/
|
||||
test/temp/
|
||||
|
@ -3,7 +3,16 @@ image: hosttoday/ht-docker-node:npmts
|
||||
stages:
|
||||
- test
|
||||
- release
|
||||
- page
|
||||
- trigger
|
||||
- pages
|
||||
|
||||
testLEGACY:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test legacy
|
||||
tags:
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
testLTS:
|
||||
stage: test
|
||||
@ -11,7 +20,6 @@ testLTS:
|
||||
- npmci test lts
|
||||
tags:
|
||||
- docker
|
||||
- lossless
|
||||
|
||||
testSTABLE:
|
||||
stage: test
|
||||
@ -19,13 +27,6 @@ testSTABLE:
|
||||
- npmci test stable
|
||||
tags:
|
||||
- docker
|
||||
- lossless
|
||||
|
||||
testLEGACY:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test legacy
|
||||
allow_failure: true
|
||||
|
||||
release:
|
||||
stage: release
|
||||
@ -35,4 +36,24 @@ release:
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
- lossless
|
||||
|
||||
trigger:
|
||||
stage: trigger
|
||||
script:
|
||||
- npmci trigger
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
|
||||
pages:
|
||||
image: hosttoday/ht-docker-node:npmpage
|
||||
stage: pages
|
||||
script:
|
||||
- npmci command npmpage --host gitlab
|
||||
only:
|
||||
- tags
|
||||
artifacts:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- public
|
||||
|
19
README.md
19
README.md
@ -3,6 +3,23 @@ setups SSH quickly and in a painless manner
|
||||
|
||||
> Attention: This is still alpha, so some things won't work, not all things are inplemented.
|
||||
|
||||
## Availabililty
|
||||
[](https://www.npmjs.com/package/smartssh)
|
||||
[](https://gitlab.com/pushrocks/smartssh)
|
||||
[](https://github.com/pushrocks/smartssh)
|
||||
[](https://pushrocks.gitlab.io/smartssh/)
|
||||
|
||||
## Status for master
|
||||
[](https://gitlab.com/pushrocks/smartssh/commits/master)
|
||||
[](https://gitlab.com/pushrocks/smartssh/commits/master)
|
||||
[](https://www.npmjs.com/package/smartssh)
|
||||
[](https://david-dm.org/pushrocks/smartssh)
|
||||
[](https://www.bithound.io/github/pushrocks/smartssh/master/dependencies/npm)
|
||||
[](https://www.bithound.io/github/pushrocks/smartssh)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](http://standardjs.com/)
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
@ -32,3 +49,5 @@ sshInstance.getKey({ // returns ssh key in the form sshKey, read more about the
|
||||
sshInstance.getKeys() // returns array of all available getKeys. Each key is in form of class sshKey
|
||||
|
||||
```
|
||||
|
||||
[](https://push.rocks)
|
||||
|
10
dist/index.d.ts
vendored
10
dist/index.d.ts
vendored
@ -1,5 +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";
|
||||
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';
|
||||
|
3
dist/index.js
vendored
3
dist/index.js
vendored
@ -8,5 +8,4 @@ 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;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUNQLENBQUMsQ0FEc0I7QUFHdkIsNkNBQTBCLGdDQUFnQyxDQUFDO0FBQW5ELGlFQUFtRDtBQUMzRCx3Q0FBcUIsMkJBQTJCLENBQUM7QUFBekMsa0RBQXlDO0FBQ2pELHdDQUFxQiwyQkFBMkIsQ0FBQztBQUF6QyxrREFBeUM7QUFDakQsMkNBQXdCLDhCQUE4QixDQUFDO0FBQS9DLDJEQUErQyIsImZpbGUiOiJpbmRleC5qcyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBcInR5cGluZ3MtZ2xvYmFsXCJcbmltcG9ydCAqIGFzIHBsdWdpbnMgZnJvbSBcIi4vc21hcnRzc2gucGx1Z2luc1wiO1xuXG5leHBvcnQge1NzaEluc3RhbmNlfSBmcm9tIFwiLi9zbWFydHNzaC5jbGFzc2VzLnNzaGluc3RhbmNlXCI7XG5leHBvcnQge1NzaEtleX0gZnJvbSBcIi4vc21hcnRzc2guY2xhc3Nlcy5zc2hrZXlcIjtcbmV4cG9ydCB7U3NoRGlyfSBmcm9tIFwiLi9zbWFydHNzaC5jbGFzc2VzLnNzaGRpclwiO1xuZXhwb3J0IHtTc2hDb25maWd9IGZyb20gXCIuL3NtYXJ0c3NoLmNsYXNzZXMuc3NoY29uZmlnXCI7Il19
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMEJBQXVCO0FBR3ZCLCtFQUEwRDtBQUFsRCxxREFBQSxXQUFXLENBQUE7QUFDbkIscUVBQWdEO0FBQXhDLDJDQUFBLE1BQU0sQ0FBQTtBQUNkLHFFQUFnRDtBQUF4QywyQ0FBQSxNQUFNLENBQUE7QUFDZCwyRUFBc0Q7QUFBOUMsaURBQUEsU0FBUyxDQUFBIn0=
|
4
dist/smartssh.classes.helpers.d.ts
vendored
4
dist/smartssh.classes.helpers.d.ts
vendored
@ -1,3 +1,3 @@
|
||||
import "typings-global";
|
||||
import { SshKey } from "./smartssh.classes.sshkey";
|
||||
import 'typings-global';
|
||||
import { SshKey } from './smartssh.classes.sshkey';
|
||||
export declare let sshKeyArrayFromDir: (dirArg: string) => SshKey[];
|
||||
|
5
dist/smartssh.classes.helpers.js
vendored
5
dist/smartssh.classes.helpers.js
vendored
@ -1,8 +1,7 @@
|
||||
"use strict";
|
||||
require("typings-global");
|
||||
exports.sshKeyArrayFromDir = function (dirArg) {
|
||||
var sshKeyArray = []; //TODO
|
||||
let sshKeyArray = []; // TODO
|
||||
return sshKeyArray;
|
||||
};
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3NoLmNsYXNzZXMuaGVscGVycy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsUUFBTyxnQkFDUCxDQUFDLENBRHNCO0FBSVosMEJBQWtCLEdBQUcsVUFBUyxNQUFhO0lBQ2xELElBQUksV0FBVyxHQUFHLEVBQUUsQ0FBQyxDQUFDLE1BQU07SUFDNUIsTUFBTSxDQUFDLFdBQVcsQ0FBQztBQUN2QixDQUFDLENBQUEiLCJmaWxlIjoic21hcnRzc2guY2xhc3Nlcy5oZWxwZXJzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFwidHlwaW5ncy1nbG9iYWxcIlxuaW1wb3J0ICogYXMgcGx1Z2lucyBmcm9tIFwiLi9zbWFydHNzaC5wbHVnaW5zXCI7XG5pbXBvcnQge1NzaEtleX0gZnJvbSBcIi4vc21hcnRzc2guY2xhc3Nlcy5zc2hrZXlcIjtcblxuZXhwb3J0IGxldCBzc2hLZXlBcnJheUZyb21EaXIgPSBmdW5jdGlvbihkaXJBcmc6c3RyaW5nKTpTc2hLZXlbXXtcbiAgICBsZXQgc3NoS2V5QXJyYXkgPSBbXTsgLy9UT0RPXG4gICAgcmV0dXJuIHNzaEtleUFycmF5O1xufSJdfQ==
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzc2guY2xhc3Nlcy5oZWxwZXJzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzc2guY2xhc3Nlcy5oZWxwZXJzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSwwQkFBdUI7QUFJWixRQUFBLGtCQUFrQixHQUFHLFVBQVMsTUFBYztJQUNuRCxJQUFJLFdBQVcsR0FBRyxFQUFFLENBQUEsQ0FBQyxPQUFPO0lBQzVCLE1BQU0sQ0FBQyxXQUFXLENBQUE7QUFDdEIsQ0FBQyxDQUFBIn0=
|
11
dist/smartssh.classes.sshconfig.d.ts
vendored
11
dist/smartssh.classes.sshconfig.d.ts
vendored
@ -1,13 +1,14 @@
|
||||
import "typings-global";
|
||||
import { SshKey } from "./smartssh.classes.sshkey";
|
||||
/// <reference types="q" />
|
||||
import 'typings-global';
|
||||
import { SshKey } from './smartssh.classes.sshkey';
|
||||
export declare class SshConfig {
|
||||
sshKeyArray: SshKey[];
|
||||
private _sshKeyArray;
|
||||
constructor(sshKeyArrayArg: SshKey[]);
|
||||
/**
|
||||
* stores a config file
|
||||
*/
|
||||
store(dirPathArg: string): any;
|
||||
read(dirPathArg: any): any;
|
||||
store(dirPathArg: string): Q.Promise<{}>;
|
||||
read(dirPathArg: any): Q.Promise<{}>;
|
||||
}
|
||||
export interface configObject {
|
||||
configString: string;
|
||||
|
52
dist/smartssh.classes.sshconfig.js
vendored
52
dist/smartssh.classes.sshconfig.js
vendored
@ -1,23 +1,24 @@
|
||||
"use strict";
|
||||
require("typings-global");
|
||||
var plugins = require("./smartssh.plugins");
|
||||
var SshConfig = (function () {
|
||||
function SshConfig(sshKeyArrayArg) {
|
||||
this.sshKeyArray = sshKeyArrayArg;
|
||||
const plugins = require("./smartssh.plugins");
|
||||
class SshConfig {
|
||||
constructor(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];
|
||||
store(dirPathArg) {
|
||||
let done = plugins.q.defer();
|
||||
let configArray = [];
|
||||
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";
|
||||
configString = 'Host ' + sshKey.host + '\n' +
|
||||
' HostName ' + sshKey.host + '\n' +
|
||||
' IdentityFile ~/.ssh/' + sshKey.host + '\n' +
|
||||
' StrictHostKeyChecking no' + '\n';
|
||||
}
|
||||
configArray.push({
|
||||
configString: configString,
|
||||
@ -25,23 +26,22 @@ var SshConfig = (function () {
|
||||
sshKey: sshKey
|
||||
});
|
||||
}
|
||||
var configFile = "";
|
||||
for (var key in configArray) {
|
||||
configFile = configFile + configArray[key].configString + "\n";
|
||||
let configFile = '';
|
||||
for (let key in configArray) {
|
||||
configFile = configFile + configArray[key].configString + '\n';
|
||||
}
|
||||
;
|
||||
plugins.smartfile.memory.toFsSync(configFile, dirPathArg);
|
||||
plugins.smartfile.memory.toFsSync(configFile, plugins.path.join(dirPathArg, 'config'));
|
||||
return done.promise;
|
||||
};
|
||||
SshConfig.prototype.read = function (dirPathArg) {
|
||||
var done = plugins.q.defer();
|
||||
var configArray;
|
||||
}
|
||||
read(dirPathArg) {
|
||||
let done = plugins.q.defer();
|
||||
let configArray;
|
||||
plugins.smartfile.fs.toStringSync(plugins.path.join(dirPathArg, 'config'));
|
||||
return done.promise;
|
||||
};
|
||||
return SshConfig;
|
||||
}());
|
||||
}
|
||||
}
|
||||
exports.SshConfig = SshConfig;
|
||||
;
|
||||
;
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3NoLmNsYXNzZXMuc3NoY29uZmlnLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFDeEIsSUFBWSxPQUFPLFdBQU0sb0JBQW9CLENBQUMsQ0FBQTtBQUk5QztJQUVJLG1CQUFZLGNBQXVCO1FBQy9CLElBQUksQ0FBQyxXQUFXLEdBQUcsY0FBYyxDQUFDO0lBQ3RDLENBQUM7SUFFRDs7T0FFRztJQUNILHlCQUFLLEdBQUwsVUFBTSxVQUFpQjtRQUNuQixJQUFJLElBQUksR0FBRyxPQUFPLENBQUMsQ0FBQyxDQUFDLEtBQUssRUFBRSxDQUFDO1FBQzdCLElBQUksV0FBMEIsQ0FBQztRQUMvQixJQUFJLFlBQVksQ0FBQztRQUNqQixHQUFHLENBQUEsQ0FBQyxJQUFJLEdBQUcsSUFBSSxJQUFJLENBQUMsV0FBVyxDQUFDLENBQUEsQ0FBQztZQUM3QixJQUFJLE1BQU0sR0FBRyxJQUFJLENBQUMsV0FBVyxDQUFDLEdBQUcsQ0FBQyxDQUFDO1lBQ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XFxuXCIgK1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcIiAgSG9zdE5hbWUgXCIgKyBzc2hLZXkuaG9zdCArIFwiXFxuXCIgK1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcIiAgSWRlbnRpdHlGaWxlIH4vLnNzaC9cIiArIHNzaEtleS5ob3N0ICsgXCJcXG5cIlxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgY29uZmlnQXJyYXkucHVzaCh7XG4gICAgICAgICAgICAgICAgY29uZmlnU3RyaW5nOmNvbmZpZ1N0cmluZyxcbiAgICAgICAgICAgICAgICBhdXRob3JpemVkOiBzc2hLZXkuYXV0aG9yaXplZCxcbiAgICAgICAgICAgICAgICBzc2hLZXk6IHNzaEtleVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICAgICAgbGV0IGNvbmZpZ0ZpbGU6c3RyaW5nID0gXCJcIjtcbiAgICAgICAgZm9yKGxldCBrZXkgaW4gY29uZmlnQXJyYXkpe1xuICAgICAgICAgICAgY29uZmlnRmlsZSA9IGNvbmZpZ0ZpbGUgKyBjb25maWdBcnJheVtrZXldLmNvbmZpZ1N0cmluZyArIFwiXFxuXCI7XG4gICAgICAgIH07XG4gICAgICAgIHBsdWdpbnMuc21hcnRmaWxlLm1lbW9yeS50b0ZzU3luYyhjb25maWdGaWxlLGRpclBhdGhBcmcpO1xuICAgICAgICByZXR1cm4gZG9uZS5wcm9taXNlO1xuICAgIH1cbiAgICByZWFkKGRpclBhdGhBcmcpe1xuICAgICAgICBsZXQgZG9uZSA9IHBsdWdpbnMucS5kZWZlcigpO1xuICAgICAgICBsZXQgY29uZmlnQXJyYXk6Y29uZmlnT2JqZWN0W107XG4gICAgICAgIFxuICAgICAgICByZXR1cm4gZG9uZS5wcm9taXNlO1xuICAgIH1cbn07XG5cbmV4cG9ydCBpbnRlcmZhY2UgY29uZmlnT2JqZWN0IHtcbiAgICBjb25maWdTdHJpbmc6c3RyaW5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h.classes.sshdir.d.ts
vendored
17
dist/smartssh.classes.sshdir.d.ts
vendored
@ -1,12 +1,13 @@
|
||||
import "typings-global";
|
||||
import { SshKey } from "./smartssh.classes.sshkey";
|
||||
import { SshConfig } from "./smartssh.classes.sshconfig";
|
||||
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;
|
||||
private _path;
|
||||
private _sshKeyArray;
|
||||
private _sshConfig;
|
||||
constructor(sshKeyArray: SshKey[], sshConfig: SshConfig, sshDirPathArg?: string);
|
||||
writeToDir(): void;
|
||||
readFromDir(): void;
|
||||
writeToDir(dirPathArg?: string): void;
|
||||
readFromDir(dirPathArg?: string): void;
|
||||
updateDirPath(dirPathArg: string): void;
|
||||
getKeys(): SshKey[];
|
||||
}
|
||||
|
52
dist/smartssh.classes.sshdir.js
vendored
52
dist/smartssh.classes.sshdir.js
vendored
@ -1,33 +1,41 @@
|
||||
"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;
|
||||
const plugins = require("./smartssh.plugins");
|
||||
const helpers = require("./smartssh.classes.helpers");
|
||||
class SshDir {
|
||||
constructor(sshKeyArray, sshConfig, sshDirPathArg) {
|
||||
this._sshKeyArray = sshKeyArray;
|
||||
this._sshConfig = sshConfig;
|
||||
if (sshDirPathArg) {
|
||||
this.path = sshDirPathArg;
|
||||
this._path = sshDirPathArg;
|
||||
}
|
||||
else {
|
||||
this.path = plugins.path.join(plugins.smartpath.get.home(), ".ssh/");
|
||||
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);
|
||||
writeToDir(dirPathArg) {
|
||||
let path = this._path;
|
||||
if (dirPathArg)
|
||||
path = dirPathArg;
|
||||
this._sshKeyArray.forEach((sshKeyArg) => {
|
||||
sshKeyArg.store(path);
|
||||
});
|
||||
this.sshConfig.store(this.path);
|
||||
};
|
||||
this._sshConfig.store(path);
|
||||
}
|
||||
;
|
||||
SshDir.prototype.readFromDir = function () {
|
||||
};
|
||||
SshDir.prototype.getKeys = function () {
|
||||
return helpers.sshKeyArrayFromDir(this.path);
|
||||
};
|
||||
return SshDir;
|
||||
}());
|
||||
readFromDir(dirPathArg) {
|
||||
let path = this._path;
|
||||
if (dirPathArg)
|
||||
path = dirPathArg;
|
||||
}
|
||||
updateDirPath(dirPathArg) {
|
||||
this._path = dirPathArg;
|
||||
}
|
||||
;
|
||||
getKeys() {
|
||||
return helpers.sshKeyArrayFromDir(this._path);
|
||||
}
|
||||
}
|
||||
exports.SshDir = SshDir;
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3NoLmNsYXNzZXMuc3NoZGlyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFDeEIsSUFBWSxPQUFPLFdBQU0sb0JBQW9CLENBQUMsQ0FBQTtBQUM5QyxJQUFZLE9BQU8sV0FBTSw0QkFBNEIsQ0FBQyxDQUFBO0FBSXREO0lBSUksZ0JBQVksV0FBb0IsRUFBQyxTQUFtQixFQUFDLGFBQXFCO1FBQ3RFLElBQUksQ0FBQyxXQUFXLEdBQUcsV0FBVyxDQUFDO1FBQy9CLEVBQUUsQ0FBQSxDQUFDLGFBQWEsQ0FBQyxDQUFBLENBQUM7WUFDZCxJQUFJLENBQUMsSUFBSSxHQUFHLGFBQWEs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FHLElBQUksQ0FBQyxLQUFLLENBQUE7UUFDckIsRUFBRSxDQUFDLENBQUMsVUFBVSxDQUFDO1lBQUMsSUFBSSxHQUFHLFVBQVUsQ0FBQTtRQUNqQyxJQUFJLENBQUMsWUFBWSxDQUFDLE9BQU8sQ0FBQyxDQUFDLFNBQVM7WUFDaEMsU0FBUyxDQUFDLEtBQUssQ0FBQyxJQUFJLENBQUMsQ0FBQTtRQUN6QixDQUFDLENBQUMsQ0FBQTtRQUNGLElBQUksQ0FBQyxVQUFVLENBQUMsS0FBSyxDQUFDLElBQUksQ0FBQyxDQUFBO0lBQy9CLENBQUM7SUFBQSxDQUFDO0lBQ0YsV0FBVyxDQUFDLFVBQW1CO1FBQzNCLElBQUksSUFBSSxHQUFHLElBQUksQ0FBQyxLQUFLLENBQUE7UUFDckIsRUFBRSxDQUFDLENBQUMsVUFBVSxDQUFDO1lBQUMsSUFBSSxHQUFHLFVBQVUsQ0FBQTtJQUNyQyxDQUFDO0lBQ0QsYUFBYSxDQUFDLFVBQWtCO1FBQzVCLElBQUksQ0FBQyxLQUFLLEdBQUcsVUFBVSxDQUFBO0lBQzNCLENBQUM7SUFBQSxDQUFDO0lBQ0YsT0FBTztRQUNILE1BQU0sQ0FBQyxPQUFPLENBQUMsa0JBQWtCLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxDQUFBO0lBQ2pELENBQUM7Q0FDSjtBQS9CRCx3QkErQkMifQ==
|
12
dist/smartssh.classes.sshinstance.d.ts
vendored
12
dist/smartssh.classes.sshinstance.d.ts
vendored
@ -1,5 +1,5 @@
|
||||
import "typings-global";
|
||||
import { SshKey } from "./smartssh.classes.sshkey";
|
||||
import 'typings-global';
|
||||
import { SshKey } from './smartssh.classes.sshkey';
|
||||
export declare class SshInstance {
|
||||
private _sshKeyArray;
|
||||
private _sshConfig;
|
||||
@ -13,15 +13,15 @@ export declare class SshInstance {
|
||||
removeKey(sshKeyArg: SshKey): void;
|
||||
replaceKey(sshKeyOldArg: SshKey, sshKeyNewArg: SshKey): void;
|
||||
getKey(hostArg: string): SshKey;
|
||||
sshKeys: SshKey[];
|
||||
readonly sshKeys: SshKey[];
|
||||
/**
|
||||
* write SshInstance to disk
|
||||
*/
|
||||
writeToDisk(): void;
|
||||
writeToDisk(dirPathArg?: string): void;
|
||||
/**
|
||||
* read ab SshInstance from disk
|
||||
*/
|
||||
readFromDisk(): void;
|
||||
readFromDisk(dirPathArg?: string): void;
|
||||
private _makeConfig();
|
||||
/**
|
||||
* method to invoke SshInstance _sync automatically when sshSync is true
|
||||
@ -30,5 +30,5 @@ export declare class SshInstance {
|
||||
/**
|
||||
* private method to sync SshInstance
|
||||
*/
|
||||
private _sync(directionArg);
|
||||
private _sync(directionArg, dirPathArg?);
|
||||
}
|
||||
|
99
dist/smartssh.classes.sshinstance.js
vendored
99
dist/smartssh.classes.sshinstance.js
vendored
File diff suppressed because one or more lines are too long
5
dist/smartssh.classes.sshkey.d.ts
vendored
5
dist/smartssh.classes.sshkey.d.ts
vendored
@ -1,9 +1,12 @@
|
||||
import "typings-global";
|
||||
import 'typings-global';
|
||||
export declare class SshKey {
|
||||
private _privKey;
|
||||
private _pubKey;
|
||||
private _hostVar;
|
||||
private _authorized;
|
||||
/**
|
||||
* the constructor for class SshKey
|
||||
*/
|
||||
constructor(optionsArg?: {
|
||||
private?: string;
|
||||
public?: string;
|
||||
|
173
dist/smartssh.classes.sshkey.js
vendored
173
dist/smartssh.classes.sshkey.js
vendored
File diff suppressed because one or more lines are too long
20
dist/smartssh.plugins.d.ts
vendored
20
dist/smartssh.plugins.d.ts
vendored
@ -1,9 +1,11 @@
|
||||
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");
|
||||
import 'typings-global';
|
||||
import * as beautylog from 'beautylog';
|
||||
import * as fs from 'fs-extra';
|
||||
import * as minimatch from 'minimatch';
|
||||
import * as path from 'path';
|
||||
import * as q from 'q';
|
||||
import * as shelljs from 'shelljs';
|
||||
import * as smartfile from 'smartfile';
|
||||
import * as smartpath from 'smartpath';
|
||||
import * as smartstring from 'smartstring';
|
||||
export { beautylog, fs, minimatch, path, q, shelljs, smartfile, smartpath, smartstring };
|
||||
|
29
dist/smartssh.plugins.js
vendored
29
dist/smartssh.plugins.js
vendored
@ -1,12 +1,21 @@
|
||||
"use strict";
|
||||
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;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3NoLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQ1AsQ0FBQyxDQURzQjtBQUNULGlCQUFTLFdBQVcsV0FBVyxDQUFDLENBQUM7QUFDcEMsY0FBTSxHQUFHLE9BQU8sQ0FBQyxXQUFXLENBQUMsQ0FBQyxNQUFNLENBQUM7QUFDckMsVUFBRSxHQUFHLE9BQU8sQ0FBQyxVQUFVLENBQUMsQ0FBQztBQUN6QixpQkFBUyxHQUFHLE9BQU8sQ0FBQyxXQUFXLENBQUMsQ0FBQztBQUM5QixZQUFJLFdBQVcsTUFBTSxDQUFDLENBQUM7QUFDMUIsU0FBQyxHQUFHLE9BQU8sQ0FBQyxHQUFHLENBQUMsQ0FBQztBQUNkLGlCQUFTLFdBQVcsV0FBVyxDQUFDLENBQUM7QUFDakMsaUJBQVMsV0FBVyxXQUFXLENBQUMsQ0FBQyIsImZpbGUiOiJzbWFydHNzaC5wbHVnaW5zLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFwidHlwaW5ncy1nbG9iYWxcIlxuZXhwb3J0IGltcG9ydCBiZWF1dHlsb2cgPSByZXF1aXJlKFwiYmVhdXR5bG9nXCIpO1xuZXhwb3J0IGxldCBiYXNlNjQgPSByZXF1aXJlKFwianMtYmFzZTY0XCIpLkJhc2U2NDtcbmV4cG9ydCBsZXQgZnMgPSByZXF1aXJlKFwiZnMtZXh0cmFcIik7XG5leHBvcnQgbGV0IG1pbmltYXRjaCA9IHJlcXVpcmUoXCJtaW5pbWF0Y2hcIik7XG5leHBvcnQgaW1wb3J0IHBhdGggPSByZXF1aXJlKFwicGF0aFwiKTtcbmV4cG9ydCBsZXQgcSA9IHJlcXVpcmUoXCJxXCIpO1xuZXhwb3J0IGltcG9ydCBzbWFydGZpbGUgPSByZXF1aXJlKFwic21hcnRmaWxlXCIpO1xuZXhwb3J0IGltcG9ydCBzbWFydHBhdGggPSByZXF1aXJlKFwic21hcnRwYXRoXCIpOyJdfQ==
|
||||
const beautylog = require("beautylog");
|
||||
exports.beautylog = beautylog;
|
||||
const fs = require("fs-extra");
|
||||
exports.fs = fs;
|
||||
const minimatch = require("minimatch");
|
||||
exports.minimatch = minimatch;
|
||||
const path = require("path");
|
||||
exports.path = path;
|
||||
const q = require("q");
|
||||
exports.q = q;
|
||||
const shelljs = require("shelljs");
|
||||
exports.shelljs = shelljs;
|
||||
const smartfile = require("smartfile");
|
||||
exports.smartfile = smartfile;
|
||||
const smartpath = require("smartpath");
|
||||
exports.smartpath = smartpath;
|
||||
const smartstring = require("smartstring");
|
||||
exports.smartstring = smartstring;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzc2gucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0c3NoLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDBCQUF1QjtBQUN2Qix1Q0FBc0M7QUFXbEMsOEJBQVM7QUFWYiwrQkFBOEI7QUFXMUIsZ0JBQUU7QUFWTix1Q0FBc0M7QUFXbEMsOEJBQVM7QUFWYiw2QkFBNEI7QUFXeEIsb0JBQUk7QUFWUix1QkFBc0I7QUFXbEIsY0FBQztBQVZMLG1DQUFrQztBQVc5QiwwQkFBTztBQVZYLHVDQUFzQztBQVdsQyw4QkFBUztBQVZiLHVDQUFzQztBQVdsQyw4QkFBUztBQVZiLDJDQUEwQztBQVd0QyxrQ0FBVyJ9
|
29
package.json
29
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "smartssh",
|
||||
"version": "1.1.3",
|
||||
"version": "1.2.1",
|
||||
"description": "setups SSH quickly and in a painless manner",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
@ -23,18 +23,25 @@
|
||||
},
|
||||
"homepage": "https://gitlab.com/pushrocks/smartssh#readme",
|
||||
"dependencies": {
|
||||
"beautylog": "^5.0.12",
|
||||
"fs-extra": "^0.30.0",
|
||||
"js-base64": "^2.1.9",
|
||||
"minimatch": "^3.0.2",
|
||||
"@types/fs-extra": "0.0.35",
|
||||
"@types/js-base64": "^2.1.5",
|
||||
"@types/minimatch": "^2.0.29",
|
||||
"@types/q": "0.0.32",
|
||||
"@types/shelljs": "^0.3.33",
|
||||
"beautylog": "^6.0.0",
|
||||
"fs-extra": "^1.0.0",
|
||||
"minimatch": "^3.0.3",
|
||||
"q": "^1.4.1",
|
||||
"smartfile": "^4.0.5",
|
||||
"smartpath": "^3.2.2",
|
||||
"typings-global": "^1.0.3",
|
||||
"typings-test": "^1.0.1"
|
||||
"shelljs": "^0.7.5",
|
||||
"smartfile": "^4.1.0",
|
||||
"smartpath": "^3.2.5",
|
||||
"smartstring": "^2.0.22",
|
||||
"typings-global": "^1.0.14"
|
||||
},
|
||||
"devDependencies": {
|
||||
"npmts-g": "^5.2.6",
|
||||
"should": "^9.0.2"
|
||||
"@types/should": "^8.1.30",
|
||||
"npmts-g": "^5.2.8",
|
||||
"should": "^11.1.1",
|
||||
"typings-test": "^1.0.3"
|
||||
}
|
||||
}
|
||||
|
3
test/test.d.ts
vendored
3
test/test.d.ts
vendored
@ -1,2 +1 @@
|
||||
import "typings-test";
|
||||
import "should";
|
||||
import 'typings-test';
|
||||
|
96
test/test.js
96
test/test.js
File diff suppressed because one or more lines are too long
133
test/test.ts
133
test/test.ts
@ -1,70 +1,75 @@
|
||||
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(){
|
||||
import 'typings-test'
|
||||
import * as should from '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"));
|
||||
host: 'example.com',
|
||||
private: 'someExamplePrivateKey',
|
||||
public: 'someExamplePublicKey'
|
||||
})
|
||||
should(testSshKey).be.instanceof(smartssh.SshKey)
|
||||
})
|
||||
});
|
||||
describe(".SshInstance",function(){
|
||||
it('.type should be a valid type',function(){
|
||||
should(testSshKey.type).equal('duplex')
|
||||
})
|
||||
it('.publicKey should be public key',function(){
|
||||
should(testSshKey.pubKey).equal('someExamplePublicKey')
|
||||
})
|
||||
it('.privateKey should be private key',function(){
|
||||
should(testSshKey.privKey).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");
|
||||
testSshInstance = new smartssh.SshInstance({
|
||||
sshDirPath: path.join(process.cwd(),'test/temp/')
|
||||
})
|
||||
should(testSshInstance).be.instanceof(smartssh.SshInstance)
|
||||
})
|
||||
it(".removeKey() should remove a key",function(){
|
||||
testSshInstance.removeKey(testSshInstance.getKey("bitbucket.org"));
|
||||
testSshInstance.sshKeys[1].host.should.equal("github.com");
|
||||
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
|
||||
should(sshKeyArray).be.Array()
|
||||
should(sshKeyArray[0].host).equal('gitlab.com')
|
||||
should(sshKeyArray[1].host).equal('bitbucket.org')
|
||||
should(sshKeyArray[2].host).equal('github.com')
|
||||
})
|
||||
it('.getKey() should get a specific key selected by host',function(){
|
||||
should(testSshInstance.getKey('github.com').pubKey).equal('someGitHubPublicKey')
|
||||
})
|
||||
it('.removeKey() should remove a key',function(){
|
||||
testSshInstance.removeKey(testSshInstance.getKey('bitbucket.org'))
|
||||
should(testSshInstance.sshKeys[1].host).equal('github.com')
|
||||
})
|
||||
it('it should store to disk',function(){
|
||||
testSshInstance.writeToDisk()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
12
ts/index.ts
12
ts/index.ts
@ -1,7 +1,7 @@
|
||||
import "typings-global"
|
||||
import * as plugins from "./smartssh.plugins";
|
||||
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";
|
||||
export {SshInstance} from './smartssh.classes.sshinstance'
|
||||
export {SshKey} from './smartssh.classes.sshkey'
|
||||
export {SshDir} from './smartssh.classes.sshdir'
|
||||
export {SshConfig} from './smartssh.classes.sshconfig'
|
||||
|
@ -1,8 +1,8 @@
|
||||
import "typings-global"
|
||||
import * as plugins from "./smartssh.plugins";
|
||||
import {SshKey} from "./smartssh.classes.sshkey";
|
||||
import 'typings-global'
|
||||
import * as plugins from './smartssh.plugins'
|
||||
import {SshKey} from './smartssh.classes.sshkey'
|
||||
|
||||
export let sshKeyArrayFromDir = function(dirArg:string):SshKey[]{
|
||||
let sshKeyArray = []; //TODO
|
||||
return sshKeyArray;
|
||||
}
|
||||
export let sshKeyArrayFromDir = function(dirArg: string): SshKey[]{
|
||||
let sshKeyArray = [] // TODO
|
||||
return sshKeyArray
|
||||
}
|
||||
|
@ -1,52 +1,54 @@
|
||||
import "typings-global";
|
||||
import * as plugins from "./smartssh.plugins";
|
||||
import * as helpers from "./smartssh.classes.helpers";
|
||||
import {SshKey} from "./smartssh.classes.sshkey"
|
||||
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;
|
||||
private _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"
|
||||
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' +
|
||||
' StrictHostKeyChecking no' + '\n'
|
||||
}
|
||||
configArray.push({
|
||||
configString:configString,
|
||||
configString: configString,
|
||||
authorized: sshKey.authorized,
|
||||
sshKey: sshKey
|
||||
});
|
||||
})
|
||||
}
|
||||
let configFile:string = "";
|
||||
for(let key in configArray){
|
||||
configFile = configFile + configArray[key].configString + "\n";
|
||||
let configFile: string = ''
|
||||
for (let key in configArray) {
|
||||
configFile = configFile + configArray[key].configString + '\n'
|
||||
};
|
||||
plugins.smartfile.memory.toFsSync(configFile,dirPathArg);
|
||||
return done.promise;
|
||||
plugins.smartfile.memory.toFsSync(configFile,plugins.path.join(dirPathArg,'config'))
|
||||
return done.promise
|
||||
}
|
||||
read(dirPathArg){
|
||||
let done = plugins.q.defer();
|
||||
let configArray:configObject[];
|
||||
|
||||
return done.promise;
|
||||
read(dirPathArg) {
|
||||
let done = plugins.q.defer()
|
||||
let configArray: configObject[]
|
||||
plugins.smartfile.fs.toStringSync(plugins.path.join(dirPathArg,'config'))
|
||||
|
||||
return done.promise
|
||||
}
|
||||
};
|
||||
|
||||
export interface configObject {
|
||||
configString:string;
|
||||
authorized:boolean;
|
||||
sshKey:SshKey;
|
||||
configString: string
|
||||
authorized: boolean
|
||||
sshKey: SshKey
|
||||
};
|
||||
|
||||
|
@ -1,31 +1,38 @@
|
||||
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";
|
||||
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;
|
||||
private _path: string // the path of the ssh directory
|
||||
private _sshKeyArray: SshKey[]
|
||||
private _sshConfig: SshConfig
|
||||
constructor(sshKeyArray: SshKey[],sshConfig: SshConfig,sshDirPathArg?: string) {
|
||||
this._sshKeyArray = sshKeyArray
|
||||
this._sshConfig = sshConfig
|
||||
if (sshDirPathArg) {
|
||||
this._path = sshDirPathArg
|
||||
} else {
|
||||
this.path = plugins.path.join(plugins.smartpath.get.home(),".ssh/");
|
||||
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);
|
||||
writeToDir(dirPathArg?: string) { // syncs sshInstance to directory
|
||||
let path = this._path
|
||||
if (dirPathArg) path = dirPathArg
|
||||
this._sshKeyArray.forEach((sshKeyArg) => {
|
||||
sshKeyArg.store(path)
|
||||
})
|
||||
this._sshConfig.store(path)
|
||||
};
|
||||
readFromDir(){ // syncs sshInstance from directory
|
||||
|
||||
readFromDir(dirPathArg?: string) { // syncs sshInstance from directory
|
||||
let path = this._path
|
||||
if (dirPathArg) path = dirPathArg
|
||||
}
|
||||
getKeys(){
|
||||
return helpers.sshKeyArrayFromDir(this.path);
|
||||
updateDirPath(dirPathArg: string) {
|
||||
this._path = dirPathArg
|
||||
};
|
||||
getKeys() {
|
||||
return helpers.sshKeyArrayFromDir(this._path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,103 +1,103 @@
|
||||
import "typings-global"
|
||||
import * as plugins from "./smartssh.plugins";
|
||||
import * as helpers from "./smartssh.classes.helpers";
|
||||
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";
|
||||
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;
|
||||
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
|
||||
};
|
||||
|
||||
//FS methods
|
||||
// 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");
|
||||
writeToDisk(dirPathArg?: string) {
|
||||
this._sync('to',dirPathArg)
|
||||
}
|
||||
|
||||
/**
|
||||
* read ab SshInstance from disk
|
||||
*/
|
||||
readFromDisk(){
|
||||
this._sync("from");
|
||||
readFromDisk(dirPathArg?: string) {
|
||||
this._sync('from',dirPathArg)
|
||||
}
|
||||
|
||||
/* ===============================================================
|
||||
========================= Private Methods ========================
|
||||
================================================================*/
|
||||
|
||||
private _makeConfig (){
|
||||
private _makeConfig () {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* method to invoke SshInstance _sync automatically when sshSync is true
|
||||
*/
|
||||
private _syncAuto(directionArg){
|
||||
if(this._sshSync) this._sync(directionArg);
|
||||
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();
|
||||
private _sync(directionArg: string,dirPathArg?: string) {
|
||||
if (directionArg === 'from') {
|
||||
this._sshDir.readFromDir(dirPathArg) // call sync method of sshDir class;
|
||||
} else if (directionArg === 'to') {
|
||||
this._sshDir.writeToDir(dirPathArg)
|
||||
} else {
|
||||
throw new Error("directionArg not recognised. Must be 'to' or 'from'");
|
||||
throw new Error("directionArg not recognised. Must be 'to' or 'from'")
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -1,92 +1,99 @@
|
||||
import "typings-global";
|
||||
import * as plugins from "./smartssh.plugins";
|
||||
import * as helpers from "./smartssh.classes.helpers";
|
||||
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;
|
||||
private _privKey: string
|
||||
private _pubKey: string
|
||||
private _hostVar: string
|
||||
private _authorized: boolean
|
||||
|
||||
/**
|
||||
* the constructor for class SshKey
|
||||
*/
|
||||
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;
|
||||
return this._hostVar
|
||||
};
|
||||
set host(hostArg:string){
|
||||
this._hostVar = hostArg;
|
||||
set host(hostArg: string){
|
||||
this._hostVar = hostArg
|
||||
};
|
||||
|
||||
// this.privKey
|
||||
get privKey(){
|
||||
return this._privKey;
|
||||
return this._privKey
|
||||
};
|
||||
set privKey(privateKeyArg:string){
|
||||
this._privKey = privateKeyArg;
|
||||
set privKey(privateKeyArg: string){
|
||||
this._privKey = privateKeyArg
|
||||
};
|
||||
|
||||
// this.privKeyBase64
|
||||
get privKeyBase64(){
|
||||
return plugins.base64.encode(this._privKey);
|
||||
return plugins.smartstring.base64.encode(this._privKey)
|
||||
}
|
||||
set privKeyBase64(privateKeyArg:string) {
|
||||
this._privKey = plugins.base64.decode(privateKeyArg);
|
||||
set privKeyBase64(privateKeyArg: string) {
|
||||
this._privKey = plugins.smartstring.base64.decode(privateKeyArg)
|
||||
}
|
||||
|
||||
// this.pubKey
|
||||
get pubKey(){
|
||||
return this._pubKey;
|
||||
return this._pubKey
|
||||
}
|
||||
set pubKey(publicKeyArg:string){
|
||||
this._pubKey = publicKeyArg;
|
||||
set pubKey(publicKeyArg: string){
|
||||
this._pubKey = publicKeyArg
|
||||
};
|
||||
|
||||
// this.pubKeyBase64
|
||||
get pubKeyBase64(){
|
||||
return plugins.base64.encode(this._pubKey);
|
||||
return plugins.smartstring.base64.encode(this._pubKey)
|
||||
}
|
||||
set pubKeyBase64(publicKeyArg:string) {
|
||||
this._pubKey = plugins.base64.decode(publicKeyArg);
|
||||
set pubKeyBase64(publicKeyArg: string) {
|
||||
this._pubKey = plugins.smartstring.base64.decode(publicKeyArg)
|
||||
}
|
||||
|
||||
get authorized(){
|
||||
return this._authorized;
|
||||
return this._authorized
|
||||
}
|
||||
set authorized(authorizedArg:boolean){
|
||||
this._authorized = authorizedArg;
|
||||
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";
|
||||
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.")
|
||||
set type(someVlueArg: any){
|
||||
console.log('the type of an SshKey connot be set. This value is autpcomputed.')
|
||||
}
|
||||
|
||||
// methods
|
||||
read(filePathArg){
|
||||
|
||||
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));
|
||||
|
||||
store(dirPathArg: string) {
|
||||
plugins.fs.ensureDirSync(dirPathArg)
|
||||
let fileNameBase = this.host
|
||||
if (this._privKey) {
|
||||
let filePath = plugins.path.join(dirPathArg,fileNameBase)
|
||||
plugins.smartfile.memory.toFsSync(this._privKey,filePath)
|
||||
plugins.shelljs.chmod(600,filePath)
|
||||
};
|
||||
if (this._pubKey){
|
||||
plugins.smartfile.memory.toFsSync(this._pubKey,plugins.path.join(dirPathArg,fileNameBase + ".pub"));
|
||||
if (this._pubKey) {
|
||||
let filePath = plugins.path.join(dirPathArg,fileNameBase + '.pub')
|
||||
plugins.smartfile.memory.toFsSync(this._pubKey,filePath)
|
||||
plugins.shelljs.chmod(600,filePath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let testKey = new SshKey();
|
@ -1,9 +1,22 @@
|
||||
import "typings-global"
|
||||
export import beautylog = require("beautylog");
|
||||
export let base64 = require("js-base64").Base64;
|
||||
export let fs = require("fs-extra");
|
||||
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");
|
||||
import 'typings-global'
|
||||
import * as beautylog from 'beautylog'
|
||||
import * as fs from 'fs-extra'
|
||||
import * as minimatch from 'minimatch'
|
||||
import * as path from 'path'
|
||||
import * as q from 'q'
|
||||
import * as shelljs from 'shelljs'
|
||||
import * as smartfile from 'smartfile'
|
||||
import * as smartpath from 'smartpath'
|
||||
import * as smartstring from 'smartstring'
|
||||
|
||||
export {
|
||||
beautylog,
|
||||
fs,
|
||||
minimatch,
|
||||
path,
|
||||
q,
|
||||
shelljs,
|
||||
smartfile,
|
||||
smartpath,
|
||||
smartstring
|
||||
}
|
||||
|
3
tslint.json
Normal file
3
tslint.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "tslint-config-standard"
|
||||
}
|
Reference in New Issue
Block a user