Documentation
¶
Index ¶
Constants ¶
const ( DefaultTokensStore = ".data/tokensList.json" DefaultChallengeCount = 50 DefaultChallengeSize = 32 DefaultChallengeDifficulty = 4 DefaultExpiresMs = 600000 // 10 minutes DefaultTokenExpiresMs = 1200000 // 20 minutes )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cap ¶
type Cap struct {
// contains filtered or unexported fields
}
Cap represents the main Cap instance
func (*Cap) CreateChallenge ¶
func (c *Cap) CreateChallenge(conf *ChallengeConfig) (*ChallengeResponse, error)
CreateChallenge generates a new challenge with the specified configuration
func (*Cap) RedeemChallenge ¶
func (c *Cap) RedeemChallenge(solution *Solution) (*RedeemResponse, error)
RedeemChallenge validates a challenge solution and returns a verification token
func (*Cap) ValidateToken ¶
func (c *Cap) ValidateToken(token string, conf *TokenConfig) (*ValidationResponse, error)
ValidateToken validates a verification token
type CapConfig ¶
type CapConfig struct {
TokensStorePath string `json:"tokensStorePath,omitempty"` // Path to store tokens file
State *ChallengeState `json:"state,omitempty"` // State configuration
NoFSState bool `json:"noFSState,omitempty"` // Whether to disable file-based state storage
}
CapConfig contains the main configuration for the Cap instance
type ChallengeConfig ¶
type ChallengeConfig struct {
ChallengeCount int `json:"challengeCount,omitempty"` // Number of challenges to generate (default: 50)
ChallengeSize int `json:"challengeSize,omitempty"` // Size of each challenge in bytes (default: 32)
ChallengeDifficulty int `json:"challengeDifficulty,omitempty"` // Difficulty level (default: 4)
ExpiresMs int `json:"expiresMs,omitempty"` // Expiration time in milliseconds (default: 600000)
Store bool `json:"store,omitempty"` // Whether to store the challenge in memory (default: true)
}
ChallengeConfig contains configuration options for challenge generation
type ChallengeData ¶
type ChallengeData struct {
Challenge []ChallengeTuple `json:"challenge"`
Expires int64 `json:"expires"`
Token string `json:"token"`
}
ChallengeData contains the complete challenge information
type ChallengeResponse ¶
type ChallengeResponse struct {
Challenge []ChallengeTuple `json:"challenge"`
Token string `json:"token,omitempty"`
Expires int64 `json:"expires"`
}
ChallengeResponse represents the response from CreateChallenge
type ChallengeState ¶
type ChallengeState struct {
ChallengesList map[string]*ChallengeData `json:"challengesList"`
TokensList map[string]int64 `json:"tokensList"`
}
ChallengeState represents the internal state of challenges and tokens
type ChallengeTuple ¶
type ChallengeTuple [2]string
ChallengeTuple represents a single challenge consisting of salt and target
type RedeemResponse ¶
type RedeemResponse struct {
Success bool `json:"success"`
Message string `json:"message,omitempty"`
Token string `json:"token,omitempty"`
Expires int64 `json:"expires,omitempty"`
}
RedeemResponse represents the response from RedeemChallenge
type Solution ¶
type Solution struct {
Token string `json:"token"`
Solutions [][]interface{} `json:"solutions"` // Array of [salt, target, solution] tuples
}
Solution represents a solution to a challenge
type TokenConfig ¶
type TokenConfig struct {
KeepToken bool `json:"keepToken,omitempty"` // Whether to keep the token after validation
}
TokenConfig contains configuration options for token validation
type ValidationResponse ¶
type ValidationResponse struct {
Success bool `json:"success"`
}
ValidationResponse represents the response from ValidateToken
