13 Commits

Author SHA1 Message Date
1f1bf7c21f 1.2.7 2022-10-11 13:18:04 +02:00
c652d0bf07 fix(core): update 2022-10-11 13:18:04 +02:00
eccc6294a8 1.2.6 2022-10-11 13:13:14 +02:00
f8a75a8d42 fix(core): update 2022-10-11 13:13:14 +02:00
d5c2bc1b53 1.2.5 2022-10-11 13:05:30 +02:00
d577a82a7b fix(core): update 2022-10-11 13:05:29 +02:00
f0b52c8da7 1.2.4 2019-07-17 11:48:31 +02:00
4cb6aa03e6 fix(core): update 2019-07-17 11:48:31 +02:00
8b85b6c8bc 1.2.3 2018-09-17 22:32:31 +02:00
c032ff69d0 fix(core): update 2018-09-17 22:32:31 +02:00
0454eef45f update structure 2017-06-15 19:25:12 +02:00
def368f8ab 1.2.2 2017-06-15 17:53:24 +02:00
6853fa28b6 update to latest standards 2017-06-15 17:52:22 +02:00
50 changed files with 17889 additions and 998 deletions

21
.gitignore vendored
View File

@ -1,5 +1,20 @@
node_modules/
.nogit/
# artifacts
coverage/
pages/
public/
test/temp/
pages/
# installs
node_modules/
# caches
.yarn/
.cache/
.rpt2_cache
# builds
dist/
dist_*/
# custom

View File

@ -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:
- test
- release
- trigger
- pages
- security
- test
- release
- metadata
testLEGACY:
stage: test
before_script:
- npm install -g @shipzone/npmci
# ====================
# security stage
# ====================
auditProductionDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
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:
- docker
allow_failure: true
testLTS:
stage: test
auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci test lts
- 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
testSTABLE:
allow_failure: true
# ====================
# test stage
# ====================
testStable:
stage: test
script:
- npmci test stable
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
testBuild:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
release:
stage: release
script:
- npmci publish
- npmci node install stable
- npmci npm publish
only:
- tags
tags:
- lossless
- 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:
stage: trigger
stage: metadata
script:
- npmci trigger
only:
- tags
tags:
- lossless
- docker
- notpriv
pages:
image: hosttoday/ht-docker-node:npmpage
stage: pages
stage: metadata
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:
- tags
artifacts:
expire_in: 1 week
paths:
- public
- public
allow_failure: true

View File

@ -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
View 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
View 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"]
}
}
}
}
}
}
]
}

View File

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

View File

@ -1,6 +1,6 @@
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
of this software and associated documentation files (the "Software"), to deal

View File

