Skip to content

Instantly share code, notes, and snippets.

View johnmpotter's full-sized avatar

John Potter johnmpotter

View GitHub Profile
@johnmpotter
johnmpotter / verify.js
Last active October 10, 2019 20:03
Node.js signature verification for BoletoSimples
import getRawBody from 'raw-body';
// Action pseudo code
async webhook(req) {
const key = KEY_FROM_BOLETOSIMPLES_WEBHOOK;
const signature = req.header('X-Hub-Signature');
// This is the important part. It only works with the raw body (in the form of a Buffer).
@johnmpotter
johnmpotter / getWeb3.js
Created November 5, 2017 20:12
Dynamic Web3 initialization (using Web3 from other providers like Mist or MetaMask if available)
import Web3 from 'web3'
let getWeb3 = new Promise(function(resolve, reject) {
// Wait for loading completion to avoid race conditions with web3 injection timing.
window.addEventListener('load', function() {
var results
var web3 = window.web3
// Checking if Web3 has been injected by the browser (Mist/MetaMask)
if (typeof web3 !== 'undefined') {