UNPKG

@microsoft/dev-tunnels-ssh

Version:
78 lines 4.26 kB
/// <reference types="node" /> import { CancellationToken, Disposable } from 'vscode-jsonrpc'; import { Stream } from './streams'; import { SshChannel } from './sshChannel'; import { SshStream } from './sshStream'; import { SshSession } from './sshSession'; import { SshSessionClosedEventArgs } from './events/sshSessionClosedEventArgs'; import { Trace } from './trace'; import { SshClientCredentials, SshServerCredentials } from './sshCredentials'; import { SshServerSession } from './sshServerSession'; import { SshAuthenticatingEventArgs } from './events/sshAuthenticatingEventArgs'; import { Duplex } from 'stream'; import { PromiseCompletionSource } from './util/promiseCompletionSource'; /** * Establishes an end-to-end encrypted two-way authenticated data stream over an underlying * transport stream, using the SSH protocol but providing simplified interface that is limited to * a single duplex stream (channel). * * This class is a complement to `MultiChannelStream`, which provides only the channel-multiplexing * functions of SSH. * * To establish a secure connection, the two sides first establish an insecure transport stream * over a pipe, socket, or anything else. Then they encrypt and authenticate the connection * before beginning to send and receive data. */ export declare class SecureStream extends Duplex implements Disposable { private transportStream; protected readonly session: SshSession; protected readonly clientCredentials: SshClientCredentials | null; protected readonly serverCredentials: SshServerCredentials | null; protected readonly connectCompletion: PromiseCompletionSource<SshStream | null>; protected stream?: SshStream; private disposed; protected disposables: Disposable[]; /** * Creates a new encrypted and authenticated stream over an underlying transport stream. * @param transportStream Stream that is used to multiplex all the channels. * @param credentials Client or server credentials for authenticating the secure connection. * @param reconnectableSessions Optional parameter that enables the stream to be reconnected * with a new transport stream after a temporary disconnection. For a stream client it is * a boolean value; for a stream server it must be an array. */ constructor(transportStream: Stream | Duplex, credentials: SshClientCredentials | SshServerCredentials, reconnectableSessions?: SshServerSession[] | boolean); get trace(): Trace; set trace(trace: Trace); get isClosed(): boolean; private readonly disconnectedEmitter; readonly onDisconnected: import("vscode-jsonrpc").Event<void>; private readonly closedEmitter; readonly onClosed: import("vscode-jsonrpc").Event<SshSessionClosedEventArgs>; onAuthenticating(listener: (e: SshAuthenticatingEventArgs) => any, thisArgs?: any, disposables?: Disposable[]): Disposable; /** * Initiates the SSH session over the transport stream by exchanging initial messages with the * remote peer. Waits for the protocol version exchange and key exchange. Additional message * processing is kicked off as a background promise chain. * @param cancellation optional cancellation token. */ connect(cancellation?: CancellationToken): Promise<void>; /** * Re-initiates the SSH session over a NEW transport stream by exchanging initial messages * with the remote server. Waits for the secure reconnect handshake to complete. Additional * message processing is kicked off as a background task chain. * * Applies only to a secure stream client. (The secure stream server handles reconnections * automatically during the session handshake.) */ reconnect(transportStream: Stream | Duplex, cancellation?: CancellationToken): Promise<void>; /** * Creates a stream instance for a channel. May be overridden to create a `SshStream` subclass. */ protected createStream(channel: SshChannel): SshStream; dispose(): void; close(): Promise<void>; private onSessionDisconnected; private onSessionClosed; private unsubscribe; } //# sourceMappingURL=secureStream.d.ts.map