his

package
v0.13.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 1 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package his implements a lightweight, self-hosted "Human Interaction Signature": it scores aggregate client interaction signals to estimate the probability that a verification was automated.

This is GateCHA's open-source take on the Human Interaction Signature concept found in ALTCHA Sentinel. It deliberately consumes only privacy-preserving aggregates (counts, distances, durations, timing variance) — never raw coordinates, timestamps, or key contents — so it leaks nothing about what the user typed or where they pointed.

The score is advisory. In "Monitor" mode callers log it and move on; they never change a verification outcome based on it.

Index

Constants

View Source
const (
	// BotSuspectThreshold is the probability at/above which a sample is counted
	// as automation-suspected for Monitor statistics.
	BotSuspectThreshold = 0.8
)

Heuristic weights and thresholds. These are intentionally simple and transparent; Monitor mode exists precisely to calibrate them against real traffic before any enforcement is considered. Tuning here is expected.

Variables

This section is empty.

Functions

func IsBotSuspected

func IsBotSuspected(score float64) bool

IsBotSuspected reports whether the score meets the default suspect threshold.

func IsBotSuspectedAt

func IsBotSuspectedAt(score, threshold float64) bool

IsBotSuspectedAt reports whether the score meets a caller-chosen threshold.

Comparison is on scores already snapped to two decimals by Score, and the threshold arrives from configuration, so a value like 0.7 that has no exact binary representation must not decide the comparison by its last bit: a sample scoring exactly the threshold has to count as meeting it. The epsilon is far below the 0.01 granularity of the score ladder, so it can never pull in a neighbouring rung.

func Score

func Score(s Signals) float64

Score returns the estimated probability in [0,1] that the interaction described by s was automated. Higher means more bot-like. Missing signals (a zero value) lean bot-ward but never reach certainty on their own, since a missing collector is not proof of automation.

Types

type Signals

type Signals struct {
	// DurationMs is how long the interaction window was observed.
	DurationMs int `json:"duration_ms"`
	// TimeToFirstMs is the delay until the first interaction event; -1 if none.
	TimeToFirstMs int `json:"time_to_first_ms"`
	// PointerEvents counts sampled pointer/mouse move events.
	PointerEvents int `json:"pointer_events"`
	// PointerDistance is the total pointer path length in CSS pixels.
	PointerDistance float64 `json:"pointer_distance"`
	// Scrolls counts scroll events.
	Scrolls int `json:"scrolls"`
	// Touches counts touch events.
	Touches int `json:"touches"`
	// Keydowns counts key-down events (host forms only; 0 for a bare widget).
	Keydowns int `json:"keydowns"`
	// KeyIntervalStdevMs is the standard deviation of inter-keydown intervals;
	// genuine typing has natural jitter, scripted input tends toward 0.
	KeyIntervalStdevMs float64 `json:"key_interval_stdev_ms"`
}

Signals is the privacy-preserving aggregate of a single interaction window, produced by the client collector. All fields are optional; a zero value means "not observed". Negative sentinels (-1) distinguish "no interaction happened" from "happened at t=0" for the timing fields.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL