Documentation
¶
Index ¶
- Constants
- func RegisterRegion(locale string, factory detectorFactory)
- func RegisterUniversal(factory detectorFactory)
- func SynthesizeValue(entityType, originalText string) string
- type APIError
- type AuthenticationError
- type BatchResponse
- type BlindfoldError
- type CallOption
- func WithCallPolicy(policy string) CallOption
- func WithCharsToShow(n int) CallOption
- func WithEntities(entities []string) CallOption
- func WithFromEnd(b bool) CallOption
- func WithHashLength(n int) CallOption
- func WithHashPrefix(p string) CallOption
- func WithHashType(t string) CallOption
- func WithLanguage(lang string) CallOption
- func WithMaskingChar(ch string) CallOption
- type Client
- func (c *Client) Detect(ctx context.Context, text string, opts ...CallOption) (*DetectResponse, error)
- func (c *Client) DetectBatch(ctx context.Context, texts []string, opts ...CallOption) (*BatchResponse[DetectResponse], error)
- func (c *Client) Detokenize(text string, mapping map[string]string) *DetokenizeResponse
- func (c *Client) Encrypt(ctx context.Context, text, encryptionKey string, opts ...CallOption) (*EncryptResponse, error)
- func (c *Client) Hash(ctx context.Context, text string, opts ...CallOption) (*HashResponse, error)
- func (c *Client) Mask(ctx context.Context, text string, opts ...CallOption) (*MaskResponse, error)
- func (c *Client) Redact(ctx context.Context, text string, opts ...CallOption) (*RedactResponse, error)
- func (c *Client) Synthesize(ctx context.Context, text string, opts ...CallOption) (*SynthesizeResponse, error)
- func (c *Client) Tokenize(ctx context.Context, text string, opts ...CallOption) (*TokenizeResponse, error)
- func (c *Client) TokenizeBatch(ctx context.Context, texts []string, opts ...CallOption) (*BatchResponse[TokenizeResponse], error)
- type DetectResponse
- type DetectedEntity
- type Detector
- type DetectorRegistry
- type DetokenizeResponse
- type EncryptResponse
- type HashResponse
- type MaskResponse
- type NetworkError
- type Option
- func WithAPIKey(key string) Option
- func WithBaseURL(url string) Option
- func WithHTTPClient(client *http.Client) Option
- func WithLocales(locales []string) Option
- func WithMaxRetries(n int) Option
- func WithMode(mode string) Option
- func WithPoliciesFile(path string) Option
- func WithPolicy(name string) Option
- func WithRegion(region string) Option
- func WithRetryDelay(d time.Duration) Option
- func WithTimeout(d time.Duration) Option
- func WithUserID(id string) Option
- type PIIMatch
- type PIIScanner
- func (s *PIIScanner) Detect(text string, entities []string) []PIIMatch
- func (s *PIIScanner) Detokenize(text string, mapping map[string]string) string
- func (s *PIIScanner) Encrypt(text, encryptionKey string, entities []string) (TextResult, error)
- func (s *PIIScanner) Hash(text, hashType, hashPrefix string, hashLength int, entities []string) TextResult
- func (s *PIIScanner) Mask(text string, charsToShow int, fromEnd bool, maskingChar string, ...) TextResult
- func (s *PIIScanner) Redact(text string, entities []string) TextResult
- func (s *PIIScanner) Synthesize(text, language string, entities []string) TextResult
- func (s *PIIScanner) Tokenize(text string, entities []string) TokenizeResult
- type RedactResponse
- type RegexDetector
- type RegexDetectorConfig
- type SynthesizeResponse
- type TextResult
- type TokenizeResponse
- type TokenizeResult
Constants ¶
const ( // Universal EntityEmailAddress = "Email Address" EntityCreditCard = "Credit Card Number" EntityPhoneNumber = "Phone Number" EntityIPAddress = "IP Address" EntityURL = "URL" EntityMACAddress = "MAC Address" EntityDateOfBirth = "Date of Birth" EntityCVV = "CVV" // US EntitySSN = "Social Security Number" EntityDriversLicense = "Driver's License" EntityUSPassport = "US Passport" EntityTaxID = "Tax ID" EntityZIPCode = "ZIP Code" EntityUSITIN = "US ITIN" // EU EntityIBAN = "IBAN" EntityPostalCode = "Postal Code" EntityVATID = "VAT ID" // UK EntityNINumber = "NI Number" EntityNHSNumber = "NHS Number" EntityUKPostcode = "UK Postcode" EntityUKPassport = "UK Passport" EntityUKUTR = "UK UTR" // Germany EntityDEPersonalID = "German Personal ID" EntityDETaxID = "German Tax ID" // France EntityFRNationalID = "French National ID" EntityFRSIREN = "French SIREN" // Spain EntityESDNI = "Spanish DNI" EntityESNIE = "Spanish NIE" EntityESNSS = "Spanish NSS" EntityESCIF = "Spanish CIF" // Italy EntityITCodiceFiscale = "Italian Codice Fiscale" EntityITPartitaIVA = "Italian Partita IVA" // Portugal EntityPTNIF = "Portuguese NIF" // Poland EntityPLPESEL = "Polish PESEL" EntityPLNIP = "Polish NIP" EntityPLREGON = "Polish REGON" // Czech Republic EntityCZBirthNumber = "Czech Birth Number" EntityCZICO = "Czech ICO" EntityCZDIC = "Czech DIC" EntityCZBankAccount = "Czech Bank Account" // Russia EntityRUINN = "Russian INN" EntityRUSNILS = "Russian SNILS" // Netherlands EntityNLBSN = "Dutch BSN" // Romania EntityROCNP = "Romanian CNP" EntityROCUI = "Romanian CUI" // Slovakia EntitySKBirthNumber = "Slovak Birth Number" EntitySKICO = "Slovak ICO" EntitySKDIC = "Slovak DIC" // Denmark EntityDKCPR = "Danish CPR" EntityDKCVR = "Danish CVR" // Sweden EntitySEPersonnummer = "Swedish Personnummer" EntitySEOrgnr = "Swedish Organisationsnummer" // Norway EntityNOBirthNumber = "Norwegian Birth Number" EntityNOOrgnr = "Norwegian Organisasjonsnummer" // Belgium EntityBENational = "Belgian National Number" EntityBEEnterprise = "Belgian Enterprise Number" // Austria EntityATSVNR = "Austrian SVNR" // Ireland EntityIEPPS = "Irish PPS Number" // Finland EntityFIHETU = "Finnish HETU" EntityFIYtunnus = "Finnish Y-tunnus" // Hungary EntityHUTaxID = "Hungarian Tax ID" EntityHUTAJ = "Hungarian TAJ" // Bulgaria EntityBGEGN = "Bulgarian EGN" // Croatia EntityHROIB = "Croatian OIB" // Slovenia EntitySIEMSO = "Slovenian EMSO" EntitySITaxNumber = "Slovenian Tax Number" // Lithuania EntityLTPersonalCode = "Lithuanian Personal Code" // Latvia EntityLVPersonalCode = "Latvian Personal Code" // Estonia EntityEEPersonalCode = "Estonian Personal Code" // Canada EntityCASIN = "Canadian SIN" // Switzerland EntityCHAHV = "Swiss AHV" // Australia EntityAUTFN = "Australian TFN" EntityAUMedicare = "Australian Medicare" // New Zealand EntityNZIRD = "New Zealand IRD" // India EntityINAadhaar = "Indian Aadhaar" EntityINPAN = "Indian PAN" // Japan EntityJPMyNumber = "Japanese My Number" // South Korea EntityKRRRN = "Korean RRN" // South Africa EntityZAID = "South African ID" // Turkey EntityTRKimlik = "Turkish Kimlik" // Israel EntityILID = "Israeli ID" // Argentina EntityARCUIT = "Argentine CUIT" // Chile EntityCLRUT = "Chilean RUT" // Colombia EntityCONIT = "Colombian NIT" // Brazil EntityBRCPF = "Brazilian CPF" EntityBRCNPJ = "Brazilian CNPJ" )
Entity type constants matching the API's Title Case format.
Variables ¶
This section is empty.
Functions ¶
func RegisterRegion ¶
func RegisterRegion(locale string, factory detectorFactory)
RegisterRegion registers a detector factory for a specific locale.
func RegisterUniversal ¶
func RegisterUniversal(factory detectorFactory)
RegisterUniversal registers a detector factory that applies to all locales.
func SynthesizeValue ¶
SynthesizeValue generates a fake replacement for the given entity type.
Types ¶
type APIError ¶
type APIError struct {
BlindfoldError
}
APIError indicates a non-retryable API error.
type AuthenticationError ¶
type AuthenticationError struct {
BlindfoldError
}
AuthenticationError indicates an invalid API key (401).
type BatchResponse ¶
type BatchResponse[T any] struct { Results []T `json:"results"` Total int `json:"total"` Succeeded int `json:"succeeded"` Failed int `json:"failed"` }
BatchResponse wraps batch results for any operation type.
type BlindfoldError ¶
BlindfoldError is the base error type for all SDK errors.
func (*BlindfoldError) Error ¶
func (e *BlindfoldError) Error() string
func (*BlindfoldError) Unwrap ¶
func (e *BlindfoldError) Unwrap() error
type CallOption ¶
type CallOption func(*callConfig)
CallOption configures a single method call.
func WithCallPolicy ¶
func WithCallPolicy(policy string) CallOption
WithCallPolicy sets the policy for this call.
func WithCharsToShow ¶
func WithCharsToShow(n int) CallOption
WithCharsToShow sets how many characters remain visible when masking.
func WithEntities ¶
func WithEntities(entities []string) CallOption
WithEntities filters detection to specific entity types.
func WithFromEnd ¶
func WithFromEnd(b bool) CallOption
WithFromEnd shows characters from the end when masking.
func WithHashLength ¶
func WithHashLength(n int) CallOption
WithHashLength sets the length of the hash output.
func WithHashPrefix ¶
func WithHashPrefix(p string) CallOption
WithHashPrefix sets the prefix for hashed replacements.
func WithHashType ¶
func WithHashType(t string) CallOption
WithHashType sets the hash algorithm (e.g., "SHA-256").
func WithLanguage ¶
func WithLanguage(lang string) CallOption
WithLanguage sets the language for synthesize.
func WithMaskingChar ¶
func WithMaskingChar(ch string) CallOption
WithMaskingChar sets the masking character.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the Blindfold PII detection client.
func (*Client) Detect ¶
func (c *Client) Detect(ctx context.Context, text string, opts ...CallOption) (*DetectResponse, error)
Detect finds PII entities in text.
func (*Client) DetectBatch ¶
func (c *Client) DetectBatch(ctx context.Context, texts []string, opts ...CallOption) (*BatchResponse[DetectResponse], error)
DetectBatch runs detect on multiple texts.
func (*Client) Detokenize ¶
func (c *Client) Detokenize(text string, mapping map[string]string) *DetokenizeResponse
Detokenize restores tokenized text using a mapping. This is client-side only.
func (*Client) Encrypt ¶
func (c *Client) Encrypt(ctx context.Context, text, encryptionKey string, opts ...CallOption) (*EncryptResponse, error)
Encrypt replaces PII with AES-encrypted values.
func (*Client) Hash ¶
func (c *Client) Hash(ctx context.Context, text string, opts ...CallOption) (*HashResponse, error)
Hash replaces PII with hash values.
func (*Client) Mask ¶
func (c *Client) Mask(ctx context.Context, text string, opts ...CallOption) (*MaskResponse, error)
Mask partially hides PII in text.
func (*Client) Redact ¶
func (c *Client) Redact(ctx context.Context, text string, opts ...CallOption) (*RedactResponse, error)
Redact removes PII from text.
func (*Client) Synthesize ¶
func (c *Client) Synthesize(ctx context.Context, text string, opts ...CallOption) (*SynthesizeResponse, error)
Synthesize replaces PII with realistic fake data.
func (*Client) Tokenize ¶
func (c *Client) Tokenize(ctx context.Context, text string, opts ...CallOption) (*TokenizeResponse, error)
Tokenize replaces PII with tokens and returns a mapping.
func (*Client) TokenizeBatch ¶
func (c *Client) TokenizeBatch(ctx context.Context, texts []string, opts ...CallOption) (*BatchResponse[TokenizeResponse], error)
TokenizeBatch runs tokenize on multiple texts.
type DetectResponse ¶
type DetectResponse struct {
DetectedEntities []DetectedEntity `json:"detected_entities"`
EntitiesCount int `json:"entities_count"`
}
DetectResponse is the result of a detect operation.
type DetectedEntity ¶
type DetectedEntity struct {
Type string `json:"type"`
Text string `json:"text"`
Start int `json:"start"`
End int `json:"end"`
Score float64 `json:"score"`
}
DetectedEntity represents a single PII entity found in text.
type Detector ¶
type Detector interface {
EntityType() string
NeedsDigit() bool
IterMatches(text, textLower string) []PIIMatch
}
Detector is the interface for all PII detectors.
type DetectorRegistry ¶
type DetectorRegistry struct {
// contains filtered or unexported fields
}
DetectorRegistry builds the detector list for given locales.
func NewDetectorRegistry ¶
func NewDetectorRegistry(locales []string) *DetectorRegistry
NewDetectorRegistry creates a registry with detectors for the given locales.
func (*DetectorRegistry) Detectors ¶
func (r *DetectorRegistry) Detectors() []Detector
Detectors returns all registered detectors.
type DetokenizeResponse ¶
type DetokenizeResponse struct {
Text string `json:"text"`
ReplacementsMade int `json:"replacements_made"`
}
DetokenizeResponse is the result of a detokenize operation.
type EncryptResponse ¶
type EncryptResponse struct {
Text string `json:"text"`
DetectedEntities []DetectedEntity `json:"detected_entities"`
EntitiesCount int `json:"entities_count"`
}
EncryptResponse is the result of an encrypt operation.
type HashResponse ¶
type HashResponse struct {
Text string `json:"text"`
DetectedEntities []DetectedEntity `json:"detected_entities"`
EntitiesCount int `json:"entities_count"`
}
HashResponse is the result of a hash operation.
type MaskResponse ¶
type MaskResponse struct {
Text string `json:"text"`
DetectedEntities []DetectedEntity `json:"detected_entities"`
EntitiesCount int `json:"entities_count"`
}
MaskResponse is the result of a mask operation.
type NetworkError ¶
type NetworkError struct {
BlindfoldError
}
NetworkError indicates a network-level failure.
type Option ¶
type Option func(*config)
Option configures the Client at construction time.
func WithAPIKey ¶
WithAPIKey sets the API key for authenticated requests.
func WithBaseURL ¶
WithBaseURL overrides the default API endpoint.
func WithHTTPClient ¶
WithHTTPClient provides a custom http.Client.
func WithLocales ¶
WithLocales sets the locale list for detector selection (e.g., "us", "eu", "uk").
func WithMaxRetries ¶
WithMaxRetries sets the maximum number of retry attempts.
func WithPoliciesFile ¶
WithPoliciesFile loads additional policies from a JSON file.
func WithRegion ¶
WithRegion sets the API region ("eu" or "us").
func WithRetryDelay ¶
WithRetryDelay sets the base delay between retries.
func WithTimeout ¶
WithTimeout sets the HTTP request timeout.
type PIIScanner ¶
type PIIScanner struct {
// contains filtered or unexported fields
}
PIIScanner performs local PII detection and transformation.
func NewPIIScanner ¶
func NewPIIScanner(locales []string) *PIIScanner
NewPIIScanner creates a scanner with detectors for the given locales.
func (*PIIScanner) Detect ¶
func (s *PIIScanner) Detect(text string, entities []string) []PIIMatch
Detect finds PII in text, optionally filtered to specific entities.
func (*PIIScanner) Detokenize ¶
func (s *PIIScanner) Detokenize(text string, mapping map[string]string) string
Detokenize restores tokenized text using a mapping.
func (*PIIScanner) Encrypt ¶
func (s *PIIScanner) Encrypt(text, encryptionKey string, entities []string) (TextResult, error)
Encrypt replaces PII with AES-CBC encrypted values.
func (*PIIScanner) Hash ¶
func (s *PIIScanner) Hash(text, hashType, hashPrefix string, hashLength int, entities []string) TextResult
Hash replaces PII with hash values.
func (*PIIScanner) Mask ¶
func (s *PIIScanner) Mask(text string, charsToShow int, fromEnd bool, maskingChar string, entities []string) TextResult
Mask partially hides PII in text.
func (*PIIScanner) Redact ¶
func (s *PIIScanner) Redact(text string, entities []string) TextResult
Redact removes PII from text.
func (*PIIScanner) Synthesize ¶
func (s *PIIScanner) Synthesize(text, language string, entities []string) TextResult
Synthesize replaces PII with realistic fake data.
func (*PIIScanner) Tokenize ¶
func (s *PIIScanner) Tokenize(text string, entities []string) TokenizeResult
Tokenize replaces PII with tokens like <Entity Type_1>.
type RedactResponse ¶
type RedactResponse struct {
Text string `json:"text"`
DetectedEntities []DetectedEntity `json:"detected_entities"`
EntitiesCount int `json:"entities_count"`
}
RedactResponse is the result of a redact operation.
type RegexDetector ¶
type RegexDetector struct {
// contains filtered or unexported fields
}
RegexDetector is a configurable regex-based detector.
func NewRegexDetector ¶
func NewRegexDetector(cfg RegexDetectorConfig) *RegexDetector
NewRegexDetector creates a RegexDetector from config.
func (*RegexDetector) EntityType ¶
func (d *RegexDetector) EntityType() string
func (*RegexDetector) IterMatches ¶
func (d *RegexDetector) IterMatches(text, textLower string) []PIIMatch
func (*RegexDetector) NeedsDigit ¶
func (d *RegexDetector) NeedsDigit() bool
type RegexDetectorConfig ¶
type RegexDetectorConfig struct {
EntityType string
Pattern *regexp.Regexp
Score float64
BaseScore *float64
NeedsDigit bool
ContextRequired bool
ContextKeywords []string
ContextWindow int
Validator func(string) bool
PreCheck func(string) bool
}
RegexDetectorConfig holds configuration for building a RegexDetector.
type SynthesizeResponse ¶
type SynthesizeResponse struct {
Text string `json:"text"`
DetectedEntities []DetectedEntity `json:"detected_entities"`
EntitiesCount int `json:"entities_count"`
}
SynthesizeResponse is the result of a synthesize operation.
type TextResult ¶
TextResult holds results with transformed text.
type TokenizeResponse ¶
type TokenizeResponse struct {
Text string `json:"text"`
Mapping map[string]string `json:"mapping"`
DetectedEntities []DetectedEntity `json:"detected_entities"`
EntitiesCount int `json:"entities_count"`
}
TokenizeResponse is the result of a tokenize operation.
Source Files
¶
- blindfold.go
- detectors.go
- detectors_americas.go
- detectors_asia_pacific.go
- detectors_baltics.go
- detectors_benelux.go
- detectors_ch.go
- detectors_de.go
- detectors_eastern_europe.go
- detectors_es.go
- detectors_eu.go
- detectors_fr.go
- detectors_ie.go
- detectors_it.go
- detectors_nordics.go
- detectors_pt.go
- detectors_ru.go
- detectors_uk.go
- detectors_universal.go
- detectors_us.go
- entity_types.go
- errors.go
- http.go
- models.go
- options.go
- policies.go
- registry.go
- scanner.go
- synthesizers.go
- validators.go