msal
Version:
Microsoft Authentication Library for js
175 lines • 9.89 kB
JavaScript
;
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var AuthError_1 = require("./AuthError");
var StringUtils_1 = require("../utils/StringUtils");
exports.ClientAuthErrorMessage = {
multipleMatchingTokens: {
code: "multiple_matching_tokens",
desc: "The cache contains multiple tokens satisfying the requirements. " +
"Call AcquireToken again providing more requirements like authority."
},
multipleCacheAuthorities: {
code: "multiple_authorities",
desc: "Multiple authorities found in the cache. Pass authority in the API overload."
},
endpointResolutionError: {
code: "endpoints_resolution_error",
desc: "Error: could not resolve endpoints. Please check network and try again."
},
popUpWindowError: {
code: "popup_window_error",
desc: "Error opening popup window. This can happen if you are using IE or if popups are blocked in the browser."
},
tokenRenewalError: {
code: "token_renewal_error",
desc: "Token renewal operation failed due to timeout."
},
invalidIdToken: {
code: "invalid_id_token",
desc: "Invalid ID token format."
},
invalidStateError: {
code: "invalid_state_error",
desc: "Invalid state."
},
nonceMismatchError: {
code: "nonce_mismatch_error",
desc: "Nonce is not matching, Nonce received: "
},
loginProgressError: {
code: "login_progress_error",
desc: "Login_In_Progress: Error during login call - login is already in progress."
},
acquireTokenProgressError: {
code: "acquiretoken_progress_error",
desc: "AcquireToken_In_Progress: Error during login call - login is already in progress."
},
userCancelledError: {
code: "user_cancelled",
desc: "User cancelled the flow."
},
callbackError: {
code: "callback_error",
desc: "Error occurred in token received callback function."
},
userLoginRequiredError: {
code: "user_login_error",
desc: "User login is required."
},
userDoesNotExistError: {
code: "user_non_existent",
desc: "User object does not exist. Please call a login API."
},
clientInfoDecodingError: {
code: "client_info_decoding_error",
desc: "The client info could not be parsed/decoded correctly. Please review the trace to determine the root cause."
},
clientInfoNotPopulatedError: {
code: "client_info_not_populated_error",
desc: "The service did not populate client_info in the response, Please verify with the service team"
},
nullOrEmptyIdToken: {
code: "null_or_empty_id_token",
desc: "The idToken is null or empty. Please review the trace to determine the root cause."
},
idTokenNotParsed: {
code: "id_token_parsing_error",
desc: "ID token cannot be parsed. Please review stack trace to determine root cause."
},
tokenEncodingError: {
code: "token_encoding_error",
desc: "The token to be decoded is not encoded correctly."
},
invalidInteractionType: {
code: "invalid_interaction_type",
desc: "The interaction type passed to the handler was incorrect or unknown"
}
};
/**
* Error thrown when there is an error in the client code running on the browser.
*/
var ClientAuthError = /** @class */ (function (_super) {
tslib_1.__extends(ClientAuthError, _super);
function ClientAuthError(errorCode, errorMessage) {
var _this = _super.call(this, errorCode, errorMessage) || this;
_this.name = "ClientAuthError";
Object.setPrototypeOf(_this, ClientAuthError.prototype);
return _this;
}
ClientAuthError.createEndpointResolutionError = function (errDetail) {
var errorMessage = exports.ClientAuthErrorMessage.endpointResolutionError.desc;
if (errDetail && !StringUtils_1.StringUtils.isEmpty(errDetail)) {
errorMessage += " Details: " + errDetail;
}
return new ClientAuthError(exports.ClientAuthErrorMessage.endpointResolutionError.code, errorMessage);
};
ClientAuthError.createMultipleMatchingTokensInCacheError = function (scope) {
return new ClientAuthError(exports.ClientAuthErrorMessage.multipleMatchingTokens.code, "Cache error for scope " + scope + ": " + exports.ClientAuthErrorMessage.multipleMatchingTokens.desc + ".");
};
ClientAuthError.createMultipleAuthoritiesInCacheError = function (scope) {
return new ClientAuthError(exports.ClientAuthErrorMessage.multipleCacheAuthorities.code, "Cache error for scope " + scope + ": " + exports.ClientAuthErrorMessage.multipleCacheAuthorities.desc + ".");
};
ClientAuthError.createPopupWindowError = function (errDetail) {
var errorMessage = exports.ClientAuthErrorMessage.popUpWindowError.desc;
if (errDetail && !StringUtils_1.StringUtils.isEmpty(errDetail)) {
errorMessage += " Details: " + errDetail;
}
return new ClientAuthError(exports.ClientAuthErrorMessage.popUpWindowError.code, errorMessage);
};
ClientAuthError.createTokenRenewalTimeoutError = function () {
return new ClientAuthError(exports.ClientAuthErrorMessage.tokenRenewalError.code, exports.ClientAuthErrorMessage.tokenRenewalError.desc);
};
ClientAuthError.createInvalidIdTokenError = function (idToken) {
return new ClientAuthError(exports.ClientAuthErrorMessage.invalidIdToken.code, exports.ClientAuthErrorMessage.invalidIdToken.desc + " Given token: " + idToken);
};
//TODO: Is this not a security flaw to send the user the state expected??
ClientAuthError.createInvalidStateError = function (invalidState, actualState) {
return new ClientAuthError(exports.ClientAuthErrorMessage.invalidStateError.code, exports.ClientAuthErrorMessage.invalidStateError.desc + " " + invalidState + ", state expected : " + actualState + ".");
};
//TODO: Is this not a security flaw to send the user the Nonce expected??
ClientAuthError.createNonceMismatchError = function (invalidNonce, actualNonce) {
return new ClientAuthError(exports.ClientAuthErrorMessage.nonceMismatchError.code, exports.ClientAuthErrorMessage.nonceMismatchError.desc + " " + invalidNonce + ", nonce expected : " + actualNonce + ".");
};
ClientAuthError.createLoginInProgressError = function () {
return new ClientAuthError(exports.ClientAuthErrorMessage.loginProgressError.code, exports.ClientAuthErrorMessage.loginProgressError.desc);
};
ClientAuthError.createAcquireTokenInProgressError = function () {
return new ClientAuthError(exports.ClientAuthErrorMessage.acquireTokenProgressError.code, exports.ClientAuthErrorMessage.acquireTokenProgressError.desc);
};
ClientAuthError.createUserCancelledError = function () {
return new ClientAuthError(exports.ClientAuthErrorMessage.userCancelledError.code, exports.ClientAuthErrorMessage.userCancelledError.desc);
};
ClientAuthError.createErrorInCallbackFunction = function (errorDesc) {
return new ClientAuthError(exports.ClientAuthErrorMessage.callbackError.code, exports.ClientAuthErrorMessage.callbackError.desc + " " + errorDesc + ".");
};
ClientAuthError.createUserLoginRequiredError = function () {
return new ClientAuthError(exports.ClientAuthErrorMessage.userLoginRequiredError.code, exports.ClientAuthErrorMessage.userLoginRequiredError.desc);
};
ClientAuthError.createUserDoesNotExistError = function () {
return new ClientAuthError(exports.ClientAuthErrorMessage.userDoesNotExistError.code, exports.ClientAuthErrorMessage.userDoesNotExistError.desc);
};
ClientAuthError.createClientInfoDecodingError = function (caughtError) {
return new ClientAuthError(exports.ClientAuthErrorMessage.clientInfoDecodingError.code, exports.ClientAuthErrorMessage.clientInfoDecodingError.desc + " Failed with error: " + caughtError);
};
ClientAuthError.createClientInfoNotPopulatedError = function (caughtError) {
return new ClientAuthError(exports.ClientAuthErrorMessage.clientInfoNotPopulatedError.code, exports.ClientAuthErrorMessage.clientInfoNotPopulatedError.desc + " Failed with error: " + caughtError);
};
ClientAuthError.createIdTokenNullOrEmptyError = function (invalidRawTokenString) {
return new ClientAuthError(exports.ClientAuthErrorMessage.nullOrEmptyIdToken.code, exports.ClientAuthErrorMessage.nullOrEmptyIdToken.desc + " Raw ID Token Value: " + invalidRawTokenString);
};
ClientAuthError.createIdTokenParsingError = function (caughtParsingError) {
return new ClientAuthError(exports.ClientAuthErrorMessage.idTokenNotParsed.code, exports.ClientAuthErrorMessage.idTokenNotParsed.desc + " Failed with error: " + caughtParsingError);
};
ClientAuthError.createTokenEncodingError = function (incorrectlyEncodedToken) {
return new ClientAuthError(exports.ClientAuthErrorMessage.tokenEncodingError.code, exports.ClientAuthErrorMessage.tokenEncodingError.desc + " Attempted to decode: " + incorrectlyEncodedToken);
};
ClientAuthError.createInvalidInteractionTypeError = function () {
return new ClientAuthError(exports.ClientAuthErrorMessage.invalidInteractionType.code, exports.ClientAuthErrorMessage.invalidInteractionType.desc);
};
return ClientAuthError;
}(AuthError_1.AuthError));
exports.ClientAuthError = ClientAuthError;
//# sourceMappingURL=ClientAuthError.js.map