Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 38620d2e2f |
@@ -343,13 +343,11 @@ export const extractGroupMetadata = (result: BinaryNode) => {
|
|||||||
let descId: string | undefined
|
let descId: string | undefined
|
||||||
let descOwner: string | undefined
|
let descOwner: string | undefined
|
||||||
let descOwnerPn: string | undefined
|
let descOwnerPn: string | undefined
|
||||||
let descOwnerUsername: string | undefined
|
|
||||||
let descTime: number | undefined
|
let descTime: number | undefined
|
||||||
if (descChild) {
|
if (descChild) {
|
||||||
desc = getBinaryNodeChildString(descChild, 'body')
|
desc = getBinaryNodeChildString(descChild, 'body')
|
||||||
descOwner = descChild.attrs.participant ? jidNormalizedUser(descChild.attrs.participant) : undefined
|
descOwner = descChild.attrs.participant ? jidNormalizedUser(descChild.attrs.participant) : undefined
|
||||||
descOwnerPn = descChild.attrs.participant_pn ? jidNormalizedUser(descChild.attrs.participant_pn) : undefined
|
descOwnerPn = descChild.attrs.participant_pn ? jidNormalizedUser(descChild.attrs.participant_pn) : undefined
|
||||||
descOwnerUsername = descChild.attrs.participant_username || undefined
|
|
||||||
descTime = +descChild.attrs.t!
|
descTime = +descChild.attrs.t!
|
||||||
descId = descChild.attrs.id
|
descId = descChild.attrs.id
|
||||||
}
|
}
|
||||||
@@ -364,19 +362,16 @@ export const extractGroupMetadata = (result: BinaryNode) => {
|
|||||||
subject: group.attrs.subject!,
|
subject: group.attrs.subject!,
|
||||||
subjectOwner: group.attrs.s_o,
|
subjectOwner: group.attrs.s_o,
|
||||||
subjectOwnerPn: group.attrs.s_o_pn,
|
subjectOwnerPn: group.attrs.s_o_pn,
|
||||||
subjectOwnerUsername: group.attrs.s_o_username,
|
|
||||||
subjectTime: +(group.attrs.s_t ?? '0'),
|
subjectTime: +(group.attrs.s_t ?? '0'),
|
||||||
size: group.attrs.size ? +group.attrs.size : getBinaryNodeChildren(group, 'participant').length,
|
size: group.attrs.size ? +group.attrs.size : getBinaryNodeChildren(group, 'participant').length,
|
||||||
creation: +(group.attrs.creation ?? '0'),
|
creation: +(group.attrs.creation ?? '0'),
|
||||||
owner: group.attrs.creator ? jidNormalizedUser(group.attrs.creator) : undefined,
|
owner: group.attrs.creator ? jidNormalizedUser(group.attrs.creator) : undefined,
|
||||||
ownerPn: group.attrs.creator_pn ? jidNormalizedUser(group.attrs.creator_pn) : undefined,
|
ownerPn: group.attrs.creator_pn ? jidNormalizedUser(group.attrs.creator_pn) : undefined,
|
||||||
ownerUsername: group.attrs.creator_username || undefined,
|
|
||||||
owner_country_code: group.attrs.creator_country_code,
|
owner_country_code: group.attrs.creator_country_code,
|
||||||
desc,
|
desc,
|
||||||
descId,
|
descId,
|
||||||
descOwner,
|
descOwner,
|
||||||
descOwnerPn,
|
descOwnerPn,
|
||||||
descOwnerUsername,
|
|
||||||
descTime,
|
descTime,
|
||||||
linkedParent: getBinaryNodeChild(group, 'linked_parent')?.attrs.jid || undefined,
|
linkedParent: getBinaryNodeChild(group, 'linked_parent')?.attrs.jid || undefined,
|
||||||
restrict: !!getBinaryNodeChild(group, 'locked'),
|
restrict: !!getBinaryNodeChild(group, 'locked'),
|
||||||
@@ -391,7 +386,6 @@ export const extractGroupMetadata = (result: BinaryNode) => {
|
|||||||
id: attrs.jid!,
|
id: attrs.jid!,
|
||||||
phoneNumber: isLidUser(attrs.jid) && isPnUser(attrs.phone_number) ? attrs.phone_number : undefined,
|
phoneNumber: isLidUser(attrs.jid) && isPnUser(attrs.phone_number) ? attrs.phone_number : undefined,
|
||||||
lid: isPnUser(attrs.jid) && isLidUser(attrs.lid) ? attrs.lid : undefined,
|
lid: isPnUser(attrs.jid) && isLidUser(attrs.lid) ? attrs.lid : undefined,
|
||||||
username: attrs.participant_username || attrs.username || undefined,
|
|
||||||
admin: (attrs.type || null) as GroupParticipant['admin']
|
admin: (attrs.type || null) as GroupParticipant['admin']
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -2240,7 +2240,6 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
|||||||
fromMe,
|
fromMe,
|
||||||
participant: node.attrs.participant,
|
participant: node.attrs.participant,
|
||||||
participantAlt,
|
participantAlt,
|
||||||
participantUsername: node.attrs.participant_username,
|
|
||||||
addressingMode,
|
addressingMode,
|
||||||
id: node.attrs.id,
|
id: node.attrs.id,
|
||||||
...(msg.key || {})
|
...(msg.key || {})
|
||||||
@@ -2249,10 +2248,6 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
|||||||
msg.messageTimestamp = +node.attrs.t!
|
msg.messageTimestamp = +node.attrs.t!
|
||||||
|
|
||||||
const fullMsg = proto.WebMessageInfo.fromObject(msg) as WAMessage
|
const fullMsg = proto.WebMessageInfo.fromObject(msg) as WAMessage
|
||||||
// Preserve custom WAMessageKey fields (participantAlt, participantUsername,
|
|
||||||
// addressingMode) that proto.WebMessageInfo.fromObject strips because
|
|
||||||
// they aren't part of the proto.MessageKey schema.
|
|
||||||
fullMsg.key = msg.key
|
|
||||||
await upsertMessage(fullMsg, 'append')
|
await upsertMessage(fullMsg, 'append')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -2695,20 +2690,7 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Slim log: identify the message that crashed without dumping the full
|
logger.error({ error, node: binaryNodeToString(node) }, 'error in handling message')
|
||||||
// stanza XML (which contains kilobytes of inline ciphertext). Under heavy
|
|
||||||
// load — e.g. a downstream consumer that throws on every Bad MAC — the
|
|
||||||
// full XML dumps overwhelm stdout and stall the event loop. Operators
|
|
||||||
// can still pivot on msgId / from / type; full payload at debug level.
|
|
||||||
const slimNode = {
|
|
||||||
tag: node.tag,
|
|
||||||
id: node.attrs?.id,
|
|
||||||
from: node.attrs?.from,
|
|
||||||
type: node.attrs?.type,
|
|
||||||
participant: node.attrs?.participant
|
|
||||||
}
|
|
||||||
logger.error({ error, node: slimNode }, 'error in handling message')
|
|
||||||
logger.debug({ node: binaryNodeToString(node) }, 'error in handling message — full stanza')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ export interface Contact {
|
|||||||
name?: string
|
name?: string
|
||||||
/** name of the contact, the contact has set on their own on WA */
|
/** name of the contact, the contact has set on their own on WA */
|
||||||
notify?: string
|
notify?: string
|
||||||
/** username associated with this contact, when provided by WA */
|
|
||||||
username?: string
|
|
||||||
/** I have no idea */
|
/** I have no idea */
|
||||||
verifiedName?: string
|
verifiedName?: string
|
||||||
// Baileys Added
|
// Baileys Added
|
||||||
|
|||||||
@@ -81,7 +81,6 @@ export type BaileysEventMap = {
|
|||||||
id: string
|
id: string
|
||||||
author: string
|
author: string
|
||||||
authorPn?: string
|
authorPn?: string
|
||||||
authorUsername?: string
|
|
||||||
participants: GroupParticipant[]
|
participants: GroupParticipant[]
|
||||||
action: ParticipantAction
|
action: ParticipantAction
|
||||||
}
|
}
|
||||||
@@ -89,7 +88,6 @@ export type BaileysEventMap = {
|
|||||||
id: string
|
id: string
|
||||||
author: string
|
author: string
|
||||||
authorPn?: string
|
authorPn?: string
|
||||||
authorUsername?: string
|
|
||||||
participant: string
|
participant: string
|
||||||
participantPn?: string
|
participantPn?: string
|
||||||
action: RequestJoinAction
|
action: RequestJoinAction
|
||||||
|
|||||||
@@ -20,20 +20,17 @@ export interface GroupMetadata {
|
|||||||
addressingMode?: WAMessageAddressingMode
|
addressingMode?: WAMessageAddressingMode
|
||||||
owner: string | undefined
|
owner: string | undefined
|
||||||
ownerPn?: string | undefined
|
ownerPn?: string | undefined
|
||||||
ownerUsername?: string | undefined
|
|
||||||
owner_country_code?: string | undefined
|
owner_country_code?: string | undefined
|
||||||
subject: string
|
subject: string
|
||||||
/** group subject owner */
|
/** group subject owner */
|
||||||
subjectOwner?: string
|
subjectOwner?: string
|
||||||
subjectOwnerPn?: string
|
subjectOwnerPn?: string
|
||||||
subjectOwnerUsername?: string
|
|
||||||
/** group subject modification date */
|
/** group subject modification date */
|
||||||
subjectTime?: number
|
subjectTime?: number
|
||||||
creation?: number
|
creation?: number
|
||||||
desc?: string
|
desc?: string
|
||||||
descOwner?: string
|
descOwner?: string
|
||||||
descOwnerPn?: string
|
descOwnerPn?: string
|
||||||
descOwnerUsername?: string
|
|
||||||
descId?: string
|
descId?: string
|
||||||
descTime?: number
|
descTime?: number
|
||||||
/** if this group is part of a community, it returns the jid of the community to which it belongs */
|
/** if this group is part of a community, it returns the jid of the community to which it belongs */
|
||||||
@@ -59,7 +56,6 @@ export interface GroupMetadata {
|
|||||||
/** the person who added you to group or changed some setting in group */
|
/** the person who added you to group or changed some setting in group */
|
||||||
author?: string
|
author?: string
|
||||||
authorPn?: string
|
authorPn?: string
|
||||||
authorUsername?: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface WAGroupCreateResponse {
|
export interface WAGroupCreateResponse {
|
||||||
|
|||||||
@@ -19,9 +19,7 @@ export type WAContactMessage = proto.Message.IContactMessage
|
|||||||
export type WAContactsArrayMessage = proto.Message.IContactsArrayMessage
|
export type WAContactsArrayMessage = proto.Message.IContactsArrayMessage
|
||||||
export type WAMessageKey = proto.IMessageKey & {
|
export type WAMessageKey = proto.IMessageKey & {
|
||||||
remoteJidAlt?: string
|
remoteJidAlt?: string
|
||||||
remoteJidUsername?: string
|
|
||||||
participantAlt?: string
|
participantAlt?: string
|
||||||
participantUsername?: string
|
|
||||||
server_id?: string
|
server_id?: string
|
||||||
addressingMode?: string
|
addressingMode?: string
|
||||||
isViewOnce?: boolean // TODO: remove out of the message key, place in WebMessageInfo
|
isViewOnce?: boolean // TODO: remove out of the message key, place in WebMessageInfo
|
||||||
|
|||||||
@@ -341,16 +341,14 @@ export const addTransactionCapability = (
|
|||||||
|
|
||||||
return result
|
return result
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// SessionError / MessageCounterError are part of the normal Bad MAC
|
// SessionError is part of the normal Bad MAC recovery flow
|
||||||
// recovery flow (retry receipt → sender resends as pkmsg → new session
|
// (retry receipt → sender resends as pkmsg → new session within ~1.3s).
|
||||||
// within ~1.3s). Logging them as ERROR creates 2 noise lines per
|
// Logging it as ERROR creates 2 noise lines per recoverable Bad MAC cycle.
|
||||||
// recoverable cycle, and under WhatsApp's LID/DSM rollout these fire
|
// Downgrade to debug for SessionError; keep ERROR for everything else.
|
||||||
// in dense bursts that saturate stdout (synchronous pm2 writes block
|
// The error is still re-thrown — recovery behavior is unchanged.
|
||||||
// the event loop). Downgrade to debug for both; keep ERROR for
|
|
||||||
// everything else. The error is still re-thrown — recovery is unchanged.
|
|
||||||
const errName = (error as { name?: string })?.name
|
const errName = (error as { name?: string })?.name
|
||||||
if (errName === 'SessionError' || errName === 'MessageCounterError') {
|
if (errName === 'SessionError') {
|
||||||
logger.debug({ error }, `transaction failed (${errName} — recoverable via retry receipt)`)
|
logger.debug({ error }, 'transaction failed (SessionError — recoverable via retry receipt)')
|
||||||
} else {
|
} else {
|
||||||
logger.error({ error }, 'transaction failed, rolling back')
|
logger.error({ error }, 'transaction failed, rolling back')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1083,7 +1083,6 @@ export const processSyncAction = (
|
|||||||
action.lidContactAction.firstName ||
|
action.lidContactAction.firstName ||
|
||||||
action.lidContactAction.username ||
|
action.lidContactAction.username ||
|
||||||
undefined,
|
undefined,
|
||||||
username: action.lidContactAction.username || undefined,
|
|
||||||
lid: id!,
|
lid: id!,
|
||||||
phoneNumber: undefined
|
phoneNumber: undefined
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -246,14 +246,10 @@ export function decodeMessageNode(stanza: BinaryNode, meId: string, meLid: strin
|
|||||||
const key: WAMessageKey = {
|
const key: WAMessageKey = {
|
||||||
remoteJid: chatId,
|
remoteJid: chatId,
|
||||||
remoteJidAlt: !isJidGroup(chatId) ? addressingContext.senderAlt : undefined,
|
remoteJidAlt: !isJidGroup(chatId) ? addressingContext.senderAlt : undefined,
|
||||||
remoteJidUsername: !isJidGroup(chatId)
|
|
||||||
? stanza.attrs.peer_recipient_username || stanza.attrs.recipient_username
|
|
||||||
: undefined,
|
|
||||||
fromMe,
|
fromMe,
|
||||||
id: msgId,
|
id: msgId,
|
||||||
participant,
|
participant,
|
||||||
participantAlt: isJidGroup(chatId) ? addressingContext.senderAlt : undefined,
|
participantAlt: isJidGroup(chatId) ? addressingContext.senderAlt : undefined,
|
||||||
participantUsername: stanza.attrs.participant ? stanza.attrs.participant_username : undefined,
|
|
||||||
addressingMode: addressingContext.addressingMode,
|
addressingMode: addressingContext.addressingMode,
|
||||||
...(msgType === 'newsletter' && stanza.attrs.server_id ? { server_id: stanza.attrs.server_id } : {})
|
...(msgType === 'newsletter' && stanza.attrs.server_id ? { server_id: stanza.attrs.server_id } : {})
|
||||||
}
|
}
|
||||||
@@ -454,40 +450,19 @@ export const decryptMessageNode = (
|
|||||||
...(isRetryExhausted && { retriesExhausted: true, attempts: err.attempts })
|
...(isRetryExhausted && { retriesExhausted: true, attempts: err.attempts })
|
||||||
}
|
}
|
||||||
|
|
||||||
// Smart logging based on error type and retry status.
|
// Smart logging based on error type and retry status
|
||||||
//
|
|
||||||
// PERF NOTE: under WhatsApp's LID/DSM rollout, own DSM messages flood
|
|
||||||
// the inbound pipeline with Bad MAC / "Key used already" / "No session
|
|
||||||
// record" errors *every* time the auth state has a session in the
|
|
||||||
// legacy `_1.0` format that no longer matches the LID-addressed
|
|
||||||
// envelope. Logging the full errorContext (key + jid + err) per failed
|
|
||||||
// attempt as warn-level produces tens of JSON lines/sec, which
|
|
||||||
// saturates stdout in pm2 (synchronous writes to a full pipe block the
|
|
||||||
// event loop). The clean `🔐 Bad MAC Error | JID: …` line emitted by
|
|
||||||
// the console.error interceptor in src/index.ts already gives an
|
|
||||||
// operator-visible signal — the duplicated pino line was pure noise.
|
|
||||||
//
|
|
||||||
// We now only emit warn-level when retries are exhausted (rare,
|
|
||||||
// actionable). Per-attempt detail is still available at debug level
|
|
||||||
// (BAILEYS_LOG_LEVEL=debug) for active troubleshooting.
|
|
||||||
const slimErrorContext = {
|
|
||||||
msgId: fullMessage.key?.id,
|
|
||||||
jid: fullMessage.key?.remoteJid,
|
|
||||||
err: slimErr,
|
|
||||||
attempts: isRetryExhausted ? err.attempts : 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isCorrupted) {
|
if (isCorrupted) {
|
||||||
// Corrupted session errors are expected — Signal Protocol auto-recovers
|
// Corrupted session errors are expected and auto-recovered
|
||||||
// via retry receipt → pkmsg → new session.
|
// Only log as ERROR if retries exhausted, otherwise WARN on first attempt
|
||||||
// eslint-disable-next-line max-depth
|
// eslint-disable-next-line max-depth
|
||||||
if (isRetryExhausted) {
|
if (isRetryExhausted) {
|
||||||
logger.warn(
|
logger.error(
|
||||||
slimErrorContext,
|
errorContext,
|
||||||
`⚠️ Session corrupted after ${err.attempts} attempts. Retry+pkmsg flow will recover.`
|
`⚠️ Session corrupted after ${err.attempts} attempts. Retry+pkmsg flow will recover.`
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
logger.debug(errorContext, '⚠️ Corrupted session detected - attempting auto-recovery')
|
// First occurrence - log as warning since auto-recovery will attempt
|
||||||
|
logger.warn(errorContext, '⚠️ Corrupted session detected - attempting auto-recovery')
|
||||||
}
|
}
|
||||||
|
|
||||||
// Session cleanup is deferred to retry exhaustion (safety net).
|
// Session cleanup is deferred to retry exhaustion (safety net).
|
||||||
@@ -500,7 +475,7 @@ export const decryptMessageNode = (
|
|||||||
// Session record errors are transient - retry should handle them
|
// Session record errors are transient - retry should handle them
|
||||||
// eslint-disable-next-line max-depth
|
// eslint-disable-next-line max-depth
|
||||||
if (isRetryExhausted) {
|
if (isRetryExhausted) {
|
||||||
logger.warn(slimErrorContext, `Failed to decrypt: No session record found after ${err.attempts} attempts`)
|
logger.error(errorContext, `Failed to decrypt: No session record found after ${err.attempts} attempts`)
|
||||||
} else {
|
} else {
|
||||||
logger.debug(errorContext, 'No session record - will retry')
|
logger.debug(errorContext, 'No session record - will retry')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -315,7 +315,6 @@ export const processHistoryMessage = (item: proto.IHistorySync, logger?: ILogger
|
|||||||
contacts.push({
|
contacts.push({
|
||||||
id: chatId,
|
id: chatId,
|
||||||
name: chat.displayName || chat.name || chat.username || undefined,
|
name: chat.displayName || chat.name || chat.username || undefined,
|
||||||
username: chat.username || undefined,
|
|
||||||
lid: chat.lidJid || chat.accountLid || undefined,
|
lid: chat.lidJid || chat.accountLid || undefined,
|
||||||
phoneNumber: chat.pnJid || undefined
|
phoneNumber: chat.pnJid || undefined
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -950,19 +950,12 @@ const processMessage = async (
|
|||||||
id: jid,
|
id: jid,
|
||||||
author: message.key.participant!,
|
author: message.key.participant!,
|
||||||
authorPn: message.key.participantAlt!,
|
authorPn: message.key.participantAlt!,
|
||||||
authorUsername: message.key.participantUsername!,
|
|
||||||
participants,
|
participants,
|
||||||
action
|
action
|
||||||
})
|
})
|
||||||
const emitGroupUpdate = (update: Partial<GroupMetadata>) => {
|
const emitGroupUpdate = (update: Partial<GroupMetadata>) => {
|
||||||
ev.emit('groups.update', [
|
ev.emit('groups.update', [
|
||||||
{
|
{ id: jid, ...update, author: message.key.participant ?? undefined, authorPn: message.key.participantAlt }
|
||||||
id: jid,
|
|
||||||
...update,
|
|
||||||
author: message.key.participant ?? undefined,
|
|
||||||
authorPn: message.key.participantAlt,
|
|
||||||
authorUsername: message.key.participantUsername
|
|
||||||
}
|
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -971,7 +964,6 @@ const processMessage = async (
|
|||||||
id: jid,
|
id: jid,
|
||||||
author: message.key.participant!,
|
author: message.key.participant!,
|
||||||
authorPn: message.key.participantAlt!,
|
authorPn: message.key.participantAlt!,
|
||||||
authorUsername: message.key.participantUsername!,
|
|
||||||
participant: participant.lid,
|
participant: participant.lid,
|
||||||
participantPn: participant.pn,
|
participantPn: participant.pn,
|
||||||
action,
|
action,
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ export const processContactAction = (
|
|||||||
{
|
{
|
||||||
id,
|
id,
|
||||||
name: action.fullName || action.firstName || action.username || undefined,
|
name: action.fullName || action.firstName || action.username || undefined,
|
||||||
username: action.username || undefined,
|
|
||||||
lid: lidJid || undefined,
|
lid: lidJid || undefined,
|
||||||
phoneNumber
|
phoneNumber
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,37 +13,11 @@ export class USyncContactProtocol implements USyncQueryProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getUserElement(user: USyncUser): BinaryNode {
|
getUserElement(user: USyncUser): BinaryNode {
|
||||||
if (user.phone) {
|
//TODO: Implement type / username fields (not yet supported)
|
||||||
return {
|
|
||||||
tag: 'contact',
|
|
||||||
attrs: {},
|
|
||||||
content: user.phone
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (user.username) {
|
|
||||||
return {
|
|
||||||
tag: 'contact',
|
|
||||||
attrs: {
|
|
||||||
username: user.username,
|
|
||||||
...(user.usernameKey ? { pin: user.usernameKey } : {}),
|
|
||||||
...(user.lid ? { lid: user.lid } : {})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (user.type) {
|
|
||||||
return {
|
|
||||||
tag: 'contact',
|
|
||||||
attrs: {
|
|
||||||
type: user.type
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
tag: 'contact',
|
tag: 'contact',
|
||||||
attrs: {}
|
attrs: {},
|
||||||
|
content: user.phone
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
import type { USyncQueryProtocol } from '../../Types/USync'
|
|
||||||
import { assertNodeErrorFree, type BinaryNode } from '../../WABinary'
|
|
||||||
import { USyncUser } from '../USyncUser'
|
|
||||||
|
|
||||||
export class USyncUsernameProtocol implements USyncQueryProtocol {
|
|
||||||
name = 'username'
|
|
||||||
|
|
||||||
getQueryElement(): BinaryNode {
|
|
||||||
return {
|
|
||||||
tag: 'username',
|
|
||||||
attrs: {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
getUserElement(user: USyncUser): BinaryNode | null {
|
|
||||||
void user
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
parser(node: BinaryNode): string | null {
|
|
||||||
if (node.tag === 'username') {
|
|
||||||
assertNodeErrorFree(node)
|
|
||||||
return typeof node.content === 'string' ? node.content : null
|
|
||||||
}
|
|
||||||
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,4 +2,3 @@ export * from './USyncDeviceProtocol'
|
|||||||
export * from './USyncContactProtocol'
|
export * from './USyncContactProtocol'
|
||||||
export * from './USyncStatusProtocol'
|
export * from './USyncStatusProtocol'
|
||||||
export * from './USyncDisappearingModeProtocol'
|
export * from './USyncDisappearingModeProtocol'
|
||||||
export * from './USyncUsernameProtocol'
|
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import {
|
|||||||
USyncContactProtocol,
|
USyncContactProtocol,
|
||||||
USyncDeviceProtocol,
|
USyncDeviceProtocol,
|
||||||
USyncDisappearingModeProtocol,
|
USyncDisappearingModeProtocol,
|
||||||
USyncStatusProtocol,
|
USyncStatusProtocol
|
||||||
USyncUsernameProtocol
|
|
||||||
} from './Protocols'
|
} from './Protocols'
|
||||||
import { USyncUser } from './USyncUser'
|
import { USyncUser } from './USyncUser'
|
||||||
|
|
||||||
@@ -138,9 +137,4 @@ export class USyncQuery {
|
|||||||
this.protocols.push(new USyncLIDProtocol())
|
this.protocols.push(new USyncLIDProtocol())
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
withUsernameProtocol() {
|
|
||||||
this.protocols.push(new USyncUsernameProtocol())
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ export class USyncUser {
|
|||||||
id?: string
|
id?: string
|
||||||
lid?: string
|
lid?: string
|
||||||
phone?: string
|
phone?: string
|
||||||
username?: string
|
|
||||||
usernameKey?: string
|
|
||||||
type?: string
|
type?: string
|
||||||
personaId?: string
|
personaId?: string
|
||||||
|
|
||||||
@@ -22,16 +20,6 @@ export class USyncUser {
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
withUsername(username: string) {
|
|
||||||
this.username = username
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
withUsernameKey(usernameKey: string) {
|
|
||||||
this.usernameKey = usernameKey
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
withType(type: string) {
|
withType(type: string) {
|
||||||
this.type = type
|
this.type = type
|
||||||
return this
|
return this
|
||||||
|
|||||||
+4
-31
@@ -5,30 +5,11 @@
|
|||||||
const _origConsoleError = console.error
|
const _origConsoleError = console.error
|
||||||
const _origConsoleLog = console.log
|
const _origConsoleLog = console.log
|
||||||
const _origConsoleInfo = console.info
|
const _origConsoleInfo = console.info
|
||||||
const _origConsoleWarn = console.warn
|
|
||||||
|
|
||||||
// Suppress libsignal session lifecycle dumps from console.log / console.info / console.warn.
|
|
||||||
// libsignal's session_record.js / session_builder.js / session_cipher.js use:
|
|
||||||
// console.info("Removing old closed session:", obj) ← ~500ms I/O dump per call
|
|
||||||
// console.info("Opening session:", obj) ← ~500ms I/O dump per call
|
|
||||||
// console.info("Migrating session to:", v) ← per migration
|
|
||||||
// console.log("Closing session:", obj) ← ~500ms I/O dump per call
|
|
||||||
// console.warn("Closing open session in favor of incoming prekey bundle") ← per pkmsg
|
|
||||||
// console.warn("Session already closed", obj) ← per stale close
|
|
||||||
// console.warn("Decrypted message with closed session.") ← per recovered decrypt
|
|
||||||
// console.warn("Unhandled bucket type (for naming):", ...) ← queue_job edge case
|
|
||||||
//
|
|
||||||
// Under WhatsApp's LID/DSM rollout these fire dozens of times per minute when
|
|
||||||
// the auth state has legacy `_1.0` sessions that don't match LID-addressed
|
|
||||||
// envelopes. Each dump is a synchronous stdout.write — pm2 buffers fill and
|
|
||||||
// the event loop blocks. Symptom: 60s inbound delivery latency, profile
|
|
||||||
// pictures don't load, queries time out.
|
|
||||||
//
|
|
||||||
// The clean operator-facing signal lives in the console.error interceptor
|
|
||||||
// below (formats Bad MAC / Counter / Decryption Failed as one emoji line).
|
|
||||||
const _SESSION_LIFECYCLE_RE =
|
|
||||||
/^(Closing session|Removing old closed session|Opening session|Migrating session|Closing open session|Session already closed|Decrypted message with closed session|Unhandled bucket type)/
|
|
||||||
|
|
||||||
|
// Suppress libsignal session lifecycle dumps from console.log / console.info.
|
||||||
|
// libsignal's session_record.js uses console.info("Removing old closed session:", obj)
|
||||||
|
// and console.log("Closing session:", obj) which dump full session objects (~500ms I/O each).
|
||||||
|
const _SESSION_LIFECYCLE_RE = /^(Closing session|Removing old closed session)/
|
||||||
console.log = function (...args: unknown[]) {
|
console.log = function (...args: unknown[]) {
|
||||||
if (args.length > 0 && typeof args[0] === 'string' && _SESSION_LIFECYCLE_RE.test(args[0])) {
|
if (args.length > 0 && typeof args[0] === 'string' && _SESSION_LIFECYCLE_RE.test(args[0])) {
|
||||||
return
|
return
|
||||||
@@ -45,14 +26,6 @@ console.info = function (...args: unknown[]) {
|
|||||||
_origConsoleInfo.apply(console, args)
|
_origConsoleInfo.apply(console, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
console.warn = function (...args: unknown[]) {
|
|
||||||
if (args.length > 0 && typeof args[0] === 'string' && _SESSION_LIFECYCLE_RE.test(args[0])) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
_origConsoleWarn.apply(console, args)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Track errors by type + JID to avoid duplicates (using Map for better performance)
|
// Track errors by type + JID to avoid duplicates (using Map for better performance)
|
||||||
const _errorTimestamps = new Map<string, number>()
|
const _errorTimestamps = new Map<string, number>()
|
||||||
// Dedup window for repeated decrypt-error console lines (Bad MAC / Counter / etc).
|
// Dedup window for repeated decrypt-error console lines (Bad MAC / Counter / etc).
|
||||||
|
|||||||
Reference in New Issue
Block a user