dto

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package dto provides data transfer objects for HTTP request and response handling.

Package dto provides data transfer objects for HTTP request and response handling.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseAlgorithm

func ParseAlgorithm(alg string) (cryptoDomain.Algorithm, error)

ParseAlgorithm converts a string to a cryptoDomain.Algorithm. Returns an error if the algorithm is not supported.

func ParseFormatType

func ParseFormatType(formatType string) (tokenizationDomain.FormatType, error)

ParseFormatType converts a string to a tokenizationDomain.FormatType. Returns an error if the format type is not supported.

Types

type CreateTokenizationKeyRequest

type CreateTokenizationKeyRequest struct {
	Name            string `json:"name"`
	FormatType      string `json:"format_type"`      // "uuid", "numeric", "luhn-preserving", "alphanumeric"
	IsDeterministic bool   `json:"is_deterministic"` // If true, same value produces same token
	Algorithm       string `json:"algorithm"`        // "aes-gcm" or "chacha20-poly1305"
}

CreateTokenizationKeyRequest contains the parameters for creating a new tokenization key.

func (*CreateTokenizationKeyRequest) Validate

func (r *CreateTokenizationKeyRequest) Validate() error

Validate checks if the create tokenization key request is valid.

type DetokenizeBatchRequest added in v0.28.0

type DetokenizeBatchRequest struct {
	Tokens []string `json:"tokens"`
}

DetokenizeBatchRequest contains the parameters for detokenizing multiple values.

func (*DetokenizeBatchRequest) Validate added in v0.28.0

func (r *DetokenizeBatchRequest) Validate(limit int) error

Validate checks if the detokenize batch request is valid.

type DetokenizeBatchResponse added in v0.28.0

type DetokenizeBatchResponse struct {
	Items []DetokenizeResponse `json:"items"`
}

DetokenizeBatchResponse represents the result of detokenizing multiple tokens.

func MapPlaintextsToDetokenizeBatchResponse added in v0.28.0

func MapPlaintextsToDetokenizeBatchResponse(
	plaintexts []string,
	metadatas []map[string]any,
) DetokenizeBatchResponse

MapPlaintextsToDetokenizeBatchResponse converts multiple plaintexts and metadatas to a detokenize batch API response.

type DetokenizeRequest

type DetokenizeRequest struct {
	Token string `json:"token"`
}

DetokenizeRequest contains the parameters for detokenizing a value.

func (*DetokenizeRequest) Validate

func (r *DetokenizeRequest) Validate() error

Validate checks if the detokenize request is valid.

type DetokenizeResponse

type DetokenizeResponse struct {
	Plaintext string         `json:"plaintext"` // Base64-encoded plaintext
	Metadata  map[string]any `json:"metadata,omitempty"`
}

DetokenizeResponse represents the result of detokenizing a token.

type ListTokenizationKeysResponse added in v0.16.0

type ListTokenizationKeysResponse struct {
	Data       []TokenizationKeyResponse `json:"data"`
	NextCursor *string                   `json:"next_cursor,omitempty"`
}

ListTokenizationKeysResponse represents the response for listing tokenization keys.

func MapTokenizationKeysToListResponse added in v0.16.0

func MapTokenizationKeysToListResponse(
	keys []*tokenizationDomain.TokenizationKey,
	nextCursor *string,
) ListTokenizationKeysResponse

MapTokenizationKeysToListResponse maps a slice of TokenizationKey domain entities to a ListTokenizationKeysResponse DTO. Returns an empty list instead of null when there are no items to match API conventions.

type RevokeTokenRequest

type RevokeTokenRequest struct {
	Token string `json:"token"`
}

RevokeTokenRequest contains the parameters for revoking a token.

func (*RevokeTokenRequest) Validate

func (r *RevokeTokenRequest) Validate() error

Validate checks if the revoke token request is valid.

type RotateTokenizationKeyRequest

type RotateTokenizationKeyRequest struct {
	FormatType      string `json:"format_type"`      // "uuid", "numeric", "luhn-preserving", "alphanumeric"
	IsDeterministic bool   `json:"is_deterministic"` // If true, same value produces same token
	Algorithm       string `json:"algorithm"`        // "aes-gcm" or "chacha20-poly1305"
}

RotateTokenizationKeyRequest contains the parameters for rotating a tokenization key.

func (*RotateTokenizationKeyRequest) Validate

func (r *RotateTokenizationKeyRequest) Validate() error

Validate checks if the rotate tokenization key request is valid.

type TokenizationKeyResponse

type TokenizationKeyResponse struct {
	ID              string    `json:"id"`
	Name            string    `json:"name"`
	Version         uint      `json:"version"`
	FormatType      string    `json:"format_type"`
	IsDeterministic bool      `json:"is_deterministic"`
	DekID           string    `json:"dek_id"`
	CreatedAt       time.Time `json:"created_at"`
}

TokenizationKeyResponse represents a tokenization key in API responses.

func MapTokenizationKeyToResponse

func MapTokenizationKeyToResponse(key *tokenizationDomain.TokenizationKey) TokenizationKeyResponse

MapTokenizationKeyToResponse converts a domain tokenization key to an API response.

type TokenizeBatchRequest added in v0.28.0

type TokenizeBatchRequest struct {
	Items []TokenizeRequest `json:"items"`
}

TokenizeBatchRequest contains the parameters for tokenizing multiple values.

func (*TokenizeBatchRequest) Validate added in v0.28.0

func (r *TokenizeBatchRequest) Validate(limit int) error

Validate checks if the tokenize batch request is valid.

type TokenizeBatchResponse added in v0.28.0

type TokenizeBatchResponse struct {
	Items []TokenizeResponse `json:"items"`
}

TokenizeBatchResponse represents the result of tokenizing multiple values.

func MapTokensToTokenizeBatchResponse added in v0.28.0

func MapTokensToTokenizeBatchResponse(tokens []*tokenizationDomain.Token) TokenizeBatchResponse

MapTokensToTokenizeBatchResponse converts multiple domain tokens to a tokenize batch API response.

type TokenizeRequest

type TokenizeRequest struct {
	Plaintext string         `json:"plaintext"` // Base64-encoded plaintext
	Metadata  map[string]any `json:"metadata,omitempty"`
	TTL       *int           `json:"ttl,omitempty"` // Time-to-live in seconds (optional)
}

TokenizeRequest contains the parameters for tokenizing a value.

func (*TokenizeRequest) Validate

func (r *TokenizeRequest) Validate() error

Validate checks if the tokenize request is valid.

type TokenizeResponse

type TokenizeResponse struct {
	Token     string         `json:"token"`
	Metadata  map[string]any `json:"metadata,omitempty"`
	CreatedAt time.Time      `json:"created_at"`
	ExpiresAt *time.Time     `json:"expires_at,omitempty"`
}

TokenizeResponse represents the result of tokenizing a value.

func MapTokenToTokenizeResponse

func MapTokenToTokenizeResponse(token *tokenizationDomain.Token) TokenizeResponse

MapTokenToTokenizeResponse converts a domain token to a tokenize API response.

type ValidateTokenRequest

type ValidateTokenRequest struct {
	Token string `json:"token"`
}

ValidateTokenRequest contains the parameters for validating a token.

func (*ValidateTokenRequest) Validate

func (r *ValidateTokenRequest) Validate() error

Validate checks if the validate token request is valid.

type ValidateTokenResponse

type ValidateTokenResponse struct {
	Valid bool `json:"valid"`
}

ValidateTokenResponse represents the result of validating a token.

Jump to

Keyboard shortcuts

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