@inzombieland/core 1.19.11 → 1.19.12
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/api-client.d.ts +2 -0
- package/api-client.mjs +7 -0
- package/get-user.mjs +3 -2
- package/package.json +1 -1
- package/types.d.ts +1 -0
- package/user-actions.mjs +11 -7
package/api-client.d.ts
CHANGED
|
@@ -3,5 +3,7 @@ export declare const setUser: (newUser?: User | null) => void;
|
|
|
3
3
|
export declare const updateUser: (newUser: Partial<User>) => void;
|
|
4
4
|
export declare const getToken: () => string | null | undefined;
|
|
5
5
|
export declare const setToken: (newToken?: string | null) => void;
|
|
6
|
+
export declare const getSecretKey: () => string | undefined;
|
|
7
|
+
export declare const setSecretKey: (newSecretKey?: string) => void;
|
|
6
8
|
export declare const flush: () => void;
|
|
7
9
|
export declare const createApiFetch: (fetch: Fetch, config: FetchConfig) => (url: string, options?: FetchOptions) => Promise<any>;
|
package/api-client.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import { useApiActions, useUser, useVisitor } from "./composables/index.mjs";
|
|
|
2
2
|
import { apiHelper, once } from "./helpers/index.mjs";
|
|
3
3
|
import { useBus } from "./index.mjs";
|
|
4
4
|
let token = null;
|
|
5
|
+
let secretKey;
|
|
5
6
|
export const setUser = (newUser) => {
|
|
6
7
|
const user = useUser();
|
|
7
8
|
user.value = newUser;
|
|
@@ -20,6 +21,12 @@ export const getToken = () => {
|
|
|
20
21
|
export const setToken = (newToken) => {
|
|
21
22
|
token = newToken;
|
|
22
23
|
};
|
|
24
|
+
export const getSecretKey = () => {
|
|
25
|
+
return secretKey;
|
|
26
|
+
};
|
|
27
|
+
export const setSecretKey = (newSecretKey) => {
|
|
28
|
+
secretKey = newSecretKey;
|
|
29
|
+
};
|
|
23
30
|
export const flush = () => {
|
|
24
31
|
setToken(null);
|
|
25
32
|
setUser(null);
|
package/get-user.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useLocalStorage } from "@vueuse/core";
|
|
2
|
-
import { flush, getToken, setUser } from "./api-client.mjs";
|
|
2
|
+
import { flush, getSecretKey, getToken, setUser } from "./api-client.mjs";
|
|
3
3
|
import { useApiActions, useUser } from "./composables/index.mjs";
|
|
4
4
|
import { createSingletonAsync, once } from "./helpers/index.mjs";
|
|
5
5
|
async function getUserRequest(fetch, config) {
|
|
@@ -26,7 +26,8 @@ async function getUserRequest(fetch, config) {
|
|
|
26
26
|
const user2 = await fetch("/account", config.useRequestHeaders?.(["cookie", "authorization"]));
|
|
27
27
|
setUser(user2);
|
|
28
28
|
const token2 = getToken();
|
|
29
|
-
|
|
29
|
+
const secretKey = getSecretKey();
|
|
30
|
+
return { token: token2, secretKey, user: user2 };
|
|
30
31
|
} catch {
|
|
31
32
|
flush();
|
|
32
33
|
return { token: null, user: null };
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
package/user-actions.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { flush, setToken, updateUser } from "./api-client.mjs";
|
|
1
|
+
import { flush, setSecretKey, setToken, updateUser } from "./api-client.mjs";
|
|
2
2
|
import { useUser } from "./composables/index.mjs";
|
|
3
3
|
import { once } from "./helpers/index.mjs";
|
|
4
4
|
export const createApiUserActions = once(
|
|
@@ -28,16 +28,20 @@ export const createApiUserActions = once(
|
|
|
28
28
|
});
|
|
29
29
|
},
|
|
30
30
|
signInByCodeVerifyCode: async (body) => {
|
|
31
|
-
const response = await fetch(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
const response = await fetch(
|
|
32
|
+
"/account/0/signinbycode/verifycode",
|
|
33
|
+
{
|
|
34
|
+
body,
|
|
35
|
+
method: "POST",
|
|
36
|
+
...config.useRequestHeaders?.(["cookie"]) ?? {}
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
const { accessToken, secretKey, ...rest } = response;
|
|
37
40
|
if (!accessToken) {
|
|
38
41
|
throw rest;
|
|
39
42
|
}
|
|
40
43
|
setToken(accessToken);
|
|
44
|
+
setSecretKey(secretKey);
|
|
41
45
|
return await getUser();
|
|
42
46
|
},
|
|
43
47
|
signUp: async (body) => {
|