Documentation
ΒΆ
Index ΒΆ
- Constants
- type CompressionType
- type DynamicInput
- type Headers
- type PixelInput
- type SbsdInput
- type SensorInput
- type Session
- func (s *Session) GeneratePixelData(ctx context.Context, input *PixelInput) (string, error)
- func (s *Session) GenerateSbsdData(ctx context.Context, input *SbsdInput) (string, error)
- func (s *Session) GenerateSensorData(ctx context.Context, input *SensorInput) (string, string, error)
- func (s *Session) WithBaseUrl(baseUrl string) *Session
- func (s *Session) WithClient(client *http.Client) *Session
- func (s *Session) WithCompression(compression CompressionType) *Session
- func (s *Session) WithJwtKey(string) *Sessiondeprecated
- func (s *Session) WithOrganization(key, secret string) *Sessiondeprecated
Constants ΒΆ
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 ΒΆ
MarshalEasyJSON supports easyjson.Marshaler interface
func (Headers) MarshalJSON ΒΆ
MarshalJSON supports json.Marshaler interface
func (*Headers) UnmarshalEasyJSON ΒΆ
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*Headers) UnmarshalJSON ΒΆ
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 ΒΆ
MarshalEasyJSON supports easyjson.Marshaler interface
func (SbsdInput) MarshalJSON ΒΆ
MarshalJSON supports json.Marshaler interface
func (*SbsdInput) UnmarshalEasyJSON ΒΆ
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*SbsdInput) UnmarshalJSON ΒΆ
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 ΒΆ
NewSession creates a new Session that can be used to make requests to the API.
func (*Session) GeneratePixelData ΒΆ
GeneratePixelData returns the pixel data using the API.
func (*Session) GenerateSbsdData ΒΆ
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 ΒΆ
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 ΒΆ
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 (*Session) WithOrganization
deprecated
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.