LID Migration & Safety
WhatsApp has migrated account identifiers from JIDs (s.whatsapp.net phone numbers) to LIDs (lid WhatsApp internal IDs).
To ensure compatibility during this transition and avoid encryption/session loops, UDMODZ Edition implements a comprehensive LID safety mechanism.
Configuration Optionsโ
These configurations are enabled by default in UDMODZ Edition:
const sock = makeWASocket({
auth: state,
// Automatically intercept ACKs with refresh_lid=true,
// migrating underlying Signal sessions to the new identity
enableLidMigrationSafety: true,
// Force-refresh phone number to LID mappings via USync
// when a migration notice is detected
refreshMappingOnLidMigration: true
})
How It Worksโ
- Safety Interception: When WhatsApp responds to a message ACK with
refresh_lid="true", the library intercepts the attributes. - Lookup & Cache Bypass: A forced USync lookup is scheduled, bypassing the normal LRU cache to verify the target JID's fresh LID.
- Session Migration: The library calls
signalRepository.migrateSession(pn, newLid)to move stored pre-keys and cryptographic session states. - Event Notification: The library triggers the
'lid-migration.update'event.
Listening to Migration Eventsโ
You can listen to 'lid-migration.update' to update JID structures in your databases/filesystems:
sock.ev.on('lid-migration.update', (migration) => {
console.log(`LID Migration detected for old JID: ${migration.oldLid}`)
console.log(`New JID (LID): ${migration.newLid}`)
console.log(`Associated Phone Number: ${migration.pn}`)
console.log(`Triggered by message ID: ${migration.messageId}`)
// Example: update contact references in your database
if (migration.newLid) {
updateContactLidInDatabase(migration.oldLid, migration.newLid)
}
})
Event Payload Schemaโ
export type LIDMigrationUpdate = {
oldLid: string // Stale LID or PN JID
newLid?: string // Newly resolved LID JID
pn?: string // Phone number JID
messageId?: string // ID of the message that triggered the refresh
reason: 'ack-refresh-lid'
}