Catalyst / admin/Synapse-Sonar 14.8 GB / 57.8 GB 40.0 GB free
Help Sign in

admin / Synapse-Sonar

public

Attack Surface Simulation

Code Issues Pull requests Pipelines Packages Security Insights Wiki Settings
Synapse-Sonar / synapse-sonar / lib / integrations.ts 923 B · main
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { prisma } from "@/lib/prisma";
import { decryptJson, EncryptedBlob } from "@/lib/crypto";
import { IntegrationProvider } from "@prisma/client";

export interface NetscanXiConfig {
  endpointUrl: string;
  apiKey: string;
}

export interface IronNodeConfig {
  webhookUrl: string;
  signingKey: string;
}

/**
 * Returns the decrypted config for a provider IFF the integration row exists
 * AND is toggled enabled. Returns null when disabled/absent — callers treat
 * null as "feature off", which is how the master On/Off toggle halts sync.
 */
export async function getEnabledIntegration<T>(
  tenantId: string,
  provider: IntegrationProvider
): Promise<T | null> {
  const row = await prisma.integrationSetting.findUnique({
    where: { tenantId_provider: { tenantId, provider } },
  });
  if (!row || !row.enabled || !row.config) return null;
  return decryptJson<T>(row.config as unknown as EncryptedBlob);
}