tempmail-sdk 1.0.0 → 1.0.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 +153 -153
- package/demo/poll-emails.ts +187 -187
- package/dist/index.js +1 -1
- package/dist/providers/chatgpt-org-uk.js +1 -1
- package/dist/providers/linshi-email.js +1 -1
- package/dist/providers/tempmail-lol.js +1 -1
- package/dist/providers/tempmail.js +1 -1
- package/dist/types.js +1 -1
- package/package.json +37 -37
- package/src/global.d.ts +5 -5
- package/src/index.ts +133 -133
- package/src/providers/chatgpt-org-uk.ts +57 -57
- package/src/providers/linshi-email.ts +61 -61
- package/src/providers/tempmail-lol.ts +53 -53
- package/src/providers/tempmail.ts +59 -59
- package/src/types.ts +58 -58
- package/test/example.ts +48 -48
- package/tsconfig.json +27 -27
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
import { EmailInfo, Email, Channel } from '../types';
|
|
2
|
-
|
|
3
|
-
const CHANNEL: Channel = 'linshi-email';
|
|
4
|
-
const BASE_URL = 'https://www.linshi-email.com/api/v1';
|
|
5
|
-
const API_KEY = '552562b8524879814776e52bc8de5c9f';
|
|
6
|
-
|
|
7
|
-
const DEFAULT_HEADERS = {
|
|
8
|
-
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36',
|
|
9
|
-
'Content-Type': 'application/json',
|
|
10
|
-
'Origin': 'https://www.linshi-email.com',
|
|
11
|
-
'Referer': 'https://www.linshi-email.com/',
|
|
12
|
-
'sec-ch-ua': '"Microsoft Edge";v="143", "Chromium";v="143", "Not A(Brand";v="24"',
|
|
13
|
-
'sec-ch-ua-mobile': '?0',
|
|
14
|
-
'sec-ch-ua-platform': '"Windows"',
|
|
15
|
-
'DNT': '1',
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export async function generateEmail(): Promise<EmailInfo> {
|
|
19
|
-
const response = await fetch(`${BASE_URL}/email/${API_KEY}`, {
|
|
20
|
-
method: 'POST',
|
|
21
|
-
headers: DEFAULT_HEADERS,
|
|
22
|
-
body: JSON.stringify({}),
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
if (!response.ok) {
|
|
26
|
-
throw new Error(`Failed to generate email: ${response.status}`);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const data = await response.json();
|
|
30
|
-
|
|
31
|
-
if (data.status !== 'ok') {
|
|
32
|
-
throw new Error('Failed to generate email');
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return {
|
|
36
|
-
channel: CHANNEL,
|
|
37
|
-
email: data.data.email,
|
|
38
|
-
expiresAt: data.data.expired,
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export async function getEmails(email: string): Promise<Email[]> {
|
|
43
|
-
const encodedEmail = encodeURIComponent(email);
|
|
44
|
-
const timestamp = Date.now();
|
|
45
|
-
const response = await fetch(`${BASE_URL}/refreshmessage/${API_KEY}/${encodedEmail}?t=${timestamp}`, {
|
|
46
|
-
method: 'GET',
|
|
47
|
-
headers: DEFAULT_HEADERS,
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
if (!response.ok) {
|
|
51
|
-
throw new Error(`Failed to get emails: ${response.status}`);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const data = await response.json();
|
|
55
|
-
|
|
56
|
-
if (data.status !== 'ok') {
|
|
57
|
-
throw new Error('Failed to get emails');
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return data.list || [];
|
|
61
|
-
}
|
|
1
|
+
import { EmailInfo, Email, Channel } from '../types';
|
|
2
|
+
|
|
3
|
+
const CHANNEL: Channel = 'linshi-email';
|
|
4
|
+
const BASE_URL = 'https://www.linshi-email.com/api/v1';
|
|
5
|
+
const API_KEY = '552562b8524879814776e52bc8de5c9f';
|
|
6
|
+
|
|
7
|
+
const DEFAULT_HEADERS = {
|
|
8
|
+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36',
|
|
9
|
+
'Content-Type': 'application/json',
|
|
10
|
+
'Origin': 'https://www.linshi-email.com',
|
|
11
|
+
'Referer': 'https://www.linshi-email.com/',
|
|
12
|
+
'sec-ch-ua': '"Microsoft Edge";v="143", "Chromium";v="143", "Not A(Brand";v="24"',
|
|
13
|
+
'sec-ch-ua-mobile': '?0',
|
|
14
|
+
'sec-ch-ua-platform': '"Windows"',
|
|
15
|
+
'DNT': '1',
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export async function generateEmail(): Promise<EmailInfo> {
|
|
19
|
+
const response = await fetch(`${BASE_URL}/email/${API_KEY}`, {
|
|
20
|
+
method: 'POST',
|
|
21
|
+
headers: DEFAULT_HEADERS,
|
|
22
|
+
body: JSON.stringify({}),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
if (!response.ok) {
|
|
26
|
+
throw new Error(`Failed to generate email: ${response.status}`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const data = await response.json();
|
|
30
|
+
|
|
31
|
+
if (data.status !== 'ok') {
|
|
32
|
+
throw new Error('Failed to generate email');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
channel: CHANNEL,
|
|
37
|
+
email: data.data.email,
|
|
38
|
+
expiresAt: data.data.expired,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export async function getEmails(email: string): Promise<Email[]> {
|
|
43
|
+
const encodedEmail = encodeURIComponent(email);
|
|
44
|
+
const timestamp = Date.now();
|
|
45
|
+
const response = await fetch(`${BASE_URL}/refreshmessage/${API_KEY}/${encodedEmail}?t=${timestamp}`, {
|
|
46
|
+
method: 'GET',
|
|
47
|
+
headers: DEFAULT_HEADERS,
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
if (!response.ok) {
|
|
51
|
+
throw new Error(`Failed to get emails: ${response.status}`);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const data = await response.json();
|
|
55
|
+
|
|
56
|
+
if (data.status !== 'ok') {
|
|
57
|
+
throw new Error('Failed to get emails');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return data.list || [];
|
|
61
|
+
}
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import { EmailInfo, Email, Channel } from '../types';
|
|
2
|
-
|
|
3
|
-
const CHANNEL: Channel = 'tempmail-lol';
|
|
4
|
-
const BASE_URL = 'https://api.tempmail.lol/v2';
|
|
5
|
-
|
|
6
|
-
const DEFAULT_HEADERS = {
|
|
7
|
-
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36',
|
|
8
|
-
'Content-Type': 'application/json',
|
|
9
|
-
'Origin': 'https://tempmail.lol',
|
|
10
|
-
'sec-ch-ua': '"Microsoft Edge";v="143", "Chromium";v="143", "Not A(Brand";v="24"',
|
|
11
|
-
'sec-ch-ua-mobile': '?0',
|
|
12
|
-
'sec-ch-ua-platform': '"Windows"',
|
|
13
|
-
'DNT': '1',
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export async function generateEmail(domain: string | null = null): Promise<EmailInfo> {
|
|
17
|
-
const response = await fetch(`${BASE_URL}/inbox/create`, {
|
|
18
|
-
method: 'POST',
|
|
19
|
-
headers: DEFAULT_HEADERS,
|
|
20
|
-
body: JSON.stringify({ domain, captcha: null }),
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
if (!response.ok) {
|
|
24
|
-
throw new Error(`Failed to generate email: ${response.status}`);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const data = await response.json();
|
|
28
|
-
|
|
29
|
-
if (!data.address || !data.token) {
|
|
30
|
-
throw new Error('Failed to generate email');
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return {
|
|
34
|
-
channel: CHANNEL,
|
|
35
|
-
email: data.address,
|
|
36
|
-
token: data.token,
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export async function getEmails(token: string): Promise<Email[]> {
|
|
41
|
-
const response = await fetch(`${BASE_URL}/inbox?token=${encodeURIComponent(token)}`, {
|
|
42
|
-
method: 'GET',
|
|
43
|
-
headers: DEFAULT_HEADERS,
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
if (!response.ok) {
|
|
47
|
-
throw new Error(`Failed to get emails: ${response.status}`);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const data = await response.json();
|
|
51
|
-
|
|
52
|
-
return data.emails || [];
|
|
53
|
-
}
|
|
1
|
+
import { EmailInfo, Email, Channel } from '../types';
|
|
2
|
+
|
|
3
|
+
const CHANNEL: Channel = 'tempmail-lol';
|
|
4
|
+
const BASE_URL = 'https://api.tempmail.lol/v2';
|
|
5
|
+
|
|
6
|
+
const DEFAULT_HEADERS = {
|
|
7
|
+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36',
|
|
8
|
+
'Content-Type': 'application/json',
|
|
9
|
+
'Origin': 'https://tempmail.lol',
|
|
10
|
+
'sec-ch-ua': '"Microsoft Edge";v="143", "Chromium";v="143", "Not A(Brand";v="24"',
|
|
11
|
+
'sec-ch-ua-mobile': '?0',
|
|
12
|
+
'sec-ch-ua-platform': '"Windows"',
|
|
13
|
+
'DNT': '1',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export async function generateEmail(domain: string | null = null): Promise<EmailInfo> {
|
|
17
|
+
const response = await fetch(`${BASE_URL}/inbox/create`, {
|
|
18
|
+
method: 'POST',
|
|
19
|
+
headers: DEFAULT_HEADERS,
|
|
20
|
+
body: JSON.stringify({ domain, captcha: null }),
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
if (!response.ok) {
|
|
24
|
+
throw new Error(`Failed to generate email: ${response.status}`);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const data = await response.json();
|
|
28
|
+
|
|
29
|
+
if (!data.address || !data.token) {
|
|
30
|
+
throw new Error('Failed to generate email');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
channel: CHANNEL,
|
|
35
|
+
email: data.address,
|
|
36
|
+
token: data.token,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export async function getEmails(token: string): Promise<Email[]> {
|
|
41
|
+
const response = await fetch(`${BASE_URL}/inbox?token=${encodeURIComponent(token)}`, {
|
|
42
|
+
method: 'GET',
|
|
43
|
+
headers: DEFAULT_HEADERS,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
if (!response.ok) {
|
|
47
|
+
throw new Error(`Failed to get emails: ${response.status}`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const data = await response.json();
|
|
51
|
+
|
|
52
|
+
return data.emails || [];
|
|
53
|
+
}
|
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
import { EmailInfo, Email, Channel } from '../types';
|
|
2
|
-
|
|
3
|
-
const CHANNEL: Channel = 'tempmail';
|
|
4
|
-
const BASE_URL = 'https://api.tempmail.ing/api';
|
|
5
|
-
|
|
6
|
-
const DEFAULT_HEADERS = {
|
|
7
|
-
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36',
|
|
8
|
-
'Content-Type': 'application/json',
|
|
9
|
-
'Referer': 'https://tempmail.ing/',
|
|
10
|
-
'sec-ch-ua': '"Microsoft Edge";v="143", "Chromium";v="143", "Not A(Brand";v="24"',
|
|
11
|
-
'sec-ch-ua-mobile': '?0',
|
|
12
|
-
'sec-ch-ua-platform': '"Windows"',
|
|
13
|
-
'DNT': '1',
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export async function generateEmail(duration: number = 30): Promise<EmailInfo> {
|
|
17
|
-
const response = await fetch(`${BASE_URL}/generate`, {
|
|
18
|
-
method: 'POST',
|
|
19
|
-
headers: DEFAULT_HEADERS,
|
|
20
|
-
body: JSON.stringify({ duration }),
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
if (!response.ok) {
|
|
24
|
-
throw new Error(`Failed to generate email: ${response.status}`);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const data = await response.json();
|
|
28
|
-
|
|
29
|
-
if (!data.success) {
|
|
30
|
-
throw new Error('Failed to generate email');
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return {
|
|
34
|
-
channel: CHANNEL,
|
|
35
|
-
email: data.email.address,
|
|
36
|
-
expiresAt: data.email.expiresAt,
|
|
37
|
-
createdAt: data.email.createdAt,
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export async function getEmails(email: string): Promise<Email[]> {
|
|
42
|
-
const encodedEmail = encodeURIComponent(email);
|
|
43
|
-
const response = await fetch(`${BASE_URL}/emails/${encodedEmail}`, {
|
|
44
|
-
method: 'GET',
|
|
45
|
-
headers: DEFAULT_HEADERS,
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
if (!response.ok) {
|
|
49
|
-
throw new Error(`Failed to get emails: ${response.status}`);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const data = await response.json();
|
|
53
|
-
|
|
54
|
-
if (!data.success) {
|
|
55
|
-
throw new Error('Failed to get emails');
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return data.emails || [];
|
|
59
|
-
}
|
|
1
|
+
import { EmailInfo, Email, Channel } from '../types';
|
|
2
|
+
|
|
3
|
+
const CHANNEL: Channel = 'tempmail';
|
|
4
|
+
const BASE_URL = 'https://api.tempmail.ing/api';
|
|
5
|
+
|
|
6
|
+
const DEFAULT_HEADERS = {
|
|
7
|
+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36',
|
|
8
|
+
'Content-Type': 'application/json',
|
|
9
|
+
'Referer': 'https://tempmail.ing/',
|
|
10
|
+
'sec-ch-ua': '"Microsoft Edge";v="143", "Chromium";v="143", "Not A(Brand";v="24"',
|
|
11
|
+
'sec-ch-ua-mobile': '?0',
|
|
12
|
+
'sec-ch-ua-platform': '"Windows"',
|
|
13
|
+
'DNT': '1',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export async function generateEmail(duration: number = 30): Promise<EmailInfo> {
|
|
17
|
+
const response = await fetch(`${BASE_URL}/generate`, {
|
|
18
|
+
method: 'POST',
|
|
19
|
+
headers: DEFAULT_HEADERS,
|
|
20
|
+
body: JSON.stringify({ duration }),
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
if (!response.ok) {
|
|
24
|
+
throw new Error(`Failed to generate email: ${response.status}`);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const data = await response.json();
|
|
28
|
+
|
|
29
|
+
if (!data.success) {
|
|
30
|
+
throw new Error('Failed to generate email');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
channel: CHANNEL,
|
|
35
|
+
email: data.email.address,
|
|
36
|
+
expiresAt: data.email.expiresAt,
|
|
37
|
+
createdAt: data.email.createdAt,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export async function getEmails(email: string): Promise<Email[]> {
|
|
42
|
+
const encodedEmail = encodeURIComponent(email);
|
|
43
|
+
const response = await fetch(`${BASE_URL}/emails/${encodedEmail}`, {
|
|
44
|
+
method: 'GET',
|
|
45
|
+
headers: DEFAULT_HEADERS,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
if (!response.ok) {
|
|
49
|
+
throw new Error(`Failed to get emails: ${response.status}`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const data = await response.json();
|
|
53
|
+
|
|
54
|
+
if (!data.success) {
|
|
55
|
+
throw new Error('Failed to get emails');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return data.emails || [];
|
|
59
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
export type Channel = 'tempmail' | 'linshi-email' | 'tempmail-lol' | 'chatgpt-org-uk';
|
|
2
|
-
|
|
3
|
-
export interface EmailInfo {
|
|
4
|
-
channel: Channel;
|
|
5
|
-
email: string;
|
|
6
|
-
token?: string;
|
|
7
|
-
expiresAt?: string | number;
|
|
8
|
-
createdAt?: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface Email {
|
|
12
|
-
id?: string | number;
|
|
13
|
-
eid?: string;
|
|
14
|
-
_id?: string;
|
|
15
|
-
from?: string;
|
|
16
|
-
from_address?: string;
|
|
17
|
-
from_name?: string;
|
|
18
|
-
address_from?: string;
|
|
19
|
-
name_from?: string;
|
|
20
|
-
to?: string;
|
|
21
|
-
name_to?: string;
|
|
22
|
-
email_address?: string;
|
|
23
|
-
subject?: string;
|
|
24
|
-
e_subject?: string;
|
|
25
|
-
body?: string;
|
|
26
|
-
text?: string;
|
|
27
|
-
content?: string;
|
|
28
|
-
html?: string;
|
|
29
|
-
html_content?: string;
|
|
30
|
-
date?: string | number;
|
|
31
|
-
e_date?: number;
|
|
32
|
-
timestamp?: number;
|
|
33
|
-
received_at?: string;
|
|
34
|
-
created_at?: string;
|
|
35
|
-
createdAt?: string;
|
|
36
|
-
is_read?: number;
|
|
37
|
-
has_html?: boolean;
|
|
38
|
-
[key: string]: any;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export interface GetEmailsResult {
|
|
42
|
-
channel: Channel;
|
|
43
|
-
email: string;
|
|
44
|
-
emails: Email[];
|
|
45
|
-
success: boolean;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export interface GenerateEmailOptions {
|
|
49
|
-
channel?: Channel;
|
|
50
|
-
duration?: number;
|
|
51
|
-
domain?: string | null;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export interface GetEmailsOptions {
|
|
55
|
-
channel: Channel;
|
|
56
|
-
email: string;
|
|
57
|
-
token?: string;
|
|
58
|
-
}
|
|
1
|
+
export type Channel = 'tempmail' | 'linshi-email' | 'tempmail-lol' | 'chatgpt-org-uk';
|
|
2
|
+
|
|
3
|
+
export interface EmailInfo {
|
|
4
|
+
channel: Channel;
|
|
5
|
+
email: string;
|
|
6
|
+
token?: string;
|
|
7
|
+
expiresAt?: string | number;
|
|
8
|
+
createdAt?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface Email {
|
|
12
|
+
id?: string | number;
|
|
13
|
+
eid?: string;
|
|
14
|
+
_id?: string;
|
|
15
|
+
from?: string;
|
|
16
|
+
from_address?: string;
|
|
17
|
+
from_name?: string;
|
|
18
|
+
address_from?: string;
|
|
19
|
+
name_from?: string;
|
|
20
|
+
to?: string;
|
|
21
|
+
name_to?: string;
|
|
22
|
+
email_address?: string;
|
|
23
|
+
subject?: string;
|
|
24
|
+
e_subject?: string;
|
|
25
|
+
body?: string;
|
|
26
|
+
text?: string;
|
|
27
|
+
content?: string;
|
|
28
|
+
html?: string;
|
|
29
|
+
html_content?: string;
|
|
30
|
+
date?: string | number;
|
|
31
|
+
e_date?: number;
|
|
32
|
+
timestamp?: number;
|
|
33
|
+
received_at?: string;
|
|
34
|
+
created_at?: string;
|
|
35
|
+
createdAt?: string;
|
|
36
|
+
is_read?: number;
|
|
37
|
+
has_html?: boolean;
|
|
38
|
+
[key: string]: any;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface GetEmailsResult {
|
|
42
|
+
channel: Channel;
|
|
43
|
+
email: string;
|
|
44
|
+
emails: Email[];
|
|
45
|
+
success: boolean;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface GenerateEmailOptions {
|
|
49
|
+
channel?: Channel;
|
|
50
|
+
duration?: number;
|
|
51
|
+
domain?: string | null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface GetEmailsOptions {
|
|
55
|
+
channel: Channel;
|
|
56
|
+
email: string;
|
|
57
|
+
token?: string;
|
|
58
|
+
}
|
package/test/example.ts
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import { generateEmail, getEmails, TempEmailClient, Channel } from '../src';
|
|
2
|
-
|
|
3
|
-
async function testGenerateEmail() {
|
|
4
|
-
console.log('=== Test Generate Email ===\n');
|
|
5
|
-
|
|
6
|
-
// Test each channel
|
|
7
|
-
const channels: Channel[] = ['tempmail', 'linshi-email', 'tempmail-lol', 'chatgpt-org-uk'];
|
|
8
|
-
|
|
9
|
-
for (const channel of channels) {
|
|
10
|
-
try {
|
|
11
|
-
console.log(`Testing channel: ${channel}`);
|
|
12
|
-
const emailInfo = await generateEmail({ channel });
|
|
13
|
-
console.log(` Channel: ${emailInfo.channel}`);
|
|
14
|
-
console.log(` Email: ${emailInfo.email}`);
|
|
15
|
-
if (emailInfo.token) console.log(` Token: ${emailInfo.token}`);
|
|
16
|
-
if (emailInfo.expiresAt) console.log(` Expires: ${emailInfo.expiresAt}`);
|
|
17
|
-
console.log();
|
|
18
|
-
} catch (error) {
|
|
19
|
-
console.error(` Error: ${error}`);
|
|
20
|
-
console.log();
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
async function testGetEmails() {
|
|
26
|
-
console.log('=== Test Get Emails ===\n');
|
|
27
|
-
|
|
28
|
-
// Generate and check emails using client
|
|
29
|
-
const client = new TempEmailClient();
|
|
30
|
-
|
|
31
|
-
try {
|
|
32
|
-
const emailInfo = await client.generate({ channel: 'tempmail' });
|
|
33
|
-
console.log(`Generated: ${emailInfo.channel} - ${emailInfo.email}`);
|
|
34
|
-
|
|
35
|
-
const result = await client.getEmails();
|
|
36
|
-
console.log(`Emails count: ${result.emails.length}`);
|
|
37
|
-
console.log();
|
|
38
|
-
} catch (error) {
|
|
39
|
-
console.error(`Error: ${error}`);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
async function main() {
|
|
44
|
-
await testGenerateEmail();
|
|
45
|
-
await testGetEmails();
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
main().catch(console.error);
|
|
1
|
+
import { generateEmail, getEmails, TempEmailClient, Channel } from '../src';
|
|
2
|
+
|
|
3
|
+
async function testGenerateEmail() {
|
|
4
|
+
console.log('=== Test Generate Email ===\n');
|
|
5
|
+
|
|
6
|
+
// Test each channel
|
|
7
|
+
const channels: Channel[] = ['tempmail', 'linshi-email', 'tempmail-lol', 'chatgpt-org-uk'];
|
|
8
|
+
|
|
9
|
+
for (const channel of channels) {
|
|
10
|
+
try {
|
|
11
|
+
console.log(`Testing channel: ${channel}`);
|
|
12
|
+
const emailInfo = await generateEmail({ channel });
|
|
13
|
+
console.log(` Channel: ${emailInfo.channel}`);
|
|
14
|
+
console.log(` Email: ${emailInfo.email}`);
|
|
15
|
+
if (emailInfo.token) console.log(` Token: ${emailInfo.token}`);
|
|
16
|
+
if (emailInfo.expiresAt) console.log(` Expires: ${emailInfo.expiresAt}`);
|
|
17
|
+
console.log();
|
|
18
|
+
} catch (error) {
|
|
19
|
+
console.error(` Error: ${error}`);
|
|
20
|
+
console.log();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async function testGetEmails() {
|
|
26
|
+
console.log('=== Test Get Emails ===\n');
|
|
27
|
+
|
|
28
|
+
// Generate and check emails using client
|
|
29
|
+
const client = new TempEmailClient();
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
const emailInfo = await client.generate({ channel: 'tempmail' });
|
|
33
|
+
console.log(`Generated: ${emailInfo.channel} - ${emailInfo.email}`);
|
|
34
|
+
|
|
35
|
+
const result = await client.getEmails();
|
|
36
|
+
console.log(`Emails count: ${result.emails.length}`);
|
|
37
|
+
console.log();
|
|
38
|
+
} catch (error) {
|
|
39
|
+
console.error(`Error: ${error}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async function main() {
|
|
44
|
+
await testGenerateEmail();
|
|
45
|
+
await testGetEmails();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
main().catch(console.error);
|
package/tsconfig.json
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2020",
|
|
4
|
-
"module": "commonjs",
|
|
5
|
-
"lib": ["ES2020", "DOM"],
|
|
6
|
-
"declaration": true,
|
|
7
|
-
"strict": true,
|
|
8
|
-
"noImplicitAny": true,
|
|
9
|
-
"strictNullChecks": true,
|
|
10
|
-
"noImplicitThis": true,
|
|
11
|
-
"alwaysStrict": true,
|
|
12
|
-
"noUnusedLocals": false,
|
|
13
|
-
"noUnusedParameters": false,
|
|
14
|
-
"noImplicitReturns": true,
|
|
15
|
-
"noFallthroughCasesInSwitch": false,
|
|
16
|
-
"inlineSourceMap": true,
|
|
17
|
-
"inlineSources": true,
|
|
18
|
-
"experimentalDecorators": true,
|
|
19
|
-
"strictPropertyInitialization": false,
|
|
20
|
-
"outDir": "./dist",
|
|
21
|
-
"rootDir": "./src",
|
|
22
|
-
"skipLibCheck": true,
|
|
23
|
-
"esModuleInterop": true
|
|
24
|
-
},
|
|
25
|
-
"include": ["src/**/*"],
|
|
26
|
-
"exclude": ["node_modules", "dist"]
|
|
27
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"lib": ["ES2020", "DOM"],
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"strict": true,
|
|
8
|
+
"noImplicitAny": true,
|
|
9
|
+
"strictNullChecks": true,
|
|
10
|
+
"noImplicitThis": true,
|
|
11
|
+
"alwaysStrict": true,
|
|
12
|
+
"noUnusedLocals": false,
|
|
13
|
+
"noUnusedParameters": false,
|
|
14
|
+
"noImplicitReturns": true,
|
|
15
|
+
"noFallthroughCasesInSwitch": false,
|
|
16
|
+
"inlineSourceMap": true,
|
|
17
|
+
"inlineSources": true,
|
|
18
|
+
"experimentalDecorators": true,
|
|
19
|
+
"strictPropertyInitialization": false,
|
|
20
|
+
"outDir": "./dist",
|
|
21
|
+
"rootDir": "./src",
|
|
22
|
+
"skipLibCheck": true,
|
|
23
|
+
"esModuleInterop": true
|
|
24
|
+
},
|
|
25
|
+
"include": ["src/**/*"],
|
|
26
|
+
"exclude": ["node_modules", "dist"]
|
|
27
|
+
}
|