Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
})
}
if (!cache || !hash) {
throw new Error('stat() requires a fully-resolved pkgmap file address')
}
let info
try {
info = await ccRead.hasContent(cache, hash)
} catch (err) {
await repairPackage(cache, hash, pkg)
info = await ccRead.hasContent(cache, hash)
}
if (!info) {
return false
}
const cpath = ccPath(cache, info.sri)
if (verify) {
try {
await ssri.checkStream(
fs.createReadStream(cpath),
info.sri
)
} catch (err) {
const newResolved = await repairPackage({ cache, hash, pkg, resolvedPath })
cache = newResolved.cache
hash = newResolved.hash
pkg = newResolved.pkg
await ssri.checkStream(
fs.createReadStream(cpath),
info.sri
)
}
ssri.checkData(
fs.readFileSync.orig(cpath),
info.sri
)
} catch (err) {
const newResolved = fetchPackageSync(cache, pkg, hash)
cache = newResolved.cache
ssri.checkData(
fs.readFileSync.orig(cpath),
info.sri
)
}
}
return Object.assign(info.stat, {
integrity: info.sri.toString(),
cachePath: ccPath(cache, info.sri)
})
}
})
}
if (!cache || !hash) {
throw new Error('statSync() requires a fully-resolved pkgmap file address')
}
let info
try {
info = ccGet.hasContent.sync(cache, hash, { memoize: true })
} catch (err) {
fetchPackageSync(cache, pkg, hash)
info = ccGet.hasContent.sync(cache, hash, { memoize: true })
}
if (!info) {
return false
}
const cpath = ccPath(cache, info.sri)
if (verify) {
try {
ssri.checkData(
fs.readFileSync.orig(cpath),
info.sri
)
} catch (err) {
const newResolved = fetchPackageSync(cache, pkg, hash)
cache = newResolved.cache
ssri.checkData(
fs.readFileSync.orig(cpath),
info.sri
)
}
}
return Object.assign(info.stat, {
await ssri.checkStream(
fs.createReadStream.orig(cpath),
info.sri
)
} catch (err) {
const newResolved = await fetchPackage(cache, pkg, hash)
cache = newResolved.cache
await ssri.checkStream(
fs.createReadStream.orig(cpath),
info.sri
)
}
}
return Object.assign(info.stat, {
integrity: info.sri.toString(),
cachePath: ccPath(cache, info.sri)
})
}
info.sri
)
} catch (err) {
const newResolved = repairPackageSync({ cache, hash, pkg, resolvedPath })
cache = newResolved.cache
hash = newResolved.hash
pkg = newResolved.pkg
ssri.checkData(
fs.readFileSync(cpath),
info.sri
)
}
}
return Object.assign(info.stat, {
integrity: info.sri.toString(),
cachePath: ccPath(cache, info.sri)
})
}
info.sri
)
} catch (err) {
const newResolved = await repairPackage({ cache, hash, pkg, resolvedPath })
cache = newResolved.cache
hash = newResolved.hash
pkg = newResolved.pkg
await ssri.checkStream(
fs.createReadStream(cpath),
info.sri
)
}
}
return Object.assign(info.stat, {
integrity: info.sri.toString(),
cachePath: ccPath(cache, info.sri)
})
}
})
}
if (!cache || !hash) {
throw new Error('statSync() requires a fully-resolved pkgmap file address')
}
let info
try {
info = ccRead.hasContent.sync(cache, hash)
} catch (err) {
repairPackageSync(cache, hash, pkg)
info = ccRead.hasContent.sync(cache, hash)
}
if (!info) {
return false
}
const cpath = ccPath(cache, info.sri)
if (verify) {
try {
ssri.checkData(
fs.readFileSync(cpath),
info.sri
)
} catch (err) {
const newResolved = repairPackageSync({ cache, hash, pkg, resolvedPath })
cache = newResolved.cache
hash = newResolved.hash
pkg = newResolved.pkg
ssri.checkData(
fs.readFileSync(cpath),
info.sri
)
}
})
}
if (!cache || !hash) {
throw new Error('stat() requires a fully-resolved pkgmap file address')
}
let info
try {
info = await ccGet.hasContent(cache, hash)
} catch (err) {
await fetchPackage(cache, hash, pkg)
info = await ccGet.hasContent(cache, hash)
}
if (!info) {
return false
}
const cpath = ccPath(cache, info.sri)
if (verify) {
try {
await ssri.checkStream(
fs.createReadStream.orig(cpath),
info.sri
)
} catch (err) {
const newResolved = await fetchPackage(cache, pkg, hash)
cache = newResolved.cache
await ssri.checkStream(
fs.createReadStream.orig(cpath),
info.sri
)
}
}
return Object.assign(info.stat, {