| 1010 | "Spam protection is still loading. Wait a moment and try again.", |
| 1011 | setStatus: setWeeklyStatus, |
| 1012 | statusElement: weeklyStatus, |
| 1013 | token: "", |
| 1014 | }, |
| 1015 | }; |
| 1016 | |
| 1017 | function makeIdempotencyKey() { |
| 1018 | if (window.crypto && typeof window.crypto.randomUUID === "function") { |
| 1019 | return window.crypto.randomUUID(); |
| 1020 | } |
| 1021 | |
| 1022 | const bytes = new Uint8Array(16); |
| 1023 | |
| 1024 | if (window.crypto && typeof window.crypto.getRandomValues === "function") { |
| 1025 | window.crypto.getRandomValues(bytes); |
| 1026 | } else { |
| 1027 | for (let index = 0; index < bytes.length; index += 1) { |
| 1028 | bytes[index] = Math.floor(Math.random() * 256); |
| 1029 | } |
| 1030 | } |
| 1031 | |
| 1032 | bytes[6] = (bytes[6] & 0x0f) | 0x40; |
| 1033 | bytes[8] = (bytes[8] & 0x3f) | 0x80; |
| 1034 | |
| 1035 | const hex = [...bytes].map((byte) => |
| 1036 | byte.toString(16).padStart(2, "0"), |
| 1037 | ); |
| 1038 | |
| 1039 | return [ |
| 1040 | hex.slice(0, 4).join(""), |
| 1041 | hex.slice(4, 6).join(""), |
| 1042 | hex.slice(6, 8).join(""), |
| 1043 | hex.slice(8, 10).join(""), |
| 1044 | hex.slice(10).join(""), |