npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

chromestaff-baileys

v1.1.9

Published

baileys by filo e giuse

Readme

  ██████╗██╗  ██╗██████╗  ██████╗ ███╗   ███╗███████╗
 ██╔════╝██║  ██║██╔══██╗██╔═══██╗████╗ ████║██╔════╝
 ██║     ███████║██████╔╝██║   ██║██╔████╔██║█████╗
 ██║     ██╔══██║██╔══██╗██║   ██║██║╚██╔╝██║██╔══╝
 ╚██████╗██║  ██║██║  ██║╚██████╔╝██║ ╚═╝ ██║███████╗
  ╚═════╝╚═╝  ╚═╝╚═╝  ╚═╝ ╚═════╝ ╚═╝     ╚═╝╚══════╝
              s t a f f   b a i l e y s

Panoramica

Fork personalizzato di Baileys ottimizzato per il bot Chrome. Include patch per la stabilità WebSocket, gestione LID/JID corretta, pairing code funzionante e performance ottimizzate per uso su VPS.

Basato su @WhiskeySockets/Baileys — mantenuto da precisione.


📦 Installazione

npm install chromestaff-baileys

oppure direttamente da GitHub:

npm install github:precisione/chromestaff-baileys

Requisiti: Node.js ≥ 18, npm ≥ 8


⚡ Avvio Rapido

Connessione base

const makeWASocket = require('chromestaff-baileys')
const { useMultiFileAuthState, DisconnectReason } = require('chromestaff-baileys')

async function start() {
    const { state, saveCreds } = await useMultiFileAuthState('./auth')

    const sock = makeWASocket({
        auth: state,
        printQRInTerminal: true,
        browser: ['Chrome Bot', 'Safari', '17.0'],
        markOnlineOnConnect: false,
        syncFullHistory: false
    })

    sock.ev.on('creds.update', saveCreds)

    sock.ev.on('connection.update', ({ connection, lastDisconnect }) => {
        if (connection === 'close') {
            const code = lastDisconnect?.error?.output?.statusCode
            if (code !== DisconnectReason.loggedOut) start()
        }
    })

    sock.ev.on('messages.upsert', async ({ messages }) => {
        const msg = messages[0]
        if (!msg.message) return
        console.log('Messaggio:', msg.message?.conversation)
    })
}

start()

Con pairing code

const sock = makeWASocket({
    auth: state,
    printQRInTerminal: false,
    markOnlineOnConnect: false
})

if (!sock.authState.creds.registered) {
    const numero = '39XXXXXXXXXX'
    const code = await sock.requestPairingCode(numero)
    console.log('Codice:', code)
}

💬 Messaggi

Testo e media

// Testo semplice
await sock.sendMessage(jid, { text: 'ciao' })

// Testo con formattazione
await sock.sendMessage(jid, { text: '*grassetto* _corsivo_ ~barrato~ `monospace`' })

// Immagine
await sock.sendMessage(jid, {
    image: { url: './img.jpg' },
    caption: 'didascalia'
})

// Video
await sock.sendMessage(jid, {
    video: { url: './video.mp4' },
    caption: 'video',
    gifPlayback: false
})

// Audio / vocale
await sock.sendMessage(jid, {
    audio: { url: './audio.mp3' },
    mimetype: 'audio/mp4',
    ptt: true
})

// Documento
await sock.sendMessage(jid, {
    document: { url: './file.pdf' },
    mimetype: 'application/pdf',
    fileName: 'file.pdf'
})

// Album (più immagini)
await sock.sendMessage(jid, {
    album: buffers.map(b => ({ image: b }))
})

Risposta citata

await sock.sendMessage(jid, { text: 'risposta' }, { quoted: msg })

Reazione

await sock.sendMessage(jid, {
    react: { text: '🔥', key: msg.key }
})

Menzioni

await sock.sendMessage(jid, {
    text: '@utente controlla',
    mentions: ['[email protected]']
})

Pulsanti

