MCPcopy Create free account
hub / github.com/Forward-Future/loopy / makeIdempotencyKey

Function makeIdempotencyKey

loop-library/site/script.js:1012–1041  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1010 "Spam protection is still loading. Wait a moment and try again.",
1011 setStatus: setWeeklyStatus,
1012 statusElement: weeklyStatus,
1013 token: "",
1014 },
1015};
1016
1017function 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(""),

Callers 1

script.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected