@e-xi/xion 0.0.24 → 0.0.26
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/chunk-files/{chunk-ILNU65BZ.js → chunk-KBVHM5ZU.js} +1 -1
- package/dist/chunk-files/{chunk-PRRVKBOL.js → chunk-UWIJOHQU.js} +3 -3
- package/dist/main/app/index.js +2 -2
- package/dist/main/auth/index.js +1 -1
- package/dist/main/auth/jwt-auth-manager.d.ts +3 -3
- package/dist/main/auth/jwt-auth-provider-abstract.d.ts +1 -1
- package/dist/main/banner/index.js +1 -1
- package/dist/main/store/jwt-auth-store.d.ts +2 -2
- package/dist/renderer/store/auth/auth-store.d.ts +48 -38
- package/dist/renderer/store/index.js +4 -1
- package/dist/shared/auth/types/auth.d.ts +3 -3
- package/package.json +1 -1
|
@@ -611,7 +611,7 @@ var JwtAuthManager = class {
|
|
|
611
611
|
}
|
|
612
612
|
/**
|
|
613
613
|
* 更新为初始化状态
|
|
614
|
-
* @param {XoAuth.
|
|
614
|
+
* @param {XoAuth.User} user 持久化的用户快照
|
|
615
615
|
* @returns {void}
|
|
616
616
|
* @private
|
|
617
617
|
*/
|
|
@@ -636,8 +636,8 @@ var JwtAuthManager = class {
|
|
|
636
636
|
}
|
|
637
637
|
/**
|
|
638
638
|
* 更新为已认证状态
|
|
639
|
-
* @param {XoAuth.
|
|
640
|
-
* @param {string}
|
|
639
|
+
* @param {XoAuth.User} user 认证用户
|
|
640
|
+
* @param {string} error 可选错误信息
|
|
641
641
|
* @returns {void}
|
|
642
642
|
* @private
|
|
643
643
|
*/
|
package/dist/main/app/index.js
CHANGED
|
@@ -39,12 +39,12 @@ import {
|
|
|
39
39
|
import "../../chunk-files/chunk-SVTZ4T6S.js";
|
|
40
40
|
import {
|
|
41
41
|
JwtAuthManager
|
|
42
|
-
} from "../../chunk-files/chunk-
|
|
42
|
+
} from "../../chunk-files/chunk-UWIJOHQU.js";
|
|
43
43
|
import "../../chunk-files/chunk-J34MOWJP.js";
|
|
44
44
|
import "../../chunk-files/chunk-RSUM4GBD.js";
|
|
45
45
|
import {
|
|
46
46
|
BannerManager
|
|
47
|
-
} from "../../chunk-files/chunk-
|
|
47
|
+
} from "../../chunk-files/chunk-KBVHM5ZU.js";
|
|
48
48
|
import "../../chunk-files/chunk-YLZRRUY7.js";
|
|
49
49
|
import {
|
|
50
50
|
defineAppConfig,
|
package/dist/main/auth/index.js
CHANGED
|
@@ -238,7 +238,7 @@ export declare class JwtAuthManager {
|
|
|
238
238
|
private updateState;
|
|
239
239
|
/**
|
|
240
240
|
* 更新为初始化状态
|
|
241
|
-
* @param {XoAuth.
|
|
241
|
+
* @param {XoAuth.User} user 持久化的用户快照
|
|
242
242
|
* @returns {void}
|
|
243
243
|
* @private
|
|
244
244
|
*/
|
|
@@ -257,8 +257,8 @@ export declare class JwtAuthManager {
|
|
|
257
257
|
private updateStateRefreshing;
|
|
258
258
|
/**
|
|
259
259
|
* 更新为已认证状态
|
|
260
|
-
* @param {XoAuth.
|
|
261
|
-
* @param {string}
|
|
260
|
+
* @param {XoAuth.User} user 认证用户
|
|
261
|
+
* @param {string} error 可选错误信息
|
|
262
262
|
* @returns {void}
|
|
263
263
|
* @private
|
|
264
264
|
*/
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @template TLogoutResponse 退出响应类型
|
|
9
9
|
* @class JwtAuthProviderAbstract
|
|
10
10
|
*/
|
|
11
|
-
export declare abstract class JwtAuthProviderAbstract<TUser = XoAuth.
|
|
11
|
+
export declare abstract class JwtAuthProviderAbstract<TUser = XoAuth.User, TLoginRequest = XoAuth.LoginRequest, TLoginResponse = unknown, TRefreshResponse = unknown, TLogoutResponse = unknown> {
|
|
12
12
|
/** 访问令牌提前刷新的时间,单位毫秒 */
|
|
13
13
|
readonly refreshBeforeExpiration: number;
|
|
14
14
|
/** 刷新失败后的重试间隔,单位毫秒 */
|
|
@@ -21,13 +21,13 @@ export declare class JwtAuthStore {
|
|
|
21
21
|
* @param {XoAuth.StoredRefreshSession<TUser>} session 会话数据
|
|
22
22
|
* @returns {boolean} 是否已持久化
|
|
23
23
|
*/
|
|
24
|
-
setSession<TUser = XoAuth.
|
|
24
|
+
setSession<TUser = XoAuth.User>(session: XoAuth.StoredRefreshSession<TUser>): boolean;
|
|
25
25
|
/**
|
|
26
26
|
* 读取并解密会话
|
|
27
27
|
* @template TUser 用户类型
|
|
28
28
|
* @returns {XoAuth.StoredRefreshSession<TUser> | undefined}
|
|
29
29
|
*/
|
|
30
|
-
getSession<TUser = XoAuth.
|
|
30
|
+
getSession<TUser = XoAuth.User>(): XoAuth.StoredRefreshSession<TUser> | undefined;
|
|
31
31
|
/**
|
|
32
32
|
* 清除持久化会话
|
|
33
33
|
* @returns {void}
|
|
@@ -1,43 +1,53 @@
|
|
|
1
|
+
import { type Pinia } from 'pinia';
|
|
2
|
+
import { type ComputedRef, type Ref } from 'vue';
|
|
1
3
|
/**
|
|
2
|
-
* JWT 认证 Store
|
|
4
|
+
* JWT 认证 Store 的 setup 返回类型
|
|
3
5
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
isAuthenticated: import("vue").ComputedRef<boolean>;
|
|
25
|
-
isUnauthenticated: import("vue").ComputedRef<boolean>;
|
|
26
|
-
isError: import("vue").ComputedRef<boolean>;
|
|
27
|
-
initialize: () => Promise<void>;
|
|
28
|
-
login: (request: XoAuth.LoginRequest) => Promise<void>;
|
|
29
|
-
logout: () => Promise<void>;
|
|
30
|
-
}, "isInitializing" | "isAuthenticating" | "isRefreshing" | "isAuthenticated" | "isUnauthenticated" | "isError">, Pick<{
|
|
31
|
-
status: import("vue").Ref<"error" | "unauthenticated" | "initializing" | "authenticating" | "refreshing" | "authenticated", "error" | "unauthenticated" | "initializing" | "authenticating" | "refreshing" | "authenticated">;
|
|
32
|
-
user: import("vue").Ref<unknown, unknown>;
|
|
33
|
-
error: import("vue").Ref<string | undefined, string | undefined>;
|
|
34
|
-
isInitializing: import("vue").ComputedRef<boolean>;
|
|
35
|
-
isAuthenticating: import("vue").ComputedRef<boolean>;
|
|
36
|
-
isRefreshing: import("vue").ComputedRef<boolean>;
|
|
37
|
-
isAuthenticated: import("vue").ComputedRef<boolean>;
|
|
38
|
-
isUnauthenticated: import("vue").ComputedRef<boolean>;
|
|
39
|
-
isError: import("vue").ComputedRef<boolean>;
|
|
6
|
+
interface AuthStoreSetup {
|
|
7
|
+
/** 当前认证状态 */
|
|
8
|
+
status: Ref<XoAuth.Status>;
|
|
9
|
+
/** 当前登录用户 */
|
|
10
|
+
user: Ref<XoAuth.User | undefined>;
|
|
11
|
+
/** 最近一次认证错误信息 */
|
|
12
|
+
error: Ref<string | undefined>;
|
|
13
|
+
/** 是否正在初始化 */
|
|
14
|
+
isInitializing: ComputedRef<boolean>;
|
|
15
|
+
/** 是否正在登录 */
|
|
16
|
+
isAuthenticating: ComputedRef<boolean>;
|
|
17
|
+
/** 是否正在刷新 */
|
|
18
|
+
isRefreshing: ComputedRef<boolean>;
|
|
19
|
+
/** 是否已登录 */
|
|
20
|
+
isAuthenticated: ComputedRef<boolean>;
|
|
21
|
+
/** 是否未登录 */
|
|
22
|
+
isUnauthenticated: ComputedRef<boolean>;
|
|
23
|
+
/** 是否认证异常 */
|
|
24
|
+
isError: ComputedRef<boolean>;
|
|
25
|
+
/** 初始化认证状态与监听器 */
|
|
40
26
|
initialize: () => Promise<void>;
|
|
27
|
+
/** 登录 */
|
|
41
28
|
login: (request: XoAuth.LoginRequest) => Promise<void>;
|
|
29
|
+
/** 退出登录 */
|
|
42
30
|
logout: () => Promise<void>;
|
|
43
|
-
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* JWT 认证 Store
|
|
34
|
+
*/
|
|
35
|
+
declare const useXoAuthStoreDefinition: import("pinia").StoreDefinition<"useXoAuthStore", Pick<AuthStoreSetup, "error" | "status" | "user">, Pick<AuthStoreSetup, "isInitializing" | "isAuthenticating" | "isRefreshing" | "isAuthenticated" | "isUnauthenticated" | "isError">, Pick<AuthStoreSetup, "login" | "logout" | "initialize">>;
|
|
36
|
+
/**
|
|
37
|
+
* 认证 Store 实例类型
|
|
38
|
+
* @template TUser 业务端指定的登录用户类型
|
|
39
|
+
*/
|
|
40
|
+
export type XoAuthStore<TUser = XoAuth.User> = Omit<ReturnType<typeof useXoAuthStoreDefinition>, 'user'> & {
|
|
41
|
+
/** 当前登录用户 */
|
|
42
|
+
user: TUser | undefined;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* 获取认证 Store 实例
|
|
46
|
+
* @template TUser 业务端指定的登录用户类型
|
|
47
|
+
* @param {Pinia | null | undefined} pinia Pinia 实例
|
|
48
|
+
* @returns {XoAuthStore<TUser>} 认证 Store 实例
|
|
49
|
+
* @example
|
|
50
|
+
* const authStore = useXoAuthStore<User>()
|
|
51
|
+
*/
|
|
52
|
+
export declare function useXoAuthStore<TUser = XoAuth.User>(pinia?: Pinia | null): XoAuthStore<TUser>;
|
|
53
|
+
export {};
|
|
@@ -69,7 +69,7 @@ var useXoAppStore = defineStore("useXoAppStore", () => {
|
|
|
69
69
|
// src/renderer/store/auth/auth-store.ts
|
|
70
70
|
import { defineStore as defineStore2 } from "pinia";
|
|
71
71
|
import { computed as computed2, ref as ref2, shallowRef } from "vue";
|
|
72
|
-
var
|
|
72
|
+
var useXoAuthStoreDefinition = defineStore2("useXoAuthStore", () => {
|
|
73
73
|
const initializePromise = shallowRef();
|
|
74
74
|
const offState = shallowRef();
|
|
75
75
|
const status = ref2("initializing");
|
|
@@ -135,6 +135,9 @@ var useXoAuthStore = defineStore2("useXoAuthStore", () => {
|
|
|
135
135
|
logout
|
|
136
136
|
};
|
|
137
137
|
});
|
|
138
|
+
function useXoAuthStore(pinia) {
|
|
139
|
+
return useXoAuthStoreDefinition(pinia);
|
|
140
|
+
}
|
|
138
141
|
|
|
139
142
|
// src/shared/remote-service/const/remote-service.ts
|
|
140
143
|
var RemoteServiceStatusOptions = [
|
|
@@ -42,7 +42,7 @@ declare global {
|
|
|
42
42
|
* 认证结果
|
|
43
43
|
* @template TUser 用户类型
|
|
44
44
|
*/
|
|
45
|
-
interface AuthResult<TUser =
|
|
45
|
+
interface AuthResult<TUser = User> extends TokenPair {
|
|
46
46
|
/** 可选用户信息 */
|
|
47
47
|
user?: TUser
|
|
48
48
|
}
|
|
@@ -51,7 +51,7 @@ declare global {
|
|
|
51
51
|
* 加密持久化会话
|
|
52
52
|
* @template TUser 用户类型
|
|
53
53
|
*/
|
|
54
|
-
interface StoredRefreshSession<TUser =
|
|
54
|
+
interface StoredRefreshSession<TUser = User> {
|
|
55
55
|
/** 刷新令牌 */
|
|
56
56
|
refreshToken: string
|
|
57
57
|
/** 刷新令牌绝对过期时间戳,单位毫秒 */
|
|
@@ -65,7 +65,7 @@ declare global {
|
|
|
65
65
|
/** 当前认证状态 */
|
|
66
66
|
status: Status
|
|
67
67
|
/** 当前登录用户,不包含任何令牌 */
|
|
68
|
-
user?:
|
|
68
|
+
user?: User
|
|
69
69
|
/** 最近一次错误信息 */
|
|
70
70
|
error?: string
|
|
71
71
|
}
|