zudoku 0.46.2 → 0.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/dist/config/config.d.ts +11 -0
  2. package/dist/config/validators/InputSidebarSchema.d.ts +4 -1
  3. package/dist/config/validators/InputSidebarSchema.js +1 -0
  4. package/dist/config/validators/InputSidebarSchema.js.map +1 -1
  5. package/dist/config/validators/SidebarSchema.d.ts +1 -1
  6. package/dist/config/validators/validate.d.ts +47 -47
  7. package/dist/config/validators/validate.js +11 -1
  8. package/dist/config/validators/validate.js.map +1 -1
  9. package/dist/config/validators/validate.test.d.ts +1 -0
  10. package/dist/config/validators/validate.test.js +80 -0
  11. package/dist/config/validators/validate.test.js.map +1 -0
  12. package/dist/lib/auth/issuer.d.ts +2 -0
  13. package/dist/lib/auth/issuer.js +34 -0
  14. package/dist/lib/auth/issuer.js.map +1 -0
  15. package/dist/lib/auth/issuer.test.d.ts +1 -0
  16. package/dist/lib/auth/issuer.test.js +81 -0
  17. package/dist/lib/auth/issuer.test.js.map +1 -0
  18. package/dist/lib/authentication/hook.d.ts +6 -0
  19. package/dist/lib/authentication/providers/auth0.js +1 -1
  20. package/dist/lib/authentication/providers/auth0.js.map +1 -1
  21. package/dist/lib/authentication/providers/azureb2c.d.ts +28 -0
  22. package/dist/lib/authentication/providers/azureb2c.js +145 -0
  23. package/dist/lib/authentication/providers/azureb2c.js.map +1 -0
  24. package/dist/lib/authentication/providers/clerk.js +3 -12
  25. package/dist/lib/authentication/providers/clerk.js.map +1 -1
  26. package/dist/lib/authentication/providers/openid.d.ts +1 -0
  27. package/dist/lib/authentication/providers/openid.js +38 -0
  28. package/dist/lib/authentication/providers/openid.js.map +1 -1
  29. package/dist/lib/authentication/providers/supabase.js +2 -9
  30. package/dist/lib/authentication/providers/supabase.js.map +1 -1
  31. package/dist/lib/authentication/state.d.ts +6 -5
  32. package/dist/lib/authentication/state.js +19 -6
  33. package/dist/lib/authentication/state.js.map +1 -1
  34. package/dist/lib/components/context/ZudokuProvider.d.ts +1 -1
  35. package/dist/lib/components/index.d.ts +6 -0
  36. package/dist/lib/components/navigation/SidebarItem.js +2 -3
  37. package/dist/lib/components/navigation/SidebarItem.js.map +1 -1
  38. package/dist/lib/hooks/index.d.ts +6 -0
  39. package/dist/lib/plugins/openapi/PlaygroundDialogWrapper.d.ts +1 -1
  40. package/dist/lib/plugins/openapi/playground/Headers.d.ts +2 -2
  41. package/dist/lib/plugins/openapi/playground/fileUtils.js +1 -1
  42. package/dist/lib/plugins/openapi/playground/fileUtils.js.map +1 -1
  43. package/dist/lib/util/MdxComponents.js +1 -1
  44. package/dist/lib/util/MdxComponents.js.map +1 -1
  45. package/dist/vite/build.js +2 -32
  46. package/dist/vite/build.js.map +1 -1
  47. package/lib/{Markdown-Cm4kj26S.js → Markdown-BUE2ViaD.js} +340 -337
  48. package/lib/{Markdown-Cm4kj26S.js.map → Markdown-BUE2ViaD.js.map} +1 -1
  49. package/lib/{MdxPage-fDGQtB5w.js → MdxPage-By4UkRkI.js} +4 -4
  50. package/lib/{MdxPage-fDGQtB5w.js.map → MdxPage-By4UkRkI.js.map} +1 -1
  51. package/lib/{OasProvider-CFBvfR3r.js → OasProvider-C6_Kx5O7.js} +2 -2
  52. package/lib/{OasProvider-CFBvfR3r.js.map → OasProvider-C6_Kx5O7.js.map} +1 -1
  53. package/lib/{OperationList-Xs4KWmsh.js → OperationList-BISd29LY.js} +6 -6
  54. package/lib/OperationList-BISd29LY.js.map +1 -0
  55. package/lib/{RouteGuard-CZ_uLv3g.js → RouteGuard-CgmsSw7T.js} +2 -2
  56. package/lib/{RouteGuard-CZ_uLv3g.js.map → RouteGuard-CgmsSw7T.js.map} +1 -1
  57. package/lib/{SchemaList-BWaNlmUJ.js → SchemaList-BqnRo5ov.js} +6 -6
  58. package/lib/{SchemaList-BWaNlmUJ.js.map → SchemaList-BqnRo5ov.js.map} +1 -1
  59. package/lib/{SchemaView-DdKJt2ln.js → SchemaView-CtYJpxQI.js} +3 -3
  60. package/lib/{SchemaView-DdKJt2ln.js.map → SchemaView-CtYJpxQI.js.map} +1 -1
  61. package/lib/{SignUp-B-1Pvc-8.js → SignUp-CrjeBbqN.js} +2 -2
  62. package/lib/{SignUp-B-1Pvc-8.js.map → SignUp-CrjeBbqN.js.map} +1 -1
  63. package/lib/{Slot-B99cbD-q.js → Slot-DANV2b7_.js} +4 -4
  64. package/lib/{Slot-B99cbD-q.js.map → Slot-DANV2b7_.js.map} +1 -1
  65. package/lib/{SyntaxHighlight-Cz6Me7-F.js → SyntaxHighlight-DtvR7RLF.js} +1291 -1265
  66. package/lib/SyntaxHighlight-DtvR7RLF.js.map +1 -0
  67. package/lib/{Toc-Qe7A4uj_.js → Toc-ClJBmdtI.js} +2 -2
  68. package/lib/{Toc-Qe7A4uj_.js.map → Toc-ClJBmdtI.js.map} +1 -1
  69. package/lib/{circular-w5eL5J8a.js → circular-pOdgLzpG.js} +2 -2
  70. package/lib/{circular-w5eL5J8a.js.map → circular-pOdgLzpG.js.map} +1 -1
  71. package/lib/clerk-yAKDC3Qz.js +24812 -0
  72. package/lib/clerk-yAKDC3Qz.js.map +1 -0
  73. package/lib/{createServer-p3yUA8Bu.js → createServer-qAtUf99r.js} +2625 -2615
  74. package/lib/createServer-qAtUf99r.js.map +1 -0
  75. package/lib/errors-Bpodza84.js +78 -0
  76. package/lib/errors-Bpodza84.js.map +1 -0
  77. package/lib/{hook-k7PfUIsj.js → hook-wIlTGE-2.js} +52 -31
  78. package/lib/{hook-k7PfUIsj.js.map → hook-wIlTGE-2.js.map} +1 -1
  79. package/lib/{index-yqBxBqxF.js → index-RFzRn4fM.js} +10 -10
  80. package/lib/index-RFzRn4fM.js.map +1 -0
  81. package/lib/{mutation-BSeQ8pEK.js → mutation-C-kdA_1r.js} +2 -2
  82. package/lib/{mutation-BSeQ8pEK.js.map → mutation-C-kdA_1r.js.map} +1 -1
  83. package/lib/ui/SyntaxHighlight.js +2 -2
  84. package/lib/{useMutation-CZSmsIGW.js → useMutation-3Ph3x6En.js} +3 -3
  85. package/lib/{useMutation-CZSmsIGW.js.map → useMutation-3Ph3x6En.js.map} +1 -1
  86. package/lib/zudoku.auth-auth0.js +2 -2
  87. package/lib/zudoku.auth-auth0.js.map +1 -1
  88. package/lib/zudoku.auth-azureb2c.js +9974 -0
  89. package/lib/zudoku.auth-azureb2c.js.map +1 -0
  90. package/lib/zudoku.auth-clerk.js +39 -48
  91. package/lib/zudoku.auth-clerk.js.map +1 -1
  92. package/lib/zudoku.auth-openid.js +291 -316
  93. package/lib/zudoku.auth-openid.js.map +1 -1
  94. package/lib/zudoku.components.js +1222 -1594
  95. package/lib/zudoku.components.js.map +1 -1
  96. package/lib/zudoku.hooks.js +2 -2
  97. package/lib/zudoku.plugin-api-catalog.js +2 -2
  98. package/lib/zudoku.plugin-api-keys.js +3 -3
  99. package/lib/zudoku.plugin-api-keys.js.map +1 -1
  100. package/lib/zudoku.plugin-custom-pages.js +1 -1
  101. package/lib/zudoku.plugin-markdown.js +1 -1
  102. package/lib/zudoku.plugin-openapi.js +2 -2
  103. package/lib/zudoku.plugin-search-pagefind.js +2 -2
  104. package/package.json +37 -19
  105. package/src/lib/auth/issuer.test.ts +104 -0
  106. package/src/lib/auth/issuer.ts +38 -0
  107. package/src/lib/authentication/providers/auth0.tsx +1 -1
  108. package/src/lib/authentication/providers/azureb2c.tsx +196 -0
  109. package/src/lib/authentication/providers/clerk.tsx +3 -12
  110. package/src/lib/authentication/providers/openid.tsx +53 -0
  111. package/src/lib/authentication/providers/supabase.tsx +2 -9
  112. package/src/lib/authentication/state.ts +37 -7
  113. package/src/lib/components/context/ZudokuProvider.tsx +1 -1
  114. package/src/lib/components/navigation/SidebarItem.tsx +2 -1
  115. package/src/lib/plugins/api-keys/SettingsApiKeys.tsx +1 -1
  116. package/src/lib/plugins/openapi/PlaygroundDialogWrapper.tsx +1 -1
  117. package/src/lib/plugins/openapi/playground/Headers.tsx +2 -2
  118. package/src/lib/plugins/openapi/playground/fileUtils.ts +1 -1
  119. package/src/lib/util/MdxComponents.tsx +1 -1
  120. package/lib/OperationList-Xs4KWmsh.js.map +0 -1
  121. package/lib/SyntaxHighlight-Cz6Me7-F.js.map +0 -1
  122. package/lib/createServer-p3yUA8Bu.js.map +0 -1
  123. package/lib/index-yqBxBqxF.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { z as p } from "./index--oeBayMa.js";
2
- import { k as n, i as a, m as c } from "./hook-k7PfUIsj.js";
3
- import { C as H } from "./hook-k7PfUIsj.js";
2
+ import { k as n, i as a, m as c } from "./hook-wIlTGE-2.js";
3
+ import { C as H } from "./hook-wIlTGE-2.js";
4
4
  import { u as f } from "./useExposedProps-BZQkZneR.js";
5
5
  import { useState as i, useEffect as E } from "react";
6
6
  import { u as d } from "./index-QzXzw_ra.js";
@@ -1,10 +1,10 @@
1
1
  import { j as t } from "./jsx-runtime-C5mzlN2N.js";
2
2
  import { s as f } from "./index-BvvmIczU.js";
3
3
  import { d as b, m as j } from "./chunk-DQRVZFIR-BblmKnHy.js";
4
- import { u as x, d as y, j as m } from "./hook-k7PfUIsj.js";
4
+ import { u as x, d as y, j as m } from "./hook-wIlTGE-2.js";
5
5
  import { H as v } from "./index.esm-BFcSKCe-.js";
6
6
  import { Link as N } from "./zudoku.components.js";
