@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.
- package/dist/connect/index.cjs +802 -110
- package/dist/connect/index.cjs.map +1 -1
- package/dist/connect/index.d.cts +305 -16
- package/dist/connect/index.d.ts +305 -16
- package/dist/connect/index.js +802 -110
- package/dist/connect/index.js.map +1 -1
- package/dist/core/index.cjs +20 -1
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +4 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/index.js +20 -1
- package/dist/core/index.js.map +1 -1
- package/dist/impl/browser/connect/index.cjs +208 -41
- package/dist/impl/browser/connect/index.cjs.map +1 -1
- package/dist/impl/browser/connect/index.d.cts +33 -1
- package/dist/impl/browser/connect/index.d.ts +33 -1
- package/dist/impl/browser/connect/index.js +208 -41
- package/dist/impl/browser/connect/index.js.map +1 -1
- package/dist/impl/nodejs/connect/index.cjs +101 -1
- package/dist/impl/nodejs/connect/index.cjs.map +1 -1
- package/dist/impl/nodejs/connect/index.d.cts +6 -1
- package/dist/impl/nodejs/connect/index.d.ts +6 -1
- package/dist/impl/nodejs/connect/index.js +101 -1
- package/dist/impl/nodejs/connect/index.js.map +1 -1
- package/dist/index.cjs +20 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +20 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.d.cts
CHANGED
|
@@ -8249,6 +8249,10 @@ declare class Sphere {
|
|
|
8249
8249
|
private _masterKey;
|
|
8250
8250
|
private _mnemonic;
|
|
8251
8251
|
private _password;
|
|
8252
|
+
/** True when the wallet was created/loaded/imported WITH a password. Distinguishes
|
|
8253
|
+
* "no password by design" (encrypt passes through) from "the password is gone" (encrypt
|
|
8254
|
+
* must throw rather than silently write plaintext over an encrypted record). */
|
|
8255
|
+
private _passwordProtected;
|
|
8252
8256
|
private _source;
|
|
8253
8257
|
private _derivationMode;
|
|
8254
8258
|
private _basePath;
|
package/dist/index.d.ts
CHANGED
|
@@ -8249,6 +8249,10 @@ declare class Sphere {
|
|
|
8249
8249
|
private _masterKey;
|
|
8250
8250
|
private _mnemonic;
|
|
8251
8251
|
private _password;
|
|
8252
|
+
/** True when the wallet was created/loaded/imported WITH a password. Distinguishes
|
|
8253
|
+
* "no password by design" (encrypt passes through) from "the password is gone" (encrypt
|
|
8254
|
+
* must throw rather than silently write plaintext over an encrypted record). */
|
|
8255
|
+
private _passwordProtected;
|
|
8252
8256
|
private _source;
|
|
8253
8257
|
private _derivationMode;
|
|
8254
8258
|
private _basePath;
|
package/dist/index.js
CHANGED
|
@@ -12314,6 +12314,7 @@ var PaymentsModule = class _PaymentsModule {
|
|
|
12314
12314
|
this.spendQueue.destroy();
|
|
12315
12315
|
this.reservationLedger.clear();
|
|
12316
12316
|
this.parsedTokenCache.clear();
|
|
12317
|
+
this.tokens.clear();
|
|
12317
12318
|
this.unsubscribeStorageEvents();
|
|
12318
12319
|
}
|
|
12319
12320
|
// ===========================================================================
|
|
@@ -28262,6 +28263,10 @@ var Sphere = class _Sphere {
|
|
|
28262
28263
|
_masterKey = null;
|
|
28263
28264
|
_mnemonic = null;
|
|
28264
28265
|
_password = null;
|
|
28266
|
+
/** True when the wallet was created/loaded/imported WITH a password. Distinguishes
|
|
28267
|
+
* "no password by design" (encrypt passes through) from "the password is gone" (encrypt
|
|
28268
|
+
* must throw rather than silently write plaintext over an encrypted record). */
|
|
28269
|
+
_passwordProtected = false;
|
|
28265
28270
|
_source = "unknown";
|
|
28266
28271
|
_derivationMode = "bip32";
|
|
28267
28272
|
_basePath = DEFAULT_BASE_PATH;
|
|
@@ -28590,6 +28595,7 @@ var Sphere = class _Sphere {
|
|
|
28590
28595
|
options.walletApi
|
|
28591
28596
|
);
|
|
28592
28597
|
sphere._password = options.password ?? null;
|
|
28598
|
+
sphere._passwordProtected = sphere._password !== null;
|
|
28593
28599
|
progress?.({ step: "storing_keys", message: "Storing wallet keys..." });
|
|
28594
28600
|
await sphere.storeMnemonic(options.mnemonic, options.derivationPath);
|
|
28595
28601
|
await sphere.initializeIdentityFromMnemonic(options.mnemonic, options.derivationPath);
|
|
@@ -28654,6 +28660,7 @@ var Sphere = class _Sphere {
|
|
|
28654
28660
|
options.walletApi
|
|
28655
28661
|
);
|
|
28656
28662
|
sphere._password = options.password ?? null;
|
|
28663
|
+
sphere._passwordProtected = sphere._password !== null;
|
|
28657
28664
|
if (!options.storage.isConnected()) {
|
|
28658
28665
|
await options.storage.connect();
|
|
28659
28666
|
}
|
|
@@ -28725,6 +28732,7 @@ var Sphere = class _Sphere {
|
|
|
28725
28732
|
options.walletApi
|
|
28726
28733
|
);
|
|
28727
28734
|
sphere._password = options.password ?? null;
|
|
28735
|
+
sphere._passwordProtected = sphere._password !== null;
|
|
28728
28736
|
progress?.({ step: "storing_keys", message: "Storing wallet keys..." });
|
|
28729
28737
|
if (options.mnemonic) {
|
|
28730
28738
|
if (!_Sphere.validateMnemonic(options.mnemonic)) {
|
|
@@ -29081,6 +29089,7 @@ var Sphere = class _Sphere {
|
|
|
29081
29089
|
* Check if wallet has BIP32 master key for HD derivation
|
|
29082
29090
|
*/
|
|
29083
29091
|
hasMasterKey() {
|
|
29092
|
+
this.ensureReady();
|
|
29084
29093
|
return this._masterKey !== null;
|
|
29085
29094
|
}
|
|
29086
29095
|
// ===========================================================================
|
|
@@ -29110,12 +29119,14 @@ var Sphere = class _Sphere {
|
|
|
29110
29119
|
* Returns null if wallet was imported from file (masterKey only)
|
|
29111
29120
|
*/
|
|
29112
29121
|
getMnemonic() {
|
|
29122
|
+
this.ensureReady();
|
|
29113
29123
|
return this._mnemonic;
|
|
29114
29124
|
}
|
|
29115
29125
|
/**
|
|
29116
29126
|
* Get wallet info for backup/export purposes
|
|
29117
29127
|
*/
|
|
29118
29128
|
getWalletInfo() {
|
|
29129
|
+
this.ensureReady();
|
|
29119
29130
|
let address0 = null;
|
|
29120
29131
|
try {
|
|
29121
29132
|
if (this._identity) {
|
|
@@ -30904,6 +30915,9 @@ var Sphere = class _Sphere {
|
|
|
30904
30915
|
this._initialized = false;
|
|
30905
30916
|
this._trackedAddressesLoaded = false;
|
|
30906
30917
|
this._identity = null;
|
|
30918
|
+
this._mnemonic = null;
|
|
30919
|
+
this._masterKey = null;
|
|
30920
|
+
this._password = null;
|
|
30907
30921
|
this._trackedAddresses.clear();
|
|
30908
30922
|
this._addressIdToIndex.clear();
|
|
30909
30923
|
this._addressNametags.clear();
|
|
@@ -31389,7 +31403,12 @@ var Sphere = class _Sphere {
|
|
|
31389
31403
|
// Private: Encryption
|
|
31390
31404
|
// ===========================================================================
|
|
31391
31405
|
encrypt(data) {
|
|
31392
|
-
if (!this._password)
|
|
31406
|
+
if (!this._password) {
|
|
31407
|
+
if (this._passwordProtected) {
|
|
31408
|
+
throw new SphereError("Wallet password is not available", "NOT_INITIALIZED");
|
|
31409
|
+
}
|
|
31410
|
+
return data;
|
|
31411
|
+
}
|
|
31393
31412
|
return encryptSimple(data, this._password);
|
|
31394
31413
|
}
|
|
31395
31414
|
decrypt(encrypted) {
|