whalibmob 5.10.1 → 5.10.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 CHANGED
@@ -1455,6 +1455,10 @@ client.on('account_restriction', (r) => {
1455
1455
  > `fetchReachoutTimelock()` throws with `err.mexFormat === 'argo'` and the raw
1456
1456
  > bytes on `err.mexPayload`.
1457
1457
  >
1458
+ > Do not add a `format` attribute to the query in the hope of getting JSON — it
1459
+ > was tried against a live server, which responded by dropping the stanza
1460
+ > entirely. An answer in a format you cannot read still beats no answer.
1461
+ >
1458
1462
  > It never guesses. Reporting "not restricted" from an answer nobody decoded
1459
1463
  > would have you send more messages and make the restriction longer, so an
1460
1464
  > unreadable reply is an error rather than an all-clear.
@@ -3262,6 +3266,24 @@ For the numbers without the countdown:
3262
3266
  wa> /restriction --once
3263
3267
  ```
3264
3268
 
3269
+ To check the display without waiting to be restricted, `--demo` counts down a
3270
+ made-up restriction. Nothing is sent, nothing is asked of the server, and
3271
+ nothing is left behind when it ends:
3272
+
3273
+ ```sh
3274
+ wa> /restriction --demo
3275
+ ──────────────────────────────────────────────────
3276
+ status RESTRICTED (demo — not real)
3277
+ reason too many people you messaged blocked or reported you
3278
+ remaining 05:00:00
3279
+ ──────────────────────────────────────────────────
3280
+ press any key to stop watching
3281
+ restricted — 04:59:57 remaining
3282
+ ```
3283
+
3284
+ `--demo 90` uses ninety seconds instead of the default five hours, which is
3285
+ short enough to watch it reach zero and stop on its own.
3286
+
3265
3287
  If your server encodes this answer in Argo, the command says so rather than
3266
3288
  guessing — and points you at the announcements, which stay readable:
3267
3289
 
@@ -3794,6 +3816,7 @@ wa> /quit
3794
3816
  | `/appstate --snapshot` | Re-read all app state from scratch |
3795
3817
  | `/restriction` | Account restriction status with a live countdown |
3796
3818
  | `/restriction --once` | Restriction status without the countdown |
3819
+ | `/restriction --demo [seconds]` | Fake countdown, to check the display |
3797
3820
  | `/limit` | Alias for `/restriction` |
3798
3821
  | `/ephemeral <jid> <seconds>` | Set disappearing messages timer for a chat |
3799
3822
  | `/ephemeral-default <seconds>` | Set global default ephemeral timer for new chats |
package/cli.js CHANGED
@@ -478,6 +478,7 @@ const HELP = `
478
478
  /appstate --snapshot re-read all of it from scratch
479
479
  /restriction account restriction + live countdown
480
480
  /restriction --once just the numbers, no countdown
481
+ /restriction --demo [seconds] fake countdown to check the display
481
482
  /ephemeral <jid> <seconds> set disappearing timer for chat
482
483
  /ephemeral-default <seconds> set default timer for ALL new chats
483
484
  /block <jid> block contact
@@ -1479,6 +1480,34 @@ async function handleLine(line) {
1479
1480
 
1480
1481
  case '/restriction':
1481
1482
  case '/limit': {
1483
+ // --demo feeds a made-up restriction into this session and counts it
1484
+ // down, so the display can be checked without waiting to be restricted.
1485
+ // Nothing is sent and nothing is asked of the server.
1486
+ const demoAt = p.indexOf('--demo');
1487
+ if (demoAt !== -1) {
1488
+ const secs = parseInt(p[demoAt + 1], 10) || 5 * 3600;
1489
+ const { parseTimelockPayload } = require('./lib/ReachoutTimelock');
1490
+ if (!_client) { fail('/restriction --demo needs a client; use /connect first'); break; }
1491
+ const fake = parseTimelockPayload({
1492
+ is_active: true,
1493
+ time_enforcement_ends: String(Math.floor(Date.now() / 1000) + secs),
1494
+ enforcement_type: 'BIZ_QUALITY'
1495
+ });
1496
+ const shown = _client._setReachoutTimelock(fake, 'demo');
1497
+ hr();
1498
+ kv('status', 'RESTRICTED (demo — not real)');
1499
+ kv('reason', shown.reason);
1500
+ kv('remaining', shown.remaining);
1501
+ hr();
1502
+ _rl && _rl.pause();
1503
+ await countdown(_client, shown);
1504
+ _rl && _rl.resume();
1505
+ // Leave nothing behind that a later check could mistake for real.
1506
+ _client._reachoutTimelock = null;
1507
+ out(' demo over — nothing was recorded');
1508
+ break;
1509
+ }
1510
+
1482
1511
  requireConn();
1483
1512
  const watch = !p.includes('--once');
1484
1513
  out('checking account restriction...');
package/lib/Client.js CHANGED
@@ -4961,32 +4961,18 @@ class WhalibmobClient extends EventEmitter {
4961
4961
  async _mexQuery(queryId, variables, dataPath) {
4962
4962
  const body = Buffer.from(JSON.stringify({ variables: variables || {} }), 'utf8');
4963
4963
 
4964
- const send = (askForJson) => {
4965
- const attrs = { query_id: String(queryId) };
4966
- // Newer servers answer this transport in Argo, Meta's binary GraphQL
4967
- // encoding, which nothing here can read. The reply labels its own format,
4968
- // so the format is evidently negotiable — ask for the one we can parse.
4969
- // A server that does not know the attribute ignores it, and one that
4970
- // refuses the stanza over it is handled below.
4971
- if (askForJson) attrs.format = 'json';
4972
- return this._sendIq(new BinaryNode('iq', {
4973
- id: this._genMsgId(),
4974
- to: 's.whatsapp.net',
4975
- type: 'get',
4976
- xmlns: 'w:mex'
4977
- }, [new BinaryNode('query', attrs, body)]));
4978
- };
4979
-
4980
- const hinted = this._mexJsonHintWorks !== false;
4981
- let resp = await send(hinted);
4982
-
4983
- // The hint is the only thing that changed, so a refusal means the server
4984
- // does not accept it. Drop it for this session and ask again plainly.
4985
- if (hinted && resp && resp.attrs && resp.attrs.type === 'error') {
4986
- this._mexJsonHintWorks = false;
4987
- _whaDbg('[DBG] MEX format=json hint refused — retrying without it');
4988
- resp = await send(false);
4989
- }
4964
+ // The <query> node carries the query id and nothing else.
4965
+ //
4966
+ // Asking for a format here was tried and is wrong: a `format="json"`
4967
+ // attribute makes the server drop the stanza on the floor — no reply at
4968
+ // all, where without it there is at least an answer. It does not ignore
4969
+ // what it does not recognise, so nothing speculative belongs on this node.
4970
+ const resp = await this._sendIq(new BinaryNode('iq', {
4971
+ id: this._genMsgId(),
4972
+ to: 's.whatsapp.net',
4973
+ type: 'get',
4974
+ xmlns: 'w:mex'
4975
+ }, [new BinaryNode('query', { query_id: String(queryId) }, body)]));
4990
4976
 
4991
4977
  if (!resp) throw new Error('mex query ' + queryId + ': no reply from server (IQ timed out)');
4992
4978
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whalibmob",
3
- "version": "5.10.1",
3
+ "version": "5.10.3",
4
4
  "description": "WhatsApp library for interaction with WhatsApp Mobile API no web",
5
5
  "author": "Kunboruto20",
6
6
  "main": "index.js",