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,34 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
import { CommonAuthorizationCodeRequest } from "@azure/msal-common/browser";
/**
* AuthorizationCodeRequest: Request object passed by browser clients to exchange an authorization code for tokens.
*/
export type AuthorizationCodeRequest = Partial<
Omit<CommonAuthorizationCodeRequest, "code" | "enableSpaAuthorizationCode">
> & {
/**
* The authorization_code that the user acquired in the first leg of the flow.
*/
code?: string;
/**
* Identifier for the native account when integrating with native or brokered experiences.
*/
nativeAccountId?: string;
/**
* Hostname for the Microsoft Cloud instance's Graph endpoint (for example, graph.microsoft.com).
*/
cloudGraphHostName?: string;
/**
* Hostname for the Microsoft Graph endpoint when overriding defaults.
*/
msGraphHost?: string;
/**
* Hostname for the Azure AD cloud instance that issued the authorization code.
*/
cloudInstanceHostName?: string;
};

View File

@ -0,0 +1,20 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
import { AccountInfo } from "@azure/msal-common/browser";
/**
* ClearCacheRequest
*/
export type ClearCacheRequest = {
/**
* Unique GUID set per request to trace a request end-to-end for telemetry purposes.
*/
correlationId?: string;
/**
* Account object that will be logged out of. All tokens tied to this account will be cleared.
*/
account?: AccountInfo | null;
};

View File

@ -0,0 +1,29 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
import { CommonEndSessionRequest } from "@azure/msal-common/browser";
import { PopupWindowAttributes } from "./PopupWindowAttributes.js";
/**
* EndSessionPopupRequest
*/
export type EndSessionPopupRequest = Partial<CommonEndSessionRequest> & {
/**
* Authority to send logout request to.
*/
authority?: string;
/**
* URI to navigate the main window to after logout is complete
*/
mainWindowRedirectUri?: string;
/**
* Optional popup window attributes. popupSize with height and width, and popupPosition with top and left can be set.
*/
popupWindowAttributes?: PopupWindowAttributes;
/**
* Optional window object to use as the parent when opening popup windows. Uses global `window` if not given.
*/
popupWindowParent?: Window;
};

View File

@ -0,0 +1,16 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
import { CommonEndSessionRequest } from "@azure/msal-common/browser";
/**
* EndSessionRequest
*/
export type EndSessionRequest = Partial<CommonEndSessionRequest> & {
/**
* Authority to send logout request.
*/
authority?: string;
};

View File

@ -0,0 +1,9 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
export type HandleRedirectPromiseOptions = {
hash?: string;
navigateToLoginRequestUrl?: boolean;
};

View File

@ -0,0 +1,14 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
/**
* InitializeApplicationRequest: Request object passed by user to initialize application
*/
export type InitializeApplicationRequest = {
/**
* Unique GUID set per request to trace a request end-to-end for telemetry purposes.
*/
correlationId?: string;
};

View File

@ -0,0 +1,41 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
import { CommonAuthorizationUrlRequest } from "@azure/msal-common/browser";
import { PopupWindowAttributes } from "./PopupWindowAttributes.js";
/**
* PopupRequest: Request object passed by user to retrieve a Code from the
* server (first leg of authorization code grant flow) with a popup window.
*/
export type PopupRequest = Partial<
Omit<
CommonAuthorizationUrlRequest,
| "responseMode"
| "scopes"
| "earJwk"
| "codeChallenge"
| "codeChallengeMethod"
| "platformBroker"
>
> & {
/**
* Array of scopes the application is requesting access to.
*/
scopes: Array<string>;
/**
* Optional popup window attributes. popupSize with height and width, and popupPosition with top and left can be set.
*/
popupWindowAttributes?: PopupWindowAttributes;
/**
* Optional window object to use as the parent when opening popup windows. Uses global `window` if not given.
*/
popupWindowParent?: Window;
/**
* Optional flag to allow overriding an existing interaction_in_progress state for popup flows. **WARNING**: Use with caution! For usage details and examples, see the [login-user.md](../../../docs/login-user.md#handling-interaction_in_progress-errors) documentation.
*/
overrideInteractionInProgress?: boolean;
};

