Skip to content

Commit

Permalink
fix: Fixed isOfficialClient check (#1769)
Browse files Browse the repository at this point in the history
  • Loading branch information
icleitoncosta authored Mar 25, 2024
1 parent 5b4827f commit 88f1f0e
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/chat/functions/prepareMessageButtons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ webpack.onFullReady(() => {
let buttonNode: websocket.WapNode | null = null;

/**
* In version 2.2411.x the order of the proto arguments was changed,
* In version 2.2411.x the order of the proto arguments was changed,
* before it was the third argument, now it is the second
*/
const proto = args[1].id ? args[2] : args[1];
Expand Down
1 change: 1 addition & 0 deletions src/conn/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

import './events';
import './patch';

export * from './functions';
export * from './types';
32 changes: 32 additions & 0 deletions src/conn/patch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*!
* Copyright 2024 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 * as webpack from '../webpack';
import { IsOfficialClient } from '../whatsapp';
import { wrapModuleFunction } from '../whatsapp/exportModule';

webpack.onInjected(() => {
/**
* When sending logs to the WhatsApp server, it will always report that the ocVersion is true.
*/
IsOfficialClient.isOfficialClient = true;
});

webpack.onFullReady(() => {
wrapModuleFunction(IsOfficialClient.isLegitErrorStack, () => {
return true;
});
}, 1000);
37 changes: 37 additions & 0 deletions src/whatsapp/misc/IsOfficialClient.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*!
* Copyright 2024 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 * as webpack from '../../webpack';
import { exportModule } from '../exportModule';

/**
* @whatsapp >= 2.3000.x
*/
export declare namespace IsOfficialClient {
function isLegitErrorStack(): boolean;
let isOfficialClient: boolean;
}

exportModule(
exports,
'IsOfficialClient',
(m) => m.isOfficialClient && m.isLegitErrorStack
);

webpack.injectFallbackModule('IsOfficialClient', {
isOfficialClient: true,
isLegitErrorStack: () => true,
});
1 change: 1 addition & 0 deletions src/whatsapp/misc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export * from './Conn';
export * from './Constants';
export * from './EventEmitter';
export * from './ImageUtils';
export * from './IsOfficialClient';
export * from './MediaBlobCache';
export * from './MediaEntry';
export * from './MediaObject';
Expand Down

0 comments on commit 88f1f0e

Please sign in to comment.