@dynamic-labs/waas 4.60.0 → 4.61.0

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 CHANGED
@@ -1,4 +1,34 @@
1
1
 
2
+ ## [4.61.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.60.1...v4.61.0) (2026-02-10)
3
+
4
+
5
+ ### Features
6
+
7
+ * add unlockWallet and getWalletRecoveryState to WaaS ([#10407](https://github.com/dynamic-labs/dynamic-auth/issues/10407)) ([e0d1a28](https://github.com/dynamic-labs/dynamic-auth/commit/e0d1a2830f36eee6c6e84737011e8cf59966122d))
8
+ * add useWalletPassword hook for waas wallet password management ([#10399](https://github.com/dynamic-labs/dynamic-auth/issues/10399)) ([508835f](https://github.com/dynamic-labs/dynamic-auth/commit/508835fb0f4f17b7353a4378f4c254e02f0a46ff))
9
+ * add WaaS unlock and recovery UI to mobile demo ([#10408](https://github.com/dynamic-labs/dynamic-auth/issues/10408)) ([94cdb88](https://github.com/dynamic-labs/dynamic-auth/commit/94cdb882fca3c34d157b42d5208f56812008c43b))
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * bump axios to fix high vulnerability ([#10406](https://github.com/dynamic-labs/dynamic-auth/issues/10406)) ([303e2dc](https://github.com/dynamic-labs/dynamic-auth/commit/303e2dcf1e7e8ecad4caf2d74e805ee427c1d00e))
15
+ * patch node-forge CVE-2025-12816 in global-wallet ([#10401](https://github.com/dynamic-labs/dynamic-auth/issues/10401)) ([46e6eb2](https://github.com/dynamic-labs/dynamic-auth/commit/46e6eb28a0add0052299eaa4ac2dcbe8b1faa98c))
16
+
17
+ ### [4.60.1](https://github.com/dynamic-labs/dynamic-auth/compare/v4.60.0...v4.60.1) (2026-02-09)
18
+
19
+
20
+ ### Features
21
+
22
+ * 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))
23
+ * 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))
24
+ * 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))
25
+
26
+
27
+ ### Bug Fixes
28
+
29
+ * 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))
30
+ * 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))
31
+
2
32
  ## [4.60.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.59.2...v4.60.0) (2026-02-05)
3
33
 
4
34
 
package/package.cjs CHANGED
@@ -3,6 +3,6 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "4.60.0";
6
+ var version = "4.61.0";
7
7
 
8
8
  exports.version = version;
package/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  'use client'
2
- var version = "4.60.0";
2
+ var version = "4.61.0";
3
3
 
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/waas",
3
- "version": "4.60.0",
3
+ "version": "4.61.0",
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.60.0",
20
- "@dynamic-labs/sdk-api-core": "0.0.860",
21
- "@dynamic-labs-wallet/browser-wallet-client": "0.0.259",
22
- "@dynamic-labs/ethereum-core": "4.60.0",
23
- "@dynamic-labs/logger": "4.60.0",
24
- "@dynamic-labs/solana-core": "4.60.0",
25
- "@dynamic-labs/sui-core": "4.60.0",
26
- "@dynamic-labs/utils": "4.60.0",
27
- "@dynamic-labs/wallet-book": "4.60.0"
19
+ "@dynamic-labs/assert-package-version": "4.61.0",
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.61.0",
23
+ "@dynamic-labs/logger": "4.61.0",
24
+ "@dynamic-labs/solana-core": "4.61.0",
25
+ "@dynamic-labs/sui-core": "4.61.0",
26
+ "@dynamic-labs/utils": "4.61.0",
27
+ "@dynamic-labs/wallet-book": "4.61.0",
28
+ "@dynamic-labs/wallet-connector-core": "4.61.0"
28
29
  },
29
30
  "peerDependencies": {}
30
31
  }
