wallaby-cash 3.0.1-alpha.0 → 3.0.1-alpha.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.cjs.js CHANGED
@@ -597,7 +597,7 @@ const MASTER_ENCRYPTION_KEY = '9fa9d3f3c77c20d3a50a08e5299644be29f6e6206ef3479fe
597
597
  { type: 'public-key', alg: exports.PublicKeyCredentialAlgorithm.ES256 },
598
598
  ];
599
599
  const isWeb = typeof window !== 'undefined' && typeof document !== 'undefined';
600
- const currentPackageVersion = "3.0.1-alpha.0" ;
600
+ const currentPackageVersion = "3.0.1-alpha.2" ;
601
601
 
602
602
  /**
603
603
  * Storage keys adapter for Storage interface across different platforms.
@@ -8105,7 +8105,8 @@ class AuthService extends Base {
8105
8105
  async getSignature({ deviceAuthKeys, walletId, passkeyChallengeType, }) {
8106
8106
  try {
8107
8107
  logger.debug('SDK::AuthService::getSignature::authType', this.deviceAuthType);
8108
- const challengeType = passkeyChallengeType !== null && passkeyChallengeType !== void 0 ? passkeyChallengeType : exports.PasskeyChallengeType.REGISTRATION;
8108
+ const needsPasskeyChallenge = this.deviceAuthType === exports.AuthType.Passkey;
8109
+ const challengeType = needsPasskeyChallenge ? (passkeyChallengeType !== null && passkeyChallengeType !== void 0 ? passkeyChallengeType : exports.PasskeyChallengeType.REGISTRATION) : undefined;
8109
8110
  logger.debug('SDK::AuthService::getSignature::challengeType', challengeType);
8110
8111
  const response = await this.request(AuthRoutes.signatureMessage, {
8111
8112
  payload: {
@@ -9480,31 +9481,26 @@ class WalletService extends Base {
9480
9481
  });
9481
9482
  }
9482
9483
  const devicePublicKey = (_a = (await this.localStorageService.fetch(exports.LocalStorageItems.ClientAuthPublicKey))) !== null && _a !== void 0 ? _a : publicKeyByPrivateKey(decryptedDevicePrivateKey);
9483
- const storedEncryptedBackupShare = await this.localStorageService.fetch(exports.LocalStorageItems.BackupDeviceKeyShare, {
9484
+ const newSignature = await this.authService.getSignature({
9485
+ deviceAuthKeys: { privateKey: decryptedDevicePrivateKey, publicKey: devicePublicKey },
9484
9486
  walletId: input.walletId,
9487
+ passkeyChallengeType: this.deviceAuthType === exports.AuthType.Passkey ? exports.PasskeyChallengeType.AUTHENTICATION : undefined,
9485
9488
  });
9486
- if (!storedEncryptedBackupShare) {
9487
- throw new WallabyError({
9488
- message: 'Backup share could not be found',
9489
- statusCode: 404,
9490
- errorCode: exports.ErrorResponseCodes.sdk_key_shares_not_found,
9491
- });
9492
- }
9493
- const encryptedBackupShareString = await this.cipher.decrypt({
9494
- cipherText: safeJsonParse(storedEncryptedBackupShare),
9495
- decryptionKey: credentialsKeyPair.privateKey,
9496
- });
9497
- const encryptedBackupShare = safeJsonParse(encryptedBackupShareString);
9498
- const backUpResponse = await this.api.wallets.addNewDevice({
9499
- walletId: input.walletId,
9500
- clientAuthPubKey: devicePublicKey,
9501
- encryptedBackupShare: encryptedBackupShare,
9489
+ const backUpResponse = await this.request(WalletRoutes.addNewDevice, {
9490
+ payload: {
9491
+ walletId: input.walletId,
9492
+ clientAuthPubKey: devicePublicKey,
9493
+ signature: newSignature.signature,
9494
+ message: newSignature.message,
9495
+ wallabyAuthPubKey: newSignature.wallabyAuthPubKey,
9496
+ encryptedBackupShare: input.encryptedBackupShare,
9497
+ },
9502
9498
  });
9503
9499
  await this.handlers.handleKeySharesFromResponse({
9504
9500
  walletId: input.walletId,
9505
9501
  shares: [backUpResponse.share],
9506
9502
  credentialsKeyPair,
9507
- encryptedBackupShare: encryptedBackupShare,
9503
+ encryptedBackupShare: input.encryptedBackupShare,
9508
9504
  });
9509
9505
  return { success: true, reference: backUpResponse.reference };
9510
9506
  }