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 { ofetch } from 'ofetch'
|
||||||
import { SHA3 } from 'crypto-js'
|
import encryptAes from './encryptAes'
|
||||||
|
import dayjs from 'dayjs'
|
||||||
|
|
||||||
const API = import.meta.env.VITE_BACKEND
|
const API = import.meta.env.VITE_BACKEND
|
||||||
|
|
||||||
export default async (api: string, body: Object) => {
|
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 {
|
try {
|
||||||
await ofetch(API + api, {
|
await ofetch(API + api, {
|
||||||
headers: {
|
headers: {
|
||||||
Accept: 'application/json',
|
Accept: 'application/json',
|
||||||
'Cache-Control': 'no-cache',
|
'Cache-Control': 'no-cache',
|
||||||
'OCBO-Token': '',
|
'OCBO-Token': hash,
|
||||||
},
|
},
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: body,
|
body: body,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue