
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
@equinor/fusion-framework-module-msal
Advanced tools
Microsoft Authentication Library (MSAL) integration module for Fusion Framework
@equinor/fusion-framework-module-msal provides secure Azure AD authentication for browser applications using Microsoft's MSAL (Microsoft Authentication Library). Perfect for web applications, SPAs, and React apps that need to authenticate with Microsoft services.
pnpm add @equinor/fusion-framework-module-msal
import { enableMSAL } from '@equinor/fusion-framework-module-msal';
import { ModulesConfigurator } from '@equinor/fusion-framework-module';
const configurator = new ModulesConfigurator();
enableMSAL(configurator, (builder) => {
builder.setClientConfig({
tenantId: 'your-tenant-id',
clientId: 'your-client-id',
redirectUri: 'https://your-app.com/callback'
});
builder.setRequiresAuth(true);
});
const framework = await initialize();
const token = await framework.auth.acquireAccessToken({
scopes: ['https://graph.microsoft.com/.default']
});
[!IMPORTANT] The
@equinor/fusion-framework-appenables this package by default, so applications using the app package do not need to enable this module manually.
| Setting | Description | Required |
|---|---|---|
clientId | Azure AD application client ID | β |
tenantId | Azure AD tenant ID | β |
redirectUri | Authentication callback URL | Optional |
| Setting | Description | Default |
|---|---|---|
requiresAuth | Auto-authenticate on initialization | false |
version | Force specific MSAL version | Latest |
# Required
AZURE_CLIENT_ID=your-client-id
AZURE_TENANT_ID=your-tenant-id
# Optional
AZURE_REDIRECT_URI=https://your-app.com/callback
enableMSAL(configurator, configure)Enables the MSAL module in your Fusion Framework application.
Parameters:
configurator: ModulesConfigurator - The modules configurator instanceconfigure: (builder: IAuthConfigurator) => void - Configuration functionIAuthProviderThe authentication provider interface available at framework.auth:
interface IAuthProvider {
// Current user account information
readonly defaultAccount: AccountInfo | undefined;
// Acquire an access token for the specified scopes
acquireAccessToken(options: { scopes: string[] }): Promise<string | undefined>;
// Acquire full authentication result
acquireToken(options: { scopes: string[] }): Promise<AuthenticationResult | void>;
// Login user
login(): Promise<void>;
// Logout user
logout(options?: { redirectUri?: string }): Promise<void>;
// Handle authentication redirect
handleRedirect(): Promise<void | null>;
}
The module implements a hoisting pattern where the authentication provider is created once at the root level and shared across all sub-modules. This ensures consistent authentication state throughout your application while maintaining security and performance.
[!IMPORTANT] Configure the auth module only in the root Fusion Framework instance - Sub-instances will automatically inherit the authentication configuration from the parent.
Module Hoisting: The module now uses module hoisting, meaning sub-module instances proxy the parent module instance. This creates a shared authentication state across all module instances.
Removed Multi-Client Support: This version no longer supports multiple MSAL clients (multi-tenant, multi-authority) in the same scoped instance due to how @azure/msal-browser uses a shared cache.
Benefits of V4:
| Issue | Solution |
|---|---|
| Authentication Loop | Ensure redirect URIs match your application's routing |
| Token Acquisition Fails | Check that required scopes are properly configured |
| Module Not Found | Ensure the module is properly configured and framework is initialized |
| Multiple MSAL Instances | Remove duplicate configurations from child modules |
The MSAL module includes built-in version checking to ensure compatibility between different MSAL library versions.
import { resolveVersion, VersionError } from '@equinor/fusion-framework-module-msal/versioning';
// Resolve and validate a version
const result = resolveVersion('2.0.0');
console.log(result.isLatest); // false
console.log(result.satisfiesLatest); // true
console.log(result.enumVersion); // MsalModuleVersion.V2
VersionError if requested major version is greater than latestVersionError with descriptive messageresolveVersion(version: string | SemVer): ResolvedVersionResolves and validates a version string against the latest available MSAL version.
Parameters:
version - Version string or SemVer object to resolveReturns: ResolvedVersion object containing:
wantedVersion: SemVer - The parsed requested versionlatestVersion: SemVer - The latest available versionisLatest: boolean - Whether the version is exactly the latestsatisfiesLatest: boolean - Whether the major version matches latestenumVersion: MsalModuleVersion - Corresponding enum versionThrows: VersionError for invalid or incompatible versions
VersionErrorError class for version-related issues with the following types:
InvalidVersion - Requested version is not a valid semverInvalidLatestVersion - Latest version parsing failed (build issue)MajorIncompatibility - Major version is greater than latestMinorMismatch - Minor version differs (warning only)PatchDifference - Patch version differs (info only)IncompatibleVersion - General incompatibilityimport { resolveVersion, VersionError } from '@equinor/fusion-framework-module-msal/versioning';
try {
const result = resolveVersion('3.0.0'); // Assuming latest is 2.x
} catch (error) {
if (error instanceof VersionError) {
console.error('Version error:', error.message);
console.error('Requested:', error.requestedVersion);
console.error('Latest:', error.latestVersion);
console.error('Type:', error.type);
}
}
FAQs
Microsoft Authentication Library (MSAL) integration module for Fusion Framework
The npm package @equinor/fusion-framework-module-msal receives a total of 2,019 weekly downloads. As such, @equinor/fusion-framework-module-msal popularity was classified as popular.
We found that @equinor/fusion-framework-module-msal demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.Β It has 4 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.