whalibmob 5.13.1 → 5.13.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
@@ -4611,7 +4611,15 @@ wa refresh-version 5568936182750 # then write its version into the session
4611
4611
  ```
4612
4612
 
4613
4613
  It touches `version` and nothing else — the keys, the device profile and the
4614
- registration are left exactly as they were. `--all` does every session in the
4614
+ registration are left exactly as they were — and it never moves a session
4615
+ backwards. The store it reads from can be behind what a session already holds,
4616
+ since Play serves the build matching the device profile it was asked with rather
4617
+ than the newest on the listing, and announcing an older version is the one
4618
+ outcome that makes a 405 more likely:
4619
+
4620
+ ```
4621
+ +40756218532 android 2.26.30.3 (kept — newer than the 2.26.29.73 available)
4622
+ ``` `--all` does every session in the
4615
4623
  session directory, which is what belongs in a monthly cron for a bot that is
4616
4624
  meant to stay up:
4617
4625
 
package/cli.js CHANGED
@@ -2395,7 +2395,11 @@ function announceTrace() {
2395
2395
  function askDebugMode(cmd) {
2396
2396
  if (TRACE_FORCE_ON) { enableWireTrace(); announceTrace(); return Promise.resolve(); }
2397
2397
  if (TRACE_FORCE_OFF) return Promise.resolve();
2398
- const OFFLINE = ['version', '--version', '-v', 'help', '--help', '-h'];
2398
+ // Commands that never open a WhatsApp connection: there is no wire for a
2399
+ // trace to show, and stopping a maintenance command to ask is what makes
2400
+ // `wa apk-material --download && wa refresh-version --all` prompt twice.
2401
+ const OFFLINE = ['version', '--version', '-v', 'help', '--help', '-h',
2402
+ 'apk-material', 'refresh-version'];
2399
2403
  if (cmd && OFFLINE.includes(cmd)) return Promise.resolve();
2400
2404
  if (!process.stdin.isTTY) return Promise.resolve();
2401
2405
 
@@ -2417,7 +2421,11 @@ function askDebugMode(cmd) {
2417
2421
  // WA_NO_DONATE=1 all skip it in silence, so nothing about it can get in the way
2418
2422
  // of a script or a real command.
2419
2423
  function askDonation(cmd) {
2420
- const OFFLINE = ['version', '--version', '-v', 'help', '--help', '-h'];
2424
+ // Commands that never open a WhatsApp connection: there is no wire for a
2425
+ // trace to show, and stopping a maintenance command to ask is what makes
2426
+ // `wa apk-material --download && wa refresh-version --all` prompt twice.
2427
+ const OFFLINE = ['version', '--version', '-v', 'help', '--help', '-h',
2428
+ 'apk-material', 'refresh-version'];
2421
2429
  if (cmd && OFFLINE.includes(cmd)) return Promise.resolve();
2422
2430
  if (!process.stdin.isTTY) return Promise.resolve();
2423
2431
  if (process.env.WA_NO_DONATE === '1') return Promise.resolve();
@@ -2508,7 +2516,7 @@ async function main() {
2508
2516
  'that instead of what this command writes. Unset it for the refresh to take effect.');
2509
2517
  }
2510
2518
 
2511
- let changed = 0, failed = 0;
2519
+ let changed = 0, failed = 0, kept = 0;
2512
2520
  const sources = new Set();
2513
2521
  for (const file of files) {
2514
2522
  try {
@@ -2518,6 +2526,10 @@ async function main() {
2518
2526
  changed++;
2519
2527
  sources.add(r.source);
2520
2528
  out(who.padEnd(30) + r.before + ' → ' + r.after);
2529
+ } else if (r.keptNewer) {
2530
+ kept++;
2531
+ out(who.padEnd(30) + r.before + ' (kept — newer than the ' +
2532
+ r.candidate + ' available)');
2521
2533
  } else {
2522
2534
  out(who.padEnd(30) + r.after + ' (already current)');
2523
2535
  }
@@ -2528,7 +2540,9 @@ async function main() {
2528
2540
  }
2529
2541
 
2530
2542
  out('');
2531
- out(' ' + changed + ' session(s) updated' + (failed ? ', ' + failed + ' failed' : ''));
2543
+ out(' ' + changed + ' session(s) updated' +
2544
+ (kept ? ', ' + kept + ' left alone (already ahead)' : '') +
2545
+ (failed ? ', ' + failed + ' failed' : ''));
2532
2546
  if (changed) {
2533
2547
  out(' read from ' + [...sources].join(', ') + '.');
2534
2548
  out(' reconnect for it to be announced.');
@@ -648,11 +648,21 @@ async function refreshSessionVersion(sessionFile, opts) {
648
648
  const device = store.device || getDeviceConfig();
649
649
  const before = store.version;
650
650
 
651
- const resolved = opts.version
651
+ const explicit = opts.version != null;
652
+ const resolved = explicit
652
653
  ? { version: String(opts.version), source: 'the value you passed' }
653
654
  : await currentVersionFor(device);
654
655
 
655
- const changed = resolved.version !== before;
656
+ // Never go backwards on a lookup. The store the version is read from can be
657
+ // behind what a session already holds — Play serves the build that matches
658
+ // the device profile it was asked with, which is not always the newest one on
659
+ // the listing — and moving a session to an older version is the one outcome
660
+ // that makes a 405 more likely rather than less. A version named on the
661
+ // command line is a decision, so that still applies either way.
662
+ const olderThanStored = !explicit && !!before &&
663
+ compareVersions(resolved.version, before) < 0;
664
+
665
+ const changed = !olderThanStored && resolved.version !== before;
656
666
  if (changed) {
657
667
  store.version = resolved.version;
658
668
  saveStore(store, sessionFile);
@@ -661,8 +671,10 @@ async function refreshSessionVersion(sessionFile, opts) {
661
671
  return {
662
672
  phoneNumber: store.phoneNumber,
663
673
  before,
664
- after: resolved.version,
674
+ after: changed ? resolved.version : before,
675
+ candidate: resolved.version,
665
676
  changed,
677
+ keptNewer: olderThanStored,
666
678
  source: resolved.source,
667
679
  os: device.os,
668
680
  business: !!device.business
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whalibmob",
3
- "version": "5.13.1",
3
+ "version": "5.13.3",
4
4
  "description": "WhatsApp library for interaction with WhatsApp Mobile API and web ",
5
5
  "author": "Kunboruto20",
6
6
  "main": "index.js",