universalsdk

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: MIT Imports: 14 Imported by: 0

README ΒΆ

Universal SDK β€” Go

Go SDK for Akamai Bot Manager: sensor data generation, pixel and SBSD challenges, sec-cpt solving and _abck cookie validation.

πŸ”‘ Getting API Access

Before using this SDK you need an API key:

  1. Go to sold-out.dev, create an account and link your API key.
  2. You can even ask for a free trial on our Discord.

πŸ“¦ Installation

go get github.com/sold-out-dev/sold-universal-sdk-go

πŸ”§ Basic Usage

package main

import (
	"context"
	"fmt"

	universalsdk "github.com/sold-out-dev/sold-universal-sdk-go"
)

func main() {
	session := universalsdk.NewSession("your-api-key")

	sensorData, sensorContext, err := session.GenerateSensorData(context.Background(), &universalsdk.SensorInput{
		// Configure sensor parameters
	})
	if err != nil {
		panic(err)
	}
	fmt.Println(sensorData, sensorContext)
}
Session options
session := universalsdk.NewSession("your-api-key").
	WithClient(customHTTPClient).
	WithCompression(universalsdk.CompressionGzip)

For drop-in compatibility with the upstream SDK, WithJwtKey and WithOrganization still exist but are no-ops: this API authenticates with the API key alone.

Custom base URL

The API base url defaults to universalsdk.DefaultBaseUrl (https://sold-out.dev). Override it with WithBaseUrl:

session := universalsdk.NewSession("your-api-key").
	WithBaseUrl("https://akamai.example.com") // trailing slashes are stripped

Setting it to an empty string falls back to the default.

πŸ›‘οΈ Akamai Bot Manager

Generating Sensor Data
sensorData, sensorContext, err := session.GenerateSensorData(ctx, &universalsdk.SensorInput{
	// Configure sensor parameters
})
Parsing Script Path
scriptPath, err := akamai.ParseScriptPath(reader)
Handling Sec-Cpt Challenges
  • ParseSecCptChallenge: parse sec-cpt challenges from HTML
  • ParseSecCptChallengeFromJson: parse from JSON responses
  • GenerateSecCptPayload: generate challenge response payloads
  • Sleep / SleepWithContext: handle challenge timing requirements
  • IsCookieValid: check _abck cookie validity for a request count
  • IsCookieInvalidated: determine if more sensors are needed
Pixel Challenge Solving
pixelData, err := session.GeneratePixelData(ctx, &universalsdk.PixelInput{
	// Pixel challenge parameters
})

Pixel parsing helpers: ParsePixelHtmlVar, ParsePixelScriptURL, ParsePixelScriptVar.

SBSD Challenge Solving
sbsdData, err := session.GenerateSbsdData(ctx, &universalsdk.SbsdInput{
	// SBSD parameters
})

πŸ“„ License

MIT β€” see LICENSE.


Fork of the Hyper Solutions SDK, trimmed down to the Akamai part and pointed at our own API.

Documentation ΒΆ

Index ΒΆ

Constants ΒΆ

View Source
const DefaultBaseUrl = "https://sold-out.dev"

DefaultBaseUrl is the default API base url used when none is configured.

Variables ΒΆ

This section is empty.

Functions ΒΆ

This section is empty.

Types ΒΆ

type CompressionType ΒΆ

type CompressionType string

CompressionType represents the compression algorithm to use

const (
	CompressionZstd CompressionType = "zstd"
	CompressionGzip CompressionType = "gzip"
)

type DynamicInput ΒΆ

type DynamicInput struct {
	// Script is the akamai script's contents.
	Script string `json:"script"`
}

func (DynamicInput) MarshalEasyJSON ΒΆ

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

MarshalEasyJSON supports easyjson.Marshaler interface

func (DynamicInput) MarshalJSON ΒΆ

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

MarshalJSON supports json.Marshaler interface

func (*DynamicInput) UnmarshalEasyJSON ΒΆ

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

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*DynamicInput) UnmarshalJSON ΒΆ

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

UnmarshalJSON supports json.Unmarshaler interface

type Headers ΒΆ

type Headers struct {
	DeviceMemory    string `json:"sec-ch-device-memory"`
	Mobile          string `json:"sec-ch-ua-mobile"`
	Arch            string `json:"sec-ch-ua-arch"`
	Platform        string `json:"sec-ch-ua-platform"`
	Model           string `json:"sec-ch-ua-model"`
	FullVersionList string `json:"sec-ch-ua-full-version-list"`
}

func (Headers) MarshalEasyJSON ΒΆ

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

