@myronsi/messenger-api 2.1.0-alpha.2.next.63 → 2.1.0-alpha.21

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.
package/dist/ws-docs.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "markdown": "# WebSocket protocol (API contract v2)\r\n\r\nThe JSON Schemas in `websocket/client/` (client → server) and `websocket/server/` (server → client) are the source of truth. Every event has an example in `websocket/examples/`, validated against its schema by `npm run check`. TypeScript types are generated into `dist/ws-events.d.ts` (`ClientEvent`, `ServerEvent`).\r\n\r\n## Connecting\r\n\r\n1. `POST /api/v2/ws/ticket` (authenticated) returns `{ \"ticket\": \"…\", \"expires_in\": 30 }`. The ticket is single-use and short-lived, so no access token ends up in a URL or a log.\r\n2. Open **one connection per browser tab**: `wss://<host>/api/v2/ws?ticket=<ticket>&api_version=<contract version>`. The connection carries the events of all chats of the user. `api_version` is optional and takes the place of the `X-Client-Api-Version` header, which browsers cannot send on a WebSocket.\r\n3. The first server event is `hello` with `api_version` and `min_client_api_version`. A client that reconnects after a deploy compares them with the contract version it was built for and shows an upgrade notice instead of failing at random.\r\n4. When the ticket is invalid or expired the server closes the connection with code `4401`. A client whose `api_version` is no longer served is closed with `4426` after `hello`.\r\n\r\n## Close codes\r\n\r\n| Code | Meaning | Client |\r\n| --- | --- | --- |\r\n| `1012` | `reconnect`: the server is restarting, or it lost its pub/sub connection and events may be missing | reconnect with backoff, then load what was missed (`after` cursor) |\r\n| `1013` | the client did not keep up with its events | reconnect, then catch up |\r\n| `4401` | invalid ticket, or the session ended (logout, revoked, password changed) | get a new ticket; if that fails, sign in again |\r\n| `4426` | the client's contract version is no longer served | show the upgrade notice |\r\n\r\n## Envelope\r\n\r\nServer → client:\r\n\r\n```json\r\n{ \"type\": \"message\", \"event_id\": \"7217400317439950849\", \"chat_id\": \"42\", \"data\": { \"message\": { \"…\": \"…\" } } }\r\n```\r\n\r\nClient → server:\r\n\r\n```json\r\n{ \"type\": \"message\", \"client_temp_id\": \"c-1\", \"chat_id\": \"42\", \"data\": { \"type\": \"text\", \"content\": \"Hello!\" } }\r\n```\r\n\r\n- All IDs are strings (Snowflake IDs do not fit into a JavaScript number).\r\n- `event_id` is unique and increases per server; it is only for deduplication and logs.\r\n- `chat_id` is always `null` in `hello`, `presence` and `approval_request_created`, which do not belong to a chat. `ack` and `error` repeat the `chat_id` of the client event they answer, and it is `null` for connection-level errors.\r\n- Unknown event `type`s must be ignored by clients, so new event types are not a breaking change.\r\n- A user who is removed from a chat (or whose chat is deleted) receives `chat_deleted` and no further events of that chat.\r\n\r\n## Acknowledgements\r\n\r\nEvery client event except `typing` (which is not acknowledged and carries no `client_temp_id`) has a `client_temp_id` (1–64 characters, unique per client). The server answers with exactly one of:\r\n\r\n- `ack` — `client_temp_id`, and for `message` the stored `message_id` and `created_at`. Sending the same `client_temp_id` again returns the same `ack` (idempotent), which makes retries after a reconnect safe.\r\n- `error` — `client_temp_id` and `data.code`/`data.message`. `code` is one of the stable codes of `ErrorCode` in `openapi.yaml` (the same codes as the REST `application/problem+json` errors).\r\n\r\nThe sender also receives the broadcast `message` event with the stored message (its `client_temp_id` is included, so the client can replace its pending copy).\r\n\r\n## Client → server events\r\n\r\n| Type | Purpose |\r\n| --- | --- |\r\n| `message` | Send a message (`type` `text`, `file` or `voice`; files are referenced by `attachment_id`, never by URL) |\r\n| `resend` | Deliver a stored but undelivered message again |\r\n| `edit` | Edit your own text message |\r\n| `delete` | Delete a message for yourself (`scope: me`) or everyone |\r\n| `read` | Mark messages as read up to `message_id` |\r\n| `reaction_add`, `reaction_remove` | Add or remove a reaction |\r\n| `typing` | Typing indicator (not acknowledged) |\r\n\r\n## Server → client events\r\n\r\n| Type | Meaning |\r\n| --- | --- |\r\n| `hello` | First event: `api_version`, `min_client_api_version`, `user_id` |\r\n| `ack`, `error` | Result of a client event, references `client_temp_id` |\r\n| `message`, `edit`, `delete` | Message created, edited or deleted |\r\n| `reaction_add`, `reaction_remove` | Reactions changed |\r\n| `read` | A user read up to `message_id` |\r\n| `typing` | A user is typing |\r\n| `chat_created`, `chat_deleted`, `chat_list_update` | Chat list changes |\r\n| `group_created`, `group_updated` | Group changes (members, roles, name, avatar) |\r\n| `approval_request_created` | New request in the inbox |\r\n| `presence` | A user came online or went offline |\r\n\r\n## Compatibility\r\n\r\nAdding an event type or an optional field is a MINOR change; removing or renaming an event or field, or making a field required, is MAJOR (see `docs/api-compatibility.md`). Clients must ignore unknown events and unknown fields.\r\n",
2
+ "markdown": "# WebSocket protocol (API contract v2)\r\n\r\nThe JSON Schemas in `websocket/client/` (client → server) and `websocket/server/` (server → client) are the source of truth. Every event has an example in `websocket/examples/`, validated against its schema by `npm run check`. TypeScript types are generated into `dist/ws-events.d.ts` (`ClientEvent`, `ServerEvent`).\r\n\r\n## Connecting\r\n\r\n1. `POST /api/v2/ws/ticket` (authenticated) returns `{ \"ticket\": \"…\", \"expires_in\": 30 }`. The ticket is single-use and short-lived, so no access token ends up in a URL or a log.\r\n2. Open **one connection per browser tab**: `wss://<host>/api/v2/ws?ticket=<ticket>&api_version=<contract version>`. The connection carries the events of all chats of the user. `api_version` is optional and takes the place of the `X-Client-Api-Version` header, which browsers cannot send on a WebSocket.\r\n3. The first server event is `hello` with `api_version` and `min_client_api_version`. A client that reconnects after a deploy compares them with the contract version it was built for and shows an upgrade notice instead of failing at random.\r\n4. When the ticket is invalid or expired the server closes the connection with code `4401`. A client whose `api_version` is no longer served is closed with `4426` after `hello`.\r\n\r\n## Close codes\r\n\r\n| Code | Meaning | Client |\r\n| --- | --- | --- |\r\n| `1012` | `reconnect`: the server is restarting, or it lost its pub/sub connection and events may be missing | reconnect with backoff, then load what was missed (`after` cursor) |\r\n| `1013` | the client did not keep up with its events, or sent more than 64 events that are not handled yet | reconnect, then catch up |\r\n| `4401` | invalid ticket, or the session ended (logout, revoked, password changed) | get a new ticket; if that fails, sign in again |\r\n| `4426` | the client's contract version is no longer served | show the upgrade notice |\r\n| `4429` | the user opened more than 10 connections on this server; the oldest one is closed | do not reconnect this tab automatically |\r\n\r\n## Envelope\r\n\r\nServer → client:\r\n\r\n```json\r\n{ \"type\": \"message\", \"event_id\": \"7217400317439950849\", \"chat_id\": \"42\", \"data\": { \"message\": { \"…\": \"…\" } } }\r\n```\r\n\r\nClient → server:\r\n\r\n```json\r\n{ \"type\": \"message\", \"client_temp_id\": \"c-1\", \"chat_id\": \"42\", \"data\": { \"type\": \"text\", \"content\": \"Hello!\" } }\r\n```\r\n\r\n- All IDs are strings (Snowflake IDs do not fit into a JavaScript number).\r\n- `event_id` is unique and increases per server; it is only for deduplication and logs.\r\n- `chat_id` is always `null` in `hello`, `presence` and `approval_request_created`, which do not belong to a chat. `ack` and `error` repeat the `chat_id` of the client event they answer, and it is `null` for connection-level errors.\r\n- Unknown event `type`s must be ignored by clients, so new event types are not a breaking change.\r\n- A user who is removed from a chat (or whose chat is deleted) receives `chat_deleted` and no further events of that chat.\r\n\r\n## Acknowledgements\r\n\r\nEvery client event except `typing` (which is not acknowledged and carries no `client_temp_id`) has a `client_temp_id` (1–64 characters, unique per client). The server answers with exactly one of:\r\n\r\n- `ack` — `client_temp_id`, and for `message` the stored `message_id` and `created_at`. Sending the same `client_temp_id` again returns the same `ack` (idempotent), which makes retries after a reconnect safe.\r\n- `error` — `client_temp_id` and `data.code`/`data.message`. `code` is one of the stable codes of `ErrorCode` in `openapi.yaml` (the same codes as the REST `application/problem+json` errors).\r\n\r\nThe sender also receives the broadcast `message` event with the stored message (its `client_temp_id` is included, so the client can replace its pending copy).\r\n\r\n## Client → server events\r\n\r\n| Type | Purpose |\r\n| --- | --- |\r\n| `message` | Send a message (`type` `text`, `file` or `voice`; files are referenced by `attachment_id`, never by URL) |\r\n| `resend` | Deliver a stored but undelivered message again |\r\n| `edit` | Edit your own text message |\r\n| `delete` | Delete a message for yourself (`scope: me`) or everyone |\r\n| `read` | Mark messages as read up to `message_id` |\r\n| `reaction_add`, `reaction_remove` | Add or remove a reaction |\r\n| `typing` | Typing or recording a voice message (`action`, not acknowledged). Repeat `is_typing: true` every 3 s while it lasts, send `false` when it ends |\r\n\r\n## Server → client events\r\n\r\n| Type | Meaning |\r\n| --- | --- |\r\n| `hello` | First event: `api_version`, `min_client_api_version`, `user_id` |\r\n| `ack`, `error` | Result of a client event, references `client_temp_id` |\r\n| `message`, `edit`, `delete` | Message created, edited or deleted |\r\n| `reaction_add`, `reaction_remove` | Reactions changed |\r\n| `read` | A user read up to `message_id` |\r\n| `typing` | A user is typing or recording a voice message (`action`); hide it after 6 s without a repeat |\r\n| `chat_created`, `chat_deleted`, `chat_list_update` | Chat list changes |\r\n| `group_created`, `group_updated` | Group changes (members, roles, name, avatar) |\r\n| `approval_request_created` | New request in the inbox |\r\n| `presence` | A user came online or went offline |\n| `call_updated` | A call of the chat changed (state, participants, epoch); carries the whole call, keep the highest `version` |\n| `call_keys` | Sealed call sender keys for this session only (`docs/calls-e2ee.md`) |\r\n\r\n## Compatibility\r\n\r\nAdding an event type or an optional field is a MINOR change; removing or renaming an event or field, or making a field required, is MAJOR (see `docs/api-compatibility.md`). Clients must ignore unknown events and unknown fields.\r\n",
3
3
  "examples": {
4
4
  "client/delete.json": {
5
5
  "type": "delete",
@@ -66,7 +66,8 @@
66
66
  "type": "typing",
67
67
  "chat_id": "42",
68
68
  "data": {
69
- "is_typing": true
69
+ "is_typing": true,
70
+ "action": "recording_voice"
70
71
  }
71
72
  },
72
73
  "server/ack.json": {
@@ -104,6 +105,70 @@
104
105
  }
105
106
  }
