temp-disposable-email 1.11.6 → 1.12.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 (39) hide show
  1. package/README.md +38 -20
  2. package/cypress.config.ts +1 -0
  3. package/dist/cjs/index.d.ts +2 -1
  4. package/dist/cjs/index.d.ts.map +1 -1
  5. package/dist/cjs/index.js +4 -3
  6. package/dist/cjs/index.js.map +1 -1
  7. package/dist/cjs/services/accountService.d.ts +10 -27
  8. package/dist/cjs/services/accountService.d.ts.map +1 -1
  9. package/dist/cjs/services/accountService.js +18 -60
  10. package/dist/cjs/services/accountService.js.map +1 -1
  11. package/dist/cjs/services/messageService.d.ts +7 -1
  12. package/dist/cjs/services/messageService.d.ts.map +1 -1
  13. package/dist/cjs/services/messageService.js +19 -42
  14. package/dist/cjs/services/messageService.js.map +1 -1
  15. package/dist/cjs/utils/api.d.ts +97 -2
  16. package/dist/cjs/utils/api.d.ts.map +1 -1
  17. package/dist/cjs/utils/api.js +79 -9
  18. package/dist/cjs/utils/api.js.map +1 -1
  19. package/dist/esm/index.d.ts +2 -1
  20. package/dist/esm/index.d.ts.map +1 -1
  21. package/dist/esm/index.js +2 -1
  22. package/dist/esm/index.js.map +1 -1
  23. package/dist/esm/services/accountService.d.ts +10 -27
  24. package/dist/esm/services/accountService.d.ts.map +1 -1
  25. package/dist/esm/services/accountService.js +17 -55
  26. package/dist/esm/services/accountService.js.map +1 -1
  27. package/dist/esm/services/messageService.d.ts +7 -1
  28. package/dist/esm/services/messageService.d.ts.map +1 -1
  29. package/dist/esm/services/messageService.js +20 -43
  30. package/dist/esm/services/messageService.js.map +1 -1
  31. package/dist/esm/utils/api.d.ts +97 -2
  32. package/dist/esm/utils/api.d.ts.map +1 -1
  33. package/dist/esm/utils/api.js +71 -6
  34. package/dist/esm/utils/api.js.map +1 -1
  35. package/package.json +1 -1
  36. package/src/index.ts +2 -1
  37. package/src/services/accountService.ts +26 -66
  38. package/src/services/messageService.ts +38 -57
  39. package/src/utils/api.ts +163 -6
package/README.md CHANGED
@@ -35,7 +35,7 @@ This npm package provides a simple interface for temp email. You can use it to c
35
35
  ## Features
36
36
 
37
37
  - **Create Inbox**: Generate a unique, random email address and create an inbox.
38
- - **Fetch Messages**: Retrieve the latest messages from the inbox.
38
+ - **Fetch Latest Messages**: Retrieve the latest messages from the inbox.
39
39
  - **Read Message Content**: Get the content (HTML and text) of a specific message.
40
40
  - **Delete Messages**: Delete a specific message from the inbox.
41
41
  - **Delete Account**: Remove the temporary account after usage
@@ -61,26 +61,30 @@ To use the package, import the functions in your TypeScript or JavaScript projec
61
61
  #### Using ES Modules (Recommended)
62
62
 
63
63
  ```typescript
64
- import { createInbox, getMessage, deleteAccount } from 'temp-disposable-email';
64
+ import {
65
+ generateEmail,
66
+ getRecentEmail,
67
+ deleteAccount,
68
+ } from 'temp-disposable-email';
65
69
  ```
66
70
 
67
71
  #### Using CommonJS
68
72
 
69
73
  ```javascript
70
74
  const {
71
- createInbox,
72
- getMessage,
75
+ generateEmail,
76
+ getRecentEmail,
73
77
  deleteAccount,
74
78
  } = require('temp-disposable-email');
75
79
  ```
76
80
 
77
81
  ### 2\. Create an Inbox
78
82
 
79
- 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.
83
+ This function creates a new disposable email account using a random username or a specified one.
80
84
 
81
85
  ```typescript
82
- const email = await createInbox(); // or pass a custom username
83
- console.log('Created email address:', email);
86
+ const { emailAddress, accountId } = await generateEmail(); // or pass a custom username
87
+ console.log('Created email address:', emailAddress);
84
88
  ```
