@hiroosy/baileys-lite 0.4.5 → 0.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -17,9 +17,10 @@ import {
|
|
|
17
17
|
generateMdTagPrefix,
|
|
18
18
|
generateRegistrationNode,
|
|
19
19
|
getCodeFromWSError,
|
|
20
|
+
getCompanionPlatformId,
|
|
20
21
|
getErrorCodeFromStreamError,
|
|
21
22
|
getNextPreKeysNode,
|
|
22
|
-
|
|
23
|
+
isAndroidBrowser,
|
|
23
24
|
makeNoiseHandler,
|
|
24
25
|
promiseTimeout,
|
|
25
26
|
signedKeyPair,
|
|
@@ -344,7 +345,7 @@ export const makeSocket = config => {
|
|
|
344
345
|
const keyEnc = noise.processHandshake(handshake, creds.noiseKey)
|
|
345
346
|
let node
|
|
346
347
|
if (!creds.me) {
|
|
347
|
-
node = generateRegistrationNode(creds, config)
|
|
348
|
+
node = generateRegistrationNode(creds, config, false)
|
|
348
349
|
logger.info({ node }, 'not logged in, attempting registration...')
|
|
349
350
|
} else {
|
|
350
351
|
node = generateLoginNode(creds.me.id, config)
|
|
@@ -628,8 +629,8 @@ export const makeSocket = config => {
|
|
|
628
629
|
content: [
|
|
629
630
|
{ tag: 'link_code_pairing_wrapped_companion_ephemeral_pub', attrs: {}, content: await generatePairingKey() },
|
|
630
631
|
{ tag: 'companion_server_auth_key_pub', attrs: {}, content: authState.creds.noiseKey.public },
|
|
631
|
-
{ tag: 'companion_platform_id', attrs: {}, content:
|
|
632
|
-
{ tag: 'companion_platform_display', attrs: {}, content: `${browser[1]} (${browser[0]})` },
|
|
632
|
+
{ tag: 'companion_platform_id', attrs: {}, content: getCompanionPlatformId(browser) },
|
|
633
|
+
{ tag: 'companion_platform_display', attrs: {}, content: isAndroidBrowser(browser) ? `Chrome (${browser[1]})` : `${browser[1]} (${browser[0]})` },
|
|
633
634
|
{ tag: 'link_code_pairing_nonce', attrs: {}, content: '0' }
|
|
634
635
|
]
|
|
635
636
|
}
|
|
@@ -1476,9 +1476,14 @@ export const generateWAMessageFromContent = (jid, message, options) => {
|
|
|
1476
1476
|
const participant = quoted.key.fromMe ? userJid : quoted.participant || quoted.key.participant || quoted.key.remoteJid
|
|
1477
1477
|
let quotedMsg = normalizeMessageContent(quoted.message)
|
|
1478
1478
|
const msgType = getContentType(quotedMsg)
|
|
1479
|
-
const
|
|
1480
|
-
|
|
1481
|
-
|
|
1479
|
+
const quotedBody = quotedMsg[msgType]
|
|
1480
|
+
if (typeof quotedBody === 'string') {
|
|
1481
|
+
quotedMsg = proto.Message.create({ [msgType]: quotedBody })
|
|
1482
|
+
} else {
|
|
1483
|
+
const quotedContent = { ...quotedBody }
|
|
1484
|
+
delete quotedContent.contextInfo
|
|
1485
|
+
quotedMsg = proto.Message.create({ [msgType]: quotedContent })
|
|
1486
|
+
}
|
|
1482
1487
|
const patch = { participant: jidNormalizedUser(participant), stanzaId: quoted.key.id, quotedMessage: quotedMsg }
|
|
1483
1488
|
if (!isNewsletter && jid !== quoted.key.remoteJid) patch.remoteJid = quoted.key.remoteJid
|
|
1484
1489
|
mergeContextInfo(patch)
|
|
@@ -342,7 +342,7 @@ export const getStatusFromReceiptType = type => {
|
|
|
342
342
|
return status
|
|
343
343
|
}
|
|
344
344
|
|
|
345
|
-
const CODE_MAP = { conflict: DisconnectReason.connectionReplaced }
|
|
345
|
+
const CODE_MAP = { conflict: DisconnectReason.connectionReplaced, ack: DisconnectReason.restartRequired }
|
|
346
346
|
|
|
347
347
|
export const getErrorCodeFromStreamError = node => {
|
|
348
348
|
const [reasonNode] = getAllBinaryNodeChildren(node)
|
|
@@ -356,7 +356,7 @@ export const getErrorCodeFromStreamError = node => {
|
|
|
356
356
|
reason = 'device removed'
|
|
357
357
|
}
|
|
358
358
|
}
|
|
359
|
-
if (statusCode === DisconnectReason.restartRequired) reason = 'restart required'
|
|
359
|
+
if (statusCode === DisconnectReason.restartRequired && reason !== 'ack') reason = 'restart required'
|
|
360
360
|
return { reason, statusCode }
|
|
361
361
|
}
|
|
362
362
|
|
|
@@ -484,7 +484,7 @@ export const getCompanionWebClientType = ([os, browserName]) => {
|
|
|
484
484
|
|
|
485
485
|
export const getCompanionPlatformId = browser => getCompanionWebClientType(browser).toString()
|
|
486
486
|
|
|
487
|
-
export const
|
|
487
|
+
export const isAndroidBrowser = browser => browser[1].toLocaleLowerCase().includes('android')
|
|
488
488
|
|
|
489
489
|
export const buildPairingQRData = (ref, noiseKeyB64, identityKeyB64, advB64, browser) =>
|
|
490
490
|
'https://wa.me/settings/linked_devices#' + [ref, noiseKeyB64, identityKeyB64, advB64, getCompanionPlatformId(browser)].join(',')
|
|
@@ -890,9 +890,9 @@ const WA_ADV_ACCOUNT_SIG_PREFIX = Buffer.from([6, 0])
|
|
|
890
890
|
const WA_ADV_DEVICE_SIG_PREFIX = Buffer.from([6, 1])
|
|
891
891
|
const WA_ADV_HOSTED_ACCOUNT_SIG_PREFIX = Buffer.from([6, 5])
|
|
892
892
|
|
|
893
|
-
const getUserAgent = config => ({
|
|
893
|
+
const getUserAgent = (config, android) => ({
|
|
894
894
|
appVersion: { primary: config.version[0], secondary: config.version[1], tertiary: config.version[2] },
|
|
895
|
-
platform: proto.ClientPayload.UserAgent.Platform.WEB,
|
|
895
|
+
platform: android ? proto.ClientPayload.UserAgent.Platform.ANDROID : proto.ClientPayload.UserAgent.Platform.WEB,
|
|
896
896
|
releaseChannel: proto.ClientPayload.UserAgent.ReleaseChannel.RELEASE,
|
|
897
897
|
osVersion: '0.1',
|
|
898
898
|
device: 'Desktop',
|
|
@@ -916,20 +916,20 @@ const getWebInfo = config => {
|
|
|
916
916
|
return { webSubPlatform }
|
|
917
917
|
}
|
|
918
918
|
|
|
919
|
-
const getClientPayload = config => {
|
|
919
|
+
const getClientPayload = (config, android) => {
|
|
920
920
|
const payload = {
|
|
921
921
|
connectType: proto.ClientPayload.ConnectType.WIFI_UNKNOWN,
|
|
922
922
|
connectReason: proto.ClientPayload.ConnectReason.USER_ACTIVATED,
|
|
923
|
-
userAgent: getUserAgent(config)
|
|
924
|
-
webInfo: getWebInfo(config)
|
|
923
|
+
userAgent: getUserAgent(config, android)
|
|
925
924
|
}
|
|
925
|
+
if (!android) payload.webInfo = getWebInfo(config)
|
|
926
926
|
if (config.pushName) payload.pushName = config.pushName
|
|
927
927
|
return payload
|
|
928
928
|
}
|
|
929
929
|
|
|
930
|
-
export const generateLoginNode = (userJid, config) => {
|
|
930
|
+
export const generateLoginNode = (userJid, config, android = isAndroidBrowser(config.browser)) => {
|
|
931
931
|
const { user, device } = jidDecode(userJid)
|
|
932
|
-
const payload = { ...getClientPayload(config), passive: true, pull: true, username: +user, device, lidDbMigrated: false }
|
|
932
|
+
const payload = { ...getClientPayload(config, android), passive: true, pull: true, username: +user, device, lidDbMigrated: false }
|
|
933
933
|
return proto.ClientPayload.fromObject(payload)
|
|
934
934
|
}
|
|
935
935
|
|
|
@@ -939,7 +939,7 @@ const getPlatformType = platform => {
|
|
|
939
939
|
return proto.DeviceProps.PlatformType[platformType] || proto.DeviceProps.PlatformType.CHROME
|
|
940
940
|
}
|
|
941
941
|
|
|
942
|
-
export const generateRegistrationNode = ({ registrationId, signedPreKey, signedIdentityKey }, config) => {
|
|
942
|
+
export const generateRegistrationNode = ({ registrationId, signedPreKey, signedIdentityKey }, config, android = isAndroidBrowser(config.browser)) => {
|
|
943
943
|
const appVersionBuf = createHash('md5').update(config.version.join('.')).digest()
|
|
944
944
|
const companion = {
|
|
945
945
|
os: config.browser[0],
|
|
@@ -966,7 +966,7 @@ export const generateRegistrationNode = ({ registrationId, signedPreKey, signedI
|
|
|
966
966
|
}
|
|
967
967
|
const companionProto = proto.DeviceProps.encode(companion).finish()
|
|
968
968
|
const registerPayload = {
|
|
969
|
-
...getClientPayload(config),
|
|
969
|
+
...getClientPayload(config, android),
|
|
970
970
|
passive: false,
|
|
971
971
|
pull: false,
|
|
972
972
|
devicePairingData: {
|