From 04f6e98bcb21df6d0ebba854781b975bea490676 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Fri, 23 May 2025 04:22:15 +0200
Subject: [PATCH] Add --no-install-recommends to apt-get install command
---
packed/index.js | 12368 +++++++++++++++++++++++++++-------------------
src/pm.ts | 4 +-
2 files changed, 7308 insertions(+), 5064 deletions(-)
diff --git a/packed/index.js b/packed/index.js
index d0a378d..2a0dd77 100644
--- a/packed/index.js
+++ b/packed/index.js
@@ -1057,7 +1057,7 @@ var AptGetPackageManager = /** @class */ (function (_super) {
this.maybe_sudo_execute("apt-get update -y");
};
AptGetPackageManager.prototype.install = function (packages) {
- this.maybe_sudo_execute("apt-get install -y ".concat(packages.join(" ")));
+ this.maybe_sudo_execute("apt-get install --no-install-recommends -y ".concat(packages.join(" ")));
};
return AptGetPackageManager;
}(PackageManager));
@@ -35133,6 +35133,10 @@ class RpcOutputStreamController {
cmp: [],
};
this._closed = false;
+ // --- RpcOutputStream async iterator API
+ // iterator state.
+ // is undefined when no iterator has been acquired yet.
+ this._itState = { q: [] };
}
// --- RpcOutputStream callback API
onNext(callback) {
@@ -35232,10 +35236,6 @@ class RpcOutputStreamController {
* messages are queued.
*/
[Symbol.asyncIterator]() {
- // init the iterator state, enabling pushIt()
- if (!this._itState) {
- this._itState = { q: [] };
- }
// if we are closed, we are definitely not receiving any more messages.
// but we can't let the iterator get stuck. we want to either:
// a) finish the new iterator immediately, because we are completed
@@ -35268,8 +35268,6 @@ class RpcOutputStreamController {
// this either resolves a pending promise, or enqueues the result.
pushIt(result) {
let state = this._itState;
- if (!state)
- return;
// is the consumer waiting for us?
if (state.p) {
// yes, consumer is waiting for this promise.
@@ -36977,7 +36975,7 @@ Object.defineProperty(exports, "readMessageOption", ({ enumerable: true, get: fu
// Message operations via reflection
var reflection_type_check_1 = __nccwpck_require__(5167);
Object.defineProperty(exports, "ReflectionTypeCheck", ({ enumerable: true, get: function () { return reflection_type_check_1.ReflectionTypeCheck; } }));
-var reflection_create_1 = __nccwpck_require__(5726);
+var reflection_create_1 = __nccwpck_require__(488);
Object.defineProperty(exports, "reflectionCreate", ({ enumerable: true, get: function () { return reflection_create_1.reflectionCreate; } }));
var reflection_scalar_default_1 = __nccwpck_require__(9526);
Object.defineProperty(exports, "reflectionScalarDefault", ({ enumerable: true, get: function () { return reflection_scalar_default_1.reflectionScalarDefault; } }));
@@ -37173,7 +37171,7 @@ const reflection_json_reader_1 = __nccwpck_require__(6790);
const reflection_json_writer_1 = __nccwpck_require__(1094);
const reflection_binary_reader_1 = __nccwpck_require__(9611);
const reflection_binary_writer_1 = __nccwpck_require__(6907);
-const reflection_create_1 = __nccwpck_require__(5726);
+const reflection_create_1 = __nccwpck_require__(488);
const reflection_merge_partial_1 = __nccwpck_require__(8044);
const json_typings_1 = __nccwpck_require__(9999);
const json_format_contract_1 = __nccwpck_require__(9367);
@@ -38247,7 +38245,7 @@ exports.containsMessageType = containsMessageType;
/***/ }),
-/***/ 5726:
+/***/ 488:
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
"use strict";
@@ -72085,7 +72083,7 @@ exports.logger = (0, logger_1.createClientLogger)("core-client");
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.getOperationArgumentValueFromParameter = getOperationArgumentValueFromParameter;
exports.getOperationRequestInfo = getOperationRequestInfo;
-const state_js_1 = __nccwpck_require__(3345);
+const state_js_1 = __nccwpck_require__(5726);
/**
* @internal
* Retrieves the value to use for a given operation argument
@@ -73475,7 +73473,7 @@ function getCredentialScopes(options) {
/***/ }),
-/***/ 3345:
+/***/ 5726:
/***/ ((__unused_webpack_module, exports) => {
"use strict";
@@ -74198,6 +74196,7 @@ function toPipelineRequest(webResource, options = {}) {
proxySettings: webResource.proxySettings,
streamResponseStatusCodes: webResource.streamResponseStatusCodes,
agent: webResource.agent,
+ requestOverrides: webResource.requestOverrides,
});
if (options.originalRequest) {
newRequest[originalClientRequestSymbol] =
@@ -74225,6 +74224,7 @@ function toWebResourceLike(request, options) {
proxySettings: request.proxySettings,
streamResponseStatusCodes: request.streamResponseStatusCodes,
agent: request.agent,
+ requestOverrides: request.requestOverrides,
clone() {
throw new Error("Cannot clone a non-proxied WebResourceLike");
},
@@ -74269,6 +74269,7 @@ function toWebResourceLike(request, options) {
"proxySettings",
"streamResponseStatusCodes",
"agent",
+ "requestOverrides",
];
if (typeof prop === "string" && passThroughProps.includes(prop)) {
request[prop] = value;
@@ -75794,7 +75795,7 @@ exports.buildCreatePoller = buildCreatePoller;
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.DEFAULT_RETRY_POLICY_COUNT = exports.SDK_VERSION = void 0;
-exports.SDK_VERSION = "1.19.1";
+exports.SDK_VERSION = "1.20.0";
exports.DEFAULT_RETRY_POLICY_COUNT = 3;
//# sourceMappingURL=constants.js.map
@@ -75823,6 +75824,7 @@ const setClientRequestIdPolicy_js_1 = __nccwpck_require__(5686);
const agentPolicy_js_1 = __nccwpck_require__(8554);
const tlsPolicy_js_1 = __nccwpck_require__(5798);
const tracingPolicy_js_1 = __nccwpck_require__(3237);
+const wrapAbortSignalLikePolicy_js_1 = __nccwpck_require__(7466);
/**
* Create a new pipeline with a default set of customizable policies.
* @param options - Options to configure a custom pipeline.
@@ -75840,6 +75842,7 @@ function createPipelineFromOptions(options) {
pipeline.addPolicy((0, proxyPolicy_js_1.proxyPolicy)(options.proxyOptions));
pipeline.addPolicy((0, decompressResponsePolicy_js_1.decompressResponsePolicy)());
}
+ pipeline.addPolicy((0, wrapAbortSignalLikePolicy_js_1.wrapAbortSignalLikePolicy)());
pipeline.addPolicy((0, formDataPolicy_js_1.formDataPolicy)(), { beforePolicies: [multipartPolicy_js_1.multipartPolicyName] });
pipeline.addPolicy((0, userAgentPolicy_js_1.userAgentPolicy)(options.userAgentOptions));
pipeline.addPolicy((0, setClientRequestIdPolicy_js_1.setClientRequestIdPolicy)((_a = options.telemetryOptions) === null || _a === void 0 ? void 0 : _a.clientRequestIdHeaderName));
@@ -75872,19 +75875,37 @@ function createPipelineFromOptions(options) {
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.createDefaultHttpClient = createDefaultHttpClient;
-const nodeHttpClient_js_1 = __nccwpck_require__(195);
+const ts_http_runtime_1 = __nccwpck_require__(1958);
+const wrapAbortSignal_js_1 = __nccwpck_require__(1297);
/**
* Create the correct HttpClient for the current environment.
*/
function createDefaultHttpClient() {
- return (0, nodeHttpClient_js_1.createNodeHttpClient)();
+ const client = (0, ts_http_runtime_1.createDefaultHttpClient)();
+ return {
+ async sendRequest(request) {
+ // we wrap any AbortSignalLike here since the TypeSpec runtime expects a native AbortSignal.
+ // 99% of the time, this should be a no-op since a native AbortSignal is passed in.
+ const { abortSignal, cleanup } = request.abortSignal
+ ? (0, wrapAbortSignal_js_1.wrapAbortSignalLike)(request.abortSignal)
+ : {};
+ try {
+ // eslint-disable-next-line no-param-reassign
+ request.abortSignal = abortSignal;
+ return await client.sendRequest(request);
+ }
+ finally {
+ cleanup === null || cleanup === void 0 ? void 0 : cleanup();
+ }
+ },
+ };
}
//# sourceMappingURL=defaultHttpClient.js.map
/***/ }),
/***/ 192:
-/***/ ((__unused_webpack_module, exports) => {
+/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
"use strict";
@@ -75892,91 +75913,13 @@ function createDefaultHttpClient() {
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.createHttpHeaders = createHttpHeaders;
-function normalizeName(name) {
- return name.toLowerCase();
-}
-function* headerIterator(map) {
- for (const entry of map.values()) {
- yield [entry.name, entry.value];
- }
-}
-class HttpHeadersImpl {
- constructor(rawHeaders) {
- this._headersMap = new Map();
- if (rawHeaders) {
- for (const headerName of Object.keys(rawHeaders)) {
- this.set(headerName, rawHeaders[headerName]);
- }
- }
- }
- /**
- * Set a header in this collection with the provided name and value. The name is
- * case-insensitive.
- * @param name - The name of the header to set. This value is case-insensitive.
- * @param value - The value of the header to set.
- */
- set(name, value) {
- this._headersMap.set(normalizeName(name), { name, value: String(value).trim() });
- }
- /**
- * Get the header value for the provided header name, or undefined if no header exists in this
- * collection with the provided name.
- * @param name - The name of the header. This value is case-insensitive.
- */
- get(name) {
- var _a;
- return (_a = this._headersMap.get(normalizeName(name))) === null || _a === void 0 ? void 0 : _a.value;
- }
- /**
- * Get whether or not this header collection contains a header entry for the provided header name.
- * @param name - The name of the header to set. This value is case-insensitive.
- */
- has(name) {
- return this._headersMap.has(normalizeName(name));
- }
- /**
- * Remove the header with the provided headerName.
- * @param name - The name of the header to remove.
- */
- delete(name) {
- this._headersMap.delete(normalizeName(name));
- }
- /**
- * Get the JSON object representation of this HTTP header collection.
- */
- toJSON(options = {}) {
- const result = {};
- if (options.preserveCase) {
- for (const entry of this._headersMap.values()) {
- result[entry.name] = entry.value;
- }
- }
- else {
- for (const [normalizedName, entry] of this._headersMap) {
- result[normalizedName] = entry.value;
- }
- }
- return result;
- }
- /**
- * Get the string representation of this HTTP header collection.
- */
- toString() {
- return JSON.stringify(this.toJSON({ preserveCase: true }));
- }
- /**
- * Iterate over tuples of header [name, value] pairs.
- */
- [Symbol.iterator]() {
- return headerIterator(this._headersMap);
- }
-}
+const ts_http_runtime_1 = __nccwpck_require__(1958);
/**
* Creates an object that satisfies the `HttpHeaders` interface.
* @param rawHeaders - A simple object representing initial headers
*/
function createHttpHeaders(rawHeaders) {
- return new HttpHeadersImpl(rawHeaders);
+ return (0, ts_http_runtime_1.createHttpHeaders)(rawHeaders);
}
//# sourceMappingURL=httpHeaders.js.map
@@ -76082,7 +76025,7 @@ exports.logger = (0, logger_1.createClientLogger)("core-rest-pipeline");
/***/ }),
-/***/ 195:
+/***/ 9590:
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
"use strict";
@@ -76090,631 +76033,420 @@ exports.logger = (0, logger_1.createClientLogger)("core-rest-pipeline");
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", ({ value: true }));
-exports.getBodyLength = getBodyLength;
-exports.createNodeHttpClient = createNodeHttpClient;
-const tslib_1 = __nccwpck_require__(1860);
-const http = tslib_1.__importStar(__nccwpck_require__(7067));
-const https = tslib_1.__importStar(__nccwpck_require__(4708));
-const zlib = tslib_1.__importStar(__nccwpck_require__(8522));
-const node_stream_1 = __nccwpck_require__(7075);
-const abort_controller_1 = __nccwpck_require__(3287);
-const httpHeaders_js_1 = __nccwpck_require__(192);
-const restError_js_1 = __nccwpck_require__(8666);
-const log_js_1 = __nccwpck_require__(544);
-const sanitizer_js_1 = __nccwpck_require__(5204);
-const DEFAULT_TLS_SETTINGS = {};
-function isReadableStream(body) {
- return body && typeof body.pipe === "function";
+exports.createEmptyPipeline = createEmptyPipeline;
+const ts_http_runtime_1 = __nccwpck_require__(1958);
+/**
+ * Creates a totally empty pipeline.
+ * Useful for testing or creating a custom one.
+ */
+function createEmptyPipeline() {
+ return (0, ts_http_runtime_1.createEmptyPipeline)();
}
-function isStreamComplete(stream) {
- if (stream.readable === false) {
- return Promise.resolve();
- }
- return new Promise((resolve) => {
- const handler = () => {
- resolve();
- stream.removeListener("close", handler);
- stream.removeListener("end", handler);
- stream.removeListener("error", handler);
- };
- stream.on("close", handler);
- stream.on("end", handler);
- stream.on("error", handler);
- });
+//# sourceMappingURL=pipeline.js.map
+
+/***/ }),
+
+/***/ 5709:
+/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
+
+"use strict";
+
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT License.
+Object.defineProperty(exports, "__esModule", ({ value: true }));
+exports.createPipelineRequest = createPipelineRequest;
+const ts_http_runtime_1 = __nccwpck_require__(1958);
+/**
+ * Creates a new pipeline request with the given options.
+ * This method is to allow for the easy setting of default values and not required.
+ * @param options - The options to create the request with.
+ */
+function createPipelineRequest(options) {
+ // Cast required due to difference between ts-http-runtime requiring AbortSignal while core-rest-pipeline allows
+ // the more generic AbortSignalLike. The wrapAbortSignalLike pipeline policy will take care of ensuring that any AbortSignalLike in the request
+ // is converted into a true AbortSignal.
+ return (0, ts_http_runtime_1.createPipelineRequest)(options);
}
-function isArrayBuffer(body) {
- return body && typeof body.byteLength === "number";
+//# sourceMappingURL=pipelineRequest.js.map
+
+/***/ }),
+
+/***/ 8554:
+/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
+
+"use strict";
+
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT License.
+Object.defineProperty(exports, "__esModule", ({ value: true }));
+exports.agentPolicyName = void 0;
+exports.agentPolicy = agentPolicy;
+const policies_1 = __nccwpck_require__(4960);
+/**
+ * Name of the Agent Policy
+ */
+exports.agentPolicyName = policies_1.agentPolicyName;
+/**
+ * Gets a pipeline policy that sets http.agent
+ */
+function agentPolicy(agent) {
+ return (0, policies_1.agentPolicy)(agent);
}
-class ReportTransform extends node_stream_1.Transform {
- // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
- _transform(chunk, _encoding, callback) {
- this.push(chunk);
- this.loadedBytes += chunk.length;
- try {
- this.progressCallback({ loadedBytes: this.loadedBytes });
- callback();
- }
- catch (e) {
- callback(e);
- }
- }
- constructor(progressCallback) {
- super();
- this.loadedBytes = 0;
- this.progressCallback = progressCallback;
- }
+//# sourceMappingURL=agentPolicy.js.map
+
+/***/ }),
+
+/***/ 2262:
+/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
+
+"use strict";
+
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT License.
+Object.defineProperty(exports, "__esModule", ({ value: true }));
+exports.auxiliaryAuthenticationHeaderPolicyName = void 0;
+exports.auxiliaryAuthenticationHeaderPolicy = auxiliaryAuthenticationHeaderPolicy;
+const tokenCycler_js_1 = __nccwpck_require__(9202);
+const log_js_1 = __nccwpck_require__(544);
+/**
+ * The programmatic identifier of the auxiliaryAuthenticationHeaderPolicy.
+ */
+exports.auxiliaryAuthenticationHeaderPolicyName = "auxiliaryAuthenticationHeaderPolicy";
+const AUTHORIZATION_AUXILIARY_HEADER = "x-ms-authorization-auxiliary";
+async function sendAuthorizeRequest(options) {
+ var _a, _b;
+ const { scopes, getAccessToken, request } = options;
+ const getTokenOptions = {
+ abortSignal: request.abortSignal,
+ tracingOptions: request.tracingOptions,
+ };
+ return (_b = (_a = (await getAccessToken(scopes, getTokenOptions))) === null || _a === void 0 ? void 0 : _a.token) !== null && _b !== void 0 ? _b : "";
}
/**
- * A HttpClient implementation that uses Node's "https" module to send HTTPS requests.
- * @internal
+ * A policy for external tokens to `x-ms-authorization-auxiliary` header.
+ * This header will be used when creating a cross-tenant application we may need to handle authentication requests
+ * for resources that are in different tenants.
+ * You could see [ARM docs](https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/authenticate-multi-tenant) for a rundown of how this feature works
*/
-class NodeHttpClient {
- constructor() {
- this.cachedHttpsAgents = new WeakMap();
- }
- /**
- * Makes a request over an underlying transport layer and returns the response.
- * @param request - The request to be made.
- */
- async sendRequest(request) {
- var _a, _b, _c;
- const abortController = new AbortController();
- let abortListener;
- if (request.abortSignal) {
- if (request.abortSignal.aborted) {
- throw new abort_controller_1.AbortError("The operation was aborted. Request has already been canceled.");
- }
- abortListener = (event) => {
- if (event.type === "abort") {
- abortController.abort();
- }
- };
- request.abortSignal.addEventListener("abort", abortListener);
- }
- let timeoutId;
- if (request.timeout > 0) {
- timeoutId = setTimeout(() => {
- const sanitizer = new sanitizer_js_1.Sanitizer();
- log_js_1.logger.info(`request to '${sanitizer.sanitizeUrl(request.url)}' timed out. canceling...`);
- abortController.abort();
- }, request.timeout);
- }
- const acceptEncoding = request.headers.get("Accept-Encoding");
- const shouldDecompress = (acceptEncoding === null || acceptEncoding === void 0 ? void 0 : acceptEncoding.includes("gzip")) || (acceptEncoding === null || acceptEncoding === void 0 ? void 0 : acceptEncoding.includes("deflate"));
- let body = typeof request.body === "function" ? request.body() : request.body;
- if (body && !request.headers.has("Content-Length")) {
- const bodyLength = getBodyLength(body);
- if (bodyLength !== null) {
- request.headers.set("Content-Length", bodyLength);
- }
- }
- let responseStream;
- try {
- if (body && request.onUploadProgress) {
- const onUploadProgress = request.onUploadProgress;
- const uploadReportStream = new ReportTransform(onUploadProgress);
- uploadReportStream.on("error", (e) => {
- log_js_1.logger.error("Error in upload progress", e);
- });
- if (isReadableStream(body)) {
- body.pipe(uploadReportStream);
- }
- else {
- uploadReportStream.end(body);
- }
- body = uploadReportStream;
- }
- const res = await this.makeRequest(request, abortController, body);
- if (timeoutId !== undefined) {
- clearTimeout(timeoutId);
- }
- const headers = getResponseHeaders(res);
- const status = (_a = res.statusCode) !== null && _a !== void 0 ? _a : 0;
- const response = {
- status,
- headers,
- request,
- };
- // Responses to HEAD must not have a body.
- // If they do return a body, that body must be ignored.
- if (request.method === "HEAD") {
- // call resume() and not destroy() to avoid closing the socket
- // and losing keep alive
- res.resume();
- return response;
- }
- responseStream = shouldDecompress ? getDecodedResponseStream(res, headers) : res;
- const onDownloadProgress = request.onDownloadProgress;
- if (onDownloadProgress) {
- const downloadReportStream = new ReportTransform(onDownloadProgress);
- downloadReportStream.on("error", (e) => {
- log_js_1.logger.error("Error in download progress", e);
- });
- responseStream.pipe(downloadReportStream);
- responseStream = downloadReportStream;
- }
- if (
- // Value of POSITIVE_INFINITY in streamResponseStatusCodes is considered as any status code
- ((_b = request.streamResponseStatusCodes) === null || _b === void 0 ? void 0 : _b.has(Number.POSITIVE_INFINITY)) ||
- ((_c = request.streamResponseStatusCodes) === null || _c === void 0 ? void 0 : _c.has(response.status))) {
- response.readableStreamBody = responseStream;
- }
- else {
- response.bodyAsText = await streamToText(responseStream);
- }
- return response;
- }
- finally {
- // clean up event listener
- if (request.abortSignal && abortListener) {
- let uploadStreamDone = Promise.resolve();
- if (isReadableStream(body)) {
- uploadStreamDone = isStreamComplete(body);
- }
- let downloadStreamDone = Promise.resolve();
- if (isReadableStream(responseStream)) {
- downloadStreamDone = isStreamComplete(responseStream);
- }
- Promise.all([uploadStreamDone, downloadStreamDone])
- .then(() => {
- var _a;
- // eslint-disable-next-line promise/always-return
- if (abortListener) {
- (_a = request.abortSignal) === null || _a === void 0 ? void 0 : _a.removeEventListener("abort", abortListener);
- }
- })
- .catch((e) => {
- log_js_1.logger.warning("Error when cleaning up abortListener on httpRequest", e);
- });
+function auxiliaryAuthenticationHeaderPolicy(options) {
+ const { credentials, scopes } = options;
+ const logger = options.logger || log_js_1.logger;
+ const tokenCyclerMap = new WeakMap();
+ return {
+ name: exports.auxiliaryAuthenticationHeaderPolicyName,
+ async sendRequest(request, next) {
+ if (!request.url.toLowerCase().startsWith("https://")) {
+ throw new Error("Bearer token authentication for auxiliary header is not permitted for non-TLS protected (non-https) URLs.");
}
- }
- }
- makeRequest(request, abortController, body) {
- var _a;
- const url = new URL(request.url);
- const isInsecure = url.protocol !== "https:";
- if (isInsecure && !request.allowInsecureConnection) {
- throw new Error(`Cannot connect to ${request.url} while allowInsecureConnection is false.`);
- }
- const agent = (_a = request.agent) !== null && _a !== void 0 ? _a : this.getOrCreateAgent(request, isInsecure);
- const options = {
- agent,
- hostname: url.hostname,
- path: `${url.pathname}${url.search}`,
- port: url.port,
- method: request.method,
- headers: request.headers.toJSON({ preserveCase: true }),
- };
- return new Promise((resolve, reject) => {
- const req = isInsecure ? http.request(options, resolve) : https.request(options, resolve);
- req.once("error", (err) => {
- var _a;
- reject(new restError_js_1.RestError(err.message, { code: (_a = err.code) !== null && _a !== void 0 ? _a : restError_js_1.RestError.REQUEST_SEND_ERROR, request }));
- });
- abortController.signal.addEventListener("abort", () => {
- const abortError = new abort_controller_1.AbortError("The operation was aborted. Rejecting from abort signal callback while making request.");
- req.destroy(abortError);
- reject(abortError);
- });
- if (body && isReadableStream(body)) {
- body.pipe(req);
+ if (!credentials || credentials.length === 0) {
+ logger.info(`${exports.auxiliaryAuthenticationHeaderPolicyName} header will not be set due to empty credentials.`);
+ return next(request);
}
- else if (body) {
- if (typeof body === "string" || Buffer.isBuffer(body)) {
- req.end(body);
- }
- else if (isArrayBuffer(body)) {
- req.end(ArrayBuffer.isView(body) ? Buffer.from(body.buffer) : Buffer.from(body));
- }
- else {
- log_js_1.logger.error("Unrecognized body type", body);
- reject(new restError_js_1.RestError("Unrecognized body type"));
+ const tokenPromises = [];
+ for (const credential of credentials) {
+ let getAccessToken = tokenCyclerMap.get(credential);
+ if (!getAccessToken) {
+ getAccessToken = (0, tokenCycler_js_1.createTokenCycler)(credential);
+ tokenCyclerMap.set(credential, getAccessToken);
}
+ tokenPromises.push(sendAuthorizeRequest({
+ scopes: Array.isArray(scopes) ? scopes : [scopes],
+ request,
+ getAccessToken,
+ logger,
+ }));
}
- else {
- // streams don't like "undefined" being passed as data
- req.end();
+ const auxiliaryTokens = (await Promise.all(tokenPromises)).filter((token) => Boolean(token));
+ if (auxiliaryTokens.length === 0) {
+ logger.warning(`None of the auxiliary tokens are valid. ${AUTHORIZATION_AUXILIARY_HEADER} header will not be set.`);
+ return next(request);
}
- });
+ request.headers.set(AUTHORIZATION_AUXILIARY_HEADER, auxiliaryTokens.map((token) => `Bearer ${token}`).join(", "));
+ return next(request);
+ },
+ };
+}
+//# sourceMappingURL=auxiliaryAuthenticationHeaderPolicy.js.map
+
+/***/ }),
+
+/***/ 6925:
+/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
+
+"use strict";
+
+// Copyright (c) Microsoft Corporation.
+// Licensed under the MIT License.
+Object.defineProperty(exports, "__esModule", ({ value: true }));
+exports.bearerTokenAuthenticationPolicyName = void 0;
+exports.bearerTokenAuthenticationPolicy = bearerTokenAuthenticationPolicy;
+exports.parseChallenges = parseChallenges;
+const tokenCycler_js_1 = __nccwpck_require__(9202);
+const log_js_1 = __nccwpck_require__(544);
+const restError_js_1 = __nccwpck_require__(8666);
+/**
+ * The programmatic identifier of the bearerTokenAuthenticationPolicy.
+ */
+exports.bearerTokenAuthenticationPolicyName = "bearerTokenAuthenticationPolicy";
+/**
+ * Try to send the given request.
+ *
+ * When a response is received, returns a tuple of the response received and, if the response was received
+ * inside a thrown RestError, the RestError that was thrown.
+ *
+ * Otherwise, if an error was thrown while sending the request that did not provide an underlying response, it
+ * will be rethrown.
+ */
+async function trySendRequest(request, next) {
+ try {
+ return [await next(request), undefined];
}
- getOrCreateAgent(request, isInsecure) {
- var _a;
- const disableKeepAlive = request.disableKeepAlive;
- // Handle Insecure requests first
- if (isInsecure) {
- if (disableKeepAlive) {
- // keepAlive:false is the default so we don't need a custom Agent
- return http.globalAgent;
- }
- if (!this.cachedHttpAgent) {
- // If there is no cached agent create a new one and cache it.
- this.cachedHttpAgent = new http.Agent({ keepAlive: true });
- }
- return this.cachedHttpAgent;
+ catch (e) {
+ if ((0, restError_js_1.isRestError)(e) && e.response) {
+ return [e.response, e];
}
else {
- if (disableKeepAlive && !request.tlsSettings) {
- // When there are no tlsSettings and keepAlive is false
- // we don't need a custom agent
- return https.globalAgent;
- }
- // We use the tlsSettings to index cached clients
- const tlsSettings = (_a = request.tlsSettings) !== null && _a !== void 0 ? _a : DEFAULT_TLS_SETTINGS;
- // Get the cached agent or create a new one with the
- // provided values for keepAlive and tlsSettings
- let agent = this.cachedHttpsAgents.get(tlsSettings);
- if (agent && agent.options.keepAlive === !disableKeepAlive) {
- return agent;
- }
- log_js_1.logger.info("No cached TLS Agent exist, creating a new Agent");
- agent = new https.Agent(Object.assign({
- // keepAlive is true if disableKeepAlive is false.
- keepAlive: !disableKeepAlive }, tlsSettings));
- this.cachedHttpsAgents.set(tlsSettings, agent);
- return agent;
+ throw e;
}
}
}
-function getResponseHeaders(res) {
- const headers = (0, httpHeaders_js_1.createHttpHeaders)();
- for (const header of Object.keys(res.headers)) {
- const value = res.headers[header];
- if (Array.isArray(value)) {
- if (value.length > 0) {
- headers.set(header, value[0]);
- }
- }
- else if (value) {
- headers.set(header, value);
- }
+/
(Patch may be truncated, please check the link at the top of this post.)