wallaby-cash 2.0.1 → 2.0.3

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.esm.js CHANGED
@@ -213,11 +213,11 @@ var WalletOwnershipType;
213
213
  WalletOwnershipType["MultiOwner"] = "MULTI_OWNER";
214
214
  })(WalletOwnershipType || (WalletOwnershipType = {}));
215
215
 
216
- var AuthType$1;
216
+ var AuthType;
217
217
  (function (AuthType) {
218
218
  AuthType["Password"] = "password";
219
219
  AuthType["Passkey"] = "passkey";
220
- })(AuthType$1 || (AuthType$1 = {}));
220
+ })(AuthType || (AuthType = {}));
221
221
 
222
222
  /** Most react native storage engines are async.
223
223
  * Explicitly setting these types will make it compatible with Expo Secure Store and React Native Async
@@ -4718,7 +4718,7 @@ class Cipher {
4718
4718
  try {
4719
4719
  let derivedKeyPair;
4720
4720
  switch (options.authType) {
4721
- case AuthType$1.Password:
4721
+ case AuthType.Password:
4722
4722
  if (!options.password || !options.salt) {
4723
4723
  throw new Error('Password and salt are required');
4724
4724
  }
@@ -4727,7 +4727,7 @@ class Cipher {
4727
4727
  salt: options.salt,
4728
4728
  });
4729
4729
  return derivedKeyPair;
4730
- case AuthType$1.Passkey:
4730
+ case AuthType.Passkey:
4731
4731
  if (!options.prfValue) {
4732
4732
  throw new Error('PRF value is required');
4733
4733
  }
@@ -6990,7 +6990,7 @@ class Base {
6990
6990
  * @returns Promise of <T> where T is the type of the response.
6991
6991
  */
6992
6992
  async request(route, options) {
6993
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
6993
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
6994
6994
  try {
6995
6995
  let url;
6996
6996
  if (typeof route.fullPath !== 'string') {
@@ -7031,7 +7031,7 @@ class Base {
7031
7031
  }
7032
7032
  catch (error) {
7033
7033
  if (error instanceof AxiosError) {
7034
- 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);
7034
+ logger.error('SDK::Base::RequestMethod.Get::AxiosError', (_b = error.response) === null || _b === void 0 ? void 0 : _b.data);
7035
7035
  return Promise.reject((_c = error.response) === null || _c === void 0 ? void 0 : _c.data);
7036
7036
  }
7037
7037
  return Promise.reject(error === null || error === void 0 ? void 0 : error.message);
@@ -7044,11 +7044,8 @@ class Base {
7044
7044
  }
7045
7045
  catch (error) {
7046
7046
  if (error instanceof AxiosError) {
7047
- 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);
7048
- 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) === ErrorResponseCodes.user_already_exists) {
7049
- return (_g = error === null || error === void 0 ? void 0 : error.response) === null || _g === void 0 ? void 0 : _g.data;
7050
- }
7051
- if (((_h = error.response) === null || _h === void 0 ? void 0 : _h.data.errorCode) && error.response.data.errorCode === ErrorResponseCodes.user_already_exists) {
7047
+ logger.error('SDK::Base::RequestMethod.Post::AxiosError', (_d = error.response) === null || _d === void 0 ? void 0 : _d.data);
7048
+ if (((_e = error.response) === null || _e === void 0 ? void 0 : _e.data.errorCode) && error.response.data.errorCode === ErrorResponseCodes.user_already_exists) {
7052
7049
  return error.response.data;
7053
7050
  }
7054
7051
  return Promise.reject(error.message);
@@ -7064,8 +7061,8 @@ class Base {
7064
7061
  }
7065
7062
  catch (error) {
7066
7063
  if (error instanceof AxiosError) {
7067
- logger.error('SDK::Base::RequestMethod.Put::error', (_j = error.response) === null || _j === void 0 ? void 0 : _j.data);
7068
- return Promise.reject((_k = error.response) === null || _k === void 0 ? void 0 : _k.data);
7064
+ logger.error('SDK::Base::RequestMethod.Put::error', (_f = error.response) === null || _f === void 0 ? void 0 : _f.data);
7065
+ return Promise.reject((_g = error.response) === null || _g === void 0 ? void 0 : _g.data);
7069
7066
  }
7070
7067
  return Promise.reject(error === null || error === void 0 ? void 0 : error.message);
7071
7068
  }
@@ -7077,8 +7074,8 @@ class Base {
7077
7074
  }
7078
7075
  catch (error) {
7079
7076
  if (error instanceof AxiosError) {
7080
- 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);
7081
- return Promise.reject((_m = error.response) === null || _m === void 0 ? void 0 : _m.data);
7077
+ logger.error('SDK::Base::RequestMethod.Put::AxiosError', (_h = error.response) === null || _h === void 0 ? void 0 : _h.data);
7078
+ return Promise.reject((_j = error.response) === null || _j === void 0 ? void 0 : _j.data);
7082
7079
  }
7083
7080
  return Promise.reject(error === null || error === void 0 ? void 0 : error.message);
7084
7081
  }
@@ -7823,7 +7820,7 @@ class PasskeyService {
7823
7820
  logger.debug('SDK::PasskeyService::handleCredentialsCreationFromPrfExtension::prfValue', !!prfValue);
7824
7821
  const credentialsKeyPair = await this.cipher.getCredentialsKeyPair({
7825
7822
  prfValue,
7826
- authType: AuthType$1.Passkey,
7823
+ authType: AuthType.Passkey,
7827
7824
  });
7828
7825
  console.log('SDK::PasskeyService::handleCredentialsCreationFromPrfExtension::credentials key pair was created', !!credentialsKeyPair);
7829
7826
  return Object.assign(Object.assign({}, credentialsKeyPair), { prfValue });
@@ -7894,7 +7891,7 @@ class AuthService extends Base {
7894
7891
  throw new Error('V2 Private key was not found');
7895
7892
  }
7896
7893
  const credentialsKeyPair = await this.cipher.getCredentialsKeyPair({
7897
- authType: AuthType$1.Password,
7894
+ authType: AuthType.Password,
7898
7895
  password,
7899
7896
  salt: clientSalt,
7900
7897
  });
@@ -7997,14 +7994,14 @@ class AuthService extends Base {
7997
7994
  const signatureMessageResponse = await this.getSignature(deviceKeyPair, PasskeyChallengeType.REGISTRATION);
7998
7995
  logger.info('signature has been generated', !!signatureMessageResponse);
7999
7996
  switch (this.deviceAuthType) {
8000
- case AuthType$1.Passkey:
7997
+ case AuthType.Passkey:
8001
7998
  logger.info('registering a new passkey');
8002
7999
  authentication = await this.passkeyService.register({
8003
8000
  deviceKeyPair,
8004
8001
  challengeResponse: signatureMessageResponse,
8005
8002
  });
8006
8003
  break;
8007
- case AuthType$1.Password:
8004
+ case AuthType.Password:
8008
8005
  logger.info('signing up with password');
8009
8006
  authentication = await this.handleSignUpWithPassword({
8010
8007
  signatureMessage: signatureMessageResponse,
@@ -8048,12 +8045,12 @@ class AuthService extends Base {
8048
8045
  let authentication;
8049
8046
  try {
8050
8047
  switch (this.deviceAuthType) {
8051
- case AuthType$1.Passkey:
8048
+ case AuthType.Passkey:
8052
8049
  authentication = await this.handleSignInWithPasskey({
8053
8050
  input,
8054
8051
  });
8055
8052
  break;
8056
- case AuthType$1.Password:
8053
+ case AuthType.Password:
8057
8054
  authentication = await this.handleSignInWithPassword({ input });
8058
8055
  break;
8059
8056
  default:
@@ -8237,11 +8234,11 @@ class AuthService extends Base {
8237
8234
  */
8238
8235
  async updateClientAuthPubKey({ password }) {
8239
8236
  try {
8240
- if (this.deviceAuthType === AuthType$1.Password && !password) {
8237
+ if (this.deviceAuthType === AuthType.Password && !password) {
8241
8238
  throw new Error('Password is required.');
8242
8239
  }
8243
8240
  const response = await this.signIn({ password }).then(async (signInResponse) => {
8244
- if (this.deviceAuthType === AuthType$1.Passkey && !signInResponse.prfValue) {
8241
+ if (this.deviceAuthType === AuthType.Passkey && !signInResponse.prfValue) {
8245
8242
  throw new Error('Something went wrong getting the PRF value.');
8246
8243
  }
8247
8244
  const encryptedDevicePrivateKey = await this.localStorageService.fetch(LocalStorageItems.EncryptedDevicePrivateKey);
@@ -8451,7 +8448,7 @@ class WalletHandlersService extends Base {
8451
8448
  const { signature, message } = await this.authService.getSignature({
8452
8449
  publicKey: deviceAuthKeys.publicKey,
8453
8450
  privateKey: deviceAuthKeys.privateKey,
8454
- }, this.deviceAuthType === AuthType$1.Passkey ? PasskeyChallengeType.AUTHENTICATION : undefined);
8451
+ }, this.deviceAuthType === AuthType.Passkey ? PasskeyChallengeType.AUTHENTICATION : undefined);
8455
8452
  if ((importWalletInput.returnWalletOption === ReturnWalletOption.ReturnOnlyEncryptedShares ||
8456
8453
  importWalletInput.returnWalletOption === ReturnWalletOption.ReturnBothEncryptedSharesAndSeed) &&
8457
8454
  !importWalletInput.keyShareOptions) {
@@ -8824,7 +8821,7 @@ class WalletService extends Base {
8824
8821
  if (!exportOptions.algorandSeedPhrase && !exportOptions.standardSeedPhrase && !exportOptions.keyShares) {
8825
8822
  throw new Error('exportOptions must be provided with at least one of the following options: algorandSeedPhrase, standardSeedPhrase, keyShares');
8826
8823
  }
8827
- if (this.deviceAuthType === AuthType$1.Password && authenticationOptions.password) {
8824
+ if (this.deviceAuthType === AuthType.Password && authenticationOptions.password) {
8828
8825
  try {
8829
8826
  await this.handleUpdateToV2({
8830
8827
  password: authenticationOptions.password,
@@ -9185,7 +9182,7 @@ class WalletService extends Base {
9185
9182
  */
9186
9183
  async changePassword({ walletId, oldPassword, newPassword, }) {
9187
9184
  try {
9188
- if (this.deviceAuthType === AuthType$1.Password && oldPassword) {
9185
+ if (this.deviceAuthType === AuthType.Password && oldPassword) {
9189
9186
  // Handle migration to V2 first then change the password to the new one.
9190
9187
  await this.handleUpdateToV2({
9191
9188
  password: oldPassword,
@@ -9285,7 +9282,7 @@ class WalletService extends Base {
9285
9282
  if (!storedEncryptedDevicePrivateKey)
9286
9283
  throw new Error('Device private key could not be found');
9287
9284
  const parsedEncryptedDevicePrivateKey = safeJsonParse(storedEncryptedDevicePrivateKey);
9288
- if (this.deviceAuthType === AuthType$1.Password && input.authenticationOptions.password) {
9285
+ if (this.deviceAuthType === AuthType.Password && input.authenticationOptions.password) {
9289
9286
  try {
9290
9287
  await this.handleUpdateToV2({
9291
9288
  password: input.authenticationOptions.password,
@@ -9382,7 +9379,7 @@ class WalletService extends Base {
9382
9379
  throw new Error('Device private key could not be found');
9383
9380
  }
9384
9381
  const parsedEncryptedDevicePrivateKey = safeJsonParse(encryptedDevicePrivateKey);
9385
- if (this.deviceAuthType === AuthType$1.Password && input.authenticationOptions.password) {
9382
+ if (this.deviceAuthType === AuthType.Password && input.authenticationOptions.password) {
9386
9383
  try {
9387
9384
  await this.handleUpdateToV2({
9388
9385
  password: input.authenticationOptions.password,
@@ -9516,7 +9513,7 @@ class WalletService extends Base {
9516
9513
  if (!walletId) {
9517
9514
  throw new Error('Missing required parameters');
9518
9515
  }
9519
- if (this.deviceAuthType === AuthType$1.Password && input.authenticationOptions.password) {
9516
+ if (this.deviceAuthType === AuthType.Password && input.authenticationOptions.password) {
9520
9517
  try {
9521
9518
  await this.handleUpdateToV2({
9522
9519
  password: input.authenticationOptions.password,
@@ -9856,7 +9853,7 @@ class WalletService extends Base {
9856
9853
  const passwordCredentialsKeyPair = await this.cipher.getCredentialsKeyPair({
9857
9854
  password: input.password,
9858
9855
  salt: clientSalt,
9859
- authType: AuthType$1.Password,
9856
+ authType: AuthType.Password,
9860
9857
  });
9861
9858
  let decryptedClientAuthPrivKey;
9862
9859
  const isPasswordValid = await this.authService.validatePassword({ password: input.password, salt: clientSalt });
@@ -9898,7 +9895,7 @@ class WalletService extends Base {
9898
9895
  storedEncryptedData: safeJsonParse(v2EncryptedSeed),
9899
9896
  encryptedDevicePrivateKey: safeJsonParse(v2EncryptedPriv),
9900
9897
  options: {
9901
- authType: AuthType$1.Password,
9898
+ authType: AuthType.Password,
9902
9899
  password: input.password,
9903
9900
  salt: clientSalt,
9904
9901
  },
@@ -10181,7 +10178,7 @@ class WalletDataService extends Base {
10181
10178
  if (!authenticationOptions || !walletId || !userId || !assetConfigId || !blockchainName) {
10182
10179
  throw new Error('Missing required parameters');
10183
10180
  }
10184
- if (this.deviceAuthType === AuthType$1.Password && authenticationOptions.password) {
10181
+ if (this.deviceAuthType === AuthType.Password && authenticationOptions.password) {
10185
10182
  await this.walletService.handleUpdateToV2({
10186
10183
  password: authenticationOptions.password,
10187
10184
  walletId: walletId,
@@ -10353,7 +10350,7 @@ class Utils extends Base {
10353
10350
  try {
10354
10351
  const salt = await this.auth.getUserSalt();
10355
10352
  const credentialsKeyPair = await this.cipher.getCredentialsKeyPair({
10356
- authType: AuthType$1.Password,
10353
+ authType: AuthType.Password,
10357
10354
  password,
10358
10355
  salt,
10359
10356
  });
@@ -10884,7 +10881,7 @@ class Transactions extends Base {
10884
10881
  async transfer({ originAddress, recipientAddress, amount, assetId, walletId, reference, authenticationOptions, memo, }) {
10885
10882
  try {
10886
10883
  // Only attempt migration if we have password auth and V2 storage might be incomplete
10887
- if (this.deviceAuthType === AuthType$1.Password && authenticationOptions.password) {
10884
+ if (this.deviceAuthType === AuthType.Password && authenticationOptions.password) {
10888
10885
  try {
10889
10886
  await this.walletService.handleUpdateToV2({
10890
10887
  password: authenticationOptions.password,
@@ -10954,7 +10951,7 @@ class Transactions extends Base {
10954
10951
  throw new Error(`Asset symbol and chain name must be provided when asset is not in user wallet.`);
10955
10952
  }
10956
10953
  // Only attempt migration if we have password auth and V2 storage might be incomplete
10957
- if (this.deviceAuthType === AuthType$1.Password && authenticationOptions.password) {
10954
+ if (this.deviceAuthType === AuthType.Password && authenticationOptions.password) {
10958
10955
  try {
10959
10956
  await this.walletService.handleUpdateToV2({
10960
10957
  password: authenticationOptions.password,
@@ -11032,7 +11029,7 @@ class Transactions extends Base {
11032
11029
  const signatureMessage = await this.authService.getSignature({
11033
11030
  publicKey: deviceAuthPublicKey,
11034
11031
  privateKey: decryptedDevicePrivateKey,
11035
- }, this.deviceAuthType === AuthType$1.Passkey ? PasskeyChallengeType.AUTHENTICATION : undefined);
11032
+ }, this.deviceAuthType === AuthType.Passkey ? PasskeyChallengeType.AUTHENTICATION : undefined);
11036
11033
  // Prepare encrypted data (seed phrase or key shares)
11037
11034
  const sharesEncryptedWithWallabyPubKey = [];
11038
11035
  let readyForTransportSeedPhrase = undefined;
@@ -11123,5 +11120,5 @@ class Wallaby {
11123
11120
  }
11124
11121
  }
11125
11122
 
11126
- export { AddressType, AndroidVersionNotSupportedError, ApiKeyStatus, AssetConfigStatus, AssetType, AuthType$1 as AuthType, AuthenticatorGeneralError, AuthenticatorMissingDiscoverableCredentialSupportError, AuthenticatorMissingUserVerificationSupportError, AuthenticatorNoSupportedPubKeyCredParamsAlgError, AuthenticatorNotRegisteredError, AuthenticatorPreviouslyRegisteredError, AutoRegisterUserVerificationFailureError, BadConfiguration, BlockchainName, BlockchainSlip44, BlockchainStatus, CeremonyAbortedError, ErrorResponseCodes, IOSVersionNotSupportedError, InterruptedError, InvalidChallengeError, InvalidDomainError, InvalidRpIdError, InvalidStateError, InvalidUserIdError, InvalidUserIdLengthError, KeyTypeName, LegacyKeyNames, LocalStorageItems, MalformedPubKeyCredParamsError, NativeError, NoCredentialsError, NotAllowedError, OwnershipType, PasskeyChallengeType, PasskeyErrorCodes, PassthroughSeeCausePropertyError, PublicKeyCredentialAlgorithm, RequestFailedError, RequestMethod, ReturnWalletOption, SeedPhraseType, TimeoutError, TokenStandard, TransactionEntryType, TransportEnum, UnknownError, UserAssetSource, UserCancelledError, V1KeyNames, V2KeyNames, Wallaby, Api as WallabyApiClient, HttpClient as WallabyHttpClient, WalletAddressTypeName, WalletOwnershipType, createIdentity, decryptWithPrivateKey, encryptWithPublicKey, hash, keccak256, publicKeyByPrivateKey, recoverPublicKey, sign };
11123
+ export { AddressType, AndroidVersionNotSupportedError, ApiKeyStatus, AssetConfigStatus, AssetType, AuthType, AuthenticatorGeneralError, AuthenticatorMissingDiscoverableCredentialSupportError, AuthenticatorMissingUserVerificationSupportError, AuthenticatorNoSupportedPubKeyCredParamsAlgError, AuthenticatorNotRegisteredError, AuthenticatorPreviouslyRegisteredError, AutoRegisterUserVerificationFailureError, BadConfiguration, BlockchainName, BlockchainSlip44, BlockchainStatus, CeremonyAbortedError, ErrorResponseCodes, IOSVersionNotSupportedError, InterruptedError, InvalidChallengeError, InvalidDomainError, InvalidRpIdError, InvalidStateError, InvalidUserIdError, InvalidUserIdLengthError, KeyTypeName, LegacyKeyNames, LocalStorageItems, MalformedPubKeyCredParamsError, NativeError, NoCredentialsError, NotAllowedError, OwnershipType, PasskeyChallengeType, PasskeyErrorCodes, PassthroughSeeCausePropertyError, PublicKeyCredentialAlgorithm, RequestFailedError, RequestMethod, ReturnWalletOption, SeedPhraseType, TimeoutError, TokenStandard, TransactionEntryType, TransportEnum, UnknownError, UserAssetSource, UserCancelledError, V1KeyNames, V2KeyNames, Wallaby, Api as WallabyApiClient, HttpClient as WallabyHttpClient, WalletAddressTypeName, WalletOwnershipType, createIdentity, decryptWithPrivateKey, encryptWithPublicKey, hash, keccak256, publicKeyByPrivateKey, recoverPublicKey, sign };
11127
11124
  //# sourceMappingURL=index.esm.js.map