( credentialId: string, requestId: string )
| 25 | * registration and cleanup. |
| 26 | */ |
| 27 | export 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 | } |
no test coverage detected