{"version":3,"file":"SilentRefreshClient.js","sources":["../../src/interaction_client/SilentRefreshClient.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { StandardInteractionClient } from \"./StandardInteractionClient\";\nimport { CommonSilentFlowRequest, AuthenticationResult, ServerTelemetryManager, RefreshTokenClient, AuthError, AzureCloudOptions, PerformanceEvents } from \"@azure/msal-common\";\nimport { ApiId } from \"../utils/BrowserConstants\";\nimport { BrowserAuthError } from \"../error/BrowserAuthError\";\n\nexport class SilentRefreshClient extends StandardInteractionClient {\n /**\n * Exchanges the refresh token for new tokens\n * @param request\n */\n async acquireToken(request: CommonSilentFlowRequest): Promise {\n const silentRequest: CommonSilentFlowRequest = {\n ...request,\n ...await this.initializeBaseRequest(request)\n };\n const acquireTokenMeasurement = this.performanceClient.startMeasurement(PerformanceEvents.SilentRefreshClientAcquireToken, silentRequest.correlationId);\n const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenSilent_silentFlow);\n\n const refreshTokenClient = await this.createRefreshTokenClient(serverTelemetryManager, silentRequest.authority, silentRequest.azureCloudOptions);\n this.logger.verbose(\"Refresh token client created\");\n // Send request to renew token. Auth module will throw errors if token cannot be renewed.\n return refreshTokenClient.acquireTokenByRefreshToken(silentRequest)\n .then((result: AuthenticationResult) => {\n acquireTokenMeasurement.endMeasurement({\n success: true,\n fromCache: result.fromCache,\n requestId: result.requestId\n });\n\n return result;\n })\n .catch((e: AuthError) => {\n if (e instanceof AuthError) {\n (e as AuthError).setCorrelationId(this.correlationId);\n }\n serverTelemetryManager.cacheFailedRequest(e);\n acquireTokenMeasurement.endMeasurement({\n errorCode: e.errorCode,\n subErrorCode: e.subError,\n success: false\n });\n throw e;\n });\n }\n\n /**\n * Currently Unsupported\n */\n logout(): Promise {\n // Synchronous so we must reject\n return Promise.reject(BrowserAuthError.createSilentLogoutUnsupportedError());\n }\n\n /**\n * Creates a Refresh Client with the given authority, or the default authority.\n * @param serverTelemetryManager\n * @param authorityUrl\n */\n protected async createRefreshTokenClient(serverTelemetryManager: ServerTelemetryManager, authorityUrl?: string, azureCloudOptions?: AzureCloudOptions): Promise {\n // Create auth module.\n const clientConfig = await this.getClientConfiguration(serverTelemetryManager, authorityUrl, azureCloudOptions);\n return new RefreshTokenClient(clientConfig, this.performanceClient);\n }\n}\n"],"names":[],"mappings":";;;;;;;;AAAA;;;;;IAUyC,uCAAyB;IAAlE;;KA0DC;;;;;IArDS,0CAAY,GAAlB,UAAmB,OAAgC;;;;;;;2CAExC,OAAO;wBACP,qBAAM,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,EAAA;;wBAF1C,aAAa,qCAEZ,SAAyC,GAC/C;wBACK,uBAAuB,GAAG,IAAI,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,+BAA+B,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC;wBAClJ,sBAAsB,GAAG,IAAI,CAAC,gCAAgC,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;wBAE/E,qBAAM,IAAI,CAAC,wBAAwB,CAAC,sBAAsB,EAAE,aAAa,CAAC,SAAS,EAAE,aAAa,CAAC,iBAAiB,CAAC,EAAA;;wBAA1I,kBAAkB,GAAG,SAAqH;wBAChJ,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,8BAA8B,CAAC,CAAC;;wBAEpD,sBAAO,kBAAkB,CAAC,0BAA0B,CAAC,aAAa,CAAC;iCAC9D,IAAI,CAAC,UAAC,MAA4B;gCAC/B,uBAAuB,CAAC,cAAc,CAAC;oCACnC,OAAO,EAAE,IAAI;oCACb,SAAS,EAAE,MAAM,CAAC,SAAS;oCAC3B,SAAS,EAAE,MAAM,CAAC,SAAS;iCAC9B,CAAC,CAAC;gCAEH,OAAO,MAAM,CAAC;6BACjB,CAAC;iCACD,KAAK,CAAC,UAAC,CAAY;gCAChB,IAAI,CAAC,YAAY,SAAS,EAAE;oCACvB,CAAe,CAA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