| Files | Last commit | Last update |
|---|---|---|
| 18 days ago | ||
| 15 days ago | ||
| 18 days ago | ||
| 18 days ago | ||
| 18 days ago |
蓝色精英可信会员接入服务
此服务保存本站登录会话、一次性登录事务、加密的中央委托与持久创作任务。会员、原余额、订阅、充值、订单和权威扣费均归小蓝助手;不另设会员密码库、钱包、赠额或图片次数。
U15 草稿恢复:已认证的 /api/session 新增 draft_owner,由本站密钥对应用来源、中央 issuer 和会员原字符串 ID 做带用途隔离的 HMAC;它只用于浏览器区分草稿归属,不能代替 Cookie、CSRF 或中央委托。匿名及关闭状态不返回该字段。同账号重新登录/重启保持一致,切号不同;密钥或应用来源变化后旧草稿不恢复。前端仅在身份确认后恢复同标签页文字,明确退出清理,提交后移除待恢复草稿;此变化不新增中央接口、数据库迁移或消费权限。需与 U15 网站组合发布,旧后端仍可登录但前端会准确提示自动保存不可用。
当前源码显式支持小蓝 0.4.5-local,应用固定 blue_elite,默认范围为 member:read。消费范围按下表显式配置。沿用中央现有登录/TOTP/注册接续,不增加授权确认页。正式中央地址、issuer、应用凭据与回调需要小蓝登记;未配置时默认关闭。历史 0.4.2-local 环境可显式指定版本,禁止自动降级;已封存的 rc1 Windows/Linux 包仍为原0.4.2源码,本次修改没有替换这些制品。
新版消费合同已接入本方可信 HTTP 服务和创作工作台,消费仍默认关闭。支持明确批准的文字和单图创作、原号查询、使用记录与私有作品读取。首次请求前将任务和参数加密保存到 SQLite;并发或重复提交仅一个请求能派发,结果未知和进程重启后只查询原号。没有第二钱包或扣费计算。金额保持中央八位十进制字符串,未确认金额为 null。
会员响应按明确配置的合同版本校验:0.4.2-local 保持空能力列表,0.4.5-local 接受中央最多4个不重复的中性能力标识。只读委托仍要求空列表,原会话不会因响应出现能力而升级;实际创作权限继续由会话范围、中央能力目录和独立批准策略共同决定。会员页与任务列表共用此校验,能力标识不向页面透传。五份中央实际 HTTP 样本作为回归数据保留;样本包含的余额和币种均为合成验收数据,不能用作正式价格。
正式接入前需要中央启用、应用登记及明确批准的参数和价格引用。本地合成通过不代表真实中央、真实会员、真实供应或正式收费已验收。旧 rc1 包保留为历史,新代码须使用新的制品和验证记录。
运行环境与持久化
- Node.js 24.14.0,依赖按 package-lock.json 执行
npm ci --ignore-scripts。Windows 已验证;Linux制品验收另做。 - 使用该Node版本的内置SQLite(该版本仍发出实验性API提示),WAL、同步事务、一次性认领及AES-256-GCM加密委托/verifier。原用户ID为字符串,关联使用issuer+ID,不按邮箱合并。
- 应用凭据和32字节原始加密密钥使用独立私有文件;数据库和密钥必须位于网站根目录之外,部署账户单独限制访问。加密密钥保持稳定才能读取重启前会话;更换密钥会使旧会话不可读取。DB及密钥属于运行数据,不放进发布包或同步档案。
- 本次单实例同机实现;生产反向代理、系统服务权限、速率限制、备份/恢复和Linux运行验收仍需发布环境核验。不得把本地合成测试当已生产上线。
所需环境变量:
| 变量 | 含义 |
|---|---|
| LSJY_PUBLIC_ORIGIN | 本站精确origin;正式HTTPS,开发 http://127.0.0.1:49180 |
| LSJY_LISTEN_PORT | 本服务监听端口,默认49180;仅绑定127.0.0.1 |
| LSJY_DEVELOPMENT | 数字回环HTTP开发设1;正式不设 |
| LSJY_SITE_ROOT | 新会员候选site根目录 |
| LSJY_DB_PATH | 私有SQLite文件绝对路径 |
| LSJY_KEY_FILE | 私有32字节原始加密密钥文件路径 |
| LSJY_CENTRAL_ENABLED | 默认关闭;登记和联调准备好后才设1 |
| LSJY_CENTRAL_ORIGIN | 已确认中央站点origin,不带路径或query |
| LSJY_CENTRAL_CONTRACT | 默认 0.4.5-local;仅旧环境显式设 0.4.2-local,响应头必须精确匹配 |
| LSJY_ISSUER | 已登记subject.issuer精确字符串,HTTPS |
| LSJY_APP_CREDENTIAL_FILE | 服务端应用凭据私有文件路径 |
| LSJY_COMPUTE_ENABLED | 新消费默认关闭;仅明确批准并验收后设1,关闭时原任务仍可查询 |
| LSJY_SCOPES | 默认 member:read;只接受规定顺序的会员、文字、图片组合,不能重复或增加空格 |
| LSJY_COMPUTE_POLICY_FILE | 网站根外的独立批准策略 JSON 数组;逐项与中央能力目录精确核对,禁止从当前目录自动批准 |
启动 npm start,禁止把真实值放进共享命令记录、文档、网页或SKILL。默认关闭状态仍需本站加密密钥和数据库配置;不自动生成正式凭据或启用中央接口。开发回调为 http://127.0.0.1:49180/auth/xiaolan/callback,正式候选为 https://www.lansejingying.com/auth/xiaolan/callback,均须精确登记。
本站接口
- GET
/api/session:登录状态、CSRF令牌与固定中央purchase/orders链接。匿名会话不等会员。 - POST
/auth/xiaolan/start:同源Origin、CSRF头与空JSON对象;生成120秒state/PKCE事务,返回中央浏览器地址。 - GET
/auth/xiaolan/callback:只接code/state;回调Cookie/state/PKCE绑定。跨站顶层GET没有Origin时仍可处理。事务在联网前原子认领,兑换只执行一次;超时/未知结果不自动重试。 - GET
/api/member:按中央Schema、issuer/字符串ID和委托到期检验,返回金额与最少订阅投影;不提供中央凭据/模型/组ID。金额不转Number,不再减冻结额。未知不当零、未知订阅不当已核实为空。 - POST
/auth/logout:同源Origin+CSRF;先结束本地会话,再单次撤销中央委托。中央撤销未确认时如实返回unconfirmed,仍保持本地退出。 - GET
/healthz:基础存活和本地开关状态;不代表中央健康或业务可用。 - GET
/api/compute/capabilities:当前登录、权限和独立批准策略共同允许的创作选项。会员余额或 session 的旧 compute_available 字段不作为算力可用依据。 - POST
/api/tasks:同源 Origin、CSRF 和 JSON;字段 request_id、choice_id、prompt,以及文字的 max_output_tokens 或图片的 size/quality。request_id 必须8–128位 ASCII 字母、数字、下划线或连字符。服务端生成并持久绑定中央业务号和调用号。重复 request_id 只查原号,改变内容返回409。 - GET
/api/tasks:当前委托经中央复核后的本人任务缓存。支持 page/page_size,缓存状态以再次查询为准。 - GET
/api/tasks/by-request/{request_id}:浏览器未收到提交回执时仅用 GET 找回原任务;查不到也不自动重发。 - GET
/api/tasks/{operation_id}:核本地归属后查询中央原号;首次创建请求失败也不能换号自动恢复。 - GET
/api/tasks/{operation_id}/result:文字只交付 text;图片从中央私有 PNG 读取,校验 PNG 结构/CRC,移除附加元数据后交付。没有供应 URL 代理、原生响应透传或本地图片永久副本。409/410不改变原结算,也不会生成新任务。 - GET
/api/usage:当前会员在本应用的中央使用记录,保留旧行空元信息和精确金额。
scope 只能为 member:read、member:read compute:text、member:read compute:image、member:read compute:text compute:image。登录事务保存当时范围,兑换必须完全匹配。数据库采用增量迁移,旧会话只保留 member:read;更新配置不会为旧会话升级权限,需要沿原小蓝登录重新接续。
正式HTTPS Cookie使用 __Host-、Secure、HttpOnly、SameSite=Lax;开发HTTP使用本站专有cookie名。会话最长900秒,无refresh;登录后旋转本站会话。HTML、API、回调不缓存且no-referrer;上游错误只返回本方固定文案。运行日志不记录请求URL或响应正文;代理配置也必须避免记录回调查询串和敏感头。
验证与交接
npm test执行真实回环HTTP、SQLite、合成中央服务测试。test/browser.mjs <全新证据目录> <site目录>通过共享已锁定Playwright工具运行真实浏览器(只作为项目测试依赖,不进入服务端生产包)。合成中央没有使用小蓝真实JWT/数据库,端到端联合验收另行记录。
官网会员页和创作工作台用 LSJY_MEMBER_BACKEND=1 创建全新候选,配合原 LSJY_MEMBER_PREVIEW=1、LSJY_RELEASE_CANDIDATE=1、LSJY_TOOL_SKILLS=1,禁演示。静态独立部署时会员API未提供,页面显示接入中;只有本服务配置并正式验收后才开放登录及相应消费。test/compute-browser.mjs <新证据目录> <候选site目录>验证本方真实浏览器与本地合成中央;不重用旧制品的验收结论。
页面不将凭据、任务或作品写入 localStorage/sessionStorage。图片使用短期内存 Blob 预览/下载,离开页面、登录到期和同源会员页退出时清除。任务以 issuer+字符串用户ID 隔离,切号后不得读取前一会员记录。正式代理仍需禁止回调查询串/凭据日志、配置同源API转发和请求限制;这些属于上线环境验收。
2026-11-10 Membership Read Candidate
The optional membership-1-local reader adds authenticated same-origin GET
/api/membership/summary and /api/membership/catalog. It is disabled by default.
LSJY_MEMBERSHIP_READ_ENABLED=1 additionally requires the existing central gate
and 0.4.5-local; it does not enable compute or checkout. Production must keep
this flag off until the central candidate, registered mappings, denomination,
new release baseline and rollback have been verified.
The BFF validates both central credentials, exact contract shapes, subject and application ownership, expiry, precise decimal strings and current local session. It strips central identity from the browser response. No quota is issued or reset, no price is calculated, and no order or settlement is created. A 403 on the new optional reader does not revoke the existing login. A 401 or identity mismatch invalidates it. The original login, member and compute contracts remain.
Settled quota is not live availability: available and reserved remain null.
Catalog prices are display labels, durations are not purchase quantities, and
every offer remains purchase_state=unavailable. No checkout URL is invented.
The r18 central source is not a production deployment; local synthetic browser
tests and an immutable package do not establish real payment or business acceptance.
2026-11-10 Explicit Subscription Candidate
LSJY_COMPUTE_CONTRACT defaults to 0.4.5-local. Explicitly selecting
subscription-1-local adds the central compute-contract header; it does not
enable central access, compute, scopes, membership reading or purchasing.
Subscription policies additionally bind billing_source: subscription, the
neutral entitlement_id, exact quota currency, price and parameter references.
New subscription operations send the explicit source; balance requests retain
their original shape. A choice and durable request cannot silently change source.
Subscription settlement keeps amount: null and displays exact eight-place
quota_consumed; it is not a zero wallet charge, free count or realtime quota.
Pending usage has no consumed amount. The existing balance contract and store
schema remain unchanged; the source and expected entitlement/unit are retained
in the existing encrypted request, not a second ledger.
Only validated central pre-dispatch refusal metadata can mark the local attempt
not_started. The refusal is durably retained, repeated submission never POSTs
again, and the browser preserves the draft and login. A new attempt requires a
fresh deliberate user submission. Missing, malformed or ambiguous responses stay
unknown and recover only by the original GET. Contract-required 409 is not logout.
New-consumption disablement and later subscription expiry do not block owned reads.
The new candidate is locally tested only. Fixed central joint verification, Linux execution of the new package, actual units/resources, fresh controlled release conditions and commercial acceptance are still required. Checkout and free-trial policy are not implemented by this adapter.
Optional Purchase Review Candidate
LSJY_PURCHASE_CONTEXT_ENABLED=1 adds only same-account central plan review. It defaults off and requires the existing central and membership-read gates. It does not enable checkout, payments, compute or new scopes.
Register the exact return URI <publicOrigin>/member/?purchase=return in the central application's purchase-return allowlist before enabling. The app persists an encrypted context locator once per session and offer, retains it on lost responses, validates the exact central review URL and never accepts client prices, quantities, user IDs or return destinations. Only explicit restart after expiry creates another review context. The additive membership_purchase_intents table is created only while this independent feature is enabled; the original Store and wallet tables are unchanged.
The page offers plan review separately from its disabled purchase action. Central owns price/payment preview, account mismatch checks, checkout and original orders. A return marker is not evidence of payment or entitlement activation. Context errors and expired review do not automatically log out the member. This is a local candidate, not a deployed or payment-accepted release.
Explicit V2 Catalog Candidate
LSJY_MEMBERSHIP_CATALOG_CONTRACT defaults to membership-1-local. Only explicit
membership-catalog-2-local selects the delegated membership/v2/catalog route.
Summary stays V1, and selection enables no gates. An unavailable V2 route or
invalid response never silently falls back. The adapter validates exact versions,
member/application identity, freshness, expiry, amounts and state/reason pairs.
V2 offers are scoped to Blue Elite. Available offers use the original purchase context and central confirmation page, with a new catalog check before creating or recovering a context. Unavailable resources, payment methods or checkout stop the transition before a context POST. This is not a local checkout or order. Encrypted original IDs, price/validity fingerprints and deliberate expiry restart remain in place. Hidden pages cancel outstanding reads/transitions and clear private details; returning refreshes authority. V1 review behavior stays intact.
Fixed central joint verification, exact Linux packages and fresh release binding remain separate acceptance steps. No commercial prices or production gates are set by this candidate.
Explicit Shared Trial Candidate (U14)
LSJY_TRIAL_READ_ENABLED=1 enables only the optional delegated trial summary;
it defaults off and requires existing central/member-read enablement. The local
GET /api/membership/trial validates trial-1-local, identity, freshness, exact
ten-place quota strings, state combinations and the registered central claim
URL. Reading or logging in never grants quota. Users explicitly claim at the
central membership page; this application exposes no claim POST or local ledger.
LSJY_COMPUTE_CONTRACT=trial-1-local preserves original balance/subscription
operations and adds an explicit trial source. Approved trial policies bind a
campaign, entitlement, quota currency, price and parameter profile. The fixed
r29 contract allows four original protocol bindings and four trial bindings;
capability identities cannot mix sources. The original validators and request
hash remain unchanged. Trial campaign identity is included in the choice and
encrypted durable request and verified again when reading the original result.
Trial settlement is amount: null plus exact eight-place quota_consumed, not a
zero wallet charge. Summary settled_remaining excludes in-flight reservations
and is not live availability or a generation count. Exhaustion preserves login,
drafts and free local tools and never falls back to balance. Unknown submissions
only recover by GET of the original task. The page explicitly separates trial,
paid membership and balance; existing CLI/MCP release packages do not gain trial
support from a website upgrade.
U14 local synthetic verification, new fixed central/Linux joint verification, commercial trial configuration and a controlled production release are separate steps. This adapter does not approve trial prices, resources, budgets or rollout.