whalibmob 5.5.26 → 5.5.27

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.
Files changed (2) hide show
  1. package/cli.js +29 -12
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -196,9 +196,10 @@ const HELP = `
196
196
  /biz <phone|jid> query business profile
197
197
 
198
198
  Registration
199
- /reg check <phone> check if number has WhatsApp
200
- /reg code <phone> [sms|voice|wa_old] request verification code
201
- /reg confirm <phone> <code> complete registration
199
+ /reg check <phone> check if number has WhatsApp
200
+ /reg code <phone> [sms|voice|wa_old] request verification code
201
+ /reg code <phone> email <address> request code via email
202
+ /reg confirm <phone> <code> complete registration
202
203
 
203
204
  Connection
204
205
  /connect <phone> connect to WhatsApp
@@ -1153,8 +1154,14 @@ async function handleLine(line) {
1153
1154
  }
1154
1155
  else if (sub === 'code') {
1155
1156
  const ph = normalizePhone(p[2]);
1156
- const method = p[3] || 'sms';
1157
- if (!ph) { fail('usage: /reg code <phone> [sms|voice|wa_old]'); break; }
1157
+ const method = (p[3] || 'sms').toLowerCase();
1158
+ // email method: /reg code <phone> email <address>
1159
+ const emailAddr = method === 'email' ? (p[4] || '') : '';
1160
+ if (!ph) { fail('usage: /reg code <phone> [sms|voice|wa_old|email <address>]'); break; }
1161
+ if (method === 'email' && !emailAddr) {
1162
+ fail('email method requires an address — usage: /reg code <phone> email <address>');
1163
+ break;
1164
+ }
1158
1165
  if (!fs.existsSync(_sessDir)) fs.mkdirSync(_sessDir, { recursive: true });
1159
1166
  const sessFile = path.join(_sessDir, `${ph}.json`);
1160
1167
  let store = loadStore(sessFile);
@@ -1173,8 +1180,10 @@ async function handleLine(line) {
1173
1180
  out(' new keys saved — proceed with code below');
1174
1181
  }
1175
1182
  }
1176
- out('requesting ' + method + ' code for +' + ph + '...');
1177
- const r = await requestSmsCode(store, method);
1183
+ const methodLabel = method === 'email' ? ('email ' + emailAddr) : method;
1184
+ out('requesting ' + methodLabel + ' code for +' + ph + '...');
1185
+ const codeOpts = method === 'email' ? { email: emailAddr } : {};
1186
+ const r = await requestSmsCode(store, method, codeOpts);
1178
1187
  store.codePending = true;
1179
1188
  saveStore(store, sessFile);
1180
1189
  out(' status ' + (r && r.status));
@@ -1427,7 +1436,8 @@ usage:
1427
1436
 
1428
1437
  options:
1429
1438
  --session <dir> session directory (default: ~/.waSession)
1430
- --method sms | voice | wa_old (default: sms)
1439
+ --method sms | voice | wa_old | email (default: sms)
1440
+ --email <address> email address (required when --method email)
1431
1441
 
1432
1442
  after connecting, type /help for all available commands.
1433
1443
  `.trim();
@@ -1475,9 +1485,14 @@ async function main() {
1475
1485
  }
1476
1486
 
1477
1487
  if (flags['request-code'] !== undefined) {
1478
- const ph = phone || normalizePhone(pos[0] || '');
1479
- const method = flags.method || 'sms';
1488
+ const ph = phone || normalizePhone(pos[0] || '');
1489
+ const method = (flags.method || 'sms').toLowerCase();
1490
+ const emailAddr = flags.email || '';
1480
1491
  if (!ph) { fail('phone number required'); process.exit(1); }
1492
+ if (method === 'email' && !emailAddr) {
1493
+ fail('--method email requires --email <address>');
1494
+ process.exit(1);
1495
+ }
1481
1496
  if (!fs.existsSync(_sessDir)) fs.mkdirSync(_sessDir, { recursive: true });
1482
1497
  const sessFile = path.join(_sessDir, `${ph}.json`);
1483
1498
  let store = loadStore(sessFile);
@@ -1500,9 +1515,11 @@ async function main() {
1500
1515
  }
1501
1516
  // If store.codePending === true, keys were already accepted by WhatsApp in a
1502
1517
  // prior /code request — reuse the exact same store without any /exist call.
1503
- out('requesting ' + method + ' code for +' + ph + '...');
1518
+ const methodLabel = method === 'email' ? ('email ' + emailAddr) : method;
1519
+ out('requesting ' + methodLabel + ' code for +' + ph + '...');
1504
1520
  try {
1505
- const r = await requestSmsCode(store, method);
1521
+ const codeOpts = method === 'email' ? { email: emailAddr } : {};
1522
+ const r = await requestSmsCode(store, method, codeOpts);
1506
1523
  store.codePending = true;
1507
1524
  saveStore(store, sessFile);
1508
1525
  out(' status ' + (r && r.status));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whalibmob",
3
- "version": "5.5.26",
3
+ "version": "5.5.27",
4
4
  "description": "WhatsApp library for interaction with WhatsApp Mobile API no web",
5
5
  "author": "Kunboruto20",
6
6
  "main": "index.js",