@ -1,53 +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.
## Availabililty
[![npm](https://push.rocks/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartssh)
[![git](https://push.rocks/assets/repo-button-git.svg)](https://gitlab.com/pushrocks/smartssh)
[![git](https://push.rocks/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smartssh)
[![docs](https://push.rocks/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/smartssh/)
## Status for master
[![build status](https://gitlab.com/pushrocks/smartssh/badges/master/build.svg)](https://gitlab.com/pushrocks/smartssh/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smartssh/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartssh/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/smartssh.svg)](https://www.npmjs.com/package/smartssh)
[![Dependency Status](https://david-dm.org/pushrocks/smartssh.svg)](https://david-dm.org/pushrocks/smartssh)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/smartssh/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/smartssh/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/pushrocks/smartssh/badges/code.svg)](https://www.bithound.io/github/pushrocks/smartssh)
[![TypeScript](https://img.shields.io/badge/TypeScript-2.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
## 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
```
[![npm](https://push.rocks/assets/repo-header.svg)](https://push.rocks)

5
dist/index.d.ts vendored
View File

@ -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
View File

@ -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=

View File

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

View File

@ -1,7 +0,0 @@
"use strict";
require("typings-global");
exports.sshKeyArrayFromDir = function (dirArg) {
let sshKeyArray = []; // TODO
return sshKeyArray;
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzc2guY2xhc3Nlcy5oZWxwZXJzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzc2guY2xhc3Nlcy5oZWxwZXJzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSwwQkFBdUI7QUFJWixRQUFBLGtCQUFrQixHQUFHLFVBQVMsTUFBYztJQUNuRCxJQUFJLFdBQVcsR0FBRyxFQUFFLENBQUEsQ0FBQyxPQUFPO0lBQzVCLE1BQU0sQ0FBQyxXQUFXLENBQUE7QUFDdEIsQ0FBQyxDQUFBIn0=

View File

@ -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;
}

View File

@ -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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzc2guY2xhc3Nlcy5zc2hjb25maWcuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHNzaC5jbGFzc2VzLnNzaGNvbmZpZy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMEJBQXVCO0FBQ3ZCLDhDQUE2QztBQUk3QztJQUVJLFlBQVksY0FBd0I7UUFDaEMsSUFBSSxDQUFDLFlBQVksR0FBRyxjQUFjLENBQUE7SUFDdEMsQ0FBQztJQUVEOztPQUVHO0lBQ0gsS0FBSyxDQUFDLFVBQWtCO1FBQ3BCLElBQUksSUFBSSxHQUFHLE9BQU8sQ0FBQyxDQUFDLENBQUMsS0FBSyxFQUFFLENBQUE7UUFDNUIsSUFBSSxXQUFXLEdBQW1CLEVBQUUsQ0FBQTtRQUNwQyxJQUFJLFlBQVksQ0FBQTtRQUNoQixHQUFHLENBQUMsQ0FBQyxJQUFJLEdBQUcsSUFBSSxJQUFJLENBQUMsWUFBWSxDQUFDLENBQUMsQ0FBQztZQUNoQyxJQUFJLE1BQU0sR0FBRyxJQUFJLENBQUMsWUFBWSxDQUFDLEdBQUcsQ0FBQyxDQUFBO1lBQ25DLEVBQUUsQ0FBQyxDQUFDLE1BQU0sQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDO2dCQUNkLFlBQVksR0FBRyxPQUFPLEdBQUcsTUFBTSxDQUFDLElBQUksR0FBRyxJQUFJO29CQUN4QixhQUFhLEdBQUcsTUFBTSxDQUFDLElBQUksR0FBRyxJQUFJO29CQUNsQyx3QkFBd0IsR0FBRyxNQUFNLENBQUMsSUFBSSxHQUFHLElBQUk7b0JBQzdDLDRCQUE0QixHQUFHLElBQUksQ0FBQTtZQUMxRCx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 '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[];
}

View File

@ -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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzc2guY2xhc3Nlcy5zc2hkaXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHNzaC5jbGFzc2VzLnNzaGRpci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMEJBQXVCO0FBQ3ZCLDhDQUE2QztBQUM3QyxzREFBcUQ7QUFJckQ7SUFJSSxZQUFZLFdBQXFCLEVBQUMsU0FBb0IsRUFBQyxhQUFzQjtRQUN6RSxJQUFJLENBQUMsWUFBWSxHQUFHLFdBQVcsQ0FBQTtRQUMvQixJQUFJLENBQUMsVUFBVSxHQUFHL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QU0sQ0FBQyxPQUFPLENBQUMsa0JBQWtCLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxDQUFBO0lBQ2pELENBQUM7Q0FDSjtBQS9CRCx3QkErQkMifQ==

View File

@ -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?);
}

View File

@ -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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzc2guY2xhc3Nlcy5zc2hpbnN0YW5jZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0c3NoLmNsYXNzZXMuc3NoaW5zdGFuY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDBCQUF1QjtBQUl2Qix1RUFBZ0Q7QUFDaEQsNkVBQXNEO0FBR3REO0lBS0ksWUFBWSxhQUFxRCxFQUFFO1FBQy9ELFVBQVUsR0FBRyxLQUFJLENBQUMsQ0FBQyxDQUFDLEdBQUcsVUFBVSxHQUFHLEVBQUUsQ0FBQTtRQUN0QyxJQUFJLENBQUMsWUFBWSxHQUFHLEVBQUUsQ0FB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UFZLENBQUMsVUFBbUI7UUFDNUIsSUFBSSxDQUFDLEtBQUssQ0FBQyxNQUFNLEVBQUMsVUFBVSxDQUFDLENBQUE7SUFDakMsQ0FBQztJQUVEOztzRUFFa0U7SUFFMUQsV0FBVztJQUVuQixDQUFDO0lBRUQ7O09BRUc7SUFDSyxTQUFTLENBQUMsWUFBWTtRQUMxQixFQUFFLENBQUMsQ0FBQyxJQUFJLENBQUMsUUFBUSxDQUFDO1lBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxZQUFZLENBQUMsQ0FBQTtJQUMvQyxDQUFDO0lBRUQ7O09BRUc7SUFDSyxLQUFLLENBQUMsWUFBb0IsRUFBQyxVQUFtQjtRQUNsRCxFQUFFLENBQUMsQ0FBQyxZQUFZLEtBQUssTUFBTSxDQUFDLENBQUMsQ0FBQztZQUMxQixJQUFJLENBQUMsT0FBTyxDQUFDLFdBQVcsQ0FBQyxVQUFVLENBQUMsQ0FBQSxDQUFDLG9DQUFvQztRQUM3RSxDQUFDO1FBQUMsSUFBSSxDQUFDLEVBQUUsQ0FBQyxDQUFDLFlBQVksS0FBSyxJQUFJLENBQUMsQ0FBQyxDQUFDO1lBQy9CLElBQUksQ0FBQyxPQUFPLENBQUMsVUFBVSxDQUFDLFVBQVUsQ0FBQyxDQUFBO1FBQ3ZDLENBQUM7UUFBQyxJQUFJLENBQUMsQ0FBQztZQUNKLE1BQU0sSUFBSSxLQUFLLENBQUMscURBQXFELENBQUMsQ0FBQTtRQUMxRSxDQUFDO0lBQ0wsQ0FBQztJQUFBLENBQUM7Q0FDTDtBQTlGRCxrQ0E4RkMifQ==

View File

@ -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;
}

View File

@ -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,eyJ2ZXJzaW9uI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QUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxDQUFDLENBQUM7WUFDZixJQUFJLFFBQVEsR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxVQUFVLEVBQUMsWUFBWSxHQUFHLE1BQU0sQ0FBQyxDQUFBO1lBQ2xFLE9BQU8sQ0FBQyxTQUFTLENBQUMsTUFBTSxDQUFDLFFBQVEsQ0FBQyxJQUFJLENBQUMsT0FBTyxFQUFDLFFBQVEsQ0FBQyxDQUFBO1lBQ3hELE9BQU8sQ0FBQyxPQUFPLENBQUMsS0FBSyxDQUFDLEdBQUcsRUFBQyxRQUFRLENBQUMsQ0FBQTtRQUN2QyxDQUFDO0lBQ0wsQ0FBQztDQUNKO0FBOUZELHdCQThGQyJ9

View File

@ -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 };

View File

@ -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
View 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"
}
}
}

View File

@ -1,4 +0,0 @@
{
"mode":"default",
"coverageTreshold":50
}

12983
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,16 @@
{
"name": "smartssh",
"version": "1.2.1",
"name": "@pushrocks/smartssh",
"version": "1.2.7",
"private": false,
"description": "setups SSH quickly and in a painless manner",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"type": "module",
"scripts": {
"test": "(npmts)"
"test": "(tstest test/)",
"testDocker": "tsdocker",
"build": "(tsbuild --allowimplicitany)",
"buildDocs": "tsdoc"
},
"repository": {
"type": "git",
@ -23,25 +28,36 @@
},
"homepage": "https://gitlab.com/pushrocks/smartssh#readme",
"dependencies": {
"@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"
"@pushrocks/smartfile": "^10.0.5",
"@pushrocks/smartpath": "^5.0.5",
"@pushrocks/smartpromise": "^3.0.2",
"@pushrocks/smartshell": "^2.0.23",
"@pushrocks/smartstring": "^4.0.5",
"@types/fs-extra": "^9.0.13",
"@types/minimatch": "^5.1.2",
"fs-extra": "^10.1.0",
"minimatch": "^5.1.0"
},
"devDependencies": {
"@types/should": "^8.1.30",
"npmts-g": "^5.2.8",
"should": "^11.1.1",
"typings-test": "^1.0.3"
}
"@gitzone/tsbuild": "^2.1.11",
"@gitzone/tsrun": "^1.2.6",
"@gitzone/tstest": "^1.0.24",
"@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

File diff suppressed because it is too large Load Diff

68
readme.md Normal file
View File

@ -0,0 +1,68 @@
# @pushrocks/smartssh
setups SSH quickly and in a painless manner
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartssh)
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartssh)
* [github.com (source mirror)](https://github.com/pushrocks/smartssh)
* [docs (typedoc)](https://pushrocks.gitlab.io/smartssh/)
## Status for master
Status Category | Status Badge
-- | --
GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/smartssh/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smartssh/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/smartssh)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/smartssh)](https://lossless.cloud)
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@pushrocks/smartssh)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/smartssh)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/smartssh)](https://lossless.cloud)
Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud)
## 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
```
## Contribution
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
For further information read the linked docs at the top of this readme.
> MIT licensed | **&copy;** [Lossless GmbH](https://lossless.gmbh)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)

1
test/temp/bitbucket.org Normal file
View File

@ -0,0 +1 @@
somePrivateKey

View File

@ -0,0 +1 @@
somePublicKey

15
test/temp/config Normal file
View 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
View File

@ -0,0 +1 @@
someExamplePrivateKey

View File

@ -0,0 +1 @@
someExamplePublicKey

1
test/temp/github.com Normal file
View File

@ -0,0 +1 @@
someGitHubPrivateKey

1
test/temp/github.com.pub Normal file
View File

@ -0,0 +1 @@
someGitHubPublicKey

1
test/temp/gitlab.com Normal file
View File

@ -0,0 +1 @@
somePrivateKey

1
test/temp/gitlab.com.pub Normal file
View File

@ -0,0 +1 @@
somePublicKey

1
test/test.d.ts vendored
View File

@ -1 +0,0 @@
import 'typings-test';

View File

@ -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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUNyQixpQ0FBZ0M7QUFDaEMsMENBQTBDO0FBQzFDLDZCQUE2QjtBQUM3QixRQUFRLENBQUMsVUFBVSxFQUF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0FBQyxLQUFLLENBQUMsWUFBWSxDQUFDLENBQUE7UUFDL0QsQ0FBQyxDQUFDLENBQUE7UUFDRixFQUFFLENBQUMseUJBQXlCLEVBQUM7WUFDekIsZUFBZSxDQUFDLFdBQVcsRUFBRSxDQUFBO1FBQ2pDLENBQUMsQ0FBQyxDQUFBO0lBQ04sQ0FBQyxDQUFDLENBQUE7QUFDTixDQUFDLENBQUMsQ0FBQSJ9

View File

@ -1,75 +1,84 @@
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'))
})
import { expect, tap } from '@pushrocks/tapbundle';
import * as smartssh from '../ts/index.js';
import * as path from 'path';
let testSshInstance: smartssh.SshInstance;
let testSshKey: smartssh.SshKey;
tap.test('should create a valid SshKey object', async () => {
testSshKey = new smartssh.SshKey({
host: 'example.com',
private: 'someExamplePrivateKey',
public: 'someExamplePublicKey',
});
expect(testSshKey).toBeInstanceOf(smartssh.SshKey);
});
tap.test('.type should be a valid type', async () => {
expect(testSshKey.type).toEqual('duplex');
});
tap.test('.publicKey should be public key', async () => {
expect(testSshKey.pubKey).toEqual('someExamplePublicKey');
});
tap.test('.privateKey should be private key', async () => {
expect(testSshKey.privKey).toEqual('someExamplePrivateKey');
});
tap.test('.publicKeyBase64 should be public key base 64 encoded', async () => {
// tslint:disable-next-line:no-unused-expression
testSshKey.pubKeyBase64;
});
tap.test('.store() should store the file to disk', async () => {
testSshKey.store(path.join(process.cwd(), 'test/temp'));
});
// SSH INstance
tap.test("'new' keyword should create a new SshInstance object from class", async () => {
testSshInstance = new smartssh.SshInstance({
sshDirPath: path.join(process.cwd(), 'test/temp/'),
});
expect(testSshInstance).toBeInstanceOf(smartssh.SshInstance);
});
tap.test('.addKey() should accept a new SshKey object', async () => {
testSshInstance.addKey(
new smartssh.SshKey({
public: 'somePublicKey',
private: 'somePrivateKey',
host: 'gitlab.com',
})
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()
})
);
testSshInstance.addKey(
new smartssh.SshKey({
public: 'somePublicKey',
private: 'somePrivateKey',
host: 'bitbucket.org',
})
})
);
testSshInstance.addKey(
new smartssh.SshKey({
public: 'someGitHubPublicKey',
private: 'someGitHubPrivateKey',
host: 'github.com',
})
);
});
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
View File

@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@pushrocks/smartssh',
version: '1.2.7',
description: 'setups SSH quickly and in a painless manner'
}

View File

@ -1,7 +1,6 @@
import 'typings-global'
import * as plugins from './smartssh.plugins'
import * as plugins from './smartssh.plugins.js';
export {SshInstance} from './smartssh.classes.sshinstance'
export {SshKey} from './smartssh.classes.sshkey'
export {SshDir} from './smartssh.classes.sshdir'
export {SshConfig} from './smartssh.classes.sshconfig'
export { SshInstance } from './smartssh.classes.sshinstance.js';
export { SshKey } from './smartssh.classes.sshkey.js';
export { SshDir } from './smartssh.classes.sshdir.js';
export { SshConfig } from './smartssh.classes.sshconfig.js';

View File

@ -1,8 +1,7 @@
import 'typings-global'
import * as plugins from './smartssh.plugins'
import {SshKey} from './smartssh.classes.sshkey'
import * as plugins from './smartssh.plugins.js';
import { SshKey } from './smartssh.classes.sshkey.js';
export let sshKeyArrayFromDir = function(dirArg: string): SshKey[]{
let sshKeyArray = [] // TODO
return sshKeyArray
}
export let sshKeyArrayFromDir = function (dirArg: string): SshKey[] {
let sshKeyArray = []; // TODO
return sshKeyArray;
};

View File

@ -1,54 +1,60 @@
import 'typings-global'
import * as plugins from './smartssh.plugins'
import * as helpers from './smartssh.classes.helpers'
import {SshKey} from './smartssh.classes.sshkey'
import * as plugins from './smartssh.plugins.js';
import * as helpers from './smartssh.classes.helpers.js';
import { SshKey } from './smartssh.classes.sshkey.js';
export class SshConfig {
private _sshKeyArray: SshKey[]
constructor(sshKeyArrayArg: SshKey[]) {
this._sshKeyArray = sshKeyArrayArg
}
private _sshKeyArray: SshKey[];
constructor(sshKeyArrayArg: SshKey[]) {
this._sshKeyArray = sshKeyArrayArg;
}
/**
* stores a config file
*/
store(dirPathArg: string) {
let done = plugins.q.defer()
let configArray: configObject[] = []
let configString
for (let key in this._sshKeyArray) {
let sshKey = this._sshKeyArray[key]
if (sshKey.host) {
configString = 'Host ' + sshKey.host + '\n' +
' HostName ' + sshKey.host + '\n' +
' IdentityFile ~/.ssh/' + sshKey.host + '\n' +
' 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
/**
* stores a config file
*/
store(dirPathArg: string) {
let done = plugins.smartpromise.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,
});
}
read(dirPathArg) {
let done = plugins.q.defer()
let configArray: configObject[]
plugins.smartfile.fs.toStringSync(plugins.path.join(dirPathArg,'config'))
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.smartpromise.defer();
let configArray: configObject[];
plugins.smartfile.fs.toStringSync(plugins.path.join(dirPathArg, 'config'));
return done.promise
}
};
return done.promise;
}
}
export interface configObject {
configString: string
authorized: boolean
sshKey: SshKey
};
configString: string;
authorized: boolean;
sshKey: SshKey;
}

View File

@ -1,38 +1,47 @@
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)
import * as plugins from './smartssh.plugins.js';
import * as helpers from './smartssh.classes.helpers.js';
import { SshInstance } from './smartssh.classes.sshinstance.js';
import { SshKey } from './smartssh.classes.sshkey.js';
import { SshConfig } from './smartssh.classes.sshconfig.js';
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);
}
/**
* TODO: implement reading of directories
*/
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);
}
}