MarshalEasyJSON supports easyjson.Marshaler interface

func (Headers) MarshalJSON ΒΆ

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

MarshalJSON supports json.Marshaler interface

func (*Headers) UnmarshalEasyJSON ΒΆ

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

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Headers) UnmarshalJSON ΒΆ

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

UnmarshalJSON supports json.Unmarshaler interface

type PixelInput ΒΆ

type PixelInput struct {
	// UserAgent must be a Chrome Windows User-Agent.
	UserAgent      string `json:"userAgent"`
	HTMLVar        string `json:"htmlVar"`
	ScriptVar      string `json:"scriptVar"`
	AcceptLanguage string `json:"acceptLanguage"`
	IP             string `json:"ip"`
}

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 SbsdInput ΒΆ

type SbsdInput struct {
	Index int `json:"index"`
	// UserAgent must be a Chrome Windows User-Agent.
	UserAgent      string `json:"userAgent"`
	Uuid           string `json:"uuid"`
	PageUrl        string `json:"pageUrl"`
	OCookie        string `json:"o"`
	Script         string `json:"script"`
	AcceptLanguage string `json:"acceptLanguage"`
	IP             string `json:"ip"`
}

func (SbsdInput) MarshalEasyJSON ΒΆ

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

MarshalEasyJSON supports easyjson.Marshaler interface

func (SbsdInput) MarshalJSON ΒΆ

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

MarshalJSON supports json.Marshaler interface

func (*SbsdInput) UnmarshalEasyJSON ΒΆ

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

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*SbsdInput) UnmarshalJSON ΒΆ

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

UnmarshalJSON supports json.Unmarshaler interface

type SensorInput ΒΆ

type SensorInput struct {
	// Abck is the _abck cookie retrieved from your cookiejar.
	// Make sure you always retrieve it fresh from the cookiejar as it gets updated while making requests.
	Abck string `json:"abck"`

	// Bmsz is the bm_sz cookie retrieved from your cookiejar, make sure you always retrieve it fresh from the cookiejar.
	Bmsz string `json:"bmsz"`

	// Version is the akamai version, this will usually be "2"
	Version string `json:"version"`

	// PageUrl is the page url that loaded the akamai script, it is the same URL as the referer header on the sensor posts
	PageUrl string `json:"pageUrl"`

	// UserAgent must be a Chrome Windows User-Agent.
	UserAgent string `json:"userAgent"`

	// Script is mutually exclusive with [SensorInput.Context], the first sensor request should include the script field.
	// 	Subsequent request should only include the Context.
	Script string `json:"script"`

	// ScriptUrl is the full URL where you are posting sensor data to
	ScriptUrl string `json:"scriptUrl"`

	AcceptLanguage string `json:"acceptLanguage"`
	IP             string `json:"ip"`
	Context        string `json:"context"`
}

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
	// BaseUrl is the API base url. If empty, DefaultBaseUrl is used.
	BaseUrl     string
	Client      *http.Client
	Compression CompressionType
}

func NewSession ΒΆ

func NewSession(apiKey string) *Session

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

func (*Session) GeneratePixelData ΒΆ

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

GeneratePixelData returns the pixel data using the API.

func (*Session) GenerateSbsdData ΒΆ

func (s *Session) GenerateSbsdData(ctx context.Context, input *SbsdInput) (string, error)

GenerateSbsdData returns the sbsd payload using the API.

func (*Session) GenerateSensorData ΒΆ

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

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

func (*Session) WithBaseUrl ΒΆ

func (s *Session) WithBaseUrl(baseUrl string) *Session

WithBaseUrl sets a custom API base url (e.g. "https://akamai.example.com"). Trailing slashes are stripped. Pass an empty string to fall back to DefaultBaseUrl.

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 API.

func (*Session) WithCompression ΒΆ

func (s *Session) WithCompression(compression CompressionType) *Session

WithCompression sets the compression type for requests.

func (*Session) WithJwtKey deprecated

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

WithJwtKey is a no-op kept for drop-in compatibility with the upstream SDK. This API authenticates with the API key alone; request signing is not used.

Deprecated: request signing was removed, this method does nothing.

func (*Session) WithOrganization deprecated

func (s *Session) WithOrganization(key, secret string) *Session

WithOrganization is a no-op kept for drop-in compatibility with the upstream SDK. This API authenticates with the API key alone; organization credentials are not used.

Deprecated: organization credentials were removed, this method does nothing.

Directories ΒΆ

Path Synopsis

Jump to

Keyboard shortcuts

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