zudoku 0.3.0-dev.3 → 0.3.0-dev.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zudoku",
3
- "version": "0.3.0-dev.3",
3
+ "version": "0.3.0-dev.5",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -48,7 +48,7 @@ export const Layout = ({ children }: { children?: ReactNode }) => {
48
48
  >
49
49
  <SideNavigation />
50
50
  <main
51
- className="dark:border-white/10 translate-x-0
51
+ className="dark:border-white/10 translate-x-0 h-full
52
52
  lg:overflow-visible
53
53
  lg:peer-data-[navigation=true]:w-[calc(100%-var(--side-nav-width))]
54
54
  lg:peer-data-[navigation=true]:translate-x-[--side-nav-width] peer-data-[navigation=true]:pl-12"
@@ -88,6 +88,7 @@ export class DevPortalContext {
88
88
  this.plugins
89
89
  .filter(needsInitialization)
90
90
  .forEach((plugin) => plugin.initialize(this));
91
+ this.authentication?.initialize(this);
91
92
  };
92
93
 
93
94
  invalidateCache = async (key: DevPortalCacheKey[]) => {
@@ -8,7 +8,6 @@ import { useState } from "react";
8
8
  import { Link } from "react-router-dom";
9
9
  import { useDevPortal } from "../../components/context/DevPortalProvider.js";
10
10
  import { Button } from "../../ui/Button.js";
11
- import { Card } from "../../ui/Card.js";
12
11
  import { type ApiKeyPluginOptions, ApiKeyService } from "./index.js";
13
12
 
14
13
  export const SettingsApiKeys = ({
@@ -49,58 +48,56 @@ export const SettingsApiKeys = ({
49
48
  )}
50
49
  </div>
51
50
 
52
- <Card>
53
- <ul className="grid grid-cols-[min-content_1fr_min-content] ">
54
- {data.map((key) => (
55
- <li
56
- className="border-b border-border p-5 grid grid-cols-subgrid col-span-full gap-2 items-center"
57
- key={key.id}
58
- >
59
- <div className="flex flex-col gap-1 text-sm">
60
- {key.description ?? key.id}
61
- <div className="text-muted-foreground text-xs">
62
- {key.createdOn && (
63
- <div>
64
- Created on {new Date(key.createdOn).toLocaleDateString()}
65
- </div>
66
- )}
67
- {key.expiresOn && (
68
- <div>
69
- Expires on {new Date(key.expiresOn).toLocaleDateString()}
70
- </div>
71
- )}
72
- </div>
73
- </div>
74
- <div className="items-center flex justify-center">
75
- <RevealApiKey apiKey={key.key} />
76
- </div>
77
- <div className="flex gap-2">
78
- {service.rollKey && (
79
- <Button size="icon">
80
- <RotateCwIcon size={16} />
81
- </Button>
51
+ <ul className="grid grid-cols-[min-content_1fr_min-content] ">
52
+ {data.map((key) => (
53
+ <li
54
+ className="border-b border-border p-5 grid grid-cols-subgrid col-span-full gap-2 items-center"
55
+ key={key.id}
56
+ >
57
+ <div className="flex flex-col gap-1 text-sm">
58
+ {key.description ?? key.id}
59
+ <div className="text-muted-foreground text-xs">
60
+ {key.createdOn && (
61
+ <div>
62
+ Created on {new Date(key.createdOn).toLocaleDateString()}
63
+ </div>
82
64
  )}
83
- {service.deleteKey && (
84
- <Button
85
- variant="ghost"
86
- size="icon"
87
- onClick={() => {
88
- if (!confirm("Do you want to delete this key?")) {
89
- return;
90
- }
91
-
92
- deleteKeyMutation.mutate(key.id);
93
- }}
94
- disabled={deleteKeyMutation.isPending}
95
- >
96
- <TrashIcon size={16} />
97
- </Button>
65
+ {key.expiresOn && (
66
+ <div>
67
+ Expires on {new Date(key.expiresOn).toLocaleDateString()}
68
+ </div>
98
69
  )}
99
70
  </div>
100
- </li>
101
- ))}
102
- </ul>
103
- </Card>
71
+ </div>
72
+ <div className="items-center flex justify-center">
73
+ <RevealApiKey apiKey={key.key} />
74
+ </div>
75
+ <div className="flex gap-2">
76
+ {service.rollKey && (
77
+ <Button size="icon">
78
+ <RotateCwIcon size={16} />
79
+ </Button>
80
+ )}
81
+ {service.deleteKey && (
82
+ <Button
83
+ variant="ghost"
84
+ size="icon"
85
+ onClick={() => {
86
+ if (!confirm("Do you want to delete this key?")) {
87
+ return;
88
+ }
89
+
90
+ deleteKeyMutation.mutate(key.id);
91
+ }}
92
+ disabled={deleteKeyMutation.isPending}
93
+ >
94
+ <TrashIcon size={16} />
95
+ </Button>
96
+ )}
97
+ </div>
98
+ </li>
99
+ ))}
100
+ </ul>
104
101
  </div>
105
102
  );
106
103
  };
@@ -1,8 +1,11 @@
1
+ import { Outlet } from "react-router-dom";
2
+ import { useAuth } from "../../authentication/hook.js";
1
3
  import { DevPortalContext } from "../../core/DevPortalContext.js";
2
4
  import {
3
5
  type ApiIdentityPlugin,
4
6
  type DevPortalPlugin,
5
7
  } from "../../core/plugins.js";
8
+ import { Button } from "../../ui/Button.js";
6
9
  import { CreateApiKey } from "./CreateApiKey.js";
7
10
  import { SettingsApiKeys } from "./SettingsApiKeys.js";
8
11
 
@@ -73,6 +76,18 @@ const createDefaultHandler = (endpoint: string): ApiKeyService => {
73
76
  };
74
77
  };
75
78
 
79
+ const ProtectedRoute = () => {
80
+ const auth = useAuth();
81
+ return auth.isAuthenticated ? (
82
+ <Outlet />
83
+ ) : (
84
+ <div className="flex flex-col justify-center gap-2 items-center h-1/2 my-12">
85
+ Please login first to view this page
86
+ <Button onClick={() => auth.login()}>Login</Button>
87
+ </div>
88
+ );
89
+ };
90
+
76
91
  export const apiKeyPlugin = (
77
92
  options: ApiKeyPluginOptions,
78
93
  ): DevPortalPlugin & ApiIdentityPlugin => {
@@ -102,12 +117,17 @@ export const apiKeyPlugin = (
102
117
  getRoutes: () => {
103
118
  return [
104
119
  {
105
- path: "/settings/api-keys",
106
- element: <SettingsApiKeys options={options} service={service} />,
107
- },
108
- {
109
- path: "/settings/api-keys/new",
110
- element: <CreateApiKey options={options} service={service} />,
120
+ element: <ProtectedRoute />,
121
+ children: [
122
+ {
123
+ path: "/settings/api-keys",
124
+ element: <SettingsApiKeys options={options} service={service} />,
125
+ },
126
+ {
127
+ path: "/settings/api-keys/new",
128
+ element: <CreateApiKey options={options} service={service} />,
129
+ },
130
+ ],
111
131
  },
112
132
  ];
113
133
  },
@@ -30,7 +30,7 @@ const MarkdownHeadings = {
30
30
 
31
31
  export const MdxPage = ({
32
32
  mdxComponent: MdxComponent,
33
- frontmatter,
33
+ frontmatter = {},
34
34
  tableOfContents,
35
35
  }: PropsWithChildren<
36
36
  Omit<MDXImport, "default"> & {
@@ -1,28 +0,0 @@
1
- var u = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
2
- function f(e) {
3
- return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
4
- }
5
- function l(e) {
6
- if (e.__esModule) return e;
7
- var r = e.default;
8
- if (typeof r == "function") {
9
- var t = function o() {
10
- return this instanceof o ? Reflect.construct(r, arguments, this.constructor) : r.apply(this, arguments);
11
- };
12
- t.prototype = r.prototype;
13
- } else t = {};
14
- return Object.defineProperty(t, "__esModule", { value: !0 }), Object.keys(e).forEach(function(o) {
15
- var n = Object.getOwnPropertyDescriptor(e, o);
16
- Object.defineProperty(t, o, n.get ? n : {
17
- enumerable: !0,
18
- get: function() {
19
- return e[o];
20
- }
21
- });
22
- }), t;
23
- }
24
- export {
25
- l as a,
26
- u as c,
27
- f as g
28
- };
@@ -1,287 +0,0 @@
1
- import w from "react";
2
- import { g as Q } from "./_commonjsHelpers-BkfeUUK-.js";
3
- var X = { BASE_URL: "/", MODE: "production", DEV: !1, PROD: !0, SSR: !1 };
4
- const H = (e) => {
5
- let s;
6
- const l = /* @__PURE__ */ new Set(), v = (u, t) => {
7
- const r = typeof u == "function" ? u(s) : u;
8
- if (!Object.is(r, s)) {
9
- const i = s;
10
- s = t ?? (typeof r != "object" || r === null) ? r : Object.assign({}, s, r), l.forEach((f) => f(s, i));
11
- }
12
- }, O = () => s, h = { setState: v, getState: O, getInitialState: () => p, subscribe: (u) => (l.add(u), () => l.delete(u)), destroy: () => {
13
- (X ? "production" : void 0) !== "production" && console.warn(
14
- "[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."
15
- ), l.clear();
16
- } }, p = s = e(v, O, h);
17
- return h;
18
- }, Z = (e) => e ? H(e) : H;
19
- var U = { exports: {} }, B = {}, V = { exports: {} }, M = {};
20
- /**
21
- * @license React
22
- * use-sync-external-store-shim.production.min.js
23
- *
24
- * Copyright (c) Facebook, Inc. and its affiliates.
25
- *
26
- * This source code is licensed under the MIT license found in the
27
- * LICENSE file in the root directory of this source tree.
28
- */
29
- var K;
30
- function ee() {
31
- if (K) return M;
32
- K = 1;
33
- var e = w;
34
- function s(t, r) {
35
- return t === r && (t !== 0 || 1 / t === 1 / r) || t !== t && r !== r;
36
- }
37
- var l = typeof Object.is == "function" ? Object.is : s, v = e.useState, O = e.useEffect, y = e.useLayoutEffect, L = e.useDebugValue;
38
- function g(t, r) {
39
- var i = r(), f = v({ inst: { value: i, getSnapshot: r } }), c = f[0].inst, d = f[1];
40
- return y(function() {
41
- c.value = i, c.getSnapshot = r, h(c) && d({ inst: c });
42
- }, [t, i, r]), O(function() {
43
- return h(c) && d({ inst: c }), t(function() {
44
- h(c) && d({ inst: c });
45
- });
46
- }, [t]), L(i), i;
47
- }
48
- function h(t) {
49
- var r = t.getSnapshot;
50
- t = t.value;
51
- try {
52
- var i = r();
53
- return !l(t, i);
54
- } catch {
55
- return !0;
56
- }
57
- }
58
- function p(t, r) {
59
- return r();
60
- }
61
- var u = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? p : g;
62
- return M.useSyncExternalStore = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : u, M;
63
- }
64
- var j = {};
65
- /**
66
- * @license React
67
- * use-sync-external-store-shim.development.js
68
- *
69
- * Copyright (c) Facebook, Inc. and its affiliates.
70
- *
71
- * This source code is licensed under the MIT license found in the
72
- * LICENSE file in the root directory of this source tree.
73
- */
74
- var N;
75
- function te() {
76
- return N || (N = 1, process.env.NODE_ENV !== "production" && function() {
77
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
78
- var e = w, s = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
79
- function l(a) {
80
- {
81
- for (var n = arguments.length, _ = new Array(n > 1 ? n - 1 : 0), o = 1; o < n; o++)
82
- _[o - 1] = arguments[o];
83
- v("error", a, _);
84
- }
85
- }
86
- function v(a, n, _) {
87
- {
88
- var o = s.ReactDebugCurrentFrame, S = o.getStackAddendum();
89
- S !== "" && (n += "%s", _ = _.concat([S]));
90
- var m = _.map(function(E) {
91
- return String(E);
92
- });
93
- m.unshift("Warning: " + n), Function.prototype.apply.call(console[a], console, m);
94
- }
95
- }
96
- function O(a, n) {
97
- return a === n && (a !== 0 || 1 / a === 1 / n) || a !== a && n !== n;
98
- }
99
- var y = typeof Object.is == "function" ? Object.is : O, L = e.useState, g = e.useEffect, h = e.useLayoutEffect, p = e.useDebugValue, u = !1, t = !1;
100
- function r(a, n, _) {
101
- u || e.startTransition !== void 0 && (u = !0, l("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));
102
- var o = n();
103
- if (!t) {
104
- var S = n();
105
- y(o, S) || (l("The result of getSnapshot should be cached to avoid an infinite loop"), t = !0);
106
- }
107
- var m = L({
108
- inst: {
109
- value: o,
110
- getSnapshot: n
111
- }
112
- }), E = m[0].inst, A = m[1];
113
- return h(function() {
114
- E.value = o, E.getSnapshot = n, i(E) && A({
115
- inst: E
116
- });
117
- }, [a, o, n]), g(function() {
118
- i(E) && A({
119
- inst: E
120
- });
121
- var b = function() {
122
- i(E) && A({
123
- inst: E
124
- });
125
- };
126
- return a(b);
127
- }, [a]), p(o), o;
128
- }
129
- function i(a) {
130
- var n = a.getSnapshot, _ = a.value;
131
- try {
132
- var o = n();
133
- return !y(_, o);
134
- } catch {
135
- return !0;
136
- }
137
- }
138
- function f(a, n, _) {
139
- return n();
140
- }
141
- var c = typeof window < "u" && typeof window.document < "u" && typeof window.document.createElement < "u", d = !c, D = d ? f : r, R = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : D;
142
- j.useSyncExternalStore = R, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
143
- }()), j;
144
- }
145
- var q;
146
- function Y() {
147
- return q || (q = 1, process.env.NODE_ENV === "production" ? V.exports = ee() : V.exports = te()), V.exports;
148
- }
149
- /**
150
- * @license React
151
- * use-sync-external-store-shim/with-selector.production.min.js
152
- *
153
- * Copyright (c) Facebook, Inc. and its affiliates.
154
- *
155
- * This source code is licensed under the MIT license found in the
156
- * LICENSE file in the root directory of this source tree.
157
- */
158
- var z;
159
- function ne() {
160
- if (z) return B;
161
- z = 1;
162
- var e = w, s = Y();
163
- function l(p, u) {
164
- return p === u && (p !== 0 || 1 / p === 1 / u) || p !== p && u !== u;
165
- }
166
- var v = typeof Object.is == "function" ? Object.is : l, O = s.useSyncExternalStore, y = e.useRef, L = e.useEffect, g = e.useMemo, h = e.useDebugValue;
167
- return B.useSyncExternalStoreWithSelector = function(p, u, t, r, i) {
168
- var f = y(null);
169
- if (f.current === null) {
170
- var c = { hasValue: !1, value: null };
171
- f.current = c;
172
- } else c = f.current;
173
- f = g(function() {
174
- function D(o) {
175
- if (!R) {
176
- if (R = !0, a = o, o = r(o), i !== void 0 && c.hasValue) {
177
- var S = c.value;
178
- if (i(S, o)) return n = S;
179
- }
180
- return n = o;
181
- }
182
- if (S = n, v(a, o)) return S;
183
- var m = r(o);
184
- return i !== void 0 && i(S, m) ? S : (a = o, n = m);
185
- }
186
- var R = !1, a, n, _ = t === void 0 ? null : t;
187
- return [function() {
188
- return D(u());
189
- }, _ === null ? void 0 : function() {
190
- return D(_());
191
- }];
192
- }, [u, t, r, i]);
193
- var d = O(p, f[0], f[1]);
194
- return L(function() {
195
- c.hasValue = !0, c.value = d;
196
- }, [d]), h(d), d;
197
- }, B;
198
- }
199
- var G = {};
200
- /**
201
- * @license React
202
- * use-sync-external-store-shim/with-selector.development.js
203
- *
204
- * Copyright (c) Facebook, Inc. and its affiliates.
205
- *
206
- * This source code is licensed under the MIT license found in the
207
- * LICENSE file in the root directory of this source tree.
208
- */
209
- var P;
210
- function re() {
211
- return P || (P = 1, process.env.NODE_ENV !== "production" && function() {
212
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
213
- var e = w, s = Y();
214
- function l(u, t) {
215
- return u === t && (u !== 0 || 1 / u === 1 / t) || u !== u && t !== t;
216
- }
217
- var v = typeof Object.is == "function" ? Object.is : l, O = s.useSyncExternalStore, y = e.useRef, L = e.useEffect, g = e.useMemo, h = e.useDebugValue;
218
- function p(u, t, r, i, f) {
219
- var c = y(null), d;
220
- c.current === null ? (d = {
221
- hasValue: !1,
222
- value: null
223
- }, c.current = d) : d = c.current;
224
- var D = g(function() {
225
- var _ = !1, o, S, m = function(T) {
226
- if (!_) {
227
- _ = !0, o = T;
228
- var x = i(T);
229
- if (f !== void 0 && d.hasValue) {
230
- var I = d.value;
231
- if (f(I, x))
232
- return S = I, I;
233
- }
234
- return S = x, x;
235
- }
236
- var J = o, C = S;
237
- if (v(J, T))
238
- return C;
239
- var W = i(T);
240
- return f !== void 0 && f(C, W) ? C : (o = T, S = W, W);
241
- }, E = r === void 0 ? null : r, A = function() {
242
- return m(t());
243
- }, b = E === null ? void 0 : function() {
244
- return m(E());
245
- };
246
- return [A, b];
247
- }, [t, r, i, f]), R = D[0], a = D[1], n = O(u, R, a);
248
- return L(function() {
249
- d.hasValue = !0, d.value = n;
250
- }, [n]), h(n), n;
251
- }
252
- G.useSyncExternalStoreWithSelector = p, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
253
- }()), G;
254
- }
255
- process.env.NODE_ENV === "production" ? U.exports = ne() : U.exports = re();
256
- var oe = U.exports;
257
- const ue = /* @__PURE__ */ Q(oe);
258
- var k = { BASE_URL: "/", MODE: "production", DEV: !1, PROD: !0, SSR: !1 };
259
- const { useDebugValue: ie } = w, { useSyncExternalStoreWithSelector: ae } = ue;
260
- let F = !1;
261
- const se = (e) => e;
262
- function ce(e, s = se, l) {
263
- (k ? "production" : void 0) !== "production" && l && !F && (console.warn(
264
- "[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"
265
- ), F = !0);
266
- const v = ae(
267
- e.subscribe,
268
- e.getState,
269
- e.getServerState || e.getInitialState,
270
- s,
271
- l
272
- );
273
- return ie(v), v;
274
- }
275
- const $ = (e) => {
276
- (k ? "production" : void 0) !== "production" && typeof e != "function" && console.warn(
277
- "[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`."
278
- );
279
- const s = typeof e == "function" ? Z(e) : e, l = (v, O) => ce(s, v, O);
280
- return Object.assign(l, s), l;
281
- }, fe = (e) => e ? $(e) : $, Se = fe(() => ({
282
- isAuthenticated: !1
283
- }));
284
- export {
285
- fe as c,
286
- Se as u
287
- };