dsh-email 0.14.4 → 0.14.5
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/CHANGELOG.md +9 -0
- package/README.en.md +6 -4
- package/README.md +7 -5
- package/lib/client.js +13 -1
- package/lib/config.d.ts +2 -0
- package/lib/config.js +32 -13
- package/lib/mail-client.d.ts +2 -4
- package/lib/mail-client.js +3 -4
- package/lib/runtime.js +2 -2
- package/lib/web.js +16 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.14.5(2026-10-01)
|
|
4
|
+
|
|
5
|
+
- 修复 [#20](https://github.com/STARDUSTLC666/dsh-email/issues/20):具名账号的服务商预设不再被顶层共享服务器遮蔽;Gmail 不再因继承 Outlook 端点被误判为 OAuth2。保留账号显式端点、传输超时和旧单账号继承规则。
|
|
6
|
+
- 账号映射转换为卡片时沿用相同端点规则;新版设置服务保存卡片时排除表单派生的共享 imap/smtp,避免修改 Outlook 后改变其他账号的连接。
|
|
7
|
+
- 连接失败显示账号、实际 IMAP 主机与端口;密码赋值及服务端回显的已知密码会脱敏,短密码不会破坏普通错误文字。
|
|
8
|
+
- 修复顶层 senderName / authUser / authPassword 未传入单账号解析的问题。
|
|
9
|
+
- 空地址卡片点击测试时先提示填写邮箱地址,不再测试隐藏表单中的旧凭据;保存后及时更新 Outlook 内置应用 ID 和独立登录密码的提示。
|
|
10
|
+
- Windows 下新增十项行为回归,整套邮件 295 项通过;官方 Harness 0.2.0-rc.2 源码构建及 18 插件同载检查通过。原生桌面已实测新增卡片、服务商切换、自动保存与删除;最后的字段提示修正有组件行为回归,尚未再次实机操作。未验证真实邮箱登录、OAuth2 授权或发信成功。
|
|
11
|
+
|
|
3
12
|
## 0.14.4(2026-09-29)
|
|
4
13
|
|
|
5
14
|
- 修复:SMTP 发送改为**每次发送独占连接**,取消(AbortSignal)时只销毁本次连接的 socket 并立即拒绝,不再影响同账号的其它发送,也不会在取消后仍把邮件发出去。
|
package/README.en.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
# dsh-email
|
|
2
2
|
|
|
3
|
-
## 0.14.
|
|
3
|
+
## 0.14.5 update (2026-10-01)
|
|
4
4
|
|
|
5
|
-
Fixes
|
|
5
|
+
Fixes [#20](https://github.com/STARDUSTLC666/dsh-email/issues/20): a named account's provider selects its own servers, so Gmail no longer inherits shared Outlook endpoints or becomes an OAuth2 account. Card saves exclude form-derived shared endpoints. Explicit account endpoints and legacy single-account configuration remain supported; top-level sender aliases and login credentials now take effect. Connection failures identify the selected account and actual IMAP host and port, with echoed credentials redacted.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
An empty card asks for its email address before testing. Outlook's built-in application ID updates from the saved snapshot, avoiding a false missing-ID warning. Stored separate login passwords are acknowledged without exposing their values.
|
|
8
|
+
|
|
9
|
+
Validation host: Harness `0.2.0-rc.2` built from the official release tag (commit `639ed01539`), Windows and Node `24.16.0`. All 295 email tests pass; all 18 plugins mount together, with 10 email tools. Native Desktop checks covered adding a card, switching Outlook/Gmail, automatic saving and deletion. The final field-hint fixes have component behavior regressions but have not been retested in the native UI. Successful real-mailbox login, OAuth2 authorization and sending remain unverified.
|
|
8
10
|
|
|
9
11
|
   
|
|
10
12
|
|
|
@@ -53,7 +55,7 @@ Example:
|
|
|
53
55
|
- **0.10.8 and earlier**: see [CHANGELOG.md](CHANGELOG.md).
|
|
54
56
|
## Compatibility
|
|
55
57
|
|
|
56
|
-
The current baseline is
|
|
58
|
+
The current baseline is Harness **0.2.0-rc.2** built from its official release tag on 2026-09-30. All 18 plugins mount together with 99 tools and 35 skills; registration and output checks pass. New email regressions cover provider isolation, card saves, endpoint diagnostics, sender aliases and editor hints. The native UI scope and remaining live-service checks are described above.
|
|
57
59
|
|
|
58
60
|
**0.11.0 co-load verification (2026-09-18, locally built Harness `0.1.5-rc.2`, `web` profile)**: the plugin mounted without errors; the settings route answered GET with 200 and no `raw` field in the response; a `text/plain` POST was refused with **415**, proving the same-origin guard holds in the real host; under a `application/json` POST the card projection was correct, and an account pinning `authKind: password` reported both `authKindDeclared` and `authKind` as `password`; the panel actually rendered account cards, the eight provider presets with localized labels, the three-way authentication selector, the application (client) ID field with its hint, the missing-ID warning banner (so `--dsw-alias-state-warn-primary` is genuinely defined in the real host) and the Sign in with Microsoft button; the browser console was clean; save worked end to end, and afterwards `accountsYaml` was restored to empty with the original account intact. Offline tests: 231 green. **Still not done**: an end-to-end OAuth2 run against a real Outlook tenant (the device-code flow needs a human to authorize in a browser) and real sending; the `clientId` paths are covered only against a fake authority. Uses the `cordis.patch.yml` + `dsh.bundle.patch` bundle model. Node requirements are 22.19 or later within 22.x, or 24 or later. Live external-service workflows require separate configuration and validation.
|
|
59
61
|
|
package/README.md
CHANGED
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
# dsh-email
|
|
4
4
|
|
|
5
|
-
## 0.14.
|
|
5
|
+
## 0.14.5 更新(2026-10-01)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
修复 [#20](https://github.com/STARDUSTLC666/dsh-email/issues/20):具名账号选择自己的服务商后,使用该服务商的服务器;Gmail 不再继承共享 Outlook 端点并被误判为 OAuth2。账号卡片保存不再把默认账号端点写回共享配置。保留显式账号端点与旧单账号配置,同时修复顶层发送别名和登录凭据未生效的问题。连接失败显示所选账号及实际 IMAP 主机、端口,服务端回显的密码继续脱敏。
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
空地址卡片点击测试时先提示填写邮箱地址;切换到 Outlook 后,内置应用 ID 提示随保存结果更新,不再误报缺失。独立登录密码只显示是否已保存,仍不回填明文。
|
|
10
|
+
|
|
11
|
+
验证宿主:官方源码构建的 Harness `0.2.0-rc.2`(commit `639ed01539`)+ Windows / Node `24.16.0`。295 项邮件测试通过;18 个插件共同加载,邮件注册 10 个工具。原生桌面已实测新增卡片、Outlook/Gmail 切换、自动保存和删除。最后的字段提示修正通过组件行为回归,尚未再次实机操作;未验证真实邮箱登录、OAuth2 授权或发信成功。
|
|
10
12
|
|
|
11
13
|
> **让 agent 协助处理邮件**:收发、搜索、回复转发、附件、邮件整理与新邮件提醒,支持八种常见邮箱服务预设。
|
|
12
14
|
|
|
@@ -61,7 +63,7 @@ IMAP/SMTP email tools for DeepSeek Harness, with replies, forwarding, mailbox or
|
|
|
61
63
|
- **0.10.8 及更早**:见 [CHANGELOG.md](CHANGELOG.md)。
|
|
62
64
|
## 兼容性
|
|
63
65
|
|
|
64
|
-
|
|
66
|
+
当前验证基线为官方发布标签源码构建的 Harness **0.2.0-rc.2**(2026-09-30)。18 个插件共同加载,99 个工具与 35 个技能的注册及输出检查通过;邮件新增多服务商隔离、卡片保存、端点错误提示、发送别名与编辑提示回归。桌面操作范围与尚未完成的真实服务验证见上文。
|
|
65
67
|
|
|
66
68
|
**0.11.0 的同载验证(2026-09-18,本地构建的 Harness `0.1.5-rc.2`,`web` profile)**:插件挂载无报错;设置路由 GET 返回 200 且响应中已无 `raw` 字段;用 `text/plain` 发 POST 被 **415** 拒绝(同源守卫在真实宿主下生效);`application/json` 的 POST 下卡片投影正确,账号钉住 `authKind: password` 后 `authKindDeclared` 与 `authKind` 均为 `password`;设置面板实际渲染出账号卡片、8 个服务商预设的中文下拉、「认证方式」三态选择器、「应用(客户端)ID」输入格与提示、未填 ID 时的警示条(说明 `--dsw-alias-state-warn-primary` 在真实宿主下确有定义)与「登录 Microsoft 账号」按钮;浏览器控制台无报错;save 全链路可用,验证结束后已把 `accountsYaml` 还原为空、原有账号恢复。离线测试 231 项全绿。**仍未做**:真实 Outlook 租户的 OAuth2 端到端(设备码流程要真人在浏览器完成授权)与真实发信未测,`clientId` 相关路径目前只有假 authority 的用例覆盖。采用 `cordis.patch.yml` + `dsh.bundle.patch` 组合包模型。Node 要求为 22.19 及以上的 22.x,或 24 及以上。外部服务的实际业务操作需按各组件配置单独验证。
|
|
67
69
|
|
|
@@ -133,7 +135,7 @@ dsh plugin --profile web remove dsh-email
|
|
|
133
135
|
downloadDir: E:/attachments # 可选,默认 $DSH_HOME/email-downloads
|
|
134
136
|
```
|
|
135
137
|
|
|
136
|
-
顶层的 `provider`/`user`/`password`/`imap`/`smtp`/`inboxFolder`
|
|
138
|
+
顶层的 `provider`/`user`/`password`/`imap`/`smtp`/`inboxFolder` 仍兼容旧单账号写法。具名账号声明自己的 `provider` 时,服务器取该预设,账号自己的 `imap`/`smtp` 显式覆盖优先;未声明服务商的账号继续继承顶层服务器。共享连接超时仍可生效。
|
|
137
139
|
|
|
138
140
|
想在多个账号之间复用同一套连接端点,可以用 `serverPresets` 自定义服务商预设(YAML 映射,键 = 预设名,值含可选的 `label` 与 `imap`/`smtp`):
|
|
139
141
|
|
package/lib/client.js
CHANGED
|
@@ -295,6 +295,7 @@ var UI = {
|
|
|
295
295
|
"card.testing": "测试中…",
|
|
296
296
|
"card.testOk": "连接成功({ms} ms)· {host}:{port}",
|
|
297
297
|
"card.testFailed": "连接失败:{message}",
|
|
298
|
+
"card.testMissingAddress": "请先填写这个账号的邮箱地址,再测试连接。",
|
|
298
299
|
"card.pickDefault": "配置了多个账号,请设置默认账号:",
|
|
299
300
|
"card.errNoName": "有账号还没填账号名,这份改动先不保存。",
|
|
300
301
|
"card.errNoProvider": "有账号还没选服务商,这份改动先不保存。",
|
|
@@ -475,6 +476,7 @@ var UI = {
|
|
|
475
476
|
"card.testing": "Testing…",
|
|
476
477
|
"card.testOk": "Connected ({ms} ms) · {host}:{port}",
|
|
477
478
|
"card.testFailed": "Connection failed: {message}",
|
|
479
|
+
"card.testMissingAddress": "Enter this account's email address before testing the connection.",
|
|
478
480
|
"card.pickDefault": "Several accounts are configured; choose the default account:",
|
|
479
481
|
"card.errNoName": "An account has no name yet; this change will not be saved.",
|
|
480
482
|
"card.errNoProvider": "An account has no provider selected; this change will not be saved.",
|
|
@@ -1154,6 +1156,9 @@ function oauthViewOf(draft, cards) {
|
|
|
1154
1156
|
oauthState: sameProvider && liveState !== "" ? liveState : draftState,
|
|
1155
1157
|
oauthUser: sameProvider && live && typeof live.oauthUser === "string" ? live.oauthUser : String(draft.oauthUser || ""),
|
|
1156
1158
|
hasPassword: live !== null && live.hasPassword === true,
|
|
1159
|
+
hasAuthPassword: live !== null && live.hasAuthPassword === true,
|
|
1160
|
+
defaultClientId: sameProvider && typeof live.oauthDefaultClientId === "string"
|
|
1161
|
+
? live.oauthDefaultClientId : String(draft.defaultClientId || ""),
|
|
1157
1162
|
};
|
|
1158
1163
|
}
|
|
1159
1164
|
|
|
@@ -1195,7 +1200,7 @@ function OauthLoginPanel(props) {
|
|
|
1195
1200
|
// (公共客户端 ID 每次都随请求发出),因此可以直接回填、直接编辑。留空不是
|
|
1196
1201
|
// 「没配置」:插件自带一份社区注册,所以这里必须说清生效的到底是哪个应用 ——
|
|
1197
1202
|
// 同意屏上写的名字不是账号主人自己的,这件事不该等点了登录才发现。
|
|
1198
|
-
const builtInClientId = String(draft.defaultClientId
|
|
1203
|
+
const builtInClientId = String(view.defaultClientId ?? draft.defaultClientId ?? "").trim();
|
|
1199
1204
|
const clientIdField = () => h("div", { className: "dshe-field dshe-oauth-client" }, [
|
|
1200
1205
|
h("label", null, t("oauth.clientIdLabel")),
|
|
1201
1206
|
h("input", {
|
|
@@ -1595,6 +1600,13 @@ function AccountCardsEditor(props) {
|
|
|
1595
1600
|
|
|
1596
1601
|
/** 传的是卡片上的「当前账号名」(可能刚改过名),行内提示按它归类。 */
|
|
1597
1602
|
const testCard = async (draftName) => {
|
|
1603
|
+
// An empty card must not fall back to credentials in the hidden legacy form.
|
|
1604
|
+
if (String(draftsRef.current[draftName]?.user || "").trim() === "") {
|
|
1605
|
+
setRowStatus((cur) => Object.assign({}, cur, {
|
|
1606
|
+
[draftName]: { kind: "error", text: t("card.testMissingAddress") },
|
|
1607
|
+
}));
|
|
1608
|
+
return;
|
|
1609
|
+
}
|
|
1598
1610
|
setBusy(draftName);
|
|
1599
1611
|
setRowStatus((cur) => Object.assign({}, cur, { [draftName]: { kind: "busy", text: t("card.testing") } }));
|
|
1600
1612
|
try {
|
package/lib/config.d.ts
CHANGED
|
@@ -280,6 +280,8 @@ export declare function providerNames(custom?: Record<string, ServerPreset>): st
|
|
|
280
280
|
* this provider name be written?", where a broken table can only mean "no".
|
|
281
281
|
*/
|
|
282
282
|
export declare function presetNamesIn(text: string | undefined): string[];
|
|
283
|
+
/** Materialize shared account defaults without replacing a named provider's servers. */
|
|
284
|
+
export declare function mergeAccountDefaults(common: AccountConfig, account?: AccountConfig): AccountConfig;
|
|
283
285
|
/** v0.1-compatible wrapper: resolve the single (or default) account. */
|
|
284
286
|
export declare function resolveEmailConfig(config: EmailConfig | undefined): ResolvedEmailConfig;
|
|
285
287
|
export declare function clampInt(value: unknown, fallback: number, min: number, max: number): number;
|
package/lib/config.js
CHANGED
|
@@ -228,6 +228,9 @@ export function resolveEmailSettings(config, onlyAccount) {
|
|
|
228
228
|
provider: raw.provider,
|
|
229
229
|
user: raw.user,
|
|
230
230
|
password: raw.password,
|
|
231
|
+
senderName: raw.senderName,
|
|
232
|
+
authUser: raw.authUser,
|
|
233
|
+
authPassword: raw.authPassword,
|
|
231
234
|
clientId: raw.clientId,
|
|
232
235
|
authKind: raw.authKind,
|
|
233
236
|
imap: raw.imap,
|
|
@@ -341,7 +344,24 @@ export function presetNamesIn(text) {
|
|
|
341
344
|
return [];
|
|
342
345
|
}
|
|
343
346
|
}
|
|
344
|
-
/**
|
|
347
|
+
/** Materialize shared account defaults without replacing a named provider's servers. */
|
|
348
|
+
export function mergeAccountDefaults(common, account = {}) {
|
|
349
|
+
const acc = account ?? {};
|
|
350
|
+
const ownProvider = acc.provider !== undefined && acc.provider !== '';
|
|
351
|
+
// A named provider selects its own servers; shared connection budgets still apply.
|
|
352
|
+
const sharedImap = ownProvider ? {
|
|
353
|
+
...(common.imap?.connectionTimeoutMs !== undefined ? { connectionTimeoutMs: common.imap.connectionTimeoutMs } : {}),
|
|
354
|
+
...(common.imap?.socketTimeoutMs !== undefined ? { socketTimeoutMs: common.imap.socketTimeoutMs } : {}),
|
|
355
|
+
} : common.imap && normalizeSettingsEndpoint(common.imap, 'imap');
|
|
356
|
+
const sharedSmtp = !ownProvider && common.smtp ? normalizeSettingsEndpoint(common.smtp, 'smtp') : undefined;
|
|
357
|
+
const imap = { ...sharedImap, ...(acc.imap && normalizeSettingsEndpoint(acc.imap, 'imap')) };
|
|
358
|
+
const smtp = { ...sharedSmtp, ...(acc.smtp && normalizeSettingsEndpoint(acc.smtp, 'smtp')) };
|
|
359
|
+
return { ...common, ...acc,
|
|
360
|
+
imap: Object.keys(imap).length > 0 ? imap : undefined,
|
|
361
|
+
smtp: Object.keys(smtp).length > 0 ? smtp : undefined,
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
/** Merge one account over shared defaults and its selected provider, then validate it. */
|
|
345
365
|
function resolveAccount(name, common, acc, allowEnvPassword, providers, known) {
|
|
346
366
|
const requested = acc.provider ?? common.provider;
|
|
347
367
|
const preset = requested === undefined ? undefined : providers[requested];
|
|
@@ -358,21 +378,20 @@ function resolveAccount(name, common, acc, allowEnvPassword, providers, known) {
|
|
|
358
378
|
const authUser = (acc.authUser ?? common.authUser ?? '').trim() || user;
|
|
359
379
|
const authPassword = (acc.authPassword ?? common.authPassword) || password;
|
|
360
380
|
const senderName = (acc.senderName ?? common.senderName ?? '').trim();
|
|
361
|
-
const
|
|
362
|
-
const
|
|
363
|
-
const accountSmtp =
|
|
364
|
-
const sharedSmtp = common.smtp && normalizeSettingsEndpoint(common.smtp, 'smtp');
|
|
381
|
+
const merged = mergeAccountDefaults(common, acc);
|
|
382
|
+
const accountImap = merged.imap && normalizeSettingsEndpoint(merged.imap, 'imap');
|
|
383
|
+
const accountSmtp = merged.smtp && normalizeSettingsEndpoint(merged.smtp, 'smtp');
|
|
365
384
|
const imap = {
|
|
366
|
-
host: accountImap?.host ??
|
|
367
|
-
port: accountImap?.port ??
|
|
368
|
-
secure: accountImap?.secure ??
|
|
369
|
-
connectionTimeoutMs: accountImap?.connectionTimeoutMs
|
|
370
|
-
socketTimeoutMs: accountImap?.socketTimeoutMs
|
|
385
|
+
host: accountImap?.host ?? preset?.imap.host,
|
|
386
|
+
port: accountImap?.port ?? preset?.imap.port,
|
|
387
|
+
secure: accountImap?.secure ?? preset?.imap.secure,
|
|
388
|
+
connectionTimeoutMs: accountImap?.connectionTimeoutMs,
|
|
389
|
+
socketTimeoutMs: accountImap?.socketTimeoutMs,
|
|
371
390
|
};
|
|
372
391
|
const smtp = {
|
|
373
|
-
host: accountSmtp?.host ??
|
|
374
|
-
port: accountSmtp?.port ??
|
|
375
|
-
secure: accountSmtp?.secure ??
|
|
392
|
+
host: accountSmtp?.host ?? preset?.smtp.host,
|
|
393
|
+
port: accountSmtp?.port ?? preset?.smtp.port,
|
|
394
|
+
secure: accountSmtp?.secure ?? preset?.smtp.secure,
|
|
376
395
|
};
|
|
377
396
|
const problems = [];
|
|
378
397
|
if (user === '')
|
package/lib/mail-client.d.ts
CHANGED
|
@@ -15,10 +15,8 @@ export declare function messageOf(error: unknown, fallback: string): string;
|
|
|
15
15
|
* messages are rendered in the settings panel, returned by the mail tools, and
|
|
16
16
|
* pasted into bug reports.
|
|
17
17
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* blob). The replacement keeps the length so a report still says how big the
|
|
21
|
-
* thing was, without saying what it was.
|
|
18
|
+
* Mask JWTs, long base64 authentication blobs and credential assignments.
|
|
19
|
+
* Token replacements retain their length for diagnostics.
|
|
22
20
|
*/
|
|
23
21
|
export declare function redactCredentials(text: string): string;
|
|
24
22
|
/** The IMAP auth shape imapflow accepts: a password, or an OAuth2 access token. */
|
package/lib/mail-client.js
CHANGED
|
@@ -24,13 +24,12 @@ export function messageOf(error, fallback) {
|
|
|
24
24
|
* messages are rendered in the settings panel, returned by the mail tools, and
|
|
25
25
|
* pasted into bug reports.
|
|
26
26
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* blob). The replacement keeps the length so a report still says how big the
|
|
30
|
-
* thing was, without saying what it was.
|
|
27
|
+
* Mask JWTs, long base64 authentication blobs and credential assignments.
|
|
28
|
+
* Token replacements retain their length for diagnostics.
|
|
31
29
|
*/
|
|
32
30
|
export function redactCredentials(text) {
|
|
33
31
|
return text
|
|
32
|
+
.replace(/(["']?(?:password|passwd|authPassword|secret|api[_-]?key)["']?)(\s*[:=]\s*)(?:"[^"]*"|'[^']*'|[^\s;,)]+)/gi, '$1$2<已隐去的凭据>')
|
|
34
33
|
.replace(/[A-Za-z0-9_-]{12,}\.[A-Za-z0-9_-]{12,}\.[A-Za-z0-9_-]{8,}/g, match => `<已隐去 ${match.length} 字符的令牌>`)
|
|
35
34
|
.replace(/[A-Za-z0-9+/]{40,}={0,2}/g, match => `<已隐去 ${match.length} 字符的凭据>`);
|
|
36
35
|
}
|
package/lib/runtime.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Live settings, account-pool ownership, and independent tool/web watch cursors. */
|
|
2
|
-
import { clampInt, presetNamesIn, resolveEmailSettings, serializeAccountsYaml } from './config.js';
|
|
2
|
+
import { clampInt, mergeAccountDefaults, presetNamesIn, resolveEmailSettings, serializeAccountsYaml } from './config.js';
|
|
3
3
|
import { EmailPool, messageOf } from './mail-client.js';
|
|
4
4
|
import { EmailSettingsSchema, SETTINGS_NAMESPACE, toEmailConfig, toSettingsBase, validateSettingsValue } from './settings.js';
|
|
5
5
|
import { liveConfig } from './host-config.js';
|
|
@@ -43,7 +43,7 @@ export function createEmailRuntime(ctx, config, createPool = settings => new Ema
|
|
|
43
43
|
const shared = Object.fromEntries(['provider', 'user', 'password', 'senderName', 'authUser', 'authPassword', 'clientId', 'authKind', 'imap', 'smtp', 'inboxFolder']
|
|
44
44
|
.filter(key => config[key] !== undefined).map(key => [key, config[key]]));
|
|
45
45
|
const cards = config.accounts && Object.keys(config.accounts).length > 0
|
|
46
|
-
? Object.fromEntries(Object.entries(config.accounts).map(([key, account]) => [key,
|
|
46
|
+
? Object.fromEntries(Object.entries(config.accounts).map(([key, account]) => [key, mergeAccountDefaults(shared, account)]))
|
|
47
47
|
: typeof config.user === 'string' && config.user !== '' ? { default: shared } : {};
|
|
48
48
|
return EmailSettingsSchema({ ...toSettingsBase(config), ...endpointDefaults,
|
|
49
49
|
accountsYaml: config.accountsYaml ?? serializeAccountsYaml(cards, config.defaultAccount),
|
package/lib/web.js
CHANGED
|
@@ -823,7 +823,12 @@ export class EmailSettingsBackend {
|
|
|
823
823
|
// resurrect a hidden old account on the next read.
|
|
824
824
|
const section = Object.hasOwn(value, 'accountsYaml')
|
|
825
825
|
? { ...value, accounts: {}, user: '', password: '', authUser: '', authPassword: '' }
|
|
826
|
-
: value;
|
|
826
|
+
: { ...value };
|
|
827
|
+
if (Object.hasOwn(value, 'accountsYaml')) {
|
|
828
|
+
// The form displays the default card's resolved endpoints; those are not shared edits.
|
|
829
|
+
delete section.imap;
|
|
830
|
+
delete section.smtp;
|
|
831
|
+
}
|
|
827
832
|
await this.ctx.settings.update(this.namespace, section, expectedRevision);
|
|
828
833
|
}
|
|
829
834
|
else
|
|
@@ -868,6 +873,7 @@ export class EmailSettingsBackend {
|
|
|
868
873
|
throw new Error(`未知账号 "${name}",可用:${available.join('、')}`);
|
|
869
874
|
}
|
|
870
875
|
const target = { account: name, imapHost: cfg.imap.host, imapPort: cfg.imap.port };
|
|
876
|
+
const targetDescription = '账号 "' + name + '" · IMAP ' + cfg.imap.host + ':' + cfg.imap.port;
|
|
871
877
|
// An OAuth2 account has no password to check: without a token there is
|
|
872
878
|
// nothing to dial with, and a failed dial would only say so less clearly.
|
|
873
879
|
if (cfg.authKind === 'oauth2') {
|
|
@@ -875,7 +881,7 @@ export class EmailSettingsBackend {
|
|
|
875
881
|
await getFreshAccessToken(name, cfg);
|
|
876
882
|
}
|
|
877
883
|
catch (error) {
|
|
878
|
-
throw new Error(messageOf(error, '尚未登录:请先在设置页完成设备码登录'));
|
|
884
|
+
throw new Error(targetDescription + '(OAuth2):' + redactCredentials(messageOf(error, '尚未登录:请先在设置页完成设备码登录')));
|
|
879
885
|
}
|
|
880
886
|
}
|
|
881
887
|
const pool = new EmailPool(settings);
|
|
@@ -889,14 +895,18 @@ export class EmailSettingsBackend {
|
|
|
889
895
|
// actionable hint instead of the opaque message. The server's own text is
|
|
890
896
|
// redacted first: a refused authentication string is echoed verbatim by
|
|
891
897
|
// many servers, and for XOAUTH2 that blob carries the access token.
|
|
892
|
-
|
|
898
|
+
let raw = redactCredentials(messageOf(error, 'unknown error'));
|
|
899
|
+
for (const secret of [cfg.password, cfg.authPassword]) {
|
|
900
|
+
if (secret && secret.length >= 4)
|
|
901
|
+
raw = raw.split(secret).join('[redacted]');
|
|
902
|
+
}
|
|
893
903
|
const lower = raw.toLowerCase();
|
|
894
904
|
if (lower.includes('command failed') || lower.includes('authentication') || lower.includes('login')) {
|
|
895
905
|
throw new Error(cfg.authKind === 'oauth2'
|
|
896
|
-
? '
|
|
897
|
-
: '
|
|
906
|
+
? targetDescription + '(OAuth2):邮箱登录失败:请在设置页重新完成设备码登录(' + raw + ')'
|
|
907
|
+
: targetDescription + ':邮箱登录失败:请检查邮箱地址与授权码(' + raw + ')');
|
|
898
908
|
}
|
|
899
|
-
throw
|
|
909
|
+
throw new Error(targetDescription + ':' + raw);
|
|
900
910
|
}
|
|
901
911
|
finally {
|
|
902
912
|
pool.dispose();
|