@mtkruto/node 0.0.6
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 +165 -0
- package/README.md +1 -0
- package/esm/_dnt.shims.js +68 -0
- package/esm/client/client.js +169 -0
- package/esm/client/client_abstract.js +51 -0
- package/esm/client/client_plain.js +112 -0
- package/esm/connection/connection.js +2 -0
- package/esm/connection/connection_web_socket.js +90 -0
- package/esm/constants.js +60 -0
- package/esm/deps/deno.land/std@0.186.0/fmt/colors.js +474 -0
- package/esm/deps/deno.land/std@0.186.0/testing/_diff.js +311 -0
- package/esm/deps/deno.land/std@0.186.0/testing/_format.js +23 -0
- package/esm/deps/deno.land/std@0.186.0/testing/asserts.js +633 -0
- package/esm/deps/deno.land/x/crc32@v0.2.0/mod.js +105 -0
- package/esm/deps/deno.land/x/tgcrypto@0.1.1/mod.js +68 -0
- package/esm/deps/deno.land/x/tgcrypto@0.1.1/tgcrypto.js +1127 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/gzip/gzip.js +239 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/utils/uint8.js +10 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/deflate.js +139 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/inflate.js +176 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/mod.js +2 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/adler32.js +19 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/crc32.js +25 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/deflate.js +1941 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/gzheader.js +85 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inffast.js +321 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inflate.js +1658 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inftrees.js +355 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/messages.js +11 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/status.js +42 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/trees.js +1107 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/zstream.js +86 -0
- package/esm/deps.js +4 -0
- package/esm/mod.js +4 -0
- package/esm/package.json +3 -0
- package/esm/tl/0_tl_raw_reader.js +62 -0
- package/esm/tl/0_tl_raw_writer.js +60 -0
- package/esm/tl/1_tl_object.js +149 -0
- package/esm/tl/2_types.js +48220 -0
- package/esm/tl/3_functions.js +19856 -0
- package/esm/tl/3_tl_object_deserializer.js +72 -0
- package/esm/tl/3_tl_reader.js +16 -0
- package/esm/tl/3_tl_writer.js +7 -0
- package/esm/tl/4_rpc_result.js +27 -0
- package/esm/tl/5_message.js +54 -0
- package/esm/tl/6_message_container.js +35 -0
- package/esm/transport/transport.js +32 -0
- package/esm/transport/transport_intermediate.js +56 -0
- package/esm/transport/transport_provider.js +23 -0
- package/esm/types.js +1 -0
- package/esm/utilities/0_bigint.js +37 -0
- package/esm/utilities/0_buffer.js +33 -0
- package/esm/utilities/0_crypto.js +35 -0
- package/esm/utilities/0_hash.js +7 -0
- package/esm/utilities/1_auth.js +29 -0
- package/esm/utilities/1_message.js +94 -0
- package/esm/utilities/1_obfuscation.js +33 -0
- package/package.json +40 -0
- package/script/_dnt.shims.js +77 -0
- package/script/client/client.js +173 -0
- package/script/client/client_abstract.js +55 -0
- package/script/client/client_plain.js +116 -0
- package/script/connection/connection.js +6 -0
- package/script/connection/connection_web_socket.js +117 -0
- package/script/constants.js +63 -0
- package/script/deps/deno.land/std@0.186.0/fmt/colors.js +548 -0
- package/script/deps/deno.land/std@0.186.0/testing/_diff.js +317 -0
- package/script/deps/deno.land/std@0.186.0/testing/_format.js +50 -0
- package/script/deps/deno.land/std@0.186.0/testing/asserts.js +659 -0
- package/script/deps/deno.land/x/crc32@v0.2.0/mod.js +113 -0
- package/script/deps/deno.land/x/tgcrypto@0.1.1/mod.js +82 -0
- package/script/deps/deno.land/x/tgcrypto@0.1.1/tgcrypto.js +1152 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/gzip/gzip.js +271 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/utils/uint8.js +14 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/deflate.js +172 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/inflate.js +208 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/mod.js +18 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/adler32.js +22 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/crc32.js +30 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/deflate.js +1976 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/gzheader.js +88 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inffast.js +324 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inflate.js +1674 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inftrees.js +358 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/messages.js +14 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/status.js +44 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/trees.js +1115 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/zstream.js +89 -0
- package/script/deps.js +30 -0
- package/script/mod.js +32 -0
- package/script/package.json +3 -0
- package/script/tl/0_tl_raw_reader.js +66 -0
- package/script/tl/0_tl_raw_writer.js +64 -0
- package/script/tl/1_tl_object.js +156 -0
- package/script/tl/2_types.js +49824 -0
- package/script/tl/3_functions.js +20413 -0
- package/script/tl/3_tl_object_deserializer.js +76 -0
- package/script/tl/3_tl_reader.js +20 -0
- package/script/tl/3_tl_writer.js +11 -0
- package/script/tl/4_rpc_result.js +31 -0
- package/script/tl/5_message.js +58 -0
- package/script/tl/6_message_container.js +39 -0
- package/script/transport/transport.js +36 -0
- package/script/transport/transport_intermediate.js +60 -0
- package/script/transport/transport_provider.js +27 -0
- package/script/types.js +2 -0
- package/script/utilities/0_bigint.js +67 -0
- package/script/utilities/0_buffer.js +38 -0
- package/script/utilities/0_crypto.js +39 -0
- package/script/utilities/0_hash.js +35 -0
- package/script/utilities/1_auth.js +56 -0
- package/script/utilities/1_message.js +102 -0
- package/script/utilities/1_obfuscation.js +60 -0
- package/types/_dnt.shims.d.ts +10 -0
- package/types/client/client.d.ts +19 -0
- package/types/client/client_abstract.d.ts +20 -0
- package/types/client/client_plain.d.ts +10 -0
- package/types/connection/connection.d.ts +7 -0
- package/types/connection/connection_web_socket.d.ts +13 -0
- package/types/constants.d.ts +2 -0
- package/types/deps/deno.land/std@0.186.0/fmt/colors.d.ts +270 -0
- package/types/deps/deno.land/std@0.186.0/testing/_diff.d.ts +26 -0
- package/types/deps/deno.land/std@0.186.0/testing/_format.d.ts +1 -0
- package/types/deps/deno.land/std@0.186.0/testing/asserts.d.ts +284 -0
- package/types/deps/deno.land/x/crc32@v0.2.0/mod.d.ts +15 -0
- package/types/deps/deno.land/x/tgcrypto@0.1.1/mod.d.ts +47 -0
- package/types/deps/deno.land/x/tgcrypto@0.1.1/tgcrypto.d.ts +2 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/gzip/gzip.d.ts +16 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/utils/uint8.d.ts +1 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/deflate.d.ts +29 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/inflate.d.ts +23 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/mod.d.ts +2 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/adler32.d.ts +1 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/crc32.d.ts +2 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/deflate.d.ts +78 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/gzheader.d.ts +12 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inffast.d.ts +1 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inflate.d.ts +47 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inftrees.d.ts +1 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/messages.d.ts +12 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/status.d.ts +30 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/trees.d.ts +5 -0
- package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/zstream.d.ts +14 -0
- package/types/deps.d.ts +4 -0
- package/types/mod.d.ts +4 -0
- package/types/tl/0_tl_raw_reader.d.ts +13 -0
- package/types/tl/0_tl_raw_writer.d.ts +13 -0
- package/types/tl/1_tl_object.d.ts +36 -0
- package/types/tl/2_types.d.ts +14815 -0
- package/types/tl/3_functions.d.ts +6122 -0
- package/types/tl/3_tl_object_deserializer.d.ts +3 -0
- package/types/tl/3_tl_reader.d.ts +4 -0
- package/types/tl/3_tl_writer.d.ts +5 -0
- package/types/tl/4_rpc_result.d.ts +8 -0
- package/types/tl/5_message.d.ts +11 -0
- package/types/tl/6_message_container.d.ts +9 -0
- package/types/transport/transport.d.ts +15 -0
- package/types/transport/transport_intermediate.d.ts +11 -0
- package/types/transport/transport_provider.d.ts +12 -0
- package/types/types.d.ts +1 -0
- package/types/utilities/0_bigint.d.ts +4 -0
- package/types/utilities/0_buffer.d.ts +2 -0
- package/types/utilities/0_crypto.d.ts +8 -0
- package/types/utilities/0_hash.d.ts +2 -0
- package/types/utilities/1_auth.d.ts +1 -0
- package/types/utilities/1_message.d.ts +10 -0
- package/types/utilities/1_obfuscation.d.ts +6 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
+
};
|
|
6
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
7
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
10
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
11
|
+
};
|
|
12
|
+
var _Crc32Stream_crc32;
|
|
13
|
+
export function crc32(arr) {
|
|
14
|
+
if (typeof arr === "string") {
|
|
15
|
+
arr = new TextEncoder().encode(arr);
|
|
16
|
+
}
|
|
17
|
+
let crc = -1, i, j, l, temp, poly = 0xEDB88320;
|
|
18
|
+
for (i = 0, l = arr.length; i < l; i += 1) {
|
|
19
|
+
temp = (crc ^ arr[i]) & 0xff;
|
|
20
|
+
for (j = 0; j < 8; j += 1) {
|
|
21
|
+
if ((temp & 1) === 1) {
|
|
22
|
+
temp = (temp >>> 1) ^ poly;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
temp = (temp >>> 1);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
crc = (crc >>> 8) ^ temp;
|
|
29
|
+
}
|
|
30
|
+
return numberToHex(crc ^ -1);
|
|
31
|
+
}
|
|
32
|
+
export class Crc32Stream {
|
|
33
|
+
constructor() {
|
|
34
|
+
Object.defineProperty(this, "bytes", {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
configurable: true,
|
|
37
|
+
writable: true,
|
|
38
|
+
value: []
|
|
39
|
+
});
|
|
40
|
+
Object.defineProperty(this, "poly", {
|
|
41
|
+
enumerable: true,
|
|
42
|
+
configurable: true,
|
|
43
|
+
writable: true,
|
|
44
|
+
value: 0xEDB88320
|
|
45
|
+
});
|
|
46
|
+
Object.defineProperty(this, "crc", {
|
|
47
|
+
enumerable: true,
|
|
48
|
+
configurable: true,
|
|
49
|
+
writable: true,
|
|
50
|
+
value: 0 ^ -1
|
|
51
|
+
});
|
|
52
|
+
Object.defineProperty(this, "encoder", {
|
|
53
|
+
enumerable: true,
|
|
54
|
+
configurable: true,
|
|
55
|
+
writable: true,
|
|
56
|
+
value: new TextEncoder()
|
|
57
|
+
});
|
|
58
|
+
_Crc32Stream_crc32.set(this, "");
|
|
59
|
+
this.reset();
|
|
60
|
+
}
|
|
61
|
+
get crc32() {
|
|
62
|
+
return __classPrivateFieldGet(this, _Crc32Stream_crc32, "f");
|
|
63
|
+
}
|
|
64
|
+
reset() {
|
|
65
|
+
__classPrivateFieldSet(this, _Crc32Stream_crc32, "", "f");
|
|
66
|
+
this.crc = 0 ^ -1;
|
|
67
|
+
for (let n = 0; n < 256; n += 1) {
|
|
68
|
+
let c = n;
|
|
69
|
+
for (let k = 0; k < 8; k += 1) {
|
|
70
|
+
if (c & 1) {
|
|
71
|
+
c = this.poly ^ (c >>> 1);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
c = c >>> 1;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
this.bytes[n] = c >>> 0;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
append(arr) {
|
|
81
|
+
if (typeof arr === "string") {
|
|
82
|
+
arr = this.encoder.encode(arr);
|
|
83
|
+
}
|
|
84
|
+
let crc = this.crc;
|
|
85
|
+
for (let i = 0, l = arr.length; i < l; i += 1) {
|
|
86
|
+
crc = (crc >>> 8) ^ this.bytes[(crc ^ arr[i]) & 0xff];
|
|
87
|
+
}
|
|
88
|
+
this.crc = crc;
|
|
89
|
+
__classPrivateFieldSet(this, _Crc32Stream_crc32, numberToHex(crc ^ -1), "f");
|
|
90
|
+
return __classPrivateFieldGet(this, _Crc32Stream_crc32, "f");
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
_Crc32Stream_crc32 = new WeakMap();
|
|
94
|
+
export function numberToHex(n) {
|
|
95
|
+
return (n >>> 0).toString(16);
|
|
96
|
+
}
|
|
97
|
+
export function hexToUint8Array(str) {
|
|
98
|
+
if (str.length === 0 || str.length % 2 !== 0) {
|
|
99
|
+
throw new Error(`The string "${str}" is not valid hex.`);
|
|
100
|
+
}
|
|
101
|
+
return new Uint8Array(str.match(/.{1,2}/g).map((byte) => parseInt(byte, 16)));
|
|
102
|
+
}
|
|
103
|
+
export function uint8ArrayToHex(bytes) {
|
|
104
|
+
return bytes.reduce((str, byte) => str + byte.toString(16).padStart(2, "0"), "");
|
|
105
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { default as init_ } from "./tgcrypto.js";
|
|
2
|
+
// deno-lint-ignore no-explicit-any
|
|
3
|
+
let module_;
|
|
4
|
+
const promise = init_().then((v) => module_ = v);
|
|
5
|
+
export async function init() {
|
|
6
|
+
await promise;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Performs IGE-256 encryption.
|
|
10
|
+
*
|
|
11
|
+
* @param data The unencrypted data, larger than a byte, divisible by 16
|
|
12
|
+
* @param key 32-byte encryption key
|
|
13
|
+
* @param iv 32-byte initialization vector
|
|
14
|
+
*/
|
|
15
|
+
export function ige256Encrypt(data, key, iv) {
|
|
16
|
+
return module_.ige256Encrypt(data, key, iv);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Performs IGE-256 decryption.
|
|
20
|
+
*
|
|
21
|
+
* @param data The encrypted data, larger than a byte, divisible by 16
|
|
22
|
+
* @param key 32-byte encryption key
|
|
23
|
+
* @param iv 32-byte initialization vector
|
|
24
|
+
*/
|
|
25
|
+
export function ige256Decrypt(data, key, iv) {
|
|
26
|
+
return module_.ige256Decrypt(data, key, iv);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Performs CTR-256 encryption.
|
|
30
|
+
*
|
|
31
|
+
* @param data The data, larger than a byte
|
|
32
|
+
* @param key 32-byte encryption key
|
|
33
|
+
* @param iv 16-byte initialization vector
|
|
34
|
+
* @param state 1-byte state
|
|
35
|
+
*/
|
|
36
|
+
export function ctr256Encrypt(data, key, iv, state) {
|
|
37
|
+
return module_.ctr256Encrypt(data, key, iv, state);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Alias of `ctr256Encrypt`
|
|
41
|
+
*/
|
|
42
|
+
export function ctr256Decrypt(data, key, iv, state) {
|
|
43
|
+
return module_.ctr256Decrypt(data, key, iv, state);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Performs CBC-256 encryption.
|
|
47
|
+
*
|
|
48
|
+
* @param data The unencrypted data, larger than a byte, divisible by 16
|
|
49
|
+
* @param key 32-byte encryption key
|
|
50
|
+
* @param iv 16-byte initialization vector
|
|
51
|
+
*/
|
|
52
|
+
export function cbc256Encrypt(data, key, iv) {
|
|
53
|
+
return module_.cbc256Encrypt(data, key, iv);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Performs CBC-256 decryption.
|
|
57
|
+
*
|
|
58
|
+
* @param data The encrypted data, larger than a byte, divisible by 16
|
|
59
|
+
* @param key 32-byte encryption key
|
|
60
|
+
* @param iv 16-byte initialization vector
|
|
61
|
+
*/
|
|
62
|
+
export function cbc256Decrypt(data, key, iv) {
|
|
63
|
+
return module_.cbc256Decrypt(data, key, iv);
|
|
64
|
+
}
|
|
65
|
+
export function factorize(pq) {
|
|
66
|
+
const vector = module_.factorize(pq);
|
|
67
|
+
return [vector.get(0), vector.get(1)];
|
|
68
|
+
}
|