Refactor WebSocket authentication handling by removing auth requirements from the hello message. Update related documentation and schemas to reflect the changes in authentication strategy, simplifying the connection process.
This commit is contained in:
@@ -33,18 +33,12 @@ If order is violated, server emits `error` with `code = "protocol.order"`.
|
||||
```json
|
||||
{
|
||||
"type": "hello",
|
||||
"version": "v1",
|
||||
"auth": {
|
||||
"apiKey": "optional-api-key",
|
||||
"jwt": "optional-jwt"
|
||||
}
|
||||
"version": "v1"
|
||||
}
|
||||
```
|
||||
|
||||
Rules:
|
||||
- `version` must be `v1`.
|
||||
- If `WS_API_KEY` is configured on server, `auth.apiKey` must match.
|
||||
- If `WS_REQUIRE_AUTH=true`, either `auth.apiKey` or `auth.jwt` must be present.
|
||||
|
||||
### `session.start`
|
||||
|
||||
@@ -205,7 +199,7 @@ Common events:
|
||||
- `trackId` convention:
|
||||
- `audio_in` for `stage in {audio, asr}`
|
||||
- `audio_out` for `stage in {llm, tts, tool}`
|
||||
- `control` otherwise (including protocol/auth errors)
|
||||
- `control` otherwise (including protocol errors)
|
||||
|
||||
Track IDs (MVP fixed values):
|
||||
- `audio_in`: ASR/VAD input-side events (`input.*`, `transcript.*`)
|
||||
|
||||
@@ -62,11 +62,7 @@
|
||||
```json
|
||||
{
|
||||
"type": "hello",
|
||||
"version": "v1",
|
||||
"auth": {
|
||||
"apiKey": "optional-api-key",
|
||||
"jwt": "optional-jwt"
|
||||
}
|
||||
"version": "v1"
|
||||
}
|
||||
```
|
||||
|
||||
@@ -76,13 +72,6 @@
|
||||
|---|---|---|---|---|---|
|
||||
| `type` | string | 是 | 固定 `"hello"` | 消息类型 | 握手第一条消息 |
|
||||
| `version` | string | 是 | 固定 `"v1"` | 协议版本 | 版本不匹配会 `protocol.version_unsupported` 并断开 |
|
||||
| `auth` | object \| null | 否 | 仅允许 `apiKey`、`jwt` | 认证载荷 | 认证策略由服务端配置决定 |
|
||||
| `auth.apiKey` | string \| null | 否 | 任意字符串 | API Key | 若服务端配置 `WS_API_KEY`,必须精确匹配 |
|
||||
| `auth.jwt` | string \| null | 否 | 任意字符串 | JWT 字符串 | 当 `WS_REQUIRE_AUTH=true` 时可用于满足“有认证信息”条件 |
|
||||
|
||||
认证行为:
|
||||
- 若设置了 `WS_API_KEY`:必须提供且匹配 `auth.apiKey`,否则 `auth.invalid_api_key` 并关闭连接。
|
||||
- 若 `WS_REQUIRE_AUTH=true` 且未设置 `WS_API_KEY`:`auth.apiKey` 或 `auth.jwt` 至少一个非空,否则 `auth.required` 并关闭连接。
|
||||
|
||||
## 3.2 `session.start`
|
||||
|
||||
@@ -472,7 +461,7 @@
|
||||
```
|
||||
|
||||
字段语义:
|
||||
- `sender`:错误来源角色(如 `client` / `server` / `auth`)
|
||||
- `sender`:错误来源角色(如 `client` / `server`)
|
||||
- `code`:机器可读错误码
|
||||
- `message`:人类可读描述
|
||||
- `stage`:阶段(`protocol|audio|asr|llm|tts|tool`)
|
||||
@@ -485,8 +474,6 @@
|
||||
- `protocol.order`
|
||||
- `protocol.version_unsupported`
|
||||
- `protocol.unsupported`
|
||||
- `auth.invalid_api_key`
|
||||
- `auth.required`
|
||||
- `audio.invalid_pcm`
|
||||
- `audio.frame_size_mismatch`
|
||||
- `audio.processing_failed`
|
||||
|
||||
Reference in New Issue
Block a user