@hiroosy/baileys-lite 0.0.4 → 0.3.1
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/LICENSE +21 -0
- package/README.md +658 -10
- package/WAProto/index.js +2 -2558
- package/engine-requirements.js +3 -4
- package/package.json +8 -3
- package/src/binary/wa-binary.js +3 -25
- package/src/constants.js +7 -15
- package/src/defaults.js +2 -5
- package/src/foundation/ai-rich.js +530 -0
- package/src/foundation/audio-duration.js +43 -103
- package/src/foundation/audio-samples.js +19 -37
- package/src/foundation/boom.js +0 -7
- package/src/foundation/cache.js +4 -26
- package/src/foundation/concurrency.js +1 -19
- package/src/foundation/curve25519.js +7 -39
- package/src/foundation/link-preview.js +15 -57
- package/src/foundation/logger.js +0 -11
- package/src/foundation/long.js +4 -14
- package/src/foundation/protobuf-minimal.js +21 -53
- package/src/foundation/qrcode-terminal.js +273 -0
- package/src/foundation/sql-database.js +716 -0
- package/src/foundation/wa-crypto.js +2 -31
- package/src/foundation/zip.js +25 -41
- package/src/index.js +8 -18
- package/src/signal/libsignal.js +23 -78
- package/src/signal/signal-group.js +0 -35
- package/src/signal/signal-repository.js +10 -29
- package/src/socket/business-communities.js +12 -31
- package/src/socket/chats.js +5 -8
- package/src/socket/groups-newsletter.js +18 -17
- package/src/socket/messages-recv.js +81 -127
- package/src/socket/messages-send.js +372 -139
- package/src/socket/socket-core.js +227 -157
- package/src/socket/usync.js +2 -6
- package/src/socket-client/native-websocket.js +344 -0
- package/src/socket-client/websocket-client.js +84 -38
- package/src/utils/auth-state-core.js +14 -56
- package/src/utils/auth-state-storage.js +7 -42
- package/src/utils/chat-sync.js +4 -26
- package/src/utils/media.js +15 -71
- package/src/utils/message-compose.js +208 -85
- package/src/utils/message-processing.js +10 -65
- package/src/utils/username.js +19 -0
- package/src/utils/wa-protocol-core.js +71 -127
- package/src/vendor/jpeg-js/decoder.js +75 -136
- package/src/vendor/jpeg-js/encoder.js +179 -264
- package/src/vendor/pngjs/bitmapper.js +5 -27
- package/src/vendor/pngjs/bitpacker.js +4 -12
- package/src/vendor/pngjs/constants.js +3 -11
- package/src/vendor/pngjs/crc.js +0 -6
- package/src/vendor/pngjs/filter-pack.js +1 -7
- package/src/vendor/pngjs/filter-parse-sync.js +0 -6
- package/src/vendor/pngjs/filter-parse.js +1 -11
- package/src/vendor/pngjs/format-normaliser.js +5 -11
- package/src/vendor/pngjs/interlace.js +7 -24
- package/src/vendor/pngjs/packer-sync.js +0 -11
- package/src/vendor/pngjs/packer.js +7 -15
- package/src/vendor/pngjs/paeth-predictor.js +0 -6
- package/src/vendor/pngjs/parser-sync.js +0 -8
- package/src/vendor/pngjs/parser.js +5 -29
- package/src/vendor/pngjs/png-sync.js +0 -7
- package/src/vendor/pngjs/sync-inflate.js +7 -16
- package/src/vendor/pngjs/sync-reader.js +4 -11
- package/src/voip/WaVoipCoordinator.js +158 -0
- package/src/voip/app-data/WaAppDataStream.js +193 -0
- package/src/voip/app-data/protocol.js +172 -0
- package/src/voip/bytes.js +63 -0
- package/src/voip/call/WaCallManager.js +442 -0
- package/src/voip/call/WaCallMediaSession.js +1705 -0
- package/src/voip/call/call-state.js +203 -0
- package/src/voip/crypto/encryption.js +13 -0
- package/src/voip/crypto/primitives.js +21 -0
- package/src/voip/crypto/rtcp.js +66 -0
- package/src/voip/crypto/srtp.js +180 -0
- package/src/voip/crypto/ssrc.js +15 -0
- package/src/voip/index.js +628 -0
- package/src/voip/media/WaAudioEngine.js +486 -0
- package/src/voip/media/WaVideoEngine.js +275 -0
- package/src/voip/media/audio-codec.js +0 -0
- package/src/voip/media/audio-reorder.js +107 -0
- package/src/voip/media/h264.js +246 -0
- package/src/voip/media/mlow-codec.js +465 -0
- package/src/voip/media/rtcp.js +68 -0
- package/src/voip/media/rtp.js +242 -0
- package/src/voip/protobuf.js +30 -0
- package/src/voip/relay/WaManualRelay.js +609 -0
- package/src/voip/relay/datachannel/pre-negotiated.js +25 -0
- package/src/voip/relay/dtls/aead.js +46 -0
- package/src/voip/relay/dtls/cert-builder.js +102 -0
- package/src/voip/relay/dtls/der.js +98 -0
- package/src/voip/relay/dtls/ecdhe.js +37 -0
- package/src/voip/relay/dtls/handshake-framing.js +100 -0
- package/src/voip/relay/dtls/handshake-messages.js +158 -0
- package/src/voip/relay/dtls/handshake.js +582 -0
- package/src/voip/relay/dtls/prf.js +39 -0
- package/src/voip/relay/dtls/record.js +56 -0
- package/src/voip/relay/relay-ack.js +141 -0
- package/src/voip/relay/sctp/association.js +434 -0
- package/src/voip/relay/sctp/crc32c.js +21 -0
- package/src/voip/relay/sctp/wire.js +226 -0
- package/src/voip/relay/stun.js +463 -0
- package/src/voip/shim/baileys-resolve.js +7 -0
- package/src/voip/shim/core.js +66 -0
- package/src/voip/shim/crypto.js +6 -0
- package/src/voip/shim/proto.js +10 -0
- package/src/voip/shim/protocol.js +130 -0
- package/src/voip/shim/transport.js +82 -0
- package/src/voip/shim/util.js +207 -0
- package/src/voip/signaling/bridge.js +102 -0
- package/src/voip/signaling/screen-share.js +60 -0
- package/src/voip/signaling/signaling.js +491 -0
- package/src/voip/types.js +69 -0
- package/src/voip/voip-deps.js +243 -0
- package/src/voip/voipClient.js +314 -0
- package/src/wam/wam-constants.js +0 -1
- package/src/wam/wam.js +2 -7
package/engine-requirements.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
const major = parseInt(process.versions.node.split('.')[0], 10)
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
if (major < 22) {
|
|
3
|
+
if (major < 18) {
|
|
5
4
|
console.error(
|
|
6
|
-
`\n❌ baileys-lite requires Node.js
|
|
5
|
+
`\n❌ baileys-lite requires Node.js 18+.\n` +
|
|
7
6
|
` You are using Node.js ${process.versions.node}.\n` +
|
|
8
|
-
` Please upgrade to Node.js
|
|
7
|
+
` Please upgrade to Node.js 18+ to proceed.\n`
|
|
9
8
|
)
|
|
10
9
|
process.exit(1)
|
|
11
10
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hiroosy/baileys-lite",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "A Lightweight Baileys
|
|
3
|
+
"version": "0.3.1",
|
|
4
|
+
"description": "A Lightweight Baileys built with NodeJs 18+",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/HirooSy/baileys-lite.git"
|
|
8
|
+
},
|
|
5
9
|
"keywords": [
|
|
6
10
|
"whatsapp",
|
|
7
11
|
"automation"
|
|
@@ -11,6 +15,7 @@
|
|
|
11
15
|
"main": "src/index.js",
|
|
12
16
|
"exports": {
|
|
13
17
|
".": "./src/index.js",
|
|
18
|
+
"./voip": "./src/voip/index.js",
|
|
14
19
|
"./package.json": "./package.json"
|
|
15
20
|
},
|
|
16
21
|
"files": [
|
|
@@ -22,6 +27,6 @@
|
|
|
22
27
|
"preinstall": "node ./engine-requirements.js"
|
|
23
28
|
},
|
|
24
29
|
"engines": {
|
|
25
|
-
"node": ">=
|
|
30
|
+
"node": ">=18.0.0"
|
|
26
31
|
}
|
|
27
32
|
}
|
package/src/binary/wa-binary.js
CHANGED
|
@@ -4,10 +4,6 @@ import { randomBytes } from 'node:crypto'
|
|
|
4
4
|
import { Boom } from '../foundation/boom.js'
|
|
5
5
|
import * as constants from './wa-binary-constants.js'
|
|
6
6
|
|
|
7
|
-
/* ------------------------------------------------------------------ */
|
|
8
|
-
/* JID utilities */
|
|
9
|
-
/* ------------------------------------------------------------------ */
|
|
10
|
-
|
|
11
7
|
export const S_WHATSAPP_NET = '@s.whatsapp.net'
|
|
12
8
|
export const OFFICIAL_BIZ_JID = '16505361212@c.us'
|
|
13
9
|
export const SERVER_JID = 'server@c.us'
|
|
@@ -85,10 +81,6 @@ export const transferDevice = (fromJid, toJid) => {
|
|
|
85
81
|
return jidEncode(user, server, deviceId)
|
|
86
82
|
}
|
|
87
83
|
|
|
88
|
-
/* ------------------------------------------------------------------ */
|
|
89
|
-
/* Binary node encode */
|
|
90
|
-
/* ------------------------------------------------------------------ */
|
|
91
|
-
|
|
92
84
|
export const encodeBinaryNode = (node, opts = constants, buffer = [0]) => {
|
|
93
85
|
const encoded = encodeBinaryNodeInner(node, opts, buffer)
|
|
94
86
|
return Buffer.from(encoded)
|
|
@@ -254,7 +246,7 @@ const encodeBinaryNodeInner = ({ tag, attrs, content }, opts, buffer) => {
|
|
|
254
246
|
writeListStart(validContent.length)
|
|
255
247
|
for (const item of validContent) encodeBinaryNodeInner(item, opts, buffer)
|
|
256
248
|
} else if (typeof content === 'undefined') {
|
|
257
|
-
|
|
249
|
+
|
|
258
250
|
} else {
|
|
259
251
|
throw new Error(`invalid children for header "${tag}": ${content} (${typeof content})`)
|
|
260
252
|
}
|
|
@@ -262,17 +254,13 @@ const encodeBinaryNodeInner = ({ tag, attrs, content }, opts, buffer) => {
|
|
|
262
254
|
return buffer
|
|
263
255
|
}
|
|
264
256
|
|
|
265
|
-
/* ------------------------------------------------------------------ */
|
|
266
|
-
/* Binary node decode */
|
|
267
|
-
/* ------------------------------------------------------------------ */
|
|
268
|
-
|
|
269
257
|
const inflatePromise = promisify(inflate)
|
|
270
258
|
|
|
271
259
|
export const decompressingIfRequired = async buffer => {
|
|
272
260
|
if (2 & buffer.readUInt8()) {
|
|
273
261
|
buffer = await inflatePromise(buffer.slice(1))
|
|
274
262
|
} else {
|
|
275
|
-
buffer = buffer.slice(1)
|
|
263
|
+
buffer = buffer.slice(1)
|
|
276
264
|
}
|
|
277
265
|
return buffer
|
|
278
266
|
}
|
|
@@ -488,10 +476,6 @@ export const decodeBinaryNode = async buff => {
|
|
|
488
476
|
return decodeDecompressedBinaryNode(decompBuff, constants)
|
|
489
477
|
}
|
|
490
478
|
|
|
491
|
-
/* ------------------------------------------------------------------ */
|
|
492
|
-
/* Generic node helpers */
|
|
493
|
-
/* ------------------------------------------------------------------ */
|
|
494
|
-
|
|
495
479
|
const indexCache = new WeakMap()
|
|
496
480
|
|
|
497
481
|
export const getBinaryNodeChildren = (node, childTag) => {
|
|
@@ -549,7 +533,6 @@ export const reduceBinaryNodeToDictionary = (node, tag) => {
|
|
|
549
533
|
}, {})
|
|
550
534
|
}
|
|
551
535
|
|
|
552
|
-
/** `proto` is passed in by the message decode call site to avoid a hard import cycle here. */
|
|
553
536
|
export const getBinaryNodeMessages = ({ content }, proto) => {
|
|
554
537
|
const msgs = []
|
|
555
538
|
if (Array.isArray(content)) {
|
|
@@ -576,11 +559,6 @@ export function binaryNodeToString(node, i = 0) {
|
|
|
576
559
|
return tag + content
|
|
577
560
|
}
|
|
578
561
|
|
|
579
|
-
/**
|
|
580
|
-
* Produce the binary node (WABinary-like JSON shape) required for the specific
|
|
581
|
-
* interactive button / list type. Compatible with observed official client traffic.
|
|
582
|
-
* NOTE: the "v" (version) / "name" values are empirically derived from real traffic.
|
|
583
|
-
*/
|
|
584
562
|
const FLOWS_MAP = {
|
|
585
563
|
mpm: true,
|
|
586
564
|
cta_catalog: true,
|
|
@@ -635,7 +613,7 @@ export const getBizBinaryNode = message => {
|
|
|
635
613
|
}
|
|
636
614
|
}
|
|
637
615
|
|
|
638
|
-
if (flowMsg || message.buttonsMessage || message.templateMessage) {
|
|
616
|
+
if (flowMsg || message.interactiveMessage?.carouselMessage || message.buttonsMessage || message.templateMessage) {
|
|
639
617
|
return { tag: 'biz', attrs: bizAttributes, content: [MIXED_NATIVE_FLOW, qualityContent] }
|
|
640
618
|
}
|
|
641
619
|
|
package/src/constants.js
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Enum and constant re-exports. Combines the entire former Types/ module
|
|
3
|
-
* (Auth, GroupMetadata, Chat, Contact, State, Message, Socket, Events, Product,
|
|
4
|
-
* Call, Signal, Mex, Label, LabelAssociation, RichType, index) — all of it was
|
|
5
|
-
* plain-object enums or pure proto re-exports with zero logic or dependencies.
|
|
6
|
-
*/
|
|
7
1
|
import { proto } from '../WAProto/index.js'
|
|
8
2
|
|
|
9
3
|
export { proto as WAProto }
|
|
10
4
|
|
|
11
5
|
export const ALL_WA_PATCH_NAMES = ['critical_block', 'critical_unblock_low', 'regular_high', 'regular_low', 'regular']
|
|
12
6
|
|
|
13
|
-
/* Message-related enums (from proto.Message) */
|
|
14
7
|
export const AssociationType = proto.MessageAssociation.AssociationType
|
|
15
8
|
export const ButtonHeaderType = proto.Message.ButtonsMessage.HeaderType
|
|
16
9
|
export const ButtonType = proto.Message.ButtonsMessage.Button.Type
|
|
@@ -22,7 +15,6 @@ export const WAMessageStatus = proto.WebMessageInfo.Status
|
|
|
22
15
|
|
|
23
16
|
export const WAMessageAddressingMode = { PN: 'pn', LID: 'lid' }
|
|
24
17
|
|
|
25
|
-
/* WhatsApp's 20 predefined label colors */
|
|
26
18
|
export const LabelColor = Object.freeze(
|
|
27
19
|
Object.fromEntries(Array.from({ length: 20 }, (_, i) => [`Color${i + 1}`, i]))
|
|
28
20
|
)
|
|
@@ -31,7 +23,8 @@ export const LabelAssociationType = { Chat: 'label_jid', Message: 'label_message
|
|
|
31
23
|
|
|
32
24
|
export const XWAPaths = {
|
|
33
25
|
xwa2_newsletter_create: 'xwa2_newsletter_create',
|
|
34
|
-
|
|
26
|
+
xwa2_newsletter_followers: 'xwa2_newsletter_followers',
|
|
27
|
+
xwa2_newsletter_admin_insights: 'xwa2_newsletter_admin_insights',
|
|
35
28
|
xwa2_newsletter_subscribed: 'xwa2_newsletter_subscribed',
|
|
36
29
|
xwa2_newsletter_view: 'xwa2_newsletter_view',
|
|
37
30
|
xwa2_newsletter_metadata: 'xwa2_newsletter',
|
|
@@ -53,7 +46,10 @@ export const QueryIds = {
|
|
|
53
46
|
CREATE: '8823471724422422',
|
|
54
47
|
UPDATE_METADATA: '24250201037901610',
|
|
55
48
|
METADATA: '6563316087068696',
|
|
56
|
-
|
|
49
|
+
PENDING_ADMIN_INVITES: '9783111038412085',
|
|
50
|
+
FOLLOWERS: '27472091235714801',
|
|
51
|
+
INSIGHTS: '9853618868050977',
|
|
52
|
+
ADMIN_INFO: '26278439461859188',
|
|
57
53
|
SUBSCRIBED: '6388546374527196',
|
|
58
54
|
FOLLOW: '24404358912487870',
|
|
59
55
|
UNFOLLOW: '9767147403369991',
|
|
@@ -82,7 +78,6 @@ export const RichSubMessageType = {
|
|
|
82
78
|
CONTENT_ITEMS: 9
|
|
83
79
|
}
|
|
84
80
|
|
|
85
|
-
/** The socket's high-level sync lifecycle state. */
|
|
86
81
|
export const SyncState = { Connecting: 0, AwaitingInitialSync: 1, Syncing: 2, Online: 3 }
|
|
87
82
|
|
|
88
83
|
export const ReachoutTimelockEnforcementType = {
|
|
@@ -102,7 +97,7 @@ export const ReachoutTimelockEnforcementType = {
|
|
|
102
97
|
BIZ_COMMERCE_VIOLATION_VIOLENT_CONTENT: 'BIZ_COMMERCE_VIOLATION_VIOLENT_CONTENT',
|
|
103
98
|
BIZ_COMMERCE_VIOLATION_WEAPONS: 'BIZ_COMMERCE_VIOLATION_WEAPONS',
|
|
104
99
|
BIZ_QUALITY: 'BIZ_QUALITY',
|
|
105
|
-
|
|
100
|
+
|
|
106
101
|
DEFAULT: 'DEFAULT',
|
|
107
102
|
WEB_COMPANION_ONLY: 'WEB_COMPANION_ONLY'
|
|
108
103
|
}
|
|
@@ -123,9 +118,6 @@ export const NewChatMessageCappingOTEStatusType = {
|
|
|
123
118
|
EXHAUSTED: 'EXHAUSTED'
|
|
124
119
|
}
|
|
125
120
|
|
|
126
|
-
// Mirrors the TypeScript enum emitted upstream: forward (name -> code) AND reverse (code -> name) mapping,
|
|
127
|
-
// e.g. DisconnectReason.loggedOut === 401 and DisconnectReason[401] === 'loggedOut'.
|
|
128
|
-
// Where two names share a code (408), the later one wins the reverse entry, same as upstream.
|
|
129
121
|
export const DisconnectReason = {}
|
|
130
122
|
for (const [name, code] of [
|
|
131
123
|
['connectionClosed', 428],
|
package/src/defaults.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Default connection configuration and misc protocol-level constants.
|
|
3
|
-
* Combines what used to be Defaults/index.js.
|
|
4
|
-
*/
|
|
5
1
|
import { proto } from '../WAProto/index.js'
|
|
6
2
|
import { makeLibSignalRepository } from './signal/signal-repository.js'
|
|
7
3
|
import { Browsers, KEY_BUNDLE_TYPE } from './utils/wa-protocol-core.js'
|
|
@@ -30,7 +26,7 @@ export const STATUS_EXPIRY_SECONDS = 24 * 60 * 60
|
|
|
30
26
|
export const PLACEHOLDER_MAX_AGE_SECONDS = 14 * 24 * 60 * 60
|
|
31
27
|
export const NOISE_MODE = 'Noise_XX_25519_AESGCM_SHA256\0\0\0\0'
|
|
32
28
|
export const DICT_VERSION = 3
|
|
33
|
-
|
|
29
|
+
|
|
34
30
|
export { KEY_BUNDLE_TYPE }
|
|
35
31
|
export const NOISE_WA_HEADER = Buffer.from([87, 65, 6, DICT_VERSION])
|
|
36
32
|
|
|
@@ -70,6 +66,7 @@ export const DEFAULT_CONNECTION_CONFIG = {
|
|
|
70
66
|
retryRequestDelayMs: 250,
|
|
71
67
|
maxMsgRetryCount: 5,
|
|
72
68
|
fireInitQueries: true,
|
|
69
|
+
disableStickyRouting: false,
|
|
73
70
|
auth: undefined,
|
|
74
71
|
markOnlineOnConnect: true,
|
|
75
72
|
syncFullHistory: true,
|