106
107
  },
108
+ "server/call_keys.json": {
109
+ "type": "call_keys",
110
+ "event_id": "7217400317439950111",
111
+ "chat_id": "77",
112
+ "data": {
113
+ "call_id": "7217400317439950100",
114
+ "epoch": 2,
115
+ "items": [
116
+ {
117
+ "epoch": 2,
118
+ "sender_user_id": "1002",
119
+ "sender_session_id": "9c1d2e3f-4a5b-4c6d-8e7f-001122334455",
120
+ "recipient_session_id": "5b0e8f0a-3f1c-4a52-9a8e-0d6e1c3f9b21",
121
+ "enc": "BJCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC",
122
+ "ciphertext": "DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"
123
+ }
124
+ ]
125
+ }
126
+ },
127
+ "server/call_updated.json": {
128
+ "type": "call_updated",
129
+ "event_id": "7217400317439950110",
130
+ "chat_id": "77",
131
+ "data": {
132
+ "call": {
133
+ "id": "7217400317439950100",
134
+ "chat_id": "77",
135
+ "kind": "group",
136
+ "state": "active",
137
+ "end_reason": null,
138
+ "initiator_id": "1001",
139
+ "created_at": "2026-11-07T12:00:00Z",
140
+ "started_at": "2026-11-07T12:00:05Z",
141
+ "ended_at": null,
142
+ "ring_expires_at": "2026-11-07T12:00:30Z",
143
+ "epoch": 2,
144
+ "version": 4,
145
+ "max_participants": 10,
146
+ "participants": [
147
+ {
148
+ "user_id": "1001",
149
+ "state": "joined",
150
+ "session_id": "5b0e8f0a-3f1c-4a52-9a8e-0d6e1c3f9b21",
151
+ "identity_key": "BAt2AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
152
+ "joined_at": "2026-11-07T12:00:01Z"
153
+ },
154
+ {
155
+ "user_id": "1002",
156
+ "state": "joined",
157
+ "session_id": "9c1d2e3f-4a5b-4c6d-8e7f-001122334455",
158
+ "identity_key": "BHk9BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB",
159
+ "joined_at": "2026-11-07T12:00:05Z"
160
+ },
161
+ {
162
+ "user_id": "1003",
163
+ "state": "ringing",
164
+ "session_id": null,
165
+ "identity_key": null,
166
+ "joined_at": null
167
+ }
168
+ ]
169
+ }
170
+ }
171
+ },
107
172
  "server/chat_created.json": {
108
173
  "type": "chat_created",
109
174
  "event_id": "7217400317439950009",
@@ -415,6 +480,36 @@
415
480
  "read_at": "2026-10-04T12:00:00Z"
416
481
  }
