UNPKG

@zowe/zos-uss-for-zowe-sdk

Version:
161 lines 5.04 kB
"use strict"; /* * This program and the accompanying materials are made available under the terms of the * Eclipse Public License v2.0 which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-v20.html * * SPDX-License-Identifier: EPL-2.0 * * Copyright Contributors to the Zowe Project. * */ Object.defineProperty(exports, "__esModule", { value: true }); exports.SshSession = void 0; const imperative_1 = require("@zowe/imperative"); /** * Utility Methods for Zowe * @export */ class SshSession { /** * Obtain session info and defaults * @readonly * @type {ISession} * @memberof AbstractSession */ get ISshSession() { return this.mISshSession; } /** * Given command line arguments, create an SSH session configuration object. * @param {ICommandArguments} args - The arguments specified by the user * @returns {ISshSession} - A session configuration to be used for an SSH session. */ static createSshSessCfgFromArgs(args) { return { privateKey: args.privateKey, keyPassphrase: args.keyPassphrase, handshakeTimeout: args.handshakeTimeout }; } /** * Creates an instance of AbstractSession. * @param {ISshSession} session: SshSession parameter object */ constructor(mISshSession) { this.mISshSession = mISshSession; mISshSession = this.buildSession(mISshSession); } static get log() { return imperative_1.Logger.getAppLogger(); } /** * Builds an ISshSession so all required pieces are filled in * @private * @param {ISession} session - the fully populated session * @memberof AbstractSession */ buildSession(session) { const populatedSession = session; // set port if not set if (populatedSession.port === undefined || populatedSession.port === null) { populatedSession.port = SshSession.DEFAULT_SSH_PORT; } return populatedSession; } } exports.SshSession = SshSession; /** * Default ssh port 22 * @static * @memberof AbstractSession */ SshSession.DEFAULT_SSH_PORT = 22; SshSession.SSH_CONNECTION_OPTION_GROUP = "z/OS Ssh Connection Options"; /** * Option used in profile creation and commands for hostname for z/OS SSH */ SshSession.SSH_OPTION_HOST = { name: "host", aliases: ["H"], description: "The z/OS SSH server host name.", type: "string", required: false, group: SshSession.SSH_CONNECTION_OPTION_GROUP }; /** * Option used in profile creation and commands for port for z/OS SSH */ SshSession.SSH_OPTION_PORT = { name: "port", aliases: ["P"], description: "The z/OS SSH server port.", type: "number", defaultValue: 22, group: SshSession.SSH_CONNECTION_OPTION_GROUP }; /** * Option used in profile creation and commands for username / ID for z/OS SSH */ SshSession.SSH_OPTION_USER = { name: "user", aliases: ["u"], description: "Mainframe user name, which can be the same as your TSO login.", type: "string", required: false, group: SshSession.SSH_CONNECTION_OPTION_GROUP }; /** * Option used in profile creation and commands for password/passphrase for z/OS SSH */ SshSession.SSH_OPTION_PASSWORD = { name: "password", aliases: ["pass", "pw"], description: "Mainframe password, which can be the same as your TSO password.", type: "string", group: SshSession.SSH_CONNECTION_OPTION_GROUP }; /** * Option used in profile creation and commands for private key path */ SshSession.SSH_OPTION_PRIVATEKEY = { name: "privateKey", aliases: ["key", "pk"], description: "Path to a file containing your private key, that must match a public key stored in the server for authentication", type: "string", group: SshSession.SSH_CONNECTION_OPTION_GROUP }; /** * Option used in profile creation and commands for passphrase for private key */ SshSession.SSH_OPTION_KEYPASSPHRASE = { name: "keyPassphrase", aliases: ["passphrase", "kp"], description: "Private key passphrase, which unlocks the private key.", type: "string", group: SshSession.SSH_CONNECTION_OPTION_GROUP }; /** * Option used in profile creation to set handshake timeout. If unset, defaults to no timeout. */ SshSession.SSH_OPTION_HANDSHAKETIMEOUT = { name: "handshakeTimeout", aliases: ["timeout", "to"], description: "How long in milliseconds to wait for the SSH handshake to complete.", type: "number", group: SshSession.SSH_CONNECTION_OPTION_GROUP }; /** * Options related to connecting to z/OS SSH * These options can be filled in if the user creates a profile */ SshSession.SSH_CONNECTION_OPTIONS = [ SshSession.SSH_OPTION_HOST, SshSession.SSH_OPTION_PORT, SshSession.SSH_OPTION_USER, SshSession.SSH_OPTION_PASSWORD, SshSession.SSH_OPTION_PRIVATEKEY, SshSession.SSH_OPTION_KEYPASSPHRASE, SshSession.SSH_OPTION_HANDSHAKETIMEOUT ]; //# sourceMappingURL=SshSession.js.map