Browse Source

upgrade dependencies

pull/150/head^2
cbutler 6 years ago
parent
commit
9d8a5eeac8
No known key found for this signature in database GPG Key ID: 9EB3D625BD14DDEC
  1. 4
      .babelrc
  2. 2
      bin/index.js
  3. 36
      cli.mjs
  4. 31
      gulpfile.js
  5. 2
      index.js
  6. 29
      package.json
  7. 2
      public/wetty/wetty.min.js
  8. 55
      wetty.mjs
  9. 4150
      yarn.lock

4
.babelrc

@ -1,11 +1,11 @@
{
"presets": [
[
"es2015",
"@babel/preset-env",
{
"modules": false
}
]
],
"compact": true,
"compact": true
}

2
bin/index.js

@ -1,3 +1,3 @@
#! /usr/bin/env node
require = require('@std/esm')(module); // eslint-disable-line no-global-assign
require = require('esm')(module, { cjs: true }); // eslint-disable-line no-global-assign
require('../cli.mjs');

36
cli.mjs

@ -6,45 +6,46 @@ import wetty from './wetty';
const opts = optimist
.options({
sslkey: {
demand : false,
demand: false,
description: 'path to SSL key',
},
sslcert: {
demand : false,
demand: false,
description: 'path to SSL certificate',
},
sshhost: {
demand : false,
demand: false,
description: 'ssh server host',
},
sshport: {
demand : false,
demand: false,
description: 'ssh server port',
},
sshuser: {
demand : false,
demand: false,
description: 'ssh user',
},
sshpass: {
demand : false,
demand: false,
description: 'ssh password',
},
sshauth: {
demand : false,
demand: false,
description: 'defaults to "password", you can use "publickey,password" instead',
},
sshkey: {
demand : false,
description: 'path to an optional client private key (connection will be password-less and insecure!)',
demand: false,
description:
'path to an optional client private key (connection will be password-less and insecure!)',
},
port: {
demand : false,
alias : 'p',
demand: false,
alias: 'p',
description: 'wetty listen port',
},
help: {
demand : false,
alias : 'h',
demand: false,
alias: 'h',
description: 'Print help message',
},
})
@ -60,7 +61,7 @@ const sshpass = opts.sshpass || process.env.SSHPASS || '';
const sshhost = opts.sshhost || process.env.SSHHOST || 'localhost';
const sshauth = opts.sshauth || process.env.SSHAUTH || 'password,keyboard-interactive';
const sshport = opts.sshport || process.env.SSHPORT || 22;
const sshkey = opts.sshkey || process.env.SSHKEY || '';
const sshkey = opts.sshkey || process.env.SSHKEY || '';
const port = opts.port || process.env.PORT || 3000;
loadSSL(opts)
@ -72,13 +73,12 @@ loadSSL(opts)
process.exit(1);
});
const sshkeyWarning =
`!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Password-less auth enabled using private key from \'%s\'.
const sshkeyWarning = `!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Password-less auth enabled using private key from ${sshkey}.
! This is dangerous, anything that reaches the wetty server
! will be able to run remote operations without authentication.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!`;
if(sshkey) {
if (sshkey) {
console.warn(sshkeyWarning);
}

31
gulpfile.js

@ -5,7 +5,7 @@ const babel = require('gulp-babel');
const shell = require('gulp-shell');
const del = require('del');
gulp.task('compress', [], () =>
const compress = () =>
gulp
.src(['./src/hterm_all.js', './src/wetty.js'])
.pipe(concat('wetty.js'))
@ -20,21 +20,22 @@ gulp.task('compress', [], () =>
ignoreFiles: ['.combo.js', '*.min.js'],
}),
)
.pipe(gulp.dest('./public/wetty')),
);
.pipe(gulp.dest('./public/wetty'));
gulp.task('default', gulp.series(compress));
gulp.task(
'hterm',
shell.task(
[
'git clone https://chromium.googlesource.com/apps/libapps',
'LIBDOT_SEARCH_PATH=$(pwd)/libapps ./libapps/libdot/bin/concat.sh -i ./libapps/hterm/concat/hterm_all.concat -o ./src/hterm_all.js',
],
{
verbose: true,
},
'upgrade',
gulp.series(
shell.task(
[
'git clone https://chromium.googlesource.com/apps/libapps',
'LIBDOT_SEARCH_PATH=$(pwd)/libapps ./libapps/libdot/bin/concat.sh -i ./libapps/hterm/concat/hterm_all.concat -o ./src/hterm_all.js',
],
{
verbose: true,
},
),
() => del(['./libapps']),
),
);
gulp.task('default', ['compress']);
gulp.task('upgrade', ['hterm'], () => del(['./libapps']));

2
index.js

@ -1,2 +1,2 @@
require = require('@std/esm')(module); // eslint-disable-line no-global-assign
require = require('esm')(module, { cjs: true }); // eslint-disable-line no-global-assign
module.exports = require('./wetty.mjs').default;

29
package.json

@ -29,29 +29,26 @@
"commit"
],
"preferGlobal": "true",
"@std/esm": {
"cjs": "true"
},
"dependencies": {
"@std/esm": "^0.12.1",
"express": "^4.15.3",
"esm": "^3.0.84",
"express": "^5.15.3",
"fs-extra": "^4.0.1",
"node-pty": "^0.7.4",
"optimist": "^0.6",
"pre-commit": "^1.2.2",
"node-pty": "^0.7.4",
"serve-favicon": "^2.4.3",
"socket.io": "^1.3.7"
},
"devDependencies": {
"babel-cli": "6.24.1",
"babel-core": "6.24.1",
"babel-eslint": "7.2.3",
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
"@babel/plugin-transform-async-to-generator": "^7.0.0",
"@babel/plugin-transform-object-assign": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"babel-eslint": "^9.0.0",
"babel-plugin-add-module-exports": "0.2.1",
"babel-plugin-es6-promise": "1.1.1",
"babel-plugin-syntax-async-functions": "6.13.0",
"babel-plugin-transform-async-to-generator": "6.24.1",
"babel-plugin-transform-object-assign": "6.22.0",
"babel-preset-es2015": "6.24.1",
"del": "^3.0.0",
"es6-promise": "^4.1.1",
"eslint": "3.19.0",
@ -63,11 +60,11 @@
"eslint-plugin-promise": "^3.5.0",
"eslint-plugin-react": "^7.1.0",
"eslint-plugin-standard": "^3.0.1",
"gulp": "^3.9.1",
"gulp-babel": "^6.1.2",
"gulp": "^4.0.0",
"gulp-babel": "^8.0.0",
"gulp-concat": "^2.6.1",
"gulp-minify": "^1.0.0",
"gulp-shell": "^0.6.3"
"gulp-minify": "^3.1.0",
"gulp-shell": "^0.6.5"
},
"contributors": [
"Krishna Srinivas <krishna.srinivas@gmail.com>",

2
public/wetty/wetty.min.js

File diff suppressed because one or more lines are too long

55
wetty.mjs

@ -3,29 +3,31 @@ import http from 'http';
import https from 'https';
import path from 'path';
import server from 'socket.io';
import { spawn } from 'node-pty';
import pty from 'node-pty';
import EventEmitter from 'events';
import favicon from 'serve-favicon';
import url from 'url';
const dirname = path.resolve();
const app = express();
app.use(favicon(`${__dirname}/public/favicon.ico`));
app.use(favicon(`${dirname}/public/favicon.ico`));
// For using wetty at /wetty on a vhost
app.get('/wetty/ssh/:user', (req, res) => {
res.sendFile(`${__dirname}/public/wetty/index.html`);
res.sendFile(`${dirname}/public/wetty/index.html`);
});
app.get('/wetty/', (req, res) => {
res.sendFile(`${__dirname}/public/wetty/index.html`);
res.sendFile(`${dirname}/public/wetty/index.html`);
});
// For using wetty on a vhost by itself
app.get('/ssh/:user', (req, res) => {
res.sendFile(`${__dirname}/public/wetty/index.html`);
res.sendFile(`${dirname}/public/wetty/index.html`);
});
app.get('/', (req, res) => {
res.sendFile(`${__dirname}/public/wetty/index.html`);
res.sendFile(`${dirname}/public/wetty/index.html`);
});
// For serving css and javascript
app.use('/', express.static(path.join(__dirname, 'public')));
app.use('/', express.static(path.join(dirname, 'public')));
function createServer(port, sslopts) {
return sslopts && sslopts.key && sslopts.cert
@ -43,29 +45,32 @@ function getCommand(socket, sshuser, sshpass, sshhost, sshport, sshauth, sshkey)
const sshAddress = sshuser ? `${sshuser}@${sshhost}` : sshhost;
const referer = url.parse(request.headers.referer, true);
sshpass = referer.query.sshpass ? referer.query.sshpass : sshpass;
let sshPath = sshuser || match ? 'ssh' : path.join(__dirname, 'bin/ssh');
const ssh = match ? `${match[0].split('/ssh/').pop().split('?')[0]}@${sshhost}` : sshAddress;
const sshPath = sshuser || match ? 'ssh' : path.join(dirname, 'bin/ssh');
const ssh = match
? `${
match[0]
.split('/ssh/')
.pop()
.split('?')[0]
}@${sshhost}`
: sshAddress;
const sshRemoteOptsBase = [
sshPath,
ssh,
'-p',
sshport,
'-o',
`PreferredAuthentications=${sshauth}`,
]
sshPath,
ssh,
'-p',
sshport,
'-o',
`PreferredAuthentications=${sshauth}`,
];
let sshRemoteOpts;
if (sshkey)
sshRemoteOpts = sshRemoteOptsBase.concat(['-i', sshkey]);
else if (sshpass)
sshRemoteOpts = ['sshpass', '-p', sshpass].concat(sshRemoteOptsBase);
else
sshRemoteOpts = sshRemoteOptsBase;
if (sshkey) sshRemoteOpts = sshRemoteOptsBase.concat(['-i', sshkey]);
else if (sshpass) sshRemoteOpts = ['sshpass', '-p', sshpass].concat(sshRemoteOptsBase);
else sshRemoteOpts = sshRemoteOptsBase;
return [
process.getuid() === 0 && sshhost === 'localhost'
? ['login', '-h', socket.client.conn.remoteAddress.split(':')[3]]
: sshRemoteOpts
,
: sshRemoteOpts,
ssh,
];
}
@ -76,7 +81,7 @@ export default function start(port, sshuser, sshpass, sshhost, sshport, sshauth,
io.on('connection', socket => {
console.log(`${new Date()} Connection accepted.`);
const [args, ssh] = getCommand(socket, sshuser, sshpass, sshhost, sshport, sshauth, sshkey);
const term = spawn('/usr/bin/env', args, {
const term = pty.spawn('/usr/bin/env', args, {
name: 'xterm-256color',
cols: 80,
rows: 30,

4150
yarn.lock

File diff suppressed because it is too large
Loading…
Cancel
Save