Files
crypto_monitor_user/docs/LICENSE_API.md
T
2026-05-21 16:44:31 +08:00

89 lines
1.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 授权云端 API 约定(独立服务实现)
用户端仓库仅包含 `license_lib.py`;签发 Web 与数据库部署在**独立项目**。
## 环境变量(用户端 `.env`)
| 变量 | 说明 |
|------|------|
| `LICENSE_API_URL` | 云端根地址,如 `https://license.example.com` |
| `LICENSE_CLIENT_KEY` | 客户端密钥,请求头 `X-Client-Key` |
| `LICENSE_CHECK_INTERVAL_DAYS` | 校验间隔,默认 `3` |
| `LICENSE_OFFLINE_GRACE_DAYS` | 断网宽限,默认 `7` |
| `LICENSE_DISABLED` | `true` 时关闭许可(仅开发) |
| `LICENSE_WECHAT_ID` | 默认 `dekun03` |
| `LICENSE_WECHAT_REMARK` | 可选;未设则提示用户用设备 ID 作备注 |
本地缓存:仓库根目录 `.license/license.cache`(勿提交 Git)。
## POST /v1/redeem
请求:
```json
{
"device_id": "32位十六进制",
"code": "一次性激活码"
}
```
成功响应:
```json
{
"ok": true,
"subscription_id": "sub_xxx",
"plan": "monthly",
"expires_at": "2026-06-21T23:59:59+08:00"
}
```
续费叠加(服务端实现):
```text
base = max(now, current_expires_at)
expires_at = base + days(plan) # monthly 30 / quarterly 90 / yearly 365
```
失败:`ok: false``message` 说明原因。
## POST /v1/validate
请求:
```json
{
"device_id": "...",
"subscription_id": "sub_xxx"
}
```
成功且有效:
```json
{
"ok": true,
"valid": true,
"expires_at": "2026-06-21T23:59:59+08:00",
"plan": "monthly"
}
```
无效(换机、过期等):
```json
{
"ok": true,
"valid": false,
"reason": "device_revoked"
}
```
## 套餐定价(商务参考)
| plan | 售价 | 天数 |
|------|------|------|
| monthly | 199 | 30 |
| quarterly | 399 | 90 |
| yearly | 699 | 365 |