@mtkruto/node 0.0.901 → 0.0.902
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/client/client.js +27 -25
- package/esm/client/client_plain.js +2 -2
- package/{script/utilities/1_message.d.ts → esm/client/utilities/0_message.d.ts} +2 -2
- package/esm/{utilities/1_message.js → client/utilities/0_message.js} +10 -10
- package/esm/{utilities/1_password.d.ts → client/utilities/0_password.d.ts} +2 -2
- package/esm/{utilities/1_password.js → client/utilities/0_password.js} +5 -5
- package/esm/connection/connection_web_socket.js +5 -2
- package/esm/constants.d.ts +1 -1
- package/esm/constants.js +1 -1
- package/esm/deps.js +1 -1
- package/esm/mod.d.ts +1 -1
- package/esm/mod.js +1 -1
- package/esm/transport/transport_abridged.js +1 -1
- package/esm/transport/transport_intermediate.js +1 -1
- package/esm/{utilities/1_obfuscation.d.ts → transport/utilities/0_obfuscation.d.ts} +2 -2
- package/esm/{utilities/1_obfuscation.js → transport/utilities/0_obfuscation.js} +3 -3
- package/esm/{utilities → types/utilities}/0_html.d.ts +1 -1
- package/esm/{utilities → types/utilities}/0_html.js +2 -2
- package/package.json +1 -1
- package/script/client/client.js +31 -29
- package/script/client/client_plain.js +4 -4
- package/{esm/utilities/1_message.d.ts → script/client/utilities/0_message.d.ts} +2 -2
- package/script/{utilities/1_message.js → client/utilities/0_message.js} +10 -10
- package/script/{utilities/1_password.d.ts → client/utilities/0_password.d.ts} +2 -2
- package/script/{utilities/1_password.js → client/utilities/0_password.js} +5 -5
- package/script/connection/connection_web_socket.js +4 -1
- package/script/constants.d.ts +1 -1
- package/script/constants.js +1 -1
- package/script/deps.js +1 -1
- package/script/mod.d.ts +1 -1
- package/script/mod.js +2 -2
- package/script/transport/transport_abridged.js +2 -2
- package/script/transport/transport_intermediate.js +2 -2
- package/script/{utilities/1_obfuscation.d.ts → transport/utilities/0_obfuscation.d.ts} +2 -2
- package/script/{utilities/1_obfuscation.js → transport/utilities/0_obfuscation.js} +3 -3
- package/script/{utilities → types/utilities}/0_html.d.ts +1 -1
- package/script/{utilities → types/utilities}/0_html.js +2 -2
- /package/esm/{utilities/1_password_test.d.ts → client/utilities/0_password_test.d.ts} +0 -0
- /package/script/{utilities/1_password_test.d.ts → client/utilities/0_password_test.d.ts} +0 -0
package/esm/client/client.js
CHANGED
|
@@ -3,9 +3,6 @@ import { ackThreshold, CHANNEL_DIFFERENCE_LIMIT_BOT, CHANNEL_DIFFERENCE_LIMIT_US
|
|
|
3
3
|
import { bigIntFromBuffer, getRandomBigInt, getRandomId } from "../utilities/0_bigint.js";
|
|
4
4
|
import { UNREACHABLE } from "../utilities/0_control.js";
|
|
5
5
|
import { sha1 } from "../utilities/0_hash.js";
|
|
6
|
-
import { parseHtml } from "../utilities/0_html.js";
|
|
7
|
-
import { decryptMessage, encryptMessage, getMessageId } from "../utilities/1_message.js";
|
|
8
|
-
import { checkPassword } from "../utilities/1_password.js";
|
|
9
6
|
import { as } from "../tl/1_tl_object.js";
|
|
10
7
|
import * as types from "../tl/2_types.js";
|
|
11
8
|
import * as functions from "../tl/3_functions.js";
|
|
@@ -16,15 +13,20 @@ import { MessageContainer } from "../tl/7_message_container.js";
|
|
|
16
13
|
import { ClientAbstract } from "./client_abstract.js";
|
|
17
14
|
import { ClientPlain } from "./client_plain.js";
|
|
18
15
|
import { StorageMemory } from "../storage/storage_memory.js";
|
|
16
|
+
import { parseHtml } from "../types/utilities/0_html.js";
|
|
19
17
|
import { messageEntityToTlObject } from "../types/0_message_entity.js";
|
|
20
18
|
import { replyKeyboardRemoveToTlObject } from "../types/0_reply_keyboard_remove.js";
|
|
21
19
|
import { forceReplyToTlObject } from "../types/0_force_reply.js";
|
|
22
20
|
import { replyKeyboardMarkupToTlObject } from "../types/2_reply_keyboard_markup.js";
|
|
23
21
|
import { inlineKeyboardMarkupToTlObject } from "../types/2_inline_keyboard_markup.js";
|
|
24
22
|
import { constructMessage } from "../types/3_message.js"; // high-level wrapper for Telegram API's message
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const
|
|
23
|
+
import { decryptMessage, encryptMessage, getMessageId } from "./utilities/0_message.js";
|
|
24
|
+
import { checkPassword } from "./utilities/0_password.js";
|
|
25
|
+
const d = debug("Client");
|
|
26
|
+
const dGap = debug("Client/recoverUpdateGap");
|
|
27
|
+
const dGapC = debug("Client/recoverChannelUpdateGap");
|
|
28
|
+
const dAuth = debug("Client/authorize");
|
|
29
|
+
const dRecv = debug("Client/receiveLoop");
|
|
28
30
|
const UPDATE_GAP = Symbol();
|
|
29
31
|
export const getEntity = Symbol();
|
|
30
32
|
export const restartAuth = Symbol();
|
|
@@ -161,7 +163,7 @@ export class Client extends ClientAbstract {
|
|
|
161
163
|
if (body instanceof types.GZIPPacked) {
|
|
162
164
|
body = new TLReader(gunzip(body.packedData)).readObject();
|
|
163
165
|
}
|
|
164
|
-
|
|
166
|
+
dRecv("received %s", body.constructor.name);
|
|
165
167
|
if (body instanceof types.Updates || body instanceof types.TypeUpdate) {
|
|
166
168
|
await this.processUpdates(body);
|
|
167
169
|
}
|
|
@@ -171,10 +173,10 @@ export class Client extends ClientAbstract {
|
|
|
171
173
|
result = new TLReader(gunzip(result.packedData)).readObject();
|
|
172
174
|
}
|
|
173
175
|
if (result instanceof types.RPCError) {
|
|
174
|
-
|
|
176
|
+
dRecv("RPCResult: %d %s", result.errorCode, result.errorMessage);
|
|
175
177
|
}
|
|
176
178
|
else {
|
|
177
|
-
|
|
179
|
+
dRecv("RPCResult: %s", result.constructor.name);
|
|
178
180
|
}
|
|
179
181
|
if (result instanceof types.Updates || result instanceof types.TypeUpdate) {
|
|
180
182
|
await this.processUpdates(result);
|
|
@@ -324,7 +326,7 @@ export class Client extends ClientAbstract {
|
|
|
324
326
|
if (!this.apiHash) {
|
|
325
327
|
throw new Error("apiHash not set");
|
|
326
328
|
}
|
|
327
|
-
|
|
329
|
+
dAuth("authorizing with %s", typeof params === "string" ? "bot token" : params instanceof types.AuthExportedAuthorization ? "exported authorization" : "AuthorizeUserParams");
|
|
328
330
|
await this.invoke(new functions.InitConnection({
|
|
329
331
|
apiId: this.apiId,
|
|
330
332
|
appVersion: this.appVersion,
|
|
@@ -350,7 +352,7 @@ export class Client extends ClientAbstract {
|
|
|
350
352
|
const input = await checkPassword(password, ap);
|
|
351
353
|
await this.invoke(new functions.AuthCheckPassword({ password: input }));
|
|
352
354
|
await this.storage.setAccountType("user");
|
|
353
|
-
|
|
355
|
+
dAuth("authorized as user");
|
|
354
356
|
break;
|
|
355
357
|
}
|
|
356
358
|
catch (err) {
|
|
@@ -386,7 +388,7 @@ export class Client extends ClientAbstract {
|
|
|
386
388
|
try {
|
|
387
389
|
if (params instanceof types.AuthExportedAuthorization) {
|
|
388
390
|
await this.invoke(new functions.AuthImportAuthorization({ id: params.id, bytes: params.bytes }));
|
|
389
|
-
|
|
391
|
+
dAuth("authorization imported");
|
|
390
392
|
}
|
|
391
393
|
else if (typeof params == "object") {
|
|
392
394
|
while (true) {
|
|
@@ -402,7 +404,7 @@ export class Client extends ClientAbstract {
|
|
|
402
404
|
phoneNumber,
|
|
403
405
|
settings: new types.CodeSettings(),
|
|
404
406
|
}));
|
|
405
|
-
|
|
407
|
+
dAuth("verification code sent");
|
|
406
408
|
if (sentCode instanceof types.AuthSentCode) {
|
|
407
409
|
while (true) {
|
|
408
410
|
const phoneCode = typeof params.code === "string" ? params.code : await params.code();
|
|
@@ -414,7 +416,7 @@ export class Client extends ClientAbstract {
|
|
|
414
416
|
else {
|
|
415
417
|
signedIn = true;
|
|
416
418
|
await this.storage.setAccountType("user");
|
|
417
|
-
|
|
419
|
+
dAuth("authorized as user");
|
|
418
420
|
break;
|
|
419
421
|
}
|
|
420
422
|
}
|
|
@@ -449,7 +451,7 @@ export class Client extends ClientAbstract {
|
|
|
449
451
|
else {
|
|
450
452
|
await this.invoke(new functions.AuthImportBotAuthorization({ apiId: this.apiId, apiHash: this.apiHash, botAuthToken: params, flags: 0 }));
|
|
451
453
|
await this.storage.setAccountType("bot");
|
|
452
|
-
|
|
454
|
+
dAuth("authorized as bot");
|
|
453
455
|
}
|
|
454
456
|
}
|
|
455
457
|
catch (err) {
|
|
@@ -511,7 +513,7 @@ export class Client extends ClientAbstract {
|
|
|
511
513
|
decrypted = await decryptMessage(buffer, this.auth.key, this.auth.id, this.sessionId);
|
|
512
514
|
}
|
|
513
515
|
catch (err) {
|
|
514
|
-
|
|
516
|
+
dRecv("failed to decrypt message: %o", err);
|
|
515
517
|
continue;
|
|
516
518
|
}
|
|
517
519
|
const messages = decrypted instanceof MessageContainer ? decrypted.messages : [decrypted];
|
|
@@ -800,7 +802,7 @@ export class Client extends ClientAbstract {
|
|
|
800
802
|
return localState;
|
|
801
803
|
}
|
|
802
804
|
async recoverUpdateGap(source) {
|
|
803
|
-
|
|
805
|
+
dGap("recovering from update gap [%s]", source);
|
|
804
806
|
const release = await this.updateGapRecoveryMutex.acquire();
|
|
805
807
|
try {
|
|
806
808
|
let state = await this.getLocalState();
|
|
@@ -816,7 +818,7 @@ export class Client extends ClientAbstract {
|
|
|
816
818
|
await this.applyUpdateNoGap(update);
|
|
817
819
|
}
|
|
818
820
|
if (difference instanceof types.UpdatesDifference) {
|
|
819
|
-
|
|
821
|
+
dGap("recovered from update gap");
|
|
820
822
|
break;
|
|
821
823
|
}
|
|
822
824
|
else if (difference instanceof types.UpdatesDifferenceSlice) {
|
|
@@ -829,11 +831,11 @@ export class Client extends ClientAbstract {
|
|
|
829
831
|
else if (difference instanceof types.UpdatesDifferenceTooLong) {
|
|
830
832
|
// stored messages should be invalidated in case we store messages in the future
|
|
831
833
|
state.pts = difference.pts;
|
|
832
|
-
|
|
834
|
+
dGap("received differenceTooLong");
|
|
833
835
|
}
|
|
834
836
|
else if (difference instanceof types.UpdatesDifferenceEmpty) {
|
|
835
837
|
await this.setUpdateStateDate(difference.date);
|
|
836
|
-
|
|
838
|
+
dGap("there was no update gap");
|
|
837
839
|
break;
|
|
838
840
|
}
|
|
839
841
|
else {
|
|
@@ -846,7 +848,7 @@ export class Client extends ClientAbstract {
|
|
|
846
848
|
}
|
|
847
849
|
}
|
|
848
850
|
async recoverChannelUpdateGap(channelId, source) {
|
|
849
|
-
|
|
851
|
+
dGapC("recovering channel update gap [%o, %s]", channelId, source);
|
|
850
852
|
const release = await this.updateGapRecoveryMutex.acquire();
|
|
851
853
|
try {
|
|
852
854
|
const pts_ = await this.storage.getChannelPts(channelId);
|
|
@@ -869,12 +871,12 @@ export class Client extends ClientAbstract {
|
|
|
869
871
|
await this.applyUpdateNoGap(update, false);
|
|
870
872
|
}
|
|
871
873
|
await this.storage.setChannelPts(channelId, difference.pts);
|
|
872
|
-
|
|
874
|
+
dGapC("recovered from update gap [%o, %s]", channelId, source);
|
|
873
875
|
break;
|
|
874
876
|
}
|
|
875
877
|
else if (difference instanceof types.UpdatesChannelDifferenceTooLong) {
|
|
876
878
|
// invalidate messages
|
|
877
|
-
|
|
879
|
+
dGapC("received channelDifferenceTooLong");
|
|
878
880
|
await this.processChats(difference.chats);
|
|
879
881
|
await this.processUsers(difference.users);
|
|
880
882
|
for (const message of difference.messages) {
|
|
@@ -887,10 +889,10 @@ export class Client extends ClientAbstract {
|
|
|
887
889
|
else {
|
|
888
890
|
UNREACHABLE();
|
|
889
891
|
}
|
|
890
|
-
|
|
892
|
+
dGapC("processed channelDifferenceTooLong");
|
|
891
893
|
}
|
|
892
894
|
else if (difference instanceof types.UpdatesChannelDifferenceEmpty) {
|
|
893
|
-
|
|
895
|
+
dGapC("there was no update gap");
|
|
894
896
|
break;
|
|
895
897
|
}
|
|
896
898
|
}
|
|
@@ -6,12 +6,12 @@ import { UNREACHABLE } from "../utilities/0_control.js";
|
|
|
6
6
|
import { sha1 } from "../utilities/0_hash.js";
|
|
7
7
|
import { rsaPad } from "../utilities/1_auth.js";
|
|
8
8
|
import { serialize } from "../tl/1_tl_object.js";
|
|
9
|
-
import { packUnencryptedMessage, unpackUnencryptedMessage } from "../utilities/1_message.js";
|
|
10
9
|
import { ClientDHInnerData, DHGenOK, PQInnerDataDC, ResPQ, ServerDHInnerData, ServerDHParamsOK } from "../tl/2_types.js";
|
|
11
10
|
import { ReqDHParams, ReqPQMulti, SetClientDHParams } from "../tl/3_functions.js";
|
|
12
11
|
import { TLReader } from "../tl/3_tl_reader.js";
|
|
13
12
|
import { ClientAbstract } from "./client_abstract.js";
|
|
14
|
-
|
|
13
|
+
import { packUnencryptedMessage, unpackUnencryptedMessage } from "./utilities/0_message.js";
|
|
14
|
+
const d = debug("ClientPlain/createAuthKey");
|
|
15
15
|
export class ClientPlain extends ClientAbstract {
|
|
16
16
|
async invoke(function_) {
|
|
17
17
|
await this.transport.send(packUnencryptedMessage(function_[serialize]()));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Message } from "
|
|
2
|
-
import { MessageContainer } from "
|
|
1
|
+
import { Message } from "../../tl/6_message.js";
|
|
2
|
+
import { MessageContainer } from "../../tl/7_message_container.js";
|
|
3
3
|
export declare function getMessageId(): bigint;
|
|
4
4
|
export declare function packUnencryptedMessage(data: Uint8Array): Uint8Array;
|
|
5
5
|
export declare function unpackUnencryptedMessage(buffer: Uint8Array): {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { assertEquals, ige256Decrypt, ige256Encrypt } from "
|
|
2
|
-
import { TLRawReader } from "
|
|
3
|
-
import { TLRawWriter } from "
|
|
4
|
-
import { id, serialize } from "
|
|
5
|
-
import { TLReader } from "
|
|
6
|
-
import { RPCResult } from "
|
|
7
|
-
import { Message } from "
|
|
8
|
-
import { MessageContainer } from "
|
|
9
|
-
import { bufferFromBigInt, concat } from "
|
|
10
|
-
import { sha256 } from "
|
|
1
|
+
import { assertEquals, ige256Decrypt, ige256Encrypt } from "../../deps.js";
|
|
2
|
+
import { TLRawReader } from "../../tl/0_tl_raw_reader.js";
|
|
3
|
+
import { TLRawWriter } from "../../tl/0_tl_raw_writer.js";
|
|
4
|
+
import { id, serialize } from "../../tl/1_tl_object.js";
|
|
5
|
+
import { TLReader } from "../../tl/3_tl_reader.js";
|
|
6
|
+
import { RPCResult } from "../../tl/5_rpc_result.js";
|
|
7
|
+
import { Message } from "../../tl/6_message.js";
|
|
8
|
+
import { MessageContainer } from "../../tl/7_message_container.js";
|
|
9
|
+
import { bufferFromBigInt, concat } from "../../utilities/0_buffer.js";
|
|
10
|
+
import { sha256 } from "../../utilities/0_hash.js";
|
|
11
11
|
let lastMsgId = 0n;
|
|
12
12
|
export function getMessageId() {
|
|
13
13
|
const now = new Date().getTime() / 1000 + 0;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as types from "
|
|
2
|
-
import { sha256 } from "
|
|
1
|
+
import * as types from "../../tl/2_types.js";
|
|
2
|
+
import { sha256 } from "../../utilities/0_hash.js";
|
|
3
3
|
export declare function isSafePrime(primeBytes: Uint8Array, g: number): boolean;
|
|
4
4
|
export declare const h: typeof sha256;
|
|
5
5
|
export declare const sh: (data: Uint8Array, salt: Uint8Array) => Promise<Uint8Array>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as dntShim from "
|
|
2
|
-
import * as types from "
|
|
3
|
-
import { bufferFromBigInt, concat } from "
|
|
4
|
-
import { sha256 } from "
|
|
5
|
-
import { bigIntFromBuffer, getRandomBigInt, mod, modExp } from "
|
|
1
|
+
import * as dntShim from "../../_dnt.shims.js";
|
|
2
|
+
import * as types from "../../tl/2_types.js";
|
|
3
|
+
import { bufferFromBigInt, concat } from "../../utilities/0_buffer.js";
|
|
4
|
+
import { sha256 } from "../../utilities/0_hash.js";
|
|
5
|
+
import { bigIntFromBuffer, getRandomBigInt, mod, modExp } from "../../utilities/0_bigint.js";
|
|
6
6
|
export function isSafePrime(primeBytes, g) {
|
|
7
7
|
// deno-fmt-ignore
|
|
8
8
|
const goodPrime = new Uint8Array([
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as dntShim from "../_dnt.shims.js";
|
|
2
|
-
import { Mutex } from "../deps.js";
|
|
2
|
+
import { debug, Mutex } from "../deps.js";
|
|
3
|
+
const d = debug("ConnectionWebSocket");
|
|
3
4
|
export class ConnectionWebSocket {
|
|
4
5
|
constructor(url) {
|
|
5
6
|
Object.defineProperty(this, "webSocket", {
|
|
@@ -44,7 +45,9 @@ export class ConnectionWebSocket {
|
|
|
44
45
|
this.nextResolve = null;
|
|
45
46
|
}
|
|
46
47
|
};
|
|
47
|
-
this.webSocket.onerror =
|
|
48
|
+
this.webSocket.onerror = (err) => {
|
|
49
|
+
d("WebSocket error: %O", err);
|
|
50
|
+
};
|
|
48
51
|
}
|
|
49
52
|
get connected() {
|
|
50
53
|
return this.webSocket.readyState == dntShim.WebSocket.OPEN;
|
package/esm/constants.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export declare const publicKeys: Map<bigint, [bigint, bigint]>;
|
|
|
4
4
|
export declare const VECTOR_CONSTRUCTOR = 481674261;
|
|
5
5
|
export declare const DEFAULT_INITIAL_DC: DC;
|
|
6
6
|
export declare const LAYER = 158;
|
|
7
|
-
export declare const DEFAULT_APP_VERSION = "MTKruto 0.0.
|
|
7
|
+
export declare const DEFAULT_APP_VERSION = "MTKruto 0.0.902";
|
|
8
8
|
export declare const DEFAULT_DEVICE_MODEL: string;
|
|
9
9
|
export declare const DEFAULT_LANG_CODE: string;
|
|
10
10
|
export declare const DEFAULT_LANG_PACK = "";
|
package/esm/constants.js
CHANGED
|
@@ -62,7 +62,7 @@ export const publicKeys = new Map([
|
|
|
62
62
|
export const VECTOR_CONSTRUCTOR = 0x1CB5C415;
|
|
63
63
|
export const DEFAULT_INITIAL_DC = "2-test";
|
|
64
64
|
export const LAYER = 158;
|
|
65
|
-
export const DEFAULT_APP_VERSION = "MTKruto 0.0.
|
|
65
|
+
export const DEFAULT_APP_VERSION = "MTKruto 0.0.902";
|
|
66
66
|
// @ts-ignore: lib
|
|
67
67
|
export const DEFAULT_DEVICE_MODEL = typeof dntShim.Deno === "undefined" ? typeof navigator === "undefined" ? typeof process === "undefined" ? "Unknown" : process.platform + "-" + process.arch : navigator.userAgent.split(" ")[0] : dntShim.Deno.build.os + "-" + dntShim.Deno.build.arch;
|
|
68
68
|
export const DEFAULT_LANG_CODE = typeof navigator === "undefined" ? "en" : navigator.language.split("-")[0];
|
package/esm/deps.js
CHANGED
|
@@ -4,6 +4,6 @@ export { gunzip, gzip } from "./deps/raw.githubusercontent.com/MTKruto/compress/
|
|
|
4
4
|
export { Mutex } from "async-mutex";
|
|
5
5
|
export { Parser } from "./deps/deno.land/x/html_parser@v0.1.3/src/mod.js";
|
|
6
6
|
import { debug as debug_ } from "./deps/raw.githubusercontent.com/MTKruto/debug/master/mod.js";
|
|
7
|
-
export const debug = (v) => debug_(`
|
|
7
|
+
export const debug = (v) => debug_(`mtkruto/${v}`);
|
|
8
8
|
export { queue } from "./deps/deno.land/x/q@v0.0.1/mod.js";
|
|
9
9
|
export { decode as base64Decode, encode as base64Encode } from "./deps/deno.land/std@0.190.0/encoding/base64.js";
|
package/esm/mod.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { checkPassword } from "./utilities/1_password.js";
|
|
2
1
|
import { getRandomId } from "./utilities/0_bigint.js";
|
|
2
|
+
import { checkPassword } from "./client/utilities/0_password.js";
|
|
3
3
|
export declare const utils: {
|
|
4
4
|
checkPassword: typeof checkPassword;
|
|
5
5
|
getRandomId: typeof getRandomId;
|
package/esm/mod.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { checkPassword } from "./utilities/1_password.js";
|
|
2
1
|
import { getRandomId } from "./utilities/0_bigint.js";
|
|
2
|
+
import { checkPassword } from "./client/utilities/0_password.js";
|
|
3
3
|
export const utils = { checkPassword, getRandomId };
|
|
4
4
|
export { as } from "./tl/1_tl_object.js";
|
|
5
5
|
export * as types from "./tl/2_types.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { bufferFromBigInt, concat } from "../utilities/0_buffer.js";
|
|
2
|
-
import { getObfuscationParameters } from "
|
|
2
|
+
import { getObfuscationParameters } from "./utilities/0_obfuscation.js";
|
|
3
3
|
import { Transport } from "./transport.js";
|
|
4
4
|
export class TransportAbridged extends Transport {
|
|
5
5
|
constructor(connection, obfuscated = false) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { bufferFromBigInt, concat } from "../utilities/0_buffer.js";
|
|
2
|
-
import { getObfuscationParameters } from "
|
|
2
|
+
import { getObfuscationParameters } from "./utilities/0_obfuscation.js";
|
|
3
3
|
import { Transport } from "./transport.js";
|
|
4
4
|
export class TransportIntermediate extends Transport {
|
|
5
5
|
constructor(connection, obfuscated = false) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { CTR } from "../../utilities/0_crypto.js";
|
|
2
|
+
import { Connection } from "../../connection/connection.js";
|
|
3
3
|
export declare function getObfuscationParameters(protocol: number, connection: Connection): Promise<{
|
|
4
4
|
encryptionCTR: CTR;
|
|
5
5
|
decryptionCTR: CTR;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as dntShim from "
|
|
2
|
-
import { bufferFromBigInt, concat } from "
|
|
3
|
-
import { CTR } from "
|
|
1
|
+
import * as dntShim from "../../_dnt.shims.js";
|
|
2
|
+
import { bufferFromBigInt, concat } from "../../utilities/0_buffer.js";
|
|
3
|
+
import { CTR } from "../../utilities/0_crypto.js";
|
|
4
4
|
export async function getObfuscationParameters(protocol, connection) {
|
|
5
5
|
const dc = 0xFCFF;
|
|
6
6
|
let init;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { MessageEntity } from "../
|
|
1
|
+
import { MessageEntity } from "../0_message_entity.js";
|
|
2
2
|
export declare function parseHtml(html: string): readonly [string, MessageEntity[]];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Parser } from "
|
|
2
|
-
import { MessageEntityType } from "../
|
|
1
|
+
import { Parser } from "../../deps.js";
|
|
2
|
+
import { MessageEntityType } from "../0_message_entity.js";
|
|
3
3
|
export function parseHtml(html) {
|
|
4
4
|
let text = "";
|
|
5
5
|
const entities = new Array();
|
package/package.json
CHANGED
package/script/client/client.js
CHANGED
|
@@ -29,9 +29,6 @@ const constants_js_1 = require("../constants.js");
|
|
|
29
29
|
const _0_bigint_js_1 = require("../utilities/0_bigint.js");
|
|
30
30
|
const _0_control_js_1 = require("../utilities/0_control.js");
|
|
31
31
|
const _0_hash_js_1 = require("../utilities/0_hash.js");
|
|
32
|
-
const _0_html_js_1 = require("../utilities/0_html.js");
|
|
33
|
-
const _1_message_js_1 = require("../utilities/1_message.js");
|
|
34
|
-
const _1_password_js_1 = require("../utilities/1_password.js");
|
|
35
32
|
const _1_tl_object_js_1 = require("../tl/1_tl_object.js");
|
|
36
33
|
const types = __importStar(require("../tl/2_types.js"));
|
|
37
34
|
const functions = __importStar(require("../tl/3_functions.js"));
|
|
@@ -42,15 +39,20 @@ const _7_message_container_js_1 = require("../tl/7_message_container.js");
|
|
|
42
39
|
const client_abstract_js_1 = require("./client_abstract.js");
|
|
43
40
|
const client_plain_js_1 = require("./client_plain.js");
|
|
44
41
|
const storage_memory_js_1 = require("../storage/storage_memory.js");
|
|
42
|
+
const _0_html_js_1 = require("../types/utilities/0_html.js");
|
|
45
43
|
const _0_message_entity_js_1 = require("../types/0_message_entity.js");
|
|
46
44
|
const _0_reply_keyboard_remove_js_1 = require("../types/0_reply_keyboard_remove.js");
|
|
47
45
|
const _0_force_reply_js_1 = require("../types/0_force_reply.js");
|
|
48
46
|
const _2_reply_keyboard_markup_js_1 = require("../types/2_reply_keyboard_markup.js");
|
|
49
47
|
const _2_inline_keyboard_markup_js_1 = require("../types/2_inline_keyboard_markup.js");
|
|
50
48
|
const _3_message_js_1 = require("../types/3_message.js"); // high-level wrapper for Telegram API's message
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
const
|
|
49
|
+
const _0_message_js_1 = require("./utilities/0_message.js");
|
|
50
|
+
const _0_password_js_1 = require("./utilities/0_password.js");
|
|
51
|
+
const d = (0, deps_js_1.debug)("Client");
|
|
52
|
+
const dGap = (0, deps_js_1.debug)("Client/recoverUpdateGap");
|
|
53
|
+
const dGapC = (0, deps_js_1.debug)("Client/recoverChannelUpdateGap");
|
|
54
|
+
const dAuth = (0, deps_js_1.debug)("Client/authorize");
|
|
55
|
+
const dRecv = (0, deps_js_1.debug)("Client/receiveLoop");
|
|
54
56
|
const UPDATE_GAP = Symbol();
|
|
55
57
|
exports.getEntity = Symbol();
|
|
56
58
|
exports.restartAuth = Symbol();
|
|
@@ -187,7 +189,7 @@ class Client extends client_abstract_js_1.ClientAbstract {
|
|
|
187
189
|
if (body instanceof types.GZIPPacked) {
|
|
188
190
|
body = new _3_tl_reader_js_1.TLReader((0, deps_js_1.gunzip)(body.packedData)).readObject();
|
|
189
191
|
}
|
|
190
|
-
|
|
192
|
+
dRecv("received %s", body.constructor.name);
|
|
191
193
|
if (body instanceof types.Updates || body instanceof types.TypeUpdate) {
|
|
192
194
|
await this.processUpdates(body);
|
|
193
195
|
}
|
|
@@ -197,10 +199,10 @@ class Client extends client_abstract_js_1.ClientAbstract {
|
|
|
197
199
|
result = new _3_tl_reader_js_1.TLReader((0, deps_js_1.gunzip)(result.packedData)).readObject();
|
|
198
200
|
}
|
|
199
201
|
if (result instanceof types.RPCError) {
|
|
200
|
-
|
|
202
|
+
dRecv("RPCResult: %d %s", result.errorCode, result.errorMessage);
|
|
201
203
|
}
|
|
202
204
|
else {
|
|
203
|
-
|
|
205
|
+
dRecv("RPCResult: %s", result.constructor.name);
|
|
204
206
|
}
|
|
205
207
|
if (result instanceof types.Updates || result instanceof types.TypeUpdate) {
|
|
206
208
|
await this.processUpdates(result);
|
|
@@ -350,7 +352,7 @@ class Client extends client_abstract_js_1.ClientAbstract {
|
|
|
350
352
|
if (!this.apiHash) {
|
|
351
353
|
throw new Error("apiHash not set");
|
|
352
354
|
}
|
|
353
|
-
|
|
355
|
+
dAuth("authorizing with %s", typeof params === "string" ? "bot token" : params instanceof types.AuthExportedAuthorization ? "exported authorization" : "AuthorizeUserParams");
|
|
354
356
|
await this.invoke(new functions.InitConnection({
|
|
355
357
|
apiId: this.apiId,
|
|
356
358
|
appVersion: this.appVersion,
|
|
@@ -373,10 +375,10 @@ class Client extends client_abstract_js_1.ClientAbstract {
|
|
|
373
375
|
if (ap.currentAlgo instanceof types.PasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow) {
|
|
374
376
|
try {
|
|
375
377
|
const password = typeof params.password === "string" ? params.password : await params.password();
|
|
376
|
-
const input = await (0,
|
|
378
|
+
const input = await (0, _0_password_js_1.checkPassword)(password, ap);
|
|
377
379
|
await this.invoke(new functions.AuthCheckPassword({ password: input }));
|
|
378
380
|
await this.storage.setAccountType("user");
|
|
379
|
-
|
|
381
|
+
dAuth("authorized as user");
|
|
380
382
|
break;
|
|
381
383
|
}
|
|
382
384
|
catch (err) {
|
|
@@ -412,7 +414,7 @@ class Client extends client_abstract_js_1.ClientAbstract {
|
|
|
412
414
|
try {
|
|
413
415
|
if (params instanceof types.AuthExportedAuthorization) {
|
|
414
416
|
await this.invoke(new functions.AuthImportAuthorization({ id: params.id, bytes: params.bytes }));
|
|
415
|
-
|
|
417
|
+
dAuth("authorization imported");
|
|
416
418
|
}
|
|
417
419
|
else if (typeof params == "object") {
|
|
418
420
|
while (true) {
|
|
@@ -428,7 +430,7 @@ class Client extends client_abstract_js_1.ClientAbstract {
|
|
|
428
430
|
phoneNumber,
|
|
429
431
|
settings: new types.CodeSettings(),
|
|
430
432
|
}));
|
|
431
|
-
|
|
433
|
+
dAuth("verification code sent");
|
|
432
434
|
if (sentCode instanceof types.AuthSentCode) {
|
|
433
435
|
while (true) {
|
|
434
436
|
const phoneCode = typeof params.code === "string" ? params.code : await params.code();
|
|
@@ -440,7 +442,7 @@ class Client extends client_abstract_js_1.ClientAbstract {
|
|
|
440
442
|
else {
|
|
441
443
|
signedIn = true;
|
|
442
444
|
await this.storage.setAccountType("user");
|
|
443
|
-
|
|
445
|
+
dAuth("authorized as user");
|
|
444
446
|
break;
|
|
445
447
|
}
|
|
446
448
|
}
|
|
@@ -475,7 +477,7 @@ class Client extends client_abstract_js_1.ClientAbstract {
|
|
|
475
477
|
else {
|
|
476
478
|
await this.invoke(new functions.AuthImportBotAuthorization({ apiId: this.apiId, apiHash: this.apiHash, botAuthToken: params, flags: 0 }));
|
|
477
479
|
await this.storage.setAccountType("bot");
|
|
478
|
-
|
|
480
|
+
dAuth("authorized as bot");
|
|
479
481
|
}
|
|
480
482
|
}
|
|
481
483
|
catch (err) {
|
|
@@ -534,10 +536,10 @@ class Client extends client_abstract_js_1.ClientAbstract {
|
|
|
534
536
|
}
|
|
535
537
|
let decrypted;
|
|
536
538
|
try {
|
|
537
|
-
decrypted = await (0,
|
|
539
|
+
decrypted = await (0, _0_message_js_1.decryptMessage)(buffer, this.auth.key, this.auth.id, this.sessionId);
|
|
538
540
|
}
|
|
539
541
|
catch (err) {
|
|
540
|
-
|
|
542
|
+
dRecv("failed to decrypt message: %o", err);
|
|
541
543
|
continue;
|
|
542
544
|
}
|
|
543
545
|
const messages = decrypted instanceof _7_message_container_js_1.MessageContainer ? decrypted.messages : [decrypted];
|
|
@@ -566,8 +568,8 @@ class Client extends client_abstract_js_1.ClientAbstract {
|
|
|
566
568
|
seqNo++;
|
|
567
569
|
this.state.seqNo++;
|
|
568
570
|
}
|
|
569
|
-
const message = new _6_message_js_1.Message((0,
|
|
570
|
-
await this.transport.send(await (0,
|
|
571
|
+
const message = new _6_message_js_1.Message((0, _0_message_js_1.getMessageId)(), seqNo, function_);
|
|
572
|
+
await this.transport.send(await (0, _0_message_js_1.encryptMessage)(message, this.auth.key, this.auth.id, this.state.salt, this.sessionId));
|
|
571
573
|
d("invoked %s", function_.constructor.name);
|
|
572
574
|
if (noWait) {
|
|
573
575
|
return;
|
|
@@ -826,7 +828,7 @@ class Client extends client_abstract_js_1.ClientAbstract {
|
|
|
826
828
|
return localState;
|
|
827
829
|
}
|
|
828
830
|
async recoverUpdateGap(source) {
|
|
829
|
-
|
|
831
|
+
dGap("recovering from update gap [%s]", source);
|
|
830
832
|
const release = await this.updateGapRecoveryMutex.acquire();
|
|
831
833
|
try {
|
|
832
834
|
let state = await this.getLocalState();
|
|
@@ -842,7 +844,7 @@ class Client extends client_abstract_js_1.ClientAbstract {
|
|
|
842
844
|
await this.applyUpdateNoGap(update);
|
|
843
845
|
}
|
|
844
846
|
if (difference instanceof types.UpdatesDifference) {
|
|
845
|
-
|
|
847
|
+
dGap("recovered from update gap");
|
|
846
848
|
break;
|
|
847
849
|
}
|
|
848
850
|
else if (difference instanceof types.UpdatesDifferenceSlice) {
|
|
@@ -855,11 +857,11 @@ class Client extends client_abstract_js_1.ClientAbstract {
|
|
|
855
857
|
else if (difference instanceof types.UpdatesDifferenceTooLong) {
|
|
856
858
|
// stored messages should be invalidated in case we store messages in the future
|
|
857
859
|
state.pts = difference.pts;
|
|
858
|
-
|
|
860
|
+
dGap("received differenceTooLong");
|
|
859
861
|
}
|
|
860
862
|
else if (difference instanceof types.UpdatesDifferenceEmpty) {
|
|
861
863
|
await this.setUpdateStateDate(difference.date);
|
|
862
|
-
|
|
864
|
+
dGap("there was no update gap");
|
|
863
865
|
break;
|
|
864
866
|
}
|
|
865
867
|
else {
|
|
@@ -872,7 +874,7 @@ class Client extends client_abstract_js_1.ClientAbstract {
|
|
|
872
874
|
}
|
|
873
875
|
}
|
|
874
876
|
async recoverChannelUpdateGap(channelId, source) {
|
|
875
|
-
|
|
877
|
+
dGapC("recovering channel update gap [%o, %s]", channelId, source);
|
|
876
878
|
const release = await this.updateGapRecoveryMutex.acquire();
|
|
877
879
|
try {
|
|
878
880
|
const pts_ = await this.storage.getChannelPts(channelId);
|
|
@@ -895,12 +897,12 @@ class Client extends client_abstract_js_1.ClientAbstract {
|
|
|
895
897
|
await this.applyUpdateNoGap(update, false);
|
|
896
898
|
}
|
|
897
899
|
await this.storage.setChannelPts(channelId, difference.pts);
|
|
898
|
-
|
|
900
|
+
dGapC("recovered from update gap [%o, %s]", channelId, source);
|
|
899
901
|
break;
|
|
900
902
|
}
|
|
901
903
|
else if (difference instanceof types.UpdatesChannelDifferenceTooLong) {
|
|
902
904
|
// invalidate messages
|
|
903
|
-
|
|
905
|
+
dGapC("received channelDifferenceTooLong");
|
|
904
906
|
await this.processChats(difference.chats);
|
|
905
907
|
await this.processUsers(difference.users);
|
|
906
908
|
for (const message of difference.messages) {
|
|
@@ -913,10 +915,10 @@ class Client extends client_abstract_js_1.ClientAbstract {
|
|
|
913
915
|
else {
|
|
914
916
|
(0, _0_control_js_1.UNREACHABLE)();
|
|
915
917
|
}
|
|
916
|
-
|
|
918
|
+
dGapC("processed channelDifferenceTooLong");
|
|
917
919
|
}
|
|
918
920
|
else if (difference instanceof types.UpdatesChannelDifferenceEmpty) {
|
|
919
|
-
|
|
921
|
+
dGapC("there was no update gap");
|
|
920
922
|
break;
|
|
921
923
|
}
|
|
922
924
|
}
|
|
@@ -9,15 +9,15 @@ const _0_control_js_1 = require("../utilities/0_control.js");
|
|
|
9
9
|
const _0_hash_js_1 = require("../utilities/0_hash.js");
|
|
10
10
|
const _1_auth_js_1 = require("../utilities/1_auth.js");
|
|
11
11
|
const _1_tl_object_js_1 = require("../tl/1_tl_object.js");
|
|
12
|
-
const _1_message_js_1 = require("../utilities/1_message.js");
|
|
13
12
|
const _2_types_js_1 = require("../tl/2_types.js");
|
|
14
13
|
const _3_functions_js_1 = require("../tl/3_functions.js");
|
|
15
14
|
const _3_tl_reader_js_1 = require("../tl/3_tl_reader.js");
|
|
16
15
|
const client_abstract_js_1 = require("./client_abstract.js");
|
|
17
|
-
const
|
|
16
|
+
const _0_message_js_1 = require("./utilities/0_message.js");
|
|
17
|
+
const d = (0, deps_js_1.debug)("ClientPlain/createAuthKey");
|
|
18
18
|
class ClientPlain extends client_abstract_js_1.ClientAbstract {
|
|
19
19
|
async invoke(function_) {
|
|
20
|
-
await this.transport.send((0,
|
|
20
|
+
await this.transport.send((0, _0_message_js_1.packUnencryptedMessage)(function_[_1_tl_object_js_1.serialize]()));
|
|
21
21
|
const buffer = await this.transport.receive();
|
|
22
22
|
if (buffer.length == 4) {
|
|
23
23
|
const int = (0, _0_bigint_js_1.bigIntFromBuffer)(buffer, true, true);
|
|
@@ -25,7 +25,7 @@ class ClientPlain extends client_abstract_js_1.ClientAbstract {
|
|
|
25
25
|
throw new Error("-404");
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
const { message } = (0,
|
|
28
|
+
const { message } = (0, _0_message_js_1.unpackUnencryptedMessage)(buffer);
|
|
29
29
|
const reader = new _3_tl_reader_js_1.TLReader(message);
|
|
30
30
|
return reader.readObject();
|
|
31
31
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Message } from "
|
|
2
|
-
import { MessageContainer } from "
|
|
1
|
+
import { Message } from "../../tl/6_message.js";
|
|
2
|
+
import { MessageContainer } from "../../tl/7_message_container.js";
|
|
3
3
|
export declare function getMessageId(): bigint;
|
|
4
4
|
export declare function packUnencryptedMessage(data: Uint8Array): Uint8Array;
|
|
5
5
|
export declare function unpackUnencryptedMessage(buffer: Uint8Array): {
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.decryptMessage = exports.encryptMessage = exports.unpackUnencryptedMessage = exports.packUnencryptedMessage = exports.getMessageId = void 0;
|
|
4
|
-
const deps_js_1 = require("
|
|
5
|
-
const _0_tl_raw_reader_js_1 = require("
|
|
6
|
-
const _0_tl_raw_writer_js_1 = require("
|
|
7
|
-
const _1_tl_object_js_1 = require("
|
|
8
|
-
const _3_tl_reader_js_1 = require("
|
|
9
|
-
const _5_rpc_result_js_1 = require("
|
|
10
|
-
const _6_message_js_1 = require("
|
|
11
|
-
const _7_message_container_js_1 = require("
|
|
12
|
-
const _0_buffer_js_1 = require("
|
|
13
|
-
const _0_hash_js_1 = require("
|
|
4
|
+
const deps_js_1 = require("../../deps.js");
|
|
5
|
+
const _0_tl_raw_reader_js_1 = require("../../tl/0_tl_raw_reader.js");
|
|
6
|
+
const _0_tl_raw_writer_js_1 = require("../../tl/0_tl_raw_writer.js");
|
|
7
|
+
const _1_tl_object_js_1 = require("../../tl/1_tl_object.js");
|
|
8
|
+
const _3_tl_reader_js_1 = require("../../tl/3_tl_reader.js");
|
|
9
|
+
const _5_rpc_result_js_1 = require("../../tl/5_rpc_result.js");
|
|
10
|
+
const _6_message_js_1 = require("../../tl/6_message.js");
|
|
11
|
+
const _7_message_container_js_1 = require("../../tl/7_message_container.js");
|
|
12
|
+
const _0_buffer_js_1 = require("../../utilities/0_buffer.js");
|
|
13
|
+
const _0_hash_js_1 = require("../../utilities/0_hash.js");
|
|
14
14
|
let lastMsgId = 0n;
|
|
15
15
|
function getMessageId() {
|
|
16
16
|
const now = new Date().getTime() / 1000 + 0;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as types from "
|
|
2
|
-
import { sha256 } from "
|
|
1
|
+
import * as types from "../../tl/2_types.js";
|
|
2
|
+
import { sha256 } from "../../utilities/0_hash.js";
|
|
3
3
|
export declare function isSafePrime(primeBytes: Uint8Array, g: number): boolean;
|
|
4
4
|
export declare const h: typeof sha256;
|
|
5
5
|
export declare const sh: (data: Uint8Array, salt: Uint8Array) => Promise<Uint8Array>;
|
|
@@ -24,11 +24,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.checkPassword = exports.pad = exports.isGoodModExpFirst = exports.ph2 = exports.pbkdf2 = exports.ph1 = exports.sh = exports.h = exports.isSafePrime = void 0;
|
|
27
|
-
const dntShim = __importStar(require("
|
|
28
|
-
const types = __importStar(require("
|
|
29
|
-
const _0_buffer_js_1 = require("
|
|
30
|
-
const _0_hash_js_1 = require("
|
|
31
|
-
const _0_bigint_js_1 = require("
|
|
27
|
+
const dntShim = __importStar(require("../../_dnt.shims.js"));
|
|
28
|
+
const types = __importStar(require("../../tl/2_types.js"));
|
|
29
|
+
const _0_buffer_js_1 = require("../../utilities/0_buffer.js");
|
|
30
|
+
const _0_hash_js_1 = require("../../utilities/0_hash.js");
|
|
31
|
+
const _0_bigint_js_1 = require("../../utilities/0_bigint.js");
|
|
32
32
|
function isSafePrime(primeBytes, g) {
|
|
33
33
|
// deno-fmt-ignore
|
|
34
34
|
const goodPrime = new Uint8Array([
|
|
@@ -26,6 +26,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.ConnectionWebSocket = void 0;
|
|
27
27
|
const dntShim = __importStar(require("../_dnt.shims.js"));
|
|
28
28
|
const deps_js_1 = require("../deps.js");
|
|
29
|
+
const d = (0, deps_js_1.debug)("ConnectionWebSocket");
|
|
29
30
|
class ConnectionWebSocket {
|
|
30
31
|
constructor(url) {
|
|
31
32
|
Object.defineProperty(this, "webSocket", {
|
|
@@ -70,7 +71,9 @@ class ConnectionWebSocket {
|
|
|
70
71
|
this.nextResolve = null;
|
|
71
72
|
}
|
|
72
73
|
};
|
|
73
|
-
this.webSocket.onerror =
|
|
74
|
+
this.webSocket.onerror = (err) => {
|
|
75
|
+
d("WebSocket error: %O", err);
|
|
76
|
+
};
|
|
74
77
|
}
|
|
75
78
|
get connected() {
|
|
76
79
|
return this.webSocket.readyState == dntShim.WebSocket.OPEN;
|
package/script/constants.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export declare const publicKeys: Map<bigint, [bigint, bigint]>;
|
|
|
4
4
|
export declare const VECTOR_CONSTRUCTOR = 481674261;
|
|
5
5
|
export declare const DEFAULT_INITIAL_DC: DC;
|
|
6
6
|
export declare const LAYER = 158;
|
|
7
|
-
export declare const DEFAULT_APP_VERSION = "MTKruto 0.0.
|
|
7
|
+
export declare const DEFAULT_APP_VERSION = "MTKruto 0.0.902";
|
|
8
8
|
export declare const DEFAULT_DEVICE_MODEL: string;
|
|
9
9
|
export declare const DEFAULT_LANG_CODE: string;
|
|
10
10
|
export declare const DEFAULT_LANG_PACK = "";
|
package/script/constants.js
CHANGED
|
@@ -88,7 +88,7 @@ exports.publicKeys = new Map([
|
|
|
88
88
|
exports.VECTOR_CONSTRUCTOR = 0x1CB5C415;
|
|
89
89
|
exports.DEFAULT_INITIAL_DC = "2-test";
|
|
90
90
|
exports.LAYER = 158;
|
|
91
|
-
exports.DEFAULT_APP_VERSION = "MTKruto 0.0.
|
|
91
|
+
exports.DEFAULT_APP_VERSION = "MTKruto 0.0.902";
|
|
92
92
|
// @ts-ignore: lib
|
|
93
93
|
exports.DEFAULT_DEVICE_MODEL = typeof dntShim.Deno === "undefined" ? typeof navigator === "undefined" ? typeof process === "undefined" ? "Unknown" : process.platform + "-" + process.arch : navigator.userAgent.split(" ")[0] : dntShim.Deno.build.os + "-" + dntShim.Deno.build.arch;
|
|
94
94
|
exports.DEFAULT_LANG_CODE = typeof navigator === "undefined" ? "en" : navigator.language.split("-")[0];
|
package/script/deps.js
CHANGED
|
@@ -31,7 +31,7 @@ Object.defineProperty(exports, "Mutex", { enumerable: true, get: function () { r
|
|
|
31
31
|
var mod_js_2 = require("./deps/deno.land/x/html_parser@v0.1.3/src/mod.js");
|
|
32
32
|
Object.defineProperty(exports, "Parser", { enumerable: true, get: function () { return mod_js_2.Parser; } });
|
|
33
33
|
const mod_js_3 = require("./deps/raw.githubusercontent.com/MTKruto/debug/master/mod.js");
|
|
34
|
-
const debug = (v) => (0, mod_js_3.debug)(`
|
|
34
|
+
const debug = (v) => (0, mod_js_3.debug)(`mtkruto/${v}`);
|
|
35
35
|
exports.debug = debug;
|
|
36
36
|
var mod_js_4 = require("./deps/deno.land/x/q@v0.0.1/mod.js");
|
|
37
37
|
Object.defineProperty(exports, "queue", { enumerable: true, get: function () { return mod_js_4.queue; } });
|
package/script/mod.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { checkPassword } from "./utilities/1_password.js";
|
|
2
1
|
import { getRandomId } from "./utilities/0_bigint.js";
|
|
2
|
+
import { checkPassword } from "./client/utilities/0_password.js";
|
|
3
3
|
export declare const utils: {
|
|
4
4
|
checkPassword: typeof checkPassword;
|
|
5
5
|
getRandomId: typeof getRandomId;
|
package/script/mod.js
CHANGED
|
@@ -27,9 +27,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.LAYER = exports.DEFAULT_SYSTEM_VERSION = exports.DEFAULT_SYSTEM_LANG_CODE = exports.DEFAULT_LANG_PACK = exports.DEFAULT_LANG_CODE = exports.DEFAULT_INITIAL_DC = exports.DEFAULT_DEVICE_MODEL = exports.DEFAULT_APP_VERSION = exports.functions = exports.types = exports.as = exports.utils = void 0;
|
|
30
|
-
const _1_password_js_1 = require("./utilities/1_password.js");
|
|
31
30
|
const _0_bigint_js_1 = require("./utilities/0_bigint.js");
|
|
32
|
-
|
|
31
|
+
const _0_password_js_1 = require("./client/utilities/0_password.js");
|
|
32
|
+
exports.utils = { checkPassword: _0_password_js_1.checkPassword, getRandomId: _0_bigint_js_1.getRandomId };
|
|
33
33
|
var _1_tl_object_js_1 = require("./tl/1_tl_object.js");
|
|
34
34
|
Object.defineProperty(exports, "as", { enumerable: true, get: function () { return _1_tl_object_js_1.as; } });
|
|
35
35
|
exports.types = __importStar(require("./tl/2_types.js"));
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TransportAbridged = void 0;
|
|
4
4
|
const _0_buffer_js_1 = require("../utilities/0_buffer.js");
|
|
5
|
-
const
|
|
5
|
+
const _0_obfuscation_js_1 = require("./utilities/0_obfuscation.js");
|
|
6
6
|
const transport_js_1 = require("./transport.js");
|
|
7
7
|
class TransportAbridged extends transport_js_1.Transport {
|
|
8
8
|
constructor(connection, obfuscated = false) {
|
|
@@ -23,7 +23,7 @@ class TransportAbridged extends transport_js_1.Transport {
|
|
|
23
23
|
async initialize() {
|
|
24
24
|
if (!this.initialized) {
|
|
25
25
|
if (this.obfuscated) {
|
|
26
|
-
this.obfuscationParameters = await (0,
|
|
26
|
+
this.obfuscationParameters = await (0, _0_obfuscation_js_1.getObfuscationParameters)(0xEFEFEFEF, this.connection);
|
|
27
27
|
}
|
|
28
28
|
else {
|
|
29
29
|
await this.connection.write(new Uint8Array([0xEF]));
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TransportIntermediate = void 0;
|
|
4
4
|
const _0_buffer_js_1 = require("../utilities/0_buffer.js");
|
|
5
|
-
const
|
|
5
|
+
const _0_obfuscation_js_1 = require("./utilities/0_obfuscation.js");
|
|
6
6
|
const transport_js_1 = require("./transport.js");
|
|
7
7
|
class TransportIntermediate extends transport_js_1.Transport {
|
|
8
8
|
constructor(connection, obfuscated = false) {
|
|
@@ -23,7 +23,7 @@ class TransportIntermediate extends transport_js_1.Transport {
|
|
|
23
23
|
async initialize() {
|
|
24
24
|
if (!this.initialized) {
|
|
25
25
|
if (this.obfuscated) {
|
|
26
|
-
this.obfuscationParameters = await (0,
|
|
26
|
+
this.obfuscationParameters = await (0, _0_obfuscation_js_1.getObfuscationParameters)(0xEEEEEEEE, this.connection);
|
|
27
27
|
}
|
|
28
28
|
else {
|
|
29
29
|
await this.connection.write(new Uint8Array([0xEE, 0xEE, 0xEE, 0xEE]));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { CTR } from "../../utilities/0_crypto.js";
|
|
2
|
+
import { Connection } from "../../connection/connection.js";
|
|
3
3
|
export declare function getObfuscationParameters(protocol: number, connection: Connection): Promise<{
|
|
4
4
|
encryptionCTR: CTR;
|
|
5
5
|
decryptionCTR: CTR;
|
|
@@ -24,9 +24,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.getObfuscationParameters = void 0;
|
|
27
|
-
const dntShim = __importStar(require("
|
|
28
|
-
const _0_buffer_js_1 = require("
|
|
29
|
-
const _0_crypto_js_1 = require("
|
|
27
|
+
const dntShim = __importStar(require("../../_dnt.shims.js"));
|
|
28
|
+
const _0_buffer_js_1 = require("../../utilities/0_buffer.js");
|
|
29
|
+
const _0_crypto_js_1 = require("../../utilities/0_crypto.js");
|
|
30
30
|
async function getObfuscationParameters(protocol, connection) {
|
|
31
31
|
const dc = 0xFCFF;
|
|
32
32
|
let init;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { MessageEntity } from "../
|
|
1
|
+
import { MessageEntity } from "../0_message_entity.js";
|
|
2
2
|
export declare function parseHtml(html: string): readonly [string, MessageEntity[]];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseHtml = void 0;
|
|
4
|
-
const deps_js_1 = require("
|
|
5
|
-
const _0_message_entity_js_1 = require("../
|
|
4
|
+
const deps_js_1 = require("../../deps.js");
|
|
5
|
+
const _0_message_entity_js_1 = require("../0_message_entity.js");
|
|
6
6
|
function parseHtml(html) {
|
|
7
7
|
let text = "";
|
|
8
8
|
const entities = new Array();
|
|
File without changes
|
|
File without changes
|