allow custom pairing code (#1550)

This commit is contained in:
DevAstro
2025-06-25 13:05:12 +01:00
committed by GitHub
parent 38b4ada997
commit 60577cf8d3

View File

@@ -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: '~'