text: "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  var sp_telemetry_1 = require("@ms/sp-telemetry");
  var SPHttpClient_1 = require("../spHttpClient/SPHttpClient");
  var TokenUtilityLogger = (function () {
      function TokenUtilityLogger() {
      }
      TokenUtilityLogger.prototype.logInfo = function (message) {
          sp_telemetry_1._TraceLogger.logVerbose(TokenUtilityLogger.logSource, message);
      };
      TokenUtilityLogger.prototype.logError = function (message) {
          sp_telemetry_1._TraceLogger.logError(TokenUtilityLogger.logSource, new Error(message));
      };
      TokenUtilityLogger.prototype.logWarning = function (message) {
          sp_telemetry_1._TraceLogger.logVerbose(TokenUtilityLogger.logSource, 'Warning: ' + message);
      };
      TokenUtilityLogger.logSource = sp_telemetry_1._LogSource.create('TokenUtility');
      return TokenUtilityLogger;
  }());
  var OAuthUtilityContext = (function () {
      function OAuthUtilityContext(serviceScope) {
          var _this = this;
          serviceScope.whenFinished(function () {
              _this._spHttpClient = serviceScope.consume(SPHttpClient_1.default.serviceKey);
              _this._logger = new TokenUtilityLogger();
          });
      }
      Object.defineProperty(OAuthUtilityContext.prototype, "logger", {
          get: function () {
              return this._logger;
          },
          enumerable: true,
          configurable: true
      });
      Object.defineProperty(OAuthUtilityContext.prototype, "webUrl", {
          get: function () {
              return '';
          },
          enumerable: true,
          configurable: true
      });
      OAuthUtilityContext.prototype.fetchWithDigest = function (request) {
          var _this = this;
          return request.blob().then(function (requestBody) {
              return _this._spHttpClient.fetch(request.url, SPHttpClient_1.default.configurations.v1, {
                  method: request.method,
                  headers: request.headers,
                  body: requestBody
              });
          });
      };
      OAuthUtilityContext.prototype.qosMonitor = function () {
          return new sp_telemetry_1._QosMonitor(OAuthUtilityContext.qosName);
      };
      OAuthUtilityContext.qosName = 'OAuthTokenProvider';
      return OAuthUtilityContext;
  }());
  exports.default = OAuthUtilityContext;
  