index.js
function(base64String, bufferEncoding = DEFAULT_ENCODING, cb = null){
        bufferEncoding = getEncodingOrDefault(bufferEncoding)
        var decodedObj = JSON.parse(Buffer.from(base64String, 'base64').toString())
        var result = {}
        if('signature' in decodedObj && 'recovery' in decodedObj){
            result = decodedObj
            result.signature = Buffer.from(result.signature, bufferEncoding)
            if('publicKey' in decodedObj){
                result.publicKey = Buffer.from(result.publicKey, bufferEncoding)
            }
        }
        else {
            result = new Error("decoded object does not contain all required elements!")
        }
        if(isFunction(cb)){
            if(result instanceof Error){
                return cb(result)
            } else {
                return cb(null, result)
            }
        } else {
            return result
        }
    }
function(base64String, bufferEncoding = DEFAULT_ENCODING, cb = null){
        bufferEncoding = getEncodingOrDefault(bufferEncoding)
        var decodedObj = JSON.parse(Buffer.from(base64String, 'base64').toString())
        var result = {}
        if('signature' in decodedObj && 'recovery' in decodedObj){
            result = decodedObj
            result.signature = Buffer.from(result.signature, bufferEncoding)
            if('publicKey' in decodedObj){
                result.publicKey = Buffer.from(result.publicKey, bufferEncoding)
            }
        }
        else {
            result = new Error("decoded object does not contain all required elements!")
        }
        if(isFunction(cb)){
            if(result instanceof Error){
                return cb(result)
            } else {
                return cb(null, result)
            }
        } else {
            return result
        }
    }
function ( base64String , bufferEncoding = DEFAULT_ENCODING , cb = null ) { bufferEncoding = getEncodingOrDefault ( bufferEncoding ) var decodedObj = JSON . parse ( Buffer . from ( base64String , 'base64' ) . toString ( ) ) var result = { } if ( 'signature' in decodedObj && 'recovery' in decodedObj ) { result = decodedObj result . signature = Buffer . from ( result . signature , bufferEncoding ) if ( 'publicKey' in decodedObj ) { result . publicKey = Buffer . from ( result . publicKey , bufferEncoding ) } } else { result = new Error ( "decoded object does not contain all required elements!" ) } if ( isFunction ( cb ) ) { if ( result instanceof Error ) { return cb ( result ) } else { return cb ( null , result ) } } else { return result } }
recover signature object from base64-encoded string
@param  {String}   base64String   String to decode
@param  {String}   bufferEncoding encoding for recovering the buffers inside the object
@param  {Function} cb             callback function
@return {Object}                  Signature object recovered from the input string, or Error object if an error occured
recover signature object from base64 - encoded string