mobile: deprecation.

This commit is contained in:
Rajeh Taher
2024-10-14 03:39:46 +03:00
parent 647f8d767f
commit 61a0ff3178
18 changed files with 47 additions and 533 deletions

View File

@@ -9,30 +9,20 @@ import { encodeBigEndian } from './generics'
import { createSignalIdentity } from './signal'
const getUserAgent = (config: SocketConfig): proto.ClientPayload.IUserAgent => {
const osVersion = config.mobile ? '15.3.1' : '0.1'
const version = config.mobile ? [2, 24, 6] : config.version
const device = config.mobile ? 'iPhone_7' : 'Desktop'
const manufacturer = config.mobile ? 'Apple' : ''
const platform = config.mobile ? proto.ClientPayload.UserAgent.Platform.IOS : proto.ClientPayload.UserAgent.Platform.WEB
const phoneId = config.mobile ? { phoneId: config.auth.creds.phoneId } : {}
return {
appVersion: {
primary: version[0],
secondary: version[1],
tertiary: version[2],
primary: config.version[0],
secondary: config.version[1],
tertiary: config.version[2],
},
platform,
platform: proto.ClientPayload.UserAgent.Platform.WEB,
releaseChannel: proto.ClientPayload.UserAgent.ReleaseChannel.RELEASE,
mcc: config.auth.creds.registration?.phoneNumberMobileCountryCode || '000',
mnc: config.auth.creds.registration?.phoneNumberMobileNetworkCode || '000',
osVersion: osVersion,
manufacturer,
device,
osBuildNumber: osVersion,
osVersion: '0.1',
device: 'Desktop',
osBuildNumber: '0.1',
localeLanguageIso6391: 'en',
localeCountryIso31661Alpha2: 'US',
...phoneId
localeCountryIso31661Alpha2: 'US'
}
}
@@ -58,34 +48,11 @@ const getClientPayload = (config: SocketConfig) => {
userAgent: getUserAgent(config),
}
if(!config.mobile) {
payload.webInfo = getWebInfo(config)
}
payload.webInfo = getWebInfo(config)
return payload
}
export const generateMobileNode = (config: SocketConfig): proto.IClientPayload => {
if(!config.auth.creds) {
throw new Boom('No registration data found', { data: config })
}
const payload: proto.IClientPayload = {
...getClientPayload(config),
sessionId: Math.floor(Math.random() * 999999999 + 1),
shortConnect: true,
connectAttemptCount: 0,
device: 0,
dnsSource: {
appCached: false,
dnsMethod: proto.ClientPayload.DNSSource.DNSResolutionMethod.SYSTEM,
},
passive: false, // XMPP heartbeat setting (false: server actively pings) (true: client actively pings)
pushName: 'test',
username: Number(`${config.auth.creds.registration.phoneNumberCountryCode}${config.auth.creds.registration.phoneNumberNationalNumber}`),
}
return proto.ClientPayload.fromObject(payload)
}
export const generateLoginNode = (userJid: string, config: SocketConfig): proto.IClientPayload => {
const { user, device } = jidDecode(userJid)!