@azure/msal-browser
Version:
Microsoft Authentication Library for js
263 lines • 12.4 kB
TypeScript
import { AccountEntity, ICrypto, IPerformanceClient, InProgressPerformanceEvent, Logger, ScopeSet, StoreInCache, TokenClaims, ITokenBindingKeyManager } from "@azure/msal-common/browser";
import { IPlatformAuthHandler } from "../broker/nativeBroker/IPlatformAuthHandler.js";
import { PlatformAuthRequest } from "../broker/nativeBroker/PlatformAuthRequest.js";
import { MATS, PlatformAuthResponse } from "../broker/nativeBroker/PlatformAuthResponse.js";
import { BrowserCacheManager } from "../cache/BrowserCacheManager.js";
import { BrowserConfiguration } from "../config/Configuration.js";
import { EventHandler } from "../event/EventHandler.js";
import { INavigationClient } from "../navigation/INavigationClient.js";
import { HandleRedirectPromiseOptions } from "../request/HandleRedirectPromiseOptions.js";
import { PopupRequest } from "../request/PopupRequest.js";
import { RedirectRequest } from "../request/RedirectRequest.js";
import { SilentRequest } from "../request/SilentRequest.js";
import { SsoSilentRequest } from "../request/SsoSilentRequest.js";
import { AuthenticationResult } from "../response/AuthenticationResult.js";
import { ApiId, CacheLookupPolicy } from "../utils/BrowserConstants.js";
import { BaseInteractionClient } from "./BaseInteractionClient.js";
import { SilentCacheClient } from "./SilentCacheClient.js";
export declare class PlatformAuthInteractionClient extends BaseInteractionClient {
protected apiId: ApiId;
protected accountId: string;
protected platformAuthProvider: IPlatformAuthHandler;
protected silentCacheClient: SilentCacheClient;
protected nativeStorageManager: BrowserCacheManager;
protected skus: string;
/**
* Storage location reported for MSAL-owned browser DPoP keys in reqCnf.
* This does not constrain the binding selected by the platform broker.
*/
private static readonly MSAL_DPOP_KEY_STORAGE_LOCATION;
constructor(config: BrowserConfiguration, browserStorage: BrowserCacheManager, browserCrypto: ICrypto, logger: Logger, eventHandler: EventHandler, navigationClient: INavigationClient, apiId: ApiId, performanceClient: IPerformanceClient, provider: IPlatformAuthHandler, accountId: string, nativeStorageImpl: BrowserCacheManager, correlationId: string, tokenBindingKeyManager?: ITokenBindingKeyManager);
/**
* Adds SKUs to request extra query parameters
* @param request {PlatformAuthRequest}
* @private
*/
private addRequestSKUs;
/**
* Acquire token from native platform via browser extension
* @param request
*/
acquireToken(request: PopupRequest | SilentRequest | SsoSilentRequest, cacheLookupPolicy?: CacheLookupPolicy): Promise<AuthenticationResult>;
/**
* Records platform-broker error telemetry on the root event for the current
* correlationId. `isNativeBroker` is set optimistically to true because the
* broker was engaged; when the caller subsequently falls back to a web flow
* that succeeds, the root success measurement overrides it to false via
* `result.fromPlatformBroker`. Terminal broker errors (no fallback) retain
* true. `brokerErrorName`/`brokerErrorCode` are recorded when the error is an `AuthError`.
* @param error error thrown by the broker interaction
*/
private setBrokerErrorTelemetry;
/**
* Creates silent flow request
* @param request
* @param cachedAccount
* @returns CommonSilentFlowRequest
*/
private createSilentCacheRequest;
/**
* Maps platform-broker token-binding state to silent-cache request fields.
* @param request
*/
private createSilentCacheTokenBindingParameters;
/**
* Fetches unexpired tokens when allowed by cache policy.
* @param nativeAccountId
* @param request
* @param cacheLookupPolicy
* @returns Cached result, or undefined when cache policy bypasses lookup.
*/
protected acquireTokensFromCache(nativeAccountId: string, request: PlatformAuthRequest, cacheLookupPolicy?: CacheLookupPolicy): Promise<AuthenticationResult | undefined>;
/**
* Acquires a token from native platform then redirects to the redirectUri instead of returning the response
* @param {RedirectRequest} request
* @param {InProgressPerformanceEvent} rootMeasurement
* @param {HandleRedirectPromiseOptions} options
*/
acquireTokenRedirect(request: RedirectRequest, rootMeasurement: InProgressPerformanceEvent, options?: HandleRedirectPromiseOptions): Promise<void>;
/**
* If the previous page called native platform for a token using redirect APIs, send the same request again and return the response
* @param performanceClient {IPerformanceClient?}
* @param correlationId {string?} correlation identifier
*/
handleRedirectPromise(): Promise<AuthenticationResult | null>;
/**
* Logout from native platform via browser extension
* @param request
*/
logout(): Promise<void>;
/**
* Transform response from native platform into AuthenticationResult object which will be returned to the end user
* @param response
* @param request
* @param reqTimestamp
*/
protected handleNativeResponse(response: PlatformAuthResponse, request: PlatformAuthRequest, reqTimestamp: number, storeInCache?: StoreInCache): Promise<AuthenticationResult>;
/**
* creates an homeAccountIdentifier for the account
* @param response
* @param idTokenObj
* @returns
*/
protected createHomeAccountIdentifier(response: PlatformAuthResponse, idTokenClaims: TokenClaims): string;
/**
* Helper to generate scopes
* @param response
* @param request
* @returns
*/
generateScopes(requestScopes: string, responseScopes?: string): ScopeSet;
/**
* If PoP token is requesred, records the PoP token if returned from the WAM, else generates one in the browser
* @param request
* @param response
*/
generatePopAccessToken(response: PlatformAuthResponse, request: PlatformAuthRequest): Promise<string>;
/**
* Generates authentication result
* @param response
* @param request
* @param idTokenObj
* @param accountEntity
* @param authority
* @param reqTimestamp
* @returns
*/
protected generateAuthenticationResult(response: PlatformAuthResponse, request: PlatformAuthRequest, idTokenClaims: TokenClaims, accountEntity: AccountEntity, authority: string, reqTimestamp: number): Promise<AuthenticationResult>;
/**
* cache the account entity in browser storage
* @param accountEntity
*/
cacheAccount(accountEntity: AccountEntity, kmsi: boolean, clearExistingTokens?: boolean): Promise<void>;
/**
* Stores the access_token and id_token in inmemory storage
* @param response
* @param request
* @param homeAccountIdentifier
* @param idTokenObj
* @param responseAccessToken
* @param tenantId
* @param reqTimestamp
*/
cacheNativeTokens(response: PlatformAuthResponse, request: PlatformAuthRequest, homeAccountIdentifier: string, idTokenClaims: TokenClaims, tenantId: string, reqTimestamp: number, environment: string, storeInCache?: StoreInCache, dpopBrokerOutcome?: "none" | "L1" | "L3"): Promise<void>;
getExpiresInValue(tokenType: string, expiresIn: string | number | undefined): number;
protected addTelemetryFromNativeResponse(matsResponse?: string): MATS | null;
/**
* Gets MATS telemetry from native response
* @param response
* @returns
*/
private getMATSFromResponse;
/**
* Returns whether or not response came from native cache
* @param response
* @returns
*/
protected isResponseFromCache(mats: MATS): boolean;
/**
* Translates developer provided request object into NativeRequest object
* @param request
*/
protected initializePlatformRequest(request: PopupRequest | SsoSilentRequest): Promise<PlatformAuthRequest>;
/**
* Creates and validates the broker-specific parameters for a DPoP request.
* @param request - Developer-provided token request.
* @returns Broker parameters for a DPoP token and resource proof.
*/
private createDpopRequestParameters;
/**
* Provisions the local key and confirmation data for a DPoP broker request.
* @param request - Broker request to prepare.
* @param reuseExistingKey - Whether a complete existing key binding may be reused.
*/
private prepareDpopBrokerRequest;
/**
* Creates the confirmation claim for an MSAL-owned broker DPoP key.
* @param keyId - Browser-managed DPoP key identifier.
* @returns Encoded broker confirmation claim.
*/
private createDpopBrokerReqCnf;
/**
* Ensures an owned DPoP key can survive redirect navigation before the
* request metadata is persisted for phase two.
*/
private ensureRedirectDpopKeyIsPersisted;
/**
* Validates and normalizes the DPoP binding outcome returned by the broker.
* @param response - Broker response to validate.
* @param request - Broker request associated with the response.
* @returns The validated DPoP binding level, or `none` for non-DPoP requests.
*/
private validateDpopBrokerOutcome;
/**
* Normalizes the canonical DPoP fields returned under response properties.
*/
private normalizeDpopBrokerResponse;
/**
* Validates normalized fields shared by L1 and L3 broker DPoP responses.
*/
private validateNormalizedDpopBrokerResponse;
/**
* Validates a broker-returned L3 DPoP proof outcome.
*/
private validateDpopBrokerL3Outcome;
/**
* Validates an L1 DPoP outcome that MSAL will sign with its local key.
*/
private validateDpopBrokerL1Outcome;
/**
* Emits bounded failure telemetry and rejects an invalid DPoP response.
*/
private throwInvalidDpopResponse;
/**
* Returns the broker proof or signs an L1 resource proof with the local key.
* @param response - Broker response containing the access token and optional proof.
* @param request - Broker request containing the proof context and local key.
* @returns The resource proof for the broker access token.
*/
private generateDpopProof;
/**
* Removes a generated DPoP request key and clears its request metadata.
* @param request - Broker request whose generated key should be removed.
*/
private resetGeneratedDpopRequestKey;
/**
* Attempts to remove a generated DPoP request key without replacing an
* existing operation error with a cleanup failure.
* @param request - Broker request whose generated key should be removed.
*/
private resetGeneratedDpopRequestKeyBestEffort;
/**
* Records that a DPoP request is about to be dispatched to the platform broker.
* @param request - Broker request about to cross the provider boundary.
*/
private addDpopBrokerAttemptTelemetry;
/**
* Determines whether a request uses the DPoP broker protocol.
* @param request - Broker request to inspect.
* @returns Whether the request uses a DPoP token type.
*/
private isDpopBrokerRequest;
/**
* Determines whether a token type represents a DPoP broker request.
* @param tokenType - Token type to inspect.
* @returns Whether the token type is a supported DPoP broker token type.
*/
private isDpopBrokerTokenType;
/**
* Removes a DPoP key while reporting cleanup failures.
* @param keyId - Identifier of the DPoP key to remove.
* @returns Whether the key was removed successfully.
*/
private removeDpopKey;
private getCanonicalAuthority;
private getPrompt;
/**
* Handles extra broker request parameters.
* @param request - Platform broker request.
* @param embeddedClientId - Embedded application client identifier.
*/
private handleExtraBrokerParams;
}
//# sourceMappingURL=PlatformAuthInteractionClient.d.ts.map