temp-disposable-email 1.8.0 → 1.9.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.
Files changed (3) hide show
  1. package/CHANGELOG.md +9 -14
  2. package/README.md +155 -1
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ # [1.9.0](https://github.com/pirasanthan-jesugeevegan/temp-disposable-email/compare/v1.8.0...v1.9.0) (2024-11-28)
2
+
3
+
4
+ ### Features
5
+
6
+ * update README with detailed package features, installation, usage, and API documentation ([06772db](https://github.com/pirasanthan-jesugeevegan/temp-disposable-email/commit/06772dbc82f6df4383d75e51078b8915f6f6c6df))
7
+
8
+
9
+
1
10
  # [1.8.0](https://github.com/pirasanthan-jesugeevegan/temp-disposable-email/compare/v1.6.4...v1.8.0) (2024-11-28)
2
11
 
3
12
 
@@ -39,17 +48,3 @@
39
48
 
40
49
 
41
50
 
42
- ## [1.6.1](https://github.com/pirasanthan-jesugeevegan/temp-disposable-email/compare/v1.6.0...v1.6.1) (2024-11-28)
43
-
44
-
45
- ### Bug Fixes
46
-
47
- * downgrade version to 1.6.0 in package.json ([3422bb1](https://github.com/pirasanthan-jesugeevegan/temp-disposable-email/commit/3422bb1adf4765b0283da9d814d2301044408b80))
48
-
49
-
50
- ### Features
51
-
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))
53
-
54
-
55
-
package/README.md CHANGED
@@ -1 +1,155 @@
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
+ ```typescript
37
+ import { createInbox, getMessage, deleteAccount } from 'temp-disposable-email';
38
+ ```
39
+
40
+ ### 2\. Create an Inbox
41
+
42
+ 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.
43
+
44
+ ```typescript
45
+ const email = await createInbox(); // or pass a custom username
46
+ console.log('Created email address:', email);
47
+ ```
48
+
49
+ #### Parameters
50
+
51
+ - `username` (Optional): The username for the new email address. If not provided, a random username will be generated.
52
+
53
+ #### Returns
54
+
55
+ - `Promise<string>`: The generated email address.
56
+
57
+ ### 3\. Fetch Recent Email
58
+
59
+ 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.
60
+
61
+ ```typescript
62
+ const message = await getRecentEmail();
63
+ console.log('Message received:', message);
64
+ ```
65
+
66
+ #### Parameters
67
+
68
+ - `options` (Optional): Polling options that can include:
69
+ - `maxWaitTime`: Maximum polling time in milliseconds (default: 30,000ms).
70
+ - `waitInterval`: Interval between polling attempts in milliseconds (default: 2,000ms).
71
+ - `logPolling`: Enable or disable logging of polling attempts (default: false).
72
+ - `deleteAfterRead`: Whether to delete the latest message after reading, helpful for parallel run
73
+
74
+ #### Returns
75
+
76
+ - `Promise<object | null>`: An object containing email details like `from`, `to`, `subject`, `intro`, `text`, and `html`.
77
+
78
+ ### 4\. Delete the Created Account
79
+
80
+ Once you're done with the email inbox, you can delete the account to clean up resources.
81
+
82
+ ```typescript
83
+ await deleteAccount();
84
+ console.log('Account deleted');
85
+ ```
86
+
87
+ #### Returns
88
+
89
+ - `Promise<void>`: Resolves when the account is successfully deleted.
90
+
91
+ ## Example Workflow
92
+
93
+ Here's a complete example of creating an inbox, retrieving a message, and deleting the account:
94
+
95
+ ```typescript
96
+ import { createInbox, getMessage, deleteAccount } from 'temp-disposable-email';
97
+
98
+ async function run() {
99
+ try {
100
+ // Create a new inbox
101
+ const email = await createInbox();
102
+ console.log('Created email:', email);
103
+
104
+ // Get the first available message from the inbox
105
+ const message = await getMessage({
106
+ maxWaitTime: 50000,
107
+ waitInterval: 3000,
108
+ logPolling: true,
109
+ });
110
+ console.log('Received message:', message);
111
+
112
+ // Delete the inbox
113
+ await deleteAccount();
114
+ console.log('Account deleted successfully');
115
+ } catch (error) {
116
+ console.error('Error:', error.message);
117
+ }
118
+ }
119
+
120
+ run();
121
+ ```
122
+
123
+ ## API Documentation
124
+
125
+ ### `createInbox(username?: string): Promise<string>`
126
+
127
+ - **Description**: Creates a disposable inbox with a randomly generated or provided username.
128
+ - **Parameters**:
129
+ - `username` (Optional): A custom username for the email address.
130
+ - **Returns**: A promise that resolves to the generated email address.
131
+
132
+ ### `getRecentEmail(options?: GetEmailOptions): Promise<any | null>`
133
+
134
+ - **Description**: Retrieves the latest message from the inbox, polling if necessary.
135
+ - **Parameters**:
136
+ - `options` (Optional): Polling configuration for waiting for messages. See GetEmailOptions.
137
+ - **Returns**: A promise that resolves to the message content (or `null` if no messages are found).
138
+
139
+ ### `deleteAccount(): Promise<void>`
140
+
141
+ - **Description**: Deletes the inbox and its associated account.
142
+ - **Returns**: A promise that resolves when the account is successfully deleted.
143
+
144
+ ## Get Email Options
145
+
146
+ You can configure polling behavior by passing an options object to `getMessage`. The available options are:
147
+
148
+ - `maxWaitTime` (Optional): The maximum time to wait for messages (in milliseconds).
149
+ - `waitInterval` (Optional): The interval between polling attempts (in milliseconds).
150
+ - `logPolling` (Optional): Whether to log each polling attempt for debugging purposes.
151
+ - `deleteAfterRead` (Optional): Whether to delete messages after reading
152
+
153
+ ## License
154
+
155
+ 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.9.0",
4
4
  "description": "",
5
5
  "main": "dist/cjs/index.js",
6
6
  "exports": {