@panneau/auth 4.0.11 → 4.0.14

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 const useAuth: () => AuthContextValue;
48
+ declare const useUser: () => User;
49
+ declare const useSetUser: () => (nextUser: User) => void;
50
+ declare const useLogout: () => () => Promise<unknown>;
51
+ declare const useLoggedIn: () => boolean;
52
+ interface AuthProviderProps {
53
+ children: ReactNode;
54
+ user?: User | null;
55
+ onLogout?: (() => void) | null;
56
+ checkOnMount?: boolean;
57
+ }
58
+ declare const 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,7 +1,5 @@
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
 
@@ -143,9 +141,28 @@ var useAuthResetPassword = function useAuthResetPassword() {
143
141
  };
144
142
  };
145
143
 
146
- var AuthContext = /*#__PURE__*/createContext(null);
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
+ });
147
164
  var useAuth = function useAuth() {
148
- return useContext(AuthContext);
165
+ return use(AuthContext);
149
166
  };
150
167
  var useUser = function useUser() {
151
168
  var _useAuth = useAuth(),
@@ -167,12 +184,6 @@ var useLoggedIn = function useLoggedIn() {
167
184
  loggedIn = _useAuth4.loggedIn;
168
185
  return loggedIn;
169
186
  };
170
- var propTypes = {
171
- children: PropTypes.node.isRequired,
172
- user: PropTypes$1.user,
173
- onLogout: PropTypes.func,
174
- checkOnMount: PropTypes.bool
175
- };
176
187
  var AuthProvider = function AuthProvider(_ref) {
177
188
  var _ref$user = _ref.user,
178
189
  initialUser = _ref$user === void 0 ? null : _ref$user,
@@ -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
265
  };
255
- AuthProvider.propTypes = propTypes;
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.14",
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.14",
64
+ "@panneau/data": "^4.0.14"
63
65
  },
64
66
  "publishConfig": {
65
67
  "access": "public"
66
68
  },
67
- "gitHead": "fe8264ed2815da0b5a40339dec99999c6fe70751"
69
+ "gitHead": "ce35c2ddb30a7be2efe951882d9826dca577f5d4"
68
70
  }