用途:为 Spuree(面向智能体的云存储)V1 API 提供认证。项目包含可嵌套的文件夹与任意层级的文件,访问全部 V1 端点需使用 JWT 令牌或 API Key。
主要能力:支持三种首次配置方式。方式 A 由用户在 studio.spuree.com/api-keys 创建 API Key 并设置 export SPUREE_API_KEY="<your-api-key>";方式 B 由智能体用邮箱密码调用 POST /auth/token 获取临时 JWT,再用 POST /v1/api-keys 创建并保存 API Key;方式 C 由智能体在 49152–65535 端口启动本地 HTTP 服务器,打开 https://studio.spuree.com/auth/signin?source=api&port=<port>,用户登录后回调 http://localhost:<port>/callback?token=<exchange-code>,再用 POST /auth/token/exchange 换取 JWT。还支持刷新令牌,以及创建、列出、吊销 API Key。
使用方式:令牌遵循 OAuth2 约定,access_token 为 NextAuth JWT,有效期 1 小时;refresh_token 有效期 30 天,每次刷新后旧的即被撤销;exchange_code 有效期 60 秒。认证端点使用 https://studio.spuree.com/api,数据端点使用 https://data.spuree.com/api。请求可带 Authorization: Bearer <access_token> 或 X-API-Key: <api-key>,两者同时提供时 JWT 优先。建议在约 55 分钟时主动刷新。
限制:认证端点限速为每 IP 每分钟 10 次,收到 429 需退避重试;连续 5 次登录失败会锁定账户 15 分钟;API Key 的 key 字段仅在创建时返回一次;创建、列出、吊销 API Key 仅接受 JWT,不接受 API Key;API Key 默认不过期,除非设置 expiresAt。