hackattic

package
v0.0.0-...-ea9887a Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attempt

type Attempt struct {
	Cfg           *config.Config
	Challenge     *Challenge
	PresenceToken string
	Result        *Result
}

type AttemptBuilder

type AttemptBuilder struct {
	Cfg           *config.Config
	Challenge     *Challenge
	Errors        []error
	PresenceToken string
	Result        *Result
}

func NewAttempt

func NewAttempt(cfg *config.Config) *AttemptBuilder

func (*AttemptBuilder) Build

func (b *AttemptBuilder) Build() (*Attempt, []error)

func (*AttemptBuilder) WithChallenge

func (b *AttemptBuilder) WithChallenge(challenge *Challenge) *AttemptBuilder

func (*AttemptBuilder) WithNewPresenceToken

func (b *AttemptBuilder) WithNewPresenceToken() *AttemptBuilder

type AttemptRegisterDoc

type AttemptRegisterDoc struct {
	AttemptID             string `firestore:"attempt_id"`
	PresenceToken         string `firestore:"presenceToken"`
	IsCompleted           bool   `firestore:"isCompleted"`
	Status                string `firestore:"status"`
	HackatticCountryCheck string `firestore:"hackatticCountryCheck"`
	ShooterURl            string `firestore:"shooter_url"`
}

type Challenge

type Challenge struct {
	Headers  []string
	Endpoint string // Normally, the challenge name?
	// Tokens
	AccessToken string // Allow to retrieve a presence token
	// APIs
	APIGetPresenceToken string // We get the token.
	APICountryCheck     string // We check the country.
	APISubmitSolution   string // We submit the solution.
	HttpClient          *http.Client
}

type ChallengeBuilder

type ChallengeBuilder struct {
	Cfg               *config.Config
	Base              string
	APIBase           string
	APIInit           string // We get the token.
	APICountryCheck   string // We check the country.
	APISubmitSolution string // We submit the solution.
	Headers           []string
	Errors            []error
	AccessToken       string // Allow to retrieve a presence token
	PresenceToken     string // Allow to perform challenge attempts.
	HttpClient        *http.Client
}

func New

func New(cfg *config.Config) *ChallengeBuilder

func (*ChallengeBuilder) Build

func (b *ChallengeBuilder) Build() (*Challenge, []error)

func (*ChallengeBuilder) WithAccessToken

func (b *ChallengeBuilder) WithAccessToken() *ChallengeBuilder

func (*ChallengeBuilder) WithCountryHeaders

func (b *ChallengeBuilder) WithCountryHeaders(country string) *ChallengeBuilder

func (*ChallengeBuilder) WithHTTPClient

func (b *ChallengeBuilder) WithHTTPClient() *ChallengeBuilder

func (*ChallengeBuilder) WithHeaders

func (b *ChallengeBuilder) WithHeaders(headers []string) *ChallengeBuilder

type CountryHeaderUserAgents

type CountryHeaderUserAgents struct {
	Country string
	Headers []string
}

func GetHeaders

func GetHeaders() []CountryHeaderUserAgents

type Document

type Document struct {
	AttemptID        string               `firestore:"attempt_id"`
	AccessToken      string               `firestore:"accessToken"`
	PresenceToken    string               `firestore:"presenceToken"`
	Attempts         []AttemptRegisterDoc `firestore:"attempts"`
	Status           string               `firestore:"status"`
	NumberOfAttempts int                  `firestore:"numberOfAttempts"`
	Result           string               `firestore:"result"`
}

type PresenceTokenResponse

type PresenceTokenResponse struct {
	PresenceToken string `json:"presence_token"`
}

type Result

type Result struct {
	CountryResponse string
	IsSuccessful    bool
}

type Shooter

type Shooter struct {
	Id         string
	AttemptId  string
	Status     string
	Cfg        *config.Config
	Challenge  *Challenge
	Attempt    *Attempt
	Errors     []error
	AttemptDoc *Document
	// The response back from hackattic
	Response *ShooterResponse
}

func (*Shooter) Register

func (s *Shooter) Register() *ShooterResponse

type ShooterBuilder

type ShooterBuilder struct {
	Cfg        *config.Config
	Challenge  *Challenge
	Attempt    *Attempt
	Id         string
	Errors     []error
	AttemptDoc *Document
	// The response back from hackattic
	Response *ShooterResponse
}

func NewShooter

func NewShooter() *ShooterBuilder

func (*ShooterBuilder) Complete

func (b *ShooterBuilder) Complete() (*Shooter, []error)

func (*ShooterBuilder) WithAttempt

func (b *ShooterBuilder) WithAttempt(attempt *Attempt) *ShooterBuilder

func (*ShooterBuilder) WithChallenge

func (b *ShooterBuilder) WithChallenge(challenge *Challenge) *ShooterBuilder

func (*ShooterBuilder) WithConfig

func (b *ShooterBuilder) WithConfig(cfg *config.Config) *ShooterBuilder

func (*ShooterBuilder) WithCountryCheck

func (b *ShooterBuilder) WithCountryCheck() *ShooterBuilder

func (*ShooterBuilder) WithPassedPresenceToken

func (b *ShooterBuilder) WithPassedPresenceToken(token string) *ShooterBuilder

func (*ShooterBuilder) WithPresenceTokenFromDb

func (b *ShooterBuilder) WithPresenceTokenFromDb() *ShooterBuilder

type ShooterExecutioner

type ShooterExecutioner interface {
	Register() *ShooterResponse
}

type ShooterResponse

type ShooterResponse struct {
	HackatticCountryCheck string
	IsSuccessful          bool
	Status                string
	Error                 error
}

Jump to

Keyboard shortcuts

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