bpanel
bpanel copied to clipboard
Client Unauthorized Error
There exists a condition in which a bug can happen here: https://github.com/bpanel-org/bpanel/blob/development/server/bcoinRouter.js#L24
If the request times out on the back end, the token
is not reset
For the wallet, we could do something like:
let wallet = client.wallet(id, token)
wallet.request(...)
But that wouldn't work with the node client, as it wouldn't have a wallet method. Maybe we can create a new and temporary client with something like:
// inject(Client)
let newclient = client.inject(client)
newclient.token = token
newclient.request(...)
or
// inject(Client, opts {})
let specialized = client.inject(client, { id, token })
// returns client.wallet() or client.node()
// that comes from a new client instance
Maybe inject is a static method that returns a new instance of the client?
Would have to reference client.prototype
to be able to reach the method then I believe
That would mean making a new client on every request? Does the finally
get skipped on timeouts?
Only if the token from the front end is different than the token on the backend, because that token needs to be proxied for some requests. I think an exception is raised and it breaks the control flow and doesn't trigger the finally