mirror of
https://github.com/MeowLynxSea/Proksea.git
synced 2025-07-10 19:34:41 +00:00
97 lines
4.1 KiB
JavaScript
97 lines
4.1 KiB
JavaScript
/*! @azure/msal-common v14.12.0 2024-06-10 */
|
|
'use strict';
|
|
import { Constants } from '../utils/Constants.mjs';
|
|
import { AuthError } from './AuthError.mjs';
|
|
import { noTokensFound, nativeAccountUnavailable, badToken, refreshTokenExpired, interactionRequired, consentRequired, loginRequired } from './InteractionRequiredAuthErrorCodes.mjs';
|
|
import * as InteractionRequiredAuthErrorCodes from './InteractionRequiredAuthErrorCodes.mjs';
|
|
export { InteractionRequiredAuthErrorCodes };
|
|
|
|
/*
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the MIT License.
|
|
*/
|
|
/**
|
|
* InteractionRequiredServerErrorMessage contains string constants used by error codes and messages returned by the server indicating interaction is required
|
|
*/
|
|
const InteractionRequiredServerErrorMessage = [
|
|
interactionRequired,
|
|
consentRequired,
|
|
loginRequired,
|
|
badToken,
|
|
];
|
|
const InteractionRequiredAuthSubErrorMessage = [
|
|
"message_only",
|
|
"additional_action",
|
|
"basic_action",
|
|
"user_password_expired",
|
|
"consent_required",
|
|
"bad_token",
|
|
];
|
|
const InteractionRequiredAuthErrorMessages = {
|
|
[noTokensFound]: "No refresh token found in the cache. Please sign-in.",
|
|
[nativeAccountUnavailable]: "The requested account is not available in the native broker. It may have been deleted or logged out. Please sign-in again using an interactive API.",
|
|
[refreshTokenExpired]: "Refresh token has expired.",
|
|
[badToken]: "Identity provider returned bad_token due to an expired or invalid refresh token. Please invoke an interactive API to resolve.",
|
|
};
|
|
/**
|
|
* Interaction required errors defined by the SDK
|
|
* @deprecated Use InteractionRequiredAuthErrorCodes instead
|
|
*/
|
|
const InteractionRequiredAuthErrorMessage = {
|
|
noTokensFoundError: {
|
|
code: noTokensFound,
|
|
desc: InteractionRequiredAuthErrorMessages[noTokensFound],
|
|
},
|
|
native_account_unavailable: {
|
|
code: nativeAccountUnavailable,
|
|
desc: InteractionRequiredAuthErrorMessages[nativeAccountUnavailable],
|
|
},
|
|
bad_token: {
|
|
code: badToken,
|
|
desc: InteractionRequiredAuthErrorMessages[badToken],
|
|
},
|
|
};
|
|
/**
|
|
* Error thrown when user interaction is required.
|
|
*/
|
|
class InteractionRequiredAuthError extends AuthError {
|
|
constructor(errorCode, errorMessage, subError, timestamp, traceId, correlationId, claims, errorNo) {
|
|
super(errorCode, errorMessage, subError);
|
|
Object.setPrototypeOf(this, InteractionRequiredAuthError.prototype);
|
|
this.timestamp = timestamp || Constants.EMPTY_STRING;
|
|
this.traceId = traceId || Constants.EMPTY_STRING;
|
|
this.correlationId = correlationId || Constants.EMPTY_STRING;
|
|
this.claims = claims || Constants.EMPTY_STRING;
|
|
this.name = "InteractionRequiredAuthError";
|
|
this.errorNo = errorNo;
|
|
}
|
|
}
|
|
/**
|
|
* Helper function used to determine if an error thrown by the server requires interaction to resolve
|
|
* @param errorCode
|
|
* @param errorString
|
|
* @param subError
|
|
*/
|
|
function isInteractionRequiredError(errorCode, errorString, subError) {
|
|
const isInteractionRequiredErrorCode = !!errorCode &&
|
|
InteractionRequiredServerErrorMessage.indexOf(errorCode) > -1;
|
|
const isInteractionRequiredSubError = !!subError &&
|
|
InteractionRequiredAuthSubErrorMessage.indexOf(subError) > -1;
|
|
const isInteractionRequiredErrorDesc = !!errorString &&
|
|
InteractionRequiredServerErrorMessage.some((irErrorCode) => {
|
|
return errorString.indexOf(irErrorCode) > -1;
|
|
});
|
|
return (isInteractionRequiredErrorCode ||
|
|
isInteractionRequiredErrorDesc ||
|
|
isInteractionRequiredSubError);
|
|
}
|
|
/**
|
|
* Creates an InteractionRequiredAuthError
|
|
*/
|
|
function createInteractionRequiredAuthError(errorCode) {
|
|
return new InteractionRequiredAuthError(errorCode, InteractionRequiredAuthErrorMessages[errorCode]);
|
|
}
|
|
|
|
export { InteractionRequiredAuthError, InteractionRequiredAuthErrorMessage, InteractionRequiredAuthSubErrorMessage, InteractionRequiredServerErrorMessage, createInteractionRequiredAuthError, isInteractionRequiredError };
|
|
//# sourceMappingURL=InteractionRequiredAuthError.mjs.map
|