Skip to content

Stealth Chromium that passes every bot detection test. Drop-in Playwright replacement with source-level fingerprint patches. 50+ tests passed.

fix(humanize): keep digit mistypes on digits (#573)

CloakHQ0739ca53242d
diff --git a/cloakbrowser/human/keyboard.py b/cloakbrowser/human/keyboard.py
index 5481f54..ea0991f 100644
--- a/cloakbrowser/human/keyboard.py
+++ b/cloakbrowser/human/keyboard.py
@@ -29,8 +29,10 @@ NEARBY_KEYS = {
'p': 'ol', 'q': 'wa', 'r': 'edft', 's': 'awedxz', 't': 'rfgy',
'u': 'yhji', 'v': 'cfgb', 'w': 'qase', 'x': 'zsdc', 'y': 'tghu',
'z': 'asx',
- '1': '2q', '2': '13qw', '3': '24we', '4': '35er', '5': '46rt',
- '6': '57ty', '7': '68yu', '8': '79ui', '9': '80io', '0': '9p',
+ # Digits stay digits: a letter typo is rejected by <input type=number>,
+ # so the correcting Backspace would delete the previous real digit (#573).
+ '1': '2', '2': '13', '3': '24', '4': '35', '5': '46',
+ '6': '57', '7': '68', '8': '79', '9': '80', '0': '9',
}
# CDP key code for each shift symbol's physical key.
diff --git a/dotnet/src/CloakBrowser/Human/HumanKeyboard.cs b/dotnet/src/CloakBrowser/Human/HumanKeyboard.cs
index 106408e..a19796d 100644
--- a/dotnet/src/CloakBrowser/Human/HumanKeyboard.cs
+++ b/dotnet/src/CloakBrowser/Human/HumanKeyboard.cs
@@ -61,8 +61,10 @@ public static class HumanKeyboard
['p'] = "ol", ['q'] = "wa", ['r'] = "edft", ['s'] = "awedxz", ['t'] = "rfgy",
['u'] = "yhji", ['v'] = "cfgb", ['w'] = "qase", ['x'] = "zsdc", ['y'] = "tghu",
['z'] = "asx",
- ['1'] = "2q", ['2'] = "13qw", ['3'] = "24we", ['4'] = "35er", ['5'] = "46rt",
- ['6'] = "57ty", ['7'] = "68yu", ['8'] = "79ui", ['9'] = "80io", ['0'] = "9p",
+ // Digits stay digits: a letter typo is rejected by <input type=number>,
+ // so the correcting Backspace would delete the previous real digit (#573).
+ ['1'] = "2", ['2'] = "13", ['3'] = "24", ['4'] = "35", ['5'] = "46",
+ ['6'] = "57", ['7'] = "68", ['8'] = "79", ['9'] = "80", ['0'] = "9",
};
/// <summary>CDP key <c>code</c> for each shift symbol's physical key.</summary>
diff --git a/dotnet/tests/CloakBrowser.Tests/MiscTests.cs b/dotnet/tests/CloakBrowser.Tests/MiscTests.cs
index d663cd0..fc55a06 100644
--- a/dotnet/tests/CloakBrowser.Tests/MiscTests.cs
+++ b/dotnet/tests/CloakBrowser.Tests/MiscTests.cs
@@ -164,6 +164,15 @@ public class KeyboardTests
Assert.Equal("sqwz", HumanKeyboard.NearbyKeys['a']);
Assert.Equal("ol", HumanKeyboard.NearbyKeys['p']);
}
+
+ [Fact]
+ public void NearbyKeys_DigitNeighborsAreDigits()
+ {
+ // #573: a letter typo is rejected by <input type=number>, so the
+ // correcting Backspace would delete the previous real digit.
+ foreach (char d in "0123456789")
+ Assert.True(HumanKeyboard.NearbyKeys[d].All(char.IsDigit), $"'{d}' -> {HumanKeyboard.NearbyKeys[d]}");
+ }
}
public class ActionabilityTests
diff --git a/js/src/human-puppeteer/keyboard.ts b/js/src/human-puppeteer/keyboard.ts
index 5708ffb..e74ce8a 100644
--- a/js/src/human-puppeteer/keyboard.ts
+++ b/js/src/human-puppeteer/keyboard.ts
@@ -27,8 +27,10 @@ const NEARBY_KEYS: Record<string, string> = {
p: 'ol', q: 'wa', r: 'edft', s: 'awedxz', t: 'rfgy',
u: 'yhji', v: 'cfgb', w: 'qase', x: 'zsdc', y: 'tghu',
z: 'asx',
- '1': '2q', '2': '13qw', '3': '24we', '4': '35er', '5': '46rt',
- '6': '57ty', '7': '68yu', '8': '79ui', '9': '80io', '0': '9p',
+ // Digits stay digits: a letter typo is rejected by <input type=number>,
+ // so the correcting Backspace would delete the previous real digit (#573).
+ '1': '2', '2': '13', '3': '24', '4': '35', '5': '46',
+ '6': '57', '7': '68', '8': '79', '9': '80', '0': '9',
};
const SHIFT_SYMBOL_CODES: Record<string, string> = {
diff --git a/js/src/human/keyboard.ts b/js/src/human/keyboard.ts
index 19924e6..5773486 100644
--- a/js/src/human/keyboard.ts
+++ b/js/src/human/keyboard.ts
@@ -36,8 +36,10 @@ const NEARBY_KEYS: Record<string, string> = {
p: 'ol', q: 'wa', r: 'edft', s: 'awedxz', t: 'rfgy',
u: 'yhji', v: 'cfgb', w: 'qase', x: 'zsdc', y: 'tghu',
z: 'asx',
- '1': '2q', '2': '13qw', '3': '24we', '4': '35er', '5': '46rt',
- '6': '57ty', '7': '68yu', '8': '79ui', '9': '80io', '0': '9p',
+ // Digits stay digits: a letter typo is rejected by <input type=number>,
+ // so the correcting Backspace would delete the previous real digit (#573).
+ '1': '2', '2': '13', '3': '24', '4': '35', '5': '46',
+ '6': '57', '7': '68', '8': '79', '9': '80', '0': '9',
};
/**
diff --git a/js/tests/stealth.test.ts b/js/tests/stealth.test.ts
index a159533..ac577bb 100644
--- a/js/tests/stealth.test.ts
+++ b/js/tests/stealth.test.ts
@@ -16,6 +16,7 @@
import { describe, it, expect, vi, beforeEach } from "vitest";
import { resolveConfig, rand, randRange, sleep } from "../src/human/config.js";
import { humanType } from "../src/human/keyboard.js";
+import { humanType as puppeteerHumanType } from "../src/human-puppeteer/keyboard.js";
import { humanMove, humanClick, clickTarget, humanIdle } from "../src/human/mouse.js";
// =========================================================================
@@ -140,6 +141,28 @@ function buildRawKeyboard() {
}
+// =========================================================================
+// Mistype on digits (#573): a letter typo is rejected by <input type=number>,
+// so the correcting Backspace would eat the previous real digit.
+// =========================================================================
+describe("digit mistypes stay digits", () => {
+ it.each([
+ ["playwright", humanType],
+ ["puppeteer", puppeteerHumanType],
+ ])("%s humanType only types digits for numeric text", async (_name, typeFn) => {
+ const cfg = resolveConfig("default", {
+ mistype_chance: 1, typing_delay: 0, typing_delay_spread: 0, typing_pause_chance: 0,
+ key_hold: [0, 0], mistype_delay_notice: [0, 0], mistype_delay_correct: [0, 0],
+ });
+ for (let i = 0; i < 20; i++) {
+ const { raw, downKeys } = buildRawKeyboard();
+ await (typeFn as any)(buildMockPage(), raw, "0123456789", cfg, null);
+ expect(downKeys.filter((k) => k !== "Backspace").every((k) => /^[0-9]$/.test(k))).toBe(true);
+ }
+ });
+});
+
+
// =========================================================================
// SHIFT_SYMBOL_CODES / SHIFT_SYMBOL_KEYCODES completeness
// =========================================================================
diff --git a/tests/test_humanize_unit.py b/tests/test_humanize_unit.py
index 2a5354f..55e0b28 100644
--- a/tests/test_humanize_unit.py
+++ b/tests/test_humanize_unit.py
@@ -887,6 +887,13 @@ class TestMistypeConfig:
careful = resolve_config("careful")
assert careful.mistype_chance >= default.mistype_chance
+ def test_digit_neighbors_are_digits(self):
+ # #573: a letter typo is rejected by <input type=number>, so the
+ # correcting Backspace would delete the previous real digit.
+ from cloakbrowser.human.keyboard import NEARBY_KEYS
+ for d in "0123456789":
+ assert NEARBY_KEYS[d].isdigit(), (d, NEARBY_KEYS[d])
+
# =========================================================================
# 10. Select-all platform detection