UNPKG

@azure/msal-browser

Version:
67 lines (64 loc) • 3.11 kB
/*! @azure/msal-browser v5.30.0 2026-11-18 */ '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. */ 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); } acquireToken( // eslint-disable-next-line @typescript-eslint/no-unused-vars request) { throw new MethodNotImplementedError("InteractionClientBaseV2.acquireToken"); } 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, requestedScopes, correlationId, apiId) { this.logger.verbose("1aahxi", correlationId); const requestTimestamp = Math.round(new Date().getTime() / 1000.0); const responseScopes = tokenResponse.scope ? tokenResponse.scope.split(" ").filter((scope) => !!scope) : requestedScopes; const result = await this.tokenResponseHandler.handleServerTokenResponse(tokenResponse, this.customAuthAuthority, requestTimestamp, { authority: this.customAuthAuthority.canonicalAuthority, correlationId, scopes: responseScopes, }, 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