mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
allow custom pairing code (#1550)
This commit is contained in:
@@ -459,8 +459,15 @@ export const makeSocket = (config: SocketConfig) => {
|
||||
end(new Boom(msg || 'Intentional Logout', { statusCode: DisconnectReason.loggedOut }))
|
||||
}
|
||||
|
||||
const requestPairingCode = async (phoneNumber: string): Promise<string> => {
|
||||
authState.creds.pairingCode = bytesToCrockford(randomBytes(5))
|
||||
const requestPairingCode = async (phoneNumber: string, customPairingCode?: string): Promise<string> => {
|
||||
const pairingCode = customPairingCode ?? bytesToCrockford(randomBytes(5))
|
||||
|
||||
if (customPairingCode && customPairingCode?.length !== 8) {
|
||||
throw new Error('Custom pairing code must be exactly 8 chars')
|
||||
}
|
||||
|
||||
authState.creds.pairingCode = pairingCode
|
||||
|
||||
authState.creds.me = {
|
||||
id: jidEncode(phoneNumber, 's.whatsapp.net'),
|
||||
name: '~'
|
||||
|
||||
Reference in New Issue
Block a user