@frak-labs/nexus-sdk 0.0.22 → 0.0.24

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.
Files changed (31) hide show
  1. package/dist/{FrakContext-DBdWC7ls.d.cts → FrakContext-DKSVaeVb.d.cts} +62 -3
  2. package/dist/{FrakContext-CDVlUN75.d.ts → FrakContext-DjeuWC2U.d.ts} +62 -3
  3. package/dist/bundle/bundle.js +5 -5
  4. package/dist/{chunk-ZQSA2VQ4.js → chunk-2VNIEGOJ.js} +10 -6
  5. package/dist/{chunk-Q3SIIAX2.js → chunk-4MMSQL44.js} +147 -28
  6. package/dist/{chunk-4OJ2NPAS.cjs → chunk-4PVF24BB.cjs} +15 -15
  7. package/dist/{chunk-H3T2GAEC.js → chunk-BOGCLEPR.js} +2 -1
  8. package/dist/chunk-DE2KWQVP.cjs +351 -0
  9. package/dist/{chunk-P4QEVLVV.js → chunk-FETGS7X7.js} +1 -1
  10. package/dist/{chunk-F3F4BCGV.cjs → chunk-H4BK3CNV.cjs} +20 -16
  11. package/dist/{chunk-QSXZKZJA.cjs → chunk-P3J2BIUT.cjs} +2 -1
  12. package/dist/{chunk-QYOOKB34.cjs → chunk-QLM5NFMZ.cjs} +22 -22
  13. package/dist/{chunk-VVF4NKYR.js → chunk-YPQA63LW.js} +2 -2
  14. package/dist/core/actions/index.cjs +9 -5
  15. package/dist/core/actions/index.d.cts +51 -6
  16. package/dist/core/actions/index.d.ts +51 -6
  17. package/dist/core/actions/index.js +10 -6
  18. package/dist/core/index.cjs +4 -4
  19. package/dist/core/index.d.cts +13 -25
  20. package/dist/core/index.d.ts +13 -25
  21. package/dist/core/index.js +3 -3
  22. package/dist/core/interactions/index.cjs +3 -3
  23. package/dist/core/interactions/index.js +2 -2
  24. package/dist/{processReferral-CFyGAENf.d.ts → processReferral-CJI_Rc4K.d.ts} +1 -1
  25. package/dist/{processReferral-BWSIamn2.d.cts → processReferral-DUP8imQV.d.cts} +1 -1
  26. package/dist/react/index.cjs +52 -31
  27. package/dist/react/index.d.cts +20 -13
  28. package/dist/react/index.d.ts +20 -13
  29. package/dist/react/index.js +32 -11
  30. package/package.json +42 -19
  31. package/dist/chunk-4CWA7EWX.cjs +0 -232
