zudoku 0.66.2 → 0.66.3

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.
Files changed (161) hide show
  1. package/dist/config/validators/validate.d.ts +32 -3
  2. package/dist/config/validators/validate.js +1 -1
  3. package/dist/config/validators/validate.js.map +1 -1
  4. package/dist/flat-config.d.ts +1 -1
  5. package/dist/lib/auth/issuer.js +1 -1
  6. package/dist/lib/auth/issuer.js.map +1 -1
  7. package/dist/lib/authentication/authentication.d.ts +3 -2
  8. package/dist/lib/authentication/hook.d.ts +2 -0
  9. package/dist/lib/authentication/hook.js +10 -0
  10. package/dist/lib/authentication/hook.js.map +1 -1
  11. package/dist/lib/authentication/providers/firebase.js +67 -9
  12. package/dist/lib/authentication/providers/firebase.js.map +1 -1
  13. package/dist/lib/authentication/ui/EmailVerificationUi.d.ts +4 -0
  14. package/dist/lib/authentication/ui/EmailVerificationUi.js +34 -0
  15. package/dist/lib/authentication/ui/EmailVerificationUi.js.map +1 -0
  16. package/dist/lib/authentication/ui/ZudokuAuthUi.d.ts +7 -2
  17. package/dist/lib/authentication/ui/ZudokuAuthUi.js +43 -11
  18. package/dist/lib/authentication/ui/ZudokuAuthUi.js.map +1 -1
  19. package/dist/lib/authentication/utils/relativeRedirectUrl.d.ts +1 -0
  20. package/dist/lib/authentication/utils/relativeRedirectUrl.js +8 -0
  21. package/dist/lib/authentication/utils/relativeRedirectUrl.js.map +1 -0
  22. package/dist/lib/components/index.d.ts +2 -0
  23. package/dist/lib/errors/ErrorMessage.d.ts +3 -0
  24. package/dist/lib/errors/ErrorMessage.js +16 -0
  25. package/dist/lib/errors/ErrorMessage.js.map +1 -0
  26. package/dist/lib/hooks/index.d.ts +2 -0
  27. package/dist/lib/plugins/api-keys/SettingsApiKeys.js +9 -172
  28. package/dist/lib/plugins/api-keys/SettingsApiKeys.js.map +1 -1
  29. package/dist/lib/plugins/api-keys/index.d.ts +4 -1
  30. package/dist/lib/plugins/api-keys/index.js +19 -14
  31. package/dist/lib/plugins/api-keys/index.js.map +1 -1
  32. package/dist/lib/plugins/api-keys/settings/ApiKeyItem.d.ts +12 -0
  33. package/dist/lib/plugins/api-keys/settings/ApiKeyItem.js +133 -0
  34. package/dist/lib/plugins/api-keys/settings/ApiKeyItem.js.map +1 -0
  35. package/dist/lib/plugins/api-keys/settings/ApiKeyList.d.ts +4 -0
  36. package/dist/lib/plugins/api-keys/settings/ApiKeyList.js +30 -0
  37. package/dist/lib/plugins/api-keys/settings/ApiKeyList.js.map +1 -0
  38. package/dist/lib/plugins/api-keys/settings/RevealApiKey.d.ts +6 -0
  39. package/dist/lib/plugins/api-keys/settings/RevealApiKey.js +39 -0
  40. package/dist/lib/plugins/api-keys/settings/RevealApiKey.js.map +1 -0
  41. package/dist/vite/config.js +7 -0
  42. package/dist/vite/config.js.map +1 -1
  43. package/dist/vite/plugin-api-keys.js +4 -1
  44. package/dist/vite/plugin-api-keys.js.map +1 -1
  45. package/dist/vite/zuplo.d.ts +13 -0
  46. package/dist/vite/zuplo.js +15 -0
  47. package/dist/vite/zuplo.js.map +1 -0
  48. package/lib/{ClaudeLogo-CGRfGTk2.js → ClaudeLogo-BZslN9XF.js} +3 -3
  49. package/lib/{ClaudeLogo-CGRfGTk2.js.map → ClaudeLogo-BZslN9XF.js.map} +1 -1
  50. package/lib/{Drawer-Ci7XwhqT.js → Drawer-BRMcpfuF.js} +6 -6
  51. package/lib/{Drawer-Ci7XwhqT.js.map → Drawer-BRMcpfuF.js.map} +1 -1
  52. package/lib/Frame-DxlznfVd.js +205 -0
  53. package/lib/Frame-DxlznfVd.js.map +1 -0
  54. package/lib/{useMutation-C6RqWmTS.js → Input-D-kqEQ5M.js} +41 -23
  55. package/lib/Input-D-kqEQ5M.js.map +1 -0
  56. package/lib/{MdxPage-Bjf72BP3.js → MdxPage-B4zZq5aR.js} +8 -8
  57. package/lib/{MdxPage-Bjf72BP3.js.map → MdxPage-B4zZq5aR.js.map} +1 -1
  58. package/lib/{Mermaid-D_VSX7_Q.js → Mermaid-BjSczjLW.js} +3 -3
  59. package/lib/{Mermaid-D_VSX7_Q.js.map → Mermaid-BjSczjLW.js.map} +1 -1
  60. package/lib/{OAuthErrorPage-1Ekji0PK.js → OAuthErrorPage-DRY2hlga.js} +20 -21
  61. package/lib/{OAuthErrorPage-1Ekji0PK.js.map → OAuthErrorPage-DRY2hlga.js.map} +1 -1
  62. package/lib/{OasProvider-BZxmTyMM.js → OasProvider-lMwTD76Y.js} +4 -4
  63. package/lib/{OasProvider-BZxmTyMM.js.map → OasProvider-lMwTD76Y.js.map} +1 -1
  64. package/lib/{OperationList-B7nPIFB8.js → OperationList-Bm76b4vl.js} +23 -24
  65. package/lib/{OperationList-B7nPIFB8.js.map → OperationList-Bm76b4vl.js.map} +1 -1
  66. package/lib/{RouteGuard-9wjejsKm.js → RouteGuard-DGc32XJV.js} +4 -4
  67. package/lib/{RouteGuard-9wjejsKm.js.map → RouteGuard-DGc32XJV.js.map} +1 -1
  68. package/lib/{SchemaList-16_obkku.js → SchemaList-DX4FPogg.js} +7 -7
  69. package/lib/{SchemaList-16_obkku.js.map → SchemaList-DX4FPogg.js.map} +1 -1
  70. package/lib/SchemaView-CjXvSRxy.js +434 -0
  71. package/lib/SchemaView-CjXvSRxy.js.map +1 -0
  72. package/lib/{Select-CkxXP5I7.js → Secret-BxGpIhDP.js} +121 -121
  73. package/lib/Secret-BxGpIhDP.js.map +1 -0
  74. package/lib/{SignUp-D54_QWFy.js → SignUp-CntxjFGS.js} +4 -4
  75. package/lib/{SignUp-D54_QWFy.js.map → SignUp-CntxjFGS.js.map} +1 -1
  76. package/lib/{SyntaxHighlight-j_HRSPCU.js → SyntaxHighlight-Dgd0AaaX.js} +2 -2
  77. package/lib/{SyntaxHighlight-j_HRSPCU.js.map → SyntaxHighlight-Dgd0AaaX.js.map} +1 -1
  78. package/lib/{Toc-z05x698-.js → Toc-L1vGGHA1.js} +2 -2
  79. package/lib/{Toc-z05x698-.js.map → Toc-L1vGGHA1.js.map} +1 -1
  80. package/lib/{ZudokuContext-BXldanA8.js → ZudokuContext-DNHMZfcP.js} +33 -33
  81. package/lib/{ZudokuContext-BXldanA8.js.map → ZudokuContext-DNHMZfcP.js.map} +1 -1
  82. package/lib/{chunk-PVWAREVJ-dLIqswPy.js → chunk-PVWAREVJ-ClM0m2aJ.js} +19 -19
  83. package/lib/{chunk-PVWAREVJ-dLIqswPy.js.map → chunk-PVWAREVJ-ClM0m2aJ.js.map} +1 -1
  84. package/lib/{circular-D5sYCIWL.js → circular-BIN_WQ0c.js} +2 -2
  85. package/lib/{circular-D5sYCIWL.js.map → circular-BIN_WQ0c.js.map} +1 -1
  86. package/lib/{createServer-BlwU7lIr.js → createServer-BEl12QFw.js} +4 -4
  87. package/lib/{createServer-BlwU7lIr.js.map → createServer-BEl12QFw.js.map} +1 -1
  88. package/lib/createVariantComponent-CQVt-H3r.js +18 -0
  89. package/lib/createVariantComponent-CQVt-H3r.js.map +1 -0
  90. package/lib/{errors-BtC4Kn2j.js → errors-CtBbD47A.js} +2 -2
  91. package/lib/{errors-BtC4Kn2j.js.map → errors-CtBbD47A.js.map} +1 -1
  92. package/lib/{firebase-Ibm_tv3G.js → firebase-CT38ugg4.js} +1588 -1342
  93. package/lib/firebase-CT38ugg4.js.map +1 -0
  94. package/lib/hook-CHw_R_xu.js +52 -0
  95. package/lib/hook-CHw_R_xu.js.map +1 -0
  96. package/lib/{ErrorAlert-BUlG32M9.js → index-CG2v-T7-.js} +5373 -4335
  97. package/lib/index-CG2v-T7-.js.map +1 -0
  98. package/lib/{index-eKVhlB94.js → index-CISwSpdT.js} +2 -2
  99. package/lib/{index-eKVhlB94.js.map → index-CISwSpdT.js.map} +1 -1
  100. package/lib/{index-Css56y3F.js → index-DXXZDuSJ.js} +4 -4
  101. package/lib/{index-Css56y3F.js.map → index-DXXZDuSJ.js.map} +1 -1
  102. package/lib/{index-CeVTNcfF.js → index-jI2Fjpy-.js} +98 -99
  103. package/lib/{index-CeVTNcfF.js.map → index-jI2Fjpy-.js.map} +1 -1
  104. package/lib/{index.esm-BoKBnRoT.js → index.esm-Bu35TNgg.js} +16 -14
  105. package/lib/index.esm-Bu35TNgg.js.map +1 -0
  106. package/lib/{mutation-BoVlx8yA.js → mutation-DMHWqmFp.js} +2 -2
  107. package/lib/{mutation-BoVlx8yA.js.map → mutation-DMHWqmFp.js.map} +1 -1
  108. package/lib/ui/Drawer.js +2 -2
  109. package/lib/ui/SyntaxHighlight.js +2 -2
  110. package/lib/zudoku.__internal.js +507 -479
  111. package/lib/zudoku.__internal.js.map +1 -1
  112. package/lib/zudoku.auth-auth0.js +1 -1
  113. package/lib/zudoku.auth-azureb2c.js +4 -4
  114. package/lib/zudoku.auth-clerk.js +2 -2
  115. package/lib/zudoku.auth-firebase.js +6 -5
  116. package/lib/zudoku.auth-firebase.js.map +1 -1
  117. package/lib/zudoku.auth-openid.js +4 -4
  118. package/lib/zudoku.auth-supabase.js +5 -5
  119. package/lib/zudoku.components.js +20 -21
  120. package/lib/zudoku.components.js.map +1 -1
  121. package/lib/zudoku.hooks.js +3 -3
  122. package/lib/zudoku.mermaid.js +3 -3
  123. package/lib/zudoku.plugin-api-catalog.js +8 -9
  124. package/lib/zudoku.plugin-api-catalog.js.map +1 -1
  125. package/lib/zudoku.plugin-api-keys.js +580 -543
  126. package/lib/zudoku.plugin-api-keys.js.map +1 -1
  127. package/lib/zudoku.plugin-custom-pages.js +1 -1
  128. package/lib/zudoku.plugin-markdown.js +1 -1
  129. package/lib/zudoku.plugin-openapi.js +3 -3
  130. package/lib/zudoku.plugin-redirect.js +1 -1
  131. package/lib/zudoku.plugin-search-pagefind.js +3 -3
  132. package/lib/zudoku.router.js +2 -2
  133. package/package.json +4 -2
  134. package/src/lib/auth/issuer.ts +1 -1
  135. package/src/lib/authentication/authentication.ts +8 -2
  136. package/src/lib/authentication/hook.ts +16 -0
  137. package/src/lib/authentication/providers/firebase.tsx +98 -6
  138. package/src/lib/authentication/ui/EmailVerificationUi.tsx +129 -0
  139. package/src/lib/authentication/ui/ZudokuAuthUi.tsx +170 -38
  140. package/src/lib/authentication/utils/relativeRedirectUrl.ts +12 -0
  141. package/src/lib/errors/ErrorMessage.tsx +38 -0
  142. package/src/lib/plugins/api-keys/SettingsApiKeys.tsx +36 -476
  143. package/src/lib/plugins/api-keys/index.tsx +33 -18
  144. package/src/lib/plugins/api-keys/settings/ApiKeyItem.tsx +342 -0
  145. package/src/lib/plugins/api-keys/settings/ApiKeyList.tsx +64 -0
  146. package/src/lib/plugins/api-keys/settings/RevealApiKey.tsx +124 -0
  147. package/lib/ErrorAlert-BUlG32M9.js.map +0 -1
  148. package/lib/RouterError-DfTZblpv.js +0 -42
  149. package/lib/RouterError-DfTZblpv.js.map +0 -1
  150. package/lib/SchemaView-eyvR4bRt.js +0 -597
  151. package/lib/SchemaView-eyvR4bRt.js.map +0 -1
  152. package/lib/Select-CkxXP5I7.js.map +0 -1
  153. package/lib/createVariantComponent-B9_dVBvu.js +0 -35
  154. package/lib/createVariantComponent-B9_dVBvu.js.map +0 -1
  155. package/lib/firebase-Ibm_tv3G.js.map +0 -1
  156. package/lib/hook-BNxidGQq.js +0 -40
  157. package/lib/hook-BNxidGQq.js.map +0 -1
  158. package/lib/index-DSOi7zVM.js +0 -1059
  159. package/lib/index-DSOi7zVM.js.map +0 -1
  160. package/lib/index.esm-BoKBnRoT.js.map +0 -1
  161. package/lib/useMutation-C6RqWmTS.js.map +0 -1
