@vltpkg/package-info 1.3.1 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -17,10 +17,16 @@ export declare const delimiter = "~";
17
17
  * `dist.tarball` relative to the registry base.
18
18
  */
19
19
  export declare const VLT_PACKUMENT_MIME = "application/vnd.vlt.packument-v1+json";
20
+ /**
21
+ * {@link VLT_PACKUMENT_MIME} with each `dist.tarball` reduced to the
22
+ * tarball's basename (`foo-1.0.0.tgz`), which resolves against the
23
+ * package's `{registry}{name}/-/` directory.
24
+ */
25
+ export declare const VLT_PACKUMENT_V2_MIME = "application/vnd.vlt.packument-v2+json";
20
26
  /**
21
27
  * Accept header for packument requests. Prefers vlt's abbreviated
22
- * packument and falls back to the full one on registries that do not
23
- * know the type. See `PackageInfoClient.#fetchPackument`.
28
+ * packument, v2 over v1, and falls back to the full one on registries
29
+ * that know neither. See `PackageInfoClient.#fetchPackument`.
24
30
  *
25
31
  * The trailing wildcard range carries an explicit `q=0.1` so that it stays
26
32
  * below `application/json`. A media range with no `q` defaults to `q=1.0`
@@ -30,7 +36,7 @@ export declare const VLT_PACKUMENT_MIME = "application/vnd.vlt.packument-v1+json
30
36
  * only so a registry that rejects what it cannot satisfy exactly still
31
37
  * has something to match.
32
38
  */
