wallaby-cash 1.7.24 → 1.7.26

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/index.cjs.js CHANGED
@@ -3861,6 +3861,54 @@ exports.SeedPhraseType = void 0;
3861
3861
  SeedPhraseType["Algorand"] = "algorand";
3862
3862
  })(exports.SeedPhraseType || (exports.SeedPhraseType = {}));
3863
3863
 
3864
+ exports.ErrorResponseCodes = void 0;
3865
+ (function (ErrorResponseCodes) {
3866
+ // Request Payload
3867
+ ErrorResponseCodes["request_payload_missing"] = "request_payload_missing";
3868
+ ErrorResponseCodes["request_payload_wrong_format"] = "request_payload_wrong_format";
3869
+ // Auth API Key
3870
+ ErrorResponseCodes["auth_api_key_invalid"] = "auth_api_key_invalid";
3871
+ ErrorResponseCodes["auth_api_key_not_active"] = "auth_api_key_not_active";
3872
+ ErrorResponseCodes["auth_api_key_pub_key_not_set"] = "auth_api_key_pub_key_not_set";
3873
+ ErrorResponseCodes["auth_api_key_not_provided"] = "auth_api_key_not_provided";
3874
+ ErrorResponseCodes["auth_api_key_not_found"] = "auth_api_key_not_found";
3875
+ // Auth Origin
3876
+ ErrorResponseCodes["auth_origin_not_allowed"] = "auth_origin_not_allowed";
3877
+ // Auth API JWT
3878
+ ErrorResponseCodes["auth_api_jwt_invalid"] = "auth_api_jwt_invalid";
3879
+ ErrorResponseCodes["auth_api_jwt_not_active"] = "auth_api_jwt_not_active";
3880
+ ErrorResponseCodes["auth_api_jwt_not_provided"] = "auth_api_jwt_not_provided";
3881
+ // Auth Client JWT
3882
+ ErrorResponseCodes["auth_client_jwt_invalid"] = "auth_client_jwt_invalid";
3883
+ ErrorResponseCodes["auth_client_jwt_missing_external_id_payload"] = "auth_client_jwt_missing_external_id_payload";
3884
+ ErrorResponseCodes["auth_client_jwt_missing_exp_payload"] = "auth_client_jwt_missing_exp_payload";
3885
+ ErrorResponseCodes["auth_client_jwt_external_id_not_match"] = "auth_client_jwt_external_id_not_match";
3886
+ ErrorResponseCodes["auth_client_jwt_expired"] = "auth_client_jwt_expired";
3887
+ ErrorResponseCodes["auth_client_jwt_not_provided"] = "auth_client_jwt_not_provided";
3888
+ // Auth Client Transport keys
3889
+ ErrorResponseCodes["auth_client_pub_key_and_message_not_match"] = "auth_client_pub_key_and_message_not_match";
3890
+ ErrorResponseCodes["auth_client_pub_key_and_message_expired"] = "auth_client_pub_key_and_message_expired";
3891
+ ErrorResponseCodes["auth_client_pub_key_and_message_signature_failed"] = "auth_client_pub_key_and_message_signature_failed";
3892
+ ErrorResponseCodes["auth_client_pub_key_not_found"] = "auth_client_pub_key_not_found";
3893
+ // Auth User's Permission
3894
+ ErrorResponseCodes["auth_user_not_allowed_to_perform_the_action"] = "auth_user_not_allowed_to_perform_the_action";
3895
+ ErrorResponseCodes["multisig_participant_not_found"] = "multisig_participant_not_found";
3896
+ // Wallet
3897
+ ErrorResponseCodes["wallet_not_found"] = "wallet_not_found";
3898
+ // Asset
3899
+ ErrorResponseCodes["asset_not_found"] = "asset_not_found";
3900
+ // Seedphrase
3901
+ ErrorResponseCodes["seedphrase_could_not_be_decrypted"] = "seedphrase_could_not_be_decrypted";
3902
+ // User
3903
+ ErrorResponseCodes["user_already_exists"] = "user_already_exists";
3904
+ ErrorResponseCodes["user_not_found"] = "user_not_found";
3905
+ // OTP
3906
+ ErrorResponseCodes["otp_code_invalid"] = "otp_code_invalid";
3907
+ ErrorResponseCodes["otp_code_expired"] = "otp_code_expired";
3908
+ // Merchant
3909
+ ErrorResponseCodes["merchant_not_found"] = "merchant_not_found";
3910
+ })(exports.ErrorResponseCodes || (exports.ErrorResponseCodes = {}));
3911
+
3864
3912
  const global$1 = (typeof global !== "undefined" ? global :
3865
3913
  typeof self !== "undefined" ? self :
3866
3914
  typeof window !== "undefined" ? window : {});
