Compare commits
63 Commits
Author | SHA1 | Date | |
---|---|---|---|
9fc03e8504 | |||
9a32b156fe | |||
a319e54d60 | |||
6a2577cde6 | |||
1f1bf7c21f | |||
c652d0bf07 | |||
eccc6294a8 | |||
f8a75a8d42 | |||
d5c2bc1b53 | |||
d577a82a7b | |||
f0b52c8da7 | |||
4cb6aa03e6 | |||
8b85b6c8bc | |||
c032ff69d0 | |||
0454eef45f | |||
def368f8ab | |||
6853fa28b6 | |||
56318f28cf | |||
32b26f21cd | |||
32c2698af7 | |||
27237f14c7 | |||
8f29f234f1 | |||
5091625953 | |||
f74b3a51b0 | |||
062f3ad060 | |||
ecd0fd8fad | |||
742bf694e4 | |||
38165f11db | |||
ef2b31b4b2 | |||
5b1f800067 | |||
6339a3ed9b | |||
bf27aaf167 | |||
9bc3aea59c | |||
f5ff302d4d | |||
cac8203bf5 | |||
e4532271cc | |||
faf6c91199 | |||
d0009e7a9c | |||
da76df2c3e | |||
a43976110a | |||
c3ee35a699 | |||
a0ce759552 | |||
201d5cc6d7 | |||
e5bdfff743 | |||
967c9fd9d1 | |||
35da2f0b73 | |||
5e991a4e4f | |||
0f75f5238c | |||
e8f3047ac0 | |||
812d28ee3d | |||
fa301eea71 | |||
48ccf317d6 | |||
9b3af8a50a | |||
78aa36c2be | |||
09d96fd94c | |||
f4f60a685d | |||
904129706c | |||
9a96bbd266 | |||
39abfd760b | |||
1b30aa428e | |||
41613c0b93 | |||
2d14617b13 | |||
3106945b47 |
66
.gitea/workflows/default_nottags.yaml
Normal file
66
.gitea/workflows/default_nottags.yaml
Normal file
@ -0,0 +1,66 @@
|
||||
name: Default (not tags)
|
||||
|
||||
on:
|
||||
push:
|
||||
tags-ignore:
|
||||
- '**'
|
||||
|
||||
env:
|
||||
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
|
||||
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
|
||||
|
||||
jobs:
|
||||
security:
|
||||
runs-on: ubuntu-latest
|
||||
continue-on-error: true
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install pnpm and npmci
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @shipzone/npmci
|
||||
|
||||
- name: Run npm prepare
|
||||
run: npmci npm prepare
|
||||
|
||||
- name: Audit production dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --prod
|
||||
continue-on-error: true
|
||||
|
||||
- name: Audit development dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --dev
|
||||
continue-on-error: true
|
||||
|
||||
test:
|
||||
if: ${{ always() }}
|
||||
needs: security
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Test stable
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm test
|
||||
|
||||
- name: Test build
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm build
|
124
.gitea/workflows/default_tags.yaml
Normal file
124
.gitea/workflows/default_tags.yaml
Normal file
@ -0,0 +1,124 @@
|
||||
name: Default (tags)
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
env:
|
||||
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
|
||||
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
|
||||
|
||||
jobs:
|
||||
security:
|
||||
runs-on: ubuntu-latest
|
||||
continue-on-error: true
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @shipzone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Audit production dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --prod
|
||||
continue-on-error: true
|
||||
|
||||
- name: Audit development dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --dev
|
||||
continue-on-error: true
|
||||
|
||||
test:
|
||||
if: ${{ always() }}
|
||||
needs: security
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @shipzone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Test stable
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm test
|
||||
|
||||
- name: Test build
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm build
|
||||
|
||||
release:
|
||||
needs: test
|
||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @shipzone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Release
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm publish
|
||||
|
||||
metadata:
|
||||
needs: test
|
||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
continue-on-error: true
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @shipzone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Code quality
|
||||
run: |
|
||||
npmci command npm install -g typescript
|
||||
npmci npm install
|
||||
|
||||
- name: Trigger
|
||||
run: npmci trigger
|
||||
|
||||
- name: Build docs and upload artifacts
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
pnpm install -g @gitzone/tsdoc
|
||||
npmci command tsdoc
|
||||
continue-on-error: true
|
25
.gitignore
vendored
25
.gitignore
vendored
@ -1,7 +1,20 @@
|
||||
.idea/
|
||||
node_modules/
|
||||
.nogit/
|
||||
|
||||
# artifacts
|
||||
coverage/
|
||||
docs/
|
||||
ts/typings/
|
||||
ts/*.js
|
||||
ts/*.js.map
|
||||
public/
|
||||
pages/
|
||||
|
||||
# installs
|
||||
node_modules/
|
||||
|
||||
# caches
|
||||
.yarn/
|
||||
.cache/
|
||||
.rpt2_cache
|
||||
|
||||
# builds
|
||||
dist/
|
||||
dist_*/
|
||||
|
||||
# custom
|
@ -1,43 +0,0 @@
|
||||
image: hosttoday/ht-docker-node:latest
|
||||
|
||||
stages:
|
||||
- test
|
||||
- release
|
||||
- page
|
||||
|
||||
testLTS:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test lts
|
||||
tags:
|
||||
- docker
|
||||
|
||||
testSTABLE:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test stable
|
||||
tags:
|
||||
- docker
|
||||
|
||||
release:
|
||||
stage: release
|
||||
script:
|
||||
- npmci publish
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
|
||||
pages:
|
||||
stage: page
|
||||
script:
|
||||
- npmci test lts
|
||||
- mkdir .public
|
||||
- cp -r test/assets/docs/ .public
|
||||
- cp -r test/assets/coverage/ .public
|
||||
- mv .public public
|
||||
artifacts:
|
||||
paths:
|
||||
- public
|
||||
only:
|
||||
- master
|
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"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
2
LICENSE
2
LICENSE
@ -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
|
||||
|
34
README.md
34
README.md
@ -1,34 +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 { Ssh } from "./smartssh.classes.ssh";
|
||||
export { SshKey } from "./smartssh.classes.sshkey";
|
||||
export { SshDir } from "./smartssh.classes.sshdir";
|
||||
export { SshConfig } from "./smartssh.classes.sshconfig";
|
12
dist/index.js
vendored
12
dist/index.js
vendored
@ -1,12 +0,0 @@
|
||||
"use strict";
|
||||
require("typings-global");
|
||||
var smartssh_classes_ssh_1 = require("./smartssh.classes.ssh");
|
||||
exports.Ssh = smartssh_classes_ssh_1.Ssh;
|
||||
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;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUNQLENBQUMsQ0FEc0I7QUFHdkIscUNBQWtCLHdCQUF3QixDQUFDO0FBQW5DLHlDQUFtQztBQUMzQyx3Q0FBcUIsMkJBQTJCLENBQUM7QUFBekMsa0RBQXlDO0FBQ2pELHdDQUFxQiwyQkFBMkIsQ0FBQztBQUF6QyxrREFBeUM7QUFDakQsMkNBQXdCLDhCQUE4QixDQUFDO0FBQS9DLDJEQUErQyIsImZpbGUiOiJpbmRleC5qcyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBcInR5cGluZ3MtZ2xvYmFsXCJcclxuaW1wb3J0ICogYXMgcGx1Z2lucyBmcm9tIFwiLi9zbWFydHNzaC5wbHVnaW5zXCI7XHJcblxyXG5leHBvcnQge1NzaH0gZnJvbSBcIi4vc21hcnRzc2guY2xhc3Nlcy5zc2hcIjtcclxuZXhwb3J0IHtTc2hLZXl9IGZyb20gXCIuL3NtYXJ0c3NoLmNsYXNzZXMuc3Noa2V5XCI7XHJcbmV4cG9ydCB7U3NoRGlyfSBmcm9tIFwiLi9zbWFydHNzaC5jbGFzc2VzLnNzaGRpclwiO1xyXG5leHBvcnQge1NzaENvbmZpZ30gZnJvbSBcIi4vc21hcnRzc2guY2xhc3Nlcy5zc2hjb25maWdcIjsiXX0=
|
4
dist/smartssh.classes.helpers.d.ts
vendored
4
dist/smartssh.classes.helpers.d.ts
vendored
@ -1,4 +0,0 @@
|
||||
import "typings-global";
|
||||
import { SshKey } from "./smartssh.classes.sshkey";
|
||||
export declare let sshKeyArrayFromDir: (dirArg: string) => SshKey[];
|
||||
export declare let getKeyIndex: (hostArg: string) => number;
|
11
dist/smartssh.classes.helpers.js
vendored
11
dist/smartssh.classes.helpers.js
vendored
@ -1,11 +0,0 @@
|
||||
"use strict";
|
||||
require("typings-global");
|
||||
exports.sshKeyArrayFromDir = function (dirArg) {
|
||||
var sshKeyArray = []; //TODO
|
||||
return sshKeyArray;
|
||||
};
|
||||
exports.getKeyIndex = function (hostArg) {
|
||||
return 0; //TODO
|
||||
};
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3NoLmNsYXNzZXMuaGVscGVycy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsUUFBTyxnQkFDUCxDQUFDLENBRHNCO0FBSVosMEJBQWtCLEdBQUcsVUFBUyxNQUFhO0lBQ2xELElBQUksV0FBVyxHQUFHLEVBQUUsQ0FBQyxDQUFDLE1BQU07SUFDNUIsTUFBTSxDQUFDLFdBQVcsQ0FBQztBQUN2QixDQUFDLENBQUE7QUFFVSxtQkFBVyxHQUFHLFVBQVMsT0FBYztJQUM1QyxNQUFNLENBQUMsQ0FBQyxDQUFDLENBQUMsT0FBTztBQUNyQixDQUFDLENBQUEiLCJmaWxlIjoic21hcnRzc2guY2xhc3Nlcy5oZWxwZXJzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFwidHlwaW5ncy1nbG9iYWxcIlxyXG5pbXBvcnQgKiBhcyBwbHVnaW5zIGZyb20gXCIuL3NtYXJ0c3NoLnBsdWdpbnNcIjtcclxuaW1wb3J0IHtTc2hLZXl9IGZyb20gXCIuL3NtYXJ0c3NoLmNsYXNzZXMuc3Noa2V5XCI7XHJcblxyXG5leHBvcnQgbGV0IHNzaEtleUFycmF5RnJvbURpciA9IGZ1bmN0aW9uKGRpckFyZzpzdHJpbmcpOlNzaEtleVtde1xyXG4gICAgbGV0IHNzaEtleUFycmF5ID0gW107IC8vVE9ET1xyXG4gICAgcmV0dXJuIHNzaEtleUFycmF5O1xyXG59XHJcblxyXG5leHBvcnQgbGV0IGdldEtleUluZGV4ID0gZnVuY3Rpb24oaG9zdEFyZzpzdHJpbmcpe1xyXG4gICAgcmV0dXJuIDA7IC8vVE9ETyBcclxufSJdfQ==
|
17
dist/smartssh.classes.ssh.d.ts
vendored
17
dist/smartssh.classes.ssh.d.ts
vendored
@ -1,17 +0,0 @@
|
||||
import "typings-global";
|
||||
import { SshKey } from "./smartssh.classes.sshkey";
|
||||
export declare class Ssh {
|
||||
private sshConfig;
|
||||
private sshDir;
|
||||
private sshKeys;
|
||||
private sshSync;
|
||||
constructor(optionsArg?: {
|
||||
sshDir?: string;
|
||||
sshSync?: boolean;
|
||||
});
|
||||
addKey(sshKeyArg: SshKey): void;
|
||||
getKey(hostArg: string): SshKey;
|
||||
removeKey(sshKeyArg: SshKey): void;
|
||||
replaceKey(sshKeyOldArg: SshKey, sshKeyNewArg: SshKey): void;
|
||||
sync(): void;
|
||||
}
|
52
dist/smartssh.classes.ssh.js
vendored
52
dist/smartssh.classes.ssh.js
vendored
@ -1,52 +0,0 @@
|
||||
"use strict";
|
||||
require("typings-global");
|
||||
var helpers = require("./smartssh.classes.helpers");
|
||||
var smartssh_classes_sshdir_1 = require("./smartssh.classes.sshdir");
|
||||
var Ssh = (function () {
|
||||
function Ssh(optionsArg) {
|
||||
if (optionsArg === void 0) { optionsArg = {}; }
|
||||
this.sshDir = new smartssh_classes_sshdir_1.SshDir(optionsArg.sshDir);
|
||||
this.sshKeys = this.sshDir.getKeys();
|
||||
this.sshSync = optionsArg.sshSync;
|
||||
}
|
||||
;
|
||||
Ssh.prototype.addKey = function (sshKeyArg) {
|
||||
this.sshKeys.push(sshKeyArg);
|
||||
this.sync();
|
||||
};
|
||||
;
|
||||
Ssh.prototype.getKey = function (hostArg) {
|
||||
var filteredArray = this.sshKeys.filter(function (keyArg) {
|
||||
return (keyArg.host == hostArg);
|
||||
});
|
||||
if (filteredArray.length > 0) {
|
||||
return filteredArray[0];
|
||||
}
|
||||
else {
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
;
|
||||
Ssh.prototype.removeKey = function (sshKeyArg) {
|
||||
var keyIndex = helpers.getKeyIndex(sshKeyArg.host);
|
||||
this.sshKeys.splice(keyIndex, 1);
|
||||
this.sync();
|
||||
};
|
||||
;
|
||||
Ssh.prototype.replaceKey = function (sshKeyOldArg, sshKeyNewArg) {
|
||||
var keyIndex = helpers.getKeyIndex(sshKeyOldArg.host);
|
||||
this.sshKeys.splice(keyIndex, 1, sshKeyNewArg);
|
||||
this.sync();
|
||||
};
|
||||
;
|
||||
Ssh.prototype.sync = function () {
|
||||
if (this.sshSync) {
|
||||
this.sshDir.sync(this.sshConfig, this.sshKeys); // call sync method of sshDir class;
|
||||
}
|
||||
};
|
||||
;
|
||||
return Ssh;
|
||||
}());
|
||||
exports.Ssh = Ssh;
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3NoLmNsYXNzZXMuc3NoLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUNQLENBQUMsQ0FEc0I7QUFFdkIsSUFBWSxPQUFPLFdBQU0sNEJBQTRCLENBQUMsQ0FBQTtBQUV0RCx3Q0FBcUIsMkJBQTJCLENBQUMsQ0FBQTtBQUlqRDtJQUtJLGFBQVksVUFBK0M7UUFBL0MsMEJBQStDLEdBQS9DLGVBQStDO1FBQ3ZELElBQUksQ0FBQyxNQUFNLEdBQUcsSUFBSSxnQ0FBTSxDQUFDLFVBQVUsQ0FBQyxNQUFNLENBQUMsQ0FBQztRQUM1QyxJQUFJLENBQUMsT0FBTyxHQUFHLElBQUksQ0FBQyxNQUFNLENBQUMsT0FBTyxFQUFFLENBQUM7UUFDckMsSUFBSSxDQUFDLE9BQU8sR0FBRyxVQUFVLENBQUMsT0FBTyxDQUFDO0lBQ3RDLENBQUM7O0lBQ0Qsb0JBQU0sR0FBTixVQUFPLFNBQWdCO1FBQ25CLElBQUksQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxDQUFDO1FBQzdCLElBQUksQ0FBQyxJQUFJLEVBQUUsQ0FBQztJQUNoQixDQUFDOztJQUNELG9CQUFNLEdBQU4sVUFBTyxPQUFjO1FBQ2pCLElBQUksYUFBYSxHQUFHLElBQUksQ0FBQyxPQUFPLENBQUMsTUFBTSxDQUFDLFVBQVMsTUFBTTtZQUNuRCxNQUFNLENBQUMsQ0FBQyxNQUFNLENBQUMsSUFBSSxJQUFJLE9BQU8sQ0FBQyxDQUFDO1FBQ3BDLENBQUMsQ0FBQyxDQUFDO1FBQ0gsRUFBRSxDQUFBLENBQUMsYUFBYSxDQUFDLE1BQU0sR0FBRyxDQUFDLENBQUMsQ0FBQSxDQUFDO1lBQ3pCLE1BQU0sQ0FBQyxhQUFhLENBQUMsQ0FBQyxDQUFDLENBQUM7UUFDNUIsQ0FBQztRQUFDLElBQUksQ0FBQyxDQUFDO1lBQ0osTUFBTSxDQUFDLFNBQVMsQ0FBQztRQUNyQixDQUFDO0lBQ0wsQ0FBQzs7SUFDRCx1QkFBUyxHQUFULFVBQVUsU0FBZ0I7UUFDdEIsSUFBSSxRQUFRLEdBQUcsT0FBTyxDQUFDLFdBQVcsQ0FBQyxTQUFTLENBQUMsSUFBSSxDQUFDLENBQUM7UUFDbkQsSUFBSSxDQUFDLE9BQU8sQ0FBQyxNQUFNLENBQUMsUUFBUSxFQUFDLENBQUMsQ0FBQyxDQUFDO1FBQ2hDLElBQUksQ0FBQyxJQUFJLEVBQUUsQ0FBQztJQUNoQixDQUFDOztJQUNELHdCQUFVLEdBQVYsVUFBVyxZQUFtQixFQUFDLFlBQW1CO1FBQzlDLElBQUksUUFBUSxHQUFHLE9BQU8sQ0FBQyxXQUFXLENBQUMsWUFBWSxDQUFDLElBQUksQ0FBQyxDQUFDO1FBQ3RELElBQUksQ0FBQyxPQUFPLENBQUMsTUFBTSxDQUFDLFFBQVEsRUFBQyxDQUFDLEVBQUMsWUFBWSxDQUFDLENBQUM7UUFDN0MsSUFBSSxDQUFDLElBQUksRUFBRSxDQUFDO0lBQ2hCLENBQUM7O0lBQ0Qsa0JBQUksR0FBSjtRQUNJLEVBQUUsQ0FBQSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUMsQ0FBQSxDQUFDO1lBQ2IsSUFBSSxDQUFDLE1BQU0sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLFNBQVMsRUFBQyxJQUFJLENBQUMsT0FBTyxDQUFDLENBQUMsQ0FBQyxvQ0FBb0M7UUFDdkYsQ0FBQztJQUNMLENBQUM7O0lBQ0wsVUFBQztBQUFELENBdkNBLEFBdUNDLElBQUE7QUF2Q1ksV0FBRyxNQXVDZixDQUFBIiwiZmlsZSI6InNtYXJ0c3NoLmNsYXNzZXMuc3NoLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFwidHlwaW5ncy1nbG9iYWxcIlxyXG5pbXBvcnQgKiBhcyBwbHVnaW5zIGZyb20gXCIuL3NtYXJ0c3NoLnBsdWdpbnNcIjtcclxuaW1wb3J0ICogYXMgaGVscGVycyBmcm9tIFwiLi9zbWFydHNzaC5jbGFzc2VzLmhlbHBlcnNcIjtcclxuXHJcbmltcG9ydCB7U3NoRGlyfSBmcm9tIFwiLi9zbWFydHNzaC5jbGFzc2VzLnNzaGRpclwiO1xyXG5pbXBvcnQge1NzaENvbmZpZ30gZnJvbSBcIi4vc21hcnRzc2guY2xhc3Nlcy5zc2hjb25maWdcIjtcclxuaW1wb3J0IHtTc2hLZXl9IGZyb20gXCIuL3NtYXJ0c3NoLmNsYXNzZXMuc3Noa2V5XCI7XHJcblxyXG5leHBvcnQgY2xhc3MgU3NoIHtcclxuICAgIHByaXZhdGUgc3NoQ29uZmlnOlNzaENvbmZpZzsgLy8gcG9pbnRzIHRvIHNzaENvbmZpZyBjbGFzcyBpbnN0YW5jZVxyXG4gICAgcHJpdmF0ZSBzc2hEaXI6U3NoRGlyOyAvLyBwb2ludHMgdG8gc3NoRGlyIGNsYXNzIGluc3RhbmNlLlxyXG4gICAgcHJpdmF0ZSBzc2hLZXlzOlNzaEtleVtdOyAvL2hvbGRzIGFsbCBzc2gga2V5c1xyXG4gICAgcHJpdmF0ZSBzc2hTeW5jOmJvb2xlYW47IC8vIGlmIHNldCB0byB0cnVlLCB0aGUgc3NoIGRpciB3aWxsIGJlIGtlcHQgaW4gc3luYyBhdXRvbWF0aWNhbGx5XHJcbiAgICBjb25zdHJ1Y3RvcihvcHRpb25zQXJnOntzc2hEaXI/OnN0cmluZyxzc2hTeW5jPzpib29sZWFufT17fSl7XHJcbiAgICAgICAgdGhpcy5zc2hEaXIgPSBuZXcgU3NoRGlyKG9wdGlvbnNBcmcuc3NoRGlyKTtcclxuICAgICAgICB0aGlzLnNzaEtleXMgPSB0aGlzLnNzaERpci5nZXRLZXlzKCk7XHJcbiAgICAgICAgdGhpcy5zc2hTeW5jID0gb3B0aW9uc0FyZy5zc2hTeW5jO1xyXG4gICAgfTtcclxuICAgIGFkZEtleShzc2hLZXlBcmc6U3NoS2V5KXtcclxuICAgICAgICB0aGlzLnNzaEtleXMucHVzaChzc2hLZXlBcmcpO1xyXG4gICAgICAgIHRoaXMuc3luYygpO1xyXG4gICAgfTtcclxuICAgIGdldEtleShob3N0QXJnOnN0cmluZyl7XHJcbiAgICAgICAgbGV0IGZpbHRlcmVkQXJyYXkgPSB0aGlzLnNzaEtleXMuZmlsdGVyKGZ1bmN0aW9uKGtleUFyZyl7XHJcbiAgICAgICAgICAgIHJldHVybiAoa2V5QXJnLmhvc3QgPT0gaG9zdEFyZyk7XHJcbiAgICAgICAgfSk7XHJcbiAgICAgICAgaWYoZmlsdGVyZWRBcnJheS5sZW5ndGggPiAwKXtcclxuICAgICAgICAgICAgcmV0dXJuIGZpbHRlcmVkQXJyYXlbMF07XHJcbiAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgcmV0dXJuIHVuZGVmaW5lZDtcclxuICAgICAgICB9XHJcbiAgICB9O1xyXG4gICAgcmVtb3ZlS2V5KHNzaEtleUFyZzpTc2hLZXkpe1xyXG4gICAgICAgIGxldCBrZXlJbmRleCA9IGhlbHBlcnMuZ2V0S2V5SW5kZXgoc3NoS2V5QXJnLmhvc3QpO1xyXG4gICAgICAgIHRoaXMuc3NoS2V5cy5zcGxpY2Uoa2V5SW5kZXgsMSk7XHJcbiAgICAgICAgdGhpcy5zeW5jKCk7XHJcbiAgICB9O1xyXG4gICAgcmVwbGFjZUtleShzc2hLZXlPbGRBcmc6U3NoS2V5LHNzaEtleU5ld0FyZzpTc2hLZXkpe1xyXG4gICAgICAgIGxldCBrZXlJbmRleCA9IGhlbHBlcnMuZ2V0S2V5SW5kZXgoc3NoS2V5T2xkQXJnLmhvc3QpO1xyXG4gICAgICAgIHRoaXMuc3NoS2V5cy5zcGxpY2Uoa2V5SW5kZXgsMSxzc2hLZXlOZXdBcmcpO1xyXG4gICAgICAgIHRoaXMuc3luYygpO1xyXG4gICAgfTtcclxuICAgIHN5bmMoKXtcclxuICAgICAgICBpZih0aGlzLnNzaFN5bmMpe1xyXG4gICAgICAgICAgICB0aGlzLnNzaERpci5zeW5jKHRoaXMuc3NoQ29uZmlnLHRoaXMuc3NoS2V5cyk7IC8vIGNhbGwgc3luYyBtZXRob2Qgb2Ygc3NoRGlyIGNsYXNzO1xyXG4gICAgICAgIH1cclxuICAgIH07XHJcbn1cclxuXHJcblxyXG4iXX0=
|
4
dist/smartssh.classes.sshconfig.d.ts
vendored
4
dist/smartssh.classes.sshconfig.d.ts
vendored
@ -1,4 +0,0 @@
|
||||
import "typings-global";
|
||||
export declare class SshConfig {
|
||||
constructor();
|
||||
}
|
10
dist/smartssh.classes.sshconfig.js
vendored
10
dist/smartssh.classes.sshconfig.js
vendored
@ -1,10 +0,0 @@
|
||||
"use strict";
|
||||
require("typings-global");
|
||||
var SshConfig = (function () {
|
||||
function SshConfig() {
|
||||
}
|
||||
return SshConfig;
|
||||
}());
|
||||
exports.SshConfig = SshConfig;
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3NoLmNsYXNzZXMuc3NoY29uZmlnLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFHeEI7SUFDSTtJQUVBLENBQUM7SUFDTCxnQkFBQztBQUFELENBSkEsQUFJQyxJQUFBO0FBSlksaUJBQVMsWUFJckIsQ0FBQSIsImZpbGUiOiJzbWFydHNzaC5jbGFzc2VzLnNzaGNvbmZpZy5qcyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBcInR5cGluZ3MtZ2xvYmFsXCI7XHJcbmltcG9ydCAqIGFzIHBsdWdpbnMgZnJvbSBcIi4vc21hcnRzc2gucGx1Z2luc1wiO1xyXG5pbXBvcnQgKiBhcyBoZWxwZXJzIGZyb20gXCIuL3NtYXJ0c3NoLmNsYXNzZXMuaGVscGVyc1wiO1xyXG5leHBvcnQgY2xhc3MgU3NoQ29uZmlnIHtcclxuICAgIGNvbnN0cnVjdG9yKCl7XHJcbiAgICAgICAgXHJcbiAgICB9XHJcbn0iXX0=
|
9
dist/smartssh.classes.sshdir.d.ts
vendored
9
dist/smartssh.classes.sshdir.d.ts
vendored
@ -1,9 +0,0 @@
|
||||
import "typings-global";
|
||||
import { SshKey } from "./smartssh.classes.sshkey";
|
||||
import { SshConfig } from "./smartssh.classes.sshconfig";
|
||||
export declare class SshDir {
|
||||
path: string;
|
||||
constructor(sshDirPathArg: string);
|
||||
sync(sshConfigArg: SshConfig, sshKeysArg: SshKey[]): void;
|
||||
getKeys(): SshKey[];
|
||||
}
|
18
dist/smartssh.classes.sshdir.js
vendored
18
dist/smartssh.classes.sshdir.js
vendored
@ -1,18 +0,0 @@
|
||||
"use strict";
|
||||
require("typings-global");
|
||||
var helpers = require("./smartssh.classes.helpers");
|
||||
var SshDir = (function () {
|
||||
function SshDir(sshDirPathArg) {
|
||||
this.path = sshDirPathArg;
|
||||
}
|
||||
SshDir.prototype.sync = function (sshConfigArg, sshKeysArg) {
|
||||
};
|
||||
;
|
||||
SshDir.prototype.getKeys = function () {
|
||||
return helpers.sshKeyArrayFromDir(this.path);
|
||||
};
|
||||
return SshDir;
|
||||
}());
|
||||
exports.SshDir = SshDir;
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3NoLmNsYXNzZXMuc3NoZGlyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFFeEIsSUFBWSxPQUFPLFdBQU0sNEJBQTRCLENBQUMsQ0FBQTtBQUd0RDtJQUVJLGdCQUFZLGFBQW9CO1FBQzVCLElBQUksQ0FBQyxJQUFJLEdBQUcsYUFBYSxDQUFDO0lBQzlCLENBQUM7SUFDRCxxQkFBSSxHQUFKLFVBQUssWUFBc0IsRUFBQyxVQUFtQjtJQUUvQyxDQUFDOztJQUNELHdCQUFPLEdBQVA7UUFDSSxNQUFNLENBQUMsT0FBTyxDQUFDLGtCQUFrQixDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQztJQUNqRCxDQUFDO0lBQ0wsYUFBQztBQUFELENBWEEsQUFXQyxJQUFBO0FBWFksY0FBTSxTQVdsQixDQUFBIiwiZmlsZSI6InNtYXJ0c3NoLmNsYXNzZXMuc3NoZGlyLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFwidHlwaW5ncy1nbG9iYWxcIjtcclxuaW1wb3J0ICogYXMgcGx1Z2lucyBmcm9tIFwiLi9zbWFydHNzaC5wbHVnaW5zXCI7XHJcbmltcG9ydCAqIGFzIGhlbHBlcnMgZnJvbSBcIi4vc21hcnRzc2guY2xhc3Nlcy5oZWxwZXJzXCI7XHJcbmltcG9ydCB7U3NoS2V5fSBmcm9tIFwiLi9zbWFydHNzaC5jbGFzc2VzLnNzaGtleVwiO1xyXG5pbXBvcnQge1NzaENvbmZpZ30gZnJvbSBcIi4vc21hcnRzc2guY2xhc3Nlcy5zc2hjb25maWdcIjtcclxuZXhwb3J0IGNsYXNzIFNzaERpciB7IC8vIHNzaERpciBjbGFzcyAtPiBOT1QgRVhQT1JURUQsIE9OTFkgRk9SIElOVEVSTkFMIFVTRVxyXG4gICAgcGF0aDpzdHJpbmc7XHJcbiAgICBjb25zdHJ1Y3Rvcihzc2hEaXJQYXRoQXJnOnN0cmluZyl7XHJcbiAgICAgICAgdGhpcy5wYXRoID0gc3NoRGlyUGF0aEFyZztcclxuICAgIH1cclxuICAgIHN5bmMoc3NoQ29uZmlnQXJnOlNzaENvbmZpZyxzc2hLZXlzQXJnOlNzaEtleVtdKXtcclxuICAgICAgICBcclxuICAgIH07XHJcbiAgICBnZXRLZXlzKCl7XHJcbiAgICAgICAgcmV0dXJuIGhlbHBlcnMuc3NoS2V5QXJyYXlGcm9tRGlyKHRoaXMucGF0aCk7XHJcbiAgICB9XHJcbn0iXX0=
|
18
dist/smartssh.classes.sshkey.d.ts
vendored
18
dist/smartssh.classes.sshkey.d.ts
vendored
@ -1,18 +0,0 @@
|
||||
import "typings-global";
|
||||
export declare class SshKey {
|
||||
private privKey;
|
||||
private pubKey;
|
||||
private hostVar;
|
||||
constructor(optionsArg?: {
|
||||
private?: string;
|
||||
public?: string;
|
||||
host?: string;
|
||||
});
|
||||
host: string;
|
||||
privateKey: string;
|
||||
privateKeyBase64: any;
|
||||
publicKey: string;
|
||||
publicKeyBase64: any;
|
||||
type: string;
|
||||
store(filePathArg?: string): void;
|
||||
}
|
98
dist/smartssh.classes.sshkey.js
vendored
98
dist/smartssh.classes.sshkey.js
vendored
File diff suppressed because one or more lines are too long
6
dist/smartssh.plugins.d.ts
vendored
6
dist/smartssh.plugins.d.ts
vendored
@ -1,6 +0,0 @@
|
||||
import "typings-global";
|
||||
export declare let beautylog: any;
|
||||
export declare let base64: any;
|
||||
export declare let fs: any;
|
||||
export declare let path: any;
|
||||
export declare let smartfile: any;
|
9
dist/smartssh.plugins.js
vendored
9
dist/smartssh.plugins.js
vendored
@ -1,9 +0,0 @@
|
||||
"use strict";
|
||||
require("typings-global");
|
||||
exports.beautylog = require("beautylog");
|
||||
exports.base64 = require("js-base64").Base64;
|
||||
exports.fs = require("fs-extra");
|
||||
exports.path = require("path");
|
||||
exports.smartfile = require("smartfile");
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3NoLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQ1AsQ0FBQyxDQURzQjtBQUNaLGlCQUFTLEdBQUcsT0FBTyxDQUFDLFdBQVcsQ0FBQyxDQUFDO0FBQ2pDLGNBQU0sR0FBRyxPQUFPLENBQUMsV0FBVyxDQUFDLENBQUMsTUFBTSxDQUFDO0FBQ3JDLFVBQUUsR0FBRyxPQUFPLENBQUMsVUFBVSxDQUFDLENBQUM7QUFDekIsWUFBSSxHQUFHLE9BQU8sQ0FBQyxNQUFNLENBQUMsQ0FBQztBQUN2QixpQkFBUyxHQUFHLE9BQU8sQ0FBQyxXQUFXLENBQUMsQ0FBQyIsImZpbGUiOiJzbWFydHNzaC5wbHVnaW5zLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFwidHlwaW5ncy1nbG9iYWxcIlxyXG5leHBvcnQgbGV0IGJlYXV0eWxvZyA9IHJlcXVpcmUoXCJiZWF1dHlsb2dcIik7XHJcbmV4cG9ydCBsZXQgYmFzZTY0ID0gcmVxdWlyZShcImpzLWJhc2U2NFwiKS5CYXNlNjQ7XHJcbmV4cG9ydCBsZXQgZnMgPSByZXF1aXJlKFwiZnMtZXh0cmFcIik7XHJcbmV4cG9ydCBsZXQgcGF0aCA9IHJlcXVpcmUoXCJwYXRoXCIpO1xyXG5leHBvcnQgbGV0IHNtYXJ0ZmlsZSA9IHJlcXVpcmUoXCJzbWFydGZpbGVcIik7Il19
|
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": "push.rocks",
|
||||
"gitrepo": "smartssh",
|
||||
"description": "setups SSH quickly and in a painless manner",
|
||||
"npmPackagename": "@push.rocks/smartssh",
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
{
|
||||
"mode":"default",
|
||||
"coverageTreshold":50
|
||||
}
|
58
package.json
58
package.json
@ -1,14 +1,20 @@
|
||||
{
|
||||
"name": "smartssh",
|
||||
"version": "1.0.2",
|
||||
"name": "@push.rocks/smartssh",
|
||||
"version": "2.0.1",
|
||||
"private": false,
|
||||
"description": "setups SSH quickly and in a painless manner",
|
||||
"main": "dist/index.js",
|
||||
"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",
|
||||
"url": "git+https://github.com/pushrocks/smartssh.git"
|
||||
"url": "git+https://gitlab.com/pushrocks/smartssh.git"
|
||||
},
|
||||
"keywords": [
|
||||
"SSH",
|
||||
@ -18,19 +24,39 @@
|
||||
"author": "Lossless GmbH",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/pushrocks/smartssh/issues"
|
||||
"url": "https://gitlab.com/pushrocks/smartssh/issues"
|
||||
},
|
||||
"homepage": "https://github.com/pushrocks/smartssh#readme",
|
||||
"homepage": "https://gitlab.com/pushrocks/smartssh#readme",
|
||||
"dependencies": {
|
||||
"beautylog": "^5.0.8",
|
||||
"fs-extra": "^0.30.0",
|
||||
"js-base64": "^2.1.9",
|
||||
"smartfile": "^3.0.10",
|
||||
"typings-global": "^1.0.3",
|
||||
"typings-test": "^1.0.1"
|
||||
"@push.rocks/smartfile": "^10.0.28",
|
||||
"@push.rocks/smartpath": "^5.0.11",
|
||||
"@push.rocks/smartpromise": "^4.0.3",
|
||||
"@push.rocks/smartshell": "^3.0.3",
|
||||
"@push.rocks/smartstring": "^4.0.7",
|
||||
"@types/fs-extra": "^11.0.1",
|
||||
"fs-extra": "^11.1.1",
|
||||
"minimatch": "^9.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"npmts": "^5.1.19",
|
||||
"should": "^9.0.0"
|
||||
}
|
||||
"@gitzone/tsbuild": "^2.1.66",
|
||||
"@gitzone/tsrun": "^1.2.44",
|
||||
"@gitzone/tstest": "^1.0.77",
|
||||
"@push.rocks/tapbundle": "^5.0.12",
|
||||
"@types/node": "^20.4.5"
|
||||
},
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
"ts_web/**/*",
|
||||
"dist/**/*",
|
||||
"dist_*/**/*",
|
||||
"dist_ts/**/*",
|
||||
"dist_ts_web/**/*",
|
||||
"assets/**/*",
|
||||
"cli.js",
|
||||
"npmextra.json",
|
||||
"readme.md"
|
||||
],
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
]
|
||||
}
|
||||
|
4794
pnpm-lock.yaml
generated
Normal file
4794
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
65
readme.md
Normal file
65
readme.md
Normal file
@ -0,0 +1,65 @@
|
||||
# @push.rocks/smartssh
|
||||
setups SSH quickly and in a painless manner
|
||||
|
||||
## Availabililty and Links
|
||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/smartssh)
|
||||
* [gitlab.com (source)](https://gitlab.com/push.rocks/smartssh)
|
||||
* [github.com (source mirror)](https://github.com/push.rocks/smartssh)
|
||||
* [docs (typedoc)](https://push.rocks.gitlab.io/smartssh/)
|
||||
|
||||
## Status for master
|
||||
|
||||
Status Category | Status Badge
|
||||
-- | --
|
||||
GitLab Pipelines | [](https://lossless.cloud)
|
||||
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||
npm | [](https://lossless.cloud)
|
||||
Snyk | [](https://lossless.cloud)
|
||||
TypeScript Support | [](https://lossless.cloud)
|
||||
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
Code Style | [](https://lossless.cloud)
|
||||
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||
BundlePhobia (total size when bundled) | [](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.
|
||||
|
||||
## Legal
|
||||
> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
|
||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
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";
|
@ -1,6 +0,0 @@
|
||||
"use strict";
|
||||
require("typings-test");
|
||||
var should = require("should");
|
||||
var smartssh = require("../dist/index.js");
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FDUCxDQUFDLENBRG9CO0FBQ3JCLElBQUksTUFBTSxHQUFHLE9BQU8sQ0FBQyxRQUFRLENBQUMsQ0FBQztBQUMvQixJQUFJLFFBQVEsR0FBRyxPQUFPLENBQUMsa0JBQWtCLENBQUMsQ0FBQyIsImZpbGUiOiJ0ZXN0LmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFwidHlwaW5ncy10ZXN0XCJcclxubGV0IHNob3VsZCA9IHJlcXVpcmUoXCJzaG91bGRcIik7XHJcbmxldCBzbWFydHNzaCA9IHJlcXVpcmUoXCIuLi9kaXN0L2luZGV4LmpzXCIpO1xyXG4iXX0=
|
87
test/test.ts
87
test/test.ts
@ -1,3 +1,84 @@
|
||||
import "typings-test"
|
||||
let should = require("should");
|
||||
let smartssh = require("../dist/index.js");
|
||||
import { expect, tap } from '@push.rocks/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',
|
||||
})
|
||||
);
|
||||
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
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @pushrocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/smartssh',
|
||||
version: '2.0.1',
|
||||
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";
|
||||
import * as plugins from './smartssh.plugins.js';
|
||||
|
||||
export {Ssh} from "./smartssh.classes.ssh";
|
||||
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';
|
||||
|
@ -1,12 +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 getKeyIndex = function(hostArg:string){
|
||||
return 0; //TODO
|
||||
}
|
||||
export let sshKeyArrayFromDir = function (dirArg: string): SshKey[] {
|
||||
let sshKeyArray = []; // TODO
|
||||
return sshKeyArray;
|
||||
};
|
||||
|
@ -1,50 +0,0 @@
|
||||
import "typings-global"
|
||||
import * as plugins from "./smartssh.plugins";
|
||||
import * as helpers from "./smartssh.classes.helpers";
|
||||
|
||||
import {SshDir} from "./smartssh.classes.sshdir";
|
||||
import {SshConfig} from "./smartssh.classes.sshconfig";
|
||||
import {SshKey} from "./smartssh.classes.sshkey";
|
||||
|
||||
export class Ssh {
|
||||
private sshConfig:SshConfig; // points to sshConfig class instance
|
||||
private sshDir:SshDir; // points to sshDir class instance.
|
||||
private sshKeys:SshKey[]; //holds all ssh keys
|
||||
private sshSync:boolean; // if set to true, the ssh dir will be kept in sync automatically
|
||||
constructor(optionsArg:{sshDir?:string,sshSync?:boolean}={}){
|
||||
this.sshDir = new SshDir(optionsArg.sshDir);
|
||||
this.sshKeys = this.sshDir.getKeys();
|
||||
this.sshSync = optionsArg.sshSync;
|
||||
};
|
||||
addKey(sshKeyArg:SshKey){
|
||||
this.sshKeys.push(sshKeyArg);
|
||||
this.sync();
|
||||
};
|
||||
getKey(hostArg:string){
|
||||
let filteredArray = this.sshKeys.filter(function(keyArg){
|
||||
return (keyArg.host == hostArg);
|
||||
});
|
||||
if(filteredArray.length > 0){
|
||||
return filteredArray[0];
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
removeKey(sshKeyArg:SshKey){
|
||||
let keyIndex = helpers.getKeyIndex(sshKeyArg.host);
|
||||
this.sshKeys.splice(keyIndex,1);
|
||||
this.sync();
|
||||
};
|
||||
replaceKey(sshKeyOldArg:SshKey,sshKeyNewArg:SshKey){
|
||||
let keyIndex = helpers.getKeyIndex(sshKeyOldArg.host);
|
||||
this.sshKeys.splice(keyIndex,1,sshKeyNewArg);
|
||||
this.sync();
|
||||
};
|
||||
sync(){
|
||||
if(this.sshSync){
|
||||
this.sshDir.sync(this.sshConfig,this.sshKeys); // call sync method of sshDir class;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,60 @@
|
||||
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 { SshKey } from './smartssh.classes.sshkey.js';
|
||||
|
||||
export class SshConfig {
|
||||
constructor(){
|
||||
|
||||
private _sshKeyArray: SshKey[];
|
||||
constructor(sshKeyArrayArg: SshKey[]) {
|
||||
this._sshKeyArray = sshKeyArrayArg;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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,
|
||||
});
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
export interface configObject {
|
||||
configString: string;
|
||||
authorized: boolean;
|
||||
sshKey: SshKey;
|
||||
}
|
||||
|
@ -1,17 +1,47 @@
|
||||
import "typings-global";
|
||||
import * as plugins from "./smartssh.plugins";
|
||||
import * as helpers from "./smartssh.classes.helpers";
|
||||
import {SshKey} from "./smartssh.classes.sshkey";
|
||||
import {SshConfig} from "./smartssh.classes.sshconfig";
|
||||
export class SshDir { // sshDir class -> NOT EXPORTED, ONLY FOR INTERNAL USE
|
||||
path:string;
|
||||
constructor(sshDirPathArg:string){
|
||||
this.path = sshDirPathArg;
|
||||
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/');
|
||||
}
|
||||
sync(sshConfigArg:SshConfig,sshKeysArg:SshKey[]){
|
||||
|
||||
};
|
||||
getKeys(){
|
||||
return helpers.sshKeyArrayFromDir(this.path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
writeToDir(dirPathArg?: string) {
|
||||
// syncs sshInstance to directory
|
||||
let path = this._path;
|
||||
if (dirPathArg) path = dirPathArg;
|
||||
this._sshKeyArray.forEach((sshKeyArg) => {
|
||||
sshKeyArg.store(path);
|
||||
});
|
||||
this._sshConfig.store(path);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
|
102
ts/smartssh.classes.sshinstance.ts
Normal file
102
ts/smartssh.classes.sshinstance.ts
Normal file
@ -0,0 +1,102 @@
|
||||
import * as plugins from './smartssh.plugins.js';
|
||||
import * as helpers from './smartssh.classes.helpers.js';
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// 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');
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
// 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 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);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,65 +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;
|
||||
constructor(optionsArg:{private?:string,public?:string,host?:string}={}){
|
||||
this.privKey = optionsArg.private;
|
||||
this.pubKey = optionsArg.public;
|
||||
this.hostVar = optionsArg.host;
|
||||
};
|
||||
|
||||
// getters
|
||||
get host(){
|
||||
return this.hostVar;
|
||||
};
|
||||
get privateKey(){
|
||||
return this.privKey;
|
||||
};
|
||||
get privateKeyBase64(){
|
||||
return plugins.base64.encode(this.privKey);
|
||||
private _privKey: string;
|
||||
private _pubKey: string;
|
||||
private _hostVar: string;
|
||||
private _authorized: boolean;
|
||||
|
||||
private _smarthshellInstance = new plugins.shelljs.Smartshell({
|
||||
executor: 'bash',
|
||||
});
|
||||
|
||||
/**
|
||||
* the constructor for class SshKey
|
||||
*/
|
||||
constructor(
|
||||
optionsArg: { private?: string; public?: string; host?: string; authorized?: boolean } = {}
|
||||
) {
|
||||
this._privKey = optionsArg.private;
|
||||
this._pubKey = optionsArg.public;
|
||||
this._hostVar = optionsArg.host;
|
||||
this._authorized = optionsArg.authorized;
|
||||
}
|
||||
|
||||
// this.host
|
||||
get host() {
|
||||
return this._hostVar;
|
||||
}
|
||||
set host(hostArg: string) {
|
||||
this._hostVar = hostArg;
|
||||
}
|
||||
|
||||
// this.privKey
|
||||
get privKey() {
|
||||
return this._privKey;
|
||||
}
|
||||
set privKey(privateKeyArg: string) {
|
||||
this._privKey = privateKeyArg;
|
||||
}
|
||||
|
||||
// this.privKeyBase64
|
||||
get privKeyBase64() {
|
||||
return plugins.smartstring.base64.encode(this._privKey);
|
||||
}
|
||||
set privKeyBase64(privateKeyArg: string) {
|
||||
this._privKey = plugins.smartstring.base64.decode(privateKeyArg);
|
||||
}
|
||||
|
||||
// this.pubKey
|
||||
get pubKey() {
|
||||
return this._pubKey;
|
||||
}
|
||||
set pubKey(publicKeyArg: string) {
|
||||
this._pubKey = publicKeyArg;
|
||||
}
|
||||
|
||||
// this.pubKeyBase64
|
||||
get pubKeyBase64() {
|
||||
return plugins.smartstring.base64.encode(this._pubKey);
|
||||
}
|
||||
set pubKeyBase64(publicKeyArg: string) {
|
||||
this._pubKey = plugins.smartstring.base64.decode(publicKeyArg);
|
||||
}
|
||||
|
||||
get authorized() {
|
||||
return this._authorized;
|
||||
}
|
||||
set authorized(authorizedArg: boolean) {
|
||||
this._authorized = authorizedArg;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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';
|
||||
}
|
||||
get publicKey(){
|
||||
return this.publicKey;
|
||||
}
|
||||
set type(someVlueArg: any) {
|
||||
console.log('the type of an SshKey connot be set. This value is autocomputed.');
|
||||
}
|
||||
|
||||
// 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}`);
|
||||
}
|
||||
get publicKeyBase64(){
|
||||
return plugins.base64.encode(this.pubKey);
|
||||
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}`);
|
||||
}
|
||||
get type(){
|
||||
if(this.privKey && this.pubKey){
|
||||
return "duplex";
|
||||
} else if(this.privKey){
|
||||
return "private";
|
||||
} else if(this.pubKey){
|
||||
return "public";
|
||||
}
|
||||
};
|
||||
|
||||
// setters
|
||||
set host(hostArg:string){
|
||||
this.hostVar = hostArg;
|
||||
};
|
||||
set privateKey(privateKeyArg:string){
|
||||
this.privKey = privateKeyArg;
|
||||
};
|
||||
// setters
|
||||
set publicKey(publicKeyArg:string){
|
||||
this.pubKey = publicKeyArg;
|
||||
};
|
||||
|
||||
store(filePathArg?:string){
|
||||
let filePathObj = plugins.path.parse(filePathArg);
|
||||
if(filePathObj.ext = ".priv"){
|
||||
plugins.smartfile.memory.toFsSync(this.privKey,{fileName:filePathObj.name + filePathObj.ext,filePath:filePathObj.dir});
|
||||
} else if (filePathObj.ext = ".pub"){
|
||||
plugins.smartfile.memory.toFsSync(this.pubKey,{fileName:filePathObj.name + filePathObj.ext,filePath:filePathObj.dir});
|
||||
} else { //we assume we are given a directory as filePathArg, so we store the whole key
|
||||
plugins.fs.ensureDirSync(filePathObj.dir);
|
||||
this.store(plugins.path.join(filePathObj.dir,"key.priv")); // call this function recursivly
|
||||
this.store(plugins.path.join(filePathObj.dir,"key.priv")); // call this function recursivly
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,10 @@
|
||||
import "typings-global"
|
||||
export let beautylog = require("beautylog");
|
||||
export let base64 = require("js-base64").Base64;
|
||||
export let fs = require("fs-extra");
|
||||
export let path = require("path");
|
||||
export let smartfile = require("smartfile");
|
||||
import * as fs from 'fs-extra';
|
||||
import * as minimatch from 'minimatch';
|
||||
import * as path from 'path';
|
||||
import * as smartpromise from '@push.rocks/smartpromise';
|
||||
import * as shelljs from '@push.rocks/smartshell';
|
||||
import * as smartfile from '@push.rocks/smartfile';
|
||||
import * as smartpath from '@push.rocks/smartpath';
|
||||
import * as smartstring from '@push.rocks/smartstring';
|
||||
|
||||
export { fs, minimatch, path, smartpromise, shelljs, smartfile, smartpath, smartstring };
|
||||
|
@ -1,8 +0,0 @@
|
||||
{
|
||||
"version": false,
|
||||
"dependencies": {},
|
||||
"ambientDependencies": {
|
||||
"colors": "registry:dt/colors#0.6.0-1+20160317120654",
|
||||
"node": "registry:dt/node#4.0.0+20160423143914"
|
||||
}
|
||||
}
|
11
tsconfig.json
Normal file
11
tsconfig.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"target": "ES2022",
|
||||
"module": "ES2022",
|
||||
"moduleResolution": "nodenext",
|
||||
"esModuleInterop": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user