@inzombieland/nuxt-common 1.20.2 → 1.20.4
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/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/composables/use-user-actions.d.ts +2 -5
- package/dist/runtime/packages/core/index.d.ts +6 -15
- package/dist/runtime/packages/core/local-storage-utils.d.ts +2 -0
- package/dist/runtime/packages/core/local-storage-utils.js +11 -0
- package/dist/runtime/packages/core/package.json +1 -1
- package/dist/runtime/packages/core/user-actions.d.ts +2 -5
- package/dist/runtime/packages/core/user-actions.js +11 -24
- package/dist/runtime/server/api/index.d.ts +2 -5
- package/package.json +1 -1
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
2
2
|
import { defineNuxtModule, createResolver, addServerHandler, addImportsDir, addPlugin, addComponent } from '@nuxt/kit';
|
|
3
3
|
|
|
4
4
|
const name = "@inzombieland/nuxt-common";
|
|
5
|
-
const version = "1.20.
|
|
5
|
+
const version = "1.20.4";
|
|
6
6
|
|
|
7
7
|
const module$1 = defineNuxtModule({
|
|
8
8
|
meta: {
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
export declare const useUserActions: () => {
|
|
2
|
-
signIn: (body: Record<string, any>) => Promise<
|
|
2
|
+
signIn: (body: Record<string, any>) => Promise<{
|
|
3
3
|
key: string;
|
|
4
4
|
}>;
|
|
5
|
-
|
|
6
|
-
key: string;
|
|
7
|
-
}>;
|
|
8
|
-
signInByCodeVerifyCode: (body: Record<string, any>) => Promise<import("../packages/core/index.js").GetUserResponse>;
|
|
5
|
+
signInVerifyCode: (body: Record<string, any>) => Promise<import("../packages/core/index.js").GetUserResponse>;
|
|
9
6
|
getToken: (body: Record<string, any>) => Promise<import("../packages/core/index.js").GetUserResponse>;
|
|
10
7
|
signUp: (body: Record<string, any>) => Promise<{
|
|
11
8
|
key: string;
|
|
@@ -9,13 +9,10 @@ export declare function initApiFetch($fetch: Fetch, config: FetchConfig): {
|
|
|
9
9
|
getUser: () => Promise<import("./types.js").GetUserResponse>;
|
|
10
10
|
useApiFetch: () => Fetch;
|
|
11
11
|
userActions: {
|
|
12
|
-
signIn: (body: Record<string, any>) => Promise<
|
|
12
|
+
signIn: (body: Record<string, any>) => Promise<{
|
|
13
13
|
key: string;
|
|
14
14
|
}>;
|
|
15
|
-
|
|
16
|
-
key: string;
|
|
17
|
-
}>;
|
|
18
|
-
signInByCodeVerifyCode: (body: Record<string, any>) => Promise<import("./types.js").GetUserResponse>;
|
|
15
|
+
signInVerifyCode: (body: Record<string, any>) => Promise<import("./types.js").GetUserResponse>;
|
|
19
16
|
getToken: (body: Record<string, any>) => Promise<import("./types.js").GetUserResponse>;
|
|
20
17
|
signUp: (body: Record<string, any>) => Promise<{
|
|
21
18
|
key: string;
|
|
@@ -108,13 +105,10 @@ export declare function initApiFetch($fetch: Fetch, config: FetchConfig): {
|
|
|
108
105
|
};
|
|
109
106
|
};
|
|
110
107
|
export declare const useUserActions: () => Ref<{
|
|
111
|
-
signIn: (body: Record<string, any>) => Promise<
|
|
112
|
-
key: string;
|
|
113
|
-
}>;
|
|
114
|
-
signInByCodeSendCode: (body: Record<string, any>) => Promise<{
|
|
108
|
+
signIn: (body: Record<string, any>) => Promise<{
|
|
115
109
|
key: string;
|
|
116
110
|
}>;
|
|
117
|
-
|
|
111
|
+
signInVerifyCode: (body: Record<string, any>) => Promise<import("./types.js").GetUserResponse>;
|
|
118
112
|
getToken: (body: Record<string, any>) => Promise<import("./types.js").GetUserResponse>;
|
|
119
113
|
signUp: (body: Record<string, any>) => Promise<{
|
|
120
114
|
key: string;
|
|
@@ -205,13 +199,10 @@ export declare const useUserActions: () => Ref<{
|
|
|
205
199
|
code: string;
|
|
206
200
|
}) => Promise<void>;
|
|
207
201
|
}, {
|
|
208
|
-
signIn: (body: Record<string, any>) => Promise<
|
|
209
|
-
key: string;
|
|
210
|
-
}>;
|
|
211
|
-
signInByCodeSendCode: (body: Record<string, any>) => Promise<{
|
|
202
|
+
signIn: (body: Record<string, any>) => Promise<{
|
|
212
203
|
key: string;
|
|
213
204
|
}>;
|
|
214
|
-
|
|
205
|
+
signInVerifyCode: (body: Record<string, any>) => Promise<import("./types.js").GetUserResponse>;
|
|
215
206
|
getToken: (body: Record<string, any>) => Promise<import("./types.js").GetUserResponse>;
|
|
216
207
|
signUp: (body: Record<string, any>) => Promise<{
|
|
217
208
|
key: string;
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
export const getSessionId = () => {
|
|
2
|
+
if (typeof window !== "undefined") {
|
|
3
|
+
return window.localStorage.getItem("sid");
|
|
4
|
+
}
|
|
5
|
+
return null;
|
|
6
|
+
};
|
|
7
|
+
export const setSessionId = (sessionId = "") => {
|
|
8
|
+
if (typeof window !== "undefined") {
|
|
9
|
+
window.localStorage.setItem("sid", sessionId);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
1
12
|
export const getVisitorId = () => {
|
|
2
13
|
if (typeof window !== "undefined") {
|
|
3
14
|
return window.localStorage.getItem("vid");
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import type { ActiveSession, Fetch, FetchConfig, GetUserResponse } from "./types.js";
|
|
2
2
|
export type UserActions = ReturnType<typeof createApiUserActions>;
|
|
3
3
|
export declare const createApiUserActions: (fetch: Fetch, config: FetchConfig, getUser: () => Promise<GetUserResponse>) => {
|
|
4
|
-
signIn: (body: Record<string, any>) => Promise<
|
|
4
|
+
signIn: (body: Record<string, any>) => Promise<{
|
|
5
5
|
key: string;
|
|
6
6
|
}>;
|
|
7
|
-
|
|
8
|
-
key: string;
|
|
9
|
-
}>;
|
|
10
|
-
signInByCodeVerifyCode: (body: Record<string, any>) => Promise<GetUserResponse>;
|
|
7
|
+
signInVerifyCode: (body: Record<string, any>) => Promise<GetUserResponse>;
|
|
11
8
|
getToken: (body: Record<string, any>) => Promise<GetUserResponse>;
|
|
12
9
|
signUp: (body: Record<string, any>) => Promise<{
|
|
13
10
|
key: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { flush, setSecretKey, setToken, updateUser } from "./api-client.js";
|
|
2
2
|
import { useUser } from "./composables/index.js";
|
|
3
3
|
import { once } from "./helpers/index.js";
|
|
4
|
-
import { setVisitorId } from "./local-storage-utils.js";
|
|
4
|
+
import { setSessionId, setVisitorId } from "./local-storage-utils.js";
|
|
5
5
|
export const createApiUserActions = once(
|
|
6
6
|
(fetch, config, getUser) => {
|
|
7
7
|
return {
|
|
@@ -11,39 +11,26 @@ export const createApiUserActions = once(
|
|
|
11
11
|
method: "POST",
|
|
12
12
|
...config.useRequestHeaders?.(["cookie"]) ?? {}
|
|
13
13
|
});
|
|
14
|
-
const {
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
-
return { key };
|
|
18
|
-
}
|
|
19
|
-
throw rest;
|
|
14
|
+
const { key, ...rest } = response;
|
|
15
|
+
if (key) {
|
|
16
|
+
return { key };
|
|
20
17
|
}
|
|
21
|
-
|
|
22
|
-
return await getUser();
|
|
18
|
+
throw rest;
|
|
23
19
|
},
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
signInVerifyCode: async (body) => {
|
|
21
|
+
const response = await fetch("/account/0/signinbycode/verifycode", {
|
|
26
22
|
body,
|
|
27
23
|
method: "POST",
|
|
28
24
|
...config.useRequestHeaders?.(["cookie"]) ?? {}
|
|
29
25
|
});
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const response = await fetch(
|
|
33
|
-
"/account/0/signinbycode/verifycode",
|
|
34
|
-
{
|
|
35
|
-
body,
|
|
36
|
-
method: "POST",
|
|
37
|
-
...config.useRequestHeaders?.(["cookie"]) ?? {}
|
|
38
|
-
}
|
|
39
|
-
);
|
|
40
|
-
const { accessToken, secretKey, visitorId, ...rest } = response;
|
|
41
|
-
if (!accessToken) {
|
|
26
|
+
const { accessToken, sessionId, visitorId, secretKey, ...rest } = response;
|
|
27
|
+
if (!accessToken || !sessionId || !visitorId || !secretKey) {
|
|
42
28
|
throw rest;
|
|
43
29
|
}
|
|
44
30
|
setToken(accessToken);
|
|
45
|
-
|
|
31
|
+
setSessionId(sessionId);
|
|
46
32
|
setVisitorId(visitorId);
|
|
33
|
+
setSecretKey(secretKey);
|
|
47
34
|
return await getUser();
|
|
48
35
|
},
|
|
49
36
|
getToken: async (body) => {
|
|
@@ -17,13 +17,10 @@ export declare const config: {
|
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
19
|
declare const fetch: Fetch, getUser: () => Promise<import("../../packages/core/index.js").GetUserResponse>, useApiFetch: () => Fetch, userActions: {
|
|
20
|
-
signIn: (body: Record<string, any>) => Promise<
|
|
20
|
+
signIn: (body: Record<string, any>) => Promise<{
|
|
21
21
|
key: string;
|
|
22
22
|
}>;
|
|
23
|
-
|
|
24
|
-
key: string;
|
|
25
|
-
}>;
|
|
26
|
-
signInByCodeVerifyCode: (body: Record<string, any>) => Promise<import("../../packages/core/index.js").GetUserResponse>;
|
|
23
|
+
signInVerifyCode: (body: Record<string, any>) => Promise<import("../../packages/core/index.js").GetUserResponse>;
|
|
27
24
|
getToken: (body: Record<string, any>) => Promise<import("../../packages/core/index.js").GetUserResponse>;
|
|
28
25
|
signUp: (body: Record<string, any>) => Promise<{
|
|
29
26
|
key: string;
|