import axios from "axios"; import https from "https"; import { load } from "cheerio"; import stringHash from "string-hash"; import fs from "fs"; const { data: res } = await axios.get( "https://accounts.pcid.ca/oauth2/v1/authorize", { params: { client_id: "ed22f54785b74fe688011366a65ed5fb", response_type: "code", scope: "openid api.loblaw.digitalpco offline_access", redirect_uri: "https://pcoptimum.ca/login", }, } ); const $ = load(res); const form = {}; $("form input").each((i, e) => { form[$(e).attr("name")] = $(e).attr("value"); }); const email = "linxiaojoe@hotmail.com"; const password = "Andy123456$"; const hashEmail = (email = "") => { const [username, domain] = email.split("@"); return `${stringHash(username)}@${domain}`; }; try { const httpsAgent = new https.Agent({ rejectUnauthorized: false, host: "192.168.50.202", port: 9090, }); const data = { email, password, loginCtx: form.loginCtx, rememberMe: false, sso: false, mandatory2fa: true, trustToken: null, deviceDetails: '{"currentTime":"Sun Mar 10 2024 02:51:27 GMT+0800 (中国标准时间)","screenWidth":390,"screenHeight":844,"screenColorDepth":24,"screenPixelDepth":24,"windowPixelRatio":3,"language":"zh-CN","userAgent":"Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1","cookieEnabled":true,"mimeTypes":0,"plugins":0,"timeZone":-480}', hashedEmail: hashEmail(email), encodedEmail: btoa(email), }; console.log(JSON.stringify(data, null, 4)); const { data: loginData } = await axios.post( "https://accounts.pcid.ca/login", data ); console.log(loginData); } catch (error) { console.log(error.message); }