From 1c2af09b03c607bbcc30a09386c72df749a544be Mon Sep 17 00:00:00 2001 From: Rajeh Taher Date: Mon, 10 Mar 2025 15:08:50 +0200 Subject: [PATCH] socket,config: deprecate printQRInTerminal option This was done to reduce dependencies --- package.json | 5 ----- src/Defaults/index.ts | 1 - src/Socket/socket.ts | 8 ++++---- src/Types/Socket.ts | 6 ++++-- src/Utils/generics.ts | 13 ------------- yarn.lock | 5 ----- 6 files changed, 8 insertions(+), 30 deletions(-) diff --git a/package.json b/package.json index c419dee..ad5db46 100644 --- a/package.json +++ b/package.json @@ -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 } diff --git a/src/Defaults/index.ts b/src/Defaults/index.ts index c72c213..e6792d6 100644 --- a/src/Defaults/index.ts +++ b/src/Defaults/index.ts @@ -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: [], diff --git a/src/Socket/socket.ts b/src/Socket/socket.ts index dc5f1c0..f6fdb95 100644 --- a/src/Socket/socket.ts +++ b/src/Socket/socket.ts @@ -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', diff --git a/src/Types/Socket.ts b/src/Types/Socket.ts index 61dfc5f..911dfee 100644 --- a/src/Types/Socket.ts +++ b/src/Types/Socket.ts @@ -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 */ diff --git a/src/Utils/generics.ts b/src/Utils/generics.ts index 178da67..4fbc9cb 100644 --- a/src/Utils/generics.ts +++ b/src/Utils/generics.ts @@ -242,19 +242,6 @@ export function bindWaitForEvent(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 diff --git a/yarn.lock b/yarn.lock index 999ddff..c4edd0f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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"