@mtkruto/node 0.6.1 → 0.6.3
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/README.md +76 -1
- package/esm/0_deps.d.ts +1 -1
- package/esm/0_deps.d.ts.map +1 -1
- package/esm/0_deps.js +1 -1
- package/esm/1_utilities.d.ts +1 -1
- package/esm/1_utilities.d.ts.map +1 -1
- package/esm/1_utilities.js +1 -1
- package/esm/deps/jsr.io/@roj/tgcrypto/1.0.0/dist/mod.d.ts +18 -0
- package/esm/deps/jsr.io/@roj/tgcrypto/1.0.0/dist/mod.d.ts.map +1 -0
- package/esm/deps/jsr.io/@roj/tgcrypto/1.0.0/dist/mod.js +63 -0
- package/esm/deps/jsr.io/@roj/tgcrypto/1.0.0/dist/tgcrypto.d.ts +3 -0
- package/esm/deps/jsr.io/@roj/tgcrypto/1.0.0/dist/tgcrypto.d.ts.map +1 -0
- package/esm/deps/jsr.io/@roj/tgcrypto/1.0.0/dist/tgcrypto.js +301 -0
- package/esm/transport/0_obfuscation.d.ts.map +1 -1
- package/esm/transport/0_obfuscation.js +5 -4
- package/esm/transport/0_transport.d.ts +2 -2
- package/esm/transport/0_transport.d.ts.map +1 -1
- package/esm/transport/0_transport.js +10 -6
- package/esm/transport/1_transport_abridged.d.ts.map +1 -1
- package/esm/transport/1_transport_abridged.js +6 -8
- package/esm/transport/1_transport_intermediate.d.ts.map +1 -1
- package/esm/transport/1_transport_intermediate.js +4 -6
- package/esm/types/0_switch_inline_query_chosen_chats.d.ts +19 -0
- package/esm/types/0_switch_inline_query_chosen_chats.d.ts.map +1 -1
- package/esm/types/0_switch_inline_query_chosen_chats.js +19 -0
- package/esm/types/2_forward_header.d.ts +19 -0
- package/esm/types/2_forward_header.d.ts.map +1 -1
- package/esm/types/2_forward_header.js +19 -0
- package/esm/utilities/0_env.d.ts.map +1 -1
- package/esm/utilities/0_env.js +19 -0
- package/esm/utilities/0_gunzip.d.ts +19 -0
- package/esm/utilities/0_gunzip.d.ts.map +1 -1
- package/esm/utilities/0_gunzip.js +19 -0
- package/{script/utilities/0_crypto.d.ts → esm/utilities/1_crypto.d.ts} +9 -5
- package/esm/utilities/1_crypto.d.ts.map +1 -0
- package/esm/utilities/{0_crypto.js → 1_crypto.js} +41 -21
- package/esm/utilities/1_crypto_test.d.ts.map +1 -0
- package/package.json +1 -1
- package/script/0_deps.d.ts +1 -1
- package/script/0_deps.d.ts.map +1 -1
- package/script/0_deps.js +2 -5
- package/script/1_utilities.d.ts +1 -1
- package/script/1_utilities.d.ts.map +1 -1
- package/script/1_utilities.js +1 -1
- package/script/deps/jsr.io/@roj/tgcrypto/1.0.0/dist/mod.d.ts +18 -0
- package/script/deps/jsr.io/@roj/tgcrypto/1.0.0/dist/mod.d.ts.map +1 -0
- package/script/deps/jsr.io/@roj/tgcrypto/1.0.0/dist/mod.js +71 -0
- package/script/deps/jsr.io/@roj/tgcrypto/1.0.0/dist/tgcrypto.d.ts +3 -0
- package/script/deps/jsr.io/@roj/tgcrypto/1.0.0/dist/tgcrypto.d.ts.map +1 -0
- package/script/deps/jsr.io/@roj/tgcrypto/1.0.0/dist/tgcrypto.js +303 -0
- package/script/transport/0_obfuscation.d.ts.map +1 -1
- package/script/transport/0_obfuscation.js +5 -4
- package/script/transport/0_transport.d.ts +2 -2
- package/script/transport/0_transport.d.ts.map +1 -1
- package/script/transport/0_transport.js +10 -6
- package/script/transport/1_transport_abridged.d.ts.map +1 -1
- package/script/transport/1_transport_abridged.js +6 -8
- package/script/transport/1_transport_intermediate.d.ts.map +1 -1
- package/script/transport/1_transport_intermediate.js +4 -6
- package/script/types/0_switch_inline_query_chosen_chats.d.ts +19 -0
- package/script/types/0_switch_inline_query_chosen_chats.d.ts.map +1 -1
- package/script/types/0_switch_inline_query_chosen_chats.js +19 -0
- package/script/types/2_forward_header.d.ts +19 -0
- package/script/types/2_forward_header.d.ts.map +1 -1
- package/script/types/2_forward_header.js +19 -0
- package/script/utilities/0_env.d.ts.map +1 -1
- package/script/utilities/0_env.js +19 -0
- package/script/utilities/0_gunzip.d.ts +19 -0
- package/script/utilities/0_gunzip.d.ts.map +1 -1
- package/script/utilities/0_gunzip.js +19 -0
- package/{esm/utilities/0_crypto.d.ts → script/utilities/1_crypto.d.ts} +9 -5
- package/script/utilities/1_crypto.d.ts.map +1 -0
- package/script/utilities/1_crypto.js +95 -0
- package/script/utilities/1_crypto_test.d.ts.map +1 -0
- package/esm/deps/jsr.io/@roj/tgcrypto/0.4.1/dist/mod.d.ts +0 -55
- package/esm/deps/jsr.io/@roj/tgcrypto/0.4.1/dist/mod.js +0 -167
- package/esm/deps/jsr.io/@roj/tgcrypto/0.4.1/dist/tgcrypto.js +0 -308
- package/esm/utilities/0_crypto.d.ts.map +0 -1
- package/script/deps/jsr.io/@roj/tgcrypto/0.4.1/dist/mod.d.ts +0 -55
- package/script/deps/jsr.io/@roj/tgcrypto/0.4.1/dist/mod.js +0 -182
- package/script/deps/jsr.io/@roj/tgcrypto/0.4.1/dist/tgcrypto.js +0 -310
- package/script/utilities/0_crypto.d.ts.map +0 -1
- package/script/utilities/0_crypto.js +0 -52
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
3
|
+
* Copyright (C) 2023-2024 Roj <https://roj.im/>
|
|
4
|
+
*
|
|
5
|
+
* This file is part of MTKruto.
|
|
6
|
+
*
|
|
7
|
+
* This program is free software: you can redistribute it and/or modify
|
|
8
|
+
* it under the terms of the GNU Lesser General Public License as published by
|
|
9
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
10
|
+
* (at your option) any later version.
|
|
11
|
+
*
|
|
12
|
+
* This program is distributed in the hope that it will be useful,
|
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
+
* GNU Lesser General Public License for more details.
|
|
16
|
+
*
|
|
17
|
+
* You should have received a copy of the GNU Lesser General Public License
|
|
18
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
|
+
*/
|
|
1
20
|
export interface SwitchInlineQueryChosenChats {
|
|
2
21
|
/** The query to type into the user's message box once switched to inline. */
|
|
3
22
|
query: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"0_switch_inline_query_chosen_chats.d.ts","sourceRoot":"","sources":["../../src/types/0_switch_inline_query_chosen_chats.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,4BAA4B;IAC3C,6EAA6E;IAC7E,KAAK,EAAE,MAAM,CAAC;IACd,mEAAmE;IACnE,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,kEAAkE;IAClE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,8DAA8D;IAC9D,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,2DAA2D;IAC3D,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB"}
|
|
1
|
+
{"version":3,"file":"0_switch_inline_query_chosen_chats.d.ts","sourceRoot":"","sources":["../../src/types/0_switch_inline_query_chosen_chats.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,WAAW,4BAA4B;IAC3C,6EAA6E;IAC7E,KAAK,EAAE,MAAM,CAAC;IACd,mEAAmE;IACnE,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,kEAAkE;IAClE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,8DAA8D;IAC9D,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,2DAA2D;IAC3D,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB"}
|
|
@@ -1,2 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
4
|
+
* Copyright (C) 2023-2024 Roj <https://roj.im/>
|
|
5
|
+
*
|
|
6
|
+
* This file is part of MTKruto.
|
|
7
|
+
*
|
|
8
|
+
* This program is free software: you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU Lesser General Public License as published by
|
|
10
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
* (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* This program is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
* GNU Lesser General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU Lesser General Public License
|
|
19
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
20
|
+
*/
|
|
2
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
3
|
+
* Copyright (C) 2023-2024 Roj <https://roj.im/>
|
|
4
|
+
*
|
|
5
|
+
* This file is part of MTKruto.
|
|
6
|
+
*
|
|
7
|
+
* This program is free software: you can redistribute it and/or modify
|
|
8
|
+
* it under the terms of the GNU Lesser General Public License as published by
|
|
9
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
10
|
+
* (at your option) any later version.
|
|
11
|
+
*
|
|
12
|
+
* This program is distributed in the hope that it will be useful,
|
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
+
* GNU Lesser General Public License for more details.
|
|
16
|
+
*
|
|
17
|
+
* You should have received a copy of the GNU Lesser General Public License
|
|
18
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
|
+
*/
|
|
1
20
|
import { Api } from "../2_tl.js";
|
|
2
21
|
import { EntityGetter } from "./_getters.js";
|
|
3
22
|
import { ChatPChannel, ChatPSupergroup } from "./1_chat_p.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"2_forward_header.d.ts","sourceRoot":"","sources":["../../src/types/2_forward_header.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"2_forward_header.d.ts","sourceRoot":"","sources":["../../src/types/2_forward_header.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,eAAe,EAAkB,MAAM,eAAe,CAAC;AAC9E,OAAO,EAAiB,IAAI,EAAE,MAAM,aAAa,CAAC;AAElD,gBAAgB;AAChB,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,IAAI,CAAC;CACZ;AAED,gBAAgB;AAChB,MAAM,WAAW,iBAAkB,SAAQ,oBAAoB;IAC7D,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,IAAI,CAAC;CACZ;AAED,gBAAgB;AAChB,MAAM,WAAW,oBAAqB,SAAQ,oBAAoB;IAChE,qBAAqB;IACrB,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,YAAY,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,gBAAgB;AAChB,MAAM,WAAW,uBAAwB,SAAQ,oBAAoB;IACnE,IAAI,EAAE,YAAY,CAAC;IACnB,IAAI,EAAE,eAAe,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,gBAAgB;AAChB,MAAM,WAAW,mBAAoB,SAAQ,oBAAoB;IAC/D,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,gBAAgB;AAChB,MAAM,WAAW,wBAAyB,SAAQ,oBAAoB;IACpE,IAAI,EAAE,aAAa,CAAC;CACrB;AAED,MAAM,MAAM,aAAa,GAAG,iBAAiB,GAAG,oBAAoB,GAAG,uBAAuB,GAAG,mBAAmB,GAAG,wBAAwB,CAAC;AAEhJ,wBAAsB,sBAAsB,CAAC,SAAS,EAAE,GAAG,CAAC,gBAAgB,EAAE,SAAS,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC,CA8C7H"}
|
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
4
|
+
* Copyright (C) 2023-2024 Roj <https://roj.im/>
|
|
5
|
+
*
|
|
6
|
+
* This file is part of MTKruto.
|
|
7
|
+
*
|
|
8
|
+
* This program is free software: you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU Lesser General Public License as published by
|
|
10
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
* (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* This program is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
* GNU Lesser General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU Lesser General Public License
|
|
19
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
20
|
+
*/
|
|
2
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
22
|
exports.constructForwardHeader = constructForwardHeader;
|
|
4
23
|
const _0_deps_js_1 = require("../0_deps.js");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"0_env.d.ts","sourceRoot":"","sources":["../../src/utilities/0_env.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"0_env.d.ts","sourceRoot":"","sources":["../../src/utilities/0_env.ts"],"names":[],"mappings":"AA0BA,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAkBrD;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,iBAWrC"}
|
|
@@ -25,6 +25,25 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.getString = getString;
|
|
27
27
|
exports.getNumber = getNumber;
|
|
28
|
+
/**
|
|
29
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
30
|
+
* Copyright (C) 2023-2024 Roj <https://roj.im/>
|
|
31
|
+
*
|
|
32
|
+
* This file is part of MTKruto.
|
|
33
|
+
*
|
|
34
|
+
* This program is free software: you can redistribute it and/or modify
|
|
35
|
+
* it under the terms of the GNU Lesser General Public License as published by
|
|
36
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
37
|
+
* (at your option) any later version.
|
|
38
|
+
*
|
|
39
|
+
* This program is distributed in the hope that it will be useful,
|
|
40
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
41
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
42
|
+
* GNU Lesser General Public License for more details.
|
|
43
|
+
*
|
|
44
|
+
* You should have received a copy of the GNU Lesser General Public License
|
|
45
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
46
|
+
*/
|
|
28
47
|
const dntShim = __importStar(require("../_dnt.shims.js"));
|
|
29
48
|
const prefix = "MTKRUTO__";
|
|
30
49
|
// deno-lint-ignore no-explicit-any
|
|
@@ -1,2 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
3
|
+
* Copyright (C) 2023-2024 Roj <https://roj.im/>
|
|
4
|
+
*
|
|
5
|
+
* This file is part of MTKruto.
|
|
6
|
+
*
|
|
7
|
+
* This program is free software: you can redistribute it and/or modify
|
|
8
|
+
* it under the terms of the GNU Lesser General Public License as published by
|
|
9
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
10
|
+
* (at your option) any later version.
|
|
11
|
+
*
|
|
12
|
+
* This program is distributed in the hope that it will be useful,
|
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
+
* GNU Lesser General Public License for more details.
|
|
16
|
+
*
|
|
17
|
+
* You should have received a copy of the GNU Lesser General Public License
|
|
18
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
|
+
*/
|
|
1
20
|
export declare function gunzip(buffer: Uint8Array): Promise<Uint8Array>;
|
|
2
21
|
//# sourceMappingURL=0_gunzip.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"0_gunzip.d.ts","sourceRoot":"","sources":["../../src/utilities/0_gunzip.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"0_gunzip.d.ts","sourceRoot":"","sources":["../../src/utilities/0_gunzip.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,wBAAsB,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAcpE"}
|
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
4
|
+
* Copyright (C) 2023-2024 Roj <https://roj.im/>
|
|
5
|
+
*
|
|
6
|
+
* This file is part of MTKruto.
|
|
7
|
+
*
|
|
8
|
+
* This program is free software: you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU Lesser General Public License as published by
|
|
10
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
* (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* This program is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
* GNU Lesser General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU Lesser General Public License
|
|
19
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
20
|
+
*/
|
|
2
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
22
|
exports.gunzip = gunzip;
|
|
4
23
|
const _0_deps_js_1 = require("../0_deps.js");
|
|
@@ -17,11 +17,15 @@
|
|
|
17
17
|
* You should have received a copy of the GNU Lesser General Public License
|
|
18
18
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
19
19
|
*/
|
|
20
|
+
import * as dntShim from "../_dnt.shims.js";
|
|
20
21
|
export declare class CTR {
|
|
21
22
|
#private;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
get _state(): {
|
|
24
|
+
iv: Uint8Array;
|
|
25
|
+
state: number;
|
|
26
|
+
};
|
|
27
|
+
constructor(key: dntShim.CryptoKey, iv: Uint8Array);
|
|
28
|
+
static importKey(key: Uint8Array): Promise<dntShim.CryptoKey>;
|
|
29
|
+
call(data: Uint8Array): Promise<Uint8Array>;
|
|
26
30
|
}
|
|
27
|
-
//# sourceMappingURL=
|
|
31
|
+
//# sourceMappingURL=1_crypto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"1_crypto.d.ts","sourceRoot":"","sources":["../../src/utilities/1_crypto.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAM5C,qBAAa,GAAG;;IAKd,IAAI,MAAM,IAAI;QAAE,EAAE,EAAE,UAAU,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAE9C;gBAEW,GAAG,EAAE,OAAO,CAAC,SAAS,EAAE,EAAE,EAAE,UAAU;WAKrC,SAAS,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC;IAI7D,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;CAuBlD"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
26
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
27
|
+
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");
|
|
28
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
29
|
+
};
|
|
30
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
31
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
32
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
33
|
+
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");
|
|
34
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
35
|
+
};
|
|
36
|
+
var _CTR_key, _CTR_iv, _CTR_incrementPending;
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.CTR = void 0;
|
|
39
|
+
/**
|
|
40
|
+
* MTKruto - Cross-runtime JavaScript library for building Telegram clients
|
|
41
|
+
* Copyright (C) 2023-2024 Roj <https://roj.im/>
|
|
42
|
+
*
|
|
43
|
+
* This file is part of MTKruto.
|
|
44
|
+
*
|
|
45
|
+
* This program is free software: you can redistribute it and/or modify
|
|
46
|
+
* it under the terms of the GNU Lesser General Public License as published by
|
|
47
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
48
|
+
* (at your option) any later version.
|
|
49
|
+
*
|
|
50
|
+
* This program is distributed in the hope that it will be useful,
|
|
51
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
52
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
53
|
+
* GNU Lesser General Public License for more details.
|
|
54
|
+
*
|
|
55
|
+
* You should have received a copy of the GNU Lesser General Public License
|
|
56
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
57
|
+
*/
|
|
58
|
+
const dntShim = __importStar(require("../_dnt.shims.js"));
|
|
59
|
+
const _0_bigint_js_1 = require("./0_bigint.js");
|
|
60
|
+
const _0_buffer_js_1 = require("./0_buffer.js");
|
|
61
|
+
class CTR {
|
|
62
|
+
get _state() {
|
|
63
|
+
return { iv: new Uint8Array(__classPrivateFieldGet(this, _CTR_iv, "f")), state: __classPrivateFieldGet(this, _CTR_incrementPending, "f") };
|
|
64
|
+
}
|
|
65
|
+
constructor(key, iv) {
|
|
66
|
+
_CTR_key.set(this, void 0);
|
|
67
|
+
_CTR_iv.set(this, void 0);
|
|
68
|
+
_CTR_incrementPending.set(this, 0);
|
|
69
|
+
__classPrivateFieldSet(this, _CTR_key, key, "f");
|
|
70
|
+
__classPrivateFieldSet(this, _CTR_iv, iv, "f");
|
|
71
|
+
}
|
|
72
|
+
static async importKey(key) {
|
|
73
|
+
return await dntShim.crypto.subtle.importKey("raw", key, "AES-CTR", false, ["encrypt"]);
|
|
74
|
+
}
|
|
75
|
+
async call(data) {
|
|
76
|
+
const promise = dntShim.crypto.subtle.encrypt({
|
|
77
|
+
name: "AES-CTR",
|
|
78
|
+
counter: new Uint8Array(__classPrivateFieldGet(this, _CTR_iv, "f")),
|
|
79
|
+
length: __classPrivateFieldGet(this, _CTR_iv, "f").length * 8,
|
|
80
|
+
}, __classPrivateFieldGet(this, _CTR_key, "f"), data);
|
|
81
|
+
const incrementPending = data.length % __classPrivateFieldGet(this, _CTR_iv, "f").length;
|
|
82
|
+
let incrementBy = (data.length - incrementPending) / __classPrivateFieldGet(this, _CTR_iv, "f").length;
|
|
83
|
+
__classPrivateFieldSet(this, _CTR_incrementPending, __classPrivateFieldGet(this, _CTR_incrementPending, "f") + incrementPending, "f");
|
|
84
|
+
while (__classPrivateFieldGet(this, _CTR_incrementPending, "f") >= __classPrivateFieldGet(this, _CTR_iv, "f").length) {
|
|
85
|
+
__classPrivateFieldSet(this, _CTR_incrementPending, __classPrivateFieldGet(this, _CTR_incrementPending, "f") - __classPrivateFieldGet(this, _CTR_iv, "f").length, "f");
|
|
86
|
+
incrementBy += 1;
|
|
87
|
+
}
|
|
88
|
+
if (incrementBy) {
|
|
89
|
+
__classPrivateFieldSet(this, _CTR_iv, (0, _0_buffer_js_1.bufferFromBigInt)((0, _0_bigint_js_1.bigIntFromBuffer)(__classPrivateFieldGet(this, _CTR_iv, "f"), false, false) + BigInt(incrementBy), 16, false, false), "f");
|
|
90
|
+
}
|
|
91
|
+
return new Uint8Array(await promise);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exports.CTR = CTR;
|
|
95
|
+
_CTR_key = new WeakMap(), _CTR_iv = new WeakMap(), _CTR_incrementPending = new WeakMap();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"1_crypto_test.d.ts","sourceRoot":"","sources":["../../src/utilities/1_crypto_test.ts"],"names":[],"mappings":""}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
export declare function init(): Promise<void>;
|
|
2
|
-
/**
|
|
3
|
-
* Performs IGE-256 encryption.
|
|
4
|
-
*
|
|
5
|
-
* @param data The unencrypted data, larger than a byte, divisible by 16
|
|
6
|
-
* @param key 32-byte encryption key
|
|
7
|
-
* @param iv 32-byte initialization vector
|
|
8
|
-
*/
|
|
9
|
-
export declare function ige256Encrypt(data: Uint8Array, key: Uint8Array, iv: Uint8Array): Uint8Array;
|
|
10
|
-
/**
|
|
11
|
-
* Performs IGE-256 decryption.
|
|
12
|
-
*
|
|
13
|
-
* @param data The encrypted data, larger than a byte, divisible by 16
|
|
14
|
-
* @param key 32-byte encryption key
|
|
15
|
-
* @param iv 32-byte initialization vector
|
|
16
|
-
*/
|
|
17
|
-
export declare function ige256Decrypt(data: Uint8Array, key: Uint8Array, iv: Uint8Array): Uint8Array;
|
|
18
|
-
export interface Ctr256State {
|
|
19
|
-
statep: number;
|
|
20
|
-
ivp: number;
|
|
21
|
-
}
|
|
22
|
-
export declare function createCtr256State(iv: Uint8Array): Ctr256State;
|
|
23
|
-
export declare function destroyCtr256State(state: Ctr256State): void;
|
|
24
|
-
export interface __Ctr256StateValues {
|
|
25
|
-
iv: Uint8Array;
|
|
26
|
-
state: Uint8Array;
|
|
27
|
-
}
|
|
28
|
-
export declare function __getCtr256StateValues(state: Ctr256State): __Ctr256StateValues;
|
|
29
|
-
export declare function __settCtr256StateState(state: Ctr256State, state_: Uint8Array): void;
|
|
30
|
-
/**
|
|
31
|
-
* Performs CTR-256 encryption/decryption.
|
|
32
|
-
*
|
|
33
|
-
* @param data The data, larger than a byte
|
|
34
|
-
* @param key 32-byte encryption key
|
|
35
|
-
* @param iv 16-byte initialization vector
|
|
36
|
-
* @param state Result of `createCtr256State()`
|
|
37
|
-
*/
|
|
38
|
-
export declare function ctr256(data: Uint8Array, key: Uint8Array, state: Ctr256State): void;
|
|
39
|
-
/**
|
|
40
|
-
* Performs CBC-256 encryption.
|
|
41
|
-
*
|
|
42
|
-
* @param data The unencrypted data, larger than a byte, divisible by 16
|
|
43
|
-
* @param key 32-byte encryption key
|
|
44
|
-
* @param iv 16-byte initialization vector
|
|
45
|
-
*/
|
|
46
|
-
export declare function cbc256Encrypt(data: Uint8Array, key: Uint8Array, iv: Uint8Array): Uint8Array;
|
|
47
|
-
/**
|
|
48
|
-
* Performs CBC-256 decryption.
|
|
49
|
-
*
|
|
50
|
-
* @param data The encrypted data, larger than a byte, divisible by 16
|
|
51
|
-
* @param key 32-byte encryption key
|
|
52
|
-
* @param iv 16-byte initialization vector
|
|
53
|
-
*/
|
|
54
|
-
export declare function cbc256Decrypt(data: Uint8Array, key: Uint8Array, iv: Uint8Array): Uint8Array;
|
|
55
|
-
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -1,167 +0,0 @@
|
|
|
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
|
-
function checkIgeParams(data, key, iv) {
|
|
9
|
-
if (data.byteLength == 0) {
|
|
10
|
-
throw new TypeError("data must not be empty");
|
|
11
|
-
}
|
|
12
|
-
else if (data.byteLength % 16 != 0) {
|
|
13
|
-
throw new TypeError("data must consist of a number of bytes that is divisible by 16");
|
|
14
|
-
}
|
|
15
|
-
else if (key.byteLength != 32) {
|
|
16
|
-
throw new TypeError("key must be 32 bytes");
|
|
17
|
-
}
|
|
18
|
-
else if (iv.byteLength != 32) {
|
|
19
|
-
throw new TypeError("iv must be 32 bytes");
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Performs IGE-256 encryption.
|
|
24
|
-
*
|
|
25
|
-
* @param data The unencrypted data, larger than a byte, divisible by 16
|
|
26
|
-
* @param key 32-byte encryption key
|
|
27
|
-
* @param iv 32-byte initialization vector
|
|
28
|
-
*/
|
|
29
|
-
export function ige256Encrypt(data, key, iv) {
|
|
30
|
-
checkIgeParams(data, key, iv);
|
|
31
|
-
const out = module_._malloc(data.byteLength);
|
|
32
|
-
const datap = module_._malloc(data.byteLength);
|
|
33
|
-
module_.HEAPU8.set(data, datap);
|
|
34
|
-
module_.ccall("ige256_encrypt", "void", ["pointer", "pointer", "number", "array", "array"], [datap, out, data.byteLength, key, iv]);
|
|
35
|
-
try {
|
|
36
|
-
return module_.HEAPU8.slice(out, out + data.byteLength);
|
|
37
|
-
}
|
|
38
|
-
finally {
|
|
39
|
-
module_._free(out);
|
|
40
|
-
module_._free(datap);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Performs IGE-256 decryption.
|
|
45
|
-
*
|
|
46
|
-
* @param data The encrypted data, larger than a byte, divisible by 16
|
|
47
|
-
* @param key 32-byte encryption key
|
|
48
|
-
* @param iv 32-byte initialization vector
|
|
49
|
-
*/
|
|
50
|
-
export function ige256Decrypt(data, key, iv) {
|
|
51
|
-
checkIgeParams(data, key, iv);
|
|
52
|
-
const out = module_._malloc(data.byteLength);
|
|
53
|
-
const datap = module_._malloc(data.byteLength);
|
|
54
|
-
module_.HEAPU8.set(data, datap);
|
|
55
|
-
module_.ccall("ige256_decrypt", "void", ["pointer", "pointer", "number", "array", "array"], [datap, out, data.byteLength, key, iv]);
|
|
56
|
-
try {
|
|
57
|
-
return module_.HEAPU8.slice(out, out + data.byteLength);
|
|
58
|
-
}
|
|
59
|
-
finally {
|
|
60
|
-
module_._free(out);
|
|
61
|
-
module_._free(datap);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
function checkCtrParams(data, key) {
|
|
65
|
-
if (data.byteLength == 0) {
|
|
66
|
-
throw new TypeError("data must not be empty");
|
|
67
|
-
}
|
|
68
|
-
else if (key.byteLength != 32) {
|
|
69
|
-
throw new TypeError("key must be 32 bytes");
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
export function createCtr256State(iv) {
|
|
73
|
-
if (iv.byteLength != 16) {
|
|
74
|
-
throw new TypeError("iv must be 16 bytes");
|
|
75
|
-
}
|
|
76
|
-
const state = {
|
|
77
|
-
ivp: module_._malloc(16),
|
|
78
|
-
statep: module_._malloc(1),
|
|
79
|
-
};
|
|
80
|
-
module_.HEAPU8.set(iv, state.ivp);
|
|
81
|
-
module_.HEAPU8[state.statep] = 0;
|
|
82
|
-
return state;
|
|
83
|
-
}
|
|
84
|
-
export function destroyCtr256State(state) {
|
|
85
|
-
module_._free(state.ivp);
|
|
86
|
-
module_._free(state.statep);
|
|
87
|
-
}
|
|
88
|
-
export function __getCtr256StateValues(state) {
|
|
89
|
-
return {
|
|
90
|
-
iv: module_.HEAPU8.slice(state.ivp, state.ivp + 16),
|
|
91
|
-
state: module_.HEAPU8.slice(state.statep, state.statep + 1),
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
export function __settCtr256StateState(state, state_) {
|
|
95
|
-
if (state_.byteLength != 1) {
|
|
96
|
-
throw new Error("state_ must be 1 byte");
|
|
97
|
-
}
|
|
98
|
-
module_.HEAPU8.set(state_, state.statep);
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Performs CTR-256 encryption/decryption.
|
|
102
|
-
*
|
|
103
|
-
* @param data The data, larger than a byte
|
|
104
|
-
* @param key 32-byte encryption key
|
|
105
|
-
* @param iv 16-byte initialization vector
|
|
106
|
-
* @param state Result of `createCtr256State()`
|
|
107
|
-
*/
|
|
108
|
-
export function ctr256(data, key, state) {
|
|
109
|
-
checkCtrParams(data, key);
|
|
110
|
-
const datap = module_._malloc(data.byteLength);
|
|
111
|
-
module_.HEAPU8.set(data, datap);
|
|
112
|
-
module_.ccall("ctr256", "void", ["pointer", "number", "array", "pointer", "pointer"], [datap, data.byteLength, key, state.ivp, state.statep]);
|
|
113
|
-
data.set(module_.HEAPU8.slice(datap, datap + data.byteLength));
|
|
114
|
-
module_._free(datap);
|
|
115
|
-
}
|
|
116
|
-
function checkCbcParams(data, key, iv) {
|
|
117
|
-
if (data.byteLength == 0) {
|
|
118
|
-
throw new TypeError("data must not be empty");
|
|
119
|
-
}
|
|
120
|
-
else if (data.byteLength % 16 != 0) {
|
|
121
|
-
throw new TypeError("data must consist of a number of bytes that is divisible by 16");
|
|
122
|
-
}
|
|
123
|
-
else if (key.byteLength != 32) {
|
|
124
|
-
throw new TypeError("key must be 32 bytes");
|
|
125
|
-
}
|
|
126
|
-
else if (iv.byteLength != 16) {
|
|
127
|
-
throw new TypeError("iv must be 16 bytes");
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Performs CBC-256 encryption.
|
|
132
|
-
*
|
|
133
|
-
* @param data The unencrypted data, larger than a byte, divisible by 16
|
|
134
|
-
* @param key 32-byte encryption key
|
|
135
|
-
* @param iv 16-byte initialization vector
|
|
136
|
-
*/
|
|
137
|
-
export function cbc256Encrypt(data, key, iv) {
|
|
138
|
-
checkCbcParams(data, key, iv);
|
|
139
|
-
const datap = module_._malloc(data.byteLength);
|
|
140
|
-
module_.HEAPU8.set(data, datap);
|
|
141
|
-
module_.ccall("cbc256_encrypt", "void", ["pointer", "number", "array", "array"], [datap, data.byteLength, key, iv]);
|
|
142
|
-
try {
|
|
143
|
-
return module_.HEAPU8.slice(datap, datap + data.byteLength);
|
|
144
|
-
}
|
|
145
|
-
finally {
|
|
146
|
-
module_._free(datap);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Performs CBC-256 decryption.
|
|
151
|
-
*
|
|
152
|
-
* @param data The encrypted data, larger than a byte, divisible by 16
|
|
153
|
-
* @param key 32-byte encryption key
|
|
154
|
-
* @param iv 16-byte initialization vector
|
|
155
|
-
*/
|
|
156
|
-
export function cbc256Decrypt(data, key, iv) {
|
|
157
|
-
checkCbcParams(data, key, iv);
|
|
158
|
-
const datap = module_._malloc(data.byteLength);
|
|
159
|
-
module_.HEAPU8.set(data, datap);
|
|
160
|
-
module_.ccall("cbc256_decrypt", "void", ["pointer", "number", "array", "array"], [datap, data.byteLength, key, iv]);
|
|
161
|
-
try {
|
|
162
|
-
return module_.HEAPU8.slice(datap, datap + data.byteLength);
|
|
163
|
-
}
|
|
164
|
-
finally {
|
|
165
|
-
module_._free(datap);
|
|
166
|
-
}
|
|
167
|
-
}
|