@unicitylabs/sphere-sdk 0.3.2 → 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.
@@ -2504,9 +2504,7 @@ var DEFAULT_AGGREGATOR_URL = "https://aggregator.unicity.network/rpc";
2504
2504
  var DEV_AGGREGATOR_URL = "https://dev-aggregator.dyndns.org/rpc";
2505
2505
  var TEST_AGGREGATOR_URL = "https://goggregator-test.unicity.network";
2506
2506
  var DEFAULT_IPFS_GATEWAYS = [
2507
- "https://ipfs.unicity.network",
2508
- "https://dweb.link",
2509
- "https://ipfs.io"
2507
+ "https://unicity-ipfs1.dyndns.org"
2510
2508
  ];
2511
2509
  var DEFAULT_BASE_PATH = "m/44'/0'/0'";
2512
2510
  var DEFAULT_DERIVATION_PATH2 = `${DEFAULT_BASE_PATH}/0/0`;
@@ -9804,6 +9802,7 @@ var Sphere = class _Sphere {
9804
9802
  _identity = null;
9805
9803
  _masterKey = null;
9806
9804
  _mnemonic = null;
9805
+ _password = null;
9807
9806
  _source = "unknown";
9808
9807
  _derivationMode = "bip32";
9809
9808
  _basePath = DEFAULT_BASE_PATH;
@@ -9903,7 +9902,8 @@ var Sphere = class _Sphere {
9903
9902
  tokenStorage: options.tokenStorage,
9904
9903
  l1: options.l1,
9905
9904
  price: options.price,
9906
- groupChat
9905
+ groupChat,
9906
+ password: options.password
9907
9907
  });
9908
9908
  return { sphere: sphere2, created: false };
9909
9909
  }
@@ -9929,7 +9929,8 @@ var Sphere = class _Sphere {
9929
9929
  nametag: options.nametag,
9930
9930
  l1: options.l1,
9931
9931
  price: options.price,
9932
- groupChat
9932
+ groupChat,
9933
+ password: options.password
9933
9934
  });
9934
9935
  return { sphere, created: true, generatedMnemonic };
9935
9936
  }
@@ -9976,6 +9977,7 @@ var Sphere = class _Sphere {
9976
9977
  options.price,
9977
9978
  groupChatConfig
9978
9979
  );
9980
+ sphere._password = options.password ?? null;
9979
9981
  await sphere.storeMnemonic(options.mnemonic, options.derivationPath);
9980
9982
  await sphere.initializeIdentityFromMnemonic(options.mnemonic, options.derivationPath);
9981
9983
  await sphere.initializeProviders();
@@ -10009,6 +10011,7 @@ var Sphere = class _Sphere {
10009
10011
  options.price,
10010
10012
  groupChatConfig
10011
10013
  );
10014
+ sphere._password = options.password ?? null;
10012
10015
  await sphere.loadIdentityFromStorage();
10013
10016
  await sphere.initializeProviders();
10014
10017
  await sphere.initializeModules();
@@ -10061,6 +10064,7 @@ var Sphere = class _Sphere {
10061
10064
  options.price,
10062
10065
  groupChatConfig
10063
10066
  );
10067
+ sphere._password = options.password ?? null;
10064
10068
  if (options.mnemonic) {
10065
10069
  if (!_Sphere.validateMnemonic(options.mnemonic)) {
10066
10070
  throw new Error("Invalid mnemonic");
@@ -12239,9 +12243,20 @@ var Sphere = class _Sphere {
12239
12243
  // Private: Encryption
12240
12244
  // ===========================================================================
12241
12245
  encrypt(data) {
12242
- return encryptSimple(data, DEFAULT_ENCRYPTION_KEY);
12246
+ if (!this._password) return data;
12247
+ return encryptSimple(data, this._password);
12243
12248
  }
12244
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
+ }
12245
12260
  try {
12246
12261
  return decryptSimple(encrypted, DEFAULT_ENCRYPTION_KEY);
12247
12262
  } catch {