33
- export declare const PACKUMENT_ACCEPT = "application/vnd.vlt.packument-v1+json; q=1.0, application/json; q=0.8, */*; q=0.1";
39
+ export declare const PACKUMENT_ACCEPT = "application/vnd.vlt.packument-v2+json; q=1.0, application/vnd.vlt.packument-v1+json; q=0.9, application/json; q=0.8, */*; q=0.1";
34
40
  export type Resolution = {
35
41
  resolved: string;
36
42
  integrity?: Integrity;
package/dist/index.js CHANGED
@@ -30,10 +30,16 @@ export const delimiter = '~';
30
30
  * `dist.tarball` relative to the registry base.
31
31
  */
32
32
  export const VLT_PACKUMENT_MIME = 'application/vnd.vlt.packument-v1+json';
33
+ /**
34
+ * {@link VLT_PACKUMENT_MIME} with each `dist.tarball` reduced to the
35
+ * tarball's basename (`foo-1.0.0.tgz`), which resolves against the
36
+ * package's `{registry}{name}/-/` directory.
37
+ */
38
+ export const VLT_PACKUMENT_V2_MIME = 'application/vnd.vlt.packument-v2+json';
33
39
  /**
34
40
  * Accept header for packument requests. Prefers vlt's abbreviated
35
- * packument and falls back to the full one on registries that do not
36
- * know the type. See `PackageInfoClient.#fetchPackument`.
41
+ * packument, v2 over v1, and falls back to the full one on registries
42
+ * that know neither. See `PackageInfoClient.#fetchPackument`.
37
43
  *
38
44
  * The trailing wildcard range carries an explicit `q=0.1` so that it stays
39
45
  * below `application/json`. A media range with no `q` defaults to `q=1.0`
@@ -43,7 +49,7 @@ export const VLT_PACKUMENT_MIME = 'application/vnd.vlt.packument-v1+json';
43
49
  * only so a registry that rejects what it cannot satisfy exactly still
44
50
  * has something to match.
45
51
  */
46
- export const PACKUMENT_ACCEPT = `${VLT_PACKUMENT_MIME}; q=1.0, application/json; q=0.8, */*; q=0.1`;
52
+ export const PACKUMENT_ACCEPT = `${VLT_PACKUMENT_V2_MIME}; q=1.0, ${VLT_PACKUMENT_MIME}; q=0.9, application/json; q=0.8, */*; q=0.1`;
47
53
  // the maximum duration of a manifest cache file
48
54
  const manifestCacheMaxAge = 5 * 60 * 1000;
49
55
  /**
@@ -94,7 +100,7 @@ export class PackageInfoClient {
94
100
  packageJson;
95
101
  monorepo;
96
102
  #trustedIntegrities = new Map();
97
- // `${registry}${name}` of every packument served as VLT_PACKUMENT_MIME
103
+ // `${registry}${name}` of every packument served as a vlt packument type
98
104
  #vltPackuments = new Set();
99
105
  #manifestCacheMinAge = Date.now() - manifestCacheMaxAge;
100
106
  #cachePath;
@@ -912,7 +918,8 @@ export class PackageInfoClient {
912
918
  }
913
919
  async #fetchPackument(spec, options, pakuURL, useCache) {
914
920
  // Request vlt's abbreviated packument, falling back to the full one:
915
- // accept: application/vnd.vlt.packument-v1+json; q=1.0,
921
+ // accept: application/vnd.vlt.packument-v2+json; q=1.0,
922
+ // application/vnd.vlt.packument-v1+json; q=0.9,
916
923
  // application/json; q=0.8, */*; q=0.1
917
924
  //
918
925
  // npm's corgi (`application/vnd.npm.install-v1+json`) is never
@@ -961,12 +968,16 @@ export class PackageInfoClient {
961
968
  throw er;
962
969
  }
963
970
  const { registry, name } = spec.final;
964
- if (response.contentType.startsWith(VLT_PACKUMENT_MIME)) {
971
+ const { contentType } = response;
972
+ const v2 = contentType.startsWith(VLT_PACKUMENT_V2_MIME);
973
+ if (v2 || contentType.startsWith(VLT_PACKUMENT_MIME)) {
965
974
  this.#vltPackuments.add(`${registry}${name}`);
966
975
  }
967
976
  /* c8 ignore next - registry specs always have a registry */
968
- if (registry)
969
- absolutizeTarballs(paku, registry);
977
+ if (registry) {
978
+ const base = registry.endsWith('/') ? registry : registry + '/';
979
+ absolutizeTarballs(paku, v2 ? `${base}${name}/-/` : base);
980
+ }
970
981
  return paku;
971
982
  }
972
983
  async resolve(spec, options = {}) {
@@ -1127,12 +1138,12 @@ export class PackageInfoClient {
1127
1138
  return er;
1128
1139
  }
1129
1140
  }
1130
- // vlt packuments carry dist.tarball relative to the registry base
1131
- // (`foo/-/foo-1.0.0.tgz`), the form conventionalRegistryTarball builds.
1141
+ // vlt packuments carry dist.tarball relative to `base`: the registry base
1142
+ // for v1 (`foo/-/foo-1.0.0.tgz`, the form conventionalRegistryTarball
1143
+ // builds), the package's `/-/` directory for v2 (`foo-1.0.0.tgz`).
1132
1144
  // Nothing downstream sees a relative URL: the manifest cache, the graph
1133
1145
  // and the lockfile all get the absolute one.
1134
- const absolutizeTarballs = (paku, registry) => {
1135
- const base = registry.endsWith('/') ? registry : registry + '/';
1146
+ const absolutizeTarballs = (paku, base) => {
1136
1147
  for (const { dist } of Object.values(paku.versions)) {
1137
1148
  const tarball = dist?.tarball;
1138
1149
  if (tarball && !/^[a-z][a-z0-9+.-]*:/i.test(tarball)) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vltpkg/package-info",
3
3
  "description": "Resolve and fetch package metadata and tarballs",
4
- "version": "1.3.1",
4
+ "version": "1.3.2",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/vltpkg/vltpkg.git",
@@ -13,17 +13,17 @@
13
13
  "url": "http://vlt.sh"
14
14
  },
15
15
  "dependencies": {
16
- "@vltpkg/error-cause": "1.3.1",
17
- "@vltpkg/git": "1.3.1",
18
- "@vltpkg/output": "1.3.1",
19
- "@vltpkg/package-json": "1.3.1",
20
- "@vltpkg/pick-manifest": "1.3.1",
21
- "@vltpkg/registry-client": "1.3.1",
22
- "@vltpkg/spec": "1.3.1",
23
- "@vltpkg/tar": "1.3.1",
24
- "@vltpkg/types": "1.3.1",
25
- "@vltpkg/workspaces": "1.3.1",
26
- "@vltpkg/xdg": "1.3.1",
16
+ "@vltpkg/error-cause": "1.3.2",
17
+ "@vltpkg/git": "1.3.2",
18
+ "@vltpkg/output": "1.3.2",
19
+ "@vltpkg/package-json": "1.3.2",
20
+ "@vltpkg/pick-manifest": "1.3.2",
21
+ "@vltpkg/registry-client": "1.3.2",
22
+ "@vltpkg/spec": "1.3.2",
23
+ "@vltpkg/tar": "1.3.2",
24
+ "@vltpkg/types": "1.3.2",
25
+ "@vltpkg/workspaces": "1.3.2",
26
+ "@vltpkg/xdg": "1.3.2",
27
27
  "ssri": "^13.0.0",
28
28
  "tar": "^7.5.2"
29
29
  },
@@ -32,8 +32,8 @@
32
32
  "@types/node": "^22.19.2",
33
33
  "@types/pacote": "^11.1.8",
34
34
  "@vltpkg/benchmark": "0.0.0",
35
- "@vltpkg/cache-unzip": "1.3.1",
36
- "@vltpkg/vlt-json": "1.3.1",
35
+ "@vltpkg/cache-unzip": "1.3.2",
36
+ "@vltpkg/vlt-json": "1.3.2",
37
37
  "eslint": "^9.39.1",
38
38
  "pacote": "^21.0.4",
39
39
  "prettier": "^3.7.4",