@bruch/max-client 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +65 -64
  2. package/package.json +10 -3
  3. package/UPSTREAM.md +0 -10
package/README.md CHANGED
@@ -1,68 +1,69 @@
1
- # tsmax
1
+ # MAX Client
2
2
 
3
- Неофициальный Bun/TypeScript-клиент внутреннего API мессенджера MAX. Это TypeScript-форк
4
- [PyMax](https://github.com/skar404/pymax), ориентированный на вход от имени обычного пользователя,
5
- SMS- и QR-аутентификацию, сообщения, чаты, контакты и вложения.
3
+ An unofficial Bun/TypeScript client for the internal MAX messenger API. It supports regular user
4
+ accounts, SMS and QR authentication, messages, chats, contacts, attachments, and live events.
6
5
 
7
- > Это не официальный SDK MAX. Внутренний протокол может измениться без предупреждения. Используйте
8
- > проект только для собственных аккаунтов и сценариев, которые не нарушают правила сервиса и закон.
6
+ > This is not an official MAX SDK. The internal protocol may change without notice. Use the project
7
+ > only with your own accounts and for workflows that comply with the service rules and applicable
8
+ > laws.
9
9
 
10
- ## Требования
10
+ ## Requirements
11
11
 
12
- - Bun 1.3.0 или новее;
13
- - Node.js не нужен и не поддерживается как runtime;
14
- - Bun используется и как runtime, и как пакетный менеджер;
15
- - ESLint проверяет код, Prettier отвечает за форматирование.
12
+ - Bun 1.3.0 or newer
13
+ - Bun as both the runtime and package manager
14
+ - ESLint for code quality and Prettier for formatting
16
15
 
17
- ## Установка
16
+ Node.js is not required and is not supported as a runtime.
17
+
18
+ ## Installation
18
19
 
19
20
  ```bash
20
- bun add tsmax
21
+ bun add @bruch/max-client
21
22
  ```
22
23
 
23
- До публикации пакета можно подключить локальный checkout:
24
+ Before the package is published, you can install a local checkout:
24
25
 
25
26
  ```bash
26
27
  bun add ../tsmax
27
28
  ```
28
29
 
29
- ## SMS-вход
30
+ ## SMS authentication
30
31
 
31
32
  ```ts
32
- import { Client } from "tsmax";
33
+ import { Client } from "@bruch/max-client";
33
34
 
34
35
  const client = new Client({
35
36
  phone: "+79990000000",
36
- smsCodeProvider: (phone) => prompt(`Код из SMS для ${phone}:`) ?? "",
37
- passwordProvider: (hint) => prompt(`Пароль 2FA${hint ? ` (${hint})` : ""}:`) ?? "",
37
+ smsCodeProvider: (phone) => prompt(`SMS code for ${phone}:`) ?? "",
38
+ passwordProvider: (hint) => prompt(`2FA password${hint ? ` (${hint})` : ""}:`) ?? "",
38
39
  });
39
40
 
40
41
  client.onStart(async (app) => {
41
- console.log(`Вошли как ${app.me?.contact.id}`);
42
- await app.sendMessage({ chatId: 123456789n, text: "Привет из **tsmax**" });
42
+ console.log(`Authenticated as ${app.me?.contact.id}`);
43
+ await app.sendMessage({ chatId: 123456789n, text: "Hello from **MAX Client**" });
43
44
  });
44
45
 
45
46
  await client.start();
46
47
  ```
47
48
 
48
- `start()` держит клиент подключённым до закрытия соединения. Для корректной остановки вызовите
49
- `await client.stop()`.
49
+ `start()` keeps the client connected until the connection closes. Call `await client.stop()` for a
50
+ graceful shutdown.
50
51
 
51
- ## QR-вход
52
+ ## QR authentication
52
53
 
53
54
  ```ts
54
- import { WebClient } from "tsmax";
55
+ import { WebClient } from "@bruch/max-client";
55
56
 
56
57
  const client = new WebClient({
57
- qrHandler: (link) => console.log("Откройте QR-ссылку:", link),
58
+ qrHandler: (link) => console.log("Open this QR link:", link),
58
59
  });
59
60
 
60
61
  await client.start();
61
62
  ```
62
63
 
63
- Стандартный QR-handler выводит QR-код прямо в терминал.
64
+ The default QR handler renders a QR code directly in the terminal.
64
65
 
65
- ## События
66
+ ## Events
66
67
 
67
68
  ```ts
68
69
  client.onMessage(
@@ -72,22 +73,22 @@ client.onMessage(
72
73
  (message) => message.chatId !== null,
73
74
  );
74
75
 
75
- client.onMessageEdit((message) => console.log("Изменено:", message.text));
76
+ client.onMessageEdit((message) => console.log("Edited:", message.text));
76
77
  client.onTyping((event) => console.log(event.userId, event.typing));
77
78
  client.onDisconnect((error, reconnect) => console.error(error.message, { reconnect }));
78
79
  ```
79
80
 
80
- Все идентификаторы пользователей, чатов и сообщений представлены как `bigint`. Передавайте литералы
81
- с суффиксом `n` и превращайте их в строки перед JSON-сериализацией.
81
+ User, chat, and message identifiers are represented as `bigint`. Use the `n` suffix for literals and
82
+ convert identifiers to strings before JSON serialization.
82
83
 
83
- ## Вложения
84
+ ## Attachments
84
85
 
85
86
  ```ts
86
- import { File, Photo, Video } from "tsmax/files";
87
+ import { File, Photo, Video } from "@bruch/max-client/files";
87
88
 
88
89
  await client.sendMessage({
89
90
  chatId: 123456789n,
90
- text: "Файлы",
91
+ text: "Files",
91
92
  attachments: [
92
93
  new Photo({ path: "./photo.jpg" }),
93
94
  new Video({ path: "./clip.mp4" }),
@@ -96,13 +97,14 @@ await client.sendMessage({
96
97
  });
97
98
  ```
98
99
 
99
- Для видео и файлов клиент ждёт серверное событие о завершении обработки, как PyMax.
100
+ For videos and files, the client waits for the server-side processing completion event before
101
+ continuing.
100
102
 
101
- ## Сессии PyMax
103
+ ## Sessions
102
104
 
103
- По умолчанию используется SQLite-файл `session.db`. Схема и миграции совместимы с PyMax 2.3.1:
104
- существующую базу можно открыть из обоих клиентов. Значения `sync_state` и токены сохраняются без
105
- потери 64-битных ID.
105
+ Sessions use the SQLite file `session.db` by default. Legacy minimal schemas are migrated
106
+ automatically, and `sync_state` values, tokens, and 64-bit identifiers are stored without precision
107
+ loss.
106
108
 
107
109
  ```ts
108
110
  const client = new Client({
@@ -112,13 +114,13 @@ const client = new Client({
112
114
  });
113
115
  ```
114
116
 
115
- Не коммитьте базы сессий: они содержат токены авторизации.
117
+ Never commit session databases. They contain authentication tokens.
116
118
 
117
- ## Proxy и транспорт
119
+ ## Proxies and transports
118
120
 
119
- Мобильный `Client` использует TCP/TLS и поддерживает HTTP CONNECT, HTTPS CONNECT, SOCKS4/4a и
120
- SOCKS5. `WebClient` использует встроенный WebSocket Bun; его `proxy` поддерживает HTTP(S)-proxy в
121
- формате Bun.
121
+ The mobile `Client` uses TCP/TLS and supports HTTP CONNECT, HTTPS CONNECT, SOCKS4/4a, and SOCKS5.
122
+ `WebClient` uses Bun's built-in WebSocket implementation; its `proxy` option accepts an HTTP(S)
123
+ proxy in Bun's format.
122
124
 
123
125
  ```ts
124
126
  const client = new Client({
@@ -127,42 +129,41 @@ const client = new Client({
127
129
  });
128
130
  ```
129
131
 
130
- ## Разработка
132
+ ## Development
131
133
 
132
134
  ```bash
133
135
  bun install
134
136
  bun run check
135
137
  ```
136
138
 
137
- Основные команды: `lint`, `format:check`, `typecheck`, `test`, `build`, `pack:check`. Покрытие строк,
138
- функций и statements не должно опускаться ниже 90% для загруженных тестами модулей.
139
+ The main commands are `lint`, `format:check`, `typecheck`, `test`, `build`, and `pack:check`. Line,
140
+ function, and statement coverage must remain at or above 90% for modules loaded by the test suite.
139
141
 
140
- ## Реальный smoke-test
142
+ ## Real account smoke test
141
143
 
142
- Файл `scripts/real-test.ts` проверяет настоящее TCP-подключение и SMS/2FA-вход. После авторизации он
143
- выводит имя пользователя, список активных подписок типа `CHANNEL` и остаётся подключённым. Каждый
144
- новый пост выводится с ID поста, ID и названием канала, текстом и типами вложений:
144
+ `scripts/real-test.ts` verifies a real TCP connection and SMS/2FA authentication. After login, it
145
+ prints the current user, lists active `CHANNEL` subscriptions, and stays connected. Every new post
146
+ is printed with its post ID, channel ID and title, text, and attachment types:
145
147
 
146
148
  ```bash
147
149
  MAX_PHONE=+79990000000 bun run test:real
148
150
  ```
149
151
 
150
- Тест ничего не отправляет и не изменяет в аккаунте; остановите его через `Ctrl+C`. Дополнительные
151
- переменные: `MAX_PROXY`, `MAX_WORK_DIR` и `MAX_SESSION_NAME`. Сессия по умолчанию хранится в
152
- `.data/real-test.db`; не публикуйте этот файл и не передавайте его другим людям.
152
+ The test does not send messages or modify the account. Stop it with `Ctrl+C`. Optional environment
153
+ variables are `MAX_PROXY`, `MAX_WORK_DIR`, and `MAX_SESSION_NAME`. The default session is stored in
154
+ `.data/real-test.db`; never publish this file or share it with anyone.
153
155
 
154
- ## Отличия от Node.js-пакета
156
+ ## Bun-only runtime
155
157
 
156
- Выбор Bun-only даёт единый runtime и доступ к `bun:sqlite`, `Bun.connect`, `Bun.zstdDecompress`,
157
- `Bun.file` и встроенному WebSocket. Цена этого решения пакет нельзя исполнять в Node.js, Deno,
158
- Cloudflare Workers и большинстве serverless-платформ без Bun; Node-специфичные тестовые инструменты и
159
- APM-интеграции также не гарантируются. Скомпилированный `dist` всё равно имеет target `bun`.
158
+ Using Bun exclusively provides a single runtime and direct access to `bun:sqlite`, `Bun.connect`,
159
+ `Bun.zstdDecompress`, `Bun.file`, and the built-in WebSocket implementation. The tradeoff is that the
160
+ package cannot run in Node.js, Deno, Cloudflare Workers, or most serverless platforms without Bun.
161
+ Node-specific test tooling and APM integrations are not guaranteed to work. The compiled `dist`
162
+ output still targets Bun.
160
163
 
161
- ## Статус совместимости
164
+ ## API conventions
162
165
 
163
- Базовая линия: PyMax 2.3.1, commit `8c40b71`. Детали зафиксированы в [UPSTREAM.md](./UPSTREAM.md).
164
- Публичный API сделан идиоматичным для TypeScript: `camelCase`, `bigint`, именованные методы событий и
165
- явные providers для интерактивной аутентификации.
166
+ The public API follows TypeScript conventions: `camelCase`, `bigint` identifiers, named event
167
+ methods, and explicit providers for interactive authentication.
166
168
 
167
- Лицензия: MIT. Проект содержит самостоятельную TypeScript-реализацию протокола и сохраняет
168
- атрибуцию исходному PyMax.
169
+ Licensed under the MIT License. This project is unofficial and is not affiliated with MAX.
package/package.json CHANGED
@@ -1,9 +1,17 @@
1
1
  {
2
2
  "name": "@bruch/max-client",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Unofficial Bun/TypeScript client for the Max messenger internal API",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/sibstark/tsmax.git"
10
+ },
11
+ "homepage": "https://github.com/sibstark/tsmax#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/sibstark/tsmax/issues"
14
+ },
7
15
  "engines": {
8
16
  "bun": ">=1.3.0"
9
17
  },
@@ -49,8 +57,7 @@
49
57
  "dist",
50
58
  "src",
51
59
  "README.md",
52
- "LICENSE",
53
- "UPSTREAM.md"
60
+ "LICENSE"
54
61
  ],
55
62
  "scripts": {
56
63
  "build": "bun run clean && bun build src/index.ts src/auth/index.ts src/files/index.ts src/protocol/index.ts src/session/index.ts src/telemetry/index.ts src/types/index.ts --outdir dist --target bun --format esm --packages external --sourcemap=external && tsc -p tsconfig.build.json",
package/UPSTREAM.md DELETED
@@ -1,10 +0,0 @@
1
- # Upstream
2
-
3
- `tsmax` is a TypeScript/Bun port of [MaxApiTeam/PyMax](https://github.com/MaxApiTeam/PyMax).
4
-
5
- - Compatibility baseline: PyMax 2.3.1
6
- - Git commit: `8c40b71`
7
- - Upstream license: MIT
8
-
9
- The local `PyMax/` checkout is used only as a development reference and is not included in the
10
- published package.