Socket
Socket
Sign inDemoInstall

cacache

Package Overview
Dependencies
56
Maintainers
3
Versions
100
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 11.0.3 to 11.1.0

10

CHANGELOG.md

@@ -5,2 +5,12 @@ # Change Log

<a name="11.1.0"></a>
# [11.1.0](https://github.com/zkat/cacache/compare/v11.0.3...v11.1.0) (2018-08-01)
### Features
* **read:** add sync support for low-level content read ([b43af83](https://github.com/zkat/cacache/commit/b43af83))
<a name="11.0.3"></a>

@@ -7,0 +17,0 @@ ## [11.0.3](https://github.com/zkat/cacache/compare/v11.0.2...v11.0.3) (2018-08-01)

@@ -36,2 +36,17 @@ 'use strict'

module.exports.sync = readSync
function readSync (cache, integrity, opts) {
opts = ReadOpts(opts)
return withContentSriSync(cache, integrity, (cpath, sri) => {
const data = fs.readFileSync(cpath)
if (typeof opts.size === 'number' && opts.size !== data.length) {
throw sizeError(opts.size, data.length)
} else if (ssri.checkData(data, sri)) {
return data
} else {
throw integrityError(sri, cpath)
}
})
}
module.exports.stream = readStream

@@ -116,2 +131,24 @@ module.exports.readStream = readStream

function withContentSriSync (cache, integrity, fn) {
const sri = ssri.parse(integrity)
// If `integrity` has multiple entries, pick the first digest
// with available local data.
const algo = sri.pickAlgorithm()
const digests = sri[algo]
if (digests.length <= 1) {
const cpath = contentPath(cache, digests[0])
return fn(cpath, digests[0])
} else {
let lastErr = null
for (const meta of sri[sri.pickAlgorithm()]) {
try {
return withContentSriSync(cache, meta, fn)
} catch (err) {
lastErr = err
}
}
if (lastErr) { throw lastErr }
}
}
function sizeError (expected, found) {

@@ -118,0 +155,0 @@ var err = new Error(Y`Bad data size: expected inserted data to be ${expected} bytes, but got ${found} instead`)

2

package.json
{
"name": "cacache",
"version": "11.0.3",
"version": "11.1.0",
"cache-version": {

@@ -5,0 +5,0 @@ "content": "2",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc