Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

add support for UUID v7

Indra Gunawan4d70c3baf1e4
diff --git a/src/lib/crypto.ts b/src/lib/crypto.ts
index f9387460b..f6b0248ea 100644
--- a/src/lib/crypto.ts
+++ b/src/lib/crypto.ts
@@ -1,5 +1,5 @@
import crypto from 'crypto';
-import { v4, v5 } from 'uuid';
+import { v4, v5, v7 } from 'uuid';
const ALGORITHM = 'aes-256-gcm';
const IV_LENGTH = 16;
@@ -57,7 +57,9 @@ export function secret() {
}
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();
}