'Convert pkcs7 file to base64 signature

I'm trying to verify my signature which is in .p7s file. I've alteady succeed to verify a signed string, but what to do with .p7s? The library requires the file to be decoded in some way. How to extract signature from PKCS7 in Javascript?

The valid signature looks like this https://justpaste.it/7q72n

    var signature = SignDataInternal('hello')
    console.log(signature) // valid signature
    var signInfo = VerifyDataInternal(signature);
    _printSignInfo(signInfo); // it works


    let p7Data = fs.readFileSync('./data/signed.p7s')
    // ???? how to convert it??
    signInfo = VerifyDataInternal(p7Data) // error: wrong data format
    _printSignInfo(signInfo)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source