@@ -0,0 +1,351 @@
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; }
2
+
3
+
4
+
5
+
6
+ var _chunkH4BK3CNVcjs = require('./chunk-H4BK3CNV.cjs');
7
+
8
+
9
+ var _chunk4PVF24BBcjs = require('./chunk-4PVF24BB.cjs');
10
+
11
+ // src/core/actions/watchWalletStatus.ts
12
+ function watchWalletStatus(client, callback) {
13
+ if (!callback) {
14
+ return client.request({ method: "frak_listenToWalletStatus" }).then((result) => {
15
+ savePotentialToken(result.interactionToken);
16
+ return result;
17
+ });
18
+ }
19
+ const firstResult = new (0, _chunkH4BK3CNVcjs.Deferred)();
20
+ let hasResolved = false;
21
+ return client.listenerRequest(
22
+ {
23
+ method: "frak_listenToWalletStatus"
24
+ },
25
+ (status) => {
26
+ callback(status);
27
+ savePotentialToken(status.interactionToken);
28
+ if (!hasResolved) {
29
+ firstResult.resolve(status);
30
+ hasResolved = true;
31
+ }
32
+ }
33
+ ).then(() => firstResult.promise);
34
+ }
35
+ function savePotentialToken(interactionToken) {
36
+ if (typeof window === "undefined") {
37
+ return;
38
+ }
39
+ if (interactionToken) {
40
+ window.sessionStorage.setItem(
41
+ "frak-wallet-interaction-token",
42
+ interactionToken
43
+ );
44
+ } else {
45
+ window.sessionStorage.removeItem("frak.interaction-token");
46
+ }
47
+ }
48
+
49
+ // src/core/utils/computeProductId.ts
50
+ var _viem = require('viem');
51
+ function computeProductId({ domain }) {
52
+ const effectiveDomain = _nullishCoalesce(domain, () => ( window.location.host));
53
+ return _viem.keccak256.call(void 0, _viem.toHex.call(void 0, effectiveDomain));
54
+ }
55
+
56
+ // src/core/actions/sendInteraction.ts
57
+ async function sendInteraction(client, { productId, interaction, validation }) {
58
+ const pId = _nullishCoalesce(productId, () => ( computeProductId(client.config)));
59
+ return await client.request({
60
+ method: "frak_sendInteraction",
61
+ params: [pId, interaction, validation]
62
+ });
63
+ }
64
+
65
+ // src/core/actions/displayModal.ts
66
+ async function displayModal(client, { steps, metadata }) {
67
+ return await client.request({
68
+ method: "frak_displayModal",
69
+ params: [steps, client.config.metadata.name, metadata]
70
+ });
71
+ }
72
+
73
+ // src/core/actions/openSso.ts
74
+ async function openSso(client, args) {
75
+ const { metadata } = client.config;
76
+ await client.request({
77
+ method: "frak_sso",
78
+ params: [args, metadata.name, metadata.css]
79
+ });
80
+ }
81
+
82
+ // src/core/actions/getProductInformation.ts
83
+ async function getProductInformation(client) {
84
+ return await client.request({
85
+ method: "frak_getProductInformation"
86
+ });
87
+ }
88
+
89
+ // src/core/actions/trackPurchaseStatus.ts
90
+ async function trackPurchaseStatus(args) {
91
+ if (typeof window === "undefined") {
92
+ console.warn("[Frak] No window found, can't track purchase");
93
+ return;
94
+ }
95
+ const interactionToken = window.sessionStorage.getItem(
96
+ "frak-wallet-interaction-token"
97
+ );
98
+ if (!interactionToken) {
99
+ console.warn("[Frak] No frak session found, skipping purchase check");
100
+ return;
101
+ }
102
+ await fetch("https://backend.frak.id/interactions/listenForPurchase", {
103
+ method: "POST",
104
+ headers: {
105
+ Accept: "application/json",
106
+ "Content-Type": "application/json",
107
+ "x-wallet-sdk-auth": interactionToken
108
+ },
109
+ body: JSON.stringify(args)
110
+ });
111
+ }
112
+
113
+ // src/core/actions/wrapper/siweAuthenticate.ts
114
+ var _siwe = require('viem/siwe');
115
+ async function siweAuthenticate(client, { siwe, metadata }) {
116
+ const effectiveDomain = _nullishCoalesce(_optionalChain([client, 'access', _ => _.config, 'optionalAccess', _2 => _2.domain]), () => ( window.location.host));
117
+ const realStatement = _nullishCoalesce(_optionalChain([siwe, 'optionalAccess', _3 => _3.statement]), () => ( `I confirm that I want to use my Frak wallet on: ${client.config.metadata.name}`));
118
+ const builtSiwe = {
119
+ ...siwe,
120
+ statement: realStatement,
121
+ nonce: _nullishCoalesce(_optionalChain([siwe, 'optionalAccess', _4 => _4.nonce]), () => ( _siwe.generateSiweNonce.call(void 0, ))),
122
+ uri: _nullishCoalesce(_optionalChain([siwe, 'optionalAccess', _5 => _5.uri]), () => ( `https://${effectiveDomain}`)),
123
+ version: _nullishCoalesce(_optionalChain([siwe, 'optionalAccess', _6 => _6.version]), () => ( "1")),
124
+ domain: effectiveDomain
125
+ };
126
+ const result = await displayModal(client, {
127
+ metadata,
128
+ steps: {
129
+ login: {},
130
+ siweAuthenticate: {
131
+ siwe: builtSiwe
132
+ }
133
+ }
134
+ });
135
+ return result.siweAuthenticate;
136
+ }
137
+
138
+ // src/core/actions/wrapper/sendTransaction.ts
139
+ async function sendTransaction(client, { tx, metadata }) {
140
+ const result = await displayModal(client, {
141
+ metadata,
142
+ steps: {
143
+ login: {},
144
+ sendTransaction: { tx }
145
+ }
146
+ });
147
+ return result.sendTransaction;
148
+ }
149
+
150
+ // src/core/actions/wrapper/modalBuilder.ts
151
+ function modalBuilder(client, {
152
+ metadata,
153
+ login,
154
+ openSession
155
+ }) {
156
+ const baseParams = {
157
+ steps: {
158
+ login: _nullishCoalesce(login, () => ( {})),
159
+ openSession: _nullishCoalesce(openSession, () => ( {}))
160
+ },
161
+ metadata
162
+ };
163
+ return modalStepsBuilder(client, baseParams);
164
+ }
165
+ function modalStepsBuilder(client, params) {
166
+ function sendTx(options) {
167
+ return modalStepsBuilder(client, {
168
+ ...params,
169
+ steps: {
170
+ ...params.steps,
171
+ sendTransaction: options
172
+ }
173
+ });
174
+ }
175
+ function reward(options) {
176
+ return modalStepsBuilder(
177
+ client,
178
+ {
179
+ ...params,
180
+ steps: {
181
+ ...params.steps,
182
+ final: {
183
+ ...options,
184
+ action: { key: "reward" }
185
+ }
186
+ }
187
+ }
188
+ );
189
+ }
190
+ function sharing(sharingOptions, options) {
191
+ return modalStepsBuilder(
192
+ client,
193
+ {
194
+ ...params,
195
+ steps: {
196
+ ...params.steps,
197
+ final: {
198
+ ...options,
199
+ action: { key: "sharing", options: sharingOptions }
200
+ }
201
+ }
202
+ }
203
+ );
204
+ }
205
+ async function display() {
206
+ return await displayModal(client, params);
207
+ }
208
+ return {
209
+ // Access current modal params
210
+ params,
211
+ // Function to add new steps
212
+ sendTx,
213
+ reward,
214
+ sharing,
215
+ // Display the modal
216
+ display
217
+ };
218
+ }
219
+
220
+ // src/core/actions/referral/processReferral.ts
221
+
222
+ async function processReferral(client, {
223
+ walletStatus,
224
+ frakContext,
225
+ modalConfig,
226
+ productId,
227
+ options
228
+ }) {
229
+ let walletRequest = false;
230
+ async function getFreshWalletStatus() {
231
+ if (walletRequest) {
232
+ return;
233
+ }
234
+ walletRequest = true;
235
+ return ensureWalletConnected(client, {
236
+ modalConfig,
237
+ walletStatus
238
+ });
239
+ }
240
+ async function pushReferralInteraction(referrer) {
241
+ const interaction = _chunk4PVF24BBcjs.ReferralInteractionEncoder.referred({
242
+ referrer
243
+ });
244
+ await sendInteraction(client, { productId, interaction });
245
+ }
246
+ try {
247
+ const { status, currentWallet } = await processReferralLogic({
248
+ initialWalletStatus: walletStatus,
249
+ getFreshWalletStatus,
250
+ pushReferralInteraction,
251
+ frakContext
252
+ });
253
+ _chunkH4BK3CNVcjs.FrakContextManager.replaceUrl({
254
+ url: _optionalChain([window, 'access', _7 => _7.location, 'optionalAccess', _8 => _8.href]),
255
+ context: _optionalChain([options, 'optionalAccess', _9 => _9.alwaysAppendUrl]) ? { r: currentWallet } : null
256
+ });
257
+ return status;
258
+ } catch (error) {
259
+ console.log("Error processing referral", { error });
260
+ _chunkH4BK3CNVcjs.FrakContextManager.replaceUrl({
261
+ url: _optionalChain([window, 'access', _10 => _10.location, 'optionalAccess', _11 => _11.href]),
262
+ context: _optionalChain([options, 'optionalAccess', _12 => _12.alwaysAppendUrl]) ? { r: _optionalChain([walletStatus, 'optionalAccess', _13 => _13.wallet]) } : null
263
+ });
264
+ return mapErrorToState(error);
265
+ }
266
+ }
267
+ async function processReferralLogic({
268
+ initialWalletStatus,
269
+ getFreshWalletStatus,
270
+ pushReferralInteraction,
271
+ frakContext
272
+ }) {
273
+ let currentWallet = _optionalChain([initialWalletStatus, 'optionalAccess', _14 => _14.wallet]);
274
+ if (!_optionalChain([frakContext, 'optionalAccess', _15 => _15.r])) {
275
+ return { status: "no-referrer", currentWallet };
276
+ }
277
+ if (!currentWallet) {
278
+ currentWallet = await getFreshWalletStatus();
279
+ }
280
+ if (currentWallet && _viem.isAddressEqual.call(void 0, frakContext.r, currentWallet)) {
281
+ return { status: "self-referral", currentWallet };
282
+ }
283
+ if (!_optionalChain([initialWalletStatus, 'optionalAccess', _16 => _16.interactionSession])) {
284
+ currentWallet = await getFreshWalletStatus();
285
+ }
286
+ await pushReferralInteraction(frakContext.r);
287
+ return { status: "success", currentWallet };
288
+ }
289
+ async function ensureWalletConnected(client, {
290
+ modalConfig,
291
+ walletStatus
292
+ }) {
293
+ if (!_optionalChain([walletStatus, 'optionalAccess', _17 => _17.interactionSession])) {
294
+ if (!modalConfig) {
295
+ return void 0;
296
+ }
297
+ const result = await displayModal(client, modalConfig);
298
+ return _nullishCoalesce(_optionalChain([result, 'optionalAccess', _18 => _18.login, 'optionalAccess', _19 => _19.wallet]), () => ( void 0));
299
+ }
300
+ return _nullishCoalesce(walletStatus.wallet, () => ( void 0));
301
+ }
302
+ function mapErrorToState(error) {
303
+ if (error instanceof _chunkH4BK3CNVcjs.FrakRpcError) {
304
+ switch (error.code) {
305
+ case _chunkH4BK3CNVcjs.RpcErrorCodes.walletNotConnected:
306
+ return "no-wallet";
307
+ case _chunkH4BK3CNVcjs.RpcErrorCodes.serverErrorForInteractionDelegation:
308
+ return "no-session";
309
+ default:
310
+ return "error";
311
+ }
312
+ }
313
+ return "error";
314
+ }
315
+
316
+ // src/core/actions/referral/referralInteraction.ts
317
+ async function referralInteraction(client, {
318
+ productId,
319
+ modalConfig,
320
+ options
321
+ } = {}) {
322
+ const frakContext = _chunkH4BK3CNVcjs.FrakContextManager.parse({
323
+ url: window.location.href
324
+ });
325
+ const currentWalletStatus = await watchWalletStatus(client);
326
+ try {
327
+ return await processReferral(client, {
328
+ walletStatus: currentWalletStatus,
329
+ frakContext,
330
+ modalConfig,
331
+ productId,
332
+ options
333
+ });
334
+ } catch (error) {
335
+ return error;
336
+ }
337
+ }
338
+
339
+
340
+
341
+
342
+
343
+
344
+
345
+
346
+
347
+
348
+
349
+
350
+
351
+ exports.watchWalletStatus = watchWalletStatus; exports.sendInteraction = sendInteraction; exports.displayModal = displayModal; exports.openSso = openSso; exports.getProductInformation = getProductInformation; exports.trackPurchaseStatus = trackPurchaseStatus; exports.siweAuthenticate = siweAuthenticate; exports.sendTransaction = sendTransaction; exports.modalBuilder = modalBuilder; exports.processReferral = processReferral; exports.referralInteraction = referralInteraction;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  interactionTypes,
3
3
  productTypes
