@mtkruto/node 0.0.965 → 0.0.966
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/0_message.d.ts +2 -2
- package/esm/client/0_message.js +3 -4
- package/esm/client/2_client_plain.d.ts +1 -0
- package/esm/client/2_client_plain.js +12 -2
- package/esm/client/3_client.d.ts +1 -0
- package/esm/client/3_client.js +8 -1
- package/esm/constants.d.ts +1 -1
- package/esm/constants.js +1 -1
- package/package.json +1 -1
- package/script/client/0_message.d.ts +2 -2
- package/script/client/0_message.js +3 -4
- package/script/client/2_client_plain.d.ts +1 -0
- package/script/client/2_client_plain.js +11 -1
- package/script/client/3_client.d.ts +1 -0
- package/script/client/3_client.js +8 -1
- package/script/constants.d.ts +1 -1
- package/script/constants.js +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Message } from "../tl/6_message.js";
|
|
2
2
|
import { MessageContainer } from "../tl/7_message_container.js";
|
|
3
|
-
export declare function getMessageId(): bigint;
|
|
4
|
-
export declare function packUnencryptedMessage(data: Uint8Array): Uint8Array;
|
|
3
|
+
export declare function getMessageId(lastMsgId: bigint): bigint;
|
|
4
|
+
export declare function packUnencryptedMessage(data: Uint8Array, messageId: bigint): Uint8Array;
|
|
5
5
|
export declare function unpackUnencryptedMessage(buffer: Uint8Array): {
|
|
6
6
|
messageId: bigint;
|
|
7
7
|
message: Uint8Array;
|
package/esm/client/0_message.js
CHANGED
|
@@ -8,8 +8,7 @@ import { Message } from "../tl/6_message.js";
|
|
|
8
8
|
import { MessageContainer } from "../tl/7_message_container.js";
|
|
9
9
|
import { bufferFromBigInt, concat } from "../utilities/0_buffer.js";
|
|
10
10
|
import { sha256 } from "../utilities/0_hash.js";
|
|
11
|
-
|
|
12
|
-
export function getMessageId() {
|
|
11
|
+
export function getMessageId(lastMsgId) {
|
|
13
12
|
const now = new Date().getTime() / 1000 + 0;
|
|
14
13
|
const nanoseconds = Math.floor((now - Math.floor(now)) * 1e9);
|
|
15
14
|
let newMsgId = (BigInt(Math.floor(now)) <<
|
|
@@ -21,8 +20,8 @@ export function getMessageId() {
|
|
|
21
20
|
lastMsgId = newMsgId;
|
|
22
21
|
return newMsgId;
|
|
23
22
|
}
|
|
24
|
-
export function packUnencryptedMessage(data) {
|
|
25
|
-
const message = concat(bufferFromBigInt(0x00, 8), bufferFromBigInt(getMessageId(), 8), bufferFromBigInt(data.length, 4), data);
|
|
23
|
+
export function packUnencryptedMessage(data, messageId) {
|
|
24
|
+
const message = concat(bufferFromBigInt(0x00, 8), bufferFromBigInt(getMessageId(messageId), 8), bufferFromBigInt(data.length, 4), data);
|
|
26
25
|
return message;
|
|
27
26
|
}
|
|
28
27
|
export function unpackUnencryptedMessage(buffer) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Function } from "../tl/3_functions.js";
|
|
2
2
|
import { ClientAbstract } from "./1_client_abstract.js";
|
|
3
3
|
export declare class ClientPlain extends ClientAbstract {
|
|
4
|
+
private lastMsgId;
|
|
4
5
|
invoke<T extends Function<unknown>>(function_: T): Promise<T["__R"]>;
|
|
5
6
|
createAuthKey(): Promise<{
|
|
6
7
|
authKey: Uint8Array;
|
|
@@ -10,11 +10,21 @@ import { ClientDHInnerData, DHGenOK, PQInnerDataDC, ResPQ, ServerDHInnerData, Se
|
|
|
10
10
|
import { ReqDHParams, ReqPQMulti, SetClientDHParams } from "../tl/3_functions.js";
|
|
11
11
|
import { TLReader } from "../tl/3_tl_reader.js";
|
|
12
12
|
import { ClientAbstract } from "./1_client_abstract.js";
|
|
13
|
-
import { packUnencryptedMessage, unpackUnencryptedMessage } from "./0_message.js";
|
|
13
|
+
import { getMessageId, packUnencryptedMessage, unpackUnencryptedMessage } from "./0_message.js";
|
|
14
14
|
const d = debug("ClientPlain/createAuthKey");
|
|
15
15
|
export class ClientPlain extends ClientAbstract {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
18
|
+
Object.defineProperty(this, "lastMsgId", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
configurable: true,
|
|
21
|
+
writable: true,
|
|
22
|
+
value: 0n
|
|
23
|
+
});
|
|
24
|
+
}
|
|
16
25
|
async invoke(function_) {
|
|
17
|
-
|
|
26
|
+
const msgId = this.lastMsgId = getMessageId(this.lastMsgId);
|
|
27
|
+
await this.transport.send(packUnencryptedMessage(function_[serialize](), msgId));
|
|
18
28
|
const buffer = await this.transport.receive();
|
|
19
29
|
if (buffer.length == 4) {
|
|
20
30
|
const int = bigIntFromBuffer(buffer, true, true);
|
package/esm/client/3_client.d.ts
CHANGED
|
@@ -131,6 +131,7 @@ export declare class Client extends ClientAbstract {
|
|
|
131
131
|
authorize(params: string | types.AuthExportedAuthorization | AuthorizeUserParams): Promise<void>;
|
|
132
132
|
private receiveLoop;
|
|
133
133
|
private pingLoop;
|
|
134
|
+
private lastMsgId;
|
|
134
135
|
/**
|
|
135
136
|
* Invokes a function waiting and returning its reply if the second parameter is not `true`. Requires the client
|
|
136
137
|
* to be connected.
|
package/esm/client/3_client.js
CHANGED
|
@@ -159,6 +159,12 @@ export class Client extends ClientAbstract {
|
|
|
159
159
|
writable: true,
|
|
160
160
|
value: false
|
|
161
161
|
});
|
|
162
|
+
Object.defineProperty(this, "lastMsgId", {
|
|
163
|
+
enumerable: true,
|
|
164
|
+
configurable: true,
|
|
165
|
+
writable: true,
|
|
166
|
+
value: 0n
|
|
167
|
+
});
|
|
162
168
|
Object.defineProperty(this, "updateApplicationMutex", {
|
|
163
169
|
enumerable: true,
|
|
164
170
|
configurable: true,
|
|
@@ -558,7 +564,8 @@ export class Client extends ClientAbstract {
|
|
|
558
564
|
seqNo++;
|
|
559
565
|
this.state.seqNo++;
|
|
560
566
|
}
|
|
561
|
-
const
|
|
567
|
+
const messageId = this.lastMsgId = getMessageId(this.lastMsgId);
|
|
568
|
+
const message = new Message_(messageId, seqNo, function_);
|
|
562
569
|
await this.transport.send(await encryptMessage(message, this.auth.key, this.auth.id, this.state.salt, this.sessionId));
|
|
563
570
|
const d_ = () => d("invoked %s", function_.constructor.name);
|
|
564
571
|
if (noWait) {
|
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.966";
|
|
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.966";
|
|
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Message } from "../tl/6_message.js";
|
|
2
2
|
import { MessageContainer } from "../tl/7_message_container.js";
|
|
3
|
-
export declare function getMessageId(): bigint;
|
|
4
|
-
export declare function packUnencryptedMessage(data: Uint8Array): Uint8Array;
|
|
3
|
+
export declare function getMessageId(lastMsgId: bigint): bigint;
|
|
4
|
+
export declare function packUnencryptedMessage(data: Uint8Array, messageId: bigint): Uint8Array;
|
|
5
5
|
export declare function unpackUnencryptedMessage(buffer: Uint8Array): {
|
|
6
6
|
messageId: bigint;
|
|
7
7
|
message: Uint8Array;
|
|
@@ -11,8 +11,7 @@ const _6_message_js_1 = require("../tl/6_message.js");
|
|
|
11
11
|
const _7_message_container_js_1 = require("../tl/7_message_container.js");
|
|
12
12
|
const _0_buffer_js_1 = require("../utilities/0_buffer.js");
|
|
13
13
|
const _0_hash_js_1 = require("../utilities/0_hash.js");
|
|
14
|
-
|
|
15
|
-
function getMessageId() {
|
|
14
|
+
function getMessageId(lastMsgId) {
|
|
16
15
|
const now = new Date().getTime() / 1000 + 0;
|
|
17
16
|
const nanoseconds = Math.floor((now - Math.floor(now)) * 1e9);
|
|
18
17
|
let newMsgId = (BigInt(Math.floor(now)) <<
|
|
@@ -25,8 +24,8 @@ function getMessageId() {
|
|
|
25
24
|
return newMsgId;
|
|
26
25
|
}
|
|
27
26
|
exports.getMessageId = getMessageId;
|
|
28
|
-
function packUnencryptedMessage(data) {
|
|
29
|
-
const message = (0, _0_buffer_js_1.concat)((0, _0_buffer_js_1.bufferFromBigInt)(0x00, 8), (0, _0_buffer_js_1.bufferFromBigInt)(getMessageId(), 8), (0, _0_buffer_js_1.bufferFromBigInt)(data.length, 4), data);
|
|
27
|
+
function packUnencryptedMessage(data, messageId) {
|
|
28
|
+
const message = (0, _0_buffer_js_1.concat)((0, _0_buffer_js_1.bufferFromBigInt)(0x00, 8), (0, _0_buffer_js_1.bufferFromBigInt)(getMessageId(messageId), 8), (0, _0_buffer_js_1.bufferFromBigInt)(data.length, 4), data);
|
|
30
29
|
return message;
|
|
31
30
|
}
|
|
32
31
|
exports.packUnencryptedMessage = packUnencryptedMessage;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Function } from "../tl/3_functions.js";
|
|
2
2
|
import { ClientAbstract } from "./1_client_abstract.js";
|
|
3
3
|
export declare class ClientPlain extends ClientAbstract {
|
|
4
|
+
private lastMsgId;
|
|
4
5
|
invoke<T extends Function<unknown>>(function_: T): Promise<T["__R"]>;
|
|
5
6
|
createAuthKey(): Promise<{
|
|
6
7
|
authKey: Uint8Array;
|
|
@@ -16,8 +16,18 @@ const _1_client_abstract_js_1 = require("./1_client_abstract.js");
|
|
|
16
16
|
const _0_message_js_1 = require("./0_message.js");
|
|
17
17
|
const d = (0, deps_js_1.debug)("ClientPlain/createAuthKey");
|
|
18
18
|
class ClientPlain extends _1_client_abstract_js_1.ClientAbstract {
|
|
19
|
+
constructor() {
|
|
20
|
+
super(...arguments);
|
|
21
|
+
Object.defineProperty(this, "lastMsgId", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
configurable: true,
|
|
24
|
+
writable: true,
|
|
25
|
+
value: 0n
|
|
26
|
+
});
|
|
27
|
+
}
|
|
19
28
|
async invoke(function_) {
|
|
20
|
-
|
|
29
|
+
const msgId = this.lastMsgId = (0, _0_message_js_1.getMessageId)(this.lastMsgId);
|
|
30
|
+
await this.transport.send((0, _0_message_js_1.packUnencryptedMessage)(function_[_1_tl_object_js_1.serialize](), msgId));
|
|
21
31
|
const buffer = await this.transport.receive();
|
|
22
32
|
if (buffer.length == 4) {
|
|
23
33
|
const int = (0, _0_bigint_js_1.bigIntFromBuffer)(buffer, true, true);
|
|
@@ -131,6 +131,7 @@ export declare class Client extends ClientAbstract {
|
|
|
131
131
|
authorize(params: string | types.AuthExportedAuthorization | AuthorizeUserParams): Promise<void>;
|
|
132
132
|
private receiveLoop;
|
|
133
133
|
private pingLoop;
|
|
134
|
+
private lastMsgId;
|
|
134
135
|
/**
|
|
135
136
|
* Invokes a function waiting and returning its reply if the second parameter is not `true`. Requires the client
|
|
136
137
|
* to be connected.
|
|
@@ -185,6 +185,12 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
185
185
|
writable: true,
|
|
186
186
|
value: false
|
|
187
187
|
});
|
|
188
|
+
Object.defineProperty(this, "lastMsgId", {
|
|
189
|
+
enumerable: true,
|
|
190
|
+
configurable: true,
|
|
191
|
+
writable: true,
|
|
192
|
+
value: 0n
|
|
193
|
+
});
|
|
188
194
|
Object.defineProperty(this, "updateApplicationMutex", {
|
|
189
195
|
enumerable: true,
|
|
190
196
|
configurable: true,
|
|
@@ -584,7 +590,8 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
584
590
|
seqNo++;
|
|
585
591
|
this.state.seqNo++;
|
|
586
592
|
}
|
|
587
|
-
const
|
|
593
|
+
const messageId = this.lastMsgId = (0, _0_message_js_1.getMessageId)(this.lastMsgId);
|
|
594
|
+
const message = new _6_message_js_1.Message(messageId, seqNo, function_);
|
|
588
595
|
await this.transport.send(await (0, _0_message_js_1.encryptMessage)(message, this.auth.key, this.auth.id, this.state.salt, this.sessionId));
|
|
589
596
|
const d_ = () => d("invoked %s", function_.constructor.name);
|
|
590
597
|
if (noWait) {
|
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.966";
|
|
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.966";
|
|
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];
|