whalibmob 5.40.37 → 5.40.38

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/index.d.ts CHANGED
@@ -62,6 +62,8 @@ export interface DeviceConfig {
62
62
  osVersion?: string;
63
63
  build?: string;
64
64
  modelId?: string;
65
+ /** The Android SDK the handset shipped with, sent as `first_api_level`. */
66
+ firstApiLevel?: number | string;
65
67
  business?: boolean;
66
68
  [key: string]: any;
67
69
  }
@@ -61,6 +61,12 @@ function getDeviceConfig() {
61
61
  // A named profile carries the handset's own RAM; WA_DEVICE_RAM overrides
62
62
  // it for someone running the same model in a different memory variant.
63
63
  if (process.env.WA_DEVICE_RAM) picked.ram = process.env.WA_DEVICE_RAM;
64
+ // Likewise first_api_level: the profile pins the SDK the handset shipped
65
+ // with, and WA_DEVICE_FIRST_API_LEVEL overrides it for a regional variant
66
+ // that left the factory on a different one.
67
+ if (process.env.WA_DEVICE_FIRST_API_LEVEL) {
68
+ picked.firstApiLevel = process.env.WA_DEVICE_FIRST_API_LEVEL;
69
+ }
64
70
  return picked;
65
71
  }
66
72
 
@@ -80,6 +86,10 @@ function getDeviceConfig() {
80
86
  // What the handset reports as usable RAM, in GiB. Registration sends it,
81
87
  // and it has to belong to the handset beside it — see deviceRam().
82
88
  ram: process.env.WA_DEVICE_RAM || '11.55',
89
+ // The SDK the handset shipped with (ro.product.first_api_level), sent as
90
+ // first_api_level. Left to the profile default here; when unset,
91
+ // registration derives it from osVersion — see firstApiLevel().
92
+ firstApiLevel: process.env.WA_DEVICE_FIRST_API_LEVEL || undefined,
83
93
  deviceModelType: 2
84
94
  };
85
95
  }
