@mitsein-ai/cli 0.2.0 → 0.2.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/index.js +68 -68
- package/package.json +1 -1
- package/src/commands/auth-browser.ts +7 -2
- package/src/commands/auth.ts +2 -2
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@ function firstQuery(q: ParsedUrlQuery, key: string): string | undefined {
|
|
|
15
15
|
|
|
16
16
|
export async function loginBrowserFlow(
|
|
17
17
|
endpoint: string,
|
|
18
|
-
provider: string,
|
|
18
|
+
provider: string | undefined,
|
|
19
19
|
profile: string,
|
|
20
20
|
jsonOutput: boolean
|
|
21
21
|
): Promise<void> {
|
|
@@ -92,7 +92,12 @@ export async function loginBrowserFlow(
|
|
|
92
92
|
timer = setTimeout(() => finish(), 300_000);
|
|
93
93
|
|
|
94
94
|
server.listen(LOCALHOST_PORT, '127.0.0.1', () => {
|
|
95
|
-
const
|
|
95
|
+
const redirectUri = `http://127.0.0.1:${LOCALHOST_PORT}/callback`;
|
|
96
|
+
const params = new URLSearchParams({ redirect_uri: redirectUri });
|
|
97
|
+
if (provider) {
|
|
98
|
+
params.set('provider', provider);
|
|
99
|
+
}
|
|
100
|
+
const loginUrl = `${endpoint}/api/auth/cognito/login?${params.toString()}`;
|
|
96
101
|
if (!jsonOutput) {
|
|
97
102
|
consola.log('\nOpening browser for login...');
|
|
98
103
|
consola.log(`If browser does not open, visit: ${loginUrl}\n`);
|
package/src/commands/auth.ts
CHANGED
|
@@ -16,7 +16,7 @@ export function registerAuth(program: Command): void {
|
|
|
16
16
|
.command('login')
|
|
17
17
|
.description('Log in (browser callback on localhost, or --device-code)')
|
|
18
18
|
.option('--device-code', 'Device code flow', false)
|
|
19
|
-
.option('--provider <name>', 'OAuth provider
|
|
19
|
+
.option('--provider <name>', 'OAuth provider (e.g. google, msa). Omit to let the server show a chooser')
|
|
20
20
|
.option('--endpoint <url>', 'API base URL')
|
|
21
21
|
.option('--profile <name>', 'Profile to save credentials', 'default')
|
|
22
22
|
.action(
|
|
@@ -33,7 +33,7 @@ export function registerAuth(program: Command): void {
|
|
|
33
33
|
if (opts.deviceCode) {
|
|
34
34
|
await loginDeviceCodeFlow(ep, opts.profile ?? 'default', Boolean(g.json));
|
|
35
35
|
} else {
|
|
36
|
-
await loginBrowserFlow(ep, opts.provider
|
|
36
|
+
await loginBrowserFlow(ep, opts.provider, opts.profile ?? 'default', Boolean(g.json));
|
|
37
37
|
}
|
|
38
38
|
})
|
|
39
39
|
);
|