@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.cjs CHANGED
@@ -316,7 +316,7 @@ var Vault = class {
316
316
  * Register a passkey as a second unlock path: the DEK (from the unlocked session)
317
317
  * is sealed under HKDF-SHA256(`prf`, salt = credential id). The password stays
318
318
  * the recovery path; `prf` is zeroized here. A v1 envelope must be unlocked (and
319
- * thereby upgraded) first.
319
+ * thereby upgraded) first, and the vault must hold a secret (it proves the DEK).
320
320
  */
321
321
  async addPasskey(dek, passkey) {
322
322
  try {
@@ -433,11 +433,14 @@ var Vault = class {
433
433
  const kek = await this._deriveScrypt(password, salt, kdf);
434
434
  return { v: 2, kdf, dek: await this._seal(kek, dek, aadDekV2(kdf)), secrets, passkeys, createdAt };
435
435
  }
436
- /** The caller's DEK must open this envelope's secrets — it is the key the password protects, not any 32 bytes. */
436
+ /**
437
+ * The caller's DEK must open this envelope's secrets — it is the key the password protects, not
438
+ * any 32 bytes. An empty vault has nothing to prove it with, so it is refused rather than trusted.
439
+ */
437
440
  async _requireDek(dek, envelope) {
438
441
  const ids = Object.keys(envelope.secrets);
439
442
  const key = await this._importDek(dek);
440
- if (ids.length === 0) return;
443
+ 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");
441
444
  const probe = await this._open(key, envelope.secrets[ids[0]], aadSecret(ids[0]), "locked");
442
445
  (0, import_core.zeroize)(probe);
443
446
  }