@violetix/baileys 0.5.2 → 0.5.3

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.
@@ -384,6 +384,15 @@ export const makeSocket = (config) => {
384
384
  };
385
385
  const ev = makeEventBuffer(logger);
386
386
  const { creds } = authState;
387
+ /**
388
+ * Last identity this socket has been logged in as. `sock.user` is a getter over
389
+ * `authState.creds.me`, and hosts read it as `sock.user.id` with no optional chaining (the
390
+ * @neoxr/wb engine does exactly that in serialize() and in its JID() helper). One stanza that
391
+ * arrives while `creds.me` is momentarily absent therefore throws inside the host's event
392
+ * listener instead of being processed. Keeping the identity we already know turns that into a
393
+ * correct answer: a socket that is receiving stanzas is logged in as this user.
394
+ */
395
+ let lastMe = creds.me;
387
396
  // add transaction capability
388
397
  const keys = addTransactionCapability(authState.keys, logger, transactionOpts);
389
398
  const signalRepository = makeSignalRepository({ creds, keys }, logger, pnFromLIDUSync);
@@ -1317,6 +1326,9 @@ export const makeSocket = (config) => {
1317
1326
  });
1318
1327
  }
1319
1328
  Object.assign(creds, update);
1329
+ if (creds.me) {
1330
+ lastMe = creds.me;
1331
+ }
1320
1332
  });
1321
1333
  const updateServerTimeOffset = ({ attrs }) => {
1322
1334
  const tValue = attrs?.t;
@@ -1396,7 +1408,7 @@ export const makeSocket = (config) => {
1396
1408
  authState: { creds, keys },
1397
1409
  signalRepository,
1398
1410
  get user() {
1399
- return authState.creds.me;
1411
+ return authState.creds.me ?? lastMe;
1400
1412
  },
1401
1413
  /**
1402
1414
  * True while the transport is repairing itself. A host that reads this does not build a
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@violetix/baileys",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
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",