mirror of
https://github.com/vercel/commerce.git
synced 2025-04-27 21:37:50 +00:00
* Fix auth & wishlist * Revert files * Update signup.ts * Update signup.ts * Requested changes * Revert fetch options
25 lines
656 B
TypeScript
25 lines
656 B
TypeScript
import type { KiboCommerceConfig } from '..'
|
|
import { getCustomerAccountQuery } from '../queries/get-customer-account-query'
|
|
|
|
async function getCustomerId({
|
|
customerToken,
|
|
config,
|
|
}: {
|
|
customerToken: string
|
|
config: KiboCommerceConfig
|
|
}): Promise<string | undefined> {
|
|
const token = customerToken
|
|
? Buffer.from(customerToken, 'base64').toString('ascii')
|
|
: null
|
|
const accessToken = token ? JSON.parse(token).accessToken : null
|
|
const { data } = await config.fetch(getCustomerAccountQuery, undefined, {
|
|
headers: {
|
|
'x-vol-user-claims': accessToken,
|
|
},
|
|
})
|
|
|
|
return data?.customerAccount?.id
|
|
}
|
|
|
|
export default getCustomerId
|