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
improvement: update share secret form and public share secret ui to v3 components
Scott Wilson3fd2dd3bef4f
diff --git a/frontend/src/pages/public/ShareSecretPage/ShareSecretPage.tsx b/frontend/src/pages/public/ShareSecretPage/ShareSecretPage.tsxindex 9a427a0530..d46be99c0f 100644--- a/frontend/src/pages/public/ShareSecretPage/ShareSecretPage.tsx+++ b/frontend/src/pages/public/ShareSecretPage/ShareSecretPage.tsx@@ -1,12 +1,21 @@import { Helmet } from "react-helmet";-import { faArrowRight } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";++import { AuthPageBackground } from "@app/components/auth/AuthPageBackground";+import { AuthPageFooter } from "@app/components/auth/AuthPageFooter";+import { AuthPageHeader } from "@app/components/auth/AuthPageHeader";+import {+ UnstableCard,+ UnstableCardContent,+ UnstableCardHeader,+ UnstableCardTitle+} from "@app/components/v3";import { ShareSecretForm } from "./components";export const ShareSecretPage = () => {return (- <>+ <div className="relative flex max-h-screen min-h-screen flex-col overflow-y-auto bg-linear-to-tr from-card via-bunker-900 to-card px-4">+ <AuthPageBackground /><Helmet><title>Securely Share Secrets | Infisical</title><link rel="icon" href="/infisical.ico" />@@ -14,88 +23,18 @@ export const ShareSecretPage = () => {<meta property="og:title" content="" /><meta name="og:description" content="" /></Helmet>- <div className="dark h-full">- <div className="flex h-screen flex-col justify-between overflow-auto bg-linear-to-tr from-mineshaft-700 to-bunker-800 text-gray-200 dark:scheme-dark">- <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">- <a target="_blank" rel="noopener noreferrer" href="https://infisical.com">- <img- src="/images/gradientLogo.svg"- height={90}- width={120}- alt="Infisical logo"- className="cursor-pointer"- />- </a>- </div>- <h1 className="bg-linear-to-b from-white to-bunker-200 bg-clip-text text-center text-4xl font-medium text-transparent">- Share a secret- </h1>- <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>- <div className="rounded-lg border border-mineshaft-600 bg-mineshaft-800 p-4">- <ShareSecretForm isPublic />- </div>- <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>+ <AuthPageHeader />++ <UnstableCard className="z-50 m-auto w-full max-w-xl">+ <UnstableCardHeader>+ <UnstableCardTitle>Share a Secret</UnstableCardTitle>+ </UnstableCardHeader>+ <UnstableCardContent>+ <ShareSecretForm isPublic />+ </UnstableCardContent>+ </UnstableCard>- <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>- </div>- </div>- </>+ <AuthPageFooter />+ </div>);};diff --git a/frontend/src/pages/public/ShareSecretPage/components/ShareSecretForm.tsx b/frontend/src/pages/public/ShareSecretPage/components/ShareSecretForm.tsxindex 9377ae48a9..d8c4fc7a68 100644--- a/frontend/src/pages/public/ShareSecretPage/components/ShareSecretForm.tsx+++ b/frontend/src/pages/public/ShareSecretPage/components/ShareSecretForm.tsx@@ -1,26 +1,34 @@import { useState } from "react";import { Controller, useForm } from "react-hook-form";-import { faCheck, faCopy, faInfoCircle, faLock, faRedo } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";import { zodResolver } from "@hookform/resolvers/zod";import { useSearch } from "@tanstack/react-router";+import { Check, ClipboardCheck, Copy, ForwardIcon, Info, Lock, RefreshCw } from "lucide-react";import { z } from "zod";import { createNotification } from "@app/components/notifications";import {- Accordion,- AccordionContent,- AccordionItem,- AccordionTrigger,Button,- FormControl,- IconButton,- Input,+ Field,+ FieldDescription,+ FieldError,+ FieldLabel,Select,+ SelectContent,SelectItem,+ SelectTrigger,+ SelectValue,Switch,- Tooltip-} from "@app/components/v2";+ TextArea,+ Tooltip,+ TooltipContent,+ TooltipTrigger,+ UnstableAccordion,+ UnstableAccordionContent,+ UnstableAccordionItem,+ UnstableAccordionTrigger,+ UnstableIconButton,+ UnstableInput+} from "@app/components/v3";import { useTimedReset } from "@app/hooks";import { useCreatePublicSharedSecret, useCreateSharedSecret } from "@app/hooks/api";import { SecretSharingAccessType } from "@app/hooks/api/secretSharing";@@ -186,27 +194,27 @@ export const ShareSecretForm = ({if (secretLink === null)return (- <form onSubmit={handleSubmit(onFormSubmit)}>+ <form onSubmit={handleSubmit(onFormSubmit)} className="flex flex-col gap-4">{!isPublic && (<Controllercontrol={control}name="name"render={({ field, fieldState: { error } }) => (- <FormControl- label="Name"- isOptional- isError={Boolean(error)}- errorText={error?.message}- >- <Input+ <Field>+ <FieldLabel>+ Name <span className="text-xs text-muted italic">- Optional</span>+ </FieldLabel>+ <UnstableInput{...field}placeholder="API Key"type="text"autoComplete="off"autoCorrect="off"- spellCheck="false"+ spellCheck={false}+ isError={Boolean(error)}/>- </FormControl>+ {error && <FieldError>{error.message}</FieldError>}+ </Field>)}/>)}@@ -214,43 +222,40 @@ export const ShareSecretForm = ({control={control}name="secret"render={({ field, fieldState: { error } }) => (- <FormControl- label="Your Secret"- isError={Boolean(error)}- errorText={error?.message}- className="mb-2"- isRequired- >- <textarea+ <Field>+ <FieldLabel>Your Secret</FieldLabel>+ <TextAreaplaceholder="Enter sensitive data to share via an encrypted link..."{...field}- className="h-40 min-h-[70px] w-full rounded-md border border-mineshaft-600 bg-mineshaft-900 px-2 py-1.5 text-bunker-300 outline-hidden transition-all group-hover:mr-2 placeholder:text-mineshaft-400 hover:border-primary-400/30 focus:border-primary-400/50"+ className="h-40 min-h-[70px] resize-none"disabled={value !== undefined}+ aria-invalid={Boolean(error)}/>- </FormControl>+ {error && <FieldError>{error.message}</FieldError>}+ </Field>)}/><Controllercontrol={control}name="password"render={({ field, fieldState: { error } }) => (- <FormControl- label="Password"- isError={Boolean(error)}- errorText={error?.message}- isOptional- >- <Input+ <Field>+ <FieldLabel>+ Password <span className="text-xs text-muted italic">- Optional</span>+ </FieldLabel>+ <UnstableInput{...field}placeholder="Password"type="password"autoComplete="new-password"autoCorrect="off"- spellCheck="false"+ spellCheck={false}aria-autocomplete="none"data-form-type="other"+ isError={Boolean(error)}/>- </FormControl>+ {error && <FieldError>{error.message}</FieldError>}+ </Field>)}/>@@ -260,81 +265,73 @@ export const ShareSecretForm = ({name="accessType"defaultValue={SecretSharingAccessType.Organization}render={({ field: { onChange, ...field }, fieldState: { error } }) => (- <FormControl errorText={error?.message} isError={Boolean(error)}>+ <Field orientation="horizontal"><Switch- className={`mr-2 ml-0 bg-mineshaft-400/50 shadow-inner data-[state=checked]:bg-primary ${!allowSecretSharingOutsideOrganization ? "opacity-50" : ""}`}- thumbClassName="bg-mineshaft-800"- containerClassName="flex-row-reverse w-fit"- isChecked={+ checked={field.value === SecretSharingAccessType.Organization ||!allowSecretSharingOutsideOrganization}- isDisabled={!allowSecretSharingOutsideOrganization}+ disabled={!allowSecretSharingOutsideOrganization}onCheckedChange={(v) =>onChange(v ? SecretSharingAccessType.Organization : SecretSharingAccessType.Anyone)}- id="org-access-only"- >+ />+ <FieldLabel className="flex-auto"><span className="flex items-center">Limit access to people within organization{!allowSecretSharingOutsideOrganization && (- <Tooltip content="Enforced by your organization">- <FontAwesomeIcon- icon={faLock}- className="ml-2 !align-[-0.2em] text-mineshaft-400"- />+ <Tooltip>+ <TooltipTrigger asChild>+ <Lock className="ml-2 size-3 text-muted" />+ </TooltipTrigger>+ <TooltipContent>Enforced by your organization</TooltipContent></Tooltip>)}</span>- </Switch>- </FormControl>+ </FieldLabel>+ {error && <FieldError>{error.message}</FieldError>}+ </Field>)}/>)}- <Accordion type="single" collapsible className="w-full">- <AccordionItem value="advance-settings" className="data-[state=open]:border-none">- <AccordionTrigger className="h-fit flex-none pl-1 text-sm">- <div className="order-1 ml-3">Advanced Settings</div>- </AccordionTrigger>- <AccordionContent childrenClassName="p-0">+ <UnstableAccordion type="single" collapsible>+ <UnstableAccordionItem value="advance-settings">+ <UnstableAccordionTrigger>Advanced Settings</UnstableAccordionTrigger>+ <UnstableAccordionContent><Controllercontrol={control}name="expiresIn"render={({ field: { onChange, ...field }, fieldState: { error } }) => (- <FormControl- label="Expires In"- errorText={error?.message}- isError={Boolean(error)}- helperText={- expiresInOptions.length !== filteredExpiresInOptions.length ? (- <span className="text-yellow-500">- Limited to{" "}- {filteredExpiresInOptions[filteredExpiresInOptions.length - 1].label} by- organization- </span>- ) : undefined- }- >- <Select- defaultValue={field.value}- {...field}- onValueChange={(e) => onChange(e)}- className="w-full"- >- {expiresInOptions.map(({ label, value: expiresInValue }) => (- <SelectItem- value={String(expiresInValue || "")}- key={label}- isDisabled={!filteredExpiresInOptions.some((v) => v.label === label)}- >- {label}- </SelectItem>- ))}+ <Field>+ <FieldLabel>Expires In</FieldLabel>+ <Select value={field.value} onValueChange={(e) => onChange(e)}>+ <SelectTrigger className="w-full">+ <SelectValue />+ </SelectTrigger>+ <SelectContent>+ {expiresInOptions.map(({ label, value: expiresInValue }) => (+ <SelectItem+ value={String(expiresInValue || "")}+ key={label}+ disabled={!filteredExpiresInOptions.some((v) => v.label === label)}+ >+ {label}+ </SelectItem>+ ))}+ </SelectContent></Select>- </FormControl>+ {expiresInOptions.length !== filteredExpiresInOptions.length && (+ <FieldDescription className="text-yellow-500">+ Limited to{" "}+ {filteredExpiresInOptions[filteredExpiresInOptions.length - 1].label} by+ organization+ </FieldDescription>+ )}+ {error && <FieldError>{error.message}</FieldError>}+ </Field>)}/><div className="flex w-full items-end gap-2">@@ -343,31 +340,28 @@ export const ShareSecretForm = ({control={control}name="shouldLimitView"render={({ field: { onChange, ...field }, fieldState: { error } }) => (- <FormControl- label="Max Views"- errorText={error?.message}- isError={Boolean(error)}- className="flex-1"- >+ <Field className="flex-1">+ <FieldLabel>Max Views</FieldLabel><Select- defaultValue={field.value.toString()}- onValueChange={(e) => onChange(e === "true")}- className="w-full"- position="popper"- {...field}value={field.value.toString()}- dropdownContainerClassName="max-w-none"+ onValueChange={(e) => onChange(e === "true")}>- {viewLimitOptions.map(({ label, value: viewLimitValue }) => (- <SelectItem- value={viewLimitValue.toString()}- key={viewLimitValue.toString()}- >- {label}- </SelectItem>- ))}+ <SelectTrigger className="w-full">+ <SelectValue />+ </SelectTrigger>+ <SelectContent position="popper">+ {viewLimitOptions.map(({ label, value: viewLimitValue }) => (+ <SelectItem+ value={viewLimitValue.toString()}+ key={viewLimitValue.toString()}+ >+ {label}+ </SelectItem>+ ))}+ </SelectContent></Select>- </FormControl>+ {error && <FieldError>{error.message}</FieldError>}+ </Field>)}/>)}@@ -376,29 +370,24 @@ export const ShareSecretForm = ({control={control}name="viewLimit"render={({ field: { onChange, ...field }, fieldState: { error } }) => (- <FormControl- label={maxSharedSecretViewLimit ? "Max Views" : undefined}- errorText={error?.message}- isError={Boolean(error)}- className="flex-1"- helperText={- maxSharedSecretViewLimit ? (- <span className="text-yellow-500">- Limited to {maxSharedSecretViewLimit} view- {maxSharedSecretViewLimit === 1 ? "" : "s"} by organization- </span>- ) : undefined- }- >- <Input+ <Field className="flex-1">+ {maxSharedSecretViewLimit && <FieldLabel>Max Views</FieldLabel>}+ <UnstableInputonChange={onChange}{...field}min={1}max={maxSharedSecretViewLimit ?? 1000}type="number"- className="h-[37px]"+ isError={Boolean(error)}/>- </FormControl>+ {maxSharedSecretViewLimit && (+ <FieldDescription className="text-yellow-500">+ Limited to {maxSharedSecretViewLimit} view+ {maxSharedSecretViewLimit === 1 ? "" : "s"} by organization+ </FieldDescription>+ )}+ {error && <FieldError>{error.message}</FieldError>}+ </Field>)}/>)}@@ -409,37 +398,39 @@ export const ShareSecretForm = ({control={control}name="emails"render={({ field, fieldState: { error } }) => (- <FormControl- label="Emails"- isOptional- helperText={- isAllowingExternalEmails- ? "All recipients will receive a link and need the password to access the secret. They don't need an Infisical account, but a password is mandatory in this case."- : "Recipients must have an Infisical account to verify identity"- }- tooltipText={- <>- <p>- Unique secret links will be emailed to each individual. The secret- will only be accessible to those links.- </p>- <p className="mt-2">- {isAllowingExternalEmails- ? "External recipients (user without an Infisical account) will need the password to view the secret. Authorized recipients will also need a password if the secret is password-protected."- : "Recipients must have an Infisical account to verify their identity."}- </p>- </>- }- tooltipClassName="max-w-sm"- isError={Boolean(error)}- errorText={error?.message}- >- <Input+ <Field>+ <FieldLabel>+ Emails <span className="text-xs text-muted italic">- Optional</span>+ <Tooltip>+ <TooltipTrigger asChild>+ <Info className="size-3 cursor-help text-muted" />+ </TooltipTrigger>+ <TooltipContent className="max-w-sm">+ <p>+ Unique secret links will be emailed to each individual. The secret+ will only be accessible to those links.+ </p>+ <p className="mt-2">+ {isAllowingExternalEmails+ ? "External recipients (user without an Infisical account) will need the password to view the secret. Authorized recipients will also need a password if the secret is password-protected."+ : "Recipients must have an Infisical account to verify their identity."}+ </p>+ </TooltipContent>+ </Tooltip>+ </FieldLabel>+ <UnstableInput{...field}placeholder="[email protected], [email protected]"autoComplete="off"+ isError={Boolean(error)}/>- </FormControl>+ <FieldDescription>+ {isAllowingExternalEmails+ ? "All recipients will receive a link and need the password to access the secret. They don't need an Infisical account, but a password is mandatory in this case."+ : "Recipients must have an Infisical account to verify identity"}+ </FieldDescription>+ {error && <FieldError>{error.message}</FieldError>}+ </Field>)}/><Controller@@ -449,57 +440,54 @@ export const ShareSecretForm = ({field: { onChange, value: isChecked, ...field },fieldState: { error }}) => (- <FormControl errorText={error?.message} isError={Boolean(error)}>- <div className="flex items-center">- <Switch- className={`mr-2 ml-0 bg-mineshaft-400/50 shadow-inner data-[state=checked]:bg-primary ${isOrgAccess ? "opacity-50" : ""}`}- thumbClassName="bg-mineshaft-800"- containerClassName={`flex-row-reverse w-fit ${isOrgAccess ? "pointer-events-none opacity-50" : ""}`}- isChecked={isOrgAccess ? false : (isChecked ?? false)}- onCheckedChange={onChange}- isDisabled={isOrgAccess}- id="allow-external-emails"- {...field}- >- <span className="flex items-center">- Allow external recipients- <Tooltip content="When enabled, the defined emails will receive the secret link via email but will need the password to access the secret.">- <FontAwesomeIcon- icon={faInfoCircle}- className="ml-2 !align-[-0.2em] text-mineshaft-400"- />- </Tooltip>- </span>- </Switch>- {!allowSecretSharingOutsideOrganization && (- <span className="inline-flex items-center">- <Tooltip- content="External sharing is disabled by your organization"- className="items-center"- >- <FontAwesomeIcon- icon={faLock}- className="ml-2 !align-[-0.2em] text-mineshaft-400"- />+ <Field orientation="horizontal">+ <Switch+ checked={isOrgAccess ? false : (isChecked ?? false)}+ onCheckedChange={onChange}+ disabled={isOrgAccess}+ id="allow-external-emails"+ {...field}+ />+ <FieldLabel className="flex-auto">+ <span className="flex items-center">+ Allow external recipients+ <Tooltip>+ <TooltipTrigger asChild>+ <Info className="ml-2 size-3 cursor-help text-muted" />+ </TooltipTrigger>+ <TooltipContent>+ When enabled, the defined emails will receive the secret link via+ email but will need the password to access the secret.+ </TooltipContent>+ </Tooltip>+ {!allowSecretSharingOutsideOrganization && (+ <Tooltip>+ <TooltipTrigger asChild>+ <Lock className="ml-2 size-3 text-muted" />+ </TooltipTrigger>+ <TooltipContent>+ External sharing is disabled by your organization+ </TooltipContent></Tooltip>- </span>- )}- </div>- </FormControl>+ )}+ </span>+ </FieldLabel>+ {error && <FieldError>{error.message}</FieldError>}+ </Field>)}/></>)}- </AccordionContent>- </AccordionItem>- </Accordion>+ </UnstableAccordionContent>+ </UnstableAccordionItem>+ </UnstableAccordion><div className="flex w-full justify-end"><Button- className="mt-4"- size="sm"+ size="md"+ variant="project"type="submit"- isLoading={isSubmitting}+ isPending={isSubmitting}isDisabled={isSubmitting}>Create Secret Link@@ -508,51 +496,49 @@ export const ShareSecretForm = ({</form>);- if (secretLink === "")+ if (secretLink === "" || true)return (<>- <div className="mt-1 flex w-full items-center justify-center gap-2">- <FontAwesomeIcon icon={faCheck} className="text-green-500" />+ <div className="relative flex items-center justify-center rounded-lg border border-border bg-container p-4 pr-6 text-foreground/85">+ <Check className="mr-2 size-4 text-success" /><span>Shared secret link has been emailed to select users.</span></div><Button- className="mt-6 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={() => setSecretLink(null)}- rightIcon={<FontAwesomeIcon icon={faRedo} className="pl-2" />}>Share Another Secret+ <ForwardIcon /></Button></>);return (<>- <div className="mr-2 flex items-center justify-end rounded-md bg-white/5 p-2 text-base text-gray-400">+ <div className="relative flex items-center justify-center rounded-lg border border-border bg-container p-4 pr-6 text-foreground/85"><p className="mr-4 break-all">{secretLink}</p>- <IconButton- ariaLabel="copy icon"- colorSchema="secondary"- className="group relative ml-2"+ <UnstableIconButton+ aria-label="copy icon"+ variant="ghost"+ className="absolute top-1 right-1"onClick={() => {navigator.clipboard.writeText(secretLink || "");setCopyTextSecret("Copied");}}>- <FontAwesomeIcon icon={isCopyingSecret ? faCheck : faCopy} />- </IconButton>+ {isCopyingSecret ? <ClipboardCheck className="size-4" /> : <Copy className="size-4" />}+ </UnstableIconButton></div><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={() => setSecretLink(null)}- rightIcon={<FontAwesomeIcon icon={faRedo} className="pl-2" />}>Share Another Secret+ <ForwardIcon /></Button></>);