417
482
  },
483
+ "server/recovery_request.json": {
484
+ "type": "recovery_request",
485
+ "event_id": "7217400317439950849",
486
+ "chat_id": null,
487
+ "data": {
488
+ "request_id": "z8uFZt0xFYtjm_iO3vI9xFYxsy7xM4K5uM1g1s8YbYI",
489
+ "user_agent": "Chrome on Windows",
490
+ "location": {
491
+ "city": "Berlin",
492
+ "country_code": "DE",
493
+ "country": "Germany"
494
+ },
495
+ "choices": [
496
+ 17,
497
+ 42,
498
+ 85
499
+ ],
500
+ "expires_at": "2026-11-05T20:00:00Z"
501
+ }
502
+ },
503
+ "server/security_alert.json": {
504
+ "type": "security_alert",
505
+ "event_id": "7217400317439950010",
506
+ "chat_id": null,
507
+ "data": {
508
+ "type": "login",
509
+ "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/140.0",
510
+ "created_at": "2026-11-06T12:00:00Z"
511
+ }
512
+ },
418
513
  "server/security_notice.json": {
419
514
  "type": "security_notice",
420
515
  "event_id": "7217400317439950009",
@@ -429,7 +524,8 @@
429
524
  "chat_id": "42",
430
525
  "data": {
431
526
  "user_id": "1002",
432
- "is_typing": true
527
+ "is_typing": true,
528
+ "action": "recording_voice"
433
529
  }
434
530
  }
