@frak-labs/core-sdk 0.0.2 → 0.0.5

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/dist/index.cjs CHANGED
@@ -1,27 +1,124 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
1
+ 'use strict';
2
2
 
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
- var _chunkNJJQPEELcjs = require('./chunk-NJJQPEEL.cjs');
16
-
17
-
18
-
19
-
20
- var _chunkPR3T7O5Icjs = require('./chunk-PR3T7O5I.cjs');
3
+ var chunkIVQL5N55_cjs = require('./chunk-IVQL5N55.cjs');
4
+ var chunkPO6YSB4Q_cjs = require('./chunk-PO6YSB4Q.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
+ constructor(config, iframe) {
12
+ chunkPO6YSB4Q_cjs.__publicField(this, "config");
13
+ chunkPO6YSB4Q_cjs.__publicField(this, "iframe");
14
+ chunkPO6YSB4Q_cjs.__publicField(this, "isSetupDone", false);
15
+ chunkPO6YSB4Q_cjs.__publicField(this, "lastResponse", null);
16
+ chunkPO6YSB4Q_cjs.__publicField(this, "lastRequest", null);
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
+ var _a;
50
+ if (!this.iframe) {
51
+ return null;
52
+ }
53
+ return {
54
+ loading: this.iframe.hasAttribute("loading"),
55
+ url: this.iframe.src,
56
+ readyState: ((_a = this.iframe.contentDocument) == null ? undefined : _a.readyState) ? this.iframe.contentDocument.readyState === "complete" ? 1 : 0 : -1,
57
+ contentWindow: !!this.iframe.contentWindow,
58
+ isConnected: this.iframe.isConnected
59
+ };
60
+ }
61
+ getNavigatorInfo() {
62
+ if (!navigator) {
63
+ return null;
64
+ }
65
+ return {
66
+ userAgent: navigator.userAgent,
67
+ language: navigator.language,
68
+ onLine: navigator.onLine,
69
+ screenWidth: window.screen.width,
70
+ screenHeight: window.screen.height,
71
+ pixelRatio: window.devicePixelRatio
72
+ };
73
+ }
74
+ gatherDebugInfo(error) {
75
+ const iframeStatus = this.getIframeStatus();
76
+ const navigatorInfo = this.getNavigatorInfo();
77
+ let formattedError = "Unknown";
78
+ if (error instanceof chunkIVQL5N55_cjs.FrakRpcError) {
79
+ formattedError = `FrakRpcError: ${error.code} '${error.message}'`;
80
+ } else if (error instanceof Error) {
81
+ formattedError = error.message;
82
+ } else if (typeof error === "string") {
83
+ formattedError = error;
84
+ }
85
+ const debugInfo = {
86
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
87
+ encodedUrl: btoa(window.location.href),
88
+ encodedConfig: this.config ? this.base64Encode(this.config) : "no-config",
89
+ navigatorInfo: navigatorInfo ? this.base64Encode(navigatorInfo) : "no-navigator",
90
+ iframeStatus: iframeStatus ? this.base64Encode(iframeStatus) : "not-iframe",
91
+ lastRequest: this.lastRequest ? this.base64Encode(this.lastRequest) : "No Frak request logged",
92
+ lastResponse: this.lastResponse ? this.base64Encode(this.lastResponse) : "No Frak response logged",
93
+ clientStatus: this.isSetupDone ? "setup" : "not-setup",
94
+ error: formattedError
95
+ };
96
+ return debugInfo;
97
+ }
98
+ static empty() {
99
+ return new _DebugInfoGatherer();
100
+ }
101
+ /**
102
+ * Format Frak debug information
103
+ */
104
+ formatDebugInfo(error) {
105
+ const debugInfo = this.gatherDebugInfo(error);
106
+ return `
107
+ Debug Information:
108
+ -----------------
109
+ Timestamp: ${debugInfo.timestamp}
110
+ URL: ${debugInfo.encodedUrl}
111
+ Config: ${debugInfo.encodedConfig}
112
+ Navigator Info: ${debugInfo.navigatorInfo}
113
+ IFrame Status: ${debugInfo.iframeStatus}
114
+ Last Request: ${debugInfo.lastRequest}
115
+ Last Response: ${debugInfo.lastResponse}
116
+ Client Status: ${debugInfo.clientStatus}
117
+ Error: ${debugInfo.error}
118
+ `.trim();
119
+ }
120
+ };
121
+
25
122
  // src/clients/transports/iframeChannelManager.ts
