camstack 0.5.0 → 0.5.1
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/dist/cli.js +26 -16
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -496,24 +496,34 @@ async function loginCommand(opts) {
|
|
|
496
496
|
clack.log.info(`Server: ${server}`);
|
|
497
497
|
}
|
|
498
498
|
const username = opts.username ?? await askText("Username", "admin");
|
|
499
|
-
const
|
|
500
|
-
|
|
501
|
-
|
|
499
|
+
const MAX_ATTEMPTS = 3;
|
|
500
|
+
let password2 = opts.password ?? await askPassword("Password");
|
|
501
|
+
let attempt = 1;
|
|
502
502
|
let jwt;
|
|
503
503
|
let displayName;
|
|
504
|
-
|
|
505
|
-
const
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
504
|
+
while (true) {
|
|
505
|
+
const authSpinner = clack.spinner();
|
|
506
|
+
authSpinner.start(`Authenticating as ${username}${attempt > 1 ? ` (attempt ${attempt}/${MAX_ATTEMPTS})` : ""}`);
|
|
507
|
+
try {
|
|
508
|
+
const login = await callTrpcMutation(
|
|
509
|
+
`${server}/trpc/auth.login?batch=1`,
|
|
510
|
+
void 0,
|
|
511
|
+
{ username, password: password2 },
|
|
512
|
+
isLoginPayload
|
|
513
|
+
);
|
|
514
|
+
jwt = login.token;
|
|
515
|
+
displayName = login.user.username;
|
|
516
|
+
authSpinner.stop(`Authenticated as ${displayName}`);
|
|
517
|
+
break;
|
|
518
|
+
} catch (err) {
|
|
519
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
520
|
+
authSpinner.stop(`Auth failed: ${msg}`);
|
|
521
|
+
if (opts.password !== void 0 || attempt >= MAX_ATTEMPTS) {
|
|
522
|
+
throw err;
|
|
523
|
+
}
|
|
524
|
+
attempt++;
|
|
525
|
+
password2 = await askPassword("Password (retry)");
|
|
526
|
+
}
|
|
517
527
|
}
|
|
518
528
|
const prior = loadSession(server);
|
|
519
529
|
if (prior && prior.tokenId) {
|