@dynamic-labs/waas 4.59.2 → 4.60.1
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/CHANGELOG.md +25 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +11 -10
- package/src/DynamicWaasMixin.cjs +75 -14
- package/src/DynamicWaasMixin.d.ts +15 -3
- package/src/DynamicWaasMixin.js +75 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,29 @@
|
|
|
1
1
|
|
|
2
|
+
### [4.60.1](https://github.com/dynamic-labs/dynamic-auth/compare/v4.60.0...v4.60.1) (2026-02-09)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* add WAAS password handlers to DynamicContextProvider settings ([#10360](https://github.com/dynamic-labs/dynamic-auth/issues/10360)) ([5fc3fa7](https://github.com/dynamic-labs/dynamic-auth/commit/5fc3fa7148c53b64d36672be2d1ae629cb9cdaf8))
|
|
8
|
+
* improve password handling and UI for wallet protection ([#10386](https://github.com/dynamic-labs/dynamic-auth/issues/10386)) ([d27936e](https://github.com/dynamic-labs/dynamic-auth/commit/d27936e5bea37facceefccc0f2507d25a775ad33))
|
|
9
|
+
* pass authToken to wallet recovery operations ([#10379](https://github.com/dynamic-labs/dynamic-auth/issues/10379)) ([294efc7](https://github.com/dynamic-labs/dynamic-auth/commit/294efc7ab5816f63b7e5cc49a150cf9d34d300af))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* override fast-xml-parser to 5.3.4 for CVE-2026-25128 ([#10381](https://github.com/dynamic-labs/dynamic-auth/issues/10381)) ([7fb4c22](https://github.com/dynamic-labs/dynamic-auth/commit/7fb4c221252b84bf38bbdab0b37b8f9a981ebe1a))
|
|
15
|
+
* unlock wallet view error handling and password error UI ([#10388](https://github.com/dynamic-labs/dynamic-auth/issues/10388)) ([5ffc8e1](https://github.com/dynamic-labs/dynamic-auth/commit/5ffc8e1e6dd0d7f32bb94c37ce3674be949f010b))
|
|
16
|
+
|
|
17
|
+
## [4.60.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.59.2...v4.60.0) (2026-02-05)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* add prompt to unlock wallet when getting encrypted shares ([#10333](https://github.com/dynamic-labs/dynamic-auth/issues/10333)) ([7009dfa](https://github.com/dynamic-labs/dynamic-auth/commit/7009dfa315538f4f4ad27ff37e7902f10e1cf019))
|
|
23
|
+
* add stellar sendBalance method ([#10310](https://github.com/dynamic-labs/dynamic-auth/issues/10310)) ([c083ea0](https://github.com/dynamic-labs/dynamic-auth/commit/c083ea0a7caa0cb9095d32897acf677c1b661cb4))
|
|
24
|
+
* **webview-controller:** add DelegatedAccessController ([#10348](https://github.com/dynamic-labs/dynamic-auth/issues/10348)) ([57599e4](https://github.com/dynamic-labs/dynamic-auth/commit/57599e4dd1ad6f4b22f98d49d7fae1a724b719ee))
|
|
25
|
+
* **webview-messages:** add DelegatedAccessMessages types ([#10347](https://github.com/dynamic-labs/dynamic-auth/issues/10347)) ([b0a1275](https://github.com/dynamic-labs/dynamic-auth/commit/b0a12759016fa6f8a76753c2394d589acb18ccf1))
|
|
26
|
+
|
|
2
27
|
### [4.59.2](https://github.com/dynamic-labs/dynamic-auth/compare/v4.59.1...v4.59.2) (2026-02-03)
|
|
3
28
|
|
|
4
29
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/waas",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.60.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "Dynamic Labs, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -16,15 +16,16 @@
|
|
|
16
16
|
"./package.json": "./package.json"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@dynamic-labs/assert-package-version": "4.
|
|
20
|
-
"@dynamic-labs/sdk-api-core": "0.0.
|
|
21
|
-
"@dynamic-labs-wallet/browser-wallet-client": "0.0.
|
|
22
|
-
"@dynamic-labs/ethereum-core": "4.
|
|
23
|
-
"@dynamic-labs/logger": "4.
|
|
24
|
-
"@dynamic-labs/solana-core": "4.
|
|
25
|
-
"@dynamic-labs/sui-core": "4.
|
|
26
|
-
"@dynamic-labs/utils": "4.
|
|
27
|
-
"@dynamic-labs/wallet-book": "4.
|
|
19
|
+
"@dynamic-labs/assert-package-version": "4.60.1",
|
|
20
|
+
"@dynamic-labs/sdk-api-core": "0.0.864",
|
|
21
|
+
"@dynamic-labs-wallet/browser-wallet-client": "0.0.260",
|
|
22
|
+
"@dynamic-labs/ethereum-core": "4.60.1",
|
|
23
|
+
"@dynamic-labs/logger": "4.60.1",
|
|
24
|
+
"@dynamic-labs/solana-core": "4.60.1",
|
|
25
|
+
"@dynamic-labs/sui-core": "4.60.1",
|
|
26
|
+
"@dynamic-labs/utils": "4.60.1",
|
|
27
|
+
"@dynamic-labs/wallet-book": "4.60.1",
|
|
28
|
+
"@dynamic-labs/wallet-connector-core": "4.60.1"
|
|
28
29
|
},
|
|
29
30
|
"peerDependencies": {}
|
|
30
31
|
}
|
package/src/DynamicWaasMixin.cjs
CHANGED
|
@@ -37,6 +37,43 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
37
37
|
setGetMfaTokenFunction(getMfaToken) {
|
|
38
38
|
this.getMfaToken = getMfaToken;
|
|
39
39
|
}
|
|
40
|
+
setGetWalletPasswordFunction(getWalletPassword) {
|
|
41
|
+
this.getWalletPassword = getWalletPassword;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Checks if the wallet needs a password for signing operations.
|
|
45
|
+
* Returns the password if needed, or undefined if the wallet is already unlocked.
|
|
46
|
+
* Automatically retrieves the signed session ID internally.
|
|
47
|
+
*/
|
|
48
|
+
getPasswordIfNeeded(_a) {
|
|
49
|
+
return _tslib.__awaiter(this, arguments, void 0, function* ({ accountAddress, }) {
|
|
50
|
+
var _b;
|
|
51
|
+
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
52
|
+
if (!signedSessionId) {
|
|
53
|
+
throw new utils.DynamicError('Signed session ID is required');
|
|
54
|
+
}
|
|
55
|
+
const recoveryState = yield this.getWalletRecoveryState({
|
|
56
|
+
accountAddress,
|
|
57
|
+
signedSessionId,
|
|
58
|
+
});
|
|
59
|
+
// If wallet is ready (already unlocked), no password needed
|
|
60
|
+
if (recoveryState.walletReadyState === 'ready') {
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
// Wallet is encrypted and needs to be unlocked
|
|
64
|
+
if (!this.getWalletPassword) {
|
|
65
|
+
throw new utils.DynamicError('Wallet is locked but no password provider is configured');
|
|
66
|
+
}
|
|
67
|
+
const password = yield this.getWalletPassword({
|
|
68
|
+
accountAddress,
|
|
69
|
+
chainName: this.chainName,
|
|
70
|
+
});
|
|
71
|
+
if (!password) {
|
|
72
|
+
throw new utils.DynamicError('Password is required to sign with this wallet');
|
|
73
|
+
}
|
|
74
|
+
return password;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
40
77
|
setEnvironmentId(environmentId) {
|
|
41
78
|
this.environmentId = environmentId;
|
|
42
79
|
}
|
|
@@ -58,6 +95,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
58
95
|
if (!accountAddress) {
|
|
59
96
|
throw new Error('Account address is required');
|
|
60
97
|
}
|
|
98
|
+
const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({ accountAddress }));
|
|
61
99
|
const walletClient = yield this.getWaasWalletClient();
|
|
62
100
|
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
63
101
|
if (!signedSessionId) {
|
|
@@ -70,7 +108,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
70
108
|
return walletClient.delegateKeyShares({
|
|
71
109
|
accountAddress,
|
|
72
110
|
authToken,
|
|
73
|
-
password,
|
|
111
|
+
password: resolvedPassword,
|
|
74
112
|
signedSessionId,
|
|
75
113
|
});
|
|
76
114
|
});
|
|
@@ -185,6 +223,9 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
185
223
|
if (!displayContainer) {
|
|
186
224
|
throw new utils.DynamicError('Missing display container for export private key');
|
|
187
225
|
}
|
|
226
|
+
const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({
|
|
227
|
+
accountAddress: targetAccountAddress,
|
|
228
|
+
}));
|
|
188
229
|
const signedSessionId = yield ((_a = this.getSignedSessionId) === null || _a === void 0 ? void 0 : _a.call(this));
|
|
189
230
|
if (!signedSessionId) {
|
|
190
231
|
throw new utils.DynamicError('Signed session ID is required');
|
|
@@ -198,7 +239,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
198
239
|
authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
|
|
199
240
|
displayContainer,
|
|
200
241
|
mfaToken,
|
|
201
|
-
password,
|
|
242
|
+
password: resolvedPassword,
|
|
202
243
|
signedSessionId,
|
|
203
244
|
});
|
|
204
245
|
});
|
|
@@ -212,6 +253,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
212
253
|
if (!accountAddress) {
|
|
213
254
|
throw new utils.DynamicError('Account address is required');
|
|
214
255
|
}
|
|
256
|
+
const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({ accountAddress }));
|
|
215
257
|
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
216
258
|
if (!signedSessionId) {
|
|
217
259
|
throw new utils.DynamicError('Signed session ID is required');
|
|
@@ -220,7 +262,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
220
262
|
yield walletClient.exportClientKeyshares({
|
|
221
263
|
accountAddress,
|
|
222
264
|
authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
|
|
223
|
-
password,
|
|
265
|
+
password: resolvedPassword,
|
|
224
266
|
signedSessionId,
|
|
225
267
|
});
|
|
226
268
|
});
|
|
@@ -231,6 +273,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
231
273
|
if (!accountAddress) {
|
|
232
274
|
throw new utils.DynamicError('Account address is required');
|
|
233
275
|
}
|
|
276
|
+
const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({ accountAddress }));
|
|
234
277
|
const walletClient = yield this.getWaasWalletClient();
|
|
235
278
|
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
236
279
|
if (!signedSessionId) {
|
|
@@ -239,7 +282,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
239
282
|
return walletClient.backupKeySharesToGoogleDrive({
|
|
240
283
|
accountAddress,
|
|
241
284
|
authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
|
|
242
|
-
password,
|
|
285
|
+
password: resolvedPassword,
|
|
243
286
|
signedSessionId,
|
|
244
287
|
});
|
|
245
288
|
});
|
|
@@ -250,6 +293,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
250
293
|
if (!accountAddress) {
|
|
251
294
|
throw new utils.DynamicError('Account address is required');
|
|
252
295
|
}
|
|
296
|
+
const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({ accountAddress }));
|
|
253
297
|
const walletClient = yield this.getWaasWalletClient();
|
|
254
298
|
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
255
299
|
if (!signedSessionId) {
|
|
@@ -258,7 +302,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
258
302
|
return walletClient.exportClientKeysharesFromGoogleDrive({
|
|
259
303
|
accountAddress,
|
|
260
304
|
authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
|
|
261
|
-
password,
|
|
305
|
+
password: resolvedPassword,
|
|
262
306
|
signedSessionId,
|
|
263
307
|
});
|
|
264
308
|
});
|
|
@@ -269,6 +313,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
269
313
|
if (!accountAddress) {
|
|
270
314
|
throw new utils.DynamicError('Account address is required');
|
|
271
315
|
}
|
|
316
|
+
const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({ accountAddress }));
|
|
272
317
|
const walletClient = yield this.getWaasWalletClient();
|
|
273
318
|
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
274
319
|
if (!signedSessionId) {
|
|
@@ -277,7 +322,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
277
322
|
return walletClient.backupKeySharesToICloud({
|
|
278
323
|
accountAddress,
|
|
279
324
|
authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
|
|
280
|
-
password,
|
|
325
|
+
password: resolvedPassword,
|
|
281
326
|
signedSessionId,
|
|
282
327
|
});
|
|
283
328
|
});
|
|
@@ -308,6 +353,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
308
353
|
if (!accountAddress) {
|
|
309
354
|
throw new utils.DynamicError('Account address is required');
|
|
310
355
|
}
|
|
356
|
+
const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({ accountAddress }));
|
|
311
357
|
const walletClient = yield this.getWaasWalletClient();
|
|
312
358
|
const recoverySignedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
313
359
|
const backupSignedSessionId = yield ((_c = this.getSignedSessionId) === null || _c === void 0 ? void 0 : _c.call(this));
|
|
@@ -326,7 +372,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
326
372
|
accountAddress,
|
|
327
373
|
authToken: (_f = this.getAuthToken) === null || _f === void 0 ? void 0 : _f.call(this),
|
|
328
374
|
mfaToken,
|
|
329
|
-
password,
|
|
375
|
+
password: resolvedPassword,
|
|
330
376
|
signedSessionId: backupSignedSessionId,
|
|
331
377
|
});
|
|
332
378
|
});
|
|
@@ -337,6 +383,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
337
383
|
if (!accountAddress) {
|
|
338
384
|
throw new utils.DynamicError('Account address is required');
|
|
339
385
|
}
|
|
386
|
+
const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({ accountAddress }));
|
|
340
387
|
const walletClient = yield this.getWaasWalletClient();
|
|
341
388
|
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
342
389
|
if (!signedSessionId) {
|
|
@@ -353,7 +400,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
353
400
|
authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
|
|
354
401
|
newThresholdSignatureScheme: thresholdSignatureScheme,
|
|
355
402
|
oldThresholdSignatureScheme,
|
|
356
|
-
password,
|
|
403
|
+
password: resolvedPassword,
|
|
357
404
|
signedSessionId,
|
|
358
405
|
});
|
|
359
406
|
});
|
|
@@ -364,6 +411,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
364
411
|
if (!accountAddress) {
|
|
365
412
|
throw new utils.DynamicError('Account address is required');
|
|
366
413
|
}
|
|
414
|
+
const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({ accountAddress }));
|
|
367
415
|
const walletClient = yield this.getWaasWalletClient();
|
|
368
416
|
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
369
417
|
if (!signedSessionId) {
|
|
@@ -372,7 +420,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
372
420
|
return walletClient.revokeDelegation({
|
|
373
421
|
accountAddress,
|
|
374
422
|
authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
|
|
375
|
-
password,
|
|
423
|
+
password: resolvedPassword,
|
|
376
424
|
signedSessionId,
|
|
377
425
|
});
|
|
378
426
|
});
|
|
@@ -383,6 +431,10 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
383
431
|
if (!accountAddress) {
|
|
384
432
|
throw new utils.DynamicError('Account address is required');
|
|
385
433
|
}
|
|
434
|
+
const resolvedExistingPassword = existingPassword !== null && existingPassword !== void 0 ? existingPassword : (yield this.getPasswordIfNeeded({ accountAddress }));
|
|
435
|
+
if (!resolvedExistingPassword) {
|
|
436
|
+
throw new utils.DynamicError('Existing password is required to update password');
|
|
437
|
+
}
|
|
386
438
|
const walletClient = yield this.getWaasWalletClient();
|
|
387
439
|
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
388
440
|
if (!signedSessionId) {
|
|
@@ -391,7 +443,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
391
443
|
return walletClient.updatePassword({
|
|
392
444
|
accountAddress,
|
|
393
445
|
authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
|
|
394
|
-
existingPassword,
|
|
446
|
+
existingPassword: resolvedExistingPassword,
|
|
395
447
|
newPassword,
|
|
396
448
|
signedSessionId,
|
|
397
449
|
});
|
|
@@ -406,6 +458,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
406
458
|
if (message.length !== 64) {
|
|
407
459
|
throw new utils.DynamicError('Message must be 64 characters long');
|
|
408
460
|
}
|
|
461
|
+
const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({ accountAddress }));
|
|
409
462
|
const walletClient = yield this.getWaasWalletClient();
|
|
410
463
|
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
411
464
|
if (!signedSessionId) {
|
|
@@ -419,14 +472,18 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
419
472
|
authToken: (_d = this.getAuthToken) === null || _d === void 0 ? void 0 : _d.call(this),
|
|
420
473
|
message,
|
|
421
474
|
mfaToken,
|
|
422
|
-
password,
|
|
475
|
+
password: resolvedPassword,
|
|
423
476
|
signedSessionId,
|
|
424
477
|
});
|
|
425
478
|
});
|
|
426
479
|
}
|
|
427
480
|
unlockWallet(_a) {
|
|
428
481
|
return _tslib.__awaiter(this, arguments, void 0, function* ({ accountAddress, password, }) {
|
|
429
|
-
var _b;
|
|
482
|
+
var _b, _c;
|
|
483
|
+
const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({ accountAddress }));
|
|
484
|
+
if (!resolvedPassword) {
|
|
485
|
+
throw new utils.DynamicError('Password is required to unlock this wallet');
|
|
486
|
+
}
|
|
430
487
|
const walletClient = yield this.getWaasWalletClient();
|
|
431
488
|
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
432
489
|
if (!signedSessionId) {
|
|
@@ -434,16 +491,20 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
434
491
|
}
|
|
435
492
|
return walletClient.unlockWallet({
|
|
436
493
|
accountAddress,
|
|
437
|
-
|
|
494
|
+
authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
|
|
495
|
+
password: resolvedPassword,
|
|
438
496
|
signedSessionId,
|
|
439
497
|
});
|
|
440
498
|
});
|
|
441
499
|
}
|
|
442
500
|
getWalletRecoveryState(_a) {
|
|
443
|
-
return _tslib.__awaiter(this, arguments, void 0, function* ({ accountAddress, }) {
|
|
501
|
+
return _tslib.__awaiter(this, arguments, void 0, function* ({ accountAddress, signedSessionId, }) {
|
|
502
|
+
var _b;
|
|
444
503
|
const walletClient = yield this.getWaasWalletClient();
|
|
445
504
|
return walletClient.getWalletRecoveryState({
|
|
446
505
|
accountAddress,
|
|
506
|
+
authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
|
|
507
|
+
signedSessionId,
|
|
447
508
|
});
|
|
448
509
|
});
|
|
449
510
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BitcoinConfig, DynamicWalletClient } from '@dynamic-labs-wallet/browser-wallet-client';
|
|
2
2
|
import { InstrumentOptions, Logger } from '@dynamic-labs/logger';
|
|
3
3
|
import { MFAAction } from '@dynamic-labs/sdk-api-core';
|
|
4
|
+
import { GetWalletPasswordFn } from '@dynamic-labs/wallet-connector-core';
|
|
4
5
|
import { InstrumentContext, InstrumentationTimer, TraceContext } from '../utils/instrumentation';
|
|
5
6
|
export declare class WaasExportHandler {
|
|
6
7
|
private iframeStamper;
|
|
@@ -16,6 +17,7 @@ export declare const withDynamicWaas: <T extends abstract new (...args: any[]) =
|
|
|
16
17
|
getMfaToken?: ((props?: {
|
|
17
18
|
mfaAction?: MFAAction;
|
|
18
19
|
}) => Promise<string | undefined>) | undefined;
|
|
20
|
+
getWalletPassword?: GetWalletPasswordFn | undefined;
|
|
19
21
|
getAuthToken?: (() => string) | undefined;
|
|
20
22
|
environmentId?: string | undefined;
|
|
21
23
|
baseApiUrl?: string | undefined;
|
|
@@ -32,6 +34,15 @@ export declare const withDynamicWaas: <T extends abstract new (...args: any[]) =
|
|
|
32
34
|
setGetMfaTokenFunction(getMfaToken: (props?: {
|
|
33
35
|
mfaAction?: MFAAction;
|
|
34
36
|
}) => Promise<string | undefined>): void;
|
|
37
|
+
setGetWalletPasswordFunction(getWalletPassword: GetWalletPasswordFn): void;
|
|
38
|
+
/**
|
|
39
|
+
* Checks if the wallet needs a password for signing operations.
|
|
40
|
+
* Returns the password if needed, or undefined if the wallet is already unlocked.
|
|
41
|
+
* Automatically retrieves the signed session ID internally.
|
|
42
|
+
*/
|
|
43
|
+
getPasswordIfNeeded({ accountAddress, }: {
|
|
44
|
+
accountAddress: string;
|
|
45
|
+
}): Promise<string | undefined>;
|
|
35
46
|
setEnvironmentId(environmentId: string): void;
|
|
36
47
|
setBaseApiUrl(baseApiUrl: string): void;
|
|
37
48
|
setBaseClientKeysharesRelayApiUrl(baseClientKeysharesRelayApiUrl?: string): void;
|
|
@@ -104,7 +115,7 @@ export declare const withDynamicWaas: <T extends abstract new (...args: any[]) =
|
|
|
104
115
|
}): Promise<void>;
|
|
105
116
|
updatePassword({ accountAddress, existingPassword, newPassword, }: {
|
|
106
117
|
accountAddress: string;
|
|
107
|
-
existingPassword
|
|
118
|
+
existingPassword?: string;
|
|
108
119
|
newPassword: string;
|
|
109
120
|
}): Promise<void>;
|
|
110
121
|
signRawMessage({ accountAddress, message, password, }: {
|
|
@@ -114,10 +125,11 @@ export declare const withDynamicWaas: <T extends abstract new (...args: any[]) =
|
|
|
114
125
|
}): Promise<string>;
|
|
115
126
|
unlockWallet({ accountAddress, password, }: {
|
|
116
127
|
accountAddress: string;
|
|
117
|
-
password
|
|
128
|
+
password?: string;
|
|
118
129
|
}): Promise<import("@dynamic-labs-wallet/browser-wallet-client").GetWalletResponse>;
|
|
119
|
-
getWalletRecoveryState({ accountAddress, }: {
|
|
130
|
+
getWalletRecoveryState({ accountAddress, signedSessionId, }: {
|
|
120
131
|
accountAddress: string;
|
|
132
|
+
signedSessionId: string;
|
|
121
133
|
}): Promise<import("@dynamic-labs-wallet/browser-wallet-client").WalletRecoveryState>;
|
|
122
134
|
endSession(): Promise<void>;
|
|
123
135
|
getActiveAccountAddress(): Promise<string | undefined>;
|
package/src/DynamicWaasMixin.js
CHANGED
|
@@ -33,6 +33,43 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
33
33
|
setGetMfaTokenFunction(getMfaToken) {
|
|
34
34
|
this.getMfaToken = getMfaToken;
|
|
35
35
|
}
|
|
36
|
+
setGetWalletPasswordFunction(getWalletPassword) {
|
|
37
|
+
this.getWalletPassword = getWalletPassword;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Checks if the wallet needs a password for signing operations.
|
|
41
|
+
* Returns the password if needed, or undefined if the wallet is already unlocked.
|
|
42
|
+
* Automatically retrieves the signed session ID internally.
|
|
43
|
+
*/
|
|
44
|
+
getPasswordIfNeeded(_a) {
|
|
45
|
+
return __awaiter(this, arguments, void 0, function* ({ accountAddress, }) {
|
|
46
|
+
var _b;
|
|
47
|
+
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
48
|
+
if (!signedSessionId) {
|
|
49
|
+
throw new DynamicError('Signed session ID is required');
|
|
50
|
+
}
|
|
51
|
+
const recoveryState = yield this.getWalletRecoveryState({
|
|
52
|
+
accountAddress,
|
|
53
|
+
signedSessionId,
|
|
54
|
+
});
|
|
55
|
+
// If wallet is ready (already unlocked), no password needed
|
|
56
|
+
if (recoveryState.walletReadyState === 'ready') {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
// Wallet is encrypted and needs to be unlocked
|
|
60
|
+
if (!this.getWalletPassword) {
|
|
61
|
+
throw new DynamicError('Wallet is locked but no password provider is configured');
|
|
62
|
+
}
|
|
63
|
+
const password = yield this.getWalletPassword({
|
|
64
|
+
accountAddress,
|
|
65
|
+
chainName: this.chainName,
|
|
66
|
+
});
|
|
67
|
+
if (!password) {
|
|
68
|
+
throw new DynamicError('Password is required to sign with this wallet');
|
|
69
|
+
}
|
|
70
|
+
return password;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
36
73
|
setEnvironmentId(environmentId) {
|
|
37
74
|
this.environmentId = environmentId;
|
|
38
75
|
}
|
|
@@ -54,6 +91,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
54
91
|
if (!accountAddress) {
|
|
55
92
|
throw new Error('Account address is required');
|
|
56
93
|
}
|
|
94
|
+
const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({ accountAddress }));
|
|
57
95
|
const walletClient = yield this.getWaasWalletClient();
|
|
58
96
|
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
59
97
|
if (!signedSessionId) {
|
|
@@ -66,7 +104,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
66
104
|
return walletClient.delegateKeyShares({
|
|
67
105
|
accountAddress,
|
|
68
106
|
authToken,
|
|
69
|
-
password,
|
|
107
|
+
password: resolvedPassword,
|
|
70
108
|
signedSessionId,
|
|
71
109
|
});
|
|
72
110
|
});
|
|
@@ -181,6 +219,9 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
181
219
|
if (!displayContainer) {
|
|
182
220
|
throw new DynamicError('Missing display container for export private key');
|
|
183
221
|
}
|
|
222
|
+
const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({
|
|
223
|
+
accountAddress: targetAccountAddress,
|
|
224
|
+
}));
|
|
184
225
|
const signedSessionId = yield ((_a = this.getSignedSessionId) === null || _a === void 0 ? void 0 : _a.call(this));
|
|
185
226
|
if (!signedSessionId) {
|
|
186
227
|
throw new DynamicError('Signed session ID is required');
|
|
@@ -194,7 +235,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
194
235
|
authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
|
|
195
236
|
displayContainer,
|
|
196
237
|
mfaToken,
|
|
197
|
-
password,
|
|
238
|
+
password: resolvedPassword,
|
|
198
239
|
signedSessionId,
|
|
199
240
|
});
|
|
200
241
|
});
|
|
@@ -208,6 +249,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
208
249
|
if (!accountAddress) {
|
|
209
250
|
throw new DynamicError('Account address is required');
|
|
210
251
|
}
|
|
252
|
+
const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({ accountAddress }));
|
|
211
253
|
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
212
254
|
if (!signedSessionId) {
|
|
213
255
|
throw new DynamicError('Signed session ID is required');
|
|
@@ -216,7 +258,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
216
258
|
yield walletClient.exportClientKeyshares({
|
|
217
259
|
accountAddress,
|
|
218
260
|
authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
|
|
219
|
-
password,
|
|
261
|
+
password: resolvedPassword,
|
|
220
262
|
signedSessionId,
|
|
221
263
|
});
|
|
222
264
|
});
|
|
@@ -227,6 +269,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
227
269
|
if (!accountAddress) {
|
|
228
270
|
throw new DynamicError('Account address is required');
|
|
229
271
|
}
|
|
272
|
+
const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({ accountAddress }));
|
|
230
273
|
const walletClient = yield this.getWaasWalletClient();
|
|
231
274
|
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
232
275
|
if (!signedSessionId) {
|
|
@@ -235,7 +278,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
235
278
|
return walletClient.backupKeySharesToGoogleDrive({
|
|
236
279
|
accountAddress,
|
|
237
280
|
authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
|
|
238
|
-
password,
|
|
281
|
+
password: resolvedPassword,
|
|
239
282
|
signedSessionId,
|
|
240
283
|
});
|
|
241
284
|
});
|
|
@@ -246,6 +289,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
246
289
|
if (!accountAddress) {
|
|
247
290
|
throw new DynamicError('Account address is required');
|
|
248
291
|
}
|
|
292
|
+
const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({ accountAddress }));
|
|
249
293
|
const walletClient = yield this.getWaasWalletClient();
|
|
250
294
|
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
251
295
|
if (!signedSessionId) {
|
|
@@ -254,7 +298,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
254
298
|
return walletClient.exportClientKeysharesFromGoogleDrive({
|
|
255
299
|
accountAddress,
|
|
256
300
|
authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
|
|
257
|
-
password,
|
|
301
|
+
password: resolvedPassword,
|
|
258
302
|
signedSessionId,
|
|
259
303
|
});
|
|
260
304
|
});
|
|
@@ -265,6 +309,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
265
309
|
if (!accountAddress) {
|
|
266
310
|
throw new DynamicError('Account address is required');
|
|
267
311
|
}
|
|
312
|
+
const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({ accountAddress }));
|
|
268
313
|
const walletClient = yield this.getWaasWalletClient();
|
|
269
314
|
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
270
315
|
if (!signedSessionId) {
|
|
@@ -273,7 +318,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
273
318
|
return walletClient.backupKeySharesToICloud({
|
|
274
319
|
accountAddress,
|
|
275
320
|
authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
|
|
276
|
-
password,
|
|
321
|
+
password: resolvedPassword,
|
|
277
322
|
signedSessionId,
|
|
278
323
|
});
|
|
279
324
|
});
|
|
@@ -304,6 +349,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
304
349
|
if (!accountAddress) {
|
|
305
350
|
throw new DynamicError('Account address is required');
|
|
306
351
|
}
|
|
352
|
+
const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({ accountAddress }));
|
|
307
353
|
const walletClient = yield this.getWaasWalletClient();
|
|
308
354
|
const recoverySignedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
309
355
|
const backupSignedSessionId = yield ((_c = this.getSignedSessionId) === null || _c === void 0 ? void 0 : _c.call(this));
|
|
@@ -322,7 +368,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
322
368
|
accountAddress,
|
|
323
369
|
authToken: (_f = this.getAuthToken) === null || _f === void 0 ? void 0 : _f.call(this),
|
|
324
370
|
mfaToken,
|
|
325
|
-
password,
|
|
371
|
+
password: resolvedPassword,
|
|
326
372
|
signedSessionId: backupSignedSessionId,
|
|
327
373
|
});
|
|
328
374
|
});
|
|
@@ -333,6 +379,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
333
379
|
if (!accountAddress) {
|
|
334
380
|
throw new DynamicError('Account address is required');
|
|
335
381
|
}
|
|
382
|
+
const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({ accountAddress }));
|
|
336
383
|
const walletClient = yield this.getWaasWalletClient();
|
|
337
384
|
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
338
385
|
if (!signedSessionId) {
|
|
@@ -349,7 +396,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
349
396
|
authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
|
|
350
397
|
newThresholdSignatureScheme: thresholdSignatureScheme,
|
|
351
398
|
oldThresholdSignatureScheme,
|
|
352
|
-
password,
|
|
399
|
+
password: resolvedPassword,
|
|
353
400
|
signedSessionId,
|
|
354
401
|
});
|
|
355
402
|
});
|
|
@@ -360,6 +407,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
360
407
|
if (!accountAddress) {
|
|
361
408
|
throw new DynamicError('Account address is required');
|
|
362
409
|
}
|
|
410
|
+
const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({ accountAddress }));
|
|
363
411
|
const walletClient = yield this.getWaasWalletClient();
|
|
364
412
|
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
365
413
|
if (!signedSessionId) {
|
|
@@ -368,7 +416,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
368
416
|
return walletClient.revokeDelegation({
|
|
369
417
|
accountAddress,
|
|
370
418
|
authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
|
|
371
|
-
password,
|
|
419
|
+
password: resolvedPassword,
|
|
372
420
|
signedSessionId,
|
|
373
421
|
});
|
|
374
422
|
});
|
|
@@ -379,6 +427,10 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
379
427
|
if (!accountAddress) {
|
|
380
428
|
throw new DynamicError('Account address is required');
|
|
381
429
|
}
|
|
430
|
+
const resolvedExistingPassword = existingPassword !== null && existingPassword !== void 0 ? existingPassword : (yield this.getPasswordIfNeeded({ accountAddress }));
|
|
431
|
+
if (!resolvedExistingPassword) {
|
|
432
|
+
throw new DynamicError('Existing password is required to update password');
|
|
433
|
+
}
|
|
382
434
|
const walletClient = yield this.getWaasWalletClient();
|
|
383
435
|
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
384
436
|
if (!signedSessionId) {
|
|
@@ -387,7 +439,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
387
439
|
return walletClient.updatePassword({
|
|
388
440
|
accountAddress,
|
|
389
441
|
authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
|
|
390
|
-
existingPassword,
|
|
442
|
+
existingPassword: resolvedExistingPassword,
|
|
391
443
|
newPassword,
|
|
392
444
|
signedSessionId,
|
|
393
445
|
});
|
|
@@ -402,6 +454,7 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
402
454
|
if (message.length !== 64) {
|
|
403
455
|
throw new DynamicError('Message must be 64 characters long');
|
|
404
456
|
}
|
|
457
|
+
const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({ accountAddress }));
|
|
405
458
|
const walletClient = yield this.getWaasWalletClient();
|
|
406
459
|
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
407
460
|
if (!signedSessionId) {
|
|
@@ -415,14 +468,18 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
415
468
|
authToken: (_d = this.getAuthToken) === null || _d === void 0 ? void 0 : _d.call(this),
|
|
416
469
|
message,
|
|
417
470
|
mfaToken,
|
|
418
|
-
password,
|
|
471
|
+
password: resolvedPassword,
|
|
419
472
|
signedSessionId,
|
|
420
473
|
});
|
|
421
474
|
});
|
|
422
475
|
}
|
|
423
476
|
unlockWallet(_a) {
|
|
424
477
|
return __awaiter(this, arguments, void 0, function* ({ accountAddress, password, }) {
|
|
425
|
-
var _b;
|
|
478
|
+
var _b, _c;
|
|
479
|
+
const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({ accountAddress }));
|
|
480
|
+
if (!resolvedPassword) {
|
|
481
|
+
throw new DynamicError('Password is required to unlock this wallet');
|
|
482
|
+
}
|
|
426
483
|
const walletClient = yield this.getWaasWalletClient();
|
|
427
484
|
const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
|
|
428
485
|
if (!signedSessionId) {
|
|
@@ -430,16 +487,20 @@ const withDynamicWaas = (BaseClass) => {
|
|
|
430
487
|
}
|
|
431
488
|
return walletClient.unlockWallet({
|
|
432
489
|
accountAddress,
|
|
433
|
-
|
|
490
|
+
authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
|
|
491
|
+
password: resolvedPassword,
|
|
434
492
|
signedSessionId,
|
|
435
493
|
});
|
|
436
494
|
});
|
|
437
495
|
}
|
|
438
496
|
getWalletRecoveryState(_a) {
|
|
439
|
-
return __awaiter(this, arguments, void 0, function* ({ accountAddress, }) {
|
|
497
|
+
return __awaiter(this, arguments, void 0, function* ({ accountAddress, signedSessionId, }) {
|
|
498
|
+
var _b;
|
|
440
499
|
const walletClient = yield this.getWaasWalletClient();
|
|
441
500
|
return walletClient.getWalletRecoveryState({
|
|
442
501
|
accountAddress,
|
|
502
|
+
authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
|
|
503
|
+
signedSessionId,
|
|
443
504
|
});
|
|
444
505
|
});
|
|
445
506
|
}
|