fix: complete InvesteMoz validation and error corrections

This commit is contained in:
2026-10-29 21:47:33 +02:00
parent 63147312e2
commit daf8623441
718 changed files with 127308 additions and 20959 deletions
+8 -3
View File
@@ -1,13 +1,18 @@
/** UUID v4 for operation identifiers; retries keep the caller's existing key. */
export function createOperationKey(): string {
const secureRandom = globalThis.crypto;
if (typeof secureRandom?.randomUUID === 'function') return secureRandom.randomUUID();
if (typeof secureRandom?.randomUUID === 'function')
return secureRandom.randomUUID();
if (typeof secureRandom?.getRandomValues !== 'function') {
throw new Error('O navegador não disponibiliza geração criptográfica segura. Reabra o portal no endereço HTTPS configurado.');
throw new Error(
'O navegador não disponibiliza geração criptográfica segura. Reabra o portal no endereço HTTPS configurado.',
);
}
const bytes = secureRandom.getRandomValues(new Uint8Array(16));
bytes[6] = (bytes[6] & 0x0f) | 0x40;
bytes[8] = (bytes[8] & 0x3f) | 0x80;
const hex = Array.from(bytes, byte => byte.toString(16).padStart(2, '0')).join('');
const hex = Array.from(bytes, (byte) =>
byte.toString(16).padStart(2, '0'),
).join('');
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
}