fix(account): invalidate a rejected token on the account service mounted at rejection
- deepseek-account: the request credential's reject() re-resolves the account service through the resolving context, so a reload between a request and the destination's HTTP 401 still removes the stored grant; without a mounted service the grant stays for the next one to reject. resolveToken and rejectToken become private; the e2e sign-in stand-in and the generated API catalog follow. - llm-deepseek: routeCredential().resolve() publishes the grant's headers, value, and rejection only, keeping the adapter's onRequestError behind the seam. - web-deepseek-api: a route publishing an unparsable base URL becomes a misconfigured source instead of throwing from readiness or dispatch.
This commit is contained in:
1 parent
7d83af645c
commit
3ca18d169f
20 files changed
+162
-108
No files matched your search
@@ -6,11 +6,11 @@
|
||||
en: 2302e2999588bac3
|
||||
zh: 5e0ac058b50036dc
|
||||
/deepseek-account/request-credentials:
|
||||
en: 76f2eb1df1948c8a
|
||||
zh: 70f698243f8e3ae8
|
||||
en: 808ace524e0dbc0b
|
||||
zh: c4268221fa4c1c09
|
||||
/deepseek-account/embedded-platform-credentials:
|
||||
en: 9a651d70acbe83a6
|
||||
zh: 4624b0299f5fdd8e
|
||||
/deepseek-account/cordis-api/deepseek-account-events/deepseek-account-signed-out-emit:
|
||||
en: b2c8c533124a121c
|
||||
zh: c2a5c227b5a01146
|
||||
en: 3065c17cb319f756
|
||||
zh: e69c2692a109c38b
|
||||
@@ -8,7 +8,7 @@ Source: [`packages/account/deepseek-account/src/index.ts`](../../packages/accoun
|
||||
|
||||
## Request credentials
|
||||
|
||||
`resolveRequestCredential(url)` is Host-only. It answers `undefined` while signed out, during credential removal, and for any destination outside the configured `inferenceOrigin`; otherwise it returns an `AccountRequestCredential` whose `headers` carry the token as `x-dsh-auth-token`, whose `value` is the bare token, and whose `reject()` removes the stored grant only while it still matches that token, containing storage failures so the caller reports the destination's rejection. The `deepseek-account` model route publishes this credential through `ctx.llm.routeCredential('deepseek-account')` ([LLM streaming](llm-streaming.md)); the DeepSeek web providers consume it there and, without that route, ask the account service directly. `resolveToken(url)` returns the bare token under the same policy for consumers that compose their own request, and `rejectToken(token)` is the invalidation `reject()` performs.
|
||||
`resolveRequestCredential(url)` is Host-only. It answers `undefined` while signed out, during credential removal, and for any destination outside the configured `inferenceOrigin`; otherwise it returns an `AccountRequestCredential` whose `headers` carry the token as `x-dsh-auth-token`, whose `value` is the bare token, and whose `reject()` removes the stored grant only while it still matches that token, containing storage failures so the caller reports the destination's rejection. The `deepseek-account` model route publishes this credential through `ctx.llm.routeCredential('deepseek-account')` ([LLM streaming](llm-streaming.md)); the DeepSeek web providers consume it there and, without that route, ask the account service directly. `reject()` runs on the account service mounted when it is called, so a reload between a request and the destination's answer still removes the grant; without a mounted service it leaves the grant for the next one to reject.
|
||||
|
||||
Model routes that bill the account register a running-task report with `registerRunningTaskReport(report)` inside `ctx.effect()`; `hasRunningAccountTasks()` answers true while any report does, so the sign-out confirmation can warn about work the sign-out interrupts. The route plugin owns cancellation of that work after `deepseek-account/signed-out`.
|
||||
|
||||
@@ -81,13 +81,6 @@ Account login, credentials, and client-safe Remote operations.
|
||||
*/
|
||||
@Remote async reportNotificationEvent(id: AccountNotificationId, event: AccountNotificationEvent, client: AccountClientMetadata): Promise<boolean>
|
||||
|
||||
/**
|
||||
* Remove an inference-rejected token only while it still matches the stored login.
|
||||
* @param token - token captured by the rejected inference request.
|
||||
* @returns after matching credentials are removed and the expiry notification is emitted.
|
||||
*/
|
||||
async rejectToken(token: string): Promise<void>
|
||||
|
||||
/**
|
||||
* Read existing login identity without creating a device or returning credentials.
|
||||
* @returns optional device/account identifiers and the provider's OS version string.
|
||||
@@ -101,16 +94,10 @@ async getDeviceIdentity(): Promise<{ deviceId?: string; userId?: AccountUserId;
|
||||
*/
|
||||
async getPlatformSession(): Promise<PlatformSession | null>
|
||||
|
||||
/**
|
||||
* Resolve a credential only for the inference origin allowed by the provider.
|
||||
* @param url - actual request destination or API base URL.
|
||||
* @returns stored token, or undefined for other origins or a signed-out account.
|
||||
*/
|
||||
async resolveToken(url: string): Promise<string | undefined>
|
||||
|
||||
/**
|
||||
* Release the account credential for one request to `url` as the request
|
||||
* carries it, together with its invalidation. Host-only.
|
||||
* carries it, together with its invalidation, which runs on the account
|
||||
* service mounted when it is called. Host-only.
|
||||
* @param url - actual request destination or API base URL.
|
||||
* @returns the request credential, or undefined for other origins or a signed-out account.
|
||||
*/
|
||||
@@ -229,6 +216,6 @@ Local grant removal has completed.
|
||||
Source: [`packages/account/deepseek-account/src/index.ts`](../../packages/account/deepseek-account/src/index.ts)
|
||||
<!-- END GENERATED cordis-surface -->
|
||||
|
||||
The account Service Definition exposes getState, getProfile, getBalance, getNotifications, getNotificationContent, reportNotificationEvent, startSignIn, cancelSignIn, signOut, watch, and Host-only resolveToken, resolveRequestCredential, registerRunningTaskReport, and getPlatformSession. The platform provider implements it with an AuthorizationFlow and a private GrantRecord. AccountView distinguishes stored presence from server validation; attempt IDs bind cancellation to one local flow. AccountUpdate carries a complete AccountView in state and a type of snapshot for initial or progress updates, or credentials-changed for credential writes and removal. Pending credential changes take priority over progress updates. See [the account package](../../packages/account/deepseek-account/README.md).
|
||||
The account Service Definition exposes getState, getProfile, getBalance, getNotifications, getNotificationContent, reportNotificationEvent, startSignIn, cancelSignIn, signOut, watch, and Host-only resolveRequestCredential, registerRunningTaskReport, and getPlatformSession. The platform provider implements it with an AuthorizationFlow and a private GrantRecord. AccountView distinguishes stored presence from server validation; attempt IDs bind cancellation to one local flow. AccountUpdate carries a complete AccountView in state and a type of snapshot for initial or progress updates, or credentials-changed for credential writes and removal. Pending credential changes take priority over progress updates. See [the account package](../../packages/account/deepseek-account/README.md).
|
||||
|
||||
`AccountClientMetadata` carries `version` from the caller’s `DSH_CLIENT_VERSION`, its active UI `locale`, and `timezoneOffsetSeconds` sampled when the operation begins. The offset is local time minus UTC in seconds: UTC+8 is `28800`. It contains no credentials. Login attempts retain their initiating metadata through exchange and cancellation; sign-out retains its metadata for revocation retries.
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
## 请求凭据
|
||||
|
||||
`resolveRequestCredential(url)` 仅限 Host。未登录、凭据删除进行中,以及目标地址不在配置的 `inferenceOrigin` 之内时,它回答 `undefined`;否则返回一个 `AccountRequestCredential`:`headers` 以 `x-dsh-auth-token` 携带 token,`value` 是裸 token,`reject()` 仅在已存授权仍与该 token 一致时删除它,并隔离存储失败,使调用方报告的是目标地址的拒绝。`deepseek-account` 模型路由通过 `ctx.llm.routeCredential('deepseek-account')`([LLM 流式](llm-streaming.zh.md))发布这份凭据;DeepSeek Web 提供方在那里消费它,没有该路由时直接询问账号服务。`resolveToken(url)` 在同一策略下为自行组装请求的消费方返回裸 token,`rejectToken(token)` 则是 `reject()` 执行的失效操作。
|
||||
`resolveRequestCredential(url)` 仅限 Host。未登录、凭据删除进行中,以及目标地址不在配置的 `inferenceOrigin` 之内时,它回答 `undefined`;否则返回一个 `AccountRequestCredential`:`headers` 以 `x-dsh-auth-token` 携带 token,`value` 是裸 token,`reject()` 仅在已存授权仍与该 token 一致时删除它,并隔离存储失败,使调用方报告的是目标地址的拒绝。`deepseek-account` 模型路由通过 `ctx.llm.routeCredential('deepseek-account')`([LLM 流式](llm-streaming.zh.md))发布这份凭据;DeepSeek Web 提供方在那里消费它,没有该路由时直接询问账号服务。`reject()` 在被调用时挂载的账号服务上执行,因此请求与目的地应答之间发生的重载仍会移除授权;没有挂载的服务时,授权留给下一个挂载的服务处理。
|
||||
|
||||
按账号计费的模型路由在 `ctx.effect()` 内用 `registerRunningTaskReport(report)` 注册运行中任务报告;只要有报告回答 true,`hasRunningAccountTasks()` 就回答 true,使退登确认能够提醒退登将打断的工作。`deepseek-account/signed-out` 之后取消这些工作由路由插件负责。
|
||||
|
||||
@@ -81,13 +81,6 @@ Account login, credentials, and client-safe Remote operations.
|
||||
*/
|
||||
@Remote async reportNotificationEvent(id: AccountNotificationId, event: AccountNotificationEvent, client: AccountClientMetadata): Promise<boolean>
|
||||
|
||||
/**
|
||||
* Remove an inference-rejected token only while it still matches the stored login.
|
||||
* @param token - token captured by the rejected inference request.
|
||||
* @returns after matching credentials are removed and the expiry notification is emitted.
|
||||
*/
|
||||
async rejectToken(token: string): Promise<void>
|
||||
|
||||
/**
|
||||
* Read existing login identity without creating a device or returning credentials.
|
||||
* @returns optional device/account identifiers and the provider's OS version string.
|
||||
@@ -101,16 +94,10 @@ async getDeviceIdentity(): Promise<{ deviceId?: string; userId?: AccountUserId;
|
||||
*/
|
||||
async getPlatformSession(): Promise<PlatformSession | null>
|
||||
|
||||
/**
|
||||
* Resolve a credential only for the inference origin allowed by the provider.
|
||||
* @param url - actual request destination or API base URL.
|
||||
* @returns stored token, or undefined for other origins or a signed-out account.
|
||||
*/
|
||||
async resolveToken(url: string): Promise<string | undefined>
|
||||
|
||||
/**
|
||||
* Release the account credential for one request to `url` as the request
|
||||
* carries it, together with its invalidation. Host-only.
|
||||
* carries it, together with its invalidation, which runs on the account
|
||||
* service mounted when it is called. Host-only.
|
||||
* @param url - actual request destination or API base URL.
|
||||
* @returns the request credential, or undefined for other origins or a signed-out account.
|
||||
*/
|
||||
@@ -229,6 +216,6 @@ Local grant removal has completed.
|
||||
Source: [`packages/account/deepseek-account/src/index.ts`](../../packages/account/deepseek-account/src/index.ts)
|
||||
<!-- END GENERATED cordis-surface -->
|
||||
|
||||
账号服务定义提供 getState、getProfile、getBalance、getNotifications、getNotificationContent、reportNotificationEvent、startSignIn、cancelSignIn、signOut、watch 及仅限 Host 的 resolveToken、resolveRequestCredential、registerRunningTaskReport 和 getPlatformSession。平台提供者使用 AuthorizationFlow 和私有 GrantRecord 实现这些操作。AccountView 区分本地存在与服务器验证;尝试 ID 将取消绑定到单次本地流程。AccountUpdate 的 state 携带完整 AccountView,type 为 snapshot 时表示首次或进度更新,为 credentials-changed 时表示凭据写入或删除。待发送的凭据变化优先于进度更新。参见[账号包](../../packages/account/deepseek-account/README.zh.md)。
|
||||
账号服务定义提供 getState、getProfile、getBalance、getNotifications、getNotificationContent、reportNotificationEvent、startSignIn、cancelSignIn、signOut、watch 及仅限 Host 的 resolveRequestCredential、registerRunningTaskReport 和 getPlatformSession。平台提供者使用 AuthorizationFlow 和私有 GrantRecord 实现这些操作。AccountView 区分本地存在与服务器验证;尝试 ID 将取消绑定到单次本地流程。AccountUpdate 的 state 携带完整 AccountView,type 为 snapshot 时表示首次或进度更新,为 credentials-changed 时表示凭据写入或删除。待发送的凭据变化优先于进度更新。参见[账号包](../../packages/account/deepseek-account/README.zh.md)。
|
||||
|
||||
`AccountClientMetadata` 携带调用方 `DSH_CLIENT_VERSION` 提供的 `version`、当前界面 `locale`,以及操作发起时采样的 `timezoneOffsetSeconds`。偏移为本地时间减 UTC 的秒数:UTC+8 对应 `28800`。其中不含凭证。登录申请在兑换及取消期间保留发起时的元数据;退出操作为撤销重试保留其元数据。
|
||||
@@ -9,8 +9,8 @@
|
||||
en: f0139803159ee9c9
|
||||
zh: 73bd5dfd53ed8d36
|
||||
/deepseek-routes-publish-the-credential-web-consumers-reuse/change:
|
||||
en: 7a63f24e07fb3d33
|
||||
zh: 99c64684a589088e
|
||||
en: 09ab43933a9e5950
|
||||
zh: a18da5d560cf0c9f
|
||||
/deepseek-routes-publish-the-credential-web-consumers-reuse/migration:
|
||||
en: 64ac045c8d9a1336
|
||||
zh: 4712f6eacd85a151
|
||||
@@ -9,13 +9,13 @@ English | [中文](guide.zh.md)
|
||||
|
||||
## Change
|
||||
|
||||
`LlmAdapter.routeCredential(provider)` and `LlmRuntime.routeCredential(provider)` publish a route's current credential as a `RouteCredential`: kind, resolved base URL, optional reference, a value-free `configured(endpoint)` check, and `resolve(endpoint, signal)` returning a `RouteCredentialGrant` with protocol headers, the bare value, and an optional `reject()`.
|
||||
`LlmAdapter.routeCredential(provider)` and `LlmRuntime.routeCredential(provider)` publish a route's current credential as a `RouteCredential`: kind, resolved base URL, optional reference, a `configured(endpoint)` presence check, and `resolve(endpoint, signal)` returning a `RouteCredentialGrant` with protocol headers, the bare value, and an optional `reject()`.
|
||||
|
||||
`@deepseek-ai/dsh-llm-deepseek` no longer exports `resolveDeepSeekApiKey`, `deepSeekApiKeyConfigured`, `resolveDeepSeekAccountToken`, or `rejectDeepSeekAccountToken`. `DeepSeekAdapterOptions.resolveAuth(connection, endpoint)` returns `DeepSeekRequestAuth | undefined`, and `DeepSeekRequestAuth` requires `value` beside `headers`; the new `missingCredential` and `credential` options name the missing-credential failure and the published credential. `createModelListingCache` takes `credential(url)` returning request headers, and its `load` is optional.
|
||||
|
||||
`@deepseek-ai/dsh-llm-deepseek-api-key` no longer exports `plainOptions` and `resolveAdapterOptions`; `@deepseek-ai/dsh-llm-deepseek-account` no longer exports `plainAccountOptions` and `resolveAccountOptions`. The account route plugin cancels its running Agents after sign-out and registers a running-task report.
|
||||
|
||||
`@deepseek-ai/dsh-deepseek-account` adds Host-only `resolveRequestCredential(url)` and `registerRunningTaskReport(report)`; `hasRunningAccountTasks()` answers from registered reports and no longer reads `ctx.agents`. The package drops its `dsh-agent` and `dsh-llm` peer dependencies and moves from `packages/credentials/` to `packages/account/` under its unchanged name. `@deepseek-ai/dsh-credentials` adds `resolveCredentialRef(ctx, ref)` and `credentialRefConfigured(ctx, ref)`.
|
||||
`@deepseek-ai/dsh-deepseek-account` adds Host-only `resolveRequestCredential(url)` and `registerRunningTaskReport(report)` and makes `resolveToken(url)` and `rejectToken(token)` private; `hasRunningAccountTasks()` answers from registered reports and no longer reads `ctx.agents`. The package drops its `dsh-agent` and `dsh-llm` peer dependencies and moves from `packages/credentials/` to `packages/account/` under its unchanged name. `@deepseek-ai/dsh-credentials` adds `resolveCredentialRef(ctx, ref)` and `credentialRefConfigured(ctx, ref)`.
|
||||
|
||||
`@deepseek-ai/dsh-web-deepseek-api` drops its peer dependencies on `dsh-llm-deepseek`, both route plugins, and `cordis-plugin-loader`; `@deepseek-ai/dsh-web-search-deepseek` drops `dsh-llm-deepseek` and `dsh-deepseek-account` and adds `dsh-llm`. Both read route credentials through `ctx.llm.routeCredential()`, so an adapter registered under a DeepSeek route id without a published credential counts as no route. Without the account route, the Search and Fetch APIs send the account credential to the origin `DEEPSEEK_BASE_URL` names and reject a value that is not an HTTP(S) URL without embedded credentials. `DeepSeekSearchProviderOptions` replaces `resolveAccountToken` and `rejectAccountToken` with `resolveAccountCredential(endpoint)`.
|
||||
|
||||
|
||||
@@ -9,13 +9,13 @@ description: "DeepSeek 模型路由通过 ctx.llm.routeCredential() 发布自己
|
||||
|
||||
## 变更
|
||||
|
||||
`LlmAdapter.routeCredential(provider)` 与 `LlmRuntime.routeCredential(provider)` 把路由当前的凭据发布为 `RouteCredential`:种类、解析后的基础地址、可选引用、不读取值的 `configured(endpoint)` 检查,以及返回 `RouteCredentialGrant` 的 `resolve(endpoint, signal)`,授权包含协议请求头、裸值和可选的 `reject()`。
|
||||
`LlmAdapter.routeCredential(provider)` 与 `LlmRuntime.routeCredential(provider)` 把路由当前的凭据发布为 `RouteCredential`:种类、解析后的基础地址、可选引用、`configured(endpoint)` 存在性检查,以及返回 `RouteCredentialGrant` 的 `resolve(endpoint, signal)`,授权包含协议请求头、裸值和可选的 `reject()`。
|
||||
|
||||
`@deepseek-ai/dsh-llm-deepseek` 不再导出 `resolveDeepSeekApiKey`、`deepSeekApiKeyConfigured`、`resolveDeepSeekAccountToken` 和 `rejectDeepSeekAccountToken`。`DeepSeekAdapterOptions.resolveAuth(connection, endpoint)` 返回 `DeepSeekRequestAuth | undefined`,且 `DeepSeekRequestAuth` 在 `headers` 之外要求 `value`;新增的 `missingCredential` 与 `credential` 选项分别命名凭据缺失的失败和发布的凭据。`createModelListingCache` 的 `credential(url)` 返回请求头,其 `load` 变为可选。
|
||||
|
||||
`@deepseek-ai/dsh-llm-deepseek-api-key` 不再导出 `plainOptions` 和 `resolveAdapterOptions`;`@deepseek-ai/dsh-llm-deepseek-account` 不再导出 `plainAccountOptions` 和 `resolveAccountOptions`。账号路由插件在退登后取消其运行中的 Agent,并注册运行中任务报告。
|
||||
|
||||
`@deepseek-ai/dsh-deepseek-account` 新增仅限 Host 的 `resolveRequestCredential(url)` 与 `registerRunningTaskReport(report)`;`hasRunningAccountTasks()` 根据注册的报告作答,不再读取 `ctx.agents`。该包移除 `dsh-agent` 与 `dsh-llm` peer 依赖,并以不变的名字从 `packages/credentials/` 移至 `packages/account/`。`@deepseek-ai/dsh-credentials` 新增 `resolveCredentialRef(ctx, ref)` 与 `credentialRefConfigured(ctx, ref)`。
|
||||
`@deepseek-ai/dsh-deepseek-account` 新增仅限 Host 的 `resolveRequestCredential(url)` 与 `registerRunningTaskReport(report)`,并将 `resolveToken(url)` 与 `rejectToken(token)` 改为私有;`hasRunningAccountTasks()` 根据注册的报告作答,不再读取 `ctx.agents`。该包移除 `dsh-agent` 与 `dsh-llm` peer 依赖,并以不变的名字从 `packages/credentials/` 移至 `packages/account/`。`@deepseek-ai/dsh-credentials` 新增 `resolveCredentialRef(ctx, ref)` 与 `credentialRefConfigured(ctx, ref)`。
|
||||
|
||||
`@deepseek-ai/dsh-web-deepseek-api` 移除对 `dsh-llm-deepseek`、两个路由插件和 `cordis-plugin-loader` 的 peer 依赖;`@deepseek-ai/dsh-web-search-deepseek` 移除 `dsh-llm-deepseek` 与 `dsh-deepseek-account`,新增 `dsh-llm`。两者都通过 `ctx.llm.routeCredential()` 读取路由凭据,因此以 DeepSeek 路由 id 注册但不发布凭据的适配器视为没有路由。没有账号路由时,Search 与 Fetch API 把账号凭据发往 `DEEPSEEK_BASE_URL` 所指的 origin,并拒绝不是不含内嵌凭据的 HTTP(S) URL 的值。`DeepSeekSearchProviderOptions` 用 `resolveAccountCredential(endpoint)` 替换 `resolveAccountToken` 与 `rejectAccountToken`。
|
||||
|
||||
|
||||
Reference in new issue
Block a user