teleproto 1.214.0 → 1.214.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/{LICENSE → LICENSE.txt} +6 -4
- package/Utils.d.ts +1 -1
- package/Version.d.ts +1 -1
- package/Version.js +1 -1
- package/client/uploads.js +13 -1
- package/crypto/converters.d.ts +12 -8
- package/crypto/converters.js +36 -23
- package/crypto/words.d.ts +1 -1
- package/package.json +1 -1
package/{LICENSE → LICENSE.txt}
RENAMED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2025
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Copyright (c) 2025 sanyok12345. All rights reserved.
|
|
4
|
+
|
|
5
|
+
This project, teleproto, is an independent work originally derived from GramJS.
|
|
6
|
+
GramJS is an open source project licensed under the MIT License.
|
|
7
|
+
Portions of teleproto are adapted from GramJS and remain subject to the MIT terms.
|
|
6
8
|
|
|
7
9
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
10
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -20,4 +22,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
20
22
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
23
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
24
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
SOFTWARE.
|
|
25
|
+
SOFTWARE.
|
package/Utils.d.ts
CHANGED
|
@@ -149,7 +149,7 @@ export declare function getInputMedia(media: any, { isPhoto, attributes, forceDo
|
|
|
149
149
|
* @param fileSize
|
|
150
150
|
* @returns {Number}
|
|
151
151
|
*/
|
|
152
|
-
export declare function getAppropriatedPartSize(fileSize: bigInt.BigInteger):
|
|
152
|
+
export declare function getAppropriatedPartSize(fileSize: bigInt.BigInteger): 128 | 256 | 512;
|
|
153
153
|
export declare function getPeer(peer: EntityLike | any): any;
|
|
154
154
|
export declare function sanitizeParseMode(mode: string | ParseInterface): ParseInterface;
|
|
155
155
|
/**
|
package/Version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.214.
|
|
1
|
+
export declare const version = "1.214.1";
|
package/Version.js
CHANGED
package/client/uploads.js
CHANGED
|
@@ -402,6 +402,11 @@ async function _sendAlbum(client, entity, { file, caption, forceDocument = false
|
|
|
402
402
|
topMsgId: (0, Utils_1.getMessageId)(topMsgId),
|
|
403
403
|
});
|
|
404
404
|
}
|
|
405
|
+
else if (topMsgId != undefined) {
|
|
406
|
+
replyObject = new tl_1.Api.InputReplyToMessage({
|
|
407
|
+
replyToMsgId: (0, Utils_1.getMessageId)(topMsgId),
|
|
408
|
+
});
|
|
409
|
+
}
|
|
405
410
|
const result = await client.invoke(new tl_1.Api.messages.SendMultiMedia({
|
|
406
411
|
peer: entity,
|
|
407
412
|
replyTo: replyObject,
|
|
@@ -481,6 +486,11 @@ async function sendFile(client, entity, { file, caption, forceDocument = false,
|
|
|
481
486
|
topMsgId: (0, Utils_1.getMessageId)(topMsgId),
|
|
482
487
|
});
|
|
483
488
|
}
|
|
489
|
+
else if (topMsgId != undefined) {
|
|
490
|
+
replyObject = new tl_1.Api.InputReplyToMessage({
|
|
491
|
+
replyToMsgId: (0, Utils_1.getMessageId)(topMsgId),
|
|
492
|
+
});
|
|
493
|
+
}
|
|
484
494
|
const request = new tl_1.Api.messages.SendMedia({
|
|
485
495
|
peer: entity,
|
|
486
496
|
media: media,
|
|
@@ -498,7 +508,9 @@ async function sendFile(client, entity, { file, caption, forceDocument = false,
|
|
|
498
508
|
}
|
|
499
509
|
function fileToBuffer(file) {
|
|
500
510
|
if (typeof File !== "undefined" && file instanceof File) {
|
|
501
|
-
return new Response(file)
|
|
511
|
+
return new Response(file)
|
|
512
|
+
.arrayBuffer()
|
|
513
|
+
.then((ab) => Buffer.from(ab));
|
|
502
514
|
}
|
|
503
515
|
else if (file instanceof CustomFile) {
|
|
504
516
|
if (file.buffer != undefined) {
|
package/crypto/converters.d.ts
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Uint32Array -> ArrayBuffer (
|
|
2
|
+
* Uint32Array -> ArrayBuffer (little-endian OS)
|
|
3
|
+
* Writes each uint32 in big-endian byte order for stable, platform-independent representation.
|
|
3
4
|
*/
|
|
4
|
-
export declare function i2abLow(buf: Uint32Array):
|
|
5
|
+
export declare function i2abLow(buf: Uint32Array): ArrayBufferLike;
|
|
5
6
|
/**
|
|
6
|
-
* Uint32Array -> ArrayBuffer (big-endian
|
|
7
|
+
* Uint32Array -> ArrayBuffer (big-endian OS)
|
|
8
|
+
* Direct buffer view is already in the desired memory layout.
|
|
7
9
|
*/
|
|
8
|
-
export declare function i2abBig(buf: Uint32Array):
|
|
10
|
+
export declare function i2abBig(buf: Uint32Array): ArrayBufferLike;
|
|
9
11
|
/**
|
|
10
|
-
* ArrayBuffer -> Uint32Array (
|
|
12
|
+
* ArrayBuffer -> Uint32Array (little-endian OS)
|
|
13
|
+
* Reads big-endian bytes into uint32 values.
|
|
11
14
|
*/
|
|
12
|
-
export declare function ab2iLow(ab:
|
|
15
|
+
export declare function ab2iLow(ab: ArrayBufferLike | Uint8Array): Uint32Array;
|
|
13
16
|
/**
|
|
14
|
-
* ArrayBuffer -> Uint32Array (big-endian
|
|
17
|
+
* ArrayBuffer -> Uint32Array (big-endian OS)
|
|
15
18
|
*/
|
|
16
|
-
export declare function ab2iBig(ab:
|
|
19
|
+
export declare function ab2iBig(ab: ArrayBufferLike | Uint8Array): Uint32Array;
|
|
20
|
+
/** Runtime endianness check (true if big-endian). */
|
|
17
21
|
export declare const isBigEndian: boolean;
|
|
18
22
|
export declare const i2ab: typeof i2abBig;
|
|
19
23
|
export declare const ab2i: typeof ab2iBig;
|
package/crypto/converters.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) sanyok12345. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License. See LICENSE.txt in the project root for details.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
2
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
7
|
exports.ab2i = exports.i2ab = exports.isBigEndian = void 0;
|
|
4
8
|
exports.i2abLow = i2abLow;
|
|
@@ -6,47 +10,56 @@ exports.i2abBig = i2abBig;
|
|
|
6
10
|
exports.ab2iLow = ab2iLow;
|
|
7
11
|
exports.ab2iBig = ab2iBig;
|
|
8
12
|
/**
|
|
9
|
-
* Uint32Array -> ArrayBuffer (
|
|
13
|
+
* Uint32Array -> ArrayBuffer (little-endian OS)
|
|
14
|
+
* Writes each uint32 in big-endian byte order for stable, platform-independent representation.
|
|
10
15
|
*/
|
|
11
16
|
function i2abLow(buf) {
|
|
12
|
-
const
|
|
13
|
-
let
|
|
17
|
+
const out = new Uint8Array(buf.length * 4);
|
|
18
|
+
let o = 0;
|
|
14
19
|
for (let j = 0; j < buf.length; j++) {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
const v = buf[j] >>> 0;
|
|
21
|
+
out[o++] = (v >>> 24) & 0xff;
|
|
22
|
+
out[o++] = (v >>> 16) & 0xff;
|
|
23
|
+
out[o++] = (v >>> 8) & 0xff;
|
|
24
|
+
out[o++] = v & 0xff;
|
|
20
25
|
}
|
|
21
|
-
return
|
|
26
|
+
return out.buffer;
|
|
22
27
|
}
|
|
23
28
|
/**
|
|
24
|
-
* Uint32Array -> ArrayBuffer (big-endian
|
|
29
|
+
* Uint32Array -> ArrayBuffer (big-endian OS)
|
|
30
|
+
* Direct buffer view is already in the desired memory layout.
|
|
25
31
|
*/
|
|
26
32
|
function i2abBig(buf) {
|
|
27
33
|
return buf.buffer;
|
|
28
34
|
}
|
|
29
35
|
/**
|
|
30
|
-
* ArrayBuffer -> Uint32Array (
|
|
36
|
+
* ArrayBuffer -> Uint32Array (little-endian OS)
|
|
37
|
+
* Reads big-endian bytes into uint32 values.
|
|
31
38
|
*/
|
|
32
39
|
function ab2iLow(ab) {
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
const src = ab instanceof Uint8Array ? ab : new Uint8Array(ab);
|
|
41
|
+
const len = src.length;
|
|
42
|
+
if (len % 4 !== 0)
|
|
43
|
+
throw new RangeError("Byte length must be a multiple of 4");
|
|
44
|
+
const out = new Uint32Array(len / 4);
|
|
45
|
+
for (let i = 0, w = 0; i < len; i += 4) {
|
|
46
|
+
out[w++] =
|
|
47
|
+
((src[i] << 24) >>> 0) ^
|
|
48
|
+
((src[i + 1] << 16) >>> 0) ^
|
|
49
|
+
((src[i + 2] << 8) >>> 0) ^
|
|
50
|
+
(src[i + 3] >>> 0);
|
|
41
51
|
}
|
|
42
|
-
return
|
|
52
|
+
return out;
|
|
43
53
|
}
|
|
44
54
|
/**
|
|
45
|
-
* ArrayBuffer -> Uint32Array (big-endian
|
|
55
|
+
* ArrayBuffer -> Uint32Array (big-endian OS)
|
|
46
56
|
*/
|
|
47
57
|
function ab2iBig(ab) {
|
|
48
|
-
return
|
|
58
|
+
return ab instanceof Uint8Array
|
|
59
|
+
? new Uint32Array(ab.buffer, ab.byteOffset, Math.floor(ab.byteLength / 4))
|
|
60
|
+
: new Uint32Array(ab);
|
|
49
61
|
}
|
|
50
|
-
|
|
62
|
+
/** Runtime endianness check (true if big-endian). */
|
|
63
|
+
exports.isBigEndian = new Uint8Array(new Uint32Array([0x01020304]).buffer)[0] === 0x01;
|
|
51
64
|
exports.i2ab = exports.isBigEndian ? i2abBig : i2abLow;
|
|
52
65
|
exports.ab2i = exports.isBigEndian ? ab2iBig : ab2iLow;
|
package/crypto/words.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ export declare function s2i(str: string, pos: number): number;
|
|
|
2
2
|
/**
|
|
3
3
|
* Helper function for transforming string key to Uint32Array
|
|
4
4
|
*/
|
|
5
|
-
export declare function getWords(key: string | Uint8Array | Uint32Array): Uint32Array<
|
|
5
|
+
export declare function getWords(key: string | Uint8Array | Uint32Array): Uint32Array<ArrayBuffer>;
|
|
6
6
|
export declare function xor(left: Uint32Array, right: Uint32Array, to?: Uint32Array<ArrayBufferLike>): void;
|