npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@distrentic/high-jump

v0.1.1

Published

An SSH jump server library using ssh2 and socket.io

Downloads

23

Readme

high-jump (library)

An SSH jump server library using ssh2 and socket.io.

Installation

npm install @distrentic/high-jump
yarn add @distrentic/high-jump

Usage

You can either run ready-to-use high-jump-server or implement your own server using this library.

Express server example (typescript)

import express from "express";
import { Server as HttpServer } from "http";
import { Server as SocketServer } from "socket.io";
import shell from "@distrentic/high-jump";

const PORT = process.env["PORT"] || 8022;

const log = console;

const app = express();
const server = new HttpServer(app);
const io = new SocketServer(server, {
  serveClient: false,
  path: "/ssh",
  cors: { origin: "*" },
});

io.on("connection", (socket) => shell(socket, log));

server.listen(PORT, () => {
  log.info(`high-jump is running at ::${PORT}`);
});

Client example (typescript)

import io from "socket.io-client";
import { Terminal } from "xterm";
import { FitAddon } from "xterm-addon-fit";

const term = new Terminal({ cursorBlink: true });
const terminalContainer = document.getElementById("terminal-container")!;
const fitAddon = new FitAddon();
term.loadAddon(fitAddon);
term.open(terminalContainer);
term.focus();
fitAddon.fit();

const socket = io("http://localhost:8022/", { path: "/ssh" }).open();

window.addEventListener("resize", resize, false);

function resize() {
  fitAddon.fit();
  socket.emit("resize", {
    cols: term.cols,
    rows: term.rows,
    width: terminalContainer.clientWidth,
    height: terminalContainer.clientHeight,
  });
}

socket.on("connect", () => {
  socket.emit("shell", {
    host: "",
    port: 22,
    username: "",
    password: "",
    cols: term.cols,
    rows: term.rows,
    width: terminalContainer.clientWidth,
    height: terminalContainer.clientHeight,
  });
});

term.onData((data: string) => {
  socket.emit("data", data);
});

socket.on("data", (data: ArrayBuffer) => {
  term.write(new TextDecoder().decode(data));
});

socket.on("shell_error", (type: string) => {
  alert(type);
});

API

require('@distrentic/high-jump) returns a function to construct the shell socket listener.

Methods

  • shell(< Socket > socket, < Logger > logger) - (void) - Constructs the shell socket listener.
    • socket - Socket - socket.io connection handler.
    • logger - Logger - An instance of a logging library. Accepts console, winston.Logger, bunyan.Logger, etc.

Events

Emitted events

These are the

  • data(< ArrayBuffer > data) - UTF-8 encoded buffer.
  • shell_error - < "SSH_CONNECTION_ERROR" | "SSH_AUTHENTICATION_ERROR" | "SHELL_ERROR" | "SOCKET_ERROR" > error) - Emitted when an error occurs. Message received indicates the type of error.

Listened events

  • shell(< object > config) - Client emitted event to request a new shell. You can either authenticate with a password or a privateKey (and a passphrase if you set one).
{
  "host": "",
  "port": 22,
  "username": "",
  "password": "P@ssw0rd",
  "privateKey": "",
  "passphrase": "",

  // pseudo tty configuration
  "cols": 80,
  "rows": 60,
  "width": 1600,
  "height": 1200
}
  • data(< string > data) - Sends data to remote shell.
  • resize(< object > config) - Event to resize pseudo tty.
{
  "cols": 80,
  "rows": 60,
  "width": 1600,
  "height": 1200
}

License

Licensed under MIT license (LICENSE or http://opensource.org/licenses/MIT)