import { Boom } from '@hapi/boom' import type { Contact } from './Contact' export enum SyncState { /** The socket is connecting, but we haven't received pending notifications yet. */ Connecting, /** Pending notifications received. Buffering events until we decide whether to sync or not. */ AwaitingInitialSync, /** The initial app state sync (history, etc.) is in progress. Buffering continues. */ Syncing, /** Initial sync is complete, or was skipped. The socket is fully operational and events are processed in real-time. */ Online } export type WAConnectionState = 'open' | 'connecting' | 'close' export type ConnectionState = { /** connection is now open, connecting or closed */ connection: WAConnectionState /** the error that caused the connection to close */ lastDisconnect?: { // TODO: refactor and gain independence from Boom error: Boom | Error | undefined date: Date } /** is this a new login */ isNewLogin?: boolean /** the current QR code */ qr?: string /** has the device received all pending notifications while it was offline */ receivedPendingNotifications?: boolean /** legacy connection options */ legacy?: { phoneConnected: boolean user?: Contact } /** * if the client is shown as an active, online client. * If this is false, the primary phone and other devices will receive notifs * */ isOnline?: boolean /** * indicates the disconnect was caused by a session error (keys desynchronized). * When true, the consumer should recreate the socket with makeWASocket() * to establish a fresh session. */ isSessionError?: boolean }