node-vault icon indicating copy to clipboard operation
node-vault copied to clipboard

How to unseal a vault that is already initialized?

Open CoinCoderBuffalo opened this issue 2 years ago • 2 comments

Basic question. I don't see any examples on handling this scenario. Thanks

CoinCoderBuffalo avatar Dec 20 '22 19:12 CoinCoderBuffalo

I figured out how to do this. I added an async run command to the client to handle this.

vaultClient.run = async () => {
  try {
    const status = await vaultClient.status()
    if (!status.initialized) {
      await vaultClient.init({ secret_shares: 1, secret_threshold: 1 })
    }
    if (status.sealed) {
      await vaultClient.unseal({ secret_shares: 1, key: config.vault.key })
    }
    logger.success('node-vault', 'Vault initialized and unsealed')
  } catch (err) {
    logger.error('node-vault', err.message)
  }
}

CoinCoderBuffalo avatar Dec 20 '22 19:12 CoinCoderBuffalo

Please add this to the documentation. There are lots of missing things in the docs that leaves us lost and unsure what to do.

jeghers avatar Jun 12 '23 03:06 jeghers