credential

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 7 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 credential is Daisybell's one credential detector (SPEC invariant 7, docs/work/04). It says whether a form field holds a secret the human must type (passwords, one-time codes, card numbers and security codes) and whether its value must never be shown back to the AI (those, plus private data such as a CPF or an IBAN). The rules are data (rules.json): the guard, the recording mask, the outline and screenshot redaction use them here, and the Cockpit extension reads the same rules from a generated TypeScript module (see ts.go).

Index

Constants

View Source
const TSPath = "extension/src/shared/credential-rules.gen.ts"

TSPath is where the extension's copy of the rules lives, relative to the repository root.

Variables

This section is empty.

Functions

func Fold

func Fold(s string) string

Fold lowercases s, strips the accents of Latin letters and collapses whitespace, so keyword lists can be written once without diacritics ("excluir", "contrasena", "codigo").

func Pattern

func Pattern(phrases []string) string

Pattern is the regular expression matching any of the phrases as whole words. The same source compiles in Go (RE2) and in JavaScript with the u flag: the extension uses it as is.

func Sensitive

func Sensitive(f Field) bool

Sensitive says whether the value of a field must never be shown back to the AI: a credential (Of) or private data (a CPF, an IBAN, any card detail, a transaction code).

func TSModule

func TSModule() string

TSModule is the TypeScript module the Cockpit extension imports (TSPath): the same rules, with each kind's phrases already joined into the pattern Go compiles (Pattern), so both sides match with the very same regular expressions. TestTSModuleIsGenerated fails when the file is stale; `go test ./internal/credential -run TestTSModuleIsGenerated -update` rewrites it.

func Words

func Words(s string) string

Words separates identifier words ("cardNumber", "card-number", "card_number" → "card number") and folds the result.

Types

type Field

type Field struct {
	Tag          string `json:"tag,omitempty"` // INPUT, TEXTAREA, SELECT, or "" for contenteditable
	Type         string `json:"type,omitempty"`
	Autocomplete string `json:"autocomplete,omitempty"`
	Name         string `json:"name,omitempty"`
	ID           string `json:"id,omitempty"`
	Label        string `json:"label,omitempty"` // accessible name / label text
	Placeholder  string `json:"placeholder,omitempty"`
	InputMode    string `json:"inputmode,omitempty"`
	MaxLength    int    `json:"maxlength,omitempty"`
	// Filled reports whether the field currently has a value (the value itself is never read).
	Filled bool `json:"filled,omitempty"`
	// Masked is set when CSS hides what is typed (-webkit-text-security): a password in disguise.
	Masked bool `json:"masked,omitempty"`
	// Segments counts the one-character inputs in the field's group (a code split into boxes).
	Segments int `json:"segments,omitempty"`
}

Field describes a form field (from the page, never its value).

type Kind

type Kind string

Kind is the kind of secret a field holds.

const (
	None     Kind = ""
	Password Kind = "password"
	OTP      Kind = "otp"       // one-time / 2FA / verification code
	Card     Kind = "card"      // card number
	CSC      Kind = "card_code" // CVV / CVC / security code
)

func Of

func Of(f Field) Kind

Of says whether a field holds a secret the human must type: passwords (type or autocomplete), one-time codes, card numbers and card security codes. It looks at the type and autocomplete first, then at the name, id, label and placeholder.

type KindRule

type KindRule struct {
	Kind    Kind     `json:"kind"`
	Phrases []string `json:"phrases"`
	Unless  []string `json:"unless,omitempty"`
}

KindRule is one kind recognised by name, id, label or placeholder.

type Rules

type Rules struct {
	Autocomplete map[string]Kind `json:"autocomplete"`
	TextTypes    []string        `json:"textTypes"`
	Kinds        []KindRule      `json:"kinds"`
	Private      struct {
		AutocompletePrefixes []string `json:"autocompletePrefixes"`
		Phrases              []string `json:"phrases"`
	} `json:"private"`
	Accents map[string]string `json:"accents"`
}

Rules is the parsed rule data (rules.json).

Jump to

Keyboard shortcuts

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