import { normalizeIdentity, plaidRequest, type PlaidAuthInput } from './plaid-core.ts' export type IdentityInput = PlaidAuthInput & { accountIds?: string[] } /** * Owner names, emails, phones, and addresses (`/identity/get`). */ export async function getIdentity(input: IdentityInput = {}) { const data = await plaidRequest({ ...input, path: '/identity/get', includeAccessToken: true, body: input.accountIds?.length ? { options: { account_ids: input.accountIds } } : {}, }) const accounts = Array.isArray(data?.accounts) ? data.accounts.map(normalizeIdentity) : [] return { accounts, item_id: data?.item?.item_id ?? null, request_id: data?.request_id ?? null, } } export default getIdentity