Skip to content

Commit

Permalink
fix: remove node globals (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
hugomrdias authored Apr 23, 2020
1 parent 363f655 commit 636041b
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@
"sinon": "^9.0.0"
},
"dependencies": {
"bs58": "^4.0.1",
"debug": "^4.1.1",
"err-code": "^2.0.0",
"it-length-prefixed": "^3.0.0",
"it-pipe": "^1.0.1",
"it-pushable": "^1.3.2",
"libp2p-crypto": "~0.17.0",
"libp2p-interfaces": "^0.3.0",
"multibase": "^0.7.0",
"peer-id": "~0.13.3",
"protons": "^1.0.1"
},
Expand Down
2 changes: 1 addition & 1 deletion src/message/sign.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict'

const { Buffer } = require('buffer')
const PeerId = require('peer-id')
const { Message } = require('./index')
const SignPrefix = Buffer.from('libp2p-pubsub:')
Expand Down
7 changes: 4 additions & 3 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
'use strict'

const { Buffer } = require('buffer')
const crypto = require('libp2p-crypto')
const bs58 = require('bs58')
const multibase = require('multibase')

exports = module.exports

Expand Down Expand Up @@ -77,7 +78,7 @@ exports.ensureArray = (maybeArray) => {
exports.normalizeInRpcMessage = (message) => {
const m = Object.assign({}, message)
if (Buffer.isBuffer(message.from)) {
m.from = bs58.encode(message.from)
m.from = multibase.encode('base58btc', message.from).toString().slice(1)
}
return m
}
Expand All @@ -97,7 +98,7 @@ exports.normalizeInRpcMessages = (messages) => {
exports.normalizeOutRpcMessage = (message) => {
const m = Object.assign({}, message)
if (typeof message.from === 'string' || message.from instanceof String) {
m.from = bs58.decode(message.from)
m.from = multibase.decode('z' + message.from)
}
return m
}
Expand Down
1 change: 1 addition & 0 deletions test/sign.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/* eslint max-nested-callbacks: ["error", 5] */
'use strict'

const { Buffer } = require('buffer')
const chai = require('chai')
chai.use(require('dirty-chai'))
const expect = chai.expect
Expand Down
2 changes: 1 addition & 1 deletion test/utils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
'use strict'

const { expect } = require('chai')

const { Buffer } = require('buffer')
const utils = require('../src/utils')

describe('utils', () => {
Expand Down

0 comments on commit 636041b

Please sign in to comment.