@pnpm/exe 11.0.0-alpha.9 → 11.0.0-beta.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/dist/node_modules/@gar/promise-retry/lib/index.js +28 -0
- package/dist/node_modules/@gar/promise-retry/package.json +48 -0
- package/dist/node_modules/@npmcli/agent/package.json +7 -7
- package/dist/node_modules/@npmcli/fs/package.json +4 -4
- package/dist/node_modules/abbrev/package.json +11 -15
- package/dist/node_modules/balanced-match/package.json +4 -7
- package/dist/node_modules/brace-expansion/dist/commonjs/index.js +1 -1
- package/dist/node_modules/brace-expansion/dist/esm/index.js +1 -1
- package/dist/node_modules/brace-expansion/package.json +3 -3
- package/dist/node_modules/cacache/package.json +10 -11
- package/dist/node_modules/glob/dist/commonjs/glob.js +2 -1
- package/dist/node_modules/glob/dist/commonjs/index.min.js +4 -0
- package/dist/node_modules/glob/dist/commonjs/pattern.js +4 -0
- package/dist/node_modules/glob/dist/esm/glob.js +2 -1
- package/dist/node_modules/glob/dist/esm/index.min.js +4 -0
- package/dist/node_modules/glob/dist/esm/pattern.js +4 -0
- package/dist/node_modules/glob/package.json +38 -37
- package/dist/node_modules/iconv-lite/encodings/dbcs-codec.js +460 -525
- package/dist/node_modules/iconv-lite/encodings/dbcs-data.js +179 -182
- package/dist/node_modules/iconv-lite/encodings/index.js +15 -15
- package/dist/node_modules/iconv-lite/encodings/internal.js +168 -148
- package/dist/node_modules/iconv-lite/encodings/sbcs-codec.js +55 -52
- package/dist/node_modules/iconv-lite/encodings/sbcs-data.js +174 -175
- package/dist/node_modules/iconv-lite/encodings/utf16.js +121 -131
- package/dist/node_modules/iconv-lite/encodings/utf32.js +226 -238
- package/dist/node_modules/iconv-lite/encodings/utf7.js +208 -215
- package/dist/node_modules/iconv-lite/lib/bom-handling.js +30 -34
- package/dist/node_modules/iconv-lite/lib/helpers/merge-exports.js +13 -0
- package/dist/node_modules/iconv-lite/lib/index.js +125 -123
- package/dist/node_modules/iconv-lite/lib/streams.js +92 -96
- package/dist/node_modules/iconv-lite/package.json +34 -8
- package/dist/node_modules/isexe/package.json +65 -18
- package/dist/node_modules/lru-cache/dist/commonjs/index.js +134 -85
- package/dist/node_modules/lru-cache/dist/commonjs/index.min.js +1 -1
- package/dist/node_modules/lru-cache/dist/esm/index.js +134 -85
- package/dist/node_modules/lru-cache/dist/esm/index.min.js +1 -1
- package/dist/node_modules/lru-cache/package.json +18 -41
- package/dist/node_modules/make-fetch-happen/lib/remote.js +1 -1
- package/dist/node_modules/make-fetch-happen/package.json +10 -10
- package/dist/node_modules/minimatch/dist/commonjs/ast.js +266 -21
- package/dist/node_modules/minimatch/dist/commonjs/index.js +178 -92
- package/dist/node_modules/minimatch/dist/esm/ast.js +266 -21
- package/dist/node_modules/minimatch/dist/esm/index.js +178 -92
- package/dist/node_modules/minimatch/package.json +4 -4
- package/dist/node_modules/minipass/dist/commonjs/index.js +13 -3
- package/dist/node_modules/minipass/dist/esm/index.js +3 -1
- package/dist/node_modules/minipass/package.json +9 -14
- package/dist/node_modules/minipass-fetch/lib/body.js +25 -15
- package/dist/node_modules/minipass-fetch/package.json +7 -7
- package/dist/node_modules/minipass-sized/dist/commonjs/index.js +69 -0
- package/dist/node_modules/minipass-sized/dist/esm/index.js +64 -0
- package/dist/node_modules/minipass-sized/package.json +39 -9
- package/dist/node_modules/node-gyp/.release-please-manifest.json +1 -1
- package/dist/node_modules/node-gyp/bin/node-gyp.js +7 -0
- package/dist/node_modules/node-gyp/gyp/.release-please-manifest.json +1 -1
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/MSVSNew.py +3 -3
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/MSVSVersion.py +26 -1
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py +1 -1
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja.py +3 -4
- package/dist/node_modules/node-gyp/gyp/pylib/gyp/xcodeproj_file.py +1 -1
- package/dist/node_modules/node-gyp/gyp/pyproject.toml +1 -1
- package/dist/node_modules/node-gyp/lib/build.js +2 -2
- package/dist/node_modules/node-gyp/lib/find-python.js +2 -8
- package/dist/node_modules/node-gyp/lib/find-visualstudio.js +11 -5
- package/dist/node_modules/node-gyp/lib/install.js +1 -1
- package/dist/node_modules/node-gyp/lib/process-release.js +3 -3
- package/dist/node_modules/node-gyp/package.json +13 -13
- package/dist/node_modules/nopt/package.json +5 -5
- package/dist/node_modules/path-scurry/package.json +8 -24
- package/dist/node_modules/proc-log/lib/index.js +10 -5
- package/dist/node_modules/proc-log/package.json +5 -5
- package/dist/node_modules/retry/lib/retry.js +2 -2
- package/dist/node_modules/retry/lib/retry_operation.js +10 -6
- package/dist/node_modules/retry/package.json +6 -2
- package/dist/node_modules/ssri/lib/index.js +33 -63
- package/dist/node_modules/ssri/package.json +17 -17
- package/dist/node_modules/tar/dist/commonjs/index.min.js +2 -2
- package/dist/node_modules/tar/dist/commonjs/unpack.js +4 -4
- package/dist/node_modules/tar/dist/esm/index.min.js +2 -2
- package/dist/node_modules/tar/dist/esm/unpack.js +4 -4
- package/dist/node_modules/tar/package.json +6 -6
- package/dist/node_modules/unique-filename/package.json +5 -5
- package/dist/node_modules/unique-slug/package.json +4 -4
- package/dist/node_modules/which/package.json +29 -20
- package/dist/pnpm.mjs +225713 -208017
- package/dist/worker.js +4838 -5926
- package/package.json +10 -10
- package/setup.js +12 -14
- package/dist/node_modules/@isaacs/cliui/dist/commonjs/ansi-regex/index.js +0 -16
- package/dist/node_modules/@isaacs/cliui/dist/commonjs/ansi-styles/index.js +0 -170
- package/dist/node_modules/@isaacs/cliui/dist/commonjs/eastasianwidth/index.js +0 -307
- package/dist/node_modules/@isaacs/cliui/dist/commonjs/emoji-regex/index.js +0 -7
- package/dist/node_modules/@isaacs/cliui/dist/commonjs/index.js +0 -322
- package/dist/node_modules/@isaacs/cliui/dist/commonjs/index.min.js +0 -12
- package/dist/node_modules/@isaacs/cliui/dist/commonjs/string-width/index.js +0 -49
- package/dist/node_modules/@isaacs/cliui/dist/commonjs/strip-ansi/index.js +0 -8
- package/dist/node_modules/@isaacs/cliui/dist/commonjs/wrap-ansi/index.js +0 -176
- package/dist/node_modules/@isaacs/cliui/dist/esm/ansi-regex/index.js +0 -12
- package/dist/node_modules/@isaacs/cliui/dist/esm/ansi-styles/index.js +0 -167
- package/dist/node_modules/@isaacs/cliui/dist/esm/eastasianwidth/index.js +0 -299
- package/dist/node_modules/@isaacs/cliui/dist/esm/emoji-regex/index.js +0 -3
- package/dist/node_modules/@isaacs/cliui/dist/esm/index.js +0 -317
- package/dist/node_modules/@isaacs/cliui/dist/esm/index.min.js +0 -12
- package/dist/node_modules/@isaacs/cliui/dist/esm/string-width/index.js +0 -46
- package/dist/node_modules/@isaacs/cliui/dist/esm/strip-ansi/index.js +0 -4
- package/dist/node_modules/@isaacs/cliui/dist/esm/wrap-ansi/index.js +0 -172
- package/dist/node_modules/@isaacs/cliui/package.json +0 -163
- package/dist/node_modules/cross-spawn/LICENSE +0 -21
- package/dist/node_modules/cross-spawn/index.js +0 -39
- package/dist/node_modules/cross-spawn/lib/enoent.js +0 -59
- package/dist/node_modules/cross-spawn/lib/parse.js +0 -91
- package/dist/node_modules/cross-spawn/lib/util/escape.js +0 -47
- package/dist/node_modules/cross-spawn/lib/util/readShebang.js +0 -23
- package/dist/node_modules/cross-spawn/lib/util/resolveCommand.js +0 -52
- package/dist/node_modules/cross-spawn/package.json +0 -73
- package/dist/node_modules/encoding/.prettierrc.js +0 -8
- package/dist/node_modules/encoding/LICENSE +0 -16
- package/dist/node_modules/encoding/lib/encoding.js +0 -83
- package/dist/node_modules/encoding/package.json +0 -18
- package/dist/node_modules/err-code/.eslintrc.json +0 -7
- package/dist/node_modules/err-code/bower.json +0 -30
- package/dist/node_modules/err-code/index.js +0 -47
- package/dist/node_modules/err-code/index.umd.js +0 -51
- package/dist/node_modules/err-code/package.json +0 -34
- package/dist/node_modules/foreground-child/LICENSE +0 -15
- package/dist/node_modules/foreground-child/dist/commonjs/all-signals.js +0 -58
- package/dist/node_modules/foreground-child/dist/commonjs/index.js +0 -123
- package/dist/node_modules/foreground-child/dist/commonjs/proxy-signals.js +0 -38
- package/dist/node_modules/foreground-child/dist/commonjs/watchdog.js +0 -50
- package/dist/node_modules/foreground-child/dist/esm/all-signals.js +0 -52
- package/dist/node_modules/foreground-child/dist/esm/index.js +0 -115
- package/dist/node_modules/foreground-child/dist/esm/proxy-signals.js +0 -34
- package/dist/node_modules/foreground-child/dist/esm/watchdog.js +0 -46
- package/dist/node_modules/foreground-child/package.json +0 -106
- package/dist/node_modules/glob/dist/esm/bin.d.mts +0 -3
- package/dist/node_modules/glob/dist/esm/bin.mjs +0 -346
- package/dist/node_modules/iconv-lite/.github/dependabot.yml +0 -11
- package/dist/node_modules/iconv-lite/.idea/codeStyles/Project.xml +0 -47
- package/dist/node_modules/iconv-lite/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/dist/node_modules/iconv-lite/.idea/iconv-lite.iml +0 -12
- package/dist/node_modules/iconv-lite/.idea/inspectionProfiles/Project_Default.xml +0 -6
- package/dist/node_modules/iconv-lite/.idea/modules.xml +0 -8
- package/dist/node_modules/iconv-lite/.idea/vcs.xml +0 -6
- package/dist/node_modules/isexe/LICENSE +0 -15
- package/dist/node_modules/isexe/index.js +0 -57
- package/dist/node_modules/isexe/mode.js +0 -41
- package/dist/node_modules/isexe/windows.js +0 -42
- package/dist/node_modules/jackspeak/dist/commonjs/index.js +0 -944
- package/dist/node_modules/jackspeak/dist/commonjs/index.min.js +0 -33
- package/dist/node_modules/jackspeak/dist/commonjs/package.json +0 -3
- package/dist/node_modules/jackspeak/dist/esm/index.js +0 -936
- package/dist/node_modules/jackspeak/dist/esm/index.min.js +0 -33
- package/dist/node_modules/jackspeak/dist/esm/package.json +0 -3
- package/dist/node_modules/jackspeak/package.json +0 -115
- package/dist/node_modules/lru-cache/LICENSE +0 -15
- package/dist/node_modules/minipass/LICENSE +0 -15
- package/dist/node_modules/minipass-sized/index.js +0 -67
- package/dist/node_modules/minipass-sized/node_modules/minipass/LICENSE +0 -15
- package/dist/node_modules/minipass-sized/node_modules/minipass/index.js +0 -649
- package/dist/node_modules/minipass-sized/node_modules/minipass/package.json +0 -56
- package/dist/node_modules/minipass-sized/package-lock.json +0 -3464
- package/dist/node_modules/node-gyp/node_modules/isexe/dist/commonjs/package.json +0 -3
- package/dist/node_modules/node-gyp/node_modules/isexe/dist/esm/package.json +0 -3
- package/dist/node_modules/node-gyp/node_modules/isexe/package.json +0 -78
- package/dist/node_modules/node-gyp/node_modules/which/LICENSE +0 -15
- package/dist/node_modules/node-gyp/node_modules/which/package.json +0 -52
- package/dist/node_modules/package-json-from-dist/dist/commonjs/index.js +0 -134
- package/dist/node_modules/package-json-from-dist/dist/commonjs/package.json +0 -3
- package/dist/node_modules/package-json-from-dist/dist/esm/index.js +0 -129
- package/dist/node_modules/package-json-from-dist/dist/esm/package.json +0 -3
- package/dist/node_modules/package-json-from-dist/package.json +0 -68
- package/dist/node_modules/path-key/index.js +0 -16
- package/dist/node_modules/path-key/license +0 -9
- package/dist/node_modules/path-key/package.json +0 -39
- package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.js +0 -1589
- package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.min.js +0 -2
- package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/package.json +0 -3
- package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.js +0 -1585
- package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.min.js +0 -2
- package/dist/node_modules/path-scurry/node_modules/lru-cache/dist/esm/package.json +0 -3
- package/dist/node_modules/path-scurry/node_modules/lru-cache/package.json +0 -101
- package/dist/node_modules/promise-retry/index.js +0 -52
- package/dist/node_modules/promise-retry/package.json +0 -37
- package/dist/node_modules/retry/equation.gif +0 -0
- package/dist/node_modules/shebang-command/index.js +0 -19
- package/dist/node_modules/shebang-command/license +0 -9
- package/dist/node_modules/shebang-command/package.json +0 -34
- package/dist/node_modules/shebang-regex/index.js +0 -2
- package/dist/node_modules/shebang-regex/license +0 -9
- package/dist/node_modules/shebang-regex/package.json +0 -35
- package/dist/node_modules/signal-exit/LICENSE.txt +0 -16
- package/dist/node_modules/signal-exit/dist/cjs/browser.js +0 -10
- package/dist/node_modules/signal-exit/dist/cjs/index.js +0 -279
- package/dist/node_modules/signal-exit/dist/cjs/package.json +0 -3
- package/dist/node_modules/signal-exit/dist/cjs/signals.js +0 -42
- package/dist/node_modules/signal-exit/dist/mjs/browser.js +0 -4
- package/dist/node_modules/signal-exit/dist/mjs/index.js +0 -275
- package/dist/node_modules/signal-exit/dist/mjs/package.json +0 -3
- package/dist/node_modules/signal-exit/dist/mjs/signals.js +0 -39
- package/dist/node_modules/signal-exit/package.json +0 -106
- package/dist/node_modules/which/bin/node-which +0 -52
- package/dist/node_modules/which/which.js +0 -125
- /package/dist/node_modules/{promise-retry → @gar/promise-retry}/LICENSE +0 -0
- /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/commonjs/index.js +0 -0
- /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/commonjs/index.min.js +0 -0
- /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/commonjs/options.js +0 -0
- /package/dist/node_modules/{@isaacs/cliui → isexe}/dist/commonjs/package.json +0 -0
- /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/commonjs/posix.js +0 -0
- /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/commonjs/win32.js +0 -0
- /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/esm/index.js +0 -0
- /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/esm/index.min.js +0 -0
- /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/esm/options.js +0 -0
- /package/dist/node_modules/{@isaacs/cliui → isexe}/dist/esm/package.json +0 -0
- /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/esm/posix.js +0 -0
- /package/dist/node_modules/{node-gyp/node_modules/isexe → isexe}/dist/esm/win32.js +0 -0
- /package/dist/node_modules/{foreground-child → minipass-sized}/dist/commonjs/package.json +0 -0
- /package/dist/node_modules/{foreground-child → minipass-sized}/dist/esm/package.json +0 -0
- /package/dist/node_modules/{node-gyp/node_modules/which → which}/bin/which.js +0 -0
- /package/dist/node_modules/{node-gyp/node_modules/which → which}/lib/index.js +0 -0
|
@@ -15,6 +15,7 @@ function RetryOperation(timeouts, options) {
|
|
|
15
15
|
this._operationTimeoutCb = null;
|
|
16
16
|
this._timeout = null;
|
|
17
17
|
this._operationStart = null;
|
|
18
|
+
this._timer = null;
|
|
18
19
|
|
|
19
20
|
if (this._options.forever) {
|
|
20
21
|
this._cachedTimeouts = this._timeouts.slice(0);
|
|
@@ -24,13 +25,16 @@ module.exports = RetryOperation;
|
|
|
24
25
|
|
|
25
26
|
RetryOperation.prototype.reset = function() {
|
|
26
27
|
this._attempts = 1;
|
|
27
|
-
this._timeouts = this._originalTimeouts;
|
|
28
|
+
this._timeouts = this._originalTimeouts.slice(0);
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
RetryOperation.prototype.stop = function() {
|
|
31
32
|
if (this._timeout) {
|
|
32
33
|
clearTimeout(this._timeout);
|
|
33
34
|
}
|
|
35
|
+
if (this._timer) {
|
|
36
|
+
clearTimeout(this._timer);
|
|
37
|
+
}
|
|
34
38
|
|
|
35
39
|
this._timeouts = [];
|
|
36
40
|
this._cachedTimeouts = null;
|
|
@@ -46,6 +50,7 @@ RetryOperation.prototype.retry = function(err) {
|
|
|
46
50
|
}
|
|
47
51
|
var currentTime = new Date().getTime();
|
|
48
52
|
if (err && currentTime - this._operationStart >= this._maxRetryTime) {
|
|
53
|
+
this._errors.push(err);
|
|
49
54
|
this._errors.unshift(new Error('RetryOperation timeout occurred'));
|
|
50
55
|
return false;
|
|
51
56
|
}
|
|
@@ -56,16 +61,15 @@ RetryOperation.prototype.retry = function(err) {
|
|
|
56
61
|
if (timeout === undefined) {
|
|
57
62
|
if (this._cachedTimeouts) {
|
|
58
63
|
// retry forever, only keep last error
|
|
59
|
-
this._errors.splice(this._errors.length - 1
|
|
60
|
-
|
|
61
|
-
timeout = this._timeouts.shift();
|
|
64
|
+
this._errors.splice(0, this._errors.length - 1);
|
|
65
|
+
timeout = this._cachedTimeouts.slice(-1);
|
|
62
66
|
} else {
|
|
63
67
|
return false;
|
|
64
68
|
}
|
|
65
69
|
}
|
|
66
70
|
|
|
67
71
|
var self = this;
|
|
68
|
-
|
|
72
|
+
this._timer = setTimeout(function() {
|
|
69
73
|
self._attempts++;
|
|
70
74
|
|
|
71
75
|
if (self._operationTimeoutCb) {
|
|
@@ -82,7 +86,7 @@ RetryOperation.prototype.retry = function(err) {
|
|
|
82
86
|
}, timeout);
|
|
83
87
|
|
|
84
88
|
if (this._options.unref) {
|
|
85
|
-
|
|
89
|
+
this._timer.unref();
|
|
86
90
|
}
|
|
87
91
|
|
|
88
92
|
return true;
|
|
@@ -3,16 +3,20 @@
|
|
|
3
3
|
"name": "retry",
|
|
4
4
|
"description": "Abstraction for exponential and custom retry strategies for failed operations.",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.13.1",
|
|
7
7
|
"homepage": "https://github.com/tim-kos/node-retry",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "git://github.com/tim-kos/node-retry.git"
|
|
11
11
|
},
|
|
12
|
+
"files": [
|
|
13
|
+
"lib",
|
|
14
|
+
"example"
|
|
15
|
+
],
|
|
12
16
|
"directories": {
|
|
13
17
|
"lib": "./lib"
|
|
14
18
|
},
|
|
15
|
-
"main": "index",
|
|
19
|
+
"main": "index.js",
|
|
16
20
|
"engines": {
|
|
17
21
|
"node": ">= 4"
|
|
18
22
|
},
|
|
@@ -5,14 +5,21 @@ const { Minipass } = require('minipass')
|
|
|
5
5
|
|
|
6
6
|
const SPEC_ALGORITHMS = ['sha512', 'sha384', 'sha256']
|
|
7
7
|
const DEFAULT_ALGORITHMS = ['sha512']
|
|
8
|
+
const NODE_HASHES = crypto.getHashes()
|
|
8
9
|
|
|
9
|
-
// TODO: this should really be a hardcoded list of algorithms we support,
|
|
10
|
-
// rather than [a-z0-9].
|
|
10
|
+
// TODO: this should really be a hardcoded list of algorithms we support, rather than [a-z0-9].
|
|
11
11
|
const BASE64_REGEX = /^[a-z0-9+/]+(?:=?=?)$/i
|
|
12
|
-
const SRI_REGEX = /^([a-z0-9]+)-([^?]+)([?\S*]*)
|
|
12
|
+
const SRI_REGEX = /^([a-z0-9]+)-([^?]+)(\?[?\S*]*)?$/
|
|
13
13
|
const STRICT_SRI_REGEX = /^([a-z0-9]+)-([A-Za-z0-9+/=]{44,88})(\?[\x21-\x7E]*)?$/
|
|
14
14
|
const VCHAR_REGEX = /^[\x21-\x7E]+$/
|
|
15
15
|
|
|
16
|
+
// This is a Best Effort™ at a reasonable priority for hash algos
|
|
17
|
+
const DEFAULT_PRIORITY = [
|
|
18
|
+
'md5', 'whirlpool', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512',
|
|
19
|
+
// TODO - it's unclear _which_ of these Node will actually use as its name for the algorithm, so we guesswork it based on the OpenSSL names.
|
|
20
|
+
'sha3', 'sha3-256', 'sha3-384', 'sha3-512', 'sha3_256', 'sha3_384', 'sha3_512',
|
|
21
|
+
].filter(algo => NODE_HASHES.includes(algo))
|
|
22
|
+
|
|
16
23
|
const getOptString = options => options?.length ? `?${options.join('?')}` : ''
|
|
17
24
|
|
|
18
25
|
class IntegrityStream extends Minipass {
|
|
@@ -99,7 +106,6 @@ class IntegrityStream extends Minipass {
|
|
|
99
106
|
// Integrity verification mode
|
|
100
107
|
const match = this.goodSri && newSri.match(this.sri, this.opts)
|
|
101
108
|
if (typeof this.expectedSize === 'number' && this.size !== this.expectedSize) {
|
|
102
|
-
/* eslint-disable-next-line max-len */
|
|
103
109
|
const err = new Error(`stream size mismatch when checking ${this.sri}.\n Wanted: ${this.expectedSize}\n Found: ${this.size}`)
|
|
104
110
|
err.code = 'EBADSIZE'
|
|
105
111
|
err.found = this.size
|
|
@@ -107,7 +113,6 @@ class IntegrityStream extends Minipass {
|
|
|
107
113
|
err.sri = this.sri
|
|
108
114
|
this.emit('error', err)
|
|
109
115
|
} else if (this.sri && !match) {
|
|
110
|
-
/* eslint-disable-next-line max-len */
|
|
111
116
|
const err = new Error(`${this.sri} integrity checksum failed when using ${this.algorithm}: wanted ${this.digests} but got ${newSri}. (${this.size} bytes)`)
|
|
112
117
|
err.code = 'EINTEGRITY'
|
|
113
118
|
err.found = newSri
|
|
@@ -137,8 +142,7 @@ class Hash {
|
|
|
137
142
|
const strict = opts?.strict
|
|
138
143
|
this.source = hash.trim()
|
|
139
144
|
|
|
140
|
-
// set default values so that we make V8 happy to
|
|
141
|
-
// always see a familiar object template.
|
|
145
|
+
// set default values so that we make V8 happy to always see a familiar object template.
|
|
142
146
|
this.digest = ''
|
|
143
147
|
this.algorithm = ''
|
|
144
148
|
this.options = []
|
|
@@ -156,6 +160,9 @@ class Hash {
|
|
|
156
160
|
if (strict && !SPEC_ALGORITHMS.includes(match[1])) {
|
|
157
161
|
return
|
|
158
162
|
}
|
|
163
|
+
if (!NODE_HASHES.includes(match[1])) {
|
|
164
|
+
return
|
|
165
|
+
}
|
|
159
166
|
this.algorithm = match[1]
|
|
160
167
|
this.digest = match[2]
|
|
161
168
|
|
|
@@ -198,15 +205,12 @@ class Hash {
|
|
|
198
205
|
|
|
199
206
|
toString (opts) {
|
|
200
207
|
if (opts?.strict) {
|
|
201
|
-
// Strict mode enforces the standard as close to the foot of the
|
|
202
|
-
// letter as it can.
|
|
208
|
+
// Strict mode enforces the standard as close to the foot of the letter as it can.
|
|
203
209
|
if (!(
|
|
204
210
|
// The spec has very restricted productions for algorithms.
|
|
205
211
|
// https://www.w3.org/TR/CSP2/#source-list-syntax
|
|
206
212
|
SPEC_ALGORITHMS.includes(this.algorithm) &&
|
|
207
|
-
// Usually, if someone insists on using a "different" base64, we
|
|
208
|
-
// leave it as-is, since there's multiple standards, and the
|
|
209
|
-
// specified is not a URL-safe variant.
|
|
213
|
+
// Usually, if someone insists on using a "different" base64, we leave it as-is, since there are multiple standards, and the specified is not a URL-safe variant.
|
|
210
214
|
// https://www.w3.org/TR/CSP2/#base64_value
|
|
211
215
|
this.digest.match(BASE64_REGEX) &&
|
|
212
216
|
// Option syntax is strictly visual chars.
|
|
@@ -300,8 +304,7 @@ class Integrity {
|
|
|
300
304
|
return parse(this, { single: true }).hexDigest()
|
|
301
305
|
}
|
|
302
306
|
|
|
303
|
-
// add additional hashes to an integrity value, but prevent
|
|
304
|
-
// *changing* an existing integrity hash.
|
|
307
|
+
// add additional hashes to an integrity value, but prevent *changing* an existing integrity hash.
|
|
305
308
|
merge (integrity, opts) {
|
|
306
309
|
const other = parse(integrity, opts)
|
|
307
310
|
for (const algo in other) {
|
|
@@ -323,33 +326,25 @@ class Integrity {
|
|
|
323
326
|
return false
|
|
324
327
|
}
|
|
325
328
|
const algo = other.pickAlgorithm(opts, Object.keys(this))
|
|
326
|
-
return (
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
other[algo] &&
|
|
330
|
-
this[algo].find(hash =>
|
|
331
|
-
other[algo].find(otherhash =>
|
|
332
|
-
hash.digest === otherhash.digest
|
|
333
|
-
)
|
|
329
|
+
return !!algo && this[algo].find(hash =>
|
|
330
|
+
other[algo].find(otherhash =>
|
|
331
|
+
hash.digest === otherhash.digest
|
|
334
332
|
)
|
|
335
333
|
) || false
|
|
336
334
|
}
|
|
337
335
|
|
|
338
|
-
// Pick the highest priority algorithm present, optionally also limited to a
|
|
339
|
-
//
|
|
340
|
-
// nothing.
|
|
336
|
+
// Pick the highest priority algorithm present, optionally also limited to a set of hashes found in another integrity.
|
|
337
|
+
// When limiting it may return nothing.
|
|
341
338
|
pickAlgorithm (opts, hashes) {
|
|
342
339
|
const pickAlgorithm = opts?.pickAlgorithm || getPrioritizedHash
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
return true
|
|
348
|
-
})
|
|
340
|
+
let keys = Object.keys(this)
|
|
341
|
+
if (hashes?.length) {
|
|
342
|
+
keys = keys.filter(k => hashes.includes(k))
|
|
343
|
+
}
|
|
349
344
|
if (keys.length) {
|
|
350
345
|
return keys.reduce((acc, algo) => pickAlgorithm(acc, algo) || acc)
|
|
351
346
|
}
|
|
352
|
-
// no intersection between this and hashes
|
|
347
|
+
// no intersection between this and hashes
|
|
353
348
|
return null
|
|
354
349
|
}
|
|
355
350
|
}
|
|
@@ -380,7 +375,7 @@ function _parse (integrity, opts) {
|
|
|
380
375
|
const hash = new Hash(string, opts)
|
|
381
376
|
if (hash.algorithm && hash.digest) {
|
|
382
377
|
const algo = hash.algorithm
|
|
383
|
-
if (!acc
|
|
378
|
+
if (!Object.keys(acc).includes(algo)) {
|
|
384
379
|
acc[algo] = []
|
|
385
380
|
}
|
|
386
381
|
acc[algo].push(hash)
|
|
@@ -421,9 +416,7 @@ function fromData (data, opts) {
|
|
|
421
416
|
`${algo}-${digest}${optString}`,
|
|
422
417
|
opts
|
|
423
418
|
)
|
|
424
|
-
|
|
425
|
-
* just calculated with an algo did not have an algo or digest.
|
|
426
|
-
*/
|
|
419
|
+
// istanbul ignore else - it would be VERY strange if the string we just calculated with an algo did not have an algo or digest.
|
|
427
420
|
if (hash.algorithm && hash.digest) {
|
|
428
421
|
const hashAlgo = hash.algorithm
|
|
429
422
|
if (!acc[hashAlgo]) {
|
|
@@ -473,7 +466,6 @@ function checkData (data, sri, opts) {
|
|
|
473
466
|
if (match || !(opts.error)) {
|
|
474
467
|
return match
|
|
475
468
|
} else if (typeof opts.size === 'number' && (data.length !== opts.size)) {
|
|
476
|
-
/* eslint-disable-next-line max-len */
|
|
477
469
|
const err = new Error(`data size mismatch when checking ${sri}.\n Wanted: ${opts.size}\n Found: ${data.length}`)
|
|
478
470
|
err.code = 'EBADSIZE'
|
|
479
471
|
err.found = data.length
|
|
@@ -481,7 +473,6 @@ function checkData (data, sri, opts) {
|
|
|
481
473
|
err.sri = sri
|
|
482
474
|
throw err
|
|
483
475
|
} else {
|
|
484
|
-
/* eslint-disable-next-line max-len */
|
|
485
476
|
const err = new Error(`Integrity checksum failed when using ${algorithm}: Wanted ${sri}, but got ${newSri}. (${data.length} bytes)`)
|
|
486
477
|
err.code = 'EINTEGRITY'
|
|
487
478
|
err.found = newSri
|
|
@@ -538,20 +529,11 @@ function createIntegrity (opts) {
|
|
|
538
529
|
digest: function () {
|
|
539
530
|
const integrity = algorithms.reduce((acc, algo) => {
|
|
540
531
|
const digest = hashes.shift().digest('base64')
|
|
541
|
-
const hash = new Hash(
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
)
|
|
545
|
-
/* istanbul ignore else - it would be VERY strange if the hash we
|
|
546
|
-
* just calculated with an algo did not have an algo or digest.
|
|
547
|
-
*/
|
|
548
|
-
if (hash.algorithm && hash.digest) {
|
|
549
|
-
const hashAlgo = hash.algorithm
|
|
550
|
-
if (!acc[hashAlgo]) {
|
|
551
|
-
acc[hashAlgo] = []
|
|
552
|
-
}
|
|
553
|
-
acc[hashAlgo].push(hash)
|
|
532
|
+
const hash = new Hash(`${algo}-${digest}${optString}`, opts)
|
|
533
|
+
if (!acc[hash.algorithm]) {
|
|
534
|
+
acc[hash.algorithm] = []
|
|
554
535
|
}
|
|
536
|
+
acc[hash.algorithm].push(hash)
|
|
555
537
|
return acc
|
|
556
538
|
}, new Integrity())
|
|
557
539
|
|
|
@@ -560,18 +542,6 @@ function createIntegrity (opts) {
|
|
|
560
542
|
}
|
|
561
543
|
}
|
|
562
544
|
|
|
563
|
-
const NODE_HASHES = crypto.getHashes()
|
|
564
|
-
|
|
565
|
-
// This is a Best Effort™ at a reasonable priority for hash algos
|
|
566
|
-
const DEFAULT_PRIORITY = [
|
|
567
|
-
'md5', 'whirlpool', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512',
|
|
568
|
-
// TODO - it's unclear _which_ of these Node will actually use as its name
|
|
569
|
-
// for the algorithm, so we guesswork it based on the OpenSSL names.
|
|
570
|
-
'sha3',
|
|
571
|
-
'sha3-256', 'sha3-384', 'sha3-512',
|
|
572
|
-
'sha3_256', 'sha3_384', 'sha3_512',
|
|
573
|
-
].filter(algo => NODE_HASHES.includes(algo))
|
|
574
|
-
|
|
575
545
|
function getPrioritizedHash (algo1, algo2) {
|
|
576
546
|
/* eslint-disable-next-line max-len */
|
|
577
547
|
return DEFAULT_PRIORITY.indexOf(algo1.toLowerCase()) >= DEFAULT_PRIORITY.indexOf(algo2.toLowerCase())
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ssri",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "13.0.1",
|
|
4
4
|
"description": "Standard Subresource Integrity library -- parses, serializes, generates, and verifies integrity metadata according to the SRI spec.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -11,21 +11,16 @@
|
|
|
11
11
|
"prerelease": "npm t",
|
|
12
12
|
"postrelease": "npm publish",
|
|
13
13
|
"posttest": "npm run lint",
|
|
14
|
-
"test": "
|
|
14
|
+
"test": "node --test './test/**/*.js'",
|
|
15
15
|
"coverage": "tap",
|
|
16
16
|
"lint": "npm run eslint",
|
|
17
17
|
"postlint": "template-oss-check",
|
|
18
18
|
"template-oss-apply": "template-oss-apply --force",
|
|
19
19
|
"lintfix": "npm run eslint -- --fix",
|
|
20
|
-
"snap": "
|
|
21
|
-
"eslint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\""
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"check-coverage": true,
|
|
25
|
-
"nyc-arg": [
|
|
26
|
-
"--exclude",
|
|
27
|
-
"tap-snapshots/**"
|
|
28
|
-
]
|
|
20
|
+
"snap": "node --test --test-update-snapshots './test/**/*.js'",
|
|
21
|
+
"eslint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"",
|
|
22
|
+
"test:node20": "node --test test",
|
|
23
|
+
"test:cover": "node --test --experimental-test-coverage --test-timeout=3000 --test-coverage-lines=100 --test-coverage-functions=100 --test-coverage-branches=100 './test/**/*.js'"
|
|
29
24
|
},
|
|
30
25
|
"repository": {
|
|
31
26
|
"type": "git",
|
|
@@ -51,16 +46,21 @@
|
|
|
51
46
|
"minipass": "^7.0.3"
|
|
52
47
|
},
|
|
53
48
|
"devDependencies": {
|
|
54
|
-
"@npmcli/eslint-config": "^
|
|
55
|
-
"@npmcli/template-oss": "4.
|
|
56
|
-
"
|
|
49
|
+
"@npmcli/eslint-config": "^6.0.0",
|
|
50
|
+
"@npmcli/template-oss": "4.28.1",
|
|
51
|
+
"benchmark": "^2.1.4"
|
|
57
52
|
},
|
|
58
53
|
"engines": {
|
|
59
|
-
"node": "^
|
|
54
|
+
"node": "^20.17.0 || >=22.9.0"
|
|
60
55
|
},
|
|
61
56
|
"templateOSS": {
|
|
62
57
|
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
|
|
63
|
-
"version": "4.
|
|
64
|
-
"publish": "true"
|
|
58
|
+
"version": "4.28.1",
|
|
59
|
+
"publish": "true",
|
|
60
|
+
"allowPaths": [
|
|
61
|
+
"benchmarks/"
|
|
62
|
+
],
|
|
63
|
+
"testRunner": "node:test",
|
|
64
|
+
"latestVersion": 24
|
|
65
65
|
}
|
|
66
66
|
}
|