@myronsi/messenger-api 2.1.0-alpha.2.next.63 → 2.1.0-alpha.20.next.97
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/CHANGELOG.md +209 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/openapi.yaml +3114 -187
- package/dist/schema.d.ts +6132 -1747
- package/dist/ws-docs.json +99 -3
- package/dist/ws-events.d.ts +348 -8
- package/dist/ws-events.schema.json +2113 -178
- package/package.json +1 -1
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
|
|
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
|
}
|
package/dist/ws-events.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* Generated from api/openapi.yaml 2.1.0-alpha.
|
|
1
|
+
/* Generated from api/openapi.yaml 2.1.0-alpha.20. 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,43 @@ 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
|
|
84
|
+
export type SystemEventKind =
|
|
85
|
+
"group_created" | "member_added" | "member_joined" | "member_removed" | "member_left" | "call";
|
|
86
|
+
/**
|
|
87
|
+
* A moderator may delete other members' messages; owners and admins also manage the group.
|
|
88
|
+
*/
|
|
89
|
+
export type GroupRole = "owner" | "admin" | "moderator" | "member";
|
|
61
90
|
/**
|
|
62
91
|
* Stable machine-readable error code. New codes can appear in MINOR versions; unknown
|
|
63
92
|
* codes must be treated like `internal_error`.
|
|
@@ -82,6 +111,15 @@ export type ErrorCode =
|
|
|
82
111
|
| "invalid_client_version"
|
|
83
112
|
| "blocked_by_user"
|
|
84
113
|
| "approval_required"
|
|
114
|
+
| "user_verification_required"
|
|
115
|
+
| "session_too_new"
|
|
116
|
+
| "calls_unavailable"
|
|
117
|
+
| "calls_not_allowed"
|
|
118
|
+
| "call_identity_required"
|
|
119
|
+
| "call_full"
|
|
120
|
+
| "call_ended"
|
|
121
|
+
| "already_in_call"
|
|
122
|
+
| "stale_epoch"
|
|
85
123
|
| "internal_error";
|
|
86
124
|
|
|
87
125
|
/**
|
|
@@ -97,7 +135,7 @@ export interface ClientDeleteEvent {
|
|
|
97
135
|
};
|
|
98
136
|
}
|
|
99
137
|
/**
|
|
100
|
-
* Edit your own text message.
|
|
138
|
+
* Edit your own text message or the caption of your file. An empty content removes a file's caption.
|
|
101
139
|
*/
|
|
102
140
|
export interface ClientEditEvent {
|
|
103
141
|
type: "edit";
|
|
@@ -181,13 +219,17 @@ export interface ClientResendEvent {
|
|
|
181
219
|
};
|
|
182
220
|
}
|
|
183
221
|
/**
|
|
184
|
-
* Tell the chat that you are (not) typing. Not acknowledged, so it carries no `client_temp_id`.
|
|
222
|
+
* 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
223
|
*/
|
|
186
224
|
export interface ClientTypingEvent {
|
|
187
225
|
type: "typing";
|
|
188
226
|
chat_id: Id;
|
|
189
227
|
data: {
|
|
190
228
|
is_typing: boolean;
|
|
229
|
+
/**
|
|
230
|
+
* What you are doing. Without it, `typing`.
|
|
231
|
+
*/
|
|
232
|
+
action?: "typing" | "recording_voice";
|
|
191
233
|
};
|
|
192
234
|
}
|
|
193
235
|
/**
|
|
@@ -253,7 +295,7 @@ export interface User {
|
|
|
253
295
|
*/
|
|
254
296
|
contact_name?: string | null;
|
|
255
297
|
/**
|
|
256
|
-
* Path of the avatar, always same-origin (`/api/v2/users/{id}/avatar`).
|
|
298
|
+
* Path of the avatar, always same-origin (`/api/v2/users/{id}/avatar?rev={revision}`).
|
|
257
299
|
*/
|
|
258
300
|
avatar_url: string | null;
|
|
259
301
|
bio: string | null;
|
|
@@ -261,6 +303,95 @@ export interface User {
|
|
|
261
303
|
last_seen: Timestamp | null;
|
|
262
304
|
is_deleted: boolean;
|
|
263
305
|
}
|
|
306
|
+
/**
|
|
307
|
+
* Sealed sender keys for this session (see docs/calls-e2ee.md). Sent only to the recipient session.
|
|
308
|
+
*/
|
|
309
|
+
export interface ServerCallKeysEvent {
|
|
310
|
+
type: "call_keys";
|
|
311
|
+
event_id: Id;
|
|
312
|
+
chat_id: Id;
|
|
313
|
+
data: CallKeyEnvelopeList;
|
|
314
|
+
}
|
|
315
|
+
export interface CallKeyEnvelopeList {
|
|
316
|
+
call_id: Id;
|
|
317
|
+
epoch: number;
|
|
318
|
+
items: CallKeyEnvelope[];
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* An HPKE Auth-mode envelope carrying one sender key (see `docs/calls-e2ee.md`).
|
|
322
|
+
*/
|
|
323
|
+
export interface CallKeyEnvelope {
|
|
324
|
+
epoch: number;
|
|
325
|
+
sender_user_id: Id;
|
|
326
|
+
sender_session_id: string;
|
|
327
|
+
recipient_session_id: string;
|
|
328
|
+
/**
|
|
329
|
+
* HPKE encapsulated key, base64url without padding.
|
|
330
|
+
*/
|
|
331
|
+
enc: string;
|
|
332
|
+
/**
|
|
333
|
+
* Sealed sender key, base64url without padding.
|
|
334
|
+
*/
|
|
335
|
+
ciphertext: string;
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* 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.
|
|
339
|
+
*/
|
|
340
|
+
export interface ServerCallUpdatedEvent {
|
|
341
|
+
type: "call_updated";
|
|
342
|
+
event_id: Id;
|
|
343
|
+
chat_id: Id;
|
|
344
|
+
data: {
|
|
345
|
+
call: Call;
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
export interface Call {
|
|
349
|
+
id: Id;
|
|
350
|
+
chat_id: Id;
|
|
351
|
+
kind: "direct" | "group";
|
|
352
|
+
state: CallState;
|
|
353
|
+
end_reason: CallEndReason | null;
|
|
354
|
+
initiator_id: Id;
|
|
355
|
+
created_at: Timestamp;
|
|
356
|
+
/**
|
|
357
|
+
* First answer; `null` while nobody answered.
|
|
358
|
+
*/
|
|
359
|
+
started_at: Timestamp | null;
|
|
360
|
+
ended_at: Timestamp | null;
|
|
361
|
+
/**
|
|
362
|
+
* When ringing invitations of this call turn into `missed`.
|
|
363
|
+
*/
|
|
364
|
+
ring_expires_at: string;
|
|
365
|
+
/**
|
|
366
|
+
* Key epoch; increases whenever the set of joined sessions or their identity keys change.
|
|
367
|
+
*/
|
|
368
|
+
epoch: number;
|
|
369
|
+
/**
|
|
370
|
+
* Increases with every change of the call; ignore events with a lower version than one already seen.
|
|
371
|
+
*/
|
|
372
|
+
version: number;
|
|
373
|
+
max_participants: number;
|
|
374
|
+
/**
|
|
375
|
+
* Everyone invited or joined, the initiator first.
|
|
376
|
+
*/
|
|
377
|
+
participants: CallParticipant[];
|
|
378
|
+
}
|
|
379
|
+
export interface CallParticipant {
|
|
380
|
+
user_id: Id;
|
|
381
|
+
state: CallParticipantState;
|
|
382
|
+
/**
|
|
383
|
+
* The session that joined; `null` unless `state` is `joined`.
|
|
384
|
+
*/
|
|
385
|
+
session_id: string | null;
|
|
386
|
+
/**
|
|
387
|
+
* Call identity of the joined session; `null` unless `state` is `joined`.
|
|
388
|
+
*/
|
|
389
|
+
identity_key: CallIdentityKey | null;
|
|
390
|
+
/**
|
|
391
|
+
* When the participant last joined; `null` if never.
|
|
392
|
+
*/
|
|
393
|
+
joined_at: Timestamp | null;
|
|
394
|
+
}
|
|
264
395
|
/**
|
|
265
396
|
* A chat was created with you.
|
|
266
397
|
*/
|
|
@@ -302,17 +433,47 @@ export interface Message {
|
|
|
302
433
|
*/
|
|
303
434
|
sender: User | null;
|
|
304
435
|
/**
|
|
305
|
-
* Text, or the
|
|
436
|
+
* Text, the caption of a file, or the emoji of a sticker; `null` when deleted.
|
|
306
437
|
*/
|
|
307
438
|
content: string | null;
|
|
308
439
|
attachment: Attachment | null;
|
|
309
440
|
reply_to: Id | null;
|
|
441
|
+
reply_preview?: ReplyPreview;
|
|
310
442
|
forwarded_from: ForwardedFrom | null;
|
|
443
|
+
sticker?: Sticker;
|
|
444
|
+
/**
|
|
445
|
+
* Ordered images and videos of an album. The first item is also returned as attachment for older clients.
|
|
446
|
+
*
|
|
447
|
+
* @minItems 2
|
|
448
|
+
* @maxItems 10
|
|
449
|
+
*/
|
|
450
|
+
attachments?:
|
|
451
|
+
| [Attachment, Attachment]
|
|
452
|
+
| [Attachment, Attachment, Attachment]
|
|
453
|
+
| [Attachment, Attachment, Attachment, Attachment]
|
|
454
|
+
| [Attachment, Attachment, Attachment, Attachment, Attachment]
|
|
455
|
+
| [Attachment, Attachment, Attachment, Attachment, Attachment, Attachment]
|
|
456
|
+
| [Attachment, Attachment, Attachment, Attachment, Attachment, Attachment, Attachment]
|
|
457
|
+
| [Attachment, Attachment, Attachment, Attachment, Attachment, Attachment, Attachment, Attachment]
|
|
458
|
+
| [Attachment, Attachment, Attachment, Attachment, Attachment, Attachment, Attachment, Attachment, Attachment]
|
|
459
|
+
| [
|
|
460
|
+
Attachment,
|
|
461
|
+
Attachment,
|
|
462
|
+
Attachment,
|
|
463
|
+
Attachment,
|
|
464
|
+
Attachment,
|
|
465
|
+
Attachment,
|
|
466
|
+
Attachment,
|
|
467
|
+
Attachment,
|
|
468
|
+
Attachment,
|
|
469
|
+
Attachment
|
|
470
|
+
];
|
|
311
471
|
reactions: Reaction[];
|
|
312
472
|
read_by: ReadReceipt[];
|
|
313
473
|
created_at: Timestamp;
|
|
314
474
|
edited_at: Timestamp | null;
|
|
315
475
|
is_deleted: boolean;
|
|
476
|
+
system_event?: SystemEvent;
|
|
316
477
|
client_temp_id?: ClientTempId;
|
|
317
478
|
}
|
|
318
479
|
export interface Attachment {
|
|
@@ -334,14 +495,96 @@ export interface Attachment {
|
|
|
334
495
|
width?: number | null;
|
|
335
496
|
height?: number | null;
|
|
336
497
|
thumbnail_url?: string | null;
|
|
498
|
+
/**
|
|
499
|
+
* 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.
|
|
500
|
+
*/
|
|
501
|
+
display_url?: string | null;
|
|
337
502
|
duration_ms?: number | null;
|
|
338
503
|
waveform?: number[] | null;
|
|
504
|
+
drawing?: Drawing;
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* What the sender drew on this image of this message. Clients show the image with the drawing on top
|
|
508
|
+
* and never without it. Absent when the image has no drawing. The same image can carry another drawing
|
|
509
|
+
* in another message.
|
|
510
|
+
*
|
|
511
|
+
*/
|
|
512
|
+
export interface Drawing {
|
|
513
|
+
version: number;
|
|
514
|
+
/**
|
|
515
|
+
* @minItems 1
|
|
516
|
+
* @maxItems 200
|
|
517
|
+
*/
|
|
518
|
+
items: [DrawingItem, ...DrawingItem[]];
|
|
519
|
+
}
|
|
520
|
+
export interface DrawingItem {
|
|
521
|
+
type: "stroke" | "text";
|
|
522
|
+
color: string;
|
|
523
|
+
/**
|
|
524
|
+
* Stroke only. Line width as a fraction of the image width.
|
|
525
|
+
*/
|
|
526
|
+
width?: number;
|
|
527
|
+
/**
|
|
528
|
+
* Stroke only. Flat list of x, y pairs. A drawing has at most 10000 numbers in all its strokes.
|
|
529
|
+
*
|
|
530
|
+
* @minItems 2
|
|
531
|
+
* @maxItems 10000
|
|
532
|
+
*/
|
|
533
|
+
points?: [number, number, ...number[]];
|
|
534
|
+
/**
|
|
535
|
+
* Text only. Left edge of the label.
|
|
536
|
+
*/
|
|
537
|
+
x?: number;
|
|
538
|
+
/**
|
|
539
|
+
* Text only. Top edge of the label.
|
|
540
|
+
*/
|
|
541
|
+
y?: number;
|
|
542
|
+
/**
|
|
543
|
+
* Text only. Font height as a fraction of the image height.
|
|
544
|
+
*/
|
|
545
|
+
size?: number;
|
|
546
|
+
/**
|
|
547
|
+
* Text only.
|
|
548
|
+
*/
|
|
549
|
+
text?: string;
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* What a reply shows of the message it answers, so a client can draw the quote without loading that
|
|
553
|
+
* message. Set on messages of history pages and `message` events when the recipient can see the answered
|
|
554
|
+
* message; absent when it is gone or hidden for them, and on chat-list previews and search results.
|
|
555
|
+
*
|
|
556
|
+
*/
|
|
557
|
+
export interface ReplyPreview {
|
|
558
|
+
id: Id;
|
|
559
|
+
type: MessageType;
|
|
560
|
+
sender: User | null;
|
|
561
|
+
/**
|
|
562
|
+
* The first 100 characters of the text or caption; `null` when deleted or empty.
|
|
563
|
+
*/
|
|
564
|
+
content: string | null;
|
|
565
|
+
attachment: Attachment | null;
|
|
566
|
+
is_deleted: boolean;
|
|
339
567
|
}
|
|
340
568
|
export interface ForwardedFrom {
|
|
341
569
|
message_id: Id;
|
|
342
570
|
sender_id: Id | null;
|
|
343
571
|
sender_name: string;
|
|
344
572
|
}
|
|
573
|
+
/**
|
|
574
|
+
* The sticker of a `sticker` message; absent for other types and when deleted. `attachment` carries the
|
|
575
|
+
* same image, so older clients show a sticker as a picture.
|
|
576
|
+
*
|
|
577
|
+
*/
|
|
578
|
+
export interface Sticker {
|
|
579
|
+
id: Id;
|
|
580
|
+
pack_id: Id;
|
|
581
|
+
/**
|
|
582
|
+
* The emoji the sticker stands for, for previews, notifications and search.
|
|
583
|
+
*/
|
|
584
|
+
emoji: string;
|
|
585
|
+
is_animated: boolean;
|
|
586
|
+
image: Attachment;
|
|
587
|
+
}
|
|
345
588
|
export interface Reaction {
|
|
346
589
|
emoji: string;
|
|
347
590
|
user_id: Id;
|
|
@@ -350,6 +593,33 @@ export interface ReadReceipt {
|
|
|
350
593
|
user_id: Id;
|
|
351
594
|
read_at: Timestamp;
|
|
352
595
|
}
|
|
596
|
+
/**
|
|
597
|
+
* What a `system` message records; set on system messages only, whose `content` is then `null`. The names
|
|
598
|
+
* are the display names at the time of the event. `target` fields are set for `member_added` and
|
|
599
|
+
* `member_removed`. `call` is set for `call` messages: one per call, posted when the call ends, `actor` is the
|
|
600
|
+
* initiator.
|
|
601
|
+
*
|
|
602
|
+
*/
|
|
603
|
+
export interface SystemEvent {
|
|
604
|
+
kind: SystemEventKind;
|
|
605
|
+
actor_id: Id | null;
|
|
606
|
+
actor_name: string;
|
|
607
|
+
target_id?: Id;
|
|
608
|
+
target_name?: string;
|
|
609
|
+
call?: CallSummary;
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* The call a `call` system message records.
|
|
613
|
+
*/
|
|
614
|
+
export interface CallSummary {
|
|
615
|
+
call_id: Id;
|
|
616
|
+
kind: "direct" | "group";
|
|
617
|
+
outcome: CallEndReason;
|
|
618
|
+
/**
|
|
619
|
+
* From the first answer to the end; `null` if nobody answered.
|
|
620
|
+
*/
|
|
621
|
+
duration_seconds: number | null;
|
|
622
|
+
}
|
|
353
623
|
/**
|
|
354
624
|
* A chat was deleted, or you were removed from it.
|
|
355
625
|
*/
|
|
@@ -517,6 +787,72 @@ export interface ServerReadEvent {
|
|
|
517
787
|
read_at: Timestamp;
|
|
518
788
|
};
|
|
519
789
|
}
|
|
790
|
+
export interface ServerRecoveryRequestEvent {
|
|
791
|
+
type: "recovery_request";
|
|
792
|
+
event_id: string;
|
|
793
|
+
chat_id: null;
|
|
794
|
+
data: {
|
|
795
|
+
/**
|
|
796
|
+
* Approval handle for POST /auth/recovery-requests/{requestId}/approve and /deny. It is not the requester's capability.
|
|
797
|
+
*/
|
|
798
|
+
request_id: string;
|
|
799
|
+
user_agent: string;
|
|
800
|
+
location: Location | null;
|
|
801
|
+
/**
|
|
802
|
+
* @minItems 3
|
|
803
|
+
* @maxItems 3
|
|
804
|
+
*/
|
|
805
|
+
choices: [number, number, number];
|
|
806
|
+
expires_at: string;
|
|
807
|
+
};
|
|
808
|
+
}
|
|
809
|
+
/**
|
|
810
|
+
* Approximate location of a client address, looked up in an offline GeoIP database (IP geolocation by
|
|
811
|
+
* DB-IP, https://db-ip.com, CC BY 4.0). The address itself is never exposed. Each field is `null` when the
|
|
812
|
+
* database does not know it; clients localise the country name from `country_code`.
|
|
813
|
+
*
|
|
814
|
+
*/
|
|
815
|
+
export interface Location {
|
|
816
|
+
/**
|
|
817
|
+
* City name in English
|
|
818
|
+
*/
|
|
819
|
+
city: string | null;
|
|
820
|
+
/**
|
|
821
|
+
* ISO 3166-1 alpha-2 country code
|
|
822
|
+
*/
|
|
823
|
+
country_code: string | null;
|
|
824
|
+
/**
|
|
825
|
+
* Country name in English
|
|
826
|
+
*/
|
|
827
|
+
country: string | null;
|
|
828
|
+
}
|
|
829
|
+
export interface ServerSecurityAlertEvent {
|
|
830
|
+
type: "security_alert";
|
|
831
|
+
event_id: Id;
|
|
832
|
+
chat_id: null;
|
|
833
|
+
data: {
|
|
834
|
+
type:
|
|
835
|
+
| "password_changed"
|
|
836
|
+
| "recovery_key_changed"
|
|
837
|
+
| "2fa_enabled"
|
|
838
|
+
| "2fa_disabled"
|
|
839
|
+
| "passkey_added"
|
|
840
|
+
| "passkey_removed"
|
|
841
|
+
| "recovery_email_changed"
|
|
842
|
+
| "recovery_email_removed"
|
|
843
|
+
| "passkey_counter_warning"
|
|
844
|
+
| "login"
|
|
845
|
+
| "login_2fa"
|
|
846
|
+
| "passkey_login"
|
|
847
|
+
| "qr_login_approved";
|
|
848
|
+
user_agent?: string;
|
|
849
|
+
created_at?: string;
|
|
850
|
+
/**
|
|
851
|
+
* The session that made the change, when a signed-in session made it. Clients skip alerts for their own session.
|
|
852
|
+
*/
|
|
853
|
+
session_id?: string;
|
|
854
|
+
};
|
|
855
|
+
}
|
|
520
856
|
export interface ServerSecurityNoticeEvent {
|
|
521
857
|
type: "security_notice";
|
|
522
858
|
event_id: Id;
|
|
@@ -526,7 +862,7 @@ export interface ServerSecurityNoticeEvent {
|
|
|
526
862
|
};
|
|
527
863
|
}
|
|
528
864
|
/**
|
|
529
|
-
* A user started or stopped typing.
|
|
865
|
+
* 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
866
|
*/
|
|
531
867
|
export interface ServerTypingEvent {
|
|
532
868
|
type: "typing";
|
|
@@ -535,5 +871,9 @@ export interface ServerTypingEvent {
|
|
|
535
871
|
data: {
|
|
536
872
|
user_id: Id;
|
|
537
873
|
is_typing: boolean;
|
|
874
|
+
/**
|
|
875
|
+
* What the user is doing. New values may be added: show an unknown one like `typing`.
|
|
876
|
+
*/
|
|
877
|
+
action: "typing" | "recording_voice";
|
|
538
878
|
};
|
|
539
879
|
}
|