temp-disposable-email 1.8.0 → 1.10.0

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.
package/CHANGELOG.md CHANGED
@@ -1,55 +1,51 @@
1
- # [1.8.0](https://github.com/pirasanthan-jesugeevegan/temp-disposable-email/compare/v1.6.4...v1.8.0) (2024-11-28)
2
-
3
-
4
- ### Bug Fixes
5
-
6
- * add skipLibCheck and exclude examples from TypeScript configuration ([5c220fd](https://github.com/pirasanthan-jesugeevegan/temp-disposable-email/commit/5c220fd8cc3a3abb8ff693c1410c29c29067f4ab))
1
+ # [1.10.0](https://github.com/pirasanthan-jesugeevegan/temp-disposable-email/compare/v1.9.0...v1.10.0) (2024-11-28)
7
2
 
8
3
 
9
4
  ### Features
10
5
 
11
- * add Cypress configuration and support for temporary email testing ([77b26a6](https://github.com/pirasanthan-jesugeevegan/temp-disposable-email/commit/77b26a680378d693e29dc8b5a984e686742f65e0))
6
+ * add Playwright testing framework and configuration; update .gitignore and package files ([64911b1](https://github.com/pirasanthan-jesugeevegan/temp-disposable-email/commit/64911b1a222c8000a3b94268c29e4ca9b495658b))
7
+ * update README with ES Modules and CommonJS usage examples; bump version to 1.8.0 and add Cypress test script ([e795bd3](https://github.com/pirasanthan-jesugeevegan/temp-disposable-email/commit/e795bd3f9f736a4c237d00037c2528348eb01e05))
12
8
 
13
9
 
14
10
 
15
- ## [1.6.4](https://github.com/pirasanthan-jesugeevegan/temp-disposable-email/compare/v1.6.3...v1.6.4) (2024-11-28)
11
+ # [1.9.0](https://github.com/pirasanthan-jesugeevegan/temp-disposable-email/compare/v1.8.0...v1.9.0) (2024-11-28)
16
12
 
17
13
 
18
- ### Bug Fixes
14
+ ### Features
19
15
 
20
- * update BASE_URL in constant and simplify publish workflow ([35e4615](https://github.com/pirasanthan-jesugeevegan/temp-disposable-email/commit/35e4615498dad384b75ac226d3bd7fa82bc64ba9))
16
+ * update README with detailed package features, installation, usage, and API documentation ([06772db](https://github.com/pirasanthan-jesugeevegan/temp-disposable-email/commit/06772dbc82f6df4383d75e51078b8915f6f6c6df))
21
17
 
22
18
 
23
19
 
24
- ## [1.6.3](https://github.com/pirasanthan-jesugeevegan/temp-disposable-email/compare/v1.6.2...v1.6.3) (2024-11-28)
20
+ # [1.8.0](https://github.com/pirasanthan-jesugeevegan/temp-disposable-email/compare/v1.6.4...v1.8.0) (2024-11-28)
25
21
 
26
22
 
27
23
  ### Bug Fixes
28
24
 
29
- * update publish workflow to set BASE_URL and build before publishing ([3f0e0dd](https://github.com/pirasanthan-jesugeevegan/temp-disposable-email/commit/3f0e0dd22b43b36d3f7ffd2e4389da3f8f7ac3d4))
25
+ * add skipLibCheck and exclude examples from TypeScript configuration ([5c220fd](https://github.com/pirasanthan-jesugeevegan/temp-disposable-email/commit/5c220fd8cc3a3abb8ff693c1410c29c29067f4ab))
30
26
 
31
27
 
28
+ ### Features
32
29
 
33
- ## [1.6.2](https://github.com/pirasanthan-jesugeevegan/temp-disposable-email/compare/v1.6.1...v1.6.2) (2024-11-28)
30
+ * add Cypress configuration and support for temporary email testing ([77b26a6](https://github.com/pirasanthan-jesugeevegan/temp-disposable-email/commit/77b26a680378d693e29dc8b5a984e686742f65e0))
34
31
 
35
32
 
36
- ### Bug Fixes
37
33
 
38
- * downgrade version to 1.6.0 in package-lock.json and update BASE_URL handling ([919c24e](https://github.com/pirasanthan-jesugeevegan/temp-disposable-email/commit/919c24e563a7541f2a4163f79f49bd6e545f9dd6))
34
+ ## [1.6.4](https://github.com/pirasanthan-jesugeevegan/temp-disposable-email/compare/v1.6.3...v1.6.4) (2024-11-28)
39
35
 
40
36
 
37
+ ### Bug Fixes
41
38
 
42
- ## [1.6.1](https://github.com/pirasanthan-jesugeevegan/temp-disposable-email/compare/v1.6.0...v1.6.1) (2024-11-28)
39
+ * update BASE_URL in constant and simplify publish workflow ([35e4615](https://github.com/pirasanthan-jesugeevegan/temp-disposable-email/commit/35e4615498dad384b75ac226d3bd7fa82bc64ba9))
43
40
 
44
41
 
45
- ### Bug Fixes
46
42
 
47
- * downgrade version to 1.6.0 in package.json ([3422bb1](https://github.com/pirasanthan-jesugeevegan/temp-disposable-email/commit/3422bb1adf4765b0283da9d814d2301044408b80))
43
+ ## [1.6.3](https://github.com/pirasanthan-jesugeevegan/temp-disposable-email/compare/v1.6.2...v1.6.3) (2024-11-28)
48
44
 
49
45
 
50
- ### Features
46
+ ### Bug Fixes
51
47
 
52
- * update package configuration for CommonJS and ES module support, add new tsconfig for CommonJS ([d322290](https://github.com/pirasanthan-jesugeevegan/temp-disposable-email/commit/d322290fd9c192792b16de2547211b716123a9d4))
48
+ * update publish workflow to set BASE_URL and build before publishing ([3f0e0dd](https://github.com/pirasanthan-jesugeevegan/temp-disposable-email/commit/3f0e0dd22b43b36d3f7ffd2e4389da3f8f7ac3d4))
53
49
 
54
50
 
55
51
 
package/README.md CHANGED
@@ -1 +1,163 @@
1
- # temp-disposable-email
1
+ # Temp Disposable Email
2
+
3
+ <span align="center">
4
+
5
+ [![npm version](https://badge.fury.io/js/temp-disposable-email.svg)](https://www.npmjs.com/package/gmail-tester)
6
+ ![NPM Downloads](https://img.shields.io/npm/d18m/temp-disposable-email)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
+ ![GitHub stars](https://img.shields.io/github/stars/pirasanthan-jesugeevegan/temp-disposable-email?style=social)
9
+
10
+ </span>
11
+
12
+ This npm package provides a simple interface for temp email. You can use it to create disposable email accounts, retrieve messages, and delete accounts when done. It includes polling functionality to wait for messages in the inbox and fetch their content.
13
+
14
+ ## Features
15
+
16
+ - **Create Inbox**: Generate a unique, random email address and create an inbox.
17
+ - **Fetch Messages**: Retrieve the latest messages from the inbox.
18
+ - **Read Message Content**: Get the content (HTML and text) of a specific message.
19
+ - **Delete Messages**: Delete a specific message from the inbox.
20
+ - **Delete Account**: Remove the temporary account after usage
21
+
22
+ ## Installation
23
+
24
+ You can install this package via npm:
25
+
26
+ ```bash
27
+ npm install temp-disposable-email
28
+ ```
29
+
30
+ ## Usage
31
+
32
+ ### 1\. Importing the package
33
+
34
+ To use the package, import the functions in your TypeScript or JavaScript project:
35
+
36
+ #### Using ES Modules (Recommended)
37
+
38
+ ```typescript
39
+ import { createInbox, getMessage, deleteAccount } from 'temp-disposable-email';
40
+ ```
41
+
42
+ #### Using CommonJS
43
+
44
+ ```javascript
45
+ import { createInbox, getMessage, deleteAccount } from 'temp-disposable-email';
46
+ ```
47
+
48
+ ### 2\. Create an Inbox
49
+
50
+ This function creates a new disposable email account using a random username or a specified one. It also authenticates and generates a token for accessing messages.
51
+
52
+ ```typescript
53
+ const email = await createInbox(); // or pass a custom username
54
+ console.log('Created email address:', email);
55
+ ```
56
+
57
+ #### Parameters
58
+
59
+ - `username` (Optional): The username for the new email address. If not provided, a random username will be generated.
60
+
61
+ #### Returns
62
+
63
+ - `Promise<string>`: The generated email address.
64
+
65
+ ### 3\. Fetch Recent Email
66
+
67
+ This function retrieves the latest message from the created inbox. You can specify polling options (timeout, interval, logging) for periodic checks when no message is immediately available.
68
+
69
+ ```typescript
70
+ const message = await getRecentEmail();
71
+ console.log('Message received:', message);
72
+ ```
73
+
74
+ #### Parameters
75
+
76
+ - `options` (Optional): Polling options that can include:
77
+ - `maxWaitTime`: Maximum polling time in milliseconds (default: 30,000ms).
78
+ - `waitInterval`: Interval between polling attempts in milliseconds (default: 2,000ms).
79
+ - `logPolling`: Enable or disable logging of polling attempts (default: false).
80
+ - `deleteAfterRead`: Whether to delete the latest message after reading, helpful for parallel run
81
+
82
+ #### Returns
83
+
84
+ - `Promise<object | null>`: An object containing email details like `from`, `to`, `subject`, `intro`, `text`, and `html`.
85
+
86
+ ### 4\. Delete the Created Account
87
+
88
+ Once you're done with the email inbox, you can delete the account to clean up resources.
89
+
90
+ ```typescript
91
+ await deleteAccount();
92
+ console.log('Account deleted');
93
+ ```
94
+
95
+ #### Returns
96
+
97
+ - `Promise<void>`: Resolves when the account is successfully deleted.
98
+
99
+ ## Example Workflow
100
+
101
+ Here's a complete example of creating an inbox, retrieving a message, and deleting the account:
102
+
103
+ ```typescript
104
+ import { createInbox, getMessage, deleteAccount } from 'temp-disposable-email';
105
+
106
+ async function run() {
107
+ try {
108
+ // Create a new inbox
109
+ const email = await createInbox();
110
+ console.log('Created email:', email);
111
+
112
+ // Get the first available message from the inbox
113
+ const message = await getMessage({
114
+ maxWaitTime: 50000,
115
+ waitInterval: 3000,
116
+ logPolling: true,
117
+ });
118
+ console.log('Received message:', message);
119
+
120
+ // Delete the inbox
121
+ await deleteAccount();
122
+ console.log('Account deleted successfully');
123
+ } catch (error) {
124
+ console.error('Error:', error.message);
125
+ }
126
+ }
127
+
128
+ run();
129
+ ```
130
+
131
+ ## API Documentation
132
+
133
+ ### `createInbox(username?: string): Promise<string>`
134
+
135
+ - **Description**: Creates a disposable inbox with a randomly generated or provided username.
136
+ - **Parameters**:
137
+ - `username` (Optional): A custom username for the email address.
138
+ - **Returns**: A promise that resolves to the generated email address.
139
+
140
+ ### `getRecentEmail(options?: GetEmailOptions): Promise<any | null>`
141
+
142
+ - **Description**: Retrieves the latest message from the inbox, polling if necessary.
143
+ - **Parameters**:
144
+ - `options` (Optional): Polling configuration for waiting for messages. See GetEmailOptions.
145
+ - **Returns**: A promise that resolves to the message content (or `null` if no messages are found).
146
+
147
+ ### `deleteAccount(): Promise<void>`
148
+
149
+ - **Description**: Deletes the inbox and its associated account.
150
+ - **Returns**: A promise that resolves when the account is successfully deleted.
151
+
152
+ ## Get Email Options
153
+
154
+ You can configure polling behavior by passing an options object to `getMessage`. The available options are:
155
+
156
+ - `maxWaitTime` (Optional): The maximum time to wait for messages (in milliseconds).
157
+ - `waitInterval` (Optional): The interval between polling attempts (in milliseconds).
158
+ - `logPolling` (Optional): Whether to log each polling attempt for debugging purposes.
159
+ - `deleteAfterRead` (Optional): Whether to delete messages after reading
160
+
161
+ ## License
162
+
163
+ This project is licensed under the MIT License.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "temp-disposable-email",
3
- "version": "1.8.0",
3
+ "version": "1.10.0",
4
4
  "description": "",
5
5
  "main": "dist/cjs/index.js",
6
6
  "exports": {
@@ -13,6 +13,8 @@
13
13
  "scripts": {
14
14
  "build": "tsc -p tsconfig.json && tsc -p tsconfig.cjs.json",
15
15
  "test": "jest",
16
+ "test:cypress": "cypress run",
17
+ "test:playwright": "playwright test",
16
18
  "lint": "eslint src --fix",
17
19
  "prepare": "npm run build"
18
20
  },
@@ -43,6 +45,7 @@
43
45
  "tslib": "^2.8.1"
44
46
  },
45
47
  "devDependencies": {
48
+ "@playwright/test": "^1.49.0",
46
49
  "@types/cypress": "^1.1.6",
47
50
  "@types/jest": "^29.5.14",
48
51
  "@types/node": "^22.10.0",
@@ -0,0 +1,78 @@
1
+ import { defineConfig, devices } from '@playwright/test';
2
+
3
+ /**
4
+ * Read environment variables from file.
5
+ * https://github.com/motdotla/dotenv
6
+ */
7
+ // import dotenv from 'dotenv';
8
+ // import path from 'path';
9
+ // dotenv.config({ path: path.resolve(__dirname, '.env') });
10
+
11
+ /**
12
+ * See https://playwright.dev/docs/test-configuration.
13
+ */
14
+ export default defineConfig({
15
+ testDir: './examples/playwright',
16
+ /* Run tests in files in parallel */
17
+ fullyParallel: true,
18
+ /* Fail the build on CI if you accidentally left test.only in the source code. */
19
+ forbidOnly: !!process.env.CI,
20
+ /* Retry on CI only */
21
+ retries: process.env.CI ? 2 : 0,
22
+ /* Opt out of parallel tests on CI. */
23
+ workers: process.env.CI ? 1 : undefined,
24
+ /* Reporter to use. See https://playwright.dev/docs/test-reporters */
25
+ reporter: 'html',
26
+ /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
27
+ use: {
28
+ /* Base URL to use in actions like `await page.goto('/')`. */
29
+ // baseURL: 'http://127.0.0.1:3000',
30
+
31
+ /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
32
+ trace: 'on-first-retry',
33
+ },
34
+
35
+ /* Configure projects for major browsers */
36
+ projects: [
37
+ {
38
+ name: 'chromium',
39
+ use: { ...devices['Desktop Chrome'] },
40
+ },
41
+
42
+ // {
43
+ // name: 'firefox',
44
+ // use: { ...devices['Desktop Firefox'] },
45
+ // },
46
+
47
+ // {
48
+ // name: 'webkit',
49
+ // use: { ...devices['Desktop Safari'] },
50
+ // },
51
+ /* Test against mobile viewports. */
52
+ // {
53
+ // name: 'Mobile Chrome',
54
+ // use: { ...devices['Pixel 5'] },
55
+ // },
56
+ // {
57
+ // name: 'Mobile Safari',
58
+ // use: { ...devices['iPhone 12'] },
59
+ // },
60
+
61
+ /* Test against branded browsers. */
62
+ // {
63
+ // name: 'Microsoft Edge',
64
+ // use: { ...devices['Desktop Edge'], channel: 'msedge' },
65
+ // },
66
+ // {
67
+ // name: 'Google Chrome',
68
+ // use: { ...devices['Desktop Chrome'], channel: 'chrome' },
69
+ // },
70
+ ],
71
+
72
+ /* Run your local dev server before starting the tests */
73
+ // webServer: {
74
+ // command: 'npm run start',
75
+ // url: 'http://127.0.0.1:3000',
76
+ // reuseExistingServer: !process.env.CI,
77
+ // },
78
+ });