What commands could I run to manually generate (or confirm) the integrity
field contained in a package-lock.json
file?
Here's an example with SHA1:
"uglify-js": {
"version": "2.8.29",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.29.tgz",
"integrity": "sha1-KcVzMUgFe7Th913zW3qcty5qWd0=",
And another with SHA512:
"uri-js": {
"version": "4.2.2",
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz",
"integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==",
My wild guess was to run the specified hash against the tgz file and then base64 encode it, but that's not it. For example:
$ sha1sum.exe uglify-js-2.8.29.tgz
29c5733148057bb4e1f75df35b7a9cb72e6a59dd *uglify-js-2.8.29.tgz
$ sha1sum.exe uglify-js-2.8.29.tgz | cut -d " " -f1
29c5733148057bb4e1f75df35b7a9cb72e6a59dd
$ sha1sum.exe uglify-js-2.8.29.tgz | cut -d " " -f1 | base64
MjljNTczMzE0ODA1N2JiNGUxZjc1ZGYzNWI3YTljYjcyZTZhNTlkZAo=
And that obviously does not equal:
KcVzMUgFe7Th913zW3qcty5qWd0=