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,12 @@
/*! @azure/msal-browser v5.11.0 2026-05-19 */
'use strict';
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
function isBridgeError(error) {
return error.status !== undefined;
}
export { isBridgeError };
//# sourceMappingURL=BridgeError.mjs.map

View File

@ -0,0 +1 @@
{"version":3,"file":"BridgeError.mjs","sources":["../../src/naa/BridgeError.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;AAGG;AAYG,SAAU,aAAa,CAAC,KAAc,EAAA;AACxC,IAAA,OAAQ,KAAqB,CAAC,MAAM,KAAK,SAAS,CAAC;AACvD;;;;"}

View File

@ -0,0 +1,158 @@
/*! @azure/msal-browser v5.11.0 2026-05-19 */
'use strict';
import { BridgeStatusCode } from './BridgeStatusCode.mjs';
import { createNewGuid } from '../crypto/BrowserCrypto.mjs';
import { BrowserConstants } from '../utils/BrowserConstants.mjs';
import { version } from '../packageMetadata.mjs';
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
/**
* BridgeProxy
* Provides a proxy for accessing a bridge to a host app and/or
* platform broker
*/
class BridgeProxy {
/**
* initializeNestedAppAuthBridge - Initializes the bridge to the host app
* @returns a promise that resolves to an InitializeBridgeResponse or rejects with an Error
* @remarks This method will be called by the create factory method
* @remarks If the bridge is not available, this method will throw an error
*/
static async initializeNestedAppAuthBridge() {
if (window === undefined) {
throw new Error("window is undefined");
}
if (window.nestedAppAuthBridge === undefined) {
throw new Error("window.nestedAppAuthBridge is undefined");
}
try {
window.nestedAppAuthBridge.addEventListener("message", (response) => {
const responsePayload = typeof response === "string" ? response : response.data;
const responseEnvelope = JSON.parse(responsePayload);
const request = BridgeProxy.bridgeRequests.find((element) => element.requestId === responseEnvelope.requestId);
if (request !== undefined) {
BridgeProxy.bridgeRequests.splice(BridgeProxy.bridgeRequests.indexOf(request), 1);
if (responseEnvelope.success) {
request.resolve(responseEnvelope);
}
else {
request.reject(responseEnvelope.error);
}
}
});
const bridgeResponse = await new Promise((resolve, reject) => {
const message = BridgeProxy.buildRequest("GetInitContext");
const request = {
requestId: message.requestId,
method: message.method,
resolve: resolve,
reject: reject,
};
BridgeProxy.bridgeRequests.push(request);
window.nestedAppAuthBridge.postMessage(JSON.stringify(message));
});
return BridgeProxy.validateBridgeResultOrThrow(bridgeResponse.initContext);
}
catch (error) {
window.console.log(error);
throw error;
}
}
/**
* getTokenInteractive - Attempts to get a token interactively from the bridge
* @param request A token request
* @returns a promise that resolves to an auth result or rejects with a BridgeError
*/
getTokenInteractive(request) {
return this.getToken("GetTokenPopup", request);
}
/**
* getTokenSilent Attempts to get a token silently from the bridge
* @param request A token request
* @returns a promise that resolves to an auth result or rejects with a BridgeError
*/
getTokenSilent(request) {
return this.getToken("GetToken", request);
}
async getToken(requestType, request) {
const result = await this.sendRequest(requestType, {
tokenParams: request,
});
return {
token: BridgeProxy.validateBridgeResultOrThrow(result.token),
account: BridgeProxy.validateBridgeResultOrThrow(result.account),
};
}
getHostCapabilities() {
return this.capabilities ?? null;
}
getAccountContext() {
return this.accountContext ? this.accountContext : null;
}
static buildRequest(method, requestParams) {
return {
messageType: "NestedAppAuthRequest",
method: method,
requestId: createNewGuid(),
sendTime: Date.now(),
clientLibrary: BrowserConstants.MSAL_SKU,
clientLibraryVersion: version,
...requestParams,
};
}
/**
* A method used to send a request to the bridge
* @param request A token request
* @returns a promise that resolves to a response of provided type or rejects with a BridgeError
*/
sendRequest(method, requestParams) {
const message = BridgeProxy.buildRequest(method, requestParams);
const promise = new Promise((resolve, reject) => {
const request = {
requestId: message.requestId,
method: message.method,
resolve: resolve,
reject: reject,
};
BridgeProxy.bridgeRequests.push(request);
window.nestedAppAuthBridge.postMessage(JSON.stringify(message));
});
return promise;
}
static validateBridgeResultOrThrow(input) {
if (input === undefined) {
const bridgeError = {
status: BridgeStatusCode.NestedAppAuthUnavailable,
};
throw bridgeError;
}
return input;
}
/**
* Private constructor for BridgeProxy
* @param sdkName The name of the SDK being used to make requests on behalf of the app
* @param sdkVersion The version of the SDK being used to make requests on behalf of the app
* @param capabilities The capabilities of the bridge / SDK / platform broker
*/
constructor(sdkName, sdkVersion, accountContext, capabilities) {
this.sdkName = sdkName;
this.sdkVersion = sdkVersion;
this.accountContext = accountContext;
this.capabilities = capabilities;
}
/**
* Factory method for creating an implementation of IBridgeProxy
* @returns A promise that resolves to a BridgeProxy implementation
*/
static async create() {
const response = await BridgeProxy.initializeNestedAppAuthBridge();
return new BridgeProxy(response.sdkName, response.sdkVersion, response.accountContext, response.capabilities);
}
}
BridgeProxy.bridgeRequests = [];
export { BridgeProxy, BridgeProxy as default };
//# sourceMappingURL=BridgeProxy.mjs.map

View File

@ -0,0 +1 @@
{"version":3,"file":"BridgeProxy.mjs","sources":["../../src/naa/BridgeProxy.ts"],"sourcesContent":[null],"names":["BrowserCrypto.createNewGuid"],"mappings":";;;;;;;AAAA;;;AAGG;AA2BH;;;;AAIG;MACU,WAAW,CAAA;AAOpB;;;;;AAKG;IACO,aAAa,6BAA6B,GAAA;QAChD,IAAI,MAAM,KAAK,SAAS,EAAE;AACtB,YAAA,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;AAC1C,SAAA;AACD,QAAA,IAAI,MAAM,CAAC,mBAAmB,KAAK,SAAS,EAAE;AAC1C,YAAA,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;AAC9D,SAAA;QAED,IAAI;YACA,MAAM,CAAC,mBAAmB,CAAC,gBAAgB,CACvC,SAAS,EACT,CAAC,QAA4B,KAAI;AAC7B,gBAAA,MAAM,eAAe,GACjB,OAAO,QAAQ,KAAK,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC;gBAC5D,MAAM,gBAAgB,GAClB,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;gBAChC,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AAC,OAAO,EAChB,QAAQ,CAAC,UAAU,EACnB,QAAQ,CAAC,cAAc,EACvB,QAAQ,CAAC,YAAY,CACxB,CAAC;KACL;;AAjMM,WAAc,CAAA,cAAA,GAAoB,EAAE;;;;"}

View File

@ -0,0 +1,19 @@
/*! @azure/msal-browser v5.11.0 2026-05-19 */
'use strict';
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
const BridgeStatusCode = {
UserInteractionRequired: "USER_INTERACTION_REQUIRED",
UserCancel: "USER_CANCEL",
NoNetwork: "NO_NETWORK",
TransientError: "TRANSIENT_ERROR",
PersistentError: "PERSISTENT_ERROR",
Disabled: "DISABLED",
AccountUnavailable: "ACCOUNT_UNAVAILABLE",
NestedAppAuthUnavailable: "NESTED_APP_AUTH_UNAVAILABLE", // NAA is unavailable in the current context, can retry with standard browser based auth
};
export { BridgeStatusCode };
//# sourceMappingURL=BridgeStatusCode.mjs.map

View File

@ -0,0 +1 @@
{"version":3,"file":"BridgeStatusCode.mjs","sources":["../../src/naa/BridgeStatusCode.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;AAGG;AAEU,MAAA,gBAAgB,GAAG;AAC5B,IAAA,uBAAuB,EAAE,2BAA2B;AACpD,IAAA,UAAU,EAAE,aAAa;AACzB,IAAA,SAAS,EAAE,YAAY;AACvB,IAAA,cAAc,EAAE,iBAAiB;AACjC,IAAA,eAAe,EAAE,kBAAkB;AACnC,IAAA,QAAQ,EAAE,UAAU;AACpB,IAAA,kBAAkB,EAAE,qBAAqB;IACzC,wBAAwB,EAAE,6BAA6B;;;;;"}

View File

@ -0,0 +1,210 @@
/*! @azure/msal-browser v5.11.0 2026-05-19 */
'use strict';
import { RequestParameterBuilder, StringUtils, Constants, createClientAuthError, ClientAuthErrorCodes, TimeUtils, AuthToken, getTenantIdFromIdTokenClaims, buildTenantProfile, AuthError, InteractionRequiredAuthError, ServerError, ClientAuthError } from '@azure/msal-common/browser';
import { isBridgeError } from '../BridgeError.mjs';
import { BridgeStatusCode } from '../BridgeStatusCode.mjs';
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
class NestedAppAuthAdapter {
constructor(clientId, clientCapabilities, crypto, logger) {
this.clientId = clientId;
this.clientCapabilities = clientCapabilities;
this.crypto = crypto;
this.logger = logger;
}
toNaaTokenRequest(request) {
let extraParams;
if (request.extraQueryParameters === undefined) {
extraParams = new Map();
}
else {
extraParams = new Map(Object.entries(request.extraQueryParameters));
}
const correlationId = request.correlationId || this.crypto.createNewGuid();
const claims = RequestParameterBuilder.addClientCapabilitiesToClaims(request.claims, this.clientCapabilities);
const scopes = request.scopes || Constants.OIDC_DEFAULT_SCOPES;
const tokenRequest = {
platformBrokerId: request.account?.homeAccountId,
clientId: this.clientId,
authority: request.authority,
resource: request.resource,
scope: scopes.join(" "),
correlationId,
claims: !StringUtils.isEmptyObj(claims) ? claims : undefined,
state: request.state,
authenticationScheme: request.authenticationScheme ||
Constants.AuthenticationScheme.BEARER,
extraParameters: extraParams,
};
return tokenRequest;
}
fromNaaTokenResponse(request, response, reqTimestamp) {
if (!response.token.id_token || !response.token.access_token) {
throw createClientAuthError(ClientAuthErrorCodes.nullOrEmptyToken);
}
// Request timestamp and AuthResult expires_in are in seconds, converting to Date for AuthenticationResult
const expiresOn = TimeUtils.toDateFromSeconds(reqTimestamp + (response.token.expires_in || 0));
const idTokenClaims = AuthToken.extractTokenClaims(response.token.id_token, this.crypto.base64Decode);
const account = this.fromNaaAccountInfo(response.account, response.token.id_token, idTokenClaims);
const scopes = response.token.scope || request.scope;
const authenticationResult = {
authority: response.token.authority || account.environment,
uniqueId: account.localAccountId,
tenantId: account.tenantId,
scopes: scopes.split(" "),
account,
idToken: response.token.id_token,
idTokenClaims,
accessToken: response.token.access_token,
fromCache: false,
expiresOn: expiresOn,
tokenType: request.authenticationScheme ||
Constants.AuthenticationScheme.BEARER,
correlationId: request.correlationId,
extExpiresOn: expiresOn,
state: request.state,
};
return authenticationResult;
}
/*
* export type AccountInfo = {
* homeAccountId: string;
* environment: string;
* tenantId: string;
* username: string;
* localAccountId: string;
* name?: string;
* idToken?: string;
* idTokenClaims?: TokenClaims & {
* [key: string]:
* | string
* | number
* | string[]
* | object
* | undefined
* | unknown;
* };
* nativeAccountId?: string;
* authorityType?: string;
* };
*/
fromNaaAccountInfo(fromAccount, idToken, idTokenClaims) {
const effectiveIdTokenClaims = idTokenClaims || fromAccount.idTokenClaims;
const localAccountId = fromAccount.localAccountId ||
effectiveIdTokenClaims?.oid ||
effectiveIdTokenClaims?.sub ||
"";
/*
* In B2C scenarios tid may not be present, use getTenantIdFromIdTokenClaims
* which handles tid, tfp (modern B2C), and acr (legacy B2C) claims
*/
const tenantId = fromAccount.tenantId ||
getTenantIdFromIdTokenClaims(effectiveIdTokenClaims) ||
"";
const homeAccountId = fromAccount.homeAccountId || `${localAccountId}.${tenantId}`;
// Validate environment - required field
const environment = fromAccount.environment;
if (!environment) {
throw createClientAuthError(ClientAuthErrorCodes.invalidCacheEnvironment);
}
/*
* In B2C scenarios the emails claim is used instead of preferred_username and it is an array.
* In most cases it will contain a single email. This field should not be relied upon if a custom
* policy is configured to return more than 1 email.
*/
const preferredUsername = effectiveIdTokenClaims?.preferred_username ||
effectiveIdTokenClaims?.upn;
const email = effectiveIdTokenClaims?.emails?.[0] || null;
const username = fromAccount.username || preferredUsername || email || "";
const name = fromAccount.name || effectiveIdTokenClaims?.name || "";
const loginHint = fromAccount.loginHint || effectiveIdTokenClaims?.login_hint;
const tenantProfiles = new Map();
const tenantProfile = buildTenantProfile(homeAccountId, localAccountId, tenantId, effectiveIdTokenClaims);
tenantProfiles.set(tenantId, tenantProfile);
const account = {
homeAccountId,
environment,
tenantId,
username,
localAccountId,
name,
loginHint,
idToken: idToken,
idTokenClaims: effectiveIdTokenClaims,
tenantProfiles,
};
return account;
}
/**
*
* @param error BridgeError
* @returns AuthError, ClientAuthError, ClientConfigurationError, ServerError, InteractionRequiredError
*/
fromBridgeError(error) {
if (isBridgeError(error)) {
switch (error.status) {
case BridgeStatusCode.UserCancel:
return new ClientAuthError(ClientAuthErrorCodes.userCanceled);
case BridgeStatusCode.NoNetwork:
return new ClientAuthError(ClientAuthErrorCodes.noNetworkConnectivity);
case BridgeStatusCode.AccountUnavailable:
return new ClientAuthError(ClientAuthErrorCodes.noAccountFound);
case BridgeStatusCode.Disabled:
return new ClientAuthError(ClientAuthErrorCodes.nestedAppAuthBridgeDisabled);
case BridgeStatusCode.NestedAppAuthUnavailable:
return new ClientAuthError(error.code ||
ClientAuthErrorCodes.nestedAppAuthBridgeDisabled, error.description);
case BridgeStatusCode.TransientError:
case BridgeStatusCode.PersistentError:
return new ServerError(error.code, error.description);
case BridgeStatusCode.UserInteractionRequired:
return new InteractionRequiredAuthError(error.code, error.description);
default:
return new AuthError(error.code, error.description);
}
}
else {
return new AuthError("unknown_error", "An unknown error occurred");
}
}
/**
* Returns an AuthenticationResult from the given cache items
*
* @param account
* @param idToken
* @param accessToken
* @param reqTimestamp
* @returns
*/
toAuthenticationResultFromCache(account, idToken, accessToken, request, correlationId) {
if (!idToken || !accessToken) {
throw createClientAuthError(ClientAuthErrorCodes.nullOrEmptyToken);
}
const idTokenClaims = AuthToken.extractTokenClaims(idToken.secret, this.crypto.base64Decode);
const scopes = accessToken.target || request.scopes.join(" ");
const authenticationResult = {
authority: accessToken.environment || account.environment,
uniqueId: account.localAccountId,
tenantId: account.tenantId,
scopes: scopes.split(" "),
account,
idToken: idToken.secret,
idTokenClaims: idTokenClaims || {},
accessToken: accessToken.secret,
fromCache: true,
expiresOn: TimeUtils.toDateFromSeconds(accessToken.expiresOn),
extExpiresOn: TimeUtils.toDateFromSeconds(accessToken.extendedExpiresOn),
tokenType: request.authenticationScheme ||
Constants.AuthenticationScheme.BEARER,
correlationId,
state: request.state,
};
return authenticationResult;
}
}
export { NestedAppAuthAdapter };
//# sourceMappingURL=NestedAppAuthAdapter.mjs.map

File diff suppressed because one or more lines are too long