@violetix/baileys 0.5.5 → 0.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.
@@ -392,7 +392,10 @@ export const makeSocket = (config) => {
392
392
  * listener instead of being processed. Keeping the identity we already know turns that into a
393
393
  * correct answer: a socket that is receiving stanzas is logged in as this user.
394
394
  */
395
- let lastMe = creds.me;
395
+ // A copy, and only when it carries an id: `creds.me` is replaced wholesale by some updates (a
396
+ // `CB:success` or a pushName change can arrive with a lid-only object), and holding the same
397
+ // reference would follow that replacement into the fallback.
398
+ let lastMe = creds.me?.id ? { ...creds.me } : undefined;
396
399
  let userMissingLogged = false;
397
400
  // add transaction capability
398
401
  const keys = addTransactionCapability(authState.keys, logger, transactionOpts);
@@ -1332,8 +1335,8 @@ export const makeSocket = (config) => {
1332
1335
  });
1333
1336
  }
1334
1337
  Object.assign(creds, update);
1335
- if (creds.me) {
1336
- lastMe = creds.me;
1338
+ if (creds.me?.id) {
1339
+ lastMe = { ...creds.me };
1337
1340
  }
1338
1341
  });
1339
1342
  const updateServerTimeOffset = ({ attrs }) => {
@@ -1414,7 +1417,9 @@ export const makeSocket = (config) => {
1414
1417
  authState: { creds, keys },
1415
1418
  signalRepository,
1416
1419
  get user() {
1417
- const me = authState.creds.me ?? lastMe;
1420
+ // `.id`, not just presence: a lid-only `me` is truthy and would be handed to hosts that
1421
+ // read `.id` unguarded, which is the crash this fallback exists to prevent.
1422
+ const me = authState.creds.me?.id ? authState.creds.me : lastMe;
1418
1423
  if (!me && !userMissingLogged) {
1419
1424
  userMissingLogged = true;
1420
1425
  logger.error(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@violetix/baileys",
3
- "version": "0.5.5",
3
+ "version": "0.5.6",
4
4
  "description": "Enhanced Baileys v7 with fixes for newsletter media uploads, plus support for interactive messages, albums, and additional message types.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",