@socketsecurity/lib 6.0.9 → 6.0.10
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 +6 -0
- package/README.md +8 -9
- package/dist/abort/signal.d.ts +1 -1
- package/dist/abort/signal.js +1 -1
- package/dist/ai/agent-context.d.mts +1 -1
- package/dist/ai/agent-context.js +3 -2
- package/dist/ai/backends.d.mts +3 -3
- package/dist/ai/backends.js +2 -2
- package/dist/ai/billing-context.d.mts +74 -0
- package/dist/ai/billing-context.js +129 -0
- package/dist/ai/credentials.d.mts +39 -5
- package/dist/ai/credentials.js +61 -6
- package/dist/ai/discover.d.mts +4 -0
- package/dist/ai/discover.js +4 -0
- package/dist/ai/exec.d.mts +1 -1
- package/dist/ai/exec.js +1 -1
- package/dist/ai/http.d.mts +8 -8
- package/dist/ai/http.js +6 -6
- package/dist/ai/profiles.d.mts +9 -10
- package/dist/ai/profiles.js +0 -5
- package/dist/ai/role.d.mts +58 -0
- package/dist/ai/role.js +96 -0
- package/dist/ai/route-heuristic.d.mts +177 -0
- package/dist/ai/route-heuristic.js +194 -0
- package/dist/ai/route.d.mts +10 -9
- package/dist/ai/route.js +14 -13
- package/dist/ai/spawn.d.mts +2 -1
- package/dist/ai/spawn.js +25 -2
- package/dist/ai/subagent-status.d.mts +2 -0
- package/dist/ai/subagent-status.js +2 -0
- package/dist/ai/tier.d.mts +1 -1
- package/dist/ai/types.d.mts +9 -2
- package/dist/ai/worktree.d.mts +1 -1
- package/dist/ai/worktree.js +3 -2
- package/dist/argv/parse.d.ts +2 -0
- package/dist/argv/parse.js +2 -0
- package/dist/bin/_internal.d.ts +1 -1
- package/dist/bin/_internal.js +1 -1
- package/dist/bin/prim.cjs +446 -300
- package/dist/bin/shadow.js +2 -1
- package/dist/bin/which.d.ts +28 -3
- package/dist/bin/which.js +45 -3
- package/dist/cacache/_internal.d.ts +10 -2
- package/dist/cacache/_internal.js +6 -10
- package/dist/cache/ttl/_internal.d.ts +33 -0
- package/dist/cache/ttl/_internal.js +68 -0
- package/dist/cache/ttl/browser.d.ts +56 -0
- package/dist/cache/ttl/browser.js +257 -0
- package/dist/cache/ttl/store.js +10 -33
- package/dist/cache/ttl/types.d.ts +46 -3
- package/dist/checks/primordials-defaults.d.ts +5 -5
- package/dist/checks/primordials-defaults.js +5 -5
- package/dist/checks/primordials.d.ts +1 -1
- package/dist/checks/primordials.js +25 -17
- package/dist/cli/check-primordials.d.ts +6 -1
- package/dist/cli/check-primordials.js +14 -5
- package/dist/cli/check.js +1 -1
- package/dist/cli/socket-lib.d.ts +1 -1
- package/dist/cli/socket-lib.js +3 -3
- package/dist/colors/socket-palette.d.ts +1 -1
- package/dist/compression/brotli.d.ts +6 -2
- package/dist/compression/brotli.js +4 -0
- package/dist/compression/gzip.d.ts +6 -2
- package/dist/compression/gzip.js +6 -1
- package/dist/config/layers.d.ts +4 -4
- package/dist/config/layers.js +4 -4
- package/dist/constants/agents.d.ts +3 -0
- package/dist/constants/agents.js +3 -0
- package/dist/constants/node.d.ts +14 -0
- package/dist/constants/node.js +14 -0
- package/dist/constants/package-default-node-range.js +1 -5
- package/dist/constants/packages.d.ts +5 -0
- package/dist/constants/packages.js +5 -0
- package/dist/constants/platform.d.ts +1 -1
- package/dist/constants/platform.js +1 -1
- package/dist/constants/socket.js +1 -1
- package/dist/constants/typescript.d.ts +5 -0
- package/dist/constants/typescript.js +5 -0
- package/dist/debug/_internal.d.ts +22 -7
- package/dist/debug/_internal.js +33 -15
- package/dist/debug/namespace.js +11 -8
- package/dist/debug/output.d.ts +12 -1
- package/dist/debug/output.js +33 -16
- package/dist/dlx/binary-resolution.js +7 -4
- package/dist/eco/npm/npm/parse-lockfile.js +2 -1
- package/dist/eco/npm/vlt/exec.d.ts +1 -1
- package/dist/eco/npm/vlt/exec.js +1 -1
- package/dist/env/agents.d.ts +6 -0
- package/dist/env/agents.js +29 -0
- package/dist/env/flags.d.ts +12 -0
- package/dist/env/flags.js +23 -0
- package/dist/env/github-status.js +2 -2
- package/dist/env/providers.d.ts +6 -0
- package/dist/env/providers.js +23 -0
- package/dist/env/proxy.js +1 -1
- package/dist/env/rewire.d.ts +32 -0
- package/dist/env/rewire.js +55 -23
- package/dist/env/runtimes.d.ts +9 -0
- package/dist/env/runtimes.js +53 -0
- package/dist/env/socket-cli.d.ts +5 -2
- package/dist/env/socket-cli.js +6 -3
- package/dist/errors/predicates.d.ts +3 -2
- package/dist/errors/predicates.js +5 -3
- package/dist/errors/stack.js +2 -1
- package/dist/events/exit/_internal.d.ts +1 -23
- package/dist/external/@npmcli/package-json.js +179 -88
- package/dist/external/@npmcli/promise-spawn.js +2 -2
- package/dist/external/@sinclair/typebox/value.js +5 -4
- package/dist/external/@socketregistry/yocto-spinner.js +3 -3
- package/dist/external/adm-zip.d.ts +82 -0
- package/dist/external/adm-zip.js +2 -2
- package/dist/external/cacache.d.ts +87 -0
- package/dist/external/debug.d.ts +22 -0
- package/dist/external/debug.js +11 -4
- package/dist/external/del.d.ts +1 -0
- package/dist/external/external-pack.d.ts +12 -0
- package/dist/external/external-pack.js +41 -34
- package/dist/external/fast-glob.d.ts +8 -0
- package/dist/external/fast-sort.d.ts +1 -0
- package/dist/external/get-east-asian-width.d.ts +5 -0
- package/dist/external/get-east-asian-width.js +8 -1
- package/dist/external/has-flag.d.ts +1 -0
- package/dist/external/inquirer-pack.d.ts +18 -0
- package/dist/external/libnpmexec.d.ts +35 -0
- package/dist/external/libnpmpack.d.ts +1 -0
- package/dist/external/make-fetch-happen.d.ts +13 -0
- package/dist/external/normalize-package-data.d.ts +4 -0
- package/dist/external/npm-core.d.ts +14 -0
- package/dist/external/npm-pack.d.ts +24 -0
- package/dist/external/npm-pack.js +1551 -1867
- package/dist/external/npm-package-arg.d.ts +4 -0
- package/dist/external/p-map.js +8 -1
- package/dist/external/pacote.d.ts +15 -0
- package/dist/external/pico-pack.d.ts +16 -0
- package/dist/external/pico-pack.js +38 -23
- package/dist/external/picomatch.d.ts +96 -0
- package/dist/external/pony-cause.d.ts +14 -0
- package/dist/external/semver.d.ts +60 -0
- package/dist/external/semver.js +1459 -4
- package/dist/external/shell-quote.d.ts +51 -0
- package/dist/external/shell-quote.js +55 -15
- package/dist/external/signal-exit.d.ts +1 -0
- package/dist/external/spdx-correct.d.ts +4 -0
- package/dist/external/spdx-expression-parse.d.ts +4 -0
- package/dist/external/spdx-pack.d.ts +10 -0
- package/dist/external/std-env.d.ts +284 -0
- package/dist/external/std-env.js +323 -0
- package/dist/external/streaming-iterables.d.ts +11 -0
- package/dist/external/supports-color.d.ts +1 -0
- package/dist/external/tar-fs.d.ts +31 -0
- package/dist/external/validate-npm-package-name.d.ts +4 -0
- package/dist/external/which.d.ts +25 -0
- package/dist/external/which.js +2 -2
- package/dist/external/yargs-parser.d.ts +2 -0
- package/dist/external/yargs-parser.js +11 -3
- package/dist/external/yoctocolors-cjs.d.ts +51 -0
- package/dist/external-tools/bazel/asset-names.d.ts +1 -1
- package/dist/external-tools/bazel/from-download.d.ts +1 -1
- package/dist/external-tools/bazel/resolve.d.ts +3 -0
- package/dist/external-tools/bazel/resolve.js +3 -0
- package/dist/external-tools/cdxgen/asset-names.d.ts +5 -5
- package/dist/external-tools/cdxgen/asset-names.js +3 -3
- package/dist/external-tools/cdxgen/from-download.d.ts +2 -2
- package/dist/external-tools/cdxgen/from-download.js +1 -1
- package/dist/external-tools/cdxgen/resolve.d.ts +4 -1
- package/dist/external-tools/cdxgen/resolve.js +4 -1
- package/dist/external-tools/cdxgen/types.d.ts +1 -1
- package/dist/external-tools/from-download.d.ts +2 -2
- package/dist/external-tools/from-download.js +1 -1
- package/dist/external-tools/janus/asset-names.d.ts +4 -1
- package/dist/external-tools/janus/asset-names.js +3 -0
- package/dist/external-tools/janus/from-download.d.ts +3 -3
- package/dist/external-tools/janus/from-download.js +2 -2
- package/dist/external-tools/janus/resolve.d.ts +3 -0
- package/dist/external-tools/janus/resolve.js +3 -0
- package/dist/external-tools/jre/asset-names.d.ts +3 -1
- package/dist/external-tools/jre/asset-names.js +2 -0
- package/dist/external-tools/jre/from-download.d.ts +1 -1
- package/dist/external-tools/manifest.d.ts +5 -3
- package/dist/external-tools/manifest.js +4 -2
- package/dist/external-tools/opengrep/asset-names.d.ts +1 -1
- package/dist/external-tools/opengrep/resolve.d.ts +3 -0
- package/dist/external-tools/opengrep/resolve.js +3 -0
- package/dist/external-tools/python/asset-names.d.ts +3 -1
- package/dist/external-tools/python/asset-names.js +7 -3
- package/dist/external-tools/python/pin.js +3 -1
- package/dist/external-tools/python/resolve.d.ts +3 -0
- package/dist/external-tools/python/resolve.js +3 -0
- package/dist/external-tools/sbt/resolve.d.ts +3 -0
- package/dist/external-tools/sbt/resolve.js +3 -0
- package/dist/external-tools/skillspector/from-uv.d.ts +1 -1
- package/dist/external-tools/synp/resolve.d.ts +3 -0
- package/dist/external-tools/synp/resolve.js +3 -0
- package/dist/external-tools/trivy/asset-names.d.ts +1 -1
- package/dist/external-tools/trivy/resolve.d.ts +3 -0
- package/dist/external-tools/trivy/resolve.js +3 -0
- package/dist/external-tools/trufflehog/asset-names.d.ts +4 -1
- package/dist/external-tools/trufflehog/asset-names.js +3 -0
- package/dist/external-tools/trufflehog/from-download.d.ts +1 -1
- package/dist/external-tools/trufflehog/resolve.d.ts +3 -0
- package/dist/external-tools/trufflehog/resolve.js +3 -0
- package/dist/external-tools/uv/asset-names.d.ts +1 -1
- package/dist/external-tools/uv/resolve.d.ts +3 -0
- package/dist/external-tools/uv/resolve.js +3 -0
- package/dist/fleet/repo-config.d.ts +8 -6
- package/dist/fleet/repo-config.js +8 -6
- package/dist/fs/_internal.d.ts +1 -1
- package/dist/fs/_internal.js +1 -1
- package/dist/fs/access.d.ts +2 -0
- package/dist/fs/access.js +2 -0
- package/dist/fs/allowed-dirs-cache.js +5 -3
- package/dist/fs/find.js +1 -2
- package/dist/fs/inspect.d.ts +2 -2
- package/dist/fs/read-file.js +3 -4
- package/dist/fs/safe.js +1 -1
- package/dist/git/_internal.js +5 -1
- package/dist/github/commit.d.ts +92 -0
- package/dist/github/commit.js +113 -0
- package/dist/github/ghsa.js +1 -1
- package/dist/github/refs-graphql.js +1 -1
- package/dist/github/request.js +1 -1
- package/dist/github/token.d.ts +5 -2
- package/dist/github/token.js +6 -4
- package/dist/github/workflow-runs.d.ts +107 -0
- package/dist/github/workflow-runs.js +98 -0
- package/dist/http-request/_internal.d.ts +1 -1
- package/dist/http-request/browser.d.ts +6 -0
- package/dist/http-request/browser.js +3 -2
- package/dist/http-request/download.js +2 -0
- package/dist/http-request/headers.d.ts +1 -1
- package/dist/http-request/headers.js +1 -1
- package/dist/http-request/request-attempt.js +6 -3
- package/dist/http-request/request-types.d.ts +10 -1
- package/dist/http-request/request.js +2 -2
- package/dist/http-request/user-agent.d.ts +23 -2
- package/dist/http-request/user-agent.js +48 -6
- package/dist/integrity.d.ts +3 -1
- package/dist/integrity.js +3 -1
- package/dist/json/format.js +4 -1
- package/dist/logger/_internal.d.ts +13 -15
- package/dist/logger/_internal.js +21 -21
- package/dist/logger/colors.d.ts +9 -3
- package/dist/logger/colors.js +6 -13
- package/dist/logger/console-methods.js +2 -2
- package/dist/logger/console.d.ts +1 -0
- package/dist/logger/console.js +9 -9
- package/dist/logger/node.js +2 -1
- package/dist/native-messaging/install.js +1 -1
- package/dist/native-messaging/rate-limit.d.ts +4 -1
- package/dist/native-messaging/rate-limit.js +4 -1
- package/dist/node/events.d.ts +3 -0
- package/dist/node/events.js +3 -0
- package/dist/node/fs.d.ts +1 -1
- package/dist/node/timers-promises.d.ts +3 -0
- package/dist/node/timers-promises.js +3 -0
- package/dist/node/url.d.ts +3 -0
- package/dist/node/url.js +3 -0
- package/dist/npm/meta-cache.d.ts +183 -0
- package/dist/npm/meta-cache.js +318 -0
- package/dist/npm/meta-slice.d.ts +27 -0
- package/dist/npm/meta-slice.js +68 -0
- package/dist/npm/meta-types.d.ts +282 -0
- package/dist/npm/meta-types.js +2 -0
- package/dist/npm/meta.d.ts +125 -0
- package/dist/npm/meta.js +347 -0
- package/dist/npm/registry.d.ts +212 -0
- package/dist/npm/registry.js +284 -0
- package/dist/objects/getters.d.ts +1 -1
- package/dist/objects/getters.js +1 -1
- package/dist/packages/manifest.js +6 -7
- package/dist/packages/metadata-extensions.js +2 -4
- package/dist/packages/provenance.d.ts +8 -0
- package/dist/packages/provenance.js +8 -0
- package/dist/packages/tarball.js +1 -2
- package/dist/packages/validation.d.ts +0 -10
- package/dist/packages/validation.js +0 -14
- package/dist/paths/exts.d.ts +30 -0
- package/dist/paths/exts.js +30 -0
- package/dist/paths/filenames.d.ts +6 -0
- package/dist/paths/filenames.js +6 -0
- package/dist/paths/globs.d.ts +6 -0
- package/dist/paths/globs.js +6 -0
- package/dist/paths/resolve.js +19 -14
- package/dist/paths/socket.d.ts +8 -8
- package/dist/paths/socket.js +8 -8
- package/dist/perf/report.js +4 -2
- package/dist/pkg-ext/data.js +0 -2
- package/dist/primordials/globals.d.ts +1 -1
- package/dist/primordials/globals.js +1 -1
- package/dist/primordials/headers.d.ts +13 -1
- package/dist/primordials/headers.js +13 -1
- package/dist/primordials/process.d.ts +1 -1
- package/dist/primordials/process.js +1 -1
- package/dist/primordials/url.d.ts +18 -0
- package/dist/primordials/url.js +18 -0
- package/dist/process/spawn/child.js +3 -5
- package/dist/promises/_internal.d.ts +1 -1
- package/dist/promises/_internal.js +1 -2
- package/dist/promises/options.js +3 -3
- package/dist/releases/socket-btm-binary-naming.js +12 -1
- package/dist/secrets/_internal.d.ts +1 -1
- package/dist/secrets/_internal.js +1 -1
- package/dist/secrets/find.d.ts +2 -2
- package/dist/secrets/find.js +2 -2
- package/dist/secrets/keychain.d.ts +10 -1
- package/dist/secrets/keychain.js +10 -1
- package/dist/secrets/socket-api-token.d.ts +1 -1
- package/dist/secrets/socket-api-token.js +1 -1
- package/dist/secrets/types.d.ts +1 -1
- package/dist/smol/http.d.ts +2 -0
- package/dist/smol/http.js +2 -0
- package/dist/smol/https.d.ts +2 -0
- package/dist/smol/https.js +2 -0
- package/dist/sorts/_internal.d.ts +2 -3
- package/dist/sorts/_internal.js +1 -3
- package/dist/spinner/format.js +2 -4
- package/dist/stdio/footer.js +8 -7
- package/dist/stdio/prompts.d.ts +8 -15
- package/dist/stdio/prompts.js +18 -29
- package/dist/strings/predicates.d.ts +2 -2
- package/dist/strings/search.js +1 -1
- package/dist/strings/types.d.ts +4 -0
- package/dist/strings/width.d.ts +1 -0
- package/dist/strings/width.js +17 -8
- package/dist/themes/context.d.ts +13 -0
- package/dist/themes/context.js +23 -8
- package/dist/versions/_internal.d.ts +43 -13
- package/dist/versions/_internal.js +27 -15
- package/dist/versions/compare.d.ts +16 -10
- package/dist/versions/compare.js +36 -16
- package/dist/versions/parse.js +1 -1
- package/dist/versions/range.js +3 -2
- package/dist/words/pluralize.js +4 -1
- package/llms.txt +63 -750
- package/package.json +200 -35
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Type surface for the npm metadata client (`./meta`, `./meta-cache`,
|
|
3
|
+
* `./meta-slice`) — the raw packument shapes accepted from the registry, the
|
|
4
|
+
* slimmed shapes the client returns, and the options/result records for the
|
|
5
|
+
* derived helpers (`getVersions`, `getLatestVersion`, `getBatch`, …). Pure
|
|
6
|
+
* types, no runtime side effects.
|
|
7
|
+
*/
|
|
8
|
+
import type { TtlCache } from '../cache/ttl/types';
|
|
9
|
+
import type { HttpRequestOptions } from '../http-request/node';
|
|
10
|
+
/**
|
|
11
|
+
* Per-name/per-batch failure shape returned by `getBatch` in place of a
|
|
12
|
+
* `PackumentMetaSlim` entry when a fetch fails and `throwOnError` is `false`.
|
|
13
|
+
*/
|
|
14
|
+
export interface PackageError {
|
|
15
|
+
error: string;
|
|
16
|
+
name: string;
|
|
17
|
+
status?: number | undefined;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Options for `getBatch`. Extends the single-package fetch options — every
|
|
21
|
+
* name in the batch shares the same registry/variant/cache/http adapter.
|
|
22
|
+
*/
|
|
23
|
+
export interface BatchOptions extends GetPackumentSlimOptions {
|
|
24
|
+
/**
|
|
25
|
+
* Number of packages fetched concurrently.
|
|
26
|
+
*
|
|
27
|
+
* @default 8
|
|
28
|
+
*/
|
|
29
|
+
concurrency?: number | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* When `true`, every item is still attempted (nothing is aborted
|
|
32
|
+
* in-flight), but once every item has settled, the error from the
|
|
33
|
+
* LOWEST-INDEX failed item is thrown — deterministic regardless of settle
|
|
34
|
+
* order. When `false` (default), failures are captured as `PackageError`
|
|
35
|
+
* entries at their original index.
|
|
36
|
+
*
|
|
37
|
+
* @default false
|
|
38
|
+
*/
|
|
39
|
+
throwOnError?: boolean | undefined;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Index-preserving element of `getBatch`'s return array — either the slimmed
|
|
43
|
+
* packument or a `PackageError` for that name.
|
|
44
|
+
*/
|
|
45
|
+
export type BatchResult = PackageError | PackumentMetaSlim;
|
|
46
|
+
/**
|
|
47
|
+
* Options shared by every `getPackumentSlim`-backed helper.
|
|
48
|
+
*/
|
|
49
|
+
export interface GetPackumentSlimOptions {
|
|
50
|
+
/**
|
|
51
|
+
* Cache instance backing the fetch. Defaults to a lazily-created module
|
|
52
|
+
* singleton (`prefix: 'npm-meta'`, 15-minute TTL). Pass a dedicated instance
|
|
53
|
+
* (`createNpmMetaCache`) for test isolation or a non-default TTL.
|
|
54
|
+
*/
|
|
55
|
+
cache?: TtlCache | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Bypass a cached entry and refetch — unless the entry is younger than 30
|
|
58
|
+
* seconds, in which case the cached value is still served (coalesces bursts
|
|
59
|
+
* of forced refreshes into one upstream fetch).
|
|
60
|
+
*
|
|
61
|
+
* @default false
|
|
62
|
+
*/
|
|
63
|
+
force?: boolean | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* Injectable HTTP adapter, mirroring `NpmHttpOptions` from `./registry`.
|
|
66
|
+
* Defaults to `httpJson` from `../http-request/node`.
|
|
67
|
+
*/
|
|
68
|
+
http?: NpmMetaHttpAdapter | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* Registry base URL.
|
|
71
|
+
*
|
|
72
|
+
* @default 'https://registry.npmjs.org'
|
|
73
|
+
*/
|
|
74
|
+
registry?: string | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* Forwarded to the HTTP adapter.
|
|
77
|
+
*/
|
|
78
|
+
retries?: number | undefined;
|
|
79
|
+
/**
|
|
80
|
+
* Forwarded to the HTTP adapter.
|
|
81
|
+
*/
|
|
82
|
+
timeout?: number | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* `'abbreviated'` (default) omits `_npmUser` trust signals and most
|
|
85
|
+
* metadata — cheap, used for version listing. `'full'` is required to read
|
|
86
|
+
* `trustedPublisher` / `staged` / `integrity` / `shasum`.
|
|
87
|
+
*
|
|
88
|
+
* @default 'abbreviated'
|
|
89
|
+
*/
|
|
90
|
+
variant?: PackumentVariant | undefined;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Options for `getVersions` / `getLatestVersion` — semver filtering layered on
|
|
94
|
+
* top of the base fetch options.
|
|
95
|
+
*/
|
|
96
|
+
export interface GetVersionsOptions extends GetPackumentSlimOptions {
|
|
97
|
+
/**
|
|
98
|
+
* Time floor — only versions published at or after this instant are kept
|
|
99
|
+
* (inclusive). Accepts an ISO 8601 string OR a numeric epoch (a `number` or
|
|
100
|
+
* a numeric string matching `/^\d+$/`) — a string is treated as an epoch
|
|
101
|
+
* ONLY when it is entirely digits; anything else is parsed as an ISO 8601
|
|
102
|
+
* date, so a date string is never misread as an epoch. Throws `RangeError`
|
|
103
|
+
* (via `toEpochMs`) when the value is neither. A version with no recorded
|
|
104
|
+
* publish time is EXCLUDED rather than included by default: it cannot be
|
|
105
|
+
* proven to satisfy the floor, and for a time-based filter a false negative
|
|
106
|
+
* (unfairly dropped) is the safer failure mode than a false positive
|
|
107
|
+
* (unfairly kept).
|
|
108
|
+
*/
|
|
109
|
+
after?: string | number | undefined;
|
|
110
|
+
/**
|
|
111
|
+
* Whether `range` may match a prerelease version (`2.0.0-beta.0`) even when
|
|
112
|
+
* the range itself has no prerelease component. Passed explicitly to every
|
|
113
|
+
* semver call this module makes — never left to the vendored semver's
|
|
114
|
+
* implicit default.
|
|
115
|
+
*
|
|
116
|
+
* @default false
|
|
117
|
+
*/
|
|
118
|
+
includePrerelease?: boolean | undefined;
|
|
119
|
+
/**
|
|
120
|
+
* Loose semver parsing for `range`.
|
|
121
|
+
*
|
|
122
|
+
* @default false
|
|
123
|
+
*/
|
|
124
|
+
loose?: boolean | undefined;
|
|
125
|
+
/**
|
|
126
|
+
* Maturity filter in days — only versions whose publish time is at least
|
|
127
|
+
* this many days old are kept. The publish time is anchored to the END of
|
|
128
|
+
* its UTC day before `minAgeDays` is added (Socket soak-window semantics), so
|
|
129
|
+
* a version published at any point during a UTC day matures at the same
|
|
130
|
+
* wall-clock instant. Like `after`, a version with no recorded publish time
|
|
131
|
+
* is excluded.
|
|
132
|
+
*/
|
|
133
|
+
minAgeDays?: number | undefined;
|
|
134
|
+
/**
|
|
135
|
+
* A semver range, an exact version, or a dist-tag name — resolved in that
|
|
136
|
+
* priority order against the packument (npm forbids a dist-tag name that is
|
|
137
|
+
* also valid semver, so the three never collide):
|
|
138
|
+
*
|
|
139
|
+
* 1. A dist-tag key (e.g. `"beta"`) resolves to the single version it points to.
|
|
140
|
+
* Throws `PackumentNotFoundError` if that version is missing from the
|
|
141
|
+
* packument (a stale or inconsistent packument).
|
|
142
|
+
* 2. An exact, valid semver version resolves to itself. Throws
|
|
143
|
+
* `PackumentNotFoundError` if it isn't in the packument — `getVersions`
|
|
144
|
+
* never falls back to the full list on a specific miss.
|
|
145
|
+
* 3. Anything else is treated as a semver range filter. Versions that don't
|
|
146
|
+
* satisfy it are dropped; an empty result (not an error) when nothing
|
|
147
|
+
* matches, since a narrow-but-valid range matching zero versions is not a
|
|
148
|
+
* "not found" case.
|
|
149
|
+
*/
|
|
150
|
+
range?: string | undefined;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Result of `getVersions` — the filtered version list plus enough context
|
|
154
|
+
* (`time`, `distTags`) that callers rarely need a second fetch.
|
|
155
|
+
*/
|
|
156
|
+
export interface GetVersionsResult {
|
|
157
|
+
distTags: Record<string, string>;
|
|
158
|
+
time: Record<string, string>;
|
|
159
|
+
versions: string[];
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Result of `getLatestVersion`.
|
|
163
|
+
*/
|
|
164
|
+
export interface LatestVersionResult {
|
|
165
|
+
distTags: Record<string, string>;
|
|
166
|
+
publishedAt: string | undefined;
|
|
167
|
+
version: string;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Injectable HTTP adapter for the metadata client. Signature-compatible with
|
|
171
|
+
* `httpJson` from `../http-request/node` so the default is a direct reference.
|
|
172
|
+
*/
|
|
173
|
+
export interface NpmMetaHttpAdapter {
|
|
174
|
+
json<T>(url: string, options?: HttpRequestOptions | undefined): Promise<T>;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* The slimmed packument this client returns — top-level fields plus the
|
|
178
|
+
* per-version map from `sliceVersionMeta`.
|
|
179
|
+
*/
|
|
180
|
+
export interface PackumentMetaSlim {
|
|
181
|
+
distTags: Record<string, string>;
|
|
182
|
+
/**
|
|
183
|
+
* `Date.now()` at fetch time (not the registry's `time.modified`) — lets
|
|
184
|
+
* callers reason about cache freshness without inspecting the cache layer.
|
|
185
|
+
*/
|
|
186
|
+
lastSynced: number;
|
|
187
|
+
name: string;
|
|
188
|
+
timeCreated?: string | undefined;
|
|
189
|
+
timeModified?: string | undefined;
|
|
190
|
+
versions: Record<string, PackumentVersionMetaSlim>;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* `'abbreviated'` matches npm's `Accept: application/vnd.npm.install-v1+json`
|
|
194
|
+
* fast packument (no `_npmUser`); `'full'` is the plain packument.
|
|
195
|
+
*/
|
|
196
|
+
export type PackumentVariant = 'abbreviated' | 'full';
|
|
197
|
+
/**
|
|
198
|
+
* Slimmed per-version metadata — `sliceVersionMeta`'s output shape for one
|
|
199
|
+
* version entry.
|
|
200
|
+
*/
|
|
201
|
+
export interface PackumentVersionMetaSlim {
|
|
202
|
+
attestations?: unknown | undefined;
|
|
203
|
+
deprecated?: string | undefined;
|
|
204
|
+
engines?: Record<string, string> | undefined;
|
|
205
|
+
integrity?: string | undefined;
|
|
206
|
+
shasum?: string | undefined;
|
|
207
|
+
/**
|
|
208
|
+
* Boolean form of `_npmUser?.approver` — `true` when the version was
|
|
209
|
+
* published through a staged/approval flow.
|
|
210
|
+
*/
|
|
211
|
+
staged?: boolean | undefined;
|
|
212
|
+
tarball?: string | undefined;
|
|
213
|
+
time: string;
|
|
214
|
+
/**
|
|
215
|
+
* Boolean form of `_npmUser?.trustedPublisher`.
|
|
216
|
+
*/
|
|
217
|
+
trustedPublisher?: boolean | undefined;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Raw `_npmUser` shape from a full-variant packument version entry.
|
|
221
|
+
*/
|
|
222
|
+
export interface RawNpmUser {
|
|
223
|
+
approver?: unknown | undefined;
|
|
224
|
+
trustedPublisher?: boolean | undefined;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Raw packument JSON as received from the registry — the input to
|
|
228
|
+
* `slicePackument` / `sliceVersionMeta`.
|
|
229
|
+
*
|
|
230
|
+
* Deliberately separate from `./registry`'s `PackumentRecord` /
|
|
231
|
+
* `PackumentVersion` / `PackumentVersionDist` hierarchy, not an oversight:
|
|
232
|
+
* this client needs `_npmUser`, `engines`, and the full `dist.integrity` /
|
|
233
|
+
* `dist.shasum` fields (for `getVersionTrustInfo` and the
|
|
234
|
+
* abbreviated-vs-full variant split), none of which `./registry`'s
|
|
235
|
+
* browser-safe, Trusted-Publisher-detection-only surface carries. The two
|
|
236
|
+
* hierarchies are NOT meant to be interchangeable — passing a `./registry`
|
|
237
|
+
* `PackumentVersion` where a `RawPackumentVersion` is expected needs an
|
|
238
|
+
* explicit re-shape, since `PackumentVersion`'s `engines` and other extra
|
|
239
|
+
* fields resolve through its `[field: string]: unknown` index signature.
|
|
240
|
+
* `test/unit/npm/meta-types.test.mts` type-checks the fields the two
|
|
241
|
+
* hierarchies DO intentionally share, so a future edit to either side can't
|
|
242
|
+
* silently break that overlap.
|
|
243
|
+
*/
|
|
244
|
+
export interface RawPackument {
|
|
245
|
+
'dist-tags'?: Record<string, string> | undefined;
|
|
246
|
+
name?: string | undefined;
|
|
247
|
+
time?: Record<string, string> | undefined;
|
|
248
|
+
versions?: Record<string, RawPackumentVersion> | undefined;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Raw per-version entry from a packument. `_npmUser` is present only on the
|
|
252
|
+
* `'full'` variant.
|
|
253
|
+
*/
|
|
254
|
+
export interface RawPackumentVersion {
|
|
255
|
+
_npmUser?: RawNpmUser | undefined;
|
|
256
|
+
deprecated?: string | undefined;
|
|
257
|
+
dist?: RawVersionDist | undefined;
|
|
258
|
+
engines?: Record<string, string> | undefined;
|
|
259
|
+
[field: string]: unknown;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Raw `dist` shape from a packument version entry.
|
|
263
|
+
*/
|
|
264
|
+
export interface RawVersionDist {
|
|
265
|
+
attestations?: unknown | undefined;
|
|
266
|
+
integrity?: string | undefined;
|
|
267
|
+
shasum?: string | undefined;
|
|
268
|
+
tarball?: string | undefined;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Per-version trust signals returned by `getVersionTrustInfo`. `approver`
|
|
272
|
+
* mirrors `PackumentVersionMetaSlim.staged` — named for its source field
|
|
273
|
+
* (`_npmUser.approver`) since this helper is specifically about trust
|
|
274
|
+
* provenance rather than general slimmed metadata.
|
|
275
|
+
*/
|
|
276
|
+
export interface VersionTrustInfo {
|
|
277
|
+
approver?: boolean | undefined;
|
|
278
|
+
attestations?: unknown | undefined;
|
|
279
|
+
integrity?: string | undefined;
|
|
280
|
+
shasum?: string | undefined;
|
|
281
|
+
trustedPublisher?: boolean | undefined;
|
|
282
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Cached, batch-capable npm registry metadata client — the Socket-wide
|
|
3
|
+
* replacement for ad-hoc packument fetchers. Sibling of `./registry` (pure
|
|
4
|
+
* parsers + injectable HTTP): this module owns caching (`./meta-cache`),
|
|
5
|
+
* slimming (`./meta-slice`), and the derived helpers built on top
|
|
6
|
+
* (`getVersions`, `getLatestVersion`, `getPublishDate`,
|
|
7
|
+
* `getVersionTrustInfo`, `getBatch`) plus their `safe*` fail-open variants.
|
|
8
|
+
* Node-only (the cache layer is cacache-backed) — unlike `./registry`, this
|
|
9
|
+
* module is not browser-safe.
|
|
10
|
+
*/
|
|
11
|
+
import type { BatchOptions, BatchResult, GetPackumentSlimOptions, GetVersionsOptions, GetVersionsResult, LatestVersionResult, PackumentMetaSlim, VersionTrustInfo } from './meta-types';
|
|
12
|
+
export { buildMetaCacheKey, createNpmMetaCache, fetchPackumentSlim, getDefaultMetaCache, getPackumentSlim, getStaleMeta, PackumentNotFoundError, rememberStaleMeta, } from './meta-cache';
|
|
13
|
+
export { sliceOneVersion, slicePackument, sliceVersionMeta } from './meta-slice';
|
|
14
|
+
export type { CachedPackumentEntry, CachedPackumentHit, CachedPackumentMiss, ResolvedPackumentFetchOptions, } from './meta-cache';
|
|
15
|
+
export type { BatchOptions, BatchResult, GetPackumentSlimOptions, GetVersionsOptions, GetVersionsResult, LatestVersionResult, NpmMetaHttpAdapter, PackageError, PackumentMetaSlim, PackumentVariant, PackumentVersionMetaSlim, RawNpmUser, RawPackument, RawPackumentVersion, RawVersionDist, VersionTrustInfo, } from './meta-types';
|
|
16
|
+
/**
|
|
17
|
+
* Extract the HTTP status code from a caught error when it came from the
|
|
18
|
+
* `httpJson` adapter (`HttpResponseError`) or a synthesized
|
|
19
|
+
* `PackumentNotFoundError`; `undefined` for anything else (network failure,
|
|
20
|
+
* abort, a custom test-double error).
|
|
21
|
+
*/
|
|
22
|
+
export declare function extractHttpStatus(error: unknown): number | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Fetch `getPackumentSlim` for every name with bounded concurrency, returning
|
|
25
|
+
* an index-preserving array. Every item is attempted regardless of
|
|
26
|
+
* `throwOnError` — nothing is aborted in-flight. A per-item failure becomes a
|
|
27
|
+
* `PackageError` at that index; when `throwOnError` is `true`, once every
|
|
28
|
+
* item has settled the error from the LOWEST-INDEX failed item is thrown —
|
|
29
|
+
* deterministic regardless of settle order.
|
|
30
|
+
*/
|
|
31
|
+
export declare function getBatch(names: string[], options?: BatchOptions | undefined): Promise<BatchResult[]>;
|
|
32
|
+
/**
|
|
33
|
+
* Resolve the latest version — `distTags.latest` when no `range` is given, or
|
|
34
|
+
* (when `range` is given) the same dist-tag / exact-version / semver-range
|
|
35
|
+
* resolution `getVersions` uses (`resolveRequestedVersions`), narrowed to a
|
|
36
|
+
* single version. There is no silent fallback to `distTags.latest`: a
|
|
37
|
+
* dist-tag or exact version that doesn't resolve throws (same contract as
|
|
38
|
+
* `getVersions`), and a range matching nothing throws too — an unsatisfiable
|
|
39
|
+
* range must never return a version outside what the caller asked for.
|
|
40
|
+
*
|
|
41
|
+
* @throws {PackumentNotFoundError} When `range` names an exact version or
|
|
42
|
+
* dist-tag that isn't present in the packument, or a semver range that no
|
|
43
|
+
* version satisfies.
|
|
44
|
+
*/
|
|
45
|
+
export declare function getLatestVersion(name: string, options?: GetVersionsOptions | undefined): Promise<LatestVersionResult>;
|
|
46
|
+
/**
|
|
47
|
+
* Look up a single version's publish time (ISO string), or `undefined` when
|
|
48
|
+
* the version isn't in the packument.
|
|
49
|
+
*/
|
|
50
|
+
export declare function getPublishDate(name: string, version: string, options?: GetPackumentSlimOptions | undefined): Promise<string | undefined>;
|
|
51
|
+
/**
|
|
52
|
+
* Per-version trust signals (forces `variant: 'full'` — `_npmUser` is absent
|
|
53
|
+
* from the abbreviated packument).
|
|
54
|
+
*/
|
|
55
|
+
export declare function getVersionTrustInfo(name: string, options?: GetPackumentSlimOptions | undefined): Promise<Record<string, VersionTrustInfo>>;
|
|
56
|
+
/**
|
|
57
|
+
* List versions, optionally filtered by `range` (a semver range, an exact
|
|
58
|
+
* version, or a dist-tag name — see `GetVersionsOptions.range`), an `after`
|
|
59
|
+
* time floor, and/or a `minAgeDays` maturity window. See `GetVersionsOptions`
|
|
60
|
+
* for the `minAgeDays` end-of-UTC-day anchor semantics.
|
|
61
|
+
*
|
|
62
|
+
* @throws {PackumentNotFoundError} When `range` names an exact version or
|
|
63
|
+
* dist-tag that isn't present in the packument.
|
|
64
|
+
*/
|
|
65
|
+
export declare function getVersions(name: string, options?: GetVersionsOptions | undefined): Promise<GetVersionsResult>;
|
|
66
|
+
/**
|
|
67
|
+
* `true` when `publishedAt` is at least `minAgeDays` days old, anchored to the
|
|
68
|
+
* END of `publishedAt`'s UTC day (Socket soak-window semantics) — a version
|
|
69
|
+
* published at any point during a UTC day matures at the same wall-clock
|
|
70
|
+
* instant, `minAgeDays` later at 23:59:59.999 UTC. Returns `false` for an
|
|
71
|
+
* unparseable `publishedAt`.
|
|
72
|
+
*/
|
|
73
|
+
export declare function isMatured(publishedAt: string, minAgeDays: number, now?: number): boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Resolve `options.range` against a packument's dist-tags / version set.
|
|
76
|
+
* Exported standalone so its resolution order is independently testable. See
|
|
77
|
+
* `GetVersionsOptions.range` for the full priority-order contract (dist-tag →
|
|
78
|
+
* exact version → semver range filter).
|
|
79
|
+
*
|
|
80
|
+
* @throws {PackumentNotFoundError} When `range` names a dist-tag or exact
|
|
81
|
+
* version that isn't present in the packument.
|
|
82
|
+
*/
|
|
83
|
+
export declare function resolveRequestedVersions(name: string, meta: PackumentMetaSlim, options: GetVersionsOptions): string[];
|
|
84
|
+
/**
|
|
85
|
+
* Fail-open `getLatestVersion` — `undefined` on any error.
|
|
86
|
+
*
|
|
87
|
+
* @unused No internal or Socket consumers (exercised only by its unit tests).
|
|
88
|
+
*/
|
|
89
|
+
export declare function safeGetLatestVersion(name: string, options?: GetVersionsOptions | undefined): Promise<LatestVersionResult | undefined>;
|
|
90
|
+
/**
|
|
91
|
+
* Fail-open `getPackumentSlim` — `undefined` on any error.
|
|
92
|
+
*
|
|
93
|
+
* @unused No internal or Socket consumers (exercised only by its unit tests).
|
|
94
|
+
*/
|
|
95
|
+
export declare function safeGetPackumentSlim(name: string, options?: GetPackumentSlimOptions | undefined): Promise<PackumentMetaSlim | undefined>;
|
|
96
|
+
/**
|
|
97
|
+
* Fail-open `getPublishDate` — `undefined` on any error.
|
|
98
|
+
*
|
|
99
|
+
* @unused No internal or Socket consumers (exercised only by its unit tests).
|
|
100
|
+
*/
|
|
101
|
+
export declare function safeGetPublishDate(name: string, version: string, options?: GetPackumentSlimOptions | undefined): Promise<string | undefined>;
|
|
102
|
+
/**
|
|
103
|
+
* Fail-open `getVersionTrustInfo` — an empty record on any error.
|
|
104
|
+
*
|
|
105
|
+
* @unused No internal or Socket consumers (exercised only by its unit tests).
|
|
106
|
+
*/
|
|
107
|
+
export declare function safeGetVersionTrustInfo(name: string, options?: GetPackumentSlimOptions | undefined): Promise<Record<string, VersionTrustInfo>>;
|
|
108
|
+
/**
|
|
109
|
+
* Fail-open `getVersions` — an empty result on any error.
|
|
110
|
+
*
|
|
111
|
+
* @unused No internal or Socket consumers (exercised only by its unit tests).
|
|
112
|
+
*/
|
|
113
|
+
export declare function safeGetVersions(name: string, options?: GetVersionsOptions | undefined): Promise<GetVersionsResult>;
|
|
114
|
+
/**
|
|
115
|
+
* Resolve an `after` filter value to epoch milliseconds. A `number` is used
|
|
116
|
+
* as-is. A string is treated as an epoch ONLY when it is entirely digits
|
|
117
|
+
* (`/^\d+$/`) — never by trying `Number()` first, which would also accept
|
|
118
|
+
* whitespace, exponents, and other numeric-ish forms `Date.parse` should get
|
|
119
|
+
* a chance at instead. Anything not all-digits is parsed via `Date.parse`.
|
|
120
|
+
*
|
|
121
|
+
* @throws {RangeError} When `after` cannot be resolved to a valid epoch —
|
|
122
|
+
* silently skipping the `after` filter on an unparseable value is the exact
|
|
123
|
+
* reference-implementation bug this module exists to avoid.
|
|
124
|
+
*/
|
|
125
|
+
export declare function toEpochMs(after: string | number): number;
|