@frak-labs/core-sdk 0.0.5 → 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 +7 -7
- package/dist/actions/index.cjs +30 -34
- package/dist/actions/index.d.cts +1 -1
- package/dist/actions/index.d.ts +1 -1
- package/dist/actions/index.js +22 -26
- package/dist/{chunk-PO6YSB4Q.cjs → chunk-665P7NO4.cjs} +0 -3
- package/dist/{chunk-IVQL5N55.cjs → chunk-7YDJDVXY.cjs} +21 -25
- package/dist/{chunk-XDZMP74U.js → chunk-GTBCSNLF.js} +18 -22
- package/dist/{chunk-ZDGHKI3S.cjs → chunk-PHVGCFDX.cjs} +19 -19
- package/dist/{chunk-GDH3M5ZC.js → chunk-U2NTN5QZ.js} +1 -3
- package/dist/{chunk-RMOFMRZR.js → chunk-VE6URIIJ.js} +1 -1
- package/dist/{context-C7RkT8hA.d.cts → context-D7aZDKLT.d.cts} +4 -0
- package/dist/{context-CJ5ByAXa.d.ts → context-rDsQbSgB.d.ts} +4 -0
- package/dist/index.cjs +44 -51
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +12 -20
- package/dist/interactions/index.cjs +6 -6
- package/dist/interactions/index.js +1 -1
- package/package.json +5 -7
package/dist/index.cjs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunk7YDJDVXY_cjs = require('./chunk-7YDJDVXY.cjs');
|
|
4
|
+
var chunk665P7NO4_cjs = require('./chunk-665P7NO4.cjs');
|
|
5
5
|
|
|
6
6
|
// src/utils/constants.ts
|
|
7
7
|
var BACKUP_KEY = "nexus-wallet-backup";
|
|
8
8
|
|
|
9
9
|
// src/clients/DebugInfo.ts
|
|
10
10
|
var DebugInfoGatherer = class _DebugInfoGatherer {
|
|
11
|
+
config;
|
|
12
|
+
iframe;
|
|
13
|
+
isSetupDone = false;
|
|
14
|
+
lastResponse = null;
|
|
15
|
+
lastRequest = null;
|
|
11
16
|
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
17
|
this.config = config;
|
|
18
18
|
this.iframe = iframe;
|
|
19
19
|
this.lastRequest = null;
|
|
@@ -46,14 +46,13 @@ var DebugInfoGatherer = class _DebugInfoGatherer {
|
|
|
46
46
|
* Extract information from the iframe status
|
|
47
47
|
*/
|
|
48
48
|
getIframeStatus() {
|
|
49
|
-
var _a;
|
|
50
49
|
if (!this.iframe) {
|
|
51
50
|
return null;
|
|
52
51
|
}
|
|
53
52
|
return {
|
|
54
53
|
loading: this.iframe.hasAttribute("loading"),
|
|
55
54
|
url: this.iframe.src,
|
|
56
|
-
readyState:
|
|
55
|
+
readyState: this.iframe.contentDocument?.readyState ? this.iframe.contentDocument.readyState === "complete" ? 1 : 0 : -1,
|
|
57
56
|
contentWindow: !!this.iframe.contentWindow,
|
|
58
57
|
isConnected: this.iframe.isConnected
|
|
59
58
|
};
|
|
@@ -75,7 +74,7 @@ var DebugInfoGatherer = class _DebugInfoGatherer {
|
|
|
75
74
|
const iframeStatus = this.getIframeStatus();
|
|
76
75
|
const navigatorInfo = this.getNavigatorInfo();
|
|
77
76
|
let formattedError = "Unknown";
|
|
78
|
-
if (error instanceof
|
|
77
|
+
if (error instanceof chunk7YDJDVXY_cjs.FrakRpcError) {
|
|
79
78
|
formattedError = `FrakRpcError: ${error.code} '${error.message}'`;
|
|
80
79
|
} else if (error instanceof Error) {
|
|
81
80
|
formattedError = error.message;
|
|
@@ -139,9 +138,8 @@ function createIFrameChannelManager() {
|
|
|
139
138
|
function createIFrameLifecycleManager({
|
|
140
139
|
iframe
|
|
141
140
|
}) {
|
|
142
|
-
const isConnectedDeferred = new
|
|
141
|
+
const isConnectedDeferred = new chunk7YDJDVXY_cjs.Deferred();
|
|
143
142
|
const handler = async (messageEvent) => {
|
|
144
|
-
var _a;
|
|
145
143
|
switch (messageEvent.iframeLifecycle) {
|
|
146
144
|
// Resolve the isConnected promise
|
|
147
145
|
case "connected":
|
|
@@ -162,17 +160,14 @@ function createIFrameLifecycleManager({
|
|
|
162
160
|
// Change iframe visibility
|
|
163
161
|
case "show":
|
|
164
162
|
case "hide":
|
|
165
|
-
|
|
163
|
+
chunk7YDJDVXY_cjs.changeIframeVisibility({
|
|
166
164
|
iframe,
|
|
167
165
|
isVisible: messageEvent.iframeLifecycle === "show"
|
|
168
166
|
});
|
|
169
167
|
break;
|
|
170
168
|
// Handshake handling
|
|
171
169
|
case "handshake": {
|
|
172
|
-
|
|
173
|
-
token: messageEvent.data.token
|
|
174
|
-
});
|
|
175
|
-
(_a = iframe.contentWindow) == null ? undefined : _a.postMessage(
|
|
170
|
+
iframe.contentWindow?.postMessage(
|
|
176
171
|
{
|
|
177
172
|
clientLifecycle: "handshake-response",
|
|
178
173
|
data: {
|
|
@@ -201,14 +196,14 @@ function createIFrameMessageHandler({
|
|
|
201
196
|
debugInfo
|
|
202
197
|
}) {
|
|
203
198
|
if (typeof window === "undefined") {
|
|
204
|
-
throw new
|
|
205
|
-
|
|
199
|
+
throw new chunk7YDJDVXY_cjs.FrakRpcError(
|
|
200
|
+
chunk7YDJDVXY_cjs.RpcErrorCodes.configError,
|
|
206
201
|
"iframe client should be used in the browser"
|
|
207
202
|
);
|
|
208
203
|
}
|
|
209
204
|
if (!iframe.contentWindow) {
|
|
210
|
-
throw new
|
|
211
|
-
|
|
205
|
+
throw new chunk7YDJDVXY_cjs.FrakRpcError(
|
|
206
|
+
chunk7YDJDVXY_cjs.RpcErrorCodes.configError,
|
|
212
207
|
"The iframe does not have a product window"
|
|
213
208
|
);
|
|
214
209
|
}
|
|
@@ -267,12 +262,11 @@ function createIFrameFrakClient({
|
|
|
267
262
|
config,
|
|
268
263
|
iframe
|
|
269
264
|
}) {
|
|
270
|
-
var _a;
|
|
271
265
|
const channelManager = createIFrameChannelManager();
|
|
272
266
|
const lifecycleManager = createIFrameLifecycleManager({ iframe });
|
|
273
267
|
const debugInfo = new DebugInfoGatherer(config, iframe);
|
|
274
268
|
const messageHandler = createIFrameMessageHandler({
|
|
275
|
-
frakWalletUrl:
|
|
269
|
+
frakWalletUrl: config?.walletUrl ?? "https://wallet.frak.id",
|
|
276
270
|
iframe,
|
|
277
271
|
channelManager,
|
|
278
272
|
iframeLifecycleManager: lifecycleManager,
|
|
@@ -281,21 +275,20 @@ function createIFrameFrakClient({
|
|
|
281
275
|
const request = async (args) => {
|
|
282
276
|
const isConnected = await lifecycleManager.isConnected;
|
|
283
277
|
if (!isConnected) {
|
|
284
|
-
throw new
|
|
285
|
-
|
|
278
|
+
throw new chunk7YDJDVXY_cjs.FrakRpcError(
|
|
279
|
+
chunk7YDJDVXY_cjs.RpcErrorCodes.clientNotConnected,
|
|
286
280
|
"The iframe provider isn't connected yet"
|
|
287
281
|
);
|
|
288
282
|
}
|
|
289
|
-
const result = new
|
|
283
|
+
const result = new chunk7YDJDVXY_cjs.Deferred();
|
|
290
284
|
const channelId = channelManager.createChannel(async (message) => {
|
|
291
|
-
|
|
292
|
-
const decompressed = await chunkIVQL5N55_cjs.decompressDataAndCheckHash(message.data);
|
|
285
|
+
const decompressed = await chunk7YDJDVXY_cjs.decompressDataAndCheckHash(message.data);
|
|
293
286
|
if (decompressed.error) {
|
|
294
287
|
result.reject(
|
|
295
|
-
new
|
|
288
|
+
new chunk7YDJDVXY_cjs.FrakRpcError(
|
|
296
289
|
decompressed.error.code,
|
|
297
290
|
decompressed.error.message,
|
|
298
|
-
|
|
291
|
+
decompressed.error?.data
|
|
299
292
|
)
|
|
300
293
|
);
|
|
301
294
|
} else {
|
|
@@ -303,7 +296,7 @@ function createIFrameFrakClient({
|
|
|
303
296
|
}
|
|
304
297
|
channelManager.removeChannel(channelId);
|
|
305
298
|
});
|
|
306
|
-
const compressedMessage = await
|
|
299
|
+
const compressedMessage = await chunk7YDJDVXY_cjs.hashAndCompressData(args);
|
|
307
300
|
messageHandler.sendEvent({
|
|
308
301
|
id: channelId,
|
|
309
302
|
topic: args.method,
|
|
@@ -314,20 +307,20 @@ function createIFrameFrakClient({
|
|
|
314
307
|
const listenerRequest = async (args, callback) => {
|
|
315
308
|
const isConnected = await lifecycleManager.isConnected;
|
|
316
309
|
if (!isConnected) {
|
|
317
|
-
throw new
|
|
318
|
-
|
|
310
|
+
throw new chunk7YDJDVXY_cjs.FrakRpcError(
|
|
311
|
+
chunk7YDJDVXY_cjs.RpcErrorCodes.clientNotConnected,
|
|
319
312
|
"The iframe provider isn't connected yet"
|
|
320
313
|
);
|
|
321
314
|
}
|
|
322
315
|
const channelId = channelManager.createChannel(async (message) => {
|
|
323
|
-
const decompressed = await
|
|
316
|
+
const decompressed = await chunk7YDJDVXY_cjs.decompressDataAndCheckHash(message.data);
|
|
324
317
|
if (decompressed.result) {
|
|
325
318
|
callback(decompressed.result);
|
|
326
319
|
} else {
|
|
327
|
-
throw new
|
|
320
|
+
throw new chunk7YDJDVXY_cjs.InternalError("No valid result in the response");
|
|
328
321
|
}
|
|
329
322
|
});
|
|
330
|
-
const compressedMessage = await
|
|
323
|
+
const compressedMessage = await chunk7YDJDVXY_cjs.hashAndCompressData(args);
|
|
331
324
|
messageHandler.sendEvent({
|
|
332
325
|
id: channelId,
|
|
333
326
|
topic: args.method,
|
|
@@ -415,7 +408,7 @@ async function postConnectionSetup({
|
|
|
415
408
|
async function setupClient({
|
|
416
409
|
config
|
|
417
410
|
}) {
|
|
418
|
-
const iframe = await
|
|
411
|
+
const iframe = await chunk7YDJDVXY_cjs.createIframe({
|
|
419
412
|
config
|
|
420
413
|
});
|
|
421
414
|
if (!iframe) {
|
|
@@ -437,59 +430,59 @@ async function setupClient({
|
|
|
437
430
|
|
|
438
431
|
Object.defineProperty(exports, "ClientNotFound", {
|
|
439
432
|
enumerable: true,
|
|
440
|
-
get: function () { return
|
|
433
|
+
get: function () { return chunk7YDJDVXY_cjs.ClientNotFound; }
|
|
441
434
|
});
|
|
442
435
|
Object.defineProperty(exports, "Deferred", {
|
|
443
436
|
enumerable: true,
|
|
444
|
-
get: function () { return
|
|
437
|
+
get: function () { return chunk7YDJDVXY_cjs.Deferred; }
|
|
445
438
|
});
|
|
446
439
|
Object.defineProperty(exports, "FrakContextManager", {
|
|
447
440
|
enumerable: true,
|
|
448
|
-
get: function () { return
|
|
441
|
+
get: function () { return chunk7YDJDVXY_cjs.FrakContextManager; }
|
|
449
442
|
});
|
|
450
443
|
Object.defineProperty(exports, "FrakRpcError", {
|
|
451
444
|
enumerable: true,
|
|
452
|
-
get: function () { return
|
|
445
|
+
get: function () { return chunk7YDJDVXY_cjs.FrakRpcError; }
|
|
453
446
|
});
|
|
454
447
|
Object.defineProperty(exports, "RpcErrorCodes", {
|
|
455
448
|
enumerable: true,
|
|
456
|
-
get: function () { return
|
|
449
|
+
get: function () { return chunk7YDJDVXY_cjs.RpcErrorCodes; }
|
|
457
450
|
});
|
|
458
451
|
Object.defineProperty(exports, "baseIframeProps", {
|
|
459
452
|
enumerable: true,
|
|
460
|
-
get: function () { return
|
|
453
|
+
get: function () { return chunk7YDJDVXY_cjs.baseIframeProps; }
|
|
461
454
|
});
|
|
462
455
|
Object.defineProperty(exports, "compressJson", {
|
|
463
456
|
enumerable: true,
|
|
464
|
-
get: function () { return
|
|
457
|
+
get: function () { return chunk7YDJDVXY_cjs.compressJson; }
|
|
465
458
|
});
|
|
466
459
|
Object.defineProperty(exports, "createIframe", {
|
|
467
460
|
enumerable: true,
|
|
468
|
-
get: function () { return
|
|
461
|
+
get: function () { return chunk7YDJDVXY_cjs.createIframe; }
|
|
469
462
|
});
|
|
470
463
|
Object.defineProperty(exports, "decompressDataAndCheckHash", {
|
|
471
464
|
enumerable: true,
|
|
472
|
-
get: function () { return
|
|
465
|
+
get: function () { return chunk7YDJDVXY_cjs.decompressDataAndCheckHash; }
|
|
473
466
|
});
|
|
474
467
|
Object.defineProperty(exports, "decompressJson", {
|
|
475
468
|
enumerable: true,
|
|
476
|
-
get: function () { return
|
|
469
|
+
get: function () { return chunk7YDJDVXY_cjs.decompressJson; }
|
|
477
470
|
});
|
|
478
471
|
Object.defineProperty(exports, "hashAndCompressData", {
|
|
479
472
|
enumerable: true,
|
|
480
|
-
get: function () { return
|
|
473
|
+
get: function () { return chunk7YDJDVXY_cjs.hashAndCompressData; }
|
|
481
474
|
});
|
|
482
475
|
Object.defineProperty(exports, "interactionTypes", {
|
|
483
476
|
enumerable: true,
|
|
484
|
-
get: function () { return
|
|
477
|
+
get: function () { return chunk665P7NO4_cjs.interactionTypes; }
|
|
485
478
|
});
|
|
486
479
|
Object.defineProperty(exports, "productTypes", {
|
|
487
480
|
enumerable: true,
|
|
488
|
-
get: function () { return
|
|
481
|
+
get: function () { return chunk665P7NO4_cjs.productTypes; }
|
|
489
482
|
});
|
|
490
483
|
Object.defineProperty(exports, "productTypesMask", {
|
|
491
484
|
enumerable: true,
|
|
492
|
-
get: function () { return
|
|
485
|
+
get: function () { return chunk665P7NO4_cjs.productTypesMask; }
|
|
493
486
|
});
|
|
494
487
|
exports.DebugInfoGatherer = DebugInfoGatherer;
|
|
495
488
|
exports.createIFrameFrakClient = createIFrameFrakClient;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as FrakWalletSdkConfig, a as FrakClient, I as IFrameEvent, b as FrakContext } from './context-
|
|
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-
|
|
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';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as FrakWalletSdkConfig, a as FrakClient, I as IFrameEvent, b as FrakContext } from './context-
|
|
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-
|
|
1
|
+
import { F as FrakWalletSdkConfig, a as FrakClient, I as IFrameEvent, b as FrakContext } from './context-rDsQbSgB.js';
|
|
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-rDsQbSgB.js';
|
|
3
3
|
export { P as PreparedInteraction, S as SendInteractionParamsType, a as SendInteractionReturnType } from './interaction-CTQ5-kqe.js';
|
|
4
4
|
import 'viem';
|
|
5
5
|
import 'viem/chains';
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import { createIframe, FrakRpcError,
|
|
2
|
-
export { ClientNotFound, Deferred, FrakContextManager, FrakRpcError, RpcErrorCodes, baseIframeProps, compressJson, createIframe, decompressDataAndCheckHash, decompressJson, hashAndCompressData } from './chunk-
|
|
3
|
-
|
|
4
|
-
export { interactionTypes, productTypes, productTypesMask } from './chunk-GDH3M5ZC.js';
|
|
1
|
+
import { createIframe, FrakRpcError, RpcErrorCodes, Deferred, decompressDataAndCheckHash, hashAndCompressData, InternalError, changeIframeVisibility } from './chunk-GTBCSNLF.js';
|
|
2
|
+
export { ClientNotFound, Deferred, FrakContextManager, FrakRpcError, RpcErrorCodes, baseIframeProps, compressJson, createIframe, decompressDataAndCheckHash, decompressJson, hashAndCompressData } from './chunk-GTBCSNLF.js';
|
|
3
|
+
export { interactionTypes, productTypes, productTypesMask } from './chunk-U2NTN5QZ.js';
|
|
5
4
|
|
|
6
5
|
// src/utils/constants.ts
|
|
7
6
|
var BACKUP_KEY = "nexus-wallet-backup";
|
|
8
7
|
|
|
9
8
|
// src/clients/DebugInfo.ts
|
|
10
9
|
var DebugInfoGatherer = class _DebugInfoGatherer {
|
|
10
|
+
config;
|
|
11
|
+
iframe;
|
|
12
|
+
isSetupDone = false;
|
|
13
|
+
lastResponse = null;
|
|
14
|
+
lastRequest = null;
|
|
11
15
|
constructor(config, iframe) {
|
|
12
|
-
__publicField(this, "config");
|
|
13
|
-
__publicField(this, "iframe");
|
|
14
|
-
__publicField(this, "isSetupDone", false);
|
|
15
|
-
__publicField(this, "lastResponse", null);
|
|
16
|
-
__publicField(this, "lastRequest", null);
|
|
17
16
|
this.config = config;
|
|
18
17
|
this.iframe = iframe;
|
|
19
18
|
this.lastRequest = null;
|
|
@@ -46,14 +45,13 @@ var DebugInfoGatherer = class _DebugInfoGatherer {
|
|
|
46
45
|
* Extract information from the iframe status
|
|
47
46
|
*/
|
|
48
47
|
getIframeStatus() {
|
|
49
|
-
var _a;
|
|
50
48
|
if (!this.iframe) {
|
|
51
49
|
return null;
|
|
52
50
|
}
|
|
53
51
|
return {
|
|
54
52
|
loading: this.iframe.hasAttribute("loading"),
|
|
55
53
|
url: this.iframe.src,
|
|
56
|
-
readyState:
|
|
54
|
+
readyState: this.iframe.contentDocument?.readyState ? this.iframe.contentDocument.readyState === "complete" ? 1 : 0 : -1,
|
|
57
55
|
contentWindow: !!this.iframe.contentWindow,
|
|
58
56
|
isConnected: this.iframe.isConnected
|
|
59
57
|
};
|
|
@@ -141,7 +139,6 @@ function createIFrameLifecycleManager({
|
|
|
141
139
|
}) {
|
|
142
140
|
const isConnectedDeferred = new Deferred();
|
|
143
141
|
const handler = async (messageEvent) => {
|
|
144
|
-
var _a;
|
|
145
142
|
switch (messageEvent.iframeLifecycle) {
|
|
146
143
|
// Resolve the isConnected promise
|
|
147
144
|
case "connected":
|
|
@@ -169,10 +166,7 @@ function createIFrameLifecycleManager({
|
|
|
169
166
|
break;
|
|
170
167
|
// Handshake handling
|
|
171
168
|
case "handshake": {
|
|
172
|
-
|
|
173
|
-
token: messageEvent.data.token
|
|
174
|
-
});
|
|
175
|
-
(_a = iframe.contentWindow) == null ? undefined : _a.postMessage(
|
|
169
|
+
iframe.contentWindow?.postMessage(
|
|
176
170
|
{
|
|
177
171
|
clientLifecycle: "handshake-response",
|
|
178
172
|
data: {
|
|
@@ -267,12 +261,11 @@ function createIFrameFrakClient({
|
|
|
267
261
|
config,
|
|
268
262
|
iframe
|
|
269
263
|
}) {
|
|
270
|
-
var _a;
|
|
271
264
|
const channelManager = createIFrameChannelManager();
|
|
272
265
|
const lifecycleManager = createIFrameLifecycleManager({ iframe });
|
|
273
266
|
const debugInfo = new DebugInfoGatherer(config, iframe);
|
|
274
267
|
const messageHandler = createIFrameMessageHandler({
|
|
275
|
-
frakWalletUrl:
|
|
268
|
+
frakWalletUrl: config?.walletUrl ?? "https://wallet.frak.id",
|
|
276
269
|
iframe,
|
|
277
270
|
channelManager,
|
|
278
271
|
iframeLifecycleManager: lifecycleManager,
|
|
@@ -288,14 +281,13 @@ function createIFrameFrakClient({
|
|
|
288
281
|
}
|
|
289
282
|
const result = new Deferred();
|
|
290
283
|
const channelId = channelManager.createChannel(async (message) => {
|
|
291
|
-
var _a2;
|
|
292
284
|
const decompressed = await decompressDataAndCheckHash(message.data);
|
|
293
285
|
if (decompressed.error) {
|
|
294
286
|
result.reject(
|
|
295
287
|
new FrakRpcError(
|
|
296
288
|
decompressed.error.code,
|
|
297
289
|
decompressed.error.message,
|
|
298
|
-
|
|
290
|
+
decompressed.error?.data
|
|
299
291
|
)
|
|
300
292
|
);
|
|
301
293
|
} else {
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkPHVGCFDX_cjs = require('../chunk-PHVGCFDX.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "PressInteractionEncoder", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunkPHVGCFDX_cjs.PressInteractionEncoder; }
|
|
10
10
|
});
|
|
11
11
|
Object.defineProperty(exports, "PurchaseInteractionEncoder", {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunkPHVGCFDX_cjs.PurchaseInteractionEncoder; }
|
|
14
14
|
});
|
|
15
15
|
Object.defineProperty(exports, "ReferralInteractionEncoder", {
|
|
16
16
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
17
|
+
get: function () { return chunkPHVGCFDX_cjs.ReferralInteractionEncoder; }
|
|
18
18
|
});
|
|
19
19
|
Object.defineProperty(exports, "RetailInteractionEncoder", {
|
|
20
20
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
21
|
+
get: function () { return chunkPHVGCFDX_cjs.RetailInteractionEncoder; }
|
|
22
22
|
});
|
|
23
23
|
Object.defineProperty(exports, "WebShopInteractionEncoder", {
|
|
24
24
|
enumerable: true,
|
|
25
|
-
get: function () { return
|
|
25
|
+
get: function () { return chunkPHVGCFDX_cjs.WebShopInteractionEncoder; }
|
|
26
26
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { PressInteractionEncoder, PurchaseInteractionEncoder, ReferralInteractionEncoder, RetailInteractionEncoder, WebShopInteractionEncoder } from '../chunk-
|
|
1
|
+
export { PressInteractionEncoder, PurchaseInteractionEncoder, ReferralInteractionEncoder, RetailInteractionEncoder, WebShopInteractionEncoder } from '../chunk-VE6URIIJ.js';
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"url": "https://twitter.com/QNivelais"
|
|
12
12
|
}
|
|
13
13
|
],
|
|
14
|
-
"version": "0.0.
|
|
14
|
+
"version": "0.0.6",
|
|
15
15
|
"description": "Core SDK of the Frak wallet, low level library to interact directly with the frak ecosystem.",
|
|
16
16
|
"repository": {
|
|
17
17
|
"url": "https://github.com/frak-id/wallet",
|
|
@@ -91,14 +91,12 @@
|
|
|
91
91
|
"devDependencies": {
|
|
92
92
|
"@arethetypeswrong/cli": "^0.17.3",
|
|
93
93
|
"@types/node": "^22",
|
|
94
|
-
"
|
|
94
|
+
"browserslist": "^4.24.4",
|
|
95
|
+
"browserslist-to-esbuild": "^2.1.1",
|
|
96
|
+
"tsup": "^8.3.6",
|
|
95
97
|
"typescript": "^5"
|
|
96
98
|
},
|
|
97
99
|
"browserslist": [
|
|
98
|
-
"
|
|
99
|
-
"edge 79",
|
|
100
|
-
"firefox 68",
|
|
101
|
-
"opera 54",
|
|
102
|
-
"safari 14"
|
|
100
|
+
"extends @frak-labs/browserslist-config"
|
|
103
101
|
]
|
|
104
102
|
}
|