@@ -1,81 +1,177 @@
1
1
  import { j as e } from "./jsx-runtime-BzflLqGi.js";
2
- import { CircleSlashIcon as $, CheckIcon as ue, XIcon as fe, PencilLineIcon as he, RefreshCwIcon as pe, TrashIcon as me, KeyRoundIcon as xe } from "lucide-react";
3
- import { R as ye } from "./RouterError-DfTZblpv.js";
4
- import { i as A } from "./invariant-CGOLuIIz.js";
5
- import { O as ge, u as je } from "./chunk-PVWAREVJ-dLIqswPy.js";
6
- import { u as Ce } from "./hook-BNxidGQq.js";
7
- import { D as ve, a as Y } from "./ErrorAlert-BUlG32M9.js";
8
- import { Button as v } from "./ui/Button.js";
9
- import { a as ne, f as ie, e as we } from "./ZudokuContext-BXldanA8.js";
10
- import { u as T } from "./useMutation-C6RqWmTS.js";
2
+ import { TrashIcon as pe, CircleSlashIcon as F, CheckIcon as me, XIcon as xe, PencilLineIcon as ye, RefreshCwIcon as ge, KeyRoundIcon as je } from "lucide-react";
3
+ import { Z as $, i as N } from "./invariant-CGOLuIIz.js";
11
4
  import * as q from "react";
