whalibmob 5.33.34 → 5.40.32
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 +165 -15
- package/cli.js +527 -38
- package/docs/accounts-sessions.md +14 -818
- package/docs/accounts.md +122 -0
- package/docs/cli-commands.md +1193 -0
- package/docs/cli-getting-started.md +394 -0
- package/docs/cli.md +7 -1404
- package/docs/events-history.md +66 -24
- package/docs/groups-channels.md +36 -5
- package/docs/internals.md +2 -0
- package/docs/linking.md +276 -1
- package/docs/profile-privacy.md +33 -1
- package/docs/proxy.md +64 -0
- package/docs/push-token.md +103 -0
- package/docs/registration.md +57 -26
- package/docs/sessions.md +636 -0
- package/index.d.ts +513 -7
- package/index.js +21 -2
- package/lib/Client.js +1166 -6
- package/lib/HistorySyncHandler.js +6 -1
- package/lib/MediaService.js +5 -1
- package/lib/PrimaryBootstrap.js +551 -77
- package/lib/PrimaryLinkStore.js +545 -28
- package/lib/PrimaryLinking.js +66 -9
- package/lib/SessionPaths.js +41 -1
- package/lib/cli/linkCommands.js +1209 -0
- package/lib/messages/MessageSender.js +54 -5
- package/lib/primary/HistoryExport.js +365 -0
- package/lib/primary/MessageStore.js +1164 -0
- package/lib/primary/Readiness.js +286 -0
- package/lib/proto/MessageProto.js +49 -1
- package/lib/store/Backend.js +14 -2
- package/lib/store/FileBackend.js +6 -1
- package/lib/store/MemoryBackend.js +1 -1
- package/lib/store/SqliteBackend.js +1 -1
- package/lib/store/migrate.js +1 -1
- package/llms.txt +40 -25
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ code, and bring the account into being. Both transports, one API.
|
|
|
21
21
|
|
|
22
22
|
[](https://github.com/Kunboruto20/whalibmob/blob/main/docs/registration.md#register-a-new-number)
|
|
23
23
|
[](https://github.com/Kunboruto20/whalibmob/blob/main/docs/linking.md#linking-to-an-existing-account-pairing-code-or-qr)
|
|
24
|
-
[](https://github.com/Kunboruto20/whalibmob/blob/main/docs/cli.md#cli--getting-started)
|
|
24
|
+
[](https://github.com/Kunboruto20/whalibmob/blob/main/docs/cli-getting-started.md#cli--getting-started)
|
|
25
25
|
|
|
26
26
|
[](https://github.com/Kunboruto20/whalibmob/blob/main/docs/registration.md#library-api)
|
|
27
27
|
[](https://github.com/Kunboruto20/whalibmob/blob/main/docs/messaging.md#sending-messages)
|
|
@@ -29,7 +29,7 @@ code, and bring the account into being. Both transports, one API.
|
|
|
29
29
|
|
|
30
30
|
[](https://github.com/Kunboruto20/whalibmob/blob/main/docs/attestation.md#device-attestation--play-integrity-and-app-attest)
|
|
31
31
|
|
|
32
|
-
[](https://github.com/Kunboruto20/whalibmob/blob/main/docs/accounts
|
|
32
|
+
[](https://github.com/Kunboruto20/whalibmob/blob/main/docs/accounts.md#why-registration-can-be-blocked--the-anti-abuse-landscape)
|
|
33
33
|
|
|
34
34
|
</div>
|
|
35
35
|
|
|
@@ -96,6 +96,123 @@ npm install -g whalibmob
|
|
|
96
96
|
```
|
|
97
97
|
|
|
98
98
|
|
|
99
|
+
## Quick Start
|
|
100
|
+
|
|
101
|
+
One script that registers a number on its first run, then connects and sends a message. Save it as `quick-start.js`, set `PHONE` and `TO`, and run `node quick-start.js`.
|
|
102
|
+
|
|
103
|
+
```js
|
|
104
|
+
const {
|
|
105
|
+
WhalibmobClient, createNewStore, loadStore, saveStore,
|
|
106
|
+
requestSmsCode, verifyCode, storeFileFor
|
|
107
|
+
} = require('whalibmob')
|
|
108
|
+
const os = require('os')
|
|
109
|
+
const path = require('path')
|
|
110
|
+
const readline = require('readline/promises')
|
|
111
|
+
|
|
112
|
+
const PHONE = '40712345678' // your number: country code + number, no '+'
|
|
113
|
+
const TO = '40798765432' // who to message
|
|
114
|
+
const BASE_DIR = path.join(os.homedir(), '.waSession')
|
|
115
|
+
|
|
116
|
+
async function register(phone) {
|
|
117
|
+
const store = createNewStore(phone, { name: 'My Bot' })
|
|
118
|
+
await requestSmsCode(store, 'sms') // or 'voice'; throws when refused
|
|
119
|
+
|
|
120
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout })
|
|
121
|
+
const code = (await rl.question('6-digit code: ')).replace(/\D/g, '')
|
|
122
|
+
rl.close()
|
|
123
|
+
|
|
124
|
+
const result = await verifyCode(store, code) // updates `store` in place
|
|
125
|
+
if (!['ok', 'sent', 'verified'].includes(result.status)) {
|
|
126
|
+
throw new Error('registration failed: ' + JSON.stringify(result))
|
|
127
|
+
}
|
|
128
|
+
store.registered = true
|
|
129
|
+
store.codePending = false
|
|
130
|
+
// Saved only once registered, so a session file always means a live account.
|
|
131
|
+
saveStore(store, storeFileFor(BASE_DIR, store.phoneNumber))
|
|
132
|
+
if (store.phoneNumber !== phone) {
|
|
133
|
+
// WhatsApp can file the account under a slightly different number.
|
|
134
|
+
console.log(`WhatsApp knows this account as +${store.phoneNumber}: set PHONE to '${store.phoneNumber}'`)
|
|
135
|
+
}
|
|
136
|
+
return store.phoneNumber
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
async function main() {
|
|
140
|
+
let phone = PHONE
|
|
141
|
+
// Registering again would replace the account, so any saved session is used as is.
|
|
142
|
+
if (!loadStore(storeFileFor(BASE_DIR, phone))) phone = await register(phone)
|
|
143
|
+
|
|
144
|
+
const client = new WhalibmobClient({ sessionDir: BASE_DIR })
|
|
145
|
+
client.on('connected', () => console.log('connected as +' + phone))
|
|
146
|
+
client.on('reconnecting', ({ attempt }) => console.log('reconnecting, attempt', attempt))
|
|
147
|
+
client.on('auth_failure', ({ reason }) => { console.error('session ended:', reason); process.exit(1) })
|
|
148
|
+
client.on('message', msg => {
|
|
149
|
+
const d = msg.decoded
|
|
150
|
+
if (d && d.type === 'text') console.log('message from', msg.from + ':', d.text)
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
await client.init(phone) // resolves once logged in
|
|
154
|
+
await client.sendText(TO, 'Hello from whalibmob!')
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
main().catch(err => { console.error(err.message || err); process.exit(1) })
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
The client reconnects by itself after a dropped connection — do not create a new one on `disconnected`. Prefer no code at all? The [CLI](https://github.com/Kunboruto20/whalibmob/blob/main/docs/cli-getting-started.md#cli--getting-started) does the same in a few commands: request the code, register, connect, then `/send`. A brand-new account is watched closely by WhatsApp's anti-abuse checks, so send the first messages to people who have your number saved — see [Accounts](https://github.com/Kunboruto20/whalibmob/blob/main/docs/accounts.md#why-registration-can-be-blocked--the-anti-abuse-landscape).
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
## Approving a Companion Device
|
|
164
|
+
|
|
165
|
+
A number registered with whalibmob is the account's **primary device**, and from the CLI it can approve **WhatsApp Web** in the phone's place: Web is linked as a companion and is handed the chat history this program has kept for the number. That is not the whole history the account has ever had; what it covers is spelled out below. Keep the shell open until the chats have loaded.
|
|
166
|
+
|
|
167
|
+
```sh
|
|
168
|
+
wa connect 447949738354 --session ~/whalibmob_auth
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
1. On WhatsApp Web choose **Link with phone number** and enter the same phone number. Web shows an 8-character code, good for about three minutes. The shell announces the request:
|
|
172
|
+
```
|
|
173
|
+
wa +447949738354> link request companion c0ffee01 code window 2:50 id a1a1a1a1
|
|
174
|
+
```
|
|
175
|
+
2. Type the code into the shell (the dash, a space between the halves and the letter case do not matter):
|
|
176
|
+
```
|
|
177
|
+
wa +447949738354> /link-code ABCD-EFGH
|
|
178
|
+
```
|
|
179
|
+
3. If more than one browser is asking, nothing is approved. The shell lists them; repeat the command with the number or the id of yours, for example `/link-code ABCD-EFGH 2`.
|
|
180
|
+
4. If the history is known to be partial, the shell says what is and is not in it, and asks `[y/N]` before approving. Enter means no, and nothing is approved.
|
|
181
|
+
|
|
182
|
+
When it works, the shell ends with:
|
|
183
|
+
|
|
184
|
+
```
|
|
185
|
+
approval sent. The binding to the browser stays unconfirmed unless you confirm it with /link-confirm FILE|JSON (needs the companion's public proof JSON).
|
|
186
|
+
sending the stored history to the companion...
|
|
187
|
+
history handed to the companion: 12 chats, 340 messages, 20.0 KB (sent inline), first link
|
|
188
|
+
capture period: since registration: the store has been on since this number was registered
|
|
189
|
+
The history is handed over; whether Web has finished showing it cannot be seen from here. If Web stays on "Loading chats", run /link-status.
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
`/linked-devices` then shows the companion (the numbers are an example):
|
|
193
|
+
|
|
194
|
+
```
|
|
195
|
+
wa +447949738354> /linked-devices
|
|
196
|
+
linked devices +447949738354
|
|
197
|
+
#0 this phone (primary)
|
|
198
|
+
#12 companion key index 3 linked 2026-11-02 15:31 by code binding unconfirmed history delivered (12 chats, 340 msgs)
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
**What the history covers.** Only what this program stored for the number since its store began: since registration for a number registered here with the CLI, or since the store was first switched on for any other (`--no-message-store` switches it off). The store keeps the newest 100 messages of each chat and 20 000 in all, oldest first out. What it knows it lost (messages it could not decrypt or save, stretches when it was not running or could not write to disk) is reported, and the shell asks before approving unless the store has kept everything since registration and dropped nothing.
|
|
202
|
+
|
|
203
|
+
**What is never transferred.** The content of revoked, expired and view-once messages (a revoked message goes over as a deleted-message marker, the other two not at all), and reactions and poll votes, which are not stored, so they do not appear on the new device. Status posts and channels are not kept. A message of a type the library does not decode is kept as it was received and handed over unchanged, for Web to read.
|
|
204
|
+
|
|
205
|
+
**Limits.**
|
|
206
|
+
- A second companion while one is still linked is not supported: the shell refuses up front. Log the first one out of Web (Menu → Log out) first.
|
|
207
|
+
- The binding stays **unconfirmed** unless a companion's public proof JSON is reconciled with `/link-confirm FILE|JSON`. Standard WhatsApp Web is not known to offer such a proof, so with an ordinary browser expect it to stay unconfirmed; the device list from WhatsApp is what shows the companion is there.
|
|
208
|
+
|
|
209
|
+
**Linking again.** Log out on Web (Menu → Log out); wait until `/linked-devices` no longer lists it; run `/link-retire` (it works once the approval is 5 minutes old, and clears the hold an unconfirmed approval leaves behind); then `/link-code` again. Web is handed the history again, with the same app-state key.
|
|
210
|
+
|
|
211
|
+
**When it stops part-way.** `/link-bootstrap --resume` continues a handover after its last accepted step, and never sends blindly: a step whose reply never came is sent once more only with `--resend-uncertain`. `/link-unlock` shows who holds the lock on the link journal and breaks it only when you answer `y`: a lock left by a dead process on the same machine is recovered without it, and any other holder is reported as busy, with who holds it, until you have checked it is gone and unlocked.
|
|
212
|
+
|
|
213
|
+
The whole walk-through, every command and the library API (`messageStore`, `getPrimaryMessageStore()`, `getPrimaryLinkReadiness()`, `bootstrapPrimaryCompanion()`, `unlockPrimaryLink()`) are in [Approving a Companion Device](https://github.com/Kunboruto20/whalibmob/blob/main/docs/linking.md#approving-a-companion-device-primary-role); the commands alone are in [the CLI reference](https://github.com/Kunboruto20/whalibmob/blob/main/docs/cli-commands.md#companion-commands-approving-whatsapp-web).
|
|
214
|
+
|
|
215
|
+
|
|
99
216
|
## Documentation
|
|
100
217
|
|
|
101
218
|
The full guide is split by topic so every page loads fast and reads cleanly. Pick a section below.
|
|
@@ -104,10 +221,17 @@ The full guide is split by topic so every page loads fast and reads cleanly. Pic
|
|
|
104
221
|
|
|
105
222
|
- [Device Attestation — Play Integrity and App Attest](https://github.com/Kunboruto20/whalibmob/blob/main/docs/attestation.md#device-attestation--play-integrity-and-app-attest)
|
|
106
223
|
|
|
107
|
-
### [
|
|
224
|
+
### [CLI — Getting Started](https://github.com/Kunboruto20/whalibmob/blob/main/docs/cli-getting-started.md)
|
|
225
|
+
|
|
226
|
+
Install the CLI, register a number and connect, all from the terminal.
|
|
108
227
|
|
|
109
|
-
- [CLI — Getting Started](https://github.com/Kunboruto20/whalibmob/blob/main/docs/cli.md#cli--getting-started)
|
|
110
|
-
|
|
228
|
+
- [CLI — Getting Started](https://github.com/Kunboruto20/whalibmob/blob/main/docs/cli-getting-started.md#cli--getting-started)
|
|
229
|
+
|
|
230
|
+
### [CLI — Interactive Shell Commands](https://github.com/Kunboruto20/whalibmob/blob/main/docs/cli-commands.md)
|
|
231
|
+
|
|
232
|
+
Every command of the interactive shell: messages, presence, profile, chats, groups, channels.
|
|
233
|
+
|
|
234
|
+
- [CLI — Interactive Shell Commands](https://github.com/Kunboruto20/whalibmob/blob/main/docs/cli-commands.md#cli--interactive-shell-commands)
|
|
111
235
|
|
|
112
236
|
### [Registering & Connecting an Account](https://github.com/Kunboruto20/whalibmob/blob/main/docs/registration.md)
|
|
113
237
|
|
|
@@ -120,15 +244,32 @@ The full guide is split by topic so every page loads fast and reads cleanly. Pic
|
|
|
120
244
|
- [Companion Mode — Node.js API](https://github.com/Kunboruto20/whalibmob/blob/main/docs/linking.md#companion-mode--nodejs-api)
|
|
121
245
|
- [Approving a Companion Device (Primary Role)](https://github.com/Kunboruto20/whalibmob/blob/main/docs/linking.md#approving-a-companion-device-primary-role)
|
|
122
246
|
|
|
123
|
-
### [Accounts
|
|
247
|
+
### [Accounts — Number, Consent & Registration Blocks](https://github.com/Kunboruto20/whalibmob/blob/main/docs/accounts.md)
|
|
248
|
+
|
|
249
|
+
Which number WhatsApp files the account under, consent refusals, and why a registration can be blocked.
|
|
250
|
+
|
|
251
|
+
- [The Number WhatsApp Files Your Account Under](https://github.com/Kunboruto20/whalibmob/blob/main/docs/accounts.md#the-number-whatsapp-files-your-account-under)
|
|
252
|
+
- [When Registration Is Refused for Consent](https://github.com/Kunboruto20/whalibmob/blob/main/docs/accounts.md#when-registration-is-refused-for-consent)
|
|
253
|
+
- [Why Registration Can Be Blocked — The Anti-Abuse Landscape](https://github.com/Kunboruto20/whalibmob/blob/main/docs/accounts.md#why-registration-can-be-blocked--the-anti-abuse-landscape)
|
|
124
254
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
- [
|
|
130
|
-
|
|
131
|
-
|
|
255
|
+
### [The Push Token](https://github.com/Kunboruto20/whalibmob/blob/main/docs/push-token.md)
|
|
256
|
+
|
|
257
|
+
The Firebase (Android) and APNs (iOS) token a registration sends, and receiving the code over push.
|
|
258
|
+
|
|
259
|
+
- [The Push Token](https://github.com/Kunboruto20/whalibmob/blob/main/docs/push-token.md#the-push-token)
|
|
260
|
+
|
|
261
|
+
### [Routing Traffic Through a Proxy](https://github.com/Kunboruto20/whalibmob/blob/main/docs/proxy.md)
|
|
262
|
+
|
|
263
|
+
Sending everything the library sends out — registration, the message socket, media — through a SOCKS proxy or Tor.
|
|
264
|
+
|
|
265
|
+
- [Routing Traffic Through a Proxy](https://github.com/Kunboruto20/whalibmob/blob/main/docs/proxy.md#routing-traffic-through-a-proxy)
|
|
266
|
+
|
|
267
|
+
### [Sessions & Signal Store](https://github.com/Kunboruto20/whalibmob/blob/main/docs/sessions.md)
|
|
268
|
+
|
|
269
|
+
Where a session is kept, saving and restoring it, database backends, and the Signal store utilities.
|
|
270
|
+
|
|
271
|
+
- [Saving & Restoring Sessions](https://github.com/Kunboruto20/whalibmob/blob/main/docs/sessions.md#saving--restoring-sessions)
|
|
272
|
+
- [Signal Store Utilities](https://github.com/Kunboruto20/whalibmob/blob/main/docs/sessions.md#signal-store-utilities)
|
|
132
273
|
|
|
133
274
|
### [Handling Events & History Sync](https://github.com/Kunboruto20/whalibmob/blob/main/docs/events-history.md)
|
|
134
275
|
|
|
@@ -188,5 +329,14 @@ The **Sponsor** button at the top of the repository leads back here.
|
|
|
188
329
|
|
|
189
330
|
## License
|
|
190
331
|
|
|
191
|
-
MIT
|
|
192
|
-
|
|
332
|
+
MIT
|
|
333
|
+
|
|
334
|
+
## Star History
|
|
335
|
+
|
|
336
|
+
<a href="https://star-history.com/#Kunboruto20/whalibmob&Date">
|
|
337
|
+
<picture>
|
|
338
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=Kunboruto20/whalibmob&type=Date&theme=dark" />
|
|
339
|
+
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=Kunboruto20/whalibmob&type=Date" />
|
|
340
|
+
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=Kunboruto20/whalibmob&type=Date" />
|
|
341
|
+
</picture>
|
|
342
|
+
</a>
|