diff --git a/src/utils/functions/postApi.ts b/src/utils/functions/postApi.ts index 7bda182..7195db6 100644 --- a/src/utils/functions/postApi.ts +++ b/src/utils/functions/postApi.ts @@ -1,16 +1,22 @@ import { ofetch } from 'ofetch' -import { SHA3 } from 'crypto-js' +import encryptAes from './encryptAes' +import dayjs from 'dayjs' const API = import.meta.env.VITE_BACKEND export default async (api: string, body: Object) => { + const today = new Date() + const todayUnix = dayjs(today).unix() + const expiration = todayUnix + 9 + const aes = await encryptAes(`${todayUnix.toString()}-${expiration.toString()}`) + const hash = `ocbo-${aes}-token` try { await ofetch(API + api, { headers: { Accept: 'application/json', 'Cache-Control': 'no-cache', - 'OCBO-Token': '', + 'OCBO-Token': hash, }, method: 'POST', body: body,