@@ -4702,11 +4750,11 @@ var Base = /** @class */ (function () {
4702
4750
  Base.prototype.request = function (route, options) {
4703
4751
  return __awaiter(this, void 0, void 0, function () {
4704
4752
  var url, headers, http, _a, result, error_1, result, error_2, result, error_3, result, error_4, error_5;
4705
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
4706
- return __generator(this, function (_m) {
4707
- switch (_m.label) {
4753
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
4754
+ return __generator(this, function (_q) {
4755
+ switch (_q.label) {
4708
4756
  case 0:
4709
- _m.trys.push([0, 16, , 17]);
4757
+ _q.trys.push([0, 16, , 17]);
4710
4758
  url = void 0;
4711
4759
  if (typeof route.fullPath !== 'string') {
4712
4760
  url = route.fullPath(options === null || options === void 0 ? void 0 : options.payload);
@@ -4719,7 +4767,7 @@ var Base = /** @class */ (function () {
4719
4767
  }
4720
4768
  return [4 /*yield*/, this.getRequestHeaders(route.requiresAccessToken)];
4721
4769
  case 1:
4722
- headers = _m.sent();
4770
+ headers = _q.sent();
4723
4771
  if ((_b = this.options) === null || _b === void 0 ? void 0 : _b.headers) {
4724
4772
  headers = __assign(__assign({}, headers), this.options.headers);
4725
4773
  }
@@ -4729,10 +4777,12 @@ var Base = /** @class */ (function () {
4729
4777
  headers: headers,
4730
4778
  });
4731
4779
  http.interceptors.response.use(function (response) { return response; }, function (error) {
4732
- var _a, _b, _c;
4780
+ var _a, _b, _c, _d, _e;
4733
4781
  if ((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data) {
4734
4782
  logger.info('SDK::Base::Interceptor::error.response.data', (_b = error === null || error === void 0 ? void 0 : error.response) === null || _b === void 0 ? void 0 : _b.data);
4735
- return Promise.reject((_c = error === null || error === void 0 ? void 0 : error.response) === null || _c === void 0 ? void 0 : _c.data);
4783
+ if (((_c = error === null || error === void 0 ? void 0 : error.response) === null || _c === void 0 ? void 0 : _c.data.errorCode) && ((_d = error === null || error === void 0 ? void 0 : error.response) === null || _d === void 0 ? void 0 : _d.data.errorCode) !== exports.ErrorResponseCodes.user_already_exists) {
4784
+ return Promise.reject((_e = error === null || error === void 0 ? void 0 : error.response) === null || _e === void 0 ? void 0 : _e.data);
4785
+ }
4736
4786
  }
4737
4787
  logger.error('SDK::Base::Interceptor::error', error);
4738
4788
  return Promise.reject(error);
@@ -4746,63 +4796,66 @@ var Base = /** @class */ (function () {
4746
4796
  }
4747
4797
  return [3 /*break*/, 14];
4748
4798
  case 2:
4749
- _m.trys.push([2, 4, , 5]);
4799
+ _q.trys.push([2, 4, , 5]);
4750
4800
  return [4 /*yield*/, http.get(url)];
4751
4801
  case 3:
4752
- result = _m.sent();
4802
+ result = _q.sent();
4753
4803
  logger.info('SDK::Base::RequestMethod.Get::result', result);
4754
4804
  return [2 /*return*/, result === null || result === void 0 ? void 0 : result.data];
4755
4805
  case 4:
4756
- error_1 = _m.sent();
4806
+ error_1 = _q.sent();
4757
4807
  if (error_1 instanceof axios.AxiosError) {
4758
- logger.error('SDK::Base::RequestMethod.Get::error', (_c = error_1 === null || error_1 === void 0 ? void 0 : error_1.response) === null || _c === void 0 ? void 0 : _c.data);
4808
+ logger.error('SDK::Base::RequestMethod.Get::AxiosError', (_c = error_1 === null || error_1 === void 0 ? void 0 : error_1.response) === null || _c === void 0 ? void 0 : _c.data);
4759
4809
  return [2 /*return*/, Promise.reject((_d = error_1 === null || error_1 === void 0 ? void 0 : error_1.response) === null || _d === void 0 ? void 0 : _d.data)];
4760
4810
  }
4761
4811
  return [2 /*return*/, Promise.reject(error_1 === null || error_1 === void 0 ? void 0 : error_1.message)];
4762
4812
  case 5:
4763
- _m.trys.push([5, 7, , 8]);
4813
+ _q.trys.push([5, 7, , 8]);
4764
4814
  return [4 /*yield*/, http.post(url, JSON.stringify(options === null || options === void 0 ? void 0 : options.payload))];
4765
4815
  case 6:
4766
- result = _m.sent();
4816
+ result = _q.sent();
4767
4817
  logger.info('SDK::Base::RequestMethod.Post::result', result);
4768
4818
  return [2 /*return*/, result === null || result === void 0 ? void 0 : result.data];
4769
4819
  case 7:
4770
- error_2 = _m.sent();
4820
+ error_2 = _q.sent();
4771
4821
  if (error_2 instanceof axios.AxiosError) {
4772
- logger.error('SDK::Base::RequestMethod.Post::error', (_e = error_2 === null || error_2 === void 0 ? void 0 : error_2.response) === null || _e === void 0 ? void 0 : _e.data);
4773
- return [2 /*return*/, Promise.reject((_f = error_2 === null || error_2 === void 0 ? void 0 : error_2.response) === null || _f === void 0 ? void 0 : _f.data)];
4822
+ logger.error('SDK::Base::RequestMethod.Post::AxiosError', (_e = error_2 === null || error_2 === void 0 ? void 0 : error_2.response) === null || _e === void 0 ? void 0 : _e.data);
4823
+ if (((_f = error_2 === null || error_2 === void 0 ? void 0 : error_2.response) === null || _f === void 0 ? void 0 : _f.data.errorCode) && ((_g = error_2 === null || error_2 === void 0 ? void 0 : error_2.response) === null || _g === void 0 ? void 0 : _g.data.errorCode) === exports.ErrorResponseCodes.user_already_exists) {
4824
+ return [2 /*return*/, (_h = error_2 === null || error_2 === void 0 ? void 0 : error_2.response) === null || _h === void 0 ? void 0 : _h.data];
4825
+ }
4826
+ return [2 /*return*/, Promise.reject((_j = error_2 === null || error_2 === void 0 ? void 0 : error_2.response) === null || _j === void 0 ? void 0 : _j.data)];
4774
4827
  }
4775
4828
  return [2 /*return*/, Promise.reject(error_2 === null || error_2 === void 0 ? void 0 : error_2.message)];
4776
4829
  case 8:
4777
- _m.trys.push([8, 10, , 11]);
4778
- return [4 /*yield*/, http.put(url, (_g = JSON.stringify(options === null || options === void 0 ? void 0 : options.payload)) !== null && _g !== void 0 ? _g : null)];
4830
+ _q.trys.push([8, 10, , 11]);
4831
+ return [4 /*yield*/, http.put(url, (_k = JSON.stringify(options === null || options === void 0 ? void 0 : options.payload)) !== null && _k !== void 0 ? _k : null)];
4779
4832
  case 9:
4780
- result = _m.sent();
4833
+ result = _q.sent();
4781
4834
  return [2 /*return*/, result === null || result === void 0 ? void 0 : result.data];
4782
4835
  case 10:
4783
- error_3 = _m.sent();
4836
+ error_3 = _q.sent();
4784
4837
  if (error_3 instanceof axios.AxiosError) {
4785
- logger.error('SDK::Base::RequestMethod.Put::error', (_h = error_3 === null || error_3 === void 0 ? void 0 : error_3.response) === null || _h === void 0 ? void 0 : _h.data);
4786
- return [2 /*return*/, Promise.reject((_j = error_3 === null || error_3 === void 0 ? void 0 : error_3.response) === null || _j === void 0 ? void 0 : _j.data)];
4838
+ logger.error('SDK::Base::RequestMethod.Put::error', (_l = error_3 === null || error_3 === void 0 ? void 0 : error_3.response) === null || _l === void 0 ? void 0 : _l.data);
4839
+ return [2 /*return*/, Promise.reject((_m = error_3 === null || error_3 === void 0 ? void 0 : error_3.response) === null || _m === void 0 ? void 0 : _m.data)];
4787
4840
  }
4788
4841
  return [2 /*return*/, Promise.reject(error_3 === null || error_3 === void 0 ? void 0 : error_3.message)];
4789
4842
  case 11:
4790
- _m.trys.push([11, 13, , 14]);
4843
+ _q.trys.push([11, 13, , 14]);
4791
4844
  return [4 /*yield*/, http.delete(url)];
4792
4845
  case 12:
4793
- result = _m.sent();
4846
+ result = _q.sent();
4794
4847
  return [2 /*return*/, result === null || result === void 0 ? void 0 : result.data];
4795
4848
  case 13:
4796
- error_4 = _m.sent();
4849
+ error_4 = _q.sent();
4797
4850
  if (error_4 instanceof axios.AxiosError) {
4798
- logger.error('SDK::Base::RequestMethod.Put::error', (_k = error_4 === null || error_4 === void 0 ? void 0 : error_4.response) === null || _k === void 0 ? void 0 : _k.data);
4799
- return [2 /*return*/, Promise.reject((_l = error_4 === null || error_4 === void 0 ? void 0 : error_4.response) === null || _l === void 0 ? void 0 : _l.data)];
4851
+ logger.error('SDK::Base::RequestMethod.Put::AxiosError', (_o = error_4 === null || error_4 === void 0 ? void 0 : error_4.response) === null || _o === void 0 ? void 0 : _o.data);
4852
+ return [2 /*return*/, Promise.reject((_p = error_4 === null || error_4 === void 0 ? void 0 : error_4.response) === null || _p === void 0 ? void 0 : _p.data)];
4800
4853
  }
4801
4854
  return [2 /*return*/, Promise.reject(error_4 === null || error_4 === void 0 ? void 0 : error_4.message)];
4802
4855
  case 14: throw new Error('Request method is not supported');
4803
4856
  case 15: return [3 /*break*/, 17];
4804
4857
  case 16:
4805
- error_5 = _m.sent();
4858
+ error_5 = _q.sent();
4806
4859
  logger.error('SDK::Base::request::error', error_5);
4807
4860
  return [2 /*return*/, Promise.reject(error_5)];
4808
4861
  case 17: return [2 /*return*/];
@@ -5011,36 +5064,47 @@ var Auth = /** @class */ (function (_super) {
5011
5064
  * Authenticates a user by either signing them in or signing them up based on the presence of existing credentials.
5012
5065
  *
5013
5066
  * @param { string } password - The user's password.
5067
+ * @param { string } [wallabyUserId] - The user's Wallaby ID if available
5014
5068
  * @returns {Promise<AuthResponse>} - A promise that resolves to the authentication response.
5015
5069
  */
5016
5070
  Auth.prototype.authenticate = function (_a) {
5017
5071
  return __awaiter(this, arguments, void 0, function (_b) {
5018
- var wallabyAuthPubKey, wallabyAccessToken, hasAccount, authentication;
5019
- var password = _b.password;
5020
- return __generator(this, function (_c) {
5021
- switch (_c.label) {
5072
+ var _c, credentials, authTokens, wallabyAuthPubKey, wallabyAccessToken, hasAccount, authentication, user, accessToken;
5073
+ var _this = this;
5074
+ var password = _b.password, wallabyUserId = _b.wallabyUserId;
5075
+ return __generator(this, function (_d) {
5076
+ switch (_d.label) {
5022
5077
  case 0: return [4 /*yield*/, this.device];
5023
5078
  case 1:
5024
- wallabyAuthPubKey = (_c.sent()).credentials.wallabyPublicKey;
5025
- return [4 /*yield*/, this.device];
5026
- case 2:
5027
- wallabyAccessToken = (_c.sent()).authTokens.accessToken;
5028
- hasAccount = !!wallabyAccessToken || !!wallabyAuthPubKey;
5029
- if (!hasAccount) return [3 /*break*/, 4];
5079
+ _c = _d.sent(), credentials = _c.credentials, authTokens = _c.authTokens;
5080
+ wallabyAuthPubKey = credentials.wallabyPublicKey;
5081
+ wallabyAccessToken = authTokens.accessToken;
5082
+ hasAccount = !!wallabyAccessToken || !!wallabyAuthPubKey || !!wallabyUserId;
5083
+ if (!hasAccount) return [3 /*break*/, 3];
5030
5084
  return [4 /*yield*/, this.signIn({ password: password })];
5031
- case 3:
5032
- authentication = _c.sent();
5033
- return [3 /*break*/, 6];
5034
- case 4: return [4 /*yield*/, this.signUp({ password: password })];
5085
+ case 2:
5086
+ authentication = _d.sent();
5087
+ return [3 /*break*/, 5];
5088
+ case 3: return [4 /*yield*/, this.signUp({ password: password }).catch(function (error) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
5089
+ switch (_a.label) {
5090
+ case 0: return [4 /*yield*/, this.handleSignUpError(error, password)];
5091
+ case 1: return [2 /*return*/, _a.sent()];
5092
+ }
5093
+ }); }); })];
5094
+ case 4:
5095
+ authentication = _d.sent();
5096
+ _d.label = 5;
5035
5097
  case 5:
5036
- authentication = _c.sent();
5037
- wallabyAuthPubKey = authentication === null || authentication === void 0 ? void 0 : authentication.user.wallabyAuthPubKey;
5038
- wallabyAccessToken = authentication === null || authentication === void 0 ? void 0 : authentication.accessToken;
5039
- _c.label = 6;
5040
- case 6:
5041
5098
  if (!authentication) {
5042
- throw new Error('Authentication failed, please try again.');
5099
+ throw new Error('Authentication failed: Unable to sign in or sign up. Please check your credentials and try again.');
5043
5100
  }
5101
+ user = authentication.user, accessToken = authentication.accessToken;
5102
+ return [4 /*yield*/, this.device];
5103
+ case 6:
5104
+ (_d.sent()).credentials.wallabyPublicKey = user.wallabyAuthPubKey;
5105
+ return [4 /*yield*/, this.device];
5106
+ case 7:
5107
+ (_d.sent()).authTokens.accessToken = accessToken;
5044
5108
  return [2 /*return*/, authentication];
5045
5109
  }
5046
5110
  });
@@ -5120,7 +5184,7 @@ var Auth = /** @class */ (function (_super) {
5120
5184
  return __generator(this, function (_e) {
5121
5185
  switch (_e.label) {
5122
5186
  case 0:
5123
- _e.trys.push([0, 7, , 8]);
5187
+ _e.trys.push([0, 10, , 11]);
5124
5188
  return [4 /*yield*/, this.signatureMessage({ password: password })];
5125
5189
  case 1:
5126
5190
  signatureMessage = _e.sent();
@@ -5131,32 +5195,35 @@ var Auth = /** @class */ (function (_super) {
5131
5195
  })];
5132
5196
  case 2:
5133
5197
  response = _e.sent();
5134
- if (!response || response.error) {
5135
- throw new Error();
5136
- }
5198
+ if (!(!response || response.error || response.errorCode)) return [3 /*break*/, 5];
5199
+ if (!(response.errorCode === exports.ErrorResponseCodes.user_already_exists)) return [3 /*break*/, 4];
5200
+ return [4 /*yield*/, this.handleSignUpError(response, password)];
5201
+ case 3: return [2 /*return*/, _e.sent()];
5202
+ case 4: throw new Error();
5203
+ case 5:
5137
5204
  accessToken = response.accessToken, user = response.user;
5138
5205
  this.storageService.setAccessToken(accessToken);
5139
5206
  this.storageService.setWallabyAuthPubKey(user.wallabyAuthPubKey);
5140
5207
  this.storageService.setEncryptedPrivateKey(decryptedClientAuthPrivKey, password);
5141
5208
  return [4 /*yield*/, this.device];
5142
- case 3:
5209
+ case 6:
5143
5210
  (_e.sent()).authTokens.accessToken = accessToken;
5144
5211
  return [4 /*yield*/, this.device];
5145
- case 4:
5212
+ case 7:
5146
5213
  (_e.sent()).credentials.wallabyPublicKey = user.wallabyAuthPubKey;
5147
5214
  return [4 /*yield*/, this.device];
5148
- case 5:
5215
+ case 8:
5149
5216
  _c = (_e.sent());
5150
5217
  _d = [{}];
5151
5218
  return [4 /*yield*/, this.device];
5152
- case 6:
5219
+ case 9:
5153
5220
  _c.user = __assign.apply(void 0, [__assign.apply(void 0, _d.concat([(_e.sent()).user])), user]);
5154
5221
  return [2 /*return*/, response];
5155
- case 7:
5222
+ case 10:
5156
5223
  error_2 = _e.sent();
5157
5224
  logger.error('SDK::Auth::singUp::error', error_2);
5158
5225
  return [2 /*return*/, Promise.reject(error_2)];
5159
- case 8: return [2 /*return*/];
5226
+ case 11: return [2 /*return*/];
5160
5227
  }
5161
5228
  });
5162
5229
  });
@@ -5311,6 +5378,33 @@ var Auth = /** @class */ (function (_super) {
5311
5378
  });
5312
5379
  });
5313
5380
  };
5381
+ Auth.prototype.handleSignUpError = function (error, password) {
5382
+ return __awaiter(this, void 0, void 0, function () {
5383
+ var userAlreadyExists, signInError_1;
5384
+ var _a;
5385
+ return __generator(this, function (_b) {
5386
+ switch (_b.label) {
5387
+ case 0:
5388
+ userAlreadyExists = (error === null || error === void 0 ? void 0 : error.errorCode) === exports.ErrorResponseCodes.user_already_exists || ((_a = error === null || error === void 0 ? void 0 : error.message) === null || _a === void 0 ? void 0 : _a.toLowerCase().match(/user already exists/i));
5389
+ if (!userAlreadyExists) return [3 /*break*/, 5];
5390
+ _b.label = 1;
5391
+ case 1:
5392
+ _b.trys.push([1, 3, , 4]);
5393
+ return [4 /*yield*/, this.signIn({ password: password })];
5394
+ case 2: return [2 /*return*/, _b.sent()];
5395
+ case 3:
5396
+ signInError_1 = _b.sent();
5397
+ logger.error('SDK::Auth::handleSignUpError::secondAttemptToSignIn::error', signInError_1);
5398
+ throw signInError_1;
5399
+ case 4: return [3 /*break*/, 6];
5400
+ case 5:
5401
+ logger.error('SDK::Auth::handleSignUpError::error', error);
5402
+ throw error;
5403
+ case 6: return [2 /*return*/];
5404
+ }
5405
+ });
5406
+ });
5407
+ };
5314
5408
  return Auth;
5315
5409
  }(Base));
5316
5410
 
@@ -5500,12 +5594,12 @@ var Wallet = /** @class */ (function (_super) {
5500
5594
  Wallet.prototype.create = function (_a) {
5501
5595
  return __awaiter(this, arguments, void 0, function (_b) {
5502
5596
  var authentication, signatureMessage, wallabyAuthPubKey, message, signature, clientAuthPubKey, decryptedClientAuthPrivKey, response, decryptedSeedPhrase, encryptedSeedPhraseWithWallabyKey, mnemonicSeedPhrase, convertedEncryptedSeed, decryptedMnemonicSeedPhrase, error_5;
5503
- var password = _b.password;
5597
+ var password = _b.password, wallabyUserId = _b.wallabyUserId;
5504
5598
  return __generator(this, function (_c) {
5505
5599
  switch (_c.label) {
5506
5600
  case 0:
5507
5601
  _c.trys.push([0, 9, , 10]);
5508
- return [4 /*yield*/, this.auth.authenticate({ password: password })];
5602
+ return [4 /*yield*/, this.auth.authenticate({ password: password, wallabyUserId: wallabyUserId })];
5509
5603
  case 1:
5510
5604
  authentication = _c.sent();
5511
5605
  return [4 /*yield*/, this.auth.signatureMessage({ password: password })];
@@ -5647,7 +5741,7 @@ var Wallet = /** @class */ (function (_super) {
5647
5741
  return [2 /*return*/, __assign(__assign({}, response), { decryptedSeedPhrase: decryptedSeedPhrase, decryptedMnemonicSeedPhrase: decryptedMnemonicSeedPhrase })];
5648
5742
  case 10:
5649
5743
  error_6 = _c.sent();
5650
- logger.error('SDK::Wallet::create::error', error_6);
5744
+ logger.error('SDK::Wallet::createWithNewAccount::error', error_6);
5651
5745
  return [2 /*return*/, Promise.reject(error_6)];
5652
5746
  case 11: return [2 /*return*/];
5653
5747
  }
@@ -5660,18 +5754,19 @@ var Wallet = /** @class */ (function (_super) {
5660
5754
  * Import an existing wallet, returns asset list and encrypted seedPhrase
5661
5755
  * @param {string} password The user's chosen password
5662
5756
  * @param {string} seedPhrase The user's seed phrase
5757
+ * @param {string} [wallabyUserId] The user's wallaby user ID if available
5663
5758
  * @returns {ImportWalletResponse} The wallet has been imported successfully
5664
5759
  * The return includes the wallet, wallet assets, and the encrypted seedphrase
5665
5760
  */
5666
5761
  Wallet.prototype.import = function (_a) {
5667
5762
  return __awaiter(this, arguments, void 0, function (_b) {
5668
5763
  var authentication, signatureMessage, message, signature, clientAuthPubKey, encryptedSeedphraseWithWallabyKey, response, error_7;
5669
- var password = _b.password, seedPhrase = _b.seedPhrase;
5764
+ var password = _b.password, seedPhrase = _b.seedPhrase, wallabyUserId = _b.wallabyUserId;
5670
5765
  return __generator(this, function (_c) {
5671
5766
  switch (_c.label) {
5672
5767
  case 0:
5673
5768
  _c.trys.push([0, 6, , 7]);
5674
- return [4 /*yield*/, this.auth.authenticate({ password: password })];
5769
+ return [4 /*yield*/, this.auth.authenticate({ password: password, wallabyUserId: wallabyUserId })];
5675
5770
  case 1:
5676
5771
  authentication = _c.sent();
5677
5772
  return [4 /*yield*/, this.auth.signatureMessage({ password: password })];
@@ -5709,7 +5804,7 @@ var Wallet = /** @class */ (function (_super) {
5709
5804
  return [2 /*return*/, response];
5710
5805
  case 6:
5711
5806
  error_7 = _c.sent();
5712
- logger.error('SDK::Wallet::create::error', error_7);
5807
+ logger.error('SDK::Wallet::import::error', error_7);
5713
5808
  return [2 /*return*/, Promise.reject(error_7)];
5714
5809
  case 7: return [2 /*return*/];
5715
5810
  }