msal
Version:
Microsoft Authentication Library for js
52 lines • 2.16 kB
JavaScript
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import * as tslib_1 from "tslib";
import { AadAuthority } from "./AadAuthority";
import { AuthorityType } from "./Authority";
import { ClientConfigurationErrorMessage } from "./error/ClientConfigurationError";
import { UrlUtils } from "./utils/UrlUtils";
/**
* @hidden
*/
var B2cAuthority = /** @class */ (function (_super) {
tslib_1.__extends(B2cAuthority, _super);
function B2cAuthority(authority, validateAuthority) {
var _this = _super.call(this, authority, validateAuthority) || this;
var urlComponents = UrlUtils.GetUrlComponents(authority);
var pathSegments = urlComponents.PathSegments;
if (pathSegments.length < 3) {
throw ClientConfigurationErrorMessage.b2cAuthorityUriInvalidPath;
}
_this.CanonicalAuthority = "https://" + urlComponents.HostNameAndPort + "/" + pathSegments[0] + "/" + pathSegments[1] + "/" + pathSegments[2] + "/";
return _this;
}
Object.defineProperty(B2cAuthority.prototype, "AuthorityType", {
get: function () {
return AuthorityType.B2C;
},
enumerable: true,
configurable: true
});
/**
* Returns a promise with the TenantDiscoveryEndpoint
*/
B2cAuthority.prototype.GetOpenIdConfigurationEndpointAsync = function () {
var _this = this;
var resultPromise = new Promise(function (resolve, reject) {
return resolve(_this.DefaultOpenIdConfigurationEndpoint);
});
if (!this.IsValidationEnabled) {
return resultPromise;
}
if (this.IsInTrustedHostList(this.CanonicalAuthorityUrlComponents.HostNameAndPort)) {
return resultPromise;
}
return new Promise(function (resolve, reject) {
return reject(ClientConfigurationErrorMessage.unsupportedAuthorityValidation);
});
};
B2cAuthority.B2C_PREFIX = "tfp";
return B2cAuthority;
}(AadAuthority));
export { B2cAuthority };
//# sourceMappingURL=B2cAuthority.js.map