@mtkruto/node 0.153.0 → 0.154.0

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 (51) hide show
  1. package/esm/4_constants.d.ts +1 -0
  2. package/esm/4_constants.d.ts.map +1 -1
  3. package/esm/4_constants.js +1 -0
  4. package/esm/client/1_client_plain.d.ts +1 -1
  5. package/esm/client/1_client_plain.d.ts.map +1 -1
  6. package/esm/client/1_client_plain.js +25 -13
  7. package/esm/client/2_client_encrypted.d.ts +6 -3
  8. package/esm/client/2_client_encrypted.d.ts.map +1 -1
  9. package/esm/client/2_client_encrypted.js +155 -48
  10. package/esm/client/2_network_statistics_manager.d.ts.map +1 -1
  11. package/esm/client/2_network_statistics_manager.js +3 -2
  12. package/esm/client/2_update_manager.d.ts.map +1 -1
  13. package/esm/client/2_update_manager.js +6 -1
  14. package/esm/client/6_client.d.ts +2 -0
  15. package/esm/client/6_client.d.ts.map +1 -1
  16. package/esm/client/6_client.js +4 -1
  17. package/esm/session/0_session_state.d.ts +1 -0
  18. package/esm/session/0_session_state.d.ts.map +1 -1
  19. package/esm/session/0_session_state.js +8 -4
  20. package/esm/session/1_session.d.ts +1 -0
  21. package/esm/session/1_session.d.ts.map +1 -1
  22. package/esm/session/1_session.js +3 -0
  23. package/esm/session/2_session_encrypted.d.ts +11 -6
  24. package/esm/session/2_session_encrypted.d.ts.map +1 -1
  25. package/esm/session/2_session_encrypted.js +18 -10
  26. package/package.json +1 -1
  27. package/script/4_constants.d.ts +1 -0
  28. package/script/4_constants.d.ts.map +1 -1
  29. package/script/4_constants.js +2 -1
  30. package/script/client/1_client_plain.d.ts +1 -1
  31. package/script/client/1_client_plain.d.ts.map +1 -1
  32. package/script/client/1_client_plain.js +24 -12
  33. package/script/client/2_client_encrypted.d.ts +6 -3
  34. package/script/client/2_client_encrypted.d.ts.map +1 -1
  35. package/script/client/2_client_encrypted.js +156 -49
  36. package/script/client/2_network_statistics_manager.d.ts.map +1 -1
  37. package/script/client/2_network_statistics_manager.js +3 -2
  38. package/script/client/2_update_manager.d.ts.map +1 -1
  39. package/script/client/2_update_manager.js +6 -1
  40. package/script/client/6_client.d.ts +2 -0
  41. package/script/client/6_client.d.ts.map +1 -1
  42. package/script/client/6_client.js +4 -1
  43. package/script/session/0_session_state.d.ts +1 -0
  44. package/script/session/0_session_state.d.ts.map +1 -1
  45. package/script/session/0_session_state.js +8 -4
  46. package/script/session/1_session.d.ts +1 -0
  47. package/script/session/1_session.d.ts.map +1 -1
  48. package/script/session/1_session.js +3 -0
  49. package/script/session/2_session_encrypted.d.ts +11 -6
  50. package/script/session/2_session_encrypted.d.ts.map +1 -1
  51. package/script/session/2_session_encrypted.js +18 -10
@@ -16,4 +16,5 @@ export declare const MAX_CHANNEL_ID = 997852516352;
16
16
  export declare const CHANNEL_DIFFERENCE_LIMIT_USER = 100;
17
17
  export declare const CHANNEL_DIFFERENCE_LIMIT_BOT = 100000;
18
18
  export declare const DOWNLOAD_MAX_CHUNK_SIZE: number;
19
+ export declare const TEMPORARY_AUTH_KEY_TTL = 86400;
19
20
  //# sourceMappingURL=4_constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"4_constants.d.ts","sourceRoot":"","sources":["../src/4_constants.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAE3C,MAAM,MAAM,UAAU,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC;AAE/D,eAAO,MAAM,WAAW,EAAE,UAkDxB,CAAC;AAEH,eAAO,MAAM,UAAU,EAAE,EAAQ,CAAC;AAElC,eAAO,MAAM,WAAW,YAAY,CAAC;AAGrC,eAAO,MAAM,YAAY,EAAE,MAA+Q,CAAC;AAE3S,eAAO,MAAM,SAAS,EAAE,MAA6H,CAAC;AAEtJ,eAAO,MAAM,SAAS,KAAK,CAAC;AAE5B,eAAO,MAAM,g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QAAe,CAAC;AAEpD,eAAO,MAAM,sBAAsB,QAAS,CAAC"}
