Estructura inicial del proyecto
This commit is contained in:
65
backend/node_modules/@azure/identity/dist/commonjs/client/identityClient.d.ts
generated
vendored
Normal file
65
backend/node_modules/@azure/identity/dist/commonjs/client/identityClient.d.ts
generated
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
import type { INetworkModule, NetworkRequestOptions, NetworkResponse } from "@azure/msal-node";
|
||||
import type { AccessToken, GetTokenOptions } from "@azure/core-auth";
|
||||
import { ServiceClient } from "@azure/core-client";
|
||||
import type { PipelineRequest } from "@azure/core-rest-pipeline";
|
||||
import type { AbortSignalLike } from "@azure/abort-controller";
|
||||
import type { TokenCredentialOptions } from "../tokenCredentialOptions.js";
|
||||
/**
|
||||
* An internal type used to communicate details of a token request's
|
||||
* response that should not be sent back as part of the access token.
|
||||
*/
|
||||
export interface TokenResponse {
|
||||
/**
|
||||
* The AccessToken to be returned from getToken.
|
||||
*/
|
||||
accessToken: AccessToken;
|
||||
/**
|
||||
* The refresh token if the 'offline_access' scope was used.
|
||||
*/
|
||||
refreshToken?: string;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export declare function getIdentityClientAuthorityHost(options?: TokenCredentialOptions): string;
|
||||
/**
|
||||
* The network module used by the Identity credentials.
|
||||
*
|
||||
* It allows for credentials to abort any pending request independently of the MSAL flow,
|
||||
* by calling to the `abortRequests()` method.
|
||||
*
|
||||
*/
|
||||
export declare class IdentityClient extends ServiceClient implements INetworkModule {
|
||||
authorityHost: string;
|
||||
private allowLoggingAccountIdentifiers?;
|
||||
private abortControllers;
|
||||
private allowInsecureConnection;
|
||||
private tokenCredentialOptions;
|
||||
constructor(options?: TokenCredentialOptions);
|
||||
sendTokenRequest(request: PipelineRequest): Promise<TokenResponse | null>;
|
||||
refreshAccessToken(tenantId: string, clientId: string, scopes: string, refreshToken: string | undefined, clientSecret: string | undefined, options?: GetTokenOptions): Promise<TokenResponse | null>;
|
||||
generateAbortSignal(correlationId: string): AbortSignalLike;
|
||||
abortRequests(correlationId?: string): void;
|
||||
getCorrelationId(options?: NetworkRequestOptions): string;
|
||||
sendGetRequestAsync<T>(url: string, options?: NetworkRequestOptions): Promise<NetworkResponse<T>>;
|
||||
sendPostRequestAsync<T>(url: string, options?: NetworkRequestOptions): Promise<NetworkResponse<T>>;
|
||||
/**
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
getTokenCredentialOptions(): TokenCredentialOptions;
|
||||
/**
|
||||
* If allowLoggingAccountIdentifiers was set on the constructor options
|
||||
* we try to log the account identifiers by parsing the received access token.
|
||||
*
|
||||
* The account identifiers we try to log are:
|
||||
* - `appid`: The application or Client Identifier.
|
||||
* - `upn`: User Principal Name.
|
||||
* - It might not be available in some authentication scenarios.
|
||||
* - If it's not available, we put a placeholder: "No User Principal Name available".
|
||||
* - `tid`: Tenant Identifier.
|
||||
* - `oid`: Object Identifier of the authenticated user.
|
||||
*/
|
||||
private logIdentifiers;
|
||||
}
|
||||
//# sourceMappingURL=identityClient.d.ts.map
|
||||
1
backend/node_modules/@azure/identity/dist/commonjs/client/identityClient.d.ts.map
generated
vendored
Normal file
1
backend/node_modules/@azure/identity/dist/commonjs/client/identityClient.d.ts.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"identityClient.d.ts","sourceRoot":"","sources":["../../../src/client/identityClient.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC/F,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,KAAK,EAAE,eAAe,EAAoB,MAAM,2BAA2B,CAAC;AAEnF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAM/D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAS3E;;;GAGG;AACH,MAAM,WAA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BAAyB,IAAI,sBAAsB;IAGnD;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,cAAc;CA6BvB"}
|
||||
265
backend/node_modules/@azure/identity/dist/commonjs/client/identityClient.js
generated
vendored
Normal file
265
backend/node_modules/@azure/identity/dist/commonjs/client/identityClient.js
generated
vendored
Normal file
@ -0,0 +1,265 @@
|
||||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.IdentityClient = void 0;
|
||||
exports.getIdentityClientAuthorityHost = getIdentityClientAuthorityHost;
|
||||
const core_client_1 = require("@azure/core-client");
|
||||
const core_util_1 = require("@azure/core-util");
|
||||
const core_rest_pipeline_1 = require("@azure/core-rest-pipeline");
|
||||
const errors_js_1 = require("../errors.js");
|
||||
const identityTokenEndpoint_js_1 = require("../util/identityTokenEndpoint.js");
|
||||
const constants_js_1 = require("../constants.js");
|
||||
const tracing_js_1 = require("../util/tracing.js");
|
||||
const logging_js_1 = require("../util/logging.js");
|
||||
const utils_js_1 = require("../credentials/managedIdentityCredential/utils.js");
|
||||
const noCorrelationId = "noCorrelationId";
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
function getIdentityClientAuthorityHost(options) {
|
||||
// The authorityHost can come from options or from the AZURE_AUTHORITY_HOST environment variable.
|
||||
let authorityHost = options?.authorityHost;
|
||||
// The AZURE_AUTHORITY_HOST environment variable can only be provided in Node.js.
|
||||
if (core_util_1.isNode) {
|
||||
authorityHost = authorityHost ?? process.env.AZURE_AUTHORITY_HOST;
|
||||
}
|
||||
// If the authorityHost is not provided, we use the default one from the public cloud: https://login.microsoftonline.com
|
||||
return authorityHost ?? constants_js_1.DefaultAuthorityHost;
|
||||
}
|
||||
/**
|
||||
* The network module used by the Identity credentials.
|
||||
*
|
||||
* It allows for credentials to abort any pending request independently of the MSAL flow,
|
||||
* by calling to the `abortRequests()` method.
|
||||
*
|
||||
*/
|
||||
class IdentityClient extends core_client_1.ServiceClient {
|
||||
authorityHost;
|
||||
allowLoggingAccountIdentifiers;
|
||||
abortControllers;
|
||||
allowInsecureConnection = false;
|
||||
// used for WorkloadIdentity
|
||||
tokenCredentialOptions;
|
||||
constructor(options) {
|
||||
const packageDetails = `azsdk-js-identity/${constants_js_1.SDK_VERSION}`;
|
||||
const userAgentPrefix = options?.userAgentOptions?.userAgentPrefix
|
||||
? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
|
||||
: `${packageDetails}`;
|
||||
const baseUri = getIdentityClientAuthorityHost(options);
|
||||
if (!baseUri.startsWith("https:")) {
|
||||
throw new Error("The authorityHost address must use the 'https' protocol.");
|
||||
}
|
||||
super({
|
||||
requestContentType: "application/json; charset=utf-8",
|
||||
retryOptions: {
|
||||
maxRetries: 3,
|
||||
},
|
||||
...options,
|
||||
userAgentOptions: {
|
||||
userAgentPrefix,
|
||||
},
|
||||
baseUri,
|
||||
});
|
||||
this.authorityHost = baseUri;
|
||||
this.abortControllers = new Map();
|
||||
this.allowLoggingAccountIdentifiers = options?.loggingOptions?.allowLoggingAccountIdentifiers;
|
||||
// used for WorkloadIdentity
|
||||
this.tokenCredentialOptions = { ...options };
|
||||
// used for ManagedIdentity
|
||||
if (options?.allowInsecureConnection) {
|
||||
this.allowInsecureConnection = options.allowInsecureConnection;
|
||||
}
|
||||
}
|
||||
async sendTokenRequest(request) {
|
||||
logging_js_1.logger.info(`IdentityClient: sending token request to [${request.url}]`);
|
||||
const response = await this.sendRequest(request);
|
||||
if (response.bodyAsText && (response.status === 200 || response.status === 201)) {
|
||||
const parsedBody = JSON.parse(response.bodyAsText);
|
||||
if (!parsedBody.access_token) {
|
||||
return null;
|
||||
}
|
||||
this.logIdentifiers(response);
|
||||
const token = {
|
||||
accessToken: {
|
||||
token: parsedBody.access_token,
|
||||
expiresOnTimestamp: (0, utils_js_1.parseExpirationTimestamp)(parsedBody),
|
||||
refreshAfterTimestamp: (0, utils_js_1.parseRefreshTimestamp)(parsedBody),
|
||||
tokenType: "Bearer",
|
||||
},
|
||||
refreshToken: parsedBody.refresh_token,
|
||||
};
|
||||
logging_js_1.logger.info(`IdentityClient: [${request.url}] token acquired, expires on ${token.accessToken.expiresOnTimestamp}`);
|
||||
return token;
|
||||
}
|
||||
else {
|
||||
const error = new errors_js_1.AuthenticationError(response.status, response.bodyAsText);
|
||||
logging_js_1.logger.warning(`IdentityClient: authentication error. HTTP status: ${response.status}, ${error.errorResponse.errorDescription}`);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
async refreshAccessToken(tenantId, clientId, scopes, refreshToken, clientSecret, options = {}) {
|
||||
if (refreshToken === undefined) {
|
||||
return null;
|
||||
}
|
||||
logging_js_1.logger.info(`IdentityClient: refreshing access token with client ID: ${clientId}, scopes: ${scopes} started`);
|
||||
const refreshParams = {
|
||||
grant_type: "refresh_token",
|
||||
client_id: clientId,
|
||||
refresh_token: refreshToken,
|
||||
scope: scopes,
|
||||
};
|
||||
if (clientSecret !== undefined) {
|
||||
refreshParams.client_secret = clientSecret;
|
||||
}
|
||||
const query = new URLSearchParams(refreshParams);
|
||||
return tracing_js_1.tracingClient.withSpan("IdentityClient.refreshAccessToken", options, async (updatedOptions) => {
|
||||
try {
|
||||
const urlSuffix = (0, identityTokenEndpoint_js_1.getIdentityTokenEndpointSuffix)(tenantId);
|
||||
const request = (0, core_rest_pipeline_1.createPipelineRequest)({
|
||||
url: `${this.authorityHost}/${tenantId}/${urlSuffix}`,
|
||||
method: "POST",
|
||||
body: query.toString(),
|
||||
abortSignal: options.abortSignal,
|
||||
headers: (0, core_rest_pipeline_1.createHttpHeaders)({
|
||||
Accept: "application/json",
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
}),
|
||||
tracingOptions: updatedOptions.tracingOptions,
|
||||
});
|
||||
const response = await this.sendTokenRequest(request);
|
||||
logging_js_1.logger.info(`IdentityClient: refreshed token for client ID: ${clientId}`);
|
||||
return response;
|
||||
}
|
||||
catch (err) {
|
||||
if (err.name === errors_js_1.AuthenticationErrorName &&
|
||||
err.errorResponse.error === "interaction_required") {
|
||||
// It's likely that the refresh token has expired, so
|
||||
// return null so that the credential implementation will
|
||||
// initiate the authentication flow again.
|
||||
logging_js_1.logger.info(`IdentityClient: interaction required for client ID: ${clientId}`);
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
logging_js_1.logger.warning(`IdentityClient: failed refreshing token for client ID: ${clientId}: ${err}`);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
// Here is a custom layer that allows us to abort requests that go through MSAL,
|
||||
// since MSAL doesn't allow us to pass options all the way through.
|
||||
generateAbortSignal(correlationId) {
|
||||
const controller = new AbortController();
|
||||
const controllers = this.abortControllers.get(correlationId) || [];
|
||||
controllers.push(controller);
|
||||
this.abortControllers.set(correlationId, controllers);
|
||||
const existingOnAbort = controller.signal.onabort;
|
||||
controller.signal.onabort = (...params) => {
|
||||
this.abortControllers.set(correlationId, undefined);
|
||||
if (existingOnAbort) {
|
||||
existingOnAbort.apply(controller.signal, params);
|
||||
}
|
||||
};
|
||||
return controller.signal;
|
||||
}
|
||||
abortRequests(correlationId) {
|
||||
const key = correlationId || noCorrelationId;
|
||||
const controllers = [
|
||||
...(this.abortControllers.get(key) || []),
|
||||
// MSAL passes no correlation ID to the get requests...
|
||||
...(this.abortControllers.get(noCorrelationId) || []),
|
||||
];
|
||||
if (!controllers.length) {
|
||||
return;
|
||||
}
|
||||
for (const controller of controllers) {
|
||||
controller.abort();
|
||||
}
|
||||
this.abortControllers.set(key, undefined);
|
||||
}
|
||||
getCorrelationId(options) {
|
||||
const parameter = options?.body
|
||||
?.split("&")
|
||||
.map((part) => part.split("="))
|
||||
.find(([key]) => key === "client-request-id");
|
||||
return parameter && parameter.length ? parameter[1] || noCorrelationId : noCorrelationId;
|
||||
}
|
||||
// The MSAL network module methods follow
|
||||
async sendGetRequestAsync(url, options) {
|
||||
const request = (0, core_rest_pipeline_1.createPipelineRequest)({
|
||||
url,
|
||||
method: "GET",
|
||||
body: options?.body,
|
||||
allowInsecureConnection: this.allowInsecureConnection,
|
||||
headers: (0, core_rest_pipeline_1.createHttpHeaders)(options?.headers),
|
||||
abortSignal: this.generateAbortSignal(noCorrelationId),
|
||||
});
|
||||
const response = await this.sendRequest(request);
|
||||
this.logIdentifiers(response);
|
||||
return {
|
||||
body: response.bodyAsText ? JSON.parse(response.bodyAsText) : undefined,
|
||||
headers: response.headers.toJSON(),
|
||||
status: response.status,
|
||||
};
|
||||
}
|
||||
async sendPostRequestAsync(url, options) {
|
||||
const request = (0, core_rest_pipeline_1.createPipelineRequest)({
|
||||
url,
|
||||
method: "POST",
|
||||
body: options?.body,
|
||||
headers: (0, core_rest_pipeline_1.createHttpHeaders)(options?.headers),
|
||||
allowInsecureConnection: this.allowInsecureConnection,
|
||||
// MSAL doesn't send the correlation ID on the get requests.
|
||||
abortSignal: this.generateAbortSignal(this.getCorrelationId(options)),
|
||||
});
|
||||
const response = await this.sendRequest(request);
|
||||
this.logIdentifiers(response);
|
||||
return {
|
||||
body: response.bodyAsText ? JSON.parse(response.bodyAsText) : undefined,
|
||||
headers: response.headers.toJSON(),
|
||||
status: response.status,
|
||||
};
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
getTokenCredentialOptions() {
|
||||
return this.tokenCredentialOptions;
|
||||
}
|
||||
/**
|
||||
* If allowLoggingAccountIdentifiers was set on the constructor options
|
||||
* we try to log the account identifiers by parsing the received access token.
|
||||
*
|
||||
* The account identifiers we try to log are:
|
||||
* - `appid`: The application or Client Identifier.
|
||||
* - `upn`: User Principal Name.
|
||||
* - It might not be available in some authentication scenarios.
|
||||
* - If it's not available, we put a placeholder: "No User Principal Name available".
|
||||
* - `tid`: Tenant Identifier.
|
||||
* - `oid`: Object Identifier of the authenticated user.
|
||||
*/
|
||||
logIdentifiers(response) {
|
||||
if (!this.allowLoggingAccountIdentifiers || !response.bodyAsText) {
|
||||
return;
|
||||
}
|
||||
const unavailableUpn = "No User Principal Name available";
|
||||
try {
|
||||
const parsed = response.parsedBody || JSON.parse(response.bodyAsText);
|
||||
const accessToken = parsed.access_token;
|
||||
if (!accessToken) {
|
||||
// Without an access token allowLoggingAccountIdentifiers isn't useful.
|
||||
return;
|
||||
}
|
||||
const base64Metadata = accessToken.split(".")[1];
|
||||
const { appid, upn, tid, oid } = JSON.parse(Buffer.from(base64Metadata, "base64").toString("utf8"));
|
||||
logging_js_1.logger.info(`[Authenticated account] Client ID: ${appid}. Tenant ID: ${tid}. User Principal Name: ${upn || unavailableUpn}. Object ID (user): ${oid}`);
|
||||
}
|
||||
catch (e) {
|
||||
logging_js_1.logger.warning("allowLoggingAccountIdentifiers was set, but we couldn't log the account information. Error:", e.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.IdentityClient = IdentityClient;
|
||||
//# sourceMappingURL=identityClient.js.map
|
||||
1
backend/node_modules/@azure/identity/dist/commonjs/client/identityClient.js.map
generated
vendored
Normal file
1
backend/node_modules/@azure/identity/dist/commonjs/client/identityClient.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user