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
fix: lint
adilson3f22ff0046fd
diff --git a/backend/src/services/user-activation/user-activation-service.ts b/backend/src/services/user-activation/user-activation-service.tsindex a191e2f658..1719c5f138 100644--- a/backend/src/services/user-activation/user-activation-service.ts+++ b/backend/src/services/user-activation/user-activation-service.ts@@ -5,8 +5,7 @@ import { getConfig } from "@app/lib/config/env";import { TOrgDALFactory } from "@app/services/org/org-dal";import { TUserActivationDALFactory } from "./user-activation-dal";-import { TGetSecretsActivationStatusDTO } from "./user-activation-types";-import { TActivationRecord, TSecretsActivationStatus } from "./user-activation-types";+import { TActivationRecord, TGetSecretsActivationStatusDTO, TSecretsActivationStatus } from "./user-activation-types";type TUserActivationServiceFactoryDep = {userActivationDAL: TUserActivationDALFactory;@@ -16,7 +15,6 @@ type TUserActivationServiceFactoryDep = {export type TUserActivationServiceFactory = ReturnType<typeof userActivationServiceFactory>;-export const userActivationServiceFactory = ({userActivationDAL,permissionService,@@ -50,26 +48,23 @@ export const userActivationServiceFactory = ({});if (!permission.can(OrgPermissionActions.Create, OrgPermissionSubjects.Member)) return noActivation;- // 2. The org must be young enough (SECRETS_ACTIVATION_ORG_MAX_AGE_MONTHS).+ // 2. The org must be young enough (SECRETS_ACTIVATION_ORG_MAX_AGE_MONTHS) or has less than 5 uconst org = await orgDAL.findById(actorOrgId);if (!org) return noActivation;- const orgAgeCutoff = new Date();- orgAgeCutoff.setMonth(orgAgeCutoff.getMonth() - appCfg.SECRETS_ACTIVATION_ORG_MAX_AGE_MONTHS);- if (org.createdAt.getTime() < orgAgeCutoff.getTime()) return noActivation;- // 3. The org must have fewer than SECRETS_ACTIVATION_ORG_MAX_MEMBERS users.const memberCount = await orgDAL.countAllOrgMembers(actorOrgId);- if (memberCount >= appCfg.SECRETS_ACTIVATION_ORG_MAX_MEMBERS) return noActivation;++ const orgAgeCutoff = new Date();+ orgAgeCutoff.setMonth(orgAgeCutoff.getMonth() - appCfg.SECRETS_ACTIVATION_ORG_MAX_AGE_MONTHS);+ if (org.createdAt.getTime() < orgAgeCutoff.getTime() || memberCount >= appCfg.SECRETS_ACTIVATION_ORG_MAX_MEMBERS)+ return noActivation;// Read-modify-write under a row lock so concurrent activation checks for the same// (userId, orgId) can't double-stamp a stage or lose an update. FOR UPDATE can't lock a row// that doesn't exist yet, so the first-interaction insert still goes through ON CONFLICT// (upsert) to stay safe against a concurrent first request.return userActivationDAL.transaction(async (tx): Promise<TSecretsActivationStatus> => {- const existingActivation = await userActivationDAL.findOneForUpdate(- { userId: actorId, orgId: actorOrgId },- tx- );+ const existingActivation = await userActivationDAL.findOneForUpdate({ userId: actorId, orgId: actorOrgId }, tx);const now = new Date();// First interaction: creating the row is itself the signal that this is the user's firstdiff --git a/backend/src/services/user-activation/user-activation-types.ts b/backend/src/services/user-activation/user-activation-types.tsindex 539f2bd9f0..6ca7c0c6fd 100644--- a/backend/src/services/user-activation/user-activation-types.ts+++ b/backend/src/services/user-activation/user-activation-types.ts@@ -7,7 +7,6 @@ export type TGetSecretsActivationStatusDTO = {actorAuthMethod: ActorAuthMethod;};-export type TActivationRecord = {firstSecretCreatedAt?: Date | null;returnedAfterThreeDaysAt?: Date | null;@@ -22,4 +21,4 @@ export type TSecretsActivationStatus = {returnedAfterThreeDaysAt: Date | null;returnedAfterSevenDaysAt: Date | null;} | null;-};\ No newline at end of file+};diff --git a/frontend/src/hooks/useSecretsActivationNudge.tsx b/frontend/src/hooks/useSecretsActivationNudge.tsxindex 522b9cb3d7..8d7226fcb2 100644--- a/frontend/src/hooks/useSecretsActivationNudge.tsx+++ b/frontend/src/hooks/useSecretsActivationNudge.tsx@@ -12,16 +12,15 @@ import { fetchSecretsActivationStatus, userActivationKeys } from "@app/hooks/apiimport { usePopUp } from "./usePopUp";-// Small delay before opening the modal so it doesn't pop the instant the page settles or a-// secret is created, which reads as abrupt. Tunable.+// Small delay before opening the modal so it doesn't pop the instant a secret is created, which+// reads as abrupt. Tunable.const ACTIVATION_NUDGE_DELAY_MS = 1000;-// Growth nudge for the secret overview page. `checkActivation` can be called from multiple-// triggers (the project having secrets, or a secret being created), but it runs the request at-// most once per session: the result is cached (gcTime Infinity) and we skip entirely-// once it is present, so the modal never re-opens on remount. The check is also gated on the user-// being able to invite members and being recent, opens the modal only if the backend says so, and-// is a no-op if the request fails.+// Growth nudge for the secret overview page. `checkActivation` is called when the user creates a+// secret, but it runs the request at most once per session: the result is cached (gcTime Infinity)+// and we skip entirely once it is present, so the modal never re-opens on remount. The check is+// also gated on the user being able to invite members and being recent, opens the modal only if+// the backend says so, and is a no-op if the request fails.export const useSecretsActivationNudge = () => {const { user } = useUser();const { currentOrg, isRootOrganization } = useOrganization();@@ -38,7 +37,6 @@ export const useSecretsActivationNudge = () => {[]);-const canInviteMembers = permission.can(OrgPermissionActions.Create,OrgPermissionSubjects.Memberdiff --git a/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx b/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsxindex 1907eafe0d..d1bba08a61 100644--- a/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx+++ b/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx@@ -94,7 +94,6 @@ import {TooltipTrigger} from "@app/components/v3";import { apiRequest } from "@app/config/request";-import { EXAMPLE_PROJECT_NAME } from "@app/const";import { ROUTE_PATHS } from "@app/const/routes";import {ProjectPermissionActions,@@ -694,26 +693,15 @@ const OverviewPageContent = () => {usedBySecretSyncs} = overview ?? {};- // Growth nudge: once the project has secrets (on load) or the user creates one, ask the backend- // whether to surface the "Invite your team" modal. The check runs at most once per session,- // opens the modal only if the backend says so, and is a no-op on failure.+ // Growth nudge: when the user creates a secret, ask the backend whether to surface the+ // "Invite your team" modal. The check runs at most once per session, opens the modal only if+ // the backend says so, and is a no-op on failure.const {popUp: invitePopUp,handlePopUpToggle: handleInvitePopUpToggle,checkActivation: checkSecretsActivation} = useSecretsActivationNudge();- const hasSecrets = !isPlaceholderData && Boolean(totalSecretCount);- useEffect(() => {- const projectName = currentProject?.name;-- const isExampleProject = projectName === EXAMPLE_PROJECT_NAME;-- if (hasSecrets && !isExampleProject) {- checkSecretsActivation();- }- }, [hasSecrets, checkSecretsActivation]);-const secretImportsShaped = secretImports?.flatMap(({ data }) => data).filter(Boolean)@@ -1679,6 +1667,9 @@ const OverviewPageContent = () => {type: "success",text: "Successfully created secret"});++ // The user just created a secret: check whether to surface the activation nudge.+ checkSecretsActivation();}};@@ -2131,8 +2122,24 @@ const OverviewPageContent = () => {: "Changes saved successfully",type: requiresApproval ? "info" : "success"});++ // If the commit actually created secrets (not just an approval request), check whether to+ // surface the activation nudge.+ const createdSecret = changes.secrets.some((s) => s.type === PendingAction.Create);+ if (createdSecret && !requiresApproval) {+ console.log("createdSecret", createdSecret);+ checkSecretsActivation();+ }},- [singleVisibleEnv, projectId, secretPath, isProtectedBranch, queryClient, createCommit]+ [+ singleVisibleEnv,+ projectId,+ secretPath,+ isProtectedBranch,+ queryClient,+ createCommit,+ checkSecretsActivation+ ]);// Batch mode: toggle@@ -3426,6 +3433,7 @@ const OverviewPageContent = () => {defaultSelectedEnvs={filteredEnvs}onClose={() => handlePopUpClose("addSecretsInAllEnvs")}isBatchMode={isBatchModeActive}+ onSecretCreated={checkSecretsActivation}onBatchSecretCreate={(params) => {addPendingChange({diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/CreateSecretForm/CreateSecretForm.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/CreateSecretForm/CreateSecretForm.tsxindex 770df92db8..943bf4cb1e 100644--- a/frontend/src/pages/secret-manager/OverviewPage/components/CreateSecretForm/CreateSecretForm.tsx+++ b/frontend/src/pages/secret-manager/OverviewPage/components/CreateSecretForm/CreateSecretForm.tsx@@ -86,6 +86,9 @@ type Props = {tags?: { id: string; slug: string }[];metadata?: { key: string; value: string; isEncrypted?: boolean }[];}) => void;+ // Called after the user actually creates a secret (non-batch path) so the parent can run the+ // activation nudge. The parent owns the nudge hook + modal state, so this stays a callback.+ onSecretCreated?: () => void;};export const CreateSecretForm = ({@@ -93,7 +96,8 @@ export const CreateSecretForm = ({defaultSelectedEnvs,onClose,isBatchMode,- onBatchSecretCreate+ onBatchSecretCreate,+ onSecretCreated}: Props) => {const { currentProject, projectId } = useProject();const { permission } = useProjectPermission();@@ -268,6 +272,9 @@ export const CreateSecretForm = ({updatedEnvs.length > 1 ? "environments" : "environment"}: ${updatedEnvs.join(", ")}`});++ // The user just created a secret: let the parent check whether to surface the nudge.+ onSecretCreated?.();}if (!updatedEnvs.length && !forApprovalEnvs.length) {