Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
wip: update view secret by id page
Scott Wilsonc762efa729f1
diff --git a/frontend/src/pages/public/ViewSharedSecretByIDPage/ViewSharedSecretByIDPage.tsx b/frontend/src/pages/public/ViewSharedSecretByIDPage/ViewSharedSecretByIDPage.tsxindex a3546017a9..0d65a07152 100644--- a/frontend/src/pages/public/ViewSharedSecretByIDPage/ViewSharedSecretByIDPage.tsx+++ b/frontend/src/pages/public/ViewSharedSecretByIDPage/ViewSharedSecretByIDPage.tsx@@ -1,14 +1,14 @@import { useEffect, useMemo, useRef } from "react";import { Helmet } from "react-helmet";-import { faArrowRight } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";import { useNavigate, useParams } from "@tanstack/react-router";import { AxiosError } from "axios";import { addSeconds, formatISO } from "date-fns";-import { twMerge } from "tailwind-merge";+import { AuthPageBackground } from "@app/components/auth/AuthPageBackground";+import { AuthPageFooter } from "@app/components/auth/AuthPageFooter";+import { AuthPageHeader } from "@app/components/auth/AuthPageHeader";import { createNotification } from "@app/components/notifications";-import { Lottie } from "@app/components/v2";+import { Card, CardContent, CardHeader, CardTitle, PageLoader } from "@app/components/v3";import { SessionStorageKeys } from "@app/const";import { ROUTE_PATHS } from "@app/const/routes";import {@@ -131,12 +131,13 @@ export const ViewSharedSecretByIDPage = () => {const secret = accessMutation.data;const isPasswordProtected = secretDetails?.isPasswordProtected ?? false;const needsPassword = isPasswordProtected;- // only show password prompt if no critical error (403/404) occurred after submissionconst hasCriticalError = accessMutation.isError && (isForbidden || isNotFound);const showPasswordPrompt = needsPassword && !secret && !hasCriticalError;const isLoading = isLoadingDetails || (!needsPassword && accessMutation.isPending);- const hasCustomBranding = !!brandingConfig;+ const hasCustomBranding =+ !!brandingConfig &&+ (brandingConfig.hasLogo || brandingConfig.hasFavicon || !!brandingConfig.primaryColor);const logoUrl = brandingConfig?.hasLogo? `/api/v1/shared-secrets/public/${id}/branding/brand-logo`@@ -157,10 +158,8 @@ export const ViewSharedSecretByIDPage = () => {return {primaryColor: primary,secondaryColor: secondary,- // Text colors based on secondary brightness (for components)textColor: isSecondaryLight ? "#1a1a1a" : "#f5f5f5",textMutedColor: isSecondaryLight ? "#1a1a1acc" : "#f5f5f5cc",- // Panel and components based on secondary colorpanelBg: secondary,panelBorder: adjustColor(secondary, isSecondaryLight ? -30 : 30),inputBg: adjustColor(secondary, isSecondaryLight ? -15 : 15),@@ -205,144 +204,79 @@ export const ViewSharedSecretByIDPage = () => {}, [faviconUrl]);if (isLoading || isLoadingBrandingConfig) {+ return <PageLoader />;+ }++ const secretContent = (+ <>+ {(showPasswordPrompt || isInvalidCredential) && (+ <PasswordContainer+ isSubmitting={accessMutation.isPending}+ onPasswordSubmit={(pwd) => {+ accessMutation.mutate({ sharedSecretId: id, password: pwd });+ }}+ isInvalidCredential={!accessMutation.isPending && isInvalidCredential}+ brandingTheme={brandingTheme}+ />+ )}+ {secret && <SecretContainer secret={secret} brandingTheme={brandingTheme} />}+ {!showPasswordPrompt && !isInvalidCredential && activeError && !isUnauthorized && (+ <SecretErrorContainer brandingTheme={brandingTheme} error={errorMessage} />+ )}+ </>+ );++ // Custom branding: minimal layout with brand colors, no Infisical elements+ if (hasCustomBranding) {return (- <div className="flex h-screen w-screen items-center justify-center bg-bunker-800">- <Lottie isAutoPlay icon="infisical_loading" className="h-32 w-32" />- </div>+ <>+ <Helmet>+ <title>Securely Share Secrets</title>+ <meta property="og:image" content="/images/message.png" />+ </Helmet>+ <div+ className="flex min-h-screen flex-col items-center justify-center overflow-auto px-4 py-10 scheme-dark"+ style={backgroundStyle}+ >+ {brandingConfig?.hasLogo && (+ <img src={logoUrl} alt="Logo" className="mb-8 max-h-16 w-auto object-contain" />+ )}+ <div+ className="w-full max-w-xl rounded-lg border p-5"+ style={{+ backgroundColor: brandingTheme?.panelBg,+ borderColor: brandingTheme?.panelBorder,+ color: brandingTheme?.textColor+ }}+ >+ <h1 className="mb-5 text-lg font-semibold" style={{ color: brandingTheme?.textColor }}>+ View shared secret+ </h1>+ {secretContent}+ </div>+ </div>+ </>);}+ // Default: Infisical auth page layoutreturn (- <>+ <div className="relative flex max-h-screen min-h-screen flex-col overflow-y-auto bg-bunker-800 px-4 text-foreground scheme-dark">+ <AuthPageBackground /><Helmet>- <title>Securely Share Secrets{hasCustomBranding ? "" : " | Infisical"}</title>+ <title>Securely Share Secrets | Infisical</title><meta property="og:image" content="/images/message.png" />- <meta property="og:title" content="" />- <meta name="og:description" content="" /></Helmet>- <div- className={twMerge(- "flex h-screen flex-col justify-between overflow-auto text-gray-200 dark:scheme-dark",- !backgroundStyle && "bg-linear-to-tr from-mineshaft-700 to-bunker-800"- )}- style={backgroundStyle}- >- <div />- <div className="mx-auto w-full max-w-xl px-4 py-4 md:px-0">- <div className="mb-8 text-center">- <div className="mb-4 flex justify-center pt-8">- {hasCustomBranding ? (- <img- src={logoUrl}- height={90}- width={120}- alt="Logo"- className="max-h-24 w-auto object-contain"- />- ) : (- <a target="_blank" rel="noopener noreferrer" href="https://infisical.com">- <img- src={logoUrl}- height={90}- width={120}- alt="Infisical logo"- className="cursor-pointer"- />- </a>- )}- </div>- <h1- className={twMerge(- "bg-linear-to-b bg-clip-text text-center text-4xl font-medium text-transparent",- brandingTheme && isLightColor(brandingTheme.primaryColor)- ? "from-black to-bunker-500"- : "from-white to-bunker-200"- )}- >- View shared secret- </h1>- {!hasCustomBranding && (- <p className="text-md">- Powered by{" "}- <a- href="https://github.com/infisical/infisical"- target="_blank"- rel="noopener noreferrer"- className="text-bold bg-linear-to-tr from-yellow-500 to-primary-500 bg-clip-text text-transparent"- >- Infisical →- </a>- </p>- )}- </div>- {(showPasswordPrompt || isInvalidCredential) && (- <PasswordContainer- isSubmitting={accessMutation.isPending}- onPasswordSubmit={(pwd) => {- accessMutation.mutate({ sharedSecretId: id, password: pwd });- }}- isInvalidCredential={!accessMutation.isPending && isInvalidCredential}- brandingTheme={brandingTheme}- />- )}- {secret && <SecretContainer secret={secret} brandingTheme={brandingTheme} />}- {!showPasswordPrompt && !isInvalidCredential && activeError && !isUnauthorized && (- <SecretErrorContainer brandingTheme={brandingTheme} error={errorMessage} />- )}- {!hasCustomBranding && (- <>- <div className="m-auto my-8 flex w-full">- <div className="w-full border-t border-mineshaft-600" />- </div>- <div className="m-auto flex w-full flex-col rounded-md border border-primary-500/30 bg-primary/5 p-6 pt-5">- <p className="w-full pb-2 text-lg font-medium text-mineshaft-100 md:pb-3 md:text-xl">- Open source{" "}- <span className="bg-linear-to-tr from-yellow-500 to-primary-500 bg-clip-text text-transparent">- secret management- </span>{" "}- for developers- </p>- <div className="flex flex-col items-start sm:flex-row sm:items-center">- <p className="md:text-md text-md mr-4">- <a- href="https://github.com/infisical/infisical"- target="_blank"- rel="noopener noreferrer"- className="text-bold bg-linear-to-tr from-yellow-500 to-primary-500 bg-clip-text text-transparent"- >- Infisical- </a>{" "}- is the all-in-one secret management platform to securely manage secrets,- configs, and certificates across your team and infrastructure.- </p>- <div className="mt-4 cursor-pointer sm:mt-0">- <a target="_blank" rel="noopener noreferrer" href="https://infisical.com">- <div className="flex items-center justify-between rounded-md border border-mineshaft-400/40 bg-mineshaft-600 px-3 py-2 duration-200 hover:border-primary/60 hover:bg-primary/20 hover:text-white">- <p className="mr-4 whitespace-nowrap">Try Infisical</p>- <FontAwesomeIcon icon={faArrowRight} />- </div>- </a>- </div>- </div>- </div>- </>- )}- </div>- {hasCustomBranding ? (- <div />- ) : (- <div className="w-full bg-mineshaft-600 p-2">- <p className="text-center text-sm text-mineshaft-300">- Made with ❤️ by{" "}- <a className="text-primary" href="https://infisical.com">- Infisical- </a>- <br />- 235 2nd st, San Francisco, California, 94105, United States. 🇺🇸- </p>- </div>- )}+ <AuthPageHeader />+ <div className="relative z-10 my-auto flex flex-col items-center py-10">+ <Card className="w-full max-w-xl">+ <CardHeader>+ <CardTitle>View shared secret</CardTitle>+ </CardHeader>+ <CardContent>{secretContent}</CardContent>+ </Card></div>- </>+ <AuthPageFooter />+ </div>);};diff --git a/frontend/src/pages/public/ViewSharedSecretByIDPage/components/PasswordContainer.tsx b/frontend/src/pages/public/ViewSharedSecretByIDPage/components/PasswordContainer.tsxindex a7877bf187..3a39218e01 100644--- a/frontend/src/pages/public/ViewSharedSecretByIDPage/components/PasswordContainer.tsx+++ b/frontend/src/pages/public/ViewSharedSecretByIDPage/components/PasswordContainer.tsx@@ -1,11 +1,9 @@import { Controller, useForm } from "react-hook-form";-import { faArrowRight, faSpinner } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";import { zodResolver } from "@hookform/resolvers/zod";import { twMerge } from "tailwind-merge";import { z } from "zod";-import { Button, FormControl, IconButton, Input } from "@app/components/v2";+import { Button, Field, FieldError, FieldLabel, Input } from "@app/components/v3";import { BrandingTheme } from "../ViewSharedSecretByIDPage";@@ -44,78 +42,69 @@ export const PasswordContainer = ({: undefined;const inputStyle = brandingTheme- ? {+ ? ({backgroundColor: brandingTheme.inputBg,color: brandingTheme.textColor,"--muted-color": brandingTheme.textMutedColor,borderColor: brandingTheme.panelBorder- }+ } as React.CSSProperties): undefined;return (- <div- className={`rounded-lg border p-4 ${brandingTheme ? "" : "border-mineshaft-600 bg-mineshaft-800"}`}- style={panelStyle}- >+ <div style={panelStyle}><form onSubmit={handleSubmit(onFormSubmit)}><Controllercontrol={control}name="password"defaultValue=""render={({ field, fieldState: { error } }) => (- <div style={brandingTheme ? { color: brandingTheme.textColor } : undefined}>- <FormControl- isError={Boolean(error) || isInvalidCredential}- errorText={isInvalidCredential ? "Invalid credential" : error?.message}- isRequired- label="Password"- labelClassName="text-[var(--muted-color)]"+ <Field style={brandingTheme ? { color: brandingTheme.textColor } : undefined}>+ <FieldLabel+ className={brandingTheme ? "text-[var(--muted-color)]" : ""}+ style={+ brandingTheme+ ? ({ "--muted-color": brandingTheme.textMutedColor } as React.CSSProperties)+ : undefined+ }>- <div className="flex items-center justify-between gap-2 rounded-md">- <Input- {...field}- placeholder="Enter password to view secret"- type="password"- style={inputStyle}- className={twMerge(- "h-9",- brandingTheme &&- "border placeholder-[var(--muted-color)]/70 focus:ring-[var(--muted-color)]/50"- )}- containerClassName="bg-transparent border-transparent h-9"- />- <div className="flex">- <IconButton- ariaLabel="submit password"- colorSchema="secondary"- className="group relative size-9 hover:opacity-70"- onClick={handleSubmit(onFormSubmit)}- style={inputStyle}- >- <FontAwesomeIcon- className={isSubmitting ? "fa-spin" : ""}- icon={isSubmitting ? faSpinner : faArrowRight}- />- </IconButton>- </div>- </div>- </FormControl>- </div>+ Password+ </FieldLabel>+ <div className="flex items-center gap-2">+ <Input+ {...field}+ autoFocus+ placeholder="Enter password to view secret"+ type="password"+ style={inputStyle}+ className={twMerge(+ "flex-1",+ brandingTheme &&+ "border placeholder-[var(--muted-color)]/70 focus-visible:ring-[var(--muted-color)]/50"+ )}+ isError={Boolean(error) || isInvalidCredential}+ />+ </div>+ {(error || isInvalidCredential) && (+ <FieldError>+ {isInvalidCredential ? "Invalid credential" : error?.message}+ </FieldError>+ )}+ </Field>)}/>- </form>- {!brandingTheme && (<Button- className="w-full bg-mineshaft-700 py-3 text-bunker-200"- colorSchema="primary"- variant="outline_bg"- size="sm"- onClick={() => window.open("/share-secret", "_blank", "noopener")}- rightIcon={<FontAwesomeIcon icon={faArrowRight} className="pl-2" />}+ aria-label="submit password"+ variant="project"+ size="lg"+ isFullWidth+ className="mt-4"+ onClick={handleSubmit(onFormSubmit)}+ style={inputStyle}+ isPending={isSubmitting}>- Share Your Own Secret+ View Secret</Button>- )}+ </form></div>);};diff --git a/frontend/src/pages/public/ViewSharedSecretByIDPage/components/SecretContainer.tsx b/frontend/src/pages/public/ViewSharedSecretByIDPage/components/SecretContainer.tsxindex 4c603d18e2..17f92ced52 100644--- a/frontend/src/pages/public/ViewSharedSecretByIDPage/components/SecretContainer.tsx+++ b/frontend/src/pages/public/ViewSharedSecretByIDPage/components/SecretContainer.tsx@@ -1,13 +1,6 @@-import {- faArrowRight,- faCheck,- faCopy,- faEye,- faEyeSlash-} from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";+import { ClipboardCheckIcon, Copy, Eye, EyeOff, ForwardIcon } from "lucide-react";-import { Button, IconButton } from "@app/components/v2";+import { Button, IconButton } from "@app/components/v3";import { useTimedReset, useToggle } from "@app/hooks";import { TAccessSharedSecretResponse } from "@app/hooks/api/secretSharing";@@ -50,54 +43,57 @@ export const SecretContainer = ({ secret, brandingTheme }: Props) => {: undefined;return (- <div- className={`rounded-lg border p-4 ${brandingTheme ? "" : "border-mineshaft-600 bg-mineshaft-800"}`}- style={panelStyle}- >+ <div style={panelStyle}><divclassName={`flex items-center justify-between rounded-md border p-2 pl-3 text-base ${- brandingTheme ? "" : "border-mineshaft-600 bg-mineshaft-700/50 text-gray-400"+ brandingTheme ? "" : "border-border bg-container text-label"}`}style={secretDisplayStyle}><p className="break-all whitespace-pre-wrap">- {isVisible ? secret.secretValue : hiddenSecret}+ {isVisible+ ? `${secret.secretValue}fsdfdsfdsfdsfsdfdsfdsfsdfddfsdfdsfdsfsfdsfsdfsdfdsfsdfdsfsdfsdfdsfsdfsdfdsfdsfdsfsdfdsfdsfdsfs`+ : hiddenSecret}</p>- <div className="flex">+ <div className="ml-1 flex"><IconButton- ariaLabel="copy icon"- colorSchema="secondary"- className="group relative size-9 hover:opacity-70"+ aria-label="copy icon"+ variant="ghost"+ size="sm"onClick={() => {navigator.clipboard.writeText(secret.secretValue);setCopyTextSecret("Copied");}}style={iconButtonStyle}>- <FontAwesomeIcon icon={isCopyingSecret ? faCheck : faCopy} />+ {isCopyingSecret ? (+ <ClipboardCheckIcon className="size-4" />+ ) : (+ <Copy className="size-4" />+ )}</IconButton><IconButton- ariaLabel="toggle visibility"- colorSchema="secondary"- className="group relative ml-2 size-9 hover:opacity-70"+ aria-label="toggle visibility"+ variant="ghost"+ size="sm"+ className="ml-2"onClick={() => setIsVisible.toggle()}style={iconButtonStyle}>- <FontAwesomeIcon icon={isVisible ? faEyeSlash : faEye} />+ {isVisible ? <EyeOff className="size-4" /> : <Eye className="size-4" />}</IconButton></div></div><SecretShareInfo secret={secret} brandingTheme={brandingTheme} />{!brandingTheme && (<Button- className="mt-4 w-full bg-mineshaft-700 py-3 text-bunker-200"- colorSchema="primary"- variant="outline_bg"- size="sm"+ className="mt-4 w-full"+ variant="project"+ size="lg"onClick={() => window.open("/share-secret", "_blank", "noopener")}- rightIcon={<FontAwesomeIcon icon={faArrowRight} className="pl-2" />}>Share Your Own Secret+ <ForwardIcon /></Button>)}</div>diff --git a/frontend/src/pages/public/ViewSharedSecretByIDPage/components/SecretErrorContainer.tsx b/frontend/src/pages/public/ViewSharedSecretByIDPage/components/SecretErrorContainer.tsxindex cffcf129a4..3413a446a8 100644--- a/frontend/src/pages/public/ViewSharedSecretByIDPage/components/SecretErrorContainer.tsx+++ b/frontend/src/pages/public/ViewSharedSecretByIDPage/components/SecretErrorContainer.tsx@@ -21,7 +21,7 @@ export const SecretErrorContainer = ({ error, brandingTheme }: Props) => {<divclassName={twMerge("rounded-lg border p-6",- !brandingTheme && "border-mineshaft-600 bg-mineshaft-800"+ !brandingTheme && "border-border bg-card")}style={panelStyle}>diff --git a/frontend/src/pages/public/ViewSharedSecretByIDPage/components/SecretShareInfo.tsx b/frontend/src/pages/public/ViewSharedSecretByIDPage/components/SecretShareInfo.tsxindex e447b01476..c8f53a2c71 100644--- a/frontend/src/pages/public/ViewSharedSecretByIDPage/components/SecretShareInfo.tsx+++ b/frontend/src/pages/public/ViewSharedSecretByIDPage/components/SecretShareInfo.tsx@@ -1,6 +1,5 @@-import { faClock, faEye } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";import { format } from "date-fns";+import { Clock, Eye } from "lucide-react";import { TAccessSharedSecretResponse } from "@app/hooks/api/secretSharing";@@ -16,7 +15,7 @@ export const SecretShareInfo = ({ secret, brandingTheme }: Props) => {if (secret.expiresAt) {try {- timeRemaining = format(new Date(secret.expiresAt), "yyyy-MM-dd 'at' HH:mm a");+ timeRemaining = format(new Date(secret.expiresAt), "MMM d, yyyy 'at' h:mm a");} catch {timeRemaining = null;}@@ -45,27 +44,19 @@ export const SecretShareInfo = ({ secret, brandingTheme }: Props) => {return (<divclassName={`mt-4 flex flex-col gap-2 rounded-md border p-3 text-sm ${- brandingTheme ? "" : "border-mineshaft-600 bg-mineshaft-700/50 text-gray-300"+ brandingTheme ? "" : "border-border bg-container text-label"}`}style={infoStyle}>{timeRemaining && (<div className="flex items-center gap-2">- <FontAwesomeIcon- icon={faClock}- className={brandingTheme ? "" : "text-mineshaft-400"}- style={iconStyle}- />+ <Clock className="size-3.5 shrink-0" style={iconStyle} /><span>Expires on {timeRemaining}</span></div>)}{viewsRemaining !== null && (<div className="flex items-center gap-2">- <FontAwesomeIcon- icon={faEye}- className={brandingTheme ? "" : "text-mineshaft-400"}- style={iconStyle}- />+ <Eye className="size-3.5 shrink-0" style={iconStyle} /><span>{viewsRemaining === 0? "This is the last time you can view this secret"