# azuread/microsoft-authentication-library-for-js architecture

> Architecture diagram of the GitHub repository azuread/microsoft-authentication-library-for-js, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/azuread/microsoft-authentication-library-for-js
- Repository: https://github.com/azuread/microsoft-authentication-library-for-js

## Overview

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: [`lib/msal-browser/src/controllers/StandardController.ts`](https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/src/controllers/StandardController.ts) (Standard controller), [`lib/msal-browser/src/interaction_client`](https://github.com/azuread/microsoft-authentication-library-for-js/tree/dev/lib/msal-browser/src/interaction_client) (Interaction clients), [`lib/msal-browser/src/cache/BrowserCacheManager.ts`](https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/src/cache/BrowserCacheManager.ts) (Browser cache manager), [`extensions/msal-node-extensions/src/persistence/PersistenceCreator.ts`](https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/extensions/msal-node-extensions/src/persistence/PersistenceCreator.ts) (Secure persistence)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Browser authentication"]
  node_public["Browser API"]
  node_controller["Standard controller"]
  node_interactions["Interaction clients"]
  node_nativebroker["Native broker"]
  node_customauth["Custom auth flows"]
  node_operating["Operating contexts"]
  node_requests["Auth requests"]
end

subgraph group_protocol["Protocol and security"]
  node_common["OAuth clients"]
  node_response["Response handling<br/>[ResponseHandler.ts]"]
  node_crypto["Browser crypto<br/>[BrowserCrypto.ts]"]
  node_encoding["Base64 encoding<br/>[Base64Decode.ts]"]
end

subgraph group_state["Cache and telemetry"]
  node_cachemanager["Browser cache manager"]
  node_storage[("Browser storage<br/>[LocalStorage.ts]")]
  node_session[("Session storage<br/>[SessionStorage.ts]")]
  node_commoncache["Common cache<br/>[CacheManager.ts]"]
  node_events["Events and telemetry<br/>[EventHandler.ts]"]
  node_performance["Performance events"]
end

subgraph group_framework["Framework wrappers"]
  node_angular["Angular adapter<br/>[msal.service.ts]"]
  node_guard["Angular guard<br/>[msal.guard.ts]"]
  node_interceptor["Angular interceptor"]
  node_broadcast["Angular broadcasts"]
  node_react["React adapter"]
end

subgraph group_node["Node authentication"]
  node_nodeapp["Node application API"]
  node_nodeclient["Node public client"]
  node_nodecache[("Node cache<br/>[NodeStorage.ts]")]
  node_extensions["Secure persistence"]
  node_filepersist[("File persistence<br/>[FilePersistence.ts]")]
  node_keychain[("Keychain persistence")]
  node_dpapi["Windows protection<br/>[Dpapi.ts]"]
end

node_app(("Application"))
node_entra(("Identity platform"))
node_nodeuser(("Node application"))
node_result["Authentication result"]

node_app -->|"calls"| node_public
node_public -.->|"dispatches"| node_controller
node_controller -->|"invokes"| node_interactions
node_controller -->|"uses"| node_cachemanager
node_controller -->|"accepts"| node_requests
node_interactions -.->|"invokes"| node_common
node_interactions -.->|"handles"| node_response
node_interactions -.->|"selects context"| node_operating
node_interactions -->|"delegates"| node_nativebroker
node_nativebroker -->|"uses"| node_cachemanager
node_customauth -.->|"runs native auth"| node_entra
node_common -->|"exchanges tokens"| node_entra
node_common -->|"processes response"| node_response
node_crypto -->|"encodes bytes"| node_encoding
node_cachemanager -.->|"persists data"| node_storage
node_cachemanager -.->|"persists data"| node_session
node_cachemanager -.->|"implements cache"| node_commoncache
node_storage -->|"encrypts data"| node_crypto
node_controller -.->|"publishes events"| node_events
node_storage -->|"records timings"| node_performance
node_response -.->|"returns"| node_result
node_angular -->|"wraps"| node_public
node_guard -.->|"uses"| node_angular
node_interceptor -.->|"uses"| node_angular
node_broadcast -->|"signals status"| node_angular
node_react -->|"wraps"| node_public
node_nodeuser -->|"calls"| node_nodeapp
node_nodeapp -.->|"supports"| node_nodeclient
node_nodeapp -.->|"uses protocols"| node_common
node_nodeapp -.->|"stores tokens"| node_nodecache
node_nodecache -.->|"implements cache"| node_commoncache
node_extensions -.->|"creates"| node_filepersist
node_extensions -.->|"creates"| node_keychain
node_extensions -.->|"protects data"| node_dpapi
node_extensions -.->|"persists cache"| node_nodecache

click node_public "https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/src/app/PublicClientApplication.ts"
click node_controller "https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/src/controllers/StandardController.ts"
click node_interactions "https://github.com/azuread/microsoft-authentication-library-for-js/tree/dev/lib/msal-browser/src/interaction_client"
click node_nativebroker "https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/src/interaction_client/PlatformAuthInteractionClient.ts"
click node_customauth "https://github.com/azuread/microsoft-authentication-library-for-js/tree/dev/lib/msal-browser/src/custom_auth"
click node_operating "https://github.com/azuread/microsoft-authentication-library-for-js/tree/dev/lib/msal-browser/src/operatingcontext"
click node_requests "https://github.com/azuread/microsoft-authentication-library-for-js/tree/dev/lib/msal-browser/src/request"
click node_common "https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-common/src/client/AuthorizationCodeClient.ts"
click node_response "https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/src/response/ResponseHandler.ts"
click node_crypto "https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/src/crypto/BrowserCrypto.ts"
click node_encoding "https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/src/encode/Base64Decode.ts"
click node_cachemanager "https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/src/cache/BrowserCacheManager.ts"
click node_storage "https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/src/cache/LocalStorage.ts"
click node_session "https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/src/cache/SessionStorage.ts"
click node_commoncache "https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-common/src/cache/CacheManager.ts"
click node_events "https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/src/event/EventHandler.ts"
click node_performance "https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/src/telemetry/BrowserPerformanceEvents.ts"
click node_angular "https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-angular/src/msal.service.ts"
click node_guard "https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-angular/src/msal.guard.ts"
click node_interceptor "https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-angular/src/msal.interceptor.ts"
click node_broadcast "https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-angular/src/msal.broadcast.service.ts"
click node_react "https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-react/src/hooks/useMsalAuthentication.ts"
click node_nodeapp "https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-node/src/client/ClientApplication.ts"
click node_nodeclient "https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-node/src/client/PublicClientApplication.ts"
click node_nodecache "https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-node/src/cache/NodeStorage.ts"
click node_extensions "https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/extensions/msal-node-extensions/src/persistence/PersistenceCreator.ts"
click node_filepersist "https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/extensions/msal-node-extensions/src/persistence/FilePersistence.ts"
click node_keychain "https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/extensions/msal-node-extensions/src/persistence/KeychainPersistence.ts"
click node_dpapi "https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/extensions/msal-node-extensions/src/Dpapi.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_public,node_controller,node_interactions,node_nativebroker,node_customauth,node_operating,node_requests toneBlue
class node_common,node_response,node_crypto,node_encoding toneAmber
class node_cachemanager,node_storage,node_session,node_commoncache,node_events,node_performance toneMint
class node_angular,node_guard,node_interceptor,node_broadcast,node_react toneRose
class node_nodeapp,node_nodeclient,node_nodecache,node_extensions,node_filepersist,node_keychain,node_dpapi,node_app,node_entra,node_nodeuser,node_result toneIndigo
```

## Components

### Browser authentication

- [Browser API](https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/src/app/PublicClientApplication.ts): `lib/msal-browser/src/app/PublicClientApplication.ts`
- [Standard controller](https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/src/controllers/StandardController.ts): `lib/msal-browser/src/controllers/StandardController.ts`
- [Interaction clients](https://github.com/azuread/microsoft-authentication-library-for-js/tree/dev/lib/msal-browser/src/interaction_client): `lib/msal-browser/src/interaction_client`
- [Native broker](https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/src/interaction_client/PlatformAuthInteractionClient.ts): `lib/msal-browser/src/interaction_client/PlatformAuthInteractionClient.ts`
- [Custom auth flows](https://github.com/azuread/microsoft-authentication-library-for-js/tree/dev/lib/msal-browser/src/custom_auth): `lib/msal-browser/src/custom_auth`
- [Operating contexts](https://github.com/azuread/microsoft-authentication-library-for-js/tree/dev/lib/msal-browser/src/operatingcontext): `lib/msal-browser/src/operatingcontext`
- [Auth requests](https://github.com/azuread/microsoft-authentication-library-for-js/tree/dev/lib/msal-browser/src/request): `lib/msal-browser/src/request`

### Protocol and security

- [OAuth clients](https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-common/src/client/AuthorizationCodeClient.ts): `lib/msal-common/src/client/AuthorizationCodeClient.ts`
- [Response handling](https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/src/response/ResponseHandler.ts): `lib/msal-browser/src/response/ResponseHandler.ts`
- [Browser crypto](https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/src/crypto/BrowserCrypto.ts): `lib/msal-browser/src/crypto/BrowserCrypto.ts`
- [Base64 encoding](https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/src/encode/Base64Decode.ts): `lib/msal-browser/src/encode/Base64Decode.ts`

### Cache and telemetry

- [Browser cache manager](https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/src/cache/BrowserCacheManager.ts): `lib/msal-browser/src/cache/BrowserCacheManager.ts`
- [Browser storage](https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/src/cache/LocalStorage.ts): `lib/msal-browser/src/cache/LocalStorage.ts`
- [Session storage](https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/src/cache/SessionStorage.ts): `lib/msal-browser/src/cache/SessionStorage.ts`
- [Common cache](https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-common/src/cache/CacheManager.ts): `lib/msal-common/src/cache/CacheManager.ts`
- [Events and telemetry](https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/src/event/EventHandler.ts): `lib/msal-browser/src/event/EventHandler.ts`
- [Performance events](https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/src/telemetry/BrowserPerformanceEvents.ts): `lib/msal-browser/src/telemetry/BrowserPerformanceEvents.ts`

### Framework wrappers

- [Angular adapter](https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-angular/src/msal.service.ts): `lib/msal-angular/src/msal.service.ts`
- [Angular guard](https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-angular/src/msal.guard.ts): `lib/msal-angular/src/msal.guard.ts`
- [Angular interceptor](https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-angular/src/msal.interceptor.ts): `lib/msal-angular/src/msal.interceptor.ts`
- [Angular broadcasts](https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-angular/src/msal.broadcast.service.ts): `lib/msal-angular/src/msal.broadcast.service.ts`
- [React adapter](https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-react/src/hooks/useMsalAuthentication.ts): `lib/msal-react/src/hooks/useMsalAuthentication.ts`

### Node authentication

- [Node application API](https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-node/src/client/ClientApplication.ts): `lib/msal-node/src/client/ClientApplication.ts`
- [Node public client](https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-node/src/client/PublicClientApplication.ts): `lib/msal-node/src/client/PublicClientApplication.ts`
- [Node cache](https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/lib/msal-node/src/cache/NodeStorage.ts): `lib/msal-node/src/cache/NodeStorage.ts`
- [Secure persistence](https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/extensions/msal-node-extensions/src/persistence/PersistenceCreator.ts): `extensions/msal-node-extensions/src/persistence/PersistenceCreator.ts`
- [File persistence](https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/extensions/msal-node-extensions/src/persistence/FilePersistence.ts): `extensions/msal-node-extensions/src/persistence/FilePersistence.ts`
- [Keychain persistence](https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/extensions/msal-node-extensions/src/persistence/KeychainPersistence.ts): `extensions/msal-node-extensions/src/persistence/KeychainPersistence.ts`
- [Windows protection](https://github.com/azuread/microsoft-authentication-library-for-js/blob/dev/extensions/msal-node-extensions/src/Dpapi.ts): `extensions/msal-node-extensions/src/Dpapi.ts`

### Other components

- **Application**
- **Identity platform**
- **Node application**
- **Authentication result**

## Connections

- Application → Browser API: calls (evidence: `README.md`)
- Browser API → Standard controller: dispatches
- Standard controller → Interaction clients: invokes (evidence: `lib/msal-browser/src/controllers/StandardController.ts`)
- Standard controller → Browser cache manager: uses (evidence: `lib/msal-browser/src/controllers/StandardController.ts`)
- Standard controller → Auth requests: accepts (evidence: `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 (evidence: `lib/msal-browser/src/interaction_client/PlatformAuthInteractionClient.ts`)
- Native broker → Browser cache manager: uses (evidence: `lib/msal-browser/src/interaction_client/PlatformAuthInteractionClient.ts`)
- Custom auth flows → Identity platform: runs native auth (evidence: `README.md`)
- OAuth clients → Identity platform: exchanges tokens (evidence: `lib/msal-common/src/client/AuthorizationCodeClient.ts`)
- OAuth clients → Response handling: processes response (evidence: `lib/msal-common/src/client/AuthorizationCodeClient.ts`)
- Browser crypto → Base64 encoding: encodes bytes (evidence: `lib/msal-browser/src/crypto/BrowserCrypto.ts`)
- Browser cache manager → Browser storage: persists data (evidence: `lib/msal-browser/src/cache/BrowserCacheManager.ts`)
- Browser cache manager → Session storage: persists data (evidence: `lib/msal-browser/src/cache/BrowserCacheManager.ts`)
- Browser cache manager → Common cache: implements cache
- Browser storage → Browser crypto: encrypts data (evidence: `lib/msal-browser/src/cache/LocalStorage.ts`)
- Standard controller → Events and telemetry: publishes events (evidence: `lib/msal-browser/src/controllers/StandardController.ts`)
- Browser storage → Performance events: records timings (evidence: `lib/msal-browser/src/cache/LocalStorage.ts`)
- Response handling → Authentication result: returns
- Angular adapter → Browser API: wraps (evidence: `README.md`)
- Angular guard → Angular adapter: uses
- Angular interceptor → Angular adapter: uses
- Angular broadcasts → Angular adapter: signals status (evidence: `lib/msal-angular/src/msal.service.ts`)
- React adapter → Browser API: wraps (evidence: `README.md`)
- Node application → Node application API: calls (evidence: `README.md`)
- Node application API → Node public client: supports
- Node application API → OAuth clients: uses protocols
- Node application API → Node cache: stores tokens (evidence: `lib/msal-node/src/client/ClientApplication.ts`)
- Node cache → Common cache: implements cache (evidence: `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 (evidence: `README.md`)
