@panneau/auth 4.0.11 → 4.0.15

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.
@@ -0,0 +1,60 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ReactNode } from 'react';
3
+ import { User } from '@panneau/core';
4
+
5
+ declare function useAuthCheck(): {
6
+ check: () => any;
7
+ loading: boolean;
8
+ };
9
+
10
+ declare function useAuthLogin(): {
11
+ login: (email: any, password: any) => any;
12
+ loading: boolean;
13
+ };
14
+
15
+ declare function useAuthLogout(): {
16
+ logout: () => Promise<any>;
17
+ loading: boolean;
18
+ };
19
+
20
+ declare function useAuthRegister(): {
21
+ register: (data: any) => any;
22
+ loading: boolean;
23
+ };
24
+
25
+ declare function useAuthRequestPassword(): {
26
+ request: (email: any) => any;
27
+ loading: boolean;
28
+ };
29
+
30
+ declare function useAuthResetPassword(): {
31
+ reset: (data: any) => any;
32
+ loading: boolean;
33
+ };
34
+
35
+ type RegisterData = Record<string, unknown>;
36
+ type ResetPasswordData = Record<string, unknown>;
37
+ interface AuthContextValue {
38
+ user: User | null;
39
+ setUser: (nextUser: User) => void;
40
+ loggedIn: boolean;
41
+ logout: () => Promise<unknown>;
42
+ login: (email: string, password: string) => Promise<User>;
43
+ register: (data: RegisterData) => Promise<User>;
44
+ requestPassword: (email: string) => Promise<unknown>;
45
+ resetPassword: (data: ResetPasswordData) => Promise<unknown>;
46
+ }
47
+ declare function useAuth(): AuthContextValue;
48
+ declare function useUser(): User;
49
+ declare function useSetUser(): (nextUser: User) => void;
50
+ declare function useLogout(): () => Promise<unknown>;
51
+ declare function useLoggedIn(): boolean;
52
+ interface AuthProviderProps {
53
+ children: ReactNode;
54
+ user?: User | null;
55
+ onLogout?: (() => void) | null;
56
+ checkOnMount?: boolean;
57
+ }
58
+ declare function AuthProvider({ user: initialUser, checkOnMount, onLogout, children, }: AuthProviderProps): react_jsx_runtime.JSX.Element;
59
+
60
+ export { AuthProvider, useAuth, useAuthCheck, useAuthLogin, useAuthLogout, useAuthRegister, useAuthRequestPassword, useAuthResetPassword, useLoggedIn, useLogout, useSetUser, useUser };
@@ -1,11 +1,9 @@
1
1
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
2
- import { PropTypes as PropTypes$1 } from '@panneau/core';
3
- import PropTypes from 'prop-types';
4
- import { useState, useCallback, useEffect, useMemo, useContext, createContext } from 'react';
2
+ import { useState, useCallback, useEffect, useMemo, use, createContext } from 'react';
5
3
  import { jsx } from 'react/jsx-runtime';
6
4
  import { useApi } from '@panneau/data';
7
5
 
8
- var useAuthCheck = function useAuthCheck() {
6
+ function useAuthCheck() {
9
7
  var _useState = useState(false),
10
8
  _useState2 = _slicedToArray(_useState, 2),
11
9
  loading = _useState2[0],
@@ -25,9 +23,9 @@ var useAuthCheck = function useAuthCheck() {
25
23
  check: check,
26
24
  loading: loading
27
25
  };
28
- };
26
+ }
29
27
 
30
- var useAuthLogin = function useAuthLogin() {
28
+ function useAuthLogin() {
31
29
  var _useState = useState(false),
32
30
  _useState2 = _slicedToArray(_useState, 2),
33
31
  loading = _useState2[0],
@@ -47,9 +45,9 @@ var useAuthLogin = function useAuthLogin() {
47
45
  login: login,
48
46
  loading: loading
49
47
  };
50
- };
48
+ }
51
49
 
52
- var useAuthLogout = function useAuthLogout() {
50
+ function useAuthLogout() {
53
51
  var _useState = useState(false),
54
52
  _useState2 = _slicedToArray(_useState, 2),
55
53
  loading = _useState2[0],
@@ -75,9 +73,9 @@ var useAuthLogout = function useAuthLogout() {
75
73
  logout: logout,
76
74
  loading: loading
77
75
  };
78
- };
76
+ }
79
77
 
80
- var useAuthRegister = function useAuthRegister() {
78
+ function useAuthRegister() {
81
79
  var _useState = useState(false),
82
80
  _useState2 = _slicedToArray(_useState, 2),
83
81
  loading = _useState2[0],
@@ -97,9 +95,9 @@ var useAuthRegister = function useAuthRegister() {
97
95
  register: register,
98
96
  loading: loading
99
97
  };
100
- };
98
+ }
101
99
 
102
- var useAuthRequestPassword = function useAuthRequestPassword() {
100
+ function useAuthRequestPassword() {
103
101
  var _useState = useState(false),
104
102
  _useState2 = _slicedToArray(_useState, 2),
105
103
  loading = _useState2[0],
@@ -119,9 +117,9 @@ var useAuthRequestPassword = function useAuthRequestPassword() {
119
117
  request: request,
120
118
  loading: loading
121
119
  };
122
- };
120
+ }
123
121
 
