Added hashing on posting

This commit is contained in:
Patrick Alvin Alcala 2025-11-07 17:31:58 +08:00
parent 05029c3b28
commit 41ede28a1c

View file

@ -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,