Estructura inicial del proyecto
This commit is contained in:
16
backend/node_modules/@azure/msal-browser/dist/broker/nativeBroker/NativeStatusCodes.mjs
generated
vendored
Normal file
16
backend/node_modules/@azure/msal-browser/dist/broker/nativeBroker/NativeStatusCodes.mjs
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
/*! @azure/msal-browser v5.11.0 2026-05-19 */
|
||||
'use strict';
|
||||
/*
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License.
|
||||
*/
|
||||
// Status Codes that can be thrown by WAM
|
||||
const USER_INTERACTION_REQUIRED = "USER_INTERACTION_REQUIRED";
|
||||
const USER_CANCEL = "USER_CANCEL";
|
||||
const NO_NETWORK = "NO_NETWORK";
|
||||
const DISABLED = "DISABLED";
|
||||
const ACCOUNT_UNAVAILABLE = "ACCOUNT_UNAVAILABLE";
|
||||
const UX_NOT_ALLOWED = "UX_NOT_ALLOWED";
|
||||
|
||||
export { ACCOUNT_UNAVAILABLE, DISABLED, NO_NETWORK, USER_CANCEL, USER_INTERACTION_REQUIRED, UX_NOT_ALLOWED };
|
||||
//# sourceMappingURL=NativeStatusCodes.mjs.map
|
||||
1
backend/node_modules/@azure/msal-browser/dist/broker/nativeBroker/NativeStatusCodes.mjs.map
generated
vendored
Normal file
1
backend/node_modules/@azure/msal-browser/dist/broker/nativeBroker/NativeStatusCodes.mjs.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"NativeStatusCodes.mjs","sources":["../../../src/broker/nativeBroker/NativeStatusCodes.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;AAGG;AAEH;AACO,MAAM,yBAAyB,GAAG,4BAA4B;AAC9D,MAAM,WAAW,GAAG,cAAc;AAClC,MAAM,UAAU,GAAG,aAAa;AAGhC,MAAM,QAAQ,GAAG,WAAW;AAC5B,MAAM,mBAAmB,GAAG,sBAAsB;AAClD,MAAM,cAAc,GAAG;;;;"}
|
||||
156
backend/node_modules/@azure/msal-browser/dist/broker/nativeBroker/PlatformAuthDOMHandler.mjs
generated
vendored
Normal file
156
backend/node_modules/@azure/msal-browser/dist/broker/nativeBroker/PlatformAuthDOMHandler.mjs
generated
vendored
Normal file
@ -0,0 +1,156 @@
|
||||
/*! @azure/msal-browser v5.11.0 2026-05-19 */
|
||||
'use strict';
|
||||
import { createAuthError, AuthErrorCodes } from '@azure/msal-common/browser';
|
||||
import { PlatformAuthConstants } from '../../utils/BrowserConstants.mjs';
|
||||
import { createNativeAuthError } from '../../error/NativeAuthError.mjs';
|
||||
|
||||
/*
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License.
|
||||
*/
|
||||
class PlatformAuthDOMHandler {
|
||||
constructor(logger, performanceClient, correlationId) {
|
||||
this.logger = logger;
|
||||
this.performanceClient = performanceClient;
|
||||
this.correlationId = correlationId;
|
||||
this.platformAuthType = PlatformAuthConstants.PLATFORM_DOM_PROVIDER;
|
||||
}
|
||||
static async createProvider(logger, performanceClient, correlationId) {
|
||||
logger.trace("12mj4a", correlationId);
|
||||
// @ts-ignore
|
||||
if (window.navigator?.platformAuthentication) {
|
||||
const supportedContracts =
|
||||
// @ts-ignore
|
||||
await window.navigator.platformAuthentication.getSupportedContracts(PlatformAuthConstants.MICROSOFT_ENTRA_BROKERID);
|
||||
if (supportedContracts?.includes(PlatformAuthConstants.PLATFORM_DOM_APIS)) {
|
||||
logger.trace("1h5q1r", correlationId);
|
||||
return new PlatformAuthDOMHandler(logger, performanceClient, correlationId);
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
/**
|
||||
* Returns the Id for the broker extension this handler is communicating with
|
||||
* @returns
|
||||
*/
|
||||
getExtensionId() {
|
||||
return PlatformAuthConstants.MICROSOFT_ENTRA_BROKERID;
|
||||
}
|
||||
getExtensionVersion() {
|
||||
return "";
|
||||
}
|
||||
getExtensionName() {
|
||||
return PlatformAuthConstants.DOM_API_NAME;
|
||||
}
|
||||
/**
|
||||
* Send token request to platform broker via browser DOM API
|
||||
* @param request
|
||||
* @returns
|
||||
*/
|
||||
async sendMessage(request) {
|
||||
this.logger.trace("02bcil", request.correlationId);
|
||||
try {
|
||||
const platformDOMRequest = this.initializePlatformDOMRequest(request);
|
||||
const response =
|
||||
// @ts-ignore
|
||||
await window.navigator.platformAuthentication.executeGetToken(platformDOMRequest);
|
||||
return this.validatePlatformBrokerResponse(response, request.correlationId);
|
||||
}
|
||||
catch (e) {
|
||||
this.logger.error("11im7g", request.correlationId);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
initializePlatformDOMRequest(request) {
|
||||
this.logger.trace("15d6yv", request.correlationId);
|
||||
const { accountId, clientId, authority, scope, redirectUri, correlationId, state, storeInCache, embeddedClientId, extraParameters, ...remainingProperties } = request;
|
||||
const validExtraParameters = this.getDOMExtraParams(remainingProperties, correlationId);
|
||||
const platformDOMRequest = {
|
||||
accountId: accountId,
|
||||
brokerId: this.getExtensionId(),
|
||||
authority: authority,
|
||||
clientId: clientId,
|
||||
correlationId: correlationId || this.correlationId,
|
||||
extraParameters: {
|
||||
...extraParameters,
|
||||
...validExtraParameters,
|
||||
},
|
||||
isSecurityTokenService: false,
|
||||
redirectUri: redirectUri,
|
||||
scope: scope,
|
||||
state: state,
|
||||
storeInCache: storeInCache,
|
||||
embeddedClientId: embeddedClientId,
|
||||
};
|
||||
return platformDOMRequest;
|
||||
}
|
||||
validatePlatformBrokerResponse(response, correlationId) {
|
||||
if (response.hasOwnProperty("isSuccess")) {
|
||||
if (response.hasOwnProperty("accessToken") &&
|
||||
response.hasOwnProperty("idToken") &&
|
||||
response.hasOwnProperty("clientInfo") &&
|
||||
response.hasOwnProperty("account") &&
|
||||
response.hasOwnProperty("scopes") &&
|
||||
response.hasOwnProperty("expiresIn")) {
|
||||
this.logger.trace("0h4vei", correlationId);
|
||||
return this.convertToPlatformBrokerResponse(response, correlationId);
|
||||
}
|
||||
else if (response.hasOwnProperty("error")) {
|
||||
const errorResponse = response;
|
||||
if (errorResponse.isSuccess === false &&
|
||||
errorResponse.error &&
|
||||
errorResponse.error.code) {
|
||||
this.logger.trace("0g92vm", correlationId);
|
||||
throw createNativeAuthError(errorResponse.error.code, errorResponse.error.description, {
|
||||
error: parseInt(errorResponse.error.errorCode),
|
||||
protocol_error: errorResponse.error.protocolError,
|
||||
status: errorResponse.error.status,
|
||||
properties: errorResponse.error.properties,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
throw createAuthError(AuthErrorCodes.unexpectedError, "Response missing expected properties.");
|
||||
}
|
||||
convertToPlatformBrokerResponse(response, correlationId) {
|
||||
this.logger.trace("14913t", correlationId);
|
||||
const nativeResponse = {
|
||||
access_token: response.accessToken,
|
||||
id_token: response.idToken,
|
||||
client_info: response.clientInfo,
|
||||
account: response.account,
|
||||
expires_in: response.expiresIn,
|
||||
scope: response.scopes,
|
||||
state: response.state || "",
|
||||
properties: response.properties || {},
|
||||
extendedLifetimeToken: response.extendedLifetimeToken ?? false,
|
||||
shr: response.proofOfPossessionPayload,
|
||||
};
|
||||
return nativeResponse;
|
||||
}
|
||||
getDOMExtraParams(extraParameters, correlationId) {
|
||||
try {
|
||||
const stringifiedProperties = {};
|
||||
for (const [key, value] of Object.entries(extraParameters)) {
|
||||
if (!value) {
|
||||
continue;
|
||||
}
|
||||
if (typeof value === "object") {
|
||||
stringifiedProperties[key] = JSON.stringify(value);
|
||||
}
|
||||
else {
|
||||
stringifiedProperties[key] = String(value);
|
||||
}
|
||||
}
|
||||
return stringifiedProperties;
|
||||
}
|
||||
catch (e) {
|
||||
this.logger.error("0eu9o3", correlationId);
|
||||
this.logger.errorPii("17rpl5", correlationId);
|
||||
return {};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export { PlatformAuthDOMHandler };
|
||||
//# sourceMappingURL=PlatformAuthDOMHandler.mjs.map
|
||||
1
backend/node_modules/@azure/msal-browser/dist/broker/nativeBroker/PlatformAuthDOMHandler.mjs.map
generated
vendored
Normal file
1
backend/node_modules/@azure/msal-browser/dist/broker/nativeBroker/PlatformAuthDOMHandler.mjs.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"PlatformAuthDOMHandler.mjs","sources":["../../../src/broker/nativeBroker/PlatformAuthDOMHandler.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;AAAA;;;AAGG;MAsBU,sBAAsB,CAAA;AAM/B,IAAA,WAAA,CACI,MAAc,EACd,iBAAqC,EACrC,aAAqB,EAAA;AAErB,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;AACrB,QAAA,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;AAC3C,QAAA,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;AACnC,QAAA,IAAI,CAAC,gBAAgB,GAAG,qBAAqB,CAAC,qBAAqB,CAAC;KACvE;IAED,aAAa,cAAc,CACvB,MAAc,EACd,iBAAqC,EACrC,aAAqB,EAAA;AAErB,QAAA,MAAM,CAAC,KAAK,CACR;;AAKJ,QAAA,IAAI,MAAM,CAAC,SAAS,EAAE,sBAAsB,EAAE;AAC1C,YAAA,MAAM,kBAAkB;;AAEpB,YAAA,MAAM,MAAM,CAAC,SAAS,CAAC,sBAAsB,CAAC,qBAAqB,CAC/D,qBAAqB,CAAC,wBAAwB,CACjD,CAAC;YACN,IACI,kBAAkB,EAAE,QAAQ,CACxB,qBAAqB,CAAC,iBAAiB,CAC1C,EACH;AACE,gBAAA,MAAM,CAAC,KAAK,CACR;gBAGJ,OAAO,IAAI,sBAAsB,CAC7B,MAAM,EACN,iBAAiB,EACjB,aAAa,CAChB,CAAC;AACL,aAAA;AACJ,SAAA;AACD,QAAA,OAAO,SAAS,CAAC;KACpB;AAED;;;AAGG;IACH,cAAc,GAAA;QACV,OAAO,qBAAqB,CAAC,wBAAwB,CAAC;KACzD;IAED,mBAAmB,GAAA;AACf,QAAA,OAAO,EAAE,CAAC;KACb;IAED,gBAAgB,GAAA;QACZ,OAAO,qBAAqB,CAAC,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,OAAO,CAAC,eAAe,CAAC,EAAE;gBACxD,IAAI,CAAC,KAAK,EAAE;oBACR,SAAS;AACZ,iBAAA;AACD,gBAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;oBAC3B,qBAAqB,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AACtD,iBAAA;AAAM,qBAAA;oBACH,qBAAqB,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;AAC9C,iBAAA;AACJ,aAAA;AACD,YAAA,OAAO,qBAAqB,CAAC;AAChC,SAAA;AAAC,QAAA,OAAO,CAAC,EAAE;AACR,YAAA,IAAI,CAAC,MAAM,CAAC,KAAK,CACb,QAAQ,EAAiB,aAAA,CAAA,CAAA;AAG7B,YAAA,IAAI,CAAC,MAAM,CAAC,QAAQ,CAChB,QAAQ,EAAC,aAAA,CAAA,CAAgB;AAG7B,YAAA,OAAO,EAAE,CAAC;AACb,SAAA;KACJ;AACJ;;;;"}
|
||||
272
backend/node_modules/@azure/msal-browser/dist/broker/nativeBroker/PlatformAuthExtensionHandler.mjs
generated
vendored
Normal file
272
backend/node_modules/@azure/msal-browser/dist/broker/nativeBroker/PlatformAuthExtensionHandler.mjs
generated
vendored
Normal file
@ -0,0 +1,272 @@
|
||||
/*! @azure/msal-browser v5.11.0 2026-05-19 */
|
||||
'use strict';
|
||||
import { PlatformAuthConstants, NativeExtensionMethod } from '../../utils/BrowserConstants.mjs';
|
||||
import { createAuthError, AuthErrorCodes } from '@azure/msal-common/browser';
|
||||
import { NativeMessageHandlerHandshake } from '../../telemetry/BrowserPerformanceEvents.mjs';
|
||||
import { createNativeAuthError } from '../../error/NativeAuthError.mjs';
|
||||
import { createBrowserAuthError } from '../../error/BrowserAuthError.mjs';
|
||||
import { createNewGuid } from '../../crypto/BrowserCrypto.mjs';
|
||||
import { createGuid } from '../../utils/BrowserUtils.mjs';
|
||||
import { nativeHandshakeTimeout, nativeExtensionNotInstalled } from '../../error/BrowserAuthErrorCodes.mjs';
|
||||
|
||||
/*
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License.
|
||||
*/
|
||||
class PlatformAuthExtensionHandler {
|
||||
constructor(logger, handshakeTimeoutMs, performanceClient, extensionId) {
|
||||
this.logger = logger;
|
||||
this.handshakeTimeoutMs = handshakeTimeoutMs;
|
||||
this.extensionId = extensionId;
|
||||
this.resolvers = new Map(); // Used for non-handshake messages
|
||||
this.handshakeResolvers = new Map(); // Used for handshake messages
|
||||
this.messageChannel = new MessageChannel();
|
||||
this.windowListener = this.onWindowMessage.bind(this); // Window event callback doesn't have access to 'this' unless it's bound
|
||||
this.performanceClient = performanceClient;
|
||||
this.handshakeEvent = this.performanceClient.startMeasurement(NativeMessageHandlerHandshake);
|
||||
this.platformAuthType =
|
||||
PlatformAuthConstants.PLATFORM_EXTENSION_PROVIDER;
|
||||
}
|
||||
/**
|
||||
* Sends a given message to the extension and resolves with the extension response
|
||||
* @param request
|
||||
*/
|
||||
async sendMessage(request) {
|
||||
this.logger.trace("0on4p2", request.correlationId);
|
||||
// fall back to native calls
|
||||
const messageBody = {
|
||||
method: NativeExtensionMethod.GetToken,
|
||||
request: request,
|
||||
};
|
||||
const req = {
|
||||
channel: PlatformAuthConstants.CHANNEL_ID,
|
||||
extensionId: this.extensionId,
|
||||
responseId: createNewGuid(),
|
||||
body: messageBody,
|
||||
};
|
||||
this.logger.trace("1qadfi", request.correlationId);
|
||||
this.logger.tracePii("1xm533", request.correlationId);
|
||||
this.messageChannel.port1.postMessage(req);
|
||||
const response = await new Promise((resolve, reject) => {
|
||||
this.resolvers.set(req.responseId, { resolve, reject });
|
||||
});
|
||||
const validatedResponse = this.validatePlatformBrokerResponse(response);
|
||||
return validatedResponse;
|
||||
}
|
||||
/**
|
||||
* Returns an instance of the MessageHandler that has successfully established a connection with an extension
|
||||
* @param {Logger} logger
|
||||
* @param {number} handshakeTimeoutMs
|
||||
* @param {IPerformanceClient} performanceClient
|
||||
* @param {ICrypto} crypto
|
||||
*/
|
||||
static async createProvider(logger, handshakeTimeoutMs, performanceClient, correlationId) {
|
||||
logger.trace("15zfnw", correlationId);
|
||||
try {
|
||||
const preferredProvider = new PlatformAuthExtensionHandler(logger, handshakeTimeoutMs, performanceClient, PlatformAuthConstants.PREFERRED_EXTENSION_ID);
|
||||
await preferredProvider.sendHandshakeRequest(correlationId);
|
||||
return preferredProvider;
|
||||
}
|
||||
catch (e) {
|
||||
// If preferred extension fails for whatever reason, fallback to using any installed extension
|
||||
const backupProvider = new PlatformAuthExtensionHandler(logger, handshakeTimeoutMs, performanceClient);
|
||||
await backupProvider.sendHandshakeRequest(correlationId);
|
||||
return backupProvider;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Send handshake request helper.
|
||||
*/
|
||||
async sendHandshakeRequest(correlationId) {
|
||||
this.logger.trace("1dpg9o", correlationId);
|
||||
// Register this event listener before sending handshake
|
||||
window.addEventListener("message", this.windowListener, false); // false is important, because content script message processing should work first
|
||||
const req = {
|
||||
channel: PlatformAuthConstants.CHANNEL_ID,
|
||||
extensionId: this.extensionId,
|
||||
responseId: createNewGuid(),
|
||||
body: {
|
||||
method: NativeExtensionMethod.HandshakeRequest,
|
||||
},
|
||||
};
|
||||
this.handshakeEvent.add({
|
||||
extensionId: this.extensionId,
|
||||
extensionHandshakeTimeoutMs: this.handshakeTimeoutMs,
|
||||
});
|
||||
this.messageChannel.port1.onmessage = (event) => {
|
||||
this.onChannelMessage(event);
|
||||
};
|
||||
window.postMessage(req, window.origin, [this.messageChannel.port2]);
|
||||
return new Promise((resolve, reject) => {
|
||||
this.handshakeResolvers.set(req.responseId, { resolve, reject });
|
||||
this.timeoutId = window.setTimeout(() => {
|
||||
/*
|
||||
* Throw an error if neither HandshakeResponse nor original Handshake request are received in a reasonable timeframe.
|
||||
* This typically suggests an event handler stopped propagation of the Handshake request but did not respond to it on the MessageChannel port
|
||||
*/
|
||||
window.removeEventListener("message", this.windowListener, false);
|
||||
this.messageChannel.port1.close();
|
||||
this.messageChannel.port2.close();
|
||||
this.handshakeEvent.end({
|
||||
extensionHandshakeTimedOut: true,
|
||||
success: false,
|
||||
});
|
||||
reject(createBrowserAuthError(nativeHandshakeTimeout));
|
||||
this.handshakeResolvers.delete(req.responseId);
|
||||
}, this.handshakeTimeoutMs); // Use a reasonable timeout in milliseconds here
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Invoked when a message is posted to the window. If a handshake request is received it means the extension is not installed.
|
||||
* @param event
|
||||
*/
|
||||
onWindowMessage(event) {
|
||||
const correlationId = createGuid();
|
||||
this.logger.trace("0jpn5u", correlationId);
|
||||
// We only accept messages from ourselves
|
||||
if (event.source !== window) {
|
||||
return;
|
||||
}
|
||||
const request = event.data;
|
||||
if (!request.channel ||
|
||||
request.channel !== PlatformAuthConstants.CHANNEL_ID) {
|
||||
return;
|
||||
}
|
||||
if (request.extensionId && request.extensionId !== this.extensionId) {
|
||||
return;
|
||||
}
|
||||
if (request.body.method === NativeExtensionMethod.HandshakeRequest) {
|
||||
const handshakeResolver = this.handshakeResolvers.get(request.responseId);
|
||||
/*
|
||||
* Filter out responses with no matched resolvers sooner to keep channel ports open while waiting for
|
||||
* the proper response.
|
||||
*/
|
||||
if (!handshakeResolver) {
|
||||
this.logger.trace("07buhm", correlationId);
|
||||
return;
|
||||
}
|
||||
// If we receive this message back it means no extension intercepted the request, meaning no extension supporting handshake protocol is installed
|
||||
this.logger.verbose(request.extensionId
|
||||
? "0xrkug"
|
||||
: "No extension installed", correlationId);
|
||||
clearTimeout(this.timeoutId);
|
||||
this.messageChannel.port1.close();
|
||||
this.messageChannel.port2.close();
|
||||
window.removeEventListener("message", this.windowListener, false);
|
||||
this.handshakeEvent.end({
|
||||
success: false,
|
||||
extensionInstalled: false,
|
||||
});
|
||||
handshakeResolver.reject(createBrowserAuthError(nativeExtensionNotInstalled));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Invoked when a message is received from the extension on the MessageChannel port
|
||||
* @param event
|
||||
*/
|
||||
onChannelMessage(event) {
|
||||
const correlationId = createGuid();
|
||||
this.logger.trace("1py8yf", correlationId);
|
||||
const request = event.data;
|
||||
const resolver = this.resolvers.get(request.responseId);
|
||||
const handshakeResolver = this.handshakeResolvers.get(request.responseId);
|
||||
try {
|
||||
const method = request.body.method;
|
||||
if (method === NativeExtensionMethod.Response) {
|
||||
if (!resolver) {
|
||||
return;
|
||||
}
|
||||
const response = request.body.response;
|
||||
this.logger.trace("19hpgm", correlationId);
|
||||
this.logger.tracePii("179a24", correlationId);
|
||||
if (response.status !== "Success") {
|
||||
resolver.reject(createNativeAuthError(response.code, response.description, response.ext));
|
||||
}
|
||||
else if (response.result) {
|
||||
if (response.result["code"] &&
|
||||
response.result["description"]) {
|
||||
resolver.reject(createNativeAuthError(response.result["code"], response.result["description"], response.result["ext"]));
|
||||
}
|
||||
else {
|
||||
resolver.resolve(response.result);
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw createAuthError(AuthErrorCodes.unexpectedError, "Event does not contain result.");
|
||||
}
|
||||
this.resolvers.delete(request.responseId);
|
||||
}
|
||||
else if (method === NativeExtensionMethod.HandshakeResponse) {
|
||||
if (!handshakeResolver) {
|
||||
this.logger.trace("082qnt", correlationId);
|
||||
return;
|
||||
}
|
||||
clearTimeout(this.timeoutId); // Clear setTimeout
|
||||
window.removeEventListener("message", this.windowListener, false); // Remove 'No extension' listener
|
||||
this.extensionId = request.extensionId;
|
||||
this.extensionVersion = request.body.version;
|
||||
this.logger.verbose("0yf5ib", correlationId);
|
||||
this.handshakeEvent.end({
|
||||
extensionInstalled: true,
|
||||
success: true,
|
||||
});
|
||||
handshakeResolver.resolve();
|
||||
this.handshakeResolvers.delete(request.responseId);
|
||||
}
|
||||
// Do nothing if method is not Response or HandshakeResponse
|
||||
}
|
||||
catch (err) {
|
||||
this.logger.error("0xf978", correlationId);
|
||||
this.logger.errorPii("04i99o", correlationId);
|
||||
this.logger.errorPii("0xdvsy", correlationId);
|
||||
if (resolver) {
|
||||
resolver.reject(err);
|
||||
}
|
||||
else if (handshakeResolver) {
|
||||
handshakeResolver.reject(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Validates native platform response before processing
|
||||
* @param response
|
||||
*/
|
||||
validatePlatformBrokerResponse(response) {
|
||||
if (response.hasOwnProperty("access_token") &&
|
||||
response.hasOwnProperty("id_token") &&
|
||||
response.hasOwnProperty("client_info") &&
|
||||
response.hasOwnProperty("account") &&
|
||||
response.hasOwnProperty("scope") &&
|
||||
response.hasOwnProperty("expires_in")) {
|
||||
return response;
|
||||
}
|
||||
else {
|
||||
throw createAuthError(AuthErrorCodes.unexpectedError, "Response missing expected properties.");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns the Id for the browser extension this handler is communicating with
|
||||
* @returns
|
||||
*/
|
||||
getExtensionId() {
|
||||
return this.extensionId;
|
||||
}
|
||||
/**
|
||||
* Returns the version for the browser extension this handler is communicating with
|
||||
* @returns
|
||||
*/
|
||||
getExtensionVersion() {
|
||||
return this.extensionVersion;
|
||||
}
|
||||
getExtensionName() {
|
||||
return this.getExtensionId() ===
|
||||
PlatformAuthConstants.PREFERRED_EXTENSION_ID
|
||||
? "chrome"
|
||||
: this.getExtensionId()?.length
|
||||
? "unknown"
|
||||
: undefined;
|
||||
}
|
||||
}
|
||||
|
||||
export { PlatformAuthExtensionHandler };
|
||||
//# sourceMappingURL=PlatformAuthExtensionHandler.mjs.map
|
||||
1
backend/node_modules/@azure/msal-browser/dist/broker/nativeBroker/PlatformAuthExtensionHandler.mjs.map
generated
vendored
Normal file
1
backend/node_modules/@azure/msal-browser/dist/broker/nativeBroker/PlatformAuthExtensionHandler.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
96
backend/node_modules/@azure/msal-browser/dist/broker/nativeBroker/PlatformAuthProvider.mjs
generated
vendored
Normal file
96
backend/node_modules/@azure/msal-browser/dist/broker/nativeBroker/PlatformAuthProvider.mjs
generated
vendored
Normal file
@ -0,0 +1,96 @@
|
||||
/*! @azure/msal-browser v5.11.0 2026-05-19 */
|
||||
'use strict';
|
||||
import { Logger, StubPerformanceClient, createClientConfigurationError, ClientConfigurationErrorCodes, Constants } from '@azure/msal-common/browser';
|
||||
import { name, version } from '../../packageMetadata.mjs';
|
||||
import { DEFAULT_NATIVE_BROKER_HANDSHAKE_TIMEOUT_MS } from '../../config/Configuration.mjs';
|
||||
import { PlatformAuthExtensionHandler } from './PlatformAuthExtensionHandler.mjs';
|
||||
import { PlatformAuthDOMHandler } from './PlatformAuthDOMHandler.mjs';
|
||||
import { createNewGuid } from '../../crypto/BrowserCrypto.mjs';
|
||||
|
||||
/*
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License.
|
||||
*/
|
||||
/**
|
||||
* Checks if the platform broker is available in the current environment.
|
||||
* @param domConfig - Whether to enable platform broker DOM API support (required)
|
||||
* @param loggerOptions - Optional logger options
|
||||
* @param perfClient - Optional performance client
|
||||
* @param correlationId - Optional correlation ID
|
||||
* @returns Promise<boolean> indicating if platform broker is available
|
||||
*/
|
||||
async function isPlatformBrokerAvailable(domConfig, loggerOptions, perfClient, correlationId) {
|
||||
const logger = new Logger(loggerOptions || {}, name, version);
|
||||
const performanceClient = perfClient || new StubPerformanceClient();
|
||||
if (typeof window === "undefined") {
|
||||
logger.trace("082ed3", correlationId || createNewGuid());
|
||||
return false;
|
||||
}
|
||||
return !!(await getPlatformAuthProvider(logger, performanceClient, correlationId || createNewGuid(), undefined, domConfig));
|
||||
}
|
||||
async function getPlatformAuthProvider(logger, performanceClient, correlationId, nativeBrokerHandshakeTimeout, enablePlatformBrokerDOMSupport) {
|
||||
logger.trace("134j0v", correlationId);
|
||||
logger.trace("04c81g", correlationId);
|
||||
let platformAuthProvider;
|
||||
try {
|
||||
if (enablePlatformBrokerDOMSupport) {
|
||||
// Check if DOM platform API is supported first
|
||||
platformAuthProvider = await PlatformAuthDOMHandler.createProvider(logger, performanceClient, correlationId);
|
||||
}
|
||||
if (!platformAuthProvider) {
|
||||
logger.trace("0l3na8", correlationId);
|
||||
/*
|
||||
* If DOM APIs are not available, check if browser extension is available.
|
||||
* Platform authentication via DOM APIs is preferred over extension APIs.
|
||||
*/
|
||||
platformAuthProvider =
|
||||
await PlatformAuthExtensionHandler.createProvider(logger, nativeBrokerHandshakeTimeout ||
|
||||
DEFAULT_NATIVE_BROKER_HANDSHAKE_TIMEOUT_MS, performanceClient, correlationId);
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
logger.trace("0icbd7", e);
|
||||
}
|
||||
return platformAuthProvider;
|
||||
}
|
||||
/**
|
||||
* Returns boolean indicating whether or not the request should attempt to use platform broker
|
||||
* @param logger
|
||||
* @param config
|
||||
* @param correlationId
|
||||
* @param platformAuthProvider
|
||||
* @param authenticationScheme
|
||||
*/
|
||||
function isPlatformAuthAllowed(config, logger, correlationId, platformAuthProvider, authenticationScheme) {
|
||||
logger.trace("0uko3r", correlationId);
|
||||
// throw an error if allowPlatformBroker is not enabled and allowPlatformBrokerWithDOM is enabled
|
||||
if (!config.system.allowPlatformBroker &&
|
||||
config.experimental.allowPlatformBrokerWithDOM) {
|
||||
throw createClientConfigurationError(ClientConfigurationErrorCodes.invalidPlatformBrokerConfiguration);
|
||||
}
|
||||
if (!config.system.allowPlatformBroker) {
|
||||
logger.trace("04hozs", correlationId);
|
||||
// Developer disabled WAM
|
||||
return false;
|
||||
}
|
||||
if (!platformAuthProvider) {
|
||||
logger.trace("0kvv1r", correlationId);
|
||||
// Platform broker auth providers are not available
|
||||
return false;
|
||||
}
|
||||
if (authenticationScheme) {
|
||||
switch (authenticationScheme) {
|
||||
case Constants.AuthenticationScheme.BEARER:
|
||||
case Constants.AuthenticationScheme.POP:
|
||||
logger.trace("18tev1", correlationId);
|
||||
return true;
|
||||
default:
|
||||
logger.trace("1dd2nh", correlationId);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
export { getPlatformAuthProvider, isPlatformAuthAllowed, isPlatformBrokerAvailable };
|
||||
//# sourceMappingURL=PlatformAuthProvider.mjs.map
|
||||
1
backend/node_modules/@azure/msal-browser/dist/broker/nativeBroker/PlatformAuthProvider.mjs.map
generated
vendored
Normal file
1
backend/node_modules/@azure/msal-browser/dist/broker/nativeBroker/PlatformAuthProvider.mjs.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"PlatformAuthProvider.mjs","sources":["../../../src/broker/nativeBroker/PlatformAuthProvider.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;AAAA;;;AAGG;AAqBH;;;;;;;AAOG;AACI,eAAe,yBAAyB,CAC3C,SAAkB,EAClB,aAA6B,EAC7B,UAA+B,EAC/B,aAAsB,EAAA;AAEtB,IAAA,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,aAAa,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AAE9D,IAAA,MAAM,iBAAiB,GAAG,UAAU,IAAI,IAAI,qBAAqB,EAAE,CAAC;AAEpE,IAAA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QAC/B,MAAM,CAAC,KAAK,CACR,QAAmD,EAAA,aAAA,IAAA,aAAA,EAAA,CAAA,CAAA;AAGvD,QAAA,OAAO,KAAK,CAAC;AAChB,KAAA;IAED,OAAO,CAAC,EAAE,MAAM,uBAAuB,CACnC,MAAM,EACN,iBAAiB,EACjB,aAAa,IAAI,aAAa,EAAE,EAChC,SAAS,EACT,SAAS,CACZ,CAAC,CAAC;AACP,CAAC;AAEM,eAAe,uBAAuB,CACzC,MAAc,EACd,iBAAqC,EACrC,aAAqB,EACrB,4BAAqC,EACrC,8BAAwC,EAAA;AAExC,IAAA,MAAM,CAAC,KAAK,CAAC;IAEb,MAAM,CAAC,KAAK,CACR,QAAA,EAAA,aAAA,CAAA,CAAA;AAIJ,IAAA,IAAI,oBAAsD,CAAC;IAC3D,IAAI;AACA,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