Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ef365246ea | |||
| ad5ea817f7 | |||
| 3841abca35 |
@@ -1 +1 @@
|
|||||||
{"version":[2,3000,1033105955]}
|
{"version":[2,3000,1033846690]}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import type { AuthenticationState, SocketConfig, WAVersion } from '../Types'
|
|||||||
import { Browsers } from '../Utils/browser-utils'
|
import { Browsers } from '../Utils/browser-utils'
|
||||||
import logger from '../Utils/logger'
|
import logger from '../Utils/logger'
|
||||||
|
|
||||||
const version = [2, 3000, 1033105955]
|
const version = [2, 3000, 1033846690]
|
||||||
|
|
||||||
export const UNAUTHORIZED_CODES = [401, 403, 419]
|
export const UNAUTHORIZED_CODES = [401, 403, 419]
|
||||||
|
|
||||||
|
|||||||
+12
-3
@@ -36,7 +36,7 @@ import {
|
|||||||
signedKeyPair,
|
signedKeyPair,
|
||||||
xmppSignedPreKey
|
xmppSignedPreKey
|
||||||
} from '../Utils'
|
} from '../Utils'
|
||||||
import { getPlatformId } from '../Utils/browser-utils'
|
import { getPlatformId, isAndroidBrowser } from '../Utils/browser-utils'
|
||||||
import {
|
import {
|
||||||
assertNodeErrorFree,
|
assertNodeErrorFree,
|
||||||
type BinaryNode,
|
type BinaryNode,
|
||||||
@@ -758,6 +758,15 @@ export const makeSocket = (config: SocketConfig) => {
|
|||||||
id: jidEncode(phoneNumber, 's.whatsapp.net'),
|
id: jidEncode(phoneNumber, 's.whatsapp.net'),
|
||||||
name: '~'
|
name: '~'
|
||||||
}
|
}
|
||||||
|
// Pair code companion_platform_id must be Chrome (1) when using Android
|
||||||
|
// browser preset. ANDROID_PHONE (16) causes silent timeout, UWP (21)
|
||||||
|
// causes rejection. Only Chrome (1) works for pair code via web protocol.
|
||||||
|
// The device still appears as "Android" in linked devices because
|
||||||
|
// DeviceProps.platformType=ANDROID_PHONE is set in the registration node.
|
||||||
|
const isAndroid = isAndroidBrowser(browser)
|
||||||
|
const pairPlatformId = isAndroid ? getPlatformId('Chrome') : getPlatformId(browser[1])
|
||||||
|
const pairPlatformDisplay = isAndroid ? 'Chrome (Mac OS)' : `${browser[1]} (${browser[0]})`
|
||||||
|
|
||||||
ev.emit('creds.update', authState.creds)
|
ev.emit('creds.update', authState.creds)
|
||||||
await sendNode({
|
await sendNode({
|
||||||
tag: 'iq',
|
tag: 'iq',
|
||||||
@@ -790,12 +799,12 @@ export const makeSocket = (config: SocketConfig) => {
|
|||||||
{
|
{
|
||||||
tag: 'companion_platform_id',
|
tag: 'companion_platform_id',
|
||||||
attrs: {},
|
attrs: {},
|
||||||
content: getPlatformId(browser[1])
|
content: pairPlatformId
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
tag: 'companion_platform_display',
|
tag: 'companion_platform_display',
|
||||||
attrs: {},
|
attrs: {},
|
||||||
content: `${browser[1]} (${browser[0]})`
|
content: pairPlatformDisplay
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
tag: 'link_code_pairing_nonce',
|
tag: 'link_code_pairing_nonce',
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ export type BrowsersMap = {
|
|||||||
baileys(browser: string): [string, string, string]
|
baileys(browser: string): [string, string, string]
|
||||||
windows(browser: string): [string, string, string]
|
windows(browser: string): [string, string, string]
|
||||||
appropriate(browser: string): [string, string, string]
|
appropriate(browser: string): [string, string, string]
|
||||||
|
android(apiLevel: string): [string, string, string]
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum DisconnectReason {
|
export enum DisconnectReason {
|
||||||
|
|||||||
@@ -22,10 +22,33 @@ export const Browsers: BrowsersMap = {
|
|||||||
baileys: browser => ['Baileys', browser, '6.5.0'],
|
baileys: browser => ['Baileys', browser, '6.5.0'],
|
||||||
windows: browser => ['Windows', browser, '10.0.22631'],
|
windows: browser => ['Windows', browser, '10.0.22631'],
|
||||||
/** The appropriate browser based on your OS & release */
|
/** The appropriate browser based on your OS & release */
|
||||||
appropriate: browser => [PLATFORM_MAP[platform()] || 'Ubuntu', browser, release()]
|
appropriate: browser => [PLATFORM_MAP[platform()] || 'Ubuntu', browser, release()],
|
||||||
|
/** Android companion device. apiLevel is the Android API level (e.g. '14') */
|
||||||
|
android: (apiLevel: string) => [apiLevel, 'Android', '']
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the browser tuple represents an Android companion device.
|
||||||
|
* @param browser - Browser tuple [os, platform, version]
|
||||||
|
* @returns True if platform is 'Android' (case-insensitive)
|
||||||
|
*/
|
||||||
|
export const isAndroidBrowser = (browser: [string, string, string]): boolean => {
|
||||||
|
return browser[1]?.toUpperCase() === 'ANDROID'
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getPlatformId = (browser: string) => {
|
export const getPlatformId = (browser: string) => {
|
||||||
const platformType = proto.DeviceProps.PlatformType[browser.toUpperCase() as any]
|
const platformType = proto.DeviceProps.PlatformType[browser.toUpperCase() as any]
|
||||||
return platformType ? platformType.toString() : '1' //chrome
|
if (platformType !== undefined) {
|
||||||
|
return platformType.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 'ANDROID' is not in the PlatformType enum — map to ANDROID_PHONE
|
||||||
|
if (browser.toUpperCase() === 'ANDROID') {
|
||||||
|
const androidPhone = proto.DeviceProps.PlatformType['ANDROID_PHONE' as any]
|
||||||
|
if (androidPhone !== undefined) {
|
||||||
|
return androidPhone.toString()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return '1' // Chrome
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Boom } from '@hapi/boom'
|
import { Boom } from '@hapi/boom'
|
||||||
import { createHash, randomBytes } from 'crypto'
|
import { createHash, randomBytes } from 'crypto'
|
||||||
import { proto } from '../../WAProto/index.js'
|
import { proto } from '../../WAProto/index.js'
|
||||||
const baileysVersion = [2, 3000, 1033105955]
|
const baileysVersion = [2, 3000, 1033846690]
|
||||||
import type {
|
import type {
|
||||||
BaileysEventEmitter,
|
BaileysEventEmitter,
|
||||||
BaileysEventMap,
|
BaileysEventMap,
|
||||||
|
|||||||
@@ -14,13 +14,17 @@ import { encodeBigEndian } from './generics'
|
|||||||
import { createSignalIdentity } from './signal'
|
import { createSignalIdentity } from './signal'
|
||||||
|
|
||||||
const getUserAgent = (config: SocketConfig): proto.ClientPayload.IUserAgent => {
|
const getUserAgent = (config: SocketConfig): proto.ClientPayload.IUserAgent => {
|
||||||
|
// Always use MACOS platform for UserAgent — we connect via web protocol
|
||||||
|
// (WA\x06\x03) so the server expects a web-compatible identity.
|
||||||
|
// Using WEB causes 405 errors; using SMB_ANDROID breaks pair code.
|
||||||
|
// Android identity is only set in DeviceProps (registration node).
|
||||||
return {
|
return {
|
||||||
appVersion: {
|
appVersion: {
|
||||||
primary: config.version[0],
|
primary: config.version[0],
|
||||||
secondary: config.version[1],
|
secondary: config.version[1],
|
||||||
tertiary: config.version[2]
|
tertiary: config.version[2]
|
||||||
},
|
},
|
||||||
platform: proto.ClientPayload.UserAgent.Platform.WEB,
|
platform: proto.ClientPayload.UserAgent.Platform.MACOS,
|
||||||
releaseChannel: proto.ClientPayload.UserAgent.ReleaseChannel.RELEASE,
|
releaseChannel: proto.ClientPayload.UserAgent.ReleaseChannel.RELEASE,
|
||||||
osVersion: '0.1',
|
osVersion: '0.1',
|
||||||
device: 'Desktop',
|
device: 'Desktop',
|
||||||
@@ -79,6 +83,11 @@ export const generateLoginNode = (userJid: string, config: SocketConfig): proto.
|
|||||||
|
|
||||||
const getPlatformType = (platform: string): proto.DeviceProps.PlatformType => {
|
const getPlatformType = (platform: string): proto.DeviceProps.PlatformType => {
|
||||||
const platformType = platform.toUpperCase()
|
const platformType = platform.toUpperCase()
|
||||||
|
// 'ANDROID' is not in PlatformType enum — map to ANDROID_PHONE
|
||||||
|
if (platformType === 'ANDROID') {
|
||||||
|
return proto.DeviceProps.PlatformType.ANDROID_PHONE
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
proto.DeviceProps.PlatformType[platformType as keyof typeof proto.DeviceProps.PlatformType] ||
|
proto.DeviceProps.PlatformType[platformType as keyof typeof proto.DeviceProps.PlatformType] ||
|
||||||
proto.DeviceProps.PlatformType.CHROME
|
proto.DeviceProps.PlatformType.CHROME
|
||||||
|
|||||||
Reference in New Issue
Block a user