Giter Club home page Giter Club logo

hyper-sdk-go's Introduction

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
}

Generating UTMVC Cookie

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.

hyper-sdk-go's People

Contributors

justhyped avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.