wallaby-cash 1.7.25 → 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 +49 -41
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +49 -41
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +49 -41
- package/dist/index.js.map +1 -1
- package/dist/types/auth.d.ts +2 -0
- package/package.json +2 -1
package/dist/index.cjs.js
CHANGED
|
@@ -4750,11 +4750,11 @@ var Base = /** @class */ (function () {
|
|
|
4750
4750
|
Base.prototype.request = function (route, options) {
|
|
4751
4751
|
return __awaiter(this, void 0, void 0, function () {
|
|
4752
4752
|
var url, headers, http, _a, result, error_1, result, error_2, result, error_3, result, error_4, error_5;
|
|
4753
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
4754
|
-
return __generator(this, function (
|
|
4755
|
-
switch (
|
|
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) {
|
|
4756
4756
|
case 0:
|
|
4757
|
-
|
|
4757
|
+
_q.trys.push([0, 16, , 17]);
|
|
4758
4758
|
url = void 0;
|
|
4759
4759
|
if (typeof route.fullPath !== 'string') {
|
|
4760
4760
|
url = route.fullPath(options === null || options === void 0 ? void 0 : options.payload);
|
|
@@ -4767,7 +4767,7 @@ var Base = /** @class */ (function () {
|
|
|
4767
4767
|
}
|
|
4768
4768
|
return [4 /*yield*/, this.getRequestHeaders(route.requiresAccessToken)];
|
|
4769
4769
|
case 1:
|
|
4770
|
-
headers =
|
|
4770
|
+
headers = _q.sent();
|
|
4771
4771
|
if ((_b = this.options) === null || _b === void 0 ? void 0 : _b.headers) {
|
|
4772
4772
|
headers = __assign(__assign({}, headers), this.options.headers);
|
|
4773
4773
|
}
|
|
@@ -4777,10 +4777,12 @@ var Base = /** @class */ (function () {
|
|
|
4777
4777
|
headers: headers,
|
|
4778
4778
|
});
|
|
4779
4779
|
http.interceptors.response.use(function (response) { return response; }, function (error) {
|
|
4780
|
-
var _a, _b, _c;
|
|
4780
|
+
var _a, _b, _c, _d, _e;
|
|
4781
4781
|
if ((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data) {
|
|
4782
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);
|
|
4783
|
-
|
|
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
|
+
}
|
|
4784
4786
|
}
|
|
4785
4787
|
logger.error('SDK::Base::Interceptor::error', error);
|
|
4786
4788
|
return Promise.reject(error);
|
|
@@ -4794,63 +4796,66 @@ var Base = /** @class */ (function () {
|
|
|
4794
4796
|
}
|
|
4795
4797
|
return [3 /*break*/, 14];
|
|
4796
4798
|
case 2:
|
|
4797
|
-
|
|
4799
|
+
_q.trys.push([2, 4, , 5]);
|
|
4798
4800
|
return [4 /*yield*/, http.get(url)];
|
|
4799
4801
|
case 3:
|
|
4800
|
-
result =
|
|
4802
|
+
result = _q.sent();
|
|
4801
4803
|
logger.info('SDK::Base::RequestMethod.Get::result', result);
|
|
4802
4804
|
return [2 /*return*/, result === null || result === void 0 ? void 0 : result.data];
|
|
4803
4805
|
case 4:
|
|
4804
|
-
error_1 =
|
|
4806
|
+
error_1 = _q.sent();
|
|
4805
4807
|
if (error_1 instanceof axios.AxiosError) {
|
|
4806
|
-
logger.error('SDK::Base::RequestMethod.Get::
|
|
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);
|
|
4807
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)];
|
|
4808
4810
|
}
|
|
4809
4811
|
return [2 /*return*/, Promise.reject(error_1 === null || error_1 === void 0 ? void 0 : error_1.message)];
|
|
4810
4812
|
case 5:
|
|
4811
|
-
|
|
4813
|
+
_q.trys.push([5, 7, , 8]);
|
|
4812
4814
|
return [4 /*yield*/, http.post(url, JSON.stringify(options === null || options === void 0 ? void 0 : options.payload))];
|
|
4813
4815
|
case 6:
|
|
4814
|
-
result =
|
|
4816
|
+
result = _q.sent();
|
|
4815
4817
|
logger.info('SDK::Base::RequestMethod.Post::result', result);
|
|
4816
4818
|
return [2 /*return*/, result === null || result === void 0 ? void 0 : result.data];
|
|
4817
4819
|
case 7:
|
|
4818
|
-
error_2 =
|
|
4820
|
+
error_2 = _q.sent();
|
|
4819
4821
|
if (error_2 instanceof axios.AxiosError) {
|
|
4820
|
-
logger.error('SDK::Base::RequestMethod.Post::
|
|
4821
|
-
|
|
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)];
|
|
4822
4827
|
}
|
|
4823
4828
|
return [2 /*return*/, Promise.reject(error_2 === null || error_2 === void 0 ? void 0 : error_2.message)];
|
|
4824
4829
|
case 8:
|
|
4825
|
-
|
|
4826
|
-
return [4 /*yield*/, http.put(url, (
|
|
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)];
|
|
4827
4832
|
case 9:
|
|
4828
|
-
result =
|
|
4833
|
+
result = _q.sent();
|
|
4829
4834
|
return [2 /*return*/, result === null || result === void 0 ? void 0 : result.data];
|
|
4830
4835
|
case 10:
|
|
4831
|
-
error_3 =
|
|
4836
|
+
error_3 = _q.sent();
|
|
4832
4837
|
if (error_3 instanceof axios.AxiosError) {
|
|
4833
|
-
logger.error('SDK::Base::RequestMethod.Put::error', (
|
|
4834
|
-
return [2 /*return*/, Promise.reject((
|
|
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)];
|
|
4835
4840
|
}
|
|
4836
4841
|
return [2 /*return*/, Promise.reject(error_3 === null || error_3 === void 0 ? void 0 : error_3.message)];
|
|
4837
4842
|
case 11:
|
|
4838
|
-
|
|
4843
|
+
_q.trys.push([11, 13, , 14]);
|
|
4839
4844
|
return [4 /*yield*/, http.delete(url)];
|
|
4840
4845
|
case 12:
|
|
4841
|
-
result =
|
|
4846
|
+
result = _q.sent();
|
|
4842
4847
|
return [2 /*return*/, result === null || result === void 0 ? void 0 : result.data];
|
|
4843
4848
|
case 13:
|
|
4844
|
-
error_4 =
|
|
4849
|
+
error_4 = _q.sent();
|
|
4845
4850
|
if (error_4 instanceof axios.AxiosError) {
|
|
4846
|
-
logger.error('SDK::Base::RequestMethod.Put::
|
|
4847
|
-
return [2 /*return*/, Promise.reject((
|
|
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)];
|
|
4848
4853
|
}
|
|
4849
4854
|
return [2 /*return*/, Promise.reject(error_4 === null || error_4 === void 0 ? void 0 : error_4.message)];
|
|
4850
4855
|
case 14: throw new Error('Request method is not supported');
|
|
4851
4856
|
case 15: return [3 /*break*/, 17];
|
|
4852
4857
|
case 16:
|
|
4853
|
-
error_5 =
|
|
4858
|
+
error_5 = _q.sent();
|
|
4854
4859
|
logger.error('SDK::Base::request::error', error_5);
|
|
4855
4860
|
return [2 /*return*/, Promise.reject(error_5)];
|
|
4856
4861
|
case 17: return [2 /*return*/];
|
|
@@ -5179,7 +5184,7 @@ var Auth = /** @class */ (function (_super) {
|
|
|
5179
5184
|
return __generator(this, function (_e) {
|
|
5180
5185
|
switch (_e.label) {
|
|
5181
5186
|
case 0:
|
|
5182
|
-
_e.trys.push([0,
|
|
5187
|
+
_e.trys.push([0, 10, , 11]);
|
|
5183
5188
|
return [4 /*yield*/, this.signatureMessage({ password: password })];
|
|
5184
5189
|
case 1:
|
|
5185
5190
|
signatureMessage = _e.sent();
|
|
@@ -5190,32 +5195,35 @@ var Auth = /** @class */ (function (_super) {
|
|
|
5190
5195
|
})];
|
|
5191
5196
|
case 2:
|
|
5192
5197
|
response = _e.sent();
|
|
5193
|
-
if (!response || response.error)
|
|
5194
|
-
|
|
5195
|
-
|
|
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:
|
|
5196
5204
|
accessToken = response.accessToken, user = response.user;
|
|
5197
5205
|
this.storageService.setAccessToken(accessToken);
|
|
5198
5206
|
this.storageService.setWallabyAuthPubKey(user.wallabyAuthPubKey);
|
|
5199
5207
|
this.storageService.setEncryptedPrivateKey(decryptedClientAuthPrivKey, password);
|
|
5200
5208
|
return [4 /*yield*/, this.device];
|
|
5201
|
-
case
|
|
5209
|
+
case 6:
|
|
5202
5210
|
(_e.sent()).authTokens.accessToken = accessToken;
|
|
5203
5211
|
return [4 /*yield*/, this.device];
|
|
5204
|
-
case
|
|
5212
|
+
case 7:
|
|
5205
5213
|
(_e.sent()).credentials.wallabyPublicKey = user.wallabyAuthPubKey;
|
|
5206
5214
|
return [4 /*yield*/, this.device];
|
|
5207
|
-
case
|
|
5215
|
+
case 8:
|
|
5208
5216
|
_c = (_e.sent());
|
|
5209
5217
|
_d = [{}];
|
|
5210
5218
|
return [4 /*yield*/, this.device];
|
|
5211
|
-
case
|
|
5219
|
+
case 9:
|
|
5212
5220
|
_c.user = __assign.apply(void 0, [__assign.apply(void 0, _d.concat([(_e.sent()).user])), user]);
|
|
5213
5221
|
return [2 /*return*/, response];
|
|
5214
|
-
case
|
|
5222
|
+
case 10:
|
|
5215
5223
|
error_2 = _e.sent();
|
|
5216
5224
|
logger.error('SDK::Auth::singUp::error', error_2);
|
|
5217
5225
|
return [2 /*return*/, Promise.reject(error_2)];
|
|
5218
|
-
case
|
|
5226
|
+
case 11: return [2 /*return*/];
|
|
5219
5227
|
}
|
|
5220
5228
|
});
|
|
5221
5229
|
});
|
|
@@ -5377,7 +5385,7 @@ var Auth = /** @class */ (function (_super) {
|
|
|
5377
5385
|
return __generator(this, function (_b) {
|
|
5378
5386
|
switch (_b.label) {
|
|
5379
5387
|
case 0:
|
|
5380
|
-
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.match(/
|
|
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));
|
|
5381
5389
|
if (!userAlreadyExists) return [3 /*break*/, 5];
|
|
5382
5390
|
_b.label = 1;
|
|
5383
5391
|
case 1:
|
|
@@ -5733,7 +5741,7 @@ var Wallet = /** @class */ (function (_super) {
|
|
|
5733
5741
|
return [2 /*return*/, __assign(__assign({}, response), { decryptedSeedPhrase: decryptedSeedPhrase, decryptedMnemonicSeedPhrase: decryptedMnemonicSeedPhrase })];
|
|
5734
5742
|
case 10:
|
|
5735
5743
|
error_6 = _c.sent();
|
|
5736
|
-
logger.error('SDK::Wallet::
|
|
5744
|
+
logger.error('SDK::Wallet::createWithNewAccount::error', error_6);
|
|
5737
5745
|
return [2 /*return*/, Promise.reject(error_6)];
|
|
5738
5746
|
case 11: return [2 /*return*/];
|
|
5739
5747
|
}
|
|
@@ -5796,7 +5804,7 @@ var Wallet = /** @class */ (function (_super) {
|
|
|
5796
5804
|
return [2 /*return*/, response];
|
|
5797
5805
|
case 6:
|
|
5798
5806
|
error_7 = _c.sent();
|
|
5799
|
-
logger.error('SDK::Wallet::
|
|
5807
|
+
logger.error('SDK::Wallet::import::error', error_7);
|
|
5800
5808
|
return [2 /*return*/, Promise.reject(error_7)];
|
|
5801
5809
|
case 7: return [2 /*return*/];
|
|
5802
5810
|
}
|