Fixed sync handshake

This commit is contained in:
2026-10-23 10:19:30 +02:00
parent 8f58e15f0f
commit 3316fc0275
8 changed files with 593 additions and 226 deletions
@@ -36,13 +36,20 @@ export function updateHasherSettings(salt?: string, minLength?: number | string)
}
}
function isAlreadyHashId(candidate: string): boolean {
if (typeof candidate !== 'string' || candidate.length < HASHER_SETTINGS.minHashLength) {
export function isAlreadyHashId(candidate: string): boolean {
if (
typeof candidate !== 'string' ||
candidate.length < HASHER_SETTINGS.minHashLength ||
/^\d+$/.test(candidate)
) {
return false;
}
try {
const decoded = hasher.decode(candidate);
return Array.isArray(decoded) && decoded.length > 0;
if (!Array.isArray(decoded) || decoded.length === 0) {
return false;
}
return hasher.encode(decoded as number[]) === candidate;
} catch {
return false;
}