libp2p-pubsub
Advanced tools
Comparing version 0.5.4 to 0.5.5
@@ -0,1 +1,6 @@ | ||
<a name="0.5.5"></a> | ||
## [0.5.5](https://github.com/libp2p/js-libp2p-pubsub/compare/v0.5.4...v0.5.5) (2020-07-14) | ||
<a name="0.5.4"></a> | ||
@@ -2,0 +7,0 @@ ## [0.5.4](https://github.com/libp2p/js-libp2p-pubsub/compare/v0.5.3...v0.5.4) (2020-07-07) |
{ | ||
"name": "libp2p-pubsub", | ||
"version": "0.5.4", | ||
"version": "0.5.5", | ||
"description": "Pubsub base protocol for libp2p pubsub routers", | ||
@@ -70,4 +70,4 @@ "leadMaintainer": "Vasco Santos <santos.vasco10@gmail.com>", | ||
"Mikerah <mikerahqc@protonmail.com>", | ||
"Cayman <caymannava@gmail.com>", | ||
"Topper Bowers <topper@toppingdesign.com>", | ||
"Cayman <caymannava@gmail.com>", | ||
"Hugo Dias <hugomrdias@gmail.com>", | ||
@@ -74,0 +74,0 @@ "Alex Potsides <alex@achingbrain.net>", |
@@ -18,2 +18,12 @@ 'use strict' | ||
/** | ||
* @typedef {Object} InMessage | ||
* @property {string} from | ||
* @property {string} receivedFrom | ||
* @property {string[]} topicIDs | ||
* @property {Buffer} data | ||
* @property {Buffer} [signature] | ||
* @property {Buffer} [key] | ||
*/ | ||
function validateRegistrar (registrar) { | ||
@@ -261,3 +271,3 @@ // registrar handling | ||
* Validates the given message. The signature will be checked for authenticity. | ||
* @param {rpc.RPC.Message} message | ||
* @param {InMessage} message | ||
* @returns {Promise<Boolean>} | ||
@@ -264,0 +274,0 @@ */ |
@@ -56,3 +56,3 @@ 'use strict' | ||
* | ||
* @param {Message} message | ||
* @param {InMessage} message | ||
* @returns {Promise<PublicKey>} | ||
@@ -70,3 +70,8 @@ */ | ||
// should be available in the from property of the message (peer id) | ||
const from = PeerId.createFromBytes(message.from) | ||
let from | ||
if (typeof message.from === 'string') { | ||
from = PeerId.createFromB58String(message.from) | ||
} else { | ||
from = PeerId.createFromBytes(message.from) | ||
} | ||
@@ -73,0 +78,0 @@ if (from.pubKey) { |
@@ -76,5 +76,6 @@ 'use strict' | ||
* @param {Buffer|String} message.from | ||
* @param {PeerId} peerId | ||
* @return {Object} | ||
*/ | ||
exports.normalizeInRpcMessage = (message) => { | ||
exports.normalizeInRpcMessage = (message, peerId) => { | ||
const m = Object.assign({}, message) | ||
@@ -84,17 +85,8 @@ if (Buffer.isBuffer(message.from)) { | ||
} | ||
if (peerId) { | ||
m.receivedFrom = peerId.toB58String() | ||
} | ||
return m | ||
} | ||
/** | ||
* The same as `normalizeInRpcMessage`, but performed on an array of messages | ||
* @param {Object[]} messages | ||
* @return {Object[]} | ||
*/ | ||
exports.normalizeInRpcMessages = (messages) => { | ||
if (!messages) { | ||
return messages | ||
} | ||
return messages.map(exports.normalizeInRpcMessage) | ||
} | ||
exports.normalizeOutRpcMessage = (message) => { | ||
@@ -107,8 +99,1 @@ const m = Object.assign({}, message) | ||
} | ||
exports.normalizeOutRpcMessages = (messages) => { | ||
if (!messages) { | ||
return messages | ||
} | ||
return messages.map(exports.normalizeOutRpcMessage) | ||
} |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
492548
724