@mtkruto/node 0.171.0 → 0.180.1
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/esm/0_deps.d.ts +1 -0
- package/esm/0_deps.d.ts.map +1 -1
- package/esm/0_deps.js +1 -0
- package/esm/client/0_params.d.ts +54 -8
- package/esm/client/0_params.d.ts.map +1 -1
- package/esm/client/1_client_generic.d.ts +72 -1
- package/esm/client/1_client_generic.d.ts.map +1 -1
- package/esm/client/2_file_manager.d.ts +9 -1
- package/esm/client/2_file_manager.d.ts.map +1 -1
- package/esm/client/2_file_manager.js +93 -37
- package/esm/client/3_secret_chat_manager.d.ts +11 -2
- package/esm/client/3_secret_chat_manager.d.ts.map +1 -1
- package/esm/client/3_secret_chat_manager.js +322 -11
- package/esm/client/4_context.d.ts +24 -6
- package/esm/client/4_context.d.ts.map +1 -1
- package/esm/client/4_context.js +53 -0
- package/esm/client/6_client.d.ts +72 -1
- package/esm/client/6_client.d.ts.map +1 -1
- package/esm/client/6_client.js +89 -0
- package/esm/client/6_client_dispatcher.d.ts +72 -1
- package/esm/client/6_client_dispatcher.d.ts.map +1 -1
- package/esm/client/6_client_dispatcher.js +89 -0
- package/esm/deps/jsr.io/@std/crypto/1.1.0/_types.d.ts +9 -0
- package/esm/deps/jsr.io/@std/crypto/1.1.0/_types.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/crypto/1.1.0/_types.js +2 -0
- package/esm/deps/jsr.io/@std/crypto/1.1.0/_wasm/lib/deno_std_wasm_crypto.d.ts +2 -0
- package/esm/deps/jsr.io/@std/crypto/1.1.0/_wasm/lib/deno_std_wasm_crypto.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/crypto/1.1.0/_wasm/lib/deno_std_wasm_crypto.internal.d.ts +69 -0
- package/esm/deps/jsr.io/@std/crypto/1.1.0/_wasm/lib/deno_std_wasm_crypto.internal.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/crypto/1.1.0/_wasm/lib/deno_std_wasm_crypto.internal.js +237 -0
- package/esm/deps/jsr.io/@std/crypto/1.1.0/_wasm/lib/deno_std_wasm_crypto.js +2277 -0
- package/esm/deps/jsr.io/@std/crypto/1.1.0/_wasm/mod.d.ts +13 -0
- package/esm/deps/jsr.io/@std/crypto/1.1.0/_wasm/mod.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/crypto/1.1.0/_wasm/mod.js +46 -0
- package/esm/deps/jsr.io/@std/crypto/1.1.0/aes_gcm.d.ts +76 -0
- package/esm/deps/jsr.io/@std/crypto/1.1.0/aes_gcm.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/crypto/1.1.0/aes_gcm.js +132 -0
- package/esm/deps/jsr.io/@std/crypto/1.1.0/crypto.d.ts +149 -0
- package/esm/deps/jsr.io/@std/crypto/1.1.0/crypto.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/crypto/1.1.0/crypto.js +270 -0
- package/esm/deps/jsr.io/@std/crypto/1.1.0/mod.d.ts +22 -0
- package/esm/deps/jsr.io/@std/crypto/1.1.0/mod.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/crypto/1.1.0/mod.js +23 -0
- package/esm/deps/jsr.io/@std/crypto/1.1.0/timing_safe_equal.d.ts +40 -0
- package/esm/deps/jsr.io/@std/crypto/1.1.0/timing_safe_equal.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/crypto/1.1.0/timing_safe_equal.js +61 -0
- package/esm/tl/0_utilities.d.ts.map +1 -1
- package/esm/tl/0_utilities.js +44 -2
- package/esm/tl/1_tl_writer.d.ts.map +1 -1
- package/esm/tl/1_tl_writer.js +6 -1
- package/esm/types/1_sticker.d.ts +7 -9
- package/esm/types/1_sticker.d.ts.map +1 -1
- package/esm/types/1_sticker.js +1 -6
- package/package.json +1 -1
- package/script/0_deps.d.ts +1 -0
- package/script/0_deps.d.ts.map +1 -1
- package/script/0_deps.js +7 -5
- package/script/client/0_params.d.ts +54 -8
- package/script/client/0_params.d.ts.map +1 -1
- package/script/client/1_client_generic.d.ts +72 -1
- package/script/client/1_client_generic.d.ts.map +1 -1
- package/script/client/2_file_manager.d.ts +9 -1
- package/script/client/2_file_manager.d.ts.map +1 -1
- package/script/client/2_file_manager.js +90 -34
- package/script/client/3_secret_chat_manager.d.ts +11 -2
- package/script/client/3_secret_chat_manager.d.ts.map +1 -1
- package/script/client/3_secret_chat_manager.js +319 -8
- package/script/client/4_context.d.ts +24 -6
- package/script/client/4_context.d.ts.map +1 -1
- package/script/client/4_context.js +53 -0
- package/script/client/6_client.d.ts +72 -1
- package/script/client/6_client.d.ts.map +1 -1
- package/script/client/6_client.js +89 -0
- package/script/client/6_client_dispatcher.d.ts +72 -1
- package/script/client/6_client_dispatcher.d.ts.map +1 -1
- package/script/client/6_client_dispatcher.js +89 -0
- package/script/deps/jsr.io/@std/crypto/1.1.0/_types.d.ts +9 -0
- package/script/deps/jsr.io/@std/crypto/1.1.0/_types.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/crypto/1.1.0/_types.js +3 -0
- package/script/deps/jsr.io/@std/crypto/1.1.0/_wasm/lib/deno_std_wasm_crypto.d.ts +2 -0
- package/script/deps/jsr.io/@std/crypto/1.1.0/_wasm/lib/deno_std_wasm_crypto.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/crypto/1.1.0/_wasm/lib/deno_std_wasm_crypto.internal.d.ts +69 -0
- package/script/deps/jsr.io/@std/crypto/1.1.0/_wasm/lib/deno_std_wasm_crypto.internal.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/crypto/1.1.0/_wasm/lib/deno_std_wasm_crypto.internal.js +255 -0
- package/script/deps/jsr.io/@std/crypto/1.1.0/_wasm/lib/deno_std_wasm_crypto.js +2315 -0
- package/script/deps/jsr.io/@std/crypto/1.1.0/_wasm/mod.d.ts +13 -0
- package/script/deps/jsr.io/@std/crypto/1.1.0/_wasm/mod.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/crypto/1.1.0/_wasm/mod.js +51 -0
- package/script/deps/jsr.io/@std/crypto/1.1.0/aes_gcm.d.ts +76 -0
- package/script/deps/jsr.io/@std/crypto/1.1.0/aes_gcm.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/crypto/1.1.0/aes_gcm.js +169 -0
- package/script/deps/jsr.io/@std/crypto/1.1.0/crypto.d.ts +149 -0
- package/script/deps/jsr.io/@std/crypto/1.1.0/crypto.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/crypto/1.1.0/crypto.js +306 -0
- package/script/deps/jsr.io/@std/crypto/1.1.0/mod.d.ts +22 -0
- package/script/deps/jsr.io/@std/crypto/1.1.0/mod.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/crypto/1.1.0/mod.js +39 -0
- package/script/deps/jsr.io/@std/crypto/1.1.0/timing_safe_equal.d.ts +40 -0
- package/script/deps/jsr.io/@std/crypto/1.1.0/timing_safe_equal.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/crypto/1.1.0/timing_safe_equal.js +64 -0
- package/script/tl/0_utilities.d.ts.map +1 -1
- package/script/tl/0_utilities.js +43 -1
- package/script/tl/1_tl_writer.d.ts.map +1 -1
- package/script/tl/1_tl_writer.js +6 -1
- package/script/types/1_sticker.d.ts +7 -9
- package/script/types/1_sticker.d.ts.map +1 -1
- package/script/types/1_sticker.js +1 -6
|
@@ -19,16 +19,16 @@ var _a;
|
|
|
19
19
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
20
20
|
*/
|
|
21
21
|
import * as dntShim from "../_dnt.shims.js";
|
|
22
|
-
import { AssertionError, basename, decodeHex, delay, extension, extname, ige256Decrypt, isAbsolute, join, MINUTE, SECOND, toFileUrl, unreachable } from "../0_deps.js";
|
|
22
|
+
import { AssertionError, basename, concat, crypto, decodeHex, delay, extension, extname, ige256Decrypt, ige256Encrypt, isAbsolute, join, MINUTE, SECOND, toFileUrl, unreachable } from "../0_deps.js";
|
|
23
23
|
import { InputError } from "../0_errors.js";
|
|
24
|
-
import { getLogger, getRandomId, iterateReadableStream, kilobyte, megabyte, mod, PartStream } from "../1_utilities.js";
|
|
24
|
+
import { getLogger, getRandomId, intFromBytes, iterateReadableStream, kilobyte, megabyte, mod, PartStream } from "../1_utilities.js";
|
|
25
25
|
import { Api } from "../2_tl.js";
|
|
26
26
|
import { TimeTooBig, TimeTooSmall } from "../3_errors.js";
|
|
27
27
|
import { getDc } from "../3_transport.js";
|
|
28
28
|
import { constructSticker, deserializeFileId, FileType, PhotoSourceType, serializeFileId, toUniqueFileId } from "../3_types.js";
|
|
29
29
|
import { DOWNLOAD_MAX_CHUNK_SIZE, STICKER_SET_NAME_TTL } from "../4_constants.js";
|
|
30
30
|
import { FloodWait, StickersetInvalid } from "../4_errors.js";
|
|
31
|
-
import { UPLOAD_REQUEST_PER_CONNECTION } from "./0_utilities.js";
|
|
31
|
+
import { DOWNLOAD_POOL_SIZE, DOWNLOAD_REQUEST_PER_CONNECTION, UPLOAD_REQUEST_PER_CONNECTION } from "./0_utilities.js";
|
|
32
32
|
export class FileManager {
|
|
33
33
|
#c;
|
|
34
34
|
#Lupload;
|
|
@@ -48,7 +48,7 @@ export class FileManager {
|
|
|
48
48
|
this.#progressIds.add(id);
|
|
49
49
|
return Promise.resolve(String(id));
|
|
50
50
|
}
|
|
51
|
-
async upload(file, params, checkName, allowStream = true) {
|
|
51
|
+
async upload(file, params, checkName, allowStream = true, encryptionInformation) {
|
|
52
52
|
if (params?.progressId !== undefined && !this.#progressIds.has(BigInt(params.progressId))) {
|
|
53
53
|
throw new InputError("Invalid progressId.");
|
|
54
54
|
}
|
|
@@ -72,15 +72,28 @@ export class FileManager {
|
|
|
72
72
|
this.#Lupload.debug("uploading " + whatIsUploaded + " with chunk size of " + chunkSize + " and pool size of " + poolSize + " and file ID of " + fileId);
|
|
73
73
|
let result;
|
|
74
74
|
if (contents instanceof Uint8Array) {
|
|
75
|
-
result = await this.#uploadBuffer(contents, fileId, mustTrackProgress, chunkSize, poolSize, params?.signal);
|
|
75
|
+
result = await this.#uploadBuffer(contents, fileId, mustTrackProgress, chunkSize, poolSize, params?.signal, encryptionInformation);
|
|
76
76
|
}
|
|
77
77
|
else {
|
|
78
|
-
result = await this.#uploadStream(contents, fileId, mustTrackProgress, chunkSize, poolSize, params?.signal);
|
|
78
|
+
result = await this.#uploadStream(contents, fileId, mustTrackProgress, chunkSize, poolSize, params?.signal, encryptionInformation);
|
|
79
79
|
}
|
|
80
80
|
this.#Lupload.debug(`[${fileId}] uploaded ` + result.parts + " part(s)");
|
|
81
81
|
if (checkName) {
|
|
82
82
|
name = checkName(name, result.firstPart);
|
|
83
83
|
}
|
|
84
|
+
if (encryptionInformation) {
|
|
85
|
+
const digest = new Uint8Array(await crypto.subtle.digest("MD5", concat([encryptionInformation.key, encryptionInformation.iv])));
|
|
86
|
+
const right = digest.subarray(4, 8);
|
|
87
|
+
const key_fingerprint = Number(intFromBytes(digest.subarray(0, 4).map((v, i) => v ^ right[i])));
|
|
88
|
+
if (result.isSmall) {
|
|
89
|
+
const inputEncryptedFile = { _: "inputEncryptedFileUploaded", id: fileId, parts: result.parts, key_fingerprint, md5_checksum: "" };
|
|
90
|
+
return { inputEncryptedFile, fileSize: result.fileSize };
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
const inputEncryptedFile = { _: "inputEncryptedFileBigUploaded", id: fileId, parts: result.parts, key_fingerprint };
|
|
94
|
+
return { inputEncryptedFile, fileSize: result.fileSize };
|
|
95
|
+
}
|
|
96
|
+
}
|
|
84
97
|
if (result.isSmall) {
|
|
85
98
|
return { _: "inputFile", id: fileId, name, parts: result.parts, md5_checksum: "" };
|
|
86
99
|
}
|
|
@@ -88,12 +101,14 @@ export class FileManager {
|
|
|
88
101
|
return { _: "inputFileBig", id: fileId, name, parts: result.parts };
|
|
89
102
|
}
|
|
90
103
|
}
|
|
91
|
-
async #uploadStream(stream, fileId, mustTrackProgress, chunkSize, poolSize, signal) {
|
|
104
|
+
async #uploadStream(stream, fileId, mustTrackProgress, chunkSize, poolSize, signal, encryptionInformation) {
|
|
92
105
|
let part;
|
|
93
106
|
let promises = new Array();
|
|
94
107
|
let ms = 0.05;
|
|
95
108
|
let uploaded = 0;
|
|
96
109
|
let firstPart;
|
|
110
|
+
let iv = encryptionInformation?.iv;
|
|
111
|
+
let fileSize = 0;
|
|
97
112
|
for await (part of iterateReadableStream(stream.pipeThrough(new PartStream(chunkSize)))) {
|
|
98
113
|
if (!part.isSmall && part.part > 0) {
|
|
99
114
|
await delay(ms);
|
|
@@ -102,6 +117,16 @@ export class FileManager {
|
|
|
102
117
|
if (!firstPart) {
|
|
103
118
|
firstPart = part.bytes;
|
|
104
119
|
}
|
|
120
|
+
if (encryptionInformation) {
|
|
121
|
+
fileSize += part.bytes.byteLength;
|
|
122
|
+
if (part.bytes.byteLength % 16 !== 0) {
|
|
123
|
+
part.bytes = concat([part.bytes, crypto.getRandomValues(new Uint8Array((16 - part.bytes.length % 16) % 16))]);
|
|
124
|
+
}
|
|
125
|
+
const right = part.bytes.subarray(-16);
|
|
126
|
+
part.bytes = ige256Encrypt(part.bytes, encryptionInformation.key, iv);
|
|
127
|
+
const left = part.bytes.subarray(-16);
|
|
128
|
+
iv = concat([left, right]);
|
|
129
|
+
}
|
|
105
130
|
promises.push(this.#uploadPart(fileId, part.totalParts, !part.isSmall, part.part, part.bytes, signal).then(() => {
|
|
106
131
|
if (mustTrackProgress) {
|
|
107
132
|
uploaded += part.bytes.byteLength;
|
|
@@ -131,9 +156,9 @@ export class FileManager {
|
|
|
131
156
|
isUploaded: true,
|
|
132
157
|
},
|
|
133
158
|
});
|
|
134
|
-
return { isSmall: part.isSmall, parts: part.totalParts, firstPart };
|
|
159
|
+
return { isSmall: part.isSmall, parts: part.totalParts, firstPart, fileSize };
|
|
135
160
|
}
|
|
136
|
-
async #uploadBuffer(buffer, fileId, mustTrackProgress, chunkSize, poolSize, signal) {
|
|
161
|
+
async #uploadBuffer(buffer, fileId, mustTrackProgress, chunkSize, poolSize, signal, encryptionInformation) {
|
|
137
162
|
const isBig = buffer.byteLength > _a.#BIG_FILE_THRESHOLD;
|
|
138
163
|
const partCount = Math.ceil(buffer.byteLength / chunkSize);
|
|
139
164
|
let promises = new Array();
|
|
@@ -141,15 +166,30 @@ export class FileManager {
|
|
|
141
166
|
let ms = 0.05;
|
|
142
167
|
let uploaded = 0;
|
|
143
168
|
let firstPart;
|
|
169
|
+
let iv = encryptionInformation?.iv;
|
|
170
|
+
let fileSize = 0;
|
|
144
171
|
main: for (let part = 0; part < partCount;) {
|
|
145
172
|
for (let i = 0; i < poolSize; ++i) {
|
|
146
173
|
for (let i = 0; i < UPLOAD_REQUEST_PER_CONNECTION; ++i) {
|
|
147
174
|
const start = part * chunkSize;
|
|
148
175
|
const end = start + chunkSize;
|
|
149
|
-
|
|
176
|
+
let bytes = buffer.subarray(start, end);
|
|
150
177
|
if (!bytes.byteLength) {
|
|
151
178
|
break main;
|
|
152
179
|
}
|
|
180
|
+
if (!firstPart) {
|
|
181
|
+
firstPart = bytes;
|
|
182
|
+
}
|
|
183
|
+
if (encryptionInformation) {
|
|
184
|
+
fileSize += bytes.byteLength;
|
|
185
|
+
if (bytes.byteLength % 16 !== 0) {
|
|
186
|
+
bytes = concat([bytes, crypto.getRandomValues(new Uint8Array((16 - bytes.length % 16) % 16))]);
|
|
187
|
+
}
|
|
188
|
+
const right = bytes.subarray(-16);
|
|
189
|
+
bytes = ige256Encrypt(bytes, encryptionInformation.key, iv);
|
|
190
|
+
const left = bytes.subarray(-16);
|
|
191
|
+
iv = concat([left, right]);
|
|
192
|
+
}
|
|
153
193
|
if (!started) {
|
|
154
194
|
started = true;
|
|
155
195
|
}
|
|
@@ -157,9 +197,6 @@ export class FileManager {
|
|
|
157
197
|
await delay(ms);
|
|
158
198
|
ms = Math.max(ms * .8, 0.003);
|
|
159
199
|
}
|
|
160
|
-
if (!firstPart) {
|
|
161
|
-
firstPart = bytes;
|
|
162
|
-
}
|
|
163
200
|
promises.push(this.#uploadPart(fileId, partCount, isBig, part++, bytes, signal).then(() => {
|
|
164
201
|
if (mustTrackProgress) {
|
|
165
202
|
uploaded += bytes.byteLength;
|
|
@@ -193,7 +230,7 @@ export class FileManager {
|
|
|
193
230
|
isUploaded: true,
|
|
194
231
|
},
|
|
195
232
|
});
|
|
196
|
-
return { isSmall: !isBig, parts: partCount, firstPart };
|
|
233
|
+
return { isSmall: !isBig, parts: partCount, firstPart, fileSize };
|
|
197
234
|
}
|
|
198
235
|
async #uploadPart(fileId, partCount, isBig, index, bytes, signal) {
|
|
199
236
|
let retryIn = 1;
|
|
@@ -363,27 +400,29 @@ export class FileManager {
|
|
|
363
400
|
let offset = params?.offset ? BigInt(params.offset) : 0n;
|
|
364
401
|
let part = 0;
|
|
365
402
|
let totalSize = 0;
|
|
366
|
-
|
|
403
|
+
const requestCount = DOWNLOAD_POOL_SIZE * DOWNLOAD_REQUEST_PER_CONNECTION;
|
|
404
|
+
let finished = false;
|
|
367
405
|
while (true) {
|
|
368
406
|
signal?.throwIfAborted();
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
try {
|
|
372
|
-
const file = await this.#c.invoke({ _: "upload.getFile", location, offset, limit }, { dc, type: "download" });
|
|
407
|
+
const results = await Promise.all(Array.from({ length: requestCount }, (_, i) => this.#downloadPart(location, offset + BigInt(i * limit), limit, dc, signal, id, part + i)));
|
|
408
|
+
for (const result of results) {
|
|
373
409
|
signal?.throwIfAborted();
|
|
374
|
-
if (Api.is("upload.file",
|
|
375
|
-
const downloadedSize =
|
|
376
|
-
|
|
410
|
+
if (Api.is("upload.file", result)) {
|
|
411
|
+
const downloadedSize = result.bytes.byteLength;
|
|
412
|
+
finished = downloadedSize < limit;
|
|
377
413
|
if (decryptionInformation) {
|
|
378
|
-
const
|
|
414
|
+
const left = result.bytes.subarray(-16);
|
|
415
|
+
const decryptedBytes = ige256Decrypt(result.bytes, decryptionInformation.key, decryptionInformation.iv);
|
|
416
|
+
const right = decryptedBytes.subarray(-16);
|
|
379
417
|
const remainingSize = Math.max(0, fileSize - totalSize);
|
|
380
|
-
|
|
381
|
-
totalSize +=
|
|
418
|
+
result.bytes = decryptedBytes.slice(0, remainingSize);
|
|
419
|
+
totalSize += result.bytes.byteLength;
|
|
382
420
|
finished = totalSize >= fileSize;
|
|
421
|
+
decryptionInformation.iv = concat([left, right]);
|
|
383
422
|
}
|
|
384
|
-
yield
|
|
423
|
+
yield result.bytes;
|
|
385
424
|
if (id !== null) {
|
|
386
|
-
await this.#c.storage.saveFilePart(id, part,
|
|
425
|
+
await this.#c.storage.saveFilePart(id, part, result.bytes);
|
|
387
426
|
signal?.throwIfAborted();
|
|
388
427
|
}
|
|
389
428
|
++part;
|
|
@@ -401,8 +440,19 @@ export class FileManager {
|
|
|
401
440
|
else {
|
|
402
441
|
unreachable();
|
|
403
442
|
}
|
|
404
|
-
|
|
405
|
-
|
|
443
|
+
}
|
|
444
|
+
if (finished) {
|
|
445
|
+
break;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
async #downloadPart(location, offset, limit, dc, signal, id, part) {
|
|
450
|
+
let retryIn = 1;
|
|
451
|
+
let errorCount = 0;
|
|
452
|
+
while (true) {
|
|
453
|
+
try {
|
|
454
|
+
signal?.throwIfAborted();
|
|
455
|
+
return await this.#c.invoke({ _: "upload.getFile", location, offset, limit }, { dc, type: "download" });
|
|
406
456
|
}
|
|
407
457
|
catch (err) {
|
|
408
458
|
if (typeof err === "object" && err instanceof AssertionError) {
|
|
@@ -411,7 +461,7 @@ export class FileManager {
|
|
|
411
461
|
++errorCount;
|
|
412
462
|
if (errorCount > 20) {
|
|
413
463
|
retryIn = 0;
|
|
414
|
-
errorCount =
|
|
464
|
+
errorCount = 20;
|
|
415
465
|
}
|
|
416
466
|
await this.#handleError(err, retryIn, `[${id}-${part + 1}]`);
|
|
417
467
|
signal?.throwIfAborted();
|
|
@@ -500,13 +550,19 @@ export class FileManager {
|
|
|
500
550
|
}
|
|
501
551
|
}
|
|
502
552
|
else if (fileId_.location.type === "common") {
|
|
503
|
-
const location =
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
553
|
+
const location = fileId_.type === FileType.Encrypted
|
|
554
|
+
? {
|
|
555
|
+
_: "inputEncryptedFileLocation",
|
|
556
|
+
id: fileId_.location.id,
|
|
557
|
+
access_hash: fileId_.location.accessHash,
|
|
558
|
+
}
|
|
559
|
+
: {
|
|
560
|
+
_: "inputDocumentFileLocation",
|
|
561
|
+
id: fileId_.location.id,
|
|
562
|
+
access_hash: fileId_.location.accessHash,
|
|
563
|
+
file_reference: fileId_.fileReference ?? new Uint8Array(),
|
|
564
|
+
thumb_size: "",
|
|
565
|
+
};
|
|
510
566
|
yield* this.downloadInner(location, fileId_.dcId, params);
|
|
511
567
|
}
|
|
512
568
|
else {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Api } from "../2_tl.js";
|
|
2
|
-
import { type ID, type Update } from "../3_types.js";
|
|
3
|
-
import type { SendSecretContactParams, SendSecretLocationParams, SendSecretMessageParams, SendSecretVenueParams } from "./0_params.js";
|
|
2
|
+
import { type FileSource, type ID, type Sticker, type Update } from "../3_types.js";
|
|
3
|
+
import type { EndSecretChatParams, SendSecretAnimationParams, SendSecretAudioParams, SendSecretContactParams, SendSecretDocumentParams, SendSecretLocationParams, SendSecretMessageParams, SendSecretPhotoParams, SendSecretStickerParams, SendSecretVenueParams, SendSecretVideoNoteParams, SendSecretVideoParams, SendSecretVoiceParams } from "./0_params.js";
|
|
4
4
|
import type { UpdateProcessor } from "./0_update_processor.js";
|
|
5
5
|
import type { C as C_ } from "./1_types.js";
|
|
6
6
|
import type { FileManager } from "./2_file_manager.js";
|
|
@@ -15,10 +15,19 @@ export declare class SecretChatManager implements UpdateProcessor<SecretChatMana
|
|
|
15
15
|
loadSecretChats(): Promise<void>;
|
|
16
16
|
requestSecretChat(chatId: ID): Promise<import("../3_types.js").SecretChat>;
|
|
17
17
|
acceptSecretChat(id: number): Promise<import("../3_types.js").SecretChat>;
|
|
18
|
+
endSecretChat(id: number, params?: EndSecretChatParams): Promise<import("../3_types.js").SecretChat>;
|
|
18
19
|
sendSecretMessage(id: number, text: string, params?: SendSecretMessageParams): Promise<void>;
|
|
19
20
|
sendSecretLocation(id: number, latitude: number, longitude: number, params?: SendSecretLocationParams): Promise<void>;
|
|
20
21
|
sendSecretVenue(id: number, latitude: number, longitude: number, title: string, address: string, params?: SendSecretVenueParams): Promise<void>;
|
|
21
22
|
sendSecretContact(id: number, firstName: string, phoneNumber: string, params?: SendSecretContactParams): Promise<void>;
|
|
23
|
+
sendSecretDocument(id: number, document: FileSource, params?: SendSecretDocumentParams): Promise<void>;
|
|
24
|
+
sendSecretVideo(id: number, video: FileSource, params?: SendSecretVideoParams): Promise<void>;
|
|
25
|
+
sendSecretVideoNote(id: number, videoNote: FileSource, params?: SendSecretVideoNoteParams): Promise<void>;
|
|
26
|
+
sendSecretAudio(id: number, audio: FileSource, params?: SendSecretAudioParams): Promise<void>;
|
|
27
|
+
sendSecretVoice(id: number, voice: FileSource, params?: SendSecretVoiceParams): Promise<void>;
|
|
28
|
+
sendSecretAnimation(id: number, animation: FileSource, params?: SendSecretAnimationParams): Promise<void>;
|
|
29
|
+
sendSecretPhoto(id: number, photo: FileSource, params?: SendSecretPhotoParams): Promise<void>;
|
|
30
|
+
sendSecretSticker(id: number, sticker: Sticker, params?: SendSecretStickerParams): Promise<void>;
|
|
22
31
|
canHandleUpdate(update: Api.Update): update is SecretChatManagerUpdate;
|
|
23
32
|
handleUpdate(update: SecretChatManagerUpdate): Promise<Update | null>;
|
|
24
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"3_secret_chat_manager.d.ts","sourceRoot":"","sources":["../../src/client/3_secret_chat_manager.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"3_secret_chat_manager.d.ts","sourceRoot":"","sources":["../../src/client/3_secret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