Socket
Socket
Sign inDemoInstall

libp2p-record

Package Overview
Dependencies
Maintainers
3
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

libp2p-record - npm Package Compare versions

Comparing version 0.6.0 to 0.6.1

5

CHANGELOG.md

@@ -0,1 +1,6 @@

<a name="0.6.1"></a>
## [0.6.1](https://github.com/libp2p/js-libp2p-record/compare/v0.6.0...v0.6.1) (2018-11-08)
<a name="0.6.0"></a>

@@ -2,0 +7,0 @@ # [0.6.0](https://github.com/libp2p/js-libp2p-record/compare/v0.5.1...v0.6.0) (2018-10-18)

4

package.json
{
"name": "libp2p-record",
"version": "0.6.0",
"version": "0.6.1",
"description": "libp2p record implementation",

@@ -51,2 +51,3 @@ "leadMaintainer": "Vasco Santos <vasco.santos@moxy.studio>",

"buffer-split": "^1.0.0",
"err-code": "^1.1.2",
"left-pad": "^1.1.3",

@@ -61,4 +62,5 @@ "multihashes": "~0.4.14",

"Vasco Santos <vasco.santos@ua.pt>",
"Vasco Santos <vasco.santos@moxy.studio>",
"ᴠɪᴄᴛᴏʀ ʙᴊᴇʟᴋʜᴏʟᴍ <victorbjelkholm@gmail.com>"
]
}
'use strict'
const bsplit = require('buffer-split')
const errcode = require('err-code')

@@ -15,3 +16,5 @@ /**

if (records.length === 0) {
throw new Error('No records given')
const errMsg = `No records given`
throw errcode(new Error(errMsg), 'ERR_NO_RECORDS_RECEIVED')
}

@@ -22,3 +25,5 @@

if (parts.length < 3) {
throw new Error('Record key does not have a selector function')
const errMsg = `Record key does not have a selector function`
throw errcode(new Error(errMsg), 'ERR_NO_SELECTOR_FUNCTION_FOR_RECORD_KEY')
}

@@ -29,3 +34,5 @@

if (!selector) {
throw new Error(`Unrecognized key prefix: ${parts[1]}`)
const errMsg = `Unrecognized key prefix: ${parts[1]}`
throw errcode(new Error(errMsg), 'ERR_UNRECOGNIZED_KEY_PREFIX')
}

@@ -32,0 +39,0 @@

'use strict'
const bsplit = require('buffer-split')
const errcode = require('err-code')

@@ -26,3 +27,5 @@ /**

if (!validator) {
return callback(new Error('Invalid record keytype'))
const errMsg = `Invalid record keytype`
return callback(errcode(new Error(errMsg), 'ERR_INVALID_RECORD_KEY_TYPE'))
}

@@ -29,0 +32,0 @@

@@ -14,2 +14,10 @@ /* eslint max-nested-callbacks: ["error", 8] */

describe('bestRecord', () => {
it('throws no records given when no records received', () => {
expect(
() => selection.bestRecord({}, Buffer.from('/'), [])
).to.throw(
/No records given/
)
})
it('throws on missing selector in the record key', () => {

@@ -16,0 +24,0 @@ expect(

@@ -82,2 +82,22 @@ /* eslint max-nested-callbacks: ["error", 8] */

})
it('calls not matching any validator', (done) => {
const k = Buffer.from('/hallo/you')
const rec = new Record(k, Buffer.from('world'), new PeerId(hash))
const validators = {
hello: {
func (key, value, cb) {
expect(key).to.eql(k)
expect(value).to.eql(Buffer.from('world'))
cb()
},
sign: false
}
}
validator.verifyRecord(validators, rec, (err) => {
expect(err).to.exist()
done()
})
})
})

@@ -84,0 +104,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc