@microsoft/dev-tunnels-ssh
Version:
SSH library for Dev Tunnels
94 lines • 5.33 kB
TypeScript
import { SshSession } from './sshSession';
import { CancellationToken } from 'vscode-jsonrpc';
import { SshSessionConfiguration } from './sshSessionConfiguration';
import { SshChannel } from './sshChannel';
import { ChannelOpenMessage, ChannelRequestMessage } from './messages/connectionMessages';
import { Stream } from './streams';
import { SshClientCredentials } from './sshCredentials';
/**
* The client side of an SSH session. Extends the base `SshSession` class to
* support client authentication.
*/
export declare class SshClientSession extends SshSession {
private readonly serviceRequests;
constructor(config: SshSessionConfiguration);
private clientAuthCompletion;
/**
* Attempts to authenticate both the server and client.
*
* This method must be called only after encrypting the session. It is equivalent
* to calling both `authenticateServer()` and `authenticateClient()` and waiting on
* both results.
*
* @returns `true` if authentication succeeded, `false` if it failed.
*/
authenticate(clientCredentials: SshClientCredentials, cancellation?: CancellationToken): Promise<boolean>;
/**
* Triggers server authentication by invoking the `authenticating` event with
* the verified server host key.
*
* This method must be called only after encrypting the session. It does not wait for any
* further message exchange with the server, since the server host key would have already
* been obtained during the key-exchange.
*
* @returns `true` if authentication succeeded, `false` if it failed.
*/
authenticateServer(cancellation?: CancellationToken): Promise<boolean>;
/**
* Performs client authentication by sending the configured public key or
* password credential to the server and waiting for a response.
*
* This method must be called only after encrypting the session.
*
* @returns `true` if authentication succeeded, `false` if it failed.
*/
authenticateClient(credentials: SshClientCredentials, cancellation?: CancellationToken): Promise<boolean>;
/**
* Performs client authentication by sending the configured public key or
* password credential to the server. Returns the result later via a callback.
*
* This method must be called only after encrypting the session. It waits for the
* authentication request message to be sent, but does not directly wait for a response.
* In scenarios when client authentication is non-interactive, only a single credential
* is used, and it is expected to be always successful in non-exceptional conditions,
* then this method may reduce the time required to establish a secure session by not
* blocking on the authentication result before sending additional messages such as
* channel open requests. If the authentication fails then those additional requests
* would likely fail also, and in that case the callback may reveal the reason.
*
* @param callback Callback that will be invoked with the result of the client
* authentication, or with an error if the session is disconnected before
* authentication completed.
*/
authenticateClient(credentials: SshClientCredentials, callback: (err?: Error, result?: boolean) => void, cancellation?: CancellationToken): Promise<void>;
private authenticateClientWithCompletion;
/**
* Sends a request for a service and waits for a response.
*
* @param serviceName Name of the service to be requested.
* @param cancellation Optional cancellation token.
* @returns A promise that resolves when the service request has been accepted.
*
* If the server does not accept the service request, it will disconnect the session.
*/
requestService(serviceName: string, cancellation?: CancellationToken): Promise<void>;
openChannel(channelTypeOrOpenMessageOrCancellation?: string | null | ChannelOpenMessage | CancellationToken, initialRequestOrCancellation?: ChannelRequestMessage | null | CancellationToken, cancellation?: CancellationToken): Promise<SshChannel>;
/**
* Call instead of `connect()` to reconnect to a prior session instead of connecting
* a new session.
* @param stream A new stream that has just (re-) connected to the server.
* @param cancellation Optional cancellation token.
* @returns True if reconnect succeeded, false if the server declined the reconnect
* request or reconnect session validation failed. In the case of a false return value,
* retrying is unlikely to succeed.
* @throws {SshConnectionError} There was a problem connecting to or communicating with
* the server; retrying may still succeed if connectivity is restored.
* @throws {SshReconnectError} Reconnect failed for some reason other than a communication
* issue: see the `failureReason` property of the error. Retrying is unlikely to succeed,
* unless the specific error condition can be addressed.
*/
reconnect(stream: Stream, cancellation?: CancellationToken): Promise<void>;
private reconnectInternal;
dispose(): void;
}
//# sourceMappingURL=sshClientSession.d.ts.map