mirror of
https://github.com/fluencelabs/js-libp2p-crypto
synced 2025-06-26 22:32:00 +00:00
fix: catch error when unmarshaling instead of crashing (#113)
* test: Add failing tests * fix: Fix some failing tests * fix: various fixes on garbage error handling and respective tests * tests: increased timeout for test timing out in CI * tests: increasing test timeout to please the CI gods * tests: increasing test timeout to please the CI gods * fix: for when unMarshallPrivateKey is called with null or undefined key
This commit is contained in:
committed by
David Dias
parent
bf9b532067
commit
7608fdd858
@ -81,7 +81,13 @@ exports.marshalPublicKey = (key, type) => {
|
||||
// Converts a protobuf serialized private key into its
|
||||
// representative object
|
||||
exports.unmarshalPrivateKey = (buf, callback) => {
|
||||
const decoded = keysPBM.PrivateKey.decode(buf)
|
||||
let decoded
|
||||
try {
|
||||
decoded = keysPBM.PrivateKey.decode(buf)
|
||||
} catch (err) {
|
||||
return callback(err)
|
||||
}
|
||||
|
||||
const data = decoded.Data
|
||||
|
||||
switch (decoded.Type) {
|
||||
|
Reference in New Issue
Block a user