@pnpm/engine.runtime.node-resolver 1101.1.4 → 1101.1.6

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.
Files changed (2) hide show
  1. package/lib/index.js +17 -8
  2. package/package.json +7 -7
package/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { fetchShasumsFile } from '@pnpm/crypto.shasums-file';
1
+ import { fetchShasumsFile, fetchVerifiedNodeShasumsFile } from '@pnpm/crypto.shasums-file';
2
2
  import { PnpmError } from '@pnpm/error';
3
3
  import semver from 'semver';
4
4
  import versionSelectorType from 'version-selector-type';
@@ -32,7 +32,7 @@ export async function resolveNodeRuntime(ctx, wantedDependency, opts) {
32
32
  if (!version) {
33
33
  throw new PnpmError('NODEJS_VERSION_NOT_FOUND', `Could not find a Node.js version that satisfies ${versionSpec}`);
34
34
  }
35
- const variants = await readNodeAssets(ctx.fetchFromRegistry, nodeMirrorBaseUrl, version);
35
+ const variants = await readNodeAssets(ctx.fetchFromRegistry, nodeMirrorBaseUrl, version, releaseChannel);
36
36
  const range = version === versionSpec ? version : `^${version}`;
37
37
  return {
38
38
  id: `node@runtime:${version}`,
@@ -61,13 +61,20 @@ export async function resolveLatestNodeRuntime(ctx, query, _opts) {
61
61
  return {};
62
62
  return { latestManifest: { name: 'node', version } };
63
63
  }
64
- async function readNodeAssets(fetch, nodeMirrorBaseUrl, version) {
65
- const assets = await readNodeAssetsFromMirror(fetch, { nodeMirrorBaseUrl, version, muslOnly: false });
64
+ async function readNodeAssets(fetch, nodeMirrorBaseUrl, version, releaseChannel) {
65
+ // The mirror is repository-configurable, so the SHASUMS file's hashes are only
66
+ // trustworthy once its OpenPGP signature is verified against the Node.js
67
+ // release keys embedded in pnpm. Only the `release` channel publishes a signed
68
+ // SHASUMS256.txt; pre-release channels (rc, nightly, …) are unsigned by Node,
69
+ // so they cannot be verified this way.
70
+ const assets = await readNodeAssetsFromMirror(fetch, { nodeMirrorBaseUrl, version, muslOnly: false, verifySignature: releaseChannel === 'release' });
66
71
  // When using the default mirror, also fetch musl variants from unofficial-builds.nodejs.org,
67
- // since musl builds are not available on the official mirror.
72
+ // since musl builds are not available on the official mirror. That URL is hardcoded (not
73
+ // repository-configurable) and signed by a different (unofficial-builds) key, so it is trusted
74
+ // over TLS rather than verified against the official release keys.
68
75
  if (nodeMirrorBaseUrl === DEFAULT_NODE_MIRROR_BASE_URL) {
69
76
  try {
70
- const muslAssets = await readNodeAssetsFromMirror(fetch, { nodeMirrorBaseUrl: UNOFFICIAL_NODE_MIRROR_BASE_URL, version, muslOnly: true });
77
+ const muslAssets = await readNodeAssetsFromMirror(fetch, { nodeMirrorBaseUrl: UNOFFICIAL_NODE_MIRROR_BASE_URL, version, muslOnly: true, verifySignature: false });
71
78
  assets.push(...muslAssets);
72
79
  }
73
80
  catch {
@@ -77,9 +84,11 @@ async function readNodeAssets(fetch, nodeMirrorBaseUrl, version) {
77
84
  return assets;
78
85
  }
79
86
  async function readNodeAssetsFromMirror(fetch, opts) {
80
- const { nodeMirrorBaseUrl, version, muslOnly } = opts;
87
+ const { nodeMirrorBaseUrl, version, muslOnly, verifySignature } = opts;
81
88
  const integritiesFileUrl = `${nodeMirrorBaseUrl}v${version}/SHASUMS256.txt`;
82
- const shasumsFileItems = await fetchShasumsFile(fetch, integritiesFileUrl);
89
+ const shasumsFileItems = verifySignature
90
+ ? await fetchVerifiedNodeShasumsFile(fetch, integritiesFileUrl)
91
+ : await fetchShasumsFile(fetch, integritiesFileUrl);
83
92
  const escaped = version.replace(/\\/g, '\\\\').replace(/\./g, '\\.');
84
93
  // The second capture group uses [^.-]+ to stop at a dash, so that the optional
85
94
  // third group can capture the '-musl' suffix separately (e.g. 'x64' + '-musl').
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnpm/engine.runtime.node-resolver",
3
- "version": "1101.1.4",
3
+ "version": "1101.1.6",
4
4
  "description": "Resolves a Node.js version specifier to an exact Node.js version",
5
5
  "keywords": [
6
6
  "pnpm",
@@ -31,18 +31,18 @@
31
31
  "dependencies": {
32
32
  "semver": "^7.8.1",
33
33
  "version-selector-type": "^3.0.0",
34
- "@pnpm/config.reader": "1101.6.0",
35
- "@pnpm/crypto.shasums-file": "1100.0.1",
34
+ "@pnpm/config.reader": "1101.8.0",
36
35
  "@pnpm/fetching.types": "1100.0.1",
37
36
  "@pnpm/error": "1100.0.0",
38
- "@pnpm/resolving.resolver-base": "1100.4.0",
39
- "@pnpm/types": "1101.3.0"
37
+ "@pnpm/crypto.shasums-file": "1100.1.0",
38
+ "@pnpm/types": "1101.3.1",
39
+ "@pnpm/resolving.resolver-base": "1100.4.1"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@jest/globals": "30.3.0",
43
43
  "@types/semver": "7.7.1",
44
- "@pnpm/engine.runtime.node-resolver": "1101.1.4",
45
- "@pnpm/network.fetch": "1100.1.0"
44
+ "@pnpm/engine.runtime.node-resolver": "1101.1.6",
45
+ "@pnpm/network.fetch": "1100.1.2"
46
46
  },
47
47
  "engines": {
48
48
  "node": ">=22.13"