@anywalletkit/extension-kit 0.1.3 → 0.1.4

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/dist/index.d.cts CHANGED
@@ -188,7 +188,7 @@ declare class Vault {
188
188
  * Register a passkey as a second unlock path: the DEK (from the unlocked session)
189
189
  * is sealed under HKDF-SHA256(`prf`, salt = credential id). The password stays
190
190
  * the recovery path; `prf` is zeroized here. A v1 envelope must be unlocked (and
191
- * thereby upgraded) first.
191
+ * thereby upgraded) first, and the vault must hold a secret (it proves the DEK).
192
192
  */
193
193
  addPasskey(dek: Uint8Array, passkey: {
194
194
  id: string;
@@ -215,7 +215,10 @@ declare class Vault {
215
215
  private _random;
216
216
  /** A fresh envelope (v2 by default, v1 with `kdf: 'pbkdf2'`) wrapping `dek` under `password`. */
217
217
  private _sealEnvelope;
218
- /** The caller's DEK must open this envelope's secrets — it is the key the password protects, not any 32 bytes. */
218
+ /**
219
+ * The caller's DEK must open this envelope's secrets — it is the key the password protects, not
220
+ * any 32 bytes. An empty vault has nothing to prove it with, so it is refused rather than trusted.
221
+ */
219
222
  private _requireDek;
220
223
  private _derivePbkdf2;
221
224
  private _deriveScrypt;
package/dist/index.d.ts CHANGED
@@ -188,7 +188,7 @@ declare class Vault {
188
188
  * Register a passkey as a second unlock path: the DEK (from the unlocked session)
189
189
  * is sealed under HKDF-SHA256(`prf`, salt = credential id). The password stays
190
190
  * the recovery path; `prf` is zeroized here. A v1 envelope must be unlocked (and
191
- * thereby upgraded) first.
191
+ * thereby upgraded) first, and the vault must hold a secret (it proves the DEK).
192
192
  */
193
193
  addPasskey(dek: Uint8Array, passkey: {
194
194
  id: string;
@@ -215,7 +215,10 @@ declare class Vault {
215
215
  private _random;
216
216
  /** A fresh envelope (v2 by default, v1 with `kdf: 'pbkdf2'`) wrapping `dek` under `password`. */
217
217
  private _sealEnvelope;
218
- /** The caller's DEK must open this envelope's secrets — it is the key the password protects, not any 32 bytes. */
218
+ /**
219
+ * The caller's DEK must open this envelope's secrets — it is the key the password protects, not
220
+ * any 32 bytes. An empty vault has nothing to prove it with, so it is refused rather than trusted.
221
+ */
219
222
  private _requireDek;
220
223
  private _derivePbkdf2;
221
224
  private _deriveScrypt;
package/dist/index.js CHANGED
@@ -170,7 +170,7 @@ var Vault = class {
170
170
  * Register a passkey as a second unlock path: the DEK (from the unlocked session)
171
171
  * is sealed under HKDF-SHA256(`prf`, salt = credential id). The password stays
172
172
  * the recovery path; `prf` is zeroized here. A v1 envelope must be unlocked (and
173
- * thereby upgraded) first.
173
+ * thereby upgraded) first, and the vault must hold a secret (it proves the DEK).
174
174
  */
175
175
  async addPasskey(dek, passkey) {
176
176
  try {
@@ -287,11 +287,14 @@ var Vault = class {
287
287
  const kek = await this._deriveScrypt(password, salt, kdf);
288
288
  return { v: 2, kdf, dek: await this._seal(kek, dek, aadDekV2(kdf)), secrets, passkeys, createdAt };
289
289
  }
290
- /** The caller's DEK must open this envelope's secrets — it is the key the password protects, not any 32 bytes. */
290
+ /**
291
+ * The caller's DEK must open this envelope's secrets — it is the key the password protects, not
292
+ * any 32 bytes. An empty vault has nothing to prove it with, so it is refused rather than trusted.
293
+ */
291
294
  async _requireDek(dek, envelope) {
292
295
  const ids = Object.keys(envelope.secrets);
293
296
  const key = await this._importDek(dek);
294
- if (ids.length === 0) return;
297
+ if (ids.length === 0) throw new VaultError("Add a secret to the vault before a passkey: an empty vault cannot prove the key is its own.", "invalid-input");
295
298
  const probe = await this._open(key, envelope.secrets[ids[0]], aadSecret(ids[0]), "locked");
296
299
  zeroize(probe);
297
300
  }