Estructura inicial del proyecto

This commit is contained in:
2026-06-02 16:57:08 +00:00
commit 8b306b9afc
9864 changed files with 1435687 additions and 0 deletions

View File

@ -0,0 +1,31 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
import { AuthError } from "@azure/msal-common/browser";
import * as BrowserAuthErrorCodes from "./BrowserAuthErrorCodes.js";
export { BrowserAuthErrorCodes }; // Allow importing as "BrowserAuthErrorCodes"
export function getDefaultErrorMessage(code: string): string {
return `See https://aka.ms/msal.js.errors#${code} for details`;
}
/**
* Browser library error class thrown by the MSAL.js library for SPAs
*/
export class BrowserAuthError extends AuthError {
constructor(errorCode: string, subError?: string) {
super(errorCode, getDefaultErrorMessage(errorCode), subError);
Object.setPrototypeOf(this, BrowserAuthError.prototype);
this.name = "BrowserAuthError";
}
}
export function createBrowserAuthError(
errorCode: string,
subError?: string
): BrowserAuthError {
return new BrowserAuthError(errorCode, subError);
}

View File

@ -0,0 +1,65 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
export const pkceNotCreated = "pkce_not_created";
export const earJwkEmpty = "ear_jwk_empty";
export const earJweEmpty = "ear_jwe_empty";
export const cryptoNonExistent = "crypto_nonexistent";
export const emptyNavigateUri = "empty_navigate_uri";
export const hashEmptyError = "hash_empty_error";
export const noStateInHash = "no_state_in_hash";
export const hashDoesNotContainKnownProperties =
"hash_does_not_contain_known_properties";
export const unableToParseState = "unable_to_parse_state";
export const stateInteractionTypeMismatch = "state_interaction_type_mismatch";
export const interactionInProgress = "interaction_in_progress";
export const interactionInProgressCancelled =
"interaction_in_progress_cancelled";
export const popupWindowError = "popup_window_error";
export const emptyWindowError = "empty_window_error";
export const userCancelled = "user_cancelled";
export const redirectBridgeEmptyResponse = "redirect_bridge_empty_response";
export const redirectInIframe = "redirect_in_iframe";
export const blockIframeReload = "block_iframe_reload";
export const blockNestedPopups = "block_nested_popups";
export const iframeClosedPrematurely = "iframe_closed_prematurely";
export const silentLogoutUnsupported = "silent_logout_unsupported";
export const noAccountError = "no_account_error";
export const silentPromptValueError = "silent_prompt_value_error";
export const noTokenRequestCacheError = "no_token_request_cache_error";
export const unableToParseTokenRequestCacheError =
"unable_to_parse_token_request_cache_error";
export const authRequestNotSetError = "auth_request_not_set_error";
export const invalidCacheType = "invalid_cache_type";
export const nonBrowserEnvironment = "non_browser_environment";
export const databaseNotOpen = "database_not_open";
export const noNetworkConnectivity = "no_network_connectivity";
export const postRequestFailed = "post_request_failed";
export const getRequestFailed = "get_request_failed";
export const failedToParseResponse = "failed_to_parse_response";
export const unableToLoadToken = "unable_to_load_token";
export const cryptoKeyNotFound = "crypto_key_not_found";
export const authCodeRequired = "auth_code_required";
export const authCodeOrNativeAccountIdRequired =
"auth_code_or_nativeAccountId_required";
export const spaCodeAndNativeAccountIdPresent =
"spa_code_and_nativeAccountId_present";
export const databaseUnavailable = "database_unavailable";
export const unableToAcquireTokenFromNativePlatform =
"unable_to_acquire_token_from_native_platform";
export const nativeHandshakeTimeout = "native_handshake_timeout";
export const nativeExtensionNotInstalled = "native_extension_not_installed";
export const nativeConnectionNotEstablished =
"native_connection_not_established";
export const uninitializedPublicClientApplication =
"uninitialized_public_client_application";
export const nativePromptNotSupported = "native_prompt_not_supported";
export const invalidBase64String = "invalid_base64_string";
export const invalidPopTokenRequest = "invalid_pop_token_request";
export const failedToBuildHeaders = "failed_to_build_headers";
export const failedToParseHeaders = "failed_to_parse_headers";
export const failedToDecryptEarResponse = "failed_to_decrypt_ear_response";
export const timedOut = "timed_out";
export const emptyResponse = "empty_response";

View File