await sock.sendMessage(jid, {
    text: 'Scegli:',
    footer: 'Chrome Bot',
    buttons: [
        { buttonId: 'opta', buttonText: { displayText: 'Opzione A' }, type: 1 },
        { buttonId: 'optb', buttonText: { displayText: 'Opzione B' }, type: 1 }
    ]
})

Lista

await sock.sendMessage(jid, {
    text: 'Menu disponibile',
    footer: 'Chrome Bot',
    title: 'Seleziona',
    buttonText: 'Apri menu',
    sections: [{
        title: 'Sezione 1',
        rows: [
            { title: 'Voce 1', rowId: 'v1', description: 'Descrizione' },
            { title: 'Voce 2', rowId: 'v2', description: 'Descrizione' }
        ]
    }]
})

Sondaggio

await sock.sendMessage(jid, {
    poll: {
        name: 'Domanda?',
        values: ['Opzione 1', 'Opzione 2', 'Opzione 3'],
        selectableCount: 1
    }
})

Pin messaggio

// Pinna
await sock.sendMessage(jid, {
    pin: { key: msg.key, type: 1, time: 86400 }
})

// Rimuovi pin
await sock.sendMessage(jid, {
    pin: { key: msg.key, type: 2 }
})

👥 Gruppi

// Crea gruppo
const group = await sock.groupCreate('Nome Gruppo', ['[email protected]'])

// Info gruppo
const meta = await sock.groupMetadata(jid)

// Aggiungi / rimuovi / promuovi / retrocedi
await sock.groupParticipantsUpdate(jid, ['[email protected]'], 'add')
await sock.groupParticipantsUpdate(jid, ['[email protected]'], 'remove')
await sock.groupParticipantsUpdate(jid, ['[email protected]'], 'promote')
await sock.groupParticipantsUpdate(jid, ['[email protected]'], 'demote')

// Impostazioni
await sock.groupUpdateSubject(jid, 'Nuovo Nome')
await sock.groupUpdateDescription(jid, 'Nuova descrizione')
await sock.groupSettingUpdate(jid, 'announcement')    // solo admin scrivono
await sock.groupSettingUpdate(jid, 'not_announcement') // tutti scrivono
await sock.groupSettingUpdate(jid, 'locked')           // solo admin modificano info
await sock.groupSettingUpdate(jid, 'unlocked')         // tutti modificano info

// Messaggi effimeri
await sock.groupToggleEphemeral(jid, 86400)   // 24h
await sock.groupToggleEphemeral(jid, 604800)  // 7 giorni
await sock.groupToggleEphemeral(jid, 0)       // disattiva

// Invito
const code = await sock.groupInviteCode(jid)
await sock.groupRevokeInvite(jid)
await sock.groupAcceptInvite(code)

// Esci
await sock.groupLeave(jid)

// Tutti i gruppi del bot
const groups = await sock.groupFetchAllParticipating()

🔧 LID / JID

WhatsApp usa sia JID (@s.whatsapp.net) che LID (@lid) per identificare gli utenti. Questa fork gestisce la conversione in modo trasparente.

const { getSenderLid, toJid, normalizeJid, validateJid } = require('chromestaff-baileys')

sock.ev.on('messages.upsert', async ({ messages }) => {
    const msg = messages[0]
    if (!msg.message) return

    const info = getSenderLid(msg)
    const validation = validateJid(info.jid)

    if (!validation.isValid) return

    const jid = toJid(info.lid)
    await sock.sendMessage(jid, { text: 'ricevuto' }, { quoted: msg })
})

Funzioni disponibili

| Funzione | Input | Output | Uso | |----------|-------|--------|-----| | getSenderLid(msg) | WAMessage | { jid, lid, user, isValid } | Estrae mittente | | toJid(lid) | string | string | Converte LID → JID | | normalizeJid(jid) | string | string | Normalizza formato | | validateJid(jid) | string | { isValid, error } | Valida JID |

Normalizzazione manuale

