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 { KiboCommerceConfig } from '../index'
|
||||||
import type { FetchOptions } from '@vercel/fetch'
|
import type { FetchOptions } from '@vercel/fetch'
|
||||||
import fetch from './fetch'
|
import fetch from './fetch'
|
||||||
|
|
||||||
|
// This object is persisted during development
|
||||||
|
const authCache: { kiboAuthTicket?: AppAuthTicket } = {}
|
||||||
|
|
||||||
interface AppAuthTicket {
|
interface AppAuthTicket {
|
||||||
access_token: string
|
access_token: string
|
||||||
token_type: string
|
token_type: string
|
||||||
@ -12,19 +14,17 @@ interface AppAuthTicket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface AuthTicketCache {
|
interface AuthTicketCache {
|
||||||
getAuthTicket: () => Promise<AppAuthTicket>
|
getAuthTicket: () => Promise<AppAuthTicket | undefined>
|
||||||
setAuthTicket: (kiboAuthTicket: AppAuthTicket) => void
|
setAuthTicket: (kiboAuthTicket: AppAuthTicket) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
class RuntimeMemCache implements AuthTicketCache {
|
class RuntimeMemCache implements AuthTicketCache {
|
||||||
constructor() {}
|
constructor() {}
|
||||||
async getAuthTicket() {
|
async getAuthTicket() {
|
||||||
const { serverRuntimeConfig } = getNextConfig()
|
return authCache.kiboAuthTicket
|
||||||
return serverRuntimeConfig.kiboAuthTicket
|
|
||||||
}
|
}
|
||||||
setAuthTicket(kiboAuthTicket: AppAuthTicket) {
|
setAuthTicket(kiboAuthTicket: AppAuthTicket) {
|
||||||
const { serverRuntimeConfig } = getNextConfig()
|
authCache.kiboAuthTicket = kiboAuthTicket
|
||||||
serverRuntimeConfig.kiboAuthTicket = kiboAuthTicket
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,6 +105,6 @@ export class APIAuthenticationHelper {
|
|||||||
authTicket = await this.refreshTicket(authTicket)
|
authTicket = await this.refreshTicket(authTicket)
|
||||||
}
|
}
|
||||||
|
|
||||||
return authTicket.access_token
|
return authTicket!.access_token
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user