@vltpkg/types 1.3.0 → 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 +21 -6
- package/dist/index.js +11 -20
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -35,14 +35,22 @@ export type Dist = {
|
|
|
35
35
|
* reference relative to this `dist`'s `tarball` (e.g. the bare filename
|
|
36
36
|
* `foo-1.2.3.tar.br`), resolved with `new URL(entry.tarball, tarball)`.
|
|
37
37
|
*
|
|
38
|
-
* An alternate is a
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
38
|
+
* An alternate is a different artifact, not a re-encoding of the same
|
|
39
|
+
* bytes. It hashes differently from the `.tgz`, so `dist.integrity` does
|
|
40
|
+
* not describe it.
|
|
41
|
+
*
|
|
42
|
+
* The `integrity` field here is the alternate's own hash. It is optional,
|
|
43
|
+
* because a hash does not compress and a registry may prefer to keep
|
|
44
|
+
* packuments small. If a registry does send it, the client pins it like
|
|
45
|
+
* any other integrity, and can look the package up in the global store
|
|
46
|
+
* without downloading anything first. If it does not, the client verifies
|
|
47
|
+
* the download against the tarball response's RFC 9530 `Repr-Digest`
|
|
48
|
+
* header and learns the hash from there.
|
|
42
49
|
*/
|
|
43
50
|
alternates?: {
|
|
44
51
|
kind: string;
|
|
45
52
|
tarball: string;
|
|
53
|
+
integrity?: Integrity;
|
|
46
54
|
}[];
|
|
47
55
|
};
|
|
48
56
|
/** An object used to mark some peerDeps as optional */
|
|
@@ -262,7 +270,8 @@ export type Manifest = {
|
|
|
262
270
|
/**
|
|
263
271
|
* Set in place of `scripts` by abbreviated registry manifests (npm's
|
|
264
272
|
* `application/vnd.npm.install-v1+json` and vlt's
|
|
265
|
-
* `application/vnd.vlt.packument-v1+json`
|
|
273
|
+
* `application/vnd.vlt.packument-v1+json` and
|
|
274
|
+
* `application/vnd.vlt.packument-v2+json`) when the package has an
|
|
266
275
|
* install, preinstall, or postinstall script.
|
|
267
276
|
*/
|
|
268
277
|
hasInstallScript?: boolean;
|
|
@@ -455,7 +464,13 @@ export declare const brotliTarballName: (tgz: string) => string;
|
|
|
455
464
|
* those derivations sound -- and costs an unusual reference the
|
|
456
465
|
* optimization rather than the install.
|
|
457
466
|
*/
|
|
458
|
-
export
|
|
467
|
+
export type BrotliAlternate = {
|
|
468
|
+
/** The absolute URL of the `.tar.br`. */
|
|
469
|
+
tarball: string;
|
|
470
|
+
/** The alternate's own hash, if the registry sent one. */
|
|
471
|
+
integrity?: Integrity;
|
|
472
|
+
};
|
|
473
|
+
export declare const brotliTarballUrl: (tarball: string | undefined, alternates: Dist["alternates"]) => BrotliAlternate | undefined;
|
|
459
474
|
export declare const keyIDRE: RegExp;
|
|
460
475
|
export declare const isKeyID: (k: unknown) => k is KeyID;
|
|
461
476
|
export declare const asKeyID: (k: unknown) => KeyID;
|
package/dist/index.js
CHANGED
|
@@ -566,23 +566,6 @@ export const tarballFormat = (url) => {
|
|
|
566
566
|
* and a different extension.
|
|
567
567
|
*/
|
|
568
568
|
export const brotliTarballName = (tgz) => tgz.replace(/\.tgz$/, BROTLI_TARBALL_EXT);
|
|
569
|
-
/**
|
|
570
|
-
* The absolute URL of a version's Brotli (`.tar.br`) tarball, from the
|
|
571
|
-
* `tar.br` entry in its `dist.alternates` -- but only when that entry
|
|
572
|
-
* resolves to the `.tgz`'s own sibling, i.e. {@link brotliTarballName} of
|
|
573
|
-
* `tarball`. Anything else reads as no alternate at all.
|
|
574
|
-
*
|
|
575
|
-
* `alternates[].tarball` is a reference relative to `dist.tarball`, and
|
|
576
|
-
* the protocol lets a registry point it anywhere. This client uses only
|
|
577
|
-
* the conventional name, because two things downstream re-derive it and
|
|
578
|
-
* both would otherwise be wrong: the format is read back off the URL
|
|
579
|
-
* suffix (brotli bytes carry no signature to sniff), and a lockfile node
|
|
580
|
-
* spends a single flag bit instead of a second URL, rebuilding the
|
|
581
|
-
* address from the `.tgz` by this same convention. Narrowing here, at
|
|
582
|
-
* the one point where the alternate is chosen, is what makes both of
|
|
583
|
-
* those derivations sound -- and costs an unusual reference the
|
|
584
|
-
* optimization rather than the install.
|
|
585
|
-
*/
|
|
586
569
|
export const brotliTarballUrl = (tarball, alternates) => {
|
|
587
570
|
if (!tarball)
|
|
588
571
|
return undefined;
|
|
@@ -591,9 +574,17 @@ export const brotliTarballUrl = (tarball, alternates) => {
|
|
|
591
574
|
return undefined;
|
|
592
575
|
try {
|
|
593
576
|
const href = new URL(entry.tarball, tarball).href;
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
577
|
+
if (href !== new URL(brotliTarballName(tarball)).href) {
|
|
578
|
+
return undefined;
|
|
579
|
+
}
|
|
580
|
+
// Ignore a hash we cannot parse. Pinning it would fail every check,
|
|
581
|
+
// so it is better to fall back to the Repr-Digest.
|
|
582
|
+
return {
|
|
583
|
+
tarball: href,
|
|
584
|
+
...(isIntegrity(entry.integrity) && {
|
|
585
|
+
integrity: entry.integrity,
|
|
586
|
+
}),
|
|
587
|
+
};
|
|
597
588
|
/* c8 ignore start - a malformed reference just means no brotli */
|
|
598
589
|
}
|
|
599
590
|
catch {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vltpkg/types",
|
|
3
3
|
"description": "definitions for some of vlt's core types",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.2",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/vltpkg/vltpkg.git",
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
"url": "http://vlt.sh"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@vltpkg/dep-id": "1.3.
|
|
17
|
-
"@vltpkg/error-cause": "1.3.
|
|
18
|
-
"@vltpkg/semver": "1.3.
|
|
19
|
-
"@vltpkg/spec": "1.3.
|
|
16
|
+
"@vltpkg/dep-id": "1.3.2",
|
|
17
|
+
"@vltpkg/error-cause": "1.3.2",
|
|
18
|
+
"@vltpkg/semver": "1.3.2",
|
|
19
|
+
"@vltpkg/spec": "1.3.2"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@eslint/js": "^9.39.1",
|