dev #1

Merged
nocci merged 51 commits from dev into main 2026-03-06 16:31:29 +01:00
Showing only changes of commit 0340873d91 - Show all commits

View file

@ -34,6 +34,17 @@ await page.setViewportSize({ width: cfg.width, height: cfg.height }); // workaro
const notify_games = []; const notify_games = [];
let user; let user;
const handleMFA = async p => {
const otpField = p.locator('#auth-mfa-otpcode, input[name=otpCode]');
if (!await otpField.count()) return false;
console.log('Two-Step Verification - enter the One Time Password (OTP), e.g. generated by your Authenticator App');
await p.locator('#auth-mfa-remember-device, [name=rememberDevice]').check().catch(() => {});
const otp = cfg.pg_otpkey && authenticator.generate(cfg.pg_otpkey) || await prompt({ type: 'text', message: 'Enter two-factor sign in code', validate: n => n.toString().length == 6 || 'The code must be 6 digits!' }); // can't use type: 'number' since it strips away leading zeros and codes sometimes have them
await otpField.first().pressSequentially(otp.toString());
await p.locator('input[type="submit"], button[type="submit"]').first().click();
return true;
};
const waitForSignedInOrMFA = async p => { const waitForSignedInOrMFA = async p => {
const otpLocator = p.locator('#auth-mfa-otpcode, input[name=otpCode]'); const otpLocator = p.locator('#auth-mfa-otpcode, input[name=otpCode]');
const waitSignedIn = p.waitForURL('**/claims/**signedIn=true', { timeout: cfg.login_timeout }).then(() => true).catch(() => false); const waitSignedIn = p.waitForURL('**/claims/**signedIn=true', { timeout: cfg.login_timeout }).then(() => true).catch(() => false);
@ -54,17 +65,6 @@ const waitForSignedInOrMFA = async p => {
await Promise.race([waitSignedIn, waitMFA]); await Promise.race([waitSignedIn, waitMFA]);
}; };
const handleMFA = async p => {
const otpField = p.locator('#auth-mfa-otpcode, input[name=otpCode]');
if (!await otpField.count()) return false;
console.log('Two-Step Verification - enter the One Time Password (OTP), e.g. generated by your Authenticator App');
await p.locator('#auth-mfa-remember-device, [name=rememberDevice]').check().catch(() => {});
const otp = cfg.pg_otpkey && authenticator.generate(cfg.pg_otpkey) || await prompt({ type: 'text', message: 'Enter two-factor sign in code', validate: n => n.toString().length == 6 || 'The code must be 6 digits!' }); // can't use type: 'number' since it strips away leading zeros and codes sometimes have them
await otpField.first().pressSequentially(otp.toString());
await p.locator('input[type="submit"], button[type="submit"]').first().click();
return true;
};
try { try {
await page.goto(URL_CLAIM, { waitUntil: 'domcontentloaded' }); // default 'load' takes forever await page.goto(URL_CLAIM, { waitUntil: 'domcontentloaded' }); // default 'load' takes forever
const handleDirectLoginPage = async () => { const handleDirectLoginPage = async () => {