7
- import { H as S, M as w } from "./Markdown-Cm4kj26S.js";
7
+ import { H as S, M as w } from "./Markdown-BUE2ViaD.js";
8
8
  const H = ({
9
9
  items: r,
10
10
  filterCatalogItems: o = (n) => n,
@@ -1,11 +1,11 @@
1
1
  import { j as e } from "./jsx-runtime-C5mzlN2N.js";
2
2
  import { CheckIcon as _, XIcon as se, PencilLineIcon as ne, RotateCwIcon as ie, EyeOffIcon as re, EyeIcon as ae, CopyIcon as oe, TrashIcon as le, KeyRoundIcon as de } from "lucide-react";
3
- import { D as ce, S as F, R as ue } from "./Slot-B99cbD-q.js";
3
+ import { D as ce, S as F, R as ue } from "./Slot-DANV2b7_.js";
4
4
  import { i as P } from "./invariant-DAFpPywt.js";
5
5
  import { O as he, L as Q } from "./chunk-DQRVZFIR-BblmKnHy.js";
6
- import { i as fe, k as pe, e as xe, d as me } from "./hook-k7PfUIsj.js";
6
+ import { i as fe, k as pe, e as xe, d as me } from "./hook-wIlTGE-2.js";
7
7
  import { Button as j } from "./ui/Button.js";
8
- import { u as z } from "./useMutation-CZSmsIGW.js";
8
+ import { u as z } from "./useMutation-3Ph3x6En.js";
9
9
  import * as S from "react";
10
10
  import ye, { createContext as q, useRef as D, useLayoutEffect as ge, useEffect as B, useId as L, useContext as O, useInsertionEffect as je, useMemo as M, useCallback as Ce, Children as ve, isValidElement as we, useState as E } from "react";
11
11
  import { C as ke, a as be } from "./Card-DPhGbYUM.js";
@@ -1 +1 @@
1
- {"version":3,"file":"zudoku.plugin-api-keys.js","sources":["../src/lib/plugins/api-keys/ProtectedRoute.tsx","../../../node_modules/.pnpm/framer-motion@12.15.0_@emotion+is-prop-valid@0.8.8_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/framer-motion/dist/es/context/LayoutGroupContext.mjs","../../../node_modules/.pnpm/framer-motion@12.15.0_@emotion+is-prop-valid@0.8.8_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/framer-motion/dist/es/utils/use-constant.mjs","../../../node_modules/.pnpm/framer-motion@12.15.0_@emotion+is-prop-valid@0.8.8_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/framer-motion/dist/es/utils/is-browser.mjs","../../../node_modules/.pnpm/framer-motion@12.15.0_@emotion+is-prop-valid@0.8.8_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/framer-motion/dist/es/utils/use-isomorphic-effect.mjs","../../../node_modules/.pnpm/framer-motion@12.15.0_@emotion+is-prop-valid@0.8.8_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/framer-motion/dist/es/context/PresenceContext.mjs","../../../node_modules/.pnpm/motion-utils@12.12.1/node_modules/motion-utils/dist/es/is-object.mjs","../../../node_modules/.pnpm/motion-dom@12.15.0/node_modules/motion-dom/dist/es/utils/is-html-element.mjs","../../../node_modules/.pnpm/framer-motion@12.15.0_@emotion+is-prop-valid@0.8.8_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/framer-motion/dist/es/context/MotionConfigContext.mjs","../../../node_modules/.pnpm/framer-motion@12.15.0_@emotion+is-prop-valid@0.8.8_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/framer-motion/dist/es/components/AnimatePresence/PopChild.mjs","../../../node_modules/.pnpm/framer-motion@12.15.0_@emotion+is-prop-valid@0.8.8_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/framer-motion/dist/es/components/AnimatePresence/PresenceChild.mjs","../../../node_modules/.pnpm/framer-motion@12.15.0_@emotion+is-prop-valid@0.8.8_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/framer-motion/dist/es/components/AnimatePresence/use-presence.mjs","../../../node_modules/.pnpm/framer-motion@12.15.0_@emotion+is-prop-valid@0.8.8_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/framer-motion/dist/es/components/AnimatePresence/utils.mjs","../../../node_modules/.pnpm/framer-motion@12.15.0_@emotion+is-prop-valid@0.8.8_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/framer-motion/dist/es/components/AnimatePresence/index.mjs","../src/lib/plugins/api-keys/SettingsApiKeys.tsx","../src/lib/plugins/api-keys/index.tsx"],"sourcesContent":["import { Outlet } from \"react-router\";\nimport { useAuth } from \"../../authentication/hook.js\";\nimport { DeveloperHint } from \"../../components/DeveloperHint.js\";\nimport { Button } from \"../../ui/Button.js\";\n\nexport const ProtectedRoute = () => {\n const auth = useAuth();\n\n // TODO: should we suspend here somehow?\n if (auth.isAuthEnabled && auth.isPending) {\n return null;\n }\n\n return auth.isAuthenticated ? (\n <Outlet />\n ) : !auth.isAuthEnabled ? (\n <div className=\"flex flex-col justify-center gap-2 items-center h-1/2\">\n <DeveloperHint className=\"max-w-[600px]\">\n Authentication needs to be enabled for API keys to work. Enable it in\n your Zudoku configuration under <code>authentication</code>.\n </DeveloperHint>\n </div>\n ) : (\n <div className=\"flex flex-col justify-center gap-2 items-center h-1/2\">\n Please login first to view this page\n <Button onClick={() => auth.login()}>Login</Button>\n </div>\n );\n};\n","\"use client\";\nimport { createContext } from 'react';\n\nconst LayoutGroupContext = createContext({});\n\nexport { LayoutGroupContext };\n","import { useRef } from 'react';\n\n/**\n * Creates a constant value over the lifecycle of a component.\n *\n * Even if `useMemo` is provided an empty array as its final argument, it doesn't offer\n * a guarantee that it won't re-run for performance reasons later on. By using `useConstant`\n * you can ensure that initialisers don't execute twice or more.\n */\nfunction useConstant(init) {\n const ref = useRef(null);\n if (ref.current === null) {\n ref.current = init();\n }\n return ref.current;\n}\n\nexport { useConstant };\n","const isBrowser = typeof window !== \"undefined\";\n\nexport { isBrowser };\n","import { useLayoutEffect, useEffect } from 'react';\nimport { isBrowser } from './is-browser.mjs';\n\nconst useIsomorphicLayoutEffect = isBrowser ? useLayoutEffect : useEffect;\n\nexport { useIsomorphicLayoutEffect };\n","\"use client\";\nimport { createContext } from 'react';\n\n/**\n * @public\n */\nconst PresenceContext = \n/* @__PURE__ */ createContext(null);\n\nexport { PresenceContext };\n","function isObject(value) {\n return typeof value === \"object\" && value !== null;\n}\n\nexport { isObject };\n","import { isObject } from 'motion-utils';\n\n/**\n * Checks if an element is an HTML element in a way\n * that works across iframes\n */\nfunction isHTMLElement(element) {\n return isObject(element) && \"offsetHeight\" in element;\n}\n\nexport { isHTMLElement };\n","\"use client\";\nimport { createContext } from 'react';\n\n/**\n * @public\n */\nconst MotionConfigContext = createContext({\n transformPagePoint: (p) => p,\n isStatic: false,\n reducedMotion: \"never\",\n});\n\nexport { MotionConfigContext };\n","\"use client\";\nimport { jsx } from 'react/jsx-runtime';\nimport { isHTMLElement } from 'motion-dom';\nimport * as React from 'react';\nimport { useId, useRef, useContext, useInsertionEffect } from 'react';\nimport { MotionConfigContext } from '../../context/MotionConfigContext.mjs';\n\n/**\n * Measurement functionality has to be within a separate component\n * to leverage snapshot lifecycle.\n */\nclass PopChildMeasure extends React.Component {\n getSnapshotBeforeUpdate(prevProps) {\n const element = this.props.childRef.current;\n if (element && prevProps.isPresent && !this.props.isPresent) {\n const parent = element.offsetParent;\n const parentWidth = isHTMLElement(parent)\n ? parent.offsetWidth || 0\n : 0;\n const size = this.props.sizeRef.current;\n size.height = element.offsetHeight || 0;\n size.width = element.offsetWidth || 0;\n size.top = element.offsetTop;\n size.left = element.offsetLeft;\n size.right = parentWidth - size.width - size.left;\n }\n return null;\n }\n /**\n * Required with getSnapshotBeforeUpdate to stop React complaining.\n */\n componentDidUpdate() { }\n render() {\n return this.props.children;\n }\n}\nfunction PopChild({ children, isPresent, anchorX }) {\n const id = useId();\n const ref = useRef(null);\n const size = useRef({\n width: 0,\n height: 0,\n top: 0,\n left: 0,\n right: 0,\n });\n const { nonce } = useContext(MotionConfigContext);\n /**\n * We create and inject a style block so we can apply this explicit\n * sizing in a non-destructive manner by just deleting the style block.\n *\n * We can't apply size via render as the measurement happens\n * in getSnapshotBeforeUpdate (post-render), likewise if we apply the\n * styles directly on the DOM node, we might be overwriting\n * styles set via the style prop.\n */\n useInsertionEffect(() => {\n const { width, height, top, left, right } = size.current;\n if (isPresent || !ref.current || !width || !height)\n return;\n const x = anchorX === \"left\" ? `left: ${left}` : `right: ${right}`;\n ref.current.dataset.motionPopId = id;\n const style = document.createElement(\"style\");\n if (nonce)\n style.nonce = nonce;\n document.head.appendChild(style);\n if (style.sheet) {\n style.sheet.insertRule(`\n [data-motion-pop-id=\"${id}\"] {\n position: absolute !important;\n width: ${width}px !important;\n height: ${height}px !important;\n ${x}px !important;\n top: ${top}px !important;\n }\n `);\n }\n return () => {\n if (document.head.contains(style)) {\n document.head.removeChild(style);\n }\n };\n }, [isPresent]);\n return (jsx(PopChildMeasure, { isPresent: isPresent, childRef: ref, sizeRef: size, children: React.cloneElement(children, { ref }) }));\n}\n\nexport { PopChild };\n","\"use client\";\nimport { jsx } from 'react/jsx-runtime';\nimport * as React from 'react';\nimport { useId, useMemo } from 'react';\nimport { PresenceContext } from '../../context/PresenceContext.mjs';\nimport { useConstant } from '../../utils/use-constant.mjs';\nimport { PopChild } from './PopChild.mjs';\n\nconst PresenceChild = ({ children, initial, isPresent, onExitComplete, custom, presenceAffectsLayout, mode, anchorX, }) => {\n const presenceChildren = useConstant(newChildrenMap);\n const id = useId();\n let isReusedContext = true;\n let context = useMemo(() => {\n isReusedContext = false;\n return {\n id,\n initial,\n isPresent,\n custom,\n onExitComplete: (childId) => {\n presenceChildren.set(childId, true);\n for (const isComplete of presenceChildren.values()) {\n if (!isComplete)\n return; // can stop searching when any is incomplete\n }\n onExitComplete && onExitComplete();\n },\n register: (childId) => {\n presenceChildren.set(childId, false);\n return () => presenceChildren.delete(childId);\n },\n };\n }, [isPresent, presenceChildren, onExitComplete]);\n /**\n * If the presence of a child affects the layout of the components around it,\n * we want to make a new context value to ensure they get re-rendered\n * so they can detect that layout change.\n */\n if (presenceAffectsLayout && isReusedContext) {\n context = { ...context };\n }\n useMemo(() => {\n presenceChildren.forEach((_, key) => presenceChildren.set(key, false));\n }, [isPresent]);\n /**\n * If there's no `motion` components to fire exit animations, we want to remove this\n * component immediately.\n */\n React.useEffect(() => {\n !isPresent &&\n !presenceChildren.size &&\n onExitComplete &&\n onExitComplete();\n }, [isPresent]);\n if (mode === \"popLayout\") {\n children = (jsx(PopChild, { isPresent: isPresent, anchorX: anchorX, children: children }));\n }\n return (jsx(PresenceContext.Provider, { value: context, children: children }));\n};\nfunction newChildrenMap() {\n return new Map();\n}\n\nexport { PresenceChild };\n","import { useContext, useId, useEffect, useCallback } from 'react';\nimport { PresenceContext } from '../../context/PresenceContext.mjs';\n\n/**\n * When a component is the child of `AnimatePresence`, it can use `usePresence`\n * to access information about whether it's still present in the React tree.\n *\n * ```jsx\n * import { usePresence } from \"framer-motion\"\n *\n * export const Component = () => {\n * const [isPresent, safeToRemove] = usePresence()\n *\n * useEffect(() => {\n * !isPresent && setTimeout(safeToRemove, 1000)\n * }, [isPresent])\n *\n * return <div />\n * }\n * ```\n *\n * If `isPresent` is `false`, it means that a component has been removed the tree, but\n * `AnimatePresence` won't really remove it until `safeToRemove` has been called.\n *\n * @public\n */\nfunction usePresence(subscribe = true) {\n const context = useContext(PresenceContext);\n if (context === null)\n return [true, null];\n const { isPresent, onExitComplete, register } = context;\n // It's safe to call the following hooks conditionally (after an early return) because the context will always\n // either be null or non-null for the lifespan of the component.\n const id = useId();\n useEffect(() => {\n if (subscribe) {\n return register(id);\n }\n }, [subscribe]);\n const safeToRemove = useCallback(() => subscribe && onExitComplete && onExitComplete(id), [id, onExitComplete, subscribe]);\n return !isPresent && onExitComplete ? [false, safeToRemove] : [true];\n}\n/**\n * Similar to `usePresence`, except `useIsPresent` simply returns whether or not the component is present.\n * There is no `safeToRemove` function.\n *\n * ```jsx\n * import { useIsPresent } from \"framer-motion\"\n *\n * export const Component = () => {\n * const isPresent = useIsPresent()\n *\n * useEffect(() => {\n * !isPresent && console.log(\"I've been removed!\")\n * }, [isPresent])\n *\n * return <div />\n * }\n * ```\n *\n * @public\n */\nfunction useIsPresent() {\n return isPresent(useContext(PresenceContext));\n}\nfunction isPresent(context) {\n return context === null ? true : context.isPresent;\n}\n\nexport { isPresent, useIsPresent, usePresence };\n","import { Children, isValidElement } from 'react';\n\nconst getChildKey = (child) => child.key || \"\";\nfunction onlyElements(children) {\n const filtered = [];\n // We use forEach here instead of map as map mutates the component key by preprending `.$`\n Children.forEach(children, (child) => {\n if (isValidElement(child))\n filtered.push(child);\n });\n return filtered;\n}\n\nexport { getChildKey, onlyElements };\n","\"use client\";\nimport { jsx, Fragment } from 'react/jsx-runtime';\nimport { useMemo, useRef, useState, useContext } from 'react';\nimport { LayoutGroupContext } from '../../context/LayoutGroupContext.mjs';\nimport { useConstant } from '../../utils/use-constant.mjs';\nimport { useIsomorphicLayoutEffect } from '../../utils/use-isomorphic-effect.mjs';\nimport { PresenceChild } from './PresenceChild.mjs';\nimport { usePresence } from './use-presence.mjs';\nimport { onlyElements, getChildKey } from './utils.mjs';\n\n/**\n * `AnimatePresence` enables the animation of components that have been removed from the tree.\n *\n * When adding/removing more than a single child, every child **must** be given a unique `key` prop.\n *\n * Any `motion` components that have an `exit` property defined will animate out when removed from\n * the tree.\n *\n * ```jsx\n * import { motion, AnimatePresence } from 'framer-motion'\n *\n * export const Items = ({ items }) => (\n * <AnimatePresence>\n * {items.map(item => (\n * <motion.div\n * key={item.id}\n * initial={{ opacity: 0 }}\n * animate={{ opacity: 1 }}\n * exit={{ opacity: 0 }}\n * />\n * ))}\n * </AnimatePresence>\n * )\n * ```\n *\n * You can sequence exit animations throughout a tree using variants.\n *\n * If a child contains multiple `motion` components with `exit` props, it will only unmount the child\n * once all `motion` components have finished animating out. Likewise, any components using\n * `usePresence` all need to call `safeToRemove`.\n *\n * @public\n */\nconst AnimatePresence = ({ children, custom, initial = true, onExitComplete, presenceAffectsLayout = true, mode = \"sync\", propagate = false, anchorX = \"left\", }) => {\n const [isParentPresent, safeToRemove] = usePresence(propagate);\n /**\n * Filter any children that aren't ReactElements. We can only track components\n * between renders with a props.key.\n */\n const presentChildren = useMemo(() => onlyElements(children), [children]);\n /**\n * Track the keys of the currently rendered children. This is used to\n * determine which children are exiting.\n */\n const presentKeys = propagate && !isParentPresent ? [] : presentChildren.map(getChildKey);\n /**\n * If `initial={false}` we only want to pass this to components in the first render.\n */\n const isInitialRender = useRef(true);\n /**\n * A ref containing the currently present children. When all exit animations\n * are complete, we use this to re-render the component with the latest children\n * *committed* rather than the latest children *rendered*.\n */\n const pendingPresentChildren = useRef(presentChildren);\n /**\n * Track which exiting children have finished animating out.\n */\n const exitComplete = useConstant(() => new Map());\n /**\n * Save children to render as React state. To ensure this component is concurrent-safe,\n * we check for exiting children via an effect.\n */\n const [diffedChildren, setDiffedChildren] = useState(presentChildren);\n const [renderedChildren, setRenderedChildren] = useState(presentChildren);\n useIsomorphicLayoutEffect(() => {\n isInitialRender.current = false;\n pendingPresentChildren.current = presentChildren;\n /**\n * Update complete status of exiting children.\n */\n for (let i = 0; i < renderedChildren.length; i++) {\n const key = getChildKey(renderedChildren[i]);\n if (!presentKeys.includes(key)) {\n if (exitComplete.get(key) !== true) {\n exitComplete.set(key, false);\n }\n }\n else {\n exitComplete.delete(key);\n }\n }\n }, [renderedChildren, presentKeys.length, presentKeys.join(\"-\")]);\n const exitingChildren = [];\n if (presentChildren !== diffedChildren) {\n let nextChildren = [...presentChildren];\n /**\n * Loop through all the currently rendered components and decide which\n * are exiting.\n */\n for (let i = 0; i < renderedChildren.length; i++) {\n const child = renderedChildren[i];\n const key = getChildKey(child);\n if (!presentKeys.includes(key)) {\n nextChildren.splice(i, 0, child);\n exitingChildren.push(child);\n }\n }\n /**\n * If we're in \"wait\" mode, and we have exiting children, we want to\n * only render these until they've all exited.\n */\n if (mode === \"wait\" && exitingChildren.length) {\n nextChildren = exitingChildren;\n }\n setRenderedChildren(onlyElements(nextChildren));\n setDiffedChildren(presentChildren);\n /**\n * Early return to ensure once we've set state with the latest diffed\n * children, we can immediately re-render.\n */\n return null;\n }\n if (process.env.NODE_ENV !== \"production\" &&\n mode === \"wait\" &&\n renderedChildren.length > 1) {\n 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.`);\n }\n /**\n * If we've been provided a forceRender function by the LayoutGroupContext,\n * we can use it to force a re-render amongst all surrounding components once\n * all components have finished animating out.\n */\n const { forceRender } = useContext(LayoutGroupContext);\n return (jsx(Fragment, { children: renderedChildren.map((child) => {\n const key = getChildKey(child);\n const isPresent = propagate && !isParentPresent\n ? false\n : presentChildren === renderedChildren ||\n presentKeys.includes(key);\n const onExit = () => {\n if (exitComplete.has(key)) {\n exitComplete.set(key, true);\n }\n else {\n return;\n }\n let isEveryExitComplete = true;\n exitComplete.forEach((isExitComplete) => {\n if (!isExitComplete)\n isEveryExitComplete = false;\n });\n if (isEveryExitComplete) {\n forceRender?.();\n setRenderedChildren(pendingPresentChildren.current);\n propagate && safeToRemove?.();\n onExitComplete && onExitComplete();\n }\n };\n return (jsx(PresenceChild, { isPresent: isPresent, initial: !isInitialRender.current || initial\n ? undefined\n : false, custom: custom, presenceAffectsLayout: presenceAffectsLayout, mode: mode, onExitComplete: isPresent ? undefined : onExit, anchorX: anchorX, children: child }, key));\n }) }));\n};\n\nexport { AnimatePresence };\n","import {\n useMutation,\n useQueryClient,\n useSuspenseQuery,\n} from \"@tanstack/react-query\";\nimport { AnimatePresence } from \"framer-motion\";\nimport {\n CheckIcon,\n CopyIcon,\n EyeIcon,\n EyeOffIcon,\n PencilLineIcon,\n RotateCwIcon,\n TrashIcon,\n XIcon,\n} from \"lucide-react\";\nimport React, { useState } from \"react\";\nimport { Link } from \"react-router\";\nimport { Card, CardHeader } from \"zudoku/ui/Card.js\";\nimport {\n Dialog,\n DialogClose,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n DialogTrigger,\n} from \"zudoku/ui/Dialog.js\";\nimport { useZudoku } from \"../../components/context/ZudokuContext.js\";\nimport { Slot } from \"../../components/Slot.js\";\nimport { Button } from \"../../ui/Button.js\";\nimport { Input } from \"../../ui/Input.js\";\nimport { cn } from \"../../util/cn.js\";\nimport { ApiConsumer, type ApiKey, type ApiKeyService } from \"./index.js\";\n\nexport const SettingsApiKeys = ({ service }: { service: ApiKeyService }) => {\n const context = useZudoku();\n const queryClient = useQueryClient();\n const [editingConsumerId, setEditingConsumerId] = useState<string | null>(\n null,\n );\n const [editingLabel, setEditingLabel] = useState<string>(\"\");\n const { data, isFetching } = useSuspenseQuery({\n queryFn: () => service.getConsumers(context),\n queryKey: [\"api-keys\"],\n retry: false,\n });\n\n const deleteKeyMutation = useMutation({\n mutationFn: ({\n consumerId,\n keyId,\n }: {\n consumerId: string;\n keyId: string;\n }) => {\n if (!service.deleteKey) {\n throw new Error(\"deleteKey not implemented\");\n }\n\n return service.deleteKey(consumerId, keyId, context);\n },\n onMutate: async ({ consumerId, keyId }) => {\n await queryClient.cancelQueries({ queryKey: [\"api-keys\"] });\n const previousData = queryClient.getQueryData<ApiConsumer[]>([\n \"api-keys\",\n ]);\n queryClient.setQueryData<ApiConsumer[]>([\"api-keys\"], (old) => {\n if (!old) {\n return old;\n }\n\n return old.map((consumer) => {\n if (consumer.id === consumerId) {\n return {\n ...consumer,\n apiKeys: consumer.apiKeys.filter((key) => key.id !== keyId),\n };\n }\n return consumer;\n });\n });\n\n return { previousData };\n },\n onError: (err, variables, context) => {\n if (context?.previousData) {\n queryClient.setQueryData([\"api-keys\"], context.previousData);\n }\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: [\"api-keys\"] });\n },\n });\n\n const updateConsumerMutation = useMutation({\n mutationFn: ({\n consumerId,\n label,\n }: {\n consumerId: string;\n label: string;\n }) => {\n if (!service.updateConsumer) {\n throw new Error(\"updateConsumer not implemented\");\n }\n\n return service.updateConsumer({ id: consumerId, label }, context);\n },\n onMutate: async ({ consumerId, label }) => {\n await queryClient.cancelQueries({ queryKey: [\"api-keys\"] });\n\n const previousData = queryClient.getQueryData([\"api-keys\"]);\n queryClient.setQueryData<ApiConsumer[]>([\"api-keys\"], (old) => {\n if (!old) {\n return old;\n }\n\n return old.map((consumer) => {\n if (consumer.id === consumerId) {\n return {\n ...consumer,\n label,\n };\n }\n return consumer;\n });\n });\n\n return { previousData };\n },\n onError: (err, variables, context) => {\n if (context?.previousData) {\n queryClient.setQueryData([\"api-keys\"], context.previousData);\n }\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: [\"api-keys\"] });\n },\n });\n\n const rollKeyMutation = useMutation({\n mutationFn: (id: string) => {\n if (!service.rollKey) {\n throw new Error(\"rollKey not implemented\");\n }\n\n return service.rollKey(id, context);\n },\n onSuccess: () => queryClient.invalidateQueries({ queryKey: [\"api-keys\"] }),\n });\n\n const handleStartEdit = (consumerId: string, currentLabel: string) => {\n setEditingConsumerId(consumerId);\n setEditingLabel(currentLabel);\n };\n\n const handleSaveEdit = (consumerId: string) => {\n if (editingLabel.trim()) {\n updateConsumerMutation.mutate({\n consumerId,\n label: editingLabel.trim(),\n });\n }\n setEditingConsumerId(null);\n setEditingLabel(\"\");\n };\n\n const handleCancelEdit = () => {\n setEditingConsumerId(null);\n setEditingLabel(\"\");\n };\n\n return (\n <div className=\"max-w-screen-lg h-full pt-(--padding-content-top) pb-(--padding-content-bottom)\">\n <Slot.Target name=\"api-keys-list-page\" />\n\n <div className=\"flex justify-between pb-3\">\n <h1 className=\"font-medium text-2xl\">API Keys</h1>\n {service.createKey && (\n <Button asChild>\n <Link to=\"/settings/api-keys/new\">Create API Key</Link>\n </Button>\n )}\n </div>\n <p>Create, manage, and monitor your API keys</p>\n\n <Slot.Target name=\"api-keys-list-page-before-keys\" />\n\n <div className=\"h-8\"></div>\n <div className=\"grid grid-cols-8\">\n {data.length === 0 ? (\n <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\">\n <p className=\"text-center\">\n You have no API keys yet.\n <br />\n {service.createKey && \"Get started and create your first key.\"}\n </p>\n {service.createKey && (\n <Button asChild variant=\"outline\">\n <Link to=\"/settings/api-keys/new\">Create API Key</Link>\n </Button>\n )}\n </div>\n ) : (\n <ul\n className={cn(\n \"grid grid-cols-1 divide-y divide-border col-span-6\",\n \"lg:grid-cols-[1fr_min-content]\",\n )}\n >\n {data.map((consumers) => (\n <Card\n className=\"grid grid-cols-subgrid col-span-full items-center mb-4 group\"\n key={consumers.id}\n >\n <CardHeader className=\"border-b col-span-full grid-cols-subgrid grid\">\n <div className=\"h-10 flex flex-col text-sm justify-center\">\n <div className=\"font-medium text-lg flex items-center gap-2\">\n {editingConsumerId === consumers.id ? (\n <div className=\"flex items-center gap-2 w-full\">\n <Input\n maxLength={32}\n value={editingLabel}\n onChange={(e) => setEditingLabel(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === \"Enter\") {\n handleSaveEdit(consumers.id);\n } else if (e.key === \"Escape\") {\n handleCancelEdit();\n }\n }}\n className=\"text-lg font-medium\"\n autoFocus\n />\n <div className=\"flex items-center\">\n <Button\n size=\"icon\"\n variant=\"ghost\"\n onClick={() => handleSaveEdit(consumers.id)}\n disabled={!editingLabel.trim()}\n >\n <CheckIcon size={16} />\n </Button>\n <Button\n size=\"icon\"\n variant=\"ghost\"\n onClick={handleCancelEdit}\n >\n <XIcon size={16} />\n </Button>\n </div>\n </div>\n ) : (\n <>{consumers.label}</>\n )}\n <div className=\"text-muted-foreground text-xs\">\n {consumers.createdOn}\n </div>\n </div>\n <div className=\"text-muted-foreground text-xs\">\n {consumers.createdOn && (\n <div>\n Created on{\" \"}\n {new Date(consumers.createdOn).toLocaleDateString()}\n </div>\n )}\n {consumers.expiresOn && (\n <div>\n Expires on{\" \"}\n {new Date(consumers.expiresOn).toLocaleDateString()}\n </div>\n )}\n </div>\n </div>\n\n <div className=\"flex justify-end\">\n {service.updateConsumer && (\n <Button\n size=\"icon\"\n variant=\"ghost\"\n onClick={() =>\n handleStartEdit(consumers.id, consumers.label)\n }\n className={cn(\n editingConsumerId === consumers.id &&\n \"opacity-0! pointer-events-none\",\n )}\n disabled={editingConsumerId === consumers.id}\n >\n <PencilLineIcon size={16} />\n </Button>\n )}\n {service.rollKey && (\n <Dialog>\n <DialogTrigger asChild>\n <Button\n size=\"icon\"\n title=\"Roll this key\"\n variant=\"ghost\"\n disabled={rollKeyMutation.isPending}\n className={\n rollKeyMutation.isPending\n ? \"animate-spin\"\n : undefined\n }\n >\n <RotateCwIcon size={16} />\n </Button>\n </DialogTrigger>\n <DialogContent>\n <DialogHeader>\n <DialogTitle>Roll API Key</DialogTitle>\n <DialogDescription>\n Are you sure you want to roll this API key?\n </DialogDescription>\n </DialogHeader>\n <DialogFooter>\n <DialogClose asChild>\n <Button variant=\"outline\">Cancel</Button>\n </DialogClose>\n <DialogClose asChild>\n <Button\n onClick={() => {\n rollKeyMutation.mutate(consumers.id);\n }}\n >\n Roll Key\n </Button>\n </DialogClose>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n )}\n </div>\n </CardHeader>\n <div className=\"col-span-full grid-cols-subgrid grid\">\n <AnimatePresence>\n {consumers.apiKeys.map((apiKey) => (\n <React.Fragment key={apiKey.id}>\n <RevealApiKey\n apiKey={apiKey}\n onDeleteKey={() => {\n deleteKeyMutation.mutate({\n consumerId: consumers.id,\n keyId: apiKey.id,\n });\n }}\n className={\n deleteKeyMutation.variables?.keyId === apiKey.id &&\n (deleteKeyMutation.isPending || isFetching)\n ? \"opacity-10!\"\n : undefined\n }\n />\n <div className=\"col-span-full h-px bg-border\"></div>\n </React.Fragment>\n ))}\n </AnimatePresence>\n </div>\n </Card>\n ))}\n </ul>\n )}\n </div>\n </div>\n );\n};\n\nconst getTimeAgo = (date: string) => {\n const now = new Date();\n const created = new Date(date);\n const diffInSeconds = Math.floor((now.getTime() - created.getTime()) / 1000);\n\n const rtf = new Intl.RelativeTimeFormat(\"en\", { numeric: \"auto\" });\n\n if (diffInSeconds < 60) return rtf.format(-diffInSeconds, \"second\");\n if (diffInSeconds < 3600)\n return rtf.format(-Math.floor(diffInSeconds / 60), \"minute\");\n if (diffInSeconds < 86400)\n return rtf.format(-Math.floor(diffInSeconds / 3600), \"hour\");\n if (diffInSeconds < 2592000)\n return rtf.format(-Math.floor(diffInSeconds / 86400), \"day\");\n if (diffInSeconds < 31536000)\n return rtf.format(-Math.floor(diffInSeconds / 2592000), \"month\");\n return rtf.format(-Math.floor(diffInSeconds / 31536000), \"year\");\n};\n\nconst RevealApiKey = ({\n apiKey,\n onDeleteKey,\n className,\n}: {\n apiKey: ApiKey;\n onDeleteKey: () => void;\n className?: string;\n}) => {\n const [revealed, setRevealed] = useState(false);\n const [copied, setCopied] = useState(false);\n\n const { key, createdOn, expiresOn } = apiKey;\n const isExpired = expiresOn && new Date(expiresOn) < new Date();\n const daysUntilExpiry = expiresOn\n ? Math.ceil(\n (new Date(expiresOn).getTime() - new Date().getTime()) /\n (1000 * 60 * 60 * 24),\n )\n : Infinity;\n const expiresSoon = daysUntilExpiry <= 7 && !isExpired;\n\n return (\n <div className={cn(\"grid col-span-full grid-cols-subgrid p-6\", className)}>\n <div className=\"flex flex-col gap-1\">\n <div className=\"flex gap-2 items-center text-sm border rounded-md w-fit px-1\">\n <div className=\"font-mono truncate h-9 items-center flex px-2 text-xs gap-2\">\n <div\n className={cn(\n \"rounded-full w-2 h-2 bg-emerald-400 mr-2\",\n (expiresSoon || isExpired) && \"bg-neutral-200\",\n )}\n ></div>\n <span>\n <span className={revealed ? \"\" : \"opacity-20\"}>\n {revealed\n ? key.slice(0, -5)\n : \"**** \".repeat(key.slice(0, -5).length / 5) +\n \"*\".repeat(key.slice(0, -5).length % 5)}\n </span>\n <span>{key.slice(-5)}</span>\n </span>\n </div>\n <Button\n variant=\"ghost\"\n onClick={() => setRevealed((prev) => !prev)}\n size=\"icon\"\n >\n {revealed ? <EyeOffIcon size={16} /> : <EyeIcon size={16} />}\n </Button>\n <Button\n variant=\"ghost\"\n onClick={() => {\n void navigator.clipboard.writeText(key).then(() => {\n setCopied(true);\n setTimeout(() => setCopied(false), 2000);\n });\n }}\n size=\"icon\"\n >\n {copied ? <CheckIcon size={16} /> : <CopyIcon size={16} />}\n </Button>\n </div>\n <div className=\"flex gap-1 mt-0.5 text-nowrap\">\n {createdOn && (\n <span className=\"text-xs text-muted-foreground\">\n Created {getTimeAgo(createdOn)}.\n </span>\n )}{\" \"}\n {expiresOn && expiresSoon && (\n <span className=\"text-xs text-primary\">\n Expires in {daysUntilExpiry}{\" \"}\n {daysUntilExpiry === 1 ? \"day\" : \"days\"}.\n </span>\n )}\n {expiresOn && isExpired && (\n <span className=\"text-xs text-primary\">\n Expired{\" \"}\n {daysUntilExpiry === 0\n ? \"today.\"\n : `${daysUntilExpiry * -1} days ago.`}\n </span>\n )}\n </div>\n </div>\n <div className=\"flex justify-end\">\n {isExpired && onDeleteKey && (\n <Dialog>\n <DialogTrigger asChild>\n <Button variant=\"ghost\" size=\"icon\">\n <TrashIcon size={16} />\n </Button>\n </DialogTrigger>\n <DialogContent>\n <DialogHeader>\n <DialogTitle>Delete API Key</DialogTitle>\n <DialogDescription>\n Are you sure you want to delete this API key?\n </DialogDescription>\n </DialogHeader>\n <DialogFooter>\n <DialogClose asChild>\n <Button variant=\"outline\">Cancel</Button>\n </DialogClose>\n <DialogClose asChild>\n <Button\n onClick={() => {\n onDeleteKey();\n }}\n >\n Delete\n </Button>\n </DialogClose>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n )}\n </div>\n </div>\n );\n};\n","import { KeyRoundIcon } from \"lucide-react\";\nimport { type RouteObject } from \"react-router\";\nimport { type ZudokuContext } from \"../../core/ZudokuContext.js\";\nimport {\n type ApiIdentityPlugin,\n type ProfileMenuPlugin,\n type ZudokuPlugin,\n} from \"../../core/plugins.js\";\nimport { RouterError } from \"../../errors/RouterError.js\";\nimport invariant from \"../../util/invariant.js\";\nimport { ProtectedRoute } from \"./ProtectedRoute.js\";\nimport { SettingsApiKeys } from \"./SettingsApiKeys.js\";\n\nconst DEFAULT_API_KEY_ENDPOINT = \"https://api.zuploedge.com/v2/client\";\n\nexport type ApiKeyService = {\n getConsumers: (context: ZudokuContext) => Promise<ApiConsumer[]>;\n rollKey?: (consumerId: string, context: ZudokuContext) => Promise<void>;\n deleteKey?: (\n consumerId: string,\n keyId: string,\n context: ZudokuContext,\n ) => Promise<void>;\n updateConsumer?: (\n consumer: { id: string; label?: string },\n context: ZudokuContext,\n ) => Promise<void>;\n getUsage?: (apiKeys: string[], context: ZudokuContext) => Promise<void>;\n createKey?: (\n apiKey: { description: string; expiresOn?: string },\n context: ZudokuContext,\n ) => Promise<void>;\n};\n\nexport type ApiKeyPluginOptions =\n | ApiKeyService\n | ({ deploymentName: string } & Partial<ApiKeyService>);\n\nexport interface ApiKey {\n id: string;\n description?: string;\n createdOn?: string;\n updatedOn?: string;\n expiresOn?: string;\n key: string;\n}\n\nexport interface ApiConsumer {\n id: string;\n label: string;\n apiKeys: ApiKey[];\n description?: string;\n createdOn?: string;\n updatedOn?: string;\n expiresOn?: string;\n key?: ApiKey;\n}\n\nconst createDefaultHandler = (deploymentName: string): ApiKeyService => {\n return {\n deleteKey: async (consumerId, keyId, context) => {\n const request = new Request(\n DEFAULT_API_KEY_ENDPOINT +\n `/${deploymentName}/consumers/${consumerId}/keys/${keyId}`,\n {\n method: \"DELETE\",\n },\n );\n await context.signRequest(request);\n\n const response = await fetch(request);\n invariant(response.ok, \"Failed to delete API key\");\n },\n updateConsumer: async (consumer, context) => {\n const response = await fetch(\n await context.signRequest(\n new Request(\n DEFAULT_API_KEY_ENDPOINT +\n `/${deploymentName}/consumers/${consumer.id}`,\n {\n method: \"PATCH\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({\n label: consumer.label,\n }),\n },\n ),\n ),\n );\n invariant(response.ok, \"Failed to update API key description\");\n },\n rollKey: async (consumerId, context) => {\n const response = await fetch(\n await context.signRequest(\n new Request(\n DEFAULT_API_KEY_ENDPOINT +\n `/${deploymentName}/consumers/${consumerId}/roll-key`,\n {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({\n expiresOn: new Date(),\n }),\n },\n ),\n ),\n );\n invariant(response.ok, \"Failed to delete API key\");\n },\n getConsumers: async (context) => {\n const request = new Request(\n DEFAULT_API_KEY_ENDPOINT + `/${deploymentName}/consumers`,\n );\n await context.signRequest(request);\n\n const keys = await fetch(request);\n invariant(keys.ok, \"Failed to fetch API keys\");\n\n const data = (await keys.json()) as {\n data: [\n {\n id: string;\n label: string;\n apiKeys: {\n data: ApiKey[];\n };\n },\n ];\n };\n\n return data.data.map((consumer) => ({\n id: consumer.id,\n label: consumer.label || \"API Key\",\n apiKeys: consumer.apiKeys.data,\n key: consumer.apiKeys.data.at(0),\n }));\n },\n };\n};\n\nexport const createApiKeyService = <T extends ApiKeyService>(service: T): T =>\n service;\n\nexport const apiKeyPlugin = (\n options: ApiKeyPluginOptions,\n): ZudokuPlugin & ApiIdentityPlugin & ProfileMenuPlugin => {\n const service: ApiKeyService =\n \"deploymentName\" in options\n ? createDefaultHandler(options.deploymentName)\n : options;\n\n return {\n getProfileMenuItems: () => [\n {\n label: \"API Keys\",\n path: \"/settings/api-keys\",\n category: \"middle\",\n icon: KeyRoundIcon,\n },\n ],\n\n getIdentities: async (context) => {\n try {\n const consumers = await service.getConsumers(context);\n\n return consumers.map((consumer) => ({\n authorizeRequest: (request) => {\n request.headers.set(\n \"Authorization\",\n `Bearer ${consumer.apiKeys.at(0)?.key}`,\n );\n return request;\n },\n id: consumer.id,\n label: consumer.description ?? consumer.id,\n }));\n } catch {\n return [];\n }\n },\n getRoutes: (): RouteObject[] => {\n // TODO: Make lazy\n return [\n {\n element: <ProtectedRoute />,\n errorElement: <RouterError />,\n children: [\n {\n path: \"/settings/api-keys\",\n element: <SettingsApiKeys service={service} />,\n },\n // {\n // path: \"/settings/api-keys/new\",\n // element: <CreateApiKey service={service} />,\n // },\n ],\n },\n ];\n },\n };\n};\n"],"names":["ProtectedRoute","auth","useAuth","jsx","Outlet","jsxs","Button","DeveloperHint","LayoutGroupContext","createContext","useConstant","init","ref","useRef","isBrowser","useIsomorphicLayoutEffect","useLayoutEffect","useEffect","PresenceContext","isObject","value","isHTMLElement","element","MotionConfigContext","p","PopChildMeasure","React","prevProps","parent","parentWidth","size","PopChild","children","isPresent","anchorX","id","useId","nonce","useContext","useInsertionEffect","width","height","top","left","right","x","style","PresenceChild","initial","onExitComplete","custom","presenceAffectsLayout","mode","presenceChildren","newChildrenMap","isReusedContext","context","useMemo","childId","isComplete","_","key","usePresence","subscribe","register","safeToRemove","useCallback","getChildKey","child","onlyElements","filtered","Children","isValidElement","AnimatePresence","propagate","isParentPresent","presentChildren","presentKeys","isInitialRender","pendingPresentChildren","exitComplete","diffedChildren","setDiffedChildren","useState","renderedChildren","setRenderedChildren","i","exitingChildren","nextChildren","forceRender","Fragment","onExit","isEveryExitComplete","isExitComplete","SettingsApiKeys","service","useZudoku","queryClient","useQueryClient","editingConsumerId","setEditingConsumerId","editingLabel","setEditingLabel","data","isFetching","useSuspenseQuery","deleteKeyMutation","useMutation","consumerId","keyId","previousData","old","consumer","err","variables","updateConsumerMutation","label","rollKeyMutation","handleStartEdit","currentLabel","handleSaveEdit","handleCancelEdit","Slot","Link","cn","consumers","Card","CardHeader","Input","e","CheckIcon","XIcon","PencilLineIcon","Dialog","DialogTrigger","RotateCwIcon","DialogContent","DialogHeader","DialogTitle","DialogDescription","DialogFooter","DialogClose","apiKey","RevealApiKey","getTimeAgo","date","now","created","diffInSeconds","rtf","onDeleteKey","className","revealed","setRevealed","copied","setCopied","createdOn","expiresOn","isExpired","daysUntilExpiry","expiresSoon","prev","EyeOffIcon","EyeIcon","CopyIcon","TrashIcon","DEFAULT_API_KEY_ENDPOINT","createDefaultHandler","deploymentName","request","response","invariant","keys","createApiKeyService","apiKeyPlugin","options","KeyRoundIcon","RouterError"],"mappings":";;;;;;;;;;;;;;AAKO,MAAMA,KAAiB,MAAM;AAClC,QAAMC,IAAOC,GAAQ;AAGjB,SAAAD,EAAK,iBAAiBA,EAAK,YACtB,OAGFA,EAAK,kBACTE,gBAAAA,MAAAC,IAAA,CAAA,CAAO,IACLH,EAAK,gBAQPI,gBAAAA,EAAA,KAAA,OAAA,EAAI,WAAU,yDAAwD,UAAA;AAAA,IAAA;AAAA,0BAEpEC,GAAO,EAAA,SAAS,MAAML,EAAK,SAAS,UAAK,QAAA,CAAA;AAAA,EAAA,GAC5C,IAVAE,gBAAAA,EAAA,IAAC,SAAI,WAAU,yDACb,UAACE,gBAAAA,EAAAA,KAAAE,IAAA,EAAc,WAAU,iBAAgB,UAAA;AAAA,IAAA;AAAA,IAEPJ,gBAAAA,EAAAA,IAAC,UAAK,UAAc,iBAAA,CAAA;AAAA,IAAO;AAAA,EAAA,EAC7D,CAAA,EAC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MAAM;AAAA,MACzB;AAAA,QACE,OAAO;AAAA,QACP,MAAM;AAAA,QACN,UAAU;AAAA,QACV,MAAMC;AAAA,MAAA;AAAA,IAEV;AAAA,IAEA,eAAe,OAAOxH,MAAY;AAC5B,UAAA;AAGK,gBAFW,MAAMuC,EAAQ,aAAavC,CAAO,GAEnC,IAAI,CAACwD,OAAc;AAAA,UAClC,kBAAkB,CAACyD,OACjBA,EAAQ,QAAQ;AAAA,YACd;AAAA,YACA,UAAUzD,EAAS,QAAQ,GAAG,CAAC,GAAG,GAAG;AAAA,UACvC,GACOyD;AAAA,UAET,IAAIzD,EAAS;AAAA,UACb,OAAOA,EAAS,eAAeA,EAAS;AAAA,QAAA,EACxC;AAAA,MAAA,QACI;AACN,eAAO,CAAC;AAAA,MAAA;AAAA,IAEZ;AAAA,IACA,WAAW,MAEF;AAAA,MACL;AAAA,QACE,+BAAUhH,IAAe,EAAA;AAAA,QACzB,oCAAeiL,IAAY,EAAA;AAAA,QAC3B,UAAU;AAAA,UACR;AAAA,YACE,MAAM;AAAA,YACN,SAAU9K,gBAAAA,EAAA,IAAA2F,IAAA,EAAgB,SAAAC,EAAkB,CAAA;AAAA,UAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAC9C;AAAA,MAKF;AAAA,IAEJ;AAAA,EAEJ;AACF;","x_google_ignoreList":[1,2,3,4,5,6,7,8,9,10,11,12,13]}
1
+ {"version":3,"file":"zudoku.plugin-api-keys.js","sources":["../src/lib/plugins/api-keys/ProtectedRoute.tsx","../../../node_modules/.pnpm/framer-motion@12.16.0_@emotion+is-prop-valid@0.8.8_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/framer-motion/dist/es/context/LayoutGroupContext.mjs","../../../node_modules/.pnpm/framer-motion@12.16.0_@emotion+is-prop-valid@0.8.8_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/framer-motion/dist/es/utils/use-constant.mjs","../../../node_modules/.pnpm/framer-motion@12.16.0_@emotion+is-prop-valid@0.8.8_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/framer-motion/dist/es/utils/is-browser.mjs","../../../node_modules/.pnpm/framer-motion@12.16.0_@emotion+is-prop-valid@0.8.8_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/framer-motion/dist/es/utils/use-isomorphic-effect.mjs","../../../node_modules/.pnpm/framer-motion@12.16.0_@emotion+is-prop-valid@0.8.8_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/framer-motion/dist/es/context/PresenceContext.mjs","../../../node_modules/.pnpm/motion-utils@12.12.1/node_modules/motion-utils/dist/es/is-object.mjs","../../../node_modules/.pnpm/motion-dom@12.16.0/node_modules/motion-dom/dist/es/utils/is-html-element.mjs","../../../node_modules/.pnpm/framer-motion@12.16.0_@emotion+is-prop-valid@0.8.8_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/framer-motion/dist/es/context/MotionConfigContext.mjs","../../../node_modules/.pnpm/framer-motion@12.16.0_@emotion+is-prop-valid@0.8.8_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/framer-motion/dist/es/components/AnimatePresence/PopChild.mjs","../../../node_modules/.pnpm/framer-motion@12.16.0_@emotion+is-prop-valid@0.8.8_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/framer-motion/dist/es/components/AnimatePresence/PresenceChild.mjs","../../../node_modules/.pnpm/framer-motion@12.16.0_@emotion+is-prop-valid@0.8.8_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/framer-motion/dist/es/components/AnimatePresence/use-presence.mjs","../../../node_modules/.pnpm/framer-motion@12.16.0_@emotion+is-prop-valid@0.8.8_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/framer-motion/dist/es/components/AnimatePresence/utils.mjs","../../../node_modules/.pnpm/framer-motion@12.16.0_@emotion+is-prop-valid@0.8.8_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/framer-motion/dist/es/components/AnimatePresence/index.mjs","../src/lib/plugins/api-keys/SettingsApiKeys.tsx","../src/lib/plugins/api-keys/index.tsx"],"sourcesContent":["import { Outlet } from \"react-router\";\nimport { useAuth } from \"../../authentication/hook.js\";\nimport { DeveloperHint } from \"../../components/DeveloperHint.js\";\nimport { Button } from \"../../ui/Button.js\";\n\nexport const ProtectedRoute = () => {\n const auth = useAuth();\n\n // TODO: should we suspend here somehow?\n if (auth.isAuthEnabled && auth.isPending) {\n return null;\n }\n\n return auth.isAuthenticated ? (\n <Outlet />\n ) : !auth.isAuthEnabled ? (\n <div className=\"flex flex-col justify-center gap-2 items-center h-1/2\">\n <DeveloperHint className=\"max-w-[600px]\">\n Authentication needs to be enabled for API keys to work. Enable it in\n your Zudoku configuration under <code>authentication</code>.\n </DeveloperHint>\n </div>\n ) : (\n <div className=\"flex flex-col justify-center gap-2 items-center h-1/2\">\n Please login first to view this page\n <Button onClick={() => auth.login()}>Login</Button>\n </div>\n );\n};\n","\"use client\";\nimport { createContext } from 'react';\n\nconst LayoutGroupContext = createContext({});\n\nexport { LayoutGroupContext };\n","import { useRef } from 'react';\n\n/**\n * Creates a constant value over the lifecycle of a component.\n *\n * Even if `useMemo` is provided an empty array as its final argument, it doesn't offer\n * a guarantee that it won't re-run for performance reasons later on. By using `useConstant`\n * you can ensure that initialisers don't execute twice or more.\n */\nfunction useConstant(init) {\n const ref = useRef(null);\n if (ref.current === null) {\n ref.current = init();\n }\n return ref.current;\n}\n\nexport { useConstant };\n","const isBrowser = typeof window !== \"undefined\";\n\nexport { isBrowser };\n","import { useLayoutEffect, useEffect } from 'react';\nimport { isBrowser } from './is-browser.mjs';\n\nconst useIsomorphicLayoutEffect = isBrowser ? useLayoutEffect : useEffect;\n\nexport { useIsomorphicLayoutEffect };\n","\"use client\";\nimport { createContext } from 'react';\n\n/**\n * @public\n */\nconst PresenceContext = \n/* @__PURE__ */ createContext(null);\n\nexport { PresenceContext };\n","function isObject(value) {\n return typeof value === \"object\" && value !== null;\n}\n\nexport { isObject };\n","import { isObject } from 'motion-utils';\n\n/**\n * Checks if an element is an HTML element in a way\n * that works across iframes\n */\nfunction isHTMLElement(element) {\n return isObject(element) && \"offsetHeight\" in element;\n}\n\nexport { isHTMLElement };\n","\"use client\";\nimport { createContext } from 'react';\n\n/**\n * @public\n */\nconst MotionConfigContext = createContext({\n transformPagePoint: (p) => p,\n isStatic: false,\n reducedMotion: \"never\",\n});\n\nexport { MotionConfigContext };\n","\"use client\";\nimport { jsx } from 'react/jsx-runtime';\nimport { isHTMLElement } from 'motion-dom';\nimport * as React from 'react';\nimport { useId, useRef, useContext, useInsertionEffect } from 'react';\nimport { MotionConfigContext } from '../../context/MotionConfigContext.mjs';\n\n/**\n * Measurement functionality has to be within a separate component\n * to leverage snapshot lifecycle.\n */\nclass PopChildMeasure extends React.Component {\n getSnapshotBeforeUpdate(prevProps) {\n const element = this.props.childRef.current;\n if (element && prevProps.isPresent && !this.props.isPresent) {\n const parent = element.offsetParent;\n const parentWidth = isHTMLElement(parent)\n ? parent.offsetWidth || 0\n : 0;\n const size = this.props.sizeRef.current;\n size.height = element.offsetHeight || 0;\n size.width = element.offsetWidth || 0;\n size.top = element.offsetTop;\n size.left = element.offsetLeft;\n size.right = parentWidth - size.width - size.left;\n }\n return null;\n }\n /**\n * Required with getSnapshotBeforeUpdate to stop React complaining.\n */\n componentDidUpdate() { }\n render() {\n return this.props.children;\n }\n}\nfunction PopChild({ children, isPresent, anchorX }) {\n const id = useId();\n const ref = useRef(null);\n const size = useRef({\n width: 0,\n height: 0,\n top: 0,\n left: 0,\n right: 0,\n });\n const { nonce } = useContext(MotionConfigContext);\n /**\n * We create and inject a style block so we can apply this explicit\n * sizing in a non-destructive manner by just deleting the style block.\n *\n * We can't apply size via render as the measurement happens\n * in getSnapshotBeforeUpdate (post-render), likewise if we apply the\n * styles directly on the DOM node, we might be overwriting\n * styles set via the style prop.\n */\n useInsertionEffect(() => {\n const { width, height, top, left, right } = size.current;\n if (isPresent || !ref.current || !width || !height)\n return;\n const x = anchorX === \"left\" ? `left: ${left}` : `right: ${right}`;\n ref.current.dataset.motionPopId = id;\n const style = document.createElement(\"style\");\n if (nonce)\n style.nonce = nonce;\n document.head.appendChild(style);\n if (style.sheet) {\n style.sheet.insertRule(`\n [data-motion-pop-id=\"${id}\"] {\n position: absolute !important;\n width: ${width}px !important;\n height: ${height}px !important;\n ${x}px !important;\n top: ${top}px !important;\n }\n `);\n }\n return () => {\n if (document.head.contains(style)) {\n document.head.removeChild(style);\n }\n };\n }, [isPresent]);\n return (jsx(PopChildMeasure, { isPresent: isPresent, childRef: ref, sizeRef: size, children: React.cloneElement(children, { ref }) }));\n}\n\nexport { PopChild };\n","\"use client\";\nimport { jsx } from 'react/jsx-runtime';\nimport * as React from 'react';\nimport { useId, useMemo } from 'react';\nimport { PresenceContext } from '../../context/PresenceContext.mjs';\nimport { useConstant } from '../../utils/use-constant.mjs';\nimport { PopChild } from './PopChild.mjs';\n\nconst PresenceChild = ({ children, initial, isPresent, onExitComplete, custom, presenceAffectsLayout, mode, anchorX, }) => {\n const presenceChildren = useConstant(newChildrenMap);\n const id = useId();\n let isReusedContext = true;\n let context = useMemo(() => {\n isReusedContext = false;\n return {\n id,\n initial,\n isPresent,\n custom,\n onExitComplete: (childId) => {\n presenceChildren.set(childId, true);\n for (const isComplete of presenceChildren.values()) {\n if (!isComplete)\n return; // can stop searching when any is incomplete\n }\n onExitComplete && onExitComplete();\n },\n register: (childId) => {\n presenceChildren.set(childId, false);\n return () => presenceChildren.delete(childId);\n },\n };\n }, [isPresent, presenceChildren, onExitComplete]);\n /**\n * If the presence of a child affects the layout of the components around it,\n * we want to make a new context value to ensure they get re-rendered\n * so they can detect that layout change.\n */\n if (presenceAffectsLayout && isReusedContext) {\n context = { ...context };\n }\n useMemo(() => {\n presenceChildren.forEach((_, key) => presenceChildren.set(key, false));\n }, [isPresent]);\n /**\n * If there's no `motion` components to fire exit animations, we want to remove this\n * component immediately.\n */\n React.useEffect(() => {\n !isPresent &&\n !presenceChildren.size &&\n onExitComplete &&\n onExitComplete();\n }, [isPresent]);\n if (mode === \"popLayout\") {\n children = (jsx(PopChild, { isPresent: isPresent, anchorX: anchorX, children: children }));\n }\n return (jsx(PresenceContext.Provider, { value: context, children: children }));\n};\nfunction newChildrenMap() {\n return new Map();\n}\n\nexport { PresenceChild };\n","import { useContext, useId, useEffect, useCallback } from 'react';\nimport { PresenceContext } from '../../context/PresenceContext.mjs';\n\n/**\n * When a component is the child of `AnimatePresence`, it can use `usePresence`\n * to access information about whether it's still present in the React tree.\n *\n * ```jsx\n * import { usePresence } from \"framer-motion\"\n *\n * export const Component = () => {\n * const [isPresent, safeToRemove] = usePresence()\n *\n * useEffect(() => {\n * !isPresent && setTimeout(safeToRemove, 1000)\n * }, [isPresent])\n *\n * return <div />\n * }\n * ```\n *\n * If `isPresent` is `false`, it means that a component has been removed the tree, but\n * `AnimatePresence` won't really remove it until `safeToRemove` has been called.\n *\n * @public\n */\nfunction usePresence(subscribe = true) {\n const context = useContext(PresenceContext);\n if (context === null)\n return [true, null];\n const { isPresent, onExitComplete, register } = context;\n // It's safe to call the following hooks conditionally (after an early return) because the context will always\n // either be null or non-null for the lifespan of the component.\n const id = useId();\n useEffect(() => {\n if (subscribe) {\n return register(id);\n }\n }, [subscribe]);\n const safeToRemove = useCallback(() => subscribe && onExitComplete && onExitComplete(id), [id, onExitComplete, subscribe]);\n return !isPresent && onExitComplete ? [false, safeToRemove] : [true];\n}\n/**\n * Similar to `usePresence`, except `useIsPresent` simply returns whether or not the component is present.\n * There is no `safeToRemove` function.\n *\n * ```jsx\n * import { useIsPresent } from \"framer-motion\"\n *\n * export const Component = () => {\n * const isPresent = useIsPresent()\n *\n * useEffect(() => {\n * !isPresent && console.log(\"I've been removed!\")\n * }, [isPresent])\n *\n * return <div />\n * }\n * ```\n *\n * @public\n */\nfunction useIsPresent() {\n return isPresent(useContext(PresenceContext));\n}\nfunction isPresent(context) {\n return context === null ? true : context.isPresent;\n}\n\nexport { isPresent, useIsPresent, usePresence };\n","import { Children, isValidElement } from 'react';\n\nconst getChildKey = (child) => child.key || \"\";\nfunction onlyElements(children) {\n const filtered = [];\n // We use forEach here instead of map as map mutates the component key by preprending `.$`\n Children.forEach(children, (child) => {\n if (isValidElement(child))\n filtered.push(child);\n });\n return filtered;\n}\n\nexport { getChildKey, onlyElements };\n","\"use client\";\nimport { jsx, Fragment } from 'react/jsx-runtime';\nimport { useMemo, useRef, useState, useContext } from 'react';\nimport { LayoutGroupContext } from '../../context/LayoutGroupContext.mjs';\nimport { useConstant } from '../../utils/use-constant.mjs';\nimport { useIsomorphicLayoutEffect } from '../../utils/use-isomorphic-effect.mjs';\nimport { PresenceChild } from './PresenceChild.mjs';\nimport { usePresence } from './use-presence.mjs';\nimport { onlyElements, getChildKey } from './utils.mjs';\n\n/**\n * `AnimatePresence` enables the animation of components that have been removed from the tree.\n *\n * When adding/removing more than a single child, every child **must** be given a unique `key` prop.\n *\n * Any `motion` components that have an `exit` property defined will animate out when removed from\n * the tree.\n *\n * ```jsx\n * import { motion, AnimatePresence } from 'framer-motion'\n *\n * export const Items = ({ items }) => (\n * <AnimatePresence>\n * {items.map(item => (\n * <motion.div\n * key={item.id}\n * initial={{ opacity: 0 }}\n * animate={{ opacity: 1 }}\n * exit={{ opacity: 0 }}\n * />\n * ))}\n * </AnimatePresence>\n * )\n * ```\n *\n * You can sequence exit animations throughout a tree using variants.\n *\n * If a child contains multiple `motion` components with `exit` props, it will only unmount the child\n * once all `motion` components have finished animating out. Likewise, any components using\n * `usePresence` all need to call `safeToRemove`.\n *\n * @public\n */\nconst AnimatePresence = ({ children, custom, initial = true, onExitComplete, presenceAffectsLayout = true, mode = \"sync\", propagate = false, anchorX = \"left\", }) => {\n const [isParentPresent, safeToRemove] = usePresence(propagate);\n /**\n * Filter any children that aren't ReactElements. We can only track components\n * between renders with a props.key.\n */\n const presentChildren = useMemo(() => onlyElements(children), [children]);\n /**\n * Track the keys of the currently rendered children. This is used to\n * determine which children are exiting.\n */\n const presentKeys = propagate && !isParentPresent ? [] : presentChildren.map(getChildKey);\n /**\n * If `initial={false}` we only want to pass this to components in the first render.\n */\n const isInitialRender = useRef(true);\n /**\n * A ref containing the currently present children. When all exit animations\n * are complete, we use this to re-render the component with the latest children\n * *committed* rather than the latest children *rendered*.\n */\n const pendingPresentChildren = useRef(presentChildren);\n /**\n * Track which exiting children have finished animating out.\n */\n const exitComplete = useConstant(() => new Map());\n /**\n * Save children to render as React state. To ensure this component is concurrent-safe,\n * we check for exiting children via an effect.\n */\n const [diffedChildren, setDiffedChildren] = useState(presentChildren);\n const [renderedChildren, setRenderedChildren] = useState(presentChildren);\n useIsomorphicLayoutEffect(() => {\n isInitialRender.current = false;\n pendingPresentChildren.current = presentChildren;\n /**\n * Update complete status of exiting children.\n */\n for (let i = 0; i < renderedChildren.length; i++) {\n const key = getChildKey(renderedChildren[i]);\n if (!presentKeys.includes(key)) {\n if (exitComplete.get(key) !== true) {\n exitComplete.set(key, false);\n }\n }\n else {\n exitComplete.delete(key);\n }\n }\n }, [renderedChildren, presentKeys.length, presentKeys.join(\"-\")]);\n const exitingChildren = [];\n if (presentChildren !== diffedChildren) {\n let nextChildren = [...presentChildren];\n /**\n * Loop through all the currently rendered components and decide which\n * are exiting.\n */\n for (let i = 0; i < renderedChildren.length; i++) {\n const child = renderedChildren[i];\n const key = getChildKey(child);\n if (!presentKeys.includes(key)) {\n nextChildren.splice(i, 0, child);\n exitingChildren.push(child);\n }\n }\n /**\n * If we're in \"wait\" mode, and we have exiting children, we want to\n * only render these until they've all exited.\n */\n if (mode === \"wait\" && exitingChildren.length) {\n nextChildren = exitingChildren;\n }\n setRenderedChildren(onlyElements(nextChildren));\n setDiffedChildren(presentChildren);\n /**\n * Early return to ensure once we've set state with the latest diffed\n * children, we can immediately re-render.\n */\n return null;\n }\n if (process.env.NODE_ENV !== \"production\" &&\n mode === \"wait\" &&\n renderedChildren.length > 1) {\n 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.`);\n }\n /**\n * If we've been provided a forceRender function by the LayoutGroupContext,\n * we can use it to force a re-render amongst all surrounding components once\n * all components have finished animating out.\n */\n const { forceRender } = useContext(LayoutGroupContext);\n return (jsx(Fragment, { children: renderedChildren.map((child) => {\n const key = getChildKey(child);\n const isPresent = propagate && !isParentPresent\n ? false\n : presentChildren === renderedChildren ||\n presentKeys.includes(key);\n const onExit = () => {\n if (exitComplete.has(key)) {\n exitComplete.set(key, true);\n }\n else {\n return;\n }\n let isEveryExitComplete = true;\n exitComplete.forEach((isExitComplete) => {\n if (!isExitComplete)\n isEveryExitComplete = false;\n });\n if (isEveryExitComplete) {\n forceRender?.();\n setRenderedChildren(pendingPresentChildren.current);\n propagate && safeToRemove?.();\n onExitComplete && onExitComplete();\n }\n };\n return (jsx(PresenceChild, { isPresent: isPresent, initial: !isInitialRender.current || initial\n ? undefined\n : false, custom: custom, presenceAffectsLayout: presenceAffectsLayout, mode: mode, onExitComplete: isPresent ? undefined : onExit, anchorX: anchorX, children: child }, key));\n }) }));\n};\n\nexport { AnimatePresence };\n","import {\n useMutation,\n useQueryClient,\n useSuspenseQuery,\n} from \"@tanstack/react-query\";\nimport { AnimatePresence } from \"framer-motion\";\nimport {\n CheckIcon,\n CopyIcon,\n EyeIcon,\n EyeOffIcon,\n PencilLineIcon,\n RotateCwIcon,\n TrashIcon,\n XIcon,\n} from \"lucide-react\";\nimport React, { useState } from \"react\";\nimport { Link } from \"react-router\";\nimport { Card, CardHeader } from \"zudoku/ui/Card.js\";\nimport {\n Dialog,\n DialogClose,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n DialogTrigger,\n} from \"zudoku/ui/Dialog.js\";\nimport { useZudoku } from \"../../components/context/ZudokuContext.js\";\nimport { Slot } from \"../../components/Slot.js\";\nimport { Button } from \"../../ui/Button.js\";\nimport { Input } from \"../../ui/Input.js\";\nimport { cn } from \"../../util/cn.js\";\nimport { type ApiConsumer, type ApiKey, type ApiKeyService } from \"./index.js\";\n\nexport const SettingsApiKeys = ({ service }: { service: ApiKeyService }) => {\n const context = useZudoku();\n const queryClient = useQueryClient();\n const [editingConsumerId, setEditingConsumerId] = useState<string | null>(\n null,\n );\n const [editingLabel, setEditingLabel] = useState<string>(\"\");\n const { data, isFetching } = useSuspenseQuery({\n queryFn: () => service.getConsumers(context),\n queryKey: [\"api-keys\"],\n retry: false,\n });\n\n const deleteKeyMutation = useMutation({\n mutationFn: ({\n consumerId,\n keyId,\n }: {\n consumerId: string;\n keyId: string;\n }) => {\n if (!service.deleteKey) {\n throw new Error(\"deleteKey not implemented\");\n }\n\n return service.deleteKey(consumerId, keyId, context);\n },\n onMutate: async ({ consumerId, keyId }) => {\n await queryClient.cancelQueries({ queryKey: [\"api-keys\"] });\n const previousData = queryClient.getQueryData<ApiConsumer[]>([\n \"api-keys\",\n ]);\n queryClient.setQueryData<ApiConsumer[]>([\"api-keys\"], (old) => {\n if (!old) {\n return old;\n }\n\n return old.map((consumer) => {\n if (consumer.id === consumerId) {\n return {\n ...consumer,\n apiKeys: consumer.apiKeys.filter((key) => key.id !== keyId),\n };\n }\n return consumer;\n });\n });\n\n return { previousData };\n },\n onError: (err, variables, context) => {\n if (context?.previousData) {\n queryClient.setQueryData([\"api-keys\"], context.previousData);\n }\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: [\"api-keys\"] });\n },\n });\n\n const updateConsumerMutation = useMutation({\n mutationFn: ({\n consumerId,\n label,\n }: {\n consumerId: string;\n label: string;\n }) => {\n if (!service.updateConsumer) {\n throw new Error(\"updateConsumer not implemented\");\n }\n\n return service.updateConsumer({ id: consumerId, label }, context);\n },\n onMutate: async ({ consumerId, label }) => {\n await queryClient.cancelQueries({ queryKey: [\"api-keys\"] });\n\n const previousData = queryClient.getQueryData([\"api-keys\"]);\n queryClient.setQueryData<ApiConsumer[]>([\"api-keys\"], (old) => {\n if (!old) {\n return old;\n }\n\n return old.map((consumer) => {\n if (consumer.id === consumerId) {\n return {\n ...consumer,\n label,\n };\n }\n return consumer;\n });\n });\n\n return { previousData };\n },\n onError: (err, variables, context) => {\n if (context?.previousData) {\n queryClient.setQueryData([\"api-keys\"], context.previousData);\n }\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: [\"api-keys\"] });\n },\n });\n\n const rollKeyMutation = useMutation({\n mutationFn: (id: string) => {\n if (!service.rollKey) {\n throw new Error(\"rollKey not implemented\");\n }\n\n return service.rollKey(id, context);\n },\n onSuccess: () => queryClient.invalidateQueries({ queryKey: [\"api-keys\"] }),\n });\n\n const handleStartEdit = (consumerId: string, currentLabel: string) => {\n setEditingConsumerId(consumerId);\n setEditingLabel(currentLabel);\n };\n\n const handleSaveEdit = (consumerId: string) => {\n if (editingLabel.trim()) {\n updateConsumerMutation.mutate({\n consumerId,\n label: editingLabel.trim(),\n });\n }\n setEditingConsumerId(null);\n setEditingLabel(\"\");\n };\n\n const handleCancelEdit = () => {\n setEditingConsumerId(null);\n setEditingLabel(\"\");\n };\n\n return (\n <div className=\"max-w-screen-lg h-full pt-(--padding-content-top) pb-(--padding-content-bottom)\">\n <Slot.Target name=\"api-keys-list-page\" />\n\n <div className=\"flex justify-between pb-3\">\n <h1 className=\"font-medium text-2xl\">API Keys</h1>\n {service.createKey && (\n <Button asChild>\n <Link to=\"/settings/api-keys/new\">Create API Key</Link>\n </Button>\n )}\n </div>\n <p>Create, manage, and monitor your API keys</p>\n\n <Slot.Target name=\"api-keys-list-page-before-keys\" />\n\n <div className=\"h-8\"></div>\n <div className=\"grid grid-cols-8\">\n {data.length === 0 ? (\n <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\">\n <p className=\"text-center\">\n You have no API keys yet.\n <br />\n {service.createKey && \"Get started and create your first key.\"}\n </p>\n {service.createKey && (\n <Button asChild variant=\"outline\">\n <Link to=\"/settings/api-keys/new\">Create API Key</Link>\n </Button>\n )}\n </div>\n ) : (\n <ul\n className={cn(\n \"grid grid-cols-1 divide-y divide-border col-span-6\",\n \"lg:grid-cols-[1fr_min-content]\",\n )}\n >\n {data.map((consumers) => (\n <Card\n className=\"grid grid-cols-subgrid col-span-full items-center mb-4 group\"\n key={consumers.id}\n >\n <CardHeader className=\"border-b col-span-full grid-cols-subgrid grid\">\n <div className=\"h-10 flex flex-col text-sm justify-center\">\n <div className=\"font-medium text-lg flex items-center gap-2\">\n {editingConsumerId === consumers.id ? (\n <div className=\"flex items-center gap-2 w-full\">\n <Input\n maxLength={32}\n value={editingLabel}\n onChange={(e) => setEditingLabel(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === \"Enter\") {\n handleSaveEdit(consumers.id);\n } else if (e.key === \"Escape\") {\n handleCancelEdit();\n }\n }}\n className=\"text-lg font-medium\"\n autoFocus\n />\n <div className=\"flex items-center\">\n <Button\n size=\"icon\"\n variant=\"ghost\"\n onClick={() => handleSaveEdit(consumers.id)}\n disabled={!editingLabel.trim()}\n >\n <CheckIcon size={16} />\n </Button>\n <Button\n size=\"icon\"\n variant=\"ghost\"\n onClick={handleCancelEdit}\n >\n <XIcon size={16} />\n </Button>\n </div>\n </div>\n ) : (\n <>{consumers.label}</>\n )}\n <div className=\"text-muted-foreground text-xs\">\n {consumers.createdOn}\n </div>\n </div>\n <div className=\"text-muted-foreground text-xs\">\n {consumers.createdOn && (\n <div>\n Created on{\" \"}\n {new Date(consumers.createdOn).toLocaleDateString()}\n </div>\n )}\n {consumers.expiresOn && (\n <div>\n Expires on{\" \"}\n {new Date(consumers.expiresOn).toLocaleDateString()}\n </div>\n )}\n </div>\n </div>\n\n <div className=\"flex justify-end\">\n {service.updateConsumer && (\n <Button\n size=\"icon\"\n variant=\"ghost\"\n onClick={() =>\n handleStartEdit(consumers.id, consumers.label)\n }\n className={cn(\n editingConsumerId === consumers.id &&\n \"opacity-0! pointer-events-none\",\n )}\n disabled={editingConsumerId === consumers.id}\n >\n <PencilLineIcon size={16} />\n </Button>\n )}\n {service.rollKey && (\n <Dialog>\n <DialogTrigger asChild>\n <Button\n size=\"icon\"\n title=\"Roll this key\"\n variant=\"ghost\"\n disabled={rollKeyMutation.isPending}\n className={\n rollKeyMutation.isPending\n ? \"animate-spin\"\n : undefined\n }\n >\n <RotateCwIcon size={16} />\n </Button>\n </DialogTrigger>\n <DialogContent>\n <DialogHeader>\n <DialogTitle>Roll API Key</DialogTitle>\n <DialogDescription>\n Are you sure you want to roll this API key?\n </DialogDescription>\n </DialogHeader>\n <DialogFooter>\n <DialogClose asChild>\n <Button variant=\"outline\">Cancel</Button>\n </DialogClose>\n <DialogClose asChild>\n <Button\n onClick={() => {\n rollKeyMutation.mutate(consumers.id);\n }}\n >\n Roll Key\n </Button>\n </DialogClose>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n )}\n </div>\n </CardHeader>\n <div className=\"col-span-full grid-cols-subgrid grid\">\n <AnimatePresence>\n {consumers.apiKeys.map((apiKey) => (\n <React.Fragment key={apiKey.id}>\n <RevealApiKey\n apiKey={apiKey}\n onDeleteKey={() => {\n deleteKeyMutation.mutate({\n consumerId: consumers.id,\n keyId: apiKey.id,\n });\n }}\n className={\n deleteKeyMutation.variables?.keyId === apiKey.id &&\n (deleteKeyMutation.isPending || isFetching)\n ? \"opacity-10!\"\n : undefined\n }\n />\n <div className=\"col-span-full h-px bg-border\"></div>\n </React.Fragment>\n ))}\n </AnimatePresence>\n </div>\n </Card>\n ))}\n </ul>\n )}\n </div>\n </div>\n );\n};\n\nconst getTimeAgo = (date: string) => {\n const now = new Date();\n const created = new Date(date);\n const diffInSeconds = Math.floor((now.getTime() - created.getTime()) / 1000);\n\n const rtf = new Intl.RelativeTimeFormat(\"en\", { numeric: \"auto\" });\n\n if (diffInSeconds < 60) return rtf.format(-diffInSeconds, \"second\");\n if (diffInSeconds < 3600)\n return rtf.format(-Math.floor(diffInSeconds / 60), \"minute\");\n if (diffInSeconds < 86400)\n return rtf.format(-Math.floor(diffInSeconds / 3600), \"hour\");\n if (diffInSeconds < 2592000)\n return rtf.format(-Math.floor(diffInSeconds / 86400), \"day\");\n if (diffInSeconds < 31536000)\n return rtf.format(-Math.floor(diffInSeconds / 2592000), \"month\");\n return rtf.format(-Math.floor(diffInSeconds / 31536000), \"year\");\n};\n\nconst RevealApiKey = ({\n apiKey,\n onDeleteKey,\n className,\n}: {\n apiKey: ApiKey;\n onDeleteKey: () => void;\n className?: string;\n}) => {\n const [revealed, setRevealed] = useState(false);\n const [copied, setCopied] = useState(false);\n\n const { key, createdOn, expiresOn } = apiKey;\n const isExpired = expiresOn && new Date(expiresOn) < new Date();\n const daysUntilExpiry = expiresOn\n ? Math.ceil(\n (new Date(expiresOn).getTime() - new Date().getTime()) /\n (1000 * 60 * 60 * 24),\n )\n : Infinity;\n const expiresSoon = daysUntilExpiry <= 7 && !isExpired;\n\n return (\n <div className={cn(\"grid col-span-full grid-cols-subgrid p-6\", className)}>\n <div className=\"flex flex-col gap-1\">\n <div className=\"flex gap-2 items-center text-sm border rounded-md w-fit px-1\">\n <div className=\"font-mono truncate h-9 items-center flex px-2 text-xs gap-2\">\n <div\n className={cn(\n \"rounded-full w-2 h-2 bg-emerald-400 mr-2\",\n (expiresSoon || isExpired) && \"bg-neutral-200\",\n )}\n ></div>\n <span>\n <span className={revealed ? \"\" : \"opacity-20\"}>\n {revealed\n ? key.slice(0, -5)\n : \"**** \".repeat(key.slice(0, -5).length / 5) +\n \"*\".repeat(key.slice(0, -5).length % 5)}\n </span>\n <span>{key.slice(-5)}</span>\n </span>\n </div>\n <Button\n variant=\"ghost\"\n onClick={() => setRevealed((prev) => !prev)}\n size=\"icon\"\n >\n {revealed ? <EyeOffIcon size={16} /> : <EyeIcon size={16} />}\n </Button>\n <Button\n variant=\"ghost\"\n onClick={() => {\n void navigator.clipboard.writeText(key).then(() => {\n setCopied(true);\n setTimeout(() => setCopied(false), 2000);\n });\n }}\n size=\"icon\"\n >\n {copied ? <CheckIcon size={16} /> : <CopyIcon size={16} />}\n </Button>\n </div>\n <div className=\"flex gap-1 mt-0.5 text-nowrap\">\n {createdOn && (\n <span className=\"text-xs text-muted-foreground\">\n Created {getTimeAgo(createdOn)}.\n </span>\n )}{\" \"}\n {expiresOn && expiresSoon && (\n <span className=\"text-xs text-primary\">\n Expires in {daysUntilExpiry}{\" \"}\n {daysUntilExpiry === 1 ? \"day\" : \"days\"}.\n </span>\n )}\n {expiresOn && isExpired && (\n <span className=\"text-xs text-primary\">\n Expired{\" \"}\n {daysUntilExpiry === 0\n ? \"today.\"\n : `${daysUntilExpiry * -1} days ago.`}\n </span>\n )}\n </div>\n </div>\n <div className=\"flex justify-end\">\n {isExpired && onDeleteKey && (\n <Dialog>\n <DialogTrigger asChild>\n <Button variant=\"ghost\" size=\"icon\">\n <TrashIcon size={16} />\n </Button>\n </DialogTrigger>\n <DialogContent>\n <DialogHeader>\n <DialogTitle>Delete API Key</DialogTitle>\n <DialogDescription>\n Are you sure you want to delete this API key?\n </DialogDescription>\n </DialogHeader>\n <DialogFooter>\n <DialogClose asChild>\n <Button variant=\"outline\">Cancel</Button>\n </DialogClose>\n <DialogClose asChild>\n <Button\n onClick={() => {\n onDeleteKey();\n }}\n >\n Delete\n </Button>\n </DialogClose>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n )}\n </div>\n </div>\n );\n};\n","import { KeyRoundIcon } from \"lucide-react\";\nimport { type RouteObject } from \"react-router\";\nimport { type ZudokuContext } from \"../../core/ZudokuContext.js\";\nimport {\n type ApiIdentityPlugin,\n type ProfileMenuPlugin,\n type ZudokuPlugin,\n} from \"../../core/plugins.js\";\nimport { RouterError } from \"../../errors/RouterError.js\";\nimport invariant from \"../../util/invariant.js\";\nimport { ProtectedRoute } from \"./ProtectedRoute.js\";\nimport { SettingsApiKeys } from \"./SettingsApiKeys.js\";\n\nconst DEFAULT_API_KEY_ENDPOINT = \"https://api.zuploedge.com/v2/client\";\n\nexport type ApiKeyService = {\n getConsumers: (context: ZudokuContext) => Promise<ApiConsumer[]>;\n rollKey?: (consumerId: string, context: ZudokuContext) => Promise<void>;\n deleteKey?: (\n consumerId: string,\n keyId: string,\n context: ZudokuContext,\n ) => Promise<void>;\n updateConsumer?: (\n consumer: { id: string; label?: string },\n context: ZudokuContext,\n ) => Promise<void>;\n getUsage?: (apiKeys: string[], context: ZudokuContext) => Promise<void>;\n createKey?: (\n apiKey: { description: string; expiresOn?: string },\n context: ZudokuContext,\n ) => Promise<void>;\n};\n\nexport type ApiKeyPluginOptions =\n | ApiKeyService\n | ({ deploymentName: string } & Partial<ApiKeyService>);\n\nexport interface ApiKey {\n id: string;\n description?: string;\n createdOn?: string;\n updatedOn?: string;\n expiresOn?: string;\n key: string;\n}\n\nexport interface ApiConsumer {\n id: string;\n label: string;\n apiKeys: ApiKey[];\n description?: string;\n createdOn?: string;\n updatedOn?: string;\n expiresOn?: string;\n key?: ApiKey;\n}\n\nconst createDefaultHandler = (deploymentName: string): ApiKeyService => {\n return {\n deleteKey: async (consumerId, keyId, context) => {\n const request = new Request(\n DEFAULT_API_KEY_ENDPOINT +\n `/${deploymentName}/consumers/${consumerId}/keys/${keyId}`,\n {\n method: \"DELETE\",\n },\n );\n await context.signRequest(request);\n\n const response = await fetch(request);\n invariant(response.ok, \"Failed to delete API key\");\n },\n updateConsumer: async (consumer, context) => {\n const response = await fetch(\n await context.signRequest(\n new Request(\n DEFAULT_API_KEY_ENDPOINT +\n `/${deploymentName}/consumers/${consumer.id}`,\n {\n method: \"PATCH\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({\n label: consumer.label,\n }),\n },\n ),\n ),\n );\n invariant(response.ok, \"Failed to update API key description\");\n },\n rollKey: async (consumerId, context) => {\n const response = await fetch(\n await context.signRequest(\n new Request(\n DEFAULT_API_KEY_ENDPOINT +\n `/${deploymentName}/consumers/${consumerId}/roll-key`,\n {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({\n expiresOn: new Date(),\n }),\n },\n ),\n ),\n );\n invariant(response.ok, \"Failed to delete API key\");\n },\n getConsumers: async (context) => {\n const request = new Request(\n DEFAULT_API_KEY_ENDPOINT + `/${deploymentName}/consumers`,\n );\n await context.signRequest(request);\n\n const keys = await fetch(request);\n invariant(keys.ok, \"Failed to fetch API keys\");\n\n const data = (await keys.json()) as {\n data: [\n {\n id: string;\n label: string;\n apiKeys: {\n data: ApiKey[];\n };\n },\n ];\n };\n\n return data.data.map((consumer) => ({\n id: consumer.id,\n label: consumer.label || \"API Key\",\n apiKeys: consumer.apiKeys.data,\n key: consumer.apiKeys.data.at(0),\n }));\n },\n };\n};\n\nexport const createApiKeyService = <T extends ApiKeyService>(service: T): T =>\n service;\n\nexport const apiKeyPlugin = (\n options: ApiKeyPluginOptions,\n): ZudokuPlugin & ApiIdentityPlugin & ProfileMenuPlugin => {\n const service: ApiKeyService =\n \"deploymentName\" in options\n ? createDefaultHandler(options.deploymentName)\n : options;\n\n return {\n getProfileMenuItems: () => [\n {\n label: \"API Keys\",\n path: \"/settings/api-keys\",\n category: \"middle\",\n icon: KeyRoundIcon,\n },\n ],\n\n getIdentities: async (context) => {\n try {\n const consumers = await service.getConsumers(context);\n\n return consumers.map((consumer) => ({\n authorizeRequest: (request) => {\n request.headers.set(\n \"Authorization\",\n `Bearer ${consumer.apiKeys.at(0)?.key}`,\n );\n return request;\n },\n id: consumer.id,\n label: consumer.description ?? consumer.id,\n }));\n } catch {\n return [];\n }\n },\n getRoutes: (): RouteObject[] => {\n // TODO: Make lazy\n return [\n {\n element: <ProtectedRoute />,\n errorElement: <RouterError />,\n children: [\n {\n path: \"/settings/api-keys\",\n element: <SettingsApiKeys service={service} />,\n },\n // {\n // path: \"/settings/api-keys/new\",\n // element: <CreateApiKey service={service} />,\n // },\n ],\n },\n ];\n },\n };\n};\n"],"names":["ProtectedRoute","auth","useAuth","jsx","Outlet","jsxs","Button","DeveloperHint","LayoutGroupContext","createContext","useConstant","init","ref","useRef","isBrowser","useIsomorphicLayoutEffect","useLayoutEffect","useEffect","PresenceContext","isObject","value","isHTMLElement","element","MotionConfigContext","p","PopChildMeasure","React","prevProps","parent","parentWidth","size","PopChild","children","isPresent","anchorX","id","useId","nonce","useContext","useInsertionEffect","width","height","top","left","right","x","style","PresenceChild","initial","onExitComplete","custom","presenceAffectsLayout","mode","presenceChildren","newChildrenMap","isReusedContext","context","useMemo","childId","isComplete","_","key","usePresence","subscribe","register","safeToRemove","useCallback","getChildKey","child","onlyElements","filtered","Children","isValidElement","AnimatePresence","propagate","isParentPresent","presentChildren","presentKeys","isInitialRender","pendingPresentChildren","exitComplete","diffedChildren","setDiffedChildren","useState","renderedChildren","setRenderedChildren","i","exitingChildren","nextChildren","forceRender","Fragment","onExit","isEveryExitComplete","isExitComplete","SettingsApiKeys","service","useZudoku","queryClient","useQueryClient","editingConsumerId","setEditingConsumerId","editingLabel","setEditingLabel","data","isFetching","useSuspenseQuery","deleteKeyMutation","useMutation","consumerId","keyId","previousData","old","consumer","err","variables","updateConsumerMutation","label","rollKeyMutation","handleStartEdit","currentLabel","handleSaveEdit","handleCancelEdit","Slot","Link","cn","consumers","Card","CardHeader","Input","e","CheckIcon","XIcon","PencilLineIcon","Dialog","DialogTrigger","RotateCwIcon","DialogContent","DialogHeader","DialogTitle","DialogDescription","DialogFooter","DialogClose","apiKey","RevealApiKey","getTimeAgo","date","now","created","diffInSeconds","rtf","onDeleteKey","className","revealed","setRevealed","copied","setCopied","createdOn","expiresOn","isExpired","daysUntilExpiry","expiresSoon","prev","EyeOffIcon","EyeIcon","CopyIcon","TrashIcon","DEFAULT_API_KEY_ENDPOINT","createDefaultHandler","deploymentName","request","response","invariant","keys","createApiKeyService","apiKeyPlugin","options","KeyRoundIcon","RouterError"],"mappings":";;;;;;;;;;;;;;AAKO,MAAMA,KAAiB,MAAM;AAClC,QAAMC,IAAOC,GAAQ;AAGjB,SAAAD,EAAK,iBAAiBA,EAAK,YACtB,OAGFA,EAAK,kBACTE,gBAAAA,MAAAC,IAAA,CAAA,CAAO,IACLH,EAAK,gBAQPI,gB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]}
@@ -1,6 +1,6 @@
1
1
  import { j as o } from "./jsx-runtime-C5mzlN2N.js";
2
2
  import a from "react";
3
- import { P as n } from "./Markdown-Cm4kj26S.js";
3
+ import { P as n } from "./Markdown-BUE2ViaD.js";
4
4
  import { c } from "./cn-wvCW-ho6.js";
5
5
  import { u as p } from "./useExposedProps-BZQkZneR.js";
6
6
  const u = ({
@@ -50,7 +50,7 @@ const m = (a) => ({
50
50
  const c = {
51
51
  path: e,
52
52
  lazy: async () => {
53
- const { MdxPage: u } = await import("./MdxPage-fDGQtB5w.js"), { default: h, ...p } = await i();
53
+ const { MdxPage: u } = await import("./MdxPage-By4UkRkI.js"), { default: h, ...p } = await i();
54
54
  return {
55
55
  element: /* @__PURE__ */ f.jsx(
56
56
  u,
@@ -1,9 +1,9 @@
1
1
  import "./jsx-runtime-C5mzlN2N.js";
2
2
  import "lucide-react";
3
3
  import "./chunk-DQRVZFIR-BblmKnHy.js";
4
- import "./hook-k7PfUIsj.js";
4
+ import "./hook-wIlTGE-2.js";
5
5
  import "./ui/Button.js";
6
- import { F as a, U as s, H as n } from "./index-yqBxBqxF.js";
6
+ import { F as a, U as s, H as n } from "./index-RFzRn4fM.js";
7
7
  export {
8
8
  a as GetSidebarOperationsQuery,
9
9
  s as UNTAGGED_PATH,
@@ -1,12 +1,12 @@
1
1
  import { j as e } from "./jsx-runtime-C5mzlN2N.js";
2
2
  import { C as k } from "./ClientOnly-E7hGysn1.js";
3
3
  import { VisuallyHidden as v } from "@radix-ui/react-visually-hidden";
4
- import { u as N, k as y, l as j, o as _, j as L } from "./hook-k7PfUIsj.js";
4
+ import { u as N, k as y, l as j, o as _, j as L } from "./hook-wIlTGE-2.js";
5
5
  import { useRef as S, useLayoutEffect as T, useState as w } from "react";
6
6
  import { B as E } from "./Button-BE9IVkWV.js";
7
7
  import { C as R, a as f, b as p, c as F, d as I, e as q, f as P } from "./Callout-CoVxYafP.js";
8
8
  import { c as $ } from "./Dialog-BxpuVLh9.js";
9
- import { S as A } from "./RouteGuard-CZ_uLv3g.js";
9
+ import { S as A } from "./RouteGuard-CgmsSw7T.js";
10
10
  import { BracketsIcon as D, FileTextIcon as O } from "lucide-react";
11
11
  import { a as B, L as g } from "./chunk-DQRVZFIR-BblmKnHy.js";
12
12
  const U = async ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zudoku",
3
- "version": "0.46.2",
3
+ "version": "0.47.0",
4
4
  "type": "module",
5
5
  "homepage": "https://zudoku.dev",
6
6
  "repository": {
@@ -36,10 +36,6 @@
36
36
  "import": "./lib/ui/*.js",
37
37
  "types": "./dist/lib/ui/*.d.ts"
38
38
  },
39
- "./hooks": {
40
- "import": "./lib/hooks/index.js",
41
- "types": "./dist/lib/hooks/index.d.ts"
42
- },
43
39
  "./client": {
44
40
  "types": "./client.d.ts"
45
41
  },
@@ -59,6 +55,10 @@
59
55
  "import": "./lib/zudoku.auth-supabase.js",
60
56
  "types": "./dist/lib/authentication/providers/supabase.d.ts"
61
57
  },
58
+ "./auth/azureb2c": {
59
+ "import": "./lib/zudoku.auth-azureb2c.js",
60
+ "types": "./dist/lib/authentication/providers/azureb2c.d.ts"
61
+ },
62
62
  "./plugins": {
63
63
  "import": "./lib/zudoku.plugins.js",
64
64
  "types": "./dist/lib/core/plugins.d.ts"
@@ -95,6 +95,10 @@
95
95
  "import": "./lib/zudoku.plugin-search-pagefind.js",
96
96
  "types": "./dist/lib/plugins/search-pagefind/index.d.ts"
97
97
  },
98
+ "./hooks": {
99
+ "import": "./lib/zudoku.hooks.js",
100
+ "types": "./dist/lib/hooks/index.d.ts"
101
+ },
98
102
  "./components": {
99
103
  "import": "./lib/zudoku.components.js",
100
104
  "types": "./dist/lib/components/index.d.ts"
@@ -159,11 +163,11 @@
159
163
  "@radix-ui/react-tooltip": "1.2.7",
160
164
  "@radix-ui/react-visually-hidden": "1.2.3",
161
165
  "@scalar/openapi-parser": "0.10.17",
162
- "@sentry/node": "9.12.0",
163
- "@shikijs/langs": "3.4.2",
164
- "@shikijs/rehype": "3.4.2",
165
- "@shikijs/themes": "3.4.2",
166
- "@shikijs/transformers": "3.4.2",
166
+ "@sentry/node": "9.26.0",
167
+ "@shikijs/langs": "3.5.0",
168
+ "@shikijs/rehype": "3.5.0",
169
+ "@shikijs/themes": "3.5.0",
170
+ "@shikijs/transformers": "3.5.0",
167
171
  "@sindresorhus/slugify": "2.2.1",
168
172
  "@stefanprobst/rehype-extract-toc": "3.0.0",
169
173
  "@tailwindcss/typography": "0.5.16",
@@ -183,14 +187,14 @@
183
187
  "devlop": "^1.1.0",
184
188
  "dotenv": "16.5.0",
185
189
  "embla-carousel-react": "8.6.0",
186
- "estree-util-value-to-estree": "3.3.3",
190
+ "estree-util-value-to-estree": "3.4.0",
187
191
  "express": "5.1.0",
188
192
  "fast-equals": "5.2.2",
189
193
  "framer-motion": "^12.12.2",
190
- "glob": "11.0.1",
194
+ "glob": "11.0.2",
191
195
  "graphql": "16.11.0",
192
196
  "graphql-type-json": "0.3.2",
193
- "graphql-yoga": "5.13.3",
197
+ "graphql-yoga": "5.13.5",
194
198
  "gray-matter": "4.0.3",
195
199
  "hast-util-to-jsx-runtime": "^2.3.6",
196
200
  "hast-util-to-string": "3.0.1",
@@ -227,7 +231,7 @@
227
231
  "remark-rehype": "^11.1.2",
228
232
  "rollup": "4.41.1",
229
233
  "semver": "7.7.1",
230
- "shiki": "3.4.2",
234
+ "shiki": "3.5.0",
231
235
  "sitemap": "8.0.0",
232
236
  "spin-delay": "2.0.1",
233
237
  "strip-ansi": "7.1.0",
@@ -241,7 +245,7 @@
241
245
  "vite": "6.3.5",
242
246
  "yaml": "2.7.1",
243
247
  "yargs": "17.7.2",
244
- "zod": "3.24.2",
248
+ "zod": "3.25.51",
245
249
  "zod-validation-error": "3.4.1",
246
250
  "zustand": "5.0.3"
247
251
  },
@@ -264,7 +268,7 @@
264
268
  "@types/semver": "7.7.0",
265
269
  "@types/unist": "^3.0.3",
266
270
  "@types/yargs": "17.0.33",
267
- "@vitest/coverage-v8": "3.1.1",
271
+ "@vitest/coverage-v8": "3.2.1",
268
272
  "esbuild": "0.25.1",
269
273
  "happy-dom": "17.5.6",
270
274
  "mdast-util-mdx": "3.0.0",
@@ -276,13 +280,27 @@
276
280
  },
277
281
  "peerDependencies": {
278
282
  "react": ">=19",
279
- "react-dom": ">=19"
280
- },
281
- "optionalDependencies": {
283
+ "react-dom": ">=19",
284
+ "@azure/msal-browser": "^4.13.0",
282
285
  "@clerk/clerk-js": "^5.63.1",
283
286
  "@sentry/react": "^9.12.0",
284
287
  "@supabase/supabase-js": "^2.49.4"
285
288
  },
289
+ "optionalDependencies": {},
290
+ "peerDependenciesMeta": {
291
+ "@azure/msal-browser": {
292
+ "optional": true
293
+ },
294
+ "@clerk/clerk-js": {
295
+ "optional": true
296
+ },
297
+ "@sentry/react": {
298
+ "optional": true
299
+ },
300
+ "@supabase/supabase-js": {
301
+ "optional": true
302
+ }
303
+ },
286
304
  "scripts": {
287
305
  "build": "tsc --project tsconfig.app.json",
288
306
  "build:dev": "esbuild './src/**/*.ts' --format=esm --platform=node --target=node22 --outdir=dist --splitting --log-level=warning",