@longzai-intelligence-auth/http 0.1.0

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.md ADDED
@@ -0,0 +1,15 @@
1
+ # @longzai-intelligence-auth/http
2
+
3
+ Auth 项目的 HTTP 传输认证包,为 HTTP 请求/响应模型提供握手级认证器,绑定认证核心的传输认证契约。
4
+
5
+ ## 定位
6
+
7
+ 位于 Auth 项目 transports 传输层,依赖 core 契约层与 credential 载体能力层。复用 credential 的共享认证编排(public path、失败归类、principal 映射),并提供 HTTP 特有的失败状态码映射,供框架适配层复用。
8
+
9
+ ## 核心能力
10
+
11
+ 提供 HTTP 传输认证器工厂;提供认证失败原因到 HTTP 状态码的映射工具;消费 strategies 层注入的请求级令牌验证器,统一返回传输认证主体。
12
+
13
+ ## 实现情况
14
+
15
+ 已实现 HTTP 传输认证器与状态码映射并统一导出,承载单元与 e2e 测试(含真实 Bun.serve HTTP 服务端验证),随传输协议扩展持续补充对应能力。
@@ -0,0 +1,24 @@
1
+ import { AuthOrchestrationOptions, TransportAuthResult, TransportAuthenticator } from "@longzai-intelligence-auth/core";
2
+ //#region src/index.d.ts
3
+ /**
4
+ * HTTP 传输认证器配置
5
+ */
6
+ type HttpAuthenticatorOptions = AuthOrchestrationOptions;
7
+ /**
8
+ * 把 HTTP 认证失败结果映射为 HTTP 状态码
9
+ *
10
+ * @param result - 认证失败结果
11
+ * @returns 对应的 HTTP 状态码
12
+ */
13
+ declare function mapHttpFailureStatus(result: Extract<TransportAuthResult, {
14
+ success: false;
15
+ }>): number;
16
+ /**
17
+ * 创建 HTTP 传输认证器
18
+ *
19
+ * @param options - HTTP 传输认证器配置
20
+ * @returns 实现 TransportAuthenticator 的 HTTP 认证器
21
+ */
22
+ declare function createHttpAuthenticator(options: HttpAuthenticatorOptions): TransportAuthenticator;
23
+ //#endregion
24
+ export { HttpAuthenticatorOptions, createHttpAuthenticator, mapHttpFailureStatus };
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ import{orchestrateAuth as e}from"@longzai-intelligence-auth/core";const t={missing:401,invalid:401,expired:401,forbidden:403};function n(e){return t[e.reason]??401}function r(t){return{async authenticate(n){return e(n,t)}}}export{r as createHttpAuthenticator,n as mapHttpFailureStatus};
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@longzai-intelligence-auth/http",
3
+ "version": "0.1.0",
4
+ "license": "UNLICENSED",
5
+ "files": [
6
+ "dist"
7
+ ],
8
+ "type": "module",
9
+ "sideEffects": false,
10
+ "main": "./dist/index.js",
11
+ "types": "./dist/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.js"
16
+ }
17
+ },
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "scripts": {
22
+ "build": "lzi-builder",
23
+ "build:prod": "NODE_ENV=production bun run build",
24
+ "prepublishOnly": "bun run build:prod",
25
+ "typecheck": "bun run typecheck:app && bun run typecheck:node && bun run typecheck:test",
26
+ "typecheck:app": "lzi-tsgo typecheck tsconfig/app.json",
27
+ "typecheck:node": "lzi-tsgo typecheck tsconfig/node.json",
28
+ "typecheck:test": "lzi-tsgo typecheck tsconfig/test.json",
29
+ "lint": "oxlint && oxfmt --check",
30
+ "lint:fix": "oxlint --fix && oxfmt",
31
+ "test": "bun test",
32
+ "test:watch": "bun test --watch",
33
+ "test:coverage": "bun test --coverage",
34
+ "test:unit": "bun test src/__tests__/unit/",
35
+ "test:integration": "bun test src/__tests__/integration/",
36
+ "clean": "lzi-dev-cli clean"
37
+ },
38
+ "dependencies": {
39
+ "@longzai-intelligence-auth/core": "0.1.0"
40
+ },
41
+ "devDependencies": {
42
+ "@longzai-intelligence-auth/bearer-jwt-strategy": "0.1.0",
43
+ "@longzai-intelligence-auth/cookie-jwt-strategy": "0.1.0",
44
+ "@longzai-intelligence-auth/jwt": "0.1.0"
45
+ }
46
+ }