@zervonex/baileys 3.0.3 → 3.0.5

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.
@@ -89,11 +89,11 @@ export const getButtonType = (message) => {
89
89
  if (message.listMessage) return 'list'
90
90
  if (message.buttonsMessage) return 'buttons'
91
91
  const interactiveMsg = message.interactiveMessage || message.interactive
92
- if (!interactiveMsg?.nativeFlowMessage) return null
93
- const btn = interactiveMsg?.nativeFlowMessage?.buttons?.[0]?.name
92
+ if (!interactiveMsg) return null
93
+ const btn = interactiveMsg.nativeFlowMessage?.buttons?.[0]?.name
94
94
  if (['review_and_pay', 'review_order', 'payment_info', 'payment_status', 'payment_method'].includes(btn)) return btn
95
- if (interactiveMsg?.nativeFlowMessage?.buttons?.length || interactiveMsg?.nativeFlowMessage) return 'interactive'
96
- return null
95
+ // any interactiveMessage subtype (nativeFlow, carousel, shop, collection, bloksWidget, etc.)
96
+ return 'interactive'
97
97
  }
98
98
 
99
99
  // ─── Biz Binary Node (canonical single implementation) ────────────────────────
@@ -114,8 +114,8 @@ const LIST_TYPE_CONTENT = { tag: 'list', attrs: { v: '2', type: 'product_list' }
114
114
  const DECISION_SOURCE = [{ tag: 'decision_source', attrs: { value: 'df' } }]
115
115
 
116
116
  export const getBizBinaryNode = (message) => {
117
- const flowMsg = message.interactiveMessage?.nativeFlowMessage
118
- const firstButtonName = flowMsg?.buttons?.[0]?.name
117
+
118
+ const firstButtonName = message.interactiveMessage?.nativeFlowMessage?.buttons?.[0]?.name
119
119
  const bizAttrs = { actual_actors: '2', host_storage: '2', privacy_mode_ts: `${Date.now() / 1000 | 0}` }
120
120
  const qualityContent = {
121
121
  tag: 'quality_control',
@@ -136,7 +136,9 @@ export const getBizBinaryNode = (message) => {
136
136
  ]
137
137
  }
138
138
  }
139
- if (flowMsg || message.buttonsMessage || message.templateMessage) {
139
+ // any interactiveMessage subtype (nativeFlowMessage, carouselMessage, shopStorefrontMessage,
140
+ // collectionMessage, bloksWidget, or anything WA adds in future) gets MIXED_NATIVE_FLOW
141
+ if (message.interactiveMessage || message.buttonsMessage || message.templateMessage) {
140
142
  return { tag: 'biz', attrs: bizAttrs, content: [MIXED_NATIVE_FLOW, qualityContent] }
141
143
  }
142
144
  if (message.listMessage) {
@@ -145,22 +147,44 @@ export const getBizBinaryNode = (message) => {
145
147
  return { tag: 'biz', attrs: bizAttrs, content: [qualityContent] }
146
148
  }
147
149
 
148
- // Legacy alias — kept for back-compat, delegates to canonical getBizBinaryNode
150
+ // Legacy alias — kept for back-compat, used by messages-send.js
151
+ // Note: messages-send.js already calls normalizeMessageContent before passing in,
152
+ // so the viewOnceMessage unwrap here is a safety net only.
149
153
  export const getButtonArgs = (message) => {
150
154
  const msgContent = message.viewOnceMessage?.message || message
151
155
  const interactiveMsg = msgContent.interactiveMessage || msgContent.interactive
152
- const flowMsg = interactiveMsg?.nativeFlowMessage
153
- const btnFirst = flowMsg?.buttons?.[0]?.name
156
+ const firstButtonName = interactiveMsg?.nativeFlowMessage?.buttons?.[0]?.name
154
157
  const ts = Math.floor(Date.now() / 1000) - 77980457
155
- const order_response_name = { review_and_pay: 'order_details', review_order: 'order_status', payment_info: 'payment_info', payment_status: 'payment_status', payment_method: 'payment_method' }
156
- const flow_name = { cta_catalog: 'cta_catalog', mpm: 'mpm', call_permission_request: 'call_permission_request', call_request: 'call_permission_request', view_catalog: 'automated_greeting_message_view_catalog', automated_greeting_message_view_catalog: 'automated_greeting_message_view_catalog', wa_pay_detail: 'wa_payment_transaction_details', wa_payment_transaction_details: 'wa_payment_transaction_details', send_location: 'send_location', open_webview: 'open_webview', galaxy_message: 'galaxy_message' }
157
- if (btnFirst && order_response_name[btnFirst]) return [{ tag: 'biz', attrs: { native_flow_name: order_response_name[btnFirst] }, content: [] }]
158
- if (flowMsg || msgContent.buttonsMessage) {
159
- const name = (btnFirst && flow_name[btnFirst]) ? flow_name[btnFirst] : 'mixed'
160
- return [{ tag: 'biz', attrs: { actual_actors: '2', host_storage: '2', privacy_mode_ts: `${ts}` }, content: [{ tag: 'engagement', attrs: { customer_service_state: 'open', conversation_state: 'open' } }, { tag: 'interactive', attrs: { type: 'native_flow', v: '1' }, content: [{ tag: 'native_flow', attrs: { v: '9', name }, content: [] }] }] }]
158
+ const bizAttrs = { actual_actors: '2', host_storage: '2', privacy_mode_ts: `${ts}` }
159
+ const engagementNode = { tag: 'engagement', attrs: { customer_service_state: 'open', conversation_state: 'open' } }
160
+
161
+ const order_response_name = {
162
+ review_and_pay: 'order_details', review_order: 'order_status',
163
+ payment_info: 'payment_info', payment_status: 'payment_status',
164
+ payment_method: 'payment_method'
165
+ }
166
+ const flow_name = {
167
+ cta_catalog: 'cta_catalog', mpm: 'mpm',
168
+ call_permission_request: 'call_permission_request', call_request: 'call_permission_request',
169
+ view_catalog: 'automated_greeting_message_view_catalog',
170
+ automated_greeting_message_view_catalog: 'automated_greeting_message_view_catalog',
171
+ wa_pay_detail: 'wa_payment_transaction_details',
172
+ wa_payment_transaction_details: 'wa_payment_transaction_details',
173
+ send_location: 'send_location', open_webview: 'open_webview', galaxy_message: 'galaxy_message'
174
+ }
175
+
176
+ if (firstButtonName && order_response_name[firstButtonName]) {
177
+ return [{ tag: 'biz', attrs: { native_flow_name: order_response_name[firstButtonName] }, content: [] }]
178
+ }
179
+ // any interactiveMessage subtype or buttonsMessage gets an interactive native_flow node
180
+ if (interactiveMsg || msgContent.buttonsMessage) {
181
+ const name = (firstButtonName && flow_name[firstButtonName]) ? flow_name[firstButtonName] : 'mixed'
182
+ return [{ tag: 'biz', attrs: bizAttrs, content: [engagementNode, { tag: 'interactive', attrs: { type: 'native_flow', v: '1' }, content: [{ tag: 'native_flow', attrs: { v: '9', name }, content: [] }] }] }]
161
183
  }
162
- if (msgContent.listMessage) return [{ tag: 'biz', attrs: { actual_actors: '2', host_storage: '2', privacy_mode_ts: `${ts}` }, content: [{ tag: 'engagement', attrs: { customer_service_state: 'open', conversation_state: 'open' } }] }]
163
- return [{ tag: 'biz', attrs: { actual_actors: '2', host_storage: '2', privacy_mode_ts: `${ts}` }, content: [{ tag: 'engagement', attrs: { customer_service_state: 'open', conversation_state: 'open' } }] }]
184
+ if (msgContent.listMessage) {
185
+ return [{ tag: 'biz', attrs: bizAttrs, content: [engagementNode] }]
186
+ }
187
+ return [{ tag: 'biz', attrs: bizAttrs, content: [engagementNode] }]
164
188
  }
165
189
 
166
190
  // ─── Debug Utilities ──────────────────────────────────────────────────────────
@@ -176,4 +200,4 @@ export const binaryNodeToString = (node, i = 0) => {
176
200
  const tag = `<${node.tag} ${Object.entries(node.attrs || {}).filter(([, v]) => v !== undefined).map(([k, v]) => `${k}='${v}'`).join(' ')}`
177
201
  const content = children ? `>\n${children}\n${tabs(i)}</${node.tag}>` : '/>'
178
202
  return tag + content
179
- }
203
+ }
package/lib/index.js CHANGED
@@ -29,7 +29,7 @@ const info = [
29
29
  '╭──────────────────────────────────────────────────────────────╮',
30
30
  '│ │',
31
31
  '│ ◆ Package › @zervonex/baileys │',
32
- '│ ◆ Version › 3.0.3 │',
32
+ '│ ◆ Version › 3.0.5 │',
33
33
  '│ ◆ Status › Production Ready │',
34
34
  '│ │',
35
35
  '├──────────────────────────── ◇◆◇ ─────────────────────────────┤',
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@zervonex/baileys",
4
4
  "type": "module",
5
- "version": "3.0.3",
5
+ "version": "3.0.5",
6
6
  "description": "Advanced WhatsApp Web API built on Baileys — interactive messages, buttons, carousels, products, events, payments, polls, albums, sticker packs and more.",
7
7
  "keywords": [
8
8
  "baileys",
@@ -72,138 +72,104 @@
72
72
  "license": "MIT",
73
73
  "author": "zervonex",
74
74
  "main": "lib/index.js",
75
- "types": "lib/index.d.ts",
76
75
  "scripts": {
77
- "build:all": "tsc && typedoc",
78
- "build:docs": "typedoc",
79
- "build:tsc": "tsc",
80
76
  "generate:license": "npx license",
81
- "changelog:last": "conventional-changelog -p angular -r 2",
82
- "changelog:preview": "conventional-changelog -p angular -u",
83
- "changelog:update": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
84
- "example": "node --inspect -r ts-node/register Example/example.ts",
85
- "gen:protobuf": "sh WAProto/GenerateStatics.sh",
86
- "lint": "eslint src --ext .js,.ts,.jsx,.tsx",
87
- "lint:fix": "eslint src --fix --ext .js,.ts,.jsx,.tsx",
77
+ "gen:protobuf": "node ./WAProto/index.js",
88
78
  "prepack": "echo 'Zervonex WhatsApp Library'",
89
79
  "prepare": "echo 'Zervonex WhatsApp Library'",
90
80
  "preinstall": "node ./engine-requirements.js",
91
- "release": "release-it",
92
- "test": "jest"
81
+ "test": "node ./lib/index.js"
93
82
  },
94
83
  "files": [
95
84
  "lib/**/*.js",
96
85
  "lib/**/*.json",
97
- "lib/**/*.d.ts",
98
- "lib/**/*.map",
99
86
  "WAProto/**/*.js",
100
87
  "WAProto/**/*.json",
101
- "WAProto/**/*.d.ts",
102
- "WAProto/**/*.sh",
103
88
  "engine-requirements.js"
104
89
  ],
105
90
  "dependencies": {
106
91
  "@adiwajshing/keyed-db": "^0.2.4",
107
- "@cacheable/node-cache": "^1.4.0",
108
- "@hapi/boom": "^9.1.3",
109
- "@keyv/etcd": "^2.1.1",
110
- "@keyv/memcache": "^2.0.2",
111
- "@keyv/mongo": "^3.1.0",
112
- "@keyv/mysql": "^2.1.10",
113
- "@keyv/postgres": "^2.2.3",
114
- "@keyv/redis": "^5.1.6",
115
- "@keyv/sqlite": "^4.0.8",
92
+ "@cacheable/node-cache": "^3.1.1",
93
+ "@hapi/boom": "^10.0.1",
94
+ "@keyv/etcd": "^6.1.0",
95
+ "@keyv/memcache": "^6.1.0",
96
+ "@keyv/mongo": "^6.1.0",
97
+ "@keyv/mysql": "^6.1.0",
98
+ "@keyv/postgres": "^6.1.0",
99
+ "@keyv/redis": "^6.1.0",
100
+ "@keyv/sqlite": "^6.1.0",
116
101
  "acorn": "^8.18.0",
117
102
  "acorn-walk": "^8.3.5",
118
103
  "async-mutex": "^0.5.0",
119
- "axios": "^1.6.0",
120
- "cache-manager": "latest",
104
+ "axios": "^1.20.0",
105
+ "cache-manager": "^7.2.9",
121
106
  "fflate": "^0.8.2",
122
107
  "ffmpeg-static": "^5.3.0",
123
- "file-type": "^22.0.1",
124
- "gradient-string": "^2.0.2",
125
- "keyv": "^5.6.0",
108
+ "file-type": "^22.2.0",
109
+ "gradient-string": "^3.0.0",
110
+ "keyv": "^6.1.0",
126
111
  "libphonenumber-js": "^1.13.3",
127
112
  "lru-cache": "^11.1.0",
128
- "music-metadata": "^11.7.0",
129
- "p-queue": "^9.0.0",
130
- "pino": "^9.6",
113
+ "music-metadata": "^12.3.0",
114
+ "p-queue": "^10.0.0",
115
+ "pino": "^10.4.0",
131
116
  "prismjs": "^1.30.0",
132
- "protobufjs": "latest",
117
+ "protobufjs": "^8.8.1",
133
118
  "qrcode-terminal": "^0.12.0",
134
119
  "rlottie": "^0.1.2",
135
- "undici": "^8.10.1",
120
+ "undici": "^8.12.3",
136
121
  "unfurl.js": "^6.4.0",
137
122
  "url-regex-safe": "^4.0.0",
138
- "uuid": "latest",
123
+ "uuid": "^14.0.3",
139
124
  "wa-sticker-formatter": "^4.4.4",
140
125
  "whatsapp-rust-bridge": "^0.5.5",
141
- "ws": "latest"
142
- },
143
- "devDependencies": {
144
- "@eslint/eslintrc": "^3.3.1",
145
- "@eslint/js": "^9.31.0",
146
- "@types/jest": "^30.0.0",
147
- "@types/node": "^20.9.0",
148
- "@types/sharp": "^0.31.1",
149
- "@types/ws": "^8.0.0",
150
- "@typescript-eslint/eslint-plugin": "^8",
151
- "@typescript-eslint/parser": "^8",
152
- "@whiskeysockets/eslint-config": "^1.0.0",
153
- "conventional-changelog": "^7.1.1",
154
- "conventional-changelog-angular": "^8.0.0",
155
- "esbuild-register": "^3.6.0",
156
- "eslint": "^9",
157
- "eslint-config-prettier": "^10.1.2",
158
- "eslint-plugin-prettier": "^5.4.0",
159
- "jest": "^25.0.0",
160
- "jimp": "^1.6.0",
161
- "jiti": "^2.4.2",
162
- "json": "^11.0.0",
163
- "lru-cache": "^11.1.0",
164
- "open": "^8.4.2",
165
- "pino-pretty": "^13.1.1",
166
- "prettier": "^3.5.3",
167
- "protobufjs-cli": "^1.1.3",
168
- "release-it": "^21.1.1",
169
- "ts-jest": "^27.0.3",
170
- "ts-node": "^10.9.2",
171
- "tsc-esm-fix": "^2.20.27",
172
- "tsup": "^8.5.1",
173
- "tsx": "^4.20.3",
174
- "typedoc": "^0.27.9",
175
- "typedoc-plugin-markdown": "4.4.2",
176
- "typescript": "^5.8.2"
177
- },
178
- "peerDependencies": {
179
- "jimp": "*",
180
- "sharp": "*"
181
- },
182
- "peerDependenciesMeta": {
183
- "jimp": {
184
- "optional": true
185
- },
186
- "sharp": {
187
- "optional": true
188
- }
126
+ "ws": "^8.22.0"
189
127
  },
190
128
  "overrides": {
191
129
  "wa-sticker-formatter": {
192
- "sharp": "^0.33.5",
193
- "axios": "^1.6.0",
194
- "file-type": "^22.0.1",
195
- "image-size": "^2.0.0"
130
+ "sharp": "^0.35.5",
131
+ "axios": "^1.20.0",
132
+ "file-type": "^22.2.0",
133
+ "image-size": "^2.0.4"
196
134
  },
135
+ "jest": "^29.0.0",
197
136
  "tar": "^7.5.22",
198
- "@tootallnate/once": "^3.0.1"
137
+ "@tootallnate/once": "^3.0.1",
138
+ "image-size": "^2.0.4",
139
+ "sqlite3": "^6.0.1",
140
+ "cacache": "^19.0.1",
141
+ "axios": "^1.20.0",
142
+ "file-type": "^22.2.0",
143
+ "sharp": "^0.35.5",
144
+ "release-it": {
145
+ "undici": "^8.12.3",
146
+ "basic-ftp": "^6.2.3"
147
+ },
148
+ "jimp": {
149
+ "file-type": "^22.2.0"
150
+ },
151
+ "esbuild": "^0.28.2",
152
+ "basic-ftp": "^6.2.3",
153
+ "music-metadata": {
154
+ "file-type": "^22.2.0"
155
+ },
156
+ "@jimp/core": {
157
+ "file-type": "^22.2.0"
158
+ }
199
159
  },
200
160
  "resolutions": {
201
- "wa-sticker-formatter/sharp": "^0.33.5",
202
- "wa-sticker-formatter/axios": "^1.6.0",
203
- "wa-sticker-formatter/file-type": "^22.0.1",
204
- "wa-sticker-formatter/image-size": "^2.0.0",
161
+ "wa-sticker-formatter/sharp": "^0.35.5",
162
+ "wa-sticker-formatter/axios": "^1.20.0",
163
+ "wa-sticker-formatter/file-type": "^22.2.0",
164
+ "wa-sticker-formatter/image-size": "^2.0.4",
205
165
  "tar": "^7.5.22",
206
- "@tootallnate/once": "^3.0.1"
166
+ "@tootallnate/once": "^3.0.1",
167
+ "image-size": "^2.0.4",
168
+ "sqlite3": "^6.0.1",
169
+ "cacache": "^19.0.1",
170
+ "axios": "^1.20.0",
171
+ "file-type": "^22.2.0",
172
+ "sharp": "^0.35.5"
207
173
  },
208
174
  "packageManager": "yarn@4.9.2",
209
175
  "engines": {
@@ -212,7 +178,6 @@
212
178
  "exports": {
213
179
  ".": {
214
180
  "import": "./lib/index.js",
215
- "require": "./lib/index.cjs",
216
181
  "default": "./lib/index.js"
217
182
  },
218
183
  "./lib/*": "./lib/*",