UNPKG

bugyo-cloud-client

Version:
55 lines 2.64 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.LoginTask = void 0; const authenticate_1 = require("../endpoints/authenticate"); const check_authentication_method_1 = require("../endpoints/check-authentication-method"); const login_page_1 = require("../endpoints/login-page"); const top_page_1 = require("../endpoints/top-page"); /** * ログイン実行します。 */ class LoginTask { constructor(authInfo, loggerFactory) { this.authInfo = authInfo; this.loggerFactory = loggerFactory; this.logger = loggerFactory.getLogger(LoginTask.name); } execute(client) { return __awaiter(this, void 0, void 0, function* () { this.logger.trace("Trying to get the login page token."); const token = yield this.getLoginPageToken(client); yield this.checkAuthMethod(client, token); this.logger.trace("Trying to get the redirect url."); const url = yield this.authenticate(client, token); yield this.setupUserCode(client, url); }); } getLoginPageToken(client) { return new login_page_1.LoginPage(this.loggerFactory).invoke(client); } checkAuthMethod(client, token) { return new check_authentication_method_1.CheckAuthenticationMethod(this.loggerFactory).invoke(client, token, this.authInfo); } authenticate(client, token) { return new authenticate_1.Authenticate(this.loggerFactory).invoke(client, token, this.authInfo); } setupUserCode(client, url) { return __awaiter(this, void 0, void 0, function* () { const topPage = new top_page_1.TopPage(this.loggerFactory); const userCode = yield topPage.invoke(client, url); this.logger.debug("UserCode retrieved.", userCode); client.param.userCode = userCode; }); } } exports.LoginTask = LoginTask; //# sourceMappingURL=login-task.js.map