@dynamic-labs/waas-evm 4.25.3 → 4.25.4

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,16 @@
1
1
 
2
+ ### [4.25.4](https://github.com/dynamic-labs/dynamic-auth/compare/v4.25.3...v4.25.4) (2025-07-25)
3
+
4
+
5
+ ### Features
6
+
7
+ * add passkey as a sign in method ([#9210](https://github.com/dynamic-labs/dynamic-auth/issues/9210)) ([90a6938](https://github.com/dynamic-labs/dynamic-auth/commit/90a69389cf89d7092519e58b0052d85c53a19905))
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * **QNTM-3416:** fix rainbow wallet connection on base network ([#9227](https://github.com/dynamic-labs/dynamic-auth/issues/9227)) ([d6dcdc3](https://github.com/dynamic-labs/dynamic-auth/commit/d6dcdc3ead194d7580bb8387432dfd15555158de))
13
+
2
14
  ### [4.25.3](https://github.com/dynamic-labs/dynamic-auth/compare/v4.25.2...v4.25.3) (2025-07-22)
3
15
 
4
16
 
package/package.cjs CHANGED
@@ -3,6 +3,6 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "4.25.3";
6
+ var version = "4.25.4";
7
7
 
8
8
  exports.version = version;
package/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  'use client'
2
- var version = "4.25.3";
2
+ var version = "4.25.4";
3
3
 
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/waas-evm",
3
- "version": "4.25.3",
3
+ "version": "4.25.4",
4
4
  "description": "A React SDK for implementing wallet web3 authentication and authorization to your website.",
5
5
  "author": "Dynamic Labs, Inc.",
6
6
  "license": "MIT",
@@ -18,15 +18,15 @@
18
18
  },
19
19
  "homepage": "https://www.dynamic.xyz/",
20
20
  "dependencies": {
21
- "@dynamic-labs/sdk-api-core": "0.0.724",
21
+ "@dynamic-labs/sdk-api-core": "0.0.728",
22
22
  "viem": "^2.28.4",
23
- "@dynamic-labs/assert-package-version": "4.25.3",
24
- "@dynamic-labs/ethereum-core": "4.25.3",
25
- "@dynamic-labs/logger": "4.25.3",
26
- "@dynamic-labs/types": "4.25.3",
27
- "@dynamic-labs/utils": "4.25.3",
28
- "@dynamic-labs/waas": "4.25.3",
29
- "@dynamic-labs/wallet-connector-core": "4.25.3"
23
+ "@dynamic-labs/assert-package-version": "4.25.4",
24
+ "@dynamic-labs/ethereum-core": "4.25.4",
25
+ "@dynamic-labs/logger": "4.25.4",
26
+ "@dynamic-labs/types": "4.25.4",
27
+ "@dynamic-labs/utils": "4.25.4",
28
+ "@dynamic-labs/waas": "4.25.4",
29
+ "@dynamic-labs/wallet-connector-core": "4.25.4"
30
30
  },
31
31
  "peerDependencies": {}
32
32
  }
@@ -14,21 +14,6 @@ var waas = require('@dynamic-labs/waas');
14
14
  var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
15
15
 
16
16
  const logger = new logger$1.Logger('DynamicWaasConnector');
17
- // This will need to be moved to a base class once we have base classes for waas connectors
18
- class WaasExportHandler {
19
- constructor() {
20
- this.iframeStamper = null;
21
- }
22
- setIframeStamper(iframe) {
23
- this.iframeStamper = iframe;
24
- }
25
- clear() {
26
- if (this.iframeStamper) {
27
- this.iframeStamper.remove();
28
- this.iframeStamper = null;
29
- }
30
- }
31
- }
32
17
  class DynamicWaasEVMConnector extends waas.withDynamicWaas(ethereumCore.EthereumWalletConnector) {
33
18
  constructor(props) {
34
19
  super(props);
@@ -36,7 +21,7 @@ class DynamicWaasEVMConnector extends waas.withDynamicWaas(ethereumCore.Ethereum
36
21
  this.overrideKey = 'dynamicwaas';
37
22
  this.isEmbeddedWallet = true;
38
23
  this._selectedChainId = this.getLastUsedChainId();
39
- this.__exportHandler = new WaasExportHandler();
24
+ this.__exportHandler = new waas.WaasExportHandler();
40
25
  }
41
26
  getLastUsedChainId() {
42
27
  var _a;
@@ -162,6 +147,9 @@ class DynamicWaasEVMConnector extends waas.withDynamicWaas(ethereumCore.Ethereum
162
147
  var _a, _b, _c;
163
148
  const walletClient = yield this.getWaasWalletClient();
164
149
  const signedSessionId = yield ((_a = this.getSignedSessionId) === null || _a === void 0 ? void 0 : _a.call(this));
150
+ if (!signedSessionId) {
151
+ throw new utils.DynamicError('Signed session ID is required');
152
+ }
165
153
  const targetWallet = yield walletClient.getWallet({
166
154
  accountAddress: expectedAddress,
167
155
  authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
@@ -176,43 +164,58 @@ class DynamicWaasEVMConnector extends waas.withDynamicWaas(ethereumCore.Ethereum
176
164
  }
177
165
  });
178
166
  }
167
+ getActiveAccountAddress() {
168
+ return _tslib.__awaiter(this, void 0, void 0, function* () {
169
+ var _a;
170
+ return (_a = this.getActiveAccount()) === null || _a === void 0 ? void 0 : _a.address;
171
+ });
172
+ }
179
173
  getViemAccount(_a) {
180
174
  return _tslib.__awaiter(this, arguments, void 0, function* ({ accountAddress, }) {
181
175
  var _b;
182
176
  const client = yield this.getWaasWalletClient();
183
177
  const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
178
+ if (!signedSessionId) {
179
+ throw new utils.DynamicError('Signed session ID is required');
180
+ }
184
181
  return accounts.toAccount({
185
182
  address: accountAddress,
186
183
  signAuthorization: (parameters) => _tslib.__awaiter(this, void 0, void 0, function* () { return this.signAuthorization(parameters); }),
187
- signMessage: ({ message }) => {
188
- var _a;
184
+ signMessage: (_c) => _tslib.__awaiter(this, [_c], void 0, function* ({ message, }) {
185
+ var _d, _e;
186
+ const mfaToken = yield ((_d = this.getMfaToken) === null || _d === void 0 ? void 0 : _d.call(this));
189
187
  return client.signMessage({
190
188
  accountAddress,
191
- authToken: (_a = this.getAuthToken) === null || _a === void 0 ? void 0 : _a.call(this),
189
+ authToken: (_e = this.getAuthToken) === null || _e === void 0 ? void 0 : _e.call(this),
192
190
  message: message,
191
+ mfaToken,
193
192
  signedSessionId,
194
193
  });
195
- },
196
- signTransaction: (transaction) => {
197
- var _a;
194
+ }),
195
+ signTransaction: (transaction) => _tslib.__awaiter(this, void 0, void 0, function* () {
196
+ var _f, _g;
197
+ const mfaToken = yield ((_f = this.getMfaToken) === null || _f === void 0 ? void 0 : _f.call(this));
198
198
  return client
199
199
  .signTransaction({
200
- authToken: (_a = this.getAuthToken) === null || _a === void 0 ? void 0 : _a.call(this),
200
+ authToken: (_g = this.getAuthToken) === null || _g === void 0 ? void 0 : _g.call(this),
201
+ mfaToken,
201
202
  senderAddress: accountAddress,
202
203
  signedSessionId,
203
204
  transaction: viem.serializeTransaction(transaction),
204
205
  })
205
206
  .then((tx) => tx);
206
- },
207
- signTypedData: (typedData) => {
208
- var _a;
207
+ }),
208
+ signTypedData: (typedData) => _tslib.__awaiter(this, void 0, void 0, function* () {
209
+ var _h, _j;
210
+ const mfaToken = yield ((_h = this.getMfaToken) === null || _h === void 0 ? void 0 : _h.call(this));
209
211
  return client.signTypedData({
210
212
  accountAddress,
211
- authToken: (_a = this.getAuthToken) === null || _a === void 0 ? void 0 : _a.call(this),
213
+ authToken: (_j = this.getAuthToken) === null || _j === void 0 ? void 0 : _j.call(this),
214
+ mfaToken,
212
215
  signedSessionId,
213
216
  typedData: typedData,
214
217
  });
215
- },
218
+ }),
216
219
  });
217
220
  });
218
221
  }
@@ -243,19 +246,6 @@ class DynamicWaasEVMConnector extends waas.withDynamicWaas(ethereumCore.Ethereum
243
246
  walletUiUtils: this.walletUiUtils,
244
247
  });
245
248
  }
246
- createWalletAccount() {
247
- return _tslib.__awaiter(this, arguments, void 0, function* ({ thresholdSignatureScheme = 'TWO_OF_TWO', } = {}) {
248
- var _a, _b;
249
- const walletClient = yield this.getWaasWalletClient();
250
- const signedSessionId = yield ((_a = this.getSignedSessionId) === null || _a === void 0 ? void 0 : _a.call(this));
251
- const createdWallet = yield walletClient.createWalletAccount({
252
- authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
253
- signedSessionId,
254
- thresholdSignatureScheme: thresholdSignatureScheme,
255
- });
256
- return createdWallet;
257
- });
258
- }
259
249
  signMessage(message) {
260
250
  var _a;
261
251
  return (_a = this.getWalletClient()) === null || _a === void 0 ? void 0 : _a.signMessage({ message });
@@ -269,127 +259,66 @@ class DynamicWaasEVMConnector extends waas.withDynamicWaas(ethereumCore.Ethereum
269
259
  this.setActiveAccount(accountAddress);
270
260
  return this.getWalletClient();
271
261
  }
272
- exportPrivateKey() {
273
- return _tslib.__awaiter(this, arguments, void 0, function* ({ accountAddress, displayContainer, password, } = {}) {
274
- var _a, _b;
275
- const walletClient = yield this.getWaasWalletClient();
276
- const targetAccountAddress = accountAddress || ((_a = this.getActiveAccount()) === null || _a === void 0 ? void 0 : _a.address);
277
- if (!targetAccountAddress) {
278
- throw new Error('Account address is required');
279
- }
280
- if (!displayContainer) {
281
- throw new Error('Missing display container for export private key');
282
- }
283
- this.__exportHandler.setIframeStamper(displayContainer);
284
- yield walletClient.exportPrivateKey({
285
- accountAddress: targetAccountAddress,
286
- authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
287
- displayContainer,
288
- password,
289
- });
290
- });
291
- }
292
- getExportHandler() {
293
- return this.__exportHandler;
294
- }
295
- importPrivateKey(_a) {
296
- return _tslib.__awaiter(this, arguments, void 0, function* ({ privateKey, thresholdSignatureScheme = 'TWO_OF_TWO', }) {
297
- var _b, _c;
298
- const walletClient = yield this.getWaasWalletClient();
299
- const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
300
- if (!signedSessionId) {
301
- throw new Error('Signed session ID is required');
302
- }
303
- yield walletClient.importPrivateKey({
304
- authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
305
- privateKey,
306
- signedSessionId,
307
- thresholdSignatureScheme: thresholdSignatureScheme,
308
- });
309
- });
310
- }
262
+ // Chain-specific override for exportClientKeyshares - EVM needs to set active account first
311
263
  exportClientKeyshares(_a) {
264
+ const _super = Object.create(null, {
265
+ exportClientKeyshares: { get: () => super.exportClientKeyshares }
266
+ });
312
267
  return _tslib.__awaiter(this, arguments, void 0, function* ({ accountAddress, password, }) {
313
- var _b, _c;
314
268
  if (!accountAddress) {
315
269
  throw new Error('Account address is required');
316
270
  }
317
- const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
271
+ // EVM-specific: set active account before exporting
318
272
  this.setActiveAccount(accountAddress);
319
- const walletClient = yield this.getWaasWalletClient();
320
- yield walletClient.exportClientKeyshares({
321
- accountAddress,
322
- authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
323
- password,
324
- signedSessionId,
325
- });
273
+ return _super.exportClientKeyshares.call(this, { accountAddress, password });
326
274
  });
327
275
  }
276
+ // Chain-specific override for backupKeySharesToGoogleDrive - EVM needs to set active account first
328
277
  backupKeySharesToGoogleDrive(_a) {
278
+ const _super = Object.create(null, {
279
+ backupKeySharesToGoogleDrive: { get: () => super.backupKeySharesToGoogleDrive }
280
+ });
329
281
  return _tslib.__awaiter(this, arguments, void 0, function* ({ accountAddress, password, }) {
330
- var _b;
331
282
  if (!accountAddress) {
332
283
  throw new Error('Account address is required');
333
284
  }
285
+ // EVM-specific: set active account before backing up
334
286
  this.setActiveAccount(accountAddress);
335
- const walletClient = yield this.getWaasWalletClient();
336
- return walletClient.backupKeySharesToGoogleDrive({
337
- accountAddress,
338
- authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
339
- password,
340
- });
287
+ return _super.backupKeySharesToGoogleDrive.call(this, { accountAddress, password });
341
288
  });
342
289
  }
290
+ // Chain-specific override for refreshWalletAccountShares - EVM needs to set active account first
343
291
  refreshWalletAccountShares(_a) {
292
+ const _super = Object.create(null, {
293
+ refreshWalletAccountShares: { get: () => super.refreshWalletAccountShares }
294
+ });
344
295
  return _tslib.__awaiter(this, arguments, void 0, function* ({ accountAddress, password, }) {
345
- var _b;
346
296
  if (!accountAddress) {
347
297
  throw new Error('Account address is required');
348
298
  }
299
+ // EVM-specific: set active account before refreshing
349
300
  this.setActiveAccount(accountAddress);
350
- const walletClient = yield this.getWaasWalletClient();
351
- return walletClient.refreshWalletAccountShares({
352
- accountAddress,
353
- authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
354
- password,
355
- });
301
+ return _super.refreshWalletAccountShares.call(this, { accountAddress, password });
356
302
  });
357
303
  }
304
+ // Chain-specific override for updatePassword - EVM needs to set active account first
358
305
  updatePassword(_a) {
306
+ const _super = Object.create(null, {
307
+ updatePassword: { get: () => super.updatePassword }
308
+ });
359
309
  return _tslib.__awaiter(this, arguments, void 0, function* ({ accountAddress, existingPassword, newPassword, }) {
360
- var _b;
361
310
  if (!accountAddress) {
362
311
  throw new Error('Account address is required');
363
312
  }
313
+ // EVM-specific: set active account before updating password
364
314
  this.setActiveAccount(accountAddress);
365
- const walletClient = yield this.getWaasWalletClient();
366
- return walletClient.updatePassword({
315
+ return _super.updatePassword.call(this, {
367
316
  accountAddress,
368
- authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
369
317
  existingPassword,
370
318
  newPassword,
371
319
  });
372
320
  });
373
321
  }
374
- signRawMessage(_a) {
375
- return _tslib.__awaiter(this, arguments, void 0, function* ({ accountAddress, message, password, }) {
376
- var _b;
377
- if (!accountAddress) {
378
- throw new Error('Account address is required');
379
- }
380
- if (message.length !== 64) {
381
- throw new Error('Message must be 64 characters long');
382
- }
383
- this.setActiveAccount(accountAddress);
384
- const walletClient = yield this.getWaasWalletClient();
385
- return walletClient.signRawMessage({
386
- accountAddress,
387
- authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
388
- message,
389
- password,
390
- });
391
- });
392
- }
393
322
  createUiTransaction(from) {
394
323
  return _tslib.__awaiter(this, void 0, void 0, function* () {
395
324
  yield this.validateActiveWallet(from);
@@ -459,7 +388,7 @@ class DynamicWaasEVMConnector extends waas.withDynamicWaas(ethereumCore.Ethereum
459
388
  }
460
389
  signAuthorization(parameters, password) {
461
390
  return _tslib.__awaiter(this, void 0, void 0, function* () {
462
- var _a, _b;
391
+ var _a, _b, _c;
463
392
  const { address: contractAddress, nonce, chainId } = parameters;
464
393
  if (!contractAddress) {
465
394
  throw new Error('Contract address not found');
@@ -474,14 +403,19 @@ class DynamicWaasEVMConnector extends waas.withDynamicWaas(ethereumCore.Ethereum
474
403
  const { address } = signer.account;
475
404
  const walletClient = yield this.getWaasWalletClient();
476
405
  const signedSessionId = yield ((_a = this.getSignedSessionId) === null || _a === void 0 ? void 0 : _a.call(this));
406
+ if (!signedSessionId) {
407
+ throw new utils.DynamicError('Signed session ID is required');
408
+ }
409
+ const mfaToken = yield ((_b = this.getMfaToken) === null || _b === void 0 ? void 0 : _b.call(this));
477
410
  const signature = yield walletClient.signRawMessage({
478
411
  accountAddress: address,
479
- authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
412
+ authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
480
413
  message: utils$1.hashAuthorization({
481
414
  address: contractAddress,
482
415
  chainId,
483
416
  nonce,
484
417
  }).slice(2),
418
+ mfaToken,
485
419
  password,
486
420
  signedSessionId,
487
421
  });
@@ -517,12 +451,11 @@ class DynamicWaasEVMConnector extends waas.withDynamicWaas(ethereumCore.Ethereum
517
451
  return true;
518
452
  }
519
453
  endSession() {
454
+ const _super = Object.create(null, {
455
+ endSession: { get: () => super.endSession }
456
+ });
520
457
  return _tslib.__awaiter(this, void 0, void 0, function* () {
521
- const waasEvmClient = yield this.getWaasWalletClient();
522
- if (!waasEvmClient) {
523
- return;
524
- }
525
- yield waasEvmClient.cleanup();
458
+ yield _super.endSession.call(this);
526
459
  });
527
460
  }
528
461
  }
@@ -3,6 +3,7 @@ import { LocalAccount, SignAuthorizationParameters, SignAuthorizationReturnType
3
3
  import { EthereumWalletConnector, EthereumWalletConnectorOpts, SwitchNetworkOps } from '@dynamic-labs/ethereum-core';
4
4
  import { JwtVerifiedCredential } from '@dynamic-labs/sdk-api-core';
5
5
  import { IUITransaction } from '@dynamic-labs/types';
6
+ import { WaasExportHandler } from '@dynamic-labs/waas';
6
7
  import { IDynamicWaasConnector } from '@dynamic-labs/wallet-connector-core';
7
8
  interface JwtVerifiedCredentialWithSmartWalletRef extends JwtVerifiedCredential {
8
9
  smartWalletRefId?: string;
@@ -15,25 +16,82 @@ declare const DynamicWaasEVMConnector_base: (abstract new (...args: any[]) => {
15
16
  overrideKey: string;
16
17
  isEmbeddedWallet: boolean;
17
18
  getSignedSessionId?: (() => Promise<string>) | undefined;
19
+ getMfaToken?: (() => Promise<string | undefined>) | undefined;
18
20
  getAuthToken?: (() => string) | undefined;
19
21
  environmentId?: string | undefined;
20
22
  baseApiUrl?: string | undefined;
21
23
  relayUrl?: string | undefined;
22
24
  dynamicWaasClient: import("@dynamic-labs-wallet/browser-wallet-client").DynamicWalletClient | undefined;
23
25
  chainName: string;
26
+ __exportHandler: WaasExportHandler;
27
+ validateActiveWallet(expectedAddress: string): Promise<void>;
24
28
  setGetAuthTokenFunction(getAuthToken: () => string): void;
29
+ setGetMfaTokenFunction(getMfaToken: () => Promise<string | undefined>): void;
25
30
  setEnvironmentId(environmentId: string): void;
26
31
  setBaseApiUrl(baseApiUrl: string): void;
27
32
  setRelayUrl(relayUrl: string): void;
28
33
  setGetSignedSessionIdFunction(getSignedSessionId: () => Promise<string>): void;
34
+ delegateKeyShares({ accountAddress, password, }: {
35
+ accountAddress: string;
36
+ password?: string | undefined;
37
+ }): Promise<void>;
29
38
  createDynamicWaasClient(): Promise<import("@dynamic-labs-wallet/browser-wallet-client").DynamicWalletClient>;
30
39
  getWaasWalletClient(): Promise<import("@dynamic-labs-wallet/browser-wallet-client").DynamicWalletClient>;
40
+ createWalletAccount({ thresholdSignatureScheme, }?: {
41
+ thresholdSignatureScheme?: string | undefined;
42
+ } | undefined): Promise<{
43
+ chainName: string;
44
+ accountAddress: string; /**
45
+ * Relationship between verifiedCredential and verifiedCredentials:
46
+ * - verifiedCredential: The first/primary credential from the array (used for active account)
47
+ * - verifiedCredentials: The full array of all credentials
48
+ * When setVerifiedCredentials is called, it processes the input array and sets both properties
49
+ * The first credential (verifiedCredential) is specifically filtered to be a "dynamicwaas"
50
+ */
51
+ publicKeyHex: string;
52
+ rawPublicKey: string | Uint8Array | undefined;
53
+ }>;
54
+ importPrivateKey({ privateKey, thresholdSignatureScheme, }: {
55
+ privateKey: string;
56
+ thresholdSignatureScheme?: string | undefined;
57
+ }): Promise<void>;
58
+ exportPrivateKey({ accountAddress, displayContainer, password, }?: {
59
+ accountAddress?: string | undefined;
60
+ displayContainer?: HTMLIFrameElement | undefined;
61
+ password?: string | undefined;
62
+ } | undefined): Promise<void>;
63
+ getExportHandler(): {
64
+ clear: () => void;
65
+ };
66
+ exportClientKeyshares({ accountAddress, password, }: {
67
+ accountAddress: string;
68
+ password?: string | undefined;
69
+ }): Promise<void>;
70
+ backupKeySharesToGoogleDrive({ accountAddress, password, }: {
71
+ accountAddress: string;
72
+ password?: string | undefined;
73
+ }): Promise<void>;
74
+ refreshWalletAccountShares({ accountAddress, password, }: {
75
+ accountAddress: string;
76
+ password?: string | undefined;
77
+ }): Promise<void>;
78
+ updatePassword({ accountAddress, existingPassword, newPassword, }: {
79
+ accountAddress: string;
80
+ existingPassword: string;
81
+ newPassword: string;
82
+ }): Promise<void>;
83
+ signRawMessage({ accountAddress, message, password, }: {
84
+ accountAddress: string;
85
+ message: string;
86
+ password?: string | undefined;
87
+ }): Promise<string>;
88
+ endSession(): Promise<void>;
89
+ getActiveAccountAddress(): Promise<string | undefined>;
31
90
  }) & typeof EthereumWalletConnector;
32
91
  export declare class DynamicWaasEVMConnector extends DynamicWaasEVMConnector_base implements IDynamicWaasConnector {
33
92
  name: string;
34
93
  overrideKey: string;
35
94
  isEmbeddedWallet: boolean;
36
- private __exportHandler;
37
95
  /**
38
96
  * Relationship between verifiedCredential and verifiedCredentials:
39
97
  * - verifiedCredential: The first/primary credential from the array (used for active account)
@@ -61,35 +119,16 @@ export declare class DynamicWaasEVMConnector extends DynamicWaasEVMConnector_bas
61
119
  switchNetwork({ networkChainId, }: SwitchNetworkOps): Promise<void>;
62
120
  private getRpcUrl;
63
121
  validateActiveWallet(expectedAddress: string): Promise<void>;
122
+ getActiveAccountAddress(): Promise<string | undefined>;
64
123
  getViemAccount({ accountAddress, }: {
65
124
  accountAddress: string;
66
125
  }): Promise<LocalAccount>;
67
126
  getWalletClient(chainId?: string): WalletClient<Transport, ViemChain, Account> | undefined;
68
- createWalletAccount({ thresholdSignatureScheme, }?: {
69
- thresholdSignatureScheme?: string;
70
- }): Promise<{
71
- chainName: string;
72
- accountAddress: string;
73
- publicKeyHex: string;
74
- rawPublicKey: string | Uint8Array | undefined;
75
- }>;
76
127
  signMessage(message: string): Promise<Hex>;
77
128
  getSigner(): Promise<any>;
78
129
  getWalletClientByAddress({ accountAddress, }: {
79
130
  accountAddress: string;
80
131
  }): WalletClient<Transport, ViemChain, Account> | undefined;
81
- exportPrivateKey({ accountAddress, displayContainer, password, }?: {
82
- accountAddress?: string;
83
- displayContainer?: HTMLIFrameElement;
84
- password?: string;
85
- }): Promise<void>;
86
- getExportHandler(): {
87
- clear: () => void;
88
- };
89
- importPrivateKey({ privateKey, thresholdSignatureScheme, }: {
90
- privateKey: string;
91
- thresholdSignatureScheme?: string;
92
- }): Promise<void>;
93
132
  exportClientKeyshares({ accountAddress, password, }: {
94
133
  accountAddress: string;
95
134
  password?: string;
@@ -107,11 +146,6 @@ export declare class DynamicWaasEVMConnector extends DynamicWaasEVMConnector_bas
107
146
  existingPassword: string;
108
147
  newPassword: string;
109
148
  }): Promise<void>;
110
- signRawMessage({ accountAddress, message, password, }: {
111
- accountAddress: string;
112
- message: string;
113
- password?: string;
114
- }): Promise<string>;
115
149
  createUiTransaction(from: string): Promise<IUITransaction>;
116
150
  getConnectedAccounts(): Promise<string[]>;
117
151
  getAddress(): Promise<string>;
@@ -6,25 +6,10 @@ import { hashAuthorization } from 'viem/utils';
6
6
  import { EthereumWalletConnector, createWalletClientWithUiConfirmation, getOrMapViemChain, ViemUiTransaction } from '@dynamic-labs/ethereum-core';
7
7
  import { Logger } from '@dynamic-labs/logger';
8
8
  import { DynamicError } from '@dynamic-labs/utils';
9
- import { withDynamicWaas } from '@dynamic-labs/waas';
9
+ import { withDynamicWaas, WaasExportHandler } from '@dynamic-labs/waas';
10
10
  import { isSameAddress } from '@dynamic-labs/wallet-connector-core';
11
11
 
12
12
  const logger = new Logger('DynamicWaasConnector');
13
- // This will need to be moved to a base class once we have base classes for waas connectors
14
- class WaasExportHandler {
15
- constructor() {
16
- this.iframeStamper = null;
17
- }
18
- setIframeStamper(iframe) {
19
- this.iframeStamper = iframe;
20
- }
21
- clear() {
22
- if (this.iframeStamper) {
23
- this.iframeStamper.remove();
24
- this.iframeStamper = null;
25
- }
26
- }
27
- }
28
13
  class DynamicWaasEVMConnector extends withDynamicWaas(EthereumWalletConnector) {
29
14
  constructor(props) {
30
15
  super(props);
@@ -158,6 +143,9 @@ class DynamicWaasEVMConnector extends withDynamicWaas(EthereumWalletConnector) {
158
143
  var _a, _b, _c;
159
144
  const walletClient = yield this.getWaasWalletClient();
160
145
  const signedSessionId = yield ((_a = this.getSignedSessionId) === null || _a === void 0 ? void 0 : _a.call(this));
146
+ if (!signedSessionId) {
147
+ throw new DynamicError('Signed session ID is required');
148
+ }
161
149
  const targetWallet = yield walletClient.getWallet({
162
150
  accountAddress: expectedAddress,
163
151
  authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
@@ -172,43 +160,58 @@ class DynamicWaasEVMConnector extends withDynamicWaas(EthereumWalletConnector) {
172
160
  }
173
161
  });
174
162
  }
163
+ getActiveAccountAddress() {
164
+ return __awaiter(this, void 0, void 0, function* () {
165
+ var _a;
166
+ return (_a = this.getActiveAccount()) === null || _a === void 0 ? void 0 : _a.address;
167
+ });
168
+ }
175
169
  getViemAccount(_a) {
176
170
  return __awaiter(this, arguments, void 0, function* ({ accountAddress, }) {
177
171
  var _b;
178
172
  const client = yield this.getWaasWalletClient();
179
173
  const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
174
+ if (!signedSessionId) {
175
+ throw new DynamicError('Signed session ID is required');
176
+ }
180
177
  return toAccount({
181
178
  address: accountAddress,
182
179
  signAuthorization: (parameters) => __awaiter(this, void 0, void 0, function* () { return this.signAuthorization(parameters); }),
183
- signMessage: ({ message }) => {
184
- var _a;
180
+ signMessage: (_c) => __awaiter(this, [_c], void 0, function* ({ message, }) {
181
+ var _d, _e;
182
+ const mfaToken = yield ((_d = this.getMfaToken) === null || _d === void 0 ? void 0 : _d.call(this));
185
183
  return client.signMessage({
186
184
  accountAddress,
187
- authToken: (_a = this.getAuthToken) === null || _a === void 0 ? void 0 : _a.call(this),
185
+ authToken: (_e = this.getAuthToken) === null || _e === void 0 ? void 0 : _e.call(this),
188
186
  message: message,
187
+ mfaToken,
189
188
  signedSessionId,
190
189
  });
191
- },
192
- signTransaction: (transaction) => {
193
- var _a;
190
+ }),
191
+ signTransaction: (transaction) => __awaiter(this, void 0, void 0, function* () {
192
+ var _f, _g;
193
+ const mfaToken = yield ((_f = this.getMfaToken) === null || _f === void 0 ? void 0 : _f.call(this));
194
194
  return client
195
195
  .signTransaction({
196
- authToken: (_a = this.getAuthToken) === null || _a === void 0 ? void 0 : _a.call(this),
196
+ authToken: (_g = this.getAuthToken) === null || _g === void 0 ? void 0 : _g.call(this),
197
+ mfaToken,
197
198
  senderAddress: accountAddress,
198
199
  signedSessionId,
199
200
  transaction: serializeTransaction(transaction),
200
201
  })
201
202
  .then((tx) => tx);
202
- },
203
- signTypedData: (typedData) => {
204
- var _a;
203
+ }),
204
+ signTypedData: (typedData) => __awaiter(this, void 0, void 0, function* () {
205
+ var _h, _j;
206
+ const mfaToken = yield ((_h = this.getMfaToken) === null || _h === void 0 ? void 0 : _h.call(this));
205
207
  return client.signTypedData({
206
208
  accountAddress,
207
- authToken: (_a = this.getAuthToken) === null || _a === void 0 ? void 0 : _a.call(this),
209
+ authToken: (_j = this.getAuthToken) === null || _j === void 0 ? void 0 : _j.call(this),
210
+ mfaToken,
208
211
  signedSessionId,
209
212
  typedData: typedData,
210
213
  });
211
- },
214
+ }),
212
215
  });
213
216
  });
214
217
  }
@@ -239,19 +242,6 @@ class DynamicWaasEVMConnector extends withDynamicWaas(EthereumWalletConnector) {
239
242
  walletUiUtils: this.walletUiUtils,
240
243
  });
241
244
  }
242
- createWalletAccount() {
243
- return __awaiter(this, arguments, void 0, function* ({ thresholdSignatureScheme = 'TWO_OF_TWO', } = {}) {
244
- var _a, _b;
245
- const walletClient = yield this.getWaasWalletClient();
246
- const signedSessionId = yield ((_a = this.getSignedSessionId) === null || _a === void 0 ? void 0 : _a.call(this));
247
- const createdWallet = yield walletClient.createWalletAccount({
248
- authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
249
- signedSessionId,
250
- thresholdSignatureScheme: thresholdSignatureScheme,
251
- });
252
- return createdWallet;
253
- });
254
- }
255
245
  signMessage(message) {
256
246
  var _a;
257
247
  return (_a = this.getWalletClient()) === null || _a === void 0 ? void 0 : _a.signMessage({ message });
@@ -265,127 +255,66 @@ class DynamicWaasEVMConnector extends withDynamicWaas(EthereumWalletConnector) {
265
255
  this.setActiveAccount(accountAddress);
266
256
  return this.getWalletClient();
267
257
  }
268
- exportPrivateKey() {
269
- return __awaiter(this, arguments, void 0, function* ({ accountAddress, displayContainer, password, } = {}) {
270
- var _a, _b;
271
- const walletClient = yield this.getWaasWalletClient();
272
- const targetAccountAddress = accountAddress || ((_a = this.getActiveAccount()) === null || _a === void 0 ? void 0 : _a.address);
273
- if (!targetAccountAddress) {
274
- throw new Error('Account address is required');
275
- }
276
- if (!displayContainer) {
277
- throw new Error('Missing display container for export private key');
278
- }
279
- this.__exportHandler.setIframeStamper(displayContainer);
280
- yield walletClient.exportPrivateKey({
281
- accountAddress: targetAccountAddress,
282
- authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
283
- displayContainer,
284
- password,
285
- });
286
- });
287
- }
288
- getExportHandler() {
289
- return this.__exportHandler;
290
- }
291
- importPrivateKey(_a) {
292
- return __awaiter(this, arguments, void 0, function* ({ privateKey, thresholdSignatureScheme = 'TWO_OF_TWO', }) {
293
- var _b, _c;
294
- const walletClient = yield this.getWaasWalletClient();
295
- const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
296
- if (!signedSessionId) {
297
- throw new Error('Signed session ID is required');
298
- }
299
- yield walletClient.importPrivateKey({
300
- authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
301
- privateKey,
302
- signedSessionId,
303
- thresholdSignatureScheme: thresholdSignatureScheme,
304
- });
305
- });
306
- }
258
+ // Chain-specific override for exportClientKeyshares - EVM needs to set active account first
307
259
  exportClientKeyshares(_a) {
260
+ const _super = Object.create(null, {
261
+ exportClientKeyshares: { get: () => super.exportClientKeyshares }
262
+ });
308
263
  return __awaiter(this, arguments, void 0, function* ({ accountAddress, password, }) {
309
- var _b, _c;
310
264
  if (!accountAddress) {
311
265
  throw new Error('Account address is required');
312
266
  }
313
- const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
267
+ // EVM-specific: set active account before exporting
314
268
  this.setActiveAccount(accountAddress);
315
- const walletClient = yield this.getWaasWalletClient();
316
- yield walletClient.exportClientKeyshares({
317
- accountAddress,
318
- authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
319
- password,
320
- signedSessionId,
321
- });
269
+ return _super.exportClientKeyshares.call(this, { accountAddress, password });
322
270
  });
323
271
  }
272
+ // Chain-specific override for backupKeySharesToGoogleDrive - EVM needs to set active account first
324
273
  backupKeySharesToGoogleDrive(_a) {
274
+ const _super = Object.create(null, {
275
+ backupKeySharesToGoogleDrive: { get: () => super.backupKeySharesToGoogleDrive }
276
+ });
325
277
  return __awaiter(this, arguments, void 0, function* ({ accountAddress, password, }) {
326
- var _b;
327
278
  if (!accountAddress) {
328
279
  throw new Error('Account address is required');
329
280
  }
281
+ // EVM-specific: set active account before backing up
330
282
  this.setActiveAccount(accountAddress);
331
- const walletClient = yield this.getWaasWalletClient();
332
- return walletClient.backupKeySharesToGoogleDrive({
333
- accountAddress,
334
- authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
335
- password,
336
- });
283
+ return _super.backupKeySharesToGoogleDrive.call(this, { accountAddress, password });
337
284
  });
338
285
  }
286
+ // Chain-specific override for refreshWalletAccountShares - EVM needs to set active account first
339
287
  refreshWalletAccountShares(_a) {
288
+ const _super = Object.create(null, {
289
+ refreshWalletAccountShares: { get: () => super.refreshWalletAccountShares }
290
+ });
340
291
  return __awaiter(this, arguments, void 0, function* ({ accountAddress, password, }) {
341
- var _b;
342
292
  if (!accountAddress) {
343
293
  throw new Error('Account address is required');
344
294
  }
295
+ // EVM-specific: set active account before refreshing
345
296
  this.setActiveAccount(accountAddress);
346
- const walletClient = yield this.getWaasWalletClient();
347
- return walletClient.refreshWalletAccountShares({
348
- accountAddress,
349
- authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
350
- password,
351
- });
297
+ return _super.refreshWalletAccountShares.call(this, { accountAddress, password });
352
298
  });
353
299
  }
300
+ // Chain-specific override for updatePassword - EVM needs to set active account first
354
301
  updatePassword(_a) {
302
+ const _super = Object.create(null, {
303
+ updatePassword: { get: () => super.updatePassword }
304
+ });
355
305
  return __awaiter(this, arguments, void 0, function* ({ accountAddress, existingPassword, newPassword, }) {
356
- var _b;
357
306
  if (!accountAddress) {
358
307
  throw new Error('Account address is required');
359
308
  }
309
+ // EVM-specific: set active account before updating password
360
310
  this.setActiveAccount(accountAddress);
361
- const walletClient = yield this.getWaasWalletClient();
362
- return walletClient.updatePassword({
311
+ return _super.updatePassword.call(this, {
363
312
  accountAddress,
364
- authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
365
313
  existingPassword,
366
314
  newPassword,
367
315
  });
368
316
  });
369
317
  }
370
- signRawMessage(_a) {
371
- return __awaiter(this, arguments, void 0, function* ({ accountAddress, message, password, }) {
372
- var _b;
373
- if (!accountAddress) {
374
- throw new Error('Account address is required');
375
- }
376
- if (message.length !== 64) {
377
- throw new Error('Message must be 64 characters long');
378
- }
379
- this.setActiveAccount(accountAddress);
380
- const walletClient = yield this.getWaasWalletClient();
381
- return walletClient.signRawMessage({
382
- accountAddress,
383
- authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
384
- message,
385
- password,
386
- });
387
- });
388
- }
389
318
  createUiTransaction(from) {
390
319
  return __awaiter(this, void 0, void 0, function* () {
391
320
  yield this.validateActiveWallet(from);
@@ -455,7 +384,7 @@ class DynamicWaasEVMConnector extends withDynamicWaas(EthereumWalletConnector) {
455
384
  }
456
385
  signAuthorization(parameters, password) {
457
386
  return __awaiter(this, void 0, void 0, function* () {
458
- var _a, _b;
387
+ var _a, _b, _c;
459
388
  const { address: contractAddress, nonce, chainId } = parameters;
460
389
  if (!contractAddress) {
461
390
  throw new Error('Contract address not found');
@@ -470,14 +399,19 @@ class DynamicWaasEVMConnector extends withDynamicWaas(EthereumWalletConnector) {
470
399
  const { address } = signer.account;
471
400
  const walletClient = yield this.getWaasWalletClient();
472
401
  const signedSessionId = yield ((_a = this.getSignedSessionId) === null || _a === void 0 ? void 0 : _a.call(this));
402
+ if (!signedSessionId) {
403
+ throw new DynamicError('Signed session ID is required');
404
+ }
405
+ const mfaToken = yield ((_b = this.getMfaToken) === null || _b === void 0 ? void 0 : _b.call(this));
473
406
  const signature = yield walletClient.signRawMessage({
474
407
  accountAddress: address,
475
- authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
408
+ authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
476
409
  message: hashAuthorization({
477
410
  address: contractAddress,
478
411
  chainId,
479
412
  nonce,
480
413
  }).slice(2),
414
+ mfaToken,
481
415
  password,
482
416
  signedSessionId,
483
417
  });
@@ -513,12 +447,11 @@ class DynamicWaasEVMConnector extends withDynamicWaas(EthereumWalletConnector) {
513
447
  return true;
514
448
  }
515
449
  endSession() {
450
+ const _super = Object.create(null, {
451
+ endSession: { get: () => super.endSession }
452
+ });
516
453
  return __awaiter(this, void 0, void 0, function* () {
517
- const waasEvmClient = yield this.getWaasWalletClient();
518
- if (!waasEvmClient) {
519
- return;
520
- }
521
- yield waasEvmClient.cleanup();
454
+ yield _super.endSession.call(this);
522
455
  });
523
456
  }
524
457
  }