mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
refactor: remove useless "encodeInt" function
This commit is contained in:
@@ -75,17 +75,9 @@ export const encodeWAMessage = (message: proto.IMessage) => (
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
export const generateRegistrationId = () => (
|
export const generateRegistrationId = () => {
|
||||||
Uint16Array.from(randomBytes(2))[0]
|
const buff = randomBytes(4)
|
||||||
)
|
return buff.readUInt32BE()
|
||||||
|
|
||||||
export const encodeInt = (e: number, t: number) => {
|
|
||||||
for(var r = t, a = new Uint8Array(e), i = e - 1; i >= 0; i--) {
|
|
||||||
a[i] = 255 & r
|
|
||||||
r >>>= 8
|
|
||||||
}
|
|
||||||
|
|
||||||
return a
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const encodeBigEndian = (e: number, t = 4) => {
|
export const encodeBigEndian = (e: number, t = 4) => {
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import { Boom } from '@hapi/boom'
|
import { Boom } from '@hapi/boom'
|
||||||
import { createHash } from 'crypto'
|
import { createHash } from 'crypto'
|
||||||
import { proto } from '../../WAProto'
|
import { proto } from '../../WAProto'
|
||||||
|
import { KEY_BUNDLE_TYPE } from '../Defaults'
|
||||||
import type { AuthenticationCreds, SignalCreds, SocketConfig } from '../Types'
|
import type { AuthenticationCreds, SignalCreds, SocketConfig } from '../Types'
|
||||||
import { Binary, BinaryNode, getAllBinaryNodeChildren, jidDecode, S_WHATSAPP_NET } from '../WABinary'
|
import { Binary, BinaryNode, getAllBinaryNodeChildren, jidDecode, S_WHATSAPP_NET } from '../WABinary'
|
||||||
import { Curve, hmacSign } from './crypto'
|
import { Curve, hmacSign } from './crypto'
|
||||||
import { encodeInt } from './generics'
|
import { encodeBigEndian } from './generics'
|
||||||
import { createSignalIdentity } from './signal'
|
import { createSignalIdentity } from './signal'
|
||||||
|
|
||||||
type ClientPayloadConfig = Pick<SocketConfig, 'version' | 'browser'>
|
type ClientPayloadConfig = Pick<SocketConfig, 'version' | 'browser'>
|
||||||
@@ -80,10 +81,10 @@ export const generateRegistrationNode = (
|
|||||||
regData: {
|
regData: {
|
||||||
buildHash: appVersionBuf,
|
buildHash: appVersionBuf,
|
||||||
companionProps: companionProto,
|
companionProps: companionProto,
|
||||||
eRegid: encodeInt(4, registrationId),
|
eRegid: encodeBigEndian(registrationId),
|
||||||
eKeytype: encodeInt(1, 5),
|
eKeytype: KEY_BUNDLE_TYPE,
|
||||||
eIdent: signedIdentityKey.public,
|
eIdent: signedIdentityKey.public,
|
||||||
eSkeyId: encodeInt(3, signedPreKey.keyId),
|
eSkeyId: encodeBigEndian(signedPreKey.keyId, 3),
|
||||||
eSkeyVal: signedPreKey.keyPair.public,
|
eSkeyVal: signedPreKey.keyPair.public,
|
||||||
eSkeySig: signedPreKey.signature,
|
eSkeySig: signedPreKey.signature,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user