@mtkruto/node 0.0.905 → 0.0.910

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 (99) hide show
  1. package/esm/{types/utilities → client}/0_html.d.ts +1 -1
  2. package/esm/{types/utilities → client}/0_html.js +2 -2
  3. package/esm/client/{utilities/0_message.d.ts → 0_message.d.ts} +2 -2
  4. package/esm/client/{utilities/0_message.js → 0_message.js} +10 -10
  5. package/esm/client/{utilities/0_password.d.ts → 0_password.d.ts} +2 -2
  6. package/esm/client/{utilities/0_password.js → 0_password.js} +5 -5
  7. package/esm/client/{client_abstract.d.ts → 1_client_abstract.d.ts} +5 -5
  8. package/esm/client/{client_abstract.js → 1_client_abstract.js} +1 -1
  9. package/esm/client/{client_plain.d.ts → 2_client_plain.d.ts} +1 -1
  10. package/esm/client/{client_plain.js → 2_client_plain.js} +2 -2
  11. package/esm/client/{client.d.ts → 3_client.d.ts} +3 -3
  12. package/esm/client/{client.js → 3_client.js} +7 -7
  13. package/{script/connection/connection_web_socket.d.ts → esm/connection/1_connection_web_socket.d.ts} +1 -1
  14. package/esm/constants.d.ts +2 -2
  15. package/esm/constants.js +1 -1
  16. package/esm/mod.d.ts +13 -13
  17. package/esm/mod.js +13 -13
  18. package/{script/storage/storage.d.ts → esm/storage/0_storage.d.ts} +1 -1
  19. package/{script/storage/storage_local_storage.d.ts → esm/storage/1_storage_local_storage.d.ts} +1 -1
  20. package/esm/storage/{storage_local_storage.js → 1_storage_local_storage.js} +1 -1
  21. package/{script/storage/storage_memory.d.ts → esm/storage/1_storage_memory.d.ts} +1 -1
  22. package/esm/storage/{storage_memory.js → 1_storage_memory.js} +1 -1
  23. package/esm/storage/{storage_session_storage.d.ts → 1_storage_session_storage.d.ts} +1 -1
  24. package/esm/storage/{storage_session_storage.js → 1_storage_session_storage.js} +1 -1
  25. package/esm/transport/{utilities/0_obfuscation.d.ts → 0_obfuscation.d.ts} +2 -2
  26. package/esm/transport/{utilities/0_obfuscation.js → 0_obfuscation.js} +3 -3
  27. package/esm/transport/{transport_abridged.d.ts → 1_transport_abridged.d.ts} +2 -2
  28. package/esm/transport/{transport_abridged.js → 1_transport_abridged.js} +2 -2
  29. package/esm/transport/{transport_intermediate.d.ts → 1_transport_intermediate.d.ts} +2 -2
  30. package/esm/transport/{transport_intermediate.js → 1_transport_intermediate.js} +2 -2
  31. package/{script/transport/transport_provider.d.ts → esm/transport/2_transport_provider.d.ts} +2 -2
  32. package/esm/transport/{transport_provider.js → 2_transport_provider.js} +2 -2
  33. package/esm/types/!0_file_id.d.ts +77 -0
  34. package/esm/types/!0_file_id.js +372 -0
  35. package/esm/types/0_chat_photo.d.ts +7 -15
  36. package/esm/types/0_chat_photo.js +30 -17
  37. package/esm/types/1_chat.d.ts +1 -0
  38. package/esm/types/1_chat.js +25 -6
  39. package/esm/types/1_user.js +2 -2
  40. package/esm/types/3_message.js +12 -0
  41. package/package.json +1 -1
  42. package/script/{types/utilities → client}/0_html.d.ts +1 -1
  43. package/script/{types/utilities → client}/0_html.js +2 -2
  44. package/script/client/{utilities/0_message.d.ts → 0_message.d.ts} +2 -2
  45. package/script/client/{utilities/0_message.js → 0_message.js} +10 -10
  46. package/script/client/{utilities/0_password.d.ts → 0_password.d.ts} +2 -2
  47. package/script/client/{utilities/0_password.js → 0_password.js} +5 -5
  48. package/script/client/{client_abstract.d.ts → 1_client_abstract.d.ts} +5 -5
  49. package/script/client/{client_abstract.js → 1_client_abstract.js} +2 -2
  50. package/script/client/{client_plain.d.ts → 2_client_plain.d.ts} +1 -1
  51. package/script/client/{client_plain.js → 2_client_plain.js} +3 -3
  52. package/script/client/{client.d.ts → 3_client.d.ts} +3 -3
  53. package/script/client/{client.js → 3_client.js} +10 -10
  54. package/{esm/connection/connection_web_socket.d.ts → script/connection/1_connection_web_socket.d.ts} +1 -1
  55. package/script/constants.d.ts +2 -2
  56. package/script/constants.js +1 -1
  57. package/script/mod.d.ts +13 -13
  58. package/script/mod.js +13 -13
  59. package/{esm/storage/storage.d.ts → script/storage/0_storage.d.ts} +1 -1
  60. package/{esm/storage/storage_local_storage.d.ts → script/storage/1_storage_local_storage.d.ts} +1 -1
  61. package/script/storage/{storage_local_storage.js → 1_storage_local_storage.js} +2 -2
  62. package/{esm/storage/storage_memory.d.ts → script/storage/1_storage_memory.d.ts} +1 -1
  63. package/script/storage/{storage_memory.js → 1_storage_memory.js} +2 -2
  64. package/script/storage/{storage_session_storage.d.ts → 1_storage_session_storage.d.ts} +1 -1
  65. package/script/storage/{storage_session_storage.js → 1_storage_session_storage.js} +2 -2
  66. package/script/transport/{utilities/0_obfuscation.d.ts → 0_obfuscation.d.ts} +2 -2
  67. package/script/transport/{utilities/0_obfuscation.js → 0_obfuscation.js} +3 -3
  68. package/script/transport/{transport_abridged.d.ts → 1_transport_abridged.d.ts} +2 -2
  69. package/script/transport/{transport_abridged.js → 1_transport_abridged.js} +3 -3
  70. package/script/transport/{transport_intermediate.d.ts → 1_transport_intermediate.d.ts} +2 -2
  71. package/script/transport/{transport_intermediate.js → 1_transport_intermediate.js} +3 -3
  72. package/{esm/transport/transport_provider.d.ts → script/transport/2_transport_provider.d.ts} +2 -2
  73. package/script/transport/{transport_provider.js → 2_transport_provider.js} +4 -4
  74. package/script/types/!0_file_id.d.ts +77 -0
  75. package/script/types/!0_file_id.js +376 -0
  76. package/script/types/0_chat_photo.d.ts +7 -15
  77. package/script/types/0_chat_photo.js +31 -18
  78. package/script/types/1_chat.d.ts +1 -0
  79. package/script/types/1_chat.js +25 -6
  80. package/script/types/1_user.js +2 -2
  81. package/script/types/3_message.js +12 -0
  82. /package/esm/client/{utilities/0_password_test.d.ts → 0_password_test.d.ts} +0 -0
  83. /package/esm/connection/{connection.d.ts → 0_connection.d.ts} +0 -0
  84. /package/esm/connection/{connection.js → 0_connection.js} +0 -0
  85. /package/esm/connection/{connection_web_socket.js → 1_connection_web_socket.js} +0 -0
  86. /package/esm/storage/{storage.js → 0_storage.js} +0 -0
  87. /package/esm/transport/{transport.d.ts → 0_transport.d.ts} +0 -0
  88. /package/esm/transport/{transport.js → 0_transport.js} +0 -0
  89. /package/esm/types/{utilities/0_id_color.d.ts → !0_id_color.d.ts} +0 -0
  90. /package/esm/types/{utilities/0_id_color.js → !0_id_color.js} +0 -0
  91. /package/script/client/{utilities/0_password_test.d.ts → 0_password_test.d.ts} +0 -0
  92. /package/script/connection/{connection.d.ts → 0_connection.d.ts} +0 -0
  93. /package/script/connection/{connection.js → 0_connection.js} +0 -0
  94. /package/script/connection/{connection_web_socket.js → 1_connection_web_socket.js} +0 -0
  95. /package/script/storage/{storage.js → 0_storage.js} +0 -0
  96. /package/script/transport/{transport.d.ts → 0_transport.d.ts} +0 -0
  97. /package/script/transport/{transport.js → 0_transport.js} +0 -0
  98. /package/script/types/{utilities/0_id_color.d.ts → !0_id_color.d.ts} +0 -0
  99. /package/script/types/{utilities/0_id_color.js → !0_id_color.js} +0 -0
@@ -0,0 +1,376 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FileUniqueID = exports.FileUniqueType = exports.FileID = exports.ThumbnailSource = exports.FileType = void 0;
4
+ // Direct port from Pyrogram
5
+ const deps_js_1 = require("../deps.js");
6
+ const _0_control_js_1 = require("../utilities/0_control.js");
7
+ const _0_tl_raw_writer_js_1 = require("../tl/0_tl_raw_writer.js");
8
+ const _0_tl_raw_reader_js_1 = require("../tl/0_tl_raw_reader.js");
9
+ function base64Encode(data) {
10
+ return (0, deps_js_1.base64Encode)(data).replace(/=*$/, "");
11
+ }
12
+ function base64Decode(data) {
13
+ return (0, deps_js_1.base64Decode)(data + "=".repeat(-data.length % 4));
14
+ }
15
+ var FileType;
16
+ (function (FileType) {
17
+ FileType[FileType["Thumbnail"] = 0] = "Thumbnail";
18
+ FileType[FileType["ChatPhoto"] = 1] = "ChatPhoto";
19
+ FileType[FileType["Photo"] = 2] = "Photo";
20
+ FileType[FileType["Voice"] = 3] = "Voice";
21
+ FileType[FileType["Video"] = 4] = "Video";
22
+ FileType[FileType["Document"] = 5] = "Document";
23
+ FileType[FileType["Encrypted"] = 6] = "Encrypted";
24
+ FileType[FileType["Temp"] = 7] = "Temp";
25
+ FileType[FileType["Sticker"] = 8] = "Sticker";
26
+ FileType[FileType["Audio"] = 9] = "Audio";
27
+ FileType[FileType["Animation"] = 10] = "Animation";
28
+ FileType[FileType["EncryptedThumbnail"] = 11] = "EncryptedThumbnail";
29
+ FileType[FileType["Wallpaper"] = 12] = "Wallpaper";
30
+ FileType[FileType["VideoNote"] = 13] = "VideoNote";
31
+ FileType[FileType["SecureRaw"] = 14] = "SecureRaw";
32
+ FileType[FileType["Secure"] = 15] = "Secure";
33
+ FileType[FileType["Background"] = 16] = "Background";
34
+ FileType[FileType["DocumentAsFile"] = 17] = "DocumentAsFile";
35
+ })(FileType = exports.FileType || (exports.FileType = {}));
36
+ const PHOTO_TYPES = [FileType.Thumbnail, FileType.ChatPhoto, FileType.Photo, FileType.EncryptedThumbnail];
37
+ const DOCUMENT_TYPES = Object.keys(FileType).map(Number).filter((v) => !isNaN(v)).filter((v) => !PHOTO_TYPES.includes(v));
38
+ var ThumbnailSource;
39
+ (function (ThumbnailSource) {
40
+ ThumbnailSource[ThumbnailSource["Legacy"] = 0] = "Legacy";
41
+ ThumbnailSource[ThumbnailSource["Thumbnail"] = 1] = "Thumbnail";
42
+ ThumbnailSource[ThumbnailSource["ChatPhotoSmall"] = 2] = "ChatPhotoSmall";
43
+ ThumbnailSource[ThumbnailSource["ChatPhotoBig"] = 3] = "ChatPhotoBig";
44
+ ThumbnailSource[ThumbnailSource["StickerSetThumbnail"] = 4] = "StickerSetThumbnail";
45
+ })(ThumbnailSource = exports.ThumbnailSource || (exports.ThumbnailSource = {}));
46
+ const WEB_LOCATION_FLAG = 1 << 24;
47
+ const FILE_REFERENCE_FLAG = 1 << 25;
48
+ function rleEncode(s) {
49
+ const r = new Array();
50
+ let n = 0;
51
+ for (const b of s) {
52
+ if (!b) {
53
+ n++;
54
+ }
55
+ else {
56
+ if (n) {
57
+ r.push(0);
58
+ r.push(n);
59
+ n = 0;
60
+ }
61
+ r.push(b);
62
+ }
63
+ }
64
+ if (n) {
65
+ r.push(0);
66
+ r.push(n);
67
+ }
68
+ return new Uint8Array(r);
69
+ }
70
+ function rleDecode(s) {
71
+ const r = new Array();
72
+ let z = false;
73
+ for (const b of s) {
74
+ if (!b) {
75
+ z = true;
76
+ continue;
77
+ }
78
+ if (z) {
79
+ for (let i = 0; i < b; i++) {
80
+ r.push(0);
81
+ }
82
+ z = false;
83
+ }
84
+ else {
85
+ r.push(b);
86
+ }
87
+ }
88
+ return new Uint8Array(r);
89
+ }
90
+ class FileID {
91
+ constructor(major = FileID.MAJOR, minor = FileID.MINOR, fileType, dcId, params) {
92
+ Object.defineProperty(this, "fileType", {
93
+ enumerable: true,
94
+ configurable: true,
95
+ writable: true,
96
+ value: fileType
97
+ });
98
+ Object.defineProperty(this, "dcId", {
99
+ enumerable: true,
100
+ configurable: true,
101
+ writable: true,
102
+ value: dcId
103
+ });
104
+ Object.defineProperty(this, "params", {
105
+ enumerable: true,
106
+ configurable: true,
107
+ writable: true,
108
+ value: params
109
+ });
110
+ Object.defineProperty(this, "major", {
111
+ enumerable: true,
112
+ configurable: true,
113
+ writable: true,
114
+ value: void 0
115
+ });
116
+ Object.defineProperty(this, "minor", {
117
+ enumerable: true,
118
+ configurable: true,
119
+ writable: true,
120
+ value: void 0
121
+ });
122
+ if (major == null) {
123
+ this.major = FileID.MAJOR;
124
+ }
125
+ else {
126
+ this.major = major;
127
+ }
128
+ if (minor == null) {
129
+ this.minor = FileID.MINOR;
130
+ }
131
+ else {
132
+ this.minor = minor;
133
+ }
134
+ this.params.thumbnailSize ??= "";
135
+ }
136
+ static decode(fileId) {
137
+ const decoded = rleDecode(base64Decode(fileId));
138
+ const major = decoded[decoded.length - 1];
139
+ let minor;
140
+ let buffer;
141
+ if (major < 4) {
142
+ minor = 0;
143
+ buffer = decoded.slice(0, -1);
144
+ }
145
+ else {
146
+ minor = decoded[decoded.length - 2];
147
+ buffer = decoded.slice(0, -2);
148
+ }
149
+ const reader = new _0_tl_raw_reader_js_1.TLRawReader(buffer);
150
+ let fileType = reader.readInt32();
151
+ const dcId = reader.readInt32();
152
+ const hasWebLocation = Boolean(fileType & WEB_LOCATION_FLAG);
153
+ const hasFileReference = Boolean(fileType & FILE_REFERENCE_FLAG);
154
+ fileType &= ~WEB_LOCATION_FLAG;
155
+ fileType &= ~FILE_REFERENCE_FLAG;
156
+ if (hasWebLocation) {
157
+ const url = reader.readString();
158
+ const accessHash = reader.readInt64();
159
+ return new FileID(major, minor, fileType, dcId, { url, accessHash });
160
+ }
161
+ let fileReference = new Uint8Array();
162
+ if (hasFileReference) {
163
+ fileReference = reader.readBytes();
164
+ }
165
+ const mediaId = reader.readInt64();
166
+ const accessHash = reader.readInt64();
167
+ if (PHOTO_TYPES.includes(fileType)) {
168
+ const volumeId = reader.readInt64();
169
+ let thumbnailSource = 0;
170
+ if (major >= 4) {
171
+ thumbnailSource = reader.readInt32();
172
+ }
173
+ switch (thumbnailSource) {
174
+ case ThumbnailSource.Legacy: {
175
+ const secret = reader.readInt64();
176
+ const localId = reader.readInt32();
177
+ return new FileID(major, minor, fileType, dcId, { fileReference, mediaId, accessHash, volumeId, thumbnailSource, secret, localId });
178
+ }
179
+ case ThumbnailSource.Thumbnail: {
180
+ const thumbnailFileType = reader.readInt32();
181
+ const thumbnailSize = String.fromCharCode(reader.readInt32());
182
+ const localId = reader.readInt32();
183
+ return new FileID(major, minor, fileType, dcId, { fileReference, mediaId, accessHash, volumeId, thumbnailSource, thumbnailFileType, thumbnailSize, localId });
184
+ }
185
+ case ThumbnailSource.ChatPhotoSmall:
186
+ case ThumbnailSource.ChatPhotoBig: {
187
+ const chatId = reader.readInt64();
188
+ const chatAccessHash = reader.readInt64();
189
+ const localId = reader.readInt32();
190
+ return new FileID(major, minor, fileType, dcId, { fileReference, mediaId, accessHash, volumeId, thumbnailSource, chatId, chatAccessHash, localId });
191
+ }
192
+ case ThumbnailSource.StickerSetThumbnail: {
193
+ const stickerSetId = reader.readInt64();
194
+ const stickerSetAccessHash = reader.readInt64();
195
+ const localId = reader.readInt32();
196
+ return new FileID(major, minor, fileType, dcId, { fileReference, mediaId, accessHash, volumeId, thumbnailSource, stickerSetId, stickerSetAccessHash, localId });
197
+ }
198
+ default:
199
+ (0, _0_control_js_1.UNREACHABLE)();
200
+ }
201
+ }
202
+ else if (DOCUMENT_TYPES.includes(fileType)) {
203
+ return new FileID(minor, major, fileType, dcId, { fileReference, mediaId, accessHash });
204
+ }
205
+ else {
206
+ (0, _0_control_js_1.UNREACHABLE)();
207
+ }
208
+ }
209
+ encode(major, minor) {
210
+ major ??= this.major;
211
+ minor ??= this.minor;
212
+ const writer = new _0_tl_raw_writer_js_1.TLRawWriter();
213
+ let fileType = this.fileType;
214
+ if (this.params.url) {
215
+ fileType |= WEB_LOCATION_FLAG;
216
+ }
217
+ if (this.params.fileReference) {
218
+ fileType |= FILE_REFERENCE_FLAG;
219
+ }
220
+ writer.writeInt32(fileType);
221
+ writer.writeInt32(this.dcId);
222
+ if (this.params.url) {
223
+ writer.writeString(this.params.url);
224
+ }
225
+ if (this.params.fileReference) {
226
+ writer.writeBytes(this.params.fileReference);
227
+ }
228
+ if (this.params.mediaId == undefined || this.params.accessHash == undefined) {
229
+ (0, _0_control_js_1.UNREACHABLE)();
230
+ }
231
+ writer.writeInt64(this.params.mediaId);
232
+ writer.writeInt64(this.params.accessHash);
233
+ if (PHOTO_TYPES.includes(this.fileType)) {
234
+ if (this.params.volumeId == undefined || this.params.thumbnailSize == undefined || this.params.localId == undefined) {
235
+ (0, _0_control_js_1.UNREACHABLE)();
236
+ }
237
+ writer.writeInt64(this.params.volumeId);
238
+ if (major > 4) {
239
+ writer.writeInt32(Number(this.params.thumbnailSource));
240
+ }
241
+ switch (this.params.thumbnailSource) {
242
+ case ThumbnailSource.Legacy:
243
+ if (this.params.secret == undefined) {
244
+ (0, _0_control_js_1.UNREACHABLE)();
245
+ }
246
+ writer.writeInt64(this.params.secret);
247
+ writer.writeInt32(this.params.localId);
248
+ break;
249
+ case ThumbnailSource.Thumbnail:
250
+ if (this.params.thumbnailFileType == undefined || this.params.thumbnailSize == undefined) {
251
+ (0, _0_control_js_1.UNREACHABLE)();
252
+ }
253
+ writer.writeInt32(Number(this.params.thumbnailFileType));
254
+ writer.writeInt32(this.params.thumbnailSize.charCodeAt(0));
255
+ writer.writeInt32(this.params.localId);
256
+ break;
257
+ case ThumbnailSource.ChatPhotoSmall:
258
+ case ThumbnailSource.ChatPhotoBig:
259
+ if (this.params.chatId == undefined || this.params.chatAccessHash == undefined) {
260
+ (0, _0_control_js_1.UNREACHABLE)();
261
+ }
262
+ writer.writeInt64(this.params.chatId);
263
+ writer.writeInt64(this.params.chatAccessHash);
264
+ writer.writeInt32(this.params.localId);
265
+ break;
266
+ case ThumbnailSource.StickerSetThumbnail:
267
+ if (this.params.stickerSetId == undefined || this.params.stickerSetAccessHash == undefined) {
268
+ (0, _0_control_js_1.UNREACHABLE)();
269
+ }
270
+ writer.writeInt64(this.params.stickerSetId);
271
+ writer.writeInt64(this.params.stickerSetAccessHash);
272
+ writer.writeInt32(this.params.localId);
273
+ break;
274
+ default:
275
+ (0, _0_control_js_1.UNREACHABLE)();
276
+ }
277
+ }
278
+ else if (DOCUMENT_TYPES.includes(this.fileType)) {
279
+ writer.writeInt32(minor);
280
+ writer.writeInt32(major);
281
+ }
282
+ else {
283
+ (0, _0_control_js_1.UNREACHABLE)();
284
+ }
285
+ writer.write(new Uint8Array([minor, major]));
286
+ return base64Encode(rleEncode(writer.buffer));
287
+ }
288
+ }
289
+ Object.defineProperty(FileID, "MAJOR", {
290
+ enumerable: true,
291
+ configurable: true,
292
+ writable: true,
293
+ value: 4
294
+ });
295
+ Object.defineProperty(FileID, "MINOR", {
296
+ enumerable: true,
297
+ configurable: true,
298
+ writable: true,
299
+ value: 30
300
+ });
301
+ exports.FileID = FileID;
302
+ var FileUniqueType;
303
+ (function (FileUniqueType) {
304
+ FileUniqueType[FileUniqueType["Web"] = 0] = "Web";
305
+ FileUniqueType[FileUniqueType["Photo"] = 1] = "Photo";
306
+ FileUniqueType[FileUniqueType["Document"] = 2] = "Document";
307
+ FileUniqueType[FileUniqueType["Secure"] = 3] = "Secure";
308
+ FileUniqueType[FileUniqueType["Encrypted"] = 4] = "Encrypted";
309
+ FileUniqueType[FileUniqueType["Temp"] = 5] = "Temp";
310
+ })(FileUniqueType = exports.FileUniqueType || (exports.FileUniqueType = {}));
311
+ class FileUniqueID {
312
+ constructor(fileUniqueType, params) {
313
+ Object.defineProperty(this, "fileUniqueType", {
314
+ enumerable: true,
315
+ configurable: true,
316
+ writable: true,
317
+ value: fileUniqueType
318
+ });
319
+ Object.defineProperty(this, "params", {
320
+ enumerable: true,
321
+ configurable: true,
322
+ writable: true,
323
+ value: params
324
+ });
325
+ }
326
+ static decode(fileId) {
327
+ const reader = new _0_tl_raw_reader_js_1.TLRawReader(rleDecode(base64Decode(fileId)));
328
+ const fileUniqueType = reader.readInt32();
329
+ switch (fileUniqueType) {
330
+ case FileUniqueType.Web: {
331
+ const url = reader.readString();
332
+ return new FileUniqueID(fileUniqueType, { url });
333
+ }
334
+ case FileUniqueType.Photo: {
335
+ const volumeId = reader.readInt64();
336
+ const localId = reader.readInt32();
337
+ return new FileUniqueID(fileUniqueType, { volumeId, localId });
338
+ }
339
+ case FileUniqueType.Document: {
340
+ const mediaId = reader.readInt64();
341
+ return new FileUniqueID(fileUniqueType, { mediaId });
342
+ }
343
+ default:
344
+ (0, _0_control_js_1.UNREACHABLE)();
345
+ }
346
+ }
347
+ encode() {
348
+ const writer = new _0_tl_raw_writer_js_1.TLRawWriter();
349
+ writer.writeInt32(this.fileUniqueType);
350
+ switch (this.fileUniqueType) {
351
+ case FileUniqueType.Web:
352
+ if (this.params.url == undefined) {
353
+ (0, _0_control_js_1.UNREACHABLE)();
354
+ }
355
+ writer.writeString(this.params.url);
356
+ break;
357
+ case FileUniqueType.Photo:
358
+ if (this.params.volumeId == undefined || this.params.localId == undefined) {
359
+ (0, _0_control_js_1.UNREACHABLE)();
360
+ }
361
+ writer.writeInt64(this.params.volumeId);
362
+ writer.writeInt32(this.params.localId);
363
+ break;
364
+ case FileUniqueType.Document:
365
+ if (this.params.mediaId == undefined) {
366
+ (0, _0_control_js_1.UNREACHABLE)();
367
+ }
368
+ writer.writeInt64(this.params.mediaId);
369
+ break;
370
+ default:
371
+ (0, _0_control_js_1.UNREACHABLE)();
372
+ }
373
+ return base64Encode(rleEncode(writer.buffer));
374
+ }
375
+ }
376
+ exports.FileUniqueID = FileUniqueID;
@@ -1,24 +1,16 @@
1
1
  import * as types from "../tl/2_types.js";
