wallaby-cash 2.0.1 → 2.0.2

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, _k;
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,11 @@ 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;
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) {
7049
+ return error.response.data;
7050
7050
  }
7051
- if (((_h = error.response) === null || _h === void 0 ? void 0 : _h.data.errorCode) && error.response.data.errorCode === ErrorResponseCodes.user_already_exists) {
7051
+ if (((_f = error.response) === null || _f === void 0 ? void 0 : _f.data.errorCode) && error.response.data.errorCode === ErrorResponseCodes.user_already_exists) {
7052
7052
  return error.response.data;
7053
7053
  }
7054
7054
  return Promise.reject(error.message);
@@ -7064,8 +7064,8 @@ class Base {
7064
7064
  }
7065
7065
  catch (error) {
7066
7066
  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);
7067
+ logger.error('SDK::Base::RequestMethod.Put::error', (_g = error.response) === null || _g === void 0 ? void 0 : _g.data);
7068
+ return Promise.reject((_h = error.response) === null || _h === void 0 ? void 0 : _h.data);
7069
7069
  }
7070
7070
  return Promise.reject(error === null || error === void 0 ? void 0 : error.message);
7071
7071
  }
@@ -7077,8 +7077,8 @@ class Base {
7077
7077
  }
7078
7078
  catch (error) {
7079
7079
  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);
7080
+ logger.error('SDK::Base::RequestMethod.Put::AxiosError', (_j = error.response) === null || _j === void 0 ? void 0 : _j.data);
7081
+ return Promise.reject((_k = error.response) === null || _k === void 0 ? void 0 : _k.data);
7082
7082
  }
7083
7083
  return Promise.reject(error === null || error === void 0 ? void 0 : error.message);
7084
7084
  }
