rittenhop-dev/versions/5.94.2/node_modules/@aws-sdk/util-user-agent-node/dist-cjs/index.js
2024-09-23 19:40:12 -04:00

42 lines
1.6 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.defaultUserAgent = exports.UA_APP_ID_INI_NAME = exports.UA_APP_ID_ENV_NAME = void 0;
const node_config_provider_1 = require("@aws-sdk/node-config-provider");
const os_1 = require("os");
const process_1 = require("process");
const is_crt_available_1 = require("./is-crt-available");
exports.UA_APP_ID_ENV_NAME = "AWS_SDK_UA_APP_ID";
exports.UA_APP_ID_INI_NAME = "sdk-ua-app-id";
const defaultUserAgent = ({ serviceId, clientVersion }) => {
const sections = [
["aws-sdk-js", clientVersion],
[`os/${(0, os_1.platform)()}`, (0, os_1.release)()],
["lang/js"],
["md/nodejs", `${process_1.versions.node}`],
];
const crtAvailable = (0, is_crt_available_1.isCrtAvailable)();
if (crtAvailable) {
sections.push(crtAvailable);
}
if (serviceId) {
sections.push([`api/${serviceId}`, clientVersion]);
}
if (process_1.env.AWS_EXECUTION_ENV) {
sections.push([`exec-env/${process_1.env.AWS_EXECUTION_ENV}`]);
}
const appIdPromise = (0, node_config_provider_1.loadConfig)({
environmentVariableSelector: (env) => env[exports.UA_APP_ID_ENV_NAME],
configFileSelector: (profile) => profile[exports.UA_APP_ID_INI_NAME],
default: undefined,
})();
let resolvedUserAgent = undefined;
return async () => {
if (!resolvedUserAgent) {
const appId = await appIdPromise;
resolvedUserAgent = appId ? [...sections, [`app/${appId}`]] : [...sections];
}
return resolvedUserAgent;
};
};
exports.defaultUserAgent = defaultUserAgent;