@n4tzz/n4lyx 2.7.1 → 2.7.3
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 +106 -20
- package/WAProto/WAProto.proto +122 -0
- package/WAProto/index.d.ts +1003 -0
- package/WAProto/index.js +3208 -0
- package/lib/Utils/validate-connection.js +5 -15
- package/package.json +1 -1
package/README.MD
CHANGED
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
> WhatsApp Web API — multi-device, TypeScript-first, built different.
|
|
4
4
|
|
|
5
|
-
[](https://npmjs.com/package/n4lyx)
|
|
5
|
+
[](https://npmjs.com/package/@n4tzz/n4lyx)
|
|
6
6
|
[](LICENSE)
|
|
7
|
-
[](https://npmjs.com/package/n4lyx)
|
|
7
|
+
[](https://npmjs.com/package/@n4tzz/n4lyx)
|
|
8
|
+
[](package.json)
|
|
8
9
|
|
|
9
10
|
---
|
|
10
11
|
|
|
11
|
-
**n4lyx** is a WhatsApp Web API library built for real projects. Proper `@lid → @pn` resolution, full multi-device support, clean TypeScript API. Fast, minimal, no bloat.
|
|
12
|
+
**n4lyx** is a WhatsApp Web API library built for real projects. Proper `@lid → @pn` resolution, full multi-device support, clean TypeScript API. Fast, minimal, no bloat. Ships with exclusive features like tag-all and group status v2 that upstream doesn't have.
|
|
12
13
|
|
|
13
14
|
> Not affiliated with WhatsApp Inc. Don't spam. Don't abuse. You're responsible for how you use this.
|
|
14
15
|
|
|
@@ -17,15 +18,13 @@
|
|
|
17
18
|
## Install
|
|
18
19
|
|
|
19
20
|
```bash
|
|
20
|
-
npm i n4lyx
|
|
21
|
-
# or latest build
|
|
22
|
-
npm i n4lyx@latest
|
|
21
|
+
npm i @n4tzz/n4lyx
|
|
23
22
|
```
|
|
24
23
|
|
|
25
24
|
```js
|
|
26
|
-
const { default: makeWASocket } = require('n4lyx')
|
|
25
|
+
const { default: makeWASocket } = require('@n4tzz/n4lyx')
|
|
27
26
|
// ESM
|
|
28
|
-
import makeWASocket from 'n4lyx'
|
|
27
|
+
import makeWASocket from '@n4tzz/n4lyx'
|
|
29
28
|
```
|
|
30
29
|
|
|
31
30
|
---
|
|
@@ -33,7 +32,11 @@ import makeWASocket from 'n4lyx'
|
|
|
33
32
|
## Quick Start
|
|
34
33
|
|
|
35
34
|
```js
|
|
36
|
-
const {
|
|
35
|
+
const {
|
|
36
|
+
default: makeWASocket,
|
|
37
|
+
DisconnectReason,
|
|
38
|
+
useMultiFileAuthState
|
|
39
|
+
} = require('@n4tzz/n4lyx')
|
|
37
40
|
const { Boom } = require('@hapi/boom')
|
|
38
41
|
|
|
39
42
|
async function connect() {
|
|
@@ -49,6 +52,8 @@ async function connect() {
|
|
|
49
52
|
if (connection === 'close') {
|
|
50
53
|
const code = (lastDisconnect?.error as Boom)?.output?.statusCode
|
|
51
54
|
if (code !== DisconnectReason.loggedOut) connect()
|
|
55
|
+
} else if (connection === 'open') {
|
|
56
|
+
console.log('connected')
|
|
52
57
|
}
|
|
53
58
|
})
|
|
54
59
|
|
|
@@ -72,7 +77,7 @@ connect()
|
|
|
72
77
|
### QR Code
|
|
73
78
|
|
|
74
79
|
```js
|
|
75
|
-
const { default: makeWASocket, Browsers } = require('n4lyx')
|
|
80
|
+
const { default: makeWASocket, Browsers } = require('@n4tzz/n4lyx')
|
|
76
81
|
|
|
77
82
|
const sock = makeWASocket({
|
|
78
83
|
browser: Browsers.ubuntu('n4lyx'),
|
|
@@ -102,7 +107,7 @@ if (!sock.authState.creds.registered) {
|
|
|
102
107
|
### Persist Auth
|
|
103
108
|
|
|
104
109
|
```js
|
|
105
|
-
const { useMultiFileAuthState } = require('n4lyx')
|
|
110
|
+
const { useMultiFileAuthState } = require('@n4tzz/n4lyx')
|
|
106
111
|
|
|
107
112
|
const { state, saveCreds } = await useMultiFileAuthState('auth')
|
|
108
113
|
const sock = makeWASocket({ auth: state })
|
|
@@ -130,7 +135,6 @@ Required for group-heavy bots. Cuts down repeated API calls significantly.
|
|
|
130
135
|
|
|
131
136
|
```js
|
|
132
137
|
const NodeCache = require('node-cache')
|
|
133
|
-
|
|
134
138
|
const groupCache = new NodeCache({ stdTTL: 5 * 60, useClones: false })
|
|
135
139
|
|
|
136
140
|
const sock = makeWASocket({
|
|
@@ -171,7 +175,7 @@ const sock = makeWASocket({ markOnlineOnConnect: false })
|
|
|
171
175
|
n4lyx doesn't ship a default persistent store. A basic in-memory store is available for local dev and testing — not recommended for production.
|
|
172
176
|
|
|
173
177
|
```js
|
|
174
|
-
const { makeInMemoryStore } = require('n4lyx')
|
|
178
|
+
const { makeInMemoryStore } = require('@n4tzz/n4lyx')
|
|
175
179
|
|
|
176
180
|
const store = makeInMemoryStore({})
|
|
177
181
|
store.readFromFile('./store.json')
|
|
@@ -215,6 +219,41 @@ await sock.sendMessage(jid, {
|
|
|
215
219
|
})
|
|
216
220
|
```
|
|
217
221
|
|
|
222
|
+
### Tag All — n4lyx exclusive
|
|
223
|
+
|
|
224
|
+
Mention every member in a group. Automatically fetches participant list — no manual work.
|
|
225
|
+
|
|
226
|
+
```js
|
|
227
|
+
// Tag all members
|
|
228
|
+
await sock.sendMessage(jid, {
|
|
229
|
+
text: '@everyone listen up',
|
|
230
|
+
tagAll: true
|
|
231
|
+
})
|
|
232
|
+
|
|
233
|
+
// Tag admins only
|
|
234
|
+
await sock.sendMessage(jid, {
|
|
235
|
+
text: 'admins only',
|
|
236
|
+
tagAll: true,
|
|
237
|
+
tagAllScope: 'admins'
|
|
238
|
+
})
|
|
239
|
+
|
|
240
|
+
// Tag non-admins only
|
|
241
|
+
await sock.sendMessage(jid, {
|
|
242
|
+
text: 'members',
|
|
243
|
+
tagAll: true,
|
|
244
|
+
tagAllScope: 'non_admins'
|
|
245
|
+
})
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
`tagAllScope` options: `'all'` (default) | `'admins'` | `'non_admins'`
|
|
249
|
+
|
|
250
|
+
You can also get the jid list directly:
|
|
251
|
+
|
|
252
|
+
```js
|
|
253
|
+
const jids = await sock.groupTagAll(groupJid, 'all')
|
|
254
|
+
// returns: ['628XXX@s.whatsapp.net', ...]
|
|
255
|
+
```
|
|
256
|
+
|
|
218
257
|
### Forward
|
|
219
258
|
|
|
220
259
|
```js
|
|
@@ -326,7 +365,7 @@ npm i link-preview-js
|
|
|
326
365
|
|
|
327
366
|
```js
|
|
328
367
|
await sock.sendMessage(jid, {
|
|
329
|
-
text: 'check this out: https://npmjs.com/package/n4lyx'
|
|
368
|
+
text: 'check this out: https://npmjs.com/package/@n4tzz/n4lyx'
|
|
330
369
|
})
|
|
331
370
|
```
|
|
332
371
|
|
|
@@ -351,7 +390,7 @@ await sock.sendMessage(jid, {
|
|
|
351
390
|
## Downloading Media
|
|
352
391
|
|
|
353
392
|
```js
|
|
354
|
-
import { downloadMediaMessage, getContentType } from 'n4lyx'
|
|
393
|
+
import { downloadMediaMessage, getContentType } from '@n4tzz/n4lyx'
|
|
355
394
|
import { createWriteStream } from 'fs'
|
|
356
395
|
|
|
357
396
|
sock.ev.on('messages.upsert', async ({ messages: [m] }) => {
|
|
@@ -476,6 +515,9 @@ await sock.groupToggleEphemeral(jid, 86400)
|
|
|
476
515
|
// Add mode
|
|
477
516
|
await sock.groupMemberAddMode(jid, 'all_member_add') // or 'admin_add'
|
|
478
517
|
|
|
518
|
+
// Join approval mode
|
|
519
|
+
await sock.groupJoinApprovalMode(jid, 'on') // or 'off'
|
|
520
|
+
|
|
479
521
|
// Join requests
|
|
480
522
|
const requests = await sock.groupRequestParticipantsList(jid)
|
|
481
523
|
await sock.groupRequestParticipantsUpdate(jid, ['jid@s.whatsapp.net'], 'approve') // or 'reject'
|
|
@@ -484,6 +526,36 @@ await sock.groupRequestParticipantsUpdate(jid, ['jid@s.whatsapp.net'], 'approve'
|
|
|
484
526
|
const all = await sock.groupFetchAllParticipating()
|
|
485
527
|
```
|
|
486
528
|
|
|
529
|
+
### Group Status V2 — n4lyx exclusive
|
|
530
|
+
|
|
531
|
+
Extended group status with full metadata control.
|
|
532
|
+
|
|
533
|
+
```js
|
|
534
|
+
// Set group status v2
|
|
535
|
+
await sock.groupSetStatusV2(jid, {
|
|
536
|
+
duration: 86400, // seconds (default: 86400 = 24h)
|
|
537
|
+
allowReply: true, // allow members to reply (default: true)
|
|
538
|
+
allowReaction: true, // allow reactions (default: true)
|
|
539
|
+
visibility: 'all' // 'all' | 'admin' (default: 'all')
|
|
540
|
+
})
|
|
541
|
+
|
|
542
|
+
// Get current group status v2 settings
|
|
543
|
+
const settings = await sock.groupGetStatusV2(jid)
|
|
544
|
+
console.log(settings)
|
|
545
|
+
// { duration: 86400, allowReply: true, allowReaction: true, visibility: 'all' }
|
|
546
|
+
|
|
547
|
+
// Send message as group status v2
|
|
548
|
+
await sock.sendMessage(jid, {
|
|
549
|
+
text: 'group announcement',
|
|
550
|
+
groupStatusV2: {
|
|
551
|
+
duration: 604800, // 7 days
|
|
552
|
+
allowReply: false,
|
|
553
|
+
allowReaction: true,
|
|
554
|
+
visibility: 'all'
|
|
555
|
+
}
|
|
556
|
+
})
|
|
557
|
+
```
|
|
558
|
+
|
|
487
559
|
---
|
|
488
560
|
|
|
489
561
|
## Presence
|
|
@@ -571,7 +643,6 @@ await sock.removeProfilePicture(jid)
|
|
|
571
643
|
## Broadcast & Stories
|
|
572
644
|
|
|
573
645
|
```js
|
|
574
|
-
// Send to story / broadcast list
|
|
575
646
|
await sock.sendMessage(
|
|
576
647
|
'status@broadcast',
|
|
577
648
|
{ image: { url: url }, caption: 'caption' },
|
|
@@ -627,7 +698,6 @@ sock.ev.on('messages.update', async (events) => {
|
|
|
627
698
|
## Low-Level: WebSocket Callbacks
|
|
628
699
|
|
|
629
700
|
```js
|
|
630
|
-
// Intercept raw WA frames
|
|
631
701
|
sock.ws.on('CB:edge_routing', (node) => { })
|
|
632
702
|
sock.ws.on('CB:edge_routing,id:abcd', (node) => { })
|
|
633
703
|
sock.ws.on('CB:edge_routing,id:abcd,routing_info', (node) => { })
|
|
@@ -660,15 +730,31 @@ const sock = makeWASocket({ logger: P({ level: 'debug' }) })
|
|
|
660
730
|
| `getDevice(msg)` | Returns sender's device info |
|
|
661
731
|
| `makeCacheableSignalKeyStore` | Speeds up auth key store operations |
|
|
662
732
|
| `downloadContentFromMessage` | Downloads raw content from a message |
|
|
733
|
+
| `fetchLatestN4lyxVersion` | Fetches latest n4lyx version from npm |
|
|
734
|
+
| `fetchLatestWaWebVersion` | Fetches latest WA Web version |
|
|
735
|
+
|
|
736
|
+
---
|
|
737
|
+
|
|
738
|
+
## n4lyx Exclusive Features
|
|
739
|
+
|
|
740
|
+
| Feature | Description |
|
|
741
|
+
|---|---|
|
|
742
|
+
| `tagAll` in `sendMessage` | Auto-mention all/admins/non-admins in a group |
|
|
743
|
+
| `groupTagAll(jid, scope)` | Get list of participant jids by scope |
|
|
744
|
+
| `groupSetStatusV2(jid, opts)` | Set group status v2 with full metadata |
|
|
745
|
+
| `groupGetStatusV2(jid)` | Get current group status v2 settings |
|
|
746
|
+
| `N4lyxMeta` in proto | Internal message metadata (version, session, timestamp) |
|
|
747
|
+
| `GroupStatusV2Message` in proto | Extended group status message type |
|
|
748
|
+
| `TagAllMessage` in proto | Tag-all message type with scope support |
|
|
663
749
|
|
|
664
750
|
---
|
|
665
751
|
|
|
666
752
|
## Optional Dependencies
|
|
667
753
|
|
|
668
754
|
```bash
|
|
669
|
-
npm i jimp
|
|
670
|
-
npm i link-preview-js
|
|
671
|
-
npm i qrcode-terminal
|
|
755
|
+
npm i jimp # or sharp — thumbnail generation
|
|
756
|
+
npm i link-preview-js # link previews in text messages
|
|
757
|
+
npm i qrcode-terminal # QR rendering in terminal
|
|
672
758
|
```
|
|
673
759
|
|
|
674
760
|
Video thumbnails require `ffmpeg` on your system.
|
package/WAProto/WAProto.proto
CHANGED
|
@@ -537,6 +537,128 @@ message NoiseCertificate {
|
|
|
537
537
|
}
|
|
538
538
|
|
|
539
539
|
|
|
540
|
+
// ─── CLIENT PAYLOAD ──────────────────────────────────────────
|
|
541
|
+
|
|
542
|
+
message ClientPayload {
|
|
543
|
+
optional uint64 username = 1;
|
|
544
|
+
optional bool passive = 3;
|
|
545
|
+
optional UserAgent userAgent = 5;
|
|
546
|
+
optional WebInfo webInfo = 6;
|
|
547
|
+
optional ConnectType connectType = 8;
|
|
548
|
+
optional ConnectReason connectReason = 9;
|
|
549
|
+
optional bytes shards = 11;
|
|
550
|
+
optional DNSSource dnsSource = 12;
|
|
551
|
+
optional uint32 device = 15;
|
|
552
|
+
optional DevicePairingRegistrationData devicePairingData = 16;
|
|
553
|
+
optional bool pull = 17;
|
|
554
|
+
optional bool recoverFromCompanionSession = 19;
|
|
555
|
+
optional bool recoverFromSessionPairSignedLtkMessage = 20;
|
|
556
|
+
optional string productType = 21;
|
|
557
|
+
optional bool fidoBrowserEnabled = 22;
|
|
558
|
+
optional bool iosPhoneNumberMigration = 23;
|
|
559
|
+
optional bool lidDbMigrated = 24;
|
|
560
|
+
|
|
561
|
+
enum ConnectReason {
|
|
562
|
+
PUSH = 0;
|
|
563
|
+
USER_ACTIVATED = 1;
|
|
564
|
+
SCHEDULED = 2;
|
|
565
|
+
ERROR_RECONNECT = 3;
|
|
566
|
+
NETWORK_SWITCH = 4;
|
|
567
|
+
PING_RECONNECT = 5;
|
|
568
|
+
}
|
|
569
|
+
enum ConnectType {
|
|
570
|
+
CELLULAR_UNKNOWN = 0;
|
|
571
|
+
WIFI_UNKNOWN = 1;
|
|
572
|
+
CELLULAR_EDGE = 100;
|
|
573
|
+
CELLULAR_IDEN = 101;
|
|
574
|
+
CELLULAR_UMTS = 102;
|
|
575
|
+
CELLULAR_EVDO = 103;
|
|
576
|
+
CELLULAR_GPRS = 104;
|
|
577
|
+
CELLULAR_HSDPA = 105;
|
|
578
|
+
CELLULAR_HSUPA = 106;
|
|
579
|
+
CELLULAR_HSPA = 107;
|
|
580
|
+
CELLULAR_CDMA = 108;
|
|
581
|
+
CELLULAR_1XRTT = 109;
|
|
582
|
+
CELLULAR_EHRPD = 110;
|
|
583
|
+
CELLULAR_LTE = 111;
|
|
584
|
+
CELLULAR_HSPAP = 112;
|
|
585
|
+
CELLULAR_NR = 113;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
message DevicePairingRegistrationData {
|
|
589
|
+
optional bytes eRegid = 1;
|
|
590
|
+
optional bytes eKeytype = 2;
|
|
591
|
+
optional bytes eIdent = 3;
|
|
592
|
+
optional bytes eSkeyId = 4;
|
|
593
|
+
optional bytes eSkeyVal = 5;
|
|
594
|
+
optional bytes eSkeySig = 6;
|
|
595
|
+
optional bytes buildHash = 7;
|
|
596
|
+
optional bytes deviceProps = 8;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
message DNSSource {
|
|
600
|
+
optional string dnsMethod = 1;
|
|
601
|
+
optional bool appCached = 2;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
message UserAgent {
|
|
605
|
+
optional Platform platform = 1;
|
|
606
|
+
optional AppVersion appVersion = 3;
|
|
607
|
+
optional string mcc = 4;
|
|
608
|
+
optional string mnc = 5;
|
|
609
|
+
optional string osVersion = 6;
|
|
610
|
+
optional string manufacturer = 7;
|
|
611
|
+
optional string device = 8;
|
|
612
|
+
optional string osBuildNumber = 9;
|
|
613
|
+
optional string phoneId = 10;
|
|
614
|
+
optional ReleaseChannel releaseChannel = 11;
|
|
615
|
+
optional string localeLanguageIso6391 = 12;
|
|
616
|
+
optional string localeCountryIso31661Alpha2 = 13;
|
|
617
|
+
optional string deviceBoard = 14;
|
|
618
|
+
|
|
619
|
+
message AppVersion {
|
|
620
|
+
optional uint32 primary = 1;
|
|
621
|
+
optional uint32 secondary = 2;
|
|
622
|
+
optional uint32 tertiary = 3;
|
|
623
|
+
optional uint32 quaternary = 4;
|
|
624
|
+
optional uint32 quinary = 5;
|
|
625
|
+
}
|
|
626
|
+
enum Platform {
|
|
627
|
+
ANDROID = 0;
|
|
628
|
+
IOS = 1;
|
|
629
|
+
WINDOWS_PHONE = 2;
|
|
630
|
+
BLACKBERRY = 3;
|
|
631
|
+
BLACKBERRY10 = 4;
|
|
632
|
+
WEB = 5;
|
|
633
|
+
PORTAL = 7;
|
|
634
|
+
FBLITE_ANDROID = 9;
|
|
635
|
+
MLITE_ANDROID = 11;
|
|
636
|
+
IPAD = 12;
|
|
637
|
+
FBLITE_IOS = 16;
|
|
638
|
+
MLITE_IOS = 17;
|
|
639
|
+
OCULUS_MSG = 18;
|
|
640
|
+
OCULUS_CALL = 19;
|
|
641
|
+
MILAN = 20;
|
|
642
|
+
NIOS = 21;
|
|
643
|
+
}
|
|
644
|
+
enum ReleaseChannel { RELEASE = 0; BETA = 1; ALPHA = 2; NIGHTLY = 3; }
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
message WebInfo {
|
|
648
|
+
optional string webdPayload = 1;
|
|
649
|
+
optional WebSubPlatform webSubPlatform = 2;
|
|
650
|
+
|
|
651
|
+
enum WebSubPlatform {
|
|
652
|
+
WEB_BROWSER = 0;
|
|
653
|
+
APP_STORE = 1;
|
|
654
|
+
WIN_STORE = 2;
|
|
655
|
+
DARWIN = 3;
|
|
656
|
+
WIN32 = 4;
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
|
|
540
662
|
// ─── CHAT ────────────────────────────────────────────────────
|
|
541
663
|
|
|
542
664
|
message ChatLockSettings {
|