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.
- package/README.md +11 -5
- package/WAProto/AICommon/AICommon.js +13991 -9169
- package/WAProto/AICommon/AICommon.proto +110 -3
- package/WAProto/CompanionReg/CompanionReg.js +114 -0
- package/WAProto/CompanionReg/CompanionReg.proto +3 -0
- package/WAProto/DeviceCapabilities/DeviceCapabilities.js +652 -0
- package/WAProto/DeviceCapabilities/DeviceCapabilities.proto +19 -0
- package/WAProto/E2E/E2E.js +77193 -51248
- package/WAProto/E2E/E2E.proto +68 -12
- package/WAProto/HistorySync/HistorySync.js +3375 -178
- package/WAProto/HistorySync/HistorySync.proto +3 -3
- package/WAProto/LidMigrationSyncPayload/LidMigrationSyncPayload.js +98 -49
- package/WAProto/LidMigrationSyncPayload/LidMigrationSyncPayload.proto +2 -2
- package/WAProto/MdStorageMsgRowOpaqueData/MdStorageMsgRowOpaqueData.js +75226 -48422
- package/WAProto/MdStorageMsgRowOpaqueData/MdStorageMsgRowOpaqueData.proto +6 -0
- package/WAProto/StatusAttributions/StatusAttributions.js +21 -0
- package/WAProto/StatusAttributions/StatusAttributions.proto +3 -0
- package/WAProto/SyncAction/SyncAction.js +9423 -2023
- package/WAProto/SyncAction/SyncAction.proto +208 -15
- package/WAProto/Wa6/Wa6.js +83 -0
- package/WAProto/Wa6/Wa6.proto +3 -0
- package/WAProto/Web/Web.js +92664 -63403
- package/WAProto/Web/Web.proto +31 -13
- package/engine-requirements.js +9 -7
- package/lib/Defaults/baileys-version.json +2 -2
- package/lib/Defaults/connection.js +51 -0
- package/lib/Defaults/constants.js +62 -0
- package/lib/Defaults/history.js +17 -0
- package/lib/Defaults/index.js +36 -142
- package/lib/Defaults/media.js +48 -0
- package/lib/Defaults/prefix.js +18 -0
- package/lib/Signal/Group/group-session-builder.js +10 -42
- package/lib/Signal/Group/group_cipher.js +9 -6
- package/lib/Signal/Group/index.js +39 -53
- package/lib/Signal/Group/keyhelper.js +8 -41
- package/lib/Signal/Group/sender-chain-key.js +4 -4
- package/lib/Signal/Group/sender-key-distribution-message.js +5 -5
- package/lib/Signal/Group/sender-key-message.js +12 -8
- package/lib/Signal/Group/sender-key-state.js +4 -4
- package/lib/Signal/Group/sender-message-key.js +2 -2
- package/lib/Signal/libsignal.js +45 -69
- package/lib/Signal/lid-mapping.js +15 -11
- package/lib/Socket/Client/types.js +2 -2
- package/lib/Socket/Client/websocket.js +16 -14
- package/lib/Socket/business.js +41 -32
- package/lib/Socket/chats.js +123 -98
- package/lib/Socket/community.js +50 -40
- package/lib/Socket/groups.js +59 -47
- package/lib/Socket/index.js +4 -4
- package/lib/Socket/messages-recv.js +226 -171
- package/lib/Socket/messages-send.js +187 -143
- package/lib/Socket/newsletter.js +61 -47
- package/lib/Socket/socket.js +133 -90
- package/lib/Socket/usync.js +6 -6
- package/lib/Store/index.js +27 -11
- package/lib/Store/make-cache-manager-store.js +14 -15
- package/lib/Store/make-in-memory-store.js +28 -24
- package/lib/Types/LabelAssociation.js +2 -2
- package/lib/Types/Message.js +6 -6
- package/lib/Types/MexUpdates.js +5 -4
- package/lib/Types/State.js +4 -4
- package/lib/Types/index.js +28 -12
- package/lib/Utils/auth-utils.js +28 -26
- package/lib/Utils/baileys-event-stream.js +68 -69
- package/lib/Utils/business.js +63 -53
- package/lib/Utils/chat-utils.js +81 -71
- package/lib/Utils/crypto.js +25 -45
- package/lib/Utils/decode-wa-message.js +319 -311
- package/lib/Utils/event-buffer.js +21 -22
- package/lib/Utils/generics.js +103 -73
- package/lib/Utils/history.js +21 -21
- package/lib/Utils/index.js +27 -13
- package/lib/Utils/link-preview.js +7 -30
- package/lib/Utils/logger.js +5 -5
- package/lib/Utils/lt-hash.js +3 -3
- package/lib/Utils/message-retry-manager.js +4 -4
- package/lib/Utils/messages-media.js +104 -109
- package/lib/Utils/messages.js +203 -171
- package/lib/Utils/noise-handler.js +28 -19
- package/lib/Utils/process-message.js +370 -136
- package/lib/Utils/signal.js +36 -25
- package/lib/Utils/use-multi-file-auth-state.js +18 -22
- package/lib/Utils/validate-connection.js +52 -45
- package/lib/WABinary/decode.js +6 -32
- package/lib/WABinary/encode.js +3 -29
- package/lib/WABinary/generic-utils.js +4 -4
- package/lib/WABinary/index.js +27 -11
- package/lib/WAM/encode.js +16 -8
- package/lib/WAM/index.js +27 -11
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +20 -16
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +2 -2
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +7 -4
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +2 -2
- package/lib/WAUSync/Protocols/USyncLIDProtocol.js +0 -2
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +2 -2
- package/lib/WAUSync/Protocols/index.js +27 -11
- package/lib/WAUSync/USyncQuery.js +17 -10
- package/lib/WAUSync/index.js +27 -11
- package/lib/index.js +62 -37
- package/package.json +1 -1
- package/WAProto/index.d.ts +0 -55
- package/lib/index.d.ts +0 -13
|
@@ -2,11 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true })
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
const { Boom } = require("@hapi/boom")
|
|
6
|
+
const { proto } = require("../../WAProto")
|
|
7
|
+
const {
|
|
8
|
+
NOISE_MODE,
|
|
9
|
+
WA_CERT_DETAILS
|
|
10
|
+
} = require("../Defaults/constants")
|
|
11
|
+
const { decodeBinaryNode } = require("../WABinary")
|
|
12
|
+
const {
|
|
13
|
+
aesDecryptGCM,
|
|
14
|
+
aesEncryptGCM,
|
|
15
|
+
Curve,
|
|
16
|
+
hkdf,
|
|
17
|
+
sha256
|
|
18
|
+
} = require("./crypto")
|
|
10
19
|
|
|
11
20
|
const generateIV = (counter) => {
|
|
12
21
|
const iv = new ArrayBuffer(12)
|
|
@@ -18,11 +27,11 @@ const makeNoiseHandler = ({ keyPair: { private: privateKey, public: publicKey },
|
|
|
18
27
|
logger = logger.child({ class: 'ns' })
|
|
19
28
|
const authenticate = (data) => {
|
|
20
29
|
if (!isFinished) {
|
|
21
|
-
hash =
|
|
30
|
+
hash = sha256(Buffer.concat([hash, data]))
|
|
22
31
|
}
|
|
23
32
|
}
|
|
24
33
|
const encrypt = (plaintext) => {
|
|
25
|
-
const result =
|
|
34
|
+
const result = aesEncryptGCM(plaintext, encKey, generateIV(writeCounter), hash)
|
|
26
35
|
writeCounter += 1
|
|
27
36
|
authenticate(result)
|
|
28
37
|
return result
|
|
@@ -31,7 +40,7 @@ const makeNoiseHandler = ({ keyPair: { private: privateKey, public: publicKey },
|
|
|
31
40
|
// before the handshake is finished, we use the same counter
|
|
32
41
|
// after handshake, the counters are different
|
|
33
42
|
const iv = generateIV(isFinished ? readCounter : writeCounter)
|
|
34
|
-
const result =
|
|
43
|
+
const result = aesDecryptGCM(ciphertext, decKey, iv, hash)
|
|
35
44
|
if (isFinished) {
|
|
36
45
|
readCounter += 1
|
|
37
46
|
}
|
|
@@ -42,7 +51,7 @@ const makeNoiseHandler = ({ keyPair: { private: privateKey, public: publicKey },
|
|
|
42
51
|
return result
|
|
43
52
|
}
|
|
44
53
|
const localHKDF = async (data) => {
|
|
45
|
-
const key = await
|
|
54
|
+
const key = await hkdf(Buffer.from(data), 64, { salt, info: '' })
|
|
46
55
|
return [key.slice(0, 32), key.slice(32)]
|
|
47
56
|
}
|
|
48
57
|
const mixIntoKey = async (data) => {
|
|
@@ -62,8 +71,8 @@ const makeNoiseHandler = ({ keyPair: { private: privateKey, public: publicKey },
|
|
|
62
71
|
writeCounter = 0
|
|
63
72
|
isFinished = true
|
|
64
73
|
}
|
|
65
|
-
const data = Buffer.from(
|
|
66
|
-
let hash = data.byteLength === 32 ? data :
|
|
74
|
+
const data = Buffer.from(NOISE_MODE)
|
|
75
|
+
let hash = data.byteLength === 32 ? data : sha256(data)
|
|
67
76
|
let salt = hash
|
|
68
77
|
let encKey = hash
|
|
69
78
|
let decKey = hash
|
|
@@ -82,17 +91,17 @@ const makeNoiseHandler = ({ keyPair: { private: privateKey, public: publicKey },
|
|
|
82
91
|
finishInit,
|
|
83
92
|
processHandshake: async ({ serverHello }, noiseKey) => {
|
|
84
93
|
authenticate(serverHello.ephemeral)
|
|
85
|
-
await mixIntoKey(
|
|
94
|
+
await mixIntoKey(Curve.sharedKey(privateKey, serverHello.ephemeral))
|
|
86
95
|
const decStaticContent = decrypt(serverHello.static)
|
|
87
|
-
await mixIntoKey(
|
|
96
|
+
await mixIntoKey(Curve.sharedKey(privateKey, decStaticContent))
|
|
88
97
|
const certDecoded = decrypt(serverHello.payload)
|
|
89
|
-
const { intermediate: certIntermediate } =
|
|
90
|
-
const { issuerSerial } =
|
|
91
|
-
if (issuerSerial !==
|
|
92
|
-
throw new
|
|
98
|
+
const { intermediate: certIntermediate } = proto.CertChain.decode(certDecoded)
|
|
99
|
+
const { issuerSerial } = proto.CertChain.NoiseCertificate.Details.decode(certIntermediate.details)
|
|
100
|
+
if (issuerSerial !== WA_CERT_DETAILS.SERIAL) {
|
|
101
|
+
throw new Boom('certification match failed', { statusCode: 400 })
|
|
93
102
|
}
|
|
94
103
|
const keyEnc = encrypt(noiseKey.public)
|
|
95
|
-
await mixIntoKey(
|
|
104
|
+
await mixIntoKey(Curve.sharedKey(noiseKey.private, serverHello.ephemeral))
|
|
96
105
|
return keyEnc
|
|
97
106
|
},
|
|
98
107
|
encodeFrame: (data) => {
|
|
@@ -140,7 +149,7 @@ const makeNoiseHandler = ({ keyPair: { private: privateKey, public: publicKey },
|
|
|
140
149
|
inBytes = inBytes.slice(size + 3)
|
|
141
150
|
if (isFinished) {
|
|
142
151
|
const result = decrypt(frame)
|
|
143
|
-
frame = await
|
|
152
|
+
frame = await decodeBinaryNode(result)
|
|
144
153
|
}
|
|
145
154
|
logger.trace({ msg: frame?.attrs?.id }, 'recv frame')
|
|
146
155
|
onFrame(frame)
|