@longzai-intelligence-auth/cookie-jwt-strategy 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 +15 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +1 -0
- package/package.json +45 -0
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# @longzai-intelligence-auth/cookie-jwt-strategy
|
|
2
|
+
|
|
3
|
+
Auth 项目的 Cookie JWT 验证策略包,组合 Cookie 凭证提取(载体维度)与令牌验证(算法维度),绑定认证核心的令牌契约。
|
|
4
|
+
|
|
5
|
+
## 定位
|
|
6
|
+
|
|
7
|
+
位于 Auth 项目 strategies 策略层,依赖 core 契约层与 credential 载体能力层。与 bearer-jwt-strategy 对称,仅载体维度不同;算法维度同样由调用方注入令牌验证器实例决定。
|
|
8
|
+
|
|
9
|
+
## 核心能力
|
|
10
|
+
|
|
11
|
+
提供指定 Cookie 名称的凭证提取与令牌验证器组合策略工厂;支持注入自定义凭证提取器;返回请求级令牌验证器,供 transport 层与框架适配层复用。
|
|
12
|
+
|
|
13
|
+
## 实现情况
|
|
14
|
+
|
|
15
|
+
已实现组合策略并统一导出,承载单元测试(含与 bearer-jwt 策略的对称性验证),随载体与算法维度扩展持续补充对应能力。
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { CredentialExtractor } from "@longzai-intelligence-auth/credential";
|
|
2
|
+
import { RequestTokenVerifier, TokenVerifierPort } from "@longzai-intelligence-auth/core";
|
|
3
|
+
//#region src/index.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Cookie JWT 验证策略配置
|
|
6
|
+
*/
|
|
7
|
+
type CookieJwtStrategyOptions = {
|
|
8
|
+
/**
|
|
9
|
+
* Cookie 名称(承载凭证的 cookie 字段名,必填)
|
|
10
|
+
*/
|
|
11
|
+
cookieName: string;
|
|
12
|
+
/**
|
|
13
|
+
* 已构造的令牌验证器(必填,强制注入)
|
|
14
|
+
*
|
|
15
|
+
* 算法维度由调用方决定。本策略不创建任何 verifier 实例。
|
|
16
|
+
*/
|
|
17
|
+
verifier: TokenVerifierPort;
|
|
18
|
+
/**
|
|
19
|
+
* 自定义凭证提取器(高级用法)
|
|
20
|
+
* 默认使用 createCookieExtractor({ cookieName })
|
|
21
|
+
*/
|
|
22
|
+
extractor?: CredentialExtractor;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* 创建 Cookie JWT 验证策略
|
|
26
|
+
*
|
|
27
|
+
* @param options - Cookie JWT 验证策略配置
|
|
28
|
+
* @returns 实现 RequestTokenVerifier 的组合策略
|
|
29
|
+
*/
|
|
30
|
+
declare function createCookieJwtStrategy(options: CookieJwtStrategyOptions): RequestTokenVerifier;
|
|
31
|
+
//#endregion
|
|
32
|
+
export { CookieJwtStrategyOptions, createCookieJwtStrategy };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createCookieExtractor as e,verifyWithExtractor as t}from"@longzai-intelligence-auth/credential";function n(n){let{cookieName:r,verifier:i,extractor:a}=n,o=a??e({cookieName:r});return{async verify(e){return t(e,o,i,`请求未携带 cookie 凭证`)}}}export{n as createCookieJwtStrategy};
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@longzai-intelligence-auth/cookie-jwt-strategy",
|
|
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
|
+
"@longzai-intelligence-auth/credential": "0.1.0"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@longzai-intelligence-auth/jwt": "0.1.0"
|
|
44
|
+
}
|
|
45
|
+
}
|