Add deterministic UUID generation for achievements
cgen-7e9fd578e56d4a5dbec8fce5ec8f4c92
This commit is contained in:
parent
c85d75d09d
commit
b304238c3f
1 changed files with 12 additions and 0 deletions
|
|
@ -1,7 +1,19 @@
|
|||
import type { VercelRequest, VercelResponse } from "@vercel/node";
|
||||
import { randomUUID } from "crypto";
|
||||
import { createHash } from "crypto";
|
||||
import { getAdminClient } from "../../api/_supabase";
|
||||
|
||||
const generateDeterministicUUID = (str: string): string => {
|
||||
const hash = createHash("sha256").update(str).digest("hex");
|
||||
return [
|
||||
hash.slice(0, 8),
|
||||
hash.slice(8, 12),
|
||||
"5" + hash.slice(13, 16),
|
||||
((parseInt(hash.slice(16, 18), 16) & 0x3f) | 0x80).toString(16).padStart(2, "0") + hash.slice(18, 20),
|
||||
hash.slice(20, 32),
|
||||
].join("-");
|
||||
};
|
||||
|
||||
const CORE_ACHIEVEMENTS = [
|
||||
{
|
||||
id: "welcome-to-aethex",
|
||||
|
|
|
|||
Loading…
Reference in a new issue