@blurose/baileys 1.1.9 → 1.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -594,9 +594,12 @@ export const makeSocket = (config) => {
594
594
  void end(new Boom(msg || 'Intentional Logout', { statusCode: DisconnectReason.loggedOut }));
595
595
  };
596
596
  const requestPairingCode = async (phoneNumber, customPairingCode) => {
597
- const pairingCode = customPairingCode ?? bytesToCrockford(randomBytes(5));
598
- if (customPairingCode && customPairingCode?.length !== 8) {
599
- throw new Error('Custom pairing code must be exactly 8 chars');
597
+ let pairingCode = customPairingCode ?? bytesToCrockford(randomBytes(5));
598
+ if (customPairingCode) {
599
+ // Blurose Auto-Formatter: ensure pairing code is exactly 8 chars
600
+ pairingCode = customPairingCode.replace(/[^a-zA-Z0-9]/g, '').toUpperCase();
601
+ if (pairingCode.length > 8) pairingCode = pairingCode.substring(0, 8);
602
+ while (pairingCode.length < 8) pairingCode += '0';
600
603
  }
601
604
  authState.creds.pairingCode = pairingCode;
602
605
  authState.creds.me = {
@@ -115,6 +115,15 @@ export const useMultiFileAuthState = async (folder) => {
115
115
  },
116
116
  saveCreds: async () => {
117
117
  return writeData(creds, 'creds.json');
118
+ },
119
+ clearPreKeys: async () => {
120
+ try {
121
+ const files = await (0, fs_1.readdir)(folder);
122
+ const preKeyFiles = files.filter(f => f.startsWith('pre-key-') && f !== 'pre-key-record');
123
+ await Promise.all(preKeyFiles.map(f => removeData(f)));
124
+ } catch (err) {
125
+ // ignore if folder doesn't exist
126
+ }
118
127
  }
119
128
  };
120
129
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@blurose/baileys",
3
3
  "type": "module",
4
- "version": "1.1.9",
4
+ "version": "1.1.10",
5
5
  "description": "A WebSockets library for interacting with WhatsApp Web",
6
6
  "keywords": [
7
7
  "whatsapp",