socket,config: deprecate printQRInTerminal option

This was done to reduce dependencies
This commit is contained in:
Rajeh Taher
2025-03-10 15:08:50 +02:00
parent e1aadc5546
commit 1c2af09b03
6 changed files with 8 additions and 30 deletions

View File

@@ -67,7 +67,6 @@
"json": "^11.0.0",
"link-preview-js": "^3.0.0",
"open": "^8.4.2",
"qrcode-terminal": "^0.12.0",
"release-it": "^15.10.3",
"sharp": "^0.32.6",
"ts-jest": "^27.0.3",
@@ -79,7 +78,6 @@
"audio-decode": "^2.1.3",
"jimp": "^0.16.1",
"link-preview-js": "^3.0.0",
"qrcode-terminal": "^0.12.0",
"sharp": "^0.32.6"
},
"peerDependenciesMeta": {
@@ -92,9 +90,6 @@
"link-preview-js": {
"optional": true
},
"qrcode-terminal": {
"optional": true
},
"sharp": {
"optional": true
}

View File

@@ -42,7 +42,6 @@ export const DEFAULT_CONNECTION_CONFIG: SocketConfig = {
connectTimeoutMs: 20_000,
keepAliveIntervalMs: 30_000,
logger: logger.child({ class: 'baileys' }),
printQRInTerminal: false,
emitOwnEvents: true,
defaultQueryTimeoutMs: 60_000,
customUploadHosts: [],

View File

@@ -28,7 +28,6 @@ import {
getPlatformId,
makeEventBuffer,
makeNoiseHandler,
printQRIfNecessaryListener,
promiseTimeout,
} from '../Utils'
import {
@@ -65,6 +64,10 @@ export const makeSocket = (config: SocketConfig) => {
makeSignalRepository,
} = config
if(printQRInTerminal) {
console.warn('⚠️ The printQRInTerminal option has been deprecated. You will no longer receive QR codes in the terminal automatically. Please listen to the connection.update event yourself and handle the QR your way. You can remove this message by removing this opttion. This message will be removed in a future version.')
}
const url = typeof waWebSocketUrl === 'string' ? new URL(waWebSocketUrl) : waWebSocketUrl
@@ -732,9 +735,6 @@ export const makeSocket = (config: SocketConfig) => {
Object.assign(creds, update)
})
if(printQRInTerminal) {
printQRIfNecessaryListener(ev, logger)
}
return {
type: 'md' as 'md',

View File

@@ -48,8 +48,10 @@ export type SocketConfig = {
browser: WABrowserDescription
/** agent used for fetch requests -- uploading/downloading media */
fetchAgent?: Agent
/** should the QR be printed in the terminal */
printQRInTerminal: boolean
/** should the QR be printed in the terminal
* @deprecated This feature has been removed
*/
printQRInTerminal?: boolean
/** should events be emitted for actions done by this socket connection */
emitOwnEvents: boolean
/** custom upload hosts to upload media to */

View File

@@ -242,19 +242,6 @@ export function bindWaitForEvent<T extends keyof BaileysEventMap>(ev: BaileysEve
export const bindWaitForConnectionUpdate = (ev: BaileysEventEmitter) => bindWaitForEvent(ev, 'connection.update')
export const printQRIfNecessaryListener = (ev: BaileysEventEmitter, logger: ILogger) => {
ev.on('connection.update', async({ qr }) => {
if(qr) {
const QR = await import('qrcode-terminal')
.then(m => m.default || m)
.catch(() => {
logger.error('QR code terminal not added as dependency')
})
QR?.generate(qr, { small: true })
}
})
}
/**
* utility that fetches latest baileys version from the master branch.
* Use to ensure your WA connection is always on the latest version

View File

@@ -6030,11 +6030,6 @@ q@^1.5.1:
resolved "https://registry.yarnpkg.com/q/-/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7"
integrity sha512-kV/CThkXo6xyFEZUugw/+pIOywXcDbFYgSct5cT3gqlbkBE1SJdwy6UQoZvodiWF/ckQLZyDE/Bu1M6gVu5lVw==
qrcode-terminal@^0.12.0:
version "0.12.0"
resolved "https://registry.yarnpkg.com/qrcode-terminal/-/qrcode-terminal-0.12.0.tgz#bb5b699ef7f9f0505092a3748be4464fe71b5819"
integrity sha512-EXtzRZmC+YGmGlDFbXKxQiMZNwCLEO6BANKXG4iCtSIM0yqc/pappSx3RIKr4r0uh5JsBckOXeKrB3Iz7mdQpQ==
querystring@0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.0.tgz#b209849203bb25df820da756e747005878521620"