scripter-x 1.0.9 → 1.0.11
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 +45 -34
- package/src/providers/tempotp.js +4 -1
package/package.json
CHANGED
package/src/commands.js
CHANGED
|
@@ -96,7 +96,11 @@ async function buildProvider(io, name) {
|
|
|
96
96
|
io.print(` ✓ TempOTP balance: ₹${bal}`);
|
|
97
97
|
if (freshlyEntered && await io.confirm('save this key locally for next time?', true)) config.setMany({ tempotp_api_key: key });
|
|
98
98
|
|
|
99
|
-
const svc = await io.select('service id', Object.keys(tp.SERVICES).map((id) => ({
|
|
99
|
+
const svc = await io.select('service id', Object.keys(tp.SERVICES).map((id) => ({
|
|
100
|
+
label: tp.SERVICE_NAMES?.[id] ? `${id} · ${tp.SERVICE_NAMES[id]}` : id,
|
|
101
|
+
value: id,
|
|
102
|
+
description: `₹${tp.SERVICES[id]}`,
|
|
103
|
+
})));
|
|
100
104
|
return new tp.TempOTPProvider(key, svc.value || svc);
|
|
101
105
|
}
|
|
102
106
|
|
|
@@ -239,40 +243,47 @@ export async function zeptoCmd(io, _api, args = {}) {
|
|
|
239
243
|
const number = String(raw).replace(/\D/g, '').slice(-10);
|
|
240
244
|
if (number.length !== 10) { io.print(' ! enter a 10-digit number', 'danger'); if (args.number) break; continue; }
|
|
241
245
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
246
|
+
try {
|
|
247
|
+
const session = zepto.newSession(number);
|
|
248
|
+
io.print(` ◉ sending OTP to ${number} …`);
|
|
249
|
+
const s = await zepto.sendOtp(session);
|
|
250
|
+
if (!s.ok) { io.print(` ✗ could not send OTP: ${s.msg || s.status}`, 'danger'); if (args.number) break; continue; }
|
|
251
|
+
io.print(' ✓ OTP sent');
|
|
252
|
+
|
|
253
|
+
// OTP entry — escapable too (Esc abandons this number and loops back)
|
|
254
|
+
const otpRaw = args.otp || await io.ask('enter the OTP', { escapable: true });
|
|
255
|
+
if (otpRaw === CANCEL) break;
|
|
256
|
+
const v = await zepto.verifyOtp(session, String(otpRaw).trim());
|
|
257
|
+
if (!v.ok) { io.print(` ✗ OTP verify failed: ${v.error || v.status}`, 'danger'); if (args.number) break; continue; }
|
|
258
|
+
io.print(` ✓ logged in${v.user?.fullName ? ` as ${v.user.fullName}` : ''}`);
|
|
259
|
+
|
|
260
|
+
// Build the ZAUTH1 envelope — the format the ZeptoAuthManager tool imports.
|
|
261
|
+
const envelope = zepto.encodeEnvelope(zepto.toSessionKeys(session), args.cert);
|
|
262
|
+
|
|
263
|
+
// {phone}-{timestamp}.txt in the chosen dir (default ~/Downloads/scripterx/zepto)
|
|
264
|
+
const stamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
265
|
+
const fname = `${number}-${stamp}.txt`;
|
|
266
|
+
let dest;
|
|
267
|
+
if (args.out) {
|
|
268
|
+
const expanded = args.out.startsWith('~') ? join(homedir(), args.out.slice(1)) : args.out;
|
|
269
|
+
dest = /\.(txt|json)$/i.test(expanded) ? expanded : join(expanded, fname);
|
|
270
|
+
} else {
|
|
271
|
+
const downloads = join(homedir(), 'Downloads');
|
|
272
|
+
dest = join(existsSync(downloads) ? downloads : homedir(), 'scripterx', 'zepto', fname);
|
|
273
|
+
}
|
|
274
|
+
mkdirSync(dirname(dest), { recursive: true });
|
|
275
|
+
writeFileSync(dest, envelope + '\n');
|
|
276
|
+
done++;
|
|
277
|
+
io.print(' ✓ envelope saved to:');
|
|
278
|
+
io.print(` ${dest}`, 'accent');
|
|
279
|
+
io.print(' ◉ paste into ZeptoAuthManager → Import:');
|
|
280
|
+
io.print(` ${envelope}`, 'accent');
|
|
281
|
+
} catch (e) {
|
|
282
|
+
// never let one bad number kill the loop — surface the real reason and keep going
|
|
283
|
+
io.print(` ✗ ${number}: ${e.message}`, 'danger');
|
|
284
|
+
if (args.number) break;
|
|
285
|
+
continue;
|
|
268
286
|
}
|
|
269
|
-
mkdirSync(dirname(dest), { recursive: true });
|
|
270
|
-
writeFileSync(dest, envelope + '\n');
|
|
271
|
-
done++;
|
|
272
|
-
io.print(' ✓ envelope saved to:');
|
|
273
|
-
io.print(` ${dest}`, 'accent');
|
|
274
|
-
io.print(' ◉ paste into ZeptoAuthManager → Import:');
|
|
275
|
-
io.print(` ${envelope}`, 'accent');
|
|
276
287
|
|
|
277
288
|
// one-shot (a number was passed on the CLI): do exactly one and stop
|
|
278
289
|
if (args.number) break;
|
package/src/providers/tempotp.js
CHANGED
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
import { extractOtp } from '../flipkart.js';
|
|
3
3
|
|
|
4
4
|
const BASE = 'https://api.tempotp.online';
|
|
5
|
-
|
|
5
|
+
// serviceId -> cost (₹). Keep ids as strings (they go straight into the GET params).
|
|
6
|
+
export const SERVICES = { '1040': 10.0, '940': 16.0, '2451': 12.5 };
|
|
7
|
+
// optional friendly names shown in the service picker
|
|
8
|
+
export const SERVICE_NAMES = { '1040': 'Flipkart', '940': 'Flipkart', '2451': 'Shopsy/Flipkart 1 (SERVER 16)' };
|
|
6
9
|
export const DEFAULT_SERVICE = '940';
|
|
7
10
|
const COUNTRY = '22';
|
|
8
11
|
|