zudoku 0.3.0-dev.53 → 0.3.0-dev.55
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/lib/components/Bootstrap.js +1 -1
- package/dist/lib/components/Bootstrap.js.map +1 -1
- package/lib/AnchorLink-BaXHjhF-.js +989 -0
- package/lib/{AnchorLink-BCN_a_Uz.js.map → AnchorLink-BaXHjhF-.js.map} +1 -1
- package/lib/Combination-BfufJFkX.js +1365 -0
- package/lib/{Combination-B0Iu6mhJ.js.map → Combination-BfufJFkX.js.map} +1 -1
- package/lib/DevPortalProvider-GjdO0Xr-.js +1610 -0
- package/lib/{DevPortalProvider-Do9oJqme.js.map → DevPortalProvider-GjdO0Xr-.js.map} +1 -1
- package/lib/Markdown-B8nPVql1.js +19708 -0
- package/lib/Markdown-B8nPVql1.js.map +1 -0
- package/lib/MdxPage-Dlujuj-J.js +223 -0
- package/lib/{MdxPage-Bsc79cD-.js.map → MdxPage-Dlujuj-J.js.map} +1 -1
- package/lib/OperationList-krPgt6sE.js +8041 -0
- package/lib/{OperationList-K-JWBxau.js.map → OperationList-krPgt6sE.js.map} +1 -1
- package/lib/Playground-DOHxca0P.js +539 -0
- package/lib/{Playground-Czy7ha9z.js.map → Playground-DOHxca0P.js.map} +1 -1
- package/lib/Route-CR6TEwVC.js +13 -0
- package/lib/{Route-D-egsGHx.js.map → Route-CR6TEwVC.js.map} +1 -1
- package/lib/Select-Boi_pe3L.js +5298 -0
- package/lib/{Select-CcBbwJ2R.js.map → Select-Boi_pe3L.js.map} +1 -1
- package/lib/Spinner-oU0QJmi_.js +16 -0
- package/lib/{Spinner-C9_Opdev.js.map → Spinner-oU0QJmi_.js.map} +1 -1
- package/lib/_commonjsHelpers-BxmBWJD2.js +34 -0
- package/lib/_commonjsHelpers-BxmBWJD2.js.map +1 -0
- package/lib/assets/index-CpIig0AX.js +6341 -0
- package/lib/{index-pI9JkN46.js.map → assets/index-CpIig0AX.js.map} +1 -1
- package/lib/assets/worker-B5k2aBV9.js +18921 -0
- package/lib/assets/{worker-BjPv-hjP.js.map → worker-B5k2aBV9.js.map} +1 -1
- package/lib/context-BoN_3uxi.js +17 -0
- package/lib/{context-_fYfJFgk.js.map → context-BoN_3uxi.js.map} +1 -1
- package/lib/hook-CIuFuyBT.js +90 -0
- package/lib/{hook-CKqQERWo.js.map → hook-CIuFuyBT.js.map} +1 -1
- package/lib/index-BL1P4Gqq.js +280 -0
- package/lib/{index-ByHya67R.js.map → index-BL1P4Gqq.js.map} +1 -1
- package/lib/index-Bn03IPZt.js +6341 -0
- package/lib/{assets/index-BPdJm2ty.js.map → index-Bn03IPZt.js.map} +1 -1
- package/lib/{index-jsFBaizC.js → index-Dih8IAqw.js} +103 -83
- package/lib/{index-jsFBaizC.js.map → index-Dih8IAqw.js.map} +1 -1
- package/lib/index-FprhHF51.js +253 -0
- package/lib/{index-DseBZFJ-.js.map → index-FprhHF51.js.map} +1 -1
- package/lib/jsx-runtime-DvZ6OKMM.js +2110 -0
- package/lib/{jsx-runtime-CJZJivg2.js.map → jsx-runtime-DvZ6OKMM.js.map} +1 -1
- package/lib/mutation-DWY9x2Uc.js +250 -0
- package/lib/{mutation-DjbQSHzT.js.map → mutation-DWY9x2Uc.js.map} +1 -1
- package/lib/prism-bash.min-BtBk0onv.js +7 -0
- package/lib/{prism-bash.min-DadFsM4Z.js.map → prism-bash.min-BtBk0onv.js.map} +1 -1
- package/lib/prism-csharp.min-Cv7D49bv.js +30 -0
- package/lib/{prism-csharp.min-Yizuc34Y.js.map → prism-csharp.min-Cv7D49bv.js.map} +1 -1
- package/lib/prism-java.min-tNK-JX6x.js +7 -0
- package/lib/{prism-java.min-d5iT_mOd.js.map → prism-java.min-tNK-JX6x.js.map} +1 -1
- package/lib/prism-json.min-Cdtv-CME.js +2 -0
- package/lib/{prism-json.min-B1GJqK1k.js.map → prism-json.min-Cdtv-CME.js.map} +1 -1
- package/lib/prism-markup-templating-iotg2sCU.js +94 -0
- package/lib/{prism-markup-templating-DZrrEs0A.js.map → prism-markup-templating-iotg2sCU.js.map} +1 -1
- package/lib/prism-objectivec.min-CY4WGixz.js +2 -0
- package/lib/{prism-objectivec.min-BXSWqpJJ.js.map → prism-objectivec.min-CY4WGixz.js.map} +1 -1
- package/lib/prism-php.min-T6sIVgED.js +11 -0
- package/lib/{prism-php.min-o7FpoMP_.js.map → prism-php.min-T6sIVgED.js.map} +1 -1
- package/lib/prism-ruby.min-B-2KAa4y.js +8 -0
- package/lib/{prism-ruby.min-C7LwcKyz.js.map → prism-ruby.min-B-2KAa4y.js.map} +1 -1
- package/lib/router-ButO1QyY.js +4062 -0
- package/lib/{router-CBw2vqJE.js.map → router-ButO1QyY.js.map} +1 -1
- package/lib/slugify-CmS97Vy8.js +50 -0
- package/lib/{slugify-CiPVjteN.js.map → slugify-CmS97Vy8.js.map} +1 -1
- package/lib/state-CmGfNKhR.js +436 -0
- package/lib/{state-DKdaQzvh.js.map → state-CmGfNKhR.js.map} +1 -1
- package/lib/urql-DtVKPBx_.js +2567 -0
- package/lib/{urql-DEKdguFl.js.map → urql-DtVKPBx_.js.map} +1 -1
- package/lib/util-B5KX4h4M.js +55 -0
- package/lib/{util-_jwUlTBU.js.map → util-B5KX4h4M.js.map} +1 -1
- package/lib/zudoku.auth-auth0.js +24 -18
- package/lib/zudoku.auth-auth0.js.map +1 -1
- package/lib/zudoku.auth-clerk.js +43 -34
- package/lib/zudoku.auth-clerk.js.map +1 -1
- package/lib/zudoku.auth-openid.js +1121 -734
- package/lib/zudoku.auth-openid.js.map +1 -1
- package/lib/zudoku.components.js +1076 -823
- package/lib/zudoku.components.js.map +1 -1
- package/lib/zudoku.openapi-worker.js +13776 -9681
- package/lib/zudoku.openapi-worker.js.map +1 -1
- package/lib/zudoku.plugin-api-keys.js +206 -165
- package/lib/zudoku.plugin-api-keys.js.map +1 -1
- package/lib/zudoku.plugin-markdown.js +41 -33
- package/lib/zudoku.plugin-markdown.js.map +1 -1
- package/lib/zudoku.plugin-openapi.js +6 -6
- package/lib/zudoku.plugin-redirect.js +10 -8
- package/lib/zudoku.plugin-redirect.js.map +1 -1
- package/package.json +1 -1
- package/src/lib/components/Bootstrap.tsx +1 -1
- package/lib/AnchorLink-BCN_a_Uz.js +0 -705
- package/lib/Combination-B0Iu6mhJ.js +0 -915
- package/lib/DevPortalProvider-Do9oJqme.js +0 -1081
- package/lib/Markdown-aE_XoLNs.js +0 -15030
- package/lib/Markdown-aE_XoLNs.js.map +0 -1
- package/lib/MdxPage-Bsc79cD-.js +0 -190
- package/lib/OperationList-K-JWBxau.js +0 -5091
- package/lib/Playground-Czy7ha9z.js +0 -502
- package/lib/Route-D-egsGHx.js +0 -13
- package/lib/Select-CcBbwJ2R.js +0 -3667
- package/lib/Spinner-C9_Opdev.js +0 -15
- package/lib/_commonjsHelpers-BVfed4GL.js +0 -29
- package/lib/_commonjsHelpers-BVfed4GL.js.map +0 -1
- package/lib/assets/index-BPdJm2ty.js +0 -4765
- package/lib/assets/worker-BjPv-hjP.js +0 -14897
- package/lib/context-_fYfJFgk.js +0 -14
- package/lib/hook-CKqQERWo.js +0 -77
- package/lib/index-ByHya67R.js +0 -207
- package/lib/index-DseBZFJ-.js +0 -170
- package/lib/index-pI9JkN46.js +0 -4765
- package/lib/jsx-runtime-CJZJivg2.js +0 -1526
- package/lib/mutation-DjbQSHzT.js +0 -208
- package/lib/prism-bash.min-DadFsM4Z.js +0 -7
- package/lib/prism-csharp.min-Yizuc34Y.js +0 -35
- package/lib/prism-java.min-d5iT_mOd.js +0 -7
- package/lib/prism-json.min-B1GJqK1k.js +0 -2
- package/lib/prism-markup-templating-DZrrEs0A.js +0 -62
- package/lib/prism-objectivec.min-BXSWqpJJ.js +0 -2
- package/lib/prism-php.min-o7FpoMP_.js +0 -11
- package/lib/prism-ruby.min-C7LwcKyz.js +0 -10
- package/lib/router-CBw2vqJE.js +0 -2973
- package/lib/slugify-CiPVjteN.js +0 -28
- package/lib/state-DKdaQzvh.js +0 -288
- package/lib/urql-DEKdguFl.js +0 -1592
- package/lib/util-_jwUlTBU.js +0 -41
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import { R as
|
|
3
|
-
import { B as
|
|
4
|
-
import { u as
|
|
5
|
-
import { c as
|
|
6
|
-
import { u as
|
|
7
|
-
import * as
|
|
8
|
-
import { useState
|
|
1
|
+
import { j as jsxRuntimeExports, a as useNavigate, O as Outlet } from "./jsx-runtime-DvZ6OKMM.js";
|
|
2
|
+
import { R as RouterError, u as useAuth } from "./hook-CIuFuyBT.js";
|
|
3
|
+
import { B as Button } from "./Combination-BfufJFkX.js";
|
|
4
|
+
import { u as useForm, a as useMutation, S as Select, b as SelectTrigger, c as SelectValue, d as SelectContent, e as SelectGroup, f as SelectItem } from "./Select-Boi_pe3L.js";
|
|
5
|
+
import { c as createLucideIcon, e as cn, L as Link } from "./Markdown-B8nPVql1.js";
|
|
6
|
+
import { u as useDevPortal, q as useQueryClient, t as useSuspenseQuery } from "./DevPortalProvider-GjdO0Xr-.js";
|
|
7
|
+
import * as React from "react";
|
|
8
|
+
import { useState } from "react";
|
|
9
9
|
/**
|
|
10
10
|
* @license lucide-react v0.378.0 - ISC
|
|
11
11
|
*
|
|
12
12
|
* This source code is licensed under the ISC license.
|
|
13
13
|
* See the LICENSE file in the root directory of this source tree.
|
|
14
14
|
*/
|
|
15
|
-
const
|
|
15
|
+
const EyeOff = createLucideIcon("EyeOff", [
|
|
16
16
|
["path", { d: "M9.88 9.88a3 3 0 1 0 4.24 4.24", key: "1jxqfv" }],
|
|
17
17
|
[
|
|
18
18
|
"path",
|
|
@@ -33,7 +33,7 @@ const I = l("EyeOff", [
|
|
|
33
33
|
* This source code is licensed under the ISC license.
|
|
34
34
|
* See the LICENSE file in the root directory of this source tree.
|
|
35
35
|
*/
|
|
36
|
-
const
|
|
36
|
+
const Eye = createLucideIcon("Eye", [
|
|
37
37
|
["path", { d: "M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z", key: "rwhkz3" }],
|
|
38
38
|
["circle", { cx: "12", cy: "12", r: "3", key: "1v7zrd" }]
|
|
39
39
|
]);
|
|
@@ -43,7 +43,7 @@ const O = l("Eye", [
|
|
|
43
43
|
* This source code is licensed under the ISC license.
|
|
44
44
|
* See the LICENSE file in the root directory of this source tree.
|
|
45
45
|
*/
|
|
46
|
-
const
|
|
46
|
+
const RotateCw = createLucideIcon("RotateCw", [
|
|
47
47
|
["path", { d: "M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8", key: "1p45f6" }],
|
|
48
48
|
["path", { d: "M21 3v5h-5", key: "1q7to0" }]
|
|
49
49
|
]);
|
|
@@ -53,251 +53,292 @@ const q = l("RotateCw", [
|
|
|
53
53
|
* This source code is licensed under the ISC license.
|
|
54
54
|
* See the LICENSE file in the root directory of this source tree.
|
|
55
55
|
*/
|
|
56
|
-
const
|
|
56
|
+
const Trash = createLucideIcon("Trash", [
|
|
57
57
|
["path", { d: "M3 6h18", key: "d0wm0j" }],
|
|
58
58
|
["path", { d: "M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6", key: "4alrt4" }],
|
|
59
59
|
["path", { d: "M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2", key: "v07s0e" }]
|
|
60
60
|
]);
|
|
61
|
-
var
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
var a = typeof r == "function" ? r() : r, n = a ? "".concat(d, ": ").concat(a) : d;
|
|
67
|
-
throw new Error(n);
|
|
61
|
+
var isProduction = process.env.NODE_ENV === "production";
|
|
62
|
+
var prefix = "Invariant failed";
|
|
63
|
+
function invariant(condition, message) {
|
|
64
|
+
if (condition) {
|
|
65
|
+
return;
|
|
68
66
|
}
|
|
67
|
+
if (isProduction) {
|
|
68
|
+
throw new Error(prefix);
|
|
69
|
+
}
|
|
70
|
+
var provided = typeof message === "function" ? message() : message;
|
|
71
|
+
var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
|
|
72
|
+
throw new Error(value);
|
|
69
73
|
}
|
|
70
|
-
const
|
|
71
|
-
({ className
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
74
|
+
const Input = React.forwardRef(
|
|
75
|
+
({ className, type, ...props }, ref) => {
|
|
76
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
77
|
+
"input",
|
|
78
|
+
{
|
|
79
|
+
type,
|
|
80
|
+
className: cn(
|
|
81
|
+
"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
|
|
82
|
+
className
|
|
83
|
+
),
|
|
84
|
+
ref,
|
|
85
|
+
...props
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
}
|
|
83
89
|
);
|
|
84
|
-
|
|
85
|
-
const
|
|
86
|
-
const
|
|
90
|
+
Input.displayName = "Input";
|
|
91
|
+
const CreateApiKey = ({ service }) => {
|
|
92
|
+
const context = useDevPortal();
|
|
93
|
+
const navigate = useNavigate();
|
|
94
|
+
const form = useForm({
|
|
87
95
|
defaultValues: {
|
|
88
96
|
expiresOn: "30"
|
|
89
97
|
}
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
|
|
98
|
+
});
|
|
99
|
+
const createKeyMutation = useMutation({
|
|
100
|
+
mutationFn: ({ description, expiresOn }) => {
|
|
101
|
+
if (!service.createKey) {
|
|
93
102
|
throw new Error("deleteKey not implemented");
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
103
|
+
}
|
|
104
|
+
const expiresOnDate = expiresOn !== "never" ? addDaysToDate(Number(expiresOn)) : void 0;
|
|
105
|
+
return service.createKey(
|
|
106
|
+
{ description, expiresOn: expiresOnDate },
|
|
107
|
+
context
|
|
98
108
|
);
|
|
99
109
|
},
|
|
100
|
-
onSuccess: () =>
|
|
110
|
+
onSuccess: () => navigate("/settings/api-keys/")
|
|
101
111
|
});
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
112
|
+
if (!service.createKey) {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "max-w-screen-lg pt-[--padding-content-top] pb-[--padding-content-bottom]", children: [
|
|
116
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex justify-between mb-4 border-b border-border pb-1", children: /* @__PURE__ */ jsxRuntimeExports.jsx("h1", { className: "font-medium text-2xl", children: "New API Key" }) }),
|
|
117
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
105
118
|
"form",
|
|
106
119
|
{
|
|
107
|
-
onSubmit:
|
|
108
|
-
children: /* @__PURE__ */
|
|
120
|
+
onSubmit: form.handleSubmit((data) => createKeyMutation.mutate(data)),
|
|
121
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2 flex-col", children: [
|
|
109
122
|
"Note",
|
|
110
|
-
/* @__PURE__ */
|
|
123
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Input, { ...form.register("description") }),
|
|
111
124
|
"Expiration",
|
|
112
|
-
/* @__PURE__ */
|
|
113
|
-
|
|
125
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
126
|
+
Select,
|
|
114
127
|
{
|
|
115
|
-
onValueChange: (
|
|
116
|
-
defaultValue:
|
|
128
|
+
onValueChange: (value) => form.setValue("expiresOn", value),
|
|
129
|
+
defaultValue: form.getValues("expiresOn"),
|
|
117
130
|
children: [
|
|
118
|
-
/* @__PURE__ */
|
|
119
|
-
/* @__PURE__ */
|
|
120
|
-
[7, 30, 60, 90].map((
|
|
121
|
-
|
|
131
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(SelectTrigger, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(SelectValue, {}) }),
|
|
132
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(SelectContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(SelectGroup, { children: [
|
|
133
|
+
[7, 30, 60, 90].map((option) => /* @__PURE__ */ jsxRuntimeExports.jsxs(SelectItem, { value: String(option), children: [
|
|
134
|
+
option,
|
|
122
135
|
" days"
|
|
123
|
-
] },
|
|
124
|
-
/* @__PURE__ */
|
|
136
|
+
] }, option)),
|
|
137
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(SelectItem, { value: "never", children: "Never" })
|
|
125
138
|
] }) })
|
|
126
139
|
]
|
|
127
140
|
}
|
|
128
141
|
),
|
|
129
|
-
/* @__PURE__ */
|
|
130
|
-
/* @__PURE__ */
|
|
131
|
-
/* @__PURE__ */
|
|
142
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [
|
|
143
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Button, { children: "Generate Key" }),
|
|
144
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "outline", asChild: true, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Link, { to: "/settings/api-keys/", children: "Cancel" }) })
|
|
132
145
|
] })
|
|
133
146
|
] })
|
|
134
147
|
}
|
|
135
148
|
)
|
|
136
|
-
] })
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
149
|
+
] });
|
|
150
|
+
};
|
|
151
|
+
const addDaysToDate = (days) => {
|
|
152
|
+
const date = /* @__PURE__ */ new Date();
|
|
153
|
+
date.setDate(date.getDate() + days);
|
|
154
|
+
return date.toISOString();
|
|
155
|
+
};
|
|
156
|
+
const SettingsApiKeys = ({ service }) => {
|
|
157
|
+
const context = useDevPortal();
|
|
158
|
+
const queryClient = useQueryClient();
|
|
159
|
+
const { data } = useSuspenseQuery({
|
|
160
|
+
queryFn: () => service.getKeys(context),
|
|
143
161
|
queryKey: ["api-keys"],
|
|
144
|
-
retry:
|
|
145
|
-
})
|
|
146
|
-
|
|
147
|
-
|
|
162
|
+
retry: false
|
|
163
|
+
});
|
|
164
|
+
const deleteKeyMutation = useMutation({
|
|
165
|
+
mutationFn: (id) => {
|
|
166
|
+
if (!service.deleteKey) {
|
|
148
167
|
throw new Error("deleteKey not implemented");
|
|
149
|
-
|
|
168
|
+
}
|
|
169
|
+
return service.deleteKey(id, context);
|
|
150
170
|
},
|
|
151
171
|
onSuccess: () => {
|
|
152
|
-
|
|
172
|
+
void queryClient.invalidateQueries({ queryKey: ["api-keys"] });
|
|
153
173
|
}
|
|
154
174
|
});
|
|
155
|
-
return /* @__PURE__ */
|
|
156
|
-
/* @__PURE__ */
|
|
157
|
-
/* @__PURE__ */
|
|
158
|
-
|
|
175
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "max-w-screen-lg h-full pt-[--padding-content-top] pb-[--padding-content-bottom]", children: [
|
|
176
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between mb-4 border-b border-border pb-3", children: [
|
|
177
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("h1", { className: "font-medium text-2xl", children: "API Keys" }),
|
|
178
|
+
service.createKey && /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { asChild: true, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Link, { to: "/settings/api-keys/new", children: "Create API Key" }) })
|
|
159
179
|
] }),
|
|
160
|
-
|
|
161
|
-
/* @__PURE__ */
|
|
180
|
+
data.length === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col justify-center gap-4 items-center h-1/2 my-8", children: [
|
|
181
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-center", children: [
|
|
162
182
|
"No API keys created yet.",
|
|
163
|
-
/* @__PURE__ */
|
|
183
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
|
|
164
184
|
"Get started and create the first one now"
|
|
165
185
|
] }),
|
|
166
|
-
|
|
167
|
-
] }) : /* @__PURE__ */
|
|
186
|
+
service.createKey && /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { asChild: true, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Link, { to: "/settings/api-keys/new", children: "Create API Key" }) })
|
|
187
|
+
] }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
168
188
|
"ul",
|
|
169
189
|
{
|
|
170
|
-
className:
|
|
190
|
+
className: cn(
|
|
171
191
|
"grid grid-cols-1 rounded border-border border",
|
|
172
192
|
"lg:grid-cols-[minmax(250px,min-content)_1fr_min-content]"
|
|
173
193
|
),
|
|
174
|
-
children:
|
|
194
|
+
children: data.map((key) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
175
195
|
"li",
|
|
176
196
|
{
|
|
177
197
|
className: "border-b border-border p-5 grid grid-cols-subgrid col-span-full gap-2 items-center",
|
|
178
198
|
children: [
|
|
179
|
-
/* @__PURE__ */
|
|
180
|
-
|
|
181
|
-
/* @__PURE__ */
|
|
182
|
-
|
|
199
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1 text-sm", children: [
|
|
200
|
+
key.description ?? key.id,
|
|
201
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-muted-foreground text-xs", children: [
|
|
202
|
+
key.createdOn && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
183
203
|
"Created on ",
|
|
184
|
-
new Date(
|
|
204
|
+
new Date(key.createdOn).toLocaleDateString()
|
|
185
205
|
] }),
|
|
186
|
-
|
|
206
|
+
key.expiresOn && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
187
207
|
"Expires on ",
|
|
188
|
-
new Date(
|
|
208
|
+
new Date(key.expiresOn).toLocaleDateString()
|
|
189
209
|
] })
|
|
190
210
|
] })
|
|
191
211
|
] }),
|
|
192
|
-
/* @__PURE__ */
|
|
193
|
-
/* @__PURE__ */
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
212
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "items-center flex lg:justify-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(RevealApiKey, { apiKey: key.key }) }),
|
|
213
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [
|
|
214
|
+
service.rollKey && /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { size: "icon", children: /* @__PURE__ */ jsxRuntimeExports.jsx(RotateCw, { size: 16 }) }),
|
|
215
|
+
service.deleteKey && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
216
|
+
Button,
|
|
197
217
|
{
|
|
198
218
|
variant: "ghost",
|
|
199
219
|
size: "icon",
|
|
200
220
|
onClick: () => {
|
|
201
|
-
confirm("Do you want to delete this key?")
|
|
221
|
+
if (!confirm("Do you want to delete this key?")) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
deleteKeyMutation.mutate(key.id);
|
|
202
225
|
},
|
|
203
|
-
disabled:
|
|
204
|
-
children: /* @__PURE__ */
|
|
226
|
+
disabled: deleteKeyMutation.isPending,
|
|
227
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Trash, { size: 16 })
|
|
205
228
|
}
|
|
206
229
|
)
|
|
207
230
|
] })
|
|
208
231
|
]
|
|
209
232
|
},
|
|
210
|
-
|
|
233
|
+
key.id
|
|
211
234
|
))
|
|
212
235
|
}
|
|
213
236
|
)
|
|
214
237
|
] });
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
238
|
+
};
|
|
239
|
+
const RevealApiKey = ({ apiKey }) => {
|
|
240
|
+
const [revealed, setRevealed] = useState(false);
|
|
241
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2 items-center text-sm w-full", children: [
|
|
242
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
219
243
|
"input",
|
|
220
244
|
{
|
|
221
245
|
className: "border border-border rounded bg-gray-100 dark:bg-gray-950 p-1 font-mono max-w-min",
|
|
222
|
-
value:
|
|
246
|
+
value: revealed ? apiKey : "•".repeat(apiKey.length)
|
|
223
247
|
}
|
|
224
248
|
),
|
|
225
|
-
/* @__PURE__ */
|
|
226
|
-
|
|
249
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
250
|
+
Button,
|
|
227
251
|
{
|
|
228
252
|
variant: "outline",
|
|
229
|
-
onClick: () =>
|
|
253
|
+
onClick: () => setRevealed((prev) => !prev),
|
|
230
254
|
size: "icon",
|
|
231
|
-
children:
|
|
255
|
+
children: revealed ? /* @__PURE__ */ jsxRuntimeExports.jsx(EyeOff, { size: 16 }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Eye, { size: 16 })
|
|
232
256
|
}
|
|
233
257
|
)
|
|
234
258
|
] });
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
259
|
+
};
|
|
260
|
+
const DEFAULT_API_KEY_ENDPOINT = "https://zudoku-rewiringamerica-main-ef9c9c0.d2.zuplo.dev";
|
|
261
|
+
const createDefaultHandler = (endpoint) => {
|
|
262
|
+
return {
|
|
263
|
+
deleteKey: async (id, context) => {
|
|
264
|
+
const request = new Request(endpoint + `/v1/developer/api-keys/${id}`, {
|
|
265
|
+
method: "DELETE"
|
|
266
|
+
});
|
|
267
|
+
await context.signRequest(request);
|
|
268
|
+
const response = await fetch(request);
|
|
269
|
+
invariant(response.ok, "Failed to delete API key");
|
|
270
|
+
},
|
|
271
|
+
createKey: async (apiKey, context) => {
|
|
272
|
+
const request = new Request(endpoint + `/v1/developer/api-keys`, {
|
|
273
|
+
method: "POST",
|
|
274
|
+
headers: {
|
|
275
|
+
"Content-Type": "application/json"
|
|
276
|
+
},
|
|
277
|
+
body: JSON.stringify(apiKey)
|
|
278
|
+
});
|
|
279
|
+
await context.signRequest(request);
|
|
280
|
+
const response = await fetch(request);
|
|
281
|
+
invariant(response.ok, "Failed to create API key");
|
|
282
|
+
},
|
|
283
|
+
getKeys: async (context) => {
|
|
284
|
+
const request = new Request(endpoint + `/v1/developer/api-keys`);
|
|
285
|
+
await context.signRequest(request);
|
|
286
|
+
const keys = await fetch(request);
|
|
287
|
+
invariant(keys.ok, "Failed to fetch API keys");
|
|
288
|
+
return await keys.json();
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
};
|
|
292
|
+
const ProtectedRoute = () => {
|
|
293
|
+
const auth = useAuth();
|
|
294
|
+
if (auth.isPending) {
|
|
295
|
+
return null;
|
|
261
296
|
}
|
|
262
|
-
})
|
|
263
|
-
const t = w();
|
|
264
|
-
return t.isPending ? null : t.isAuthenticated ? /* @__PURE__ */ e.jsx(v, {}) : /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col justify-center gap-2 items-center h-1/2 my-12", children: [
|
|
297
|
+
return auth.isAuthenticated ? /* @__PURE__ */ jsxRuntimeExports.jsx(Outlet, {}) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col justify-center gap-2 items-center h-1/2 my-12", children: [
|
|
265
298
|
"Please login first to view this page",
|
|
266
|
-
/* @__PURE__ */
|
|
299
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Button, { onClick: () => auth.login(), children: "Login" })
|
|
267
300
|
] });
|
|
268
|
-
}
|
|
269
|
-
|
|
301
|
+
};
|
|
302
|
+
const apiKeyPlugin = (options) => {
|
|
303
|
+
const endpoint = "endpoint" in options ? options.endpoint : DEFAULT_API_KEY_ENDPOINT;
|
|
304
|
+
const service = "getKeys" in options ? options : createDefaultHandler(endpoint);
|
|
270
305
|
return {
|
|
271
|
-
getIdentities: async (
|
|
306
|
+
getIdentities: async (context) => {
|
|
272
307
|
try {
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
308
|
+
const keys = await service.getKeys(context);
|
|
309
|
+
return keys.map((key) => ({
|
|
310
|
+
authorizeRequest: (request) => {
|
|
311
|
+
request.headers.set("Authorization", `Bearer ${key.key}`);
|
|
312
|
+
return request;
|
|
313
|
+
},
|
|
314
|
+
id: key.id,
|
|
315
|
+
label: key.description ?? key.id
|
|
277
316
|
}));
|
|
278
317
|
} catch {
|
|
279
318
|
return [];
|
|
280
319
|
}
|
|
281
320
|
},
|
|
282
|
-
getRoutes: () =>
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
321
|
+
getRoutes: () => {
|
|
322
|
+
return [
|
|
323
|
+
{
|
|
324
|
+
element: /* @__PURE__ */ jsxRuntimeExports.jsx(ProtectedRoute, {}),
|
|
325
|
+
errorElement: /* @__PURE__ */ jsxRuntimeExports.jsx(RouterError, {}),
|
|
326
|
+
children: [
|
|
327
|
+
{
|
|
328
|
+
path: "/settings/api-keys",
|
|
329
|
+
element: /* @__PURE__ */ jsxRuntimeExports.jsx(SettingsApiKeys, { service })
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
path: "/settings/api-keys/new",
|
|
333
|
+
element: /* @__PURE__ */ jsxRuntimeExports.jsx(CreateApiKey, { service })
|
|
334
|
+
}
|
|
335
|
+
]
|
|
336
|
+
}
|
|
337
|
+
];
|
|
338
|
+
}
|
|
298
339
|
};
|
|
299
340
|
};
|
|
300
341
|
export {
|
|
301
|
-
|
|
342
|
+
apiKeyPlugin
|
|
302
343
|
};
|
|
303
344
|
//# sourceMappingURL=zudoku.plugin-api-keys.js.map
|