chore: apply suggestions from code review

This commit is contained in:
Vasco Santos
2020-07-17 14:00:59 +02:00
committed by Jacob Heun
parent 15613ccf19
commit f574e82a5d
15 changed files with 75 additions and 68 deletions

View File

@ -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) {