zudoku 0.63.0 → 0.64.0
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/client.d.ts +8 -0
- package/dist/app/entry.server.js +14 -1
- package/dist/app/entry.server.js.map +1 -1
- package/dist/config/config.d.ts +3 -1
- package/dist/config/validators/BuildSchema.d.ts +5 -4
- package/dist/config/validators/BuildSchema.js +5 -2
- package/dist/config/validators/BuildSchema.js.map +1 -1
- package/dist/config/validators/InputNavigationSchema.d.ts +20 -20
- package/dist/config/validators/validate.d.ts +10 -12
- package/dist/config/validators/validate.js +8 -8
- package/dist/config/validators/validate.js.map +1 -1
- package/dist/flat-config.d.ts +6 -1
- package/dist/lib/authentication/authentication.d.ts +17 -9
- package/dist/lib/authentication/components/OAuthErrorPage.js +1 -1
- package/dist/lib/authentication/components/OAuthErrorPage.js.map +1 -1
- package/dist/lib/authentication/components/SignIn.js +6 -5
- package/dist/lib/authentication/components/SignIn.js.map +1 -1
- package/dist/lib/authentication/components/SignOut.js +6 -6
- package/dist/lib/authentication/components/SignOut.js.map +1 -1
- package/dist/lib/authentication/components/SignUp.js +5 -5
- package/dist/lib/authentication/components/SignUp.js.map +1 -1
- package/dist/lib/authentication/hook.d.ts +3 -2
- package/dist/lib/authentication/hook.js +12 -8
- package/dist/lib/authentication/hook.js.map +1 -1
- package/dist/lib/authentication/providers/auth0.js +1 -1
- package/dist/lib/authentication/providers/auth0.js.map +1 -1
- package/dist/lib/authentication/providers/azureb2c.d.ts +4 -4
- package/dist/lib/authentication/providers/azureb2c.js +3 -3
- package/dist/lib/authentication/providers/azureb2c.js.map +1 -1
- package/dist/lib/authentication/providers/clerk.js +2 -2
- package/dist/lib/authentication/providers/clerk.js.map +1 -1
- package/dist/lib/authentication/providers/openid.d.ts +7 -7
- package/dist/lib/authentication/providers/openid.js +5 -3
- package/dist/lib/authentication/providers/openid.js.map +1 -1
- package/dist/lib/authentication/providers/supabase/SupabaseAuthUI.d.ts +8 -0
- package/dist/lib/authentication/providers/supabase/SupabaseAuthUI.js +39 -0
- package/dist/lib/authentication/providers/supabase/SupabaseAuthUI.js.map +1 -0
- package/dist/lib/authentication/providers/supabase.js +35 -31
- package/dist/lib/authentication/providers/supabase.js.map +1 -1
- package/dist/lib/authentication/state.d.ts +1 -5
- package/dist/lib/authentication/state.js +2 -14
- package/dist/lib/authentication/state.js.map +1 -1
- package/dist/lib/components/Zudoku.js +3 -3
- package/dist/lib/components/index.d.ts +2 -2
- package/dist/lib/components/navigation/Toc.js +1 -1
- package/dist/lib/components/navigation/Toc.js.map +1 -1
- package/dist/lib/core/RouteGuard.d.ts +1 -1
- package/dist/lib/core/RouteGuard.js +6 -14
- package/dist/lib/core/RouteGuard.js.map +1 -1
- package/dist/lib/core/ZudokuContext.d.ts +1 -0
- package/dist/lib/core/ZudokuContext.js +2 -0
- package/dist/lib/core/ZudokuContext.js.map +1 -1
- package/dist/lib/core/__internal.d.ts +1 -1
- package/dist/lib/hooks/index.d.ts +2 -2
- package/dist/lib/plugins/markdown/MdxPage.d.ts +2 -1
- package/dist/lib/plugins/markdown/MdxPage.js +3 -2
- package/dist/lib/plugins/markdown/MdxPage.js.map +1 -1
- package/dist/lib/plugins/markdown/index.d.ts +1 -0
- package/dist/lib/plugins/markdown/index.js +1 -1
- package/dist/lib/plugins/markdown/index.js.map +1 -1
- package/dist/lib/plugins/openapi/index.js +4 -9
- package/dist/lib/plugins/openapi/index.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/CollapsibleHeader.js +1 -1
- package/dist/lib/plugins/openapi/playground/CollapsibleHeader.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/Playground.js +12 -2
- package/dist/lib/plugins/openapi/playground/Playground.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/RequestLoginDialog.d.ts +2 -1
- package/dist/lib/plugins/openapi/playground/RequestLoginDialog.js +10 -2
- package/dist/lib/plugins/openapi/playground/RequestLoginDialog.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/result-panel/Highlight.d.ts +1 -1
- package/dist/lib/plugins/openapi/playground/result-panel/ResponseStatusBar.js +1 -1
- package/dist/lib/plugins/openapi/playground/result-panel/ResponseStatusBar.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/result-panel/ResponseTab.js +23 -21
- package/dist/lib/plugins/openapi/playground/result-panel/ResponseTab.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/result-panel/ResultPanel.js +1 -1
- package/dist/lib/plugins/openapi/playground/result-panel/ResultPanel.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/useRememberSkipLoginDialog.js +2 -0
- package/dist/lib/plugins/openapi/playground/useRememberSkipLoginDialog.js.map +1 -1
- package/dist/lib/shiki.d.ts +1 -1
- package/dist/lib/shiki.js +13 -2
- package/dist/lib/shiki.js.map +1 -1
- package/dist/lib/ui/Callout.d.ts +5 -5
- package/dist/lib/ui/Callout.js +5 -5
- package/dist/lib/ui/Callout.js.map +1 -1
- package/dist/lib/ui/EmbeddedCodeBlock.d.ts +3 -1
- package/dist/lib/ui/EmbeddedCodeBlock.js +2 -2
- package/dist/lib/ui/EmbeddedCodeBlock.js.map +1 -1
- package/dist/lib/ui/ReactComponentDoc.d.ts +1 -1
- package/dist/lib/ui/ReactComponentDoc.js +2 -2
- package/dist/lib/ui/ReactComponentDoc.js.map +1 -1
- package/dist/lib/ui/SyntaxHighlight.d.ts +1 -0
- package/dist/lib/ui/SyntaxHighlight.js.map +1 -1
- package/dist/lib/util/MdxComponents.d.ts +2 -1
- package/dist/lib/util/MdxComponents.js +3 -2
- package/dist/lib/util/MdxComponents.js.map +1 -1
- package/dist/lib/util/syncZustandState.d.ts +5 -0
- package/dist/lib/util/syncZustandState.js +14 -0
- package/dist/lib/util/syncZustandState.js.map +1 -0
- package/dist/vite/api/SchemaManager.d.ts +3 -1
- package/dist/vite/api/SchemaManager.js +22 -3
- package/dist/vite/api/SchemaManager.js.map +1 -1
- package/dist/vite/api/SchemaManager.test.js +2 -2
- package/dist/vite/api/SchemaManager.test.js.map +1 -1
- package/dist/vite/plugin-api.js +14 -5
- package/dist/vite/plugin-api.js.map +1 -1
- package/dist/vite/plugin-docs.js +1 -1
- package/dist/vite/plugin-docs.js.map +1 -1
- package/dist/vite/plugin-markdown-export.js +4 -2
- package/dist/vite/plugin-markdown-export.js.map +1 -1
- package/dist/vite/plugin-mdx.js +36 -30
- package/dist/vite/plugin-mdx.js.map +1 -1
- package/lib/{ErrorAlert-VBJ8aHH7.js → ErrorAlert-DE3Sf66a.js} +1711 -1772
- package/lib/ErrorAlert-DE3Sf66a.js.map +1 -0
- package/lib/{MdxPage-DFRNwSsc.js → MdxPage-DZfeC0QY.js} +81 -80
- package/lib/MdxPage-DZfeC0QY.js.map +1 -0
- package/lib/{OAuthErrorPage-DJUOdr6Q.js → OAuthErrorPage-BycMozgn.js} +8 -8
- package/lib/{OAuthErrorPage-DJUOdr6Q.js.map → OAuthErrorPage-BycMozgn.js.map} +1 -1
- package/lib/{OasProvider-D2NYAaBN.js → OasProvider-Bf5zBDBY.js} +3 -3
- package/lib/{OasProvider-D2NYAaBN.js.map → OasProvider-Bf5zBDBY.js.map} +1 -1
- package/lib/{OperationList-DmXCI4NU.js → OperationList-Cmiw1xm2.js} +10 -10
- package/lib/{OperationList-DmXCI4NU.js.map → OperationList-Cmiw1xm2.js.map} +1 -1
- package/lib/{Pagination-CT4VUR6u.js → Pagination-CJszmeSA.js} +3 -3
- package/lib/{Pagination-CT4VUR6u.js.map → Pagination-CJszmeSA.js.map} +1 -1
- package/lib/RouteGuard-DhU3LRr1.js +81 -0
- package/lib/RouteGuard-DhU3LRr1.js.map +1 -0
- package/lib/{RouterError-fm21cqlj.js → RouterError-VDLnrFqF.js} +5 -5
- package/lib/{RouterError-fm21cqlj.js.map → RouterError-VDLnrFqF.js.map} +1 -1
- package/lib/{SchemaList-uElsscMN.js → SchemaList-xZSf3IMh.js} +7 -7
- package/lib/{SchemaList-uElsscMN.js.map → SchemaList-xZSf3IMh.js.map} +1 -1
- package/lib/{SchemaView-CNQ3VAbI.js → SchemaView-tHXTm5oM.js} +3 -3
- package/lib/{SchemaView-CNQ3VAbI.js.map → SchemaView-tHXTm5oM.js.map} +1 -1
- package/lib/{Select-CPoGZU_V.js → Select-C1DeCqKv.js} +3 -3
- package/lib/{Select-CPoGZU_V.js.map → Select-C1DeCqKv.js.map} +1 -1
- package/lib/SignUp-6SGx9Yyq.js +50 -0
- package/lib/SignUp-6SGx9Yyq.js.map +1 -0
- package/lib/{SyntaxHighlight-B0laqAqK.js → SyntaxHighlight-zvlnSnHB.js} +789 -778
- package/lib/{SyntaxHighlight-B0laqAqK.js.map → SyntaxHighlight-zvlnSnHB.js.map} +1 -1
- package/lib/{Toc-KzXCRqrX.js → Toc-Da9yp7lo.js} +5 -5
- package/lib/Toc-Da9yp7lo.js.map +1 -0
- package/lib/{ZudokuContext-BXTZApgy.js → ZudokuContext-BUZ5hkWB.js} +33 -31
- package/lib/ZudokuContext-BUZ5hkWB.js.map +1 -0
- package/lib/{chunk-PVWAREVJ-BO6B-RAk.js → chunk-PVWAREVJ-BMhpCH5D.js} +7 -7
- package/lib/{chunk-PVWAREVJ-BO6B-RAk.js.map → chunk-PVWAREVJ-BMhpCH5D.js.map} +1 -1
- package/lib/{circular-BWT7_Ahq.js → circular-DvuimBGQ.js} +2 -2
- package/lib/{circular-BWT7_Ahq.js.map → circular-DvuimBGQ.js.map} +1 -1
- package/lib/{createServer-zhJZSgor.js → createServer-D9UvCoDf.js} +4 -4
- package/lib/{createServer-zhJZSgor.js.map → createServer-D9UvCoDf.js.map} +1 -1
- package/lib/{errors-XqO6MsfU.js → errors-CuGgh3hf.js} +2 -2
- package/lib/{errors-XqO6MsfU.js.map → errors-CuGgh3hf.js.map} +1 -1
- package/lib/hook-CMeoxziF.js +40 -0
- package/lib/hook-CMeoxziF.js.map +1 -0
- package/lib/{index-BPSpOxTK.js → index-B1rmok4X.js} +148 -147
- package/lib/index-B1rmok4X.js.map +1 -0
- package/lib/{index-D8Btv4uT.js → index-Cr9_YzOZ.js} +826 -780
- package/lib/index-Cr9_YzOZ.js.map +1 -0
- package/lib/{index-C5L4favO.js → index-rYHsvtTo.js} +2 -2
- package/lib/{index-C5L4favO.js.map → index-rYHsvtTo.js.map} +1 -1
- package/lib/{mutation-CdGPxHNX.js → mutation-BSU0xu4m.js} +2 -2
- package/lib/{mutation-CdGPxHNX.js.map → mutation-BSU0xu4m.js.map} +1 -1
- package/lib/ui/Callout.js +18 -18
- package/lib/ui/Callout.js.map +1 -1
- package/lib/ui/CodeBlock.js +217 -7
- package/lib/ui/CodeBlock.js.map +1 -1
- package/lib/ui/EmbeddedCodeBlock.js +22 -19
- package/lib/ui/EmbeddedCodeBlock.js.map +1 -1
- package/lib/ui/ReactComponentDoc.js +13 -13
- package/lib/ui/ReactComponentDoc.js.map +1 -1
- package/lib/ui/SyntaxHighlight.js +3 -3
- package/lib/{useExposedProps-Cd7Yg_uG.js → useExposedProps-U3pmsHaG.js} +2 -2
- package/lib/{useExposedProps-Cd7Yg_uG.js.map → useExposedProps-U3pmsHaG.js.map} +1 -1
- package/lib/zudoku.__internal.js +7 -7
- package/lib/zudoku.auth-auth0.js +13 -13
- package/lib/zudoku.auth-auth0.js.map +1 -1
- package/lib/zudoku.auth-azureb2c.js +28 -28
- package/lib/zudoku.auth-azureb2c.js.map +1 -1
- package/lib/zudoku.auth-clerk.js +40 -40
- package/lib/zudoku.auth-clerk.js.map +1 -1
- package/lib/zudoku.auth-openid.js +53 -56
- package/lib/zudoku.auth-openid.js.map +1 -1
- package/lib/zudoku.auth-supabase.js +111 -52
- package/lib/zudoku.auth-supabase.js.map +1 -1
- package/lib/zudoku.components.js +6 -6
- package/lib/zudoku.hooks.js +4 -4
- package/lib/zudoku.plugin-api-catalog.js +5 -5
- package/lib/zudoku.plugin-api-keys.js +99 -99
- package/lib/zudoku.plugin-custom-pages.js +1 -1
- package/lib/zudoku.plugin-markdown.js +10 -9
- package/lib/zudoku.plugin-markdown.js.map +1 -1
- package/lib/zudoku.plugin-openapi.js +6 -7
- package/lib/zudoku.plugin-openapi.js.map +1 -1
- package/lib/zudoku.plugin-redirect.js +1 -1
- package/lib/zudoku.plugin-search-pagefind.js +38 -38
- package/lib/zudoku.plugin-search-pagefind.js.map +1 -1
- package/lib/zudoku.router.js +2 -2
- package/package.json +18 -10
- package/src/app/entry.server.tsx +16 -6
- package/src/app/main.css +61 -9
- package/src/lib/authentication/authentication.ts +22 -4
- package/src/lib/authentication/components/OAuthErrorPage.tsx +1 -1
- package/src/lib/authentication/components/SignIn.tsx +7 -5
- package/src/lib/authentication/components/SignOut.tsx +7 -6
- package/src/lib/authentication/components/SignUp.tsx +5 -8
- package/src/lib/authentication/hook.ts +21 -10
- package/src/lib/authentication/providers/auth0.tsx +2 -1
- package/src/lib/authentication/providers/azureb2c.tsx +10 -3
- package/src/lib/authentication/providers/clerk.tsx +9 -2
- package/src/lib/authentication/providers/openid.tsx +20 -15
- package/src/lib/authentication/providers/supabase/SupabaseAuthUI.tsx +75 -0
- package/src/lib/authentication/providers/supabase.tsx +59 -43
- package/src/lib/authentication/state.ts +3 -23
- package/src/lib/components/Zudoku.tsx +3 -3
- package/src/lib/components/navigation/Toc.tsx +3 -3
- package/src/lib/core/RouteGuard.tsx +33 -13
- package/src/lib/core/ZudokuContext.ts +3 -0
- package/src/lib/plugins/markdown/MdxPage.tsx +4 -1
- package/src/lib/plugins/markdown/index.tsx +2 -0
- package/src/lib/plugins/openapi/index.tsx +9 -29
- package/src/lib/plugins/openapi/playground/CollapsibleHeader.tsx +2 -2
- package/src/lib/plugins/openapi/playground/Playground.tsx +13 -2
- package/src/lib/plugins/openapi/playground/RequestLoginDialog.tsx +20 -1
- package/src/lib/plugins/openapi/playground/result-panel/ResponseStatusBar.tsx +2 -2
- package/src/lib/plugins/openapi/playground/result-panel/ResponseTab.tsx +102 -58
- package/src/lib/plugins/openapi/playground/result-panel/ResultPanel.tsx +1 -1
- package/src/lib/plugins/openapi/playground/useRememberSkipLoginDialog.tsx +3 -0
- package/src/lib/shiki.ts +16 -2
- package/src/lib/ui/Callout.tsx +10 -5
- package/src/lib/ui/EmbeddedCodeBlock.tsx +6 -3
- package/src/lib/ui/ReactComponentDoc.tsx +17 -17
- package/src/lib/ui/SyntaxHighlight.tsx +6 -1
- package/src/lib/util/MdxComponents.tsx +3 -5
- package/src/lib/util/syncZustandState.ts +22 -0
- package/lib/CodeBlock-CanTUJLl.js +0 -221
- package/lib/CodeBlock-CanTUJLl.js.map +0 -1
- package/lib/ErrorAlert-VBJ8aHH7.js.map +0 -1
- package/lib/MdxPage-DFRNwSsc.js.map +0 -1
- package/lib/RouteGuard-Bg0Lu0OU.js +0 -56
- package/lib/RouteGuard-Bg0Lu0OU.js.map +0 -1
- package/lib/SignUp-BraHuRN_.js +0 -56
- package/lib/SignUp-BraHuRN_.js.map +0 -1
- package/lib/Toc-KzXCRqrX.js.map +0 -1
- package/lib/ZudokuContext-BXTZApgy.js.map +0 -1
- package/lib/hook-CAebs2rv.js +0 -31
- package/lib/hook-CAebs2rv.js.map +0 -1
- package/lib/index-BPSpOxTK.js.map +0 -1
- package/lib/index-D8Btv4uT.js.map +0 -1
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { useEffect } from "react";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { useLatest } from "../../util/useLatest.js";
|
|
3
|
+
import { useAuth } from "../hook.js";
|
|
4
4
|
|
|
5
5
|
export const SignOut = () => {
|
|
6
|
-
const
|
|
7
|
-
|
|
6
|
+
const auth = useAuth();
|
|
7
|
+
|
|
8
|
+
const logout = useLatest(auth.logout);
|
|
8
9
|
|
|
9
10
|
useEffect(() => {
|
|
10
|
-
void
|
|
11
|
-
}, [
|
|
11
|
+
void logout.current();
|
|
12
|
+
}, [logout]);
|
|
12
13
|
|
|
13
14
|
return null;
|
|
14
15
|
};
|
|
@@ -7,14 +7,14 @@ import {
|
|
|
7
7
|
CardHeader,
|
|
8
8
|
CardTitle,
|
|
9
9
|
} from "zudoku/ui/Card.js";
|
|
10
|
-
import {
|
|
10
|
+
import { useAuth } from "../hook.js";
|
|
11
11
|
|
|
12
12
|
export const SignUp = () => {
|
|
13
|
-
const
|
|
13
|
+
const auth = useAuth();
|
|
14
14
|
|
|
15
15
|
useEffect(() => {
|
|
16
|
-
void
|
|
17
|
-
}, [
|
|
16
|
+
void auth.signup();
|
|
17
|
+
}, [auth]);
|
|
18
18
|
|
|
19
19
|
return (
|
|
20
20
|
<div className="flex items-center justify-center mt-8">
|
|
@@ -28,10 +28,7 @@ export const SignUp = () => {
|
|
|
28
28
|
</CardHeader>
|
|
29
29
|
<CardContent>
|
|
30
30
|
<div className="flex flex-col gap-2 justify-center">
|
|
31
|
-
<Button
|
|
32
|
-
onClick={() => context.authentication?.signIn()}
|
|
33
|
-
variant="default"
|
|
34
|
-
>
|
|
31
|
+
<Button onClick={() => auth.signup()} variant="default">
|
|
35
32
|
Register
|
|
36
33
|
</Button>
|
|
37
34
|
<Button variant="link" className="text-muted-foreground" asChild>
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { useNavigate } from "react-router";
|
|
1
2
|
import { useZudoku } from "../components/context/ZudokuContext.js";
|
|
3
|
+
import type { AuthActionOptions } from "./authentication.js";
|
|
2
4
|
import { useAuthState } from "./state.js";
|
|
3
5
|
|
|
4
6
|
export type UseAuthReturn = ReturnType<typeof useAuth>;
|
|
@@ -7,19 +9,24 @@ export const useAuth = () => {
|
|
|
7
9
|
const { authentication } = useZudoku();
|
|
8
10
|
const authState = useAuthState();
|
|
9
11
|
const isAuthEnabled = typeof authentication !== "undefined";
|
|
12
|
+
const navigate = useNavigate();
|
|
10
13
|
|
|
11
14
|
return {
|
|
12
15
|
isAuthEnabled,
|
|
13
16
|
...authState,
|
|
14
17
|
|
|
15
|
-
login: async () => {
|
|
18
|
+
login: async (options?: AuthActionOptions) => {
|
|
16
19
|
if (!isAuthEnabled) {
|
|
17
20
|
throw new Error("Authentication is not enabled.");
|
|
18
21
|
}
|
|
19
22
|
// TODO: Should handle errors/state
|
|
20
|
-
await authentication.signIn(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
await authentication.signIn(
|
|
24
|
+
{ navigate },
|
|
25
|
+
{
|
|
26
|
+
...options,
|
|
27
|
+
redirectTo: options?.redirectTo ?? window.location.href,
|
|
28
|
+
},
|
|
29
|
+
);
|
|
23
30
|
},
|
|
24
31
|
|
|
25
32
|
logout: async () => {
|
|
@@ -27,19 +34,23 @@ export const useAuth = () => {
|
|
|
27
34
|
throw new Error("Authentication is not enabled.");
|
|
28
35
|
}
|
|
29
36
|
// TODO: Should handle errors/state
|
|
30
|
-
await authentication.signOut();
|
|
37
|
+
await authentication.signOut({ navigate });
|
|
31
38
|
|
|
32
39
|
// Redirect to home
|
|
33
|
-
|
|
40
|
+
void navigate("/", { replace: true });
|
|
34
41
|
},
|
|
35
42
|
|
|
36
|
-
signup: async () => {
|
|
43
|
+
signup: async (options?: AuthActionOptions) => {
|
|
37
44
|
if (!isAuthEnabled) {
|
|
38
45
|
throw new Error("Authentication is not enabled.");
|
|
39
46
|
}
|
|
40
|
-
await authentication.signUp(
|
|
41
|
-
|
|
42
|
-
|
|
47
|
+
await authentication.signUp(
|
|
48
|
+
{ navigate },
|
|
49
|
+
{
|
|
50
|
+
...options,
|
|
51
|
+
redirectTo: options?.redirectTo ?? window.location.href,
|
|
52
|
+
},
|
|
53
|
+
);
|
|
43
54
|
},
|
|
44
55
|
};
|
|
45
56
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Auth0AuthenticationConfig } from "../../../config/config.js";
|
|
2
2
|
import type {
|
|
3
|
+
AuthActionContext,
|
|
3
4
|
AuthenticationPlugin,
|
|
4
5
|
AuthenticationProviderInitializer,
|
|
5
6
|
} from "../authentication.js";
|
|
@@ -35,7 +36,7 @@ class Auth0AuthenticationProvider
|
|
|
35
36
|
}
|
|
36
37
|
};
|
|
37
38
|
|
|
38
|
-
signOut = async (): Promise<void> => {
|
|
39
|
+
signOut = async (_: AuthActionContext): Promise<void> => {
|
|
39
40
|
const as = await this.getAuthServer();
|
|
40
41
|
const idToken = await this.getAccessToken();
|
|
41
42
|
|
|
@@ -6,6 +6,7 @@ import { ClientOnly } from "../../components/ClientOnly.js";
|
|
|
6
6
|
import { joinUrl } from "../../util/joinUrl.js";
|
|
7
7
|
import { CoreAuthenticationPlugin } from "../AuthenticationPlugin.js";
|
|
8
8
|
import type {
|
|
9
|
+
AuthActionContext,
|
|
9
10
|
AuthenticationPlugin,
|
|
10
11
|
AuthenticationProviderInitializer,
|
|
11
12
|
} from "../authentication.js";
|
|
@@ -106,7 +107,10 @@ export class AzureB2CAuthPlugin
|
|
|
106
107
|
});
|
|
107
108
|
}
|
|
108
109
|
|
|
109
|
-
async signUp(
|
|
110
|
+
async signUp(
|
|
111
|
+
_: AuthActionContext,
|
|
112
|
+
{ redirectTo }: { redirectTo?: string } = {},
|
|
113
|
+
) {
|
|
110
114
|
const redirectUri = this.redirectToAfterSignUp ?? redirectTo ?? "/";
|
|
111
115
|
sessionStorage.setItem("redirect-to", redirectUri);
|
|
112
116
|
|
|
@@ -116,7 +120,10 @@ export class AzureB2CAuthPlugin
|
|
|
116
120
|
});
|
|
117
121
|
}
|
|
118
122
|
|
|
119
|
-
async signIn(
|
|
123
|
+
async signIn(
|
|
124
|
+
_: AuthActionContext,
|
|
125
|
+
{ redirectTo }: { redirectTo?: string } = {},
|
|
126
|
+
) {
|
|
120
127
|
const redirectUri = this.redirectToAfterSignIn ?? redirectTo ?? "/";
|
|
121
128
|
sessionStorage.setItem("redirect-to", redirectUri);
|
|
122
129
|
|
|
@@ -156,7 +163,7 @@ export class AzureB2CAuthPlugin
|
|
|
156
163
|
return request;
|
|
157
164
|
};
|
|
158
165
|
|
|
159
|
-
signOut = async () => {
|
|
166
|
+
signOut = async (_: AuthActionContext) => {
|
|
160
167
|
const account = this.msalInstance.getAllAccounts()[0];
|
|
161
168
|
if (account) {
|
|
162
169
|
await this.msalInstance.logoutRedirect({
|
|
@@ -3,6 +3,7 @@ import { LogOutIcon } from "lucide-react";
|
|
|
3
3
|
import type { ZudokuPlugin } from "zudoku/plugins";
|
|
4
4
|
import type { ClerkAuthenticationConfig } from "../../../config/config.js";
|
|
5
5
|
import type {
|
|
6
|
+
AuthActionContext,
|
|
6
7
|
AuthenticationPlugin,
|
|
7
8
|
AuthenticationProviderInitializer,
|
|
8
9
|
} from "../authentication.js";
|
|
@@ -147,7 +148,10 @@ const clerkAuth: AuthenticationProviderInitializer<
|
|
|
147
148
|
});
|
|
148
149
|
useAuthState.getState().setLoggedOut();
|
|
149
150
|
},
|
|
150
|
-
signIn: async (
|
|
151
|
+
signIn: async (
|
|
152
|
+
_: AuthActionContext,
|
|
153
|
+
{ redirectTo }: { redirectTo?: string } = {},
|
|
154
|
+
) => {
|
|
151
155
|
await ensureLoaded;
|
|
152
156
|
await clerkApi?.redirectToSignIn({
|
|
153
157
|
signInForceRedirectUrl: redirectToAfterSignIn
|
|
@@ -158,7 +162,10 @@ const clerkAuth: AuthenticationProviderInitializer<
|
|
|
158
162
|
: redirectTo,
|
|
159
163
|
});
|
|
160
164
|
},
|
|
161
|
-
signUp: async (
|
|
165
|
+
signUp: async (
|
|
166
|
+
_: AuthActionContext,
|
|
167
|
+
{ redirectTo }: { redirectTo?: string } = {},
|
|
168
|
+
) => {
|
|
162
169
|
await ensureLoaded;
|
|
163
170
|
await clerkApi?.redirectToSignUp({
|
|
164
171
|
signInForceRedirectUrl: redirectToAfterSignIn
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import logger from "loglevel";
|
|
2
2
|
import * as oauth from "oauth4webapi";
|
|
3
3
|
import { ErrorBoundary } from "react-error-boundary";
|
|
4
|
+
import type { NavigateFunction } from "react-router";
|
|
4
5
|
import type { OpenIDAuthenticationConfig } from "../../../config/config.js";
|
|
5
6
|
import { ClientOnly } from "../../components/ClientOnly.js";
|
|
6
7
|
import { joinUrl } from "../../util/joinUrl.js";
|
|
7
8
|
import { CoreAuthenticationPlugin } from "../AuthenticationPlugin.js";
|
|
8
9
|
import type {
|
|
10
|
+
AuthActionContext,
|
|
11
|
+
AuthActionOptions,
|
|
9
12
|
AuthenticationPlugin,
|
|
10
13
|
AuthenticationProviderInitializer,
|
|
11
14
|
} from "../authentication.js";
|
|
@@ -115,13 +118,16 @@ export class OpenIDAuthenticationProvider
|
|
|
115
118
|
});
|
|
116
119
|
}
|
|
117
120
|
|
|
118
|
-
async signUp(
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
121
|
+
async signUp(
|
|
122
|
+
_: { navigate: NavigateFunction },
|
|
123
|
+
{
|
|
124
|
+
redirectTo,
|
|
125
|
+
replace = false,
|
|
126
|
+
}: {
|
|
127
|
+
redirectTo?: string;
|
|
128
|
+
replace?: boolean;
|
|
129
|
+
} = {},
|
|
130
|
+
) {
|
|
125
131
|
return this.authorize({
|
|
126
132
|
redirectTo: this.redirectToAfterSignUp ?? redirectTo ?? "/",
|
|
127
133
|
replace,
|
|
@@ -129,13 +135,10 @@ export class OpenIDAuthenticationProvider
|
|
|
129
135
|
});
|
|
130
136
|
}
|
|
131
137
|
|
|
132
|
-
async signIn(
|
|
133
|
-
|
|
134
|
-
replace = false,
|
|
135
|
-
|
|
136
|
-
redirectTo?: string;
|
|
137
|
-
replace?: boolean;
|
|
138
|
-
} = {}) {
|
|
138
|
+
async signIn(
|
|
139
|
+
_: AuthActionContext,
|
|
140
|
+
{ redirectTo, replace = false }: AuthActionOptions,
|
|
141
|
+
) {
|
|
139
142
|
return this.authorize({
|
|
140
143
|
redirectTo: this.redirectToAfterSignIn ?? redirectTo ?? "/",
|
|
141
144
|
replace,
|
|
@@ -178,6 +181,7 @@ export class OpenIDAuthenticationProvider
|
|
|
178
181
|
const redirectUrl = new URL(window.location.origin);
|
|
179
182
|
redirectUrl.pathname = this.callbackUrlPath;
|
|
180
183
|
redirectUrl.search = "";
|
|
184
|
+
redirectUrl.hash = "";
|
|
181
185
|
|
|
182
186
|
authorizationUrl.searchParams.set("client_id", this.client.client_id);
|
|
183
187
|
authorizationUrl.searchParams.set("redirect_uri", redirectUrl.toString());
|
|
@@ -260,7 +264,7 @@ export class OpenIDAuthenticationProvider
|
|
|
260
264
|
return request;
|
|
261
265
|
};
|
|
262
266
|
|
|
263
|
-
signOut = async () => {
|
|
267
|
+
signOut = async (_: AuthActionContext) => {
|
|
264
268
|
useAuthState.setState({
|
|
265
269
|
isAuthenticated: false,
|
|
266
270
|
isPending: false,
|
|
@@ -384,6 +388,7 @@ export class OpenIDAuthenticationProvider
|
|
|
384
388
|
const redirectUrl = new URL(url);
|
|
385
389
|
redirectUrl.pathname = this.callbackUrlPath;
|
|
386
390
|
redirectUrl.search = "";
|
|
391
|
+
redirectUrl.hash = "";
|
|
387
392
|
|
|
388
393
|
const response = await oauth.authorizationCodeGrantRequest(
|
|
389
394
|
authServer,
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Auth } from "@supabase/auth-ui-react";
|
|
2
|
+
import {
|
|
3
|
+
ThemeSupa,
|
|
4
|
+
type ThemeVariables,
|
|
5
|
+
type ViewType,
|
|
6
|
+
} from "@supabase/auth-ui-shared";
|
|
7
|
+
import type { SupabaseClient } from "@supabase/supabase-js";
|
|
8
|
+
import { useSearchParams } from "react-router";
|
|
9
|
+
import type { SupabaseAuthenticationConfig } from "../../../../config/config.js";
|
|
10
|
+
import { Heading } from "../../../components/Heading.js";
|
|
11
|
+
|
|
12
|
+
export const SupabaseAuthUI = ({
|
|
13
|
+
client,
|
|
14
|
+
config,
|
|
15
|
+
view = "sign_in",
|
|
16
|
+
}: {
|
|
17
|
+
client: SupabaseClient;
|
|
18
|
+
config: SupabaseAuthenticationConfig;
|
|
19
|
+
view: ViewType;
|
|
20
|
+
}) => {
|
|
21
|
+
const [searchParams] = useSearchParams();
|
|
22
|
+
const redirectTo = searchParams.get("redirectTo");
|
|
23
|
+
const providers = config.provider ? [config.provider] : config.providers;
|
|
24
|
+
const root = config.basePath ?? "/";
|
|
25
|
+
const redirectToAfterSignUp =
|
|
26
|
+
redirectTo ?? config.redirectToAfterSignUp ?? root;
|
|
27
|
+
const redirectToAfterSignIn =
|
|
28
|
+
redirectTo ?? config.redirectToAfterSignIn ?? root;
|
|
29
|
+
const redirectToAfterSignOut =
|
|
30
|
+
redirectTo ?? config.redirectToAfterSignOut ?? root;
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<div className="flex items-center justify-center">
|
|
34
|
+
<div className="max-w-md w-full mt-10">
|
|
35
|
+
<Heading level={1}>
|
|
36
|
+
{view === "sign_in" ? "Sign in" : "Sign up"}
|
|
37
|
+
</Heading>
|
|
38
|
+
<Auth
|
|
39
|
+
view={view}
|
|
40
|
+
redirectToAfterSignIn={redirectToAfterSignIn}
|
|
41
|
+
redirectToAfterSignUp={redirectToAfterSignUp}
|
|
42
|
+
redirectToAfterSignOut={redirectToAfterSignOut}
|
|
43
|
+
supabaseClient={client}
|
|
44
|
+
onlyThirdPartyProviders={config.onlyThirdPartyProviders}
|
|
45
|
+
appearance={{
|
|
46
|
+
theme: ThemeSupa,
|
|
47
|
+
variables: {
|
|
48
|
+
default: {
|
|
49
|
+
colors: {
|
|
50
|
+
dividerBackground: "var(--border)",
|
|
51
|
+
brand: "var(--primary)",
|
|
52
|
+
brandAccent: "hsla(from var(--primary) h s l / 0.8)",
|
|
53
|
+
brandButtonText: "var(--primary-foreground)",
|
|
54
|
+
defaultButtonBorder: "var(--border)",
|
|
55
|
+
inputBorder: "var(--border)",
|
|
56
|
+
inputText: "var(--foreground)",
|
|
57
|
+
inputBorderHover: "var(--accent)",
|
|
58
|
+
defaultButtonBackground: "var(--secondary)",
|
|
59
|
+
defaultButtonBackgroundHover: "var(--accent)",
|
|
60
|
+
},
|
|
61
|
+
radii: {
|
|
62
|
+
borderRadiusButton: "var(--radius)",
|
|
63
|
+
buttonBorderRadius: "var(--radius)",
|
|
64
|
+
inputBorderRadius: "var(--radius)",
|
|
65
|
+
},
|
|
66
|
+
} satisfies ThemeVariables,
|
|
67
|
+
},
|
|
68
|
+
}}
|
|
69
|
+
providers={providers}
|
|
70
|
+
redirectTo={config.redirectToAfterSignIn ?? "/"}
|
|
71
|
+
/>
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
);
|
|
75
|
+
};
|
|
@@ -7,46 +7,38 @@ import {
|
|
|
7
7
|
import type { SupabaseAuthenticationConfig } from "../../../config/config.js";
|
|
8
8
|
import { CoreAuthenticationPlugin } from "../AuthenticationPlugin.js";
|
|
9
9
|
import type {
|
|
10
|
+
AuthActionContext,
|
|
11
|
+
AuthActionOptions,
|
|
10
12
|
AuthenticationPlugin,
|
|
11
13
|
AuthenticationProviderInitializer,
|
|
12
14
|
} from "../authentication.js";
|
|
15
|
+
import { SignOut } from "../components/SignOut.js";
|
|
13
16
|
import { AuthorizationError } from "../errors.js";
|
|
14
17
|
import { type UserProfile, useAuthState } from "../state.js";
|
|
18
|
+
import { SupabaseAuthUI } from "./supabase/SupabaseAuthUI.js";
|
|
15
19
|
|
|
16
20
|
class SupabaseAuthenticationProvider
|
|
17
21
|
extends CoreAuthenticationPlugin
|
|
18
22
|
implements AuthenticationPlugin
|
|
19
23
|
{
|
|
20
24
|
private readonly client: SupabaseClient;
|
|
21
|
-
private readonly
|
|
22
|
-
private readonly
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
constructor({
|
|
28
|
-
supabaseUrl,
|
|
29
|
-
supabaseKey,
|
|
30
|
-
provider,
|
|
31
|
-
redirectToAfterSignUp,
|
|
32
|
-
redirectToAfterSignIn,
|
|
33
|
-
redirectToAfterSignOut,
|
|
34
|
-
basePath,
|
|
35
|
-
}: SupabaseAuthenticationConfig) {
|
|
25
|
+
private readonly providers: Provider[];
|
|
26
|
+
private readonly config: SupabaseAuthenticationConfig;
|
|
27
|
+
|
|
28
|
+
constructor(config: SupabaseAuthenticationConfig) {
|
|
29
|
+
const { provider, providers, supabaseUrl, supabaseKey } = config;
|
|
36
30
|
super();
|
|
37
|
-
this.
|
|
31
|
+
this.providers = providers ?? (provider ? [provider] : []);
|
|
32
|
+
if (this.providers.length === 0) {
|
|
33
|
+
throw new Error("At least one provider must be provided");
|
|
34
|
+
}
|
|
38
35
|
this.client = createClient(supabaseUrl, supabaseKey, {
|
|
39
36
|
auth: {
|
|
40
37
|
autoRefreshToken: true,
|
|
41
38
|
persistSession: true,
|
|
42
39
|
},
|
|
43
40
|
});
|
|
44
|
-
|
|
45
|
-
const root = basePath ?? "/";
|
|
46
|
-
|
|
47
|
-
this.redirectToAfterSignUp = redirectToAfterSignUp ?? root;
|
|
48
|
-
this.redirectToAfterSignIn = redirectToAfterSignIn ?? root;
|
|
49
|
-
this.redirectToAfterSignOut = redirectToAfterSignOut ?? root;
|
|
41
|
+
this.config = config;
|
|
50
42
|
|
|
51
43
|
this.client.auth.onAuthStateChange(async (event, session) => {
|
|
52
44
|
if (session && (event === "SIGNED_IN" || event === "TOKEN_REFRESHED")) {
|
|
@@ -90,31 +82,55 @@ class SupabaseAuthenticationProvider
|
|
|
90
82
|
return request;
|
|
91
83
|
}
|
|
92
84
|
|
|
93
|
-
signUp = async (
|
|
94
|
-
|
|
85
|
+
signUp = async (
|
|
86
|
+
{ navigate }: AuthActionContext,
|
|
87
|
+
{ redirectTo }: AuthActionOptions,
|
|
88
|
+
) => {
|
|
89
|
+
void navigate(
|
|
90
|
+
redirectTo
|
|
91
|
+
? `/signup?redirectTo=${encodeURIComponent(redirectTo)}`
|
|
92
|
+
: `/signup`,
|
|
93
|
+
);
|
|
94
|
+
};
|
|
95
95
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
96
|
+
signIn = async (
|
|
97
|
+
{ navigate }: AuthActionContext,
|
|
98
|
+
{ redirectTo }: AuthActionOptions,
|
|
99
|
+
) => {
|
|
100
|
+
void navigate(
|
|
101
|
+
redirectTo
|
|
102
|
+
? `/signin?redirectTo=${encodeURIComponent(redirectTo)}`
|
|
103
|
+
: `/signin`,
|
|
104
|
+
);
|
|
103
105
|
};
|
|
104
106
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
107
|
+
getRoutes = () => {
|
|
108
|
+
return [
|
|
109
|
+
{
|
|
110
|
+
path: "/signin",
|
|
111
|
+
element: (
|
|
112
|
+
<SupabaseAuthUI
|
|
113
|
+
view="sign_in"
|
|
114
|
+
client={this.client}
|
|
115
|
+
config={this.config}
|
|
116
|
+
/>
|
|
117
|
+
),
|
|
116
118
|
},
|
|
117
|
-
|
|
119
|
+
{
|
|
120
|
+
path: "/signup",
|
|
121
|
+
element: (
|
|
122
|
+
<SupabaseAuthUI
|
|
123
|
+
view="sign_up"
|
|
124
|
+
client={this.client}
|
|
125
|
+
config={this.config}
|
|
126
|
+
/>
|
|
127
|
+
),
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
path: "/signout",
|
|
131
|
+
element: <SignOut />,
|
|
132
|
+
},
|
|
133
|
+
];
|
|
118
134
|
};
|
|
119
135
|
|
|
120
136
|
signOut = async () => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { create
|
|
1
|
+
import { create } from "zustand";
|
|
2
2
|
import { createJSONStorage, persist } from "zustand/middleware";
|
|
3
|
+
import { syncZustandState } from "../util/syncZustandState.js";
|
|
3
4
|
|
|
4
5
|
export interface AuthState<ProviderData = unknown> {
|
|
5
6
|
isAuthenticated: boolean;
|
|
@@ -17,25 +18,6 @@ export interface AuthState<ProviderData = unknown> {
|
|
|
17
18
|
}) => void;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
export type StoreWithPersist<T> = Mutate<
|
|
21
|
-
StoreApi<T>,
|
|
22
|
-
[["zustand/persist", unknown]]
|
|
23
|
-
>;
|
|
24
|
-
|
|
25
|
-
const withStorageDOMEvents = <T>(store: StoreWithPersist<T>) => {
|
|
26
|
-
const storageEventCallback = (e: StorageEvent) => {
|
|
27
|
-
if (e.key === store.persist.getOptions().name && e.newValue) {
|
|
28
|
-
void store.persist.rehydrate();
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
window.addEventListener("storage", storageEventCallback);
|
|
33
|
-
|
|
34
|
-
return () => {
|
|
35
|
-
window.removeEventListener("storage", storageEventCallback);
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
|
|
39
21
|
export const useAuthState = create<AuthState>()(
|
|
40
22
|
persist(
|
|
41
23
|
(set) => ({
|
|
@@ -85,9 +67,7 @@ export const useAuthState = create<AuthState>()(
|
|
|
85
67
|
),
|
|
86
68
|
);
|
|
87
69
|
|
|
88
|
-
|
|
89
|
-
withStorageDOMEvents(useAuthState);
|
|
90
|
-
}
|
|
70
|
+
syncZustandState(useAuthState);
|
|
91
71
|
|
|
92
72
|
export interface UserProfile {
|
|
93
73
|
sub: string;
|
|
@@ -32,7 +32,7 @@ import { ZudokuProvider } from "./context/ZudokuProvider.js";
|
|
|
32
32
|
|
|
33
33
|
let zudokuContext: ZudokuContext | undefined;
|
|
34
34
|
|
|
35
|
-
const
|
|
35
|
+
const ZudokuInner = memo(
|
|
36
36
|
({ children, ...props }: PropsWithChildren<ZudokuContextOptions>) => {
|
|
37
37
|
const components = useMemo(
|
|
38
38
|
() => ({ ...DEFAULT_COMPONENTS, ...props.overrides }),
|
|
@@ -105,12 +105,12 @@ const ZudokoInner = memo(
|
|
|
105
105
|
},
|
|
106
106
|
);
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
ZudokuInner.displayName = "ZudokuInner";
|
|
109
109
|
|
|
110
110
|
const Zudoku = (props: ZudokuContextOptions) => {
|
|
111
111
|
return (
|
|
112
112
|
<ErrorBoundary FallbackComponent={TopLevelError}>
|
|
113
|
-
<
|
|
113
|
+
<ZudokuInner {...props} />
|
|
114
114
|
</ErrorBoundary>
|
|
115
115
|
);
|
|
116
116
|
};
|
|
@@ -85,11 +85,11 @@ export const Toc = ({ entries }: { entries: TocEntry[] }) => {
|
|
|
85
85
|
<ListTreeIcon size={16} />
|
|
86
86
|
On this page
|
|
87
87
|
</div>
|
|
88
|
-
<div className="relative ms-
|
|
89
|
-
<div className="absolute inset-0 end-auto bg-border w-[
|
|
88
|
+
<div className="relative ms-px ps-4">
|
|
89
|
+
<div className="absolute inset-0 end-auto bg-border w-[1.5px]" />
|
|
90
90
|
<div
|
|
91
91
|
className={cn(
|
|
92
|
-
"absolute
|
|
92
|
+
"absolute start-0 -translate-y-1 h-6 w-[2.5px] bg-primary",
|
|
93
93
|
paintedOnce.current &&
|
|
94
94
|
"ease-out [transition:top_150ms,opacity_325ms]",
|
|
95
95
|
)}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { useQuery } from "@tanstack/react-query";
|
|
2
1
|
import { Helmet } from "@zudoku/react-helmet-async";
|
|
3
2
|
import { use } from "react";
|
|
4
3
|
import { matchPath, Outlet, useLocation, useNavigate } from "react-router";
|
|
4
|
+
import { Button } from "zudoku/ui/Button.js";
|
|
5
5
|
import {
|
|
6
6
|
Dialog,
|
|
7
7
|
DialogContent,
|
|
8
8
|
DialogDescription,
|
|
9
|
+
DialogFooter,
|
|
9
10
|
DialogHeader,
|
|
10
11
|
DialogTitle,
|
|
11
12
|
} from "zudoku/ui/Dialog.js";
|
|
@@ -37,17 +38,9 @@ export const RouteGuard = () => {
|
|
|
37
38
|
const needsToSignIn =
|
|
38
39
|
isProtectedRoute && !authCheckFn({ auth, context: zudoku });
|
|
39
40
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
await new Promise((resolve) => setTimeout(resolve, 1200));
|
|
44
|
-
await zudoku.authentication?.signIn({
|
|
45
|
-
redirectTo: latestPath.current,
|
|
46
|
-
});
|
|
47
|
-
return true;
|
|
48
|
-
},
|
|
49
|
-
enabled: typeof window !== "undefined" && needsToSignIn && !auth.isPending,
|
|
50
|
-
});
|
|
41
|
+
if (needsToSignIn && auth.isPending && typeof window !== "undefined") {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
51
44
|
|
|
52
45
|
if (needsToSignIn) {
|
|
53
46
|
return (
|
|
@@ -61,11 +54,38 @@ export const RouteGuard = () => {
|
|
|
61
54
|
>
|
|
62
55
|
<DialogContent>
|
|
63
56
|
<DialogHeader>
|
|
64
|
-
<DialogTitle>
|
|
57
|
+
<DialogTitle>Login to continue</DialogTitle>
|
|
65
58
|
</DialogHeader>
|
|
66
59
|
<DialogDescription>
|
|
67
60
|
Please wait while we log you in.
|
|
68
61
|
</DialogDescription>
|
|
62
|
+
<DialogFooter>
|
|
63
|
+
<Button variant="outline" onClick={() => void navigate(-1)}>
|
|
64
|
+
Cancel
|
|
65
|
+
</Button>
|
|
66
|
+
<div className="w-full"></div>
|
|
67
|
+
<Button
|
|
68
|
+
variant="secondary"
|
|
69
|
+
onClick={() =>
|
|
70
|
+
void zudoku.authentication?.signUp(
|
|
71
|
+
{ navigate },
|
|
72
|
+
{ redirectTo: latestPath.current },
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
>
|
|
76
|
+
Register
|
|
77
|
+
</Button>
|
|
78
|
+
<Button
|
|
79
|
+
onClick={() =>
|
|
80
|
+
void zudoku.authentication?.signIn(
|
|
81
|
+
{ navigate },
|
|
82
|
+
{ redirectTo: latestPath.current },
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
>
|
|
86
|
+
Login{" "}
|
|
87
|
+
</Button>
|
|
88
|
+
</DialogFooter>
|
|
69
89
|
</DialogContent>
|
|
70
90
|
</Dialog>
|
|
71
91
|
);
|
|
@@ -129,6 +129,7 @@ export class ZudokuContext {
|
|
|
129
129
|
public meta: ZudokuContextOptions["metadata"];
|
|
130
130
|
public site: ZudokuContextOptions["site"];
|
|
131
131
|
public readonly authentication?: ZudokuContextOptions["authentication"];
|
|
132
|
+
public readonly getAuthState: () => AuthState;
|
|
132
133
|
public readonly queryClient: QueryClient;
|
|
133
134
|
public readonly options: ZudokuContextOptions;
|
|
134
135
|
private readonly navigationPlugins: NavigationPlugin[];
|
|
@@ -156,6 +157,8 @@ export class ZudokuContext {
|
|
|
156
157
|
this.navigation = options.navigation ?? [];
|
|
157
158
|
this.navigationPlugins = this.plugins.filter(isNavigationPlugin);
|
|
158
159
|
this.authentication = this.plugins.find(isAuthenticationPlugin);
|
|
160
|
+
this.getAuthState = useAuthState.getState;
|
|
161
|
+
|
|
159
162
|
this.meta = options.metadata;
|
|
160
163
|
this.site = options.site;
|
|
161
164
|
this.plugins.forEach((plugin) => {
|