Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 35 additions & 34 deletions src/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const {
WAState,
MessageTypes,
} = require('./util/Constants');
const { ExposeAuthStore } = require('./util/Injected/AuthStore/AuthStore');
const { LoadUtils } = require('./util/Injected/Utils');
const ChatFactory = require('./factories/ChatFactory');
const ContactFactory = require('./factories/ContactFactory');
Expand Down Expand Up @@ -140,8 +139,6 @@ class Client extends EventEmitter {
const pairWithPhoneNumber = this.options.pairWithPhoneNumber;
const version = await this.getWWebVersion();

await this.pupPage.evaluate(ExposeAuthStore);

const needAuthentication = await this.pupPage.evaluate(async () => {
let state = window.require('WAWebSocketModel').Socket.state;

Expand Down Expand Up @@ -244,19 +241,21 @@ class Client extends EventEmitter {
);

await this.pupPage.evaluate(async () => {
const registrationInfo =
await window.AuthStore.RegistrationUtils.waSignalStore.getRegistrationInfo();
const noiseKeyPair =
await window.AuthStore.RegistrationUtils.waNoiseInfo.get();
const staticKeyB64 = window.AuthStore.Base64Tools.encodeB64(
noiseKeyPair.staticKeyPair.pubKey,
);
const identityKeyB64 =
window.AuthStore.Base64Tools.encodeB64(
registrationInfo.identityKeyPair.pubKey,
);
const platform =
window.AuthStore.RegistrationUtils.DEVICE_PLATFORM;
const registrationInfo = await window
.require('WAWebSignalStoreApi')
.waSignalStore.getRegistrationInfo();
const noiseKeyPair = await window
.require('WAWebUserPrefsInfoStore')
.waNoiseInfo.get();
const staticKeyB64 = window
.require('WABase64')
.encodeB64(noiseKeyPair.staticKeyPair.pubKey);
const identityKeyB64 = window
.require('WABase64')
.encodeB64(registrationInfo.identityKeyPair.pubKey);
const platform = window.require(
'WAWebCompanionRegClientUtils',
).DEVICE_PLATFORM;
const getQR = (ref) =>
ref +
',' +
Expand All @@ -269,10 +268,14 @@ class Client extends EventEmitter {
.getADVSecretKey() +
',' +
platform;
window.onQRChangedEvent(getQR(window.AuthStore.Conn.ref)); // initial qr
window.AuthStore.Conn.on('change:ref', (_, ref) => {
window.onQRChangedEvent(getQR(ref));
}); // future QR changes
window.onQRChangedEvent(
getQR(window.require('WAWebConnModel').Conn.ref),
); // initial qr
window
.require('WAWebConnModel')
.Conn.on('change:ref', (_, ref) => {
window.onQRChangedEvent(getQR(ref));
}); // future QR changes
});
}
}
Expand Down Expand Up @@ -410,7 +413,9 @@ class Client extends EventEmitter {
const Cmd = window.require('WAWebCmd').Cmd;
Cmd.on('offline_progress_update_from_bridge', () => {
window.onOfflineProgressUpdateEvent(
window.AuthStore.OfflineMessageHandler.getOfflineDeliveryProgress(),
window
.require('WAWebOfflineHandler')
.OfflineMessageHandler.getOfflineDeliveryProgress(),
);
});
Cmd.on('logout', async () => {
Expand Down Expand Up @@ -526,19 +531,15 @@ class Client extends EventEmitter {
return await this.pupPage.evaluate(
async (phoneNumber, showNotification, intervalMs) => {
const getCode = async () => {
while (!window.AuthStore.PairingCodeLinkUtils) {
await new Promise((resolve) =>
setTimeout(resolve, 250),
);
}
window.AuthStore.PairingCodeLinkUtils.setPairingType(
'ALT_DEVICE_LINKING',
);
await window.AuthStore.PairingCodeLinkUtils.initializeAltDeviceLinking();
return window.AuthStore.PairingCodeLinkUtils.startAltLinkingFlow(
phoneNumber,
showNotification,
);
window
.require('WAWebAltDeviceLinkingApi')
.setPairingType('ALT_DEVICE_LINKING');
await window
.require('WAWebAltDeviceLinkingApi')
.initializeAltDeviceLinking();
return window
.require('WAWebAltDeviceLinkingApi')
.startAltLinkingFlow(phoneNumber, showNotification);
};
if (window.codeInterval) {
clearInterval(window.codeInterval); // remove existing interval
Expand Down
21 changes: 0 additions & 21 deletions src/util/Injected/AuthStore/AuthStore.js

This file was deleted.

Loading