@unicitylabs/sphere-sdk 0.3.3 → 0.3.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/core/index.cjs +20 -3
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +9 -0
- package/dist/core/index.d.ts +9 -0
- package/dist/core/index.js +20 -3
- package/dist/core/index.js.map +1 -1
- package/dist/impl/nodejs/index.cjs +18 -4
- package/dist/impl/nodejs/index.cjs.map +1 -1
- package/dist/impl/nodejs/index.d.cts +3 -0
- package/dist/impl/nodejs/index.d.ts +3 -0
- package/dist/impl/nodejs/index.js +18 -4
- package/dist/impl/nodejs/index.js.map +1 -1
- package/dist/index.cjs +20 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +20 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -10069,6 +10069,7 @@ var Sphere = class _Sphere {
|
|
|
10069
10069
|
_identity = null;
|
|
10070
10070
|
_masterKey = null;
|
|
10071
10071
|
_mnemonic = null;
|
|
10072
|
+
_password = null;
|
|
10072
10073
|
_source = "unknown";
|
|
10073
10074
|
_derivationMode = "bip32";
|
|
10074
10075
|
_basePath = DEFAULT_BASE_PATH;
|
|
@@ -10168,7 +10169,8 @@ var Sphere = class _Sphere {
|
|
|
10168
10169
|
tokenStorage: options.tokenStorage,
|
|
10169
10170
|
l1: options.l1,
|
|
10170
10171
|
price: options.price,
|
|
10171
|
-
groupChat
|
|
10172
|
+
groupChat,
|
|
10173
|
+
password: options.password
|
|
10172
10174
|
});
|
|
10173
10175
|
return { sphere: sphere2, created: false };
|
|
10174
10176
|
}
|
|
@@ -10194,7 +10196,8 @@ var Sphere = class _Sphere {
|
|
|
10194
10196
|
nametag: options.nametag,
|
|
10195
10197
|
l1: options.l1,
|
|
10196
10198
|
price: options.price,
|
|
10197
|
-
groupChat
|
|
10199
|
+
groupChat,
|
|
10200
|
+
password: options.password
|
|
10198
10201
|
});
|
|
10199
10202
|
return { sphere, created: true, generatedMnemonic };
|
|
10200
10203
|
}
|
|
@@ -10241,6 +10244,7 @@ var Sphere = class _Sphere {
|
|
|
10241
10244
|
options.price,
|
|
10242
10245
|
groupChatConfig
|
|
10243
10246
|
);
|
|
10247
|
+
sphere._password = options.password ?? null;
|
|
10244
10248
|
await sphere.storeMnemonic(options.mnemonic, options.derivationPath);
|
|
10245
10249
|
await sphere.initializeIdentityFromMnemonic(options.mnemonic, options.derivationPath);
|
|
10246
10250
|
await sphere.initializeProviders();
|
|
@@ -10274,6 +10278,7 @@ var Sphere = class _Sphere {
|
|
|
10274
10278
|
options.price,
|
|
10275
10279
|
groupChatConfig
|
|
10276
10280
|
);
|
|
10281
|
+
sphere._password = options.password ?? null;
|
|
10277
10282
|
await sphere.loadIdentityFromStorage();
|
|
10278
10283
|
await sphere.initializeProviders();
|
|
10279
10284
|
await sphere.initializeModules();
|
|
@@ -10326,6 +10331,7 @@ var Sphere = class _Sphere {
|
|
|
10326
10331
|
options.price,
|
|
10327
10332
|
groupChatConfig
|
|
10328
10333
|
);
|
|
10334
|
+
sphere._password = options.password ?? null;
|
|
10329
10335
|
if (options.mnemonic) {
|
|
10330
10336
|
if (!_Sphere.validateMnemonic(options.mnemonic)) {
|
|
10331
10337
|
throw new Error("Invalid mnemonic");
|
|
@@ -12504,9 +12510,20 @@ var Sphere = class _Sphere {
|
|
|
12504
12510
|
// Private: Encryption
|
|
12505
12511
|
// ===========================================================================
|
|
12506
12512
|
encrypt(data) {
|
|
12507
|
-
return
|
|
12513
|
+
if (!this._password) return data;
|
|
12514
|
+
return encryptSimple(data, this._password);
|
|
12508
12515
|
}
|
|
12509
12516
|
decrypt(encrypted) {
|
|
12517
|
+
if (this._password) {
|
|
12518
|
+
try {
|
|
12519
|
+
return decryptSimple(encrypted, this._password);
|
|
12520
|
+
} catch {
|
|
12521
|
+
return null;
|
|
12522
|
+
}
|
|
12523
|
+
}
|
|
12524
|
+
if (validateMnemonic2(encrypted) || /^[0-9a-f]{64}$/i.test(encrypted)) {
|
|
12525
|
+
return encrypted;
|
|
12526
|
+
}
|
|
12510
12527
|
try {
|
|
12511
12528
|
return decryptSimple(encrypted, DEFAULT_ENCRYPTION_KEY);
|
|
12512
12529
|
} catch {
|