@unicitylabs/sphere-sdk 0.12.0-dev.1 → 0.13.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.
@@ -7834,6 +7834,10 @@ declare class Sphere {
7834
7834
  private _masterKey;
7835
7835
  private _mnemonic;
7836
7836
  private _password;
7837
+ /** True when the wallet was created/loaded/imported WITH a password. Distinguishes
7838
+ * "no password by design" (encrypt passes through) from "the password is gone" (encrypt
7839
+ * must throw rather than silently write plaintext over an encrypted record). */
7840
+ private _passwordProtected;
7837
7841
  private _source;
7838
7842
  private _derivationMode;
7839
7843
  private _basePath;
@@ -7834,6 +7834,10 @@ declare class Sphere {
7834
7834
  private _masterKey;
7835
7835
  private _mnemonic;
7836
7836
  private _password;
7837
+ /** True when the wallet was created/loaded/imported WITH a password. Distinguishes
7838
+ * "no password by design" (encrypt passes through) from "the password is gone" (encrypt
7839
+ * must throw rather than silently write plaintext over an encrypted record). */
7840
+ private _passwordProtected;
7837
7841
  private _source;
7838
7842
  private _derivationMode;
7839
7843
  private _basePath;
@@ -10754,6 +10754,7 @@ var PaymentsModule = class _PaymentsModule {
10754
10754
  this.spendQueue.destroy();
10755
10755
  this.reservationLedger.clear();
10756
10756
  this.parsedTokenCache.clear();
10757
+ this.tokens.clear();
10757
10758
  this.unsubscribeStorageEvents();
10758
10759
  }
10759
10760
  // ===========================================================================
@@ -26707,6 +26708,10 @@ var Sphere = class _Sphere {
26707
26708
  _masterKey = null;
26708
26709
  _mnemonic = null;
26709
26710
  _password = null;
26711
+ /** True when the wallet was created/loaded/imported WITH a password. Distinguishes
26712
+ * "no password by design" (encrypt passes through) from "the password is gone" (encrypt
26713
+ * must throw rather than silently write plaintext over an encrypted record). */
26714
+ _passwordProtected = false;
26710
26715
  _source = "unknown";
26711
26716
  _derivationMode = "bip32";
26712
26717
  _basePath = DEFAULT_BASE_PATH;
@@ -27035,6 +27040,7 @@ var Sphere = class _Sphere {
27035
27040
  options.walletApi
27036
27041
  );
27037
27042
  sphere._password = options.password ?? null;
27043
+ sphere._passwordProtected = sphere._password !== null;
27038
27044
  progress?.({ step: "storing_keys", message: "Storing wallet keys..." });
27039
27045
  await sphere.storeMnemonic(options.mnemonic, options.derivationPath);
27040
27046
  await sphere.initializeIdentityFromMnemonic(options.mnemonic, options.derivationPath);
@@ -27099,6 +27105,7 @@ var Sphere = class _Sphere {
27099
27105
  options.walletApi
27100
27106
  );
27101
27107
  sphere._password = options.password ?? null;
27108
+ sphere._passwordProtected = sphere._password !== null;
27102
27109
  if (!options.storage.isConnected()) {
27103
27110
  await options.storage.connect();
27104
27111
  }
@@ -27170,6 +27177,7 @@ var Sphere = class _Sphere {
27170
27177
  options.walletApi
27171
27178
  );
27172
27179
  sphere._password = options.password ?? null;
27180
+ sphere._passwordProtected = sphere._password !== null;
27173
27181
  progress?.({ step: "storing_keys", message: "Storing wallet keys..." });
27174
27182
  if (options.mnemonic) {
27175
27183
  if (!_Sphere.validateMnemonic(options.mnemonic)) {
@@ -27526,6 +27534,7 @@ var Sphere = class _Sphere {
27526
27534
  * Check if wallet has BIP32 master key for HD derivation
27527
27535
  */
27528
27536
  hasMasterKey() {
27537
+ this.ensureReady();
27529
27538
  return this._masterKey !== null;
27530
27539
  }
27531
27540
  // ===========================================================================
@@ -27555,12 +27564,14 @@ var Sphere = class _Sphere {
27555
27564
  * Returns null if wallet was imported from file (masterKey only)
27556
27565
  */
27557
27566
  getMnemonic() {
27567
+ this.ensureReady();
27558
27568
  return this._mnemonic;
27559
27569
  }
27560
27570
  /**
27561
27571
  * Get wallet info for backup/export purposes
27562
27572
  */
27563
27573
  getWalletInfo() {
27574
+ this.ensureReady();
27564
27575
  let address0 = null;
27565
27576
  try {
27566
27577
  if (this._identity) {
@@ -29349,6 +29360,9 @@ var Sphere = class _Sphere {
29349
29360
  this._initialized = false;
29350
29361
  this._trackedAddressesLoaded = false;
29351
29362
  this._identity = null;
29363
+ this._mnemonic = null;
29364
+ this._masterKey = null;
29365
+ this._password = null;
29352
29366
  this._trackedAddresses.clear();
29353
29367
  this._addressIdToIndex.clear();
29354
29368
  this._addressNametags.clear();
@@ -29834,7 +29848,12 @@ var Sphere = class _Sphere {
29834
29848
  // Private: Encryption
29835
29849
  // ===========================================================================
29836
29850
  encrypt(data) {
29837
- if (!this._password) return data;
29851
+ if (!this._password) {
29852
+ if (this._passwordProtected) {
29853
+ throw new SphereError("Wallet password is not available", "NOT_INITIALIZED");
29854
+ }
29855
+ return data;
29856
+ }
29838
29857
  return encryptSimple(data, this._password);
29839
29858
  }
29840
29859
  decrypt(encrypted) {