12
- import ke, { createContext as Q, useRef as N, useLayoutEffect as be, useEffect as re, useId as _, useContext as H, useInsertionEffect as Ke, useMemo as F, useCallback as Ee, Children as De, isValidElement as Ne, useState as D } from "react";
13
- import { A as O, a as M, b as Pe } from "./Mermaid-D_VSX7_Q.js";
14
- import { C as Ae, a as Ie } from "./Card-KFniaZn5.js";
15
- import { e as V, f as P, D as B, g as G, a as J, b as U, c as W, d as ae } from "./Dialog-BQciPiHN.js";
16
- import { S as Re, a as Se, b as Te, c as Oe, d as Me, e as Z, f as qe } from "./Select-CkxXP5I7.js";
17
- import { Input as oe } from "./ui/Input.js";
18
- import { c as L } from "./cn-dYga0KKN.js";
19
- import { a as ze } from "./index.esm-BYObtETB.js";
20
- import { A as $e } from "./ActionButton-DUgvSylL.js";
21
- import { b as Fe } from "./index-Css56y3F.js";
22
- const Le = () => {
23
- const t = Ce();
24
- return t.isAuthEnabled && t.isPending ? null : t.isAuthEnabled ? t.isAuthenticated ? /* @__PURE__ */ e.jsx(ge, {}) : /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col justify-center gap-2 items-center h-1/2", children: [
25
- "Please login first to view this page",
26
- /* @__PURE__ */ e.jsx(v, { onClick: () => t.login(), children: "Login" })
27
- ] }) : /* @__PURE__ */ e.jsx("div", { className: "flex flex-col justify-center gap-2 items-center h-1/2", children: /* @__PURE__ */ e.jsxs(ve, { className: "max-w-[600px]", children: [
28
- "Authentication needs to be enabled for API keys to work. Enable it in your Zudoku configuration under ",
29
- /* @__PURE__ */ e.jsx("code", { children: "authentication" }),
30
- "."
31
- ] }) });
32
- }, Qe = Q({});
33
- function le(t) {
34
- const r = N(null);
35
- return r.current === null && (r.current = t()), r.current;
5
+ import { createContext as L, useRef as P, useLayoutEffect as ve, useEffect as ne, useId as Q, useContext as V, useInsertionEffect as Ce, useMemo as z, useCallback as we, Children as ke, isValidElement as Ee, useState as E } from "react";
6
+ import { D as Ie, c as be, d as Z, B as De, E as Ke } from "./index-CG2v-T7-.js";
7
+ import { b as ie } from "./index-DXXZDuSJ.js";
8
+ import { F as Pe, g as Ae, j as Ne, h as Se, d as Re, I as Oe, a as Te, b as qe, k as Me, c as Fe } from "./Frame-DxlznfVd.js";
9
+ import { A as D, a as K, b as re } from "./Mermaid-BjSczjLW.js";
10
+ import { e as H, f as A, D as _, g as B, a as G, b as J, c as Y, d as ae } from "./Dialog-BQciPiHN.js";
11
+ import { Button as oe } from "./ui/Button.js";
12
+ import { a as U, g as le, e as $e } from "./ZudokuContext-DNHMZfcP.js";
13
+ import { u as T, I as ze } from "./Input-D-kqEQ5M.js";
14
+ import { a as Le } from "./index.esm-BYObtETB.js";
15
+ import { u as Qe } from "./chunk-PVWAREVJ-ClM0m2aJ.js";
16
+ import { A as Ve } from "./ActionButton-DUgvSylL.js";
17
+ import { S as He, a as _e, b as Be, c as Ge, d as Je, e as ee, f as Ye } from "./Secret-BxGpIhDP.js";
18
+ import { Input as Ue } from "./ui/Input.js";
19
+ import { c as W } from "./cn-dYga0KKN.js";
20
+ import { B as k } from "./Button-CynVW1JV.js";
21
+ function We({ error: t }) {
22
+ const i = t instanceof Error ? t.message : "Something went wrong", s = process.env.NODE_ENV === "development", n = t instanceof $ ? t.developerHint : void 0, r = t instanceof $ ? t.title : "Something went wrong", a = t instanceof Error ? t.stack : void 0, o = t instanceof Error ? t.cause : void 0, d = o instanceof Error ? String(o.stack) : a;
23
+ return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
24
+ /* @__PURE__ */ e.jsxs(D, { variant: "destructive", children: [
25
+ /* @__PURE__ */ e.jsx(K, { children: r }),
26
+ /* @__PURE__ */ e.jsx(re, { children: i })
27
+ ] }),
28
+ s && n && /* @__PURE__ */ e.jsx(Ie, { className: "mb-4", children: n }),
29
+ s && d && /* @__PURE__ */ e.jsx(
30
+ be,
31
+ {
32
+ className: "max-h-[400px] [&>pre]:p-4",
33
+ language: "js",
34
+ code: d
35
+ }
36
+ )
37
+ ] });
38
+ }
39
+ const Xe = ({
40
+ service: t,
41
+ onOpenChange: i
42
+ }) => {
43
+ const s = U(), n = le(), r = Qe(), a = Le({
44
+ defaultValues: {
45
+ expiresOn: "30"
46
+ }
47
+ }), o = ie(), d = T({
48
+ mutationFn: ({ description: c, expiresOn: u }) => {
49
+ if (!t.createKey)
50
+ throw new Error("createKey not implemented");
51
+ const h = u !== "never" ? Ze(Number(u)) : void 0;
52
+ return t.createKey({
53
+ apiKey: {
54
+ description: c || "Secret Key",
55
+ expiresOn: h
56
+ },
57
+ context: s,
58
+ auth: o
59
+ });
60
+ },
61
+ onSuccess: async () => {
62
+ await n.invalidateQueries({ queryKey: ["api-keys"] }), await r("/settings/api-keys/");
63
+ }
64
+ });
65
+ return t.createKey ? /* @__PURE__ */ e.jsxs(
66
+ "form",
67
+ {
68
+ onSubmit: a.handleSubmit(
69
+ (c) => d.mutate(
70
+ { ...c },
71
+ {
72
+ onSuccess: () => i(!1)
73
+ }
74
+ )
75
+ ),
76
+ children: [
77
+ d.error && /* @__PURE__ */ e.jsxs(D, { variant: "destructive", className: "mb-4", children: [
78
+ /* @__PURE__ */ e.jsx(K, { children: "Error" }),
79
+ /* @__PURE__ */ e.jsx(re, { children: d.error.message })
80
+ ] }),
81
+ /* @__PURE__ */ e.jsxs("div", { className: "flex gap-2 flex-col text-sm font-medium", children: [
82
+ "Name",
83
+ /* @__PURE__ */ e.jsx(Ue, { ...a.register("description") }),
84
+ "Expiration",
85
+ /* @__PURE__ */ e.jsxs(
86
+ He,
87
+ {
88
+ onValueChange: (c) => a.setValue("expiresOn", c),
89
+ defaultValue: a.getValues("expiresOn"),
90
+ children: [
91
+ /* @__PURE__ */ e.jsx(_e, { children: /* @__PURE__ */ e.jsx(Be, {}) }),
92
+ /* @__PURE__ */ e.jsx(Ge, { children: /* @__PURE__ */ e.jsxs(Je, { children: [
93
+ [7, 30, 60, 90].map((c) => /* @__PURE__ */ e.jsxs(ee, { value: String(c), children: [
94
+ c,
95
+ " days"
96
+ ] }, c)),
97
+ /* @__PURE__ */ e.jsx(ee, { value: "never", children: "Never" })
98
+ ] }) })
99
+ ]
100
+ }
101
+ ),
102
+ /* @__PURE__ */ e.jsxs(H, { children: [
103
+ /* @__PURE__ */ e.jsx(A, { asChild: !0, children: /* @__PURE__ */ e.jsx(oe, { variant: "outline", children: "Cancel" }) }),
104
+ /* @__PURE__ */ e.jsx(Ve, { isPending: d.isPending, children: "Generate Key" })
105
+ ] })
106
+ ] })
107
+ ]
108
+ }
109
+ ) : null;
110
+ }, Ze = (t) => {
111
+ const i = /* @__PURE__ */ new Date();
112
+ return i.setDate(i.getDate() + t), i.toISOString();
113
+ }, ce = ({
114
+ service: t,
115
+ isOpen: i,
116
+ onOpenChange: s,
117
+ trigger: n,
118
+ buttonVariant: r = "outline"
119
+ }) => {
120
+ const a = /* @__PURE__ */ e.jsx(oe, { variant: r, children: "Create API Key" });
121
+ return /* @__PURE__ */ e.jsxs(_, { open: i, onOpenChange: s, children: [
122
+ /* @__PURE__ */ e.jsx(B, { asChild: !0, children: n ?? a }),
123
+ /* @__PURE__ */ e.jsxs(G, { children: [
124
+ /* @__PURE__ */ e.jsx(J, { children: /* @__PURE__ */ e.jsx(Y, { children: "Create API Key" }) }),
125
+ /* @__PURE__ */ e.jsx(Xe, { service: t, onOpenChange: s })
126
+ ] })
127
+ ] });
128
+ }, et = L({});
129
+ function de(t) {
130
+ const i = P(null);
131
+ return i.current === null && (i.current = t()), i.current;
36
132
  }