@ -0,0 +1,29 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
import { AuthError } from "@azure/msal-common/browser";
import * as BrowserConfigurationAuthErrorCodes from "./BrowserConfigurationAuthErrorCodes.js";
import { getDefaultErrorMessage } from "./BrowserAuthError.js";
export { BrowserConfigurationAuthErrorCodes };
/**
* Browser library error class thrown by the MSAL.js library for SPAs
*/
export class BrowserConfigurationAuthError extends AuthError {
constructor(errorCode: string, errorMessage?: string) {
super(errorCode, errorMessage);
this.name = "BrowserConfigurationAuthError";
Object.setPrototypeOf(this, BrowserConfigurationAuthError.prototype);
}
}
export function createBrowserConfigurationAuthError(
errorCode: string
): BrowserConfigurationAuthError {
return new BrowserConfigurationAuthError(
errorCode,
getDefaultErrorMessage(errorCode)
);
}

View File

@ -0,0 +1,9 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
export const storageNotSupported = "storage_not_supported";
export const stubbedPublicClientApplicationCalled =
"stubbed_public_client_application_called";
export const inMemRedirectUnavailable = "in_mem_redirect_unavailable";

View File

@ -0,0 +1,110 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
import {
AuthError,
InteractionRequiredAuthError,
InteractionRequiredAuthErrorCodes,
createInteractionRequiredAuthError,
} from "@azure/msal-common/browser";
import {
createBrowserAuthError,
BrowserAuthErrorCodes,
getDefaultErrorMessage,
} from "./BrowserAuthError.js";
import * as NativeAuthErrorCodes from "./NativeAuthErrorCodes.js";
import * as NativeStatusCodes from "../broker/nativeBroker/NativeStatusCodes.js";
export { NativeAuthErrorCodes };
export type OSError = {
error?: number;
protocol_error?: string;
properties?: object;
status?: string;
retryable?: boolean;
};
const INVALID_METHOD_ERROR = -2147186943;
export class NativeAuthError extends AuthError {
ext: OSError | undefined;
constructor(errorCode: string, description?: string, ext?: OSError) {
super(errorCode, description || getDefaultErrorMessage(errorCode));
Object.setPrototypeOf(this, NativeAuthError.prototype);
this.name = "NativeAuthError";
this.ext = ext;
}
}
/**
* These errors should result in a fallback to the 'standard' browser based auth flow.
*/
export function isFatalNativeAuthError(error: NativeAuthError): boolean {
if (
error.ext &&
error.ext.status &&
error.ext.status === NativeStatusCodes.DISABLED
) {
return true;
}
if (
error.ext &&
error.ext.error &&
error.ext.error === INVALID_METHOD_ERROR
) {
return true;
}
switch (error.errorCode) {
case NativeAuthErrorCodes.contentError:
case NativeAuthErrorCodes.pageException:
return true;
default:
return false;
}
}
/**
* Create the appropriate error object based on the WAM status code.
* @param code
* @param description
* @param ext
* @returns
*/
export function createNativeAuthError(
code: string,
description?: string,
ext?: OSError
): AuthError {
if (ext && ext.status) {
switch (ext.status) {
case NativeStatusCodes.ACCOUNT_UNAVAILABLE:
return createInteractionRequiredAuthError(
InteractionRequiredAuthErrorCodes.nativeAccountUnavailable,
getDefaultErrorMessage(code)
);
case NativeStatusCodes.USER_INTERACTION_REQUIRED:
return new InteractionRequiredAuthError(code, description);
case NativeStatusCodes.USER_CANCEL:
return createBrowserAuthError(
BrowserAuthErrorCodes.userCancelled
);
case NativeStatusCodes.NO_NETWORK:
return createBrowserAuthError(
BrowserAuthErrorCodes.noNetworkConnectivity
);
case NativeStatusCodes.UX_NOT_ALLOWED:
return createInteractionRequiredAuthError(
InteractionRequiredAuthErrorCodes.uxNotAllowed
);
}
}
return new NativeAuthError(code, description, ext);
}

View File

@ -0,0 +1,9 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
export const contentError = "ContentError";
export const pageException = "PageException";
export const userSwitch = "user_switch";
export const unsupportedMethod = "unsupported_method";

View File

@ -0,0 +1,20 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
import { AuthError } from "@azure/msal-common/browser";
import { unsupportedMethod } from "./NativeAuthErrorCodes.js";
export class NestedAppAuthError extends AuthError {
constructor(errorCode: string, errorMessage?: string) {
super(errorCode, errorMessage);
Object.setPrototypeOf(this, NestedAppAuthError.prototype);
this.name = "NestedAppAuthError";
}
public static createUnsupportedError(): NestedAppAuthError {
return new NestedAppAuthError(unsupportedMethod);
}
}