msal
Version:
Microsoft Authentication Library for js
62 lines • 2.48 kB
JavaScript
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import * as tslib_1 from "tslib";
import { Authority, AuthorityType } from "./Authority";
import { XhrClient } from "./XHRClient";
import { AADTrustedHostList } from "./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 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();
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 AADTrustedHostList[host.toLowerCase()];
};
AadAuthority.AadInstanceDiscoveryEndpoint = "https://login.microsoftonline.com/common/discovery/instance";
return AadAuthority;
}(Authority));
export { AadAuthority };
//# sourceMappingURL=AadAuthority.js.map