hyper

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 14 Imported by: 0

README

Hyper Solutions SDK

Installation

To use the Hyper Solutions SDK in your Go project, you need to install it using the following command:

go get github.com/Hyper-Solutions/hyper-sdk-go

Usage

Creating a Session

To start using the SDK, you need to create a new Session instance by providing your API key:

session := hyper.NewSession("your-api-key")

You can also optionally set a JWT key and a custom HTTP client:

session := hyper.NewSession("your-api-key").
    WithJwtKey("your-jwt-key").
    WithClient(customHTTPClient)

Akamai

The Akamai package provides functions for interacting with Akamai Bot Manager, including generating sensor data, parsing script path, parsing pixel challenges, and handling sec-cpt challenges.

Generating Sensor Data

To generate sensor data required for generating valid Akamai cookies, use the GenerateSensorData function:

sensorData, err := session.GenerateSensorData(ctx, &hyper.SensorInput{
    // Set the required input fields
})
if err != nil {
    // Handle the error
}
Parsing Script Path

To parse the Akamai Bot Manager script path from the given HTML code, use the ParseScriptPath function:

scriptPath, err := akamai.ParseScriptPath(reader)
if err != nil {
    // Handle the error
}
Handling Sec-Cpt Challenges

The Akamai package provides functions for handling sec-cpt challenges:

  • ParseSecCptChallenge: Parses a sec-cpt challenge from an io.Reader.
  • ParseSecCptChallengeFromJson: Parses a sec-cpt challenge from an io.Reader.
  • GenerateSecCptPayload: Generates a sec-cpt payload using the provided sec-cpt cookie.
  • Sleep: Sleeps for the duration specified in the sec-cpt challenge.
  • SleepWithContext: Sleeps for the duration specified in the sec-cpt challenge, this is context aware.
Validating Cookies

The Akamai package provides functions for validating cookies:

  • IsCookieValid: Determines if the provided _abck cookie value is valid based on the given request count.
  • IsCookieInvalidated: Determines if the current session requires more sensors to be sent.
Generating Pixel Data

To generate pixel data, use the GeneratePixelData function:

pixelData, err := session.GeneratePixelData(ctx, &hyper.PixelInput{
    // Set the required input fields
})
if err != nil {
    // Handle the error
}
Parsing Pixel Challenges

The Akamai package provides functions for parsing pixel challenges:

  • ParsePixelHtmlVar: Parses the required pixel challenge variable from the given HTML code.
  • ParsePixelScriptURL: Parses the script URL of the pixel challenge script and the URL to post a generated payload to from the given HTML code.
  • ParsePixelScriptVar: Parses the dynamic value from the pixel script.

Incapsula

The Incapsula package provides functions for interacting with Incapsula, including generating Reese84 sensor data, UTMVC cookies, and parsing UTMVC script paths.

Generating Reese84 Sensor

To generate sensor data required for generating valid Reese84 cookies, use the GenerateReese84Sensor function:

sensorData, err := session.GenerateReese84Sensor(ctx, site, userAgent)
if err != nil {
    // Handle the error
}

To generate the UTMVC cookie using the Hyper Solutions API, use the GenerateUtmvcCookie function:

utmvcCookie, err := session.GenerateUtmvcCookie(ctx, &hyper.UtmvcInput{
    Script: "your-script",
    SessionIds: []string{"session-id-1", "session-id-2"},
    UserAgent: "user-agent-here"
})
if err != nil {
    // Handle the error
}
Parsing UTMVC Script Path

To parse the UTMVC script path from a given script content, use the ParseUtmvcScriptPath function:

scriptPath, err := incapsula.ParseUtmvcScriptPath(scriptReader)
if err != nil {
    // Handle the error
}
Generating UTMVC Submit Path

To generate a unique UTMVC submit path with a random query parameter, use the GetUtmvcSubmitPath function:

submitPath := incapsula.GetUtmvcSubmitPath()

Contributing

If you find any issues or have suggestions for improvement, please open an issue or submit a pull request.

License

This SDK is licensed under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PixelInput

type PixelInput struct {
	UserAgent string `json:"userAgent"`
	HTMLVar   string `json:"htmlVar"`
	ScriptVar string `json:"scriptVar"`
}

func (PixelInput) MarshalEasyJSON

func (v PixelInput) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (PixelInput) MarshalJSON

func (v PixelInput) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*PixelInput) UnmarshalEasyJSON

func (v *PixelInput) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*PixelInput) UnmarshalJSON

func (v *PixelInput) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type SensorInput

type SensorInput struct {
	Abck       string `json:"abck"`
	Bmsz       string `json:"bmsz"`
	Version    string `json:"version"`
	PageUrl    string `json:"pageUrl"`
	UserAgent  string `json:"userAgent"`
	ScriptHash string `json:"scriptHash"`
}

func (SensorInput) MarshalEasyJSON

func (v SensorInput) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (SensorInput) MarshalJSON

func (v SensorInput) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*SensorInput) UnmarshalEasyJSON

func (v *SensorInput) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*SensorInput) UnmarshalJSON

func (v *SensorInput) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Session

type Session struct {
	ApiKey string
	JwtKey []byte
	Client *http.Client
}

func NewSession

func NewSession(apiKey string) *Session

NewSession creates a new Session that can be used to make requests to the Hyper Solutions API.

func (*Session) GeneratePixelData

func (s *Session) GeneratePixelData(ctx context.Context, input *PixelInput) (string, error)

GeneratePixelData returns the pixel data using the Hyper Solutions API.

func (*Session) GenerateReese84Sensor

func (s *Session) GenerateReese84Sensor(ctx context.Context, site, userAgent string) (string, error)

GenerateReese84Sensor returns the sensor data required to generate valid reese84 cookies using the Hyper Solutions API.

func (*Session) GenerateSensorData

func (s *Session) GenerateSensorData(ctx context.Context, input *SensorInput) (string, error)

GenerateSensorData returns the sensor data required to generate valid akamai cookies using the Hyper Solutions API.

func (*Session) GenerateUtmvcCookie

func (s *Session) GenerateUtmvcCookie(ctx context.Context, input *UtmvcInput) (string, error)

GenerateUtmvcCookie returns the utmvc cookie using the Hyper Solutions API.

func (*Session) WithClient

func (s *Session) WithClient(client *http.Client) *Session

WithClient sets a new client that will be used to make requests to the Hyper Solutions API.

func (*Session) WithJwtKey

func (s *Session) WithJwtKey(jwt string) *Session

WithJwtKey adds the JWT Key to the session. If not empty, a signature will be added to each request.

type UtmvcInput

type UtmvcInput struct {
	UserAgent  string   `json:"userAgent"`
	SessionIds []string `json:"sessionIds"`
	Script     string   `json:"script"`
}

func (UtmvcInput) MarshalEasyJSON

func (v UtmvcInput) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (UtmvcInput) MarshalJSON

func (v UtmvcInput) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*UtmvcInput) UnmarshalEasyJSON

func (v *UtmvcInput) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*UtmvcInput) UnmarshalJSON

func (v *UtmvcInput) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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