@h-ai/serv 0.1.0-alpha.55 → 0.1.0-alpha.57
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/README.en.md +655 -0
- package/README.ja.md +655 -0
- package/README.md +9 -1
- package/dist/features/ai.d.ts +1 -1
- package/dist/features/iam.d.ts +1 -1
- package/dist/features/storage.d.ts +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js.map +1 -1
- package/dist/{serv-context-jc3rZxbj.d.ts → serv-context-C8JUUm6I.d.ts} +3 -3
- package/package.json +10 -10
|
@@ -87,7 +87,7 @@ interface RefreshCookieConfig {
|
|
|
87
87
|
* 与 Bearer accessToken。**不会**填充 `session`。
|
|
88
88
|
* - `buildAuthContextFactory(verifyToken)`:**带认证的上下文工厂**。在 `parseRequestContext` 基础上
|
|
89
89
|
* 异步调用 `verifyToken(accessToken)` 校验访问令牌,若成功则把会话写入 `context.session`。
|
|
90
|
-
* 失败或 token 不存在均使 `session = undefined
|
|
90
|
+
* 失败或 token 不存在均使 `session = undefined`,下游 `.auth()` 返回失败 HaiResult(error.httpStatus=401),普通 procedure 默认 HTTP 200。
|
|
91
91
|
*
|
|
92
92
|
* 应用层通常无需直接调用上述函数:`serv.createApp({ iam })` 内部自动选择最合适的工厂。
|
|
93
93
|
* @module serv-context
|
|
@@ -156,14 +156,14 @@ declare function parseRequestContext(input: CreateServContextInput): ServContext
|
|
|
156
156
|
* 1. 调用 `parseRequestContext` 提取元数据 + accessToken(仅来自 Authorization Bearer)
|
|
157
157
|
* 2. 若 `accessToken` 存在 → 调用 `verifyToken(accessToken)`
|
|
158
158
|
* 3. `verifyToken` 成功 → `session = result.data`;失败或 token 缺失 → `session = undefined`
|
|
159
|
-
* 4. 下游 `.auth()` / `.permission()` / `.role()` guard
|
|
159
|
+
* 4. 下游 `.auth()` / `.permission()` / `.role()` guard 据此返回 HaiResult(error.httpStatus=401/403),普通 procedure 默认 HTTP 200
|
|
160
160
|
*
|
|
161
161
|
* refresh token **不参与**这里的认证流程:它只在 access token 过期后,被 `/auth/refresh`
|
|
162
162
|
* 从浏览器 httpOnly cookie 或受信原生 JSON body 中读出,用于换发新的 access token。
|
|
163
163
|
*
|
|
164
164
|
* **安全保证**:
|
|
165
165
|
* - 每个请求都会重新调用 `verifyToken`(不缓存),用户被撤权后立即生效
|
|
166
|
-
* - `verifyToken` 失败时**不**抛错,统一收敛为 `session=undefined
|
|
166
|
+
* - `verifyToken` 失败时**不**抛错,统一收敛为 `session=undefined`,交由 guard 返回未认证的失败 HaiResult
|
|
167
167
|
* - 异常通过 try/catch 兜底,避免向 HTTP 层泄漏堆栈
|
|
168
168
|
*
|
|
169
169
|
* @param verifyToken - 访问令牌校验回调(通常是 `token => iam.session.verifyToken(token)` 或自定义函数)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h-ai/serv",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.0-alpha.
|
|
4
|
+
"version": "0.1.0-alpha.57",
|
|
5
5
|
"description": "Hai Framework service runtime powered by Hono and oRPC.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"exports": {
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"node": ">=22.12.0"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@h-ai/
|
|
39
|
-
"@h-ai/
|
|
40
|
-
"@h-ai/storage": "0.1.0-alpha.
|
|
38
|
+
"@h-ai/iam": "0.1.0-alpha.57",
|
|
39
|
+
"@h-ai/ai": "0.1.0-alpha.57",
|
|
40
|
+
"@h-ai/storage": "0.1.0-alpha.57"
|
|
41
41
|
},
|
|
42
42
|
"peerDependenciesMeta": {
|
|
43
43
|
"@h-ai/ai": {
|
|
@@ -59,9 +59,9 @@
|
|
|
59
59
|
"@scalar/api-reference": "^1.57.1",
|
|
60
60
|
"hono": "^4.12.18",
|
|
61
61
|
"zod": "^4.4.3",
|
|
62
|
-
"@h-ai/api-contract": "0.1.0-alpha.
|
|
63
|
-
"@h-ai/
|
|
64
|
-
"@h-ai/
|
|
62
|
+
"@h-ai/api-contract": "0.1.0-alpha.57",
|
|
63
|
+
"@h-ai/crypto": "0.1.0-alpha.57",
|
|
64
|
+
"@h-ai/core": "0.1.0-alpha.57"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@types/node": "^25.9.1",
|
|
@@ -69,9 +69,9 @@
|
|
|
69
69
|
"tsup": "^8.5.1",
|
|
70
70
|
"typescript": "^6.0.3",
|
|
71
71
|
"vitest": "^4.1.7",
|
|
72
|
-
"@h-ai/iam": "0.1.0-alpha.
|
|
73
|
-
"@h-ai/ai": "0.1.0-alpha.
|
|
74
|
-
"@h-ai/storage": "0.1.0-alpha.
|
|
72
|
+
"@h-ai/iam": "0.1.0-alpha.57",
|
|
73
|
+
"@h-ai/ai": "0.1.0-alpha.57",
|
|
74
|
+
"@h-ai/storage": "0.1.0-alpha.57"
|
|
75
75
|
},
|
|
76
76
|
"scripts": {
|
|
77
77
|
"build": "tsup",
|