435
531
  }
@@ -1,4 +1,4 @@
1
- /* Generated from api/openapi.yaml 2.1.0-alpha.2. Do not edit. */
1
+ /* Generated from api/openapi.yaml 2.1.0-alpha.21. Do not edit. */
2
2
 
3
3
  /**
4
4
  * Any WebSocket event, in either direction.
@@ -34,6 +34,8 @@ export type AttachmentRef = string;
34
34
  export type ServerEvent =
35
35
  | ServerAckEvent
36
36
  | ServerApprovalRequestCreatedEvent
37
+ | ServerCallKeysEvent
38
+ | ServerCallUpdatedEvent
37
39
  | ServerChatCreatedEvent
38
40
  | ServerChatDeletedEvent
39
41
  | ServerChatListUpdateEvent
@@ -48,16 +50,44 @@ export type ServerEvent =
48
50
  | ServerReactionAddEvent
49
51
  | ServerReactionRemoveEvent
50
52
  | ServerReadEvent
53
+ | ServerRecoveryRequestEvent
54
+ | ServerSecurityAlertEvent
51
55
  | ServerSecurityNoticeEvent
52
56
  | ServerTypingEvent;
53
57
  export type Timestamp = string;
54
58
  export type ApprovalRequestType = "direct_message" | "group_invite";
55
59
  export type ApprovalRequestStatus = "pending" | "approved" | "rejected";
56
60
  export type Username = string;
61
+ /**
62
+ * `ringing` until someone answers, `active` while people are in it, `ended` afterwards.
63
+ */
64
+ export type CallState = "ringing" | "active" | "ended";
65
+ /**
66
+ * Why the call ended: `completed` (people talked), `missed` (nobody answered in time), `declined` (the peer of a
67
+ * direct call declined), `cancelled` (the caller hung up before an answer), `failed` (the media service lost
68
+ * the call).
69
+ *
70
+ */
71
+ export type CallEndReason = "completed" | "missed" | "declined" | "cancelled" | "failed";
72
+ /**
73
+ * `left` and `declined` can become `joined` again in a group call.
74
+ */
75
+ export type CallParticipantState = "ringing" | "joined" | "declined" | "missed" | "left";
76
+ /**
77
+ * P-256 public key as an uncompressed point (65 bytes, first byte `0x04`), base64url without padding.
78
+ *
79
+ */
80
+ export type CallIdentityKey = string;
57
81
  export type ChatType = "direct" | "group";
