Spaces:
Configuration error
Configuration error
Download src/lib/crypto.ts from SreejithSHR/umami: direct link, hf CLI and curl.
- Browser
- Download file 618 Bytes
-
https://huggingface.co/spaces/SreejithSHR/umami/resolve/main/src/lib/crypto.ts
- Command line
-
hf download hf://spaces/SreejithSHR/umami/src/lib/crypto.ts
-
curl -L -o crypto.ts https://huggingface.co/spaces/SreejithSHR/umami/resolve/main/src/lib/crypto.ts
618 Bytes
| import { startOfHour, startOfMonth } from 'date-fns'; | |
| import { hash } from 'next-basics'; | |
| import { v4, v5 } from 'uuid'; | |
| export function secret() { | |
| return hash(process.env.APP_SECRET || process.env.DATABASE_URL); | |
| } | |
| export function salt() { | |
| const ROTATING_SALT = hash(startOfMonth(new Date()).toUTCString()); | |
| return hash(secret(), ROTATING_SALT); | |
| } | |
| export function visitSalt() { | |
| const ROTATING_SALT = hash(startOfHour(new Date()).toUTCString()); | |
| return hash(secret(), ROTATING_SALT); | |
| } | |
| export function uuid(...args: any) { | |
| if (!args.length) return v4(); | |
| return v5(hash(...args, salt()), v5.DNS); | |
| } | |