mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-06-26 07:21:36 +00:00
chore: apply suggestions from code review
This commit is contained in:
@ -112,7 +112,12 @@ const formatSignaturePayload = (domain, payloadType, payload) => {
|
||||
])
|
||||
}
|
||||
|
||||
const unmarshalEnvelope = async (data) => {
|
||||
/**
|
||||
* Unmarshal a serialized Envelope protobuf message.
|
||||
* @param {Buffer} data
|
||||
* @return {Promise<Envelope>}
|
||||
*/
|
||||
Envelope.createFromProtobuf = async (data) => {
|
||||
const envelopeData = Protobuf.decode(data)
|
||||
const peerId = await PeerId.createFromPubKey(envelopeData.public_key)
|
||||
|
||||
@ -124,13 +129,6 @@ const unmarshalEnvelope = async (data) => {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Unmarshal a serialized Envelope protobuf message.
|
||||
* @param {Buffer} data
|
||||
* @return {Promise<Envelope>}
|
||||
*/
|
||||
Envelope.createFromProtobuf = unmarshalEnvelope
|
||||
|
||||
/**
|
||||
* Seal marshals the given Record, places the marshaled bytes inside an Envelope
|
||||
* and signs it with the given peerId's private key.
|
||||
@ -163,7 +161,7 @@ Envelope.seal = async (record, peerId) => {
|
||||
* @return {Envelope}
|
||||
*/
|
||||
Envelope.openAndCertify = async (data, domain) => {
|
||||
const envelope = await unmarshalEnvelope(data)
|
||||
const envelope = await Envelope.createFromProtobuf(data)
|
||||
const valid = await envelope.validate(domain)
|
||||
|
||||
if (!valid) {
|
||||
|
Reference in New Issue
Block a user