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

Function getCredentialOwner

apps/sim/lib/webhooks/provider-subscription-utils.ts:27–48  ·  view source on GitHub ↗
(
  credentialId: string,
  requestId: string
)

Source from the content-addressed store, hash-verified

25 * registration and cleanup.
26 */
27export async function getCredentialOwner(
28 credentialId: string,
29 requestId: string
30): Promise<{ userId: string; accountId: string } | null> {
31 const resolved = await resolveOAuthAccountId(credentialId)
32 if (!resolved) {
33 logger.warn(`[${requestId}] Failed to resolve OAuth account for credentialId ${credentialId}`)
34 return null
35 }
36 const [credentialRecord] = await db
37 .select({ userId: account.userId })
38 .from(account)
39 .where(eq(account.id, resolved.accountId))
40 .limit(1)
41
42 if (!credentialRecord?.userId) {
43 logger.warn(`[${requestId}] Credential owner not found for credentialId ${credentialId}`)
44 return null
45 }
46
47 return { userId: credentialRecord.userId, accountId: resolved.accountId }
48}

Callers 10

resolveAccessTokenFunction · 0.90
deleteSubscriptionFunction · 0.90
createSubscriptionFunction · 0.90
deleteSubscriptionFunction · 0.90
createSubscriptionFunction · 0.90
deleteSubscriptionFunction · 0.90
createSubscriptionFunction · 0.90
deleteSubscriptionFunction · 0.90
createSubscriptionFunction · 0.90
deleteSubscriptionFunction · 0.90

Calls 3

resolveOAuthAccountIdFunction · 0.90
warnMethod · 0.65
eqFunction · 0.50

Tested by

no test coverage detected