koishi-plugin-wordpress-notifier 2.0.4 → 2.0.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/README.md CHANGED
@@ -49,11 +49,24 @@ plugins:
49
49
  enableUserPush: false # 是否启用新用户注册推送
50
50
  mentionAll: false # 是否 @全体成员
51
51
  maxArticles: 5 # 每次最多推送的文章数量
52
- # 可选:WordPress API 认证配置(用于访问受保护的端点,如 users 端点)
52
+ # 可选:WordPress API 认证配置
53
+ # 推荐使用应用程序密码(Application Password),更安全
53
54
  # username: 'your-wordpress-username'
54
- # password: 'your-wordpress-password'
55
+ # password: 'your-application-password' # 可以是普通密码或应用程序密码
55
56
  ```
56
57
 
58
+ ### 如何获取WordPress应用程序密码
59
+
60
+ 1. 登录WordPress后台
61
+ 2. 进入用户 > 个人资料
62
+ 3. 滚动到"应用程序密码"部分
63
+ 4. 输入应用程序名称(例如:"Koishi 推送插件")
64
+ 5. 点击"添加新应用程序密码"
65
+ 6. 复制生成的应用程序密码(例如:`hGR2 sPFu Yncl xHc4 AvJq cUtB`)
66
+ 7. 在插件配置中使用此密码,**无需删除空格**,插件会自动处理
67
+
68
+ 应用程序密码是WordPress生成的安全密码,适合API访问,比普通密码更安全,可以随时撤销,不会影响您的主密码。
69
+
57
70
  ### 配置参数说明
58
71
 
59
72
  | 参数 | 类型 | 默认值 | 说明 |
@@ -66,8 +79,8 @@ plugins:
66
79
  | `enableUserPush` | boolean | false | 是否启用新用户注册推送 |
67
80
  | `mentionAll` | boolean | false | 是否在推送时 @全体成员 |
68
81
  | `maxArticles` | number | 5 | 每次最多推送的文章数量 |
69
- | `username` | string | 可选 | WordPress 用户名(用于 Basic 基础认证,访问受保护的 API 端点,如 users 端点) |
70
- | `password` | string | 可选 | WordPress 密码(用于 Basic 基础认证,访问受保护的 API 端点,如 users 端点) |
82
+ | `username` | string | 可选 | WordPress 用户名(用于 Basic 基础认证) |
83
+ | `password` | string | 可选 | WordPress 密码或应用程序密码(用于 Basic 基础认证,推荐使用应用程序密码,更安全) |
71
84
 
72
85
  ## 使用命令
73
86
 
@@ -272,6 +285,14 @@ npm install
272
285
 
273
286
  ## 版本历史
274
287
 
288
+ ### 2.0.5 (2026-01-25)
289
+
290
+ - ✅ 支持WordPress应用程序密码(Application Password)
291
+ - ✅ 自动处理带有空格的应用程序密码,无需手动删除空格
292
+ - ✅ 优化认证逻辑,确保应用程序密码能正确工作
293
+ - 🔧 更新了文档,详细说明如何获取和使用应用程序密码
294
+ - 🔧 推荐使用应用程序密码,提高安全性
295
+
275
296
  ### 2.0.4 (2026-01-25)
276
297
 
277
298
  - ✅ 修复插件配置页面无法添加WordPress账号和密码的问题
package/lib/index.js CHANGED
@@ -64,7 +64,10 @@ function apply(ctx, config) {
64
64
  // 准备请求配置,添加认证头(如果配置了用户名和密码)
65
65
  const requestConfig = {};
66
66
  if (config.username && config.password) {
67
- const auth = Buffer.from(`${config.username}:${config.password}`).toString('base64');
67
+ // 处理WordPress应用程序密码,移除空格(WordPress生成的应用密码格式为:hGR2 sPFu Yncl xHc4 AvJq cUtB)
68
+ const username = config.username;
69
+ const password = config.password.replace(/\s+/g, ''); // 移除所有空格
70
+ const auth = Buffer.from(`${username}:${password}`).toString('base64');
68
71
  requestConfig.headers = {
69
72
  Authorization: `Basic ${auth}`
70
73
  };
@@ -85,7 +88,10 @@ function apply(ctx, config) {
85
88
  // 准备请求配置,添加认证头(如果配置了用户名和密码)
86
89
  const requestConfig = {};
87
90
  if (config.username && config.password) {
88
- const auth = Buffer.from(`${config.username}:${config.password}`).toString('base64');
91
+ // 处理WordPress应用程序密码,移除空格(WordPress生成的应用密码格式为:hGR2 sPFu Yncl xHc4 AvJq cUtB)
92
+ const username = config.username;
93
+ const password = config.password.replace(/\s+/g, ''); // 移除所有空格
94
+ const auth = Buffer.from(`${username}:${password}`).toString('base64');
89
95
  requestConfig.headers = {
90
96
  Authorization: `Basic ${auth}`
91
97
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koishi-plugin-wordpress-notifier",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "description": "WordPress 文章自动推送到 QQ",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",