@azure/msal-common package
Classes
| AuthError |
General error class thrown by the MSAL.js library. |
| AuthenticationHeaderParser |
This is a helper class that parses supported HTTP response authentication headers to extract and return header challenge values that can be used outside the basic authorization flows. |
| CacheError |
Error thrown when there is an error with the cache |
| ClientAuthError |
Error thrown when there is an error in the client code running on the browser. |
| ClientConfigurationError |
Error thrown when there is an error in configuration of the MSAL.js library. |
| InteractionRequiredAuthError |
Error thrown when user interaction is required. |
| Logger |
Class which facilitates logging of messages to a specific place. |
| NetworkError |
Represents network related errors |
| PerformanceClient | |
| ProtocolUtils |
Class which provides helpers for OAuth 2.0 protocol specific values |
| ScopeSet |
The ScopeSet class creates a set of scopes. Scopes are case-insensitive, unique values, so the Set object in JS makes the most sense to implement for this class. All scopes are trimmed and converted to lower case strings in intersection and union functions to ensure uniqueness of strings. |
| ServerError |
Error thrown when there is an error with the server code, for example, unavailability. |
| StubPerformanceClient | |
| UrlString |
Url object class which can perform various transformations on url strings. |
| TokenCacheContext |
This class instance helps track the memory changes facilitating decisions to read from and write to the persistent cache |
Interfaces
| ICrypto |
Interface for crypto functions used by library |
| ILoggerCallback | |
| INetworkModule |
Client network interface to send backend requests. |
| IPerformanceClient | |
| IPerformanceMeasurement | |
| IUri |
Interface which describes URI components. |
| PreQueueEvent | |
| IAppTokenProvider | |
| ICachePlugin | |
| IGuidGenerator | |
| INativeBrokerPlugin | |
| ISerializableTokenCache | |
Type Aliases
| AADAuthorityConstants | |
| AccessTokenEntity |
Access token cache type |
| AccountFilter |
Account: <home_account_id>-<environment>-<realm*> |
| AccountInfo |
Account object with the following signature:
|
| ActiveAccountFilters | |
| AppMetadataEntity |
App Metadata Cache Type |
| ApplicationTelemetry |
Telemetry information sent on request
|
| AuthenticationResult |
Result returned from the authority's token endpoint.
|
| AuthenticationScheme | |
| AuthorityOptions | |
| AuthorityType | |
| AuthorizationCodePayload |
Response returned after processing the code response query string or fragment. |
| AuthorizeResponse |
Response properties that may be returned by the /authorize endpoint |
| AzureCloudInstance | |
| AzureCloudOptions |
AzureCloudInstance specific options
|
| AzureRegion | |
| AzureRegionConfiguration | |
| BaseAuthRequest |
BaseAuthRequest
|
| CacheAccountType | |
| CacheOptions |
Use this to configure credential cache preferences in the ClientConfiguration object
|
| CacheOutcome | |
| CacheType | |
| CcsCredential | |
| CcsCredentialType | |
| ClaimsRequestKeys | |
| ClientInfo |
Client info object which consists of: uid: user id utid: tenant id xms_tdbr: optional, only for non-US tenants |
| CommonAuthorizationCodeRequest |
Request object passed by user to acquire a token from the server exchanging a valid authorization code (second leg of OAuth2.0 Authorization Code flow)
|
| CommonAuthorizationUrlRequest |
Request object passed by user to retrieve a Code from the server (first leg of authorization code grant flow)
|
| CommonEndSessionRequest |
CommonEndSessionRequest
|
| CommonRefreshTokenRequest |
CommonRefreshTokenRequest
|
| CommonSilentFlowRequest |
SilentFlow parameters passed by the user to retrieve credentials silently
|
| CredentialEntity |
Credential Cache Type |
| CredentialFilter |
Credential: <home_account_id*>-<environment>-<credential_type>-<client_id>-<realm*>-<target*>-<scheme*> |
| CredentialType | |
| EncodingTypes | |
| ExternalTokenResponse |
Response object used for loading external tokens to cache.
|
| GrantType | |
| HeaderNames | |
| HttpMethod | |
| HttpStatus | |
| IdTokenEntity |
Id Token Cache Type |
| InProgressPerformanceEvent | |
| JsonWebTokenTypes | |
| LibraryStateObject |
Type which defines the object that is stringified, encoded and sent in the state value. Contains the following:
|
| LoggerOptions |
Use this to configure the logging that MSAL does, by configuring logger options in the Configuration object
|
| NetworkRequestOptions |
Options allowed by network request APIs. |
| NetworkResponse | |
| OAuthResponseType | |
| OIDCOptions |
Options for the OIDC protocol mode. |
| PasswordGrantConstants | |
| PerformanceCallbackFunction | |
| PerformanceEvent |
Performance measurement taken by the library, including metadata about the request and application. |
| PersistentCacheKeys | |
| PkceCodes |
The PkceCodes type describes the structure of objects that contain PKCE code challenge and verifier pairs |
| ProtocolMode | |
| QueueMeasurement |
Queue measurement type |
| RefreshTokenEntity |
Refresh Token Cache Type |
| RequestStateObject |
Type which defines the stringified and encoded object sent to the service in the authorize request. |
| RequestThumbprint |
Type representing a unique request thumbprint. |
| ResponseMode | |
| ServerAuthorizationTokenResponse |
Deserialized response object from server authorization code request.
In case of error:
|
| ServerResponseType | |
| ServerTelemetryEntity | |
| ServerTelemetryRequest | |
| ShrOptions | |
| SignedHttpRequest | |
| SignedHttpRequestParameters | |
| StaticAuthorityOptions | |
| StoreInCache |
Controls whether tokens should be stored in the cache or not. If set to false, tokens may still be acquired and returned but will not be cached for later retrieval. |
| StringDict |
Key-Value type to support queryParams, extraQueryParams and claims |
| SubMeasurement | |
| SystemOptions |
Use this to configure token renewal info in the Configuration object
|
| TenantProfile |
Account details that vary across tenants for the same user |
| ThrottlingEntity | |
| TokenClaims |
Type which describes Id Token claims known by MSAL. |
| TokenKeys | |
| AppTokenProviderParameters |
Input object for the IAppTokenProvider extensiblity. MSAL will create this object, which can be used to help create an AppTokenProviderResult.
|
| AppTokenProviderResult |
Output object for IAppTokenProvider extensiblity.
|
| ClientAssertion |
Client Assertion credential for Confidential Clients |
| ClientAssertionCallback | |
| ClientAssertionConfig | |
| CommonClientCredentialRequest |
CommonClientCredentialRequest
|
| CommonDeviceCodeRequest |
Parameters for Oauth2 device code flow.
|
| CommonOnBehalfOfRequest |
|
| CommonUsernamePasswordRequest |
CommonUsernamePassword parameters passed by the user to retrieve credentials Note: The latest OAuth 2.0 Security Best Current Practice disallows the password grant entirely. This flow is added for internal testing.
|
| DeviceCodeResponse |
DeviceCode returned by the security token service device code endpoint containing information necessary for device code flow.
|
| NativeRequest | |
| NativeSignOutRequest | |
| ServerDeviceCodeResponse | |
Enums
| LogLevel |
Log message level. |
| PerformanceEventStatus |
State of the performance event. |
| PerformanceEvents |
Enumeration of operations that are instrumented by have their performance measured by the PerformanceClient. |
Functions
| build |
|
| build |
Function to build a client info object from server clientInfo string |
| build |
Function to build a client info object from cached homeAccountId string |
| build |
|
| build |
Build tenant profile |
| create |
|
| create |
Helper function to wrap browser errors in a CacheError object |
| create |
|
| create |
|
| create |
Creates an InteractionRequiredAuthError |
| create |
Creates NetworkError object for a failed network request |
| format |
|
| get |
|
| get |
Gets tenantId from available ID token claims to set as credential realm with the following precedence:
|
| tenant |
Returns true if tenantId matches the utid portion of homeAccountId |
| update |
Replaces account info that varies by tenant profile sourced from the ID token claims passed in with the tenant-specific account info |
Function Details
buildAccountToCache(CacheManager, Authority, string, (input: string) => string, string, TokenClaims, string, string, null | string, AuthorizationCodePayload, string, Logger)
function buildAccountToCache(cacheStorage: CacheManager, authority: Authority, homeAccountId: string, base64Decode: (input: string) => string, correlationId: string, idTokenClaims?: TokenClaims, clientInfo?: string, environment?: string, claimsTenantId?: null | string, authCodePayload?: AuthorizationCodePayload, nativeAccountId?: string, logger?: Logger): AccountEntity
Parameters
- cacheStorage
-
CacheManager
- authority
-
Authority
- homeAccountId
-
string
- base64Decode
-
(input: string) => string
- correlationId
-
string
- idTokenClaims
- TokenClaims
- clientInfo
-
string
- environment
-
string
- claimsTenantId
-
null | string
- authCodePayload
- AuthorizationCodePayload
- nativeAccountId
-
string
- logger
- Logger
Returns
AccountEntity
buildClientInfo(string, (input: string) => string)
Function to build a client info object from server clientInfo string
function buildClientInfo(rawClientInfo: string, base64Decode: (input: string) => string): ClientInfo
Parameters
- rawClientInfo
-
string
- base64Decode
-
(input: string) => string
Returns
buildClientInfoFromHomeAccountId(string)
Function to build a client info object from cached homeAccountId string
function buildClientInfoFromHomeAccountId(homeAccountId: string): ClientInfo
Parameters
- homeAccountId
-
string
Returns
buildStaticAuthorityOptions(Partial<AuthorityOptions>)
function buildStaticAuthorityOptions(authOptions: Partial<AuthorityOptions>): StaticAuthorityOptions
Parameters
- authOptions
-
Partial<AuthorityOptions>
Returns
buildTenantProfile(string, string, string, TokenClaims)
Build tenant profile
function buildTenantProfile(homeAccountId: string, localAccountId: string, tenantId: string, idTokenClaims?: TokenClaims): TenantProfile
Parameters
- homeAccountId
-
string
Home account identifier for this account object
- localAccountId
-
string
Local account identifer for this account object
- tenantId
-
string
Full tenant or organizational id that this account belongs to
- idTokenClaims
- TokenClaims
Claims from the ID token
Returns
createAuthError(string, string)
function createAuthError(code: string, additionalMessage?: string): AuthError
Parameters
- code
-
string
- additionalMessage
-
string
Returns
createCacheError(unknown)
Helper function to wrap browser errors in a CacheError object
function createCacheError(e: unknown): CacheError
Parameters
- e
-
unknown
Returns
createClientAuthError(string, string)
function createClientAuthError(errorCode: string, additionalMessage?: string): ClientAuthError
Parameters
- errorCode
-
string
- additionalMessage
-
string
Returns
createClientConfigurationError(string)
function createClientConfigurationError(errorCode: string): ClientConfigurationError
Parameters
- errorCode
-
string
Returns
createInteractionRequiredAuthError(string)
Creates an InteractionRequiredAuthError
function createInteractionRequiredAuthError(errorCode: string): InteractionRequiredAuthError
Parameters
- errorCode
-
string
Returns
createNetworkError(AuthError, number, Record<string, string>, Error)
Creates NetworkError object for a failed network request
function createNetworkError(error: AuthError, httpStatus?: number, responseHeaders?: Record<string, string>, additionalError?: Error): NetworkError
Parameters
- error
- AuthError
Error to be thrown back to the caller
- httpStatus
-
number
Status code of the network request
- responseHeaders
-
Record<string, string>
Response headers of the network request, when available
- additionalError
-
Error
Returns
NetworkError object
formatAuthorityUri(string)
function formatAuthorityUri(authorityUri: string): string
Parameters
- authorityUri
-
string
Returns
string
getRequestThumbprint(string, BaseAuthRequest, string)
function getRequestThumbprint(clientId: string, request: BaseAuthRequest, homeAccountId?: string): RequestThumbprint
Parameters
- clientId
-
string
- request
- BaseAuthRequest
- homeAccountId
-
string
Returns
getTenantIdFromIdTokenClaims(TokenClaims)
Gets tenantId from available ID token claims to set as credential realm with the following precedence:
- tid - if the token is acquired from an Azure AD tenant tid will be present
- tfp - if the token is acquired from a modern B2C tenant tfp should be present
- acr - if the token is acquired from a legacy B2C tenant acr should be present Downcased to match the realm case-insensitive comparison requirements
function getTenantIdFromIdTokenClaims(idTokenClaims?: TokenClaims): string | null
Parameters
- idTokenClaims
- TokenClaims
Returns
string | null
tenantIdMatchesHomeTenant(string, string)
Returns true if tenantId matches the utid portion of homeAccountId
function tenantIdMatchesHomeTenant(tenantId?: string, homeAccountId?: string): boolean
Parameters
- tenantId
-
string
- homeAccountId
-
string
Returns
boolean
updateAccountTenantProfileData(AccountInfo, TenantProfile, TokenClaims, string)
Replaces account info that varies by tenant profile sourced from the ID token claims passed in with the tenant-specific account info
function updateAccountTenantProfileData(baseAccountInfo: AccountInfo, tenantProfile?: TenantProfile, idTokenClaims?: TokenClaims, idTokenSecret?: string): AccountInfo
Parameters
- baseAccountInfo
- AccountInfo
- tenantProfile
- TenantProfile
- idTokenClaims
- TokenClaims
- idTokenSecret
-
string