View File

@ -1,103 +1,102 @@
import 'typings-global'
import * as plugins from './smartssh.plugins'
import * as helpers from './smartssh.classes.helpers'
import * as plugins from './smartssh.plugins.js';
import * as helpers from './smartssh.classes.helpers.js';
import {SshDir} from './smartssh.classes.sshdir'
import {SshConfig} from './smartssh.classes.sshconfig'
import {SshKey} from './smartssh.classes.sshkey'
import { SshDir } from './smartssh.classes.sshdir.js';
import { SshConfig } from './smartssh.classes.sshconfig.js';
import { SshKey } from './smartssh.classes.sshkey.js';
/**
* SshInstance is the main class dealing with ssh management
*/
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
};
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')
};
// 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)
// non altering methods
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;
}
/**
* read ab SshInstance from disk
*/
readFromDisk(dirPathArg?: string) {
this._sync('from',dirPathArg)
// 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 ========================
================================================================*/
/**
* method to invoke SshInstance _sync automatically when sshSync is true
*/
private _syncAuto(directionArg: 'from' | 'to') {
if (this._sshSync) {
// if auto sync is not enabled, do nothing
this._sync(directionArg);
}
}
/* ===============================================================
========================= Private Methods ========================
================================================================*/
private _makeConfig () {
/**
* private method to sync SshInstance
*/
private _sync(directionArg: 'from' | 'to', dirPathArg?: string) {
if (directionArg === 'from') {
this._sshDir.readFromDir(dirPathArg); // call sync method of sshDir class;
} else if (directionArg === 'to') {
this._sshDir.writeToDir(dirPathArg);
}
/**
* 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'")
}
};
}
}

View File

@ -1,99 +1,106 @@
import 'typings-global'
import * as plugins from './smartssh.plugins'
import * as helpers from './smartssh.classes.helpers'
import * as plugins from './smartssh.plugins.js';
import * as helpers from './smartssh.classes.helpers.js';
export class SshKey {
private _privKey: string
private _pubKey: string
private _hostVar: string
private _authorized: boolean
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
};
private _smarthshellInstance = new plugins.shelljs.Smartshell({
executor: 'bash',
});
// this.host
get host(){
return this._hostVar
};
set host(hostArg: string){
this._hostVar = hostArg
};
/**
* 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.privKey
get privKey(){
return this._privKey
};
set privKey(privateKeyArg: string){
this._privKey = privateKeyArg
};
// this.host
get host() {
return this._hostVar;
}
set host(hostArg: string) {
this._hostVar = hostArg;
}
// this.privKeyBase64
get privKeyBase64(){
return plugins.smartstring.base64.encode(this._privKey)
}
set privKeyBase64(privateKeyArg: string) {
this._privKey = plugins.smartstring.base64.decode(privateKeyArg)
}
// this.privKey
get privKey() {
return this._privKey;
}
set privKey(privateKeyArg: string) {
this._privKey = privateKeyArg;
}
// this.pubKey
get pubKey(){
return this._pubKey
}
set pubKey(publicKeyArg: string){
this._pubKey = publicKeyArg
};
// this.privKeyBase64
get privKeyBase64() {
return plugins.smartstring.base64.encode(this._privKey);
}
set privKeyBase64(privateKeyArg: string) {
this._privKey = plugins.smartstring.base64.decode(privateKeyArg);
}
// this.pubKeyBase64
get pubKeyBase64(){
return plugins.smartstring.base64.encode(this._pubKey)
}
set pubKeyBase64(publicKeyArg: string) {
this._pubKey = plugins.smartstring.base64.decode(publicKeyArg)
}
// this.pubKey
get pubKey() {
return this._pubKey;
}
set pubKey(publicKeyArg: string) {
this._pubKey = 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.')
}
// this.pubKeyBase64
get pubKeyBase64() {
return plugins.smartstring.base64.encode(this._pubKey);
}
set pubKeyBase64(publicKeyArg: string) {
this._pubKey = plugins.smartstring.base64.decode(publicKeyArg);
}
// methods
read(filePathArg) {
get authorized() {
return this._authorized;
}
set authorized(authorizedArg: boolean) {
this._authorized = authorizedArg;
}
/**
* returns wether there is a private, a public or both keys
*/
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 autocomputed.');
}
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)
}
// methods
read(filePathArg) {}
async 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);
await this._smarthshellInstance.exec(`chmod 0600 ${filePath}`);
}
if (this._pubKey) {
let filePath = plugins.path.join(dirPathArg, fileNameBase + '.pub');
plugins.smartfile.memory.toFsSync(this._pubKey, filePath);
await this._smarthshellInstance.exec(`chmod 0600 ${filePath}`);
}
}
}

View File

@ -1,22 +1,10 @@
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'
import * as fs from 'fs-extra';
import * as minimatch from 'minimatch';
import * as path from 'path';
import * as smartpromise from '@pushrocks/smartpromise';
import * as shelljs from '@pushrocks/smartshell';
import * as smartfile from '@pushrocks/smartfile';
import * as smartpath from '@pushrocks/smartpath';
import * as smartstring from '@pushrocks/smartstring';
export {
beautylog,
fs,
minimatch,
path,
q,
shelljs,
smartfile,
smartpath,
smartstring
}
export { fs, minimatch, path, smartpromise, shelljs, smartfile, smartpath, smartstring };

10
tsconfig.json Normal file
View File

@ -0,0 +1,10 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "nodenext",
"esModuleInterop": true
}
}

View File

@ -1,3 +0,0 @@
{
"extends": "tslint-config-standard"
}