camstack 0.5.0 → 0.5.2

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/dist/cli.js +29 -16
  2. 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 password2 = opts.password ?? await askPassword("Password");
500
- const authSpinner = clack.spinner();
501
- authSpinner.start(`Authenticating as ${username}`);
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
- try {
505
- const login = await callTrpcMutation(
506
- `${server}/trpc/auth.login?batch=1`,
507
- void 0,
508
- { username, password: password2 },
509
- isLoginPayload
510
- );
511
- jwt = login.token;
512
- displayName = login.user.username;
513
- authSpinner.stop(`Authenticated as ${displayName}`);
514
- } catch (err) {
515
- authSpinner.stop(`Auth failed: ${err instanceof Error ? err.message : String(err)}`);
516
- throw err;
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) {
@@ -962,6 +972,9 @@ function optionalString(values, key, outKey) {
962
972
  return { [outKey ?? key]: v };
963
973
  }
964
974
  async function main() {
975
+ if (!process.env.CAMSTACK_STRICT_TLS) {
976
+ process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
977
+ }
965
978
  maybeNotifyUpdate("camstack", pkgVersion);
966
979
  const argv = process.argv.slice(2);
967
980
  const commands = buildCommands();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "camstack",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "CLI tool for managing and running CamStack server",
5
5
  "keywords": [
6
6
  "camstack",