dsh-oauth
其他 活跃维护

dsh-oauth

hrhgit/dsh-oauth

提供与厂商无关的OAuth认证基础,不绑定任何特定AI服务商,兼容标准授权流程,便于快速集成多种服务的登录与授权。

0
Stars 标星
0
Forks 分支
0
Watchers 关注
0
Open Issues
TypeScript
主要语言
MIT
开源协议
91 KB
仓库大小
3 个月前
最后推送
一键安装扩展 / 插件指令
dsh plugin --profile web add github:hrhgit/dsh-oauth
git clone https://github.com/hrhgit/dsh-oauth.git
git clone git@github.com:hrhgit/dsh-oauth.git
README.md main

dsh-oauth

English | 简体中文

dsh-oauth is a provider-neutral OAuth foundation for DeepSeek Harness. It does not embed OpenAI, ChatGPT, Codex, or any other vendor protocol. Independent provider plugins register drivers while this package owns the shared account and credential lifecycle.

The base provides provider registration, browser/device/input challenges, cancellation and timeouts, token-free account projections, DSH credential storage, per-account cross-process refresh locking, and Typert Remote methods. It keeps a compatibility sign-in entry on the Host Models page and contributes the same OAuth login and account configuration flow to the independent Model Center provided by dsh-model-manager.

It deliberately does not own authorization endpoints, client identifiers, scopes, account-specific protocol details, model catalogs, LLM adapters, model requests, or model-provider configuration. Provider plugins contribute configuration through OAuth child slots and maintain their own model routes. The independent Model Center is the evolution path while the original Host Models page remains available.

Provider integration

import type { Context } from '@deepseek-ai/cordis'
import type {} from 'dsh-oauth'
import type { OAuthProviderDriver } from 'dsh-oauth/types'

const driver: OAuthProviderDriver = {
  id: 'example',
  displayName: 'Example Account',
  authorizationTimeoutMs: 900000,
  async authorize(interaction, signal) {
    interaction.publish({ kind: 'browser', url: 'https://example.test/oauth/authorize' })
    return {
      account: { id: 'stable-account-id', displayName: 'Example User' },
      credential: { schemaVersion: 1, accessToken: '...', refreshToken: '...' },
    }
  },
}

export function apply(ctx: Context): void {
  ctx.effect(() => ctx.oauth.registerProvider(driver), 'example-oauth-provider')
}

export const inject = ['oauth']

Providers may declare authorizationTimeoutMs for longer authorization flows such as device code. Drivers that omit it use the base loginTimeoutMs setting.

Development

pnpm install
pnpm run typecheck
pnpm test
pnpm run build
pnpm run pack:check

The package ships no real provider. Install a separate provider plugin to make sign-in available.

Security

OAuth credentials are stored through ctx.credentials. The Web Remote and account index never contain access or refresh tokens. The ordinary provider search preference uses dsh.oauth.settings.global.search.v1; one-time codes, passwords, device codes, and live sessions remain transient.

License

MIT