chore: update noise_version to 6

This commit is contained in:
Adhiraj Singh
2022-04-25 23:15:22 +05:30
parent d834e1d029
commit 47ab32f314
2 changed files with 11 additions and 11 deletions

View File

@@ -13,18 +13,18 @@ export const PHONE_CONNECTION_CB = 'CB:Pong'
export const WA_DEFAULT_EPHEMERAL = 7 * 24 * 60 * 60
export const NOISE_MODE = 'Noise_XX_25519_AESGCM_SHA256\0\0\0\0'
export const DICT_VERSION = Buffer.from([2])
export const DICT_VERSION = 2
export const KEY_BUNDLE_TYPE = Buffer.from([5])
export const NOISE_WA_HEADER = Buffer.concat(
[
Buffer.from('WA', 'ascii'),
KEY_BUNDLE_TYPE,
DICT_VERSION
]
export const NOISE_WA_HEADER = Buffer.from(
[ 87, 65, 6, DICT_VERSION ]
) // last is "DICT_VERSION"
/** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */
export const URL_REGEX = /[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)?/gi
export const WA_CERT_DETAILS = {
SERIAL: 0,
}
const BASE_CONNECTION_CONFIG: CommonSocketConfig<any> = {
version: version as any,
browser: Browsers.baileys('Chrome'),

View File

@@ -2,7 +2,7 @@ import { Boom } from '@hapi/boom'
import { createCipheriv, createDecipheriv } from 'crypto'
import { Logger } from 'pino'
import { proto } from '../../WAProto'
import { NOISE_MODE, NOISE_WA_HEADER } from '../Defaults'
import { NOISE_MODE, NOISE_WA_HEADER, WA_CERT_DETAILS } from '../Defaults'
import { KeyPair } from '../Types'
import { BinaryNode, decodeBinaryNode } from '../WABinary'
import { Curve, hkdf, sha256 } from './crypto'
@@ -117,11 +117,11 @@ export const makeNoiseHandler = (
mixIntoKey(Curve.sharedKey(privateKey, decStaticContent))
const certDecoded = decrypt(serverHello!.payload!)
const { details: certDetails } = proto.NoiseCertificate.decode(certDecoded)
const { intermediate: certIntermediate } = proto.CertChain.decode(certDecoded)
const { key: certKey } = proto.NoiseCertificateDetails.decode(certDetails)
const { issuerSerial } = proto.Details.decode(certIntermediate!.details!)
if(Buffer.compare(decStaticContent, certKey) !== 0) {
if(issuerSerial !== WA_CERT_DETAILS.SERIAL) {
throw new Boom('certification match failed', { statusCode: 400 })
}