greymass / anchor-link

Persistent, fast and secure signature provider for EOSIO chains built on top of EOSIO Signing Requests (EEP-7)
Other
53 stars 22 forks source link

Validate configuration parameters during initialization #19

Closed aaroncox closed 3 years ago

aaroncox commented 3 years ago

When setting up the link instance, having some sanity checks for non-typescript applications and their configuration would help troubleshoot issues during setup. For example:

// initialize the browser transport
const transport = new AnchorLinkBrowserTransport()
// initialize the link, this time we are using the TELOS chain
const link = new AnchorLink({
    transport,
    chains: [{
        chainId: '4667b205c6838ef70ff7988f6e8257e8be0e1284a2f59699054a018f743b1d11',
        INCORRECT: 'https://telos.greymass.com'
    }]
})

The chains are incorrectly configured and are missing the nodeUrl field. This could be the wrong keyword or even perhaps a casing issue. The goal would be to have it detect and throw an exception if the configuration was invalid to help the developer track down why it is not working.

Currently, if you specify a bad value for nodeUrl, it'll actually let you start the login process and then when it attempts to do the identity proof verification, it'll throw the following error:

link.ts:473 Uncaught (in promise) TypeError: Cannot read property 'v1' of undefined

This error isn't all that helpful in tracking down that the nodeUrl parameter is wrong.