26
123
  function createIFrameChannelManager() {
27
124
  const channels = /* @__PURE__ */ new Map();
@@ -42,8 +139,9 @@ function createIFrameChannelManager() {
42
139
  function createIFrameLifecycleManager({
43
140
  iframe
44
141
  }) {
45
- const isConnectedDeferred = new (0, _chunkNJJQPEELcjs.Deferred)();
142
+ const isConnectedDeferred = new chunkIVQL5N55_cjs.Deferred();
46
143
  const handler = async (messageEvent) => {
144
+ var _a;
47
145
  switch (messageEvent.iframeLifecycle) {
48
146
  // Resolve the isConnected promise
49
147
  case "connected":
@@ -64,11 +162,28 @@ function createIFrameLifecycleManager({
64
162
  // Change iframe visibility
65
163
  case "show":
66
164
  case "hide":
67
- _chunkNJJQPEELcjs.changeIframeVisibility.call(void 0, {
165
+ chunkIVQL5N55_cjs.changeIframeVisibility({
68
166
  iframe,
69
167
  isVisible: messageEvent.iframeLifecycle === "show"
70
168
  });
71
169
  break;
170
+ // Handshake handling
171
+ case "handshake": {
172
+ console.log("Received handshake event", {
173
+ token: messageEvent.data.token
174
+ });
175
+ (_a = iframe.contentWindow) == null ? undefined : _a.postMessage(
176
+ {
177
+ clientLifecycle: "handshake-response",
178
+ data: {
179
+ token: messageEvent.data.token,
180
+ currentUrl: window.location.href
181
+ }
182
+ },
183
+ "*"
184
+ );
185
+ break;
186
+ }
72
187
  }
73
188
  };
74
189
  return {
@@ -82,31 +197,38 @@ function createIFrameMessageHandler({
82
197
  frakWalletUrl,
83
198
  iframe,
84
199
  channelManager,
85
- iframeLifecycleManager
200
+ iframeLifecycleManager,
201
+ debugInfo
86
202
  }) {
87
203
  if (typeof window === "undefined") {
88
- throw new (0, _chunkNJJQPEELcjs.FrakRpcError)(
89
- _chunkNJJQPEELcjs.RpcErrorCodes.configError,
204
+ throw new chunkIVQL5N55_cjs.FrakRpcError(
205
+ chunkIVQL5N55_cjs.RpcErrorCodes.configError,
90
206
  "iframe client should be used in the browser"
91
207
  );
92
208
  }
93
209
  if (!iframe.contentWindow) {
94
- throw new (0, _chunkNJJQPEELcjs.FrakRpcError)(
95
- _chunkNJJQPEELcjs.RpcErrorCodes.configError,
210
+ throw new chunkIVQL5N55_cjs.FrakRpcError(
211
+ chunkIVQL5N55_cjs.RpcErrorCodes.configError,
96
212
  "The iframe does not have a product window"
97
213
  );
98
214
  }
99
215
  const contentWindow = iframe.contentWindow;
100
- const msgHandler = async (event) => {
101
- if (!(event.origin && URL.canParse(event.origin))) {
216
+ async function msgHandler(event) {
217
+ if (!event.origin) {
102
218
  return;
103
219
  }
104
- if (new URL(event.origin).origin.toLowerCase() !== new URL(frakWalletUrl).origin.toLowerCase()) {
220
+ try {
221
+ if (new URL(event.origin).origin.toLowerCase() !== new URL(frakWalletUrl).origin.toLowerCase()) {
222
+ return;
223
+ }
224
+ } catch (e) {
225
+ console.log("Unable to check frak msg origin", e);
105
226
  return;
106
227
  }
107
228
  if (typeof event.data !== "object") {
108
229
  return;
109
230
  }
231
+ debugInfo.setLastResponse(event);
110
232
  if ("iframeLifecycle" in event.data) {
111
233
  await iframeLifecycleManager.handleEvent(event.data);
112
234
  return;
@@ -123,16 +245,17 @@ function createIFrameMessageHandler({
123
245
  return;
124
246
  }
125
247
  await resolver(event.data);
126
- };
248
+ }
127
249
  window.addEventListener("message", msgHandler);
128
- const sendEvent = (message) => {
250
+ function sendEvent(message) {
129
251
  contentWindow.postMessage(message, {
130
252
  targetOrigin: frakWalletUrl
131
253
  });
132
- };
133
- const cleanup = () => {
254
+ debugInfo.setLastRequest(message, frakWalletUrl);
255
+ }
256
+ function cleanup() {
134
257
  window.removeEventListener("message", msgHandler);
135
- };
258
+ }
136
259
  return {
137
260
  sendEvent,
138
261
  cleanup
@@ -144,31 +267,35 @@ function createIFrameFrakClient({
144
267
  config,
145
268
  iframe
146
269
  }) {
270
+ var _a;
147
271
  const channelManager = createIFrameChannelManager();
148
272
  const lifecycleManager = createIFrameLifecycleManager({ iframe });
273
+ const debugInfo = new DebugInfoGatherer(config, iframe);
149
274
  const messageHandler = createIFrameMessageHandler({
150
- frakWalletUrl: _nullishCoalesce(_optionalChain([config, 'optionalAccess', _ => _.walletUrl]), () => ( "https://wallet.frak.id")),
275
+ frakWalletUrl: (_a = config == null ? undefined : config.walletUrl) != null ? _a : "https://wallet.frak.id",
151
276
  iframe,
152
277
  channelManager,
153
- iframeLifecycleManager: lifecycleManager
278
+ iframeLifecycleManager: lifecycleManager,
279
+ debugInfo
154
280
  });
155
281
  const request = async (args) => {
156
282
  const isConnected = await lifecycleManager.isConnected;
157
283
  if (!isConnected) {
158
- throw new (0, _chunkNJJQPEELcjs.FrakRpcError)(
159
- _chunkNJJQPEELcjs.RpcErrorCodes.clientNotConnected,
284
+ throw new chunkIVQL5N55_cjs.FrakRpcError(
285
+ chunkIVQL5N55_cjs.RpcErrorCodes.clientNotConnected,
160
286
  "The iframe provider isn't connected yet"
161
287
  );
162
288
  }
163
- const result = new (0, _chunkNJJQPEELcjs.Deferred)();
289
+ const result = new chunkIVQL5N55_cjs.Deferred();
164
290
  const channelId = channelManager.createChannel(async (message) => {
165
- const decompressed = await _chunkNJJQPEELcjs.decompressDataAndCheckHash.call(void 0, message.data);
291
+ var _a2;
292
+ const decompressed = await chunkIVQL5N55_cjs.decompressDataAndCheckHash(message.data);
166
293
  if (decompressed.error) {
167
294
  result.reject(
168
- new (0, _chunkNJJQPEELcjs.FrakRpcError)(
295
+ new chunkIVQL5N55_cjs.FrakRpcError(
169
296
  decompressed.error.code,
170
297
  decompressed.error.message,
171
- _optionalChain([decompressed, 'access', _2 => _2.error, 'optionalAccess', _3 => _3.data])
298
+ (_a2 = decompressed.error) == null ? undefined : _a2.data
172
299
  )
173
300
  );
174
301
  } else {
@@ -176,7 +303,7 @@ function createIFrameFrakClient({
176
303
  }
177
304
  channelManager.removeChannel(channelId);
178
305
  });
179
- const compressedMessage = await _chunkNJJQPEELcjs.hashAndCompressData.call(void 0, args);
306
+ const compressedMessage = await chunkIVQL5N55_cjs.hashAndCompressData(args);
180
307
  messageHandler.sendEvent({
181
308
  id: channelId,
182
309
  topic: args.method,
@@ -187,20 +314,20 @@ function createIFrameFrakClient({
187
314
  const listenerRequest = async (args, callback) => {
188
315
  const isConnected = await lifecycleManager.isConnected;
189
316
  if (!isConnected) {
190
- throw new (0, _chunkNJJQPEELcjs.FrakRpcError)(
191
- _chunkNJJQPEELcjs.RpcErrorCodes.clientNotConnected,
317
+ throw new chunkIVQL5N55_cjs.FrakRpcError(
318
+ chunkIVQL5N55_cjs.RpcErrorCodes.clientNotConnected,
192
319
  "The iframe provider isn't connected yet"
193
320
  );
194
321
  }
195
322
  const channelId = channelManager.createChannel(async (message) => {
196
- const decompressed = await _chunkNJJQPEELcjs.decompressDataAndCheckHash.call(void 0, message.data);
323
+ const decompressed = await chunkIVQL5N55_cjs.decompressDataAndCheckHash(message.data);
197
324
  if (decompressed.result) {
198
325
  callback(decompressed.result);
199
326
  } else {
200
- throw new (0, _chunkNJJQPEELcjs.InternalError)("No valid result in the response");
327
+ throw new chunkIVQL5N55_cjs.InternalError("No valid result in the response");
201
328
  }
202
329
  });
203
- const compressedMessage = await _chunkNJJQPEELcjs.hashAndCompressData.call(void 0, args);
330
+ const compressedMessage = await chunkIVQL5N55_cjs.hashAndCompressData(args);
204
331
  messageHandler.sendEvent({
205
332
  id: channelId,
206
333
  topic: args.method,
@@ -218,9 +345,10 @@ function createIFrameFrakClient({
218
345
  config,
219
346
  messageHandler,
220
347
  lifecycleManager
221
- });
348
+ }).then(() => debugInfo.updateSetupStatus(true));
222
349
  return {
223
350
  config,
351
+ debugInfo,
224
352
  waitForConnection: lifecycleManager.isConnected,
225
353
  waitForSetup,
226
354
  request,
@@ -234,7 +362,7 @@ function setupHeartbeat(messageHandler, lifecycleManager) {
234
362
  let heartbeatInterval;
235
363
  let timeoutId;
236
364
  const sendHeartbeat = () => messageHandler.sendEvent({
237
- iframeLifecycle: "heartbeat"
365
+ clientLifecycle: "heartbeat"
238
366
  });
239
367
  async function startHeartbeat() {
240
368
  sendHeartbeat();
@@ -287,7 +415,7 @@ async function postConnectionSetup({
287
415
  async function setupClient({
288
416
  config
289
417
  }) {
290
- const iframe = await _chunkNJJQPEELcjs.createIframe.call(void 0, {
418
+ const iframe = await chunkIVQL5N55_cjs.createIframe({
291
419
  config
292
420
  });
293
421
  if (!iframe) {
@@ -307,20 +435,62 @@ async function setupClient({
307
435
  return client;
308
436
  }
309
437
 
310
-
311
-
312
-
313
-
314
-
315
-
316
-
317
-
318
-
319
-
320
-
321
-
322
-
323
-
324
-
325
-
326
- exports.ClientNotFound = _chunkNJJQPEELcjs.ClientNotFound; exports.Deferred = _chunkNJJQPEELcjs.Deferred; exports.FrakContextManager = _chunkNJJQPEELcjs.FrakContextManager; exports.FrakRpcError = _chunkNJJQPEELcjs.FrakRpcError; exports.RpcErrorCodes = _chunkNJJQPEELcjs.RpcErrorCodes; exports.baseIframeProps = _chunkNJJQPEELcjs.baseIframeProps; exports.compressJson = _chunkNJJQPEELcjs.compressJson; exports.createIFrameFrakClient = createIFrameFrakClient; exports.createIframe = _chunkNJJQPEELcjs.createIframe; exports.decompressDataAndCheckHash = _chunkNJJQPEELcjs.decompressDataAndCheckHash; exports.decompressJson = _chunkNJJQPEELcjs.decompressJson; exports.hashAndCompressData = _chunkNJJQPEELcjs.hashAndCompressData; exports.interactionTypes = _chunkPR3T7O5Icjs.interactionTypes; exports.productTypes = _chunkPR3T7O5Icjs.productTypes; exports.productTypesMask = _chunkPR3T7O5Icjs.productTypesMask; exports.setupClient = setupClient;
438
+ Object.defineProperty(exports, "ClientNotFound", {
439
+ enumerable: true,
440
+ get: function () { return chunkIVQL5N55_cjs.ClientNotFound; }
441
+ });
442
+ Object.defineProperty(exports, "Deferred", {
443
+ enumerable: true,
444
+ get: function () { return chunkIVQL5N55_cjs.Deferred; }
445
+ });
446
+ Object.defineProperty(exports, "FrakContextManager", {
447
+ enumerable: true,
448
+ get: function () { return chunkIVQL5N55_cjs.FrakContextManager; }
449
+ });
450
+ Object.defineProperty(exports, "FrakRpcError", {
451
+ enumerable: true,
452
+ get: function () { return chunkIVQL5N55_cjs.FrakRpcError; }
453
+ });
454
+ Object.defineProperty(exports, "RpcErrorCodes", {
455
+ enumerable: true,
456
+ get: function () { return chunkIVQL5N55_cjs.RpcErrorCodes; }
457
+ });
458
+ Object.defineProperty(exports, "baseIframeProps", {
459
+ enumerable: true,
460
+ get: function () { return chunkIVQL5N55_cjs.baseIframeProps; }
461
+ });
462
+ Object.defineProperty(exports, "compressJson", {
463
+ enumerable: true,
464
+ get: function () { return chunkIVQL5N55_cjs.compressJson; }
465
+ });
466
+ Object.defineProperty(exports, "createIframe", {
467
+ enumerable: true,
468
+ get: function () { return chunkIVQL5N55_cjs.createIframe; }
469
+ });
470
+ Object.defineProperty(exports, "decompressDataAndCheckHash", {
471
+ enumerable: true,
472
+ get: function () { return chunkIVQL5N55_cjs.decompressDataAndCheckHash; }
473
+ });
474
+ Object.defineProperty(exports, "decompressJson", {
475
+ enumerable: true,
476
+ get: function () { return chunkIVQL5N55_cjs.decompressJson; }
477
+ });
478
+ Object.defineProperty(exports, "hashAndCompressData", {
479
+ enumerable: true,
480
+ get: function () { return chunkIVQL5N55_cjs.hashAndCompressData; }
481
+ });
482
+ Object.defineProperty(exports, "interactionTypes", {
483
+ enumerable: true,
484
+ get: function () { return chunkPO6YSB4Q_cjs.interactionTypes; }
485
+ });
486
+ Object.defineProperty(exports, "productTypes", {
487
+ enumerable: true,
488
+ get: function () { return chunkPO6YSB4Q_cjs.productTypes; }
489
+ });
490
+ Object.defineProperty(exports, "productTypesMask", {
491
+ enumerable: true,
492
+ get: function () { return chunkPO6YSB4Q_cjs.productTypesMask; }
493
+ });
494
+ exports.DebugInfoGatherer = DebugInfoGatherer;
495
+ exports.createIFrameFrakClient = createIFrameFrakClient;
496
+ 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-GkNATUkF.cjs';
2
- export { C as ClientLifecycleEvent, D as DisplayModalParamsType, E as ExtractedParametersFromRpc, w as ExtractedReturnTypeFromRpc, r as FinalActionType, q as FinalModalStepType, G as GetProductInformationReturnType, u as IFrameEvent, v as IFrameLifecycleEvent, t as IFrameRpcEvent, I as IFrameRpcSchema, s as IFrameTransport, L as LoginModalStepType, d as ModalRpcMetadata, e as ModalRpcStepsInput, f as ModalRpcStepsResultType, g as ModalStepMetadata, M as ModalStepTypes, o as OpenInteractionSessionModalStepType, n as OpenInteractionSessionReturnType, O as OpenSsoParamsType, P as ProductTypesKey, R as RpcResponse, l as SendTransactionModalStepType, m as SendTransactionReturnType, k as SendTransactionTxType, h as SiweAuthenticateModalStepType, j as SiweAuthenticateReturnType, i as SiweAuthenticationParams, S as SsoMetadata, W as WalletStatusReturnType, p as productTypes, c as productTypesMask } from './context-GkNATUkF.cjs';
1
+ import { F as FrakWalletSdkConfig, a as FrakClient, I as IFrameEvent, b as FrakContext } from './context-C7RkT8hA.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-C7RkT8hA.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,43 +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
- };
267
- };
268
-
269
- 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 };