UNPKG

alwaysai

Version:

The alwaysAI command-line interface (CLI)

93 lines 3.67 kB
import { SecureTunnelPorts } from './shadows'; declare type SecureTunnelInfo = { tunnelId: string; sourceAccessToken: string; sshPort: number; expiresAt: number; }; export declare type SecureTunnelStorage = { setItem(key: string, value: SecureTunnelInfo): void; getItem(key: string): SecureTunnelInfo; getNextAvailablePort(): number; removeItem(key: string): void; removeExpiredItems(): number[]; }; declare type TunnelUsed = { by: string; since: number; }; export declare type OpenTunnelResponseBody = { expiresAt: number; newTunnelCreated: boolean; sourceAccessToken: string; txId: string; tunnelId: string; tunnelUsed?: TunnelUsed; }; export declare type DockerStartParams = { deviceUuid: string; sshPort: number; imageName: string; sourceAccessToken: string; httpPorts: SecureTunnelPorts[]; }; export declare const secureTunnelValidateFunction: import("ajv").ValidateFunction<{ [key: string]: SecureTunnelInfo; }>; /** * Contains functionality to read, update, and delete items in the secure-tunnel.json * @returns secure tunnel storage */ export declare function secureTunnelJsonFile(): SecureTunnelStorage; /** * Gets the docker image name for secure tunneling, * which depends on the dev, qa, prod environment. * @returns {string} full name for the docker image */ export declare function getDockerImageName(): string; /** * Removes previously added localhost with port numbers from known_hosts file * @param {number[]} sshPortList - list of ssh port numbers to be removed from known_hosts file */ export declare function removeLocalhostPortsFromKnownHostsFile(sshPortList: number[]): Promise<void>; /** * Gets source access token, needed to open secure tunnel * @param {string} deviceUuid - device uuid * @returns {Promise<OpenTunnelResponseBody>} source access token */ export declare function getSourceAccessToken(deviceUuid: string, services?: { SSH: number; HTTP: number; }): Promise<OpenTunnelResponseBody>; /** * Starts a docker container with local proxy binary with parameters * @param {DockerStartParams} startParams - parameters for starting the docker container with local proxy */ export declare function startDockerLocalProxyContainer(startParams: DockerStartParams): Promise<void>; /** * Stops docker container with local proxy binary * @param {string} containerName - docker container name to stop */ export declare function stopDockerLocalProxyContainer(containerName: string): Promise<void>; /** * Starts a ssh session with the remote host using localproxy binary running in the docker container * @param {string} remoteUser - remote host username * @param {number} sshPort - port number for ssh */ export declare function startSecureTunnelSshSession(remoteUser: string, sshPort: number): Promise<void>; export declare function constructSecureTunnelMessage({ chargeOccurredMsg, tunnelId, expiresAtString, secureTunnelInfo, httpPortLocalProxyMessage }: { chargeOccurredMsg: any; tunnelId: any; expiresAtString?: string | undefined; secureTunnelInfo: any; httpPortLocalProxyMessage?: string | undefined; }): string; /** * Processes open tunnel data * @param {OpenTunnelResponseBody} openTunnelResp - open tunnel response data to process * @returns {SecureTunnelInfo} secure tunnel info */ export declare function processOpenTunnelData(openTunnelResp: OpenTunnelResponseBody, selectedDeviceUuid: string, httpPortRequired: boolean, getSshPortFn?: typeof getSshPort): SecureTunnelInfo; declare function getSshPort(selectedDeviceUuid: string): number; export {}; //# sourceMappingURL=secure-tunnel.d.ts.map