@inzombieland/nuxt-common 1.20.2 → 1.20.3
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/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.js +10 -12
- 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.3";
|
|
6
6
|
|
|
7
7
|
const module$1 = defineNuxtModule({
|
|
8
8
|
meta: {
|
|
@@ -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,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 {
|
|
@@ -29,21 +29,19 @@ export const createApiUserActions = once(
|
|
|
29
29
|
});
|
|
30
30
|
},
|
|
31
31
|
signInByCodeVerifyCode: async (body) => {
|
|
32
|
-
const response = await fetch(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
);
|
|
40
|
-
const { accessToken, secretKey, visitorId, ...rest } = response;
|
|
41
|
-
if (!accessToken) {
|
|
32
|
+
const response = await fetch("/account/0/signinbycode/verifycode", {
|
|
33
|
+
body,
|
|
34
|
+
method: "POST",
|
|
35
|
+
...config.useRequestHeaders?.(["cookie"]) ?? {}
|
|
36
|
+
});
|
|
37
|
+
const { accessToken, sessionId, visitorId, secretKey, ...rest } = response;
|
|
38
|
+
if (!accessToken || !sessionId) {
|
|
42
39
|
throw rest;
|
|
43
40
|
}
|
|
44
41
|
setToken(accessToken);
|
|
45
|
-
|
|
42
|
+
setSessionId(sessionId);
|
|
46
43
|
setVisitorId(visitorId);
|
|
44
|
+
setSecretKey(secretKey);
|
|
47
45
|
return await getUser();
|
|
48
46
|
},
|
|
49
47
|
getToken: async (body) => {
|