zudoku 0.17.0 → 0.18.1
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/dist/app/demo.js +0 -2
- package/dist/app/demo.js.map +1 -1
- package/dist/app/entry.client.js +14 -0
- package/dist/app/entry.client.js.map +1 -1
- package/dist/app/entry.server.js +5 -4
- package/dist/app/entry.server.js.map +1 -1
- package/dist/app/standalone.js +0 -2
- package/dist/app/standalone.js.map +1 -1
- package/dist/codegen.d.ts +3 -0
- package/dist/codegen.js +45 -0
- package/dist/codegen.js.map +1 -0
- package/dist/config/validators/InputSidebarSchema.d.ts +10 -10
- package/dist/config/validators/validate.d.ts +74 -74
- package/dist/lib/authentication/hook.d.ts +5 -4
- package/dist/lib/authentication/hook.js +1 -3
- package/dist/lib/authentication/hook.js.map +1 -1
- package/dist/lib/authentication/providers/auth0.js +11 -11
- package/dist/lib/authentication/providers/auth0.js.map +1 -1
- package/dist/lib/authentication/providers/openid.d.ts +0 -1
- package/dist/lib/authentication/providers/openid.js +11 -26
- package/dist/lib/authentication/providers/openid.js.map +1 -1
- package/dist/lib/authentication/state.d.ts +25 -4
- package/dist/lib/authentication/state.js +28 -5
- package/dist/lib/authentication/state.js.map +1 -1
- package/dist/lib/components/Bootstrap.d.ts +3 -1
- package/dist/lib/components/Bootstrap.js +10 -4
- package/dist/lib/components/Bootstrap.js.map +1 -1
- package/dist/lib/components/DeveloperHint.js +2 -1
- package/dist/lib/components/DeveloperHint.js.map +1 -1
- package/dist/lib/components/Header.js +3 -7
- package/dist/lib/components/Header.js.map +1 -1
- package/dist/lib/components/Heading.d.ts +1 -1
- package/dist/lib/components/Layout.js +11 -3
- package/dist/lib/components/Layout.js.map +1 -1
- package/dist/lib/components/MobileTopNavigation.js +6 -7
- package/dist/lib/components/MobileTopNavigation.js.map +1 -1
- package/dist/lib/components/SyntaxHighlight.js +16 -12
- package/dist/lib/components/SyntaxHighlight.js.map +1 -1
- package/dist/lib/components/ThemeSwitch.d.ts +1 -0
- package/dist/lib/components/ThemeSwitch.js +13 -0
- package/dist/lib/components/ThemeSwitch.js.map +1 -0
- package/dist/lib/components/TopNavigation.d.ts +2 -0
- package/dist/lib/components/TopNavigation.js +13 -7
- package/dist/lib/components/TopNavigation.js.map +1 -1
- package/dist/lib/components/Zudoku.js +4 -5
- package/dist/lib/components/Zudoku.js.map +1 -1
- package/dist/lib/components/context/ZudokuContext.d.ts +3 -3
- package/dist/lib/components/context/ZudokuContext.js +7 -12
- package/dist/lib/components/context/ZudokuContext.js.map +1 -1
- package/dist/lib/components/index.d.ts +14 -3
- package/dist/lib/components/navigation/Sidebar.js +1 -1
- package/dist/lib/components/navigation/Sidebar.js.map +1 -1
- package/dist/lib/components/navigation/utils.js +2 -2
- package/dist/lib/components/navigation/utils.js.map +1 -1
- package/dist/lib/core/ZudokuContext.d.ts +0 -4
- package/dist/lib/core/ZudokuContext.js +0 -5
- package/dist/lib/core/ZudokuContext.js.map +1 -1
- package/dist/lib/errors/ErrorAlert.js +1 -1
- package/dist/lib/errors/ErrorAlert.js.map +1 -1
- package/dist/lib/plugins/openapi/ColorizedParam.js +13 -9
- package/dist/lib/plugins/openapi/ColorizedParam.js.map +1 -1
- package/dist/lib/plugins/openapi/Endpoint.d.ts +1 -1
- package/dist/lib/plugins/openapi/Endpoint.js +5 -9
- package/dist/lib/plugins/openapi/Endpoint.js.map +1 -1
- package/dist/lib/plugins/openapi/OperationList.d.ts +2 -2
- package/dist/lib/plugins/openapi/OperationList.js +6 -21
- package/dist/lib/plugins/openapi/OperationList.js.map +1 -1
- package/dist/lib/plugins/openapi/Route.d.ts +4 -4
- package/dist/lib/plugins/openapi/Route.js +2 -4
- package/dist/lib/plugins/openapi/Route.js.map +1 -1
- package/dist/lib/plugins/openapi/Sidecar.d.ts +1 -1
- package/dist/lib/plugins/openapi/Sidecar.js +8 -11
- package/dist/lib/plugins/openapi/Sidecar.js.map +1 -1
- package/dist/lib/plugins/openapi/client/GraphQLClient.d.ts +8 -0
- package/dist/lib/plugins/openapi/client/GraphQLClient.js +102 -0
- package/dist/lib/plugins/openapi/client/GraphQLClient.js.map +1 -0
- package/dist/lib/plugins/openapi/client/GraphQLContext.d.ts +7 -0
- package/dist/lib/plugins/openapi/client/GraphQLContext.js +5 -0
- package/dist/lib/plugins/openapi/client/GraphQLContext.js.map +1 -0
- package/dist/lib/plugins/openapi/client/createServer.d.ts +1 -0
- package/dist/lib/plugins/openapi/client/useCreateQuery.d.ts +5 -0
- package/dist/lib/plugins/openapi/client/useCreateQuery.js +13 -0
- package/dist/lib/plugins/openapi/client/useCreateQuery.js.map +1 -0
- package/dist/lib/plugins/openapi/client/worker.d.ts +4 -1
- package/dist/lib/plugins/openapi/client/worker.js +23 -14
- package/dist/lib/plugins/openapi/client/worker.js.map +1 -1
- package/dist/lib/plugins/openapi/graphql/fragment-masking.d.ts +3 -3
- package/dist/lib/plugins/openapi/graphql/fragment-masking.js +3 -4
- package/dist/lib/plugins/openapi/graphql/fragment-masking.js.map +1 -1
- package/dist/lib/plugins/openapi/graphql/gql.d.ts +5 -52
- package/dist/lib/plugins/openapi/graphql/gql.js +2 -1
- package/dist/lib/plugins/openapi/graphql/gql.js.map +1 -1
- package/dist/lib/plugins/openapi/graphql/graphql.d.ts +134 -9
- package/dist/lib/plugins/openapi/graphql/graphql.js +194 -778
- package/dist/lib/plugins/openapi/graphql/graphql.js.map +1 -1
- package/dist/lib/plugins/openapi/index.js +40 -53
- package/dist/lib/plugins/openapi/index.js.map +1 -1
- package/dist/lib/plugins/openapi/schema/SchemaView.js.map +1 -1
- package/dist/lib/plugins/openapi-worker.d.ts +1 -1
- package/dist/lib/plugins/openapi-worker.js +7 -1
- package/dist/lib/plugins/openapi-worker.js.map +1 -1
- package/dist/lib/util/MdxComponents.d.ts +1 -1
- package/dist/vite/config.js +0 -1
- package/dist/vite/config.js.map +1 -1
- package/dist/vite/html.js +0 -2
- package/dist/vite/html.js.map +1 -1
- package/dist/vite/plugin-component.js +1 -1
- package/dist/vite/plugin-component.js.map +1 -1
- package/dist/vite/plugin-mdx.js +3 -2
- package/dist/vite/plugin-mdx.js.map +1 -1
- package/dist/vite/plugin.js +0 -2
- package/dist/vite/plugin.js.map +1 -1
- package/dist/vite/remarkStaticGeneration.d.ts +3 -0
- package/dist/vite/remarkStaticGeneration.js +125 -0
- package/dist/vite/remarkStaticGeneration.js.map +1 -0
- package/lib/{AnchorLink-DYbUOP9U.js → AnchorLink-CDlhr8gL.js} +11 -10
- package/lib/{AnchorLink-DYbUOP9U.js.map → AnchorLink-CDlhr8gL.js.map} +1 -1
- package/lib/{AuthenticationPlugin-bqGAKfot.js → AuthenticationPlugin-DeGDVa1r.js} +6 -5
- package/lib/{AuthenticationPlugin-bqGAKfot.js.map → AuthenticationPlugin-DeGDVa1r.js.map} +1 -1
- package/lib/{Spinner-ChOGyPls.js → Button-jK0EsymC.js} +12 -15
- package/lib/Button-jK0EsymC.js.map +1 -0
- package/lib/Markdown-ievDDhFT.js +15192 -0
- package/lib/Markdown-ievDDhFT.js.map +1 -0
- package/lib/{MdxPage-DRKqyn2b.js → MdxPage-Bwn-VSsH.js} +5 -5
- package/lib/{MdxPage-DRKqyn2b.js.map → MdxPage-Bwn-VSsH.js.map} +1 -1
- package/lib/OperationList-BwBl1xrD.js +4691 -0
- package/lib/OperationList-BwBl1xrD.js.map +1 -0
- package/lib/Route-DlG_HTMu.js +11 -0
- package/lib/Route-DlG_HTMu.js.map +1 -0
- package/lib/{Select-DYKDahHt.js → Select-O9ZM3ZgX.js} +7 -7
- package/lib/Select-O9ZM3ZgX.js.map +1 -0
- package/lib/SidebarBadge-DxFJcJ6V.js +51 -0
- package/lib/SidebarBadge-DxFJcJ6V.js.map +1 -0
- package/lib/SlotletProvider-DyomlzGx.js +252 -0
- package/lib/SlotletProvider-DyomlzGx.js.map +1 -0
- package/lib/Spinner-3cQDBVGr.js +7 -0
- package/lib/Spinner-3cQDBVGr.js.map +1 -0
- package/lib/SyntaxHighlight-DkLOsjHS.js +2983 -0
- package/lib/SyntaxHighlight-DkLOsjHS.js.map +1 -0
- package/lib/assets/{worker-YA-aCP3P.js → worker-CPsGZsve.js} +24 -22
- package/lib/assets/{worker-YA-aCP3P.js.map → worker-CPsGZsve.js.map} +1 -1
- package/lib/context-D1nXWxm7.js +22 -0
- package/lib/context-D1nXWxm7.js.map +1 -0
- package/lib/createServer-DK-g7kbB.js +16089 -0
- package/lib/createServer-DK-g7kbB.js.map +1 -0
- package/lib/{hook-CjQERPa7.js → hook-hEqe7fPB.js} +12 -14
- package/lib/hook-hEqe7fPB.js.map +1 -0
- package/lib/index-Czzd9rjU.js +899 -0
- package/lib/index-Czzd9rjU.js.map +1 -0
- package/lib/index-DNxQ_rCt.js +1273 -0
- package/lib/index-DNxQ_rCt.js.map +1 -0
- package/lib/index-Yn8c3UWE.js +921 -0
- package/lib/index-Yn8c3UWE.js.map +1 -0
- package/lib/{router-BsfSoK2j.js → router-lfyopgBI.js} +23 -23
- package/lib/{router-BsfSoK2j.js.map → router-lfyopgBI.js.map} +1 -1
- package/lib/state-tsXBLONe.js +203 -0
- package/lib/state-tsXBLONe.js.map +1 -0
- package/lib/ui/ActionButton.js +11 -10
- package/lib/ui/ActionButton.js.map +1 -1
- package/lib/useExposedProps-CTPtylCV.js +10 -0
- package/lib/{useExposedProps-BxyHjPNN.js.map → useExposedProps-CTPtylCV.js.map} +1 -1
- package/lib/{utils-DNAltzXc.js → utils-DcpDOncX.js} +197 -202
- package/lib/utils-DcpDOncX.js.map +1 -0
- package/lib/zudoku.auth-auth0.js +24 -18
- package/lib/zudoku.auth-auth0.js.map +1 -1
- package/lib/zudoku.auth-clerk.js +2 -2
- package/lib/zudoku.auth-openid.js +124 -138
- package/lib/zudoku.auth-openid.js.map +1 -1
- package/lib/zudoku.components.js +1128 -992
- package/lib/zudoku.components.js.map +1 -1
- package/lib/zudoku.openapi-worker.js +10 -16346
- package/lib/zudoku.openapi-worker.js.map +1 -1
- package/lib/zudoku.plugin-api-keys.js +18 -18
- package/lib/zudoku.plugin-custom-pages.js +2 -2
- package/lib/zudoku.plugin-markdown.js +1 -1
- package/lib/zudoku.plugin-openapi.js +5 -9
- package/lib/zudoku.plugin-openapi.js.map +1 -1
- package/lib/zudoku.plugin-redirect.js +1 -1
- package/package.json +14 -4
- package/src/app/demo.tsx +0 -3
- package/src/app/entry.client.tsx +14 -0
- package/src/app/entry.server.tsx +59 -57
- package/src/app/standalone.tsx +0 -3
- package/src/lib/authentication/hook.ts +1 -3
- package/src/lib/authentication/providers/auth0.tsx +16 -11
- package/src/lib/authentication/providers/openid.tsx +12 -30
- package/src/lib/authentication/state.ts +44 -10
- package/src/lib/components/Bootstrap.tsx +36 -14
- package/src/lib/components/DeveloperHint.tsx +6 -1
- package/src/lib/components/Header.tsx +31 -42
- package/src/lib/components/Layout.tsx +48 -36
- package/src/lib/components/MobileTopNavigation.tsx +15 -18
- package/src/lib/components/SyntaxHighlight.tsx +81 -46
- package/src/lib/components/ThemeSwitch.tsx +26 -0
- package/src/lib/components/TopNavigation.tsx +27 -19
- package/src/lib/components/Zudoku.tsx +5 -10
- package/src/lib/components/context/ZudokuContext.ts +8 -13
- package/src/lib/components/navigation/Sidebar.tsx +3 -3
- package/src/lib/components/navigation/utils.ts +2 -2
- package/src/lib/core/ZudokuContext.ts +0 -8
- package/src/lib/errors/ErrorAlert.tsx +2 -1
- package/src/lib/plugins/openapi/ColorizedParam.tsx +23 -14
- package/src/lib/plugins/openapi/Endpoint.tsx +5 -10
- package/src/lib/plugins/openapi/OperationList.tsx +5 -40
- package/src/lib/plugins/openapi/Route.tsx +11 -12
- package/src/lib/plugins/openapi/Sidecar.tsx +10 -13
- package/src/lib/plugins/openapi/client/GraphQLClient.tsx +140 -0
- package/src/lib/plugins/openapi/client/GraphQLContext.tsx +16 -0
- package/src/lib/plugins/openapi/client/createServer.ts +2 -0
- package/src/lib/plugins/openapi/client/useCreateQuery.ts +18 -0
- package/src/lib/plugins/openapi/client/worker.ts +38 -24
- package/src/lib/plugins/openapi/graphql/fragment-masking.ts +11 -18
- package/src/lib/plugins/openapi/graphql/gql.ts +7 -25
- package/src/lib/plugins/openapi/graphql/graphql.ts +351 -782
- package/src/lib/plugins/openapi/index.tsx +40 -63
- package/src/lib/plugins/openapi/schema/SchemaView.tsx +1 -1
- package/src/lib/plugins/openapi-worker.ts +11 -1
- package/dist/lib/components/context/ThemeContext.d.ts +0 -2
- package/dist/lib/components/context/ThemeContext.js +0 -7
- package/dist/lib/components/context/ThemeContext.js.map +0 -1
- package/dist/lib/components/context/ThemeProvider.d.ts +0 -4
- package/dist/lib/components/context/ThemeProvider.js +0 -23
- package/dist/lib/components/context/ThemeProvider.js.map +0 -1
- package/dist/lib/plugins/openapi/client/createMemoryClient.d.ts +0 -9
- package/dist/lib/plugins/openapi/client/createMemoryClient.js +0 -54
- package/dist/lib/plugins/openapi/client/createMemoryClient.js.map +0 -1
- package/dist/lib/plugins/openapi/client/createWorkerClient.d.ts +0 -10
- package/dist/lib/plugins/openapi/client/createWorkerClient.js +0 -62
- package/dist/lib/plugins/openapi/client/createWorkerClient.js.map +0 -1
- package/dist/lib/plugins/openapi/client/interfaces.d.ts +0 -4
- package/dist/lib/plugins/openapi/client/interfaces.js +0 -2
- package/dist/lib/plugins/openapi/client/interfaces.js.map +0 -1
- package/dist/lib/themeToggle.d.ts +0 -1
- package/dist/lib/themeToggle.js +0 -7
- package/dist/lib/themeToggle.js.map +0 -1
- package/dist/lib/util/createWaitForNotify.d.ts +0 -1
- package/dist/lib/util/createWaitForNotify.js +0 -15
- package/dist/lib/util/createWaitForNotify.js.map +0 -1
- package/dist/vite/plugin-html-transform.d.ts +0 -2
- package/dist/vite/plugin-html-transform.js +0 -15
- package/dist/vite/plugin-html-transform.js.map +0 -1
- package/lib/DeveloperHint-DHdLXGHA.js +0 -16
- package/lib/DeveloperHint-DHdLXGHA.js.map +0 -1
- package/lib/Markdown-D6UxMbZm.js +0 -18059
- package/lib/Markdown-D6UxMbZm.js.map +0 -1
- package/lib/OperationList-BHUBGM0c.js +0 -621
- package/lib/OperationList-BHUBGM0c.js.map +0 -1
- package/lib/Route-B0XuN1oC.js +0 -13
- package/lib/Route-B0XuN1oC.js.map +0 -1
- package/lib/Select-DYKDahHt.js.map +0 -1
- package/lib/SidebarBadge-Bbt92M5K.js +0 -38
- package/lib/SidebarBadge-Bbt92M5K.js.map +0 -1
- package/lib/SlotletProvider-mhjLPG44.js +0 -241
- package/lib/SlotletProvider-mhjLPG44.js.map +0 -1
- package/lib/Spinner-ChOGyPls.js.map +0 -1
- package/lib/StaggeredRender-DDHSzQKE.js +0 -17
- package/lib/StaggeredRender-DDHSzQKE.js.map +0 -1
- package/lib/hook-CjQERPa7.js.map +0 -1
- package/lib/index-BRg5pi5D.js +0 -5902
- package/lib/index-BRg5pi5D.js.map +0 -1
- package/lib/index-DM9hrcCG.js +0 -1783
- package/lib/index-DM9hrcCG.js.map +0 -1
- package/lib/state-BsPrOUAh.js +0 -252
- package/lib/state-BsPrOUAh.js.map +0 -1
- package/lib/urql-core-35Qt_U4i.js +0 -1511
- package/lib/urql-core-35Qt_U4i.js.map +0 -1
- package/lib/useExposedProps-BxyHjPNN.js +0 -9
- package/lib/utils-DNAltzXc.js.map +0 -1
- package/src/lib/components/context/ThemeContext.tsx +0 -8
- package/src/lib/components/context/ThemeProvider.tsx +0 -27
- package/src/lib/plugins/openapi/client/createMemoryClient.ts +0 -65
- package/src/lib/plugins/openapi/client/createWorkerClient.ts +0 -79
- package/src/lib/plugins/openapi/client/interfaces.ts +0 -5
- package/src/lib/themeToggle.ts +0 -7
- package/src/lib/util/createWaitForNotify.ts +0 -18
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { j as e } from "./jsx-runtime-B6kdoens.js";
|
|
2
|
-
import { S as m, R as
|
|
2
|
+
import { D as g, S as m, R as f } from "./SlotletProvider-DyomlzGx.js";
|
|
3
3
|
import { i as c } from "./invariant-Caa8-XvF.js";
|
|
4
|
-
import { u as d, S as
|
|
5
|
-
import { a as
|
|
6
|
-
import {
|
|
7
|
-
import { u as h, d as
|
|
4
|
+
import { u as d, S as j, a as v, b as w, c as b, d as k, e as x } from "./Select-O9ZM3ZgX.js";
|
|
5
|
+
import { a as K } from "./index.esm-C5mr_sKO.js";
|
|
6
|
+
import { L as u } from "./index-Yn8c3UWE.js";
|
|
7
|
+
import { u as h, d as N, g as I } from "./utils-DcpDOncX.js";
|
|
8
8
|
import { Button as l } from "./ui/Button.js";
|
|
9
|
-
import { Input as
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
9
|
+
import { Input as S } from "./ui/Input.js";
|
|
10
|
+
import { a as A, O as C } from "./index-Czzd9rjU.js";
|
|
11
|
+
import { u as E } from "./hook-hEqe7fPB.js";
|
|
12
12
|
import { RotateCwIcon as P, TrashIcon as D, EyeOffIcon as R, EyeIcon as q, CheckIcon as O, CopyIcon as z } from "lucide-react";
|
|
13
13
|
import { useState as p } from "react";
|
|
14
14
|
import { c as T } from "./cn-BmFQLtkS.js";
|
|
15
15
|
const F = ({ service: t }) => {
|
|
16
|
-
const s = h(), r =
|
|
16
|
+
const s = h(), r = A(), n = K({
|
|
17
17
|
defaultValues: {
|
|
18
18
|
expiresOn: "30"
|
|
19
19
|
}
|
|
@@ -37,16 +37,16 @@ const F = ({ service: t }) => {
|
|
|
37
37
|
onSubmit: n.handleSubmit((a) => o.mutate(a)),
|
|
38
38
|
children: /* @__PURE__ */ e.jsxs("div", { className: "flex gap-2 flex-col", children: [
|
|
39
39
|
"Note",
|
|
40
|
-
/* @__PURE__ */ e.jsx(
|
|
40
|
+
/* @__PURE__ */ e.jsx(S, { ...n.register("description") }),
|
|
41
41
|
"Expiration",
|
|
42
42
|
/* @__PURE__ */ e.jsxs(
|
|
43
|
-
|
|
43
|
+
j,
|
|
44
44
|
{
|
|
45
45
|
onValueChange: (a) => n.setValue("expiresOn", a),
|
|
46
46
|
defaultValue: n.getValues("expiresOn"),
|
|
47
47
|
children: [
|
|
48
|
-
/* @__PURE__ */ e.jsx(
|
|
49
|
-
/* @__PURE__ */ e.jsx(
|
|
48
|
+
/* @__PURE__ */ e.jsx(v, { children: /* @__PURE__ */ e.jsx(w, {}) }),
|
|
49
|
+
/* @__PURE__ */ e.jsx(b, { children: /* @__PURE__ */ e.jsxs(k, { children: [
|
|
50
50
|
[7, 30, 60, 90].map((a) => /* @__PURE__ */ e.jsxs(x, { value: String(a), children: [
|
|
51
51
|
a,
|
|
52
52
|
" days"
|
|
@@ -68,17 +68,17 @@ const F = ({ service: t }) => {
|
|
|
68
68
|
const s = /* @__PURE__ */ new Date();
|
|
69
69
|
return s.setDate(s.getDate() + t), s.toISOString();
|
|
70
70
|
}, V = () => {
|
|
71
|
-
const t =
|
|
72
|
-
return t.isAuthEnabled && t.isPending ? null : t.isAuthenticated ? /* @__PURE__ */ e.jsx(
|
|
71
|
+
const t = E();
|
|
72
|
+
return t.isAuthEnabled && t.isPending ? null : t.isAuthenticated ? /* @__PURE__ */ e.jsx(C, {}) : t.isAuthEnabled ? /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col justify-center gap-2 items-center h-1/2", children: [
|
|
73
73
|
"Please login first to view this page",
|
|
74
74
|
/* @__PURE__ */ e.jsx(l, { onClick: () => t.login(), children: "Login" })
|
|
75
|
-
] }) : /* @__PURE__ */ e.jsx("div", { className: "flex flex-col justify-center gap-2 items-center h-1/2", children: /* @__PURE__ */ e.jsxs(
|
|
75
|
+
] }) : /* @__PURE__ */ e.jsx("div", { className: "flex flex-col justify-center gap-2 items-center h-1/2", children: /* @__PURE__ */ e.jsxs(g, { className: "max-w-[600px]", children: [
|
|
76
76
|
"Authentication needs to be enabled for API keys to work. Enable it in your Zudoku configuration under ",
|
|
77
77
|
/* @__PURE__ */ e.jsx("code", { children: "authentication" }),
|
|
78
78
|
"."
|
|
79
79
|
] }) });
|
|
80
80
|
}, M = ({ service: t }) => {
|
|
81
|
-
const s = h(), r =
|
|
81
|
+
const s = h(), r = N(), { data: n } = I({
|
|
82
82
|
queryFn: () => t.getKeys(s),
|
|
83
83
|
queryKey: ["api-keys"],
|
|
84
84
|
retry: !1
|
|
@@ -259,7 +259,7 @@ const F = ({ service: t }) => {
|
|
|
259
259
|
getRoutes: () => [
|
|
260
260
|
{
|
|
261
261
|
element: /* @__PURE__ */ e.jsx(V, {}),
|
|
262
|
-
errorElement: /* @__PURE__ */ e.jsx(
|
|
262
|
+
errorElement: /* @__PURE__ */ e.jsx(f, {}),
|
|
263
263
|
children: [
|
|
264
264
|
{
|
|
265
265
|
path: "/settings/api-keys",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { j as o } from "./jsx-runtime-B6kdoens.js";
|
|
2
2
|
import a from "react";
|
|
3
|
-
import { P as n } from "./Markdown-
|
|
3
|
+
import { P as n } from "./Markdown-ievDDhFT.js";
|
|
4
4
|
import { c } from "./cn-BmFQLtkS.js";
|
|
5
|
-
import { u as p } from "./useExposedProps-
|
|
5
|
+
import { u as p } from "./useExposedProps-CTPtylCV.js";
|
|
6
6
|
const u = ({
|
|
7
7
|
element: t,
|
|
8
8
|
render: s,
|
|
@@ -74,7 +74,7 @@ const C = (n) => ({
|
|
|
74
74
|
const h = {
|
|
75
75
|
path: r,
|
|
76
76
|
lazy: async () => {
|
|
77
|
-
const { MdxPage: l } = await import("./MdxPage-
|
|
77
|
+
const { MdxPage: l } = await import("./MdxPage-Bwn-VSsH.js"), { default: p, ...g } = await a();
|
|
78
78
|
return {
|
|
79
79
|
element: /* @__PURE__ */ P.jsx(
|
|
80
80
|
l,
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import "./jsx-runtime-B6kdoens.js";
|
|
2
|
-
import { o as
|
|
3
|
-
import "./utils-
|
|
2
|
+
import { o as a } from "./index-DNxQ_rCt.js";
|
|
3
|
+
import "./utils-DcpDOncX.js";
|
|
4
4
|
import "lucide-react";
|
|
5
|
-
import "
|
|
6
|
-
import "./hook-CjQERPa7.js";
|
|
7
|
-
import "./Markdown-D6UxMbZm.js";
|
|
5
|
+
import "./hook-hEqe7fPB.js";
|
|
8
6
|
import "./ui/Button.js";
|
|
9
|
-
import "./
|
|
10
|
-
import "./router-BsfSoK2j.js";
|
|
11
|
-
import "./index-DM9hrcCG.js";
|
|
7
|
+
import "./router-lfyopgBI.js";
|
|
12
8
|
export {
|
|
13
|
-
|
|
9
|
+
a as openApiPlugin
|
|
14
10
|
};
|
|
15
11
|
//# sourceMappingURL=zudoku.plugin-openapi.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zudoku.plugin-openapi.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"zudoku.plugin-openapi.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zudoku",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"homepage": "https://zudoku.dev",
|
|
6
6
|
"repository": {
|
|
@@ -137,11 +137,11 @@
|
|
|
137
137
|
"@sindresorhus/slugify": "2.2.1",
|
|
138
138
|
"@stefanprobst/rehype-extract-toc": "2.2.0",
|
|
139
139
|
"@tailwindcss/typography": "0.5.15",
|
|
140
|
-
"@tanstack/react-query": "5.
|
|
140
|
+
"@tanstack/react-query": "5.61.0",
|
|
141
141
|
"@types/react": "18.3.11",
|
|
142
142
|
"@types/react-dom": "18.3.1",
|
|
143
143
|
"@vitejs/plugin-react": "4.3.1",
|
|
144
|
-
"@zudoku/config": "0.
|
|
144
|
+
"@zudoku/config": "0.18.1",
|
|
145
145
|
"@zudoku/httpsnippet": "10.0.9",
|
|
146
146
|
"@zudoku/react-helmet-async": "2.0.4",
|
|
147
147
|
"autoprefixer": "10.4.20",
|
|
@@ -151,6 +151,7 @@
|
|
|
151
151
|
"cmdk": "1.0.4",
|
|
152
152
|
"dotenv": "16.4.5",
|
|
153
153
|
"embla-carousel-react": "8.3.1",
|
|
154
|
+
"estree-util-value-to-estree": "3.2.1",
|
|
154
155
|
"express": "4.21.1",
|
|
155
156
|
"glob": "11.0.0",
|
|
156
157
|
"graphql": "16.9.0",
|
|
@@ -161,6 +162,7 @@
|
|
|
161
162
|
"loglevel": "1.9.2",
|
|
162
163
|
"lru-cache": "11.0.1",
|
|
163
164
|
"lucide-react": "0.452.0",
|
|
165
|
+
"next-themes": "0.4.3",
|
|
164
166
|
"oauth4webapi": "2.17.0",
|
|
165
167
|
"object-hash": "3.0.0",
|
|
166
168
|
"openapi-types": "12.1.3",
|
|
@@ -185,6 +187,7 @@
|
|
|
185
187
|
"rollup": "4.24.0",
|
|
186
188
|
"semver": "7.6.3",
|
|
187
189
|
"sitemap": "8.0.0",
|
|
190
|
+
"spin-delay": "2.0.1",
|
|
188
191
|
"strip-ansi": "7.1.0",
|
|
189
192
|
"tailwind-merge": "2.5.4",
|
|
190
193
|
"tailwindcss": "3.4.13",
|
|
@@ -192,6 +195,7 @@
|
|
|
192
195
|
"unist-util-visit": "5.0.0",
|
|
193
196
|
"urql": "4.1.0",
|
|
194
197
|
"vaul": "1.1.0",
|
|
198
|
+
"vfile": "6.0.3",
|
|
195
199
|
"vite": "5.4.9",
|
|
196
200
|
"yaml": "2.6.0",
|
|
197
201
|
"yargs": "17.7.2",
|
|
@@ -200,19 +204,24 @@
|
|
|
200
204
|
"zustand": "5.0.0"
|
|
201
205
|
},
|
|
202
206
|
"devDependencies": {
|
|
207
|
+
"@graphql-codegen/cli": "5.0.3",
|
|
208
|
+
"@graphql-codegen/client-preset": "4.5.0",
|
|
209
|
+
"@types/estree": "1.0.6",
|
|
203
210
|
"@types/express": "5.0.0",
|
|
204
211
|
"@types/har-format": "1.2.15",
|
|
205
212
|
"@types/json-schema": "7.0.15",
|
|
213
|
+
"@types/mdast": "4.0.4",
|
|
206
214
|
"@types/mdx": "2.0.13",
|
|
207
215
|
"@types/node": "20.16.11",
|
|
208
216
|
"@types/object-hash": "3.0.6",
|
|
209
217
|
"@types/react-is": "18.3.0",
|
|
210
218
|
"@types/semver": "7.5.8",
|
|
211
219
|
"@types/yargs": "17.0.33",
|
|
220
|
+
"mdast-util-mdx": "3.0.0",
|
|
212
221
|
"react": "18.3.1",
|
|
213
222
|
"react-dom": "18.3.1",
|
|
214
223
|
"rollup-plugin-visualizer": "5.12.0",
|
|
215
|
-
"typescript": "5.
|
|
224
|
+
"typescript": "5.7.2"
|
|
216
225
|
},
|
|
217
226
|
"peerDependencies": {
|
|
218
227
|
"react": ">=18",
|
|
@@ -229,6 +238,7 @@
|
|
|
229
238
|
"build:standalone:html": "cp ./src/app/standalone.html ./standalone/standalone.html && cp ./src/app/demo.html ./standalone/demo.html && cp ./src/app/demo-cdn.html ./standalone/index.html",
|
|
230
239
|
"hack:fix-worker-paths": "node ./scripts/hack-worker.mjs",
|
|
231
240
|
"clean": "tsc --build --clean",
|
|
241
|
+
"codegen": "graphql-codegen --config ./src/codegen.ts",
|
|
232
242
|
"test": "node --test --enable-source-maps"
|
|
233
243
|
},
|
|
234
244
|
"module": "./dist/index.js",
|
package/src/app/demo.tsx
CHANGED
|
@@ -5,7 +5,6 @@ import { Bootstrap } from "zudoku/components";
|
|
|
5
5
|
import type { ZudokuConfig } from "../config/validators/validate.js";
|
|
6
6
|
import DemoAnnouncement from "../lib/demo/DemoAnnouncement.js";
|
|
7
7
|
import { openApiPlugin } from "../lib/plugins/openapi/index.js";
|
|
8
|
-
import { themeToggle } from "../lib/themeToggle.js";
|
|
9
8
|
import "../lib/util/logInit.js";
|
|
10
9
|
import "./main.css";
|
|
11
10
|
import { getRoutesByConfig } from "./main.js";
|
|
@@ -18,8 +17,6 @@ if (!apiUrl) {
|
|
|
18
17
|
);
|
|
19
18
|
}
|
|
20
19
|
|
|
21
|
-
themeToggle();
|
|
22
|
-
|
|
23
20
|
logger.info(`API URL: ${apiUrl}`);
|
|
24
21
|
|
|
25
22
|
const root =
|
package/src/app/entry.client.tsx
CHANGED
|
@@ -38,6 +38,13 @@ async function hydrateLazyRoutes(routes: RouteObject[]) {
|
|
|
38
38
|
function render(routes: RouteObject[]) {
|
|
39
39
|
const router = createBrowserRouter(routes, {
|
|
40
40
|
basename: config.basePath,
|
|
41
|
+
future: {
|
|
42
|
+
v7_relativeSplatPath: true,
|
|
43
|
+
v7_fetcherPersist: true,
|
|
44
|
+
v7_partialHydration: true,
|
|
45
|
+
v7_skipActionErrorRevalidation: true,
|
|
46
|
+
v7_normalizeFormMethod: true,
|
|
47
|
+
},
|
|
41
48
|
});
|
|
42
49
|
createRoot(root).render(<Bootstrap router={router} />);
|
|
43
50
|
}
|
|
@@ -46,6 +53,13 @@ async function hydrate(routes: RouteObject[]) {
|
|
|
46
53
|
await hydrateLazyRoutes(routes);
|
|
47
54
|
const router = createBrowserRouter(routes, {
|
|
48
55
|
basename: config.basePath,
|
|
56
|
+
future: {
|
|
57
|
+
v7_relativeSplatPath: true,
|
|
58
|
+
v7_fetcherPersist: true,
|
|
59
|
+
v7_partialHydration: true,
|
|
60
|
+
v7_skipActionErrorRevalidation: true,
|
|
61
|
+
v7_normalizeFormMethod: true,
|
|
62
|
+
},
|
|
49
63
|
});
|
|
50
64
|
|
|
51
65
|
hydrateRoot(root, <Bootstrap hydrate router={router} />);
|
package/src/app/entry.server.tsx
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { dehydrate, QueryClient } from "@tanstack/react-query";
|
|
1
2
|
import { type HelmetData } from "@zudoku/react-helmet-async";
|
|
2
3
|
import type express from "express";
|
|
3
4
|
import logger from "loglevel";
|
|
@@ -11,7 +12,6 @@ import {
|
|
|
11
12
|
import "virtual:zudoku-theme.css";
|
|
12
13
|
import { BootstrapStatic, ServerError } from "zudoku/components";
|
|
13
14
|
import type { ZudokuConfig } from "../config/config.js";
|
|
14
|
-
import { ssr as urqlSsr } from "../lib/plugins/openapi/client/createMemoryClient.js";
|
|
15
15
|
import type { FileWritingResponse } from "../vite/prerender.js";
|
|
16
16
|
import "./main.css";
|
|
17
17
|
import { getRoutesByConfig } from "./main.js";
|
|
@@ -33,6 +33,7 @@ export const render = async ({
|
|
|
33
33
|
const { query, dataRoutes } = createStaticHandler(routes, {
|
|
34
34
|
basename: config.basePath,
|
|
35
35
|
});
|
|
36
|
+
const queryClient = new QueryClient();
|
|
36
37
|
|
|
37
38
|
const request =
|
|
38
39
|
baseRequest instanceof Request
|
|
@@ -63,72 +64,73 @@ export const render = async ({
|
|
|
63
64
|
|
|
64
65
|
const router = createStaticRouter(dataRoutes, context);
|
|
65
66
|
const helmetContext = {} as HelmetData["context"];
|
|
66
|
-
const graphqlData = urqlSsr.extractData();
|
|
67
67
|
|
|
68
|
-
const
|
|
68
|
+
const App = (
|
|
69
69
|
<BootstrapStatic
|
|
70
70
|
router={router}
|
|
71
71
|
context={context}
|
|
72
|
+
queryClient={queryClient}
|
|
72
73
|
helmetContext={helmetContext}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
74
|
+
/>
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
const { pipe } = renderToPipeableStream(App, {
|
|
78
|
+
onShellError(error) {
|
|
79
|
+
response.status(500);
|
|
80
|
+
response.set({ "Content-Type": "text/html" });
|
|
81
|
+
|
|
82
|
+
const html = renderToStaticMarkup(<ServerError error={error} />);
|
|
83
|
+
|
|
84
|
+
response.send(html);
|
|
85
|
+
},
|
|
86
|
+
// for SSG we could use onAllReady instead of onShellReady
|
|
87
|
+
// https://react.dev/reference/react-dom/server/renderToPipeableStream#waiting-for-all-content-to-load-for-crawlers-and-static-generation
|
|
88
|
+
onAllReady() {
|
|
89
|
+
response.set({ "Content-Type": "text/html" });
|
|
90
|
+
response.status(status);
|
|
91
|
+
|
|
92
|
+
const transformStream = new Transform({
|
|
93
|
+
transform(chunk, encoding, callback) {
|
|
94
|
+
response.write(chunk, encoding);
|
|
95
|
+
callback();
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const [htmlStart, htmlEnd] = template.split("<!--app-html-->");
|
|
100
|
+
|
|
101
|
+
if (!htmlStart) {
|
|
102
|
+
throw new Error("No <!--app-html--> found in template");
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
response.write(
|
|
106
|
+
htmlStart.replace(
|
|
107
|
+
"<!--app-helmet-->",
|
|
108
|
+
[
|
|
109
|
+
helmetContext.helmet.title.toString(),
|
|
110
|
+
helmetContext.helmet.meta.toString(),
|
|
111
|
+
helmetContext.helmet.link.toString(),
|
|
112
|
+
helmetContext.helmet.style.toString(),
|
|
113
|
+
helmetContext.helmet.script.toString(),
|
|
114
|
+
].join("\n"),
|
|
115
|
+
),
|
|
116
|
+
);
|
|
101
117
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
helmetContext.helmet.meta.toString(),
|
|
108
|
-
helmetContext.helmet.link.toString(),
|
|
109
|
-
helmetContext.helmet.style.toString(),
|
|
110
|
-
helmetContext.helmet.script.toString(),
|
|
111
|
-
].join("\n"),
|
|
118
|
+
transformStream.on("finish", () => {
|
|
119
|
+
response.end(
|
|
120
|
+
htmlEnd?.replace(
|
|
121
|
+
"</body>",
|
|
122
|
+
`<script>window.DATA = ${JSON.stringify(dehydrate(queryClient))}</script></body>`,
|
|
112
123
|
),
|
|
113
124
|
);
|
|
125
|
+
});
|
|
114
126
|
|
|
115
|
-
|
|
116
|
-
response.end(
|
|
117
|
-
htmlEnd?.replace(
|
|
118
|
-
"</body>",
|
|
119
|
-
`<script>window.__URQL_DATA__ = ${JSON.stringify(graphqlData)};</script></body>`,
|
|
120
|
-
),
|
|
121
|
-
);
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
pipe(transformStream);
|
|
125
|
-
},
|
|
126
|
-
onError(error) {
|
|
127
|
-
status = 500;
|
|
128
|
-
logger.error(error);
|
|
129
|
-
},
|
|
127
|
+
pipe(transformStream);
|
|
130
128
|
},
|
|
131
|
-
|
|
129
|
+
onError(error) {
|
|
130
|
+
status = 500;
|
|
131
|
+
logger.error(error);
|
|
132
|
+
},
|
|
133
|
+
});
|
|
132
134
|
};
|
|
133
135
|
|
|
134
136
|
export function createFetchRequest(
|
package/src/app/standalone.tsx
CHANGED
|
@@ -3,7 +3,6 @@ import { createBrowserRouter } from "react-router-dom";
|
|
|
3
3
|
import { Bootstrap } from "zudoku/components";
|
|
4
4
|
import type { ZudokuConfig } from "../config/validators/validate.js";
|
|
5
5
|
import { openApiPlugin } from "../lib/plugins/openapi/index.js";
|
|
6
|
-
import { themeToggle } from "../lib/themeToggle.js";
|
|
7
6
|
import "../lib/util/logInit.js";
|
|
8
7
|
import "./main.css";
|
|
9
8
|
import { getRoutesByConfig } from "./main.js";
|
|
@@ -13,8 +12,6 @@ if (!root) {
|
|
|
13
12
|
throw new Error("No div found with attribute data-api-url");
|
|
14
13
|
}
|
|
15
14
|
|
|
16
|
-
themeToggle();
|
|
17
|
-
|
|
18
15
|
const apiUrl = root.getAttribute("data-api-url");
|
|
19
16
|
const pageTitle = document.getElementsByTagName("title")[0]!.innerText;
|
|
20
17
|
const logoUrl = root.getAttribute("data-logo-url");
|
|
@@ -25,17 +25,20 @@ class Auth0AuthenticationProvider extends OpenIDAuthenticationProvider {
|
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
signOut = async (): Promise<void> => {
|
|
28
|
+
const as = await this.getAuthServer();
|
|
29
|
+
const idToken = await this.getAccessToken();
|
|
30
|
+
|
|
28
31
|
useAuthState.setState({
|
|
29
32
|
isAuthenticated: false,
|
|
30
33
|
isPending: false,
|
|
31
|
-
profile:
|
|
34
|
+
profile: null,
|
|
35
|
+
providerData: null,
|
|
32
36
|
});
|
|
33
|
-
sessionStorage.clear();
|
|
34
|
-
const as = await this.getAuthServer();
|
|
35
37
|
|
|
36
38
|
const redirectUrl = new URL(
|
|
37
39
|
window.location.origin + this.logoutRedirectUrlPath,
|
|
38
40
|
);
|
|
41
|
+
|
|
39
42
|
redirectUrl.pathname = this.logoutRedirectUrlPath;
|
|
40
43
|
|
|
41
44
|
// SEE: https://auth0.com/docs/authenticate/login/logout/log-users-out-of-auth0
|
|
@@ -43,22 +46,24 @@ class Auth0AuthenticationProvider extends OpenIDAuthenticationProvider {
|
|
|
43
46
|
// Logout End Session Endpoint Discovery is enabled by default.
|
|
44
47
|
// Otherwise we fallback to the old non-compliant logout
|
|
45
48
|
|
|
46
|
-
let logoutUrl: URL;
|
|
47
49
|
// The endSessionEndpoint is set, the IdP supports some form of logout,
|
|
48
50
|
// so we use the IdP logout. Otherwise, just redirect the user to home
|
|
49
51
|
if (as.end_session_endpoint) {
|
|
50
|
-
logoutUrl = new URL(as.end_session_endpoint);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
// logoutUrl.searchParams.set("id_token_hint", id_token);
|
|
55
|
-
// }
|
|
52
|
+
const logoutUrl = new URL(as.end_session_endpoint);
|
|
53
|
+
if (idToken) {
|
|
54
|
+
logoutUrl.searchParams.set("id_token_hint", idToken);
|
|
55
|
+
}
|
|
56
56
|
logoutUrl.searchParams.set(
|
|
57
57
|
"post_logout_redirect_uri",
|
|
58
58
|
redirectUrl.toString(),
|
|
59
59
|
);
|
|
60
|
+
|
|
61
|
+
// window.location.href = logoutUrl.toString();
|
|
60
62
|
} else {
|
|
61
|
-
logoutUrl = new URL(
|
|
63
|
+
const logoutUrl = new URL(
|
|
64
|
+
`${this.issuer.replace(/\/$/, "")}/oidc/logout`,
|
|
65
|
+
);
|
|
66
|
+
// window.location.href = logoutUrl.toString();
|
|
62
67
|
}
|
|
63
68
|
};
|
|
64
69
|
}
|
|
@@ -107,7 +107,10 @@ export class OpenIDAuthenticationProvider implements AuthenticationProvider {
|
|
|
107
107
|
expiresOn: new Date(Date.now() + response.expires_in * 1000),
|
|
108
108
|
tokenType: response.token_type,
|
|
109
109
|
};
|
|
110
|
-
|
|
110
|
+
|
|
111
|
+
useAuthState.setState({
|
|
112
|
+
providerData: tokens,
|
|
113
|
+
});
|
|
111
114
|
}
|
|
112
115
|
|
|
113
116
|
async signUp({ redirectTo }: { redirectTo?: string } = {}) {
|
|
@@ -194,14 +197,14 @@ export class OpenIDAuthenticationProvider implements AuthenticationProvider {
|
|
|
194
197
|
|
|
195
198
|
async getAccessToken(): Promise<string> {
|
|
196
199
|
const as = await this.getAuthServer();
|
|
197
|
-
const
|
|
198
|
-
if (!
|
|
200
|
+
const { providerData } = useAuthState.getState();
|
|
201
|
+
if (!providerData) {
|
|
199
202
|
throw new AuthorizationError("User is not authenticated");
|
|
200
203
|
}
|
|
204
|
+
const tokenState = providerData as TokenState;
|
|
201
205
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
if (!state.refreshToken) {
|
|
206
|
+
if (tokenState.expiresOn < new Date()) {
|
|
207
|
+
if (!tokenState.refreshToken) {
|
|
205
208
|
await this.signIn();
|
|
206
209
|
return "";
|
|
207
210
|
}
|
|
@@ -209,7 +212,7 @@ export class OpenIDAuthenticationProvider implements AuthenticationProvider {
|
|
|
209
212
|
const request = await oauth.refreshTokenGrantRequest(
|
|
210
213
|
as,
|
|
211
214
|
this.client,
|
|
212
|
-
|
|
215
|
+
tokenState.refreshToken,
|
|
213
216
|
);
|
|
214
217
|
const response = await oauth.processRefreshTokenResponse(
|
|
215
218
|
as,
|
|
@@ -225,7 +228,7 @@ export class OpenIDAuthenticationProvider implements AuthenticationProvider {
|
|
|
225
228
|
|
|
226
229
|
return response.access_token.toString();
|
|
227
230
|
} else {
|
|
228
|
-
return
|
|
231
|
+
return tokenState.accessToken;
|
|
229
232
|
}
|
|
230
233
|
}
|
|
231
234
|
|
|
@@ -234,8 +237,8 @@ export class OpenIDAuthenticationProvider implements AuthenticationProvider {
|
|
|
234
237
|
isAuthenticated: false,
|
|
235
238
|
isPending: false,
|
|
236
239
|
profile: undefined,
|
|
240
|
+
providerData: undefined,
|
|
237
241
|
});
|
|
238
|
-
sessionStorage.clear();
|
|
239
242
|
|
|
240
243
|
const as = await this.getAuthServer();
|
|
241
244
|
|
|
@@ -342,32 +345,11 @@ export class OpenIDAuthenticationProvider implements AuthenticationProvider {
|
|
|
342
345
|
profile,
|
|
343
346
|
});
|
|
344
347
|
|
|
345
|
-
sessionStorage.setItem(
|
|
346
|
-
"profile-state",
|
|
347
|
-
JSON.stringify(useAuthState.getState().profile),
|
|
348
|
-
);
|
|
349
|
-
|
|
350
348
|
const redirectTo = sessionStorage.getItem("redirect-to") ?? "/";
|
|
351
349
|
sessionStorage.removeItem("redirect-to");
|
|
352
350
|
return redirectTo;
|
|
353
351
|
};
|
|
354
352
|
|
|
355
|
-
pageLoad(): void {
|
|
356
|
-
const profileState = sessionStorage.getItem("profile-state");
|
|
357
|
-
if (profileState) {
|
|
358
|
-
try {
|
|
359
|
-
const profile = JSON.parse(profileState);
|
|
360
|
-
useAuthState.setState({
|
|
361
|
-
isAuthenticated: true,
|
|
362
|
-
isPending: false,
|
|
363
|
-
profile,
|
|
364
|
-
});
|
|
365
|
-
} catch (err) {
|
|
366
|
-
logger.error("Error parsing auth state", err);
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
|
|
371
353
|
getAuthenticationPlugin() {
|
|
372
354
|
// TODO: This API is a bit messy, we need to refactor auth plugins/providers
|
|
373
355
|
// to remove the extra layers of abstraction.
|
|
@@ -1,24 +1,58 @@
|
|
|
1
|
-
import { create } from "zustand";
|
|
2
|
-
import { persist } from "zustand/middleware";
|
|
3
|
-
import { shared } from "./use-broadcast/shared.js";
|
|
1
|
+
import { create, type Mutate, type StoreApi } from "zustand";
|
|
2
|
+
import { createJSONStorage, persist } from "zustand/middleware";
|
|
4
3
|
|
|
5
|
-
export interface AuthState {
|
|
4
|
+
export interface AuthState<ProviderData = unknown> {
|
|
6
5
|
isAuthenticated: boolean;
|
|
7
6
|
isPending: boolean;
|
|
8
|
-
profile
|
|
7
|
+
profile: UserProfile | null;
|
|
8
|
+
providerData: ProviderData | null;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
export class Authentication {
|
|
12
|
+
async setLoggedIn(isLoggedIn: boolean) {}
|
|
13
|
+
async setProfile() {}
|
|
14
|
+
async setPersistentProviderData() {}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type StoreWithPersist<T> = Mutate<
|
|
18
|
+
StoreApi<T>,
|
|
19
|
+
[["zustand/persist", unknown]]
|
|
20
|
+
>;
|
|
21
|
+
|
|
22
|
+
export const withStorageDOMEvents = <T>(store: StoreWithPersist<T>) => {
|
|
23
|
+
const storageEventCallback = (e: StorageEvent) => {
|
|
24
|
+
if (e.key === store.persist.getOptions().name && e.newValue) {
|
|
25
|
+
void store.persist.rehydrate();
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
window.addEventListener("storage", storageEventCallback);
|
|
30
|
+
|
|
31
|
+
return () => {
|
|
32
|
+
window.removeEventListener("storage", storageEventCallback);
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const useAuthState = create<AuthState>()(
|
|
37
|
+
persist(
|
|
38
|
+
(state) => ({
|
|
14
39
|
isAuthenticated: false,
|
|
15
40
|
isPending: false,
|
|
16
|
-
profile:
|
|
41
|
+
profile: null,
|
|
42
|
+
providerData: null,
|
|
17
43
|
}),
|
|
18
|
-
{
|
|
44
|
+
{
|
|
45
|
+
name: "auth-state",
|
|
46
|
+
storage: createJSONStorage(() => localStorage),
|
|
47
|
+
// partialize: (s) => ({ state: s }),
|
|
48
|
+
},
|
|
19
49
|
),
|
|
20
50
|
);
|
|
21
51
|
|
|
52
|
+
if (typeof window !== "undefined") {
|
|
53
|
+
withStorageDOMEvents(useAuthState);
|
|
54
|
+
}
|
|
55
|
+
|
|
22
56
|
export interface UserProfile {
|
|
23
57
|
sub: string;
|
|
24
58
|
email: string | undefined;
|