Metadata-Version: 2.4
Name: cookie-jar-bridge
Version: 0.2.2
Summary: Netscape cookies.txt ↔ Playwright JSON — convert, validate, merge; MLX cookie import. CLI: cookie-bridge.
Project-URL: Homepage, https://pypi.org/project/cookie-jar-bridge/
Project-URL: Documentation, https://pypi.org/project/cookie-jar-bridge/
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
Project-URL: Changelog, https://github.com/cookie-jar-bridge/cookie-jar-bridge/blob/main/CHANGELOG.md
Author: cookie-jar-bridge contributors
License-Expression: MIT
License-File: LICENSE
Keywords: antidetect-cookies,browser-cookies,cookie-converter,cookie-format,cookie-jar,cookie-merge,cookie-validator,cookies-txt,curl-b-cookies,curl-cookies,http-cookie,multilogin-cookies,netscape-cookies,playwright-cookies,playwright-storage-state,selenium-cookies,set-cookie
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
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: Topic :: Software Development :: Quality Assurance
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

**Netscape cookies.txt ↔ Playwright JSON** — convert, validate, and merge browser cookies; MLX import optional.

[![PyPI version](https://img.shields.io/pypi/v/cookie-jar-bridge.svg)](https://pypi.org/project/cookie-jar-bridge/)
[![Python versions](https://img.shields.io/pypi/pyversions/cookie-jar-bridge.svg)](https://pypi.org/project/cookie-jar-bridge/)
[![License: MIT](https://img.shields.io/pypi/l/cookie-jar-bridge.svg)](https://pypi.org/project/cookie-jar-bridge/)

```bash
pip install cookie-jar-bridge
cookie-bridge validate cookies.txt
```

CLI: **`cookie-bridge`** · Python **3.10+** · optional **`[mlx]`** for Launcher helpers

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.

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

## When imported cookies fail login (playbook)

Conversion succeeded but the site still asks you to sign in — usually **context**, not format.

| Symptom | Likely cause | Fix |
|---------|--------------|-----|
| Valid jar, no session | `www` vs apex domain | `validate --host example.com`; re-export with correct domain |
| Worked once, then logout | Expired `expiry` or session cookie | `cookie-bridge stats` histogram; refresh export |
| Login on old IP only | New fingerprint/proxy | Match [proxy-lane-checker](https://pypi.org/project/proxy-lane-checker/) + profile |
| MLX import ok, site fails | IP/device challenge | [cdp-probe](https://pypi.org/project/playwright-cdp-probe/) after import |

**Session import pipeline (fleet tail):**

```bash
cookie-bridge merge ./exports/ -o merged.txt
cookie-bridge validate merged.txt --strict --host your-app.example
cookie-bridge convert merged.txt --to playwright-json -o state.json
cookie-bridge mlx-import --profile-id PROFILE_UUID --input merged.txt   # optional MLX
cdp-probe mlx --profile-id PROFILE_UUID --url https://your-app.example
```

See [docs/CURL_RECIPES.md](docs/CURL_RECIPES.md) for `curl -b` and `requests` without a browser.

### 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

Convert → `validate --strict` → import into **isolated** profiles (Playwright `storage_state` or MLX `mlx-import`). Cookies restore stored credentials — they do not fix fingerprint or IP drift alone.

```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
```

**Partner note (affiliate):** Multi-account persistence usually needs cookies in **isolated Multilogin X** profiles with matched proxy/fingerprint — not a shared daily browser. Eligible new browser purchases may accept code **`SAAS50`** at [multilogin.com](https://multilogin.com/?ref=SAAS50) — verify terms before checkout. Convert/validate/merge need no MLX. Full disclosure: [docs/AFFILIATE.md](docs/AFFILIATE.md). Coupon details only via `cookie-bridge --show-deal` (never printed by default).

**FAQ:** [docs/FAQ.md](docs/FAQ.md) — Netscape cookies.txt, Playwright storage_state, curl import.

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




## Related tools (on PyPI)

| Package | CLI | Role |
|---------|-----|------|
| [playwright-cdp-probe](https://pypi.org/project/playwright-cdp-probe/) | `cdp-probe` | CDP / WebDriver exposure score |
| [cookie-jar-bridge](https://pypi.org/project/cookie-jar-bridge/) | `cookie-bridge` | Netscape ↔ Playwright cookies |
| [proxy-lane-checker](https://pypi.org/project/proxy-lane-checker/) | `proxy-lane` | Proxy TCP / HTTP / geo / DNSBL |
| [fingerprint-coherence](https://pypi.org/project/fingerprint-coherence/) | `fp-coherence` | UA / screen / timezone lint |

**Toolkit pipeline:** `proxy-lane check` → `fp-coherence audit` → automate → `cdp-probe run` → `cookie-bridge validate`

## 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/)
