diff --git a/package.json b/package.json index 3b8e90a..868ea75 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "peer-id": "~0.13.6" }, "dependencies": { - "buffer-split": "^1.0.0", + "buffer": "^5.6.0", "err-code": "^2.0.0", "multihashes": "~0.4.15", "multihashing-async": "^0.8.0", diff --git a/src/record.js b/src/record.js index 5fe8c79..0db6451 100644 --- a/src/record.js +++ b/src/record.js @@ -1,7 +1,7 @@ 'use strict' const protons = require('protons') - +const { Buffer } = require('buffer') const pb = protons(require('./record.proto')).Record const utils = require('./utils') diff --git a/src/selection.js b/src/selection.js index 93e18ab..e3423b8 100644 --- a/src/selection.js +++ b/src/selection.js @@ -1,8 +1,6 @@ 'use strict' -const bsplit = require('buffer-split') const errcode = require('err-code') - /** * Select the best record out of the given records. * @@ -18,7 +16,7 @@ const bestRecord = (selectors, k, records) => { throw errcode(new Error(errMsg), 'ERR_NO_RECORDS_RECEIVED') } - const parts = bsplit(k, Buffer.from('/')) + const parts = k.toString().split('/') if (parts.length < 3) { const errMsg = 'Record key does not have a selector function' diff --git a/src/validator.js b/src/validator.js index 07d17e6..1723964 100644 --- a/src/validator.js +++ b/src/validator.js @@ -1,8 +1,6 @@ 'use strict' -const bsplit = require('buffer-split') const errcode = require('err-code') - /** * Checks a record and ensures it is still valid. * It runs the needed validators. @@ -14,7 +12,7 @@ const errcode = require('err-code') */ const verifyRecord = (validators, record) => { const key = record.key - const parts = bsplit(key, Buffer.from('/')) + const parts = key.toString().split('/') if (parts.length < 3) { // No validator available diff --git a/src/validators/public-key.js b/src/validators/public-key.js index 1681944..0799e8f 100644 --- a/src/validators/public-key.js +++ b/src/validators/public-key.js @@ -2,7 +2,7 @@ const multihashing = require('multihashing-async') const errcode = require('err-code') - +const { Buffer } = require('buffer') /** * Validator for publick key records. * Verifies that the passed in record value is the PublicKey diff --git a/test/fixtures/go-key-records.js b/test/fixtures/go-key-records.js index 4df45e1..c483bab 100644 --- a/test/fixtures/go-key-records.js +++ b/test/fixtures/go-key-records.js @@ -1,5 +1,5 @@ 'use strict' - +const { Buffer } = require('buffer') module.exports = { publicKey: Buffer.from( 'CAASXjBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQDjXAQQMal4SB2tSnX6NJIPmC69/BT8A8jc7/gDUZNkEhdhYHvc7k7S4vntV/c92nJGxNdop9fKJyevuNMuXhhHAgMBAAE=', diff --git a/test/fixtures/go-record.js b/test/fixtures/go-record.js index d91b84d..188b6c1 100644 --- a/test/fixtures/go-record.js +++ b/test/fixtures/go-record.js @@ -1,5 +1,5 @@ 'use strict' - +const { Buffer } = require('buffer') // Fixtures generated using gore (https://github.com/motemen/gore) // // :import github.com/libp2p/go-libp2p-record diff --git a/test/record.spec.js b/test/record.spec.js index e4d71f2..a8aa060 100644 --- a/test/record.spec.js +++ b/test/record.spec.js @@ -4,7 +4,7 @@ const chai = require('chai') chai.use(require('dirty-chai')) const expect = chai.expect - +const { Buffer } = require('buffer') const libp2pRecord = require('../src') const Record = libp2pRecord.Record diff --git a/test/selection.spec.js b/test/selection.spec.js index 89fd284..b90adf0 100644 --- a/test/selection.spec.js +++ b/test/selection.spec.js @@ -3,7 +3,7 @@ 'use strict' var expect = require('chai').expect - +const { Buffer } = require('buffer') const libp2pRecord = require('../src') const selection = libp2pRecord.selection diff --git a/test/validator.spec.js b/test/validator.spec.js index a043941..7e34da7 100644 --- a/test/validator.spec.js +++ b/test/validator.spec.js @@ -7,7 +7,7 @@ chai.use(require('dirty-chai')) const expect = chai.expect const crypto = require('libp2p-crypto') const PeerId = require('peer-id') - +const { Buffer } = require('buffer') const libp2pRecord = require('../src') const validator = libp2pRecord.validator const Record = libp2pRecord.Record