@mtkruto/browser 0.0.801 → 0.0.821

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.
Files changed (137) hide show
  1. package/esm/client/client_plain.js +4 -3
  2. package/esm/connection/connection_web_socket.js +3 -1
  3. package/{types → esm}/mod.d.ts +1 -0
  4. package/esm/mod.js +1 -0
  5. package/{types → esm}/tl/1_tl_object.d.ts +5 -2
  6. package/esm/tl/1_tl_object.js +14 -7
  7. package/esm/tl/3_tl_reader.js +1 -1
  8. package/esm/tl/3_tl_writer.js +2 -1
  9. package/esm/tl/5_message.js +2 -2
  10. package/esm/utilities/1_message.js +2 -2
  11. package/package.json +3 -10
  12. package/script/_dnt.shims.d.ts +1 -0
  13. package/script/client/client.d.ts +50 -0
  14. package/script/client/client_abstract.d.ts +16 -0
  15. package/script/client/client_plain.d.ts +9 -0
  16. package/script/client/client_plain.js +4 -3
  17. package/script/connection/connection.d.ts +7 -0
  18. package/script/connection/connection_web_socket.d.ts +13 -0
  19. package/script/connection/connection_web_socket.js +3 -1
  20. package/script/constants.d.ts +12 -0
  21. package/script/deps/deno.land/std@0.186.0/fmt/colors.d.ts +270 -0
  22. package/script/deps/deno.land/std@0.186.0/testing/_diff.d.ts +26 -0
  23. package/script/deps/deno.land/std@0.186.0/testing/_format.d.ts +1 -0
  24. package/script/deps/deno.land/std@0.186.0/testing/asserts.d.ts +284 -0
  25. package/script/deps/deno.land/x/crc32@v0.2.0/mod.d.ts +15 -0
  26. package/script/deps/deno.land/x/tgcrypto@0.1.3/mod.d.ts +47 -0
  27. package/script/deps/deno.land/x/tgcrypto@0.1.3/tgcrypto.d.ts +2 -0
  28. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/gzip/gzip.d.ts +16 -0
  29. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/utils/uint8.d.ts +1 -0
  30. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/deflate.d.ts +29 -0
  31. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/inflate.d.ts +23 -0
  32. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/mod.d.ts +2 -0
  33. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/adler32.d.ts +1 -0
  34. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/crc32.d.ts +2 -0
  35. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/deflate.d.ts +78 -0
  36. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/gzheader.d.ts +12 -0
  37. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inffast.d.ts +1 -0
  38. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inflate.d.ts +47 -0
  39. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inftrees.d.ts +1 -0
  40. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/messages.d.ts +12 -0
  41. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/status.d.ts +30 -0
  42. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/trees.d.ts +5 -0
  43. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/zstream.d.ts +14 -0
  44. package/script/deps.d.ts +4 -0
  45. package/script/mod.d.ts +24 -0
  46. package/script/mod.js +3 -1
  47. package/script/session/session.d.ts +12 -0
  48. package/script/session/session_local_storage.d.ts +7 -0
  49. package/script/session/session_memory.d.ts +5 -0
  50. package/script/tl/0_tl_raw_reader.d.ts +13 -0
  51. package/script/tl/0_tl_raw_writer.d.ts +13 -0
  52. package/script/tl/1_tl_object.d.ts +40 -0
  53. package/script/tl/1_tl_object.js +15 -8
  54. package/script/tl/2_types.d.ts +14815 -0
  55. package/script/tl/3_deserialize.d.ts +3 -0
  56. package/script/tl/3_functions.d.ts +6122 -0
  57. package/script/tl/3_tl_reader.d.ts +6 -0
  58. package/script/tl/3_tl_reader.js +2 -2
  59. package/script/tl/3_tl_writer.d.ts +5 -0
  60. package/script/tl/3_tl_writer.js +2 -1
  61. package/script/tl/4_rpc_result.d.ts +8 -0
  62. package/script/tl/5_message.d.ts +11 -0
  63. package/script/tl/5_message.js +1 -1
  64. package/script/tl/6_message_container.d.ts +9 -0
  65. package/script/transport/transport.d.ts +15 -0
  66. package/script/transport/transport_abridged.d.ts +11 -0
  67. package/script/transport/transport_intermediate.d.ts +11 -0
  68. package/script/transport/transport_provider.d.ts +17 -0
  69. package/script/types.d.ts +1 -0
  70. package/script/utilities/0_bigint.d.ts +5 -0
  71. package/script/utilities/0_buffer.d.ts +2 -0
  72. package/script/utilities/0_crypto.d.ts +8 -0
  73. package/script/utilities/0_hash.d.ts +2 -0
  74. package/script/utilities/1_auth.d.ts +1 -0
  75. package/script/utilities/1_message.d.ts +10 -0
  76. package/script/utilities/1_message.js +1 -1
  77. package/script/utilities/1_obfuscation.d.ts +6 -0
  78. package/script/utilities/1_password.d.ts +11 -0
  79. /package/{types → esm}/_dnt.shims.d.ts +0 -0
  80. /package/{types → esm}/client/client.d.ts +0 -0
  81. /package/{types → esm}/client/client_abstract.d.ts +0 -0
  82. /package/{types → esm}/client/client_plain.d.ts +0 -0
  83. /package/{types → esm}/connection/connection.d.ts +0 -0
  84. /package/{types → esm}/connection/connection_web_socket.d.ts +0 -0
  85. /package/{types → esm}/constants.d.ts +0 -0
  86. /package/{types → esm}/deps/deno.land/std@0.186.0/fmt/colors.d.ts +0 -0
  87. /package/{types → esm}/deps/deno.land/std@0.186.0/testing/_diff.d.ts +0 -0
  88. /package/{types → esm}/deps/deno.land/std@0.186.0/testing/_format.d.ts +0 -0
  89. /package/{types → esm}/deps/deno.land/std@0.186.0/testing/asserts.d.ts +0 -0
  90. /package/{types → esm}/deps/deno.land/x/crc32@v0.2.0/mod.d.ts +0 -0
  91. /package/{types → esm}/deps/deno.land/x/tgcrypto@0.1.3/mod.d.ts +0 -0
  92. /package/{types → esm}/deps/deno.land/x/tgcrypto@0.1.3/tgcrypto.d.ts +0 -0
  93. /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/gzip/gzip.d.ts +0 -0
  94. /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/utils/uint8.d.ts +0 -0
  95. /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/deflate.d.ts +0 -0
  96. /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/inflate.d.ts +0 -0
  97. /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/mod.d.ts +0 -0
  98. /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/adler32.d.ts +0 -0
  99. /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/crc32.d.ts +0 -0
  100. /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/deflate.d.ts +0 -0
  101. /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/gzheader.d.ts +0 -0
  102. /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inffast.d.ts +0 -0
  103. /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inflate.d.ts +0 -0
  104. /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inftrees.d.ts +0 -0
  105. /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/messages.d.ts +0 -0
  106. /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/status.d.ts +0 -0
  107. /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/trees.d.ts +0 -0
  108. /package/{types → esm}/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/zstream.d.ts +0 -0
  109. /package/{types → esm}/deps.d.ts +0 -0
  110. /package/{types → esm}/session/session.d.ts +0 -0
  111. /package/{types → esm}/session/session_local_storage.d.ts +0 -0
  112. /package/{types → esm}/session/session_memory.d.ts +0 -0
  113. /package/{types → esm}/tl/0_tl_raw_reader.d.ts +0 -0
  114. /package/{types → esm}/tl/0_tl_raw_writer.d.ts +0 -0
  115. /package/{types → esm}/tl/2_types.d.ts +0 -0
  116. /package/{types/tl/3_tl_object_deserializer.d.ts → esm/tl/3_deserialize.d.ts} +0 -0
  117. /package/esm/tl/{3_tl_object_deserializer.js → 3_deserialize.js} +0 -0
  118. /package/{types → esm}/tl/3_functions.d.ts +0 -0
  119. /package/{types → esm}/tl/3_tl_reader.d.ts +0 -0
  120. /package/{types → esm}/tl/3_tl_writer.d.ts +0 -0
  121. /package/{types → esm}/tl/4_rpc_result.d.ts +0 -0
  122. /package/{types → esm}/tl/5_message.d.ts +0 -0
  123. /package/{types → esm}/tl/6_message_container.d.ts +0 -0
  124. /package/{types → esm}/transport/transport.d.ts +0 -0
  125. /package/{types → esm}/transport/transport_abridged.d.ts +0 -0
  126. /package/{types → esm}/transport/transport_intermediate.d.ts +0 -0
  127. /package/{types → esm}/transport/transport_provider.d.ts +0 -0
  128. /package/{types → esm}/types.d.ts +0 -0
  129. /package/{types → esm}/utilities/0_bigint.d.ts +0 -0
  130. /package/{types → esm}/utilities/0_buffer.d.ts +0 -0
  131. /package/{types → esm}/utilities/0_crypto.d.ts +0 -0
  132. /package/{types → esm}/utilities/0_hash.d.ts +0 -0
  133. /package/{types → esm}/utilities/1_auth.d.ts +0 -0
  134. /package/{types → esm}/utilities/1_message.d.ts +0 -0
  135. /package/{types → esm}/utilities/1_obfuscation.d.ts +0 -0
  136. /package/{types → esm}/utilities/1_password.d.ts +0 -0
  137. /package/script/tl/{3_tl_object_deserializer.js → 3_deserialize.js} +0 -0
