Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
d5c2bc1b53 | |||
d577a82a7b | |||
f0b52c8da7 | |||
4cb6aa03e6 | |||
8b85b6c8bc | |||
c032ff69d0 | |||
0454eef45f | |||
def368f8ab | |||
6853fa28b6 | |||
56318f28cf | |||
32b26f21cd |
21
.gitignore
vendored
21
.gitignore
vendored
@ -1,5 +1,20 @@
|
|||||||
node_modules/
|
.nogit/
|
||||||
|
|
||||||
|
# artifacts
|
||||||
coverage/
|
coverage/
|
||||||
pages/
|
|
||||||
public/
|
public/
|
||||||
test/temp/
|
pages/
|
||||||
|
|
||||||
|
# installs
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# caches
|
||||||
|
.yarn/
|
||||||
|
.cache/
|
||||||
|
.rpt2_cache
|
||||||
|
|
||||||
|
# builds
|
||||||
|
dist/
|
||||||
|
dist_*/
|
||||||
|
|
||||||
|
# custom
|
@ -1,59 +1,128 @@
|
|||||||
image: hosttoday/ht-docker-node:npmts
|
# gitzone ci_default
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
|
||||||
|
cache:
|
||||||
|
paths:
|
||||||
|
- .npmci_cache/
|
||||||
|
key: '$CI_BUILD_STAGE'
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
|
- security
|
||||||
- test
|
- test
|
||||||
- release
|
- release
|
||||||
- trigger
|
- metadata
|
||||||
- pages
|
|
||||||
|
|
||||||
testLEGACY:
|
before_script:
|
||||||
stage: test
|
- npm install -g @shipzone/npmci
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# security stage
|
||||||
|
# ====================
|
||||||
|
auditProductionDependencies:
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci test legacy
|
- npmci npm prepare
|
||||||
|
- npmci command npm install --production --ignore-scripts
|
||||||
|
- npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
- npmci command npm audit --audit-level=high --only=prod --production
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
|
||||||
testLTS:
|
auditDevDependencies:
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
stage: security
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci command npm install --ignore-scripts
|
||||||
|
- npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
- npmci command npm audit --audit-level=high --only=dev
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
allow_failure: true
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# test stage
|
||||||
|
# ====================
|
||||||
|
|
||||||
|
testStable:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci test lts
|
- npmci npm prepare
|
||||||
|
- npmci node install stable
|
||||||
|
- npmci npm install
|
||||||
|
- npmci npm test
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
|
||||||
testSTABLE:
|
testBuild:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci test stable
|
- npmci npm prepare
|
||||||
|
- npmci node install stable
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command npm run build
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
script:
|
script:
|
||||||
- npmci publish
|
- npmci node install stable
|
||||||
|
- npmci npm publish
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# metadata stage
|
||||||
|
# ====================
|
||||||
|
codequality:
|
||||||
|
stage: metadata
|
||||||
|
allow_failure: true
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
script:
|
||||||
|
- npmci command npm install -g typescript
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci npm install
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- priv
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
stage: trigger
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci trigger
|
- npmci trigger
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
pages:
|
pages:
|
||||||
image: hosttoday/ht-docker-node:npmpage
|
stage: metadata
|
||||||
stage: pages
|
|
||||||
script:
|
script:
|
||||||
- npmci command npmpage --host gitlab
|
- npmci node install stable
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command npm run buildDocs
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
artifacts:
|
artifacts:
|
||||||
expire_in: 1 week
|
expire_in: 1 week
|
||||||
paths:
|
paths:
|
||||||
- public
|
- public
|
||||||
|
allow_failure: true
|
||||||
|
12
.travis.yml
12
.travis.yml
@ -1,12 +0,0 @@
|
|||||||
language: node_js
|
|
||||||
node_js:
|
|
||||||
- '4'
|
|
||||||
- stable
|
|
||||||
deploy:
|
|
||||||
provider: npm
|
|
||||||
email: npm@lossless.digital
|
|
||||||
api_key:
|
|
||||||
secure: xApCMlDyZcTOgq+iomxR2A/2aMBhhPpgEBxdFYqXDNC/AGkr+NQJhGt67W4840FMrSUFEDZNQhOS+t6gYMqxUHv+vJFc0cHskFSuLDnAH2MS45TqtFYNcP+GARs1suuM9Il5hXNEvjVJ6XF0lYlNlK8mJstKQscdEKWyBHj42oSsgWRcuzBgqps8Vnbp+Ey2Bpfaw1yV+P1fyv8dNnkwG5dSt3EIxAcbGiMOhCz0u6oMroKfAYfNTxMJjja2uJJOqoTTShzeMyIYx+YwxorcZGfchI+TOPHHeVc+fByCHfzTZJYCy9qTSSTvWcKD/H7q3RGciEXHzhwMj0d8dlY3WPHC6BBliD6bLwVgDmToD3cdHm8OLsxW7hjFLO51vOIbhJZrWBVztlusuLwuyVAlIgeAsV8Yb5FxetxZmBU42qr5itykPl45rNd7talI0ZcoFPRTAWxxmCD8hp0d3ZLdjcEdbCzc5GYmEFN0NwKLTZF3Q1G4UbsHMgN8Pe4ohjdaYYhJ7RKgbmLR0J4NBrWIAUOhDaUTkZhgsHFyEmtbKI6JkxQtwCEBBBursemZWFQSIdtj2+O/RBaBCgoUNIpxUDBFq+D3Pir7BZP7DK2m3Otl0F9aCdqJmhCc7rOn3MueLpmndjtO1RFteXAdAkDxKp2RehIB6yohxbRmQ1O9PsA=
|
|
||||||
on:
|
|
||||||
tags: true
|
|
||||||
repo: pushrocks/smartssh
|
|
11
.vscode/launch.json
vendored
Normal file
11
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"command": "npm test",
|
||||||
|
"name": "Run npm test",
|
||||||
|
"request": "launch",
|
||||||
|
"type": "node-terminal"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
26
.vscode/settings.json
vendored
Normal file
26
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"json.schemas": [
|
||||||
|
{
|
||||||
|
"fileMatch": ["/npmextra.json"],
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"npmci": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "settings for npmci"
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "settings for gitzone",
|
||||||
|
"properties": {
|
||||||
|
"projectType": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -1,5 +0,0 @@
|
|||||||
FROM hosttoday/ht-docker-node:npmts
|
|
||||||
COPY ./ /node-app
|
|
||||||
WORKDIR /node-app
|
|
||||||
RUN npm install
|
|
||||||
RUN npmts
|
|
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
|||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2016 Push.Rocks
|
Copyright (c) 2016 Lossless GmbH
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
36
README.md
36
README.md
@ -1,36 +0,0 @@
|
|||||||
# smartssh
|
|
||||||
setups SSH quickly and in a painless manner
|
|
||||||
|
|
||||||
> Attention: This is still alpha, so some things won't work, not all things are inplemented.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var smartssh = require("smartssh");
|
|
||||||
var sshInstance = new smartssh.sshInstance({
|
|
||||||
sshDir: "/some/path/.ssh", // the standard ssh directory, optional, defaults to "~./.ssh"
|
|
||||||
sshSync: true // sync ssh this instance will represent the status of an ssh dir if set to true;
|
|
||||||
});
|
|
||||||
|
|
||||||
sshInstance.addKey(new smartssh.sshKey({
|
|
||||||
private: "somestring",
|
|
||||||
public: "somestring", // optional
|
|
||||||
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({
|
|
||||||
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
|
|
||||||
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
5
dist/index.d.ts
vendored
@ -1,5 +0,0 @@
|
|||||||
import 'typings-global';
|
|
||||||
export { SshInstance } from './smartssh.classes.sshinstance';
|
|
||||||
export { SshKey } from './smartssh.classes.sshkey';
|
|
||||||
export { SshDir } from './smartssh.classes.sshdir';
|
|
||||||
export { SshConfig } from './smartssh.classes.sshconfig';
|
|
11
dist/index.js
vendored
11
dist/index.js
vendored
@ -1,11 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
require("typings-global");
|
|
||||||
var smartssh_classes_sshinstance_1 = require("./smartssh.classes.sshinstance");
|
|
||||||
exports.SshInstance = smartssh_classes_sshinstance_1.SshInstance;
|
|
||||||
var smartssh_classes_sshkey_1 = require("./smartssh.classes.sshkey");
|
|
||||||
exports.SshKey = smartssh_classes_sshkey_1.SshKey;
|
|
||||||
var smartssh_classes_sshdir_1 = require("./smartssh.classes.sshdir");
|
|
||||||
exports.SshDir = smartssh_classes_sshdir_1.SshDir;
|
|
||||||
var smartssh_classes_sshconfig_1 = require("./smartssh.classes.sshconfig");
|
|
||||||
exports.SshConfig = smartssh_classes_sshconfig_1.SshConfig;
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMEJBQXVCO0FBR3ZCLCtFQUEwRDtBQUFsRCxxREFBQSxXQUFXLENBQUE7QUFDbkIscUVBQWdEO0FBQXhDLDJDQUFBLE1BQU0sQ0FBQTtBQUNkLHFFQUFnRDtBQUF4QywyQ0FBQSxNQUFNLENBQUE7QUFDZCwyRUFBc0Q7QUFBOUMsaURBQUEsU0FBUyxDQUFBIn0=
|
|
3
dist/smartssh.classes.helpers.d.ts
vendored
3
dist/smartssh.classes.helpers.d.ts
vendored
@ -1,3 +0,0 @@
|
|||||||
import 'typings-global';
|
|
||||||
import { SshKey } from './smartssh.classes.sshkey';
|
|
||||||
export declare let sshKeyArrayFromDir: (dirArg: string) => SshKey[];
|
|
7
dist/smartssh.classes.helpers.js
vendored
7
dist/smartssh.classes.helpers.js
vendored
@ -1,7 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
require("typings-global");
|
|
||||||
exports.sshKeyArrayFromDir = function (dirArg) {
|
|
||||||
let sshKeyArray = []; // TODO
|
|
||||||
return sshKeyArray;
|
|
||||||
};
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzc2guY2xhc3Nlcy5oZWxwZXJzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzc2guY2xhc3Nlcy5oZWxwZXJzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSwwQkFBdUI7QUFJWixRQUFBLGtCQUFrQixHQUFHLFVBQVMsTUFBYztJQUNuRCxJQUFJLFdBQVcsR0FBRyxFQUFFLENBQUEsQ0FBQyxPQUFPO0lBQzVCLE1BQU0sQ0FBQyxXQUFXLENBQUE7QUFDdEIsQ0FBQyxDQUFBIn0=
|
|
17
dist/smartssh.classes.sshconfig.d.ts
vendored
17
dist/smartssh.classes.sshconfig.d.ts
vendored
@ -1,17 +0,0 @@
|
|||||||
/// <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
47
dist/smartssh.classes.sshconfig.js
vendored
@ -1,47 +0,0 @@
|
|||||||
"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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzc2guY2xhc3Nlcy5zc2hjb25maWcuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHNzaC5jbGFzc2VzLnNzaGNvbmZpZy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMEJBQXVCO0FBQ3ZCLDhDQUE2QztBQUk3QztJQUVJLFlBQVksY0FBd0I7UUFDaEMsSUFBSSxDQUFDLFlBQVksR0FBRyxjQUFjLENBQUE7SUFDdEMsQ0FBQztJQUVEOztPQUVHO0lBQ0gsS0FBSyxDQUFDLFVBQWtCO1FBQ3BCLElBQUksSUFBSSxHQUFHLE9BQU8sQ0FBQyxDQUFDLENBQUMsS0FBSyxFQUFFLENBQUE7UUFDNUIsSUFBSSxXQUFXLEdBQW1CLEVBQUUsQ0FBQTtRQUNwQyxJQUFJLFlBQVksQ0FBQTtRQUNoQixHQUFHLENBQUMsQ0FBQyxJQUFJLEdBQUcsSUFBSSxJQUFJLENBQUMsWUFBWSxDQUFDLENBQUMsQ0FBQztZQUNoQyxJQUFJLE1BQU0sR0FBRyxJQUFJLENBQUMsWUFBWSxDQUFDLEdBQUcsQ0FBQyxDQUFBO1lBQ25DLEVBQUUsQ0FBQyxDQUFDLE1BQU0sQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDO2dCQUNkLFlBQVksR0FBRyxPQUFPLEdBQUcsTUFBTSxDQUFDLElBQUksR0FBRyxJQUFJO29CQUN4QixhQUFhLEdBQUcsTUFBTSxDQUFDLElBQUksR0FBRyxJ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sT0FBTyxDQUFBO0lBQ3ZCLENBQUM7Q0FDSjtBQXpDRCw4QkF5Q0M7QUFBQSxDQUFDO0FBTUQsQ0FBQyJ9
|
|
13
dist/smartssh.classes.sshdir.d.ts
vendored
13
dist/smartssh.classes.sshdir.d.ts
vendored
@ -1,13 +0,0 @@
|
|||||||
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
41
dist/smartssh.classes.sshdir.js
vendored
@ -1,41 +0,0 @@
|
|||||||
"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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzc2guY2xhc3Nlcy5zc2hkaXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHNzaC5jbGFzc2VzLnNzaGRpci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMEJBQXVCO0FBQ3ZCLDhDQUE2QztBQUM3QyxzREFBcUQ7QUFJckQ7SUFJSSxZQUFZLFdBQXFCLEVBQUMsU0FBb0IsRUFBQyxhQUFzQjtRQUN6RSxJQUFJLENBQUMsWUFBWSxHQUFHLFdBQVcsQ0FBQTtRQUMvQixJQUFJLENBQUMsVUFBVSxHQUFHLFNBQVMsQ0FBQTtRQUMzQixFQUFFLENBQUMsQ0FBQyxhQUFhLENBQUMsQ0FBQyxDQUFDO1lBQ2hCLElBQUksQ0FBQyxLQUFLLEdBQUcsYUFBYSxDQUFBO1FBQzlCLENBQUM7UUFBQyxJQUFJLENBQUMsQ0FBQztZQUNKLElBQUksQ0FBQyxLQUFLLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDLFNBQVMsQ0FBQyxHQUFHLENBQUMsSUFBSSxFQUFFLEVBQUMsT0FBTyxDQUFDLENBQUE7UUFDeEUsQ0FBQztRQUFBLENBQUM7SUFDTixDQUFDO0lBQ0QsVUFBVSxDQUFDLFVBQW1CO1FBQzFCLElBQUksSUFBSSxHQUFHLElBQUksQ0FBQyxLQUFLLENBQUE7UUFDckIsRUFBRSxDQUFDLENBQUMsVUFBVSxDQUFDO1lBQUMsSUFBSSxHQUFHLFVBQVUsQ0FBQTtRQUNqQyxJQUFJLENBQUMsWUFBWSxDQUFDLE9BQU8sQ0FBQyxDQUFDLFNBQVM7WUFDaEMsU0FBUyxDQUFDLEtBQUssQ0FBQyxJQUFJLENBQUMsQ0FBQTtRQUN6QixDQUFDLENBQUMsQ0FBQTtRQUNGLElBQUksQ0FBQyxVQUFVLENBQUMsS0FBSyxDQUFDLElBQUksQ0FBQyxDQUFBO0lBQy9CLENBQUM7SUFBQSxDQUFDO0lBQ0YsV0FBVyxDQUFDLFVBQW1CO1FBQzNCLElBQUksSUFBSSxHQUFHLElBQUksQ0FBQyxLQUFLLENBQUE7UUFDckIsRUFBRSxDQUFDLENBQUMsVUFBVSxDQUFDO1lBQUMsSUFBSSxHQUFHLFVBQVUsQ0FBQTtJQUNyQyxDQUFDO0lBQ0QsYUFBYSxDQUFDLFVBQWtCO1FBQzVCLElBQUksQ0FBQyxLQUFLLEdBQUcsVUFBVSxDQUFBO0lBQzNCLENBQUM7SUFBQSxDQUFDO0lBQ0YsT0FBTztRQUNILE1BQU0sQ0FBQyxPQUFPLENBQUMsa0JBQWtCLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxDQUFBO0lBQ2pELENBQUM7Q0FDSjtBQS9CRCx3QkErQkMifQ==
|
|
34
dist/smartssh.classes.sshinstance.d.ts
vendored
34
dist/smartssh.classes.sshinstance.d.ts
vendored
@ -1,34 +0,0 @@
|
|||||||
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
98
dist/smartssh.classes.sshinstance.js
vendored
@ -1,98 +0,0 @@
|
|||||||
"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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzc2guY2xhc3Nlcy5zc2hpbnN0YW5jZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0c3NoLmNsYXNzZXMuc3NoaW5zdGFuY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDBCQUF1QjtBQUl2Qix1RUFBZ0Q7QUFDaEQsNkVBQXNEO0FBR3REO0lBS0ksWUFBWSxhQUFxRCxFQUFFO1FBQy9ELFVBQVUsR0FBRyxLQUFJLENBQUMsQ0FBQyxDQUFDLEdBQUcsVUFBVSxHQUFHLEVBQUUsQ0FBQTtRQUN0QyxJQUFJLENBQUMsWUFBWSxHQUFHLEVBQUUsQ0FBQTtRQUN0QixJQUFJLENBQUMsVUFBVSxHQUFHLElBQUksc0NBQVMsQ0FBQyxJQUFJLENBQUMsWUFBWSxDQUFDLENBQUE7UUFDbEQsSUFBSSxDQUFDLE9BQU8sR0FBRyxJQUFJLGdDQUFNLENBQUMsSUFBSSxDQUFDLFlBQVksRUFBQyxJQUFJLENBQUMsVUFBVSxFQUFDLFVBQVUsQ0FBQyxVQUFVLENBQUMsQ0FBQTtRQUNsRixJQUFJLENBQUM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SSxDQUFDLEtBQUssQ0FBQyxZQUFZLENBQUMsQ0FBQTtJQUMvQyxDQUFDO0lBRUQ7O09BRUc7SUFDSyxLQUFLLENBQUMsWUFBb0IsRUFBQyxVQUFtQjtRQUNsRCxFQUFFLENBQUMsQ0FBQyxZQUFZLEtBQUssTUFBTSxDQUFDLENBQUMsQ0FBQztZQUMxQixJQUFJLENBQUMsT0FBTyxDQUFDLFdBQVcsQ0FBQyxVQUFVLENBQUMsQ0FBQSxDQUFDLG9DQUFvQztRQUM3RSxDQUFDO1FBQUMsSUFBSSxDQUFDLEVBQUUsQ0FBQyxDQUFDLFlBQVksS0FBSyxJQUFJLENBQUMsQ0FBQyxDQUFDO1lBQy9CLElBQUksQ0FBQyxPQUFPLENBQUMsVUFBVSxDQUFDLFVBQVUsQ0FBQyxDQUFBO1FBQ3ZDLENBQUM7UUFBQyxJQUFJLENBQUMsQ0FBQztZQUNKLE1BQU0sSUFBSSxLQUFLLENBQUMscURBQXFELENBQUMsQ0FBQTtRQUMxRSxDQUFDO0lBQ0wsQ0FBQztJQUFBLENBQUM7Q0FDTDtBQTlGRCxrQ0E4RkMifQ==
|
|
25
dist/smartssh.classes.sshkey.d.ts
vendored
25
dist/smartssh.classes.sshkey.d.ts
vendored
@ -1,25 +0,0 @@
|
|||||||
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
96
dist/smartssh.classes.sshkey.js
vendored
@ -1,96 +0,0 @@
|
|||||||
"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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzc2guY2xhc3Nlcy5zc2hrZXkuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHNzaC5jbGFzc2VzLnNzaGtleS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMEJBQXVCO0FBQ3ZCLDhDQUE2QztBQUc3QztJQU1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UFDLFFBQVEsQ0FBQyxJQUFJLENBQUMsT0FBTyxFQUFDLFFBQVEsQ0FBQyxDQUFBO1lBQ3hELE9BQU8sQ0FBQyxPQUFPLENBQUMsS0FBSyxDQUFDLEdBQUcsRUFBQyxRQUFRLENBQUMsQ0FBQTtRQUN2QyxDQUFDO0lBQ0wsQ0FBQztDQUNKO0FBOUZELHdCQThGQyJ9
|
|
11
dist/smartssh.plugins.d.ts
vendored
11
dist/smartssh.plugins.d.ts
vendored
@ -1,11 +0,0 @@
|
|||||||
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 };
|
|
21
dist/smartssh.plugins.js
vendored
21
dist/smartssh.plugins.js
vendored
@ -1,21 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
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
|
|
17
npmextra.json
Normal file
17
npmextra.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"npmci": {
|
||||||
|
"npmGlobalTools": [],
|
||||||
|
"npmAccessLevel": "public"
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"projectType": "npm",
|
||||||
|
"module": {
|
||||||
|
"githost": "gitlab.com",
|
||||||
|
"gitscope": "pushrocks",
|
||||||
|
"gitrepo": "smartssh",
|
||||||
|
"description": "setups SSH quickly and in a painless manner",
|
||||||
|
"npmPackagename": "@pushrocks/smartssh",
|
||||||
|
"license": "MIT"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +0,0 @@
|
|||||||
{
|
|
||||||
"mode":"default",
|
|
||||||
"coverageTreshold":50
|
|
||||||
}
|
|
64
package.json
64
package.json
@ -1,11 +1,16 @@
|
|||||||
{
|
{
|
||||||
"name": "smartssh",
|
"name": "@pushrocks/smartssh",
|
||||||
"version": "1.2.0",
|
"version": "1.2.5",
|
||||||
|
"private": false,
|
||||||
"description": "setups SSH quickly and in a painless manner",
|
"description": "setups SSH quickly and in a painless manner",
|
||||||
"main": "dist/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(npmts)"
|
"test": "(tstest test/)",
|
||||||
|
"testDocker": "tsdocker",
|
||||||
|
"build": "(tsbuild)",
|
||||||
|
"buildDocs": "tsdoc"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -23,25 +28,36 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/smartssh#readme",
|
"homepage": "https://gitlab.com/pushrocks/smartssh#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/fs-extra": "0.0.35",
|
"@pushrocks/smartfile": "^10.0.5",
|
||||||
"@types/js-base64": "^2.1.5",
|
"@pushrocks/smartpath": "^5.0.5",
|
||||||
"@types/minimatch": "^2.0.29",
|
"@pushrocks/smartpromise": "^3.0.2",
|
||||||
"@types/q": "0.0.32",
|
"@pushrocks/smartshell": "^2.0.23",
|
||||||
"@types/shelljs": "^0.3.33",
|
"@pushrocks/smartstring": "^4.0.5",
|
||||||
"beautylog": "^6.0.0",
|
"@types/fs-extra": "^9.0.13",
|
||||||
"fs-extra": "^1.0.0",
|
"@types/minimatch": "^5.1.2",
|
||||||
"minimatch": "^3.0.3",
|
"fs-extra": "^10.1.0",
|
||||||
"q": "^1.4.1",
|
"minimatch": "^5.1.0"
|
||||||
"shelljs": "^0.7.5",
|
|
||||||
"smartfile": "^4.1.0",
|
|
||||||
"smartpath": "^3.2.5",
|
|
||||||
"smartstring": "^2.0.22",
|
|
||||||
"typings-global": "^1.0.14"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/should": "^8.1.30",
|
"@gitzone/tsbuild": "^2.1.11",
|
||||||
"npmts-g": "^5.2.8",
|
"@gitzone/tsrun": "^1.2.6",
|
||||||
"should": "^11.1.1",
|
"@gitzone/tstest": "^1.0.24",
|
||||||
"typings-test": "^1.0.3"
|
"@pushrocks/tapbundle": "^5.0.4",
|
||||||
}
|
"@types/node": "^18.8.4"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"ts/**/*",
|
||||||
|
"ts_web/**/*",
|
||||||
|
"dist/**/*",
|
||||||
|
"dist_*/**/*",
|
||||||
|
"dist_ts/**/*",
|
||||||
|
"dist_ts_web/**/*",
|
||||||
|
"assets/**/*",
|
||||||
|
"cli.js",
|
||||||
|
"npmextra.json",
|
||||||
|
"readme.md"
|
||||||
|
],
|
||||||
|
"browserslist": [
|
||||||
|
"last 1 chrome versions"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
4213
pnpm-lock.yaml
generated
Normal file
4213
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
1
test/temp/bitbucket.org
Normal file
1
test/temp/bitbucket.org
Normal file
@ -0,0 +1 @@
|
|||||||
|
somePrivateKey
|
1
test/temp/bitbucket.org.pub
Normal file
1
test/temp/bitbucket.org.pub
Normal file
@ -0,0 +1 @@
|
|||||||
|
somePublicKey
|
15
test/temp/config
Normal file
15
test/temp/config
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
Host gitlab.com
|
||||||
|
HostName gitlab.com
|
||||||
|
IdentityFile ~/.ssh/gitlab.com
|
||||||
|
StrictHostKeyChecking no
|
||||||
|
|
||||||
|
Host bitbucket.org
|
||||||
|
HostName bitbucket.org
|
||||||
|
IdentityFile ~/.ssh/bitbucket.org
|
||||||
|
StrictHostKeyChecking no
|
||||||
|
|
||||||
|
Host github.com
|
||||||
|
HostName github.com
|
||||||
|
IdentityFile ~/.ssh/github.com
|
||||||
|
StrictHostKeyChecking no
|
||||||
|
|
1
test/temp/example.com
Normal file
1
test/temp/example.com
Normal file
@ -0,0 +1 @@
|
|||||||
|
someExamplePrivateKey
|
1
test/temp/example.com.pub
Normal file
1
test/temp/example.com.pub
Normal file
@ -0,0 +1 @@
|
|||||||
|
someExamplePublicKey
|
1
test/temp/github.com
Normal file
1
test/temp/github.com
Normal file
@ -0,0 +1 @@
|
|||||||
|
someGitHubPrivateKey
|
1
test/temp/github.com.pub
Normal file
1
test/temp/github.com.pub
Normal file
@ -0,0 +1 @@
|
|||||||
|
someGitHubPublicKey
|
1
test/temp/gitlab.com
Normal file
1
test/temp/gitlab.com
Normal file
@ -0,0 +1 @@
|
|||||||
|
somePrivateKey
|
1
test/temp/gitlab.com.pub
Normal file
1
test/temp/gitlab.com.pub
Normal file
@ -0,0 +1 @@
|
|||||||
|
somePublicKey
|
1
test/test.d.ts
vendored
1
test/test.d.ts
vendored
@ -1 +0,0 @@
|
|||||||
import 'typings-test';
|
|
77
test/test.js
77
test/test.js
@ -1,77 +0,0 @@
|
|||||||
"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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUNyQixpQ0FBZ0M7QUFDaEMsMENBQTBDO0FBQzFDLDZCQUE2QjtBQUM3QixRQUFRLENBQUMsVUFBVSxFQUFDO0lBQ2hCLElBQUksZUFBcUMsQ0FBQTtJQUN6QyxJQUFJLFVBQTJCLENBQUE7SUFDL0IsUUFBUSxDQUFDLFNBQVMsRUFBQztRQUNmLEVBQUUsQ0FBQyxtREFBbUQsRUFBQztZQUNuRCxVQUFVLEdBQUcsSUFBSSxRQUFRLENBQUMsTUFBTSxDQUFDO2dCQUM3QixJQUFJLEVBQUUsYUFBYTtnQkFDbkIsT0FBTyxFQUFFLHVCQUF1QjtnQkFDaEMsTUFBTSxFQUFFLHNCQUFzQjthQUNqQyxDQUFDLENBQUE7WUFDRixNQUFNLENBQUMsVUFBVSxDQUFDLENBQUMsRUFBRSxDQUFDLFVBQVUsQ0FBQyxRQUFRLENBQUMsTUFBTSxDQUFDLENBQUE7UUFDckQsQ0FBQyxDQUFDLENBQUE7UUFDRixFQUFFLENBQUMsOEJBQThCLEVBQUM7WUFDOUIsTUFBTSxDQUFDLFVBQVUsQ0FBQyxJQUFJLENBQUMsQ0FBQyxLQUFLLENBQUMsUUFBUSxDQUFDLENBQUE7UUFDM0MsQ0FBQyxDQUFDLENBQUE7UUFDRixFQUFFLENBQUMsaUNBQWlDLEVBQUM7WUFDakMsTUFBTSxDQUFDLFVBQVUsQ0FBQyxNQUFNLENBQUMsQ0FBQyxLQUFLLENBQUMsc0JBQXNCLENBQUMsQ0FBQTtRQUMzRCxDQUFDLENBQUMsQ0FBQ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yxZQUFZLENBQUMsQ0FBQyxNQUFNLENBQUMsQ0FBQyxLQUFLLENBQUMscUJBQXFCLENBQUMsQ0FBQTtRQUNwRixDQUFDLENBQUMsQ0FBQTtRQUNGLEVBQUUsQ0FBQyxrQ0FBa0MsRUFBQztZQUNsQyxlQUFlLENBQUMsU0FBUyxDQUFDLGVBQWUsQ0FBQyxNQUFNLENBQUMsZUFBZSxDQUFDLENBQUMsQ0FBQTtZQUNsRSxNQUFNLENBQUMsZUFBZSxDQUFDLE9BQU8sQ0FBQyxDQUFDLENBQUMsQ0FBQyxJQUFJLENBQUMsQ0FBQyxLQUFLLENBQUMsWUFBWSxDQUFDLENBQUE7UUFDL0QsQ0FBQyxDQUFDLENBQUE7UUFDRixFQUFFLENBQUMseUJBQXlCLEVBQUM7WUFDekIsZUFBZSxDQUFDLFdBQVcsRUFBRSxDQUFBO1FBQ2pDLENBQUMsQ0FBQyxDQUFBO0lBQ04sQ0FBQyxDQUFDLENBQUE7QUFDTixDQUFDLENBQUMsQ0FBQSJ9
|
|
137
test/test.ts
137
test/test.ts
@ -1,75 +1,84 @@
|
|||||||
import 'typings-test'
|
import { expect, tap } from '@pushrocks/tapbundle';
|
||||||
import * as should from 'should'
|
import * as smartssh from '../ts/index.js';
|
||||||
import smartssh = require('../dist/index')
|
import * as path from 'path';
|
||||||
import path = require('path')
|
|
||||||
describe('smartssh',function(){
|
let testSshInstance: smartssh.SshInstance;
|
||||||
let testSshInstance: smartssh.SshInstance
|
let testSshKey: smartssh.SshKey;
|
||||||
let testSshKey: smartssh.SshKey
|
tap.test('should create a valid SshKey object', async () => {
|
||||||
describe('.SshKey',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',
|
||||||
})
|
});
|
||||||
should(testSshKey).be.instanceof(smartssh.SshKey)
|
expect(testSshKey).toBeInstanceOf(smartssh.SshKey);
|
||||||
})
|
});
|
||||||
it('.type should be a valid type',function(){
|
tap.test('.type should be a valid type', async () => {
|
||||||
should(testSshKey.type).equal('duplex')
|
expect(testSshKey.type).toEqual('duplex');
|
||||||
})
|
});
|
||||||
it('.publicKey should be public key',function(){
|
tap.test('.publicKey should be public key', async () => {
|
||||||
should(testSshKey.pubKey).equal('someExamplePublicKey')
|
expect(testSshKey.pubKey).toEqual('someExamplePublicKey');
|
||||||
})
|
});
|
||||||
it('.privateKey should be private key',function(){
|
tap.test('.privateKey should be private key', async () => {
|
||||||
should(testSshKey.privKey).equal('someExamplePrivateKey')
|
expect(testSshKey.privKey).toEqual('someExamplePrivateKey');
|
||||||
})
|
});
|
||||||
it('.publicKeyBase64 should be public key base 64 encoded',function(){
|
tap.test('.publicKeyBase64 should be public key base 64 encoded', async () => {
|
||||||
testSshKey.pubKeyBase64
|
// tslint:disable-next-line:no-unused-expression
|
||||||
})
|
testSshKey.pubKeyBase64;
|
||||||
it('.store() should store the file to disk',function(){
|
});
|
||||||
testSshKey.store(path.join(process.cwd(),'test/temp'))
|
tap.test('.store() should store the file to disk', async () => {
|
||||||
})
|
testSshKey.store(path.join(process.cwd(), 'test/temp'));
|
||||||
})
|
});
|
||||||
describe('.SshInstance',function(){
|
|
||||||
it("'new' keyword should create a new SshInstance object from class",function(){
|
// SSH INstance
|
||||||
|
tap.test("'new' keyword should create a new SshInstance object from class", async () => {
|
||||||
testSshInstance = new smartssh.SshInstance({
|
testSshInstance = new smartssh.SshInstance({
|
||||||
sshDirPath: path.join(process.cwd(),'test/temp/')
|
sshDirPath: path.join(process.cwd(), 'test/temp/'),
|
||||||
})
|
});
|
||||||
should(testSshInstance).be.instanceof(smartssh.SshInstance)
|
expect(testSshInstance).toBeInstanceOf(smartssh.SshInstance);
|
||||||
})
|
});
|
||||||
it('.addKey() should accept a new SshKey object',function(){
|
tap.test('.addKey() should accept a new SshKey object', async () => {
|
||||||
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(){
|
|
||||||
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()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('.sshKeys should point to an array of sshKeys', async () => {
|
||||||
|
let sshKeyArray = testSshInstance.sshKeys;
|
||||||
|
expect(sshKeyArray).toBeInstanceOf(Array);
|
||||||
|
expect(sshKeyArray[0].host).toEqual('gitlab.com');
|
||||||
|
expect(sshKeyArray[1].host).toEqual('bitbucket.org');
|
||||||
|
expect(sshKeyArray[2].host).toEqual('github.com');
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('.getKey() should get a specific key selected by host', async () => {
|
||||||
|
expect(testSshInstance.getKey('github.com').pubKey).toEqual('someGitHubPublicKey');
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('.removeKey() should remove a key', async () => {
|
||||||
|
testSshInstance.removeKey(testSshInstance.getKey('bitbucket.org'));
|
||||||
|
expect(testSshInstance.sshKeys[1].host).toEqual('github.com');
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('it should store to disk', async () => {
|
||||||
|
testSshInstance.writeToDisk();
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.start();
|
||||||
|
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* autocreated commitinfo by @pushrocks/commitinfo
|
||||||
|
*/
|
||||||
|
export const commitinfo = {
|
||||||
|
name: '@pushrocks/smartssh',
|
||||||
|
version: '1.2.5',
|
||||||
|
description: 'setups SSH quickly and in a painless manner'
|
||||||
|
}
|
11
ts/index.ts
11
ts/index.ts
@ -1,7 +1,6 @@
|
|||||||
import 'typings-global'
|
import * as plugins from './smartssh.plugins.js';
|
||||||
import * as plugins from './smartssh.plugins'
|
|
||||||
|
|
||||||
export {SshInstance} from './smartssh.classes.sshinstance'
|
export { SshInstance } from './smartssh.classes.sshinstance.js';
|
||||||
export {SshKey} from './smartssh.classes.sshkey'
|
export { SshKey } from './smartssh.classes.sshkey.js';
|
||||||
export {SshDir} from './smartssh.classes.sshdir'
|
export { SshDir } from './smartssh.classes.sshdir.js';
|
||||||
export {SshConfig} from './smartssh.classes.sshconfig'
|
export { SshConfig } from './smartssh.classes.sshconfig.js';
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import 'typings-global'
|
import * as plugins from './smartssh.plugins.js';
|
||||||
import * as plugins from './smartssh.plugins'
|
import { SshKey } from './smartssh.classes.sshkey.js';
|
||||||
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,60 @@
|
|||||||
import 'typings-global'
|
import * as plugins from './smartssh.plugins.js';
|
||||||
import * as plugins from './smartssh.plugins'
|
import * as helpers from './smartssh.classes.helpers.js';
|
||||||
import * as helpers from './smartssh.classes.helpers'
|
import { SshKey } from './smartssh.classes.sshkey.js';
|
||||||
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.smartpromise.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 =
|
||||||
' HostName ' + sshKey.host + '\n' +
|
'Host ' +
|
||||||
' IdentityFile ~/.ssh/' + sshKey.host + '\n' +
|
sshKey.host +
|
||||||
' StrictHostKeyChecking no' + '\n'
|
'\n' +
|
||||||
|
' HostName ' +
|
||||||
|
sshKey.host +
|
||||||
|
'\n' +
|
||||||
|
' IdentityFile ~/.ssh/' +
|
||||||
|
sshKey.host +
|
||||||
|
'\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.smartpromise.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,47 @@
|
|||||||
import 'typings-global'
|
import * as plugins from './smartssh.plugins.js';
|
||||||
import * as plugins from './smartssh.plugins'
|
import * as helpers from './smartssh.classes.helpers.js';
|
||||||
import * as helpers from './smartssh.classes.helpers'
|
import { SshInstance } from './smartssh.classes.sshinstance.js';
|
||||||
import {SshInstance} from './smartssh.classes.sshinstance'
|
import { SshKey } from './smartssh.classes.sshkey.js';
|
||||||
import {SshKey} from './smartssh.classes.sshkey'
|
import { SshConfig } from './smartssh.classes.sshconfig.js';
|
||||||
import {SshConfig} from './smartssh.classes.sshconfig'
|
|
||||||
export class SshDir { // sshDir class -> NOT EXPORTED, ONLY FOR INTERNAL USE
|
export class SshDir {
|
||||||
private _path: string // the path of the ssh directory
|
// sshDir class -> NOT EXPORTED, ONLY FOR INTERNAL USE
|
||||||
private _sshKeyArray: SshKey[]
|
private _path: string; // the path of the ssh directory
|
||||||
private _sshConfig: SshConfig
|
private _sshKeyArray: SshKey[];
|
||||||
|
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
|
}
|
||||||
let path = this._path
|
|
||||||
if (dirPathArg) path = dirPathArg
|
writeToDir(dirPathArg?: string) {
|
||||||
|
// syncs sshInstance to directory
|
||||||
|
let path = this._path;
|
||||||
|
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
|
|
||||||
let path = this._path
|
/**
|
||||||
if (dirPathArg) path = dirPathArg
|
* TODO: implement reading of directories
|
||||||
|
*/
|
||||||
|
readFromDir(dirPathArg?: string) {
|
||||||
|
// syncs sshInstance from directory
|
||||||
|
let path = this._path;
|
||||||
|
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,61 +1,63 @@
|
|||||||
import 'typings-global'
|
import * as plugins from './smartssh.plugins.js';
|
||||||
import * as plugins from './smartssh.plugins'
|
import * as helpers from './smartssh.classes.helpers.js';
|
||||||
import * as helpers from './smartssh.classes.helpers'
|
|
||||||
|
|
||||||
import {SshDir} from './smartssh.classes.sshdir'
|
import { SshDir } from './smartssh.classes.sshdir.js';
|
||||||
import {SshConfig} from './smartssh.classes.sshconfig'
|
import { SshConfig } from './smartssh.classes.sshconfig.js';
|
||||||
import {SshKey} from './smartssh.classes.sshkey'
|
import { SshKey } from './smartssh.classes.sshkey.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SshInstance is the main class dealing with ssh management
|
||||||
|
*/
|
||||||
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');
|
||||||
};
|
}
|
||||||
|
|
||||||
//
|
// non altering methods
|
||||||
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,41 +65,38 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===============================================================
|
/* ===============================================================
|
||||||
========================= Private Methods ========================
|
========================= Private Methods ========================
|
||||||
================================================================*/
|
================================================================*/
|
||||||
|
|
||||||
private _makeConfig () {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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: 'from' | 'to') {
|
||||||
if (this._sshSync) this._sync(directionArg)
|
if (this._sshSync) {
|
||||||
|
// if auto sync is not enabled, do nothing
|
||||||
|
this._sync(directionArg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* private method to sync SshInstance
|
* private method to sync SshInstance
|
||||||
*/
|
*/
|
||||||
private _sync(directionArg: string,dirPathArg?: string) {
|
private _sync(directionArg: 'from' | 'to', 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 {
|
}
|
||||||
throw new Error("directionArg not recognised. Must be 'to' or 'from'")
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
@ -1,99 +1,106 @@
|
|||||||
import 'typings-global'
|
import * as plugins from './smartssh.plugins.js';
|
||||||
import * as plugins from './smartssh.plugins'
|
import * as helpers from './smartssh.classes.helpers.js';
|
||||||
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;
|
||||||
|
|
||||||
|
private _smarthshellInstance = new plugins.shelljs.Smartshell({
|
||||||
|
executor: 'bash',
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the constructor for class SshKey
|
* the constructor for class SshKey
|
||||||
*/
|
*/
|
||||||
constructor(optionsArg: {private?: string,public?: string,host?: string,authorized?: boolean}= {}) {
|
constructor(
|
||||||
this._privKey = optionsArg.private
|
optionsArg: { private?: string; public?: string; host?: string; authorized?: boolean } = {}
|
||||||
this._pubKey = optionsArg.public
|
) {
|
||||||
this._hostVar = optionsArg.host
|
this._privKey = optionsArg.private;
|
||||||
this._authorized = optionsArg.authorized
|
this._pubKey = optionsArg.public;
|
||||||
};
|
this._hostVar = optionsArg.host;
|
||||||
|
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.smartstring.base64.encode(this._privKey)
|
return plugins.smartstring.base64.encode(this._privKey);
|
||||||
}
|
}
|
||||||
set privKeyBase64(privateKeyArg: string) {
|
set privKeyBase64(privateKeyArg: string) {
|
||||||
this._privKey = plugins.smartstring.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.smartstring.base64.encode(this._pubKey)
|
return plugins.smartstring.base64.encode(this._pubKey);
|
||||||
}
|
}
|
||||||
set pubKeyBase64(publicKeyArg: string) {
|
set pubKeyBase64(publicKeyArg: string) {
|
||||||
this._pubKey = plugins.smartstring.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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns wether there is a private, a public or both keys
|
||||||
|
*/
|
||||||
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 autocomputed.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
read(filePathArg) {
|
read(filePathArg) {}
|
||||||
|
|
||||||
}
|
async store(dirPathArg: string) {
|
||||||
|
plugins.fs.ensureDirSync(dirPathArg);
|
||||||
store(dirPathArg: string) {
|
let fileNameBase = this.host;
|
||||||
plugins.fs.ensureDirSync(dirPathArg)
|
|
||||||
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)
|
await this._smarthshellInstance.exec(`chmod 0600 ${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)
|
await this._smarthshellInstance.exec(`chmod 0600 ${filePath}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,10 @@
|
|||||||
import 'typings-global'
|
import * as fs from 'fs-extra';
|
||||||
import * as beautylog from 'beautylog'
|
import * as minimatch from 'minimatch';
|
||||||
import * as fs from 'fs-extra'
|
import * as path from 'path';
|
||||||
import * as minimatch from 'minimatch'
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
import * as path from 'path'
|
import * as shelljs from '@pushrocks/smartshell';
|
||||||
import * as q from 'q'
|
import * as smartfile from '@pushrocks/smartfile';
|
||||||
import * as shelljs from 'shelljs'
|
import * as smartpath from '@pushrocks/smartpath';
|
||||||
import * as smartfile from 'smartfile'
|
import * as smartstring from '@pushrocks/smartstring';
|
||||||
import * as smartpath from 'smartpath'
|
|
||||||
import * as smartstring from 'smartstring'
|
|
||||||
|
|
||||||
export {
|
export { fs, minimatch, path, smartpromise, shelljs, smartfile, smartpath, smartstring };
|
||||||
beautylog,
|
|
||||||
fs,
|
|
||||||
minimatch,
|
|
||||||
path,
|
|
||||||
q,
|
|
||||||
shelljs,
|
|
||||||
smartfile,
|
|
||||||
smartpath,
|
|
||||||
smartstring
|
|
||||||
}
|
|
||||||
|
10
tsconfig.json
Normal file
10
tsconfig.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"useDefineForClassFields": false,
|
||||||
|
"target": "ES2022",
|
||||||
|
"module": "ES2022",
|
||||||
|
"moduleResolution": "nodenext",
|
||||||
|
"esModuleInterop": true
|
||||||
|
}
|
||||||
|
}
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": "tslint-config-standard"
|
|
||||||
}
|
|
Reference in New Issue
Block a user