@pnpm/resolving.tarball-url 1101.0.0 → 1101.1.1
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 +18 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.js +48 -0
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @pnpm/resolving.tarball-url
|
|
2
2
|
|
|
3
|
+
## 1101.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies:
|
|
8
|
+
- @pnpm/crypto.integrity@1100.0.6
|
|
9
|
+
|
|
10
|
+
## 1101.1.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- Added support for registry replacement tarballs using standard integrity values, explicit revision fields, registry routing from the `registries` setting, non-redirecting integrity-addressed URLs, canonical safe-integer revision numbers, and pnpr proxying for immutable upstream revision artifacts.
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies:
|
|
19
|
+
- @pnpm/types@1102.1.0
|
|
20
|
+
|
|
3
21
|
## 1101.0.0
|
|
4
22
|
|
|
5
23
|
### Major Changes
|
package/lib/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Buffer } from 'node:buffer';
|
|
1
2
|
import type { RegistryServerType } from '@pnpm/types';
|
|
2
3
|
export interface TarballUrlOptions {
|
|
3
4
|
registry?: string;
|
|
@@ -7,6 +8,14 @@ export interface TarballUrlOptions {
|
|
|
7
8
|
*/
|
|
8
9
|
serverType?: RegistryServerType;
|
|
9
10
|
}
|
|
11
|
+
export interface IntegrityAddress {
|
|
12
|
+
algorithm: 'sha512';
|
|
13
|
+
digest: Buffer;
|
|
14
|
+
}
|
|
15
|
+
export declare function isIntegrityAddressedRegistryTarballUrl(tarball: string, integrity: string, registry: string): boolean;
|
|
16
|
+
export declare function getIntegrityAddressedTarballUrl(integrity: unknown, registry: string): string | undefined;
|
|
17
|
+
export declare function parseIntegrityAddress(integrity: unknown): IntegrityAddress | undefined;
|
|
18
|
+
export declare function isValidTarballRevision(revision: unknown): revision is number;
|
|
10
19
|
/**
|
|
11
20
|
* Build the canonical tarball URL of an npm package — i.e. the URL pnpm derives
|
|
12
21
|
* from a package's name, version, and registry. Vendored from the
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import { Buffer } from 'node:buffer';
|
|
2
|
+
import util from 'node:util';
|
|
3
|
+
import { formatIntegrity, parseIntegrity } from '@pnpm/crypto.integrity';
|
|
1
4
|
const PUBLIC_NPM_REGISTRY = 'https://registry.npmjs.org/';
|
|
5
|
+
const SHA512_INTEGRITY_LENGTH = 'sha512-'.length + 88;
|
|
2
6
|
/**
|
|
3
7
|
* registry.npmjs.org is the one registry whose layout pnpm knows without being
|
|
4
8
|
* told, so it is a row of data rather than a hostname comparison. A declared
|
|
@@ -7,6 +11,50 @@ const PUBLIC_NPM_REGISTRY = 'https://registry.npmjs.org/';
|
|
|
7
11
|
const DEFAULT_REGISTRY_SERVER_TYPES = {
|
|
8
12
|
[PUBLIC_NPM_REGISTRY]: 'npm',
|
|
9
13
|
};
|
|
14
|
+
export function isIntegrityAddressedRegistryTarballUrl(tarball, integrity, registry) {
|
|
15
|
+
const expected = getIntegrityAddressedTarballUrl(integrity, registry);
|
|
16
|
+
if (expected == null)
|
|
17
|
+
return false;
|
|
18
|
+
try {
|
|
19
|
+
return new URL(tarball).toString() === expected;
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export function getIntegrityAddressedTarballUrl(integrity, registry) {
|
|
26
|
+
const parsed = parseIntegrityAddress(integrity);
|
|
27
|
+
if (parsed == null)
|
|
28
|
+
return undefined;
|
|
29
|
+
return new URL(`-/tarballs/${parsed.algorithm}/${parsed.digest.toString('base64url')}`, normalizeRegistry(registry)).toString();
|
|
30
|
+
}
|
|
31
|
+
export function parseIntegrityAddress(integrity) {
|
|
32
|
+
if (typeof integrity !== 'string' || integrity.length !== SHA512_INTEGRITY_LENGTH)
|
|
33
|
+
return undefined;
|
|
34
|
+
let parsed;
|
|
35
|
+
try {
|
|
36
|
+
parsed = parseIntegrity(integrity);
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
if (util.types.isNativeError(err) && 'code' in err && err.code === 'ERR_PNPM_INVALID_INTEGRITY') {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
throw err;
|
|
43
|
+
}
|
|
44
|
+
if (parsed.algorithm !== 'sha512' ||
|
|
45
|
+
parsed.hexDigest.length !== 128 ||
|
|
46
|
+
formatIntegrity(parsed.algorithm, parsed.hexDigest) !== integrity)
|
|
47
|
+
return undefined;
|
|
48
|
+
return {
|
|
49
|
+
algorithm: parsed.algorithm,
|
|
50
|
+
digest: Buffer.from(parsed.hexDigest, 'hex'),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export function isValidTarballRevision(revision) {
|
|
54
|
+
return typeof revision === 'number' &&
|
|
55
|
+
Number.isSafeInteger(revision) &&
|
|
56
|
+
revision > 0;
|
|
57
|
+
}
|
|
10
58
|
/**
|
|
11
59
|
* Build the canonical tarball URL of an npm package — i.e. the URL pnpm derives
|
|
12
60
|
* from a package's name, version, and registry. Vendored from the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/resolving.tarball-url",
|
|
3
|
-
"version": "1101.
|
|
3
|
+
"version": "1101.1.1",
|
|
4
4
|
"description": "Build and recognize the canonical tarball URL of an npm package",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -29,11 +29,12 @@
|
|
|
29
29
|
"!*.map"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@pnpm/
|
|
32
|
+
"@pnpm/crypto.integrity": "1100.0.6",
|
|
33
|
+
"@pnpm/types": "1102.1.0"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
36
|
"@jest/globals": "30.4.1",
|
|
36
|
-
"@pnpm/resolving.tarball-url": "1101.
|
|
37
|
+
"@pnpm/resolving.tarball-url": "1101.1.1"
|
|
37
38
|
},
|
|
38
39
|
"engines": {
|
|
39
40
|
"node": ">=22.13"
|