vialeys 0.0.1 → 0.0.2

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.
Files changed (102) hide show
  1. package/README.md +11 -5
  2. package/WAProto/AICommon/AICommon.js +13991 -9169
  3. package/WAProto/AICommon/AICommon.proto +110 -3
  4. package/WAProto/CompanionReg/CompanionReg.js +114 -0
  5. package/WAProto/CompanionReg/CompanionReg.proto +3 -0
  6. package/WAProto/DeviceCapabilities/DeviceCapabilities.js +652 -0
  7. package/WAProto/DeviceCapabilities/DeviceCapabilities.proto +19 -0
  8. package/WAProto/E2E/E2E.js +77193 -51248
  9. package/WAProto/E2E/E2E.proto +68 -12
  10. package/WAProto/HistorySync/HistorySync.js +3375 -178
  11. package/WAProto/HistorySync/HistorySync.proto +3 -3
  12. package/WAProto/LidMigrationSyncPayload/LidMigrationSyncPayload.js +98 -49
  13. package/WAProto/LidMigrationSyncPayload/LidMigrationSyncPayload.proto +2 -2
  14. package/WAProto/MdStorageMsgRowOpaqueData/MdStorageMsgRowOpaqueData.js +75226 -48422
  15. package/WAProto/MdStorageMsgRowOpaqueData/MdStorageMsgRowOpaqueData.proto +6 -0
  16. package/WAProto/StatusAttributions/StatusAttributions.js +21 -0
  17. package/WAProto/StatusAttributions/StatusAttributions.proto +3 -0
  18. package/WAProto/SyncAction/SyncAction.js +9423 -2023
  19. package/WAProto/SyncAction/SyncAction.proto +208 -15
  20. package/WAProto/Wa6/Wa6.js +83 -0
  21. package/WAProto/Wa6/Wa6.proto +3 -0
  22. package/WAProto/Web/Web.js +92664 -63403
  23. package/WAProto/Web/Web.proto +31 -13
  24. package/engine-requirements.js +9 -7
  25. package/lib/Defaults/baileys-version.json +2 -2
  26. package/lib/Defaults/connection.js +51 -0
  27. package/lib/Defaults/constants.js +62 -0
  28. package/lib/Defaults/history.js +17 -0
  29. package/lib/Defaults/index.js +36 -142
  30. package/lib/Defaults/media.js +48 -0
  31. package/lib/Defaults/prefix.js +18 -0
  32. package/lib/Signal/Group/group-session-builder.js +10 -42
  33. package/lib/Signal/Group/group_cipher.js +9 -6
  34. package/lib/Signal/Group/index.js +39 -53
  35. package/lib/Signal/Group/keyhelper.js +8 -41
  36. package/lib/Signal/Group/sender-chain-key.js +4 -4
  37. package/lib/Signal/Group/sender-key-distribution-message.js +5 -5
  38. package/lib/Signal/Group/sender-key-message.js +12 -8
  39. package/lib/Signal/Group/sender-key-state.js +4 -4
  40. package/lib/Signal/Group/sender-message-key.js +2 -2
  41. package/lib/Signal/libsignal.js +45 -69
  42. package/lib/Signal/lid-mapping.js +15 -11
  43. package/lib/Socket/Client/types.js +2 -2
  44. package/lib/Socket/Client/websocket.js +16 -14
  45. package/lib/Socket/business.js +41 -32
  46. package/lib/Socket/chats.js +123 -98
  47. package/lib/Socket/community.js +50 -40
  48. package/lib/Socket/groups.js +59 -47
  49. package/lib/Socket/index.js +4 -4
  50. package/lib/Socket/messages-recv.js +226 -171
  51. package/lib/Socket/messages-send.js +187 -143
  52. package/lib/Socket/newsletter.js +61 -47
  53. package/lib/Socket/socket.js +133 -90
  54. package/lib/Socket/usync.js +6 -6
  55. package/lib/Store/index.js +27 -11
  56. package/lib/Store/make-cache-manager-store.js +14 -15
  57. package/lib/Store/make-in-memory-store.js +28 -24
  58. package/lib/Types/LabelAssociation.js +2 -2
  59. package/lib/Types/Message.js +6 -6
  60. package/lib/Types/MexUpdates.js +5 -4
  61. package/lib/Types/State.js +4 -4
  62. package/lib/Types/index.js +28 -12
  63. package/lib/Utils/auth-utils.js +28 -26
  64. package/lib/Utils/baileys-event-stream.js +68 -69
  65. package/lib/Utils/business.js +63 -53
  66. package/lib/Utils/chat-utils.js +81 -71
  67. package/lib/Utils/crypto.js +25 -45
  68. package/lib/Utils/decode-wa-message.js +319 -311
  69. package/lib/Utils/event-buffer.js +21 -22
  70. package/lib/Utils/generics.js +103 -73
  71. package/lib/Utils/history.js +21 -21
  72. package/lib/Utils/index.js +27 -13
  73. package/lib/Utils/link-preview.js +7 -30
  74. package/lib/Utils/logger.js +5 -5
  75. package/lib/Utils/lt-hash.js +3 -3
  76. package/lib/Utils/message-retry-manager.js +4 -4
  77. package/lib/Utils/messages-media.js +104 -109
  78. package/lib/Utils/messages.js +203 -171
  79. package/lib/Utils/noise-handler.js +28 -19
  80. package/lib/Utils/process-message.js +370 -136
  81. package/lib/Utils/signal.js +36 -25
  82. package/lib/Utils/use-multi-file-auth-state.js +18 -22
  83. package/lib/Utils/validate-connection.js +52 -45
  84. package/lib/WABinary/decode.js +6 -32
  85. package/lib/WABinary/encode.js +3 -29
  86. package/lib/WABinary/generic-utils.js +4 -4
  87. package/lib/WABinary/index.js +27 -11
  88. package/lib/WAM/encode.js +16 -8
  89. package/lib/WAM/index.js +27 -11
  90. package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +20 -16
  91. package/lib/WAUSync/Protocols/USyncContactProtocol.js +2 -2
  92. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +7 -4
  93. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +2 -2
  94. package/lib/WAUSync/Protocols/USyncLIDProtocol.js +0 -2
  95. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +2 -2
  96. package/lib/WAUSync/Protocols/index.js +27 -11
  97. package/lib/WAUSync/USyncQuery.js +17 -10
  98. package/lib/WAUSync/index.js +27 -11
  99. package/lib/index.js +62 -37
  100. package/package.json +1 -1
  101. package/WAProto/index.d.ts +0 -55
  102. package/lib/index.d.ts +0 -13
