@socketsecurity/lib 5.18.1 → 5.19.0
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/CHANGELOG.md +49 -0
- package/README.md +6 -5
- package/dist/abort.d.ts +3 -0
- package/dist/abort.js +1 -0
- package/dist/agent.d.ts +66 -49
- package/dist/agent.js +51 -50
- package/dist/ansi.d.ts +2 -5
- package/dist/ansi.js +3 -2
- package/dist/archives.d.ts +25 -21
- package/dist/archives.js +35 -34
- package/dist/argv/flags.d.ts +100 -91
- package/dist/argv/flags.js +88 -87
- package/dist/argv/parse.d.ts +30 -40
- package/dist/argv/parse.js +33 -32
- package/dist/arrays.d.ts +4 -8
- package/dist/arrays.js +1 -0
- package/dist/bin.d.ts +7 -5
- package/dist/bin.js +52 -29
- package/dist/cacache.d.ts +13 -12
- package/dist/cacache.js +9 -8
- package/dist/cache-with-ttl.d.ts +53 -35
- package/dist/cache-with-ttl.js +1 -0
- package/dist/colors.d.ts +5 -5
- package/dist/colors.js +1 -0
- package/dist/constants/agents.d.ts +5 -9
- package/dist/constants/agents.js +3 -2
- package/dist/constants/core.d.ts +5 -10
- package/dist/constants/core.js +2 -1
- package/dist/constants/encoding.d.ts +3 -3
- package/dist/constants/encoding.js +1 -0
- package/dist/constants/github.d.ts +3 -3
- package/dist/constants/github.js +1 -0
- package/dist/constants/licenses.d.ts +9 -2
- package/dist/constants/licenses.js +1 -0
- package/dist/constants/lifecycle-script-names.js +1 -0
- package/dist/constants/maintained-node-versions.d.ts +3 -0
- package/dist/constants/maintained-node-versions.js +1 -0
- package/dist/constants/node.d.ts +125 -16
- package/dist/constants/node.js +74 -73
- package/dist/constants/package-default-node-range.d.ts +3 -1
- package/dist/constants/package-default-node-range.js +2 -1
- package/dist/constants/package-default-socket-categories.d.ts +0 -1
- package/dist/constants/package-default-socket-categories.js +1 -0
- package/dist/constants/packages.d.ts +12 -17
- package/dist/constants/packages.js +31 -16
- package/dist/constants/platform.d.ts +1 -2
- package/dist/constants/platform.js +2 -1
- package/dist/constants/process.d.ts +18 -0
- package/dist/constants/process.js +1 -0
- package/dist/constants/socket.d.ts +4 -10
- package/dist/constants/socket.js +2 -1
- package/dist/constants/testing.d.ts +3 -3
- package/dist/constants/testing.js +1 -0
- package/dist/constants/time.d.ts +3 -4
- package/dist/constants/time.js +1 -0
- package/dist/constants/typescript.d.ts +10 -3
- package/dist/constants/typescript.js +5 -4
- package/dist/cover/code.d.ts +3 -0
- package/dist/cover/code.js +12 -12
- package/dist/cover/formatters.d.ts +12 -9
- package/dist/cover/formatters.js +19 -18
- package/dist/cover/type.d.ts +3 -0
- package/dist/cover/type.js +1 -0
- package/dist/cover/types.js +1 -0
- package/dist/debug.d.ts +32 -47
- package/dist/debug.js +97 -96
- package/dist/dlx/arborist.d.ts +134 -0
- package/dist/dlx/arborist.js +177 -0
- package/dist/dlx/binary.d.ts +25 -9
- package/dist/dlx/binary.js +34 -12
- package/dist/dlx/cache.d.ts +1 -0
- package/dist/dlx/cache.js +2 -1
- package/dist/dlx/detect.d.ts +15 -0
- package/dist/dlx/detect.js +28 -20
- package/dist/dlx/dir.d.ts +1 -11
- package/dist/dlx/dir.js +2 -12
- package/dist/dlx/integrity.d.ts +86 -0
- package/dist/dlx/integrity.js +112 -0
- package/dist/dlx/lockfile.d.ts +115 -0
- package/dist/dlx/lockfile.js +139 -0
- package/dist/dlx/manifest.d.ts +26 -1
- package/dist/dlx/manifest.js +9 -6
- package/dist/dlx/package.d.ts +58 -3
- package/dist/dlx/package.js +101 -74
- package/dist/dlx/packages.d.ts +1 -11
- package/dist/dlx/packages.js +3 -14
- package/dist/dlx/paths.d.ts +1 -0
- package/dist/dlx/paths.js +2 -1
- package/dist/effects/pulse-frames.js +1 -0
- package/dist/effects/text-shimmer.d.ts +13 -2
- package/dist/effects/text-shimmer.js +50 -46
- package/dist/effects/types.js +1 -0
- package/dist/effects/ultra.js +1 -0
- package/dist/env/ci.d.ts +6 -1
- package/dist/env/ci.js +1 -0
- package/dist/env/debug.d.ts +5 -1
- package/dist/env/debug.js +1 -0
- package/dist/env/github.d.ts +19 -23
- package/dist/env/github.js +5 -4
- package/dist/env/helpers.d.ts +21 -9
- package/dist/env/helpers.js +5 -11
- package/dist/env/home.d.ts +17 -4
- package/dist/env/home.js +2 -1
- package/dist/env/locale.d.ts +4 -3
- package/dist/env/locale.js +1 -0
- package/dist/env/node-auth-token.d.ts +5 -1
- package/dist/env/node-auth-token.js +1 -0
- package/dist/env/node-env.d.ts +5 -1
- package/dist/env/node-env.js +1 -0
- package/dist/env/npm.d.ts +4 -5
- package/dist/env/npm.js +1 -0
- package/dist/env/package-manager.d.ts +4 -3
- package/dist/env/package-manager.js +2 -1
- package/dist/env/path.d.ts +5 -1
- package/dist/env/path.js +1 -0
- package/dist/env/pre-commit.d.ts +5 -1
- package/dist/env/pre-commit.js +1 -0
- package/dist/env/rewire.d.ts +10 -0
- package/dist/env/rewire.js +7 -5
- package/dist/env/shell.d.ts +5 -1
- package/dist/env/shell.js +1 -0
- package/dist/env/socket-cli-shadow.d.ts +4 -5
- package/dist/env/socket-cli-shadow.js +1 -0
- package/dist/env/socket-cli.d.ts +4 -14
- package/dist/env/socket-cli.js +1 -0
- package/dist/env/socket.d.ts +6 -18
- package/dist/env/socket.js +4 -3
- package/dist/env/temp-dir.d.ts +4 -3
- package/dist/env/temp-dir.js +1 -0
- package/dist/env/term.d.ts +5 -1
- package/dist/env/term.js +1 -0
- package/dist/env/test.d.ts +4 -3
- package/dist/env/test.js +1 -0
- package/dist/env/windows.d.ts +4 -4
- package/dist/env/windows.js +1 -0
- package/dist/env/xdg.d.ts +4 -3
- package/dist/env/xdg.js +1 -0
- package/dist/env.d.ts +83 -23
- package/dist/env.js +112 -80
- package/dist/errors.js +1 -0
- package/dist/external/@npmcli/package-json.js +9 -3968
- package/dist/external/@socketregistry/packageurl-js.js +2 -2
- package/dist/external/debug.js +162 -328
- package/dist/external/external-pack.js +3 -2835
- package/dist/external/npm-pack.js +13939 -33342
- package/dist/external/zod.js +160 -7558
- package/dist/fs.d.ts +92 -113
- package/dist/fs.js +35 -35
- package/dist/git.d.ts +170 -164
- package/dist/git.js +113 -87
- package/dist/github.d.ts +249 -227
- package/dist/github.js +82 -81
- package/dist/globs.d.ts +31 -17
- package/dist/globs.js +51 -58
- package/dist/http-request.d.ts +99 -99
- package/dist/http-request.js +182 -156
- package/dist/ipc-cli.d.ts +28 -0
- package/dist/{utils/get-ipc.js → ipc-cli.js} +4 -3
- package/dist/ipc.d.ts +9 -299
- package/dist/ipc.js +18 -204
- package/dist/json/edit.d.ts +3 -1
- package/dist/json/edit.js +30 -30
- package/dist/json/format.d.ts +36 -36
- package/dist/json/format.js +22 -21
- package/dist/json/parse.d.ts +4 -2
- package/dist/json/parse.js +1 -0
- package/dist/json/types.js +1 -0
- package/dist/{links/index.d.ts → links.d.ts} +6 -2
- package/dist/{links/index.js → links.js} +5 -4
- package/dist/logger.d.ts +4 -6
- package/dist/logger.js +61 -53
- package/dist/memoization.d.ts +52 -49
- package/dist/memoization.js +55 -33
- package/dist/objects.d.ts +25 -44
- package/dist/objects.js +2 -1
- package/dist/package-extensions.d.ts +6 -0
- package/dist/package-extensions.js +2 -1
- package/dist/packages/edit.d.ts +3 -5
- package/dist/packages/edit.js +4 -3
- package/dist/packages/exports.d.ts +11 -14
- package/dist/packages/exports.js +11 -10
- package/dist/packages/isolation.d.ts +4 -0
- package/dist/packages/isolation.js +20 -19
- package/dist/packages/licenses.d.ts +3 -10
- package/dist/packages/licenses.js +2 -1
- package/dist/packages/manifest.d.ts +3 -3
- package/dist/packages/manifest.js +1 -0
- package/dist/packages/normalize.d.ts +3 -4
- package/dist/packages/normalize.js +1 -0
- package/dist/packages/operations.d.ts +3 -10
- package/dist/packages/operations.js +1 -0
- package/dist/packages/provenance.d.ts +10 -8
- package/dist/packages/provenance.js +55 -54
- package/dist/packages/specs.d.ts +3 -5
- package/dist/packages/specs.js +1 -0
- package/dist/packages/validation.d.ts +3 -3
- package/dist/packages/validation.js +1 -0
- package/dist/packages.d.ts +2 -17
- package/dist/packages.js +2 -1
- package/dist/paths/dirnames.d.ts +0 -2
- package/dist/paths/dirnames.js +1 -0
- package/dist/paths/exts.d.ts +0 -1
- package/dist/paths/exts.js +1 -0
- package/dist/paths/filenames.d.ts +0 -1
- package/dist/paths/filenames.js +1 -0
- package/dist/paths/globs.d.ts +0 -1
- package/dist/paths/globs.js +1 -0
- package/dist/paths/normalize.d.ts +115 -123
- package/dist/paths/normalize.js +128 -127
- package/dist/paths/packages.d.ts +3 -2
- package/dist/paths/packages.js +2 -1
- package/dist/paths/rewire.d.ts +9 -0
- package/dist/paths/rewire.js +5 -3
- package/dist/paths/socket.d.ts +37 -23
- package/dist/paths/socket.js +26 -25
- package/dist/performance.d.ts +87 -84
- package/dist/performance.js +97 -96
- package/dist/process-lock.d.ts +41 -1
- package/dist/process-lock.js +24 -17
- package/dist/promise-queue.d.ts +6 -0
- package/dist/promise-queue.js +1 -0
- package/dist/promises.d.ts +40 -55
- package/dist/promises.js +12 -11
- package/dist/regexps.d.ts +0 -5
- package/dist/regexps.js +1 -0
- package/dist/releases/github.d.ts +59 -63
- package/dist/releases/github.js +95 -100
- package/dist/releases/socket-btm.d.ts +9 -2
- package/dist/releases/socket-btm.js +32 -25
- package/dist/sea.d.ts +5 -0
- package/dist/sea.js +1 -0
- package/dist/shadow.d.ts +4 -0
- package/dist/shadow.js +1 -0
- package/dist/signal-exit.d.ts +7 -7
- package/dist/signal-exit.js +46 -45
- package/dist/sorts.d.ts +5 -7
- package/dist/sorts.js +11 -10
- package/dist/spawn.d.ts +96 -77
- package/dist/spawn.js +39 -38
- package/dist/spinner.d.ts +21 -22
- package/dist/spinner.js +15 -11
- package/dist/ssri.d.ts +31 -36
- package/dist/ssri.js +15 -14
- package/dist/stdio/_stream.d.ts +31 -0
- package/dist/stdio/_stream.js +57 -0
- package/dist/stdio/divider.d.ts +40 -36
- package/dist/stdio/divider.js +10 -9
- package/dist/stdio/footer.d.ts +20 -0
- package/dist/stdio/footer.js +12 -2
- package/dist/stdio/header.d.ts +4 -16
- package/dist/stdio/header.js +1 -9
- package/dist/stdio/stderr.d.ts +51 -39
- package/dist/stdio/stderr.js +19 -22
- package/dist/stdio/stdout.d.ts +54 -52
- package/dist/stdio/stdout.js +35 -33
- package/dist/streams.d.ts +4 -3
- package/dist/streams.js +1 -0
- package/dist/strings.d.ts +31 -85
- package/dist/strings.js +5 -49
- package/dist/suppress-warnings.d.ts +32 -15
- package/dist/suppress-warnings.js +14 -13
- package/dist/tables.d.ts +30 -26
- package/dist/tables.js +24 -23
- package/dist/temporary-executor.d.ts +4 -0
- package/dist/temporary-executor.js +1 -0
- package/dist/themes/context.d.ts +30 -26
- package/dist/themes/context.js +19 -18
- package/dist/themes/index.d.ts +0 -4
- package/dist/themes/index.js +1 -0
- package/dist/themes/themes.d.ts +1 -1
- package/dist/themes/themes.js +1 -0
- package/dist/themes/types.js +1 -0
- package/dist/themes/utils.d.ts +46 -43
- package/dist/themes/utils.js +45 -44
- package/dist/types.d.ts +48 -52
- package/dist/types.js +35 -35
- package/dist/url.d.ts +48 -53
- package/dist/url.js +38 -37
- package/dist/validation/json-parser.d.ts +19 -190
- package/dist/validation/json-parser.js +5 -69
- package/dist/validation/types.d.ts +9 -33
- package/dist/validation/types.js +1 -0
- package/dist/versions.d.ts +1 -0
- package/dist/versions.js +2 -1
- package/dist/words.d.ts +3 -6
- package/dist/words.js +1 -0
- package/dist/zod.js +1 -0
- package/package.json +34 -70
- package/dist/external/@inquirer/checkbox.js +0 -5
- package/dist/external/@inquirer/confirm.js +0 -5
- package/dist/external/@inquirer/input.js +0 -5
- package/dist/external/@inquirer/password.js +0 -5
- package/dist/external/@inquirer/search.js +0 -5
- package/dist/external/@inquirer/select.js +0 -5
- package/dist/functions.d.ts +0 -57
- package/dist/functions.js +0 -70
- package/dist/stdio/clear.d.ts +0 -140
- package/dist/stdio/clear.js +0 -95
- package/dist/stdio/mask.d.ts +0 -151
- package/dist/stdio/mask.js +0 -224
- package/dist/stdio/progress.d.ts +0 -148
- package/dist/stdio/progress.js +0 -212
- package/dist/stdio/prompts.d.ts +0 -195
- package/dist/stdio/prompts.js +0 -176
- package/dist/utils/get-ipc.d.ts +0 -15
package/dist/github.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* Socket Lib - Built with esbuild */
|
|
3
|
+
"use strict";
|
|
3
4
|
var __create = Object.create;
|
|
4
5
|
var __defProp = Object.defineProperty;
|
|
5
6
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -49,6 +50,42 @@ var import_spawn = require("./spawn");
|
|
|
49
50
|
const GITHUB_API_BASE_URL = "https://api.github.com";
|
|
50
51
|
const DEFAULT_CACHE_TTL_MS = 5 * 60 * 1e3;
|
|
51
52
|
let _githubCache;
|
|
53
|
+
async function fetchRefSha(owner, repo, ref, options) {
|
|
54
|
+
const fetchOptions = {
|
|
55
|
+
token: options.token
|
|
56
|
+
};
|
|
57
|
+
try {
|
|
58
|
+
const tagUrl = `${GITHUB_API_BASE_URL}/repos/${owner}/${repo}/git/refs/tags/${ref}`;
|
|
59
|
+
const tagData = await fetchGitHub(tagUrl, fetchOptions);
|
|
60
|
+
if (tagData.object.type === "tag") {
|
|
61
|
+
const tagObject = await fetchGitHub(
|
|
62
|
+
tagData.object.url,
|
|
63
|
+
fetchOptions
|
|
64
|
+
);
|
|
65
|
+
return tagObject.object.sha;
|
|
66
|
+
}
|
|
67
|
+
return tagData.object.sha;
|
|
68
|
+
} catch {
|
|
69
|
+
try {
|
|
70
|
+
const branchUrl = `${GITHUB_API_BASE_URL}/repos/${owner}/${repo}/git/refs/heads/${ref}`;
|
|
71
|
+
const branchData = await fetchGitHub(branchUrl, fetchOptions);
|
|
72
|
+
return branchData.object.sha;
|
|
73
|
+
} catch {
|
|
74
|
+
try {
|
|
75
|
+
const commitUrl = `${GITHUB_API_BASE_URL}/repos/${owner}/${repo}/commits/${ref}`;
|
|
76
|
+
const commitData = await fetchGitHub(
|
|
77
|
+
commitUrl,
|
|
78
|
+
fetchOptions
|
|
79
|
+
);
|
|
80
|
+
return commitData.sha;
|
|
81
|
+
} catch (e) {
|
|
82
|
+
throw new Error(
|
|
83
|
+
`failed to resolve ref "${ref}" for ${owner}/${repo}: ${e instanceof Error ? e.message : String(e)}`
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
52
89
|
function getGithubCache() {
|
|
53
90
|
if (_githubCache === void 0) {
|
|
54
91
|
_githubCache = (0, import_cache_with_ttl.createTtlCache)({
|
|
@@ -59,8 +96,38 @@ function getGithubCache() {
|
|
|
59
96
|
}
|
|
60
97
|
return _githubCache;
|
|
61
98
|
}
|
|
62
|
-
function
|
|
63
|
-
|
|
99
|
+
async function cacheFetchGhsa(ghsaId, options) {
|
|
100
|
+
const cache = getGithubCache();
|
|
101
|
+
const key = `ghsa:${ghsaId}`;
|
|
102
|
+
if (import_node_process.default.env["DISABLE_GITHUB_CACHE"]) {
|
|
103
|
+
return await fetchGhsaDetails(ghsaId, options);
|
|
104
|
+
}
|
|
105
|
+
return await cache.getOrFetch(key, async () => {
|
|
106
|
+
return await fetchGhsaDetails(ghsaId, options);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
async function clearRefCache() {
|
|
110
|
+
if (_githubCache) {
|
|
111
|
+
await _githubCache.clear({ memoOnly: true });
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
async function fetchGhsaDetails(ghsaId, options) {
|
|
115
|
+
const url = `https://api.github.com/advisories/${ghsaId}`;
|
|
116
|
+
const data = await fetchGitHub(url, options);
|
|
117
|
+
return {
|
|
118
|
+
ghsaId: data.ghsa_id,
|
|
119
|
+
summary: data.summary,
|
|
120
|
+
details: data.details,
|
|
121
|
+
severity: data.severity,
|
|
122
|
+
aliases: data.aliases || [],
|
|
123
|
+
publishedAt: data.published_at,
|
|
124
|
+
updatedAt: data.updated_at,
|
|
125
|
+
withdrawnAt: data.withdrawn_at,
|
|
126
|
+
references: data.references || [],
|
|
127
|
+
vulnerabilities: data.vulnerabilities || [],
|
|
128
|
+
cvss: data.cvss,
|
|
129
|
+
cwes: data.cwes || []
|
|
130
|
+
};
|
|
64
131
|
}
|
|
65
132
|
async function fetchGitHub(url, options) {
|
|
66
133
|
const opts = { __proto__: null, ...options };
|
|
@@ -105,60 +172,11 @@ Response may be malformed or incomplete.`,
|
|
|
105
172
|
);
|
|
106
173
|
}
|
|
107
174
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
__proto__: null,
|
|
111
|
-
...options
|
|
112
|
-
};
|
|
113
|
-
const cacheKey = `${owner}/${repo}@${ref}`;
|
|
114
|
-
if (import_node_process.default.env["DISABLE_GITHUB_CACHE"]) {
|
|
115
|
-
return await fetchRefSha(owner, repo, ref, opts);
|
|
116
|
-
}
|
|
117
|
-
const cache = getGithubCache();
|
|
118
|
-
return await cache.getOrFetch(cacheKey, async () => {
|
|
119
|
-
return await fetchRefSha(owner, repo, ref, opts);
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
async function fetchRefSha(owner, repo, ref, options) {
|
|
123
|
-
const fetchOptions = {
|
|
124
|
-
token: options.token
|
|
125
|
-
};
|
|
126
|
-
try {
|
|
127
|
-
const tagUrl = `${GITHUB_API_BASE_URL}/repos/${owner}/${repo}/git/refs/tags/${ref}`;
|
|
128
|
-
const tagData = await fetchGitHub(tagUrl, fetchOptions);
|
|
129
|
-
if (tagData.object.type === "tag") {
|
|
130
|
-
const tagObject = await fetchGitHub(
|
|
131
|
-
tagData.object.url,
|
|
132
|
-
fetchOptions
|
|
133
|
-
);
|
|
134
|
-
return tagObject.object.sha;
|
|
135
|
-
}
|
|
136
|
-
return tagData.object.sha;
|
|
137
|
-
} catch {
|
|
138
|
-
try {
|
|
139
|
-
const branchUrl = `${GITHUB_API_BASE_URL}/repos/${owner}/${repo}/git/refs/heads/${ref}`;
|
|
140
|
-
const branchData = await fetchGitHub(branchUrl, fetchOptions);
|
|
141
|
-
return branchData.object.sha;
|
|
142
|
-
} catch {
|
|
143
|
-
try {
|
|
144
|
-
const commitUrl = `${GITHUB_API_BASE_URL}/repos/${owner}/${repo}/commits/${ref}`;
|
|
145
|
-
const commitData = await fetchGitHub(
|
|
146
|
-
commitUrl,
|
|
147
|
-
fetchOptions
|
|
148
|
-
);
|
|
149
|
-
return commitData.sha;
|
|
150
|
-
} catch (e) {
|
|
151
|
-
throw new Error(
|
|
152
|
-
`failed to resolve ref "${ref}" for ${owner}/${repo}: ${e instanceof Error ? e.message : String(e)}`
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
175
|
+
function getGhsaUrl(ghsaId) {
|
|
176
|
+
return `https://github.com/advisories/${ghsaId}`;
|
|
157
177
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
await _githubCache.clear({ memoOnly: true });
|
|
161
|
-
}
|
|
178
|
+
function getGitHubToken() {
|
|
179
|
+
return (0, import_github.getGithubToken)() || (0, import_github.getGhToken)() || (0, import_socket_cli.getSocketCliGithubToken)() || void 0;
|
|
162
180
|
}
|
|
163
181
|
async function getGitHubTokenFromGitConfig(options) {
|
|
164
182
|
try {
|
|
@@ -176,35 +194,18 @@ async function getGitHubTokenFromGitConfig(options) {
|
|
|
176
194
|
async function getGitHubTokenWithFallback() {
|
|
177
195
|
return getGitHubToken() || await getGitHubTokenFromGitConfig();
|
|
178
196
|
}
|
|
179
|
-
function
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
const url = `https://api.github.com/advisories/${ghsaId}`;
|
|
184
|
-
const data = await fetchGitHub(url, options);
|
|
185
|
-
return {
|
|
186
|
-
ghsaId: data.ghsa_id,
|
|
187
|
-
summary: data.summary,
|
|
188
|
-
details: data.details,
|
|
189
|
-
severity: data.severity,
|
|
190
|
-
aliases: data.aliases || [],
|
|
191
|
-
publishedAt: data.published_at,
|
|
192
|
-
updatedAt: data.updated_at,
|
|
193
|
-
withdrawnAt: data.withdrawn_at,
|
|
194
|
-
references: data.references || [],
|
|
195
|
-
vulnerabilities: data.vulnerabilities || [],
|
|
196
|
-
cvss: data.cvss,
|
|
197
|
-
cwes: data.cwes || []
|
|
197
|
+
async function resolveRefToSha(owner, repo, ref, options) {
|
|
198
|
+
const opts = {
|
|
199
|
+
__proto__: null,
|
|
200
|
+
...options
|
|
198
201
|
};
|
|
199
|
-
}
|
|
200
|
-
async function cacheFetchGhsa(ghsaId, options) {
|
|
201
|
-
const cache = getGithubCache();
|
|
202
|
-
const key = `ghsa:${ghsaId}`;
|
|
202
|
+
const cacheKey = `${owner}/${repo}@${ref}`;
|
|
203
203
|
if (import_node_process.default.env["DISABLE_GITHUB_CACHE"]) {
|
|
204
|
-
return await
|
|
204
|
+
return await fetchRefSha(owner, repo, ref, opts);
|
|
205
205
|
}
|
|
206
|
-
|
|
207
|
-
|
|
206
|
+
const cache = getGithubCache();
|
|
207
|
+
return await cache.getOrFetch(cacheKey, async () => {
|
|
208
|
+
return await fetchRefSha(owner, repo, ref, opts);
|
|
208
209
|
});
|
|
209
210
|
}
|
|
210
211
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/globs.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Glob pattern matching utilities with default ignore patterns.
|
|
3
|
+
* Provides file filtering and glob matcher functions for npm-like behavior.
|
|
4
|
+
*/
|
|
2
5
|
type Pattern = string;
|
|
3
6
|
interface FastGlobOptions {
|
|
4
7
|
absolute?: boolean;
|
|
@@ -31,29 +34,30 @@ export interface GlobOptions extends FastGlobOptions {
|
|
|
31
34
|
export type { Pattern, FastGlobOptions };
|
|
32
35
|
export declare const defaultIgnore: readonly string[];
|
|
33
36
|
/**
|
|
34
|
-
*
|
|
37
|
+
* Return a glob-matcher function, memoized by pattern + options.
|
|
35
38
|
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
* Get a cached glob matcher function.
|
|
39
|
+
* The returned function is a fast synchronous predicate built on picomatch.
|
|
40
|
+
* Results are memoized — calling `getGlobMatcher(['*.ts'])` a thousand times
|
|
41
|
+
* in a loop returns the same compiled matcher each time, so callers do not
|
|
42
|
+
* need to hoist it themselves.
|
|
43
|
+
*
|
|
44
|
+
* The cache is LRU with a cap of 100 entries. Cache keys fold together the
|
|
45
|
+
* (sorted) pattern list and (sorted) option set, so arguments that differ
|
|
46
|
+
* only in ordering share a matcher.
|
|
47
|
+
*
|
|
48
|
+
* Default options: `dot: true`, `nocase: true`. Patterns starting with `!`
|
|
49
|
+
* become ignore patterns.
|
|
48
50
|
*
|
|
49
51
|
* @example
|
|
50
52
|
* ```typescript
|
|
51
53
|
* const isMatch = getGlobMatcher('*.ts')
|
|
52
54
|
* isMatch('index.ts') // true
|
|
53
55
|
* isMatch('index.js') // false
|
|
56
|
+
*
|
|
57
|
+
* // With negation
|
|
58
|
+
* const isSource = getGlobMatcher(['src/**', '!**\/*.test.ts'])
|
|
54
59
|
* ```
|
|
55
60
|
*/
|
|
56
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
57
61
|
export declare function getGlobMatcher(glob: Pattern | Pattern[], options?: {
|
|
58
62
|
dot?: boolean;
|
|
59
63
|
nocase?: boolean;
|
|
@@ -69,8 +73,19 @@ export declare function getGlobMatcher(glob: Pattern | Pattern[], options?: {
|
|
|
69
73
|
* console.log(files) // ['src/index.ts', 'src/utils.ts']
|
|
70
74
|
* ```
|
|
71
75
|
*/
|
|
72
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
73
76
|
export declare function glob(patterns: Pattern | Pattern[], options?: FastGlobOptions): Promise<string[]>;
|
|
77
|
+
/**
|
|
78
|
+
* Create a stream of license file paths matching glob patterns.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```typescript
|
|
82
|
+
* const stream = globStreamLicenses('/tmp/my-package')
|
|
83
|
+
* for await (const licensePath of stream) {
|
|
84
|
+
* console.log(licensePath)
|
|
85
|
+
* }
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
export declare function globStreamLicenses(dirname: string, options?: GlobOptions): NodeJS.ReadableStream;
|
|
74
89
|
/**
|
|
75
90
|
* Synchronously find files matching glob patterns.
|
|
76
91
|
* Wrapper around fast-glob.sync.
|
|
@@ -81,5 +96,4 @@ export declare function glob(patterns: Pattern | Pattern[], options?: FastGlobOp
|
|
|
81
96
|
* console.log(files) // ['package.json', 'tsconfig.json']
|
|
82
97
|
* ```
|
|
83
98
|
*/
|
|
84
|
-
/*@__NO_SIDE_EFFECTS__*/
|
|
85
99
|
export declare function globSync(patterns: Pattern | Pattern[], options?: FastGlobOptions): string[];
|
package/dist/globs.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* Socket Lib - Built with esbuild */
|
|
3
|
+
"use strict";
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -29,21 +30,9 @@ module.exports = __toCommonJS(globs_exports);
|
|
|
29
30
|
var import_objects = require("./objects");
|
|
30
31
|
var import_globs = require("./paths/globs");
|
|
31
32
|
let _fastGlob;
|
|
32
|
-
// @__NO_SIDE_EFFECTS__
|
|
33
|
-
function getFastGlob() {
|
|
34
|
-
if (_fastGlob === void 0) {
|
|
35
|
-
_fastGlob = require("./external/fast-glob.js");
|
|
36
|
-
}
|
|
37
|
-
return _fastGlob;
|
|
38
|
-
}
|
|
39
33
|
let _picomatch;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (_picomatch === void 0) {
|
|
43
|
-
_picomatch = require("./external/picomatch.js");
|
|
44
|
-
}
|
|
45
|
-
return _picomatch;
|
|
46
|
-
}
|
|
34
|
+
const MATCHER_CACHE_MAX_SIZE = 100;
|
|
35
|
+
const matcherCache = /* @__PURE__ */ new Map();
|
|
47
36
|
const defaultIgnore = (0, import_objects.objectFreeze)([
|
|
48
37
|
// Most of these ignored files can be included specifically if included in the
|
|
49
38
|
// files globs. Exceptions to this are:
|
|
@@ -85,43 +74,18 @@ const defaultIgnore = (0, import_objects.objectFreeze)([
|
|
|
85
74
|
"**/bower_components"
|
|
86
75
|
]);
|
|
87
76
|
// @__NO_SIDE_EFFECTS__
|
|
88
|
-
function
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
ignoreOriginals,
|
|
92
|
-
recursive,
|
|
93
|
-
...globOptions
|
|
94
|
-
} = { __proto__: null, ...options };
|
|
95
|
-
const ignore = [
|
|
96
|
-
...Array.isArray(ignoreOpt) ? ignoreOpt : defaultIgnore,
|
|
97
|
-
"**/*.{cjs,cts,js,json,mjs,mts,ts}"
|
|
98
|
-
];
|
|
99
|
-
if (ignoreOriginals) {
|
|
100
|
-
ignore.push(import_globs.LICENSE_ORIGINAL_GLOB_RECURSIVE);
|
|
77
|
+
function getFastGlob() {
|
|
78
|
+
if (_fastGlob === void 0) {
|
|
79
|
+
_fastGlob = require("./external/fast-glob.js");
|
|
101
80
|
}
|
|
102
|
-
|
|
103
|
-
return fastGlob.globStream(
|
|
104
|
-
[recursive ? import_globs.LICENSE_GLOB_RECURSIVE : import_globs.LICENSE_GLOB],
|
|
105
|
-
{
|
|
106
|
-
__proto__: null,
|
|
107
|
-
absolute: true,
|
|
108
|
-
caseSensitiveMatch: false,
|
|
109
|
-
cwd: dirname,
|
|
110
|
-
...globOptions,
|
|
111
|
-
...ignore ? { ignore } : {}
|
|
112
|
-
}
|
|
113
|
-
);
|
|
81
|
+
return _fastGlob;
|
|
114
82
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
if (matcherCache.size >= MATCHER_CACHE_MAX_SIZE && matcherAccessOrder.length > 0) {
|
|
120
|
-
const oldest = matcherAccessOrder.shift();
|
|
121
|
-
if (oldest) {
|
|
122
|
-
matcherCache.delete(oldest);
|
|
123
|
-
}
|
|
83
|
+
// @__NO_SIDE_EFFECTS__
|
|
84
|
+
function getPicomatch() {
|
|
85
|
+
if (_picomatch === void 0) {
|
|
86
|
+
_picomatch = require("./external/picomatch.js");
|
|
124
87
|
}
|
|
88
|
+
return _picomatch;
|
|
125
89
|
}
|
|
126
90
|
// @__NO_SIDE_EFFECTS__
|
|
127
91
|
function getGlobMatcher(glob2, options) {
|
|
@@ -129,16 +93,18 @@ function getGlobMatcher(glob2, options) {
|
|
|
129
93
|
const sortedPatterns = [...patterns].sort();
|
|
130
94
|
const sortedOptions = options ? Object.keys(options).sort().map((k) => `${k}:${JSON.stringify(options[k])}`).join(",") : "";
|
|
131
95
|
const key = `${sortedPatterns.join("|")}:${sortedOptions}`;
|
|
132
|
-
|
|
133
|
-
if (
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
96
|
+
const existing = matcherCache.get(key);
|
|
97
|
+
if (existing) {
|
|
98
|
+
matcherCache.delete(key);
|
|
99
|
+
matcherCache.set(key, existing);
|
|
100
|
+
return existing;
|
|
101
|
+
}
|
|
102
|
+
if (matcherCache.size >= MATCHER_CACHE_MAX_SIZE) {
|
|
103
|
+
const oldest = matcherCache.keys().next().value;
|
|
104
|
+
if (oldest !== void 0) {
|
|
105
|
+
matcherCache.delete(oldest);
|
|
138
106
|
}
|
|
139
|
-
return matcher;
|
|
140
107
|
}
|
|
141
|
-
evictLRUMatcher();
|
|
142
108
|
const positivePatterns = patterns.filter((p) => !p.startsWith("!"));
|
|
143
109
|
const negativePatterns = patterns.filter((p) => p.startsWith("!")).map((p) => p.slice(1));
|
|
144
110
|
const matchOptions = {
|
|
@@ -148,12 +114,11 @@ function getGlobMatcher(glob2, options) {
|
|
|
148
114
|
...negativePatterns.length > 0 ? { ignore: negativePatterns } : {}
|
|
149
115
|
};
|
|
150
116
|
const picomatch = /* @__PURE__ */ getPicomatch();
|
|
151
|
-
matcher = picomatch(
|
|
117
|
+
const matcher = picomatch(
|
|
152
118
|
positivePatterns.length > 0 ? positivePatterns : patterns,
|
|
153
119
|
matchOptions
|
|
154
120
|
);
|
|
155
121
|
matcherCache.set(key, matcher);
|
|
156
|
-
matcherAccessOrder.push(key);
|
|
157
122
|
return matcher;
|
|
158
123
|
}
|
|
159
124
|
// @__NO_SIDE_EFFECTS__
|
|
@@ -162,6 +127,34 @@ function glob(patterns, options) {
|
|
|
162
127
|
return fastGlob.glob(patterns, options);
|
|
163
128
|
}
|
|
164
129
|
// @__NO_SIDE_EFFECTS__
|
|
130
|
+
function globStreamLicenses(dirname, options) {
|
|
131
|
+
const {
|
|
132
|
+
ignore: ignoreOpt,
|
|
133
|
+
ignoreOriginals,
|
|
134
|
+
recursive,
|
|
135
|
+
...globOptions
|
|
136
|
+
} = { __proto__: null, ...options };
|
|
137
|
+
const ignore = [
|
|
138
|
+
...Array.isArray(ignoreOpt) ? ignoreOpt : defaultIgnore,
|
|
139
|
+
"**/*.{cjs,cts,js,json,mjs,mts,ts}"
|
|
140
|
+
];
|
|
141
|
+
if (ignoreOriginals) {
|
|
142
|
+
ignore.push(import_globs.LICENSE_ORIGINAL_GLOB_RECURSIVE);
|
|
143
|
+
}
|
|
144
|
+
const fastGlob = /* @__PURE__ */ getFastGlob();
|
|
145
|
+
return fastGlob.globStream(
|
|
146
|
+
[recursive ? import_globs.LICENSE_GLOB_RECURSIVE : import_globs.LICENSE_GLOB],
|
|
147
|
+
{
|
|
148
|
+
__proto__: null,
|
|
149
|
+
absolute: true,
|
|
150
|
+
caseSensitiveMatch: false,
|
|
151
|
+
cwd: dirname,
|
|
152
|
+
...globOptions,
|
|
153
|
+
...ignore ? { ignore } : {}
|
|
154
|
+
}
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
// @__NO_SIDE_EFFECTS__
|
|
165
158
|
function globSync(patterns, options) {
|
|
166
159
|
const fastGlob = /* @__PURE__ */ getFastGlob();
|
|
167
160
|
return fastGlob.globSync(patterns, options);
|
package/dist/http-request.d.ts
CHANGED
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
* - Timeout support for all operations.
|
|
14
14
|
* - Zero dependencies on external HTTP libraries.
|
|
15
15
|
*/
|
|
16
|
+
import type { IncomingHttpHeaders, IncomingMessage } from 'node:http';
|
|
16
17
|
import type { Readable } from 'node:stream';
|
|
17
|
-
import type {
|
|
18
|
+
import type { Logger } from './logger';
|
|
18
19
|
/** IncomingMessage received as a response to a client request (http.request callback). */
|
|
19
20
|
export type IncomingResponse = IncomingMessage;
|
|
20
21
|
/** IncomingMessage received as a request in a server handler (http.createServer callback). */
|
|
21
22
|
export type IncomingRequest = IncomingMessage;
|
|
22
|
-
import type { Logger } from './logger.js';
|
|
23
23
|
/**
|
|
24
24
|
* Information passed to the onRequest hook before each request attempt.
|
|
25
25
|
*/
|
|
@@ -422,22 +422,6 @@ export interface HttpResponse {
|
|
|
422
422
|
*/
|
|
423
423
|
rawResponse?: IncomingResponse | undefined;
|
|
424
424
|
}
|
|
425
|
-
/**
|
|
426
|
-
* Read and buffer a client-side IncomingResponse into an HttpResponse.
|
|
427
|
-
*
|
|
428
|
-
* Useful when you have a raw response from code that bypasses
|
|
429
|
-
* `httpRequest()` (e.g., multipart form-data uploads via `http.request()`,
|
|
430
|
-
* or responses from third-party HTTP libraries) and need to convert it
|
|
431
|
-
* into the standard HttpResponse interface.
|
|
432
|
-
*
|
|
433
|
-
* @example
|
|
434
|
-
* ```typescript
|
|
435
|
-
* const raw = await makeRawRequest('https://example.com/api')
|
|
436
|
-
* const response = await readIncomingResponse(raw)
|
|
437
|
-
* console.log(response.status, response.body.toString('utf8'))
|
|
438
|
-
* ```
|
|
439
|
-
*/
|
|
440
|
-
export declare function readIncomingResponse(msg: IncomingResponse): Promise<HttpResponse>;
|
|
441
425
|
/**
|
|
442
426
|
* Error thrown when an HTTP response has a non-2xx status code
|
|
443
427
|
* and `throwOnError` is enabled. Carries the full `HttpResponse`
|
|
@@ -447,47 +431,6 @@ export declare class HttpResponseError extends Error {
|
|
|
447
431
|
response: HttpResponse;
|
|
448
432
|
constructor(response: HttpResponse, message?: string | undefined);
|
|
449
433
|
}
|
|
450
|
-
/**
|
|
451
|
-
* Parse a `Retry-After` HTTP header value into milliseconds.
|
|
452
|
-
*
|
|
453
|
-
* Supports both formats defined in RFC 7231 §7.1.3:
|
|
454
|
-
* - **delay-seconds**: integer number of seconds (e.g., `"120"`)
|
|
455
|
-
* - **HTTP-date**: an absolute date/time (e.g., `"Fri, 31 Dec 2027 23:59:59 GMT"`)
|
|
456
|
-
*
|
|
457
|
-
* When the header is an array (multiple values), the first element is used.
|
|
458
|
-
*
|
|
459
|
-
* @param value - The raw Retry-After header value(s)
|
|
460
|
-
* @returns Delay in milliseconds, or `undefined` if the value cannot be parsed
|
|
461
|
-
*
|
|
462
|
-
* @example
|
|
463
|
-
* ```ts
|
|
464
|
-
* const delay = parseRetryAfterHeader(response.headers['retry-after'])
|
|
465
|
-
* if (delay !== undefined) {
|
|
466
|
-
* await new Promise(resolve => setTimeout(resolve, delay))
|
|
467
|
-
* }
|
|
468
|
-
* ```
|
|
469
|
-
*/
|
|
470
|
-
export declare function parseRetryAfterHeader(value: string | string[] | undefined): number | undefined;
|
|
471
|
-
/**
|
|
472
|
-
* Redact sensitive HTTP headers for safe logging and telemetry.
|
|
473
|
-
*
|
|
474
|
-
* Replaces values of sensitive headers (Authorization, Cookie, etc.)
|
|
475
|
-
* with `[REDACTED]`. Non-sensitive headers are passed through unchanged.
|
|
476
|
-
* Array values are joined with `', '`.
|
|
477
|
-
*
|
|
478
|
-
* @param headers - HTTP headers to sanitize
|
|
479
|
-
* @returns A new object with sensitive values redacted
|
|
480
|
-
*
|
|
481
|
-
* @example
|
|
482
|
-
* ```ts
|
|
483
|
-
* const safe = sanitizeHeaders({
|
|
484
|
-
* 'authorization': 'Bearer secret',
|
|
485
|
-
* 'content-type': 'application/json'
|
|
486
|
-
* })
|
|
487
|
-
* // { authorization: '[REDACTED]', 'content-type': 'application/json' }
|
|
488
|
-
* ```
|
|
489
|
-
*/
|
|
490
|
-
export declare function sanitizeHeaders(headers: Record<string, unknown> | undefined): Record<string, string>;
|
|
491
434
|
/**
|
|
492
435
|
* Configuration options for file downloads.
|
|
493
436
|
*/
|
|
@@ -704,32 +647,6 @@ export interface HttpDownloadResult {
|
|
|
704
647
|
* ```
|
|
705
648
|
*/
|
|
706
649
|
export type Checksums = Record<string, string>;
|
|
707
|
-
/**
|
|
708
|
-
* Parse a checksums file text into a filename-to-hash map.
|
|
709
|
-
*
|
|
710
|
-
* Supports standard checksums file formats:
|
|
711
|
-
* - BSD style: "SHA256 (filename) = hash"
|
|
712
|
-
* - GNU style: "hash filename" (two spaces)
|
|
713
|
-
* - Simple style: "hash filename" (single space)
|
|
714
|
-
*
|
|
715
|
-
* Lines starting with '#' are treated as comments and ignored.
|
|
716
|
-
* Empty lines are ignored.
|
|
717
|
-
*
|
|
718
|
-
* @param text - Raw text content of a checksums file
|
|
719
|
-
* @returns Map of filenames to lowercase SHA256 hashes
|
|
720
|
-
*
|
|
721
|
-
* @example
|
|
722
|
-
* ```ts
|
|
723
|
-
* const text = `
|
|
724
|
-
* # SHA256 checksums
|
|
725
|
-
* e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 file.zip
|
|
726
|
-
* abc123def456... other.tar.gz
|
|
727
|
-
* `
|
|
728
|
-
* const checksums = parseChecksums(text)
|
|
729
|
-
* console.log(checksums['file.zip']) // 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
|
|
730
|
-
* ```
|
|
731
|
-
*/
|
|
732
|
-
export declare function parseChecksums(text: string): Checksums;
|
|
733
650
|
/**
|
|
734
651
|
* Options for fetching checksums from a URL.
|
|
735
652
|
*/
|
|
@@ -749,6 +666,20 @@ export interface FetchChecksumsOptions {
|
|
|
749
666
|
*/
|
|
750
667
|
timeout?: number | undefined;
|
|
751
668
|
}
|
|
669
|
+
/**
|
|
670
|
+
* Build an enriched error message based on the error code.
|
|
671
|
+
* Generic guidance (no product-specific branding).
|
|
672
|
+
*
|
|
673
|
+
* @example
|
|
674
|
+
* ```typescript
|
|
675
|
+
* try {
|
|
676
|
+
* await fetch('https://api.example.com')
|
|
677
|
+
* } catch (err) {
|
|
678
|
+
* console.error(enrichErrorMessage('https://api.example.com', 'GET', err))
|
|
679
|
+
* }
|
|
680
|
+
* ```
|
|
681
|
+
*/
|
|
682
|
+
export declare function enrichErrorMessage(url: string, method: string, error: NodeJS.ErrnoException): string;
|
|
752
683
|
/**
|
|
753
684
|
* Fetch and parse a checksums file from a URL.
|
|
754
685
|
*
|
|
@@ -776,20 +707,6 @@ export interface FetchChecksumsOptions {
|
|
|
776
707
|
* ```
|
|
777
708
|
*/
|
|
778
709
|
export declare function fetchChecksums(url: string, options?: FetchChecksumsOptions | undefined): Promise<Checksums>;
|
|
779
|
-
/**
|
|
780
|
-
* Build an enriched error message based on the error code.
|
|
781
|
-
* Generic guidance (no product-specific branding).
|
|
782
|
-
*
|
|
783
|
-
* @example
|
|
784
|
-
* ```typescript
|
|
785
|
-
* try {
|
|
786
|
-
* await fetch('https://api.example.com')
|
|
787
|
-
* } catch (err) {
|
|
788
|
-
* console.error(enrichErrorMessage('https://api.example.com', 'GET', err))
|
|
789
|
-
* }
|
|
790
|
-
* ```
|
|
791
|
-
*/
|
|
792
|
-
export declare function enrichErrorMessage(url: string, method: string, error: NodeJS.ErrnoException): string;
|
|
793
710
|
/**
|
|
794
711
|
* Download a file from a URL to a local path with redirect support, retry logic, and progress callbacks.
|
|
795
712
|
* Uses streaming to avoid loading entire file in memory.
|
|
@@ -973,3 +890,86 @@ export declare function httpRequest(url: string, options?: HttpRequestOptions |
|
|
|
973
890
|
* ```
|
|
974
891
|
*/
|
|
975
892
|
export declare function httpText(url: string, options?: HttpRequestOptions | undefined): Promise<string>;
|
|
893
|
+
/**
|
|
894
|
+
* Parse a checksums file text into a filename-to-hash map.
|
|
895
|
+
*
|
|
896
|
+
* Supports standard checksums file formats:
|
|
897
|
+
* - BSD style: "SHA256 (filename) = hash"
|
|
898
|
+
* - GNU style: "hash filename" (two spaces)
|
|
899
|
+
* - Simple style: "hash filename" (single space)
|
|
900
|
+
*
|
|
901
|
+
* Lines starting with '#' are treated as comments and ignored.
|
|
902
|
+
* Empty lines are ignored.
|
|
903
|
+
*
|
|
904
|
+
* @param text - Raw text content of a checksums file
|
|
905
|
+
* @returns Map of filenames to lowercase SHA256 hashes
|
|
906
|
+
*
|
|
907
|
+
* @example
|
|
908
|
+
* ```ts
|
|
909
|
+
* const text = `
|
|
910
|
+
* # SHA256 checksums
|
|
911
|
+
* e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 file.zip
|
|
912
|
+
* abc123def456... other.tar.gz
|
|
913
|
+
* `
|
|
914
|
+
* const checksums = parseChecksums(text)
|
|
915
|
+
* console.log(checksums['file.zip']) // 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
|
|
916
|
+
* ```
|
|
917
|
+
*/
|
|
918
|
+
export declare function parseChecksums(text: string): Checksums;
|
|
919
|
+
/**
|
|
920
|
+
* Parse a `Retry-After` HTTP header value into milliseconds.
|
|
921
|
+
*
|
|
922
|
+
* Supports both formats defined in RFC 7231 §7.1.3:
|
|
923
|
+
* - **delay-seconds**: integer number of seconds (e.g., `"120"`)
|
|
924
|
+
* - **HTTP-date**: an absolute date/time (e.g., `"Fri, 31 Dec 2027 23:59:59 GMT"`)
|
|
925
|
+
*
|
|
926
|
+
* When the header is an array (multiple values), the first element is used.
|
|
927
|
+
*
|
|
928
|
+
* @param value - The raw Retry-After header value(s)
|
|
929
|
+
* @returns Delay in milliseconds, or `undefined` if the value cannot be parsed
|
|
930
|
+
*
|
|
931
|
+
* @example
|
|
932
|
+
* ```ts
|
|
933
|
+
* const delay = parseRetryAfterHeader(response.headers['retry-after'])
|
|
934
|
+
* if (delay !== undefined) {
|
|
935
|
+
* await new Promise(resolve => setTimeout(resolve, delay))
|
|
936
|
+
* }
|
|
937
|
+
* ```
|
|
938
|
+
*/
|
|
939
|
+
export declare function parseRetryAfterHeader(value: string | string[] | undefined): number | undefined;
|
|
940
|
+
/**
|
|
941
|
+
* Read and buffer a client-side IncomingResponse into an HttpResponse.
|
|
942
|
+
*
|
|
943
|
+
* Useful when you have a raw response from code that bypasses
|
|
944
|
+
* `httpRequest()` (e.g., multipart form-data uploads via `http.request()`,
|
|
945
|
+
* or responses from third-party HTTP libraries) and need to convert it
|
|
946
|
+
* into the standard HttpResponse interface.
|
|
947
|
+
*
|
|
948
|
+
* @example
|
|
949
|
+
* ```typescript
|
|
950
|
+
* const raw = await makeRawRequest('https://example.com/api')
|
|
951
|
+
* const response = await readIncomingResponse(raw)
|
|
952
|
+
* console.log(response.status, response.body.toString('utf8'))
|
|
953
|
+
* ```
|
|
954
|
+
*/
|
|
955
|
+
export declare function readIncomingResponse(msg: IncomingResponse): Promise<HttpResponse>;
|
|
956
|
+
/**
|
|
957
|
+
* Redact sensitive HTTP headers for safe logging and telemetry.
|
|
958
|
+
*
|
|
959
|
+
* Replaces values of sensitive headers (Authorization, Cookie, etc.)
|
|
960
|
+
* with `[REDACTED]`. Non-sensitive headers are passed through unchanged.
|
|
961
|
+
* Array values are joined with `', '`.
|
|
962
|
+
*
|
|
963
|
+
* @param headers - HTTP headers to sanitize
|
|
964
|
+
* @returns A new object with sensitive values redacted
|
|
965
|
+
*
|
|
966
|
+
* @example
|
|
967
|
+
* ```ts
|
|
968
|
+
* const safe = sanitizeHeaders({
|
|
969
|
+
* 'authorization': 'Bearer secret',
|
|
970
|
+
* 'content-type': 'application/json'
|
|
971
|
+
* })
|
|
972
|
+
* // { authorization: '[REDACTED]', 'content-type': 'application/json' }
|
|
973
|
+
* ```
|
|
974
|
+
*/
|
|
975
|
+
export declare function sanitizeHeaders(headers: Record<string, unknown> | undefined): Record<string, string>;
|