mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
mobile: deprecation.
This commit is contained in:
@@ -8,9 +8,6 @@ import {
|
||||
DEF_TAG_PREFIX,
|
||||
INITIAL_PREKEY_COUNT,
|
||||
MIN_PREKEY_COUNT,
|
||||
MOBILE_ENDPOINT,
|
||||
MOBILE_NOISE_HEADER,
|
||||
MOBILE_PORT,
|
||||
NOISE_WA_HEADER
|
||||
} from '../Defaults'
|
||||
import { DisconnectReason, SocketConfig } from '../Types'
|
||||
@@ -24,7 +21,6 @@ import {
|
||||
derivePairingCodeKey,
|
||||
generateLoginNode,
|
||||
generateMdTagPrefix,
|
||||
generateMobileNode,
|
||||
generateRegistrationNode,
|
||||
getCodeFromWSError,
|
||||
getErrorCodeFromStreamError,
|
||||
@@ -45,7 +41,7 @@ import {
|
||||
jidEncode,
|
||||
S_WHATSAPP_NET
|
||||
} from '../WABinary'
|
||||
import { MobileSocketClient, WebSocketClient } from './Client'
|
||||
import { WebSocketClient } from './Client'
|
||||
|
||||
/**
|
||||
* Connects to WA servers and performs:
|
||||
@@ -69,19 +65,18 @@ export const makeSocket = (config: SocketConfig) => {
|
||||
makeSignalRepository,
|
||||
} = config
|
||||
|
||||
let url = typeof waWebSocketUrl === 'string' ? new URL(waWebSocketUrl) : waWebSocketUrl
|
||||
const url = typeof waWebSocketUrl === 'string' ? new URL(waWebSocketUrl) : waWebSocketUrl
|
||||
|
||||
config.mobile = config.mobile || url.protocol === 'tcp:'
|
||||
|
||||
if(config.mobile && url.protocol !== 'tcp:') {
|
||||
url = new URL(`tcp://${MOBILE_ENDPOINT}:${MOBILE_PORT}`)
|
||||
if(config.mobile || url.protocol === 'tcp:') {
|
||||
throw new Boom('Mobile API is not supported anymore', { statusCode: DisconnectReason.loggedOut })
|
||||
}
|
||||
|
||||
if(!config.mobile && url.protocol === 'wss' && authState?.creds?.routingInfo) {
|
||||
if(url.protocol === 'wss' && authState?.creds?.routingInfo) {
|
||||
url.searchParams.append('ED', authState.creds.routingInfo.toString('base64url'))
|
||||
}
|
||||
|
||||
const ws = config.socket ? config.socket : config.mobile ? new MobileSocketClient(url, config) : new WebSocketClient(url, config)
|
||||
const ws = config.socket ? config.socket : new WebSocketClient(url, config)
|
||||
|
||||
ws.connect()
|
||||
|
||||
@@ -91,8 +86,7 @@ export const makeSocket = (config: SocketConfig) => {
|
||||
/** WA noise protocol wrapper */
|
||||
const noise = makeNoiseHandler({
|
||||
keyPair: ephemeralKeyPair,
|
||||
NOISE_HEADER: config.mobile ? MOBILE_NOISE_HEADER : NOISE_WA_HEADER,
|
||||
mobile: config.mobile,
|
||||
NOISE_HEADER: NOISE_WA_HEADER,
|
||||
logger,
|
||||
routingInfo: authState?.creds?.routingInfo
|
||||
})
|
||||
@@ -247,9 +241,7 @@ export const makeSocket = (config: SocketConfig) => {
|
||||
const keyEnc = noise.processHandshake(handshake, creds.noiseKey)
|
||||
|
||||
let node: proto.IClientPayload
|
||||
if(config.mobile) {
|
||||
node = generateMobileNode(config)
|
||||
} else if(!creds.me) {
|
||||
if(!creds.me) {
|
||||
node = generateRegistrationNode(creds, config)
|
||||
logger.info({ node }, 'not logged in, attempting registration...')
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user