temp-disposable-email 1.11.7 → 1.12.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.
- package/README.md +28 -18
- package/cypress.config.ts +1 -0
- package/dist/cjs/index.d.ts +2 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +4 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/services/accountService.d.ts +10 -27
- package/dist/cjs/services/accountService.d.ts.map +1 -1
- package/dist/cjs/services/accountService.js +18 -60
- package/dist/cjs/services/accountService.js.map +1 -1
- package/dist/cjs/services/messageService.d.ts +7 -1
- package/dist/cjs/services/messageService.d.ts.map +1 -1
- package/dist/cjs/services/messageService.js +19 -42
- package/dist/cjs/services/messageService.js.map +1 -1
- package/dist/cjs/utils/api.d.ts +97 -2
- package/dist/cjs/utils/api.d.ts.map +1 -1
- package/dist/cjs/utils/api.js +79 -9
- package/dist/cjs/utils/api.js.map +1 -1
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/services/accountService.d.ts +10 -27
- package/dist/esm/services/accountService.d.ts.map +1 -1
- package/dist/esm/services/accountService.js +17 -55
- package/dist/esm/services/accountService.js.map +1 -1
- package/dist/esm/services/messageService.d.ts +7 -1
- package/dist/esm/services/messageService.d.ts.map +1 -1
- package/dist/esm/services/messageService.js +20 -43
- package/dist/esm/services/messageService.js.map +1 -1
- package/dist/esm/utils/api.d.ts +97 -2
- package/dist/esm/utils/api.d.ts.map +1 -1
- package/dist/esm/utils/api.js +71 -6
- package/dist/esm/utils/api.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +2 -1
- package/src/services/accountService.ts +26 -66
- package/src/services/messageService.ts +38 -57
- package/src/utils/api.ts +163 -6
package/dist/cjs/utils/api.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.deleteAccount = exports.createAccount = exports.deleteMessage = exports.getMessageAttachments = exports.getMessagesContent = exports.getMessages = exports.getDomains = exports.getAuthHeaders = void 0;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
8
|
const constant_1 = require("./constant");
|
|
9
9
|
const authService_1 = require("../services/authService");
|
|
@@ -18,30 +18,100 @@ const getAuthHeaders = () => {
|
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
20
|
exports.getAuthHeaders = getAuthHeaders;
|
|
21
|
-
const
|
|
21
|
+
const getDomains = async () => {
|
|
22
22
|
try {
|
|
23
|
-
const
|
|
23
|
+
const { data } = await axios_1.default.get(`${constant_1.BASE_URL}/domains`, {
|
|
24
|
+
headers: { accept: 'application/json' },
|
|
25
|
+
});
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
console.error('Error fetching domains:', error);
|
|
30
|
+
throw new Error('Failed to fetch messages. Please try again later.');
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
exports.getDomains = getDomains;
|
|
34
|
+
const getMessages = async () => {
|
|
35
|
+
try {
|
|
36
|
+
const { data } = await axios_1.default.get(`${constant_1.BASE_URL}/messages`, {
|
|
24
37
|
headers: (0, exports.getAuthHeaders)(),
|
|
25
38
|
});
|
|
26
|
-
return
|
|
39
|
+
return data;
|
|
27
40
|
}
|
|
28
41
|
catch (error) {
|
|
29
42
|
console.error('Error fetching messages:', error);
|
|
30
43
|
throw new Error('Failed to fetch messages. Please try again later.');
|
|
31
44
|
}
|
|
32
45
|
};
|
|
33
|
-
exports.
|
|
34
|
-
const
|
|
46
|
+
exports.getMessages = getMessages;
|
|
47
|
+
const getMessagesContent = async (messageId) => {
|
|
35
48
|
try {
|
|
36
|
-
const
|
|
49
|
+
const { data } = await axios_1.default.get(`${constant_1.BASE_URL}/messages/${messageId}`, {
|
|
37
50
|
headers: (0, exports.getAuthHeaders)(),
|
|
38
51
|
});
|
|
39
|
-
return
|
|
52
|
+
return data;
|
|
40
53
|
}
|
|
41
54
|
catch (error) {
|
|
42
55
|
console.error(`Error fetching message content for ID ${messageId}:`, error);
|
|
43
56
|
throw new Error('Failed to fetch message content. Please try again later.');
|
|
44
57
|
}
|
|
45
58
|
};
|
|
46
|
-
exports.
|
|
59
|
+
exports.getMessagesContent = getMessagesContent;
|
|
60
|
+
const getMessageAttachments = async (messageId, attachmentsId) => {
|
|
61
|
+
try {
|
|
62
|
+
const { data } = await axios_1.default.get(`${constant_1.BASE_URL}/messages/${messageId}/attachment/${attachmentsId}`, {
|
|
63
|
+
headers: (0, exports.getAuthHeaders)(),
|
|
64
|
+
});
|
|
65
|
+
return data;
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
console.error(`Error fetching message attachment for ID ${messageId}:`, error);
|
|
69
|
+
throw new Error('Failed to fetch message content. Please try again later.');
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
exports.getMessageAttachments = getMessageAttachments;
|
|
73
|
+
const deleteMessage = async (messageId) => {
|
|
74
|
+
try {
|
|
75
|
+
const { status } = await axios_1.default.delete(`${constant_1.BASE_URL}/messages/${messageId}`, {
|
|
76
|
+
headers: (0, exports.getAuthHeaders)(),
|
|
77
|
+
});
|
|
78
|
+
return status;
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
console.error(`Error deleting message for ID ${messageId}:`, error);
|
|
82
|
+
throw new Error('Failed to fetch message content. Please try again later.');
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
exports.deleteMessage = deleteMessage;
|
|
86
|
+
const createAccount = async (payload) => {
|
|
87
|
+
const { data } = await axios_1.default.post(`${constant_1.BASE_URL}/accounts`, payload, {
|
|
88
|
+
headers: { accept: 'application/json' },
|
|
89
|
+
});
|
|
90
|
+
return data;
|
|
91
|
+
};
|
|
92
|
+
exports.createAccount = createAccount;
|
|
93
|
+
/**
|
|
94
|
+
* Deletes the account created during `generateEmail`.
|
|
95
|
+
*
|
|
96
|
+
* @returns {Promise<number>} status code of 204 when the account is successfully deleted.
|
|
97
|
+
*
|
|
98
|
+
* @throws {Error} If no account is authenticated or deletion fails.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* await deleteAccount();
|
|
102
|
+
* console.log("Account deleted successfully.");
|
|
103
|
+
*/
|
|
104
|
+
const deleteAccount = async (accountId) => {
|
|
105
|
+
try {
|
|
106
|
+
const { status } = await axios_1.default.delete(`${constant_1.BASE_URL}/accounts/${accountId}`, {
|
|
107
|
+
headers: (0, exports.getAuthHeaders)(),
|
|
108
|
+
});
|
|
109
|
+
return status;
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
console.error(`Error deleting account for ID ${accountId}:`, error);
|
|
113
|
+
throw new Error('Failed to fetch message content. Please try again later.');
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
exports.deleteAccount = deleteAccount;
|
|
47
117
|
//# sourceMappingURL=api.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/utils/api.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,yCAAsC;AACtC,yDAAmD;
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/utils/api.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,yCAAsC;AACtC,yDAAmD;AA+E5C,MAAM,cAAc,GAAG,GAAG,EAAE;IACjC,MAAM,KAAK,GAAG,IAAA,sBAAQ,GAAE,CAAC;IACzB,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAC/D,CAAC;IACD,OAAO;QACL,MAAM,EAAE,kBAAkB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M,aAAa,GAAG,KAAK,EAAE,OAGnC,EAAyB,EAAE;IAC1B,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,eAAK,CAAC,IAAI,CAAC,GAAG,mBAAQ,WAAW,EAAE,OAAO,EAAE;QACjE,OAAO,EAAE,EAAE,MAAM,EAAE,kBAAkB,EAAE;KACxC,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AARW,QAAA,aAAa,iBAQxB;AAEF;;;;;;;;;;GAUG;AACI,MAAM,aAAa,GAAG,KAAK,EAAE,SAAiB,EAAmB,EAAE;IACxE,IAAI,CAAC;QACH,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,eAAK,CAAC,MAAM,CAAC,GAAG,mBAAQ,aAAa,SAAS,EAAE,EAAE;YACzE,OAAO,EAAE,IAAA,sBAAc,GAAE;SAC1B,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,iCAAiC,SAAS,GAAG,EAAE,KAAK,CAAC,CAAC;QACpE,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;IAC9E,CAAC;AACH,CAAC,CAAC;AAVW,QAAA,aAAa,iBAUxB"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export {
|
|
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
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,
|
|
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/esm/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as dotenv from 'dotenv';
|
|
2
2
|
dotenv.config();
|
|
3
|
-
export {
|
|
3
|
+
export { generateEmail } from './services/accountService';
|
|
4
|
+
export { deleteAccount } from './utils/api';
|
|
4
5
|
export { getRecentEmail, deleteMessage, } from './services/messageService';
|
|
5
6
|
export { getVerificationCode } from './utils/getVerificationCode';
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,OAAO,EAAE,aAAa,EAAkB,MAAM,2BAA2B,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EACL,cAAc,EACd,aAAa,GAGd,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -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
|
|
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} [
|
|
11
|
-
* @returns {Promise<
|
|
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
|
|
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
|
|
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":"
|
|
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,49 +1,40 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { authenticate, getToken } from './authService';
|
|
1
|
+
import { authenticate } from './authService';
|
|
3
2
|
import { generateRandomName } from '../utils/generateRandomName';
|
|
4
3
|
import { delay } from '../utils/delay';
|
|
5
|
-
import {
|
|
6
|
-
let accountId = null;
|
|
4
|
+
import { createAccount, getDomains } from '../utils/api';
|
|
7
5
|
/**
|
|
8
6
|
* Creates a new email inbox with a unique address.
|
|
9
7
|
*
|
|
10
|
-
* This function
|
|
11
|
-
* address, and attempts to create an account on the Mail.tm service.
|
|
12
|
-
* If account creation is rate-limited, the function retries with a
|
|
13
|
-
* delay. Upon successful creation, it authenticates the account and
|
|
14
|
-
* stores the token and account ID for future API calls.
|
|
8
|
+
* This function generates an temp inbox & email address
|
|
15
9
|
*
|
|
16
|
-
* @param {string} [
|
|
17
|
-
* @returns {Promise<
|
|
10
|
+
* @param {string} [emailPrefix] - Optional emailPrefix; a random one is generated if not provided.
|
|
11
|
+
* @returns {Promise<GeneratedEmail>} The generated email address & account ID.
|
|
18
12
|
*
|
|
19
13
|
* @throws {Error} If no domains are available or account creation fails.
|
|
20
14
|
*
|
|
21
15
|
* @example
|
|
22
|
-
* const email = await
|
|
23
|
-
* console.log(email); // Outputs: "customUser@mail.tm"
|
|
16
|
+
* const email = await generateEmail("customUser");
|
|
17
|
+
* console.log(email); // Outputs: {"emailAddress": "customUser@mail.tm" , "accountId": "1234"}
|
|
24
18
|
*/
|
|
25
|
-
export const
|
|
26
|
-
const domainsResponse = await
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
19
|
+
export const generateEmail = async (emailPrefix) => {
|
|
20
|
+
const domainsResponse = await getDomains();
|
|
21
|
+
const domains = domainsResponse
|
|
22
|
+
.filter((domain) => domain.isActive)
|
|
23
|
+
.map((domain) => domain.domain);
|
|
30
24
|
if (domains.length === 0)
|
|
31
25
|
throw new Error('No available domains.');
|
|
32
|
-
const emailAddress = `${
|
|
26
|
+
const emailAddress = `${emailPrefix || generateRandomName()}@${domains[0]}`;
|
|
33
27
|
const password = generateRandomName();
|
|
34
28
|
let attempts = 0;
|
|
35
29
|
const maxRetries = 5;
|
|
36
30
|
while (attempts < maxRetries) {
|
|
37
31
|
try {
|
|
38
|
-
const accountResponse = await
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
'Content-Type': 'application/json',
|
|
42
|
-
},
|
|
32
|
+
const accountResponse = await createAccount({
|
|
33
|
+
address: emailAddress,
|
|
34
|
+
password,
|
|
43
35
|
});
|
|
44
|
-
accountId = accountResponse.data.id;
|
|
45
36
|
await authenticate(emailAddress, password);
|
|
46
|
-
return emailAddress;
|
|
37
|
+
return { emailAddress, accountId: accountResponse.id };
|
|
47
38
|
}
|
|
48
39
|
catch (error) {
|
|
49
40
|
if (error.response?.status === 429) {
|
|
@@ -60,33 +51,4 @@ export const createInbox = async (username) => {
|
|
|
60
51
|
}
|
|
61
52
|
throw new Error('Failed to create account after multiple retries.');
|
|
62
53
|
};
|
|
63
|
-
/**
|
|
64
|
-
* Deletes the account created during `createInbox`.
|
|
65
|
-
*
|
|
66
|
-
* This function removes the email account from the Mail.tm service
|
|
67
|
-
* and clears the stored authentication token and account ID.
|
|
68
|
-
* Subsequent API calls requiring authentication will fail until a
|
|
69
|
-
* new account is created.
|
|
70
|
-
*
|
|
71
|
-
* @returns {Promise<void>} Resolves when the account is successfully deleted.
|
|
72
|
-
*
|
|
73
|
-
* @throws {Error} If no account is authenticated or deletion fails.
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* await deleteAccount();
|
|
77
|
-
* console.log("Account deleted successfully.");
|
|
78
|
-
*/
|
|
79
|
-
export const deleteAccount = async () => {
|
|
80
|
-
const token = getToken();
|
|
81
|
-
if (!token || !accountId) {
|
|
82
|
-
throw new Error('Account information missing. Create and authenticate an account first.');
|
|
83
|
-
}
|
|
84
|
-
await axios.delete(`${BASE_URL}/accounts/${accountId}`, {
|
|
85
|
-
headers: {
|
|
86
|
-
accept: '*/*',
|
|
87
|
-
Authorization: `Bearer ${token}`,
|
|
88
|
-
},
|
|
89
|
-
});
|
|
90
|
-
accountId = null;
|
|
91
|
-
};
|
|
92
54
|
//# sourceMappingURL=accountService.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accountService.js","sourceRoot":"","sources":["../../../src/services/accountService.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"accountService.js","sourceRoot":"","sources":["../../../src/services/accountService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAOzD;;;;;;;;;;;;;GAaG;AAEH,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAChC,WAAoB,EACK,EAAE;IAC3B,MAAM,eAAe,GAAG,MAAM,UAAU,EAAE,CAAC;IAC3C,MAAM,OAAO,GAAG,eAAe;SAC5B,MAAM,CAAC,CAAC,MAA6B,EAAE,EAAE,CAAC,MA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,CAAC"}
|
|
@@ -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;
|
|
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"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
import { getToken } from './authService';
|
|
3
3
|
import { BASE_URL } from '../utils/constant';
|
|
4
|
-
import {
|
|
4
|
+
import { getMessagesContent, getMessages } from '../utils/api';
|
|
5
5
|
/**
|
|
6
6
|
* Retrieves the latest message from the inbox.
|
|
7
7
|
*
|
|
@@ -11,6 +11,10 @@ import { fetchMessageContent, fetchMessages } from '../utils/api';
|
|
|
11
11
|
* deleted after reading.
|
|
12
12
|
*
|
|
13
13
|
* @param {GetEmailOptions} [options] - Optional settings for polling and deletion.
|
|
14
|
+
* @param {number} [options.maxWaitTime=30000] - Maximum time to wait for messages (in milliseconds). Default is 30 seconds.
|
|
15
|
+
* @param {number} [options.waitInterval=2000] - Time interval between polling attempts (in milliseconds). Default is 2 seconds.
|
|
16
|
+
* @param {boolean} [options.logPolling=false] - Whether to log polling attempts. Default is `false`.
|
|
17
|
+
* @param {boolean} [options.deleteAfterRead=false] - Whether to delete the message after reading. Default is `false`.
|
|
14
18
|
* @returns {Promise<MessageContent | null>} The email content (sender, recipient, subject, text, HTML), or `null` if no messages are found.
|
|
15
19
|
*
|
|
16
20
|
* @throws {Error} If no messages are available within the polling timeout or authentication fails.
|
|
@@ -20,63 +24,36 @@ import { fetchMessageContent, fetchMessages } from '../utils/api';
|
|
|
20
24
|
* console.log(message.subject); // Outputs: "Hello!"
|
|
21
25
|
*/
|
|
22
26
|
export const getRecentEmail = async (options) => {
|
|
23
|
-
const token = getToken();
|
|
24
27
|
const { maxWaitTime = 30000, waitInterval = 2000, logPolling = false, deleteAfterRead = false, } = options || {};
|
|
25
|
-
if (!token)
|
|
26
|
-
throw new Error('Authentication required. Call createInbox() first.');
|
|
27
|
-
if (!options) {
|
|
28
|
-
const messages = await fetchMessages();
|
|
29
|
-
if (messages.length === 0)
|
|
30
|
-
throw new Error('No messages available');
|
|
31
|
-
const messageId = messages[0].id;
|
|
32
|
-
const { from, to, subject, intro, text, html } = await fetchMessageContent(messageId);
|
|
33
|
-
if (deleteAfterRead) {
|
|
34
|
-
await deleteMessage(messageId);
|
|
35
|
-
}
|
|
36
|
-
return {
|
|
37
|
-
from: from.address,
|
|
38
|
-
to: to[0].address,
|
|
39
|
-
subject,
|
|
40
|
-
intro,
|
|
41
|
-
text,
|
|
42
|
-
html,
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
28
|
const startTime = Date.now();
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
29
|
+
const logger = (message) => logPolling && console.log(message);
|
|
30
|
+
logger(`Polling started with a timeout of ${maxWaitTime / 1000}sec and interval of ${waitInterval / 1000}sec.`);
|
|
49
31
|
while (Date.now() - startTime < maxWaitTime) {
|
|
50
|
-
const messages = await
|
|
32
|
+
const messages = await getMessages();
|
|
51
33
|
if (messages.length > 0) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
console.log(`Message retrieved`);
|
|
58
|
-
}
|
|
59
|
-
const { from, to, subject, intro, text, html } = await fetchMessageContent(messageId);
|
|
34
|
+
logger(`Found ${messages.length} message(s), fetching details...`);
|
|
35
|
+
const sortedMessages = messages.sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime());
|
|
36
|
+
const messageId = sortedMessages[0].id;
|
|
37
|
+
logger(`Found ${messageId}`);
|
|
38
|
+
const { from, to, subject, intro, text, html, createdAt, updatedAt } = await getMessagesContent(messageId);
|
|
60
39
|
if (deleteAfterRead) {
|
|
61
40
|
await deleteMessage(messageId);
|
|
62
41
|
}
|
|
63
42
|
return {
|
|
64
|
-
from: from
|
|
65
|
-
to: to
|
|
43
|
+
from: from,
|
|
44
|
+
to: to,
|
|
66
45
|
subject,
|
|
67
46
|
intro,
|
|
68
47
|
text,
|
|
69
48
|
html,
|
|
49
|
+
createdAt,
|
|
50
|
+
updatedAt,
|
|
70
51
|
};
|
|
71
52
|
}
|
|
72
53
|
await new Promise((resolve) => setTimeout(resolve, waitInterval));
|
|
73
|
-
|
|
74
|
-
console.log(`No messages found, waiting for ${waitInterval / 1000} seconds...`);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
if (logPolling) {
|
|
78
|
-
console.log(`Waiting timeout of ${maxWaitTime / 1000} seconds reached. No messages found.`);
|
|
54
|
+
logger(`No messages found, waiting for ${waitInterval / 1000} seconds...`);
|
|
79
55
|
}
|
|
56
|
+
logger(`Waiting timeout of ${maxWaitTime / 1000} seconds reached. No messages found.`);
|
|
80
57
|
throw new Error(`No messages available within ${maxWaitTime / 1000} seconds timeout`);
|
|
81
58
|
};
|
|
82
59
|
/**
|
|
@@ -98,7 +75,7 @@ export const getRecentEmail = async (options) => {
|
|
|
98
75
|
export const deleteMessage = async (messageId) => {
|
|
99
76
|
const token = getToken();
|
|
100
77
|
if (!token)
|
|
101
|
-
throw new Error('Authentication required. Call
|
|
78
|
+
throw new Error('Authentication required. Call generateEmail() first.');
|
|
102
79
|
try {
|
|
103
80
|
await axios.delete(`${BASE_URL}/messages/${messageId}`, {
|
|
104
81
|
headers: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messageService.js","sourceRoot":"","sources":["../../../src/services/messageService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"messageService.js","sourceRoot":"","sources":["../../../src/services/messageService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAmB/D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,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,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AAC;IAEF,MAAM,IAAI,KAAK,CACb,gCAAgC,WAAW,GAAG,IAAI,kBAAkB,CACrE,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAAE,SAAiB,EAAiB,EAAE;IACtE,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;IACzB,IAAI,CAAC,KAAK;QACR,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;IAE1E,IAAI,CAAC;QACH,MAAM,KAAK,CAAC,MAAM,CAAC,GAAG,QAAQ,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"}
|
package/dist/esm/utils/api.d.ts
CHANGED
|
@@ -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
|
|
6
|
-
export declare const
|
|
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":"AAIA,eAAO,MAAM,cAAc;;;CAS1B,CAAC;AAEF,eAAO,MAAM,aAAa,QAAa,OAAO,CAAC,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/utils/api.ts"],"names":[],"mappings":"AAIA,UAAU,YAAY;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AACD,UAAU,aAAa;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAA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