Metadata-Version: 2.4
Name: sold_universal_sdk
Version: 1.0.1
Summary: Universal SDK - Akamai Bot Manager support
License: MIT License
        
        Copyright (c) 2024 Hyper Solutions
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: homepage, https://github.com/sold-out-dev/sold-universal-sdk-py
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Framework :: AsyncIO
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: httpx[http2]>=0.24.0
Requires-Dist: certifi>=2024.2.2
Requires-Dist: charset-normalizer>=3.3.2
Requires-Dist: idna>=3.6
Requires-Dist: jsonpickle>=3.0.3
Requires-Dist: urllib3>=2.2.1
Dynamic: license-file

# Universal SDK — Python

Python SDK for **Akamai Bot Manager**: sensor data generation, pixel and SBSD challenges, sec-cpt solving and `_abck` cookie validation. Sync and async clients included.

## 🔑 Getting API Access

Before using this SDK you need an API key:

1. Go to [sold-out.dev](https://sold-out.dev/), create an account and link your API key.
2. You can even ask for a **free trial** on our [Discord](https://discord.gg/NMRfsunxZ4).

## 📦 Installation

```bash
pip install sold-universal-sdk
```

## 🔧 Basic Usage

```python
from universal_sdk import Session, SensorInput

session = Session("your-api-key")

sensor_data, sensor_context = session.generate_sensor_data(SensorInput(
    # sensor input fields
))
```

Async version:

```python
from universal_sdk.session_async import SessionAsync

async with SessionAsync("your-api-key") as session:
    sensor_data, sensor_context = await session.generate_sensor_data(SensorInput(...))
```

### Session options

```python
session = Session(
    api_key="your-api-key",
    compression=True,
)
```

For drop-in compatibility with the upstream SDK, `jwt_key`, `app_key` and `app_secret` are
still accepted (positionally or by keyword) and ignored: this API authenticates with the
API key alone.

### Custom base URL

The API base url defaults to `DEFAULT_BASE_URL` (`https://sold-out.dev`). Override it with the `base_url` argument:

```python
from universal_sdk.session import DEFAULT_BASE_URL

session = Session("your-api-key", base_url="https://akamai.example.com")  # trailing slashes are stripped
print(session.base_url, DEFAULT_BASE_URL)
```

`SessionAsync` accepts the same argument.

## 🛡️ Akamai Bot Manager


### Handling Sec-Cpt Challenges

```python
from universal_sdk.akamai import SecCptChallenge

challenge = SecCptChallenge.parse(html_content)
# or: challenge = SecCptChallenge.parse_from_json(json_response)

payload = challenge.generate_sec_cpt_payload(sec_cpt_cookie)
challenge.sleep()
```

### Cookie Validation

```python
from universal_sdk.akamai import is_cookie_valid, is_cookie_invalidated

is_valid = is_cookie_valid(cookie_value, request_count)
needs_refresh = is_cookie_invalidated(cookie_value)
```


### Pixel Challenge Solving

```python
from universal_sdk import PixelInput
from universal_sdk.akamai import parse_pixel_html_var, parse_pixel_script_url, parse_pixel_script_var

html_var = parse_pixel_html_var(html_content)
script_url, post_url = parse_pixel_script_url(html_content)
script_var = parse_pixel_script_var(script_content)

pixel_data = session.generate_pixel_data(PixelInput(
    # pixel input fields
))
```

### SBSD Challenge Solving

```python
from universal_sdk import SbsdInput

sbsd_data = session.generate_sbsd_data(SbsdInput(
    # sbsd input fields
))
```

### Script Path Parsing

```python
from universal_sdk.akamai import parse_akamai_script_path

script_path = parse_akamai_script_path(html_content)
```

## 📄 License

MIT — see [LICENSE](LICENSE).

---

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