@@ -1244,9 +1244,10 @@ function toUrlHex(buf) {
1244
1244
 
1245
1245
  // The native client inserts registration fields into a LinkedHashMap in a
1246
1246
  // fixed order; the wire sequence is that insertion order, not a sort. These are
1247
- // the live orders captured from WhatsApp Android reverse engerring: 50 fields
1247
+ // the live orders captured from WhatsApp Android reverse engerring: 51 fields
1248
1248
  // for /v2/code, 49 for /v2/register. gpia/token/vname that this build omits
1249
- // simply drop out — their slots collapse.
1249
+ // simply drop out — their slots collapse. first_api_level rides between
1250
+ // e_skey_id and feo2_query_status, the slot the native client gives it.
1250
1251
  const CODE_PARAM_ORDER = [
1251
1252
  'method', 'backup_token', '_gs', 'sim_mnc', 'id', 'mnc', '_gg',
1252
1253
  'network_radio_type', 'lg', 'rc', 'pid', '_ge', 'cellular_strength', 'gpia',
@@ -1255,7 +1256,8 @@ const CODE_PARAM_ORDER = [
1255
1256
  'mistyped', 'airplane_mode_type', 'e_ident', 'e_skey_sig', 'entrypoint',
1256
1257
  'token', 'in', 'expid', 'simnum', 'cc', 'education_screen_displayed',
1257
1258
  'e_skey_val', 'authkey', 'e_keytype', 'e_regid', 'client_metrics', '_gi',
1258
- 'e_skey_id', 'feo2_query_status', 'reason', 'fdid', 'recaptcha', '_ga', 'lc'
1259
+ 'e_skey_id', 'first_api_level', 'feo2_query_status', 'reason', 'fdid',
1260
+ 'recaptcha', '_ga', 'lc'
1259
1261
  ];
1260
1262
 
1261
1263
  const REGISTER_PARAM_ORDER = [
@@ -1388,6 +1390,39 @@ function deviceRam(device) {
1388
1390
  return Number.isFinite(n) && n > 0 ? n.toFixed(2) : DEFAULT_DEVICE_RAM;
1389
1391
  }
1390
1392
 
1393
+ // ---------- first_api_level ----------
1394
+ //
1395
+ // ro.product.first_api_level: the Android SDK the handset shipped with, which
1396
+ // registration sends as first_api_level. It is a property of the model, not of
1397
+ // the installed OS — a phone that launched on Android 13 and was updated to 14
1398
+ // still reports 33 — so it is taken from the declared profile's firstApiLevel.
1399
+ //
1400
+ // When the profile does not pin one (a custom WA_DEVICE_* build), it is derived
1401
+ // from osVersion: a phone is assumed to have shipped on the OS it now runs,
1402
+ // which is true for anything bought on its launch version. The last resort is
1403
+ // 34 (Android 14), the floor the default profiles sit on.
1404
+ const ANDROID_VERSION_TO_API = {
1405
+ '10': 29, '11': 30, '12': 31, '13': 33, '14': 34, '15': 35, '16': 36
1406
+ };
1407
+ const DEFAULT_FIRST_API_LEVEL = 34;
1408
+
1409
+ function firstApiLevel(device) {
1410
+ const pinned = device && device.firstApiLevel;
1411
+ if (pinned != null && String(pinned).trim() !== '') {
1412
+ const n = parseInt(pinned, 10);
1413
+ if (Number.isFinite(n) && n > 0) return String(n);
1414
+ }
1415
+ const osVersion = device && device.osVersion;
1416
+ if (osVersion != null) {
1417
+ // Match on the major version so '14', '14.1' and '13.0' all resolve.
1418
+ const major = String(osVersion).trim().split('.')[0];
1419
+ if (ANDROID_VERSION_TO_API[major] != null) {
1420
+ return String(ANDROID_VERSION_TO_API[major]);
1421
+ }
1422
+ }
1423
+ return String(DEFAULT_FIRST_API_LEVEL);
1424
+ }
1425
+
1391
1426
  // ---------- pid ----------
1392
1427
  //
1393
1428
  // The process id of the app making the request.
@@ -1533,6 +1568,7 @@ function getRequestVerificationCodeParameters(store, method, meta, device, attem
1533
1568
  'hasinrc', '1',
1534
1569
  'roaming_type', '0',
1535
1570
  'device_ram', deviceRam(device),
1571
+ 'first_api_level', firstApiLevel(device),
1536
1572
  'education_screen_displayed', 'false',
1537
1573
  'pid', getAppPid(store),
1538
1574
  'cellular_strength', '5',
package/lib/constants.js CHANGED
@@ -164,96 +164,101 @@ const IOS_DEVICE_PROFILES = {
164
164
 
165
165
  // ─── Android device profiles ───────────────────────────────────────────────
166
166
  // Set WA_OS=android WA_DEVICE=<key> in .env to select one.
167
+ // firstApiLevel is the Android API level the handset *shipped* with
168
+ // (ro.product.first_api_level), which registration sends as first_api_level. It
169
+ // is not the current OS: a phone launched on Android 13 (API 33) and updated to
170
+ // 14 still reports 33, so the value is pinned per model to the SDK it left the
171
+ // factory on, not derived from osVersion.
167
172
  const ANDROID_DEVICE_PROFILES = {
168
173
  'samsung-s24-ultra': {
169
174
  os: 'android', platform: PLATFORM.ANDROID,
170
175
  model: 'Samsung Galaxy S24 Ultra', manufacturer: 'Samsung',
171
176
  osVersion: '14', osBuildNumber: 'UP1A.231005.007',
172
- modelId: 'SM-S928B', deviceModelType: 2, ram: '11.55'
177
+ modelId: 'SM-S928B', deviceModelType: 2, ram: '11.55', firstApiLevel: 34
173
178
  },
174
179
  'samsung-s24': {
175
180
  os: 'android', platform: PLATFORM.ANDROID,
176
181
  model: 'Samsung Galaxy S24', manufacturer: 'Samsung',
177
182
  osVersion: '14', osBuildNumber: 'UP1A.231005.007',
178
- modelId: 'SM-S921B', deviceModelType: 2, ram: '7.63'
183
+ modelId: 'SM-S921B', deviceModelType: 2, ram: '7.63', firstApiLevel: 34
179
184
  },
180
185
  'samsung-s23': {
181
186
  os: 'android', platform: PLATFORM.ANDROID,
182
187
  model: 'Samsung Galaxy S23', manufacturer: 'Samsung',
183
188
  osVersion: '14', osBuildNumber: 'UP1A.231005.007',
184
- modelId: 'SM-S911B', deviceModelType: 2, ram: '7.63'
189
+ modelId: 'SM-S911B', deviceModelType: 2, ram: '7.63', firstApiLevel: 33
185
190
  },
186
191
  'samsung-s23-ultra': {
187
192
  os: 'android', platform: PLATFORM.ANDROID,
188
193
  model: 'Samsung Galaxy S23 Ultra', manufacturer: 'Samsung',
189
194
  osVersion: '14', osBuildNumber: 'UP1A.231005.007',
190
- modelId: 'SM-S918B', deviceModelType: 2, ram: '11.55'
195
+ modelId: 'SM-S918B', deviceModelType: 2, ram: '11.55', firstApiLevel: 33
191
196
  },
192
197
  'samsung-a55': {
193
198
  os: 'android', platform: PLATFORM.ANDROID,
194
199
  model: 'Samsung Galaxy A55', manufacturer: 'Samsung',
195
200
  osVersion: '14', osBuildNumber: 'UP1A.231005.007',
196
- modelId: 'SM-A556B', deviceModelType: 1, ram: '7.44'
201
+ modelId: 'SM-A556B', deviceModelType: 1, ram: '7.44', firstApiLevel: 34
197
202
  },
198
203
  'pixel8pro': {
199
204
  os: 'android', platform: PLATFORM.ANDROID,
200
205
  model: 'Pixel 8 Pro', manufacturer: 'Google',
201
206
  osVersion: '14', osBuildNumber: 'UP1A.231005.007',
202
- modelId: 'Pixel 8 Pro', deviceModelType: 2, ram: '11.44'
207
+ modelId: 'Pixel 8 Pro', deviceModelType: 2, ram: '11.44', firstApiLevel: 34
203
208
  },
204
209
  'pixel8': {
205
210
  os: 'android', platform: PLATFORM.ANDROID,
206
211
  model: 'Pixel 8', manufacturer: 'Google',
207
212
  osVersion: '14', osBuildNumber: 'UP1A.231005.007',
208
- modelId: 'Pixel 8', deviceModelType: 2, ram: '7.53'
213
+ modelId: 'Pixel 8', deviceModelType: 2, ram: '7.53', firstApiLevel: 34
209
214
  },
210
215
  'pixel7': {
211
216
  os: 'android', platform: PLATFORM.ANDROID,
212
217
  model: 'Pixel 7', manufacturer: 'Google',
213
218
  osVersion: '14', osBuildNumber: 'TP1A.221005.002',
214
- modelId: 'Pixel 7', deviceModelType: 2, ram: '7.53'
219
+ modelId: 'Pixel 7', deviceModelType: 2, ram: '7.53', firstApiLevel: 33
215
220
  },
216
221
  'pixel7a': {
217
222
  os: 'android', platform: PLATFORM.ANDROID,
218
223
  model: 'Pixel 7a', manufacturer: 'Google',
219
224
  osVersion: '14', osBuildNumber: 'UP1A.231005.007',
220
- modelId: 'Pixel 7a', deviceModelType: 1, ram: '7.44'
225
+ modelId: 'Pixel 7a', deviceModelType: 1, ram: '7.44', firstApiLevel: 33
221
226
  },
222
227
  'xiaomi14': {
223
228
  os: 'android', platform: PLATFORM.ANDROID,
224
229
  model: 'Xiaomi 14', manufacturer: 'Xiaomi',
225
230
  osVersion: '14', osBuildNumber: 'UP1A.231005.007',
226
- modelId: '23127PN0CG', deviceModelType: 2, ram: '11.36'
231
+ modelId: '23127PN0CG', deviceModelType: 2, ram: '11.36', firstApiLevel: 34
227
232
  },
228
233
  'xiaomi13': {
229
234
  os: 'android', platform: PLATFORM.ANDROID,
230
235
  model: 'Xiaomi 13', manufacturer: 'Xiaomi',
231
236
  osVersion: '13', osBuildNumber: 'TQ3A.230901.001',
232
- modelId: '2211133G', deviceModelType: 2, ram: '7.51'
237
+ modelId: '2211133G', deviceModelType: 2, ram: '7.51', firstApiLevel: 33
233
238
  },
234
239
  'oneplus12': {
235
240
  os: 'android', platform: PLATFORM.ANDROID,
236
241
  model: 'OnePlus 12', manufacturer: 'OnePlus',
237
242
  osVersion: '14', osBuildNumber: 'UP1A.231005.007',
238
- modelId: 'CPH2573', deviceModelType: 2, ram: '11.48'
243
+ modelId: 'CPH2573', deviceModelType: 2, ram: '11.48', firstApiLevel: 34
239
244
  },
240
245
  'oneplus11': {
241
246
  os: 'android', platform: PLATFORM.ANDROID,
242
247
  model: 'OnePlus 11', manufacturer: 'OnePlus',
243
248
  osVersion: '13', osBuildNumber: 'TQ3A.230901.001',
244
- modelId: 'CPH2449', deviceModelType: 2, ram: '15.32'
249
+ modelId: 'CPH2449', deviceModelType: 2, ram: '15.32', firstApiLevel: 33
245
250
  },
246
251
  'oppo-find-x7': {
247
252
  os: 'android', platform: PLATFORM.ANDROID,
248
253
  model: 'OPPO Find X7', manufacturer: 'OPPO',
249
254
  osVersion: '14', osBuildNumber: 'UP1A.231005.007',
250
- modelId: 'CPH2599', deviceModelType: 2, ram: '11.40'
255
+ modelId: 'CPH2599', deviceModelType: 2, ram: '11.40', firstApiLevel: 34
251
256
  },
252
257
  'realme-gt5': {
253
258
  os: 'android', platform: PLATFORM.ANDROID,
254
259
  model: 'realme GT 5 Pro', manufacturer: 'realme',
255
260
  osVersion: '14', osBuildNumber: 'UP1A.231005.007',
256
- modelId: 'RMX3888', deviceModelType: 2, ram: '15.28'
261
+ modelId: 'RMX3888', deviceModelType: 2, ram: '15.28', firstApiLevel: 34
257
262
  }
258
263
  };
259
264
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whalibmob",
3
- "version": "5.40.37",
3
+ "version": "5.40.38",
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",