mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-15 09:45:04 +01:00
Implement rotating salt.
This commit is contained in:
parent
5cade59111
commit
c95d8e8a01
@ -2,9 +2,11 @@ import crypto from 'crypto';
|
||||
import { v4, v5, validate } from 'uuid';
|
||||
import bcrypt from 'bcrypt';
|
||||
import { JWT, JWE, JWK } from 'jose';
|
||||
import { startOfMonth } from 'date-fns';
|
||||
|
||||
const SALT_ROUNDS = 10;
|
||||
const KEY = JWK.asKey(Buffer.from(secret()));
|
||||
const ROTATING_SALT = hash(startOfMonth(new Date()).toUTCString());
|
||||
const CHARS = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
||||
|
||||
export function hash(...args) {
|
||||
@ -15,10 +17,14 @@ export function secret() {
|
||||
return hash(process.env.HASH_SALT);
|
||||
}
|
||||
|
||||
export function salt() {
|
||||
return v5([secret(), ROTATING_SALT].join(''), v5.DNS);
|
||||
}
|
||||
|
||||
export function uuid(...args) {
|
||||
if (!args.length) return v4();
|
||||
|
||||
return v5(args.join(''), v5.DNS);
|
||||
return v5(args.join(''), salt());
|
||||
}
|
||||
|
||||
export function isValidId(s) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "umami",
|
||||
"version": "0.11.0",
|
||||
"version": "0.12.0",
|
||||
"description": "A simple, fast, website analytics alternative to Google Analytics. ",
|
||||
"author": "Mike Cao <mike@mikecao.com>",
|
||||
"license": "MIT",
|
||||
|
Loading…
Reference in New Issue
Block a user