2
- export declare enum ChatPhotoType {
3
- Chat = "chat",
4
- User = "user"
5
- }
6
2
  export declare namespace ChatPhoto {
7
3
  interface Base {
8
- type: ChatPhotoType;
9
- hasVideo: boolean;
10
- photoId: bigint;
11
- strippedThumb?: Uint8Array;
12
- dcId: number;
4
+ smallFileId: string;
5
+ smallFileUniqueId: string;
6
+ bigFileId: string;
7
+ bigFileUniqueId: string;
13
8
  }
14
9
  interface User extends Base {
15
- type: ChatPhotoType;
16
10
  personal: boolean;
17
11
  }
18
- interface Chat extends Base {
19
- type: ChatPhotoType;
20
- }
12
+ type Chat = Base;
21
13
  }
22
14
  export type ChatPhoto = ChatPhoto.User | ChatPhoto.Chat;
23
- export declare function constructChatPhoto(photo: types.ChatPhoto): ChatPhoto.Chat;
24
- export declare function constructChatPhoto(photo: types.UserProfilePhoto): ChatPhoto.User;
15
+ export declare function constructChatPhoto(photo: types.ChatPhoto, chatId: number, chatAccessHash: bigint): ChatPhoto.Chat;
16
+ export declare function constructChatPhoto(photo: types.UserProfilePhoto, chatId: number, chatAccessHash: bigint): ChatPhoto.User;
@@ -23,32 +23,45 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.constructChatPhoto = exports.ChatPhotoType = void 0;
26
+ exports.constructChatPhoto = void 0;
27
27
  const types = __importStar(require("../tl/2_types.js"));