124
- var useAuthResetPassword = function useAuthResetPassword() {
122
+ function useAuthResetPassword() {
125
123
  var _useState = useState(false),
126
124
  _useState2 = _slicedToArray(_useState, 2),
127
125
  loading = _useState2[0],
@@ -141,39 +139,52 @@ var useAuthResetPassword = function useAuthResetPassword() {
141
139
  reset: reset,
142
140
  loading: loading
143
141
  };
144
- };
142
+ }
145
143
 
146
- var AuthContext = /*#__PURE__*/createContext(null);
147
- var useAuth = function useAuth() {
148
- return useContext(AuthContext);
149
- };
150
- var useUser = function useUser() {
144
+ var AuthContext = /*#__PURE__*/createContext({
145
+ user: null,
146
+ setUser: function setUser() {},
147
+ loggedIn: false,
148
+ logout: function logout() {
149
+ return Promise.reject();
150
+ },
151
+ login: function login() {
152
+ return Promise.reject();
153
+ },
154
+ register: function register() {
155
+ return Promise.reject();
156
+ },
157
+ requestPassword: function requestPassword() {
158
+ return Promise.reject();
159
+ },
160
+ resetPassword: function resetPassword() {
161
+ return Promise.reject();
162
+ }
163
+ });
164
+ function useAuth() {
165
+ return use(AuthContext);
166
+ }
167
+ function useUser() {
151
168
  var _useAuth = useAuth(),
152
169
  user = _useAuth.user;
153
170
  return user;
154
- };
155
- var useSetUser = function useSetUser() {
171
+ }
172
+ function useSetUser() {
156
173
  var _useAuth2 = useAuth(),
157
174
  setUser = _useAuth2.setUser;
158
175
  return setUser;
159
- };
160
- var useLogout = function useLogout() {
176
+ }
177
+ function useLogout() {
161
178
  var _useAuth3 = useAuth(),
162
179
  logout = _useAuth3.logout;
163
180
  return logout;
164
- };
165
- var useLoggedIn = function useLoggedIn() {
181
+ }
182
+ function useLoggedIn() {
166
183
  var _useAuth4 = useAuth(),
167
184
  loggedIn = _useAuth4.loggedIn;
168
185
  return loggedIn;
169
- };
170
- var propTypes = {
171
- children: PropTypes.node.isRequired,
172
- user: PropTypes$1.user,
173
- onLogout: PropTypes.func,
174
- checkOnMount: PropTypes.bool
175
- };
176
- var AuthProvider = function AuthProvider(_ref) {
186
+ }
187
+ function AuthProvider(_ref) {
177
188
  var _ref$user = _ref.user,
178
189
  initialUser = _ref$user === void 0 ? null : _ref$user,
179
190
  _ref$checkOnMount = _ref.checkOnMount,
@@ -247,11 +258,10 @@ var AuthProvider = function AuthProvider(_ref) {
247
258
  resetPassword: resetPassword
248
259
  };
249
260
  }, [user, setUser, logout, login, register, requestPassword, resetPassword]);
250
- return /*#__PURE__*/jsx(AuthContext.Provider, {
261
+ return /*#__PURE__*/jsx(AuthContext, {
251
262
  value: value,
252
263
  children: children
253
264
  });
254
- };
255
- AuthProvider.propTypes = propTypes;
265
+ }
256
266
 
257
267
  export { AuthProvider, useAuth, useAuthCheck, useAuthLogin, useAuthLogout, useAuthRegister, useAuthRequestPassword, useAuthResetPassword, useLoggedIn, useLogout, useSetUser, useUser };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panneau/auth",
3
- "version": "4.0.11",
3
+ "version": "4.0.15",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "javascript"
@@ -34,18 +34,21 @@
34
34
  ],
35
35
  "license": "ISC",
36
36
  "type": "module",
37
- "module": "es/index.js",
37
+ "module": "dist/index.js",
38
+ "types": "dist/index.d.ts",
38
39
  "exports": {
39
- ".": "./es/index.js"
40
+ ".": {
41
+ "default": "./dist/index.js",
42
+ "types": "./dist/index.d.ts"
43
+ }
40
44
  },
41
45
  "files": [
42
- "lib",
43
- "es",
46
+ "dist",
44
47
  "assets"
45
48
  ],
46
49
  "scripts": {
47
50
  "prepublishOnly": "npm run build",
48
- "build": "../../scripts/prepare-package.sh"
51
+ "build": "../../scripts/prepare-package.sh --types"
49
52
  },
50
53
  "devDependencies": {
51
54
  "react": "^19.0.0",
@@ -57,12 +60,11 @@
57
60
  },
58
61
  "dependencies": {
59
62
  "@babel/runtime": "^7.12.5",
60
- "@panneau/core": "^4.0.11",
61
- "@panneau/data": "^4.0.11",
62
- "prop-types": "^15.7.2"
63
+ "@panneau/core": "^4.0.15",
64
+ "@panneau/data": "^4.0.15"
63
65
  },
64
66
  "publishConfig": {
65
67
  "access": "public"
66
68
  },
67
- "gitHead": "fe8264ed2815da0b5a40339dec99999c6fe70751"
69
+ "gitHead": "83c02ca2f26e02383ef452ffcafda984d0b211cd"
68
70
  }