Added hashing on posting
This commit is contained in:
parent
05029c3b28
commit
41ede28a1c
1 changed files with 8 additions and 2 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue