wallaby-cash 2.0.1-rc.92 → 2.0.1

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/README.md CHANGED
@@ -10,6 +10,7 @@ The SDK leverages Wallaby API as a gateway to web3 and the blockchain.
10
10
  The SDK currently supports the following blockchains:
11
11
 
12
12
  - Algorand
13
+ - Aptos
13
14
  - Avalanche
14
15
  - Base
15
16
  - Binance chain
@@ -17,11 +18,12 @@ The SDK currently supports the following blockchains:
17
18
  - Bsc
18
19
  - Canton
19
20
  - Ethereum
20
- - Polygon
21
- - Sui
21
+ - Hedera
22
22
  - Injective
23
+ - Polygon
24
+ - Polymesh
23
25
  - Sei
24
- - Aptos
26
+ - Sui
25
27
 
26
28
  ## Install the SDK
27
29
 
package/dist/base.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { WallabyConfig, RequestOptions, RequestRoute, WallabyConfigOptions, AuthType } from './types';
1
+ import { WallabyConfig, RequestOptions, RequestRoute, WallabyConfigOptions } from './types';
2
2
  import { StorageService } from './lib/utils/storage.service';
3
3
  import { LocalStorage } from './types/storage';
4
4
  import { LockManagerService } from './helpers/lock-manager.service';
@@ -3338,7 +3338,7 @@ export interface Transaction {
3338
3338
  /** Transaction Gas Price */
3339
3339
  gasPrice: number;
3340
3340
  /** Transaction hash after broadcasting */
3341
- hash: string;
3341
+ hash?: string | null;
3342
3342
  merchant: Merchant;
3343
3343
  /**
3344
3344
  * Merchant ID
@@ -3446,7 +3446,7 @@ export interface TransactionResponse {
3446
3446
  /** Transaction Gas Price */
3447
3447
  gasPrice: number;
3448
3448
  /** Transaction hash after broadcasting */
3449
- hash: string;
3449
+ hash?: string | null;
3450
3450
  merchant: Merchant;
3451
3451
  /**
3452
3452
  * Merchant ID
@@ -4685,6 +4685,11 @@ export interface UserDto {
4685
4685
  * @example "6e464058-67c1-4273-a6a4-8aae522e34be"
4686
4686
  */
4687
4687
  merchantId?: string;
4688
+ /**
4689
+ * User's Polymesh identity
4690
+ * @example "0x73ecca5cf1ecaa365a7d1f1e5dbc91737c73fe0a96b41386f574dfb915a913a7"
4691
+ */
4692
+ polymeshDID: string;
4688
4693
  /** @example "wallet_user" */
4689
4694
  role: "super_admin" | "merchant_admin" | "merchant_user" | "wallet_user" | "contract_admin" | "reserve_admin" | "wallets_admin" | "transfer_admin" | "soft_burn_admin" | "mint_admin" | "automation_admin";
4690
4695
  /**
package/dist/index.cjs.js CHANGED
@@ -157,20 +157,23 @@ exports.BlockchainSlip44 = void 0;
157
157
  BlockchainSlip44[BlockchainSlip44["INJ"] = 2525] = "INJ";
158
158
  BlockchainSlip44[BlockchainSlip44["SEI"] = 19000118] = "SEI";
159
159
  BlockchainSlip44[BlockchainSlip44["APT"] = 637] = "APT";
160
+ BlockchainSlip44[BlockchainSlip44["HBAR"] = 3030] = "HBAR";
161
+ BlockchainSlip44[BlockchainSlip44["POLYX"] = 595] = "POLYX";
160
162
  })(exports.BlockchainSlip44 || (exports.BlockchainSlip44 = {}));
161
163
  exports.BlockchainName = void 0;
162
164
  (function (BlockchainName) {
163
165
  BlockchainName["Algorand"] = "ALGORAND";
164
166
  BlockchainName["Aptos"] = "APTOS";
165
167
  BlockchainName["Avalanche"] = "AVALANCHE";
168
+ BlockchainName["Base"] = "BASE";
166
169
  BlockchainName["Bitcoin"] = "BITCOIN";
170
+ BlockchainName["Bsc"] = "BSC";
167
171
  BlockchainName["Canton"] = "CANTON";
168
172
  BlockchainName["Ethereum"] = "ETHEREUM";
173
+ BlockchainName["Hedera"] = "HEDERA";
169
174
  BlockchainName["Injective"] = "INJECTIVE";
170
175
  BlockchainName["Polygon"] = "POLYGON";
171
176
  BlockchainName["Polymesh"] = "POLYMESH";
172
- BlockchainName["Bsc"] = "BSC";
173
- BlockchainName["Base"] = "BASE";
174
177
  BlockchainName["Sei"] = "SEI";
175
178
  BlockchainName["Sui"] = "SUI";
176
179
  })(exports.BlockchainName || (exports.BlockchainName = {}));
@@ -206,6 +209,26 @@ exports.SeedPhraseType = void 0;
206
209
  SeedPhraseType["Standard"] = "standard";
207
210
  SeedPhraseType["Algorand"] = "algorand";
208
211
  })(exports.SeedPhraseType || (exports.SeedPhraseType = {}));
212
+ exports.WalletAddressTypeName = void 0;
213
+ (function (WalletAddressTypeName) {
214
+ WalletAddressTypeName["BTC_MAINNET_SEGWIT"] = "BTC:MAINNET:SEGWIT";
215
+ WalletAddressTypeName["BTC_MAINNET_LEGACY"] = "BTC:MAINNET:LEGACY";
216
+ WalletAddressTypeName["BTC_TESTNET_SEGWIT"] = "BTC:TESTNET:SEGWIT";
217
+ WalletAddressTypeName["BTC_TESTNET_LEGACY"] = "BTC:TESTNET:LEGACY";
218
+ WalletAddressTypeName["ETH"] = "ETH:ALL:DEFAULT";
219
+ WalletAddressTypeName["ALGO"] = "ALGO:ALL:DEFAULT";
220
+ WalletAddressTypeName["SUI"] = "SUI:ALL:DEFAULT";
221
+ WalletAddressTypeName["INJ"] = "INJ:ALL:DEFAULT";
222
+ WalletAddressTypeName["APT"] = "APT:ALL:DEFAULT";
223
+ WalletAddressTypeName["POLYX"] = "POLYX:ALL:DEFAULT";
224
+ WalletAddressTypeName["BSC"] = "BSC:ALL:DEFAULT";
225
+ WalletAddressTypeName["AVAX"] = "AVAX:ALL:DEFAULT";
226
+ WalletAddressTypeName["MATIC"] = "MATIC:ALL:DEFAULT";
227
+ WalletAddressTypeName["BASE"] = "BASE:ALL:DEFAULT";
228
+ WalletAddressTypeName["SEI"] = "SEI:ALL:DEFAULT";
229
+ WalletAddressTypeName["HBAR"] = "HBAR:ALL:DEFAULT";
230
+ WalletAddressTypeName["CC"] = "CC:ALL:DEFAULT";
231
+ })(exports.WalletAddressTypeName || (exports.WalletAddressTypeName = {}));
209
232
  exports.ReturnWalletOption = void 0;
210
233
  (function (ReturnWalletOption) {
211
234
  ReturnWalletOption["ReturnOnlyEncryptedShares"] = "RETURN_ONLY_ENCRYPTED_SHARES";
@@ -6938,10 +6961,10 @@ class Base {
6938
6961
  }
6939
6962
  this.clientAuthToken = token;
6940
6963
  if (userIsMfaVerified(token)) {
6941
- this.deviceAuthType = exports.AuthType.Password;
6964
+ this.deviceAuthType = AuthType.Password;
6942
6965
  }
6943
6966
  else {
6944
- this.deviceAuthType = exports.AuthType.Passkey;
6967
+ this.deviceAuthType = AuthType.Passkey;
6945
6968
  }
6946
6969
  }
6947
6970
  /**
@@ -6995,7 +7018,7 @@ class Base {
6995
7018
  * @returns Promise of <T> where T is the type of the response.
6996
7019
  */
6997
7020
  async request(route, options) {
6998
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
7021
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
6999
7022
  try {
7000
7023
  let url;
7001
7024
  if (typeof route.fullPath !== 'string') {
@@ -7017,8 +7040,15 @@ class Base {
7017
7040
  headers,
7018
7041
  });
7019
7042
  http.interceptors.response.use((response) => response, (error) => {
7020
- var _a;
7021
- return Promise.reject((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data);
7043
+ var _a, _b, _c, _d, _e;
7044
+ if ((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data) {
7045
+ 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);
7046
+ 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) {
7047
+ return Promise.reject((_e = error === null || error === void 0 ? void 0 : error.response) === null || _e === void 0 ? void 0 : _e.data);
7048
+ }
7049
+ }
7050
+ logger.error('SDK::Base::Interceptor::error', error);
7051
+ return Promise.reject(error);
7022
7052
  });
7023
7053
  switch (route.method) {
7024
7054
  case exports.RequestMethod.Get:
@@ -7029,7 +7059,7 @@ class Base {
7029
7059
  }
7030
7060
  catch (error) {
7031
7061
  if (error instanceof axios.AxiosError) {
7032
- logger.error('SDK::Base::RequestMethod.Get::AxiosError', (_b = error.response) === null || _b === void 0 ? void 0 : _b.data);
7062
+ logger.error('SDK::Base::RequestMethod.Get::AxiosError', (_b = error === null || error === void 0 ? void 0 : error.response) === null || _b === void 0 ? void 0 : _b.data);
7033
7063
  return Promise.reject((_c = error.response) === null || _c === void 0 ? void 0 : _c.data);
7034
7064
  }
7035
7065
  return Promise.reject(error === null || error === void 0 ? void 0 : error.message);
@@ -7042,8 +7072,11 @@ class Base {
7042
7072
  }
7043
7073
  catch (error) {
7044
7074
  if (error instanceof axios.AxiosError) {
7045
- logger.error('SDK::Base::RequestMethod.Post::AxiosError', (_d = error.response) === null || _d === void 0 ? void 0 : _d.data);
7046
- if (((_e = error.response) === null || _e === void 0 ? void 0 : _e.data.errorCode) && error.response.data.errorCode === exports.ErrorResponseCodes.user_already_exists) {
7075
+ logger.error('SDK::Base::RequestMethod.Post::AxiosError', (_d = error === null || error === void 0 ? void 0 : error.response) === null || _d === void 0 ? void 0 : _d.data);
7076
+ if (((_e = error === null || error === void 0 ? void 0 : error.response) === null || _e === void 0 ? void 0 : _e.data.errorCode) && ((_f = error === null || error === void 0 ? void 0 : error.response) === null || _f === void 0 ? void 0 : _f.data.errorCode) === exports.ErrorResponseCodes.user_already_exists) {
7077
+ return (_g = error === null || error === void 0 ? void 0 : error.response) === null || _g === void 0 ? void 0 : _g.data;
7078
+ }
7079
+ if (((_h = error.response) === null || _h === void 0 ? void 0 : _h.data.errorCode) && error.response.data.errorCode === exports.ErrorResponseCodes.user_already_exists) {
7047
7080
  return error.response.data;
7048
7081
  }
7049
7082
  return Promise.reject(error.message);
@@ -7059,8 +7092,8 @@ class Base {
7059
7092
  }
7060
7093
  catch (error) {
7061
7094
  if (error instanceof axios.AxiosError) {
7062
- logger.error('SDK::Base::RequestMethod.Put::error', (_f = error.response) === null || _f === void 0 ? void 0 : _f.data);
7063
- return Promise.reject((_g = error.response) === null || _g === void 0 ? void 0 : _g.data);
7095
+ logger.error('SDK::Base::RequestMethod.Put::error', (_j = error.response) === null || _j === void 0 ? void 0 : _j.data);
7096
+ return Promise.reject((_k = error.response) === null || _k === void 0 ? void 0 : _k.data);
7064
7097
  }
7065
7098
  return Promise.reject(error === null || error === void 0 ? void 0 : error.message);
7066
7099
  }
@@ -7072,8 +7105,8 @@ class Base {
7072
7105
  }
7073
7106
  catch (error) {
7074
7107
  if (error instanceof axios.AxiosError) {
7075
- logger.error('SDK::Base::RequestMethod.Put::AxiosError', (_h = error.response) === null || _h === void 0 ? void 0 : _h.data);
7076
- return Promise.reject((_j = error.response) === null || _j === void 0 ? void 0 : _j.data);
7108
+ logger.error('SDK::Base::RequestMethod.Put::AxiosError', (_l = error === null || error === void 0 ? void 0 : error.response) === null || _l === void 0 ? void 0 : _l.data);
7109
+ return Promise.reject((_m = error.response) === null || _m === void 0 ? void 0 : _m.data);
7077
7110
  }
7078
7111
  return Promise.reject(error === null || error === void 0 ? void 0 : error.message);
7079
7112
  }
@@ -8394,6 +8427,14 @@ class AuthService extends Base {
8394
8427
  message: 'Password must be at least 8 characters long',
8395
8428
  };
8396
8429
  }
8430
+ // Check if password contains at least 1 number
8431
+ const hasNumber = /\d/.test(password);
8432
+ if (!hasNumber) {
8433
+ return {
8434
+ valid: false,
8435
+ message: 'Password must contain at least 1 number',
8436
+ };
8437
+ }
8397
8438
  // Check maximum length (128 characters) to avoid DDoS attacks
8398
8439
  if (password.length > 128) {
8399
8440
  return {
@@ -9958,34 +9999,12 @@ class WalletDataService extends Base {
9958
9999
  }
9959
10000
  /**
9960
10001
  * @description Validates the wallet address info for a given blockchain.
9961
- * @param { WalletAddressInfo } walletAddressInfo The wallet address info object containing addresses for different blockchains.
10002
+ * @param { WalletAddressesInfoEntry } walletAddressesInfo The wallet address info array containing addresses for different blockchains.
9962
10003
  * @param { BlockchainName } blockchainName The name of the blockchain to validate against.
9963
10004
  * @returns { boolean } Returns true if the wallet address info is valid for the given blockchain, otherwise throws an error.
9964
10005
  */
9965
- validateWalletAddressInfo(walletAddressInfo, blockchainName) {
9966
- switch (blockchainName) {
9967
- case exports.BlockchainName.Avalanche:
9968
- case exports.BlockchainName.Ethereum:
9969
- case exports.BlockchainName.Bsc:
9970
- case exports.BlockchainName.Base:
9971
- case exports.BlockchainName.Polygon:
9972
- // return !!walletAddressInfo.evmAddress && isEvmAddress(walletAddressInfo.evmAddress);
9973
- return !!walletAddressInfo.evmAddress;
9974
- case exports.BlockchainName.Bitcoin:
9975
- // return !!walletAddressInfo.btcAddress && isBtcAddress(walletAddressInfo.btcAddress);
9976
- return !!walletAddressInfo.btcAddress;
9977
- case exports.BlockchainName.Algorand:
9978
- // return !!walletAddressInfo.algoAddress && isAlgoAddress(walletAddressInfo.algoAddress);
9979
- return !!walletAddressInfo.algoAddress;
9980
- case exports.BlockchainName.Sui:
9981
- // return !!walletAddressInfo.suiAddress && isSUIAddress(walletAddressInfo.suiAddress);
9982
- return !!walletAddressInfo.suiAddress;
9983
- case exports.BlockchainName.Injective:
9984
- // return !!walletAddressInfo.injAddress && isInjectiveAddress(walletAddressInfo.injAddress);
9985
- return !!walletAddressInfo.injAddress;
9986
- default:
9987
- throw new Error(`Unsupported blockchain: ${blockchainName}`);
9988
- }
10006
+ validateWalletAddressInfo(walletAddressesInfo, blockchainName) {
10007
+ return walletAddressesInfo.some((address) => address.chainName === blockchainName);
9989
10008
  }
9990
10009
  /**
9991
10010
  *
@@ -10047,7 +10066,7 @@ class WalletDataService extends Base {
10047
10066
  * @public
10048
10067
  * Fetches the balances for all tokens in a specific wallet.
10049
10068
  * @param { string } walletId Wallet address
10050
- * @returns { TokenBalanceResponse[] } Returns an array of the requested tokens balances.
10069
+ * @returns { TokenBalanceResponse } Returns an object containing the requested tokens balances.
10051
10070
  */
10052
10071
  async getWalletBalances({ walletId }) {
10053
10072
  try {
@@ -10201,7 +10220,7 @@ class WalletDataService extends Base {
10201
10220
  walletId: input.walletId,
10202
10221
  authenticationOptions: input.authenticationOptions,
10203
10222
  });
10204
- const addressInfoIsPresentForBlockchain = this.validateWalletAddressInfo(addressInfo.walletAddressInfo, blockchainName);
10223
+ const addressInfoIsPresentForBlockchain = this.validateWalletAddressInfo(addressInfo.walletAddressesInfo, blockchainName);
10205
10224
  if (addressInfoIsPresentForBlockchain) {
10206
10225
  const response = await this.addTokenToWallet({
10207
10226
  assetConfigId: assetConfigId,