dn-react-router-toolkit 0.2.3 → 0.2.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.
@@ -4,12 +4,10 @@ import 'jose';
4
4
 
5
5
  type AuthContextValue = {
6
6
  auth: AccessTokenPayload | undefined;
7
- login: (id: string, password: string) => Promise<void>;
7
+ login: (id: string, password: string) => Promise<AccessTokenPayload>;
8
8
  loginWithGoogle: (redirectUrl?: string) => Promise<void>;
9
9
  logout: () => Promise<void>;
10
- signup: (email: string, password: string, passwordConfirm: string) => Promise<{
11
- userId: string;
12
- }>;
10
+ signup: (email: string, password: string, passwordConfirm: string) => Promise<AccessTokenPayload>;
13
11
  requestResetPassword: (email: string) => Promise<boolean>;
14
12
  resetPassword: (token: string, password: string, passwordConfirm: string) => Promise<boolean>;
15
13
  };
@@ -4,12 +4,10 @@ import 'jose';
4
4
 
5
5
  type AuthContextValue = {
6
6
  auth: AccessTokenPayload | undefined;
7
- login: (id: string, password: string) => Promise<void>;
7
+ login: (id: string, password: string) => Promise<AccessTokenPayload>;
8
8
  loginWithGoogle: (redirectUrl?: string) => Promise<void>;
9
9
  logout: () => Promise<void>;
10
- signup: (email: string, password: string, passwordConfirm: string) => Promise<{
11
- userId: string;
12
- }>;
10
+ signup: (email: string, password: string, passwordConfirm: string) => Promise<AccessTokenPayload>;
13
11
  requestResetPassword: (email: string) => Promise<boolean>;
14
12
  resetPassword: (token: string, password: string, passwordConfirm: string) => Promise<boolean>;
15
13
  };
@@ -57,12 +57,11 @@ function AuthProvider({
57
57
  },
58
58
  body: JSON.stringify({ id, password })
59
59
  });
60
- if (res.ok) {
61
- navigate("/");
62
- } else {
60
+ if (!res.ok) {
63
61
  const { message } = await res.json();
64
- alert(message);
62
+ throw new Error(message);
65
63
  }
64
+ return res.json();
66
65
  };
67
66
  const loginWithGoogle = async (redirectUrl = "/") => {
68
67
  if (!googleAuth) {
@@ -21,12 +21,11 @@ function AuthProvider({
21
21
  },
22
22
  body: JSON.stringify({ id, password })
23
23
  });
24
- if (res.ok) {
25
- navigate("/");
26
- } else {
24
+ if (!res.ok) {
27
25
  const { message } = await res.json();
28
- alert(message);
26
+ throw new Error(message);
29
27
  }
28
+ return res.json();
30
29
  };
31
30
  const loginWithGoogle = async (redirectUrl = "/") => {
32
31
  if (!googleAuth) {
@@ -33,7 +33,7 @@ var JWTManager = class {
33
33
  constructor({
34
34
  siteOrigin,
35
35
  accessTokenSecret,
36
- accessTokenExpiresIn = "10s",
36
+ accessTokenExpiresIn = "1m",
37
37
  refreshTokenSecret,
38
38
  refreshTokenExpiresIn = "1y"
39
39
  }) {
@@ -9,7 +9,7 @@ var JWTManager = class {
9
9
  constructor({
10
10
  siteOrigin,
11
11
  accessTokenSecret,
12
- accessTokenExpiresIn = "10s",
12
+ accessTokenExpiresIn = "1m",
13
13
  refreshTokenSecret,
14
14
  refreshTokenExpiresIn = "1y"
15
15
  }) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dn-react-router-toolkit",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "types": "./dist/index.d.ts",
5
5
  "main": "./dist/index.mjs",
6
6
  "module": "./dist/index.js",