cozy-keys-lib 4.1.7 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-keys-lib",
3
- "version": "4.1.7",
3
+ "version": "4.2.0",
4
4
  "description": "Interactions between cozy-keys and a bitwarden server",
5
5
  "browser": "transpiled/index.js",
6
6
  "main": "transpiled/index.node.js",
@@ -39,6 +39,8 @@ class VaultProvider extends React.Component {
39
39
  cozyClient.on('login', () => {
40
40
  this.setupClient(cozyClient.getStackClient().uri)
41
41
  })
42
+ } else {
43
+ this.setupClient(uri)
42
44
  }
43
45
  }
44
46
  if (instance) {
@@ -125,6 +127,10 @@ const withVaultClient = BaseComponent => {
125
127
 
126
128
  const useVaultClient = () => {
127
129
  const ctx = useContext(VaultContext)
130
+
131
+ if (!ctx) {
132
+ throw new Error('useVaultClient must be used within a VaultProvider')
133
+ }
128
134
  return ctx.vaultClient
129
135
  }
130
136
 
@@ -60,6 +60,8 @@ var VaultProvider = /*#__PURE__*/function (_React$Component) {
60
60
  cozyClient.on('login', function () {
61
61
  _this2.setupClient(cozyClient.getStackClient().uri);
62
62
  });
63
+ } else {
64
+ this.setupClient(uri);
63
65
  }
64
66
  }
65
67
 
@@ -176,6 +178,11 @@ var withVaultClient = function withVaultClient(BaseComponent) {
176
178
 
177
179
  var useVaultClient = function useVaultClient() {
178
180
  var ctx = useContext(VaultContext);
181
+
182
+ if (!ctx) {
183
+ throw new Error('useVaultClient must be used within a VaultProvider');
184
+ }
185
+
179
186
  return ctx.vaultClient;
180
187
  };
181
188