@mtkruto/node 0.0.966 → 0.0.968
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.js +1 -2
- package/esm/client/1_client_abstract.js +2 -2
- package/esm/client/3_client.d.ts +3 -3
- package/esm/client/3_client.js +3 -6
- package/esm/connection/0_connection.d.ts +11 -2
- package/esm/connection/0_connection.js +23 -1
- package/esm/connection/1_connection_http.d.ts +16 -0
- package/esm/connection/1_connection_http.js +91 -0
- package/esm/connection/1_connection_web_socket.d.ts +2 -2
- package/esm/connection/1_connection_web_socket.js +4 -4
- package/esm/constants.d.ts +2 -2
- package/esm/constants.js +2 -2
- package/esm/tl/2_types.d.ts +484 -87
- package/esm/tl/2_types.js +1647 -308
- package/esm/tl/3_functions.d.ts +286 -48
- package/esm/tl/3_functions.js +919 -165
- package/esm/transport/1_transport_piped.d.ts +10 -0
- package/esm/transport/1_transport_piped.js +23 -0
- package/esm/transport/2_transport_provider.d.ts +8 -2
- package/esm/transport/2_transport_provider.js +40 -2
- package/package.json +1 -1
- package/script/client/0_message.js +1 -2
- package/script/client/1_client_abstract.js +1 -1
- package/script/client/3_client.d.ts +3 -3
- package/script/client/3_client.js +3 -6
- package/script/connection/0_connection.d.ts +11 -2
- package/script/connection/0_connection.js +26 -3
- package/script/connection/1_connection_http.d.ts +16 -0
- package/script/connection/1_connection_http.js +95 -0
- package/script/connection/1_connection_web_socket.d.ts +2 -2
- package/script/connection/1_connection_web_socket.js +4 -4
- package/script/constants.d.ts +2 -2
- package/script/constants.js +2 -2
- package/script/tl/2_types.d.ts +484 -87
- package/script/tl/2_types.js +1718 -339
- package/script/tl/3_functions.d.ts +286 -48
- package/script/tl/3_functions.js +950 -175
- package/script/transport/1_transport_piped.d.ts +10 -0
- package/script/transport/1_transport_piped.js +27 -0
- package/script/transport/2_transport_provider.d.ts +8 -2
- package/script/transport/2_transport_provider.js +43 -4
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ConnectionFramed } from "../connection/0_connection.js";
|
|
2
|
+
import { Transport } from "./0_transport.js";
|
|
3
|
+
export declare class TransportPiped extends Transport implements Transport {
|
|
4
|
+
private readonly connection;
|
|
5
|
+
constructor(connection: ConnectionFramed);
|
|
6
|
+
initialize(): Promise<void>;
|
|
7
|
+
receive(): import("../utilities/0_types.js").MaybePromise<Uint8Array>;
|
|
8
|
+
send(buffer: Uint8Array): import("../utilities/0_types.js").MaybePromise<void>;
|
|
9
|
+
deinitialize(): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Transport } from "./0_transport.js";
|
|
2
|
+
export class TransportPiped extends Transport {
|
|
3
|
+
constructor(connection) {
|
|
4
|
+
super();
|
|
5
|
+
Object.defineProperty(this, "connection", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
configurable: true,
|
|
8
|
+
writable: true,
|
|
9
|
+
value: connection
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
async initialize() {
|
|
13
|
+
}
|
|
14
|
+
receive() {
|
|
15
|
+
return this.connection.read();
|
|
16
|
+
}
|
|
17
|
+
send(buffer) {
|
|
18
|
+
return this.connection.write(buffer);
|
|
19
|
+
}
|
|
20
|
+
deinitialize() {
|
|
21
|
+
this.initialized = false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -16,5 +16,11 @@ export type TransportProvider = {
|
|
|
16
16
|
export interface TransportProviderCreatorParams {
|
|
17
17
|
initialDc: DC;
|
|
18
18
|
}
|
|
19
|
-
export type TransportProviderCreator = (params: TransportProviderCreatorParams) => TransportProvider;
|
|
20
|
-
export declare const
|
|
19
|
+
export type TransportProviderCreator<E = Record<never, never>> = (params: TransportProviderCreatorParams & E) => TransportProvider;
|
|
20
|
+
export declare const webSocketTransportProvider: TransportProviderCreator<{
|
|
21
|
+
wss?: boolean;
|
|
22
|
+
}>;
|
|
23
|
+
export declare const httpTransportProvider: TransportProviderCreator<{
|
|
24
|
+
secure?: boolean;
|
|
25
|
+
v6?: boolean;
|
|
26
|
+
}>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { ConnectionHTTP } from "../connection/1_connection_http.js";
|
|
1
2
|
import { ConnectionWebSocket } from "../connection/1_connection_web_socket.js";
|
|
3
|
+
import { TransportPiped } from "./1_transport_piped.js";
|
|
2
4
|
import { TransportIntermediate } from "./1_transport_intermediate.js";
|
|
3
5
|
const dcToNameMap = {
|
|
4
6
|
"1": "pluto",
|
|
@@ -10,7 +12,10 @@ const dcToNameMap = {
|
|
|
10
12
|
"4": "vesta",
|
|
11
13
|
"5": "flora",
|
|
12
14
|
};
|
|
13
|
-
|
|
15
|
+
function getDcId(dc, cdn) {
|
|
16
|
+
return Number(dc[0]) + (dc.endsWith("-test") ? 10000 : 0) * (cdn ? -1 : 1);
|
|
17
|
+
}
|
|
18
|
+
export const webSocketTransportProvider = ({ initialDc, wss }) => {
|
|
14
19
|
return {
|
|
15
20
|
initialDc,
|
|
16
21
|
createTransport: ({ dc, cdn }) => {
|
|
@@ -19,7 +24,40 @@ export const defaultTransportProvider = ({ initialDc, wss }) => {
|
|
|
19
24
|
const url = `${wss ? "wss" : "ws"}://${dcToNameMap[dc]}${cdn ? "-1" : ""}.web.telegram.org/${dc.endsWith("-test") ? "apiws_test" : "apiws"}`;
|
|
20
25
|
const connection = new ConnectionWebSocket(url);
|
|
21
26
|
const transport = new TransportIntermediate(connection, true);
|
|
22
|
-
const dcId =
|
|
27
|
+
const dcId = getDcId(dc, cdn);
|
|
28
|
+
return { connection, transport, dcId };
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
const dcToIPv4Map = {
|
|
33
|
+
"1": "149.154.175.50",
|
|
34
|
+
"1-test": "149.154.175.10",
|
|
35
|
+
"2": "149.154.167.51",
|
|
36
|
+
"2-test": "149.154.167.40",
|
|
37
|
+
"3": "149.154.175.100",
|
|
38
|
+
"3-test": "149.154.175.117",
|
|
39
|
+
"4": "149.154.167.91",
|
|
40
|
+
"5": "149.154.171.5",
|
|
41
|
+
};
|
|
42
|
+
const dcToIPv6Map = {
|
|
43
|
+
"1": "[2001:b28:f23d:f001::a]",
|
|
44
|
+
"1-test": "[2001:b28:f23d:f001::e]",
|
|
45
|
+
"2": "[2001:67c:4e8:f002::a]",
|
|
46
|
+
"2-test": "[2001:67c:4e8:f002::e]",
|
|
47
|
+
"3": "[2001:b28:f23d:f003::a]",
|
|
48
|
+
"3-test": "[2001:b28:f23d:f003::e]",
|
|
49
|
+
"4": "[2001:67c:4e8:f004::a]",
|
|
50
|
+
"5": "[2001:b28:f23f:f005::a]",
|
|
51
|
+
};
|
|
52
|
+
export const httpTransportProvider = ({ initialDc, secure, v6 }) => {
|
|
53
|
+
return {
|
|
54
|
+
initialDc,
|
|
55
|
+
createTransport({ dc, cdn }) {
|
|
56
|
+
dc ??= initialDc;
|
|
57
|
+
const url = secure ? `https://${dcToNameMap[dc]}${cdn ? "-1" : ""}.web.telegram.org/${dc.endsWith("-test") ? "apiw1_test" : "apiw1"}` : `http://${(v6 ? dcToIPv6Map : dcToIPv4Map)[dc]}/${dc.endsWith("-test") ? "api_test" : "api"}`;
|
|
58
|
+
const connection = new ConnectionHTTP(url);
|
|
59
|
+
const transport = new TransportPiped(connection);
|
|
60
|
+
const dcId = getDcId(dc, cdn);
|
|
23
61
|
return { connection, transport, dcId };
|
|
24
62
|
},
|
|
25
63
|
};
|
package/package.json
CHANGED
|
@@ -20,12 +20,11 @@ function getMessageId(lastMsgId) {
|
|
|
20
20
|
if (lastMsgId >= (newMsgId)) {
|
|
21
21
|
newMsgId = lastMsgId + 4n;
|
|
22
22
|
}
|
|
23
|
-
lastMsgId = newMsgId;
|
|
24
23
|
return newMsgId;
|
|
25
24
|
}
|
|
26
25
|
exports.getMessageId = getMessageId;
|
|
27
26
|
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)(
|
|
27
|
+
const message = (0, _0_buffer_js_1.concat)((0, _0_buffer_js_1.bufferFromBigInt)(0x00, 8), (0, _0_buffer_js_1.bufferFromBigInt)(messageId, 8), (0, _0_buffer_js_1.bufferFromBigInt)(data.length, 4), data);
|
|
29
28
|
return message;
|
|
30
29
|
}
|
|
31
30
|
exports.packUnencryptedMessage = packUnencryptedMessage;
|
|
@@ -8,7 +8,7 @@ class ClientAbstract {
|
|
|
8
8
|
get initialDc() {
|
|
9
9
|
return this._initialDc;
|
|
10
10
|
}
|
|
11
|
-
constructor(transportProvider = (0, _2_transport_provider_js_1.
|
|
11
|
+
constructor(transportProvider = (0, _2_transport_provider_js_1.webSocketTransportProvider)({ initialDc: constants_js_1.DEFAULT_INITIAL_DC }), cdn = false) {
|
|
12
12
|
Object.defineProperty(this, "transportProvider", {
|
|
13
13
|
enumerable: true,
|
|
14
14
|
configurable: true,
|
|
@@ -69,8 +69,8 @@ export interface ForwardMessagesParams {
|
|
|
69
69
|
}
|
|
70
70
|
export declare class Client extends ClientAbstract {
|
|
71
71
|
readonly storage: Storage;
|
|
72
|
-
readonly apiId: number;
|
|
73
|
-
readonly apiHash: string;
|
|
72
|
+
readonly apiId: number | null;
|
|
73
|
+
readonly apiHash: string | null;
|
|
74
74
|
private auth;
|
|
75
75
|
private sessionId;
|
|
76
76
|
private state;
|
|
@@ -93,7 +93,7 @@ export declare class Client extends ClientAbstract {
|
|
|
93
93
|
* @param apiHash App's API hash from [my.telegram.org/apps](https://my.telegram.org/apps). Default to empty string (unset).
|
|
94
94
|
* @param params Other parameters.
|
|
95
95
|
*/
|
|
96
|
-
constructor(storage?: Storage, apiId?: number, apiHash?: string, params?: ClientParams, cdn?: boolean);
|
|
96
|
+
constructor(storage?: Storage, apiId?: number | null, apiHash?: string | null, params?: ClientParams, cdn?: boolean);
|
|
97
97
|
private storageInited;
|
|
98
98
|
/**
|
|
99
99
|
* Sets the DC and resets the auth key stored in the session provider
|
|
@@ -398,7 +398,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
398
398
|
apiId: this.apiId,
|
|
399
399
|
apiHash: this.apiHash,
|
|
400
400
|
phoneNumber,
|
|
401
|
-
settings: new types.CodeSettings(),
|
|
401
|
+
settings: new types.CodeSettings({}),
|
|
402
402
|
}));
|
|
403
403
|
dAuth("verification code sent");
|
|
404
404
|
if (sentCode instanceof types.AuthSentCode) {
|
|
@@ -593,9 +593,8 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
593
593
|
const messageId = this.lastMsgId = (0, _0_message_js_1.getMessageId)(this.lastMsgId);
|
|
594
594
|
const message = new _6_message_js_1.Message(messageId, seqNo, function_);
|
|
595
595
|
await this.transport.send(await (0, _0_message_js_1.encryptMessage)(message, this.auth.key, this.auth.id, this.state.salt, this.sessionId));
|
|
596
|
-
|
|
596
|
+
d("invoked %s", function_.constructor.name);
|
|
597
597
|
if (noWait) {
|
|
598
|
-
d_();
|
|
599
598
|
return;
|
|
600
599
|
}
|
|
601
600
|
const result = await new Promise((resolve, reject) => {
|
|
@@ -605,7 +604,6 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
605
604
|
return await this.invoke(function_);
|
|
606
605
|
}
|
|
607
606
|
else {
|
|
608
|
-
d_();
|
|
609
607
|
return result;
|
|
610
608
|
}
|
|
611
609
|
}
|
|
@@ -1173,8 +1171,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
1173
1171
|
noWebpage,
|
|
1174
1172
|
silent,
|
|
1175
1173
|
noforwards,
|
|
1176
|
-
replyToMsgId,
|
|
1177
|
-
topMsgId,
|
|
1174
|
+
replyTo: replyToMsgId !== undefined ? new types.InputReplyToMessage({ replyToMsgId, topMsgId }) : undefined,
|
|
1178
1175
|
sendAs,
|
|
1179
1176
|
entities,
|
|
1180
1177
|
replyMarkup,
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { MaybePromise } from "../utilities/0_types.js";
|
|
2
|
-
|
|
2
|
+
declare abstract class Foundation {
|
|
3
3
|
abstract get connected(): boolean;
|
|
4
4
|
abstract open(): MaybePromise<void>;
|
|
5
|
-
abstract read(p: Uint8Array): MaybePromise<void>;
|
|
6
5
|
abstract write(p: Uint8Array): MaybePromise<void>;
|
|
7
6
|
abstract close(): MaybePromise<void>;
|
|
8
7
|
}
|
|
8
|
+
export declare abstract class ConnectionUnframed extends Foundation {
|
|
9
|
+
readonly type: "framed";
|
|
10
|
+
abstract read(p: Uint8Array): MaybePromise<void>;
|
|
11
|
+
}
|
|
12
|
+
export declare abstract class ConnectionFramed extends Foundation {
|
|
13
|
+
readonly type: "framed";
|
|
14
|
+
abstract read(): MaybePromise<Uint8Array>;
|
|
15
|
+
}
|
|
16
|
+
export type Connection = ConnectionUnframed | ConnectionFramed;
|
|
17
|
+
export {};
|
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
class
|
|
3
|
+
exports.ConnectionFramed = exports.ConnectionUnframed = void 0;
|
|
4
|
+
class Foundation {
|
|
5
5
|
}
|
|
6
|
-
|
|
6
|
+
class ConnectionUnframed extends Foundation {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
Object.defineProperty(this, "type", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
configurable: true,
|
|
12
|
+
writable: true,
|
|
13
|
+
value: "framed"
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.ConnectionUnframed = ConnectionUnframed;
|
|
18
|
+
class ConnectionFramed extends Foundation {
|
|
19
|
+
constructor() {
|
|
20
|
+
super(...arguments);
|
|
21
|
+
Object.defineProperty(this, "type", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
configurable: true,
|
|
24
|
+
writable: true,
|
|
25
|
+
value: "framed"
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.ConnectionFramed = ConnectionFramed;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ConnectionFramed } from "./0_connection.js";
|
|
2
|
+
export declare class ConnectionHTTP extends ConnectionFramed implements ConnectionFramed {
|
|
3
|
+
private readonly url;
|
|
4
|
+
private rMutex;
|
|
5
|
+
private wMutex;
|
|
6
|
+
private resolveCanRead;
|
|
7
|
+
private canRead;
|
|
8
|
+
private buffers;
|
|
9
|
+
constructor(url: string | URL);
|
|
10
|
+
private resetCanRead;
|
|
11
|
+
get connected(): boolean;
|
|
12
|
+
open(): Promise<void>;
|
|
13
|
+
read(): Promise<Uint8Array>;
|
|
14
|
+
write(buffer: Uint8Array): Promise<void>;
|
|
15
|
+
close(): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConnectionHTTP = void 0;
|
|
4
|
+
const deps_js_1 = require("../deps.js");
|
|
5
|
+
const _0_control_js_1 = require("../utilities/0_control.js");
|
|
6
|
+
const _0_connection_js_1 = require("./0_connection.js");
|
|
7
|
+
class ConnectionHTTP extends _0_connection_js_1.ConnectionFramed {
|
|
8
|
+
constructor(url) {
|
|
9
|
+
super();
|
|
10
|
+
Object.defineProperty(this, "url", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
writable: true,
|
|
14
|
+
value: url
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(this, "rMutex", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
configurable: true,
|
|
19
|
+
writable: true,
|
|
20
|
+
value: new deps_js_1.Mutex()
|
|
21
|
+
});
|
|
22
|
+
Object.defineProperty(this, "wMutex", {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
configurable: true,
|
|
25
|
+
writable: true,
|
|
26
|
+
value: new deps_js_1.Mutex()
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(this, "resolveCanRead", {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
configurable: true,
|
|
31
|
+
writable: true,
|
|
32
|
+
value: () => { }
|
|
33
|
+
});
|
|
34
|
+
Object.defineProperty(this, "canRead", {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
configurable: true,
|
|
37
|
+
writable: true,
|
|
38
|
+
value: Promise.resolve()
|
|
39
|
+
});
|
|
40
|
+
Object.defineProperty(this, "buffers", {
|
|
41
|
+
enumerable: true,
|
|
42
|
+
configurable: true,
|
|
43
|
+
writable: true,
|
|
44
|
+
value: new Array()
|
|
45
|
+
});
|
|
46
|
+
this.resetCanRead();
|
|
47
|
+
}
|
|
48
|
+
resetCanRead() {
|
|
49
|
+
this.canRead = new Promise((r) => this.resolveCanRead = r);
|
|
50
|
+
}
|
|
51
|
+
get connected() {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
async open() {
|
|
55
|
+
}
|
|
56
|
+
async read() {
|
|
57
|
+
await this.canRead;
|
|
58
|
+
const release = await this.rMutex.acquire();
|
|
59
|
+
try {
|
|
60
|
+
const buffer = this.buffers.pop();
|
|
61
|
+
if (buffer === undefined) {
|
|
62
|
+
throw (0, _0_control_js_1.UNREACHABLE)();
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
return buffer;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
finally {
|
|
69
|
+
if (this.buffers.length == 0) {
|
|
70
|
+
this.resetCanRead();
|
|
71
|
+
}
|
|
72
|
+
release();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
async write(buffer) {
|
|
76
|
+
const release = await this.wMutex.acquire();
|
|
77
|
+
try {
|
|
78
|
+
const res = await fetch(this.url, {
|
|
79
|
+
mode: "cors",
|
|
80
|
+
method: "POST",
|
|
81
|
+
body: buffer,
|
|
82
|
+
});
|
|
83
|
+
this.buffers.push(new Uint8Array(await res.arrayBuffer()));
|
|
84
|
+
}
|
|
85
|
+
finally {
|
|
86
|
+
if (this.buffers.length == 1) {
|
|
87
|
+
this.resolveCanRead();
|
|
88
|
+
}
|
|
89
|
+
release();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
close() {
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
exports.ConnectionHTTP = ConnectionHTTP;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare class ConnectionWebSocket implements
|
|
1
|
+
import { ConnectionUnframed } from "./0_connection.js";
|
|
2
|
+
export declare class ConnectionWebSocket extends ConnectionUnframed implements ConnectionUnframed {
|
|
3
3
|
private webSocket;
|
|
4
4
|
private rMutex;
|
|
5
5
|
private wMutex;
|
|
@@ -26,9 +26,11 @@ 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 _0_connection_js_1 = require("./0_connection.js");
|
|
29
30
|
const d = (0, deps_js_1.debug)("ConnectionWebSocket");
|
|
30
|
-
class ConnectionWebSocket {
|
|
31
|
+
class ConnectionWebSocket extends _0_connection_js_1.ConnectionUnframed {
|
|
31
32
|
constructor(url) {
|
|
33
|
+
super();
|
|
32
34
|
Object.defineProperty(this, "webSocket", {
|
|
33
35
|
enumerable: true,
|
|
34
36
|
configurable: true,
|
|
@@ -72,7 +74,6 @@ class ConnectionWebSocket {
|
|
|
72
74
|
value: null
|
|
73
75
|
});
|
|
74
76
|
this.webSocket = this.reinitWs(url);
|
|
75
|
-
// TODO
|
|
76
77
|
this.webSocket.addEventListener("close", (e) => {
|
|
77
78
|
if (e.code != 1000 && e.reason != "method") {
|
|
78
79
|
this.webSocket = this.reinitWs(url);
|
|
@@ -87,7 +88,7 @@ class ConnectionWebSocket {
|
|
|
87
88
|
return;
|
|
88
89
|
}
|
|
89
90
|
const release = await mutex.acquire();
|
|
90
|
-
const data = new Uint8Array(await new Blob([e.data].map((v) => v instanceof ArrayBuffer ? v : Array.isArray(v) ? v.map((v) => v.buffer) : v.buffer).flat()).arrayBuffer());
|
|
91
|
+
const data = new Uint8Array(await new Blob([e.data].map((v) => v instanceof Blob ? v : v instanceof ArrayBuffer ? v : Array.isArray(v) ? v.map((v) => v.buffer) : v.buffer).flat()).arrayBuffer());
|
|
91
92
|
for (const byte of data) {
|
|
92
93
|
this.buffer.push(byte);
|
|
93
94
|
}
|
|
@@ -166,7 +167,6 @@ class ConnectionWebSocket {
|
|
|
166
167
|
throw new Error("Connection not open");
|
|
167
168
|
}
|
|
168
169
|
this.webSocket.close(1000, "method");
|
|
169
|
-
console.trace("close called");
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
exports.ConnectionWebSocket = ConnectionWebSocket;
|
package/script/constants.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ export declare const ackThreshold = 10;
|
|
|
3
3
|
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
|
-
export declare const LAYER =
|
|
7
|
-
export declare const DEFAULT_APP_VERSION = "MTKruto 0.0.
|
|
6
|
+
export declare const LAYER = 160;
|
|
7
|
+
export declare const DEFAULT_APP_VERSION = "MTKruto 0.0.968";
|
|
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
|
@@ -87,8 +87,8 @@ exports.publicKeys = new Map([
|
|
|
87
87
|
]);
|
|
88
88
|
exports.VECTOR_CONSTRUCTOR = 0x1CB5C415;
|
|
89
89
|
exports.DEFAULT_INITIAL_DC = "2-test";
|
|
90
|
-
exports.LAYER =
|
|
91
|
-
exports.DEFAULT_APP_VERSION = "MTKruto 0.0.
|
|
90
|
+
exports.LAYER = 160;
|
|
91
|
+
exports.DEFAULT_APP_VERSION = "MTKruto 0.0.968";
|
|
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];
|