@crysnovax/baileys 2.5.5 → 2.5.6
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.
- package/WAProto/index.js +3578 -14789
- package/lib/Defaults/index.js +11 -19
- package/lib/Signal/libsignal.js +18 -42
- package/lib/Socket/chats.js +91 -246
- package/lib/Socket/messages-recv.js +322 -618
- package/lib/Socket/messages-send.js +74 -174
- package/lib/Socket/newsletter.js +2 -2
- package/lib/Socket/socket.js +20 -12
- package/lib/Types/index.js +0 -1
- package/lib/Utils/index.js +0 -1
- package/lib/Utils/messages.js +114 -148
- package/lib/WABinary/constants.js +5 -99
- package/package.json +9 -43
- package/lib/Socket/Client//342/234/230 +0 -1
- package/lib/Socket//342/230/201/357/270/216 +0 -1
- package/lib/Types/Mex.js +0 -39
- package/lib/Types//342/234/206 +0 -1
- package/lib/Utils/use-sqlite-auth-state.js +0 -109
- package/lib/Utils//342/232/211 +0 -1
- package/lib/WABinary//342/216/231 +0 -1
package/lib/Defaults/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { proto } from '../../WAProto/index.js';
|
|
|
2
2
|
import { makeLibSignalRepository } from '../Signal/libsignal.js';
|
|
3
3
|
import { Browsers } from '../Utils/browser-utils.js';
|
|
4
4
|
import logger from '../Utils/logger.js';
|
|
5
|
-
const version = [2, 3000,
|
|
5
|
+
const version = [2, 3000, 1037013887];
|
|
6
6
|
export const UNAUTHORIZED_CODES = [401, 403, 419];
|
|
7
7
|
export const BIZ_BOT_SUPPORT_PAYLOAD = '{"version":1,"is_ai_message":true,"should_upload_client_logs":false,"should_show_system_message":false,"ticket_id":"7004947587700716","citation_items":[],"ticket_locale":"us"}';
|
|
8
8
|
export const DEFAULT_ORIGIN = 'https://web.whatsapp.com';
|
|
@@ -48,7 +48,7 @@ export const DEFAULT_CONNECTION_CONFIG = {
|
|
|
48
48
|
browser: Browsers.macOS('Chrome'),
|
|
49
49
|
waWebSocketUrl: 'wss://web.whatsapp.com/ws/chat',
|
|
50
50
|
connectTimeoutMs: 20000,
|
|
51
|
-
keepAliveIntervalMs:
|
|
51
|
+
keepAliveIntervalMs: 30000,
|
|
52
52
|
logger: logger.child({ class: 'baileys' }),
|
|
53
53
|
emitOwnEvents: true,
|
|
54
54
|
defaultQueryTimeoutMs: 60000,
|
|
@@ -66,7 +66,7 @@ export const DEFAULT_CONNECTION_CONFIG = {
|
|
|
66
66
|
shouldIgnoreJid: () => false,
|
|
67
67
|
linkPreviewImageThumbnailWidth: 192,
|
|
68
68
|
transactionOpts: { maxCommitRetries: 10, delayBetweenTriesMs: 3000 },
|
|
69
|
-
generateHighQualityLinkPreview:
|
|
69
|
+
generateHighQualityLinkPreview: false,
|
|
70
70
|
enableAutoSessionRecreation: true,
|
|
71
71
|
enableRecentMessageCache: true,
|
|
72
72
|
options: {},
|
|
@@ -87,16 +87,13 @@ export const MEDIA_PATH_MAP = {
|
|
|
87
87
|
sticker: '/mms/image',
|
|
88
88
|
'sticker-pack': '/mms/sticker-pack',
|
|
89
89
|
'thumbnail-sticker-pack': '/mms/thumbnail-sticker-pack',
|
|
90
|
-
'thumbnail-link': '/mms/
|
|
91
|
-
'thumbnail-image': '/mms/image',
|
|
92
|
-
'thumbnail-video': '/mms/video',
|
|
93
|
-
'thumbnail-document': '/mms/document',
|
|
90
|
+
'thumbnail-link': '/mms/thumbnail-link',
|
|
94
91
|
'product-catalog-image': '/product/image',
|
|
95
92
|
'md-app-state': '',
|
|
96
93
|
'md-msg-hist': '/mms/md-app-state',
|
|
97
94
|
'biz-cover-photo': '/pps/biz-cover-photo'
|
|
98
95
|
};
|
|
99
|
-
//
|
|
96
|
+
// Lia@Changes 06-02-26 --- Add newsletter media path for "/m1/" instead of "/o1/" (≧▽≦)
|
|
100
97
|
export const NEWSLETTER_MEDIA_PATH_MAP = {
|
|
101
98
|
image: '/newsletter/newsletter-image',
|
|
102
99
|
video: '/newsletter/newsletter-video',
|
|
@@ -123,26 +120,22 @@ export const MEDIA_HKDF_KEY_MAPPING = {
|
|
|
123
120
|
'thumbnail-link': 'Link Thumbnail',
|
|
124
121
|
'md-msg-hist': 'History',
|
|
125
122
|
'md-app-state': 'App State',
|
|
126
|
-
'product-catalog-image': '
|
|
123
|
+
'product-catalog-image': '',
|
|
127
124
|
'payment-bg-image': 'Payment Background',
|
|
128
125
|
ptv: 'Video',
|
|
129
|
-
'biz-cover-photo': 'Image'
|
|
130
|
-
location: 'Location',
|
|
131
|
-
contact: 'Contact',
|
|
132
|
-
'voip-token': 'Voip Token'
|
|
126
|
+
'biz-cover-photo': 'Image'
|
|
133
127
|
};
|
|
134
128
|
export const MEDIA_KEYS = Object.keys(MEDIA_PATH_MAP);
|
|
129
|
+
export const MIN_PREKEY_COUNT = 5;
|
|
130
|
+
export const INITIAL_PREKEY_COUNT = 812;
|
|
131
|
+
export const UPLOAD_TIMEOUT = 30000; // 30 seconds
|
|
132
|
+
export const MIN_UPLOAD_INTERVAL = 5000; // 5 seconds minimum between uploads
|
|
135
133
|
export const DEFAULT_CACHE_TTLS = {
|
|
136
134
|
SIGNAL_STORE: 5 * 60, // 5 minutes
|
|
137
135
|
MSG_RETRY: 60 * 60, // 1 hour
|
|
138
136
|
CALL_OFFER: 5 * 60, // 5 minutes
|
|
139
137
|
USER_DEVICES: 5 * 60 // 5 minutes
|
|
140
138
|
};
|
|
141
|
-
/** 120s timeout for history sync stall detection, same as WA Web's handleChunkProgress / restartPausedTimer (g = 120) */
|
|
142
|
-
export const HISTORY_SYNC_PAUSED_TIMEOUT_MS = 120000;
|
|
143
|
-
export const MIN_PREKEY_COUNT = 5;
|
|
144
|
-
export const INITIAL_PREKEY_COUNT = 812;
|
|
145
|
-
export const UPLOAD_TIMEOUT = 30000; // 30 seconds
|
|
146
139
|
export const TimeMs = {
|
|
147
140
|
Minute: 60 * 1000,
|
|
148
141
|
Hour: 60 * 60 * 1000,
|
|
@@ -153,4 +146,3 @@ export const BOT_RENDERING_CONFIG_METADATA = {
|
|
|
153
146
|
bloksVersioningId: '0903aa5f7f47de66789d5f4c86d3bd6e05e4bc3ff85e454a9f907d5ed7fef97c',
|
|
154
147
|
pixelDensity: 2.75
|
|
155
148
|
};
|
|
156
|
-
|
package/lib/Signal/libsignal.js
CHANGED
|
@@ -40,16 +40,6 @@ export function makeLibSignalRepository(auth, logger, pnToLIDFunc) {
|
|
|
40
40
|
ttlAutopurge: true,
|
|
41
41
|
updateAgeOnGet: true
|
|
42
42
|
});
|
|
43
|
-
const ensureSenderKeyAndCreateSkdm = async (group, meId) => {
|
|
44
|
-
const senderName = jidToSignalSenderKeyName(group, meId);
|
|
45
|
-
const senderNameStr = senderName.toString();
|
|
46
|
-
const { [senderNameStr]: senderKey } = await auth.keys.get('sender-key', [senderNameStr]);
|
|
47
|
-
if (!senderKey) {
|
|
48
|
-
await storage.storeSenderKey(senderName, new SenderKeyRecord());
|
|
49
|
-
}
|
|
50
|
-
const skdm = await new GroupSessionBuilder(storage).create(senderName);
|
|
51
|
-
return { senderName, skdm };
|
|
52
|
-
};
|
|
53
43
|
const repository = {
|
|
54
44
|
decryptGroupMessage({ group, authorJid, msg }) {
|
|
55
45
|
const senderName = jidToSignalSenderKeyName(group, authorJid);
|
|
@@ -122,43 +112,27 @@ export function makeLibSignalRepository(auth, logger, pnToLIDFunc) {
|
|
|
122
112
|
}, jid);
|
|
123
113
|
},
|
|
124
114
|
async encryptGroupMessage({ group, meId, data }) {
|
|
115
|
+
const senderName = jidToSignalSenderKeyName(group, meId);
|
|
116
|
+
const builder = new GroupSessionBuilder(storage);
|
|
117
|
+
const senderNameStr = senderName.toString();
|
|
125
118
|
return parsedKeys.transaction(async () => {
|
|
126
|
-
const {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
119
|
+
const { [senderNameStr]: senderKey } = await auth.keys.get('sender-key', [senderNameStr]);
|
|
120
|
+
if (!senderKey) {
|
|
121
|
+
await storage.storeSenderKey(senderName, new SenderKeyRecord());
|
|
122
|
+
}
|
|
123
|
+
const senderKeyDistributionMessage = await builder.create(senderName);
|
|
124
|
+
const session = new GroupCipher(storage, senderName);
|
|
125
|
+
const ciphertext = await session.encrypt(data);
|
|
126
|
+
return {
|
|
127
|
+
ciphertext,
|
|
128
|
+
senderKeyDistributionMessage: senderKeyDistributionMessage.serialize()
|
|
129
|
+
};
|
|
135
130
|
}, group);
|
|
136
131
|
},
|
|
137
|
-
async hasSenderKey({ group, meId }) {
|
|
138
|
-
const senderName = jidToSignalSenderKeyName(group, meId).toString();
|
|
139
|
-
const { [senderName]: key } = await auth.keys.get('sender-key', [senderName]);
|
|
140
|
-
return !!key;
|
|
141
|
-
},
|
|
142
|
-
async getSessionInfo(jid) {
|
|
143
|
-
const addr = jidToSignalProtocolAddress(jid).toString();
|
|
144
|
-
const session = (await storage.loadSession(addr));
|
|
145
|
-
if (!session) {
|
|
146
|
-
return null;
|
|
147
|
-
}
|
|
148
|
-
const open = session.getOpenSession?.();
|
|
149
|
-
const baseKey = open?.indexInfo?.baseKey;
|
|
150
|
-
const registrationId = open?.registrationId;
|
|
151
|
-
if (!baseKey || typeof registrationId !== 'number') {
|
|
152
|
-
return null;
|
|
153
|
-
}
|
|
154
|
-
return { baseKey: new Uint8Array(baseKey), registrationId };
|
|
155
|
-
},
|
|
156
132
|
async injectE2ESession({ jid, session }) {
|
|
157
133
|
logger.trace({ jid }, 'injecting E2EE session');
|
|
158
134
|
const cipher = new libsignal.SessionBuilder(storage, jidToSignalProtocolAddress(jid));
|
|
159
135
|
return parsedKeys.transaction(async () => {
|
|
160
|
-
// libsignal runtime accepts an absent prekey (initOutgoing checks `device.preKey && ...`)
|
|
161
|
-
// but the bundled .d.ts marks it required.
|
|
162
136
|
await cipher.initOutgoing(session);
|
|
163
137
|
}, jid);
|
|
164
138
|
},
|
|
@@ -197,7 +171,7 @@ export function makeLibSignalRepository(auth, logger, pnToLIDFunc) {
|
|
|
197
171
|
await auth.keys.set({ session: sessionUpdates });
|
|
198
172
|
}, `delete-${jids.length}-sessions`);
|
|
199
173
|
},
|
|
200
|
-
close() {
|
|
174
|
+
close () {
|
|
201
175
|
migratedSessionCache.clear();
|
|
202
176
|
lidMapping.close();
|
|
203
177
|
},
|
|
@@ -371,7 +345,9 @@ function signalStorage({ creds, keys }, lidMapping) {
|
|
|
371
345
|
saveIdentity: async (id, identityKey) => {
|
|
372
346
|
const wireJid = await resolveLIDSignalAddress(id);
|
|
373
347
|
const { [wireJid]: existingKey } = await keys.get('identity-key', [wireJid]);
|
|
374
|
-
const keysMatch = existingKey
|
|
348
|
+
const keysMatch = existingKey &&
|
|
349
|
+
existingKey.length === identityKey.length &&
|
|
350
|
+
existingKey.every((byte, i) => byte === identityKey[i]);
|
|
375
351
|
if (existingKey && !keysMatch) {
|
|
376
352
|
// Identity changed - clear session and update key
|
|
377
353
|
await keys.set({
|