@indigoai-us/hq-cli 5.35.1 → 5.36.0

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.
@@ -0,0 +1,30 @@
1
+ import type { CognitoAuthConfig } from "@indigoai-us/hq-cloud";
2
+ import { DEFAULT_COGNITO } from "./cognito-session.js";
3
+
4
+ const PROVIDER_TO_COGNITO_IDP = {
5
+ google: "Google",
6
+ microsoft: "MicrosoftPersonal",
7
+ picker: undefined,
8
+ } as const;
9
+
10
+ export type LoginProvider = keyof typeof PROVIDER_TO_COGNITO_IDP;
11
+
12
+ export function parseLoginProvider(value: string | undefined): LoginProvider | undefined {
13
+ if (value === undefined) return undefined;
14
+ const normalized = value.trim().toLowerCase();
15
+ if (normalized in PROVIDER_TO_COGNITO_IDP) {
16
+ return normalized as LoginProvider;
17
+ }
18
+ throw new Error("Provider must be one of: google, microsoft, picker");
19
+ }
20
+
21
+ export function cognitoConfigForLoginProvider(
22
+ value: string | undefined,
23
+ ): CognitoAuthConfig {
24
+ const provider = parseLoginProvider(value);
25
+ if (!provider) return DEFAULT_COGNITO;
26
+ return {
27
+ ...DEFAULT_COGNITO,
28
+ identityProvider: PROVIDER_TO_COGNITO_IDP[provider],
29
+ };
30
+ }