Metadata-Version: 2.4
Name: migate
Version: 1.1.6
Summary: migate is a simplified Xiaomi authentication gateway for Python projects
Author: offici5l
License: MIT License
        
        Copyright (c) 2026 offici5l
        
        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: Repository, https://github.com/offici5l/migate
Keywords: xiaomi,miunlock,MiUnlockTool,bootloader,unlock,MIUI,HyperOS,Tools,18n_bbs_global,unlockApi,xiaomiio,mi,auth,login,gateway,2fa,Captcha
Classifier: Development Status :: 5 - Production/Stable
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests
Requires-Dist: rich
Requires-Dist: qrcode
Dynamic: license-file

<div align="center">

<a href="https://github.com/offici5l/migate/releases/latest">
  <img src="https://img.shields.io/badge/migate-%23FF6900?style=flat&logo=xiaomi&logoColor=white" alt="migate" width="100"/>
</a>

**Xiaomi authentication gateway for Python**

---

[![Version](https://img.shields.io/pypi/v/migate?label=Version&labelColor=black&color=brightgreen)](https://pypi.org/project/migate/)
[![Changelog](https://img.shields.io/badge/Changelog-blue?style=flat&logoColor=white)](CHANGELOG.md)

---

</div>

## Install

```sh
pip install migate
```

Or add it as a dependency in your project:

```toml
# pyproject.toml
dependencies = ["migate"]
```

```txt
# requirements.txt
migate
```

---

## Usage

```python
import migate

# --- passport (default) ---
# If no params are passed, sid defaults to passport.
# pass_token = migate.get_passtoken()
# service = migate.get_service(pass_token)

# --- unlockApi: bootloader unlock ---
# params = {"sid": "unlockApi", "checkSafeAddress": True}

# --- xiaomiio: Mi Home / smart home devices ---
# params = {"sid": "xiaomiio"}

# --- micoapi: Mi AI speaker ---
# params = {"sid": "micoapi"}

# --- i.mi.com: Mi Cloud / Find Device ---
# params = {"sid": "i.mi.com"}

# --- 18n_bbs_global: Mi Community ---
# params = {"sid": "18n_bbs_global"}

params = {"sid": "unlockApi", "checkSafeAddress": True}

pass_token = migate.get_passtoken(params)
# skip the interactive prompt if already logged in
# pass_token = migate.get_passtoken(params, silent=True)

service = migate.get_service(pass_token, params)

print(pass_token)
# {
#   "deviceId":  "wb_...",
#   "passToken": "...",
#   "userId":    "..."
# }

print(service)
# {
#   "servicedata": {
#     "nonce":     ...,
#     "ssecurity": "...",
#     "cUserId":   "...",
#     "psecurity": "...",
#     "deviceId":  "wb_..."
#   },
#   "cookies": {
#     # passport       -> {}
#     # unlockApi      -> serviceToken, unlockApi_slh, unlockApi_ph, userId
#     # xiaomiio       -> serviceToken, cUserId, userId
#     # micoapi        -> serviceToken, micoapi_slh, micoapi_ph, userId
#     # i.mi.com       -> serviceToken, i.mi.com_slh, i.mi.com_ph, userId
#     # 18n_bbs_global -> serviceToken, popRunToken, new_bbs_serviceToken, new_login, userId
#   }
# }
```

> All functions return `None` on failure. Always check the return value before passing it to the next call.

---

## Utilities

```python
# get account region 
region = migate.get_region(pass_token)

# get dataCenterZone
## get with account region
zone = migate.get_dataCenterZone(region)                 ## get with account ID 
zone = migate.get_dataCenterZone(userId)                 ## manual selection
zone = migate.get_dataCenterZone()                              

# get uRegion
uRegion = migate.get_uRegion()

# get uLocale
uLocale = migate.get_uLocale() 

# areaConfig, ex: with SG
area = migate.get_areaConfig("SG")
# {"code": "SG", "name": "Singapore", "dial": "+65"}
```


---

<div align="center">

🤝 [Contributing](CONTRIBUTING.md)

<a href="https://github.com/offici5l/migate/graphs/contributors">
  <img src="https://contrib.rocks/image?repo=offici5l/migate" />
</a>

---

[![License](https://img.shields.io/badge/License-MIT-green.svg)](./LICENSE)

</div>