85
89
 
86
90
  #### Parameters
@@ -89,7 +93,7 @@ console.log('Created email address:', email);
89
93
 
90
94
  #### Returns
91
95
 
92
- - `Promise<string>`: The generated email address.
96
+ - `Promise<object>`: An object containing email details like `emailAddress`, and `accountId`.
93
97
 
94
98
  ### 3\. Fetch Recent Email
95
99
 
@@ -110,20 +114,24 @@ console.log('Message received:', message);
110
114
 
111
115
  #### Returns
112
116
 
113
- - `Promise<object | null>`: An object containing email details like `from`, `to`, `subject`, `intro`, `text`, and `html`.
117
+ - `Promise<object | null>`: An object containing email details like `from`, `to`, `subject`, `intro`, `text`, `html`, `createdAt`, and `updatedAt`.
114
118
 
115
119
  ### 4\. Delete the Created Account
116
120
 
117
121
  Once you're done with the email inbox, you can delete the account to clean up resources.
118
122
 
119
123
  ```typescript
120
- await deleteAccount();
121
- console.log('Account deleted');
124
+ const res = await deleteAccount('accountId');
125
+ console.log(res); // status code
122
126
  ```
123
127
 
128
+ #### Parameters
129
+
130
+ - `accountId`: `accountId` from `generateEmail()`
131
+
124
132
  #### Returns
125
133
 
126
- - `Promise<void>`: Resolves when the account is successfully deleted.
134
+ - `Promise<number>`: status code.
127
135
 
128
136
  <p id="example"></p>
129
137
 