@@ -37,8 +37,8 @@ const withDynamicWaas = (BaseClass) => {
37
37
  setGetMfaTokenFunction(getMfaToken) {
38
38
  this.getMfaToken = getMfaToken;
39
39
  }
40
- setGetPasswordForSigningFunction(getPasswordForSigning) {
41
- this.getPasswordForSigning = getPasswordForSigning;
40
+ setGetWalletPasswordFunction(getWalletPassword) {
41
+ this.getWalletPassword = getWalletPassword;
42
42
  }
43
43
  /**
44
44
  * Checks if the wallet needs a password for signing operations.
@@ -47,24 +47,18 @@ const withDynamicWaas = (BaseClass) => {
47
47
  */
48
48
  getPasswordIfNeeded(_a) {
49
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
50
  const recoveryState = yield this.getWalletRecoveryState({
56
51
  accountAddress,
57
- signedSessionId,
58
52
  });
59
53
  // If wallet is ready (already unlocked), no password needed
60
54
  if (recoveryState.walletReadyState === 'ready') {
61
55
  return undefined;
62
56
  }
63
57
  // Wallet is encrypted and needs to be unlocked
64
- if (!this.getPasswordForSigning) {
58
+ if (!this.getWalletPassword) {
65
59
  throw new utils.DynamicError('Wallet is locked but no password provider is configured');
66
60
  }
67
- const password = yield this.getPasswordForSigning({
61
+ const password = yield this.getWalletPassword({
68
62
  accountAddress,
69
63
  chainName: this.chainName,
70
64
  });
@@ -95,6 +89,7 @@ const withDynamicWaas = (BaseClass) => {
95
89
  if (!accountAddress) {
96
90
  throw new Error('Account address is required');
97
91
  }
92
+ const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({ accountAddress }));
98
93
  const walletClient = yield this.getWaasWalletClient();
99
94
  const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
100
95
  if (!signedSessionId) {
@@ -107,7 +102,7 @@ const withDynamicWaas = (BaseClass) => {
107
102
  return walletClient.delegateKeyShares({
108
103
  accountAddress,
109
104
  authToken,
110
- password,
105
+ password: resolvedPassword,
111
106
  signedSessionId,
112
107
  });
113
108
  });
@@ -222,6 +217,9 @@ const withDynamicWaas = (BaseClass) => {
222
217
  if (!displayContainer) {
223
218
  throw new utils.DynamicError('Missing display container for export private key');
224
219
  }
220
+ const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({
221
+ accountAddress: targetAccountAddress,
222
+ }));
225
223
  const signedSessionId = yield ((_a = this.getSignedSessionId) === null || _a === void 0 ? void 0 : _a.call(this));
226
224
  if (!signedSessionId) {
227
225
  throw new utils.DynamicError('Signed session ID is required');
@@ -235,7 +233,7 @@ const withDynamicWaas = (BaseClass) => {
235
233
  authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
236
234
  displayContainer,
237
235
  mfaToken,
238
- password,
236
+ password: resolvedPassword,
239
237
  signedSessionId,
240
238
  });
241
239
  });
@@ -249,6 +247,7 @@ const withDynamicWaas = (BaseClass) => {
249
247
  if (!accountAddress) {
250
248
  throw new utils.DynamicError('Account address is required');
251
249
  }
250
+ const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({ accountAddress }));
252
251
  const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
253
252
  if (!signedSessionId) {
254
253
  throw new utils.DynamicError('Signed session ID is required');
@@ -257,7 +256,7 @@ const withDynamicWaas = (BaseClass) => {
257
256
  yield walletClient.exportClientKeyshares({
258
257
  accountAddress,
259
258
  authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
260
- password,
259
+ password: resolvedPassword,
261
260
  signedSessionId,
262
261
  });
263
262
  });
@@ -268,6 +267,7 @@ const withDynamicWaas = (BaseClass) => {
268
267
  if (!accountAddress) {
269
268
  throw new utils.DynamicError('Account address is required');
270
269
  }
270
+ const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({ accountAddress }));
271
271
  const walletClient = yield this.getWaasWalletClient();
272
272
  const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
273
273
  if (!signedSessionId) {
@@ -276,7 +276,7 @@ const withDynamicWaas = (BaseClass) => {
276
276
  return walletClient.backupKeySharesToGoogleDrive({
277
277
  accountAddress,
278
278
  authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
279
- password,
279
+ password: resolvedPassword,
280
280
  signedSessionId,
281
281
  });
282
282
  });
@@ -287,6 +287,7 @@ const withDynamicWaas = (BaseClass) => {
287
287
  if (!accountAddress) {
288
288
  throw new utils.DynamicError('Account address is required');
289
289
  }
290
+ const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({ accountAddress }));
290
291
  const walletClient = yield this.getWaasWalletClient();
291
292
  const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
292
293
  if (!signedSessionId) {
@@ -295,7 +296,7 @@ const withDynamicWaas = (BaseClass) => {
295
296
  return walletClient.exportClientKeysharesFromGoogleDrive({
296
297
  accountAddress,
297
298
  authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
298
- password,
299
+ password: resolvedPassword,
299
300
  signedSessionId,
300
301
  });
301
302
  });
@@ -306,6 +307,7 @@ const withDynamicWaas = (BaseClass) => {
306
307
  if (!accountAddress) {
307
308
  throw new utils.DynamicError('Account address is required');
308
309
  }
310
+ const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({ accountAddress }));
309
311
  const walletClient = yield this.getWaasWalletClient();
310
312
  const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
311
313
  if (!signedSessionId) {
@@ -314,7 +316,7 @@ const withDynamicWaas = (BaseClass) => {
314
316
  return walletClient.backupKeySharesToICloud({
315
317
  accountAddress,
316
318
  authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
317
- password,
319
+ password: resolvedPassword,
318
320
  signedSessionId,
319
321
  });
320
322
  });
@@ -345,6 +347,7 @@ const withDynamicWaas = (BaseClass) => {
345
347
  if (!accountAddress) {
346
348
  throw new utils.DynamicError('Account address is required');
347
349
  }
350
+ const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({ accountAddress }));
348
351
  const walletClient = yield this.getWaasWalletClient();
349
352
  const recoverySignedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
350
353
  const backupSignedSessionId = yield ((_c = this.getSignedSessionId) === null || _c === void 0 ? void 0 : _c.call(this));
@@ -363,7 +366,7 @@ const withDynamicWaas = (BaseClass) => {
363
366
  accountAddress,
364
367
  authToken: (_f = this.getAuthToken) === null || _f === void 0 ? void 0 : _f.call(this),
365
368
  mfaToken,
366
- password,
369
+ password: resolvedPassword,
367
370
  signedSessionId: backupSignedSessionId,
368
371
  });
369
372
  });
@@ -374,6 +377,7 @@ const withDynamicWaas = (BaseClass) => {
374
377
  if (!accountAddress) {
375
378
  throw new utils.DynamicError('Account address is required');
376
379
  }
380
+ const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({ accountAddress }));
377
381
  const walletClient = yield this.getWaasWalletClient();
378
382
  const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
379
383
  if (!signedSessionId) {
@@ -390,7 +394,7 @@ const withDynamicWaas = (BaseClass) => {
390
394
  authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
391
395
  newThresholdSignatureScheme: thresholdSignatureScheme,
392
396
  oldThresholdSignatureScheme,
393
- password,
397
+ password: resolvedPassword,
394
398
  signedSessionId,
395
399
  });
396
400
  });
