add otplib to generate OTP from key for eg, pg; gog only has mail
This commit is contained in:
parent
9e0d4434fe
commit
1a3d90f795
6 changed files with 141 additions and 3 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import { firefox } from 'playwright'; // stealth plugin needs no outdated playwright-extra
|
||||
import { authenticator } from 'otplib';
|
||||
import path from 'path';
|
||||
import { dirs, jsonDb, datetime, stealth, filenamify } from './util.js';
|
||||
import { cfg } from './config.js';
|
||||
|
|
@ -61,7 +62,7 @@ try {
|
|||
page.waitForNavigation({ url: '**/ap/mfa**'}).then(async () => {
|
||||
console.log('Two-Step Verification - enter the One Time Password (OTP), e.g. generated by your Authenticator App');
|
||||
await page.check('[name=rememberDevice]');
|
||||
const otp = 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
|
||||
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 page.type('input[name=otpCode]', otp.toString());
|
||||
await page.click('input[type="submit"]');
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue