From 018ab61161ae6265d85b5f4a29afcad58571423f Mon Sep 17 00:00:00 2001 From: Edgard Date: Mon, 7 Nov 2022 21:45:43 -0300 Subject: [PATCH] fix: Fixed compatibility with WhatsApp >= 2.2243.5 --- src/conn/functions/getAuthCode.ts | 20 ++-------- .../collections/GroupMetadataCollection.ts | 2 +- .../collections/StarredStickerCollection.ts | 37 ------------------- src/whatsapp/collections/index.ts | 1 - src/whatsapp/functions/getOrGenerate.ts | 32 ---------------- src/whatsapp/functions/index.ts | 1 - src/whatsapp/stores.ts | 3 -- 7 files changed, 5 insertions(+), 91 deletions(-) delete mode 100644 src/whatsapp/collections/StarredStickerCollection.ts delete mode 100644 src/whatsapp/functions/getOrGenerate.ts diff --git a/src/conn/functions/getAuthCode.ts b/src/conn/functions/getAuthCode.ts index 24d7e144e5..fc394495e3 100644 --- a/src/conn/functions/getAuthCode.ts +++ b/src/conn/functions/getAuthCode.ts @@ -14,11 +14,10 @@ * limitations under the License. */ -import { Base64, Browser, Conn } from '../../whatsapp'; -import { getOrGenerate } from '../../whatsapp/functions'; +import { Base64, Conn } from '../../whatsapp'; import { adv, waNoiseInfo, waSignalStore } from '../../whatsapp/multidevice'; import { AuthCode } from '..'; -import { isAuthenticated, isMultiDevice } from '.'; +import { isAuthenticated, isMultiDevice, isRegistered } from '.'; /** * Return the current auth code @@ -26,7 +25,7 @@ import { isAuthenticated, isMultiDevice } from '.'; * @return {Promise}[return description] */ export async function getAuthCode(): Promise { - if (!Conn.ref || Conn.connected || isAuthenticated()) { + if (!Conn.ref || Conn.connected || isAuthenticated() || isRegistered()) { return null; } @@ -54,16 +53,5 @@ export async function getAuthCode(): Promise { }; } - const keyPair = getOrGenerate(); - const browserId = Browser.id(); - - const fullCode = [ref, keyPair, browserId].join(','); - - return { - type: 'single', - ref, - keyPair, - browserId, - fullCode, - }; + return null; } diff --git a/src/whatsapp/collections/GroupMetadataCollection.ts b/src/whatsapp/collections/GroupMetadataCollection.ts index 08c622107c..79115f004e 100644 --- a/src/whatsapp/collections/GroupMetadataCollection.ts +++ b/src/whatsapp/collections/GroupMetadataCollection.ts @@ -28,5 +28,5 @@ export declare class GroupMetadataCollection extends BaseCollection typeof m.default.handlePendingInvite === 'function' + (m) => typeof m.default.onParentGroupChange === 'function' ); diff --git a/src/whatsapp/collections/StarredStickerCollection.ts b/src/whatsapp/collections/StarredStickerCollection.ts deleted file mode 100644 index 6b3ceb6a4c..0000000000 --- a/src/whatsapp/collections/StarredStickerCollection.ts +++ /dev/null @@ -1,37 +0,0 @@ -/*! - * Copyright 2021 WPPConnect Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { exportModule } from '../exportModule'; -import { StickerModel } from '../models'; -import { Collection } from './Collection'; - -/** @whatsapp 16774 */ -export declare class StarredStickerCollection extends Collection { - static model: StickerModel; - syncNextPage(): any; - sync(e?: any): any; - isSynced(): boolean; - canLoadMore(): boolean; - getRemaining(): any; - static comparator(): any; -} -exportModule( - exports, - { - StarredStickerCollection: 'StarredStickerCollectionImpl', - }, - (m) => m.StarredStickerCollectionImpl -); diff --git a/src/whatsapp/collections/index.ts b/src/whatsapp/collections/index.ts index 20a5b9bba8..cf07aa0c44 100644 --- a/src/whatsapp/collections/index.ts +++ b/src/whatsapp/collections/index.ts @@ -54,7 +54,6 @@ export * from './ReactionsSendersCollection'; export * from './RecentEmojiCollection'; export * from './RecentStickerCollection'; export * from './StarredMsgCollection'; -export * from './StarredStickerCollection'; export * from './StatusCollection'; export * from './StatusV3Collection'; export * from './StickerCollection'; diff --git a/src/whatsapp/functions/getOrGenerate.ts b/src/whatsapp/functions/getOrGenerate.ts deleted file mode 100644 index 92249fb6a9..0000000000 --- a/src/whatsapp/functions/getOrGenerate.ts +++ /dev/null @@ -1,32 +0,0 @@ -/*! - * Copyright 2021 WPPConnect Team - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { exportModule } from '../exportModule'; - -/** @whatsapp 98250 - * @whatsapp 16413 >= 2.2204.13 - * @whatsapp 66333 >= 2.2218.4 - * @whatsapp 266333 >= 2.2222.8 - */ -export declare function getOrGenerate(): string; - -exportModule( - exports, - { - getOrGenerate: 'getOrGenerate', - }, - (m) => m.getOrGenerate -); diff --git a/src/whatsapp/functions/index.ts b/src/whatsapp/functions/index.ts index 10bce9d620..be4c6e7585 100644 --- a/src/whatsapp/functions/index.ts +++ b/src/whatsapp/functions/index.ts @@ -32,7 +32,6 @@ export * from './generateVideoThumbsAndDuration'; export * from './genMinimalLinkPreview'; export * from './getFanOutList'; export * from './getGroupSenderKeyList'; -export * from './getOrGenerate'; export * from './getSearchContext'; export * from './groupParticipants'; export * from './handleAck'; diff --git a/src/whatsapp/stores.ts b/src/whatsapp/stores.ts index 924411ac6c..7d41576cae 100644 --- a/src/whatsapp/stores.ts +++ b/src/whatsapp/stores.ts @@ -110,8 +110,6 @@ export declare const RecentStickerStore: collections.RecentStickerCollection; * @whatsapp 719011 >= 2.2222.8 */ export declare const StarredMsgStore: collections.StarredMsgCollection; -/** @whatsapp 16774 */ -export declare const StarredStickerStore: collections.StarredStickerCollection; /** @whatsapp 46133 */ export declare const StatusStore: collections.StatusCollection; /** @whatsapp 59387 @@ -154,7 +152,6 @@ const storeNames = [ 'QuickReplyStore', 'ReactionsStore', 'RecentEmojiStore', - 'StarredStickerStore', 'StatusStore', 'StatusV3Store', 'StickerStore',