@z_06/relay-temp-mail 2.1.2 → 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.
Files changed (3) hide show
  1. package/README.md +2 -94
  2. package/README.zh-CN.md +2 -94
  3. 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 | Current Implementations |
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
- ### Alias Providers
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/package.json CHANGED
@@ -1,40 +1,40 @@
1
- {
2
- "name": "@z_06/relay-temp-mail",
3
- "version": "2.1.2",
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
+ }