@equinor/fusion-framework-module-msal 7.1.0 → 7.2.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.
@@ -113,6 +113,21 @@ export declare class MsalConfigurator extends BaseConfigBuilder<MsalConfig> {
113
113
  * ```
114
114
  */
115
115
  setRequiresAuth(requiresAuth: boolean): this;
116
+ /**
117
+ * Sets a default login hint for authentication flows.
118
+ *
119
+ * The login hint is used to pre-fill the username during authentication and
120
+ * enables silent SSO when no account is available.
121
+ *
122
+ * @param loginHint - The preferred username/email to use as login hint
123
+ * @returns The configurator instance for method chaining
124
+ *
125
+ * @example
126
+ * ```typescript
127
+ * configurator.setLoginHint('user@company.com');
128
+ * ```
129
+ */
130
+ setLoginHint(loginHint?: string): this;
116
131
  /**
117
132
  * @deprecated - since version 5.1.0, use setClient instead
118
133
  */
@@ -39,6 +39,11 @@ export type AuthConfigFn = (builder: {
39
39
  * @param requiresAuth - If true, app will attempt automatic login on initialization
40
40
  */
41
41
  setRequiresAuth: (requiresAuth: boolean) => void;
42
+ /**
43
+ * Set a default login hint used for silent SSO and pre-filled usernames
44
+ * @param loginHint - Preferred username/email to use for login hint
45
+ */
46
+ setLoginHint: (loginHint: string) => void;
42
47
  }) => void;
43
48
  /**
44
49
  * Enables MSAL authentication module in the framework.
@@ -1 +1 @@
1
- export declare const version = "7.1.0";
1
+ export declare const version = "7.2.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/fusion-framework-module-msal",
3
- "version": "7.1.0",
3
+ "version": "7.2.0",
4
4
  "description": "Microsoft Authentication Library (MSAL) integration module for Fusion Framework",
5
5
  "main": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -43,6 +43,7 @@ const MsalConfigSchema = z.object({
43
43
  provider: z.custom<IMsalProvider>().optional(),
44
44
  requiresAuth: z.boolean().optional(),
45
45
  redirectUri: z.string().optional(),
46
+ loginHint: z.string().optional(),
46
47
  authCode: z.string().optional(),
47
48
  version: z.string().transform((x: string) => String(semver.coerce(x))),
48
49
  telemetry: TelemetryConfigSchema,
@@ -180,6 +181,25 @@ export class MsalConfigurator extends BaseConfigBuilder<MsalConfig> {
180
181
  return this;
181
182
  }
182
183
 
184
+ /**
185
+ * Sets a default login hint for authentication flows.
186
+ *
187
+ * The login hint is used to pre-fill the username during authentication and
188
+ * enables silent SSO when no account is available.
189
+ *
190
+ * @param loginHint - The preferred username/email to use as login hint
191
+ * @returns The configurator instance for method chaining
192
+ *
193
+ * @example
194
+ * ```typescript
195
+ * configurator.setLoginHint('user@company.com');
196
+ * ```
197
+ */
198
+ setLoginHint(loginHint?: string): this {
199
+ this._set('loginHint', async () => loginHint);
200
+ return this;
201
+ }
202
+
183
203
  /**
184
204
  * @deprecated - since version 5.1.0, use setClient instead
185
205
  */
@@ -61,6 +61,7 @@ export class MsalProvider extends BaseModuleProvider<MsalConfig> implements IMsa
61
61
  };
62
62
  #requiresAuth?: boolean;
63
63
  #authCode?: string;
64
+ #loginHint?: string;
64
65
 
65
66
  /**
66
67
  * The MSAL module version enum value indicating the API compatibility level.
@@ -127,6 +128,7 @@ export class MsalProvider extends BaseModuleProvider<MsalConfig> implements IMsa
127
128
  });
128
129
  this.#requiresAuth = config.requiresAuth;
129
130
  this.#telemetry = config.telemetry;
131
+ this.#loginHint = config.loginHint;
130
132
 
131
133
  // Extract auth code from config if present
132
134
  // This will be used during initialize to exchange for tokens
@@ -406,6 +408,9 @@ export class MsalProvider extends BaseModuleProvider<MsalConfig> implements IMsa
406
408
  async login(options: LoginOptions): Promise<LoginResult> {
407
409
  const { behavior = 'redirect', silent = true, request } = options;
408
410
 
411
+ request.loginHint ??=
412
+ this.#loginHint ?? this.account?.username ?? this.account?.loginHint ?? undefined;
413
+
409
414
  // Determine if silent login is possible based on available account/hint information
410
415
  // Silent login requires either an account object or a loginHint to work
411
416
  const canLoginSilently = silent && (request.account || request.loginHint);
package/src/module.ts CHANGED
@@ -91,6 +91,11 @@ export type AuthConfigFn = (builder: {
91
91
  * @param requiresAuth - If true, app will attempt automatic login on initialization
92
92
  */
93
93
  setRequiresAuth: (requiresAuth: boolean) => void;
94
+ /**
95
+ * Set a default login hint used for silent SSO and pre-filled usernames
96
+ * @param loginHint - Preferred username/email to use for login hint
97
+ */
98
+ setLoginHint: (loginHint: string) => void;
94
99
  }) => void;
95
100
 
96
101
  /**
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- export const version = '7.1.0';
2
+ export const version = '7.2.0';