@dynamic-labs-wallet/browser 0.0.121 → 0.0.122
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 +198 -11
- package/index.esm.js +199 -12
- package/package.json +2 -2
- package/src/client.d.ts +27 -3
- package/src/client.d.ts.map +1 -1
package/index.cjs.js
CHANGED
|
@@ -618,6 +618,7 @@ class DynamicWalletClient {
|
|
|
618
618
|
sessionId,
|
|
619
619
|
userId
|
|
620
620
|
});
|
|
621
|
+
this.sessionId = sessionId;
|
|
621
622
|
} catch (error) {
|
|
622
623
|
logError({
|
|
623
624
|
message: '[DynamicWaasWalletClient] Error initializing logger context',
|
|
@@ -1075,7 +1076,7 @@ class DynamicWalletClient {
|
|
|
1075
1076
|
existingClientKeyShares
|
|
1076
1077
|
};
|
|
1077
1078
|
}
|
|
1078
|
-
async reshare({ chainName, accountAddress, oldThresholdSignatureScheme, newThresholdSignatureScheme, password = undefined, signedSessionId, backupToGoogleDrive = false }) {
|
|
1079
|
+
async reshare({ chainName, accountAddress, oldThresholdSignatureScheme, newThresholdSignatureScheme, password = undefined, signedSessionId, backupToGoogleDrive = false, delegateToProjectEnvironment = false }) {
|
|
1079
1080
|
const dynamicRequestId = uuid.v4();
|
|
1080
1081
|
try {
|
|
1081
1082
|
await this.verifyPassword({
|
|
@@ -1112,7 +1113,8 @@ class DynamicWalletClient {
|
|
|
1112
1113
|
clientKeygenIds: clientKeygenIds,
|
|
1113
1114
|
oldThresholdSignatureScheme,
|
|
1114
1115
|
newThresholdSignatureScheme,
|
|
1115
|
-
dynamicRequestId
|
|
1116
|
+
dynamicRequestId,
|
|
1117
|
+
delegateToProjectEnvironment
|
|
1116
1118
|
});
|
|
1117
1119
|
const { roomId, serverKeygenIds, newServerKeygenIds = [] } = data;
|
|
1118
1120
|
// Get the MPC config for the threshold signature scheme
|
|
@@ -1139,12 +1141,20 @@ class DynamicWalletClient {
|
|
|
1139
1141
|
clientKeyShares: reshareResults,
|
|
1140
1142
|
overwriteOrMerge: 'overwrite'
|
|
1141
1143
|
});
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1144
|
+
if (delegateToProjectEnvironment) {
|
|
1145
|
+
await this.storeEncryptedBackupByDelegatedWallet({
|
|
1146
|
+
accountAddress,
|
|
1147
|
+
password,
|
|
1148
|
+
signedSessionId
|
|
1149
|
+
});
|
|
1150
|
+
} else {
|
|
1151
|
+
await this.storeEncryptedBackupByWallet({
|
|
1152
|
+
accountAddress,
|
|
1153
|
+
password,
|
|
1154
|
+
signedSessionId,
|
|
1155
|
+
backupToGoogleDrive
|
|
1156
|
+
});
|
|
1157
|
+
}
|
|
1148
1158
|
} catch (error) {
|
|
1149
1159
|
logError({
|
|
1150
1160
|
message: '[DynamicWaasWalletClient] Error in reshare',
|
|
@@ -1161,6 +1171,88 @@ class DynamicWalletClient {
|
|
|
1161
1171
|
throw error;
|
|
1162
1172
|
}
|
|
1163
1173
|
}
|
|
1174
|
+
async sendKeySharesToDelegatedAccess({ accountAddress, chainName, delegatedKeyShares, environmentId, userId, walletId }) {
|
|
1175
|
+
try {
|
|
1176
|
+
if (!this.delegatedAccessEndpoint) {
|
|
1177
|
+
throw new Error('Cannot send key shares to delegated access because delegated access endpoint is not set');
|
|
1178
|
+
}
|
|
1179
|
+
const delegatedAccessEndpoint = this.delegatedAccessEndpoint;
|
|
1180
|
+
const response = await fetch(delegatedAccessEndpoint, {
|
|
1181
|
+
method: 'POST',
|
|
1182
|
+
body: JSON.stringify({
|
|
1183
|
+
chainName,
|
|
1184
|
+
accountAddress,
|
|
1185
|
+
delegatedKeyShares,
|
|
1186
|
+
environmentId,
|
|
1187
|
+
userId,
|
|
1188
|
+
walletId
|
|
1189
|
+
})
|
|
1190
|
+
});
|
|
1191
|
+
const data = await response.json();
|
|
1192
|
+
return data;
|
|
1193
|
+
} catch (error) {
|
|
1194
|
+
logError({
|
|
1195
|
+
message: '[DynamicWaasWalletClient] Error in sendKeySharesToDelegatedAccess',
|
|
1196
|
+
error: error,
|
|
1197
|
+
context: {
|
|
1198
|
+
accountAddress,
|
|
1199
|
+
chainName
|
|
1200
|
+
}
|
|
1201
|
+
});
|
|
1202
|
+
throw error;
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
async delegateKeyShares({ accountAddress, password = undefined, signedSessionId }) {
|
|
1206
|
+
try {
|
|
1207
|
+
const delegateToProjectEnvironment = this.featureFlags && this.featureFlags[core.FEATURE_FLAGS.ENABLE_DELEGATED_KEY_SHARES_FLAG] === true;
|
|
1208
|
+
if (!delegateToProjectEnvironment) {
|
|
1209
|
+
throw new Error('Delegation is not allowed for this project environment');
|
|
1210
|
+
}
|
|
1211
|
+
const environmentSettings = await this.apiClient.getEnvironmentSettings();
|
|
1212
|
+
const delegatedAccessEndpoint = environmentSettings.sdk.waas.delegatedAccessEndpoint;
|
|
1213
|
+
if (!delegatedAccessEndpoint) {
|
|
1214
|
+
throw new Error('Cannot delegate key shares because verified access endpoint is not set in the environment settings');
|
|
1215
|
+
}
|
|
1216
|
+
this.delegatedAccessEndpoint = delegatedAccessEndpoint;
|
|
1217
|
+
const wallet = await this.getWallet({
|
|
1218
|
+
accountAddress,
|
|
1219
|
+
walletOperation: core.WalletOperation.REACH_ALL_PARTIES,
|
|
1220
|
+
password,
|
|
1221
|
+
signedSessionId
|
|
1222
|
+
});
|
|
1223
|
+
if (wallet.chainName === 'SUI') {
|
|
1224
|
+
throw new Error('Delegation is not allowed for SUI');
|
|
1225
|
+
}
|
|
1226
|
+
const currentThresholdSignatureScheme = this.walletMap[accountAddress].thresholdSignatureScheme;
|
|
1227
|
+
if (currentThresholdSignatureScheme === core.ThresholdSignatureScheme.TWO_OF_TWO) {
|
|
1228
|
+
// Reshare to 2-of-3, which will automatically handle the backup distribution
|
|
1229
|
+
await this.reshare({
|
|
1230
|
+
chainName: this.walletMap[accountAddress].chainName,
|
|
1231
|
+
accountAddress,
|
|
1232
|
+
oldThresholdSignatureScheme: currentThresholdSignatureScheme,
|
|
1233
|
+
newThresholdSignatureScheme: core.ThresholdSignatureScheme.TWO_OF_THREE,
|
|
1234
|
+
password,
|
|
1235
|
+
signedSessionId,
|
|
1236
|
+
backupToGoogleDrive: false,
|
|
1237
|
+
delegateToProjectEnvironment: true
|
|
1238
|
+
});
|
|
1239
|
+
const backupInfo = this.walletMap[accountAddress].clientKeySharesBackupInfo;
|
|
1240
|
+
const delegatedKeyShares = backupInfo.backups[core.BackupLocation.EXTERNAL] || [];
|
|
1241
|
+
return delegatedKeyShares;
|
|
1242
|
+
} else {
|
|
1243
|
+
throw new Error('Delegation is not allowed for this threshold signature scheme');
|
|
1244
|
+
}
|
|
1245
|
+
} catch (error) {
|
|
1246
|
+
logError({
|
|
1247
|
+
message: '[DynamicWaasWalletClient] Error in delegateKeyShares',
|
|
1248
|
+
error: error,
|
|
1249
|
+
context: {
|
|
1250
|
+
accountAddress
|
|
1251
|
+
}
|
|
1252
|
+
});
|
|
1253
|
+
throw error;
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1164
1256
|
async exportKey({ accountAddress, chainName, password = undefined, signedSessionId }) {
|
|
1165
1257
|
const dynamicRequestId = uuid.v4();
|
|
1166
1258
|
try {
|
|
@@ -1352,7 +1444,7 @@ class DynamicWalletClient {
|
|
|
1352
1444
|
* @returns Promise with backup metadata including share locations and IDs
|
|
1353
1445
|
*/ async storeEncryptedBackupByWallet({ accountAddress, clientKeyShares = undefined, password = undefined, signedSessionId, backupToGoogleDrive = false }) {
|
|
1354
1446
|
try {
|
|
1355
|
-
var _this_walletMap_accountAddress;
|
|
1447
|
+
var _this_walletMap_accountAddress, _this_walletMap_accountAddress_clientKeySharesBackupInfo_backups_BackupLocation_GOOGLE_DRIVE, _this_walletMap_accountAddress_clientKeySharesBackupInfo_backups, _this_walletMap_accountAddress_clientKeySharesBackupInfo, _this_walletMap_accountAddress1;
|
|
1356
1448
|
const keySharesToBackup = clientKeyShares != null ? clientKeyShares : await this.getClientKeySharesFromLocalStorage({
|
|
1357
1449
|
accountAddress
|
|
1358
1450
|
});
|
|
@@ -1375,7 +1467,7 @@ class DynamicWalletClient {
|
|
|
1375
1467
|
keyShare,
|
|
1376
1468
|
password
|
|
1377
1469
|
})));
|
|
1378
|
-
const hasExistingGoogleDriveBackup = this.walletMap[accountAddress].clientKeySharesBackupInfo.backups[core.BackupLocation.GOOGLE_DRIVE].length > 0;
|
|
1470
|
+
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;
|
|
1379
1471
|
// Backup to Google Drive if:
|
|
1380
1472
|
// 1. Explicitly requested via flag, OR
|
|
1381
1473
|
// 2. User already has Google Drive backups
|
|
@@ -1433,6 +1525,95 @@ class DynamicWalletClient {
|
|
|
1433
1525
|
throw error;
|
|
1434
1526
|
}
|
|
1435
1527
|
}
|
|
1528
|
+
async storeEncryptedBackupByDelegatedWallet({ accountAddress, clientKeyShares = undefined, password = undefined, signedSessionId }) {
|
|
1529
|
+
try {
|
|
1530
|
+
var _this_walletMap_accountAddress, _this_walletMap_accountAddress_clientKeySharesBackupInfo_backups_BackupLocation_EXTERNAL, _this_walletMap_accountAddress_clientKeySharesBackupInfo_backups, _this_walletMap_accountAddress_clientKeySharesBackupInfo, _this_walletMap_accountAddress1;
|
|
1531
|
+
const keySharesToBackup = clientKeyShares != null ? clientKeyShares : await this.getClientKeySharesFromLocalStorage({
|
|
1532
|
+
accountAddress
|
|
1533
|
+
});
|
|
1534
|
+
if (!((_this_walletMap_accountAddress = this.walletMap[accountAddress]) == null ? void 0 : _this_walletMap_accountAddress.walletId)) {
|
|
1535
|
+
const error = new Error(`WalletId not found for accountAddress ${accountAddress}`);
|
|
1536
|
+
logError({
|
|
1537
|
+
message: '[DynamicWaasWalletClient] Error in storeEncryptedBackupByWallet, wallet or walletId not found from the wallet map',
|
|
1538
|
+
error,
|
|
1539
|
+
context: {
|
|
1540
|
+
accountAddress,
|
|
1541
|
+
walletMap: this.walletMap
|
|
1542
|
+
}
|
|
1543
|
+
});
|
|
1544
|
+
throw error;
|
|
1545
|
+
}
|
|
1546
|
+
let dynamicClientKeyShares = [];
|
|
1547
|
+
let delegatedKeyShares = [];
|
|
1548
|
+
const encryptedKeyShares = await Promise.all(keySharesToBackup.map((keyShare)=>this.encryptKeyShare({
|
|
1549
|
+
keyShare,
|
|
1550
|
+
password
|
|
1551
|
+
})));
|
|
1552
|
+
const hasExistingDelegatedBackup = ((_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_EXTERNAL = _this_walletMap_accountAddress_clientKeySharesBackupInfo_backups[core.BackupLocation.EXTERNAL]) == null ? void 0 : _this_walletMap_accountAddress_clientKeySharesBackupInfo_backups_BackupLocation_EXTERNAL.length) > 0;
|
|
1553
|
+
const shouldBackupToDelegated = hasExistingDelegatedBackup || keySharesToBackup.length >= 2;
|
|
1554
|
+
if (shouldBackupToDelegated) {
|
|
1555
|
+
// For 2 shares: 1 to backend, 1 to delegated
|
|
1556
|
+
// For 3+ shares: N-1 to backend, 1 to delegated
|
|
1557
|
+
dynamicClientKeyShares = encryptedKeyShares.slice(0, -core.DELEGATED_SHARE_COUNT);
|
|
1558
|
+
delegatedKeyShares = encryptedKeyShares.slice(-core.DELEGATED_SHARE_COUNT);
|
|
1559
|
+
} else {
|
|
1560
|
+
dynamicClientKeyShares = encryptedKeyShares;
|
|
1561
|
+
}
|
|
1562
|
+
const data = await this.apiClient.storeEncryptedBackupByWallet({
|
|
1563
|
+
walletId: this.walletMap[accountAddress].walletId,
|
|
1564
|
+
encryptedKeyShares: dynamicClientKeyShares,
|
|
1565
|
+
passwordEncrypted: Boolean(password) && password !== this.environmentId,
|
|
1566
|
+
encryptionVersion: ENCRYPTION_VERSION_CURRENT,
|
|
1567
|
+
signedSessionId
|
|
1568
|
+
});
|
|
1569
|
+
await this.apiClient.markKeySharesAsBackedUp({
|
|
1570
|
+
walletId: this.walletMap[accountAddress].walletId,
|
|
1571
|
+
location: core.BackupLocation.DYNAMIC
|
|
1572
|
+
});
|
|
1573
|
+
if (delegatedKeyShares.length > 0) {
|
|
1574
|
+
const wallet = this.walletMap[accountAddress];
|
|
1575
|
+
var _this_userId;
|
|
1576
|
+
const delegatedKeyShareIds = await this.sendKeySharesToDelegatedAccess({
|
|
1577
|
+
accountAddress,
|
|
1578
|
+
chainName: wallet.chainName,
|
|
1579
|
+
environmentId: this.environmentId,
|
|
1580
|
+
walletId: wallet.walletId,
|
|
1581
|
+
userId: (_this_userId = this.userId) != null ? _this_userId : '',
|
|
1582
|
+
delegatedKeyShares: delegatedKeyShares
|
|
1583
|
+
});
|
|
1584
|
+
data.keyShares.push({
|
|
1585
|
+
backupLocation: core.BackupLocation.EXTERNAL,
|
|
1586
|
+
id: delegatedKeyShareIds
|
|
1587
|
+
});
|
|
1588
|
+
//todo: combine with user share service backup once other branch is merged
|
|
1589
|
+
await this.apiClient.markKeySharesAsBackedUp({
|
|
1590
|
+
walletId: this.walletMap[accountAddress].walletId,
|
|
1591
|
+
location: core.BackupLocation.EXTERNAL
|
|
1592
|
+
});
|
|
1593
|
+
}
|
|
1594
|
+
const updatedBackupInfo = getClientKeyShareBackupInfo({
|
|
1595
|
+
walletProperties: {
|
|
1596
|
+
derivationPath: this.walletMap[accountAddress].derivationPath,
|
|
1597
|
+
keyShares: data.keyShares,
|
|
1598
|
+
thresholdSignatureScheme: this.walletMap[accountAddress].thresholdSignatureScheme
|
|
1599
|
+
}
|
|
1600
|
+
});
|
|
1601
|
+
this.walletMap[accountAddress] = _extends({}, this.walletMap[accountAddress], {
|
|
1602
|
+
clientKeySharesBackupInfo: updatedBackupInfo
|
|
1603
|
+
});
|
|
1604
|
+
await this.storage.setItem(this.storageKey, JSON.stringify(this.walletMap));
|
|
1605
|
+
return data;
|
|
1606
|
+
} catch (error) {
|
|
1607
|
+
logError({
|
|
1608
|
+
message: '[DynamicWaasWalletClient] Error in storeEncryptedBackupByDelegatedWallet',
|
|
1609
|
+
error: error,
|
|
1610
|
+
context: {
|
|
1611
|
+
accountAddress
|
|
1612
|
+
}
|
|
1613
|
+
});
|
|
1614
|
+
throw error;
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1436
1617
|
async storeEncryptedBackupByWalletWithRetry({ accountAddress, clientKeyShares, password, signedSessionId }) {
|
|
1437
1618
|
await retryPromise(()=>this.storeEncryptedBackupByWallet({
|
|
1438
1619
|
accountAddress,
|
|
@@ -2042,6 +2223,7 @@ class DynamicWalletClient {
|
|
|
2042
2223
|
try {
|
|
2043
2224
|
var _user_verifiedCredentials;
|
|
2044
2225
|
const user = await this.apiClient.getUser();
|
|
2226
|
+
this.userId = user.id;
|
|
2045
2227
|
const waasWallets = (_user_verifiedCredentials = user.verifiedCredentials) == null ? void 0 : _user_verifiedCredentials.filter((vc)=>vc.walletName === 'dynamicwaas');
|
|
2046
2228
|
const wallets = waasWallets.map((vc)=>{
|
|
2047
2229
|
var _this_walletMap_vc_address, _vc_walletProperties;
|
|
@@ -2086,13 +2268,17 @@ class DynamicWalletClient {
|
|
|
2086
2268
|
*/ syncAuthToken(authToken) {
|
|
2087
2269
|
this.apiClient.syncAuthToken(authToken);
|
|
2088
2270
|
}
|
|
2089
|
-
constructor({ environmentId, authToken, baseApiUrl, baseMPCRelayApiUrl, storageKey, debug }){
|
|
2271
|
+
constructor({ environmentId, authToken, baseApiUrl, baseMPCRelayApiUrl, storageKey, debug, featureFlags }){
|
|
2272
|
+
this.userId = undefined;
|
|
2273
|
+
this.sessionId = undefined;
|
|
2274
|
+
this.delegatedAccessEndpoint = undefined;
|
|
2090
2275
|
this.initializePromise = null;
|
|
2091
2276
|
this.logger = logger;
|
|
2092
2277
|
this.walletMap = {} // todo: store in session storage
|
|
2093
2278
|
;
|
|
2094
2279
|
this.memoryStorage = null;
|
|
2095
2280
|
this.iframe = null;
|
|
2281
|
+
this.featureFlags = {};
|
|
2096
2282
|
this.environmentId = environmentId;
|
|
2097
2283
|
this.storageKey = `${STORAGE_KEY}-${storageKey != null ? storageKey : environmentId}`;
|
|
2098
2284
|
this.baseMPCRelayApiUrl = baseMPCRelayApiUrl;
|
|
@@ -2103,6 +2289,7 @@ class DynamicWalletClient {
|
|
|
2103
2289
|
});
|
|
2104
2290
|
this.debug = Boolean(debug);
|
|
2105
2291
|
this.logger.setLogLevel(this.debug ? logger$1.LogLevel.DEBUG : DEFAULT_LOG_LEVEL);
|
|
2292
|
+
this.featureFlags = featureFlags || {};
|
|
2106
2293
|
// setup storage
|
|
2107
2294
|
if (supportsLocalStorage()) {
|
|
2108
2295
|
this.storage = localStorageAdapter;
|
package/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SigningAlgorithm, MPC_RELAY_PROD_API_URL, getMPCChainConfig, BackupLocation, getClientThreshold, MPC_CONFIG, getTSSConfig, WalletOperation, getReshareConfig, ThresholdSignatureScheme, verifiedCredentialNameToChainEnum, DynamicApiClient, getEnvironmentFromUrl, IFRAME_DOMAIN_MAP } from '@dynamic-labs-wallet/core';
|
|
1
|
+
import { SigningAlgorithm, MPC_RELAY_PROD_API_URL, getMPCChainConfig, BackupLocation, getClientThreshold, MPC_CONFIG, getTSSConfig, WalletOperation, getReshareConfig, FEATURE_FLAGS, ThresholdSignatureScheme, DELEGATED_SHARE_COUNT, verifiedCredentialNameToChainEnum, DynamicApiClient, getEnvironmentFromUrl, IFRAME_DOMAIN_MAP } from '@dynamic-labs-wallet/core';
|
|
2
2
|
export * from '@dynamic-labs-wallet/core';
|
|
3
3
|
import { v4 } from 'uuid';
|
|
4
4
|
import { BIP340, ExportableEd25519, Ecdsa, MessageHash, EcdsaKeygenResult, ExportableEd25519KeygenResult, BIP340KeygenResult } from './internal/web';
|
|
@@ -619,6 +619,7 @@ class DynamicWalletClient {
|
|
|
619
619
|
sessionId,
|
|
620
620
|
userId
|
|
621
621
|
});
|
|
622
|
+
this.sessionId = sessionId;
|
|
622
623
|
} catch (error) {
|
|
623
624
|
logError({
|
|
624
625
|
message: '[DynamicWaasWalletClient] Error initializing logger context',
|
|
@@ -1076,7 +1077,7 @@ class DynamicWalletClient {
|
|
|
1076
1077
|
existingClientKeyShares
|
|
1077
1078
|
};
|
|
1078
1079
|
}
|
|
1079
|
-
async reshare({ chainName, accountAddress, oldThresholdSignatureScheme, newThresholdSignatureScheme, password = undefined, signedSessionId, backupToGoogleDrive = false }) {
|
|
1080
|
+
async reshare({ chainName, accountAddress, oldThresholdSignatureScheme, newThresholdSignatureScheme, password = undefined, signedSessionId, backupToGoogleDrive = false, delegateToProjectEnvironment = false }) {
|
|
1080
1081
|
const dynamicRequestId = v4();
|
|
1081
1082
|
try {
|
|
1082
1083
|
await this.verifyPassword({
|
|
@@ -1113,7 +1114,8 @@ class DynamicWalletClient {
|
|
|
1113
1114
|
clientKeygenIds: clientKeygenIds,
|
|
1114
1115
|
oldThresholdSignatureScheme,
|
|
1115
1116
|
newThresholdSignatureScheme,
|
|
1116
|
-
dynamicRequestId
|
|
1117
|
+
dynamicRequestId,
|
|
1118
|
+
delegateToProjectEnvironment
|
|
1117
1119
|
});
|
|
1118
1120
|
const { roomId, serverKeygenIds, newServerKeygenIds = [] } = data;
|
|
1119
1121
|
// Get the MPC config for the threshold signature scheme
|
|
@@ -1140,12 +1142,20 @@ class DynamicWalletClient {
|
|
|
1140
1142
|
clientKeyShares: reshareResults,
|
|
1141
1143
|
overwriteOrMerge: 'overwrite'
|
|
1142
1144
|
});
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1145
|
+
if (delegateToProjectEnvironment) {
|
|
1146
|
+
await this.storeEncryptedBackupByDelegatedWallet({
|
|
1147
|
+
accountAddress,
|
|
1148
|
+
password,
|
|
1149
|
+
signedSessionId
|
|
1150
|
+
});
|
|
1151
|
+
} else {
|
|
1152
|
+
await this.storeEncryptedBackupByWallet({
|
|
1153
|
+
accountAddress,
|
|
1154
|
+
password,
|
|
1155
|
+
signedSessionId,
|
|
1156
|
+
backupToGoogleDrive
|
|
1157
|
+
});
|
|
1158
|
+
}
|
|
1149
1159
|
} catch (error) {
|
|
1150
1160
|
logError({
|
|
1151
1161
|
message: '[DynamicWaasWalletClient] Error in reshare',
|
|
@@ -1162,6 +1172,88 @@ class DynamicWalletClient {
|
|
|
1162
1172
|
throw error;
|
|
1163
1173
|
}
|
|
1164
1174
|
}
|
|
1175
|
+
async sendKeySharesToDelegatedAccess({ accountAddress, chainName, delegatedKeyShares, environmentId, userId, walletId }) {
|
|
1176
|
+
try {
|
|
1177
|
+
if (!this.delegatedAccessEndpoint) {
|
|
1178
|
+
throw new Error('Cannot send key shares to delegated access because delegated access endpoint is not set');
|
|
1179
|
+
}
|
|
1180
|
+
const delegatedAccessEndpoint = this.delegatedAccessEndpoint;
|
|
1181
|
+
const response = await fetch(delegatedAccessEndpoint, {
|
|
1182
|
+
method: 'POST',
|
|
1183
|
+
body: JSON.stringify({
|
|
1184
|
+
chainName,
|
|
1185
|
+
accountAddress,
|
|
1186
|
+
delegatedKeyShares,
|
|
1187
|
+
environmentId,
|
|
1188
|
+
userId,
|
|
1189
|
+
walletId
|
|
1190
|
+
})
|
|
1191
|
+
});
|
|
1192
|
+
const data = await response.json();
|
|
1193
|
+
return data;
|
|
1194
|
+
} catch (error) {
|
|
1195
|
+
logError({
|
|
1196
|
+
message: '[DynamicWaasWalletClient] Error in sendKeySharesToDelegatedAccess',
|
|
1197
|
+
error: error,
|
|
1198
|
+
context: {
|
|
1199
|
+
accountAddress,
|
|
1200
|
+
chainName
|
|
1201
|
+
}
|
|
1202
|
+
});
|
|
1203
|
+
throw error;
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
async delegateKeyShares({ accountAddress, password = undefined, signedSessionId }) {
|
|
1207
|
+
try {
|
|
1208
|
+
const delegateToProjectEnvironment = this.featureFlags && this.featureFlags[FEATURE_FLAGS.ENABLE_DELEGATED_KEY_SHARES_FLAG] === true;
|
|
1209
|
+
if (!delegateToProjectEnvironment) {
|
|
1210
|
+
throw new Error('Delegation is not allowed for this project environment');
|
|
1211
|
+
}
|
|
1212
|
+
const environmentSettings = await this.apiClient.getEnvironmentSettings();
|
|
1213
|
+
const delegatedAccessEndpoint = environmentSettings.sdk.waas.delegatedAccessEndpoint;
|
|
1214
|
+
if (!delegatedAccessEndpoint) {
|
|
1215
|
+
throw new Error('Cannot delegate key shares because verified access endpoint is not set in the environment settings');
|
|
1216
|
+
}
|
|
1217
|
+
this.delegatedAccessEndpoint = delegatedAccessEndpoint;
|
|
1218
|
+
const wallet = await this.getWallet({
|
|
1219
|
+
accountAddress,
|
|
1220
|
+
walletOperation: WalletOperation.REACH_ALL_PARTIES,
|
|
1221
|
+
password,
|
|
1222
|
+
signedSessionId
|
|
1223
|
+
});
|
|
1224
|
+
if (wallet.chainName === 'SUI') {
|
|
1225
|
+
throw new Error('Delegation is not allowed for SUI');
|
|
1226
|
+
}
|
|
1227
|
+
const currentThresholdSignatureScheme = this.walletMap[accountAddress].thresholdSignatureScheme;
|
|
1228
|
+
if (currentThresholdSignatureScheme === ThresholdSignatureScheme.TWO_OF_TWO) {
|
|
1229
|
+
// Reshare to 2-of-3, which will automatically handle the backup distribution
|
|
1230
|
+
await this.reshare({
|
|
1231
|
+
chainName: this.walletMap[accountAddress].chainName,
|
|
1232
|
+
accountAddress,
|
|
1233
|
+
oldThresholdSignatureScheme: currentThresholdSignatureScheme,
|
|
1234
|
+
newThresholdSignatureScheme: ThresholdSignatureScheme.TWO_OF_THREE,
|
|
1235
|
+
password,
|
|
1236
|
+
signedSessionId,
|
|
1237
|
+
backupToGoogleDrive: false,
|
|
1238
|
+
delegateToProjectEnvironment: true
|
|
1239
|
+
});
|
|
1240
|
+
const backupInfo = this.walletMap[accountAddress].clientKeySharesBackupInfo;
|
|
1241
|
+
const delegatedKeyShares = backupInfo.backups[BackupLocation.EXTERNAL] || [];
|
|
1242
|
+
return delegatedKeyShares;
|
|
1243
|
+
} else {
|
|
1244
|
+
throw new Error('Delegation is not allowed for this threshold signature scheme');
|
|
1245
|
+
}
|
|
1246
|
+
} catch (error) {
|
|
1247
|
+
logError({
|
|
1248
|
+
message: '[DynamicWaasWalletClient] Error in delegateKeyShares',
|
|
1249
|
+
error: error,
|
|
1250
|
+
context: {
|
|
1251
|
+
accountAddress
|
|
1252
|
+
}
|
|
1253
|
+
});
|
|
1254
|
+
throw error;
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1165
1257
|
async exportKey({ accountAddress, chainName, password = undefined, signedSessionId }) {
|
|
1166
1258
|
const dynamicRequestId = v4();
|
|
1167
1259
|
try {
|
|
@@ -1353,7 +1445,7 @@ class DynamicWalletClient {
|
|
|
1353
1445
|
* @returns Promise with backup metadata including share locations and IDs
|
|
1354
1446
|
*/ async storeEncryptedBackupByWallet({ accountAddress, clientKeyShares = undefined, password = undefined, signedSessionId, backupToGoogleDrive = false }) {
|
|
1355
1447
|
try {
|
|
1356
|
-
var _this_walletMap_accountAddress;
|
|
1448
|
+
var _this_walletMap_accountAddress, _this_walletMap_accountAddress_clientKeySharesBackupInfo_backups_BackupLocation_GOOGLE_DRIVE, _this_walletMap_accountAddress_clientKeySharesBackupInfo_backups, _this_walletMap_accountAddress_clientKeySharesBackupInfo, _this_walletMap_accountAddress1;
|
|
1357
1449
|
const keySharesToBackup = clientKeyShares != null ? clientKeyShares : await this.getClientKeySharesFromLocalStorage({
|
|
1358
1450
|
accountAddress
|
|
1359
1451
|
});
|
|
@@ -1376,7 +1468,7 @@ class DynamicWalletClient {
|
|
|
1376
1468
|
keyShare,
|
|
1377
1469
|
password
|
|
1378
1470
|
})));
|
|
1379
|
-
const hasExistingGoogleDriveBackup = this.walletMap[accountAddress].clientKeySharesBackupInfo.backups[BackupLocation.GOOGLE_DRIVE].length > 0;
|
|
1471
|
+
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;
|
|
1380
1472
|
// Backup to Google Drive if:
|
|
1381
1473
|
// 1. Explicitly requested via flag, OR
|
|
1382
1474
|
// 2. User already has Google Drive backups
|
|
@@ -1434,6 +1526,95 @@ class DynamicWalletClient {
|
|
|
1434
1526
|
throw error;
|
|
1435
1527
|
}
|
|
1436
1528
|
}
|
|
1529
|
+
async storeEncryptedBackupByDelegatedWallet({ accountAddress, clientKeyShares = undefined, password = undefined, signedSessionId }) {
|
|
1530
|
+
try {
|
|
1531
|
+
var _this_walletMap_accountAddress, _this_walletMap_accountAddress_clientKeySharesBackupInfo_backups_BackupLocation_EXTERNAL, _this_walletMap_accountAddress_clientKeySharesBackupInfo_backups, _this_walletMap_accountAddress_clientKeySharesBackupInfo, _this_walletMap_accountAddress1;
|
|
1532
|
+
const keySharesToBackup = clientKeyShares != null ? clientKeyShares : await this.getClientKeySharesFromLocalStorage({
|
|
1533
|
+
accountAddress
|
|
1534
|
+
});
|
|
1535
|
+
if (!((_this_walletMap_accountAddress = this.walletMap[accountAddress]) == null ? void 0 : _this_walletMap_accountAddress.walletId)) {
|
|
1536
|
+
const error = new Error(`WalletId not found for accountAddress ${accountAddress}`);
|
|
1537
|
+
logError({
|
|
1538
|
+
message: '[DynamicWaasWalletClient] Error in storeEncryptedBackupByWallet, wallet or walletId not found from the wallet map',
|
|
1539
|
+
error,
|
|
1540
|
+
context: {
|
|
1541
|
+
accountAddress,
|
|
1542
|
+
walletMap: this.walletMap
|
|
1543
|
+
}
|
|
1544
|
+
});
|
|
1545
|
+
throw error;
|
|
1546
|
+
}
|
|
1547
|
+
let dynamicClientKeyShares = [];
|
|
1548
|
+
let delegatedKeyShares = [];
|
|
1549
|
+
const encryptedKeyShares = await Promise.all(keySharesToBackup.map((keyShare)=>this.encryptKeyShare({
|
|
1550
|
+
keyShare,
|
|
1551
|
+
password
|
|
1552
|
+
})));
|
|
1553
|
+
const hasExistingDelegatedBackup = ((_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_EXTERNAL = _this_walletMap_accountAddress_clientKeySharesBackupInfo_backups[BackupLocation.EXTERNAL]) == null ? void 0 : _this_walletMap_accountAddress_clientKeySharesBackupInfo_backups_BackupLocation_EXTERNAL.length) > 0;
|
|
1554
|
+
const shouldBackupToDelegated = hasExistingDelegatedBackup || keySharesToBackup.length >= 2;
|
|
1555
|
+
if (shouldBackupToDelegated) {
|
|
1556
|
+
// For 2 shares: 1 to backend, 1 to delegated
|
|
1557
|
+
// For 3+ shares: N-1 to backend, 1 to delegated
|
|
1558
|
+
dynamicClientKeyShares = encryptedKeyShares.slice(0, -DELEGATED_SHARE_COUNT);
|
|
1559
|
+
delegatedKeyShares = encryptedKeyShares.slice(-DELEGATED_SHARE_COUNT);
|
|
1560
|
+
} else {
|
|
1561
|
+
dynamicClientKeyShares = encryptedKeyShares;
|
|
1562
|
+
}
|
|
1563
|
+
const data = await this.apiClient.storeEncryptedBackupByWallet({
|
|
1564
|
+
walletId: this.walletMap[accountAddress].walletId,
|
|
1565
|
+
encryptedKeyShares: dynamicClientKeyShares,
|
|
1566
|
+
passwordEncrypted: Boolean(password) && password !== this.environmentId,
|
|
1567
|
+
encryptionVersion: ENCRYPTION_VERSION_CURRENT,
|
|
1568
|
+
signedSessionId
|
|
1569
|
+
});
|
|
1570
|
+
await this.apiClient.markKeySharesAsBackedUp({
|
|
1571
|
+
walletId: this.walletMap[accountAddress].walletId,
|
|
1572
|
+
location: BackupLocation.DYNAMIC
|
|
1573
|
+
});
|
|
1574
|
+
if (delegatedKeyShares.length > 0) {
|
|
1575
|
+
const wallet = this.walletMap[accountAddress];
|
|
1576
|
+
var _this_userId;
|
|
1577
|
+
const delegatedKeyShareIds = await this.sendKeySharesToDelegatedAccess({
|
|
1578
|
+
accountAddress,
|
|
1579
|
+
chainName: wallet.chainName,
|
|
1580
|
+
environmentId: this.environmentId,
|
|
1581
|
+
walletId: wallet.walletId,
|
|
1582
|
+
userId: (_this_userId = this.userId) != null ? _this_userId : '',
|
|
1583
|
+
delegatedKeyShares: delegatedKeyShares
|
|
1584
|
+
});
|
|
1585
|
+
data.keyShares.push({
|
|
1586
|
+
backupLocation: BackupLocation.EXTERNAL,
|
|
1587
|
+
id: delegatedKeyShareIds
|
|
1588
|
+
});
|
|
1589
|
+
//todo: combine with user share service backup once other branch is merged
|
|
1590
|
+
await this.apiClient.markKeySharesAsBackedUp({
|
|
1591
|
+
walletId: this.walletMap[accountAddress].walletId,
|
|
1592
|
+
location: BackupLocation.EXTERNAL
|
|
1593
|
+
});
|
|
1594
|
+
}
|
|
1595
|
+
const updatedBackupInfo = getClientKeyShareBackupInfo({
|
|
1596
|
+
walletProperties: {
|
|
1597
|
+
derivationPath: this.walletMap[accountAddress].derivationPath,
|
|
1598
|
+
keyShares: data.keyShares,
|
|
1599
|
+
thresholdSignatureScheme: this.walletMap[accountAddress].thresholdSignatureScheme
|
|
1600
|
+
}
|
|
1601
|
+
});
|
|
1602
|
+
this.walletMap[accountAddress] = _extends({}, this.walletMap[accountAddress], {
|
|
1603
|
+
clientKeySharesBackupInfo: updatedBackupInfo
|
|
1604
|
+
});
|
|
1605
|
+
await this.storage.setItem(this.storageKey, JSON.stringify(this.walletMap));
|
|
1606
|
+
return data;
|
|
1607
|
+
} catch (error) {
|
|
1608
|
+
logError({
|
|
1609
|
+
message: '[DynamicWaasWalletClient] Error in storeEncryptedBackupByDelegatedWallet',
|
|
1610
|
+
error: error,
|
|
1611
|
+
context: {
|
|
1612
|
+
accountAddress
|
|
1613
|
+
}
|
|
1614
|
+
});
|
|
1615
|
+
throw error;
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1437
1618
|
async storeEncryptedBackupByWalletWithRetry({ accountAddress, clientKeyShares, password, signedSessionId }) {
|
|
1438
1619
|
await retryPromise(()=>this.storeEncryptedBackupByWallet({
|
|
1439
1620
|
accountAddress,
|
|
@@ -2043,6 +2224,7 @@ class DynamicWalletClient {
|
|
|
2043
2224
|
try {
|
|
2044
2225
|
var _user_verifiedCredentials;
|
|
2045
2226
|
const user = await this.apiClient.getUser();
|
|
2227
|
+
this.userId = user.id;
|
|
2046
2228
|
const waasWallets = (_user_verifiedCredentials = user.verifiedCredentials) == null ? void 0 : _user_verifiedCredentials.filter((vc)=>vc.walletName === 'dynamicwaas');
|
|
2047
2229
|
const wallets = waasWallets.map((vc)=>{
|
|
2048
2230
|
var _this_walletMap_vc_address, _vc_walletProperties;
|
|
@@ -2087,13 +2269,17 @@ class DynamicWalletClient {
|
|
|
2087
2269
|
*/ syncAuthToken(authToken) {
|
|
2088
2270
|
this.apiClient.syncAuthToken(authToken);
|
|
2089
2271
|
}
|
|
2090
|
-
constructor({ environmentId, authToken, baseApiUrl, baseMPCRelayApiUrl, storageKey, debug }){
|
|
2272
|
+
constructor({ environmentId, authToken, baseApiUrl, baseMPCRelayApiUrl, storageKey, debug, featureFlags }){
|
|
2273
|
+
this.userId = undefined;
|
|
2274
|
+
this.sessionId = undefined;
|
|
2275
|
+
this.delegatedAccessEndpoint = undefined;
|
|
2091
2276
|
this.initializePromise = null;
|
|
2092
2277
|
this.logger = logger;
|
|
2093
2278
|
this.walletMap = {} // todo: store in session storage
|
|
2094
2279
|
;
|
|
2095
2280
|
this.memoryStorage = null;
|
|
2096
2281
|
this.iframe = null;
|
|
2282
|
+
this.featureFlags = {};
|
|
2097
2283
|
this.environmentId = environmentId;
|
|
2098
2284
|
this.storageKey = `${STORAGE_KEY}-${storageKey != null ? storageKey : environmentId}`;
|
|
2099
2285
|
this.baseMPCRelayApiUrl = baseMPCRelayApiUrl;
|
|
@@ -2104,6 +2290,7 @@ class DynamicWalletClient {
|
|
|
2104
2290
|
});
|
|
2105
2291
|
this.debug = Boolean(debug);
|
|
2106
2292
|
this.logger.setLogLevel(this.debug ? LogLevel.DEBUG : DEFAULT_LOG_LEVEL);
|
|
2293
|
+
this.featureFlags = featureFlags || {};
|
|
2107
2294
|
// setup storage
|
|
2108
2295
|
if (supportsLocalStorage()) {
|
|
2109
2296
|
this.storage = localStorageAdapter;
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs-wallet/browser",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.122",
|
|
4
4
|
"license": "Licensed under the Dynamic Labs, Inc. Terms Of Service (https://www.dynamic.xyz/terms-conditions)",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@dynamic-labs-wallet/core": "0.0.
|
|
7
|
+
"@dynamic-labs-wallet/core": "0.0.122",
|
|
8
8
|
"@dynamic-labs/logger": "^4.9.9",
|
|
9
9
|
"@dynamic-labs/sdk-api-core": "^0.0.663",
|
|
10
10
|
"axios": "1.9.0",
|
package/src/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BackupLocation, DynamicApiClient, type DynamicWalletClientProps, type InitializeResult, type KeyShareBackupInfo, ThresholdSignatureScheme, WalletOperation } from '@dynamic-labs-wallet/core';
|
|
1
|
+
import { BackupLocation, DynamicApiClient, type DynamicWalletClientProps, FeatureFlags, type InitializeResult, type KeyShareBackupInfo, ThresholdSignatureScheme, WalletOperation } from '@dynamic-labs-wallet/core';
|
|
2
2
|
import { BIP340KeygenResult, EcdsaKeygenResult, type EcdsaPublicKey, type EcdsaSignature, ExportableEd25519 } from '../../internal/web';
|
|
3
3
|
import type { ClientInitKeygenResult, ClientKeyShare } from './mpc/types';
|
|
4
4
|
import { type SupportedStorage } from './services/localStorage';
|
|
@@ -7,6 +7,9 @@ export declare class DynamicWalletClient {
|
|
|
7
7
|
environmentId: string;
|
|
8
8
|
storageKey: string;
|
|
9
9
|
debug: boolean;
|
|
10
|
+
protected userId: string | undefined;
|
|
11
|
+
protected sessionId: string | undefined;
|
|
12
|
+
protected delegatedAccessEndpoint: string | undefined;
|
|
10
13
|
protected initializePromise: Promise<InitializeResult> | null;
|
|
11
14
|
protected logger: import("@dynamic-labs/logger").Logger;
|
|
12
15
|
protected apiClient: DynamicApiClient;
|
|
@@ -19,7 +22,8 @@ export declare class DynamicWalletClient {
|
|
|
19
22
|
protected iframe: HTMLIFrameElement | null;
|
|
20
23
|
readonly instanceId: string;
|
|
21
24
|
readonly iframeDomain: string;
|
|
22
|
-
|
|
25
|
+
readonly featureFlags: FeatureFlags;
|
|
26
|
+
constructor({ environmentId, authToken, baseApiUrl, baseMPCRelayApiUrl, storageKey, debug, featureFlags, }: DynamicWalletClientProps);
|
|
23
27
|
initLoggerContext(authToken: string): Promise<void>;
|
|
24
28
|
initialize(): Promise<InitializeResult>;
|
|
25
29
|
/**
|
|
@@ -129,7 +133,7 @@ export declare class DynamicWalletClient {
|
|
|
129
133
|
existingClientKeygenIds: string[];
|
|
130
134
|
existingClientKeyShares: ClientKeyShare[];
|
|
131
135
|
}>;
|
|
132
|
-
reshare({ chainName, accountAddress, oldThresholdSignatureScheme, newThresholdSignatureScheme, password, signedSessionId, backupToGoogleDrive, }: {
|
|
136
|
+
reshare({ chainName, accountAddress, oldThresholdSignatureScheme, newThresholdSignatureScheme, password, signedSessionId, backupToGoogleDrive, delegateToProjectEnvironment, }: {
|
|
133
137
|
chainName: string;
|
|
134
138
|
accountAddress: string;
|
|
135
139
|
oldThresholdSignatureScheme: ThresholdSignatureScheme;
|
|
@@ -137,7 +141,21 @@ export declare class DynamicWalletClient {
|
|
|
137
141
|
password?: string;
|
|
138
142
|
signedSessionId: string;
|
|
139
143
|
backupToGoogleDrive?: boolean;
|
|
144
|
+
delegateToProjectEnvironment?: boolean;
|
|
140
145
|
}): Promise<void>;
|
|
146
|
+
sendKeySharesToDelegatedAccess({ accountAddress, chainName, delegatedKeyShares, environmentId, userId, walletId, }: {
|
|
147
|
+
accountAddress: string;
|
|
148
|
+
chainName: string;
|
|
149
|
+
delegatedKeyShares: string[];
|
|
150
|
+
environmentId: string;
|
|
151
|
+
userId: string;
|
|
152
|
+
walletId: string;
|
|
153
|
+
}): Promise<any>;
|
|
154
|
+
delegateKeyShares({ accountAddress, password, signedSessionId, }: {
|
|
155
|
+
accountAddress: string;
|
|
156
|
+
password?: string;
|
|
157
|
+
signedSessionId: string;
|
|
158
|
+
}): Promise<string[]>;
|
|
141
159
|
exportKey({ accountAddress, chainName, password, signedSessionId, }: {
|
|
142
160
|
accountAddress: string;
|
|
143
161
|
chainName: string;
|
|
@@ -206,6 +224,12 @@ export declare class DynamicWalletClient {
|
|
|
206
224
|
signedSessionId: string;
|
|
207
225
|
backupToGoogleDrive?: boolean;
|
|
208
226
|
}): Promise<any>;
|
|
227
|
+
storeEncryptedBackupByDelegatedWallet({ accountAddress, clientKeyShares, password, signedSessionId, }: {
|
|
228
|
+
accountAddress: string;
|
|
229
|
+
clientKeyShares?: ClientKeyShare[];
|
|
230
|
+
password?: string;
|
|
231
|
+
signedSessionId: string;
|
|
232
|
+
}): Promise<any>;
|
|
209
233
|
storeEncryptedBackupByWalletWithRetry({ accountAddress, clientKeyShares, password, signedSessionId, }: {
|
|
210
234
|
accountAddress: string;
|
|
211
235
|
clientKeyShares?: ClientKeyShare[];
|
package/src/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../packages/src/client.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,cAAc,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../packages/src/client.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,cAAc,EAEd,gBAAgB,EAChB,KAAK,wBAAwB,EAE7B,YAAY,EAOZ,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EAEvB,wBAAwB,EAExB,eAAe,EAChB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAEL,kBAAkB,EAElB,iBAAiB,EACjB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,iBAAiB,EAGlB,MAAM,eAAe,CAAC;AAmBvB,OAAO,KAAK,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAGL,KAAK,gBAAgB,EAEtB,MAAM,yBAAyB,CAAC;AAE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