28
- var ChatPhotoType;
29
- (function (ChatPhotoType) {
30
- ChatPhotoType["Chat"] = "chat";
31
- ChatPhotoType["User"] = "user";
32
- })(ChatPhotoType = exports.ChatPhotoType || (exports.ChatPhotoType = {}));
33
- function constructChatPhoto(photo) {
34
- const { hasVideo = false, photoId, strippedThumb, dcId } = photo;
28
+ const _0_file_id_js_1 = require("./!0_file_id.js");
29
+ function constructChatPhoto(photo, chatId, chatAccessHash) {
30
+ const smallFileId = new _0_file_id_js_1.FileID(null, null, _0_file_id_js_1.FileType.ChatPhoto, photo.dcId, {
31
+ mediaId: photo.photoId,
32
+ thumbnailSource: _0_file_id_js_1.ThumbnailSource.ChatPhotoSmall,
33
+ chatId: BigInt(chatId),
34
+ chatAccessHash,
35
+ accessHash: 0n,
36
+ volumeId: 0n,
37
+ localId: 0,
38
+ }).encode();
39
+ const smallFileUniqueId = new _0_file_id_js_1.FileUniqueID(_0_file_id_js_1.FileUniqueType.Document, { mediaId: photo.photoId }).encode();
40
+ const bigFileId = new _0_file_id_js_1.FileID(null, null, _0_file_id_js_1.FileType.ChatPhoto, photo.dcId, {
41
+ mediaId: photo.photoId,
42
+ thumbnailSource: _0_file_id_js_1.ThumbnailSource.ChatPhotoBig,
43
+ chatId: BigInt(chatId),
44
+ chatAccessHash,
45
+ accessHash: 0n,
46
+ volumeId: 0n,
47
+ localId: 0,
48
+ }).encode();
49
+ const bigFileUniqueId = new _0_file_id_js_1.FileUniqueID(_0_file_id_js_1.FileUniqueType.Document, { mediaId: photo.photoId }).encode();
35
50
  if (photo instanceof types.ChatPhoto) {
36
51
  return {
37
- type: ChatPhotoType.Chat,
38
- hasVideo,
39
- photoId,
40
- strippedThumb,
41
- dcId,
52
+ smallFileId,
53
+ smallFileUniqueId,
54
+ bigFileId,
55
+ bigFileUniqueId,
42
56
  };
43
57
  }
44
58
  else {
45
59
  return {
46
- type: ChatPhotoType.User,
47
60
  personal: photo.personal || false,
48
- hasVideo,
49
- photoId,
50
- strippedThumb,
51
- dcId,
61
+ smallFileId,
62
+ smallFileUniqueId,
63
+ bigFileId,
64
+ bigFileUniqueId,
52
65
  };
53
66
  }
54
67
  }
@@ -53,6 +53,7 @@ export declare namespace Chat {
53
53
  }
54
54
  interface Supergroup extends ChannelBase {
55
55
  type: ChatType.Supergroup;
56
+ isForum: boolean;
56
57
  }
57
58
  }
