@headless-adminapp/app 0.0.17-alpha.32 → 0.0.17-alpha.34
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/auth/AuthProvider.js
CHANGED
|
@@ -15,14 +15,7 @@ const react_query_1 = require("@tanstack/react-query");
|
|
|
15
15
|
const react_1 = require("react");
|
|
16
16
|
const context_1 = require("../mutable/context");
|
|
17
17
|
const context_2 = require("./context");
|
|
18
|
-
const
|
|
19
|
-
return {
|
|
20
|
-
email: 'demo@example.com',
|
|
21
|
-
fullName: 'Demo User',
|
|
22
|
-
exp: Date.now() / 1000 + 60 * 60 * 24,
|
|
23
|
-
};
|
|
24
|
-
});
|
|
25
|
-
const AuthProvider = ({ sessionResolver = defaultSessionResolver, onUnauthenticated, children, }) => {
|
|
18
|
+
const AuthProvider = ({ sessionResolver, onUnauthenticated, children, }) => {
|
|
26
19
|
const onUnauthenticatedRef = (0, react_1.useRef)(onUnauthenticated);
|
|
27
20
|
onUnauthenticatedRef.current = onUnauthenticated;
|
|
28
21
|
const queryClient = (0, react_query_1.useQueryClient)();
|
|
@@ -40,9 +33,11 @@ const AuthProvider = ({ sessionResolver = defaultSessionResolver, onUnauthentica
|
|
|
40
33
|
.catch(console.error);
|
|
41
34
|
}, [queryClient]);
|
|
42
35
|
const contextValue = (0, context_1.useCreateContextStore)({
|
|
43
|
-
loading:
|
|
36
|
+
loading: !!sessionResolver,
|
|
44
37
|
loadError: false,
|
|
45
|
-
|
|
38
|
+
authenticated: !sessionResolver,
|
|
39
|
+
initialized: !sessionResolver,
|
|
40
|
+
skipAuthCheck: !sessionResolver,
|
|
46
41
|
loadSession: () => Promise.resolve(),
|
|
47
42
|
onUnauthenticated: onUnauthenticatedInternal,
|
|
48
43
|
});
|
|
@@ -54,6 +49,9 @@ const AuthProvider = ({ sessionResolver = defaultSessionResolver, onUnauthentica
|
|
|
54
49
|
var _a;
|
|
55
50
|
contextValue.setValue({ loading: true, loadError: false });
|
|
56
51
|
try {
|
|
52
|
+
if (!sessionResolverRef.current) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
57
55
|
const data = yield sessionResolverRef.current();
|
|
58
56
|
if (!data) {
|
|
59
57
|
contextValue.setValue({
|
package/auth/context.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ interface AuthStoreAuthorizedState<T extends AuthSession = AuthSession> {
|
|
|
16
16
|
export type AuthState = (AuthStoreLoadingState | AuthStoreUnauthorizedState | AuthStoreAuthorizedState) & {
|
|
17
17
|
loading: boolean;
|
|
18
18
|
loadError: boolean;
|
|
19
|
+
skipAuthCheck?: boolean;
|
|
19
20
|
loadSession: () => Promise<void>;
|
|
20
21
|
onUnauthenticated?: (reason: UnauthorizeReason) => void;
|
|
21
22
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useIsSkipAuthCheck(): boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useIsSkipAuthCheck = useIsSkipAuthCheck;
|
|
4
|
+
const mutable_1 = require("../../mutable");
|
|
5
|
+
const context_1 = require("../context");
|
|
6
|
+
function useIsSkipAuthCheck() {
|
|
7
|
+
return (0, mutable_1.useContextSelector)(context_1.AuthContext, (state) => { var _a; return (_a = state.skipAuthCheck) !== null && _a !== void 0 ? _a : false; });
|
|
8
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@headless-adminapp/app",
|
|
3
|
-
"version": "0.0.17-alpha.
|
|
3
|
+
"version": "0.0.17-alpha.34",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"react-hook-form": "7.52.2",
|
|
40
40
|
"yup": "^1.4.0"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "4c3efe1f179c2b530941c0cf0817130173634330"
|
|
43
43
|
}
|