58
- export type MessageType = "text" | "file" | "voice" | "system";
82
+ export type MessageType = "text" | "file" | "voice" | "system" | "sticker";
59
83
  export type AttachmentKind = "image" | "audio" | "voice" | "video" | "file";
60
- export type GroupRole = "owner" | "admin" | "member";
84
+ export type StickerPackSlug = string;
85
+ export type SystemEventKind =
86
+ "group_created" | "member_added" | "member_joined" | "member_removed" | "member_left" | "call";
87
+ /**
88
+ * A moderator may delete other members' messages; owners and admins also manage the group.
89
+ */
90
+ export type GroupRole = "owner" | "admin" | "moderator" | "member";
61
91
  /**
62
92
  * Stable machine-readable error code. New codes can appear in MINOR versions; unknown
63
93
  * codes must be treated like `internal_error`.
@@ -82,6 +112,16 @@ export type ErrorCode =
82
112
  | "invalid_client_version"
83
113
  | "blocked_by_user"
84
114
  | "approval_required"
115
+ | "user_verification_required"
116
+ | "session_too_new"
117
+ | "calls_unavailable"
118
+ | "calls_not_allowed"
119
+ | "call_identity_required"
120
+ | "call_full"
121
+ | "call_ended"
122
+ | "already_in_call"
123
+ | "stale_epoch"
124
+ | "limit_reached"
85
125
  | "internal_error";
86
126
 
87
127
  /**
@@ -97,7 +137,7 @@ export interface ClientDeleteEvent {
97
137
  };
98
138
  }
99
139
  /**
100
- * Edit your own text message.
140
+ * Edit your own text message or the caption of your file. An empty content removes a file's caption.
101
141
  */
102
142
  export interface ClientEditEvent {
103
143
  type: "edit";
@@ -181,13 +221,17 @@ export interface ClientResendEvent {
181
221
  };
182
222
  }
183
223
  /**
184
- * Tell the chat that you are (not) typing. Not acknowledged, so it carries no `client_temp_id`.
224
+ * Tell the chat that you are (not) typing or recording a voice message. Not acknowledged, so it carries no `client_temp_id`. Send `is_typing: true` again every few seconds while it lasts and `false` when it ends; receivers hide it when it is not repeated. Dropped when your `typing_indicators_enabled` privacy setting is off.
185
225
  */
186
226
  export interface ClientTypingEvent {
187
227
  type: "typing";
188
228
  chat_id: Id;
189
229
  data: {
190
230
  is_typing: boolean;
231
+ /**
232
+ * What you are doing. Without it, `typing`.
233
+ */
234
+ action?: "typing" | "recording_voice";
191
235
  };
192
236
  }
193
237
  /**
@@ -253,7 +297,7 @@ export interface User {
253
297
  */
254
298
  contact_name?: string | null;
255
299
  /**
256
- * Path of the avatar, always same-origin (`/api/v2/users/{id}/avatar`).
300
+ * Path of the avatar, always same-origin (`/api/v2/users/{id}/avatar?rev={revision}`).
257
301
  */
258
302
  avatar_url: string | null;
259
303
  bio: string | null;
@@ -261,6 +305,95 @@ export interface User {
261
305
  last_seen: Timestamp | null;
262
306
  is_deleted: boolean;
263
307
  }
