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,57 +1,37 @@
1
1
  "use strict"
2
2
 
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k
5
- var desc = Object.getOwnPropertyDescriptor(m, k)
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k] } }
8
- }
9
- Object.defineProperty(o, k2, desc)
10
- } : function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k
12
- o[k2] = m[k]
13
- })
14
-
15
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? function(o, v) {
16
- Object.defineProperty(o, "default", { enumerable: true, value: v })
17
- } : function(o, v) {
18
- o["default"] = v
19
- })
20
-
21
- var __importStar = (this && this.__importStar) || function(mod) {
22
- if (mod && mod.__esModule) return mod
23
- var result = {}
24
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k)
25
- __setModuleDefault(result, mod)
26
- return result
27
- }
28
-
29
3
  Object.defineProperty(exports, "__esModule", { value: true })
30
4
 
31
- const crypto_1 = require("crypto")
32
- const libsignal = __importStar(require("libsignal-node"))
33
- const Defaults_1 = require("../Defaults")
5
+ const {
6
+ createCipheriv,
7
+ createDecipheriv,
8
+ createHash,
9
+ createHmac,
10
+ randomBytes
11
+ } = require("crypto")
12
+ const { curve } = require("libsignal-node")
13
+ const { KEY_BUNDLE_TYPE } = require("../Defaults/constants")
34
14
 
35
15
  const generateSignalPubKey = (pubKey) => (
36
- pubKey.length === 33 ? pubKey : Buffer.concat([Defaults_1.KEY_BUNDLE_TYPE, pubKey])
16
+ pubKey.length === 33 ? pubKey : Buffer.concat([KEY_BUNDLE_TYPE, pubKey])
37
17
  )
38
18
 
39
19
  const Curve = {
40
20
  generateKeyPair: () => {
41
- const { pubKey, privKey } = libsignal.curve.generateKeyPair()
21
+ const { pubKey, privKey } = curve.generateKeyPair()
42
22
  return {
43
23
  private: Buffer.from(privKey),
44
24
  public: Buffer.from(pubKey.slice(1))
45
25
  }
46
26
  },
47
27
  sharedKey: (privateKey, publicKey) => {
48
- const shared = libsignal.curve.calculateAgreement(generateSignalPubKey(publicKey), privateKey)
28
+ const shared = curve.calculateAgreement(generateSignalPubKey(publicKey), privateKey)
49
29
  return Buffer.from(shared)
50
30
  },
51
- sign: (privateKey, buf) => libsignal.curve.calculateSignature(privateKey, buf),
31
+ sign: (privateKey, buf) => curve.calculateSignature(privateKey, buf),
52
32
  verify: (pubKey, message, signature) => {
53
33
  try {
54
- libsignal.curve.verifySignature(generateSignalPubKey(pubKey), message, signature)
34
+ curve.verifySignature(generateSignalPubKey(pubKey), message, signature)
55
35
  return true
56
36
  } catch {
57
37
  return false
@@ -69,13 +49,13 @@ const signedKeyPair = (identityKeyPair, keyId) => {
69
49
  const GCM_TAG_LENGTH = 128 >> 3
70
50
 
71
51
  function aesEncryptGCM(plaintext, key, iv, additionalData) {
72
- const cipher = crypto_1.createCipheriv('aes-256-gcm', key, iv)
52
+ const cipher = createCipheriv('aes-256-gcm', key, iv)
73
53
  cipher.setAAD(additionalData)
74
54
  return Buffer.concat([cipher.update(plaintext), cipher.final(), cipher.getAuthTag()])
75
55
  }
76
56
 
77
57
  function aesDecryptGCM(ciphertext, key, iv, additionalData) {
78
- const decipher = crypto_1.createDecipheriv('aes-256-gcm', key, iv)
58
+ const decipher = createDecipheriv('aes-256-gcm', key, iv)
79
59
  const enc = ciphertext.slice(0, ciphertext.length - GCM_TAG_LENGTH)
80
60
  const tag = ciphertext.slice(ciphertext.length - GCM_TAG_LENGTH)
81
61
  if (additionalData) decipher.setAAD(additionalData)
@@ -84,12 +64,12 @@ function aesDecryptGCM(ciphertext, key, iv, additionalData) {
84
64
  }
85
65
 
86
66
  function aesEncryptCTR(plaintext, key, iv) {
87
- const cipher = crypto_1.createCipheriv('aes-256-ctr', key, iv)
67
+ const cipher = createCipheriv('aes-256-ctr', key, iv)
88
68
  return Buffer.concat([cipher.update(plaintext), cipher.final()])
89
69
  }
90
70
 
91
71
  function aesDecryptCTR(ciphertext, key, iv) {
92
- const decipher = crypto_1.createDecipheriv('aes-256-ctr', key, iv)
72
+ const decipher = createDecipheriv('aes-256-ctr', key, iv)
93
73
  return Buffer.concat([decipher.update(ciphertext), decipher.final()])
94
74
  }
95
75
 
@@ -98,31 +78,31 @@ function aesDecrypt(buffer, key) {
98
78
  }
99
79
 
100
80
  function aesDecryptWithIV(buffer, key, IV) {
101
- const aes = crypto_1.createDecipheriv('aes-256-cbc', key, IV)
81
+ const aes = createDecipheriv('aes-256-cbc', key, IV)
102
82
  return Buffer.concat([aes.update(buffer), aes.final()])
103
83
  }
104
84
 
105
85
  function aesEncrypt(buffer, key) {
106
- const IV = crypto_1.randomBytes(16)
107
- const aes = crypto_1.createCipheriv('aes-256-cbc', key, IV)
86
+ const IV = randomBytes(16)
87
+ const aes = createCipheriv('aes-256-cbc', key, IV)
108
88
  return Buffer.concat([IV, aes.update(buffer), aes.final()])
109
89
  }
110
90
 
111
91
  function aesEncrypWithIV(buffer, key, IV) {
112
- const aes = crypto_1.createCipheriv('aes-256-cbc', key, IV)
92
+ const aes = createCipheriv('aes-256-cbc', key, IV)
113
93
  return Buffer.concat([aes.update(buffer), aes.final()])
114
94
  }
115
95
 
116
96
  function hmacSign(buffer, key, variant = 'sha256') {
117
- return crypto_1.createHmac(variant, key).update(buffer).digest()
97
+ return createHmac(variant, key).update(buffer).digest()
118
98
  }
119
99
 
120
100
  function sha256(buffer) {
121
- return crypto_1.createHash('sha256').update(buffer).digest()
101
+ return createHash('sha256').update(buffer).digest()
122
102
  }
123
103
 
124
104
  function md5(buffer) {
125
- return crypto_1.createHash('md5').update(buffer).digest()
105
+ return createHash('md5').update(buffer).digest()
126
106
  }
127
107
 
128
108
  async function hkdf(buffer, expandedLength, info) {