UNPKG

bugyo-cloud-client

Version:
56 lines 2.88 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BugyoCloudClientService = void 0; const undici_1 = require("http-cookie-agent/undici"); const tough_cookie_1 = require("tough-cookie"); const bugyo_cloud_client_1 = require("./bugyo-cloud-client"); const authenticate_1 = require("./endpoints/authenticate"); const call_logout_1 = require("./endpoints/call-logout"); const check_authentication_method_1 = require("./endpoints/check-authentication-method"); const login_page_1 = require("./endpoints/login-page"); const om_redirect_1 = require("./endpoints/om-redirect"); const punchmark_page_1 = require("./endpoints/punchmark-page"); const time_clock_1 = require("./endpoints/time-clock"); const login_task_1 = require("./tasks/login-task"); const logout_task_1 = require("./tasks/logout-task"); const punch_task_1 = require("./tasks/punch-task"); const http_session_1 = require("./utils/http-session"); /** * Create instances */ class BugyoCloudClientService { loggerFactory; constructor(loggerFactory) { this.loggerFactory = loggerFactory; } createClient(tenantCode) { return new bugyo_cloud_client_1.BugyoCloudClient(this.getLogger(bugyo_cloud_client_1.BugyoCloudClient), tenantCode, this.createHttpSession()); } createLoginTask(authInfo) { return new login_task_1.LoginTask(this.getLogger(login_task_1.LoginTask), this.createEndpointInstance(login_page_1.LoginPage), this.createEndpointInstance(check_authentication_method_1.CheckAuthenticationMethod), this.createEndpointInstance(authenticate_1.Authenticate), this.createEndpointInstance(om_redirect_1.OmRedirect), authInfo); } createLogoutTask() { return new logout_task_1.LogoutTask(this.getLogger(logout_task_1.LogoutTask), this.createEndpointInstance(call_logout_1.CallLogout)); } createPunchTask(punchInfo) { return new punch_task_1.PunchTask(this.getLogger(punch_task_1.PunchTask), this.createEndpointInstance(time_clock_1.TimeClock), this.createEndpointInstance(punchmark_page_1.PunchmarkPage), punchInfo); } createHttpSession() { const jar = new tough_cookie_1.CookieJar(); // const agent = new ProxyAgent({ // uri: "http://127.0.0.1:9000", // // Do not verify TLS certificates. // requestTls: { rejectUnauthorized: false }, // }).compose(cookie({ jar })); const agent = new undici_1.CookieAgent({ cookies: { jar } }); return new http_session_1.HttpSession(this.getLogger(http_session_1.HttpSession), agent); } createEndpointInstance(ctor) { return new ctor(this.loggerFactory.getLogger(ctor.name)); } getLogger(cls) { return this.loggerFactory.getLogger(cls.name); } } exports.BugyoCloudClientService = BugyoCloudClientService; //# sourceMappingURL=bugyo-cloud-client-service.js.map