@timshel_npm/maildev 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/LICENSE +16 -0
  2. package/README.md +287 -0
  3. package/bin/maildev +13 -0
  4. package/dist/app/components/angular/angular.js +20282 -0
  5. package/dist/app/components/angular/angular.min.js +201 -0
  6. package/dist/app/components/angular/angular.min.js.map +8 -0
  7. package/dist/app/components/angular-cookies/angular-cookies.js +202 -0
  8. package/dist/app/components/angular-cookies/angular-cookies.min.js +8 -0
  9. package/dist/app/components/angular-cookies/angular-cookies.min.js.map +8 -0
  10. package/dist/app/components/angular-resource/angular-resource.js +546 -0
  11. package/dist/app/components/angular-resource/angular-resource.min.js +12 -0
  12. package/dist/app/components/angular-resource/angular-resource.min.js.map +8 -0
  13. package/dist/app/components/angular-route/angular-route.js +891 -0
  14. package/dist/app/components/angular-route/angular-route.min.js +14 -0
  15. package/dist/app/components/angular-route/angular-route.min.js.map +8 -0
  16. package/dist/app/components/angular-sanitize/angular-sanitize.js +615 -0
  17. package/dist/app/components/angular-sanitize/angular-sanitize.min.js +14 -0
  18. package/dist/app/components/angular-sanitize/angular-sanitize.min.js.map +8 -0
  19. package/dist/app/components/socket.io/socket.io.min.js +7 -0
  20. package/dist/app/favicon.ico +0 -0
  21. package/dist/app/index.html +176 -0
  22. package/dist/app/scripts/app.js +68 -0
  23. package/dist/app/scripts/components/address.js +15 -0
  24. package/dist/app/scripts/controllers/item.js +191 -0
  25. package/dist/app/scripts/controllers/main.js +259 -0
  26. package/dist/app/scripts/services.js +84 -0
  27. package/dist/app/styles/style.css +37 -0
  28. package/dist/app/views/address.html +3 -0
  29. package/dist/app/views/item.html +310 -0
  30. package/dist/app/views/main.html +18 -0
  31. package/dist/app/webfonts/fa-brands-400.eot +0 -0
  32. package/dist/app/webfonts/fa-brands-400.svg +3717 -0
  33. package/dist/app/webfonts/fa-brands-400.ttf +0 -0
  34. package/dist/app/webfonts/fa-brands-400.woff +0 -0
  35. package/dist/app/webfonts/fa-brands-400.woff2 +0 -0
  36. package/dist/app/webfonts/fa-regular-400.eot +0 -0
  37. package/dist/app/webfonts/fa-regular-400.svg +801 -0
  38. package/dist/app/webfonts/fa-regular-400.ttf +0 -0
  39. package/dist/app/webfonts/fa-regular-400.woff +0 -0
  40. package/dist/app/webfonts/fa-regular-400.woff2 +0 -0
  41. package/dist/app/webfonts/fa-solid-900.eot +0 -0
  42. package/dist/app/webfonts/fa-solid-900.svg +5028 -0
  43. package/dist/app/webfonts/fa-solid-900.ttf +0 -0
  44. package/dist/app/webfonts/fa-solid-900.woff +0 -0
  45. package/dist/app/webfonts/fa-solid-900.woff2 +0 -0
  46. package/dist/index.d.ts +26 -0
  47. package/dist/index.js +50 -0
  48. package/dist/lib/auth.d.ts +4 -0
  49. package/dist/lib/auth.js +26 -0
  50. package/dist/lib/helpers/bcc.d.ts +5 -0
  51. package/dist/lib/helpers/bcc.js +16 -0
  52. package/dist/lib/helpers/smtp.d.ts +4 -0
  53. package/dist/lib/helpers/smtp.js +16 -0
  54. package/dist/lib/helpers/strtotime.d.ts +2 -0
  55. package/dist/lib/helpers/strtotime.js +1301 -0
  56. package/dist/lib/logger.d.ts +2 -0
  57. package/dist/lib/logger.js +30 -0
  58. package/dist/lib/mailbuffer.d.ts +21 -0
  59. package/dist/lib/mailbuffer.js +102 -0
  60. package/dist/lib/mailparser.d.ts +2 -0
  61. package/dist/lib/mailparser.js +253 -0
  62. package/dist/lib/mailserver.d.ts +115 -0
  63. package/dist/lib/mailserver.js +497 -0
  64. package/dist/lib/options.d.ts +3 -0
  65. package/dist/lib/options.js +150 -0
  66. package/dist/lib/outgoing.d.ts +40 -0
  67. package/dist/lib/outgoing.js +162 -0
  68. package/dist/lib/routes.d.ts +2 -0
  69. package/dist/lib/routes.js +139 -0
  70. package/dist/lib/type.d.ts +228 -0
  71. package/dist/lib/type.js +2 -0
  72. package/dist/lib/utils.d.ts +4 -0
  73. package/dist/lib/utils.js +65 -0
  74. package/dist/lib/web.d.ts +32 -0
  75. package/dist/lib/web.js +90 -0
  76. package/package.json +109 -0
