Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ black-lint:
isort:
poetry run isort --settings-path formatters-cfg.toml $(SRC_DIR)

doc-lint:
poetry run lazydocs --validate --output-path $(REFERENCES_DIR) $(PACKAGE_DIR)

format: black isort doc-lint
format: black isort

lint: flake mypy black-lint

Expand Down
137 changes: 1 addition & 136 deletions docs/references/auth.md
Original file line number Diff line number Diff line change
@@ -1,136 +1 @@
<!-- markdownlint-disable -->

<a href="../../telegram_webapp_auth/auth.py#L0"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

# <kbd>module</kbd> `auth`





---

<a href="../../telegram_webapp_auth/auth.py#L32"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>function</kbd> `generate_secret_key`

```python
generate_secret_key(token: str) → bytes
```

Generates a secret key from a Telegram token.

Links: https://core.telegram.org/bots/webapps#validating-data-received-via-the-mini-app



**Args:**

- <b>`token`</b>: Telegram Bot Token



**Returns:**

- <b>`bytes`</b>: secret key


---

<a href="../../telegram_webapp_auth/auth.py#L12"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `TelegramUser`
Represents a Telegram user.

Links: https://core.telegram.org/bots/webapps#webappuser

<a href="../../<string>"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `__init__`

```python
__init__(
id: int,
first_name: str,
is_bot: Optional[bool] = None,
last_name: Optional[str] = None,
username: Optional[str] = None,
language_code: Optional[str] = None,
is_premium: Optional[bool] = None,
added_to_attachment_menu: Optional[bool] = None,
allows_write_to_pm: Optional[bool] = None,
photo_url: Optional[str] = None
) → None
```









---

<a href="../../telegram_webapp_auth/auth.py#L49"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `TelegramAuthenticator`




<a href="../../telegram_webapp_auth/auth.py#L50"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `__init__`

```python
__init__(secret: bytes)
```








---

<a href="../../telegram_webapp_auth/auth.py#L97"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `verify_token`

```python
verify_token(token: str) → TelegramUser
```

Verifies the data using the method from documentation. Returns Telegram user if data is valid.

Links: https://core.telegram.org/bots/webapps#validating-data-received-via-the-mini-app



**Args:**

- <b>`hash_`</b>: hash from init data
- <b>`token`</b>: init data from webapp



**Returns:**

- <b>`TelegramUser`</b>: Telegram user if token is valid



**Raises:**

- <b>`InvalidInitDataError`</b>: if the token is invalid




---

_This file was automatically generated via [lazydocs](https://github.com/ml-tooling/lazydocs)._
::: telegram_webapp_auth.auth
141 changes: 1 addition & 140 deletions docs/references/data.md
Original file line number Diff line number Diff line change
@@ -1,140 +1 @@
<!-- markdownlint-disable -->

<a href="../../telegram_webapp_auth/data.py#L0"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

# <kbd>module</kbd> `data`




**Global Variables**
---------------
- **dataclasses**
- **TEST_PUBLIC_KEY_STR**
- **PROD_PUBLIC_KEY_STR**
- **TEST_PUBLIC_KEY_BYTES**
- **PROD_PUBLIC_KEY_BYTES**


---

<a href="../../telegram_webapp_auth/data.py#L17"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `WebAppUser`
Represents a Telegram user.

Links: https://core.telegram.org/bots/webapps#webappuser

<a href="../../<string>"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `__init__`

```python
__init__(
id: int,
first_name: str,
is_bot: Optional[bool] = None,
last_name: Optional[str] = None,
username: Optional[str] = None,
language_code: Optional[str] = None,
is_premium: Optional[bool] = None,
added_to_attachment_menu: Optional[bool] = None,
allows_write_to_pm: Optional[bool] = None,
photo_url: Optional[str] = None
) → None
```









---

<a href="../../telegram_webapp_auth/data.py#L37"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `ChatType`








---

<a href="../../telegram_webapp_auth/data.py#L44"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `WebAppChat`
Represents a Telegram chat.

Links: https://core.telegram.org/bots/webapps#webappchat

<a href="../../<string>"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `__init__`

```python
__init__(
id: int,
type: ChatType,
title: str,
username: Optional[str] = None,
photo_url: Optional[str] = None
) → None
```









---

<a href="../../telegram_webapp_auth/data.py#L59"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `WebAppInitData`
Represents the data that the webapp receives from Telegram.

Links: https://core.telegram.org/bots/webapps#webappinitdata

<a href="../../<string>"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `__init__`

```python
__init__(
auth_date: int,
hash: str,
signature: str,
query_id: Optional[str] = None,
user: Optional[WebAppUser] = None,
receiver: Optional[WebAppUser] = None,
chat: Optional[WebAppChat] = None,
chat_type: Optional[ChatType] = None,
chat_instance: Optional[str] = None,
start_param: Optional[str] = None,
can_send_after: Optional[int] = None
) → None
```











---

_This file was automatically generated via [lazydocs](https://github.com/ml-tooling/lazydocs)._
::: telegram_webapp_auth.data
56 changes: 1 addition & 55 deletions docs/references/errors.md
Original file line number Diff line number Diff line change
@@ -1,55 +1 @@
<!-- markdownlint-disable -->

<a href="../../telegram_webapp_auth/errors.py#L0"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

# <kbd>module</kbd> `errors`






---

<a href="../../telegram_webapp_auth/errors.py#L1"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `BaseTWAError`








---

<a href="../../telegram_webapp_auth/errors.py#L5"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `InvalidInitDataError`








---

<a href="../../telegram_webapp_auth/errors.py#L9"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `ExpiredInitDataError`










---

_This file was automatically generated via [lazydocs](https://github.com/ml-tooling/lazydocs)._
::: telegram_webapp_auth.errors
6 changes: 5 additions & 1 deletion formatters-cfg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ target-version = ["py39"]

[tool.flake8]
inline-quotes = "double"
ignore = "E203, W503, S101"
ignore = "E203, W503, S101, D100, D104"
max-line-length = 120
docstring-convention = "google"
per-file-ignores = [
"tests/*: D"
]

[tool.isort]
profile = "black"
Expand Down
4 changes: 3 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,16 @@ nav:
- FastAPI: guide/examples/fastapi.md
- References:
- Authorization: references/auth.md
- Data: references/data.md
- Errors: references/errors.md
- License: license.md

plugins:
- search
- section-index
- mkdocstrings
- coverage
- mkdocstrings:
default_handler: python
- macros:
include_dir: .
- minify:
Expand Down
Loading
Loading