// SPDX-License-Identifier: MIT import { login } from "../../azure/index.ts"; import type { ResourceName } from "../../azure/index.ts"; import { loadAuthConfig } from "../../index.ts"; type LoginOptions = { useDeviceCode?: boolean; noBrowser?: boolean; browserName?: string; browserProfile?: string; }; type LoginResult = { accountUpn: string | null; resources: Array<{ resource: string; expiresOn: string | null }>; flow: "device-code" | "interactive"; browserLaunchAttempted: boolean; }; export async function runLoginCommand(resources: ResourceName[], options: LoginOptions): Promise { const config = await loadAuthConfig("public-config"); const result = await login( config.tenantId, config.clientId, resources, Boolean(options.useDeviceCode), Boolean(options.noBrowser), options.browserName, options.browserProfile, ) as LoginResult; console.log(`Logged in as ${result.accountUpn ?? ""} using ${result.flow} flow for resources: ${resources.join(",")}`); }