Skip to content

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

remove in-app as provider

Thiago Araujo da Silvac15292e5a559
diff --git a/backend/src/services/alarm/alarm-channel-types.ts b/backend/src/services/alarm/alarm-channel-types.ts
index 826f6478a2..e141506753 100644
--- a/backend/src/services/alarm/alarm-channel-types.ts
+++ b/backend/src/services/alarm/alarm-channel-types.ts
@@ -1,12 +1,9 @@
import RE2 from "re2";
import { z } from "zod";
-import { TNotificationServiceFactory } from "@app/services/notification/notification-service";
-import { NotificationType } from "@app/services/notification/notification-types";
import { TSmtpService } from "@app/services/smtp/smtp-service";
export enum AlarmChannelType {
- IN_APP = "in-app",
EMAIL = "email",
SLACK = "slack",
WEBHOOK = "webhook",
@@ -39,9 +36,6 @@ export type TAlarmPayload = {
severity: TAlarmSeverity;
summary: string; // one-line human summary
items: TAlarmItem[];
- // Required by the in-app channel; ignored by the others. Kept optional so endpoint-only alarms
- // need not supply it.
- notificationType?: NotificationType;
};
export type TChannelResult = { success: boolean; error?: string };
@@ -54,7 +48,6 @@ export type TAlarmRecipient = {
export type TAlarmChannelDeps = {
smtpService: Pick<TSmtpService, "sendMail">;
- notificationService: Pick<TNotificationServiceFactory, "createUserNotifications">;
};
export type TAlarmChannelSendContext = {
@@ -74,8 +67,6 @@ export type TAlarmChannelDefinition = {
export const EmailChannelConfigSchema = z.object({}).strip();
-export const InAppChannelConfigSchema = z.object({}).strip();
-
export const WebhookChannelConfigSchema = z.object({
url: z
.string()
@@ -107,7 +98,6 @@ export const PagerDutyChannelConfigSchema = z.object({
});
export type TEmailChannelConfig = z.infer<typeof EmailChannelConfigSchema>;
-export type TInAppChannelConfig = z.infer<typeof InAppChannelConfigSchema>;
export type TWebhookChannelConfig = z.infer<typeof WebhookChannelConfigSchema>;
export type TSlackChannelConfig = z.infer<typeof SlackChannelConfigSchema>;
export type TPagerDutyChannelConfig = z.infer<typeof PagerDutyChannelConfigSchema>;
diff --git a/backend/src/services/alarm/alarm-engine.test.ts b/backend/src/services/alarm/alarm-engine.test.ts
index 70a53ac541..588b8b66de 100644
--- a/backend/src/services/alarm/alarm-engine.test.ts
+++ b/backend/src/services/alarm/alarm-engine.test.ts
@@ -1,7 +1,5 @@
import { z } from "zod";
-import { NotificationType } from "@app/services/notification/notification-types";
-
import { TAlarmPayload } from "./alarm-channel-types";
import { alarmEngineFactory, TAlarmEngineDep } from "./alarm-engine";
import { alarmProviderRegistryFactory } from "./alarm-provider-registry";
@@ -50,7 +48,6 @@ const makeProvider = (targets: TTarget[]): IResourceAlarmProvider<TTarget> => ({
resourceKind: "Test Resource",
severity: "warning",
summary: `${matched.length} expiring`,
- notificationType: NotificationType.ALARM_CHANNEL_FAILED,
items: matched.map((target) => ({ id: target.id, title: target.id }))
})
});
@@ -121,20 +118,17 @@ const buildEngine = (opts: {
};
describe("alarm engine", () => {
- test("dispatches email + in-app to resolved recipients and records history", async () => {
+ test("dispatches email to resolved recipients and records history", async () => {
const { engine, sentMail, createdNotifications, historyWrites } = buildEngine({
targets: [{ id: "t1" }, { id: "t2" }],
- channels: [
- { id: "c-email", channelType: "email", encryptedConfig: encConfig({}), enabled: true },
- { id: "c-inapp", channelType: "in-app", encryptedConfig: encConfig({}), enabled: true }
- ]
+ channels: [{ id: "c-email", channelType: "email", encryptedConfig: encConfig({}), enabled: true }]
});
await engine.runAlarm(makeAlarm());
expect(sentMail).toHaveLength(1);
expect(sentMail[0].recipients).toEqual(["[email protected]"]);
- expect(createdNotifications).toHaveLength(1); // in-app delivery, not a failure fallback
+ expect(createdNotifications).toHaveLength(0); // no failure fallback on success
expect(historyWrites).toHaveLength(1);
expect(historyWrites[0].targetIds).toEqual(["t1", "t2"]);
expect(historyWrites[0].status).toBe(AlarmRunStatus.SUCCESS);
diff --git a/backend/src/services/alarm/alarm-engine.ts b/backend/src/services/alarm/alarm-engine.ts
index 17ff990d55..f714c1a957 100644
--- a/backend/src/services/alarm/alarm-engine.ts
+++ b/backend/src/services/alarm/alarm-engine.ts
@@ -122,7 +122,7 @@ export const alarmEngineFactory = ({
recipients = await alarmRecipientResolver.resolve(alarm.orgId, await alarmRecipientDAL.findByAlarmId(alarm.id));
}
- const deps: TAlarmChannelDeps = { smtpService, notificationService };
+ const deps: TAlarmChannelDeps = { smtpService };
const channelResults = await Promise.all(
channels.map(async (channel) => {
diff --git a/backend/src/services/alarm/alarm-service.test.ts b/backend/src/services/alarm/alarm-service.test.ts
index 54c7291dcb..bc4bc87a1c 100644
--- a/backend/src/services/alarm/alarm-service.test.ts
+++ b/backend/src/services/alarm/alarm-service.test.ts
@@ -113,7 +113,7 @@ const validCreate = {
recipients: [{ principalType: AlarmPrincipalType.USER, principalId: "user-1" }],
channels: [
{ channelType: AlarmChannelType.EMAIL, config: {} },
- { channelType: AlarmChannelType.IN_APP, config: {} }
+ { channelType: AlarmChannelType.WEBHOOK, config: { url: "https://example.com/hook" } }
],
...actor
};
diff --git a/backend/src/services/alarm/alarm-service.ts b/backend/src/services/alarm/alarm-service.ts
index b4590fddba..0f5752a78a 100644
--- a/backend/src/services/alarm/alarm-service.ts
+++ b/backend/src/services/alarm/alarm-service.ts
@@ -91,7 +91,7 @@ export const alarmServiceFactory = ({
const hasDirected = input.channels.some((channel) => ALARM_CHANNEL_REGISTRY[channel.channelType]?.directed);
if (hasDirected && (input.recipients ?? []).length === 0) {
- throw new BadRequestError({ message: "At least one recipient is required for in-app or email channels" });
+ throw new BadRequestError({ message: "At least one recipient is required for email channels" });
}
for (const channel of input.channels) {
diff --git a/backend/src/services/alarm/channels/alarm-channel-inapp-fns.ts b/backend/src/services/alarm/channels/alarm-channel-inapp-fns.ts
deleted file mode 100644
index 8f68a4a57a..0000000000
--- a/backend/src/services/alarm/channels/alarm-channel-inapp-fns.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-import { logger } from "@app/lib/logger";
-
-import { InAppChannelConfigSchema, TAlarmChannelSendContext, TChannelResult } from "../alarm-channel-types";
-
-export const sendInAppNotification = async (ctx: TAlarmChannelSendContext): Promise<TChannelResult> => {
- InAppChannelConfigSchema.parse(ctx.config);
-
- if (!ctx.recipient?.userId) {
- return { success: true };
- }
- if (!ctx.payload.notificationType) {
- return { success: false, error: "Missing notificationType for in-app channel" };
- }
-
- try {
- await ctx.deps.notificationService.createUserNotifications([
- {
- userId: ctx.recipient.userId,
- orgId: ctx.payload.alarm.orgId,
- type: ctx.payload.notificationType,
- title: `${ctx.payload.resourceKind} ${ctx.payload.eventLabel}: ${ctx.payload.alarm.name}`,
- body: ctx.payload.summary,
- link: ctx.payload.alarm.viewUrl
- }
- ]);
- return { success: true };
- } catch (err) {
- const error = err instanceof Error ? err.message : "Unknown error";
- logger.error(err, `Alarm in-app notification failed [channelId=${ctx.channelId}]`);
- return { success: false, error };
- }
-};
diff --git a/backend/src/services/alarm/channels/alarm-channel-registry.ts b/backend/src/services/alarm/channels/alarm-channel-registry.ts
index 8ce16bcff3..37bb861fd8 100644
--- a/backend/src/services/alarm/channels/alarm-channel-registry.ts
+++ b/backend/src/services/alarm/channels/alarm-channel-registry.ts
@@ -1,25 +1,17 @@
import {
AlarmChannelType,
EmailChannelConfigSchema,
- InAppChannelConfigSchema,
PagerDutyChannelConfigSchema,
SlackChannelConfigSchema,
TAlarmChannelDefinition,
WebhookChannelConfigSchema
} from "../alarm-channel-types";
import { sendEmailNotification } from "./alarm-channel-email-fns";
-import { sendInAppNotification } from "./alarm-channel-inapp-fns";
import { sendPagerDutyNotification } from "./alarm-channel-pagerduty-fns";
import { sendSlackNotification } from "./alarm-channel-slack-fns";
import { sendWebhookNotification } from "./alarm-channel-webhook-fns";
export const ALARM_CHANNEL_REGISTRY: Record<AlarmChannelType, TAlarmChannelDefinition> = {
- [AlarmChannelType.IN_APP]: {
- type: AlarmChannelType.IN_APP,
- directed: true,
- configSchema: InAppChannelConfigSchema,
- send: sendInAppNotification
- },
[AlarmChannelType.EMAIL]: {
type: AlarmChannelType.EMAIL,
directed: true,
diff --git a/backend/src/services/alarm/channels/alarm-channels.test.ts b/backend/src/services/alarm/channels/alarm-channels.test.ts
index 83ee164846..36497efe0d 100644
--- a/backend/src/services/alarm/channels/alarm-channels.test.ts
+++ b/backend/src/services/alarm/channels/alarm-channels.test.ts
@@ -1,8 +1,5 @@
-import { NotificationType } from "@app/services/notification/notification-types";
-
import { AlarmChannelType, TAlarmPayload } from "../alarm-channel-types";
import { sendEmailNotification } from "./alarm-channel-email-fns";
-import { sendInAppNotification } from "./alarm-channel-inapp-fns";
import { buildPagerDutyPayload } from "./alarm-channel-pagerduty-fns";
import { ALARM_CHANNEL_REGISTRY } from "./alarm-channel-registry";
import { buildSlackPayload, validateSlackWebhookUrl } from "./alarm-channel-slack-fns";
@@ -24,7 +21,6 @@ const samplePayload = (): TAlarmPayload => ({
resourceKind: "Certificate",
severity: "warning",
summary: "2 certificates expiring within 30d",
- notificationType: NotificationType.PKI_ALERT_CHANNEL_FAILED,
items: [
{
id: "cert-a",
@@ -48,14 +44,12 @@ const baseCtx = () => ({
channelId: "chan-1",
payload: samplePayload(),
deps: {
- smtpService: { sendMail: async () => undefined },
- notificationService: { createUserNotifications: async () => undefined }
+ smtpService: { sendMail: async () => undefined }
}
});
describe("alarm channel registry", () => {
- test("exposes all five channels with correct directed flags", () => {
- expect(ALARM_CHANNEL_REGISTRY[AlarmChannelType.IN_APP].directed).toBe(true);
+ test("exposes all four channels with correct directed flags", () => {
expect(ALARM_CHANNEL_REGISTRY[AlarmChannelType.EMAIL].directed).toBe(true);
expect(ALARM_CHANNEL_REGISTRY[AlarmChannelType.SLACK].directed).toBe(false);
expect(ALARM_CHANNEL_REGISTRY[AlarmChannelType.WEBHOOK].directed).toBe(false);
@@ -173,45 +167,3 @@ describe("sendEmailNotification (directed)", () => {
expect(result.success).toBe(false);
});
});
-
-describe("sendInAppNotification (directed)", () => {
- test("creates a notification for the recipient", async () => {
- let created: unknown[] | undefined;
- const ctx = {
- ...baseCtx(),
- config: {},
- recipient: { userId: "u1", email: "[email protected]" },
- deps: {
- ...baseCtx().deps,
- notificationService: {
- createUserNotifications: async (data: unknown[]) => {
- created = data;
- }
- }
- }
- };
- const result = await sendInAppNotification(ctx);
- expect(result.success).toBe(true);
- expect(created).toHaveLength(1);
- });
-
- test("skips (success no-op) a raw EMAIL-address recipient with no user id", async () => {
- let created: unknown[] | undefined;
- const ctx = {
- ...baseCtx(),
- config: {},
- recipient: { email: "[email protected]" },
- deps: {
- ...baseCtx().deps,
- notificationService: {
- createUserNotifications: async (data: unknown[]) => {
- created = data;
- }
- }
- }
- };
- const result = await sendInAppNotification(ctx);
- expect(result.success).toBe(true);
- expect(created).toBeUndefined();
- });
-});
diff --git a/backend/src/services/alarm/providers/identity-credential-alarm-provider.test.ts b/backend/src/services/alarm/providers/identity-credential-alarm-provider.test.ts
index 5f511e7914..26d10e0275 100644
--- a/backend/src/services/alarm/providers/identity-credential-alarm-provider.test.ts
+++ b/backend/src/services/alarm/providers/identity-credential-alarm-provider.test.ts
@@ -102,14 +102,13 @@ describe("identity credential alarm provider", () => {
expect(provider.targetId(targets[0])).toBe("ua-client-secret:sec-1");
});
- test("buildPayload produces neutral items, severity, and an in-app notification type", () => {
+ test("buildPayload produces neutral items and severity", () => {
const provider = buildProvider();
const target = { credentialType: "ua-client-secret" as const, ...sampleSecret({ expiresAt: futureDate(3) }) };
const payload = provider.buildPayload(alarmContext(), [target]);
expect(payload.eventKey).toBe(IDENTITY_CREDENTIAL_EXPIRY_EVENT);
expect(payload.severity).toBe("critical"); // 3 days out
- expect(payload.notificationType).toBe("identity-credential-expiry");
expect(payload.items[0].fields?.some((f) => f.label === "Days Until Expiry")).toBe(true);
expect(payload.alarm.viewUrl).toContain("/organizations/org-1/identities");
});
diff --git a/backend/src/services/alarm/providers/identity-credential-alarm-provider.ts b/backend/src/services/alarm/providers/identity-credential-alarm-provider.ts
index 70456b2e5f..824e2cf2a1 100644
--- a/backend/src/services/alarm/providers/identity-credential-alarm-provider.ts
+++ b/backend/src/services/alarm/providers/identity-credential-alarm-provider.ts
@@ -8,7 +8,6 @@ import { TPermissionServiceFactory } from "@app/ee/services/permission/permissio
import { ProjectPermissionIdentityActions, ProjectPermissionSub } from "@app/ee/services/permission/project-permission";
import { getConfig } from "@app/lib/config/env";
import { NotFoundError } from "@app/lib/errors";
-import { NotificationType } from "@app/services/notification/notification-types";
import { TAlarmPayload, TAlarmSeverity } from "../alarm-channel-types";
import {
@@ -107,7 +106,6 @@ export const identityCredentialAlarmProviderFactory = ({
summary: alertBefore
? `${targets.length} identity credential(s) expiring within ${alertBefore}`
: `${targets.length} identity credential(s) expiring`,
- notificationType: NotificationType.IDENTITY_CREDENTIAL_EXPIRY,
items: targets.map((target) => ({
id: `${target.credentialType}:${target.id}`,
title: `${CREDENTIAL_TYPE_LABEL[target.credentialType]} — ${target.identityName}`,
diff --git a/backend/src/services/notification/notification-types.ts b/backend/src/services/notification/notification-types.ts
index d7810cd0a3..fd503b7fb7 100644
--- a/backend/src/services/notification/notification-types.ts
+++ b/backend/src/services/notification/notification-types.ts
@@ -23,8 +23,7 @@ export enum NotificationType {
PKI_ALERT_CHANNEL_FAILED = "pki-alert-channel-failed",
CREDENTIAL_ROTATION_FAILED = "credential-rotation-failed",
AUDIT_LOG_MIGRATION_RECOMMENDED = "audit-log-migration-recommended",
- ALARM_CHANNEL_FAILED = "alarm-channel-failed",
- IDENTITY_CREDENTIAL_EXPIRY = "identity-credential-expiry"
+ ALARM_CHANNEL_FAILED = "alarm-channel-failed"
}
export interface TCreateUserNotificationDTO {