@violetix/baileys 0.5.2 → 0.5.4

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.
@@ -956,14 +956,16 @@ export const makeChatsSocket = (config) => {
956
956
  const upsertMessage = ev.createBufferedFunction(async (msg, type) => {
957
957
  ev.emit('messages.upsert', { messages: [msg], type });
958
958
  if (!!msg.pushName) {
959
- let jid = msg.key.fromMe ? authState.creds.me.id : msg.key.participant || msg.key.remoteJid;
959
+ let jid = msg.key.fromMe ? authState.creds.me?.id : msg.key.participant || msg.key.remoteJid;
960
960
  jid = jidNormalizedUser(jid);
961
961
  if (!msg.key.fromMe) {
962
962
  ev.emit('contacts.update', [{ id: jid, notify: msg.pushName, verifiedName: msg.verifiedBizName }]);
963
963
  }
964
964
  // update our pushname too
965
965
  if (msg.key.fromMe && msg.pushName && authState.creds.me?.name !== msg.pushName) {
966
- ev.emit('creds.update', { me: { ...authState.creds.me, name: msg.pushName } });
966
+ if (authState.creds.me?.id) {
967
+ ev.emit('creds.update', { me: { ...authState.creds.me, name: msg.pushName } });
968
+ }
967
969
  }
968
970
  }
969
971
  const historyMsg = getHistoryMsg(msg.message);
@@ -384,6 +384,16 @@ 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;
396
+ let userMissingLogged = false;
387
397
  // add transaction capability
388
398
  const keys = addTransactionCapability(authState.keys, logger, transactionOpts);
389
399
  const signalRepository = makeSignalRepository({ creds, keys }, logger, pnFromLIDUSync);
@@ -1185,6 +1195,11 @@ export const makeSocket = (config) => {
1185
1195
  logger.info('opened connection to WA');
1186
1196
  clearTimeout(qrTimer); // will never happen in all likelyhood -- but just in case WA sends success on first try
1187
1197
  ev.emit('creds.update', { me: { ...authState.creds.me, lid: node.attrs.lid } });
1198
+ if (!authState.creds.me?.id) {
1199
+ // `me` absent: the spread above produced a lid-only identity, which hosts then read as
1200
+ // `sock.user.id === undefined`. Say so once per socket instead of letting it look healthy.
1201
+ logger.error({ credsKeys: Object.keys(authState.creds), registered: authState.creds.registered, hasAccount: !!authState.creds.account }, 'login completed but creds.me.id is missing — host reads sock.user.id unguarded');
1202
+ }
1188
1203
  ev.emit('connection.update', { connection: 'open' });
1189
1204
  void sendUnifiedSession();
1190
1205
  if (node.attrs.lid && authState.creds.me?.id) {
@@ -1317,6 +1332,9 @@ export const makeSocket = (config) => {
1317
1332
  });
1318
1333
  }
1319
1334
  Object.assign(creds, update);
1335
+ if (creds.me) {
1336
+ lastMe = creds.me;
1337
+ }
1320
1338
  });
1321
1339
  const updateServerTimeOffset = ({ attrs }) => {
1322
1340
  const tValue = attrs?.t;
@@ -1396,7 +1414,20 @@ export const makeSocket = (config) => {
1396
1414
  authState: { creds, keys },
1397
1415
  signalRepository,
1398
1416
  get user() {
1399
- return authState.creds.me;
1417
+ const me = authState.creds.me ?? lastMe;
1418
+ if (!me && !userMissingLogged) {
1419
+ userMissingLogged = true;
1420
+ logger.error(
1421
+ {
1422
+ credsKeys: Object.keys(authState.creds),
1423
+ registered: authState.creds.registered,
1424
+ hasAccount: !!authState.creds.account,
1425
+ sameAuthObject: authState === config.auth
1426
+ },
1427
+ 'sock.user is undefined: creds.me never arrived on this socket (host reads sock.user.id unguarded)'
1428
+ );
1429
+ }
1430
+ return me;
1400
1431
  },
1401
1432
  /**
1402
1433
  * True while the transport is repairing itself. A host that reads this does not build a
@@ -732,7 +732,7 @@ export const processSyncAction = (syncAction, ev, me, initialSyncOpts, logger) =
732
732
  }
733
733
  else if (action?.pushNameSetting) {
734
734
  const name = action?.pushNameSetting?.name;
735
- if (name && me?.name !== name) {
735
+ if (name && me?.id && me?.name !== name) {
736
736
  ev.emit('creds.update', { me: { ...me, name } });
737
737
  }
738
738
  }
package/package.json CHANGED
@@ -1,125 +1,125 @@
1
1
  {
2
- "name": "@violetix/baileys",
3
- "version": "0.5.2",
4
- "description": "Enhanced Baileys v7 with fixes for newsletter media uploads, plus support for interactive messages, albums, and additional message types.",
5
- "main": "lib/index.js",
6
- "types": "lib/index.d.ts",
7
- "type": "module",
8
- "scripts": {
9
- "preinstall": "node ./engine-requirements.js",
10
- "test": "node --experimental-vm-modules --test",
11
- "test:types": "tsc -p tests/types/tsconfig.json",
12
- "check": "node scripts/check.mjs && npm run test:types && npm test",
13
- "prepublishOnly": "npm run check",
14
- "proto": "node scripts/generate-waproto.mjs"
15
- },
16
- "engines": {
17
- "node": ">=20.0.0"
18
- },
19
- "repository": {
20
- "type": "git",
21
- "url": "git+https://github.com/cv3inx/bv2.git"
22
- },
23
- "files": [
24
- "lib/**/*",
25
- "WAProto/**/*",
26
- "engine-requirements.js"
27
- ],
28
- "keywords": [
29
- "automation",
30
- "baileys",
31
- "bot",
32
- "interactive-messages",
33
- "js-whatsapp",
34
- "multi-device",
35
- "whatsapp",
36
- "whatsapp-api",
37
- "whatsapp-bot",
38
- "whatsapp-web"
39
- ],
40
- "homepage": "https://github.com/cv3inx/bv2#readme",
41
- "author": "Violetics",
42
- "contributors": [
43
- "Lia Wynn",
44
- "Rajeh Taher / WhiskeySockets"
45
- ],
46
- "license": "MIT",
47
- "publishConfig": {
48
- "access": "public"
49
- },
50
- "dependencies": {
51
- "@adiwajshing/keyed-db": "^0.2.4",
52
- "@cacheable/node-cache": "^1.4.0",
53
- "@hapi/boom": "^9.1.3",
54
- "async-mutex": "^0.5.0",
55
- "fflate": "^0.8.2",
56
- "libsignal": "^6.0.0",
57
- "lru-cache": "^11.2.6",
58
- "music-metadata": "^11.12.3",
59
- "p-queue": "^9.1.0",
60
- "pino": "^9.6.0",
61
- "protobufjs": "^7.5.6",
62
- "whatsapp-rust-bridge": "0.5.5",
63
- "ws": "^8.19.0"
64
- },
65
- "peerDependencies": {
66
- "@napi-rs/image": "~1.12.0",
67
- "audio-decode": "^2.2.3",
68
- "better-sqlite3": "^11.0.0",
69
- "jimp": "^1.6.1",
70
- "link-preview-js": "^3.0.0",
71
- "sharp": ">=0.33.0"
72
- },
73
- "peerDependenciesMeta": {
74
- "@napi-rs/image": {
75
- "optional": true
76
- },
77
- "audio-decode": {
78
- "optional": true
79
- },
80
- "better-sqlite3": {
81
- "optional": true
82
- },
83
- "jimp": {
84
- "optional": true
85
- },
86
- "link-preview-js": {
87
- "optional": true
88
- }
89
- },
90
- "resolutions": {
91
- "ajv@npm:^6.12.4": "^6.14.0",
92
- "basic-ftp": "^5.2.4",
93
- "brace-expansion@npm:^1.1.7": "^1.1.13",
94
- "brace-expansion@npm:^2.0.1": "^2.0.3",
95
- "flatted": "^3.4.2",
96
- "glob@npm:^10.2.2": "^10.5.0",
97
- "glob@npm:^10.3.10": "^10.5.0",
98
- "glob@npm:^10.5.0": "^10.5.0",
99
- "handlebars": "^4.7.9",
100
- "ip-address": "^10.1.1",
101
- "js-yaml@npm:^3.13.1": "^3.14.2",
102
- "js-yaml@npm:^4.1.0": "^4.1.1",
103
- "markdown-it": "^14.1.1",
104
- "minimatch@npm:^3.0.4": "^3.1.5",
105
- "minimatch@npm:^3.1.2": "^3.1.5",
106
- "minimatch@npm:^5.0.1": "^5.1.8",
107
- "minimatch@npm:^9.0.4": "^9.0.9",
108
- "minimatch@npm:^9.0.5": "^9.0.9",
109
- "picomatch@npm:^2.0.4": "^2.3.2",
110
- "picomatch@npm:^2.3.1": "^2.3.2",
111
- "picomatch@npm:^4.0.0": "^4.0.4",
112
- "picomatch@npm:^4.0.2": "^4.0.4",
113
- "socks": "^2.8.8",
114
- "tar": "^7.5.11",
115
- "tmp": "^0.2.5",
116
- "underscore": "^1.13.8",
117
- "yaml@npm:^2.6.1": "^2.8.4"
118
- },
119
- "packageManager": "yarn@4.9.2",
120
- "devDependencies": {
121
- "@types/node": "^20.19.43",
122
- "protobufjs-cli": "^1.3.3",
123
- "typescript": "^7.0.2"
124
- }
2
+ "name": "@violetix/baileys",
3
+ "version": "0.5.4",
4
+ "description": "Enhanced Baileys v7 with fixes for newsletter media uploads, plus support for interactive messages, albums, and additional message types.",
5
+ "main": "lib/index.js",
6
+ "types": "lib/index.d.ts",
7
+ "type": "module",
8
+ "scripts": {
9
+ "preinstall": "node ./engine-requirements.js",
10
+ "test": "node --experimental-vm-modules --test",
11
+ "test:types": "tsc -p tests/types/tsconfig.json",
12
+ "check": "node scripts/check.mjs && npm run test:types && npm test",
13
+ "prepublishOnly": "npm run check",
14
+ "proto": "node scripts/generate-waproto.mjs"
15
+ },
16
+ "engines": {
17
+ "node": ">=20.0.0"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/cv3inx/bv2.git"
22
+ },
23
+ "files": [
24
+ "lib/**/*",
25
+ "WAProto/**/*",
26
+ "engine-requirements.js"
27
+ ],
28
+ "keywords": [
29
+ "automation",
30
+ "baileys",
31
+ "bot",
32
+ "interactive-messages",
33
+ "js-whatsapp",
34
+ "multi-device",
35
+ "whatsapp",
36
+ "whatsapp-api",
37
+ "whatsapp-bot",
38
+ "whatsapp-web"
39
+ ],
40
+ "homepage": "https://github.com/cv3inx/bv2#readme",
41
+ "author": "Violetics",
42
+ "contributors": [
43
+ "Lia Wynn",
44
+ "Rajeh Taher / WhiskeySockets"
45
+ ],
46
+ "license": "MIT",
47
+ "publishConfig": {
48
+ "access": "public"
49
+ },
50
+ "dependencies": {
51
+ "@adiwajshing/keyed-db": "^0.2.4",
52
+ "@cacheable/node-cache": "^1.4.0",
53
+ "@hapi/boom": "^9.1.3",
54
+ "async-mutex": "^0.5.0",
55
+ "fflate": "^0.8.2",
56
+ "libsignal": "^6.0.0",
57
+ "lru-cache": "^11.2.6",
58
+ "music-metadata": "^11.12.3",
59
+ "p-queue": "^9.1.0",
60
+ "pino": "^9.6.0",
61
+ "protobufjs": "^7.5.6",
62
+ "whatsapp-rust-bridge": "0.5.5",
63
+ "ws": "^8.19.0"
64
+ },
65
+ "peerDependencies": {
66
+ "@napi-rs/image": "~1.12.0",
67
+ "audio-decode": "^2.2.3",
68
+ "better-sqlite3": "^11.0.0",
69
+ "jimp": "^1.6.1",
70
+ "link-preview-js": "^3.0.0",
71
+ "sharp": ">=0.33.0"
72
+ },
73
+ "peerDependenciesMeta": {
74
+ "@napi-rs/image": {
75
+ "optional": true
76
+ },
77
+ "audio-decode": {
78
+ "optional": true
79
+ },
80
+ "better-sqlite3": {
81
+ "optional": true
82
+ },
83
+ "jimp": {
84
+ "optional": true
85
+ },
86
+ "link-preview-js": {
87
+ "optional": true
88
+ }
89
+ },
90
+ "resolutions": {
91
+ "ajv@npm:^6.12.4": "^6.14.0",
92
+ "basic-ftp": "^5.2.4",
93
+ "brace-expansion@npm:^1.1.7": "^1.1.13",
94
+ "brace-expansion@npm:^2.0.1": "^2.0.3",
95
+ "flatted": "^3.4.2",
96
+ "glob@npm:^10.2.2": "^10.5.0",
97
+ "glob@npm:^10.3.10": "^10.5.0",
98
+ "glob@npm:^10.5.0": "^10.5.0",
99
+ "handlebars": "^4.7.9",
100
+ "ip-address": "^10.1.1",
101
+ "js-yaml@npm:^3.13.1": "^3.14.2",
102
+ "js-yaml@npm:^4.1.0": "^4.1.1",
103
+ "markdown-it": "^14.1.1",
104
+ "minimatch@npm:^3.0.4": "^3.1.5",
105
+ "minimatch@npm:^3.1.2": "^3.1.5",
106
+ "minimatch@npm:^5.0.1": "^5.1.8",
107
+ "minimatch@npm:^9.0.4": "^9.0.9",
108
+ "minimatch@npm:^9.0.5": "^9.0.9",
109
+ "picomatch@npm:^2.0.4": "^2.3.2",
110
+ "picomatch@npm:^2.3.1": "^2.3.2",
111
+ "picomatch@npm:^4.0.0": "^4.0.4",
112
+ "picomatch@npm:^4.0.2": "^4.0.4",
113
+ "socks": "^2.8.8",
114
+ "tar": "^7.5.11",
115
+ "tmp": "^0.2.5",
116
+ "underscore": "^1.13.8",
117
+ "yaml@npm:^2.6.1": "^2.8.4"
118
+ },
119
+ "packageManager": "yarn@4.9.2",
120
+ "devDependencies": {
121
+ "@types/node": "^20.19.43",
122
+ "protobufjs-cli": "^1.3.3",
123
+ "typescript": "^7.0.2"
124
+ }
125
125
  }