update to latest standards
This commit is contained in:
parent
8f29f234f1
commit
27237f14c7
7
.gitignore
vendored
7
.gitignore
vendored
@ -1,8 +1,5 @@
|
|||||||
.idea/
|
|
||||||
node_modules/
|
node_modules/
|
||||||
coverage/
|
coverage/
|
||||||
docs/
|
pages/
|
||||||
ts/typings/
|
public/
|
||||||
ts/*.js
|
|
||||||
ts/*.js.map
|
|
||||||
test/temp/
|
test/temp/
|
@ -3,7 +3,16 @@ image: hosttoday/ht-docker-node:npmts
|
|||||||
stages:
|
stages:
|
||||||
- test
|
- test
|
||||||
- release
|
- release
|
||||||
- page
|
- trigger
|
||||||
|
- pages
|
||||||
|
|
||||||
|
testLEGACY:
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- npmci test legacy
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
allow_failure: true
|
||||||
|
|
||||||
testLTS:
|
testLTS:
|
||||||
stage: test
|
stage: test
|
||||||
@ -11,7 +20,6 @@ testLTS:
|
|||||||
- npmci test lts
|
- npmci test lts
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
- lossless
|
|
||||||
|
|
||||||
testSTABLE:
|
testSTABLE:
|
||||||
stage: test
|
stage: test
|
||||||
@ -19,13 +27,6 @@ testSTABLE:
|
|||||||
- npmci test stable
|
- npmci test stable
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
- lossless
|
|
||||||
|
|
||||||
testLEGACY:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci test legacy
|
|
||||||
allow_failure: true
|
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
@ -35,4 +36,24 @@ release:
|
|||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- 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
|
||||||
|
@ -3,6 +3,8 @@ setups SSH quickly and in a painless manner
|
|||||||
|
|
||||||
> Attention: This is still alpha, so some things won't work, not all things are inplemented.
|
> Attention: This is still alpha, so some things won't work, not all things are inplemented.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
|
10
dist/index.d.ts
vendored
10
dist/index.d.ts
vendored
@ -1,5 +1,5 @@
|
|||||||
import "typings-global";
|
import 'typings-global';
|
||||||
export { SshInstance } from "./smartssh.classes.sshinstance";
|
export { SshInstance } from './smartssh.classes.sshinstance';
|
||||||
export { SshKey } from "./smartssh.classes.sshkey";
|
export { SshKey } from './smartssh.classes.sshkey';
|
||||||
export { SshDir } from "./smartssh.classes.sshdir";
|
export { SshDir } from './smartssh.classes.sshdir';
|
||||||
export { SshConfig } from "./smartssh.classes.sshconfig";
|
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;
|
exports.SshDir = smartssh_classes_sshdir_1.SshDir;
|
||||||
var smartssh_classes_sshconfig_1 = require("./smartssh.classes.sshconfig");
|
var smartssh_classes_sshconfig_1 = require("./smartssh.classes.sshconfig");
|
||||||
exports.SshConfig = smartssh_classes_sshconfig_1.SshConfig;
|
exports.SshConfig = smartssh_classes_sshconfig_1.SshConfig;
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJm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Db25maWd9IGZyb20gXCIuL3NtYXJ0c3NoLmNsYXNzZXMuc3NoY29uZmlnXCI7Il19
|
|
4
dist/smartssh.classes.helpers.d.ts
vendored
4
dist/smartssh.classes.helpers.d.ts
vendored
@ -1,3 +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[];
|
||||||
|
5
dist/smartssh.classes.helpers.js
vendored
5
dist/smartssh.classes.helpers.js
vendored
@ -1,8 +1,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
require("typings-global");
|
require("typings-global");
|
||||||
exports.sshKeyArrayFromDir = function (dirArg) {
|
exports.sshKeyArrayFromDir = function (dirArg) {
|
||||||
var sshKeyArray = []; //TODO
|
let sshKeyArray = []; // TODO
|
||||||
return sshKeyArray;
|
return sshKeyArray;
|
||||||
};
|
};
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzc2guY2xhc3Nlcy5oZWxwZXJzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzc2guY2xhc3Nlcy5oZWxwZXJzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSwwQkFBdUI7QUFJWixRQUFBLGtCQUFrQixHQUFHLFVBQVMsTUFBYztJQUNuRCxJQUFJLFdBQVcsR0FBRyxFQUFFLENBQUEsQ0FBQyxPQUFPO0lBQzVCLE1BQU0sQ0FBQyxXQUFXLENBQUE7QUFDdEIsQ0FBQyxDQUFBIn0=
|
||||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3NoLmNsYXNzZXMuaGVscGVycy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsUUFBTyxnQkFDUCxDQUFDLENBRHNCO0FBSVosMEJBQWtCLEdBQUcsVUFBUyxNQUFhO0lBQ2xELElBQUksV0FBVyxHQUFHLEVBQUUsQ0FBQyxDQUFDLE1BQU07SUFDNUIsTUFBTSxDQUFDLFdBQVcsQ0FBQztBQUN2QixDQUFDLENBQUEiLCJmaWxlIjoic21hcnRzc2guY2xhc3Nlcy5oZWxwZXJzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFwidHlwaW5ncy1nbG9iYWxcIlxuaW1wb3J0ICogYXMgcGx1Z2lucyBmcm9tIFwiLi9zbWFydHNzaC5wbHVnaW5zXCI7XG5pbXBvcnQge1NzaEtleX0gZnJvbSBcIi4vc21hcnRzc2guY2xhc3Nlcy5zc2hrZXlcIjtcblxuZXhwb3J0IGxldCBzc2hLZXlBcnJheUZyb21EaXIgPSBmdW5jdGlvbihkaXJBcmc6c3RyaW5nKTpTc2hLZXlbXXtcbiAgICBsZXQgc3NoS2V5QXJyYXkgPSBbXTsgLy9UT0RPXG4gICAgcmV0dXJuIHNzaEtleUFycmF5O1xufSJdfQ==
|
|
9
dist/smartssh.classes.sshconfig.d.ts
vendored
9
dist/smartssh.classes.sshconfig.d.ts
vendored
@ -1,13 +1,14 @@
|
|||||||
import "typings-global";
|
/// <reference types="q" />
|
||||||
import { SshKey } from "./smartssh.classes.sshkey";
|
import 'typings-global';
|
||||||
|
import { SshKey } from './smartssh.classes.sshkey';
|
||||||
export declare class SshConfig {
|
export declare class SshConfig {
|
||||||
private _sshKeyArray;
|
private _sshKeyArray;
|
||||||
constructor(sshKeyArrayArg: SshKey[]);
|
constructor(sshKeyArrayArg: SshKey[]);
|
||||||
/**
|
/**
|
||||||
* stores a config file
|
* stores a config file
|
||||||
*/
|
*/
|
||||||
store(dirPathArg: string): any;
|
store(dirPathArg: string): Q.Promise<{}>;
|
||||||
read(dirPathArg: any): any;
|
read(dirPathArg: any): Q.Promise<{}>;
|
||||||
}
|
}
|
||||||
export interface configObject {
|
export interface configObject {
|
||||||
configString: string;
|
configString: string;
|
||||||
|
52
dist/smartssh.classes.sshconfig.js
vendored
52
dist/smartssh.classes.sshconfig.js
vendored
@ -1,24 +1,24 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
require("typings-global");
|
require("typings-global");
|
||||||
var plugins = require("./smartssh.plugins");
|
const plugins = require("./smartssh.plugins");
|
||||||
var SshConfig = (function () {
|
class SshConfig {
|
||||||
function SshConfig(sshKeyArrayArg) {
|
constructor(sshKeyArrayArg) {
|
||||||
this._sshKeyArray = sshKeyArrayArg;
|
this._sshKeyArray = sshKeyArrayArg;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* stores a config file
|
* stores a config file
|
||||||
*/
|
*/
|
||||||
SshConfig.prototype.store = function (dirPathArg) {
|
store(dirPathArg) {
|
||||||
var done = plugins.q.defer();
|
let done = plugins.q.defer();
|
||||||
var configArray = [];
|
let configArray = [];
|
||||||
var configString;
|
let configString;
|
||||||
for (var key in this._sshKeyArray) {
|
for (let key in this._sshKeyArray) {
|
||||||
var sshKey = this._sshKeyArray[key];
|
let sshKey = this._sshKeyArray[key];
|
||||||
if (sshKey.host) {
|
if (sshKey.host) {
|
||||||
configString = "Host " + sshKey.host + "\n" +
|
configString = 'Host ' + sshKey.host + '\n' +
|
||||||
" HostName " + sshKey.host + "\n" +
|
' HostName ' + sshKey.host + '\n' +
|
||||||
" IdentityFile ~/.ssh/" + sshKey.host + "\n" +
|
' IdentityFile ~/.ssh/' + sshKey.host + '\n' +
|
||||||
" StrictHostKeyChecking no" + "\n";
|
' StrictHostKeyChecking no' + '\n';
|
||||||
}
|
}
|
||||||
configArray.push({
|
configArray.push({
|
||||||
configString: configString,
|
configString: configString,
|
||||||
@ -26,24 +26,22 @@ var SshConfig = (function () {
|
|||||||
sshKey: sshKey
|
sshKey: sshKey
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
var configFile = "";
|
let configFile = '';
|
||||||
for (var key in configArray) {
|
for (let key in configArray) {
|
||||||
configFile = configFile + configArray[key].configString + "\n";
|
configFile = configFile + configArray[key].configString + '\n';
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
plugins.smartfile.memory.toFsSync(configFile, plugins.path.join(dirPathArg, "config"));
|
plugins.smartfile.memory.toFsSync(configFile, plugins.path.join(dirPathArg, 'config'));
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
}
|
||||||
SshConfig.prototype.read = function (dirPathArg) {
|
read(dirPathArg) {
|
||||||
var done = plugins.q.defer();
|
let done = plugins.q.defer();
|
||||||
var configArray;
|
let configArray;
|
||||||
plugins.smartfile.fs.toStringSync(plugins.path.join(dirPathArg, "config"));
|
plugins.smartfile.fs.toStringSync(plugins.path.join(dirPathArg, 'config'));
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
}
|
||||||
return SshConfig;
|
}
|
||||||
}());
|
|
||||||
exports.SshConfig = SshConfig;
|
exports.SshConfig = SshConfig;
|
||||||
;
|
;
|
||||||
;
|
;
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzc2guY2xhc3Nlcy5zc2hjb25maWcuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHNzaC5jbGFzc2VzLnNzaGNvbmZpZy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMEJBQXVCO0FBQ3ZCLDhDQUE2QztBQUk3QztJQUVJLFlBQVksY0FBd0I7UUFDaEMsSUFBSSxDQUFDLFlBQVksR0FBRyxjQUFjLENBQUE7SUFDdEMsQ0FBQztJQUVEOztPQUVHO0lBQ0gsS0FBSyxDQUFDLFVBQWtCO1FBQ3BCLElBQUksSUFBSSxHQUFHLE9BQU8sQ0FBQyxDQUFDLENBQUMsS0FBSyxFQUFFLENBQUE7UUFDNUIsSUFBSSxXQUFXLEdBQW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ZGlyUGF0aEFyZzpzdHJpbmcpe1xuICAgICAgICBsZXQgZG9uZSA9IHBsdWdpbnMucS5kZWZlcigpO1xuICAgICAgICBsZXQgY29uZmlnQXJyYXk6Y29uZmlnT2JqZWN0W10gPSBbXTtcbiAgICAgICAgbGV0IGNvbmZpZ1N0cmluZztcbiAgICAgICAgZm9yKGxldCBrZXkgaW4gdGhpcy5fc3NoS2V5QXJyYXkpe1xuICAgICAgICAgICAgbGV0IHNzaEtleSA9IHRoaXMuX3NzaEtleUFycmF5W2tleV07XG4gICAgICAgICAgICBpZihzc2hLZXkuaG9zdCl7XG4gICAgICAgICAgICAgICAgY29uZmlnU3RyaW5nID0gXCJIb3N0IFwiICsgc3NoS2V5Lmhvc3QgKyBcIlxcblwiICtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXCIgIEhvc3ROYW1lIFwiICsgc3NoS2V5Lmhvc3QgKyBcIlxcblwiICtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXCIgIElkZW50aXR5RmlsZSB+Ly5zc2gvXCIgKyBzc2hLZXkuaG9zdCArIFwiXFxuXCIgK1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcIiAgU3RyaWN0SG9zdEtleUNoZWNraW5nIG5vXCIgKyBcIlxcblwiXG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjb25maWdBcnJheS5wdXNoKHtcbiAgICAgICAgICAgICAgICBjb25maWdTdHJpbmc6Y29uZmlnU3RyaW5nLFxuICAgICAgICAgICAgICAgIGF1dGhvcml6ZWQ6IHNzaEtleS5hdXRob3JpemVkLFxuICAgICAgICAgICAgICAgIHNzaEtleTogc3NoS2V5XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgICAgICBsZXQgY29uZmlnRmlsZTpzdHJpbmcgPSBcIlwiO1xuICAgICAgICBmb3IobGV0IGtleSBpbiBjb25maWdBcnJheSl7XG4gICAgICAgICAgICBjb25maWdGaWxlID0gY29uZmlnRmlsZSArIGNvbmZpZ0FycmF5W2tleV0uY29uZmlnU3RyaW5nICsgXCJcXG5cIjtcbiAgICAgICAgfTtcbiAgICAgICAgcGx1Z2lucy5zbWFydGZpbGUubWVtb3J5LnRvRnNTeW5jKGNvbmZpZ0ZpbGUscGx1Z2lucy5wYXRoLmpvaW4oZGlyUGF0aEFyZyxcImNvbmZpZ1wiKSk7XG4gICAgICAgIHJldHVybiBkb25lLnByb21pc2U7XG4gICAgfVxuICAgIHJlYWQoZGlyUGF0aEFyZyl7XG4gICAgICAgIGxldCBkb25lID0gcGx1Z2lucy5xLmRlZmVyKCk7XG4gICAgICAgIGxldCBjb25maWdBcnJheTpjb25maWdPYmplY3RbXTtcbiAgICAgICAgcGx1Z2lucy5zbWFydGZpbGUuZnMudG9TdHJpbmdTeW5jKHBsdWdpbnMucGF0aC5qb2luKGRpclBhdGhBcmcsXCJjb25maWdcIikpO1xuXG4gICAgICAgIHJldHVybiBkb25lLnByb21pc2U7XG4gICAgfVxufTtcblxuZXhwb3J0IGludGVyZmFjZSBjb25maWdPYmplY3Qge1xuICAgIGNvbmZpZ1N0cmluZzpzdHJpbmc7XG4gICAgYXV0aG9yaXplZDpib29sZWFuO1xuICAgIHNzaEtleTpTc2hLZXk7XG59O1xuXG4iXX0=
|
|
6
dist/smartssh.classes.sshdir.d.ts
vendored
6
dist/smartssh.classes.sshdir.d.ts
vendored
@ -1,6 +1,6 @@
|
|||||||
import "typings-global";
|
import 'typings-global';
|
||||||
import { SshKey } from "./smartssh.classes.sshkey";
|
import { SshKey } from './smartssh.classes.sshkey';
|
||||||
import { SshConfig } from "./smartssh.classes.sshconfig";
|
import { SshConfig } from './smartssh.classes.sshconfig';
|
||||||
export declare class SshDir {
|
export declare class SshDir {
|
||||||
private _path;
|
private _path;
|
||||||
private _sshKeyArray;
|
private _sshKeyArray;
|
||||||
|
38
dist/smartssh.classes.sshdir.js
vendored
38
dist/smartssh.classes.sshdir.js
vendored
@ -1,43 +1,41 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
require("typings-global");
|
require("typings-global");
|
||||||
var plugins = require("./smartssh.plugins");
|
const plugins = require("./smartssh.plugins");
|
||||||
var helpers = require("./smartssh.classes.helpers");
|
const helpers = require("./smartssh.classes.helpers");
|
||||||
var SshDir = (function () {
|
class SshDir {
|
||||||
function SshDir(sshKeyArray, sshConfig, sshDirPathArg) {
|
constructor(sshKeyArray, sshConfig, sshDirPathArg) {
|
||||||
this._sshKeyArray = sshKeyArray;
|
this._sshKeyArray = sshKeyArray;
|
||||||
this._sshConfig = sshConfig;
|
this._sshConfig = sshConfig;
|
||||||
if (sshDirPathArg) {
|
if (sshDirPathArg) {
|
||||||
this._path = sshDirPathArg;
|
this._path = sshDirPathArg;
|
||||||
}
|
}
|
||||||
else {
|
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 (dirPathArg) {
|
writeToDir(dirPathArg) {
|
||||||
var path = this._path;
|
let path = this._path;
|
||||||
if (dirPathArg)
|
if (dirPathArg)
|
||||||
path = dirPathArg;
|
path = dirPathArg;
|
||||||
this._sshKeyArray.forEach(function (sshKeyArg) {
|
this._sshKeyArray.forEach((sshKeyArg) => {
|
||||||
sshKeyArg.store(path);
|
sshKeyArg.store(path);
|
||||||
});
|
});
|
||||||
this._sshConfig.store(path);
|
this._sshConfig.store(path);
|
||||||
};
|
}
|
||||||
;
|
;
|
||||||
SshDir.prototype.readFromDir = function (dirPathArg) {
|
readFromDir(dirPathArg) {
|
||||||
var path = this._path;
|
let path = this._path;
|
||||||
if (dirPathArg)
|
if (dirPathArg)
|
||||||
path = dirPathArg;
|
path = dirPathArg;
|
||||||
};
|
}
|
||||||
SshDir.prototype.updateDirPath = function (dirPathArg) {
|
updateDirPath(dirPathArg) {
|
||||||
this._path = dirPathArg;
|
this._path = dirPathArg;
|
||||||
};
|
}
|
||||||
;
|
;
|
||||||
SshDir.prototype.getKeys = function () {
|
getKeys() {
|
||||||
return helpers.sshKeyArrayFromDir(this._path);
|
return helpers.sshKeyArrayFromDir(this._path);
|
||||||
};
|
}
|
||||||
return SshDir;
|
}
|
||||||
}());
|
|
||||||
exports.SshDir = SshDir;
|
exports.SshDir = SshDir;
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzc2guY2xhc3Nlcy5zc2hkaXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHNzaC5jbGFzc2VzLnNzaGRpci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMEJBQXVCO0FBQ3ZCLDhDQUE2QztBQUM3QyxzREFBcUQ7QUFJckQ7SUFJSSxZQUFZLFdBQXFCLEVBQUMsU0FBb0IsRUFBQyxhQUFzQjtRQUN6RSxJQUFJLENBQUMsWUFBWSxHQUFHLFdBQVcsQ0FBQTtRQUMvQixJQUFJLENBQUMsVUFBVSxHQUFHLFNBQVMsQ0FBQTtRQUMzQixFQUFFLENBQUMsQ0FBQyxhQUFhLENBQUMsQ0FBQyxDQUFDO1lBQ2hCLElBQUksQ0FBQyxLQUFLLEdBQUcsYUFBYSxDQUFBO1FBQzlCLENBQUM7UUFBQyxJQUFJLENBQUMsQ0FBQztZQUNKLElBQUksQ0FBQyxLQUFLLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDLFNBQVMsQ0FBQyxHQUFHLENBQUMsSUFBSSxFQUFFLEVBQUMsT0FBTyxDQUFDLENBQUE7UUFDeEUsQ0FBQztRQUFBLENBQUM7SUFDTixDQUFDO0lBQ0QsVUFBVSxDQUFDLFVBQW1CO1FBQzFCLElBQUksSUFBSSxHQUFHLElBQUksQ0FBQyxLQUFLLENBQUE7UUFDckI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UGF0aEFyZztcbiAgICB9O1xuICAgIGdldEtleXMoKXtcbiAgICAgICAgcmV0dXJuIGhlbHBlcnMuc3NoS2V5QXJyYXlGcm9tRGlyKHRoaXMuX3BhdGgpO1xuICAgIH1cbn0iXX0=
|
|
6
dist/smartssh.classes.sshinstance.d.ts
vendored
6
dist/smartssh.classes.sshinstance.d.ts
vendored
@ -1,5 +1,5 @@
|
|||||||
import "typings-global";
|
import 'typings-global';
|
||||||
import { SshKey } from "./smartssh.classes.sshkey";
|
import { SshKey } from './smartssh.classes.sshkey';
|
||||||
export declare class SshInstance {
|
export declare class SshInstance {
|
||||||
private _sshKeyArray;
|
private _sshKeyArray;
|
||||||
private _sshConfig;
|
private _sshConfig;
|
||||||
@ -13,7 +13,7 @@ export declare class SshInstance {
|
|||||||
removeKey(sshKeyArg: SshKey): void;
|
removeKey(sshKeyArg: SshKey): void;
|
||||||
replaceKey(sshKeyOldArg: SshKey, sshKeyNewArg: SshKey): void;
|
replaceKey(sshKeyOldArg: SshKey, sshKeyNewArg: SshKey): void;
|
||||||
getKey(hostArg: string): SshKey;
|
getKey(hostArg: string): SshKey;
|
||||||
sshKeys: SshKey[];
|
readonly sshKeys: SshKey[];
|
||||||
/**
|
/**
|
||||||
* write SshInstance to disk
|
* write SshInstance to disk
|
||||||
*/
|
*/
|
||||||
|
89
dist/smartssh.classes.sshinstance.js
vendored
89
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 {
|
export declare class SshKey {
|
||||||
private _privKey;
|
private _privKey;
|
||||||
private _pubKey;
|
private _pubKey;
|
||||||
private _hostVar;
|
private _hostVar;
|
||||||
private _authorized;
|
private _authorized;
|
||||||
|
/**
|
||||||
|
* the constructor for class SshKey
|
||||||
|
*/
|
||||||
constructor(optionsArg?: {
|
constructor(optionsArg?: {
|
||||||
private?: string;
|
private?: string;
|
||||||
public?: string;
|
public?: string;
|
||||||
|
135
dist/smartssh.classes.sshkey.js
vendored
135
dist/smartssh.classes.sshkey.js
vendored
File diff suppressed because one or more lines are too long
21
dist/smartssh.plugins.d.ts
vendored
21
dist/smartssh.plugins.d.ts
vendored
@ -1,10 +1,11 @@
|
|||||||
import "typings-global";
|
import 'typings-global';
|
||||||
export import beautylog = require("beautylog");
|
import * as beautylog from 'beautylog';
|
||||||
export declare let base64: any;
|
import * as fs from 'fs-extra';
|
||||||
export declare let fs: any;
|
import * as minimatch from 'minimatch';
|
||||||
export declare let minimatch: any;
|
import * as path from 'path';
|
||||||
export import path = require("path");
|
import * as q from 'q';
|
||||||
export declare let q: any;
|
import * as shelljs from 'shelljs';
|
||||||
export declare let shelljs: any;
|
import * as smartfile from 'smartfile';
|
||||||
export import smartfile = require("smartfile");
|
import * as smartpath from 'smartpath';
|
||||||
export import smartpath = require("smartpath");
|
import * as smartstring from 'smartstring';
|
||||||
|
export { beautylog, fs, minimatch, path, q, shelljs, smartfile, smartpath, smartstring };
|
||||||
|
30
dist/smartssh.plugins.js
vendored
30
dist/smartssh.plugins.js
vendored
@ -1,13 +1,21 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
require("typings-global");
|
require("typings-global");
|
||||||
exports.beautylog = require("beautylog");
|
const beautylog = require("beautylog");
|
||||||
exports.base64 = require("js-base64").Base64;
|
exports.beautylog = beautylog;
|
||||||
exports.fs = require("fs-extra");
|
const fs = require("fs-extra");
|
||||||
exports.minimatch = require("minimatch");
|
exports.fs = fs;
|
||||||
exports.path = require("path");
|
const minimatch = require("minimatch");
|
||||||
exports.q = require("q");
|
exports.minimatch = minimatch;
|
||||||
exports.shelljs = require("shelljs");
|
const path = require("path");
|
||||||
exports.smartfile = require("smartfile");
|
exports.path = path;
|
||||||
exports.smartpath = require("smartpath");
|
const q = require("q");
|
||||||
|
exports.q = q;
|
||||||
//# sourceMapping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CIpO1xuZXhwb3J0IGxldCBzaGVsbGpzID0gcmVxdWlyZShcInNoZWxsanNcIik7XG5leHBvcnQgaW1wb3J0IHNtYXJ0ZmlsZSA9IHJlcXVpcmUoXCJzbWFydGZpbGVcIik7XG5leHBvcnQgaW1wb3J0IHNtYXJ0cGF0aCA9IHJlcXVpcmUoXCJzbWFydHBhdGhcIik7Il19
|
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
|
28
package.json
28
package.json
@ -23,19 +23,25 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/smartssh#readme",
|
"homepage": "https://gitlab.com/pushrocks/smartssh#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"beautylog": "^5.0.12",
|
"@types/fs-extra": "0.0.35",
|
||||||
"fs-extra": "^0.30.0",
|
"@types/js-base64": "^2.1.5",
|
||||||
"js-base64": "^2.1.9",
|
"@types/minimatch": "^2.0.29",
|
||||||
"minimatch": "^3.0.2",
|
"@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",
|
"q": "^1.4.1",
|
||||||
"shelljs": "^0.7.0",
|
"shelljs": "^0.7.5",
|
||||||
"smartfile": "^4.0.5",
|
"smartfile": "^4.1.0",
|
||||||
"smartpath": "^3.2.2",
|
"smartpath": "^3.2.5",
|
||||||
"typings-global": "^1.0.3",
|
"smartstring": "^2.0.22",
|
||||||
"typings-test": "^1.0.1"
|
"typings-global": "^1.0.14"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"npmts-g": "^5.2.6",
|
"@types/should": "^8.1.30",
|
||||||
"should": "^9.0.2"
|
"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 'typings-test';
|
||||||
import "should";
|
|
||||||
|
93
test/test.js
93
test/test.js
File diff suppressed because one or more lines are too long
136
test/test.ts
136
test/test.ts
@ -1,75 +1,75 @@
|
|||||||
import "typings-test"
|
import 'typings-test'
|
||||||
import "should";
|
import * as should from 'should'
|
||||||
import smartssh = require("../dist/index");
|
import smartssh = require('../dist/index')
|
||||||
import path = require("path");
|
import path = require('path')
|
||||||
describe("smartssh",function(){
|
describe('smartssh',function(){
|
||||||
let testSshInstance:smartssh.SshInstance;
|
let testSshInstance: smartssh.SshInstance
|
||||||
let testSshKey:smartssh.SshKey;
|
let testSshKey: smartssh.SshKey
|
||||||
describe(".SshKey",function(){
|
describe('.SshKey',function(){
|
||||||
it("'new' keyword should create a valid SshKey object",function(){
|
it("'new' keyword should create a valid SshKey object",function(){
|
||||||
testSshKey = new smartssh.SshKey({
|
testSshKey = new smartssh.SshKey({
|
||||||
host:"example.com",
|
host: 'example.com',
|
||||||
private:"someExamplePrivateKey",
|
private: 'someExamplePrivateKey',
|
||||||
public:"someExamplePublicKey"
|
public: 'someExamplePublicKey'
|
||||||
});
|
})
|
||||||
testSshKey.should.be.instanceof(smartssh.SshKey);
|
should(testSshKey).be.instanceof(smartssh.SshKey)
|
||||||
});
|
})
|
||||||
it(".type should be a valid type",function(){
|
it('.type should be a valid type',function(){
|
||||||
testSshKey.type.should.equal("duplex");
|
should(testSshKey.type).equal('duplex')
|
||||||
});
|
})
|
||||||
it(".publicKey should be public key",function(){
|
it('.publicKey should be public key',function(){
|
||||||
testSshKey.pubKey.should.equal("someExamplePublicKey");
|
should(testSshKey.pubKey).equal('someExamplePublicKey')
|
||||||
});
|
})
|
||||||
it(".privateKey should be private key",function(){
|
it('.privateKey should be private key',function(){
|
||||||
testSshKey.privKey.should.equal("someExamplePrivateKey");
|
should(testSshKey.privKey).equal('someExamplePrivateKey')
|
||||||
});
|
})
|
||||||
it(".publicKeyBase64 should be public key base 64 encoded",function(){
|
it('.publicKeyBase64 should be public key base 64 encoded',function(){
|
||||||
testSshKey.pubKeyBase64;
|
testSshKey.pubKeyBase64
|
||||||
});
|
})
|
||||||
it(".store() should store the file to disk",function(){
|
it('.store() should store the file to disk',function(){
|
||||||
testSshKey.store(path.join(process.cwd(),"test/temp"));
|
testSshKey.store(path.join(process.cwd(),'test/temp'))
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
describe(".SshInstance",function(){
|
describe('.SshInstance',function(){
|
||||||
it("'new' keyword 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({
|
||||||
sshDirPath: path.join(process.cwd(),"test/temp/")
|
sshDirPath: path.join(process.cwd(),'test/temp/')
|
||||||
});
|
})
|
||||||
testSshInstance.should.be.instanceof(smartssh.SshInstance);
|
should(testSshInstance).be.instanceof(smartssh.SshInstance)
|
||||||
});
|
})
|
||||||
it(".addKey() 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',
|
||||||
host:"gitlab.com"
|
host: 'gitlab.com'
|
||||||
}));
|
}))
|
||||||
testSshInstance.addKey(new smartssh.SshKey({
|
testSshInstance.addKey(new smartssh.SshKey({
|
||||||
public:"somePublicKey",
|
public: 'somePublicKey',
|
||||||
private:"somePrivateKey",
|
private: 'somePrivateKey',
|
||||||
host:"bitbucket.org"
|
host: 'bitbucket.org'
|
||||||
}));
|
}))
|
||||||
testSshInstance.addKey(new smartssh.SshKey({
|
testSshInstance.addKey(new smartssh.SshKey({
|
||||||
public:"someGitHubPublicKey",
|
public: 'someGitHubPublicKey',
|
||||||
private:"someGitHubPrivateKey",
|
private: 'someGitHubPrivateKey',
|
||||||
host:"github.com"
|
host: 'github.com'
|
||||||
}));
|
}))
|
||||||
});
|
})
|
||||||
it(".sshKeys should point to an array of sshKeys",function(){
|
it('.sshKeys should point to an array of sshKeys',function(){
|
||||||
let sshKeyArray = testSshInstance.sshKeys;
|
let sshKeyArray = testSshInstance.sshKeys
|
||||||
sshKeyArray.should.be.Array();
|
should(sshKeyArray).be.Array()
|
||||||
sshKeyArray[0].host.should.equal("gitlab.com");
|
should(sshKeyArray[0].host).equal('gitlab.com')
|
||||||
sshKeyArray[1].host.should.equal("bitbucket.org");
|
should(sshKeyArray[1].host).equal('bitbucket.org')
|
||||||
sshKeyArray[2].host.should.equal("github.com");
|
should(sshKeyArray[2].host).equal('github.com')
|
||||||
});
|
})
|
||||||
it(".getKey() should get a specific key selected by host",function(){
|
it('.getKey() should get a specific key selected by host',function(){
|
||||||
testSshInstance.getKey("github.com").pubKey.should.equal("someGitHubPublicKey");
|
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()
|
||||||
})
|
})
|
||||||
it(".removeKey() should remove a key",function(){
|
|
||||||
testSshInstance.removeKey(testSshInstance.getKey("bitbucket.org"));
|
|
||||||
testSshInstance.sshKeys[1].host.should.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 'typings-global'
|
||||||
import * as plugins from "./smartssh.plugins";
|
import * as plugins from './smartssh.plugins'
|
||||||
|
|
||||||
export {SshInstance} from "./smartssh.classes.sshinstance";
|
export {SshInstance} from './smartssh.classes.sshinstance'
|
||||||
export {SshKey} from "./smartssh.classes.sshkey";
|
export {SshKey} from './smartssh.classes.sshkey'
|
||||||
export {SshDir} from "./smartssh.classes.sshdir";
|
export {SshDir} from './smartssh.classes.sshdir'
|
||||||
export {SshConfig} from "./smartssh.classes.sshconfig";
|
export {SshConfig} from './smartssh.classes.sshconfig'
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import "typings-global"
|
import 'typings-global'
|
||||||
import * as plugins from "./smartssh.plugins";
|
import * as plugins from './smartssh.plugins'
|
||||||
import {SshKey} from "./smartssh.classes.sshkey";
|
import {SshKey} from './smartssh.classes.sshkey'
|
||||||
|
|
||||||
export let sshKeyArrayFromDir = function(dirArg: string): SshKey[]{
|
export let sshKeyArrayFromDir = function(dirArg: string): SshKey[]{
|
||||||
let sshKeyArray = []; //TODO
|
let sshKeyArray = [] // TODO
|
||||||
return sshKeyArray;
|
return sshKeyArray
|
||||||
}
|
}
|
@ -1,54 +1,54 @@
|
|||||||
import "typings-global";
|
import 'typings-global'
|
||||||
import * as plugins from "./smartssh.plugins";
|
import * as plugins from './smartssh.plugins'
|
||||||
import * as helpers from "./smartssh.classes.helpers";
|
import * as helpers from './smartssh.classes.helpers'
|
||||||
import {SshKey} from "./smartssh.classes.sshkey"
|
import {SshKey} from './smartssh.classes.sshkey'
|
||||||
|
|
||||||
export class SshConfig {
|
export class SshConfig {
|
||||||
private _sshKeyArray:SshKey[];
|
private _sshKeyArray: SshKey[]
|
||||||
constructor(sshKeyArrayArg: SshKey[]) {
|
constructor(sshKeyArrayArg: SshKey[]) {
|
||||||
this._sshKeyArray = sshKeyArrayArg;
|
this._sshKeyArray = sshKeyArrayArg
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* stores a config file
|
* stores a config file
|
||||||
*/
|
*/
|
||||||
store(dirPathArg: string) {
|
store(dirPathArg: string) {
|
||||||
let done = plugins.q.defer();
|
let done = plugins.q.defer()
|
||||||
let configArray:configObject[] = [];
|
let configArray: configObject[] = []
|
||||||
let configString;
|
let configString
|
||||||
for (let key in this._sshKeyArray) {
|
for (let key in this._sshKeyArray) {
|
||||||
let sshKey = this._sshKeyArray[key];
|
let sshKey = this._sshKeyArray[key]
|
||||||
if (sshKey.host) {
|
if (sshKey.host) {
|
||||||
configString = "Host " + sshKey.host + "\n" +
|
configString = 'Host ' + sshKey.host + '\n' +
|
||||||
" HostName " + sshKey.host + "\n" +
|
' HostName ' + sshKey.host + '\n' +
|
||||||
" IdentityFile ~/.ssh/" + sshKey.host + "\n" +
|
' IdentityFile ~/.ssh/' + sshKey.host + '\n' +
|
||||||
" StrictHostKeyChecking no" + "\n"
|
' StrictHostKeyChecking no' + '\n'
|
||||||
}
|
}
|
||||||
configArray.push({
|
configArray.push({
|
||||||
configString: configString,
|
configString: configString,
|
||||||
authorized: sshKey.authorized,
|
authorized: sshKey.authorized,
|
||||||
sshKey: sshKey
|
sshKey: sshKey
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
let configFile:string = "";
|
let configFile: string = ''
|
||||||
for (let key in configArray) {
|
for (let key in configArray) {
|
||||||
configFile = configFile + configArray[key].configString + "\n";
|
configFile = configFile + configArray[key].configString + '\n'
|
||||||
};
|
};
|
||||||
plugins.smartfile.memory.toFsSync(configFile,plugins.path.join(dirPathArg,"config"));
|
plugins.smartfile.memory.toFsSync(configFile,plugins.path.join(dirPathArg,'config'))
|
||||||
return done.promise;
|
return done.promise
|
||||||
}
|
}
|
||||||
read(dirPathArg) {
|
read(dirPathArg) {
|
||||||
let done = plugins.q.defer();
|
let done = plugins.q.defer()
|
||||||
let configArray:configObject[];
|
let configArray: configObject[]
|
||||||
plugins.smartfile.fs.toStringSync(plugins.path.join(dirPathArg,"config"));
|
plugins.smartfile.fs.toStringSync(plugins.path.join(dirPathArg,'config'))
|
||||||
|
|
||||||
return done.promise;
|
return done.promise
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface configObject {
|
export interface configObject {
|
||||||
configString:string;
|
configString: string
|
||||||
authorized:boolean;
|
authorized: boolean
|
||||||
sshKey:SshKey;
|
sshKey: SshKey
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,38 +1,38 @@
|
|||||||
import "typings-global";
|
import 'typings-global'
|
||||||
import * as plugins from "./smartssh.plugins";
|
import * as plugins from './smartssh.plugins'
|
||||||
import * as helpers from "./smartssh.classes.helpers";
|
import * as helpers from './smartssh.classes.helpers'
|
||||||
import {SshInstance} from "./smartssh.classes.sshinstance";
|
import {SshInstance} from './smartssh.classes.sshinstance'
|
||||||
import {SshKey} from "./smartssh.classes.sshkey";
|
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
|
||||||
private _path:string; // the path of the ssh directory
|
private _path: string // the path of the ssh directory
|
||||||
private _sshKeyArray:SshKey[];
|
private _sshKeyArray: SshKey[]
|
||||||
private _sshConfig:SshConfig;
|
private _sshConfig: SshConfig
|
||||||
constructor(sshKeyArray: SshKey[],sshConfig: SshConfig,sshDirPathArg?: string) {
|
constructor(sshKeyArray: SshKey[],sshConfig: SshConfig,sshDirPathArg?: string) {
|
||||||
this._sshKeyArray = sshKeyArray;
|
this._sshKeyArray = sshKeyArray
|
||||||
this._sshConfig = sshConfig;
|
this._sshConfig = sshConfig
|
||||||
if (sshDirPathArg) {
|
if (sshDirPathArg) {
|
||||||
this._path = sshDirPathArg;
|
this._path = sshDirPathArg
|
||||||
} else {
|
} else {
|
||||||
this._path = plugins.path.join(plugins.smartpath.get.home(),".ssh/");
|
this._path = plugins.path.join(plugins.smartpath.get.home(),'.ssh/')
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
writeToDir(dirPathArg?: string) { // syncs sshInstance to directory
|
writeToDir(dirPathArg?: string) { // syncs sshInstance to directory
|
||||||
let path = this._path;
|
let path = this._path
|
||||||
if(dirPathArg) path = dirPathArg;
|
if (dirPathArg) path = dirPathArg
|
||||||
this._sshKeyArray.forEach((sshKeyArg) => {
|
this._sshKeyArray.forEach((sshKeyArg) => {
|
||||||
sshKeyArg.store(path);
|
sshKeyArg.store(path)
|
||||||
});
|
})
|
||||||
this._sshConfig.store(path);
|
this._sshConfig.store(path)
|
||||||
};
|
};
|
||||||
readFromDir(dirPathArg?: string) { // syncs sshInstance from directory
|
readFromDir(dirPathArg?: string) { // syncs sshInstance from directory
|
||||||
let path = this._path;
|
let path = this._path
|
||||||
if(dirPathArg) path = dirPathArg;
|
if (dirPathArg) path = dirPathArg
|
||||||
}
|
}
|
||||||
updateDirPath(dirPathArg: string) {
|
updateDirPath(dirPathArg: string) {
|
||||||
this._path = dirPathArg;
|
this._path = dirPathArg
|
||||||
};
|
};
|
||||||
getKeys() {
|
getKeys() {
|
||||||
return helpers.sshKeyArrayFromDir(this._path);
|
return helpers.sshKeyArrayFromDir(this._path)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,60 +1,60 @@
|
|||||||
import "typings-global"
|
import 'typings-global'
|
||||||
import * as plugins from "./smartssh.plugins";
|
import * as plugins from './smartssh.plugins'
|
||||||
import * as helpers from "./smartssh.classes.helpers";
|
import * as helpers from './smartssh.classes.helpers'
|
||||||
|
|
||||||
import {SshDir} from "./smartssh.classes.sshdir";
|
import {SshDir} from './smartssh.classes.sshdir'
|
||||||
import {SshConfig} from "./smartssh.classes.sshconfig";
|
import {SshConfig} from './smartssh.classes.sshconfig'
|
||||||
import {SshKey} from "./smartssh.classes.sshkey";
|
import {SshKey} from './smartssh.classes.sshkey'
|
||||||
|
|
||||||
export class SshInstance {
|
export class SshInstance {
|
||||||
private _sshKeyArray:SshKey[]; //holds all ssh keys
|
private _sshKeyArray: SshKey[] // holds all ssh keys
|
||||||
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 _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: {sshDirPath?: string,sshSync?: boolean}= {}) {
|
constructor(optionsArg: {sshDirPath?: string,sshSync?: boolean}= {}) {
|
||||||
optionsArg ? void(0) : optionsArg = {};
|
optionsArg ? void(0) : optionsArg = {}
|
||||||
this._sshKeyArray = [];
|
this._sshKeyArray = []
|
||||||
this._sshConfig = new SshConfig(this._sshKeyArray);
|
this._sshConfig = new SshConfig(this._sshKeyArray)
|
||||||
this._sshDir = new SshDir(this._sshKeyArray,this._sshConfig,optionsArg.sshDirPath);
|
this._sshDir = new SshDir(this._sshKeyArray,this._sshConfig,optionsArg.sshDirPath)
|
||||||
this._sshSync = optionsArg.sshSync;
|
this._sshSync = optionsArg.sshSync
|
||||||
};
|
};
|
||||||
|
|
||||||
// altering methods
|
// altering methods
|
||||||
addKey(sshKeyArg: SshKey) {
|
addKey(sshKeyArg: SshKey) {
|
||||||
this._syncAuto("from");
|
this._syncAuto('from')
|
||||||
this._sshKeyArray.push(sshKeyArg);
|
this._sshKeyArray.push(sshKeyArg)
|
||||||
this._syncAuto("to");
|
this._syncAuto('to')
|
||||||
};
|
};
|
||||||
removeKey(sshKeyArg: SshKey) {
|
removeKey(sshKeyArg: SshKey) {
|
||||||
this._syncAuto("from");
|
this._syncAuto('from')
|
||||||
let filteredArray = this._sshKeyArray.filter((sshKeyArg2: SshKey) => {
|
let filteredArray = this._sshKeyArray.filter((sshKeyArg2: SshKey) => {
|
||||||
return (sshKeyArg != sshKeyArg2);
|
return (sshKeyArg != sshKeyArg2)
|
||||||
});
|
})
|
||||||
this._sshKeyArray = filteredArray;
|
this._sshKeyArray = filteredArray
|
||||||
this._syncAuto("to");
|
this._syncAuto('to')
|
||||||
};
|
};
|
||||||
replaceKey(sshKeyOldArg: SshKey,sshKeyNewArg: SshKey) {
|
replaceKey(sshKeyOldArg: SshKey,sshKeyNewArg: SshKey) {
|
||||||
this._syncAuto("from");
|
this._syncAuto('from')
|
||||||
this.removeKey(sshKeyOldArg);
|
this.removeKey(sshKeyOldArg)
|
||||||
this.addKey(sshKeyNewArg);
|
this.addKey(sshKeyNewArg)
|
||||||
this._syncAuto("to");
|
this._syncAuto('to')
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
getKey(hostArg: string): SshKey {
|
getKey(hostArg: string): SshKey {
|
||||||
this._syncAuto("from");
|
this._syncAuto('from')
|
||||||
let filteredArray = this._sshKeyArray.filter(function(keyArg){
|
let filteredArray = this._sshKeyArray.filter(function(keyArg){
|
||||||
return (keyArg.host == hostArg);
|
return (keyArg.host === hostArg)
|
||||||
});
|
})
|
||||||
if (filteredArray.length > 0) {
|
if (filteredArray.length > 0) {
|
||||||
return filteredArray[0];
|
return filteredArray[0]
|
||||||
} else {
|
} else {
|
||||||
return undefined;
|
return undefined
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
get sshKeys(): SshKey[] {
|
get sshKeys(): SshKey[] {
|
||||||
this._syncAuto("from");
|
this._syncAuto('from')
|
||||||
return this._sshKeyArray;
|
return this._sshKeyArray
|
||||||
};
|
};
|
||||||
|
|
||||||
// FS methods
|
// FS methods
|
||||||
@ -63,14 +63,14 @@ export class SshInstance {
|
|||||||
* write SshInstance to disk
|
* write SshInstance to disk
|
||||||
*/
|
*/
|
||||||
writeToDisk(dirPathArg?: string) {
|
writeToDisk(dirPathArg?: string) {
|
||||||
this._sync("to",dirPathArg);
|
this._sync('to',dirPathArg)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* read ab SshInstance from disk
|
* read ab SshInstance from disk
|
||||||
*/
|
*/
|
||||||
readFromDisk(dirPathArg?: string) {
|
readFromDisk(dirPathArg?: string) {
|
||||||
this._sync("from",dirPathArg);
|
this._sync('from',dirPathArg)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===============================================================
|
/* ===============================================================
|
||||||
@ -85,19 +85,19 @@ export class SshInstance {
|
|||||||
* method to invoke SshInstance _sync automatically when sshSync is true
|
* method to invoke SshInstance _sync automatically when sshSync is true
|
||||||
*/
|
*/
|
||||||
private _syncAuto(directionArg) {
|
private _syncAuto(directionArg) {
|
||||||
if(this._sshSync) this._sync(directionArg);
|
if (this._sshSync) this._sync(directionArg)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* private method to sync SshInstance
|
* private method to sync SshInstance
|
||||||
*/
|
*/
|
||||||
private _sync(directionArg: string,dirPathArg?: string) {
|
private _sync(directionArg: string,dirPathArg?: string) {
|
||||||
if(directionArg == "from"){
|
if (directionArg === 'from') {
|
||||||
this._sshDir.readFromDir(dirPathArg); // call sync method of sshDir class;
|
this._sshDir.readFromDir(dirPathArg) // call sync method of sshDir class;
|
||||||
} else if(directionArg == "to") {
|
} else if (directionArg === 'to') {
|
||||||
this._sshDir.writeToDir(dirPathArg);
|
this._sshDir.writeToDir(dirPathArg)
|
||||||
} else {
|
} else {
|
||||||
throw new Error("directionArg not recognised. Must be 'to' or 'from'");
|
throw new Error("directionArg not recognised. Must be 'to' or 'from'")
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,96 +1,99 @@
|
|||||||
import "typings-global";
|
import 'typings-global'
|
||||||
import * as plugins from "./smartssh.plugins";
|
import * as plugins from './smartssh.plugins'
|
||||||
import * as helpers from "./smartssh.classes.helpers";
|
import * as helpers from './smartssh.classes.helpers'
|
||||||
|
|
||||||
export class SshKey {
|
export class SshKey {
|
||||||
private _privKey:string;
|
private _privKey: string
|
||||||
private _pubKey:string;
|
private _pubKey: string
|
||||||
private _hostVar:string;
|
private _hostVar: string
|
||||||
private _authorized:boolean;
|
private _authorized: boolean
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the constructor for class SshKey
|
||||||
|
*/
|
||||||
constructor(optionsArg: {private?: string,public?: string,host?: string,authorized?: boolean}= {}) {
|
constructor(optionsArg: {private?: string,public?: string,host?: string,authorized?: boolean}= {}) {
|
||||||
this._privKey = optionsArg.private;
|
this._privKey = optionsArg.private
|
||||||
this._pubKey = optionsArg.public;
|
this._pubKey = optionsArg.public
|
||||||
this._hostVar = optionsArg.host;
|
this._hostVar = optionsArg.host
|
||||||
this._authorized = optionsArg.authorized;
|
this._authorized = optionsArg.authorized
|
||||||
};
|
};
|
||||||
|
|
||||||
// this.host
|
// this.host
|
||||||
get host(){
|
get host(){
|
||||||
return this._hostVar;
|
return this._hostVar
|
||||||
};
|
};
|
||||||
set host(hostArg: string){
|
set host(hostArg: string){
|
||||||
this._hostVar = hostArg;
|
this._hostVar = hostArg
|
||||||
};
|
};
|
||||||
|
|
||||||
// this.privKey
|
// this.privKey
|
||||||
get privKey(){
|
get privKey(){
|
||||||
return this._privKey;
|
return this._privKey
|
||||||
};
|
};
|
||||||
set privKey(privateKeyArg: string){
|
set privKey(privateKeyArg: string){
|
||||||
this._privKey = privateKeyArg;
|
this._privKey = privateKeyArg
|
||||||
};
|
};
|
||||||
|
|
||||||
// this.privKeyBase64
|
// this.privKeyBase64
|
||||||
get privKeyBase64(){
|
get privKeyBase64(){
|
||||||
return plugins.base64.encode(this._privKey);
|
return plugins.smartstring.base64.encode(this._privKey)
|
||||||
}
|
}
|
||||||
set privKeyBase64(privateKeyArg: string) {
|
set privKeyBase64(privateKeyArg: string) {
|
||||||
this._privKey = plugins.base64.decode(privateKeyArg);
|
this._privKey = plugins.smartstring.base64.decode(privateKeyArg)
|
||||||
}
|
}
|
||||||
|
|
||||||
// this.pubKey
|
// this.pubKey
|
||||||
get pubKey(){
|
get pubKey(){
|
||||||
return this._pubKey;
|
return this._pubKey
|
||||||
}
|
}
|
||||||
set pubKey(publicKeyArg: string){
|
set pubKey(publicKeyArg: string){
|
||||||
this._pubKey = publicKeyArg;
|
this._pubKey = publicKeyArg
|
||||||
};
|
};
|
||||||
|
|
||||||
// this.pubKeyBase64
|
// this.pubKeyBase64
|
||||||
get pubKeyBase64(){
|
get pubKeyBase64(){
|
||||||
return plugins.base64.encode(this._pubKey);
|
return plugins.smartstring.base64.encode(this._pubKey)
|
||||||
}
|
}
|
||||||
set pubKeyBase64(publicKeyArg: string) {
|
set pubKeyBase64(publicKeyArg: string) {
|
||||||
this._pubKey = plugins.base64.decode(publicKeyArg);
|
this._pubKey = plugins.smartstring.base64.decode(publicKeyArg)
|
||||||
}
|
}
|
||||||
|
|
||||||
get authorized(){
|
get authorized(){
|
||||||
return this._authorized;
|
return this._authorized
|
||||||
}
|
}
|
||||||
set authorized(authorizedArg: boolean){
|
set authorized(authorizedArg: boolean){
|
||||||
this._authorized = authorizedArg;
|
this._authorized = authorizedArg
|
||||||
}
|
}
|
||||||
get type(){
|
get type(){
|
||||||
if (this._privKey && this._pubKey) {
|
if (this._privKey && this._pubKey) {
|
||||||
return "duplex";
|
return 'duplex'
|
||||||
} else if (this._privKey) {
|
} else if (this._privKey) {
|
||||||
return "private";
|
return 'private'
|
||||||
} else if (this._pubKey) {
|
} else if (this._pubKey) {
|
||||||
return "public";
|
return 'public'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
set type(someVlueArg: any){
|
set type(someVlueArg: any){
|
||||||
console.log("the type of an SshKey connot be set. This value is autpcomputed.")
|
console.log('the type of an SshKey connot be set. This value is autpcomputed.')
|
||||||
}
|
}
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
read(filePathArg) {
|
read(filePathArg) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
store(dirPathArg: string) {
|
store(dirPathArg: string) {
|
||||||
plugins.fs.ensureDirSync(dirPathArg);
|
plugins.fs.ensureDirSync(dirPathArg)
|
||||||
let fileNameBase = this.host;
|
let fileNameBase = this.host
|
||||||
if (this._privKey) {
|
if (this._privKey) {
|
||||||
let filePath = plugins.path.join(dirPathArg,fileNameBase);
|
let filePath = plugins.path.join(dirPathArg,fileNameBase)
|
||||||
plugins.smartfile.memory.toFsSync(this._privKey,filePath);
|
plugins.smartfile.memory.toFsSync(this._privKey,filePath)
|
||||||
plugins.shelljs.chmod(600,filePath);
|
plugins.shelljs.chmod(600,filePath)
|
||||||
};
|
};
|
||||||
if (this._pubKey) {
|
if (this._pubKey) {
|
||||||
let filePath = plugins.path.join(dirPathArg,fileNameBase + ".pub");
|
let filePath = plugins.path.join(dirPathArg,fileNameBase + '.pub')
|
||||||
plugins.smartfile.memory.toFsSync(this._pubKey,filePath);
|
plugins.smartfile.memory.toFsSync(this._pubKey,filePath)
|
||||||
plugins.shelljs.chmod(600,filePath);
|
plugins.shelljs.chmod(600,filePath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let testKey = new SshKey();
|
|
@ -1,10 +1,22 @@
|
|||||||
import "typings-global"
|
import 'typings-global'
|
||||||
export import beautylog = require("beautylog");
|
import * as beautylog from 'beautylog'
|
||||||
export let base64 = require("js-base64").Base64;
|
import * as fs from 'fs-extra'
|
||||||
export let fs = require("fs-extra");
|
import * as minimatch from 'minimatch'
|
||||||
export let minimatch = require("minimatch");
|
import * as path from 'path'
|
||||||
export import path = require("path");
|
import * as q from 'q'
|
||||||
export let q = require("q");
|
import * as shelljs from 'shelljs'
|
||||||
export let shelljs = require("shelljs");
|
import * as smartfile from 'smartfile'
|
||||||
export import smartfile = require("smartfile");
|
import * as smartpath from 'smartpath'
|
||||||
export import smartpath = require("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"
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user