MCPcopy
hub / github.com/simstudioai/sim / deleteCredential

Function deleteCredential

apps/sim/lib/credentials/deletion.ts:30–72  ·  view source on GitHub ↗
(params: DeleteCredentialParams)

Source from the content-addressed store, hash-verified

28 * records an audit entry. Idempotent when the row no longer exists.
29 */
30export async function deleteCredential(params: DeleteCredentialParams): Promise<void> {
31 const { credentialId, actorId, actorName, actorEmail, reason, request } = params
32
33 const [row] = await db
34 .select({
35 id: schema.credential.id,
36 workspaceId: schema.credential.workspaceId,
37 type: schema.credential.type,
38 displayName: schema.credential.displayName,
39 providerId: schema.credential.providerId,
40 accountId: schema.credential.accountId,
41 })
42 .from(schema.credential)
43 .where(eq(schema.credential.id, credentialId))
44 .limit(1)
45
46 if (!row) return
47
48 await clearCredentialRefs(credentialId, row.workspaceId)
49
50 await db.delete(schema.credential).where(eq(schema.credential.id, credentialId))
51
52 recordAudit({
53 workspaceId: row.workspaceId,
54 actorId,
55 actorName: actorName ?? undefined,
56 actorEmail: actorEmail ?? undefined,
57 action: AuditAction.CREDENTIAL_DELETED,
58 resourceType: AuditResourceType.CREDENTIAL,
59 resourceId: credentialId,
60 resourceName: row.displayName,
61 description: `Deleted ${row.type} credential "${row.displayName}" (${reason})`,
62 metadata: {
63 reason,
64 credentialType: row.type,
65 providerId: row.providerId,
66 accountId: row.accountId,
67 },
68 request,
69 })
70
71 logger.info('Deleted credential', { credentialId, workspaceId: row.workspaceId, reason })
72}
73
74/**
75 * Clears stored references to a credential across mutable workspace state

Callers 2

performDeleteCredentialFunction · 0.90
route.tsFile · 0.90

Calls 5

recordAuditFunction · 0.90
clearCredentialRefsFunction · 0.85
infoMethod · 0.80
deleteMethod · 0.65
eqFunction · 0.50

Tested by

no test coverage detected