Compare commits
52 Commits
Author | SHA1 | Date | |
---|---|---|---|
32c2698af7 | |||
27237f14c7 | |||
8f29f234f1 | |||
5091625953 | |||
f74b3a51b0 | |||
062f3ad060 | |||
ecd0fd8fad | |||
742bf694e4 | |||
38165f11db | |||
ef2b31b4b2 | |||
5b1f800067 | |||
6339a3ed9b | |||
bf27aaf167 | |||
9bc3aea59c | |||
f5ff302d4d | |||
cac8203bf5 | |||
e4532271cc | |||
faf6c91199 | |||
d0009e7a9c | |||
da76df2c3e | |||
a43976110a | |||
c3ee35a699 | |||
a0ce759552 | |||
201d5cc6d7 | |||
e5bdfff743 | |||
967c9fd9d1 | |||
35da2f0b73 | |||
5e991a4e4f | |||
0f75f5238c | |||
e8f3047ac0 | |||
812d28ee3d | |||
fa301eea71 | |||
48ccf317d6 | |||
9b3af8a50a | |||
78aa36c2be | |||
09d96fd94c | |||
f4f60a685d | |||
904129706c | |||
9a96bbd266 | |||
39abfd760b | |||
1b30aa428e | |||
41613c0b93 | |||
2d14617b13 | |||
3106945b47 | |||
2284620387 | |||
cd6bcb974c | |||
eb66ed0244 | |||
d12c7ab621 | |||
84374299cf | |||
b73928109b | |||
1d17dd1b84 | |||
1663d9a266 |
8
.gitignore
vendored
8
.gitignore
vendored
@ -1,7 +1,5 @@
|
||||
.idea/
|
||||
node_modules/
|
||||
coverage/
|
||||
docs/
|
||||
ts/typings/
|
||||
ts/*.js
|
||||
ts/*.js.map
|
||||
pages/
|
||||
public/
|
||||
test/temp/
|
||||
|
59
.gitlab-ci.yml
Normal file
59
.gitlab-ci.yml
Normal file
@ -0,0 +1,59 @@
|
||||
image: hosttoday/ht-docker-node:npmts
|
||||
|
||||
stages:
|
||||
- test
|
||||
- release
|
||||
- trigger
|
||||
- pages
|
||||
|
||||
testLEGACY:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test legacy
|
||||
tags:
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
testLTS:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test lts
|
||||
tags:
|
||||
- docker
|
||||
|
||||
testSTABLE:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test stable
|
||||
tags:
|
||||
- docker
|
||||
|
||||
release:
|
||||
stage: release
|
||||
script:
|
||||
- npmci publish
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
|
||||
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
|
5
Dockerfile
Normal file
5
Dockerfile
Normal file
@ -0,0 +1,5 @@
|
||||
FROM hosttoday/ht-docker-node:npmts
|
||||
COPY ./ /node-app
|
||||
WORKDIR /node-app
|
||||
RUN npm install
|
||||
RUN npmts
|
13
README.md
13
README.md
@ -2,7 +2,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.
|
||||
I (Phil from Lossless) expect this to be ready 2016/05/01.
|
||||
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
@ -16,18 +17,20 @@ var sshInstance = new smartssh.sshInstance({
|
||||
sshInstance.addKey(new smartssh.sshKey({
|
||||
private: "somestring",
|
||||
public: "somestring", // optional
|
||||
for:"github.com",
|
||||
host:"github.com",
|
||||
encoding: "base64" // optional, defaults to "utf8", can be "utf8" or "base64", useful for reading ssh keys from environment variables
|
||||
}));
|
||||
|
||||
sshInstance.removeKey(sshInstance.getKey("github.com")); // removes key for host "github.com" is present
|
||||
|
||||
sshInstance.createKey({
|
||||
for:"gitlab.com" // returns new key in the form sshKey, read more about the sshKey class below
|
||||
host:"gitlab.com" // returns new key in the form sshKey, read more about the sshKey class below
|
||||
})
|
||||
|
||||
sshInstance.getKey({ // returns ssh key in the form sshKey, read more about the sshKey class below
|
||||
for:"github.com"
|
||||
host:"github.com"
|
||||
});
|
||||
|
||||
sshInstance.getKeys() // returns array of all available getKeys. Each key is in form of class sshKey
|
||||
|
||||
```
|
||||
```
|
||||
|
5
dist/index.d.ts
vendored
Normal file
5
dist/index.d.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
import 'typings-global';
|
||||
export { SshInstance } from './smartssh.classes.sshinstance';
|
||||
export { SshKey } from './smartssh.classes.sshkey';
|
||||
export { SshDir } from './smartssh.classes.sshdir';
|
||||
export { SshConfig } from './smartssh.classes.sshconfig';
|
12
dist/index.js
vendored
12
dist/index.js
vendored
@ -1,3 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsImZpbGUiOiJpbmRleC5qcyIsInNvdXJjZXNDb250ZW50IjpbXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=
|
||||
require("typings-global");
|
||||
var smartssh_classes_sshinstance_1 = require("./smartssh.classes.sshinstance");
|
||||
exports.SshInstance = smartssh_classes_sshinstance_1.SshInstance;
|
||||
var smartssh_classes_sshkey_1 = require("./smartssh.classes.sshkey");
|
||||
exports.SshKey = smartssh_classes_sshkey_1.SshKey;
|
||||
var smartssh_classes_sshdir_1 = require("./smartssh.classes.sshdir");
|
||||
exports.SshDir = smartssh_classes_sshdir_1.SshDir;
|
||||
var smartssh_classes_sshconfig_1 = require("./smartssh.classes.sshconfig");
|
||||
exports.SshConfig = smartssh_classes_sshconfig_1.SshConfig;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMEJBQXVCO0FBR3ZCLCtFQUEwRDtBQUFsRCxxREFBQSxXQUFXLENBQUE7QUFDbkIscUVBQWdEO0FBQXhDLDJDQUFBLE1BQU0sQ0FBQTtBQUNkLHFFQUFnRDtBQUF4QywyQ0FBQSxNQUFNLENBQUE7QUFDZCwyRUFBc0Q7QUFBOUMsaURBQUEsU0FBUyxDQUFBIn0=
|
3
dist/smartssh.classes.helpers.d.ts
vendored
Normal file
3
dist/smartssh.classes.helpers.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import 'typings-global';
|
||||
import { SshKey } from './smartssh.classes.sshkey';
|
||||
export declare let sshKeyArrayFromDir: (dirArg: string) => SshKey[];
|
6
dist/smartssh.classes.helpers.js
vendored
6
dist/smartssh.classes.helpers.js
vendored
@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
require("typings-global");
|
||||
exports.sshKeyArrayFromDir = function (dirArg) {
|
||||
var sshKeyArray = [];
|
||||
let sshKeyArray = []; // TODO
|
||||
return sshKeyArray;
|
||||
};
|
||||
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3NoLmNsYXNzZXMuaGVscGVycy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBSVcsMEJBQWtCLEdBQUcsVUFBUyxNQUFhO0lBQ2xELElBQUksV0FBVyxHQUFHLEVBQUUsQ0FBQztJQUNyQixNQUFNLENBQUMsV0FBVyxDQUFDO0FBQ3ZCLENBQUMsQ0FBQSIsImZpbGUiOiJzbWFydHNzaC5jbGFzc2VzLmhlbHBlcnMuanMiLCJzb3VyY2VzQ29udGVudCI6WyIvLy8gPHJlZmVyZW5jZSBwYXRoPVwiLi90eXBpbmdzL21haW4uZC50c1wiIC8+XG5pbXBvcnQgcGx1Z2lucyA9IHJlcXVpcmUoXCIuL3NtYXJ0c3NoLnBsdWdpbnNcIik7XG5pbXBvcnQgY2xhc3NlcyA9IHJlcXVpcmUoXCIuL3NtYXJ0c3NoLmNsYXNzZXNcIik7XG5cbmV4cG9ydCBsZXQgc3NoS2V5QXJyYXlGcm9tRGlyID0gZnVuY3Rpb24oZGlyQXJnOnN0cmluZyk6Y2xhc3Nlcy5zc2hLZXlbXXtcbiAgICBsZXQgc3NoS2V5QXJyYXkgPSBbXTtcbiAgICByZXR1cm4gc3NoS2V5QXJyYXk7XG59Il0sInNvdXJjZVJvb3QiOiIvc291cmNlLyJ9
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzc2guY2xhc3Nlcy5oZWxwZXJzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzc2guY2xhc3Nlcy5oZWxwZXJzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSwwQkFBdUI7QUFJWixRQUFBLGtCQUFrQixHQUFHLFVBQVMsTUFBYztJQUNuRCxJQUFJLFdBQVcsR0FBRyxFQUFFLENBQUEsQ0FBQyxPQUFPO0lBQzVCLE1BQU0sQ0FBQyxXQUFXLENBQUE7QUFDdEIsQ0FBQyxDQUFBIn0=
|
106
dist/smartssh.classes.js
vendored
106
dist/smartssh.classes.js
vendored
File diff suppressed because one or more lines are too long
17
dist/smartssh.classes.sshconfig.d.ts
vendored
Normal file
17
dist/smartssh.classes.sshconfig.d.ts
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
/// <reference types="q" />
|
||||
import 'typings-global';
|
||||
import { SshKey } from './smartssh.classes.sshkey';
|
||||
export declare class SshConfig {
|
||||
private _sshKeyArray;
|
||||
constructor(sshKeyArrayArg: SshKey[]);
|
||||
/**
|
||||
* stores a config file
|
||||
*/
|
||||
store(dirPathArg: string): Q.Promise<{}>;
|
||||
read(dirPathArg: any): Q.Promise<{}>;
|
||||
}
|
||||
export interface configObject {
|
||||
configString: string;
|
||||
authorized: boolean;
|
||||
sshKey: SshKey;
|
||||
}
|
47
dist/smartssh.classes.sshconfig.js
vendored
Normal file
47
dist/smartssh.classes.sshconfig.js
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
"use strict";
|
||||
require("typings-global");
|
||||
const plugins = require("./smartssh.plugins");
|
||||
class SshConfig {
|
||||
constructor(sshKeyArrayArg) {
|
||||
this._sshKeyArray = sshKeyArrayArg;
|
||||
}
|
||||
/**
|
||||
* stores a config file
|
||||
*/
|
||||
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' +
|
||||
' StrictHostKeyChecking no' + '\n';
|
||||
}
|
||||
configArray.push({
|
||||
configString: configString,
|
||||
authorized: sshKey.authorized,
|
||||
sshKey: sshKey
|
||||
});
|
||||
}
|
||||
let configFile = '';
|
||||
for (let key in configArray) {
|
||||
configFile = configFile + configArray[key].configString + '\n';
|
||||
}
|
||||
;
|
||||
plugins.smartfile.memory.toFsSync(configFile, plugins.path.join(dirPathArg, 'config'));
|
||||
return done.promise;
|
||||
}
|
||||
read(dirPathArg) {
|
||||
let done = plugins.q.defer();
|
||||
let configArray;
|
||||
plugins.smartfile.fs.toStringSync(plugins.path.join(dirPathArg, 'config'));
|
||||
return done.promise;
|
||||
}
|
||||
}
|
||||
exports.SshConfig = SshConfig;
|
||||
;
|
||||
;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzc2guY2xhc3Nlcy5zc2hjb25maWcuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHNzaC5jbGFzc2VzLnNzaGNvbmZpZy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsME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LENBQUM7WUFDMUIsVUFBVSxHQUFHLFVBQVUsR0FBRyxXQUFXLENBQUMsR0FBRyxDQUFDLENBQUMsWUFBWSxHQUFHLElBQUksQ0FBQTtRQUNsRSxDQUFDO1FBQUEsQ0FBQztRQUNGLE9BQU8sQ0FBQyxTQUFTLENBQUMsTUFBTSxDQUFDLFFBQVEsQ0FBQyxVQUFVLEVBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsVUFBVSxFQUFDLFFBQVEsQ0FBQyxDQUFDLENBQUE7UUFDcEYsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUE7SUFDdkIsQ0FBQztJQUNELElBQUksQ0FBQyxVQUFVO1FBQ1gsSUFBSSxJQUFJLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQyxLQUFLLEVBQUUsQ0FBQTtRQUM1QixJQUFJLFdBQTJCLENBQUE7UUFDL0IsT0FBTyxDQUFDLFNBQVMsQ0FBQyxFQUFFLENBQUMsWUFBWSxDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLFVBQVUsRUFBQyxRQUFRLENBQUMsQ0FBQyxDQUFBO1FBRXpFLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFBO0lBQ3ZCLENBQUM7Q0FDSjtBQXpDRCw4QkF5Q0M7QUFBQSxDQUFDO0FBTUQsQ0FBQyJ9
|
13
dist/smartssh.classes.sshdir.d.ts
vendored
Normal file
13
dist/smartssh.classes.sshdir.d.ts
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
import 'typings-global';
|
||||
import { SshKey } from './smartssh.classes.sshkey';
|
||||
import { SshConfig } from './smartssh.classes.sshconfig';
|
||||
export declare class SshDir {
|
||||
private _path;
|
||||
private _sshKeyArray;
|
||||
private _sshConfig;
|
||||
constructor(sshKeyArray: SshKey[], sshConfig: SshConfig, sshDirPathArg?: string);
|
||||
writeToDir(dirPathArg?: string): void;
|
||||
readFromDir(dirPathArg?: string): void;
|
||||
updateDirPath(dirPathArg: string): void;
|
||||
getKeys(): SshKey[];
|
||||
}
|
41
dist/smartssh.classes.sshdir.js
vendored
Normal file
41
dist/smartssh.classes.sshdir.js
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
"use strict";
|
||||
require("typings-global");
|
||||
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;
|
||||
}
|
||||
else {
|
||||
this._path = plugins.path.join(plugins.smartpath.get.home(), '.ssh/');
|
||||
}
|
||||
;
|
||||
}
|
||||
writeToDir(dirPathArg) {
|
||||
let path = this._path;
|
||||
if (dirPathArg)
|
||||
path = dirPathArg;
|
||||
this._sshKeyArray.forEach((sshKeyArg) => {
|
||||
sshKeyArg.store(path);
|
||||
});
|
||||
this._sshConfig.store(path);
|
||||
}
|
||||
;
|
||||
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;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzc2guY2xhc3Nlcy5zc2hkaXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHNzaC5jbGFzc2VzLnNzaGRpci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMEJBQXVCO0FBQ3ZCLDhDQUE2QztBQUM3QyxzREFBcUQ7QUFJckQ7SUFJSSxZQUFZLFdBQ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BYSxDQUFDLFVBQWtCO1FBQzVCLElBQUksQ0FBQyxLQUFLLEdBQUcsVUFBVSxDQUFBO0lBQzNCLENBQUM7SUFBQSxDQUFDO0lBQ0YsT0FBTztRQUNILE1BQU0sQ0FBQyxPQUFPLENBQUMsa0JBQWtCLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxDQUFBO0lBQ2pELENBQUM7Q0FDSjtBQS9CRCx3QkErQkMifQ==
|
34
dist/smartssh.classes.sshinstance.d.ts
vendored
Normal file
34
dist/smartssh.classes.sshinstance.d.ts
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
import 'typings-global';
|
||||
import { SshKey } from './smartssh.classes.sshkey';
|
||||
export declare class SshInstance {
|
||||
private _sshKeyArray;
|
||||
private _sshConfig;
|
||||
private _sshDir;
|
||||
private _sshSync;
|
||||
constructor(optionsArg?: {
|
||||
sshDirPath?: string;
|
||||
sshSync?: boolean;
|
||||
});
|
||||
addKey(sshKeyArg: SshKey): void;
|
||||
removeKey(sshKeyArg: SshKey): void;
|
||||
replaceKey(sshKeyOldArg: SshKey, sshKeyNewArg: SshKey): void;
|
||||
getKey(hostArg: string): SshKey;
|
||||
readonly sshKeys: SshKey[];
|
||||
/**
|
||||
* write SshInstance to disk
|
||||
*/
|
||||
writeToDisk(dirPathArg?: string): void;
|
||||
/**
|
||||
* read ab SshInstance from disk
|
||||
*/
|
||||
readFromDisk(dirPathArg?: string): void;
|
||||
private _makeConfig();
|
||||
/**
|
||||
* method to invoke SshInstance _sync automatically when sshSync is true
|
||||
*/
|
||||
private _syncAuto(directionArg);
|
||||
/**
|
||||
* private method to sync SshInstance
|
||||
*/
|
||||
private _sync(directionArg, dirPathArg?);
|
||||
}
|
98
dist/smartssh.classes.sshinstance.js
vendored
Normal file
98
dist/smartssh.classes.sshinstance.js
vendored
Normal file
@ -0,0 +1,98 @@
|
||||
"use strict";
|
||||
require("typings-global");
|
||||
const smartssh_classes_sshdir_1 = require("./smartssh.classes.sshdir");
|
||||
const smartssh_classes_sshconfig_1 = require("./smartssh.classes.sshconfig");
|
||||
class SshInstance {
|
||||
constructor(optionsArg = {}) {
|
||||
optionsArg ? void (0) : optionsArg = {};
|
||||
this._sshKeyArray = [];
|
||||
this._sshConfig = new smartssh_classes_sshconfig_1.SshConfig(this._sshKeyArray);
|
||||
this._sshDir = new smartssh_classes_sshdir_1.SshDir(this._sshKeyArray, this._sshConfig, optionsArg.sshDirPath);
|
||||
this._sshSync = optionsArg.sshSync;
|
||||
}
|
||||
;
|
||||
// altering methods
|
||||
addKey(sshKeyArg) {
|
||||
this._syncAuto('from');
|
||||
this._sshKeyArray.push(sshKeyArg);
|
||||
this._syncAuto('to');
|
||||
}
|
||||
;
|
||||
removeKey(sshKeyArg) {
|
||||
this._syncAuto('from');
|
||||
let filteredArray = this._sshKeyArray.filter((sshKeyArg2) => {
|
||||
return (sshKeyArg != sshKeyArg2);
|
||||
});
|
||||
this._sshKeyArray = filteredArray;
|
||||
this._syncAuto('to');
|
||||
}
|
||||
;
|
||||
replaceKey(sshKeyOldArg, sshKeyNewArg) {
|
||||
this._syncAuto('from');
|
||||
this.removeKey(sshKeyOldArg);
|
||||
this.addKey(sshKeyNewArg);
|
||||
this._syncAuto('to');
|
||||
}
|
||||
;
|
||||
//
|
||||
getKey(hostArg) {
|
||||
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() {
|
||||
this._syncAuto('from');
|
||||
return this._sshKeyArray;
|
||||
}
|
||||
;
|
||||
// FS methods
|
||||
/**
|
||||
* write SshInstance to disk
|
||||
*/
|
||||
writeToDisk(dirPathArg) {
|
||||
this._sync('to', dirPathArg);
|
||||
}
|
||||
/**
|
||||
* read ab SshInstance from disk
|
||||
*/
|
||||
readFromDisk(dirPathArg) {
|
||||
this._sync('from', dirPathArg);
|
||||
}
|
||||
/* ===============================================================
|
||||
========================= Private Methods ========================
|
||||
================================================================*/
|
||||
_makeConfig() {
|
||||
}
|
||||
/**
|
||||
* method to invoke SshInstance _sync automatically when sshSync is true
|
||||
*/
|
||||
_syncAuto(directionArg) {
|
||||
if (this._sshSync)
|
||||
this._sync(directionArg);
|
||||
}
|
||||
/**
|
||||
* private method to sync SshInstance
|
||||
*/
|
||||
_sync(directionArg, dirPathArg) {
|
||||
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'");
|
||||
}
|
||||
}
|
||||
;
|
||||
}
|
||||
exports.SshInstance = SshInstance;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzc2guY2xhc3Nlcy5zc2hpbnN0YW5jZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0c3NoLmNsYXNzZXMuc3NoaW5zdGFuY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDBCQUF1QjtBQUl2Qix1RUFBZ0Q7QUFDaEQsNkVBQXNEO0FBR3REO0lBS0ksWUFBWSxhQUFxRCxFQUFFO1FBQy9ELFVBQVUsR0FBRyxLQUFJLENBQUMsQ0FBQyxDQUFDLEdBQUcsVUFBVSxHQUFHLEVBQUUsQ0FBQTtRQUN0QyxJQUFJLENBQUMsWUFBWSxHQUFHLEVBQUUsQ0FBQTtRQUN0QixJQUFJLENBQUMsVUFBVSxHQUFHLElBQUksc0NBQVMsQ0FBQyxJQUFJLENBQUMsWUFBWSxDQUFDLENBQUE7UUFDbEQsSUFBSSxDQUFDLE9BQU8sR0FBRyxJQUF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BVztJQUVuQixDQUFDO0lBRUQ7O09BRUc7SUFDSyxTQUFTLENBQUMsWUFBWTtRQUMxQixFQUFFLENBQUMsQ0FBQyxJQUFJLENBQUMsUUFBUSxDQUFDO1lBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxZQUFZLENBQUMsQ0FBQTtJQUMvQyxDQUFDO0lBRUQ7O09BRUc7SUFDSyxLQUFLLENBQUMsWUFBb0IsRUFBQyxVQUFtQjtRQUNsRCxFQUFFLENBQUMsQ0FBQyxZQUFZLEtBQUssTUFBTSxDQUFDLENBQUMsQ0FBQztZQUMxQixJQUFJLENBQUMsT0FBTyxDQUFDLFdBQVcsQ0FBQyxVQUFVLENBQUMsQ0FBQSxDQUFDLG9DQUFvQztRQUM3RSxDQUFDO1FBQUMsSUFBSSxDQUFDLEVBQUUsQ0FBQyxDQUFDLFlBQVksS0FBSyxJQUFJLENBQUMsQ0FBQyxDQUFDO1lBQy9CLElBQUksQ0FBQyxPQUFPLENBQUMsVUFBVSxDQUFDLFVBQVUsQ0FBQyxDQUFBO1FBQ3ZDLENBQUM7UUFBQyxJQUFJLENBQUMsQ0FBQztZQUNKLE1BQU0sSUFBSSxLQUFLLENBQUMscURBQXFELENBQUMsQ0FBQTtRQUMxRSxDQUFDO0lBQ0wsQ0FBQztJQUFBLENBQUM7Q0FDTDtBQTlGRCxrQ0E4RkMifQ==
|
25
dist/smartssh.classes.sshkey.d.ts
vendored
Normal file
25
dist/smartssh.classes.sshkey.d.ts
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
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;
|
||||
host?: string;
|
||||
authorized?: boolean;
|
||||
});
|
||||
host: string;
|
||||
privKey: string;
|
||||
privKeyBase64: string;
|
||||
pubKey: string;
|
||||
pubKeyBase64: string;
|
||||
authorized: boolean;
|
||||
type: any;
|
||||
read(filePathArg: any): void;
|
||||
store(dirPathArg: string): void;
|
||||
}
|
96
dist/smartssh.classes.sshkey.js
vendored
Normal file
96
dist/smartssh.classes.sshkey.js
vendored
Normal file
@ -0,0 +1,96 @@
|
||||
"use strict";
|
||||
require("typings-global");
|
||||
const plugins = require("./smartssh.plugins");
|
||||
class SshKey {
|
||||
/**
|
||||
* the constructor for class SshKey
|
||||
*/
|
||||
constructor(optionsArg = {}) {
|
||||
this._privKey = optionsArg.private;
|
||||
this._pubKey = optionsArg.public;
|
||||
this._hostVar = optionsArg.host;
|
||||
this._authorized = optionsArg.authorized;
|
||||
}
|
||||
;
|
||||
// this.host
|
||||
get host() {
|
||||
return this._hostVar;
|
||||
}
|
||||
;
|
||||
set host(hostArg) {
|
||||
this._hostVar = hostArg;
|
||||
}
|
||||
;
|
||||
// this.privKey
|
||||
get privKey() {
|
||||
return this._privKey;
|
||||
}
|
||||
;
|
||||
set privKey(privateKeyArg) {
|
||||
this._privKey = privateKeyArg;
|
||||
}
|
||||
;
|
||||
// this.privKeyBase64
|
||||
get privKeyBase64() {
|
||||
return plugins.smartstring.base64.encode(this._privKey);
|
||||
}
|
||||
set privKeyBase64(privateKeyArg) {
|
||||
this._privKey = plugins.smartstring.base64.decode(privateKeyArg);
|
||||
}
|
||||
// this.pubKey
|
||||
get pubKey() {
|
||||
return this._pubKey;
|
||||
}
|
||||
set pubKey(publicKeyArg) {
|
||||
this._pubKey = publicKeyArg;
|
||||
}
|
||||
;
|
||||
// this.pubKeyBase64
|
||||
get pubKeyBase64() {
|
||||
return plugins.smartstring.base64.encode(this._pubKey);
|
||||
}
|
||||
set pubKeyBase64(publicKeyArg) {
|
||||
this._pubKey = plugins.smartstring.base64.decode(publicKeyArg);
|
||||
}
|
||||
get authorized() {
|
||||
return this._authorized;
|
||||
}
|
||||
set authorized(authorizedArg) {
|
||||
this._authorized = authorizedArg;
|
||||
}
|
||||
get type() {
|
||||
if (this._privKey && this._pubKey) {
|
||||
return 'duplex';
|
||||
}
|
||||
else if (this._privKey) {
|
||||
return 'private';
|
||||
}
|
||||
else if (this._pubKey) {
|
||||
return 'public';
|
||||
}
|
||||
}
|
||||
;
|
||||
set type(someVlueArg) {
|
||||
console.log('the type of an SshKey connot be set. This value is autpcomputed.');
|
||||
}
|
||||
// methods
|
||||
read(filePathArg) {
|
||||
}
|
||||
store(dirPathArg) {
|
||||
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) {
|
||||
let filePath = plugins.path.join(dirPathArg, fileNameBase + '.pub');
|
||||
plugins.smartfile.memory.toFsSync(this._pubKey, filePath);
|
||||
plugins.shelljs.chmod(600, filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.SshKey = SshKey;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzc2guY2xhc3Nlcy5zc2hrZXkuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHNzaC5jbGFzc2VzLnNzaGtleS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMEJBQXVCO0FBQ3ZCLDhDQUE2QztBQUc3QztJQU1JOztPQUVHO0lBQ0gsWUFBWSxhQUFtRixFQUFFO1FBQzdGLElBQUksQ0FBQyxRQUFRLEdBQUcsVUFBVSxDQUFDLE9BQU8sQ0FBQTtRQUNsQyxJQUFJLENBQUMsT0FBTyxHQUFHLFVBQVUsQ0FBQyxNQUFNLENBQUE7UUFDaEMsSUFBSSxDQUFDLFFBQVEsR0FBRyxVQUFVLENBQUMsSUFBSSxDQUFBO1FBQy9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
Normal file
11
dist/smartssh.plugins.d.ts
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
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 };
|
28
dist/smartssh.plugins.js
vendored
28
dist/smartssh.plugins.js
vendored
@ -1,9 +1,21 @@
|
||||
"use strict";
|
||||
/// <reference path="./typings/main.d.ts" />
|
||||
exports.beautylog = require("beautylog");
|
||||
exports.base64 = require("js-base64").Base64;
|
||||
exports.fs = require("fs-extra");
|
||||
exports.path = require("path");
|
||||
exports.smartfile = require("smartfile");
|
||||
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3NoLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDRDQUE0QztBQUNqQyxpQkFBUyxHQUFHLE9BQU8sQ0FBQyxXQUFXLENBQUMsQ0FBQztBQUNqQyxjQUFNLEdBQUcsT0FBTyxDQUFDLFdBQVcsQ0FBQyxDQUFDLE1BQU0sQ0FBQztBQUNyQyxVQUFFLEdBQUcsT0FBTyxDQUFDLFVBQVUsQ0FBQyxDQUFDO0FBQ3pCLFlBQUksR0FBRyxPQUFPLENBQUMsTUFBTSxDQUFDLENBQUM7QUFDdkIsaUJBQVMsR0FBRyxPQUFPLENBQUMsV0FBVyxDQUFDLENBQUMiLCJmaWxlIjoic21hcnRzc2gucGx1Z2lucy5qcyIsInNvdXJjZXNDb250ZW50IjpbIi8vLyA8cmVmZXJlbmNlIHBhdGg9XCIuL3R5cGluZ3MvbWFpbi5kLnRzXCIgLz5cbmV4cG9ydCBsZXQgYmVhdXR5bG9nID0gcmVxdWlyZShcImJlYXV0eWxvZ1wiKTtcbmV4cG9ydCBsZXQgYmFzZTY0ID0gcmVxdWlyZShcImpzLWJhc2U2NFwiKS5CYXNlNjQ7XG5leHBvcnQgbGV0IGZzID0gcmVxdWlyZShcImZzLWV4dHJhXCIpO1xuZXhwb3J0IGxldCBwYXRoID0gcmVxdWlyZShcInBhdGhcIik7XG5leHBvcnQgbGV0IHNtYXJ0ZmlsZSA9IHJlcXVpcmUoXCJzbWFydGZpbGVcIik7Il0sInNvdXJjZVJvb3QiOiIvc291cmNlLyJ9
|
||||
require("typings-global");
|
||||
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
|
4
npmts.json
Normal file
4
npmts.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"mode":"default",
|
||||
"coverageTreshold":50
|
||||
}
|
33
package.json
33
package.json
@ -1,14 +1,15 @@
|
||||
{
|
||||
"name": "smartssh",
|
||||
"version": "1.0.1",
|
||||
"version": "1.2.0",
|
||||
"description": "setups SSH quickly and in a painless manner",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"scripts": {
|
||||
"test": "(npmts)"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/pushrocks/smartssh.git"
|
||||
"url": "git+https://gitlab.com/pushrocks/smartssh.git"
|
||||
},
|
||||
"keywords": [
|
||||
"SSH",
|
||||
@ -18,17 +19,29 @@
|
||||
"author": "Lossless GmbH",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/pushrocks/smartssh/issues"
|
||||
"url": "https://gitlab.com/pushrocks/smartssh/issues"
|
||||
},
|
||||
"homepage": "https://github.com/pushrocks/smartssh#readme",
|
||||
"homepage": "https://gitlab.com/pushrocks/smartssh#readme",
|
||||
"dependencies": {
|
||||
"beautylog": "^4.1.2",
|
||||
"fs-extra": "^0.28.0",
|
||||
"js-base64": "^2.1.9",
|
||||
"smartfile": "^3.0.5"
|
||||
"@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",
|
||||
"shelljs": "^0.7.5",
|
||||
"smartfile": "^4.1.0",
|
||||
"smartpath": "^3.2.5",
|
||||
"smartstring": "^2.0.22",
|
||||
"typings-global": "^1.0.14"
|
||||
},
|
||||
"devDependencies": {
|
||||
"npmts": "^5.0.4",
|
||||
"should": "^8.3.1"
|
||||
"@types/should": "^8.1.30",
|
||||
"npmts-g": "^5.2.8",
|
||||
"should": "^11.1.1",
|
||||
"typings-test": "^1.0.3"
|
||||
}
|
||||
}
|
||||
|
1
test/test.d.ts
vendored
Normal file
1
test/test.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
import 'typings-test';
|
82
test/test.js
82
test/test.js
@ -1,5 +1,77 @@
|
||||
/// <reference path="../ts/typings/main.d.ts" />
|
||||
var should = require("should");
|
||||
var smartssh = require("../dist/index.js");
|
||||
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsZ0RBQWdEO0FBQ2hELElBQUksTUFBTSxHQUFHLE9BQU8sQ0FBQyxRQUFRLENBQUMsQ0FBQztBQUMvQixJQUFJLFFBQVEsR0FBRyxPQUFPLENBQUMsa0JBQWtCLENBQUMsQ0FBQyIsImZpbGUiOiJ0ZXN0LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cIi4uL3RzL3R5cGluZ3MvbWFpbi5kLnRzXCIgLz5cbmxldCBzaG91bGQgPSByZXF1aXJlKFwic2hvdWxkXCIpO1xubGV0IHNtYXJ0c3NoID0gcmVxdWlyZShcIi4uL2Rpc3QvaW5kZXguanNcIik7XG4iXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=
|
||||
"use strict";
|
||||
require("typings-test");
|
||||
const should = require("should");
|
||||
const smartssh = require("../dist/index");
|
||||
const path = require("path");
|
||||
describe('smartssh', function () {
|
||||
let testSshInstance;
|
||||
let testSshKey;
|
||||
describe('.SshKey', function () {
|
||||
it("'new' keyword should create a valid SshKey object", function () {
|
||||
testSshKey = new smartssh.SshKey({
|
||||
host: 'example.com',
|
||||
private: 'someExamplePrivateKey',
|
||||
public: 'someExamplePublicKey'
|
||||
});
|
||||
should(testSshKey).be.instanceof(smartssh.SshKey);
|
||||
});
|
||||
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({
|
||||
sshDirPath: path.join(process.cwd(), 'test/temp/')
|
||||
});
|
||||
should(testSshInstance).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;
|
||||
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();
|
||||
});
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUNyQixpQ0FBZ0M7QUFDaEMsMENBQTBDO0FBQzFDLDZCQUE2QjtBQUM3QixRQUFRLENBQUMsVUFBVSxFQUFDO0lBQ2hCLElBQUksZUFBcUMsQ0FBQTtJQUN6QyxJQUFJLFVBQTJCLENBQUE7SUFDL0IsUUFBUSxDQUFDLFNBQVMsRUFBQztRQUNmLEVBQUUsQ0FBQyxtREFBbUQsRUFBQztZQUNuRCxVQUFVLEdBQUcsSUFBSSxRQUFRLENBQUMsTUFBTSxDQUFDO2dCQUM3QixJQUFJLEVBQUUsYUFBYTtnQkFDbkIsT0FBTyxFQUFFLHVCQUF1QjtnQkFDaEMsTUFBTSxFQUFFLHNCQUFzQjthQUNqQyxDQUFDLENBQUE7WUFDRixNQUFNLENBQUMsVUFBVSxDQUFDLENBQUMsRUFBRSxDQUFDLFVBQVUsQ0FBQyxRQUFRLENBQUMsTUFBTSxDQUFDLENBQUE7UUFDckQsQ0FBQyxDQUFDLENBQUE7UUFDRixFQUFFLENBQUMsOEJBQThCLEVBQUM7WUFDOUIsTUFBTSxDQUFDLFVBQVUsQ0FBQyxJQUFJLENBQUMsQ0FBQyxLQUFL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FNLENBQUMsV0FBVyxDQUFDLENBQUMsQ0FBQyxDQUFDLElBQUksQ0FBQyxDQUFDLEtBQUssQ0FBQyxZQUFZLENBQUMsQ0FBQTtRQUNuRCxDQUFDLENBQUMsQ0FBQTtRQUNGLEVBQUUsQ0FBQyxzREFBc0QsRUFBQztZQUN0RCxNQUFNLENBQUMsZUFBZSxDQUFDLE1BQU0sQ0FBQyxZQUFZLENBQUMsQ0FBQyxNQUFNLENBQUMsQ0FBQyxLQUFLLENBQUMscUJBQXFCLENBQUMsQ0FBQTtRQUNwRixDQUFDLENBQUMsQ0FBQTtRQUNGLEVBQUUsQ0FBQyxrQ0FBa0MsRUFBQztZQUNsQyxlQUFlLENBQUMsU0FBUyxDQUFDLGVBQWUsQ0FBQyxNQUFNLENBQUMsZUFBZSxDQUFDLENBQUMsQ0FBQTtZQUNsRSxNQUFNLENBQUMsZUFBZSxDQUFDLE9BQU8sQ0FBQyxDQUFDLENBQUMsQ0FBQyxJQUFJLENBQUMsQ0FBQyxLQUFLLENBQUMsWUFBWSxDQUFDLENBQUE7UUFDL0QsQ0FBQyxDQUFDLENBQUE7UUFDRixFQUFFLENBQUMseUJBQXlCLEVBQUM7WUFDekIsZUFBZSxDQUFDLFdBQVcsRUFBRSxDQUFBO1FBQ2pDLENBQUMsQ0FBQyxDQUFBO0lBQ04sQ0FBQyxDQUFDLENBQUE7QUFDTixDQUFDLENBQUMsQ0FBQSJ9
|
78
test/test.ts
78
test/test.ts
@ -1,3 +1,75 @@
|
||||
/// <reference path="../ts/typings/main.d.ts" />
|
||||
let should = require("should");
|
||||
let smartssh = require("../dist/index.js");
|
||||
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'
|
||||
})
|
||||
should(testSshKey).be.instanceof(smartssh.SshKey)
|
||||
})
|
||||
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({
|
||||
sshDirPath: path.join(process.cwd(),'test/temp/')
|
||||
})
|
||||
should(testSshInstance).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
|
||||
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()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
10
ts/index.ts
10
ts/index.ts
@ -1,3 +1,7 @@
|
||||
/// <reference path="./typings/main.d.ts" />
|
||||
import plugins = require("./smartssh.plugins");
|
||||
import classes = require("./smartssh.classes");
|
||||
import 'typings-global'
|
||||
import * as plugins from './smartssh.plugins'
|
||||
|
||||
export {SshInstance} from './smartssh.classes.sshinstance'
|
||||
export {SshKey} from './smartssh.classes.sshkey'
|
||||
export {SshDir} from './smartssh.classes.sshdir'
|
||||
export {SshConfig} from './smartssh.classes.sshconfig'
|
||||
|
@ -1,8 +1,8 @@
|
||||
/// <reference path="./typings/main.d.ts" />
|
||||
import plugins = require("./smartssh.plugins");
|
||||
import classes = require("./smartssh.classes");
|
||||
import 'typings-global'
|
||||
import * as plugins from './smartssh.plugins'
|
||||
import {SshKey} from './smartssh.classes.sshkey'
|
||||
|
||||
export let sshKeyArrayFromDir = function(dirArg:string):classes.sshKey[]{
|
||||
let sshKeyArray = [];
|
||||
return sshKeyArray;
|
||||
}
|
||||
export let sshKeyArrayFromDir = function(dirArg: string): SshKey[]{
|
||||
let sshKeyArray = [] // TODO
|
||||
return sshKeyArray
|
||||
}
|
||||
|
54
ts/smartssh.classes.sshconfig.ts
Normal file
54
ts/smartssh.classes.sshconfig.ts
Normal file
@ -0,0 +1,54 @@
|
||||
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 {
|
||||
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' +
|
||||
' StrictHostKeyChecking no' + '\n'
|
||||
}
|
||||
configArray.push({
|
||||
configString: configString,
|
||||
authorized: sshKey.authorized,
|
||||
sshKey: sshKey
|
||||
})
|
||||
}
|
||||
let configFile: string = ''
|
||||
for (let key in configArray) {
|
||||
configFile = configFile + configArray[key].configString + '\n'
|
||||
};
|
||||
plugins.smartfile.memory.toFsSync(configFile,plugins.path.join(dirPathArg,'config'))
|
||||
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
|
||||
};
|
||||
|
38
ts/smartssh.classes.sshdir.ts
Normal file
38
ts/smartssh.classes.sshdir.ts
Normal file
@ -0,0 +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'
|
||||
export class SshDir { // sshDir class -> NOT EXPORTED, ONLY FOR INTERNAL USE
|
||||
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/')
|
||||
};
|
||||
}
|
||||
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(dirPathArg?: string) { // syncs sshInstance from directory
|
||||
let path = this._path
|
||||
if (dirPathArg) path = dirPathArg
|
||||
}
|
||||
updateDirPath(dirPathArg: string) {
|
||||
this._path = dirPathArg
|
||||
};
|
||||
getKeys() {
|
||||
return helpers.sshKeyArrayFromDir(this._path)
|
||||
}
|
||||
}
|
103
ts/smartssh.classes.sshinstance.ts
Normal file
103
ts/smartssh.classes.sshinstance.ts
Normal file
@ -0,0 +1,103 @@
|
||||
import 'typings-global'
|
||||
import * as plugins from './smartssh.plugins'
|
||||
import * as helpers from './smartssh.classes.helpers'
|
||||
|
||||
import {SshDir} from './smartssh.classes.sshdir'
|
||||
import {SshConfig} from './smartssh.classes.sshconfig'
|
||||
import {SshKey} from './smartssh.classes.sshkey'
|
||||
|
||||
export class SshInstance {
|
||||
private _sshKeyArray: SshKey[] // holds all ssh keys
|
||||
private _sshConfig: SshConfig // sshConfig (e.g. represents ~/.ssh/config)
|
||||
private _sshDir: SshDir // points to sshDir class instance.
|
||||
private _sshSync: boolean // if set to true, the ssh dir will be kept in sync automatically
|
||||
constructor(optionsArg: {sshDirPath?: string,sshSync?: boolean}= {}) {
|
||||
optionsArg ? void(0) : optionsArg = {}
|
||||
this._sshKeyArray = []
|
||||
this._sshConfig = new SshConfig(this._sshKeyArray)
|
||||
this._sshDir = new SshDir(this._sshKeyArray,this._sshConfig,optionsArg.sshDirPath)
|
||||
this._sshSync = optionsArg.sshSync
|
||||
};
|
||||
|
||||
// altering methods
|
||||
addKey(sshKeyArg: SshKey) {
|
||||
this._syncAuto('from')
|
||||
this._sshKeyArray.push(sshKeyArg)
|
||||
this._syncAuto('to')
|
||||
};
|
||||
removeKey(sshKeyArg: SshKey) {
|
||||
this._syncAuto('from')
|
||||
let filteredArray = this._sshKeyArray.filter((sshKeyArg2: SshKey) => {
|
||||
return (sshKeyArg != sshKeyArg2)
|
||||
})
|
||||
this._sshKeyArray = filteredArray
|
||||
this._syncAuto('to')
|
||||
};
|
||||
replaceKey(sshKeyOldArg: SshKey,sshKeyNewArg: SshKey) {
|
||||
this._syncAuto('from')
|
||||
this.removeKey(sshKeyOldArg)
|
||||
this.addKey(sshKeyNewArg)
|
||||
this._syncAuto('to')
|
||||
};
|
||||
|
||||
//
|
||||
getKey(hostArg: string): SshKey {
|
||||
this._syncAuto('from')
|
||||
let filteredArray = this._sshKeyArray.filter(function(keyArg){
|
||||
return (keyArg.host === hostArg)
|
||||
})
|
||||
if (filteredArray.length > 0) {
|
||||
return filteredArray[0]
|
||||
} else {
|
||||
return undefined
|
||||
}
|
||||
};
|
||||
get sshKeys(): SshKey[] {
|
||||
this._syncAuto('from')
|
||||
return this._sshKeyArray
|
||||
};
|
||||
|
||||
// FS methods
|
||||
|
||||
/**
|
||||
* write SshInstance to disk
|
||||
*/
|
||||
writeToDisk(dirPathArg?: string) {
|
||||
this._sync('to',dirPathArg)
|
||||
}
|
||||
|
||||
/**
|
||||
* read ab SshInstance from disk
|
||||
*/
|
||||
readFromDisk(dirPathArg?: string) {
|
||||
this._sync('from',dirPathArg)
|
||||
}
|
||||
|
||||
/* ===============================================================
|
||||
========================= Private Methods ========================
|
||||
================================================================*/
|
||||
|
||||
private _makeConfig () {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* method to invoke SshInstance _sync automatically when sshSync is true
|
||||
*/
|
||||
private _syncAuto(directionArg) {
|
||||
if (this._sshSync) this._sync(directionArg)
|
||||
}
|
||||
|
||||
/**
|
||||
* private method to sync SshInstance
|
||||
*/
|
||||
private _sync(directionArg: string,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'")
|
||||
}
|
||||
};
|
||||
}
|
99
ts/smartssh.classes.sshkey.ts
Normal file
99
ts/smartssh.classes.sshkey.ts
Normal file
@ -0,0 +1,99 @@
|
||||
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
|
||||
|
||||
/**
|
||||
* 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
|
||||
};
|
||||
set host(hostArg: string){
|
||||
this._hostVar = hostArg
|
||||
};
|
||||
|
||||
// this.privKey
|
||||
get privKey(){
|
||||
return this._privKey
|
||||
};
|
||||
set privKey(privateKeyArg: string){
|
||||
this._privKey = privateKeyArg
|
||||
};
|
||||
|
||||
// this.privKeyBase64
|
||||
get privKeyBase64(){
|
||||
return plugins.smartstring.base64.encode(this._privKey)
|
||||
}
|
||||
set privKeyBase64(privateKeyArg: string) {
|
||||
this._privKey = plugins.smartstring.base64.decode(privateKeyArg)
|
||||
}
|
||||
|
||||
// this.pubKey
|
||||
get pubKey(){
|
||||
return this._pubKey
|
||||
}
|
||||
set pubKey(publicKeyArg: string){
|
||||
this._pubKey = publicKeyArg
|
||||
};
|
||||
|
||||
// this.pubKeyBase64
|
||||
get pubKeyBase64(){
|
||||
return plugins.smartstring.base64.encode(this._pubKey)
|
||||
}
|
||||
set pubKeyBase64(publicKeyArg: string) {
|
||||
this._pubKey = plugins.smartstring.base64.decode(publicKeyArg)
|
||||
}
|
||||
|
||||
get authorized(){
|
||||
return this._authorized
|
||||
}
|
||||
set authorized(authorizedArg: boolean){
|
||||
this._authorized = authorizedArg
|
||||
}
|
||||
get type(){
|
||||
if (this._privKey && this._pubKey) {
|
||||
return 'duplex'
|
||||
} else if (this._privKey) {
|
||||
return 'private'
|
||||
} else if (this._pubKey) {
|
||||
return 'public'
|
||||
}
|
||||
};
|
||||
set type(someVlueArg: any){
|
||||
console.log('the type of an SshKey connot be set. This value is autpcomputed.')
|
||||
}
|
||||
|
||||
// methods
|
||||
read(filePathArg) {
|
||||
|
||||
}
|
||||
|
||||
store(dirPathArg: string) {
|
||||
plugins.fs.ensureDirSync(dirPathArg)
|
||||
let fileNameBase = this.host
|
||||
if (this._privKey) {
|
||||
let filePath = plugins.path.join(dirPathArg,fileNameBase)
|
||||
plugins.smartfile.memory.toFsSync(this._privKey,filePath)
|
||||
plugins.shelljs.chmod(600,filePath)
|
||||
};
|
||||
if (this._pubKey) {
|
||||
let filePath = plugins.path.join(dirPathArg,fileNameBase + '.pub')
|
||||
plugins.smartfile.memory.toFsSync(this._pubKey,filePath)
|
||||
plugins.shelljs.chmod(600,filePath)
|
||||
}
|
||||
}
|
||||
}
|
@ -1,78 +0,0 @@
|
||||
/// <reference path="./typings/main.d.ts" />
|
||||
import plugins = require("./smartssh.plugins");
|
||||
import helpers = require("./smartssh.classes.helpers");
|
||||
|
||||
export class ssh {
|
||||
private sshDir:string;
|
||||
private sshKeys:sshKey[];
|
||||
private sshSync:boolean; // if set to true, the ssh dir will be kept in sync automatically
|
||||
constructor(optionsArg:{sshDir?:string,sshSync?:boolean}={}){
|
||||
this.sshDir = optionsArg.sshDir
|
||||
this.sshDir ?
|
||||
this.sshKeys = helpers.sshKeyArrayFromDir(this.sshDir)
|
||||
: void(0);
|
||||
this.sshSync = optionsArg.sshSync;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
export class sshConfig {
|
||||
constructor(){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
export class sshKey {
|
||||
private privKey:string;
|
||||
private pubKey:string;
|
||||
constructor(optionsArg:{private:string,public:string}){
|
||||
if(!optionsArg) optionsArg = {private:undefined,public:undefined};
|
||||
this.privKey = optionsArg.private;
|
||||
this.pubKey = optionsArg.public;
|
||||
};
|
||||
|
||||
// getters
|
||||
get privateKey(){
|
||||
return this.privKey;
|
||||
};
|
||||
get privateKeyBase64(){
|
||||
return plugins.base64.encode(this.privKey);
|
||||
}
|
||||
get publicKey(){
|
||||
return this.publicKey;
|
||||
}
|
||||
get publicKeyBase64(){
|
||||
return plugins.base64.encode(this.pubKey);
|
||||
}
|
||||
get type(){
|
||||
if(this.privKey && this.pubKey){
|
||||
return "duplex";
|
||||
} else if(this.privKey){
|
||||
return "private";
|
||||
} else if(this.pubKey){
|
||||
return "public";
|
||||
}
|
||||
};
|
||||
|
||||
// setters
|
||||
set privateKey(privateKeyArg:string){
|
||||
this.privKey = privateKeyArg;
|
||||
};
|
||||
// setters
|
||||
set publicKey(publicKeyArg:string){
|
||||
this.pubKey = publicKeyArg;
|
||||
};
|
||||
|
||||
store(filePathArg?:string){
|
||||
let filePathObj = plugins.path.parse(filePathArg);
|
||||
if(filePathObj.ext = ".priv"){
|
||||
plugins.smartfile.memory.toFsSync(this.privKey,{fileName:filePathObj.name + filePathObj.ext,filePath:filePathObj.dir});
|
||||
} else if (filePathObj.ext = ".pub"){
|
||||
plugins.smartfile.memory.toFsSync(this.pubKey,{fileName:filePathObj.name + filePathObj.ext,filePath:filePathObj.dir});
|
||||
} else { //we assume we are given a directory as filePathArg, so we store the whole key
|
||||
plugins.fs.ensureDirSync(filePathObj.dir);
|
||||
this.store(plugins.path.join(filePathObj.dir,"key.priv")); // call this function recursivly
|
||||
this.store(plugins.path.join(filePathObj.dir,"key.priv")); // call this function recursivly
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,22 @@
|
||||
/// <reference path="./typings/main.d.ts" />
|
||||
export let beautylog = require("beautylog");
|
||||
export let base64 = require("js-base64").Base64;
|
||||
export let fs = require("fs-extra");
|
||||
export let path = require("path");
|
||||
export let smartfile = require("smartfile");
|
||||
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
|
||||
}
|
||||
|
@ -1,8 +0,0 @@
|
||||
{
|
||||
"version": false,
|
||||
"dependencies": {},
|
||||
"ambientDependencies": {
|
||||
"colors": "registry:dt/colors#0.6.0-1+20160317120654",
|
||||
"node": "registry:dt/node#4.0.0+20160423143914"
|
||||
}
|
||||
}
|
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