whalibmob 5.5.67 → 5.5.68

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/cli.js CHANGED
@@ -90,7 +90,19 @@ function enableWireTrace() {
90
90
  // reformat its lines on the way out. Anything that is not a pino record is
91
91
  // passed through byte-for-byte.
92
92
  const stamp = () => new Date().toISOString().slice(11, 23);
93
- const trace = (s) => _origStderrWrite(s + '\n');
93
+ // Traffic arrives while readline owns the bottom line, so writing straight
94
+ // out overwrites the prompt and leaves the two interleaved. Clear the line
95
+ // first and redraw the prompt after, the same way the CLI's own event
96
+ // handlers do.
97
+ const trace = (s) => {
98
+ const live = _rl && process.stdout.isTTY;
99
+ if (live) {
100
+ readline.cursorTo(process.stdout, 0);
101
+ readline.clearLine(process.stdout, 0);
102
+ }
103
+ _origStderrWrite(s + '\n');
104
+ if (live) _rl.prompt(true);
105
+ };
94
106
 
95
107
  // Route the library's internal [DBG] stream through pino at full verbosity.
96
108
  // pino writes newline-delimited JSON straight to fd 1 via sonic-boom, which
@@ -424,7 +424,7 @@ function getRequestVerificationCodeParameters(store, method, meta, device, attem
424
424
  'manage_call_permission', 'false',
425
425
  'clicked_education_link', 'false',
426
426
  'aid', '',
427
- 'push_code', ''
427
+ 'push_code', store.pushCode || ''
428
428
  ];
429
429
  }
430
430
 
@@ -434,7 +434,7 @@ function getRequestVerificationCodeParameters(store, method, meta, device, attem
434
434
  'sim_mcc', meta.mcc,
435
435
  'sim_mnc', meta.mnc,
436
436
  'jailbroken', '0',
437
- 'push_code', '',
437
+ 'push_code', store.pushCode || '',
438
438
  'cellular_strength', '1'
439
439
  ];
440
440
  }
package/lib/Store.js CHANGED
@@ -64,6 +64,11 @@ function createNewStore(phoneNumber) {
64
64
  // Registration.js): advertising id (UUID) and the 20-byte backup token.
65
65
  const advertisingId = uuidv4();
66
66
  const backupToken = crypto.randomBytes(20);
67
+ // Push-notification token sent as `push_code` on /code. The server validates
68
+ // its shape and rejects an empty value with bad_param/bad_format, so it has
69
+ // to be a real 32-hex-character token. Generated once and persisted, because
70
+ // the value must stay the same across the /code and /register pair.
71
+ const pushCode = crypto.randomBytes(16).toString('hex');
67
72
 
68
73
  const device = getDeviceConfig();
69
74
  const version = device.os === 'android' ? ANDROID_VERSION_FALLBACK : IOS_VERSION_FALLBACK;
@@ -86,6 +91,7 @@ function createNewStore(phoneNumber) {
86
91
  identityId,
87
92
  advertisingId,
88
93
  backupToken,
94
+ pushCode,
89
95
  registered: false,
90
96
  codePending: false, // true after /code request, cleared on successful /register
91
97
  name: 'User',
@@ -140,6 +146,7 @@ function storeToJson(store) {
140
146
  identityId: store.identityId.toString('base64'),
141
147
  advertisingId: store.advertisingId || null,
142
148
  backupToken: store.backupToken ? store.backupToken.toString('base64') : null,
149
+ pushCode: store.pushCode || null,
143
150
  registered: !!store.registered,
144
151
  codePending: store.codePending || false,
145
152
  name,
@@ -182,6 +189,7 @@ function storeFromJson(obj) {
182
189
  // enriched /code request always has stable values.
183
190
  advertisingId: obj.advertisingId || uuidv4(),
184
191
  backupToken: obj.backupToken ? Buffer.from(obj.backupToken, 'base64') : crypto.randomBytes(20),
192
+ pushCode: obj.pushCode || crypto.randomBytes(16).toString('hex'),
185
193
  registered: !!obj.registered,
186
194
  codePending: obj.codePending || false,
187
195
  name,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whalibmob",
3
- "version": "5.5.67",
3
+ "version": "5.5.68",
4
4
  "description": "WhatsApp library for interaction with WhatsApp Mobile API no web",
5
5
  "author": "Kunboruto50",
6
6
  "main": "index.js",