@@ -87,3 +87,4 @@ export const MAX_CHANNEL_ID = 997852516352;
87
87
  export const CHANNEL_DIFFERENCE_LIMIT_USER = 100;
88
88
  export const CHANNEL_DIFFERENCE_LIMIT_BOT = 100_000;
89
89
  export const DOWNLOAD_MAX_CHUNK_SIZE = 1 * megabyte;
90
+ export const TEMPORARY_AUTH_KEY_TTL = 86_400;
@@ -32,6 +32,6 @@ export declare class ClientPlain extends ClientAbstract implements ClientAbstrac
32
32
  session: SessionPlain;
33
33
  constructor(dc: DC, params?: ClientPlainParams);
34
34
  invoke<T extends Mtproto.AnyObject, R = T["_"] extends keyof Mtproto.Functions ? Mtproto.ReturnType<T> extends never ? Mtproto.ReturnType<Mtproto.Functions[T["_"]]> : never : never>(function_: T): Promise<R>;
35
- createAuthKey(): Promise<[Uint8Array<ArrayBuffer>, bigint]>;
35
+ createAuthKey(isTemporary: boolean): Promise<[Uint8Array<ArrayBuffer>, bigint]>;
36
36
  }
37
37
  //# sourceMappingURL=1_client_plain.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"1_client_plain.d.ts","sourceRoot":"","sources":["../../src/client/1_client_plain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,EAAW,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,KAAK,aAAa,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAKxD,MAAM,WAAW,iBAAkB,SAAQ,aAAa;IACtD,2KAA2K;IAC3K,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;AAED,oJAAoJ;AACpJ,qBAAa,WAAY,SAAQ,cAAe,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AAS,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,SAAS,MAAM,OAAO,CAAC,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,KAAK,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,KAAK,EAAE,SAAS,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAM/M,aAAa,CAAC,WAAW,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,CAAC;CA4ItF"}