37
- const _e = typeof window < "u", He = _e ? be : re, ce = /* @__PURE__ */ Q(null);
38
- function Ve(t) {
133
+ const tt = typeof window < "u", st = tt ? ve : ne, ue = /* @__PURE__ */ L(null);
134
+ function nt(t) {
39
135
  return typeof t == "object" && t !== null;
40
136
  }
41
- function Be(t) {
42
- return Ve(t) && "offsetHeight" in t;
137
+ function it(t) {
138
+ return nt(t) && "offsetHeight" in t;
43
139
  }
44
- const Ge = Q({
140
+ const rt = L({
45
141
  transformPagePoint: (t) => t,
46
142
  isStatic: !1,
47
143
  reducedMotion: "never"
48
144
  });
49
- function ee(t, r) {
145
+ function te(t, i) {
50
146
  if (typeof t == "function")
51
- return t(r);
52
- t != null && (t.current = r);
147
+ return t(i);
148
+ t != null && (t.current = i);
53
149
  }
54
- function Je(...t) {
55
- return (r) => {
150
+ function at(...t) {
151
+ return (i) => {
56
152
  let s = !1;
57
- const n = t.map((i) => {
58
- const a = ee(i, r);
153
+ const n = t.map((r) => {
154
+ const a = te(r, i);
59
155
  return !s && typeof a == "function" && (s = !0), a;
60
156
  });
61
157
  if (s)
62
158
  return () => {
63
- for (let i = 0; i < n.length; i++) {
64
- const a = n[i];
65
- typeof a == "function" ? a() : ee(t[i], null);
159
+ for (let r = 0; r < n.length; r++) {
160
+ const a = n[r];
161
+ typeof a == "function" ? a() : te(t[r], null);
66
162
  }
67
163
  };
68
164
  };
69
165
  }
70
- function Ue(...t) {
71
- return q.useCallback(Je(...t), t);
166
+ function ot(...t) {
167
+ return q.useCallback(at(...t), t);
72
168
  }
73
- class We extends q.Component {
74
- getSnapshotBeforeUpdate(r) {
169
+ class lt extends q.Component {
170
+ getSnapshotBeforeUpdate(i) {
75
171
  const s = this.props.childRef.current;
76
- if (s && r.isPresent && !this.props.isPresent) {
77
- const n = s.offsetParent, i = Be(n) && n.offsetWidth || 0, a = this.props.sizeRef.current;
78
- a.height = s.offsetHeight || 0, a.width = s.offsetWidth || 0, a.top = s.offsetTop, a.left = s.offsetLeft, a.right = i - a.width - a.left;
172
+ if (s && i.isPresent && !this.props.isPresent) {
173
+ const n = s.offsetParent, r = it(n) && n.offsetWidth || 0, a = this.props.sizeRef.current;
174
+ a.height = s.offsetHeight || 0, a.width = s.offsetWidth || 0, a.top = s.offsetTop, a.left = s.offsetLeft, a.right = r - a.width - a.left;
79
175
  }
80
176
  return null;
81
177
  }
@@ -88,555 +184,489 @@ class We extends q.Component {
88
184
  return this.props.children;
89
185
  }
90
186
  }
91
- function Xe({ children: t, isPresent: r, anchorX: s, root: n }) {
92
- const i = _(), a = N(null), l = N({
187
+ function ct({ children: t, isPresent: i, anchorX: s, root: n }) {
188
+ const r = Q(), a = P(null), o = P({
93
189
  width: 0,
94
190
  height: 0,
95
191
  top: 0,
96
192
  left: 0,
97
193
  right: 0
98
- }), { nonce: u } = H(Ge), f = Ue(a, t?.ref);
99
- return Ke(() => {
100
- const { width: d, height: y, top: h, left: x, right: p } = l.current;
101
- if (r || !a.current || !d || !y)
194
+ }), { nonce: d } = V(rt), c = ot(a, t?.ref);
195
+ return Ce(() => {
196
+ const { width: u, height: h, top: f, left: m, right: g } = o.current;
197
+ if (i || !a.current || !u || !h)
102
198
  return;
103
- const k = s === "left" ? `left: ${x}` : `right: ${p}`;
104
- a.current.dataset.motionPopId = i;
105
- const m = document.createElement("style");
106
- u && (m.nonce = u);
107
- const K = n ?? document.head;
108
- return K.appendChild(m), m.sheet && m.sheet.insertRule(`
109
- [data-motion-pop-id="${i}"] {
199
+ const j = s === "left" ? `left: ${m}` : `right: ${g}`;
200
+ a.current.dataset.motionPopId = r;
201
+ const l = document.createElement("style");
202
+ d && (l.nonce = d);
203
+ const x = n ?? document.head;
204
+ return x.appendChild(l), l.sheet && l.sheet.insertRule(`
205
+ [data-motion-pop-id="${r}"] {
110
206
  position: absolute !important;
111
- width: ${d}px !important;
112
- height: ${y}px !important;
113
- ${k}px !important;
114
- top: ${h}px !important;
207
+ width: ${u}px !important;
208
+ height: ${h}px !important;
209
+ ${j}px !important;
210
+ top: ${f}px !important;
115
211
  }
116
212
  `), () => {
117
- K.contains(m) && K.removeChild(m);
213
+ x.contains(l) && x.removeChild(l);
118
214
  };
119
- }, [r]), e.jsx(We, { isPresent: r, childRef: a, sizeRef: l, children: q.cloneElement(t, { ref: f }) });
215
+ }, [i]), e.jsx(lt, { isPresent: i, childRef: a, sizeRef: o, children: q.cloneElement(t, { ref: c }) });
120
216
  }
121
- const Ye = ({ children: t, initial: r, isPresent: s, onExitComplete: n, custom: i, presenceAffectsLayout: a, mode: l, anchorX: u, root: f }) => {
122
- const d = le(Ze), y = _();
123
- let h = !0, x = F(() => (h = !1, {
124
- id: y,
125
- initial: r,
217
+ const dt = ({ children: t, initial: i, isPresent: s, onExitComplete: n, custom: r, presenceAffectsLayout: a, mode: o, anchorX: d, root: c }) => {
218
+ const u = de(ut), h = Q();
219
+ let f = !0, m = z(() => (f = !1, {
220
+ id: h,
221
+ initial: i,
126
222
  isPresent: s,
127
- custom: i,
128
- onExitComplete: (p) => {
129
- d.set(p, !0);
130
- for (const k of d.values())
131
- if (!k)
223
+ custom: r,
224
+ onExitComplete: (g) => {
225
+ u.set(g, !0);
226
+ for (const j of u.values())
227
+ if (!j)
132
228
  return;
133
229
  n && n();
134
230
  },
135
- register: (p) => (d.set(p, !1), () => d.delete(p))
136
- }), [s, d, n]);
137
- return a && h && (x = { ...x }), F(() => {
138
- d.forEach((p, k) => d.set(k, !1));
231
+ register: (g) => (u.set(g, !1), () => u.delete(g))
232
+ }), [s, u, n]);
233
+ return a && f && (m = { ...m }), z(() => {
234
+ u.forEach((g, j) => u.set(j, !1));
139
235
  }, [s]), q.useEffect(() => {
140
- !s && !d.size && n && n();
141
- }, [s]), l === "popLayout" && (t = e.jsx(Xe, { isPresent: s, anchorX: u, root: f, children: t })), e.jsx(ce.Provider, { value: x, children: t });
236
+ !s && !u.size && n && n();
237
+ }, [s]), o === "popLayout" && (t = e.jsx(ct, { isPresent: s, anchorX: d, root: c, children: t })), e.jsx(ue.Provider, { value: m, children: t });
142
238
  };
143
- function Ze() {
239
+ function ut() {
144
240
  return /* @__PURE__ */ new Map();
145
241
  }
146
- function et(t = !0) {
147
- const r = H(ce);
148
- if (r === null)
242
+ function ft(t = !0) {
243
+ const i = V(ue);
244
+ if (i === null)
149
245
  return [!0, null];
150
- const { isPresent: s, onExitComplete: n, register: i } = r, a = _();
151
- re(() => {
246
+ const { isPresent: s, onExitComplete: n, register: r } = i, a = Q();
247
+ ne(() => {
152
248
  if (t)
153
- return i(a);
249
+ return r(a);
154
250
  }, [t]);
155
- const l = Ee(() => t && n && n(a), [a, n, t]);
156
- return !s && n ? [!1, l] : [!0];
251
+ const o = we(() => t && n && n(a), [a, n, t]);
252
+ return !s && n ? [!1, o] : [!0];
157
253
  }
158
- const I = (t) => t.key || "";
159
- function te(t) {
160
- const r = [];
161
- return De.forEach(t, (s) => {
162
- Ne(s) && r.push(s);
163
- }), r;
254
+ const S = (t) => t.key || "";
255
+ function se(t) {
256
+ const i = [];
257
+ return ke.forEach(t, (s) => {
258
+ Ee(s) && i.push(s);
259
+ }), i;
164
260
  }
165
- const tt = ({ children: t, custom: r, initial: s = !0, onExitComplete: n, presenceAffectsLayout: i = !0, mode: a = "sync", propagate: l = !1, anchorX: u = "left", root: f }) => {
166
- const [d, y] = et(l), h = F(() => te(t), [t]), x = l && !d ? [] : h.map(I), p = N(!0), k = N(h), m = le(() => /* @__PURE__ */ new Map()), [K, o] = D(h), [c, j] = D(h);
167
- He(() => {
168
- p.current = !1, k.current = h;
169
- for (let C = 0; C < c.length; C++) {
170
- const g = I(c[C]);
171
- x.includes(g) ? m.delete(g) : m.get(g) !== !0 && m.set(g, !1);
261
+ const ht = ({ children: t, custom: i, initial: s = !0, onExitComplete: n, presenceAffectsLayout: r = !0, mode: a = "sync", propagate: o = !1, anchorX: d = "left", root: c }) => {
262
+ const [u, h] = ft(o), f = z(() => se(t), [t]), m = o && !u ? [] : f.map(S), g = P(!0), j = P(f), l = de(() => /* @__PURE__ */ new Map()), [x, v] = E(f), [p, C] = E(f);
263
+ st(() => {
264
+ g.current = !1, j.current = f;
265
+ for (let w = 0; w < p.length; w++) {
266
+ const y = S(p[w]);
267
+ m.includes(y) ? l.delete(y) : l.get(y) !== !0 && l.set(y, !1);
172
268
  }
173
- }, [c, x.length, x.join("-")]);
174
- const w = [];
175
- if (h !== K) {
176
- let C = [...h];
177
- for (let g = 0; g < c.length; g++) {
178
- const E = c[g], z = I(E);
179
- x.includes(z) || (C.splice(g, 0, E), w.push(E));
269
+ }, [p, m.length, m.join("-")]);
270
+ const b = [];
271
+ if (f !== x) {
272
+ let w = [...f];
273
+ for (let y = 0; y < p.length; y++) {
274
+ const I = p[y], M = S(I);
275
+ m.includes(M) || (w.splice(y, 0, I), b.push(I));
180
276
  }
181
- return a === "wait" && w.length && (C = w), j(te(C)), o(h), null;
277
+ return a === "wait" && b.length && (w = b), C(se(w)), v(f), null;
182
278
  }
183
- process.env.NODE_ENV !== "production" && a === "wait" && c.length > 1 && console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);
184
- const { forceRender: b } = H(Qe);
185
- return e.jsx(e.Fragment, { children: c.map((C) => {
186
- const g = I(C), E = l && !d ? !1 : h === c || x.includes(g), z = () => {
187
- if (m.has(g))
188
- m.set(g, !0);
279
+ process.env.NODE_ENV !== "production" && a === "wait" && p.length > 1 && console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);
280
+ const { forceRender: fe } = V(et);
281
+ return e.jsx(e.Fragment, { children: p.map((w) => {
282
+ const y = S(w), I = o && !u ? !1 : f === p || m.includes(y), M = () => {
283
+ if (l.has(y))
284
+ l.set(y, !0);
189
285
  else
190
286
  return;
191
287
  let X = !0;
192
- m.forEach((de) => {
193
- de || (X = !1);
194
- }), X && (b?.(), j(k.current), l && y?.(), n && n());
288
+ l.forEach((he) => {
289
+ he || (X = !1);
290
+ }), X && (fe?.(), C(j.current), o && h?.(), n && n());
195
291
  };
196
- return e.jsx(Ye, { isPresent: E, initial: !p.current || s ? void 0 : !1, custom: r, presenceAffectsLayout: i, mode: a, root: f, onExitComplete: E ? void 0 : z, anchorX: u, children: C }, g);
292
+ return e.jsx(dt, { isPresent: I, initial: !g.current || s ? void 0 : !1, custom: i, presenceAffectsLayout: r, mode: a, root: c, onExitComplete: I ? void 0 : M, anchorX: d, children: w }, y);
197
293
  }) });
198
- }, st = ({
199
- service: t,
200
- onOpenChange: r
294
+ }, pt = ({
295
+ apiKey: t,
296
+ onDeleteKey: i,
297
+ className: s
201
298
  }) => {
202
- const s = ne(), n = ie(), i = je(), a = ze({
203
- defaultValues: {
204
- expiresOn: "30"
205
- }
206
- }), l = Fe(), u = T({
207
- mutationFn: ({ description: f, expiresOn: d }) => {
208
- if (!t.createKey)
209
- throw new Error("createKey not implemented");
210
- const y = d !== "never" ? nt(Number(d)) : void 0;
211
- return t.createKey({
212
- apiKey: {
213
- description: f || "Secret Key",
214
- expiresOn: y
215
- },
216
- context: s,
217
- auth: l
218
- });
219
- },
220
- onSuccess: async () => {
221
- await n.invalidateQueries({ queryKey: ["api-keys"] }), await i("/settings/api-keys/");
222
- }
223
- });
224
- return t.createKey ? /* @__PURE__ */ e.jsxs(
225
- "form",
226
- {
227
- onSubmit: a.handleSubmit(
228
- (f) => u.mutate(
229
- { ...f },
230
- {
231
- onSuccess: () => r(!1)
232
- }
233
- )
299
+ const [n, r] = E(!1), { key: a, createdOn: o, expiresOn: d } = t, c = d && new Date(d) < /* @__PURE__ */ new Date(), u = d ? Math.ceil(
300
+ (new Date(d).getTime() - Date.now()) / (1e3 * 60 * 60 * 24)
301
+ ) : 1 / 0, h = u <= 7 && !c;
302
+ return /* @__PURE__ */ e.jsxs("div", { className: W("grid col-span-full grid-cols-subgrid p-6", s), children: [
303
+ /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col gap-1", children: [
304
+ /* @__PURE__ */ e.jsx(
305
+ Ye,
306
+ {
307
+ className: "max-w-fit w-full",
308
+ secret: a,
309
+ status: c ? "expired" : h ? "expiring" : "active",
310
+ revealed: n,
311
+ onReveal: r
312
+ }
234
313
  ),
235
- children: [
236
- u.error && /* @__PURE__ */ e.jsxs(O, { variant: "destructive", className: "mb-4", children: [
237
- /* @__PURE__ */ e.jsx(M, { children: "Error" }),
238
- /* @__PURE__ */ e.jsx(Pe, { children: u.error.message })
314
+ /* @__PURE__ */ e.jsxs("div", { className: "flex gap-1 mt-0.5 text-nowrap", children: [
315
+ o && /* @__PURE__ */ e.jsxs("span", { className: "text-xs text-muted-foreground", children: [
316
+ "Created ",
317
+ mt(o),
318
+ "."
239
319
  ] }),
240
- /* @__PURE__ */ e.jsxs("div", { className: "flex gap-2 flex-col text-sm font-medium", children: [
241
- "Name",
242
- /* @__PURE__ */ e.jsx(oe, { ...a.register("description") }),
243
- "Expiration",
244
- /* @__PURE__ */ e.jsxs(
245
- Re,
320
+ " ",
321
+ d && h && /* @__PURE__ */ e.jsxs("span", { className: "text-xs text-primary", children: [
322
+ "Expires in ",
323
+ u,
324
+ " ",
325
+ u === 1 ? "day" : "days",
326
+ "."
327
+ ] }),
328
+ d && c && /* @__PURE__ */ e.jsxs("span", { className: "text-xs text-primary", children: [
329
+ "Expired",
330
+ " ",
331
+ u === 0 ? "today." : `${u * -1} days ago.`
332
+ ] })
333
+ ] })
334
+ ] }),
335
+ /* @__PURE__ */ e.jsx("div", { className: "flex justify-end", children: d && i && /* @__PURE__ */ e.jsxs(_, { children: [
336
+ /* @__PURE__ */ e.jsx(B, { asChild: !0, children: /* @__PURE__ */ e.jsx(k, { variant: "ghost", size: "icon", children: /* @__PURE__ */ e.jsx(pe, { size: 16 }) }) }),
337
+ /* @__PURE__ */ e.jsxs(G, { children: [
338
+ /* @__PURE__ */ e.jsxs(J, { children: [
339
+ /* @__PURE__ */ e.jsx(Y, { children: "Delete API Key" }),
340
+ /* @__PURE__ */ e.jsx(ae, { children: "Are you sure you want to delete this API key?" })
341
+ ] }),
342
+ /* @__PURE__ */ e.jsxs(H, { children: [
343
+ /* @__PURE__ */ e.jsx(A, { asChild: !0, children: /* @__PURE__ */ e.jsx(k, { variant: "outline", children: "Cancel" }) }),
344
+ /* @__PURE__ */ e.jsx(A, { asChild: !0, children: /* @__PURE__ */ e.jsx(
345
+ k,
246
346
  {
247
- onValueChange: (f) => a.setValue("expiresOn", f),
248
- defaultValue: a.getValues("expiresOn"),
249
- children: [
250
- /* @__PURE__ */ e.jsx(Se, { children: /* @__PURE__ */ e.jsx(Te, {}) }),
251
- /* @__PURE__ */ e.jsx(Oe, { children: /* @__PURE__ */ e.jsxs(Me, { children: [
252
- [7, 30, 60, 90].map((f) => /* @__PURE__ */ e.jsxs(Z, { value: String(f), children: [
253
- f,
254
- " days"
255
- ] }, f)),
256
- /* @__PURE__ */ e.jsx(Z, { value: "never", children: "Never" })
257
- ] }) })
258
- ]
347
+ onClick: () => {
348
+ i();
349
+ },
350
+ children: "Delete"
259
351
  }
260
- ),
261
- /* @__PURE__ */ e.jsxs(V, { children: [
262
- /* @__PURE__ */ e.jsx(P, { asChild: !0, children: /* @__PURE__ */ e.jsx(v, { variant: "outline", children: "Cancel" }) }),
263
- /* @__PURE__ */ e.jsx($e, { isPending: u.isPending, children: "Generate Key" })
264
- ] })
352
+ ) })
265
353
  ] })
266
- ]
267
- }
268
- ) : null;
269
- }, nt = (t) => {
270
- const r = /* @__PURE__ */ new Date();
271
- return r.setDate(r.getDate() + t), r.toISOString();
272
- }, se = ({
273
- service: t,
274
- isOpen: r,
275
- onOpenChange: s,
276
- trigger: n,
277
- buttonVariant: i = "outline"
278
- }) => {
279
- const a = /* @__PURE__ */ e.jsx(v, { variant: i, children: "Create API Key" });
280
- return /* @__PURE__ */ e.jsxs(B, { open: r, onOpenChange: s, children: [
281
- /* @__PURE__ */ e.jsx(G, { asChild: !0, children: n ?? a }),
282
- /* @__PURE__ */ e.jsxs(J, { children: [
283
- /* @__PURE__ */ e.jsx(U, { children: /* @__PURE__ */ e.jsx(W, { children: "Create API Key" }) }),
284
- /* @__PURE__ */ e.jsx(st, { service: t, onOpenChange: s })
285
- ] })
354
+ ] })
355
+ ] }) })
286
356
  ] });
287
- }, it = ({ service: t }) => {
288
- const r = ne(), s = ie(), [n, i] = D(
289
- null
290
- ), [a, l] = D(""), { data: u, isFetching: f } = we({
291
- queryFn: () => t.getConsumers(r),
292
- queryKey: ["api-keys"],
293
- retry: !1
294
- }), [d, y] = D(!1), h = T({
357
+ }, mt = (t) => {
358
+ const i = /* @__PURE__ */ new Date(), s = new Date(t), n = Math.floor((i.getTime() - s.getTime()) / 1e3), r = new Intl.RelativeTimeFormat("en", { numeric: "auto" });
359
+ return n < 60 ? r.format(-n, "second") : n < 3600 ? r.format(-Math.floor(n / 60), "minute") : n < 86400 ? r.format(-Math.floor(n / 3600), "hour") : n < 2592e3 ? r.format(-Math.floor(n / 86400), "day") : n < 31536e3 ? r.format(-Math.floor(n / 2592e3), "month") : r.format(-Math.floor(n / 31536e3), "year");
360
+ }, xt = ({
361
+ consumer: t,
362
+ onUpdate: i,
363
+ onRollKey: s,
364
+ onDeleteKey: n
365
+ }) => {
366
+ const [r, a] = E(!1), [o, d] = E(t.label), c = le(), u = U(), h = T({
367
+ mutationFn: async (l) => {
368
+ if (!s)
369
+ throw new Error("rollKey not implemented");
370
+ return await s?.(l, u);
371
+ },
372
+ onSuccess: () => void c.invalidateQueries({ queryKey: ["api-keys"] })
373
+ }), f = T({
295
374
  mutationFn: ({
296
- consumerId: o,
297
- keyId: c
375
+ consumerId: l,
376
+ keyId: x
298
377
  }) => {
299
- if (!t.deleteKey)
378
+ if (!n)
300
379
  throw new Error("deleteKey not implemented");
301
- return t.deleteKey(o, c, r);
380
+ return n(l, x, u);
302
381
  },
303
- onMutate: async ({ consumerId: o, keyId: c }) => {
304
- await s.cancelQueries({ queryKey: ["api-keys"] });
305
- const j = s.getQueryData([
382
+ onMutate: async ({ consumerId: l, keyId: x }) => {
383
+ await c.cancelQueries({ queryKey: ["api-keys"] });
384
+ const v = c.getQueryData([
306
385
  "api-keys"
307
386
  ]);
308
- return s.setQueryData(["api-keys"], (w) => w && w.map((b) => b.id === o ? {
309
- ...b,
310
- apiKeys: b.apiKeys.filter((C) => C.id !== c)
311
- } : b)), { previousData: j };
387
+ return c.setQueryData(["api-keys"], (p) => p && p.map((C) => C.id === l ? {
388
+ ...C,
389
+ apiKeys: C.apiKeys.filter((b) => b.id !== x)
390
+ } : C)), { previousData: v };
312
391
  },
313
- onError: (o, c, j) => {
314
- j?.previousData && s.setQueryData(["api-keys"], j.previousData);
392
+ onError: (l, x, v) => {
393
+ v?.previousData && c.setQueryData(["api-keys"], v.previousData);
315
394
  },
316
395
  onSuccess: () => {
317
- s.invalidateQueries({ queryKey: ["api-keys"] });
396
+ c.invalidateQueries({ queryKey: ["api-keys"] });
318
397
  }
319
- }), x = T({
398
+ }), m = T({
320
399
  mutationFn: ({
321
- consumerId: o,
322
- label: c
400
+ consumerId: l,
401
+ label: x
323
402
  }) => {
324
- if (!t.updateConsumer)
403
+ if (!i)
325
404
  throw new Error("updateConsumer not implemented");
326
- return t.updateConsumer({ id: o, label: c }, r);
405
+ return i({ id: l, label: x }, u);
327
406
  },
328
- onMutate: async ({ consumerId: o, label: c }) => {
329
- await s.cancelQueries({ queryKey: ["api-keys"] });
330
- const j = s.getQueryData(["api-keys"]);
331
- return s.setQueryData(["api-keys"], (w) => w && w.map((b) => b.id === o ? {
332
- ...b,
333
- label: c
334
- } : b)), { previousData: j };
407
+ onMutate: async ({ consumerId: l, label: x }) => {
408
+ await c.cancelQueries({ queryKey: ["api-keys"] });
409
+ const v = c.getQueryData(["api-keys"]);
410
+ return c.setQueryData(["api-keys"], (p) => p && p.map((C) => C.id === l ? {
411
+ ...C,
412
+ label: x
413
+ } : C)), { previousData: v };
335
414
  },
336
- onError: (o, c, j) => {
337
- j?.previousData && s.setQueryData(["api-keys"], j.previousData);
415
+ onError: (l, x, v) => {
416
+ v?.previousData && c.setQueryData(["api-keys"], v.previousData);
338
417
  },
339
418
  onSuccess: () => {
340
- s.invalidateQueries({ queryKey: ["api-keys"] });
419
+ c.invalidateQueries({ queryKey: ["api-keys"] });
341
420
  }
342
- }), p = T({
343
- mutationFn: (o) => {
344
- if (!t.rollKey)
345
- throw new Error("rollKey not implemented");
346
- return t.rollKey(o, r);
347
- },
348
- onSuccess: () => s.invalidateQueries({ queryKey: ["api-keys"] })
349
- }), k = (o, c) => {
350
- i(o), l(c);
351
- }, m = (o) => {
352
- a.trim() && x.mutate({
353
- consumerId: o,
354
- label: a.trim()
355
- }), i(null), l("");
356
- }, K = () => {
357
- i(null), l("");
421
+ }), g = () => {
422
+ a(!0), d(t.label);
423
+ }, j = () => {
424
+ o.trim() && m.mutate({
425
+ label: o.trim(),
426
+ consumerId: t.id
427
+ }), a(!1);
358
428
  };
359
- return /* @__PURE__ */ e.jsxs("div", { className: "max-w-screen-md h-full pt-(--padding-content-top) pb-(--padding-content-bottom)", children: [
360
- /* @__PURE__ */ e.jsx(Y.Target, { name: "api-keys-list-page" }),
361
- /* @__PURE__ */ e.jsxs("div", { className: "flex justify-between pb-3", children: [
362
- /* @__PURE__ */ e.jsx("h1", { className: "font-medium text-2xl", children: "API Keys" }),
363
- t.createKey && /* @__PURE__ */ e.jsx(
364
- se,
365
- {
366
- service: t,
367
- isOpen: d,
368
- onOpenChange: y
369
- }
370
- )
429
+ return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
430
+ h.isError && /* @__PURE__ */ e.jsxs(D, { variant: "destructive", className: "mb-4", children: [
431
+ /* @__PURE__ */ e.jsx(F, { size: 16 }),
432
+ /* @__PURE__ */ e.jsx(K, { children: h.error.message })
371
433
  ] }),
372
- /* @__PURE__ */ e.jsx("p", { children: "Create, manage, and monitor your API keys" }),
373
- /* @__PURE__ */ e.jsx(Y.Target, { name: "api-keys-list-page-before-keys" }),
374
- /* @__PURE__ */ e.jsx("div", { className: "h-8" }),
375
- p.isError && /* @__PURE__ */ e.jsxs(O, { variant: "destructive", className: "mb-4", children: [
376
- /* @__PURE__ */ e.jsx($, { size: 16 }),
377
- /* @__PURE__ */ e.jsx(M, { children: p.error.message })
378
- ] }),
379
- x.isError && /* @__PURE__ */ e.jsxs(O, { variant: "destructive", className: "mb-4", children: [
380
- /* @__PURE__ */ e.jsx($, { size: 16 }),
381
- /* @__PURE__ */ e.jsx(M, { children: x.error.message })
434
+ m.isError && /* @__PURE__ */ e.jsxs(D, { variant: "destructive", className: "mb-4", children: [
435
+ /* @__PURE__ */ e.jsx(F, { size: 16 }),
436
+ /* @__PURE__ */ e.jsx(K, { children: m.error.message })
382
437
  ] }),
383
- h.isError && /* @__PURE__ */ e.jsxs(O, { variant: "destructive", className: "mb-4", children: [
384
- /* @__PURE__ */ e.jsx($, { size: 16 }),
385
- /* @__PURE__ */ e.jsx(M, { children: h.error.message })
438
+ f.isError && /* @__PURE__ */ e.jsxs(D, { variant: "destructive", className: "mb-4", children: [
439
+ /* @__PURE__ */ e.jsx(F, { size: 16 }),
440
+ /* @__PURE__ */ e.jsx(K, { children: f.error.message })
386
441
  ] }),
387
- /* @__PURE__ */ e.jsx("div", { className: "", children: u.length === 0 ? /* @__PURE__ */ e.jsxs("div", { className: "flex col-span-full flex-col justify-center gap-4 items-center p-8 border rounded-sm bg-muted/30 text-muted-foreground", children: [
388
- /* @__PURE__ */ e.jsxs("p", { className: "text-center", children: [
389
- "You have no API keys yet.",
390
- /* @__PURE__ */ e.jsx("br", {}),
391
- t.createKey && "Get started and create your first key."
392
- ] }),
393
- t.createKey && /* @__PURE__ */ e.jsx(
394
- se,
395
- {
396
- service: t,
397
- isOpen: d,
398
- onOpenChange: y
399
- }
400
- )
401
- ] }) : /* @__PURE__ */ e.jsx(
402
- "ul",
442
+ /* @__PURE__ */ e.jsxs(
443
+ Pe,
403
444
  {
404
- className: L(
405
- "grid grid-cols-[1fr_min-content] divide-y divide-border col-span-6"
406
- ),
407
- children: u.map((o) => /* @__PURE__ */ e.jsxs(
408
- Ae,
409
- {
410
- className: "grid grid-cols-subgrid col-span-full items-center mb-4 group",
411
- children: [
412
- /* @__PURE__ */ e.jsxs(Ie, { className: "border-b col-span-full grid-cols-subgrid grid", children: [
413
- /* @__PURE__ */ e.jsxs("div", { className: "h-10 flex flex-col text-sm justify-center", children: [
414
- /* @__PURE__ */ e.jsxs("div", { className: "font-medium text-lg flex items-center gap-2", children: [
415
- n === o.id ? /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2 w-full", children: [
445
+ className: "grid grid-cols-subgrid col-span-full items-center mb-4 group",
446
+ children: [
447
+ /* @__PURE__ */ e.jsxs(Ae, { className: "col-span-full flex-row items-start justify-between gap-4", children: [
448
+ /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col gap-1", children: [
449
+ r ? /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
450
+ /* @__PURE__ */ e.jsx(
451
+ ze,
452
+ {
453
+ maxLength: 32,
454
+ value: o,
455
+ onChange: (l) => d(l.target.value),
456
+ onKeyDown: (l) => {
457
+ l.key === "Enter" ? j() : l.key === "Escape" && a(!1);
458
+ },
459
+ autoFocus: !0
460
+ }
461
+ ),
462
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center", children: [
463
+ /* @__PURE__ */ e.jsx(
464
+ k,
465
+ {
466
+ size: "icon",
467
+ variant: "ghost",
468
+ onClick: j,
469
+ disabled: !o.trim(),
470
+ children: /* @__PURE__ */ e.jsx(me, { size: 16 })
471
+ }
472
+ ),
473
+ /* @__PURE__ */ e.jsx(
474
+ k,
475
+ {
476
+ size: "icon",
477
+ variant: "ghost",
478
+ onClick: () => a(!1),
479
+ children: /* @__PURE__ */ e.jsx(xe, { size: 16 })
480
+ }
481
+ )
482
+ ] })
483
+ ] }) : /* @__PURE__ */ e.jsx(Ne, { children: t.label }),
484
+ /* @__PURE__ */ e.jsxs(Se, { children: [
485
+ t.createdOn && /* @__PURE__ */ e.jsxs("div", { children: [
486
+ "Created on ",
487
+ new Date(t.createdOn).toLocaleDateString()
488
+ ] }),
489
+ t.expiresOn && /* @__PURE__ */ e.jsxs("div", { children: [
490
+ "Expires on ",
491
+ new Date(t.expiresOn).toLocaleDateString()
492
+ ] })
493
+ ] })
494
+ ] }),
495
+ /* @__PURE__ */ e.jsxs("div", { className: "flex gap-1", children: [
496
+ i && /* @__PURE__ */ e.jsxs(
497
+ k,
498
+ {
499
+ variant: "ghost",
500
+ onClick: g,
501
+ className: W(
502
+ "flex gap-2",
503
+ r && "opacity-0! pointer-events-none"
504
+ ),
505
+ disabled: r,
506
+ children: [
507
+ /* @__PURE__ */ e.jsx(ye, { size: 16 }),
508
+ /* @__PURE__ */ e.jsx("span", { className: "hidden md:block", children: "Edit label" })
509
+ ]
510
+ }
511
+ ),
512
+ s && /* @__PURE__ */ e.jsxs(_, { children: [
513
+ /* @__PURE__ */ e.jsx(B, { asChild: !0, children: /* @__PURE__ */ e.jsxs(
514
+ k,
515
+ {
516
+ title: "Roll this key",
517
+ variant: "ghost",
518
+ disabled: h.isPending,
519
+ className: "flex items-center gap-2",
520
+ children: [
416
521
  /* @__PURE__ */ e.jsx(
417
- oe,
522
+ ge,
418
523
  {
419
- maxLength: 32,
420
- value: a,
421
- onChange: (c) => l(c.target.value),
422
- onKeyDown: (c) => {
423
- c.key === "Enter" ? m(o.id) : c.key === "Escape" && K();
424
- },
425
- className: "text-lg font-medium",
426
- autoFocus: !0
524
+ size: 16,
525
+ className: h.isPending ? "animate-spin" : void 0
427
526
  }
428
527
  ),
429
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center", children: [
430
- /* @__PURE__ */ e.jsx(
431
- v,
432
- {
433
- size: "icon",
434
- variant: "ghost",
435
- onClick: () => m(o.id),
436
- disabled: !a.trim(),
437
- children: /* @__PURE__ */ e.jsx(ue, { size: 16 })
438
- }
439
- ),
440
- /* @__PURE__ */ e.jsx(
441
- v,
442
- {
443
- size: "icon",
444
- variant: "ghost",
445
- onClick: K,
446
- children: /* @__PURE__ */ e.jsx(fe, { size: 16 })
447
- }
448
- )
449
- ] })
450
- ] }) : o.label,
451
- /* @__PURE__ */ e.jsx("div", { className: "text-muted-foreground text-xs", children: o.createdOn })
528
+ /* @__PURE__ */ e.jsx("span", { className: "hidden md:block", children: "Roll key" })
529
+ ]
530
+ }
531
+ ) }),
532
+ /* @__PURE__ */ e.jsxs(G, { children: [
533
+ /* @__PURE__ */ e.jsxs(J, { children: [
534
+ /* @__PURE__ */ e.jsx(Y, { children: "Roll API Key" }),
535
+ /* @__PURE__ */ e.jsx(ae, { children: "Are you sure you want to roll this API key?" })
452
536
  ] }),
453
- /* @__PURE__ */ e.jsxs("div", { className: "text-muted-foreground text-xs", children: [
454
- o.createdOn && /* @__PURE__ */ e.jsxs("div", { children: [
455
- "Created on",
456
- " ",
457
- new Date(o.createdOn).toLocaleDateString()
458
- ] }),
459
- o.expiresOn && /* @__PURE__ */ e.jsxs("div", { children: [
460
- "Expires on",
461
- " ",
462
- new Date(o.expiresOn).toLocaleDateString()
463
- ] })
464
- ] })
465
- ] }),
466
- /* @__PURE__ */ e.jsxs("div", { className: "flex justify-end", children: [
467
- t.updateConsumer && /* @__PURE__ */ e.jsxs(
468
- v,
469
- {
470
- variant: "ghost",
471
- onClick: () => k(o.id, o.label),
472
- className: L(
473
- "flex gap-2",
474
- n === o.id && "opacity-0! pointer-events-none"
475
- ),
476
- disabled: n === o.id,
477
- children: [
478
- /* @__PURE__ */ e.jsx(he, { size: 16 }),
479
- /* @__PURE__ */ e.jsx("span", { className: "hidden md:block", children: "Edit label" })
480
- ]
481
- }
482
- ),
483
- t.rollKey && /* @__PURE__ */ e.jsxs(B, { children: [
484
- /* @__PURE__ */ e.jsx(G, { asChild: !0, children: /* @__PURE__ */ e.jsxs(
485
- v,
537
+ /* @__PURE__ */ e.jsxs(H, { children: [
538
+ /* @__PURE__ */ e.jsx(A, { asChild: !0, children: /* @__PURE__ */ e.jsx(k, { variant: "outline", children: "Cancel" }) }),
539
+ /* @__PURE__ */ e.jsx(A, { asChild: !0, children: /* @__PURE__ */ e.jsx(
540
+ k,
486
541
  {
487
- title: "Roll this key",
488
- variant: "ghost",
489
- disabled: p.isPending,
490
- className: "flex items-center gap-2",
491
- children: [
492
- /* @__PURE__ */ e.jsx(
493
- pe,
494
- {
495
- size: 16,
496
- className: p.isPending ? "animate-spin" : void 0
497
- }
498
- ),
499
- /* @__PURE__ */ e.jsx("span", { className: "hidden md:block", children: "Roll key" })
500
- ]
542
+ onClick: () => {
543
+ h.mutate(t.id);
544
+ },
545
+ children: "Roll Key"
501
546
  }
502
- ) }),
503
- /* @__PURE__ */ e.jsxs(J, { children: [
504
- /* @__PURE__ */ e.jsxs(U, { children: [
505
- /* @__PURE__ */ e.jsx(W, { children: "Roll API Key" }),
506
- /* @__PURE__ */ e.jsx(ae, { children: "Are you sure you want to roll this API key?" })
507
- ] }),
508
- /* @__PURE__ */ e.jsxs(V, { children: [
509
- /* @__PURE__ */ e.jsx(P, { asChild: !0, children: /* @__PURE__ */ e.jsx(v, { variant: "outline", children: "Cancel" }) }),
510
- /* @__PURE__ */ e.jsx(P, { asChild: !0, children: /* @__PURE__ */ e.jsx(
511
- v,
512
- {
513
- onClick: () => {
514
- p.mutate(o.id);
515
- },
516
- children: "Roll Key"
517
- }
518
- ) })
519
- ] })
520
- ] })
547
+ ) })
521
548
  ] })
522
549
  ] })
523
- ] }),
524
- /* @__PURE__ */ e.jsx("div", { className: "col-span-full grid-cols-subgrid grid", children: /* @__PURE__ */ e.jsx(tt, { children: o.apiKeys.map((c) => /* @__PURE__ */ e.jsxs(ke.Fragment, { children: [
525
- /* @__PURE__ */ e.jsx(
526
- at,
527
- {
528
- apiKey: c,
529
- onDeleteKey: () => {
530
- h.mutate({
531
- consumerId: o.id,
532
- keyId: c.id
533
- });
534
- },
535
- className: h.variables?.keyId === c.id && (h.isPending || f) ? "opacity-10!" : void 0
536
- }
537
- ),
538
- /* @__PURE__ */ e.jsx("div", { className: "col-span-full h-px bg-border" })
539
- ] }, c.id)) }) })
540
- ]
541
- },
542
- o.id
543
- ))
544
- }
545
- ) })
550
+ ] })
551
+ ] })
552
+ ] }),
553
+ /* @__PURE__ */ e.jsx(Re, { className: "p-0 grid grid-cols-subgrid col-span-full divide-y divide-border", children: /* @__PURE__ */ e.jsx(ht, { children: t.apiKeys.map((l) => /* @__PURE__ */ e.jsx(
554
+ pt,
555
+ {
556
+ apiKey: l,
557
+ onDeleteKey: () => {
558
+ f.mutate({
559
+ consumerId: t.id,
560
+ keyId: l.id
561
+ });
562
+ },
563
+ className: f.variables?.keyId === l.id && f.isPending ? "opacity-10!" : void 0
564
+ },
565
+ l.id
566
+ )) }) })
567
+ ]
568
+ },
569
+ t.id
570
+ )
546
571
  ] });
547
- }, rt = (t) => {
548
- const r = /* @__PURE__ */ new Date(), s = new Date(t), n = Math.floor((r.getTime() - s.getTime()) / 1e3), i = new Intl.RelativeTimeFormat("en", { numeric: "auto" });
549
- return n < 60 ? i.format(-n, "second") : n < 3600 ? i.format(-Math.floor(n / 60), "minute") : n < 86400 ? i.format(-Math.floor(n / 3600), "hour") : n < 2592e3 ? i.format(-Math.floor(n / 86400), "day") : n < 31536e3 ? i.format(-Math.floor(n / 2592e3), "month") : i.format(-Math.floor(n / 31536e3), "year");
550
- }, at = ({
551
- apiKey: t,
552
- onDeleteKey: r,
553
- className: s
554
- }) => {
555
- const [n, i] = D(!1), { key: a, createdOn: l, expiresOn: u } = t, f = u && new Date(u) < /* @__PURE__ */ new Date(), d = u ? Math.ceil(
556
- (new Date(u).getTime() - Date.now()) / (1e3 * 60 * 60 * 24)
557
- ) : 1 / 0, y = d <= 7 && !f;
558
- return /* @__PURE__ */ e.jsxs("div", { className: L("grid col-span-full grid-cols-subgrid p-6", s), children: [
559
- /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col gap-1", children: [
560
- /* @__PURE__ */ e.jsx(
561
- qe,
572
+ }, yt = ({ service: t }) => {
573
+ const i = U(), { data: s } = $e({
574
+ queryFn: async () => {
575
+ try {
576
+ return await t.getConsumers(i);
577
+ } catch (a) {
578
+ throw new $("Cannot get API keys", {
579
+ cause: a,
580
+ title: "Error getting API keys",
581
+ developerHint: "Check the response of the API request for more information."
582
+ });
583
+ }
584
+ },
585
+ queryKey: ["api-keys"],
586
+ retry: !1
587
+ }), [n, r] = E(!1);
588
+ return /* @__PURE__ */ e.jsx("div", { className: "mt-8", children: s.length === 0 ? /* @__PURE__ */ e.jsxs("div", { className: "flex col-span-full flex-col justify-center gap-4 items-center p-8 border rounded-sm bg-muted/30 text-muted-foreground", children: [
589
+ /* @__PURE__ */ e.jsxs("p", { className: "text-center", children: [
590
+ "You have no API keys yet.",
591
+ /* @__PURE__ */ e.jsx("br", {}),
592
+ t.createKey && "Get started and create your first key."
593
+ ] }),
594
+ t.createKey && /* @__PURE__ */ e.jsx(
595
+ ce,
596
+ {
597
+ service: t,
598
+ isOpen: n,
599
+ onOpenChange: r
600
+ }
601
+ )
602
+ ] }) : /* @__PURE__ */ e.jsx("ul", { className: W("grid grid-cols-[1fr_min-content] col-span-6"), children: s.map((a) => /* @__PURE__ */ e.jsx(
603
+ xt,
604
+ {
605
+ consumer: a,
606
+ onUpdate: t.updateConsumer,
607
+ onRollKey: t.rollKey,
608
+ onDeleteKey: t.deleteKey
609
+ },
610
+ a.id
611
+ )) }) });
612
+ }, gt = ({ service: t }) => {
613
+ const [i, s] = E(!1), n = ie();
614
+ return /* @__PURE__ */ e.jsxs("div", { className: "max-w-3xl h-full pt-(--padding-content-top) pb-(--padding-content-bottom)", children: [
615
+ /* @__PURE__ */ e.jsx(Z.Target, { name: "api-keys-list-page" }),
616
+ /* @__PURE__ */ e.jsxs("div", { className: "flex justify-between pb-3", children: [
617
+ /* @__PURE__ */ e.jsx("h1", { className: "font-medium text-2xl", children: "API Keys" }),
618
+ t.createKey && /* @__PURE__ */ e.jsx(
619
+ ce,
562
620
  {
563
- className: "max-w-fit w-full",
564
- secret: a,
565
- status: f ? "expired" : y ? "expiring" : "active",
566
- revealed: n,
567
- onReveal: i
621
+ service: t,
622
+ isOpen: i,
623
+ onOpenChange: s
568
624
  }
569
- ),
570
- /* @__PURE__ */ e.jsxs("div", { className: "flex gap-1 mt-0.5 text-nowrap", children: [
571
- l && /* @__PURE__ */ e.jsxs("span", { className: "text-xs text-muted-foreground", children: [
572
- "Created ",
573
- rt(l),
574
- "."
575
- ] }),
576
- " ",
577
- u && y && /* @__PURE__ */ e.jsxs("span", { className: "text-xs text-primary", children: [
578
- "Expires in ",
579
- d,
580
- " ",
581
- d === 1 ? "day" : "days",
582
- "."
583
- ] }),
584
- u && f && /* @__PURE__ */ e.jsxs("span", { className: "text-xs text-primary", children: [
585
- "Expired",
586
- " ",
587
- d === 0 ? "today." : `${d * -1} days ago.`
588
- ] })
589
- ] })
625
+ )
590
626
  ] }),
591
- /* @__PURE__ */ e.jsx("div", { className: "flex justify-end", children: u && r && /* @__PURE__ */ e.jsxs(B, { children: [
592
- /* @__PURE__ */ e.jsx(G, { asChild: !0, children: /* @__PURE__ */ e.jsx(v, { variant: "ghost", size: "icon", children: /* @__PURE__ */ e.jsx(me, { size: 16 }) }) }),
593
- /* @__PURE__ */ e.jsxs(J, { children: [
594
- /* @__PURE__ */ e.jsxs(U, { children: [
595
- /* @__PURE__ */ e.jsx(W, { children: "Delete API Key" }),
596
- /* @__PURE__ */ e.jsx(ae, { children: "Are you sure you want to delete this API key?" })
597
- ] }),
598
- /* @__PURE__ */ e.jsxs(V, { children: [
599
- /* @__PURE__ */ e.jsx(P, { asChild: !0, children: /* @__PURE__ */ e.jsx(v, { variant: "outline", children: "Cancel" }) }),
600
- /* @__PURE__ */ e.jsx(P, { asChild: !0, children: /* @__PURE__ */ e.jsx(
601
- v,
602
- {
603
- onClick: () => {
604
- r();
605
- },
606
- children: "Delete"
607
- }
608
- ) })
609
- ] })
610
- ] })
611
- ] }) })
627
+ /* @__PURE__ */ e.jsx("p", { children: "Create, manage, and monitor your API keys" }),
628
+ /* @__PURE__ */ e.jsx(Z.Target, { name: "api-keys-list-page-before-keys" }),
629
+ n.profile?.emailVerified === !1 ? /* @__PURE__ */ e.jsxs(Oe, { variant: "outline", children: [
630
+ /* @__PURE__ */ e.jsxs(Te, { children: [
631
+ /* @__PURE__ */ e.jsx(qe, { children: "Verified email required" }),
632
+ /* @__PURE__ */ e.jsx(Me, { children: "You need to verify your email to access API keys." })
633
+ ] }),
634
+ /* @__PURE__ */ e.jsx(Fe, { children: /* @__PURE__ */ e.jsx(De, { onClick: () => n.requestEmailVerification(), children: "Verify email" }) })
635
+ ] }) : /* @__PURE__ */ e.jsx(
636
+ Ke,
637
+ {
638
+ fallbackRender: ({ error: r }) => /* @__PURE__ */ e.jsx(We, { error: r }),
639
+ children: /* @__PURE__ */ e.jsx(yt, { service: t })
640
+ }
641
+ )
612
642
  ] });
613
- }, R = "https://api.zuploedge.com/v2/client", ot = async (t) => {
643
+ }, R = "https://api.zuploedge.com/v2/client", jt = async (t) => {
614
644
  try {
615
645
  return await t.json();
616
646
  } catch {
617
647
  return;
618
648
  }
619
- }, S = async (t) => {
620
- const r = t.headers.get("content-type");
621
- if (!t.ok && r?.includes("application/problem+json")) {
622
- const s = await ot(t);
649
+ }, O = async (t) => {
650
+ const i = t.headers.get("content-type");
651
+ if (!t.ok && i?.includes("application/problem+json")) {
652
+ const s = await jt(t);
623
653
  if (s.type && s.title)
624
654
  throw new Error(s.detail ?? s.title);
625
655
  }
626
- }, lt = (t, r) => ({
627
- deleteKey: async (s, n, i) => {
656
+ }, vt = (t, i) => ({
657
+ deleteKey: async (s, n, r) => {
628
658
  const a = new Request(
629
659
  R + `/${t}/consumers/${s}/keys/${n}`,
630
660
  {
631
661
  method: "DELETE"
632
662
  }
633
663
  );
634
- await i.signRequest(a);
635
- const l = await fetch(a);
636
- await S(l), A(l.ok, "Failed to delete API key");
664
+ await r.signRequest(a);
665
+ const o = await fetch(a);
666
+ await O(o), N(o.ok, "Failed to delete API key");
637
667
  },
638
668
  updateConsumer: async (s, n) => {
639
- const i = await fetch(
669
+ const r = await fetch(
640
670
  await n.signRequest(
641
671
  new Request(
642
672
  R + `/${t}/consumers/${s.id}`,
@@ -652,10 +682,10 @@ const tt = ({ children: t, custom: r, initial: s = !0, onExitComplete: n, presen
652
682
  )
653
683
  )
654
684
  );
655
- await S(i), A(i.ok, "Failed to update API key description");
685
+ await O(r), N(r.ok, "Failed to update API key description");
656
686
  },
657
687
  rollKey: async (s, n) => {
658
- const i = await fetch(
688
+ const r = await fetch(
659
689
  await n.signRequest(
660
690
  new Request(
661
691
  R + `/${t}/consumers/${s}/roll-key`,
@@ -669,42 +699,54 @@ const tt = ({ children: t, custom: r, initial: s = !0, onExitComplete: n, presen
669
699
  )
670
700
  )
671
701
  );
672
- await S(i), A(i.ok, "Failed to delete API key");
702
+ await O(r), N(r.ok, "Failed to delete API key");
673
703
  },
674
704
  getConsumers: async (s) => {
675
705
  const n = new Request(
676
706
  `${R}/${t}/consumers`
677
707
  );
678
708
  await s.signRequest(n);
679
- const i = await fetch(n);
680
- return await S(i), A(i.ok, "Failed to fetch API keys"), (await i.json()).data.map((l) => ({
681
- id: l.id,
682
- label: l.label || l.subject || "API Key",
683
- apiKeys: l.apiKeys.data,
684
- key: l.apiKeys.data.at(0)
709
+ const r = await fetch(n);
710
+ return await O(r), N(r.ok, "Failed to fetch API keys"), (await r.json()).data.map((o) => ({
711
+ id: o.id,
712
+ createdOn: o.createdOn,
713
+ updatedOn: o.updatedOn,
714
+ expiresOn: o.expiresOn,
715
+ label: o.label || o.subject || "API Key",
716
+ apiKeys: o.apiKeys.data,
717
+ key: o.apiKeys.data.at(0)
685
718
  }));
686
719
  },
687
- ...r
688
- }), Pt = (t) => t, At = (t) => {
689
- const r = "deploymentName" in t ? lt(t.deploymentName, t) : t;
720
+ ...i
721
+ }), zt = (t) => t, Lt = ({
722
+ deploymentName: t,
723
+ ...i
724
+ }) => {
725
+ const s = t ? vt(t, { deploymentName: t, ...i }) : i;
726
+ if (!s.getConsumers)
727
+ throw new Error("getConsumers is required when using the apiKeyPlugin");
728
+ const n = {
729
+ ...s,
730
+ getConsumers: s.getConsumers
731
+ };
690
732
  return {
691
733
  getProfileMenuItems: () => [
692
734
  {
693
735
  label: "API Keys",
694
736
  path: "/settings/api-keys",
695
737
  category: "middle",
696
- icon: xe
738
+ icon: je
697
739
  }
698
740
  ],
699
- getIdentities: async (s) => {
741
+ getIdentities: async (r) => {
700
742
  try {
701
- return (await r.getConsumers(s)).map((i) => ({
702
- authorizeRequest: (a) => (a.headers.set(
743
+ return (await n.getConsumers(r)).map((o) => ({
744
+ authorizeRequest: (d) => (d.headers.set(
703
745
  "Authorization",
704
- `Bearer ${i.apiKeys.at(0)?.key}`
705
- ), a),
706
- id: i.id,
707
- label: i.label
746
+ `Bearer ${o.apiKeys.at(0)?.key}`
747
+ ), d),
748
+ id: o.id,
749
+ label: o.label
708
750
  }));
709
751
  } catch {
710
752
  return [];
@@ -712,20 +754,15 @@ const tt = ({ children: t, custom: r, initial: s = !0, onExitComplete: n, presen
712
754
  },
713
755
  getRoutes: () => [
714
756
  {
715
- element: /* @__PURE__ */ e.jsx(Le, {}),
716
- errorElement: /* @__PURE__ */ e.jsx(ye, {}),
717
- children: [
718
- {
719
- path: "/settings/api-keys",
720
- element: /* @__PURE__ */ e.jsx(it, { service: r })
721
- }
722
- ]
757
+ path: "/settings/api-keys",
758
+ element: /* @__PURE__ */ e.jsx(gt, { service: n })
723
759
  }
724
- ]
760
+ ],
761
+ getProtectedRoutes: () => ["/settings/api-keys"]
725
762
  };
726
763
  };
727
764
  export {
728
- At as apiKeyPlugin,
729
- Pt as createApiKeyService
765
+ Lt as apiKeyPlugin,
766
+ zt as createApiKeyService
730
767
  };
731
768
  //# sourceMappingURL=zudoku.plugin-api-keys.js.map