UNPKG

msal

Version:
64 lines 2.59 kB
"use strict"; // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var Authority_1 = require("./Authority"); var XHRClient_1 = require("./XHRClient"); var Constants_1 = require("./utils/Constants"); /** * @hidden */ var AadAuthority = /** @class */ (function (_super) { tslib_1.__extends(AadAuthority, _super); function AadAuthority(authority, validateAuthority) { return _super.call(this, authority, validateAuthority) || this; } Object.defineProperty(AadAuthority.prototype, "AadInstanceDiscoveryEndpointUrl", { get: function () { return AadAuthority.AadInstanceDiscoveryEndpoint + "?api-version=1.0&authorization_endpoint=" + this.CanonicalAuthority + "oauth2/v2.0/authorize"; }, enumerable: true, configurable: true }); Object.defineProperty(AadAuthority.prototype, "AuthorityType", { get: function () { return Authority_1.AuthorityType.Aad; }, enumerable: true, configurable: true }); /** * Returns a promise which resolves to the OIDC endpoint * Only responds with the endpoint */ AadAuthority.prototype.GetOpenIdConfigurationEndpointAsync = function () { var _this = this; var resultPromise = new Promise(function (resolve, reject) { return resolve(_this.DefaultOpenIdConfigurationEndpoint); }); if (!this.IsValidationEnabled) { return resultPromise; } var host = this.CanonicalAuthorityUrlComponents.HostNameAndPort; if (this.IsInTrustedHostList(host)) { return resultPromise; } var client = new XHRClient_1.XhrClient(); return client.sendRequestAsync(this.AadInstanceDiscoveryEndpointUrl, "GET", true) .then(function (response) { return response.tenant_discovery_endpoint; }); }; /** * Checks to see if the host is in a list of trusted hosts * @param {string} The host to look up */ AadAuthority.prototype.IsInTrustedHostList = function (host) { return Constants_1.AADTrustedHostList[host.toLowerCase()]; }; AadAuthority.AadInstanceDiscoveryEndpoint = "https://login.microsoftonline.com/common/discovery/instance"; return AadAuthority; }(Authority_1.Authority)); exports.AadAuthority = AadAuthority; //# sourceMappingURL=AadAuthority.js.map