tempmail-sdk 1.2.0 → 1.2.2-dev
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 +9 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +48 -2
- package/dist/normalize.js +5 -3
- package/dist/providers/10mail-wangtz.d.ts +3 -0
- package/dist/providers/10mail-wangtz.js +117 -0
- package/dist/providers/10minute-one.d.ts +3 -0
- package/dist/providers/10minute-one.js +264 -0
- package/dist/providers/moakt.d.ts +3 -0
- package/dist/providers/moakt.js +214 -0
- package/dist/providers/ta-easy.d.ts +5 -0
- package/dist/providers/ta-easy.js +55 -0
- package/dist/providers/tempmailg.d.ts +7 -0
- package/dist/providers/tempmailg.js +202 -0
- package/dist/providers/tmpmails.d.ts +3 -0
- package/dist/providers/tmpmails.js +169 -0
- package/dist/retry.d.ts +5 -1
- package/dist/retry.js +25 -3
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -1
- package/package.json +2 -2
- package/src/index.ts +43 -2
- package/src/normalize.ts +4 -2
- package/src/providers/10mail-wangtz.ts +128 -0
- package/src/providers/10minute-one.ts +258 -0
- package/src/providers/moakt.ts +215 -0
- package/src/providers/ta-easy.ts +56 -0
- package/src/providers/tempmailg.ts +208 -0
- package/src/providers/tmpmails.ts +168 -0
- package/src/retry.ts +36 -1
- package/src/types.ts +1 -1
package/src/retry.ts
CHANGED
|
@@ -171,13 +171,48 @@ function getFetchConfig(): { fetchFn: typeof fetch; timeout: number } {
|
|
|
171
171
|
return _cachedFetchConfig;
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
+
/** Node 下跳过 TLS 证书校验(用于 10mail.wangtz.cn 等渠道默认行为) */
|
|
175
|
+
export interface FetchWithTimeoutOptions {
|
|
176
|
+
skipTlsVerify?: boolean;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function resolveFetchForTls(
|
|
180
|
+
baseFetch: typeof fetch,
|
|
181
|
+
skipTlsVerify: boolean | undefined,
|
|
182
|
+
): typeof fetch {
|
|
183
|
+
if (!skipTlsVerify) {
|
|
184
|
+
return baseFetch;
|
|
185
|
+
}
|
|
186
|
+
if (typeof process === 'undefined' || !process.versions?.node) {
|
|
187
|
+
return baseFetch;
|
|
188
|
+
}
|
|
189
|
+
try {
|
|
190
|
+
// Node 18+ 内置 undici,用于 per-request 关闭证书校验(不修改全局 NODE_TLS_REJECT_UNAUTHORIZED)
|
|
191
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
192
|
+
const undici = require('undici') as {
|
|
193
|
+
Agent: new (opts: { connect: { rejectUnauthorized: boolean } }) => unknown;
|
|
194
|
+
fetch: (input: string, init?: Record<string, unknown>) => Promise<Response>;
|
|
195
|
+
};
|
|
196
|
+
const dispatcher = new undici.Agent({ connect: { rejectUnauthorized: false } });
|
|
197
|
+
return ((u: string, i?: RequestInit) =>
|
|
198
|
+
undici.fetch(u, {
|
|
199
|
+
...(i as Record<string, unknown>),
|
|
200
|
+
dispatcher,
|
|
201
|
+
})) as typeof fetch;
|
|
202
|
+
} catch {
|
|
203
|
+
return baseFetch;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
174
207
|
export async function fetchWithTimeout(
|
|
175
208
|
url: string,
|
|
176
209
|
init?: RequestInit,
|
|
177
210
|
timeoutMs?: number,
|
|
211
|
+
opts?: FetchWithTimeoutOptions,
|
|
178
212
|
): Promise<Response> {
|
|
179
213
|
const { fetchFn, timeout: defaultTimeout } = getFetchConfig();
|
|
180
214
|
const effectiveTimeout = timeoutMs ?? defaultTimeout;
|
|
215
|
+
const fetchImpl = resolveFetchForTls(fetchFn, opts?.skipTlsVerify);
|
|
181
216
|
const controller = new AbortController();
|
|
182
217
|
const timeoutId = setTimeout(() => controller.abort(), effectiveTimeout);
|
|
183
218
|
|
|
@@ -191,7 +226,7 @@ export async function fetchWithTimeout(
|
|
|
191
226
|
}
|
|
192
227
|
|
|
193
228
|
try {
|
|
194
|
-
const response = await
|
|
229
|
+
const response = await fetchImpl(url, {
|
|
195
230
|
...init,
|
|
196
231
|
signal: controller.signal,
|
|
197
232
|
});
|
package/src/types.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* 支持的临时邮箱渠道标识
|
|
3
3
|
* 每个渠道对应一个第三方临时邮箱服务商
|
|
4
4
|
*/
|
|
5
|
-
export type Channel = 'tempmail' | 'tempmail-cn' | 'linshi-email' | 'linshiyou' | 'mffac' | 'tempmail-lol' | 'chatgpt-org-uk' | 'temp-mail-io' | 'awamail' | 'temporary-email-org' | 'mail-tm' | 'mail-cx' | 'dropmail' | 'guerrillamail' | 'maildrop' | 'smail-pw' | 'boomlify' | 'minmail' | 'vip-215' | 'anonbox' | 'fake-legal';
|
|
5
|
+
export type Channel = 'tempmail' | 'tempmail-cn' | 'tmpmails' | 'tempmailg' | 'ta-easy' | '10mail-wangtz' | '10minute-one' | 'linshi-email' | 'linshiyou' | 'mffac' | 'tempmail-lol' | 'chatgpt-org-uk' | 'temp-mail-io' | 'awamail' | 'temporary-email-org' | 'mail-tm' | 'mail-cx' | 'dropmail' | 'guerrillamail' | 'maildrop' | 'smail-pw' | 'boomlify' | 'minmail' | 'vip-215' | 'anonbox' | 'fake-legal' | 'moakt';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* 创建临时邮箱后返回的邮箱信息
|