@@ -0,0 +1,4 @@
1
+ export * from "./deps/deno.land/std@0.186.0/testing/asserts.js";
2
+ export { ctr256Decrypt, ctr256Encrypt, factorize, ige256Decrypt, ige256Encrypt, init as initTgCrypto } from "./deps/deno.land/x/tgcrypto@0.1.3/mod.js";
3
+ export { gunzip, gzip } from "./deps/raw.githubusercontent.com/MTKruto/compress/master/gzip/gzip.js";
4
+ export { Mutex } from "async-mutex";
@@ -0,0 +1,24 @@
1
+ import { checkPassword } from "./utilities/1_password.js";
2
+ import { getRandomId } from "./utilities/0_bigint.js";
3
+ export declare const utils: {
4
+ checkPassword: typeof checkPassword;
5
+ getRandomId: typeof getRandomId;
6
+ };
7
+ export { as } from "./tl/1_tl_object.js";
8
+ export * as types from "./tl/2_types.js";
9
+ export * as functions from "./tl/3_functions.js";
10
+ export * from "./tl/4_rpc_result.js";
11
+ export * from "./tl/5_message.js";
12
+ export * from "./tl/6_message_container.js";
13
+ export * from "./client/client_plain.js";
14
+ export * from "./client/client.js";
15
+ export * from "./session/session.js";
16
+ export * from "./session/session_memory.js";
17
+ export * from "./session/session_local_storage.js";
18
+ export * from "./transport/transport_abridged.js";
19
+ export * from "./transport/transport_intermediate.js";
20
+ export * from "./transport/transport.js";
21
+ export * from "./transport/transport_provider.js";
22
+ export * from "./connection/connection.js";
23
+ export * from "./connection/connection_web_socket.js";
24
+ export { DEFAULT_APP_VERSION, DEFAULT_DEVICE_MODEL, DEFAULT_INITIAL_DC, DEFAULT_LANG_CODE, DEFAULT_LANG_PACK, DEFAULT_SYSTEM_LANG_CODE, DEFAULT_SYSTEM_VERSION, LAYER } from "./constants.js";
package/script/mod.js CHANGED
@@ -26,10 +26,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
26
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
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.utils = void 0;
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
30
  const _1_password_js_1 = require("./utilities/1_password.js");
