justinkalland / protonmail-api Goto Github PK
View Code? Open in Web Editor NEW✉ Node.js API for ProtonMail
License: MIT License
✉ Node.js API for ProtonMail
License: MIT License
$ npm install --save protonmail-api
> [email protected] install/nodetube/node_modules/puppeteer
> node install.js
nodetube/node_modules/puppeteer/install.js:175
} catch {
^
SyntaxError: Unexpected token {
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:617:28)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Function.Module.runMain (module.js:694:10)
at startup (bootstrap_node.js:204:16)
at bootstrap_node.js:625:3
Adding TypeScript typings would be great for those that use TypeScript (like me)
how to get latest email , the body of the mail
Hi!
Thank you for your project, but did you try or is there a way how to run this inside browser extension? Afaik I have setup webpack build for cross-browser extension but it finished on some Puppeteer issue with running "ws" / websockets ....
In general - my idea was to (thanks to your API) to send, receive and assign to folders specially formatted emails that contains data about events (maybe use some of well-known format mime/type) and make the extension that will work as Calendar fetching and parsing this data from private PM folder .... but I failed for now.
Maybe, the workaround can be to wrap it inside the Electron container and make the desktop app?
I found it very useful to have the unread
field from the email.
This is already brought to us by the API:
function isEmailUnread(email) {
return email._data.Unread;
}
const pm = await ProtonMail.connect({
username: '[email protected]',
password: 'password'
})
D:\projects\project\node_modules\puppeteer\lib\cjs\puppeteer\common\DOMWorld.js:513
const timeoutError = new Errors_js_1.TimeoutError(`waiting for ${options.title} failed: timeout ${options.timeout}ms exceeded`);
^
TimeoutError: waiting for selector `#login_btn` failed: timeout 30000ms exceeded
at new WaitTask (D:\projects\project\node_modules\puppeteer\lib\cjs\puppeteer\common\DOMWorld.js:513:34)
at DOMWorld.waitForSelectorInPage (D:\projects\project\node_modules\puppeteer\lib\cjs\puppeteer\common\DOMWorld.js:424:26)
at Object.internalHandler.waitFor (D:\projects\project\node_modules\puppeteer\lib\cjs\puppeteer\common\QueryHandler.js:31:77)
at DOMWorld.waitForSelector (D:\projects\project\node_modules\puppeteer\lib\cjs\puppeteer\common\DOMWorld.js:317:29)
at Frame.waitForSelector (D:\projects\project\node_modules\puppeteer\lib\cjs\puppeteer\common\FrameManager.js:841:51)
at Page.waitForSelector (D:\projects\project\node_modules\puppeteer\lib\cjs\puppeteer\common\Page.js:2313:33)
at ProtonMail._connect (D:\projects\project\node_modules\protonmail-api\lib\proton-mail.js:57:16)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Function.connect (D:\projects\project\node_modules\protonmail-api\lib\proton-mail.js:31:5)
at async D:\projects\project\old\protonmail\test.js:6:16
Node.js v17.1.0
I am using this to automate sending an email from a raspberry pi security camera setup so adding attachments(i.e.picture or video) in the sendMail() would be great. I'll do my best to try and come up with a PR eventually. It will just take some time.
const pm = await ProtonMail.connect({
username: '[email protected]',
password: '111'
})
await pm.sendEmail({
to: '[email protected]',
subject: 'Send email tutorial',
body: 'Hello world'
})
pm.close()
Error: spawn Unknown system error -86
at ChildProcess.spawn (node:internal/child_process:413:11)
at Object.spawn (node:child_process:757:9)
at BrowserRunner.start (/Users/a002211/Desktop/info-getter/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:80:34)
at ChromeLauncher.launch (/Users/a002211/Desktop/info-getter/node_modules/puppeteer/lib/cjs/puppeteer/node/Launcher.js:94:16)
at async ProtonMail._connect (/Users/a002211/Desktop/info-getter/node_modules/protonmail-api/lib/proton-mail.js:50:23)
at async ProtonMail.connect (/Users/a002211/Desktop/info-getter/node_modules/protonmail-api/lib/proton-mail.js:31:5)
at async sendMail (/Users/a002211/Desktop/info-getter/app.js:8:16)
at async Server. (/Users/a002211/Desktop/info-getter/app.js:32:9) {
errno: -86,
code: 'Unknown system error -86',
syscall: 'spawn'
}
Hi 👋🏼 ! I just found your library and is really useful. Reading through the documentation and following the "viagra" example, I found out that if the user has another theme selected (in my case Carbon
), the scrapper fails with the following error:
...
TimeoutError: waiting for selector `#ptSidebar` failed: timeout 30000ms exceeded
...
I know that it may be difficult to handle all the themes, but I think it should be mentioned in the initial README description so new users don't struggle finding out why this is happening.
node -v
v13.9.0
typeof(ProtonMail(node:13204) UnhandledPromiseRejectionWarning: TimeoutError: waiting for selector "#ptSidebar" failed: timeout 30000ms eptceeded
at new WaitTask (/Users/pt/code/node_modules/puppeteer/lib/DOMWorld.js:388:34)
at DOMWorld._waitForSelectorOrptPath (/Users/pt/code/node_modules/puppeteer/lib/DOMWorld.js:313:26)
at DOMWorld.waitForSelector (/Users/pt/code/node_modules/puppeteer/lib/DOMWorld.js:296:21)
at Frame.waitForSelector (/Users/pt/code/node_modules/puppeteer/lib/FrameManager.js:384:51)
at Frame. (/Users/pt/code/node_modules/puppeteer/lib/helper.js:95:27)
at Page.waitForSelector (/Users/pt/code/node_modules/puppeteer/lib/Page.js:799:33)
at ProtonMail._connect (/Users/pt/code/node_modules/protonmail-api/lib/proton-mail.js:59:16)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async Function.connect (/Users/pt/code/node_modules/protonmail-api/lib/proton-mail.js:30:5)
at async repl:2:14
When using an invalid username and/or password an error is not returned. Instead the program just hangs.
Likely a promise never returns (we await for certain conditions in Puppeteer)
I have become fond of Conventional Commits and would like to use it on all my OSS repos.
Tests are running fine locally, but setup times out on GitHub Actions Workflow.
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: '[email protected]',
password: 'somethingsecure',
puppeteerOpts: {args: ['--proxy-server=socks5://127.0.0.1:9050','--no-sandbox', '--disable-setuid-sandbox']}
})
await pm.sendEmail({
to: '[email protected]',
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.
Implementing standard-version will help automate releasing new versions of the package (as well as automatic changelogs).
standard-version
packagerelease
and pre-release
scripts (see jwt-guard
for example)Blocked by #4
Hello,
Could you add the ability to add 2FA token in order to automatically get the codes ?
Thanks !
Is it possible to send attachments via your API? If so, I'll happily work on a PR for that feature. However, I'm wondering if this is something you tried to implement already and couldn't. If that is the case, I won't spend the time.
Since you're using puppeteer, it should be feasible to click the attachment button. Just unclear on how to transmit the document and attach it via the headless browser session.
Any thoughts?
Thanks!
Where do we enter the protonmail mailbox password?
Presumably newer accounts no longer use this..
Wouldn't it be nice to fix that?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.