mirror of
https://github.com/umami-software/umami.git
synced 2025-12-06 01:18:00 +01:00
add support for UUID v7
This commit is contained in:
parent
aaa1f9dc58
commit
4d70c3baf1
1 changed files with 5 additions and 3 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
import crypto from 'crypto';
|
import crypto from 'crypto';
|
||||||
import { v4, v5 } from 'uuid';
|
import { v4, v5, v7 } from 'uuid';
|
||||||
|
|
||||||
const ALGORITHM = 'aes-256-gcm';
|
const ALGORITHM = 'aes-256-gcm';
|
||||||
const IV_LENGTH = 16;
|
const IV_LENGTH = 16;
|
||||||
|
|
@ -57,7 +57,9 @@ export function secret() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function uuid(...args: any) {
|
export function uuid(...args: any) {
|
||||||
if (!args.length) return v4();
|
if (args.length) {
|
||||||
|
return v5(hash(...args, secret()), v5.DNS);
|
||||||
|
}
|
||||||
|
|
||||||
return v5(hash(...args, secret()), v5.DNS);
|
return process.env.USE_UUIDV7 ? v7() : v4();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue