Skip to content
← Public packages

@kody/plaid

Read Plaid identity, items, accounts, balances, and transactions with sandbox-friendly secret-backed helpers.

FollowFork

Files

identity.ts

25 lines · 716 B · TypeScript
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