58
59
  export type Chat = Chat.Private | Chat.Group | Chat.Supergroup | Chat.Channel;
@@ -29,8 +29,8 @@ const _0_control_js_1 = require("../utilities/0_control.js");
29
29
  const _0_object_js_1 = require("../utilities/0_object.js");
30
30
  const _1_tl_object_js_1 = require("../tl/1_tl_object.js");
31
31
  const types = __importStar(require("../tl/2_types.js"));
32
+ const _0_id_color_js_1 = require("./!0_id_color.js");
32
33
  const _0_chat_photo_js_1 = require("./0_chat_photo.js");
33
- const _0_id_color_js_1 = require("./utilities/0_id_color.js");
34
34
  var ChatType;
35
35
  (function (ChatType) {
36
36
  ChatType["Private"] = "private";
@@ -58,7 +58,7 @@ function constructChat(chat) {
58
58
  chat_.restrictionReason = chat.restrictionReason?.map((v) => v[_1_tl_object_js_1.as](types.RestrictionReason));
59
59
  }
60
60
  if (chat.photo instanceof types.UserProfilePhoto) {
61
- chat_.photo = (0, _0_chat_photo_js_1.constructChatPhoto)(chat.photo);
61
+ chat_.photo = (0, _0_chat_photo_js_1.constructChatPhoto)(chat.photo, chat_.id, chat.accessHash ?? 0n);
62
62
  }
63
63
  return (0, _0_object_js_1.cleanObject)(chat_);
64
64
  }
@@ -72,7 +72,7 @@ function constructChat(chat) {
72
72
  isCreator: chat.creator || false,
73
73
  };
74
74
  if (chat.photo instanceof types.ChatPhoto) {
75
- chat_.photo = (0, _0_chat_photo_js_1.constructChatPhoto)(chat.photo);
75
+ chat_.photo = (0, _0_chat_photo_js_1.constructChatPhoto)(chat.photo, chat_.id, 0n);
76
76
  }
77
77
  return (0, _0_object_js_1.cleanObject)(chat_);
78
78
  }