308
+ /**
309
+ * Sealed sender keys for this session (see docs/calls-e2ee.md). Sent only to the recipient session.
310
+ */
311
+ export interface ServerCallKeysEvent {
312
+ type: "call_keys";
313
+ event_id: Id;
314
+ chat_id: Id;
315
+ data: CallKeyEnvelopeList;
316
+ }
317
+ export interface CallKeyEnvelopeList {
318
+ call_id: Id;
319
+ epoch: number;
320
+ items: CallKeyEnvelope[];
321
+ }
322
+ /**
323
+ * An HPKE Auth-mode envelope carrying one sender key (see `docs/calls-e2ee.md`).
324
+ */
325
+ export interface CallKeyEnvelope {
326
+ epoch: number;
327
+ sender_user_id: Id;
328
+ sender_session_id: string;
329
+ recipient_session_id: string;
330
+ /**
331
+ * HPKE encapsulated key, base64url without padding.
332
+ */
333
+ enc: string;
334
+ /**
335
+ * Sealed sender key, base64url without padding.
336
+ */
337
+ ciphertext: string;
338
+ }
339
+ /**
340
+ * A call of the chat started, rang, changed participants or epoch, or ended. Carries the whole call; keep the one with the highest `version`. Sent to every member of the chat.
341
+ */
342
+ export interface ServerCallUpdatedEvent {
343
+ type: "call_updated";
344
+ event_id: Id;
345
+ chat_id: Id;
346
+ data: {
347
+ call: Call;
348
+ };
349
+ }
350
+ export interface Call {
351
+ id: Id;
352
+ chat_id: Id;
353
+ kind: "direct" | "group";
354
+ state: CallState;
355
+ end_reason: CallEndReason | null;
356
+ initiator_id: Id;
357
+ created_at: Timestamp;
358
+ /**
359
+ * First answer; `null` while nobody answered.
360
+ */
361
+ started_at: Timestamp | null;
362
+ ended_at: Timestamp | null;
363
+ /**
364
+ * When ringing invitations of this call turn into `missed`.
365
+ */
366
+ ring_expires_at: string;
367
+ /**
368
+ * Key epoch; increases whenever the set of joined sessions or their identity keys change.
369
+ */
370
+ epoch: number;
371
+ /**
372
+ * Increases with every change of the call; ignore events with a lower version than one already seen.
373
+ */
374
+ version: number;
375
+ max_participants: number;
376
+ /**
377
+ * Everyone invited or joined, the initiator first.
378
+ */
379
+ participants: CallParticipant[];
380
+ }
381
+ export interface CallParticipant {
382
+ user_id: Id;
383
+ state: CallParticipantState;
384
+ /**
385
+ * The session that joined; `null` unless `state` is `joined`.
386
+ */
387
+ session_id: string | null;
388
+ /**
389
+ * Call identity of the joined session; `null` unless `state` is `joined`.
390
+ */
391
+ identity_key: CallIdentityKey | null;
392
+ /**
393
+ * When the participant last joined; `null` if never.
394
+ */
395
+ joined_at: Timestamp | null;
396
+ }
264
397
  /**
265
398
  * A chat was created with you.
266
399
  */
@@ -302,17 +435,47 @@ export interface Message {
302
435
  */
303
436
  sender: User | null;
304
437
  /**
305
- * Text, or the caption of a file; `null` when deleted.
438
+ * Text, the caption of a file, or the emoji of a sticker; `null` when deleted.
306
439
  */
307
440
  content: string | null;
308
441
  attachment: Attachment | null;
309
442
  reply_to: Id | null;
443
+ reply_preview?: ReplyPreview;
310
444
  forwarded_from: ForwardedFrom | null;
445
+ sticker?: Sticker;
446
+ /**
447
+ * Ordered images and videos of an album. The first item is also returned as attachment for older clients.
448
+ *
449
+ * @minItems 2
450
+ * @maxItems 10
451
+ */
452
+ attachments?:
453
+ | [Attachment, Attachment]
454
+ | [Attachment, Attachment, Attachment]
455
+ | [Attachment, Attachment, Attachment, Attachment]
456
+ | [Attachment, Attachment, Attachment, Attachment, Attachment]
457
+ | [Attachment, Attachment, Attachment, Attachment, Attachment, Attachment]
458
+ | [Attachment, Attachment, Attachment, Attachment, Attachment, Attachment, Attachment]
459
+ | [Attachment, Attachment, Attachment, Attachment, Attachment, Attachment, Attachment, Attachment]
460
+ | [Attachment, Attachment, Attachment, Attachment, Attachment, Attachment, Attachment, Attachment, Attachment]
461
+ | [
462
+ Attachment,
463
+ Attachment,
464
+ Attachment,
465
+ Attachment,
466
+ Attachment,
467
+ Attachment,
468
+ Attachment,
469
+ Attachment,
470
+ Attachment,
471
+ Attachment
472
+ ];
311
473
  reactions: Reaction[];
312
474
  read_by: ReadReceipt[];
313
475
  created_at: Timestamp;
314
476
  edited_at: Timestamp | null;
315
477
  is_deleted: boolean;
478
+ system_event?: SystemEvent;
316
479
  client_temp_id?: ClientTempId;
317
480
  }
