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
Refine platform workflow implementation
Andrew Huang78e5aaf74b41
diff --git a/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx b/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsxindex e9202bf355..e3908e317c 100644--- a/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx+++ b/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx@@ -48,13 +48,7 @@ import { ReconcileLocalAccountRotationModal } from "@app/components/secret-rotatimport { RotateSecretRotationV2Modal } from "@app/components/secret-rotations-v2/RotateSecretRotationV2Modal";import { ViewSecretRotationV2GeneratedCredentialsModal } from "@app/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials";import { CommitHistorySheet } from "@app/components/secrets/CommitHistorySheet";-import {- Button as ButtonV2,- DeleteActionModal,- Modal,- ModalContent,- PageHeader-} from "@app/components/v2";+import { DeleteActionModal, Modal, ModalContent, PageHeader } from "@app/components/v2";import {Alert,AlertDialog,@@ -207,6 +201,10 @@ import { CreateSecretImportForm } from "../SecretDashboardPage/components/Actionimport { DopplerSecretImportModal } from "../SecretDashboardPage/components/ActionBar/DopplerSecretImportModal";import { FolderForm } from "../SecretDashboardPage/components/ActionBar/FolderForm";import { ReplicateFolderFromBoard } from "../SecretDashboardPage/components/ActionBar/ReplicateFolderFromBoard/ReplicateFolderFromBoard";+import {+ getDestinationSecretPath,+ getSecretLocation+} from "../SecretDashboardPage/components/ActionBar/ReplicateFolderFromBoard/replicateSecrets";import { VaultSecretImportModal } from "../SecretDashboardPage/components/ActionBar/VaultSecretImportModal";import { CommitForm } from "../SecretDashboardPage/components/CommitForm";import { CreateDynamicSecretLease } from "../SecretDashboardPage/components/DynamicSecretListView/CreateDynamicSecretLease";@@ -894,6 +892,7 @@ const OverviewPageContent = () => {string,{ value: string; comments: string[] }> | null>(null);+ const [isReplicateCopying, setIsReplicateCopying] = useState(false);const { handlePopUpOpen, handlePopUpToggle, handlePopUpClose, popUp } = usePopUp(["addSecretsInAllEnvs",@@ -1096,15 +1095,15 @@ const OverviewPageContent = () => {}};- // Replicate Secrets Logicconst replicateCreateCount = ((popUp.confirmReplicateUpload?.data as TSecOverwriteOpt)?.create || []).length;- const replicateUpdateCount = (- (popUp.confirmReplicateUpload?.data as TSecOverwriteOpt)?.update || []- ).length;+ const replicateConflictingSecrets =+ (popUp.confirmReplicateUpload?.data as TSecOverwriteOpt)?.update || [];+ const replicateUpdateCount = replicateConflictingSecrets.length;const isReplicateNonConflicting = !replicateUpdateCount;- const isReplicateSubmitting = isCreatingSecrets || isUpdatingSecrets;+ const isReplicateSubmitting = isReplicateCopying || isCreatingSecrets || isUpdatingSecrets;+ const replicateDestinationEnvironment = singleVisibleEnv?.name ?? singleVisibleEnv?.slug ?? "";const handleParsedEnvMultiFolder = async (envByPath: TParsedFolderEnv) => {if (Object.keys(envByPath).length === 0) {@@ -1121,17 +1120,7 @@ const OverviewPageContent = () => {await Promise.all(Object.entries(envByPath).map(async ([folderPath, boardSecrets]) => {- let normalizedPath = folderPath;-- if (normalizedPath === "/") {- normalizedPath = secretPath;- } else {- const baseSecretPath = secretPath.endsWith("/") ? secretPath.slice(0, -1) : secretPath;- const cleanFolderPath = folderPath.startsWith("/")- ? folderPath.substring(1)- : folderPath;- normalizedPath = `${baseSecretPath}/${cleanFolderPath}`;- }+ const normalizedPath = getDestinationSecretPath(secretPath, folderPath);const secretFolderKeys = Object.keys(boardSecrets);@@ -1328,12 +1317,22 @@ const OverviewPageContent = () => {});handlePopUpClose("confirmReplicateUpload");+ handlePopUpClose("replicateFolder");createNotification({type: "success",- text: "Successfully replicated secrets"+ text: "Secrets copied"});};+ const handleConfirmReplicateImport = async () => {+ setIsReplicateCopying(true);+ try {+ await handleSaveReplicateImport();+ } finally {+ setIsReplicateCopying(false);+ }+ };+const handleFolderUpdate = async (newFolderName: string, description: string | null) => {if (isBatchModeActive && singleVisibleEnv) {const { name: oldFolderName } = popUp.updateFolder.data as TSecretFolder;@@ -3837,58 +3836,61 @@ const OverviewPageContent = () => {projectId={projectId}secretPath={secretPath}/>- <Modal- isOpen={popUp?.confirmReplicateUpload?.isOpen}- onOpenChange={(open) => handlePopUpToggle("confirmReplicateUpload", open)}+ <AlertDialog+ open={popUp?.confirmReplicateUpload?.isOpen}+ onOpenChange={(open) => {+ if (!isReplicateSubmitting) handlePopUpToggle("confirmReplicateUpload", open);+ }}>- <ModalContent- title="Confirm Secret Upload"- footerContent={[- <ButtonV2- isLoading={isReplicateSubmitting}- isDisabled={isReplicateSubmitting}- colorSchema={isReplicateNonConflicting ? "primary" : "danger"}- key="overwrite-btn"- onClick={handleSaveReplicateImport}+ <AlertDialogContent>+ <AlertDialogHeader>+ <AlertDialogMedia>+ <CopyIcon />+ </AlertDialogMedia>+ <AlertDialogTitle>+ {isReplicateNonConflicting ? "Copy Secrets" : "Overwrite Existing Secrets"}+ </AlertDialogTitle>+ <AlertDialogDescription>+ {isReplicateNonConflicting+ ? `Copy ${replicateCreateCount} ${replicateCreateCount === 1 ? "secret" : "secrets"} to ${replicateDestinationEnvironment} at ${secretPath}.`+ : `${replicateUpdateCount} ${replicateUpdateCount === 1 ? "secret already exists" : "secrets already exist"} in ${replicateDestinationEnvironment}. Copying will replace the values at the destination paths below${replicateCreateCount > 0 ? ` and create ${replicateCreateCount} new ${replicateCreateCount === 1 ? "secret" : "secrets"}` : ""}.`}+ </AlertDialogDescription>+ </AlertDialogHeader>+ {!isReplicateNonConflicting && (+ <ul+ aria-label="Secrets that will be overwritten"+ className="max-h-48 space-y-1 overflow-y-auto rounded-md border border-danger/20 bg-danger/5 p-3">- {isReplicateNonConflicting ? "Upload" : "Overwrite"}- </ButtonV2>,- <ButtonV2- key="keep-old-btn"- className="ml-4"- onClick={() => handlePopUpClose("confirmReplicateUpload")}- variant="outline_bg"+ {replicateConflictingSecrets.map((secret) => {+ const location = getSecretLocation(+ secret.secretPath ?? secretPath,+ secret.secretKey+ );++ return (+ <li key={location} className="truncate font-mono text-xs text-foreground">+ {location}+ </li>+ );+ })}+ </ul>+ )}+ <AlertDialogFooter>+ <AlertDialogCancel isDisabled={isReplicateSubmitting}>Cancel</AlertDialogCancel>+ <AlertDialogAction+ variant={isReplicateNonConflicting ? "project" : "danger"}+ isPending={isReplicateSubmitting}isDisabled={isReplicateSubmitting}+ onClick={(event) => {+ event.preventDefault();+ handleConfirmReplicateImport().catch(() => undefined);+ }}>- Cancel- </ButtonV2>- ]}- >- {isReplicateNonConflicting ? (- <div>- Are you sure you want to import {replicateCreateCount} secret- {replicateCreateCount > 1 ? "s" : ""} to this environment?- </div>- ) : (- <div className="flex flex-col text-gray-300">- <div>Your project already contains the following {replicateUpdateCount} secrets:</div>- <div className="mt-2 text-sm text-gray-400">- {(popUp?.confirmReplicateUpload?.data as TSecOverwriteOpt)?.update- ?.map((sec) => sec.secretKey)- .join(", ")}- </div>- <div className="mt-6">- Are you sure you want to overwrite these secrets- {replicateCreateCount > 0- ? ` and import ${replicateCreateCount} new- one${replicateCreateCount > 1 ? "s" : ""}`- : ""}- ?- </div>- </div>- )}- </ModalContent>- </Modal>+ {isReplicateNonConflicting ? "Copy secrets" : "Copy and overwrite"}+ </AlertDialogAction>+ </AlertDialogFooter>+ </AlertDialogContent>+ </AlertDialog><VaultSecretImportModalisOpen={popUp.importFromVault.isOpen}onOpenChange={(isOpen) => handlePopUpToggle("importFromVault", isOpen)}diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/AddResourceButtons/AddResourceButtons.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/AddResourceButtons/AddResourceButtons.tsxindex 5437a7a1dc..c8f025d4bf 100644--- a/frontend/src/pages/secret-manager/OverviewPage/components/AddResourceButtons/AddResourceButtons.tsx+++ b/frontend/src/pages/secret-manager/OverviewPage/components/AddResourceButtons/AddResourceButtons.tsx@@ -230,13 +230,13 @@ export function AddResourceButtons({isDisabled={!isReplicateSecretsAvailable || !isAllowed}><ClipboardPasteIcon className="text-accent" />- Replicate Secrets+ Copy secrets</DropdownMenuItem></TooltipTrigger><TooltipContent side="left">{!isReplicateSecretsAvailable- ? "Select a single environment to replicate secrets"- : "Access Denied"}+ ? "Select a single environment to copy secrets"+ : "Access denied"}</TooltipContent></Tooltip>)}diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/ReplicateFolderFromBoard/ReplicateFolderFromBoard.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/ReplicateFolderFromBoard/ReplicateFolderFromBoard.tsxindex f43163ac7b..20049ed384 100644--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/ReplicateFolderFromBoard/ReplicateFolderFromBoard.tsx+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/ReplicateFolderFromBoard/ReplicateFolderFromBoard.tsx@@ -1,37 +1,43 @@import { useEffect, useMemo, useState } from "react";import { Controller, useForm } from "react-hook-form";-import { faClone } from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";import { zodResolver } from "@hookform/resolvers/zod";+import { ArrowRightIcon, CopyIcon } from "lucide-react";import { z } from "zod";import {Button,- FilterableSelect,- FormControl,- Modal,- ModalContent,+ Combobox,+ DocumentationLinkBadge,+ Field,+ FieldContent,+ FieldDescription,+ FieldError,+ FieldLabel,+ FieldLegend,+ FieldSet,+ SecretPathInput,+ Sheet,+ SheetContent,+ SheetDescription,+ SheetFooter,+ SheetHeader,+ SheetTitle,Switch-} from "@app/components/v2";-import { SecretPathInput } from "@app/components/v2/SecretPathInput";-import { DocumentationLinkBadge } from "@app/components/v3";+} from "@app/components/v3";import { ProjectPermissionSecretActions } from "@app/context/ProjectPermissionContext/types";import { useDebounce } from "@app/hooks";import { useGetAccessibleSecrets } from "@app/hooks/api/dashboard";import { SecretV3Raw } from "@app/hooks/api/types";+import { getRelativeSecretPath, normalizeSecretPath } from "./replicateSecrets";import { SecretTreeView } from "./SecretTreeView";const formSchema = z.object({environment: z.object({ name: z.string(), slug: z.string() }),- secretPath: z- .string()- .trim()- .transform((val) =>- typeof val === "string" && val.at(-1) === "/" && val.length > 1 ? val.slice(0, -1) : val- ),+ secretPath: z.string().trim(),secrets: z.object({+ id: z.string(),secretKey: z.string(),secretValue: z.string().optional(),secretPath: z.string()@@ -47,7 +53,7 @@ type Props = {onToggle: (isOpen: boolean) => void;onParsedEnv: (env: Record<string, Record<string, { value: string; comments: string[]; secretPath?: string }>>- ) => void;+ ) => Promise<void> | void;environments?: { name: string; slug: string }[];projectId: string;environment: string;@@ -55,7 +61,7 @@ type Props = {};type SecretFolder = {- items: Partial<SecretV3Raw>[];+ items: SecretV3Raw[];subFolders: Record<string, SecretFolder>;};@@ -68,261 +74,303 @@ export const ReplicateFolderFromBoard = ({projectId,isOpen,onToggle,- onParsedEnv+ onParsedEnv,+ environment,+ secretPath}: Props) => {const [shouldIncludeValues, setShouldIncludeValues] = useState(true);- const { handleSubmit, control, watch, reset, setValue } = useForm<TFormSchema>({+ const {+ handleSubmit,+ control,+ watch,+ reset,+ setValue,+ formState: { errors, isSubmitting }+ } = useForm<TFormSchema>({resolver: zodResolver(formSchema),- defaultValues: { secretPath: "/", environment: environments?.[0], secrets: [] }+ defaultValues: { secretPath: "/", environment: environments[0], secrets: [] }});const envCopySecPath = watch("secretPath");- const selectedEnvSlug = watch("environment");+ const selectedEnvironment = watch("environment");const selectedSecrets = watch("secrets");const [debouncedEnvCopySecretPath] = useDebounce(envCopySecPath);- const { data: accessibleSecrets } = useGetAccessibleSecrets({+ const {+ data: accessibleSecrets,+ isPending: isSourceLoading,+ isFetching: isSourceFetching,+ isError: isSourceError,+ refetch: retrySourceFetch+ } = useGetAccessibleSecrets({projectId,secretPath: "/",- environment: selectedEnvSlug?.slug,+ environment: selectedEnvironment?.slug,recursive: true,filterByAction: shouldIncludeValues? ProjectPermissionSecretActions.ReadValue: ProjectPermissionSecretActions.DescribeSecret,- options: { enabled: Boolean(projectId) && Boolean(selectedEnvSlug) && isOpen }+ options: { enabled: Boolean(projectId) && Boolean(selectedEnvironment) && isOpen }});const restructureSecrets = useMemo(() => {if (!accessibleSecrets) return {};- const result: SecretStructure = {};- result["/"] = {- items: [],- subFolders: {}+ const result: SecretStructure = {+ "/": {+ items: [],+ subFolders: {}+ }};accessibleSecrets.forEach((secret) => {- const path = secret.secretPath || "/";+ const path = normalizeSecretPath(secret.secretPath || "/");if (path === "/") {- result["/"]?.items.push(secret);+ result["/"].items.push(secret);return;}- const normalizedPath = path.startsWith("/") ? path.substring(1) : path;- const pathParts = normalizedPath.split("/");-+ const pathParts = path.substring(1).split("/");let currentFolder = result["/"];- for (let i = 0; i < pathParts.length; i += 1) {- const part = pathParts[i];-- // eslint-disable-next-line no-continue- if (!part) continue;-- if (i === pathParts.length - 1) {- if (!currentFolder.subFolders[part]) {- currentFolder.subFolders[part] = {- items: [],- subFolders: {}- };- }- currentFolder.subFolders[part].items.push(secret);- } else {- if (!currentFolder.subFolders[part]) {- currentFolder.subFolders[part] = {- items: [],- subFolders: {}- };- }- currentFolder = currentFolder.subFolders[part];+ pathParts.forEach((part) => {+ if (!currentFolder.subFolders[part]) {+ currentFolder.subFolders[part] = {+ items: [],+ subFolders: {}+ };}- }+ currentFolder = currentFolder.subFolders[part];+ });++ currentFolder.items.push(secret);});return result;- }, [accessibleSecrets, selectedEnvSlug]);+ }, [accessibleSecrets]);const secretsFilteredByPath = useMemo(() => {- let normalizedPath = debouncedEnvCopySecretPath;- normalizedPath = debouncedEnvCopySecretPath.startsWith("/")- ? debouncedEnvCopySecretPath- : `/${debouncedEnvCopySecretPath}`;- if (normalizedPath.length > 1 && normalizedPath.endsWith("/")) {- normalizedPath = debouncedEnvCopySecretPath.slice(0, -1);- }-- if (normalizedPath === "/") {- return restructureSecrets["/"];- }-- const segments = normalizedPath.split("/").filter((segment) => segment !== "");-- let currentLevel = restructureSecrets["/"];- let result = null;- let currentPath = "";-- if (!currentLevel) {- setValue("secretPath", "/");- return null;- }-- for (let i = 0; i < segments.length; i += 1) {- const segment = segments[i];- currentPath += `/${segment}`;-- if (currentLevel?.subFolders?.[segment]) {- currentLevel = currentLevel.subFolders[segment];+ const normalizedPath = normalizeSecretPath(debouncedEnvCopySecretPath);+ const currentLevel = restructureSecrets["/"];++ if (!currentLevel) return null;+ if (normalizedPath === "/") return currentLevel;++ return normalizedPath+ .split("/")+ .filter(Boolean)+ .reduce<SecretFolder | null>(+ (folder, segment) => folder?.subFolders[segment] ?? null,+ currentLevel+ );+ }, [restructureSecrets, debouncedEnvCopySecretPath]);- if (currentPath === normalizedPath) {- result = currentLevel;- break;- }- } else {- return null;- }+ useEffect(() => {+ if (isOpen && !selectedEnvironment && environments[0]) {+ setValue("environment", environments[0]);}-- return result;- }, [restructureSecrets, debouncedEnvCopySecretPath]);+ }, [environments, isOpen, selectedEnvironment, setValue]);useEffect(() => {setValue("secrets", []);- }, [debouncedEnvCopySecretPath, selectedEnvSlug]);+ }, [debouncedEnvCopySecretPath, selectedEnvironment, setValue]);++ useEffect(() => {+ if (!isOpen) {+ reset({ secretPath: "/", environment: environments[0], secrets: [] });+ setShouldIncludeValues(true);+ }+ }, [environments, isOpen, reset]);const handleFormSubmit = async (data: TFormSchema) => {+ const sourceRootPath = normalizeSecretPath(data.secretPath);const secretsToBePulled: Record<string,Record<string, { value: string; comments: string[]; secretPath: string }>> = {};+data.secrets.forEach(({ secretKey, secretValue, secretPath: secretPathToRecreate }) => {- const normalizedPath = secretPathToRecreate.startsWith(envCopySecPath)- ? secretPathToRecreate.slice(envCopySecPath.length)- : secretPathToRecreate;+ const relativePath = getRelativeSecretPath(secretPathToRecreate, sourceRootPath);- if (!secretsToBePulled[normalizedPath]) {- secretsToBePulled[normalizedPath] = {};+ if (!secretsToBePulled[relativePath]) {+ secretsToBePulled[relativePath] = {};}- secretsToBePulled[normalizedPath][secretKey] = {+ secretsToBePulled[relativePath][secretKey] = {value: (shouldIncludeValues && secretValue) || "",comments: [""],- secretPath: normalizedPath+ secretPath: relativePath};});- onParsedEnv(secretsToBePulled);- onToggle(false);- reset();++ await onParsedEnv(secretsToBePulled);+ };++ const normalizedSourcePath = normalizeSecretPath(envCopySecPath);+ const normalizedDestinationPath = normalizeSecretPath(secretPath);+ const destinationEnvironment = environments.find(({ slug }) => slug === environment);+ const isInvalidSourcePath =+ !isSourceLoading && !isSourceError && Boolean(accessibleSecrets) && !secretsFilteredByPath;+ const isCopyDisabled =+ selectedSecrets.length === 0 ||+ isSourceLoading ||+ isSourceError ||+ isInvalidSourcePath ||+ isSourceFetching;++ const handleOpenChange = (open: boolean) => {+ if (isSubmitting) return;+ onToggle(open);};return (- <Modal- isOpen={isOpen}- onOpenChange={(state) => {- onToggle(state);- reset();- }}- >- <ModalContent- bodyClassName="overflow-visible"- className="max-w-2xl"- title={- <div className="flex items-center gap-x-2 text-mineshaft-300">- <span>Replicate Secrets</span>- <DocumentationLinkBadge href="https://infisical.com/docs/documentation/platform/folder#replicating-folder-contents" />- </div>- }- subTitle="Copy folder contents from other locations into this context"- >- <form onSubmit={handleSubmit(handleFormSubmit)}>- <div className="flex items-center space-x-2">+ <Sheet open={isOpen} onOpenChange={handleOpenChange}>+ <SheetContent className="sm:max-w-2xl">+ <form className="flex min-h-0 flex-1 flex-col" onSubmit={handleSubmit(handleFormSubmit)}>+ <SheetHeader>+ <SheetTitle className="flex items-center gap-2">+ <span>Copy Secrets</span>+ <DocumentationLinkBadge href="https://infisical.com/docs/documentation/platform/folder#replicating-folder-contents" />+ </SheetTitle>+ <SheetDescription>+ Copy selected secrets and folders from another project location into this one.+ </SheetDescription>+ </SheetHeader>++ <div className="flex min-h-0 flex-1 flex-col gap-5 overflow-y-auto p-4">+ <div+ aria-label="Copy source and destination"+ className="grid items-center gap-3 rounded-md border border-border bg-container p-3 sm:grid-cols-[1fr_auto_1fr]"+ >+ <div className="min-w-0">+ <p className="text-xs font-medium text-accent">Source</p>+ <p className="truncate text-sm text-foreground">+ {selectedEnvironment?.name ?? "Select an environment"}+ </p>+ <p className="truncate font-mono text-xs text-muted">{normalizedSourcePath}</p>+ </div>+ <ArrowRightIcon className="size-4 rotate-90 text-muted sm:rotate-0" aria-hidden />+ <div className="min-w-0">+ <p className="text-xs font-medium text-accent">Destination</p>+ <p className="truncate text-sm text-foreground">+ {destinationEnvironment?.name ?? environment}+ </p>+ <p className="truncate font-mono text-xs text-muted">{normalizedDestinationPath}</p>+ </div>+ </div>++ <div className="grid gap-4 sm:grid-cols-2">+ <Controller+ control={control}+ name="environment"+ render={({ field: { value, onChange } }) => (+ <Field>+ <FieldLabel htmlFor="copy-secrets-source-environment">+ Source environment+ </FieldLabel>+ <Combobox+ id="copy-secrets-source-environment"+ modal+ value={value}+ onValueChange={onChange}+ options={environments}+ placeholder="Select environment..."+ searchPlaceholder="Search environments..."+ searchAriaLabel="Search source environments"+ getOptionLabel={(option) => option.name}+ getOptionValue={(option) => option.slug}+ isDisabled={isSubmitting}+ />+ <FieldDescription>Choose the environment to copy from.</FieldDescription>+ </Field>+ )}+ />+ <Controller+ control={control}+ name="secretPath"+ render={({ field }) => (+ <Field>+ <FieldLabel htmlFor="copy-secrets-source-path">Source root path</FieldLabel>+ <SecretPathInput+ {...field}+ id="copy-secrets-source-path"+ projectId={projectId}+ placeholder="/"+ environment={selectedEnvironment?.slug}+ disabled={isSubmitting}+ />+ <FieldDescription>+ Descendant paths are recreated beneath the destination path.+ </FieldDescription>+ </Field>+ )}+ />+ </div>+<Controllercontrol={control}- name="environment"+ name="secrets"render={({ field: { value, onChange } }) => (- <FormControl- tooltipText="The environment to replicate secrets from"- label="Source Environment"- isRequired- className="w-1/3"- >- <FilterableSelect- value={value}+ <FieldSet>+ <FieldLegend>Affected secrets</FieldLegend>+ <FieldDescription>Select the secrets and folders to copy.</FieldDescription>+ <SecretTreeView+ data={secretsFilteredByPath}+ selectedItems={value}+ basePath={normalizeSecretPath(debouncedEnvCopySecretPath)}onChange={onChange}- options={environments}- placeholder="Select environment..."- getOptionLabel={(option) => option.name}- getOptionValue={(option) => option.slug}- />- </FormControl>- )}- />- <Controller- control={control}- name="secretPath"- render={({ field }) => (- <FormControl- tooltipText="The folder to use as a root for replication. Using /foo as a root for /foo/bar will result in /bar being copied to this context."- label="Source Root Path"- className="grow"- isRequired- >- <SecretPathInput- {...field}- placeholder="Provide a path, default is /"- environment={selectedEnvSlug?.slug}+ isDisabled={isSubmitting}+ isLoading={isSourceLoading}+ isFetching={isSourceFetching}+ isError={isSourceError}+ isInvalidPath={isInvalidSourcePath}+ onRetry={() => retrySourceFetch()}/>- </FormControl>+ <FieldError>{errors.secrets?.message}</FieldError>+ </FieldSet>)}/>++ <Field orientation="horizontal">+ <FieldContent>+ <FieldLabel size="sm" htmlFor="copy-secrets-include-values">+ Include secret values+ </FieldLabel>+ <FieldDescription>+ Turn this off to copy secret keys without their current values.+ </FieldDescription>+ </FieldContent>+ <Switch+ id="copy-secrets-include-values"+ variant="project"+ checked={shouldIncludeValues}+ disabled={isSubmitting}+ onCheckedChange={(isChecked) => {+ setValue("secrets", []);+ setShouldIncludeValues(isChecked);+ }}+ />+ </Field></div>- <Controller- control={control}- name="secrets"- render={({ field: { onChange } }) => (- <FormControl- tooltipText="The folders and secrets to replicate into this context"- className="grow"- label="Affected Subjects"- isRequired- >- <SecretTreeView- data={secretsFilteredByPath}- basePath={debouncedEnvCopySecretPath}- onChange={onChange}- />- </FormControl>- )}- />- <div className="my-6 ml-2">- <Switch- id="populate-include-value"- isChecked={shouldIncludeValues}- onCheckedChange={(isChecked) => {- setValue("secrets", []);- setShouldIncludeValues(isChecked as boolean);- }}- >- Include secret values- </Switch>- </div>- <div className="flex items-center space-x-4">++ <SheetFooter className="border-t">+ <Button variant="ghost" isDisabled={isSubmitting} onClick={() => onToggle(false)}>+ Cancel+ </Button><Button- leftIcon={<FontAwesomeIcon icon={faClone} />}type="submit"- variant="outline_bg"- colorSchema="secondary"- isDisabled={!selectedSecrets || selectedSecrets.length === 0}+ variant="project"+ isPending={isSubmitting}+ isDisabled={isCopyDisabled}>- Replicate Secrets+ <CopyIcon />+ Check and copy</Button>- <Button variant="plain" colorSchema="secondary" onClick={() => onToggle(false)}>- Cancel- </Button>- </div>+ </SheetFooter></form>- </ModalContent>- </Modal>+ </SheetContent>+ </Sheet>);};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/ReplicateFolderFromBoard/SecretTreeView.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/ReplicateFolderFromBoard/SecretTreeView.tsxindex 9f3e7d3909..4a6a92d53e 100644--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/ReplicateFolderFromBoard/SecretTreeView.tsx+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/ReplicateFolderFromBoard/SecretTreeView.tsx@@ -1,34 +1,36 @@-import React, { useEffect, useMemo, useState } from "react";-import {- faChevronDown,- faChevronRight,- faFolder,- faFolderOpen,- faFolderTree,- faKey-} from "@fortawesome/free-solid-svg-icons";-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";+import { useId, useMemo, useState } from "react";import * as CollapsiblePrimitive from "@radix-ui/react-collapsible";+import {+ ChevronDownIcon,+ ChevronRightIcon,+ FolderIcon,+ FolderOpenIcon,+ FolderTreeIcon,+ KeyRoundIcon+} from "lucide-react";-import { Checkbox } from "@app/components/v2";+import {+ Button,+ Checkbox,+ Empty,+ EmptyContent,+ EmptyDescription,+ EmptyHeader,+ EmptyTitle,+ Skeleton+} from "@app/components/v3";+import { cn } from "@app/components/v3/utils";interface SecretItem {- id?: string;- secretKey?: string;+ id: string;+ secretKey: string;secretValue?: string;- secretPath?: string;- [key: string]: any;+ secretPath: string;}interface FolderStructure {items: SecretItem[];- subFolders: {- [key: string]: FolderStructure;- };-}--interface TreeData {- [key: string]: FolderStructure | null;+ subFolders: Record<string, FolderStructure>;}interface FolderProps {@@ -40,41 +42,36 @@ interface FolderProps {onFolderSelect: (folderPath: string, isChecked: boolean) => void;isExpanded?: boolean;level: number;- basePath?: string;+ basePath: string;isDisabled?: boolean;}interface TreeViewProps {data: FolderStructure | null;+ selectedItems: SecretItem[];basePath?: string;className?: string;onChange: (items: SecretItem[]) => void;+ onRetry: () => void;isDisabled?: boolean;+ isLoading?: boolean;+ isFetching?: boolean;+ isError?: boolean;+ isInvalidPath?: boolean;}-const getAllItemsInFolder = (folder: FolderStructure): SecretItem[] => {- let items: SecretItem[] = [];-- items = items.concat(folder.items);-- // eslint-disable-next-line @typescript-eslint/no-unused-vars- Object.entries(folder.subFolders).forEach(([_, subFolder]) => {- items = items.concat(getAllItemsInFolder(subFolder));- });+const getAllItemsInFolder = (folder: FolderStructure): SecretItem[] => [+ ...folder.items,+ ...Object.values(folder.subFolders).flatMap(getAllItemsInFolder)+];- return items;-};--const getDisplayName = (name: string): string => {- const parts = name.split("/");- return parts[parts.length - 1];-};+const getDisplayName = (name: string) => name.split("/").filter(Boolean).at(-1) ?? "/";const Collapsible = CollapsiblePrimitive.Root;const CollapsibleTrigger = CollapsiblePrimitive.Trigger;const CollapsibleContent = CollapsiblePrimitive.Content;-const Folder: React.FC<FolderProps> = ({+const Folder = ({name,structure,path,@@ -85,103 +82,104 @@ const Folder: React.FC<FolderProps> = ({level,basePath,isDisabled = false-}) => {+}: FolderProps) => {const [open, setOpen] = useState(isExpanded);- const displayName = useMemo(() => getDisplayName(name), [name]);-+ const checkboxId = useId();+ const secretCheckboxIdPrefix = useId();+ const folderLabel = level === 0 ? basePath : getDisplayName(name);const allItems = useMemo(() => getAllItemsInFolder(structure), [structure]);const allItemIds = useMemo(() => allItems.map((item) => item.id), [allItems]);const selectedItemIds = useMemo(() => selectedItems.map((item) => item.id), [selectedItems]);- const allSelected = useMemo(- () => allItemIds.length > 0 && allItemIds.every((id) => selectedItemIds.includes(id)),- [allItemIds, selectedItemIds]- );- const someSelected = useMemo(- () => allItemIds.some((id) => selectedItemIds.includes(id)) && !allSelected,- [allItemIds, selectedItemIds, allSelected]- );+ const allSelected =+ allItemIds.length > 0 && allItemIds.every((id) => selectedItemIds.includes(id));+ const someSelected = !allSelected && allItemIds.some((id) => selectedItemIds.includes(id));const hasContents = structure.items.length > 0 || Object.keys(structure.subFolders).length > 0;-- const handleFolderSelect = (checked: boolean) => {- onFolderSelect(path, checked);- };+ let FolderGlyph = FolderIcon;+ if (level === 0) FolderGlyph = FolderTreeIcon;+ else if (open) FolderGlyph = FolderOpenIcon;return (- <div className={`folder-container ml-${level > 0 ? "4" : 0}`}>+ <li className={cn(level > 0 && "ml-4")}><Collapsible open={open} onOpenChange={setOpen}>- <div className="group flex items-center rounded-sm px-2 py-1">+ <div className="group flex min-h-8 items-center rounded-sm px-2 py-1 hover:bg-container-hover"><CollapsibleTrigger asChild><buttontype="button"- className="mr-1 flex h-6 w-6 items-center justify-center rounded-sm focus:outline-hidden"+ className="mr-1 flex size-7 items-center justify-center rounded-sm text-muted outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-default disabled:opacity-50"disabled={!hasContents}- aria-label={open ? "Collapse folder" : "Expand folder"}+ aria-label={`${open ? "Collapse" : "Expand"} ${folderLabel}`}>- {hasContents && (- <FontAwesomeIcon icon={open ? faChevronDown : faChevronRight} className="h-3 w-3" />- )}+ {hasContents &&+ (open ? (+ <ChevronDownIcon className="size-3.5" />+ ) : (+ <ChevronRightIcon className="size-3.5" />+ ))}</button></CollapsibleTrigger>- <div className="mr-2">- <FontAwesomeIcon- // eslint-disable-next-line no-nested-ternary- icon={level > 0 ? (open ? faFolderOpen : faFolder) : faFolderTree}- className={`h-4 w-4 text-${level === 0 ? "mineshaft-300" : "yellow"}`}- />- </div>- {!isDisabled && (- <Checkbox- id="folder-root"- isChecked={allSelected || someSelected}- onCheckedChange={handleFolderSelect}- isIndeterminate={someSelected && !allSelected}- isDisabled={isDisabled}- />- )}+ <FolderGlyph className="mr-2 size-4 text-folder" aria-hidden />+ <Checkbox+ id={checkboxId}+ variant="project"+ isChecked={allSelected || someSelected}+ onCheckedChange={(checked) => onFolderSelect(path, checked === true)}+ isIndeterminate={someSelected}+ isDisabled={isDisabled || allItemIds.length === 0}+ /><label- htmlFor={`folder-${path}`}- className={`ml-2 flex-1 cursor-pointer truncate ${basePath ? "text-mineshaft-300 italic" : ""}`}- title={displayName}+ htmlFor={checkboxId}+ className={cn(+ "ml-2 min-w-0 flex-1 truncate text-sm text-foreground",+ isDisabled || allItemIds.length === 0 ? "cursor-not-allowed" : "cursor-pointer",+ level === 0 && "font-mono text-xs"+ )}+ title={folderLabel}>- {displayName || `${basePath}`}+ {folderLabel}</label>{allItemIds.length > 0 && (- <span className="ml-2 text-xs text-mineshaft-400">+ <span className="ml-2 text-xs text-muted">{allItemIds.length} {allItemIds.length === 1 ? "item" : "items"}</span>)}</div>- <CollapsibleContent className="overflow-hidden transition-all duration-300 ease-in-out">- <div className="relative mt-1">- <div className="absolute top-0 bottom-0 left-5 w-px bg-mineshaft-600" />+ <CollapsibleContent>+ <ul className="relative ml-5 border-l border-border pl-1">{[...structure.items]- .sort((a, b) => (a.secretKey ?? "").localeCompare(b.secretKey ?? ""))- .map((item) => (- <div key={item.id} className="group ml-6 flex items-center rounded-sm px-2 py-1">- <div className="mr-2 ml-6">- <FontAwesomeIcon icon={faKey} className="h-3 w-3" />- </div>- {!isDisabled && (+ .sort((a, b) => a.secretKey.localeCompare(b.secretKey))+ .map((item) => {+ const checkboxItemId = `${secretCheckboxIdPrefix}-${item.id}`;++ return (+ <li+ key={item.id}+ className="group ml-4 flex min-h-8 items-center rounded-sm px-2 py-1 hover:bg-container-hover"+ >+ <KeyRoundIcon className="mr-2 ml-7 size-3.5 text-secret" aria-hidden /><Checkbox- id={`folder-${item.id}`}+ id={checkboxItemId}+ variant="project"isChecked={selectedItemIds.includes(item.id)}- onCheckedChange={(checked) => onItemSelect(item, !!checked)}+ onCheckedChange={(checked) => onItemSelect(item, checked === true)}isDisabled={isDisabled}/>- )}- <label- htmlFor={item.id}- className="ml-2 flex-1 cursor-pointer truncate"- title={item.secretKey}- >- {item.secretKey}- </label>- </div>- ))}+ <label+ htmlFor={checkboxItemId}+ className={cn(+ "ml-2 min-w-0 flex-1 truncate font-mono text-xs text-foreground",+ isDisabled ? "cursor-not-allowed" : "cursor-pointer"+ )}+ title={item.secretKey}+ >+ {item.secretKey}+ </label>+ </li>+ );+ })}{Object.entries(structure.subFolders).sort(([a], [b]) => a.localeCompare(b))@@ -190,148 +188,164 @@ const Folder: React.FC<FolderProps> = ({key={subName}name={subName}structure={subStructure}- path={path ? `${path}/${subName}` : subName}+ path={`${path === "/" ? "" : path}/${subName}`}selectedItems={selectedItems}onItemSelect={onItemSelect}onFolderSelect={onFolderSelect}level={level + 1}+ basePath={basePath}isDisabled={isDisabled}/>))}- </div>+ </ul></CollapsibleContent></Collapsible>- </div>+ </li>);};-export const SecretTreeView: React.FC<TreeViewProps> = ({+export const SecretTreeView = ({data,+ selectedItems,basePath = "/",- className = "",+ className,onChange,- isDisabled = false-}) => {- const [selectedItems, setSelectedItems] = useState<SecretItem[]>([]);- const rootPath = "/";- const treeData: TreeData = data ? { [rootPath]: data as FolderStructure } : { [rootPath]: null };-- const rootFolders = useMemo(() => {- return Object.entries(treeData);- }, [treeData]);-- const isEmptyData = useMemo(() => {- return (- !data || (typeof data === "object" && Object.keys(data).length === 0) || !rootFolders.length- );- }, [data, rootFolders]);+ onRetry,+ isDisabled = false,+ isLoading = false,+ isFetching = false,+ isError = false,+ isInvalidPath = false+}: TreeViewProps) => {+ const isEmptyData =+ Boolean(data) && data?.items.length === 0 && Object.keys(data.subFolders).length === 0;const handleItemSelect = (item: SecretItem, isChecked: boolean) => {if (isChecked) {- setSelectedItems((prev) => [...prev, item]);- } else {- setSelectedItems((prev) => prev.filter((i) => i.id !== item.id));+ if (!selectedItems.some(({ id }) => id === item.id)) onChange([...selectedItems, item]);+ return;}++ onChange(selectedItems.filter(({ id }) => id !== item.id));};const handleFolderSelect = (folderPath: string, isChecked: boolean) => {- const getFolderFromPath = (tree: TreeData, path: string): FolderStructure | null => {- if (rootFolders.length === 1 && rootFolders[0][0] === path) {- return rootFolders[0][1];- }-- let adjustedPath = path;- if (!path.startsWith(rootPath)) {- adjustedPath = rootPath === path ? rootPath : `${rootPath}/${path}`;- }-- if (adjustedPath === "/") return tree["/"];+ if (!data) return;++ const folder =+ folderPath === "/"+ ? data+ : folderPath+ .split("/")+ .filter(Boolean)+ .reduce<FolderStructure | null>(+ (currentFolder, segment) => currentFolder?.subFolders[segment] ?? null,+ data+ );- const parts = adjustedPath.split("/").filter((p) => p !== "");+ if (!folder) return;- let current: any;- current = tree["/"];+ const folderItems = getAllItemsInFolder(folder);+ const folderItemIds = new Set(folderItems.map((item) => item.id));- const targetExists = parts.every((part) => {- if (current?.subFolders?.[part]) {- current = current.subFolders[part];- return true;- }- return false;- });+ if (isChecked) {+ const selectedItemIds = new Set(selectedItems.map((item) => item.id));+ onChange([...selectedItems, ...folderItems.filter((item) => !selectedItemIds.has(item.id))]);+ return;+ }- if (!targetExists) {- return null;- }+ onChange(selectedItems.filter((item) => !folderItemIds.has(item.id)));+ };- return current;- };+ const renderContent = () => {+ if (isLoading) {+ return (+ <div className="flex flex-col gap-3 p-4" aria-label="Loading accessible secrets">+ {Array.from({ length: 5 }, (_, index) => (+ <Skeleton key={`copy-secret-tree-skeleton-${index + 1}`} className="h-8 w-full" />+ ))}+ </div>+ );+ }- const folder = getFolderFromPath(treeData, folderPath);- if (!folder) return;+ if (isError) {+ return (+ <Empty role="alert" className="min-h-64 border">+ <EmptyHeader>+ <EmptyTitle>Could Not Load Secrets</EmptyTitle>+ <EmptyDescription>+ The source secrets could not be loaded. Check your access and try again.+ </EmptyDescription>+ </EmptyHeader>+ <EmptyContent>+ <Button size="sm" variant="outline" onClick={onRetry}>+ Retry+ </Button>+ </EmptyContent>+ </Empty>+ );+ }- const folderItems = getAllItemsInFolder(folder);- const folderItemIds = folderItems.map((item) => item.id);+ if (isInvalidPath) {+ return (+ <Empty className="min-h-64 border">+ <EmptyHeader>+ <EmptyTitle>Source Path Unavailable</EmptyTitle>+ <EmptyDescription>+ This path does not exist or you do not have access to its secrets. Choose another+ source path.+ </EmptyDescription>+ </EmptyHeader>+ </Empty>+ );+ }- if (isChecked) {- setSelectedItems((prev) => {- const prevIds = prev.map((item) => item.id);- const newItems = [...prev];- folderItems.forEach((item) => {- if (!prevIds.includes(item.id)) {- newItems.push(item);- }- });- return newItems;- });- } else {- setSelectedItems((prev) => prev.filter((item) => !folderItemIds.includes(item.id)));+ if (isEmptyData) {+ return (+ <Empty className="min-h-64 border">+ <EmptyHeader>+ <EmptyTitle>No Accessible Secrets</EmptyTitle>+ <EmptyDescription>+ No secrets are available at this source path. Choose another path or environment.+ </EmptyDescription>+ </EmptyHeader>+ </Empty>+ );}- };- useEffect(() => {- setSelectedItems([]);- }, [data]);+ if (!data) return null;- useEffect(() => {- onChange(selectedItems);- }, [selectedItems]);+ return (+ <ul aria-label={`Secrets under ${basePath}`}>+ <Folder+ basePath={basePath}+ name={basePath}+ structure={data}+ path="/"+ selectedItems={selectedItems}+ onItemSelect={handleItemSelect}+ onFolderSelect={handleFolderSelect}+ isExpanded+ level={0}+ isDisabled={isDisabled}+ />+ </ul>+ );+ };return (- <div className="flex w-full items-start gap-3 rounded-lg border border-mineshaft-600 bg-mineshaft-900">- <div className={`w-full rounded-lg shadow-xs ${className}`}>- <div className="h-[25vh] overflow-auto p-3">- {isEmptyData ? (- <div className="flex h-full w-full items-center justify-center text-center text-mineshaft-300">- <p>No secrets or folders available</p>- </div>- ) : (- rootFolders.map(([folderName, folderStructure]) => (- <Folder- basePath={basePath}- key={folderName}- name={folderName}- structure={folderStructure || { items: [], subFolders: {} }}- path={folderName}- selectedItems={selectedItems}- onItemSelect={handleItemSelect}- onFolderSelect={handleFolderSelect}- isExpanded- level={0}- isDisabled={isDisabled}- />- ))- )}+ <div+ className={cn("w-full rounded-md border border-border bg-container", className)}+ aria-busy={isFetching || undefined}+ >+ <div className="h-[32vh] min-h-64 overflow-auto p-3">{renderContent()}</div>+ {!isLoading && !isError && !isInvalidPath && !isEmptyData && data && (+ <div className="flex justify-end border-t border-border px-3 py-2">+ <p className="text-xs text-muted" aria-live="polite">+ {selectedItems.length} {selectedItems.length === 1 ? "item" : "items"} selected+ </p></div>-- {!isDisabled && (- <div className="flex justify-end pt-2 pr-2 pb-2">- <h3 className="flex items-center text-mineshaft-400">- {selectedItems.length} Item{selectedItems.length === 1 ? "" : "s"} Selected- </h3>- </div>- )}- </div>+ )}</div>);};diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/ReplicateFolderFromBoard/replicateSecrets.test.ts b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/ReplicateFolderFromBoard/replicateSecrets.test.tsnew file mode 100644index 0000000000..7fbc7f5a35--- /dev/null+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/ReplicateFolderFromBoard/replicateSecrets.test.ts@@ -0,0 +1,34 @@+import assert from "node:assert/strict";+import { describe, it } from "node:test";++import {+ getDestinationSecretPath,+ getRelativeSecretPath,+ getSecretLocation,+ normalizeSecretPath+} from "./replicateSecrets";++describe("copy secrets path mapping", () => {+ it("normalizes root and trailing slashes", () => {+ assert.equal(normalizeSecretPath(""), "/");+ assert.equal(normalizeSecretPath("folder/"), "/folder");+ assert.equal(normalizeSecretPath("/folder///"), "/folder");+ });++ it("maps source paths relative to the selected source root", () => {+ assert.equal(getRelativeSecretPath("/source", "/source"), "/");+ assert.equal(getRelativeSecretPath("/source/nested", "/source"), "/nested");+ assert.equal(getRelativeSecretPath("/nested", "/"), "/nested");+ });++ it("maps relative paths onto the selected destination root", () => {+ assert.equal(getDestinationSecretPath("/destination", "/"), "/destination");+ assert.equal(getDestinationSecretPath("/destination", "/nested"), "/destination/nested");+ assert.equal(getDestinationSecretPath("/", "/nested"), "/nested");+ });++ it("qualifies a secret key with its full path", () => {+ assert.equal(getSecretLocation("/", "API_KEY"), "/API_KEY");+ assert.equal(getSecretLocation("/services/api", "API_KEY"), "/services/api/API_KEY");+ });+});diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/ReplicateFolderFromBoard/replicateSecrets.ts b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/ReplicateFolderFromBoard/replicateSecrets.tsnew file mode 100644index 0000000000..1b2dbf09ff--- /dev/null+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/ReplicateFolderFromBoard/replicateSecrets.ts@@ -0,0 +1,42 @@+export const normalizeSecretPath = (path: string) => {+ const trimmedPath = path.trim();++ if (!trimmedPath) return "/";++ const pathWithLeadingSlash = trimmedPath.startsWith("/") ? trimmedPath : `/${trimmedPath}`;+ const normalizedPath = pathWithLeadingSlash.replace(/\/+$/u, "");++ return normalizedPath || "/";+};++export const getRelativeSecretPath = (secretPath: string, sourceRootPath: string) => {+ const normalizedSecretPath = normalizeSecretPath(secretPath);+ const normalizedSourceRootPath = normalizeSecretPath(sourceRootPath);++ if (normalizedSecretPath === normalizedSourceRootPath) return "/";+ if (normalizedSourceRootPath === "/") return normalizedSecretPath;+ if (normalizedSecretPath.startsWith(`${normalizedSourceRootPath}/`)) {+ return normalizedSecretPath.slice(normalizedSourceRootPath.length);+ }++ return normalizedSecretPath;+};++export const getDestinationSecretPath = (destinationRootPath: string, relativePath: string) => {+ const normalizedDestinationRootPath = normalizeSecretPath(destinationRootPath);+ const normalizedRelativePath = normalizeSecretPath(relativePath);++ if (normalizedRelativePath === "/") return normalizedDestinationRootPath;++ const destinationPrefix =+ normalizedDestinationRootPath === "/" ? "" : normalizedDestinationRootPath;++ return normalizeSecretPath(`${destinationPrefix}/${normalizedRelativePath.slice(1)}`);+};++export const getSecretLocation = (secretPath: string, secretKey: string) => {+ const normalizedSecretPath = normalizeSecretPath(secretPath);+ const pathPrefix = normalizedSecretPath === "/" ? "" : normalizedSecretPath;++ return `${pathPrefix}/${secretKey}`;+};