I am specifically looking at the npm package metadata like from the lodash package, the relevant part which is this:
{
"shasum": "392617f69a947e40cec7848d85fcc3dd29d74bc5",
"tarball": "https://registry.npmjs.org/lodash/-/lodash-0.1.0.tgz",
"integrity": "sha512-ufIfwX7g5obXKaJhzbnAJBNf5Idxqty+AHaNadWFxtNKjGmF/ZO8ptSEjQRQRymBPZtLa0NV9sbrsH87Ae2R1A==",
"signatures": [
{
"keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
"sig": "MEQCIBB7pdqPfBFUsZQhVr3woDJ7/bbRWV3tlXQZNp3ivosbAiBMhwfq9fqaJvFFX1/scqPbIywUUZCQkfJaISqaJbZX2Q=="
}
]
}
What exactly are these 4 things used for, and how are they computed roughly speaking?
- shasum
- integrity
- keyid
- sig
The second one, the integrity
, I figured out is the sha-512 of the tar.gz:
shasum -a 512 lodash-0.1.0.tgz | cut -f1 -d\ | xxd -r -p | base64
ufIfwX7g5obXKaJhzbnAJBNf5Idxqty+AHaNadWFxtNKjGmF/ZO8ptSEjQRQRymBPZtLa0NV9sbrsH87Ae2R1A==
That would be computed I guess at the moment after it is uploaded to the package registry. Then it would be used when you download the package tar.gz, to check that the integrity value matches.
But what about the other 3 values?
- How are they calculated (and what from exactly)?
- When are they used in the verification process?
If there is anything more/better which a package manager should do, I'd be curious to know, but I assume npm already has this figured out and so just want to know what they did basically.