whalibmob 5.40.37 → 5.40.39
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 +1 -0
- package/cli.js +5 -4
- package/docs/events-history.md +47 -0
- package/index.d.ts +21 -0
- package/index.js +6 -0
- package/lib/AndroidApk.js +13 -12
- package/lib/BinaryNode.js +2 -1
- package/lib/Client.js +273 -269
- package/lib/CompanionPairing.js +3 -1
- package/lib/DeviceConfig.js +10 -0
- package/lib/DeviceManager.js +2 -1
- package/lib/HistorySyncHandler.js +13 -11
- package/lib/MediaService.js +14 -12
- package/lib/OfflineNodeProcessor.js +3 -1
- package/lib/PairingCode.js +2 -1
- package/lib/PasskeyPairing.js +18 -17
- package/lib/PlayStore.js +15 -13
- package/lib/PrimaryLinkCrypto.js +2 -1
- package/lib/Registration.js +76 -38
- package/lib/Store.js +6 -5
- package/lib/WebSocketStream.js +3 -2
- package/lib/WebVersion.js +5 -3
- package/lib/apns-courier.js +15 -13
- package/lib/apns.js +6 -4
- package/lib/argo/ArgoDecoder.js +16 -14
- package/lib/auth-utils.js +10 -9
- package/lib/cli/linkCommands.js +5 -2
- package/lib/constants.js +20 -15
- package/lib/curve.js +5 -4
- package/lib/errors.js +42 -0
- package/lib/fcm.js +7 -5
- package/lib/image/JpegEncoder.js +4 -2
- package/lib/messages/MediaRetry.js +3 -2
- package/lib/messages/MessageSecret.js +9 -8
- package/lib/messages/MessageSender.js +30 -28
- package/lib/noise.js +13 -11
- package/lib/plist.js +18 -15
- package/lib/primary/HistoryExport.js +2 -1
- package/lib/primary/MessageStore.js +8 -2
- package/lib/proto/MessageProto.js +3 -1
- package/lib/signal/SenderKey.js +5 -4
- package/lib/signal/WaSignalGroup/group-session-builder.js +2 -1
- package/lib/signal/WaSignalGroup/group_cipher.js +10 -9
- package/lib/signal/WaSignalGroup/sender-key-distribution-message.js +2 -1
- package/lib/signal/WaSignalGroup/sender-key-message.js +2 -1
- package/lib/socks.js +9 -8
- package/lib/store/Backend.js +3 -1
- package/lib/store/FileBackend.js +2 -1
- package/lib/store/MemoryBackend.js +2 -1
- package/lib/store/SqliteBackend.js +6 -5
- package/lib/store/migrate.js +2 -1
- package/llms.txt +1 -0
- package/package.json +2 -1
package/lib/socks.js
CHANGED
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
// curl honours SOCKS_PROXY, https.get does not. Same machine, same proxy,
|
|
27
27
|
// opposite results.
|
|
28
28
|
|
|
29
|
+
const { Boom } = require('@hapi/boom');
|
|
29
30
|
const https = require('https');
|
|
30
31
|
const tls = require('tls');
|
|
31
32
|
|
|
@@ -51,16 +52,16 @@ function loadSocks() {
|
|
|
51
52
|
if (override) {
|
|
52
53
|
try { return require(override); }
|
|
53
54
|
catch (err) {
|
|
54
|
-
throw new
|
|
55
|
+
throw new Boom('WA_SOCKS_LIB points at ' + override +
|
|
55
56
|
' but it could not be loaded: ' + err.message);
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
59
|
try {
|
|
59
60
|
return require('socks');
|
|
60
61
|
} catch (_) {
|
|
61
|
-
throw new
|
|
62
|
+
throw new Boom(
|
|
62
63
|
"A SOCKS proxy is configured but the 'socks' package is not installed. " +
|
|
63
|
-
'Run: npm install socks'
|
|
64
|
+
'Run: npm install socks', { statusCode: 501 }
|
|
64
65
|
);
|
|
65
66
|
}
|
|
66
67
|
}
|
|
@@ -73,7 +74,7 @@ function loadSocks() {
|
|
|
73
74
|
*/
|
|
74
75
|
function parseSocksProxy(proxyUrl) {
|
|
75
76
|
let raw = String(proxyUrl || '').trim();
|
|
76
|
-
if (!raw) throw new
|
|
77
|
+
if (!raw) throw new Boom('No SOCKS proxy configured', { statusCode: 400 });
|
|
77
78
|
|
|
78
79
|
// A bare host:port is what .env.example has always shown and what most people
|
|
79
80
|
// type. Without a scheme `new URL` reads "127.0.0.1:" as the protocol and the
|
|
@@ -82,14 +83,14 @@ function parseSocksProxy(proxyUrl) {
|
|
|
82
83
|
|
|
83
84
|
let url;
|
|
84
85
|
try { url = new URL(raw); }
|
|
85
|
-
catch (_) { throw new
|
|
86
|
+
catch (_) { throw new Boom('Invalid SOCKS proxy URL: ' + proxyUrl, { statusCode: 400 }); }
|
|
86
87
|
|
|
87
88
|
const type = SOCKS_SCHEMES[url.protocol];
|
|
88
89
|
if (!type) {
|
|
89
|
-
throw new
|
|
90
|
-
Object.keys(SOCKS_SCHEMES).map(s => s.replace(':', '')).join(', '));
|
|
90
|
+
throw new Boom('Unsupported proxy scheme "' + url.protocol + '" — use ' +
|
|
91
|
+
Object.keys(SOCKS_SCHEMES).map(s => s.replace(':', '')).join(', '), { statusCode: 400 });
|
|
91
92
|
}
|
|
92
|
-
if (!url.hostname) throw new
|
|
93
|
+
if (!url.hostname) throw new Boom('SOCKS proxy URL has no host: ' + proxyUrl, { statusCode: 400 });
|
|
93
94
|
|
|
94
95
|
const proxy = {
|
|
95
96
|
host: url.hostname,
|
package/lib/store/Backend.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const { Boom } = require('@hapi/boom');
|
|
4
|
+
|
|
3
5
|
// Where a session's state is kept.
|
|
4
6
|
//
|
|
5
7
|
// Every piece of state a number owns — the credentials, the Signal sessions,
|
|
@@ -106,7 +108,7 @@ const PRE_KEY_PREFIX = 'pre-key/';
|
|
|
106
108
|
function preKeyKey(id) {
|
|
107
109
|
const n = Number(id);
|
|
108
110
|
if (!Number.isInteger(n) || n < 0) {
|
|
109
|
-
throw new
|
|
111
|
+
throw new Boom('preKeyKey: id must be a non-negative integer, got ' + id, { statusCode: 400 });
|
|
110
112
|
}
|
|
111
113
|
return PRE_KEY_PREFIX + n;
|
|
112
114
|
}
|
package/lib/store/FileBackend.js
CHANGED
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
// a process that died mid-write — which, for the file holding a number's
|
|
24
24
|
// identity keys, is the difference between a session and a lost number.
|
|
25
25
|
|
|
26
|
+
const { Boom } = require('@hapi/boom');
|
|
26
27
|
const fs = require('fs');
|
|
27
28
|
const path = require('path');
|
|
28
29
|
|
|
@@ -85,7 +86,7 @@ class FileBackend {
|
|
|
85
86
|
return path.join(this.dir, this._stem + PRE_KEY_INFIX + id + '.json');
|
|
86
87
|
}
|
|
87
88
|
const suffix = KEY_SUFFIX[key];
|
|
88
|
-
if (!suffix) throw new
|
|
89
|
+
if (!suffix) throw new Boom('FileBackend: unknown key ' + JSON.stringify(key), { statusCode: 400 });
|
|
89
90
|
return path.join(this.dir, this._stem + suffix);
|
|
90
91
|
}
|
|
91
92
|
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
// registration is spent, the number is taken, and the keys that proved it was
|
|
20
20
|
// yours are gone. Use it for sessions that were never meant to outlive the run.
|
|
21
21
|
|
|
22
|
+
const { Boom } = require('@hapi/boom');
|
|
22
23
|
const { isValidKey } = require('./Backend');
|
|
23
24
|
|
|
24
25
|
class MemoryBackend {
|
|
@@ -65,7 +66,7 @@ class MemoryBackend {
|
|
|
65
66
|
// which is the one failure a second implementation exists to catch.
|
|
66
67
|
_assertKey(key) {
|
|
67
68
|
if (!isValidKey(key)) {
|
|
68
|
-
throw new
|
|
69
|
+
throw new Boom('MemoryBackend: unknown key ' + JSON.stringify(key), { statusCode: 400 });
|
|
69
70
|
}
|
|
70
71
|
}
|
|
71
72
|
}
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
// the bytes go in and come back exactly, whatever is in them, so that is what
|
|
35
35
|
// the column is and the conversion happens here rather than in the caller.
|
|
36
36
|
|
|
37
|
+
const { Boom } = require('@hapi/boom');
|
|
37
38
|
const path = require('path');
|
|
38
39
|
const fs = require('fs');
|
|
39
40
|
|
|
@@ -117,7 +118,7 @@ function resolveDriver(prefer) {
|
|
|
117
118
|
if (!driver) {
|
|
118
119
|
const [major, minor] = process.versions.node.split('.').map(Number);
|
|
119
120
|
const tooOld = major < 22 || (major === 22 && minor < 5);
|
|
120
|
-
throw new
|
|
121
|
+
throw new Boom(
|
|
121
122
|
'SqliteBackend: no SQLite driver available.\n' +
|
|
122
123
|
(tooOld
|
|
123
124
|
? ` Node ${process.versions.node} has no built-in SQLite — it arrives in 22.5.0.\n` +
|
|
@@ -126,7 +127,7 @@ function resolveDriver(prefer) {
|
|
|
126
127
|
: ` node:sqlite should be present on Node ${process.versions.node} but could not ` +
|
|
127
128
|
'be loaded.\n Install the fallback driver instead:\n' +
|
|
128
129
|
' npm install better-sqlite3\n') +
|
|
129
|
-
' Or leave it out entirely: the default FileBackend needs nothing installed.'
|
|
130
|
+
' Or leave it out entirely: the default FileBackend needs nothing installed.', { statusCode: 501 }
|
|
130
131
|
);
|
|
131
132
|
}
|
|
132
133
|
|
|
@@ -169,10 +170,10 @@ function _acquire(file, prefer) {
|
|
|
169
170
|
const version = found ? Number(found.user_version) : 0;
|
|
170
171
|
if (version > SCHEMA_VERSION) {
|
|
171
172
|
db.close();
|
|
172
|
-
throw new
|
|
173
|
+
throw new Boom(
|
|
173
174
|
`SqliteBackend: ${key} was written by a newer whalibmob (schema ` +
|
|
174
175
|
`${version}, this one understands ${SCHEMA_VERSION}). Upgrade whalibmob ` +
|
|
175
|
-
'rather than letting an older release write to it.'
|
|
176
|
+
'rather than letting an older release write to it.', { statusCode: 409 }
|
|
176
177
|
);
|
|
177
178
|
}
|
|
178
179
|
if (version < SCHEMA_VERSION) db.exec('PRAGMA user_version = ' + SCHEMA_VERSION);
|
|
@@ -234,7 +235,7 @@ class SqliteBackend {
|
|
|
234
235
|
|
|
235
236
|
_assertKey(key) {
|
|
236
237
|
if (!isValidKey(key)) {
|
|
237
|
-
throw new
|
|
238
|
+
throw new Boom('SqliteBackend: unknown key ' + JSON.stringify(key), { statusCode: 400 });
|
|
238
239
|
}
|
|
239
240
|
return key;
|
|
240
241
|
}
|
package/lib/store/migrate.js
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
// otherwise, which makes an interrupted copy safe to run again — it picks up
|
|
13
13
|
// what did not make it the first time and does not undo what did.
|
|
14
14
|
|
|
15
|
+
const { Boom } = require('@hapi/boom');
|
|
15
16
|
const { assertBackend } = require('./Backend');
|
|
16
17
|
|
|
17
18
|
/**
|
|
@@ -26,7 +27,7 @@ const { assertBackend } = require('./Backend');
|
|
|
26
27
|
function copySession(from, to, opts) {
|
|
27
28
|
assertBackend(from, 'source backend');
|
|
28
29
|
assertBackend(to, 'destination backend');
|
|
29
|
-
if (from === to) throw new
|
|
30
|
+
if (from === to) throw new Boom('copySession: source and destination are the same backend', { statusCode: 400 });
|
|
30
31
|
|
|
31
32
|
const overwrite = !!(opts && opts.overwrite);
|
|
32
33
|
const copied = [], skipped = [];
|
package/llms.txt
CHANGED
|
@@ -134,6 +134,7 @@ main().catch((err) => { console.error(err.message || err); process.exit(1); });
|
|
|
134
134
|
- [Media Messages](https://github.com/Kunboruto20/whalibmob#media-messages): images, video, audio, voice notes, documents, stickers
|
|
135
135
|
- [Receiving Media](https://github.com/Kunboruto20/whalibmob#receiving-media): downloading and decrypting what arrives
|
|
136
136
|
- [Handling Events](https://github.com/Kunboruto20/whalibmob#handling-events): the full event list, keepalive and offline-sync events included
|
|
137
|
+
- [Handling Errors](https://github.com/Kunboruto20/whalibmob/blob/main/docs/events-history.md#handling-errors): every error the library raises is a Boom (`@hapi/boom`) with an HTTP-style `err.output.statusCode` — 400 bad input, 401 not authenticated, 408 timed out, 428 not connected, 502 a server answered wrongly, or the server's own status passed through
|
|
137
138
|
- [Encrypted add-ons](https://github.com/Kunboruto20/whalibmob/blob/main/docs/messaging.md#encrypted-reactions-comments-event-responses-and-edits): poll votes, encrypted reactions, comments, event responses and edits; `sendRawMessage` for any encoded Message
|
|
138
139
|
- [History Sync](https://github.com/Kunboruto20/whalibmob#history-sync): the backlog the server sends on first connect, and reading it back
|
|
139
140
|
- [Status / Stories](https://github.com/Kunboruto20/whalibmob#status--stories): posting to status
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "whalibmob",
|
|
3
|
-
"version": "5.40.
|
|
3
|
+
"version": "5.40.39",
|
|
4
4
|
"description": "Node.js library for WhatsApp — register a number over SMS, or link as a companion by QR. Signal E2E encryption, media, groups, channels.",
|
|
5
5
|
"author": "Kunboruto20",
|
|
6
6
|
"main": "index.js",
|
|
@@ -66,6 +66,7 @@
|
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
68
|
"@cacheable/node-cache": "3.1.1",
|
|
69
|
+
"@hapi/boom": "^10.0.1",
|
|
69
70
|
"@noble/hashes": "^1.7.2",
|
|
70
71
|
"async-mutex": "^0.5.0",
|
|
71
72
|
"axios": "^1.7.2",
|