@@ -7823,7 +7823,7 @@ class PasskeyService {
7823
7823
  logger.debug('SDK::PasskeyService::handleCredentialsCreationFromPrfExtension::prfValue', !!prfValue);
7824
7824
  const credentialsKeyPair = await this.cipher.getCredentialsKeyPair({
7825
7825
  prfValue,
7826
- authType: AuthType$1.Passkey,
7826
+ authType: AuthType.Passkey,
7827
7827
  });
7828
7828
  console.log('SDK::PasskeyService::handleCredentialsCreationFromPrfExtension::credentials key pair was created', !!credentialsKeyPair);
7829
7829
  return Object.assign(Object.assign({}, credentialsKeyPair), { prfValue });
@@ -7894,7 +7894,7 @@ class AuthService extends Base {
7894
7894
  throw new Error('V2 Private key was not found');
7895
7895
  }
7896
7896
  const credentialsKeyPair = await this.cipher.getCredentialsKeyPair({
7897
- authType: AuthType$1.Password,
7897
+ authType: AuthType.Password,
7898
7898
  password,
7899
7899
  salt: clientSalt,
7900
7900
  });
@@ -7997,14 +7997,14 @@ class AuthService extends Base {
7997
7997
  const signatureMessageResponse = await this.getSignature(deviceKeyPair, PasskeyChallengeType.REGISTRATION);
7998
7998
  logger.info('signature has been generated', !!signatureMessageResponse);
7999
7999
  switch (this.deviceAuthType) {
8000
- case AuthType$1.Passkey:
8000
+ case AuthType.Passkey:
8001
8001
  logger.info('registering a new passkey');
8002
8002
  authentication = await this.passkeyService.register({
8003
8003
  deviceKeyPair,
8004
8004
  challengeResponse: signatureMessageResponse,
8005
8005
  });
8006
8006
  break;
8007
- case AuthType$1.Password:
8007
+ case AuthType.Password:
8008
8008
  logger.info('signing up with password');
8009
8009
  authentication = await this.handleSignUpWithPassword({
8010
8010
  signatureMessage: signatureMessageResponse,
@@ -8048,12 +8048,12 @@ class AuthService extends Base {
8048
8048
  let authentication;
8049
8049
  try {
8050
8050
  switch (this.deviceAuthType) {
8051
- case AuthType$1.Passkey:
8051
+ case AuthType.Passkey:
8052
8052
  authentication = await this.handleSignInWithPasskey({
8053
8053
  input,
8054
8054
  });
8055
8055
  break;
8056
- case AuthType$1.Password:
8056
+ case AuthType.Password:
8057
8057
  authentication = await this.handleSignInWithPassword({ input });
8058
8058
  break;
8059
8059
  default:
@@ -8237,11 +8237,11 @@ class AuthService extends Base {
8237
8237
  */
8238
8238
  async updateClientAuthPubKey({ password }) {
8239
8239
  try {
8240
- if (this.deviceAuthType === AuthType$1.Password && !password) {
8240
+ if (this.deviceAuthType === AuthType.Password && !password) {
8241
8241
  throw new Error('Password is required.');
8242
8242
  }
8243
8243
  const response = await this.signIn({ password }).then(async (signInResponse) => {
8244
- if (this.deviceAuthType === AuthType$1.Passkey && !signInResponse.prfValue) {
8244
+ if (this.deviceAuthType === AuthType.Passkey && !signInResponse.prfValue) {
8245
8245
  throw new Error('Something went wrong getting the PRF value.');
8246
8246
  }
8247
8247
  const encryptedDevicePrivateKey = await this.localStorageService.fetch(LocalStorageItems.EncryptedDevicePrivateKey);
@@ -8451,7 +8451,7 @@ class WalletHandlersService extends Base {
8451
8451
  const { signature, message } = await this.authService.getSignature({
8452
8452
  publicKey: deviceAuthKeys.publicKey,
8453
8453
  privateKey: deviceAuthKeys.privateKey,
8454
- }, this.deviceAuthType === AuthType$1.Passkey ? PasskeyChallengeType.AUTHENTICATION : undefined);
8454
+ }, this.deviceAuthType === AuthType.Passkey ? PasskeyChallengeType.AUTHENTICATION : undefined);
8455
8455
  if ((importWalletInput.returnWalletOption === ReturnWalletOption.ReturnOnlyEncryptedShares ||
8456
8456
  importWalletInput.returnWalletOption === ReturnWalletOption.ReturnBothEncryptedSharesAndSeed) &&
8457
8457
  !importWalletInput.keyShareOptions) {
@@ -8824,7 +8824,7 @@ class WalletService extends Base {
8824
8824
  if (!exportOptions.algorandSeedPhrase && !exportOptions.standardSeedPhrase && !exportOptions.keyShares) {
8825
8825
  throw new Error('exportOptions must be provided with at least one of the following options: algorandSeedPhrase, standardSeedPhrase, keyShares');
8826
8826
  }
8827
- if (this.deviceAuthType === AuthType$1.Password && authenticationOptions.password) {
8827
+ if (this.deviceAuthType === AuthType.Password && authenticationOptions.password) {
8828
8828
  try {
8829
8829
  await this.handleUpdateToV2({
8830
8830
  password: authenticationOptions.password,
@@ -9185,7 +9185,7 @@ class WalletService extends Base {
9185
9185
  */
9186
9186
  async changePassword({ walletId, oldPassword, newPassword, }) {
9187
9187
  try {
9188
- if (this.deviceAuthType === AuthType$1.Password && oldPassword) {
9188
+ if (this.deviceAuthType === AuthType.Password && oldPassword) {
9189
9189
  // Handle migration to V2 first then change the password to the new one.
9190
9190
  await this.handleUpdateToV2({
9191
9191
  password: oldPassword,
@@ -9285,7 +9285,7 @@ class WalletService extends Base {
9285
9285
  if (!storedEncryptedDevicePrivateKey)
9286
9286
  throw new Error('Device private key could not be found');
9287
9287
  const parsedEncryptedDevicePrivateKey = safeJsonParse(storedEncryptedDevicePrivateKey);
9288
- if (this.deviceAuthType === AuthType$1.Password && input.authenticationOptions.password) {
9288
+ if (this.deviceAuthType === AuthType.Password && input.authenticationOptions.password) {
9289
9289
  try {
9290
9290
  await this.handleUpdateToV2({
9291
9291
  password: input.authenticationOptions.password,
@@ -9382,7 +9382,7 @@ class WalletService extends Base {
9382
9382
  throw new Error('Device private key could not be found');
9383
9383
  }
9384
9384
  const parsedEncryptedDevicePrivateKey = safeJsonParse(encryptedDevicePrivateKey);
9385
- if (this.deviceAuthType === AuthType$1.Password && input.authenticationOptions.password) {
9385
+ if (this.deviceAuthType === AuthType.Password && input.authenticationOptions.password) {
9386
9386
  try {
9387
9387
  await this.handleUpdateToV2({
9388
9388
  password: input.authenticationOptions.password,
@@ -9516,7 +9516,7 @@ class WalletService extends Base {
9516
9516
  if (!walletId) {
9517
9517
  throw new Error('Missing required parameters');
9518
9518
  }
9519
- if (this.deviceAuthType === AuthType$1.Password && input.authenticationOptions.password) {
9519
+ if (this.deviceAuthType === AuthType.Password && input.authenticationOptions.password) {
9520
9520
  try {
9521
9521
  await this.handleUpdateToV2({
9522
9522
  password: input.authenticationOptions.password,
@@ -9856,7 +9856,7 @@ class WalletService extends Base {
9856
9856
  const passwordCredentialsKeyPair = await this.cipher.getCredentialsKeyPair({
9857
9857
  password: input.password,
9858
9858
  salt: clientSalt,
9859
- authType: AuthType$1.Password,
9859
+ authType: AuthType.Password,
9860
9860
  });
9861
9861
  let decryptedClientAuthPrivKey;
9862
9862
  const isPasswordValid = await this.authService.validatePassword({ password: input.password, salt: clientSalt });
@@ -9898,7 +9898,7 @@ class WalletService extends Base {
9898
9898
  storedEncryptedData: safeJsonParse(v2EncryptedSeed),
9899
9899
  encryptedDevicePrivateKey: safeJsonParse(v2EncryptedPriv),
9900
9900
  options: {
9901
- authType: AuthType$1.Password,
9901
+ authType: AuthType.Password,
9902
9902
  password: input.password,
9903
9903
  salt: clientSalt,
9904
9904
  },
@@ -10181,7 +10181,7 @@ class WalletDataService extends Base {
10181
10181
  if (!authenticationOptions || !walletId || !userId || !assetConfigId || !blockchainName) {
10182
10182
  throw new Error('Missing required parameters');
10183
10183
  }
10184
- if (this.deviceAuthType === AuthType$1.Password && authenticationOptions.password) {
10184
+ if (this.deviceAuthType === AuthType.Password && authenticationOptions.password) {
10185
10185
  await this.walletService.handleUpdateToV2({
10186
10186
  password: authenticationOptions.password,
10187
10187
  walletId: walletId,
@@ -10353,7 +10353,7 @@ class Utils extends Base {
10353
10353
  try {
10354
10354
  const salt = await this.auth.getUserSalt();
10355
10355
  const credentialsKeyPair = await this.cipher.getCredentialsKeyPair({
10356
- authType: AuthType$1.Password,
10356
+ authType: AuthType.Password,
10357
10357
  password,
10358
10358
  salt,
10359
10359
  });
@@ -10884,7 +10884,7 @@ class Transactions extends Base {
10884
10884
  async transfer({ originAddress, recipientAddress, amount, assetId, walletId, reference, authenticationOptions, memo, }) {
10885
10885
  try {
10886
10886
  // Only attempt migration if we have password auth and V2 storage might be incomplete
10887
- if (this.deviceAuthType === AuthType$1.Password && authenticationOptions.password) {
10887
+ if (this.deviceAuthType === AuthType.Password && authenticationOptions.password) {
10888
10888
  try {
10889
10889
  await this.walletService.handleUpdateToV2({
10890
10890
  password: authenticationOptions.password,
@@ -10954,7 +10954,7 @@ class Transactions extends Base {
10954
10954
  throw new Error(`Asset symbol and chain name must be provided when asset is not in user wallet.`);
10955
10955
  }
10956
10956
  // Only attempt migration if we have password auth and V2 storage might be incomplete
10957
- if (this.deviceAuthType === AuthType$1.Password && authenticationOptions.password) {
10957
+ if (this.deviceAuthType === AuthType.Password && authenticationOptions.password) {
10958
10958
  try {
10959
10959
  await this.walletService.handleUpdateToV2({
10960
10960
  password: authenticationOptions.password,
@@ -11032,7 +11032,7 @@ class Transactions extends Base {
11032
11032
  const signatureMessage = await this.authService.getSignature({
11033
11033
  publicKey: deviceAuthPublicKey,
11034
11034
  privateKey: decryptedDevicePrivateKey,
11035
- }, this.deviceAuthType === AuthType$1.Passkey ? PasskeyChallengeType.AUTHENTICATION : undefined);
11035
+ }, this.deviceAuthType === AuthType.Passkey ? PasskeyChallengeType.AUTHENTICATION : undefined);
11036
11036
  // Prepare encrypted data (seed phrase or key shares)
11037
11037
  const sharesEncryptedWithWallabyPubKey = [];
11038
11038
  let readyForTransportSeedPhrase = undefined;
@@ -11123,5 +11123,5 @@ class Wallaby {
11123
11123
  }
11124
11124
  }
11125
11125
 
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 };
11126
+ 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
11127
  //# sourceMappingURL=index.esm.js.map