UNPKG

@azure/msal-browser

Version:
68 lines (65 loc) • 3.27 kB
/*! @azure/msal-browser v5.25.0 2026-10-06 */ 'use strict'; import { ResponseHandler, Constants } from '@azure/msal-common/browser'; import { StandardInteractionClient } from '../../../../interaction_client/StandardInteractionClient.mjs'; import { MethodNotImplementedError } from '../../error/MethodNotImplementedError.mjs'; import { initializeServerTelemetryManager } from '../../../../interaction_client/BaseInteractionClient.mjs'; /* * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ /* * Shared base for Native Auth V2 interaction clients. It extends * `StandardInteractionClient` for common browser infrastructure while keeping * V1 and V2 token handling independent. */ class InteractionClientBaseV2 extends StandardInteractionClient { constructor(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, customAuthAuthority) { super(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, ""); this.customAuthAuthority = customAuthAuthority; this.tokenResponseHandler = new ResponseHandler(this.config.auth.clientId, this.browserStorage, this.browserCrypto, this.logger, this.performanceClient, null, null); } // Required by the base contract. After sign-in, use CustomAuthAccountData.getAccessToken(). acquireToken( // eslint-disable-next-line @typescript-eslint/no-unused-vars request) { throw new MethodNotImplementedError("InteractionClientBaseV2.acquireToken"); } // Required by the base contract. After sign-in, use CustomAuthAccountData.signOut(). logout( // eslint-disable-next-line @typescript-eslint/no-unused-vars request) { throw new MethodNotImplementedError("InteractionClientBaseV2.logout"); } getScopes(scopes) { const requestedScopes = scopes?.filter((scope) => !!scope) ?? []; const seenScopes = new Set(requestedScopes.map((scope) => scope.toLowerCase())); const defaultScopes = [ Constants.OPENID_SCOPE, Constants.PROFILE_SCOPE, Constants.OFFLINE_ACCESS_SCOPE, ]; return [ ...requestedScopes, ...defaultScopes.filter((scope) => !seenScopes.has(scope.toLowerCase())), ]; } async handleTokenResponse(tokenResponse, requestScopes, correlationId, apiId) { this.logger.verbose("1aahxi", correlationId); const requestTimestamp = Math.round(new Date().getTime() / 1000.0); const result = await this.tokenResponseHandler.handleServerTokenResponse(tokenResponse, this.customAuthAuthority, requestTimestamp, { authority: this.customAuthAuthority.canonicalAuthority, correlationId, scopes: requestScopes, }, apiId); return result; } createRequestContext(apiId, correlationId) { return { correlationId, telemetryManager: initializeServerTelemetryManager(apiId, this.config.auth.clientId, correlationId, this.browserStorage, this.logger), }; } } export { InteractionClientBaseV2 }; //# sourceMappingURL=InteractionClientBaseV2.mjs.map