scripter-x 1.0.21 → 1.0.22
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/package.json +1 -1
- package/src/commands.js +28 -11
package/package.json
CHANGED
package/src/commands.js
CHANGED
|
@@ -438,8 +438,9 @@ export async function zeptoCmd(io, api, args = {}) {
|
|
|
438
438
|
if (worker.stats.succeeded > 0) {
|
|
439
439
|
const saved = await saveZeptoSessions(results, name, args.out);
|
|
440
440
|
if (saved) {
|
|
441
|
-
io.print(` ✓ saved ${saved.count} session(s) to:`);
|
|
442
|
-
io.print(` ${saved.
|
|
441
|
+
io.print(` ✓ saved ${saved.count} session(s) to 2 files:`);
|
|
442
|
+
io.print(` full → ${saved.fullPath}`, 'accent');
|
|
443
|
+
io.print(` zauth → ${saved.zauthPath}`, 'accent');
|
|
443
444
|
io.print(' ◉ ZAUTH1 envelopes:');
|
|
444
445
|
for (const r of results) {
|
|
445
446
|
if (r.status === 'success') {
|
|
@@ -457,30 +458,46 @@ async function saveZeptoSessions(results, name, out) {
|
|
|
457
458
|
const ok = results.filter((r) => r.status === 'success');
|
|
458
459
|
if (!ok.length) return null;
|
|
459
460
|
|
|
460
|
-
const
|
|
461
|
-
const
|
|
462
|
-
|
|
461
|
+
const count = ok.length; // number of sessions extracted
|
|
462
|
+
const ts = Math.floor(Date.now() / 1000);
|
|
463
|
+
const fullName = `zepto-${count}-fullsession-${ts}.json`;
|
|
464
|
+
const zauthName = `zepto-${count}-zauth-${ts}.json`;
|
|
465
|
+
|
|
466
|
+
// Resolve the output directory. `out` may be a directory or an explicit file path;
|
|
467
|
+
// when it's a file path we still write BOTH files alongside it (using its directory)
|
|
468
|
+
// so each file gets its own correct name.
|
|
469
|
+
let dir;
|
|
463
470
|
if (out) {
|
|
464
471
|
const expanded = out.startsWith('~') ? join(homedir(), out.slice(1)) : out;
|
|
465
472
|
const isDir = (existsSync(expanded) && statSync(expanded).isDirectory()) || /[/\\]$/.test(out);
|
|
466
|
-
|
|
473
|
+
dir = isDir ? expanded : dirname(expanded);
|
|
467
474
|
} else {
|
|
468
475
|
const downloads = join(homedir(), 'Downloads');
|
|
469
476
|
const base = existsSync(downloads) ? downloads : homedir();
|
|
470
|
-
|
|
477
|
+
dir = join(base, 'scripterx');
|
|
471
478
|
}
|
|
479
|
+
mkdirSync(dir, { recursive: true });
|
|
472
480
|
|
|
473
|
-
|
|
481
|
+
// 1. Full session details — everything we have per extracted account.
|
|
482
|
+
const fullPath = join(dir, fullName);
|
|
483
|
+
const fullPayload = ok.map((r) => ({
|
|
474
484
|
mobileNo: r.mobile,
|
|
475
485
|
zauth1_envelope: r.envelope,
|
|
476
486
|
session: r.session,
|
|
477
487
|
}));
|
|
488
|
+
writeFileSync(fullPath, JSON.stringify(fullPayload, null, 2));
|
|
489
|
+
|
|
490
|
+
// 2. ZAUTH1-only — just the envelope strings, nothing else.
|
|
491
|
+
const zauthPath = join(dir, zauthName);
|
|
492
|
+
const zauthPayload = ok.map((r) => r.envelope);
|
|
493
|
+
writeFileSync(zauthPath, JSON.stringify(zauthPayload, null, 2));
|
|
478
494
|
|
|
479
|
-
|
|
480
|
-
writeFileSync(dest, JSON.stringify(payload, null, 2));
|
|
481
|
-
return { path: dest, count: payload.length };
|
|
495
|
+
return { fullPath, zauthPath, count };
|
|
482
496
|
}
|
|
483
497
|
|
|
498
|
+
// Exposed for tests only.
|
|
499
|
+
export const __saveZeptoSessionsForTest = saveZeptoSessions;
|
|
500
|
+
|
|
484
501
|
export async function campaigns(io, api) {
|
|
485
502
|
api = api || await getApi(io);
|
|
486
503
|
const camps = await api.listCampaigns();
|