@@ -401,6 +405,7 @@ const withDynamicWaas = (BaseClass) => {
401
405
  if (!accountAddress) {
402
406
  throw new utils.DynamicError('Account address is required');
403
407
  }
408
+ const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({ accountAddress }));
404
409
  const walletClient = yield this.getWaasWalletClient();
405
410
  const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
406
411
  if (!signedSessionId) {
@@ -409,7 +414,7 @@ const withDynamicWaas = (BaseClass) => {
409
414
  return walletClient.revokeDelegation({
410
415
  accountAddress,
411
416
  authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
412
- password,
417
+ password: resolvedPassword,
413
418
  signedSessionId,
414
419
  });
415
420
  });
@@ -420,6 +425,10 @@ const withDynamicWaas = (BaseClass) => {
420
425
  if (!accountAddress) {
421
426
  throw new utils.DynamicError('Account address is required');
422
427
  }
428
+ const resolvedExistingPassword = existingPassword !== null && existingPassword !== void 0 ? existingPassword : (yield this.getPasswordIfNeeded({ accountAddress }));
429
+ if (!resolvedExistingPassword) {
430
+ throw new utils.DynamicError('Existing password is required to update password');
431
+ }
423
432
  const walletClient = yield this.getWaasWalletClient();
424
433
  const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
425
434
  if (!signedSessionId) {
@@ -428,7 +437,7 @@ const withDynamicWaas = (BaseClass) => {
428
437
  return walletClient.updatePassword({
429
438
  accountAddress,
430
439
  authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
431
- existingPassword,
440
+ existingPassword: resolvedExistingPassword,
432
441
  newPassword,
433
442
  signedSessionId,
434
443
  });
@@ -443,6 +452,7 @@ const withDynamicWaas = (BaseClass) => {
443
452
  if (message.length !== 64) {
444
453
  throw new utils.DynamicError('Message must be 64 characters long');
445
454
  }
455
+ const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({ accountAddress }));
446
456
  const walletClient = yield this.getWaasWalletClient();
447
457
  const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
448
458
  if (!signedSessionId) {
@@ -456,14 +466,18 @@ const withDynamicWaas = (BaseClass) => {
456
466
  authToken: (_d = this.getAuthToken) === null || _d === void 0 ? void 0 : _d.call(this),
457
467
  message,
458
468
  mfaToken,
459
- password,
469
+ password: resolvedPassword,
460
470
  signedSessionId,
461
471
  });
462
472
  });
463
473
  }
