Przeglądaj źródła

Remove unneeded session check

painor 4 lat temu
rodzic
commit
5e882bef9b

+ 1 - 1
gramjs/client/auth.ts

@@ -10,7 +10,7 @@ export interface UserAuthParams {
     password: (hint?: string) => Promise<string>;
     firstAndLastNames?: () => Promise<[string, string?]>;
     qrCode?: (qrCode: { token: Buffer; expires: number }) => Promise<void>;
-    onError: (err: Error) => Promise<boolean>;
+    onError: (err: Error) => Promise<boolean> | void;
     forceSMS?: boolean;
 }
 

+ 6 - 10
gramjs/client/telegramBaseClient.ts

@@ -2,11 +2,10 @@ import { version } from "../";
 import { IS_NODE } from "../Helpers";
 import {
     ConnectionTCPFull,
-    ConnectionTCPObfuscated,
+    ConnectionTCPObfuscated
 } from "../network/connection";
-import type { Session } from "../sessions/Abstract";
+import { Session } from "../sessions";
 import { Logger } from "../extensions";
-import { StoreSession, StringSession } from "../sessions";
 import { Api } from "../tl";
 
 import os from "os";
@@ -90,7 +89,7 @@ export class TelegramBaseClient {
             baseLogger = "gramjs",
             useWSS = typeof window !== "undefined"
                 ? window.location.protocol == "https:"
-                : false,
+                : false
         }: TelegramClientParams
     ) {
         if (!apiId || !apiHash) {
@@ -102,10 +101,7 @@ export class TelegramBaseClient {
             this._log = baseLogger;
         }
         this._log.debug("Running gramJS version " + version);
-        if (
-            !(session instanceof StoreSession) &&
-            !(session instanceof StringSession)
-        ) {
+        if (!(session instanceof Session)) {
             throw new Error(
                 "Only StringSession and StoreSessions are supported currently :( "
             );
@@ -133,7 +129,7 @@ export class TelegramBaseClient {
             langCode: langCode,
             langPack: "", // this should be left empty.
             systemLangCode: systemLangCode,
-            proxy: undefined, // no proxies yet.
+            proxy: undefined // no proxies yet.
         });
         this._eventBuilders = [];
 
@@ -191,7 +187,7 @@ export class TelegramBaseClient {
                 (promise: any) => {
                     return promise.then((sender: any) => sender.disconnect());
                 }
-            ),
+            )
         ]);
 
         this._eventBuilders = [];

+ 1 - 0
gramjs/sessions/index.ts

@@ -1,5 +1,6 @@
 export { MemorySession } from "./Memory";
 export { StringSession } from "./StringSession";
 export { StoreSession } from "./StoreSession";
+export { Session } from "./Abstract";
 // @ts-ignore
 //export {CacheApiSession} from './CacheApiSession';

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "telegram",
-  "version": "1.6.11",
+  "version": "1.6.12",
   "description": "NodeJS MTProto API Telegram client library,",
   "main": "index.js",
   "types": "index.d.ts",