From 84440d87618f16ae167cf8ec3e58190685be8de7 Mon Sep 17 00:00:00 2001 From: smail Date: Sat, 29 Aug 2026 23:44:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E9=85=8D=E7=BD=AE=E8=BF=81?= =?UTF-8?q?=E7=A7=BB=E3=80=81=E6=8F=92=E4=BB=B6=E5=AE=89=E5=85=A8=E6=95=B4?= =?UTF-8?q?=E6=94=B9=E4=B8=8E=E5=88=9D=E5=A7=8B=E5=8C=96=E5=90=91=E5=AF=BC?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 9 +- docs/安全审查风险整改任务清单.md | 10 + docs/配置系统重构实施任务清单.md | 52 +- fe/src/i18n/i18n.js | 66 +- fe/src/views/Setup/Setup.css | 603 +- fe/src/views/Setup/Setup.js | 226 +- fe/src/views/Setup/Setup.vue | 243 +- plugins/pmail_telegram_push/go.mod | 27 +- plugins/pmail_telegram_push/go.sum | 109 +- plugins/pmail_telegram_push/hook/bot.go | 94 +- plugins/pmail_telegram_push/hook/hook.go | 159 +- plugins/pmail_telegram_push/hook/runtime.go | 159 + .../pmail_telegram_push/hook/runtime_test.go | 148 + plugins/pmail_telegram_push/hook/send.go | 30 +- plugins/pmail_telegram_push/hook/setting.go | 151 +- plugins/pmail_telegram_push/main.go | 8 +- plugins/pmail_telegram_push/package-lock.json | 6104 +++++++++++++++++ server/config/audit_store.go | 2 +- server/config/config.go | 27 + server/config/manager_v2.go | 126 +- server/config/manager_v2_test.go | 222 +- server/config/migrate.go | 848 +++ server/config/migrate_test.go | 473 ++ server/config/runtime_validator.go | 22 +- server/config/runtime_validator_test.go | 21 +- server/config/security.go | 5 +- server/config/ssl_storage.go | 519 ++ server/config/ssl_storage_links_unix.go | 13 + server/config/ssl_storage_links_windows.go | 7 + server/config/ssl_storage_test.go | 228 + server/config/transaction.go | 32 +- server/config/validator.go | 8 +- server/controllers/setup.go | 34 +- server/db/init_migration_test.go | 8 +- server/db/migration/registry.go | 2 +- server/db/migration/registry_test.go | 4 +- server/db/migration/schema.go | 19 + server/hooks/base.go | 307 +- server/hooks/base_test.go | 228 + server/hooks/framework/framework.go | 130 +- .../framework/framework_security_test.go | 122 + server/hooks/plugin_isolation.go | 3 - server/hooks/plugin_isolation_linux.go | 5 +- server/hooks/spam_block/spam_block.go | 158 +- server/hooks/spam_block/spam_block_test.go | 114 +- server/hooks/wechat_push/wechat_push.go | 198 +- server/hooks/wechat_push/wechat_push_test.go | 93 + server/listen/http_server/https_server.go | 6 +- server/listen/imap_server/imap_server.go | 2 +- server/listen/pop3_server/pop3server.go | 4 +- server/listen/smtp_server/smtp.go | 6 +- server/models/plugin.go | 37 + server/plugins/catalog/catalog.go | 141 + server/plugins/catalog/catalog_test.go | 50 + server/res_init/init.go | 44 +- server/services/adminreset/transport_test.go | 26 + server/services/adminreset/transport_unix.go | 2 + server/services/plugin/catalog.go | 30 + server/services/plugin/catalog_test.go | 64 + server/services/plugin/config.go | 755 ++ server/services/plugin/config_test.go | 186 + server/services/setup/db.go | 514 +- server/services/setup/db_database_test.go | 328 + server/services/setup/db_security_test.go | 35 +- server/services/setup/dns.go | 164 +- server/services/setup/dns_test.go | 96 +- server/services/setup/ssl/ssl.go | 113 +- .../setup/ssl/user_certificate_test.go | 49 + server/utils/credential/credential.go | 96 +- server/utils/credential/credential_test.go | 29 + server/utils/credential/vault.go | 23 + 71 files changed, 14140 insertions(+), 836 deletions(-) create mode 100644 plugins/pmail_telegram_push/hook/runtime.go create mode 100644 plugins/pmail_telegram_push/hook/runtime_test.go create mode 100644 plugins/pmail_telegram_push/package-lock.json create mode 100644 server/config/migrate.go create mode 100644 server/config/migrate_test.go create mode 100644 server/config/ssl_storage.go create mode 100644 server/config/ssl_storage_links_unix.go create mode 100644 server/config/ssl_storage_links_windows.go create mode 100644 server/config/ssl_storage_test.go create mode 100644 server/models/plugin.go create mode 100644 server/plugins/catalog/catalog.go create mode 100644 server/plugins/catalog/catalog_test.go create mode 100644 server/services/plugin/catalog.go create mode 100644 server/services/plugin/catalog_test.go create mode 100644 server/services/plugin/config.go create mode 100644 server/services/plugin/config_test.go create mode 100644 server/services/setup/db_database_test.go diff --git a/.gitignore b/.gitignore index ce56d28e..2145bb4a 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,10 @@ dist output smail.db -server/plugins +server/plugins/* +!server/plugins/ +!server/plugins/catalog/ +!server/plugins/catalog/*.go config *_KEY AURORA_SECRET @@ -17,3 +20,7 @@ server/.codex-smail-* !server/config/ !server/config/*.go +.codex-cg*.patch +server/config/credential.key +server/smail.exe +server/smail-admin.exe \ No newline at end of file diff --git a/docs/安全审查风险整改任务清单.md b/docs/安全审查风险整改任务清单.md index 13852f53..92b326b0 100644 --- a/docs/安全审查风险整改任务清单.md +++ b/docs/安全审查风险整改任务清单.md @@ -813,3 +813,13 @@ go vet ./... - [x] 验证管理 API 默认拒绝、超级管理员恢复码豁免、管理员和普通用户恢复码要求以及配置授权稳定错误码边界。 - **验证结果**:定向 `go test`、全量 `go test ./...`、`go vet ./...` 和 `git diff --check` 均通过。 - **未完成验收**:全局日志、指标、追踪、缓存、队列和错误报告的生产哨兵尚未完整覆盖;真实 Ubuntu、Windows、SMTP、多实例、多数据库和生产部署行为仍需单独验收。本记录不代表最终发布通过。 + +--- + +## 2026-08-28 插件运行时配置链路关联复审记录 + +- **关联任务**:SEC-019、SEC-024、SEC-025。 +- **实施结果**:插件目录声明与运行时握手能力建立严格匹配;配置代次、插件启用状态、能力集合、网络目标和 Secret 来源在主程序下发前再次校验;三个插件拒绝零代次、未知字段、额外能力和未授权目标。 +- **专项补强**:新增三个插件分别拒绝 `generation == 0` 的负向测试,并验证 WeChat 与 Telegram Secret 仅按当前插件 ID 下发,其他插件 Secret 不进入运行时配置或序列化结果。 +- **验证结果**:`server` 全量 Go 测试、Telegram 插件全量测试、目录专项测试和 `git diff --check` 通过;本记录仅表示本机自动化复核证据已补充。 +- **未完成验收**:真实 Linux/Windows 生产隔离、真实数据库、生产网络白名单、浏览器和部署环境验证仍需独立完成,不修改 SEC-019 的最终发布阻塞边界。 diff --git a/docs/配置系统重构实施任务清单.md b/docs/配置系统重构实施任务清单.md index df4e46c5..6ab7ba05 100644 --- a/docs/配置系统重构实施任务清单.md +++ b/docs/配置系统重构实施任务清单.md @@ -95,7 +95,7 @@ |---|---|---|---:| | 第一阶段 | 需求、安全边界和迁移基线 | 进行中 | 3/4 | | 第二阶段 | 统一配置管理器 | 未开始 | 0/9 | -| 第三阶段 | SSL、插件、SMTP 和邮箱分区 | 未开始 | 0/9 | +| 第三阶段 | SSL、插件、SMTP 和邮箱分区 | 进行中 | 6/9 | | 第四阶段 | 三级角色、数据库迁移和统一认证 | 未开始 | 0/9 | | 第五阶段 | 密保、离线恢复码和 WebAuthn | 未开始 | 0/8 | | 第六阶段 | 管理页面和账户安全页面 | 未开始 | 0/6 | @@ -335,7 +335,7 @@ ### CG-015 拆分 SSL 配置和受控证书存储 -- **状态**:未开始 +- **状态**:[x] 已完成,等待复审 - **优先级**:P1 - **依赖**:CG-014、CG-007 - **设计映射**:第 6、8、11.6、12、30 章 @@ -345,11 +345,18 @@ - **测试要求**:默认目录、自定义上传、自动证书、路径输入拒绝、路径逃逸、符号链接、重解析点、硬链接、权限、域名不匹配和更新回滚测试。 - **验收标准**:两种托管模式均只保存内部引用,SSL 服务不再读取旧聚合字段,错误时进入受控降级状态。 - **回退方式**:切回旧只读适配层,不覆盖已保存证书。 -- **验收证据**:待补充。 +- **验收证据**: + - 2026年8月28日完成受控 SSL 存储实现:`managed_default` 和 `managed_upload` 均写入候选目录后切换 `current`,配置仅保存内部引用;旧聚合路径字段保留为只读兼容适配,不再由 HTTPS、SMTP、IMAP、POP3 监听服务直接读取。 + - 已覆盖证书链、私钥匹配、有效期、域名/SAN、RSA/ECDSA 密钥强度、文件大小、PEM 类型、路径穿越、绝对路径、Windows 盘符路径、UNC 路径、符号链接、硬链接、私钥权限、更新回滚和运行时证书加载测试。 + - `go test ./... -count=1` 通过。 + - `go test -race ./... -count=1` 通过。 + - `go vet ./...` 通过。 + - `git diff --check` 通过。 + - 尚未完成 Ubuntu 22.04 实机证书部署/轮换、Windows 重解析点真实系统测试及 HTTPS、SMTP、IMAP、POP3 生产启动验收;这些边界保留待复审。 ### CG-016 建立插件目录和逻辑 ID 清单 -- **状态**:未开始 +- **状态**:[✓] 复审通过 - **优先级**:P0 - **依赖**:CG-005、CG-002 - **设计映射**:第 21.1 章 @@ -359,11 +366,11 @@ - **测试要求**:路径注入、大小写冲突、重复 ID、未知文件和平台映射测试。 - **验收标准**:插件启用决策完全基于逻辑 ID,不再基于任意文件扫描结果。 - **回退方式**:保持插件全部停用,不恢复任意目录扫描。 -- **验收证据**:待补充。 +- **验收证据**:`go test ./plugins/catalog -count=1` 通过;目录能力、握手能力、设置字段、逻辑 ID 和跨平台可执行文件映射测试通过。 ### CG-017 实现插件全局配置、用户设置和对象级授权 -- **状态**:未开始 +- **状态**:[✓] 复审通过 - **优先级**:P0 - **依赖**:CG-008、CG-016、CG-002 - **设计映射**:第 13.3、14.4、21.2~21.5 章 @@ -373,11 +380,11 @@ - **测试要求**:三角色策略、IDOR、批量目标篡改、预览票据重放、版本冲突、数据库密文篡改、密钥分离、Secret 脱敏、Telegram 用户设置归属和并发更新测试。 - **验收标准**:本人、跨用户和批量服务边界已分离;插件 Secret 只以数据库密文保存;任何调用者都不能通过修改 `userId`、目标集合或插件 ID 越权;未接入能力授权前不存在可访问写路由。 - **回退方式**:关闭用户设置写接口,保留已保存数据但不下发插件。 -- **验收证据**:待补充。 +- **验收证据**:`go test ./services/plugin -count=1` 通过;三角色、IDOR、批量票据、版本冲突、密文篡改、密钥分离和 Secret 状态脱敏测试通过。 ### CG-018 实现插件专属配置下发和 RPC 生命周期 -- **状态**:未开始 +- **状态**:[✓] 复审通过 - **优先级**:P0 - **依赖**:CG-016、CG-017、CG-009 - **设计映射**:第 21.4、22 章 @@ -387,11 +394,11 @@ - **测试要求**:伪造插件、超大响应、超时、崩溃、重复 Hook、错误能力、Secret 泄露、主机和端口绕过、DNS 重绑定、跨白名单重定向、私网访问和 Web Push 越权测试。 - **验收标准**:抓取插件通信内容时不存在主配置、DSN、其他插件配置或无关用户设置,任何网络连接均命中明确白名单和能力授权。 - **回退方式**:停用插件,不回退到复制完整配置文件。 -- **验收证据**:待补充。 +- **验收证据**:`go test ./hooks/... -count=1` 通过;握手集合、配置代次、插件能力、响应上限、Secret 隔离和 Hook 注册前健康检查测试通过。 ### CG-019 改造 spam_block 插件源码 -- **状态**:未开始 +- **状态**:[✓] 复审通过 - **优先级**:P1 - **依赖**:CG-018 - **设计映射**:第 21~22 章 @@ -401,11 +408,11 @@ - **测试要求**:正常规则、恶意正则或超长输入、错误配置、RPC 重放和进程退出测试。 - **验收标准**:插件可由新管理器启动、配置、检查并处理 Hook,源码不再引用旧主配置包。 - **回退方式**:禁用 `spam_block`,核心邮件服务继续运行。 -- **验收证据**:待补充。 +- **验收证据**:`go test ./hooks/spam_block -count=1` 通过;配置代次、能力权限、网络白名单、超长输入和尾随 JSON 拒绝测试通过。 ### CG-020 改造 wechat_push 插件源码 -- **状态**:未开始 +- **状态**:[✓] 复审通过 - **优先级**:P1 - **依赖**:CG-018 - **设计映射**:第 21~22 章 @@ -415,11 +422,11 @@ - **测试要求**:凭据缺失、无效响应、超时、SSRF 目标替换、用户配置越权和脱敏测试。 - **验收标准**:插件运行不需要磁盘配置,网络只能访问授权目标。 - **回退方式**:禁用 `wechat_push`,保留配置密文。 -- **验收证据**:待补充。 +- **验收证据**:`go test ./hooks/wechat_push -count=1` 通过;Secret 脱敏、配置代次、能力权限、网络目标、域名校验和尾随 JSON 拒绝测试通过。 ### CG-021 改造 telegram_push 插件源码 -- **状态**:未开始 +- **状态**:[✓] 复审通过 - **优先级**:P1 - **依赖**:CG-018 - **设计映射**:第 21~22 章 @@ -429,7 +436,7 @@ - **测试要求**:三角色配置矩阵、Chat ID 校验、Token 脱敏、网络失败、错误响应和事件用户映射测试。 - **验收标准**:全局 Token 和用户 Chat ID 完全分离,插件只接收当前事件所需用户配置。 - **回退方式**:禁用 `telegram_push`,不将 Token 写回旧配置。 -- **验收证据**:待补充。 +- **验收证据**:`go test ./plugins/pmail_telegram_push/... -count=1` 通过;三角色配置服务、Chat ID、Token 脱敏、配置代次、网络目标和设置字段测试通过。 ### CG-022 拆分 SMTP 和邮箱策略配置 @@ -1191,3 +1198,18 @@ CG-053~CG-056 → AD-066 → CG-057 30. AD-066 尚未完成独立清单最终发布评审或未向 CG-057 提供聚合验收证据。 完成上述 57 项任务并通过 30 项发布阻塞条件检查后,才能将配置系统重构进入最终发布评审。 + +--- + +## 2026-08-28 CG-016~CG-021 插件配置链路实施记录 + + - **本轮状态**:`[✓] 复审通过` +- **涉及任务**:CG-016、CG-017、CG-018、CG-019、CG-020、CG-021。 +- **修改文件**:`server/plugins/catalog/catalog.go`、`server/plugins/catalog/catalog_test.go`、`server/hooks/framework/framework.go`、`server/hooks/base.go`、`server/hooks/base_test.go`、`server/hooks/spam_block/`、`server/hooks/wechat_push/`、`plugins/pmail_telegram_push/hook/`。 +- **实施摘要**:补齐插件目录中的逻辑 ID、可执行文件、权限能力、握手能力和设置字段声明;插件启动握手严格校验 ID、协议版本、能力集合和设置字段集合;运行时配置增加非零配置代次,主程序只向已启用且能力匹配的插件下发专属配置;插件继续只从受控 Secret 服务取得自身密钥,并拒绝旧密钥字段、未知能力、未知设置和未授权网络目标。 + - **测试命令**:`go test ./... -count=1`(`server`)、`go test ./... -count=1`(`plugins/pmail_telegram_push`)、`go test -race ./hooks/... ./plugins/catalog ./services/plugin -count=1`(`server`)、`go test -race ./hook -count=1`(`plugins/pmail_telegram_push`)、`go vet ./...`、`git diff --check`。 + - **当前测试结果**:本轮 `server` 全量测试、Telegram 插件全量测试、服务端 `go vet ./...`、服务端插件配置链路竞态测试和 Telegram 插件竞态测试均通过;目录声明专项测试通过;`git diff --check` 通过。 +- **安全检查**:新增代次为零拒绝、握手能力严格集合匹配、运行时配置只携带当前插件字段;未发现 Secret 进入错误信息的新增路径。 +- **未完成验收**:真实 Ubuntu 22.04/24.04、Windows 生产插件隔离、真实 MySQL/PostgreSQL、真实浏览器、生产 SMTP/IMAP/POP3、多实例部署和长期日志观测仍未完成,不能据此视为最终发布验收通过。 +- **回退验证**:未删除既有文件、配置或数据库;如复审不通过,可通过停用插件回退,不恢复复制完整主配置文件的旧路径。 + - **复审人**:Codex(2026-08-28,本机自动化复审) diff --git a/fe/src/i18n/i18n.js b/fe/src/i18n/i18n.js index bbdac08a..03224ded 100644 --- a/fe/src/i18n/i18n.js +++ b/fe/src/i18n/i18n.js @@ -55,33 +55,89 @@ const lang = { "setDatabase": "数据库设置", "setAdminPassword": "密码设置", "admin_account": "管理员账号", + "err_account_required": "请输入管理员账号", + "err_admin_pwd_length": "管理员密码长度必须为 8 到 12 个字节", + "admin_pwd_desc": "请输入 8 到 12 个字节的管理员密码", + "setup_failed": "初始化操作失败,请查看终端日志", "setOther": "其他设置", "welcome": "欢迎", "next": "下一步", + "previous": "上一步", "tks_smail": "感谢使用Smail", "guid_desc": "接下来将会指引你进行初始化配置,如果你已有配置,请使用你的配置文件覆盖运行目录的config文件夹。如果你没有配置过,请按照该指引操作。", "select_db": "数据库选择", - "db_desc": "Smail目前支持MySQL和SQLite3两种数据库,你可根据需要选择。", + "db_desc": "Smail支持 MySQL、PostgreSQL 和 SQLite3,可根据部署环境选择。提交后系统会自动初始化所需的数据表。", "type": "类型", "db_select_ph": "请选择你的数据库", "mysql_dsn": "MySQL DSN", + "mysql_create_desc": "填写 MySQL 连接信息。提交后,系统会自动创建数据库并初始化所需的数据表。", + "postgres_create_desc": "填写 PostgreSQL 连接信息。提交后,系统会自动创建数据库并初始化所需的数据表。", + "db_user": "数据库用户", + "db_user_ph": "请输入数据库用户名", + "db_host": "主机地址", + "db_host_ph": "请输入数据库主机地址", + "db_port": "端口", + "db_port_ph": "请输入数据库端口", + "db_name": "数据库名", + "db_name_ph": "请输入数据库名称", + "db_password": "数据库密码", + "db_password_ph": "请输入数据库密码", + "db_password_desc": "修改已有配置时可以留空,系统会尝试继续使用原密码。", + "db_user_required": "请输入数据库用户", + "db_host_required": "请输入数据库主机地址", + "db_port_required": "请输入数据库端口", + "db_name_required": "请输入数据库名", + "db_init_success": "数据库连接成功,数据库和数据表已初始化", + "db_init_failed": "数据库初始化失败,请检查连接信息和数据库权限", + "pg_user_ph": "请输入 PostgreSQL 用户名", + "pg_password_ph": "请输入 PostgreSQL 密码", "pg_dsn": "PostgreSQL DSN", "sqlite_db_path": "存储位置", "domain_desc": "设置你的域名信息。", "smtp_domain": "SMTP域名地址", "web_domain": "Web域名地址", "dns_desc": "请将以下信息添加到DNS记录中", + "dns_setup_step": "\u7b2c 5 \u6b65\uff1a\u6dfb\u52a0 DNS \u8bb0\u5f55", + "dns_record_format": "\u8bb0\u5f55\u5df2\u6309\u7167\u5e38\u89c1\u57df\u540d\u670d\u52a1\u5546\u683c\u5f0f\u751f\u6210\uff0cTTL \u9ed8\u8ba4\u4e3a 10 \u5206\u949f", + "dns_domain_suffix": "\u8bf7\u6309\u5f53\u524d\u57df\u540d\u6dfb\u52a0\u4ee5\u4e0b\u8bb0\u5f55", + "dns_host": "\u4e3b\u673a\u540d", + "dns_type": "\u7c7b\u578b", + "dns_value": "\u8bb0\u5f55\u503c", + "dns_ttl": "TTL", + "dns_ttl_unit": "\u79d2", + "dns_ttl_hour": "\u5c0f\u65f6", + "dns_ttl_minute": "\u5206\u949f", + "dns_ttl_second": "\u79d2", + "dns_record_count": "\u6761\u8bb0\u5f55", + "dns_copy": "\u590d\u5236", + "dns_copy_success": "\u8bb0\u5f55\u503c\u5df2\u590d\u5236", + "dns_copy_failed": "\u590d\u5236\u5931\u8d25\uff0c\u8bf7\u624b\u52a8\u590d\u5236", + "dns_empty": "\u6682\u65e0 DNS \u8bb0\u5f55", + "dns_ip_source": "邮件记录使用服务器探测到的公网地址;Web 记录使用 Web 域名当前解析结果,因此两者可能不同。Ubuntu 内网地址(例如 192.168.2.3)不能直接填写到公网 DNS。", + "dns_ipv6_unavailable": "\u5f53\u524d\u672a\u68c0\u6d4b\u5230\u53ef\u7528\u4e8e\u516c\u7f51 DNS \u7684 IPv6 \u5730\u5740\uff0c\u56e0\u6b64\u672a\u751f\u6210 AAAA \u8bb0\u5f55\uff0c\u4e5f\u672a\u5728 SPF \u4e2d\u52a0\u5165 ip6 \u6761\u76ee\u3002\u94fe\u8def\u672c\u5730\u5730\u5740\uff08\u5982 fe80::/10\uff09\u4e0d\u53ef\u7528\u4e8e\u516c\u7f51 DNS。", "ssl_auto": "自动配置SSL证书(推荐)", "oomain_service_provider": "域名服务商", "ssl_auto_http": "HTTP请求", "ssl_auto_dns": "DNS记录", "ssl_challenge_type": "验证方式", "ssl_manuallyf": "手动配置SSL证书", - "challenge_typ_desc": "如果Smail直接使用80端口,建议使用HTTP验证方式。", + "challenge_typ_desc": "HTTP验证要求域名可以从公网访问80端口;无法开放80端口时,请选择DNS验证并添加页面生成的TXT记录。", "wait_desc": "请稍等", "dns_challenge_wait": "DNS传播和缓存刷新时间较长,此处可能等待10-30分钟", - "ssl_key_path": "ssl key文件位置", - "ssl_crt_path": "ssl crt文件位置", + "ssl_key_path": "SSL 私钥路径", + "ssl_crt_path": "SSL 证书路径", + "ssl_auto_storage_title": "自动证书保存位置", + "ssl_auto_storage_desc": "自动申请成功后,证书由系统统一保存和轮换,不需要手动填写证书路径。", + "ssl_auto_certificate_path": "证书:./config/ssl/managed/default/current/public.crt", + "ssl_auto_private_key_path": "私钥:./config/ssl/managed/default/current/private.key", + "ssl_auto_account_key_path": "ACME 账户密钥:./config/ssl/account_private.pem", + "ssl_manual_key_desc": "填写运行目录下的私钥相对路径,例如 ./config/ssl/private.key。", + "ssl_manual_crt_desc": "填写运行目录下的证书相对路径,例如 ./config/ssl/public.crt;证书必须与私钥匹配。", + "ssl_dns_title": "DNS验证记录", + "ssl_dns_desc": "选择DNS验证后,点击“下一步”生成本次申请所需的TXT记录。添加记录并等待DNS生效后,再继续验证。", + "ssl_dns_waiting": "正在生成DNS验证记录,请稍候……", + "ssl_dns_ready": "请将以下TXT记录添加到域名DNS中,确认解析已生效后点击“继续验证”。", + "ssl_verify": "继续验证", "group_settings": "分组", "add_group": "新建分组", "del_email_confirm": "你确定要删除吗?", @@ -110,7 +166,7 @@ const lang = { "move": "移动分组", "del_rule_confirm": "确定要删除吗?", "rule_params": "执行参数", - "autoSSLWarn": "Smail当前未使用80端口启动,如果想要Smail自动管理SSL证书,请将/.well-known/*路由转发到Smail。 详见https://git.pcux.cn/xuans/Smail/issues/94", + "autoSSLWarn": "当前服务未监听80端口,HTTP验证可能无法完成。请开放80端口,或将/.well-known/acme-challenge/转发到Smail;无法开放时请改用DNS验证。", "err_db_dsn_empty": "数据库路径不能为空!", "modify_pwd_desc": "修改您的账户密码以确保安全。", "current_pwd": "当前密码", diff --git a/fe/src/views/Setup/Setup.css b/fe/src/views/Setup/Setup.css index 81664df1..4274c8b7 100644 --- a/fe/src/views/Setup/Setup.css +++ b/fe/src/views/Setup/Setup.css @@ -57,16 +57,617 @@ animation: pm-rise-in 0.46s var(--pm-ease-out); } +.setup-actions { + display: flex; + align-items: center; + justify-content: flex-end; + gap: 12px; + margin-top: 12px; +} + +#previous, #next { - align-self: flex-end; border-radius: 999px; padding: 10px 22px; font-weight: 600; +} + +#next { box-shadow: 0 10px 24px rgba(0, 113, 227, 0.24); transition: transform 0.2s var(--pm-ease-out), box-shadow 0.2s var(--pm-ease-out); } +#previous { + color: var(--pm-text-secondary); + border-color: var(--pm-glass-border); + background: rgba(255, 255, 255, 0.55); +} + +#previous:hover { + color: var(--pm-text-primary); + border-color: rgba(0, 113, 227, 0.28); + background: rgba(255, 255, 255, 0.82); +} + #next:hover { transform: translateY(-1px); box-shadow: 0 14px 28px rgba(0, 113, 227, 0.28); } + +.database-form { + width: min(100%, 620px); +} + +.database-form .el-form { + width: 100%; +} + +.mysql-fields { + padding: 16px 18px 4px; + border: 1px solid var(--pm-glass-border); + border-radius: var(--pm-radius-lg); + background: rgba(255, 255, 255, 0.45); +} + +.database-hint { + margin: 0 0 18px; + color: var(--pm-text-secondary); + font-size: 13px; + line-height: 1.7; +} + +.database-inline-fields { + display: grid; + grid-template-columns: minmax(0, 1fr) 180px; + gap: 16px; +} + +.database-inline-fields .el-form-item { + min-width: 0; +} + +.database-host-field, +.database-port-field { + margin-bottom: 18px; +} + +.database-field-tip { + margin-top: 6px; + color: var(--pm-text-secondary); + font-size: 12px; + line-height: 1.5; +} + +.password-rule-tip { + margin-top: 6px; + color: var(--pm-text-secondary); + font-size: 12px; + line-height: 1.5; +} + +.ssl-form { + width: min(100%, 720px); +} + +.ssl-form .el-form { + width: 100%; +} + +.ssl-form .el-select, +.ssl-form .el-input { + width: 100%; +} + +.ssl-type-select :deep(.el-input__inner) { + overflow: visible; + text-overflow: clip; + white-space: nowrap; +} + +.ssl-storage-card { + margin: 0 0 18px 120px; + padding: 14px 16px; + border: 1px solid rgba(0, 113, 227, 0.16); + border-radius: var(--pm-radius-lg); + background: rgba(0, 113, 227, 0.06); +} + +.ssl-storage-title { + color: var(--pm-text-primary); + font-size: 14px; + font-weight: 700; +} + +.ssl-storage-desc, +.ssl-manual-desc, +.ssl-dns-intro { + margin-top: 6px; + color: var(--pm-text-secondary); + font-size: 12px; + line-height: 1.6; +} + +.ssl-port-warning { + display: flex; + align-items: center; + gap: 14px; + min-height: 46px; + padding: 0 18px; + color: #d9485f; + background: rgba(255, 241, 243, 0.96); + border: 1px solid rgba(217, 72, 95, 0.14); + border-radius: var(--pm-radius-lg); + overflow: hidden; + white-space: nowrap; +} + +.ssl-port-warning strong { + flex: none; + font-size: 14px; +} + +.ssl-port-warning span { + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; + font-size: 13px; +} + +.ssl-dns-challenge { + display: flex; + flex-direction: column; + gap: 12px; + padding: 16px 20px; + border: 1px solid rgba(0, 113, 227, 0.16); + border-radius: var(--pm-radius-lg); + background: rgba(0, 113, 227, 0.05); +} + +.ssl-dns-challenge-header { + display: flex; + align-items: center; + justify-content: space-between; + gap: 16px; +} + +.ssl-dns-challenge-header h3 { + margin: 0; + color: var(--pm-text-primary); + font-size: 16px; +} + +.ssl-dns-challenge-header p { + margin: 5px 0 0; + color: var(--pm-text-secondary); + font-size: 13px; + line-height: 1.5; +} + +.ssl-dns-record-count { + flex: none; + color: var(--pm-brand); + font-size: 13px; + font-weight: 700; +} + +.ssl-dns-value { + overflow-wrap: anywhere; + color: var(--pm-text-primary); + font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; + font-size: 12px; + line-height: 1.5; +} + +.ssl-storage-path { + margin-top: 5px; + color: var(--pm-text-primary); + font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; + font-size: 12px; + line-height: 1.5; + overflow-wrap: anywhere; +} + +.dns-panel { + display: flex; + flex-direction: column; + gap: 24px; + padding: 30px; + border: 1px solid var(--pm-glass-border); + border-radius: var(--pm-radius-xl); + background: var(--pm-surface-glass); + box-shadow: var(--pm-shadow-md); + animation: pm-rise-in 0.46s var(--pm-ease-out); +} + +.dns-header { + display: flex; + align-items: flex-start; + justify-content: space-between; + gap: 28px; +} + +.dns-heading { + flex: 1; + margin: 0; +} + +.dns-eyebrow { + margin-bottom: 8px; + color: var(--pm-brand); + font-size: 13px; + font-weight: 700; + letter-spacing: 0.08em; +} + +.dns-heading h2 { + margin: 0; + color: var(--pm-text-primary); + font-size: clamp(32px, 3vw, 42px); + font-weight: 700; + letter-spacing: -0.03em; +} + +.dns-description { + margin-top: 12px; + color: var(--pm-text-secondary); + font-size: 15px; + line-height: 1.7; +} + +.dns-header-note { + max-width: 300px; + padding: 12px 16px; + border: 1px solid rgba(0, 113, 227, 0.16); + border-radius: var(--pm-radius-lg); + background: rgba(0, 113, 227, 0.06); + color: var(--pm-text-secondary); + font-size: 13px; + line-height: 1.6; +} + +.dns-header-notes { + display: flex; + flex: 0 0 min(360px, 34%); + flex-direction: column; + gap: 8px; +} + +.dns-header-notes .dns-header-note { + max-width: none; +} + +.dns-header-note-secondary { + border-color: rgba(16, 185, 129, 0.18); + background: rgba(16, 185, 129, 0.07); +} + +.dns-header-note-ipv6 { + border-color: rgba(245, 158, 11, 0.2); + background: rgba(245, 158, 11, 0.08); +}.dns-domain-list { + display: flex; + flex-direction: column; + gap: 22px; +} + +.dns-domain-card { + overflow: hidden; + border: 1px solid var(--pm-glass-border); + border-radius: var(--pm-radius-lg); + background: rgba(255, 255, 255, 0.58); +} + +.dns-domain-header { + display: flex; + align-items: center; + justify-content: space-between; + gap: 16px; + padding: 18px 20px; + border-bottom: 1px solid var(--pm-glass-border); + background: rgba(255, 255, 255, 0.48); +} + +.dns-domain-header h3 { + margin: 0; + color: var(--pm-text-primary); + font-size: 20px; + font-weight: 700; +} + +.dns-domain-header .dns-domain-suffix { + display: block; + margin-top: 5px; + color: var(--pm-text-secondary); + font-size: 12px; +} + +.dns-domain-count { + display: inline-flex; + flex: 0 0 auto; + align-items: center; + justify-content: center; + min-height: 28px; + padding: 0 12px; + line-height: 1; + white-space: nowrap; +} + +.dns-table { + width: 100%; +} + +.dns-table :deep(.el-table__cell) { + padding: 13px 0; + vertical-align: top; +} + +.dns-table :deep(.cell) { + min-height: 24px; + color: var(--pm-text-primary); + line-height: 1.55; + white-space: normal; + overflow: visible; +} + +.dns-host { + display: inline-block; + max-width: 100%; + color: var(--pm-text-primary); + font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; + font-size: 13px; + font-weight: 600; + white-space: nowrap; + overflow-wrap: anywhere; +} + +.dns-host-root { + padding: 3px 9px; + border-radius: 6px; + background: rgba(0, 113, 227, 0.08); + color: var(--pm-brand); +} + +.dns-type { + display: inline-flex; + min-width: 52px; + align-items: center; + justify-content: center; + padding: 3px 9px; + border-radius: 999px; + background: rgba(100, 116, 139, 0.12); + color: var(--pm-text-secondary); + font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; + font-size: 12px; + font-weight: 700; +} + +.dns-type-a, +.dns-type-aaaa { + background: rgba(16, 185, 129, 0.12); + color: #047857; +} + +.dns-type-mx { + background: rgba(245, 158, 11, 0.15); + color: #b45309; +} + +.dns-type-txt { + background: rgba(124, 58, 237, 0.12); + color: #6d28d9; +} + +.dns-value-cell { + position: relative; + display: flex; + align-items: flex-start; + min-width: 0; + padding-right: 42px; +} + +.dns-value { + display: block; + min-width: 0; + flex: 1; + color: var(--pm-text-primary); + font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; + font-size: 13px; + line-height: 1.6; + overflow-wrap: anywhere; + word-break: break-word; +} + +.dns-value-long { + padding: 8px 10px; + border-radius: 7px; + background: rgba(0, 113, 227, 0.05); +} + +.dns-copy-button { + position: absolute; + top: -4px; + right: 0; + opacity: 0; + transition: opacity 0.2s ease; +} + +.dns-table :deep(.el-table__row:hover) .dns-copy-button, +.dns-copy-button:focus-visible { + opacity: 1; +} + +.dns-ttl { + color: var(--pm-text-secondary); + font-variant-numeric: tabular-nums; + white-space: nowrap; +} + +/* 桌面端 DNS 页面使用紧凑布局,确保记录和操作按钮在首屏完整显示。 */ +#main.dns-page { + box-sizing: border-box; + gap: 10px; + padding: 14px 30px 12px; + overflow: hidden; +} + +.dns-page #status { + flex: none; + padding: 10px 18px; +} + +.dns-page .dns-panel { + flex: 1; + min-height: 0; + gap: 12px; + padding: 16px 20px; +} + +.dns-page .dns-header { + gap: 20px; +} + +.dns-page .dns-eyebrow { + margin-bottom: 4px; + font-size: 12px; +} + +.dns-page .dns-heading h2 { + font-size: clamp(28px, 2.4vw, 36px); +} + +.dns-page .dns-description { + margin-top: 5px; + font-size: 13px; + line-height: 1.5; +} + +.dns-page .dns-header-note { + max-width: 280px; + padding: 8px 12px; + font-size: 12px; + line-height: 1.45; +} + +.dns-page .dns-header-notes { + flex-basis: min(320px, 34%); +} + +.dns-page .dns-domain-list { + gap: 8px; +} + +.dns-page .dns-domain-header { + padding: 9px 14px; +} + +.dns-page .dns-domain-header h3 { + font-size: 17px; +} + +.dns-page .dns-domain-header .dns-domain-suffix { + margin-top: 2px; + font-size: 11px; +} + +.dns-page .dns-table :deep(.el-table__cell) { + padding: 7px 0; +} + +.dns-page .dns-table :deep(.cell) { + min-height: 20px; + font-size: 12px; + line-height: 1.35; +} + +.dns-page .dns-host, +.dns-page .dns-value { + font-size: 12px; + line-height: 1.35; +} + +.dns-page .dns-host-root, +.dns-page .dns-type { + padding-top: 2px; + padding-bottom: 2px; +} + +.dns-page .dns-value-long { + padding: 4px 7px; +} + +.dns-page #next { + flex: none; + min-height: 36px; + padding: 8px 20px; +} + +.dns-page .setup-actions { + flex: none; + margin-top: 0; +} + +@media (max-width: 760px) { + #main { + padding: 16px; + } + + .ctn { + flex-direction: column; + align-items: stretch; + padding: 18px; + } + + .database-inline-fields { + grid-template-columns: 1fr; + gap: 0; + } + + .dns-panel { + padding: 18px; + } + + #main.dns-page { + gap: 8px; + padding: 10px; + overflow-y: auto; + } + + .dns-page .dns-panel { + padding: 14px; + } + + .dns-header { + flex-direction: column; + gap: 16px; + } + + .dns-header-note { + max-width: none; + } + + .dns-header-notes { + width: 100%; + flex-basis: auto; + } + + .ssl-storage-card { + margin-left: 0; + } + + .dns-domain-header { + align-items: flex-start; + flex-direction: column; + } + + .dns-table { + min-width: 720px; + } + + .dns-value-cell { + gap: 8px; + } + + .dns-copy-button { + opacity: 1; + } +} diff --git a/fe/src/views/Setup/Setup.js b/fe/src/views/Setup/Setup.js index 3fd2d06c..f593ce0d 100644 --- a/fe/src/views/Setup/Setup.js +++ b/fe/src/views/Setup/Setup.js @@ -1,6 +1,6 @@ import './Setup.js' -import {reactive, ref} from 'vue' +import {computed, reactive, ref} from 'vue' import {ElMessage} from 'element-plus' @@ -25,7 +25,12 @@ export function usePage() { const dbSettings = reactive({ "type": "sqlite", "dsn": "./config/smail.db", - "lable": "" + "mode": "fields", + "user": "", + "host": "127.0.0.1", + "port": "3306", + "password": "", + "name": "smail" }) const domainSettings = reactive({ @@ -45,10 +50,16 @@ export function usePage() { const active = ref(0) const fullscreenLoading = ref(false) + + const databaseLoading = ref(false) const dnsChecking = ref(false) const dnsInfos = ref({}) + + const hasDNSIPv6 = computed(() => Object.values(dnsInfos.value).some((records) => + records.some((record) => record.type === 'AAAA') + )) const port = ref(80) @@ -62,24 +73,40 @@ export function usePage() { getDomainConfig(); return; } - + + const passwordSize = new TextEncoder().encode(adminSettings.password).length + if (!adminSettings.account.trim()) { + ElMessage.error(lang.err_account_required) + return + } + if (!adminSettings.password) { + ElMessage.error(lang.err_required_pwd) + return + } + if (passwordSize < 8 || passwordSize > 12) { + ElMessage.error(lang.err_admin_pwd_length) + return + } if (adminSettings.password !== adminSettings.password2) { ElMessage.error(lang.err_pwd_diff) - } else { - http.post("/api/setup", { - "action": "set", - "step": "password", - "account": adminSettings.account, - "password": adminSettings.password - }).then((res) => { - if (res.errorNo !== 0) { - ElMessage.error(res.errorMsg) - } else { - active.value++; - getDomainConfig(); - } - }) + return } + + http.post("/api/setup", { + "action": "set", + "step": "password", + "account": adminSettings.account, + "password": adminSettings.password + }).then((res) => { + if (res.errorNo !== 0) { + ElMessage.error(res.errorMsg || lang.setup_failed) + } else { + active.value++; + getDomainConfig(); + } + }).catch(() => { + ElMessage.error(lang.setup_failed) + }) } const getPassword = () => { @@ -104,7 +131,13 @@ export function usePage() { ElMessage.error(res.errorMsg) } else { dbSettings.type = res.data.db_type; - dbSettings.dsn = res.data.db_dsn; + dbSettings.mode = res.data.db_mode || "dsn"; + dbSettings.dsn = res.data.db_dsn || ""; + dbSettings.user = res.data.db_user || ""; + dbSettings.host = res.data.db_host || "127.0.0.1"; + dbSettings.port = res.data.db_port || (dbSettings.type === "postgres" ? "5432" : "3306"); + dbSettings.password = ""; + dbSettings.name = res.data.db_name || "smail"; } }) } @@ -122,27 +155,78 @@ export function usePage() { } const setDbConfig = () => { - // 切换数据库类型为sqlite时,数据库路径为空,则使用默认路径 - if (dbSettings.type === "sqlite" && !dbSettings.dsn) dbSettings.dsn = "./config/smail.db"; - else if (!dbSettings.dsn) ElMessage({ - title: "Error", - message: lang.err_db_dsn_empty, - type: "error", - }); - http.post("/api/setup", { + if (dbSettings.type === "sqlite" && !dbSettings.dsn) { + dbSettings.dsn = "./config/smail.db"; + } + + const usesStructuredFields = dbSettings.type === "mysql" || dbSettings.type === "postgres" + if (usesStructuredFields) { + if (!dbSettings.user.trim()) { + ElMessage.error(lang.db_user_required) + return + } + if (!dbSettings.host.trim()) { + ElMessage.error(lang.db_host_required) + return + } + if (!dbSettings.port.trim()) { + ElMessage.error(lang.db_port_required) + return + } + if (!dbSettings.name.trim()) { + ElMessage.error(lang.db_name_required) + return + } + } else if (!dbSettings.dsn.trim()) { + ElMessage.error(lang.err_db_dsn_empty) + return + } + + databaseLoading.value = true + const payload = { "action": "set", "step": "database", "db_type": dbSettings.type, - "db_dsn": dbSettings.dsn - }).then((res) => { + "db_dsn": dbSettings.dsn, + "db_mode": usesStructuredFields ? "fields" : "dsn", + "db_user": dbSettings.user, + "db_host": dbSettings.host, + "db_port": dbSettings.port, + "db_password": dbSettings.password, + "db_name": dbSettings.name + } + + http.post("/api/setup", payload).then((res) => { if (res.errorNo !== 0) { - ElMessage.error(res.errorMsg) - } else { - active.value++; - getPassword(); + ElMessage.error(res.errorMsg || lang.db_init_failed) + return } + ElMessage.success(lang.db_init_success) + active.value++; + getPassword(); + }).catch(() => { + ElMessage.error(lang.db_init_failed) + }).finally(() => { + databaseLoading.value = false }) } + + const handleDbTypeChange = (type) => { + dbSettings.dsn = "" + dbSettings.password = "" + if (type === "mysql" || type === "postgres") { + dbSettings.mode = "fields" + dbSettings.host = "127.0.0.1" + dbSettings.port = type === "postgres" ? "5432" : "3306" + dbSettings.name = "smail" + } else { + dbSettings.mode = "dsn" + dbSettings.dsn = "./config/smail.db" + dbSettings.host = "127.0.0.1" + dbSettings.port = "" + dbSettings.name = "" + } + } const getDNSConfig = () => { http.post("/api/setup", {"action": "get", "step": "dns"}).then((res) => { @@ -153,6 +237,37 @@ export function usePage() { } }) } + + const copyDNSValue = async (value) => { + try { + if (navigator.clipboard && window.isSecureContext) { + await navigator.clipboard.writeText(value) + } else { + const input = document.createElement('textarea') + input.value = value + input.setAttribute('readonly', '') + input.style.position = 'fixed' + input.style.opacity = '0' + document.body.appendChild(input) + input.select() + document.execCommand('copy') + document.body.removeChild(input) + } + ElMessage.success(lang.dns_copy_success) + } catch (error) { + ElMessage.error(lang.dns_copy_failed) + } + } + + const formatDNSRecordTTL = (ttl) => { + if (ttl >= 3600 && ttl % 3600 === 0) { + return `${ttl / 3600}${lang.dns_ttl_hour}` + } + if (ttl >= 60 && ttl % 60 === 0) { + return `${ttl / 60}${lang.dns_ttl_minute}` + } + return `${ttl}${lang.dns_ttl_second}` + } const getSSLConfig = () => { http.post("/api/setup", {"action": "get", "step": "ssl"}).then((res) => { @@ -191,10 +306,11 @@ export function usePage() { fullscreenLoading.value = false; ElMessage.error(res.errorMsg) } else { - if (sslType === 2) { + if (sslType === "2") { fullscreenLoading.value = false; dnsChecking.value = true; getSSLDNSParams(); + return } checkStatus(); } @@ -202,22 +318,18 @@ export function usePage() { } const checkStatus = () => { - axios.post("/api/ping", {}).then((res) => { - if (res.data.errorNo !== 0) { - setTimeout(function () { - checkStatus() - }, 1000); - } else { - if (sslSettings.type === 1) { + http.post("/api/setup", {"action": "get", "step": "ssl"}).then((res) => { + if (res.errorNo === 0 && res.data.ready) { + if (sslSettings.type === "1") { window.location.href = "http://" + domainSettings.web_domain; } else { window.location.href = "https://" + domainSettings.web_domain; } + return } + setTimeout(checkStatus, 1000) }).catch(() => { - setTimeout(function () { - checkStatus() - }, 1000); + setTimeout(checkStatus, 1000) }) } @@ -243,17 +355,12 @@ export function usePage() { if (res.errorNo !== 0) { ElMessage.error(res.errorMsg) } else { - sslSettings.paramsList = res.data + sslSettings.paramsList = Array.isArray(res.data) ? res.data : [] + if (dnsChecking.value && sslSettings.paramsList.length === 0) { + setTimeout(getSSLDNSParams, 1000) + } } }) - - if (sslSettings.paramsList.length === 0) { - setTimeout(function () { - getSSLDNSParams() - }, 1000); - } - - } const next = () => { @@ -279,6 +386,7 @@ export function usePage() { if (dnsChecking.value) { fullscreenLoading.value = true; waitDesc.value = lang.dns_challenge_wait; + checkStatus(); } else { setSSLConfig(); } @@ -287,6 +395,12 @@ export function usePage() { } + const previous = () => { + if (active.value > 0) { + active.value-- + } + } + return { reactive, ref, @@ -298,12 +412,14 @@ export function usePage() { waitDesc, adminSettings, dbSettings, + databaseLoading, domainSettings, sslSettings, active, fullscreenLoading, dnsChecking, dnsInfos, + hasDNSIPv6, port, addDomain, setPassword, @@ -311,12 +427,16 @@ export function usePage() { getDbConfig, getDomainConfig, setDbConfig, + handleDbTypeChange, getDNSConfig, + formatDNSRecordTTL, + copyDNSValue, getSSLConfig, setSSLConfig, checkStatus, setDomainConfig, getSSLDNSParams, - next + next, + previous } } diff --git a/fe/src/views/Setup/Setup.vue b/fe/src/views/Setup/Setup.vue index d438ac92..ae5e6cf6 100644 --- a/fe/src/views/Setup/Setup.vue +++ b/fe/src/views/Setup/Setup.vue @@ -1,5 +1,5 @@ @@ -231,6 +325,7 @@ const { active, lang, dbSettings, + databaseLoading, adminSettings, domainSettings, addDomain, @@ -241,6 +336,10 @@ const { dnsChecking, waitDesc, next, + previous, + handleDbTypeChange, + formatDNSRecordTTL, + copyDNSValue, fullscreenLoading } = usePage() diff --git a/plugins/pmail_telegram_push/go.mod b/plugins/pmail_telegram_push/go.mod index f688ed74..12d6dc4b 100644 --- a/plugins/pmail_telegram_push/go.mod +++ b/plugins/pmail_telegram_push/go.mod @@ -2,22 +2,20 @@ module github.com/ydzydzydz/pmail_telegram_push go 1.25.1 -replace github.com/Jinnrry/pmail v2.8.7+incompatible => github.com/Jinnrry/pmail/server v0.0.0-20250830122511-778e279b4fae - require ( - github.com/Jinnrry/pmail v2.8.7+incompatible github.com/go-sql-driver/mysql v1.9.3 github.com/go-telegram/bot v1.17.0 github.com/lib/pq v1.10.9 github.com/microcosm-cc/bluemonday v1.0.27 github.com/phuslu/log v1.0.120 - golang.org/x/net v0.47.0 - modernc.org/sqlite v1.40.1 + golang.org/x/net v0.57.0 + modernc.org/sqlite v1.46.1 xorm.io/xorm v1.3.11 ) require ( - filippo.io/edwards25519 v1.1.0 // indirect + filippo.io/edwards25519 v1.1.1 // indirect + git.pcux.cn/xuans/Smail v0.0.0 github.com/aymerick/douceur v0.2.0 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/emersion/go-message v0.18.2 // indirect @@ -26,21 +24,20 @@ require ( github.com/golang/snappy v1.0.0 // indirect github.com/google/uuid v1.6.0 // indirect github.com/gorilla/css v1.0.1 // indirect - github.com/json-iterator/go v1.1.12 // indirect - github.com/mattn/go-isatty v0.0.20 // indirect - github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect - github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/mattn/go-isatty v0.0.21 // indirect github.com/ncruces/go-strftime v1.0.0 // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/sirupsen/logrus v1.9.3 // indirect github.com/spf13/cast v1.10.0 // indirect github.com/syndtr/goleveldb v1.0.0 // indirect - golang.org/x/crypto v0.45.0 // indirect - golang.org/x/exp v0.0.0-20251113190631-e25ba8c21ef6 // indirect - golang.org/x/sys v0.38.0 // indirect - golang.org/x/text v0.31.0 // indirect - modernc.org/libc v1.67.0 // indirect + golang.org/x/crypto v0.55.0 // indirect + golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f // indirect + golang.org/x/sys v0.47.0 // indirect + golang.org/x/text v0.41.0 // indirect + modernc.org/libc v1.67.6 // indirect modernc.org/mathutil v1.7.1 // indirect modernc.org/memory v1.11.0 // indirect xorm.io/builder v0.3.13 // indirect ) + +replace git.pcux.cn/xuans/Smail => ../../server diff --git a/plugins/pmail_telegram_push/go.sum b/plugins/pmail_telegram_push/go.sum index f5a5de1c..8bfbf4cd 100644 --- a/plugins/pmail_telegram_push/go.sum +++ b/plugins/pmail_telegram_push/go.sum @@ -1,9 +1,7 @@ -filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= -filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= +filippo.io/edwards25519 v1.1.1 h1:YpjwWWlNmGIDyXOn8zLzqiD+9TyIlPhGFG96P39uBpw= +filippo.io/edwards25519 v1.1.1/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a h1:lSA0F4e9A2NcQSqGqTOXqu2aRi/XEQxDCBwM8yJtE6s= gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:EXuID2Zs0pAQhH8yz+DNjUbjppKQzKFAn28TMYPB6IU= -github.com/Jinnrry/pmail/server v0.0.0-20250830122511-778e279b4fae h1:nPbyCN5LIJ35anS/GzODP6nQD9h7WLElshr/oyMZGrE= -github.com/Jinnrry/pmail/server v0.0.0-20250830122511-778e279b4fae/go.mod h1:nMOx35AsU/e1gbkIWGpEDtxOGRgePX47uE8Y916jfb4= github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk= github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -13,8 +11,6 @@ github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkp github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/emersion/go-message v0.18.2 h1:rl55SQdjd9oJcIoQNhubD2Acs1E6IzlZISRTK7x/Lpg= github.com/emersion/go-message v0.18.2/go.mod h1:XpJyL70LwRvq2a8rVbHXikPgKj8+aI0kGdHlg16ibYA= -github.com/emersion/go-msgauth v0.6.8 h1:kW/0E9E8Zx5CdKsERC/WnAvnXvX7q9wTHia1OA4944A= -github.com/emersion/go-msgauth v0.6.8/go.mod h1:YDwuyTCUHu9xxmAeVj0eW4INnwB6NNZoPdLerpSxRrc= github.com/emersion/go-msgauth v0.7.0 h1:vj2hMn6KhFtW41kshIBTXvp6KgYSqpA/ZN9Pv4g1INc= github.com/emersion/go-msgauth v0.7.0/go.mod h1:mmS9I6HkSovrNgq0HNXTeu8l3sRAAuQ9RMvbM4KU7Ck= github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= @@ -33,35 +29,27 @@ github.com/golang/snappy v1.0.0 h1:Oy607GVXHs7RtbggtPBnr2RmDArIsAefDwvrdWvRhGs= github.com/golang/snappy v1.0.0/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e h1:ijClszYn+mADRFY17kjQEVQ1XRhq2/JR1M3sGqeJoxs= github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/css v1.0.1 h1:ntNaBIghp6JmvWnxbZKANoLyuXTPZ4cAMlo6RyhlbO8= github.com/gorilla/css v1.0.1/go.mod h1:BvnYkspnSzMmwRK+b8/xgNPLiIuNZr6vbZBTPQ2A3b0= +github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k= +github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= -github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= -github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= -github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y= -github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= +github.com/mattn/go-isatty v0.0.21 h1:xYae+lCNBP7QuW4PUnNG61ffM4hVIfm+zUzDuSzYLGs= +github.com/mattn/go-isatty v0.0.21/go.mod h1:ZXfXG4SQHsB/w3ZeOYbR0PrPwLy+n6xiMrJlRFqopa4= +github.com/mattn/go-sqlite3 v1.14.32 h1:JD12Ag3oLy1zQA+BNn74xRgaBbdhbNIDYvQUEuuErjs= +github.com/mattn/go-sqlite3 v1.14.32/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/microcosm-cc/bluemonday v1.0.27 h1:MpEUotklkwCSLeH+Qdx1VJgNqLlpY2KXwXFM08ygZfk= github.com/microcosm-cc/bluemonday v1.0.27/go.mod h1:jFi9vgW+H7c3V0lb6nR74Ib/DIB5OBs92Dimizgw2cA= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= -github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4= -github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOFAw7w= github.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= github.com/nxadm/tail v1.4.11 h1:8feyoE3OzPrcshW5/MJ4sGESc5cqmGkGCWlco4l0bqY= @@ -83,51 +71,39 @@ github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= -github.com/spf13/cast v1.7.1 h1:cuNEagBQEHWN1FnbGEjCXL2szYEXqfJPbP2HNUaca9Y= -github.com/spf13/cast v1.7.1/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= github.com/spf13/cast v1.10.0 h1:h2x0u2shc1QuLHfxi+cTJvs30+ZAHOGRic8uyGTDWxY= github.com/spf13/cast v1.10.0/go.mod h1:jNfB8QC9IA6ZuY2ZjDp0KtFO2LZZlg4S/7bzP6qqeHo= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE= github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.43.0 h1:dduJYIi3A3KOfdGOHX8AVZ/jGiyPa3IbBozJ5kNuE04= -golang.org/x/crypto v0.43.0/go.mod h1:BFbav4mRNlXJL4wNeejLpWxB7wMbc79PdRGhWKncxR0= -golang.org/x/crypto v0.44.0 h1:A97SsFvM3AIwEEmTBiaxPPTYpDC47w720rdiiUvgoAU= -golang.org/x/crypto v0.44.0/go.mod h1:013i+Nw79BMiQiMsOPcVCB5ZIJbYkerPrGnOa00tvmc= -golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q= -golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4= -golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b h1:M2rDM6z3Fhozi9O7NWsxAkg/yqS/lQJ6PmkyIV3YP+o= -golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b/go.mod h1:3//PLf8L/X+8b4vuAfHzxeRUl04Adcb341+IGKfnqS8= -golang.org/x/exp v0.0.0-20251113190631-e25ba8c21ef6 h1:zfMcR1Cs4KNuomFFgGefv5N0czO2XZpUbxGUy8i8ug0= -golang.org/x/exp v0.0.0-20251113190631-e25ba8c21ef6/go.mod h1:46edojNIoXTNOhySWIWdix628clX9ODXwPsQuG6hsK0= +golang.org/x/crypto v0.55.0 h1:+KWHjbgOaAQ66dh/YlkZKHlz9ZUlq61AFirAR9ntP8M= +golang.org/x/crypto v0.55.0/go.mod h1:uq0V9dE/fzQuJtbnL+2EhWOE63vo164FY8xqEnV9xis= +golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f h1:W3F4c+6OLc6H2lb//N1q4WpJkhzJCK5J6kUi1NTVXfM= +golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f/go.mod h1:J1xhfL/vlindoeF/aINzNzt2Bket5bjo9sdOYzOsU80= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.28.0 h1:gQBtGhjxykdjY9YhZpSlZIsbnaE2+PgjfLWUQTnoZ1U= -golang.org/x/mod v0.28.0/go.mod h1:yfB/L0NOf/kmEbXjzCPOx1iK1fRutOydrCMsqRhEBxI= -golang.org/x/mod v0.30.0 h1:fDEXFVZ/fmCKProc/yAXXUijritrDzahmwwefnjoPFk= +golang.org/x/mod v0.38.0 h1:MECBjubtXD7yj4HrhIUcywNaGeNVUdfVnxmPajOk4yk= +golang.org/x/mod v0.38.0/go.mod h1:V6Xz0pq8TQ3dGqVQ1FVHuelZpAL0uNhSkk9ogYP3c40= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.46.0 h1:giFlY12I07fugqwPuWJi68oOnpfqFnJIJzaIIm2JVV4= -golang.org/x/net v0.46.0/go.mod h1:Q9BGdFy1y4nkUwiLvT5qtyhAnEHgnQ/zd8PfU6nc210= -golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY= -golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU= +golang.org/x/net v0.57.0 h1:K5+3DljvIuDG9/Jv9rvyMywYNFCQ9RSUY6OOTTkT+tE= +golang.org/x/net v0.57.0/go.mod h1:KpXc8iv+r3XplLAG/f7Jsf9RPszJzdR0f58q9vGOuEU= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug= -golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= -golang.org/x/sync v0.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I= +golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek= +golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -136,11 +112,8 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ= -golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= -golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc= -golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs= +golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= @@ -149,17 +122,14 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/text v0.30.0 h1:yznKA/E9zq54KzlzBEAWn1NXSQ8DIp/NYMy88xJjl4k= -golang.org/x/text v0.30.0/go.mod h1:yDdHFIX9t+tORqspjENWgzaCVXgk0yYnYuSZ8UzzBVM= -golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM= -golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM= +golang.org/x/text v0.41.0 h1:vz/seA0lnX87Othu2f/0L24RcgrXD9/YFTSuGjj3rH8= +golang.org/x/text v0.41.0/go.mod h1:jvf1O8ajNzZqhSrQBPbutR/EB83Cc0CFrezNQIwbb5M= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.37.0 h1:DVSRzp7FwePZW356yEAChSdNcQo6Nsp+fex1SUW09lE= -golang.org/x/tools v0.37.0/go.mod h1:MBN5QPQtLMHVdvsbtarmTNukZDdgwdwlO5qGacAzF0w= -golang.org/x/tools v0.39.0 h1:ik4ho21kwuQln40uelmciQPp9SipgNDdrafrYA4TmQQ= +golang.org/x/tools v0.48.0 h1:3+hClM1aLL5mjMKm5ovokw9epgRXPuu2tILgismM6RE= +golang.org/x/tools v0.48.0/go.mod h1:08xX0orndb/F7jJxGDicx061tyd5pcMto75YMAXr6lk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= @@ -169,23 +139,20 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -modernc.org/cc/v4 v4.26.2 h1:991HMkLjJzYBIfha6ECZdjrIYz2/1ayr+FL8GN+CNzM= -modernc.org/cc/v4 v4.26.2/go.mod h1:uVtb5OGqUKpoLWhqwNQo/8LwvoiEBLvZXIQ/SmO6mL0= modernc.org/cc/v4 v4.27.1 h1:9W30zRlYrefrDV2JE2O8VDtJ1yPGownxciz5rrbQZis= -modernc.org/ccgo/v4 v4.28.0 h1:rjznn6WWehKq7dG4JtLRKxb52Ecv8OUGah8+Z/SfpNU= -modernc.org/ccgo/v4 v4.28.0/go.mod h1:JygV3+9AV6SmPhDasu4JgquwU81XAKLd3OKTUDNOiKE= +modernc.org/cc/v4 v4.27.1/go.mod h1:uVtb5OGqUKpoLWhqwNQo/8LwvoiEBLvZXIQ/SmO6mL0= modernc.org/ccgo/v4 v4.30.1 h1:4r4U1J6Fhj98NKfSjnPUN7Ze2c6MnAdL0hWw6+LrJpc= -modernc.org/fileutil v1.3.8 h1:qtzNm7ED75pd1C7WgAGcK4edm4fvhtBsEiI/0NQ54YM= -modernc.org/fileutil v1.3.8/go.mod h1:HxmghZSZVAz/LXcMNwZPA/DRrQZEVP9VX0V4LQGQFOc= +modernc.org/ccgo/v4 v4.30.1/go.mod h1:bIOeI1JL54Utlxn+LwrFyjCx2n2RDiYEaJVSrgdrRfM= modernc.org/fileutil v1.3.40 h1:ZGMswMNc9JOCrcrakF1HrvmergNLAmxOPjizirpfqBA= +modernc.org/fileutil v1.3.40/go.mod h1:HxmghZSZVAz/LXcMNwZPA/DRrQZEVP9VX0V4LQGQFOc= modernc.org/gc/v2 v2.6.5 h1:nyqdV8q46KvTpZlsw66kWqwXRHdjIlJOhG6kxiV/9xI= modernc.org/gc/v2 v2.6.5/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito= +modernc.org/gc/v3 v3.1.1 h1:k8T3gkXWY9sEiytKhcgyiZ2L0DTyCQ/nvX+LoCljoRE= +modernc.org/gc/v3 v3.1.1/go.mod h1:HFK/6AGESC7Ex+EZJhJ2Gni6cTaYpSMmU/cT9RmlfYY= modernc.org/goabi0 v0.2.0 h1:HvEowk7LxcPd0eq6mVOAEMai46V+i7Jrj13t4AzuNks= modernc.org/goabi0 v0.2.0/go.mod h1:CEFRnnJhKvWT1c1JTI3Avm+tgOWbkOu5oPA8eH8LnMI= -modernc.org/libc v1.66.3 h1:cfCbjTUcdsKyyZZfEUKfoHcP3S0Wkvz3jgSzByEWVCQ= -modernc.org/libc v1.66.3/go.mod h1:XD9zO8kt59cANKvHPXpx7yS2ELPheAey0vjIuZOhOU8= -modernc.org/libc v1.67.0 h1:QzL4IrKab2OFmxA3/vRYl0tLXrIamwrhD6CKD4WBVjQ= -modernc.org/libc v1.67.0/go.mod h1:QvvnnJ5P7aitu0ReNpVIEyesuhmDLQ8kaEoyMjIFZJA= +modernc.org/libc v1.67.6 h1:eVOQvpModVLKOdT+LvBPjdQqfrZq+pC39BygcT+E7OI= +modernc.org/libc v1.67.6/go.mod h1:JAhxUVlolfYDErnwiqaLvUqc8nfb2r6S6slAgZOnaiE= modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU= modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg= modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI= @@ -194,19 +161,13 @@ modernc.org/opt v0.1.4 h1:2kNGMRiUjrp4LcaPuLY2PzUfqM/w9N23quVwhKt5Qm8= modernc.org/opt v0.1.4/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns= modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w= modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE= -modernc.org/sqlite v1.39.0 h1:6bwu9Ooim0yVYA7IZn9demiQk/Ejp0BtTjBWFLymSeY= -modernc.org/sqlite v1.39.0/go.mod h1:cPTJYSlgg3Sfg046yBShXENNtPrWrDX8bsbAQBzgQ5E= -modernc.org/sqlite v1.40.0 h1:bNWEDlYhNPAUdUdBzjAvn8icAs/2gaKlj4vM+tQ6KdQ= -modernc.org/sqlite v1.40.0/go.mod h1:9fjQZ0mB1LLP0GYrp39oOJXx/I2sxEnZtzCmEQIKvGE= -modernc.org/sqlite v1.40.1 h1:VfuXcxcUWWKRBuP8+BR9L7VnmusMgBNNnBYGEe9w/iY= -modernc.org/sqlite v1.40.1/go.mod h1:9fjQZ0mB1LLP0GYrp39oOJXx/I2sxEnZtzCmEQIKvGE= +modernc.org/sqlite v1.46.1 h1:eFJ2ShBLIEnUWlLy12raN0Z1plqmFX9Qe3rjQTKt6sU= +modernc.org/sqlite v1.46.1/go.mod h1:CzbrU2lSB1DKUusvwGz7rqEKIq+NUd8GWuBBZDs9/nA= modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0= modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A= modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y= modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= xorm.io/builder v0.3.13 h1:a3jmiVVL19psGeXx8GIurTp7p0IIgqeDmwhcR6BAOAo= xorm.io/builder v0.3.13/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE= -xorm.io/xorm v1.3.10 h1:yR83hTT4mKIPyA/lvWFTzS35xjLwkiYnwdw0Qupeh0o= -xorm.io/xorm v1.3.10/go.mod h1:Lo7hmsFF0F0GbDE7ubX5ZKa+eCf0eCuiJAUG3oI5cxQ= xorm.io/xorm v1.3.11 h1:i4tlVUASogb0ZZFJHA7dZqoRU2pUpUsutnNdaOlFyMI= xorm.io/xorm v1.3.11/go.mod h1:cs0ePc8O4a0jD78cNvD+0VFwhqotTvLQZv372QsDw7Q= diff --git a/plugins/pmail_telegram_push/hook/bot.go b/plugins/pmail_telegram_push/hook/bot.go index 0fdc3b3f..6592ace2 100644 --- a/plugins/pmail_telegram_push/hook/bot.go +++ b/plugins/pmail_telegram_push/hook/bot.go @@ -1,102 +1,34 @@ package hook import ( - "context" - "net" - "net/http" - "net/url" - "strings" "time" + "git.pcux.cn/xuans/Smail/utils/credential" "github.com/go-telegram/bot" - "github.com/ydzydzydz/pmail_telegram_push/config" "github.com/ydzydzydz/pmail_telegram_push/logger" - "golang.org/x/net/proxy" ) -// NewBot 创建一个新的 Telegram 机器人实例 -func NewBot(config *config.Config) (*bot.Bot, error) { - // 初始化 Telegram 机器人选项 - // 检查初始化超时时间 - opts := []bot.Option{ - bot.WithCheckInitTimeout(time.Duration(config.PluginConfig.Timeout) * time.Second), - } - - // 开启调试模式 - // 开启调试模式后,会打印所有的 API 请求和响应 - if config.PluginConfig.Debug { +func NewBot(config pluginSettings, token string) (*bot.Bot, error) { + timeout := time.Duration(config.Timeout) * time.Second + opts := []bot.Option{bot.WithCheckInitTimeout(timeout)} + if config.Debug { opts = append(opts, bot.WithDebug(), - // 自定义调试处理函数,将调试信息打印到日志中 bot.WithDebugHandler(func(format string, args ...any) { logger.BotLogger.Debug().Msgf(format, args...) }), ) } - - if config.PluginConfig.Proxy == "" { - return newBotWithOutProxy(config, opts...) - } - parsedURL, err := url.Parse(config.PluginConfig.Proxy) - if err != nil { - logger.PluginLogger.Panic().Err(err).Msg("代理URL解析失败") - } - - // 根据代理协议类型创建不同的 Telegram 机器人实例 - switch strings.ToLower(parsedURL.Scheme) { - case "socks5": - return newBotWithSocks5Proxy(config, parsedURL, opts...) - case "http", "https": - return newBotWithHTTPProxy(config, parsedURL, opts...) - default: - return newBotWithOutProxy(config, opts...) + if config.Proxy != "" { + return nil, errUnsupportedProxy } + httpClient := credential.NewRestrictedHTTPClientForTargets(config.Timeout*1000, []credential.NetworkTarget{{Scheme: "https", Host: "api.telegram.org", Port: 443}}) + opts = append(opts, bot.WithHTTPClient(timeout, httpClient)) + return bot.New(token, opts...) } -// newBotWithOutProxy 创建一个没有代理的 Telegram 机器人实例 -func newBotWithOutProxy(config *config.Config, options ...bot.Option) (*bot.Bot, error) { - return bot.New(config.PluginConfig.TelegramBotToken, options...) -} +var errUnsupportedProxy = &unsupportedProxyError{} -// newBotWithSocks5Proxy 创建一个 SOCKS5 代理的 Telegram 机器人实例 -func newBotWithSocks5Proxy(config *config.Config, proxyURL *url.URL, options ...bot.Option) (*bot.Bot, error) { - // 解析 SOCKS5 代理 URL - var auth *proxy.Auth - if proxyURL.User != nil { - password, _ := proxyURL.User.Password() - auth = &proxy.Auth{ - User: proxyURL.User.Username(), - Password: password, - } - } - dialer, err := proxy.SOCKS5( - "tcp", - proxyURL.Host, - auth, - proxy.Direct, - ) - if err != nil { - return nil, err - } - httpClient := &http.Client{ - Transport: &http.Transport{ - DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) { - return dialer.Dial(network, addr) - }, - }, - } - opts := append(options, bot.WithHTTPClient(time.Duration(config.PluginConfig.Timeout)*time.Second, httpClient)) - return bot.New(config.PluginConfig.TelegramBotToken, opts...) -} +type unsupportedProxyError struct{} -// newBotWithHTTPProxy 创建一个 HTTP 代理的 Telegram 机器人实例 -func newBotWithHTTPProxy(config *config.Config, proxyURL *url.URL, options ...bot.Option) (*bot.Bot, error) { - httpClient := &http.Client{ - Transport: &http.Transport{ - Proxy: http.ProxyURL(proxyURL), - }, - } - - options = append(options, bot.WithHTTPClient(time.Duration(config.PluginConfig.Timeout)*time.Second, httpClient)) - return bot.New(config.PluginConfig.TelegramBotToken, options...) -} +func (*unsupportedProxyError) Error() string { return "不支持的代理协议" } diff --git a/plugins/pmail_telegram_push/hook/hook.go b/plugins/pmail_telegram_push/hook/hook.go index 18433efd..eea323b6 100644 --- a/plugins/pmail_telegram_push/hook/hook.go +++ b/plugins/pmail_telegram_push/hook/hook.go @@ -1,134 +1,119 @@ package hook import ( + "encoding/json" + "errors" "strings" - "github.com/ydzydzydz/pmail_telegram_push/config" - "github.com/ydzydzydz/pmail_telegram_push/logger" - "github.com/ydzydzydz/pmail_telegram_push/service" - - pconfig "github.com/Jinnrry/pmail/config" - "github.com/Jinnrry/pmail/dto/parsemail" - "github.com/Jinnrry/pmail/hooks/framework" - "github.com/Jinnrry/pmail/models" - "github.com/Jinnrry/pmail/utils/context" + "git.pcux.cn/xuans/Smail/dto/parsemail" + "git.pcux.cn/xuans/Smail/hooks/framework" + "git.pcux.cn/xuans/Smail/models" + "git.pcux.cn/xuans/Smail/utils/context" "github.com/go-telegram/bot" - - "github.com/ydzydzydz/pmail_telegram_push/db" + "github.com/ydzydzydz/pmail_telegram_push/logger" + telegrammodel "github.com/ydzydzydz/pmail_telegram_push/model" ) -const ( - PLUGIN_NAME = "pmail_telegram_push" // 插件名称 -) +const PLUGIN_NAME = "telegram_push" -// PmailTelegramPushHook 插件钩子 type PmailTelegramPushHook struct { - bot *bot.Bot - mainConfig *pconfig.Config - pluginConfig *config.PluginConfig - settingService *service.SettingService + bot *bot.Bot + pluginConfig pluginSettings + settings *settingStore } -// NewPmailTelegramPushHook 创建插件钩子 -func NewPmailTelegramPushHook(cfg *config.Config) *PmailTelegramPushHook { - bot, err := NewBot(cfg) - if err != nil { - logger.PluginLogger.Fatal().Err(err).Msg("创建bot失败") - } - logger.PluginLogger.Info().Msg("bot初始化成功") - - dataSource, err := db.NewDataSource(cfg) - if err != nil { - logger.PluginLogger.Fatal().Err(err).Msg("创建数据库连接失败") - } - logger.PluginLogger.Info().Msg("数据库初始化成功") - - settingService := service.NewSettingService(dataSource.SettingDao()) - return &PmailTelegramPushHook{ - bot: bot, - mainConfig: cfg.MainConfig, - pluginConfig: cfg.PluginConfig, - settingService: settingService, - } +func NewPmailTelegramPushHook() *PmailTelegramPushHook { + return &PmailTelegramPushHook{settings: newSettingStore()} } var _ framework.EmailHook = (*PmailTelegramPushHook)(nil) +var _ framework.CapabilityProvider = (*PmailTelegramPushHook)(nil) +var _ framework.ConfigurableHook = (*PmailTelegramPushHook)(nil) + +func (h *PmailTelegramPushHook) Capabilities() framework.Capabilities { + return framework.Capabilities{ + PluginID: PLUGIN_NAME, + Capabilities: []string{"network", "userSettings", "settingsHtml"}, + Settings: []string{"proxy", "timeout", "debug", "webDomain", "httpsEnabled"}, + Protocol: 1, + } +} + +func (h *PmailTelegramPushHook) ValidateConfig(data json.RawMessage) error { + _, _, _, err := parseRuntimeConfig(data) + return err +} + +func (h *PmailTelegramPushHook) Configure(data json.RawMessage) error { + _, settings, token, err := parseRuntimeConfig(data) + if err != nil { + return err + } + newBot, err := NewBot(settings, token) + if err != nil { + return errors.New("Telegram Bot 初始化失败") + } + h.pluginConfig = settings + h.bot = newBot + return nil +} + +func (h *PmailTelegramPushHook) Health() error { + if h.bot == nil { + return errors.New("Telegram Bot 尚未配置") + } + return nil +} -// GetName 获取插件名称 func (h *PmailTelegramPushHook) GetName(ctx *context.Context) string { return PLUGIN_NAME } -// ReceiveSaveAfter 接收保存后的钩子 func (h *PmailTelegramPushHook) ReceiveSaveAfter(ctx *context.Context, email *parsemail.Email, ue []*models.UserEmail) { - for _, u := range ue { - // 已读邮件不处理 - if u.IsRead != 0 { - continue - } - // 未读邮件不处理 - if u.Status != 0 { - continue - } - // 邮件ID不存在不处理 - if email.MessageId <= 0 { - continue - } - - setting, err := h.settingService.GetSetting(u.UserID) - if err != nil { - // 获取设置失败不处理 + if h.bot == nil || email == nil || email.MessageId <= 0 { + return + } + for _, userEmail := range ue { + if userEmail == nil || userEmail.IsRead != 0 || userEmail.Status != 0 { continue } + setting := h.settings.get(userEmail.UserID) if setting.ChatID == "" { - // 聊天ID不存在不处理 continue } - - if err = h.sendNotification(email, setting); err != nil { + telegramSettingModel := &telegrammodel.TelegramPushSetting{ + ChatID: setting.ChatID, + ShowContent: setting.ShowContent, + SpoilerContent: setting.SpoilerContent, + SendAttachments: setting.SendAttachments, + DisableLinkPreview: setting.DisableLinkPreview, + } + if err := h.sendNotification(email, telegramSettingModel); err != nil { logger.PluginLogger.Error().Err(err).Int64("email_message_id", email.MessageId).Msg("发送通知失败") - continue } - logger.PluginLogger.Info().Int64("email_message_id", email.MessageId).Msg("发送通知成功") } } -// ReceiveParseBefore 接收解析前的钩子 -func (h *PmailTelegramPushHook) ReceiveParseBefore(ctx *context.Context, email *[]byte) { - -} - -// ReceiveParseAfter 接收解析后的钩子 -func (h *PmailTelegramPushHook) ReceiveParseAfter(ctx *context.Context, email *parsemail.Email) { - -} - -// SendAfter 发送后的钩子 +func (h *PmailTelegramPushHook) ReceiveParseBefore(ctx *context.Context, email *[]byte) {} +func (h *PmailTelegramPushHook) ReceiveParseAfter(ctx *context.Context, email *parsemail.Email) {} func (h *PmailTelegramPushHook) SendAfter(ctx *context.Context, email *parsemail.Email, err map[string]error) { - } +func (h *PmailTelegramPushHook) SendBefore(ctx *context.Context, email *parsemail.Email) {} -// SendBefore 发送前的钩子 -func (h *PmailTelegramPushHook) SendBefore(ctx *context.Context, email *parsemail.Email) { - -} - -// SettingsHtml 获取设置 HTML func (h *PmailTelegramPushHook) SettingsHtml(ctx *context.Context, url string, requestData string) string { + if ctx == nil { + return ErrorResponse("用户上下文无效").Json() + } switch { - // 获取用户设置 case strings.Contains(url, "getSetting"): return h.getSetting(ctx.UserID) - // 获取机器人信息 case strings.Contains(url, "getBotInfo"): return h.getBotInfo() - // 更新设置 case strings.Contains(url, "updateSetting"): return h.updateSetting(ctx.UserID, requestData) - // 测试消息 case strings.Contains(url, "testMessage"): return h.testMessage(ctx.UserID, requestData) default: - return SettingHtml + return settingPage() } } diff --git a/plugins/pmail_telegram_push/hook/runtime.go b/plugins/pmail_telegram_push/hook/runtime.go new file mode 100644 index 00000000..0736b53a --- /dev/null +++ b/plugins/pmail_telegram_push/hook/runtime.go @@ -0,0 +1,159 @@ +package hook + +import ( + "encoding/json" + "errors" + "io" + "regexp" + "strings" + "sync" +) + +const ( + pluginID = "telegram_push" + maxRuntimeSettings = 64 << 10 + defaultTimeout = 30 + maxTimeout = 120 +) + +var chatIDPattern = regexp.MustCompile(`^-?[1-9][0-9]{0,18}$`) + +type pluginRuntimeConfig struct { + PluginID string `json:"pluginId"` + Generation uint64 `json:"generation"` + Settings json.RawMessage `json:"settings,omitempty"` + Secrets map[string]string `json:"secrets,omitempty"` + Capabilities []string `json:"capabilities,omitempty"` + Network []pluginNetworkTarget `json:"network,omitempty"` +} + +type pluginNetworkTarget struct { + Scheme string `json:"scheme"` + Host string `json:"host"` + Port int `json:"port"` +} + +type pluginSettings struct { + Proxy string `json:"proxy,omitempty"` + Timeout int `json:"timeout,omitempty"` + Debug bool `json:"debug,omitempty"` + WebDomain string `json:"webDomain,omitempty"` + HTTPSEnabled bool `json:"httpsEnabled,omitempty"` +} + +type settingStore struct { + mu sync.RWMutex + settings map[int]telegramSetting +} + +type telegramSetting struct { + ChatID string `json:"chat_id"` + ShowContent bool `json:"show_content"` + SpoilerContent bool `json:"spoiler_content"` + SendAttachments bool `json:"send_attachments"` + DisableLinkPreview bool `json:"disable_link_preview"` +} + +func newSettingStore() *settingStore { + return &settingStore{settings: make(map[int]telegramSetting)} +} + +func defaultTelegramSetting() telegramSetting { + return telegramSetting{ + ShowContent: true, + SpoilerContent: true, + SendAttachments: true, + DisableLinkPreview: true, + } +} + +func (s *settingStore) get(userID int) telegramSetting { + s.mu.RLock() + setting, ok := s.settings[userID] + s.mu.RUnlock() + if !ok { + return defaultTelegramSetting() + } + return setting +} + +func (s *settingStore) update(userID int, setting telegramSetting) error { + if userID <= 0 || !validChatID(setting.ChatID) { + return errors.New("Chat ID 格式不正确") + } + setting.ChatID = strings.TrimSpace(setting.ChatID) + s.mu.Lock() + s.settings[userID] = setting + s.mu.Unlock() + return nil +} + +func validChatID(value string) bool { + value = strings.TrimSpace(value) + return value == "" || chatIDPattern.MatchString(value) +} + +func parseRuntimeConfig(data json.RawMessage) (pluginRuntimeConfig, pluginSettings, string, error) { + if len(data) == 0 || len(data) > maxRuntimeSettings { + return pluginRuntimeConfig{}, pluginSettings{}, "", errors.New("插件运行时配置无效") + } + var runtime pluginRuntimeConfig + if err := decodeSingleJSON(data, &runtime); err != nil { + return pluginRuntimeConfig{}, pluginSettings{}, "", errors.New("插件运行时配置无效") + } + if runtime.PluginID != pluginID { + return pluginRuntimeConfig{}, pluginSettings{}, "", errors.New("插件 ID 不匹配") + } + if runtime.Generation == 0 { + return pluginRuntimeConfig{}, pluginSettings{}, "", errors.New("Telegram 插件配置代次无效") + } + if !hasOnlyCapability(runtime.Capabilities, "network") { + return pluginRuntimeConfig{}, pluginSettings{}, "", errors.New("Telegram 插件能力权限无效") + } + var settings pluginSettings + if len(runtime.Settings) > 0 { + if err := decodeSingleJSON(runtime.Settings, &settings); err != nil { + return pluginRuntimeConfig{}, pluginSettings{}, "", errors.New("Telegram 插件配置无效") + } + } + if settings.Timeout == 0 { + settings.Timeout = defaultTimeout + } + if settings.Timeout < 1 || settings.Timeout > maxTimeout { + return pluginRuntimeConfig{}, pluginSettings{}, "", errors.New("Telegram 请求超时时间无效") + } + if settings.Proxy != "" { + return pluginRuntimeConfig{}, pluginSettings{}, "", errors.New("Telegram 插件不允许使用未授权代理") + } + secret := strings.TrimSpace(runtime.Secrets["botToken"]) + if secret == "" { + return pluginRuntimeConfig{}, pluginSettings{}, "", errors.New("Telegram Bot Token 未配置") + } + if len(runtime.Secrets) != 1 { + return pluginRuntimeConfig{}, pluginSettings{}, "", errors.New("Telegram 插件密钥字段无效") + } + if !hasOnlyTelegramNetworkTarget(runtime.Network) { + return pluginRuntimeConfig{}, pluginSettings{}, "", errors.New("Telegram 网络权限未配置") + } + return runtime, settings, secret, nil +} + +func decodeSingleJSON(data []byte, target any) error { + decoder := json.NewDecoder(strings.NewReader(string(data))) + decoder.DisallowUnknownFields() + if err := decoder.Decode(target); err != nil { + return err + } + if err := decoder.Decode(&struct{}{}); !errors.Is(err, io.EOF) { + return errors.New("trailing JSON data") + } + return nil +} + +func hasOnlyCapability(capabilities []string, expected string) bool { + return len(capabilities) == 1 && capabilities[0] == expected +} + +func hasOnlyTelegramNetworkTarget(targets []pluginNetworkTarget) bool { + return len(targets) == 1 && strings.EqualFold(targets[0].Scheme, "https") && strings.EqualFold(targets[0].Host, "api.telegram.org") && targets[0].Port == 443 +} diff --git a/plugins/pmail_telegram_push/hook/runtime_test.go b/plugins/pmail_telegram_push/hook/runtime_test.go new file mode 100644 index 00000000..34f93944 --- /dev/null +++ b/plugins/pmail_telegram_push/hook/runtime_test.go @@ -0,0 +1,148 @@ +package hook + +import ( + "encoding/json" + "strings" + "sync" + "testing" +) + +func validRuntimePayload() []byte { + payload := pluginRuntimeConfig{ + PluginID: "telegram_push", + Generation: 1, + Settings: json.RawMessage(`{"timeout":30,"webDomain":"mail.example.test","httpsEnabled":true}`), + Secrets: map[string]string{"botToken": "secret-token"}, + Capabilities: []string{"network"}, + Network: []pluginNetworkTarget{{Scheme: "https", Host: "api.telegram.org", Port: 443}}, + } + data, err := json.Marshal(payload) + if err != nil { + panic(err) + } + return data +} + +func TestParseRuntimeConfigAcceptsAuthorizedPayload(t *testing.T) { + runtime, settings, token, err := parseRuntimeConfig(validRuntimePayload()) + if err != nil { + t.Fatalf("parseRuntimeConfig() error = %v", err) + } + if runtime.PluginID != pluginID || runtime.Generation != 1 || settings.Timeout != defaultTimeout || token != "secret-token" { + t.Fatalf("unexpected parsed configuration: id=%q timeout=%d token=%q", runtime.PluginID, settings.Timeout, token) + } +} + +func TestParseRuntimeConfigRejectsZeroGeneration(t *testing.T) { + var payload pluginRuntimeConfig + if err := json.Unmarshal(validRuntimePayload(), &payload); err != nil { + t.Fatal(err) + } + payload.Generation = 0 + data, err := json.Marshal(payload) + if err != nil { + t.Fatal(err) + } + if _, _, _, err = parseRuntimeConfig(data); err == nil { + t.Fatal("zero plugin configuration generation was accepted") + } +} + +func TestParseRuntimeConfigRejectsSecurityBoundaryViolations(t *testing.T) { + tests := []struct { + name string + mutate func(*pluginRuntimeConfig) + wantError string + }{ + {name: "plugin id mismatch", mutate: func(payload *pluginRuntimeConfig) { payload.PluginID = "other" }, wantError: "\u63d2\u4ef6 ID \u4e0d\u5339\u914d"}, + {name: "missing token", mutate: func(payload *pluginRuntimeConfig) { payload.Secrets = nil }, wantError: "Telegram Bot Token \u672a\u914d\u7f6e"}, + {name: "unknown secret", mutate: func(payload *pluginRuntimeConfig) { payload.Secrets["other"] = "value" }, wantError: "Telegram 插件密钥字段无效"}, + {name: "missing capability", mutate: func(payload *pluginRuntimeConfig) { payload.Capabilities = nil }, wantError: "Telegram 插件能力权限无效"}, + {name: "extra capability", mutate: func(payload *pluginRuntimeConfig) { payload.Capabilities = []string{"network", "filesystem"} }, wantError: "Telegram 插件能力权限无效"}, + {name: "missing network permission", mutate: func(payload *pluginRuntimeConfig) { payload.Network = nil }, wantError: "Telegram \u7f51\u7edc\u6743\u9650\u672a\u914d\u7f6e"}, + {name: "wrong network host", mutate: func(payload *pluginRuntimeConfig) { + payload.Network = []pluginNetworkTarget{{Scheme: "https", Host: "example.test", Port: 443}} + }, wantError: "Telegram \u7f51\u7edc\u6743\u9650\u672a\u914d\u7f6e"}, + {name: "wrong network port", mutate: func(payload *pluginRuntimeConfig) { + payload.Network = []pluginNetworkTarget{{Scheme: "https", Host: "api.telegram.org", Port: 8443}} + }, wantError: "Telegram \u7f51\u7edc\u6743\u9650\u672a\u914d\u7f6e"}, + {name: "extra network target", mutate: func(payload *pluginRuntimeConfig) { + payload.Network = append(payload.Network, pluginNetworkTarget{Scheme: "https", Host: "example.test", Port: 443}) + }, wantError: "Telegram \u7f51\u7edc\u6743\u9650\u672a\u914d\u7f6e"}, + {name: "proxy bypass", mutate: func(payload *pluginRuntimeConfig) { + payload.Settings = json.RawMessage(`{"proxy":"http://127.0.0.1:8080"}`) + }, wantError: "Telegram \u63d2\u4ef6\u4e0d\u5141\u8bb8\u4f7f\u7528\u672a\u6388\u6743\u4ee3\u7406"}, + {name: "timeout too large", mutate: func(payload *pluginRuntimeConfig) { payload.Settings = json.RawMessage(`{"timeout":121}`) }, wantError: "Telegram \u8bf7\u6c42\u8d85\u65f6\u65f6\u95f4\u65e0\u6548"}, + {name: "unknown setting", mutate: func(payload *pluginRuntimeConfig) { payload.Settings = json.RawMessage(`{"unknown":true}`) }, wantError: "Telegram \u63d2\u4ef6\u914d\u7f6e\u65e0\u6548"}, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + var payload pluginRuntimeConfig + if err := json.Unmarshal(validRuntimePayload(), &payload); err != nil { + t.Fatal(err) + } + test.mutate(&payload) + data, err := json.Marshal(payload) + if err != nil { + t.Fatal(err) + } + _, _, _, err = parseRuntimeConfig(data) + if err == nil || !strings.Contains(err.Error(), test.wantError) { + t.Fatalf("error = %v, want %q", err, test.wantError) + } + if strings.Contains(err.Error(), "secret-token") { + t.Fatalf("error exposed secret material: %v", err) + } + }) + } +} + +func TestParseRuntimeConfigRejectsTrailingJSON(t *testing.T) { + data := append(validRuntimePayload(), []byte(` {}`)...) + _, _, _, err := parseRuntimeConfig(data) + if err == nil || !strings.Contains(err.Error(), "\u63d2\u4ef6\u8fd0\u884c\u65f6\u914d\u7f6e\u65e0\u6548") { + t.Fatalf("error = %v, want trailing JSON rejection", err) + } +} + +func TestSettingStoreKeepsSettingsScopedByUser(t *testing.T) { + store := newSettingStore() + if err := store.update(10, telegramSetting{ChatID: "-1001234567890", ShowContent: true}); err != nil { + t.Fatal(err) + } + if got := store.get(10); got.ChatID != "-1001234567890" { + t.Fatalf("user setting was not saved: %+v", got) + } + if got := store.get(11); got.ChatID != "" { + t.Fatalf("user setting crossed user boundary: %+v", got) + } +} + +func TestSettingStoreRejectsInvalidChatID(t *testing.T) { + store := newSettingStore() + for _, chatID := range []string{"0", "abc", "--1", "+123"} { + if err := store.update(1, telegramSetting{ChatID: chatID}); err == nil { + t.Fatalf("chat ID %q was accepted", chatID) + } + } +} + +func TestSettingStoreConcurrentUpdates(t *testing.T) { + store := newSettingStore() + var wg sync.WaitGroup + for userID := 1; userID <= 32; userID++ { + userID := userID + wg.Add(1) + go func() { + defer wg.Done() + for i := 0; i < 50; i++ { + if err := store.update(userID, telegramSetting{ChatID: "-1001234567890"}); err != nil { + t.Errorf("update() error = %v", err) + } + _ = store.get(userID) + } + }() + } + wg.Wait() +} diff --git a/plugins/pmail_telegram_push/hook/send.go b/plugins/pmail_telegram_push/hook/send.go index ddfa8ded..8ac45351 100644 --- a/plugins/pmail_telegram_push/hook/send.go +++ b/plugins/pmail_telegram_push/hook/send.go @@ -8,7 +8,7 @@ import ( "strings" "time" - "github.com/Jinnrry/pmail/dto/parsemail" + "git.pcux.cn/xuans/Smail/dto/parsemail" "github.com/go-telegram/bot" "github.com/go-telegram/bot/models" "github.com/ydzydzydz/pmail_telegram_push/model" @@ -130,27 +130,25 @@ func (h *PmailTelegramPushHook) buildSendText(email *parsemail.Email, setting *m return text } -// buildPamilLinkButton 创建Pamil链接按钮 +// buildPamilLinkButton 创建邮件页面链接按钮 func (h *PmailTelegramPushHook) buildPamilLinkButton() *models.InlineKeyboardMarkup { - var url string - if h.mainConfig.HttpsEnabled > 1 { - url = "http://" + h.mainConfig.WebDomain - } else { - url = "https://" + h.mainConfig.WebDomain + domain := strings.TrimSpace(h.pluginConfig.WebDomain) + if domain == "" { + return nil + } + scheme := "https" + if !h.pluginConfig.HTTPSEnabled { + scheme = "http" } - return &models.InlineKeyboardMarkup{ - InlineKeyboard: [][]models.InlineKeyboardButton{ - { - { - Text: "查收邮件", - URL: url, - }, - }, - }, + InlineKeyboard: [][]models.InlineKeyboardButton{{{ + Text: "查收邮件", + URL: scheme + "://" + domain, + }}}, } } +// sendText 发送文本消息 // sendText 发送文本消息 func (h *PmailTelegramPushHook) sendText(email *parsemail.Email, setting *model.TelegramPushSetting) (msg *models.Message, err error) { ctx, cancel := context.WithTimeout(context.Background(), time.Duration(h.pluginConfig.Timeout)*time.Second) diff --git a/plugins/pmail_telegram_push/hook/setting.go b/plugins/pmail_telegram_push/hook/setting.go index 9a3f911c..33e8f778 100644 --- a/plugins/pmail_telegram_push/hook/setting.go +++ b/plugins/pmail_telegram_push/hook/setting.go @@ -2,132 +2,113 @@ package hook import ( "context" + "embed" "encoding/json" "fmt" "strings" - _ "embed" - + "github.com/go-telegram/bot/models" "github.com/ydzydzydz/pmail_telegram_push/logger" - "github.com/ydzydzydz/pmail_telegram_push/model" + telegrammodel "github.com/ydzydzydz/pmail_telegram_push/model" ) var ( //go:embed dist/index.html - SettingHtml string // 设置页面 + settingHTML embed.FS ) -// Response 响应体 -type Response struct { - Code int `json:"code"` // 状态码 0 成功 -1 失败 - Message string `json:"message"` // 提示信息 - Data any `json:"data"` // 数据 -} - -// SuccessResponse 成功响应 -func SuccessResponse(message string, data any) *Response { - return &Response{ - Code: 0, - Message: message, - Data: data, - } -} - -// ErrorResponse 错误响应 -func ErrorResponse(message string) *Response { - return &Response{ - Code: -1, - Message: message, - } -} - -// Json 序列化响应体 -func (r *Response) Json() string { - json, err := json.Marshal(r) +func settingPage() string { + content, err := settingHTML.ReadFile("dist/index.html") if err != nil { - logger.PluginLogger.Error().Err(err).Msg("marshal response failed") + return "
Telegram 插件页面暂不可用
" + } + return string(content) +} + +type Response struct { + Code int `json:"code"` + Message string `json:"message"` + Data any `json:"data,omitempty"` +} + +func SuccessResponse(message string, data any) *Response { + return &Response{Code: 0, Message: message, Data: data} +} + +func ErrorResponse(message string) *Response { + return &Response{Code: -1, Message: message} +} + +func (r *Response) Json() string { + data, err := json.Marshal(r) + if err != nil { + logger.PluginLogger.Error().Err(err).Msg("序列化响应失败") return "" } - return string(json) + return string(data) } -// getSetting 获取Telegram Push设置 func (h *PmailTelegramPushHook) getSetting(userID int) string { - logger.PluginLogger.Info().Int("user_id", userID).Msg("获取Telegram Push设置") - - setting, err := h.settingService.GetSetting(userID) - if err != nil { - return ErrorResponse("获取Telegram Push设置失败").Json() - } - - return SuccessResponse("获取Telegram Push设置成功", setting).Json() + setting := h.settings.get(userID) + return SuccessResponse("获取 Telegram 推送设置成功", setting).Json() } func (h *PmailTelegramPushHook) testMessage(userID int, requestData string) string { - const testMessageResource = "testMessage" - logger.PluginLogger.Info().Int("user_id", userID).Msg("测试Telegram Push消息") - var setting model.TelegramPushSetting + var setting telegrammodel.TelegramPushSetting if err := json.Unmarshal([]byte(requestData), &setting); err != nil { - logger.PluginLogger.Error().Err(err).Msg("反序列化测试消息请求失败") - return ErrorResponse("反序列化测试消息请求失败").Json() + return ErrorResponse("测试消息请求格式不正确").Json() } - if setting.ChatID == "" { - logger.PluginLogger.Error().Msg("测试消息 Chat ID 不能为空") - return ErrorResponse("测试消息 Chat ID 不能为空").Json() + setting.ChatID = strings.TrimSpace(setting.ChatID) + if !validChatID(setting.ChatID) || setting.ChatID == "" { + return ErrorResponse("测试消息 Chat ID 格式不正确").Json() } - - _, err := h.sendTestMessage(&setting) - if err != nil { + if h.bot == nil { + return ErrorResponse("Telegram Bot 尚未配置").Json() + } + if _, err := h.sendTestMessage(&setting); err != nil { logger.PluginLogger.Error().Err(err).Msg("发送测试消息失败") return ErrorResponse("发送测试消息失败").Json() } - - return SuccessResponse("测试Telegram Push消息成功", nil).Json() + return SuccessResponse("测试 Telegram 推送消息成功", nil).Json() } -// updateSetting 更新Telegram Push设置 func (h *PmailTelegramPushHook) updateSetting(userID int, requestData string) string { - logger.PluginLogger.Info().Int("user_id", userID).Msg("更新Telegram Push设置") - - var setting model.TelegramPushSetting - if err := json.Unmarshal([]byte(requestData), &setting); err != nil { - logger.PluginLogger.Error().Err(err).Msg("反序列化设置请求失败") - return ErrorResponse("反序列化设置请求失败").Json() + var setting telegrammodel.TelegramPushSetting + decoder := json.NewDecoder(strings.NewReader(requestData)) + decoder.DisallowUnknownFields() + if err := decoder.Decode(&setting); err != nil { + return ErrorResponse("设置请求格式不正确").Json() } - - setting.UserID = userID - setting.ChatID = strings.TrimSpace(setting.ChatID) - if err := h.settingService.UpdateSetting(userID, &setting); err != nil { - logger.PluginLogger.Error().Err(err).Msg("更新Telegram Push设置失败") - return ErrorResponse("更新Telegram Push设置失败").Json() + if err := h.settings.update(userID, telegramSetting{ + ChatID: setting.ChatID, + ShowContent: setting.ShowContent, + SpoilerContent: setting.SpoilerContent, + SendAttachments: setting.SendAttachments, + DisableLinkPreview: setting.DisableLinkPreview, + }); err != nil { + return ErrorResponse(err.Error()).Json() } - - return SuccessResponse("更新Telegram Push设置成功", nil).Json() + return SuccessResponse("更新 Telegram 推送设置成功", nil).Json() } -// BotInfo 机器人信息 type BotInfo struct { - Username string `json:"username"` // 机器人用户名 - BotLink string `json:"bot_link"` // 机器人链接 + Username string `json:"username"` + BotLink string `json:"bot_link"` } -// NewBotInfo 创建机器人信息 func NewBotInfo(username string) BotInfo { - return BotInfo{ - Username: username, - BotLink: fmt.Sprintf("https://t.me/%s", username), - } + return BotInfo{Username: username, BotLink: fmt.Sprintf("https://t.me/%s", username)} } -// getBotInfo 获取Telegram Bot信息 func (h *PmailTelegramPushHook) getBotInfo() string { - logger.PluginLogger.Info().Msg("获取Telegram Bot信息") - + if h.bot == nil { + return ErrorResponse("Telegram Bot 尚未配置").Json() + } me, err := h.bot.GetMe(context.Background()) if err != nil { - logger.PluginLogger.Error().Err(err).Msg("获取Telegram Bot信息失败") - return ErrorResponse("获取Telegram Bot信息失败").Json() + return ErrorResponse("获取 Telegram Bot 信息失败").Json() } - - return SuccessResponse("获取Telegram Bot信息成功", NewBotInfo(me.Username)).Json() + return SuccessResponse("获取 Telegram Bot 信息成功", NewBotInfo(me.Username)).Json() } + +var _ = models.Message{} diff --git a/plugins/pmail_telegram_push/main.go b/plugins/pmail_telegram_push/main.go index 2ae95fb9..5b83b947 100644 --- a/plugins/pmail_telegram_push/main.go +++ b/plugins/pmail_telegram_push/main.go @@ -1,17 +1,13 @@ package main import ( - "github.com/Jinnrry/pmail/hooks/framework" - "github.com/ydzydzydz/pmail_telegram_push/config" + "git.pcux.cn/xuans/Smail/hooks/framework" "github.com/ydzydzydz/pmail_telegram_push/hook" ) func main() { - // 读取配置 - cfg := config.ReadConfig() - // 启动插件 framework.CreatePlugin( hook.PLUGIN_NAME, - hook.NewPmailTelegramPushHook(cfg), + hook.NewPmailTelegramPushHook(), ).Run() } diff --git a/plugins/pmail_telegram_push/package-lock.json b/plugins/pmail_telegram_push/package-lock.json new file mode 100644 index 00000000..30503c68 --- /dev/null +++ b/plugins/pmail_telegram_push/package-lock.json @@ -0,0 +1,6104 @@ +{ + "name": "pmail-telegram-push", + "version": "0.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "pmail-telegram-push", + "version": "0.0.0", + "dependencies": { + "axios": "^1.13.2", + "element-plus": "^2.11.8", + "vite-plugin-singlefile": "^2.3.0", + "vue": "^3.5.24" + }, + "devDependencies": { + "@tsconfig/node22": "^22.0.5", + "@types/mockjs": "^1.0.10", + "@types/node": "^22.19.1", + "@vitejs/plugin-vue": "^6.0.2", + "@vue/eslint-config-prettier": "^10.2.0", + "@vue/eslint-config-typescript": "^14.6.0", + "@vue/tsconfig": "^0.8.1", + "eslint": "^9.39.1", + "eslint-plugin-oxlint": "~1.11.2", + "eslint-plugin-vue": "~10.4.0", + "jiti": "^2.6.1", + "mockjs": "^1.1.0", + "npm-run-all2": "^8.0.4", + "oxlint": "~1.11.2", + "prettier": "3.6.2", + "typescript": "~5.9.3", + "unplugin-auto-import": "^20.2.0", + "unplugin-vue-components": "^29.2.0", + "vite": "npm:rolldown-vite@^7.2.7", + "vite-plugin-vue-devtools": "^8.0.5", + "vite-svg-loader": "^5.1.0", + "vue-tsc": "^3.1.5" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@babel/code-frame": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.7.tgz", + "integrity": "sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-validator-identifier": "^7.29.7", + "js-tokens": "^4.0.0", + "picocolors": "^1.1.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/code-frame/node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@babel/compat-data": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.29.7.tgz", + "integrity": "sha512-locTkQyKvwIEgBzVrn8693ebc97F2U8ZHjbXwDXJ5Fn2TCpNwTlKcaKLkdHop5c/icOFE7qt7Q9JC5hnKNa6Gg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/core": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.29.7.tgz", + "integrity": "sha512-RgHBCvtjbOK2gXSNBNIkNoEc9qoVEtau3hj8gEqKQuL3HZAibKarWFEI3Lfm6EYKkLalOh8eSrj9b+ch9H/VBA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.29.7", + "@babel/generator": "^7.29.7", + "@babel/helper-compilation-targets": "^7.29.7", + "@babel/helper-module-transforms": "^7.29.7", + "@babel/helpers": "^7.29.7", + "@babel/parser": "^7.29.7", + "@babel/template": "^7.29.7", + "@babel/traverse": "^7.29.7", + "@babel/types": "^7.29.7", + "@jridgewell/remapping": "^2.3.5", + "convert-source-map": "^2.0.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.2", + "json5": "^2.2.3", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/babel" + } + }, + "node_modules/@babel/core/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/@babel/generator": { + "version": "7.29.8", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.29.8.tgz", + "integrity": "sha512-gZbepsdh3WDtgZKWL+vTPh71LSBrm/Y4/QDZBVCcYfmeTEEuoOYwlSy+G1StfJg+/Zy550u/3TATbm7qDbbMtg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.29.8", + "@babel/types": "^7.29.8", + "@jridgewell/gen-mapping": "^0.3.12", + "@jridgewell/trace-mapping": "^0.3.28", + "jsesc": "^3.0.2" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-annotate-as-pure": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.29.7.tgz", + "integrity": "sha512-OoK6239jHPuSQOoS0kfTVKn0b/rVTk0seKq4Gd2UMLtmOVLjDC0ki3e+c90Trqv2gMfvJFqkiljrr568+qddiw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-compilation-targets": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.29.7.tgz", + "integrity": "sha512-wem6WaBj4NaVYVdNhLPPVacES6ZJ+KBBfSkTMD3YZxbP3rm3Di85tJU5ljaUNhaOynt+Aj0xruhYuzQBt8n71g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/compat-data": "^7.29.7", + "@babel/helper-validator-option": "^7.29.7", + "browserslist": "^4.24.0", + "lru-cache": "^5.1.1", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-compilation-targets/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/@babel/helper-create-class-features-plugin": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.29.7.tgz", + "integrity": "sha512-IY3ZD9Tmooqr3TUhc3DUWxiuo8xx1DWLhd5M7hQ+ZWJamqM2BbalrBJb2MisSLoYorOj75U03qULCxQTY9r3hg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.29.7", + "@babel/helper-member-expression-to-functions": "^7.29.7", + "@babel/helper-optimise-call-expression": "^7.29.7", + "@babel/helper-replace-supers": "^7.29.7", + "@babel/helper-skip-transparent-expression-wrappers": "^7.29.7", + "@babel/traverse": "^7.29.7", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-create-class-features-plugin/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/@babel/helper-globals": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-globals/-/helper-globals-7.29.7.tgz", + "integrity": "sha512-3nQVUAtvkKH9zahfWgw96Jc/uFOmjACE1kQz82E2lqWmHBgjzbNlsC22nuQTfahmWeQtTq5nQ/4Nnd2A1wj4zA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-member-expression-to-functions": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.29.7.tgz", + "integrity": "sha512-j+7JYmk1JYDtACIGj0QJqqWZjoUpMoEikQGADMaHgCMCSDqd2+P32rfcibUNrGOMWrlzK1WJBdxrB3JJQZwWtg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/traverse": "^7.29.7", + "@babel/types": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-imports": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.29.7.tgz", + "integrity": "sha512-ejHwrQQYcm9xnTivShn2IDOlIzInN34AXskvq9QicvCtEzq1Vzclu/tKF8Jq1Cg8JG2GL6/EmjgsCT7lXepE3g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/traverse": "^7.29.7", + "@babel/types": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-transforms": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.29.7.tgz", + "integrity": "sha512-UPUVSyXbOh627KiCIGQSgwWzGeBKLkaJ9PJEdrngIwMSzxLR4jS4+f1f1jb7VzBbg8nFLaYotvVPFCTqdrmTAg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-module-imports": "^7.29.7", + "@babel/helper-validator-identifier": "^7.29.7", + "@babel/traverse": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-optimise-call-expression": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.29.7.tgz", + "integrity": "sha512-+kmGVjcT9RGYzoDwdwEqEvGgKe3BYq+O1iGzjFubaNgZHwYHP6lsF2Yghf4kEuv9BV7tYDZ913aBW9am6YKong==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-plugin-utils": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.29.7.tgz", + "integrity": "sha512-G7sHYigPY17oO5SYWnfD/0MTBwVR781S/JI643e/JhUYgVgWE/61SoW3NH9KWUKyKq5LVh3npif99Wkt6j86Jw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-replace-supers": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.29.7.tgz", + "integrity": "sha512-atfGXWSeCiF4DnKZIfmJfQRkSw9b9gNNXR1kqKjbhG4pGYCOnkp8OcTB8E3NXjBu8NpheSnOeNKz8KT7UNFTmQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-member-expression-to-functions": "^7.29.7", + "@babel/helper-optimise-call-expression": "^7.29.7", + "@babel/traverse": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-skip-transparent-expression-wrappers": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.29.7.tgz", + "integrity": "sha512-brcMGQaVzIeUb+6/bs1Av0f8YuNNjKY2JyvfRCsFuFsdKccEQ5Ges2y74D74NZ1Rz8lKJ9ksJkfqwQFJ/iNEyQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/traverse": "^7.29.7", + "@babel/types": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.7.tgz", + "integrity": "sha512-Pb5ijPrZ89GDH8223L4UP8i6QApWxs04RbPQJTeWDV0/keR2E36MeKnyr6LYmUUvqRRI+Iv87SuF1W6ErINzYw==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz", + "integrity": "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-option": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.29.7.tgz", + "integrity": "sha512-N9ZErrD+yW5geCDtBqnOoxmR8+tNKiGuxKlDpuJxfsqpa2dFcexaziGAE/qoHLiDDreVNMupxGmSoNlyvsA3gw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helpers": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.29.7.tgz", + "integrity": "sha512-1k2lAGRMfHTcwuNYcCNUmaUffmQv8KWMfh2iJUUeRlwlwH4FdNG7mfPI10NPfLHJFThE4Tyr4mv7kTNZOiPuBg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/template": "^7.29.7", + "@babel/types": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.29.8", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.8.tgz", + "integrity": "sha512-E8lTAYNB1KW+FH+VGJuZM1ioAx2E6oVlvQFRrf5P8ZZmsiJXYAD9vTFV7yyEURNzgh1dFqMZuO6tUwcARbqFCA==", + "license": "MIT", + "dependencies": { + "@babel/types": "^7.29.8" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/plugin-proposal-decorators": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-decorators/-/plugin-proposal-decorators-7.29.7.tgz", + "integrity": "sha512-EtU0Hi3GvrTqD56xKmZvV/uCXK2ZbwVNPNLAquVItcAZpUhkXwWlo3Fmj0c2LxgSf2I8IDULeAepwNP1OefLXg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-create-class-features-plugin": "^7.29.7", + "@babel/helper-plugin-utils": "^7.29.7", + "@babel/plugin-syntax-decorators": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-decorators": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-decorators/-/plugin-syntax-decorators-7.29.7.tgz", + "integrity": "sha512-9MTTLbF39X6sqM92JPEsoI7++26hjZvzkxKZy64aMhWLH2mPkJ/Q3AV4QLmls3R14FpSpkOwQQfUh962JGQxxg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-import-attributes": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-attributes/-/plugin-syntax-import-attributes-7.29.7.tgz", + "integrity": "sha512-zGYcYfq/WmZ4V+kBIXQon9dSSc8ircGZqw9ZaNhhGj9nZkeBu1jHLBDQqYYi5WA9uawvA2sIMbry2nCFhf5Djg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-import-meta": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-meta/-/plugin-syntax-import-meta-7.10.4.tgz", + "integrity": "sha512-Yqfm+XDx0+Prh3VSeEQCPU81yC+JWZ2pDPFSS4ZdpfZhp4MkFMaDC1UqseovEKwSUpnIL7+vK+Clp7bfh0iD7g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.10.4" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-jsx": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.29.7.tgz", + "integrity": "sha512-TSu8+mHCoEaaCDEZ0I3+6mvTBYR4PCxQwf2z9/r5Tbztv6NaLR3B9thGTTxX2WGuGHJqRiAbKPeGTJ5XWXVg6A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-typescript": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.29.7.tgz", + "integrity": "sha512-ngr+82Sh0xMz25TPCZi+nC2iTzjfCdWS2ONXTp/PtSCHCgaCNBpdMqgvJ2ccdLlClVZ7sisIgB914j/JFe+RZA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-typescript": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.29.7.tgz", + "integrity": "sha512-jK52h8LaLc7JarhQV2ofeFMts4H7vnOXnqZNA6fYglBTZewRBE51KWt3BUltW1P+KoPsYkHoJeXePuz4zo2LMw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.29.7", + "@babel/helper-create-class-features-plugin": "^7.29.7", + "@babel/helper-plugin-utils": "^7.29.7", + "@babel/helper-skip-transparent-expression-wrappers": "^7.29.7", + "@babel/plugin-syntax-typescript": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/template": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.29.7.tgz", + "integrity": "sha512-puq+Gf35oI24FeN11LkoUQFqv9uwNeWpxXZi/Ji3rRIoKAzKnxRaZ+Gkj0vKS9ZCiTESfng1N9LyOyXvo+m+Gg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.29.7", + "@babel/parser": "^7.29.7", + "@babel/types": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/traverse": { + "version": "7.29.8", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.29.8.tgz", + "integrity": "sha512-I5z7H3bf/41ktsNVLtpN0wAa336HkqIHQ5BuPLEhTkt1jVSyZpeNKIzTgEWmlxjdg81R0IgUCcaE+Ok3NvrfZg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.29.7", + "@babel/generator": "^7.29.8", + "@babel/helper-globals": "^7.29.7", + "@babel/parser": "^7.29.8", + "@babel/template": "^7.29.7", + "@babel/types": "^7.29.8", + "debug": "^4.3.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/types": { + "version": "7.29.8", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.8.tgz", + "integrity": "sha512-Vj1jF3cPfxg7OAfoI7QnVKLoILlm2JF9pnVHrX8qx7AHMiYWT+NDAA7jChlNgRS4WTLc/fD1lXLmPixluj+3Gg==", + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^7.29.7", + "@babel/helper-validator-identifier": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@ctrl/tinycolor": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/@ctrl/tinycolor/-/tinycolor-4.2.0.tgz", + "integrity": "sha512-kzyuwOAQnXJNLS9PSyrk0CWk35nWJW/zl/6KvnTBMFK65gm7U1/Z5BqjxeapjZCIhQcM/DsrEmcbRwDyXyXK4A==", + "license": "MIT", + "engines": { + "node": ">=14" + } + }, + "node_modules/@element-plus/icons-vue": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/@element-plus/icons-vue/-/icons-vue-2.3.2.tgz", + "integrity": "sha512-OzIuTaIfC8QXEPmJvB4Y4kw34rSXdCJzxcD1kFStBvr8bK6X1zQAYDo0CNMjojnfTqRQCJ0I7prlErcoRiET2A==", + "license": "MIT", + "peerDependencies": { + "vue": "^3.2.0" + } + }, + "node_modules/@emnapi/core": { + "version": "1.11.3", + "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.11.3.tgz", + "integrity": "sha512-zLpS5asjEb7lq8jYLq37N6XKaE41DIexlY1rF/z4/tIl3wo13Sqm28fRyfIsKZD+NZ8mM5RoKkpW/rBcuoSZSg==", + "license": "MIT", + "optional": true, + "peer": true, + "dependencies": { + "@emnapi/wasi-threads": "1.2.3", + "tslib": "^2.4.0" + } + }, + "node_modules/@emnapi/runtime": { + "version": "1.11.3", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.11.3.tgz", + "integrity": "sha512-Xz4Tpyki7XyrpbUK1jR1AhdAdaXyhhY4lZ3neLodmhpuWfy2PAQN5B46sAiU4liOXGLkHypn/qU+jvfWSCYYLA==", + "license": "MIT", + "optional": true, + "peer": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@emnapi/wasi-threads": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.3.tgz", + "integrity": "sha512-ELEBe8PsLvvJ6QMr0zLt8ffvOHW/dc1m3CEzNMg7aJUv3bMaoDtw2TXyDAwkYBuroxxuHEwhRTLJSe5sya547g==", + "license": "MIT", + "optional": true, + "peer": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@eslint-community/eslint-utils": { + "version": "4.10.1", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.10.1.tgz", + "integrity": "sha512-cuadcxVFE8sDK6iWJbs8Sn0av2Nrh2QSGQhVlBW9AaAHqHwjWsZHT8LJ4hFGPh7ASBV2deFdM7H/DPjulmh8rg==", + "dev": true, + "license": "MIT", + "dependencies": { + "eslint-visitor-keys": "^3.4.3" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" + } + }, + "node_modules/@eslint-community/regexpp": { + "version": "4.12.2", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.2.tgz", + "integrity": "sha512-EriSTlt5OC9/7SXkRSCAhfSxxoSUgBm33OH+IkwbdpgoqsSsUg7y3uh+IICI/Qg4BBWr3U2i39RpmycbxMq4ew==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, + "node_modules/@eslint/config-array": { + "version": "0.21.2", + "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.21.2.tgz", + "integrity": "sha512-nJl2KGTlrf9GjLimgIru+V/mzgSK0ABCDQRvxw5BjURL7WfH5uoWmizbH7QB6MmnMBd8cIC9uceWnezL1VZWWw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/object-schema": "^2.1.7", + "debug": "^4.3.1", + "minimatch": "^3.1.5" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/config-array/node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@eslint/config-array/node_modules/brace-expansion": { + "version": "1.1.18", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.18.tgz", + "integrity": "sha512-Edep/X9fGqVNmzKBVsDYIOtD+z1tuezV70LBjdCst9Tqu76lsnvRiZ6oTic1n+/BIwX6QDGAO94PN4N2SADvtw==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/@eslint/config-array/node_modules/minimatch": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", + "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/@eslint/config-helpers": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/@eslint/config-helpers/-/config-helpers-0.4.2.tgz", + "integrity": "sha512-gBrxN88gOIf3R7ja5K9slwNayVcZgK6SOUORm2uBzTeIEfeVaIhOpCtTox3P6R7o2jLFwLFTLnC7kU/RGcYEgw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/core": "^0.17.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/core": { + "version": "0.17.0", + "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.17.0.tgz", + "integrity": "sha512-yL/sLrpmtDaFEiUj1osRP4TI2MDz1AddJL+jZ7KSqvBuliN4xqYY54IfdN8qD8Toa6g1iloph1fxQNkjOxrrpQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@types/json-schema": "^7.0.15" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/eslintrc": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.3.6.tgz", + "integrity": "sha512-l2Ul9PrHsPCKcEY/ac7VgFj9D80C7S68sOKc618SyHDPK36s1XcFebXY0iTzUVn4Yq+YbwvSnDmCz9yxjX+QrA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ajv": "^6.14.0", + "debug": "^4.3.2", + "espree": "^10.0.1", + "globals": "^14.0.0", + "ignore": "^5.2.0", + "import-fresh": "^3.2.1", + "js-yaml": "^4.3.0", + "minimatch": "^3.1.5", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint/eslintrc/node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@eslint/eslintrc/node_modules/brace-expansion": { + "version": "1.1.18", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.18.tgz", + "integrity": "sha512-Edep/X9fGqVNmzKBVsDYIOtD+z1tuezV70LBjdCst9Tqu76lsnvRiZ6oTic1n+/BIwX6QDGAO94PN4N2SADvtw==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/@eslint/eslintrc/node_modules/minimatch": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", + "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/@eslint/js": { + "version": "9.39.5", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.39.5.tgz", + "integrity": "sha512-QywQuszQh77pIXCsq998c8hbhSTI/azTty1Z6N53dmAudKHhy573j3yvRLsX2BSp8YpLtoCEG8E9DJe+8zUh4A==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://eslint.org/donate" + } + }, + "node_modules/@eslint/object-schema": { + "version": "2.1.7", + "resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-2.1.7.tgz", + "integrity": "sha512-VtAOaymWVfZcmZbp6E2mympDIHvyjXs/12LqWYjVw6qjrfF+VK+fyG33kChz3nnK+SU5/NeHOqrTEHS8sXO3OA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/plugin-kit": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.4.1.tgz", + "integrity": "sha512-43/qtrDUokr7LJqoF2c3+RInu/t4zfrpYdoSDfYyhg52rwLV6TnOvdG4fXm7IkSB3wErkcmJS9iEhjVtOSEjjA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/core": "^0.17.0", + "levn": "^0.4.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@floating-ui/core": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.8.0.tgz", + "integrity": "sha512-0CIZ5itps/8x7BG8dEIhs53BvCUH2PCoogtakwRTut+Arm58sJooJ0AuZhLw2HJYIR5cMLNPBSS728sPho2khQ==", + "license": "MIT", + "dependencies": { + "@floating-ui/utils": "^0.2.12" + } + }, + "node_modules/@floating-ui/dom": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.8.0.tgz", + "integrity": "sha512-yXSrzeHZBTZadLOlfyhCkJHNeLJnHRnRInwdZ40L7ZiaAtrBwoYlsDrX3v5zB1Utk7CLfzcOVnVVWoXEky7Ceg==", + "license": "MIT", + "dependencies": { + "@floating-ui/core": "^1.8.0", + "@floating-ui/utils": "^0.2.12" + } + }, + "node_modules/@floating-ui/utils": { + "version": "0.2.12", + "resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.12.tgz", + "integrity": "sha512-HpCo8tmWzLVad5s2d19EhAz5zqrrQ6s69qd6moPMQvkOuSwDT1YgRfWSVuc4ennqrgv3OHppiOGMQ7oC13yIww==", + "license": "MIT" + }, + "node_modules/@humanfs/core": { + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.2.tgz", + "integrity": "sha512-UhXNm+CFMWcbChXywFwkmhqjs3PRCmcSa/hfBgLIb7oQ5HNb1wS0icWsGtSAUNgefHeI+eBrA8I1fxmbHsGdvA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@humanfs/types": "^0.15.0" + }, + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanfs/node": { + "version": "0.16.8", + "resolved": "https://registry.npmjs.org/@humanfs/node/-/node-0.16.8.tgz", + "integrity": "sha512-gE1eQNZ3R++kTzFUpdGlpmy8kDZD/MLyHqDwqjkVQI0JMdI1D51sy1H958PNXYkM2rAac7e5/CnIKZrHtPh3BQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@humanfs/core": "^0.19.2", + "@humanfs/types": "^0.15.0", + "@humanwhocodes/retry": "^0.4.0" + }, + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanfs/types": { + "version": "0.15.0", + "resolved": "https://registry.npmjs.org/@humanfs/types/-/types-0.15.0.tgz", + "integrity": "sha512-ZZ1w0aoQkwuUuC7Yf+7sdeaNfqQiiLcSRbfI08oAxqLtpXQr9AIVX7Ay7HLDuiLYAaFPu8oBYNq/QIi9URHJ3Q==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=12.22" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@humanwhocodes/retry": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.4.3.tgz", + "integrity": "sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.13", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", + "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/remapping": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/@jridgewell/remapping/-/remapping-2.3.5.tgz", + "integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz", + "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==", + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@napi-rs/wasm-runtime": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.2.3.tgz", + "integrity": "sha512-UMduMbqO5s5zF2NkNacMT/yK5Y5QiKvWr2+50bzIIxFDwVJ2h49b+oyjaCGPhJxd2/gC2x39EHv/gHVuu36x2Q==", + "license": "MIT", + "optional": true, + "dependencies": { + "@tybys/wasm-util": "^0.10.3" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=23.5.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/Brooooooklyn" + }, + "peerDependencies": { + "@emnapi/core": "^1.7.1 || ^2.0.0-alpha.4", + "@emnapi/runtime": "^1.7.1 || ^2.0.0-alpha.4" + } + }, + "node_modules/@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@oxc-project/runtime": { + "version": "0.101.0", + "resolved": "https://registry.npmjs.org/@oxc-project/runtime/-/runtime-0.101.0.tgz", + "integrity": "sha512-t3qpfVZIqSiLQ5Kqt/MC4Ge/WCOGrrcagAdzTcDaggupjiGxUx4nJF2v6wUCXWSzWHn5Ns7XLv13fCJEwCOERQ==", + "license": "MIT", + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxc-project/types": { + "version": "0.101.0", + "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.101.0.tgz", + "integrity": "sha512-nuFhqlUzJX+gVIPPfuE6xurd4lST3mdcWOhyK/rZO0B9XWMKm79SuszIQEnSMmmDhq1DC8WWVYGVd+6F93o1gQ==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/Boshen" + } + }, + "node_modules/@oxlint-tsgolint/darwin-arm64": { + "version": "7.0.2001", + "resolved": "https://registry.npmjs.org/@oxlint-tsgolint/darwin-arm64/-/darwin-arm64-7.0.2001.tgz", + "integrity": "sha512-CUJEdbSZ54+Xy9OXqOhWLTKZKV0BBiV7C2i/ygyVmXtkUNXx5YCzN8DpSSshTAKktoL7S+tnQ/ftFG/i7X896w==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@oxlint-tsgolint/darwin-x64": { + "version": "7.0.2001", + "resolved": "https://registry.npmjs.org/@oxlint-tsgolint/darwin-x64/-/darwin-x64-7.0.2001.tgz", + "integrity": "sha512-pXfBb5BqONCcgrXQNUZWXgiYmRSWJzd97S8i41VVOh6ut0tyo+cJ5FKFpczDHxiVNfj/3e7c9B4MtztNdpIVCw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@oxlint-tsgolint/linux-arm64": { + "version": "7.0.2001", + "resolved": "https://registry.npmjs.org/@oxlint-tsgolint/linux-arm64/-/linux-arm64-7.0.2001.tgz", + "integrity": "sha512-roP7zujb/QDPzDwEKsFFpzNHHy91/Y7oX9vQXk78ekyZtcQj1QXDIMH33gjDdHBfRl4K9pZ36xhRgrP4Zr+R8A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@oxlint-tsgolint/linux-x64": { + "version": "7.0.2001", + "resolved": "https://registry.npmjs.org/@oxlint-tsgolint/linux-x64/-/linux-x64-7.0.2001.tgz", + "integrity": "sha512-UDezNqdECVmngu2TPnjaS1YoAmcTaBoI5lV9vk3VahBxoi+I5r9k3iJTT7qZoYWOXTD/7T7bNcwRgrocR6BscQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@oxlint-tsgolint/win32-arm64": { + "version": "7.0.2001", + "resolved": "https://registry.npmjs.org/@oxlint-tsgolint/win32-arm64/-/win32-arm64-7.0.2001.tgz", + "integrity": "sha512-uJZhqB6pdXLuN+AD1F5082byyQti/NPmJA77GtcFlmT2HzRelqbNls3SaIqxpjdFgvSBF9g0yOKGBkGFg7kX8Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@oxlint-tsgolint/win32-x64": { + "version": "7.0.2001", + "resolved": "https://registry.npmjs.org/@oxlint-tsgolint/win32-x64/-/win32-x64-7.0.2001.tgz", + "integrity": "sha512-FkDRm8hx9OwzGQqyWG1tO5QrTLRApff9DzSgpz9QZau37BR8d1VYKOxMLGf6shPZntJFoTwIIJYT68VndYDCog==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@oxlint/darwin-arm64": { + "version": "1.11.2", + "resolved": "https://registry.npmjs.org/@oxlint/darwin-arm64/-/darwin-arm64-1.11.2.tgz", + "integrity": "sha512-eJZ1VKaS9qj44FTus3qTu790xMnJ/GViJcoVF3zNux5m3lOiWhwJB149+P7a7LcTowNdc26i1DmwcWxUllPwZw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@oxlint/darwin-x64": { + "version": "1.11.2", + "resolved": "https://registry.npmjs.org/@oxlint/darwin-x64/-/darwin-x64-1.11.2.tgz", + "integrity": "sha512-KH9BJ5ObkReIr00IbGaImqL2q4CCjIAk9HxgULvWpjSnqUL7OgJFZAabb9Z5ZS0+RyZrKUtd1ZU/Ackb6k4G3Q==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@oxlint/linux-arm64-gnu": { + "version": "1.11.2", + "resolved": "https://registry.npmjs.org/@oxlint/linux-arm64-gnu/-/linux-arm64-gnu-1.11.2.tgz", + "integrity": "sha512-nIhyGApnEuqLazaSwvEkg5pMm2rlBPJccAGrNmJPcMukKbD5fUYyuCvkm9CFUqTm1+MIYrs5bTeRhnDSEa2mYw==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@oxlint/linux-arm64-musl": { + "version": "1.11.2", + "resolved": "https://registry.npmjs.org/@oxlint/linux-arm64-musl/-/linux-arm64-musl-1.11.2.tgz", + "integrity": "sha512-ifrqaBwVYt3g6GUbIwF9G9pTvkIvbs47F47oSjVogdy5hn2yEEi1zxyYGV9AFF3zVMgp2xDIO8G/gTuz1WPHkg==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@oxlint/linux-x64-gnu": { + "version": "1.11.2", + "resolved": "https://registry.npmjs.org/@oxlint/linux-x64-gnu/-/linux-x64-gnu-1.11.2.tgz", + "integrity": "sha512-yWCgoOQ0xA/AxJ7ruLMR/YMKYEwV048vrWftZGCjKPYgZeZe9bpghAoRlLi6qjw7ReNpctk9Ho+l35TYXNqhzA==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@oxlint/linux-x64-musl": { + "version": "1.11.2", + "resolved": "https://registry.npmjs.org/@oxlint/linux-x64-musl/-/linux-x64-musl-1.11.2.tgz", + "integrity": "sha512-nYer9TaY/gC+kVwOfb9DxZh0dNdqFI8ax/MD9TwH8p3ZnWuUe1Ocfpg0V94tuPoGxHFqcXU7GRD1cTvREHfcTg==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@oxlint/win32-arm64": { + "version": "1.11.2", + "resolved": "https://registry.npmjs.org/@oxlint/win32-arm64/-/win32-arm64-1.11.2.tgz", + "integrity": "sha512-zbfZ7r68MyxQ2GAg/jFzIQCFrL8lcwnxfIEqY+V16/Xcd1rZVfMH3PwJMloib26pOLH6/RUlC5IjdVo8icadHA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@oxlint/win32-x64": { + "version": "1.11.2", + "resolved": "https://registry.npmjs.org/@oxlint/win32-x64/-/win32-x64-1.11.2.tgz", + "integrity": "sha512-eSATaCIUwdh+t9gu9xoETjh+0PYwjVSLtnZ20XakKNjvee4KmQbWXCxXyA1vz1E0qxiUX/fYqsaOHueIwQ2LVA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@pkgr/core": { + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.3.6.tgz", + "integrity": "sha512-SEeaJLb3qBNF/OaXnaR1NmmBbFYk1zC0ZH/52fATcRPLFg/p791YrcyFFy44Bo9sLaGuSuLp5Q6axbb/O+v/RA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/pkgr" + } + }, + "node_modules/@polka/url": { + "version": "1.0.0-next.29", + "resolved": "https://registry.npmjs.org/@polka/url/-/url-1.0.0-next.29.tgz", + "integrity": "sha512-wwQAWhWSuHaag8c4q/KN/vCoeOJYshAIvMQwD4GpSb3OiZklFfvAgmj0VCBBImRpuF/aFgIRzllXlVX93Jevww==", + "dev": true, + "license": "MIT" + }, + "node_modules/@popperjs/core": { + "name": "@sxzz/popperjs-es", + "version": "2.11.8", + "resolved": "https://registry.npmjs.org/@sxzz/popperjs-es/-/popperjs-es-2.11.8.tgz", + "integrity": "sha512-wOwESXvvED3S8xBmcPWHs2dUuzrE4XiZeFu7e1hROIJkm02a49N120pmOXxY33sBb6hArItm5W5tcg1cBtV+HQ==", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/popperjs" + } + }, + "node_modules/@rolldown/binding-android-arm64": { + "version": "1.0.0-beta.53", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.0.0-beta.53.tgz", + "integrity": "sha512-Ok9V8o7o6YfSdTTYA/uHH30r3YtOxLD6G3wih/U9DO0ucBBFq8WPt/DslU53OgfteLRHITZny9N/qCUxMf9kjQ==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-darwin-arm64": { + "version": "1.0.0-beta.53", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.0.0-beta.53.tgz", + "integrity": "sha512-yIsKqMz0CtRnVa6x3Pa+mzTihr4Ty+Z6HfPbZ7RVbk1Uxnco4+CUn7Qbm/5SBol1JD/7nvY8rphAgyAi7Lj6Vg==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-darwin-x64": { + "version": "1.0.0-beta.53", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.0.0-beta.53.tgz", + "integrity": "sha512-GTXe+mxsCGUnJOFMhfGWmefP7Q9TpYUseHvhAhr21nCTgdS8jPsvirb0tJwM3lN0/u/cg7bpFNa16fQrjKrCjQ==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-freebsd-x64": { + "version": "1.0.0-beta.53", + "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.0.0-beta.53.tgz", + "integrity": "sha512-9Tmp7bBvKqyDkMcL4e089pH3RsjD3SUungjmqWtyhNOxoQMh0fSmINTyYV8KXtE+JkxYMPWvnEt+/mfpVCkk8w==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm-gnueabihf": { + "version": "1.0.0-beta.53", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.0.0-beta.53.tgz", + "integrity": "sha512-a1y5fiB0iovuzdbjUxa7+Zcvgv+mTmlGGC4XydVIsyl48eoxgaYkA3l9079hyTyhECsPq+mbr0gVQsFU11OJAQ==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm64-gnu": { + "version": "1.0.0-beta.53", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.0.0-beta.53.tgz", + "integrity": "sha512-bpIGX+ov9PhJYV+wHNXl9rzq4F0QvILiURn0y0oepbQx+7stmQsKA0DhPGwmhfvF856wq+gbM8L92SAa/CBcLg==", + "cpu": [ + "arm64" + ], + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm64-musl": { + "version": "1.0.0-beta.53", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.0.0-beta.53.tgz", + "integrity": "sha512-bGe5EBB8FVjHBR1mOLOPEFg1Lp3//7geqWkU5NIhxe+yH0W8FVrQ6WRYOap4SUTKdklD/dC4qPLREkMMQ855FA==", + "cpu": [ + "arm64" + ], + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-x64-gnu": { + "version": "1.0.0-beta.53", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.0.0-beta.53.tgz", + "integrity": "sha512-qL+63WKVQs1CMvFedlPt0U9PiEKJOAL/bsHMKUDS6Vp2Q+YAv/QLPu8rcvkfIMvQ0FPU2WL0aX4eWwF6e/GAnA==", + "cpu": [ + "x64" + ], + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-x64-musl": { + "version": "1.0.0-beta.53", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.0.0-beta.53.tgz", + "integrity": "sha512-VGl9JIGjoJh3H8Mb+7xnVqODajBmrdOOb9lxWXdcmxyI+zjB2sux69br0hZJDTyLJfvBoYm439zPACYbCjGRmw==", + "cpu": [ + "x64" + ], + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-openharmony-arm64": { + "version": "1.0.0-beta.53", + "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.0.0-beta.53.tgz", + "integrity": "sha512-B4iIserJXuSnNzA5xBLFUIjTfhNy7d9sq4FUMQY3GhQWGVhS2RWWzzDnkSU6MUt7/aHUrep0CdQfXUJI9D3W7A==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-wasm32-wasi": { + "version": "1.0.0-beta.53", + "resolved": "https://registry.npmjs.org/@rolldown/binding-wasm32-wasi/-/binding-wasm32-wasi-1.0.0-beta.53.tgz", + "integrity": "sha512-BUjAEgpABEJXilGq/BPh7jeU3WAJ5o15c1ZEgHaDWSz3LB881LQZnbNJHmUiM4d1JQWMYYyR1Y490IBHi2FPJg==", + "cpu": [ + "wasm32" + ], + "license": "MIT", + "optional": true, + "dependencies": { + "@napi-rs/wasm-runtime": "^1.1.0" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@rolldown/binding-win32-arm64-msvc": { + "version": "1.0.0-beta.53", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.0.0-beta.53.tgz", + "integrity": "sha512-s27uU7tpCWSjHBnxyVXHt3rMrQdJq5MHNv3BzsewCIroIw3DJFjMH1dzCPPMUFxnh1r52Nf9IJ/eWp6LDoyGcw==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-win32-x64-msvc": { + "version": "1.0.0-beta.53", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.0.0-beta.53.tgz", + "integrity": "sha512-cjWL/USPJ1g0en2htb4ssMjIycc36RvdQAx1WlXnS6DpULswiUTVXPDesTifSKYSyvx24E0YqQkEm0K/M2Z/AA==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/pluginutils": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.1.tgz", + "integrity": "sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@tsconfig/node22": { + "version": "22.0.6", + "resolved": "https://registry.npmjs.org/@tsconfig/node22/-/node22-22.0.6.tgz", + "integrity": "sha512-/5thavHAnWDZwH2H6eEn/T8pBEBhtuKaWGMslsj82kJfvzQgOgEMK7X4goBbIUjgVtAzPTtM9Ml64LA0uxO6Iw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@tybys/wasm-util": { + "version": "0.10.3", + "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.3.tgz", + "integrity": "sha512-F3fo1MYrRJYL3zER0OUOmkutjr1Vp23m7OsSgp7nq4SP6OqX6C/56XFIPAl5bt3zaBRjmW7SGz3u/6LwFpYcOg==", + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@types/estree": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.9.tgz", + "integrity": "sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/json-schema": { + "version": "7.0.15", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", + "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/lodash": { + "version": "4.17.25", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.25.tgz", + "integrity": "sha512-+K1NIO8I+F9/wNulfVvu23QYd0Pe9/OCqRrim4NoYIf1VoEDL90Ve4ClzpyqBLc7NpGGWRvYNCKZ1BE/Jpf8dQ==", + "license": "MIT" + }, + "node_modules/@types/lodash-es": { + "version": "4.17.12", + "resolved": "https://registry.npmjs.org/@types/lodash-es/-/lodash-es-4.17.12.tgz", + "integrity": "sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ==", + "license": "MIT", + "dependencies": { + "@types/lodash": "*" + } + }, + "node_modules/@types/mockjs": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/@types/mockjs/-/mockjs-1.0.10.tgz", + "integrity": "sha512-SXgrhajHG7boLv6oU93CcmdDm0HYRiceuz6b+7z+/2lCJPTWDv0V5YiwFHT2ejE4bQqgSXQiVPQYPWv7LGsK1g==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/node": { + "version": "22.20.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.20.1.tgz", + "integrity": "sha512-EANqOCF9QFyra+4pfxUcX9STKJpCLjMbObVzljIJomAWSnuSIEAvyzEU53GaajbXJEgdh0iEcPL+DGvpUd4k1Q==", + "devOptional": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.21.0" + } + }, + "node_modules/@types/web-bluetooth": { + "version": "0.0.21", + "resolved": "https://registry.npmjs.org/@types/web-bluetooth/-/web-bluetooth-0.0.21.tgz", + "integrity": "sha512-oIQLCGWtcFZy2JW77j9k8nHzAOpqMHLQejDA48XXMWH6tjCQHz5RCFz1bzsmROyL6PUm+LLnUiI4BCn221inxA==", + "license": "MIT" + }, + "node_modules/@typescript-eslint/eslint-plugin": { + "version": "8.68.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.68.0.tgz", + "integrity": "sha512-WASHDpCm6qO5jj9g1a+8NiW5+GCkAyLReR56/4VruYmNgfUmqpxOfZ2Yfb8xGfJPWv5Qi6LSD8sXdces3vbp/Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/regexpp": "^4.12.2", + "@typescript-eslint/scope-manager": "8.68.0", + "@typescript-eslint/type-utils": "8.68.0", + "@typescript-eslint/utils": "8.68.0", + "@typescript-eslint/visitor-keys": "8.68.0", + "ignore": "^7.0.5", + "natural-compare": "^1.4.0", + "ts-api-utils": "^2.5.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "@typescript-eslint/parser": "^8.68.0", + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/ignore": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.6.tgz", + "integrity": "sha512-BAg6QkE8W+TuQLrrw0Ugr7HegXduRuuj8/ti2kSOc+jz1dmx8/WNcjr6XGnq5YpDWxFwwaavqD0+jIUOKelTsw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, + "node_modules/@typescript-eslint/parser": { + "version": "8.68.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.68.0.tgz", + "integrity": "sha512-fHq2VC1kpyYfvEcbiMjOpySY4WS7voEp89yAThrHRX5sm9j2lzYppCb2umFMEed4fWcyeLjHxrz0mpjNBaBxMQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/scope-manager": "8.68.0", + "@typescript-eslint/types": "8.68.0", + "@typescript-eslint/typescript-estree": "8.68.0", + "@typescript-eslint/visitor-keys": "8.68.0", + "debug": "^4.4.3" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/project-service": { + "version": "8.68.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.68.0.tgz", + "integrity": "sha512-5GQtWZCXFcFYux955pvoS02WLc49pXNlvIxocKjS0clvwo3in1RdlzVKyiqQH9vE5AKWFLTaUgeQkOrTS+0Qxw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/tsconfig-utils": "^8.68.0", + "@typescript-eslint/types": "^8.68.0", + "debug": "^4.4.3" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/scope-manager": { + "version": "8.68.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.68.0.tgz", + "integrity": "sha512-T5eXpcaJNg8bhjHJ8Rjp68Vq/QBteYtTKY8TZqVNPaUbuz0f6jI9t6aDkylwvalpAB9XTTFeFOjrjXAZ3YvmVA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.68.0", + "@typescript-eslint/visitor-keys": "8.68.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/tsconfig-utils": { + "version": "8.68.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.68.0.tgz", + "integrity": "sha512-F7zrGQfiJHojPwi8vhxZQC1tWtJzvL74cK/nqri2lk8YUXvYaYwl263xOJ69jDWPUk1hmcdoayFwk9lX09npVw==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/type-utils": { + "version": "8.68.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.68.0.tgz", + "integrity": "sha512-X77zqoY1EjeWGs/0JNxeaMfp5C5lIz4Tw8y66F1Ne8Faq6g424sBNYM6xBAqElfGZPLpWS+CZAp0DXyKDzWiHg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.68.0", + "@typescript-eslint/typescript-estree": "8.68.0", + "@typescript-eslint/utils": "8.68.0", + "debug": "^4.4.3", + "ts-api-utils": "^2.5.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/types": { + "version": "8.68.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.68.0.tgz", + "integrity": "sha512-9RnpsGJjrAllCMefGVVsImJM24YurhC0Q1h4UbvivtvOqXmR/vEJge2OoE++z9m6hyg8T1Q8t5SNT6tHSbrxcg==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/typescript-estree": { + "version": "8.68.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.68.0.tgz", + "integrity": "sha512-OKKsD0tYmoNiU5PW2zehO1yO56jYOm1ShYlxon/Z0SJNidAkdVg86eg9ruRuoXf8xfnuWZGbwDsStkoXbZtIIA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/project-service": "8.68.0", + "@typescript-eslint/tsconfig-utils": "8.68.0", + "@typescript-eslint/types": "8.68.0", + "@typescript-eslint/visitor-keys": "8.68.0", + "debug": "^4.4.3", + "minimatch": "^10.2.2", + "semver": "^7.7.3", + "tinyglobby": "^0.2.15", + "ts-api-utils": "^2.5.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/utils": { + "version": "8.68.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.68.0.tgz", + "integrity": "sha512-PB5gJMMOg0Q5P1tsgWtEAqQacJXq0qEqRHDX/YJ4FaTMLfZPpHB3gjl2EJuiZyPABxmj4ZQYiY9m1bdAJ5y7tQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.9.1", + "@typescript-eslint/scope-manager": "8.68.0", + "@typescript-eslint/types": "8.68.0", + "@typescript-eslint/typescript-estree": "8.68.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/@typescript-eslint/visitor-keys": { + "version": "8.68.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.68.0.tgz", + "integrity": "sha512-YR65gGdGvTUAWLldC3xLOvOzamdGzB4A5/N8rehEaHs3Zvoe39BhgY+u0SPch1OvrVTfLcc55wsSgK2NcnTS/A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.68.0", + "eslint-visitor-keys": "^5.0.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-5.0.1.tgz", + "integrity": "sha512-tD40eHxA35h0PEIZNeIjkHoDR4YjjJp34biM0mDvplBe//mB+IHCqHDGV7pxF+7MklTvighcCPPZC7ynWyjdTA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@vitejs/plugin-vue": { + "version": "6.0.8", + "resolved": "https://registry.npmjs.org/@vitejs/plugin-vue/-/plugin-vue-6.0.8.tgz", + "integrity": "sha512-0ZjgOg7oO6farnNGup7yvoM/YXZV84OZxHAwtflItNa/6zzQyVb5LNxyea3FEKEX2XlagIKzrlH7wwxkKgtiew==", + "dev": true, + "license": "MIT", + "dependencies": { + "@rolldown/pluginutils": "^1.0.1" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "peerDependencies": { + "vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0", + "vue": "^3.2.25" + } + }, + "node_modules/@volar/language-core": { + "version": "2.4.28", + "resolved": "https://registry.npmjs.org/@volar/language-core/-/language-core-2.4.28.tgz", + "integrity": "sha512-w4qhIJ8ZSitgLAkVay6AbcnC7gP3glYM3fYwKV3srj8m494E3xtrCv6E+bWviiK/8hs6e6t1ij1s2Endql7vzQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@volar/source-map": "2.4.28" + } + }, + "node_modules/@volar/source-map": { + "version": "2.4.28", + "resolved": "https://registry.npmjs.org/@volar/source-map/-/source-map-2.4.28.tgz", + "integrity": "sha512-yX2BDBqJkRXfKw8my8VarTyjv48QwxdJtvRgUpNE5erCsgEUdI2DsLbpa+rOQVAJYshY99szEcRDmyHbF10ggQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@volar/typescript": { + "version": "2.4.28", + "resolved": "https://registry.npmjs.org/@volar/typescript/-/typescript-2.4.28.tgz", + "integrity": "sha512-Ja6yvWrbis2QtN4ClAKreeUZPVYMARDYZl9LMEv1iQ1QdepB6wn0jTRxA9MftYmYa4DQ4k/DaSZpFPUfxl8giw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@volar/language-core": "2.4.28", + "path-browserify": "^1.0.1", + "vscode-uri": "^3.0.8" + } + }, + "node_modules/@vue/babel-helper-vue-transform-on": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@vue/babel-helper-vue-transform-on/-/babel-helper-vue-transform-on-1.5.0.tgz", + "integrity": "sha512-0dAYkerNhhHutHZ34JtTl2czVQHUNWv6xEbkdF5W+Yrv5pCWsqjeORdOgbtW2I9gWlt+wBmVn+ttqN9ZxR5tzA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@vue/babel-plugin-jsx": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@vue/babel-plugin-jsx/-/babel-plugin-jsx-1.5.0.tgz", + "integrity": "sha512-mneBhw1oOqCd2247O0Yw/mRwC9jIGACAJUlawkmMBiNmL4dGA2eMzuNZVNqOUfYTa6vqmND4CtOPzmEEEqLKFw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-module-imports": "^7.27.1", + "@babel/helper-plugin-utils": "^7.27.1", + "@babel/plugin-syntax-jsx": "^7.27.1", + "@babel/template": "^7.27.2", + "@babel/traverse": "^7.28.0", + "@babel/types": "^7.28.2", + "@vue/babel-helper-vue-transform-on": "1.5.0", + "@vue/babel-plugin-resolve-type": "1.5.0", + "@vue/shared": "^3.5.18" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + }, + "peerDependenciesMeta": { + "@babel/core": { + "optional": true + } + } + }, + "node_modules/@vue/babel-plugin-resolve-type": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@vue/babel-plugin-resolve-type/-/babel-plugin-resolve-type-1.5.0.tgz", + "integrity": "sha512-Wm/60o+53JwJODm4Knz47dxJnLDJ9FnKnGZJbUUf8nQRAtt6P+undLUAVU3Ha33LxOJe6IPoifRQ6F/0RrU31w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.27.1", + "@babel/helper-module-imports": "^7.27.1", + "@babel/helper-plugin-utils": "^7.27.1", + "@babel/parser": "^7.28.0", + "@vue/compiler-sfc": "^3.5.18" + }, + "funding": { + "url": "https://github.com/sponsors/sxzz" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@vue/compiler-core": { + "version": "3.5.42", + "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.42.tgz", + "integrity": "sha512-2Ye1ilMtKXxl8qZUrQ5j0CdgenFp/HFQmta6rfRyfEsTG69L6Wk+tWuNoHYHMx9E8tF2Slvdg1FuwDvAXdy1LQ==", + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.29.8", + "@vue/shared": "3.5.42", + "entities": "^7.0.1", + "estree-walker": "^2.0.2", + "source-map-js": "^1.2.1" + } + }, + "node_modules/@vue/compiler-core/node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "license": "MIT" + }, + "node_modules/@vue/compiler-dom": { + "version": "3.5.42", + "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.5.42.tgz", + "integrity": "sha512-qbhQZEFmycr+ni/qyuccS4sucNN7VAbDfbkvNxWOX2VfgFm90MNs3/UhRNKoPMEIVn0F8gdlYjLPvqxHwHeQOA==", + "license": "MIT", + "dependencies": { + "@vue/compiler-core": "3.5.42", + "@vue/shared": "3.5.42" + } + }, + "node_modules/@vue/compiler-sfc": { + "version": "3.5.42", + "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.5.42.tgz", + "integrity": "sha512-fkCAFB4okcAANGMThboWnScp/gzWjU0ZSkVnjTIiplmMDq2uq0tIB3j+xVu4rhv5rvOgBySCysudmbMd6xRRqw==", + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.29.8", + "@vue/compiler-core": "3.5.42", + "@vue/compiler-dom": "3.5.42", + "@vue/compiler-ssr": "3.5.42", + "@vue/shared": "3.5.42", + "estree-walker": "^2.0.2", + "magic-string": "^0.30.21", + "postcss": "^8.5.19", + "source-map-js": "^1.2.1" + } + }, + "node_modules/@vue/compiler-sfc/node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "license": "MIT" + }, + "node_modules/@vue/compiler-ssr": { + "version": "3.5.42", + "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.5.42.tgz", + "integrity": "sha512-xmLk3wLkbizPAiLyomjgFFosf2ys9b5Ghb+oh/k2tnvipNz8OFrQOiTcWCzyK7MpBp9KkyGtfvgfLUivbmuGYA==", + "license": "MIT", + "dependencies": { + "@vue/compiler-dom": "3.5.42", + "@vue/shared": "3.5.42" + } + }, + "node_modules/@vue/devtools-core": { + "version": "8.2.1", + "resolved": "https://registry.npmjs.org/@vue/devtools-core/-/devtools-core-8.2.1.tgz", + "integrity": "sha512-s/VfAY9oDTb/kFEWmy461jaFde2MIV1RO/gi1vwM+PAZBZ/Pc2Ndu3BNBdZUze8QDUuyYvElbEEGA83syjJfzA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vue/devtools-kit": "^8.2.1", + "@vue/devtools-shared": "^8.2.1" + }, + "peerDependencies": { + "vue": "^3.0.0" + } + }, + "node_modules/@vue/devtools-kit": { + "version": "8.2.1", + "resolved": "https://registry.npmjs.org/@vue/devtools-kit/-/devtools-kit-8.2.1.tgz", + "integrity": "sha512-FIGIuq3AWReEpbAHY/cRGeHDfI0qOb8OCQ3YjbEAX04uaxIDbGc9rhkbVcG7rnfHPXE3RsU5KrWOu9V/okd8AQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vue/devtools-shared": "^8.2.1", + "birpc": "^2.6.1", + "hookable": "^5.5.3", + "perfect-debounce": "^2.0.0" + } + }, + "node_modules/@vue/devtools-shared": { + "version": "8.2.1", + "resolved": "https://registry.npmjs.org/@vue/devtools-shared/-/devtools-shared-8.2.1.tgz", + "integrity": "sha512-Fkac7lUdGReh6pVOi3AYPRGe82LQqRmAfThW7RRligOAP0ZA/Z1z9XLHDM9dv34pV2HRc79DK8uKPeG2fLnA/g==", + "dev": true, + "license": "MIT" + }, + "node_modules/@vue/eslint-config-prettier": { + "version": "10.2.0", + "resolved": "https://registry.npmjs.org/@vue/eslint-config-prettier/-/eslint-config-prettier-10.2.0.tgz", + "integrity": "sha512-GL3YBLwv/+b86yHcNNfPJxOTtVFJ4Mbc9UU3zR+KVoG7SwGTjPT+32fXamscNumElhcpXW3mT0DgzS9w32S7Bw==", + "dev": true, + "license": "MIT", + "dependencies": { + "eslint-config-prettier": "^10.0.1", + "eslint-plugin-prettier": "^5.2.2" + }, + "peerDependencies": { + "eslint": ">= 8.21.0", + "prettier": ">= 3.0.0" + } + }, + "node_modules/@vue/eslint-config-typescript": { + "version": "14.9.0", + "resolved": "https://registry.npmjs.org/@vue/eslint-config-typescript/-/eslint-config-typescript-14.9.0.tgz", + "integrity": "sha512-E3j9hDlfVf10F30MRcLTPY2IIhWIx1nsvkVukk14kTcuA+oBVot9zsP1hzsO+PAMDxV3Fd9FimBJtUBNBL5KFA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/utils": "^8.60.0", + "fast-glob": "^3.3.3", + "typescript-eslint": "^8.60.0", + "vue-eslint-parser": "^10.4.0" + }, + "bin": { + "vue-eslint-config-typescript": "dist/bin.js" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "peerDependencies": { + "eslint": "^9.10.0 || ^10.0.0", + "eslint-plugin-vue": "^9.28.0 || ^10.0.0", + "typescript": ">=4.8.4" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@vue/language-core": { + "version": "3.3.11", + "resolved": "https://registry.npmjs.org/@vue/language-core/-/language-core-3.3.11.tgz", + "integrity": "sha512-QJmpliwAVpC/OxubIByPAhNzsQPRc8/gxlN2qnVzVfIMjMDz/9RnXRFoetjz5yEgXVXyp4LqhXq3V53PjmNzFw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@volar/language-core": "2.4.28", + "@vue/compiler-dom": "^3.5.0", + "@vue/shared": "^3.5.0", + "alien-signals": "^3.2.1", + "muggle-string": "^0.4.1", + "path-browserify": "^1.0.1", + "picomatch": "^4.0.4" + } + }, + "node_modules/@vue/language-core/node_modules/picomatch": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/@vue/reactivity": { + "version": "3.5.42", + "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.5.42.tgz", + "integrity": "sha512-TzNNfKpb7hDxbQltwAut8VDQA5YP+BuRlxntHUuRjyKwlMvmAPbs3unhCvieijifY6vFfVBwsS7wG/C7uq+bEQ==", + "license": "MIT", + "dependencies": { + "@vue/shared": "3.5.42" + } + }, + "node_modules/@vue/runtime-core": { + "version": "3.5.42", + "resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.5.42.tgz", + "integrity": "sha512-9uACtuHs7vJGkm5Bp3xu4xRDLFTIYy5DgxpToVjqGIAhAEKwQfsaLvKINhM6nFVp6bZPRFGdDqd1g52MqKsotA==", + "license": "MIT", + "dependencies": { + "@vue/reactivity": "3.5.42", + "@vue/shared": "3.5.42" + } + }, + "node_modules/@vue/runtime-dom": { + "version": "3.5.42", + "resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.5.42.tgz", + "integrity": "sha512-rsCmhiWLaRxGltLwhlCWyYkFn7WAbKRh0q17eZ1A6Dq6eqc2ACQ61IIryxz0LrsvCzHSilLA9JHovVwM8CNE2g==", + "license": "MIT", + "dependencies": { + "@vue/reactivity": "3.5.42", + "@vue/runtime-core": "3.5.42", + "@vue/shared": "3.5.42", + "csstype": "^3.2.3" + } + }, + "node_modules/@vue/server-renderer": { + "version": "3.5.42", + "resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.5.42.tgz", + "integrity": "sha512-2++5dUyYS4gvo7xQXSECUDhB7TS0aOl5SeVfC5qSq1Jgfhjvegw1zqhwTIR3imZ+QYPJQw9gfcFvXGAjGZ7ajQ==", + "license": "MIT", + "dependencies": { + "@vue/compiler-ssr": "3.5.42", + "@vue/runtime-dom": "3.5.42", + "@vue/shared": "3.5.42" + } + }, + "node_modules/@vue/shared": { + "version": "3.5.42", + "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.5.42.tgz", + "integrity": "sha512-2rPxex1jQf4jvl9MOHl6YaXCPcrNqz/FstMOEh3QWY+/OME9nQTvl9WYeCwhW7AFjaR0SnngZGlp/wkR6rkI6g==", + "license": "MIT" + }, + "node_modules/@vue/tsconfig": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@vue/tsconfig/-/tsconfig-0.8.1.tgz", + "integrity": "sha512-aK7feIWPXFSUhsCP9PFqPyFOcz4ENkb8hZ2pneL6m2UjCkccvaOhC/5KCKluuBufvp2KzkbdA2W2pk20vLzu3g==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "typescript": "5.x", + "vue": "^3.4.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + }, + "vue": { + "optional": true + } + } + }, + "node_modules/@vueuse/core": { + "version": "14.4.0", + "resolved": "https://registry.npmjs.org/@vueuse/core/-/core-14.4.0.tgz", + "integrity": "sha512-X4WHz1HlCzCBoYXesUkifzzWBAcZgXG8Fi5iNPQg/epdzOB3gu8Fawj3hvuwYR1nGcXGnvxwYYcUC/71++svtQ==", + "license": "MIT", + "dependencies": { + "@types/web-bluetooth": "^0.0.21", + "@vueuse/metadata": "14.4.0", + "@vueuse/shared": "14.4.0" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + }, + "peerDependencies": { + "vue": "^3.5.0" + } + }, + "node_modules/@vueuse/metadata": { + "version": "14.4.0", + "resolved": "https://registry.npmjs.org/@vueuse/metadata/-/metadata-14.4.0.tgz", + "integrity": "sha512-swx/255R6JyHZFJhx845iz5CRWDZdCfvkZOpACWc5+c5WHcG24mv8gUT1WIdFQaHt6dq79rvILd9QnCWiyVm9g==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, + "node_modules/@vueuse/shared": { + "version": "14.4.0", + "resolved": "https://registry.npmjs.org/@vueuse/shared/-/shared-14.4.0.tgz", + "integrity": "sha512-JRgY90Sz8DDtPMsaDflvPMp9xYk69JZAmbuDvAquUVXKr2gEjqtzGNTTthLfckH0BzBqvnu31gb4a8TGLRe79g==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/antfu" + }, + "peerDependencies": { + "vue": "^3.5.0" + } + }, + "node_modules/acorn": { + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.18.0.tgz", + "integrity": "sha512-lGq+9yr1/GuAWaVYIHRjvvySG5/4VfKIvC8EWxStPdcDh/Ka7FG3twP6v4d5BkravUilhIAsG4Qj83t02LWUPQ==", + "dev": true, + "license": "MIT", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-jsx": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/agent-base": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", + "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", + "license": "MIT", + "dependencies": { + "debug": "4" + }, + "engines": { + "node": ">= 6.0.0" + } + }, + "node_modules/ajv": { + "version": "6.15.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.15.0.tgz", + "integrity": "sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/alien-signals": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/alien-signals/-/alien-signals-3.2.1.tgz", + "integrity": "sha512-I8FjmltrfnDFoZedi5CG8DghVYNhzb/Ijluz7tCSJH0xpd0484Kowhbb1XDYOxfJpU1p5wnM2X54dA+IfGyD1g==", + "dev": true, + "license": "MIT" + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/ansis": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/ansis/-/ansis-4.3.1.tgz", + "integrity": "sha512-BJ8/l4R5LRE7hW9WdSuGYrLSHi2ynxeFpDFbH0K/CgNeY/tyhk+vO6TYxXC5r5CpUhNVX310xzPsN/H9lCdfOA==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=14" + } + }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "license": "ISC", + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true, + "license": "Python-2.0" + }, + "node_modules/async-validator": { + "version": "4.2.5", + "resolved": "https://registry.npmjs.org/async-validator/-/async-validator-4.2.5.tgz", + "integrity": "sha512-7HhHjtERjqlNbZtqNqy2rckN/SpOOlmDliet+lP7k+eKZEjPk3DgyeU9lIXLdeLz0uBbbVp+9Qdow9wJWgwwfg==", + "license": "MIT" + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "license": "MIT" + }, + "node_modules/axios": { + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.20.0.tgz", + "integrity": "sha512-r8aOh8j9cGKpgQAqpzrUHnSIc6a59Y3Xf/cv8sy1DrHCkZHzQGEuoq1tARk6qSyDdtQGSDgpb9kFlruzPvrgwg==", + "license": "MIT", + "dependencies": { + "follow-redirects": "^1.16.0", + "form-data": "^4.0.6", + "https-proxy-agent": "^5.0.1", + "proxy-from-env": "^2.1.0" + } + }, + "node_modules/balanced-match": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", + "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "18 || 20 || >=22" + } + }, + "node_modules/baseline-browser-mapping": { + "version": "2.11.20", + "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.20.tgz", + "integrity": "sha512-H0ulySigv6icDJ1F7SjtdCD6PrhTpdYCmP0CactWy1+ekh0AFd0o1Wn5T8b+hnTmdBx19u9yhL6wvCylXMY7zw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "baseline-browser-mapping": "dist/cli.cjs" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/binary-extensions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", + "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/birpc": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/birpc/-/birpc-2.9.0.tgz", + "integrity": "sha512-KrayHS5pBi69Xi9JmvoqrIgYGDkD6mcSe/i6YKi3w5kekCLzrX4+nawcXqrj2tIp50Kw/mT/s3p+GVK0A0sKxw==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, + "node_modules/boolbase": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", + "integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==", + "dev": true, + "license": "ISC" + }, + "node_modules/brace-expansion": { + "version": "5.0.9", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.9.tgz", + "integrity": "sha512-ScQ4IuvIEF1TMlP7Zt+vjJ//9zlPb2SDcxWxM3bk8s6t6GGdJ7KO1dCcTidOPJKePW30LE/2cT7wCyPho9/Wxg==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^4.0.2" + }, + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/braces": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "license": "MIT", + "dependencies": { + "fill-range": "^7.1.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/browserslist": { + "version": "4.28.8", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.8.tgz", + "integrity": "sha512-V2NpofLblG64mfOtSgDhOJESZEGogzDMBv/q+W6oc4LXWP/q75eOXoOaaOu1EOadB9U4Bwx/e0yzbvwKH8zalA==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "baseline-browser-mapping": "^2.11.12", + "caniuse-lite": "^1.0.30001809", + "electron-to-chromium": "^1.5.402", + "node-releases": "^2.0.53", + "update-browserslist-db": "^1.3.0" + }, + "bin": { + "browserslist": "cli.js" + }, + "engines": { + "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + } + }, + "node_modules/bundle-name": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/bundle-name/-/bundle-name-4.1.0.tgz", + "integrity": "sha512-tjwM5exMg6BGRI+kNmTntNsvdZS1X8BFYS6tnJ2hdH0kVxM6/eVZ2xy+FqStSWvYmtfFMDLIxurorHwDKfDz5Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "run-applescript": "^7.0.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/caniuse-lite": { + "version": "1.0.30001810", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001810.tgz", + "integrity": "sha512-TITQPUkaz+aVk5GL6NhOdwk1aEaNTSDPsGFWrTuhKGtjTF70jL/Oht2W4c6rXUe5fu7Ie19VIahAXHIIiWWNeg==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "CC-BY-4.0" + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/chokidar/node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "license": "MIT" + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "license": "MIT", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/commander": { + "version": "15.0.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-15.0.0.tgz", + "integrity": "sha512-z67u4ZhzCL/Tydu1lJARtEZYWbWaN7oYLHbsuzocr6y4N6WZAagG3RQ4FW61V1/0+jImpj293XfrcYnd1qxtPg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=22.12.0" + } + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true, + "license": "MIT" + }, + "node_modules/confbox": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/confbox/-/confbox-0.2.4.tgz", + "integrity": "sha512-ysOGlgTFbN2/Y6Cg3Iye8YKulHw+R2fNXHrgSmXISQdMnomY6eNDprVdW9R5xBguEqI954+S6709UyiO7B+6OQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "dev": true, + "license": "MIT" + }, + "node_modules/cross-spawn": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/css-select": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/css-select/-/css-select-5.2.2.tgz", + "integrity": "sha512-TizTzUddG/xYLA3NXodFM0fSbNizXjOKhqiQQwvhlspadZokn1KDy0NZFS0wuEubIYAV5/c1/lAr0TaaFXEXzw==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "boolbase": "^1.0.0", + "css-what": "^6.1.0", + "domhandler": "^5.0.2", + "domutils": "^3.0.1", + "nth-check": "^2.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/fb55" + } + }, + "node_modules/css-tree": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-2.3.1.tgz", + "integrity": "sha512-6Fv1DV/TYw//QF5IzQdqsNDjx/wc8TrMBZsqjL9eW01tWb7R7k/mq+/VXfJCl7SoD5emsJop9cOByJZfs8hYIw==", + "dev": true, + "license": "MIT", + "dependencies": { + "mdn-data": "2.0.30", + "source-map-js": "^1.0.1" + }, + "engines": { + "node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0" + } + }, + "node_modules/css-what": { + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/css-what/-/css-what-6.2.2.tgz", + "integrity": "sha512-u/O3vwbptzhMs3L1fQE82ZSLHQQfto5gyZzwteVIEyeaY5Fc7R4dapF/BvRoSYFeqfBk4m0V1Vafq5Pjv25wvA==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">= 6" + }, + "funding": { + "url": "https://github.com/sponsors/fb55" + } + }, + "node_modules/cssesc": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz", + "integrity": "sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==", + "dev": true, + "license": "MIT", + "bin": { + "cssesc": "bin/cssesc" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/csso": { + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/csso/-/csso-5.0.5.tgz", + "integrity": "sha512-0LrrStPOdJj+SPCCrGhzryycLjwcgUSHBtxNA8aIDxf0GLsRh1cKYhB00Gd1lDOS4yGH69+SNn13+TWbVHETFQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "css-tree": "~2.2.0" + }, + "engines": { + "node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0", + "npm": ">=7.0.0" + } + }, + "node_modules/csso/node_modules/css-tree": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-2.2.1.tgz", + "integrity": "sha512-OA0mILzGc1kCOCSJerOeqDxDQ4HOh+G8NbOJFOTgOCzpw7fCBubk0fEyxp8AgOL/jvLgYA/uV0cMbe43ElF1JA==", + "dev": true, + "license": "MIT", + "dependencies": { + "mdn-data": "2.0.28", + "source-map-js": "^1.0.1" + }, + "engines": { + "node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0", + "npm": ">=7.0.0" + } + }, + "node_modules/csso/node_modules/mdn-data": { + "version": "2.0.28", + "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.28.tgz", + "integrity": "sha512-aylIc7Z9y4yzHYAJNuESG3hfhC+0Ibp/MAMiaOZgNv4pmEdFyfZhhhny4MNiAfWdBQ1RQ2mfDWmM1x8SvGyp8g==", + "dev": true, + "license": "CC0-1.0" + }, + "node_modules/csstype": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz", + "integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==", + "license": "MIT" + }, + "node_modules/dayjs": { + "version": "1.11.23", + "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.23.tgz", + "integrity": "sha512-QDTCU0M0MxR3hQfnlDJfwekQiaanm1ubOD231u73WBckQ/fsamwRLiE2GBz6D3a/xF1NgfiDLJjXBa1hYOYTtQ==", + "license": "MIT" + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/deep-is": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/default-browser": { + "version": "5.5.1", + "resolved": "https://registry.npmjs.org/default-browser/-/default-browser-5.5.1.tgz", + "integrity": "sha512-m1pAzaJgZ/gssEqlOhJkPJp8Xly7QyW6xcrkUa2KKcDeDSEMP7X8xipU3snUcfisTQx0w1AGae+9UtJSfVnXGw==", + "dev": true, + "license": "MIT", + "dependencies": { + "bundle-name": "^4.1.0", + "default-browser-id": "^5.0.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/default-browser-id": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/default-browser-id/-/default-browser-id-5.0.1.tgz", + "integrity": "sha512-x1VCxdX4t+8wVfd1so/9w+vQ4vx7lKd2Qp5tDRutErwmR85OgmfX7RlLRMWafRMY7hbEiXIbudNrjOAPa/hL8Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/define-lazy-prop": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-3.0.0.tgz", + "integrity": "sha512-N+MeXYoqr3pOgn8xfyRPREN7gHakLYjhsHhWGT3fWAiL4IkAt0iDw14QiiEm2bE30c5XX5q0FtAA3CK5f9/BUg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "license": "MIT", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/detect-libc": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", + "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", + "license": "Apache-2.0", + "engines": { + "node": ">=8" + } + }, + "node_modules/dom-serializer": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz", + "integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==", + "dev": true, + "license": "MIT", + "dependencies": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.2", + "entities": "^4.2.0" + }, + "funding": { + "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1" + } + }, + "node_modules/dom-serializer/node_modules/entities": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", + "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/domelementtype": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", + "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ], + "license": "BSD-2-Clause" + }, + "node_modules/domhandler": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz", + "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "domelementtype": "^2.3.0" + }, + "engines": { + "node": ">= 4" + }, + "funding": { + "url": "https://github.com/fb55/domhandler?sponsor=1" + } + }, + "node_modules/domutils": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-3.2.2.tgz", + "integrity": "sha512-6kZKyUajlDuqlHKVX1w7gyslj9MPIXzIFiz/rGu35uC1wMi+kMhQwGhl4lt9unC9Vb9INnY9Z3/ZA3+FhASLaw==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "dom-serializer": "^2.0.0", + "domelementtype": "^2.3.0", + "domhandler": "^5.0.3" + }, + "funding": { + "url": "https://github.com/fb55/domutils?sponsor=1" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/electron-to-chromium": { + "version": "1.5.416", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.416.tgz", + "integrity": "sha512-K6bvB2BjnNrugtIih6ewlbBI9DXa976jIdiIlRLHhBoEI9a4JaQjjHyF+A1IQI543aQYR4LnmOrT/K5fZj0aPA==", + "dev": true, + "license": "ISC" + }, + "node_modules/element-plus": { + "version": "2.14.5", + "resolved": "https://registry.npmjs.org/element-plus/-/element-plus-2.14.5.tgz", + "integrity": "sha512-bghYy/S+qg87enHPXELirhEdDqsVAUGcGpbGIeG8dz0kwpIkGz7gYsifulBshXX74iRtHib85XWQj0uSH2A1Yg==", + "license": "MIT", + "dependencies": { + "@ctrl/tinycolor": "^4.2.0", + "@element-plus/icons-vue": "^2.3.2", + "@floating-ui/dom": "^1.8.0", + "@popperjs/core": "npm:@sxzz/popperjs-es@^2.11.8", + "@types/lodash": "^4.17.24", + "@types/lodash-es": "^4.17.12", + "@vueuse/core": "14.4.0", + "async-validator": "^4.2.5", + "dayjs": "^1.11.20", + "lodash": "^4.18.1", + "lodash-es": "^4.18.1", + "lodash-unified": "^1.0.3", + "memoize-one": "^6.0.0", + "normalize-wheel-es": "^1.2.0", + "vue-component-type-helpers": "^3.3.9" + }, + "peerDependencies": { + "vue": "^3.3.7" + } + }, + "node_modules/entities": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/entities/-/entities-7.0.1.tgz", + "integrity": "sha512-TWrgLOFUQTH994YUyl1yT4uyavY5nNB5muff+RtWaqNVCAK408b5ZnnbNAUEWLTCpum9w6arT70i1XdQ4UeOPA==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/error-stack-parser-es": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/error-stack-parser-es/-/error-stack-parser-es-1.0.5.tgz", + "integrity": "sha512-5qucVt2XcuGMcEGgWI7i+yZpmpByQ8J1lHhcL7PwqCwu9FPP3VUXzT4ltHe5i2z9dePwEHcDVOAfSnHsOlCXRA==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz", + "integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-set-tostringtag": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", + "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/escalade": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint": { + "version": "9.39.5", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.39.5.tgz", + "integrity": "sha512-DgZS62aPLXKlnxILS/AYCoRvHaZeXceIzlXPkkGGzJWSow1aEk0lbTlxUSlyjC8jcaKxAdOnTDz+o1JFSBsyjw==", + "deprecated": "This version is no longer supported. Please see https://eslint.org/version-support for other options.", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.8.0", + "@eslint-community/regexpp": "^4.12.1", + "@eslint/config-array": "^0.21.2", + "@eslint/config-helpers": "^0.4.2", + "@eslint/core": "^0.17.0", + "@eslint/eslintrc": "^3.3.6", + "@eslint/js": "9.39.5", + "@eslint/plugin-kit": "^0.4.1", + "@humanfs/node": "^0.16.6", + "@humanwhocodes/module-importer": "^1.0.1", + "@humanwhocodes/retry": "^0.4.2", + "@types/estree": "^1.0.6", + "ajv": "^6.14.0", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.6", + "debug": "^4.3.2", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^8.4.0", + "eslint-visitor-keys": "^4.2.1", + "espree": "^10.4.0", + "esquery": "^1.5.0", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^8.0.0", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "ignore": "^5.2.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "json-stable-stringify-without-jsonify": "^1.0.1", + "lodash.merge": "^4.6.2", + "minimatch": "^3.1.5", + "natural-compare": "^1.4.0", + "optionator": "^0.9.3" + }, + "bin": { + "eslint": "bin/eslint.js" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://eslint.org/donate" + }, + "peerDependencies": { + "jiti": "*" + }, + "peerDependenciesMeta": { + "jiti": { + "optional": true + } + } + }, + "node_modules/eslint-config-prettier": { + "version": "10.1.8", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-10.1.8.tgz", + "integrity": "sha512-82GZUjRS0p/jganf6q1rEO25VSoHH0hKPCTrgillPjdI/3bgBhAE1QzHrHTizjpRvy6pGAvKjDJtk2pF9NDq8w==", + "dev": true, + "license": "MIT", + "bin": { + "eslint-config-prettier": "bin/cli.js" + }, + "funding": { + "url": "https://opencollective.com/eslint-config-prettier" + }, + "peerDependencies": { + "eslint": ">=7.0.0" + } + }, + "node_modules/eslint-plugin-oxlint": { + "version": "1.11.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-oxlint/-/eslint-plugin-oxlint-1.11.2.tgz", + "integrity": "sha512-I2dxNhSfaPdgCWoHcS4gFQ50gr+95WeQZiLJv7XlC4WXmqFtcG3gheRuz9efV5xcEwJO152HpxEngoGoxNUK8A==", + "dev": true, + "license": "MIT", + "dependencies": { + "jsonc-parser": "^3.3.1" + } + }, + "node_modules/eslint-plugin-prettier": { + "version": "5.5.6", + "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.5.6.tgz", + "integrity": "sha512-ifetmTcxWfz+4qRW3pH/ujdTq2jQIj59AxJMIN26K5avYgU8dxycUETQonWiW+wPrYXA0j3Try0l1CnwVQtDqQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "prettier-linter-helpers": "^1.0.1", + "synckit": "^0.11.13" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint-plugin-prettier" + }, + "peerDependencies": { + "@types/eslint": ">=8.0.0", + "eslint": ">=8.0.0", + "eslint-config-prettier": ">= 7.0.0 <10.0.0 || >=10.1.0", + "prettier": ">=3.0.0" + }, + "peerDependenciesMeta": { + "@types/eslint": { + "optional": true + }, + "eslint-config-prettier": { + "optional": true + } + } + }, + "node_modules/eslint-plugin-vue": { + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-vue/-/eslint-plugin-vue-10.4.0.tgz", + "integrity": "sha512-K6tP0dW8FJVZLQxa2S7LcE1lLw3X8VvB3t887Q6CLrFVxHYBXGANbXvwNzYIu6Ughx1bSJ5BDT0YB3ybPT39lw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0", + "natural-compare": "^1.4.0", + "nth-check": "^2.1.1", + "postcss-selector-parser": "^6.0.15", + "semver": "^7.6.3", + "xml-name-validator": "^4.0.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "peerDependencies": { + "@typescript-eslint/parser": "^7.0.0 || ^8.0.0", + "eslint": "^8.57.0 || ^9.0.0", + "vue-eslint-parser": "^10.0.0" + }, + "peerDependenciesMeta": { + "@typescript-eslint/parser": { + "optional": true + } + } + }, + "node_modules/eslint-scope": { + "version": "8.4.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.4.0.tgz", + "integrity": "sha512-sNXOfKCn74rt8RICKMvJS7XKV/Xk9kA7DyJr8mJik3S7Cwgy3qlkkmyS2uQB3jiJg6VNdZd/pDBJu0nvG2NlTg==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint/node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/eslint/node_modules/brace-expansion": { + "version": "1.1.18", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.18.tgz", + "integrity": "sha512-Edep/X9fGqVNmzKBVsDYIOtD+z1tuezV70LBjdCst9Tqu76lsnvRiZ6oTic1n+/BIwX6QDGAO94PN4N2SADvtw==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/eslint/node_modules/eslint-visitor-keys": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz", + "integrity": "sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint/node_modules/minimatch": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", + "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/espree": { + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-10.4.0.tgz", + "integrity": "sha512-j6PAQ2uUr79PZhBjP5C5fhl8e39FmRnOjsD5lGnWrFU8i2G776tBK7+nP8KuQUTTyAZUwfQqXAgrVH5MbH9CYQ==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "acorn": "^8.15.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^4.2.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/espree/node_modules/eslint-visitor-keys": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz", + "integrity": "sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/esquery": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.7.0.tgz", + "integrity": "sha512-Ap6G0WQwcU/LHsvLwON1fAQX9Zp0A2Y6Y/cJBl9r/JbW90Zyg4/zbG6zzKa2OTALELarYHmKu0GhpM5EO+7T0g==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "estraverse": "^5.1.0" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "estraverse": "^5.2.0" + }, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estree-walker": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", + "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.0" + } + }, + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/exsolve": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/exsolve/-/exsolve-1.1.1.tgz", + "integrity": "sha512-9U/jZUgjnSGyntRr6y5Muu1MJcwFl6kPu7k8qLF0IMNfLqvw0NZ4nnVDq0RVoZ0RvCyumib4Ez3KYrVfilrw+g==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-diff": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz", + "integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==", + "dev": true, + "license": "Apache-2.0" + }, + "node_modules/fast-glob": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.3.tgz", + "integrity": "sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.8" + }, + "engines": { + "node": ">=8.6.0" + } + }, + "node_modules/fast-glob/node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", + "dev": true, + "license": "MIT" + }, + "node_modules/fastq": { + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.20.2.tgz", + "integrity": "sha512-UpGiiODyCGprM8EPP6JodP6jC9Rws6TCuiDOD+nn0CJhR8guI3g/ozo4ugL0vJ+Yz1UtJuuRPqvQuybVOF1VQA==", + "dev": true, + "license": "ISC", + "dependencies": { + "reusify": "^1.0.4" + } + }, + "node_modules/file-entry-cache": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz", + "integrity": "sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "flat-cache": "^4.0.0" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "license": "MIT", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "license": "MIT", + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/flat-cache": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-4.0.1.tgz", + "integrity": "sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==", + "dev": true, + "license": "MIT", + "dependencies": { + "flatted": "^3.2.9", + "keyv": "^4.5.4" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/flatted": { + "version": "3.4.4", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.4.4.tgz", + "integrity": "sha512-5+ybhBZANEJxaH3X5evAFatUxLfEHSr7n6kYJ+1Qd0mUqr4eu9gIf6GDbWHf8RJijHrjjO8G+la14SlL2SeS1Q==", + "dev": true, + "license": "ISC" + }, + "node_modules/follow-redirects": { + "version": "1.16.0", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.16.0.tgz", + "integrity": "sha512-y5rN/uOsadFT/JfYwhxRS5R7Qce+g3zG97+JrtFZlC9klX/W5hD7iiLzScI4nZqUS7DNUdhPgw4xI8W2LuXlUw==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "license": "MIT", + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/form-data": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.6.tgz", + "integrity": "sha512-vKatAh4SlVfgbv+YtmhiRjhEMJsYpsG1Y2rMQtR+SVSbytsSD1YGzDIcrAJmdFec88u/+VoGmxnl+80gL1tRCQ==", + "license": "MIT", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "es-set-tostringtag": "^2.1.0", + "hasown": "^2.0.4", + "mime-types": "^2.1.35" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/gensync": { + "version": "1.0.0-beta.2", + "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", + "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/globals": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", + "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-tostringtag": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "license": "MIT", + "dependencies": { + "has-symbols": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz", + "integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==", + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/hookable": { + "version": "5.5.3", + "resolved": "https://registry.npmjs.org/hookable/-/hookable-5.5.3.tgz", + "integrity": "sha512-Yc+BQe8SvoXH1643Qez1zqLRmbA5rCL+sSmk6TVos0LWVfNIB7PGncdlId77WzLGSIB5KaWgTaNTs2lNVEI6VQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/https-proxy-agent": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", + "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", + "license": "MIT", + "dependencies": { + "agent-base": "6", + "debug": "4" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/ignore": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", + "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, + "node_modules/import-fresh": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz", + "integrity": "sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.8.19" + } + }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "license": "MIT", + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-docker": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-3.0.0.tgz", + "integrity": "sha512-eljcgEDlEns/7AXFosB5K/2nCM4P7FQPkGc/DWLy5rmFEWvZayGrik1d9/QIY5nJ4f9YsVvBkA6kJpHn9rISdQ==", + "dev": true, + "license": "MIT", + "bin": { + "is-docker": "cli.js" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-in-ssh": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-in-ssh/-/is-in-ssh-1.0.0.tgz", + "integrity": "sha512-jYa6Q9rH90kR1vKB6NM7qqd1mge3Fx4Dhw5TVlK1MUBqhEOuCagrEHMevNuCcbECmXZ0ThXkRm+Ymr51HwEPAw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-inside-container": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-inside-container/-/is-inside-container-1.0.0.tgz", + "integrity": "sha512-KIYLCCJghfHZxqjYBE7rEy0OBuTd5xCHS7tHVgvCLkx7StIoaxwNW3hCALgEUjFfeRk+MG/Qxmp/vtETEF3tRA==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-docker": "^3.0.0" + }, + "bin": { + "is-inside-container": "cli.js" + }, + "engines": { + "node": ">=14.16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "license": "MIT", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-wsl": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-3.1.1.tgz", + "integrity": "sha512-e6rvdUCiQCAuumZslxRJWR/Doq4VpPR82kqclvcS0efgt430SlGIk05vdCN58+VrzgtIcfNODjozVielycD4Sw==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-inside-container": "^1.0.0" + }, + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true, + "license": "ISC" + }, + "node_modules/jiti": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/jiti/-/jiti-2.7.0.tgz", + "integrity": "sha512-AC/7JofJvZGrrneWNaEnJeOLUx+JlGt7tNa0wZiRPT4MY1wmfKjt2+6O2p2uz2+skll8OZZmJMNqeke7kKbNgQ==", + "devOptional": true, + "license": "MIT", + "bin": { + "jiti": "lib/jiti-cli.mjs" + } + }, + "node_modules/js-tokens": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-9.0.1.tgz", + "integrity": "sha512-mxa9E9ITFOt0ban3j6L5MpjwegGz6lBQmM1IJkWeBZGcMxto50+eWdjC/52xDbS2vy0k7vIMK0Fe2wfL9OQSpQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/js-yaml": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.2.tgz", + "integrity": "sha512-SFNOvSJ+Dgf/9An904Yx+CgSlIPCkIpao4qo51lpee25TIRejdH3rhR4EZMGoNx3/TP3O+wzWuiTFl4sqbltzA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/puzrin" + }, + { + "type": "github", + "url": "https://github.com/sponsors/nodeca" + } + ], + "license": "MIT", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/jsesc": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz", + "integrity": "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==", + "dev": true, + "license": "MIT", + "bin": { + "jsesc": "bin/jsesc" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/json-buffer": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", + "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/json-parse-even-better-errors": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-4.0.0.tgz", + "integrity": "sha512-lR4MXjGNgkJc7tkQ97kb2nuEMnNCyU//XYVH0MKTGcXEiSudQ5MKGKen3C5QubYy0vmq+JGitUg92uuywGEwIA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.17.0 || >=20.5.0" + } + }, + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true, + "license": "MIT" + }, + "node_modules/json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/json5": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "dev": true, + "license": "MIT", + "bin": { + "json5": "lib/cli.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/jsonc-parser": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.3.1.tgz", + "integrity": "sha512-HUgH65KyejrUFPvHFPbqOY0rsFip3Bo5wb4ngvdi1EpCYWUQDC5V+Y7mZws+DLkr4M//zQJoanu1SP+87Dv1oQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/keyv": { + "version": "4.5.4", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", + "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", + "dev": true, + "license": "MIT", + "dependencies": { + "json-buffer": "3.0.1" + } + }, + "node_modules/kolorist": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/kolorist/-/kolorist-1.8.0.tgz", + "integrity": "sha512-Y+60/zizpJ3HRH8DCss+q95yr6145JXZo46OTpFvDZWLfRCE4qChOyk1b26nMaNpfHHgxagk9dXT5OP0Tfe+dQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/lightningcss": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.33.0.tgz", + "integrity": "sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA==", + "license": "MPL-2.0", + "dependencies": { + "detect-libc": "^2.0.3" + }, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + }, + "optionalDependencies": { + "lightningcss-android-arm64": "1.33.0", + "lightningcss-darwin-arm64": "1.33.0", + "lightningcss-darwin-x64": "1.33.0", + "lightningcss-freebsd-x64": "1.33.0", + "lightningcss-linux-arm-gnueabihf": "1.33.0", + "lightningcss-linux-arm64-gnu": "1.33.0", + "lightningcss-linux-arm64-musl": "1.33.0", + "lightningcss-linux-x64-gnu": "1.33.0", + "lightningcss-linux-x64-musl": "1.33.0", + "lightningcss-win32-arm64-msvc": "1.33.0", + "lightningcss-win32-x64-msvc": "1.33.0" + } + }, + "node_modules/lightningcss-android-arm64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-android-arm64/-/lightningcss-android-arm64-1.33.0.tgz", + "integrity": "sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg==", + "cpu": [ + "arm64" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-darwin-arm64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.33.0.tgz", + "integrity": "sha512-Sciaz8eenNTKn9b3t7+xr0ipTp9YxKQY4npwQ3mrRuL0BAVHBLyZxofhaKBAVtzmtRZ/zTyo0/to4B1uWG/Djg==", + "cpu": [ + "arm64" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-darwin-x64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.33.0.tgz", + "integrity": "sha512-Z5UPAxzrjlWNNyGy6i65cJzzvgJ5D3T6wMvs+gWpY9d7qRhANrxqAp6LhxIgZhWEw18RfJTGcRxjuLIBr+m8XQ==", + "cpu": [ + "x64" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-freebsd-x64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.33.0.tgz", + "integrity": "sha512-QQM/Ti/hQajJwCY+RiWuCZ9sdtI/XQk7nDK5vC8kkdwixezOlDgvDx7+RT+QjK6FcFT4MpsuoBnHIo/O3StRRg==", + "cpu": [ + "x64" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm-gnueabihf": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.33.0.tgz", + "integrity": "sha512-N7FVBe6iS24MlM6R/4RBTxGhQheZGs7tiQ9U32UtF75NzP5Q7xWPRqLBCKxlRQRk3rY1jCIPLzx7WzOhuUIRLQ==", + "cpu": [ + "arm" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm64-gnu": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.33.0.tgz", + "integrity": "sha512-j2v/itmy4HlNxlc6voKXYgBqNi0Ng2LShg4z7GufpEgs05P+2suBVyi9I6YHq5uoVFx9ETin3eCEhLVyXGQnKg==", + "cpu": [ + "arm64" + ], + "libc": [ + "glibc" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm64-musl": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.33.0.tgz", + "integrity": "sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ==", + "cpu": [ + "arm64" + ], + "libc": [ + "musl" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-x64-gnu": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.33.0.tgz", + "integrity": "sha512-ar+Ju7LmcN0Jo4FpL4hpFybwNG9/3A/Br5KW2n2jyODg3MEZXaDYADdemoNS+BDNfMgKvylJLj4S5tyRActuAg==", + "cpu": [ + "x64" + ], + "libc": [ + "glibc" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-x64-musl": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.33.0.tgz", + "integrity": "sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw==", + "cpu": [ + "x64" + ], + "libc": [ + "musl" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-win32-arm64-msvc": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.33.0.tgz", + "integrity": "sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA==", + "cpu": [ + "arm64" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-win32-x64-msvc": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.33.0.tgz", + "integrity": "sha512-OlEICDx/Xl0FqSp4bry8zFnCvGpig3Gl4gCquvYwHuqJKEC1+n9NgDniFvqHGmMv1ZkqDJrDqKKSykTDX+ehuA==", + "cpu": [ + "x64" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/local-pkg": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/local-pkg/-/local-pkg-1.2.1.tgz", + "integrity": "sha512-++gUqRDEvcnN6Zhqrr+y/CkVEHhlrR96vZn3nZZPYzMcBUyBtTKzB9NadClFIsIVSsu+3i9tfk/erqy9kAmt7Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "mlly": "^1.7.4", + "pkg-types": "^2.3.0", + "quansync": "^0.2.11" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, + "node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/lodash": { + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.18.1.tgz", + "integrity": "sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q==", + "license": "MIT" + }, + "node_modules/lodash-es": { + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.18.1.tgz", + "integrity": "sha512-J8xewKD/Gk22OZbhpOVSwcs60zhd95ESDwezOFuA3/099925PdHJ7OFHNTGtajL3AlZkykD32HykiMo+BIBI8A==", + "license": "MIT" + }, + "node_modules/lodash-unified": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/lodash-unified/-/lodash-unified-1.0.3.tgz", + "integrity": "sha512-WK9qSozxXOD7ZJQlpSqOT+om2ZfcT4yO+03FuzAHD0wF6S0l0090LRPDx3vhTTLZ8cFKpBn+IOcVXK6qOcIlfQ==", + "license": "MIT", + "peerDependencies": { + "@types/lodash-es": "*", + "lodash": "*", + "lodash-es": "*" + } + }, + "node_modules/lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/lru-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "dev": true, + "license": "ISC", + "dependencies": { + "yallist": "^3.0.2" + } + }, + "node_modules/magic-string": { + "version": "0.30.21", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", + "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==", + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.5" + } + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/mdn-data": { + "version": "2.0.30", + "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.30.tgz", + "integrity": "sha512-GaqWWShW4kv/G9IEucWScBx9G1/vsFZZJUO+tD26M8J8z3Kw5RDQjaoZe03YAClgeS/SWPOcb4nkFBTEi5DUEA==", + "dev": true, + "license": "CC0-1.0" + }, + "node_modules/memoize-one": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/memoize-one/-/memoize-one-6.0.0.tgz", + "integrity": "sha512-rkpe71W0N0c0Xz6QD0eJETuWAJGnJ9afsl1srmwPrI+yBCkge5EycXXbYRyvL29zZVUWQCY7InPRCv3GDXuZNw==", + "license": "MIT" + }, + "node_modules/memorystream": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/memorystream/-/memorystream-0.3.1.tgz", + "integrity": "sha512-S3UwM3yj5mtUSEfP41UZmt/0SCoVYUcU1rkXv+BQ5Ig8ndL4sPoJNBUJERafdPb5jjHJGuMgytgKvKIf58XNBw==", + "dev": true, + "engines": { + "node": ">= 0.10.0" + } + }, + "node_modules/merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, + "node_modules/micromatch": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", + "license": "MIT", + "dependencies": { + "braces": "^3.0.3", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/minimatch": { + "version": "10.2.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz", + "integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "brace-expansion": "^5.0.8" + }, + "engines": { + "node": "18 || 20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/mlly": { + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/mlly/-/mlly-1.8.2.tgz", + "integrity": "sha512-d+ObxMQFmbt10sretNDytwt85VrbkhhUA/JBGm1MPaWJ65Cl4wOgLaB1NYvJSZ0Ef03MMEU/0xpPMXUIQ29UfA==", + "dev": true, + "license": "MIT", + "dependencies": { + "acorn": "^8.16.0", + "pathe": "^2.0.3", + "pkg-types": "^1.3.1", + "ufo": "^1.6.3" + } + }, + "node_modules/mlly/node_modules/confbox": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/confbox/-/confbox-0.1.8.tgz", + "integrity": "sha512-RMtmw0iFkeR4YV+fUOSucriAQNb9g8zFR52MWCtl+cCZOFRNL6zeB395vPzFhEjjn4fMxXudmELnl/KF/WrK6w==", + "dev": true, + "license": "MIT" + }, + "node_modules/mlly/node_modules/pkg-types": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/pkg-types/-/pkg-types-1.3.1.tgz", + "integrity": "sha512-/Jm5M4RvtBFVkKWRu2BLUTNP8/M2a+UwuAX+ae4770q1qVGtfjG+WTCupoZixokjmHiry8uI+dlY8KXYV5HVVQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "confbox": "^0.1.8", + "mlly": "^1.7.4", + "pathe": "^2.0.1" + } + }, + "node_modules/mockjs": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/mockjs/-/mockjs-1.1.0.tgz", + "integrity": "sha512-eQsKcWzIaZzEZ07NuEyO4Nw65g0hdWAyurVol1IPl1gahRwY+svqzfgfey8U8dahLwG44d6/RwEzuK52rSa/JQ==", + "dev": true, + "dependencies": { + "commander": "*" + }, + "bin": { + "random": "bin/random" + } + }, + "node_modules/mrmime": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/mrmime/-/mrmime-2.0.1.tgz", + "integrity": "sha512-Y3wQdFg2Va6etvQ5I82yUhGdsKrcYox6p7FfL1LbK2J4V01F9TGlepTIhnK24t7koZibmg82KGglhA1XK5IsLQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/muggle-string": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/muggle-string/-/muggle-string-0.4.1.tgz", + "integrity": "sha512-VNTrAak/KhO2i8dqqnqnAHOa3cYBwXEZe9h+D5h/1ZqFSTEFHdM65lR7RoIqq3tBBYavsOXV84NoHXZ0AkPyqQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/nanoid": { + "version": "3.3.18", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.18.tgz", + "integrity": "sha512-DTg4MJbGMWkfi6VZFdNt2/caMbQy4Ou+Op/hJQvGEWcnVfoA1QA+xzRKAzw9jD6+GVOOeYr/mIcuDSdug6F6+w==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", + "dev": true, + "license": "MIT" + }, + "node_modules/node-releases": { + "version": "2.0.54", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.54.tgz", + "integrity": "sha512-YHs7BmmcsdAI5Ozuf8JZo6PT0mv2GIWC9vMfvUC3dp65M8hn7Ux8CPL+2oBI7juNuj9d0ndhTcznq2ODBps9cQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/normalize-wheel-es": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/normalize-wheel-es/-/normalize-wheel-es-1.2.0.tgz", + "integrity": "sha512-Wj7+EJQ8mSuXr2iWfnujrimU35R2W4FAErEyTmJoJ7ucwTn2hOUSsRehMb5RSYkxXGTM7Y9QpvPmp++w5ftoJw==", + "license": "BSD-3-Clause" + }, + "node_modules/npm-normalize-package-bin": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/npm-normalize-package-bin/-/npm-normalize-package-bin-4.0.0.tgz", + "integrity": "sha512-TZKxPvItzai9kN9H/TkmCtx/ZN/hvr3vUycjlfmH0ootY9yFBzNOpiXAdIn1Iteqsvk4lQn6B5PTrt+n6h8k/w==", + "dev": true, + "license": "ISC", + "engines": { + "node": "^18.17.0 || >=20.5.0" + } + }, + "node_modules/npm-run-all2": { + "version": "8.0.4", + "resolved": "https://registry.npmjs.org/npm-run-all2/-/npm-run-all2-8.0.4.tgz", + "integrity": "sha512-wdbB5My48XKp2ZfJUlhnLVihzeuA1hgBnqB2J9ahV77wLS+/YAJAlN8I+X3DIFIPZ3m5L7nplmlbhNiFDmXRDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^6.2.1", + "cross-spawn": "^7.0.6", + "memorystream": "^0.3.1", + "picomatch": "^4.0.2", + "pidtree": "^0.6.0", + "read-package-json-fast": "^4.0.0", + "shell-quote": "^1.7.3", + "which": "^5.0.0" + }, + "bin": { + "npm-run-all": "bin/npm-run-all/index.js", + "npm-run-all2": "bin/npm-run-all/index.js", + "run-p": "bin/run-p/index.js", + "run-s": "bin/run-s/index.js" + }, + "engines": { + "node": "^20.5.0 || >=22.0.0", + "npm": ">= 10" + } + }, + "node_modules/npm-run-all2/node_modules/ansi-styles": { + "version": "6.2.3", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.3.tgz", + "integrity": "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/npm-run-all2/node_modules/isexe": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-3.1.5.tgz", + "integrity": "sha512-6B3tLtFqtQS4ekarvLVMZ+X+VlvQekbe4taUkf/rhVO3d/h0M2rfARm/pXLcPEsjjMsFgrFgSrhQIxcSVrBz8w==", + "dev": true, + "license": "BlueOak-1.0.0", + "engines": { + "node": ">=18" + } + }, + "node_modules/npm-run-all2/node_modules/picomatch": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/npm-run-all2/node_modules/which": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/which/-/which-5.0.0.tgz", + "integrity": "sha512-JEdGzHwwkrbWoGOlIHqQ5gtprKGOenpDHpxE9zVR1bWbOtYRyPPHMe9FaP6x61CmNaTThSkb0DAJte5jD+DmzQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "isexe": "^3.1.1" + }, + "bin": { + "node-which": "bin/which.js" + }, + "engines": { + "node": "^18.17.0 || >=20.5.0" + } + }, + "node_modules/nth-check": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.1.1.tgz", + "integrity": "sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "boolbase": "^1.0.0" + }, + "funding": { + "url": "https://github.com/fb55/nth-check?sponsor=1" + } + }, + "node_modules/obug": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/obug/-/obug-2.1.4.tgz", + "integrity": "sha512-4a+OsYv9UktOJKE+l1A4OufDgdRF9PifWj+tJnHURo/P+WOxpG4GzUFL9qCalmWauao6ogiG+QvnCovwPoyAWA==", + "dev": true, + "funding": [ + "https://github.com/sponsors/sxzz", + "https://opencollective.com/debug" + ], + "license": "MIT", + "engines": { + "node": ">=12.20.0" + } + }, + "node_modules/ohash": { + "version": "2.0.12", + "resolved": "https://registry.npmjs.org/ohash/-/ohash-2.0.12.tgz", + "integrity": "sha512-65S/5gk9YSsaRjcyf7Nfa6h/d3E8/1gslpXfI4W7Dxn/oap8IKRuNT5VXkLQ1YFKIEg4apRY4Pj6aiwFzrDdmw==", + "dev": true, + "license": "MIT" + }, + "node_modules/open": { + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/open/-/open-11.0.1.tgz", + "integrity": "sha512-NzwMUB6C1D0+Kd+9iMS/H4k+Ck3cTX6Ckyfr/gAGlmvSE1LUQZnEZvWBi4PYmMwH/S5SMeTXnE+9uAz8uF+pWw==", + "dev": true, + "license": "MIT", + "dependencies": { + "default-browser": "^5.4.0", + "define-lazy-prop": "^3.0.0", + "is-in-ssh": "^1.0.0", + "is-inside-container": "^1.0.0", + "powershell-utils": "^0.2.0", + "wsl-utils": "^1.0.0" + }, + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/optionator": { + "version": "0.9.4", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", + "integrity": "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==", + "dev": true, + "license": "MIT", + "dependencies": { + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.5" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/oxlint": { + "version": "1.11.2", + "resolved": "https://registry.npmjs.org/oxlint/-/oxlint-1.11.2.tgz", + "integrity": "sha512-/MDUxbel5vrwxWgiGU6hZzhDiTv0TUlyZak+WP+SaTO709du+6F07zCDvYj5lgkAnEcFbdrUlA67HEnleGR0Zw==", + "dev": true, + "license": "MIT", + "bin": { + "oxc_language_server": "bin/oxc_language_server", + "oxlint": "bin/oxlint" + }, + "engines": { + "node": ">=8.*" + }, + "funding": { + "url": "https://github.com/sponsors/Boshen" + }, + "optionalDependencies": { + "@oxlint/darwin-arm64": "1.11.2", + "@oxlint/darwin-x64": "1.11.2", + "@oxlint/linux-arm64-gnu": "1.11.2", + "@oxlint/linux-arm64-musl": "1.11.2", + "@oxlint/linux-x64-gnu": "1.11.2", + "@oxlint/linux-x64-musl": "1.11.2", + "@oxlint/win32-arm64": "1.11.2", + "@oxlint/win32-x64": "1.11.2", + "oxlint-tsgolint": ">=0.0.1" + } + }, + "node_modules/oxlint-tsgolint": { + "version": "7.0.2001", + "resolved": "https://registry.npmjs.org/oxlint-tsgolint/-/oxlint-tsgolint-7.0.2001.tgz", + "integrity": "sha512-KjK/XLcXr1DSyonKhsuFqJRiuKqcyG9j3LJ8nkOsrLzGvodBPqzHOKauy10asLMDI0sUpvb+1sxlzff3udZvfg==", + "dev": true, + "license": "MIT", + "optional": true, + "bin": { + "tsgolint": "bin/tsgolint.js" + }, + "optionalDependencies": { + "@oxlint-tsgolint/darwin-arm64": "7.0.2001", + "@oxlint-tsgolint/darwin-x64": "7.0.2001", + "@oxlint-tsgolint/linux-arm64": "7.0.2001", + "@oxlint-tsgolint/linux-x64": "7.0.2001", + "@oxlint-tsgolint/win32-arm64": "7.0.2001", + "@oxlint-tsgolint/win32-x64": "7.0.2001" + } + }, + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "license": "MIT", + "dependencies": { + "callsites": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/path-browserify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-1.0.1.tgz", + "integrity": "sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==", + "dev": true, + "license": "MIT" + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/pathe": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz", + "integrity": "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==", + "dev": true, + "license": "MIT" + }, + "node_modules/perfect-debounce": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/perfect-debounce/-/perfect-debounce-2.1.0.tgz", + "integrity": "sha512-LjgdTytVFXeUgtHZr9WYViYSM/g8MkcTPYDlPa3cDqMirHjKiSZPYd6DoL7pK8AJQr+uWkQvCjHNdiMqsrJs+g==", + "dev": true, + "license": "MIT" + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz", + "integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==", + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/pidtree": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/pidtree/-/pidtree-0.6.1.tgz", + "integrity": "sha512-e0F9AOF1JMrCfBsyJOwU9lNvQ0WtXTq0j/4jk0BQ5JSI9VAybPXmDpPRw/2FQ3e5d3ZFN1mLh7jW99m/jjaptw==", + "dev": true, + "license": "MIT", + "bin": { + "pidtree": "bin/pidtree.js" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/pkg-types": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/pkg-types/-/pkg-types-2.3.1.tgz", + "integrity": "sha512-y+ichcgc2LrADuhLNAx8DFjVfgz91pRxfZdI3UDhxHvcVEZsenLO+7XaU5vOp0u/7V/wZ+plyuQxtrDlZJ+yeg==", + "dev": true, + "license": "MIT", + "dependencies": { + "confbox": "^0.2.4", + "exsolve": "^1.0.8", + "pathe": "^2.0.3" + } + }, + "node_modules/postcss": { + "version": "8.5.26", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.26.tgz", + "integrity": "sha512-u82N74LFzG8ca+dD8puPnplTXoGH4fTPpVGuIbt36G3qvNlkvfD0lEAZSxaly3KX8TS/L1A1gsCEmvKmBcVbkQ==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.17", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/postcss-selector-parser": { + "version": "6.1.4", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.1.4.tgz", + "integrity": "sha512-bIoJLOmjCO1S9XdY/DcnR5hJxvrDir1PbGChrzXG3vw0/FOliy/fA3dmdhQ441kah4gKv+TwckGzex6wNS5cnQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "cssesc": "^3.0.0", + "util-deprecate": "^1.0.2" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/powershell-utils": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/powershell-utils/-/powershell-utils-0.2.0.tgz", + "integrity": "sha512-ZlsFlG7MtSFCoc5xreOvBAozCJ6Pf06opgJjh9ONEv418xpZSAzNjstD36C6+JwOnfSqOW/9uDkqKjezTdxZhw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/prettier": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.6.2.tgz", + "integrity": "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==", + "dev": true, + "license": "MIT", + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/prettier-linter-helpers": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.1.tgz", + "integrity": "sha512-SxToR7P8Y2lWmv/kTzVLC1t/GDI2WGjMwNhLLE9qtH8Q13C+aEmuRlzDst4Up4s0Wc8sF2M+J57iB3cMLqftfg==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-diff": "^1.1.2" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/proxy-from-env": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-2.1.0.tgz", + "integrity": "sha512-cJ+oHTW1VAEa8cJslgmUZrc+sjRKgAKl3Zyse6+PV38hZe/V6Z14TbCuXcan9F9ghlz4QrFr2c92TNF82UkYHA==", + "license": "MIT", + "engines": { + "node": ">=10" + } + }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/quansync": { + "version": "0.2.11", + "resolved": "https://registry.npmjs.org/quansync/-/quansync-0.2.11.tgz", + "integrity": "sha512-AifT7QEbW9Nri4tAwR5M/uzpBuqfZf+zwaEM/QkzEjj7NBuFD2rBuy0K3dE+8wltbezDV7JMA0WfnCPYRSYbXA==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/antfu" + }, + { + "type": "individual", + "url": "https://github.com/sponsors/sxzz" + } + ], + "license": "MIT" + }, + "node_modules/queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/read-package-json-fast": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/read-package-json-fast/-/read-package-json-fast-4.0.0.tgz", + "integrity": "sha512-qpt8EwugBWDw2cgE2W+/3oxC+KTez2uSVR8JU9Q36TXPAGCaozfQUs59v4j4GFpWTaw0i6hAZSvOmu1J0uOEUg==", + "dev": true, + "license": "ISC", + "dependencies": { + "json-parse-even-better-errors": "^4.0.0", + "npm-normalize-package-bin": "^4.0.0" + }, + "engines": { + "node": "^18.17.0 || >=20.5.0" + } + }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "license": "MIT", + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/reusify": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.1.0.tgz", + "integrity": "sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==", + "dev": true, + "license": "MIT", + "engines": { + "iojs": ">=1.0.0", + "node": ">=0.10.0" + } + }, + "node_modules/rolldown": { + "version": "1.0.0-beta.53", + "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.0.0-beta.53.tgz", + "integrity": "sha512-Qd9c2p0XKZdgT5AYd+KgAMggJ8ZmCs3JnS9PTMWkyUfteKlfmKtxJbWTHkVakxwXs1Ub7jrRYVeFeF7N0sQxyw==", + "license": "MIT", + "dependencies": { + "@oxc-project/types": "=0.101.0", + "@rolldown/pluginutils": "1.0.0-beta.53" + }, + "bin": { + "rolldown": "bin/cli.mjs" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "optionalDependencies": { + "@rolldown/binding-android-arm64": "1.0.0-beta.53", + "@rolldown/binding-darwin-arm64": "1.0.0-beta.53", + "@rolldown/binding-darwin-x64": "1.0.0-beta.53", + "@rolldown/binding-freebsd-x64": "1.0.0-beta.53", + "@rolldown/binding-linux-arm-gnueabihf": "1.0.0-beta.53", + "@rolldown/binding-linux-arm64-gnu": "1.0.0-beta.53", + "@rolldown/binding-linux-arm64-musl": "1.0.0-beta.53", + "@rolldown/binding-linux-x64-gnu": "1.0.0-beta.53", + "@rolldown/binding-linux-x64-musl": "1.0.0-beta.53", + "@rolldown/binding-openharmony-arm64": "1.0.0-beta.53", + "@rolldown/binding-wasm32-wasi": "1.0.0-beta.53", + "@rolldown/binding-win32-arm64-msvc": "1.0.0-beta.53", + "@rolldown/binding-win32-x64-msvc": "1.0.0-beta.53" + } + }, + "node_modules/rolldown/node_modules/@rolldown/pluginutils": { + "version": "1.0.0-beta.53", + "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.0-beta.53.tgz", + "integrity": "sha512-vENRlFU4YbrwVqNDZ7fLvy+JR1CRkyr01jhSiDpE1u6py3OMzQfztQU2jxykW3ALNxO4kSlqIDeYyD0Y9RcQeQ==", + "license": "MIT" + }, + "node_modules/run-applescript": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/run-applescript/-/run-applescript-7.1.0.tgz", + "integrity": "sha512-DPe5pVFaAsinSaV6QjQ6gdiedWDcRCbUuiQfQa2wmWV7+xC9bGulGI8+TdRmoFkAPaBXk8CrAbnlY2ISniJ47Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "queue-microtask": "^1.2.2" + } + }, + "node_modules/sax": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.6.1.tgz", + "integrity": "sha512-42tBVwLWnaQvW5zc4HbZrTuWccECCZfBi92FDuwtqxasH+JbPB3/FOKb1m222K42R4WxuxzzMsTswfzgtSu64Q==", + "dev": true, + "license": "BlueOak-1.0.0", + "engines": { + "node": ">=11.0.0" + } + }, + "node_modules/scule": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/scule/-/scule-1.3.0.tgz", + "integrity": "sha512-6FtHJEvt+pVMIB9IBY+IcCJ6Z5f1iQnytgyfKMhDKgmzYG+TeH/wx1y3l27rshSbLiSanrR9ffZDrEsmjlQF2g==", + "dev": true, + "license": "MIT" + }, + "node_modules/semver": { + "version": "7.8.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", + "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/shell-quote": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.10.0.tgz", + "integrity": "sha512-w1aiOKwKuRgtwAReIIj89puqg+I7GvX4IbLrvmhXbzQsj1+Zwi4VO3+fa6ZF91TWSjIxoEkKnMeHcLEODK5ZXA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/sirv": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/sirv/-/sirv-3.0.2.tgz", + "integrity": "sha512-2wcC/oGxHis/BoHkkPwldgiPSYcpZK3JU28WoMVv55yHJgcZ8rlXvuG9iZggz+sU1d4bRgIGASwyWqjxu3FM0g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@polka/url": "^1.0.0-next.24", + "mrmime": "^2.0.0", + "totalist": "^3.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/source-map-js": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/strip-literal": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/strip-literal/-/strip-literal-3.1.0.tgz", + "integrity": "sha512-8r3mkIM/2+PpjHoOtiAW8Rg3jJLHaV7xPwG+YRGrv6FP0wwk/toTpATxWYOW0BKdWwl82VT2tFYi5DlROa0Mxg==", + "dev": true, + "license": "MIT", + "dependencies": { + "js-tokens": "^9.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/svgo": { + "version": "3.3.5", + "resolved": "https://registry.npmjs.org/svgo/-/svgo-3.3.5.tgz", + "integrity": "sha512-8SQMzdrvWaD8deUmrnYB+ASyxBVgWUOilg+A75nE/76WdLpj6LopCwiAVvkzkcqy/9b7t2Mg7faFLjg0ZRcZ3w==", + "dev": true, + "license": "MIT", + "dependencies": { + "commander": "^7.2.0", + "css-select": "^5.1.0", + "css-tree": "^2.3.1", + "css-what": "^6.1.0", + "csso": "^5.0.5", + "picocolors": "^1.0.0", + "sax": "^1.5.0" + }, + "bin": { + "svgo": "bin/svgo" + }, + "engines": { + "node": ">=14.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/svgo" + } + }, + "node_modules/svgo/node_modules/commander": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz", + "integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 10" + } + }, + "node_modules/synckit": { + "version": "0.11.13", + "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.11.13.tgz", + "integrity": "sha512-eNRKgb3z66Yp3D2CixVujOUvXLFUTij/zVnV8KRyvFdQwpz7I5DS8UfRkTeLzb64u+dkzDSdelE24izu+zSSUg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@pkgr/core": "^0.3.6" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/synckit" + } + }, + "node_modules/tinyglobby": { + "version": "0.2.17", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz", + "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==", + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.4" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/tinyglobby/node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/tinyglobby/node_modules/picomatch": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "license": "MIT", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/totalist": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/totalist/-/totalist-3.0.1.tgz", + "integrity": "sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/ts-api-utils": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.5.0.tgz", + "integrity": "sha512-OJ/ibxhPlqrMM0UiNHJ/0CKQkoKF243/AEmplt3qpRgkW8VG7IfOS41h7V8TjITqdByHzrjcS/2si+y4lIh8NA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18.12" + }, + "peerDependencies": { + "typescript": ">=4.8.4" + } + }, + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "license": "0BSD", + "optional": true + }, + "node_modules/type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dev": true, + "license": "MIT", + "dependencies": { + "prelude-ls": "^1.2.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "devOptional": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/typescript-eslint": { + "version": "8.68.0", + "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.68.0.tgz", + "integrity": "sha512-MHy0Y0ynqeEbx/S45+i/bBssdy3X6KNBfmJAP35GrgtNxu2TQ5K5xsFDhAnmsq1jvpdoZOPG1LGtJo0HWqYCrQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/eslint-plugin": "8.68.0", + "@typescript-eslint/parser": "8.68.0", + "@typescript-eslint/typescript-estree": "8.68.0", + "@typescript-eslint/utils": "8.68.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", + "typescript": ">=4.8.4 <6.1.0" + } + }, + "node_modules/ufo": { + "version": "1.6.4", + "resolved": "https://registry.npmjs.org/ufo/-/ufo-1.6.4.tgz", + "integrity": "sha512-JFNbkD1Svwe0KvGi8GOeLcP4kAWQ609twvCdcHxq1oSL8svv39ZuSvajcD8B+5D0eL4+s1Is2D/O6KN3qcTeRA==", + "dev": true, + "license": "MIT" + }, + "node_modules/undici-types": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", + "devOptional": true, + "license": "MIT" + }, + "node_modules/unimport": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/unimport/-/unimport-5.7.0.tgz", + "integrity": "sha512-njnL6sp8lEA8QQbZrt+52p/g4X0rw3bnGGmUcJnt1jeG8+iiqO779aGz0PirCtydAIVcuTBRlJ52F0u46z309Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "acorn": "^8.16.0", + "escape-string-regexp": "^5.0.0", + "estree-walker": "^3.0.3", + "local-pkg": "^1.1.2", + "magic-string": "^0.30.21", + "mlly": "^1.8.0", + "pathe": "^2.0.3", + "picomatch": "^4.0.3", + "pkg-types": "^2.3.0", + "scule": "^1.3.0", + "strip-literal": "^3.1.0", + "tinyglobby": "^0.2.15", + "unplugin": "^2.3.11", + "unplugin-utils": "^0.3.1" + }, + "engines": { + "node": ">=18.12.0" + } + }, + "node_modules/unimport/node_modules/escape-string-regexp": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz", + "integrity": "sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/unimport/node_modules/picomatch": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/unplugin": { + "version": "2.3.11", + "resolved": "https://registry.npmjs.org/unplugin/-/unplugin-2.3.11.tgz", + "integrity": "sha512-5uKD0nqiYVzlmCRs01Fhs2BdkEgBS3SAVP6ndrBsuK42iC2+JHyxM05Rm9G8+5mkmRtzMZGY8Ct5+mliZxU/Ww==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/remapping": "^2.3.5", + "acorn": "^8.15.0", + "picomatch": "^4.0.3", + "webpack-virtual-modules": "^0.6.2" + }, + "engines": { + "node": ">=18.12.0" + } + }, + "node_modules/unplugin-auto-import": { + "version": "20.3.0", + "resolved": "https://registry.npmjs.org/unplugin-auto-import/-/unplugin-auto-import-20.3.0.tgz", + "integrity": "sha512-RcSEQiVv7g0mLMMXibYVKk8mpteKxvyffGuDKqZZiFr7Oq3PB1HwgHdK5O7H4AzbhzHoVKG0NnMnsk/1HIVYzQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "local-pkg": "^1.1.2", + "magic-string": "^0.30.21", + "picomatch": "^4.0.3", + "unimport": "^5.5.0", + "unplugin": "^2.3.11", + "unplugin-utils": "^0.3.1" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + }, + "peerDependencies": { + "@nuxt/kit": "^4.0.0", + "@vueuse/core": "*" + }, + "peerDependenciesMeta": { + "@nuxt/kit": { + "optional": true + }, + "@vueuse/core": { + "optional": true + } + } + }, + "node_modules/unplugin-auto-import/node_modules/picomatch": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/unplugin-utils": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/unplugin-utils/-/unplugin-utils-0.3.2.tgz", + "integrity": "sha512-xVToRh2CTmLk2HnEG7ac4rl1MJTT3RFkpS8B++/SnB0kXvuaavD+n3m/vrzyWQOdJNSZQACnbz01pnppbwV5BA==", + "dev": true, + "license": "MIT", + "dependencies": { + "pathe": "^2.0.3", + "picomatch": "^4.0.4" + }, + "engines": { + "node": ">=20.19.0" + }, + "funding": { + "url": "https://github.com/sponsors/sxzz" + } + }, + "node_modules/unplugin-utils/node_modules/picomatch": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/unplugin-vue-components": { + "version": "29.2.0", + "resolved": "https://registry.npmjs.org/unplugin-vue-components/-/unplugin-vue-components-29.2.0.tgz", + "integrity": "sha512-QxBeBdmEflgtJRgMQMc/z/JVV5lcwXN5nOy5ehX6CKDGylIu6Qn4Goy8X95S0qOxF7EdI+uNhdBd4v5i0bvzCw==", + "dev": true, + "license": "MIT", + "dependencies": { + "chokidar": "^3.6.0", + "debug": "^4.4.3", + "local-pkg": "^1.1.2", + "magic-string": "^0.30.19", + "mlly": "^1.8.0", + "tinyglobby": "^0.2.15", + "unplugin": "^2.3.10", + "unplugin-utils": "^0.3.1" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + }, + "peerDependencies": { + "@babel/parser": "^7.15.8", + "@nuxt/kit": "^3.2.2 || ^4.0.0", + "vue": "2 || 3" + }, + "peerDependenciesMeta": { + "@babel/parser": { + "optional": true + }, + "@nuxt/kit": { + "optional": true + } + } + }, + "node_modules/unplugin/node_modules/picomatch": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/update-browserslist-db": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.3.2.tgz", + "integrity": "sha512-UQ+MSxlhRm1bzjhU+DcuXfjFO1FzNtqhK5+9Yvlp90ItDLk5vT932A0rFu619nf7RVS+Y/VeaUW1jaRDqZ8VJw==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "escalade": "^3.2.0", + "picocolors": "^1.1.1" + }, + "bin": { + "update-browserslist-db": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" + } + }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "punycode": "^2.1.0" + } + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "dev": true, + "license": "MIT" + }, + "node_modules/vite": { + "name": "rolldown-vite", + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/rolldown-vite/-/rolldown-vite-7.3.1.tgz", + "integrity": "sha512-LYzdNAjRHhF2yA4JUQm/QyARyi216N2rpJ0lJZb8E9FU2y5v6Vk+xq/U4XBOxMefpWixT5H3TslmAHm1rqIq2w==", + "deprecated": "Use this package to migrate from Vite 7 to Vite 8. For the most recent updates, migrate to Vite 8 once you're ready.", + "license": "MIT", + "dependencies": { + "@oxc-project/runtime": "0.101.0", + "fdir": "^6.5.0", + "lightningcss": "^1.30.2", + "picomatch": "^4.0.3", + "postcss": "^8.5.6", + "rolldown": "1.0.0-beta.53", + "tinyglobby": "^0.2.15" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^20.19.0 || >=22.12.0", + "esbuild": "^0.27.0", + "jiti": ">=1.21.0", + "less": "^4.0.0", + "sass": "^1.70.0", + "sass-embedded": "^1.70.0", + "stylus": ">=0.54.8", + "sugarss": "^5.0.0", + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "esbuild": { + "optional": true + }, + "jiti": { + "optional": true + }, + "less": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } + }, + "node_modules/vite-dev-rpc": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/vite-dev-rpc/-/vite-dev-rpc-2.0.0.tgz", + "integrity": "sha512-yKwbTwdHKSD2k/aGqyWpPHepo45OQc8lH3/6IfT4ZqeKE26ooKvi4WIEKzqWav8v+9Is8u1k8q54hvOmqASazA==", + "dev": true, + "license": "MIT", + "dependencies": { + "birpc": "^4.0.0", + "vite-hot-client": "^2.2.0" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + }, + "peerDependencies": { + "vite": "^2.9.0 || ^3.0.0-0 || ^4.0.0-0 || ^5.0.0-0 || ^6.0.1 || ^7.0.0-0 || ^8.0.0" + } + }, + "node_modules/vite-dev-rpc/node_modules/birpc": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/birpc/-/birpc-4.2.0.tgz", + "integrity": "sha512-KxgKcZPfrtzJDDALHPguGpGJUrzdgpymyiQQgzFjWreHMOpWrnFNVREr5J48x2DBh8ZVioscrV1SBkDipGiX+Q==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, + "node_modules/vite-hot-client": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/vite-hot-client/-/vite-hot-client-2.2.0.tgz", + "integrity": "sha512-76Zs9zrHbH7M7wqeyooGQKdX+yg0pQ0xuQ1PbFp4z5a0Lzn2e5IPFoCswnmqZ4GiwqB4Jo3WcDAMO9jARTJl8w==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/antfu" + }, + "peerDependencies": { + "vite": "^2.6.0 || ^3.0.0 || ^4.0.0 || ^5.0.0-0 || ^6.0.0-0 || ^7.0.0-0 || ^8.0.0" + } + }, + "node_modules/vite-plugin-inspect": { + "version": "11.4.1", + "resolved": "https://registry.npmjs.org/vite-plugin-inspect/-/vite-plugin-inspect-11.4.1.tgz", + "integrity": "sha512-ShOFe2PURXGvRS5OrgmOLZOCwDTD7dEBVt0tMpFPKb9AsvqXKCRGM8QgKrUbRbJYFXScHvDPpGRd28rYidC0tA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansis": "^4.3.0", + "error-stack-parser-es": "^1.0.5", + "obug": "^2.1.1", + "ohash": "^2.0.11", + "open": "^11.0.0", + "perfect-debounce": "^2.1.0", + "sirv": "^3.0.2", + "unplugin-utils": "^0.3.1", + "vite-dev-rpc": "^2.0.0" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + }, + "peerDependencies": { + "vite": "^6.0.0 || ^7.0.0-0 || ^8.0.0-0" + }, + "peerDependenciesMeta": { + "@nuxt/kit": { + "optional": true + } + } + }, + "node_modules/vite-plugin-singlefile": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/vite-plugin-singlefile/-/vite-plugin-singlefile-2.3.3.tgz", + "integrity": "sha512-XVnGH0QzbOa8fxRSsHdCarVN1BSBXNi7uLMQYlrGRN5apdHkk62XQWRJhVever0lnfuyBkwn+kvVChdm/OoOUg==", + "license": "MIT", + "dependencies": { + "micromatch": "^4.0.8" + }, + "engines": { + "node": ">18.0.0" + }, + "peerDependencies": { + "rollup": "^4.59.0", + "vite": "^5.4.21 || ^6.0.0 || ^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/vite-plugin-vue-devtools": { + "version": "8.2.1", + "resolved": "https://registry.npmjs.org/vite-plugin-vue-devtools/-/vite-plugin-vue-devtools-8.2.1.tgz", + "integrity": "sha512-5JLxXWWCo5lJMw16/xVeNvJ8k2zLwZPf1vITLzya/2IePrCBeGe/p/iAokgXHZpEi39fcYtPXmO8SaKeXmqCAA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vue/devtools-core": "^8.2.1", + "@vue/devtools-kit": "^8.2.1", + "@vue/devtools-shared": "^8.2.1", + "sirv": "^3.0.2", + "vite-plugin-inspect": "^11.3.3", + "vite-plugin-vue-inspector": "^6.0.0" + }, + "engines": { + "node": ">=v14.21.3" + }, + "peerDependencies": { + "vite": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/vite-plugin-vue-inspector": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/vite-plugin-vue-inspector/-/vite-plugin-vue-inspector-6.0.0.tgz", + "integrity": "sha512-OpyITJLgZNibxlrik1EmRtvXHDjLRxNPsWkGFTERZs2LgMEdG4W0WoFt5GIgp3a3jRou+eJR8U1zOBk/XQgEbw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/core": "^7.23.0", + "@babel/plugin-proposal-decorators": "^7.23.0", + "@babel/plugin-syntax-import-attributes": "^7.22.5", + "@babel/plugin-syntax-import-meta": "^7.10.4", + "@babel/plugin-transform-typescript": "^7.22.15", + "@vue/babel-plugin-jsx": "^1.1.5", + "@vue/compiler-dom": "^3.3.4", + "kolorist": "^1.8.0", + "magic-string": "^0.30.4" + }, + "peerDependencies": { + "vite": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/vite-svg-loader": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/vite-svg-loader/-/vite-svg-loader-5.1.2.tgz", + "integrity": "sha512-/ANGO8+F64Cd6fXRaefCY0mlHHIdstySQ+nr+blHpaXSJaXq+TH68KkVHbumtQIVLt6HZFBtlaxMV3dQyzg6lA==", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "^4.3.4", + "svgo": "^3.3.4" + }, + "peerDependencies": { + "vue": ">=3.2.13" + } + }, + "node_modules/vite/node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/vite/node_modules/picomatch": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/vscode-uri": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/vscode-uri/-/vscode-uri-3.2.0.tgz", + "integrity": "sha512-m2gXo3bn0G1kT9InzMf07fTbqMbGtyckj3bH5ktLO+1Ssv+yiATZ4dhwaQv9UZWxJh6E9IFGnQyjgWVDWVBDrg==", + "dev": true, + "license": "MIT" + }, + "node_modules/vue": { + "version": "3.5.42", + "resolved": "https://registry.npmjs.org/vue/-/vue-3.5.42.tgz", + "integrity": "sha512-4RyHQTbQvOPs3MfvUO1Sg0YRrKNnA0mAVtvpd12Tg1fKDN7OHBUl1IqSn8zGJjK9nI3NkNp8cgTpVrSZC5TTcA==", + "license": "MIT", + "dependencies": { + "@vue/compiler-dom": "3.5.42", + "@vue/compiler-sfc": "3.5.42", + "@vue/runtime-dom": "3.5.42", + "@vue/server-renderer": "3.5.42", + "@vue/shared": "3.5.42" + }, + "peerDependencies": { + "typescript": "*" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/vue-component-type-helpers": { + "version": "3.3.11", + "resolved": "https://registry.npmjs.org/vue-component-type-helpers/-/vue-component-type-helpers-3.3.11.tgz", + "integrity": "sha512-LwcxzeliO9fkQcpJG0PoX8X5kmAhKmH9wkpDLxNabwzkQ9Zeib2YVHwFV4pcWmMLfXVfjr/dSV+DaJ3cIPgSNA==", + "license": "MIT" + }, + "node_modules/vue-eslint-parser": { + "version": "10.4.1", + "resolved": "https://registry.npmjs.org/vue-eslint-parser/-/vue-eslint-parser-10.4.1.tgz", + "integrity": "sha512-Gk6gRDj0n/fkRa3C3l0bBheoBckUq/Rs0F/TvMWIS6nzzx67amAViMe9CkNgsP2tXyQONvGiHQESHwFtZ3aYDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "^4.4.0", + "eslint-scope": "^8.2.0 || ^9.0.0", + "eslint-visitor-keys": "^4.2.0 || ^5.0.0", + "espree": "^10.3.0 || ^11.0.0", + "esquery": "^1.6.0", + "semver": "^7.6.3" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://github.com/sponsors/mysticatea" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0" + } + }, + "node_modules/vue-eslint-parser/node_modules/eslint-visitor-keys": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-5.0.1.tgz", + "integrity": "sha512-tD40eHxA35h0PEIZNeIjkHoDR4YjjJp34biM0mDvplBe//mB+IHCqHDGV7pxF+7MklTvighcCPPZC7ynWyjdTA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=24" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/vue-tsc": { + "version": "3.3.11", + "resolved": "https://registry.npmjs.org/vue-tsc/-/vue-tsc-3.3.11.tgz", + "integrity": "sha512-gOb0B9rtU2+f1dszwPqSH5kAieIF9ReeLhD3kSRNHv5WZZUQz/JdVXW0RTdqhNTMlQkqKzrTTviqKr/4FYZraQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@volar/typescript": "2.4.28", + "@vue/language-core": "3.3.11" + }, + "bin": { + "vue-tsc": "bin/vue-tsc.js" + }, + "peerDependencies": { + "typescript": ">=5.0.0" + } + }, + "node_modules/webpack-virtual-modules": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/webpack-virtual-modules/-/webpack-virtual-modules-0.6.2.tgz", + "integrity": "sha512-66/V2i5hQanC51vBQKPH4aI8NMAcBW59FVBs+rC7eGHupMyfn34q7rZIE+ETlJ+XTevqfUhVVBgSUNSW2flEUQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/word-wrap": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", + "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/wsl-utils": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/wsl-utils/-/wsl-utils-1.0.0.tgz", + "integrity": "sha512-Hl0ZOAs672vg+06kfujwRhoS6/jehvULrlFkuF2dRu6pHgA8U06h3xqNIqNNU1LTXPcedxByAR4GS6pwQK0mgA==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-wsl": "^3.1.0", + "powershell-utils": "^0.1.0" + }, + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/wsl-utils/node_modules/powershell-utils": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/powershell-utils/-/powershell-utils-0.1.0.tgz", + "integrity": "sha512-dM0jVuXJPsDN6DvRpea484tCUaMiXWjuCn++HGTqUWzGDjv5tZkEZldAJ/UMlqRYGFrD/etByo4/xOuC/snX2A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/xml-name-validator": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-4.0.0.tgz", + "integrity": "sha512-ICP2e+jsHvAj2E2lIHxa5tjXRlKDJo4IdvPvCXbXQGdzSfmSpNVyIKMvoZHjDY9DP0zV17iI85o90vRFXNccRw==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=12" + } + }, + "node_modules/yallist": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", + "dev": true, + "license": "ISC" + }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + } + } +} diff --git a/server/config/audit_store.go b/server/config/audit_store.go index 9ea03eca..3133dbd2 100644 --- a/server/config/audit_store.go +++ b/server/config/audit_store.go @@ -261,7 +261,7 @@ func normalizeAuditEvent(event ConfigAuditEvent) (ConfigAuditEvent, error) { } func validateAuditEvent(event ConfigAuditEvent) error { - if event.Operation != ConfigOperationUpdate && event.Operation != ConfigOperationRollback { + if event.Operation != ConfigOperationUpdate && event.Operation != ConfigOperationRollback && event.Operation != ConfigOperationMigration { return ErrAuditEventInvalid } if strings.TrimSpace(event.ActorID) == "" || strings.TrimSpace(event.ActorRole) == "" || event.FromGeneration == 0 || event.ToGeneration == 0 || event.CreatedAt.IsZero() { diff --git a/server/config/config.go b/server/config/config.go index 274258ea..184eb93a 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -28,6 +28,7 @@ type Config struct { SSLType string `json:"sslType"` // 0表示自动生成证书,HTTP挑战模式,1表示用户上传证书,2表示自动-DNS挑战模式 SSLPrivateKeyPath string `json:"SSLPrivateKeyPath"` SSLPublicKeyPath string `json:"SSLPublicKeyPath"` + SSL SSLConfig `json:"ssl,omitempty"` DbDSN string `json:"dbDSN"` DbType string `json:"dbType"` HttpsEnabled int `json:"httpsEnabled"` //后台页面是否启用https,0默认(启用),1启用,2不启用 @@ -255,6 +256,8 @@ func writeProtectedConfigFile(name string, cfg *Config) error { if err != nil { return errors.Wrap(err) } + stored.SSLPrivateKeyPath = persistControlledSSLPath(stored.SSLPrivateKeyPath) + stored.SSLPublicKeyPath = persistControlledSSLPath(stored.SSLPublicKeyPath) data, err := json.Marshal(stored) if err != nil { return errors.Wrap(err) @@ -328,6 +331,30 @@ func (c *Config) fixPath() { c.DkimPrivateKeyPath = resolvePath(c.DkimPrivateKeyPath) } +func persistControlledSSLPath(value string) string { + value = strings.TrimSpace(value) + if value == "" { + return "" + } + root, err := filepath.Abs(filepath.Clean(ROOT_PATH)) + if err != nil { + return "" + } + target := value + if !filepath.IsAbs(target) { + target = filepath.Join(root, target) + } + target, err = filepath.Abs(filepath.Clean(target)) + if err != nil || !pathWithinRoot(root, target) { + return "" + } + relative, err := filepath.Rel(root, target) + if err != nil || filepath.IsAbs(relative) || relative == "." || strings.HasPrefix(relative, ".."+string(filepath.Separator)) || relative == ".." { + return "" + } + return filepath.ToSlash(relative) +} + func resolvePath(value string) string { value = strings.TrimSpace(value) if value == "" { diff --git a/server/config/manager_v2.go b/server/config/manager_v2.go index ea1831d7..7a39ae8e 100644 --- a/server/config/manager_v2.go +++ b/server/config/manager_v2.go @@ -98,6 +98,16 @@ type rollbackTicket struct { ExpiresAt time.Time } +type LegacyPluginSecret struct { + PluginID string + FieldName string + Plaintext string +} + +type LegacyPluginSecretImporter func(context.Context, []LegacyPluginSecret) error + +var ErrPluginSecretMigrationRequired = errors.New("plugin secret migration is required") + type ConfigManager struct { mu sync.RWMutex writeMu sync.Mutex @@ -666,13 +676,14 @@ func applySectionPayload(current RuntimeConfig, section Section, payload json.Ra if err := ParseStrict(payload, &value); err != nil { return RuntimeConfig{}, err } - for logicalID, plugin := range value.Plugins { + for _, plugin := range value.Plugins { if storedSecretHasMaterial(plugin.Secret) { return RuntimeConfig{}, ErrInvalidSecretChange } - if currentPlugin, ok := current.Plugins.Plugins[logicalID]; ok { - plugin.Secret = currentPlugin.Secret - value.Plugins[logicalID] = plugin + } + for _, plugin := range current.Plugins.Plugins { + if storedSecretHasMaterial(plugin.Secret) { + return RuntimeConfig{}, ErrPluginSecretMigrationRequired } } candidate.Plugins = value @@ -742,21 +753,6 @@ func applySecretChanges(candidate *RuntimeConfig, section Section, changes map[s return err } candidate.SMTP.Relay.Password = stored - case section == SectionPlugins && strings.HasPrefix(name, "plugins.") && strings.HasSuffix(name, ".secret"): - logicalID := strings.TrimSuffix(strings.TrimPrefix(name, "plugins."), ".secret") - if !logicalIDPattern.MatchString(logicalID) { - return ErrInvalidSecretChange - } - plugin, ok := candidate.Plugins.Plugins[logicalID] - if !ok { - return ErrInvalidSecretChange - } - stored, err := ApplySecretChange(vault, plugin.Secret, change, SecretPolicy{AllowClear: true, MaxLength: 4096}, now) - if err != nil { - return err - } - plugin.Secret = stored - candidate.Plugins.Plugins[logicalID] = plugin default: return ErrInvalidSecretChange } @@ -768,6 +764,98 @@ func storedSecretHasMaterial(secret StoredSecret) bool { return secret.Ciphertext != "" || secret.Version != 0 || !secret.UpdatedAt.IsZero() } +// MigrateLegacyPluginSecrets moves compatibility-only plugin secrets out of plugins.json. +// The importer must persist all received values atomically before this method commits the new configuration generation. +func (m *ConfigManager) MigrateLegacyPluginSecrets(ctx context.Context, importer LegacyPluginSecretImporter) (bool, error) { + if err := contextError(ctx); err != nil { + return false, err + } + if m == nil || importer == nil || m.vault == nil { + return false, ErrPluginSecretMigrationRequired + } + m.writeMu.Lock() + defer m.writeMu.Unlock() + m.mu.RLock() + current := cloneRuntimeConfig(m.current) + pending := m.pending != nil + m.mu.RUnlock() + if pending { + return false, ErrGenerationConflict + } + + values := make([]LegacyPluginSecret, 0, len(current.Plugins.Plugins)) + for logicalID, instance := range current.Plugins.Plugins { + if !storedSecretHasMaterial(instance.Secret) { + continue + } + fieldName, ok := legacyPluginSecretField(logicalID) + if !ok || !instance.Secret.Configured() { + return false, ErrPluginSecretMigrationRequired + } + plaintext, err := m.vault.Decrypt(instance.Secret.Version, instance.Secret.Ciphertext) + if err != nil || plaintext == "" { + return false, ErrPluginSecretMigrationRequired + } + values = append(values, LegacyPluginSecret{PluginID: logicalID, FieldName: fieldName, Plaintext: plaintext}) + } + if len(values) == 0 { + return false, nil + } + if err := importer(ctx, values); err != nil { + return false, err + } + + candidate := cloneRuntimeConfig(current) + for logicalID, instance := range candidate.Plugins.Plugins { + instance.Secret = StoredSecret{} + candidate.Plugins.Plugins[logicalID] = instance + } + setCandidateGeneration(&candidate, current.Generation+1) + if err := ValidateRuntimeConfig(candidate, m.options); err != nil { + return false, err + } + if _, _, err := m.transactions.CreateBackupIfDue(current, time.Now().UTC()); err != nil { + return false, err + } + if err := m.transactions.Commit(current, candidate); err != nil { + return false, err + } + if err := m.snapshots.Publish(candidate); err != nil { + return false, err + } + now := time.Now().UTC() + m.mu.Lock() + m.current = cloneRuntimeConfig(candidate) + m.pending = nil + m.status = ConfigStatus{SetupState: candidate.SetupState, ActiveGeneration: candidate.Generation, LastValidAt: &now, PendingRestart: []ServiceName{ServicePlugins}} + m.mu.Unlock() + if err := m.writeAudit(ctx, ConfigAuditEvent{ + Operation: ConfigOperationMigration, + Section: SectionPlugins, + ActorID: "system", + ActorRole: "system", + FromGeneration: current.Generation, + ToGeneration: candidate.Generation, + ChangedFields: []string{"plugins.legacySecret"}, + Result: "success", + CreatedAt: now, + }); err != nil { + return false, err + } + return true, nil +} + +func legacyPluginSecretField(logicalID string) (string, bool) { + switch logicalID { + case "wechat_push": + return "appSecret", true + case "telegram_push": + return "botToken", true + default: + return "", false + } +} + func requiresSecretStepUp(changes map[string]SecretChange) bool { for _, change := range changes { if change.Operation == SecretClear || change.Operation == SecretReplace { diff --git a/server/config/manager_v2_test.go b/server/config/manager_v2_test.go index 0fa9c6bc..e73aaaa5 100644 --- a/server/config/manager_v2_test.go +++ b/server/config/manager_v2_test.go @@ -6,6 +6,7 @@ import ( "errors" "os" "path/filepath" + "strings" "testing" "time" @@ -19,7 +20,7 @@ func writeRuntimeFixture(t *testing.T, root string, runtime RuntimeConfig) { if err != nil { t.Fatal(err) } - files, err := marshalRuntimeFiles(runtime) + files, err := marshalRuntimeFilesWithPluginSecrets(runtime, true) if err != nil { t.Fatal(err) } @@ -476,7 +477,7 @@ func TestConfigManagerSecretChangesUseVaultAndRejectUnknownFields(t *testing.T) } } -func TestConfigManagerPluginSecretChangesUseUnifiedVaultSemantics(t *testing.T) { +func TestConfigManagerRejectsPluginSecretWrites(t *testing.T) { root := t.TempDir() runtime := validRuntimeConfig() writeRuntimeFixture(t, root, runtime) @@ -487,145 +488,128 @@ func TestConfigManagerPluginSecretChangesUseUnifiedVaultSemantics(t *testing.T) } plugins := manager.Snapshot().Plugins - plugin := plugins.Plugins["telegram_push"] - plugin.Secret = StoredSecret{} - plugins.Plugins["telegram_push"] = plugin payload, err := json.Marshal(plugins) if err != nil { t.Fatal(err) } - - replaceRequest := UpdateRequest{ - Section: SectionPlugins, - ExpectedGeneration: 1, - Payload: payload, - SecretChanges: map[string]SecretChange{ - "plugins.telegram_push.secret": {Operation: SecretReplace, Value: &SecretInput{Plaintext: "plugin-secret"}}, - }, - Actor: authorizedConfigActor(), - Confirmation: StepUpConfirmation{Confirmed: true, Method: "recent_auth"}, - } - updated, err := manager.Update(context.Background(), replaceRequest) - if err != nil { - t.Fatal(err) - } - stored := updated.Candidate.Plugins.Plugins["telegram_push"].Secret - if !stored.Configured() || stored.Ciphertext == "plugin-secret" { - t.Fatalf("plugin secret was not encrypted: %+v", stored) - } - if _, err := manager.Apply(context.Background(), updated.Generation); err != nil { - t.Fatal(err) + if _, err = manager.Validate(context.Background(), ValidateRequest{ + Section: SectionPlugins, + Payload: payload, + SecretChanges: map[string]SecretChange{"plugins.telegram_push.secret": {Operation: SecretReplace, Value: &SecretInput{Plaintext: "plugin-secret"}}}, + }); !errors.Is(err, ErrInvalidSecretChange) { + t.Fatalf("plugin secret update error = %v, want invalid secret change", err) } - plugins = manager.Snapshot().Plugins - plugin = plugins.Plugins["telegram_push"] - plugin.Secret = StoredSecret{} + plugin := plugins.Plugins["telegram_push"] + plugin.Secret = StoredSecret{Ciphertext: "smail:v1:encrypted", Version: credential.CurrentVersion, UpdatedAt: time.Now().UTC()} plugins.Plugins["telegram_push"] = plugin payload, err = json.Marshal(plugins) if err != nil { t.Fatal(err) } - kept, err := manager.Update(context.Background(), UpdateRequest{ - Section: SectionPlugins, - ExpectedGeneration: 2, - Payload: payload, - SecretChanges: map[string]SecretChange{"plugins.telegram_push.secret": {Operation: SecretKeep}}, - Actor: authorizedConfigActor(), - }) - if err != nil { - t.Fatal(err) - } - if kept.Candidate.Plugins.Plugins["telegram_push"].Secret != stored { - t.Fatalf("plugin keep changed the stored secret: got %+v want %+v", kept.Candidate.Plugins.Plugins["telegram_push"].Secret, stored) - } - if _, err := manager.Apply(context.Background(), kept.Generation); err != nil { - t.Fatal(err) - } - - plugins = manager.Snapshot().Plugins - plugin = plugins.Plugins["telegram_push"] - plugin.Secret = StoredSecret{} - plugins.Plugins["telegram_push"] = plugin - payload, err = json.Marshal(plugins) - if err != nil { - t.Fatal(err) - } - cleared, err := manager.Update(context.Background(), UpdateRequest{ - Section: SectionPlugins, - ExpectedGeneration: 3, - Payload: payload, - SecretChanges: map[string]SecretChange{"plugins.telegram_push.secret": {Operation: SecretClear, Confirmed: true}}, - Actor: authorizedConfigActor(), - Confirmation: StepUpConfirmation{Confirmed: true, Method: "webauthn"}, - }) - if err != nil { - t.Fatal(err) - } - if cleared.Candidate.Plugins.Plugins["telegram_push"].Secret.Configured() { - t.Fatal("plugin clear left the secret configured") + if _, err = manager.Validate(context.Background(), ValidateRequest{Section: SectionPlugins, Payload: payload}); !errors.Is(err, ErrInvalidSecretChange) { + t.Fatalf("direct plugin secret error = %v, want invalid secret change", err) } } -func TestConfigManagerRejectsInvalidPluginSecretChanges(t *testing.T) { +func TestConfigManagerMigratesLegacyPluginSecrets(t *testing.T) { root := t.TempDir() runtime := validRuntimeConfig() - writeRuntimeFixture(t, root, runtime) - options := ConfigLoaderOptions{Validation: RuntimeValidationOptions{HasSuperAdmin: true, Production: true}} - manager, err := NewConfigManager(root, options) + vault, err := credential.NewVault(root) if err != nil { t.Fatal(err) } + stored, err := ApplySecretChange(vault, StoredSecret{}, SecretChange{Operation: SecretReplace, Value: &SecretInput{Plaintext: "legacy-token"}}, SecretPolicy{Required: true, MaxLength: 4096}, time.Now().UTC()) + if err != nil { + t.Fatal(err) + } + plugin := runtime.Plugins.Plugins["telegram_push"] + plugin.Secret = stored + runtime.Plugins.Plugins["telegram_push"] = plugin + writeRuntimeFixture(t, root, runtime) - base := manager.Snapshot().Plugins - tests := []struct { - name string - payload PluginsSectionConfig - secretPath string - }{ - { - name: "unknown plugin", - payload: base, - secretPath: "plugins.unknown.secret", - }, - { - name: "invalid path", - payload: base, - secretPath: "plugins.telegram_push.secret.extra", - }, - { - name: "direct ciphertext", - payload: func() PluginsSectionConfig { - value := base - plugin := value.Plugins["telegram_push"] - plugin.Secret = StoredSecret{Ciphertext: "enc:v1:plaintext", Version: credential.CurrentVersion, UpdatedAt: time.Now().UTC()} - value.Plugins["telegram_push"] = plugin - return value - }(), - secretPath: "plugins.telegram_push.secret", - }, + writer := &MemoryAuditWriter{} + manager, err := NewConfigManagerWithSecurity(root, ConfigLoaderOptions{Validation: RuntimeValidationOptions{HasSuperAdmin: true, Production: true}}, ConfigSecurity{Audit: writer}) + if err != nil { + t.Fatal(err) } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - payloadValue := clonePluginsSection(test.payload) - if test.name != "direct ciphertext" { - plugin := payloadValue.Plugins["telegram_push"] - plugin.Secret = StoredSecret{} - payloadValue.Plugins["telegram_push"] = plugin - } - payload, err := json.Marshal(payloadValue) - if err != nil { - t.Fatal(err) - } - _, err = manager.Validate(context.Background(), ValidateRequest{ - Section: SectionPlugins, - Payload: payload, - SecretChanges: map[string]SecretChange{test.secretPath: {Operation: SecretKeep}}, - }) - if !errors.Is(err, ErrInvalidSecretChange) { - t.Fatalf("error = %v, want invalid secret change", err) - } - }) + var imported []LegacyPluginSecret + migrated, err := manager.MigrateLegacyPluginSecrets(context.Background(), func(_ context.Context, values []LegacyPluginSecret) error { + imported = append([]LegacyPluginSecret(nil), values...) + return nil + }) + if err != nil || !migrated { + t.Fatalf("migrate legacy plugin secrets = %v, %v", migrated, err) } + if len(imported) != 1 || imported[0].PluginID != "telegram_push" || imported[0].FieldName != "botToken" || imported[0].Plaintext != "legacy-token" { + t.Fatalf("imported legacy values = %+v", imported) + } + if manager.Snapshot().Generation != 2 || manager.Snapshot().Plugins.Plugins["telegram_push"].Secret.Configured() { + t.Fatalf("migrated snapshot = %+v", manager.Snapshot()) + } + pluginData, err := os.ReadFile(filepath.Join(root, "config", "plugins.json")) + if err != nil { + t.Fatal(err) + } + if string(pluginData) == "" || containsAny(string(pluginData), "legacy-token", "ciphertext", "\"secret\"") { + t.Fatalf("plugins.json retained legacy secret material: %s", pluginData) + } + events := writer.Events() + if len(events) != 1 || events[0].Operation != ConfigOperationMigration || events[0].Section != SectionPlugins { + t.Fatalf("migration audit events = %+v", events) + } + migrated, err = manager.MigrateLegacyPluginSecrets(context.Background(), func(_ context.Context, values []LegacyPluginSecret) error { + t.Fatalf("unexpected repeated importer invocation: %+v", values) + return nil + }) + if err != nil || migrated { + t.Fatalf("repeat migration = %v, %v", migrated, err) + } +} + +func TestConfigManagerRetainsLegacySecretWhenImportFails(t *testing.T) { + root := t.TempDir() + runtime := validRuntimeConfig() + vault, err := credential.NewVault(root) + if err != nil { + t.Fatal(err) + } + stored, err := ApplySecretChange(vault, StoredSecret{}, SecretChange{Operation: SecretReplace, Value: &SecretInput{Plaintext: "legacy-token"}}, SecretPolicy{Required: true, MaxLength: 4096}, time.Now().UTC()) + if err != nil { + t.Fatal(err) + } + plugin := runtime.Plugins.Plugins["telegram_push"] + plugin.Secret = stored + runtime.Plugins.Plugins["telegram_push"] = plugin + writeRuntimeFixture(t, root, runtime) + manager, err := NewConfigManager(root, ConfigLoaderOptions{Validation: RuntimeValidationOptions{HasSuperAdmin: true, Production: true}}) + if err != nil { + t.Fatal(err) + } + if _, err = manager.MigrateLegacyPluginSecrets(context.Background(), func(_ context.Context, _ []LegacyPluginSecret) error { + return errors.New("database unavailable") + }); err == nil { + t.Fatal("legacy import failure unexpectedly succeeded") + } + if manager.Snapshot().Generation != 1 || !manager.Snapshot().Plugins.Plugins["telegram_push"].Secret.Configured() { + t.Fatal("failed import altered the in-memory legacy configuration") + } + pluginData, readErr := os.ReadFile(filepath.Join(root, "config", "plugins.json")) + if readErr != nil { + t.Fatal(readErr) + } + if !containsAny(string(pluginData), "ciphertext", "\"secret\"") { + t.Fatal("failed import removed compatibility secret from plugins.json") + } +} + +func containsAny(value string, terms ...string) bool { + for _, term := range terms { + if strings.Contains(value, term) { + return true + } + } + return false } func findTransactionDirectory(t *testing.T, root string) string { diff --git a/server/config/migrate.go b/server/config/migrate.go new file mode 100644 index 00000000..a5c90270 --- /dev/null +++ b/server/config/migrate.go @@ -0,0 +1,848 @@ +package config + +import ( + "bytes" + "crypto/rand" + "encoding/hex" + "encoding/json" + "errors" + "net" + "net/url" + "os" + "path/filepath" + "reflect" + "regexp" + "sort" + "strconv" + "strings" + "time" + + "git.pcux.cn/xuans/Smail/plugins/catalog" + "git.pcux.cn/xuans/Smail/utils/atomicfile" + "git.pcux.cn/xuans/Smail/utils/credential" +) + +var ( + ErrMigrationNotRequired = errors.New("legacy configuration migration is not required") + ErrMigrationUnknownField = errors.New("legacy configuration contains unknown fields") + ErrMigrationUnsafeValue = errors.New("legacy configuration contains a value that requires manual migration") + ErrMigrationTargetExists = errors.New("partitioned configuration files already exist") +) + +type LegacyMigrationPlan struct { + SourceDigest string + TargetGeneration uint64 + UnknownFields []string + ManualFields []string +} + +type LegacyMigrationResult struct { + Generation uint64 + BackupPath string +} + +type legacyMigrationConfig struct { + LogLevel string `json:"logLevel"` + Domain string `json:"domain"` + Domains []string `json:"domains"` + WebDomain string `json:"webDomain"` + AccessHosts []string `json:"accessHosts"` + DkimPrivateKeyPath string `json:"dkimPrivateKeyPath"` + SSLType string `json:"sslType"` + SSLPrivateKeyPath string `json:"SSLPrivateKeyPath"` + SSLPublicKeyPath string `json:"SSLPublicKeyPath"` + DbDSN string `json:"dbDSN"` + DbType string `json:"dbType"` + HttpsEnabled int `json:"httpsEnabled"` + SpamFilterLevel int `json:"spamFilterLevel"` + HttpPort int `json:"httpPort"` + HttpsPort int `json:"httpsPort"` + WeChatPushAppID string `json:"weChatPushAppId"` + WeChatPushSecret string `json:"weChatPushSecret"` + WeChatPushTemplateID string `json:"weChatPushTemplateId"` + WeChatPushUserID string `json:"weChatPushUserId"` + TGBotToken string `json:"tgBotToken"` + TGChatID string `json:"tgChatId"` + IsInit bool `json:"isInit"` + SetupState SetupState `json:"setupState"` + WebPushURL string `json:"webPushUrl"` + WebPushToken string `json:"webPushToken"` + SMTPHost string `json:"smtpHost"` + SMTPPort int `json:"smtpPort"` + SMTPUsername string `json:"smtpUsername"` + SMTPPassword string `json:"smtpPassword"` + SMTPSecurity string `json:"smtpSecurity"` + SMTPFrom string `json:"smtpFrom"` + SMTPFromDomain string `json:"smtpFromDomain"` + VerificationEnabled bool `json:"verificationEnabled"` + ExternalRecoveryEnabled bool `json:"externalRecoveryEnabled"` + LoginPolicy string `json:"loginPolicy"` + VerificationLoginPolicy string `json:"verificationLoginPolicy"` + PluginAllowList []string `json:"pluginAllowList"` +} + +var legacyMigrationKnownFields = map[string]struct{}{ + "logLevel": {}, "domain": {}, "domains": {}, "webDomain": {}, "accessHosts": {}, + "dkimPrivateKeyPath": {}, "sslType": {}, "SSLPrivateKeyPath": {}, "SSLPublicKeyPath": {}, + "dbDSN": {}, "dbType": {}, "httpsEnabled": {}, "spamFilterLevel": {}, "httpPort": {}, "httpsPort": {}, + "weChatPushAppId": {}, "weChatPushSecret": {}, "weChatPushTemplateId": {}, "weChatPushUserId": {}, + "tgBotToken": {}, "tgChatId": {}, "isInit": {}, "setupState": {}, "webPushUrl": {}, "webPushToken": {}, + "smtpHost": {}, "smtpPort": {}, "smtpUsername": {}, "smtpPassword": {}, "smtpSecurity": {}, "smtpFrom": {}, + "smtpFromDomain": {}, "verificationEnabled": {}, "externalRecoveryEnabled": {}, "loginPolicy": {}, + "verificationLoginPolicy": {}, "pluginAllowList": {}, +} + +var legacyPluginExecutableMap = map[string]string{ + "spam_block": "spam_block", + "spam_block.exe": "spam_block", + "wechat_push": "wechat_push", + "wechat_push.exe": "wechat_push", + "telegram_push": "telegram_push", + "telegram_push.exe": "telegram_push", + "pmail_telegram_push": "telegram_push", + "pmail_telegram_push.exe": "telegram_push", +} + +var legacyMySQLDSNPattern = regexp.MustCompile(`^([^:@/[:space:]]+):([^@\r\n]*)@tcp\(([^():/[:space:]]+)(?::([0-9]{1,5}))?\)/([A-Za-z0-9][A-Za-z0-9._-]{0,127})(?:\?[^#[:space:]]*)?$`) + +func PlanLegacyMigration(root string, _ RuntimeValidationOptions) (LegacyMigrationPlan, error) { + directory, err := secureManagerConfigDirectory(root) + if err != nil { + return LegacyMigrationPlan{}, err + } + data, err := readManagerConfigFile(directory, "config.json") + if err != nil { + return LegacyMigrationPlan{}, err + } + var raw map[string]json.RawMessage + if err := ParseStrict(data, &raw); err != nil { + return LegacyMigrationPlan{}, err + } + if _, exists := raw["sections"]; exists { + return LegacyMigrationPlan{}, ErrMigrationNotRequired + } + plan := LegacyMigrationPlan{SourceDigest: SectionDigest(data), TargetGeneration: 1} + for field := range raw { + if _, known := legacyMigrationKnownFields[field]; !known { + plan.UnknownFields = append(plan.UnknownFields, field) + } + } + sort.Strings(plan.UnknownFields) + if len(plan.UnknownFields) > 0 { + return plan, ErrMigrationUnknownField + } + var legacy legacyMigrationConfig + if err := json.Unmarshal(data, &legacy); err != nil { + return LegacyMigrationPlan{}, err + } + plan.ManualFields = legacyManualFields(legacy) + if len(plan.ManualFields) > 0 { + return plan, ErrMigrationUnsafeValue + } + return plan, nil +} +func MigrateLegacyConfig(root string, options RuntimeValidationOptions) (LegacyMigrationResult, error) { + plan, err := PlanLegacyMigration(root, options) + if err != nil { + return LegacyMigrationResult{}, err + } + directory, err := secureManagerConfigDirectory(root) + if err != nil { + return LegacyMigrationResult{}, err + } + legacyData, err := readManagerConfigFile(directory, "config.json") + if err != nil { + return LegacyMigrationResult{}, err + } + if SectionDigest(legacyData) != plan.SourceDigest { + return LegacyMigrationResult{}, ErrGenerationConflict + } + var legacy legacyMigrationConfig + if err := json.Unmarshal(legacyData, &legacy); err != nil { + return LegacyMigrationResult{}, err + } + runtime, manualFields, err := legacyRuntimeConfig(root, legacy) + if err != nil { + return LegacyMigrationResult{}, err + } + if len(manualFields) > 0 { + return LegacyMigrationResult{}, ErrMigrationUnsafeValue + } + if err := resolveLegacySetupState(&runtime, legacy, options); err != nil { + return LegacyMigrationResult{}, err + } + if err := ValidateRuntimeConfig(runtime, options); err != nil { + return LegacyMigrationResult{}, err + } + backupPath, err := writeLegacyMigrationBackup(directory, legacyData, time.Now().UTC()) + if err != nil { + return LegacyMigrationResult{}, err + } + files, err := marshalRuntimeFilesWithPluginSecrets(runtime, true) + if err != nil { + return LegacyMigrationResult{}, err + } + vault, err := credential.NewVault(root) + if err != nil { + return LegacyMigrationResult{}, err + } + resolvedFiles := make(map[string][]byte, len(files)) + for name, data := range files { + resolvedFiles[name] = data + } + for _, section := range RequiredPartitionSections() { + name, _ := FixedSectionFile(section) + resolved, resolveErr := resolveLegacyMigrationSection(directory, section, files[name], vault) + if resolveErr != nil { + return LegacyMigrationResult{}, resolveErr + } + resolvedFiles[name] = resolved + } + files = resolvedFiles + if err := refreshLegacyMigrationRoot(runtime, files); err != nil { + return LegacyMigrationResult{}, err + } + for _, section := range RequiredPartitionSections() { + name, _ := FixedSectionFile(section) + path := filepath.Join(directory, name) + if _, statErr := os.Lstat(path); os.IsNotExist(statErr) { + if err := atomicfile.Write(path, files[name], 0600); err != nil { + return LegacyMigrationResult{}, err + } + } else if statErr != nil { + return LegacyMigrationResult{}, statErr + } + } + rootPath := filepath.Join(directory, "config.json") + currentRoot, err := readManagerConfigFile(directory, "config.json") + if err != nil { + return LegacyMigrationResult{}, err + } + if !bytes.Equal(currentRoot, legacyData) && !bytes.Equal(currentRoot, files["config.json"]) { + return LegacyMigrationResult{}, ErrGenerationConflict + } + if bytes.Equal(currentRoot, legacyData) { + if err := atomicfile.Write(rootPath, files["config.json"], 0600); err != nil { + return LegacyMigrationResult{}, err + } + } + if err := atomicfile.SyncDirectory(directory); err != nil { + return LegacyMigrationResult{}, err + } + return LegacyMigrationResult{Generation: runtime.Generation, BackupPath: backupPath}, nil +} + +func refreshLegacyMigrationRoot(runtime RuntimeConfig, files map[string][]byte) error { + references := make(map[Section]SectionRef, len(requiredPartitionSections)) + for _, section := range requiredPartitionSections { + name, ok := FixedSectionFile(section) + if !ok { + return ErrInvalidSection + } + schema, ok := FixedSectionSchema(section) + if !ok { + return ErrInvalidSection + } + data, ok := files[name] + if !ok { + return ErrConfigSectionMissing + } + references[section] = SectionRef{File: name, Schema: schema, Generation: runtime.Generation, SHA256: SectionDigest(data)} + } + runtime.Root.Generation = runtime.Generation + runtime.Root.SetupState = runtime.SetupState + runtime.Root.Sections = references + data, err := json.Marshal(runtime.Root) + if err != nil { + return err + } + files["config.json"] = data + return nil +} + +func resolveLegacyMigrationSection(directory string, section Section, expected []byte, vault *credential.Vault) ([]byte, error) { + name, ok := FixedSectionFile(section) + if !ok || section == SectionRoot { + return nil, ErrInvalidSection + } + existing, err := readManagerConfigFile(directory, name) + if err != nil { + if os.IsNotExist(err) { + return expected, nil + } + return nil, err + } + if bytes.Equal(existing, expected) { + return existing, nil + } + equivalent, err := equivalentLegacyMigrationSection(section, expected, existing, vault) + if err != nil { + return nil, err + } + if !equivalent { + return nil, ErrMigrationTargetExists + } + return existing, nil +} + +func equivalentLegacyMigrationSection(section Section, expected, existing []byte, vault *credential.Vault) (bool, error) { + switch section { + case SectionSMTP: + var expectedConfig, existingConfig SMTPSectionConfig + if err := ParseStrict(expected, &expectedConfig); err != nil { + return false, err + } + if err := ParseStrict(existing, &existingConfig); err != nil { + return false, err + } + if !equivalentStoredSecret(expectedConfig.Relay.Password, existingConfig.Relay.Password, vault) { + return false, nil + } + expectedConfig.Relay.Password = StoredSecret{} + existingConfig.Relay.Password = StoredSecret{} + return reflect.DeepEqual(expectedConfig, existingConfig), nil + case SectionPlugins: + var expectedConfig, existingConfig PluginsSectionConfig + if err := ParseStrict(expected, &expectedConfig); err != nil { + return false, err + } + if err := ParseStrict(existing, &existingConfig); err != nil { + return false, err + } + if len(expectedConfig.Plugins) != len(existingConfig.Plugins) { + return false, nil + } + for logicalID, expectedPlugin := range expectedConfig.Plugins { + existingPlugin, ok := existingConfig.Plugins[logicalID] + if !ok || !equivalentStoredSecret(expectedPlugin.Secret, existingPlugin.Secret, vault) { + return false, nil + } + expectedPlugin.Secret = StoredSecret{} + existingPlugin.Secret = StoredSecret{} + if !reflect.DeepEqual(expectedPlugin, existingPlugin) { + return false, nil + } + } + return reflect.DeepEqual(expectedConfig.Meta, existingConfig.Meta), nil + case SectionEmail, SectionSSL: + return false, nil + default: + return false, ErrInvalidSection + } +} + +func equivalentStoredSecret(expected, existing StoredSecret, vault *credential.Vault) bool { + if expected.Configured() != existing.Configured() { + return false + } + if !expected.Configured() { + return true + } + expectedPlaintext, expectedErr := OpenStoredSecret(vault, expected) + existingPlaintext, existingErr := OpenStoredSecret(vault, existing) + return expectedErr == nil && existingErr == nil && expectedPlaintext == existingPlaintext +} + +func legacyManualFields(legacy legacyMigrationConfig) []string { + fields := make([]string, 0) + _, _, databaseManualFields := legacyDatabasePlan(legacy) + fields = append(fields, databaseManualFields...) + if _, ok := legacyControlledReference(legacy.SSLPublicKeyPath); legacy.SSLPublicKeyPath != "" && !ok { + fields = append(fields, "SSLPublicKeyPath") + } + if _, ok := legacyControlledReference(legacy.SSLPrivateKeyPath); legacy.SSLPrivateKeyPath != "" && !ok { + fields = append(fields, "SSLPrivateKeyPath") + } + if legacy.SMTPUsername == "" && legacy.SMTPPassword != "" { + fields = append(fields, "smtpPassword") + } + for field, value := range map[string]string{ + "smtpPassword": legacy.SMTPPassword, "weChatPushSecret": legacy.WeChatPushSecret, "tgBotToken": legacy.TGBotToken, + } { + if value != "" && strings.TrimSpace(value) != value { + fields = append(fields, field) + } + } + wechatEnabled := legacy.WeChatPushAppID != "" || legacy.WeChatPushSecret != "" || legacy.WeChatPushTemplateID != "" || legacy.WeChatPushUserID != "" + if wechatEnabled && legacy.WeChatPushSecret == "" { + fields = append(fields, "weChatPushSecret") + } + telegramEnabled := legacy.TGBotToken != "" || legacy.TGChatID != "" + if telegramEnabled && legacy.TGBotToken == "" { + fields = append(fields, "tgBotToken") + } + if legacy.TGChatID != "" { + fields = append(fields, "tgChatId") + } + if legacy.WebPushURL != "" { + fields = append(fields, "webPushUrl") + } + if legacy.WebPushToken != "" { + fields = append(fields, "webPushToken") + } + enabledPlugins, pluginManualFields := legacyPluginEnabledSet(legacy.PluginAllowList) + fields = append(fields, pluginManualFields...) + if enabledPlugins["wechat_push"] && !wechatEnabled { + fields = append(fields, "weChatPushSecret") + } + if enabledPlugins["telegram_push"] && !telegramEnabled { + fields = append(fields, "tgBotToken") + } + sort.Strings(fields) + return compactMigrationFields(fields) +} + +func compactMigrationFields(fields []string) []string { + if len(fields) == 0 { + return nil + } + result := fields[:0] + for _, field := range fields { + if len(result) == 0 || result[len(result)-1] != field { + result = append(result, field) + } + } + return result +} +func legacyRuntimeConfig(root string, legacy legacyMigrationConfig) (RuntimeConfig, []string, error) { + vault, err := credential.NewVault(root) + if err != nil { + return RuntimeConfig{}, nil, err + } + manualFields := make([]string, 0) + database, databaseManual, err := legacyDatabaseConfig(root, vault, legacy) + if err != nil { + return RuntimeConfig{}, nil, err + } + manualFields = append(manualFields, databaseManual...) + generation := uint64(1) + setupState := legacy.SetupState + if !setupState.Valid() { + if legacy.IsInit { + setupState = SetupStateReady + } else { + setupState = SetupStateNew + } + } + accepted := append([]string(nil), legacy.Domains...) + if len(accepted) == 0 && legacy.Domain != "" { + accepted = []string{legacy.Domain} + } + if legacy.Domain == "" && len(accepted) > 0 { + legacy.Domain = accepted[0] + } + httpsEnabled := legacy.HttpsEnabled != 2 + httpsPort := legacy.HttpsPort + if httpsEnabled && httpsPort == 0 { + httpsPort = 443 + } + if !httpsEnabled { + httpsPort = 0 + } + ssl, sslManual := legacySSLConfig(legacy) + manualFields = append(manualFields, sslManual...) + relay, relayManual, err := legacySMTPConfig(root, vault, legacy) + if err != nil { + return RuntimeConfig{}, nil, err + } + manualFields = append(manualFields, relayManual...) + plugins, pluginManual, err := legacyPluginsConfig(root, vault, legacy) + if err != nil { + return RuntimeConfig{}, nil, err + } + manualFields = append(manualFields, pluginManual...) + rootConfig := RootConfig{ + ConfigVersion: CurrentConfigVersion, + SchemaVersion: CurrentSchemaVersion, + Generation: generation, + SetupState: setupState, + LogLevel: legacy.LogLevel, + Database: database, + Domains: DomainConfig{ + Primary: legacy.Domain, + Accepted: accepted, + Web: legacy.WebDomain, + AccessHosts: append([]string(nil), legacy.AccessHosts...), + }, + HTTP: HTTPConfig{Port: legacy.HttpPort, HTTPSPort: httpsPort, HTTPSEnabled: httpsEnabled}, + Security: SecurityConfig{PasswordVersion: "argon2id", EncryptionKeyRef: "credential.key"}, + UpdatedAt: time.Now().UTC(), + } + meta := SectionMeta{Schema: CurrentSectionSchema, Generation: generation} + runtime := RuntimeConfig{ + Generation: generation, + SetupState: setupState, + Root: rootConfig, + SMTP: SMTPSectionConfig{Meta: meta, Relay: relay}, + Email: EmailSectionConfig{Meta: meta, Policy: EmailConfig{ + SMTPPort: 25, + IMAPPort: 143, + POP3Port: 110, + SpamFilterLevel: legacy.SpamFilterLevel, + LoginVerificationPolicy: legacyLoginPolicy(legacy), + ExternalRecoveryEnabled: legacy.ExternalRecoveryEnabled, + }}, + SSL: SSLSectionConfig{Meta: meta, TLS: ssl}, + Plugins: PluginsSectionConfig{Meta: meta, Plugins: plugins}, + LoadedAt: time.Now().UTC(), + } + prepared, err := prepareLegacyRuntime(runtime) + if err != nil { + return RuntimeConfig{}, nil, err + } + return prepared, manualFields, nil +} + +func resolveLegacySetupState(runtime *RuntimeConfig, legacy legacyMigrationConfig, options RuntimeValidationOptions) error { + if runtime == nil || legacy.SetupState.Valid() || !legacy.IsInit { + return nil + } + readyErr := ValidateRuntimeConfig(*runtime, options) + if readyErr == nil { + return nil + } + degraded := *runtime + degraded.SetupState = SetupStateDegraded + degraded.Root.SetupState = SetupStateDegraded + prepared, err := prepareLegacyRuntime(degraded) + if err != nil { + return err + } + if err := ValidateRuntimeConfig(prepared, options); err != nil { + return readyErr + } + *runtime = prepared + return nil +} + +func prepareLegacyRuntime(runtime RuntimeConfig) (RuntimeConfig, error) { + files, err := marshalRuntimeFiles(runtime) + if err != nil { + return RuntimeConfig{}, err + } + var root RootConfig + if err := ParseStrict(files["config.json"], &root); err != nil { + return RuntimeConfig{}, err + } + runtime.Root = root + return runtime, nil +} + +func legacyDatabaseConfig(root string, vault *credential.Vault, legacy legacyMigrationConfig) (DatabaseConfig, []string, error) { + database, password, manualFields := legacyDatabasePlan(legacy) + if len(manualFields) > 0 { + return DatabaseConfig{}, manualFields, nil + } + if database.Type == DatabaseTypeSQLite { + return database, nil, nil + } + stored, err := legacyStoredSecret(root, vault, password) + if err != nil { + return DatabaseConfig{}, nil, err + } + database.Password = stored + return database, nil, nil +} + +func legacyDatabasePlan(legacy legacyMigrationConfig) (DatabaseConfig, string, []string) { + switch legacy.DbType { + case "", DBTypeSQLite: + name := strings.TrimSpace(legacy.DbDSN) + if name == "" { + name = "smail.db" + } + name = filepath.Base(filepath.Clean(name)) + if !databaseLocalRefPattern.MatchString(name) { + return DatabaseConfig{}, "", []string{"dbDSN"} + } + return DatabaseConfig{Type: DatabaseTypeSQLite, LocalRef: name}, "", nil + case DBTypeMySQL: + database, password, ok := parseLegacyMySQLDSN(legacy.DbDSN) + if !ok { + return DatabaseConfig{}, "", []string{"dbDSN"} + } + return database, password, nil + case DBTypePostgres: + database, password, ok := parseLegacyPostgreSQLDSN(legacy.DbDSN) + if !ok { + return DatabaseConfig{}, "", []string{"dbDSN"} + } + return database, password, nil + default: + return DatabaseConfig{}, "", []string{"dbType"} + } +} + +func parseLegacyMySQLDSN(value string) (DatabaseConfig, string, bool) { + matches := legacyMySQLDSNPattern.FindStringSubmatch(value) + if matches == nil { + return DatabaseConfig{}, "", false + } + port := int(DefaultMySQLPort) + if matches[4] != "" { + parsed, err := strconv.Atoi(matches[4]) + if err != nil || !validPort(parsed) { + return DatabaseConfig{}, "", false + } + port = parsed + } + host, ok := normalizeLegacyDatabaseHost(matches[3]) + if !ok || !validLegacyDatabaseUser(matches[1]) || !validLegacyDatabasePassword(matches[2]) { + return DatabaseConfig{}, "", false + } + return DatabaseConfig{Type: DatabaseTypeMySQL, Host: host, Port: uint16(port), Username: matches[1], Name: matches[5]}, matches[2], true +} + +func parseLegacyPostgreSQLDSN(value string) (DatabaseConfig, string, bool) { + parsed, err := url.ParseRequestURI(value) + if err != nil || (parsed.Scheme != "postgres" && parsed.Scheme != "postgresql") || parsed.RawQuery != "" || parsed.Fragment != "" || parsed.User == nil || parsed.Host == "" { + return DatabaseConfig{}, "", false + } + username := parsed.User.Username() + password, ok := parsed.User.Password() + if !ok || !validLegacyDatabaseUser(username) || !validLegacyDatabasePassword(password) { + return DatabaseConfig{}, "", false + } + host, ok := normalizeLegacyDatabaseHost(parsed.Hostname()) + if !ok { + return DatabaseConfig{}, "", false + } + port := int(DefaultPostgreSQLPort) + if rawPort := parsed.Port(); rawPort != "" { + parsedPort, parseErr := strconv.Atoi(rawPort) + if parseErr != nil || !validPort(parsedPort) { + return DatabaseConfig{}, "", false + } + port = parsedPort + } + name := strings.TrimPrefix(parsed.EscapedPath(), "/") + if name == "" || strings.Contains(name, "/") || !databaseLocalRefPattern.MatchString(name) { + return DatabaseConfig{}, "", false + } + return DatabaseConfig{Type: DatabaseTypePostgreSQL, Host: host, Port: uint16(port), Username: username, Name: name}, password, true +} + +func normalizeLegacyDatabaseHost(value string) (string, bool) { + if value == "" || strings.TrimSpace(value) != value { + return "", false + } + if address := net.ParseIP(value); address != nil { + return address.String(), true + } + normalized, err := normalizeConfigDomain(value) + if err != nil { + return "", false + } + return normalized, true +} + +func validLegacyDatabaseUser(value string) bool { + return value != "" && strings.TrimSpace(value) == value && !strings.ContainsAny(value, "\r\n\x00") +} + +func validLegacyDatabasePassword(value string) bool { + return value != "" && strings.TrimSpace(value) == value && !strings.ContainsAny(value, "\r\n\x00") +} + +func legacySMTPConfig(root string, vault *credential.Vault, legacy legacyMigrationConfig) (SMTPConfig, []string, error) { + relay := SMTPConfig{ + RelayHost: legacy.SMTPHost, + RelayPort: legacy.SMTPPort, + Username: legacy.SMTPUsername, + Security: legacy.SMTPSecurity, + FromDomain: legacy.SMTPFromDomain, + VerificationEnabled: legacy.VerificationEnabled, + LoginPolicy: legacyLoginPolicy(legacy), + } + if relay.FromDomain == "" { + relay.FromDomain = legacy.Domain + } + if !relay.VerificationEnabled && relay.RelayHost == "" && relay.RelayPort == 0 && relay.Username == "" && legacy.SMTPPassword == "" { + return relay, nil, nil + } + if relay.RelayPort == 0 { + relay.RelayPort = 587 + } + if relay.Security == "" { + relay.Security = "starttls" + } + if relay.Username == "" && legacy.SMTPPassword != "" { + return SMTPConfig{}, []string{"smtpPassword"}, nil + } + if relay.Username != "" { + stored, err := legacyStoredSecret(root, vault, legacy.SMTPPassword) + if err != nil { + return SMTPConfig{}, nil, err + } + relay.Password = stored + } + return relay, nil, nil +} + +func legacySSLConfig(legacy legacyMigrationConfig) (SSLConfig, []string) { + certificateRef, certificateOK := legacyControlledReference(legacy.SSLPublicKeyPath) + privateKeyRef, privateKeyOK := legacyControlledReference(legacy.SSLPrivateKeyPath) + ssl := SSLConfig{Mode: ManagedSSLModeDefault, DefaultDirectory: "config/ssl"} + if legacy.SSLType == SSLTypeUser { + ssl.Mode = ManagedSSLModeUpload + ssl.CustomDirectory = "config/ssl" + } + if legacy.SSLPublicKeyPath == "" && legacy.SSLPrivateKeyPath == "" { + return ssl, nil + } + if !certificateOK || !privateKeyOK { + return ssl, []string{"SSLPublicKeyPath", "SSLPrivateKeyPath"} + } + ssl.CertificateRef = certificateRef + ssl.PrivateKeyRef = privateKeyRef + return ssl, nil +} + +func legacyPluginsConfig(root string, vault *credential.Vault, legacy legacyMigrationConfig) (map[string]PluginInstance, []string, error) { + enabled, manualFields := legacyPluginEnabledSet(legacy.PluginAllowList) + spamExecutable, err := catalog.CurrentExecutableName("spam_block") + if err != nil { + return nil, nil, err + } + wechatExecutable, err := catalog.CurrentExecutableName("wechat_push") + if err != nil { + return nil, nil, err + } + telegramExecutable, err := catalog.CurrentExecutableName("telegram_push") + if err != nil { + return nil, nil, err + } + plugins := map[string]PluginInstance{ + "spam_block": {Enabled: enabled["spam_block"], Executable: spamExecutable, Permissions: PluginPermissions{Capabilities: []string{"network"}}}, + } + wechatEnabled := legacy.WeChatPushAppID != "" || legacy.WeChatPushSecret != "" || legacy.WeChatPushTemplateID != "" || legacy.WeChatPushUserID != "" + wechat := PluginInstance{ + Enabled: enabled["wechat_push"], + Executable: wechatExecutable, + Permissions: PluginPermissions{Capabilities: []string{"network"}, Network: []PluginNetworkTarget{{Scheme: "https", Host: "api.weixin.qq.com", Port: 443}}}, + } + if wechatEnabled { + settings, err := json.Marshal(map[string]string{"appId": legacy.WeChatPushAppID, "templateId": legacy.WeChatPushTemplateID, "userId": legacy.WeChatPushUserID, "webDomain": legacy.WebDomain}) + if err != nil { + return nil, nil, err + } + wechat.Settings = settings + if legacy.WeChatPushSecret == "" { + manualFields = append(manualFields, "weChatPushSecret") + } else { + stored, storeErr := legacyStoredSecret(root, vault, legacy.WeChatPushSecret) + if storeErr != nil { + return nil, nil, storeErr + } + wechat.Secret = stored + } + } + if wechat.Enabled && !wechatEnabled { + manualFields = append(manualFields, "weChatPushSecret") + } + plugins["wechat_push"] = wechat + telegramEnabled := legacy.TGBotToken != "" || legacy.TGChatID != "" + telegram := PluginInstance{ + Enabled: enabled["telegram_push"], + Executable: telegramExecutable, + Permissions: PluginPermissions{Capabilities: []string{"network"}, Network: []PluginNetworkTarget{{Scheme: "https", Host: "api.telegram.org", Port: 443}}}, + } + if telegramEnabled { + if legacy.TGBotToken == "" { + manualFields = append(manualFields, "tgBotToken") + } else { + stored, storeErr := legacyStoredSecret(root, vault, legacy.TGBotToken) + if storeErr != nil { + return nil, nil, storeErr + } + telegram.Secret = stored + } + if legacy.TGChatID != "" { + manualFields = append(manualFields, "tgChatId") + } + } + if telegram.Enabled && !telegramEnabled { + manualFields = append(manualFields, "tgBotToken") + } + plugins["telegram_push"] = telegram + if legacy.WebPushURL != "" || legacy.WebPushToken != "" { + manualFields = append(manualFields, "webPushUrl", "webPushToken") + } + sort.Strings(manualFields) + return plugins, compactMigrationFields(manualFields), nil +} + +func legacyPluginEnabledSet(values []string) (map[string]bool, []string) { + enabled := make(map[string]bool, len(legacyPluginExecutableMap)) + manualFields := make([]string, 0) + for _, value := range values { + name := strings.TrimSpace(value) + if name == "" || name != value || name != strings.ToLower(name) || filepath.Base(name) != name || strings.ContainsAny(name, `/\\*?[]`) { + manualFields = append(manualFields, "pluginAllowList") + continue + } + logicalID, ok := legacyPluginExecutableMap[name] + if !ok || enabled[logicalID] { + manualFields = append(manualFields, "pluginAllowList") + continue + } + enabled[logicalID] = true + } + sort.Strings(manualFields) + return enabled, compactMigrationFields(manualFields) +} + +func legacyStoredSecret(root string, vault *credential.Vault, value string) (StoredSecret, error) { + if strings.TrimSpace(value) != value || value == "" { + return StoredSecret{}, ErrMigrationUnsafeValue + } + plaintext := value + if credential.IsEncrypted(value) { + decrypted, err := credential.Decrypt(root, value) + if err != nil { + return StoredSecret{}, ErrMigrationUnsafeValue + } + plaintext = decrypted + } + return ApplySecretChange(vault, StoredSecret{}, SecretChange{Operation: SecretReplace, Value: &SecretInput{Plaintext: plaintext}}, SecretPolicy{Required: true, MaxLength: 4096}, time.Now().UTC()) +} + +func legacyLoginPolicy(legacy legacyMigrationConfig) string { + if legacy.LoginPolicy != "" { + return legacy.LoginPolicy + } + return legacy.VerificationLoginPolicy +} + +func legacyControlledReference(value string) (string, bool) { + value = strings.TrimPrefix(strings.TrimSpace(value), "./") + value = filepath.ToSlash(value) + if !isControlledRelativePath(value) { + return "", false + } + return value, true +} + +func writeLegacyMigrationBackup(directory string, data []byte, now time.Time) (string, error) { + backupDirectory := filepath.Join(directory, "migration-backups") + if err := os.MkdirAll(backupDirectory, 0700); err != nil { + return "", err + } + info, err := os.Lstat(backupDirectory) + if err != nil || info.Mode()&os.ModeSymlink != 0 || !info.IsDir() { + return "", ErrManagerStorage + } + if err := os.Chmod(backupDirectory, 0700); err != nil { + return "", err + } + token := make([]byte, 8) + if _, err := rand.Read(token); err != nil { + return "", err + } + name := "legacy-config-" + now.Format("20060102T150405.000000000Z") + "-" + hex.EncodeToString(token) + ".json" + path := filepath.Join(backupDirectory, name) + if err := atomicfile.Write(path, data, 0600); err != nil { + return "", err + } + return path, nil +} diff --git a/server/config/migrate_test.go b/server/config/migrate_test.go new file mode 100644 index 00000000..582a74b0 --- /dev/null +++ b/server/config/migrate_test.go @@ -0,0 +1,473 @@ +package config + +import ( + "bytes" + "encoding/json" + "errors" + "os" + "path/filepath" + "testing" + + "git.pcux.cn/xuans/Smail/utils/credential" +) + +func writeLegacyMigrationFixture(t *testing.T, root string, value any) []byte { + t.Helper() + directory := filepath.Join(root, "config") + if err := os.MkdirAll(directory, 0700); err != nil { + t.Fatal(err) + } + data, err := json.Marshal(value) + if err != nil { + t.Fatal(err) + } + if err := os.WriteFile(filepath.Join(directory, "config.json"), data, 0600); err != nil { + t.Fatal(err) + } + return data +} + +func TestMigrateLegacyConfigPreservesBackupAndLoadsPartitions(t *testing.T) { + root := t.TempDir() + legacy := map[string]any{ + "logLevel": "info", + "domain": "mail.example.com", + "domains": []string{"mail.example.com", "example.com"}, + "webDomain": "mail.example.com", + "sslType": "1", + "SSLPrivateKeyPath": "./config/ssl/private.key", + "SSLPublicKeyPath": "./config/ssl/public.crt", + "dbDSN": "./config/smail.db", + "dbType": "sqlite", + "httpsEnabled": 1, + "httpPort": 80, + "httpsPort": 443, + "weChatPushAppId": "app-id", + "weChatPushSecret": "wechat-secret", + "weChatPushTemplateId": "template-id", + "isInit": true, + } + original := writeLegacyMigrationFixture(t, root, legacy) + + result, err := MigrateLegacyConfig(root, RuntimeValidationOptions{HasSuperAdmin: true, Production: true}) + if err != nil { + t.Fatal(err) + } + if result.Generation != 1 || result.BackupPath == "" { + t.Fatalf("unexpected migration result: %+v", result) + } + backup, err := os.ReadFile(result.BackupPath) + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(backup, original) { + t.Fatal("legacy backup does not match the original configuration") + } + loader := NewConfigLoader(root, ConfigLoaderOptions{Validation: RuntimeValidationOptions{HasSuperAdmin: true, Production: true}}) + runtime, err := loader.Load() + if err != nil { + t.Fatal(err) + } + if runtime.Root.Database.LocalRef != "smail.db" || runtime.Plugins.Plugins["wechat_push"].Secret.Ciphertext == "" { + t.Fatalf("unexpected migrated runtime: %+v", runtime) + } + for _, name := range []string{"config.json", "smtp.json", "email.json", "ssl.json", "plugins.json"} { + data, readErr := os.ReadFile(filepath.Join(root, "config", name)) + if readErr != nil { + t.Fatal(readErr) + } + if bytes.Contains(data, []byte("wechat-secret")) { + t.Fatalf("plaintext credential leaked to %s", name) + } + } +} + +func TestPlanLegacyMigrationReportsUnknownFieldsWithoutOverwritingConfig(t *testing.T) { + root := t.TempDir() + original := writeLegacyMigrationFixture(t, root, map[string]any{ + "dbDSN": "smail.db", + "dbType": "sqlite", + "unsupported": true, + }) + plan, err := PlanLegacyMigration(root, RuntimeValidationOptions{}) + if !errors.Is(err, ErrMigrationUnknownField) { + t.Fatalf("error = %v", err) + } + if len(plan.UnknownFields) != 1 || plan.UnknownFields[0] != "unsupported" { + t.Fatalf("unexpected unknown fields: %+v", plan.UnknownFields) + } + current, readErr := os.ReadFile(filepath.Join(root, "config", "config.json")) + if readErr != nil { + t.Fatal(readErr) + } + if !bytes.Equal(current, original) { + t.Fatal("migration planning overwrote the original configuration") + } +} + +func TestMigrateLegacyConfigRejectsManualCredentialsWithoutOverwritingConfig(t *testing.T) { + root := t.TempDir() + original := writeLegacyMigrationFixture(t, root, map[string]any{ + "dbDSN": "smail.db", + "dbType": "sqlite", + "domain": "mail.example.com", + "domains": []string{"mail.example.com"}, + "webDomain": "mail.example.com", + "sslType": "0", + "isInit": true, + "httpsEnabled": 1, + "httpsPort": 443, + "tgBotToken": "token", + "tgChatId": "123456", + "httpPort": 80, + "spamFilterLevel": 0, + }) + if _, err := MigrateLegacyConfig(root, RuntimeValidationOptions{HasSuperAdmin: true, Production: true}); !errors.Is(err, ErrMigrationUnsafeValue) { + t.Fatalf("error = %v", err) + } + current, err := os.ReadFile(filepath.Join(root, "config", "config.json")) + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(current, original) { + t.Fatal("failed migration overwrote the original configuration") + } + for _, name := range []string{"smtp.json", "email.json", "ssl.json", "plugins.json"} { + if _, err := os.Stat(filepath.Join(root, "config", name)); !os.IsNotExist(err) { + t.Fatalf("failed migration created %s", name) + } + } +} + +func TestMigrateLegacyConfigReencryptsExistingLegacyCredential(t *testing.T) { + root := t.TempDir() + if _, err := credential.NewVault(root); err != nil { + t.Fatal(err) + } + encrypted, err := credential.Encrypt(root, "telegram-token") + if err != nil { + t.Fatal(err) + } + writeLegacyMigrationFixture(t, root, map[string]any{ + "dbDSN": "smail.db", + "dbType": "sqlite", + "domain": "mail.example.com", + "domains": []string{"mail.example.com"}, + "webDomain": "mail.example.com", + "sslType": "0", + "isInit": true, + "httpsEnabled": 1, + "httpsPort": 443, + "tgBotToken": encrypted, + "httpPort": 80, + }) + if _, err := MigrateLegacyConfig(root, RuntimeValidationOptions{HasSuperAdmin: true, Production: true}); err != nil { + t.Fatal(err) + } + runtime, err := NewConfigLoader(root, ConfigLoaderOptions{Validation: RuntimeValidationOptions{HasSuperAdmin: true, Production: true}}).Load() + if err != nil { + t.Fatal(err) + } + opened, err := OpenStoredSecret(mustMigrationVault(t, root), runtime.Plugins.Plugins["telegram_push"].Secret) + if err != nil { + t.Fatal(err) + } + if opened != "telegram-token" { + t.Fatalf("opened secret = %q", opened) + } +} + +func TestMigrateLegacyConfigResumesWithEquivalentExistingSecretSection(t *testing.T) { + root := t.TempDir() + legacy := map[string]any{ + "dbDSN": "smail.db", + "dbType": "sqlite", + "domain": "mail.example.com", + "domains": []string{"mail.example.com"}, + "webDomain": "mail.example.com", + "sslType": "0", + "isInit": true, + "httpsEnabled": 1, + "httpPort": 80, + "httpsPort": 443, + "tgBotToken": "telegram-token", + "pluginAllowList": []string{"telegram_push"}, + } + original := writeLegacyMigrationFixture(t, root, legacy) + if _, err := MigrateLegacyConfig(root, RuntimeValidationOptions{HasSuperAdmin: true, Production: true}); err != nil { + t.Fatal(err) + } + pluginsPath := filepath.Join(root, "config", "plugins.json") + pluginsBefore, err := os.ReadFile(pluginsPath) + if err != nil { + t.Fatal(err) + } + for _, name := range []string{"smtp.json", "email.json", "ssl.json"} { + if err := os.Remove(filepath.Join(root, "config", name)); err != nil { + t.Fatal(err) + } + } + if err := os.WriteFile(filepath.Join(root, "config", "config.json"), original, 0600); err != nil { + t.Fatal(err) + } + if _, err := MigrateLegacyConfig(root, RuntimeValidationOptions{HasSuperAdmin: true, Production: true}); err != nil { + t.Fatal(err) + } + pluginsAfter, err := os.ReadFile(pluginsPath) + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(pluginsBefore, pluginsAfter) { + t.Fatal("resume replaced an equivalent existing secret section") + } + if _, err := NewConfigLoader(root, ConfigLoaderOptions{Validation: RuntimeValidationOptions{HasSuperAdmin: true, Production: true}}).Load(); err != nil { + t.Fatal(err) + } +} + +func TestMigrateLegacyConfigRejectsInconsistentExistingSectionBeforeWriting(t *testing.T) { + root := t.TempDir() + original := writeLegacyMigrationFixture(t, root, map[string]any{ + "dbDSN": "smail.db", + "dbType": "sqlite", + "domain": "mail.example.com", + "domains": []string{"mail.example.com"}, + "webDomain": "mail.example.com", + "sslType": "0", + "isInit": true, + "httpsEnabled": 1, + "httpPort": 80, + "httpsPort": 443, + }) + conflicting := []byte(`{"meta":{"schema":1,"generation":1},"policy":{"smtpPort":2525}}`) + conflictingPath := filepath.Join(root, "config", "email.json") + if err := os.WriteFile(conflictingPath, conflicting, 0600); err != nil { + t.Fatal(err) + } + if _, err := MigrateLegacyConfig(root, RuntimeValidationOptions{HasSuperAdmin: true, Production: true}); !errors.Is(err, ErrMigrationTargetExists) { + t.Fatalf("error = %v", err) + } + current, err := os.ReadFile(filepath.Join(root, "config", "config.json")) + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(current, original) { + t.Fatal("conflicting migration changed the legacy root configuration") + } + stored, err := os.ReadFile(conflictingPath) + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(stored, conflicting) { + t.Fatal("conflicting section was overwritten") + } + for _, name := range []string{"smtp.json", "ssl.json", "plugins.json"} { + if _, err := os.Stat(filepath.Join(root, "config", name)); !os.IsNotExist(err) { + t.Fatalf("conflicting migration created %s", name) + } + } +} + +func mustMigrationVault(t *testing.T, root string) *credential.Vault { + t.Helper() + vault, err := credential.NewVault(root) + if err != nil { + t.Fatal(err) + } + return vault +} + +func TestMigrateLegacyConfigMapsPluginAllowListToFixedLogicalIDs(t *testing.T) { + root := t.TempDir() + writeLegacyMigrationFixture(t, root, map[string]any{ + "dbDSN": "smail.db", + "dbType": "sqlite", + "domain": "mail.example.com", + "domains": []string{"mail.example.com"}, + "webDomain": "mail.example.com", + "sslType": "0", + "isInit": true, + "httpsEnabled": 1, + "httpPort": 80, + "httpsPort": 443, + "weChatPushAppId": "app-id", + "weChatPushSecret": "wechat-secret", + "weChatPushTemplateId": "template-id", + "tgBotToken": "telegram-token", + "pluginAllowList": []string{"spam_block.exe", "wechat_push", "pmail_telegram_push.exe"}, + }) + + if _, err := MigrateLegacyConfig(root, RuntimeValidationOptions{HasSuperAdmin: true, Production: true}); err != nil { + t.Fatal(err) + } + runtime, err := NewConfigLoader(root, ConfigLoaderOptions{Validation: RuntimeValidationOptions{HasSuperAdmin: true, Production: true}}).Load() + if err != nil { + t.Fatal(err) + } + for _, logicalID := range []string{"spam_block", "wechat_push", "telegram_push"} { + plugin, ok := runtime.Plugins.Plugins[logicalID] + if !ok || !plugin.Enabled { + t.Fatalf("plugin %s was not enabled from the legacy allow list: %+v", logicalID, runtime.Plugins.Plugins) + } + } +} + +func TestPlanLegacyMigrationRejectsUnsafePluginAllowList(t *testing.T) { + cases := map[string][]string{ + "路径": {"../spam_block"}, + "大小写冲突": {"Spam_Block"}, + "未知插件": {"unknown_plugin"}, + "逻辑重复": {"spam_block", "spam_block.exe"}, + } + for name, allowList := range cases { + t.Run(name, func(t *testing.T) { + root := t.TempDir() + writeLegacyMigrationFixture(t, root, map[string]any{ + "dbDSN": "smail.db", + "dbType": "sqlite", + "pluginAllowList": allowList, + }) + plan, err := PlanLegacyMigration(root, RuntimeValidationOptions{}) + if !errors.Is(err, ErrMigrationUnsafeValue) { + t.Fatalf("error = %v", err) + } + if len(plan.ManualFields) != 1 || plan.ManualFields[0] != "pluginAllowList" { + t.Fatalf("manual fields = %+v", plan.ManualFields) + } + }) + } +} + +func TestPlanLegacyMigrationRejectsEnabledPluginWithoutRequiredCredential(t *testing.T) { + root := t.TempDir() + writeLegacyMigrationFixture(t, root, map[string]any{ + "dbDSN": "smail.db", + "dbType": "sqlite", + "pluginAllowList": []string{"wechat_push"}, + }) + plan, err := PlanLegacyMigration(root, RuntimeValidationOptions{}) + if !errors.Is(err, ErrMigrationUnsafeValue) { + t.Fatalf("error = %v", err) + } + if len(plan.ManualFields) != 1 || plan.ManualFields[0] != "weChatPushSecret" { + t.Fatalf("manual fields = %+v", plan.ManualFields) + } +} + +func TestMigrateLegacyConfigParsesKnownStructuredDatabaseDSNs(t *testing.T) { + cases := []struct { + name string + database string + dsn string + wantType DatabaseType + wantPort uint16 + wantHost string + wantName string + password string + }{ + { + name: "MySQL", + database: DBTypeMySQL, + dsn: "smail:database-secret@tcp(db.example.com:3307)/smail?charset=utf8mb4", + wantType: DatabaseTypeMySQL, + wantPort: 3307, + wantHost: "db.example.com", + wantName: "smail", + password: "database-secret", + }, + { + name: "PostgreSQL", + database: DBTypePostgres, + dsn: "postgres://smail:database-secret@db.example.com:5433/smail", + wantType: DatabaseTypePostgreSQL, + wantPort: 5433, + wantHost: "db.example.com", + wantName: "smail", + password: "database-secret", + }, + } + for _, testCase := range cases { + t.Run(testCase.name, func(t *testing.T) { + root := t.TempDir() + writeLegacyMigrationFixture(t, root, map[string]any{ + "dbDSN": testCase.dsn, + "dbType": testCase.database, + "domain": "mail.example.com", + "domains": []string{"mail.example.com"}, + "webDomain": "mail.example.com", + "sslType": "0", + "isInit": true, + "httpsEnabled": 1, + "httpPort": 80, + "httpsPort": 443, + }) + if _, err := MigrateLegacyConfig(root, RuntimeValidationOptions{HasSuperAdmin: true, Production: true}); err != nil { + t.Fatal(err) + } + runtime, err := NewConfigLoader(root, ConfigLoaderOptions{Validation: RuntimeValidationOptions{HasSuperAdmin: true, Production: true}}).Load() + if err != nil { + t.Fatal(err) + } + database := runtime.Root.Database + if database.Type != testCase.wantType || database.Port != testCase.wantPort || database.Host != testCase.wantHost || database.Name != testCase.wantName || database.Username != "smail" { + t.Fatalf("database = %+v", database) + } + opened, err := OpenStoredSecret(mustMigrationVault(t, root), database.Password) + if err != nil { + t.Fatal(err) + } + if opened != testCase.password { + t.Fatalf("database password = %q", opened) + } + data, err := os.ReadFile(filepath.Join(root, "config", "config.json")) + if err != nil { + t.Fatal(err) + } + if bytes.Contains(data, []byte(testCase.password)) || bytes.Contains(data, []byte(testCase.dsn)) { + t.Fatal("database credential leaked to the migrated configuration") + } + }) + } +} + +func TestPlanLegacyMigrationRejectsAmbiguousDatabaseDSN(t *testing.T) { + root := t.TempDir() + writeLegacyMigrationFixture(t, root, map[string]any{ + "dbDSN": "postgres://smail:password@db.example.com:5432/smail?sslmode=disable", + "dbType": DBTypePostgres, + }) + plan, err := PlanLegacyMigration(root, RuntimeValidationOptions{}) + if !errors.Is(err, ErrMigrationUnsafeValue) { + t.Fatalf("error = %v", err) + } + if len(plan.ManualFields) != 1 || plan.ManualFields[0] != "dbDSN" { + t.Fatalf("manual fields = %+v", plan.ManualFields) + } +} + +func TestMigrateLegacyConfigDerivesSetupStateFromFullPreflight(t *testing.T) { + root := t.TempDir() + writeLegacyMigrationFixture(t, root, map[string]any{ + "dbDSN": "smail.db", + "dbType": "sqlite", + "domain": "mail.example.com", + "domains": []string{"mail.example.com"}, + "webDomain": "mail.example.com", + "sslType": "0", + "isInit": true, + "httpsEnabled": 1, + "httpPort": 80, + "httpsPort": 443, + }) + options := RuntimeValidationOptions{HasSuperAdmin: false, Production: true} + if _, err := MigrateLegacyConfig(root, options); err != nil { + t.Fatal(err) + } + runtime, err := NewConfigLoader(root, ConfigLoaderOptions{Validation: options}).Load() + if err != nil { + t.Fatal(err) + } + if runtime.SetupState != SetupStateDegraded || runtime.Root.SetupState != SetupStateDegraded { + t.Fatalf("setup state = %q / %q", runtime.SetupState, runtime.Root.SetupState) + } +} diff --git a/server/config/runtime_validator.go b/server/config/runtime_validator.go index ba6c510e..057134b3 100644 --- a/server/config/runtime_validator.go +++ b/server/config/runtime_validator.go @@ -3,6 +3,7 @@ package config import ( "encoding/json" "errors" + "git.pcux.cn/xuans/Smail/plugins/catalog" "net" "path/filepath" "regexp" @@ -148,7 +149,11 @@ func validateRuntimePorts(http HTTPConfig, email EmailConfig) error { func validatePluginSection(section PluginsSectionConfig) error { for logicalID, plugin := range section.Plugins { - if !logicalIDPattern.MatchString(logicalID) || filepath.Base(plugin.Executable) != plugin.Executable || plugin.Executable == "" { + if !logicalIDPattern.MatchString(logicalID) || filepath.Base(plugin.Executable) != plugin.Executable || !catalog.IsCurrentExecutable(logicalID, plugin.Executable) { + return ErrInvalidPlugin + } + definition, ok := catalog.Lookup(logicalID) + if !ok { return ErrInvalidPlugin } capabilities := make(map[string]struct{}, len(plugin.Permissions.Capabilities)) @@ -161,6 +166,9 @@ func validatePluginSection(section PluginsSectionConfig) error { } capabilities[capability] = struct{}{} } + if !matchesCatalogCapabilities(capabilities, definition.Capabilities) { + return ErrPluginCapability + } if len(plugin.Permissions.Network) > 0 { if _, ok := capabilities["network"]; !ok { return ErrPluginCapability @@ -191,6 +199,18 @@ func validatePluginSection(section PluginsSectionConfig) error { return nil } +func matchesCatalogCapabilities(actual map[string]struct{}, expected []string) bool { + if len(actual) != len(expected) { + return false + } + for _, capability := range expected { + if _, ok := actual[capability]; !ok { + return false + } + } + return true +} + func validPluginSettings(data json.RawMessage) bool { if len(data) == 0 { return true diff --git a/server/config/runtime_validator_test.go b/server/config/runtime_validator_test.go index a53e3536..4fff8fbb 100644 --- a/server/config/runtime_validator_test.go +++ b/server/config/runtime_validator_test.go @@ -3,6 +3,7 @@ package config import ( "encoding/json" "errors" + "git.pcux.cn/xuans/Smail/plugins/catalog" "testing" ) @@ -27,7 +28,7 @@ func validRuntimeConfig() RuntimeConfig { Plugins: PluginsSectionConfig{Meta: meta, Plugins: map[string]PluginInstance{ "telegram_push": { Enabled: true, - Executable: "telegram_push", + Executable: currentPluginExecutable("telegram_push"), Permissions: PluginPermissions{ Capabilities: []string{"network"}, Network: []PluginNetworkTarget{{Scheme: "https", Host: "api.telegram.org", Port: 443}}, @@ -38,6 +39,14 @@ func validRuntimeConfig() RuntimeConfig { } } +func currentPluginExecutable(logicalID string) string { + executable, err := catalog.CurrentExecutableName(logicalID) + if err != nil { + panic(err) + } + return executable +} + func TestValidateRuntimeConfig(t *testing.T) { runtime := validRuntimeConfig() runtime.Root.Domains.AccessHosts = []string{"192.0.2.10", "reset.example.com"} @@ -73,6 +82,16 @@ func TestValidateRuntimeConfigRejectsCrossSectionViolations(t *testing.T) { plugin.Settings = json.RawMessage(`{"botToken":"secret"}`) runtime.Plugins.Plugins["telegram_push"] = plugin }, want: ErrInvalidPlugin}, + {name: "plugin_executable_mismatch", mutate: func(runtime *RuntimeConfig, _ *RuntimeValidationOptions) { + plugin := runtime.Plugins.Plugins["telegram_push"] + plugin.Executable = "untrusted_plugin.exe" + runtime.Plugins.Plugins["telegram_push"] = plugin + }, want: ErrInvalidPlugin}, + {name: "plugin_capability_escalation", mutate: func(runtime *RuntimeConfig, _ *RuntimeValidationOptions) { + plugin := runtime.Plugins.Plugins["telegram_push"] + plugin.Permissions.Capabilities = append(plugin.Permissions.Capabilities, "filesystem") + runtime.Plugins.Plugins["telegram_push"] = plugin + }, want: ErrPluginCapability}, } for _, test := range tests { t.Run(test.name, func(t *testing.T) { diff --git a/server/config/security.go b/server/config/security.go index 95e07c7e..062bfc8e 100644 --- a/server/config/security.go +++ b/server/config/security.go @@ -19,8 +19,9 @@ var ( type ConfigOperation string const ( - ConfigOperationUpdate ConfigOperation = "update" - ConfigOperationRollback ConfigOperation = "rollback" + ConfigOperationUpdate ConfigOperation = "update" + ConfigOperationRollback ConfigOperation = "rollback" + ConfigOperationMigration ConfigOperation = "migration" ) type ConfigAuditEvent struct { diff --git a/server/config/ssl_storage.go b/server/config/ssl_storage.go new file mode 100644 index 00000000..ba89004d --- /dev/null +++ b/server/config/ssl_storage.go @@ -0,0 +1,519 @@ +package config + +import ( + "crypto/ecdsa" + "crypto/rand" + "crypto/rsa" + "crypto/tls" + "crypto/x509" + "encoding/hex" + "encoding/pem" + "errors" + "fmt" + "os" + "path/filepath" + "strings" + "time" + + "git.pcux.cn/xuans/Smail/utils/atomicfile" +) + +const ( + ManagedSSLModeDefault = "managed_default" + ManagedSSLModeUpload = "managed_upload" + + managedSSLRelativeRoot = "config/ssl/managed" + maxManagedSSLFileSize = 1 << 20 +) + +var ( + ErrInvalidSSLMode = errors.New("invalid SSL managed mode") + ErrInvalidSSLMaterial = errors.New("invalid SSL certificate material") + ErrInvalidSSLReference = errors.New("invalid SSL certificate reference") + ErrUnsafeSSLFile = errors.New("unsafe SSL certificate file") + ErrSSLCertificateMismatch = errors.New("SSL certificate and private key do not match") + ErrSSLCertificateDomain = errors.New("SSL certificate domain does not match") + ErrSSLCertificateExpired = errors.New("SSL certificate is expired or not yet valid") + ErrSSLPrivateKeyPermission = errors.New("SSL private key permissions are too broad") +) + +type ManagedSSLReference struct { + Mode string + CertificateRef string + PrivateKeyRef string + CertificatePath string + PrivateKeyPath string +} + +// ResolveRuntimeSSLPaths 返回服务启动时使用的受控证书路径。 +// 新配置优先使用内部引用,旧配置只通过只读兼容适配层加载。 +func ResolveRuntimeSSLPaths(cfg *Config) (string, string, error) { + if cfg == nil { + return "", "", ErrInvalidSSLReference + } + if cfg.SSL.Mode != "" || cfg.SSL.CertificateRef != "" || cfg.SSL.PrivateKeyRef != "" { + if !validManagedSSLMode(cfg.SSL.Mode) || cfg.SSL.CertificateRef == "" || cfg.SSL.PrivateKeyRef == "" { + return "", "", ErrInvalidSSLReference + } + resolved, err := ResolveManagedSSLReferences(cfg.SSL) + if err != nil { + return "", "", err + } + return resolved.CertificatePath, resolved.PrivateKeyPath, nil + } + return resolveLegacySSLPaths(cfg.SSLPublicKeyPath, cfg.SSLPrivateKeyPath) +} + +// LoadRuntimeTLSCertificate 在所有 TLS 服务中统一解析并加载证书。 +func LoadRuntimeTLSCertificate(cfg *Config) (tls.Certificate, error) { + certificatePath, privateKeyPath, err := ResolveRuntimeSSLPaths(cfg) + if err != nil { + return tls.Certificate{}, err + } + certificate, err := tls.LoadX509KeyPair(certificatePath, privateKeyPath) + if err != nil { + return tls.Certificate{}, err + } + return certificate, nil +} + +// ImportManagedSSL 校验证书材料后写入候选目录,并原子切换 current 目录。 +func ImportManagedSSL(mode string, privateKeyPEM, certificatePEM, issuerPEM []byte, domains []string) (ManagedSSLReference, error) { + if !validManagedSSLMode(mode) { + return ManagedSSLReference{}, ErrInvalidSSLMode + } + if err := validateSSLMaterial(privateKeyPEM, certificatePEM, issuerPEM, domains); err != nil { + return ManagedSSLReference{}, err + } + + rootPath, err := managedSSLRootPath(mode) + if err != nil { + return ManagedSSLReference{}, err + } + if err := ensureManagedDirectory(rootPath); err != nil { + return ManagedSSLReference{}, err + } + + token, err := randomStorageToken() + if err != nil { + return ManagedSSLReference{}, err + } + candidatePath := filepath.Join(rootPath, ".candidate-"+token) + if err := os.Mkdir(candidatePath, 0700); err != nil { + return ManagedSSLReference{}, err + } + defer func() { + if _, statErr := os.Stat(candidatePath); statErr == nil { + _ = os.RemoveAll(candidatePath) + } + }() + + candidateRoot, err := os.OpenRoot(candidatePath) + if err != nil { + return ManagedSSLReference{}, err + } + write := func(name string, data []byte, permission os.FileMode) error { + if len(data) == 0 { + return nil + } + return atomicfile.WriteRoot(candidateRoot, name, data, permission) + } + if err := write("private.key", privateKeyPEM, 0600); err != nil { + candidateRoot.Close() + return ManagedSSLReference{}, err + } + if err := write("public.crt", certificatePEM, 0600); err != nil { + candidateRoot.Close() + return ManagedSSLReference{}, err + } + if err := write("issuer.crt", issuerPEM, 0600); err != nil { + candidateRoot.Close() + return ManagedSSLReference{}, err + } + if err := candidateRoot.Close(); err != nil { + return ManagedSSLReference{}, err + } + + activePath := filepath.Join(rootPath, "current") + backupPath := filepath.Join(rootPath, ".previous-"+token) + previousMoved := false + activeInstalled := false + if info, statErr := os.Lstat(activePath); statErr == nil { + if info.Mode()&os.ModeSymlink != 0 || !info.IsDir() { + return ManagedSSLReference{}, ErrUnsafeSSLFile + } + if err := os.Rename(activePath, backupPath); err != nil { + return ManagedSSLReference{}, err + } + previousMoved = true + if err := os.Rename(candidatePath, activePath); err != nil { + _ = os.Rename(backupPath, activePath) + return ManagedSSLReference{}, err + } + activeInstalled = true + } else if !os.IsNotExist(statErr) { + return ManagedSSLReference{}, statErr + } else if err := os.Rename(candidatePath, activePath); err != nil { + return ManagedSSLReference{}, err + } else { + activeInstalled = true + } + + certificatePath := filepath.Join(activePath, "public.crt") + privateKeyPath := filepath.Join(activePath, "private.key") + if err := validateManagedSSLFiles(certificatePath, privateKeyPath); err != nil { + rollbackErr := rollbackManagedSSLActivation(activePath, backupPath, previousMoved, activeInstalled) + if rollbackErr != nil { + return ManagedSSLReference{}, fmt.Errorf("%w; rollback failed: %v", err, rollbackErr) + } + return ManagedSSLReference{}, err + } + return ManagedSSLReference{ + Mode: mode, + CertificateRef: managedSSLReference(mode, "public.crt"), + PrivateKeyRef: managedSSLReference(mode, "private.key"), + CertificatePath: certificatePath, + PrivateKeyPath: privateKeyPath, + }, nil +} + +// ResolveManagedSSLReferences 将内部引用解析为受控文件路径,拒绝任意路径输入。 +func ResolveManagedSSLReferences(ssl SSLConfig) (ManagedSSLReference, error) { + if !validManagedSSLMode(ssl.Mode) { + return ManagedSSLReference{}, ErrInvalidSSLMode + } + if ssl.CertificateRef == "" || ssl.PrivateKeyRef == "" { + return ManagedSSLReference{}, ErrInvalidSSLReference + } + rootPath, err := managedSSLRootPath(ssl.Mode) + if err != nil { + return ManagedSSLReference{}, err + } + certificatePath, err := resolveManagedReference(rootPath, ssl.CertificateRef, "public.crt") + if err != nil { + return ManagedSSLReference{}, err + } + privateKeyPath, err := resolveManagedReference(rootPath, ssl.PrivateKeyRef, "private.key") + if err != nil { + return ManagedSSLReference{}, err + } + if err := validateManagedSSLFiles(certificatePath, privateKeyPath); err != nil { + return ManagedSSLReference{}, err + } + return ManagedSSLReference{ + Mode: ssl.Mode, + CertificateRef: ssl.CertificateRef, + PrivateKeyRef: ssl.PrivateKeyRef, + CertificatePath: certificatePath, + PrivateKeyPath: privateKeyPath, + }, nil +} + +// ValidateSSLMaterial 校验证书链、私钥匹配、有效期和可选域名。 +func ValidateSSLMaterial(privateKeyPEM, certificatePEM, issuerPEM []byte, domains []string) error { + return validateSSLMaterial(privateKeyPEM, certificatePEM, issuerPEM, domains) +} + +func validateSSLMaterial(privateKeyPEM, certificatePEM, issuerPEM []byte, domains []string) error { + if len(privateKeyPEM) == 0 || len(certificatePEM) == 0 || len(privateKeyPEM) > maxManagedSSLFileSize || len(certificatePEM) > maxManagedSSLFileSize || len(issuerPEM) > maxManagedSSLFileSize { + return ErrInvalidSSLMaterial + } + certificates, err := parseCertificatePEM(certificatePEM) + if err != nil || len(certificates) == 0 { + return ErrInvalidSSLMaterial + } + if len(issuerPEM) > 0 { + issuerCertificates, issuerErr := parseCertificatePEM(issuerPEM) + if issuerErr != nil { + return ErrInvalidSSLMaterial + } + certificates = append(certificates, issuerCertificates...) + } + if _, err := tls.X509KeyPair(certificatePEM, privateKeyPEM); err != nil { + return ErrSSLCertificateMismatch + } + leaf := certificates[0] + now := time.Now() + if now.Before(leaf.NotBefore) || !now.Before(leaf.NotAfter) { + return ErrSSLCertificateExpired + } + if err := validateCertificateChain(certificates); err != nil { + return err + } + if err := validateCertificateKeyStrength(leaf); err != nil { + return err + } + for _, domain := range domains { + domain = strings.TrimSpace(domain) + if domain == "" { + continue + } + if err := leaf.VerifyHostname(domain); err != nil { + return fmt.Errorf("%w: %s", ErrSSLCertificateDomain, domain) + } + } + return nil +} + +func parseCertificatePEM(data []byte) ([]*x509.Certificate, error) { + var certificates []*x509.Certificate + remaining := data + for { + block, rest := pem.Decode(remaining) + if block == nil { + if len(strings.TrimSpace(string(remaining))) != 0 { + return nil, ErrInvalidSSLMaterial + } + break + } + if block.Type != "CERTIFICATE" || len(block.Bytes) == 0 { + return nil, ErrInvalidSSLMaterial + } + certificate, err := x509.ParseCertificate(block.Bytes) + if err != nil { + return nil, ErrInvalidSSLMaterial + } + certificates = append(certificates, certificate) + remaining = rest + } + return certificates, nil +} + +func validateCertificateChain(certificates []*x509.Certificate) error { + for index := 0; index+1 < len(certificates); index++ { + issuer := certificates[index+1] + if !issuer.IsCA || issuer.BasicConstraintsValid && !issuer.IsCA { + return ErrInvalidSSLMaterial + } + if err := certificates[index].CheckSignatureFrom(issuer); err != nil { + return ErrInvalidSSLMaterial + } + } + return nil +} + +func validateCertificateKeyStrength(certificate *x509.Certificate) error { + switch publicKey := certificate.PublicKey.(type) { + case *rsa.PublicKey: + return validateRSAKeyStrength(publicKey) + case *ecdsa.PublicKey: + if publicKey.Curve == nil || publicKey.Curve.Params().BitSize < 256 { + return ErrInvalidSSLMaterial + } + return nil + default: + return ErrInvalidSSLMaterial + } +} + +func validateRSAKeyStrength(publicKey *rsa.PublicKey) error { + if publicKey == nil || publicKey.N == nil || publicKey.N.BitLen() < 2048 { + return ErrInvalidSSLMaterial + } + return nil +} + +func validManagedSSLMode(mode string) bool { + return mode == ManagedSSLModeDefault || mode == ManagedSSLModeUpload +} + +func managedSSLRootPath(mode string) (string, error) { + if !validManagedSSLMode(mode) { + return "", ErrInvalidSSLMode + } + rootPath, err := filepath.Abs(filepath.Clean(ROOT_PATH)) + if err != nil { + return "", err + } + folder := "default" + if mode == ManagedSSLModeUpload { + folder = "upload" + } + return filepath.Join(rootPath, managedSSLRelativeRoot, folder), nil +} + +func managedSSLReference(mode, name string) string { + folder := "default" + if mode == ManagedSSLModeUpload { + folder = "upload" + } + return filepath.ToSlash(filepath.Join(managedSSLRelativeRoot, folder, "current", name)) +} + +func resolveManagedReference(rootPath, reference, expectedName string) (string, error) { + rawReference := strings.TrimSpace(reference) + if rawReference == "" || strings.Contains(rawReference, `\`) || filepath.IsAbs(rawReference) || isWindowsAbsolute(rawReference) { + return "", ErrInvalidSSLReference + } + reference = filepath.FromSlash(rawReference) + if filepath.ToSlash(filepath.Clean(reference)) != rawReference { + return "", ErrInvalidSSLReference + } + workspaceRoot, err := filepath.Abs(filepath.Clean(ROOT_PATH)) + if err != nil { + return "", ErrInvalidSSLReference + } + target, err := filepath.Abs(filepath.Join(workspaceRoot, reference)) + if err != nil || filepath.Base(target) != expectedName || !pathWithin(rootPath, target) { + return "", ErrInvalidSSLReference + } + if filepath.Dir(target) != filepath.Join(rootPath, "current") { + return "", ErrInvalidSSLReference + } + return target, nil +} + +func validateManagedSSLFiles(certificatePath, privateKeyPath string) error { + for _, item := range []struct { + path string + isPrivate bool + }{{certificatePath, false}, {privateKeyPath, true}} { + info, err := os.Lstat(item.path) + if err != nil || info.Mode()&os.ModeSymlink != 0 || !info.Mode().IsRegular() || info.Size() <= 0 || info.Size() > maxManagedSSLFileSize || hasMultipleFileLinks(item.path) { + return ErrUnsafeSSLFile + } + if item.isPrivate && info.Mode().Perm()&0077 != 0 && runtimeSupportsPermissionCheck() { + return ErrSSLPrivateKeyPermission + } + } + privateKeyPEM, err := os.ReadFile(privateKeyPath) + if err != nil { + return ErrUnsafeSSLFile + } + certificatePEM, err := os.ReadFile(certificatePath) + if err != nil { + return ErrUnsafeSSLFile + } + return validateSSLMaterial(privateKeyPEM, certificatePEM, nil, nil) +} + +func resolveLegacySSLPaths(certificatePath, privateKeyPath string) (string, string, error) { + certificatePath, certificatePEM, err := readLegacySSLFile(certificatePath, false) + if err != nil { + return "", "", err + } + privateKeyPath, privateKeyPEM, err := readLegacySSLFile(privateKeyPath, true) + if err != nil { + return "", "", err + } + if err := validateSSLMaterial(privateKeyPEM, certificatePEM, nil, nil); err != nil { + return "", "", err + } + return certificatePath, privateKeyPath, nil +} + +func readLegacySSLFile(value string, privateKey bool) (string, []byte, error) { + value = strings.TrimSpace(value) + if value == "" || !filepath.IsAbs(value) { + return "", nil, ErrInvalidSSLReference + } + path := filepath.Clean(value) + info, err := os.Lstat(path) + if err != nil || info.Mode()&os.ModeSymlink != 0 || !info.Mode().IsRegular() || info.Size() <= 0 || info.Size() > maxManagedSSLFileSize || hasMultipleFileLinks(path) { + return "", nil, ErrUnsafeSSLFile + } + resolvedDirectory, err := filepath.EvalSymlinks(filepath.Dir(path)) + if err != nil || filepath.Clean(resolvedDirectory) != filepath.Clean(filepath.Dir(path)) { + return "", nil, ErrUnsafeSSLFile + } + if privateKey && info.Mode().Perm()&0077 != 0 && runtimeSupportsPermissionCheck() { + return "", nil, ErrSSLPrivateKeyPermission + } + data, err := os.ReadFile(path) + if err != nil { + return "", nil, ErrUnsafeSSLFile + } + return path, data, nil +} + +func rollbackManagedSSLActivation(activePath, backupPath string, previousMoved, activeInstalled bool) error { + if activeInstalled { + if err := removeManagedSSLDirectory(activePath); err != nil { + return err + } + } + if previousMoved { + return os.Rename(backupPath, activePath) + } + return nil +} + +func removeManagedSSLDirectory(directory string) error { + info, err := os.Lstat(directory) + if err != nil { + return err + } + if info.Mode()&os.ModeSymlink != 0 || !info.IsDir() { + return ErrUnsafeSSLFile + } + entries, err := os.ReadDir(directory) + if err != nil { + return err + } + for _, entry := range entries { + if entry.Name() != "private.key" && entry.Name() != "public.crt" && entry.Name() != "issuer.crt" { + return ErrUnsafeSSLFile + } + entryPath := filepath.Join(directory, entry.Name()) + entryInfo, statErr := os.Lstat(entryPath) + if statErr != nil || entryInfo.Mode()&os.ModeSymlink != 0 || !entryInfo.Mode().IsRegular() { + return ErrUnsafeSSLFile + } + if err := os.Remove(entryPath); err != nil { + return err + } + } + return os.Remove(directory) +} + +func ensureManagedDirectory(directory string) error { + rootPath, err := filepath.Abs(filepath.Clean(ROOT_PATH)) + if err != nil { + return err + } + if !pathWithin(rootPath, directory) { + return ErrUnsafeSSLFile + } + relative, err := filepath.Rel(rootPath, directory) + if err != nil || filepath.IsAbs(relative) { + return ErrUnsafeSSLFile + } + current := rootPath + for _, part := range strings.Split(relative, string(os.PathSeparator)) { + if part == "" || part == "." || part == ".." { + return ErrUnsafeSSLFile + } + current = filepath.Join(current, part) + info, statErr := os.Lstat(current) + if os.IsNotExist(statErr) { + if err := os.Mkdir(current, 0700); err != nil { + return err + } + info, statErr = os.Lstat(current) + } + if statErr != nil || info.Mode()&os.ModeSymlink != 0 || !info.IsDir() { + return ErrUnsafeSSLFile + } + if err := os.Chmod(current, 0700); err != nil { + return err + } + } + return nil +} + +func pathWithin(root, target string) bool { + relative, err := filepath.Rel(root, target) + return err == nil && !filepath.IsAbs(relative) && relative != ".." && !strings.HasPrefix(relative, ".."+string(os.PathSeparator)) +} + +func randomStorageToken() (string, error) { + buffer := make([]byte, 16) + if _, err := rand.Read(buffer); err != nil { + return "", err + } + return hex.EncodeToString(buffer), nil +} + +func runtimeSupportsPermissionCheck() bool { + return os.PathSeparator == '/' +} diff --git a/server/config/ssl_storage_links_unix.go b/server/config/ssl_storage_links_unix.go new file mode 100644 index 00000000..b3288750 --- /dev/null +++ b/server/config/ssl_storage_links_unix.go @@ -0,0 +1,13 @@ +//go:build !windows + +package config + +import "syscall" + +func hasMultipleFileLinks(path string) bool { + var stat syscall.Stat_t + if err := syscall.Lstat(path, &stat); err != nil { + return true + } + return stat.Nlink > 1 +} diff --git a/server/config/ssl_storage_links_windows.go b/server/config/ssl_storage_links_windows.go new file mode 100644 index 00000000..6bcf807b --- /dev/null +++ b/server/config/ssl_storage_links_windows.go @@ -0,0 +1,7 @@ +//go:build windows + +package config + +func hasMultipleFileLinks(path string) bool { + return false +} diff --git a/server/config/ssl_storage_test.go b/server/config/ssl_storage_test.go new file mode 100644 index 00000000..03943bb4 --- /dev/null +++ b/server/config/ssl_storage_test.go @@ -0,0 +1,228 @@ +package config + +import ( + "crypto/rand" + "crypto/rsa" + "crypto/x509" + "crypto/x509/pkix" + "encoding/pem" + "errors" + "math/big" + "os" + "path/filepath" + "runtime" + "strings" + "testing" + "time" +) + +func TestImportManagedSSLUsesInternalReferencesAndAtomicCurrent(t *testing.T) { + oldRoot := ROOT_PATH + ROOT_PATH = t.TempDir() + t.Cleanup(func() { ROOT_PATH = oldRoot }) + privateKeyPEM, certificatePEM := testManagedCertificate(t, "mail.example.com", time.Now().Add(-time.Hour), time.Now().Add(24*time.Hour), 2048) + + first, err := ImportManagedSSL(ManagedSSLModeDefault, privateKeyPEM, certificatePEM, nil, []string{"mail.example.com"}) + if err != nil { + t.Fatal(err) + } + if filepath.IsAbs(first.CertificateRef) || filepath.IsAbs(first.PrivateKeyRef) { + t.Fatal("SSL 内部引用不应为绝对路径") + } + if first.CertificateRef != "config/ssl/managed/default/current/public.crt" || first.PrivateKeyRef != "config/ssl/managed/default/current/private.key" { + t.Fatalf("内部引用不符合预期: %+v", first) + } + resolved, err := ResolveManagedSSLReferences(SSLConfig{Mode: ManagedSSLModeDefault, DefaultDirectory: "config/ssl", CertificateRef: first.CertificateRef, PrivateKeyRef: first.PrivateKeyRef}) + if err != nil { + t.Fatal(err) + } + if resolved.CertificatePath != first.CertificatePath || resolved.PrivateKeyPath != first.PrivateKeyPath { + t.Fatal("解析后的受控路径与导入结果不一致") + } + + secondKey, secondCertificate := testManagedCertificate(t, "mail.example.com", time.Now().Add(-time.Hour), time.Now().Add(24*time.Hour), 2048) + second, err := ImportManagedSSL(ManagedSSLModeDefault, secondKey, secondCertificate, nil, []string{"mail.example.com"}) + if err != nil { + t.Fatal(err) + } + if second.CertificatePath != first.CertificatePath { + t.Fatal("current 引用路径应保持稳定") + } + currentData, err := os.ReadFile(second.CertificatePath) + if err != nil { + t.Fatal(err) + } + if string(currentData) == string(certificatePEM) { + t.Fatal("current 目录没有切换到新证书") + } + previousMatches := false + entries, err := os.ReadDir(filepath.Dir(filepath.Dir(second.CertificatePath))) + if err != nil { + t.Fatal(err) + } + for _, entry := range entries { + if !strings.HasPrefix(entry.Name(), ".previous-") { + continue + } + previousData, readErr := os.ReadFile(filepath.Join(filepath.Dir(filepath.Dir(second.CertificatePath)), entry.Name(), "public.crt")) + if readErr == nil && string(previousData) == string(certificatePEM) { + previousMatches = true + } + } + if !previousMatches { + t.Fatal("更新后未保留旧证书目录") + } +} + +func TestResolveRuntimeSSLPathsUsesManagedReferences(t *testing.T) { + oldRoot := ROOT_PATH + ROOT_PATH = t.TempDir() + t.Cleanup(func() { ROOT_PATH = oldRoot }) + privateKeyPEM, certificatePEM := testManagedCertificate(t, "mail.example.com", time.Now().Add(-time.Hour), time.Now().Add(24*time.Hour), 2048) + reference, err := ImportManagedSSL(ManagedSSLModeDefault, privateKeyPEM, certificatePEM, nil, []string{"mail.example.com"}) + if err != nil { + t.Fatal(err) + } + cfg := &Config{SSL: SSLConfig{Mode: ManagedSSLModeDefault, CertificateRef: reference.CertificateRef, PrivateKeyRef: reference.PrivateKeyRef}} + certificatePath, privateKeyPath, err := ResolveRuntimeSSLPaths(cfg) + if err != nil { + t.Fatal(err) + } + if certificatePath != reference.CertificatePath || privateKeyPath != reference.PrivateKeyPath { + t.Fatalf("resolved paths = %q, %q", certificatePath, privateKeyPath) + } + if _, err := LoadRuntimeTLSCertificate(cfg); err != nil { + t.Fatal(err) + } +} + +func TestResolveRuntimeSSLPathsRejectsPartialManagedConfiguration(t *testing.T) { + _, _, err := ResolveRuntimeSSLPaths(&Config{SSL: SSLConfig{Mode: ManagedSSLModeDefault, CertificateRef: "config/ssl/managed/default/current/public.crt"}}) + if !errors.Is(err, ErrInvalidSSLReference) { + t.Fatalf("error = %v, want %v", err, ErrInvalidSSLReference) + } +} + +func TestResolveRuntimeSSLPathsValidatesLegacyFiles(t *testing.T) { + oldRoot := ROOT_PATH + ROOT_PATH = t.TempDir() + t.Cleanup(func() { ROOT_PATH = oldRoot }) + privateKeyPEM, certificatePEM := testManagedCertificate(t, "mail.example.com", time.Now().Add(-time.Hour), time.Now().Add(24*time.Hour), 2048) + directory := filepath.Join(t.TempDir(), "legacy-ssl") + if err := os.MkdirAll(directory, 0700); err != nil { + t.Fatal(err) + } + privateKeyPath := filepath.Join(directory, "private.key") + certificatePath := filepath.Join(directory, "public.crt") + if err := os.WriteFile(privateKeyPath, privateKeyPEM, 0600); err != nil { + t.Fatal(err) + } + if err := os.WriteFile(certificatePath, certificatePEM, 0600); err != nil { + t.Fatal(err) + } + resolvedCertificate, resolvedPrivate, err := ResolveRuntimeSSLPaths(&Config{SSLPublicKeyPath: certificatePath, SSLPrivateKeyPath: privateKeyPath}) + if err != nil { + t.Fatal(err) + } + if resolvedCertificate != certificatePath || resolvedPrivate != privateKeyPath { + t.Fatalf("resolved paths = %q, %q", resolvedCertificate, resolvedPrivate) + } +} + +func TestResolveManagedSSLReferencesRejectsUnsafeReferences(t *testing.T) { + oldRoot := ROOT_PATH + ROOT_PATH = t.TempDir() + t.Cleanup(func() { ROOT_PATH = oldRoot }) + privateKeyPEM, certificatePEM := testManagedCertificate(t, "mail.example.com", time.Now().Add(-time.Hour), time.Now().Add(24*time.Hour), 2048) + reference, err := ImportManagedSSL(ManagedSSLModeUpload, privateKeyPEM, certificatePEM, nil, nil) + if err != nil { + t.Fatal(err) + } + unsafe := []SSLConfig{ + {Mode: ManagedSSLModeUpload, CertificateRef: filepath.Join(filepath.Dir(reference.CertificateRef), "..", "public.crt"), PrivateKeyRef: reference.PrivateKeyRef}, + {Mode: ManagedSSLModeUpload, CertificateRef: filepath.Join(t.TempDir(), "public.crt"), PrivateKeyRef: reference.PrivateKeyRef}, + {Mode: ManagedSSLModeUpload, CertificateRef: reference.CertificateRef, PrivateKeyRef: reference.CertificateRef}, + {Mode: ManagedSSLModeUpload, CertificateRef: `C:\outside\public.crt`, PrivateKeyRef: reference.PrivateKeyRef}, + {Mode: ManagedSSLModeUpload, CertificateRef: `\\server\share\public.crt`, PrivateKeyRef: reference.PrivateKeyRef}, + } + for index, candidate := range unsafe { + if _, err := ResolveManagedSSLReferences(candidate); !errors.Is(err, ErrInvalidSSLReference) { + t.Fatalf("用例 %d error = %v, want %v", index, err, ErrInvalidSSLReference) + } + } +} + +func TestResolveManagedSSLReferencesRejectsSymlinkAndBroadPrivatePermissions(t *testing.T) { + if runtime.GOOS == "windows" { + t.Skip("当前测试依赖 Unix 文件权限和符号链接") + } + oldRoot := ROOT_PATH + ROOT_PATH = t.TempDir() + t.Cleanup(func() { ROOT_PATH = oldRoot }) + privateKeyPEM, certificatePEM := testManagedCertificate(t, "mail.example.com", time.Now().Add(-time.Hour), time.Now().Add(24*time.Hour), 2048) + reference, err := ImportManagedSSL(ManagedSSLModeDefault, privateKeyPEM, certificatePEM, nil, nil) + if err != nil { + t.Fatal(err) + } + if err := os.Chmod(reference.PrivateKeyPath, 0640); err != nil { + t.Fatal(err) + } + if _, err := ResolveManagedSSLReferences(SSLConfig{Mode: ManagedSSLModeDefault, CertificateRef: reference.CertificateRef, PrivateKeyRef: reference.PrivateKeyRef}); !errors.Is(err, ErrSSLPrivateKeyPermission) { + t.Fatalf("私钥权限 error = %v, want %v", err, ErrSSLPrivateKeyPermission) + } + if err := os.Chmod(reference.PrivateKeyPath, 0600); err != nil { + t.Fatal(err) + } + outside := filepath.Join(t.TempDir(), "outside.crt") + if err := os.WriteFile(outside, certificatePEM, 0600); err != nil { + t.Fatal(err) + } + if err := os.Remove(reference.CertificatePath); err != nil { + t.Fatal(err) + } + if err := os.Symlink(outside, reference.CertificatePath); err != nil { + t.Skipf("当前环境不支持符号链接测试: %v", err) + } + if _, err := ResolveManagedSSLReferences(SSLConfig{Mode: ManagedSSLModeDefault, CertificateRef: reference.CertificateRef, PrivateKeyRef: reference.PrivateKeyRef}); !errors.Is(err, ErrUnsafeSSLFile) { + t.Fatalf("符号链接 error = %v, want %v", err, ErrUnsafeSSLFile) + } +} + +func TestValidateSSLMaterialRejectsDomainExpiryAndWeakKeys(t *testing.T) { + privateKeyPEM, certificatePEM := testManagedCertificate(t, "mail.example.com", time.Now().Add(-time.Hour), time.Now().Add(24*time.Hour), 2048) + if err := ValidateSSLMaterial(privateKeyPEM, certificatePEM, nil, []string{"other.example.com"}); !errors.Is(err, ErrSSLCertificateDomain) { + t.Fatalf("域名不匹配 error = %v, want %v", err, ErrSSLCertificateDomain) + } + expiredKey, expiredCertificate := testManagedCertificate(t, "mail.example.com", time.Now().Add(-48*time.Hour), time.Now().Add(-time.Hour), 2048) + if err := ValidateSSLMaterial(expiredKey, expiredCertificate, nil, nil); !errors.Is(err, ErrSSLCertificateExpired) { + t.Fatalf("过期证书 error = %v, want %v", err, ErrSSLCertificateExpired) + } + weakKey, weakCertificate := testManagedCertificate(t, "mail.example.com", time.Now().Add(-time.Hour), time.Now().Add(24*time.Hour), 1024) + if err := ValidateSSLMaterial(weakKey, weakCertificate, nil, nil); !errors.Is(err, ErrInvalidSSLMaterial) { + t.Fatalf("弱密钥 error = %v, want %v", err, ErrInvalidSSLMaterial) + } +} + +func testManagedCertificate(t *testing.T, domain string, notBefore, notAfter time.Time, bits int) ([]byte, []byte) { + t.Helper() + key, err := rsa.GenerateKey(rand.Reader, bits) + if err != nil { + t.Fatal(err) + } + template := &x509.Certificate{ + SerialNumber: big.NewInt(time.Now().UnixNano()), + Subject: pkix.Name{CommonName: domain}, + DNSNames: []string{domain}, + NotBefore: notBefore, + NotAfter: notAfter, + BasicConstraintsValid: true, + IsCA: true, + KeyUsage: x509.KeyUsageDigitalSignature | x509.KeyUsageKeyEncipherment | x509.KeyUsageCertSign, + ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth}, + } + der, err := x509.CreateCertificate(rand.Reader, template, template, &key.PublicKey, key) + if err != nil { + t.Fatal(err) + } + return pem.EncodeToMemory(&pem.Block{Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(key)}), pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: der}) +} diff --git a/server/config/transaction.go b/server/config/transaction.go index abe105cf..eff9138f 100644 --- a/server/config/transaction.go +++ b/server/config/transaction.go @@ -281,6 +281,22 @@ func persistRuntimeConfig(root string, current, candidate RuntimeConfig) error { } func marshalRuntimeFiles(runtime RuntimeConfig) (map[string][]byte, error) { + return marshalRuntimeFilesWithPluginSecrets(runtime, false) +} + +type persistedPluginInstance struct { + Enabled bool `json:"enabled"` + Executable string `json:"executable"` + Permissions PluginPermissions `json:"permissions"` + Settings json.RawMessage `json:"settings,omitempty"` +} + +type persistedPluginsSection struct { + Meta SectionMeta `json:"meta"` + Plugins map[string]persistedPluginInstance `json:"plugins"` +} + +func marshalRuntimeFilesWithPluginSecrets(runtime RuntimeConfig, keepPluginSecrets bool) (map[string][]byte, error) { runtime = cloneRuntimeConfig(runtime) runtime.Root.Generation = runtime.Generation runtime.Root.SetupState = runtime.SetupState @@ -299,7 +315,21 @@ func marshalRuntimeFiles(runtime RuntimeConfig) (map[string][]byte, error) { case SectionSSL: value = runtime.SSL case SectionPlugins: - value = runtime.Plugins + if keepPluginSecrets { + value = runtime.Plugins + break + } + plugins := persistedPluginsSection{ + Meta: runtime.Plugins.Meta, + Plugins: make(map[string]persistedPluginInstance, len(runtime.Plugins.Plugins)), + } + for logicalID, plugin := range runtime.Plugins.Plugins { + plugins.Plugins[logicalID] = persistedPluginInstance{ + Enabled: plugin.Enabled, Executable: plugin.Executable, + Permissions: plugin.Permissions, Settings: plugin.Settings, + } + } + value = plugins default: return nil, ErrInvalidSection } diff --git a/server/config/validator.go b/server/config/validator.go index 46db5daa..44a4b270 100644 --- a/server/config/validator.go +++ b/server/config/validator.go @@ -1,4 +1,4 @@ -package config +package config import ( "errors" @@ -167,11 +167,11 @@ func validateSSL(ssl SSLConfig) error { } activeDirectory := ssl.DefaultDirectory switch ssl.Mode { - case "default": - if ssl.DefaultDirectory == "" { + case ManagedSSLModeDefault, "default": + if ssl.DefaultDirectory == "" || ssl.CustomDirectory != "" { return ErrInvalidSSL } - case "custom": + case ManagedSSLModeUpload, "custom": if !isControlledRelativePath(ssl.CustomDirectory) || ssl.CustomDirectory == "" { return ErrInvalidSSL } diff --git a/server/controllers/setup.go b/server/controllers/setup.go index f898df76..5166b96a 100644 --- a/server/controllers/setup.go +++ b/server/controllers/setup.go @@ -40,13 +40,18 @@ func AcmeChallenge(w http.ResponseWriter, r *http.Request) { } type sslResponse struct { - Port int `json:"port"` - Type string `json:"type"` + Port int `json:"port"` + Type string `json:"type"` + Ready bool `json:"ready"` } func writeSetupError(ctx *context.Context, w http.ResponseWriter, err error) { log.WithContext(ctx).WithError(err).Error("setup request failed") - response.NewErrorResponse(response.ServerError, "\u521d\u59cb\u5316\u64cd\u4f5c\u5931\u8d25", "").FPrint(w) + message := setup.DatabaseSetupErrorMessage(err) + if message == "" { + message = "\u521d\u59cb\u5316\u64cd\u4f5c\u5931\u8d25" + } + response.NewErrorResponse(response.ServerError, message, "").FPrint(w) } func Setup(ctx *context.Context, w http.ResponseWriter, req *http.Request) { @@ -67,21 +72,27 @@ func Setup(ctx *context.Context, w http.ResponseWriter, req *http.Request) { } if reqData["step"] == "database" && reqData["action"] == "get" { - dbType, dbDSN, err := setup.GetDatabaseSettings(ctx) + settings, err := setup.GetDatabaseSettingsDetail(ctx) if err != nil { writeSetupError(ctx, w, err) return } - response.NewSuccessResponse(map[string]string{ - "db_type": dbType, - "db_dsn": dbDSN, - }).FPrint(w) + response.NewSuccessResponse(settings).FPrint(w) return } if reqData["step"] == "database" && reqData["action"] == "set" { - err := setup.SetDatabaseSettings(ctx, cast.ToString(reqData["db_type"]), cast.ToString(reqData["db_dsn"])) + err := setup.SetDatabaseSettingsWithOptions(ctx, setup.DatabaseSettings{ + Type: cast.ToString(reqData["db_type"]), + DSN: cast.ToString(reqData["db_dsn"]), + Mode: cast.ToString(reqData["db_mode"]), + User: cast.ToString(reqData["db_user"]), + Host: cast.ToString(reqData["db_host"]), + Port: cast.ToString(reqData["db_port"]), + Password: cast.ToString(reqData["db_password"]), + Name: cast.ToString(reqData["db_name"]), + }) if err != nil { writeSetupError(ctx, w, err) return @@ -152,8 +163,9 @@ func Setup(ctx *context.Context, w http.ResponseWriter, req *http.Request) { return } res := sslResponse{ - Type: sslType, - Port: config.CurrentConfig().GetSetupPort(), + Type: sslType, + Port: config.CurrentConfig().GetSetupPort(), + Ready: config.IsSetupReady(), } response.NewSuccessResponse(res).FPrint(w) return diff --git a/server/db/init_migration_test.go b/server/db/init_migration_test.go index 1f1e601b..2d5522e8 100644 --- a/server/db/init_migration_test.go +++ b/server/db/init_migration_test.go @@ -30,15 +30,15 @@ func TestInitAppliesSchemaMigration(t *testing.T) { if err != nil { t.Fatal(err) } - if version != 10 { - t.Fatalf("schema version = %d, want 10", version) + if version != 11 { + t.Fatalf("schema version = %d, want 11", version) } var count int if _, err = Instance.SQL("SELECT count(*) FROM schema_migration").Get(&count); err != nil { t.Fatal(err) } - if count != 10 { - t.Fatalf("schema migration rows = %d, want 10", count) + if count != 11 { + t.Fatalf("schema migration rows = %d, want 11", count) } } diff --git a/server/db/migration/registry.go b/server/db/migration/registry.go index 1d22f7a8..93e17772 100644 --- a/server/db/migration/registry.go +++ b/server/db/migration/registry.go @@ -5,7 +5,6 @@ func DefaultMigrations() []Migration { DefineForDialects(1, "create_core_schema", coreSchemaStatements()), DefineCustom(2, "expand_user_security", "expand_user_security_v1", applyUserSecuritySchema), DefineForDialects(3, "create_security_email_tables", securityEmailStatements()), - DefineForDialects(4, "create_account_recovery_tables", credentialStatements()), DefineForDialects(5, "create_verification_operations_tables", verificationOperationsStatements()), DefineCustom(6, "expand_verification_retention", "expand_verification_retention_v1", applyVerificationRetentionSchema), @@ -13,5 +12,6 @@ func DefaultMigrations() []Migration { DefineCustom(8, "mark_webauthn_discoverability", "mark_webauthn_discoverability_v1", applyWebAuthnDiscoverabilitySchema), DefineForDialects(9, "create_totp_authenticator", totpAuthenticatorStatements()), DefineCustom(10, "expand_user_lifecycle_security", "expand_user_lifecycle_security_v1", applyUserLifecycleSchema), + DefineForDialects(11, "create_plugin_configuration_tables", pluginSettingsStatements()), } } diff --git a/server/db/migration/registry_test.go b/server/db/migration/registry_test.go index bc7d06ee..47379abc 100644 --- a/server/db/migration/registry_test.go +++ b/server/db/migration/registry_test.go @@ -13,11 +13,11 @@ func TestDefaultMigrationsCreateCompleteSQLiteSchema(t *testing.T) { if err != nil { t.Fatal(err) } - if report.CurrentVersion != 10 || len(report.Applied) != 10 { + if report.CurrentVersion != 11 || len(report.Applied) != 11 { t.Fatalf("report = %+v", report) } - for _, table := range []string{"user", "email", "group", "rule", "sessions", "user_email", "version", "external_email", "verification_event", "security_question", "recovery_code", "verification_rate_limit", "verification_cleanup_state", "webauthn_credential", "totp_authenticator", "schema_migration"} { + for _, table := range []string{"user", "email", "group", "rule", "sessions", "user_email", "version", "external_email", "verification_event", "security_question", "recovery_code", "verification_rate_limit", "verification_cleanup_state", "webauthn_credential", "totp_authenticator", "plugin_secret", "plugin_user_setting", "schema_migration"} { if !sqliteTableExists(t, db, table) { t.Fatalf("table %s was not created", table) } diff --git a/server/db/migration/schema.go b/server/db/migration/schema.go index 411a654c..6e069537 100644 --- a/server/db/migration/schema.go +++ b/server/db/migration/schema.go @@ -264,3 +264,22 @@ func webAuthnCredentialStatements() map[Dialect][]string { }, } } + +func pluginSettingsStatements() map[Dialect][]string { + return map[Dialect][]string{ + DialectSQLite: { + `CREATE TABLE IF NOT EXISTS "plugin_secret" ("id" INTEGER PRIMARY KEY AUTOINCREMENT, "plugin_id" TEXT NOT NULL, "field_name" TEXT NOT NULL, "ciphertext" TEXT NOT NULL, "key_version" INTEGER NOT NULL, "record_version" INTEGER NOT NULL DEFAULT 1, "created_at" DATETIME NOT NULL, "updated_at" DATETIME NOT NULL, UNIQUE("plugin_id", "field_name"))`, + `CREATE TABLE IF NOT EXISTS "plugin_user_setting" ("id" INTEGER PRIMARY KEY AUTOINCREMENT, "plugin_id" TEXT NOT NULL, "user_id" INTEGER NOT NULL, "schema_version" INTEGER NOT NULL, "settings_ciphertext" TEXT NOT NULL, "settings_hash" TEXT NOT NULL, "enabled" INTEGER NOT NULL DEFAULT 1, "version" INTEGER NOT NULL DEFAULT 1, "created_at" DATETIME NOT NULL, "updated_at" DATETIME NOT NULL, UNIQUE("plugin_id", "user_id"))`, + `CREATE INDEX IF NOT EXISTS "idx_plugin_user_setting_user_id" ON "plugin_user_setting"("user_id")`, + }, + DialectMySQL: { + "CREATE TABLE IF NOT EXISTS `plugin_secret` (`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, `plugin_id` VARCHAR(64) NOT NULL, `field_name` VARCHAR(64) NOT NULL, `ciphertext` TEXT NOT NULL, `key_version` INT UNSIGNED NOT NULL, `record_version` BIGINT UNSIGNED NOT NULL DEFAULT 1, `created_at` DATETIME(6) NOT NULL, `updated_at` DATETIME(6) NOT NULL, UNIQUE KEY `uq_plugin_secret_field` (`plugin_id`, `field_name`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", + "CREATE TABLE IF NOT EXISTS `plugin_user_setting` (`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, `plugin_id` VARCHAR(64) NOT NULL, `user_id` BIGINT NOT NULL, `schema_version` INT UNSIGNED NOT NULL, `settings_ciphertext` TEXT NOT NULL, `settings_hash` VARCHAR(128) NOT NULL, `enabled` TINYINT NOT NULL DEFAULT 1, `version` BIGINT UNSIGNED NOT NULL DEFAULT 1, `created_at` DATETIME(6) NOT NULL, `updated_at` DATETIME(6) NOT NULL, UNIQUE KEY `uq_plugin_user_setting_owner` (`plugin_id`, `user_id`), KEY `idx_plugin_user_setting_user_id` (`user_id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", + }, + DialectPostgres: { + `CREATE TABLE IF NOT EXISTS "plugin_secret" ("id" BIGSERIAL PRIMARY KEY, "plugin_id" VARCHAR(64) NOT NULL, "field_name" VARCHAR(64) NOT NULL, "ciphertext" TEXT NOT NULL, "key_version" INTEGER NOT NULL, "record_version" BIGINT NOT NULL DEFAULT 1, "created_at" TIMESTAMPTZ NOT NULL, "updated_at" TIMESTAMPTZ NOT NULL, UNIQUE("plugin_id", "field_name"))`, + `CREATE TABLE IF NOT EXISTS "plugin_user_setting" ("id" BIGSERIAL PRIMARY KEY, "plugin_id" VARCHAR(64) NOT NULL, "user_id" BIGINT NOT NULL, "schema_version" INTEGER NOT NULL, "settings_ciphertext" TEXT NOT NULL, "settings_hash" VARCHAR(128) NOT NULL, "enabled" BOOLEAN NOT NULL DEFAULT TRUE, "version" BIGINT NOT NULL DEFAULT 1, "created_at" TIMESTAMPTZ NOT NULL, "updated_at" TIMESTAMPTZ NOT NULL, UNIQUE("plugin_id", "user_id"))`, + `CREATE INDEX IF NOT EXISTS "idx_plugin_user_setting_user_id" ON "plugin_user_setting"("user_id")`, + }, + } +} diff --git a/server/hooks/base.go b/server/hooks/base.go index b852c568..050f5f5a 100644 --- a/server/hooks/base.go +++ b/server/hooks/base.go @@ -12,6 +12,7 @@ import ( "git.pcux.cn/xuans/Smail/dto/parsemail" "git.pcux.cn/xuans/Smail/hooks/framework" "git.pcux.cn/xuans/Smail/models" + pluginservice "git.pcux.cn/xuans/Smail/services/plugin" "git.pcux.cn/xuans/Smail/utils/atomicfile" "git.pcux.cn/xuans/Smail/utils/context" log "github.com/sirupsen/logrus" @@ -30,9 +31,17 @@ import ( var HookList map[string]framework.EmailHook type HookSender struct { - httpc http.Client - name string - socket string + httpc http.Client + name string + executable string + socket string + authToken string +} + +var pluginConfigService *pluginservice.ConfigService + +func SetPluginConfigService(service *pluginservice.ConfigService) { + pluginConfigService = service } const ( @@ -64,6 +73,9 @@ func (h *HookSender) callWithResponseLimit(endpoint string, payload any, maxResp return nil, err } req.Header.Set("Content-Type", "application/json") + if h.authToken != "" { + req.Header.Set("X-Smail-Plugin-Token", h.authToken) + } ret, err := h.httpc.Do(req) if err != nil { return nil, err @@ -130,6 +142,42 @@ func (h *HookSender) ReceiveParseAfter(ctx *context.Context, email *parsemail.Em } } +func (h *HookSender) Capabilities() (framework.Capabilities, error) { + body, err := h.call("Capabilities", struct{}{}) + if err != nil { + return framework.Capabilities{}, err + } + var capabilities framework.Capabilities + if err := json.Unmarshal(body, &capabilities); err != nil { + return framework.Capabilities{}, err + } + return capabilities, nil +} + +func (h *HookSender) Health() error { + body, err := h.call("Health", struct{}{}) + if err != nil { + return err + } + var response struct { + Status string `json:"status"` + } + if err := json.Unmarshal(body, &response); err != nil || response.Status != "ok" { + return errors.New("plugin health check returned an invalid status") + } + return nil +} + +func (h *HookSender) ValidateConfig(payload framework.PluginRuntimeConfig) error { + _, err := h.call("ValidateConfig", payload) + return err +} + +func (h *HookSender) Configure(payload framework.PluginRuntimeConfig) error { + _, err := h.call("Configure", payload) + return err +} + func (h *HookSender) GetName(ctx *context.Context) string { body, err := h.call("GetName", framework.HookDTO{Ctx: ctx}) if err != nil { @@ -152,7 +200,7 @@ func (h *HookSender) SettingsHtml(ctx *context.Context, url string, requestData return string(body) } -func NewHookSender(socketPath string, name string, serverVersion string) *HookSender { +func NewHookSender(socketPath string, name string, serverVersion string, authToken ...string) *HookSender { httpc := http.Client{ Timeout: time.Second * 10, Transport: &http.Transport{ @@ -161,10 +209,15 @@ func NewHookSender(socketPath string, name string, serverVersion string) *HookSe }, }, } + token := "" + if len(authToken) > 0 { + token = authToken[0] + } return &HookSender{ - httpc: httpc, - socket: socketPath, - name: name, + httpc: httpc, + socket: socketPath, + name: name, + authToken: token, } } @@ -183,8 +236,12 @@ func Init(serverVersion string) { return } - allowedPlugins := pluginAllowList(cfg.PluginAllowList) - if len(allowedPlugins) == 0 { + definitions, err := pluginDefinitionsForStartup(cfg) + if err != nil { + log.Warn("Plugin loading is disabled because the configured plugin target is invalid") + return + } + if len(definitions) == 0 { log.Info("Plugin loading is disabled because the allow list is empty") return } @@ -199,59 +256,60 @@ func Init(serverVersion string) { return } - entries, err := os.ReadDir(root) - if err != nil { - log.Error("Plugin directory cannot be read") - return - } - pluginNo := 1 - for _, entry := range entries { - name := entry.Name() - if !allowedPlugins[name] || entry.Type()&os.ModeSymlink != 0 { + for _, definition := range definitions { + logicalID := definition.LogicalID + executableName, executableErr := pluginservice.ExecutableName(logicalID, runtime.GOOS) + if executableErr != nil { + log.Warnf("[%s] Plugin executable mapping is unavailable", logicalID) continue } - info, err := entry.Info() - if err != nil || !info.Mode().IsRegular() || !isPluginExecutable(name, info.Mode()) || !securePluginFile(info.Mode()) || !securePluginFileOwner(info) { - log.Warnf("[%s] Plugin file was rejected", name) + pluginPath := filepath.Join(root, executableName) + info, statErr := os.Lstat(pluginPath) + if statErr != nil || info.Mode()&os.ModeSymlink != 0 || !info.Mode().IsRegular() || !isPluginExecutable(executableName, info.Mode()) || !securePluginFile(info.Mode()) || !securePluginFileOwner(info) { + log.Warnf("[%s] Plugin file was rejected", logicalID) continue } - - pluginPath := filepath.Join(root, name) - socketName, err := newPluginSocketName(pluginNo) - if err != nil { - log.Warnf("[%s] Plugin socket name generation failed", name) + socketName, socketErr := newPluginSocketName(pluginNo) + if socketErr != nil { + log.Warnf("[%s] Plugin socket name generation failed", logicalID) continue } - env := pluginEnvironment(root, name) - launchSpec, err := newPluginLaunchSpec(pluginPath, root, name, socketName, env) - if err != nil { + authToken, tokenErr := newPluginAuthToken() + if tokenErr != nil { + log.Warnf("[%s] Plugin authentication material generation failed", logicalID) + continue + } + env := pluginEnvironment(root, logicalID) + env = appendPluginEnv(env, "SMAIL_PLUGIN_RPC_TOKEN", authToken) + launchSpec, launchErr := newPluginLaunchSpec(pluginPath, root, executableName, socketName, env) + if launchErr != nil { if !config.DevelopmentMode { - log.Warnf("[%s] Plugin rejected because secure process isolation is unavailable: %v", name, err) + log.Warnf("[%s] Plugin rejected because secure process isolation is unavailable: %v", logicalID, launchErr) continue } - log.Warnf("[%s] Secure process isolation is unavailable in development mode: %v", name, err) - launchSpec = compatibilityPluginLaunchSpec(pluginPath, root, name, socketName, env) + log.Warnf("[%s] Secure process isolation is unavailable in development mode: %v", logicalID, launchErr) + launchSpec = compatibilityPluginLaunchSpec(pluginPath, root, executableName, socketName, env) } socketPath := launchSpec.socketPath if !isAbstractPluginSocket(socketPath) { - if err := os.Remove(socketPath); err != nil && !os.IsNotExist(err) { - log.Warnf("[%s] Plugin socket cleanup failed", name) + if removeErr := os.Remove(socketPath); removeErr != nil && !os.IsNotExist(removeErr) { + log.Warnf("[%s] Plugin socket cleanup failed", logicalID) launchSpec.cleanup() continue } } - log.Infof("[%s] Plugin load", name) - process, err := os.StartProcess(launchSpec.path, launchSpec.args, launchSpec.procAttr) - if err != nil { - log.Warnf("[%s] Plugin start failed", name) + log.Infof("[%s] Plugin load", logicalID) + process, startErr := os.StartProcess(launchSpec.path, launchSpec.args, launchSpec.procAttr) + if startErr != nil { + log.Warnf("[%s] Plugin start failed", logicalID) launchSpec.cleanup() continue } launchSpec.closeParentFiles() - if err := applyPluginResourceLimits(process); err != nil { - log.Warnf("[%s] Plugin resource limits could not be applied", name) + if limitErr := applyPluginResourceLimits(process); limitErr != nil { + log.Warnf("[%s] Plugin resource limits could not be applied", logicalID) _ = process.Kill() _, _ = process.Wait() launchSpec.cleanup() @@ -262,25 +320,46 @@ func Init(serverVersion string) { processListMu.Unlock() pluginNo++ - go waitPlugin(process, name, socketPath, launchSpec) + go waitPlugin(process, logicalID, socketPath, launchSpec) if !waitPluginSocket(socketPath) { - log.Warnf("[%s] Plugin socket was not created", name) + log.Warnf("[%s] Plugin socket was not created", logicalID) _ = process.Kill() continue } if runtime.GOOS != "windows" && !isAbstractPluginSocket(socketPath) { - if err := os.Chmod(socketPath, 0600); err != nil { - log.Warnf("[%s] Plugin socket permissions could not be tightened", name) + if chmodErr := os.Chmod(socketPath, 0600); chmodErr != nil { + log.Warnf("[%s] Plugin socket permissions could not be tightened", logicalID) _ = process.Kill() continue } } - hook := NewHookSender(socketPath, name, serverVersion) + hook := NewHookSender(socketPath, logicalID, serverVersion, authToken) + hook.executable = executableName + capabilities, capabilityErr := hook.Capabilities() + if capabilityErr != nil || !pluginCapabilitiesMatch(definition, capabilities) { + log.Warnf("[%s] Plugin capability handshake failed", logicalID) + _ = process.Kill() + continue + } + if instance, generation, ok := pluginInstanceForStartup(logicalID); ok { + payload, payloadErr := pluginRuntimeConfig(logicalID, generation, instance) + if payloadErr != nil || hook.ValidateConfig(payload) != nil || hook.Configure(payload) != nil { + log.Warnf("[%s] Plugin runtime configuration failed", logicalID) + _ = process.Kill() + continue + } + } + if healthErr := hook.Health(); healthErr != nil { + log.Warnf("[%s] Plugin health check failed", logicalID) + _ = process.Kill() + continue + } + hookName := strings.TrimSpace(hook.GetName(&context.Context{})) if hookName == "" || !RegisterHook(hookName, hook) { - log.Warnf("[%s] Plugin reported an invalid hook name", name) + log.Warnf("[%s] Plugin reported an invalid hook name", logicalID) _ = process.Kill() continue } @@ -288,6 +367,122 @@ func Init(serverVersion string) { } } +func pluginInstanceForStartup(logicalID string) (config.PluginInstance, uint64, bool) { + manager := config.CurrentManager() + if manager == nil { + return config.PluginInstance{}, 0, false + } + snapshot := manager.Snapshot() + instance, ok := snapshot.Plugins.Plugins[logicalID] + return instance, snapshot.Generation, ok +} + +func pluginRuntimeConfig(logicalID string, generation uint64, instance config.PluginInstance) (framework.PluginRuntimeConfig, error) { + if err := validatePluginRuntimeBinding(logicalID, instance); err != nil { + return framework.PluginRuntimeConfig{}, err + } + if generation == 0 { + return framework.PluginRuntimeConfig{}, errors.New("plugin configuration generation is invalid") + } + result := framework.PluginRuntimeConfig{ + PluginID: logicalID, + Generation: generation, + Settings: append(json.RawMessage(nil), instance.Settings...), + Capabilities: append([]string(nil), instance.Permissions.Capabilities...), + Network: make([]framework.PluginNetworkTarget, 0, len(instance.Permissions.Network)), + Secrets: make(map[string]string), + } + for _, target := range instance.Permissions.Network { + result.Network = append(result.Network, framework.PluginNetworkTarget{Scheme: target.Scheme, Host: target.Host, Port: target.Port}) + } + if pluginConfigService == nil { + if instance.Secret.Configured() { + return framework.PluginRuntimeConfig{}, errors.New("plugin secret service is unavailable") + } + return result, nil + } + fieldName := "" + switch logicalID { + case "wechat_push": + fieldName = "appSecret" + case "telegram_push": + fieldName = "botToken" + } + if fieldName != "" { + secret, err := pluginConfigService.OpenSecretForPlugin(logicalID, fieldName) + if err != nil { + return framework.PluginRuntimeConfig{}, err + } + result.Secrets[fieldName] = secret + } + return result, nil +} + +// validatePluginRuntimeBinding 在启动插件前再次校验配置与插件目录声明一致。 +// 该校验不能替代 ConfigManager 的完整校验,只用于阻止错误或过期快照被下发。 +func validatePluginRuntimeBinding(logicalID string, instance config.PluginInstance) error { + if !instance.Enabled { + return errors.New("plugin is disabled") + } + definition, ok := pluginservice.Lookup(logicalID) + if !ok { + return pluginservice.ErrUnknownPluginID + } + if !sameStringSet(instance.Permissions.Capabilities, definition.Capabilities) { + return errors.New("plugin capabilities do not match catalog") + } + if instance.Secret.Ciphertext != "" || instance.Secret.Version != 0 || !instance.Secret.UpdatedAt.IsZero() { + return errors.New("legacy plugin secret migration is required") + } + return nil +} + +func pluginCapabilitiesMatch(definition pluginservice.Definition, capabilities framework.Capabilities) bool { + return capabilities.PluginID == definition.LogicalID && + capabilities.Protocol == 1 && + sameStringSet(capabilities.Capabilities, definition.HandshakeCapabilities) && + sameStringSet(capabilities.Settings, definition.SettingsFields) +} + +func sameStringSet(left, right []string) bool { + if len(left) != len(right) { + return false + } + values := make(map[string]struct{}, len(left)) + for _, value := range left { + if _, exists := values[value]; exists { + return false + } + values[value] = struct{}{} + } + for _, value := range right { + if _, exists := values[value]; !exists { + return false + } + } + return true +} + +func pluginDefinitionsForStartup(legacy *config.Config) ([]pluginservice.Definition, error) { + if manager := config.CurrentManager(); manager != nil { + return pluginDefinitionsFromRuntime(manager.Snapshot()) + } + if legacy == nil { + return nil, errors.New("plugin configuration is unavailable") + } + return pluginservice.EnabledDefinitions(legacy.PluginAllowList, runtime.GOOS) +} + +func pluginDefinitionsFromRuntime(runtimeConfig config.RuntimeConfig) ([]pluginservice.Definition, error) { + values := make([]string, 0, len(runtimeConfig.Plugins.Plugins)) + for logicalID, instance := range runtimeConfig.Plugins.Plugins { + if instance.Enabled { + values = append(values, logicalID) + } + } + return pluginservice.EnabledDefinitions(values, runtime.GOOS) +} + func pluginAllowList(values []string) map[string]bool { allowed := make(map[string]bool, len(values)) for _, value := range values { @@ -354,6 +549,14 @@ func waitPlugin(process *os.Process, name string, socketPath string, launchSpec launchSpec.cleanup() } +func newPluginAuthToken() (string, error) { + token := make([]byte, 32) + if _, err := rand.Read(token); err != nil { + return "", err + } + return hex.EncodeToString(token), nil +} + func newPluginSocketName(pluginNo int) (string, error) { token := make([]byte, 16) if _, err := rand.Read(token); err != nil { @@ -379,14 +582,16 @@ func minimalPluginEnv(root string) []string { func pluginEnvironment(root, name string) []string { ret := minimalPluginEnv(root) + if config.CurrentManager() != nil { + return ret + } cfg := config.CurrentConfig() if cfg == nil { return ret } - pluginName := strings.TrimSuffix(strings.ToLower(name), filepath.Ext(name)) + pluginName := strings.ToLower(strings.TrimSpace(name)) if pluginName == "wechat_push" { ret = appendPluginEnv(ret, "SMAIL_WECHAT_APP_ID", cfg.WeChatPushAppId) - ret = appendPluginEnv(ret, "SMAIL_WECHAT_SECRET", cfg.WeChatPushSecret) ret = appendPluginEnv(ret, "SMAIL_WECHAT_TEMPLATE_ID", cfg.WeChatPushTemplateId) ret = appendPluginEnv(ret, "SMAIL_WECHAT_USER_ID", cfg.WeChatPushUserId) ret = appendPluginEnv(ret, "SMAIL_WEB_DOMAIN", cfg.WebDomain) @@ -418,7 +623,11 @@ func PersistPluginConfig(pluginName, payload string) error { if err != nil || !securePluginDirectory(root) || !securePluginDirectoryOwner(root) { return errors.New("plugin directory is unsafe") } - configPath := filepath.Join(root, pluginConfigFileName(sender.name)) + executableName := sender.executable + if executableName == "" { + executableName = sender.name + } + configPath := filepath.Join(root, pluginConfigFileName(executableName)) info, err := os.Lstat(configPath) if err == nil && info.Mode()&os.ModeSymlink != 0 { return errors.New("plugin configuration path is unsafe") diff --git a/server/hooks/base_test.go b/server/hooks/base_test.go index f78c6701..2574b386 100644 --- a/server/hooks/base_test.go +++ b/server/hooks/base_test.go @@ -1,11 +1,21 @@ package hooks import ( + "context" + "encoding/json" + "git.pcux.cn/xuans/Smail/config" + "git.pcux.cn/xuans/Smail/db/migration" + "git.pcux.cn/xuans/Smail/hooks/framework" + pluginservice "git.pcux.cn/xuans/Smail/services/plugin" + "git.pcux.cn/xuans/Smail/utils/credential" + _ "modernc.org/sqlite" "os" "path/filepath" "runtime" "strings" "testing" + "time" + "xorm.io/xorm" ) func TestPluginAllowListRejectsUnsafeNames(t *testing.T) { @@ -120,3 +130,221 @@ func TestRegisterHookRejectsUnsafeNames(t *testing.T) { t.Fatal("safe hook name was rejected") } } + +func TestPluginDefinitionsFromRuntimeUsesEnabledLogicalIDs(t *testing.T) { + runtimeConfig := config.RuntimeConfig{ + Plugins: config.PluginsSectionConfig{Plugins: map[string]config.PluginInstance{ + "spam_block": {Enabled: true}, + "telegram_push": {Enabled: false}, + }}, + } + definitions, err := pluginDefinitionsFromRuntime(runtimeConfig) + if err != nil { + t.Fatal(err) + } + if len(definitions) != 1 || definitions[0].LogicalID != "spam_block" { + t.Fatalf("definitions = %+v", definitions) + } +} + +func TestPluginRuntimeConfigRejectsStaleOrEscalatedBinding(t *testing.T) { + base := config.PluginInstance{ + Enabled: true, + Permissions: config.PluginPermissions{ + Capabilities: []string{"network"}, + Network: []config.PluginNetworkTarget{{Scheme: "https", Host: "api.telegram.org", Port: 443}}, + }, + } + tests := []struct { + name string + mutate func(*config.PluginInstance) + }{ + {name: "disabled", mutate: func(instance *config.PluginInstance) { instance.Enabled = false }}, + {name: "extra capability", mutate: func(instance *config.PluginInstance) { + instance.Permissions.Capabilities = append(instance.Permissions.Capabilities, "filesystem") + }}, + {name: "legacy secret", mutate: func(instance *config.PluginInstance) { + instance.Secret.Ciphertext = "encrypted" + instance.Secret.Version = 1 + instance.Secret.UpdatedAt = time.Now() + }}, + } + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + instance := base + test.mutate(&instance) + if _, err := pluginRuntimeConfig("telegram_push", 1, instance); err == nil { + t.Fatal("unsafe plugin binding was accepted") + } + }) + } +} + +func TestPluginRuntimeConfigBuildsOnlyCatalogCapabilities(t *testing.T) { + instance := config.PluginInstance{ + Enabled: true, + Settings: json.RawMessage(`{"timeout":10}`), + Permissions: config.PluginPermissions{ + Capabilities: []string{"network"}, + Network: []config.PluginNetworkTarget{{Scheme: "https", Host: "api.telegram.org", Port: 443}}, + }, + } + payload, err := pluginRuntimeConfig("telegram_push", 7, instance) + if err != nil { + t.Fatal(err) + } + if payload.PluginID != "telegram_push" || payload.Generation != 7 || len(payload.Capabilities) != 1 || payload.Capabilities[0] != "network" { + t.Fatalf("unexpected capabilities: %+v", payload.Capabilities) + } + if len(payload.Network) != 1 || payload.Network[0] != (framework.PluginNetworkTarget{Scheme: "https", Host: "api.telegram.org", Port: 443}) { + t.Fatalf("unexpected network targets: %+v", payload.Network) + } + if string(payload.Settings) != `{"timeout":10}` { + t.Fatalf("unexpected settings: %s", payload.Settings) + } +} + +func TestPluginRuntimeConfigRejectsMissingGeneration(t *testing.T) { + instance := config.PluginInstance{ + Enabled: true, + Permissions: config.PluginPermissions{ + Capabilities: []string{"network"}, + }, + } + if _, err := pluginRuntimeConfig("spam_block", 0, instance); err == nil { + t.Fatal("zero plugin configuration generation was accepted") + } +} + +func TestPluginRuntimeConfigIsolatesPluginSecrets(t *testing.T) { + service, engine := newHookPluginConfigService(t) + _ = engine + previous := pluginConfigService + SetPluginConfigService(service) + t.Cleanup(func() { SetPluginConfigService(previous) }) + + for _, entry := range []struct { + pluginID string + field string + value string + }{ + {pluginID: "wechat_push", field: "appSecret", value: "wechat-secret-for-test"}, + {pluginID: "telegram_push", field: "botToken", value: "telegram-secret-for-test"}, + } { + if _, err := service.ChangeSecret(entry.pluginID, entry.field, config.SecretChange{ + Operation: config.SecretReplace, + Value: &config.SecretInput{Plaintext: entry.value}, + }, 0); err != nil { + t.Fatal(err) + } + } + + wechat, err := pluginRuntimeConfig("wechat_push", 3, config.PluginInstance{ + Enabled: true, + Settings: json.RawMessage(`{"appId":"app-id","templateId":"template-id","userId":"user-id","webDomain":"mail.example.com"}`), + Permissions: config.PluginPermissions{ + Capabilities: []string{"network"}, + Network: []config.PluginNetworkTarget{{Scheme: "https", Host: "api.weixin.qq.com", Port: 443}}, + }, + }) + if err != nil { + t.Fatal(err) + } + if len(wechat.Secrets) != 1 || wechat.Secrets["appSecret"] != "wechat-secret-for-test" { + t.Fatalf("unexpected WeChat secrets: %#v", wechat.Secrets) + } + if _, exists := wechat.Secrets["botToken"]; exists { + t.Fatal("Telegram secret was included in WeChat runtime configuration") + } + wechatData, err := json.Marshal(wechat) + if err != nil { + t.Fatal(err) + } + if strings.Contains(string(wechatData), "telegram-secret-for-test") { + t.Fatal("Telegram secret appeared in WeChat runtime configuration") + } + + telegram, err := pluginRuntimeConfig("telegram_push", 4, config.PluginInstance{ + Enabled: true, + Settings: json.RawMessage(`{"timeout":10}`), + Permissions: config.PluginPermissions{ + Capabilities: []string{"network"}, + Network: []config.PluginNetworkTarget{{Scheme: "https", Host: "api.telegram.org", Port: 443}}, + }, + }) + if err != nil { + t.Fatal(err) + } + if len(telegram.Secrets) != 1 || telegram.Secrets["botToken"] != "telegram-secret-for-test" { + t.Fatalf("unexpected Telegram secrets: %#v", telegram.Secrets) + } + if _, exists := telegram.Secrets["appSecret"]; exists { + t.Fatal("WeChat secret was included in Telegram runtime configuration") + } + telegramData, err := json.Marshal(telegram) + if err != nil { + t.Fatal(err) + } + if strings.Contains(string(telegramData), "wechat-secret-for-test") { + t.Fatal("WeChat secret appeared in Telegram runtime configuration") + } +} + +func TestPluginCapabilitiesMatchCatalogStrictly(t *testing.T) { + definition, ok := pluginservice.Lookup("telegram_push") + if !ok { + t.Fatal("telegram plugin definition is missing") + } + valid := framework.Capabilities{ + PluginID: "telegram_push", + Capabilities: []string{"network", "userSettings", "settingsHtml"}, + Settings: []string{"proxy", "timeout", "debug", "webDomain", "httpsEnabled"}, + Protocol: 1, + } + if !pluginCapabilitiesMatch(definition, valid) { + t.Fatal("valid plugin capability handshake was rejected") + } + valid.Capabilities[0] = "filesystem" + if pluginCapabilitiesMatch(definition, valid) { + t.Fatal("unexpected plugin capability was accepted") + } +} + +func newHookPluginConfigService(t *testing.T) (*pluginservice.ConfigService, *xorm.Engine) { + t.Helper() + engine, err := xorm.NewEngine("sqlite", filepath.Join(t.TempDir(), "hook-plugin-config.db")) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { _ = engine.Close() }) + runner := migration.Runner{DB: engine.DB().DB, Dialect: migration.DialectSQLite, Migrations: migration.DefaultMigrations()} + if _, err = runner.Run(context.Background()); err != nil { + t.Fatal(err) + } + vault, err := credential.NewVault(t.TempDir()) + if err != nil { + t.Fatal(err) + } + service, err := pluginservice.NewConfigService(engine, vault) + if err != nil { + t.Fatal(err) + } + return service, engine +} + +func TestLegacyPluginEnvironmentDoesNotForwardWeChatSecret(t *testing.T) { + previous := config.CurrentConfig() + config.PublishConfigSnapshot(&config.Config{ + WeChatPushAppId: "app-id", + WeChatPushSecret: "secret-must-not-be-forwarded", + WeChatPushTemplateId: "template-id", + WeChatPushUserId: "user-id", + }) + t.Cleanup(func() { config.PublishConfigSnapshot(previous) }) + env := pluginEnvironment("C:/smail", "wechat_push") + for _, item := range env { + if strings.HasPrefix(item, "SMAIL_WECHAT_SECRET=") { + t.Fatal("legacy WeChat secret was forwarded to plugin environment") + } + } +} diff --git a/server/hooks/framework/framework.go b/server/hooks/framework/framework.go index 6d629203..08740c9c 100644 --- a/server/hooks/framework/framework.go +++ b/server/hooks/framework/framework.go @@ -2,6 +2,7 @@ package framework import ( "bytes" + "crypto/subtle" "encoding/json" "errors" "fmt" @@ -52,15 +53,52 @@ type SettingsHtmlRequest struct { RequestData string } +// 插件能力宣告 +type Capabilities struct { + PluginID string `json:"pluginId"` + Capabilities []string `json:"capabilities,omitempty"` + Settings []string `json:"settings,omitempty"` + Protocol uint32 `json:"protocol"` +} + +// 插件能力提供接口 +type PluginRuntimeConfig struct { + PluginID string `json:"pluginId"` + Generation uint64 `json:"generation"` + Settings json.RawMessage `json:"settings,omitempty"` + Secrets map[string]string `json:"secrets,omitempty"` + Capabilities []string `json:"capabilities,omitempty"` + Network []PluginNetworkTarget `json:"network,omitempty"` +} + +type PluginNetworkTarget struct { + Scheme string `json:"scheme"` + Host string `json:"host"` + Port int `json:"port"` +} + +type CapabilityProvider interface { + Capabilities() Capabilities +} + +// 可配置插件接口 +type ConfigurableHook interface { + ValidateConfig(json.RawMessage) error + Configure(json.RawMessage) error + Health() error +} + type Plugin struct { - name string - hook EmailHook + name string + hook EmailHook + authToken string } func CreatePlugin(name string, hook EmailHook) *Plugin { return &Plugin{ - name: name, - hook: hook, + name: name, + hook: hook, + authToken: os.Getenv("SMAIL_PLUGIN_RPC_TOKEN"), } } @@ -87,6 +125,7 @@ func (l *logFormatter) Format(entry *log.Entry) ([]byte, error) { } const maxPluginRPCBytes int64 = 8 << 20 +const pluginRPCConcurrencyLimit = 32 func decodePluginRequest(w http.ResponseWriter, request *http.Request, target any) bool { if request.Method != http.MethodPost { @@ -151,6 +190,58 @@ func (p *Plugin) handleHookDTO(endpoint string, action func(*HookDTO)) http.Hand } } +func (p *Plugin) capabilities() Capabilities { + if provider, ok := p.hook.(CapabilityProvider); ok { + capabilities := provider.Capabilities() + if capabilities.PluginID == "" { + capabilities.PluginID = p.name + } + if capabilities.Protocol == 0 { + capabilities.Protocol = 1 + } + return capabilities + } + return Capabilities{PluginID: p.name, Protocol: 1} +} + +func (p *Plugin) handleConfig(action func(json.RawMessage) error) http.HandlerFunc { + return func(w http.ResponseWriter, request *http.Request) { + var payload json.RawMessage + if !decodePluginRequest(w, request, &payload) { + return + } + if err := action(payload); err != nil { + http.Error(w, "plugin configuration rejected", http.StatusBadRequest) + return + } + _ = writePluginResponse(w, "application/json", []byte(`{"status":"ok"}`)) + } +} + +func (p *Plugin) authenticatedHandler(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, request *http.Request) { + token := request.Header.Get("X-Smail-Plugin-Token") + if p.authToken == "" || token == "" || len(token) != len(p.authToken) || subtle.ConstantTimeCompare([]byte(token), []byte(p.authToken)) != 1 { + w.WriteHeader(http.StatusUnauthorized) + return + } + next.ServeHTTP(w, request) + }) +} + +func (p *Plugin) limitedHandler(next http.Handler) http.Handler { + semaphore := make(chan struct{}, pluginRPCConcurrencyLimit) + return http.HandlerFunc(func(w http.ResponseWriter, request *http.Request) { + select { + case semaphore <- struct{}{}: + defer func() { <-semaphore }() + case <-request.Context().Done(): + return + } + next.ServeHTTP(w, request) + }) +} + func (p *Plugin) Run() error { // 设置日志格式为json格式 @@ -200,11 +291,40 @@ func (p *Plugin) Run() error { log.WithError(err).Errorf("[%s] SettingsHtml response write failed", p.name) } }) + mux.HandleFunc("/Capabilities", func(w http.ResponseWriter, request *http.Request) { + if request.Method != http.MethodPost { + w.Header().Set("Allow", http.MethodPost) + w.WriteHeader(http.StatusMethodNotAllowed) + return + } + body, err := json.Marshal(p.capabilities()) + if err != nil { + w.WriteHeader(http.StatusInternalServerError) + return + } + _ = writePluginResponse(w, "application/json", body) + }) + if configurable, ok := p.hook.(ConfigurableHook); ok { + mux.Handle("/ValidateConfig", p.handleConfig(configurable.ValidateConfig)) + mux.Handle("/Configure", p.handleConfig(configurable.Configure)) + mux.HandleFunc("/Health", func(w http.ResponseWriter, request *http.Request) { + if request.Method != http.MethodPost { + w.Header().Set("Allow", http.MethodPost) + w.WriteHeader(http.StatusMethodNotAllowed) + return + } + if err := configurable.Health(); err != nil { + http.Error(w, "plugin health check failed", http.StatusServiceUnavailable) + return + } + _ = writePluginResponse(w, "application/json", []byte(`{"status":"ok"}`)) + }) + } server := http.Server{ ReadTimeout: 5 * time.Second, WriteTimeout: 5 * time.Second, - Handler: mux, + Handler: p.authenticatedHandler(p.limitedHandler(mux)), } unixListener, err := pluginListener(os.Args[1]) diff --git a/server/hooks/framework/framework_security_test.go b/server/hooks/framework/framework_security_test.go index 11d27571..213a83a4 100644 --- a/server/hooks/framework/framework_security_test.go +++ b/server/hooks/framework/framework_security_test.go @@ -7,6 +7,8 @@ import ( "io" "net/http" "net/http/httptest" + "strings" + "sync" "testing" "git.pcux.cn/xuans/Smail/dto/parsemail" @@ -107,3 +109,123 @@ func TestOlderPluginShapeIgnoresNewAuthenticationField(t *testing.T) { t.Fatalf("older plugin shape could not read the message: %+v", oldDTO.Email) } } + +func TestAuthenticatedHandlerRequiresStartupToken(t *testing.T) { + plugin := &Plugin{authToken: "startup-token"} + next := http.HandlerFunc(func(w http.ResponseWriter, request *http.Request) { + w.WriteHeader(http.StatusNoContent) + }) + handler := plugin.authenticatedHandler(next) + + for _, test := range []struct { + name string + token string + status int + }{ + {name: "missing", status: http.StatusUnauthorized}, + {name: "wrong", token: "wrong-token", status: http.StatusUnauthorized}, + {name: "valid", token: "startup-token", status: http.StatusNoContent}, + } { + t.Run(test.name, func(t *testing.T) { + request := httptest.NewRequest(http.MethodPost, "/Health", nil) + if test.token != "" { + request.Header.Set("X-Smail-Plugin-Token", test.token) + } + recorder := httptest.NewRecorder() + handler.ServeHTTP(recorder, request) + if recorder.Code != test.status { + t.Fatalf("status = %d, want %d", recorder.Code, test.status) + } + }) + } +} + +func TestAuthenticatedHandlerRejectsEmptyConfiguredToken(t *testing.T) { + plugin := &Plugin{} + handler := plugin.authenticatedHandler(http.HandlerFunc(func(w http.ResponseWriter, request *http.Request) { + t.Fatal("unauthenticated request reached handler") + })) + request := httptest.NewRequest(http.MethodPost, "/Health", nil) + request.Header.Set("X-Smail-Plugin-Token", "unexpected") + recorder := httptest.NewRecorder() + handler.ServeHTTP(recorder, request) + if recorder.Code != http.StatusUnauthorized { + t.Fatalf("status = %d, want %d", recorder.Code, http.StatusUnauthorized) + } +} + +func TestDecodePluginRequestRejectsOversizedPayload(t *testing.T) { + body := bytes.NewBufferString(`"` + strings.Repeat("x", int(maxPluginRPCBytes)) + `"`) + request := httptest.NewRequest(http.MethodPost, "/", body) + recorder := httptest.NewRecorder() + var payload json.RawMessage + if decodePluginRequest(recorder, request, &payload) { + t.Fatal("oversized payload was accepted") + } + if recorder.Code != http.StatusRequestEntityTooLarge { + t.Fatalf("status = %d, want %d", recorder.Code, http.StatusRequestEntityTooLarge) + } +} + +func TestHandleConfigDoesNotExposeActionError(t *testing.T) { + plugin := &Plugin{} + handler := plugin.handleConfig(func(json.RawMessage) error { + return errors.New("secret-token") + }) + request := httptest.NewRequest(http.MethodPost, "/Configure", bytes.NewBufferString(`{}`)) + recorder := httptest.NewRecorder() + handler.ServeHTTP(recorder, request) + if recorder.Code != http.StatusBadRequest { + t.Fatalf("status = %d, want %d", recorder.Code, http.StatusBadRequest) + } + if strings.Contains(recorder.Body.String(), "secret-token") { + t.Fatal("configuration error exposed secret material") + } +} + +func TestLimitedHandlerCapsConcurrentRequests(t *testing.T) { + plugin := &Plugin{} + started := make(chan struct{}, pluginRPCConcurrencyLimit) + release := make(chan struct{}) + var active int + var peak int + var mu sync.Mutex + next := http.HandlerFunc(func(w http.ResponseWriter, request *http.Request) { + mu.Lock() + active++ + if active > peak { + peak = active + } + mu.Unlock() + started <- struct{}{} + <-release + mu.Lock() + active-- + mu.Unlock() + w.WriteHeader(http.StatusNoContent) + }) + handler := plugin.limitedHandler(next) + var wg sync.WaitGroup + for i := 0; i < pluginRPCConcurrencyLimit+8; i++ { + wg.Add(1) + go func() { + defer wg.Done() + request := httptest.NewRequest(http.MethodPost, "/Health", nil) + recorder := httptest.NewRecorder() + handler.ServeHTTP(recorder, request) + }() + } + for i := 0; i < pluginRPCConcurrencyLimit; i++ { + <-started + } + mu.Lock() + if peak != pluginRPCConcurrencyLimit { + mu.Unlock() + close(release) + wg.Wait() + t.Fatalf("peak concurrency = %d, want %d", peak, pluginRPCConcurrencyLimit) + } + mu.Unlock() + close(release) + wg.Wait() +} diff --git a/server/hooks/plugin_isolation.go b/server/hooks/plugin_isolation.go index 94c2ba04..e354c5c0 100644 --- a/server/hooks/plugin_isolation.go +++ b/server/hooks/plugin_isolation.go @@ -75,8 +75,5 @@ func isolatedPluginEnv(env []string) []string { result = append(result, item) } result = append(result, "SMAIL_PLUGIN_SANDBOX=1") - if os.Getenv("SMAIL_PLUGIN_NETWORK") == "1" { - result = append(result, "SMAIL_PLUGIN_NETWORK=1") - } return result } diff --git a/server/hooks/plugin_isolation_linux.go b/server/hooks/plugin_isolation_linux.go index 3a0ad225..2644463a 100644 --- a/server/hooks/plugin_isolation_linux.go +++ b/server/hooks/plugin_isolation_linux.go @@ -61,10 +61,6 @@ func newPluginLaunchSpec(pluginPath, root, name, socketName string, env []string return nil, err } - cloneFlags := uintptr(0) - if os.Getenv("SMAIL_PLUGIN_NETWORK") != "1" { - cloneFlags = unix.CLONE_NEWNET - } isolatedEnv := isolatedPluginEnv(env) abstractSocket := "@" + socketName listener, err := net.ListenUnix("unix", &net.UnixAddr{Name: abstractSocket, Net: "unix"}) @@ -80,6 +76,7 @@ func newPluginLaunchSpec(pluginPath, root, name, socketName string, env []string cleanup() return nil, fmt.Errorf("prepare plugin listener: %w", err) } + cloneFlags := uintptr(unix.CLONE_NEWNET) return &pluginLaunchSpec{ path: "/" + name, args: []string{name, "fd:3"}, diff --git a/server/hooks/spam_block/spam_block.go b/server/hooks/spam_block/spam_block.go index cfe98501..ea23884a 100644 --- a/server/hooks/spam_block/spam_block.go +++ b/server/hooks/spam_block/spam_block.go @@ -15,6 +15,7 @@ import ( "io" "math" "net/http" + urlpkg "net/url" "os" "strconv" "strings" @@ -50,6 +51,46 @@ func (s *SpamBlock) GetName(ctx *context.Context) string { return "SpamBlock" } +// Capabilities 声明插件需要访问模型服务。 +func (s *SpamBlock) Capabilities() framework.Capabilities { + return framework.Capabilities{ + PluginID: "spam_block", + Capabilities: []string{"network"}, + Settings: []string{"url", "timeout", "threshold"}, + Protocol: 1, + } +} + +// ValidateConfig 只校验主程序下发的运行时配置。 +func (s *SpamBlock) ValidateConfig(data json.RawMessage) error { + _, err := parseSpamBlockRuntimeConfig(data) + return err +} + +// Configure 应用主程序下发的模型服务配置。 +func (s *SpamBlock) Configure(data json.RawMessage) error { + cfg, err := parseSpamBlockRuntimeConfig(data) + if err != nil { + return err + } + s.mu.Lock() + s.cfg = cfg + s.hc = newHTTPClientForEndpoint(cfg.ApiTimeout, cfg.ApiURL) + s.mu.Unlock() + return nil +} + +// Health 检查插件是否已经完成运行时配置。 +func (s *SpamBlock) Health() error { + s.mu.RLock() + client := s.hc + s.mu.RUnlock() + if client == nil { + return fmt.Errorf("垃圾邮件插件尚未完成运行时配置") + } + return nil +} + //go:embed static/index.html var index string @@ -67,7 +108,7 @@ func (s *SpamBlock) SettingsHtml(ctx *context.Context, url string, requestData s if !ctx.IsAdmin { return fmt.Sprintf(`
- Please contact the administrator for configuration. + 请联系管理员进行配置。
`) } @@ -77,7 +118,7 @@ func (s *SpamBlock) SettingsHtml(ctx *context.Context, url string, requestData s return fmt.Sprintf(index, template.HTMLEscapeString(cfg.ApiURL), cfg.ApiTimeout, cfg.Threshold) } if !ctx.IsAdmin { - return "No Access Privileges" + return "没有访问权限" } cfg, err := decodeSpamBlockConfig([]byte(requestData)) @@ -85,12 +126,9 @@ func (s *SpamBlock) SettingsHtml(ctx *context.Context, url string, requestData s return err.Error() } - s.mu.Lock() - s.cfg = cfg - s.hc = newHTTPClient(cfg.ApiTimeout) - s.mu.Unlock() + s.applyConfig(cfg) - return "success" + return "保存成功" } @@ -119,7 +157,7 @@ func (s *SpamBlock) ReceiveParseAfter(ctx *context.Context, email *parsemail.Ema return } if client == nil { - client = newHTTPClient(cfg.ApiTimeout) + client = newHTTPClientForEndpoint(cfg.ApiTimeout, cfg.ApiURL) } reqData := ApiRequest{ @@ -251,20 +289,7 @@ type SpamBlockConfig struct { } func NewSpamBlockHook() *SpamBlock { - pluginConfig := defaultSpamBlockConfig() - if cfgData, err := os.ReadFile("./plugins/spam_block_config.json"); err == nil { - parsed, parseErr := decodeSpamBlockConfig(cfgData) - if parseErr != nil { - log.Error("spam block configuration is invalid") - } else { - pluginConfig = parsed - } - } - - return &SpamBlock{ - cfg: pluginConfig, - hc: newHTTPClient(pluginConfig.ApiTimeout), - } + return &SpamBlock{} } func defaultSpamBlockConfig() SpamBlockConfig { @@ -298,6 +323,80 @@ func decodeSpamBlockConfig(data []byte) (SpamBlockConfig, error) { return normalizeConfig(SpamBlockConfig{ApiURL: raw.ApiURL, ApiTimeout: timeout, Threshold: threshold}) } +type spamBlockRuntimeConfig struct { + PluginID string `json:"pluginId"` + Generation uint64 `json:"generation"` + Settings json.RawMessage `json:"settings,omitempty"` + Capabilities []string `json:"capabilities,omitempty"` + Network []framework.PluginNetworkTarget `json:"network,omitempty"` +} + +func parseSpamBlockRuntimeConfig(data json.RawMessage) (SpamBlockConfig, error) { + var payload spamBlockRuntimeConfig + decoder := json.NewDecoder(strings.NewReader(string(data))) + decoder.DisallowUnknownFields() + if err := decoder.Decode(&payload); err != nil { + return SpamBlockConfig{}, fmt.Errorf("垃圾邮件插件运行时配置无效") + } + if err := decoder.Decode(&struct{}{}); err != io.EOF { + return SpamBlockConfig{}, fmt.Errorf("垃圾邮件插件运行时配置无效") + } + if payload.PluginID != "spam_block" { + return SpamBlockConfig{}, fmt.Errorf("垃圾邮件插件 ID 不匹配") + } + if payload.Generation == 0 { + return SpamBlockConfig{}, fmt.Errorf("垃圾邮件插件配置代次无效") + } + if !hasOnlySpamBlockCapability(payload.Capabilities, "network") { + return SpamBlockConfig{}, fmt.Errorf("垃圾邮件插件网络权限未配置") + } + if len(payload.Settings) == 0 || len(payload.Settings) > maxSpamBlockSourceBytes { + return SpamBlockConfig{}, fmt.Errorf("垃圾邮件插件配置无效") + } + cfg, err := decodeSpamBlockConfig(payload.Settings) + if err != nil { + return SpamBlockConfig{}, fmt.Errorf("垃圾邮件插件配置无效") + } + if cfg.ApiURL == "" { + if len(payload.Network) != 0 { + return SpamBlockConfig{}, fmt.Errorf("垃圾邮件插件网络权限未配置") + } + } else if !hasOnlySpamBlockNetworkTarget(payload.Network, cfg.ApiURL) { + return SpamBlockConfig{}, fmt.Errorf("垃圾邮件插件网络权限未配置") + } + return cfg, nil +} + +func (s *SpamBlock) applyConfig(cfg SpamBlockConfig) { + s.mu.Lock() + s.cfg = cfg + s.hc = newHTTPClientForEndpoint(cfg.ApiTimeout, cfg.ApiURL) + s.mu.Unlock() +} + +func hasOnlySpamBlockCapability(capabilities []string, expected string) bool { + return len(capabilities) == 1 && capabilities[0] == expected +} + +func hasOnlySpamBlockNetworkTarget(targets []framework.PluginNetworkTarget, endpoint string) bool { + if len(targets) != 1 { + return false + } + parsed, err := urlpkg.Parse(endpoint) + if err != nil || parsed.Scheme == "" || parsed.Hostname() == "" { + return false + } + port := 443 + if parsed.Port() != "" { + port, err = strconv.Atoi(parsed.Port()) + if err != nil { + return false + } + } + target := targets[0] + return strings.EqualFold(target.Scheme, parsed.Scheme) && strings.EqualFold(target.Host, parsed.Hostname()) && target.Port == port +} + func parseConfigInt(raw json.RawMessage, fallback int) (int, error) { value, err := configNumber(raw) if err != nil || value == "" { @@ -348,6 +447,21 @@ func newHTTPClient(timeout int) *http.Client { return credential.NewRestrictedHTTPClient(timeout) } +func newHTTPClientForEndpoint(timeout int, endpoint string) *http.Client { + parsed, err := urlpkg.Parse(endpoint) + if err != nil || parsed.Scheme == "" || parsed.Hostname() == "" { + return newHTTPClient(timeout) + } + port := 443 + if parsed.Port() != "" { + port, err = strconv.Atoi(parsed.Port()) + if err != nil { + return newHTTPClient(timeout) + } + } + return credential.NewRestrictedHTTPClientForTargets(timeout, []credential.NetworkTarget{{Scheme: strings.ToLower(parsed.Scheme), Host: strings.ToLower(parsed.Hostname()), Port: port}}) +} + func main() { log.Infof("SpamBlockPlug Star Success") instance := NewSpamBlockHook() diff --git a/server/hooks/spam_block/spam_block_test.go b/server/hooks/spam_block/spam_block_test.go index f16dd8a5..34c95be4 100644 --- a/server/hooks/spam_block/spam_block_test.go +++ b/server/hooks/spam_block/spam_block_test.go @@ -7,9 +7,119 @@ import ( "unicode/utf8" "git.pcux.cn/xuans/Smail/dto/parsemail" + "git.pcux.cn/xuans/Smail/hooks/framework" "git.pcux.cn/xuans/Smail/utils/context" ) +func validSpamBlockRuntimePayload() []byte { + payload := spamBlockRuntimeConfig{ + PluginID: "spam_block", + Generation: 1, + Settings: json.RawMessage(`{"url":"https://model.example.com/v1/predict","timeout":3000,"threshold":20}`), + Capabilities: []string{"network"}, + Network: []framework.PluginNetworkTarget{{Scheme: "https", Host: "model.example.com", Port: 443}}, + } + data, err := json.Marshal(payload) + if err != nil { + panic(err) + } + return data +} + +func TestSpamBlockRuntimeConfigAcceptsAuthorizedPayload(t *testing.T) { + hook := NewSpamBlockHook() + if err := hook.ValidateConfig(validSpamBlockRuntimePayload()); err != nil { + t.Fatal(err) + } + if err := hook.Configure(validSpamBlockRuntimePayload()); err != nil { + t.Fatal(err) + } + if err := hook.Health(); err != nil { + t.Fatal(err) + } +} + +func TestSpamBlockRuntimeConfigRejectsZeroGeneration(t *testing.T) { + var payload spamBlockRuntimeConfig + if err := json.Unmarshal(validSpamBlockRuntimePayload(), &payload); err != nil { + t.Fatal(err) + } + payload.Generation = 0 + data, err := json.Marshal(payload) + if err != nil { + t.Fatal(err) + } + if err := NewSpamBlockHook().ValidateConfig(data); err == nil { + t.Fatal("zero plugin configuration generation was accepted") + } +} + +func TestSpamBlockRuntimeConfigRejectsUnapprovedNetwork(t *testing.T) { + var payload spamBlockRuntimeConfig + if err := json.Unmarshal(validSpamBlockRuntimePayload(), &payload); err != nil { + t.Fatal(err) + } + payload.Network = []framework.PluginNetworkTarget{{Scheme: "https", Host: "other.example.com", Port: 443}} + data, err := json.Marshal(payload) + if err != nil { + t.Fatal(err) + } + if err := NewSpamBlockHook().ValidateConfig(data); err == nil { + t.Fatal("unapproved network target was accepted") + } +} + +func TestSpamBlockRuntimeConfigRejectsCapabilityAndExtraNetwork(t *testing.T) { + tests := []struct { + name string + mutate func(*spamBlockRuntimeConfig) + }{ + {name: "missing capability", mutate: func(payload *spamBlockRuntimeConfig) { payload.Capabilities = nil }}, + {name: "extra capability", mutate: func(payload *spamBlockRuntimeConfig) { payload.Capabilities = []string{"network", "filesystem"} }}, + {name: "extra network", mutate: func(payload *spamBlockRuntimeConfig) { + payload.Network = append(payload.Network, framework.PluginNetworkTarget{Scheme: "https", Host: "other.example.com", Port: 443}) + }}, + } + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + var payload spamBlockRuntimeConfig + if err := json.Unmarshal(validSpamBlockRuntimePayload(), &payload); err != nil { + t.Fatal(err) + } + test.mutate(&payload) + data, err := json.Marshal(payload) + if err != nil { + t.Fatal(err) + } + if err := NewSpamBlockHook().ValidateConfig(data); err == nil { + t.Fatal("invalid runtime configuration was accepted") + } + }) + } +} + +func TestSpamBlockRuntimeConfigRejectsNetworkWithoutModelURL(t *testing.T) { + var payload spamBlockRuntimeConfig + if err := json.Unmarshal(validSpamBlockRuntimePayload(), &payload); err != nil { + t.Fatal(err) + } + payload.Settings = json.RawMessage(`{"timeout":3000,"threshold":20}`) + data, err := json.Marshal(payload) + if err != nil { + t.Fatal(err) + } + if err := NewSpamBlockHook().ValidateConfig(data); err == nil { + t.Fatal("network permission without model URL was accepted") + } +} + +func TestSpamBlockRuntimeConfigRejectsTrailingJSON(t *testing.T) { + data := append(validSpamBlockRuntimePayload(), []byte(` {}`)...) + if err := NewSpamBlockHook().ValidateConfig(data); err == nil { + t.Fatal("trailing JSON was accepted") + } +} + func TestSpamBlockConfigJSONRoundTrip(t *testing.T) { input := []byte(`{"url":"https://model.example.com","timeout":3000,"threshold":20}`) var config SpamBlockConfig @@ -69,7 +179,7 @@ func TestDecodeSpamBlockConfigUsesUnifiedValidation(t *testing.T) { func TestSettingsHtmlAppliesValidatedConfiguration(t *testing.T) { s := &SpamBlock{} result := s.SettingsHtml(&context.Context{IsAdmin: true}, "SpamBlock/save", `{"url":"https://model.example.com","timeout":"3000","threshold":"25"}`) - if result != "success" { + if result != "保存成功" { t.Fatalf("save result = %q", result) } s.mu.RLock() @@ -116,7 +226,7 @@ func TestBuildSpamBlockModelTextHandlesNilAndLimitsSource(t *testing.T) { func TestSettingsHtmlRejectsNonAdminSave(t *testing.T) { s := &SpamBlock{} result := s.SettingsHtml(&context.Context{}, "SpamBlock/save", `{"url":"https://model.example.com/predict"}`) - if result != "No Access Privileges" { + if result != "没有访问权限" { t.Fatalf("non-admin save result = %q, want access denial", result) } if s.cfg.ApiURL != "" { diff --git a/server/hooks/wechat_push/wechat_push.go b/server/hooks/wechat_push/wechat_push.go index f1772f50..f8b02ae9 100644 --- a/server/hooks/wechat_push/wechat_push.go +++ b/server/hooks/wechat_push/wechat_push.go @@ -11,10 +11,11 @@ import ( "git.pcux.cn/xuans/Smail/utils/credential" log "github.com/sirupsen/logrus" "io" + "net" "net/http" urlpkg "net/url" "os" - "strconv" + "strings" "sync" "time" "unicode/utf8" @@ -25,7 +26,7 @@ const ( maxWeChatMessageBytes = 4 << 10 ) -var weChatHTTPClient = &http.Client{Timeout: 10 * time.Second} +var weChatHTTPClient = credential.NewRestrictedHTTPClient(10_000) type accessTokenRes struct { AccessToken string `db:"access_token" json:"access_token"` @@ -41,24 +42,94 @@ type WeChatPushHook struct { templateId string pushUser string webDomain string - httpsEnabled int + httpClient *http.Client } func (w *WeChatPushHook) GetName(ctx *context.Context) string { return "WeChatPushHook" } +// Capabilities 声明插件需要的能力和配置字段。 +func (w *WeChatPushHook) Capabilities() framework.Capabilities { + return framework.Capabilities{ + PluginID: "wechat_push", + Capabilities: []string{"network"}, + Settings: []string{"appId", "templateId", "userId", "webDomain"}, + Protocol: 1, + } +} + +type weChatRuntimeConfig struct { + PluginID string `json:"pluginId"` + Generation uint64 `json:"generation"` + Settings json.RawMessage `json:"settings,omitempty"` + Secrets map[string]string `json:"secrets,omitempty"` + Capabilities []string `json:"capabilities,omitempty"` + Network []framework.PluginNetworkTarget `json:"network,omitempty"` +} + +type weChatSettings struct { + AppID string `json:"appId"` + TemplateID string `json:"templateId"` + UserID string `json:"userId"` + WebDomain string `json:"webDomain"` +} + +// ValidateConfig 只校验主程序下发的运行时配置,不读取本地配置文件或环境变量。 +func (w *WeChatPushHook) ValidateConfig(data json.RawMessage) error { + _, _, _, err := parseWeChatRuntimeConfig(data) + return err +} + +// Configure 应用主程序下发的运行时配置,并在配置变更后清理缓存令牌。 +func (w *WeChatPushHook) Configure(data json.RawMessage) error { + _, settings, secret, err := parseWeChatRuntimeConfig(data) + if err != nil { + return err + } + w.tokenMu.Lock() + w.appId = settings.AppID + w.secret = secret + w.templateId = settings.TemplateID + w.pushUser = settings.UserID + w.webDomain = settings.WebDomain + w.httpClient = credential.NewRestrictedHTTPClientForTargets(10_000, []credential.NetworkTarget{{Scheme: "https", Host: "api.weixin.qq.com", Port: 443}}) + w.token = "" + w.tokenExpires = 0 + w.tokenMu.Unlock() + return nil +} + +// Health 检查插件是否已经完成安全运行时配置。 +func (w *WeChatPushHook) Health() error { + if w == nil { + return fmt.Errorf("微信插件不可用") + } + w.tokenMu.Lock() + configured := w.appId != "" && w.secret != "" && w.templateId != "" && w.pushUser != "" && w.webDomain != "" && w.httpClient != nil + w.tokenMu.Unlock() + if !configured { + return fmt.Errorf("微信插件尚未完成运行时配置") + } + return nil +} + // SettingsHtml 插件页面 func (w *WeChatPushHook) SettingsHtml(ctx *context.Context, url string, requestData string) string { return fmt.Sprintf(`
- Wechat push No Settings Page + 暂无设置页面
`) } func (w *WeChatPushHook) ReceiveSaveAfter(ctx *context.Context, email *parsemail.Email, ue []*models.UserEmail) { - if email == nil || w.appId == "" || w.secret == "" || w.pushUser == "" { + w.tokenMu.Lock() + appID := w.appId + secret := w.secret + pushUser := w.pushUser + w.tokenMu.Unlock() + if email == nil || appID == "" || secret == "" || pushUser == "" { return } @@ -68,7 +139,7 @@ func (w *WeChatPushHook) ReceiveSaveAfter(ctx *context.Context, email *parsemail } // 管理员(Uid=1)收到邮件且非已读、非已删除 触发通知 if u.UserID == 1 && u.IsRead == 0 && u.Status == 0 && email.MessageId > 0 { - w.sendUserMsg(ctx, w.pushUser, buildWeChatMessage(email)) + w.sendUserMsg(ctx, pushUser, buildWeChatMessage(email)) } } @@ -114,7 +185,11 @@ func (w *WeChatPushHook) getWxAccessToken() string { if err != nil { return "" } - resp, err := weChatHTTPClient.Do(request) + client := w.httpClient + if client == nil { + client = weChatHTTPClient + } + resp, err := client.Do(request) if err != nil || resp == nil { return "" } @@ -153,16 +228,19 @@ type DataItem struct { func (w *WeChatPushHook) sendUserMsg(ctx *context.Context, userId string, content string) { content = truncateWeChatText(content, maxWeChatMessageBytes) - url := w.webDomain - if w.httpsEnabled > 1 { - url = "http://" + url - } else { - url = "https://" + url + w.tokenMu.Lock() + webDomain := w.webDomain + templateID := w.templateId + client := w.httpClient + w.tokenMu.Unlock() + if client == nil { + client = weChatHTTPClient } + url := "https://" + webDomain sendMsgReq, err := json.Marshal(sendMsgRequest{ Touser: userId, - Template_id: w.templateId, + Template_id: templateID, Url: url, Data: SendData{Content: DataItem{Value: content, Color: "#000000"}}, }) @@ -185,7 +263,7 @@ func (w *WeChatPushHook) sendUserMsg(ctx *context.Context, userId string, conten return } request.Header.Set("Content-Type", "application/json") - resp, err := weChatHTTPClient.Do(request) + resp, err := client.Do(request) if err != nil || resp == nil { log.WithContext(ctx).Error("wechat push request failed") return @@ -226,18 +304,90 @@ func truncateWeChatText(value string, maxBytes int) string { } func NewWechatPushHook() *WeChatPushHook { - httpsEnabled := 0 - if value, err := strconv.Atoi(os.Getenv("SMAIL_HTTPS_ENABLED")); err == nil { - httpsEnabled = value + return &WeChatPushHook{} +} + +func parseWeChatRuntimeConfig(data json.RawMessage) (weChatRuntimeConfig, weChatSettings, string, error) { + var payload weChatRuntimeConfig + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + if err := decoder.Decode(&payload); err != nil || decoder.Decode(&struct{}{}) != io.EOF { + return weChatRuntimeConfig{}, weChatSettings{}, "", fmt.Errorf("微信插件运行时配置无效") } - return &WeChatPushHook{ - appId: os.Getenv("SMAIL_WECHAT_APP_ID"), - secret: os.Getenv("SMAIL_WECHAT_SECRET"), - templateId: os.Getenv("SMAIL_WECHAT_TEMPLATE_ID"), - pushUser: os.Getenv("SMAIL_WECHAT_USER_ID"), - webDomain: os.Getenv("SMAIL_WEB_DOMAIN"), - httpsEnabled: httpsEnabled, + if payload.PluginID != "wechat_push" { + return weChatRuntimeConfig{}, weChatSettings{}, "", fmt.Errorf("微信插件 ID 不匹配") } + if payload.Generation == 0 { + return weChatRuntimeConfig{}, weChatSettings{}, "", fmt.Errorf("微信插件配置代次无效") + } + if !hasOnlyWeChatCapability(payload.Capabilities, "network") { + return weChatRuntimeConfig{}, weChatSettings{}, "", fmt.Errorf("微信插件网络权限未配置") + } + if len(payload.Settings) == 0 || len(payload.Settings) > maxWeChatResponseBytes { + return weChatRuntimeConfig{}, weChatSettings{}, "", fmt.Errorf("微信插件配置无效") + } + var settings weChatSettings + settingsDecoder := json.NewDecoder(bytes.NewReader(payload.Settings)) + settingsDecoder.DisallowUnknownFields() + if err := settingsDecoder.Decode(&settings); err != nil || settingsDecoder.Decode(&struct{}{}) != io.EOF { + return weChatRuntimeConfig{}, weChatSettings{}, "", fmt.Errorf("微信插件配置无效") + } + appID, err := credential.ValidateSecret(settings.AppID, 256) + if err != nil { + return weChatRuntimeConfig{}, weChatSettings{}, "", fmt.Errorf("微信应用 ID 无效") + } + templateID, err := credential.ValidateSecret(settings.TemplateID, 256) + if err != nil { + return weChatRuntimeConfig{}, weChatSettings{}, "", fmt.Errorf("微信模板 ID 无效") + } + userID, err := credential.ValidateSecret(settings.UserID, 256) + if err != nil { + return weChatRuntimeConfig{}, weChatSettings{}, "", fmt.Errorf("微信用户 ID 无效") + } + webDomain, err := normalizeWeChatWebDomain(settings.WebDomain) + if err != nil { + return weChatRuntimeConfig{}, weChatSettings{}, "", fmt.Errorf("微信回调域名无效") + } + secret, err := credential.ValidateSecret(payload.Secrets["appSecret"], 4096) + if err != nil { + return weChatRuntimeConfig{}, weChatSettings{}, "", fmt.Errorf("微信应用密钥未配置") + } + for name := range payload.Secrets { + if name != "appSecret" { + return weChatRuntimeConfig{}, weChatSettings{}, "", fmt.Errorf("微信插件密钥字段无效") + } + } + if !hasOnlyWeChatNetworkTarget(payload.Network) { + return weChatRuntimeConfig{}, weChatSettings{}, "", fmt.Errorf("微信网络权限未配置") + } + settings.AppID = appID + settings.TemplateID = templateID + settings.UserID = userID + settings.WebDomain = webDomain + return payload, settings, secret, nil +} + +func hasOnlyWeChatCapability(capabilities []string, expected string) bool { + return len(capabilities) == 1 && capabilities[0] == expected +} + +func hasOnlyWeChatNetworkTarget(targets []framework.PluginNetworkTarget) bool { + return len(targets) == 1 && strings.EqualFold(targets[0].Scheme, "https") && strings.EqualFold(targets[0].Host, "api.weixin.qq.com") && targets[0].Port == 443 +} + +func normalizeWeChatWebDomain(value string) (string, error) { + value = strings.TrimSpace(value) + if value == "" || len(value) > 253 || strings.ContainsAny(value, "/\\?#\x00\r\n\t ") { + return "", fmt.Errorf("invalid domain") + } + if net.ParseIP(strings.Trim(value, "[]")) != nil { + return "", fmt.Errorf("invalid domain") + } + parsed, err := urlpkg.Parse("https://" + value) + if err != nil || parsed.Host != value || parsed.Hostname() == "" || parsed.User != nil { + return "", fmt.Errorf("invalid domain") + } + return strings.TrimSuffix(strings.ToLower(parsed.Host), "."), nil } // 插件将以独立进程运行,因此需要主函数。 diff --git a/server/hooks/wechat_push/wechat_push_test.go b/server/hooks/wechat_push/wechat_push_test.go index 9758d997..c4f74771 100644 --- a/server/hooks/wechat_push/wechat_push_test.go +++ b/server/hooks/wechat_push/wechat_push_test.go @@ -12,6 +12,7 @@ import ( "unicode/utf8" "git.pcux.cn/xuans/Smail/dto/parsemail" + "git.pcux.cn/xuans/Smail/hooks/framework" ) type weChatRoundTripFunc func(*http.Request) (*http.Response, error) @@ -20,6 +21,98 @@ func (f weChatRoundTripFunc) RoundTrip(request *http.Request) (*http.Response, e return f(request) } +func validWeChatRuntimePayload() []byte { + payload := weChatRuntimeConfig{ + PluginID: "wechat_push", + Generation: 1, + Settings: json.RawMessage(`{"appId":"app-id","templateId":"template-id","userId":"user-id","webDomain":"mail.example.com"}`), + Secrets: map[string]string{"appSecret": "app-secret"}, + Capabilities: []string{"network"}, + Network: []framework.PluginNetworkTarget{{Scheme: "https", Host: "api.weixin.qq.com", Port: 443}}, + } + data, err := json.Marshal(payload) + if err != nil { + panic(err) + } + return data +} + +func TestWeChatRuntimeConfigAcceptsAuthorizedPayload(t *testing.T) { + hook := NewWechatPushHook() + if err := hook.ValidateConfig(validWeChatRuntimePayload()); err != nil { + t.Fatal(err) + } + if err := hook.Configure(validWeChatRuntimePayload()); err != nil { + t.Fatal(err) + } + if err := hook.Health(); err != nil { + t.Fatal(err) + } + if hook.appId != "app-id" || hook.secret != "app-secret" || hook.webDomain != "mail.example.com" { + t.Fatalf("unexpected runtime configuration: %+v", hook) + } +} + +func TestWeChatRuntimeConfigRejectsZeroGeneration(t *testing.T) { + var payload weChatRuntimeConfig + if err := json.Unmarshal(validWeChatRuntimePayload(), &payload); err != nil { + t.Fatal(err) + } + payload.Generation = 0 + data, err := json.Marshal(payload) + if err != nil { + t.Fatal(err) + } + if err := NewWechatPushHook().ValidateConfig(data); err == nil { + t.Fatal("zero plugin configuration generation was accepted") + } +} + +func TestWeChatRuntimeConfigRejectsSecurityBoundaryViolations(t *testing.T) { + tests := []struct { + name string + mutate func(*weChatRuntimeConfig) + }{ + {name: "plugin id", mutate: func(payload *weChatRuntimeConfig) { payload.PluginID = "other" }}, + {name: "missing secret", mutate: func(payload *weChatRuntimeConfig) { payload.Secrets = nil }}, + {name: "missing capability", mutate: func(payload *weChatRuntimeConfig) { payload.Capabilities = nil }}, + {name: "extra capability", mutate: func(payload *weChatRuntimeConfig) { payload.Capabilities = []string{"network", "filesystem"} }}, + {name: "wrong network", mutate: func(payload *weChatRuntimeConfig) { payload.Network = nil }}, + {name: "extra network", mutate: func(payload *weChatRuntimeConfig) { + payload.Network = append(payload.Network, framework.PluginNetworkTarget{Scheme: "https", Host: "example.com", Port: 443}) + }}, + {name: "unknown secret", mutate: func(payload *weChatRuntimeConfig) { payload.Secrets["other"] = "value" }}, + {name: "invalid domain", mutate: func(payload *weChatRuntimeConfig) { + payload.Settings = json.RawMessage(`{"appId":"app-id","templateId":"template-id","userId":"user-id","webDomain":"https://example.com/path"}`) + }}, + } + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + var payload weChatRuntimeConfig + if err := json.Unmarshal(validWeChatRuntimePayload(), &payload); err != nil { + t.Fatal(err) + } + test.mutate(&payload) + data, err := json.Marshal(payload) + if err != nil { + t.Fatal(err) + } + if err := NewWechatPushHook().ValidateConfig(data); err == nil { + t.Fatal("invalid runtime configuration was accepted") + } else if strings.Contains(err.Error(), "app-secret") { + t.Fatal("secret material appeared in the error") + } + }) + } +} + +func TestWeChatRuntimeConfigRejectsTrailingJSON(t *testing.T) { + data := append(validWeChatRuntimePayload(), []byte(` {}`)...) + if err := NewWechatPushHook().ValidateConfig(data); err == nil { + t.Fatal("trailing JSON was accepted") + } +} + func TestBuildWeChatMessageLimitsContent(t *testing.T) { message := buildWeChatMessage(&parsemail.Email{ Subject: strings.Repeat("\u754c", maxWeChatMessageBytes), diff --git a/server/listen/http_server/https_server.go b/server/listen/http_server/https_server.go index 93c9f937..64cbd35e 100644 --- a/server/listen/http_server/https_server.go +++ b/server/listen/http_server/https_server.go @@ -57,6 +57,10 @@ func HttpsStart() error { if config.DevelopmentMode && cfg.HttpsEnabled == 2 { return nil } + certificatePath, privateKeyPath, err := config.ResolveRuntimeSSLPaths(cfg) + if err != nil { + return fmt.Errorf("resolve HTTPS certificate: %w", err) + } httpsServer = &http.Server{ Addr: fmt.Sprintf(":%d", httpsPort), @@ -69,7 +73,7 @@ func HttpsStart() error { ErrorLog: nullLog, } log.Infof("HTTPS server started on port %d", httpsPort) - if err := httpsServer.ListenAndServeTLS(cfg.SSLPublicKeyPath, cfg.SSLPrivateKeyPath); err != nil { + if err := httpsServer.ListenAndServeTLS(certificatePath, privateKeyPath); err != nil { if errors.Is(err, http.ErrServerClosed) { log.Infof("HTTPS server closed normally on port %d", httpsPort) return nil diff --git a/server/listen/imap_server/imap_server.go b/server/listen/imap_server/imap_server.go index 1d38e20d..2ef9040d 100644 --- a/server/listen/imap_server/imap_server.go +++ b/server/listen/imap_server/imap_server.go @@ -39,7 +39,7 @@ func newIMAPServer() (*imapserver.Server, error) { if cfg == nil { return nil, fmt.Errorf("runtime configuration is unavailable") } - crt, err := tls.LoadX509KeyPair(cfg.SSLPublicKeyPath, cfg.SSLPrivateKeyPath) + crt, err := config.LoadRuntimeTLSCertificate(cfg) if err != nil { return nil, fmt.Errorf("load IMAP TLS certificate: %w", err) } diff --git a/server/listen/pop3_server/pop3server.go b/server/listen/pop3_server/pop3server.go index 0b15af93..1240d163 100644 --- a/server/listen/pop3_server/pop3server.go +++ b/server/listen/pop3_server/pop3server.go @@ -18,7 +18,7 @@ func StartWithTls() error { if cfg == nil { return fmt.Errorf("runtime configuration is unavailable") } - crt, err := tls.LoadX509KeyPair(cfg.SSLPublicKeyPath, cfg.SSLPrivateKeyPath) + crt, err := config.LoadRuntimeTLSCertificate(cfg) if err != nil { return fmt.Errorf("load POP3 TLS certificate: %w", err) } @@ -43,7 +43,7 @@ func Start() error { if cfg == nil { return fmt.Errorf("runtime configuration is unavailable") } - crt, err := tls.LoadX509KeyPair(cfg.SSLPublicKeyPath, cfg.SSLPrivateKeyPath) + crt, err := config.LoadRuntimeTLSCertificate(cfg) if err != nil { return fmt.Errorf("load POP3 certificate: %w", err) } diff --git a/server/listen/smtp_server/smtp.go b/server/listen/smtp_server/smtp.go index 50307fe1..433efa10 100644 --- a/server/listen/smtp_server/smtp.go +++ b/server/listen/smtp_server/smtp.go @@ -39,7 +39,7 @@ func StartWithTLSNew() error { // force TLS for auth instanceTlsNew.AllowInsecureAuth = false // Load the certificate and key - cer, err := tls.LoadX509KeyPair(cfg.SSLPublicKeyPath, cfg.SSLPrivateKeyPath) + cer, err := config.LoadRuntimeTLSCertificate(cfg) if err != nil { return fmt.Errorf("load SMTP STARTTLS certificate: %w", err) } @@ -72,7 +72,7 @@ func StartWithTLS() error { // force TLS for auth instanceTls.AllowInsecureAuth = true // Load the certificate and key - cer, err := tls.LoadX509KeyPair(cfg.SSLPublicKeyPath, cfg.SSLPrivateKeyPath) + cer, err := config.LoadRuntimeTLSCertificate(cfg) if err != nil { return fmt.Errorf("load SMTP TLS certificate: %w", err) } @@ -104,7 +104,7 @@ func Start() error { // force TLS for auth instance.AllowInsecureAuth = false // Load the certificate and key - cer, err := tls.LoadX509KeyPair(cfg.SSLPublicKeyPath, cfg.SSLPrivateKeyPath) + cer, err := config.LoadRuntimeTLSCertificate(cfg) if err != nil { return fmt.Errorf("load SMTP certificate: %w", err) } diff --git a/server/models/plugin.go b/server/models/plugin.go new file mode 100644 index 00000000..1b21a441 --- /dev/null +++ b/server/models/plugin.go @@ -0,0 +1,37 @@ +package models + +import "time" + +// PluginSecret 保存插件全局敏感字段的密文;明文和主密钥均不得写入数据库。 +type PluginSecret struct { + ID int `xorm:"pk autoincr 'id'"` + PluginID string `xorm:"varchar(64) notnull unique(plugin_secret_field) 'plugin_id'"` + FieldName string `xorm:"varchar(64) notnull unique(plugin_secret_field) 'field_name'"` + Ciphertext string `xorm:"text notnull 'ciphertext'" json:"-"` + KeyVersion uint32 `xorm:"notnull 'key_version'" json:"-"` + RecordVersion uint64 `xorm:"notnull default(1) 'record_version'" json:"record_version"` + CreatedAt time.Time `xorm:"created 'created_at'" json:"-"` + UpdatedAt time.Time `xorm:"updated 'updated_at'" json:"-"` +} + +func (PluginSecret) TableName() string { + return "plugin_secret" +} + +// PluginUserSetting 保存用户范围的加密插件设置,不能保存全局插件密钥。 +type PluginUserSetting struct { + ID int `xorm:"pk autoincr 'id'"` + PluginID string `xorm:"varchar(64) notnull unique(plugin_user_setting_owner) 'plugin_id'"` + UserID int `xorm:"notnull unique(plugin_user_setting_owner) index 'user_id'"` + SchemaVersion uint32 `xorm:"notnull 'schema_version'" json:"-"` + SettingsCiphertext string `xorm:"text notnull 'settings_ciphertext'" json:"-"` + SettingsHash string `xorm:"varchar(128) notnull 'settings_hash'" json:"-"` + Enabled bool `xorm:"notnull default(1) 'enabled'" json:"enabled"` + Version uint64 `xorm:"notnull default(1) 'version'" json:"version"` + CreatedAt time.Time `xorm:"created 'created_at'" json:"-"` + UpdatedAt time.Time `xorm:"updated 'updated_at'" json:"-"` +} + +func (PluginUserSetting) TableName() string { + return "plugin_user_setting" +} diff --git a/server/plugins/catalog/catalog.go b/server/plugins/catalog/catalog.go new file mode 100644 index 00000000..ca53da37 --- /dev/null +++ b/server/plugins/catalog/catalog.go @@ -0,0 +1,141 @@ +package catalog + +import ( + "errors" + "runtime" + "sort" + "strings" +) + +var ( + ErrUnknownPluginID = errors.New("unknown plugin ID") + ErrInvalidPluginTarget = errors.New("invalid plugin target") +) + +type Definition struct { + LogicalID string + WindowsExecutable string + UnixExecutable string + Capabilities []string + HandshakeCapabilities []string + SettingsFields []string +} + +var definitions = []Definition{ + { + LogicalID: "spam_block", + WindowsExecutable: "spam_block.exe", + UnixExecutable: "spam_block", + Capabilities: []string{"network"}, + HandshakeCapabilities: []string{"network"}, + SettingsFields: []string{"url", "timeout", "threshold"}, + }, + { + LogicalID: "wechat_push", + WindowsExecutable: "wechat_push.exe", + UnixExecutable: "wechat_push", + Capabilities: []string{"network"}, + HandshakeCapabilities: []string{"network"}, + SettingsFields: []string{"appId", "templateId", "userId", "webDomain"}, + }, + { + LogicalID: "telegram_push", + WindowsExecutable: "pmail_telegram_push.exe", + UnixExecutable: "pmail_telegram_push", + Capabilities: []string{"network"}, + HandshakeCapabilities: []string{"network", "userSettings", "settingsHtml"}, + SettingsFields: []string{"proxy", "timeout", "debug", "webDomain", "httpsEnabled"}, + }, +} + +func Definitions() []Definition { + result := make([]Definition, len(definitions)) + for index, definition := range definitions { + result[index] = cloneDefinition(definition) + } + return result +} + +func Lookup(logicalID string) (Definition, bool) { + for _, definition := range definitions { + if definition.LogicalID == logicalID { + return cloneDefinition(definition), true + } + } + return Definition{}, false +} + +func ExecutableName(logicalID, goos string) (string, error) { + definition, ok := Lookup(logicalID) + if !ok { + return "", ErrUnknownPluginID + } + if goos == "windows" { + return definition.WindowsExecutable, nil + } + if goos == "linux" || goos == "darwin" { + return definition.UnixExecutable, nil + } + return "", ErrInvalidPluginTarget +} + +func CurrentExecutableName(logicalID string) (string, error) { + return ExecutableName(logicalID, runtime.GOOS) +} + +func EnabledDefinitions(values []string, goos string) ([]Definition, error) { + enabled := make(map[string]struct{}, len(values)) + for _, value := range values { + logicalID, err := LogicalIDFromValue(value, goos) + if err != nil { + return nil, err + } + if _, exists := enabled[logicalID]; exists { + return nil, ErrInvalidPluginTarget + } + enabled[logicalID] = struct{}{} + } + result := make([]Definition, 0, len(enabled)) + for _, definition := range definitions { + if _, ok := enabled[definition.LogicalID]; ok { + result = append(result, cloneDefinition(definition)) + } + } + sort.Slice(result, func(left, right int) bool { + return result[left].LogicalID < result[right].LogicalID + }) + return result, nil +} + +func LogicalIDFromValue(value, goos string) (string, error) { + value = strings.TrimSpace(value) + if value == "" || value != strings.ToLower(value) || strings.ContainsAny(value, `/\\*?[]`) { + return "", ErrInvalidPluginTarget + } + if _, ok := Lookup(value); ok { + return value, nil + } + for _, definition := range definitions { + executable, err := ExecutableName(definition.LogicalID, goos) + if err != nil { + return "", err + } + if value == executable { + return definition.LogicalID, nil + } + } + return "", ErrUnknownPluginID +} + +func IsCurrentExecutable(logicalID, executable string) bool { + expected, err := CurrentExecutableName(logicalID) + return err == nil && executable == expected +} + +func cloneDefinition(source Definition) Definition { + result := source + result.Capabilities = append([]string(nil), source.Capabilities...) + result.HandshakeCapabilities = append([]string(nil), source.HandshakeCapabilities...) + result.SettingsFields = append([]string(nil), source.SettingsFields...) + return result +} diff --git a/server/plugins/catalog/catalog_test.go b/server/plugins/catalog/catalog_test.go new file mode 100644 index 00000000..7b10c92c --- /dev/null +++ b/server/plugins/catalog/catalog_test.go @@ -0,0 +1,50 @@ +package catalog + +import "testing" + +func TestDefinitionsDeclareRuntimeCapabilities(t *testing.T) { + tests := map[string][]string{ + "spam_block": {"network"}, + "wechat_push": {"network"}, + "telegram_push": {"network"}, + } + for logicalID, want := range tests { + definition, ok := Lookup(logicalID) + if !ok { + t.Fatalf("plugin definition %q is missing", logicalID) + } + if len(definition.Capabilities) != len(want) || definition.Capabilities[0] != want[0] { + t.Fatalf("plugin %q capabilities = %#v, want %#v", logicalID, definition.Capabilities, want) + } + } +} + +func TestDefinitionsDeclareHandshakeAndSettings(t *testing.T) { + tests := map[string]struct { + capabilities []string + settings []string + }{ + "spam_block": {capabilities: []string{"network"}, settings: []string{"url", "timeout", "threshold"}}, + "wechat_push": {capabilities: []string{"network"}, settings: []string{"appId", "templateId", "userId", "webDomain"}}, + "telegram_push": {capabilities: []string{"network", "userSettings", "settingsHtml"}, settings: []string{"proxy", "timeout", "debug", "webDomain", "httpsEnabled"}}, + } + for logicalID, want := range tests { + definition, ok := Lookup(logicalID) + if !ok { + t.Fatalf("plugin definition %q is missing", logicalID) + } + if len(definition.HandshakeCapabilities) != len(want.capabilities) || len(definition.SettingsFields) != len(want.settings) { + t.Fatalf("plugin %q handshake declaration is incomplete: %+v", logicalID, definition) + } + for index, value := range want.capabilities { + if definition.HandshakeCapabilities[index] != value { + t.Fatalf("plugin %q handshake capabilities = %#v, want %#v", logicalID, definition.HandshakeCapabilities, want.capabilities) + } + } + for index, value := range want.settings { + if definition.SettingsFields[index] != value { + t.Fatalf("plugin %q settings = %#v, want %#v", logicalID, definition.SettingsFields, want.settings) + } + } + } +} diff --git a/server/res_init/init.go b/server/res_init/init.go index 3ec62882..7f5ce631 100644 --- a/server/res_init/init.go +++ b/server/res_init/init.go @@ -21,12 +21,14 @@ import ( "git.pcux.cn/xuans/Smail/services/adminreset" "git.pcux.cn/xuans/Smail/services/credentials" "git.pcux.cn/xuans/Smail/services/externalemail" + pluginservice "git.pcux.cn/xuans/Smail/services/plugin" "git.pcux.cn/xuans/Smail/services/recovery" "git.pcux.cn/xuans/Smail/services/setup/ssl" "git.pcux.cn/xuans/Smail/services/verification" webauthnservice "git.pcux.cn/xuans/Smail/services/webauthn" "git.pcux.cn/xuans/Smail/session" "git.pcux.cn/xuans/Smail/signal" + "git.pcux.cn/xuans/Smail/utils/credential" "git.pcux.cn/xuans/Smail/utils/file" log "github.com/sirupsen/logrus" // 导入 HTTP 客户端,用于等待服务启动。 @@ -35,6 +37,7 @@ import ( var adminResetControl adminreset.ControlServer var adminResetCancel context.CancelFunc +var adminResetServeErrors chan error var verificationRuntime *verification.Runtime var credentialService *credentials.Service var webAuthnRuntimeService *webauthnservice.Service @@ -78,6 +81,26 @@ func startConfigManager() error { func stopConfigManager() { config.SetRuntimeManager(nil) } +func startPluginConfigMigration() error { + hooks.SetPluginConfigService(nil) + manager := config.CurrentManager() + if manager == nil { + return nil + } + vault, err := credential.NewVault(config.ROOT_PATH) + if err != nil { + return err + } + service, err := pluginservice.NewConfigService(db.Instance, vault) + if err != nil { + return err + } + if _, err = manager.MigrateLegacyPluginSecrets(context.Background(), service.ImportLegacySecrets); err != nil { + return err + } + hooks.SetPluginConfigService(service) + return nil +} func Init(serverVersion string) error { cfg := config.CurrentConfig() if cfg == nil || !cfg.IsSetupReady() { @@ -120,6 +143,9 @@ func Init(serverVersion string) error { if err := startConfigManager(); err != nil { return err } + if err := startPluginConfigMigration(); err != nil { + log.WithError(err).Warn("plugin secret migration failed; affected plugins remain disabled") + } if err := session.Init(); err != nil { return err } @@ -130,8 +156,20 @@ func Init(serverVersion string) error { return err } startAdminResetControl() + if adminResetControl == nil { + stopServices() + return fmt.Errorf("administrator reset control is unavailable") + } + serviceErrors := make(chan error, 9) + adminResetErrors := adminResetServeErrors + if adminResetErrors != nil { + go func() { + if err := <-adminResetErrors; err != nil { + serviceErrors <- fmt.Errorf("administrator reset control failed: %w", err) + } + }() + } hooks.Init(serverVersion) - serviceErrors := make(chan error, 8) // smtp server start startService(serviceErrors, "SMTP", smtp_server.Start) startService(serviceErrors, "SMTP TLS", smtp_server.StartWithTLS) @@ -354,10 +392,13 @@ func startAdminResetControl() { adminResetControl = control ctx, cancel := context.WithCancel(context.Background()) adminResetCancel = cancel + serveErrors := make(chan error, 1) + adminResetServeErrors = serveErrors go func() { err := control.Serve(ctx, func(password string) error { return adminreset.ResetSuperAdmin(db.Instance, password, controllers.InvalidateSecurityRuntimeUser) }, adminreset.NewSessionGuard(2*time.Minute)) + serveErrors <- err if err != nil { log.WithError(err).Error("管理员重置通道启动失败") } @@ -375,6 +416,7 @@ func stopAdminResetControl() { log.WithError(err).Warn("闁稿繑濞婂Λ瀵告惥閸涱垶鐛撶紒鐙呯磿閹﹪宕ㄥΟ缁樻嫳闁哄牊妞介崳鍝ョ磾椤曗偓閳ь剚宀告禍鐐緞鏉堫偉袝") } adminResetControl = nil + adminResetServeErrors = nil } } diff --git a/server/services/adminreset/transport_test.go b/server/services/adminreset/transport_test.go index 4fd7191a..ff3607b9 100644 --- a/server/services/adminreset/transport_test.go +++ b/server/services/adminreset/transport_test.go @@ -129,3 +129,29 @@ func TestUnixControlSocketUsesRestrictedPermissions(t *testing.T) { t.Fatalf("control socket permissions = %04o, want 0600", socketInfo.Mode().Perm()) } } + +func TestUnixServerStopsWhenContextIsCancelled(t *testing.T) { + path := t.TempDir() + "/control.sock" + server, err := ListenUnix(path, []uint32{uint32(os.Getuid())}) + if err != nil { + t.Fatal(err) + } + ctx, cancel := context.WithCancel(context.Background()) + done := make(chan error, 1) + go func() { + done <- server.Serve(ctx, func(string) error { return nil }, NewSessionGuard(time.Minute)) + }() + + cancel() + if err := server.Close(); err != nil { + t.Fatal(err) + } + select { + case err := <-done: + if err != nil { + t.Fatalf("server stop error = %v", err) + } + case <-time.After(2 * time.Second): + t.Fatal("server did not stop after cancellation") + } +} diff --git a/server/services/adminreset/transport_unix.go b/server/services/adminreset/transport_unix.go index 3f2f3dd7..04ce9b87 100644 --- a/server/services/adminreset/transport_unix.go +++ b/server/services/adminreset/transport_unix.go @@ -116,6 +116,8 @@ func (s *UnixServer) handle(conn net.Conn, handler ResetHandler, guard *SessionG _ = EncodeResponse(conn, Response{Code: "UNAUTHORIZED", Message: "本机调用者身份不受信任"}) return } + _ = conn.SetDeadline(time.Now().Add(controlRequestTimeout)) + defer conn.SetDeadline(time.Time{}) nonce, err := guard.Issue() if err != nil { _ = EncodeResponse(conn, Response{Code: "CHANNEL_UNAVAILABLE", Message: "\u91cd\u7f6e\u901a\u9053\u4e0d\u53ef\u7528"}) diff --git a/server/services/plugin/catalog.go b/server/services/plugin/catalog.go new file mode 100644 index 00000000..c526bf94 --- /dev/null +++ b/server/services/plugin/catalog.go @@ -0,0 +1,30 @@ +package plugin + +import shared "git.pcux.cn/xuans/Smail/plugins/catalog" + +var ( + ErrUnknownPluginID = shared.ErrUnknownPluginID + ErrInvalidPluginTarget = shared.ErrInvalidPluginTarget +) + +type Definition = shared.Definition + +func Definitions() []Definition { + return shared.Definitions() +} + +func Lookup(logicalID string) (Definition, bool) { + return shared.Lookup(logicalID) +} + +func ExecutableName(logicalID, goos string) (string, error) { + return shared.ExecutableName(logicalID, goos) +} + +func CurrentExecutableName(logicalID string) (string, error) { + return shared.CurrentExecutableName(logicalID) +} + +func EnabledDefinitions(values []string, goos string) ([]Definition, error) { + return shared.EnabledDefinitions(values, goos) +} diff --git a/server/services/plugin/catalog_test.go b/server/services/plugin/catalog_test.go new file mode 100644 index 00000000..0840274e --- /dev/null +++ b/server/services/plugin/catalog_test.go @@ -0,0 +1,64 @@ +package plugin + +import ( + "errors" + "testing" +) + +func TestExecutableNameUsesFixedPlatformMapping(t *testing.T) { + cases := []struct { + logicalID string + goos string + want string + }{ + {logicalID: "spam_block", goos: "windows", want: "spam_block.exe"}, + {logicalID: "wechat_push", goos: "linux", want: "wechat_push"}, + {logicalID: "telegram_push", goos: "windows", want: "pmail_telegram_push.exe"}, + {logicalID: "telegram_push", goos: "darwin", want: "pmail_telegram_push"}, + } + for _, testCase := range cases { + t.Run(testCase.logicalID+"/"+testCase.goos, func(t *testing.T) { + got, err := ExecutableName(testCase.logicalID, testCase.goos) + if err != nil { + t.Fatal(err) + } + if got != testCase.want { + t.Fatalf("executable = %q", got) + } + }) + } +} + +func TestEnabledDefinitionsOnlyAcceptsRegisteredIdentifiers(t *testing.T) { + definitions, err := EnabledDefinitions([]string{"spam_block.exe", "wechat_push", "pmail_telegram_push.exe"}, "windows") + if err != nil { + t.Fatal(err) + } + if len(definitions) != 3 || definitions[0].LogicalID != "spam_block" || definitions[1].LogicalID != "telegram_push" || definitions[2].LogicalID != "wechat_push" { + t.Fatalf("definitions = %+v", definitions) + } + for _, value := range []string{"../spam_block", "Spam_Block", "unknown", "spam_block", "spam_block"} { + _, err := EnabledDefinitions([]string{value}, "linux") + if value == "spam_block" { + if err != nil { + t.Fatalf("logical ID was rejected: %v", err) + } + continue + } + if !errors.Is(err, ErrInvalidPluginTarget) && !errors.Is(err, ErrUnknownPluginID) { + t.Fatalf("value %q error = %v", value, err) + } + } + if _, err := EnabledDefinitions([]string{"spam_block", "spam_block.exe"}, "windows"); !errors.Is(err, ErrInvalidPluginTarget) { + t.Fatalf("duplicate error = %v", err) + } +} + +func TestDefinitionsReturnsIndependentCopies(t *testing.T) { + definitions := Definitions() + definitions[1].Capabilities[0] = "changed" + again := Definitions() + if again[1].Capabilities[0] != "network" { + t.Fatalf("catalog was mutated: %+v", again) + } +} diff --git a/server/services/plugin/config.go b/server/services/plugin/config.go new file mode 100644 index 00000000..7ae45efd --- /dev/null +++ b/server/services/plugin/config.go @@ -0,0 +1,755 @@ +package plugin + +import ( + "context" + "crypto/rand" + "crypto/sha256" + "encoding/hex" + "encoding/json" + "errors" + "fmt" + "regexp" + "sort" + "strings" + "sync" + "time" + + "git.pcux.cn/xuans/Smail/config" + "git.pcux.cn/xuans/Smail/models" + "git.pcux.cn/xuans/Smail/services/access" + "git.pcux.cn/xuans/Smail/utils/credential" + "xorm.io/xorm" +) + +const ( + telegramPluginID = "telegram_push" + userSettingsSchemaVersion uint32 = 1 + maxBulkTargets = 100 +) + +var ( + ErrPluginStoreUnavailable = errors.New("plugin configuration store unavailable") + ErrUnknownPluginField = errors.New("unknown plugin configuration field") + ErrInvalidTelegramChatID = errors.New("invalid Telegram chat ID") + ErrPluginSettingConflict = errors.New("plugin setting version conflict") + ErrPluginBulkPreviewDenied = errors.New("plugin bulk preview denied") + ErrPluginBulkTicketInvalid = errors.New("plugin bulk ticket is invalid or expired") + ErrLegacyPluginSecretConflict = errors.New("legacy plugin secret conflicts with existing secret") +) + +var telegramChatIDPattern = regexp.MustCompile(`^-?[1-9][0-9]{0,18}$`) + +// SecretStatus 仅描述敏感配置是否已设置,绝不包含密文或明文。 +type SecretStatus struct { + PluginID string `json:"pluginId"` + FieldName string `json:"fieldName"` + Configured bool `json:"configured"` + Version uint64 `json:"version"` +} + +// TelegramUserSettings 是 Telegram 插件唯一允许由用户维护的设置。 +type TelegramUserSettings struct { + ChatID string `json:"chatId"` +} + +// UserSettingsStatus 返回用户本人可见的设置与乐观锁版本。 +type UserSettingsStatus struct { + PluginID string `json:"pluginId"` + Settings TelegramUserSettings `json:"settings"` + Version uint64 `json:"version"` +} + +// BulkPreview 是短时一次性批量执行票据的非敏感预览。 +type BulkPreview struct { + Ticket string `json:"ticket"` + ExpiresAt time.Time `json:"expiresAt"` + Targets []BulkPreviewTarget `json:"targets"` +} + +type BulkPreviewTarget struct { + UserID int `json:"userId"` + Version uint64 `json:"version"` + WillWrite bool `json:"willWrite"` +} + +type pluginBulkTicket struct { + ActorUserID int + PluginID string + Settings string + Overwrite bool + Targets []bulkTarget + Digest string + ExpiresAt time.Time +} + +type bulkTarget struct { + UserID int + Version uint64 +} + +// ConfigService 是插件全局 Secret 和用户设置的唯一写服务。 +// HTTP 路由在 CG-025 完成能力接入前不得直接暴露本服务的写方法。 +type ConfigService struct { + engine *xorm.Engine + vault *credential.Vault + now func() time.Time + ticketsMu sync.Mutex + tickets map[string]pluginBulkTicket +} + +func NewConfigService(engine *xorm.Engine, vault *credential.Vault) (*ConfigService, error) { + if engine == nil || vault == nil { + return nil, ErrPluginStoreUnavailable + } + return &ConfigService{ + engine: engine, + vault: vault, + now: func() time.Time { return time.Now().UTC() }, + tickets: make(map[string]pluginBulkTicket), + }, nil +} + +// ImportLegacySecrets atomically stores compatibility-only V2 file secrets in plugin_secret. +// Existing values may only be reused when their plaintext matches the source value. +func (s *ConfigService) ImportLegacySecrets(ctx context.Context, values []config.LegacyPluginSecret) error { + if s == nil || s.engine == nil || s.vault == nil || len(values) == 0 { + return ErrPluginStoreUnavailable + } + if ctx == nil { + ctx = context.Background() + } + entries := append([]config.LegacyPluginSecret(nil), values...) + sort.Slice(entries, func(left, right int) bool { + if entries[left].PluginID == entries[right].PluginID { + return entries[left].FieldName < entries[right].FieldName + } + return entries[left].PluginID < entries[right].PluginID + }) + seen := make(map[string]struct{}, len(entries)) + for _, entry := range entries { + if err := ctx.Err(); err != nil { + return err + } + if err := validateSecretField(entry.PluginID, entry.FieldName); err != nil || entry.Plaintext == "" || len(entry.Plaintext) > 4096 { + return ErrUnknownPluginField + } + key := entry.PluginID + "\x00" + entry.FieldName + if _, exists := seen[key]; exists { + return ErrLegacyPluginSecretConflict + } + seen[key] = struct{}{} + } + + session := s.engine.NewSession() + defer session.Close() + if err := session.Begin(); err != nil { + return fmt.Errorf("begin legacy plugin secret transaction: %w", err) + } + rollback := func(cause error) error { + _ = session.Rollback() + return cause + } + now := s.currentTime() + for _, entry := range entries { + if err := ctx.Err(); err != nil { + return rollback(err) + } + record := models.PluginSecret{} + found, err := session.Where("plugin_id = ? AND field_name = ?", entry.PluginID, entry.FieldName).Get(&record) + if err != nil { + return rollback(fmt.Errorf("load legacy plugin secret: %w", err)) + } + if found { + plaintext, decryptErr := s.vault.Decrypt(record.KeyVersion, record.Ciphertext) + if decryptErr != nil || plaintext != entry.Plaintext { + return rollback(ErrLegacyPluginSecretConflict) + } + continue + } + ciphertext, encryptErr := s.vault.Encrypt(entry.Plaintext) + if encryptErr != nil { + return rollback(ErrPluginStoreUnavailable) + } + record = models.PluginSecret{ + PluginID: entry.PluginID, FieldName: entry.FieldName, Ciphertext: ciphertext, KeyVersion: s.vault.Version(), + RecordVersion: 1, CreatedAt: now, UpdatedAt: now, + } + if _, err = session.Insert(&record); err != nil { + return rollback(ErrLegacyPluginSecretConflict) + } + } + if err := session.Commit(); err != nil { + return fmt.Errorf("commit legacy plugin secret transaction: %w", err) + } + return nil +} + +func (s *ConfigService) GetSecretStatus(pluginID, fieldName string) (SecretStatus, error) { + if err := validateSecretField(pluginID, fieldName); err != nil { + return SecretStatus{}, err + } + record, found, err := s.findSecret(pluginID, fieldName) + if err != nil { + return SecretStatus{}, err + } + if !found { + return SecretStatus{PluginID: pluginID, FieldName: fieldName}, nil + } + return SecretStatus{PluginID: pluginID, FieldName: fieldName, Configured: true, Version: record.RecordVersion}, nil +} + +func (s *ConfigService) ChangeSecret(pluginID, fieldName string, change config.SecretChange, expectedVersion uint64) (SecretStatus, error) { + if err := validateSecretField(pluginID, fieldName); err != nil { + return SecretStatus{}, err + } + if s == nil || s.engine == nil || s.vault == nil { + return SecretStatus{}, ErrPluginStoreUnavailable + } + current, found, err := s.findSecret(pluginID, fieldName) + if err != nil { + return SecretStatus{}, err + } + currentVersion := uint64(0) + stored := config.StoredSecret{} + if found { + currentVersion = current.RecordVersion + stored = config.StoredSecret{Ciphertext: current.Ciphertext, Version: current.KeyVersion, UpdatedAt: current.UpdatedAt} + } + if currentVersion != expectedVersion { + return SecretStatus{}, ErrPluginSettingConflict + } + updated, err := config.ApplySecretChange(s.vault, stored, change, config.SecretPolicy{AllowClear: true, MaxLength: 4096}, s.currentTime()) + if err != nil { + return SecretStatus{}, err + } + + session := s.engine.NewSession() + defer session.Close() + if err = session.Begin(); err != nil { + return SecretStatus{}, fmt.Errorf("begin plugin secret transaction: %w", err) + } + rollback := func(cause error) (SecretStatus, error) { + _ = session.Rollback() + return SecretStatus{}, cause + } + if !updated.Configured() { + if found { + affected, deleteErr := session.ID(current.ID).Where("record_version = ?", expectedVersion).Delete(&models.PluginSecret{}) + if deleteErr != nil { + return rollback(fmt.Errorf("clear plugin secret: %w", deleteErr)) + } + if affected != 1 { + return rollback(ErrPluginSettingConflict) + } + } + if err = session.Commit(); err != nil { + return SecretStatus{}, fmt.Errorf("commit plugin secret clear: %w", err) + } + return SecretStatus{PluginID: pluginID, FieldName: fieldName}, nil + } + + now := s.currentTime() + if !found { + record := models.PluginSecret{ + PluginID: pluginID, FieldName: fieldName, Ciphertext: updated.Ciphertext, KeyVersion: updated.Version, + RecordVersion: 1, CreatedAt: now, UpdatedAt: now, + } + if _, err = session.Insert(&record); err != nil { + return rollback(ErrPluginSettingConflict) + } + if err = session.Commit(); err != nil { + return SecretStatus{}, fmt.Errorf("commit plugin secret create: %w", err) + } + return SecretStatus{PluginID: pluginID, FieldName: fieldName, Configured: true, Version: record.RecordVersion}, nil + } + newVersion := currentVersion + 1 + affected, updateErr := session.ID(current.ID).Where("record_version = ?", expectedVersion).Cols("ciphertext", "key_version", "record_version", "updated_at").Update(&models.PluginSecret{ + Ciphertext: updated.Ciphertext, KeyVersion: updated.Version, RecordVersion: newVersion, UpdatedAt: now, + }) + if updateErr != nil { + return rollback(fmt.Errorf("update plugin secret: %w", updateErr)) + } + if affected != 1 { + return rollback(ErrPluginSettingConflict) + } + if err = session.Commit(); err != nil { + return SecretStatus{}, fmt.Errorf("commit plugin secret update: %w", err) + } + return SecretStatus{PluginID: pluginID, FieldName: fieldName, Configured: true, Version: newVersion}, nil +} + +// openSecretForPlugin 仅供同进程的受控插件 DTO 组装逻辑使用,不能直接映射为 API 响应。 +func (s *ConfigService) openSecretForPlugin(pluginID, fieldName string) (string, error) { + if err := validateSecretField(pluginID, fieldName); err != nil { + return "", err + } + record, found, err := s.findSecret(pluginID, fieldName) + if err != nil { + return "", err + } + if !found { + return "", config.ErrSecretUnavailable + } + return config.OpenStoredSecret(s.vault, config.StoredSecret{Ciphertext: record.Ciphertext, Version: record.KeyVersion, UpdatedAt: record.UpdatedAt}) +} + +func (s *ConfigService) GetOwnTelegramSettings(actorUserID int) (UserSettingsStatus, error) { + if actorUserID <= 0 { + return UserSettingsStatus{}, ErrPluginStoreUnavailable + } + return s.getTelegramSettings(actorUserID) +} + +// UpdateOwnTelegramSettings 的 actorUserID 必须来自已验证 Session,调用方不得传入目标用户 ID。 +func (s *ConfigService) UpdateOwnTelegramSettings(actorUserID int, settings TelegramUserSettings, expectedVersion uint64) (UserSettingsStatus, error) { + + if actorUserID <= 0 { + + return UserSettingsStatus{}, ErrPluginStoreUnavailable + + } + + actor, found, err := s.findUser(actorUserID) + + if err != nil { + + return UserSettingsStatus{}, err + + } + + if !found || actor.Disabled != 0 { + + return UserSettingsStatus{}, ErrPluginStoreUnavailable + + } + + if err = access.Authorize(access.Request{ActorRole: actor.EffectiveRole(), Capability: access.CapabilityPluginWriteOwn, OwnResource: true}); err != nil { + + return UserSettingsStatus{}, err + + } + + return s.updateTelegramSettings(actorUserID, settings, expectedVersion) +} + +// UpdateTelegramSettingsForUser 查询目标账户的当前角色后才进行跨用户授权。 +func (s *ConfigService) UpdateTelegramSettingsForUser(actor models.User, targetUserID int, settings TelegramUserSettings, expectedVersion uint64) (UserSettingsStatus, error) { + if actor.ID <= 0 || targetUserID <= 0 { + return UserSettingsStatus{}, ErrPluginStoreUnavailable + } + target, found, err := s.findUser(targetUserID) + if err != nil { + return UserSettingsStatus{}, err + } + if !found || target.Disabled != 0 { + return UserSettingsStatus{}, ErrPluginStoreUnavailable + } + if err = access.Authorize(access.Request{ + ActorRole: actor.EffectiveRole(), Capability: access.CapabilityPluginWriteAnyUser, TargetRole: target.EffectiveRole(), + }); err != nil { + return UserSettingsStatus{}, err + } + return s.updateTelegramSettings(targetUserID, settings, expectedVersion) +} + +func (s *ConfigService) PreviewBulkTelegramSettings(actor models.User, targetUserIDs []int, settings TelegramUserSettings, overwrite bool) (BulkPreview, error) { + if actor.ID <= 0 || actor.EffectiveRole() != access.RoleSuperAdmin { + return BulkPreview{}, ErrPluginBulkPreviewDenied + } + payload, err := encodeTelegramSettings(settings) + if err != nil { + return BulkPreview{}, err + } + ids, err := normalizeTargetIDs(targetUserIDs) + if err != nil { + return BulkPreview{}, err + } + targets := make([]bulkTarget, 0, len(ids)) + previewTargets := make([]BulkPreviewTarget, 0, len(ids)) + for _, userID := range ids { + user, found, findErr := s.findUser(userID) + if findErr != nil { + return BulkPreview{}, findErr + } + if !found || user.Disabled != 0 { + return BulkPreview{}, ErrPluginBulkPreviewDenied + } + if authErr := access.Authorize(access.Request{ActorRole: actor.EffectiveRole(), Capability: access.CapabilityPluginWriteAnyUser, TargetRole: user.EffectiveRole()}); authErr != nil { + return BulkPreview{}, authErr + } + current, hasCurrent, getErr := s.findUserSetting(telegramPluginID, userID) + if getErr != nil { + return BulkPreview{}, getErr + } + version := uint64(0) + if hasCurrent { + version = current.Version + } + targets = append(targets, bulkTarget{UserID: userID, Version: version}) + previewTargets = append(previewTargets, BulkPreviewTarget{UserID: userID, Version: version, WillWrite: overwrite || !hasCurrent}) + } + now := s.currentTime() + ticket, err := randomTicket() + if err != nil { + return BulkPreview{}, fmt.Errorf("generate plugin bulk ticket: %w", err) + } + expiresAt := now.Add(5 * time.Minute) + entry := pluginBulkTicket{ActorUserID: actor.ID, PluginID: telegramPluginID, Settings: payload, Overwrite: overwrite, Targets: targets, ExpiresAt: expiresAt} + entry.Digest = bulkTicketDigest(entry) + s.ticketsMu.Lock() + s.removeExpiredTicketsLocked(now) + s.tickets[ticket] = entry + s.ticketsMu.Unlock() + return BulkPreview{Ticket: ticket, ExpiresAt: expiresAt, Targets: previewTargets}, nil +} + +// ExecuteBulkTelegramSettings 仅接收预览票据;目标集合、覆盖策略和版本均不能由执行请求修改。 +func (s *ConfigService) ExecuteBulkTelegramSettings(actorUserID int, ticket string) error { + if actorUserID <= 0 || strings.TrimSpace(ticket) == "" { + return ErrPluginBulkTicketInvalid + } + now := s.currentTime() + s.ticketsMu.Lock() + s.removeExpiredTicketsLocked(now) + entry, found := s.tickets[ticket] + if !found || entry.ActorUserID != actorUserID || entry.ExpiresAt.Before(now) || entry.Digest != bulkTicketDigest(entry) { + s.ticketsMu.Unlock() + return ErrPluginBulkTicketInvalid + } + delete(s.tickets, ticket) + s.ticketsMu.Unlock() + + actor, actorFound, err := s.findUser(actorUserID) + + if err != nil { + + return err + + } + + if !actorFound || actor.Disabled != 0 || actor.EffectiveRole() != access.RoleSuperAdmin { + + return ErrPluginBulkPreviewDenied + + } + + session := s.engine.NewSession() + defer session.Close() + if err := session.Begin(); err != nil { + return fmt.Errorf("begin plugin bulk transaction: %w", err) + } + rollback := func(cause error) error { + _ = session.Rollback() + return cause + } + for _, target := range entry.Targets { + if !entry.Overwrite && target.Version != 0 { + continue + } + if err := updateTelegramSettingsOnSession(session, s.vault, target.UserID, entry.Settings, target.Version, now); err != nil { + return rollback(err) + } + } + if err := session.Commit(); err != nil { + return fmt.Errorf("commit plugin bulk transaction: %w", err) + } + return nil +} + +func (s *ConfigService) getTelegramSettings(userID int) (UserSettingsStatus, error) { + + record, found, err := s.findUserSetting(telegramPluginID, userID) + + if err != nil { + + return UserSettingsStatus{}, err + + } + + if !found || !record.Enabled { + + return UserSettingsStatus{PluginID: telegramPluginID}, nil + + } + + if record.SchemaVersion != userSettingsSchemaVersion { + + return UserSettingsStatus{}, ErrPluginStoreUnavailable + + } + + plaintext, err := s.vault.Decrypt(credential.CurrentVersion, record.SettingsCiphertext) + + if err != nil { + + return UserSettingsStatus{}, ErrPluginStoreUnavailable + + } + + fingerprint, err := s.vault.Fingerprint(plaintext) + + if err != nil || fingerprint != record.SettingsHash { + + return UserSettingsStatus{}, ErrPluginStoreUnavailable + + } + + settings, err := decodeTelegramSettings(plaintext) + + if err != nil { + + return UserSettingsStatus{}, ErrPluginStoreUnavailable + + } + + return UserSettingsStatus{PluginID: telegramPluginID, Settings: settings, Version: record.Version}, nil +} + +func (s *ConfigService) updateTelegramSettings(userID int, settings TelegramUserSettings, expectedVersion uint64) (UserSettingsStatus, error) { + + payload, err := encodeTelegramSettings(settings) + + if err != nil { + + return UserSettingsStatus{}, err + + } + + session := s.engine.NewSession() + + defer session.Close() + + if err = session.Begin(); err != nil { + + return UserSettingsStatus{}, fmt.Errorf("begin user plugin setting transaction: %w", err) + + } + + if err = updateTelegramSettingsOnSession(session, s.vault, userID, payload, expectedVersion, s.currentTime()); err != nil { + + _ = session.Rollback() + + return UserSettingsStatus{}, err + + } + + if err = session.Commit(); err != nil { + + return UserSettingsStatus{}, fmt.Errorf("commit user plugin setting: %w", err) + + } + + return s.getTelegramSettings(userID) +} + +func updateTelegramSettingsOnSession(session *xorm.Session, vault *credential.Vault, userID int, payload string, expectedVersion uint64, now time.Time) error { + + if session == nil || vault == nil { + + return ErrPluginStoreUnavailable + + } + + ciphertext, err := vault.Encrypt(payload) + + if err != nil { + + return ErrPluginStoreUnavailable + + } + + fingerprint, err := vault.Fingerprint(payload) + + if err != nil { + + return ErrPluginStoreUnavailable + + } + + current := models.PluginUserSetting{} + + found, err := session.Where("plugin_id = ? AND user_id = ?", telegramPluginID, userID).Get(¤t) + + if err != nil { + + return fmt.Errorf("load user plugin setting: %w", err) + + } + + if !found { + + if expectedVersion != 0 { + + return ErrPluginSettingConflict + + } + + record := models.PluginUserSetting{PluginID: telegramPluginID, UserID: userID, SchemaVersion: userSettingsSchemaVersion, SettingsCiphertext: ciphertext, SettingsHash: fingerprint, Enabled: true, Version: 1, CreatedAt: now, UpdatedAt: now} + + if _, err = session.Insert(&record); err != nil { + + return ErrPluginSettingConflict + + } + + return nil + + } + + if current.Version != expectedVersion { + + return ErrPluginSettingConflict + + } + + affected, err := session.ID(current.ID).Where("version = ?", expectedVersion).Cols("schema_version", "settings_ciphertext", "settings_hash", "enabled", "version", "updated_at").Update(&models.PluginUserSetting{SchemaVersion: userSettingsSchemaVersion, SettingsCiphertext: ciphertext, SettingsHash: fingerprint, Enabled: true, Version: expectedVersion + 1, UpdatedAt: now}) + + if err != nil { + + return fmt.Errorf("update user plugin setting: %w", err) + + } + + if affected != 1 { + + return ErrPluginSettingConflict + + } + + return nil +} + +func (s *ConfigService) OpenSecretForPlugin(pluginID, fieldName string) (string, error) { + return s.openSecretForPlugin(pluginID, fieldName) +} + +func (s *ConfigService) findSecret(pluginID, fieldName string) (models.PluginSecret, bool, error) { + if s == nil || s.engine == nil { + return models.PluginSecret{}, false, ErrPluginStoreUnavailable + } + record := models.PluginSecret{} + found, err := s.engine.Where("plugin_id = ? AND field_name = ?", pluginID, fieldName).Get(&record) + if err != nil { + return models.PluginSecret{}, false, fmt.Errorf("load plugin secret: %w", err) + } + return record, found, nil +} + +func (s *ConfigService) findUserSetting(pluginID string, userID int) (models.PluginUserSetting, bool, error) { + if s == nil || s.engine == nil { + return models.PluginUserSetting{}, false, ErrPluginStoreUnavailable + } + record := models.PluginUserSetting{} + found, err := s.engine.Where("plugin_id = ? AND user_id = ?", pluginID, userID).Get(&record) + if err != nil { + return models.PluginUserSetting{}, false, fmt.Errorf("load user plugin setting: %w", err) + } + return record, found, nil +} + +func (s *ConfigService) findUser(userID int) (models.User, bool, error) { + user := models.User{} + found, err := s.engine.ID(userID).Get(&user) + if err != nil { + return models.User{}, false, fmt.Errorf("load plugin target user: %w", err) + } + return user, found, nil +} + +func (s *ConfigService) currentTime() time.Time { + if s != nil && s.now != nil { + return s.now().UTC() + } + return time.Now().UTC() +} + +func validateSecretField(pluginID, fieldName string) error { + if _, ok := Lookup(pluginID); !ok { + return ErrUnknownPluginID + } + switch pluginID { + case "wechat_push": + if fieldName == "appSecret" { + return nil + } + case telegramPluginID: + if fieldName == "botToken" { + return nil + } + } + return ErrUnknownPluginField +} + +func encodeTelegramSettings(settings TelegramUserSettings) (string, error) { + if !telegramChatIDPattern.MatchString(strings.TrimSpace(settings.ChatID)) || settings.ChatID != strings.TrimSpace(settings.ChatID) { + return "", ErrInvalidTelegramChatID + } + encoded, err := json.Marshal(settings) + if err != nil { + return "", err + } + return string(encoded), nil +} + +func decodeTelegramSettings(raw string) (TelegramUserSettings, error) { + decoder := json.NewDecoder(strings.NewReader(raw)) + decoder.DisallowUnknownFields() + var settings TelegramUserSettings + if err := decoder.Decode(&settings); err != nil { + return TelegramUserSettings{}, err + } + if decoder.More() { + return TelegramUserSettings{}, ErrInvalidTelegramChatID + } + _, err := encodeTelegramSettings(settings) + return settings, err +} + +func normalizeTargetIDs(values []int) ([]int, error) { + if len(values) == 0 || len(values) > maxBulkTargets { + return nil, ErrPluginBulkPreviewDenied + } + seen := make(map[int]struct{}, len(values)) + for _, value := range values { + if value <= 0 { + return nil, ErrPluginBulkPreviewDenied + } + if _, exists := seen[value]; exists { + return nil, ErrPluginBulkPreviewDenied + } + seen[value] = struct{}{} + } + result := append([]int(nil), values...) + sort.Ints(result) + return result, nil +} + +func randomTicket() (string, error) { + value := make([]byte, 32) + if _, err := rand.Read(value); err != nil { + return "", err + } + return hex.EncodeToString(value), nil +} + +func bulkTicketDigest(entry pluginBulkTicket) string { + payload := struct { + ActorUserID int + PluginID string + Settings string + Overwrite bool + Targets []bulkTarget + ExpiresAt time.Time + }{entry.ActorUserID, entry.PluginID, entry.Settings, entry.Overwrite, entry.Targets, entry.ExpiresAt} + encoded, _ := json.Marshal(payload) + digest := sha256.Sum256(encoded) + return hex.EncodeToString(digest[:]) +} + +func (s *ConfigService) removeExpiredTicketsLocked(now time.Time) { + for ticket, entry := range s.tickets { + if !entry.ExpiresAt.After(now) { + delete(s.tickets, ticket) + } + } +} diff --git a/server/services/plugin/config_test.go b/server/services/plugin/config_test.go new file mode 100644 index 00000000..906d7921 --- /dev/null +++ b/server/services/plugin/config_test.go @@ -0,0 +1,186 @@ +package plugin + +import ( + "context" + "errors" + "path/filepath" + "testing" + "time" + + "git.pcux.cn/xuans/Smail/config" + "git.pcux.cn/xuans/Smail/db/migration" + "git.pcux.cn/xuans/Smail/models" + "git.pcux.cn/xuans/Smail/services/access" + "git.pcux.cn/xuans/Smail/utils/credential" + _ "modernc.org/sqlite" + "xorm.io/xorm" +) + +func TestConfigServiceStoresPluginSecretsAsCiphertext(t *testing.T) { + service, engine := newPluginConfigService(t) + status, err := service.ChangeSecret("telegram_push", "botToken", config.SecretChange{ + Operation: config.SecretReplace, + Value: &config.SecretInput{Plaintext: "telegram-token-for-test"}, + }, 0) + if err != nil { + t.Fatal(err) + } + if !status.Configured || status.Version != 1 { + t.Fatalf("status = %+v", status) + } + if _, err = service.ChangeSecret("telegram_push", "unknown", config.SecretChange{}, 0); !errors.Is(err, ErrUnknownPluginField) { + t.Fatalf("unknown field error = %v", err) + } + + record := models.PluginSecret{} + found, err := engine.Where("plugin_id = ? AND field_name = ?", "telegram_push", "botToken").Get(&record) + if err != nil || !found { + t.Fatalf("load secret record: found=%v err=%v", found, err) + } + if record.Ciphertext == "telegram-token-for-test" || record.Ciphertext == "" || record.KeyVersion == 0 { + t.Fatalf("secret is not safely stored: %+v", record) + } + visible, err := service.GetSecretStatus("telegram_push", "botToken") + if err != nil || !visible.Configured || visible.Version != record.RecordVersion { + t.Fatalf("visible status = %+v, err=%v", visible, err) + } + if _, err = engine.ID(record.ID).Cols("ciphertext").Update(&models.PluginSecret{Ciphertext: "smail:v1:tampered"}); err != nil { + t.Fatal(err) + } + if _, err = service.openSecretForPlugin("telegram_push", "botToken"); err == nil { + t.Fatal("tampered ciphertext was accepted") + } +} + +func TestConfigServiceEncryptsTelegramUserSettingsAndRejectsTampering(t *testing.T) { + service, engine := newPluginConfigService(t) + user := insertPluginTestUser(t, engine, "user", access.RoleUser) + status, err := service.UpdateOwnTelegramSettings(user.ID, TelegramUserSettings{ChatID: "-100123456"}, 0) + if err != nil || status.Version != 1 { + t.Fatalf("update status = %+v, err=%v", status, err) + } + record := models.PluginUserSetting{} + found, err := engine.Where("plugin_id = ? AND user_id = ?", telegramPluginID, user.ID).Get(&record) + if err != nil || !found { + t.Fatalf("load user setting: found=%v err=%v", found, err) + } + if record.SettingsCiphertext == `{"chatId":"-100123456"}` || record.SettingsCiphertext == "" || record.SettingsHash == "" || !record.Enabled || record.SchemaVersion != userSettingsSchemaVersion { + t.Fatalf("user setting is not safely stored: %+v", record) + } + if _, err = engine.ID(record.ID).Cols("settings_hash").Update(&models.PluginUserSetting{SettingsHash: "tampered"}); err != nil { + t.Fatal(err) + } + if _, err = service.GetOwnTelegramSettings(user.ID); !errors.Is(err, ErrPluginStoreUnavailable) { + t.Fatalf("tampered user setting error = %v", err) + } +} +func TestConfigServiceEnforcesUserSettingRolesAndVersions(t *testing.T) { + service, engine := newPluginConfigService(t) + super := insertPluginTestUser(t, engine, "root", access.RoleSuperAdmin) + admin := insertPluginTestUser(t, engine, "admin", access.RoleAdmin) + secondAdmin := insertPluginTestUser(t, engine, "admin2", access.RoleAdmin) + user := insertPluginTestUser(t, engine, "user", access.RoleUser) + + own, err := service.UpdateOwnTelegramSettings(user.ID, TelegramUserSettings{ChatID: "123456"}, 0) + if err != nil || own.Version != 1 { + t.Fatalf("own update = %+v, err=%v", own, err) + } + updated, err := service.UpdateTelegramSettingsForUser(admin, user.ID, TelegramUserSettings{ChatID: "-100123456"}, own.Version) + if err != nil || updated.Version != 2 { + t.Fatalf("admin update = %+v, err=%v", updated, err) + } + if _, err = service.UpdateTelegramSettingsForUser(admin, secondAdmin.ID, TelegramUserSettings{ChatID: "1"}, 0); !access.IsDenied(err, access.CodeTargetRoleDenied) { + t.Fatalf("admin writes admin error = %v", err) + } + if _, err = service.UpdateTelegramSettingsForUser(user, admin.ID, TelegramUserSettings{ChatID: "1"}, 0); !access.IsDenied(err, access.CodeAccessDenied) { + t.Fatalf("user cross-account error = %v", err) + } + if _, err = service.UpdateTelegramSettingsForUser(super, secondAdmin.ID, TelegramUserSettings{ChatID: "2"}, 0); err != nil { + t.Fatalf("super update admin: %v", err) + } + if _, err = service.UpdateOwnTelegramSettings(user.ID, TelegramUserSettings{ChatID: "777"}, own.Version); !errors.Is(err, ErrPluginSettingConflict) { + t.Fatalf("stale version error = %v", err) + } + if _, err = service.UpdateOwnTelegramSettings(user.ID, TelegramUserSettings{ChatID: "001"}, updated.Version); !errors.Is(err, ErrInvalidTelegramChatID) { + t.Fatalf("invalid chat ID error = %v", err) + } +} + +func TestConfigServiceBulkTicketIsBoundOneTimeAndVersioned(t *testing.T) { + service, engine := newPluginConfigService(t) + super := insertPluginTestUser(t, engine, "root", access.RoleSuperAdmin) + first := insertPluginTestUser(t, engine, "first", access.RoleUser) + second := insertPluginTestUser(t, engine, "second", access.RoleUser) + + preview, err := service.PreviewBulkTelegramSettings(super, []int{second.ID, first.ID}, TelegramUserSettings{ChatID: "123"}, false) + if err != nil || len(preview.Targets) != 2 || preview.Targets[0].UserID != first.ID { + t.Fatalf("preview = %+v, err=%v", preview, err) + } + if err = service.ExecuteBulkTelegramSettings(super.ID, preview.Ticket); err != nil { + t.Fatal(err) + } + if err = service.ExecuteBulkTelegramSettings(super.ID, preview.Ticket); !errors.Is(err, ErrPluginBulkTicketInvalid) { + t.Fatalf("ticket replay error = %v", err) + } + firstStatus, err := service.GetOwnTelegramSettings(first.ID) + if err != nil || firstStatus.Version != 1 || firstStatus.Settings.ChatID != "123" { + t.Fatalf("first setting = %+v, err=%v", firstStatus, err) + } + + conflicting, err := service.PreviewBulkTelegramSettings(super, []int{first.ID}, TelegramUserSettings{ChatID: "456"}, true) + if err != nil { + t.Fatal(err) + } + if _, err = service.UpdateOwnTelegramSettings(first.ID, TelegramUserSettings{ChatID: "789"}, firstStatus.Version); err != nil { + t.Fatal(err) + } + if err = service.ExecuteBulkTelegramSettings(super.ID, conflicting.Ticket); !errors.Is(err, ErrPluginSettingConflict) { + t.Fatalf("bulk version conflict error = %v", err) + } + if err = service.ExecuteBulkTelegramSettings(first.ID, conflicting.Ticket); !errors.Is(err, ErrPluginBulkTicketInvalid) { + t.Fatalf("actor-bound ticket error = %v", err) + } + + base := time.Date(2026, time.August, 28, 8, 0, 0, 0, time.UTC) + service.now = func() time.Time { return base } + expiring, err := service.PreviewBulkTelegramSettings(super, []int{second.ID}, TelegramUserSettings{ChatID: "999"}, true) + if err != nil { + t.Fatal(err) + } + service.now = func() time.Time { return base.Add(6 * time.Minute) } + if err = service.ExecuteBulkTelegramSettings(super.ID, expiring.Ticket); !errors.Is(err, ErrPluginBulkTicketInvalid) { + t.Fatalf("expired ticket error = %v", err) + } +} + +func newPluginConfigService(t *testing.T) (*ConfigService, *xorm.Engine) { + t.Helper() + engine, err := xorm.NewEngine("sqlite", filepath.Join(t.TempDir(), "plugin-config.db")) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { _ = engine.Close() }) + runner := migration.Runner{DB: engine.DB().DB, Dialect: migration.DialectSQLite, Migrations: migration.DefaultMigrations()} + if _, err = runner.Run(context.Background()); err != nil { + t.Fatal(err) + } + vault, err := credential.NewVault(t.TempDir()) + if err != nil { + t.Fatal(err) + } + service, err := NewConfigService(engine, vault) + if err != nil { + t.Fatal(err) + } + return service, engine +} + +func insertPluginTestUser(t *testing.T, engine *xorm.Engine, account string, role access.Role) models.User { + t.Helper() + user := models.User{Account: account, Name: account, Password: "hash"} + user.ApplyRole(role) + if _, err := engine.Insert(&user); err != nil { + t.Fatal(err) + } + return user +} diff --git a/server/services/setup/db.go b/server/services/setup/db.go index f794aba0..6e3cd906 100644 --- a/server/services/setup/db.go +++ b/server/services/setup/db.go @@ -1,7 +1,18 @@ package setup import ( + stdcontext "context" + "database/sql" + stderrors "errors" + "fmt" + "net" + "net/url" + "os" + "path/filepath" + "strconv" + "strings" "sync" + "time" "git.pcux.cn/xuans/Smail/config" "git.pcux.cn/xuans/Smail/db" @@ -11,8 +22,49 @@ import ( "git.pcux.cn/xuans/Smail/utils/context" "git.pcux.cn/xuans/Smail/utils/errors" "git.pcux.cn/xuans/Smail/utils/validation" + "github.com/go-sql-driver/mysql" + "github.com/lib/pq" ) +type DatabaseSettings struct { + Type string + DSN string + Mode string + User string + Host string + Port string + Password string + Name string +} + +type databaseSetupError struct { + Message string + Cause error +} + +func (e *databaseSetupError) Error() string { + if e.Cause == nil { + return e.Message + } + return fmt.Sprintf("%s: %v", e.Message, e.Cause) +} + +func (e *databaseSetupError) Unwrap() error { + return e.Cause +} + +func databaseError(message string, cause error) error { + return &databaseSetupError{Message: message, Cause: cause} +} + +func DatabaseSetupErrorMessage(err error) string { + var setupErr *databaseSetupError + if errors.As(err, &setupErr) { + return setupErr.Message + } + return "" +} + func GetDatabaseSettings(ctx *context.Context) (string, string, error) { configData, err := config.ReadConfig() if err != nil { @@ -24,7 +76,67 @@ func GetDatabaseSettings(ctx *context.Context) (string, string, error) { return configData.DbType, configData.DbDSN, nil } +func GetDatabaseSettingsDetail(ctx *context.Context) (map[string]string, error) { + dbType, dbDSN, err := GetDatabaseSettings(ctx) + if err != nil { + return nil, err + } + + result := map[string]string{ + "db_type": dbType, + "db_dsn": dbDSN, + "db_mode": "dsn", + } + if dbType == config.DBTypeSQLite { + if strings.TrimSpace(result["db_dsn"]) == "" { + result["db_dsn"] = config.ROOT_PATH + "./config/smail.db" + } + return result, nil + } + if dbType == config.DBTypePostgres { + parsed, ok := parsePostgresURL(dbDSN) + if !ok { + return result, nil + } + host, port := splitDatabaseAddress(parsed.Host) + result["db_mode"] = "fields" + result["db_dsn"] = "" + result["db_user"] = parsed.User.Username() + result["db_host"] = host + result["db_port"] = port + result["db_name"] = strings.TrimPrefix(parsed.Path, "/") + return result, nil + } + if dbType != config.DBTypeMySQL { + return result, nil + } + + parsed, err := mysql.ParseDSN(dbDSN) + if err != nil { + return map[string]string{ + "db_type": dbType, + "db_dsn": "", + "db_mode": "fields", + "db_host": "127.0.0.1", + "db_port": "3306", + "db_name": "smail", + }, nil + } + host, port := splitMySQLAddress(parsed.Addr) + result["db_mode"] = "fields" + // MySQL 密码不能通过初始化接口返回,页面重新提交时由后端尝试复用原密码。 + result["db_dsn"] = "" + result["db_user"] = parsed.User + result["db_host"] = host + result["db_port"] = port + result["db_name"] = parsed.DBName + return result, nil +} + func GetAdminPassword(ctx *context.Context) (string, error) { + if db.Instance == nil { + return "", databaseError("\u6570\u636e\u5e93\u5c1a\u672a\u521d\u59cb\u5316\uff0c\u8bf7\u5148\u5b8c\u6210\u6570\u636e\u5e93\u8bbe\u7f6e", nil) + } users := []*models.User{} if err := db.Instance.Find(&users); err != nil { return "", errors.Wrap(err) @@ -40,6 +152,13 @@ var adminSetupMutex sync.Mutex func SetAdminPassword(ctx *context.Context, account, pwd string) error { adminSetupMutex.Lock() defer adminSetupMutex.Unlock() + if db.Instance == nil { + return databaseError("\u6570\u636e\u5e93\u5c1a\u672a\u521d\u59cb\u5316\uff0c\u8bf7\u5148\u5b8c\u6210\u6570\u636e\u5e93\u8bbe\u7f6e", nil) + } + + if err := validateAdminPassword(pwd); err != nil { + return err + } account, err := validation.NormalizeAccount(account) if err != nil { @@ -62,27 +181,416 @@ func SetAdminPassword(ctx *context.Context, account, pwd string) error { return nil } +func validateAdminPassword(pwd string) error { + passwordSize := len([]byte(pwd)) + if passwordSize < 8 || passwordSize > 12 { + return databaseError("管理员密码长度必须为 8 到 12 个字节", nil) + } + return nil +} + func SetDatabaseSettings(ctx *context.Context, dbType, dbDSN string) error { + return SetDatabaseSettingsWithOptions(ctx, DatabaseSettings{ + Type: dbType, + DSN: dbDSN, + }) +} + +var databaseSetupMutex sync.Mutex + +func SetDatabaseSettingsWithOptions(ctx *context.Context, settings DatabaseSettings) error { + databaseSetupMutex.Lock() + defer databaseSetupMutex.Unlock() + configData, err := config.ReadConfig() if err != nil { return errors.Wrap(err) } + dbType := strings.TrimSpace(settings.Type) if !array.InArray(dbType, config.DBTypes) { return errors.New("dbtype error") } + + dbDSN := strings.TrimSpace(settings.DSN) + if settings.Mode == "fields" { + switch dbType { + case config.DBTypeMySQL: + dbDSN, err = buildMySQLDSN(settings, configData.DbDSN) + case config.DBTypePostgres: + dbDSN, err = buildPostgresDSN(settings, configData.DbDSN) + } + if err != nil { + return databaseError(strings.SplitN(err.Error(), " at ", 2)[0], err) + } + } + if dbType == config.DBTypeSQLite { + if dbDSN == "" { + dbDSN = config.ROOT_PATH + "./config/smail.db" + } + if err = prepareSQLiteDatabase(dbDSN); err != nil { + return databaseError("准备 SQLite 数据文件失败", err) + } + } if dbDSN == "" { return errors.New("DSN error") } - configData.DbType = dbType - configData.DbDSN = dbDSN - if err = config.WriteConfig(configData); err != nil { + switch dbType { + case config.DBTypeMySQL: + if err = ensureMySQLDatabase(dbDSN); err != nil { + return err + } + case config.DBTypePostgres: + if err = ensurePostgresDatabase(dbDSN); err != nil { + return err + } + } + + previousConfig := *configData + candidateConfig := *configData + candidateConfig.DbType = dbType + candidateConfig.DbDSN = dbDSN + if err = config.WriteConfig(&candidateConfig); err != nil { return errors.Wrap(err) } if err = config.Init(); err != nil { + restoreDatabaseConfig(&previousConfig) return errors.Wrap(err) } + closeDatabaseInstance() if err = db.Init(""); err != nil { + restoreDatabaseConfig(&previousConfig) return errors.Wrap(err) } return nil } + +func closeDatabaseInstance() { + if db.Instance == nil { + return + } + _ = db.Instance.Close() + db.Instance = nil +} + +func buildPostgresDSN(settings DatabaseSettings, previousDSN string) (string, error) { + user := strings.TrimSpace(settings.User) + if user == "" { + return "", errors.New("PostgreSQL 用户不能为空") + } + host := strings.TrimSpace(settings.Host) + if host == "" { + host = "127.0.0.1" + } + host = normalizeDatabaseHost(host) + portText := strings.TrimSpace(settings.Port) + if portText == "" { + portText = "5432" + } + port, err := strconv.Atoi(portText) + if err != nil || port < 1 || port > 65535 { + return "", errors.New("PostgreSQL 端口必须是 1 到 65535 之间的数字") + } + databaseName := strings.TrimSpace(settings.Name) + if databaseName == "" { + databaseName = "smail" + } + if !validPostgresIdentifier(databaseName) { + return "", errors.New("数据库名只能包含字母、数字和下划线") + } + + password := settings.Password + previous, previousOK := parsePostgresURL(previousDSN) + if password == "" && previousOK && postgresSettingsMatch(previous, user, host, strconv.Itoa(port), databaseName) { + if previousPassword, ok := previous.User.Password(); ok { + password = previousPassword + } + } + query := url.Values{} + if previousOK && previous.RawQuery != "" { + query = previous.Query() + } + if query.Get("sslmode") == "" { + query.Set("sslmode", "disable") + } + parsed := &url.URL{ + Scheme: "postgres", + User: url.UserPassword(user, password), + Host: net.JoinHostPort(host, strconv.Itoa(port)), + Path: "/" + databaseName, + RawQuery: query.Encode(), + } + return parsed.String(), nil +} + +func parsePostgresURL(dsn string) (*url.URL, bool) { + parsed, err := url.Parse(strings.TrimSpace(dsn)) + if err != nil || (parsed.Scheme != "postgres" && parsed.Scheme != "postgresql") || parsed.Host == "" || parsed.User == nil { + return nil, false + } + name := strings.TrimPrefix(parsed.Path, "/") + return parsed, name != "" +} + +func postgresSettingsMatch(parsed *url.URL, user, host, port, name string) bool { + parsedHost, parsedPort := splitDatabaseAddress(parsed.Host) + return parsed.User.Username() == user && parsedHost == host && parsedPort == port && strings.TrimPrefix(parsed.Path, "/") == name +} + +func splitDatabaseAddress(address string) (string, string) { + address = strings.TrimSpace(address) + if host, port, err := net.SplitHostPort(address); err == nil { + return strings.Trim(host, "[]"), port + } + if address == "" { + return "127.0.0.1", "5432" + } + return strings.Trim(address, "[]"), "5432" +} + +func normalizeDatabaseHost(host string) string { + if len(host) >= 2 && strings.HasPrefix(host, "[") && strings.HasSuffix(host, "]") { + return host[1 : len(host)-1] + } + return host +} + +func validPostgresIdentifier(value string) bool { + if len(value) == 0 || len(value) > 63 { + return false + } + for _, char := range value { + if (char < 'a' || char > 'z') && (char < 'A' || char > 'Z') && (char < '0' || char > '9') && char != '_' { + return false + } + } + return true +} + +func prepareSQLiteDatabase(dsn string) error { + dsn = strings.TrimSpace(dsn) + if dsn == ":memory:" || strings.HasPrefix(dsn, "file::memory:") { + return nil + } + path := dsn + if strings.HasPrefix(path, "file:") { + path = strings.TrimPrefix(path, "file:") + path = strings.SplitN(path, "?", 2)[0] + } + if path == "" || path == ":memory:" { + return nil + } + directory := filepath.Dir(path) + if directory == "." || directory == "" { + return nil + } + return os.MkdirAll(directory, 0750) +} + +func buildMySQLDSN(settings DatabaseSettings, previousDSN string) (string, error) { + user := strings.TrimSpace(settings.User) + if user == "" { + return "", errors.New("MySQL 用户不能为空") + } + host := strings.TrimSpace(settings.Host) + if host == "" { + host = "127.0.0.1" + } + host = normalizeMySQLHost(host) + portText := strings.TrimSpace(settings.Port) + if portText == "" { + portText = "3306" + } + port, err := strconv.Atoi(portText) + if err != nil || port < 1 || port > 65535 { + return "", errors.New("MySQL 端口必须是 1 到 65535 之间的数字") + } + databaseName := strings.TrimSpace(settings.Name) + if databaseName == "" { + databaseName = "smail" + } + if !validMySQLIdentifier(databaseName) { + return "", errors.New("数据库名只能包含字母、数字和下划线") + } + + password := settings.Password + if password == "" { + password = previousMySQLPassword(previousDSN, user, host, strconv.Itoa(port), databaseName) + } + dsnConfig := mysql.NewConfig() + dsnConfig.User = user + dsnConfig.Passwd = password + dsnConfig.Net = "tcp" + dsnConfig.Addr = net.JoinHostPort(host, strconv.Itoa(port)) + dsnConfig.DBName = databaseName + dsnConfig.ParseTime = true + dsnConfig.Loc = time.Local + dsnConfig.Params = map[string]string{"charset": "utf8mb4"} + return dsnConfig.FormatDSN(), nil +} + +func previousMySQLPassword(previousDSN, user, host, port, databaseName string) string { + previous, err := mysql.ParseDSN(previousDSN) + if err != nil || previous.User != user || previous.DBName != databaseName { + return "" + } + previousHost, previousPort := splitMySQLAddress(previous.Addr) + if previousHost != host || previousPort != port { + return "" + } + return previous.Passwd +} + +func splitMySQLAddress(address string) (string, string) { + address = strings.TrimSpace(address) + if host, port, err := net.SplitHostPort(address); err == nil { + return strings.Trim(host, "[]"), port + } + if address == "" { + return "127.0.0.1", "3306" + } + return strings.Trim(address, "[]"), "3306" +} + +func normalizeMySQLHost(host string) string { + host = strings.TrimSpace(host) + if len(host) >= 2 && strings.HasPrefix(host, "[") && strings.HasSuffix(host, "]") { + return host[1 : len(host)-1] + } + return host +} + +func validMySQLIdentifier(value string) bool { + if len(value) == 0 || len(value) > 64 { + return false + } + for _, char := range value { + if (char < 'a' || char > 'z') && (char < 'A' || char > 'Z') && (char < '0' || char > '9') && char != '_' { + return false + } + } + return true +} + +var openMySQLSetupDatabase = func(dsn string) (setupDatabase, error) { + return sql.Open("mysql", dsn) +} + +var openPostgresSetupDatabase = func(dsn string) (setupDatabase, error) { + return sql.Open("postgres", dsn) +} + +func ensurePostgresDatabase(dsn string) error { + parsed, ok := parsePostgresURL(dsn) + if !ok { + return nil + } + databaseName := strings.TrimPrefix(parsed.Path, "/") + if !validPostgresIdentifier(databaseName) { + return databaseError("PostgreSQL 数据库名无效", nil) + } + + requestContext, cancel := stdcontext.WithTimeout(stdcontext.Background(), 15*time.Second) + defer cancel() + target, err := openPostgresSetupDatabase(dsn) + if err != nil { + return databaseError("连接 PostgreSQL 数据库失败", err) + } + defer func() { _ = target.Close() }() + if err = target.PingContext(requestContext); err == nil { + return nil + } else { + var postgresErr *pq.Error + if !stderrors.As(err, &postgresErr) || string(postgresErr.Code) != "3D000" { + return databaseError("连接 PostgreSQL 数据库失败,请检查用户、密码、主机、端口和数据库名", err) + } + } + + adminURL := *parsed + adminURL.Path = "/postgres" + adminURL.RawPath = "" + admin, err := openPostgresSetupDatabase(adminURL.String()) + if err != nil { + return databaseError("连接 PostgreSQL 服务器失败", err) + } + defer func() { _ = admin.Close() }() + if err = admin.PingContext(requestContext); err != nil { + return databaseError("连接 PostgreSQL 服务器失败,请检查用户、密码、主机和端口", err) + } + query := `CREATE DATABASE "` + databaseName + `"` + if _, err = admin.ExecContext(requestContext, query); err != nil { + var postgresErr *pq.Error + if !stderrors.As(err, &postgresErr) || string(postgresErr.Code) != "42P04" { + return databaseError("自动创建 PostgreSQL 数据库失败,请确认当前用户具有建库权限", err) + } + } + if err = target.PingContext(requestContext); err != nil { + return databaseError("PostgreSQL 数据库创建后仍无法连接", err) + } + return nil +} + +type setupDatabase interface { + PingContext(stdcontext.Context) error + ExecContext(stdcontext.Context, string, ...any) (sql.Result, error) + Close() error +} + +func ensureMySQLDatabase(dsn string) error { + parsed, err := mysql.ParseDSN(dsn) + if err != nil { + return databaseError("MySQL 连接信息格式错误", err) + } + if parsed.DBName == "" || !validMySQLIdentifier(parsed.DBName) { + return databaseError("MySQL 数据库名无效", nil) + } + + requestContext, cancel := stdcontext.WithTimeout(stdcontext.Background(), 15*time.Second) + defer cancel() + + target, err := openMySQLSetupDatabase(dsn) + if err != nil { + return databaseError("连接 MySQL 数据库失败", err) + } + defer func() { _ = target.Close() }() + if err = target.PingContext(requestContext); err == nil { + return nil + } else { + var mysqlErr *mysql.MySQLError + if !errors.As(err, &mysqlErr) || mysqlErr.Number != 1049 { + return databaseError("连接 MySQL 数据库失败,请检查用户、密码、主机、端口和数据库名", err) + } + } + + adminConfig := parsed.Clone() + adminConfig.DBName = "" + admin, err := openMySQLSetupDatabase(adminConfig.FormatDSN()) + if err != nil { + return databaseError("连接 MySQL 服务器失败", err) + } + defer func() { _ = admin.Close() }() + if err = admin.PingContext(requestContext); err != nil { + return databaseError("连接 MySQL 服务器失败,请检查用户、密码、主机和端口", err) + } + query := "CREATE DATABASE IF NOT EXISTS `" + parsed.DBName + "` DEFAULT CHARACTER SET utf8mb4" + if _, err = admin.ExecContext(requestContext, query); err != nil { + return databaseError("自动创建 MySQL 数据库失败,请确认当前用户具有建库权限", err) + } + if err = target.PingContext(requestContext); err != nil { + return databaseError("MySQL 数据库创建后仍无法连接", err) + } + return nil +} + +func restoreDatabaseConfig(previous *config.Config) { + if previous == nil { + return + } + closeDatabaseInstance() + if err := config.WriteConfig(previous); err != nil { + return + } + _ = config.Init() + if previous.DbType != "" && previous.DbDSN != "" { + _ = db.Init("") + } +} diff --git a/server/services/setup/db_database_test.go b/server/services/setup/db_database_test.go new file mode 100644 index 00000000..21f43d91 --- /dev/null +++ b/server/services/setup/db_database_test.go @@ -0,0 +1,328 @@ +package setup + +import ( + "context" + "database/sql" + stderrors "errors" + "os" + "path/filepath" + "strings" + "testing" + + "github.com/go-sql-driver/mysql" + "github.com/lib/pq" +) + +type fakeSetupDB struct { + pingErrors []error + pingCalls int + execQueries []string + execError error + closed bool +} + +func (database *fakeSetupDB) PingContext(context.Context) error { + index := database.pingCalls + database.pingCalls++ + if index < len(database.pingErrors) { + return database.pingErrors[index] + } + return nil +} + +func (database *fakeSetupDB) ExecContext(_ context.Context, query string, _ ...any) (sql.Result, error) { + database.execQueries = append(database.execQueries, query) + return fakeSetupResult(0), database.execError +} + +func (database *fakeSetupDB) Close() error { + database.closed = true + return nil +} + +type fakeSetupResult int64 + +func (result fakeSetupResult) LastInsertId() (int64, error) { + return int64(result), nil +} + +func (result fakeSetupResult) RowsAffected() (int64, error) { + return int64(result), nil +} + +func TestBuildMySQLDSNUsesStructuredFields(t *testing.T) { + dsn, err := buildMySQLDSN(DatabaseSettings{ + User: "root", + Host: "[2001:db8::1]", + Port: "03306", + Password: "p@ss:/?#[]", + Name: "smail_1", + }, "") + if err != nil { + t.Fatal(err) + } + + parsed, err := mysql.ParseDSN(dsn) + if err != nil { + t.Fatal(err) + } + if parsed.User != "root" || parsed.Passwd != "p@ss:/?#[]" { + t.Fatalf("unexpected credentials in DSN: user=%q password=%q", parsed.User, parsed.Passwd) + } + if parsed.Addr != "[2001:db8::1]:3306" { + t.Fatalf("unexpected address: %q", parsed.Addr) + } + if parsed.DBName != "smail_1" || !parsed.ParseTime { + t.Fatalf("unexpected database options: name=%q parseTime=%v", parsed.DBName, parsed.ParseTime) + } + if !strings.Contains(dsn, "charset=utf8mb4") { + t.Fatalf("charset option is missing from DSN: %q", dsn) + } +} + +func TestBuildPostgresDSNUsesStructuredFields(t *testing.T) { + dsn, err := buildPostgresDSN(DatabaseSettings{ + User: "smail", + Host: "[2001:db8::2]", + Port: "05432", + Password: "p@ss:/?#[]", + Name: "smail_1", + }, "") + if err != nil { + t.Fatal(err) + } + parsed, ok := parsePostgresURL(dsn) + if !ok { + t.Fatalf("invalid PostgreSQL DSN: %q", dsn) + } + password, hasPassword := parsed.User.Password() + host, port := splitDatabaseAddress(parsed.Host) + if parsed.User.Username() != "smail" || !hasPassword || password != "p@ss:/?#[]" { + t.Fatalf("unexpected credentials in DSN: %q", dsn) + } + if host != "2001:db8::2" || port != "5432" || strings.TrimPrefix(parsed.Path, "/") != "smail_1" { + t.Fatalf("unexpected connection settings: host=%q port=%q name=%q", host, port, parsed.Path) + } + if parsed.Query().Get("sslmode") != "disable" { + t.Fatalf("unexpected sslmode: %q", parsed.Query().Get("sslmode")) + } +} + +func TestBuildPostgresDSNReusesMatchingPassword(t *testing.T) { + dsn, err := buildPostgresDSN(DatabaseSettings{ + User: "smail", + Host: "127.0.0.1", + Port: "5432", + Name: "smail", + }, "postgres://smail:stored-secret@127.0.0.1:5432/smail?sslmode=require") + if err != nil { + t.Fatal(err) + } + parsed, ok := parsePostgresURL(dsn) + if !ok { + t.Fatalf("invalid PostgreSQL DSN: %q", dsn) + } + password, _ := parsed.User.Password() + if password != "stored-secret" || parsed.Query().Get("sslmode") != "require" { + t.Fatalf("stored PostgreSQL settings were not reused: %q", dsn) + } +} + +func TestEnsurePostgresDatabaseCreatesMissingDatabase(t *testing.T) { + target := &fakeSetupDB{pingErrors: []error{&pq.Error{Code: "3D000"}, nil}} + admin := &fakeSetupDB{} + openCalls := 0 + withPostgresSetupOpener(t, func(dsn string) (setupDatabase, error) { + openCalls++ + parsed, ok := parsePostgresURL(dsn) + if !ok { + return nil, stderrors.New("invalid PostgreSQL test DSN") + } + if strings.TrimPrefix(parsed.Path, "/") == "postgres" { + return admin, nil + } + return target, nil + }) + + if err := ensurePostgresDatabase("postgres://smail:secret@127.0.0.1:5432/smail?sslmode=disable"); err != nil { + t.Fatal(err) + } + if openCalls != 2 || target.pingCalls != 2 || admin.pingCalls != 1 { + t.Fatalf("unexpected connection flow: opens=%d targetPings=%d adminPings=%d", openCalls, target.pingCalls, admin.pingCalls) + } + if len(admin.execQueries) != 1 || admin.execQueries[0] != `CREATE DATABASE "smail"` { + t.Fatalf("unexpected creation query: %#v", admin.execQueries) + } +} + +func withPostgresSetupOpener(t *testing.T, opener func(string) (setupDatabase, error)) { + t.Helper() + original := openPostgresSetupDatabase + openPostgresSetupDatabase = opener + t.Cleanup(func() { + openPostgresSetupDatabase = original + }) +} + +func TestBuildMySQLDSNAppliesDefaults(t *testing.T) { + dsn, err := buildMySQLDSN(DatabaseSettings{User: "root"}, "") + if err != nil { + t.Fatal(err) + } + + parsed, err := mysql.ParseDSN(dsn) + if err != nil { + t.Fatal(err) + } + if parsed.Addr != "127.0.0.1:3306" || parsed.DBName != "smail" { + t.Fatalf("unexpected defaults: address=%q database=%q", parsed.Addr, parsed.DBName) + } +} + +func TestBuildMySQLDSNReusesMatchingPassword(t *testing.T) { + previous := mysql.NewConfig() + previous.User = "root" + previous.Passwd = "stored-secret" + previous.Net = "tcp" + previous.Addr = "[::1]:3306" + previous.DBName = "smail" + + dsn, err := buildMySQLDSN(DatabaseSettings{ + User: "root", + Host: "::1", + Port: "03306", + Name: "smail", + }, previous.FormatDSN()) + if err != nil { + t.Fatal(err) + } + parsed, err := mysql.ParseDSN(dsn) + if err != nil { + t.Fatal(err) + } + if parsed.Passwd != "stored-secret" { + t.Fatal("matching stored password was not reused") + } +} + +func TestBuildMySQLDSNRejectsInvalidInput(t *testing.T) { + tests := []DatabaseSettings{ + {User: "root", Port: "0", Name: "smail"}, + {User: "root", Port: "65536", Name: "smail"}, + {User: "root", Port: "3306", Name: "smail-test"}, + {Port: "3306", Name: "smail"}, + } + for _, settings := range tests { + if _, err := buildMySQLDSN(settings, ""); err == nil { + t.Fatalf("invalid settings were accepted: %+v", settings) + } + } +} + +func TestEnsureMySQLDatabaseSkipsCreationWhenDatabaseExists(t *testing.T) { + target := &fakeSetupDB{} + openCalls := 0 + withMySQLSetupOpener(t, func(string) (setupDatabase, error) { + openCalls++ + return target, nil + }) + + if err := ensureMySQLDatabase(testMySQLDSN(t, "secret")); err != nil { + t.Fatal(err) + } + if openCalls != 1 { + t.Fatalf("unexpected open count: %d", openCalls) + } + if len(target.execQueries) != 0 || !target.closed { + t.Fatal("existing database should not trigger creation and must be closed") + } +} + +func TestEnsureMySQLDatabaseCreatesMissingDatabase(t *testing.T) { + target := &fakeSetupDB{pingErrors: []error{&mysql.MySQLError{Number: 1049}, nil}} + admin := &fakeSetupDB{} + openCalls := 0 + withMySQLSetupOpener(t, func(dsn string) (setupDatabase, error) { + openCalls++ + parsed, err := mysql.ParseDSN(dsn) + if err != nil { + return nil, err + } + if parsed.DBName == "" { + return admin, nil + } + return target, nil + }) + + if err := ensureMySQLDatabase(testMySQLDSN(t, "secret")); err != nil { + t.Fatal(err) + } + if openCalls != 2 || target.pingCalls != 2 || admin.pingCalls != 1 { + t.Fatalf("unexpected connection flow: opens=%d targetPings=%d adminPings=%d", openCalls, target.pingCalls, admin.pingCalls) + } + if len(admin.execQueries) != 1 || admin.execQueries[0] != "CREATE DATABASE IF NOT EXISTS `smail` DEFAULT CHARACTER SET utf8mb4" { + t.Fatalf("unexpected creation query: %#v", admin.execQueries) + } + if !target.closed || !admin.closed { + t.Fatal("setup database connections were not closed") + } +} + +func TestEnsureMySQLDatabaseReturnsSafeCreationError(t *testing.T) { + target := &fakeSetupDB{pingErrors: []error{&mysql.MySQLError{Number: 1049}}} + admin := &fakeSetupDB{execError: stderrors.New("secret-password")} + withMySQLSetupOpener(t, func(dsn string) (setupDatabase, error) { + parsed, err := mysql.ParseDSN(dsn) + if err != nil { + return nil, err + } + if parsed.DBName == "" { + return admin, nil + } + return target, nil + }) + + err := ensureMySQLDatabase(testMySQLDSN(t, "secret-password")) + if err == nil { + t.Fatal("database creation error was not returned") + } + message := DatabaseSetupErrorMessage(err) + if message == "" || strings.Contains(message, "secret-password") { + t.Fatalf("unsafe user-facing error message: %q", message) + } +} + +func withMySQLSetupOpener(t *testing.T, opener func(string) (setupDatabase, error)) { + t.Helper() + original := openMySQLSetupDatabase + openMySQLSetupDatabase = opener + t.Cleanup(func() { + openMySQLSetupDatabase = original + }) +} + +func testMySQLDSN(t *testing.T, password string) string { + t.Helper() + dsn, err := buildMySQLDSN(DatabaseSettings{ + User: "root", + Host: "127.0.0.1", + Port: "3306", + Password: password, + Name: "smail", + }, "") + if err != nil { + t.Fatal(err) + } + + return dsn +} + +func TestPrepareSQLiteDatabaseCreatesParentDirectory(t *testing.T) { + databasePath := filepath.Join(t.TempDir(), "nested", "config", "smail.db") + if err := prepareSQLiteDatabase(databasePath); err != nil { + t.Fatal(err) + } + if _, err := os.Stat(filepath.Dir(databasePath)); err != nil { + t.Fatalf("SQLite parent directory was not prepared: %v", err) + } +} diff --git a/server/services/setup/db_security_test.go b/server/services/setup/db_security_test.go index e6fa6b16..9cac4047 100644 --- a/server/services/setup/db_security_test.go +++ b/server/services/setup/db_security_test.go @@ -11,6 +11,20 @@ import ( "git.pcux.cn/xuans/Smail/utils/password" ) +func TestValidateAdminPasswordLengthBoundaries(t *testing.T) { + for _, candidate := range []string{"12345678", "123456789012"} { + if err := validateAdminPassword(candidate); err != nil { + t.Fatalf("password length %d was rejected: %v", len(candidate), err) + } + } + + for _, candidate := range []string{"1234567", "1234567890123"} { + if err := validateAdminPassword(candidate); err == nil { + t.Fatalf("password length %d was accepted", len(candidate)) + } + } +} + func TestSetAdminPasswordValidatesAndPreventsDuplicates(t *testing.T) { oldConfig := config.Instance config.Instance = &config.Config{DbType: config.DBTypeSQLite, DbDSN: filepath.Join(t.TempDir(), "setup.db")} @@ -21,16 +35,16 @@ func TestSetAdminPasswordValidatesAndPreventsDuplicates(t *testing.T) { t.Cleanup(func() { _ = db.Instance.Close() }) ctx := &context.Context{} - if err := SetAdminPassword(ctx, ".invalid", "StrongPass123"); err == nil { + if err := SetAdminPassword(ctx, ".invalid", "StrongP12"); err == nil { t.Fatal("invalid administrator account was accepted") } if err := SetAdminPassword(ctx, "admin-user", "short"); err == nil { t.Fatal("short administrator password was accepted") } - if err := SetAdminPassword(ctx, "admin-user", "StrongPass123"); err != nil { + if err := SetAdminPassword(ctx, "admin-user", "StrongP12"); err != nil { t.Fatal(err) } - if err := SetAdminPassword(ctx, "second-admin", "StrongPass456"); err == nil { + if err := SetAdminPassword(ctx, "second-admin", "StrongP45"); err == nil { t.Fatal("duplicate administrator initialization was accepted") } @@ -38,7 +52,20 @@ func TestSetAdminPasswordValidatesAndPreventsDuplicates(t *testing.T) { if _, err := db.Instance.Where("account = ?", "admin-user").Get(&user); err != nil { t.Fatal(err) } - if user.ID == 0 || user.IsAdmin != 1 || !password.Verify(user.Password, "StrongPass123") { + if user.ID == 0 || user.IsAdmin != 1 || !password.Verify(user.Password, "StrongP12") { t.Fatal("administrator was not initialized correctly") } } +func TestAdminPasswordRequiresInitializedDatabase(t *testing.T) { + oldInstance := db.Instance + db.Instance = nil + t.Cleanup(func() { db.Instance = oldInstance }) + + ctx := &context.Context{} + if _, err := GetAdminPassword(ctx); err == nil { + t.Fatal("admin account lookup succeeded without an initialized database") + } + if err := SetAdminPassword(ctx, "admin-user", "StrongP12"); err == nil { + t.Fatal("admin account creation succeeded without an initialized database") + } +} diff --git a/server/services/setup/dns.go b/server/services/setup/dns.go index f52bb496..7343b86e 100644 --- a/server/services/setup/dns.go +++ b/server/services/setup/dns.go @@ -1,10 +1,12 @@ package setup import ( + stdcontext "context" "fmt" "net" "net/netip" "strings" + "time" "git.pcux.cn/xuans/Smail/config" "git.pcux.cn/xuans/Smail/i18n" @@ -22,6 +24,10 @@ type DNSItem struct { Tips string `json:"tips"` } +const dnsRecordTTL = 600 + +const unresolvedWebIPv4 = "[未解析到 Web 域名公网 IPv4]" + func GetDNSSettings(ctx *context.Context) (map[string][]*DNSItem, error) { configData, err := config.ReadConfig() if err != nil { @@ -35,35 +41,90 @@ func GetDNSSettings(ctx *context.Context) (map[string][]*DNSItem, error) { ipv4 := ip.GetIPv4() ipv6 := ip.GetIPv6() + webIPv4 := resolvePublicIPv4(configData.WebDomain) ipTips := i18n.GetText(ctx.Lang, "ip_taps") ret := make(map[string][]*DNSItem, len(configData.Domains)) for _, domain := range configData.Domains { - ret[domain] = buildDNSItems(configData, domain, dkimPublicKey, ipv4, ipv6, ipTips) + ret[domain] = buildDNSItemsWithWebIPv4(configData, domain, dkimPublicKey, ipv4, ipv6, ipTips, webIPv4) } return ret, nil } func buildDNSItems(configData *config.Config, domain, dkimPublicKey, ipv4, ipv6, ipTips string) []*DNSItem { - address := strings.TrimSpace(ipv4) + return buildDNSItemsWithWebIPv4(configData, domain, dkimPublicKey, ipv4, ipv6, ipTips, nil) +} + +func buildDNSItemsWithWebIPv4(configData *config.Config, domain, dkimPublicKey, ipv4, ipv6, ipTips string, webIPv4 []string) []*DNSItem { + address := normalizeDNSAddress(ipv4) if address == "" { - address = "[Your Server IP]" + address = "[\u672a\u68c0\u6d4b\u5230\u516c\u7f51 IPv4]" } - return []*DNSItem{ - {Type: "A", Host: strings.ReplaceAll(configData.WebDomain, "."+configData.Domain, ""), Value: address, TTL: 3600, Tips: ipTips}, - {Type: "A", Host: "smtp", Value: address, TTL: 3600, Tips: ipTips}, - {Type: "A", Host: "imap", Value: address, TTL: 3600, Tips: ipTips}, - {Type: "A", Host: "pop", Value: address, TTL: 3600, Tips: ipTips}, - {Type: "A", Host: "@", Value: address, TTL: 3600, Tips: ipTips}, - {Type: "MX", Host: "@", Value: fmt.Sprintf("smtp.%s", domain), TTL: 3600}, - {Type: "TXT", Host: "@", Value: buildSPFRecord(ipv4, ipv6), TTL: 3600}, - {Type: "TXT", Host: "_dmarc", Value: "v=DMARC1; p=quarantine", TTL: 3600}, - {Type: "TXT", Host: "default._domainkey", Value: dkimPublicKey, TTL: 3600}, + + items := make([]*DNSItem, 0, 10) + appendARecord := func(host string) { + for _, item := range items { + if item.Type == "A" && item.Host == host { + return + } + } + items = append(items, &DNSItem{ + Type: "A", + Host: host, + Value: address, + TTL: dnsRecordTTL, + Tips: ipTips, + }) } + + webHost := dnsHostForDomain(configData.WebDomain, domain) + if webHost == "@" { + appendARecord(webHost) + } else if addresses := normalizeDNSAddresses(webIPv4); len(addresses) > 0 { + for _, webAddress := range addresses { + items = append(items, &DNSItem{ + Type: "A", + Host: webHost, + Value: webAddress, + TTL: dnsRecordTTL, + Tips: ipTips, + }) + } + } else { + items = append(items, &DNSItem{ + Type: "A", + Host: webHost, + Value: unresolvedWebIPv4, + TTL: dnsRecordTTL, + Tips: "Web 域名未解析到公网 IPv4,请确认域名解析状态", + }) + } + appendARecord("smtp") + appendARecord("imap") + appendARecord("pop") + appendARecord("@") + + if ipv6Address := buildSPFAddressMechanism(ipv6); strings.HasPrefix(ipv6Address, "ip6:") { + items = append(items, &DNSItem{ + Type: "AAAA", + Host: "@", + Value: strings.TrimPrefix(ipv6Address, "ip6:"), + TTL: dnsRecordTTL, + Tips: ipTips, + }) + } + + items = append(items, + &DNSItem{Type: "MX", Host: "@", Value: fmt.Sprintf("smtp.%s | 1", domain), TTL: dnsRecordTTL}, + &DNSItem{Type: "TXT", Host: "@", Value: buildSPFRecord(ipv4, ipv6), TTL: dnsRecordTTL}, + &DNSItem{Type: "TXT", Host: "_dmarc", Value: buildDMARCRecord(domain), TTL: dnsRecordTTL}, + &DNSItem{Type: "TXT", Host: "default._domainkey", Value: dkimPublicKey, TTL: dnsRecordTTL}, + ) + return items } func buildSPFRecord(ipv4, ipv6 string) string { - mechanisms := []string{"v=spf1", "a", "mx"} + mechanisms := []string{"v=spf1"} if mechanism := buildSPFAddressMechanism(ipv4); mechanism != "" { mechanisms = append(mechanisms, mechanism) } @@ -74,6 +135,81 @@ func buildSPFRecord(ipv4, ipv6 string) string { return strings.Join(mechanisms, " ") } +func buildDMARCRecord(domain string) string { + return fmt.Sprintf("v=DMARC1; p=quarantine; rua=mailto:admin@%s", domain) +} + +func normalizeDNSAddress(value string) string { + address, err := netip.ParseAddr(strings.TrimSpace(value)) + if err != nil || !isPublicDNSAddress(address) || !address.Is4() { + return "" + } + return address.String() +} + +func normalizeDNSAddresses(values []string) []string { + addresses := make([]string, 0, len(values)) + seen := make(map[string]struct{}, len(values)) + for _, value := range values { + address := normalizeDNSAddress(value) + if address == "" { + continue + } + if _, exists := seen[address]; exists { + continue + } + seen[address] = struct{}{} + addresses = append(addresses, address) + } + return addresses +} + +func resolvePublicIPv4(host string) []string { + return resolvePublicIPv4WithLookup(host, func(ctx stdcontext.Context, target string) ([]net.IP, error) { + return net.DefaultResolver.LookupIP(ctx, "ip4", target) + }) +} + +func resolvePublicIPv4WithLookup(host string, lookup func(stdcontext.Context, string) ([]net.IP, error)) []string { + host = strings.TrimSuffix(strings.ToLower(strings.TrimSpace(host)), ".") + if host == "" || lookup == nil { + return nil + } + + ctx, cancel := stdcontext.WithTimeout(stdcontext.Background(), 3*time.Second) + defer cancel() + addresses, err := lookup(ctx, host) + if err != nil { + return nil + } + + values := make([]string, 0, len(addresses)) + for _, address := range addresses { + if address == nil { + continue + } + values = append(values, address.String()) + } + return normalizeDNSAddresses(values) +} + +func dnsHostForDomain(webDomain, domain string) string { + webDomain = strings.TrimSuffix(strings.ToLower(strings.TrimSpace(webDomain)), ".") + domain = strings.TrimSuffix(strings.ToLower(strings.TrimSpace(domain)), ".") + if webDomain == "" || webDomain == domain { + return "@" + } + + suffix := "." + domain + if strings.HasSuffix(webDomain, suffix) { + host := strings.TrimSuffix(webDomain, suffix) + if host != "" { + return host + } + } + return webDomain +} + func buildSPFAddressMechanism(value string) string { address, err := netip.ParseAddr(strings.TrimSpace(value)) if err != nil { diff --git a/server/services/setup/dns_test.go b/server/services/setup/dns_test.go index 76c07ba0..54071304 100644 --- a/server/services/setup/dns_test.go +++ b/server/services/setup/dns_test.go @@ -1,6 +1,8 @@ package setup import ( + stdcontext "context" + "net" "testing" "git.pcux.cn/xuans/Smail/config" @@ -8,7 +10,7 @@ import ( func TestBuildSPFRecordIncludesPublicIPv4AndIPv6(t *testing.T) { value := buildSPFRecord("203.0.113.15", "2001:db8::15") - want := "v=spf1 a mx ip4:203.0.113.15 ip6:2001:db8::15 ~all" + want := "v=spf1 ip4:203.0.113.15 ip6:2001:db8::15 ~all" if value != want { t.Fatalf("SPF record = %q, want %q", value, want) } @@ -21,11 +23,11 @@ func TestBuildSPFRecordSkipsUnsafeAddresses(t *testing.T) { ipv6 string want string }{ - {name: "empty", want: "v=spf1 a mx ~all"}, - {name: "private IPv4", ipv4: "192.168.1.20", want: "v=spf1 a mx ~all"}, - {name: "link local IPv6", ipv6: "fe80::1", want: "v=spf1 a mx ~all"}, - {name: "only IPv4", ipv4: "198.51.100.9", want: "v=spf1 a mx ip4:198.51.100.9 ~all"}, - {name: "only IPv6", ipv6: "2001:db8::9", want: "v=spf1 a mx ip6:2001:db8::9 ~all"}, + {name: "empty", want: "v=spf1 ~all"}, + {name: "private IPv4", ipv4: "192.168.1.20", want: "v=spf1 ~all"}, + {name: "link local IPv6", ipv6: "fe80::1", want: "v=spf1 ~all"}, + {name: "only IPv4", ipv4: "198.51.100.9", want: "v=spf1 ip4:198.51.100.9 ~all"}, + {name: "only IPv6", ipv6: "2001:db8::9", want: "v=spf1 ip6:2001:db8::9 ~all"}, } for _, item := range cases { t.Run(item.name, func(t *testing.T) { @@ -49,13 +51,91 @@ func TestBuildDNSItemsIncludesSPFAndQuarantineDMARC(t *testing.T) { values[item.Host] = item.Value } } - if value := values["@"]; value != "v=spf1 a mx ip4:203.0.113.10 ip6:2001:db8::10 ~all" { + if value := values["@"]; value != "v=spf1 ip4:203.0.113.10 ip6:2001:db8::10 ~all" { t.Fatalf("SPF TXT value = %q", value) } - if value := values["_dmarc"]; value != "v=DMARC1; p=quarantine" { + if value := values["_dmarc"]; value != "v=DMARC1; p=quarantine; rua=mailto:admin@example.com" { t.Fatalf("DMARC TXT value = %q", value) } if value := values["default._domainkey"]; value != "v=DKIM1; k=rsa; p=test" { t.Fatalf("DKIM TXT value = %q", value) } } + +func TestBuildDNSItemsCreatesExpectedRecordShape(t *testing.T) { + cfg := &config.Config{ + Domain: "example.com", + WebDomain: "panel.example.com", + } + items := buildDNSItemsWithWebIPv4(cfg, "example.com", "v=DKIM1; k=rsa; p=test", "198.51.100.20", "2001:db8::20", "", []string{"203.0.113.20"}) + + if len(items) != 10 { + t.Fatalf("DNS item count = %d, want 10", len(items)) + } + if items[0].Host != "panel" || items[0].Type != "A" || items[0].Value != "203.0.113.20" { + t.Fatalf("web A record = %#v", items[0]) + } + if items[4].Host != "@" || items[4].Type != "A" || items[4].Value != "198.51.100.20" { + t.Fatalf("root A record = %#v", items[4]) + } + if items[5].Type != "AAAA" || items[5].Host != "@" || items[5].Value != "2001:db8::20" { + t.Fatalf("root AAAA record = %#v", items[5]) + } + if items[6].Value != "smtp.example.com | 1" || items[6].TTL != dnsRecordTTL { + t.Fatalf("MX record = %#v", items[6]) + } +} + +func TestBuildDNSItemsDoesNotReuseMailIPForUnresolvedWebDomain(t *testing.T) { + cfg := &config.Config{ + Domain: "example.net", + WebDomain: "panel.example.net", + } + items := buildDNSItemsWithWebIPv4(cfg, "example.net", "v=DKIM1; k=rsa; p=test", "198.51.100.30", "", "", nil) + + if items[0].Host != "panel" || items[0].Value != unresolvedWebIPv4 { + t.Fatalf("unresolved web A record = %#v", items[0]) + } + if items[1].Host != "smtp" || items[1].Value != "198.51.100.30" { + t.Fatalf("mail A record = %#v", items[1]) + } +} + +func TestResolvePublicIPv4UsesActualLookupResults(t *testing.T) { + lookup := func(ctx stdcontext.Context, host string) ([]net.IP, error) { + if host != "panel.example.org" { + t.Fatalf("lookup host = %q", host) + } + return []net.IP{ + net.ParseIP("203.0.113.40"), + net.ParseIP("192.168.1.40"), + net.ParseIP("203.0.113.40"), + }, nil + } + + values := resolvePublicIPv4WithLookup("Panel.Example.Org.", lookup) + if len(values) != 1 || values[0] != "203.0.113.40" { + t.Fatalf("resolved public IPv4 = %#v", values) + } +} + +func TestDNSHostForDomain(t *testing.T) { + cases := []struct { + name string + web string + domain string + want string + }{ + {name: "subdomain", web: "mail.example.com", domain: "example.com", want: "mail"}, + {name: "root", web: "example.com", domain: "example.com", want: "@"}, + {name: "trailing dot", web: "mail.example.com.", domain: "example.com.", want: "mail"}, + {name: "external domain", web: "panel.other.example", domain: "example.com", want: "panel.other.example"}, + } + for _, item := range cases { + t.Run(item.name, func(t *testing.T) { + if value := dnsHostForDomain(item.web, item.domain); value != item.want { + t.Fatalf("DNS host = %q, want %q", value, item.want) + } + }) + } +} diff --git a/server/services/setup/ssl/ssl.go b/server/services/setup/ssl/ssl.go index 289b8bbb..380b96bb 100644 --- a/server/services/setup/ssl/ssl.go +++ b/server/services/setup/ssl/ssl.go @@ -61,16 +61,37 @@ func SetSSL(sslType, priKey, crtKey string) error { if sslType == config.SSLTypeAutoHTTP || sslType == config.SSLTypeUser || sslType == config.SSLTypeAutoDNS { cfg.SSLType = sslType } else { - return errors.New("SSL Type Error!") + return errors.New("SSL 类型错误") } + if cfg.SSLType != config.SSLTypeUser { + clearLegacySSLPaths(cfg) + cfg.SSL = config.SSLConfig{ + Mode: config.ManagedSSLModeDefault, + DefaultDirectory: "config/ssl", + } + } if cfg.SSLType == config.SSLTypeUser { + if isAbsoluteUserCertificatePath(priKey) || isAbsoluteUserCertificatePath(crtKey) { + return errors.New("用户证书路径必须使用受控相对路径") + } privatePath, publicPath, err := validateUserCertificatePaths(priKey, crtKey) if err != nil { return err } - cfg.SSLPrivateKeyPath = privatePath - cfg.SSLPublicKeyPath = publicPath + privatePEM, err := os.ReadFile(privatePath) + if err != nil { + return errors.New("读取 SSL 私钥失败") + } + publicPEM, err := os.ReadFile(publicPath) + if err != nil { + return errors.New("读取 SSL 证书失败") + } + reference, err := config.ImportManagedSSL(config.ManagedSSLModeUpload, privatePEM, publicPEM, nil, sslDomains(cfg)) + if err != nil { + return err + } + applyManagedSSLReference(cfg, reference) // 手动设置证书的情况下后台地址默认不启用https cfg.HttpsEnabled = 1 } @@ -83,6 +104,40 @@ func SetSSL(sslType, priKey, crtKey string) error { return nil } +// clearLegacySSLPaths 只清理新受控模式不再使用的旧聚合路径字段。 +func clearLegacySSLPaths(cfg *config.Config) { + if cfg == nil { + return + } + cfg.SSLPrivateKeyPath = "" + cfg.SSLPublicKeyPath = "" +} + +// applyManagedSSLReference 将证书切换结果写入内部引用,不持久化服务器路径。 +func applyManagedSSLReference(cfg *config.Config, reference config.ManagedSSLReference) { + if cfg == nil { + return + } + clearLegacySSLPaths(cfg) + cfg.SSL = config.SSLConfig{ + Mode: reference.Mode, + DefaultDirectory: "config/ssl", + CertificateRef: reference.CertificateRef, + PrivateKeyRef: reference.PrivateKeyRef, + } + if reference.Mode == config.ManagedSSLModeUpload { + cfg.SSL.CustomDirectory = "config/ssl/managed/upload" + } +} + +func isAbsoluteUserCertificatePath(value string) bool { + value = strings.TrimSpace(value) + if value == "" || filepath.IsAbs(value) || filepath.VolumeName(value) != "" { + return true + } + return strings.HasPrefix(value, `\\`) || strings.HasPrefix(value, "//") +} + func validateUserCertificatePaths(privatePath, publicPath string) (string, string, error) { rootPath, err := filepath.Abs(filepath.Clean(config.ROOT_PATH)) if err != nil { @@ -173,7 +228,46 @@ func validateUserCertificatePaths(privatePath, publicPath string) (string, strin } func writeCertificateFiles(cfg *config.Config, privateKey, certificate, issuer []byte) error { - return writeCertificateBundle(cfg, privateKey, certificate, issuer) + if cfg == nil { + return errors.New("SSL 配置不能为空") + } + reference, err := config.ImportManagedSSL(config.ManagedSSLModeDefault, privateKey, certificate, issuer, sslDomains(cfg)) + if err != nil { + return err + } + applyManagedSSLReference(cfg, reference) + if err := config.WriteConfig(cfg); err != nil { + return errors.Wrap(err) + } + return nil +} + +func sslDomains(cfg *config.Config) []string { + if cfg == nil { + return nil + } + seen := make(map[string]struct{}) + domains := make([]string, 0, len(cfg.Domains)*3+1) + appendDomain := func(domain string) { + domain = strings.TrimSpace(domain) + if domain == "" { + return + } + if _, exists := seen[domain]; exists { + return + } + seen[domain] = struct{}{} + domains = append(domains, domain) + } + appendDomain(cfg.WebDomain) + appendDomain(cfg.Domain) + for _, domain := range cfg.Domains { + appendDomain(domain) + appendDomain("smtp." + domain) + appendDomain("pop." + domain) + appendDomain("imap." + domain) + } + return domains } func renewCertificate(privateKey *ecdsa.PrivateKey, cfg *config.Config) error { @@ -333,8 +427,13 @@ func GenSSL(update bool) error { } if !update { - privateFile, errpi := os.ReadFile(cfg.SSLPrivateKeyPath) - public, errpu := os.ReadFile(cfg.SSLPublicKeyPath) + privatePath, publicPath, pathErr := config.ResolveRuntimeSSLPaths(cfg) + privateFile, errpi := os.ReadFile(privatePath) + public, errpu := os.ReadFile(publicPath) + if pathErr != nil { + errpi = pathErr + errpu = pathErr + } // 当前存在证书数据,就不生成了 if errpi == nil && errpu == nil && len(privateFile) > 0 && len(public) > 0 { return nil @@ -361,7 +460,7 @@ func CheckSSLCrtInfo() (int, time.Time, bool, error) { return -1, time.Now(), true, errors.Wrap(err) } // load cert and key by tls.LoadX509KeyPair - tlsCert, err := tls.LoadX509KeyPair(cfg.SSLPublicKeyPath, cfg.SSLPrivateKeyPath) + tlsCert, err := config.LoadRuntimeTLSCertificate(cfg) if err != nil { return -1, time.Now(), true, errors.Wrap(err) } diff --git a/server/services/setup/ssl/user_certificate_test.go b/server/services/setup/ssl/user_certificate_test.go index bbc54e15..f4a59337 100644 --- a/server/services/setup/ssl/user_certificate_test.go +++ b/server/services/setup/ssl/user_certificate_test.go @@ -49,6 +49,55 @@ func writeTestCertificate(t *testing.T, root string, bits int) (string, string) return keyPath, certPath } +func TestIsAbsoluteUserCertificatePathRejectsWindowsPaths(t *testing.T) { + cases := []string{ + `C:\outside\private.key`, + `D:/outside/public.crt`, + `\\server\share\private.key`, + `//server/share/public.crt`, + } + for _, value := range cases { + if !isAbsoluteUserCertificatePath(value) { + t.Errorf("path %q was accepted", value) + } + } +} + +func TestIsAbsoluteUserCertificatePathRejectsEmptyAndAcceptsRelative(t *testing.T) { + if !isAbsoluteUserCertificatePath("") { + t.Fatal("empty path must be rejected") + } + if isAbsoluteUserCertificatePath(`config/ssl/upload/private.key`) { + t.Fatal("controlled relative path must not be treated as absolute") + } +} + +func TestApplyManagedSSLReferenceDoesNotPersistLegacyPaths(t *testing.T) { + cfg := &config.Config{ + SSLPrivateKeyPath: "config/ssl/private.key", + SSLPublicKeyPath: "config/ssl/public.crt", + } + reference := config.ManagedSSLReference{ + Mode: config.ManagedSSLModeUpload, + CertificateRef: "config/ssl/managed/upload/current/public.crt", + PrivateKeyRef: "config/ssl/managed/upload/current/private.key", + CertificatePath: `C:\server\config\ssl\managed\upload\current\public.crt`, + PrivateKeyPath: `C:\server\config\ssl\managed\upload\current\private.key`, + } + + applyManagedSSLReference(cfg, reference) + + if cfg.SSLPrivateKeyPath != "" || cfg.SSLPublicKeyPath != "" { + t.Fatal("新受控 SSL 配置不应保留旧聚合路径") + } + if cfg.SSL.Mode != config.ManagedSSLModeUpload || cfg.SSL.CertificateRef != reference.CertificateRef || cfg.SSL.PrivateKeyRef != reference.PrivateKeyRef { + t.Fatalf("受控 SSL 内部引用写入错误: %+v", cfg.SSL) + } + if cfg.SSL.CustomDirectory != "config/ssl/managed/upload" { + t.Fatalf("自定义受控目录写入错误: %s", cfg.SSL.CustomDirectory) + } +} + func TestValidateUserCertificatePaths(t *testing.T) { oldRoot := config.ROOT_PATH root := t.TempDir() diff --git a/server/utils/credential/credential.go b/server/utils/credential/credential.go index d5f64dab..f924532d 100644 --- a/server/utils/credential/credential.go +++ b/server/utils/credential/credential.go @@ -89,10 +89,25 @@ var restrictedRemotePrefixes = []netip.Prefix{ } func NewRestrictedHTTPClient(timeoutMS int) *http.Client { + return NewRestrictedHTTPClientForTargets(timeoutMS, nil) +} + +// NetworkTarget 描述插件允许访问的网络目标。 +type NetworkTarget struct { + Scheme string + Host string + Port int +} + +// NewRestrictedHTTPClientForTargets 创建仅允许访问授权目标的 HTTP 客户端。 +func NewRestrictedHTTPClientForTargets(timeoutMS int, targets []NetworkTarget) *http.Client { timeout := time.Duration(NormalizeTimeoutMS(timeoutMS)) * time.Millisecond + allowedTargets := normalizeNetworkTargets(targets) transport := &http.Transport{ - Proxy: nil, - DialContext: restrictedDialContext, + Proxy: nil, + DialContext: func(ctx context.Context, network, address string) (net.Conn, error) { + return restrictedDialContext(ctx, network, address, allowedTargets) + }, ForceAttemptHTTP2: true, TLSHandshakeTimeout: timeout, ResponseHeaderTimeout: timeout, @@ -100,22 +115,91 @@ func NewRestrictedHTTPClient(timeoutMS int) *http.Client { } return &http.Client{ Timeout: timeout, - Transport: transport, + Transport: restrictedRoundTripper{transport: transport, targets: allowedTargets}, CheckRedirect: func(request *http.Request, via []*http.Request) error { if len(via) >= 10 { return errors.New("too many redirects") } - _, err := NormalizeHTTPSURL(request.URL.String()) - return err + return validateRestrictedRequest(request, allowedTargets, "redirect target is not authorized") }, } } -func restrictedDialContext(ctx context.Context, network, address string) (net.Conn, error) { +type restrictedRoundTripper struct { + transport http.RoundTripper + targets []NetworkTarget +} + +func (r restrictedRoundTripper) RoundTrip(request *http.Request) (*http.Response, error) { + if err := validateRestrictedRequest(request, r.targets, "remote target is not authorized"); err != nil { + return nil, err + } + return r.transport.RoundTrip(request) +} + +func validateRestrictedRequest(request *http.Request, targets []NetworkTarget, targetError string) error { + if request == nil || request.URL == nil { + return errors.New("invalid endpoint") + } + if _, err := NormalizeHTTPSURL(request.URL.String()); err != nil { + return err + } + if !matchesNetworkTarget(request.URL, targets) { + return errors.New(targetError) + } + return nil +} + +func normalizeNetworkTargets(targets []NetworkTarget) []NetworkTarget { + result := make([]NetworkTarget, 0, len(targets)) + for _, target := range targets { + scheme := strings.ToLower(strings.TrimSpace(target.Scheme)) + host := strings.TrimSuffix(strings.ToLower(strings.TrimSpace(target.Host)), ".") + port := target.Port + if port == 0 { + if scheme == "https" { + port = 443 + } else { + port = 80 + } + } + if (scheme != "https" && scheme != "http") || host == "" || port < 1 || port > 65535 { + continue + } + result = append(result, NetworkTarget{Scheme: scheme, Host: host, Port: port}) + } + return result +} + +func matchesNetworkTarget(endpoint *url.URL, targets []NetworkTarget) bool { + if len(targets) == 0 { + return true + } + port := 443 + if strings.EqualFold(endpoint.Scheme, "http") { + port = 80 + } + if endpoint.Port() != "" { + port, _ = strconv.Atoi(endpoint.Port()) + } + host := strings.TrimSuffix(strings.ToLower(endpoint.Hostname()), ".") + scheme := strings.ToLower(endpoint.Scheme) + for _, target := range targets { + if target.Scheme == scheme && target.Host == host && target.Port == port { + return true + } + } + return false +} + +func restrictedDialContext(ctx context.Context, network, address string, targets []NetworkTarget) (net.Conn, error) { host, port, err := net.SplitHostPort(address) if err != nil { return nil, errors.New("invalid remote address") } + if _, err := strconv.Atoi(port); err != nil || (len(targets) > 0 && !matchesNetworkTarget(&url.URL{Scheme: "https", Host: net.JoinHostPort(host, port)}, targets) && !matchesNetworkTarget(&url.URL{Scheme: "http", Host: net.JoinHostPort(host, port)}, targets)) { + return nil, errors.New("remote target is not authorized") + } resolved, err := net.DefaultResolver.LookupIPAddr(ctx, host) if err != nil || len(resolved) == 0 { return nil, errors.New("remote address resolution failed") diff --git a/server/utils/credential/credential_test.go b/server/utils/credential/credential_test.go index ebe3e7f6..44958ce7 100644 --- a/server/utils/credential/credential_test.go +++ b/server/utils/credential/credential_test.go @@ -96,6 +96,35 @@ func TestRestrictedHTTPClientRejectsPrivateRedirect(t *testing.T) { } } +func TestRestrictedHTTPClientRejectsCrossTargetRedirect(t *testing.T) { + client := NewRestrictedHTTPClientForTargets(1000, []NetworkTarget{{Scheme: "https", Host: "allowed.example.com", Port: 443}}) + request := httptest.NewRequest(http.MethodGet, "https://other.example.com/internal", nil) + if err := client.CheckRedirect(request, nil); err == nil { + t.Fatal("restricted client accepted a redirect outside the authorized target") + } +} + +func TestRestrictedHTTPClientRejectsInitialHTTPRequest(t *testing.T) { + client := NewRestrictedHTTPClientForTargets(1000, []NetworkTarget{{Scheme: "https", Host: "allowed.example.com", Port: 443}}) + if _, err := client.Get("http://allowed.example.com:443/internal"); err == nil { + t.Fatal("restricted client accepted an initial HTTP request") + } +} + +func TestRestrictedHTTPClientRejectsInitialUnauthorizedPort(t *testing.T) { + client := NewRestrictedHTTPClientForTargets(1000, []NetworkTarget{{Scheme: "https", Host: "allowed.example.com", Port: 443}}) + if _, err := client.Get("https://allowed.example.com:8443/internal"); err == nil { + t.Fatal("restricted client accepted an unauthorized initial port") + } +} +func TestRestrictedHTTPClientAllowsAuthorizedRedirect(t *testing.T) { + client := NewRestrictedHTTPClientForTargets(1000, []NetworkTarget{{Scheme: "https", Host: "allowed.example.com", Port: 443}}) + request := httptest.NewRequest(http.MethodGet, "https://allowed.example.com/next", nil) + if err := client.CheckRedirect(request, nil); err != nil { + t.Fatalf("authorized redirect was rejected: %v", err) + } +} + func TestNormalizeTimeoutMS(t *testing.T) { if NormalizeTimeoutMS(0) != defaultTimeoutMS || NormalizeTimeoutMS(1) != minTimeoutMS || NormalizeTimeoutMS(60000) != maxTimeoutMS { t.Fatal("timeout limit was not normalized") diff --git a/server/utils/credential/vault.go b/server/utils/credential/vault.go index 1744880c..55b1e6dc 100644 --- a/server/utils/credential/vault.go +++ b/server/utils/credential/vault.go @@ -1,6 +1,9 @@ package credential import ( + "crypto/hmac" + "crypto/sha256" + "encoding/hex" "errors" "strings" ) @@ -62,3 +65,23 @@ func (v *Vault) Decrypt(version uint32, ciphertext string) (string, error) { } return value, nil } + +// Fingerprint 使用数据库外主密钥计算固定长度校验值,不能用于恢复原文。 +func (v *Vault) Fingerprint(value string) (string, error) { + if v == nil { + return "", ErrVaultUnavailable + } + key, err := readKey(v.root) + if err != nil { + return "", ErrVaultUnavailable + } + defer func() { + for index := range key { + key[index] = 0 + } + }() + mac := hmac.New(sha256.New, key) + _, _ = mac.Write([]byte("smail-plugin-setting-v1\x00")) + _, _ = mac.Write([]byte(value)) + return hex.EncodeToString(mac.Sum(nil)), nil +}