violetics 7.0.6-alpha → 7.0.7-alpha

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.
@@ -1,6 +1,7 @@
1
1
  import { Boom } from '@hapi/boom';
2
+ import { randomBytes } from 'crypto';
2
3
  import { proto } from '../../WAProto/index.js';
3
- import { } from './types.js';
4
+ import {} from './types.js';
4
5
  // some extra useful utilities
5
6
  const indexCache = new WeakMap();
6
7
  export const getBinaryNodeChildren = (node, childTag) => {
@@ -131,80 +132,96 @@ const FLOWS_MAP = {
131
132
  wa_payment_transaction_details: true,
132
133
  automated_greeting_message_view_catalog: true
133
134
  };
134
- const qualityAttribute = {
135
- tag: 'quality_control',
136
- attrs: { source_type: 'third_party' }
137
- };
138
- const defaultContent = [qualityAttribute]
139
- const listContent = [
135
+ const DECISION_SOURCE_CONTENT = [
140
136
  {
141
- tag: 'list',
142
- attrs: { v: '2', type: 'product_list' }
143
- },
144
- qualityAttribute
137
+ tag: 'decision_source',
138
+ attrs: { value: 'df' }
139
+ }
145
140
  ];
146
- export const getBizBinaryNode = (message) => {
141
+ const LIST_TYPE_CONTENT = {
142
+ tag: 'list',
143
+ attrs: { v: '2', type: 'product_list' }
144
+ };
145
+ const NATIVE_FLOW_ATTRIBUTE = { type: 'native_flow', v: '1' };
146
+ const MIXED_NATIVE_FLOW = {
147
+ tag: 'interactive',
148
+ attrs: NATIVE_FLOW_ATTRIBUTE,
149
+ content: [
150
+ {
151
+ tag: 'native_flow',
152
+ attrs: { v: '9', name: 'mixed' }
153
+ }
154
+ ]
155
+ };
156
+ export const getBizBinaryNode = (message, addBizAttributes) => {
157
+ const bizAttributes = {};
147
158
  const flowMsg = message.interactiveMessage?.nativeFlowMessage;
148
- const buttonName = flowMsg?.buttons?.[0]?.name;
149
- if (buttonName === 'review_and_pay' || buttonName === 'payment_info') {
159
+ const firstButtonName = flowMsg?.buttons?.[0]?.name;
160
+ const qualityContent = {
161
+ tag: 'quality_control',
162
+ attrs: {
163
+ decision_id: randomBytes(20).toString('hex'),
164
+ source_type: 'third_party'
165
+ },
166
+ content: DECISION_SOURCE_CONTENT
167
+ };
168
+ if (addBizAttributes) {
169
+ bizAttributes.actual_actors = '2';
170
+ bizAttributes.host_storage = '2';
171
+ bizAttributes.privacy_mode_ts = `${Date.now() / 1_000 | 0}`;
172
+ }
173
+ if (firstButtonName === 'review_and_pay' || firstButtonName === 'payment_info') {
174
+ bizAttributes.native_flow_name = firstButtonName === 'review_and_pay' ?
175
+ 'order_details' :
176
+ firstButtonName;
150
177
  return {
151
178
  tag: 'biz',
152
- attrs: {
153
- native_flow_name: buttonName === 'review_and_pay' ?
154
- 'order_details' :
155
- buttonName
156
- },
157
- content: defaultContent
179
+ attrs: bizAttributes,
180
+ content: [qualityContent]
158
181
  };
159
182
  }
160
- if (buttonName && FLOWS_MAP[buttonName]) {
183
+ if (firstButtonName && FLOWS_MAP[firstButtonName]) {
161
184
  return {
162
185
  tag: 'biz',
163
- attrs: {},
186
+ attrs: bizAttributes,
164
187
  content: [
165
188
  {
166
189
  tag: 'interactive',
167
- attrs: { type: 'native_flow', v: '1' },
190
+ attrs: NATIVE_FLOW_ATTRIBUTE,
168
191
  content: [
169
192
  {
170
193
  tag: 'native_flow',
171
- attrs: { v: '2', name: buttonName }
194
+ attrs: { v: '2', name: firstButtonName }
172
195
  }
173
196
  ]
174
197
  },
175
- qualityAttribute
198
+ qualityContent
176
199
  ]
177
200
  };
178
201
  }
179
202
  if (flowMsg || message.buttonsMessage || message.templateMessage) {
180
203
  return {
181
204
  tag: 'biz',
182
- attrs: {},
205
+ attrs: bizAttributes,
183
206
  content: [
184
- {
185
- tag: 'interactive',
186
- attrs: { type: 'native_flow', v: '1' },
187
- content: [
188
- {
189
- tag: 'native_flow',
190
- attrs: { v: '9', name: 'mixed' }
191
- }
192
- ]
193
- },
194
- qualityAttribute
207
+ MIXED_NATIVE_FLOW,
208
+ qualityContent
195
209
  ]
196
210
  };
197
211
  }
198
212
  if (message.listMessage) {
199
213
  return {
200
214
  tag: 'biz',
201
- attrs: {},
202
- content: listContent
215
+ attrs: bizAttributes,
216
+ content: [
217
+ LIST_TYPE_CONTENT,
218
+ qualityContent
219
+ ]
203
220
  };
204
221
  }
205
222
  return {
206
223
  tag: 'biz',
207
- attrs: {},
208
- content: defaultContent
224
+ attrs: bizAttributes,
225
+ content: [qualityContent]
209
226
  };
210
227
  }
@@ -25,7 +25,7 @@ export const getServerFromDomainType = (initialServer, domainType) => {
25
25
  }
26
26
  };
27
27
  export const jidEncode = (user, server, device, agent) => {
28
- return `${user || ''}${!!agent ? `_${agent}` : ''}${!!device ? `:${device}` : ''}@${server}`;
28
+ return `${user || ''}${!!agent ? `_${agent}` : ''}${!!device ? `:${device}` : ''}@${server || 'lid'}`;
29
29
  };
30
30
  export const jidDecode = (jid) => {
31
31
  // todo: investigate how to implement hosted ids in this case
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "violetics",
3
- "version": "7.0.6-alpha",
3
+ "version": "7.0.7-alpha",
4
4
  "description": "A simple fork of Baileys for WhatsApp automation",
5
5
  "main": "lib/index.js",
6
6
  "type": "module",
@@ -14,25 +14,6 @@
14
14
  "type": "git",
15
15
  "url": "git+https://github.com/cv3inx/violetics.git"
16
16
  },
17
- "files": [
18
- "lib/**/*",
19
- "WAProto/**/*",
20
- "engine-requirements.js"
21
- ],
22
- "keywords": [
23
- "automation",
24
- "baileys",
25
- "baileys-fork",
26
- "baileys-mod",
27
- "js-whatsapp",
28
- "multi-device",
29
- "whatsapp",
30
- "whatsapp-api",
31
- "whatsapp-bot",
32
- "whatsapp-chat",
33
- "whatsapp-group",
34
- "whatsapp-web"
35
- ],
36
17
  "homepage": "https://github.com/cv3inx/violetics#readme",
37
18
  "author": "Lia Wynn",
38
19
  "license": "MIT",
@@ -42,13 +23,13 @@
42
23
  "@hapi/boom": "^9.1.3",
43
24
  "async-mutex": "^0.5.0",
44
25
  "fflate": "^0.8.2",
45
- "libsignal": "git+https://github.com/whiskeysockets/libsignal-node",
26
+ "libsignal": "github:WhiskeySockets/libsignal-wasm#master",
46
27
  "lru-cache": "^11.2.6",
47
28
  "music-metadata": "^11.7.0",
48
29
  "p-queue": "^9.1.0",
49
30
  "pino": "^9.6.0",
50
31
  "protobufjs": "^7.5.4",
51
- "whatsapp-rust-bridge": "^0.5.3",
32
+ "whatsapp-rust-bridge": "0.5.3",
52
33
  "ws": "^8.19.0"
53
34
  },
54
35
  "peerDependencies": {