@inzombieland/nuxt-common 1.19.11 → 1.19.13

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inzombieland/nuxt-common",
3
- "version": "1.19.11",
3
+ "version": "1.19.13",
4
4
  "configKey": "nuxt-common",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "0.6.0",
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.19.11";
5
+ const version = "1.19.13";
6
6
 
7
7
  const module = defineNuxtModule({
8
8
  meta: {
@@ -24,6 +24,7 @@ declare const fetch: Fetch, getUser: () => Promise<import("src/runtime/packages/
24
24
  key: string;
25
25
  }>;
26
26
  signInByCodeVerifyCode: (body: Record<string, any>) => Promise<import("src/runtime/packages/core/types").GetUserResponse>;
27
+ getToken: (body: Record<string, any>) => Promise<import("src/runtime/packages/core/types").GetUserResponse>;
27
28
  signUp: (body: Record<string, any>) => Promise<{
28
29
  key: string;
29
30
  }>;
@@ -6,6 +6,7 @@ export declare const useUserActions: () => {
6
6
  key: string;
7
7
  }>;
8
8
  signInByCodeVerifyCode: (body: Record<string, any>) => Promise<import("src/runtime/packages/core").GetUserResponse>;
9
+ getToken: (body: Record<string, any>) => Promise<import("src/runtime/packages/core").GetUserResponse>;
9
10
  signUp: (body: Record<string, any>) => Promise<{
10
11
  key: string;
11
12
  }>;
@@ -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>;
@@ -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);
@@ -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
- return { token: token2, user: user2 };
29
+ const secretKey = getSecretKey();
30
+ return { token: token2, secretKey, user: user2 };
30
31
  } catch {
31
32
  flush();
32
33
  return { token: null, user: null };
@@ -16,6 +16,7 @@ export declare function initApiFetch($fetch: Fetch, config: FetchConfig): {
16
16
  key: string;
17
17
  }>;
18
18
  signInByCodeVerifyCode: (body: Record<string, any>) => Promise<import("./types").GetUserResponse>;
19
+ getToken: (body: Record<string, any>) => Promise<import("./types").GetUserResponse>;
19
20
  signUp: (body: Record<string, any>) => Promise<{
20
21
  key: string;
21
22
  }>;
@@ -114,6 +115,7 @@ export declare const useUserActions: () => Ref<{
114
115
  key: string;
115
116
  }>;
116
117
  signInByCodeVerifyCode: (body: Record<string, any>) => Promise<import("./types").GetUserResponse>;
118
+ getToken: (body: Record<string, any>) => Promise<import("./types").GetUserResponse>;
117
119
  signUp: (body: Record<string, any>) => Promise<{
118
120
  key: string;
119
121
  }>;
@@ -210,6 +212,7 @@ export declare const useUserActions: () => Ref<{
210
212
  key: string;
211
213
  }>;
212
214
  signInByCodeVerifyCode: (body: Record<string, any>) => Promise<import("./types").GetUserResponse>;
215
+ getToken: (body: Record<string, any>) => Promise<import("./types").GetUserResponse>;
213
216
  signUp: (body: Record<string, any>) => Promise<{
214
217
  key: string;
215
218
  }>;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inzombieland/core",
3
- "version": "1.19.11",
3
+ "version": "1.19.13",
4
4
  "type": "module",
5
5
  "license": "ISC",
6
6
  "main": "./index.mjs",
@@ -38,6 +38,7 @@ export type FetchConfig = {
38
38
  };
39
39
  export type GetUserResponse = {
40
40
  token?: string | null;
41
+ secretKey?: string;
41
42
  user?: User | null;
42
43
  };
43
44
  export type User = {
@@ -8,6 +8,7 @@ export declare const createApiUserActions: (fetch: Fetch, config: FetchConfig, g
8
8
  key: string;
9
9
  }>;
10
10
  signInByCodeVerifyCode: (body: Record<string, any>) => Promise<GetUserResponse>;
11
+ getToken: (body: Record<string, any>) => Promise<GetUserResponse>;
11
12
  signUp: (body: Record<string, any>) => Promise<{
12
13
  key: string;
13
14
  }>;
@@ -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,7 +28,24 @@ export const createApiUserActions = once(
28
28
  });
29
29
  },
30
30
  signInByCodeVerifyCode: async (body) => {
31
- const response = await fetch("/account/0/signinbycode/verifycode", {
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;
40
+ if (!accessToken) {
41
+ throw rest;
42
+ }
43
+ setToken(accessToken);
44
+ setSecretKey(secretKey);
45
+ return await getUser();
46
+ },
47
+ getToken: async (body) => {
48
+ const response = await fetch("/account/0/token", {
32
49
  body,
33
50
  method: "POST",
34
51
  ...config.useRequestHeaders?.(["cookie"]) ?? {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inzombieland/nuxt-common",
3
- "version": "1.19.11",
3
+ "version": "1.19.13",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "exports": {