@dynamic-labs-wallet/browser 0.0.211 → 0.0.212

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/index.cjs.js CHANGED
@@ -813,6 +813,43 @@ const localStorageWriteTest = {
813
813
  }
814
814
  });
815
815
 
816
+ const createDelegationWithGoogleDriveDistribution = ({ existingShares, delegatedShare })=>({
817
+ dynamicBackendShares: existingShares,
818
+ googleDriveShares: existingShares,
819
+ delegatedShare
820
+ });
821
+ const createDelegationOnlyDistribution = ({ existingShares, delegatedShare })=>({
822
+ dynamicBackendShares: existingShares,
823
+ googleDriveShares: [],
824
+ delegatedShare
825
+ });
826
+ const createGoogleDriveOnlyDistribution = ({ allShares })=>({
827
+ dynamicBackendShares: allShares.slice(0, -1),
828
+ googleDriveShares: allShares.slice(-1)
829
+ });
830
+ const createDynamicOnlyDistribution = ({ allShares })=>({
831
+ dynamicBackendShares: allShares,
832
+ googleDriveShares: []
833
+ });
834
+ const hasGoogleDriveBackup = (backupInfo)=>{
835
+ var _backupInfo_backups_BackupLocation_GOOGLE_DRIVE, _backupInfo_backups;
836
+ var _backupInfo_backups_BackupLocation_GOOGLE_DRIVE_length;
837
+ return ((_backupInfo_backups_BackupLocation_GOOGLE_DRIVE_length = backupInfo == null ? void 0 : (_backupInfo_backups = backupInfo.backups) == null ? void 0 : (_backupInfo_backups_BackupLocation_GOOGLE_DRIVE = _backupInfo_backups[core.BackupLocation.GOOGLE_DRIVE]) == null ? void 0 : _backupInfo_backups_BackupLocation_GOOGLE_DRIVE.length) != null ? _backupInfo_backups_BackupLocation_GOOGLE_DRIVE_length : 0) > 0;
838
+ };
839
+ const hasDelegatedBackup = (backupInfo)=>{
840
+ var _backupInfo_backups_BackupLocation_DELEGATED, _backupInfo_backups;
841
+ var _backupInfo_backups_BackupLocation_DELEGATED_length;
842
+ return ((_backupInfo_backups_BackupLocation_DELEGATED_length = backupInfo == null ? void 0 : (_backupInfo_backups = backupInfo.backups) == null ? void 0 : (_backupInfo_backups_BackupLocation_DELEGATED = _backupInfo_backups[core.BackupLocation.DELEGATED]) == null ? void 0 : _backupInfo_backups_BackupLocation_DELEGATED.length) != null ? _backupInfo_backups_BackupLocation_DELEGATED_length : 0) > 0;
843
+ };
844
+ /**
845
+ * Distribution for adding Google Drive backup to an existing delegation.
846
+ * Client's shares go to both Dynamic and Google Drive.
847
+ * delegatedShare is undefined - we don't re-publish, but preserve the location.
848
+ */ const createAddGoogleDriveToExistingDelegationDistribution = ({ clientShares })=>({
849
+ dynamicBackendShares: clientShares,
850
+ googleDriveShares: clientShares
851
+ });
852
+
816
853
  class DynamicWalletClient {
817
854
  async initializeForwardMPCClient() {
818
855
  try {
@@ -1494,14 +1531,42 @@ class DynamicWalletClient {
1494
1531
  clientKeyShares: clientKeysharesToLocalStorage,
1495
1532
  overwriteOrMerge: 'overwrite'
1496
1533
  });
1497
- // if delegateToProjectEnvironment is true, we need to update location for the delegated share
1498
- const delegatedKeyshare = delegateToProjectEnvironment ? newReshareResults[0] : undefined;
1499
- await this.storeEncryptedBackupByWallet({
1534
+ const allClientShares = [
1535
+ ...existingReshareResults,
1536
+ ...newReshareResults
1537
+ ];
1538
+ let distribution;
1539
+ if (delegateToProjectEnvironment && backupToGoogleDrive) {
1540
+ // Delegation + Google Drive: Client's existing share backs up to both Dynamic and Google Drive.
1541
+ // The new share goes to the webhook for delegation.
1542
+ distribution = createDelegationWithGoogleDriveDistribution({
1543
+ existingShares: existingReshareResults,
1544
+ delegatedShare: newReshareResults[0]
1545
+ });
1546
+ } else if (delegateToProjectEnvironment) {
1547
+ // Delegation only: Client's existing share backs up to Dynamic.
1548
+ // The new share goes to the webhook for delegation. No Google Drive backup.
1549
+ distribution = createDelegationOnlyDistribution({
1550
+ existingShares: existingReshareResults,
1551
+ delegatedShare: newReshareResults[0]
1552
+ });
1553
+ } else if (backupToGoogleDrive) {
1554
+ // Google Drive only: Split shares between Dynamic (N-1) and Google Drive (1).
1555
+ // The last share (new share) goes to Google Drive.
1556
+ distribution = createGoogleDriveOnlyDistribution({
1557
+ allShares: allClientShares
1558
+ });
1559
+ } else {
1560
+ // No delegation, no Google Drive: All shares go to Dynamic backend only.
1561
+ distribution = createDynamicOnlyDistribution({
1562
+ allShares: allClientShares
1563
+ });
1564
+ }
1565
+ await this.backupSharesWithDistribution({
1500
1566
  accountAddress,
1501
1567
  password,
1502
1568
  signedSessionId,
1503
- backupToGoogleDrive,
1504
- delegatedKeyshare
1569
+ distribution
1505
1570
  });
1506
1571
  } catch (error) {
1507
1572
  logError({
@@ -1530,6 +1595,7 @@ class DynamicWalletClient {
1530
1595
  }
1531
1596
  async performDelegationOperation({ accountAddress, password, signedSessionId, mfaToken, newThresholdSignatureScheme, revokeDelegation = false, operationName }) {
1532
1597
  try {
1598
+ var _this_walletMap_accountAddress;
1533
1599
  const delegateToProjectEnvironment = this.featureFlags && this.featureFlags[core.FEATURE_FLAGS.ENABLE_DELEGATED_KEY_SHARES_FLAG] === true;
1534
1600
  if (!delegateToProjectEnvironment) {
1535
1601
  throw new Error('Delegation is not allowed for this project environment');
@@ -1551,7 +1617,7 @@ class DynamicWalletClient {
1551
1617
  newThresholdSignatureScheme,
1552
1618
  password,
1553
1619
  signedSessionId,
1554
- backupToGoogleDrive: false,
1620
+ backupToGoogleDrive: hasGoogleDriveBackup((_this_walletMap_accountAddress = this.walletMap[accountAddress]) == null ? void 0 : _this_walletMap_accountAddress.clientKeySharesBackupInfo),
1555
1621
  delegateToProjectEnvironment: true,
1556
1622
  mfaToken,
1557
1623
  revokeDelegation
@@ -1755,47 +1821,14 @@ class DynamicWalletClient {
1755
1821
  });
1756
1822
  await ((_this_storage = this.storage) == null ? void 0 : _this_storage.setItem(accountAddress, stringifiedClientKeyShares));
1757
1823
  }
1758
- /**
1759
- * Central backup orchestrator that encrypts and stores wallet key shares.
1760
- *
1761
- * This method serves as the main backup coordinator, handling the distribution of encrypted
1762
- * key shares between Dynamic's backend and Google Drive based on the wallet's threshold scheme.
1763
- * It is used by multiple operations including reshare, refresh, and manual backup requests.
1764
- *
1765
- * **Backup Distribution Strategy:**
1766
- * - **Single share wallets**: All shares stored on Dynamic's backend only
1767
- * - **Multi-share wallets (2+)**: When backing up to Google Drive, N-1 shares on Dynamic's backend, 1 share on Google Drive
1768
- * - **Multi-share wallets (2+)**: When not backing up to Google Drive, all shares on Dynamic's backend
1769
- *
1770
- * **Process Flow:**
1771
- * 1. Encrypts all client key shares with the provided password (or environment ID if no password)
1772
- * 2. For multi-share wallets (2+): conditionally distributes N-1 to backend, 1 to Google Drive
1773
- * 3. For other configurations: stores all shares on Dynamic's backend
1774
- * 4. Updates backup metadata and synchronizes wallet state
1775
- * 5. Persists the updated wallet map to local storage
1776
- *
1777
- * **Delegated Key Shares:**
1778
- * - When delegatedKeyshare is provided, the method will not store the delegated key share but it will mark the delegated share as backed up on Dynamic's backend
1779
- * - and encrypt the delegated key share to publish it to the webhook
1780
- *
1781
- * @param params - The backup operation parameters
1782
- * @param params.accountAddress - The account address of the wallet to backup
1783
- * @param params.clientKeyShares - Optional specific key shares to backup (uses localStorage if not provided)
1784
- * @param params.password - Optional password for encryption (uses environment ID if not provided)
1785
- * @param params.signedSessionId - Optional signed session ID for authentication
1786
- * @param params.backupToGoogleDrive - Whether to backup to Google Drive (defaults to false)
1787
- * @returns Promise with backup metadata including share locations and IDs
1788
- */ async storeEncryptedBackupByWallet({ accountAddress, clientKeyShares = undefined, password = undefined, signedSessionId, backupToGoogleDrive = false, delegatedKeyshare = undefined }) {
1824
+ async backupSharesWithDistribution({ accountAddress, password, signedSessionId, distribution, preserveDelegatedLocation = false }) {
1789
1825
  const dynamicRequestId = uuid.v4();
1790
1826
  try {
1791
- var _this_walletMap_accountAddress, _this_walletMap_accountAddress_clientKeySharesBackupInfo_backups_BackupLocation_GOOGLE_DRIVE, _this_walletMap_accountAddress_clientKeySharesBackupInfo_backups, _this_walletMap_accountAddress_clientKeySharesBackupInfo, _this_walletMap_accountAddress1;
1792
- const keySharesToBackup = clientKeyShares != null ? clientKeyShares : await this.getClientKeySharesFromLocalStorage({
1793
- accountAddress
1794
- });
1827
+ var _this_walletMap_accountAddress;
1795
1828
  if (!((_this_walletMap_accountAddress = this.walletMap[accountAddress]) == null ? void 0 : _this_walletMap_accountAddress.walletId)) {
1796
1829
  const error = new Error(`WalletId not found for accountAddress ${accountAddress}`);
1797
1830
  logError({
1798
- message: 'Error in storeEncryptedBackupByWallet, wallet or walletId not found from the wallet map',
1831
+ message: 'Error in backupSharesWithDistribution, wallet or walletId not found from the wallet map',
1799
1832
  error,
1800
1833
  context: {
1801
1834
  accountAddress,
@@ -1804,58 +1837,44 @@ class DynamicWalletClient {
1804
1837
  });
1805
1838
  throw error;
1806
1839
  }
1807
- // TODO(zfaizal2): throw error if signedSessionId is not provided after service deploy
1808
- let dynamicClientKeyShares = [];
1809
- let googleDriveKeyShares = [];
1810
- const encryptedKeyShares = await Promise.all(keySharesToBackup.map((keyShare)=>this.encryptKeyShare({
1811
- keyShare,
1812
- password
1813
- })));
1814
- const hasExistingGoogleDriveBackup = ((_this_walletMap_accountAddress1 = this.walletMap[accountAddress]) == null ? void 0 : (_this_walletMap_accountAddress_clientKeySharesBackupInfo = _this_walletMap_accountAddress1.clientKeySharesBackupInfo) == null ? void 0 : (_this_walletMap_accountAddress_clientKeySharesBackupInfo_backups = _this_walletMap_accountAddress_clientKeySharesBackupInfo.backups) == null ? void 0 : (_this_walletMap_accountAddress_clientKeySharesBackupInfo_backups_BackupLocation_GOOGLE_DRIVE = _this_walletMap_accountAddress_clientKeySharesBackupInfo_backups[core.BackupLocation.GOOGLE_DRIVE]) == null ? void 0 : _this_walletMap_accountAddress_clientKeySharesBackupInfo_backups_BackupLocation_GOOGLE_DRIVE.length) > 0;
1815
- // Backup to Google Drive if:
1816
- // 1. Explicitly requested via flag, OR
1817
- // 2. User already has Google Drive backups
1818
- const shouldBackupToGoogleDrive = backupToGoogleDrive || hasExistingGoogleDriveBackup;
1819
- if (shouldBackupToGoogleDrive && keySharesToBackup.length >= 2) {
1820
- // For 2 shares: 1 to backend, 1 to Google Drive
1821
- // For 3+ shares: N-1 to backend, 1 to Google Drive
1822
- const googleDriveShareCount = 1;
1823
- dynamicClientKeyShares = encryptedKeyShares.slice(0, -googleDriveShareCount);
1824
- googleDriveKeyShares = encryptedKeyShares.slice(-googleDriveShareCount);
1825
- } else {
1826
- dynamicClientKeyShares = encryptedKeyShares;
1827
- }
1828
- const data = await this.apiClient.storeEncryptedBackupByWallet({
1829
- walletId: this.walletMap[accountAddress].walletId,
1830
- encryptedKeyShares: dynamicClientKeyShares,
1831
- passwordEncrypted: Boolean(password) && password !== this.environmentId,
1832
- encryptionVersion: ENCRYPTION_VERSION_CURRENT,
1833
- signedSessionId,
1834
- authMode: this.authMode,
1835
- requiresSignedSessionId: this.requiresSignedSessionId(),
1836
- dynamicRequestId
1837
- });
1838
- if (data.keyShareIds.length === 0) {
1839
- throw new Error('No key shares were backed up');
1840
- }
1841
- const locations = [
1842
- {
1840
+ const locations = [];
1841
+ if (distribution.dynamicBackendShares.length > 0) {
1842
+ const encryptedDynamicShares = await Promise.all(distribution.dynamicBackendShares.map((keyShare)=>this.encryptKeyShare({
1843
+ keyShare,
1844
+ password
1845
+ })));
1846
+ const data = await this.apiClient.storeEncryptedBackupByWallet({
1847
+ walletId: this.walletMap[accountAddress].walletId,
1848
+ encryptedKeyShares: encryptedDynamicShares,
1849
+ passwordEncrypted: Boolean(password) && password !== this.environmentId,
1850
+ encryptionVersion: ENCRYPTION_VERSION_CURRENT,
1851
+ signedSessionId,
1852
+ authMode: this.authMode,
1853
+ requiresSignedSessionId: this.requiresSignedSessionId(),
1854
+ dynamicRequestId
1855
+ });
1856
+ if (data.keyShareIds.length === 0) {
1857
+ throw new Error('No key shares were backed up to Dynamic backend');
1858
+ }
1859
+ locations.push({
1843
1860
  location: core.BackupLocation.DYNAMIC,
1844
1861
  externalKeyShareId: data.keyShareIds[0]
1845
- }
1846
- ];
1847
- if (googleDriveKeyShares.length > 0) {
1862
+ });
1863
+ }
1864
+ if (distribution.googleDriveShares.length > 0) {
1865
+ const encryptedGoogleDriveShares = await Promise.all(distribution.googleDriveShares.map((keyShare)=>this.encryptKeyShare({
1866
+ keyShare,
1867
+ password
1868
+ })));
1848
1869
  await this.uploadKeySharesToGoogleDrive({
1849
1870
  accountAddress,
1850
- encryptedKeyShares: googleDriveKeyShares
1871
+ encryptedKeyShares: encryptedGoogleDriveShares
1851
1872
  });
1852
1873
  locations.push({
1853
1874
  location: core.BackupLocation.GOOGLE_DRIVE
1854
1875
  });
1855
1876
  }
1856
- // if delegatedKeyshare is provided, we encrypt the delegated key share and publish it to the webhook
1857
- // after publish confirmed, we mark the delegated share as backed up on Dynamic's backend
1858
- if (delegatedKeyshare) {
1877
+ if (distribution.delegatedShare) {
1859
1878
  var _publicKey_key, _publicKey_key1, _publicKey_key2;
1860
1879
  const publicKey = await this.apiClient.getDelegatedEncryptionKey({
1861
1880
  environmentId: this.environmentId
@@ -1864,7 +1883,7 @@ class DynamicWalletClient {
1864
1883
  throw new Error('Public key not found');
1865
1884
  }
1866
1885
  var _publicKey_key_keyId;
1867
- const encryptedDelegatedKeyShareEnvelope = await encryptDelegatedKeyShare(JSON.stringify(delegatedKeyshare), publicKey == null ? void 0 : (_publicKey_key1 = publicKey.key) == null ? void 0 : _publicKey_key1.publicKeyPemB64, (_publicKey_key_keyId = publicKey == null ? void 0 : (_publicKey_key2 = publicKey.key) == null ? void 0 : _publicKey_key2.keyId) != null ? _publicKey_key_keyId : publicKey == null ? void 0 : publicKey.keyId);
1886
+ const encryptedDelegatedKeyShareEnvelope = await encryptDelegatedKeyShare(JSON.stringify(distribution.delegatedShare), publicKey == null ? void 0 : (_publicKey_key1 = publicKey.key) == null ? void 0 : _publicKey_key1.publicKeyPemB64, (_publicKey_key_keyId = publicKey == null ? void 0 : (_publicKey_key2 = publicKey.key) == null ? void 0 : _publicKey_key2.keyId) != null ? _publicKey_key_keyId : publicKey == null ? void 0 : publicKey.keyId);
1868
1887
  const { status } = await this.apiClient.publishDelegatedKeyShare({
1869
1888
  walletId: this.walletMap[accountAddress].walletId,
1870
1889
  encryptedKeyShare: encryptedDelegatedKeyShareEnvelope,
@@ -1879,6 +1898,12 @@ class DynamicWalletClient {
1879
1898
  location: core.BackupLocation.DELEGATED
1880
1899
  });
1881
1900
  }
1901
+ // Preserve existing delegated location without re-publishing
1902
+ if (preserveDelegatedLocation && !distribution.delegatedShare) {
1903
+ locations.push({
1904
+ location: core.BackupLocation.DELEGATED
1905
+ });
1906
+ }
1882
1907
  const backupData = await this.apiClient.markKeySharesAsBackedUp({
1883
1908
  walletId: this.walletMap[accountAddress].walletId,
1884
1909
  locations,
@@ -1900,10 +1925,10 @@ class DynamicWalletClient {
1900
1925
  clientKeySharesBackupInfo: updatedBackupInfo
1901
1926
  });
1902
1927
  await this.storage.setItem(this.storageKey, JSON.stringify(this.walletMap));
1903
- return data;
1928
+ return backupData;
1904
1929
  } catch (error) {
1905
1930
  logError({
1906
- message: 'Error in storeEncryptedBackupByWallet',
1931
+ message: 'Error in backupSharesWithDistribution',
1907
1932
  error: error,
1908
1933
  context: {
1909
1934
  accountAddress,
@@ -1913,6 +1938,88 @@ class DynamicWalletClient {
1913
1938
  throw error;
1914
1939
  }
1915
1940
  }
1941
+ /**
1942
+ * Central backup orchestrator that encrypts and stores wallet key shares.
1943
+ *
1944
+ * This method serves as the main backup coordinator, handling the distribution of encrypted
1945
+ * key shares between Dynamic's backend and Google Drive based on the wallet's threshold scheme.
1946
+ * It is used by multiple operations including reshare, refresh, and manual backup requests.
1947
+ *
1948
+ * **Backup Distribution Strategy:**
1949
+ * - **Single share wallets**: All shares stored on Dynamic's backend only
1950
+ * - **Multi-share wallets (2+)**: When backing up to Google Drive, N-1 shares on Dynamic's backend, 1 share on Google Drive
1951
+ * - **Multi-share wallets (2+)**: When not backing up to Google Drive, all shares on Dynamic's backend
1952
+ *
1953
+ * **Process Flow:**
1954
+ * 1. Encrypts all client key shares with the provided password (or environment ID if no password)
1955
+ * 2. For multi-share wallets (2+): conditionally distributes N-1 to backend, 1 to Google Drive
1956
+ * 3. For other configurations: stores all shares on Dynamic's backend
1957
+ * 4. Updates backup metadata and synchronizes wallet state
1958
+ * 5. Persists the updated wallet map to local storage
1959
+ *
1960
+ * **Delegated Key Shares:**
1961
+ * - When delegatedKeyshare is provided, the method will not store the delegated key share but it will mark the delegated share as backed up on Dynamic's backend
1962
+ * - and encrypt the delegated key share to publish it to the webhook
1963
+ *
1964
+ * @param params - The backup operation parameters
1965
+ * @param params.accountAddress - The account address of the wallet to backup
1966
+ * @param params.clientKeyShares - Optional specific key shares to backup (uses localStorage if not provided)
1967
+ * @param params.password - Optional password for encryption (uses environment ID if not provided)
1968
+ * @param params.signedSessionId - Optional signed session ID for authentication
1969
+ * @param params.backupToGoogleDrive - Whether to backup to Google Drive (defaults to false)
1970
+ * @returns Promise with backup metadata including share locations and IDs
1971
+ */ async storeEncryptedBackupByWallet({ accountAddress, clientKeyShares = undefined, password = undefined, signedSessionId, backupToGoogleDrive = false, delegatedKeyshare = undefined }) {
1972
+ var _this_walletMap_accountAddress, _this_walletMap_accountAddress1;
1973
+ const keySharesToBackup = clientKeyShares != null ? clientKeyShares : await this.getClientKeySharesFromLocalStorage({
1974
+ accountAddress
1975
+ });
1976
+ const shouldBackupToGoogleDrive = backupToGoogleDrive || hasGoogleDriveBackup((_this_walletMap_accountAddress = this.walletMap[accountAddress]) == null ? void 0 : _this_walletMap_accountAddress.clientKeySharesBackupInfo);
1977
+ const hasExistingDelegation = hasDelegatedBackup((_this_walletMap_accountAddress1 = this.walletMap[accountAddress]) == null ? void 0 : _this_walletMap_accountAddress1.clientKeySharesBackupInfo);
1978
+ let distribution;
1979
+ let preserveDelegatedLocation = false;
1980
+ if (delegatedKeyshare && shouldBackupToGoogleDrive) {
1981
+ // NEW delegation + Google Drive: Client's shares back up to both Dynamic and Google Drive.
1982
+ // The delegated share goes to the webhook.
1983
+ distribution = createDelegationWithGoogleDriveDistribution({
1984
+ existingShares: keySharesToBackup,
1985
+ delegatedShare: delegatedKeyshare
1986
+ });
1987
+ } else if (delegatedKeyshare) {
1988
+ // NEW delegation only: Client's shares back up to Dynamic.
1989
+ // The delegated share goes to the webhook. No Google Drive backup.
1990
+ distribution = createDelegationOnlyDistribution({
1991
+ existingShares: keySharesToBackup,
1992
+ delegatedShare: delegatedKeyshare
1993
+ });
1994
+ } else if (hasExistingDelegation && shouldBackupToGoogleDrive) {
1995
+ // ADD Google Drive to EXISTING delegation: Client's share backs up to both Dynamic and GD.
1996
+ // Don't re-publish delegated share, just preserve the location.
1997
+ distribution = createAddGoogleDriveToExistingDelegationDistribution({
1998
+ clientShares: keySharesToBackup
1999
+ });
2000
+ preserveDelegatedLocation = true;
2001
+ } else if (shouldBackupToGoogleDrive && keySharesToBackup.length >= 2) {
2002
+ // Google Drive only (no delegation): Split shares between Dynamic (N-1) and Google Drive (1).
2003
+ distribution = createGoogleDriveOnlyDistribution({
2004
+ allShares: keySharesToBackup
2005
+ });
2006
+ } else {
2007
+ // No delegation, no Google Drive: All shares go to Dynamic backend only.
2008
+ distribution = createDynamicOnlyDistribution({
2009
+ allShares: keySharesToBackup
2010
+ });
2011
+ }
2012
+ const backupData = await this.backupSharesWithDistribution({
2013
+ accountAddress,
2014
+ password,
2015
+ signedSessionId,
2016
+ distribution,
2017
+ preserveDelegatedLocation
2018
+ });
2019
+ return _extends({}, backupData, {
2020
+ keyShareIds: backupData.locationsWithKeyShares.map((ks)=>ks.keyShareId)
2021
+ });
2022
+ }
1916
2023
  async storeEncryptedBackupByWalletWithRetry({ accountAddress, clientKeyShares, password, signedSessionId }) {
1917
2024
  await retryPromise(()=>this.storeEncryptedBackupByWallet({
1918
2025
  accountAddress,
@@ -2102,14 +2209,18 @@ class DynamicWalletClient {
2102
2209
  return (_ks_externalKeyShareId = ks.externalKeyShareId) != null ? _ks_externalKeyShareId : '';
2103
2210
  });
2104
2211
  } else {
2105
- // Already 2-of-3, only call backup
2106
- const data = await this.storeEncryptedBackupByWallet({
2212
+ await this.storeEncryptedBackupByWallet({
2107
2213
  accountAddress,
2108
2214
  password,
2109
2215
  signedSessionId,
2110
2216
  backupToGoogleDrive: true
2111
2217
  });
2112
- return data.keyShareIds;
2218
+ const backupInfo = this.walletMap[accountAddress].clientKeySharesBackupInfo;
2219
+ const googleDriveShares = backupInfo.backups[core.BackupLocation.GOOGLE_DRIVE] || [];
2220
+ return googleDriveShares.map((ks)=>{
2221
+ var _ks_externalKeyShareId;
2222
+ return (_ks_externalKeyShareId = ks.externalKeyShareId) != null ? _ks_externalKeyShareId : '';
2223
+ });
2113
2224
  }
2114
2225
  } catch (error) {
2115
2226
  logError({
@@ -2703,7 +2814,12 @@ exports.ERROR_SIGN_MESSAGE = ERROR_SIGN_MESSAGE;
2703
2814
  exports.ERROR_SIGN_TYPED_DATA = ERROR_SIGN_TYPED_DATA;
2704
2815
  exports.ERROR_VERIFY_MESSAGE_SIGNATURE = ERROR_VERIFY_MESSAGE_SIGNATURE;
2705
2816
  exports.ERROR_VERIFY_TRANSACTION_SIGNATURE = ERROR_VERIFY_TRANSACTION_SIGNATURE;
2817
+ exports.createAddGoogleDriveToExistingDelegationDistribution = createAddGoogleDriveToExistingDelegationDistribution;
2706
2818
  exports.createBackupData = createBackupData;
2819
+ exports.createDelegationOnlyDistribution = createDelegationOnlyDistribution;
2820
+ exports.createDelegationWithGoogleDriveDistribution = createDelegationWithGoogleDriveDistribution;
2821
+ exports.createDynamicOnlyDistribution = createDynamicOnlyDistribution;
2822
+ exports.createGoogleDriveOnlyDistribution = createGoogleDriveOnlyDistribution;
2707
2823
  exports.downloadStringAsFile = downloadStringAsFile;
2708
2824
  exports.formatEvmMessage = formatEvmMessage;
2709
2825
  exports.formatMessage = formatMessage;
@@ -2712,6 +2828,8 @@ exports.getClientKeyShareExportFileName = getClientKeyShareExportFileName;
2712
2828
  exports.getGoogleOAuthAccountId = getGoogleOAuthAccountId;
2713
2829
  exports.getMPCSignatureScheme = getMPCSignatureScheme;
2714
2830
  exports.getMPCSigner = getMPCSigner;
2831
+ exports.hasDelegatedBackup = hasDelegatedBackup;
2832
+ exports.hasGoogleDriveBackup = hasGoogleDriveBackup;
2715
2833
  exports.isBrowser = isBrowser;
2716
2834
  exports.isHexString = isHexString;
2717
2835
  exports.mergeUniqueKeyShares = mergeUniqueKeyShares;
package/index.esm.js CHANGED
@@ -814,6 +814,43 @@ const localStorageWriteTest = {
814
814
  }
815
815
  });
816
816
 
817
+ const createDelegationWithGoogleDriveDistribution = ({ existingShares, delegatedShare })=>({
818
+ dynamicBackendShares: existingShares,
819
+ googleDriveShares: existingShares,
820
+ delegatedShare
821
+ });
822
+ const createDelegationOnlyDistribution = ({ existingShares, delegatedShare })=>({
823
+ dynamicBackendShares: existingShares,
824
+ googleDriveShares: [],
825
+ delegatedShare
826
+ });
827
+ const createGoogleDriveOnlyDistribution = ({ allShares })=>({
828
+ dynamicBackendShares: allShares.slice(0, -1),
829
+ googleDriveShares: allShares.slice(-1)
830
+ });
831
+ const createDynamicOnlyDistribution = ({ allShares })=>({
832
+ dynamicBackendShares: allShares,
833
+ googleDriveShares: []
834
+ });
835
+ const hasGoogleDriveBackup = (backupInfo)=>{
836
+ var _backupInfo_backups_BackupLocation_GOOGLE_DRIVE, _backupInfo_backups;
837
+ var _backupInfo_backups_BackupLocation_GOOGLE_DRIVE_length;
838
+ return ((_backupInfo_backups_BackupLocation_GOOGLE_DRIVE_length = backupInfo == null ? void 0 : (_backupInfo_backups = backupInfo.backups) == null ? void 0 : (_backupInfo_backups_BackupLocation_GOOGLE_DRIVE = _backupInfo_backups[BackupLocation.GOOGLE_DRIVE]) == null ? void 0 : _backupInfo_backups_BackupLocation_GOOGLE_DRIVE.length) != null ? _backupInfo_backups_BackupLocation_GOOGLE_DRIVE_length : 0) > 0;
839
+ };
840
+ const hasDelegatedBackup = (backupInfo)=>{
841
+ var _backupInfo_backups_BackupLocation_DELEGATED, _backupInfo_backups;
842
+ var _backupInfo_backups_BackupLocation_DELEGATED_length;
843
+ return ((_backupInfo_backups_BackupLocation_DELEGATED_length = backupInfo == null ? void 0 : (_backupInfo_backups = backupInfo.backups) == null ? void 0 : (_backupInfo_backups_BackupLocation_DELEGATED = _backupInfo_backups[BackupLocation.DELEGATED]) == null ? void 0 : _backupInfo_backups_BackupLocation_DELEGATED.length) != null ? _backupInfo_backups_BackupLocation_DELEGATED_length : 0) > 0;
844
+ };
845
+ /**
846
+ * Distribution for adding Google Drive backup to an existing delegation.
847
+ * Client's shares go to both Dynamic and Google Drive.
848
+ * delegatedShare is undefined - we don't re-publish, but preserve the location.
849
+ */ const createAddGoogleDriveToExistingDelegationDistribution = ({ clientShares })=>({
850
+ dynamicBackendShares: clientShares,
851
+ googleDriveShares: clientShares
852
+ });
853
+
817
854
  class DynamicWalletClient {
818
855
  async initializeForwardMPCClient() {
819
856
  try {
@@ -1495,14 +1532,42 @@ class DynamicWalletClient {
1495
1532
  clientKeyShares: clientKeysharesToLocalStorage,
1496
1533
  overwriteOrMerge: 'overwrite'
1497
1534
  });
1498
- // if delegateToProjectEnvironment is true, we need to update location for the delegated share
1499
- const delegatedKeyshare = delegateToProjectEnvironment ? newReshareResults[0] : undefined;
1500
- await this.storeEncryptedBackupByWallet({
1535
+ const allClientShares = [
1536
+ ...existingReshareResults,
1537
+ ...newReshareResults
1538
+ ];
1539
+ let distribution;
1540
+ if (delegateToProjectEnvironment && backupToGoogleDrive) {
1541
+ // Delegation + Google Drive: Client's existing share backs up to both Dynamic and Google Drive.
1542
+ // The new share goes to the webhook for delegation.
1543
+ distribution = createDelegationWithGoogleDriveDistribution({
1544
+ existingShares: existingReshareResults,
1545
+ delegatedShare: newReshareResults[0]
1546
+ });
1547
+ } else if (delegateToProjectEnvironment) {
1548
+ // Delegation only: Client's existing share backs up to Dynamic.
1549
+ // The new share goes to the webhook for delegation. No Google Drive backup.
1550
+ distribution = createDelegationOnlyDistribution({
1551
+ existingShares: existingReshareResults,
1552
+ delegatedShare: newReshareResults[0]
1553
+ });
1554
+ } else if (backupToGoogleDrive) {
1555
+ // Google Drive only: Split shares between Dynamic (N-1) and Google Drive (1).
1556
+ // The last share (new share) goes to Google Drive.
1557
+ distribution = createGoogleDriveOnlyDistribution({
1558
+ allShares: allClientShares
1559
+ });
1560
+ } else {
1561
+ // No delegation, no Google Drive: All shares go to Dynamic backend only.
1562
+ distribution = createDynamicOnlyDistribution({
1563
+ allShares: allClientShares
1564
+ });
1565
+ }
1566
+ await this.backupSharesWithDistribution({
1501
1567
  accountAddress,
1502
1568
  password,
1503
1569
  signedSessionId,
1504
- backupToGoogleDrive,
1505
- delegatedKeyshare
1570
+ distribution
1506
1571
  });
1507
1572
  } catch (error) {
1508
1573
  logError({
@@ -1531,6 +1596,7 @@ class DynamicWalletClient {
1531
1596
  }
1532
1597
  async performDelegationOperation({ accountAddress, password, signedSessionId, mfaToken, newThresholdSignatureScheme, revokeDelegation = false, operationName }) {
1533
1598
  try {
1599
+ var _this_walletMap_accountAddress;
1534
1600
  const delegateToProjectEnvironment = this.featureFlags && this.featureFlags[FEATURE_FLAGS.ENABLE_DELEGATED_KEY_SHARES_FLAG] === true;
1535
1601
  if (!delegateToProjectEnvironment) {
1536
1602
  throw new Error('Delegation is not allowed for this project environment');
@@ -1552,7 +1618,7 @@ class DynamicWalletClient {
1552
1618
  newThresholdSignatureScheme,
1553
1619
  password,
1554
1620
  signedSessionId,
1555
- backupToGoogleDrive: false,
1621
+ backupToGoogleDrive: hasGoogleDriveBackup((_this_walletMap_accountAddress = this.walletMap[accountAddress]) == null ? void 0 : _this_walletMap_accountAddress.clientKeySharesBackupInfo),
1556
1622
  delegateToProjectEnvironment: true,
1557
1623
  mfaToken,
1558
1624
  revokeDelegation
@@ -1756,47 +1822,14 @@ class DynamicWalletClient {
1756
1822
  });
1757
1823
  await ((_this_storage = this.storage) == null ? void 0 : _this_storage.setItem(accountAddress, stringifiedClientKeyShares));
1758
1824
  }
1759
- /**
1760
- * Central backup orchestrator that encrypts and stores wallet key shares.
1761
- *
1762
- * This method serves as the main backup coordinator, handling the distribution of encrypted
1763
- * key shares between Dynamic's backend and Google Drive based on the wallet's threshold scheme.
1764
- * It is used by multiple operations including reshare, refresh, and manual backup requests.
1765
- *
1766
- * **Backup Distribution Strategy:**
1767
- * - **Single share wallets**: All shares stored on Dynamic's backend only
1768
- * - **Multi-share wallets (2+)**: When backing up to Google Drive, N-1 shares on Dynamic's backend, 1 share on Google Drive
1769
- * - **Multi-share wallets (2+)**: When not backing up to Google Drive, all shares on Dynamic's backend
1770
- *
1771
- * **Process Flow:**
1772
- * 1. Encrypts all client key shares with the provided password (or environment ID if no password)
1773
- * 2. For multi-share wallets (2+): conditionally distributes N-1 to backend, 1 to Google Drive
1774
- * 3. For other configurations: stores all shares on Dynamic's backend
1775
- * 4. Updates backup metadata and synchronizes wallet state
1776
- * 5. Persists the updated wallet map to local storage
1777
- *
1778
- * **Delegated Key Shares:**
1779
- * - When delegatedKeyshare is provided, the method will not store the delegated key share but it will mark the delegated share as backed up on Dynamic's backend
1780
- * - and encrypt the delegated key share to publish it to the webhook
1781
- *
1782
- * @param params - The backup operation parameters
1783
- * @param params.accountAddress - The account address of the wallet to backup
1784
- * @param params.clientKeyShares - Optional specific key shares to backup (uses localStorage if not provided)
1785
- * @param params.password - Optional password for encryption (uses environment ID if not provided)
1786
- * @param params.signedSessionId - Optional signed session ID for authentication
1787
- * @param params.backupToGoogleDrive - Whether to backup to Google Drive (defaults to false)
1788
- * @returns Promise with backup metadata including share locations and IDs
1789
- */ async storeEncryptedBackupByWallet({ accountAddress, clientKeyShares = undefined, password = undefined, signedSessionId, backupToGoogleDrive = false, delegatedKeyshare = undefined }) {
1825
+ async backupSharesWithDistribution({ accountAddress, password, signedSessionId, distribution, preserveDelegatedLocation = false }) {
1790
1826
  const dynamicRequestId = v4();
1791
1827
  try {
1792
- var _this_walletMap_accountAddress, _this_walletMap_accountAddress_clientKeySharesBackupInfo_backups_BackupLocation_GOOGLE_DRIVE, _this_walletMap_accountAddress_clientKeySharesBackupInfo_backups, _this_walletMap_accountAddress_clientKeySharesBackupInfo, _this_walletMap_accountAddress1;
1793
- const keySharesToBackup = clientKeyShares != null ? clientKeyShares : await this.getClientKeySharesFromLocalStorage({
1794
- accountAddress
1795
- });
1828
+ var _this_walletMap_accountAddress;
1796
1829
  if (!((_this_walletMap_accountAddress = this.walletMap[accountAddress]) == null ? void 0 : _this_walletMap_accountAddress.walletId)) {
1797
1830
  const error = new Error(`WalletId not found for accountAddress ${accountAddress}`);
1798
1831
  logError({
1799
- message: 'Error in storeEncryptedBackupByWallet, wallet or walletId not found from the wallet map',
1832
+ message: 'Error in backupSharesWithDistribution, wallet or walletId not found from the wallet map',
1800
1833
  error,
1801
1834
  context: {
1802
1835
  accountAddress,
@@ -1805,58 +1838,44 @@ class DynamicWalletClient {
1805
1838
  });
1806
1839
  throw error;
1807
1840
  }
1808
- // TODO(zfaizal2): throw error if signedSessionId is not provided after service deploy
1809
- let dynamicClientKeyShares = [];
1810
- let googleDriveKeyShares = [];
1811
- const encryptedKeyShares = await Promise.all(keySharesToBackup.map((keyShare)=>this.encryptKeyShare({
1812
- keyShare,
1813
- password
1814
- })));
1815
- const hasExistingGoogleDriveBackup = ((_this_walletMap_accountAddress1 = this.walletMap[accountAddress]) == null ? void 0 : (_this_walletMap_accountAddress_clientKeySharesBackupInfo = _this_walletMap_accountAddress1.clientKeySharesBackupInfo) == null ? void 0 : (_this_walletMap_accountAddress_clientKeySharesBackupInfo_backups = _this_walletMap_accountAddress_clientKeySharesBackupInfo.backups) == null ? void 0 : (_this_walletMap_accountAddress_clientKeySharesBackupInfo_backups_BackupLocation_GOOGLE_DRIVE = _this_walletMap_accountAddress_clientKeySharesBackupInfo_backups[BackupLocation.GOOGLE_DRIVE]) == null ? void 0 : _this_walletMap_accountAddress_clientKeySharesBackupInfo_backups_BackupLocation_GOOGLE_DRIVE.length) > 0;
1816
- // Backup to Google Drive if:
1817
- // 1. Explicitly requested via flag, OR
1818
- // 2. User already has Google Drive backups
1819
- const shouldBackupToGoogleDrive = backupToGoogleDrive || hasExistingGoogleDriveBackup;
1820
- if (shouldBackupToGoogleDrive && keySharesToBackup.length >= 2) {
1821
- // For 2 shares: 1 to backend, 1 to Google Drive
1822
- // For 3+ shares: N-1 to backend, 1 to Google Drive
1823
- const googleDriveShareCount = 1;
1824
- dynamicClientKeyShares = encryptedKeyShares.slice(0, -googleDriveShareCount);
1825
- googleDriveKeyShares = encryptedKeyShares.slice(-googleDriveShareCount);
1826
- } else {
1827
- dynamicClientKeyShares = encryptedKeyShares;
1828
- }
1829
- const data = await this.apiClient.storeEncryptedBackupByWallet({
1830
- walletId: this.walletMap[accountAddress].walletId,
1831
- encryptedKeyShares: dynamicClientKeyShares,
1832
- passwordEncrypted: Boolean(password) && password !== this.environmentId,
1833
- encryptionVersion: ENCRYPTION_VERSION_CURRENT,
1834
- signedSessionId,
1835
- authMode: this.authMode,
1836
- requiresSignedSessionId: this.requiresSignedSessionId(),
1837
- dynamicRequestId
1838
- });
1839
- if (data.keyShareIds.length === 0) {
1840
- throw new Error('No key shares were backed up');
1841
- }
1842
- const locations = [
1843
- {
1841
+ const locations = [];
1842
+ if (distribution.dynamicBackendShares.length > 0) {
1843
+ const encryptedDynamicShares = await Promise.all(distribution.dynamicBackendShares.map((keyShare)=>this.encryptKeyShare({
1844
+ keyShare,
1845
+ password
1846
+ })));
1847
+ const data = await this.apiClient.storeEncryptedBackupByWallet({
1848
+ walletId: this.walletMap[accountAddress].walletId,
1849
+ encryptedKeyShares: encryptedDynamicShares,
1850
+ passwordEncrypted: Boolean(password) && password !== this.environmentId,
1851
+ encryptionVersion: ENCRYPTION_VERSION_CURRENT,
1852
+ signedSessionId,
1853
+ authMode: this.authMode,
1854
+ requiresSignedSessionId: this.requiresSignedSessionId(),
1855
+ dynamicRequestId
1856
+ });
1857
+ if (data.keyShareIds.length === 0) {
1858
+ throw new Error('No key shares were backed up to Dynamic backend');
1859
+ }
1860
+ locations.push({
1844
1861
  location: BackupLocation.DYNAMIC,
1845
1862
  externalKeyShareId: data.keyShareIds[0]
1846
- }
1847
- ];
1848
- if (googleDriveKeyShares.length > 0) {
1863
+ });
1864
+ }
1865
+ if (distribution.googleDriveShares.length > 0) {
1866
+ const encryptedGoogleDriveShares = await Promise.all(distribution.googleDriveShares.map((keyShare)=>this.encryptKeyShare({
1867
+ keyShare,
1868
+ password
1869
+ })));
1849
1870
  await this.uploadKeySharesToGoogleDrive({
1850
1871
  accountAddress,
1851
- encryptedKeyShares: googleDriveKeyShares
1872
+ encryptedKeyShares: encryptedGoogleDriveShares
1852
1873
  });
1853
1874
  locations.push({
1854
1875
  location: BackupLocation.GOOGLE_DRIVE
1855
1876
  });
1856
1877
  }
1857
- // if delegatedKeyshare is provided, we encrypt the delegated key share and publish it to the webhook
1858
- // after publish confirmed, we mark the delegated share as backed up on Dynamic's backend
1859
- if (delegatedKeyshare) {
1878
+ if (distribution.delegatedShare) {
1860
1879
  var _publicKey_key, _publicKey_key1, _publicKey_key2;
1861
1880
  const publicKey = await this.apiClient.getDelegatedEncryptionKey({
1862
1881
  environmentId: this.environmentId
@@ -1865,7 +1884,7 @@ class DynamicWalletClient {
1865
1884
  throw new Error('Public key not found');
1866
1885
  }
1867
1886
  var _publicKey_key_keyId;
1868
- const encryptedDelegatedKeyShareEnvelope = await encryptDelegatedKeyShare(JSON.stringify(delegatedKeyshare), publicKey == null ? void 0 : (_publicKey_key1 = publicKey.key) == null ? void 0 : _publicKey_key1.publicKeyPemB64, (_publicKey_key_keyId = publicKey == null ? void 0 : (_publicKey_key2 = publicKey.key) == null ? void 0 : _publicKey_key2.keyId) != null ? _publicKey_key_keyId : publicKey == null ? void 0 : publicKey.keyId);
1887
+ const encryptedDelegatedKeyShareEnvelope = await encryptDelegatedKeyShare(JSON.stringify(distribution.delegatedShare), publicKey == null ? void 0 : (_publicKey_key1 = publicKey.key) == null ? void 0 : _publicKey_key1.publicKeyPemB64, (_publicKey_key_keyId = publicKey == null ? void 0 : (_publicKey_key2 = publicKey.key) == null ? void 0 : _publicKey_key2.keyId) != null ? _publicKey_key_keyId : publicKey == null ? void 0 : publicKey.keyId);
1869
1888
  const { status } = await this.apiClient.publishDelegatedKeyShare({
1870
1889
  walletId: this.walletMap[accountAddress].walletId,
1871
1890
  encryptedKeyShare: encryptedDelegatedKeyShareEnvelope,
@@ -1880,6 +1899,12 @@ class DynamicWalletClient {
1880
1899
  location: BackupLocation.DELEGATED
1881
1900
  });
1882
1901
  }
1902
+ // Preserve existing delegated location without re-publishing
1903
+ if (preserveDelegatedLocation && !distribution.delegatedShare) {
1904
+ locations.push({
1905
+ location: BackupLocation.DELEGATED
1906
+ });
1907
+ }
1883
1908
  const backupData = await this.apiClient.markKeySharesAsBackedUp({
1884
1909
  walletId: this.walletMap[accountAddress].walletId,
1885
1910
  locations,
@@ -1901,10 +1926,10 @@ class DynamicWalletClient {
1901
1926
  clientKeySharesBackupInfo: updatedBackupInfo
1902
1927
  });
1903
1928
  await this.storage.setItem(this.storageKey, JSON.stringify(this.walletMap));
1904
- return data;
1929
+ return backupData;
1905
1930
  } catch (error) {
1906
1931
  logError({
1907
- message: 'Error in storeEncryptedBackupByWallet',
1932
+ message: 'Error in backupSharesWithDistribution',
1908
1933
  error: error,
1909
1934
  context: {
1910
1935
  accountAddress,
@@ -1914,6 +1939,88 @@ class DynamicWalletClient {
1914
1939
  throw error;
1915
1940
  }
1916
1941
  }
1942
+ /**
1943
+ * Central backup orchestrator that encrypts and stores wallet key shares.
1944
+ *
1945
+ * This method serves as the main backup coordinator, handling the distribution of encrypted
1946
+ * key shares between Dynamic's backend and Google Drive based on the wallet's threshold scheme.
1947
+ * It is used by multiple operations including reshare, refresh, and manual backup requests.
1948
+ *
1949
+ * **Backup Distribution Strategy:**
1950
+ * - **Single share wallets**: All shares stored on Dynamic's backend only
1951
+ * - **Multi-share wallets (2+)**: When backing up to Google Drive, N-1 shares on Dynamic's backend, 1 share on Google Drive
1952
+ * - **Multi-share wallets (2+)**: When not backing up to Google Drive, all shares on Dynamic's backend
1953
+ *
1954
+ * **Process Flow:**
1955
+ * 1. Encrypts all client key shares with the provided password (or environment ID if no password)
1956
+ * 2. For multi-share wallets (2+): conditionally distributes N-1 to backend, 1 to Google Drive
1957
+ * 3. For other configurations: stores all shares on Dynamic's backend
1958
+ * 4. Updates backup metadata and synchronizes wallet state
1959
+ * 5. Persists the updated wallet map to local storage
1960
+ *
1961
+ * **Delegated Key Shares:**
1962
+ * - When delegatedKeyshare is provided, the method will not store the delegated key share but it will mark the delegated share as backed up on Dynamic's backend
1963
+ * - and encrypt the delegated key share to publish it to the webhook
1964
+ *
1965
+ * @param params - The backup operation parameters
1966
+ * @param params.accountAddress - The account address of the wallet to backup
1967
+ * @param params.clientKeyShares - Optional specific key shares to backup (uses localStorage if not provided)
1968
+ * @param params.password - Optional password for encryption (uses environment ID if not provided)
1969
+ * @param params.signedSessionId - Optional signed session ID for authentication
1970
+ * @param params.backupToGoogleDrive - Whether to backup to Google Drive (defaults to false)
1971
+ * @returns Promise with backup metadata including share locations and IDs
1972
+ */ async storeEncryptedBackupByWallet({ accountAddress, clientKeyShares = undefined, password = undefined, signedSessionId, backupToGoogleDrive = false, delegatedKeyshare = undefined }) {
1973
+ var _this_walletMap_accountAddress, _this_walletMap_accountAddress1;
1974
+ const keySharesToBackup = clientKeyShares != null ? clientKeyShares : await this.getClientKeySharesFromLocalStorage({
1975
+ accountAddress
1976
+ });
1977
+ const shouldBackupToGoogleDrive = backupToGoogleDrive || hasGoogleDriveBackup((_this_walletMap_accountAddress = this.walletMap[accountAddress]) == null ? void 0 : _this_walletMap_accountAddress.clientKeySharesBackupInfo);
1978
+ const hasExistingDelegation = hasDelegatedBackup((_this_walletMap_accountAddress1 = this.walletMap[accountAddress]) == null ? void 0 : _this_walletMap_accountAddress1.clientKeySharesBackupInfo);
1979
+ let distribution;
1980
+ let preserveDelegatedLocation = false;
1981
+ if (delegatedKeyshare && shouldBackupToGoogleDrive) {
1982
+ // NEW delegation + Google Drive: Client's shares back up to both Dynamic and Google Drive.
1983
+ // The delegated share goes to the webhook.
1984
+ distribution = createDelegationWithGoogleDriveDistribution({
1985
+ existingShares: keySharesToBackup,
1986
+ delegatedShare: delegatedKeyshare
1987
+ });
1988
+ } else if (delegatedKeyshare) {
1989
+ // NEW delegation only: Client's shares back up to Dynamic.
1990
+ // The delegated share goes to the webhook. No Google Drive backup.
1991
+ distribution = createDelegationOnlyDistribution({
1992
+ existingShares: keySharesToBackup,
1993
+ delegatedShare: delegatedKeyshare
1994
+ });
1995
+ } else if (hasExistingDelegation && shouldBackupToGoogleDrive) {
1996
+ // ADD Google Drive to EXISTING delegation: Client's share backs up to both Dynamic and GD.
1997
+ // Don't re-publish delegated share, just preserve the location.
1998
+ distribution = createAddGoogleDriveToExistingDelegationDistribution({
1999
+ clientShares: keySharesToBackup
2000
+ });
2001
+ preserveDelegatedLocation = true;
2002
+ } else if (shouldBackupToGoogleDrive && keySharesToBackup.length >= 2) {
2003
+ // Google Drive only (no delegation): Split shares between Dynamic (N-1) and Google Drive (1).
2004
+ distribution = createGoogleDriveOnlyDistribution({
2005
+ allShares: keySharesToBackup
2006
+ });
2007
+ } else {
2008
+ // No delegation, no Google Drive: All shares go to Dynamic backend only.
2009
+ distribution = createDynamicOnlyDistribution({
2010
+ allShares: keySharesToBackup
2011
+ });
2012
+ }
2013
+ const backupData = await this.backupSharesWithDistribution({
2014
+ accountAddress,
2015
+ password,
2016
+ signedSessionId,
2017
+ distribution,
2018
+ preserveDelegatedLocation
2019
+ });
2020
+ return _extends({}, backupData, {
2021
+ keyShareIds: backupData.locationsWithKeyShares.map((ks)=>ks.keyShareId)
2022
+ });
2023
+ }
1917
2024
  async storeEncryptedBackupByWalletWithRetry({ accountAddress, clientKeyShares, password, signedSessionId }) {
1918
2025
  await retryPromise(()=>this.storeEncryptedBackupByWallet({
1919
2026
  accountAddress,
@@ -2103,14 +2210,18 @@ class DynamicWalletClient {
2103
2210
  return (_ks_externalKeyShareId = ks.externalKeyShareId) != null ? _ks_externalKeyShareId : '';
2104
2211
  });
2105
2212
  } else {
2106
- // Already 2-of-3, only call backup
2107
- const data = await this.storeEncryptedBackupByWallet({
2213
+ await this.storeEncryptedBackupByWallet({
2108
2214
  accountAddress,
2109
2215
  password,
2110
2216
  signedSessionId,
2111
2217
  backupToGoogleDrive: true
2112
2218
  });
2113
- return data.keyShareIds;
2219
+ const backupInfo = this.walletMap[accountAddress].clientKeySharesBackupInfo;
2220
+ const googleDriveShares = backupInfo.backups[BackupLocation.GOOGLE_DRIVE] || [];
2221
+ return googleDriveShares.map((ks)=>{
2222
+ var _ks_externalKeyShareId;
2223
+ return (_ks_externalKeyShareId = ks.externalKeyShareId) != null ? _ks_externalKeyShareId : '';
2224
+ });
2114
2225
  }
2115
2226
  } catch (error) {
2116
2227
  logError({
@@ -2642,4 +2753,4 @@ const ERROR_VERIFY_TRANSACTION_SIGNATURE = '[DynamicWaasWalletClient]: Error ver
2642
2753
  const ERROR_EXPORT_PRIVATE_KEY = '[DynamicWaasWalletClient]: Error exporting private key';
2643
2754
  const ERROR_IMPORT_PRIVATE_KEY = '[DynamicWaasWalletClient]: Error importing private key';
2644
2755
 
2645
- export { DynamicWalletClient, ERROR_ACCOUNT_ADDRESS_REQUIRED, ERROR_CREATE_WALLET_ACCOUNT, ERROR_EXPORT_PRIVATE_KEY, ERROR_IMPORT_PRIVATE_KEY, ERROR_KEYGEN_FAILED, ERROR_SIGN_MESSAGE, ERROR_SIGN_TYPED_DATA, ERROR_VERIFY_MESSAGE_SIGNATURE, ERROR_VERIFY_TRANSACTION_SIGNATURE, createBackupData, downloadStringAsFile, formatEvmMessage, formatMessage, getClientKeyShareBackupInfo, getClientKeyShareExportFileName, getGoogleOAuthAccountId, getMPCSignatureScheme, getMPCSigner, isBrowser, isHexString, mergeUniqueKeyShares, retryPromise, timeoutPromise };
2756
+ export { DynamicWalletClient, ERROR_ACCOUNT_ADDRESS_REQUIRED, ERROR_CREATE_WALLET_ACCOUNT, ERROR_EXPORT_PRIVATE_KEY, ERROR_IMPORT_PRIVATE_KEY, ERROR_KEYGEN_FAILED, ERROR_SIGN_MESSAGE, ERROR_SIGN_TYPED_DATA, ERROR_VERIFY_MESSAGE_SIGNATURE, ERROR_VERIFY_TRANSACTION_SIGNATURE, createAddGoogleDriveToExistingDelegationDistribution, createBackupData, createDelegationOnlyDistribution, createDelegationWithGoogleDriveDistribution, createDynamicOnlyDistribution, createGoogleDriveOnlyDistribution, downloadStringAsFile, formatEvmMessage, formatMessage, getClientKeyShareBackupInfo, getClientKeyShareExportFileName, getGoogleOAuthAccountId, getMPCSignatureScheme, getMPCSigner, hasDelegatedBackup, hasGoogleDriveBackup, isBrowser, isHexString, mergeUniqueKeyShares, retryPromise, timeoutPromise };
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@dynamic-labs-wallet/browser",
3
- "version": "0.0.211",
3
+ "version": "0.0.212",
4
4
  "license": "Licensed under the Dynamic Labs, Inc. Terms Of Service (https://www.dynamic.xyz/terms-conditions)",
5
5
  "type": "module",
6
6
  "dependencies": {
7
- "@dynamic-labs-wallet/core": "0.0.211",
7
+ "@dynamic-labs-wallet/core": "0.0.212",
8
8
  "@dynamic-labs/logger": "^4.25.3",
9
9
  "@dynamic-labs/sdk-api-core": "^0.0.818",
10
10
  "argon2id": "1.0.1",
package/src/client.d.ts CHANGED
@@ -3,7 +3,7 @@ import { AuthMode, BackupLocation, type BackupLocationWithExternalKeyShareId, Dy
3
3
  import type { SignMessageContext } from '@dynamic-labs/sdk-api-core';
4
4
  import type { ClientInitKeygenResult, ClientKeyShare } from './mpc/types.js';
5
5
  import { type SupportedStorage } from './services/localStorage.js';
6
- import type { WalletProperties } from './types.js';
6
+ import { type ShareDistribution, type WalletProperties } from './types.js';
7
7
  export declare class DynamicWalletClient {
8
8
  environmentId: string;
9
9
  storageKey: string;
@@ -224,6 +224,21 @@ export declare class DynamicWalletClient {
224
224
  clientKeyShares: ClientKeyShare[];
225
225
  overwriteOrMerge?: 'overwrite' | 'merge';
226
226
  }): Promise<void>;
227
+ backupSharesWithDistribution({ accountAddress, password, signedSessionId, distribution, preserveDelegatedLocation, }: {
228
+ accountAddress: string;
229
+ password?: string;
230
+ signedSessionId: string;
231
+ distribution: ShareDistribution;
232
+ preserveDelegatedLocation?: boolean;
233
+ }): Promise<{
234
+ message: string;
235
+ walletId: string;
236
+ locationsWithKeyShares: {
237
+ location: BackupLocation;
238
+ keyShareId: string;
239
+ externalKeyShareId?: string;
240
+ }[];
241
+ }>;
227
242
  /**
228
243
  * Central backup orchestrator that encrypts and stores wallet key shares.
229
244
  *
@@ -261,8 +276,17 @@ export declare class DynamicWalletClient {
261
276
  password?: string;
262
277
  signedSessionId: string;
263
278
  backupToGoogleDrive?: boolean;
264
- delegatedKeyshare?: any;
265
- }): Promise<any>;
279
+ delegatedKeyshare?: ClientKeyShare;
280
+ }): Promise<{
281
+ keyShareIds: string[];
282
+ message: string;
283
+ walletId: string;
284
+ locationsWithKeyShares: {
285
+ location: BackupLocation;
286
+ keyShareId: string;
287
+ externalKeyShareId?: string;
288
+ }[];
289
+ }>;
266
290
  storeEncryptedBackupByWalletWithRetry({ accountAddress, clientKeyShares, password, signedSessionId, }: {
267
291
  accountAddress: string;
268
292
  clientKeyShares?: ClientKeyShare[];
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../packages/src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,kBAAkB,EAElB,iBAAiB,EACjB,KAAK,cAAc,EACnB,cAAc,EAEd,6BAA6B,EAC7B,WAAW,EACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,QAAQ,EAER,cAAc,EACd,KAAK,oCAAoC,EACzC,gBAAgB,EAChB,KAAK,wBAAwB,EAE7B,KAAK,YAAY,EAOjB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EAIvB,wBAAwB,EAExB,eAAe,E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G,4BAA4B,CAAC,EACjC,cAAc,EACd,eAAiD,GAClD,EAAE;QACD,cAAc,EAAE,MAAM,CAAC;QACvB,eAAe,CAAC,EAAE,eAAe,CAAC;KACnC,GAAG,OAAO,CAAC,OAAO,CAAC;IAYpB;;OAEG;IACG,uCAAuC,CAAC,EAC5C,cAAc,EACd,eAAiD,GAClD,EAAE;QACD,cAAc,EAAE,MAAM,CAAC;QACvB,eAAe,CAAC,EAAE,eAAe,CAAC;KACnC,GAAG,OAAO,CAAC,OAAO,CAAC;IAgCd,iCAAiC,CAAC,EACtC,cAAc,GACf,EAAE;QACD,cAAc,EAAE,MAAM,CAAC;KACxB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAiCzB,SAAS,CAAC,EACd,cAAc,EACd,eAA8C,EAC9C,UAAsB,EACtB,QAAoB,EACpB,eAAe,GAChB,EAAE;QACD,cAAc,EAAE,MAAM,CAAC;QACvB,eAAe,CAAC,EAAE,eAAe,CAAC;QAClC,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,eAAe,EAAE,MAAM,CAAC;KACzB;IAmGK,UAAU;IAgDhB;;;OAGG;IACH,aAAa,CAAC,SAAS,EAAE,MAAM;CAOhC"}
package/src/types.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import type { KeyShareBackupInfo, ThresholdSignatureScheme } from '@dynamic-labs-wallet/core';
1
+ import { type KeyShareBackupInfo, type ThresholdSignatureScheme } from '@dynamic-labs-wallet/core';
2
+ import type { ClientKeyShare } from './mpc/types.js';
2
3
  export interface WalletProperties {
3
4
  chainName: string;
4
5
  walletId: string;
@@ -7,4 +8,33 @@ export interface WalletProperties {
7
8
  thresholdSignatureScheme: ThresholdSignatureScheme;
8
9
  derivationPath?: string;
9
10
  }
11
+ export type ShareDistribution = {
12
+ dynamicBackendShares: ClientKeyShare[];
13
+ googleDriveShares: ClientKeyShare[];
14
+ delegatedShare?: ClientKeyShare;
15
+ };
16
+ export declare const createDelegationWithGoogleDriveDistribution: ({ existingShares, delegatedShare, }: {
17
+ existingShares: ClientKeyShare[];
18
+ delegatedShare: ClientKeyShare;
19
+ }) => ShareDistribution;
20
+ export declare const createDelegationOnlyDistribution: ({ existingShares, delegatedShare, }: {
21
+ existingShares: ClientKeyShare[];
22
+ delegatedShare: ClientKeyShare;
23
+ }) => ShareDistribution;
24
+ export declare const createGoogleDriveOnlyDistribution: ({ allShares, }: {
25
+ allShares: ClientKeyShare[];
26
+ }) => ShareDistribution;
27
+ export declare const createDynamicOnlyDistribution: ({ allShares, }: {
28
+ allShares: ClientKeyShare[];
29
+ }) => ShareDistribution;
30
+ export declare const hasGoogleDriveBackup: (backupInfo?: KeyShareBackupInfo) => boolean;
31
+ export declare const hasDelegatedBackup: (backupInfo?: KeyShareBackupInfo) => boolean;
32
+ /**
33
+ * Distribution for adding Google Drive backup to an existing delegation.
34
+ * Client's shares go to both Dynamic and Google Drive.
35
+ * delegatedShare is undefined - we don't re-publish, but preserve the location.
36
+ */
37
+ export declare const createAddGoogleDriveToExistingDelegationDistribution: ({ clientShares, }: {
38
+ clientShares: ClientKeyShare[];
39
+ }) => ShareDistribution;
10
40
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../packages/src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,wBAAwB,EACzB,MAAM,2BAA2B,CAAC;AAEnC,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,yBAAyB,EAAE,kBAAkB,CAAC;IAC9C,wBAAwB,EAAE,wBAAwB,CAAC;IACnD,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../packages/src/types.ts"],"names":[],"mappings":"AAAA,OAAO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