chiefy / vaulted

nodejs based wrapper for HashiCorp's Vault HTTP API
https://chiefy.github.io/vaulted
MIT License
47 stars 6 forks source link

is setToken() now redundant ? #70

Closed jmls closed 8 years ago

jmls commented 8 years ago

I thought that with the work you did (passing token into every api call) , there was no need for setToken() any more.

However, setToken() is the only place I can find where vault.initialized is set. I am connecting to a vault that has already been unsealed by another process, so I don't need / want to unseal() it.

var Vaulted = require('vaulted');

var vault = new Vaulted({
    vault_host: "myVault"
});

vault.prepare()
.then(function() {
    return vault.read({token: "foo", id: "bar"})
})
.then(function(data) {
    console.log("all ok");
})
.catch(function(e) {
    console.log("err",e)
})

this code returns

err [Error: Vault has not been initialized.]

However, if I change the read function to

vault.setToken("XXX");
return vault.read({token: "foo", id: "bar"})

then I don't get the error

kenjones-cisco commented 8 years ago

You should not have to call setToken but as part of removing the need of requiring the call to setToken (it is still an option for anyone that does not want to have to pass it to every API call), the flag for initialized is not being set properly.

Should get resolved in master later this evening.