@@ -1,38 +1,40 @@
1
1
  "use strict"
2
2
 
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod }
5
- }
6
-
7
3
  Object.defineProperty(exports, "__esModule", { value: true })
8
4
 
9
- const ws_1 = __importDefault(require("ws"))
10
- const Defaults_1 = require("../../Defaults")
11
- const types_1 = require("./types")
5
+ const {
6
+ OPEN,
7
+ CLOSED,
8
+ CLOSING,
9
+ CONNECTING,
10
+ WebSocket
11
+ } = require("ws")
12
+ const { DEFAULT_ORIGIN } = require("../../Defaults/constants")
13
+ const { AbstractSocketClient } = require("./types")
12
14
 
13
- class WebSocketClient extends types_1.AbstractSocketClient {
15
+ class WebSocketClient extends AbstractSocketClient {
14
16
  constructor() {
15
17
  super(...arguments)
16
18
  this.socket = null
17
19
  }
18
20
  get isOpen() {
19
- return this.socket?.readyState === ws_1.default.OPEN
21
+ return this.socket?.readyState === OPEN
20
22
  }
21
23
  get isClosed() {
22
- return this.socket?.readyState === ws_1.default.CLOSED
24
+ return this.socket?.readyState === CLOSED
23
25
  }
24
26
  get isClosing() {
25
- this.socket?.readyState === ws_1.default.CLOSING
27
+ this.socket?.readyState === CLOSING
26
28
  }
27
29
  get isConnecting() {
28
- this.socket?.readyState === ws_1.default.CONNECTING
30
+ this.socket?.readyState === CONNECTING
29
31
  }
30
32
  async connect() {
31
33
  if (this.socket) {
32
34
  return
33
35
  }
34
- this.socket = new ws_1.default(this.url, {
35
- origin: Defaults_1.DEFAULT_ORIGIN,
36
+ this.socket = new WebSocket(this.url, {
37
+ origin: DEFAULT_ORIGIN,
36
38
  headers: this.config.options?.headers,
37
39
  handshakeTimeout: this.config.connectTimeoutMs,
38
40
  timeout: this.config.connectTimeoutMs,
@@ -2,14 +2,23 @@
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", { value: true })
4
4
 
5
- const Utils_1 = require("../Utils")
6
- const WABinary_1 = require("../WABinary")
7
- const business_1 = require("../Utils/business")
8
- const generic_utils_1 = require("../WABinary/generic-utils")
9
- const messages_recv_1 = require("./messages-recv")
5
+ const {
6
+ toProductNode,
7
+ parseCatalogNode,
8
+ parseCollectionsNode,
9
+ parseOrderDetailsNode,
10
+ getRawMediaUploadData,
11
+ uploadingNecessaryImagesOfProduct
12
+ } = require("../Utils")
13
+ const {
14
+ S_WHATSAPP_NET,
15
+ jidNormalizedUser,
16
+ getBinaryNodeChild
17
+ } = require("../WABinary")
18
+ const { makeMessagesRecvSocket } = require("./messages-recv")
10
19
 
11
20
  const makeBusinessSocket = (config) => {
12
- const suki = messages_recv_1.makeMessagesRecvSocket(config)
21
+ const suki = makeMessagesRecvSocket(config)
13
22
  const { authState, query, waUploadToServer } = suki
14
23
 
15
24
  const updateBussinesProfile = async (args) => {
@@ -63,7 +72,7 @@ const makeBusinessSocket = (config) => {
63
72
  const result = await query({
64
73
  tag: 'iq',
65
74
  attrs: {
66
- to: WABinary_1.S_WHATSAPP_NET,
75
+ to: S_WHATSAPP_NET,
67
76
  type: 'set',
68
77
  xmlns: 'w:biz'
69
78
  },
@@ -83,7 +92,7 @@ const makeBusinessSocket = (config) => {
83
92
  }
84
93
 
85
94
  const updateCoverPhoto = async (photo) => {
86
- const { fileSha256, filePath } = await Utils_1.getRawMediaUploadData(photo, 'biz-cover-photo')
95
+ const { fileSha256, filePath } = await getRawMediaUploadData(photo, 'biz-cover-photo')
87
96
  const fileSha256B64 = fileSha256.toString('base64')
88
97
 
89
98
  const { meta_hmac, fbid, ts } = await waUploadToServer(filePath, {
@@ -94,7 +103,7 @@ const makeBusinessSocket = (config) => {
94
103
  await query({
95
104
  tag: 'iq',
96
105
  attrs: {
97
- to: WABinary_1.S_WHATSAPP_NET,
106
+ to: S_WHATSAPP_NET,
98
107
  type: 'set',
99
108
  xmlns: 'w:biz'
100
109
  },
@@ -122,7 +131,7 @@ const makeBusinessSocket = (config) => {
122
131
  return await query({
123
132
  tag: 'iq',
124
133
  attrs: {
125
- to: WABinary_1.S_WHATSAPP_NET,
134
+ to: S_WHATSAPP_NET,
126
135
  type: 'set',
127
136
  xmlns: 'w:biz'
128
137
  },
@@ -146,7 +155,7 @@ const makeBusinessSocket = (config) => {
146
155
 
147
156
  const getCatalog = async ({ jid, limit, cursor }) => {
148
157
  jid = jid || authState.creds.me?.id
149
- jid = WABinary_1.jidNormalizedUser(jid)
158
+ jid = jidNormalizedUser(jid)
150
159
 
151
160
  const queryParamNodes = [
152
161
  {
@@ -177,7 +186,7 @@ const makeBusinessSocket = (config) => {
177
186
  const result = await query({
178
187
  tag: 'iq',
179
188
  attrs: {
180
- to: WABinary_1.S_WHATSAPP_NET,
189
+ to: S_WHATSAPP_NET,
181
190
  type: 'get',
182
191
  xmlns: 'w:biz:catalog'
183
192
  },
@@ -193,17 +202,17 @@ const makeBusinessSocket = (config) => {
193
202
  ]
194
203
  })
195
204
 
196
- return business_1.parseCatalogNode(result)
205
+ return parseCatalogNode(result)
197
206
  }
198
207
 
199
208
  const getCollections = async (jid, limit = 51) => {
200
209
  jid = jid || authState.creds.me?.id
201
- jid = WABinary_1.jidNormalizedUser(jid)
210
+ jid = jidNormalizedUser(jid)
202
211
 
203
212
  const result = await query({
204
213
  tag: 'iq',
205
214
  attrs: {
206
- to: WABinary_1.S_WHATSAPP_NET,
215
+ to: S_WHATSAPP_NET,
207
216
  type: 'get',
208
217
  xmlns: 'w:biz:catalog',
209
218
  'smax_id': '35'
@@ -240,14 +249,14 @@ const makeBusinessSocket = (config) => {
240
249
  ]
241
250
  })
242
251
 
243
- return business_1.parseCollectionsNode(result)
252
+ return parseCollectionsNode(result)
244
253
  }
245
254
 
246
255
  const getOrderDetails = async (orderId, tokenBase64) => {
247
256
  const result = await query({
248
257
  tag: 'iq',
249
258
  attrs: {
250
- to: WABinary_1.S_WHATSAPP_NET,
259
+ to: S_WHATSAPP_NET,
251
260
  type: 'get',
252
261
  xmlns: 'fb:thrift_iq',
253
262
  'smax_id': '5'
@@ -286,17 +295,17 @@ const makeBusinessSocket = (config) => {
286
295
  ]
287
296
  })
288
297
 
289
- return business_1.parseOrderDetailsNode(result)
298
+ return parseOrderDetailsNode(result)
290
299
  }
291
300
 
292
301
  const productUpdate = async (productId, update) => {
293
- update = await business_1.uploadingNecessaryImagesOfProduct(update, waUploadToServer)
294
- const editNode = business_1.toProductNode(productId, update)
302
+ update = await uploadingNecessaryImagesOfProduct(update, waUploadToServer)
303
+ const editNode = toProductNode(productId, update)
295
304
 
296
305
  const result = await query({
297
306
  tag: 'iq',
298
307
  attrs: {
299
- to: WABinary_1.S_WHATSAPP_NET,
308
+ to: S_WHATSAPP_NET,
300
309
  type: 'set',
301
310
  xmlns: 'w:biz:catalog'
302
311
  },
@@ -320,21 +329,21 @@ const makeBusinessSocket = (config) => {
320
329
  }
321
330
  ]
322
331
  })
323
- const productCatalogEditNode = generic_utils_1.getBinaryNodeChild(result, 'product_catalog_edit')
324
- const productNode = generic_utils_1.getBinaryNodeChild(productCatalogEditNode, 'product')
325
- return business_1.parseProductNode(productNode)
332
+ const productCatalogEditNode = getBinaryNodeChild(result, 'product_catalog_edit')
333
+ const productNode = getBinaryNodeChild(productCatalogEditNode, 'product')
334
+ return parseProductNode(productNode)
326
335
  }
327
336
 
328
337
  const productCreate = async (create) => {
329
338
  // ensure isHidden is defined
330
339
  create.isHidden = !!create.isHidden
331
- create = await business_1.uploadingNecessaryImagesOfProduct(create, waUploadToServer)
332
- const createNode = business_1.toProductNode(undefined, create)
340
+ create = await uploadingNecessaryImagesOfProduct(create, waUploadToServer)
341
+ const createNode = toProductNode(undefined, create)
333
342
 
334
343
  const result = await query({
335
344
  tag: 'iq',
336
345
  attrs: {
337
- to: WABinary_1.S_WHATSAPP_NET,
346
+ to: S_WHATSAPP_NET,
338
347
  type: 'set',
339
348
  xmlns: 'w:biz:catalog'
340
349
  },
@@ -358,17 +367,17 @@ const makeBusinessSocket = (config) => {
358
367
  }
359
368
  ]
360
369
  })
361
- const productCatalogAddNode = generic_utils_1.getBinaryNodeChild(result, 'product_catalog_add')
362
- const productNode = generic_utils_1.getBinaryNodeChild(productCatalogAddNode, 'product')
370
+ const productCatalogAddNode = getBinaryNodeChild(result, 'product_catalog_add')
371
+ const productNode = getBinaryNodeChild(productCatalogAddNode, 'product')
363
372
 
364
- return business_1.parseProductNode(productNode)
373
+ return parseProductNode(productNode)
365
374
  }
366
375
 
367
376
  const productDelete = async (productIds) => {
368
377
  const result = await query({
369
378
  tag: 'iq',
370
379
  attrs: {
371
- to: WABinary_1.S_WHATSAPP_NET,
380
+ to: S_WHATSAPP_NET,
372
381
  type: 'set',
373
382
  xmlns: 'w:biz:catalog'
374
383
  },
@@ -390,7 +399,7 @@ const makeBusinessSocket = (config) => {
390
399
  }
391
400
  ]
392
401
  })
393
- const productCatalogDelNode = generic_utils_1.getBinaryNodeChild(result, 'product_catalog_delete')
402
+ const productCatalogDelNode = getBinaryNodeChild(result, 'product_catalog_delete')
394
403
  return {
395
404
  deleted: +(productCatalogDelNode?.attrs?.deleted_count || 0)
396
405
  }