mirror of
https://github.com/vercel/commerce.git
synced 2025-05-18 07:26:59 +00:00
Removed next import from kibocommerce
This commit is contained in:
parent
ac3120a54c
commit
fffc7e1aae
@ -1,8 +1,10 @@
|
||||
import getNextConfig from 'next/config'
|
||||
import type { KiboCommerceConfig } from '../index'
|
||||
import type { FetchOptions } from '@vercel/fetch'
|
||||
import fetch from './fetch'
|
||||
|
||||
// This object is persisted during development
|
||||
const authCache: { kiboAuthTicket?: AppAuthTicket } = {}
|
||||
|
||||
interface AppAuthTicket {
|
||||
access_token: string
|
||||
token_type: string
|
||||
@ -12,19 +14,17 @@ interface AppAuthTicket {
|
||||
}
|
||||
|
||||
interface AuthTicketCache {
|
||||
getAuthTicket: () => Promise<AppAuthTicket>
|
||||
getAuthTicket: () => Promise<AppAuthTicket | undefined>
|
||||
setAuthTicket: (kiboAuthTicket: AppAuthTicket) => void
|
||||
}
|
||||
|
||||
class RuntimeMemCache implements AuthTicketCache {
|
||||
constructor() {}
|
||||
async getAuthTicket() {
|
||||
const { serverRuntimeConfig } = getNextConfig()
|
||||
return serverRuntimeConfig.kiboAuthTicket
|
||||
return authCache.kiboAuthTicket
|
||||
}
|
||||
setAuthTicket(kiboAuthTicket: AppAuthTicket) {
|
||||
const { serverRuntimeConfig } = getNextConfig()
|
||||
serverRuntimeConfig.kiboAuthTicket = kiboAuthTicket
|
||||
authCache.kiboAuthTicket = kiboAuthTicket
|
||||
}
|
||||
}
|
||||
|
||||
@ -105,6 +105,6 @@ export class APIAuthenticationHelper {
|
||||
authTicket = await this.refreshTicket(authTicket)
|
||||
}
|
||||
|
||||
return authTicket.access_token
|
||||
return authTicket!.access_token
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user