@@ -81,11 +81,30 @@ function constructChat(chat) {
81
81
  const { title, scam: isScam = false, fake: isFake = false, verified: isVerified = false, restricted: isRestricted = false, } = chat;
82
82
  const id = constants_js_1.ZERO_CHANNEL_ID + -Number(chat.id);
83
83
  if (chat.megagroup) {
84
- chat_ = { id, idColor: (0, _0_id_color_js_1.getIdColor)(id), type: ChatType.Supergroup, title, isScam, isFake, isVerified, isRestricted };
84
+ chat_ = {
85
+ id,
86
+ idColor: (0, _0_id_color_js_1.getIdColor)(id),
87
+ type: ChatType.Supergroup,
88
+ title,
89
+ isScam,
90
+ isFake,
91
+ isVerified,
92
+ isRestricted,
93
+ isForum: chat.forum || false,
94
+ };
85
95
  }
86
96
  else {
87
97
  const id = constants_js_1.ZERO_CHANNEL_ID + -Number(chat.id);
88
- chat_ = { id, idColor: (0, _0_id_color_js_1.getIdColor)(id), type: ChatType.Channel, title, isScam, isFake, isVerified, isRestricted };
98
+ chat_ = {
99
+ id,
100
+ idColor: (0, _0_id_color_js_1.getIdColor)(id),
101
+ type: ChatType.Channel,
102
+ title,
103
+ isScam,
104
+ isFake,
105
+ isVerified,
106
+ isRestricted,
107
+ };
89
108
  }
90
109
  chat_.username = chat.username;
91
110
  chat_.also = chat.usernames?.map((v) => v[_1_tl_object_js_1.as](types.Username)).map((v) => v.username);
@@ -93,7 +112,7 @@ function constructChat(chat) {
93
112
  chat_.restrictionReason = chat.restrictionReason?.map((v) => v[_1_tl_object_js_1.as](types.RestrictionReason));
94
113
  }
95
114
  if (chat.photo instanceof types.ChatPhoto) {
96
- chat_.photo = (0, _0_chat_photo_js_1.constructChatPhoto)(chat.photo);
115
+ chat_.photo = (0, _0_chat_photo_js_1.constructChatPhoto)(chat.photo, chat_.id, chat.accessHash ?? 0n);
97
116
  }
98
117
  return (0, _0_object_js_1.cleanObject)(chat_);
99
118
  }
