@microsoft/dev-tunnels-ssh
Version:
SSH library for Dev Tunnels
78 lines • 4.02 kB
TypeScript
import { CancellationToken, Disposable, Event } from 'vscode-jsonrpc';
import { SshSession } from '../sshSession';
import { SshChannel } from '../sshChannel';
import { SshRequestEventArgs } from '../events/sshRequestEventArgs';
import { SshChannelOpeningEventArgs } from '../events/sshChannelOpeningEventArgs';
import { SessionRequestMessage } from '../messages/transportMessages';
import { ChannelRequestMessage } from '../messages/connectionMessages';
import { SshMessage } from '../messages/sshMessage';
import { Trace } from '../trace';
import { Progress } from '../progress';
/**
* An `SshService` subclass must provide a constructor that takes an `SshSession`
* and optional config object.
*/
export interface SshServiceConstructor<T extends SshService = SshService> {
new (session: SshSession, config?: any): T;
}
/**
* Base class for SSH session services that handle incoming requests.
*
* Services can be on either the server side or the client side, because either side may
* send requests to the other's services.
*
* Service subclasses must have one or more `serviceActivation` decorators applied to them to
* declare the type(s) of requests that cause the service to be activated. Only one instance
* of each service type gets activated for a session, even if there are multiple activation
* rules. After activation, a service remains active for the duration of the session,
* handling any additional requests, until it is disposed when the session is disposed.
*
* To enable activation of a service, add the service type to
* `SshSessionConfiguration.services`. When a service is activated, the session raises a
* `SshSession.serviceActivated` event.
*/
export declare class SshService implements Disposable {
readonly session: SshSession;
private disposed;
constructor(session: SshSession);
protected get trace(): Trace;
protected raiseReportProgress(progress: Progress): void;
dispose(): void;
private readonly disposedEmitter;
readonly onDisposed: Event<void>;
/**
* Services that are activated via session requests must override this method to handle
* incoming session requests.
*
* Implementations must set `SshRequestEventArgs.isAuthorized` or
* `SshRequestEventArgs.responsePromise` to indicate whether the request was allowed.
*/
protected onSessionRequest(request: SshRequestEventArgs<SessionRequestMessage>, cancellation?: CancellationToken): Promise<void>;
/**
* Services that are activated via channel types must override this method to handle
* incoming requests to open a channel.
*
* Implementations may set `SshChannelOpeningEventArgs.failureReason` or
* `SshChannelOpeningEventArgs.openingPromise` to block opening of the channel.
* The default behavior allows the channel to open.
*
* Requests on the opened channel will not be directed to `onChannelRequest`
* unless the service also declares activation on specific channel request(s). Otherwise,
* an implementation of this method may add any event-handlers to the
* `SshChannelOpeningEventArgs.channel` including a request event handler.
*/
protected onChannelOpening(request: SshChannelOpeningEventArgs, cancellation?: CancellationToken): Promise<void>;
/**
* Services that are activated via channel requests must override this method to handle
* incoming channel requests.
*
* Implementations must set `SshRequestEventArgs.isAuthorized` or
* `SshRequestEventArgs.responsePromise` to indicate whether the request was allowed.
*/
protected onChannelRequest(channel: SshChannel, request: SshRequestEventArgs<ChannelRequestMessage>, cancellation?: CancellationToken): Promise<void>;
/**
* Sends any message.
*/
protected sendMessage(message: SshMessage, cancellation?: CancellationToken): Promise<void>;
}
//# sourceMappingURL=sshService.d.ts.map