318
481
  export interface Attachment {
@@ -334,14 +497,102 @@ export interface Attachment {
334
497
  width?: number | null;
335
498
  height?: number | null;
336
499
  thumbnail_url?: string | null;
500
+ /**
501
+ * A JPEG of at most 1600 px to show in an image viewer instead of the original; `null` for small images and GIFs, which are shown as they are.
502
+ */
503
+ display_url?: string | null;
337
504
  duration_ms?: number | null;
338
505
  waveform?: number[] | null;
506
+ drawing?: Drawing;
507
+ }
508
+ /**
509
+ * What the sender drew on this image of this message. Clients show the image with the drawing on top
510
+ * and never without it. Absent when the image has no drawing. The same image can carry another drawing
511
+ * in another message.
512
+ *
513
+ */
514
+ export interface Drawing {
515
+ version: number;
516
+ /**
517
+ * @minItems 1
518
+ * @maxItems 200
519
+ */
520
+ items: [DrawingItem, ...DrawingItem[]];
521
+ }
522
+ export interface DrawingItem {
523
+ type: "stroke" | "text";
524
+ color: string;
525
+ /**
526
+ * Stroke only. Line width as a fraction of the image width.
527
+ */
528
+ width?: number;
529
+ /**
530
+ * Stroke only. Flat list of x, y pairs. A drawing has at most 10000 numbers in all its strokes.
531
+ *
532
+ * @minItems 2
533
+ * @maxItems 10000
534
+ */
535
+ points?: [number, number, ...number[]];
536
+ /**
537
+ * Text only. Left edge of the label.
538
+ */
539
+ x?: number;
540
+ /**
541
+ * Text only. Top edge of the label.
542
+ */
543
+ y?: number;
544
+ /**
545
+ * Text only. Font height as a fraction of the image height.
546
+ */
547
+ size?: number;
548
+ /**
549
+ * Text only.
550
+ */
551
+ text?: string;
552
+ }
553
+ /**
554
+ * What a reply shows of the message it answers, so a client can draw the quote without loading that
555
+ * message. Set on messages of history pages and `message` events when the recipient can see the answered
556
+ * message; absent when it is gone or hidden for them, and on chat-list previews and search results.
557
+ *
558
+ */
559
+ export interface ReplyPreview {
560
+ id: Id;
561
+ type: MessageType;
562
+ sender: User | null;
563
+ /**
564
+ * The first 100 characters of the text or caption; `null` when deleted or empty.
565
+ */
566
+ content: string | null;
567
+ attachment: Attachment | null;
568
+ is_deleted: boolean;
339
569
  }
340
570
  export interface ForwardedFrom {
341
571
  message_id: Id;
342
572
  sender_id: Id | null;
343
573
  sender_name: string;
344
574
  }
575
+ /**
576
+ * The sticker of a `sticker` message; absent for other types and when deleted. `attachment` carries the
577
+ * same image, so older clients show a sticker as a picture.
578
+ *
579
+ */
580
+ export interface Sticker {
581
+ id: Id;
582
+ pack_id: Id;
583
+ /**
584
+ * The share link of the sticker's pack when a user made it; missing for built-in packs. A client that
585
+ * shows the pack of a sticker someone sent opens it with `GET /stickers/links/{slug}`.
586
+ *
587
+ */
588
+ pack_slug?: StickerPackSlug;
589
+ /**
590
+ * The emoji the sticker stands for, for previews, notifications and search.
591
+ */
592
+ emoji: string;
593
+ is_animated: boolean;
594
+ image: Attachment;
595
+ }
345
596
  export interface Reaction {
346
597
  emoji: string;
347
598
  user_id: Id;
@@ -350,6 +601,33 @@ export interface ReadReceipt {
350
601
  user_id: Id;
351
602
  read_at: Timestamp;
352
603
  }
604
+ /**
605
+ * What a `system` message records; set on system messages only, whose `content` is then `null`. The names
606
+ * are the display names at the time of the event. `target` fields are set for `member_added` and
607
+ * `member_removed`. `call` is set for `call` messages: one per call, posted when the call ends, `actor` is the
608
+ * initiator.
609
+ *
610
+ */
611
+ export interface SystemEvent {
612
+ kind: SystemEventKind;
613
+ actor_id: Id | null;
614
+ actor_name: string;
615
+ target_id?: Id;
616
+ target_name?: string;
617
+ call?: CallSummary;
618
+ }
619
+ /**
620
+ * The call a `call` system message records.
621
+ */
622
+ export interface CallSummary {
623
+ call_id: Id;
624
+ kind: "direct" | "group";
625
+ outcome: CallEndReason;
626
+ /**
627
+ * From the first answer to the end; `null` if nobody answered.
628
+ */
629
+ duration_seconds: number | null;
630
+ }
353
631
  /**
354
632
  * A chat was deleted, or you were removed from it.
355
633
  */
@@ -517,6 +795,72 @@ export interface ServerReadEvent {
517
795
  read_at: Timestamp;
518
796
  };
519
797
  }
798
+ export interface ServerRecoveryRequestEvent {
799
+ type: "recovery_request";
800
+ event_id: string;
801
+ chat_id: null;
802
+ data: {
803
+ /**
804
+ * Approval handle for POST /auth/recovery-requests/{requestId}/approve and /deny. It is not the requester's capability.
805
+ */
806
+ request_id: string;
807
+ user_agent: string;
808
+ location: Location | null;
809
+ /**
810
+ * @minItems 3
811
+ * @maxItems 3
812
+ */
813
+ choices: [number, number, number];
814
+ expires_at: string;
815
+ };
816
+ }
817
+ /**
818
+ * Approximate location of a client address, looked up in an offline GeoIP database (IP geolocation by
819
+ * DB-IP, https://db-ip.com, CC BY 4.0). The address itself is never exposed. Each field is `null` when the
820
+ * database does not know it; clients localise the country name from `country_code`.
821
+ *
822
+ */
823
+ export interface Location {
824
+ /**
825
+ * City name in English
826
+ */
827
+ city: string | null;
828
+ /**
829
+ * ISO 3166-1 alpha-2 country code
830
+ */
831
+ country_code: string | null;
832
+ /**
833
+ * Country name in English
834
+ */
835
+ country: string | null;
836
+ }
837
+ export interface ServerSecurityAlertEvent {
838
+ type: "security_alert";
839
+ event_id: Id;
840
+ chat_id: null;
841
+ data: {
842
+ type:
843
+ | "password_changed"
844
+ | "recovery_key_changed"
845
+ | "2fa_enabled"
846
+ | "2fa_disabled"
847
+ | "passkey_added"
848
+ | "passkey_removed"
849
+ | "recovery_email_changed"
850
+ | "recovery_email_removed"
851
+ | "passkey_counter_warning"
852
+ | "login"
853
+ | "login_2fa"
854
+ | "passkey_login"
855
+ | "qr_login_approved";
856
+ user_agent?: string;
857
+ created_at?: string;
858
+ /**
859
+ * The session that made the change, when a signed-in session made it. Clients skip alerts for their own session.
860
+ */
861
+ session_id?: string;
862
+ };
863
+ }
520
864
  export interface ServerSecurityNoticeEvent {
521
865
  type: "security_notice";
522
866
  event_id: Id;
@@ -526,7 +870,7 @@ export interface ServerSecurityNoticeEvent {
526
870
  };
527
871
  }
528
872
  /**
529
- * A user started or stopped typing.
873
+ * A user started or stopped typing or recording a voice message. Hide it after about 6 seconds without a repeat: the sender may disconnect before it sends `false`.
530
874
  */
531
875
  export interface ServerTypingEvent {
532
876
  type: "typing";
@@ -535,5 +879,9 @@ export interface ServerTypingEvent {
535
879
  data: {
536
880
  user_id: Id;
537
881
  is_typing: boolean;
882
+ /**
883
+ * What the user is doing. New values may be added: show an unknown one like `typing`.
884
+ */
885
+ action: "typing" | "recording_voice";
538
886
  };
539
887
  }