update visitId hash and expiration logic

This commit is contained in:
Francis Cao 2024-03-25 17:47:53 -07:00
parent d3ca856521
commit 0aaf2c0b3b
5 changed files with 44 additions and 10 deletions

View file

@ -1,4 +1,4 @@
import { startOfMonth } from 'date-fns';
import { startOfHour, startOfMonth } from 'date-fns';
import { hash } from 'next-basics';
import { v4, v5, validate } from 'uuid';
@ -12,6 +12,12 @@ export function salt() {
return hash(secret(), ROTATING_SALT);
}
export function sessionSalt() {
const ROTATING_SALT = hash(startOfHour(new Date()).toUTCString());
return hash(secret(), ROTATING_SALT);
}
export function uuid(...args: any) {
if (!args.length) return v4();