@pnpm/resolving.npm-resolver 1102.1.7 → 1102.1.9

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 CHANGED
@@ -1,5 +1,44 @@
1
1
  # @pnpm/npm-resolver
2
2
 
3
+ ## 1102.1.9
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies:
8
+ - @pnpm/config.pick-registry-for-package@1100.0.13
9
+ - @pnpm/config.version-policy@1100.1.10
10
+ - @pnpm/core-loggers@1100.3.0
11
+ - @pnpm/resolving.registry.pkg-metadata-filter@1100.0.13
12
+ - @pnpm/resolving.registry.types@1100.1.7
13
+ - @pnpm/resolving.resolver-base@1100.5.5
14
+ - @pnpm/store.cafs@1100.1.16
15
+ - @pnpm/types@1101.7.0
16
+
17
+ ## 1102.1.8
18
+
19
+ ### Patch Changes
20
+
21
+ - Republished every package: the tarballs published by the v11.13.1 through v11.16.0 releases were missing most of their compiled files due to a packing bug [#13164](https://github.com/pnpm/pnpm/issues/13164).
22
+
23
+ - Updated dependencies:
24
+ - @pnpm/config.pick-registry-for-package@1100.0.12
25
+ - @pnpm/config.version-policy@1100.1.9
26
+ - @pnpm/constants@1100.0.1
27
+ - @pnpm/core-loggers@1100.2.5
28
+ - @pnpm/crypto.hash@1100.0.2
29
+ - @pnpm/error@1100.1.0
30
+ - @pnpm/fetching.types@1100.0.3
31
+ - @pnpm/fs.graceful-fs@1100.1.1
32
+ - @pnpm/resolving.jsr-specifier-parser@1100.0.3
33
+ - @pnpm/resolving.registry.pkg-metadata-filter@1100.0.12
34
+ - @pnpm/resolving.registry.types@1100.1.6
35
+ - @pnpm/resolving.resolver-base@1100.5.4
36
+ - @pnpm/store.cafs@1100.1.15
37
+ - @pnpm/store.index@1100.2.2
38
+ - @pnpm/types@1101.6.0
39
+ - @pnpm/workspace.range-resolver@1100.0.3
40
+ - @pnpm/workspace.spec-parser@1100.0.1
41
+
3
42
  ## 1102.1.7
4
43
 
5
44
  ### Patch Changes
@@ -0,0 +1,24 @@
1
+ import type { PackageMeta } from '@pnpm/resolving.registry.types';
2
+ /**
3
+ * Reduces a package metadata document to the abbreviated field set that the
4
+ * resolver actually reads, dropping install-irrelevant fields (scripts,
5
+ * exports, readme, custom `_`-prefixed fields, etc.). Retaining unstripped
6
+ * full documents — tens of MB parsed for a popular package — is what drove
7
+ * large installs out of memory (https://github.com/pnpm/pnpm/issues/8441).
8
+ * `etag` is carried over so a condensed document can still answer
9
+ * conditional-request headers.
10
+ *
11
+ * Null-safe on `versions` so it can be called on an unpublished package (no
12
+ * versions), which the abbreviated path can reach.
13
+ */
14
+ export declare function clearMeta(pkg: PackageMeta): PackageMeta;
15
+ /**
16
+ * Whether a resolver keeps full packuments rather than condensing them with
17
+ * {@link clearMeta}: only `fullMetadata` without `filterMetadata`, whose
18
+ * consumers read fields outside the abbreviated set (`pnpm outdated --long`
19
+ * shows description/homepage).
20
+ */
21
+ export declare function retainsFullMeta(opts: {
22
+ fullMetadata?: boolean;
23
+ filterMetadata?: boolean;
24
+ }): boolean;
@@ -0,0 +1,76 @@
1
+ import { pick } from 'ramda';
2
+ // The list taken from https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md#abbreviated-version-object
3
+ // with the addition of 'libc'
4
+ const ABBREVIATED_VERSION_FIELDS = [
5
+ 'name',
6
+ 'version',
7
+ 'bin',
8
+ 'directories',
9
+ 'devDependencies',
10
+ 'optionalDependencies',
11
+ 'dependencies',
12
+ 'peerDependencies',
13
+ 'dist',
14
+ 'engines',
15
+ 'peerDependenciesMeta',
16
+ 'cpu',
17
+ 'os',
18
+ 'libc',
19
+ 'deprecated',
20
+ 'bundleDependencies',
21
+ 'bundledDependencies',
22
+ 'hasInstallScript',
23
+ '_npmUser',
24
+ ];
25
+ // Memoized by input identity: several layers condense the same parsed
26
+ // document, and the WeakMap makes them share one condensed copy instead of
27
+ // pinning one each. Outputs map to themselves so re-condensing is the
28
+ // identity.
29
+ const condensedPackuments = new WeakMap();
30
+ /**
31
+ * Reduces a package metadata document to the abbreviated field set that the
32
+ * resolver actually reads, dropping install-irrelevant fields (scripts,
33
+ * exports, readme, custom `_`-prefixed fields, etc.). Retaining unstripped
34
+ * full documents — tens of MB parsed for a popular package — is what drove
35
+ * large installs out of memory (https://github.com/pnpm/pnpm/issues/8441).
36
+ * `etag` is carried over so a condensed document can still answer
37
+ * conditional-request headers.
38
+ *
39
+ * Null-safe on `versions` so it can be called on an unpublished package (no
40
+ * versions), which the abbreviated path can reach.
41
+ */
42
+ export function clearMeta(pkg) {
43
+ const memoized = condensedPackuments.get(pkg);
44
+ if (memoized != null)
45
+ return memoized;
46
+ // A null prototype so that a registry-controlled version key named
47
+ // `__proto__` becomes a regular own property instead of mutating the
48
+ // prototype of the map (js/prototype-polluting-assignment).
49
+ const versions = Object.create(null);
50
+ for (const [version, info] of Object.entries(pkg.versions ?? {})) {
51
+ versions[version] = pick(ABBREVIATED_VERSION_FIELDS, info);
52
+ }
53
+ const condensed = {
54
+ name: pkg.name,
55
+ 'dist-tags': pkg['dist-tags'],
56
+ versions,
57
+ time: pkg.time,
58
+ modified: pkg.modified,
59
+ };
60
+ if (pkg.etag != null) {
61
+ condensed.etag = pkg.etag;
62
+ }
63
+ condensedPackuments.set(pkg, condensed);
64
+ condensedPackuments.set(condensed, condensed);
65
+ return condensed;
66
+ }
67
+ /**
68
+ * Whether a resolver keeps full packuments rather than condensing them with
69
+ * {@link clearMeta}: only `fullMetadata` without `filterMetadata`, whose
70
+ * consumers read fields outside the abbreviated set (`pnpm outdated --long`
71
+ * shows description/homepage).
72
+ */
73
+ export function retainsFullMeta(opts) {
74
+ return opts.fullMetadata === true && opts.filterMetadata !== true;
75
+ }
76
+ //# sourceMappingURL=clearMeta.js.map
@@ -0,0 +1,89 @@
1
+ import type { GetAuthHeader } from '@pnpm/fetching.types';
2
+ import { type ResolutionVerifier } from '@pnpm/resolving.resolver-base';
3
+ import type { Registries, TrustPolicy } from '@pnpm/types';
4
+ import type { FetchMetadataFromFromRegistryOptions } from './fetch.js';
5
+ import { type FetchFullMetadataCachedOptions } from './fetchFullMetadataCached.js';
6
+ import type { PackageMetaCache } from './pickPackage.js';
7
+ export interface CreateNpmResolutionVerifierOptions {
8
+ /**
9
+ * Minimum age (in minutes) a published version must reach before it is
10
+ * accepted. When unset, the verifier is a no-op for the age check.
11
+ */
12
+ minimumReleaseAge?: number;
13
+ /**
14
+ * Retained on the options bag because the resolver path branches on it
15
+ * (the lowest-version fallback) and tests forward both fields together.
16
+ * The verifier itself no longer gates on this flag — once the loose-mode
17
+ * auto-collect makes every accepted-immature pin explicit in
18
+ * `minimumReleaseAgeExclude`, running the verifier in loose mode is the
19
+ * thing that proves the manifest stays in sync with the lockfile.
20
+ */
21
+ minimumReleaseAgeStrict?: boolean;
22
+ minimumReleaseAgeExclude?: string[];
23
+ /**
24
+ * When the registry's metadata lacks the per-version `time` field
25
+ * (some self-hosted registries strip it), the verifier can't apply
26
+ * the maturity cutoff. Set this to `true` to mirror the resolver's
27
+ * `pickMatchingVersionFinal` warn-and-skip behavior — the verifier
28
+ * passes the entry with a one-time `globalWarn`, instead of failing
29
+ * closed. Defaults to `false` so the verifier stays stricter than
30
+ * the resolver only when the user has explicitly opted in to the
31
+ * skip on the resolver side.
32
+ */
33
+ ignoreMissingTimeField?: boolean;
34
+ /**
35
+ * `'no-downgrade'` rejects a lockfile entry whose version has weaker
36
+ * trust evidence (no attestations) than an earlier-published version
37
+ * had. This mirrors the resolver-time `failIfTrustDowngraded` check
38
+ * applied during fresh resolution — the verifier catches the same
39
+ * supply-chain signal on entries that bypassed resolution (peek-path,
40
+ * frozen lockfile, etc.).
41
+ */
42
+ trustPolicy?: TrustPolicy;
43
+ trustPolicyExclude?: string[];
44
+ trustPolicyIgnoreAfter?: number;
45
+ registries: Registries;
46
+ /**
47
+ * Registries reached via the named-registry resolver chain (e.g. `gh:` →
48
+ * GitHub Packages). When a lockfile entry's tarball URL falls under one of
49
+ * these registry base URLs, route the manifest fetch there instead of the
50
+ * scope-derived default.
51
+ */
52
+ namedRegistries?: Record<string, string>;
53
+ /**
54
+ * Cache-aware full-metadata fetcher. Decoupled from the resolver pipeline
55
+ * so abbreviated metadata and `peekManifestFromStore` fast paths cannot
56
+ * hide the publish timestamp.
57
+ */
58
+ fetchOpts: FetchMetadataFromFromRegistryOptions;
59
+ getAuthHeaderValueByURI: GetAuthHeader;
60
+ cacheDir?: FetchFullMetadataCachedOptions['cacheDir'];
61
+ /**
62
+ * Per-install LRU shared with the npm resolver's `pickPackage`
63
+ * (`{ get, set }` over `PackageMeta`). When provided, the verifier
64
+ * consults it before fetching: a name the resolver already pulled
65
+ * during the same install yields the cached packument instead of a
66
+ * fresh disk/network round-trip. Optional — frozen-install paths and
67
+ * unit tests don't have a resolver running alongside, in which case
68
+ * the verifier falls back to its own fetch chain.
69
+ */
70
+ metaCache?: PackageMetaCache;
71
+ /** Overrides Date.now() for tests. */
72
+ now?: number;
73
+ }
74
+ /**
75
+ * Returns a `ResolutionVerifier` for npm-registry-resolved lockfile
76
+ * entries. It always binds each entry's recorded tarball URL to the
77
+ * artifact the registry's metadata lists (an anti-tamper check that does
78
+ * not depend on any policy), and additionally re-applies the
79
+ * `minimumReleaseAge` and/or `trustPolicy='no-downgrade'` policies when
80
+ * those are configured. Pairs with `createNpmResolver`: each resolver
81
+ * factory may export a sibling verifier factory that the default-resolver
82
+ * combines.
83
+ *
84
+ * Designed for fail-closed semantics: if the manifest can't be loaded or
85
+ * the pinned version is missing from it, the verifier reports a violation
86
+ * rather than silently passing. Mirrors the post-resolution gate bun added
87
+ * for the same shape of bug in oven-sh/bun#30526.
88
+ */
89
+ export declare function createNpmResolutionVerifier(opts: CreateNpmResolutionVerifierOptions): ResolutionVerifier;