@@ -142,16 +150,20 @@ For using temp-disposable-email with Cypress, see the example in the [Cypress fo
142
150
  Here's a complete example of creating an inbox, retrieving a message, and deleting the account:
143
151
 
144
152
  ```typescript
145
- import { createInbox, getMessage, deleteAccount } from 'temp-disposable-email';
153
+ import {
154
+ generateEmail,
155
+ getRecentEmail,
156
+ deleteAccount,
157
+ } from 'temp-disposable-email';
146
158
 
147
159
  async function run() {
148
160
  try {
149
161
  // Create a new inbox
150
- const email = await createInbox();
151
- console.log('Created email:', email);
162
+ const { emailAddress, accountId } = await generateEmail();
163
+ console.log('Created email:', emailAddress);
152
164
 
153
165
  // Get the first available message from the inbox
154
- const message = await getMessage({
166
+ const message = await getRecentEmail({
155
167
  maxWaitTime: 50000,
156
168
  waitInterval: 3000,
157
169
  logPolling: true,
@@ -159,8 +171,12 @@ async function run() {
159
171
  console.log('Received message:', message);
160
172
 
161
173
  // Delete the inbox
162
- await deleteAccount();
163
- console.log('Account deleted successfully');
174
+ const res = await deleteAccount(accountId);
175
+ if (res === 204) {
176
+ console.log('Account deleted successfully');
177
+ } else {
178
+ console.log('Account deleted failed');
179
+ }
164
180
  } catch (error) {
165
181
  console.error('Error:', error.message);
166
182
  }
@@ -173,7 +189,7 @@ run();
173
189
 
174
190
  ## API Documentation
175
191
 
176
- ### `createInbox(username?: string): Promise<string>`
192
+ ### `generateEmail(username?: string): Promise<string>`
177
193
 
178
194
  - **Description**: Creates a disposable inbox with a randomly generated or provided username.
179
195
  - **Parameters**:
@@ -190,11 +206,13 @@ run();
190
206
  ### `deleteAccount(): Promise<void>`
191
207
 
192
208
  - **Description**: Deletes the inbox and its associated account.
209
+ - **Parameters**:
210
+ - `accountId` accountId from `generateEmail()`
193
211
  - **Returns**: A promise that resolves when the account is successfully deleted.
194
212
 
195
213
  ## Get Email Options
196
214
 
197
- You can configure polling behavior by passing an options object to `getMessage`. The available options are:
215
+ You can configure polling behavior by passing an options object to `getRecentEmail`. The available options are:
198
216
 
199
217
  - `maxWaitTime` (Optional): The maximum time to wait for messages (in milliseconds).
200
218
  - `waitInterval` (Optional): The interval between polling attempts (in milliseconds).
package/cypress.config.ts CHANGED
@@ -9,5 +9,6 @@ export default defineConfig({
9
9
  setupNodeEvents(on, config) {
10
10
  // implement node event listeners here
11
11
  },
12
+ chromeWebSecurity: false,
12
13
  },
13
14
  });
@@ -1,4 +1,5 @@
1
- export { createInbox, deleteAccount } from './services/accountService';
1
+ export { generateEmail, GeneratedEmail } from './services/accountService';
2
+ export { deleteAccount } from './utils/api';
2
3
  export { getRecentEmail, deleteMessage, MessageContent, GetEmailOptions, } from './services/messageService';
3
4
  export { getVerificationCode } from './utils/getVerificationCode';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EACL,cAAc,EACd,aAAa,EACb,cAAc,EACd,eAAe,GAChB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EACL,cAAc,EACd,aAAa,EACb,cAAc,EACd,eAAe,GAChB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC"}
package/dist/cjs/index.js CHANGED
@@ -33,12 +33,13 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.getVerificationCode = exports.deleteMessage = exports.getRecentEmail = exports.deleteAccount = exports.createInbox = void 0;
36
+ exports.getVerificationCode = exports.deleteMessage = exports.getRecentEmail = exports.deleteAccount = exports.generateEmail = void 0;
37
37
  const dotenv = __importStar(require("dotenv"));
38
38
  dotenv.config();
39
39
  var accountService_1 = require("./services/accountService");
40
- Object.defineProperty(exports, "createInbox", { enumerable: true, get: function () { return accountService_1.createInbox; } });
41
- Object.defineProperty(exports, "deleteAccount", { enumerable: true, get: function () { return accountService_1.deleteAccount; } });
40
+ Object.defineProperty(exports, "generateEmail", { enumerable: true, get: function () { return accountService_1.generateEmail; } });
41
+ var api_1 = require("./utils/api");
42
+ Object.defineProperty(exports, "deleteAccount", { enumerable: true, get: function () { return api_1.deleteAccount; } });
42
43
  var messageService_1 = require("./services/messageService");
43
44
  Object.defineProperty(exports, "getRecentEmail", { enumerable: true, get: function () { return messageService_1.getRecentEmail; } });
44
45
  Object.defineProperty(exports, "deleteMessage", { enumerable: true, get: function () { return messageService_1.deleteMessage; } });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAiC;AACjC,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,4DAAuE;AAA9D,6GAAA,WAAW,OAAA;AAAE,+GAAA,aAAa,OAAA;AACnC,4DAKmC;AAJjC,gHAAA,cAAc,OAAA;AACd,+GAAA,aAAa,OAAA;AAIf,mEAAkE;AAAzD,0HAAA,mBAAmB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAiC;AACjC,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,4DAA0E;AAAjE,+GAAA,aAAa,OAAA;AACtB,mCAA4C;AAAnC,oGAAA,aAAa,OAAA;AACtB,4DAKmC;AAJjC,gHAAA,cAAc,OAAA;AACd,+GAAA,aAAa,OAAA;AAIf,mEAAkE;AAAzD,0HAAA,mBAAmB,OAAA"}
@@ -1,37 +1,20 @@
1
+ export interface GeneratedEmail {
2
+ emailAddress: string;
3
+ accountId: string;
4
+ }
1
5
  /**
2
6
  * Creates a new email inbox with a unique address.
3
7
  *
4
- * This function selects an available domain, generates an email
5
- * address, and attempts to create an account on the Mail.tm service.
6
- * If account creation is rate-limited, the function retries with a
7
- * delay. Upon successful creation, it authenticates the account and
8
- * stores the token and account ID for future API calls.
8
+ * This function generates an temp inbox & email address
9
9
  *
10
- * @param {string} [username] - Optional username; a random one is generated if not provided.
11
- * @returns {Promise<string>} The generated email address.
10
+ * @param {string} [emailPrefix] - Optional emailPrefix; a random one is generated if not provided.
11
+ * @returns {Promise<GeneratedEmail>} The generated email address & account ID.
12
12
  *
13
13
  * @throws {Error} If no domains are available or account creation fails.
14
14
  *
15
15
  * @example
16
- * const email = await createInbox("customUser");
17
- * console.log(email); // Outputs: "customUser@mail.tm"
16
+ * const email = await generateEmail("customUser");
17
+ * console.log(email); // Outputs: {"emailAddress": "customUser@mail.tm" , "accountId": "1234"}
18
18
  */
19
- export declare const createInbox: (username?: string) => Promise<string>;
20
- /**
21
- * Deletes the account created during `createInbox`.
22
- *
23
- * This function removes the email account from the Mail.tm service
24
- * and clears the stored authentication token and account ID.
25
- * Subsequent API calls requiring authentication will fail until a
26
- * new account is created.
27
- *
28
- * @returns {Promise<void>} Resolves when the account is successfully deleted.
29
- *
30
- * @throws {Error} If no account is authenticated or deletion fails.
31
- *
32
- * @example
33
- * await deleteAccount();
34
- * console.log("Account deleted successfully.");
35
- */
36
- export declare const deleteAccount: () => Promise<void>;
19
+ export declare const generateEmail: (emailPrefix?: string) => Promise<GeneratedEmail>;
37
20
  //# sourceMappingURL=accountService.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"accountService.d.ts","sourceRoot":"","sources":["../../../src/services/accountService.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;GAiBG;AAEH,eAAO,MAAM,WAAW,cAAqB,MAAM,KAAG,OAAO,CAAC,MAAM,CA2CnE,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,aAAa,QAAa,OAAO,CAAC,IAAI,CAelD,CAAC"}
1
+ {"version":3,"file":"accountService.d.ts","sourceRoot":"","sources":["../../../src/services/accountService.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,aAAa,iBACV,MAAM,KACnB,OAAO,CAAC,cAAc,CAmCxB,CAAC"}
@@ -1,55 +1,43 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.deleteAccount = exports.createInbox = void 0;
7
- const axios_1 = __importDefault(require("axios"));
3
+ exports.generateEmail = void 0;
8
4
  const authService_1 = require("./authService");
9
5
  const generateRandomName_1 = require("../utils/generateRandomName");
10
6
  const delay_1 = require("../utils/delay");
11
- const constant_1 = require("../utils/constant");
12
- let accountId = null;
7
+ const api_1 = require("../utils/api");
13
8
  /**
14
9
  * Creates a new email inbox with a unique address.
15
10
  *
16
- * This function selects an available domain, generates an email
17
- * address, and attempts to create an account on the Mail.tm service.
18
- * If account creation is rate-limited, the function retries with a
19
- * delay. Upon successful creation, it authenticates the account and
20
- * stores the token and account ID for future API calls.
11
+ * This function generates an temp inbox & email address
21
12
  *
22
- * @param {string} [username] - Optional username; a random one is generated if not provided.
23
- * @returns {Promise<string>} The generated email address.
13
+ * @param {string} [emailPrefix] - Optional emailPrefix; a random one is generated if not provided.
14
+ * @returns {Promise<GeneratedEmail>} The generated email address & account ID.
24
15
  *
25
16
  * @throws {Error} If no domains are available or account creation fails.
26
17
  *
27
18
  * @example
28
- * const email = await createInbox("customUser");
29
- * console.log(email); // Outputs: "customUser@mail.tm"
19
+ * const email = await generateEmail("customUser");
20
+ * console.log(email); // Outputs: {"emailAddress": "customUser@mail.tm" , "accountId": "1234"}
30
21
  */
31
- const createInbox = async (username) => {
32
- const domainsResponse = await axios_1.default.get(`${constant_1.BASE_URL}/domains`, {
33
- headers: { accept: 'application/ld+json' },
34
- });
35
- const domains = domainsResponse.data['hydra:member'].map((domain) => domain.domain);
22
+ const generateEmail = async (emailPrefix) => {
23
+ const domainsResponse = await (0, api_1.getDomains)();
24
+ const domains = domainsResponse
25
+ .filter((domain) => domain.isActive)
26
+ .map((domain) => domain.domain);
36
27
  if (domains.length === 0)
37
28
  throw new Error('No available domains.');
38
- const emailAddress = `${username || (0, generateRandomName_1.generateRandomName)()}@${domains[0]}`;
29
+ const emailAddress = `${emailPrefix || (0, generateRandomName_1.generateRandomName)()}@${domains[0]}`;
39
30
  const password = (0, generateRandomName_1.generateRandomName)();
40
31
  let attempts = 0;
41
32
  const maxRetries = 5;
42
33
  while (attempts < maxRetries) {
43
34
  try {
44
- const accountResponse = await axios_1.default.post(`${constant_1.BASE_URL}/accounts`, { address: emailAddress, password }, {
45
- headers: {
46
- accept: 'application/json',
47
- 'Content-Type': 'application/json',
48
- },
35
+ const accountResponse = await (0, api_1.createAccount)({
36
+ address: emailAddress,
37
+ password,
49
38
  });
50
- accountId = accountResponse.data.id;
51
39
  await (0, authService_1.authenticate)(emailAddress, password);
52
- return emailAddress;
40
+ return { emailAddress, accountId: accountResponse.id };
53
41
  }
54
42
  catch (error) {
55
43
  if (error.response?.status === 429) {
@@ -66,35 +54,5 @@ const createInbox = async (username) => {
66
54
  }
67
55
  throw new Error('Failed to create account after multiple retries.');
68
56
  };
69
- exports.createInbox = createInbox;
70
- /**
71
- * Deletes the account created during `createInbox`.
72
- *
73
- * This function removes the email account from the Mail.tm service
74
- * and clears the stored authentication token and account ID.
75
- * Subsequent API calls requiring authentication will fail until a
76
- * new account is created.
77
- *
78
- * @returns {Promise<void>} Resolves when the account is successfully deleted.
79
- *
80
- * @throws {Error} If no account is authenticated or deletion fails.
81
- *
82
- * @example
83
- * await deleteAccount();
84
- * console.log("Account deleted successfully.");
85
- */
86
- const deleteAccount = async () => {
87
- const token = (0, authService_1.getToken)();
88
- if (!token || !accountId) {
89
- throw new Error('Account information missing. Create and authenticate an account first.');
90
- }
91
- await axios_1.default.delete(`${constant_1.BASE_URL}/accounts/${accountId}`, {
92
- headers: {
93
- accept: '*/*',
94
- Authorization: `Bearer ${token}`,
95
- },
96
- });
97
- accountId = null;
98
- };
99
- exports.deleteAccount = deleteAccount;
57
+ exports.generateEmail = generateEmail;
100
58
  //# sourceMappingURL=accountService.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"accountService.js","sourceRoot":"","sources":["../../../src/services/accountService.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,+CAAuD;AACvD,oEAAiE;AACjE,0CAAuC;AACvC,gDAA6C;AAE7C,IAAI,SAAS,GAAkB,IAAI,CAAC;AACpC;;;;;;;;;;;;;;;;;GAiBG;AAEI,MAAM,WAAW,GAAG,KAAK,EAAE,QAAiB,EAAmB,EAAE;IACtE,MAAM,eAAe,GAAG,MAAM,eAAK,CAA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a,iBAqCxB"}
@@ -8,7 +8,9 @@ export interface MessageContent {
8
8
  subject: string;
9
9
  intro: string;
10
10
  text: string;
11
- html: string;
11
+ html: string[];
12
+ createdAt: string;
13
+ updatedAt: string;
12
14
  }
13
15
  export interface GetEmailOptions {
14
16
  maxWaitTime?: number;
@@ -25,6 +27,10 @@ export interface GetEmailOptions {
25
27
  * deleted after reading.
26
28
  *
27
29
  * @param {GetEmailOptions} [options] - Optional settings for polling and deletion.
30
+ * @param {number} [options.maxWaitTime=30000] - Maximum time to wait for messages (in milliseconds). Default is 30 seconds.
31
+ * @param {number} [options.waitInterval=2000] - Time interval between polling attempts (in milliseconds). Default is 2 seconds.
32
+ * @param {boolean} [options.logPolling=false] - Whether to log polling attempts. Default is `false`.
33
+ * @param {boolean} [options.deleteAfterRead=false] - Whether to delete the message after reading. Default is `false`.
28
34
  * @returns {Promise<MessageContent | null>} The email content (sender, recipient, subject, text, HTML), or `null` if no messages are found.
29
35
  *
30
36
  * @throws {Error} If no messages are available within the polling timeout or authentication fails.
@@ -1 +1 @@
1
- {"version":3,"file":"messageService.d.ts","sourceRoot":"","sources":["../../../src/services/messageService.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1B,EAAE,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AACD,MAAM,WAAW,eAAe;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,cAAc,aACf,eAAe,KACxB,OAAO,CAAC,cAAc,GAAG,IAAI,CAkF/B,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,aAAa,cAAqB,MAAM,KAAG,OAAO,CAAC,IAAI,CAenE,CAAC"}
1
+ {"version":3,"file":"messageService.d.ts","sourceRoot":"","sources":["../../../src/services/messageService.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1B,EAAE,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AACD,MAAM,WAAW,eAAe;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,cAAc,aACf,eAAe,KACxB,OAAO,CAAC,cAAc,GAAG,IAAI,CAyD/B,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,aAAa,cAAqB,MAAM,KAAG,OAAO,CAAC,IAAI,CAenE,CAAC"}
@@ -17,6 +17,10 @@ const api_1 = require("../utils/api");
17
17
  * deleted after reading.
18
18
  *
19
19
  * @param {GetEmailOptions} [options] - Optional settings for polling and deletion.
20
+ * @param {number} [options.maxWaitTime=30000] - Maximum time to wait for messages (in milliseconds). Default is 30 seconds.
21
+ * @param {number} [options.waitInterval=2000] - Time interval between polling attempts (in milliseconds). Default is 2 seconds.
22
+ * @param {boolean} [options.logPolling=false] - Whether to log polling attempts. Default is `false`.
23
+ * @param {boolean} [options.deleteAfterRead=false] - Whether to delete the message after reading. Default is `false`.
20
24
  * @returns {Promise<MessageContent | null>} The email content (sender, recipient, subject, text, HTML), or `null` if no messages are found.
21
25
  *
22
26
  * @throws {Error} If no messages are available within the polling timeout or authentication fails.
@@ -26,63 +30,36 @@ const api_1 = require("../utils/api");
26
30
  * console.log(message.subject); // Outputs: "Hello!"
27
31
  */
28
32
  const getRecentEmail = async (options) => {
29
- const token = (0, authService_1.getToken)();
30
33
  const { maxWaitTime = 30000, waitInterval = 2000, logPolling = false, deleteAfterRead = false, } = options || {};
31
- if (!token)
32
- throw new Error('Authentication required. Call createInbox() first.');
33
- if (!options) {
34
- const messages = await (0, api_1.fetchMessages)();
35
- if (messages.length === 0)
36
- throw new Error('No messages available');
37
- const messageId = messages[0].id;
38
- const { from, to, subject, intro, text, html } = await (0, api_1.fetchMessageContent)(messageId);
39
- if (deleteAfterRead) {
40
- await (0, exports.deleteMessage)(messageId);
41
- }
42
- return {
43
- from: from.address,
44
- to: to[0].address,
45
- subject,
46
- intro,
47
- text,
48
- html,
49
- };
50
- }
51
34
  const startTime = Date.now();
52
- if (logPolling) {
53
- console.log(`Polling started with a timeout of ${maxWaitTime / 1000}sec and interval of ${waitInterval / 1000}sec.`);
54
- }
35
+ const logger = (message) => logPolling && console.log(message);
36
+ logger(`Polling started with a timeout of ${maxWaitTime / 1000}sec and interval of ${waitInterval / 1000}sec.`);
55
37
  while (Date.now() - startTime < maxWaitTime) {
56
- const messages = await (0, api_1.fetchMessages)();
38
+ const messages = await (0, api_1.getMessages)();
57
39
  if (messages.length > 0) {
58
- if (logPolling) {
59
- console.log(`Found ${messages.length} message(s), fetching details...`);
60
- }
61
- const messageId = messages[0].id;
62
- if (logPolling) {
63
- console.log(`Message retrieved`);
64
- }
65
- const { from, to, subject, intro, text, html } = await (0, api_1.fetchMessageContent)(messageId);
40
+ logger(`Found ${messages.length} message(s), fetching details...`);
41
+ const sortedMessages = messages.sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime());
42
+ const messageId = sortedMessages[0].id;
43
+ logger(`Found ${messageId}`);
44
+ const { from, to, subject, intro, text, html, createdAt, updatedAt } = await (0, api_1.getMessagesContent)(messageId);
66
45
  if (deleteAfterRead) {
67
46
  await (0, exports.deleteMessage)(messageId);
68
47
  }
69
48
  return {
70
- from: from.address,
71
- to: to[0].address,
49
+ from: from,
50
+ to: to,
72
51
  subject,
73
52
  intro,
74
53
  text,
75
54
  html,
55
+ createdAt,
56
+ updatedAt,
76
57
  };
77
58
  }
78
59
  await new Promise((resolve) => setTimeout(resolve, waitInterval));
79
- if (logPolling) {
80
- console.log(`No messages found, waiting for ${waitInterval / 1000} seconds...`);
81
- }
82
- }
83
- if (logPolling) {
84
- console.log(`Waiting timeout of ${maxWaitTime / 1000} seconds reached. No messages found.`);
60
+ logger(`No messages found, waiting for ${waitInterval / 1000} seconds...`);
85
61
  }
62
+ logger(`Waiting timeout of ${maxWaitTime / 1000} seconds reached. No messages found.`);
86
63
  throw new Error(`No messages available within ${maxWaitTime / 1000} seconds timeout`);
87
64
  };
88
65
  exports.getRecentEmail = getRecentEmail;
@@ -105,7 +82,7 @@ exports.getRecentEmail = getRecentEmail;
105
82
  const deleteMessage = async (messageId) => {
106
83
  const token = (0, authService_1.getToken)();
107
84
  if (!token)
108
- throw new Error('Authentication required. Call createInbox() first.');
85
+ throw new Error('Authentication required. Call generateEmail() first.');
109
86
  try {
110
87
  await axios_1.default.delete(`${constant_1.BASE_URL}/messages/${messageId}`, {
111
88
  headers: {
@@ -1 +1 @@
1
- {"version":3,"file":"messageService.js","sourceRoot":"","sources":["../../../src/services/messageService.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,+CAAyC;AACzC,gDAA6C;AAC7C,sCAAkE;AAiBlE;;;;;;;;;;;;;;;;GAgBG;AACI,MAAM,cAAc,GAAG,KAAK,EACjC,OAAyB,EACO,E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;;;;;;;;;;;GAeG;AACI,MAAM,aAAa,GAAG,KAAK,EAAE,SAAiB,EAAiB,EAAE;IACtE,MAAM,KAAK,GAAG,IAAA,sBAAQ,GAAE,CAAC;IACzB,IAAI,CAAC,KAAK;QACR,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;IAExE,IAAI,CAAC;QACH,MAAM,eAAK,CAAC,MAAM,CAAC,GAAG,mBAAQ,aAAa,SAAS,EAAE,EAAE;YACtD,OAAO,EAAE;gBACP,MAAM,EAAE,KAAK;gBACb,aAAa,EAAE,UAAU,KAAK,EAAE;aACjC;SACF,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,oCAAoC,SAAS,KAAK,KAAK,EAAE,CAAC,CAAC;IAC3E,CAAC;AACH,CAAC,CAAC;AAfW,QAAA,aAAa,iBAexB"}
1
+ {"version":3,"file":"messageService.js","sourceRoot":"","sources":["../../../src/services/messageService.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,+CAAyC;AACzC,gDAA6C;AAC7C,sCAA+D;AAmB/D;;;;;;;;;;;;;;;;;;;;GAoBG;AACI,MAAM,cAAc,GAAG,KAAK,EACjC,OAAyB,EACO,EAAE;IAClC,MAAM,EACJ,WAAW,GAAG,KAAK,EACnB,YAAY,GAAG,IAAI,EACnB,UAAU,GAAG,KAAK,EAClB,eAAe,GAAG,KAAK,GACxB,GAAG,OAAO,IAAI,EAAE,CAAC;IAElB,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC7B,MAAM,MAAM,GAAG,CAAC,OAAe,EAAE,EAAE,CAAC,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAEvE,MAAM,CACJ,qCACE,WAAW,GAAG,IAChB,uBAAuB,YAAY,GAAG,IAAI,MAAM,CACjD,CAAC;IACF,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,SAA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ACb,gCAAgC,WAAW,GAAG,IAAI,kBAAkB,CACrE,CAAC;AACJ,CAAC,CAAC;AA3DW,QAAA,cAAc,kBA2DzB;AAEF;;;;;;;;;;;;;;;GAeG;AACI,MAAM,aAAa,GAAG,KAAK,EAAE,SAAiB,EAAiB,EAAE;IACtE,MAAM,KAAK,GAAG,IAAA,sBAAQ,GAAE,CAAC;IACzB,IAAI,CAAC,KAAK;QACR,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;IAE1E,IAAI,CAAC;QACH,MAAM,eAAK,CAAC,MAAM,CAAC,GAAG,mBAAQ,aAAa,SAAS,EAAE,EAAE;YACtD,OAAO,EAAE;gBACP,MAAM,EAAE,KAAK;gBACb,aAAa,EAAE,UAAU,KAAK,EAAE;aACjC;SACF,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,oCAAoC,SAAS,KAAK,KAAK,EAAE,CAAC,CAAC;IAC3E,CAAC;AACH,CAAC,CAAC;AAfW,QAAA,aAAa,iBAexB"}
@@ -1,7 +1,102 @@
1
+ interface EmailAccount {
2
+ id: string;
3
+ address: string;
4
+ quota: number;
5
+ used: number;
6
+ isDisabled: boolean;
7
+ isDeleted: boolean;
8
+ createdAt: string;
9
+ updatedAt: string;
10
+ }
11
+ interface ListOfDomains {
12
+ id: string;
13
+ domain: string;
14
+ isActive: boolean;
15
+ isPrivate: boolean;
16
+ createdAt: string;
17
+ updatedAt: string;
18
+ }
19
+ interface Address {
20
+ address: string;
21
+ name: string;
22
+ }
23
+ interface EmailObject {
24
+ id: string;
25
+ msgid: string;
26
+ from: Address;
27
+ to: Address[];
28
+ subject: string;
29
+ intro: string;
30
+ seen: boolean;
31
+ isDeleted: boolean;
32
+ hasAttachments: boolean;
33
+ size: number;
34
+ downloadUrl: string;
35
+ sourceUrl: string;
36
+ createdAt: string;
37
+ updatedAt: string;
38
+ accountId: string;
39
+ }
40
+ interface Attachment {
41
+ id: string;
42
+ filename: string;
43
+ contentType: string;
44
+ disposition: string;
45
+ transferEncoding: string;
46
+ related: boolean;
47
+ size: number;
48
+ downloadUrl: string;
49
+ }
50
+ interface EmailResource {
51
+ id: string;
52
+ msgid: string;
53
+ from: Address;
54
+ to: Address[];
55
+ cc: Address[];
56
+ bcc: Address[];
57
+ subject: string;
58
+ intro: string;
59
+ seen: boolean;
60
+ flagged: boolean;
61
+ isDeleted: boolean;
62
+ verifications: string[];
63
+ retention: boolean;
64
+ retentionDate: string;
65
+ text: string;
66
+ html: string[];
67
+ hasAttachments: boolean;
68
+ attachments: Attachment[];
69
+ size: number;
70
+ downloadUrl: string;
71
+ sourceUrl: string;
72
+ createdAt: string;
73
+ updatedAt: string;
74
+ accountId: string;
75
+ }
1
76
  export declare const getAuthHeaders: () => {
2
77
  accept: string;
3
78
  Authorization: string;
4
79
  };
5
- export declare const fetchMessages: () => Promise<any[]>;
6
- export declare const fetchMessageContent: (messageId: string) => Promise<any>;
80
+ export declare const getDomains: () => Promise<ListOfDomains[]>;
81
+ export declare const getMessages: () => Promise<EmailObject[]>;
82
+ export declare const getMessagesContent: (messageId: string) => Promise<EmailResource>;
83
+ export declare const getMessageAttachments: (messageId: string, attachmentsId: string) => Promise<any>;
84
+ export declare const deleteMessage: (messageId: string) => Promise<number>;
85
+ export declare const createAccount: (payload: {
86
+ address: string;
87
+ password: string;
88
+ }) => Promise<EmailAccount>;
89
+ /**
90
+ * Deletes the account created during `generateEmail`.
91
+ *
92
+ * @returns {Promise<number>} status code of 204 when the account is successfully deleted.
93
+ *
94
+ * @throws {Error} If no account is authenticated or deletion fails.
95
+ *
96
+ * @example
97
+ * await deleteAccount();
98
+ * console.log("Account deleted successfully.");
99
+ */
100
+ export declare const deleteAccount: (accountId: string) => Promise<number>;
101
+ export {};
7
102
  //# sourceMappingURL=api.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/utils/api.ts"],"names":[],"mappings":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