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
feat: add template for emails
adilson00acc11bea11
diff --git a/backend/src/keystore/keystore.ts b/backend/src/keystore/keystore.tsindex 14ab51a30d..d8629ecde5 100644--- a/backend/src/keystore/keystore.ts+++ b/backend/src/keystore/keystore.ts@@ -178,7 +178,7 @@ export const KeyStorePrefixes = {// period is a YYYY-MM stamp so the monthly notice can only go out once per org per monthNativeIntegrationDeprecationNotice: (orgId: string, period: string) =>- `new-2-native-integration-deprecation-notice:${orgId}:${period}` as const+ `native-integration-deprecation-notice:${orgId}:${period}` as const};export const KeyStoreTtls = {diff --git a/backend/src/services/integration/integration-deprecation-queue.ts b/backend/src/services/integration/integration-deprecation-queue.tsindex 59ad598d78..91a270c8b2 100644--- a/backend/src/services/integration/integration-deprecation-queue.ts+++ b/backend/src/services/integration/integration-deprecation-queue.ts@@ -18,7 +18,6 @@ import {buildNativeIntegrationsUrl,groupIntegrationsByProject,NATIVE_INTEGRATION_DEPRECATION_DATE,- TIntegrationProjectSummary,TNoticeRecipient,toRecipients} from "./integration-deprecation-fns";@@ -39,7 +38,11 @@ type TIntegrationDeprecationQueueFactoryDep = {export type TIntegrationDeprecationQueueFactory = ReturnType<typeof integrationDeprecationQueueFactory>;-const EMAIL_SUBJECT = `Action required: Migrate Native Integrations by ${NATIVE_INTEGRATION_DEPRECATION_DATE}`;+const PROJECT_ADMIN_EMAIL_SUBJECT = `Action required: Migrate Native Integrations by ${NATIVE_INTEGRATION_DEPRECATION_DATE}`;+const getOrgAdminEmailSubject = (projectCount: number, orgName: string) =>+ projectCount === 1+ ? `Action needed: 1 project in ${orgName} still uses native integrations`+ : `Action needed: ${projectCount} projects in ${orgName} still use native integrations`;// the notification dropdown renders the title on a single ellipsised line next to a timestamp, so this// stays shorter than the subject line and front-loads the part that mattersconst NOTIFICATION_TITLE = `Native integrations stop working ${NATIVE_INTEGRATION_DEPRECATION_DATE}`;@@ -73,17 +76,17 @@ export const integrationDeprecationQueueFactory = ({}: TIntegrationDeprecationQueueFactoryDep) => {const sendNotice = async ({orgId,- orgName,- projects,recipients,- siteUrl,+ email,link}: {orgId: string;- orgName: string;- projects: TIntegrationProjectSummary[];recipients: TNoticeRecipient[];- siteUrl: string;+ email: {+ template: SmtpTemplates;+ subjectLine: string;+ substitutions: Record<string, unknown>;+ };/** site-relative — see buildNativeIntegrationsPath */link?: string;}) => {@@ -92,17 +95,10 @@ export const integrationDeprecationQueueFactory = ({const sendEmail = async () => {try {await smtpService.sendMail({- template: SmtpTemplates.NativeIntegrationDeprecation,- subjectLine: EMAIL_SUBJECT,+ template: email.template,+ subjectLine: email.subjectLine,recipients: recipients.map((recipient) => recipient.email),- substitutions: {- orgName,- projects: projects.map((project) => ({- name: project.projectName,- integrations: project.integrations,- url: buildNativeIntegrationsUrl(siteUrl, orgId, project.projectId)- }))- }+ substitutions: email.substitutions});} catch (error) {logger.error(error, `integrationDeprecationNotice: failed to send email [orgId=${orgId}]`);@@ -177,25 +173,40 @@ export const integrationDeprecationQueueFactory = ({// every recipient list is resolved above; from here on it is only sendingconst { SITE_URL: siteUrl } = appCfg;- const notify = (recipients: TNoticeRecipient[], noticeProjects: TIntegrationProjectSummary[], link?: string) =>- sendNotice({ orgId, orgName: org.name, siteUrl, recipients, projects: noticeProjects, link });// org admins get one notice covering every affected project; a deep link only makes sense when there is a// single project to point at- await notify(- orgAdminRecipients,- projects,- projects.length === 1 ? buildNativeIntegrationsPath(orgId, projects[0].projectId) : undefined- );+ await sendNotice({+ orgId,+ recipients: orgAdminRecipients,+ email: {+ template: SmtpTemplates.NativeIntegrationDeprecationOrgAdmin,+ subjectLine: getOrgAdminEmailSubject(projects.length, org.name),+ substitutions: { orgName: org.name, projectCount: projects.length }+ },+ link: projects.length === 1 ? buildNativeIntegrationsPath(orgId, projects[0].projectId) : undefined+ });// then each project's admins get a notice scoped to their own project, minus anyone already reached abovefor (const project of projects) {// eslint-disable-next-line no-await-in-loop- await notify(- toRecipients(projectAdminsByProjectId[project.projectId] ?? [], orgAdminUserIds),- [project],- buildNativeIntegrationsPath(orgId, project.projectId)- );+ await sendNotice({+ orgId,+ recipients: toRecipients(projectAdminsByProjectId[project.projectId] ?? [], orgAdminUserIds),+ email: {+ template: SmtpTemplates.NativeIntegrationDeprecationProjectAdmin,+ subjectLine: PROJECT_ADMIN_EMAIL_SUBJECT,+ substitutions: {+ orgName: org.name,+ project: {+ name: project.projectName,+ integrations: project.integrations,+ url: buildNativeIntegrationsUrl(siteUrl, orgId, project.projectId)+ }+ }+ },+ link: buildNativeIntegrationsPath(orgId, project.projectId)+ });}logger.info(diff --git a/backend/src/services/project-membership/project-membership-dal.ts b/backend/src/services/project-membership/project-membership-dal.tsindex dfbb5fad46..042ffdfc72 100644--- a/backend/src/services/project-membership/project-membership-dal.ts+++ b/backend/src/services/project-membership/project-membership-dal.ts@@ -1,7 +1,7 @@import { Knex } from "knex";import { TDbClient } from "@app/db";-import { AccessScope, TableName, TMemberships, TUserEncryptionKeys } from "@app/db/schemas";+import { AccessScope, OrgMembershipStatus, TableName, TMemberships, TUserEncryptionKeys } from "@app/db/schemas";import { DatabaseError } from "@app/lib/errors";import { selectAllTableCols, sqlNestRelationships } from "@app/lib/knex";@@ -175,7 +175,15 @@ export const projectMembershipDALFactory = (db: TDbClient) => {.whereNotNull(`${TableName.Membership}.actorUserId`).join(TableName.Project, `${TableName.Membership}.scopeProjectId`, `${TableName.Project}.id`).join(TableName.Users, `${TableName.Membership}.actorUserId`, `${TableName.Users}.id`)+ .join<TMemberships>(db(TableName.Membership).as("orgMembership"), (qb) => {+ qb.on(`${TableName.Users}.id`, "=", `orgMembership.actorUserId`)+ .andOn(`orgMembership.scopeOrgId`, "=", `${TableName.Project}.orgId`)+ .andOn("orgMembership.scope", db.raw("?", [AccessScope.Organization]));+ }).where({ isGhost: false })+ .where({ [`${TableName.Membership}.isActive` as "isActive"]: true })+ .where(`orgMembership.isActive`, true)+ .where(`orgMembership.status`, OrgMembershipStatus.Accepted).where((qb) => {if (filter.orgId) {void qb.where(`${TableName.Project}.orgId`, filter.orgId);diff --git a/backend/src/services/smtp/emails/NativeIntegrationDeprecationOrgAdminTemplate.tsx b/backend/src/services/smtp/emails/NativeIntegrationDeprecationOrgAdminTemplate.tsxnew file mode 100644index 0000000000..bd372af3ff--- /dev/null+++ b/backend/src/services/smtp/emails/NativeIntegrationDeprecationOrgAdminTemplate.tsx@@ -0,0 +1,75 @@+import { Heading, Section, Text } from "@react-email/components";++import { NATIVE_INTEGRATION_DEPRECATION_DATE } from "@app/services/integration/integration-deprecation-fns";++import { BaseEmailWrapper, BaseEmailWrapperProps } from "./BaseEmailWrapper";+import { BaseLink } from "./BaseLink";++const MIGRATION_DOC_URL = "https://infisical.com/docs/integrations/secret-syncs/native-integrations-migration";++interface NativeIntegrationDeprecationOrgAdminTemplateProps+ extends Omit<BaseEmailWrapperProps, "title" | "preview" | "children"> {+ orgName: string;+ projectCount: number;+}++export const NativeIntegrationDeprecationOrgAdminTemplate = ({+ siteUrl,+ orgName,+ projectCount+}: NativeIntegrationDeprecationOrgAdminTemplateProps) => {+ const isSingleProject = projectCount === 1;++ return (+ <BaseEmailWrapper+ title="Native Integrations are being retired"+ preview="Native Integrations must be migrated to Secret Syncs"+ siteUrl={siteUrl}+ >+ <Heading className="text-black text-[18px] leading-[28px] text-center font-normal p-0 mx-0">+ <strong>Native Integrations must be migrated to Secret Syncs</strong>+ </Heading>+ <Section className="px-[24px] mb-[28px] mt-[36px] pt-[12px] pb-[8px] border border-solid border-gray-200 rounded-md bg-gray-50">+ <Text className="text-black text-[14px] leading-[24px]">Hello,</Text>+ <Text className="text-black text-[14px] leading-[24px]">+ <strong>{projectCount}</strong> {isSingleProject ? "project" : "projects"} in <strong>{orgName}</strong>{" "}+ {isSingleProject ? "is" : "are"} using native integrations. Native integrations are being retired on{" "}+ <strong>{NATIVE_INTEGRATION_DEPRECATION_DATE}</strong>.+ </Text>+ <Text className="text-black text-[14px] leading-[24px]">+ Native Integrations are being replaced by Secret Syncs, which support all the same third-party services, plus+ additional features such as reusable credentials, secret key schemas, and much more. Most users finish+ migrating in under 15 minutes.+ </Text>+ <Text className="text-black text-[14px] leading-[24px]">+ We recommend sharing this with the project admins in your organization so they can plan their migration.{" "}+ <BaseLink href={MIGRATION_DOC_URL}>+ Learn more about the migration from Native Integrations to Secret Syncs+ </BaseLink>+ .+ </Text>+ <Text className="text-black text-[14px] leading-[24px]">+ We put together a step-by-step guide here:{" "}+ <BaseLink href={MIGRATION_DOC_URL}>Migrating Native Integrations</BaseLink>+ </Text>+ <Text className="text-black text-[14px] leading-[24px]">+ If you have a complex setup or want us to walk through the migration with you, reach out to us at{" "}+ <BaseLink href="mailto:[email protected]">[email protected]</BaseLink>.+ </Text>+ <Text className="text-black text-[14px] leading-[24px]">+ Thanks,+ <br />+ The Infisical Team+ </Text>+ </Section>+ </BaseEmailWrapper>+ );+};++export default NativeIntegrationDeprecationOrgAdminTemplate;++NativeIntegrationDeprecationOrgAdminTemplate.PreviewProps = {+ siteUrl: "https://infisical.com",+ orgName: "Example Organization",+ projectCount: 5+} as NativeIntegrationDeprecationOrgAdminTemplateProps;diff --git a/backend/src/services/smtp/emails/NativeIntegrationDeprecationProjectAdminTemplate.tsx b/backend/src/services/smtp/emails/NativeIntegrationDeprecationProjectAdminTemplate.tsxnew file mode 100644index 0000000000..88576a5b7d--- /dev/null+++ b/backend/src/services/smtp/emails/NativeIntegrationDeprecationProjectAdminTemplate.tsx@@ -0,0 +1,78 @@+import { Heading, Section, Text } from "@react-email/components";++import { NATIVE_INTEGRATION_DEPRECATION_DATE } from "@app/services/integration/integration-deprecation-fns";++import { BaseEmailWrapper, BaseEmailWrapperProps } from "./BaseEmailWrapper";+import { BaseLink } from "./BaseLink";++const MIGRATION_DOC_URL = "https://infisical.com/docs/integrations/secret-syncs/native-integrations-migration";++interface NativeIntegrationDeprecationProjectAdminTemplateProps+ extends Omit<BaseEmailWrapperProps, "title" | "preview" | "children"> {+ orgName: string;+ project: { name: string; integrations: string[]; url: string };+}++export const NativeIntegrationDeprecationProjectAdminTemplate = ({+ siteUrl,+ orgName,+ project+}: NativeIntegrationDeprecationProjectAdminTemplateProps) => {+ return (+ <BaseEmailWrapper+ title="Native Integrations are being retired"+ preview="Native Integrations must be migrated to Secret Syncs"+ siteUrl={siteUrl}+ >+ <Heading className="text-black text-[18px] leading-[28px] text-center font-normal p-0 mx-0">+ <strong>Native Integrations must be migrated to Secret Syncs</strong>+ </Heading>+ <Section className="px-[24px] mb-[28px] mt-[36px] pt-[12px] pb-[8px] border border-solid border-gray-200 rounded-md bg-gray-50">+ <Text className="text-black text-[14px] leading-[24px]">Hello,</Text>+ <Text className="text-black text-[14px] leading-[24px]">+ Your project <strong>{project.name}</strong> in <strong>{orgName}</strong> is using Native Integrations, which+ we're retiring on <strong>{NATIVE_INTEGRATION_DEPRECATION_DATE}</strong>.+ </Text>+ <Text className="text-black text-[14px] leading-[24px]">+ Native Integrations are being replaced by Secret Syncs, which support all the same services, plus additional+ features such as reusable credentials, secret key schemas, and much more. Most users finish migrating in under+ 15 minutes.+ </Text>+ <Text className="text-black text-[14px] leading-[24px]">+ We put together a step-by-step guide here:{" "}+ <BaseLink href={MIGRATION_DOC_URL}>Migrating Native Integrations</BaseLink>+ </Text>+ <Text className="text-black text-[14px] leading-[24px]">+ If you have a complex setup or want us to walk through the migration with you, reach out to us at{" "}+ <BaseLink href="mailto:[email protected]">[email protected]</BaseLink>.+ </Text>+ <Text className="text-black text-[14px] leading-[24px]">+ Thanks,+ <br />+ The Infisical Team+ </Text>+ </Section>+ <Section className="mb-[28px]">+ <Text className="text-[14px] font-semibold mb-[12px]">Integrations to migrate</Text>+ <Section className="mb-[16px] p-[16px] border border-solid border-gray-200 rounded-md bg-gray-50">+ <Text className="text-[14px] font-semibold m-0 mb-[4px]">+ <BaseLink href={project.url}>{project.name}</BaseLink>+ </Text>+ <Text className="text-[12px] text-gray-600 m-0">{project.integrations.join(", ")}</Text>+ </Section>+ </Section>+ </BaseEmailWrapper>+ );+};++export default NativeIntegrationDeprecationProjectAdminTemplate;++NativeIntegrationDeprecationProjectAdminTemplate.PreviewProps = {+ siteUrl: "https://infisical.com",+ orgName: "Example Organization",+ project: {+ name: "backend-api",+ integrations: ["GitHub", "AWS Parameter Store", "Vercel"],+ url: "https://infisical.com"+ }+} as NativeIntegrationDeprecationProjectAdminTemplateProps;diff --git a/backend/src/services/smtp/emails/NativeIntegrationDeprecationTemplate.tsx b/backend/src/services/smtp/emails/NativeIntegrationDeprecationTemplate.tsxdeleted file mode 100644index 472c15ac80..0000000000--- a/backend/src/services/smtp/emails/NativeIntegrationDeprecationTemplate.tsx+++ /dev/null@@ -1,110 +0,0 @@-import { Heading, Section, Text } from "@react-email/components";--import { NATIVE_INTEGRATION_DEPRECATION_DATE } from "@app/services/integration/integration-deprecation-fns";--import { BaseButton } from "./BaseButton";-import { BaseEmailWrapper, BaseEmailWrapperProps } from "./BaseEmailWrapper";-import { BaseLink } from "./BaseLink";--interface NativeIntegrationDeprecationTemplateProps- extends Omit<BaseEmailWrapperProps, "title" | "preview" | "children"> {- orgName: string;- // a single entry for the per-project email, every affected project for the org-wide email- projects: { name: string; integrations: string[]; url: string }[];-}--export const NativeIntegrationDeprecationTemplate = ({- siteUrl,- orgName,- projects-}: NativeIntegrationDeprecationTemplateProps) => {- const isSingleProject = projects.length === 1;-- return (- <BaseEmailWrapper- title="Native Integrations are being retired"- preview={`Native Integrations are being retired on ${NATIVE_INTEGRATION_DEPRECATION_DATE}. Your existing integrations keep working until then.`}- siteUrl={siteUrl}- >- <Heading className="text-black text-[18px] leading-[28px] text-center font-normal p-0 mx-0">- <strong>Native Integrations must be migrated to Secret Syncs</strong>- </Heading>- <Section className="px-[24px] mb-[28px] mt-[36px] pt-[12px] pb-[8px] border border-solid border-gray-200 rounded-md bg-gray-50">- <Text className="text-black text-[14px] leading-[24px]">- {isSingleProject ? (- <>- The <strong>{projects[0].name}</strong> project in <strong>{orgName}</strong> still uses native- integrations.- </>- ) : (- <>- <strong>{projects.length}</strong> projects in <strong>{orgName}</strong> still use native integrations.- </>- )}{" "}- Native Integrations are being retired on <strong>{NATIVE_INTEGRATION_DEPRECATION_DATE}</strong> and you can- learn more about it on{" "}- <BaseLink href="https://infisical.com/docs/integrations/secret-syncs/native-integrations-migration">- Migrating Native Integrations- </BaseLink>- . Secret Syncs are the new, recommended way to sync secrets to third-party services, offering more features- and supporting all the same services. Your existing integrations keep working until then.- </Text>- </Section>- <Section className="mb-[28px]">- <Text className="text-[14px] font-semibold mb-[12px]">- {isSingleProject ? "Integrations to migrate" : "Projects using native integrations"}- </Text>- {projects.map((project) => (- <Section- key={project.name}- className="mb-[16px] p-[16px] border border-solid border-gray-200 rounded-md bg-gray-50"- >- <Text className="text-[14px] font-semibold m-0 mb-[4px]">- <BaseLink href={project.url}>{project.name}</BaseLink>- </Text>- <Text className="text-[12px] text-gray-600 m-0">{project.integrations.join(", ")}</Text>- </Section>- ))}- </Section>- <Section className="text-center">- <BaseButton href="https://infisical.com/docs/integrations/secret-syncs/native-integrations-migration">- Migrate to Secret Syncs- </BaseButton>- </Section>- </BaseEmailWrapper>- );-};--export default NativeIntegrationDeprecationTemplate;--NativeIntegrationDeprecationTemplate.PreviewProps = {- siteUrl: "https://infisical.com",- orgName: "Example Organization",- projects: [- {- name: "backend-api",- integrations: ["GitHub", "AWS Parameter Store", "Vercel"],- url: "https://infisical.com"- },- {- name: "web-app",- integrations: ["Netlify", "Cloudflare Pages"],- url: "https://infisical.com"- },- {- name: "mobile-app",- integrations: ["Firebase", "AWS Secrets Manager"],- url: "https://infisical.com"- },- {- name: "data-pipeline",- integrations: ["Databricks", "Snowflake"],- url: "https://infisical.com"- },- {- name: "infra",- integrations: ["Terraform Cloud", "Fly.io"],- url: "https://infisical.com"- }- ]-} as NativeIntegrationDeprecationTemplateProps;diff --git a/backend/src/services/smtp/emails/index.ts b/backend/src/services/smtp/emails/index.tsindex a1dd3c55f8..cf807162b3 100644--- a/backend/src/services/smtp/emails/index.ts+++ b/backend/src/services/smtp/emails/index.ts@@ -18,7 +18,8 @@ export * from "./HealthAlertTemplate";export * from "./HoneyTokenTriggeredTemplate";export * from "./IntegrationSyncFailedTemplate";export * from "./MfaRecoveryCodeUsedTemplate";-export * from "./NativeIntegrationDeprecationTemplate";+export * from "./NativeIntegrationDeprecationOrgAdminTemplate";+export * from "./NativeIntegrationDeprecationProjectAdminTemplate";export * from "./NewDeviceLoginTemplate";export * from "./OAuthPasswordResetTemplate";export * from "./OrgAdminBreakglassAccessTemplate";diff --git a/backend/src/services/smtp/smtp-service.ts b/backend/src/services/smtp/smtp-service.tsindex 9c4f2df9dc..a879ced3de 100644--- a/backend/src/services/smtp/smtp-service.ts+++ b/backend/src/services/smtp/smtp-service.ts@@ -28,7 +28,8 @@ import {HoneyTokenTriggeredTemplate,IntegrationSyncFailedTemplate,MfaRecoveryCodeUsedTemplate,- NativeIntegrationDeprecationTemplate,+ NativeIntegrationDeprecationOrgAdminTemplate,+ NativeIntegrationDeprecationProjectAdminTemplate,NewDeviceLoginTemplate,OAuthPasswordResetTemplate,OrgAdminBreakglassAccessTemplate,@@ -94,7 +95,8 @@ export enum SmtpTemplates {SecretApprovalRequestNeedsReview = "secretApprovalRequestNeedsReview",// HistoricalSecretList = "historicalSecretLeakIncident", not used anymore?NewDeviceJoin = "newDevice",- NativeIntegrationDeprecation = "nativeIntegrationDeprecation",+ NativeIntegrationDeprecationOrgAdmin = "nativeIntegrationDeprecationOrgAdmin",+ NativeIntegrationDeprecationProjectAdmin = "nativeIntegrationDeprecationProjectAdmin",OrgInvite = "organizationInvitation",SubOrgInvite = "subOrganizationInvitation",OrgAssignment = "organizationAssignment",@@ -144,7 +146,8 @@ const EmailTemplateMap: Record<SmtpTemplates, React.FC<any>> = {[SmtpTemplates.SubOrgInvite]: SubOrganizationInvitationTemplate,[SmtpTemplates.OrgAssignment]: OrganizationAssignmentTemplate,[SmtpTemplates.NewDeviceJoin]: NewDeviceLoginTemplate,- [SmtpTemplates.NativeIntegrationDeprecation]: NativeIntegrationDeprecationTemplate,+ [SmtpTemplates.NativeIntegrationDeprecationOrgAdmin]: NativeIntegrationDeprecationOrgAdminTemplate,+ [SmtpTemplates.NativeIntegrationDeprecationProjectAdmin]: NativeIntegrationDeprecationProjectAdminTemplate,[SmtpTemplates.SignupEmailVerification]: SignupEmailVerificationTemplate,[SmtpTemplates.SignupExistingAccount]: SignupExistingAccountTemplate,[SmtpTemplates.EmailMfa]: EmailMfaTemplate,