blob: f9560d660e8bdd19e451543a330378638c53d014 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
'use strict'
// Utilities for generating and verifying the packageIntegrity field for
// package-lock
//
// Spec: https://github.com/npm/npm/pull/16441
const ssri = require('ssri')
const SSRI_OPTS = {
algorithms: ['sha512']
}
module.exports.check = check
function check (pkg, integrity) {
return ssri.checkData(JSON.stringify(pkg), integrity, SSRI_OPTS)
}
module.exports.hash = hash
function hash (pkg) {
return ssri.fromData(JSON.stringify(pkg), SSRI_OPTS).toString()
}
|