@@ -21,7 +21,7 @@ import { assert, assertEquals, concat, ige256Decrypt, ige256Encrypt, unreachable
21
21
  import { factorize, getLogger, getRandomInt, intFromBytes, intToBytes, modExp, rsaPad, sha1 } from "../1_utilities.js";
22
22
  import { Mtproto } from "../2_tl.js";
23
23
  import { getDcId } from "../3_transport.js";
24
- import { PUBLIC_KEYS } from "../4_constants.js";
24
+ import { PUBLIC_KEYS, TEMPORARY_AUTH_KEY_TTL } from "../4_constants.js";
25
25
  import { SessionPlain } from "../4_session.js";
26
26
  import { ClientAbstract } from "./0_client_abstract.js";
27
27
  const L = getLogger("ClientPlain");
@@ -40,9 +40,9 @@ export class ClientPlain extends ClientAbstract {
40
40
  const body = await this.session.receive();
41
41
  return await Mtproto.deserializeType(Mtproto.mustGetReturnType(function_._), body);
42
42
  }
43
- async createAuthKey() {
43
+ async createAuthKey(isTemporary) {
44
44
  const nonce = getRandomInt(16);
45
- LcreateAuthKey.debug("auth key creation started");
45
+ LcreateAuthKey.debug(`${isTemporary ? "temporary " : ""}auth key creation started`);
46
46
  let resPq = null;
47
47
  for (let i = 0; i < 10; i++) {
48
48
  try {
@@ -84,16 +84,28 @@ export class ClientPlain extends ClientAbstract {
84
84
  const pq = resPq.pq;
85
85
  const serverNonce = resPq.server_nonce;
86
86
  const newNonce = getRandomInt(32);
87
- let encryptedData = await rsaPad(Mtproto.serializeObject({
88
- _: "p_q_inner_data_dc",
89
- pq,
90
- p,
91
- q,
92
- dc,
93
- new_nonce: newNonce,
94
- nonce,
95
- server_nonce: serverNonce,
96
- }), publicKey);
87
+ let encryptedData = await rsaPad(Mtproto.serializeObject(isTemporary
88
+ ? {
89
+ _: "p_q_inner_data_temp_dc",
90
+ pq,
91
+ p,
92
+ q,
93
+ dc,
94
+ new_nonce: newNonce,
95
+ nonce,
96
+ server_nonce: serverNonce,
97
+ expires_in: TEMPORARY_AUTH_KEY_TTL,
98
+ }
99
+ : {
100
+ _: "p_q_inner_data_dc",
101
+ pq,
102
+ p,
103
+ q,
104
+ dc,
105
+ new_nonce: newNonce,
106
+ nonce,
107
+ server_nonce: serverNonce,
108
+ }), publicKey);
97
109
  const dhParams = await this.invoke({
98
110
  _: "req_DH_params",
99
111
  nonce,
@@ -17,6 +17,7 @@
17
17
  * You should have received a copy of the GNU Lesser General Public License
18
18
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
19
  */
20
+ import { type MaybePromise } from "../1_utilities.js";
20
21
  import { Api, Mtproto } from "../2_tl.js";
21
22
  import type { DC } from "../3_transport.js";
22
23
  import { SessionEncrypted } from "../4_session.js";
@@ -37,11 +38,13 @@ export interface ClientEncryptedParams extends ClientPlainParams {
37
38
  systemVersion?: string;
38
39
  /** Whether to disable receiving updates. Defaults to `false`. */
39
40
  disableUpdates?: boolean;
41
+ /** Whether perfect forward secrecy should be enabled. Defaults to `false`. */
42
+ isPerfectForwardSecrecyEnabled?: boolean;
40
43
  }
41
44
  export interface ClientEncryptedHandlers {
42
- onNewServerSalt?: (newServerSalt: bigint) => void;
43
- onUpdate?: (update: Api.Updates | Api.Update) => void;
44
- onDeserializationError?: () => void;
45
+ onNewServerSalt?: (newServerSalt: bigint) => MaybePromise<void>;
46
+ onUpdate?: (update: Api.Updates | Api.Update) => MaybePromise<void>;
47
+ onDeserializationError?: () => MaybePromise<void>;
45
48
  }
46
49
  export declare class ClientEncrypted extends ClientAbstract {
47
50
  #private;
@@ -1 +1 @@
1
- {"version":3,"file":"2_client_encrypted.d.ts","sourceRoot":"","sources":["../../src/client/2_client_encrypted.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAAE,GAAG,EAAE,OAAO,EAAK,MAAM,YAAY,CAAC;AAE7C,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AAG5C,OAAO,EAAE,gBAAgB,EAAgB,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAO1E,MAAM,WAAW,qBAAsB,SAAQ,iBAAiB;IAC9D,iKAAiK;IACjK,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8GAA8G;IAC9G,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4GAA4G;IAC5G,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2FAA2F;IAC3F,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mHAAmH;IACnH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,8GAA8G;IAC9G,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iEAAiE;IACjE,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,uBAAuB;IACtC,eAAe,CAAC,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,IAAI,CAAC;IAClD,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,MAAM,KAAK,IAAI,CAAC;IACtD,sBAAsB,CAAC,EAAE,MAAM,IAAI,CAAC;CACrC;AAED,qBAAa,eAAgB,SAAQ,cAAc;;IAIjD,QAAQ,EAAE,uBAAuB,CAAM;IAIvC,OAAO,EAAE,gBAAgB,CAAC;gBAYd,EAAE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AAG,CAAC,SAAS,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,GAAG,CAAC,SAAS,GAAG,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,SAAS,MAAM,GAAG,CAAC,SAAS,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,KAAK,GAAG,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,KAAK,EAAE,SAAS,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAwG3T"}
@@ -18,11 +18,11 @@
18
18
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
19
  */
20
20
  var _a;
21
- import { InputError } from "../0_errors.js";
22
- import { getLogger } from "../1_utilities.js";
23
- import { Api, Mtproto, X } from "../2_tl.js";
24
- import { ConnectionNotInited } from "../3_errors.js";
25
- import { APP_VERSION, DEVICE_MODEL, LANG_CODE, LANG_PACK, SYSTEM_LANG_CODE, SYSTEM_VERSION } from "../4_constants.js";
21
+ import { concat, delay, ige256Encrypt, SECOND } from "../0_deps.js";
22
+ import { drop, fromUnixTimestamp, getLogger, getRandomId, intFromBytes, mod, sha1, toUnixTimestamp } from "../1_utilities.js";
23
+ import { Api, Mtproto, serializeMessage, TLWriter, X } from "../2_tl.js";
24
+ import { APP_VERSION, DEVICE_MODEL, LANG_CODE, LANG_PACK, SYSTEM_LANG_CODE, SYSTEM_VERSION, TEMPORARY_AUTH_KEY_TTL } from "../4_constants.js";
25
+ import { ConnectionNotInited, InputError } from "../4_errors.js";
26
26
  import { constructTelegramError } from "../4_errors.js";
27
27
  import { SessionEncrypted, SessionError } from "../4_session.js";
28
28
  import { ClientAbstract } from "./0_client_abstract.js";
@@ -35,62 +35,146 @@ export class ClientEncrypted extends ClientAbstract {
35
35
  static #AUTH_KEY_CREATION_MAX_TRIES = 10;
36
36
  handlers = {};
37
37
  #L;
38
- #plain;
38
+ #dc;
39
+ #apiId;
40
+ #params;
41
+ #authKey = new Uint8Array();
42
+ #authKeyId = 0n;
43
+ #temporaryAuthKey = new Uint8Array();
44
+ #temporaryAuthKeyExpiresIn = 0;
39
45
  session;
40
46
  #sentRequests = new Map();
41
- #apiId;
42
- #appVersion;
43
- #deviceModel;
44
- #langCode;
45
- #langPack;
46
- #systemLangCode;
47
- #systemVersion;
48
- #disableUpdates;
47
+ #isAuthKeyBound = false;
48
+ #isPerfectForwardSecrecyEnabled = false;
49
49
  constructor(dc, apiId, params) {
50
50
  super();
51
51
  this.#L = getLogger("ClientEncrypted").client(id++);
52
- this.#plain = new ClientPlain(dc, params);
52
+ this.#dc = dc;
53
+ this.#apiId = apiId;
54
+ this.#params = params;
55
+ this.#isPerfectForwardSecrecyEnabled = params?.isPerfectForwardSecrecyEnabled ?? false;
53
56
  this.session = new SessionEncrypted(dc, params);
57
+ this.session.handlers.onTransportError = this.#onTransportError.bind(this);
54
58
  this.session.handlers.onUpdate = this.#onUpdate.bind(this);
55
59
  this.session.handlers.onNewServerSalt = this.#onNewServerSalt.bind(this);
56
60
  this.session.handlers.onMessageFailed = this.#onMessageFailed.bind(this);
57
61
  this.session.handlers.onRpcError = this.#onRpcError.bind(this);
58
62
  this.session.handlers.onRpcResult = this.#onRpcResult.bind(this);
59
63
  this.session.handlers.onPong = this.#onPong.bind(this);
60
- this.#apiId = apiId;
61
- this.#appVersion = params?.appVersion ?? APP_VERSION;
62
- this.#deviceModel = params?.deviceModel ?? DEVICE_MODEL;
63
- this.#langCode = params?.langCode ?? LANG_CODE;
64
- this.#langPack = params?.langPack ?? LANG_PACK;
65
- this.#systemLangCode = params?.systemLangCode ?? SYSTEM_LANG_CODE;
66
- this.#systemVersion = params?.systemVersion ?? SYSTEM_VERSION;
67
- this.#disableUpdates = params?.disableUpdates ?? false;
64
+ }
65
+ async #encryptMessage(message) {
66
+ const payloadWriter = new TLWriter();
67
+ payloadWriter.writeInt64(getRandomId());
68
+ payloadWriter.writeInt64(getRandomId());
69
+ payloadWriter.write(await serializeMessage(message));
70
+ let payload = payloadWriter.buffer;
71
+ const payloadSha1 = await sha1(payload);
72
+ const messageKey = payloadSha1.subarray(4, 20);
73
+ payloadWriter.write(new Uint8Array(mod(-payload.length, 16)));
74
+ payload = payloadWriter.buffer;
75
+ const sha1A = await sha1(concat([messageKey, this.#authKey.subarray(0, 32)]));
76
+ const sha1B = await sha1(concat([this.#authKey.slice(32, 48), messageKey, this.#authKey.slice(48, 64)]));
77
+ const sha1C = await sha1(concat([this.#authKey.slice(64, 96), messageKey]));
78
+ const sha1D = await sha1(concat([messageKey, this.#authKey.slice(96, 128)]));
79
+ const encryptionKey = concat([sha1A.slice(0, 8), sha1B.slice(8, 20), sha1C.slice(4, 16)]);
80
+ const encryptionIv = concat([sha1A.slice(8, 20), sha1B.slice(0, 8), sha1C.slice(16, 20), sha1D.slice(0, 8)]);
81
+ const encrypted = ige256Encrypt(payload, encryptionKey, encryptionIv);
82
+ const messageWriter = new TLWriter();
83
+ messageWriter.writeInt64(this.#authKeyId);
84
+ messageWriter.write(messageKey);
85
+ messageWriter.write(encrypted);
86
+ return messageWriter.buffer;
68
87
  }
69
88
  async connect() {
70
89
  if (!this.authKey.byteLength) {
71
90
  await this.#createAuthKey();
72
91
  }
92
+ else if (this.#isPerfectForwardSecrecyEnabled) {
93
+ this.#L.debug("creating temporary auth key");
94
+ await this.#createAuthKeyInner(true);
95
+ }
73
96
  await super.connect();
97
+ if (this.#isPerfectForwardSecrecyEnabled) {
98
+ this.#isAuthKeyBound = false;
99
+ await this.#bindTemporaryAuthKey();
100
+ drop(this.#refreshTemporaryAuthKey());
101
+ }
102
+ else {
103
+ this.#isAuthKeyBound = true;
104
+ }
105
+ }
106
+ async #bindTemporaryAuthKey() {
107
+ const nonce = getRandomId();
108
+ const expires_at = toUnixTimestamp(new Date()) + TEMPORARY_AUTH_KEY_TTL;
109
+ this.#temporaryAuthKeyExpiresIn = fromUnixTimestamp(expires_at).getTime() - Date.now();
110
+ const object = {
111
+ _: "bind_auth_key_inner",
112
+ perm_auth_key_id: this.#authKeyId,
113
+ nonce,
114
+ expires_at,
115
+ temp_auth_key_id: this.session.authKeyId,
116
+ temp_session_id: this.session.id,
117
+ };
118
+ const encrypted_message = await this.#encryptMessage({
119
+ _: "message",
120
+ seqno: 0,
121
+ msg_id: this.session.previewNextMessageId(),
122
+ body: Mtproto.serializeObject(object),
123
+ });
124
+ await this.invoke({
125
+ _: "auth.bindTempAuthKey",
126
+ perm_auth_key_id: this.#authKeyId,
127
+ nonce,
128
+ encrypted_message,
129
+ expires_at,
130
+ }), this.#isAuthKeyBound = true;
131
+ }
132
+ #temporaryAuthKeyTimeoutController;
133
+ async #refreshTemporaryAuthKey() {
134
+ this.#temporaryAuthKeyTimeoutController?.abort();
135
+ const controller = this.#temporaryAuthKeyTimeoutController = new AbortController();
136
+ await delay(Math.max(0, this.#temporaryAuthKeyExpiresIn - 5 * SECOND), { signal: controller.signal });
137
+ if (this.#temporaryAuthKeyTimeoutController !== controller) {
138
+ return;
139
+ }
140
+ this.#temporaryAuthKeyTimeoutController = undefined;
141
+ this.#L.debug("reconnecting with a new temporary auth key");
142
+ this.disconnect();
143
+ drop(this.connect());
74
144
  }
75
145
  disconnect() {
76
146
  super.disconnect();
147
+ this.#temporaryAuthKeyTimeoutController?.abort();
148
+ this.#temporaryAuthKeyTimeoutController = undefined;
77
149
  this.lastRequest = undefined;
78
150
  }
79
151
  #createAuthKeyPromise;
80
152
  #createAuthKey() {
81
- return this.#createAuthKeyPromise ??= this.#createAuthKeyInner().finally(() => {
153
+ return this.#createAuthKeyPromise ??= (this.#isPerfectForwardSecrecyEnabled ? Promise.all([this.#createAuthKeyInner(false), this.#createAuthKeyInner(true)]) : this.#createAuthKeyInner(false)).finally(() => {
82
154
  this.#createAuthKeyPromise = undefined;
83
155
  });
84
156
  }
85
- async #createAuthKeyInner() {
157
+ async #createAuthKeyInner(isTemporary) {
86
158
  let lastErr;
87
159
  let errored = false;
160
+ const plain = new ClientPlain(this.#dc, this.#params);
88
161
  for (let i = 0; i < _a.#AUTH_KEY_CREATION_MAX_TRIES; ++i) {
89
162
  try {
90
- await this.#plain.connect();
91
- const [authKey, serverSalt] = await this.#plain.createAuthKey();
92
- await this.setAuthKey(authKey);
93
- this.serverSalt = serverSalt;
163
+ await plain.connect();
164
+ const [authKey, serverSalt] = await plain.createAuthKey(isTemporary);
165
+ if (isTemporary) {
166
+ this.#temporaryAuthKey = authKey;
167
+ await this.session.setAuthKey(this.#temporaryAuthKey);
168
+ this.session.serverSalt = serverSalt;
169
+ this.#isConnectionInited = false;
170
+ }
171
+ else {
172
+ await this.setAuthKey(authKey);
173
+ }
174
+ if (!this.#isPerfectForwardSecrecyEnabled) {
175
+ await this.session.setAuthKey(authKey);
176
+ this.session.serverSalt = serverSalt;
177
+ }
94
178
  errored = false;
95
179
  break;
96
180
  }
@@ -103,7 +187,7 @@ export class ClientEncrypted extends ClientAbstract {
103
187
  this.#L.error("failed to create auth key:", err);
104
188
  }
105
189
  finally {
106
- this.#plain.disconnect();
190
+ plain.disconnect();
107
191
  }
108
192
  }
109
193
  if (errored) {
@@ -111,12 +195,19 @@ export class ClientEncrypted extends ClientAbstract {
111
195
  }
112
196
  }
113
197
  get authKey() {
114
- return this.session.authKey;
198
+ return this.#isPerfectForwardSecrecyEnabled ? this.#authKey : this.session.authKey;
115
199
  }
116
200
  async setAuthKey(authKey) {
117
- await this.session.setAuthKey(authKey);
201
+ if (this.#isPerfectForwardSecrecyEnabled) {
202
+ const hash = await sha1(authKey);
203
+ this.#authKeyId = intFromBytes(hash.slice(-8));
204
+ this.#authKey = authKey;
205
+ }
206
+ else {
207
+ await this.session.setAuthKey(authKey);
208
+ }
118
209
  }
119
- #connectionInited = false;
210
+ #isConnectionInited = false;
120
211
  lastRequest;
121
212
  async #send(function_) {
122
213
  this.lastRequest = new Date();
@@ -125,27 +216,27 @@ export class ClientEncrypted extends ClientAbstract {
125
216
  body = Mtproto.serializeObject(function_);
126
217
  }
127
218
  else {
128
- if (this.#disableUpdates && !isMediaFunction(function_)) {
219
+ if (this.#isAuthKeyBound && this.#params?.disableUpdates && !isMediaFunction(function_)) {
129
220
  function_ = { _: "invokeWithoutUpdates", query: function_ };
130
221
  }
131
- if (!this.#connectionInited) {
222
+ if (this.#isAuthKeyBound && !this.#isConnectionInited) {
132
223
  if (!this.#apiId) {
133
224
  throw new InputError("apiId not set");
134
225
  }
135
226
  function_ = {
136
227
  _: "initConnection",
137
228
  api_id: this.#apiId,
138
- app_version: this.#appVersion,
139
- device_model: this.#deviceModel,
140
- lang_code: this.#langCode,
141
- lang_pack: this.#langPack,
229
+ app_version: this.#params?.appVersion ?? APP_VERSION,
230
+ device_model: this.#params?.deviceModel ?? DEVICE_MODEL,
231
+ lang_code: this.#params?.langCode ?? LANG_CODE,
232
+ lang_pack: this.#params?.langPack ?? LANG_PACK,
142
233
  query: {
143
234
  _: "invokeWithLayer",
144
235
  layer: Api.LAYER,
145
236
  query: function_,
146
237
  },
147
- system_lang_code: this.#systemLangCode,
148
- system_version: this.#systemVersion,
238
+ system_lang_code: this.#params?.systemLangCode ?? SYSTEM_LANG_CODE,
239
+ system_version: this.#params?.systemVersion ?? SYSTEM_VERSION,
149
240
  };
150
241
  }
151
242
  body = Api.serializeObject(function_);
@@ -190,6 +281,17 @@ export class ClientEncrypted extends ClientAbstract {
190
281
  this.#sentRequests.set(messageId, sentRequest);
191
282
  return await sentRequest.promiseWithResolvers.promise;
192
283
  }
284
+ async #onTransportError(transportError) {
285
+ this.#L.error("transport error:", transportError);
286
+ if (!this.#isPerfectForwardSecrecyEnabled) {
287
+ return;
288
+ }
289
+ if (transportError.code === -404) {
290
+ this.#L.debug("reconnecting with a new temporary auth key");
291
+ this.disconnect();
292
+ await this.connect();
293
+ }
294
+ }
193
295
  async #onUpdate(body) {
194
296
  let type;
195
297
  try {
@@ -197,18 +299,18 @@ export class ClientEncrypted extends ClientAbstract {
197
299
  }
198
300
  catch (err) {
199
301
  this.#L.error("failed to deserialize update:", err);
200
- this.handlers.onDeserializationError?.();
302
+ await this.handlers.onDeserializationError?.();
201
303
  return;
202
304
  }
203
305
  if (Api.isOfEnum("Update", type) || Api.isOfEnum("Updates", type)) {
204
- this.handlers.onUpdate?.(type);
306
+ await this.handlers.onUpdate?.(type);
205
307
  }
206
308
  else {
207
309
  this.#L.warning("received unknown type:", repr(type));
208
310
  }
209
311
  }
210
312
  #onNewServerSalt(serverSalt) {
211
- this.handlers.onNewServerSalt?.(serverSalt);
313
+ drop(this.handlers.onNewServerSalt?.(serverSalt));
212
314
  }
213
315
  async #onMessageFailed(msgId, error) {
214
316
  const request = this.#sentRequests.get(msgId);
@@ -223,13 +325,18 @@ export class ClientEncrypted extends ClientAbstract {
223
325
  }
224
326
  }
225
327
  async #onRpcError(msgId, error) {
328
+ if (error.error_message === "AUTH_KEY_PERM_EMPTY" || error.error_message === "ENCRYPTED_MESSAGE_INVALID") {
329
+ this.#L.debug("reconnecting with a new temporary auth key because of", error.error_message);
330
+ this.disconnect();
331
+ await this.connect();
332
+ }
226
333
  const request = this.#sentRequests.get(msgId);
227
334
  this.#L.debug("received rpc_error with req_msg_id =", msgId, "for", request === undefined ? "unknown" : "known", "request");
228
335
  if (request) {
229
336
  this.#sentRequests.delete(msgId);
230
337
  const reason = constructTelegramError(error, request.call);
231
338
  if (reason instanceof ConnectionNotInited) {
232
- this.#connectionInited = false;
339
+ this.#isConnectionInited = false;
233
340
  await this.#resend(request);
234
341
  }
235
342
  else {
@@ -251,15 +358,15 @@ export class ClientEncrypted extends ClientAbstract {
251
358
  catch (err) {
252
359
  sentRequest.promiseWithResolvers.reject(err);
253
360
  this.#L.error("failed to deserialize rpc_result body:", err);
254
- this.handlers.onDeserializationError?.();
361
+ await this.handlers.onDeserializationError?.();
255
362
  return;
256
363
  }
257
364
  finally {
258
365
  this.#sentRequests.delete(msgId);
259
366
  }
260
367
  }
261
- if (!this.#connectionInited) {
262
- this.#connectionInited = true;
368
+ if (!this.#isConnectionInited) {
369
+ this.#isConnectionInited = true;
263
370
  }
264
371
  }
265
372
  #onPong(pong) {
@@ -1 +1 @@
1
- {"version":3,"file":"2_network_statistics_manager.d.ts","sourceRoot":"","sources":["../../src/client/2_network_statistics_manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,cAAc,CAAC;AAEtC,qBAAa,wBAAwB;;gBAIvB,CAAC,EAAE,CAAC;IAKV,oBAAoB;;;;;;;;;;IAmB1B,6BAA6B,CAAC,OAAO,EAAE,OAAO;sBAE5B,MAAM;uBAKL,MAAM;;CA2B1B"}
1
+ {"version":3,"file":"2_network_statistics_manager.d.ts","sourceRoot":"","sources":["../../src/client/2_network_statistics_manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,cAAc,CAAC;AAEtC,qBAAa,wBAAwB;;gBAIvB,CAAC,EAAE,CAAC;IAKV,oBAAoB;;;;;;;;;;IAmB1B,6BAA6B,CAAC,OAAO,EAAE,OAAO;sBAE5B,MAAM;uBAKL,MAAM;;CA2B1B"}
@@ -17,6 +17,7 @@
17
17
  * You should have received a copy of the GNU Lesser General Public License
18
18
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
19
  */
20
+ import { drop } from "../utilities/0_misc.js";
20
21
  import { getLogger } from "../utilities/1_logger.js";
21
22
  export class NetworkStatisticsManager {
22
23
  #c;
@@ -48,12 +49,12 @@ export class NetworkStatisticsManager {
48
49
  read: (count) => {
49
50
  const key = isMedia ? "netstat_media_read" : "netstat_messages_read";
50
51
  this.#pendingWrites[key] = (this.#pendingWrites[key] ?? 0) + count;
51
- this.#write();
52
+ drop(this.#write());
52
53
  },
53
54
  write: (count) => {
54
55
  const key = isMedia ? "netstat_media_write" : "netstat_messages_write";
55
56
  this.#pendingWrites[key] = (this.#pendingWrites[key] ?? 0) + count;
56
- this.#write();
57
+ drop(this.#write());
57
58
  },
58
59
  };
59
60
  }
@@ -1 +1 @@
1
- {"version":3,"file":"2_update_manager.d.ts","sourceRoot":"","sources":["../../src/client/2_update_manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAAiC,KAAK,EAAmB,MAAM,mBAAmB,CAAC;AAC1F,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEjC,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,cAAc,CAAC;AAEtC,KAAK,aAAa,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,KAAK,OAAO,CAAC,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAE/E,MAAM,MAAM,SAAS,GACjB,GAAG,CAAC,gBAAgB,GACpB,GAAG,CAAC,oBAAoB,GACxB,GAAG,CAAC,sBAAsB,GAC1B,GAAG,CAAC,uBAAuB,GAC3B,GAAG,CAAC,2BAA2B,GAC/B,GAAG,CAAC,oBAAoB,GACxB,GAAG,CAAC,iBAAiB,GACrB,GAAG,CAAC,oBAAoB,GACxB,GAAG,CAAC,iBAAiB,GACrB,GAAG,CAAC,0BAA0B,GAC9B,GAAG,CAAC,aAAa,CAAC;AAEtB,MAAM,MAAM,gBAAgB,GACxB,GAAG,CAAC,uBAAuB,GAC3B,GAAG,CAAC,wBAAwB,GAC5B,GAAG,CAAC,2BAA2B,GAC/B,GAAG,CAAC,oBAAoB,CAAC;AAE7B,MAAM,MAAM,SAAS,GACjB,GAAG,CAAC,yBAAyB,GAC7B,GAAG,CAAC,qBAAqB,GACzB,GAAG,CAAC,gBAAg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AAoB,CAAC,KAAK,EAAE,MAAM;IA6JlC,cAAc,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,GAAE,GAAG,CAAC,SAAS,GAAG,IAAW,EAAE,QAAQ,CAAC,EAAE,MAAM,IAAI;IAsMvH,gBAAgB,CAAC,MAAM,EAAE,MAAM;IAsVrC,gBAAgB,CAAC,OAAO,EAAE,aAAa;IAKjC,QAAQ,CAAC,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,cAAc;IA4C5C,SAAS,CAAC,MAAM,EAAE,EAAE;IAW1B,aAAa;CAMd"}
@@ -624,7 +624,12 @@ export class UpdateManager {
624
624
  continue;
625
625
  }
626
626
  else {
627
- throw err;
627
+ if (this.#c.isDisconnected()) {
628
+ return;
629
+ }
630
+ else {
631
+ throw err;
632
+ }
628
633
  }
629
634
  }
630
635
  if (Api.is("updates.difference", difference) || Api.is("updates.differenceSlice", difference)) {
@@ -80,6 +80,8 @@ export interface ClientParams extends ClientPlainParams {
80
80
  authString?: string;
81
81
  /** The first DC to connect to. This is commonly used to decide whether to connect to test or production servers. It is not necessarily the DC that the client will directly connect to or is currently connected to. Defaults to the default initial DC. */
82
82
  initialDc?: DC;
83
+ /** Whether perfect forward secrecy should be enabled. Defaults to `false`. */
84
+ isPerfectForwardSecrecyEnabled?: boolean;
83
85
  }
84
86
  /** An MTKruto client. */
85
87
  export declare class Client<C extends Context = Context> extends Composer<C> implements ClientGeneric {