@kevisual/auth 2.0.1 → 2.0.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/dist/app.d.ts +36 -1
- package/dist/app.js +1642 -1
- package/package.json +5 -5
- package/src/index.ts +5 -1
- package/src/query.ts +53 -0
package/dist/app.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import * as jose from 'jose';
|
|
2
|
+
import { Query, Result } from '@kevisual/query/query';
|
|
3
|
+
import { LRUCache } from 'lru-cache';
|
|
2
4
|
|
|
3
5
|
/***
|
|
4
6
|
* 验证 JWT
|
|
@@ -53,5 +55,38 @@ declare function signJWT(payload: JWTPayload, privateKey: jose.CryptoKey | strin
|
|
|
53
55
|
*/
|
|
54
56
|
declare const decodeJWT: (token: string) => JWTPayload;
|
|
55
57
|
|
|
56
|
-
|
|
58
|
+
type GenerateOpts = {
|
|
59
|
+
kid?: string;
|
|
60
|
+
};
|
|
61
|
+
declare const generate: (opts?: GenerateOpts) => Promise<{
|
|
62
|
+
jwks: {
|
|
63
|
+
keys: any[];
|
|
64
|
+
};
|
|
65
|
+
privateJWK: any;
|
|
66
|
+
privatePEM: any;
|
|
67
|
+
publicPEM: any;
|
|
68
|
+
}>;
|
|
69
|
+
|
|
70
|
+
type TokenUser = {
|
|
71
|
+
id: string;
|
|
72
|
+
username: string;
|
|
73
|
+
nickname: string;
|
|
74
|
+
description: string;
|
|
75
|
+
/** user or org */
|
|
76
|
+
type: string;
|
|
77
|
+
avatar?: string;
|
|
78
|
+
orgs?: string[];
|
|
79
|
+
[key: string]: any;
|
|
80
|
+
};
|
|
81
|
+
type AuthQueryOpts = {
|
|
82
|
+
url?: string;
|
|
83
|
+
};
|
|
84
|
+
declare class AuthQuery extends Query {
|
|
85
|
+
cache: LRUCache<string, any>;
|
|
86
|
+
constructor(opts?: AuthQueryOpts);
|
|
87
|
+
getTokenUser: (token: string) => Promise<Result<TokenUser>>;
|
|
88
|
+
getTokenUserCache: (token: string) => Promise<Result<TokenUser>>;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export { AuthQuery, decodeJWT, generate, signJWT, verifyJWT };
|
|
57
92
|
export type { JWTPayload };
|