31
31
  const _0_bigint_js_1 = require("./utilities/0_bigint.js");
32
32
  exports.utils = { checkPassword: _1_password_js_1.checkPassword, getRandomId: _0_bigint_js_1.getRandomId };
33
+ var _1_tl_object_js_1 = require("./tl/1_tl_object.js");
34
+ Object.defineProperty(exports, "as", { enumerable: true, get: function () { return _1_tl_object_js_1.as; } });
33
35
  exports.types = __importStar(require("./tl/2_types.js"));
34
36
  exports.functions = __importStar(require("./tl/3_functions.js"));
35
37
  __exportStar(require("./tl/4_rpc_result.js"), exports);
@@ -0,0 +1,12 @@
1
+ import { MaybePromise } from "../types.js";
2
+ import { DC } from "../transport/transport_provider.js";
3
+ export declare abstract class Session {
4
+ dc: DC | null;
5
+ private _authKeyId;
6
+ private _authKey;
7
+ abstract load(): MaybePromise<void>;
8
+ abstract save(): MaybePromise<void>;
9
+ get authKeyId(): Promise<bigint | null>;
10
+ set authKey(authKey: Uint8Array | null);
11
+ get authKey(): Uint8Array | null;
12
+ }
@@ -0,0 +1,7 @@
1
+ import { Session } from "./session.js";
2
+ export declare class SessionLocalStorage extends Session implements Session {
3
+ private readonly key;
4
+ constructor(key: string);
5
+ load(): void;
6
+ save(): void;
7
+ }
@@ -0,0 +1,5 @@
1
+ import { Session } from "./session.js";
2
+ export declare class SessionMemory extends Session implements Session {
3
+ load(): void;
4
+ save(): void;
5
+ }
@@ -0,0 +1,13 @@
1
+ export declare class TLRawReader {
2
+ protected _buffer: Uint8Array;
3
+ constructor(_buffer: Uint8Array);
4
+ get buffer(): Uint8Array;
5
+ read(count: number): Uint8Array;
6
+ readInt24(signed?: boolean): number;
7
+ readInt32(signed?: boolean): number;
8
+ readInt64(signed?: boolean): bigint;
9
+ readInt128(signed?: boolean): bigint;
10
+ readInt256(signed?: boolean): bigint;
11
+ readBytes(): Uint8Array;
12
+ readString(): string;
13
+ }
@@ -0,0 +1,13 @@
1
+ export declare class TLRawWriter {
2
+ protected _buffer: Uint8Array;
3
+ constructor();
4
+ get buffer(): Uint8Array;
5
+ write(buffer: Uint8Array): this;
6
+ writeInt24(int: number, signed?: boolean): this;
7
+ writeInt32(int: number, signed?: boolean): this;
8
+ writeInt64(int: bigint, signed?: boolean): this;
9
+ writeInt128(int: bigint, signed?: boolean): this;
10
+ writeInt256(int: bigint, signed?: boolean): this;
11
+ writeBytes(bytes: Uint8Array): this;
12
+ writeString(string: string): this;
13
+ }
@@ -0,0 +1,40 @@
1
+ type MaybeArrayOf<T> = T | T[];
2
+ type MaybeInArray<T> = T | [T];
3
+ export type ParamDesc = ([
4
+ string,
5
+ MaybeInArray<typeof TLObject | typeof Uint8Array | "string" | "number" | "bigint" | "boolean" | "true">,
6
+ string
7
+ ] | [string, typeof flags, "#"])[];
8
+ export type Param = null | MaybeArrayOf<string | number | bigint | boolean | Uint8Array | TLObject>;
9
+ export declare const flags: unique symbol;
10
+ export type Params = ([
11
+ Param,
12
+ MaybeInArray<typeof TLObject | typeof Uint8Array | "string" | "number" | "bigint" | "boolean" | "true">,
13
+ string
14
+ ] | [string, typeof flags, "#"])[];
15
+ export declare const id: unique symbol;
16
+ export declare const params: unique symbol;
17
+ export declare const paramDesc: unique symbol;
18
+ export declare const length: unique symbol;
19
+ export declare const serialize: unique symbol;
20
+ export declare const as: unique symbol;
21
+ export declare function isOptionalParam(ntype: string): boolean;
22
+ export declare function analyzeOptionalParam(ntype: string): {
23
+ flagField: string;
24
+ bitIndex: number;
25
+ };
26
+ export declare abstract class TLObject {
27
+ protected abstract get [id](): number;
28
+ protected abstract get [params](): Params;
29
+ protected static get [paramDesc](): ParamDesc;
30
+ get [length](): number;
31
+ [serialize](): Uint8Array;
32
+ [as]<T extends TLObjectConstructor<InstanceType<T>>>(constructor: T): InstanceType<T>;
33
+ }
34
+ export type MaybeVectorTLObject = TLObject | Array<MaybeVectorTLObject | TLObject>;
35
+ export interface TLObjectConstructor<T = TLObject> {
36
+ new (params: any): T;
37
+ [paramDesc]: ParamDesc;
38
+ }
39
+ export declare function isTLObjectConstructor(t: unknown): t is typeof TLObject;
40
+ export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isTLObjectConstructor = exports.TLObject = exports.analyzeOptionalParam = exports.isOptionalParam = exports.length = exports.paramDesc = exports.params = exports.id = exports.flags = void 0;
3
+ exports.isTLObjectConstructor = exports.TLObject = exports.analyzeOptionalParam = exports.isOptionalParam = exports.as = exports.serialize = exports.length = exports.paramDesc = exports.params = exports.id = exports.flags = void 0;
4
4
  const deps_js_1 = require("../deps.js");
