@kenz1117/dsh-ui-usage-billing 0.9.19 → 0.9.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +2 -0
- package/README.md +2 -0
- package/lib/client.js +460 -416
- package/lib/index.js +160 -50
- package/lib/types/client/TokenPanel.d.ts +0 -2
- package/lib/types/client/UsageBilling.d.ts +1 -0
- package/lib/types/client/pricing.d.ts +3 -2
- package/lib/types/client/usage-billing-settings.d.ts +2 -1
- package/package.json +28 -28
package/README.en.md
CHANGED
|
@@ -85,6 +85,8 @@
|
|
|
85
85
|
- **Real usage aggregation**: the server aggregates from session logs on demand (incremental cache recomputes only written sessions), with per-session corruption tolerance and snapshot fallback; an optional `usage_stats` tool lets the model query today / month / current session / cumulative spend, plus `bySite` (relay-attributed) and `relay` (relay-only) summaries (toggle it in Settings; takes effect after a reload).
|
|
86
86
|
- **Model health + uncatalogued annotation**: provider connection dots (green / red / grey); a model id not in the catalog is marked "uncatalogued" priced at the fallback, with provider inferred (e.g. `mi-mimo-2.5` → Xiaomi); estimated-price models are marked "estimated".
|
|
87
87
|
- **Multi-language + dual currency**: the ¥/$ switch is bilingual (USD→English, CNY→Chinese, this plugin only); the rate table converts to the selected currency.
|
|
88
|
+
- **Security hardening**: every HTTP endpoint enforces loopback-only access via a dual check of the peer socket address and an exact Host-header match (literal loopback IP, not a prefix), rejecting `127.0.0.1.evil.com`-style DNS-rebinding names; the `/api/billing/usage-tool` write path additionally validates a loopback Origin and `application/json` Content-Type with a body-size cap to block cross-site rewrites; balance / subscription / relay queries and pricing fetches carry bounded retries with per-upstream circuit breaking (auth failures are config issues and do not trip the breaker).
|
|
89
|
+
- **Export injection guard**: daily / session / site CSV cells starting with `=` / `+` / `-` / `@` are prefixed with a single quote, and commas / quotes / newlines / carriage returns are fully escaped, so they cannot be executed as formulas in Excel / WPS.
|
|
88
90
|
- **Privacy baseline**: a pure UI surface — registers no tools, injects no system prompt, writes no model-visible events; it only aggregates from existing session logs, whose content is owned by other packages.
|
|
89
91
|
|
|
90
92
|
## 🚀 Quick start
|
package/README.md
CHANGED
|
@@ -85,6 +85,8 @@
|
|
|
85
85
|
- **真实用量聚合**:服务端从会话日志实时聚合(增量缓存只重算写过的会话),单会话损坏容错、快照落盘回退;`usage_stats` 工具让模型自查今天 / 本月 / 当前会话 / 累计费用,还可查 `bySite`(按站点归组)与 `relay`(只看中转站)的汇总。
|
|
86
86
|
- **模型健康 + 未收录标注**:厂商接入状态圆点(绿 / 红 / 灰);模型 id 不在目录时标「未收录」按兜底价估算、厂商自动推断(如 `mi-mimo-2.5` → 小米);估算价模型标注「估算价」。
|
|
87
87
|
- **多语种 + 双币种**:¥ / $ 切换随币种双语(USD→英文、CNY→中文,仅本插件生效);费率表按所选币种换算。
|
|
88
|
+
- **安全加固**:全部 HTTP 端点强制回环访问——peer socket 地址 + Host 头精确匹配(回环 IP 字面量,而非前缀)双重校验,拒绝 `127.0.0.1.evil.com` 形式的 DNS rebinding 域名;`/api/billing/usage-tool` 的写操作额外校验 Origin 回环与 Content-Type 为 `application/json` 并限制 body 上限,杜绝跨站改写;余额 / 订阅 / 中转站查询与定价拉取均带有限重试与按上游维度熔断(鉴权失败属配置问题、不计入熔断)。
|
|
89
|
+
- **数据导出防注入**:按日 / 按会话 / 按站点 CSV 对以 `=` / `+` / `-` / `@` 开头的单元格前置单引号,并完整转义逗号 / 引号 / 换行 / 回车,防止在 Excel / WPS 中被当作公式执行。
|
|
88
90
|
- **隐私底线**:纯 UI surface,不注册工具、不注入系统提示、不向会话日志写入模型可见事件;仅从既有会话日志聚合,日志内容由其他包负责。
|
|
89
91
|
|
|
90
92
|
## 🚀 快速开始
|