@aws-sdk/util-user-agent-node 3.972.13 → 3.973.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-cjs/index.js +68 -8
- package/dist-es/defaultUserAgent.js +7 -2
- package/dist-es/getRuntimeUserAgentPair.js +1 -1
- package/dist-es/getSanitizedTypeScriptVersion.js +9 -0
- package/dist-es/getTypeScriptPackageJsonPaths.js +17 -0
- package/dist-es/getTypeScriptUserAgentPair.js +29 -0
- package/dist-types/getSanitizedTypeScriptVersion.d.ts +8 -0
- package/dist-types/getTypeScriptPackageJsonPaths.d.ts +10 -0
- package/dist-types/getTypeScriptUserAgentPair.d.ts +6 -0
- package/dist-types/is-crt-available.d.ts +1 -1
- package/dist-types/nodeAppIdConfigOptions.d.ts +1 -1
- package/dist-types/ts3.4/getSanitizedTypeScriptVersion.d.ts +3 -0
- package/dist-types/ts3.4/getTypeScriptPackageJsonPaths.d.ts +3 -0
- package/dist-types/ts3.4/getTypeScriptUserAgentPair.d.ts +4 -0
- package/package.json +3 -3
package/dist-cjs/index.js
CHANGED
|
@@ -1,17 +1,73 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var node_os = require('node:os');
|
|
4
|
+
var node_process = require('node:process');
|
|
5
|
+
var promises = require('node:fs/promises');
|
|
6
|
+
var node_path = require('node:path');
|
|
5
7
|
var middlewareUserAgent = require('@aws-sdk/middleware-user-agent');
|
|
6
8
|
|
|
7
9
|
const getRuntimeUserAgentPair = () => {
|
|
8
10
|
const runtimesToCheck = ["deno", "bun", "llrt"];
|
|
9
11
|
for (const runtime of runtimesToCheck) {
|
|
10
|
-
if (
|
|
11
|
-
return [`md/${runtime}`,
|
|
12
|
+
if (node_process.versions[runtime]) {
|
|
13
|
+
return [`md/${runtime}`, node_process.versions[runtime]];
|
|
12
14
|
}
|
|
13
15
|
}
|
|
14
|
-
return ["md/nodejs",
|
|
16
|
+
return ["md/nodejs", node_process.versions.node];
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const SEMVER_REGEX = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*)?$/;
|
|
20
|
+
const getSanitizedTypeScriptVersion = (version = "") => {
|
|
21
|
+
const match = version.match(SEMVER_REGEX);
|
|
22
|
+
if (!match) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
const [major, minor, patch, prerelease] = [match[1], match[2], match[3], match[4]];
|
|
26
|
+
return prerelease ? `${major}.${minor}.${patch}-${prerelease}` : `${major}.${minor}.${patch}`;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const typescriptPackageJsonPath = node_path.join("node_modules", "typescript", "package.json");
|
|
30
|
+
const getTypeScriptPackageJsonPaths = (dirname) => {
|
|
31
|
+
const cwdPath = node_path.join(process.cwd(), typescriptPackageJsonPath);
|
|
32
|
+
if (!dirname) {
|
|
33
|
+
return [cwdPath];
|
|
34
|
+
}
|
|
35
|
+
const normalizedPath = node_path.normalize(dirname);
|
|
36
|
+
const parts = normalizedPath.split(node_path.sep);
|
|
37
|
+
const nodeModulesIndex = parts.indexOf("node_modules");
|
|
38
|
+
const parentDir = nodeModulesIndex !== -1 ? parts.slice(0, nodeModulesIndex).join(node_path.sep) : dirname;
|
|
39
|
+
const parentDirPath = node_path.join(parentDir, typescriptPackageJsonPath);
|
|
40
|
+
if (cwdPath === parentDirPath) {
|
|
41
|
+
return [cwdPath];
|
|
42
|
+
}
|
|
43
|
+
return [parentDirPath, cwdPath];
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
let tscVersion;
|
|
47
|
+
const getTypeScriptUserAgentPair = async () => {
|
|
48
|
+
if (tscVersion === null) {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
else if (typeof tscVersion === "string") {
|
|
52
|
+
return ["md/tsc", tscVersion];
|
|
53
|
+
}
|
|
54
|
+
const dirname = typeof __dirname !== "undefined" ? __dirname : undefined;
|
|
55
|
+
for (const typescriptPackageJsonPath of getTypeScriptPackageJsonPaths(dirname)) {
|
|
56
|
+
try {
|
|
57
|
+
const packageJson = await promises.readFile(typescriptPackageJsonPath, "utf-8");
|
|
58
|
+
const { version } = JSON.parse(packageJson);
|
|
59
|
+
const sanitizedVersion = getSanitizedTypeScriptVersion(version);
|
|
60
|
+
if (typeof sanitizedVersion !== "string") {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
tscVersion = sanitizedVersion;
|
|
64
|
+
return ["md/tsc", tscVersion];
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
tscVersion = null;
|
|
70
|
+
return undefined;
|
|
15
71
|
};
|
|
16
72
|
|
|
17
73
|
const crtAvailability = {
|
|
@@ -31,10 +87,14 @@ const createDefaultUserAgentProvider = ({ serviceId, clientVersion }) => {
|
|
|
31
87
|
const sections = [
|
|
32
88
|
["aws-sdk-js", clientVersion],
|
|
33
89
|
["ua", "2.1"],
|
|
34
|
-
[`os/${
|
|
90
|
+
[`os/${node_os.platform()}`, node_os.release()],
|
|
35
91
|
["lang/js"],
|
|
36
92
|
runtimeUserAgentPair,
|
|
37
93
|
];
|
|
94
|
+
const typescriptUserAgentPair = await getTypeScriptUserAgentPair();
|
|
95
|
+
if (typescriptUserAgentPair) {
|
|
96
|
+
sections.push(typescriptUserAgentPair);
|
|
97
|
+
}
|
|
38
98
|
const crtAvailable = isCrtAvailable();
|
|
39
99
|
if (crtAvailable) {
|
|
40
100
|
sections.push(crtAvailable);
|
|
@@ -42,8 +102,8 @@ const createDefaultUserAgentProvider = ({ serviceId, clientVersion }) => {
|
|
|
42
102
|
if (serviceId) {
|
|
43
103
|
sections.push([`api/${serviceId}`, clientVersion]);
|
|
44
104
|
}
|
|
45
|
-
if (
|
|
46
|
-
sections.push([`exec-env/${
|
|
105
|
+
if (node_process.env.AWS_EXECUTION_ENV) {
|
|
106
|
+
sections.push([`exec-env/${node_process.env.AWS_EXECUTION_ENV}`]);
|
|
47
107
|
}
|
|
48
108
|
const appId = await config?.userAgentAppId?.();
|
|
49
109
|
const resolvedUserAgent = appId ? [...sections, [`app/${appId}`]] : [...sections];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { platform, release } from "os";
|
|
2
|
-
import { env } from "process";
|
|
1
|
+
import { platform, release } from "node:os";
|
|
2
|
+
import { env } from "node:process";
|
|
3
3
|
import { getRuntimeUserAgentPair } from "./getRuntimeUserAgentPair";
|
|
4
|
+
import { getTypeScriptUserAgentPair } from "./getTypeScriptUserAgentPair";
|
|
4
5
|
import { isCrtAvailable } from "./is-crt-available";
|
|
5
6
|
export { crtAvailability } from "./crt-availability";
|
|
6
7
|
export const createDefaultUserAgentProvider = ({ serviceId, clientVersion }) => {
|
|
@@ -13,6 +14,10 @@ export const createDefaultUserAgentProvider = ({ serviceId, clientVersion }) =>
|
|
|
13
14
|
["lang/js"],
|
|
14
15
|
runtimeUserAgentPair,
|
|
15
16
|
];
|
|
17
|
+
const typescriptUserAgentPair = await getTypeScriptUserAgentPair();
|
|
18
|
+
if (typescriptUserAgentPair) {
|
|
19
|
+
sections.push(typescriptUserAgentPair);
|
|
20
|
+
}
|
|
16
21
|
const crtAvailable = isCrtAvailable();
|
|
17
22
|
if (crtAvailable) {
|
|
18
23
|
sections.push(crtAvailable);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const SEMVER_REGEX = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*)?$/;
|
|
2
|
+
export const getSanitizedTypeScriptVersion = (version = "") => {
|
|
3
|
+
const match = version.match(SEMVER_REGEX);
|
|
4
|
+
if (!match) {
|
|
5
|
+
return undefined;
|
|
6
|
+
}
|
|
7
|
+
const [major, minor, patch, prerelease] = [match[1], match[2], match[3], match[4]];
|
|
8
|
+
return prerelease ? `${major}.${minor}.${patch}-${prerelease}` : `${major}.${minor}.${patch}`;
|
|
9
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { join, normalize, sep } from "node:path";
|
|
2
|
+
const typescriptPackageJsonPath = join("node_modules", "typescript", "package.json");
|
|
3
|
+
export const getTypeScriptPackageJsonPaths = (dirname) => {
|
|
4
|
+
const cwdPath = join(process.cwd(), typescriptPackageJsonPath);
|
|
5
|
+
if (!dirname) {
|
|
6
|
+
return [cwdPath];
|
|
7
|
+
}
|
|
8
|
+
const normalizedPath = normalize(dirname);
|
|
9
|
+
const parts = normalizedPath.split(sep);
|
|
10
|
+
const nodeModulesIndex = parts.indexOf("node_modules");
|
|
11
|
+
const parentDir = nodeModulesIndex !== -1 ? parts.slice(0, nodeModulesIndex).join(sep) : dirname;
|
|
12
|
+
const parentDirPath = join(parentDir, typescriptPackageJsonPath);
|
|
13
|
+
if (cwdPath === parentDirPath) {
|
|
14
|
+
return [cwdPath];
|
|
15
|
+
}
|
|
16
|
+
return [parentDirPath, cwdPath];
|
|
17
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { getSanitizedTypeScriptVersion } from "./getSanitizedTypeScriptVersion";
|
|
3
|
+
import { getTypeScriptPackageJsonPaths } from "./getTypeScriptPackageJsonPaths";
|
|
4
|
+
let tscVersion;
|
|
5
|
+
export const getTypeScriptUserAgentPair = async () => {
|
|
6
|
+
if (tscVersion === null) {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
else if (typeof tscVersion === "string") {
|
|
10
|
+
return ["md/tsc", tscVersion];
|
|
11
|
+
}
|
|
12
|
+
const dirname = typeof __dirname !== "undefined" ? __dirname : undefined;
|
|
13
|
+
for (const typescriptPackageJsonPath of getTypeScriptPackageJsonPaths(dirname)) {
|
|
14
|
+
try {
|
|
15
|
+
const packageJson = await readFile(typescriptPackageJsonPath, "utf-8");
|
|
16
|
+
const { version } = JSON.parse(packageJson);
|
|
17
|
+
const sanitizedVersion = getSanitizedTypeScriptVersion(version);
|
|
18
|
+
if (typeof sanitizedVersion !== "string") {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
tscVersion = sanitizedVersion;
|
|
22
|
+
return ["md/tsc", tscVersion];
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
tscVersion = null;
|
|
28
|
+
return undefined;
|
|
29
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validates a semver string (with optional pre-release and/or build metadata).
|
|
3
|
+
* If valid, returns the version string with build metadata stripped.
|
|
4
|
+
* Returns undefined if the string is not a valid semver.
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export declare const getSanitizedTypeScriptVersion: (version?: string) => string | undefined;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns candidate paths to the TypeScript package.json file derived from the current
|
|
3
|
+
* working directory and, if provided, from the given directory.
|
|
4
|
+
*
|
|
5
|
+
* @param dirname - Optional directory path to derive an additional candidate path from.
|
|
6
|
+
* @returns An array of unique candidate paths to the TypeScript package.json file.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export declare const getTypeScriptPackageJsonPaths: (dirname?: string) => string[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/util-user-agent-node",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.973.1",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "concurrently 'yarn:build:types' 'yarn:build:es' && yarn build:cjs",
|
|
6
6
|
"build:cjs": "node ../../scripts/compilation/inline util-user-agent-node",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
},
|
|
25
25
|
"license": "Apache-2.0",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@aws-sdk/middleware-user-agent": "^3.972.
|
|
28
|
-
"@aws-sdk/types": "^3.973.
|
|
27
|
+
"@aws-sdk/middleware-user-agent": "^3.972.16",
|
|
28
|
+
"@aws-sdk/types": "^3.973.4",
|
|
29
29
|
"@smithy/node-config-provider": "^4.3.10",
|
|
30
30
|
"@smithy/types": "^4.13.0",
|
|
31
31
|
"tslib": "^2.6.2"
|