New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

xterm-addon-ssh

Package Overview
Dependencies
Maintainers
5
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xterm-addon-ssh

Ssh addon for xterm.js

latest
Source
npmnpm
Version
0.0.25
Version published
Maintainers
5
Created
Source

version downloads license vulnerabilities

xterm-addon-ssh

Overview

This library sends to the socket server for communication with SSH.

If you want to communicate to SSH directly, use xterm-addon-attach

Install

npm install --save xterm-addon-ssh

Usage

  • Javascript
import { Terminal } from 'xterm';
import { SshAddon } from 'xterm-addon-ssh';
import * as SockJS from 'sockjs-client';

const sockjs = new SockJS('https://127.0.0.1:8080');

const terminal = new Terminal();
const sshAddon = new SshAddon(sockjs, {
  serverUuid: '123e4567-e89b-12d3-a456-426614174000',
  header: {
    Authorization:
      'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c',
  },
  connectImmediately: true,
});

terminal.loadAddon(sshAddon);
  • React with Typescript
import * as React from 'react';
import { QPXterm } from 'qp-xtermjs';
import { SshAddon, TerminalKeyEvent } from 'xterm-addon-ssh';
import * as SockJS from 'sockjs-client';

const sockjs = new SockJS('https://127.0.0.1:8080');

const Term: React.FC = () => {
  const terminalRef = useRef<QPXterm | null>();
  const sshAddon = React.useRef(
    new SshAddon(sockjs, {
      serverUuid: '123e4567-e89b-12d3-a456-426614174000',
      header: {
        Authorization:
          'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c',
      },
      connectImmediately: true,
      onKey: console.log,
    }),
  ).current;

  const onDidMount = React.useCallback((terminal: QPXterm) => {
    terminalRef.current = terminal;
  }, []);

  React.useEffect(() => {
    const callback = (event: Event | TerminalKeyEvent) => {
      console.log(event);
    };

    sshAddon.addEventListener('connect', callback);
    sshAddon.addEventListener('message', callback);
    sshAddon.addEventListener('key', callback);
    sshAddon.addEventListener('error', callback);
    sshAddon.addEventListener('close', callback);

    return () => {
      sshAddon.removeEventListener('connect', callback);
      sshAddon.removeEventListener('message', callback);
      sshAddon.removeEventListener('key', callback);
      sshAddon.removeEventListener('error', callback);
      sshAddon.removeEventListener('close', callback);
    };
  }, []);

  React.useEffect(() => {
    return () => {
      sshAddon.removeAllListeners();
    };
  });

  return <QPXterm onDidMount={onDidMount} addons={[sshAddon]} />;
};

export default Term;

Keywords

xterm

FAQs

Package last updated on 22 Jun 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts