@@ -86,6 +86,44 @@ vault.init({ secret_shares: 1, secret_threshold: 1 })
8686 .catch (console .error );
8787```
8888
89+ ### Unseal a vault that is already initialized
90+
91+ If the vault server has been restarted or sealed, you can unseal it using
92+ the unseal keys from the original initialization. If the vault was initialized
93+ with ` secret_threshold > 1 ` , you must call ` unseal ` multiple times with
94+ different keys until the threshold is met.
95+
96+ ``` javascript
97+ const vault = require (' node-vault' )({
98+ apiVersion: ' v1' ,
99+ endpoint: ' http://127.0.0.1:8200' ,
100+ });
101+
102+ // unseal vault server with a single key
103+ vault .unseal ({ key: ' my-unseal-key' })
104+ .then (console .log )
105+ .catch (console .error );
106+ ```
107+
108+ When the vault requires multiple unseal keys (threshold > 1):
109+
110+ ``` javascript
111+ vault .unseal ({ key: ' first-unseal-key' })
112+ .then ((result ) => {
113+ // result.sealed will be true until enough keys are provided
114+ console .log (' Sealed:' , result .sealed );
115+ console .log (' Progress:' , result .progress + ' /' + result .t );
116+ return vault .unseal ({ key: ' second-unseal-key' });
117+ })
118+ .then ((result ) => {
119+ // once the threshold is met, sealed will be false
120+ console .log (' Sealed:' , result .sealed );
121+ })
122+ .catch (console .error );
123+ ```
124+
125+ See [ example/unseal.js] ( example/unseal.js ) for a working example.
126+
89127### Write, read, update and delete secrets
90128
91129``` javascript
0 commit comments