@inzombieland/core 1.18.30 → 1.18.32
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/index.d.ts +9 -15
- package/package.json +1 -1
- package/user-actions.d.ts +3 -5
- package/user-actions.mjs +16 -0
package/index.d.ts
CHANGED
|
@@ -9,13 +9,10 @@ export declare function initApiFetch($fetch: Fetch, config: FetchConfig): {
|
|
|
9
9
|
getUser: () => Promise<import("./types").GetUserResponse>;
|
|
10
10
|
useApiFetch: () => Fetch;
|
|
11
11
|
userActions: {
|
|
12
|
-
signIn: (body: {
|
|
13
|
-
username: string;
|
|
14
|
-
password: string;
|
|
15
|
-
rememberMe: boolean;
|
|
16
|
-
}) => Promise<import("./types").GetUserResponse | {
|
|
12
|
+
signIn: (body: Record<string, any>) => Promise<import("./types").GetUserResponse | {
|
|
17
13
|
key: string;
|
|
18
14
|
}>;
|
|
15
|
+
signInByCodeVerifyCode: (body: Record<string, any>) => Promise<import("./types").GetUserResponse>;
|
|
19
16
|
logout: () => Promise<void>;
|
|
20
17
|
fetchActiveSessions: () => Promise<{
|
|
21
18
|
sessions: import("./types").ActiveSession[];
|
|
@@ -67,16 +64,14 @@ export declare function initApiFetch($fetch: Fetch, config: FetchConfig): {
|
|
|
67
64
|
}) => Promise<void>;
|
|
68
65
|
changeAvatar: (body: FormData) => Promise<void>;
|
|
69
66
|
deleteAvatar: () => Promise<void>;
|
|
67
|
+
logoutFromAllActiveSessions: () => Promise<any>;
|
|
70
68
|
};
|
|
71
69
|
};
|
|
72
70
|
export declare const useUserActions: () => Ref<{
|
|
73
|
-
signIn: (body: {
|
|
74
|
-
username: string;
|
|
75
|
-
password: string;
|
|
76
|
-
rememberMe: boolean;
|
|
77
|
-
}) => Promise<import("./types").GetUserResponse | {
|
|
71
|
+
signIn: (body: Record<string, any>) => Promise<import("./types").GetUserResponse | {
|
|
78
72
|
key: string;
|
|
79
73
|
}>;
|
|
74
|
+
signInByCodeVerifyCode: (body: Record<string, any>) => Promise<import("./types").GetUserResponse>;
|
|
80
75
|
logout: () => Promise<void>;
|
|
81
76
|
fetchActiveSessions: () => Promise<{
|
|
82
77
|
sessions: import("./types").ActiveSession[];
|
|
@@ -128,14 +123,12 @@ export declare const useUserActions: () => Ref<{
|
|
|
128
123
|
}) => Promise<void>;
|
|
129
124
|
changeAvatar: (body: FormData) => Promise<void>;
|
|
130
125
|
deleteAvatar: () => Promise<void>;
|
|
126
|
+
logoutFromAllActiveSessions: () => Promise<any>;
|
|
131
127
|
}, {
|
|
132
|
-
signIn: (body: {
|
|
133
|
-
username: string;
|
|
134
|
-
password: string;
|
|
135
|
-
rememberMe: boolean;
|
|
136
|
-
}) => Promise<import("./types").GetUserResponse | {
|
|
128
|
+
signIn: (body: Record<string, any>) => Promise<import("./types").GetUserResponse | {
|
|
137
129
|
key: string;
|
|
138
130
|
}>;
|
|
131
|
+
signInByCodeVerifyCode: (body: Record<string, any>) => Promise<import("./types").GetUserResponse>;
|
|
139
132
|
logout: () => Promise<void>;
|
|
140
133
|
fetchActiveSessions: () => Promise<{
|
|
141
134
|
sessions: import("./types").ActiveSession[];
|
|
@@ -187,4 +180,5 @@ export declare const useUserActions: () => Ref<{
|
|
|
187
180
|
}) => Promise<void>;
|
|
188
181
|
changeAvatar: (body: FormData) => Promise<void>;
|
|
189
182
|
deleteAvatar: () => Promise<void>;
|
|
183
|
+
logoutFromAllActiveSessions: () => Promise<any>;
|
|
190
184
|
}> | undefined;
|
package/package.json
CHANGED
package/user-actions.d.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import type { ActiveSession, Fetch, FetchConfig, GetUserResponse } from "./types";
|
|
2
2
|
export type UserActions = ReturnType<typeof createApiUserActions>;
|
|
3
3
|
export declare const createApiUserActions: (fetch: Fetch, config: FetchConfig, getUser: () => Promise<GetUserResponse>) => {
|
|
4
|
-
signIn: (body: {
|
|
5
|
-
username: string;
|
|
6
|
-
password: string;
|
|
7
|
-
rememberMe: boolean;
|
|
8
|
-
}) => Promise<GetUserResponse | {
|
|
4
|
+
signIn: (body: Record<string, any>) => Promise<GetUserResponse | {
|
|
9
5
|
key: string;
|
|
10
6
|
}>;
|
|
7
|
+
signInByCodeVerifyCode: (body: Record<string, any>) => Promise<GetUserResponse>;
|
|
11
8
|
logout: () => Promise<void>;
|
|
12
9
|
fetchActiveSessions: () => Promise<{
|
|
13
10
|
sessions: ActiveSession[];
|
|
@@ -59,4 +56,5 @@ export declare const createApiUserActions: (fetch: Fetch, config: FetchConfig, g
|
|
|
59
56
|
}) => Promise<void>;
|
|
60
57
|
changeAvatar: (body: FormData) => Promise<void>;
|
|
61
58
|
deleteAvatar: () => Promise<void>;
|
|
59
|
+
logoutFromAllActiveSessions: () => Promise<any>;
|
|
62
60
|
};
|
package/user-actions.mjs
CHANGED
|
@@ -20,6 +20,19 @@ export const createApiUserActions = once(
|
|
|
20
20
|
setToken(accessToken);
|
|
21
21
|
return await getUser();
|
|
22
22
|
},
|
|
23
|
+
signInByCodeVerifyCode: async (body) => {
|
|
24
|
+
const response = await fetch("/account/0/signinbycode/verifycode", {
|
|
25
|
+
body,
|
|
26
|
+
method: "POST",
|
|
27
|
+
...config.useRequestHeaders?.(["cookie"]) ?? {}
|
|
28
|
+
});
|
|
29
|
+
const { accessToken, ...rest } = response;
|
|
30
|
+
if (!accessToken) {
|
|
31
|
+
throw rest;
|
|
32
|
+
}
|
|
33
|
+
setToken(accessToken);
|
|
34
|
+
return await getUser();
|
|
35
|
+
},
|
|
23
36
|
logout: async () => {
|
|
24
37
|
const user = useUser();
|
|
25
38
|
try {
|
|
@@ -95,6 +108,9 @@ export const createApiUserActions = once(
|
|
|
95
108
|
const user = useUser();
|
|
96
109
|
await fetch("/account/1/delete/avatar", { body: { avatar: user.value?.avatar }, method: "DELETE" });
|
|
97
110
|
updateUser({ avatar: "" });
|
|
111
|
+
},
|
|
112
|
+
logoutFromAllActiveSessions: async () => {
|
|
113
|
+
return await fetch("/account/1/logout/sessions", { method: "POST" });
|
|
98
114
|
}
|
|
99
115
|
};
|
|
100
116
|
}
|