@@ -12,7 +12,6 @@ const {
1212 WAState,
1313 MessageTypes,
1414} = require ( './util/Constants' ) ;
15- const { ExposeAuthStore } = require ( './util/Injected/AuthStore/AuthStore' ) ;
1615const { LoadUtils } = require ( './util/Injected/Utils' ) ;
1716const ChatFactory = require ( './factories/ChatFactory' ) ;
1817const ContactFactory = require ( './factories/ContactFactory' ) ;
@@ -141,8 +140,6 @@ class Client extends EventEmitter {
141140 const pairWithPhoneNumber = this . options . pairWithPhoneNumber ;
142141 const version = await this . getWWebVersion ( ) ;
143142
144- await this . pupPage . evaluate ( ExposeAuthStore ) ;
145-
146143 const needAuthentication = await this . pupPage . evaluate ( async ( ) => {
147144 let state = window . require ( 'WAWebSocketModel' ) . Socket . state ;
148145
@@ -245,19 +242,21 @@ class Client extends EventEmitter {
245242 ) ;
246243
247244 await this . pupPage . evaluate ( async ( ) => {
248- const registrationInfo =
249- await window . AuthStore . RegistrationUtils . waSignalStore . getRegistrationInfo ( ) ;
250- const noiseKeyPair =
251- await window . AuthStore . RegistrationUtils . waNoiseInfo . get ( ) ;
252- const staticKeyB64 = window . AuthStore . Base64Tools . encodeB64 (
253- noiseKeyPair . staticKeyPair . pubKey ,
254- ) ;
255- const identityKeyB64 =
256- window . AuthStore . Base64Tools . encodeB64 (
257- registrationInfo . identityKeyPair . pubKey ,
258- ) ;
259- const platform =
260- window . AuthStore . RegistrationUtils . DEVICE_PLATFORM ;
245+ const registrationInfo = await window
246+ . require ( 'WAWebSignalStoreApi' )
247+ . waSignalStore . getRegistrationInfo ( ) ;
248+ const noiseKeyPair = await window
249+ . require ( 'WAWebUserPrefsInfoStore' )
250+ . waNoiseInfo . get ( ) ;
251+ const staticKeyB64 = window
252+ . require ( 'WABase64' )
253+ . encodeB64 ( noiseKeyPair . staticKeyPair . pubKey ) ;
254+ const identityKeyB64 = window
255+ . require ( 'WABase64' )
256+ . encodeB64 ( registrationInfo . identityKeyPair . pubKey ) ;
257+ const platform = window . require (
258+ 'WAWebCompanionRegClientUtils' ,
259+ ) . DEVICE_PLATFORM ;
261260 const getQR = ( ref ) =>
262261 ref +
263262 ',' +
@@ -270,10 +269,14 @@ class Client extends EventEmitter {
270269 . getADVSecretKey ( ) +
271270 ',' +
272271 platform ;
273- window . onQRChangedEvent ( getQR ( window . AuthStore . Conn . ref ) ) ; // initial qr
274- window . AuthStore . Conn . on ( 'change:ref' , ( _ , ref ) => {
275- window . onQRChangedEvent ( getQR ( ref ) ) ;
276- } ) ; // future QR changes
272+ window . onQRChangedEvent (
273+ getQR ( window . require ( 'WAWebConnModel' ) . Conn . ref ) ,
274+ ) ; // initial qr
275+ window
276+ . require ( 'WAWebConnModel' )
277+ . Conn . on ( 'change:ref' , ( _ , ref ) => {
278+ window . onQRChangedEvent ( getQR ( ref ) ) ;
279+ } ) ; // future QR changes
277280 } ) ;
278281 }
279282 }
@@ -411,7 +414,9 @@ class Client extends EventEmitter {
411414 const Cmd = window . require ( 'WAWebCmd' ) . Cmd ;
412415 Cmd . on ( 'offline_progress_update_from_bridge' , ( ) => {
413416 window . onOfflineProgressUpdateEvent (
414- window . AuthStore . OfflineMessageHandler . getOfflineDeliveryProgress ( ) ,
417+ window
418+ . require ( 'WAWebOfflineHandler' )
419+ . OfflineMessageHandler . getOfflineDeliveryProgress ( ) ,
415420 ) ;
416421 } ) ;
417422 Cmd . on ( 'logout' , async ( ) => {
@@ -527,19 +532,15 @@ class Client extends EventEmitter {
527532 return await this . pupPage . evaluate (
528533 async ( phoneNumber , showNotification , intervalMs ) => {
529534 const getCode = async ( ) => {
530- while ( ! window . AuthStore . PairingCodeLinkUtils ) {
531- await new Promise ( ( resolve ) =>
532- setTimeout ( resolve , 250 ) ,
533- ) ;
534- }
535- window . AuthStore . PairingCodeLinkUtils . setPairingType (
536- 'ALT_DEVICE_LINKING' ,
537- ) ;
538- await window . AuthStore . PairingCodeLinkUtils . initializeAltDeviceLinking ( ) ;
539- return window . AuthStore . PairingCodeLinkUtils . startAltLinkingFlow (
540- phoneNumber ,
541- showNotification ,
542- ) ;
535+ window
536+ . require ( 'WAWebAltDeviceLinkingApi' )
537+ . setPairingType ( 'ALT_DEVICE_LINKING' ) ;
538+ await window
539+ . require ( 'WAWebAltDeviceLinkingApi' )
540+ . initializeAltDeviceLinking ( ) ;
541+ return window
542+ . require ( 'WAWebAltDeviceLinkingApi' )
543+ . startAltLinkingFlow ( phoneNumber , showNotification ) ;
543544 } ;
544545 if ( window . codeInterval ) {
545546 clearInterval ( window . codeInterval ) ; // remove existing interval
0 commit comments