@@ -27,8 +27,8 @@ exports.constructUser = void 0;
27
27
  const _0_object_js_1 = require("../utilities/0_object.js");
28
28
  const _1_tl_object_js_1 = require("../tl/1_tl_object.js");
29
29
  const types = __importStar(require("../tl/2_types.js"));
30
+ const _0_id_color_js_1 = require("./!0_id_color.js");
30
31
  const _0_chat_photo_js_1 = require("./0_chat_photo.js");
31
- const _0_id_color_js_1 = require("./utilities/0_id_color.js");
32
32
  function constructUser(user_) {
33
33
  const id = Number(user_.id);
34
34
  const user = {
@@ -48,7 +48,7 @@ function constructUser(user_) {
48
48
  addedToAttachmentMenu: user_.attachMenuEnabled || false,
49
49
  };
50
50
  if (user_.photo instanceof types.UserProfilePhoto) {
51
- user.photo = (0, _0_chat_photo_js_1.constructChatPhoto)(user_.photo);
51
+ user.photo = (0, _0_chat_photo_js_1.constructChatPhoto)(user_.photo, user.id, user_.accessHash ?? 0n);
52
52
  }
53
53
  return (0, _0_object_js_1.cleanObject)(user);
54
54
  }
@@ -90,6 +90,18 @@ async function constructMessage(message_, getEntity, getMessage) {
90
90
  (0, _0_control_js_1.UNREACHABLE)();
91
91
  }
92
92
  }
93
+ else if (message_.fromId instanceof types.PeerChannel) {
94
+ const entity = await getEntity(message_.fromId);
95
+ if (entity) {
96
+ message.senderChat = (0, _1_chat_js_1.constructChat)(entity);
97
+ }
98
+ else {
99
+ (0, _0_control_js_1.UNREACHABLE)();
100
+ }
101
+ }
102
+ else {
103
+ (0, _0_control_js_1.UNREACHABLE)();
104
+ }
93
105
  if (message_.message) {
94
106
  if (message_.media == undefined) {
95
107
  message.text = message_.message;
File without changes
File without changes
File without changes