Skip to content

Built for people who want to own their automations. Join the waitlist for an invite.

Package listing

@kody/plaid

src/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