text: "use strict";
  /*
    * Copyright (c) Microsoft Corporation
    *  All Rights Reserved
    *  MIT License
    *
    * Permission is hereby granted, free of charge, to any person obtaining a copy of this
    * software and associated documentation files (the "Software"), to deal in the Software
    * without restriction, including without limitation the rights to use, copy, modify,
    * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
    * permit persons to whom the Software is furnished to do so, subject to the following
    * conditions:
    *
    * The above copyright notice and this permission notice shall be
    * included in all copies or substantial portions of the Software.
    *
    * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
    * OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
    * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
    * OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    */
  Object.defineProperty(exports, "__esModule", { value: true });
  var Utils_1 = require("./Utils");
  /*
   * @hidden
   */
  var IdToken = /** @class */ (function () {
      function IdToken(rawIdToken) {
          if (Utils_1.Utils.isEmpty(rawIdToken)) {
              throw new Error("null or empty raw idtoken");
          }
          try {
              this.rawIdToken = rawIdToken;
              this.decodedIdToken = Utils_1.Utils.extractIdToken(rawIdToken);
              if (this.decodedIdToken) {
                  if (this.decodedIdToken.hasOwnProperty("iss")) {
                      this.issuer = this.decodedIdToken["iss"];
                  }
                  if (this.decodedIdToken.hasOwnProperty("oid")) {
                      this.objectId = this.decodedIdToken['oid'];
                  }
                  if (this.decodedIdToken.hasOwnProperty("sub")) {
                      this.subject = this.decodedIdToken["sub"];
                  }
                  if (this.decodedIdToken.hasOwnProperty("tid")) {
                      this.tenantId = this.decodedIdToken["tid"];
                  }
                  if (this.decodedIdToken.hasOwnProperty("ver")) {
                      this.version = this.decodedIdToken["ver"];
                  }
                  if (this.decodedIdToken.hasOwnProperty("preferred_username")) {
                      this.preferredName = this.decodedIdToken["preferred_username"];
                  }
                  if (this.decodedIdToken.hasOwnProperty("name")) {
                      this.name = this.decodedIdToken["name"];
                  }
                  if (this.decodedIdToken.hasOwnProperty("nonce")) {
                      this.nonce = this.decodedIdToken["nonce"];
                  }
                  if (this.decodedIdToken.hasOwnProperty("exp")) {
                      this.expiration = this.decodedIdToken["exp"];
                  }
                  if (this.decodedIdToken.hasOwnProperty("home_oid")) {
                      this.homeObjectId = this.decodedIdToken["home_oid"];
                  }
                  if (this.decodedIdToken.hasOwnProperty("sid")) {
                      this.sid = this.decodedIdToken["sid"];
                  }
              }
          }
          catch (e) {
              throw new Error("Failed to parse the returned id token");
          }
      }
      return IdToken;
  }());
  exports.IdToken = IdToken;
  //# sourceMappingURL=IdToken.js.map