justinkalland/protonmail-api

Launch options

Opened this issue · 0 comments

Quick question: how do I specify "config.puppeteerOpts puppeteer launch options"

If you were to use a Tor proxy to launch the puppeteer as such:

"const browser = await puppeteer.launch({headless:true, args: ['--proxy-server=socks5://127.0.0.1:9050','--no-sandbox', '--disable-setuid-sandbox']})"

How would you specify that option when sending an email - I can of course hardcode it into your proton-mail.js module, but is there a way to specify the option without rewriting your code when sending emails?

Many thanks - great project.

---- FOLLOW UP ----

I just found this doc: file:///Users/master/code/protonmail-api/docs/ProtonMail.html

Does that mean the following code would solve the above issue?

const ProtonMail = require('protonmail-api');

(async () => {
const pm = await ProtonMail.connect({
username: 'foobar@protonmail.com',
password: 'somethingsecure',
puppeteerOpts: {args: ['--proxy-server=socks5://127.0.0.1:9050','--no-sandbox', '--disable-setuid-sandbox']}
})

await pm.sendEmail({
to: 'justin@kalland.ch',
subject: 'Send email tutorial',
body: 'Hello world'
})

pm.close()
})()

ANSWER: Yes this is how it works. I tested it by modifying the proton-mail.js as follows:

if (this._browser === undefined) {
// console.log(typeof this._config.puppeteerOpts)
this._browser = await puppeteer.launch({ headless: false, ...this._config.puppeteerOpts })
this._page = await this._browser.newPage()
}

const page = this._page
await page.goto('https://api.ipify.org')

This opens the Chromium browser with your IP and the IP is a Tor IP.