@yiminlab/authkit 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/dist/index-jde0aIND.d.mts +349 -0
- package/dist/index-jde0aIND.d.ts +349 -0
- package/dist/index.d.mts +80 -0
- package/dist/index.d.ts +80 -0
- package/dist/index.js +737 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +695 -0
- package/dist/index.mjs.map +1 -0
- package/dist/react/index.d.mts +3 -0
- package/dist/react/index.d.ts +3 -0
- package/dist/react/index.js +708 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/index.mjs +677 -0
- package/dist/react/index.mjs.map +1 -0
- package/package.json +58 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { U as User } from './index-jde0aIND.mjs';
|
|
2
|
+
export { b as AuthConfig, m as AuthGuard, n as AuthGuardProps, e as AuthRedirect, i as AuthRedirectConfig, A as AuthResponse, a as AuthState, C as CallbackHandler, o as CallbackHandlerProps, D as DEFAULT_AUTH_CONFIG, d as IStorage, I as ITokenManager, L as LocalStorageAdapter, S as StoredTokens, c as TokenManager, T as TokenResponse, k as UseAuthOptions, l as UseAuthReturn, f as getAuthRedirect, g as getTokenManager, h as resetAuthRedirect, r as resetTokenManager, j as useAccessToken, u as useAuth, w as withAuthGuard } from './index-jde0aIND.mjs';
|
|
3
|
+
import 'react/jsx-runtime';
|
|
4
|
+
import 'react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* AuthKit API 客户端
|
|
8
|
+
*
|
|
9
|
+
* 用于调用 AuthKit 服务的 API
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Scoped Token 响应(标准化格式)
|
|
14
|
+
*/
|
|
15
|
+
interface ScopedTokenResponse {
|
|
16
|
+
token: string;
|
|
17
|
+
expires_at: string;
|
|
18
|
+
scopes: string[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* AuthKit 客户端配置
|
|
22
|
+
*/
|
|
23
|
+
interface AuthKitClientConfig {
|
|
24
|
+
baseUrl: string;
|
|
25
|
+
getAccessToken: () => string | null;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* AuthKit API 客户端
|
|
29
|
+
*/
|
|
30
|
+
declare class AuthKitClient {
|
|
31
|
+
private config;
|
|
32
|
+
constructor(config: Partial<AuthKitClientConfig> & {
|
|
33
|
+
getAccessToken: () => string | null;
|
|
34
|
+
});
|
|
35
|
+
/**
|
|
36
|
+
* 构建请求头
|
|
37
|
+
*/
|
|
38
|
+
private buildHeaders;
|
|
39
|
+
/**
|
|
40
|
+
* 解析 API 响应为标准格式
|
|
41
|
+
*/
|
|
42
|
+
private parseTokenResponse;
|
|
43
|
+
/**
|
|
44
|
+
* 获取当前用户信息
|
|
45
|
+
*/
|
|
46
|
+
getMe(): Promise<User>;
|
|
47
|
+
/**
|
|
48
|
+
* 获取全局 Scoped Token(自动创建/续期)
|
|
49
|
+
*
|
|
50
|
+
* @param scope 权限范围,如 'streamock:stream:read'
|
|
51
|
+
* @returns 短 token,如 'st_7kB2xM9pQr3n'
|
|
52
|
+
*/
|
|
53
|
+
getScopedToken(scope: string): Promise<ScopedTokenResponse>;
|
|
54
|
+
/**
|
|
55
|
+
* 轮换 Scoped Token(废弃旧的,生成新的)
|
|
56
|
+
*
|
|
57
|
+
* @param scope 权限范围,如 'streamock:stream:read'
|
|
58
|
+
* @returns 新的短 token
|
|
59
|
+
*/
|
|
60
|
+
rotateScopedToken(scope: string): Promise<ScopedTokenResponse>;
|
|
61
|
+
/**
|
|
62
|
+
* 创建 Scoped Token(短 token)- 保留兼容性
|
|
63
|
+
*
|
|
64
|
+
* @param scopes 权限范围,如 ['streamock:stream:read']
|
|
65
|
+
* @param expiresIn 过期时间(秒),默认 24 小时
|
|
66
|
+
* @returns 短 token,如 'st_7kB2xM9pQr3n'
|
|
67
|
+
* @deprecated 请使用 getScopedToken 获取全局 token
|
|
68
|
+
*/
|
|
69
|
+
createScopedToken(scopes: string[], expiresIn?: number): Promise<ScopedTokenResponse>;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* 获取 AuthKit 客户端单例
|
|
73
|
+
*/
|
|
74
|
+
declare function getAuthKitClient(getAccessToken: () => string | null): AuthKitClient;
|
|
75
|
+
/**
|
|
76
|
+
* 重置单例(用于测试)
|
|
77
|
+
*/
|
|
78
|
+
declare function resetAuthKitClient(): void;
|
|
79
|
+
|
|
80
|
+
export { AuthKitClient, type AuthKitClientConfig, type ScopedTokenResponse, User, getAuthKitClient, resetAuthKitClient };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { U as User } from './index-jde0aIND.js';
|
|
2
|
+
export { b as AuthConfig, m as AuthGuard, n as AuthGuardProps, e as AuthRedirect, i as AuthRedirectConfig, A as AuthResponse, a as AuthState, C as CallbackHandler, o as CallbackHandlerProps, D as DEFAULT_AUTH_CONFIG, d as IStorage, I as ITokenManager, L as LocalStorageAdapter, S as StoredTokens, c as TokenManager, T as TokenResponse, k as UseAuthOptions, l as UseAuthReturn, f as getAuthRedirect, g as getTokenManager, h as resetAuthRedirect, r as resetTokenManager, j as useAccessToken, u as useAuth, w as withAuthGuard } from './index-jde0aIND.js';
|
|
3
|
+
import 'react/jsx-runtime';
|
|
4
|
+
import 'react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* AuthKit API 客户端
|
|
8
|
+
*
|
|
9
|
+
* 用于调用 AuthKit 服务的 API
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Scoped Token 响应(标准化格式)
|
|
14
|
+
*/
|
|
15
|
+
interface ScopedTokenResponse {
|
|
16
|
+
token: string;
|
|
17
|
+
expires_at: string;
|
|
18
|
+
scopes: string[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* AuthKit 客户端配置
|
|
22
|
+
*/
|
|
23
|
+
interface AuthKitClientConfig {
|
|
24
|
+
baseUrl: string;
|
|
25
|
+
getAccessToken: () => string | null;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* AuthKit API 客户端
|
|
29
|
+
*/
|
|
30
|
+
declare class AuthKitClient {
|
|
31
|
+
private config;
|
|
32
|
+
constructor(config: Partial<AuthKitClientConfig> & {
|
|
33
|
+
getAccessToken: () => string | null;
|
|
34
|
+
});
|
|
35
|
+
/**
|
|
36
|
+
* 构建请求头
|
|
37
|
+
*/
|
|
38
|
+
private buildHeaders;
|
|
39
|
+
/**
|
|
40
|
+
* 解析 API 响应为标准格式
|
|
41
|
+
*/
|
|
42
|
+
private parseTokenResponse;
|
|
43
|
+
/**
|
|
44
|
+
* 获取当前用户信息
|
|
45
|
+
*/
|
|
46
|
+
getMe(): Promise<User>;
|
|
47
|
+
/**
|
|
48
|
+
* 获取全局 Scoped Token(自动创建/续期)
|
|
49
|
+
*
|
|
50
|
+
* @param scope 权限范围,如 'streamock:stream:read'
|
|
51
|
+
* @returns 短 token,如 'st_7kB2xM9pQr3n'
|
|
52
|
+
*/
|
|
53
|
+
getScopedToken(scope: string): Promise<ScopedTokenResponse>;
|
|
54
|
+
/**
|
|
55
|
+
* 轮换 Scoped Token(废弃旧的,生成新的)
|
|
56
|
+
*
|
|
57
|
+
* @param scope 权限范围,如 'streamock:stream:read'
|
|
58
|
+
* @returns 新的短 token
|
|
59
|
+
*/
|
|
60
|
+
rotateScopedToken(scope: string): Promise<ScopedTokenResponse>;
|
|
61
|
+
/**
|
|
62
|
+
* 创建 Scoped Token(短 token)- 保留兼容性
|
|
63
|
+
*
|
|
64
|
+
* @param scopes 权限范围,如 ['streamock:stream:read']
|
|
65
|
+
* @param expiresIn 过期时间(秒),默认 24 小时
|
|
66
|
+
* @returns 短 token,如 'st_7kB2xM9pQr3n'
|
|
67
|
+
* @deprecated 请使用 getScopedToken 获取全局 token
|
|
68
|
+
*/
|
|
69
|
+
createScopedToken(scopes: string[], expiresIn?: number): Promise<ScopedTokenResponse>;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* 获取 AuthKit 客户端单例
|
|
73
|
+
*/
|
|
74
|
+
declare function getAuthKitClient(getAccessToken: () => string | null): AuthKitClient;
|
|
75
|
+
/**
|
|
76
|
+
* 重置单例(用于测试)
|
|
77
|
+
*/
|
|
78
|
+
declare function resetAuthKitClient(): void;
|
|
79
|
+
|
|
80
|
+
export { AuthKitClient, type AuthKitClientConfig, type ScopedTokenResponse, User, getAuthKitClient, resetAuthKitClient };
|