Coder Social home page Coder Social logo

protonmail-api's People

Contributors

dependabot[bot] avatar justinkalland avatar ltimelordl avatar nobiit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

protonmail-api's Issues

Install fails

$ 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

TypeScript typings

Adding TypeScript typings would be great for those that use TypeScript (like me)

Running PM-api in webExtension

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?

Screen Shot 2019-05-14 at 3 52 32 AM

Add Unread to Email

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;
}

Connection Error

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

Adding attachements in sendMail()

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.

Error: spawn Unknown system error -86

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'
}

If a theme different than 'Proton' is selected, breaks

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.

trying to send mail using the given code.

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

Fix CI testing

Tests are running fine locally, but setup times out on GitHub Actions Workflow.

Launch options

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.

Implement standard-version

Implementing standard-version will help automate releasing new versions of the package (as well as automatic changelogs).

  • Add standard-version package
  • Setup release and pre-release scripts (see jwt-guard for example)
  • Add details in contributing documentation

Blocked by #4

Feature Request: Email Attachments

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!

Mailbox password

Where do we enter the protonmail mailbox password?

Presumably newer accounts no longer use this..

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.