Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

improvement(secret-sharing): masked share value, name prefill, and constraint count (#8633)

Andrew Huang13f5e7fe562a
diff --git a/frontend/src/components/v3/platform/SecretInput/SecretInput.tsx b/frontend/src/components/v3/platform/SecretInput/SecretInput.tsx
index 0d65d06425..dd44d00f74 100644
--- a/frontend/src/components/v3/platform/SecretInput/SecretInput.tsx
+++ b/frontend/src/components/v3/platform/SecretInput/SecretInput.tsx
@@ -156,6 +156,8 @@ type Props = TextareaHTMLAttributes<HTMLTextAreaElement> & {
isReadOnly?: boolean;
isDisabled?: boolean;
containerClassName?: string;
+ // Grows from a textarea-height box with the value top-aligned, for standalone form fields.
+ isMultiline?: boolean;
canEditButNotView?: boolean;
isLoadingValue?: boolean;
isErrorLoadingValue?: boolean;
@@ -176,6 +178,7 @@ export const SecretInput = forwardRef<HTMLTextAreaElement, Props>(
valueAlwaysHidden,
maskEachCharacter,
containerClassName,
+ isMultiline,
onBlur,
isDisabled,
isReadOnly,
@@ -243,6 +246,7 @@ export const SecretInput = forwardRef<HTMLTextAreaElement, Props>(
variant === "default" &&
"flex min-h-9 items-center rounded-md border border-border shadow-xs transition-[color,box-shadow] focus-within:border-ring focus-within:ring-[3px] focus-within:ring-ring/50 data-[invalid=true]:border-danger data-[invalid=true]:ring-danger/40",
variant === "plain" && invisibleChars.length > 0 && "flex",
+ variant === "default" && isMultiline && "min-h-16 items-start py-1",
containerClassName
)}
style={{ maxHeight: `${21 * 7}px` }}
diff --git a/frontend/src/pages/public/ShareSecretPage/components/ShareSecretForm.tsx b/frontend/src/pages/public/ShareSecretPage/components/ShareSecretForm.tsx
index 8870212829..cf5f7a9447 100644
--- a/frontend/src/pages/public/ShareSecretPage/components/ShareSecretForm.tsx
+++ b/frontend/src/pages/public/ShareSecretPage/components/ShareSecretForm.tsx
@@ -11,8 +11,7 @@ import {
ForwardIcon,
Info,
Lock,
- MailCheck,
- SlidersHorizontal
+ MailCheck
} from "lucide-react";
import { z } from "zod";
@@ -37,12 +36,12 @@ import {
InputGroupAddon,
InputGroupButton,
InputGroupInput,
+ SecretInput,
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
- TextArea,
Toggle,
Tooltip,
TooltipContent,
@@ -75,7 +74,7 @@ const parseRecipients = (emails?: string) =>
: [];
const baseSchema = z.object({
- name: z.string().optional(),
+ name: z.string().max(50, "Name must be 50 characters or fewer.").optional(),
password: z.string().optional(),
secret: z.string().min(1, "Enter the value you want to share."),
expiresIn: z.string(),
@@ -221,6 +220,14 @@ export const ShareSecretForm = ({
const resolvedExpiry = formatExpiry(selectedExpiresIn);
+ const isValueLocked = value !== undefined;
+ const constraintCount = [
+ isLimitingView,
+ Boolean(watch("password")),
+ !isPublic && isOrgAccess,
+ !isPublic && !isAllowingExternalEmails && parseRecipients(watch("emails")).length > 0
+ ].filter(Boolean).length;
+
const onFormSubmit = async ({
name,
password,
@@ -373,13 +380,20 @@ export const ShareSecretForm = ({
render={({ field, fieldState: { error } }) => (
<Field>
<FieldLabel htmlFor="share-secret-value">Secret Value</FieldLabel>
- <TextArea
+ <SecretInput
placeholder="Enter sensitive data to share via an encrypted link"
{...field}
id="share-secret-value"
- disabled={value !== undefined}
- aria-invalid={Boolean(error)}
+ isMultiline
+ isReadOnly={isValueLocked}
+ isError={Boolean(error)}
/>
+ {isValueLocked && (
+ <FieldDescription>
+ Locked to the stored value, so the link shares exactly what is saved in
+ Infisical.
+ </FieldDescription>
+ )}
{error && <FieldError>{error.message}</FieldError>}
</Field>
)}
@@ -433,11 +447,12 @@ export const ShareSecretForm = ({
<AccordionItem value="options">
<AccordionTrigger>
<span className="flex flex-1 items-center justify-between gap-3">
- <span className="inline-flex items-center gap-2">
- <SlidersHorizontal className="size-4 text-accent" />
- More Options
+ More Options
+ <span className="text-xs font-normal text-muted">
+ {constraintCount === 0
+ ? "No constraints"
+ : `${constraintCount} constraint${constraintCount === 1 ? "" : "s"}`}
</span>
- <span className="text-xs font-normal text-muted">Password, views, delivery</span>
</span>
</AccordionTrigger>
<AccordionContent className="flex flex-col gap-6 p-5">