@inzombieland/core 1.20.3 → 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/index.d.ts CHANGED
@@ -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<import("./types.js").GetUserResponse | {
12
+ signIn: (body: Record<string, any>) => Promise<{
13
13
  key: string;
14
14
  }>;
15
- signInByCodeSendCode: (body: Record<string, any>) => Promise<{
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<import("./types.js").GetUserResponse | {
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
- signInByCodeVerifyCode: (body: Record<string, any>) => Promise<import("./types.js").GetUserResponse>;
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<import("./types.js").GetUserResponse | {
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
- signInByCodeVerifyCode: (body: Record<string, any>) => Promise<import("./types.js").GetUserResponse>;
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inzombieland/core",
3
- "version": "1.20.3",
3
+ "version": "1.20.4",
4
4
  "type": "module",
5
5
  "license": "ISC",
6
6
  "main": "./index.js",
package/user-actions.d.ts CHANGED
@@ -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<GetUserResponse | {
4
+ signIn: (body: Record<string, any>) => Promise<{
5
5
  key: string;
6
6
  }>;
7
- signInByCodeSendCode: (body: Record<string, any>) => Promise<{
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;
package/user-actions.js CHANGED
@@ -11,31 +11,20 @@ export const createApiUserActions = once(
11
11
  method: "POST",
12
12
  ...config.useRequestHeaders?.(["cookie"]) ?? {}
13
13
  });
14
- const { accessToken, key, ...rest } = response;
15
- if (!accessToken) {
16
- if (key) {
17
- return { key };
18
- }
19
- throw rest;
14
+ const { key, ...rest } = response;
15
+ if (key) {
16
+ return { key };
20
17
  }
21
- setToken(accessToken);
22
- return await getUser();
23
- },
24
- signInByCodeSendCode: async (body) => {
25
- return await fetch("/account/0/signinbycode/sendcode", {
26
- body,
27
- method: "POST",
28
- ...config.useRequestHeaders?.(["cookie"]) ?? {}
29
- });
18
+ throw rest;
30
19
  },
31
- signInByCodeVerifyCode: async (body) => {
20
+ signInVerifyCode: async (body) => {
32
21
  const response = await fetch("/account/0/signinbycode/verifycode", {
33
22
  body,
34
23
  method: "POST",
35
24
  ...config.useRequestHeaders?.(["cookie"]) ?? {}
36
25
  });
37
26
  const { accessToken, sessionId, visitorId, secretKey, ...rest } = response;
38
- if (!accessToken || !sessionId) {
27
+ if (!accessToken || !sessionId || !visitorId || !secretKey) {
39
28
  throw rest;
40
29
  }
41
30
  setToken(accessToken);