View File

@ -0,0 +1,22 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
/**
* Popup configurations for setting dimensions and position of popup window
*/
export type PopupWindowAttributes = {
popupSize?: PopupSize;
popupPosition?: PopupPosition;
};
export type PopupSize = {
height: number;
width: number;
};
export type PopupPosition = {
top: number;
left: number;
};

View File

@ -0,0 +1,31 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
import { CommonAuthorizationUrlRequest } from "@azure/msal-common/browser";
/**
* RedirectRequest: Request object passed by user to retrieve a Code from the
* server (first leg of authorization code grant flow) with a full page redirect.
*/
export type RedirectRequest = Partial<
Omit<
CommonAuthorizationUrlRequest,
| "responseMode"
| "scopes"
| "earJwk"
| "codeChallenge"
| "codeChallengeMethod"
| "platformBroker"
>
> & {
/**
* Array of scopes the application is requesting access to.
*/
scopes: Array<string>;
/**
* The page that should be returned to after loginRedirect or acquireTokenRedirect. This should only be used if this is different from the redirectUri and will default to the page that initiates the request. When the navigateToLoginRequestUrl config option is set to false this parameter will be ignored.
*/
redirectStartPage?: string;
};

View File

@ -0,0 +1,134 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
import {
AccountInfo,
Constants,
BaseAuthRequest,
ClientConfigurationErrorCodes,
CommonSilentFlowRequest,
IPerformanceClient,
Logger,
ProtocolMode,
createClientConfigurationError,
invokeAsync,
} from "@azure/msal-common/browser";
import * as BrowserPerformanceEvents from "../telemetry/BrowserPerformanceEvents.js";
import { BrowserConfiguration } from "../config/Configuration.js";
import { SilentRequest } from "./SilentRequest.js";
import { PopupRequest } from "./PopupRequest.js";
import { RedirectRequest } from "./RedirectRequest.js";
/**
* Initializer function for all request APIs
* @param request
* @param config
* @param performanceClient
* @param logger
* @param correlationId
*/
export async function initializeBaseRequest(
request: Partial<BaseAuthRequest> & { correlationId: string },
config: BrowserConfiguration,
performanceClient: IPerformanceClient,
logger: Logger,
correlationId: string
): Promise<BaseAuthRequest> {
const authority = request.authority || config.auth.authority;
const scopes = [...((request && request.scopes) || [])];
const validatedRequest: BaseAuthRequest = {
...request,
correlationId: request.correlationId,
authority,
scopes,
};
// Set authenticationScheme to BEARER if not explicitly set in the request
if (!validatedRequest.authenticationScheme) {
validatedRequest.authenticationScheme =
Constants.AuthenticationScheme.BEARER;
logger.verbose(
'Authentication Scheme was not explicitly set in request, defaulting to "Bearer" request',
correlationId
);
} else {
if (
validatedRequest.authenticationScheme ===
Constants.AuthenticationScheme.SSH
) {
if (!request.sshJwk) {
throw createClientConfigurationError(
ClientConfigurationErrorCodes.missingSshJwk
);
}
if (!request.sshKid) {
throw createClientConfigurationError(
ClientConfigurationErrorCodes.missingSshKid
);
}
}
logger.verbose(
`Authentication Scheme set to "'${validatedRequest.authenticationScheme}'" as configured in Auth request`,
correlationId
);
}
return validatedRequest;
}
export async function initializeSilentRequest(
request: SilentRequest & { correlationId: string },
account: AccountInfo,
config: BrowserConfiguration,
performanceClient: IPerformanceClient,
logger: Logger
): Promise<CommonSilentFlowRequest> {
const baseRequest = await invokeAsync(
initializeBaseRequest,
BrowserPerformanceEvents.InitializeBaseRequest,
logger,
performanceClient,
request.correlationId
)(request, config, performanceClient, logger, request.correlationId);
return {
...request,
...baseRequest,
account: account,
forceRefresh: request.forceRefresh || false,
};
}
/**
* Validates that the combination of request method, protocol mode and authorize body parameters is correct.
* Returns the validated or defaulted HTTP method or throws if the configured combination is invalid.
* @param interactionRequest
* @param protocolMode
* @returns
*/
export function validateRequestMethod(
interactionRequest: BaseAuthRequest | PopupRequest | RedirectRequest,
protocolMode: ProtocolMode
): Constants.HttpMethod {
let httpMethod: Constants.HttpMethod | undefined;
const requestMethod = interactionRequest.httpMethod;
if (protocolMode === ProtocolMode.EAR) {
// Validate that method can only be POST when protocol mode is EAR
if (requestMethod && requestMethod !== Constants.HttpMethod.POST) {
throw createClientConfigurationError(
ClientConfigurationErrorCodes.invalidRequestMethodForEAR
);
} else {
httpMethod = Constants.HttpMethod.POST;
}
} else {
// For non-EAR protocol modes, default to GET if httpMethod is not set
httpMethod = requestMethod || Constants.HttpMethod.GET;
}
return httpMethod;
}

