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.
@@ -1,8 +1,10 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 Alexander Grigoryev
4
- Based on work originally licensed under MIT by GramJS (c) 2019
5
- https://github.com/gram-js/gramjs
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): 256 | 512 | 128;
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.0";
1
+ export declare const version = "1.214.1";
package/Version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = void 0;
4
- exports.version = "1.214.0";
4
+ exports.version = "1.214.1";
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).arrayBuffer();
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) {
@@ -1,19 +1,23 @@
1
1
  /**
2
- * Uint32Array -> ArrayBuffer (low-endian os)
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): ArrayBuffer;
5
+ export declare function i2abLow(buf: Uint32Array): ArrayBufferLike;
5
6
  /**
6
- * Uint32Array -> ArrayBuffer (big-endian os)
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): ArrayBuffer;
10
+ export declare function i2abBig(buf: Uint32Array): ArrayBufferLike;
9
11
  /**
10
- * ArrayBuffer -> Uint32Array (low-endian os)
12
+ * ArrayBuffer -> Uint32Array (little-endian OS)
13
+ * Reads big-endian bytes into uint32 values.
11
14
  */
12
- export declare function ab2iLow(ab: ArrayBuffer | SharedArrayBuffer | Uint8Array): Uint32Array;
15
+ export declare function ab2iLow(ab: ArrayBufferLike | Uint8Array): Uint32Array;
13
16
  /**
14
- * ArrayBuffer -> Uint32Array (big-endian os)
17
+ * ArrayBuffer -> Uint32Array (big-endian OS)
15
18
  */
16
- export declare function ab2iBig(ab: ArrayBuffer | SharedArrayBuffer | Uint8Array): Uint32Array;
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;
@@ -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 (low-endian os)
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 uint8 = new Uint8Array(buf.length * 4);
13
- let i = 0;
17
+ const out = new Uint8Array(buf.length * 4);
18
+ let o = 0;
14
19
  for (let j = 0; j < buf.length; j++) {
15
- const int = buf[j];
16
- uint8[i++] = int >>> 24;
17
- uint8[i++] = (int >> 16) & 0xff;
18
- uint8[i++] = (int >> 8) & 0xff;
19
- uint8[i++] = int & 0xff;
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 uint8.buffer;
26
+ return out.buffer;
22
27
  }
23
28
  /**
24
- * Uint32Array -> ArrayBuffer (big-endian os)
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 (low-endian os)
36
+ * ArrayBuffer -> Uint32Array (little-endian OS)
37
+ * Reads big-endian bytes into uint32 values.
31
38
  */
32
39
  function ab2iLow(ab) {
33
- const uint8 = new Uint8Array(ab);
34
- const buf = new Uint32Array(uint8.length / 4);
35
- for (let i = 0; i < uint8.length; i += 4) {
36
- buf[i / 4] =
37
- (uint8[i] << 24) ^
38
- (uint8[i + 1] << 16) ^
39
- (uint8[i + 2] << 8) ^
40
- uint8[i + 3];
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 buf;
52
+ return out;
43
53
  }
44
54
  /**
45
- * ArrayBuffer -> Uint32Array (big-endian os)
55
+ * ArrayBuffer -> Uint32Array (big-endian OS)
46
56
  */
47
57
  function ab2iBig(ab) {
48
- return new Uint32Array(ab);
58
+ return ab instanceof Uint8Array
59
+ ? new Uint32Array(ab.buffer, ab.byteOffset, Math.floor(ab.byteLength / 4))
60
+ : new Uint32Array(ab);
49
61
  }
50
- exports.isBigEndian = new Uint8Array(new Uint32Array([0x01020304]))[0] === 0x01;
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<ArrayBufferLike>;
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teleproto",
3
- "version": "1.214.0",
3
+ "version": "1.214.1",
4
4
  "description": "NodeJS MTProto API Telegram client library,",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",