@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/core/index.cjs
CHANGED
|
@@ -9802,6 +9802,7 @@ var Sphere = class _Sphere {
|
|
|
9802
9802
|
_identity = null;
|
|
9803
9803
|
_masterKey = null;
|
|
9804
9804
|
_mnemonic = null;
|
|
9805
|
+
_password = null;
|
|
9805
9806
|
_source = "unknown";
|
|
9806
9807
|
_derivationMode = "bip32";
|
|
9807
9808
|
_basePath = DEFAULT_BASE_PATH;
|
|
@@ -9901,7 +9902,8 @@ var Sphere = class _Sphere {
|
|
|
9901
9902
|
tokenStorage: options.tokenStorage,
|
|
9902
9903
|
l1: options.l1,
|
|
9903
9904
|
price: options.price,
|
|
9904
|
-
groupChat
|
|
9905
|
+
groupChat,
|
|
9906
|
+
password: options.password
|
|
9905
9907
|
});
|
|
9906
9908
|
return { sphere: sphere2, created: false };
|
|
9907
9909
|
}
|
|
@@ -9927,7 +9929,8 @@ var Sphere = class _Sphere {
|
|
|
9927
9929
|
nametag: options.nametag,
|
|
9928
9930
|
l1: options.l1,
|
|
9929
9931
|
price: options.price,
|
|
9930
|
-
groupChat
|
|
9932
|
+
groupChat,
|
|
9933
|
+
password: options.password
|
|
9931
9934
|
});
|
|
9932
9935
|
return { sphere, created: true, generatedMnemonic };
|
|
9933
9936
|
}
|
|
@@ -9974,6 +9977,7 @@ var Sphere = class _Sphere {
|
|
|
9974
9977
|
options.price,
|
|
9975
9978
|
groupChatConfig
|
|
9976
9979
|
);
|
|
9980
|
+
sphere._password = options.password ?? null;
|
|
9977
9981
|
await sphere.storeMnemonic(options.mnemonic, options.derivationPath);
|
|
9978
9982
|
await sphere.initializeIdentityFromMnemonic(options.mnemonic, options.derivationPath);
|
|
9979
9983
|
await sphere.initializeProviders();
|
|
@@ -10007,6 +10011,7 @@ var Sphere = class _Sphere {
|
|
|
10007
10011
|
options.price,
|
|
10008
10012
|
groupChatConfig
|
|
10009
10013
|
);
|
|
10014
|
+
sphere._password = options.password ?? null;
|
|
10010
10015
|
await sphere.loadIdentityFromStorage();
|
|
10011
10016
|
await sphere.initializeProviders();
|
|
10012
10017
|
await sphere.initializeModules();
|
|
@@ -10059,6 +10064,7 @@ var Sphere = class _Sphere {
|
|
|
10059
10064
|
options.price,
|
|
10060
10065
|
groupChatConfig
|
|
10061
10066
|
);
|
|
10067
|
+
sphere._password = options.password ?? null;
|
|
10062
10068
|
if (options.mnemonic) {
|
|
10063
10069
|
if (!_Sphere.validateMnemonic(options.mnemonic)) {
|
|
10064
10070
|
throw new Error("Invalid mnemonic");
|
|
@@ -12237,9 +12243,20 @@ var Sphere = class _Sphere {
|
|
|
12237
12243
|
// Private: Encryption
|
|
12238
12244
|
// ===========================================================================
|
|
12239
12245
|
encrypt(data) {
|
|
12240
|
-
return
|
|
12246
|
+
if (!this._password) return data;
|
|
12247
|
+
return encryptSimple(data, this._password);
|
|
12241
12248
|
}
|
|
12242
12249
|
decrypt(encrypted) {
|
|
12250
|
+
if (this._password) {
|
|
12251
|
+
try {
|
|
12252
|
+
return decryptSimple(encrypted, this._password);
|
|
12253
|
+
} catch {
|
|
12254
|
+
return null;
|
|
12255
|
+
}
|
|
12256
|
+
}
|
|
12257
|
+
if (validateMnemonic2(encrypted) || /^[0-9a-f]{64}$/i.test(encrypted)) {
|
|
12258
|
+
return encrypted;
|
|
12259
|
+
}
|
|
12243
12260
|
try {
|
|
12244
12261
|
return decryptSimple(encrypted, DEFAULT_ENCRYPTION_KEY);
|
|
12245
12262
|
} catch {
|