@dynamic-labs/waas-sui 4.25.2 → 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,29 @@
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
+
14
+ ### [4.25.3](https://github.com/dynamic-labs/dynamic-auth/compare/v4.25.2...v4.25.3) (2025-07-22)
15
+
16
+
17
+ ### Features
18
+
19
+ * add permanentlyDeleteUser for react native ([#8838](https://github.com/dynamic-labs/dynamic-auth/issues/8838)) ([1e00fd1](https://github.com/dynamic-labs/dynamic-auth/commit/1e00fd166f2cef55cd0526a66d9bb3123d10504f))
20
+
21
+
22
+ ### Bug Fixes
23
+
24
+ * chain id on dynamic waas for confirmation view and clean up tests ([#9204](https://github.com/dynamic-labs/dynamic-auth/issues/9204)) ([4cebd8b](https://github.com/dynamic-labs/dynamic-auth/commit/4cebd8b63c9327d936ebe1c2305eb4e8f5f69aeb))
25
+ * remove errant calls to fetchMultichainTokenBalances from useEffect ([#9207](https://github.com/dynamic-labs/dynamic-auth/issues/9207)) ([84bacfc](https://github.com/dynamic-labs/dynamic-auth/commit/84bacfc1ddd6b18fde9ba1baed310531b3ec0adc))
26
+
2
27
  ### [4.25.2](https://github.com/dynamic-labs/dynamic-auth/compare/v4.25.1...v4.25.2) (2025-07-18)
3
28
 
4
29
 
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.2";
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.2";
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-sui",
3
- "version": "4.25.2",
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,18 +18,18 @@
18
18
  },
19
19
  "homepage": "https://www.dynamic.xyz/",
20
20
  "dependencies": {
21
- "@dynamic-labs-wallet/browser-wallet-client": "0.0.120",
21
+ "@dynamic-labs-wallet/browser-wallet-client": "0.0.124",
22
22
  "@mysten/sui": "1.24.0",
23
23
  "@mysten/wallet-standard": "0.13.29",
24
- "@dynamic-labs/assert-package-version": "4.25.2",
25
- "@dynamic-labs/logger": "4.25.2",
26
- "@dynamic-labs/rpc-providers": "4.25.2",
27
- "@dynamic-labs/sui-core": "4.25.2",
28
- "@dynamic-labs/types": "4.25.2",
29
- "@dynamic-labs/utils": "4.25.2",
30
- "@dynamic-labs/waas": "4.25.2",
31
- "@dynamic-labs/wallet-book": "4.25.2",
32
- "@dynamic-labs/wallet-connector-core": "4.25.2"
24
+ "@dynamic-labs/assert-package-version": "4.25.4",
25
+ "@dynamic-labs/logger": "4.25.4",
26
+ "@dynamic-labs/rpc-providers": "4.25.4",
27
+ "@dynamic-labs/sui-core": "4.25.4",
28
+ "@dynamic-labs/types": "4.25.4",
29
+ "@dynamic-labs/utils": "4.25.4",
30
+ "@dynamic-labs/waas": "4.25.4",
31
+ "@dynamic-labs/wallet-book": "4.25.4",
32
+ "@dynamic-labs/wallet-connector-core": "4.25.4"
33
33
  },
34
34
  "peerDependencies": {}
35
35
  }
@@ -11,21 +11,6 @@ var waas = require('@dynamic-labs/waas');
11
11
  var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
12
12
  var WaasSuiWallet = require('../wallet/WaasSuiWallet.cjs');
13
13
 
14
- // This will need to be moved to a base class once we have base classes for waas connectors
15
- class WaasExportHandler {
16
- constructor() {
17
- this.iframeStamper = null;
18
- }
19
- setIframeStamper(iframe) {
20
- this.iframeStamper = iframe;
21
- }
22
- clear() {
23
- if (this.iframeStamper) {
24
- this.iframeStamper.remove();
25
- this.iframeStamper = null;
26
- }
27
- }
28
- }
29
14
  class DynamicWaasSuiConnector extends waas.withDynamicWaas(suiCore.SuiWalletConnector) {
30
15
  constructor(props) {
31
16
  super('Dynamic Waas', props);
@@ -34,7 +19,6 @@ class DynamicWaasSuiConnector extends waas.withDynamicWaas(suiCore.SuiWalletConn
34
19
  this.name = 'Dynamic Waas';
35
20
  this.overrideKey = 'dynamicwaas';
36
21
  this.isEmbeddedWallet = true;
37
- this.__exportHandler = new WaasExportHandler();
38
22
  }
39
23
  connect() {
40
24
  return _tslib.__awaiter(this, void 0, void 0, function* () {
@@ -103,6 +87,9 @@ class DynamicWaasSuiConnector extends waas.withDynamicWaas(suiCore.SuiWalletConn
103
87
  var _a, _b;
104
88
  const walletClient = yield this.getWaasWalletClient();
105
89
  const signedSessionId = yield ((_a = this.getSignedSessionId) === null || _a === void 0 ? void 0 : _a.call(this));
90
+ if (!signedSessionId) {
91
+ throw new utils.DynamicError('Signed session ID is required');
92
+ }
106
93
  const targetWallet = yield walletClient.getWallet({
107
94
  accountAddress: expectedAddress,
108
95
  authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
@@ -117,26 +104,14 @@ class DynamicWaasSuiConnector extends waas.withDynamicWaas(suiCore.SuiWalletConn
117
104
  }
118
105
  });
119
106
  }
120
- createWalletAccount() {
121
- return _tslib.__awaiter(this, arguments, void 0, function* ({ thresholdSignatureScheme = 'TWO_OF_TWO', } = {}) {
122
- var _a, _b;
123
- const walletClient = yield this.getWaasWalletClient();
124
- const signedSessionId = yield ((_a = this.getSignedSessionId) === null || _a === void 0 ? void 0 : _a.call(this));
125
- const createdWallet = yield walletClient.createWalletAccount({
126
- authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
127
- signedSessionId,
128
- thresholdSignatureScheme: thresholdSignatureScheme,
129
- });
130
- return createdWallet;
131
- });
132
- }
107
+ // Override importPrivateKey to use the proper type casting for SUI
133
108
  importPrivateKey(_a) {
134
109
  return _tslib.__awaiter(this, arguments, void 0, function* ({ privateKey, thresholdSignatureScheme = 'TWO_OF_TWO', }) {
135
110
  var _b, _c;
136
111
  const walletClient = yield this.getWaasWalletClient();
137
112
  const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
138
113
  if (!signedSessionId) {
139
- throw new Error('Signed session ID is required');
114
+ throw new utils.DynamicError('Signed session ID is required');
140
115
  }
141
116
  yield walletClient.importPrivateKey({
142
117
  authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
@@ -148,16 +123,21 @@ class DynamicWaasSuiConnector extends waas.withDynamicWaas(suiCore.SuiWalletConn
148
123
  }
149
124
  signMessage(message) {
150
125
  return _tslib.__awaiter(this, void 0, void 0, function* () {
151
- var _a, _b;
126
+ var _a, _b, _c;
152
127
  const waasSuiClient = yield this.getWaasWalletClient();
153
128
  if (!this.activeAccountAddress) {
154
129
  throw new Error('Active account address is required');
155
130
  }
156
131
  const signedSessionId = yield ((_a = this.getSignedSessionId) === null || _a === void 0 ? void 0 : _a.call(this));
132
+ if (!signedSessionId) {
133
+ throw new utils.DynamicError('Signed session ID is required');
134
+ }
135
+ const mfaToken = yield ((_b = this.getMfaToken) === null || _b === void 0 ? void 0 : _b.call(this));
157
136
  const signedMessage = yield waasSuiClient.signMessage({
158
137
  accountAddress: this.activeAccountAddress,
159
- authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
138
+ authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
160
139
  message,
140
+ mfaToken,
161
141
  signedSessionId,
162
142
  });
163
143
  return signedMessage;
@@ -165,7 +145,7 @@ class DynamicWaasSuiConnector extends waas.withDynamicWaas(suiCore.SuiWalletConn
165
145
  }
166
146
  createAndSignTransaction(transaction) {
167
147
  return _tslib.__awaiter(this, void 0, void 0, function* () {
168
- var _a, _b;
148
+ var _a, _b, _c;
169
149
  const networkName = yield this.getNetworkName();
170
150
  const client$1 = new client.SuiClient({ url: client.getFullnodeUrl(networkName) });
171
151
  const txBytes = yield transaction.build({ client: client$1 });
@@ -175,8 +155,13 @@ class DynamicWaasSuiConnector extends waas.withDynamicWaas(suiCore.SuiWalletConn
175
155
  throw new Error('Active account address is required');
176
156
  }
177
157
  const signedSessionId = yield ((_a = this.getSignedSessionId) === null || _a === void 0 ? void 0 : _a.call(this));
158
+ if (!signedSessionId) {
159
+ throw new utils.DynamicError('Signed session ID is required');
160
+ }
161
+ const mfaToken = yield ((_b = this.getMfaToken) === null || _b === void 0 ? void 0 : _b.call(this));
178
162
  const signedTx = yield walletClient.signTransaction({
179
- authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
163
+ authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
164
+ mfaToken,
180
165
  senderAddress: this.activeAccountAddress,
181
166
  signedSessionId,
182
167
  transaction: txString,
@@ -238,105 +223,18 @@ class DynamicWaasSuiConnector extends waas.withDynamicWaas(suiCore.SuiWalletConn
238
223
  return client;
239
224
  });
240
225
  }
241
- exportPrivateKey() {
242
- return _tslib.__awaiter(this, arguments, void 0, function* ({ accountAddress, displayContainer, password, } = {}) {
243
- var _a, _b;
244
- const walletClient = yield this.getWaasWalletClient();
245
- const targetAccountAddress = accountAddress || this.activeAccountAddress;
246
- if (!targetAccountAddress) {
247
- throw new Error('Account address is required');
248
- }
249
- if (!displayContainer) {
250
- throw new Error('Missing display container for export private key');
251
- }
252
- this.__exportHandler.setIframeStamper(displayContainer);
253
- const signedSessionId = yield ((_a = this.getSignedSessionId) === null || _a === void 0 ? void 0 : _a.call(this));
254
- yield walletClient.exportPrivateKey({
255
- accountAddress: targetAccountAddress,
256
- authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
257
- displayContainer,
258
- password,
259
- signedSessionId,
260
- });
261
- });
262
- }
263
- getExportHandler() {
264
- return this.__exportHandler;
265
- }
226
+ // Chain-specific override for exportClientKeyshares - SUI needs to handle optional account address
266
227
  exportClientKeyshares(_a) {
228
+ const _super = Object.create(null, {
229
+ exportClientKeyshares: { get: () => super.exportClientKeyshares }
230
+ });
267
231
  return _tslib.__awaiter(this, arguments, void 0, function* ({ accountAddress, password, }) {
268
- var _b, _c;
269
- const waasSuiClient = yield this.getWaasWalletClient();
270
232
  const targetAccountAddress = accountAddress || this.activeAccountAddress;
271
233
  if (!targetAccountAddress) {
272
234
  throw new Error('Account address is required');
273
235
  }
274
- const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
275
- yield waasSuiClient.exportClientKeyshares({
236
+ return _super.exportClientKeyshares.call(this, {
276
237
  accountAddress: targetAccountAddress,
277
- authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
278
- password,
279
- signedSessionId,
280
- });
281
- });
282
- }
283
- backupKeySharesToGoogleDrive(_a) {
284
- return _tslib.__awaiter(this, arguments, void 0, function* ({ accountAddress, password, }) {
285
- var _b;
286
- if (!accountAddress) {
287
- throw new Error('Account address is required');
288
- }
289
- const walletClient = yield this.getWaasWalletClient();
290
- return walletClient.backupKeySharesToGoogleDrive({
291
- accountAddress,
292
- authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
293
- password,
294
- });
295
- });
296
- }
297
- refreshWalletAccountShares(_a) {
298
- return _tslib.__awaiter(this, arguments, void 0, function* ({ accountAddress, password, }) {
299
- var _b;
300
- if (!accountAddress) {
301
- throw new Error('Account address is required');
302
- }
303
- const walletClient = yield this.getWaasWalletClient();
304
- return walletClient.refreshWalletAccountShares({
305
- accountAddress,
306
- authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
307
- password,
308
- });
309
- });
310
- }
311
- updatePassword(_a) {
312
- return _tslib.__awaiter(this, arguments, void 0, function* ({ accountAddress, existingPassword, newPassword, }) {
313
- var _b;
314
- if (!accountAddress) {
315
- throw new Error('Account address is required');
316
- }
317
- const walletClient = yield this.getWaasWalletClient();
318
- return walletClient.updatePassword({
319
- accountAddress,
320
- authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
321
- existingPassword,
322
- newPassword,
323
- });
324
- });
325
- }
326
- signRawMessage(_a) {
327
- return _tslib.__awaiter(this, arguments, void 0, function* ({ accountAddress, message, password, }) {
328
- var _b;
329
- if (!accountAddress) {
330
- throw new Error('Account address is required');
331
- }
332
- if (message.length !== 64) {
333
- throw new Error('Message must be 64 characters long');
334
- }
335
- const walletClient = yield this.getWaasWalletClient();
336
- return walletClient.signRawMessage({
337
- accountAddress,
338
- authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
339
- message,
340
238
  password,
341
239
  });
342
240
  });
@@ -363,14 +261,12 @@ class DynamicWaasSuiConnector extends waas.withDynamicWaas(suiCore.SuiWalletConn
363
261
  });
364
262
  }
365
263
  endSession() {
264
+ const _super = Object.create(null, {
265
+ endSession: { get: () => super.endSession }
266
+ });
366
267
  return _tslib.__awaiter(this, void 0, void 0, function* () {
367
- const waasSuiClient = yield this.getWaasWalletClient();
368
- if (!waasSuiClient) {
369
- return;
370
- }
371
- yield waasSuiClient.cleanup();
268
+ yield _super.endSession.call(this);
372
269
  this.activeAccountAddress = undefined;
373
- this.dynamicWaasClient = undefined;
374
270
  });
375
271
  }
376
272
  }
@@ -12,19 +12,71 @@ declare const DynamicWaasSuiConnector_base: (abstract new (...args: any[]) => {
12
12
  overrideKey: string;
13
13
  isEmbeddedWallet: boolean;
14
14
  getSignedSessionId?: (() => Promise<string>) | undefined;
15
+ getMfaToken?: (() => Promise<string | undefined>) | undefined;
15
16
  getAuthToken?: (() => string) | undefined;
16
17
  environmentId?: string | undefined;
17
18
  baseApiUrl?: string | undefined;
18
19
  relayUrl?: string | undefined;
19
20
  dynamicWaasClient: DynamicWalletClient | undefined;
20
21
  chainName: string;
22
+ __exportHandler: import("@dynamic-labs/waas").WaasExportHandler;
23
+ validateActiveWallet(expectedAddress: string): Promise<void>;
21
24
  setGetAuthTokenFunction(getAuthToken: () => string): void;
25
+ setGetMfaTokenFunction(getMfaToken: () => Promise<string | undefined>): void;
22
26
  setEnvironmentId(environmentId: string): void;
23
27
  setBaseApiUrl(baseApiUrl: string): void;
24
28
  setRelayUrl(relayUrl: string): void;
25
29
  setGetSignedSessionIdFunction(getSignedSessionId: () => Promise<string>): void;
30
+ delegateKeyShares({ accountAddress, password, }: {
31
+ accountAddress: string;
32
+ password?: string | undefined;
33
+ }): Promise<void>;
26
34
  createDynamicWaasClient(): Promise<DynamicWalletClient>;
27
35
  getWaasWalletClient(): Promise<DynamicWalletClient>;
36
+ createWalletAccount({ thresholdSignatureScheme, }?: {
37
+ thresholdSignatureScheme?: string | undefined;
38
+ } | undefined): Promise<{
39
+ chainName: string;
40
+ accountAddress: string;
41
+ publicKeyHex: string;
42
+ rawPublicKey: string | Uint8Array | undefined;
43
+ }>;
44
+ importPrivateKey({ privateKey, thresholdSignatureScheme, }: {
45
+ privateKey: string;
46
+ thresholdSignatureScheme?: string | undefined;
47
+ }): Promise<void>;
48
+ exportPrivateKey({ accountAddress, displayContainer, password, }?: {
49
+ accountAddress?: string | undefined;
50
+ displayContainer?: HTMLIFrameElement | undefined;
51
+ password?: string | undefined;
52
+ } | undefined): Promise<void>;
53
+ getExportHandler(): {
54
+ clear: () => void;
55
+ };
56
+ exportClientKeyshares({ accountAddress, password, }: {
57
+ accountAddress: string;
58
+ password?: string | undefined;
59
+ }): Promise<void>;
60
+ backupKeySharesToGoogleDrive({ accountAddress, password, }: {
61
+ accountAddress: string;
62
+ password?: string | undefined;
63
+ }): Promise<void>;
64
+ refreshWalletAccountShares({ accountAddress, password, }: {
65
+ accountAddress: string;
66
+ password?: string | undefined;
67
+ }): Promise<void>;
68
+ updatePassword({ accountAddress, existingPassword, newPassword, }: {
69
+ accountAddress: string;
70
+ existingPassword: string;
71
+ newPassword: string;
72
+ }): Promise<void>;
73
+ signRawMessage({ accountAddress, message, password, }: {
74
+ accountAddress: string;
75
+ message: string;
76
+ password?: string | undefined;
77
+ }): Promise<string>;
78
+ endSession(): Promise<void>;
79
+ getActiveAccountAddress(): Promise<string | undefined>;
28
80
  }) & typeof SuiWalletConnector;
29
81
  export declare class DynamicWaasSuiConnector extends DynamicWaasSuiConnector_base implements IDynamicWaasConnector {
30
82
  ChainWallet: typeof WaasSuiWallet;
@@ -40,19 +92,10 @@ export declare class DynamicWaasSuiConnector extends DynamicWaasSuiConnector_bas
40
92
  name: string;
41
93
  overrideKey: string;
42
94
  isEmbeddedWallet: boolean;
43
- private __exportHandler;
44
95
  activeAccountAddress: string | undefined;
45
96
  private setActiveAccountAddress;
46
97
  getActiveAccountAddress(): Promise<string | undefined>;
47
98
  validateActiveWallet(expectedAddress: string): Promise<void>;
48
- createWalletAccount({ thresholdSignatureScheme, }?: {
49
- thresholdSignatureScheme?: string;
50
- }): Promise<{
51
- chainName: string;
52
- accountAddress: string;
53
- publicKeyHex: string;
54
- rawPublicKey: string | Uint8Array | undefined;
55
- }>;
56
99
  importPrivateKey({ privateKey, thresholdSignatureScheme, }: {
57
100
  privateKey: string;
58
101
  thresholdSignatureScheme?: string;
@@ -66,36 +109,10 @@ export declare class DynamicWaasSuiConnector extends DynamicWaasSuiConnector_bas
66
109
  accountAddress: string;
67
110
  }): Promise<DynamicWalletClient>;
68
111
  getWalletClient(): Promise<DynamicWalletClient | undefined>;
69
- exportPrivateKey({ accountAddress, displayContainer, password, }?: {
70
- accountAddress?: string;
71
- displayContainer?: HTMLIFrameElement;
72
- password?: string;
73
- }): Promise<void>;
74
- getExportHandler(): {
75
- clear: () => void;
76
- };
77
112
  exportClientKeyshares({ accountAddress, password, }: {
78
113
  accountAddress: string;
79
114
  password?: string;
80
115
  }): Promise<void>;
81
- backupKeySharesToGoogleDrive({ accountAddress, password, }: {
82
- accountAddress: string;
83
- password?: string;
84
- }): Promise<void>;
85
- refreshWalletAccountShares({ accountAddress, password, }: {
86
- accountAddress: string;
87
- password?: string;
88
- }): Promise<void>;
89
- updatePassword({ accountAddress, existingPassword, newPassword, }: {
90
- accountAddress: string;
91
- existingPassword: string;
92
- newPassword: string;
93
- }): Promise<void>;
94
- signRawMessage({ accountAddress, message, password, }: {
95
- accountAddress: string;
96
- message: string;
97
- password?: string;
98
- }): Promise<string>;
99
116
  /** Function used to create transactions in the SDK interface */
100
117
  createUiTransaction(from: string): Promise<IUITransaction>;
101
118
  endSession(): Promise<void>;
@@ -7,21 +7,6 @@ import { withDynamicWaas } from '@dynamic-labs/waas';
7
7
  import { isSameAddress } from '@dynamic-labs/wallet-connector-core';
8
8
  import { WaasSuiWallet } from '../wallet/WaasSuiWallet.js';
9
9
 
10
- // This will need to be moved to a base class once we have base classes for waas connectors
11
- class WaasExportHandler {
12
- constructor() {
13
- this.iframeStamper = null;
14
- }
15
- setIframeStamper(iframe) {
16
- this.iframeStamper = iframe;
17
- }
18
- clear() {
19
- if (this.iframeStamper) {
20
- this.iframeStamper.remove();
21
- this.iframeStamper = null;
22
- }
23
- }
24
- }
25
10
  class DynamicWaasSuiConnector extends withDynamicWaas(SuiWalletConnector) {
26
11
  constructor(props) {
27
12
  super('Dynamic Waas', props);
@@ -30,7 +15,6 @@ class DynamicWaasSuiConnector extends withDynamicWaas(SuiWalletConnector) {
30
15
  this.name = 'Dynamic Waas';
31
16
  this.overrideKey = 'dynamicwaas';
32
17
  this.isEmbeddedWallet = true;
33
- this.__exportHandler = new WaasExportHandler();
34
18
  }
35
19
  connect() {
36
20
  return __awaiter(this, void 0, void 0, function* () {
@@ -99,6 +83,9 @@ class DynamicWaasSuiConnector extends withDynamicWaas(SuiWalletConnector) {
99
83
  var _a, _b;
100
84
  const walletClient = yield this.getWaasWalletClient();
101
85
  const signedSessionId = yield ((_a = this.getSignedSessionId) === null || _a === void 0 ? void 0 : _a.call(this));
86
+ if (!signedSessionId) {
87
+ throw new DynamicError('Signed session ID is required');
88
+ }
102
89
  const targetWallet = yield walletClient.getWallet({
103
90
  accountAddress: expectedAddress,
104
91
  authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
@@ -113,26 +100,14 @@ class DynamicWaasSuiConnector extends withDynamicWaas(SuiWalletConnector) {
113
100
  }
114
101
  });
115
102
  }
116
- createWalletAccount() {
117
- return __awaiter(this, arguments, void 0, function* ({ thresholdSignatureScheme = 'TWO_OF_TWO', } = {}) {
118
- var _a, _b;
119
- const walletClient = yield this.getWaasWalletClient();
120
- const signedSessionId = yield ((_a = this.getSignedSessionId) === null || _a === void 0 ? void 0 : _a.call(this));
121
- const createdWallet = yield walletClient.createWalletAccount({
122
- authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
123
- signedSessionId,
124
- thresholdSignatureScheme: thresholdSignatureScheme,
125
- });
126
- return createdWallet;
127
- });
128
- }
103
+ // Override importPrivateKey to use the proper type casting for SUI
129
104
  importPrivateKey(_a) {
130
105
  return __awaiter(this, arguments, void 0, function* ({ privateKey, thresholdSignatureScheme = 'TWO_OF_TWO', }) {
131
106
  var _b, _c;
132
107
  const walletClient = yield this.getWaasWalletClient();
133
108
  const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
134
109
  if (!signedSessionId) {
135
- throw new Error('Signed session ID is required');
110
+ throw new DynamicError('Signed session ID is required');
136
111
  }
137
112
  yield walletClient.importPrivateKey({
138
113
  authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
@@ -144,16 +119,21 @@ class DynamicWaasSuiConnector extends withDynamicWaas(SuiWalletConnector) {
144
119
  }
145
120
  signMessage(message) {
146
121
  return __awaiter(this, void 0, void 0, function* () {
147
- var _a, _b;
122
+ var _a, _b, _c;
148
123
  const waasSuiClient = yield this.getWaasWalletClient();
149
124
  if (!this.activeAccountAddress) {
150
125
  throw new Error('Active account address is required');
151
126
  }
152
127
  const signedSessionId = yield ((_a = this.getSignedSessionId) === null || _a === void 0 ? void 0 : _a.call(this));
128
+ if (!signedSessionId) {
129
+ throw new DynamicError('Signed session ID is required');
130
+ }
131
+ const mfaToken = yield ((_b = this.getMfaToken) === null || _b === void 0 ? void 0 : _b.call(this));
153
132
  const signedMessage = yield waasSuiClient.signMessage({
154
133
  accountAddress: this.activeAccountAddress,
155
- authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
134
+ authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
156
135
  message,
136
+ mfaToken,
157
137
  signedSessionId,
158
138
  });
159
139
  return signedMessage;
@@ -161,7 +141,7 @@ class DynamicWaasSuiConnector extends withDynamicWaas(SuiWalletConnector) {
161
141
  }
162
142
  createAndSignTransaction(transaction) {
163
143
  return __awaiter(this, void 0, void 0, function* () {
164
- var _a, _b;
144
+ var _a, _b, _c;
165
145
  const networkName = yield this.getNetworkName();
166
146
  const client = new SuiClient({ url: getFullnodeUrl(networkName) });
167
147
  const txBytes = yield transaction.build({ client });
@@ -171,8 +151,13 @@ class DynamicWaasSuiConnector extends withDynamicWaas(SuiWalletConnector) {
171
151
  throw new Error('Active account address is required');
172
152
  }
173
153
  const signedSessionId = yield ((_a = this.getSignedSessionId) === null || _a === void 0 ? void 0 : _a.call(this));
154
+ if (!signedSessionId) {
155
+ throw new DynamicError('Signed session ID is required');
156
+ }
157
+ const mfaToken = yield ((_b = this.getMfaToken) === null || _b === void 0 ? void 0 : _b.call(this));
174
158
  const signedTx = yield walletClient.signTransaction({
175
- authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
159
+ authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
160
+ mfaToken,
176
161
  senderAddress: this.activeAccountAddress,
177
162
  signedSessionId,
178
163
  transaction: txString,
@@ -234,105 +219,18 @@ class DynamicWaasSuiConnector extends withDynamicWaas(SuiWalletConnector) {
234
219
  return client;
235
220
  });
236
221
  }
237
- exportPrivateKey() {
238
- return __awaiter(this, arguments, void 0, function* ({ accountAddress, displayContainer, password, } = {}) {
239
- var _a, _b;
240
- const walletClient = yield this.getWaasWalletClient();
241
- const targetAccountAddress = accountAddress || this.activeAccountAddress;
242
- if (!targetAccountAddress) {
243
- throw new Error('Account address is required');
244
- }
245
- if (!displayContainer) {
246
- throw new Error('Missing display container for export private key');
247
- }
248
- this.__exportHandler.setIframeStamper(displayContainer);
249
- const signedSessionId = yield ((_a = this.getSignedSessionId) === null || _a === void 0 ? void 0 : _a.call(this));
250
- yield walletClient.exportPrivateKey({
251
- accountAddress: targetAccountAddress,
252
- authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
253
- displayContainer,
254
- password,
255
- signedSessionId,
256
- });
257
- });
258
- }
259
- getExportHandler() {
260
- return this.__exportHandler;
261
- }
222
+ // Chain-specific override for exportClientKeyshares - SUI needs to handle optional account address
262
223
  exportClientKeyshares(_a) {
224
+ const _super = Object.create(null, {
225
+ exportClientKeyshares: { get: () => super.exportClientKeyshares }
226
+ });
263
227
  return __awaiter(this, arguments, void 0, function* ({ accountAddress, password, }) {
264
- var _b, _c;
265
- const waasSuiClient = yield this.getWaasWalletClient();
266
228
  const targetAccountAddress = accountAddress || this.activeAccountAddress;
267
229
  if (!targetAccountAddress) {
268
230
  throw new Error('Account address is required');
269
231
  }
270
- const signedSessionId = yield ((_b = this.getSignedSessionId) === null || _b === void 0 ? void 0 : _b.call(this));
271
- yield waasSuiClient.exportClientKeyshares({
232
+ return _super.exportClientKeyshares.call(this, {
272
233
  accountAddress: targetAccountAddress,
273
- authToken: (_c = this.getAuthToken) === null || _c === void 0 ? void 0 : _c.call(this),
274
- password,
275
- signedSessionId,
276
- });
277
- });
278
- }
279
- backupKeySharesToGoogleDrive(_a) {
280
- return __awaiter(this, arguments, void 0, function* ({ accountAddress, password, }) {
281
- var _b;
282
- if (!accountAddress) {
283
- throw new Error('Account address is required');
284
- }
285
- const walletClient = yield this.getWaasWalletClient();
286
- return walletClient.backupKeySharesToGoogleDrive({
287
- accountAddress,
288
- authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
289
- password,
290
- });
291
- });
292
- }
293
- refreshWalletAccountShares(_a) {
294
- return __awaiter(this, arguments, void 0, function* ({ accountAddress, password, }) {
295
- var _b;
296
- if (!accountAddress) {
297
- throw new Error('Account address is required');
298
- }
299
- const walletClient = yield this.getWaasWalletClient();
300
- return walletClient.refreshWalletAccountShares({
301
- accountAddress,
302
- authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
303
- password,
304
- });
305
- });
306
- }
307
- updatePassword(_a) {
308
- return __awaiter(this, arguments, void 0, function* ({ accountAddress, existingPassword, newPassword, }) {
309
- var _b;
310
- if (!accountAddress) {
311
- throw new Error('Account address is required');
312
- }
313
- const walletClient = yield this.getWaasWalletClient();
314
- return walletClient.updatePassword({
315
- accountAddress,
316
- authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
317
- existingPassword,
318
- newPassword,
319
- });
320
- });
321
- }
322
- signRawMessage(_a) {
323
- return __awaiter(this, arguments, void 0, function* ({ accountAddress, message, password, }) {
324
- var _b;
325
- if (!accountAddress) {
326
- throw new Error('Account address is required');
327
- }
328
- if (message.length !== 64) {
329
- throw new Error('Message must be 64 characters long');
330
- }
331
- const walletClient = yield this.getWaasWalletClient();
332
- return walletClient.signRawMessage({
333
- accountAddress,
334
- authToken: (_b = this.getAuthToken) === null || _b === void 0 ? void 0 : _b.call(this),
335
- message,
336
234
  password,
337
235
  });
338
236
  });
@@ -359,14 +257,12 @@ class DynamicWaasSuiConnector extends withDynamicWaas(SuiWalletConnector) {
359
257
  });
360
258
  }
361
259
  endSession() {
260
+ const _super = Object.create(null, {
261
+ endSession: { get: () => super.endSession }
262
+ });
362
263
  return __awaiter(this, void 0, void 0, function* () {
363
- const waasSuiClient = yield this.getWaasWalletClient();
364
- if (!waasSuiClient) {
365
- return;
366
- }
367
- yield waasSuiClient.cleanup();
264
+ yield _super.endSession.call(this);
368
265
  this.activeAccountAddress = undefined;
369
- this.dynamicWaasClient = undefined;
370
266
  });
371
267
  }
372
268
  }