Metadata-Version: 2.4
Name: cookie-jar-bridge
Version: 0.2.0
Summary: Stop hand-editing cookies.txt — convert Netscape, Playwright, Selenium, and Set-Cookie formats in one CLI.
Project-URL: Homepage, https://github.com/cookie-jar-bridge/cookie-jar-bridge
Project-URL: Documentation, https://github.com/cookie-jar-bridge/cookie-jar-bridge#readme
Project-URL: Repository, https://github.com/cookie-jar-bridge/cookie-jar-bridge
Project-URL: Issues, https://github.com/cookie-jar-bridge/cookie-jar-bridge/issues
Author: cookie-jar-bridge contributors
License-Expression: MIT
License-File: LICENSE
Keywords: browser-cookies,cookie-converter,cookie-format,cookie-jar,cookie-merge,cookie-validator,curl-cookies,http-cookie,netscape-cookies,playwright-cookies,selenium-cookies,set-cookie
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Internet :: WWW/HTTP :: Browsers
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: click>=8.1
Provides-Extra: dev
Requires-Dist: build>=1.2; extra == 'dev'
Requires-Dist: httpx>=0.27; extra == 'dev'
Requires-Dist: pytest-httpx>=0.34; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: ruff>=0.8; extra == 'dev'
Requires-Dist: twine>=5.0; extra == 'dev'
Provides-Extra: mlx
Requires-Dist: httpx>=0.27; extra == 'mlx'
Description-Content-Type: text/markdown

# cookie-jar-bridge

Python 3.10+ | MLX optional · [Compatibility](../packages/COMPATIBILITY.md)

Convert and validate browser cookies across **Netscape** (`cookies.txt`), **Playwright** storage state JSON, **Selenium** cookie dict lists, and raw **HTTP Set-Cookie** headers.

Pure Python — no browser required for convert, validate, or merge.

## Problem

Cookie exports arrive in incompatible shapes:

- `curl` / browser extensions → Netscape `cookies.txt`
- Playwright → `storage_state.json` with `cookies` + `origins`
- Selenium → list of `{"name", "value", "domain", ...}` dicts
- HTTP traces → `Set-Cookie:` header lines

Teams waste time hand-editing tab-separated files or writing one-off scripts. `cookie-bridge` normalizes to a canonical model and writes any supported output format.

## pip install

```bash
pip install cookie-jar-bridge
```

MLX profile import (unlock + Launcher API):

```bash
pip install cookie-jar-bridge[mlx]
```

## Quick start

```bash
# Playwright storage state -> Netscape (for curl, wget, legacy tools)
cookie-bridge convert state.json --to netscape -o cookies.txt

# Netscape -> Playwright storage state
cookie-bridge convert cookies.txt --to playwright-json -o state.json

# Validate a jar before use
cookie-bridge validate cookies.txt

# Merge exports from a folder (later files win on duplicates)
cookie-bridge merge ./exports/ -o merged.txt
```

```python
from cookie_jar_bridge import load_cookies, convert_cookies

cookies = load_cookies(open("cookies.txt").read())
open("state.json", "w").write(convert_cookies(cookies, "playwright-json"))
```

## CLI

| Command | Description |
|---------|-------------|
| `cookie-bridge convert INPUT --to FORMAT -o OUT` | Convert between formats |
| `cookie-bridge validate INPUT` | Structural + semantic checks (`--host` for domain match) |
| `cookie-bridge stats INPUT` | Domain counts + expiry histogram |
| `cookie-bridge merge DIR/ -o OUT` | Merge `.txt`/`.json` cookie files |
| `cookie-bridge mlx-import --profile-id UUID --input FILE` | MLX unlock + import (`[mlx]`) |

### Format conversion matrix

| From ↓ / To → | Netscape (`curl -b`) | Playwright JSON | Selenium JSON | Set-Cookie lines |
|---------------|----------------------|-----------------|---------------|------------------|
| **Netscape** | — | `convert --to playwright-json` | `convert --to selenium-json` | `convert --to set-cookie` |
| **Playwright** | `convert --to netscape` | — | via Netscape or direct JSON | `convert --to set-cookie` |
| **Selenium** | `convert --to netscape` | `convert --to playwright-json` | — | `convert --to set-cookie` |
| **Set-Cookie** | `convert --to netscape` | `convert --to playwright-json` | `convert --to selenium-json` | — |

| `--to` / auto-detect | Description |
|----------------------|-------------|
| `netscape` | Tab-separated `cookies.txt` (curl-compatible) |
| `playwright-json` | Playwright `storage_state` object |
| `selenium-json` | JSON array of Selenium cookie dicts |
| `set-cookie` | `Set-Cookie:` header lines |

Use `--from FORMAT` to override auto-detection.

`validate` checks expired cookies, Netscape subdomain/domain flag mismatches, optional `--host example.com`, and httpOnly issues on secure session-like cookies.

### Exit codes

| Code | Meaning |
|------|---------|
| `0` | Success |
| `1` | Validation failed (`validate`) or `--strict` warnings |
| `2` | Runtime error |