View File

@ -0,0 +1,64 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
import {
AccountInfo,
CommonSilentFlowRequest,
StringDict,
} from "@azure/msal-common/browser";
import { CacheLookupPolicy } from "../utils/BrowserConstants.js";
/**
* SilentRequest: Request object passed by user to retrieve tokens from the
* cache, renew an expired token with a refresh token, or retrieve a code (first leg of authorization code grant flow)
* in a hidden iframe.
*/
export type SilentRequest = Omit<
CommonSilentFlowRequest,
"authority" | "correlationId" | "forceRefresh" | "account"
> & {
/**
* The redirect URI where authentication responses can be received by your application. It must exactly match one of the redirect URIs registered in the Azure portal. Only used for cases where refresh token is expired.
*/
redirectUri?: string;
/**
* String to string map of custom query parameters added to outgoing token service requests. Unless the parameter is ONLY supported on query string use extraParameters instead.
*/
extraQueryParameters?: StringDict;
/**
* Url of the authority which the application acquires tokens from.
*/
authority?: string;
/**
* Account entity to lookup the credentials.
*/
account?: AccountInfo;
/**
* Unique GUID set per request to trace a request end-to-end for telemetry purposes.
*/
correlationId?: string;
/**
* Forces silent requests to make network calls if true.
*/
forceRefresh?: boolean;
/**
* Enum of different ways the silent token can be retrieved.
*/
cacheLookupPolicy?: CacheLookupPolicy;
/**
* Indicates the type of user interaction that is required.
* login: will force the user to enter their credentials on that request, negating single-sign on
* none: will ensure that the user isn't presented with any interactive prompt. if request can't be completed via single-sign on, the endpoint will return an interaction_required error
* consent: will the trigger the OAuth consent dialog after the user signs in, asking the user to grant permissions to the app
* select_account: will interrupt single sign-=on providing account selection experience listing all the accounts in session or any remembered accounts or an option to choose to use a different account
* create: will direct the user to the account creation experience instead of the log in experience
* no_session: will not read existing session token when authenticating the user. Upon user being successfully authenticated, EVO wont create a new session for the user. FOR INTERNAL USE ONLY.
*/
prompt?: string;
/**
* A value included in the request that is also returned in the token response when a hidden iframe is used.
*/
state?: string;
};

View File

@ -0,0 +1,20 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
import { CommonAuthorizationUrlRequest } from "@azure/msal-common/browser";
/**
* Request object passed by user to ssoSilent to retrieve a Code from the server (first leg of authorization code grant flow)
*/
export type SsoSilentRequest = Partial<
Omit<
CommonAuthorizationUrlRequest,
| "responseMode"
| "earJwk"
| "codeChallenge"
| "codeChallengeMethod"
| "platformBroker"
>
>;