Skip to content

Commit

Permalink
Merge branch 'main' into webpack-exodus
Browse files Browse the repository at this point in the history
  • Loading branch information
MobCode100 committed Jan 10, 2025
2 parents cbc9d59 + 2261b11 commit f9f4cea
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions src/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -799,23 +799,25 @@ class Client extends EventEmitter {
});
} else {
this.pupPage.on('response', async (res) => {
const textContent = await res.text();
// Get pairing code expiration time in seconds
if(this.pairingCodeTTL == null && this.options.pairWithPhoneNumber.phoneNumber){
const index = textContent.indexOf('("WAWebAltDeviceLinkingApi",[');
if(index > -1){
const execRegex = (reg) => {
reg.lastIndex = index;
return reg.exec(textContent);
if(res.ok()){
const textContent = await res.text();
// Get pairing code expiration time in seconds
if(this.pairingCodeTTL == null && this.options.pairWithPhoneNumber.phoneNumber){
const index = textContent.indexOf('("WAWebAltDeviceLinkingApi",[');
if(index > -1){
const execRegex = (reg) => {
reg.lastIndex = index;
return reg.exec(textContent);
}
const captureVarName = execRegex(/.codeGenerationTs>(.+?)\)/g);
// Find last occurrence of the variable definition
const captureValue = execRegex(new RegExp(`${captureVarName[1]}=(\\d+)(?!.*${captureVarName[1]}=.+?codeGenerationTs>)`,"g"));
this.pairingCodeTTL = Number(captureValue[1]);
}
const captureVarName = execRegex(/.codeGenerationTs>(.+?)\)/g);
// Find last occurrence of the variable definition
const captureValue = execRegex(new RegExp(`${captureVarName[1]}=(\\d+)(?!.*${captureVarName[1]}=.+?codeGenerationTs>)`,"g"));
this.pairingCodeTTL = Number(captureValue[1]);
}
}
if(res.ok() && res.url() === WhatsWebURL) {
this.currentIndexHtml = textContent;
if(res.url() === WhatsWebURL) {
this.currentIndexHtml = textContent;
}
}
});
}
Expand Down

0 comments on commit f9f4cea

Please sign in to comment.