@inzombieland/nuxt-common 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/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inzombieland/nuxt-common",
3
- "version": "1.18.30",
3
+ "version": "1.18.32",
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.18.30";
5
+ const version = "1.18.32";
6
6
 
7
7
  const module = defineNuxtModule({
8
8
  meta: {
@@ -17,13 +17,10 @@ export declare const config: {
17
17
  };
18
18
  };
19
19
  declare const fetch: Fetch, getUser: () => Promise<import("src/runtime/packages/core/types").GetUserResponse>, useApiFetch: () => Fetch, userActions: {
20
- signIn: (body: {
21
- username: string;
22
- password: string;
23
- rememberMe: boolean;
24
- }) => Promise<import("src/runtime/packages/core/types").GetUserResponse | {
20
+ signIn: (body: Record<string, any>) => Promise<import("src/runtime/packages/core/types").GetUserResponse | {
25
21
  key: string;
26
22
  }>;
23
+ signInByCodeVerifyCode: (body: Record<string, any>) => Promise<import("src/runtime/packages/core/types").GetUserResponse>;
27
24
  logout: () => Promise<void>;
28
25
  fetchActiveSessions: () => Promise<{
29
26
  sessions: import("src/runtime/packages/core/types").ActiveSession[];
@@ -75,5 +72,6 @@ declare const fetch: Fetch, getUser: () => Promise<import("src/runtime/packages/
75
72
  }) => Promise<void>;
76
73
  changeAvatar: (body: FormData) => Promise<void>;
77
74
  deleteAvatar: () => Promise<void>;
75
+ logoutFromAllActiveSessions: () => Promise<any>;
78
76
  };
79
77
  export { fetch, getUser, useApiFetch, userActions };
@@ -1,11 +1,8 @@
1
1
  import type { ActiveSession } from "../packages/core";
2
- export declare const signIn: (body: {
3
- username: string;
4
- password: string;
5
- rememberMe: boolean;
6
- }) => Promise<import("src/runtime/packages/core/types").GetUserResponse | {
2
+ export declare const signIn: (body: Record<string, any>) => Promise<import("src/runtime/packages/core/types").GetUserResponse | {
7
3
  key: string;
8
4
  }>;
5
+ export declare const signInByCodeVerifyCode: (body: Record<string, any>) => Promise<import("src/runtime/packages/core/types").GetUserResponse>;
9
6
  export declare const logout: () => Promise<void>;
10
7
  export declare const changeName: (body: {
11
8
  firstName: string;
@@ -48,16 +45,12 @@ export declare const changePhone: (body: {
48
45
  }) => Promise<void>;
49
46
  export declare const changeAvatar: (body: FormData) => Promise<void>;
50
47
  export declare const deleteAvatar: () => Promise<void>;
48
+ export declare const logoutFromAllActiveSessions: () => Promise<any>;
51
49
  export declare const signInByCodeSendCode: (body: {
52
50
  username: string;
53
51
  }) => Promise<{
54
52
  key: string;
55
53
  }>;
56
- export declare const signInByCodeVerifyCode: (body: {
57
- key: string;
58
- code: string;
59
- rememberMe?: boolean;
60
- }) => Promise<import("src/runtime/packages/core/types").GetUserResponse>;
61
54
  export declare const signUp: (body: {
62
55
  email: string;
63
56
  password: string;
@@ -96,7 +89,6 @@ export declare const logoutActiveSession: (body: {
96
89
  sessionId: string;
97
90
  visitorId: string;
98
91
  }) => Promise<any>;
99
- export declare const logoutFromAllActiveSessions: () => Promise<any>;
100
92
  export declare const deleteAccount: () => Promise<{
101
93
  key: string;
102
94
  }>;
@@ -1,7 +1,8 @@
1
1
  import { useRequestHeaders } from "#imports";
2
- import { flush, setToken } from "../packages/core/api-client.mjs";
3
- import { fetch, getUser, userActions } from "./index.mjs";
2
+ import { flush } from "../packages/core/api-client.mjs";
3
+ import { fetch, userActions } from "./index.mjs";
4
4
  export const signIn = userActions.signIn;
5
+ export const signInByCodeVerifyCode = userActions.signInByCodeVerifyCode;
5
6
  export const logout = userActions.logout;
6
7
  export const changeName = userActions.changeName;
7
8
  export const changeBirthday = userActions.changeBirthday;
@@ -13,6 +14,7 @@ export const confirmEmailChange = userActions.confirmEmailChange;
13
14
  export const changePhone = userActions.changePhone;
14
15
  export const changeAvatar = userActions.changeAvatar;
15
16
  export const deleteAvatar = userActions.deleteAvatar;
17
+ export const logoutFromAllActiveSessions = userActions.logoutFromAllActiveSessions;
16
18
  export const signInByCodeSendCode = async (body) => {
17
19
  return await fetch("/account/0/signinbycode/sendcode", {
18
20
  body,
@@ -21,20 +23,6 @@ export const signInByCodeSendCode = async (body) => {
21
23
  headers: useRequestHeaders(["cookie"])
22
24
  });
23
25
  };
24
- export const signInByCodeVerifyCode = async (body) => {
25
- const response = await fetch("/account/0/signinbycode/verifycode", {
26
- body,
27
- method: "POST",
28
- baseURL: "/",
29
- headers: useRequestHeaders(["cookie"])
30
- });
31
- const { accessToken, ...rest } = response;
32
- if (!accessToken) {
33
- throw rest;
34
- }
35
- setToken(accessToken);
36
- return await getUser();
37
- };
38
26
  export const signUp = async (body) => {
39
27
  return await fetch("/account/0/signup", {
40
28
  body,
@@ -89,9 +77,6 @@ export const fetchActiveSessions = async () => {
89
77
  export const logoutActiveSession = async (body) => {
90
78
  return await fetch("/account/1/logout/session", { body, method: "POST" });
91
79
  };
92
- export const logoutFromAllActiveSessions = async () => {
93
- return await fetch("/account/1/logout/sessions", { method: "POST" });
94
- };
95
80
  export const deleteAccount = async () => {
96
81
  return await fetch("/account/1/delete", { method: "POST" });
97
82
  };
@@ -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;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inzombieland/core",
3
- "version": "1.18.30",
3
+ "version": "1.18.32",
4
4
  "type": "module",
5
5
  "license": "ISC",
6
6
  "main": "./index.mjs",
@@ -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
  };
@@ -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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inzombieland/nuxt-common",
3
- "version": "1.18.30",
3
+ "version": "1.18.32",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "exports": {