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,8 +1,9 @@
|
|||
import { firefox } from 'playwright'; // stealth plugin needs no outdated playwright-extra
|
||||
import { authenticator } from 'otplib';
|
||||
import path from 'path';
|
||||
import { existsSync, writeFileSync } from 'fs';
|
||||
import { dirs, jsonDb, datetime, stealth, filenamify } from './util.js';
|
||||
import { cfg } from './config.js';
|
||||
import { existsSync, writeFileSync } from 'fs';
|
||||
|
||||
import prompts from 'prompts'; // alternatives: enquirer, inquirer
|
||||
// import enquirer from 'enquirer'; const { prompt } = enquirer;
|
||||
|
|
@ -85,7 +86,7 @@ try {
|
|||
// handle MFA, but don't await it
|
||||
page.waitForNavigation({ url: '**/id/login/mfa**'}).then(async () => {
|
||||
console.log('Enter the security code to continue - This appears to be a new device, browser or location. A security code has been sent to your email address at ...');
|
||||
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.eg_otpkey && authenticator.generate(cfg.eg_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="code-input-0"]', otp.toString());
|
||||
await page.click('button[type="submit"]');
|
||||
}).catch(_ => { });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue