feat: add support for FB and Interop JID encoding/decoding and empty strings (#2189)

This commit is contained in:
vini
2026-01-08 16:56:50 -03:00
committed by GitHub
parent 720cc688d6
commit c392d4ce6c
2 changed files with 33 additions and 1 deletions
+27
View File
@@ -167,6 +167,29 @@ export const decodeDecompressedBinaryNode = (
return jidEncode(user, server, device)
}
const readFbJid = () => {
const user = readString(readByte()!)
const device = readInt(2)
const server = readString(readByte()!)
return `${user}:${device}@${server}`
}
const readInteropJid = () => {
const user = readString(readByte()!)
const device = readInt(2)
const integrator = readInt(2)
let server = 'interop'
const beforeServer = indexRef.index
try {
server = readString(readByte()!)
} catch (err) {
indexRef.index = beforeServer
}
return `${integrator}-${user}:${device}@${server}`
}
const readString = (tag: number): string => {
if (tag >= 1 && tag < SINGLE_BYTE_TOKENS.length) {
return SINGLE_BYTE_TOKENS[tag] || ''
@@ -188,6 +211,10 @@ export const decodeDecompressedBinaryNode = (
return readStringFromChars(readInt(4))
case TAGS.JID_PAIR:
return readJidPair()
case TAGS.FB_JID:
return readFbJid()
case TAGS.INTEROP_JID:
return readInteropJid()
case TAGS.AD_JID:
return readAdJid()
case TAGS.HEX_8: