How azuread/microsoft-authentication-library-for-js works
MSAL.js is a family of JavaScript authentication libraries: browser and Node runtimes perform authentication and token acquisition, while React and Angular expose framework adapters and Node extensions provide persistent cache storage. The main browser workflow accepts an application request, coordinates an interactive or silent controller/client path, uses OAuth/OIDC protocol handling and cryptography, then reads or updates token cache and returns an authentication result. README-documented Node grants, custom native-auth journeys, wrappers, and secure Node persistence are retained as distinct capabilities. Source evidence is partial, so unsampled subsystem links are documented or left unverified.
Main entry points: StandardController.ts Standard controller · interaction_client Interaction clients · BrowserCacheManager.ts Browser cache manager · PersistenceCreator.ts Secure persistence
Components 33
Browser authentication
- Browser API
lib/msal-browser/src/app/PublicClientApplication.ts - Standard controller
lib/msal-browser/src/controllers/StandardController.ts - Interaction clients
lib/msal-browser/src/interaction_client - Native broker
lib/msal-browser/src/interaction_client/PlatformAuthInteractionClient.ts - Custom auth flows
lib/msal-browser/src/custom_auth - Operating contexts
lib/msal-browser/src/operatingcontext - Auth requests
lib/msal-browser/src/request
Protocol and security
- OAuth clients
lib/msal-common/src/client/AuthorizationCodeClient.ts - Response handling
lib/msal-browser/src/response/ResponseHandler.ts - Browser crypto
lib/msal-browser/src/crypto/BrowserCrypto.ts - Base64 encoding
lib/msal-browser/src/encode/Base64Decode.ts
Cache and telemetry
- Browser cache manager
lib/msal-browser/src/cache/BrowserCacheManager.ts - Browser storage
lib/msal-browser/src/cache/LocalStorage.ts - Session storage
lib/msal-browser/src/cache/SessionStorage.ts - Common cache
lib/msal-common/src/cache/CacheManager.ts - Events and telemetry
lib/msal-browser/src/event/EventHandler.ts - Performance events
lib/msal-browser/src/telemetry/BrowserPerformanceEvents.ts
Framework wrappers
- Angular adapter
lib/msal-angular/src/msal.service.ts - Angular guard
lib/msal-angular/src/msal.guard.ts - Angular interceptor
lib/msal-angular/src/msal.interceptor.ts - Angular broadcasts
lib/msal-angular/src/msal.broadcast.service.ts - React adapter
lib/msal-react/src/hooks/useMsalAuthentication.ts
Node authentication
- Node application API
lib/msal-node/src/client/ClientApplication.ts - Node public client
lib/msal-node/src/client/PublicClientApplication.ts - Node cache
lib/msal-node/src/cache/NodeStorage.ts - Secure persistence
extensions/msal-node-extensions/src/persistence/PersistenceCreator.ts - File persistence
extensions/msal-node-extensions/src/persistence/FilePersistence.ts - Keychain persistence
extensions/msal-node-extensions/src/persistence/KeychainPersistence.ts - Windows protection
extensions/msal-node-extensions/src/Dpapi.ts
Other components
- Application
- Identity platform
- Node application
- Authentication result
Connections 35
- Application → Browser API: calls
README.md - Browser API → Standard controller: dispatches
- Standard controller → Interaction clients: invokes
lib/msal-browser/src/controllers/StandardController.ts - Standard controller → Browser cache manager: uses
lib/msal-browser/src/controllers/StandardController.ts - Standard controller → Auth requests: accepts
lib/msal-browser/src/controllers/StandardController.ts - Interaction clients → OAuth clients: invokes
- Interaction clients → Response handling: handles
- Interaction clients → Operating contexts: selects context
- Interaction clients → Native broker: delegates
lib/msal-browser/src/interaction_client/PlatformAuthInteractionClient.ts - Native broker → Browser cache manager: uses
lib/msal-browser/src/interaction_client/PlatformAuthInteractionClient.ts - Custom auth flows → Identity platform: runs native auth
README.md - OAuth clients → Identity platform: exchanges tokens
lib/msal-common/src/client/AuthorizationCodeClient.ts - OAuth clients → Response handling: processes response
lib/msal-common/src/client/AuthorizationCodeClient.ts - Browser crypto → Base64 encoding: encodes bytes
lib/msal-browser/src/crypto/BrowserCrypto.ts - Browser cache manager → Browser storage: persists data
lib/msal-browser/src/cache/BrowserCacheManager.ts - Browser cache manager → Session storage: persists data
lib/msal-browser/src/cache/BrowserCacheManager.ts - Browser cache manager → Common cache: implements cache
- Browser storage → Browser crypto: encrypts data
lib/msal-browser/src/cache/LocalStorage.ts - Standard controller → Events and telemetry: publishes events
lib/msal-browser/src/controllers/StandardController.ts - Browser storage → Performance events: records timings
lib/msal-browser/src/cache/LocalStorage.ts - Response handling → Authentication result: returns
- Angular adapter → Browser API: wraps
README.md - Angular guard → Angular adapter: uses
- Angular interceptor → Angular adapter: uses
- Angular broadcasts → Angular adapter: signals status
lib/msal-angular/src/msal.service.ts - React adapter → Browser API: wraps
README.md - Node application → Node application API: calls
README.md - Node application API → Node public client: supports
- Node application API → OAuth clients: uses protocols
- Node application API → Node cache: stores tokens
lib/msal-node/src/client/ClientApplication.ts - Node cache → Common cache: implements cache
lib/msal-node/src/cache/NodeStorage.ts - Secure persistence → File persistence: creates
- Secure persistence → Keychain persistence: creates
- Secure persistence → Windows protection: protects data
- Secure persistence → Node cache: persists cache
README.md