4
- } from "./chunk-H3T2GAEC.js";
4
+ } from "./chunk-BOGCLEPR.js";
5
5
 
6
6
  // src/core/interactions/pressEncoder.ts
7
7
  import { concatHex, pad, toHex } from "viem";
@@ -2,10 +2,10 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkQSXZKZJAcjs = require('./chunk-QSXZKZJA.cjs');
5
+ var _chunkP3J2BIUTcjs = require('./chunk-P3J2BIUT.cjs');
6
6
 
7
7
  // ../../node_modules/async-lz-string/libs/async-lz-string.js
8
- var require_async_lz_string = _chunkQSXZKZJAcjs.__commonJS.call(void 0, {
8
+ var require_async_lz_string = _chunkP3J2BIUTcjs.__commonJS.call(void 0, {
9
9
  "../../node_modules/async-lz-string/libs/async-lz-string.js"(exports, module) {
10
10
  "use strict";
11
11
  !function(t, e) {
@@ -587,13 +587,13 @@ var RpcErrorCodes = {
587
587
  // src/core/utils/Deferred.ts
588
588
  var Deferred = class {
589
589
  constructor() {
590
- _chunkQSXZKZJAcjs.__publicField.call(void 0, this, "_promise");
591
- _chunkQSXZKZJAcjs.__publicField.call(void 0, this, "_resolve");
592
- _chunkQSXZKZJAcjs.__publicField.call(void 0, this, "_reject");
593
- _chunkQSXZKZJAcjs.__publicField.call(void 0, this, "resolve", (value) => {
590
+ _chunkP3J2BIUTcjs.__publicField.call(void 0, this, "_promise");
591
+ _chunkP3J2BIUTcjs.__publicField.call(void 0, this, "_resolve");
592
+ _chunkP3J2BIUTcjs.__publicField.call(void 0, this, "_reject");
593
+ _chunkP3J2BIUTcjs.__publicField.call(void 0, this, "resolve", (value) => {
594
594
  _optionalChain([this, 'access', _2 => _2._resolve, 'optionalCall', _3 => _3(value)]);
595
595
  });
596
- _chunkQSXZKZJAcjs.__publicField.call(void 0, this, "reject", (reason) => {
596
+ _chunkP3J2BIUTcjs.__publicField.call(void 0, this, "reject", (reason) => {
597
597
  _optionalChain([this, 'access', _4 => _4._reject, 'optionalCall', _5 => _5(reason)]);
598
598
  });
599
599
  this._promise = new Promise((resolve, reject) => {
@@ -607,7 +607,7 @@ var Deferred = class {
607
607
  };
608
608
 
609
609
  // src/core/utils/compression/compress.ts
610
- var import_async_lz_string = _chunkQSXZKZJAcjs.__toESM.call(void 0, require_async_lz_string(), 1);
610
+ var import_async_lz_string = _chunkP3J2BIUTcjs.__toESM.call(void 0, require_async_lz_string(), 1);
611
611
  var _jssha256 = require('js-sha256');
612
612
  async function hashAndCompressData(data) {
613
613
  const validationHash = _jssha256.sha256.call(void 0, JSON.stringify(data));
@@ -627,7 +627,7 @@ async function compressJson(data) {
627
627
  }
628
628
 
629
629
  // src/core/utils/compression/decompress.ts
630
- var import_async_lz_string2 = _chunkQSXZKZJAcjs.__toESM.call(void 0, require_async_lz_string(), 1);
630
+ var import_async_lz_string2 = _chunkP3J2BIUTcjs.__toESM.call(void 0, require_async_lz_string(), 1);
631
631
 
632
632
  async function decompressDataAndCheckHash(compressedData) {
633
633
  if (!(_optionalChain([compressedData, 'optionalAccess', _6 => _6.compressed]) && _optionalChain([compressedData, 'optionalAccess', _7 => _7.compressedHash]))) {
@@ -679,7 +679,7 @@ async function decompressJson(data) {
679
679
  }
680
680
 
681
681
  // src/core/utils/buttonShare.ts
682
- var getButtonShare = (selector = "#nexus-share-button > button") => document.querySelector(selector);
682
+ var getButtonShare = (selector = "button[data-frak-share-button], #nexus-share-button > button") => document.querySelectorAll(selector);
683
683
  var setButtonDisabled = (disabled, button) => {
684
684
  if (disabled) {
685
685
  _optionalChain([button, 'optionalAccess', _9 => _9.removeAttribute, 'call', _10 => _10("disabled")]);
@@ -688,8 +688,12 @@ var setButtonDisabled = (disabled, button) => {
688
688
  _optionalChain([button, 'optionalAccess', _11 => _11.setAttribute, 'call', _12 => _12("disabled", "")]);
689
689
  };
690
690
  var toggleButtonDisabled = (disabled) => (config) => {
691
- const button = getButtonShare(_optionalChain([config, 'optionalAccess', _13 => _13.metadata, 'optionalAccess', _14 => _14.buttonShare]));
692
- setButtonDisabled(disabled, button);
691
+ const buttons = Array.from(
692
+ getButtonShare(_optionalChain([config, 'optionalAccess', _13 => _13.metadata, 'optionalAccess', _14 => _14.buttonShare]))
693
+ );
694
+ for (const button of buttons) {
695
+ setButtonDisabled(disabled, button);
696
+ }
693
697
  };
694
698
  var enableButtonShare = toggleButtonDisabled(true);
695
699
  var disableButtonShare = toggleButtonDisabled(false);
@@ -716,7 +720,7 @@ function createIframe({
716
720
  disableButtonShare(config);
717
721
  const alreadyCreatedIFrame = document.querySelector("#nexus-wallet");
718
722
  if (alreadyCreatedIFrame) {
719
- return Promise.resolve(alreadyCreatedIFrame);
723
+ alreadyCreatedIFrame.remove();
720
724
  }
721
725
  const iframe = document.createElement("iframe");
722
726
  iframe.id = baseIframeProps.id;
@@ -727,7 +731,7 @@ function createIframe({
727
731
  document.body.appendChild(iframe);
728
732
  return new Promise((resolve) => {
729
733
  _optionalChain([iframe, 'optionalAccess', _15 => _15.addEventListener, 'call', _16 => _16("load", () => resolve(iframe))]);
730
- iframe.src = `${walletBaseUrl}/listener`;
734
+ iframe.src = `${_nullishCoalesce(_nullishCoalesce(walletBaseUrl, () => ( _optionalChain([config, 'optionalAccess', _17 => _17.walletUrl]))), () => ( "https://wallet.frak.id"))}/listener`;
731
735
  });
732
736
  }
733
737
  function changeIframeVisibility({
@@ -767,7 +771,7 @@ function base64url_decode(value) {
767
771
  );
768
772
  }
769
773
  function compress(context) {
770
- if (!_optionalChain([context, 'optionalAccess', _17 => _17.r])) return;
774
+ if (!_optionalChain([context, 'optionalAccess', _18 => _18.r])) return;
771
775
  try {
772
776
  const bytes = _viem.hexToBytes.call(void 0, context.r);
773
777
  return base64url_encode(bytes);
@@ -816,7 +820,7 @@ function replaceUrl({
816
820
  url: baseUrl,
817
821
  context
818
822
  }) {
819
- if (!_optionalChain([window, 'access', _18 => _18.location, 'optionalAccess', _19 => _19.href]) || typeof window === "undefined") {
823
+ if (!_optionalChain([window, 'access', _19 => _19.location, 'optionalAccess', _20 => _20.href]) || typeof window === "undefined") {
820
824
  console.error("No window found, can't update context");
821
825
  return;
822
826
  }
@@ -65,7 +65,8 @@ var interactionTypes = {
65
65
  },
66
66
  purchase: {
67
67
  started: "0xd87e90c3",
68
- completed: "0x8403aeb4"
68
+ completed: "0x8403aeb4",
69
+ unsafeCompleted: "0x4d5b14e0"
69
70
  }
70
71
  };
71
72
 
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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";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; }
2
2
 
3
3
 
4
4
 
@@ -7,7 +7,7 @@
7
7
 
8
8
 
9
9
 
10
- var _chunkF3F4BCGVcjs = require('./chunk-F3F4BCGV.cjs');
10
+ var _chunkH4BK3CNVcjs = require('./chunk-H4BK3CNV.cjs');
11
11
 
12
12
  // src/core/utils/constants.ts
13
13
  var BACKUP_KEY = "nexus-wallet-backup";
@@ -32,7 +32,7 @@ function createIFrameChannelManager() {
32
32
  function createIFrameLifecycleManager({
33
33
  iframe
34
34
  }) {
35
- const isConnectedDeferred = new (0, _chunkF3F4BCGVcjs.Deferred)();
35
+ const isConnectedDeferred = new (0, _chunkH4BK3CNVcjs.Deferred)();
36
36
  const handler = async (messageEvent) => {
37
37
  switch (messageEvent.iframeLifecycle) {
38
38
  // Resolve the isConnected promise
@@ -54,7 +54,7 @@ function createIFrameLifecycleManager({
54
54
  // Change iframe visibility
55
55
  case "show":
56
56
  case "hide":
57
- _chunkF3F4BCGVcjs.changeIframeVisibility.call(void 0, {
57
+ _chunkH4BK3CNVcjs.changeIframeVisibility.call(void 0, {
58
58
  iframe,
59
59
  isVisible: messageEvent.iframeLifecycle === "show"
60
60
  });
@@ -75,14 +75,14 @@ function createIFrameMessageHandler({
75
75
  iframeLifecycleManager
76
76
  }) {
77
77
  if (typeof window === "undefined") {
78
- throw new (0, _chunkF3F4BCGVcjs.FrakRpcError)(
79
- _chunkF3F4BCGVcjs.RpcErrorCodes.configError,
78
+ throw new (0, _chunkH4BK3CNVcjs.FrakRpcError)(
79
+ _chunkH4BK3CNVcjs.RpcErrorCodes.configError,
80
80
  "iframe client should be used in the browser"
81
81
  );
82
82
  }
83
83
  if (!iframe.contentWindow) {
84
- throw new (0, _chunkF3F4BCGVcjs.FrakRpcError)(
85
- _chunkF3F4BCGVcjs.RpcErrorCodes.configError,
84
+ throw new (0, _chunkH4BK3CNVcjs.FrakRpcError)(
85
+ _chunkH4BK3CNVcjs.RpcErrorCodes.configError,
86
86
  "The iframe does not have a product window"
87
87
  );
88
88
  }
@@ -134,7 +134,7 @@ function createIFrameNexusClient({
134
134
  const channelManager = createIFrameChannelManager();
135
135
  const lifecycleManager = createIFrameLifecycleManager({ iframe });
136
136
  const messageHandler = createIFrameMessageHandler({
137
- nexusWalletUrl: config.walletUrl,
137
+ nexusWalletUrl: _nullishCoalesce(_optionalChain([config, 'optionalAccess', _ => _.walletUrl]), () => ( "https://wallet.frak.id")),
138
138
  iframe,
139
139
  channelManager,
140
140
  iframeLifecycleManager: lifecycleManager
@@ -142,20 +142,20 @@ function createIFrameNexusClient({
142
142
  const request = async (args) => {
143
143
  const isConnected = await lifecycleManager.isConnected;
144
144
  if (!isConnected) {
145
- throw new (0, _chunkF3F4BCGVcjs.FrakRpcError)(
146
- _chunkF3F4BCGVcjs.RpcErrorCodes.clientNotConnected,
145
+ throw new (0, _chunkH4BK3CNVcjs.FrakRpcError)(
146
+ _chunkH4BK3CNVcjs.RpcErrorCodes.clientNotConnected,
147
147
  "The iframe provider isn't connected yet"
148
148
  );
149
149
  }
150
- const result = new (0, _chunkF3F4BCGVcjs.Deferred)();
150
+ const result = new (0, _chunkH4BK3CNVcjs.Deferred)();
151
151
  const channelId = channelManager.createChannel(async (message) => {
152
- const decompressed = await _chunkF3F4BCGVcjs.decompressDataAndCheckHash.call(void 0, message.data);
152
+ const decompressed = await _chunkH4BK3CNVcjs.decompressDataAndCheckHash.call(void 0, message.data);
153
153
  if (decompressed.error) {
154
154
  result.reject(
155
- new (0, _chunkF3F4BCGVcjs.FrakRpcError)(
155
+ new (0, _chunkH4BK3CNVcjs.FrakRpcError)(
156
156
  decompressed.error.code,
157
157
  decompressed.error.message,
158
- _optionalChain([decompressed, 'access', _ => _.error, 'optionalAccess', _2 => _2.data])
158
+ _optionalChain([decompressed, 'access', _2 => _2.error, 'optionalAccess', _3 => _3.data])
159
159
  )
160
160
  );
161
161
  } else {
@@ -163,7 +163,7 @@ function createIFrameNexusClient({
163
163
  }
164
164
  channelManager.removeChannel(channelId);
165
165
  });
166
- const compressedMessage = await _chunkF3F4BCGVcjs.hashAndCompressData.call(void 0, args);
166
+ const compressedMessage = await _chunkH4BK3CNVcjs.hashAndCompressData.call(void 0, args);
167
167
  messageHandler.sendEvent({
168
168
  id: channelId,
169
169
  topic: args.method,
@@ -174,20 +174,20 @@ function createIFrameNexusClient({
174
174
  const listenerRequest = async (args, callback) => {
175
175
  const isConnected = await lifecycleManager.isConnected;
176
176
  if (!isConnected) {
177
- throw new (0, _chunkF3F4BCGVcjs.FrakRpcError)(
178
- _chunkF3F4BCGVcjs.RpcErrorCodes.clientNotConnected,
177
+ throw new (0, _chunkH4BK3CNVcjs.FrakRpcError)(
178
+ _chunkH4BK3CNVcjs.RpcErrorCodes.clientNotConnected,
179
179
  "The iframe provider isn't connected yet"
180
180
  );
181
181
  }
182
182
  const channelId = channelManager.createChannel(async (message) => {
183
- const decompressed = await _chunkF3F4BCGVcjs.decompressDataAndCheckHash.call(void 0, message.data);
183
+ const decompressed = await _chunkH4BK3CNVcjs.decompressDataAndCheckHash.call(void 0, message.data);
184
184
  if (decompressed.result) {
185
185
  callback(decompressed.result);
186
186
  } else {
187
- throw new (0, _chunkF3F4BCGVcjs.InternalError)("No valid result in the response");
187
+ throw new (0, _chunkH4BK3CNVcjs.InternalError)("No valid result in the response");
188
188
  }
189
189
  });
190
- const compressedMessage = await _chunkF3F4BCGVcjs.hashAndCompressData.call(void 0, args);
190
+ const compressedMessage = await _chunkH4BK3CNVcjs.hashAndCompressData.call(void 0, args);
191
191
  messageHandler.sendEvent({
192
192
  id: channelId,
193
193
  topic: args.method,
@@ -219,7 +219,7 @@ async function postConnectionSetup({
219
219
  lifecycleManager
220
220
  }) {
221
221
  await lifecycleManager.isConnected;
222
- _chunkF3F4BCGVcjs.enableButtonShare.call(void 0, config);
222
+ _chunkH4BK3CNVcjs.enableButtonShare.call(void 0, config);
223
223
  const pushCss = async () => {
224
224
  const cssLink = config.metadata.css;
225
225
  if (!cssLink) return;
@@ -7,7 +7,7 @@ import {
7
7
  decompressDataAndCheckHash,
8
8
  enableButtonShare,
9
9
  hashAndCompressData
10
- } from "./chunk-ZQSA2VQ4.js";
10
+ } from "./chunk-2VNIEGOJ.js";
11
11
 
12
12
  // src/core/utils/constants.ts
13
13
  var BACKUP_KEY = "nexus-wallet-backup";
@@ -134,7 +134,7 @@ function createIFrameNexusClient({
134
134
  const channelManager = createIFrameChannelManager();
135
135
  const lifecycleManager = createIFrameLifecycleManager({ iframe });
136
136
  const messageHandler = createIFrameMessageHandler({
137
- nexusWalletUrl: config.walletUrl,
137
+ nexusWalletUrl: config?.walletUrl ?? "https://wallet.frak.id",
138
138
  iframe,
139
139
  channelManager,
140
140
  iframeLifecycleManager: lifecycleManager
@@ -8,12 +8,12 @@
8
8
 
9
9
 
10
10
 
11
- var _chunk4CWA7EWXcjs = require('../../chunk-4CWA7EWX.cjs');
12
- require('../../chunk-F3F4BCGV.cjs');
13
- require('../../chunk-4OJ2NPAS.cjs');
14
- require('../../chunk-QSXZKZJA.cjs');
15
11
 
16
12
 
13
+ var _chunkDE2KWQVPcjs = require('../../chunk-DE2KWQVP.cjs');
14
+ require('../../chunk-H4BK3CNV.cjs');
15
+ require('../../chunk-4PVF24BB.cjs');
16
+ require('../../chunk-P3J2BIUT.cjs');
17
17
 
18
18
 
19
19
 
@@ -22,4 +22,8 @@ require('../../chunk-QSXZKZJA.cjs');
22
22
 
23
23
 
24
24
 
25
- exports.displayModal = _chunk4CWA7EWXcjs.displayModal; exports.openSso = _chunk4CWA7EWXcjs.openSso; exports.processReferral = _chunk4CWA7EWXcjs.processReferral; exports.referralInteraction = _chunk4CWA7EWXcjs.referralInteraction; exports.sendInteraction = _chunk4CWA7EWXcjs.sendInteraction; exports.sendTransaction = _chunk4CWA7EWXcjs.sendTransaction; exports.siweAuthenticate = _chunk4CWA7EWXcjs.siweAuthenticate; exports.walletStatus = _chunk4CWA7EWXcjs.walletStatus; exports.watchWalletStatus = _chunk4CWA7EWXcjs.watchWalletStatus;
25
+
26
+
27
+
28
+
29
+ exports.displayModal = _chunkDE2KWQVPcjs.displayModal; exports.getProductInformation = _chunkDE2KWQVPcjs.getProductInformation; exports.modalBuilder = _chunkDE2KWQVPcjs.modalBuilder; exports.openSso = _chunkDE2KWQVPcjs.openSso; exports.processReferral = _chunkDE2KWQVPcjs.processReferral; exports.referralInteraction = _chunkDE2KWQVPcjs.referralInteraction; exports.sendInteraction = _chunkDE2KWQVPcjs.sendInteraction; exports.sendTransaction = _chunkDE2KWQVPcjs.sendTransaction; exports.siweAuthenticate = _chunkDE2KWQVPcjs.siweAuthenticate; exports.trackPurchaseStatus = _chunkDE2KWQVPcjs.trackPurchaseStatus; exports.watchWalletStatus = _chunkDE2KWQVPcjs.watchWalletStatus;