Documentation
¶
Overview ¶
Package domain defines core tokenization domain models for data tokenization. Supports multiple token formats (UUID, Numeric, Luhn-preserving, Alphanumeric) with configurable deterministic behavior.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrTokenizationKeyNotFound indicates the tokenization key was not found. ErrTokenizationKeyNotFound = errors.Wrap(errors.ErrNotFound, "tokenization key not found") // ErrTokenizationKeyAlreadyExists indicates a tokenization key with the same name and version already exists. ErrTokenizationKeyAlreadyExists = errors.Wrap(errors.ErrConflict, "tokenization key already exists") // ErrTokenNotFound indicates the token was not found. ErrTokenNotFound = errors.Wrap(errors.ErrNotFound, "token not found") // ErrTokenExpired indicates the token has expired. ErrTokenExpired = errors.Wrap(errors.ErrInvalidInput, "token has expired") // ErrTokenRevoked indicates the token has been revoked. ErrTokenRevoked = errors.Wrap(errors.ErrInvalidInput, "token has been revoked") // ErrInvalidFormatType indicates an invalid token format type was provided. ErrInvalidFormatType = errors.Wrap(errors.ErrInvalidInput, "invalid format type") // ErrInvalidTokenLength indicates the token length is invalid for the specified format. ErrInvalidTokenLength = errors.Wrap(errors.ErrInvalidInput, "invalid token length for format") // ErrValueTooLong indicates the value exceeds the maximum allowed length. ErrValueTooLong = errors.Wrap(errors.ErrInvalidInput, "value exceeds maximum length") )
Functions ¶
This section is empty.
Types ¶
type FormatType ¶
type FormatType string
FormatType defines the token format type.
const ( FormatUUID FormatType = "uuid" FormatNumeric FormatType = "numeric" FormatLuhnPreserving FormatType = "luhn-preserving" FormatAlphanumeric FormatType = "alphanumeric" )
func (FormatType) String ¶
func (f FormatType) String() string
String returns the string representation of the format type.
func (FormatType) Validate ¶
func (f FormatType) Validate() error
Validate checks if the format type is valid.
type Token ¶
type Token struct {
ID uuid.UUID
TokenizationKeyID uuid.UUID
Token string
ValueHash *string
Ciphertext []byte
Nonce []byte
Metadata map[string]any
CreatedAt time.Time
ExpiresAt *time.Time
RevokedAt *time.Time
}
Token represents a tokenization mapping between a token and its encrypted original value. Supports optional expiration, revocation, and metadata for display purposes.
type TokenizationKey ¶
type TokenizationKey struct {
ID uuid.UUID
Name string
Version uint
FormatType FormatType
IsDeterministic bool
DekID uuid.UUID
CreatedAt time.Time
DeletedAt *time.Time
}
TokenizationKey represents a versioned tokenization key configuration. Each key defines the token format and deterministic behavior for tokenization operations.