5
5
  const _0_tl_raw_writer_js_1 = require("./0_tl_raw_writer.js");
6
6
  exports.flags = Symbol("flags");
@@ -8,6 +8,8 @@ exports.id = Symbol("id");
8
8
  exports.params = Symbol("params");
9
9
  exports.paramDesc = Symbol("paramDesc");
10
10
  exports.length = Symbol("length");
11
+ exports.serialize = Symbol();
12
+ exports.as = Symbol();
11
13
  function isOptionalParam(ntype) {
12
14
  return ntype.includes("?");
13
15
  }
@@ -27,7 +29,7 @@ function serializeSingleParam(writer, value, type, ntype) {
27
29
  if (isTLObjectConstructor(type)) {
28
30
  if ((type.name == "TypeX" && value instanceof TLObject) ||
29
31
  value instanceof type) {
30
- writer.write(value.serialize());
32
+ writer.write(value[exports.serialize]());
31
33
  return;
32
34
  }
33
35
  else {
@@ -92,10 +94,7 @@ function serializeSingleParam(writer, value, type, ntype) {
92
94
  }
93
95
  break;
94
96
  case "true":
95
- if (value === true) {
96
- writer.writeInt32(0x997275B5);
97
- }
98
- else {
97
+ if (value !== true) {
99
98
  throw new TypeError("Expected true");
100
99
  }
101
100
  }
@@ -106,9 +105,9 @@ class TLObject {
106
105
  return [];
107
106
  }
108
107
  get [exports.length]() {
109
- return this.serialize().byteLength;
108
+ return this[exports.serialize]().byteLength;
110
109
  }
111
- serialize() {
110
+ [exports.serialize]() {
112
111
  const writer = new _0_tl_raw_writer_js_1.TLRawWriter();
113
112
  writer.writeInt32(this[exports.id], false);
114
113
  for (const [value, type, ntype] of this[exports.params]) {
@@ -147,6 +146,14 @@ class TLObject {
147
146
  }
148
147
  return writer.buffer;
149
148
  }
149
+ [exports.as](constructor) {
150
+ if (this instanceof constructor) {
151
+ return this;
152
+ }
153
+ else {
154
+ throw new TypeError(`Expected ${constructor.name}, got ${this.constructor.name}`);
155
+ }
156
+ }
150
157
  }
151
158
  exports.TLObject = TLObject;
152
159
  function isTLObjectConstructor(t) {