464
474
  unlockWallet(_a) {
465
475
  return _tslib.__awaiter(this, arguments, void 0, function* ({ accountAddress, password, }) {
466
- var _b;
476
+ var _b, _c;
477
+ const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({ accountAddress }));
478
+ if (!resolvedPassword) {
479
+ throw new utils.DynamicError('Password is required to unlock this wallet');
480
+ }
467
481
  const walletClient = yield this.getWaasWalletClient();
468
482
  const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
469
483
  if (!signedSessionId) {
@@ -471,16 +485,23 @@ const withDynamicWaas = (BaseClass) => {
471
485
  }
472
486
  return walletClient.unlockWallet({
473
487
  accountAddress,
474
- password,
488
+ authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
489
+ password: resolvedPassword,
475
490
  signedSessionId,
476
491
  });
477
492
  });
478
493
  }
479
494
  getWalletRecoveryState(_a) {
480
- return _tslib.__awaiter(this, arguments, void 0, function* ({ accountAddress, signedSessionId, }) {
495
+ return _tslib.__awaiter(this, arguments, void 0, function* ({ accountAddress, }) {
496
+ var _b, _c;
481
497
  const walletClient = yield this.getWaasWalletClient();
498
+ const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
499
+ if (!signedSessionId) {
500
+ throw new utils.DynamicError('Signed session ID is required');
501
+ }
482
502
  return walletClient.getWalletRecoveryState({
483
503
  accountAddress,
504
+ authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
484
505
  signedSessionId,
485
506
  });
486
507
  });
@@ -1,11 +1,8 @@
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
- export type GetPasswordForSigningFn = (props: {
6
- accountAddress: string;
7
- chainName: string;
8
- }) => Promise<string | undefined>;
9
6
  export declare class WaasExportHandler {
10
7
  private iframeStamper;
11
8
  setIframeStamper(iframe: HTMLIFrameElement): void;
@@ -20,7 +17,7 @@ export declare const withDynamicWaas: <T extends abstract new (...args: any[]) =
20
17
  getMfaToken?: ((props?: {
21
18
  mfaAction?: MFAAction;
22
19
  }) => Promise<string | undefined>) | undefined;
23
- getPasswordForSigning?: GetPasswordForSigningFn | undefined;
20
+ getWalletPassword?: GetWalletPasswordFn | undefined;
24
21
  getAuthToken?: (() => string) | undefined;
25
22
  environmentId?: string | undefined;
26
23
  baseApiUrl?: string | undefined;
@@ -37,7 +34,7 @@ export declare const withDynamicWaas: <T extends abstract new (...args: any[]) =
37
34
  setGetMfaTokenFunction(getMfaToken: (props?: {
38
35
  mfaAction?: MFAAction;
39
36
  }) => Promise<string | undefined>): void;
40
- setGetPasswordForSigningFunction(getPasswordForSigning: GetPasswordForSigningFn): void;
37
+ setGetWalletPasswordFunction(getWalletPassword: GetWalletPasswordFn): void;
41
38
  /**
42
39
  * Checks if the wallet needs a password for signing operations.
43
40
  * Returns the password if needed, or undefined if the wallet is already unlocked.
@@ -118,7 +115,7 @@ export declare const withDynamicWaas: <T extends abstract new (...args: any[]) =
118
115
  }): Promise<void>;
119
116
  updatePassword({ accountAddress, existingPassword, newPassword, }: {
120
117
  accountAddress: string;
121
- existingPassword: string;
118
+ existingPassword?: string;
122
119
  newPassword: string;
123
120
  }): Promise<void>;
124
121
  signRawMessage({ accountAddress, message, password, }: {
@@ -128,11 +125,10 @@ export declare const withDynamicWaas: <T extends abstract new (...args: any[]) =
128
125
  }): Promise<string>;
129
126
  unlockWallet({ accountAddress, password, }: {
130
127
  accountAddress: string;
131
- password: string;
128
+ password?: string;
132
129
  }): Promise<import("@dynamic-labs-wallet/browser-wallet-client").GetWalletResponse>;
133
- getWalletRecoveryState({ accountAddress, signedSessionId, }: {
130
+ getWalletRecoveryState({ accountAddress, }: {
134
131
  accountAddress: string;
135
- signedSessionId: string;
136
132
  }): Promise<import("@dynamic-labs-wallet/browser-wallet-client").WalletRecoveryState>;
137
133
  endSession(): Promise<void>;
138
134
  getActiveAccountAddress(): Promise<string | undefined>;
@@ -33,8 +33,8 @@ const withDynamicWaas = (BaseClass) => {
33
33
  setGetMfaTokenFunction(getMfaToken) {
34
34
  this.getMfaToken = getMfaToken;
35
35
  }
36
- setGetPasswordForSigningFunction(getPasswordForSigning) {
37
- this.getPasswordForSigning = getPasswordForSigning;
36
+ setGetWalletPasswordFunction(getWalletPassword) {
37
+ this.getWalletPassword = getWalletPassword;
38
38
  }
39
39
  /**
40
40
  * Checks if the wallet needs a password for signing operations.
@@ -43,24 +43,18 @@ const withDynamicWaas = (BaseClass) => {
43
43
  */
44
44
  getPasswordIfNeeded(_a) {
45
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
46
  const recoveryState = yield this.getWalletRecoveryState({
52
47
  accountAddress,
53
- signedSessionId,
54
48
  });
55
49
  // If wallet is ready (already unlocked), no password needed
56
50
  if (recoveryState.walletReadyState === 'ready') {
57
51
  return undefined;
58
52
  }
59
53
  // Wallet is encrypted and needs to be unlocked
60
- if (!this.getPasswordForSigning) {
54
+ if (!this.getWalletPassword) {
61
55
  throw new DynamicError('Wallet is locked but no password provider is configured');
62
56
  }
63
- const password = yield this.getPasswordForSigning({
57
+ const password = yield this.getWalletPassword({
64
58
  accountAddress,
65
59
  chainName: this.chainName,
66
60
  });
@@ -91,6 +85,7 @@ const withDynamicWaas = (BaseClass) => {
91
85
  if (!accountAddress) {
92
86
  throw new Error('Account address is required');
93
87
  }
88
+ const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({ accountAddress }));
94
89
  const walletClient = yield this.getWaasWalletClient();
95
90
  const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
96
91
  if (!signedSessionId) {
@@ -103,7 +98,7 @@ const withDynamicWaas = (BaseClass) => {
103
98
  return walletClient.delegateKeyShares({
104
99
  accountAddress,
105
100
  authToken,
106
- password,
101
+ password: resolvedPassword,
107
102
  signedSessionId,
108
103
  });
109
104
  });
@@ -218,6 +213,9 @@ const withDynamicWaas = (BaseClass) => {
218
213
  if (!displayContainer) {
219
214
  throw new DynamicError('Missing display container for export private key');
220
215
  }
216
+ const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({
217
+ accountAddress: targetAccountAddress,
218
+ }));
221
219
  const signedSessionId = yield ((_a = this.getSignedSessionId) === null || _a === void 0 ? void 0 : _a.call(this));
222
220
  if (!signedSessionId) {
223
221
  throw new DynamicError('Signed session ID is required');
@@ -231,7 +229,7 @@ const withDynamicWaas = (BaseClass) => {
231
229
  authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
232
230
  displayContainer,
233
231
  mfaToken,
234
- password,
232
+ password: resolvedPassword,
235
233
  signedSessionId,
236
234
  });
237
235
  });
@@ -245,6 +243,7 @@ const withDynamicWaas = (BaseClass) => {
245
243
  if (!accountAddress) {
246
244
  throw new DynamicError('Account address is required');
247
245
  }
246
+ const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({ accountAddress }));
248
247
  const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
249
248
  if (!signedSessionId) {
250
249
  throw new DynamicError('Signed session ID is required');
@@ -253,7 +252,7 @@ const withDynamicWaas = (BaseClass) => {
253
252
  yield walletClient.exportClientKeyshares({
254
253
  accountAddress,
255
254
  authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
256
- password,
255
+ password: resolvedPassword,
257
256
  signedSessionId,
258
257
  });
259
258
  });
@@ -264,6 +263,7 @@ const withDynamicWaas = (BaseClass) => {
264
263
  if (!accountAddress) {
265
264
  throw new DynamicError('Account address is required');
266
265
  }
266
+ const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({ accountAddress }));
267
267
  const walletClient = yield this.getWaasWalletClient();
268
268
  const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
269
269
  if (!signedSessionId) {
@@ -272,7 +272,7 @@ const withDynamicWaas = (BaseClass) => {
272
272
  return walletClient.backupKeySharesToGoogleDrive({
273
273
  accountAddress,
274
274
  authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
275
- password,
275
+ password: resolvedPassword,
276
276
  signedSessionId,
277
277
  });
278
278
  });
@@ -283,6 +283,7 @@ const withDynamicWaas = (BaseClass) => {
283
283
  if (!accountAddress) {
284
284
  throw new DynamicError('Account address is required');
285
285
  }
286
+ const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({ accountAddress }));
286
287
  const walletClient = yield this.getWaasWalletClient();
287
288
  const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
288
289
  if (!signedSessionId) {
@@ -291,7 +292,7 @@ const withDynamicWaas = (BaseClass) => {
291
292
  return walletClient.exportClientKeysharesFromGoogleDrive({
292
293
  accountAddress,
293
294
  authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
294
- password,
295
+ password: resolvedPassword,
295
296
  signedSessionId,
296
297
  });
297
298
  });
@@ -302,6 +303,7 @@ const withDynamicWaas = (BaseClass) => {
302
303
  if (!accountAddress) {
303
304
  throw new DynamicError('Account address is required');
304
305
  }
306
+ const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({ accountAddress }));
305
307
  const walletClient = yield this.getWaasWalletClient();
306
308
  const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
307
309
  if (!signedSessionId) {
@@ -310,7 +312,7 @@ const withDynamicWaas = (BaseClass) => {
310
312
  return walletClient.backupKeySharesToICloud({
311
313
  accountAddress,
312
314
  authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
313
- password,
315
+ password: resolvedPassword,
314
316
  signedSessionId,
315
317
  });
316
318
  });
@@ -341,6 +343,7 @@ const withDynamicWaas = (BaseClass) => {
341
343
  if (!accountAddress) {
342
344
  throw new DynamicError('Account address is required');
343
345
  }
346
+ const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({ accountAddress }));
344
347
  const walletClient = yield this.getWaasWalletClient();
345
348
  const recoverySignedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
346
349
  const backupSignedSessionId = yield ((_c = this.getSignedSessionId) === null || _c === void 0 ? void 0 : _c.call(this));
@@ -359,7 +362,7 @@ const withDynamicWaas = (BaseClass) => {
359
362
  accountAddress,
360
363
  authToken: (_f = this.getAuthToken) === null || _f === void 0 ? void 0 : _f.call(this),
361
364
  mfaToken,
362
- password,
365
+ password: resolvedPassword,
363
366
  signedSessionId: backupSignedSessionId,
364
367
  });
365
368
  });
@@ -370,6 +373,7 @@ const withDynamicWaas = (BaseClass) => {
370
373
  if (!accountAddress) {
371
374
  throw new DynamicError('Account address is required');
372
375
  }
376
+ const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({ accountAddress }));
373
377
  const walletClient = yield this.getWaasWalletClient();
374
378
  const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
375
379
  if (!signedSessionId) {
@@ -386,7 +390,7 @@ const withDynamicWaas = (BaseClass) => {
386
390
  authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
387
391
  newThresholdSignatureScheme: thresholdSignatureScheme,
388
392
  oldThresholdSignatureScheme,
389
- password,
393
+ password: resolvedPassword,
390
394
  signedSessionId,
391
395
  });
392
396
  });
@@ -397,6 +401,7 @@ const withDynamicWaas = (BaseClass) => {
397
401
  if (!accountAddress) {
398
402
  throw new DynamicError('Account address is required');
399
403
  }
404
+ const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({ accountAddress }));
400
405
  const walletClient = yield this.getWaasWalletClient();
401
406
  const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
402
407
  if (!signedSessionId) {
@@ -405,7 +410,7 @@ const withDynamicWaas = (BaseClass) => {
405
410
  return walletClient.revokeDelegation({
406
411
  accountAddress,
407
412
  authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
408
- password,
413
+ password: resolvedPassword,
409
414
  signedSessionId,
410
415
  });
411
416
  });
@@ -416,6 +421,10 @@ const withDynamicWaas = (BaseClass) => {
416
421
  if (!accountAddress) {
417
422
  throw new DynamicError('Account address is required');
418
423
  }
424
+ const resolvedExistingPassword = existingPassword !== null && existingPassword !== void 0 ? existingPassword : (yield this.getPasswordIfNeeded({ accountAddress }));
425
+ if (!resolvedExistingPassword) {
426
+ throw new DynamicError('Existing password is required to update password');
427
+ }
419
428
  const walletClient = yield this.getWaasWalletClient();
420
429
  const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
421
430
  if (!signedSessionId) {
@@ -424,7 +433,7 @@ const withDynamicWaas = (BaseClass) => {
424
433
  return walletClient.updatePassword({
425
434
  accountAddress,
426
435
  authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
427
- existingPassword,
436
+ existingPassword: resolvedExistingPassword,
428
437
  newPassword,
429
438
  signedSessionId,
430
439
  });
@@ -439,6 +448,7 @@ const withDynamicWaas = (BaseClass) => {
439
448
  if (message.length !== 64) {
440
449
  throw new DynamicError('Message must be 64 characters long');
441
450
  }
451
+ const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({ accountAddress }));
442
452
  const walletClient = yield this.getWaasWalletClient();
443
453
  const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
444
454
  if (!signedSessionId) {
@@ -452,14 +462,18 @@ const withDynamicWaas = (BaseClass) => {
452
462
  authToken: (_d = this.getAuthToken) === null || _d === void 0 ? void 0 : _d.call(this),
453
463
  message,
454
464
  mfaToken,
455
- password,
465
+ password: resolvedPassword,
456
466
  signedSessionId,
457
467
  });
458
468
  });
459
469
  }
460
470
  unlockWallet(_a) {
461
471
  return __awaiter(this, arguments, void 0, function* ({ accountAddress, password, }) {
462
- var _b;
472
+ var _b, _c;
473
+ const resolvedPassword = password !== null && password !== void 0 ? password : (yield this.getPasswordIfNeeded({ accountAddress }));
474
+ if (!resolvedPassword) {
475
+ throw new DynamicError('Password is required to unlock this wallet');
476
+ }
463
477
  const walletClient = yield this.getWaasWalletClient();
464
478
  const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
465
479
  if (!signedSessionId) {
@@ -467,16 +481,23 @@ const withDynamicWaas = (BaseClass) => {
467
481
  }
468
482
  return walletClient.unlockWallet({
469
483
  accountAddress,
470
- password,
484
+ authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
485
+ password: resolvedPassword,
471
486
  signedSessionId,
472
487
  });
473
488
  });
474
489
  }
475
490
  getWalletRecoveryState(_a) {
476
- return __awaiter(this, arguments, void 0, function* ({ accountAddress, signedSessionId, }) {
491
+ return __awaiter(this, arguments, void 0, function* ({ accountAddress, }) {
492
+ var _b, _c;
477
493
  const walletClient = yield this.getWaasWalletClient();
494
+ const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
495
+ if (!signedSessionId) {
496
+ throw new DynamicError('Signed session ID is required');
497
+ }
478
498
  return walletClient.getWalletRecoveryState({
479
499
  accountAddress,
500
+ authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
480
501
  signedSessionId,
481
502
  });
482
503
  });