@dynamic-labs-wallet/browser 0.0.0-beta.154.0 → 0.0.0-beta.154.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs.js +123 -49
- package/index.esm.js +123 -50
- package/package.json +2 -2
- package/src/backup/providers/googleDrive.d.ts +4 -4
- package/src/backup/providers/googleDrive.d.ts.map +1 -1
- package/src/backup/utils.d.ts +37 -0
- package/src/backup/utils.d.ts.map +1 -0
- package/src/client.d.ts +3 -5
- package/src/client.d.ts.map +1 -1
- package/src/utils.d.ts +26 -3
- package/src/utils.d.ts.map +1 -1
package/index.cjs.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var core = require('@dynamic-labs-wallet/core');
|
|
4
4
|
var web = require('./internal/web');
|
|
5
|
-
var logger$1 = require('@dynamic-labs/logger');
|
|
6
5
|
var sdkApiCore = require('@dynamic-labs/sdk-api-core');
|
|
6
|
+
var logger$1 = require('@dynamic-labs/logger');
|
|
7
7
|
|
|
8
8
|
function _extends() {
|
|
9
9
|
_extends = Object.assign || function assign(target) {
|
|
@@ -130,7 +130,9 @@ const timeoutPromise = ({ timeInMs, activity = 'Ceremony' })=>{
|
|
|
130
130
|
}));
|
|
131
131
|
throw error;
|
|
132
132
|
}
|
|
133
|
-
|
|
133
|
+
// Calculate exponential backoff delay
|
|
134
|
+
const exponentialDelay = retryInterval * 2 ** (attempts - 1);
|
|
135
|
+
await new Promise((resolve)=>setTimeout(resolve, exponentialDelay));
|
|
134
136
|
}
|
|
135
137
|
}
|
|
136
138
|
// TypeScript needs this even though it's unreachable
|
|
@@ -170,6 +172,26 @@ const getGoogleOAuthAccountId = (verifiedCredentials)=>{
|
|
|
170
172
|
const googleVerifiedCredential = verifiedCredentials == null ? void 0 : verifiedCredentials.find((credential)=>credential.oauthProvider === sdkApiCore.ProviderEnum.Google);
|
|
171
173
|
return googleVerifiedCredential == null ? void 0 : googleVerifiedCredential.id;
|
|
172
174
|
};
|
|
175
|
+
const createBackupData = ({ encryptedKeyShares, accountAddress, thresholdSignatureScheme, hasPassword = true })=>{
|
|
176
|
+
return {
|
|
177
|
+
keyShares: encryptedKeyShares,
|
|
178
|
+
metadata: {
|
|
179
|
+
version: '1.0',
|
|
180
|
+
createdAt: new Date().toISOString(),
|
|
181
|
+
accountAddress,
|
|
182
|
+
thresholdSignatureScheme,
|
|
183
|
+
hasPassword,
|
|
184
|
+
encryption: {
|
|
185
|
+
algorithm: AES_GCM_ALGORITHM,
|
|
186
|
+
keyDerivation: PBKDF2_ALGORITHM,
|
|
187
|
+
iterations: PBKDF2_ITERATIONS,
|
|
188
|
+
hashAlgorithm: PBKDF2_HASH_ALGORITHM,
|
|
189
|
+
algorithmLength: AES_GCM_LENGTH
|
|
190
|
+
},
|
|
191
|
+
shareCount: encryptedKeyShares.length
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
};
|
|
173
195
|
|
|
174
196
|
const PBKDF2_ALGORITHM = 'PBKDF2';
|
|
175
197
|
const PBKDF2_ITERATIONS = 100000;
|
|
@@ -297,9 +319,9 @@ const uploadFileToGoogleDrive = async ({ accessToken, fileName, jsonData, parent
|
|
|
297
319
|
const result = await response.json();
|
|
298
320
|
return result; // Return file metadata, including file ID
|
|
299
321
|
};
|
|
300
|
-
const listFilesFromGoogleDrive = async ({ accessToken,
|
|
322
|
+
const listFilesFromGoogleDrive = async ({ accessToken, fileName })=>{
|
|
301
323
|
// Step 1: List all files inside `appDataFolder` with the specified backup filename
|
|
302
|
-
const resp = await fetch(`${GOOGLE_DRIVE_UPLOAD_API}/drive/v3/files?q=${encodeURIComponent(`name='${
|
|
324
|
+
const resp = await fetch(`${GOOGLE_DRIVE_UPLOAD_API}/drive/v3/files?q=${encodeURIComponent(`name='${fileName}'`)}&spaces=appDataFolder&orderBy=createdTime desc`, {
|
|
303
325
|
headers: {
|
|
304
326
|
Authorization: `Bearer ${accessToken}`
|
|
305
327
|
}
|
|
@@ -312,10 +334,10 @@ const listFilesFromGoogleDrive = async ({ accessToken, name })=>{
|
|
|
312
334
|
const files = data.files;
|
|
313
335
|
return files;
|
|
314
336
|
};
|
|
315
|
-
const downloadFileFromGoogleDrive = async ({ accessToken,
|
|
337
|
+
const downloadFileFromGoogleDrive = async ({ accessToken, fileName })=>{
|
|
316
338
|
const files = await listFilesFromGoogleDrive({
|
|
317
339
|
accessToken,
|
|
318
|
-
|
|
340
|
+
fileName
|
|
319
341
|
});
|
|
320
342
|
if (!files || files.length === 0) {
|
|
321
343
|
return null;
|
|
@@ -411,6 +433,56 @@ const localStorageWriteTest = {
|
|
|
411
433
|
}
|
|
412
434
|
});
|
|
413
435
|
|
|
436
|
+
/**
|
|
437
|
+
* Updates the wallet map with backup information after successful backup to Google Drive
|
|
438
|
+
* @param data - Response data containing key shares information
|
|
439
|
+
* @param walletMap - The wallet map to update
|
|
440
|
+
* @param accountAddress - The account address associated with the wallet
|
|
441
|
+
* @param backupLocation - The location where the backup is stored
|
|
442
|
+
* @param storage - Storage interface for persisting the updated wallet map
|
|
443
|
+
* @param storageKey - Key used to store the wallet map
|
|
444
|
+
* @returns The array of key share IDs that were backed up
|
|
445
|
+
*/ const updateWalletMapWithBackupInfo = async ({ data, walletMap, accountAddress, storage, storageKey })=>{
|
|
446
|
+
const ids = data.keyShares.map((keyShare)=>keyShare.id);
|
|
447
|
+
walletMap[accountAddress].clientKeySharesBackupInfo.backups[core.BackupLocation.GOOGLE_DRIVE] = ids;
|
|
448
|
+
await storage.setItem(storageKey, JSON.stringify(walletMap));
|
|
449
|
+
return ids;
|
|
450
|
+
};
|
|
451
|
+
/**
|
|
452
|
+
* Uploads a backup to Google Drive App
|
|
453
|
+
* @param accessToken - The access token for the Google Drive API
|
|
454
|
+
* @param fileName - The name of the file to upload
|
|
455
|
+
* @param backupData - The data to upload
|
|
456
|
+
* @param accountAddress - The account address associated with the backup
|
|
457
|
+
*/ const uploadBackupToGoogleDrive = async ({ accessToken, fileName, backupData, accountAddress })=>{
|
|
458
|
+
try {
|
|
459
|
+
await retryPromise(()=>uploadFileToGoogleDriveAppStorage({
|
|
460
|
+
accessToken,
|
|
461
|
+
fileName,
|
|
462
|
+
jsonData: backupData
|
|
463
|
+
}));
|
|
464
|
+
} catch (error) {
|
|
465
|
+
logger.error('Failed to upload keyshares to Google Drive App Storage', {
|
|
466
|
+
accountAddress,
|
|
467
|
+
error
|
|
468
|
+
});
|
|
469
|
+
throw new Error(`Failed to backup keyshares to Google Drive App Storage: ${error instanceof Error ? error.message : String(error)}`);
|
|
470
|
+
}
|
|
471
|
+
try {
|
|
472
|
+
await retryPromise(()=>uploadFileToGoogleDrivePersonal({
|
|
473
|
+
accessToken,
|
|
474
|
+
fileName,
|
|
475
|
+
jsonData: backupData
|
|
476
|
+
}));
|
|
477
|
+
} catch (error) {
|
|
478
|
+
logger.error('Failed to upload keyshares to Google Drive Personal', {
|
|
479
|
+
accountAddress,
|
|
480
|
+
error
|
|
481
|
+
});
|
|
482
|
+
throw new Error(`Failed to backup keyshares to Google Drive Personal: ${error instanceof Error ? error.message : String(error)}`);
|
|
483
|
+
}
|
|
484
|
+
};
|
|
485
|
+
|
|
414
486
|
class DynamicWalletClient {
|
|
415
487
|
async initialize() {
|
|
416
488
|
if (this.initializePromise) {
|
|
@@ -1083,7 +1155,7 @@ class DynamicWalletClient {
|
|
|
1083
1155
|
}
|
|
1084
1156
|
this.walletMap = JSON.parse(wallets);
|
|
1085
1157
|
}
|
|
1086
|
-
async backupKeySharesToGoogleDrive({ accountAddress,
|
|
1158
|
+
async backupKeySharesToGoogleDrive({ accountAddress, password }) {
|
|
1087
1159
|
await this.getWallet({
|
|
1088
1160
|
accountAddress,
|
|
1089
1161
|
walletOperation: core.WalletOperation.REACH_ALL_PARTIES,
|
|
@@ -1104,50 +1176,33 @@ class DynamicWalletClient {
|
|
|
1104
1176
|
oauthAccountId
|
|
1105
1177
|
});
|
|
1106
1178
|
const thresholdSignatureScheme = this.walletMap[accountAddress].thresholdSignatureScheme;
|
|
1107
|
-
const
|
|
1179
|
+
const fileName = getClientKeyShareExportFileName({
|
|
1108
1180
|
thresholdSignatureScheme,
|
|
1109
1181
|
accountAddress
|
|
1110
1182
|
});
|
|
1111
|
-
const backupData = {
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
iterations: PBKDF2_ITERATIONS,
|
|
1123
|
-
hashAlgorithm: PBKDF2_HASH_ALGORITHM,
|
|
1124
|
-
algorithmLength: AES_GCM_LENGTH
|
|
1125
|
-
},
|
|
1126
|
-
shareCount: encryptedKeyShares.length
|
|
1127
|
-
}
|
|
1128
|
-
};
|
|
1129
|
-
// TODO: handle errors
|
|
1130
|
-
await Promise.all([
|
|
1131
|
-
uploadFileToGoogleDriveAppStorage({
|
|
1132
|
-
accessToken,
|
|
1133
|
-
fileName: fileName != null ? fileName : suggestedFileName,
|
|
1134
|
-
jsonData: backupData
|
|
1135
|
-
}),
|
|
1136
|
-
uploadFileToGoogleDrivePersonal({
|
|
1137
|
-
accessToken,
|
|
1138
|
-
fileName: fileName != null ? fileName : suggestedFileName,
|
|
1139
|
-
jsonData: backupData
|
|
1140
|
-
})
|
|
1141
|
-
]);
|
|
1183
|
+
const backupData = createBackupData({
|
|
1184
|
+
encryptedKeyShares,
|
|
1185
|
+
accountAddress,
|
|
1186
|
+
thresholdSignatureScheme
|
|
1187
|
+
});
|
|
1188
|
+
await uploadBackupToGoogleDrive({
|
|
1189
|
+
accessToken,
|
|
1190
|
+
fileName,
|
|
1191
|
+
backupData,
|
|
1192
|
+
accountAddress
|
|
1193
|
+
});
|
|
1142
1194
|
const data = await this.apiClient.markKeySharesAsBackedUpGoogleDrive({
|
|
1143
1195
|
walletId: this.walletMap[accountAddress].walletId
|
|
1144
1196
|
});
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1197
|
+
await updateWalletMapWithBackupInfo({
|
|
1198
|
+
data,
|
|
1199
|
+
walletMap: this.walletMap,
|
|
1200
|
+
accountAddress,
|
|
1201
|
+
storage: this.storage,
|
|
1202
|
+
storageKey: this.storageKey
|
|
1203
|
+
});
|
|
1149
1204
|
}
|
|
1150
|
-
async restoreBackupFromGoogleDrive({ accountAddress,
|
|
1205
|
+
async restoreBackupFromGoogleDrive({ accountAddress, password }) {
|
|
1151
1206
|
await this.getWallet({
|
|
1152
1207
|
accountAddress
|
|
1153
1208
|
});
|
|
@@ -1156,19 +1211,37 @@ class DynamicWalletClient {
|
|
|
1156
1211
|
oauthAccountId
|
|
1157
1212
|
});
|
|
1158
1213
|
const thresholdSignatureScheme = this.walletMap[accountAddress].thresholdSignatureScheme;
|
|
1159
|
-
const
|
|
1214
|
+
const fileName = getClientKeyShareExportFileName({
|
|
1160
1215
|
thresholdSignatureScheme,
|
|
1161
1216
|
accountAddress
|
|
1162
1217
|
});
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1218
|
+
let backupData = null;
|
|
1219
|
+
try {
|
|
1220
|
+
backupData = await retryPromise(()=>downloadFileFromGoogleDrive({
|
|
1221
|
+
accessToken,
|
|
1222
|
+
fileName
|
|
1223
|
+
}));
|
|
1224
|
+
} catch (error) {
|
|
1225
|
+
this.logger.error('Failed to download backup from Google Drive', {
|
|
1226
|
+
accountAddress,
|
|
1227
|
+
fileName,
|
|
1228
|
+
error
|
|
1229
|
+
});
|
|
1230
|
+
throw new Error('Failed to restore backup from Google Drive');
|
|
1231
|
+
}
|
|
1167
1232
|
if (!backupData) {
|
|
1233
|
+
this.logger.error('No backup file found', {
|
|
1234
|
+
accountAddress,
|
|
1235
|
+
fileName
|
|
1236
|
+
});
|
|
1168
1237
|
throw new Error('No backup file found');
|
|
1169
1238
|
}
|
|
1170
1239
|
// Validate the backup data structure
|
|
1171
1240
|
if (!backupData.keyShares || !backupData.metadata) {
|
|
1241
|
+
this.logger.error('Invalid backup format: missing keyShares or metadata', {
|
|
1242
|
+
accountAddress,
|
|
1243
|
+
fileName
|
|
1244
|
+
});
|
|
1172
1245
|
throw new Error('Invalid backup format: missing keyShares or metadata');
|
|
1173
1246
|
}
|
|
1174
1247
|
const { keyShares } = backupData;
|
|
@@ -1531,6 +1604,7 @@ Object.defineProperty(exports, "MessageHash", {
|
|
|
1531
1604
|
exports.DynamicWalletClient = DynamicWalletClient;
|
|
1532
1605
|
exports.base64ToBytes = base64ToBytes;
|
|
1533
1606
|
exports.bytesToBase64 = bytesToBase64;
|
|
1607
|
+
exports.createBackupData = createBackupData;
|
|
1534
1608
|
exports.ensureBase64Padding = ensureBase64Padding;
|
|
1535
1609
|
exports.formatEvmMessage = formatEvmMessage;
|
|
1536
1610
|
exports.formatMessage = formatMessage;
|
package/index.esm.js
CHANGED
|
@@ -2,8 +2,8 @@ import { SigningAlgorithm, MPC_RELAY_PROD_API_URL, getMPCChainConfig, BackupLoca
|
|
|
2
2
|
export * from '@dynamic-labs-wallet/core';
|
|
3
3
|
import { BIP340, Ed25519, Ecdsa, MessageHash, EcdsaKeygenResult, Ed25519KeygenResult, BIP340KeygenResult } from './internal/web';
|
|
4
4
|
export { BIP340, BIP340InitKeygenResult, BIP340KeygenResult, Ecdsa, EcdsaInitKeygenResult, EcdsaKeygenResult, EcdsaPublicKey, EcdsaSignature, Ed25519, Ed25519InitKeygenResult, Ed25519KeygenResult, MessageHash } from './internal/web';
|
|
5
|
-
import { Logger } from '@dynamic-labs/logger';
|
|
6
5
|
import { ProviderEnum } from '@dynamic-labs/sdk-api-core';
|
|
6
|
+
import { Logger } from '@dynamic-labs/logger';
|
|
7
7
|
|
|
8
8
|
function _extends() {
|
|
9
9
|
_extends = Object.assign || function assign(target) {
|
|
@@ -130,7 +130,9 @@ const timeoutPromise = ({ timeInMs, activity = 'Ceremony' })=>{
|
|
|
130
130
|
}));
|
|
131
131
|
throw error;
|
|
132
132
|
}
|
|
133
|
-
|
|
133
|
+
// Calculate exponential backoff delay
|
|
134
|
+
const exponentialDelay = retryInterval * 2 ** (attempts - 1);
|
|
135
|
+
await new Promise((resolve)=>setTimeout(resolve, exponentialDelay));
|
|
134
136
|
}
|
|
135
137
|
}
|
|
136
138
|
// TypeScript needs this even though it's unreachable
|
|
@@ -170,6 +172,26 @@ const getGoogleOAuthAccountId = (verifiedCredentials)=>{
|
|
|
170
172
|
const googleVerifiedCredential = verifiedCredentials == null ? void 0 : verifiedCredentials.find((credential)=>credential.oauthProvider === ProviderEnum.Google);
|
|
171
173
|
return googleVerifiedCredential == null ? void 0 : googleVerifiedCredential.id;
|
|
172
174
|
};
|
|
175
|
+
const createBackupData = ({ encryptedKeyShares, accountAddress, thresholdSignatureScheme, hasPassword = true })=>{
|
|
176
|
+
return {
|
|
177
|
+
keyShares: encryptedKeyShares,
|
|
178
|
+
metadata: {
|
|
179
|
+
version: '1.0',
|
|
180
|
+
createdAt: new Date().toISOString(),
|
|
181
|
+
accountAddress,
|
|
182
|
+
thresholdSignatureScheme,
|
|
183
|
+
hasPassword,
|
|
184
|
+
encryption: {
|
|
185
|
+
algorithm: AES_GCM_ALGORITHM,
|
|
186
|
+
keyDerivation: PBKDF2_ALGORITHM,
|
|
187
|
+
iterations: PBKDF2_ITERATIONS,
|
|
188
|
+
hashAlgorithm: PBKDF2_HASH_ALGORITHM,
|
|
189
|
+
algorithmLength: AES_GCM_LENGTH
|
|
190
|
+
},
|
|
191
|
+
shareCount: encryptedKeyShares.length
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
};
|
|
173
195
|
|
|
174
196
|
const PBKDF2_ALGORITHM = 'PBKDF2';
|
|
175
197
|
const PBKDF2_ITERATIONS = 100000;
|
|
@@ -297,9 +319,9 @@ const uploadFileToGoogleDrive = async ({ accessToken, fileName, jsonData, parent
|
|
|
297
319
|
const result = await response.json();
|
|
298
320
|
return result; // Return file metadata, including file ID
|
|
299
321
|
};
|
|
300
|
-
const listFilesFromGoogleDrive = async ({ accessToken,
|
|
322
|
+
const listFilesFromGoogleDrive = async ({ accessToken, fileName })=>{
|
|
301
323
|
// Step 1: List all files inside `appDataFolder` with the specified backup filename
|
|
302
|
-
const resp = await fetch(`${GOOGLE_DRIVE_UPLOAD_API}/drive/v3/files?q=${encodeURIComponent(`name='${
|
|
324
|
+
const resp = await fetch(`${GOOGLE_DRIVE_UPLOAD_API}/drive/v3/files?q=${encodeURIComponent(`name='${fileName}'`)}&spaces=appDataFolder&orderBy=createdTime desc`, {
|
|
303
325
|
headers: {
|
|
304
326
|
Authorization: `Bearer ${accessToken}`
|
|
305
327
|
}
|
|
@@ -312,10 +334,10 @@ const listFilesFromGoogleDrive = async ({ accessToken, name })=>{
|
|
|
312
334
|
const files = data.files;
|
|
313
335
|
return files;
|
|
314
336
|
};
|
|
315
|
-
const downloadFileFromGoogleDrive = async ({ accessToken,
|
|
337
|
+
const downloadFileFromGoogleDrive = async ({ accessToken, fileName })=>{
|
|
316
338
|
const files = await listFilesFromGoogleDrive({
|
|
317
339
|
accessToken,
|
|
318
|
-
|
|
340
|
+
fileName
|
|
319
341
|
});
|
|
320
342
|
if (!files || files.length === 0) {
|
|
321
343
|
return null;
|
|
@@ -411,6 +433,56 @@ const localStorageWriteTest = {
|
|
|
411
433
|
}
|
|
412
434
|
});
|
|
413
435
|
|
|
436
|
+
/**
|
|
437
|
+
* Updates the wallet map with backup information after successful backup to Google Drive
|
|
438
|
+
* @param data - Response data containing key shares information
|
|
439
|
+
* @param walletMap - The wallet map to update
|
|
440
|
+
* @param accountAddress - The account address associated with the wallet
|
|
441
|
+
* @param backupLocation - The location where the backup is stored
|
|
442
|
+
* @param storage - Storage interface for persisting the updated wallet map
|
|
443
|
+
* @param storageKey - Key used to store the wallet map
|
|
444
|
+
* @returns The array of key share IDs that were backed up
|
|
445
|
+
*/ const updateWalletMapWithBackupInfo = async ({ data, walletMap, accountAddress, storage, storageKey })=>{
|
|
446
|
+
const ids = data.keyShares.map((keyShare)=>keyShare.id);
|
|
447
|
+
walletMap[accountAddress].clientKeySharesBackupInfo.backups[BackupLocation.GOOGLE_DRIVE] = ids;
|
|
448
|
+
await storage.setItem(storageKey, JSON.stringify(walletMap));
|
|
449
|
+
return ids;
|
|
450
|
+
};
|
|
451
|
+
/**
|
|
452
|
+
* Uploads a backup to Google Drive App
|
|
453
|
+
* @param accessToken - The access token for the Google Drive API
|
|
454
|
+
* @param fileName - The name of the file to upload
|
|
455
|
+
* @param backupData - The data to upload
|
|
456
|
+
* @param accountAddress - The account address associated with the backup
|
|
457
|
+
*/ const uploadBackupToGoogleDrive = async ({ accessToken, fileName, backupData, accountAddress })=>{
|
|
458
|
+
try {
|
|
459
|
+
await retryPromise(()=>uploadFileToGoogleDriveAppStorage({
|
|
460
|
+
accessToken,
|
|
461
|
+
fileName,
|
|
462
|
+
jsonData: backupData
|
|
463
|
+
}));
|
|
464
|
+
} catch (error) {
|
|
465
|
+
logger.error('Failed to upload keyshares to Google Drive App Storage', {
|
|
466
|
+
accountAddress,
|
|
467
|
+
error
|
|
468
|
+
});
|
|
469
|
+
throw new Error(`Failed to backup keyshares to Google Drive App Storage: ${error instanceof Error ? error.message : String(error)}`);
|
|
470
|
+
}
|
|
471
|
+
try {
|
|
472
|
+
await retryPromise(()=>uploadFileToGoogleDrivePersonal({
|
|
473
|
+
accessToken,
|
|
474
|
+
fileName,
|
|
475
|
+
jsonData: backupData
|
|
476
|
+
}));
|
|
477
|
+
} catch (error) {
|
|
478
|
+
logger.error('Failed to upload keyshares to Google Drive Personal', {
|
|
479
|
+
accountAddress,
|
|
480
|
+
error
|
|
481
|
+
});
|
|
482
|
+
throw new Error(`Failed to backup keyshares to Google Drive Personal: ${error instanceof Error ? error.message : String(error)}`);
|
|
483
|
+
}
|
|
484
|
+
};
|
|
485
|
+
|
|
414
486
|
class DynamicWalletClient {
|
|
415
487
|
async initialize() {
|
|
416
488
|
if (this.initializePromise) {
|
|
@@ -1083,7 +1155,7 @@ class DynamicWalletClient {
|
|
|
1083
1155
|
}
|
|
1084
1156
|
this.walletMap = JSON.parse(wallets);
|
|
1085
1157
|
}
|
|
1086
|
-
async backupKeySharesToGoogleDrive({ accountAddress,
|
|
1158
|
+
async backupKeySharesToGoogleDrive({ accountAddress, password }) {
|
|
1087
1159
|
await this.getWallet({
|
|
1088
1160
|
accountAddress,
|
|
1089
1161
|
walletOperation: WalletOperation.REACH_ALL_PARTIES,
|
|
@@ -1104,50 +1176,33 @@ class DynamicWalletClient {
|
|
|
1104
1176
|
oauthAccountId
|
|
1105
1177
|
});
|
|
1106
1178
|
const thresholdSignatureScheme = this.walletMap[accountAddress].thresholdSignatureScheme;
|
|
1107
|
-
const
|
|
1179
|
+
const fileName = getClientKeyShareExportFileName({
|
|
1108
1180
|
thresholdSignatureScheme,
|
|
1109
1181
|
accountAddress
|
|
1110
1182
|
});
|
|
1111
|
-
const backupData = {
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
iterations: PBKDF2_ITERATIONS,
|
|
1123
|
-
hashAlgorithm: PBKDF2_HASH_ALGORITHM,
|
|
1124
|
-
algorithmLength: AES_GCM_LENGTH
|
|
1125
|
-
},
|
|
1126
|
-
shareCount: encryptedKeyShares.length
|
|
1127
|
-
}
|
|
1128
|
-
};
|
|
1129
|
-
// TODO: handle errors
|
|
1130
|
-
await Promise.all([
|
|
1131
|
-
uploadFileToGoogleDriveAppStorage({
|
|
1132
|
-
accessToken,
|
|
1133
|
-
fileName: fileName != null ? fileName : suggestedFileName,
|
|
1134
|
-
jsonData: backupData
|
|
1135
|
-
}),
|
|
1136
|
-
uploadFileToGoogleDrivePersonal({
|
|
1137
|
-
accessToken,
|
|
1138
|
-
fileName: fileName != null ? fileName : suggestedFileName,
|
|
1139
|
-
jsonData: backupData
|
|
1140
|
-
})
|
|
1141
|
-
]);
|
|
1183
|
+
const backupData = createBackupData({
|
|
1184
|
+
encryptedKeyShares,
|
|
1185
|
+
accountAddress,
|
|
1186
|
+
thresholdSignatureScheme
|
|
1187
|
+
});
|
|
1188
|
+
await uploadBackupToGoogleDrive({
|
|
1189
|
+
accessToken,
|
|
1190
|
+
fileName,
|
|
1191
|
+
backupData,
|
|
1192
|
+
accountAddress
|
|
1193
|
+
});
|
|
1142
1194
|
const data = await this.apiClient.markKeySharesAsBackedUpGoogleDrive({
|
|
1143
1195
|
walletId: this.walletMap[accountAddress].walletId
|
|
1144
1196
|
});
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1197
|
+
await updateWalletMapWithBackupInfo({
|
|
1198
|
+
data,
|
|
1199
|
+
walletMap: this.walletMap,
|
|
1200
|
+
accountAddress,
|
|
1201
|
+
storage: this.storage,
|
|
1202
|
+
storageKey: this.storageKey
|
|
1203
|
+
});
|
|
1149
1204
|
}
|
|
1150
|
-
async restoreBackupFromGoogleDrive({ accountAddress,
|
|
1205
|
+
async restoreBackupFromGoogleDrive({ accountAddress, password }) {
|
|
1151
1206
|
await this.getWallet({
|
|
1152
1207
|
accountAddress
|
|
1153
1208
|
});
|
|
@@ -1156,19 +1211,37 @@ class DynamicWalletClient {
|
|
|
1156
1211
|
oauthAccountId
|
|
1157
1212
|
});
|
|
1158
1213
|
const thresholdSignatureScheme = this.walletMap[accountAddress].thresholdSignatureScheme;
|
|
1159
|
-
const
|
|
1214
|
+
const fileName = getClientKeyShareExportFileName({
|
|
1160
1215
|
thresholdSignatureScheme,
|
|
1161
1216
|
accountAddress
|
|
1162
1217
|
});
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1218
|
+
let backupData = null;
|
|
1219
|
+
try {
|
|
1220
|
+
backupData = await retryPromise(()=>downloadFileFromGoogleDrive({
|
|
1221
|
+
accessToken,
|
|
1222
|
+
fileName
|
|
1223
|
+
}));
|
|
1224
|
+
} catch (error) {
|
|
1225
|
+
this.logger.error('Failed to download backup from Google Drive', {
|
|
1226
|
+
accountAddress,
|
|
1227
|
+
fileName,
|
|
1228
|
+
error
|
|
1229
|
+
});
|
|
1230
|
+
throw new Error('Failed to restore backup from Google Drive');
|
|
1231
|
+
}
|
|
1167
1232
|
if (!backupData) {
|
|
1233
|
+
this.logger.error('No backup file found', {
|
|
1234
|
+
accountAddress,
|
|
1235
|
+
fileName
|
|
1236
|
+
});
|
|
1168
1237
|
throw new Error('No backup file found');
|
|
1169
1238
|
}
|
|
1170
1239
|
// Validate the backup data structure
|
|
1171
1240
|
if (!backupData.keyShares || !backupData.metadata) {
|
|
1241
|
+
this.logger.error('Invalid backup format: missing keyShares or metadata', {
|
|
1242
|
+
accountAddress,
|
|
1243
|
+
fileName
|
|
1244
|
+
});
|
|
1172
1245
|
throw new Error('Invalid backup format: missing keyShares or metadata');
|
|
1173
1246
|
}
|
|
1174
1247
|
const { keyShares } = backupData;
|
|
@@ -1480,4 +1553,4 @@ class DynamicWalletClient {
|
|
|
1480
1553
|
}
|
|
1481
1554
|
}
|
|
1482
1555
|
|
|
1483
|
-
export { DynamicWalletClient, base64ToBytes, bytesToBase64, ensureBase64Padding, formatEvmMessage, formatMessage, getClientKeyShareBackupInfo, getClientKeyShareExportFileName, getGoogleOAuthAccountId, getMPCSignatureScheme, getMPCSigner, isBrowser, isHexString, mergeUniqueKeyShares, retryPromise, stringToBytes, timeoutPromise };
|
|
1556
|
+
export { DynamicWalletClient, base64ToBytes, bytesToBase64, createBackupData, ensureBase64Padding, formatEvmMessage, formatMessage, getClientKeyShareBackupInfo, getClientKeyShareExportFileName, getGoogleOAuthAccountId, getMPCSignatureScheme, getMPCSigner, isBrowser, isHexString, mergeUniqueKeyShares, retryPromise, stringToBytes, timeoutPromise };
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs-wallet/browser",
|
|
3
|
-
"version": "0.0.0-beta.154.
|
|
3
|
+
"version": "0.0.0-beta.154.2",
|
|
4
4
|
"license": "Licensed under the Dynamic Labs, Inc. Terms Of Service (https://www.dynamic.xyz/terms-conditions)",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@dynamic-labs-wallet/core": "0.0.0-beta.154.
|
|
6
|
+
"@dynamic-labs-wallet/core": "0.0.0-beta.154.2",
|
|
7
7
|
"@dynamic-labs/logger": "^4.9.9",
|
|
8
8
|
"@noble/hashes": "1.7.1"
|
|
9
9
|
},
|
|
@@ -8,12 +8,12 @@ export declare const uploadFileToGoogleDrivePersonal: ({ accessToken, fileName,
|
|
|
8
8
|
fileName: string;
|
|
9
9
|
jsonData: unknown;
|
|
10
10
|
}) => Promise<any>;
|
|
11
|
-
export declare const listFilesFromGoogleDrive: ({ accessToken,
|
|
11
|
+
export declare const listFilesFromGoogleDrive: ({ accessToken, fileName, }: {
|
|
12
12
|
accessToken: string;
|
|
13
|
-
|
|
13
|
+
fileName: string;
|
|
14
14
|
}) => Promise<any>;
|
|
15
|
-
export declare const downloadFileFromGoogleDrive: ({ accessToken,
|
|
15
|
+
export declare const downloadFileFromGoogleDrive: ({ accessToken, fileName, }: {
|
|
16
16
|
accessToken: string;
|
|
17
|
-
|
|
17
|
+
fileName: string;
|
|
18
18
|
}) => Promise<unknown | null>;
|
|
19
19
|
//# sourceMappingURL=googleDrive.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"googleDrive.d.ts","sourceRoot":"","sources":["../../../src/backup/providers/googleDrive.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iCAAiC,yCAI3C;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;CACnB,iBAOA,CAAC;AAEF,eAAO,MAAM,+BAA+B,yCAIzC;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;CACnB,iBAOA,CAAC;AAgDF,eAAO,MAAM,wBAAwB
|
|
1
|
+
{"version":3,"file":"googleDrive.d.ts","sourceRoot":"","sources":["../../../src/backup/providers/googleDrive.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iCAAiC,yCAI3C;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;CACnB,iBAOA,CAAC;AAEF,eAAO,MAAM,+BAA+B,yCAIzC;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;CACnB,iBAOA,CAAC;AAgDF,eAAO,MAAM,wBAAwB,+BAGlC;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB,iBAsBA,CAAC;AAEF,eAAO,MAAM,2BAA2B,+BAGrC;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB,KAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAgCzB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { SupportedStorage } from '../services/localStorage';
|
|
2
|
+
import type { WalletProperties } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Updates the wallet map with backup information after successful backup to Google Drive
|
|
5
|
+
* @param data - Response data containing key shares information
|
|
6
|
+
* @param walletMap - The wallet map to update
|
|
7
|
+
* @param accountAddress - The account address associated with the wallet
|
|
8
|
+
* @param backupLocation - The location where the backup is stored
|
|
9
|
+
* @param storage - Storage interface for persisting the updated wallet map
|
|
10
|
+
* @param storageKey - Key used to store the wallet map
|
|
11
|
+
* @returns The array of key share IDs that were backed up
|
|
12
|
+
*/
|
|
13
|
+
export declare const updateWalletMapWithBackupInfo: ({ data, walletMap, accountAddress, storage, storageKey, }: {
|
|
14
|
+
data: {
|
|
15
|
+
keyShares: Array<{
|
|
16
|
+
id: string;
|
|
17
|
+
}>;
|
|
18
|
+
};
|
|
19
|
+
walletMap: Record<string, WalletProperties>;
|
|
20
|
+
accountAddress: string;
|
|
21
|
+
storage: SupportedStorage;
|
|
22
|
+
storageKey: string;
|
|
23
|
+
}) => Promise<string[]>;
|
|
24
|
+
/**
|
|
25
|
+
* Uploads a backup to Google Drive App
|
|
26
|
+
* @param accessToken - The access token for the Google Drive API
|
|
27
|
+
* @param fileName - The name of the file to upload
|
|
28
|
+
* @param backupData - The data to upload
|
|
29
|
+
* @param accountAddress - The account address associated with the backup
|
|
30
|
+
*/
|
|
31
|
+
export declare const uploadBackupToGoogleDrive: ({ accessToken, fileName, backupData, accountAddress, }: {
|
|
32
|
+
accessToken: string;
|
|
33
|
+
fileName: string;
|
|
34
|
+
backupData: any;
|
|
35
|
+
accountAddress: string;
|
|
36
|
+
}) => Promise<void>;
|
|
37
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/backup/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAIjD;;;;;;;;;GASG;AACH,eAAO,MAAM,6BAA6B,8DAMvC;IACD,IAAI,EAAE;QAAE,SAAS,EAAE,KAAK,CAAC;YAAE,EAAE,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC;IAC3C,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAC5C,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,gBAAgB,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;CACpB,KAAG,OAAO,CAAC,MAAM,EAAE,CAQnB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,2DAKnC;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,GAAG,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;CACxB,kBAwCA,CAAC"}
|
package/src/client.d.ts
CHANGED
|
@@ -238,14 +238,12 @@ export declare class DynamicWalletClient {
|
|
|
238
238
|
storeRecoveredShares?: boolean;
|
|
239
239
|
}): Promise<any[]>;
|
|
240
240
|
restoreWallets(): Promise<void>;
|
|
241
|
-
backupKeySharesToGoogleDrive({ accountAddress,
|
|
241
|
+
backupKeySharesToGoogleDrive({ accountAddress, password, }: {
|
|
242
242
|
accountAddress: string;
|
|
243
|
-
fileName?: string;
|
|
244
243
|
password?: string;
|
|
245
|
-
}): Promise<
|
|
246
|
-
restoreBackupFromGoogleDrive({ accountAddress,
|
|
244
|
+
}): Promise<void>;
|
|
245
|
+
restoreBackupFromGoogleDrive({ accountAddress, password, }: {
|
|
247
246
|
accountAddress: string;
|
|
248
|
-
name?: string;
|
|
249
247
|
password?: string;
|
|
250
248
|
}): Promise<ClientKeyShare[]>;
|
|
251
249
|
exportClientKeyshares({ accountAddress, password, }: {
|
package/src/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../packages/src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,wBAAwB,EAC7B,gBAAgB,EAIhB,cAAc,EAEd,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,eAAe,EAGhB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAIL,KAAK,cAAc,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,KAAK,cAAc,EAEpB,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"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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;IAoBzB,SAAS,CAAC,EACd,cAAc,EACd,eAA8C,EAC9C,UAAsB,EACtB,QAAoB,GACrB,EAAE;QACD,cAAc,EAAE,MAAM,CAAC;QACvB,eAAe,CAAC,EAAE,eAAe,CAAC;QAClC,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB;IA2EK,UAAU;CAkCjB"}
|
package/src/utils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import type { ClientKeyShare } from './mpc/types';
|
|
3
|
-
import { MessageHash } from '../../internal/web';
|
|
1
|
+
import { type KeyShareBackupInfo, type ThresholdSignatureScheme, type WaasWalletProperties } from '@dynamic-labs-wallet/core';
|
|
4
2
|
import type { JwtVerifiedCredential } from '@dynamic-labs/sdk-api-core';
|
|
3
|
+
import { MessageHash } from '../../internal/web';
|
|
4
|
+
import type { ClientKeyShare } from './mpc/types';
|
|
5
5
|
export declare const bytesToBase64: (arr: Uint8Array) => string;
|
|
6
6
|
export declare const stringToBytes: (str: string) => Uint8Array;
|
|
7
7
|
export declare const base64ToBytes: (base64: string) => Uint8Array;
|
|
@@ -44,5 +44,28 @@ export declare function retryPromise<T>(operation: () => Promise<T>, { maxAttemp
|
|
|
44
44
|
export declare const formatEvmMessage: (message: string | Uint8Array) => MessageHash;
|
|
45
45
|
export declare const formatMessage: (chainName: string, message: string | Uint8Array) => string | Uint8Array | MessageHash;
|
|
46
46
|
export declare const getGoogleOAuthAccountId: (verifiedCredentials: JwtVerifiedCredential[]) => string | undefined;
|
|
47
|
+
export declare const createBackupData: ({ encryptedKeyShares, accountAddress, thresholdSignatureScheme, hasPassword, }: {
|
|
48
|
+
encryptedKeyShares: string[];
|
|
49
|
+
accountAddress: string;
|
|
50
|
+
thresholdSignatureScheme: ThresholdSignatureScheme;
|
|
51
|
+
hasPassword?: boolean;
|
|
52
|
+
}) => {
|
|
53
|
+
keyShares: string[];
|
|
54
|
+
metadata: {
|
|
55
|
+
version: string;
|
|
56
|
+
createdAt: string;
|
|
57
|
+
accountAddress: string;
|
|
58
|
+
thresholdSignatureScheme: ThresholdSignatureScheme;
|
|
59
|
+
hasPassword: boolean;
|
|
60
|
+
encryption: {
|
|
61
|
+
algorithm: string;
|
|
62
|
+
keyDerivation: string;
|
|
63
|
+
iterations: number;
|
|
64
|
+
hashAlgorithm: string;
|
|
65
|
+
algorithmLength: number;
|
|
66
|
+
};
|
|
67
|
+
shareCount: number;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
47
70
|
export {};
|
|
48
71
|
//# sourceMappingURL=utils.d.ts.map
|
package/src/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../packages/src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../packages/src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EAC1B,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAExE,OAAO,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