@frak-labs/core-sdk 0.0.4 → 0.0.6
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/cdn/bundle.js +18 -6
- package/dist/actions/index.cjs +61 -63
- package/dist/actions/index.d.cts +11 -13
- package/dist/actions/index.d.ts +11 -13
- package/dist/actions/index.js +21 -36
- package/dist/{chunk-GDH3M5ZC.js → chunk-665P7NO4.cjs} +7 -10
- package/dist/{chunk-HDFNBQ4E.cjs → chunk-7YDJDVXY.cjs} +61 -70
- package/dist/{chunk-AFLVOY5H.js → chunk-GTBCSNLF.js} +34 -57
- package/dist/chunk-PHVGCFDX.cjs +155 -0
- package/dist/{chunk-PO6YSB4Q.cjs → chunk-U2NTN5QZ.js} +2 -11
- package/dist/{chunk-RMOFMRZR.js → chunk-VE6URIIJ.js} +19 -41
- package/dist/{context-BjKowynW.d.cts → context-D7aZDKLT.d.cts} +209 -23
- package/dist/{context-DjVVznrf.d.ts → context-rDsQbSgB.d.ts} +209 -23
- package/dist/index.cjs +231 -68
- package/dist/index.d.cts +49 -67
- package/dist/index.d.ts +49 -67
- package/dist/index.js +154 -50
- package/dist/interactions/index.cjs +26 -15
- package/dist/interactions/index.js +1 -15
- package/package.json +9 -4
- package/dist/chunk-ZDGHKI3S.cjs +0 -171
package/dist/index.cjs
CHANGED
|
@@ -1,27 +1,123 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var _chunkHDFNBQ4Ecjs = require('./chunk-HDFNBQ4E.cjs');
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var _chunkPO6YSB4Qcjs = require('./chunk-PO6YSB4Q.cjs');
|
|
3
|
+
var chunk7YDJDVXY_cjs = require('./chunk-7YDJDVXY.cjs');
|
|
4
|
+
var chunk665P7NO4_cjs = require('./chunk-665P7NO4.cjs');
|
|
21
5
|
|
|
22
6
|
// src/utils/constants.ts
|
|
23
7
|
var BACKUP_KEY = "nexus-wallet-backup";
|
|
24
8
|
|
|
9
|
+
// src/clients/DebugInfo.ts
|
|
10
|
+
var DebugInfoGatherer = class _DebugInfoGatherer {
|
|
11
|
+
config;
|
|
12
|
+
iframe;
|
|
13
|
+
isSetupDone = false;
|
|
14
|
+
lastResponse = null;
|
|
15
|
+
lastRequest = null;
|
|
16
|
+
constructor(config, iframe) {
|
|
17
|
+
this.config = config;
|
|
18
|
+
this.iframe = iframe;
|
|
19
|
+
this.lastRequest = null;
|
|
20
|
+
this.lastResponse = null;
|
|
21
|
+
}
|
|
22
|
+
// Update communication logs
|
|
23
|
+
setLastResponse(event) {
|
|
24
|
+
this.lastResponse = {
|
|
25
|
+
event: event.data,
|
|
26
|
+
origin: event.origin,
|
|
27
|
+
timestamp: Date.now()
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
setLastRequest(event, target) {
|
|
31
|
+
this.lastRequest = { event, target, timestamp: Date.now() };
|
|
32
|
+
}
|
|
33
|
+
// Update connection status
|
|
34
|
+
updateSetupStatus(status) {
|
|
35
|
+
this.isSetupDone = status;
|
|
36
|
+
}
|
|
37
|
+
base64Encode(data) {
|
|
38
|
+
try {
|
|
39
|
+
return btoa(JSON.stringify(data));
|
|
40
|
+
} catch (err) {
|
|
41
|
+
console.warn("Failed to encode debug data", err);
|
|
42
|
+
return btoa("Failed to encode data");
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Extract information from the iframe status
|
|
47
|
+
*/
|
|
48
|
+
getIframeStatus() {
|
|
49
|
+
if (!this.iframe) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
loading: this.iframe.hasAttribute("loading"),
|
|
54
|
+
url: this.iframe.src,
|
|
55
|
+
readyState: this.iframe.contentDocument?.readyState ? this.iframe.contentDocument.readyState === "complete" ? 1 : 0 : -1,
|
|
56
|
+
contentWindow: !!this.iframe.contentWindow,
|
|
57
|
+
isConnected: this.iframe.isConnected
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
getNavigatorInfo() {
|
|
61
|
+
if (!navigator) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
userAgent: navigator.userAgent,
|
|
66
|
+
language: navigator.language,
|
|
67
|
+
onLine: navigator.onLine,
|
|
68
|
+
screenWidth: window.screen.width,
|
|
69
|
+
screenHeight: window.screen.height,
|
|
70
|
+
pixelRatio: window.devicePixelRatio
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
gatherDebugInfo(error) {
|
|
74
|
+
const iframeStatus = this.getIframeStatus();
|
|
75
|
+
const navigatorInfo = this.getNavigatorInfo();
|
|
76
|
+
let formattedError = "Unknown";
|
|
77
|
+
if (error instanceof chunk7YDJDVXY_cjs.FrakRpcError) {
|
|
78
|
+
formattedError = `FrakRpcError: ${error.code} '${error.message}'`;
|
|
79
|
+
} else if (error instanceof Error) {
|
|
80
|
+
formattedError = error.message;
|
|
81
|
+
} else if (typeof error === "string") {
|
|
82
|
+
formattedError = error;
|
|
83
|
+
}
|
|
84
|
+
const debugInfo = {
|
|
85
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
86
|
+
encodedUrl: btoa(window.location.href),
|
|
87
|
+
encodedConfig: this.config ? this.base64Encode(this.config) : "no-config",
|
|
88
|
+
navigatorInfo: navigatorInfo ? this.base64Encode(navigatorInfo) : "no-navigator",
|
|
89
|
+
iframeStatus: iframeStatus ? this.base64Encode(iframeStatus) : "not-iframe",
|
|
90
|
+
lastRequest: this.lastRequest ? this.base64Encode(this.lastRequest) : "No Frak request logged",
|
|
91
|
+
lastResponse: this.lastResponse ? this.base64Encode(this.lastResponse) : "No Frak response logged",
|
|
92
|
+
clientStatus: this.isSetupDone ? "setup" : "not-setup",
|
|
93
|
+
error: formattedError
|
|
94
|
+
};
|
|
95
|
+
return debugInfo;
|
|
96
|
+
}
|
|
97
|
+
static empty() {
|
|
98
|
+
return new _DebugInfoGatherer();
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Format Frak debug information
|
|
102
|
+
*/
|
|
103
|
+
formatDebugInfo(error) {
|
|
104
|
+
const debugInfo = this.gatherDebugInfo(error);
|
|
105
|
+
return `
|
|
106
|
+
Debug Information:
|
|
107
|
+
-----------------
|
|
108
|
+
Timestamp: ${debugInfo.timestamp}
|
|
109
|
+
URL: ${debugInfo.encodedUrl}
|
|
110
|
+
Config: ${debugInfo.encodedConfig}
|
|
111
|
+
Navigator Info: ${debugInfo.navigatorInfo}
|
|
112
|
+
IFrame Status: ${debugInfo.iframeStatus}
|
|
113
|
+
Last Request: ${debugInfo.lastRequest}
|
|
114
|
+
Last Response: ${debugInfo.lastResponse}
|
|
115
|
+
Client Status: ${debugInfo.clientStatus}
|
|
116
|
+
Error: ${debugInfo.error}
|
|
117
|
+
`.trim();
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
|
|
25
121
|
// src/clients/transports/iframeChannelManager.ts
|
|
26
122
|
function createIFrameChannelManager() {
|
|
27
123
|
const channels = /* @__PURE__ */ new Map();
|
|
@@ -42,7 +138,7 @@ function createIFrameChannelManager() {
|
|
|
42
138
|
function createIFrameLifecycleManager({
|
|
43
139
|
iframe
|
|
44
140
|
}) {
|
|
45
|
-
const isConnectedDeferred = new
|
|
141
|
+
const isConnectedDeferred = new chunk7YDJDVXY_cjs.Deferred();
|
|
46
142
|
const handler = async (messageEvent) => {
|
|
47
143
|
switch (messageEvent.iframeLifecycle) {
|
|
48
144
|
// Resolve the isConnected promise
|
|
@@ -64,11 +160,25 @@ function createIFrameLifecycleManager({
|
|
|
64
160
|
// Change iframe visibility
|
|
65
161
|
case "show":
|
|
66
162
|
case "hide":
|
|
67
|
-
|
|
163
|
+
chunk7YDJDVXY_cjs.changeIframeVisibility({
|
|
68
164
|
iframe,
|
|
69
165
|
isVisible: messageEvent.iframeLifecycle === "show"
|
|
70
166
|
});
|
|
71
167
|
break;
|
|
168
|
+
// Handshake handling
|
|
169
|
+
case "handshake": {
|
|
170
|
+
iframe.contentWindow?.postMessage(
|
|
171
|
+
{
|
|
172
|
+
clientLifecycle: "handshake-response",
|
|
173
|
+
data: {
|
|
174
|
+
token: messageEvent.data.token,
|
|
175
|
+
currentUrl: window.location.href
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
"*"
|
|
179
|
+
);
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
72
182
|
}
|
|
73
183
|
};
|
|
74
184
|
return {
|
|
@@ -82,31 +192,38 @@ function createIFrameMessageHandler({
|
|
|
82
192
|
frakWalletUrl,
|
|
83
193
|
iframe,
|
|
84
194
|
channelManager,
|
|
85
|
-
iframeLifecycleManager
|
|
195
|
+
iframeLifecycleManager,
|
|
196
|
+
debugInfo
|
|
86
197
|
}) {
|
|
87
198
|
if (typeof window === "undefined") {
|
|
88
|
-
throw new
|
|
89
|
-
|
|
199
|
+
throw new chunk7YDJDVXY_cjs.FrakRpcError(
|
|
200
|
+
chunk7YDJDVXY_cjs.RpcErrorCodes.configError,
|
|
90
201
|
"iframe client should be used in the browser"
|
|
91
202
|
);
|
|
92
203
|
}
|
|
93
204
|
if (!iframe.contentWindow) {
|
|
94
|
-
throw new
|
|
95
|
-
|
|
205
|
+
throw new chunk7YDJDVXY_cjs.FrakRpcError(
|
|
206
|
+
chunk7YDJDVXY_cjs.RpcErrorCodes.configError,
|
|
96
207
|
"The iframe does not have a product window"
|
|
97
208
|
);
|
|
98
209
|
}
|
|
99
210
|
const contentWindow = iframe.contentWindow;
|
|
100
|
-
|
|
101
|
-
if (!
|
|
211
|
+
async function msgHandler(event) {
|
|
212
|
+
if (!event.origin) {
|
|
102
213
|
return;
|
|
103
214
|
}
|
|
104
|
-
|
|
215
|
+
try {
|
|
216
|
+
if (new URL(event.origin).origin.toLowerCase() !== new URL(frakWalletUrl).origin.toLowerCase()) {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
} catch (e) {
|
|
220
|
+
console.log("Unable to check frak msg origin", e);
|
|
105
221
|
return;
|
|
106
222
|
}
|
|
107
223
|
if (typeof event.data !== "object") {
|
|
108
224
|
return;
|
|
109
225
|
}
|
|
226
|
+
debugInfo.setLastResponse(event);
|
|
110
227
|
if ("iframeLifecycle" in event.data) {
|
|
111
228
|
await iframeLifecycleManager.handleEvent(event.data);
|
|
112
229
|
return;
|
|
@@ -123,16 +240,17 @@ function createIFrameMessageHandler({
|
|
|
123
240
|
return;
|
|
124
241
|
}
|
|
125
242
|
await resolver(event.data);
|
|
126
|
-
}
|
|
243
|
+
}
|
|
127
244
|
window.addEventListener("message", msgHandler);
|
|
128
|
-
|
|
245
|
+
function sendEvent(message) {
|
|
129
246
|
contentWindow.postMessage(message, {
|
|
130
247
|
targetOrigin: frakWalletUrl
|
|
131
248
|
});
|
|
132
|
-
|
|
133
|
-
|
|
249
|
+
debugInfo.setLastRequest(message, frakWalletUrl);
|
|
250
|
+
}
|
|
251
|
+
function cleanup() {
|
|
134
252
|
window.removeEventListener("message", msgHandler);
|
|
135
|
-
}
|
|
253
|
+
}
|
|
136
254
|
return {
|
|
137
255
|
sendEvent,
|
|
138
256
|
cleanup
|
|
@@ -146,29 +264,31 @@ function createIFrameFrakClient({
|
|
|
146
264
|
}) {
|
|
147
265
|
const channelManager = createIFrameChannelManager();
|
|
148
266
|
const lifecycleManager = createIFrameLifecycleManager({ iframe });
|
|
267
|
+
const debugInfo = new DebugInfoGatherer(config, iframe);
|
|
149
268
|
const messageHandler = createIFrameMessageHandler({
|
|
150
|
-
frakWalletUrl:
|
|
269
|
+
frakWalletUrl: config?.walletUrl ?? "https://wallet.frak.id",
|
|
151
270
|
iframe,
|
|
152
271
|
channelManager,
|
|
153
|
-
iframeLifecycleManager: lifecycleManager
|
|
272
|
+
iframeLifecycleManager: lifecycleManager,
|
|
273
|
+
debugInfo
|
|
154
274
|
});
|
|
155
275
|
const request = async (args) => {
|
|
156
276
|
const isConnected = await lifecycleManager.isConnected;
|
|
157
277
|
if (!isConnected) {
|
|
158
|
-
throw new
|
|
159
|
-
|
|
278
|
+
throw new chunk7YDJDVXY_cjs.FrakRpcError(
|
|
279
|
+
chunk7YDJDVXY_cjs.RpcErrorCodes.clientNotConnected,
|
|
160
280
|
"The iframe provider isn't connected yet"
|
|
161
281
|
);
|
|
162
282
|
}
|
|
163
|
-
const result = new
|
|
283
|
+
const result = new chunk7YDJDVXY_cjs.Deferred();
|
|
164
284
|
const channelId = channelManager.createChannel(async (message) => {
|
|
165
|
-
const decompressed = await
|
|
285
|
+
const decompressed = await chunk7YDJDVXY_cjs.decompressDataAndCheckHash(message.data);
|
|
166
286
|
if (decompressed.error) {
|
|
167
287
|
result.reject(
|
|
168
|
-
new
|
|
288
|
+
new chunk7YDJDVXY_cjs.FrakRpcError(
|
|
169
289
|
decompressed.error.code,
|
|
170
290
|
decompressed.error.message,
|
|
171
|
-
|
|
291
|
+
decompressed.error?.data
|
|
172
292
|
)
|
|
173
293
|
);
|
|
174
294
|
} else {
|
|
@@ -176,7 +296,7 @@ function createIFrameFrakClient({
|
|
|
176
296
|
}
|
|
177
297
|
channelManager.removeChannel(channelId);
|
|
178
298
|
});
|
|
179
|
-
const compressedMessage = await
|
|
299
|
+
const compressedMessage = await chunk7YDJDVXY_cjs.hashAndCompressData(args);
|
|
180
300
|
messageHandler.sendEvent({
|
|
181
301
|
id: channelId,
|
|
182
302
|
topic: args.method,
|
|
@@ -187,20 +307,20 @@ function createIFrameFrakClient({
|
|
|
187
307
|
const listenerRequest = async (args, callback) => {
|
|
188
308
|
const isConnected = await lifecycleManager.isConnected;
|
|
189
309
|
if (!isConnected) {
|
|
190
|
-
throw new
|
|
191
|
-
|
|
310
|
+
throw new chunk7YDJDVXY_cjs.FrakRpcError(
|
|
311
|
+
chunk7YDJDVXY_cjs.RpcErrorCodes.clientNotConnected,
|
|
192
312
|
"The iframe provider isn't connected yet"
|
|
193
313
|
);
|
|
194
314
|
}
|
|
195
315
|
const channelId = channelManager.createChannel(async (message) => {
|
|
196
|
-
const decompressed = await
|
|
316
|
+
const decompressed = await chunk7YDJDVXY_cjs.decompressDataAndCheckHash(message.data);
|
|
197
317
|
if (decompressed.result) {
|
|
198
318
|
callback(decompressed.result);
|
|
199
319
|
} else {
|
|
200
|
-
throw new
|
|
320
|
+
throw new chunk7YDJDVXY_cjs.InternalError("No valid result in the response");
|
|
201
321
|
}
|
|
202
322
|
});
|
|
203
|
-
const compressedMessage = await
|
|
323
|
+
const compressedMessage = await chunk7YDJDVXY_cjs.hashAndCompressData(args);
|
|
204
324
|
messageHandler.sendEvent({
|
|
205
325
|
id: channelId,
|
|
206
326
|
topic: args.method,
|
|
@@ -218,9 +338,10 @@ function createIFrameFrakClient({
|
|
|
218
338
|
config,
|
|
219
339
|
messageHandler,
|
|
220
340
|
lifecycleManager
|
|
221
|
-
});
|
|
341
|
+
}).then(() => debugInfo.updateSetupStatus(true));
|
|
222
342
|
return {
|
|
223
343
|
config,
|
|
344
|
+
debugInfo,
|
|
224
345
|
waitForConnection: lifecycleManager.isConnected,
|
|
225
346
|
waitForSetup,
|
|
226
347
|
request,
|
|
@@ -234,7 +355,7 @@ function setupHeartbeat(messageHandler, lifecycleManager) {
|
|
|
234
355
|
let heartbeatInterval;
|
|
235
356
|
let timeoutId;
|
|
236
357
|
const sendHeartbeat = () => messageHandler.sendEvent({
|
|
237
|
-
|
|
358
|
+
clientLifecycle: "heartbeat"
|
|
238
359
|
});
|
|
239
360
|
async function startHeartbeat() {
|
|
240
361
|
sendHeartbeat();
|
|
@@ -287,7 +408,7 @@ async function postConnectionSetup({
|
|
|
287
408
|
async function setupClient({
|
|
288
409
|
config
|
|
289
410
|
}) {
|
|
290
|
-
const iframe = await
|
|
411
|
+
const iframe = await chunk7YDJDVXY_cjs.createIframe({
|
|
291
412
|
config
|
|
292
413
|
});
|
|
293
414
|
if (!iframe) {
|
|
@@ -307,20 +428,62 @@ async function setupClient({
|
|
|
307
428
|
return client;
|
|
308
429
|
}
|
|
309
430
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
431
|
+
Object.defineProperty(exports, "ClientNotFound", {
|
|
432
|
+
enumerable: true,
|
|
433
|
+
get: function () { return chunk7YDJDVXY_cjs.ClientNotFound; }
|
|
434
|
+
});
|
|
435
|
+
Object.defineProperty(exports, "Deferred", {
|
|
436
|
+
enumerable: true,
|
|
437
|
+
get: function () { return chunk7YDJDVXY_cjs.Deferred; }
|
|
438
|
+
});
|
|
439
|
+
Object.defineProperty(exports, "FrakContextManager", {
|
|
440
|
+
enumerable: true,
|
|
441
|
+
get: function () { return chunk7YDJDVXY_cjs.FrakContextManager; }
|
|
442
|
+
});
|
|
443
|
+
Object.defineProperty(exports, "FrakRpcError", {
|
|
444
|
+
enumerable: true,
|
|
445
|
+
get: function () { return chunk7YDJDVXY_cjs.FrakRpcError; }
|
|
446
|
+
});
|
|
447
|
+
Object.defineProperty(exports, "RpcErrorCodes", {
|
|
448
|
+
enumerable: true,
|
|
449
|
+
get: function () { return chunk7YDJDVXY_cjs.RpcErrorCodes; }
|
|
450
|
+
});
|
|
451
|
+
Object.defineProperty(exports, "baseIframeProps", {
|
|
452
|
+
enumerable: true,
|
|
453
|
+
get: function () { return chunk7YDJDVXY_cjs.baseIframeProps; }
|
|
454
|
+
});
|
|
455
|
+
Object.defineProperty(exports, "compressJson", {
|
|
456
|
+
enumerable: true,
|
|
457
|
+
get: function () { return chunk7YDJDVXY_cjs.compressJson; }
|
|
458
|
+
});
|
|
459
|
+
Object.defineProperty(exports, "createIframe", {
|
|
460
|
+
enumerable: true,
|
|
461
|
+
get: function () { return chunk7YDJDVXY_cjs.createIframe; }
|
|
462
|
+
});
|
|
463
|
+
Object.defineProperty(exports, "decompressDataAndCheckHash", {
|
|
464
|
+
enumerable: true,
|
|
465
|
+
get: function () { return chunk7YDJDVXY_cjs.decompressDataAndCheckHash; }
|
|
466
|
+
});
|
|
467
|
+
Object.defineProperty(exports, "decompressJson", {
|
|
468
|
+
enumerable: true,
|
|
469
|
+
get: function () { return chunk7YDJDVXY_cjs.decompressJson; }
|
|
470
|
+
});
|
|
471
|
+
Object.defineProperty(exports, "hashAndCompressData", {
|
|
472
|
+
enumerable: true,
|
|
473
|
+
get: function () { return chunk7YDJDVXY_cjs.hashAndCompressData; }
|
|
474
|
+
});
|
|
475
|
+
Object.defineProperty(exports, "interactionTypes", {
|
|
476
|
+
enumerable: true,
|
|
477
|
+
get: function () { return chunk665P7NO4_cjs.interactionTypes; }
|
|
478
|
+
});
|
|
479
|
+
Object.defineProperty(exports, "productTypes", {
|
|
480
|
+
enumerable: true,
|
|
481
|
+
get: function () { return chunk665P7NO4_cjs.productTypes; }
|
|
482
|
+
});
|
|
483
|
+
Object.defineProperty(exports, "productTypesMask", {
|
|
484
|
+
enumerable: true,
|
|
485
|
+
get: function () { return chunk665P7NO4_cjs.productTypesMask; }
|
|
486
|
+
});
|
|
487
|
+
exports.DebugInfoGatherer = DebugInfoGatherer;
|
|
488
|
+
exports.createIFrameFrakClient = createIFrameFrakClient;
|
|
489
|
+
exports.setupClient = setupClient;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,10 +1,31 @@
|
|
|
1
|
-
import { F as FrakWalletSdkConfig, a as FrakClient, b as FrakContext } from './context-
|
|
2
|
-
export { C as ClientLifecycleEvent, D as DisplayModalParamsType, E as ExtractedParametersFromRpc,
|
|
1
|
+
import { F as FrakWalletSdkConfig, a as FrakClient, I as IFrameEvent, b as FrakContext } from './context-D7aZDKLT.cjs';
|
|
2
|
+
export { C as ClientLifecycleEvent, D as DisplayEmbededWalletParamsType, j as DisplayModalParamsType, E as EmbededViewAction, H as ExtractedParametersFromRpc, J as ExtractedReturnTypeFromRpc, y as FinalActionType, x as FinalModalStepType, e as FullInteractionTypesKey, G as GetProductInformationReturnType, B as IFrameLifecycleEvent, A as IFrameRpcEvent, f as IFrameRpcSchema, z as IFrameTransport, d as InteractionTypesKey, g as LoggedInEmbededView, L as LoggedOutEmbededView, n as LoginModalStepType, h as ModalRpcMetadata, k as ModalRpcStepsInput, l as ModalRpcStepsResultType, m as ModalStepMetadata, M as ModalStepTypes, w as OpenInteractionSessionModalStepType, v as OpenInteractionSessionReturnType, O as OpenSsoParamsType, P as ProductTypesKey, R as RpcResponse, t as SendTransactionModalStepType, u as SendTransactionReturnType, s as SendTransactionTxType, o as SiweAuthenticateModalStepType, r as SiweAuthenticateReturnType, q as SiweAuthenticationParams, S as SsoMetadata, W as WalletStatusReturnType, i as interactionTypes, p as productTypes, c as productTypesMask } from './context-D7aZDKLT.cjs';
|
|
3
3
|
export { P as PreparedInteraction, S as SendInteractionParamsType, a as SendInteractionReturnType } from './interaction-CTQ5-kqe.cjs';
|
|
4
4
|
import 'viem';
|
|
5
5
|
import 'viem/chains';
|
|
6
6
|
import 'viem/siwe';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Create a new iframe Frak client
|
|
10
|
+
* @param args
|
|
11
|
+
* @param args.config - The configuration to use for the Frak Wallet SDK
|
|
12
|
+
* @param args.iframe - The iframe to use for the communication
|
|
13
|
+
* @returns The created Frak Client
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* const frakConfig: FrakWalletSdkConfig = {
|
|
17
|
+
* metadata: {
|
|
18
|
+
* name: "My app title",
|
|
19
|
+
* },
|
|
20
|
+
* }
|
|
21
|
+
* const iframe = await createIframe({ config: frakConfig });
|
|
22
|
+
* const client = createIFrameFrakClient({ config: frakConfig, iframe });
|
|
23
|
+
*/
|
|
24
|
+
declare function createIFrameFrakClient({ config, iframe, }: {
|
|
25
|
+
config: FrakWalletSdkConfig;
|
|
26
|
+
iframe: HTMLIFrameElement;
|
|
27
|
+
}): FrakClient;
|
|
28
|
+
|
|
8
29
|
/**
|
|
9
30
|
* Generic Frak RPC error
|
|
10
31
|
* @ignore
|
|
@@ -58,27 +79,6 @@ type HashProtectedData<DataType> = Readonly<DataType & {
|
|
|
58
79
|
*/
|
|
59
80
|
type KeyProvider<DataType> = (value: DataType) => string[];
|
|
60
81
|
|
|
61
|
-
/**
|
|
62
|
-
* Create a new iframe Frak client
|
|
63
|
-
* @param args
|
|
64
|
-
* @param args.config - The configuration to use for the Frak Wallet SDK
|
|
65
|
-
* @param args.iframe - The iframe to use for the communication
|
|
66
|
-
* @returns The created Frak Client
|
|
67
|
-
*
|
|
68
|
-
* @example
|
|
69
|
-
* const frakConfig: FrakWalletSdkConfig = {
|
|
70
|
-
* metadata: {
|
|
71
|
-
* name: "My app title",
|
|
72
|
-
* },
|
|
73
|
-
* }
|
|
74
|
-
* const iframe = await createIframe({ config: frakConfig });
|
|
75
|
-
* const client = createIFrameFrakClient({ config: frakConfig, iframe });
|
|
76
|
-
*/
|
|
77
|
-
declare function createIFrameFrakClient({ config, iframe, }: {
|
|
78
|
-
config: FrakWalletSdkConfig;
|
|
79
|
-
iframe: HTMLIFrameElement;
|
|
80
|
-
}): FrakClient;
|
|
81
|
-
|
|
82
82
|
/**
|
|
83
83
|
* Directly setup the Frak client with an iframe
|
|
84
84
|
* Return when the FrakClient is ready (setup and communication estbalished with the wallet)
|
|
@@ -98,6 +98,31 @@ declare function setupClient({ config, }: {
|
|
|
98
98
|
config: FrakWalletSdkConfig;
|
|
99
99
|
}): Promise<FrakClient | undefined>;
|
|
100
100
|
|
|
101
|
+
/** @ignore */
|
|
102
|
+
declare class DebugInfoGatherer {
|
|
103
|
+
private config?;
|
|
104
|
+
private iframe?;
|
|
105
|
+
private isSetupDone;
|
|
106
|
+
private lastResponse;
|
|
107
|
+
private lastRequest;
|
|
108
|
+
constructor(config?: FrakWalletSdkConfig, iframe?: HTMLIFrameElement);
|
|
109
|
+
setLastResponse(event: MessageEvent<IFrameEvent>): void;
|
|
110
|
+
setLastRequest(event: IFrameEvent, target: string): void;
|
|
111
|
+
updateSetupStatus(status: boolean): void;
|
|
112
|
+
private base64Encode;
|
|
113
|
+
/**
|
|
114
|
+
* Extract information from the iframe status
|
|
115
|
+
*/
|
|
116
|
+
private getIframeStatus;
|
|
117
|
+
private getNavigatorInfo;
|
|
118
|
+
private gatherDebugInfo;
|
|
119
|
+
static empty(): DebugInfoGatherer;
|
|
120
|
+
/**
|
|
121
|
+
* Format Frak debug information
|
|
122
|
+
*/
|
|
123
|
+
formatDebugInfo(error: Error | unknown | string): string;
|
|
124
|
+
}
|
|
125
|
+
|
|
101
126
|
/**
|
|
102
127
|
* Base props for the iframe
|
|
103
128
|
* @ignore
|
|
@@ -227,47 +252,4 @@ declare class Deferred<T> {
|
|
|
227
252
|
reject: (reason?: unknown) => void;
|
|
228
253
|
}
|
|
229
254
|
|
|
230
|
-
|
|
231
|
-
* The final keys for each interaction types (e.g. `openArticle`) -> interaction type
|
|
232
|
-
* @inline
|
|
233
|
-
*/
|
|
234
|
-
type InteractionTypesKey = {
|
|
235
|
-
[K in keyof typeof interactionTypes]: keyof (typeof interactionTypes)[K];
|
|
236
|
-
}[keyof typeof interactionTypes];
|
|
237
|
-
/**
|
|
238
|
-
* The keys for each interaction types (e.g. `press.openArticle`) -> category_type.interaction_type
|
|
239
|
-
* @inline
|
|
240
|
-
*/
|
|
241
|
-
type FullInteractionTypesKey = {
|
|
242
|
-
[Category in keyof typeof interactionTypes]: `${Category & string}.${keyof (typeof interactionTypes)[Category] & string}`;
|
|
243
|
-
}[keyof typeof interactionTypes];
|
|
244
|
-
/**
|
|
245
|
-
* Each interactions types according to the product types
|
|
246
|
-
*/
|
|
247
|
-
declare const interactionTypes: {
|
|
248
|
-
readonly press: {
|
|
249
|
-
readonly openArticle: "0xc0a24ffb";
|
|
250
|
-
readonly readArticle: "0xd5bd0fbe";
|
|
251
|
-
};
|
|
252
|
-
readonly dapp: {
|
|
253
|
-
readonly proofVerifiableStorageUpdate: "0x2ab2aeef";
|
|
254
|
-
readonly callableVerifiableStorageUpdate: "0xa07da986";
|
|
255
|
-
};
|
|
256
|
-
readonly webshop: {
|
|
257
|
-
readonly open: "0xb311798f";
|
|
258
|
-
};
|
|
259
|
-
readonly referral: {
|
|
260
|
-
readonly referred: "0x010cc3b9";
|
|
261
|
-
readonly createLink: "0xb2c0f17c";
|
|
262
|
-
};
|
|
263
|
-
readonly purchase: {
|
|
264
|
-
readonly started: "0xd87e90c3";
|
|
265
|
-
readonly completed: "0x8403aeb4";
|
|
266
|
-
readonly unsafeCompleted: "0x4d5b14e0";
|
|
267
|
-
};
|
|
268
|
-
readonly retail: {
|
|
269
|
-
readonly customerMeeting: "0x74489004";
|
|
270
|
-
};
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
export { ClientNotFound, type CompressedData, Deferred, FrakClient, FrakContext, FrakContextManager, FrakRpcError, FrakWalletSdkConfig, type FullInteractionTypesKey, type HashProtectedData, type InteractionTypesKey, type KeyProvider, RpcErrorCodes, baseIframeProps, compressJson, createIFrameFrakClient, createIframe, decompressDataAndCheckHash, decompressJson, hashAndCompressData, interactionTypes, setupClient };
|
|
255
|
+
export { ClientNotFound, type CompressedData, DebugInfoGatherer, Deferred, FrakClient, FrakContext, FrakContextManager, FrakRpcError, FrakWalletSdkConfig, type HashProtectedData, IFrameEvent, type KeyProvider, RpcErrorCodes, baseIframeProps, compressJson, createIFrameFrakClient, createIframe, decompressDataAndCheckHash, decompressJson, hashAndCompressData, setupClient };
|