## API

| Symbol | Description |
|--------|-------------|
| `load_cookies(text, fmt=None)` | Parse any supported format |
| `detect_format(text)` | Auto-detect source format |
| `convert_cookies(cookies, target)` | Serialize to target format |
| `validate_text(text)` | Return `ValidationReport` |
| `merge_directory(path)` | Merge files → `list[Cookie]` |

## MLX import (`[mlx]` extra)

Imports cookies into a Multilogin X profile:

1. **Unlock** profile via Cloud API `GET /profile/unlock?profile_ids=UUID`
2. **Import** via Launcher `POST /api/v1/cookies/import`

```bash
export MLX_TOKEN="your-bearer-token"
cookie-bridge mlx-import --profile-id PROFILE_UUID --input cookies.txt
```

Requires the Multilogin desktop agent running locally.

## Limitations

- **No live browser sync** — converts static files only; does not read Chrome SQLite or Firefox `cookies.sqlite` directly.
- **Domain inference** — Set-Cookie lines without `Domain=` may produce cookies missing domain until you add it manually.
- **Merge scope** — `merge` reads `.txt`, `.json`, `.cookies` in one directory; no recursive subfolders.
- **MLX import** — Launcher must be running; encrypted profiles must unlock successfully before import.
- **Not a security audit** — validation checks structure, not cookie secrecy or theft risk.

## Production

Partner offers, eligibility, and disclosure: [docs/AFFILIATE.md](docs/AFFILIATE.md).

For production antidetect workflows, convert cookies to the format your stack expects, validate before import, then push to isolated profiles:

```bash
cookie-bridge convert export.json --to netscape -o clean.txt
cookie-bridge validate clean.txt --strict
cookie-bridge mlx-import --profile-id "$PROFILE_ID" --input clean.txt
```

Pair with [playwright-cdp-probe](https://github.com/playwright-cdp-probe/playwright-cdp-probe) to audit the session after import.

## Guides

Monorepo playbooks (copy-paste commands, sample output, diagrams):

| Guide | Flow |
|-------|------|
| [Detection fail → MLX farm](../packages/docs/workflows/WORKFLOW_DETECTED.md) | `cdp-probe` → `cdp-connect` → `farm-runner mlx-pool` |
| [Competitor migration](../packages/docs/workflows/WORKFLOW_MIGRATION.md) | `antidetect-import` → `profile-factory mlx-create` |
| [Proxy lane → profile pool](../packages/docs/workflows/WORKFLOW_FARM.md) | `proxy-lane` → `profile-factory` → `farm-runner mlx-pool` |

**FAQ:** [docs/FAQ.md](docs/FAQ.md) — Netscape cookies, Playwright JSON, merge formats.

**curl / requests:** [docs/CURL_RECIPES.md](docs/CURL_RECIPES.md) — Netscape → `curl -b`, Playwright state → `requests.Session` (5 copy-paste recipes).

## Related tools

| Tool | Use with |
|------|----------|
| [playwright-cdp-probe](../playwright-cdp-probe/) — Score CDP/WebDriver exposure and fingerprint leaks | → [cdp-connect-kit](../cdp-connect-kit/) when probe fails |
| [cookie-jar-bridge](../cookie-jar-bridge/) — Convert, validate, and merge cookies across formats | → [session-bundle-kit](../session-bundle-kit/) for full session |
| [proxy-lane-checker](../proxy-lane-checker/) — Batch-check proxies for connectivity, geo, and DNSBL | → [profile-yaml-factory](../profile-yaml-factory/) |
| [fingerprint-coherence](../fingerprint-coherence/) — Lint fingerprints for cross-signal contradictions | → [profile-yaml-factory](../profile-yaml-factory/) before create |
| [human-input-kit](../human-input-kit/) — Human-like mouse, scroll, and warmup replay | → [automation-farm-runner](../automation-farm-runner/) |
| [cdp-connect-kit](../cdp-connect-kit/) — Playwright CDP connect; MLX start/stop helpers | → all packages needing CDP |
| [session-bundle-kit](../session-bundle-kit/) — Export/import cookies and storage as portable bundles | → [cookie-jar-bridge](../cookie-jar-bridge/) |
| [profile-yaml-factory](../profile-yaml-factory/) — YAML blueprints → MLX `profile/create` payloads | → [antidetect-importer](../antidetect-importer/) after migration |
| [antidetect-importer](../antidetect-importer/) — Parse competitor exports and push to MLX | → [profile-yaml-factory](../profile-yaml-factory/) |
| [automation-farm-runner](../automation-farm-runner/) — YAML job queue and MLX profile-pool runner | → [cdp-connect-kit](../cdp-connect-kit/) `[mlx]` |

## License

MIT

---

**Production antidetect:** [Multilogin X](https://multilogin.com/?ref=SAAS50) · Code `SAAS50` (-50% browser) · `MIN50` (-50% cloud phone)  
More scripts: [@Multilogin_Scripts_Bot](https://t.me/Multilogin_Scripts_Bot) · [Coupons](https://anti-detect.github.io/)