package/LICENSE ADDED
@@ -0,0 +1,16 @@
1
+ Copyright (c) 2023 Dan Farrelly
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
11
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
13
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
14
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
15
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
16
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,287 @@
1
+ # MailDev
2
+ [![Docker Pulls](https://img.shields.io/docker/pulls/timshel/maildev)](https://hub.docker.com/r/timshel/maildev)
3
+ [![License](https://img.shields.io/npm/l/maildev?color=white)](/LICENSE)
4
+ [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-black.svg)](https://prettier.io/)
5
+
6
+
7
+ > This is a fork of ⭐️ **[maildev/maildev](https://github.com/maildev/maildev)** with a focus on a better api for Playwright tests.
8
+ >
9
+ > The goal of the fork is to:
10
+ > - Update dependencies
11
+ > - Swtich to TypeScript
12
+ > - Add more event listeners method
13
+ > - Add async support
14
+ > - Add additionnal features
15
+ > - `mailEventSubjectMapper` allow to define custom event `subject` (by default use the first recipient)
16
+ > - `MailBuffer` allows to easily query and `await` emails
17
+ >
18
+ > :warning: Due to extensive mofitications migrate with caution. :warning:
19
+
20
+ **MailDev** is a simple way to test your project's generated email during development, with an easy to use web interface that runs on your machine built on top of [Node.js](http://www.nodejs.org).
21
+
22
+ ![MailDev Screenshot](https://github.com/maildev/maildev/blob/gh-pages/images/screenshot-2021-01-03.png?raw=true)
23
+
24
+ ## Npm / Yarn
25
+
26
+ It's not published on `npm` but due to [Github](https://docs.npmjs.com/cli/v10/configuring-npm/package-json#git-urls-as-dependencies) support you can use it with:
27
+
28
+ ```
29
+ "maildev": "timshel/maildev#3.1.0"
30
+ ```
31
+
32
+ ## API
33
+
34
+ MailDev can be used in your Node.js application. For more info view the [API docs](https://github.com/timshel/maildev/blob/master/docs/api.md).
35
+
36
+ Example in a Playwright test:
37
+ ```javascript
38
+ import { test, expect, type TestInfo } from '@playwright/test';
39
+ import { MailDev } from 'maildev';
40
+
41
+ let mailserver;
42
+
43
+ test.beforeAll('Setup', async ({ browser }, testInfo: TestInfo) => {
44
+ mailserver = new MailDev({
45
+ port: process.env.MAILDEV_SMTP_PORT,
46
+ web: { port: process.env.MAILDEV_HTTP_PORT },
47
+ })
48
+
49
+ await mailserver.listen();
50
+ });
51
+
52
+ test.afterAll('Teardown', async ({}) => {
53
+ utils.stopVault();
54
+ if( mailserver ){
55
+ await mailserver.close();
56
+ }
57
+ });
58
+
59
+ test('2fa', async ({ page }) => {
60
+ const mailBuffer = mailserver.buffer("test@yopmail.com");
61
+
62
+ await test.step('login', async () => {
63
+ await page.goto('/');
64
+
65
+ await page.getByLabel(/Email address/).fill("test@yopmail.com");
66
+ await page.getByRole('button', { name: 'Continue' }).click();
67
+ await page.getByLabel('Master password').fill("test@yopmail.com");
68
+ await page.getByRole('button', { name: 'Log in with master password' }).click();
69
+
70
+ const code = await test.step('retrieve code', async () => {
71
+ const codeMail = await mailBuffer.expect((mail) => mail.subject.includes("Login Verification Code"));
72
+ const page2 = await page.context().newPage();
73
+ await page2.setContent(codeMail.html);
74
+ const code = await page2.getByTestId("2fa").innerText();
75
+ await page2.close();
76
+ return code;
77
+ });
78
+
79
+ await page.getByLabel(/Verification code/).fill(code);
80
+ await page.getByRole('button', { name: 'Continue' }).click();
81
+ await expect(page).toHaveTitle(/Vaults/);
82
+
83
+ await mailBuffer.expect((m) => m.subject === "Welcome");
84
+ await mailBuffer.expect((m) => m.subject === "New Device Logged In From Firefox");
85
+ })
86
+
87
+ mailBuffer.close();
88
+ });
89
+
90
+ ```
91
+
92
+ MailDev also has a **REST API**. For more info
93
+ [view the docs](https://github.com/timshel/maildev/blob/master/docs/rest.md).
94
+
95
+ ## Docker Run
96
+
97
+ If you want to use MailDev with [Docker](https://www.docker.com/), you can use the
98
+ [**timshel/maildev** image on Docker Hub](https://hub.docker.com/r/timshel/maildev).
99
+ For a guide for usage with Docker,
100
+ [checkout the docs](https://github.com/timshel/maildev/blob/master/docs/docker.md).
101
+
102
+ $ docker run -p 1080:1080 -p 1025:1025 timshel/maildev
103
+
104
+ By default the following environment variables are set:
105
+
106
+ - MAILDEV_WEB_PORT=1080
107
+ - MAILDEV_SMTP_PORT=1025
108
+ - MAILDEV_MAIL_DIRECTORY=/tmp/maildev
109
+
110
+ ## Usage
111
+
112
+ ```
113
+ Usage: maildev [options]
114
+ ```
115
+
116
+ | Options | Environment variable | Description |
117
+ | -------------------------------- | -------------------------- | ----------------------------------------------------------------------------------------- |
118
+ | `-s, --smtp <port>` | `MAILDEV_SMTP_PORT` | SMTP port to catch mail |
119
+ | `-w, --web <port>` | `MAILDEV_WEB_PORT` | Port to run the Web GUI |
120
+ | `--mail-directory <path>` | `MAILDEV_MAIL_DIRECTORY` | Directory for persisting mail |
121
+ | `--https` | `MAILDEV_HTTPS` | Switch from http to https protocol |
122
+ | `--https-key <file>` | `MAILDEV_HTTPS_KEY` | The file path to the ssl private key |
123
+ | `--https-cert <file>` | `MAILDEV_HTTPS_CERT` | The file path to the ssl cert file |
124
+ | `--ip <ip address>` | `MAILDEV_IP` | IP Address to bind SMTP service to |
125
+ | `--outgoing-host <host>` | `MAILDEV_OUTGOING_HOST` | SMTP host for outgoing mail |
126
+ | `--outgoing-port <port>` | `MAILDEV_OUTGOING_PORT` | SMTP port for outgoing mail |
127
+ | `--outgoing-user <user>` | `MAILDEV_OUTGOING_USER` | SMTP user for outgoing mail |
128
+ | `--outgoing-pass <password>` | `MAILDEV_OUTGOING_PASS` | SMTP password for outgoing mail |
129
+ | `--outgoing-secure` | `MAILDEV_OUTGOING_SECURE` | Use SMTP SSL for outgoing mail |
130
+ | `--auto-relay [email]` | `MAILDEV_AUTO_RELAY` | Use auto-relay mode. Optional relay email address |
131
+ | `--auto-relay-rules <file>` | `MAILDEV_AUTO_RELAY_RULES` | Filter rules for auto relay mode |
132
+ | `--incoming-user <user>` | `MAILDEV_INCOMING_USER` | SMTP user for incoming mail |
133
+ | `--incoming-pass <pass>` | `MAILDEV_INCOMING_PASS` | SMTP password for incoming mail |
134
+ | `--incoming-secure` | `MAILDEV_INCOMING_SECURE` | Use SMTP SSL for incoming emails |
135
+ | `--incoming-cert <path>` | `MAILDEV_INCOMING_CERT` | Cert file location for incoming SSL |
136
+ | `--incoming-key <path>` | `MAILDEV_INCOMING_KEY` | Key file location for incoming SSL |
137
+ | `--web-ip <ip address>` | `MAILDEV_WEB_IP` | IP Address to bind HTTP service to, defaults to --ip |
138
+ | `--web-user <user>` | `MAILDEV_WEB_USER` | HTTP user for GUI |
139
+ | `--web-pass <password>` | `MAILDEV_WEB_PASS` | HTTP password for GUI |
140
+ | `--base-pathname <path>` | `MAILDEV_BASE_PATHNAME` | Base path for URLs |
141
+ | `--disable-web` | `MAILDEV_DISABLE_WEB` | Disable the use of the web interface. Useful for unit testing |
142
+ | `--hide-extensions <extensions>` | `MAILDEV_HIDE_EXTENSIONS` | Comma separated list of SMTP extensions to NOT advertise (SMTPUTF8, PIPELINING, 8BITMIME) |
143
+ | `-o, --open` | | Open the Web GUI after startup |
144
+ | `-v, --verbose` | | |
145
+ | `--silent` | | |
146
+ | `--log-mail-contents` | | Log a JSON representation of each incoming mail |
147
+
148
+
149
+ ## Outgoing email
150
+
151
+ Maildev optionally supports selectively relaying email to an outgoing SMTP server. If you configure outgoing
152
+ email with the --outgoing-* options you can click "Relay" on an individual email to relay through MailDev out
153
+ to a real SMTP service that will *actually\* send the email to the recipient.
154
+
155
+ Example:
156
+
157
+ $ maildev --outgoing-host smtp.gmail.com \
158
+ --outgoing-secure \
159
+ --outgoing-user 'you@gmail.com' \
160
+ --outgoing-pass '<pass>'
161
+
162
+ ### Auto relay mode
163
+
164
+ Enabling the auto relay mode will automatically send each email to it's recipient
165
+ without the need to click the "Relay" button mentioned above.
166
+ The outgoing email options are required to enable this feature.
167
+
168
+ Optionally you may pass an single email address which Maildev will forward all
169
+ emails to instead of the original recipient. For example, using
170
+ `--auto-relay you@example.com` will forward all emails to that address
171
+ automatically.
172
+
173
+ Additionally, you can pass a valid json file with additional configuration for
174
+ what email addresses you would like to `allow` or `deny`. The last matching
175
+ rule in the array will be the rule MailDev will follow.
176
+
177
+ Example:
178
+
179
+ $ maildev --outgoing-host smtp.gmail.com \
180
+ --outgoing-secure \
181
+ --outgoing-user 'you@gmail.com' \
182
+ --outgoing-pass '<pass>' \
183
+ --auto-relay \
184
+ --auto-relay-rules file.json
185
+
186
+ Rules example file:
187
+
188
+ ```javascript
189
+ [
190
+ { "allow": "*" },
191
+ { "deny": "*@test.com" },
192
+ { "allow": "ok@test.com" },
193
+ { "deny": "*@utah.com" },
194
+ { "allow": "johnny@utah.com" }
195
+ ]
196
+ ```
197
+
198
+ This would allow `angelo@fbi.gov`, `ok@test.com`, `johnny@utah.com`, but deny
199
+ `bodhi@test.com`.
200
+
201
+ ## Configure your project
202
+
203
+ Configure your application to send emails via port `1025` and open `localhost:1080` in your browser.
204
+
205
+ **Nodemailer (v1.0+)**
206
+
207
+ ```javascript
208
+ // We add this setting to tell nodemailer the host isn't secure during dev
209
+ process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
210
+
211
+ const transport = nodemailer.createTransport({
212
+ port: 1025,
213
+ // other settings...
214
+ });
215
+ ```
216
+
217
+ **Django** -- Add `EMAIL_PORT = 1025` in your settings file [[source]](https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-EMAIL_PORT)
218
+
219
+ **Rails** -- config settings:
220
+
221
+ ```ruby
222
+ config.action_mailer.delivery_method = :smtp
223
+ config.action_mailer.smtp_settings = {
224
+ address: "localhost",
225
+ port: 1025,
226
+ enable_starttls_auto: false
227
+ }
228
+ ```
229
+
230
+ **Drupal** -- Install and configure [SMTP](https://www.drupal.org/project/smtp) module or use a library like [SwiftMailer](http://swiftmailer.org/).
231
+
232
+ ## Features
233
+
234
+ - Toggle between HTML, plain text views as well as view email headers
235
+ - Test responsive emails with resizable preview pane available for various screen sizes
236
+ - Ability to receive and view email attachments
237
+ - WebSocket integration keeps the interface in sync once emails are received
238
+ - Command line interface for configuring SMTP and web interface ports
239
+ - Ability to relay email to an upstream SMTP server
240
+
241
+ ## Ideas
242
+
243
+ If you're using MailDev and you have a great idea, I'd love to hear it. If you're not using MailDev because it lacks a feature, I'd love to hear that too. Add an issue to the repo [here](https://github.com/timshel/maildev/issues/new).
244
+
245
+ ## Contributing
246
+
247
+ Any help on MailDev would be awesome. There is plenty of room for improvement. Feel free to [create a Pull Request](https://github.com/timshel/maildev/issues/new) from small to big changes.
248
+
249
+ To run **MailDev** during development:
250
+
251
+ npm install
252
+ npm run dev
253
+
254
+ The "dev" task will run MailDev using nodemon and restart automatically when
255
+ changes are detected. On `*.scss` file save, the css will also be recompiled.
256
+ Using `test/send.js`, a few test emails will be sent every time the application
257
+ restarts.
258
+
259
+ If you want to debug you can use the `nodemon` debug profile in VSCode. To change arguments or environment variables edit the `.vscode\launch.json`.
260
+
261
+ The project uses the [JavaScript Standard coding style](https://standardjs.com).
262
+ To lint your code before submitting your PR, run `npm run lint`.
263
+
264
+ To run the test suite:
265
+
266
+ $ npm test
267
+
268
+ ## [Changelog](https://github.com/maildev/maildev/releases)
269
+
270
+ ## Thanks
271
+
272
+ **MailDev** is built on using great open source projects including
273
+ [Express](http://expressjs.com),
274
+ [AngularJS](http://angularjs.org/),
275
+ [Font Awesome](http://fontawesome.io/) and two great projects from
276
+ [Andris Reinman](https://github.com/andris9):
277
+ [smtp-server](https://github.com/nodemailer/smtp-server)
278
+ and [mailparser](https://github.com/nodemailer/mailparser).
279
+ Many thanks to Andris as his projects are the backbone of this app and to
280
+ [MailCatcher](http://mailcatcher.me/) for the inspiration.
281
+
282
+ Additionally, thanks to all the awesome [contributors](https://github.com/maildev/maildev/graphs/contributors)
283
+ to the project.
284
+
285
+ ## License
286
+
287
+ MIT
package/bin/maildev ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env node
2
+
3
+ const path = require('path')
4
+ const fs = require('fs')
5
+
6
+ const root = path.join(path.dirname(fs.realpathSync(__filename)), '../dist')
7
+
8
+ const MailDev = require(`${root}/index`).MailDev
9
+ const cliOptions = require(`${root}/lib/options`).cliOptions
10
+
11
+ const options = cliOptions();
12
+ const maildev = new MailDev(options);
13
+ maildev.listen();