UNPKG

@dapperlabs/dappauth

Version:

A util to prove actionable control ('ownership') over a public Ethereum address using eth_sign

25 lines (21 loc) 627 B
function isHexString(value) { return ( typeof value === 'string' && value.length % 2 === 0 && value.match(/^0x[0-9A-Fa-f]*$/) ); } function removeHexPrefix(value) { return value.slice(0, 2) === '0x' ? value.slice(2) : value; } function mergeErrors(errEOA, errCA) { const msgEOA = errEOA ? `errored with: ${errEOA.toString()}` : 'returned false'; return `Authorisation check failed and errored in 2 alternative flows. 'External Owned Account' check ${msgEOA} . 'Contract Account' check errored with: ${errCA.toString()}`; } module.exports = { isHexString, removeHexPrefix, mergeErrors, };