@dynamic-labs-wallet/browser-wallet-client 0.0.0-beta.232.8 → 0.0.0-beta.244.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs.js
CHANGED
|
@@ -1,48 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var core = require('@dynamic-labs-wallet/core');
|
|
3
4
|
var messageTransport = require('@dynamic-labs/message-transport');
|
|
4
5
|
var logger$1 = require('@dynamic-labs/logger');
|
|
5
|
-
var core = require('@dynamic-labs-wallet/core');
|
|
6
|
-
|
|
7
|
-
const setupMessageTransportBridge = (messageTransport$1, iframe, iframeOrigin)=>{
|
|
8
|
-
if (!(iframe == null ? void 0 : iframe.contentWindow)) {
|
|
9
|
-
throw new Error('Iframe or contentWindow not available');
|
|
10
|
-
}
|
|
11
|
-
const logger = new logger$1.Logger('debug');
|
|
12
|
-
messageTransport$1.on((message)=>{
|
|
13
|
-
// Forward the message to webview via postMessage
|
|
14
|
-
if (message.origin === 'host') {
|
|
15
|
-
var _iframe_contentWindow;
|
|
16
|
-
iframe == null ? void 0 : (_iframe_contentWindow = iframe.contentWindow) == null ? void 0 : _iframe_contentWindow.postMessage(message, iframeOrigin);
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const handleIncomingMessage = (message)=>{
|
|
20
|
-
const { data } = message;
|
|
21
|
-
if (!data) return;
|
|
22
|
-
if ((data == null ? void 0 : data.origin) !== 'webview') {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
if (typeof data !== 'object') {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
try {
|
|
29
|
-
const message = messageTransport.parseMessageTransportData(data);
|
|
30
|
-
messageTransport$1.emit(message);
|
|
31
|
-
} catch (error) {
|
|
32
|
-
if (!(error instanceof SyntaxError)) {
|
|
33
|
-
logger.error('Error handling incoming message:', error);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* Handle incoming message from android client
|
|
39
|
-
*/ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
40
|
-
// @ts-ignore
|
|
41
|
-
document.addEventListener('message', handleIncomingMessage);
|
|
42
|
-
/**
|
|
43
|
-
* Handle incoming message from iOS client
|
|
44
|
-
*/ window.addEventListener('message', handleIncomingMessage);
|
|
45
|
-
};
|
|
46
6
|
|
|
47
7
|
class iframeMessageHandler {
|
|
48
8
|
async getWallets(request) {
|
|
@@ -102,6 +62,9 @@ class iframeMessageHandler {
|
|
|
102
62
|
async offlineExportPrivateKey(request) {
|
|
103
63
|
return this.requestChannel.request('offlineExportPrivateKey', request);
|
|
104
64
|
}
|
|
65
|
+
async signTypedData(request) {
|
|
66
|
+
return this.requestChannel.request('signTypedData', request);
|
|
67
|
+
}
|
|
105
68
|
async cleanup() {
|
|
106
69
|
return this.requestChannel.request('cleanup');
|
|
107
70
|
}
|
|
@@ -112,6 +75,46 @@ class iframeMessageHandler {
|
|
|
112
75
|
|
|
113
76
|
const logger = new logger$1.Logger('DynamicWaasWalletClient');
|
|
114
77
|
|
|
78
|
+
const setupMessageTransportBridge = (messageTransport$1, iframe, iframeOrigin)=>{
|
|
79
|
+
if (!(iframe == null ? void 0 : iframe.contentWindow)) {
|
|
80
|
+
throw new Error('Iframe or contentWindow not available');
|
|
81
|
+
}
|
|
82
|
+
const logger = new logger$1.Logger('debug');
|
|
83
|
+
messageTransport$1.on((message)=>{
|
|
84
|
+
// Forward the message to webview via postMessage
|
|
85
|
+
if (message.origin === 'host') {
|
|
86
|
+
var _iframe_contentWindow;
|
|
87
|
+
iframe == null ? void 0 : (_iframe_contentWindow = iframe.contentWindow) == null ? void 0 : _iframe_contentWindow.postMessage(message, iframeOrigin);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
const handleIncomingMessage = (message)=>{
|
|
91
|
+
const { data } = message;
|
|
92
|
+
if (!data) return;
|
|
93
|
+
if ((data == null ? void 0 : data.origin) !== 'webview') {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (typeof data !== 'object') {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
const message = messageTransport.parseMessageTransportData(data);
|
|
101
|
+
messageTransport$1.emit(message);
|
|
102
|
+
} catch (error) {
|
|
103
|
+
if (!(error instanceof SyntaxError)) {
|
|
104
|
+
logger.error('Error handling incoming message:', error);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Handle incoming message from android client
|
|
110
|
+
*/ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
111
|
+
// @ts-ignore
|
|
112
|
+
document.addEventListener('message', handleIncomingMessage);
|
|
113
|
+
/**
|
|
114
|
+
* Handle incoming message from iOS client
|
|
115
|
+
*/ window.addEventListener('message', handleIncomingMessage);
|
|
116
|
+
};
|
|
117
|
+
|
|
115
118
|
class DynamicWalletClient {
|
|
116
119
|
// Simply load the iframe from localhost
|
|
117
120
|
async initialize() {
|
|
@@ -170,6 +173,18 @@ class DynamicWalletClient {
|
|
|
170
173
|
throw new Error('Failed to establish secure token exchange: ' + error);
|
|
171
174
|
}
|
|
172
175
|
}
|
|
176
|
+
/**
|
|
177
|
+
* Reset the shared iframe and iframe load promise, and iframe instance count
|
|
178
|
+
*/ async resetSharedIframe() {
|
|
179
|
+
DynamicWalletClient.sharedIframe = null;
|
|
180
|
+
DynamicWalletClient.iframeInstanceCount = 0;
|
|
181
|
+
DynamicWalletClient.iframeLoadPromise = null;
|
|
182
|
+
this.iframe = null;
|
|
183
|
+
this.iframeMessageHandler = null;
|
|
184
|
+
this.messageTransport = null;
|
|
185
|
+
// Double the timeout and cap at 60 seconds to give more time for slow networks
|
|
186
|
+
this.iframeLoadTimeout = Math.min(this.iframeLoadTimeout * 2, 60000);
|
|
187
|
+
}
|
|
173
188
|
async loadIframe() {
|
|
174
189
|
// If the iframe is already loaded, just assign and resolve
|
|
175
190
|
if (DynamicWalletClient.sharedIframe) {
|
|
@@ -185,10 +200,27 @@ class DynamicWalletClient {
|
|
|
185
200
|
});
|
|
186
201
|
}
|
|
187
202
|
DynamicWalletClient.iframeLoadPromise = new Promise((resolve, reject)=>{
|
|
203
|
+
var _this_sdkVersion;
|
|
204
|
+
this.logger.info(`Loading iframe for waas wallet client...`, {
|
|
205
|
+
iframeDomain: this.iframeDomain,
|
|
206
|
+
environmentId: this.environmentId,
|
|
207
|
+
sdkVersion: (_this_sdkVersion = this.sdkVersion) != null ? _this_sdkVersion : '',
|
|
208
|
+
instanceId: this.instanceId,
|
|
209
|
+
chainName: this.chainName
|
|
210
|
+
});
|
|
188
211
|
const iframe = document.createElement('iframe');
|
|
189
212
|
const iframeTimeoutId = setTimeout(()=>{
|
|
190
|
-
|
|
191
|
-
|
|
213
|
+
this.resetSharedIframe();
|
|
214
|
+
var _this_sdkVersion;
|
|
215
|
+
this.logger.error('Iframe load timeout due to no handshake message from iframe, this could be network issues, incorrect iframe domain, or CORS errors that prevents iframe from being loaded or sending handshake message. A retry will be attempted to load the iframe with wallet interaction function calls.', {
|
|
216
|
+
iframeDomain: this.iframeDomain,
|
|
217
|
+
environmentId: this.environmentId,
|
|
218
|
+
sdkVersion: (_this_sdkVersion = this.sdkVersion) != null ? _this_sdkVersion : '',
|
|
219
|
+
instanceId: this.instanceId,
|
|
220
|
+
chainName: this.chainName
|
|
221
|
+
});
|
|
222
|
+
reject(new Error('Iframe load timeout due to no handshake message from iframe, this could be network issues, incorrect iframe domain, or CORS errors that prevents iframe from being loaded or sending handshake message. A retry will be attempted to load the iframe with wallet interaction function calls.'));
|
|
223
|
+
}, this.iframeLoadTimeout);
|
|
192
224
|
iframe.style.display = 'none';
|
|
193
225
|
iframe.setAttribute('title', 'Dynamic Wallet Iframe');
|
|
194
226
|
iframe.setAttribute('sandbox', 'allow-scripts allow-same-origin allow-downloads');
|
|
@@ -200,29 +232,45 @@ class DynamicWalletClient {
|
|
|
200
232
|
iframe.style.height = '0';
|
|
201
233
|
iframe.style.border = 'none';
|
|
202
234
|
iframe.style.pointerEvents = 'none';
|
|
203
|
-
var _this_instanceId,
|
|
235
|
+
var _this_instanceId, _this_sdkVersion1;
|
|
204
236
|
const params = new URLSearchParams({
|
|
205
237
|
instanceId: (_this_instanceId = this.instanceId) != null ? _this_instanceId : '',
|
|
206
238
|
hostOrigin: window.location.origin,
|
|
207
239
|
environmentId: this.environmentId,
|
|
208
240
|
baseApiUrl: this.baseApiUrl,
|
|
209
241
|
baseMPCRelayApiUrl: this.baseMPCRelayApiUrl,
|
|
210
|
-
sdkVersion: (
|
|
242
|
+
sdkVersion: (_this_sdkVersion1 = this.sdkVersion) != null ? _this_sdkVersion1 : ''
|
|
211
243
|
});
|
|
212
244
|
iframe.src = `${this.iframeDomain}/waas-v1/${this.environmentId}?${params.toString()}`;
|
|
213
245
|
this.logger.debug('Creating iframe with src:', iframe.src);
|
|
214
246
|
document.body.appendChild(iframe);
|
|
215
247
|
iframe.onload = ()=>{
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
248
|
+
// Listen for handshake
|
|
249
|
+
const onMessage = (event)=>{
|
|
250
|
+
if (event.source === iframe.contentWindow && event.data === `iframe-ready`) {
|
|
251
|
+
window.removeEventListener('message', onMessage);
|
|
252
|
+
clearTimeout(iframeTimeoutId);
|
|
253
|
+
DynamicWalletClient.sharedIframe = iframe;
|
|
254
|
+
this.iframe = iframe;
|
|
255
|
+
DynamicWalletClient.iframeInstanceCount++;
|
|
256
|
+
resolve();
|
|
257
|
+
var _this_sdkVersion;
|
|
258
|
+
this.logger.info('Iframe loaded successfully...', {
|
|
259
|
+
iframeDomain: this.iframeDomain,
|
|
260
|
+
environmentId: this.environmentId,
|
|
261
|
+
sdkVersion: (_this_sdkVersion = this.sdkVersion) != null ? _this_sdkVersion : '',
|
|
262
|
+
instanceId: this.instanceId,
|
|
263
|
+
chainName: this.chainName
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
window.addEventListener('message', onMessage);
|
|
221
268
|
};
|
|
222
269
|
iframe.onerror = (error)=>{
|
|
223
270
|
clearTimeout(iframeTimeoutId);
|
|
224
|
-
this.logger.error('Iframe failed to load:', error);
|
|
225
|
-
|
|
271
|
+
this.logger.error('Iframe failed to load due to errors: ', error);
|
|
272
|
+
this.resetSharedIframe();
|
|
273
|
+
reject(new Error('Failed to load iframe due to unknown load errors, this is likely a browser or network issue.'));
|
|
226
274
|
};
|
|
227
275
|
});
|
|
228
276
|
return DynamicWalletClient.iframeLoadPromise;
|
|
@@ -233,38 +281,71 @@ class DynamicWalletClient {
|
|
|
233
281
|
* @returns {Promise<HTMLIFrameElement>} that resolves when the iframe is loaded
|
|
234
282
|
*/ loadIframeForContainer(container) {
|
|
235
283
|
return new Promise((resolve, reject)=>{
|
|
284
|
+
var _this_sdkVersion;
|
|
285
|
+
this.logger.info(`Loading iframe for container...`, {
|
|
286
|
+
iframeDomain: this.iframeDomain,
|
|
287
|
+
environmentId: this.environmentId,
|
|
288
|
+
sdkVersion: (_this_sdkVersion = this.sdkVersion) != null ? _this_sdkVersion : '',
|
|
289
|
+
instanceId: this.instanceId,
|
|
290
|
+
chainName: this.chainName
|
|
291
|
+
});
|
|
236
292
|
const iframe = document.createElement('iframe');
|
|
237
293
|
const iframeTimeoutId = setTimeout(()=>{
|
|
238
|
-
|
|
239
|
-
|
|
294
|
+
var _this_sdkVersion;
|
|
295
|
+
this.logger.error('Iframe load timeout due to no handshake message from iframe, this could be network issues, incorrect iframe domain, or CORS errors that prevents iframe from being loaded or sending handshake message.', {
|
|
296
|
+
iframeDomain: this.iframeDomain,
|
|
297
|
+
environmentId: this.environmentId,
|
|
298
|
+
sdkVersion: (_this_sdkVersion = this.sdkVersion) != null ? _this_sdkVersion : '',
|
|
299
|
+
instanceId: this.instanceId,
|
|
300
|
+
chainName: this.chainName
|
|
301
|
+
});
|
|
302
|
+
reject(new Error('Iframe load timeout due to no handshake message from iframe, this could be network issues, incorrect iframe domain, or CORS errors that prevents iframe from being loaded or sending handshake message.'));
|
|
303
|
+
}, this.iframeLoadTimeout);
|
|
240
304
|
iframe.style.display = 'block';
|
|
241
305
|
iframe.style.width = '100%';
|
|
242
306
|
iframe.style.height = '100%';
|
|
243
307
|
iframe.setAttribute('title', 'Dynamic Wallet Storage');
|
|
244
308
|
iframe.setAttribute('sandbox', 'allow-scripts allow-same-origin');
|
|
245
309
|
iframe.setAttribute('referrerpolicy', 'origin');
|
|
246
|
-
var _this_instanceId;
|
|
310
|
+
var _this_instanceId, _this_sdkVersion1;
|
|
247
311
|
const params = new URLSearchParams({
|
|
248
312
|
instanceId: (_this_instanceId = this.instanceId) != null ? _this_instanceId : '',
|
|
249
313
|
hostOrigin: window.location.origin,
|
|
250
314
|
environmentId: this.environmentId,
|
|
251
315
|
baseApiUrl: this.baseApiUrl,
|
|
252
316
|
baseMPCRelayApiUrl: this.baseMPCRelayApiUrl,
|
|
253
|
-
|
|
317
|
+
sdkVersion: (_this_sdkVersion1 = this.sdkVersion) != null ? _this_sdkVersion1 : ''
|
|
254
318
|
});
|
|
255
319
|
iframe.src = `${this.iframeDomain}/waas-v1/${this.environmentId}?${params.toString()}`;
|
|
256
320
|
this.logger.debug('Creating iframe with src:', iframe.src);
|
|
257
321
|
// Add iframe to the provided container
|
|
258
322
|
container.appendChild(iframe);
|
|
259
323
|
iframe.onload = ()=>{
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
324
|
+
// Listen for handshake
|
|
325
|
+
const onMessage = (event)=>{
|
|
326
|
+
if (event.source === iframe.contentWindow && event.data === `iframe-ready`) {
|
|
327
|
+
window.removeEventListener('message', onMessage);
|
|
328
|
+
clearTimeout(iframeTimeoutId);
|
|
329
|
+
DynamicWalletClient.sharedIframe = iframe;
|
|
330
|
+
this.iframe = iframe;
|
|
331
|
+
DynamicWalletClient.iframeInstanceCount++;
|
|
332
|
+
resolve(iframe);
|
|
333
|
+
var _this_sdkVersion;
|
|
334
|
+
this.logger.info('Iframe loaded successfully...', {
|
|
335
|
+
iframeDomain: this.iframeDomain,
|
|
336
|
+
environmentId: this.environmentId,
|
|
337
|
+
sdkVersion: (_this_sdkVersion = this.sdkVersion) != null ? _this_sdkVersion : '',
|
|
338
|
+
instanceId: this.instanceId,
|
|
339
|
+
chainName: this.chainName
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
window.addEventListener('message', onMessage);
|
|
263
344
|
};
|
|
264
345
|
iframe.onerror = (error)=>{
|
|
265
346
|
clearTimeout(iframeTimeoutId);
|
|
266
|
-
this.logger.error('Iframe failed to load:', error);
|
|
267
|
-
reject(new Error('Failed to load iframe'));
|
|
347
|
+
this.logger.error('Iframe failed to load due to errors: ', error);
|
|
348
|
+
reject(new Error('Failed to load iframe due to unknown load errors, this is likely a browser or network issue.'));
|
|
268
349
|
};
|
|
269
350
|
});
|
|
270
351
|
}
|
|
@@ -409,6 +490,19 @@ class DynamicWalletClient {
|
|
|
409
490
|
authToken
|
|
410
491
|
});
|
|
411
492
|
}
|
|
493
|
+
async signTypedData({ accountAddress, typedData, password = undefined, signedSessionId }) {
|
|
494
|
+
await this.initializeMessageTransport();
|
|
495
|
+
if (!this.iframeMessageHandler) {
|
|
496
|
+
throw new Error('Iframe message handler not initialized');
|
|
497
|
+
}
|
|
498
|
+
return this.iframeMessageHandler.signTypedData({
|
|
499
|
+
chainName: this.chainName,
|
|
500
|
+
accountAddress,
|
|
501
|
+
typedData: JSON.stringify(typedData),
|
|
502
|
+
password,
|
|
503
|
+
signedSessionId
|
|
504
|
+
});
|
|
505
|
+
}
|
|
412
506
|
async backupKeySharesToGoogleDrive({ accountAddress, password = undefined, signedSessionId, authToken }) {
|
|
413
507
|
await this.initializeMessageTransport();
|
|
414
508
|
if (!this.iframeMessageHandler) {
|
|
@@ -577,6 +671,7 @@ class DynamicWalletClient {
|
|
|
577
671
|
this.messageTransport = null;
|
|
578
672
|
this.iframeMessageHandler = null;
|
|
579
673
|
this.iframe = null;
|
|
674
|
+
this.iframeLoadTimeout = 10000;
|
|
580
675
|
this.environmentId = environmentId;
|
|
581
676
|
this.authToken = authToken;
|
|
582
677
|
this.baseApiUrl = baseApiUrl;
|
package/index.esm.js
CHANGED
|
@@ -1,47 +1,7 @@
|
|
|
1
|
-
import { parseMessageTransportData, createRequestChannel, applyDefaultMessageOrigin, createMessageTransport } from '@dynamic-labs/message-transport';
|
|
2
|
-
import { Logger } from '@dynamic-labs/logger';
|
|
3
1
|
import { WalletOperation, getEnvironmentFromUrl, IFRAME_DOMAIN_MAP } from '@dynamic-labs-wallet/core';
|
|
4
2
|
export { MPC_RELAY_PREPROD_API_URL, MPC_RELAY_PROD_API_URL, ThresholdSignatureScheme, WalletOperation } from '@dynamic-labs-wallet/core';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
if (!(iframe == null ? void 0 : iframe.contentWindow)) {
|
|
8
|
-
throw new Error('Iframe or contentWindow not available');
|
|
9
|
-
}
|
|
10
|
-
const logger = new Logger('debug');
|
|
11
|
-
messageTransport.on((message)=>{
|
|
12
|
-
// Forward the message to webview via postMessage
|
|
13
|
-
if (message.origin === 'host') {
|
|
14
|
-
var _iframe_contentWindow;
|
|
15
|
-
iframe == null ? void 0 : (_iframe_contentWindow = iframe.contentWindow) == null ? void 0 : _iframe_contentWindow.postMessage(message, iframeOrigin);
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
const handleIncomingMessage = (message)=>{
|
|
19
|
-
const { data } = message;
|
|
20
|
-
if (!data) return;
|
|
21
|
-
if ((data == null ? void 0 : data.origin) !== 'webview') {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
if (typeof data !== 'object') {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
try {
|
|
28
|
-
const message = parseMessageTransportData(data);
|
|
29
|
-
messageTransport.emit(message);
|
|
30
|
-
} catch (error) {
|
|
31
|
-
if (!(error instanceof SyntaxError)) {
|
|
32
|
-
logger.error('Error handling incoming message:', error);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* Handle incoming message from android client
|
|
38
|
-
*/ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
39
|
-
// @ts-ignore
|
|
40
|
-
document.addEventListener('message', handleIncomingMessage);
|
|
41
|
-
/**
|
|
42
|
-
* Handle incoming message from iOS client
|
|
43
|
-
*/ window.addEventListener('message', handleIncomingMessage);
|
|
44
|
-
};
|
|
3
|
+
import { createRequestChannel, parseMessageTransportData, applyDefaultMessageOrigin, createMessageTransport } from '@dynamic-labs/message-transport';
|
|
4
|
+
import { Logger } from '@dynamic-labs/logger';
|
|
45
5
|
|
|
46
6
|
class iframeMessageHandler {
|
|
47
7
|
async getWallets(request) {
|
|
@@ -101,6 +61,9 @@ class iframeMessageHandler {
|
|
|
101
61
|
async offlineExportPrivateKey(request) {
|
|
102
62
|
return this.requestChannel.request('offlineExportPrivateKey', request);
|
|
103
63
|
}
|
|
64
|
+
async signTypedData(request) {
|
|
65
|
+
return this.requestChannel.request('signTypedData', request);
|
|
66
|
+
}
|
|
104
67
|
async cleanup() {
|
|
105
68
|
return this.requestChannel.request('cleanup');
|
|
106
69
|
}
|
|
@@ -111,6 +74,46 @@ class iframeMessageHandler {
|
|
|
111
74
|
|
|
112
75
|
const logger = new Logger('DynamicWaasWalletClient');
|
|
113
76
|
|
|
77
|
+
const setupMessageTransportBridge = (messageTransport, iframe, iframeOrigin)=>{
|
|
78
|
+
if (!(iframe == null ? void 0 : iframe.contentWindow)) {
|
|
79
|
+
throw new Error('Iframe or contentWindow not available');
|
|
80
|
+
}
|
|
81
|
+
const logger = new Logger('debug');
|
|
82
|
+
messageTransport.on((message)=>{
|
|
83
|
+
// Forward the message to webview via postMessage
|
|
84
|
+
if (message.origin === 'host') {
|
|
85
|
+
var _iframe_contentWindow;
|
|
86
|
+
iframe == null ? void 0 : (_iframe_contentWindow = iframe.contentWindow) == null ? void 0 : _iframe_contentWindow.postMessage(message, iframeOrigin);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
const handleIncomingMessage = (message)=>{
|
|
90
|
+
const { data } = message;
|
|
91
|
+
if (!data) return;
|
|
92
|
+
if ((data == null ? void 0 : data.origin) !== 'webview') {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if (typeof data !== 'object') {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
try {
|
|
99
|
+
const message = parseMessageTransportData(data);
|
|
100
|
+
messageTransport.emit(message);
|
|
101
|
+
} catch (error) {
|
|
102
|
+
if (!(error instanceof SyntaxError)) {
|
|
103
|
+
logger.error('Error handling incoming message:', error);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Handle incoming message from android client
|
|
109
|
+
*/ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
110
|
+
// @ts-ignore
|
|
111
|
+
document.addEventListener('message', handleIncomingMessage);
|
|
112
|
+
/**
|
|
113
|
+
* Handle incoming message from iOS client
|
|
114
|
+
*/ window.addEventListener('message', handleIncomingMessage);
|
|
115
|
+
};
|
|
116
|
+
|
|
114
117
|
class DynamicWalletClient {
|
|
115
118
|
// Simply load the iframe from localhost
|
|
116
119
|
async initialize() {
|
|
@@ -169,6 +172,18 @@ class DynamicWalletClient {
|
|
|
169
172
|
throw new Error('Failed to establish secure token exchange: ' + error);
|
|
170
173
|
}
|
|
171
174
|
}
|
|
175
|
+
/**
|
|
176
|
+
* Reset the shared iframe and iframe load promise, and iframe instance count
|
|
177
|
+
*/ async resetSharedIframe() {
|
|
178
|
+
DynamicWalletClient.sharedIframe = null;
|
|
179
|
+
DynamicWalletClient.iframeInstanceCount = 0;
|
|
180
|
+
DynamicWalletClient.iframeLoadPromise = null;
|
|
181
|
+
this.iframe = null;
|
|
182
|
+
this.iframeMessageHandler = null;
|
|
183
|
+
this.messageTransport = null;
|
|
184
|
+
// Double the timeout and cap at 60 seconds to give more time for slow networks
|
|
185
|
+
this.iframeLoadTimeout = Math.min(this.iframeLoadTimeout * 2, 60000);
|
|
186
|
+
}
|
|
172
187
|
async loadIframe() {
|
|
173
188
|
// If the iframe is already loaded, just assign and resolve
|
|
174
189
|
if (DynamicWalletClient.sharedIframe) {
|
|
@@ -184,10 +199,27 @@ class DynamicWalletClient {
|
|
|
184
199
|
});
|
|
185
200
|
}
|
|
186
201
|
DynamicWalletClient.iframeLoadPromise = new Promise((resolve, reject)=>{
|
|
202
|
+
var _this_sdkVersion;
|
|
203
|
+
this.logger.info(`Loading iframe for waas wallet client...`, {
|
|
204
|
+
iframeDomain: this.iframeDomain,
|
|
205
|
+
environmentId: this.environmentId,
|
|
206
|
+
sdkVersion: (_this_sdkVersion = this.sdkVersion) != null ? _this_sdkVersion : '',
|
|
207
|
+
instanceId: this.instanceId,
|
|
208
|
+
chainName: this.chainName
|
|
209
|
+
});
|
|
187
210
|
const iframe = document.createElement('iframe');
|
|
188
211
|
const iframeTimeoutId = setTimeout(()=>{
|
|
189
|
-
|
|
190
|
-
|
|
212
|
+
this.resetSharedIframe();
|
|
213
|
+
var _this_sdkVersion;
|
|
214
|
+
this.logger.error('Iframe load timeout due to no handshake message from iframe, this could be network issues, incorrect iframe domain, or CORS errors that prevents iframe from being loaded or sending handshake message. A retry will be attempted to load the iframe with wallet interaction function calls.', {
|
|
215
|
+
iframeDomain: this.iframeDomain,
|
|
216
|
+
environmentId: this.environmentId,
|
|
217
|
+
sdkVersion: (_this_sdkVersion = this.sdkVersion) != null ? _this_sdkVersion : '',
|
|
218
|
+
instanceId: this.instanceId,
|
|
219
|
+
chainName: this.chainName
|
|
220
|
+
});
|
|
221
|
+
reject(new Error('Iframe load timeout due to no handshake message from iframe, this could be network issues, incorrect iframe domain, or CORS errors that prevents iframe from being loaded or sending handshake message. A retry will be attempted to load the iframe with wallet interaction function calls.'));
|
|
222
|
+
}, this.iframeLoadTimeout);
|
|
191
223
|
iframe.style.display = 'none';
|
|
192
224
|
iframe.setAttribute('title', 'Dynamic Wallet Iframe');
|
|
193
225
|
iframe.setAttribute('sandbox', 'allow-scripts allow-same-origin allow-downloads');
|
|
@@ -199,29 +231,45 @@ class DynamicWalletClient {
|
|
|
199
231
|
iframe.style.height = '0';
|
|
200
232
|
iframe.style.border = 'none';
|
|
201
233
|
iframe.style.pointerEvents = 'none';
|
|
202
|
-
var _this_instanceId,
|
|
234
|
+
var _this_instanceId, _this_sdkVersion1;
|
|
203
235
|
const params = new URLSearchParams({
|
|
204
236
|
instanceId: (_this_instanceId = this.instanceId) != null ? _this_instanceId : '',
|
|
205
237
|
hostOrigin: window.location.origin,
|
|
206
238
|
environmentId: this.environmentId,
|
|
207
239
|
baseApiUrl: this.baseApiUrl,
|
|
208
240
|
baseMPCRelayApiUrl: this.baseMPCRelayApiUrl,
|
|
209
|
-
sdkVersion: (
|
|
241
|
+
sdkVersion: (_this_sdkVersion1 = this.sdkVersion) != null ? _this_sdkVersion1 : ''
|
|
210
242
|
});
|
|
211
243
|
iframe.src = `${this.iframeDomain}/waas-v1/${this.environmentId}?${params.toString()}`;
|
|
212
244
|
this.logger.debug('Creating iframe with src:', iframe.src);
|
|
213
245
|
document.body.appendChild(iframe);
|
|
214
246
|
iframe.onload = ()=>{
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
247
|
+
// Listen for handshake
|
|
248
|
+
const onMessage = (event)=>{
|
|
249
|
+
if (event.source === iframe.contentWindow && event.data === `iframe-ready`) {
|
|
250
|
+
window.removeEventListener('message', onMessage);
|
|
251
|
+
clearTimeout(iframeTimeoutId);
|
|
252
|
+
DynamicWalletClient.sharedIframe = iframe;
|
|
253
|
+
this.iframe = iframe;
|
|
254
|
+
DynamicWalletClient.iframeInstanceCount++;
|
|
255
|
+
resolve();
|
|
256
|
+
var _this_sdkVersion;
|
|
257
|
+
this.logger.info('Iframe loaded successfully...', {
|
|
258
|
+
iframeDomain: this.iframeDomain,
|
|
259
|
+
environmentId: this.environmentId,
|
|
260
|
+
sdkVersion: (_this_sdkVersion = this.sdkVersion) != null ? _this_sdkVersion : '',
|
|
261
|
+
instanceId: this.instanceId,
|
|
262
|
+
chainName: this.chainName
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
window.addEventListener('message', onMessage);
|
|
220
267
|
};
|
|
221
268
|
iframe.onerror = (error)=>{
|
|
222
269
|
clearTimeout(iframeTimeoutId);
|
|
223
|
-
this.logger.error('Iframe failed to load:', error);
|
|
224
|
-
|
|
270
|
+
this.logger.error('Iframe failed to load due to errors: ', error);
|
|
271
|
+
this.resetSharedIframe();
|
|
272
|
+
reject(new Error('Failed to load iframe due to unknown load errors, this is likely a browser or network issue.'));
|
|
225
273
|
};
|
|
226
274
|
});
|
|
227
275
|
return DynamicWalletClient.iframeLoadPromise;
|
|
@@ -232,38 +280,71 @@ class DynamicWalletClient {
|
|
|
232
280
|
* @returns {Promise<HTMLIFrameElement>} that resolves when the iframe is loaded
|
|
233
281
|
*/ loadIframeForContainer(container) {
|
|
234
282
|
return new Promise((resolve, reject)=>{
|
|
283
|
+
var _this_sdkVersion;
|
|
284
|
+
this.logger.info(`Loading iframe for container...`, {
|
|
285
|
+
iframeDomain: this.iframeDomain,
|
|
286
|
+
environmentId: this.environmentId,
|
|
287
|
+
sdkVersion: (_this_sdkVersion = this.sdkVersion) != null ? _this_sdkVersion : '',
|
|
288
|
+
instanceId: this.instanceId,
|
|
289
|
+
chainName: this.chainName
|
|
290
|
+
});
|
|
235
291
|
const iframe = document.createElement('iframe');
|
|
236
292
|
const iframeTimeoutId = setTimeout(()=>{
|
|
237
|
-
|
|
238
|
-
|
|
293
|
+
var _this_sdkVersion;
|
|
294
|
+
this.logger.error('Iframe load timeout due to no handshake message from iframe, this could be network issues, incorrect iframe domain, or CORS errors that prevents iframe from being loaded or sending handshake message.', {
|
|
295
|
+
iframeDomain: this.iframeDomain,
|
|
296
|
+
environmentId: this.environmentId,
|
|
297
|
+
sdkVersion: (_this_sdkVersion = this.sdkVersion) != null ? _this_sdkVersion : '',
|
|
298
|
+
instanceId: this.instanceId,
|
|
299
|
+
chainName: this.chainName
|
|
300
|
+
});
|
|
301
|
+
reject(new Error('Iframe load timeout due to no handshake message from iframe, this could be network issues, incorrect iframe domain, or CORS errors that prevents iframe from being loaded or sending handshake message.'));
|
|
302
|
+
}, this.iframeLoadTimeout);
|
|
239
303
|
iframe.style.display = 'block';
|
|
240
304
|
iframe.style.width = '100%';
|
|
241
305
|
iframe.style.height = '100%';
|
|
242
306
|
iframe.setAttribute('title', 'Dynamic Wallet Storage');
|
|
243
307
|
iframe.setAttribute('sandbox', 'allow-scripts allow-same-origin');
|
|
244
308
|
iframe.setAttribute('referrerpolicy', 'origin');
|
|
245
|
-
var _this_instanceId;
|
|
309
|
+
var _this_instanceId, _this_sdkVersion1;
|
|
246
310
|
const params = new URLSearchParams({
|
|
247
311
|
instanceId: (_this_instanceId = this.instanceId) != null ? _this_instanceId : '',
|
|
248
312
|
hostOrigin: window.location.origin,
|
|
249
313
|
environmentId: this.environmentId,
|
|
250
314
|
baseApiUrl: this.baseApiUrl,
|
|
251
315
|
baseMPCRelayApiUrl: this.baseMPCRelayApiUrl,
|
|
252
|
-
|
|
316
|
+
sdkVersion: (_this_sdkVersion1 = this.sdkVersion) != null ? _this_sdkVersion1 : ''
|
|
253
317
|
});
|
|
254
318
|
iframe.src = `${this.iframeDomain}/waas-v1/${this.environmentId}?${params.toString()}`;
|
|
255
319
|
this.logger.debug('Creating iframe with src:', iframe.src);
|
|
256
320
|
// Add iframe to the provided container
|
|
257
321
|
container.appendChild(iframe);
|
|
258
322
|
iframe.onload = ()=>{
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
323
|
+
// Listen for handshake
|
|
324
|
+
const onMessage = (event)=>{
|
|
325
|
+
if (event.source === iframe.contentWindow && event.data === `iframe-ready`) {
|
|
326
|
+
window.removeEventListener('message', onMessage);
|
|
327
|
+
clearTimeout(iframeTimeoutId);
|
|
328
|
+
DynamicWalletClient.sharedIframe = iframe;
|
|
329
|
+
this.iframe = iframe;
|
|
330
|
+
DynamicWalletClient.iframeInstanceCount++;
|
|
331
|
+
resolve(iframe);
|
|
332
|
+
var _this_sdkVersion;
|
|
333
|
+
this.logger.info('Iframe loaded successfully...', {
|
|
334
|
+
iframeDomain: this.iframeDomain,
|
|
335
|
+
environmentId: this.environmentId,
|
|
336
|
+
sdkVersion: (_this_sdkVersion = this.sdkVersion) != null ? _this_sdkVersion : '',
|
|
337
|
+
instanceId: this.instanceId,
|
|
338
|
+
chainName: this.chainName
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
window.addEventListener('message', onMessage);
|
|
262
343
|
};
|
|
263
344
|
iframe.onerror = (error)=>{
|
|
264
345
|
clearTimeout(iframeTimeoutId);
|
|
265
|
-
this.logger.error('Iframe failed to load:', error);
|
|
266
|
-
reject(new Error('Failed to load iframe'));
|
|
346
|
+
this.logger.error('Iframe failed to load due to errors: ', error);
|
|
347
|
+
reject(new Error('Failed to load iframe due to unknown load errors, this is likely a browser or network issue.'));
|
|
267
348
|
};
|
|
268
349
|
});
|
|
269
350
|
}
|
|
@@ -408,6 +489,19 @@ class DynamicWalletClient {
|
|
|
408
489
|
authToken
|
|
409
490
|
});
|
|
410
491
|
}
|
|
492
|
+
async signTypedData({ accountAddress, typedData, password = undefined, signedSessionId }) {
|
|
493
|
+
await this.initializeMessageTransport();
|
|
494
|
+
if (!this.iframeMessageHandler) {
|
|
495
|
+
throw new Error('Iframe message handler not initialized');
|
|
496
|
+
}
|
|
497
|
+
return this.iframeMessageHandler.signTypedData({
|
|
498
|
+
chainName: this.chainName,
|
|
499
|
+
accountAddress,
|
|
500
|
+
typedData: JSON.stringify(typedData),
|
|
501
|
+
password,
|
|
502
|
+
signedSessionId
|
|
503
|
+
});
|
|
504
|
+
}
|
|
411
505
|
async backupKeySharesToGoogleDrive({ accountAddress, password = undefined, signedSessionId, authToken }) {
|
|
412
506
|
await this.initializeMessageTransport();
|
|
413
507
|
if (!this.iframeMessageHandler) {
|
|
@@ -576,6 +670,7 @@ class DynamicWalletClient {
|
|
|
576
670
|
this.messageTransport = null;
|
|
577
671
|
this.iframeMessageHandler = null;
|
|
578
672
|
this.iframe = null;
|
|
673
|
+
this.iframeLoadTimeout = 10000;
|
|
579
674
|
this.environmentId = environmentId;
|
|
580
675
|
this.authToken = authToken;
|
|
581
676
|
this.baseApiUrl = baseApiUrl;
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs-wallet/browser-wallet-client",
|
|
3
|
-
"version": "0.0.0-beta.
|
|
3
|
+
"version": "0.0.0-beta.244.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@dynamic-labs-wallet/core": "0.0.0-beta.
|
|
6
|
+
"@dynamic-labs-wallet/core": "0.0.0-beta.244.2",
|
|
7
7
|
"@dynamic-labs/message-transport": "^4.9.9",
|
|
8
8
|
"@dynamic-labs/logger": "^4.9.9"
|
|
9
9
|
},
|
package/src/client/client.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import type { BackupKeySharesToGoogleDriveRequest, CreateWalletAccountRequest, CreateWalletAccountResponse, ExportClientKeysharesRequest, GetWalletResponse, ImportPrivateKeyRequest, IsPasswordEncryptedRequest, OfflineExportPrivateKeyResponse, RefreshWalletAccountSharesRequest, RequiresPasswordForOperationRequest, ReshareRequest, SignMessageRequest, SignRawMessageRequest, SignTransactionRequest, SignTypedDataRequest, UpdatePasswordRequest, VerifyPasswordRequest } from '@dynamic-labs-wallet/core';
|
|
2
|
+
import { WalletOperation } from '@dynamic-labs-wallet/core';
|
|
1
3
|
import { type MessageTransportWithDefaultOrigin } from '@dynamic-labs/message-transport';
|
|
2
4
|
import { iframeMessageHandler } from '../services/iframeMessageHandler';
|
|
3
|
-
import type { GetWalletResponse, CreateWalletAccountResponse, RequiresPasswordForOperationRequest, SignMessageRequest, IsPasswordEncryptedRequest, BackupKeySharesToGoogleDriveRequest, VerifyPasswordRequest, UpdatePasswordRequest, ImportPrivateKeyRequest, ExportClientKeysharesRequest, OfflineExportPrivateKeyResponse, SignRawMessageRequest, CreateWalletAccountRequest, SignTransactionRequest, RefreshWalletAccountSharesRequest, ReshareRequest } from '@dynamic-labs-wallet/core';
|
|
4
|
-
import { WalletOperation } from '@dynamic-labs-wallet/core';
|
|
5
5
|
export declare class DynamicWalletClient {
|
|
6
6
|
protected chainName: string;
|
|
7
7
|
protected logger: import("@dynamic-labs/logger").Logger;
|
|
@@ -16,6 +16,7 @@ export declare class DynamicWalletClient {
|
|
|
16
16
|
private static iframeLoadPromise;
|
|
17
17
|
protected iframe: HTMLIFrameElement | null;
|
|
18
18
|
private debug;
|
|
19
|
+
iframeLoadTimeout: number;
|
|
19
20
|
private static sharedIframe;
|
|
20
21
|
private static iframeInstanceCount;
|
|
21
22
|
sdkVersion: string | undefined;
|
|
@@ -47,6 +48,10 @@ export declare class DynamicWalletClient {
|
|
|
47
48
|
* securely exchange the auth token with iframe securely
|
|
48
49
|
*/
|
|
49
50
|
private initAuthToken;
|
|
51
|
+
/**
|
|
52
|
+
* Reset the shared iframe and iframe load promise, and iframe instance count
|
|
53
|
+
*/
|
|
54
|
+
private resetSharedIframe;
|
|
50
55
|
private loadIframe;
|
|
51
56
|
/**
|
|
52
57
|
* Load an iframe for a specific container
|
|
@@ -94,6 +99,7 @@ export declare class DynamicWalletClient {
|
|
|
94
99
|
* const txString = Buffer.from(txBytes).toString("hex");
|
|
95
100
|
*/
|
|
96
101
|
signTransaction({ senderAddress, transaction, password, signedSessionId, authToken, }: Omit<SignTransactionRequest, 'chainName'>): Promise<string>;
|
|
102
|
+
signTypedData({ accountAddress, typedData, password, signedSessionId, }: Omit<SignTypedDataRequest, 'chainName'>): Promise<string>;
|
|
97
103
|
backupKeySharesToGoogleDrive({ accountAddress, password, signedSessionId, authToken, }: Omit<BackupKeySharesToGoogleDriveRequest, 'chainName'>): Promise<void>;
|
|
98
104
|
restoreBackupFromGoogleDrive({ accountAddress, displayContainer, password, signedSessionId, authToken, }: {
|
|
99
105
|
accountAddress: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mCAAmC,EACnC,0BAA0B,EAC1B,2BAA2B,EAC3B,4BAA4B,EAC5B,iBAAiB,EACjB,uBAAuB,EACvB,0BAA0B,EAC1B,+BAA+B,EAC/B,iCAAiC,EACjC,mCAAmC,EACnC,cAAc,EACd,kBAAkB,EAClB,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAGL,eAAe,EAChB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAGL,KAAK,iCAAiC,EACvC,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAIxE,qBAAa,mBAAmB;IAC9B,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC;IAC5B,SAAS,CAAC,MAAM,wCAAU;IACnB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAQ;IACjC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAQ;IACnC,aAAa,EAAE,MAAM,CAAC;IAC7B,OAAO,CAAC,SAAS,CAAS;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB,EAAE,MAAM,CAAC;IAClC,SAAS,CAAC,gBAAgB,EAAE,iCAAiC,GAAG,IAAI,C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,CAAC;IAgBrD,cAAc,CAAC,EACnB,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,eAAe,EACf,SAAS,GACV,EAAE,IAAI,CAAC,qBAAqB,EAAE,WAAW,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBrD,gBAAgB,CAAC,EACrB,UAAU,EACV,wBAAwB,EACxB,eAAe,EACf,SAAS,GACV,EAAE,IAAI,CACL,uBAAuB,EACvB,WAAW,CACZ,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAelC,qBAAqB,CAAC,EAC1B,cAAc,EACd,QAAQ,EACR,eAAe,EACf,SAAS,GACV,EAAE,IAAI,CAAC,4BAA4B,EAAE,WAAW,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAelE;;OAEG;IACG,uBAAuB,CAAC,EAC5B,SAAS,EACT,cAAc,GACf,EAAE;QACD,SAAS,EAAE,MAAM,EAAE,CAAC;QACpB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,GAAG,OAAO,CAAC,+BAA+B,CAAC;IAqB/B,OAAO;CAqBrB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type MessageTransportWithDefaultOrigin, type RequestChannel } from '@dynamic-labs/message-transport';
|
|
2
|
-
import type { IframeRequestMessages, GetWalletResponse, CreateWalletAccountResponse, SignMessageRequest, RequiresPasswordForOperationRequest, SignTransactionRequest, IsPasswordEncryptedRequest, BackupKeySharesToGoogleDriveRequest, RestoreBackupFromGoogleDriveRequest, RefreshWalletAccountSharesRequest, ReshareRequest, ExportPrivateKeyRequest, VerifyPasswordRequest, UpdatePasswordRequest, ImportPrivateKeyRequest, ExportClientKeysharesRequest, OfflineExportPrivateKeyRequest, OfflineExportPrivateKeyResponse, SignRawMessageRequest, GetWalletsRequest, CreateWalletAccountRequest, GetWalletRequest } from '@dynamic-labs-wallet/core';
|
|
2
|
+
import type { IframeRequestMessages, GetWalletResponse, CreateWalletAccountResponse, SignMessageRequest, RequiresPasswordForOperationRequest, SignTransactionRequest, IsPasswordEncryptedRequest, BackupKeySharesToGoogleDriveRequest, RestoreBackupFromGoogleDriveRequest, RefreshWalletAccountSharesRequest, ReshareRequest, ExportPrivateKeyRequest, VerifyPasswordRequest, UpdatePasswordRequest, ImportPrivateKeyRequest, ExportClientKeysharesRequest, OfflineExportPrivateKeyRequest, OfflineExportPrivateKeyResponse, SignRawMessageRequest, GetWalletsRequest, CreateWalletAccountRequest, GetWalletRequest, SignTypedDataRequest } from '@dynamic-labs-wallet/core';
|
|
3
3
|
export declare class iframeMessageHandler {
|
|
4
4
|
requestChannel: RequestChannel<IframeRequestMessages>;
|
|
5
5
|
constructor(messageTransport: MessageTransportWithDefaultOrigin);
|
|
@@ -22,6 +22,7 @@ export declare class iframeMessageHandler {
|
|
|
22
22
|
sendAuthToken(token: string): Promise<void>;
|
|
23
23
|
exportClientKeyshares(request: ExportClientKeysharesRequest): Promise<void>;
|
|
24
24
|
offlineExportPrivateKey(request: OfflineExportPrivateKeyRequest): Promise<OfflineExportPrivateKeyResponse>;
|
|
25
|
+
signTypedData(request: SignTypedDataRequest): Promise<string>;
|
|
25
26
|
cleanup(): Promise<void>;
|
|
26
27
|
}
|
|
27
28
|
//# sourceMappingURL=iframeMessageHandler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iframeMessageHandler.d.ts","sourceRoot":"","sources":["../../src/services/iframeMessageHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,iCAAiC,EACtC,KAAK,cAAc,EACpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EACV,qBAAqB,EACrB,iBAAiB,EACjB,2BAA2B,EAC3B,kBAAkB,EAClB,mCAAmC,EACnC,sBAAsB,EACtB,0BAA0B,EAC1B,mCAAmC,EACnC,mCAAmC,EACnC,iCAAiC,EACjC,cAAc,EACd,uBAAuB,EACvB,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,4BAA4B,EAC5B,8BAA8B,EAC9B,+BAA+B,EAC/B,qBAAqB,EACrB,iBAAiB,EACjB,0BAA0B,EAC1B,gBAAgB,
|
|
1
|
+
{"version":3,"file":"iframeMessageHandler.d.ts","sourceRoot":"","sources":["../../src/services/iframeMessageHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,iCAAiC,EACtC,KAAK,cAAc,EACpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EACV,qBAAqB,EACrB,iBAAiB,EACjB,2BAA2B,EAC3B,kBAAkB,EAClB,mCAAmC,EACnC,sBAAsB,EACtB,0BAA0B,EAC1B,mCAAmC,EACnC,mCAAmC,EACnC,iCAAiC,EACjC,cAAc,EACd,uBAAuB,EACvB,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,4BAA4B,EAC5B,8BAA8B,EAC9B,+BAA+B,EAC/B,qBAAqB,EACrB,iBAAiB,EACjB,0BAA0B,EAC1B,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,2BAA2B,CAAC;AAEnC,qBAAa,oBAAoB;IAC/B,cAAc,EAAE,cAAc,CAAC,qBAAqB,CAAC,CAAC;gBAE1C,gBAAgB,EAAE,iCAAiC;IAKzD,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAIpE,SAAS,CAAC,OAAO,EAAE,gBAAgB;IAInC,mBAAmB,CACvB,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,2BAA2B,CAAC;IAIjC,4BAA4B,CAChC,OAAO,EAAE,mCAAmC,GAC3C,OAAO,CAAC,OAAO,CAAC;IAIb,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC;IAIzD,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,MAAM,CAAC;IAI/D,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,CAAC;IAIjE,mBAAmB,CACvB,OAAO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