UNPKG

@zowe/imperative

Version:
59 lines 1.91 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.Session = void 0; const SessConstants_1 = require("./SessConstants"); const AbstractSession_1 = require("./AbstractSession"); /** * Non-abstract session class * @export * @class Session * @extends {AbstractSession} */ class Session extends AbstractSession_1.AbstractSession { /** * Creates an instance of Session. * @param {ISession} newSession - contains input for new session * @memberof Session */ constructor(newSession) { super(newSession); } /** * Creates an instance of Session from a URL object. * @param {URL} url - URL object from the Node.js `url` library * @param {boolean} includePath - Specifies whether session base path should be populated. Default value is true. * @memberof Session */ static createFromUrl(url, includePath) { const sessCfg = { hostname: url.hostname, user: url.username, password: url.password }; if (url.protocol === "http:" || url.protocol === "https:") { sessCfg.protocol = url.protocol.slice(0, -1); } if (url.port) { sessCfg.port = parseInt(url.port); } if (includePath !== false) { sessCfg.basePath = url.pathname; } if (sessCfg.user != null && sessCfg.password != null) { sessCfg.type = SessConstants_1.AUTH_TYPE_BASIC; } return new this(sessCfg); } } exports.Session = Session; //# sourceMappingURL=Session.js.map