@noob9527/dsh-mcp-oauth 0.2.0-rc.1 → 0.2.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/CONTRIBUTING.md +1 -1
- package/README.md +27 -9
- package/README.zh.md +29 -11
- package/SECURITY.md +1 -1
- package/docs/acceptance.md +12 -0
- package/docs/releasing.md +10 -4
- package/lib/client.js +149 -49
- package/lib/index.js +80 -20
- package/lib/types/callback.d.ts +4 -2
- package/lib/types/client/form.d.ts +33 -0
- package/lib/types/client/locales.d.ts +29 -3
- package/lib/types/client/service-id.d.ts +2 -0
- package/lib/types/diagnostics.d.ts +21 -0
- package/lib/types/manual-response.d.ts +1 -0
- package/lib/types/provider.d.ts +3 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.0-rc.2 — 2026-11-17
|
|
4
|
+
|
|
5
|
+
- Report malformed MCP URLs as field validation errors. Exclude unused metadata URLs when saving DCR or pre-registered settings, and identify invalid fields in localized messages.
|
|
6
|
+
|
|
7
|
+
- Allocate an available local callback port when the URL omits it; declare native CIMD redirects for both localhost and 127.0.0.1. Keep explicit ports and existing configuration unchanged.
|
|
8
|
+
|
|
9
|
+
- Host a public CIMD document on GitHub Pages and prefill its editable URL under Advanced for new services; preserve existing values. Invalid metadata URLs report validation errors.
|
|
10
|
+
|
|
11
|
+
- Simplify the service form with Advanced settings, registration-specific fields and bilingual help tooltips. Restrict the default hosted CIMD document to local callbacks.
|
|
12
|
+
|
|
13
|
+
- Move Service ID into Advanced and generate it from the display name for new services. Keep saved IDs read-only and report duplicate IDs for manual correction.
|
|
14
|
+
- Add sanitized Host OAuth failure diagnostics with operation stages, bounded error chains, network/OAuth reason codes and proxy tunnel rejection status. Raw messages, URLs, stacks and credentials are excluded.
|
|
15
|
+
- Preserve existing Client error codes and authentication recovery behavior.
|
|
16
|
+
|
|
3
17
|
## 0.2.0-rc.1 — 2026-11-16
|
|
4
18
|
|
|
5
19
|
- Lower the DSH requirement to `>=0.2.1-alpha.3`, using the public `dsh-llm` error export and the Client locale type entry. Build against the minimum version and validate all 17 published 0.2.x versions.
|
package/CONTRIBUTING.md
CHANGED
|
@@ -10,7 +10,7 @@ pnpm run typecheck
|
|
|
10
10
|
pnpm test
|
|
11
11
|
pnpm run build
|
|
12
12
|
pnpm pack --pack-destination artifacts
|
|
13
|
-
node scripts/check-release.mjs --tarball artifacts/noob9527-dsh-mcp-oauth-0.2.0-rc.
|
|
13
|
+
node scripts/check-release.mjs --tarball artifacts/noob9527-dsh-mcp-oauth-0.2.0-rc.2.tgz
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
Describe the user-visible behavior, relevant tests and compatibility impact. Add regression tests for changes to authorization, refresh, retries or teardown. Use loopback fixtures, atomic port allocation and explicit lifecycle cleanup. Do not weaken TLS verification, log credentials or silently retry tools with unknown outcomes.
|
package/README.md
CHANGED
|
@@ -6,28 +6,28 @@ OAuth-protected MCP tools for an unmodified DeepSeek Harness installation. The p
|
|
|
6
6
|
|
|
7
7
|
## Status and compatibility
|
|
8
8
|
|
|
9
|
-
Independent community plugin; not an official DeepSeek product. The npm 0.1.0 release supports local callbacks.
|
|
9
|
+
Independent community plugin; not an official DeepSeek product. The npm 0.1.0 release supports local callbacks. Version 0.2.0-rc.2 adds remote personal-instance callbacks and manual response submission.
|
|
10
10
|
|
|
11
11
|
| Surface | Status |
|
|
12
12
|
| --- | --- |
|
|
13
13
|
| Official DSH 0.2.1-alpha.3 / 0.2.2-rc.1 Web, local macOS | Current candidate: browser CIMD OAuth and real chat tool calls verified |
|
|
14
14
|
| Official Desktop | Intended scope; acceptance pending |
|
|
15
15
|
| Other DSH versions | Not declared compatible |
|
|
16
|
-
| Remote personal DSH, 0.2.0-rc.
|
|
16
|
+
| Remote personal DSH, 0.2.0-rc.2 | HTTPS proxy fixture verified; actual deployment acceptance required |
|
|
17
17
|
| Shared multi-user DSH | Not supported |
|
|
18
18
|
|
|
19
|
-
Version 0.2.0-rc.
|
|
19
|
+
Version 0.2.0-rc.2 requires DSH `>=0.2.1-alpha.3`. All 13 published versions at or above this floor in the [17-version compatibility matrix](docs/compatibility.md) passed automated checks. Later versions are admitted by the range but are not automatically certified. Version 0.1.0 retains its original rc.2 requirement.
|
|
20
20
|
|
|
21
21
|
## Install from npm
|
|
22
22
|
|
|
23
23
|
Requires Node 24.9+ and an unmodified official DSH installation satisfying `>=0.2.1-alpha.3`. The public package name is `@noob9527/dsh-mcp-oauth`.
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
Version `0.2.0-rc.2` is a release candidate distributed under `next`. Use `latest` for the stable release.
|
|
26
26
|
|
|
27
|
-
Install the preview
|
|
27
|
+
Install the published preview:
|
|
28
28
|
|
|
29
29
|
```sh
|
|
30
|
-
dsh plugin --profile web add @noob9527/dsh-mcp-oauth@
|
|
30
|
+
dsh plugin --profile web add @noob9527/dsh-mcp-oauth@next
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
The unscoped `dsh-mcp-oauth` package is a different project. When migrating a local unscoped installation, remove its plugin entry before installing this package; do not enable both together. Use the same DSH profile and home to retain locally stored service settings and grants.
|
|
@@ -41,7 +41,7 @@ pnpm install --frozen-lockfile --ignore-scripts
|
|
|
41
41
|
pnpm run typecheck
|
|
42
42
|
pnpm test
|
|
43
43
|
pnpm pack --pack-destination artifacts
|
|
44
|
-
dsh plugin --profile web add "$(pwd)/artifacts/noob9527-dsh-mcp-oauth-0.2.0-rc.
|
|
44
|
+
dsh plugin --profile web add "$(pwd)/artifacts/noob9527-dsh-mcp-oauth-0.2.0-rc.2.tgz"
|
|
45
45
|
```
|
|
46
46
|
|
|
47
47
|
Tests require OpenSSL supporting `req -addext`. No model API key or business MCP endpoint is needed for automated tests. Restart DSH when prompted. If DSH uses a custom `DSH_HOME`, use the same value for plugin installation and startup. For npm installation, check `npm config get registry` if the package cannot be resolved; the public registry is `https://registry.npmjs.org/`.
|
|
@@ -64,10 +64,10 @@ The initial service list is empty. A placeholder endpoint is `https://mcp.exampl
|
|
|
64
64
|
| Client ID / secret | Pre-registered identity; the secret is stored separately |
|
|
65
65
|
| Callback mode | Local automatic, remote HTTPS automatic, or manual response paste; remote automatic requires an administrator-configured proxy |
|
|
66
66
|
| Internal loopback listener port | Remote mode only; defaults to 6274, always bound to 127.0.0.1 |
|
|
67
|
-
| Callback URL | Defaults to `http://127.0.0.1
|
|
67
|
+
| Callback URL | Defaults to `http://127.0.0.1/oauth/callback`; local mode chooses a free port when none is specified |
|
|
68
68
|
| Scopes | Optional space-separated scope names |
|
|
69
69
|
|
|
70
|
-
Automatic mode uses configured pre-registration first, then CIMD when configured and supported, then dynamic registration. Explicit CIMD fails when unsupported. The
|
|
70
|
+
Automatic mode uses configured pre-registration first, then CIMD when configured and supported, then dynamic registration. Explicit CIMD fails when unsupported. The public CIMD document declares native-client callbacks at `http://127.0.0.1/oauth/callback` and `http://localhost/oauth/callback`. Local mode binds an OS-assigned port before authorization and uses that exact URL for authorization and token exchange. Explicitly configured ports remain fixed and report conflicts; existing settings are not migrated. Authorization servers must support native loopback port matching (RFC 8252). Remote HTTPS callbacks and manual responses retain exact matching.
|
|
71
71
|
|
|
72
72
|
Advanced defaults: connection timeout 30 seconds, sign-in timeout 5 minutes, tool deadline 10 minutes, refresh lead time 60 seconds, 5 reconnect attempts with a maximum delay of 30 seconds. Tool deadlines are total deadlines, not progress-reset timers.
|
|
73
73
|
|
|
@@ -124,3 +124,21 @@ Authentication recovery failure withdraws the affected service’s tools and req
|
|
|
124
124
|
## License
|
|
125
125
|
|
|
126
126
|
[MIT](LICENSE). Dependencies retain their own licenses.
|
|
127
|
+
|
|
128
|
+
### Host OAuth diagnostics
|
|
129
|
+
|
|
130
|
+
OAuth login and refresh failures emit a JSON `mcp_oauth_failure` record to Host stderr. Container operators should inspect the Host/container logs, not the chat transcript. Records contain a hashed service identifier, the failure stage, and up to six allowlisted error classifications, network codes and HTTP status numbers. Stages are `callback_setup`, `resource_challenge`, `discovery_and_registration`, `authorization_callback`, `token_exchange`, `credential_persistence` and `refresh`. The discovery stage includes SDK-managed registration. Unknown errors remain `UnknownError`; absence of a classified reason does not imply success. Proxy tunnel rejection status is extracted from recognized proxy error text without retaining the text.
|
|
131
|
+
|
|
132
|
+
Diagnostics omit raw messages, stacks, URLs, service labels, request/response bodies, headers, authorization codes, state and credentials. They are not returned in Client state or session events. UI error codes remain unchanged. A hashed identifier correlates failures but is not an access credential.
|
|
133
|
+
|
|
134
|
+
When adding a service, Service ID is blank under Advanced, with a placeholder generated from the display name. Saving uses the entered ID or, when blank, the generated ID. Clearing a manually entered ID restores automatic generation. Non-ASCII letters use Unicode code-point segments. Duplicate IDs are rejected; change the ID in Advanced. Saved services retain their existing, read-only ID when renamed.
|
|
135
|
+
|
|
136
|
+
New services prefill the [public client metadata document](https://noob9527.github.io/dsh-mcp-oauth/oauth/client-metadata.json) in **Advanced → Client metadata document URL**. You can edit or clear this value. Existing services retain their saved value, including an empty value. The hosted document supports both local hostnames with the `/oauth/callback` path and variable ports. Other callback paths or remote callbacks require a matching document.
|
|
137
|
+
|
|
138
|
+
Scopes appears under Advanced and defaults to empty for automatic discovery. Separate multiple scopes with spaces. Existing configured scopes remain unchanged.
|
|
139
|
+
|
|
140
|
+
The service form shows only Display name and MCP URL by default. All other configuration fields are under Advanced; expanding it does not change stored values. Validation errors in advanced fields expand that section automatically.
|
|
141
|
+
|
|
142
|
+
Each configuration field has a help button with a localized tooltip. Hover, focus with the keyboard or click to read its purpose; click outside or press Escape to dismiss it.
|
|
143
|
+
|
|
144
|
+
Registration mode controls the fields in Advanced: Automatic shows Client ID, Client secret and Client metadata document URL; CIMD shows only the document URL; Pre-registration shows Client ID and Client secret; DCR shows none of these. Switching modes retains draft values. Saving DCR or pre-registered settings clears the unused metadata URL; hidden client identity values are retained. Validation errors name the affected fields. The callback URL is hidden for local callbacks or when the active registration identity uses the default hosted document; its saved value is preserved. The default document supports local callbacks only. Remote or manual callbacks need compatible client metadata and callback settings.
|
package/README.zh.md
CHANGED
|
@@ -6,28 +6,28 @@
|
|
|
6
6
|
|
|
7
7
|
## 状态与兼容性
|
|
8
8
|
|
|
9
|
-
本项目是独立社区插件,并非 DeepSeek 官方产品。npm 0.1.0 仅支持本机回调;0.2.0-rc.
|
|
9
|
+
本项目是独立社区插件,并非 DeepSeek 官方产品。npm 0.1.0 仅支持本机回调;0.2.0-rc.2 新增远程个人实例回调和手动粘贴授权响应。
|
|
10
10
|
|
|
11
11
|
| 客户端 | 验证状态 |
|
|
12
12
|
| --- | --- |
|
|
13
13
|
| 官方 DSH 0.2.1-alpha.3 / 0.2.2-rc.1 Web,本机 macOS | 当前候选包:已验证浏览器 CIMD 授权和真实聊天调用 |
|
|
14
14
|
| 官方 Desktop | 计划支持,尚待验收 |
|
|
15
15
|
| 其他 DSH 版本 | 未声明兼容 |
|
|
16
|
-
| 远程个人 DSH,0.2.0-rc.
|
|
16
|
+
| 远程个人 DSH,0.2.0-rc.2 | HTTPS 代理 fixture 已验证,实际部署仍需验收 |
|
|
17
17
|
| 多人共享 DSH | 不支持 |
|
|
18
18
|
|
|
19
|
-
0.2.0-rc.
|
|
19
|
+
0.2.0-rc.2 要求 DSH `>=0.2.1-alpha.3`。[17 版本兼容矩阵](docs/compatibility.md)中满足下限的 13 个已发布版本均通过自动化检查。范围允许安装后续版本,但不代表后续版本自动通过验收。0.1.0 保留原 rc.2 限制。
|
|
20
20
|
|
|
21
21
|
## 从 npm 安装
|
|
22
22
|
|
|
23
23
|
需要 Node 24.9+ 和满足 `>=0.2.1-alpha.3` 的未经修改官方 DSH。公开包名为 `@noob9527/dsh-mcp-oauth`。
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
`0.2.0-rc.2` 为通过 `next` 分发的候选版本;`latest` 用于安装稳定版。
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
安装已发布的预览版:
|
|
28
28
|
|
|
29
29
|
```sh
|
|
30
|
-
dsh plugin --profile web add @noob9527/dsh-mcp-oauth@
|
|
30
|
+
dsh plugin --profile web add @noob9527/dsh-mcp-oauth@next
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
无 scope 的 `dsh-mcp-oauth` 属于其他项目。从本地旧包迁移时,先移除旧插件条目,再安装新包,不要同时启用两者。使用相同 DSH profile 和 home,以保留本机服务配置和授权记录。
|
|
@@ -41,7 +41,7 @@ pnpm install --frozen-lockfile --ignore-scripts
|
|
|
41
41
|
pnpm run typecheck
|
|
42
42
|
pnpm test
|
|
43
43
|
pnpm pack --pack-destination artifacts
|
|
44
|
-
dsh plugin --profile web add "$(pwd)/artifacts/noob9527-dsh-mcp-oauth-0.2.0-rc.
|
|
44
|
+
dsh plugin --profile web add "$(pwd)/artifacts/noob9527-dsh-mcp-oauth-0.2.0-rc.2.tgz"
|
|
45
45
|
```
|
|
46
46
|
|
|
47
47
|
测试需要支持 `req -addext` 的 OpenSSL;自动化测试不需要模型 API Key 或业务 MCP 服务。DSH 提示需要重启时,重启后继续。如果使用自定义 `DSH_HOME`,安装插件和启动 DSH 时必须使用相同值。通过 npm 安装时,如无法解析包名,请检查 `npm config get registry`;公开 registry 为 `https://registry.npmjs.org/`。
|
|
@@ -54,13 +54,13 @@ Desktop 使用独立 profile,目前尚未完成其安装和 OAuth 验收。
|
|
|
54
54
|
|
|
55
55
|
## 配置
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
候选版本支持“本机”“远程个人实例”自动回调和“手动粘贴授权响应”三种回调方式。远程模式配置公网 HTTPS 回调 URL 和内部监听端口(默认 6274),监听地址固定为 `127.0.0.1`。代理必须与实例共享网络命名空间,每人拥有独立 Host、profile 和凭据存储。部署步骤、CIMD 模板及降级限制见[远程个人实例指南](docs/remote-personal-instances.zh.md)。
|
|
58
58
|
|
|
59
59
|
默认服务列表为空。文档中的 `https://mcp.example.com/mcp` 仅为占位地址。
|
|
60
60
|
|
|
61
61
|
- 自动模式优先使用已配置的预注册身份,其次使用服务端支持的 CIMD,最后尝试 DCR。
|
|
62
|
-
- CIMD
|
|
63
|
-
- 默认回调为 `http://127.0.0.1
|
|
62
|
+
- 插件提供公共 CIMD 文档,声明 `127.0.0.1` 和 `localhost` 两种本机回调;用户仍可替换文档地址。
|
|
63
|
+
- 默认回调为 `http://127.0.0.1/oauth/callback`。本机模式未填写端口时,登录前由系统分配空闲端口,授权请求和 token 交换使用同一个实际地址;授权服务器须支持 RFC 8252 原生客户端 loopback 端口匹配。已有显式端口配置保持固定,冲突时仍报错;远程 HTTPS 回调和手动响应仍精确匹配。
|
|
64
64
|
- 客户端密钥单独保存;编辑表单留空表示保留已有值。清除授权会删除包含密钥的本机授权记录。
|
|
65
65
|
- 高级设置默认:连接超时 30 秒、授权超时 5 分钟、工具总时限 10 分钟、提前 60 秒刷新、最多重连 5 次且间隔不超过 30 秒。
|
|
66
66
|
|
|
@@ -74,7 +74,7 @@ Desktop 使用独立 profile,目前尚未完成其安装和 OAuth 验收。
|
|
|
74
74
|
|
|
75
75
|
刷新 token 不主动中断已受理的长调用。HTTP 401 最多触发一次 SDK 认证后重发;断线或超时不会自动重放工具调用。出现“结果未知”时,先核查服务端执行情况,再决定是否重试。
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
候选版本支持本机及远程个人 Web 实例;Desktop 仍待验收。不支持多人共享 Host、旧版 SSE/stdio、MCP Tasks、资源浏览和提示词浏览。
|
|
78
78
|
|
|
79
79
|
## 升级与卸载
|
|
80
80
|
|
|
@@ -104,3 +104,21 @@ pnpm exec tsx tests/serve-fixture.ts
|
|
|
104
104
|
## 许可证
|
|
105
105
|
|
|
106
106
|
[MIT](LICENSE)。依赖保留各自的许可证。
|
|
107
|
+
|
|
108
|
+
### Host OAuth 诊断日志
|
|
109
|
+
|
|
110
|
+
OAuth 登录和刷新失败会向 Host 标准错误输出 JSON `mcp_oauth_failure` 记录。容器部署请查看 Host/容器日志,而非聊天记录。日志包含服务标识摘要、失败阶段,以及最多六层允许输出的错误分类、网络错误码和 HTTP 状态码。阶段包括 `callback_setup`、`resource_challenge`、`discovery_and_registration`、`authorization_callback`、`token_exchange`、`credential_persistence` 和 `refresh`;发现阶段包含 SDK 管理的客户端注册。未知错误保留为 `UnknownError`,未识别原因不表示成功。代理隧道拒绝状态从已识别的错误文本中提取,原始文本不会保留。
|
|
111
|
+
|
|
112
|
+
日志不包含原始消息、堆栈、URL、服务显示名称、请求或响应正文、请求头、授权码、state 或凭据,也不进入 Client 状态和会话事件。UI 错误码保持不变。服务标识摘要用于关联错误,不是访问凭据。
|
|
113
|
+
|
|
114
|
+
新增服务时,高级设置中的服务标识默认为空,占位文字展示根据显示名称生成的标识。保存时使用手动填写的标识,留空则使用自动生成值;清空手动填写的标识可恢复自动生成。非 ASCII 字母使用 Unicode 码点片段。标识重复时拒绝保存,请在高级设置中修改。已有服务保留原标识,编辑时不可修改,重命名也不会改变标识。
|
|
115
|
+
|
|
116
|
+
新增服务在 **Advanced → Client metadata document URL** 中预填[公开客户端元数据文档](https://noob9527.github.io/dsh-mcp-oauth/oauth/client-metadata.json),允许修改或清空。已有服务保留原值,包括空值。该文档支持两种本机主机名、`/oauth/callback` 路径和动态端口;其他路径或远程回调需要使用匹配的文档。
|
|
117
|
+
|
|
118
|
+
Scopes(权限范围)位于高级设置,默认留空以自动发现;多个权限用空格分隔。已有配置的权限范围保持不变。
|
|
119
|
+
|
|
120
|
+
服务表单默认仅显示 Display name(显示名称)和 MCP URL,其余配置项均位于 Advanced(高级设置)。展开高级设置不会改变已有配置;高级字段校验失败时自动展开。
|
|
121
|
+
|
|
122
|
+
每个配置项旁都有说明按钮,支持悬停、键盘聚焦或点击查看中英文用途提示;点击外部或按 Escape 可关闭。
|
|
123
|
+
|
|
124
|
+
高级设置中的字段按注册模式显示:自动模式显示客户端 ID、客户端密钥和元数据文档 URL;CIMD 仅显示文档 URL;预注册显示客户端 ID 和密钥;DCR 隐藏这三项。切换模式时保留草稿值;保存 DCR 或预注册配置时清空不适用的元数据文档 URL,隐藏的客户端身份值保持不变。校验错误会列出有问题的字段。本机回调或当前注册身份使用默认托管文档时隐藏回调 URL,保留已保存的值。默认文档仅支持本机回调;远程或手动回调需要相匹配的客户端元数据和回调配置。
|
package/SECURITY.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Security
|
|
2
2
|
|
|
3
|
-
This
|
|
3
|
+
This plugin integrates OAuth credentials and external tools. DSH >=0.2.1-alpha.3 is supported; Desktop acceptance is pending. See the README for deployment limitations.
|
|
4
4
|
|
|
5
5
|
Do not put tokens, client secrets, authorization codes, credential files or unsanitized logs in public issues or pull requests.
|
|
6
6
|
|
package/docs/acceptance.md
CHANGED
|
@@ -118,3 +118,15 @@ The in-app browser's failed-navigation API exposed an internal error page instea
|
|
|
118
118
|
On 2026-11-16, the adapted 0.2.0-rc.1 candidate was built against DSH 0.2.1-alpha.3 and installed as a tarball in clean official Web profiles for 0.2.1-alpha.3 and 0.2.2-rc.1. Both passed plugin/settings loading, independent browser CIMD login, discovery of two tools, and a real-chat search returning `document-1`. The fixture confirmed exactly one search per client, two validated CIMD documents and no DCR registration. See the [17-version matrix](compatibility.md) for automated coverage and evidence limits.
|
|
119
119
|
|
|
120
120
|
When preparing model credentials in an isolated home, retain the official versioned document format (`version: 1` with `refs`); a flat or incomplete credentials document prevents OAuth credential writes and can prevent DSH startup. Keep the file and values outside the repository.
|
|
121
|
+
|
|
122
|
+
## Dynamic local callback ports
|
|
123
|
+
|
|
124
|
+
The 0.2.0-rc.2 development build passed 89 automated tests on 2026-11-17. Local callbacks without a port bind an OS-assigned loopback port before OAuth discovery; the authorization request and token exchange use the same actual URL. Both `127.0.0.1` and `localhost` complete CIMD, DCR and pre-registered flows against the local fixture, refresh tokens, reuse persisted grants after restart and call the deterministic search tool. Concurrent receivers have distinct active ports; wrong state, Host, path and repeated responses are rejected, and cancellation releases the listener. Explicit-port conflict tests and remote/manual callback tests still pass.
|
|
125
|
+
|
|
126
|
+
The CIMD fixture applies native loopback port matching only; scheme, hostname, path and query changes remain mismatches. These tests establish compatibility with that fixture policy, not with arbitrary authorization servers. Local DCR browser acceptance is recorded under Configuration form release acceptance below. Existing persisted explicit-port configurations retain their fixed-port behavior.
|
|
127
|
+
|
|
128
|
+
## Configuration form release acceptance
|
|
129
|
+
|
|
130
|
+
On 2026-11-17, the 0.2.0-rc.2 configuration page was exercised in the in-app browser using packed installations on unmodified DSH 0.2.1-alpha.3 and isolated profiles. Checks covered generated/read-only service IDs, duplicate rejection, registration-dependent fields, default CIMD callback restrictions, save/edit persistence, English/dark and Chinese/light rendering, constrained layouts and help dismissal. Local DCR consent with a dynamically allocated callback port reached Authorized / Connected / Tools: 2; disable/enable restored tools without renewed consent.
|
|
131
|
+
|
|
132
|
+
After validation fixes, the rebuilt tarball rejected malformed MCP URLs with a field-specific message and no browser console errors. DCR and pre-registration saved despite an invalid inactive metadata draft; CIMD still rejected invalid metadata, and pre-registration still required Client ID. Saved DCR metadata was empty on reopening. Typecheck, build and all 99 automated tests passed. These checks do not qualify Desktop, deployed remote authorization or a new model-driven chat call.
|
package/docs/releasing.md
CHANGED
|
@@ -25,23 +25,29 @@ pnpm run check:release
|
|
|
25
25
|
pnpm run typecheck
|
|
26
26
|
pnpm test
|
|
27
27
|
pnpm pack --pack-destination artifacts
|
|
28
|
-
node scripts/check-release.mjs --tarball artifacts/noob9527-dsh-mcp-oauth-0.2.0-rc.
|
|
28
|
+
node scripts/check-release.mjs --tarball artifacts/noob9527-dsh-mcp-oauth-0.2.0-rc.2.tgz
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
Manually create a GitHub prerelease and attach the reviewed tarball if preview distribution is desired. A source release and an npm release are distinct operations.
|
|
32
32
|
|
|
33
|
-
Publish release candidates under `next`, leaving the stable `latest` tag unchanged.
|
|
33
|
+
Version `0.2.0-rc.2` is a release candidate. Publishing requires acceptance and explicit release approval. Publish release candidates under `next`, leaving the stable `latest` tag unchanged.
|
|
34
34
|
|
|
35
|
-
The distribution target is the public npm registry under `@noob9527/dsh-mcp-oauth`. Package metadata fixes the registry and public access. Authenticate as an account permitted to publish under the `noob9527` scope; keep credentials outside this repository. Review the exact tarball with `npm publish ./artifacts/noob9527-dsh-mcp-oauth-0.2.0-rc.
|
|
35
|
+
The distribution target is the public npm registry under `@noob9527/dsh-mcp-oauth`. Package metadata fixes the registry and public access. Authenticate as an account permitted to publish under the `noob9527` scope; keep credentials outside this repository. Review the exact tarball with `npm publish ./artifacts/noob9527-dsh-mcp-oauth-0.2.0-rc.2.tgz --dry-run`, then publish that same file with `npm publish ./artifacts/noob9527-dsh-mcp-oauth-0.2.0-rc.2.tgz --access public --tag next`. Verify the registry version and install the published package into a clean official DSH profile before announcing it. No workflow automatically publishes npm packages.
|
|
36
36
|
|
|
37
37
|
## Authentication and post-publication checks
|
|
38
38
|
|
|
39
39
|
Before publishing, check `npm config get registry` and `npm whoami --registry=https://registry.npmjs.org/`. The expected registry is `https://registry.npmjs.org/` and the account must have access to the package scope. A successful login alone does not satisfy npm's publishing authentication requirements. Complete the account's 2FA/browser verification when requested; do not put tokens, one-time codes or verification URLs in repository files or CI logs.
|
|
40
40
|
|
|
41
|
-
An exit code of zero can mean the upload was accepted while npm still processes the package. If the CLI reports processing and public lookup returns 404, wait and check again; do not repeatedly publish the same version. Confirm `npm view @noob9527/dsh-mcp-oauth@0.2.0-rc.
|
|
41
|
+
An exit code of zero can mean the upload was accepted while npm still processes the package. If the CLI reports processing and public lookup returns 404, wait and check again; do not repeatedly publish the same version. Confirm `npm view @noob9527/dsh-mcp-oauth@0.2.0-rc.2 version dist.shasum --registry=https://registry.npmjs.org/`, compare the package digest, and install by registry package name in a clean official DSH profile. Only then mark registry installation as verified and remove any pending-availability notice from the READMEs and acceptance record.
|
|
42
42
|
|
|
43
43
|
Published name/version pairs cannot be overwritten. Repository documentation fixes after publication do not update the README bundled in that tarball; include them in a subsequent package version when needed. Keep the reviewed release tarball intact for digest comparison.
|
|
44
44
|
|
|
45
45
|
## Evidence limits
|
|
46
46
|
|
|
47
47
|
Local Web acceptance and the automated suite are recorded in acceptance.md. Desktop remains unqualified. Local screenshots, counters and tarballs under artifacts/ are intentionally ignored; review them before any separate upload. Do not publish URLs containing browser login tokens, callback codes or OAuth state.
|
|
48
|
+
|
|
49
|
+
## Publish the client metadata document
|
|
50
|
+
|
|
51
|
+
The `site/` directory contains only public OAuth client metadata. Its GitHub Pages deployment uses the `gh-pages` branch root. After reviewing and committing changes to `site/`, publish its subtree with `git subtree split --prefix=site` and push the returned commit with `git push origin <commit>:gh-pages`. Subsequent deployments must retain branch history; do not force-push. Configure repository Pages to deploy from `gh-pages` at `/ (root)`. This publishes static metadata only, not an npm package.
|
|
52
|
+
|
|
53
|
+
Verify the document URL returns HTTP 200 without redirects, a JSON Content-Type, and a `client_id` exactly matching its URL. Keep the URL stable and retain supported redirect URIs when updating the document. The default native-client document supports the `/oauth/callback` path on localhost and 127.0.0.1 with variable ports; it contains no credentials or deployment-specific service addresses.
|
package/lib/client.js
CHANGED
|
@@ -19895,6 +19895,7 @@ var ResultValue = class {
|
|
|
19895
19895
|
|
|
19896
19896
|
// src/config.ts
|
|
19897
19897
|
var endpoint = external_exports.string().url().refine((value) => {
|
|
19898
|
+
if (!URL.canParse(value)) return false;
|
|
19898
19899
|
const url2 = new URL(value);
|
|
19899
19900
|
return !url2.username && !url2.password && !url2.hash && (url2.protocol === "https:" || url2.protocol === "http:" && ["127.0.0.1", "[::1]", "localhost"].includes(url2.hostname));
|
|
19900
19901
|
}, "Use HTTPS, or HTTP on loopback, without user information or fragments.");
|
|
@@ -19907,12 +19908,13 @@ var serverSchema = external_exports.object({
|
|
|
19907
19908
|
mode: external_exports.enum(["auto", "cimd", "preregistered", "dcr"]).default("auto"),
|
|
19908
19909
|
clientId: external_exports.string().max(2048).default(""),
|
|
19909
19910
|
metadataUrl: external_exports.union([external_exports.literal(""), external_exports.string().url().refine((value) => {
|
|
19911
|
+
if (!URL.canParse(value)) return false;
|
|
19910
19912
|
const url2 = new URL(value);
|
|
19911
19913
|
return url2.protocol === "https:" && url2.pathname !== "/" && !url2.username && !url2.password && !url2.hash;
|
|
19912
19914
|
})]).default(""),
|
|
19913
19915
|
callbackMode: external_exports.enum(["local", "remote", "manual"]).default("local"),
|
|
19914
19916
|
callbackPort: external_exports.number().int().min(1).max(65535).default(6274),
|
|
19915
|
-
redirectUrl: external_exports.string().url().default("http://127.0.0.1
|
|
19917
|
+
redirectUrl: external_exports.string().url().default("http://127.0.0.1/oauth/callback"),
|
|
19916
19918
|
scope: external_exports.string().max(2048).default(""),
|
|
19917
19919
|
connectTimeoutMs: duration3.default(3e4),
|
|
19918
19920
|
authTimeoutMs: duration3.default(3e5),
|
|
@@ -19929,9 +19931,10 @@ var serverSchema = external_exports.object({
|
|
|
19929
19931
|
}
|
|
19930
19932
|
const clean = redirect.pathname !== "/" && !redirect.search && !redirect.hash && !redirect.username && !redirect.password;
|
|
19931
19933
|
const https = redirect.protocol === "https:" && !["localhost", "127.0.0.1", "[::1]"].includes(redirect.hostname);
|
|
19932
|
-
const loopback = redirect.protocol === "http:" &&
|
|
19933
|
-
const
|
|
19934
|
-
|
|
19934
|
+
const loopback = redirect.protocol === "http:" && ["127.0.0.1", "localhost"].includes(redirect.hostname);
|
|
19935
|
+
const manualLoopback = loopback && !!redirect.port && Number(redirect.port) > 0;
|
|
19936
|
+
const valid = value.callbackMode === "remote" ? https : value.callbackMode === "manual" ? https || manualLoopback : loopback;
|
|
19937
|
+
if (!clean || !valid) ctx.addIssue({ code: "custom", path: ["redirectUrl"], message: "Use HTTPS for remote callbacks; local callbacks require a loopback HTTP URL with a path; omit the port for automatic allocation. Manual mode requires HTTPS or an explicit loopback port." });
|
|
19935
19938
|
if (value.mode === "cimd" && !value.metadataUrl) ctx.addIssue({ code: "custom", path: ["metadataUrl"], message: "CIMD requires a metadata document URL." });
|
|
19936
19939
|
if (value.mode === "preregistered" && !value.clientId) ctx.addIssue({ code: "custom", path: ["clientId"], message: "Pre-registration requires a client ID." });
|
|
19937
19940
|
});
|
|
@@ -19959,8 +19962,58 @@ var remoteInfo = createTypertRemoteInfo({ package: "@noob9527/dsh-mcp-oauth", me
|
|
|
19959
19962
|
"mcpOAuth/act": method([["id", external_exports.string()], ["action", actionSchema]], external_exports.null())
|
|
19960
19963
|
} }, external_exports);
|
|
19961
19964
|
|
|
19965
|
+
// src/client/form.ts
|
|
19966
|
+
function parseServiceForm(config2) {
|
|
19967
|
+
return serverSchema.safeParse({
|
|
19968
|
+
...config2,
|
|
19969
|
+
metadataUrl: config2.mode === "dcr" || config2.mode === "preregistered" ? "" : config2.metadataUrl
|
|
19970
|
+
});
|
|
19971
|
+
}
|
|
19972
|
+
var defaultMetadataUrl = "https://noob9527.github.io/dsh-mcp-oauth/oauth/client-metadata.json";
|
|
19973
|
+
function usesDefaultMetadata(config2) {
|
|
19974
|
+
return config2.metadataUrl === defaultMetadataUrl && (config2.mode === "cimd" || config2.mode === "auto" && !config2.clientId);
|
|
19975
|
+
}
|
|
19976
|
+
function showsCallbackUrl(config2) {
|
|
19977
|
+
return config2.callbackMode !== "local" && !usesDefaultMetadata(config2);
|
|
19978
|
+
}
|
|
19979
|
+
function changeCallbackMode(config2, callbackMode) {
|
|
19980
|
+
const redirect = URL.canParse(config2.redirectUrl) ? new URL(config2.redirectUrl) : void 0;
|
|
19981
|
+
const local = redirect?.protocol === "http:" && ["127.0.0.1", "localhost"].includes(redirect.hostname);
|
|
19982
|
+
return { ...config2, callbackMode, redirectUrl: callbackMode === "local" && !local ? "http://127.0.0.1/oauth/callback" : config2.redirectUrl };
|
|
19983
|
+
}
|
|
19984
|
+
|
|
19985
|
+
// src/client/service-id.ts
|
|
19986
|
+
function serviceIdFromLabel(label) {
|
|
19987
|
+
const slug = label.normalize("NFKD").toLowerCase().replace(/\p{M}/gu, "").replace(/[^a-z0-9\s-]/gu, (char) => /\p{L}|\p{N}/u.test(char) ? `-u${char.codePointAt(0).toString(16)}-` : "-").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
19988
|
+
return (slug ? /^[a-z]/.test(slug) ? slug : `service-${slug}` : "service").slice(0, 32).replace(/-+$/g, "");
|
|
19989
|
+
}
|
|
19990
|
+
|
|
19962
19991
|
// src/client/locales.ts
|
|
19963
19992
|
var en = {
|
|
19993
|
+
fieldHelp: "Help",
|
|
19994
|
+
defaultCallbackHelp: "The default CIMD document is for local callbacks. Select Local, or configure a custom document matching your remote or manual callback.",
|
|
19995
|
+
clientIdAutoPlaceholder: "Optional; leave blank to try CIMD or dynamic registration",
|
|
19996
|
+
clientIdRequiredPlaceholder: "Required; enter the pre-registered client ID",
|
|
19997
|
+
secretPlaceholder: "Optional; only for pre-registered confidential clients",
|
|
19998
|
+
secretEditPlaceholder: "Leave blank to keep any saved secret",
|
|
19999
|
+
labelTooltip: "Name shown in the service list. Renaming a saved service does not change its Service ID.",
|
|
20000
|
+
urlTooltip: "Streamable HTTP endpoint of the MCP server. Use the MCP endpoint, not the authorization or metadata URL.",
|
|
20001
|
+
idTooltip: "Unique identifier for tool names and stored authorization. Leave blank to use the identifier generated from the display name, shown as placeholder text. Read-only after saving. Duplicate IDs must be changed manually.",
|
|
20002
|
+
modeTooltip: "Automatic uses configured pre-registration first, then supported CIMD, then DCR. An explicit mode does not fall back to a different registration method.",
|
|
20003
|
+
clientIdTooltip: "Client identifier issued by the authorization server for pre-registration. In automatic mode, a supplied ID takes priority; leave blank to try CIMD or dynamic registration. CIMD uses the metadata document URL as the client ID. Required in pre-registered mode.",
|
|
20004
|
+
secretTooltip: "Secret for a pre-registered confidential client, stored separately from service configuration. Leave blank for public clients; when editing, blank preserves an existing secret.",
|
|
20005
|
+
metadataUrlTooltip: "Public HTTPS CIMD JSON document describing this client and its permitted callbacks. New services use the plugin\u2019s hosted document; custom callbacks need a matching document.",
|
|
20006
|
+
callbackModeTooltip: "Local receives the browser callback on this computer. Remote personal instance uses an administrator-configured HTTPS proxy. Manual response paste accepts the full callback URL without starting a listener.",
|
|
20007
|
+
redirectUrlTooltip: "OAuth return address. Local mode supports 127.0.0.1 or localhost and chooses a free port when omitted; explicit ports stay fixed. Remote mode requires HTTPS. Manual mode requires HTTPS or an explicit local port. Must be allowed by the client metadata.",
|
|
20008
|
+
callbackPortTooltip: "Internal port bound to 127.0.0.1 in remote mode. The HTTPS reverse proxy must forward to this port while preserving the external Host and path.",
|
|
20009
|
+
scopeTooltip: "Permissions requested during OAuth login. Leave blank for automatic discovery; separate multiple scopes with spaces. The authorization server decides which permissions are granted.",
|
|
20010
|
+
connectTimeoutMsTooltip: "Timeout in milliseconds for connection setup, tool discovery and individual OAuth network requests. Default: 30000 ms.",
|
|
20011
|
+
authTimeoutMsTooltip: "Total time allowed to complete one login, including browser consent. Expiry cancels the pending login. Default: 300000 ms.",
|
|
20012
|
+
toolTimeoutMsTooltip: "Total deadline for a tool call. A timeout can leave its result unknown; the plugin does not automatically replay it. Default: 600000 ms.",
|
|
20013
|
+
refreshSkewMsTooltip: "Refresh an expiring token this many milliseconds early before a request, when a refresh token is available. Does not interrupt an accepted tool call. Default: 60000 ms.",
|
|
20014
|
+
reconnectAttemptsTooltip: "Maximum automatic connection recovery attempts. Set 0 to disable automatic recovery. Reconnection does not replay tool calls. Default: 5.",
|
|
20015
|
+
reconnectMaxDelayMsTooltip: "Upper limit in milliseconds on the increasing delay between automatic reconnection attempts. Default: 30000 ms.",
|
|
20016
|
+
manualResponseTooltip: "Paste the complete callback URL from the login you just approved. It contains a sensitive one-use authorization response; do not send it in chat or paste an access token here.",
|
|
19964
20017
|
title: "OAuth MCP",
|
|
19965
20018
|
description: "Connect personal DSH instances to OAuth-protected MCP tools.",
|
|
19966
20019
|
add: "Add service",
|
|
@@ -19986,7 +20039,8 @@ var en = {
|
|
|
19986
20039
|
metadataUrl: "Client metadata document URL",
|
|
19987
20040
|
redirectUrl: "OAuth callback URL",
|
|
19988
20041
|
scope: "Scopes",
|
|
19989
|
-
|
|
20042
|
+
scopePlaceholder: "Auto-discover (optional)",
|
|
20043
|
+
secret: "Client secret",
|
|
19990
20044
|
advanced: "Advanced",
|
|
19991
20045
|
connectTimeoutMs: "Connection timeout (ms)",
|
|
19992
20046
|
authTimeoutMs: "Sign-in timeout (ms)",
|
|
@@ -20006,8 +20060,9 @@ var en = {
|
|
|
20006
20060
|
connecting: "Connecting",
|
|
20007
20061
|
connected: "Connected",
|
|
20008
20062
|
connectionFailed: "Connection failed",
|
|
20063
|
+
duplicateId: "Invalid configuration: Service ID already exists. Change Service ID in Advanced.",
|
|
20009
20064
|
tools: "Tools",
|
|
20010
|
-
invalid: "Check the
|
|
20065
|
+
invalid: "Check the following fields:",
|
|
20011
20066
|
deploymentHelp: "Supports local and remote personal instances. Shared multi-user hosts are not supported.",
|
|
20012
20067
|
callbackMode: "Callback mode",
|
|
20013
20068
|
localMode: "Local",
|
|
@@ -20021,11 +20076,35 @@ var en = {
|
|
|
20021
20076
|
manualReceived: "Response received. Wait for authorization and connection results above.",
|
|
20022
20077
|
callbackPort: "Internal loopback listener port",
|
|
20023
20078
|
remoteHelp: "An administrator must proxy your HTTPS callback to 127.0.0.1 on this instance, preserving Host and path. The proxy must share its network namespace. Use a dedicated instance and credential store.",
|
|
20024
|
-
local: "Open the authorization link on the computer running DSH.",
|
|
20079
|
+
local: "Open the authorization link on the computer running DSH. Omit the callback port to choose a free port automatically.",
|
|
20025
20080
|
deleteConfirm: "Delete this service and its local authorization?",
|
|
20026
20081
|
clearConfirm: "Clear the local authorization and disconnect this service?"
|
|
20027
20082
|
};
|
|
20028
20083
|
var zh = {
|
|
20084
|
+
fieldHelp: "\u8BF4\u660E",
|
|
20085
|
+
defaultCallbackHelp: "\u9ED8\u8BA4 CIMD \u6587\u6863\u7528\u4E8E\u672C\u673A\u56DE\u8C03\u3002\u8BF7\u9009\u62E9\u672C\u673A\u6A21\u5F0F\uFF0C\u6216\u914D\u7F6E\u4E0E\u8FDC\u7A0B\u3001\u624B\u52A8\u56DE\u8C03\u5339\u914D\u7684\u81EA\u5B9A\u4E49\u6587\u6863\u3002",
|
|
20086
|
+
clientIdAutoPlaceholder: "\u53EF\u9009\uFF1B\u7559\u7A7A\u65F6\u5C1D\u8BD5 CIMD \u6216\u52A8\u6001\u6CE8\u518C",
|
|
20087
|
+
clientIdRequiredPlaceholder: "\u5FC5\u586B\uFF1B\u8BF7\u8F93\u5165\u9884\u6CE8\u518C\u7684\u5BA2\u6237\u7AEF ID",
|
|
20088
|
+
secretPlaceholder: "\u53EF\u9009\uFF1B\u4EC5\u9884\u6CE8\u518C\u673A\u5BC6\u5BA2\u6237\u7AEF\u9700\u8981",
|
|
20089
|
+
secretEditPlaceholder: "\u7559\u7A7A\u4FDD\u7559\u5DF2\u6709\u5BC6\u94A5",
|
|
20090
|
+
labelTooltip: "\u670D\u52A1\u5217\u8868\u4E2D\u663E\u793A\u7684\u540D\u79F0\u3002\u4FEE\u6539\u5DF2\u4FDD\u5B58\u670D\u52A1\u7684\u540D\u79F0\u4E0D\u4F1A\u6539\u53D8\u670D\u52A1\u6807\u8BC6\u3002",
|
|
20091
|
+
urlTooltip: "MCP \u670D\u52A1\u7684 Streamable HTTP \u63A5\u53E3\u5730\u5740\uFF0C\u5E94\u586B\u5199 MCP \u7AEF\u70B9\uFF0C\u800C\u975E\u6388\u6743\u9875\u6216\u5143\u6570\u636E\u6587\u6863\u5730\u5740\u3002",
|
|
20092
|
+
idTooltip: "\u7528\u4E8E\u5DE5\u5177\u547D\u540D\u548C\u6388\u6743\u5B58\u50A8\u7684\u552F\u4E00\u6807\u8BC6\u3002\u7559\u7A7A\u65F6\u4F7F\u7528\u5360\u4F4D\u6587\u5B57\u4E2D\u6839\u636E\u663E\u793A\u540D\u79F0\u751F\u6210\u7684\u6807\u8BC6\uFF0C\u4FDD\u5B58\u540E\u53EA\u8BFB\uFF1B\u91CD\u590D\u65F6\u9700\u8981\u624B\u52A8\u4FEE\u6539\u3002",
|
|
20093
|
+
modeTooltip: "\u81EA\u52A8\u6A21\u5F0F\u4F18\u5148\u4F7F\u7528\u5DF2\u914D\u7F6E\u7684\u9884\u6CE8\u518C\u8EAB\u4EFD\uFF0C\u5176\u6B21\u4F7F\u7528\u53D7\u652F\u6301\u7684 CIMD\uFF0C\u6700\u540E\u5C1D\u8BD5 DCR\u3002\u660E\u786E\u9009\u62E9\u4E00\u79CD\u65B9\u5F0F\u540E\uFF0C\u4E0D\u4F1A\u81EA\u52A8\u5207\u6362\u5176\u4ED6\u6CE8\u518C\u65B9\u5F0F\u3002",
|
|
20094
|
+
clientIdTooltip: "\u6388\u6743\u670D\u52A1\u5668\u4E3A\u9884\u6CE8\u518C\u5BA2\u6237\u7AEF\u63D0\u4F9B\u7684\u6807\u8BC6\u3002\u81EA\u52A8\u6A21\u5F0F\u4E0B\u586B\u5199\u540E\u4F18\u5148\u4F7F\u7528\u9884\u6CE8\u518C\u8EAB\u4EFD\uFF0C\u7559\u7A7A\u65F6\u5C1D\u8BD5 CIMD \u6216\u52A8\u6001\u6CE8\u518C\uFF1BCIMD \u4F7F\u7528\u5143\u6570\u636E\u6587\u6863 URL \u4F5C\u4E3A\u5BA2\u6237\u7AEF ID\u3002\u9884\u6CE8\u518C\u6A21\u5F0F\u4E0B\u5FC5\u586B\u3002",
|
|
20095
|
+
secretTooltip: "\u9884\u6CE8\u518C\u673A\u5BC6\u5BA2\u6237\u7AEF\u7684\u5BC6\u94A5\uFF0C\u4E0E\u670D\u52A1\u914D\u7F6E\u5206\u5F00\u5B58\u50A8\u3002\u516C\u5171\u5BA2\u6237\u7AEF\u65E0\u9700\u586B\u5199\uFF1B\u7F16\u8F91\u65F6\u7559\u7A7A\u4F1A\u4FDD\u7559\u5DF2\u6709\u5BC6\u94A5\u3002",
|
|
20096
|
+
metadataUrlTooltip: "\u516C\u5F00\u7684 HTTPS CIMD JSON \u6587\u6863\uFF0C\u58F0\u660E\u5BA2\u6237\u7AEF\u8EAB\u4EFD\u548C\u5141\u8BB8\u7684\u56DE\u8C03\u5730\u5740\u3002\u65B0\u589E\u670D\u52A1\u9ED8\u8BA4\u4F7F\u7528\u63D2\u4EF6\u6258\u7BA1\u6587\u6863\uFF1B\u81EA\u5B9A\u4E49\u56DE\u8C03\u9700\u5339\u914D\u5BF9\u5E94\u6587\u6863\u3002",
|
|
20097
|
+
callbackModeTooltip: "\u672C\u673A\u6A21\u5F0F\u5728\u5F53\u524D\u7535\u8111\u63A5\u6536\u6D4F\u89C8\u5668\u56DE\u8C03\uFF1B\u8FDC\u7A0B\u4E2A\u4EBA\u5B9E\u4F8B\u6A21\u5F0F\u4F7F\u7528\u7BA1\u7406\u5458\u914D\u7F6E\u7684 HTTPS \u4EE3\u7406\uFF1B\u624B\u52A8\u54CD\u5E94\u6A21\u5F0F\u7C98\u8D34\u5B8C\u6574\u56DE\u8C03 URL\uFF0C\u4E0D\u542F\u52A8\u76D1\u542C\u5668\u3002",
|
|
20098
|
+
redirectUrlTooltip: "OAuth \u6388\u6743\u540E\u7684\u8FD4\u56DE\u5730\u5740\u3002\u672C\u673A\u6A21\u5F0F\u652F\u6301 127.0.0.1 \u6216 localhost\uFF0C\u7701\u7565\u7AEF\u53E3\u65F6\u81EA\u52A8\u5206\u914D\uFF0C\u663E\u5F0F\u7AEF\u53E3\u4FDD\u6301\u56FA\u5B9A\u3002\u8FDC\u7A0B\u6A21\u5F0F\u987B\u4E3A HTTPS\uFF1B\u624B\u52A8\u6A21\u5F0F\u987B\u4E3A HTTPS \u6216\u5E26\u660E\u786E\u7AEF\u53E3\u7684\u672C\u673A\u5730\u5740\u3002\u5FC5\u987B\u7B26\u5408\u5BA2\u6237\u7AEF\u5143\u6570\u636E\u5141\u8BB8\u7684\u56DE\u8C03\u3002",
|
|
20099
|
+
callbackPortTooltip: "\u8FDC\u7A0B\u6A21\u5F0F\u4E0B\u5728 127.0.0.1 \u4E0A\u76D1\u542C\u7684\u5185\u90E8\u7AEF\u53E3\u3002HTTPS \u53CD\u5411\u4EE3\u7406\u987B\u8F6C\u53D1\u5230\u8BE5\u7AEF\u53E3\uFF0C\u5E76\u4FDD\u7559\u5916\u90E8 Host \u548C\u8DEF\u5F84\u3002",
|
|
20100
|
+
scopeTooltip: "OAuth \u767B\u5F55\u65F6\u7533\u8BF7\u7684\u6743\u9650\u3002\u7559\u7A7A\u65F6\u81EA\u52A8\u53D1\u73B0\uFF1B\u591A\u4E2A\u6743\u9650\u7528\u7A7A\u683C\u5206\u9694\u3002\u5B9E\u9645\u6388\u4E88\u7684\u6743\u9650\u7531\u6388\u6743\u670D\u52A1\u5668\u51B3\u5B9A\u3002",
|
|
20101
|
+
connectTimeoutMsTooltip: "\u8FDE\u63A5\u5EFA\u7ACB\u3001\u5DE5\u5177\u53D1\u73B0\u53CA\u5355\u6B21 OAuth \u7F51\u7EDC\u8BF7\u6C42\u7684\u8D85\u65F6\u65F6\u95F4\uFF0C\u5355\u4F4D\u4E3A\u6BEB\u79D2\u3002\u9ED8\u8BA4 30000 \u6BEB\u79D2\u3002",
|
|
20102
|
+
authTimeoutMsTooltip: "\u5B8C\u6210\u4E00\u6B21\u767B\u5F55\u7684\u603B\u65F6\u9650\uFF0C\u5305\u542B\u6D4F\u89C8\u5668\u6388\u6743\u7B49\u5F85\u3002\u8D85\u65F6\u4F1A\u53D6\u6D88\u672C\u6B21\u767B\u5F55\u3002\u9ED8\u8BA4 300000 \u6BEB\u79D2\u3002",
|
|
20103
|
+
toolTimeoutMsTooltip: "\u5355\u6B21\u5DE5\u5177\u8C03\u7528\u7684\u603B\u65F6\u9650\u3002\u8D85\u65F6\u53EF\u80FD\u5BFC\u81F4\u7ED3\u679C\u672A\u77E5\uFF0C\u63D2\u4EF6\u4E0D\u4F1A\u81EA\u52A8\u91CD\u653E\u8C03\u7528\u3002\u9ED8\u8BA4 600000 \u6BEB\u79D2\u3002",
|
|
20104
|
+
refreshSkewMsTooltip: "\u6709\u5237\u65B0\u4EE4\u724C\u65F6\uFF0C\u5728\u8BF7\u6C42\u524D\u63D0\u524D\u6307\u5B9A\u6BEB\u79D2\u6570\u5237\u65B0\u5373\u5C06\u5230\u671F\u7684 token\u3002\u4E0D\u4F1A\u4E2D\u65AD\u5DF2\u53D7\u7406\u7684\u5DE5\u5177\u8C03\u7528\u3002\u9ED8\u8BA4 60000 \u6BEB\u79D2\u3002",
|
|
20105
|
+
reconnectAttemptsTooltip: "\u81EA\u52A8\u6062\u590D\u8FDE\u63A5\u7684\u6700\u5927\u5C1D\u8BD5\u6B21\u6570\uFF0C\u8BBE\u4E3A 0 \u53EF\u5173\u95ED\u81EA\u52A8\u6062\u590D\u3002\u91CD\u8FDE\u4E0D\u4F1A\u91CD\u653E\u5DE5\u5177\u8C03\u7528\u3002\u9ED8\u8BA4 5 \u6B21\u3002",
|
|
20106
|
+
reconnectMaxDelayMsTooltip: "\u81EA\u52A8\u91CD\u8FDE\u9010\u6B65\u589E\u52A0\u7684\u7B49\u5F85\u95F4\u9694\u4E0A\u9650\uFF0C\u5355\u4F4D\u4E3A\u6BEB\u79D2\u3002\u9ED8\u8BA4 30000 \u6BEB\u79D2\u3002",
|
|
20107
|
+
manualResponseTooltip: "\u7C98\u8D34\u521A\u521A\u6279\u51C6\u7684\u767B\u5F55\u6240\u5BF9\u5E94\u7684\u5B8C\u6574\u56DE\u8C03 URL\u3002\u5176\u4E2D\u5305\u542B\u654F\u611F\u7684\u4E00\u6B21\u6027\u6388\u6743\u54CD\u5E94\uFF0C\u8BF7\u52FF\u53D1\u9001\u5230\u804A\u5929\u4E2D\uFF0C\u4E5F\u4E0D\u8981\u5728\u6B64\u7C98\u8D34\u8BBF\u95EE\u4EE4\u724C\u3002",
|
|
20029
20108
|
title: "OAuth MCP",
|
|
20030
20109
|
description: "\u5728\u4E2A\u4EBA DSH \u5B9E\u4F8B\u4E2D\u8FDE\u63A5\u9700\u8981 OAuth \u6388\u6743\u7684 MCP \u5DE5\u5177\u3002",
|
|
20031
20110
|
add: "\u6DFB\u52A0\u670D\u52A1",
|
|
@@ -20051,7 +20130,8 @@ var zh = {
|
|
|
20051
20130
|
metadataUrl: "\u5BA2\u6237\u7AEF\u5143\u6570\u636E\u6587\u6863 URL",
|
|
20052
20131
|
redirectUrl: "OAuth \u56DE\u8C03 URL",
|
|
20053
20132
|
scope: "\u6743\u9650\u8303\u56F4",
|
|
20054
|
-
|
|
20133
|
+
scopePlaceholder: "\u81EA\u52A8\u53D1\u73B0\uFF08\u53EF\u9009\uFF09",
|
|
20134
|
+
secret: "\u5BA2\u6237\u7AEF\u5BC6\u94A5",
|
|
20055
20135
|
advanced: "\u9AD8\u7EA7\u8BBE\u7F6E",
|
|
20056
20136
|
connectTimeoutMs: "\u8FDE\u63A5\u8D85\u65F6\uFF08\u6BEB\u79D2\uFF09",
|
|
20057
20137
|
authTimeoutMs: "\u767B\u5F55\u8D85\u65F6\uFF08\u6BEB\u79D2\uFF09",
|
|
@@ -20072,8 +20152,9 @@ var zh = {
|
|
|
20072
20152
|
connected: "\u5DF2\u8FDE\u63A5",
|
|
20073
20153
|
connectionFailed: "\u8FDE\u63A5\u5931\u8D25",
|
|
20074
20154
|
tools: "\u5DE5\u5177\u6570",
|
|
20075
|
-
|
|
20076
|
-
|
|
20155
|
+
duplicateId: "\u914D\u7F6E\u65E0\u6548\uFF1A\u670D\u52A1\u6807\u8BC6\u5DF2\u5B58\u5728\uFF0C\u8BF7\u5728\u9AD8\u7EA7\u8BBE\u7F6E\u4E2D\u4FEE\u6539\u670D\u52A1\u6807\u8BC6\u3002",
|
|
20156
|
+
invalid: "\u8BF7\u68C0\u67E5\u4EE5\u4E0B\u5B57\u6BB5\uFF1A",
|
|
20157
|
+
local: "\u8BF7\u5728\u8FD0\u884C DSH \u7684\u7535\u8111\u4E0A\u6253\u5F00\u6388\u6743\u94FE\u63A5\u3002\u4E0D\u586B\u5199\u56DE\u8C03\u7AEF\u53E3\u65F6\uFF0C\u81EA\u52A8\u9009\u62E9\u7A7A\u95F2\u7AEF\u53E3\u3002",
|
|
20077
20158
|
deploymentHelp: "\u652F\u6301\u672C\u673A\u6216\u8FDC\u7A0B\u4E2A\u4EBA\u5B9E\u4F8B\uFF0C\u4E0D\u652F\u6301\u591A\u4EBA\u5171\u4EAB Host\u3002",
|
|
20078
20159
|
callbackMode: "\u56DE\u8C03\u65B9\u5F0F",
|
|
20079
20160
|
localMode: "\u672C\u673A",
|
|
@@ -20097,6 +20178,16 @@ var stack = { display: "grid", gap: 12, minWidth: 0 };
|
|
|
20097
20178
|
var actions = { display: "flex", flexWrap: "wrap", gap: 8 };
|
|
20098
20179
|
var box = { ...stack, padding: 16, border: "1px solid var(--dsw-border)", borderRadius: 12, overflowWrap: "anywhere" };
|
|
20099
20180
|
var numeric = ["connectTimeoutMs", "authTimeoutMs", "toolTimeoutMs", "refreshSkewMs", "reconnectAttempts", "reconnectMaxDelayMs"];
|
|
20181
|
+
function Field({ name, t, children }) {
|
|
20182
|
+
const id = (0, import_react.useId)();
|
|
20183
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: stack, children: [
|
|
20184
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: 4 }, children: [
|
|
20185
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { htmlFor: id, children: t(name) }),
|
|
20186
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Tooltip, { label: t(`${name}Tooltip`), side: "top", portal: true, openOnClick: true, maxWidth: 320, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { type: "button", size: "sm", "aria-label": `${t(name)} \u2014 ${t("fieldHelp")}`, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconInfoOutlineRegular, { size: 16 }) }) })
|
|
20187
|
+
] }),
|
|
20188
|
+
(0, import_react.cloneElement)(children, { id })
|
|
20189
|
+
] });
|
|
20190
|
+
}
|
|
20100
20191
|
function ManualInput({ id, t, invoke }) {
|
|
20101
20192
|
const [response, setResponse] = (0, import_react.useState)("");
|
|
20102
20193
|
const [pending, setPending] = (0, import_react.useState)(false);
|
|
@@ -20119,10 +20210,7 @@ function ManualInput({ id, t, invoke }) {
|
|
|
20119
20210
|
}
|
|
20120
20211
|
}, children: [
|
|
20121
20212
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: t("manualInstructions") }),
|
|
20122
|
-
/* @__PURE__ */ (0, import_jsx_runtime.
|
|
20123
|
-
t("manualResponse"),
|
|
20124
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Input, { type: "password", autoComplete: "off", spellCheck: false, maxLength: 16384, value: response, disabled: pending || received, onChange: (event) => setResponse(event.target.value) })
|
|
20125
|
-
] }),
|
|
20213
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { name: "manualResponse", t, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Input, { type: "password", autoComplete: "off", spellCheck: false, maxLength: 16384, value: response, disabled: pending || received, onChange: (event) => setResponse(event.target.value) }) }),
|
|
20126
20214
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { type: "submit", disabled: pending || received || !response.trim(), children: t("manualSubmit") }),
|
|
20127
20215
|
error62 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { role: "alert", children: error62 }),
|
|
20128
20216
|
received && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { role: "status", children: t("manualReceived") })
|
|
@@ -20134,6 +20222,8 @@ function Card({ t, view, invoke }) {
|
|
|
20134
20222
|
const [busy, setBusy] = (0, import_react.useState)(false);
|
|
20135
20223
|
const [draft, setDraft] = (0, import_react.useState)();
|
|
20136
20224
|
const [editing, setEditing] = (0, import_react.useState)(false);
|
|
20225
|
+
const [customId, setCustomId] = (0, import_react.useState)("");
|
|
20226
|
+
const [advanced, setAdvanced] = (0, import_react.useState)(false);
|
|
20137
20227
|
const [secret, setSecret] = (0, import_react.useState)("");
|
|
20138
20228
|
(0, import_react.useEffect)(() => {
|
|
20139
20229
|
if (view === "summary") return;
|
|
@@ -20203,6 +20293,8 @@ function Card({ t, view, invoke }) {
|
|
|
20203
20293
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { disabled: busy, onClick: () => {
|
|
20204
20294
|
setDraft(row.config);
|
|
20205
20295
|
setEditing(true);
|
|
20296
|
+
setCustomId("");
|
|
20297
|
+
setAdvanced(false);
|
|
20206
20298
|
setSecret("");
|
|
20207
20299
|
}, children: t("edit") }),
|
|
20208
20300
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { disabled: busy, onClick: () => {
|
|
@@ -20213,15 +20305,31 @@ function Card({ t, view, invoke }) {
|
|
|
20213
20305
|
] })
|
|
20214
20306
|
] }, row.config.id)),
|
|
20215
20307
|
!draft && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { disabled: busy, onClick: () => {
|
|
20216
|
-
setDraft(serverSchema.parse({ id: "
|
|
20308
|
+
setDraft(serverSchema.parse({ id: serviceIdFromLabel("MCP"), label: "MCP", url: "https://mcp.example.com/mcp", metadataUrl: defaultMetadataUrl }));
|
|
20217
20309
|
setEditing(false);
|
|
20310
|
+
setCustomId("");
|
|
20311
|
+
setAdvanced(false);
|
|
20218
20312
|
setSecret("");
|
|
20219
20313
|
}, children: t("add") }),
|
|
20220
|
-
draft && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", { style: box, onSubmit: (event) => {
|
|
20314
|
+
draft && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", { noValidate: true, style: box, onSubmit: (event) => {
|
|
20221
20315
|
event.preventDefault();
|
|
20222
|
-
|
|
20223
|
-
if (
|
|
20224
|
-
|
|
20316
|
+
if (busy) return;
|
|
20317
|
+
if (usesDefaultMetadata(draft) && draft.callbackMode !== "local") {
|
|
20318
|
+
setAdvanced(true);
|
|
20319
|
+
setError(t("defaultCallbackHelp"));
|
|
20320
|
+
return;
|
|
20321
|
+
}
|
|
20322
|
+
const effectiveId = editing ? draft.id : customId || serviceIdFromLabel(draft.label);
|
|
20323
|
+
const parsed = parseServiceForm({ ...draft, id: effectiveId });
|
|
20324
|
+
if (!editing && rows?.some((row) => row.config.id === effectiveId)) {
|
|
20325
|
+
setAdvanced(true);
|
|
20326
|
+
setError(t("duplicateId"));
|
|
20327
|
+
return;
|
|
20328
|
+
}
|
|
20329
|
+
if (!parsed.success) {
|
|
20330
|
+
const fields = [...new Set(parsed.error.issues.map((issue2) => issue2.path[0]))];
|
|
20331
|
+
if (fields.some((field) => field !== "label" && field !== "url")) setAdvanced(true);
|
|
20332
|
+
setError(t("invalid") + " " + fields.filter((field) => typeof field === "string" && field in en).map((field) => t(field)).join(", "));
|
|
20225
20333
|
return;
|
|
20226
20334
|
}
|
|
20227
20335
|
void run(async () => {
|
|
@@ -20230,37 +20338,29 @@ function Card({ t, view, invoke }) {
|
|
|
20230
20338
|
setSecret("");
|
|
20231
20339
|
});
|
|
20232
20340
|
}, children: [
|
|
20233
|
-
/* @__PURE__ */ (0, import_jsx_runtime.
|
|
20234
|
-
|
|
20235
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", { disabled: busy, value: draft.callbackMode, onChange: (event) => setDraft({ ...draft, callbackMode: serverSchema.shape.callbackMode.parse(event.target.value) }), children: [
|
|
20236
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "local", children: t("localMode") }),
|
|
20237
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "remote", children: t("remoteMode") }),
|
|
20238
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "manual", children: t("manualMode") })
|
|
20239
|
-
] })
|
|
20240
|
-
] }),
|
|
20241
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: t(draft.callbackMode === "manual" ? "manualHelp" : draft.callbackMode === "remote" ? "remoteHelp" : "local") }),
|
|
20242
|
-
draft.callbackMode === "remote" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { style: stack, children: [
|
|
20243
|
-
t("callbackPort"),
|
|
20244
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Input, { type: "number", disabled: busy, value: draft.callbackPort, onChange: (event) => setDraft({ ...draft, callbackPort: Number(event.target.value) }) })
|
|
20245
|
-
] }),
|
|
20246
|
-
["id", "label", "url", "clientId", "metadataUrl", "redirectUrl", "scope"].map((key) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { style: stack, children: [
|
|
20247
|
-
t(key),
|
|
20248
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Input, { value: draft[key], disabled: busy || key === "id" && editing, onChange: (event) => setDraft({ ...draft, [key]: event.target.value }) })
|
|
20249
|
-
] }, key)),
|
|
20250
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { style: stack, children: [
|
|
20251
|
-
t("mode"),
|
|
20252
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("select", { disabled: busy, value: draft.mode, onChange: (event) => setDraft({ ...draft, mode: serverSchema.shape.mode.parse(event.target.value) }), children: ["auto", "cimd", "preregistered", "dcr"].map((mode) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: mode, children: t(mode) }, mode)) })
|
|
20253
|
-
] }),
|
|
20254
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { style: stack, children: [
|
|
20255
|
-
t("secret"),
|
|
20256
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Input, { type: "password", autoComplete: "new-password", value: secret, disabled: busy, onChange: (event) => setSecret(event.target.value) })
|
|
20257
|
-
] }),
|
|
20258
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("details", { children: [
|
|
20341
|
+
["label", "url"].map((key) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { name: key, t, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Input, { value: draft[key], disabled: busy, onChange: (event) => setDraft({ ...draft, [key]: event.target.value }) }) }, key)),
|
|
20342
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("details", { open: advanced, onToggle: (event) => setAdvanced(event.currentTarget.open), children: [
|
|
20259
20343
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("summary", { children: t("advanced") }),
|
|
20260
|
-
/* @__PURE__ */ (0, import_jsx_runtime.
|
|
20261
|
-
t(
|
|
20262
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
20263
|
-
|
|
20344
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: stack, children: [
|
|
20345
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { name: "id", t, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Input, { value: editing ? draft.id : customId, placeholder: editing ? void 0 : serviceIdFromLabel(draft.label), disabled: busy || editing, onChange: (event) => setCustomId(event.target.value) }) }),
|
|
20346
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { name: "mode", t, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("select", { disabled: busy, value: draft.mode, onChange: (event) => setDraft({ ...draft, mode: serverSchema.shape.mode.parse(event.target.value) }), children: ["auto", "cimd", "preregistered", "dcr"].map((mode) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: mode, children: t(mode) }, mode)) }) }),
|
|
20347
|
+
(draft.mode === "auto" || draft.mode === "cimd") && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { name: "metadataUrl", t, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Input, { value: draft.metadataUrl, required: draft.mode === "cimd", disabled: busy, onChange: (event) => setDraft({ ...draft, metadataUrl: event.target.value }) }) }),
|
|
20348
|
+
(draft.mode === "auto" || draft.mode === "preregistered") && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
20349
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { name: "clientId", t, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Input, { value: draft.clientId, placeholder: t(draft.mode === "auto" ? "clientIdAutoPlaceholder" : "clientIdRequiredPlaceholder"), required: draft.mode === "preregistered", disabled: busy, onChange: (event) => setDraft({ ...draft, clientId: event.target.value }) }) }),
|
|
20350
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { name: "secret", t, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Input, { type: "password", autoComplete: "new-password", placeholder: t(editing ? "secretEditPlaceholder" : "secretPlaceholder"), value: secret, disabled: busy, onChange: (event) => setSecret(event.target.value) }) })
|
|
20351
|
+
] }),
|
|
20352
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { name: "callbackMode", t, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", { disabled: busy, value: draft.callbackMode, onChange: (event) => setDraft(changeCallbackMode(draft, serverSchema.shape.callbackMode.parse(event.target.value))), children: [
|
|
20353
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "local", children: t("localMode") }),
|
|
20354
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "remote", children: t("remoteMode") }),
|
|
20355
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "manual", children: t("manualMode") })
|
|
20356
|
+
] }) }),
|
|
20357
|
+
usesDefaultMetadata(draft) && draft.callbackMode !== "local" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { role: "status", children: t("defaultCallbackHelp") }),
|
|
20358
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: t(draft.callbackMode === "manual" ? "manualHelp" : draft.callbackMode === "remote" ? "remoteHelp" : "local") }),
|
|
20359
|
+
draft.callbackMode === "remote" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { name: "callbackPort", t, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Input, { type: "number", disabled: busy, value: draft.callbackPort, onChange: (event) => setDraft({ ...draft, callbackPort: Number(event.target.value) }) }) }),
|
|
20360
|
+
showsCallbackUrl(draft) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { name: "redirectUrl", t, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Input, { value: draft.redirectUrl, disabled: busy, onChange: (event) => setDraft({ ...draft, redirectUrl: event.target.value }) }) }),
|
|
20361
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { name: "scope", t, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Input, { value: draft.scope, disabled: busy, placeholder: t("scopePlaceholder"), onChange: (event) => setDraft({ ...draft, scope: event.target.value }) }) }),
|
|
20362
|
+
numeric.map((key) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, { name: key, t, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Input, { type: "number", disabled: busy, value: draft[key], onChange: (event) => setDraft({ ...draft, [key]: Number(event.target.value) }) }) }, key))
|
|
20363
|
+
] })
|
|
20264
20364
|
] }),
|
|
20265
20365
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: actions, children: [
|
|
20266
20366
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { type: "submit", disabled: busy, children: t("save") }),
|
package/lib/index.js
CHANGED
|
@@ -50,7 +50,7 @@ var __privateMethod = (obj, member, method2) => (__accessCheck(obj, member, "acc
|
|
|
50
50
|
// src/index.ts
|
|
51
51
|
import { mkdir, readFile, rename, writeFile, realpath } from "node:fs/promises";
|
|
52
52
|
import { join } from "node:path";
|
|
53
|
-
import { createHash as
|
|
53
|
+
import { createHash as createHash4, randomUUID } from "node:crypto";
|
|
54
54
|
import { TypertRemoteService, principalOf, Remote } from "@deepseek-ai/dsh-typert-protocol";
|
|
55
55
|
import { credentialKey } from "@deepseek-ai/dsh-credentials";
|
|
56
56
|
import { z as z4 } from "zod";
|
|
@@ -58,6 +58,7 @@ import { z as z4 } from "zod";
|
|
|
58
58
|
// src/config.ts
|
|
59
59
|
import { z } from "zod";
|
|
60
60
|
var endpoint = z.string().url().refine((value) => {
|
|
61
|
+
if (!URL.canParse(value)) return false;
|
|
61
62
|
const url = new URL(value);
|
|
62
63
|
return !url.username && !url.password && !url.hash && (url.protocol === "https:" || url.protocol === "http:" && ["127.0.0.1", "[::1]", "localhost"].includes(url.hostname));
|
|
63
64
|
}, "Use HTTPS, or HTTP on loopback, without user information or fragments.");
|
|
@@ -70,12 +71,13 @@ var serverSchema = z.object({
|
|
|
70
71
|
mode: z.enum(["auto", "cimd", "preregistered", "dcr"]).default("auto"),
|
|
71
72
|
clientId: z.string().max(2048).default(""),
|
|
72
73
|
metadataUrl: z.union([z.literal(""), z.string().url().refine((value) => {
|
|
74
|
+
if (!URL.canParse(value)) return false;
|
|
73
75
|
const url = new URL(value);
|
|
74
76
|
return url.protocol === "https:" && url.pathname !== "/" && !url.username && !url.password && !url.hash;
|
|
75
77
|
})]).default(""),
|
|
76
78
|
callbackMode: z.enum(["local", "remote", "manual"]).default("local"),
|
|
77
79
|
callbackPort: z.number().int().min(1).max(65535).default(6274),
|
|
78
|
-
redirectUrl: z.string().url().default("http://127.0.0.1
|
|
80
|
+
redirectUrl: z.string().url().default("http://127.0.0.1/oauth/callback"),
|
|
79
81
|
scope: z.string().max(2048).default(""),
|
|
80
82
|
connectTimeoutMs: duration.default(3e4),
|
|
81
83
|
authTimeoutMs: duration.default(3e5),
|
|
@@ -92,9 +94,10 @@ var serverSchema = z.object({
|
|
|
92
94
|
}
|
|
93
95
|
const clean = redirect.pathname !== "/" && !redirect.search && !redirect.hash && !redirect.username && !redirect.password;
|
|
94
96
|
const https = redirect.protocol === "https:" && !["localhost", "127.0.0.1", "[::1]"].includes(redirect.hostname);
|
|
95
|
-
const loopback = redirect.protocol === "http:" &&
|
|
96
|
-
const
|
|
97
|
-
|
|
97
|
+
const loopback = redirect.protocol === "http:" && ["127.0.0.1", "localhost"].includes(redirect.hostname);
|
|
98
|
+
const manualLoopback = loopback && !!redirect.port && Number(redirect.port) > 0;
|
|
99
|
+
const valid = value.callbackMode === "remote" ? https : value.callbackMode === "manual" ? https || manualLoopback : loopback;
|
|
100
|
+
if (!clean || !valid) ctx.addIssue({ code: "custom", path: ["redirectUrl"], message: "Use HTTPS for remote callbacks; local callbacks require a loopback HTTP URL with a path; omit the port for automatic allocation. Manual mode requires HTTPS or an explicit loopback port." });
|
|
98
101
|
if (value.mode === "cimd" && !value.metadataUrl) ctx.addIssue({ code: "custom", path: ["metadataUrl"], message: "CIMD requires a metadata document URL." });
|
|
99
102
|
if (value.mode === "preregistered" && !value.clientId) ctx.addIssue({ code: "custom", path: ["clientId"], message: "Pre-registration requires a client ID." });
|
|
100
103
|
});
|
|
@@ -109,7 +112,7 @@ var statusSchema = z.object({
|
|
|
109
112
|
var actionSchema = z.enum(["login", "cancel", "reconnect", "clear", "remove"]);
|
|
110
113
|
|
|
111
114
|
// src/provider.ts
|
|
112
|
-
import { randomBytes, createHash } from "node:crypto";
|
|
115
|
+
import { randomBytes, createHash as createHash2 } from "node:crypto";
|
|
113
116
|
import {
|
|
114
117
|
auth,
|
|
115
118
|
extractResourceMetadataUrl
|
|
@@ -127,6 +130,38 @@ function cancelled() {
|
|
|
127
130
|
return new DOMException("Cancelled", "AbortError");
|
|
128
131
|
}
|
|
129
132
|
|
|
133
|
+
// src/diagnostics.ts
|
|
134
|
+
import { createHash } from "node:crypto";
|
|
135
|
+
var names = /* @__PURE__ */ new Set(["Error", "TypeError", "AggregateError", "AbortError", "TimeoutError", "OAuthMcpError", "OAuthError", "SdkError", "SdkHttpError", "IssuerMismatchError", "RegistrationRejectedError", "InsecureTokenEndpointError", "AuthorizationServerMismatchError", "InsufficientScopeError", "UnauthorizedError"]);
|
|
136
|
+
var codes = /* @__PURE__ */ new Set(["OAUTH_LOGIN_REQUIRED", "OAUTH_CANCELLED", "OAUTH_CALLBACK_UNAVAILABLE", "OAUTH_CIMD_UNSUPPORTED", "OAUTH_ISSUER_CHANGED", "OAUTH_RESPONSE_INVALID", "OAUTH_RESPONSE_INACTIVE", "ECONNREFUSED", "ECONNRESET", "ETIMEDOUT", "ENOTFOUND", "EAI_AGAIN", "EACCES", "EPERM", "EADDRINUSE", "CERT_HAS_EXPIRED", "DEPTH_ZERO_SELF_SIGNED_CERT", "UNABLE_TO_VERIFY_LEAF_SIGNATURE", "UND_ERR_ABORTED", "UND_ERR_CONNECT_TIMEOUT", "UND_ERR_HEADERS_TIMEOUT", "UND_ERR_SOCKET", "invalid_grant", "invalid_client", "access_denied", "invalid_scope", "unauthorized_client", "unsupported_grant_type"]);
|
|
137
|
+
function oauthDiagnostic(identity, stage, error) {
|
|
138
|
+
const causes = [];
|
|
139
|
+
const seen = /* @__PURE__ */ new Set();
|
|
140
|
+
const visit = (value) => {
|
|
141
|
+
if (causes.length >= 6 || !value || typeof value !== "object" || seen.has(value)) return;
|
|
142
|
+
seen.add(value);
|
|
143
|
+
const row = { type: "UnknownError" };
|
|
144
|
+
if ("name" in value && typeof value.name === "string" && names.has(value.name)) row.type = value.name;
|
|
145
|
+
if ("code" in value && typeof value.code === "string" && codes.has(value.code)) row.code = value.code;
|
|
146
|
+
if ("status" in value && Number.isInteger(value.status) && typeof value.status === "number" && value.status >= 400 && value.status <= 599) row.status = value.status;
|
|
147
|
+
if ("message" in value && typeof value.message === "string") {
|
|
148
|
+
const match = /Proxy response \(([45]\d{2})\) !== 200 when HTTP Tunneling/.exec(value.message);
|
|
149
|
+
if (match) {
|
|
150
|
+
row.status = Number(match[1]);
|
|
151
|
+
row.reason = "proxy_tunnel_rejected";
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
causes.push(row);
|
|
155
|
+
if ("cause" in value) visit(value.cause);
|
|
156
|
+
if (value instanceof AggregateError) for (const child of value.errors.slice(0, 6)) visit(child);
|
|
157
|
+
};
|
|
158
|
+
visit(error);
|
|
159
|
+
return { event: "mcp_oauth_failure", service: createHash("sha256").update(identity).digest("hex").slice(0, 16), stage, causes };
|
|
160
|
+
}
|
|
161
|
+
function logOAuthFailure(identity, stage, error) {
|
|
162
|
+
console.warn(JSON.stringify(oauthDiagnostic(identity, stage, error)));
|
|
163
|
+
}
|
|
164
|
+
|
|
130
165
|
// src/manual-response.ts
|
|
131
166
|
import { timingSafeEqual } from "node:crypto";
|
|
132
167
|
var ManualResponse = class {
|
|
@@ -144,6 +179,9 @@ var ManualResponse = class {
|
|
|
144
179
|
signal.addEventListener("abort", this.abort, { once: true });
|
|
145
180
|
}
|
|
146
181
|
result;
|
|
182
|
+
get redirectUrl() {
|
|
183
|
+
return this.redirect;
|
|
184
|
+
}
|
|
147
185
|
settled = false;
|
|
148
186
|
resolve;
|
|
149
187
|
reject;
|
|
@@ -250,6 +288,9 @@ async function listenCallback(redirect, state, signal, reserved, listenPort) {
|
|
|
250
288
|
yes();
|
|
251
289
|
});
|
|
252
290
|
});
|
|
291
|
+
const address = server.address();
|
|
292
|
+
if (!address || typeof address === "string") throw new OAuthMcpError("OAUTH_CALLBACK_UNAVAILABLE");
|
|
293
|
+
if (target.protocol === "http:") target.port = String(address.port);
|
|
253
294
|
signal.throwIfAborted();
|
|
254
295
|
} catch {
|
|
255
296
|
signal.removeEventListener("abort", abort);
|
|
@@ -257,7 +298,7 @@ async function listenCallback(redirect, state, signal, reserved, listenPort) {
|
|
|
257
298
|
server.close();
|
|
258
299
|
throw new OAuthMcpError(signal.aborted ? "OAUTH_CANCELLED" : "OAUTH_CALLBACK_UNAVAILABLE");
|
|
259
300
|
}
|
|
260
|
-
return { result, async close() {
|
|
301
|
+
return { redirectUrl: target.href, result, async close() {
|
|
261
302
|
signal.removeEventListener("abort", abort);
|
|
262
303
|
server.removeListener("request", handle);
|
|
263
304
|
reject(cancelled());
|
|
@@ -271,7 +312,7 @@ var tokensSchema = z2.object({ access_token: z2.string(), token_type: z2.string(
|
|
|
271
312
|
var clientSchema = z2.object({ client_id: z2.string(), client_secret: z2.string().optional(), issuer: z2.string().optional() }).passthrough();
|
|
272
313
|
var grantSchema = z2.object({ version: z2.literal(1), binding: z2.string(), tokens: tokensSchema.optional(), client: clientSchema.optional(), expiresAt: z2.number().optional(), issuer: z2.string().optional(), secret: z2.string().optional() });
|
|
273
314
|
function binding(config) {
|
|
274
|
-
return
|
|
315
|
+
return createHash2("sha256").update(JSON.stringify([config.url, config.mode, config.clientId, config.metadataUrl, config.redirectUrl, config.scope])).digest("hex");
|
|
275
316
|
}
|
|
276
317
|
var Provider = class {
|
|
277
318
|
constructor(config, store, receiveCallback = listenCallback, now = Date.now) {
|
|
@@ -289,6 +330,8 @@ var Provider = class {
|
|
|
289
330
|
}
|
|
290
331
|
}
|
|
291
332
|
grant;
|
|
333
|
+
stage = "callback_setup";
|
|
334
|
+
failureStage;
|
|
292
335
|
verifier = "";
|
|
293
336
|
manual;
|
|
294
337
|
discovery;
|
|
@@ -308,10 +351,10 @@ var Provider = class {
|
|
|
308
351
|
if (parsed.data.binding === this.grant.binding) this.grant = parsed.data;
|
|
309
352
|
}
|
|
310
353
|
get redirectUrl() {
|
|
311
|
-
return this.config.redirectUrl;
|
|
354
|
+
return this.active?.redirectUrl ?? this.config.redirectUrl;
|
|
312
355
|
}
|
|
313
356
|
get clientMetadata() {
|
|
314
|
-
return { client_name: "DSH MCP OAuth", redirect_uris: [this.redirectUrl], grant_types: ["authorization_code", "refresh_token"], response_types: ["code"], token_endpoint_auth_method: this.grant.secret ? "client_secret_post" : "none", ...this.config.scope ? { scope: this.config.scope } : {} };
|
|
357
|
+
return { ...this.config.callbackMode === "local" ? { application_type: "native" } : {}, client_name: "DSH MCP OAuth", redirect_uris: [this.redirectUrl], grant_types: ["authorization_code", "refresh_token"], response_types: ["code"], token_endpoint_auth_method: (this.config.mode === "preregistered" || this.config.mode === "auto" && this.config.clientId) && this.grant.secret ? "client_secret_post" : "none", ...this.config.scope ? { scope: this.config.scope } : {} };
|
|
315
358
|
}
|
|
316
359
|
state() {
|
|
317
360
|
if (!this.active) throw new OAuthMcpError("OAUTH_LOGIN_REQUIRED");
|
|
@@ -369,7 +412,12 @@ var Provider = class {
|
|
|
369
412
|
persist(value) {
|
|
370
413
|
const write = this.writes.then(async () => {
|
|
371
414
|
if (this.stopped || this.active?.signal.aborted) throw new OAuthMcpError("OAUTH_CANCELLED");
|
|
372
|
-
|
|
415
|
+
try {
|
|
416
|
+
await this.store.write(value);
|
|
417
|
+
} catch (error) {
|
|
418
|
+
this.failureStage = "credential_persistence";
|
|
419
|
+
throw error;
|
|
420
|
+
}
|
|
373
421
|
this.grant = value;
|
|
374
422
|
});
|
|
375
423
|
this.writes = write.catch(() => {
|
|
@@ -379,7 +427,11 @@ var Provider = class {
|
|
|
379
427
|
fetch = (url, init) => fetch(url, { ...init, signal: AbortSignal.any([this.lifetime.signal, ...this.active ? [this.active.signal] : [], AbortSignal.timeout(this.config.connectTimeoutMs), ...init?.signal ? [init.signal] : []]) });
|
|
380
428
|
login(signal, notify) {
|
|
381
429
|
if (this.loginTask || this.stopped) return Promise.reject(new OAuthMcpError(this.stopped ? "OAUTH_STOPPED" : "OAUTH_BUSY"));
|
|
382
|
-
this.
|
|
430
|
+
this.failureStage = void 0;
|
|
431
|
+
this.loginTask = this.runLogin(signal, notify).catch((error) => {
|
|
432
|
+
logOAuthFailure(this.config.id + ":" + this.config.url, this.failureStage ?? this.stage, error);
|
|
433
|
+
throw error;
|
|
434
|
+
}).finally(() => {
|
|
383
435
|
this.loginTask = void 0;
|
|
384
436
|
});
|
|
385
437
|
return this.loginTask;
|
|
@@ -393,20 +445,26 @@ var Provider = class {
|
|
|
393
445
|
if (this.active) throw new OAuthMcpError("OAUTH_BUSY");
|
|
394
446
|
await this.refresh;
|
|
395
447
|
const lifetime = AbortSignal.any([signal, this.lifetime.signal, AbortSignal.timeout(this.config.authTimeoutMs)]);
|
|
396
|
-
this.active = { state: randomBytes(32).toString("hex"), signal: lifetime, notify };
|
|
448
|
+
this.active = { redirectUrl: this.config.redirectUrl, state: randomBytes(32).toString("hex"), signal: lifetime, notify };
|
|
397
449
|
let callback;
|
|
398
450
|
try {
|
|
451
|
+
this.stage = "callback_setup";
|
|
399
452
|
if (this.config.callbackMode === "manual") {
|
|
400
453
|
this.manual = new ManualResponse(this.redirectUrl, this.active.state, lifetime);
|
|
401
454
|
callback = this.manual;
|
|
402
455
|
} else callback = await this.receiveCallback(this.redirectUrl, this.active.state, lifetime, void 0, this.config.callbackMode === "remote" ? this.config.callbackPort : void 0);
|
|
456
|
+
this.active.redirectUrl = callback.redirectUrl;
|
|
457
|
+
this.stage = "resource_challenge";
|
|
403
458
|
const challenge = await this.fetch(this.config.url, { method: "GET" });
|
|
404
459
|
const resourceMetadataUrl = extractResourceMetadataUrl(challenge);
|
|
405
460
|
await challenge.body?.cancel();
|
|
461
|
+
this.stage = "discovery_and_registration";
|
|
406
462
|
const result = await auth(this, { serverUrl: this.config.url, resourceMetadataUrl, scope: this.config.scope || void 0, forceReauthorization: true, fetchFn: this.fetch });
|
|
407
463
|
if (result === "REDIRECT") {
|
|
464
|
+
this.stage = "authorization_callback";
|
|
408
465
|
const response = await callback.result;
|
|
409
466
|
lifetime.throwIfAborted();
|
|
467
|
+
this.stage = "token_exchange";
|
|
410
468
|
await auth(this, { serverUrl: this.config.url, authorizationCode: response.code, iss: response.iss, fetchFn: this.fetch });
|
|
411
469
|
}
|
|
412
470
|
lifetime.throwIfAborted();
|
|
@@ -421,11 +479,13 @@ var Provider = class {
|
|
|
421
479
|
renew(resourceMetadataUrl) {
|
|
422
480
|
if (this.active) return Promise.reject(new OAuthMcpError("OAUTH_BUSY"));
|
|
423
481
|
if (!this.refresh) {
|
|
482
|
+
this.failureStage = void 0;
|
|
424
483
|
this.refresh = (async () => {
|
|
425
484
|
if (!this.grant.tokens?.refresh_token) throw new OAuthMcpError("OAUTH_LOGIN_REQUIRED");
|
|
426
485
|
const result = await auth(this, { serverUrl: this.config.url, resourceMetadataUrl, fetchFn: this.fetch });
|
|
427
486
|
if (result !== "AUTHORIZED") throw new OAuthMcpError("OAUTH_LOGIN_REQUIRED");
|
|
428
|
-
})().catch(() => {
|
|
487
|
+
})().catch((error) => {
|
|
488
|
+
logOAuthFailure(this.config.id + ":" + this.config.url, this.failureStage ?? "refresh", error);
|
|
429
489
|
throw new OAuthMcpError("OAUTH_LOGIN_REQUIRED");
|
|
430
490
|
}).finally(() => {
|
|
431
491
|
this.refresh = void 0;
|
|
@@ -455,13 +515,13 @@ var Provider = class {
|
|
|
455
515
|
};
|
|
456
516
|
|
|
457
517
|
// src/connection.ts
|
|
458
|
-
import { createHash as
|
|
518
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
459
519
|
import { Client, StreamableHTTPClientTransport, UnauthorizedError, SdkHttpError, SdkErrorCode } from "@modelcontextprotocol/client";
|
|
460
520
|
import { createMcpToolDefinition } from "@deepseek-ai/dsh-mcp-client";
|
|
461
521
|
function toolName(server, raw) {
|
|
462
522
|
const name2 = `mcp__${server}__${raw}`;
|
|
463
523
|
if (name2.length <= 64 && /^[a-zA-Z0-9_-]+$/.test(name2)) return name2;
|
|
464
|
-
return name2.replace(/[^a-zA-Z0-9_-]/g, "_").slice(0, 51) + "_" +
|
|
524
|
+
return name2.replace(/[^a-zA-Z0-9_-]/g, "_").slice(0, 51) + "_" + createHash3("sha256").update(JSON.stringify([server, raw])).digest("hex").slice(0, 12);
|
|
465
525
|
}
|
|
466
526
|
var Connection = class {
|
|
467
527
|
constructor(ctx, provider, status) {
|
|
@@ -544,11 +604,11 @@ var Connection = class {
|
|
|
544
604
|
if (cursor) seen.add(cursor);
|
|
545
605
|
} while (cursor);
|
|
546
606
|
if (this.disposed || client !== this.client) return;
|
|
547
|
-
const
|
|
607
|
+
const names2 = /* @__PURE__ */ new Set();
|
|
548
608
|
const definitions = tools.map((tool) => {
|
|
549
609
|
const name2 = toolName(this.provider.config.id, tool.name);
|
|
550
|
-
if (
|
|
551
|
-
|
|
610
|
+
if (names2.has(name2)) throw new OAuthMcpError("MCP_TOOL_NAME_CONFLICT");
|
|
611
|
+
names2.add(name2);
|
|
552
612
|
if (tool.execution?.taskSupport === "required") throw new OAuthMcpError("MCP_TASKS_UNSUPPORTED");
|
|
553
613
|
return createMcpToolDefinition(this.ctx, {
|
|
554
614
|
name: name2,
|
|
@@ -696,7 +756,7 @@ var McpOAuth = class extends (_a = TypertRemoteService, _list_dec = [Remote], _s
|
|
|
696
756
|
for (const config of values) await this.mount(config);
|
|
697
757
|
}
|
|
698
758
|
key(id) {
|
|
699
|
-
return credentialKey("mcp-oauth", "grant-" +
|
|
759
|
+
return credentialKey("mcp-oauth", "grant-" + createHash4("sha256").update(JSON.stringify([this.profile, id])).digest("hex"));
|
|
700
760
|
}
|
|
701
761
|
owner() {
|
|
702
762
|
if (this.closed) throw new OAuthMcpError("OAUTH_STOPPED");
|
package/lib/types/callback.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/** One-attempt loopback receiver, optionally behind an HTTPS reverse proxy; a callback is not a successful token exchange. */
|
|
2
2
|
import { type Server } from 'node:http';
|
|
3
3
|
export interface Callback {
|
|
4
|
+
/** Actual destination, including the allocated port for a local receiver. */
|
|
5
|
+
readonly redirectUrl: string;
|
|
4
6
|
result: Promise<{
|
|
5
7
|
code: string;
|
|
6
8
|
iss?: string;
|
|
@@ -9,11 +11,11 @@ export interface Callback {
|
|
|
9
11
|
}
|
|
10
12
|
/**
|
|
11
13
|
* Accept one response for an active authorization; the caller closes the receiver.
|
|
12
|
-
* @param redirect -
|
|
14
|
+
* @param redirect - Local URL (omit the port for automatic allocation), or external proxy URL whose Host and path must survive proxying.
|
|
13
15
|
* @param state - One-time secret binding the response to the pending login.
|
|
14
16
|
* @param signal - Cancels reception and releases the socket.
|
|
15
17
|
* @param reserved - Optional atomically reserved socket for test isolation.
|
|
16
18
|
* @param listenPort - Internal port for HTTPS reverse proxying; binding stays on 127.0.0.1.
|
|
17
|
-
* @returns
|
|
19
|
+
* @returns Actual redirect URL, pending response and idempotent cleanup, not a completed token exchange.
|
|
18
20
|
*/
|
|
19
21
|
export declare function listenCallback(redirect: string, state: string, signal: AbortSignal, reserved?: Server, listenPort?: number): Promise<Callback>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** Registration-dependent callback visibility for the settings form. */
|
|
2
|
+
import { type ServerConfig } from '../config.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Validate settings for saving without the metadata URL unused by DCR or pre-registration.
|
|
5
|
+
* @param config Current form values; the draft is not mutated.
|
|
6
|
+
* @returns Validated settings or field validation issues.
|
|
7
|
+
*/
|
|
8
|
+
export declare function parseServiceForm(config: ServerConfig): import("zod").ZodSafeParseResult<{
|
|
9
|
+
id: string;
|
|
10
|
+
label: string;
|
|
11
|
+
url: string;
|
|
12
|
+
enabled: boolean;
|
|
13
|
+
mode: "auto" | "cimd" | "preregistered" | "dcr";
|
|
14
|
+
clientId: string;
|
|
15
|
+
metadataUrl: string;
|
|
16
|
+
callbackMode: "local" | "remote" | "manual";
|
|
17
|
+
callbackPort: number;
|
|
18
|
+
redirectUrl: string;
|
|
19
|
+
scope: string;
|
|
20
|
+
connectTimeoutMs: number;
|
|
21
|
+
authTimeoutMs: number;
|
|
22
|
+
toolTimeoutMs: number;
|
|
23
|
+
refreshSkewMs: number;
|
|
24
|
+
reconnectAttempts: number;
|
|
25
|
+
reconnectMaxDelayMs: number;
|
|
26
|
+
}>;
|
|
27
|
+
export declare const defaultMetadataUrl = "https://noob9527.github.io/dsh-mcp-oauth/oauth/client-metadata.json";
|
|
28
|
+
/** Whether the hosted document is selected by the current registration settings. */
|
|
29
|
+
export declare function usesDefaultMetadata(config: ServerConfig): boolean;
|
|
30
|
+
/** Whether the callback address can be edited for the selected mode. */
|
|
31
|
+
export declare function showsCallbackUrl(config: ServerConfig): boolean;
|
|
32
|
+
/** Switching to local restores a loopback address without rewriting an existing local address. */
|
|
33
|
+
export declare function changeCallbackMode(config: ServerConfig, callbackMode: ServerConfig['callbackMode']): ServerConfig;
|
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
/** Locale-owned configuration and action labels. */
|
|
2
2
|
export declare const en: {
|
|
3
|
+
readonly fieldHelp: "Help";
|
|
4
|
+
readonly defaultCallbackHelp: "The default CIMD document is for local callbacks. Select Local, or configure a custom document matching your remote or manual callback.";
|
|
5
|
+
readonly clientIdAutoPlaceholder: "Optional; leave blank to try CIMD or dynamic registration";
|
|
6
|
+
readonly clientIdRequiredPlaceholder: "Required; enter the pre-registered client ID";
|
|
7
|
+
readonly secretPlaceholder: "Optional; only for pre-registered confidential clients";
|
|
8
|
+
readonly secretEditPlaceholder: "Leave blank to keep any saved secret";
|
|
9
|
+
readonly labelTooltip: "Name shown in the service list. Renaming a saved service does not change its Service ID.";
|
|
10
|
+
readonly urlTooltip: "Streamable HTTP endpoint of the MCP server. Use the MCP endpoint, not the authorization or metadata URL.";
|
|
11
|
+
readonly idTooltip: "Unique identifier for tool names and stored authorization. Leave blank to use the identifier generated from the display name, shown as placeholder text. Read-only after saving. Duplicate IDs must be changed manually.";
|
|
12
|
+
readonly modeTooltip: "Automatic uses configured pre-registration first, then supported CIMD, then DCR. An explicit mode does not fall back to a different registration method.";
|
|
13
|
+
readonly clientIdTooltip: "Client identifier issued by the authorization server for pre-registration. In automatic mode, a supplied ID takes priority; leave blank to try CIMD or dynamic registration. CIMD uses the metadata document URL as the client ID. Required in pre-registered mode.";
|
|
14
|
+
readonly secretTooltip: "Secret for a pre-registered confidential client, stored separately from service configuration. Leave blank for public clients; when editing, blank preserves an existing secret.";
|
|
15
|
+
readonly metadataUrlTooltip: "Public HTTPS CIMD JSON document describing this client and its permitted callbacks. New services use the plugin’s hosted document; custom callbacks need a matching document.";
|
|
16
|
+
readonly callbackModeTooltip: "Local receives the browser callback on this computer. Remote personal instance uses an administrator-configured HTTPS proxy. Manual response paste accepts the full callback URL without starting a listener.";
|
|
17
|
+
readonly redirectUrlTooltip: "OAuth return address. Local mode supports 127.0.0.1 or localhost and chooses a free port when omitted; explicit ports stay fixed. Remote mode requires HTTPS. Manual mode requires HTTPS or an explicit local port. Must be allowed by the client metadata.";
|
|
18
|
+
readonly callbackPortTooltip: "Internal port bound to 127.0.0.1 in remote mode. The HTTPS reverse proxy must forward to this port while preserving the external Host and path.";
|
|
19
|
+
readonly scopeTooltip: "Permissions requested during OAuth login. Leave blank for automatic discovery; separate multiple scopes with spaces. The authorization server decides which permissions are granted.";
|
|
20
|
+
readonly connectTimeoutMsTooltip: "Timeout in milliseconds for connection setup, tool discovery and individual OAuth network requests. Default: 30000 ms.";
|
|
21
|
+
readonly authTimeoutMsTooltip: "Total time allowed to complete one login, including browser consent. Expiry cancels the pending login. Default: 300000 ms.";
|
|
22
|
+
readonly toolTimeoutMsTooltip: "Total deadline for a tool call. A timeout can leave its result unknown; the plugin does not automatically replay it. Default: 600000 ms.";
|
|
23
|
+
readonly refreshSkewMsTooltip: "Refresh an expiring token this many milliseconds early before a request, when a refresh token is available. Does not interrupt an accepted tool call. Default: 60000 ms.";
|
|
24
|
+
readonly reconnectAttemptsTooltip: "Maximum automatic connection recovery attempts. Set 0 to disable automatic recovery. Reconnection does not replay tool calls. Default: 5.";
|
|
25
|
+
readonly reconnectMaxDelayMsTooltip: "Upper limit in milliseconds on the increasing delay between automatic reconnection attempts. Default: 30000 ms.";
|
|
26
|
+
readonly manualResponseTooltip: "Paste the complete callback URL from the login you just approved. It contains a sensitive one-use authorization response; do not send it in chat or paste an access token here.";
|
|
3
27
|
readonly title: "OAuth MCP";
|
|
4
28
|
readonly description: "Connect personal DSH instances to OAuth-protected MCP tools.";
|
|
5
29
|
readonly add: "Add service";
|
|
@@ -25,7 +49,8 @@ export declare const en: {
|
|
|
25
49
|
readonly metadataUrl: "Client metadata document URL";
|
|
26
50
|
readonly redirectUrl: "OAuth callback URL";
|
|
27
51
|
readonly scope: "Scopes";
|
|
28
|
-
readonly
|
|
52
|
+
readonly scopePlaceholder: "Auto-discover (optional)";
|
|
53
|
+
readonly secret: "Client secret";
|
|
29
54
|
readonly advanced: "Advanced";
|
|
30
55
|
readonly connectTimeoutMs: "Connection timeout (ms)";
|
|
31
56
|
readonly authTimeoutMs: "Sign-in timeout (ms)";
|
|
@@ -45,8 +70,9 @@ export declare const en: {
|
|
|
45
70
|
readonly connecting: "Connecting";
|
|
46
71
|
readonly connected: "Connected";
|
|
47
72
|
readonly connectionFailed: "Connection failed";
|
|
73
|
+
readonly duplicateId: "Invalid configuration: Service ID already exists. Change Service ID in Advanced.";
|
|
48
74
|
readonly tools: "Tools";
|
|
49
|
-
readonly invalid: "Check the
|
|
75
|
+
readonly invalid: "Check the following fields:";
|
|
50
76
|
readonly deploymentHelp: "Supports local and remote personal instances. Shared multi-user hosts are not supported.";
|
|
51
77
|
readonly callbackMode: "Callback mode";
|
|
52
78
|
readonly localMode: "Local";
|
|
@@ -60,7 +86,7 @@ export declare const en: {
|
|
|
60
86
|
readonly manualReceived: "Response received. Wait for authorization and connection results above.";
|
|
61
87
|
readonly callbackPort: "Internal loopback listener port";
|
|
62
88
|
readonly remoteHelp: "An administrator must proxy your HTTPS callback to 127.0.0.1 on this instance, preserving Host and path. The proxy must share its network namespace. Use a dedicated instance and credential store.";
|
|
63
|
-
readonly local: "Open the authorization link on the computer running DSH.";
|
|
89
|
+
readonly local: "Open the authorization link on the computer running DSH. Omit the callback port to choose a free port automatically.";
|
|
64
90
|
readonly deleteConfirm: "Delete this service and its local authorization?";
|
|
65
91
|
readonly clearConfirm: "Clear the local authorization and disconnect this service?";
|
|
66
92
|
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type OAuthStage = 'callback_setup' | 'resource_challenge' | 'discovery_and_registration' | 'authorization_callback' | 'token_exchange' | 'credential_persistence' | 'refresh';
|
|
2
|
+
export type OAuthDiagnostic = {
|
|
3
|
+
event: 'mcp_oauth_failure';
|
|
4
|
+
service: string;
|
|
5
|
+
stage: OAuthStage;
|
|
6
|
+
causes: {
|
|
7
|
+
type: string;
|
|
8
|
+
code?: string;
|
|
9
|
+
status?: number;
|
|
10
|
+
reason?: 'proxy_tunnel_rejected';
|
|
11
|
+
}[];
|
|
12
|
+
};
|
|
13
|
+
/** Build bounded diagnostics from untrusted exceptions without copying messages, stacks or URLs.
|
|
14
|
+
* @param identity Stable private service identity; only its digest is emitted.
|
|
15
|
+
* @param stage OAuth operation that failed.
|
|
16
|
+
* @param error Original exception; never serialized directly.
|
|
17
|
+
* @returns A record containing only allowlisted classifications and HTTP status numbers.
|
|
18
|
+
*/
|
|
19
|
+
export declare function oauthDiagnostic(identity: string, stage: OAuthStage, error: unknown): OAuthDiagnostic;
|
|
20
|
+
/** Emit only the sanitized record to the Host's stderr, never to remote UI or session events. */
|
|
21
|
+
export declare function logOAuthFailure(identity: string, stage: OAuthStage, error: unknown): void;
|
package/lib/types/provider.d.ts
CHANGED
|
@@ -34,6 +34,8 @@ export declare class Provider implements OAuthClientProvider {
|
|
|
34
34
|
private readonly receiveCallback;
|
|
35
35
|
private readonly now;
|
|
36
36
|
private grant;
|
|
37
|
+
private stage;
|
|
38
|
+
private failureStage?;
|
|
37
39
|
private verifier;
|
|
38
40
|
private manual?;
|
|
39
41
|
private discovery?;
|
|
@@ -55,6 +57,7 @@ export declare class Provider implements OAuthClientProvider {
|
|
|
55
57
|
grant_types: string[];
|
|
56
58
|
response_types: string[];
|
|
57
59
|
token_endpoint_auth_method: string;
|
|
60
|
+
application_type?: string | undefined;
|
|
58
61
|
};
|
|
59
62
|
state(): string;
|
|
60
63
|
clientInformation(ctx?: OAuthClientInformationContext): StoredOAuthClientInformation | undefined;
|