@z_06/relay-temp-mail 2.1.1 → 2.1.3
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 +2 -94
- package/README.zh-CN.md +2 -94
- package/dist/index.cjs +1 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -20
- package/dist/index.js.map +1 -1
- package/package.json +40 -40
package/README.md
CHANGED
|
@@ -59,104 +59,12 @@ const emails = await client.getEmails(alias.fullAddress, { limit: 10 });
|
|
|
59
59
|
|
|
60
60
|
The library uses two types of providers that can be combined independently:
|
|
61
61
|
|
|
62
|
-
| Provider Type | Interface |
|
|
62
|
+
| Provider Type | Interface | Available Providers |
|
|
63
63
|
|---|---|---|
|
|
64
64
|
| **Alias Provider** | `AliasProvider` | `firefox-relay`, `duckduckgo-email` |
|
|
65
65
|
| **Mail Provider** | `MailProvider` | `cf-temp-mail` |
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
#### `firefox-relay`
|
|
70
|
-
|
|
71
|
-
Manages email aliases through [Firefox Relay](https://relay.firefox.com).
|
|
72
|
-
|
|
73
|
-
**Configuration:**
|
|
74
|
-
|
|
75
|
-
```typescript
|
|
76
|
-
{
|
|
77
|
-
type: 'firefox-relay',
|
|
78
|
-
csrfToken: string; // CSRF token from relay.firefox.com cookies
|
|
79
|
-
sessionId: string; // Session ID from relay.firefox.com cookies
|
|
80
|
-
}
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
**Getting your tokens:**
|
|
84
|
-
|
|
85
|
-
1. Login to [relay.firefox.com](https://relay.firefox.com)
|
|
86
|
-
2. Open your browser's developer tools (F12)
|
|
87
|
-
3. Go to the Application/Storage tab
|
|
88
|
-
4. Find Cookies for `relay.firefox.com`
|
|
89
|
-
5. Copy the values for `csrftoken` and `sessionid`
|
|
90
|
-
|
|
91
|
-
#### `duckduckgo-email`
|
|
92
|
-
|
|
93
|
-
Manages email aliases through [DuckDuckGo Email Protection](https://duckduckgo.com/email/).
|
|
94
|
-
|
|
95
|
-
Since the DuckDuckGo API does not provide endpoints for listing or deleting aliases, this provider uses a local store. A default in-memory store is included; implement `DuckDuckGoAliasStore` for custom persistence (e.g., file-based, database).
|
|
96
|
-
|
|
97
|
-
**Configuration:**
|
|
98
|
-
|
|
99
|
-
```typescript
|
|
100
|
-
{
|
|
101
|
-
type: 'duckduckgo-email',
|
|
102
|
-
jwtToken: string; // JWT token from DuckDuckGo Email Protection
|
|
103
|
-
store?: DuckDuckGoAliasStore; // Optional custom store (default: in-memory)
|
|
104
|
-
}
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
**Getting your JWT token:**
|
|
108
|
-
|
|
109
|
-
1. Visit [duckduckgo.com/email](https://duckduckgo.com/email/) and register an account
|
|
110
|
-
2. Open your browser's developer tools (F12)
|
|
111
|
-
3. Click "Generate New Address" in the DuckDuckGo Email UI
|
|
112
|
-
4. In the Network tab, find the request to `quack.duckduckgo.com`
|
|
113
|
-
5. Copy the Bearer token from the `Authorization` header
|
|
114
|
-
|
|
115
|
-
**Custom persistence:**
|
|
116
|
-
|
|
117
|
-
```typescript
|
|
118
|
-
import type { DuckDuckGoAliasStore, RelayAlias } from '@z_06/relay-temp-mail';
|
|
119
|
-
|
|
120
|
-
class MyFileStore implements DuckDuckGoAliasStore {
|
|
121
|
-
getAll(): RelayAlias[] { /* read from file */ }
|
|
122
|
-
add(alias: RelayAlias): void { /* append to file */ }
|
|
123
|
-
remove(id: number): void { /* remove from file */ }
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
const client = new TempMailClient({
|
|
127
|
-
aliasProvider: {
|
|
128
|
-
type: 'duckduckgo-email',
|
|
129
|
-
jwtToken: 'your-jwt-token',
|
|
130
|
-
store: new MyFileStore(),
|
|
131
|
-
},
|
|
132
|
-
mailProvider: { /* ... */ },
|
|
133
|
-
});
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
**Duplicate detection:** The DuckDuckGo API may occasionally return a previously-generated address with a 201 response. The provider detects this and throws a `RelayTempMailError` with code `DUPLICATE_ALIAS`.
|
|
137
|
-
|
|
138
|
-
### Mail Providers
|
|
139
|
-
|
|
140
|
-
#### `cf-temp-mail`
|
|
141
|
-
|
|
142
|
-
Retrieves emails from a [cloudflare_temp_email](https://github.com/dreamhunter2333/cloudflare_temp_email) instance.
|
|
143
|
-
|
|
144
|
-
**Configuration:**
|
|
145
|
-
|
|
146
|
-
```typescript
|
|
147
|
-
{
|
|
148
|
-
type: 'cf-temp-mail',
|
|
149
|
-
apiUrl: string; // Base URL of your CF temp email API
|
|
150
|
-
token: string; // Bearer token for API authentication
|
|
151
|
-
}
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
**Deploying the backend:**
|
|
155
|
-
|
|
156
|
-
1. Fork [cloudflare_temp_email](https://github.com/dreamhunter2333/cloudflare_temp_email)
|
|
157
|
-
2. Deploy to Cloudflare Workers (one-click or manual via [docs](https://temp-mail-docs.awsl.uk))
|
|
158
|
-
3. Configure Email Routing and catch-all rules in Cloudflare Dashboard
|
|
159
|
-
4. Generate an API Token from the admin panel or user settings
|
|
67
|
+
For detailed configuration parameters and credential acquisition guides, see **[Provider Setup Guide](PROVIDERS.md)**.
|
|
160
68
|
|
|
161
69
|
## API Documentation
|
|
162
70
|
|
package/README.zh-CN.md
CHANGED
|
@@ -59,104 +59,12 @@ const emails = await client.getEmails(alias.fullAddress, { limit: 10 });
|
|
|
59
59
|
|
|
60
60
|
本库使用两种可独立组合的 Provider:
|
|
61
61
|
|
|
62
|
-
| Provider 类型 | 接口 |
|
|
62
|
+
| Provider 类型 | 接口 | 可用提供商 |
|
|
63
63
|
|---|---|---|
|
|
64
64
|
| **别名提供商** | `AliasProvider` | `firefox-relay`, `duckduckgo-email` |
|
|
65
65
|
| **邮件提供商** | `MailProvider` | `cf-temp-mail` |
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
#### `firefox-relay`
|
|
70
|
-
|
|
71
|
-
通过 [Firefox Relay](https://relay.firefox.com) 管理邮箱别名。
|
|
72
|
-
|
|
73
|
-
**配置:**
|
|
74
|
-
|
|
75
|
-
```typescript
|
|
76
|
-
{
|
|
77
|
-
type: 'firefox-relay',
|
|
78
|
-
csrfToken: string; // relay.firefox.com 的 CSRF token
|
|
79
|
-
sessionId: string; // relay.firefox.com 的 Session ID
|
|
80
|
-
}
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
**获取 Token:**
|
|
84
|
-
|
|
85
|
-
1. 登录 [relay.firefox.com](https://relay.firefox.com)
|
|
86
|
-
2. 打开浏览器开发者工具(F12)
|
|
87
|
-
3. 切换到 Application/Storage 标签页
|
|
88
|
-
4. 找到 `relay.firefox.com` 的 Cookies
|
|
89
|
-
5. 复制 `csrftoken` 和 `sessionid` 的值
|
|
90
|
-
|
|
91
|
-
#### `duckduckgo-email`
|
|
92
|
-
|
|
93
|
-
通过 [DuckDuckGo 邮件保护](https://duckduckgo.com/email/) 管理邮箱别名。
|
|
94
|
-
|
|
95
|
-
由于 DuckDuckGo API 不提供列出或删除别名的接口,该提供商使用本地存储。内置内存存储;可通过实现 `DuckDuckGoAliasStore` 接口自定义持久化(如文件、数据库)。
|
|
96
|
-
|
|
97
|
-
**配置:**
|
|
98
|
-
|
|
99
|
-
```typescript
|
|
100
|
-
{
|
|
101
|
-
type: 'duckduckgo-email',
|
|
102
|
-
jwtToken: string; // DuckDuckGo 邮件保护的 JWT token
|
|
103
|
-
store?: DuckDuckGoAliasStore; // 可选自定义存储(默认: 内存存储)
|
|
104
|
-
}
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
**获取 JWT Token:**
|
|
108
|
-
|
|
109
|
-
1. 访问 [duckduckgo.com/email](https://duckduckgo.com/email/) 并注册账户
|
|
110
|
-
2. 打开浏览器开发者工具(F12)
|
|
111
|
-
3. 在 DuckDuckGo 邮件界面点击"生成新地址"
|
|
112
|
-
4. 在网络请求栏中找到发往 `quack.duckduckgo.com` 的请求
|
|
113
|
-
5. 从 `Authorization` 请求头中复制 Bearer token
|
|
114
|
-
|
|
115
|
-
**自定义持久化:**
|
|
116
|
-
|
|
117
|
-
```typescript
|
|
118
|
-
import type { DuckDuckGoAliasStore, RelayAlias } from '@z_06/relay-temp-mail';
|
|
119
|
-
|
|
120
|
-
class MyFileStore implements DuckDuckGoAliasStore {
|
|
121
|
-
getAll(): RelayAlias[] { /* 从文件读取 */ }
|
|
122
|
-
add(alias: RelayAlias): void { /* 追加到文件 */ }
|
|
123
|
-
remove(id: number): void { /* 从文件中删除 */ }
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
const client = new TempMailClient({
|
|
127
|
-
aliasProvider: {
|
|
128
|
-
type: 'duckduckgo-email',
|
|
129
|
-
jwtToken: 'your-jwt-token',
|
|
130
|
-
store: new MyFileStore(),
|
|
131
|
-
},
|
|
132
|
-
mailProvider: { /* ... */ },
|
|
133
|
-
});
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
**重复检测:** DuckDuckGo API 偶尔会返回之前已生成过的地址(仍返回 201)。该提供商会检测这种情况并抛出 `RelayTempMailError`,错误代码为 `DUPLICATE_ALIAS`。
|
|
137
|
-
|
|
138
|
-
### 邮件提供商
|
|
139
|
-
|
|
140
|
-
#### `cf-temp-mail`
|
|
141
|
-
|
|
142
|
-
从 [cloudflare_temp_email](https://github.com/dreamhunter2333/cloudflare_temp_email) 实例获取邮件。
|
|
143
|
-
|
|
144
|
-
**配置:**
|
|
145
|
-
|
|
146
|
-
```typescript
|
|
147
|
-
{
|
|
148
|
-
type: 'cf-temp-mail',
|
|
149
|
-
apiUrl: string; // CF 临时邮箱 API 的基础 URL
|
|
150
|
-
token: string; // API Bearer Token
|
|
151
|
-
}
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
**部署后端:**
|
|
155
|
-
|
|
156
|
-
1. Fork [cloudflare_temp_email](https://github.com/dreamhunter2333/cloudflare_temp_email)
|
|
157
|
-
2. 部署到 Cloudflare Workers(一键部署或参考[部署文档](https://temp-mail-docs.awsl.uk)手动部署)
|
|
158
|
-
3. 在 Cloudflare Dashboard 中配置域名和 Email Routing 的 catch-all 规则
|
|
159
|
-
4. 从管理后台或用户设置中生成 API Token
|
|
67
|
+
详细的配置参数和凭证获取指南,请参阅 **[提供商配置指南](PROVIDERS.zh-CN.md)**。
|
|
160
68
|
|
|
161
69
|
## API 文档
|
|
162
70
|
|
package/dist/index.cjs
CHANGED
|
@@ -389,9 +389,6 @@ var DuckDuckGoEmailProvider = class {
|
|
|
389
389
|
// src/parser.ts
|
|
390
390
|
var EMAIL_PATTERN = /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g;
|
|
391
391
|
var MOZMAIL_SUFFIX_PATTERN = /@mozmail\.com$/i;
|
|
392
|
-
var DUCK_SUFFIX_PATTERN = /@duck\.com$/i;
|
|
393
|
-
var DUCK_ALIAS_PATTERN = /([a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)+@duck\.com)/gi;
|
|
394
|
-
var DUCK_SYSTEM_ADDRESSES = /* @__PURE__ */ new Set(["support@duck.com", "noreply@duck.com"]);
|
|
395
392
|
var ENCODED_WORD_PATTERN = /=\?([^?]+)\?([BbQq])\?([^?]*)\?=/g;
|
|
396
393
|
var EmailParser = class {
|
|
397
394
|
parseEmail(raw) {
|
|
@@ -414,22 +411,6 @@ var EmailParser = class {
|
|
|
414
411
|
extractRelayAlias(raw) {
|
|
415
412
|
try {
|
|
416
413
|
const headers = this.parseHeaders(raw);
|
|
417
|
-
const duckOriginalTo = headers.get("duck-original-to");
|
|
418
|
-
if (duckOriginalTo) {
|
|
419
|
-
const duckAddress = this.extractEmailAddress(duckOriginalTo);
|
|
420
|
-
if (duckAddress && DUCK_SUFFIX_PATTERN.test(duckAddress)) {
|
|
421
|
-
return duckAddress;
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
const duckMatches = raw.match(DUCK_ALIAS_PATTERN);
|
|
425
|
-
if (duckMatches && duckMatches.length > 0) {
|
|
426
|
-
return duckMatches[0].toLowerCase();
|
|
427
|
-
}
|
|
428
|
-
const rawEmails = raw.match(EMAIL_PATTERN) ?? [];
|
|
429
|
-
const duckFallback = rawEmails.find(
|
|
430
|
-
(e) => DUCK_SUFFIX_PATTERN.test(e) && !DUCK_SYSTEM_ADDRESSES.has(e.toLowerCase())
|
|
431
|
-
);
|
|
432
|
-
if (duckFallback) return duckFallback.toLowerCase();
|
|
433
414
|
const fromAddresses = this.extractHeaderEmails(headers.get("from"));
|
|
434
415
|
const toAddresses = this.extractHeaderEmails(headers.get("to"));
|
|
435
416
|
const allAddresses = [...fromAddresses, ...toAddresses];
|
|
@@ -643,7 +624,7 @@ var TempMailClient = class {
|
|
|
643
624
|
if (aliasAddress) {
|
|
644
625
|
const normalizedAlias = aliasAddress.toLowerCase();
|
|
645
626
|
return parsedEmails.filter(
|
|
646
|
-
(email) => email.relayAlias?.toLowerCase() === normalizedAlias || email.address.toLowerCase() === normalizedAlias
|
|
627
|
+
(email) => email.relayAlias?.toLowerCase() === normalizedAlias || email.address.toLowerCase() === normalizedAlias || email.raw.toLowerCase().includes(normalizedAlias)
|
|
647
628
|
);
|
|
648
629
|
}
|
|
649
630
|
return parsedEmails;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/cf-api.ts","../src/http.ts","../src/duckduckgo-api.ts","../src/parser.ts","../src/relay-api.ts","../src/client.ts"],"sourcesContent":["export type {\n AliasProvider,\n MailProvider,\n TempMailConfig,\n FirefoxRelayConfig,\n DuckDuckGoEmailConfig,\n DuckDuckGoAliasStore,\n CFTempMailConfig,\n AliasProviderConfig,\n MailProviderConfig,\n RelayAlias,\n Email,\n ParsedEmail,\n ListAliasesOptions,\n GetEmailsOptions,\n CFMailsResponse,\n RelayAddressesResponse,\n CreateAliasResponse,\n RelayConfig,\n} from './types.js';\n\nexport {\n RelayTempMailError,\n NetworkError,\n AuthError,\n NotFoundError,\n ParseError,\n RateLimitError,\n} from './errors.js';\n\nexport { TempMailClient, RelayClient } from './client.js';\n\nexport { FirefoxRelayProvider, RelayAPIClient } from './relay-api.js';\n\nexport { CFTempMailProvider, CFEmailClient } from './cf-api.js';\n\nexport {\n DuckDuckGoEmailProvider,\n InMemoryDuckDuckGoAliasStore,\n} from './duckduckgo-api.js';\n","/**\n * Custom error classes for the relay-temp-mail package.\n *\n * These errors provide structured error information including error codes,\n * HTTP status codes, and response data for better error handling.\n */\n\n/**\n * Base error class for all relay-temp-mail errors.\n *\n * Extends the built-in Error class with additional context about the error,\n * including an error code for programmatic error handling and optional\n * response data from the API.\n */\nexport class RelayTempMailError extends Error {\n /**\n * Machine-readable error code for programmatic error handling.\n * Examples: 'NETWORK_ERROR', 'AUTH_ERROR', 'NOT_FOUND'\n */\n code: string;\n\n /**\n * HTTP status code associated with this error, if applicable.\n */\n statusCode?: number;\n\n /**\n * Raw response data from the API, if available.\n */\n response?: any;\n\n /**\n * Creates a new RelayTempMailError instance.\n *\n * @param message - Human-readable error message describing the error.\n * @param code - Machine-readable error code (e.g., 'UNKNOWN_ERROR').\n * @param statusCode - Optional HTTP status code associated with the error.\n * @param response - Optional raw response data from the API.\n */\n constructor(\n message: string,\n code: string,\n statusCode?: number,\n response?: any\n ) {\n super(message);\n this.name = this.constructor.name;\n this.code = code;\n this.statusCode = statusCode;\n this.response = response;\n\n // Maintains proper stack trace in V8 environments\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, this.constructor);\n }\n }\n}\n\n/**\n * Error for network-related failures.\n *\n * Thrown when there is a problem establishing or maintaining a network\n * connection, such as DNS resolution failures, connection timeouts,\n * or network unreachability.\n */\nexport class NetworkError extends RelayTempMailError {\n code = 'NETWORK_ERROR' as const;\n\n constructor(message: string, response?: any) {\n super(message, 'NETWORK_ERROR', undefined, response);\n }\n}\n\n/**\n * Error for authentication and authorization failures.\n *\n * Thrown when API requests fail due to invalid or missing credentials\n * (401) or when the authenticated user lacks permission for the\n * requested operation (403).\n */\nexport class AuthError extends RelayTempMailError {\n code = 'AUTH_ERROR' as const;\n\n constructor(message: string, statusCode?: number, response?: any) {\n super(message, 'AUTH_ERROR', statusCode, response);\n }\n}\n\n/**\n * Error for resource not found errors.\n *\n * Thrown when the requested resource does not exist (404 response),\n * such as when trying to access a non-existent alias or email.\n */\nexport class NotFoundError extends RelayTempMailError {\n code = 'NOT_FOUND' as const;\n\n constructor(message: string, response?: any) {\n super(message, 'NOT_FOUND', 404, response);\n }\n}\n\n/**\n * Error for MIME message parsing failures.\n *\n * Thrown when there is an error parsing email MIME content,\n * such as malformed headers or invalid message structure.\n */\nexport class ParseError extends RelayTempMailError {\n code = 'PARSE_ERROR' as const;\n\n constructor(message: string, response?: any) {\n super(message, 'PARSE_ERROR', undefined, response);\n }\n}\n\n/**\n * Error for rate limiting responses.\n *\n * Thrown when the API rate limit has been exceeded (429 response).\n * The client should wait and retry the request after the indicated\n * cooldown period.\n */\nexport class RateLimitError extends RelayTempMailError {\n code = 'RATE_LIMIT_ERROR' as const;\n\n constructor(message: string, response?: any) {\n super(message, 'RATE_LIMIT_ERROR', 429, response);\n }\n}\n","import type { MailProvider, Email } from './types.js';\nimport { AuthError, NetworkError, NotFoundError, RateLimitError, RelayTempMailError } from './errors.js';\n\ninterface CFRawEmail {\n id: number;\n message_id: string;\n source: string;\n address: string;\n raw: string;\n metadata: any | null;\n created_at: string;\n}\n\ninterface CFRawResponse {\n results: CFRawEmail[];\n count: number;\n}\n\nexport class CFTempMailProvider implements MailProvider {\n private readonly apiUrl: string;\n private readonly token: string;\n private readonly httpClient: HttpClient;\n\n constructor(apiUrl: string, token: string, httpClient?: HttpClient) {\n this.apiUrl = apiUrl.replace(/\\/+$/, '');\n this.token = token;\n this.httpClient = httpClient ?? new DefaultHttpClient();\n }\n\n async getMails(limit: number = 20, offset: number = 0): Promise<Email[]> {\n const url = new URL(`${this.apiUrl}/api/mails`);\n url.searchParams.set('limit', String(limit));\n url.searchParams.set('offset', String(offset));\n\n const headers: Record<string, string> = {\n 'Authorization': `Bearer ${this.token}`,\n };\n\n try {\n const response = await this.httpClient.get(url.toString(), { headers });\n return this.mapCFResponse(response as CFRawResponse);\n } catch (error) {\n throw this.handleError(error);\n }\n }\n\n private mapCFResponse(response: CFRawResponse): Email[] {\n return response.results.map((item): Email => ({\n id: item.id,\n messageId: item.message_id,\n source: item.source,\n address: item.address,\n raw: item.raw,\n metadata: item.metadata,\n createdAt: item.created_at,\n }));\n }\n\n private handleError(error: unknown): RelayTempMailError {\n if (error instanceof RelayTempMailError) {\n const statusCode = error.statusCode;\n\n if (statusCode === 401 || statusCode === 403) {\n return new AuthError(error.message, statusCode, error.response);\n }\n if (statusCode === 404) {\n return new NotFoundError(error.message, error.response);\n }\n if (statusCode === 429) {\n return new RateLimitError(error.message, error.response);\n }\n\n return error;\n }\n\n if (error instanceof TypeError && error.message.includes('fetch')) {\n return new NetworkError(error.message);\n }\n\n if (error instanceof Error) {\n return new NetworkError(error.message);\n }\n\n return new RelayTempMailError(\n 'Unknown error occurred',\n 'UNKNOWN_ERROR',\n undefined,\n error\n );\n }\n}\n\n/** @deprecated Use CFTempMailProvider instead */\nexport const CFEmailClient = CFTempMailProvider;\n\nexport interface HttpClient {\n get(url: string, options?: { headers?: Record<string, string> }): Promise<unknown>;\n}\n\nexport class DefaultHttpClient implements HttpClient {\n async get(url: string, options?: { headers?: Record<string, string> }): Promise<unknown> {\n const response = await fetch(url, {\n method: 'GET',\n headers: options?.headers,\n });\n\n if (!response.ok) {\n const errorBody = await response.text();\n throw new RelayTempMailError(\n `HTTP ${response.status}: ${errorBody}`,\n 'HTTP_ERROR',\n response.status,\n errorBody\n );\n }\n\n return response.json();\n }\n}\n","/**\n * HTTP client utilities for the relay-temp-mail package.\n *\n * This module provides a configurable HTTP client with timeout support,\n * automatic retry logic, and proper error classification for API responses.\n */\n\nimport {\n RelayTempMailError,\n NetworkError,\n AuthError,\n NotFoundError,\n RateLimitError,\n} from './errors';\n\n/**\n * Options for individual HTTP requests.\n */\nexport interface RequestOptions {\n /** Custom headers to include in the request */\n headers?: Record<string, string>;\n\n /** Request body (will be JSON serialized) */\n body?: unknown;\n\n /** Request timeout in milliseconds (overrides client default) */\n timeout?: number;\n\n /** Number of retries on failure (overrides client default) */\n retries?: number;\n}\n\n/**\n * HTTP client for making requests to the relay-temp-mail API.\n *\n * Provides a configurable base URL with timeout, retry, and automatic\n * JSON parsing capabilities.\n */\nexport class HttpClient {\n private baseUrl: string;\n private defaultTimeout: number;\n private defaultRetries: number;\n\n /**\n * Creates a new HttpClient instance.\n *\n * @param baseUrl - Base URL for all requests (e.g., 'https://api.example.com')\n * @param defaultTimeout - Default timeout in milliseconds (default: 30000)\n * @param defaultRetries - Default number of retries on failure (default: 0)\n */\n constructor(\n baseUrl: string,\n defaultTimeout: number = 30000,\n defaultRetries: number = 0\n ) {\n this.baseUrl = baseUrl.replace(/\\/$/, ''); // Remove trailing slash\n this.defaultTimeout = defaultTimeout;\n this.defaultRetries = defaultRetries;\n }\n\n /**\n * Makes an HTTP request to the specified path.\n *\n * @param method - HTTP method (GET, POST, PUT, DELETE, etc.)\n * @param path - API path (will be appended to baseUrl)\n * @param options - Optional request configuration\n * @returns Promise resolving to the parsed JSON response\n */\n async request<T>(\n method: string,\n path: string,\n options: RequestOptions = {}\n ): Promise<T> {\n const timeout = options.timeout ?? this.defaultTimeout;\n const retries = options.retries ?? this.defaultRetries;\n\n let lastError: RelayTempMailError | Error | undefined;\n\n for (let attempt = 0; attempt <= retries; attempt++) {\n try {\n const response = await this.executeRequest(method, path, options, timeout);\n return await this.handleResponse<T>(response);\n } catch (error) {\n lastError = error as Error;\n\n // Check if we should retry\n if (attempt < retries && this.shouldRetry(error)) {\n const delay = 1000 * Math.pow(2, attempt);\n await this.sleep(delay);\n continue;\n }\n\n // Don't retry, throw the classified error\n if (error instanceof RelayTempMailError) {\n throw error;\n }\n\n // Classify the error if not already classified\n throw this.classifyError(error);\n }\n }\n\n // This should never be reached, but just in case\n throw lastError || new NetworkError('Request failed');\n }\n\n /**\n * Executes the actual HTTP request with timeout support.\n */\n private async executeRequest(\n method: string,\n path: string,\n options: RequestOptions,\n timeout: number\n ): Promise<Response> {\n const url = `${this.baseUrl}${path}`;\n\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), timeout);\n\n try {\n const fetchOptions: RequestInit = {\n method,\n headers: {\n 'Content-Type': 'application/json',\n ...options.headers,\n },\n signal: controller.signal,\n };\n\n if (options.body !== undefined) {\n fetchOptions.body = JSON.stringify(options.body);\n }\n\n const response = await fetch(url, fetchOptions);\n return response;\n } finally {\n clearTimeout(timeoutId);\n }\n }\n\n /**\n * Handles the HTTP response, parsing JSON and checking for errors.\n */\n private async handleResponse<T>(response: Response): Promise<T> {\n if (!response.ok) {\n throw this.classifyError(new Error(`HTTP ${response.status}`), response);\n }\n\n const text = await response.text();\n\n // Handle empty responses\n if (!text) {\n return {} as T;\n }\n\n return JSON.parse(text) as T;\n }\n\n /**\n * Classifies an error based on the error type and HTTP response.\n */\n private classifyError(error: unknown, response?: Response): RelayTempMailError {\n // Network errors (fetch failed)\n if (error instanceof Error && error.name === 'AbortError') {\n return new NetworkError('Request timed out');\n }\n\n if (error instanceof TypeError && error.message.includes('fetch')) {\n return new NetworkError('Network request failed');\n }\n\n if (error instanceof Error && error.message.includes('Failed to fetch')) {\n return new NetworkError('Network request failed');\n }\n\n // HTTP status-based classification\n if (response) {\n const status = response.status;\n\n if (status === 401 || status === 403) {\n return new AuthError(\n `Authentication failed: ${response.statusText}`,\n status\n );\n }\n\n if (status === 404) {\n return new NotFoundError(`Resource not found: ${response.statusText}`);\n }\n\n if (status === 429) {\n return new RateLimitError(\n `Rate limit exceeded: ${response.statusText}`\n );\n }\n\n if (status >= 500) {\n return new NetworkError(\n `Server error: ${response.statusText}`,\n status\n );\n }\n }\n\n // Default error\n if (error instanceof Error) {\n return new RelayTempMailError(\n error.message,\n 'REQUEST_ERROR',\n response?.status\n );\n }\n\n return new RelayTempMailError('Unknown error occurred', 'UNKNOWN_ERROR');\n }\n\n /**\n * Determines if a request should be retried based on the error.\n */\n private shouldRetry(error: unknown): boolean {\n if (error instanceof NetworkError) {\n return true;\n }\n\n if (error instanceof RelayTempMailError && error.statusCode) {\n return error.statusCode >= 500;\n }\n\n if (error instanceof Error) {\n if (error.name === 'AbortError') {\n return true;\n }\n if (error instanceof TypeError && error.message.includes('fetch')) {\n return true;\n }\n }\n\n return false;\n }\n\n /**\n * Sleep for a specified duration.\n */\n private sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n }\n}\n","import { HttpClient } from './http';\nimport { RelayTempMailError } from './errors';\nimport type { AliasProvider, RelayAlias, DuckDuckGoAliasStore } from './types';\n\ninterface DuckDuckGoCreateAddressResponse {\n address: string;\n}\n\nexport class InMemoryDuckDuckGoAliasStore implements DuckDuckGoAliasStore {\n private aliases: RelayAlias[] = [];\n\n getAll(): RelayAlias[] {\n return [...this.aliases];\n }\n\n add(alias: RelayAlias): void {\n this.aliases.push(alias);\n }\n\n remove(id: number): void {\n this.aliases = this.aliases.filter((a) => a.id !== id);\n }\n}\n\nexport class DuckDuckGoEmailProvider implements AliasProvider {\n private jwtToken: string;\n private httpClient: HttpClient;\n private store: DuckDuckGoAliasStore;\n private nextId: number;\n\n constructor(\n jwtToken: string,\n store?: DuckDuckGoAliasStore,\n httpClient?: HttpClient\n ) {\n this.jwtToken = jwtToken;\n this.store = store ?? new InMemoryDuckDuckGoAliasStore();\n this.httpClient =\n httpClient ?? new HttpClient('https://quack.duckduckgo.com');\n this.nextId = 1;\n }\n\n async listAliases(): Promise<RelayAlias[]> {\n return this.store.getAll();\n }\n\n async createAlias(): Promise<RelayAlias> {\n const response =\n await this.httpClient.request<DuckDuckGoCreateAddressResponse>(\n 'POST',\n '/api/email/addresses',\n {\n headers: {\n Authorization: `Bearer ${this.jwtToken}`,\n },\n }\n );\n\n const fullAddress = `${response.address}@duck.com`;\n\n const existing = await this.store.getAll();\n if (existing.some((a) => a.fullAddress === fullAddress)) {\n throw new RelayTempMailError(\n `DuckDuckGo returned a duplicate alias: ${fullAddress}`,\n 'DUPLICATE_ALIAS',\n 201\n );\n }\n\n const alias: RelayAlias = {\n id: this.nextId++,\n address: response.address,\n fullAddress,\n enabled: true,\n createdAt: new Date().toISOString(),\n domain: 3,\n maskType: 'random',\n };\n\n await this.store.add(alias);\n return alias;\n }\n\n async deleteAlias(id: number): Promise<void> {\n await this.store.remove(id);\n }\n}\n","/**\n * MIME email parser for extracting Firefox Relay alias information.\n */\nimport type { ParsedEmail } from './types.js';\n\nconst EMAIL_PATTERN = /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}/g;\nconst MOZMAIL_SUFFIX_PATTERN = /@mozmail\\.com$/i;\nconst DUCK_SUFFIX_PATTERN = /@duck\\.com$/i;\n// DuckDuckGo aliases are \"word-word-word@duck.com\"; the From header\n// uses \"sender_at_domain_alias@duck.com\" which EMAIL_PATTERN matches\n// as a single address. This pattern extracts just the alias portion.\nconst DUCK_ALIAS_PATTERN = /([a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)+@duck\\.com)/gi;\n// System addresses at @duck.com that are not user aliases\nconst DUCK_SYSTEM_ADDRESSES = new Set(['support@duck.com', 'noreply@duck.com']);\nconst ENCODED_WORD_PATTERN = /=\\?([^?]+)\\?([BbQq])\\?([^?]*)\\?=/g;\n\n/**\n * EmailParser class for parsing MIME email content.\n */\nexport class EmailParser {\n parseEmail(raw: string): ParsedEmail {\n const headers = this.parseHeaders(raw);\n const toHeader = headers.get('to') || '';\n const fromHeader = headers.get('from') || '';\n const messageIdHeader = headers.get('message-id') || '';\n const relayAlias = this.extractRelayAlias(raw);\n \n return {\n id: 0,\n messageId: this.extractMessageId(messageIdHeader),\n source: this.extractEmailAddress(fromHeader),\n address: this.extractEmailAddress(toHeader),\n raw,\n metadata: null,\n createdAt: new Date().toISOString(),\n relayAlias: relayAlias || undefined,\n };\n }\n\n extractRelayAlias(raw: string): string | null {\n try {\n const headers = this.parseHeaders(raw);\n\n // DuckDuckGo Email Protection adds a Duck-Original-To header\n // containing the @duck.com alias the email was forwarded to\n const duckOriginalTo = headers.get('duck-original-to');\n if (duckOriginalTo) {\n const duckAddress = this.extractEmailAddress(duckOriginalTo);\n if (duckAddress && DUCK_SUFFIX_PATTERN.test(duckAddress)) {\n return duckAddress;\n }\n }\n\n // Search the full raw content for @duck.com addresses.\n // Duck-Original-To may be stripped during forwarding,\n // but the alias address often appears in From headers as\n // \"sender_at_domain_alias@duck.com\" or elsewhere in the MIME.\n // First try the precise pattern (hyphenated aliases like word-word-word@duck.com)\n const duckMatches = raw.match(DUCK_ALIAS_PATTERN);\n if (duckMatches && duckMatches.length > 0) {\n return duckMatches[0].toLowerCase();\n }\n // Fallback: search with broader EMAIL_PATTERN and filter for @duck.com,\n // excluding known system addresses like support@duck.com\n const rawEmails = raw.match(EMAIL_PATTERN) ?? [];\n const duckFallback = rawEmails.find(\n (e) => DUCK_SUFFIX_PATTERN.test(e) && !DUCK_SYSTEM_ADDRESSES.has(e.toLowerCase())\n );\n if (duckFallback) return duckFallback.toLowerCase();\n\n const fromAddresses = this.extractHeaderEmails(headers.get('from'));\n const toAddresses = this.extractHeaderEmails(headers.get('to'));\n const allAddresses = [...fromAddresses, ...toAddresses];\n\n const mozmailAddress = allAddresses.find((address) =>\n MOZMAIL_SUFFIX_PATTERN.test(address)\n );\n if (mozmailAddress) return mozmailAddress;\n\n return toAddresses[0] ?? null;\n } catch {\n return null;\n }\n }\n\n private parseHeaders(raw: string): Map<string, string> {\n const headers = new Map<string, string>();\n const headerEnd = raw.indexOf('\\r\\n\\r\\n');\n const headerSection = headerEnd === -1 ? raw : raw.substring(0, headerEnd);\n const lines = headerSection.split(/\\r?\\n/);\n let currentHeader: string | null = null;\n let currentValue = '';\n \n for (const line of lines) {\n if (/^\\s/.test(line)) {\n if (currentHeader) currentValue += ' ' + line.trim();\n } else {\n if (currentHeader) headers.set(currentHeader, currentValue);\n const colonIndex = line.indexOf(':');\n if (colonIndex > 0) {\n currentHeader = line.substring(0, colonIndex).toLowerCase().trim();\n currentValue = line.substring(colonIndex + 1).trim();\n } else {\n currentHeader = null;\n currentValue = '';\n }\n }\n }\n if (currentHeader) headers.set(currentHeader, currentValue);\n return headers;\n }\n\n private decodeHeader(value: string): string {\n return value.replace(ENCODED_WORD_PATTERN, (_, charset, encoding, encoded) => {\n try {\n if (encoding.toUpperCase() === 'Q') {\n return this.decodeQuotedPrintable(encoded);\n } else if (encoding.toUpperCase() === 'B') {\n return this.decodeBase64(encoded);\n }\n return encoded;\n } catch {\n return encoded;\n }\n });\n }\n\n private decodeQuotedPrintable(encoded: string): string {\n // RFC 2047: underscores represent spaces in encoded-word\n let decoded = encoded.replace(/_/g, ' ');\n decoded = decoded.replace(/=([0-9A-Fa-f]{2})/g, (_, hex) => \n String.fromCharCode(parseInt(hex, 16))\n );\n return decoded;\n }\n\n private decodeBase64(encoded: string): string {\n return Buffer.from(encoded, 'base64').toString('utf-8');\n }\n\n private extractEmailAddress(headerValue: string): string {\n if (!headerValue) return '';\n const decoded = this.decodeHeader(headerValue);\n const bracketMatch = decoded.match(/<([^>]+)>/);\n if (bracketMatch) return bracketMatch[1].trim().toLowerCase();\n const emailMatch = decoded.match(/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}/);\n return emailMatch ? emailMatch[0].toLowerCase() : decoded.trim().toLowerCase();\n }\n\n private extractHeaderEmails(headerValue?: string): string[] {\n if (!headerValue) return [];\n const decoded = this.decodeHeader(headerValue);\n const matches = decoded.match(EMAIL_PATTERN);\n return matches ? matches.map((match) => match.toLowerCase()) : [];\n }\n\n private extractMessageId(headerValue: string): string {\n if (!headerValue) return `<generated-${Date.now()}@relay-temp-mail>`;\n const cleaned = headerValue.replace(/[<>]/g, '').trim();\n return `<${cleaned}>`;\n }\n}\n","import { HttpClient } from './http';\nimport type { AliasProvider, RelayAlias } from './types';\n\ninterface RawAliasResponse {\n id: number;\n address: string;\n full_address: string;\n enabled: boolean;\n created_at: string;\n domain: number;\n mask_type: string;\n description?: string;\n num_forwarded?: number;\n num_blocked?: number;\n last_modified_at?: string;\n last_used_at?: string | null;\n num_level_one_trackers_blocked?: number;\n num_replied?: number;\n num_spam?: number;\n block_list_emails?: boolean;\n generated_for?: string;\n used_on?: string | null;\n}\n\nexport class FirefoxRelayProvider implements AliasProvider {\n private csrfToken: string;\n private sessionId: string;\n private httpClient: HttpClient;\n\n constructor(\n csrfToken: string,\n sessionId: string,\n httpClient?: HttpClient\n ) {\n this.csrfToken = csrfToken;\n this.sessionId = sessionId;\n this.httpClient = httpClient ?? new HttpClient('https://relay.firefox.com');\n }\n\n private getAuthHeaders(): Record<string, string> {\n return {\n 'Origin': 'https://relay.firefox.com',\n 'Referer': 'https://relay.firefox.com/accounts/profile/?',\n 'Accept': 'application/json',\n 'X-CSRFToken': this.csrfToken,\n 'Cookie': `sessionid=${this.sessionId}; csrftoken=${this.csrfToken}`,\n };\n }\n\n async listAliases(): Promise<RelayAlias[]> {\n const response = await this.httpClient.request<RawAliasResponse[]>(\n 'GET',\n '/api/v1/relayaddresses/',\n { headers: this.getAuthHeaders() }\n );\n\n return response.map((item) => this.mapAliasResponse(item));\n }\n\n async createAlias(): Promise<RelayAlias> {\n const response = await this.httpClient.request<RawAliasResponse>(\n 'POST',\n '/api/v1/relayaddresses/',\n {\n headers: this.getAuthHeaders(),\n body: { enabled: true },\n }\n );\n\n return this.mapAliasResponse(response);\n }\n\n async deleteAlias(id: number): Promise<void> {\n await this.httpClient.request<void>(\n 'DELETE',\n `/api/v1/relayaddresses/${id}/`,\n { headers: this.getAuthHeaders() }\n );\n }\n\n private mapAliasResponse(data: RawAliasResponse): RelayAlias {\n return {\n id: data.id,\n address: data.address,\n fullAddress: data.full_address,\n enabled: data.enabled,\n createdAt: data.created_at,\n domain: data.domain,\n maskType: data.mask_type,\n description: data.description,\n numForwarded: data.num_forwarded,\n numBlocked: data.num_blocked,\n lastModifiedAt: data.last_modified_at,\n lastUsedAt: data.last_used_at,\n numLevelOneTrackersBlocked: data.num_level_one_trackers_blocked,\n numReplied: data.num_replied,\n numSpam: data.num_spam,\n blockListEmails: data.block_list_emails,\n generatedFor: data.generated_for,\n usedOn: data.used_on,\n };\n }\n}\n\n/** @deprecated Use FirefoxRelayProvider instead */\nexport const RelayAPIClient = FirefoxRelayProvider;\n","import { CFTempMailProvider, DefaultHttpClient } from './cf-api.js';\nimport { DuckDuckGoEmailProvider } from './duckduckgo-api.js';\nimport { EmailParser } from './parser.js';\nimport { FirefoxRelayProvider } from './relay-api.js';\nimport { HttpClient } from './http.js';\nimport type {\n TempMailConfig,\n RelayConfig,\n AliasProvider,\n MailProvider,\n RelayAlias,\n ParsedEmail,\n GetEmailsOptions,\n} from './types.js';\n\nfunction createAliasProvider(config: TempMailConfig, httpClient: HttpClient): AliasProvider {\n const aliasConfig = config.aliasProvider;\n switch (aliasConfig.type) {\n case 'firefox-relay':\n return new FirefoxRelayProvider(\n aliasConfig.csrfToken,\n aliasConfig.sessionId,\n httpClient\n );\n case 'duckduckgo-email':\n return new DuckDuckGoEmailProvider(\n aliasConfig.jwtToken,\n aliasConfig.store\n );\n }\n}\n\nfunction createMailProvider(config: TempMailConfig): MailProvider {\n const mailConfig = config.mailProvider;\n switch (mailConfig.type) {\n case 'cf-temp-mail':\n return new CFTempMailProvider(\n mailConfig.apiUrl,\n mailConfig.token\n );\n }\n}\n\nexport class TempMailClient {\n private readonly aliasProvider: AliasProvider;\n private readonly mailProvider: MailProvider;\n private readonly parser: EmailParser;\n\n constructor(config: TempMailConfig) {\n const timeout = config.timeout ?? 30000;\n const httpClient = new HttpClient('https://relay.firefox.com', timeout);\n this.aliasProvider = createAliasProvider(config, httpClient);\n this.mailProvider = createMailProvider(config);\n this.parser = new EmailParser();\n }\n\n async listAliases(): Promise<RelayAlias[]> {\n return this.aliasProvider.listAliases();\n }\n\n async createAlias(): Promise<RelayAlias> {\n return this.aliasProvider.createAlias();\n }\n\n async deleteAlias(id: number): Promise<void> {\n return this.aliasProvider.deleteAlias(id);\n }\n\n async getEmails(\n aliasAddress?: string,\n options?: GetEmailsOptions\n ): Promise<ParsedEmail[]> {\n const limit = options?.limit ?? 20;\n const offset = options?.offset ?? 0;\n\n const emails = await this.mailProvider.getMails(limit, offset);\n\n const parsedEmails: ParsedEmail[] = emails.map((email) => {\n const parsed = this.parser.parseEmail(email.raw);\n return {\n ...parsed,\n id: email.id,\n messageId: email.messageId,\n source: email.source,\n address: email.address,\n createdAt: email.createdAt,\n metadata: email.metadata,\n };\n });\n\n if (aliasAddress) {\n const normalizedAlias = aliasAddress.toLowerCase();\n return parsedEmails.filter(\n (email) =>\n email.relayAlias?.toLowerCase() === normalizedAlias ||\n email.address.toLowerCase() === normalizedAlias\n );\n }\n\n return parsedEmails;\n }\n}\n\n/** @deprecated Use TempMailClient instead */\nexport const RelayClient = TempMailClient;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACcO,IAAM,qBAAN,cAAiC,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAyB5C,YACE,SACA,MACA,YACA,UACA;AACA,UAAM,OAAO;AACb,SAAK,OAAO,KAAK,YAAY;AAC7B,SAAK,OAAO;AACZ,SAAK,aAAa;AAClB,SAAK,WAAW;AAGhB,QAAI,MAAM,mBAAmB;AAC3B,YAAM,kBAAkB,MAAM,KAAK,WAAW;AAAA,IAChD;AAAA,EACF;AACF;AASO,IAAM,eAAN,cAA2B,mBAAmB;AAAA,EAGnD,YAAY,SAAiB,UAAgB;AAC3C,UAAM,SAAS,iBAAiB,QAAW,QAAQ;AAHrD,gBAAO;AAAA,EAIP;A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,MAAM;AAAA,QACd,SAAS,MAAM;AAAA,QACf,WAAW,MAAM;AAAA,QACjB,UAAU,MAAM;AAAA,MAClB;AAAA,IACF,CAAC;AAED,QAAI,cAAc;AAChB,YAAM,kBAAkB,aAAa,YAAY;AACjD,aAAO,aAAa;AAAA,QAClB,CAAC,UACC,MAAM,YAAY,YAAY,MAAM,mBACpC,MAAM,QAAQ,YAAY,MAAM;AAAA,MACpC;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AACF;AAGO,IAAM,cAAc;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/cf-api.ts","../src/http.ts","../src/duckduckgo-api.ts","../src/parser.ts","../src/relay-api.ts","../src/client.ts"],"sourcesContent":["export type {\n AliasProvider,\n MailProvider,\n TempMailConfig,\n FirefoxRelayConfig,\n DuckDuckGoEmailConfig,\n DuckDuckGoAliasStore,\n CFTempMailConfig,\n AliasProviderConfig,\n MailProviderConfig,\n RelayAlias,\n Email,\n ParsedEmail,\n ListAliasesOptions,\n GetEmailsOptions,\n CFMailsResponse,\n RelayAddressesResponse,\n CreateAliasResponse,\n RelayConfig,\n} from './types.js';\n\nexport {\n RelayTempMailError,\n NetworkError,\n AuthError,\n NotFoundError,\n ParseError,\n RateLimitError,\n} from './errors.js';\n\nexport { TempMailClient, RelayClient } from './client.js';\n\nexport { FirefoxRelayProvider, RelayAPIClient } from './relay-api.js';\n\nexport { CFTempMailProvider, CFEmailClient } from './cf-api.js';\n\nexport {\n DuckDuckGoEmailProvider,\n InMemoryDuckDuckGoAliasStore,\n} from './duckduckgo-api.js';\n","/**\n * Custom error classes for the relay-temp-mail package.\n *\n * These errors provide structured error information including error codes,\n * HTTP status codes, and response data for better error handling.\n */\n\n/**\n * Base error class for all relay-temp-mail errors.\n *\n * Extends the built-in Error class with additional context about the error,\n * including an error code for programmatic error handling and optional\n * response data from the API.\n */\nexport class RelayTempMailError extends Error {\n /**\n * Machine-readable error code for programmatic error handling.\n * Examples: 'NETWORK_ERROR', 'AUTH_ERROR', 'NOT_FOUND'\n */\n code: string;\n\n /**\n * HTTP status code associated with this error, if applicable.\n */\n statusCode?: number;\n\n /**\n * Raw response data from the API, if available.\n */\n response?: any;\n\n /**\n * Creates a new RelayTempMailError instance.\n *\n * @param message - Human-readable error message describing the error.\n * @param code - Machine-readable error code (e.g., 'UNKNOWN_ERROR').\n * @param statusCode - Optional HTTP status code associated with the error.\n * @param response - Optional raw response data from the API.\n */\n constructor(\n message: string,\n code: string,\n statusCode?: number,\n response?: any\n ) {\n super(message);\n this.name = this.constructor.name;\n this.code = code;\n this.statusCode = statusCode;\n this.response = response;\n\n // Maintains proper stack trace in V8 environments\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, this.constructor);\n }\n }\n}\n\n/**\n * Error for network-related failures.\n *\n * Thrown when there is a problem establishing or maintaining a network\n * connection, such as DNS resolution failures, connection timeouts,\n * or network unreachability.\n */\nexport class NetworkError extends RelayTempMailError {\n code = 'NETWORK_ERROR' as const;\n\n constructor(message: string, response?: any) {\n super(message, 'NETWORK_ERROR', undefined, response);\n }\n}\n\n/**\n * Error for authentication and authorization failures.\n *\n * Thrown when API requests fail due to invalid or missing credentials\n * (401) or when the authenticated user lacks permission for the\n * requested operation (403).\n */\nexport class AuthError extends RelayTempMailError {\n code = 'AUTH_ERROR' as const;\n\n constructor(message: string, statusCode?: number, response?: any) {\n super(message, 'AUTH_ERROR', statusCode, response);\n }\n}\n\n/**\n * Error for resource not found errors.\n *\n * Thrown when the requested resource does not exist (404 response),\n * such as when trying to access a non-existent alias or email.\n */\nexport class NotFoundError extends RelayTempMailError {\n code = 'NOT_FOUND' as const;\n\n constructor(message: string, response?: any) {\n super(message, 'NOT_FOUND', 404, response);\n }\n}\n\n/**\n * Error for MIME message parsing failures.\n *\n * Thrown when there is an error parsing email MIME content,\n * such as malformed headers or invalid message structure.\n */\nexport class ParseError extends RelayTempMailError {\n code = 'PARSE_ERROR' as const;\n\n constructor(message: string, response?: any) {\n super(message, 'PARSE_ERROR', undefined, response);\n }\n}\n\n/**\n * Error for rate limiting responses.\n *\n * Thrown when the API rate limit has been exceeded (429 response).\n * The client should wait and retry the request after the indicated\n * cooldown period.\n */\nexport class RateLimitError extends RelayTempMailError {\n code = 'RATE_LIMIT_ERROR' as const;\n\n constructor(message: string, response?: any) {\n super(message, 'RATE_LIMIT_ERROR', 429, response);\n }\n}\n","import type { MailProvider, Email } from './types.js';\nimport { AuthError, NetworkError, NotFoundError, RateLimitError, RelayTempMailError } from './errors.js';\n\ninterface CFRawEmail {\n id: number;\n message_id: string;\n source: string;\n address: string;\n raw: string;\n metadata: any | null;\n created_at: string;\n}\n\ninterface CFRawResponse {\n results: CFRawEmail[];\n count: number;\n}\n\nexport class CFTempMailProvider implements MailProvider {\n private readonly apiUrl: string;\n private readonly token: string;\n private readonly httpClient: HttpClient;\n\n constructor(apiUrl: string, token: string, httpClient?: HttpClient) {\n this.apiUrl = apiUrl.replace(/\\/+$/, '');\n this.token = token;\n this.httpClient = httpClient ?? new DefaultHttpClient();\n }\n\n async getMails(limit: number = 20, offset: number = 0): Promise<Email[]> {\n const url = new URL(`${this.apiUrl}/api/mails`);\n url.searchParams.set('limit', String(limit));\n url.searchParams.set('offset', String(offset));\n\n const headers: Record<string, string> = {\n 'Authorization': `Bearer ${this.token}`,\n };\n\n try {\n const response = await this.httpClient.get(url.toString(), { headers });\n return this.mapCFResponse(response as CFRawResponse);\n } catch (error) {\n throw this.handleError(error);\n }\n }\n\n private mapCFResponse(response: CFRawResponse): Email[] {\n return response.results.map((item): Email => ({\n id: item.id,\n messageId: item.message_id,\n source: item.source,\n address: item.address,\n raw: item.raw,\n metadata: item.metadata,\n createdAt: item.created_at,\n }));\n }\n\n private handleError(error: unknown): RelayTempMailError {\n if (error instanceof RelayTempMailError) {\n const statusCode = error.statusCode;\n\n if (statusCode === 401 || statusCode === 403) {\n return new AuthError(error.message, statusCode, error.response);\n }\n if (statusCode === 404) {\n return new NotFoundError(error.message, error.response);\n }\n if (statusCode === 429) {\n return new RateLimitError(error.message, error.response);\n }\n\n return error;\n }\n\n if (error instanceof TypeError && error.message.includes('fetch')) {\n return new NetworkError(error.message);\n }\n\n if (error instanceof Error) {\n return new NetworkError(error.message);\n }\n\n return new RelayTempMailError(\n 'Unknown error occurred',\n 'UNKNOWN_ERROR',\n undefined,\n error\n );\n }\n}\n\n/** @deprecated Use CFTempMailProvider instead */\nexport const CFEmailClient = CFTempMailProvider;\n\nexport interface HttpClient {\n get(url: string, options?: { headers?: Record<string, string> }): Promise<unknown>;\n}\n\nexport class DefaultHttpClient implements HttpClient {\n async get(url: string, options?: { headers?: Record<string, string> }): Promise<unknown> {\n const response = await fetch(url, {\n method: 'GET',\n headers: options?.headers,\n });\n\n if (!response.ok) {\n const errorBody = await response.text();\n throw new RelayTempMailError(\n `HTTP ${response.status}: ${errorBody}`,\n 'HTTP_ERROR',\n response.status,\n errorBody\n );\n }\n\n return response.json();\n }\n}\n","/**\n * HTTP client utilities for the relay-temp-mail package.\n *\n * This module provides a configurable HTTP client with timeout support,\n * automatic retry logic, and proper error classification for API responses.\n */\n\nimport {\n RelayTempMailError,\n NetworkError,\n AuthError,\n NotFoundError,\n RateLimitError,\n} from './errors';\n\n/**\n * Options for individual HTTP requests.\n */\nexport interface RequestOptions {\n /** Custom headers to include in the request */\n headers?: Record<string, string>;\n\n /** Request body (will be JSON serialized) */\n body?: unknown;\n\n /** Request timeout in milliseconds (overrides client default) */\n timeout?: number;\n\n /** Number of retries on failure (overrides client default) */\n retries?: number;\n}\n\n/**\n * HTTP client for making requests to the relay-temp-mail API.\n *\n * Provides a configurable base URL with timeout, retry, and automatic\n * JSON parsing capabilities.\n */\nexport class HttpClient {\n private baseUrl: string;\n private defaultTimeout: number;\n private defaultRetries: number;\n\n /**\n * Creates a new HttpClient instance.\n *\n * @param baseUrl - Base URL for all requests (e.g., 'https://api.example.com')\n * @param defaultTimeout - Default timeout in milliseconds (default: 30000)\n * @param defaultRetries - Default number of retries on failure (default: 0)\n */\n constructor(\n baseUrl: string,\n defaultTimeout: number = 30000,\n defaultRetries: number = 0\n ) {\n this.baseUrl = baseUrl.replace(/\\/$/, ''); // Remove trailing slash\n this.defaultTimeout = defaultTimeout;\n this.defaultRetries = defaultRetries;\n }\n\n /**\n * Makes an HTTP request to the specified path.\n *\n * @param method - HTTP method (GET, POST, PUT, DELETE, etc.)\n * @param path - API path (will be appended to baseUrl)\n * @param options - Optional request configuration\n * @returns Promise resolving to the parsed JSON response\n */\n async request<T>(\n method: string,\n path: string,\n options: RequestOptions = {}\n ): Promise<T> {\n const timeout = options.timeout ?? this.defaultTimeout;\n const retries = options.retries ?? this.defaultRetries;\n\n let lastError: RelayTempMailError | Error | undefined;\n\n for (let attempt = 0; attempt <= retries; attempt++) {\n try {\n const response = await this.executeRequest(method, path, options, timeout);\n return await this.handleResponse<T>(response);\n } catch (error) {\n lastError = error as Error;\n\n // Check if we should retry\n if (attempt < retries && this.shouldRetry(error)) {\n const delay = 1000 * Math.pow(2, attempt);\n await this.sleep(delay);\n continue;\n }\n\n // Don't retry, throw the classified error\n if (error instanceof RelayTempMailError) {\n throw error;\n }\n\n // Classify the error if not already classified\n throw this.classifyError(error);\n }\n }\n\n // This should never be reached, but just in case\n throw lastError || new NetworkError('Request failed');\n }\n\n /**\n * Executes the actual HTTP request with timeout support.\n */\n private async executeRequest(\n method: string,\n path: string,\n options: RequestOptions,\n timeout: number\n ): Promise<Response> {\n const url = `${this.baseUrl}${path}`;\n\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), timeout);\n\n try {\n const fetchOptions: RequestInit = {\n method,\n headers: {\n 'Content-Type': 'application/json',\n ...options.headers,\n },\n signal: controller.signal,\n };\n\n if (options.body !== undefined) {\n fetchOptions.body = JSON.stringify(options.body);\n }\n\n const response = await fetch(url, fetchOptions);\n return response;\n } finally {\n clearTimeout(timeoutId);\n }\n }\n\n /**\n * Handles the HTTP response, parsing JSON and checking for errors.\n */\n private async handleResponse<T>(response: Response): Promise<T> {\n if (!response.ok) {\n throw this.classifyError(new Error(`HTTP ${response.status}`), response);\n }\n\n const text = await response.text();\n\n // Handle empty responses\n if (!text) {\n return {} as T;\n }\n\n return JSON.parse(text) as T;\n }\n\n /**\n * Classifies an error based on the error type and HTTP response.\n */\n private classifyError(error: unknown, response?: Response): RelayTempMailError {\n // Network errors (fetch failed)\n if (error instanceof Error && error.name === 'AbortError') {\n return new NetworkError('Request timed out');\n }\n\n if (error instanceof TypeError && error.message.includes('fetch')) {\n return new NetworkError('Network request failed');\n }\n\n if (error instanceof Error && error.message.includes('Failed to fetch')) {\n return new NetworkError('Network request failed');\n }\n\n // HTTP status-based classification\n if (response) {\n const status = response.status;\n\n if (status === 401 || status === 403) {\n return new AuthError(\n `Authentication failed: ${response.statusText}`,\n status\n );\n }\n\n if (status === 404) {\n return new NotFoundError(`Resource not found: ${response.statusText}`);\n }\n\n if (status === 429) {\n return new RateLimitError(\n `Rate limit exceeded: ${response.statusText}`\n );\n }\n\n if (status >= 500) {\n return new NetworkError(\n `Server error: ${response.statusText}`,\n status\n );\n }\n }\n\n // Default error\n if (error instanceof Error) {\n return new RelayTempMailError(\n error.message,\n 'REQUEST_ERROR',\n response?.status\n );\n }\n\n return new RelayTempMailError('Unknown error occurred', 'UNKNOWN_ERROR');\n }\n\n /**\n * Determines if a request should be retried based on the error.\n */\n private shouldRetry(error: unknown): boolean {\n if (error instanceof NetworkError) {\n return true;\n }\n\n if (error instanceof RelayTempMailError && error.statusCode) {\n return error.statusCode >= 500;\n }\n\n if (error instanceof Error) {\n if (error.name === 'AbortError') {\n return true;\n }\n if (error instanceof TypeError && error.message.includes('fetch')) {\n return true;\n }\n }\n\n return false;\n }\n\n /**\n * Sleep for a specified duration.\n */\n private sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n }\n}\n","import { HttpClient } from './http';\nimport { RelayTempMailError } from './errors';\nimport type { AliasProvider, RelayAlias, DuckDuckGoAliasStore } from './types';\n\ninterface DuckDuckGoCreateAddressResponse {\n address: string;\n}\n\nexport class InMemoryDuckDuckGoAliasStore implements DuckDuckGoAliasStore {\n private aliases: RelayAlias[] = [];\n\n getAll(): RelayAlias[] {\n return [...this.aliases];\n }\n\n add(alias: RelayAlias): void {\n this.aliases.push(alias);\n }\n\n remove(id: number): void {\n this.aliases = this.aliases.filter((a) => a.id !== id);\n }\n}\n\nexport class DuckDuckGoEmailProvider implements AliasProvider {\n private jwtToken: string;\n private httpClient: HttpClient;\n private store: DuckDuckGoAliasStore;\n private nextId: number;\n\n constructor(\n jwtToken: string,\n store?: DuckDuckGoAliasStore,\n httpClient?: HttpClient\n ) {\n this.jwtToken = jwtToken;\n this.store = store ?? new InMemoryDuckDuckGoAliasStore();\n this.httpClient =\n httpClient ?? new HttpClient('https://quack.duckduckgo.com');\n this.nextId = 1;\n }\n\n async listAliases(): Promise<RelayAlias[]> {\n return this.store.getAll();\n }\n\n async createAlias(): Promise<RelayAlias> {\n const response =\n await this.httpClient.request<DuckDuckGoCreateAddressResponse>(\n 'POST',\n '/api/email/addresses',\n {\n headers: {\n Authorization: `Bearer ${this.jwtToken}`,\n },\n }\n );\n\n const fullAddress = `${response.address}@duck.com`;\n\n const existing = await this.store.getAll();\n if (existing.some((a) => a.fullAddress === fullAddress)) {\n throw new RelayTempMailError(\n `DuckDuckGo returned a duplicate alias: ${fullAddress}`,\n 'DUPLICATE_ALIAS',\n 201\n );\n }\n\n const alias: RelayAlias = {\n id: this.nextId++,\n address: response.address,\n fullAddress,\n enabled: true,\n createdAt: new Date().toISOString(),\n domain: 3,\n maskType: 'random',\n };\n\n await this.store.add(alias);\n return alias;\n }\n\n async deleteAlias(id: number): Promise<void> {\n await this.store.remove(id);\n }\n}\n","/**\n * MIME email parser for extracting Firefox Relay alias information.\n */\nimport type { ParsedEmail } from './types.js';\n\nconst EMAIL_PATTERN = /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}/g;\nconst MOZMAIL_SUFFIX_PATTERN = /@mozmail\\.com$/i;\nconst ENCODED_WORD_PATTERN = /=\\?([^?]+)\\?([BbQq])\\?([^?]*)\\?=/g;\n\n/**\n * EmailParser class for parsing MIME email content.\n */\nexport class EmailParser {\n parseEmail(raw: string): ParsedEmail {\n const headers = this.parseHeaders(raw);\n const toHeader = headers.get('to') || '';\n const fromHeader = headers.get('from') || '';\n const messageIdHeader = headers.get('message-id') || '';\n const relayAlias = this.extractRelayAlias(raw);\n \n return {\n id: 0,\n messageId: this.extractMessageId(messageIdHeader),\n source: this.extractEmailAddress(fromHeader),\n address: this.extractEmailAddress(toHeader),\n raw,\n metadata: null,\n createdAt: new Date().toISOString(),\n relayAlias: relayAlias || undefined,\n };\n }\n\n extractRelayAlias(raw: string): string | null {\n try {\n const headers = this.parseHeaders(raw);\n const fromAddresses = this.extractHeaderEmails(headers.get('from'));\n const toAddresses = this.extractHeaderEmails(headers.get('to'));\n const allAddresses = [...fromAddresses, ...toAddresses];\n\n const mozmailAddress = allAddresses.find((address) =>\n MOZMAIL_SUFFIX_PATTERN.test(address)\n );\n if (mozmailAddress) return mozmailAddress;\n\n return toAddresses[0] ?? null;\n } catch {\n return null;\n }\n }\n\n private parseHeaders(raw: string): Map<string, string> {\n const headers = new Map<string, string>();\n const headerEnd = raw.indexOf('\\r\\n\\r\\n');\n const headerSection = headerEnd === -1 ? raw : raw.substring(0, headerEnd);\n const lines = headerSection.split(/\\r?\\n/);\n let currentHeader: string | null = null;\n let currentValue = '';\n \n for (const line of lines) {\n if (/^\\s/.test(line)) {\n if (currentHeader) currentValue += ' ' + line.trim();\n } else {\n if (currentHeader) headers.set(currentHeader, currentValue);\n const colonIndex = line.indexOf(':');\n if (colonIndex > 0) {\n currentHeader = line.substring(0, colonIndex).toLowerCase().trim();\n currentValue = line.substring(colonIndex + 1).trim();\n } else {\n currentHeader = null;\n currentValue = '';\n }\n }\n }\n if (currentHeader) headers.set(currentHeader, currentValue);\n return headers;\n }\n\n private decodeHeader(value: string): string {\n return value.replace(ENCODED_WORD_PATTERN, (_, charset, encoding, encoded) => {\n try {\n if (encoding.toUpperCase() === 'Q') {\n return this.decodeQuotedPrintable(encoded);\n } else if (encoding.toUpperCase() === 'B') {\n return this.decodeBase64(encoded);\n }\n return encoded;\n } catch {\n return encoded;\n }\n });\n }\n\n private decodeQuotedPrintable(encoded: string): string {\n // RFC 2047: underscores represent spaces in encoded-word\n let decoded = encoded.replace(/_/g, ' ');\n decoded = decoded.replace(/=([0-9A-Fa-f]{2})/g, (_, hex) => \n String.fromCharCode(parseInt(hex, 16))\n );\n return decoded;\n }\n\n private decodeBase64(encoded: string): string {\n return Buffer.from(encoded, 'base64').toString('utf-8');\n }\n\n private extractEmailAddress(headerValue: string): string {\n if (!headerValue) return '';\n const decoded = this.decodeHeader(headerValue);\n const bracketMatch = decoded.match(/<([^>]+)>/);\n if (bracketMatch) return bracketMatch[1].trim().toLowerCase();\n const emailMatch = decoded.match(/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}/);\n return emailMatch ? emailMatch[0].toLowerCase() : decoded.trim().toLowerCase();\n }\n\n private extractHeaderEmails(headerValue?: string): string[] {\n if (!headerValue) return [];\n const decoded = this.decodeHeader(headerValue);\n const matches = decoded.match(EMAIL_PATTERN);\n return matches ? matches.map((match) => match.toLowerCase()) : [];\n }\n\n private extractMessageId(headerValue: string): string {\n if (!headerValue) return `<generated-${Date.now()}@relay-temp-mail>`;\n const cleaned = headerValue.replace(/[<>]/g, '').trim();\n return `<${cleaned}>`;\n }\n}\n","import { HttpClient } from './http';\nimport type { AliasProvider, RelayAlias } from './types';\n\ninterface RawAliasResponse {\n id: number;\n address: string;\n full_address: string;\n enabled: boolean;\n created_at: string;\n domain: number;\n mask_type: string;\n description?: string;\n num_forwarded?: number;\n num_blocked?: number;\n last_modified_at?: string;\n last_used_at?: string | null;\n num_level_one_trackers_blocked?: number;\n num_replied?: number;\n num_spam?: number;\n block_list_emails?: boolean;\n generated_for?: string;\n used_on?: string | null;\n}\n\nexport class FirefoxRelayProvider implements AliasProvider {\n private csrfToken: string;\n private sessionId: string;\n private httpClient: HttpClient;\n\n constructor(\n csrfToken: string,\n sessionId: string,\n httpClient?: HttpClient\n ) {\n this.csrfToken = csrfToken;\n this.sessionId = sessionId;\n this.httpClient = httpClient ?? new HttpClient('https://relay.firefox.com');\n }\n\n private getAuthHeaders(): Record<string, string> {\n return {\n 'Origin': 'https://relay.firefox.com',\n 'Referer': 'https://relay.firefox.com/accounts/profile/?',\n 'Accept': 'application/json',\n 'X-CSRFToken': this.csrfToken,\n 'Cookie': `sessionid=${this.sessionId}; csrftoken=${this.csrfToken}`,\n };\n }\n\n async listAliases(): Promise<RelayAlias[]> {\n const response = await this.httpClient.request<RawAliasResponse[]>(\n 'GET',\n '/api/v1/relayaddresses/',\n { headers: this.getAuthHeaders() }\n );\n\n return response.map((item) => this.mapAliasResponse(item));\n }\n\n async createAlias(): Promise<RelayAlias> {\n const response = await this.httpClient.request<RawAliasResponse>(\n 'POST',\n '/api/v1/relayaddresses/',\n {\n headers: this.getAuthHeaders(),\n body: { enabled: true },\n }\n );\n\n return this.mapAliasResponse(response);\n }\n\n async deleteAlias(id: number): Promise<void> {\n await this.httpClient.request<void>(\n 'DELETE',\n `/api/v1/relayaddresses/${id}/`,\n { headers: this.getAuthHeaders() }\n );\n }\n\n private mapAliasResponse(data: RawAliasResponse): RelayAlias {\n return {\n id: data.id,\n address: data.address,\n fullAddress: data.full_address,\n enabled: data.enabled,\n createdAt: data.created_at,\n domain: data.domain,\n maskType: data.mask_type,\n description: data.description,\n numForwarded: data.num_forwarded,\n numBlocked: data.num_blocked,\n lastModifiedAt: data.last_modified_at,\n lastUsedAt: data.last_used_at,\n numLevelOneTrackersBlocked: data.num_level_one_trackers_blocked,\n numReplied: data.num_replied,\n numSpam: data.num_spam,\n blockListEmails: data.block_list_emails,\n generatedFor: data.generated_for,\n usedOn: data.used_on,\n };\n }\n}\n\n/** @deprecated Use FirefoxRelayProvider instead */\nexport const RelayAPIClient = FirefoxRelayProvider;\n","import { CFTempMailProvider, DefaultHttpClient } from './cf-api.js';\nimport { DuckDuckGoEmailProvider } from './duckduckgo-api.js';\nimport { EmailParser } from './parser.js';\nimport { FirefoxRelayProvider } from './relay-api.js';\nimport { HttpClient } from './http.js';\nimport type {\n TempMailConfig,\n RelayConfig,\n AliasProvider,\n MailProvider,\n RelayAlias,\n ParsedEmail,\n GetEmailsOptions,\n} from './types.js';\n\nfunction createAliasProvider(config: TempMailConfig, httpClient: HttpClient): AliasProvider {\n const aliasConfig = config.aliasProvider;\n switch (aliasConfig.type) {\n case 'firefox-relay':\n return new FirefoxRelayProvider(\n aliasConfig.csrfToken,\n aliasConfig.sessionId,\n httpClient\n );\n case 'duckduckgo-email':\n return new DuckDuckGoEmailProvider(\n aliasConfig.jwtToken,\n aliasConfig.store\n );\n }\n}\n\nfunction createMailProvider(config: TempMailConfig): MailProvider {\n const mailConfig = config.mailProvider;\n switch (mailConfig.type) {\n case 'cf-temp-mail':\n return new CFTempMailProvider(\n mailConfig.apiUrl,\n mailConfig.token\n );\n }\n}\n\nexport class TempMailClient {\n private readonly aliasProvider: AliasProvider;\n private readonly mailProvider: MailProvider;\n private readonly parser: EmailParser;\n\n constructor(config: TempMailConfig) {\n const timeout = config.timeout ?? 30000;\n const httpClient = new HttpClient('https://relay.firefox.com', timeout);\n this.aliasProvider = createAliasProvider(config, httpClient);\n this.mailProvider = createMailProvider(config);\n this.parser = new EmailParser();\n }\n\n async listAliases(): Promise<RelayAlias[]> {\n return this.aliasProvider.listAliases();\n }\n\n async createAlias(): Promise<RelayAlias> {\n return this.aliasProvider.createAlias();\n }\n\n async deleteAlias(id: number): Promise<void> {\n return this.aliasProvider.deleteAlias(id);\n }\n\n async getEmails(\n aliasAddress?: string,\n options?: GetEmailsOptions\n ): Promise<ParsedEmail[]> {\n const limit = options?.limit ?? 20;\n const offset = options?.offset ?? 0;\n\n const emails = await this.mailProvider.getMails(limit, offset);\n\n const parsedEmails: ParsedEmail[] = emails.map((email) => {\n const parsed = this.parser.parseEmail(email.raw);\n return {\n ...parsed,\n id: email.id,\n messageId: email.messageId,\n source: email.source,\n address: email.address,\n createdAt: email.createdAt,\n metadata: email.metadata,\n };\n });\n\n if (aliasAddress) {\n const normalizedAlias = aliasAddress.toLowerCase();\n return parsedEmails.filter(\n (email) =>\n email.relayAlias?.toLowerCase() === normalizedAlias ||\n email.address.toLowerCase() === normalizedAlias ||\n email.raw.toLowerCase().includes(normalizedAlias)\n );\n }\n\n return parsedEmails;\n }\n}\n\n/** @deprecated Use TempMailClient instead */\nexport const RelayClient = TempMailClient;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACcO,IAAM,qBAAN,cAAiC,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAyB5C,YACE,SACA,MACA,YACA,UACA;AACA,UAAM,OAAO;AACb,SAAK,OAAO,KAAK,YAAY;AAC7B,SAAK,OAAO;AACZ,SAAK,aAAa;AAClB,SAAK,WAAW;AAGhB,QAAI,MAAM,mBAAmB;AAC3B,YAAM,kBAAkB,MAAM,KAAK,WAAW;AAAA,IAChD;AAAA,EACF;AACF;AASO,IAAM,eAAN,cAA2B,mBAAmB;AAAA,EAGnD,YAAY,SAAiB,UAAgB;AAC3C,UAAM,SAAS,iBAAiB,QAAW,QAAQ;AAHrD,gBAAO;AAAA,EAIP;AACF;AASO,IAAM,YAAN,cAAwB,mBAAmB;AAAA,EAGhD,YAAY,SAAiB,YAAqB,UAAgB;AAChE,UAAM,SAAS,cAAc,YAAY,QAAQ;AAHnD,gBAAO;AAAA,EAIP;AACF;AAQO,IAAM,gBAAN,cAA4B,mBAAmB;AAAA,EAGpD,YAAY,SAAiB,UAAgB;A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IAA2B;AAC3C,WAAO,KAAK,cAAc,YAAY,EAAE;AAAA,EAC1C;AAAA,EAEA,MAAM,UACJ,cACA,SACwB;AACxB,UAAM,QAAQ,SAAS,SAAS;AAChC,UAAM,SAAS,SAAS,UAAU;AAElC,UAAM,SAAS,MAAM,KAAK,aAAa,SAAS,OAAO,MAAM;AAE7D,UAAM,eAA8B,OAAO,IAAI,CAAC,UAAU;AACxD,YAAM,SAAS,KAAK,OAAO,WAAW,MAAM,GAAG;AAC/C,aAAO;AAAA,QACL,GAAG;AAAA,QACH,IAAI,MAAM;AAAA,QACV,WAAW,MAAM;AAAA,QACjB,QAAQ,MAAM;AAAA,QACd,SAAS,MAAM;AAAA,QACf,WAAW,MAAM;AAAA,QACjB,UAAU,MAAM;AAAA,MAClB;AAAA,IACF,CAAC;AAED,QAAI,cAAc;AAChB,YAAM,kBAAkB,aAAa,YAAY;AACjD,aAAO,aAAa;AAAA,QAClB,CAAC,UACC,MAAM,YAAY,YAAY,MAAM,mBACpC,MAAM,QAAQ,YAAY,MAAM,mBAChC,MAAM,IAAI,YAAY,EAAE,SAAS,eAAe;AAAA,MACpD;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AACF;AAGO,IAAM,cAAc;","names":[]}
|
package/dist/index.js
CHANGED
|
@@ -350,9 +350,6 @@ var DuckDuckGoEmailProvider = class {
|
|
|
350
350
|
// src/parser.ts
|
|
351
351
|
var EMAIL_PATTERN = /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g;
|
|
352
352
|
var MOZMAIL_SUFFIX_PATTERN = /@mozmail\.com$/i;
|
|
353
|
-
var DUCK_SUFFIX_PATTERN = /@duck\.com$/i;
|
|
354
|
-
var DUCK_ALIAS_PATTERN = /([a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)+@duck\.com)/gi;
|
|
355
|
-
var DUCK_SYSTEM_ADDRESSES = /* @__PURE__ */ new Set(["support@duck.com", "noreply@duck.com"]);
|
|
356
353
|
var ENCODED_WORD_PATTERN = /=\?([^?]+)\?([BbQq])\?([^?]*)\?=/g;
|
|
357
354
|
var EmailParser = class {
|
|
358
355
|
parseEmail(raw) {
|
|
@@ -375,22 +372,6 @@ var EmailParser = class {
|
|
|
375
372
|
extractRelayAlias(raw) {
|
|
376
373
|
try {
|
|
377
374
|
const headers = this.parseHeaders(raw);
|
|
378
|
-
const duckOriginalTo = headers.get("duck-original-to");
|
|
379
|
-
if (duckOriginalTo) {
|
|
380
|
-
const duckAddress = this.extractEmailAddress(duckOriginalTo);
|
|
381
|
-
if (duckAddress && DUCK_SUFFIX_PATTERN.test(duckAddress)) {
|
|
382
|
-
return duckAddress;
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
const duckMatches = raw.match(DUCK_ALIAS_PATTERN);
|
|
386
|
-
if (duckMatches && duckMatches.length > 0) {
|
|
387
|
-
return duckMatches[0].toLowerCase();
|
|
388
|
-
}
|
|
389
|
-
const rawEmails = raw.match(EMAIL_PATTERN) ?? [];
|
|
390
|
-
const duckFallback = rawEmails.find(
|
|
391
|
-
(e) => DUCK_SUFFIX_PATTERN.test(e) && !DUCK_SYSTEM_ADDRESSES.has(e.toLowerCase())
|
|
392
|
-
);
|
|
393
|
-
if (duckFallback) return duckFallback.toLowerCase();
|
|
394
375
|
const fromAddresses = this.extractHeaderEmails(headers.get("from"));
|
|
395
376
|
const toAddresses = this.extractHeaderEmails(headers.get("to"));
|
|
396
377
|
const allAddresses = [...fromAddresses, ...toAddresses];
|
|
@@ -604,7 +585,7 @@ var TempMailClient = class {
|
|
|
604
585
|
if (aliasAddress) {
|
|
605
586
|
const normalizedAlias = aliasAddress.toLowerCase();
|
|
606
587
|
return parsedEmails.filter(
|
|
607
|
-
(email) => email.relayAlias?.toLowerCase() === normalizedAlias || email.address.toLowerCase() === normalizedAlias
|
|
588
|
+
(email) => email.relayAlias?.toLowerCase() === normalizedAlias || email.address.toLowerCase() === normalizedAlias || email.raw.toLowerCase().includes(normalizedAlias)
|
|
608
589
|
);
|
|
609
590
|
}
|
|
610
591
|
return parsedEmails;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors.ts","../src/cf-api.ts","../src/http.ts","../src/duckduckgo-api.ts","../src/parser.ts","../src/relay-api.ts","../src/client.ts"],"sourcesContent":["/**\n * Custom error classes for the relay-temp-mail package.\n *\n * These errors provide structured error information including error codes,\n * HTTP status codes, and response data for better error handling.\n */\n\n/**\n * Base error class for all relay-temp-mail errors.\n *\n * Extends the built-in Error class with additional context about the error,\n * including an error code for programmatic error handling and optional\n * response data from the API.\n */\nexport class RelayTempMailError extends Error {\n /**\n * Machine-readable error code for programmatic error handling.\n * Examples: 'NETWORK_ERROR', 'AUTH_ERROR', 'NOT_FOUND'\n */\n code: string;\n\n /**\n * HTTP status code associated with this error, if applicable.\n */\n statusCode?: number;\n\n /**\n * Raw response data from the API, if available.\n */\n response?: any;\n\n /**\n * Creates a new RelayTempMailError instance.\n *\n * @param message - Human-readable error message describing the error.\n * @param code - Machine-readable error code (e.g., 'UNKNOWN_ERROR').\n * @param statusCode - Optional HTTP status code associated with the error.\n * @param response - Optional raw response data from the API.\n */\n constructor(\n message: string,\n code: string,\n statusCode?: number,\n response?: any\n ) {\n super(message);\n this.name = this.constructor.name;\n this.code = code;\n this.statusCode = statusCode;\n this.response = response;\n\n // Maintains proper stack trace in V8 environments\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, this.constructor);\n }\n }\n}\n\n/**\n * Error for network-related failures.\n *\n * Thrown when there is a problem establishing or maintaining a network\n * connection, such as DNS resolution failures, connection timeouts,\n * or network unreachability.\n */\nexport class NetworkError extends RelayTempMailError {\n code = 'NETWORK_ERROR' as const;\n\n constructor(message: string, response?: any) {\n super(message, 'NETWORK_ERROR', undefined, response);\n }\n}\n\n/**\n * Error for authentication and authorization failures.\n *\n * Thrown when API requests fail due to invalid or missing credentials\n * (401) or when the authenticated user lacks permission for the\n * requested operation (403).\n */\nexport class AuthError extends RelayTempMailError {\n code = 'AUTH_ERROR' as const;\n\n constructor(message: string, statusCode?: number, response?: any) {\n super(message, 'AUTH_ERROR', statusCode, response);\n }\n}\n\n/**\n * Error for resource not found errors.\n *\n * Thrown when the requested resource does not exist (404 response),\n * such as when trying to access a non-existent alias or email.\n */\nexport class NotFoundError extends RelayTempMailError {\n code = 'NOT_FOUND' as const;\n\n constructor(message: string, response?: any) {\n super(message, 'NOT_FOUND', 404, response);\n }\n}\n\n/**\n * Error for MIME message parsing failures.\n *\n * Thrown when there is an error parsing email MIME content,\n * such as malformed headers or invalid message structure.\n */\nexport class ParseError extends RelayTempMailError {\n code = 'PARSE_ERROR' as const;\n\n constructor(message: string, response?: any) {\n super(message, 'PARSE_ERROR', undefined, response);\n }\n}\n\n/**\n * Error for rate limiting responses.\n *\n * Thrown when the API rate limit has been exceeded (429 response).\n * The client should wait and retry the request after the indicated\n * cooldown period.\n */\nexport class RateLimitError extends RelayTempMailError {\n code = 'RATE_LIMIT_ERROR' as const;\n\n constructor(message: string, response?: any) {\n super(message, 'RATE_LIMIT_ERROR', 429, response);\n }\n}\n","import type { MailProvider, Email } from './types.js';\nimport { AuthError, NetworkError, NotFoundError, RateLimitError, RelayTempMailError } from './errors.js';\n\ninterface CFRawEmail {\n id: number;\n message_id: string;\n source: string;\n address: string;\n raw: string;\n metadata: any | null;\n created_at: string;\n}\n\ninterface CFRawResponse {\n results: CFRawEmail[];\n count: number;\n}\n\nexport class CFTempMailProvider implements MailProvider {\n private readonly apiUrl: string;\n private readonly token: string;\n private readonly httpClient: HttpClient;\n\n constructor(apiUrl: string, token: string, httpClient?: HttpClient) {\n this.apiUrl = apiUrl.replace(/\\/+$/, '');\n this.token = token;\n this.httpClient = httpClient ?? new DefaultHttpClient();\n }\n\n async getMails(limit: number = 20, offset: number = 0): Promise<Email[]> {\n const url = new URL(`${this.apiUrl}/api/mails`);\n url.searchParams.set('limit', String(limit));\n url.searchParams.set('offset', String(offset));\n\n const headers: Record<string, string> = {\n 'Authorization': `Bearer ${this.token}`,\n };\n\n try {\n const response = await this.httpClient.get(url.toString(), { headers });\n return this.mapCFResponse(response as CFRawResponse);\n } catch (error) {\n throw this.handleError(error);\n }\n }\n\n private mapCFResponse(response: CFRawResponse): Email[] {\n return response.results.map((item): Email => ({\n id: item.id,\n messageId: item.message_id,\n source: item.source,\n address: item.address,\n raw: item.raw,\n metadata: item.metadata,\n createdAt: item.created_at,\n }));\n }\n\n private handleError(error: unknown): RelayTempMailError {\n if (error instanceof RelayTempMailError) {\n const statusCode = error.statusCode;\n\n if (statusCode === 401 || statusCode === 403) {\n return new AuthError(error.message, statusCode, error.response);\n }\n if (statusCode === 404) {\n return new NotFoundError(error.message, error.response);\n }\n if (statusCode === 429) {\n return new RateLimitError(error.message, error.response);\n }\n\n return error;\n }\n\n if (error instanceof TypeError && error.message.includes('fetch')) {\n return new NetworkError(error.message);\n }\n\n if (error instanceof Error) {\n return new NetworkError(error.message);\n }\n\n return new RelayTempMailError(\n 'Unknown error occurred',\n 'UNKNOWN_ERROR',\n undefined,\n error\n );\n }\n}\n\n/** @deprecated Use CFTempMailProvider instead */\nexport const CFEmailClient = CFTempMailProvider;\n\nexport interface HttpClient {\n get(url: string, options?: { headers?: Record<string, string> }): Promise<unknown>;\n}\n\nexport class DefaultHttpClient implements HttpClient {\n async get(url: string, options?: { headers?: Record<string, string> }): Promise<unknown> {\n const response = await fetch(url, {\n method: 'GET',\n headers: options?.headers,\n });\n\n if (!response.ok) {\n const errorBody = await response.text();\n throw new RelayTempMailError(\n `HTTP ${response.status}: ${errorBody}`,\n 'HTTP_ERROR',\n response.status,\n errorBody\n );\n }\n\n return response.json();\n }\n}\n","/**\n * HTTP client utilities for the relay-temp-mail package.\n *\n * This module provides a configurable HTTP client with timeout support,\n * automatic retry logic, and proper error classification for API responses.\n */\n\nimport {\n RelayTempMailError,\n NetworkError,\n AuthError,\n NotFoundError,\n RateLimitError,\n} from './errors';\n\n/**\n * Options for individual HTTP requests.\n */\nexport interface RequestOptions {\n /** Custom headers to include in the request */\n headers?: Record<string, string>;\n\n /** Request body (will be JSON serialized) */\n body?: unknown;\n\n /** Request timeout in milliseconds (overrides client default) */\n timeout?: number;\n\n /** Number of retries on failure (overrides client default) */\n retries?: number;\n}\n\n/**\n * HTTP client for making requests to the relay-temp-mail API.\n *\n * Provides a configurable base URL with timeout, retry, and automatic\n * JSON parsing capabilities.\n */\nexport class HttpClient {\n private baseUrl: string;\n private defaultTimeout: number;\n private defaultRetries: number;\n\n /**\n * Creates a new HttpClient instance.\n *\n * @param baseUrl - Base URL for all requests (e.g., 'https://api.example.com')\n * @param defaultTimeout - Default timeout in milliseconds (default: 30000)\n * @param defaultRetries - Default number of retries on failure (default: 0)\n */\n constructor(\n baseUrl: string,\n defaultTimeout: number = 30000,\n defaultRetries: number = 0\n ) {\n this.baseUrl = baseUrl.replace(/\\/$/, ''); // Remove trailing slash\n this.defaultTimeout = defaultTimeout;\n this.defaultRetries = defaultRetries;\n }\n\n /**\n * Makes an HTTP request to the specified path.\n *\n * @param method - HTTP method (GET, POST, PUT, DELETE, etc.)\n * @param path - API path (will be appended to baseUrl)\n * @param options - Optional request configuration\n * @returns Promise resolving to the parsed JSON response\n */\n async request<T>(\n method: string,\n path: string,\n options: RequestOptions = {}\n ): Promise<T> {\n const timeout = options.timeout ?? this.defaultTimeout;\n const retries = options.retries ?? this.defaultRetries;\n\n let lastError: RelayTempMailError | Error | undefined;\n\n for (let attempt = 0; attempt <= retries; attempt++) {\n try {\n const response = await this.executeRequest(method, path, options, timeout);\n return await this.handleResponse<T>(response);\n } catch (error) {\n lastError = error as Error;\n\n // Check if we should retry\n if (attempt < retries && this.shouldRetry(error)) {\n const delay = 1000 * Math.pow(2, attempt);\n await this.sleep(delay);\n continue;\n }\n\n // Don't retry, throw the classified error\n if (error instanceof RelayTempMailError) {\n throw error;\n }\n\n // Classify the error if not already classified\n throw this.classifyError(error);\n }\n }\n\n // This should never be reached, but just in case\n throw lastError || new NetworkError('Request failed');\n }\n\n /**\n * Executes the actual HTTP request with timeout support.\n */\n private async executeRequest(\n method: string,\n path: string,\n options: RequestOptions,\n timeout: number\n ): Promise<Response> {\n const url = `${this.baseUrl}${path}`;\n\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), timeout);\n\n try {\n const fetchOptions: RequestInit = {\n method,\n headers: {\n 'Content-Type': 'application/json',\n ...options.headers,\n },\n signal: controller.signal,\n };\n\n if (options.body !== undefined) {\n fetchOptions.body = JSON.stringify(options.body);\n }\n\n const response = await fetch(url, fetchOptions);\n return response;\n } finally {\n clearTimeout(timeoutId);\n }\n }\n\n /**\n * Handles the HTTP response, parsing JSON and checking for errors.\n */\n private async handleResponse<T>(response: Response): Promise<T> {\n if (!response.ok) {\n throw this.classifyError(new Error(`HTTP ${response.status}`), response);\n }\n\n const text = await response.text();\n\n // Handle empty responses\n if (!text) {\n return {} as T;\n }\n\n return JSON.parse(text) as T;\n }\n\n /**\n * Classifies an error based on the error type and HTTP response.\n */\n private classifyError(error: unknown, response?: Response): RelayTempMailError {\n // Network errors (fetch failed)\n if (error instanceof Error && error.name === 'AbortError') {\n return new NetworkError('Request timed out');\n }\n\n if (error instanceof TypeError && error.message.includes('fetch')) {\n return new NetworkError('Network request failed');\n }\n\n if (error instanceof Error && error.message.includes('Failed to fetch')) {\n return new NetworkError('Network request failed');\n }\n\n // HTTP status-based classification\n if (response) {\n const status = response.status;\n\n if (status === 401 || status === 403) {\n return new AuthError(\n `Authentication failed: ${response.statusText}`,\n status\n );\n }\n\n if (status === 404) {\n return new NotFoundError(`Resource not found: ${response.statusText}`);\n }\n\n if (status === 429) {\n return new RateLimitError(\n `Rate limit exceeded: ${response.statusText}`\n );\n }\n\n if (status >= 500) {\n return new NetworkError(\n `Server error: ${response.statusText}`,\n status\n );\n }\n }\n\n // Default error\n if (error instanceof Error) {\n return new RelayTempMailError(\n error.message,\n 'REQUEST_ERROR',\n response?.status\n );\n }\n\n return new RelayTempMailError('Unknown error occurred', 'UNKNOWN_ERROR');\n }\n\n /**\n * Determines if a request should be retried based on the error.\n */\n private shouldRetry(error: unknown): boolean {\n if (error instanceof NetworkError) {\n return true;\n }\n\n if (error instanceof RelayTempMailError && error.statusCode) {\n return error.statusCode >= 500;\n }\n\n if (error instanceof Error) {\n if (error.name === 'AbortError') {\n return true;\n }\n if (error instanceof TypeError && error.message.includes('fetch')) {\n return true;\n }\n }\n\n return false;\n }\n\n /**\n * Sleep for a specified duration.\n */\n private sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n }\n}\n","import { HttpClient } from './http';\nimport { RelayTempMailError } from './errors';\nimport type { AliasProvider, RelayAlias, DuckDuckGoAliasStore } from './types';\n\ninterface DuckDuckGoCreateAddressResponse {\n address: string;\n}\n\nexport class InMemoryDuckDuckGoAliasStore implements DuckDuckGoAliasStore {\n private aliases: RelayAlias[] = [];\n\n getAll(): RelayAlias[] {\n return [...this.aliases];\n }\n\n add(alias: RelayAlias): void {\n this.aliases.push(alias);\n }\n\n remove(id: number): void {\n this.aliases = this.aliases.filter((a) => a.id !== id);\n }\n}\n\nexport class DuckDuckGoEmailProvider implements AliasProvider {\n private jwtToken: string;\n private httpClient: HttpClient;\n private store: DuckDuckGoAliasStore;\n private nextId: number;\n\n constructor(\n jwtToken: string,\n store?: DuckDuckGoAliasStore,\n httpClient?: HttpClient\n ) {\n this.jwtToken = jwtToken;\n this.store = store ?? new InMemoryDuckDuckGoAliasStore();\n this.httpClient =\n httpClient ?? new HttpClient('https://quack.duckduckgo.com');\n this.nextId = 1;\n }\n\n async listAliases(): Promise<RelayAlias[]> {\n return this.store.getAll();\n }\n\n async createAlias(): Promise<RelayAlias> {\n const response =\n await this.httpClient.request<DuckDuckGoCreateAddressResponse>(\n 'POST',\n '/api/email/addresses',\n {\n headers: {\n Authorization: `Bearer ${this.jwtToken}`,\n },\n }\n );\n\n const fullAddress = `${response.address}@duck.com`;\n\n const existing = await this.store.getAll();\n if (existing.some((a) => a.fullAddress === fullAddress)) {\n throw new RelayTempMailError(\n `DuckDuckGo returned a duplicate alias: ${fullAddress}`,\n 'DUPLICATE_ALIAS',\n 201\n );\n }\n\n const alias: RelayAlias = {\n id: this.nextId++,\n address: response.address,\n fullAddress,\n enabled: true,\n createdAt: new Date().toISOString(),\n domain: 3,\n maskType: 'random',\n };\n\n await this.store.add(alias);\n return alias;\n }\n\n async deleteAlias(id: number): Promise<void> {\n await this.store.remove(id);\n }\n}\n","/**\n * MIME email parser for extracting Firefox Relay alias information.\n */\nimport type { ParsedEmail } from './types.js';\n\nconst EMAIL_PATTERN = /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}/g;\nconst MOZMAIL_SUFFIX_PATTERN = /@mozmail\\.com$/i;\nconst DUCK_SUFFIX_PATTERN = /@duck\\.com$/i;\n// DuckDuckGo aliases are \"word-word-word@duck.com\"; the From header\n// uses \"sender_at_domain_alias@duck.com\" which EMAIL_PATTERN matches\n// as a single address. This pattern extracts just the alias portion.\nconst DUCK_ALIAS_PATTERN = /([a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)+@duck\\.com)/gi;\n// System addresses at @duck.com that are not user aliases\nconst DUCK_SYSTEM_ADDRESSES = new Set(['support@duck.com', 'noreply@duck.com']);\nconst ENCODED_WORD_PATTERN = /=\\?([^?]+)\\?([BbQq])\\?([^?]*)\\?=/g;\n\n/**\n * EmailParser class for parsing MIME email content.\n */\nexport class EmailParser {\n parseEmail(raw: string): ParsedEmail {\n const headers = this.parseHeaders(raw);\n const toHeader = headers.get('to') || '';\n const fromHeader = headers.get('from') || '';\n const messageIdHeader = headers.get('message-id') || '';\n const relayAlias = this.extractRelayAlias(raw);\n \n return {\n id: 0,\n messageId: this.extractMessageId(messageIdHeader),\n source: this.extractEmailAddress(fromHeader),\n address: this.extractEmailAddress(toHeader),\n raw,\n metadata: null,\n createdAt: new Date().toISOString(),\n relayAlias: relayAlias || undefined,\n };\n }\n\n extractRelayAlias(raw: string): string | null {\n try {\n const headers = this.parseHeaders(raw);\n\n // DuckDuckGo Email Protection adds a Duck-Original-To header\n // containing the @duck.com alias the email was forwarded to\n const duckOriginalTo = headers.get('duck-original-to');\n if (duckOriginalTo) {\n const duckAddress = this.extractEmailAddress(duckOriginalTo);\n if (duckAddress && DUCK_SUFFIX_PATTERN.test(duckAddress)) {\n return duckAddress;\n }\n }\n\n // Search the full raw content for @duck.com addresses.\n // Duck-Original-To may be stripped during forwarding,\n // but the alias address often appears in From headers as\n // \"sender_at_domain_alias@duck.com\" or elsewhere in the MIME.\n // First try the precise pattern (hyphenated aliases like word-word-word@duck.com)\n const duckMatches = raw.match(DUCK_ALIAS_PATTERN);\n if (duckMatches && duckMatches.length > 0) {\n return duckMatches[0].toLowerCase();\n }\n // Fallback: search with broader EMAIL_PATTERN and filter for @duck.com,\n // excluding known system addresses like support@duck.com\n const rawEmails = raw.match(EMAIL_PATTERN) ?? [];\n const duckFallback = rawEmails.find(\n (e) => DUCK_SUFFIX_PATTERN.test(e) && !DUCK_SYSTEM_ADDRESSES.has(e.toLowerCase())\n );\n if (duckFallback) return duckFallback.toLowerCase();\n\n const fromAddresses = this.extractHeaderEmails(headers.get('from'));\n const toAddresses = this.extractHeaderEmails(headers.get('to'));\n const allAddresses = [...fromAddresses, ...toAddresses];\n\n const mozmailAddress = allAddresses.find((address) =>\n MOZMAIL_SUFFIX_PATTERN.test(address)\n );\n if (mozmailAddress) return mozmailAddress;\n\n return toAddresses[0] ?? null;\n } catch {\n return null;\n }\n }\n\n private parseHeaders(raw: string): Map<string, string> {\n const headers = new Map<string, string>();\n const headerEnd = raw.indexOf('\\r\\n\\r\\n');\n const headerSection = headerEnd === -1 ? raw : raw.substring(0, headerEnd);\n const lines = headerSection.split(/\\r?\\n/);\n let currentHeader: string | null = null;\n let currentValue = '';\n \n for (const line of lines) {\n if (/^\\s/.test(line)) {\n if (currentHeader) currentValue += ' ' + line.trim();\n } else {\n if (currentHeader) headers.set(currentHeader, currentValue);\n const colonIndex = line.indexOf(':');\n if (colonIndex > 0) {\n currentHeader = line.substring(0, colonIndex).toLowerCase().trim();\n currentValue = line.substring(colonIndex + 1).trim();\n } else {\n currentHeader = null;\n currentValue = '';\n }\n }\n }\n if (currentHeader) headers.set(currentHeader, currentValue);\n return headers;\n }\n\n private decodeHeader(value: string): string {\n return value.replace(ENCODED_WORD_PATTERN, (_, charset, encoding, encoded) => {\n try {\n if (encoding.toUpperCase() === 'Q') {\n return this.decodeQuotedPrintable(encoded);\n } else if (encoding.toUpperCase() === 'B') {\n return this.decodeBase64(encoded);\n }\n return encoded;\n } catch {\n return encoded;\n }\n });\n }\n\n private decodeQuotedPrintable(encoded: string): string {\n // RFC 2047: underscores represent spaces in encoded-word\n let decoded = encoded.replace(/_/g, ' ');\n decoded = decoded.replace(/=([0-9A-Fa-f]{2})/g, (_, hex) => \n String.fromCharCode(parseInt(hex, 16))\n );\n return decoded;\n }\n\n private decodeBase64(encoded: string): string {\n return Buffer.from(encoded, 'base64').toString('utf-8');\n }\n\n private extractEmailAddress(headerValue: string): string {\n if (!headerValue) return '';\n const decoded = this.decodeHeader(headerValue);\n const bracketMatch = decoded.match(/<([^>]+)>/);\n if (bracketMatch) return bracketMatch[1].trim().toLowerCase();\n const emailMatch = decoded.match(/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}/);\n return emailMatch ? emailMatch[0].toLowerCase() : decoded.trim().toLowerCase();\n }\n\n private extractHeaderEmails(headerValue?: string): string[] {\n if (!headerValue) return [];\n const decoded = this.decodeHeader(headerValue);\n const matches = decoded.match(EMAIL_PATTERN);\n return matches ? matches.map((match) => match.toLowerCase()) : [];\n }\n\n private extractMessageId(headerValue: string): string {\n if (!headerValue) return `<generated-${Date.now()}@relay-temp-mail>`;\n const cleaned = headerValue.replace(/[<>]/g, '').trim();\n return `<${cleaned}>`;\n }\n}\n","import { HttpClient } from './http';\nimport type { AliasProvider, RelayAlias } from './types';\n\ninterface RawAliasResponse {\n id: number;\n address: string;\n full_address: string;\n enabled: boolean;\n created_at: string;\n domain: number;\n mask_type: string;\n description?: string;\n num_forwarded?: number;\n num_blocked?: number;\n last_modified_at?: string;\n last_used_at?: string | null;\n num_level_one_trackers_blocked?: number;\n num_replied?: number;\n num_spam?: number;\n block_list_emails?: boolean;\n generated_for?: string;\n used_on?: string | null;\n}\n\nexport class FirefoxRelayProvider implements AliasProvider {\n private csrfToken: string;\n private sessionId: string;\n private httpClient: HttpClient;\n\n constructor(\n csrfToken: string,\n sessionId: string,\n httpClient?: HttpClient\n ) {\n this.csrfToken = csrfToken;\n this.sessionId = sessionId;\n this.httpClient = httpClient ?? new HttpClient('https://relay.firefox.com');\n }\n\n private getAuthHeaders(): Record<string, string> {\n return {\n 'Origin': 'https://relay.firefox.com',\n 'Referer': 'https://relay.firefox.com/accounts/profile/?',\n 'Accept': 'application/json',\n 'X-CSRFToken': this.csrfToken,\n 'Cookie': `sessionid=${this.sessionId}; csrftoken=${this.csrfToken}`,\n };\n }\n\n async listAliases(): Promise<RelayAlias[]> {\n const response = await this.httpClient.request<RawAliasResponse[]>(\n 'GET',\n '/api/v1/relayaddresses/',\n { headers: this.getAuthHeaders() }\n );\n\n return response.map((item) => this.mapAliasResponse(item));\n }\n\n async createAlias(): Promise<RelayAlias> {\n const response = await this.httpClient.request<RawAliasResponse>(\n 'POST',\n '/api/v1/relayaddresses/',\n {\n headers: this.getAuthHeaders(),\n body: { enabled: true },\n }\n );\n\n return this.mapAliasResponse(response);\n }\n\n async deleteAlias(id: number): Promise<void> {\n await this.httpClient.request<void>(\n 'DELETE',\n `/api/v1/relayaddresses/${id}/`,\n { headers: this.getAuthHeaders() }\n );\n }\n\n private mapAliasResponse(data: RawAliasResponse): RelayAlias {\n return {\n id: data.id,\n address: data.address,\n fullAddress: data.full_address,\n enabled: data.enabled,\n createdAt: data.created_at,\n domain: data.domain,\n maskType: data.mask_type,\n description: data.description,\n numForwarded: data.num_forwarded,\n numBlocked: data.num_blocked,\n lastModifiedAt: data.last_modified_at,\n lastUsedAt: data.last_used_at,\n numLevelOneTrackersBlocked: data.num_level_one_trackers_blocked,\n numReplied: data.num_replied,\n numSpam: data.num_spam,\n blockListEmails: data.block_list_emails,\n generatedFor: data.generated_for,\n usedOn: data.used_on,\n };\n }\n}\n\n/** @deprecated Use FirefoxRelayProvider instead */\nexport const RelayAPIClient = FirefoxRelayProvider;\n","import { CFTempMailProvider, DefaultHttpClient } from './cf-api.js';\nimport { DuckDuckGoEmailProvider } from './duckduckgo-api.js';\nimport { EmailParser } from './parser.js';\nimport { FirefoxRelayProvider } from './relay-api.js';\nimport { HttpClient } from './http.js';\nimport type {\n TempMailConfig,\n RelayConfig,\n AliasProvider,\n MailProvider,\n RelayAlias,\n ParsedEmail,\n GetEmailsOptions,\n} from './types.js';\n\nfunction createAliasProvider(config: TempMailConfig, httpClient: HttpClient): AliasProvider {\n const aliasConfig = config.aliasProvider;\n switch (aliasConfig.type) {\n case 'firefox-relay':\n return new FirefoxRelayProvider(\n aliasConfig.csrfToken,\n aliasConfig.sessionId,\n httpClient\n );\n case 'duckduckgo-email':\n return new DuckDuckGoEmailProvider(\n aliasConfig.jwtToken,\n aliasConfig.store\n );\n }\n}\n\nfunction createMailProvider(config: TempMailConfig): MailProvider {\n const mailConfig = config.mailProvider;\n switch (mailConfig.type) {\n case 'cf-temp-mail':\n return new CFTempMailProvider(\n mailConfig.apiUrl,\n mailConfig.token\n );\n }\n}\n\nexport class TempMailClient {\n private readonly aliasProvider: AliasProvider;\n private readonly mailProvider: MailProvider;\n private readonly parser: EmailParser;\n\n constructor(config: TempMailConfig) {\n const timeout = config.timeout ?? 30000;\n const httpClient = new HttpClient('https://relay.firefox.com', timeout);\n this.aliasProvider = createAliasProvider(config, httpClient);\n this.mailProvider = createMailProvider(config);\n this.parser = new EmailParser();\n }\n\n async listAliases(): Promise<RelayAlias[]> {\n return this.aliasProvider.listAliases();\n }\n\n async createAlias(): Promise<RelayAlias> {\n return this.aliasProvider.createAlias();\n }\n\n async deleteAlias(id: number): Promise<void> {\n return this.aliasProvider.deleteAlias(id);\n }\n\n async getEmails(\n aliasAddress?: string,\n options?: GetEmailsOptions\n ): Promise<ParsedEmail[]> {\n const limit = options?.limit ?? 20;\n const offset = options?.offset ?? 0;\n\n const emails = await this.mailProvider.getMails(limit, offset);\n\n const parsedEmails: ParsedEmail[] = emails.map((email) => {\n const parsed = this.parser.parseEmail(email.raw);\n return {\n ...parsed,\n id: email.id,\n messageId: email.messageId,\n source: email.source,\n address: email.address,\n createdAt: email.createdAt,\n metadata: email.metadata,\n };\n });\n\n if (aliasAddress) {\n const normalizedAlias = aliasAddress.toLowerCase();\n return parsedEmails.filter(\n (email) =>\n email.relayAlias?.toLowerCase() === normalizedAlias ||\n email.address.toLowerCase() === normalizedAlias\n );\n }\n\n return parsedEmails;\n }\n}\n\n/** @deprecated Use TempMailClient instead */\nexport const RelayClient = TempMailClient;\n"],"mappings":";AAcO,IAAM,qBAAN,cAAiC,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAyB5C,YACE,SACA,MACA,YACA,UACA;AACA,UAAM,OAAO;AACb,SAAK,OAAO,KAAK,YAAY;AAC7B,SAAK,OAAO;AACZ,SAAK,aAAa;AAClB,SAAK,WAAW;AAGhB,QAAI,MAAM,mBAAmB;AAC3B,YAAM,kBAAkB,MAAM,KAAK,WAAW;AAAA,IAChD;AAAA,EACF;AACF;AASO,IAAM,eAAN,cAA2B,mBAAmB;AAAA,EAGnD,YAAY,SAAiB,UAAgB;AAC3C,UAAM,SAAS,iBAAiB,QAAW,QAAQ;AAHrD,gBAAO;AAAA,EAIP;AACF;AASO,IAAM,YAAN,cAAwB,mBAAmB;AAAA,EAGhD,YAAY,SAAiB,YAAqB,UAAgB;AAChE,UAAM,SAAS,cAAc,YAAY,QAAQ;AAHnD,gBAAO;AAAA,EAIP;AACF;AAQO,IAAM,gBAAN,cAA4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AAa;AAAA,QAClB,CAAC,UACC,MAAM,YAAY,YAAY,MAAM,mBACpC,MAAM,QAAQ,YAAY,MAAM;AAAA,MACpC;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AACF;AAGO,IAAM,cAAc;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts","../src/cf-api.ts","../src/http.ts","../src/duckduckgo-api.ts","../src/parser.ts","../src/relay-api.ts","../src/client.ts"],"sourcesContent":["/**\n * Custom error classes for the relay-temp-mail package.\n *\n * These errors provide structured error information including error codes,\n * HTTP status codes, and response data for better error handling.\n */\n\n/**\n * Base error class for all relay-temp-mail errors.\n *\n * Extends the built-in Error class with additional context about the error,\n * including an error code for programmatic error handling and optional\n * response data from the API.\n */\nexport class RelayTempMailError extends Error {\n /**\n * Machine-readable error code for programmatic error handling.\n * Examples: 'NETWORK_ERROR', 'AUTH_ERROR', 'NOT_FOUND'\n */\n code: string;\n\n /**\n * HTTP status code associated with this error, if applicable.\n */\n statusCode?: number;\n\n /**\n * Raw response data from the API, if available.\n */\n response?: any;\n\n /**\n * Creates a new RelayTempMailError instance.\n *\n * @param message - Human-readable error message describing the error.\n * @param code - Machine-readable error code (e.g., 'UNKNOWN_ERROR').\n * @param statusCode - Optional HTTP status code associated with the error.\n * @param response - Optional raw response data from the API.\n */\n constructor(\n message: string,\n code: string,\n statusCode?: number,\n response?: any\n ) {\n super(message);\n this.name = this.constructor.name;\n this.code = code;\n this.statusCode = statusCode;\n this.response = response;\n\n // Maintains proper stack trace in V8 environments\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, this.constructor);\n }\n }\n}\n\n/**\n * Error for network-related failures.\n *\n * Thrown when there is a problem establishing or maintaining a network\n * connection, such as DNS resolution failures, connection timeouts,\n * or network unreachability.\n */\nexport class NetworkError extends RelayTempMailError {\n code = 'NETWORK_ERROR' as const;\n\n constructor(message: string, response?: any) {\n super(message, 'NETWORK_ERROR', undefined, response);\n }\n}\n\n/**\n * Error for authentication and authorization failures.\n *\n * Thrown when API requests fail due to invalid or missing credentials\n * (401) or when the authenticated user lacks permission for the\n * requested operation (403).\n */\nexport class AuthError extends RelayTempMailError {\n code = 'AUTH_ERROR' as const;\n\n constructor(message: string, statusCode?: number, response?: any) {\n super(message, 'AUTH_ERROR', statusCode, response);\n }\n}\n\n/**\n * Error for resource not found errors.\n *\n * Thrown when the requested resource does not exist (404 response),\n * such as when trying to access a non-existent alias or email.\n */\nexport class NotFoundError extends RelayTempMailError {\n code = 'NOT_FOUND' as const;\n\n constructor(message: string, response?: any) {\n super(message, 'NOT_FOUND', 404, response);\n }\n}\n\n/**\n * Error for MIME message parsing failures.\n *\n * Thrown when there is an error parsing email MIME content,\n * such as malformed headers or invalid message structure.\n */\nexport class ParseError extends RelayTempMailError {\n code = 'PARSE_ERROR' as const;\n\n constructor(message: string, response?: any) {\n super(message, 'PARSE_ERROR', undefined, response);\n }\n}\n\n/**\n * Error for rate limiting responses.\n *\n * Thrown when the API rate limit has been exceeded (429 response).\n * The client should wait and retry the request after the indicated\n * cooldown period.\n */\nexport class RateLimitError extends RelayTempMailError {\n code = 'RATE_LIMIT_ERROR' as const;\n\n constructor(message: string, response?: any) {\n super(message, 'RATE_LIMIT_ERROR', 429, response);\n }\n}\n","import type { MailProvider, Email } from './types.js';\nimport { AuthError, NetworkError, NotFoundError, RateLimitError, RelayTempMailError } from './errors.js';\n\ninterface CFRawEmail {\n id: number;\n message_id: string;\n source: string;\n address: string;\n raw: string;\n metadata: any | null;\n created_at: string;\n}\n\ninterface CFRawResponse {\n results: CFRawEmail[];\n count: number;\n}\n\nexport class CFTempMailProvider implements MailProvider {\n private readonly apiUrl: string;\n private readonly token: string;\n private readonly httpClient: HttpClient;\n\n constructor(apiUrl: string, token: string, httpClient?: HttpClient) {\n this.apiUrl = apiUrl.replace(/\\/+$/, '');\n this.token = token;\n this.httpClient = httpClient ?? new DefaultHttpClient();\n }\n\n async getMails(limit: number = 20, offset: number = 0): Promise<Email[]> {\n const url = new URL(`${this.apiUrl}/api/mails`);\n url.searchParams.set('limit', String(limit));\n url.searchParams.set('offset', String(offset));\n\n const headers: Record<string, string> = {\n 'Authorization': `Bearer ${this.token}`,\n };\n\n try {\n const response = await this.httpClient.get(url.toString(), { headers });\n return this.mapCFResponse(response as CFRawResponse);\n } catch (error) {\n throw this.handleError(error);\n }\n }\n\n private mapCFResponse(response: CFRawResponse): Email[] {\n return response.results.map((item): Email => ({\n id: item.id,\n messageId: item.message_id,\n source: item.source,\n address: item.address,\n raw: item.raw,\n metadata: item.metadata,\n createdAt: item.created_at,\n }));\n }\n\n private handleError(error: unknown): RelayTempMailError {\n if (error instanceof RelayTempMailError) {\n const statusCode = error.statusCode;\n\n if (statusCode === 401 || statusCode === 403) {\n return new AuthError(error.message, statusCode, error.response);\n }\n if (statusCode === 404) {\n return new NotFoundError(error.message, error.response);\n }\n if (statusCode === 429) {\n return new RateLimitError(error.message, error.response);\n }\n\n return error;\n }\n\n if (error instanceof TypeError && error.message.includes('fetch')) {\n return new NetworkError(error.message);\n }\n\n if (error instanceof Error) {\n return new NetworkError(error.message);\n }\n\n return new RelayTempMailError(\n 'Unknown error occurred',\n 'UNKNOWN_ERROR',\n undefined,\n error\n );\n }\n}\n\n/** @deprecated Use CFTempMailProvider instead */\nexport const CFEmailClient = CFTempMailProvider;\n\nexport interface HttpClient {\n get(url: string, options?: { headers?: Record<string, string> }): Promise<unknown>;\n}\n\nexport class DefaultHttpClient implements HttpClient {\n async get(url: string, options?: { headers?: Record<string, string> }): Promise<unknown> {\n const response = await fetch(url, {\n method: 'GET',\n headers: options?.headers,\n });\n\n if (!response.ok) {\n const errorBody = await response.text();\n throw new RelayTempMailError(\n `HTTP ${response.status}: ${errorBody}`,\n 'HTTP_ERROR',\n response.status,\n errorBody\n );\n }\n\n return response.json();\n }\n}\n","/**\n * HTTP client utilities for the relay-temp-mail package.\n *\n * This module provides a configurable HTTP client with timeout support,\n * automatic retry logic, and proper error classification for API responses.\n */\n\nimport {\n RelayTempMailError,\n NetworkError,\n AuthError,\n NotFoundError,\n RateLimitError,\n} from './errors';\n\n/**\n * Options for individual HTTP requests.\n */\nexport interface RequestOptions {\n /** Custom headers to include in the request */\n headers?: Record<string, string>;\n\n /** Request body (will be JSON serialized) */\n body?: unknown;\n\n /** Request timeout in milliseconds (overrides client default) */\n timeout?: number;\n\n /** Number of retries on failure (overrides client default) */\n retries?: number;\n}\n\n/**\n * HTTP client for making requests to the relay-temp-mail API.\n *\n * Provides a configurable base URL with timeout, retry, and automatic\n * JSON parsing capabilities.\n */\nexport class HttpClient {\n private baseUrl: string;\n private defaultTimeout: number;\n private defaultRetries: number;\n\n /**\n * Creates a new HttpClient instance.\n *\n * @param baseUrl - Base URL for all requests (e.g., 'https://api.example.com')\n * @param defaultTimeout - Default timeout in milliseconds (default: 30000)\n * @param defaultRetries - Default number of retries on failure (default: 0)\n */\n constructor(\n baseUrl: string,\n defaultTimeout: number = 30000,\n defaultRetries: number = 0\n ) {\n this.baseUrl = baseUrl.replace(/\\/$/, ''); // Remove trailing slash\n this.defaultTimeout = defaultTimeout;\n this.defaultRetries = defaultRetries;\n }\n\n /**\n * Makes an HTTP request to the specified path.\n *\n * @param method - HTTP method (GET, POST, PUT, DELETE, etc.)\n * @param path - API path (will be appended to baseUrl)\n * @param options - Optional request configuration\n * @returns Promise resolving to the parsed JSON response\n */\n async request<T>(\n method: string,\n path: string,\n options: RequestOptions = {}\n ): Promise<T> {\n const timeout = options.timeout ?? this.defaultTimeout;\n const retries = options.retries ?? this.defaultRetries;\n\n let lastError: RelayTempMailError | Error | undefined;\n\n for (let attempt = 0; attempt <= retries; attempt++) {\n try {\n const response = await this.executeRequest(method, path, options, timeout);\n return await this.handleResponse<T>(response);\n } catch (error) {\n lastError = error as Error;\n\n // Check if we should retry\n if (attempt < retries && this.shouldRetry(error)) {\n const delay = 1000 * Math.pow(2, attempt);\n await this.sleep(delay);\n continue;\n }\n\n // Don't retry, throw the classified error\n if (error instanceof RelayTempMailError) {\n throw error;\n }\n\n // Classify the error if not already classified\n throw this.classifyError(error);\n }\n }\n\n // This should never be reached, but just in case\n throw lastError || new NetworkError('Request failed');\n }\n\n /**\n * Executes the actual HTTP request with timeout support.\n */\n private async executeRequest(\n method: string,\n path: string,\n options: RequestOptions,\n timeout: number\n ): Promise<Response> {\n const url = `${this.baseUrl}${path}`;\n\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), timeout);\n\n try {\n const fetchOptions: RequestInit = {\n method,\n headers: {\n 'Content-Type': 'application/json',\n ...options.headers,\n },\n signal: controller.signal,\n };\n\n if (options.body !== undefined) {\n fetchOptions.body = JSON.stringify(options.body);\n }\n\n const response = await fetch(url, fetchOptions);\n return response;\n } finally {\n clearTimeout(timeoutId);\n }\n }\n\n /**\n * Handles the HTTP response, parsing JSON and checking for errors.\n */\n private async handleResponse<T>(response: Response): Promise<T> {\n if (!response.ok) {\n throw this.classifyError(new Error(`HTTP ${response.status}`), response);\n }\n\n const text = await response.text();\n\n // Handle empty responses\n if (!text) {\n return {} as T;\n }\n\n return JSON.parse(text) as T;\n }\n\n /**\n * Classifies an error based on the error type and HTTP response.\n */\n private classifyError(error: unknown, response?: Response): RelayTempMailError {\n // Network errors (fetch failed)\n if (error instanceof Error && error.name === 'AbortError') {\n return new NetworkError('Request timed out');\n }\n\n if (error instanceof TypeError && error.message.includes('fetch')) {\n return new NetworkError('Network request failed');\n }\n\n if (error instanceof Error && error.message.includes('Failed to fetch')) {\n return new NetworkError('Network request failed');\n }\n\n // HTTP status-based classification\n if (response) {\n const status = response.status;\n\n if (status === 401 || status === 403) {\n return new AuthError(\n `Authentication failed: ${response.statusText}`,\n status\n );\n }\n\n if (status === 404) {\n return new NotFoundError(`Resource not found: ${response.statusText}`);\n }\n\n if (status === 429) {\n return new RateLimitError(\n `Rate limit exceeded: ${response.statusText}`\n );\n }\n\n if (status >= 500) {\n return new NetworkError(\n `Server error: ${response.statusText}`,\n status\n );\n }\n }\n\n // Default error\n if (error instanceof Error) {\n return new RelayTempMailError(\n error.message,\n 'REQUEST_ERROR',\n response?.status\n );\n }\n\n return new RelayTempMailError('Unknown error occurred', 'UNKNOWN_ERROR');\n }\n\n /**\n * Determines if a request should be retried based on the error.\n */\n private shouldRetry(error: unknown): boolean {\n if (error instanceof NetworkError) {\n return true;\n }\n\n if (error instanceof RelayTempMailError && error.statusCode) {\n return error.statusCode >= 500;\n }\n\n if (error instanceof Error) {\n if (error.name === 'AbortError') {\n return true;\n }\n if (error instanceof TypeError && error.message.includes('fetch')) {\n return true;\n }\n }\n\n return false;\n }\n\n /**\n * Sleep for a specified duration.\n */\n private sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n }\n}\n","import { HttpClient } from './http';\nimport { RelayTempMailError } from './errors';\nimport type { AliasProvider, RelayAlias, DuckDuckGoAliasStore } from './types';\n\ninterface DuckDuckGoCreateAddressResponse {\n address: string;\n}\n\nexport class InMemoryDuckDuckGoAliasStore implements DuckDuckGoAliasStore {\n private aliases: RelayAlias[] = [];\n\n getAll(): RelayAlias[] {\n return [...this.aliases];\n }\n\n add(alias: RelayAlias): void {\n this.aliases.push(alias);\n }\n\n remove(id: number): void {\n this.aliases = this.aliases.filter((a) => a.id !== id);\n }\n}\n\nexport class DuckDuckGoEmailProvider implements AliasProvider {\n private jwtToken: string;\n private httpClient: HttpClient;\n private store: DuckDuckGoAliasStore;\n private nextId: number;\n\n constructor(\n jwtToken: string,\n store?: DuckDuckGoAliasStore,\n httpClient?: HttpClient\n ) {\n this.jwtToken = jwtToken;\n this.store = store ?? new InMemoryDuckDuckGoAliasStore();\n this.httpClient =\n httpClient ?? new HttpClient('https://quack.duckduckgo.com');\n this.nextId = 1;\n }\n\n async listAliases(): Promise<RelayAlias[]> {\n return this.store.getAll();\n }\n\n async createAlias(): Promise<RelayAlias> {\n const response =\n await this.httpClient.request<DuckDuckGoCreateAddressResponse>(\n 'POST',\n '/api/email/addresses',\n {\n headers: {\n Authorization: `Bearer ${this.jwtToken}`,\n },\n }\n );\n\n const fullAddress = `${response.address}@duck.com`;\n\n const existing = await this.store.getAll();\n if (existing.some((a) => a.fullAddress === fullAddress)) {\n throw new RelayTempMailError(\n `DuckDuckGo returned a duplicate alias: ${fullAddress}`,\n 'DUPLICATE_ALIAS',\n 201\n );\n }\n\n const alias: RelayAlias = {\n id: this.nextId++,\n address: response.address,\n fullAddress,\n enabled: true,\n createdAt: new Date().toISOString(),\n domain: 3,\n maskType: 'random',\n };\n\n await this.store.add(alias);\n return alias;\n }\n\n async deleteAlias(id: number): Promise<void> {\n await this.store.remove(id);\n }\n}\n","/**\n * MIME email parser for extracting Firefox Relay alias information.\n */\nimport type { ParsedEmail } from './types.js';\n\nconst EMAIL_PATTERN = /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}/g;\nconst MOZMAIL_SUFFIX_PATTERN = /@mozmail\\.com$/i;\nconst ENCODED_WORD_PATTERN = /=\\?([^?]+)\\?([BbQq])\\?([^?]*)\\?=/g;\n\n/**\n * EmailParser class for parsing MIME email content.\n */\nexport class EmailParser {\n parseEmail(raw: string): ParsedEmail {\n const headers = this.parseHeaders(raw);\n const toHeader = headers.get('to') || '';\n const fromHeader = headers.get('from') || '';\n const messageIdHeader = headers.get('message-id') || '';\n const relayAlias = this.extractRelayAlias(raw);\n \n return {\n id: 0,\n messageId: this.extractMessageId(messageIdHeader),\n source: this.extractEmailAddress(fromHeader),\n address: this.extractEmailAddress(toHeader),\n raw,\n metadata: null,\n createdAt: new Date().toISOString(),\n relayAlias: relayAlias || undefined,\n };\n }\n\n extractRelayAlias(raw: string): string | null {\n try {\n const headers = this.parseHeaders(raw);\n const fromAddresses = this.extractHeaderEmails(headers.get('from'));\n const toAddresses = this.extractHeaderEmails(headers.get('to'));\n const allAddresses = [...fromAddresses, ...toAddresses];\n\n const mozmailAddress = allAddresses.find((address) =>\n MOZMAIL_SUFFIX_PATTERN.test(address)\n );\n if (mozmailAddress) return mozmailAddress;\n\n return toAddresses[0] ?? null;\n } catch {\n return null;\n }\n }\n\n private parseHeaders(raw: string): Map<string, string> {\n const headers = new Map<string, string>();\n const headerEnd = raw.indexOf('\\r\\n\\r\\n');\n const headerSection = headerEnd === -1 ? raw : raw.substring(0, headerEnd);\n const lines = headerSection.split(/\\r?\\n/);\n let currentHeader: string | null = null;\n let currentValue = '';\n \n for (const line of lines) {\n if (/^\\s/.test(line)) {\n if (currentHeader) currentValue += ' ' + line.trim();\n } else {\n if (currentHeader) headers.set(currentHeader, currentValue);\n const colonIndex = line.indexOf(':');\n if (colonIndex > 0) {\n currentHeader = line.substring(0, colonIndex).toLowerCase().trim();\n currentValue = line.substring(colonIndex + 1).trim();\n } else {\n currentHeader = null;\n currentValue = '';\n }\n }\n }\n if (currentHeader) headers.set(currentHeader, currentValue);\n return headers;\n }\n\n private decodeHeader(value: string): string {\n return value.replace(ENCODED_WORD_PATTERN, (_, charset, encoding, encoded) => {\n try {\n if (encoding.toUpperCase() === 'Q') {\n return this.decodeQuotedPrintable(encoded);\n } else if (encoding.toUpperCase() === 'B') {\n return this.decodeBase64(encoded);\n }\n return encoded;\n } catch {\n return encoded;\n }\n });\n }\n\n private decodeQuotedPrintable(encoded: string): string {\n // RFC 2047: underscores represent spaces in encoded-word\n let decoded = encoded.replace(/_/g, ' ');\n decoded = decoded.replace(/=([0-9A-Fa-f]{2})/g, (_, hex) => \n String.fromCharCode(parseInt(hex, 16))\n );\n return decoded;\n }\n\n private decodeBase64(encoded: string): string {\n return Buffer.from(encoded, 'base64').toString('utf-8');\n }\n\n private extractEmailAddress(headerValue: string): string {\n if (!headerValue) return '';\n const decoded = this.decodeHeader(headerValue);\n const bracketMatch = decoded.match(/<([^>]+)>/);\n if (bracketMatch) return bracketMatch[1].trim().toLowerCase();\n const emailMatch = decoded.match(/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}/);\n return emailMatch ? emailMatch[0].toLowerCase() : decoded.trim().toLowerCase();\n }\n\n private extractHeaderEmails(headerValue?: string): string[] {\n if (!headerValue) return [];\n const decoded = this.decodeHeader(headerValue);\n const matches = decoded.match(EMAIL_PATTERN);\n return matches ? matches.map((match) => match.toLowerCase()) : [];\n }\n\n private extractMessageId(headerValue: string): string {\n if (!headerValue) return `<generated-${Date.now()}@relay-temp-mail>`;\n const cleaned = headerValue.replace(/[<>]/g, '').trim();\n return `<${cleaned}>`;\n }\n}\n","import { HttpClient } from './http';\nimport type { AliasProvider, RelayAlias } from './types';\n\ninterface RawAliasResponse {\n id: number;\n address: string;\n full_address: string;\n enabled: boolean;\n created_at: string;\n domain: number;\n mask_type: string;\n description?: string;\n num_forwarded?: number;\n num_blocked?: number;\n last_modified_at?: string;\n last_used_at?: string | null;\n num_level_one_trackers_blocked?: number;\n num_replied?: number;\n num_spam?: number;\n block_list_emails?: boolean;\n generated_for?: string;\n used_on?: string | null;\n}\n\nexport class FirefoxRelayProvider implements AliasProvider {\n private csrfToken: string;\n private sessionId: string;\n private httpClient: HttpClient;\n\n constructor(\n csrfToken: string,\n sessionId: string,\n httpClient?: HttpClient\n ) {\n this.csrfToken = csrfToken;\n this.sessionId = sessionId;\n this.httpClient = httpClient ?? new HttpClient('https://relay.firefox.com');\n }\n\n private getAuthHeaders(): Record<string, string> {\n return {\n 'Origin': 'https://relay.firefox.com',\n 'Referer': 'https://relay.firefox.com/accounts/profile/?',\n 'Accept': 'application/json',\n 'X-CSRFToken': this.csrfToken,\n 'Cookie': `sessionid=${this.sessionId}; csrftoken=${this.csrfToken}`,\n };\n }\n\n async listAliases(): Promise<RelayAlias[]> {\n const response = await this.httpClient.request<RawAliasResponse[]>(\n 'GET',\n '/api/v1/relayaddresses/',\n { headers: this.getAuthHeaders() }\n );\n\n return response.map((item) => this.mapAliasResponse(item));\n }\n\n async createAlias(): Promise<RelayAlias> {\n const response = await this.httpClient.request<RawAliasResponse>(\n 'POST',\n '/api/v1/relayaddresses/',\n {\n headers: this.getAuthHeaders(),\n body: { enabled: true },\n }\n );\n\n return this.mapAliasResponse(response);\n }\n\n async deleteAlias(id: number): Promise<void> {\n await this.httpClient.request<void>(\n 'DELETE',\n `/api/v1/relayaddresses/${id}/`,\n { headers: this.getAuthHeaders() }\n );\n }\n\n private mapAliasResponse(data: RawAliasResponse): RelayAlias {\n return {\n id: data.id,\n address: data.address,\n fullAddress: data.full_address,\n enabled: data.enabled,\n createdAt: data.created_at,\n domain: data.domain,\n maskType: data.mask_type,\n description: data.description,\n numForwarded: data.num_forwarded,\n numBlocked: data.num_blocked,\n lastModifiedAt: data.last_modified_at,\n lastUsedAt: data.last_used_at,\n numLevelOneTrackersBlocked: data.num_level_one_trackers_blocked,\n numReplied: data.num_replied,\n numSpam: data.num_spam,\n blockListEmails: data.block_list_emails,\n generatedFor: data.generated_for,\n usedOn: data.used_on,\n };\n }\n}\n\n/** @deprecated Use FirefoxRelayProvider instead */\nexport const RelayAPIClient = FirefoxRelayProvider;\n","import { CFTempMailProvider, DefaultHttpClient } from './cf-api.js';\nimport { DuckDuckGoEmailProvider } from './duckduckgo-api.js';\nimport { EmailParser } from './parser.js';\nimport { FirefoxRelayProvider } from './relay-api.js';\nimport { HttpClient } from './http.js';\nimport type {\n TempMailConfig,\n RelayConfig,\n AliasProvider,\n MailProvider,\n RelayAlias,\n ParsedEmail,\n GetEmailsOptions,\n} from './types.js';\n\nfunction createAliasProvider(config: TempMailConfig, httpClient: HttpClient): AliasProvider {\n const aliasConfig = config.aliasProvider;\n switch (aliasConfig.type) {\n case 'firefox-relay':\n return new FirefoxRelayProvider(\n aliasConfig.csrfToken,\n aliasConfig.sessionId,\n httpClient\n );\n case 'duckduckgo-email':\n return new DuckDuckGoEmailProvider(\n aliasConfig.jwtToken,\n aliasConfig.store\n );\n }\n}\n\nfunction createMailProvider(config: TempMailConfig): MailProvider {\n const mailConfig = config.mailProvider;\n switch (mailConfig.type) {\n case 'cf-temp-mail':\n return new CFTempMailProvider(\n mailConfig.apiUrl,\n mailConfig.token\n );\n }\n}\n\nexport class TempMailClient {\n private readonly aliasProvider: AliasProvider;\n private readonly mailProvider: MailProvider;\n private readonly parser: EmailParser;\n\n constructor(config: TempMailConfig) {\n const timeout = config.timeout ?? 30000;\n const httpClient = new HttpClient('https://relay.firefox.com', timeout);\n this.aliasProvider = createAliasProvider(config, httpClient);\n this.mailProvider = createMailProvider(config);\n this.parser = new EmailParser();\n }\n\n async listAliases(): Promise<RelayAlias[]> {\n return this.aliasProvider.listAliases();\n }\n\n async createAlias(): Promise<RelayAlias> {\n return this.aliasProvider.createAlias();\n }\n\n async deleteAlias(id: number): Promise<void> {\n return this.aliasProvider.deleteAlias(id);\n }\n\n async getEmails(\n aliasAddress?: string,\n options?: GetEmailsOptions\n ): Promise<ParsedEmail[]> {\n const limit = options?.limit ?? 20;\n const offset = options?.offset ?? 0;\n\n const emails = await this.mailProvider.getMails(limit, offset);\n\n const parsedEmails: ParsedEmail[] = emails.map((email) => {\n const parsed = this.parser.parseEmail(email.raw);\n return {\n ...parsed,\n id: email.id,\n messageId: email.messageId,\n source: email.source,\n address: email.address,\n createdAt: email.createdAt,\n metadata: email.metadata,\n };\n });\n\n if (aliasAddress) {\n const normalizedAlias = aliasAddress.toLowerCase();\n return parsedEmails.filter(\n (email) =>\n email.relayAlias?.toLowerCase() === normalizedAlias ||\n email.address.toLowerCase() === normalizedAlias ||\n email.raw.toLowerCase().includes(normalizedAlias)\n );\n }\n\n return parsedEmails;\n }\n}\n\n/** @deprecated Use TempMailClient instead */\nexport const RelayClient = TempMailClient;\n"],"mappings":";AAcO,IAAM,qBAAN,cAAiC,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAyB5C,YACE,SACA,MACA,YACA,UACA;AACA,UAAM,OAAO;AACb,SAAK,OAAO,KAAK,YAAY;AAC7B,SAAK,OAAO;AACZ,SAAK,aAAa;AAClB,SAAK,WAAW;AAGhB,QAAI,MAAM,mBAAmB;AAC3B,YAAM,kBAAkB,MAAM,KAA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relay-temp-mail",
|
|
3
|
-
"version": "2.1.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"description": "TypeScript npm package for Firefox Relay + CF temp email API",
|
|
6
|
-
"main": "./dist/index.cjs",
|
|
7
|
-
"module": "./dist/index.js",
|
|
8
|
-
"types": "./dist/index.d.ts",
|
|
9
|
-
"exports": {
|
|
10
|
-
".": {
|
|
11
|
-
"import": {
|
|
12
|
-
"types": "./dist/index.d.ts",
|
|
13
|
-
"default": "./dist/index.js"
|
|
14
|
-
},
|
|
15
|
-
"require": {
|
|
16
|
-
"types": "./dist/index.d.cts",
|
|
17
|
-
"default": "./dist/index.cjs"
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
"files": [
|
|
22
|
-
"dist"
|
|
23
|
-
],
|
|
24
|
-
"scripts": {
|
|
25
|
-
"build": "tsup",
|
|
26
|
-
"test": "vitest",
|
|
27
|
-
"typecheck": "tsc --noEmit",
|
|
28
|
-
"lint": "eslint src --ext .ts",
|
|
29
|
-
"coverage": "vitest run --coverage"
|
|
30
|
-
},
|
|
31
|
-
"devDependencies": {
|
|
32
|
-
"@types/node": "^20.0.0",
|
|
33
|
-
"tsup": "^8.0.0",
|
|
34
|
-
"typescript": "^5.0.0",
|
|
35
|
-
"vitest": "^1.0.0"
|
|
36
|
-
},
|
|
37
|
-
"engines": {
|
|
38
|
-
"node": ">=18"
|
|
39
|
-
}
|
|
40
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@z_06/relay-temp-mail",
|
|
3
|
+
"version": "2.1.3",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "TypeScript npm package for Firefox Relay + CF temp email API",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"require": {
|
|
16
|
+
"types": "./dist/index.d.cts",
|
|
17
|
+
"default": "./dist/index.cjs"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsup",
|
|
26
|
+
"test": "vitest",
|
|
27
|
+
"typecheck": "tsc --noEmit",
|
|
28
|
+
"lint": "eslint src --ext .ts",
|
|
29
|
+
"coverage": "vitest run --coverage"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/node": "^20.0.0",
|
|
33
|
+
"tsup": "^8.0.0",
|
|
34
|
+
"typescript": "^5.0.0",
|
|
35
|
+
"vitest": "^1.0.0"
|
|
36
|
+
},
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=18"
|
|
39
|
+
}
|
|
40
|
+
}
|