// Ottieni JID pulito da qualsiasi formato
const jid = normalizeJid('1234567890@lid')
// → '[email protected]'

// Controllo validità
const { isValid, error } = validateJid(jid)
if (!isValid) console.error('JID non valido:', error)

📚 API

makeWASocket(config)

Crea il socket WhatsApp. Opzioni principali:

makeWASocket({
    auth: state,                      // stato autenticazione (obbligatorio)
    printQRInTerminal: true,          // mostra QR nel terminale
    browser: ['NomeBot', 'Safari', '17.0'], // fingerprint browser
    markOnlineOnConnect: false,       // non mostrare "online" alla connessione
    syncFullHistory: false,           // non sincronizzare tutta la cronologia
    defaultQueryTimeoutMs: 60000,     // timeout query
    keepAliveIntervalMs: 30000,       // intervallo keepalive
    connectTimeoutMs: 60000,          // timeout connessione
    maxMsgRetryCount: 5,              // tentativi massimi per messaggio
    generateHighQualityLinkPreview: true
})

Eventi principali

| Evento | Descrizione | Payload | |--------|-------------|---------| | connection.update | Stato connessione | { connection, lastDisconnect, qr } | | creds.update | Aggiornamento credenziali | — | | messages.upsert | Nuovi messaggi | { messages, type } | | messages.update | Aggiornamento stato messaggi | WAMessageUpdate[] | | message-receipt.update | Ricevute lettura/consegna | MessageUserReceiptUpdate[] | | group-participants.update | Cambiamenti partecipanti | { id, participants, action } | | groups.update | Aggiornamento info gruppo | GroupMetadata[] | | contacts.update | Aggiornamento contatti | Partial<Contact>[] | | presence.update | Stato presenza utente | { id, presences } |

Gestione risposte interattive

sock.ev.on('messages.upsert', async ({ messages }) => {
    const msg = messages[0]

    if (msg.message?.buttonsResponseMessage) {
        const id = msg.message.buttonsResponseMessage.selectedButtonId
        // gestisci risposta pulsante
    }

    if (msg.message?.listResponseMessage) {
        const id = msg.message.listResponseMessage.singleSelectReply.selectedRowId
        // gestisci risposta lista
    }

    if (msg.message?.pollUpdateMessage) {
        // gestisci voto sondaggio
    }
})

⚙️ Configurazione consigliata per VPS

const sock = makeWASocket({
    auth: state,
    browser: ['Chrome Bot', 'Safari', '17.0'],
    markOnlineOnConnect: false,
    syncFullHistory: false,
    defaultQueryTimeoutMs: 60000,
    keepAliveIntervalMs: 25000,
    connectTimeoutMs: 60000,
    retryRequestDelayMs: 500,
    maxMsgRetryCount: 3
})

// Reconnect con backoff esponenziale
let attempts = 0

sock.ev.on('connection.update', ({ connection, lastDisconnect }) => {
    if (connection === 'close') {
        const code = lastDisconnect?.error?.output?.statusCode
        if (code === DisconnectReason.loggedOut) return

        attempts++
        const delay = Math.min(5000 * Math.pow(1.5, attempts - 1), 60000)
        setTimeout(start, delay)
    } else if (connection === 'open') {
        attempts = 0
    }
})

🐛 Problemi noti / fix inclusi

  • HTTP 405 — Risolto: regex fetchLatestWaWebVersion corretta, versione WA aggiornata dinamicamente all'avvio
  • Pairing code malformato — Risolto: uso di bytesToCrockford per la generazione corretta
  • WebSocket drop — Mitigato: keepalive ridotto, gestione errori migliorata
  • Mutex deadlock — Risolto: ristrutturazione del lock nelle operazioni concorrenti
  • Commenti nel bundle — Rimossi: pipeline Python di stripping integrata, con fix al parsing regex literal


📄 Licenza

MIT — © 2025 precisione

Basato su Baileys — non affiliato con WhatsApp Inc. o Meta.