@hsafa/cli 1.0.2 → 1.0.3

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.
@@ -22,8 +22,10 @@ export function registerAuthCommands(program) {
22
22
  });
23
23
  async function loginBrowser() {
24
24
  const serverUrl = config.get('serverUrl');
25
+ // Determine the client URL for authentication (NextAuth runs on the client)
26
+ const clientUrl = serverUrl.replace('server.hsafa.com', 'hsafa.com');
25
27
  console.log(chalk.cyan('Authentication requested.'));
26
- console.log(`We will open your browser to log you in to: ${serverUrl}`);
28
+ console.log(`We will open your browser to log you in to: ${clientUrl}`);
27
29
  const { confirm } = await inquirer.prompt([
28
30
  {
29
31
  type: 'confirm',
@@ -73,14 +75,13 @@ export function registerAuthCommands(program) {
73
75
  const port = address.port;
74
76
  const callbackUrl = `http://localhost:${port}`;
75
77
  // Open the browser
76
- // Point to the server-side CLI login page which will redirect back to us with the token
77
- // We assume the server has a route /cli-login that handles the auth check and redirects back to callbackUrl
78
- // The server page logic:
78
+ // Point to the client-side CLI login page (where NextAuth is configured)
79
+ // The client page logic:
79
80
  // 1. Check if user is logged in (session).
80
- // 2. If not, redirect to /auth/signin?callbackUrl=/cli-login?callback=callbackUrl
81
+ // 2. If not, redirect to /api/auth/signin?callbackUrl=/cli-login?callback=callbackUrl
81
82
  // 3. If logged in, get session token.
82
83
  // 4. Redirect to callbackUrl?token=sessionToken
83
- const loginUrl = `${serverUrl}/cli-login?callback=${encodeURIComponent(callbackUrl)}`;
84
+ const loginUrl = `${clientUrl}/cli-login?callback=${encodeURIComponent(callbackUrl)}`;
84
85
  try {
85
86
  await open(loginUrl);
86
87
  }
package/dist/index.js CHANGED
@@ -21,7 +21,7 @@ const program = new Command();
21
21
  program
22
22
  .name('hsafa')
23
23
  .description('CLI to control HSAFA without UI')
24
- .version('1.0.2')
24
+ .version('1.0.3')
25
25
  .option('--json', 'Output results in JSON format');
26
26
  program
27
27
  .command('config')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hsafa/cli",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "CLI to control HSAFA without UI",
5
5
  "main": "dist/index.js",
6
6
  "exports": {