@frak-labs/nexus-sdk 0.0.23 → 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 (30) 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-4Q2OHGWX.js → chunk-4MMSQL44.js} +15 -5
  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-BHZDDGW6.cjs → chunk-DE2KWQVP.cjs} +36 -26
  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 +7 -5
  15. package/dist/core/actions/index.d.cts +11 -5
  16. package/dist/core/actions/index.d.ts +11 -5
  17. package/dist/core/actions/index.js +6 -4
  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 +48 -27
  27. package/dist/react/index.d.cts +20 -13
  28. package/dist/react/index.d.ts +20 -13
  29. package/dist/react/index.js +26 -5
  30. package/package.json +42 -19
@@ -1,27 +1,27 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
3
 
4
- var _chunkQSXZKZJAcjs = require('./chunk-QSXZKZJA.cjs');
4
+ var _chunkP3J2BIUTcjs = require('./chunk-P3J2BIUT.cjs');
5
5
 
6
6
  // src/core/interactions/pressEncoder.ts
7
7
  var _viem = require('viem');
8
8
  function openArticle({ articleId }) {
9
9
  const interactionData = _viem.concatHex.call(void 0, [
10
- _chunkQSXZKZJAcjs.interactionTypes.press.openArticle,
10
+ _chunkP3J2BIUTcjs.interactionTypes.press.openArticle,
11
11
  _viem.pad.call(void 0, articleId, { size: 32 })
12
12
  ]);
13
13
  return {
14
- handlerTypeDenominator: _viem.toHex.call(void 0, _chunkQSXZKZJAcjs.productTypes.press),
14
+ handlerTypeDenominator: _viem.toHex.call(void 0, _chunkP3J2BIUTcjs.productTypes.press),
15
15
  interactionData
16
16
  };
17
17
  }
18
18
  function readArticle({ articleId }) {
19
19
  const interactionData = _viem.concatHex.call(void 0, [
20
- _chunkQSXZKZJAcjs.interactionTypes.press.readArticle,
20
+ _chunkP3J2BIUTcjs.interactionTypes.press.readArticle,
21
21
  _viem.pad.call(void 0, articleId, { size: 32 })
22
22
  ]);
23
23
  return {
24
- handlerTypeDenominator: _viem.toHex.call(void 0, _chunkQSXZKZJAcjs.productTypes.press),
24
+ handlerTypeDenominator: _viem.toHex.call(void 0, _chunkP3J2BIUTcjs.productTypes.press),
25
25
  interactionData
26
26
  };
27
27
  }
@@ -34,21 +34,21 @@ var PressInteractionEncoder = {
34
34
 
35
35
  function createLink() {
36
36
  const interactionData = _viem.concatHex.call(void 0, [
37
- _chunkQSXZKZJAcjs.interactionTypes.referral.createLink,
37
+ _chunkP3J2BIUTcjs.interactionTypes.referral.createLink,
38
38
  "0x"
39
39
  ]);
40
40
  return {
41
- handlerTypeDenominator: _viem.toHex.call(void 0, _chunkQSXZKZJAcjs.productTypes.referral),
41
+ handlerTypeDenominator: _viem.toHex.call(void 0, _chunkP3J2BIUTcjs.productTypes.referral),
42
42
  interactionData
43
43
  };
44
44
  }
45
45
  function referred({ referrer }) {
46
46
  const interactionData = _viem.concatHex.call(void 0, [
47
- _chunkQSXZKZJAcjs.interactionTypes.referral.referred,
47
+ _chunkP3J2BIUTcjs.interactionTypes.referral.referred,
48
48
  _viem.pad.call(void 0, referrer, { size: 32 })
49
49
  ]);
50
50
  return {
51
- handlerTypeDenominator: _viem.toHex.call(void 0, _chunkQSXZKZJAcjs.productTypes.referral),
51
+ handlerTypeDenominator: _viem.toHex.call(void 0, _chunkP3J2BIUTcjs.productTypes.referral),
52
52
  interactionData
53
53
  };
54
54
  }
@@ -63,11 +63,11 @@ function startPurchase({
63
63
  purchaseId
64
64
  }) {
65
65
  const interactionData = _viem.concatHex.call(void 0, [
66
- _chunkQSXZKZJAcjs.interactionTypes.purchase.started,
66
+ _chunkP3J2BIUTcjs.interactionTypes.purchase.started,
67
67
  _viem.pad.call(void 0, purchaseId, { size: 32 })
68
68
  ]);
69
69
  return {
70
- handlerTypeDenominator: _viem.toHex.call(void 0, _chunkQSXZKZJAcjs.productTypes.purchase),
70
+ handlerTypeDenominator: _viem.toHex.call(void 0, _chunkP3J2BIUTcjs.productTypes.purchase),
71
71
  interactionData
72
72
  };
73
73
  }
@@ -80,11 +80,11 @@ function completedPurchase({
80
80
  [BigInt(purchaseId), proof]
81
81
  );
82
82
  const interactionData = _viem.concatHex.call(void 0, [
83
- _chunkQSXZKZJAcjs.interactionTypes.purchase.completed,
83
+ _chunkP3J2BIUTcjs.interactionTypes.purchase.completed,
84
84
  innerData
85
85
  ]);
86
86
  return {
87
- handlerTypeDenominator: _viem.toHex.call(void 0, _chunkQSXZKZJAcjs.productTypes.purchase),
87
+ handlerTypeDenominator: _viem.toHex.call(void 0, _chunkP3J2BIUTcjs.productTypes.purchase),
88
88
  interactionData
89
89
  };
90
90
  }
@@ -96,9 +96,9 @@ var PurchaseInteractionEncoder = {
96
96
  // src/core/interactions/webshopEncoder.ts
97
97
 
98
98
  function open() {
99
- const interactionData = _viem.concatHex.call(void 0, [_chunkQSXZKZJAcjs.interactionTypes.webshop.open, "0x"]);
99
+ const interactionData = _viem.concatHex.call(void 0, [_chunkP3J2BIUTcjs.interactionTypes.webshop.open, "0x"]);
100
100
  return {
101
- handlerTypeDenominator: _viem.toHex.call(void 0, _chunkQSXZKZJAcjs.productTypes.webshop),
101
+ handlerTypeDenominator: _viem.toHex.call(void 0, _chunkP3J2BIUTcjs.productTypes.webshop),
102
102
  interactionData
103
103
  };
104
104
  }
@@ -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
 
@@ -3,10 +3,10 @@
3
3
 
4
4
 
5
5
 
6
- var _chunkF3F4BCGVcjs = require('./chunk-F3F4BCGV.cjs');
6
+ var _chunkH4BK3CNVcjs = require('./chunk-H4BK3CNV.cjs');
7
7
 
8
8
 
9
- var _chunk4OJ2NPAScjs = require('./chunk-4OJ2NPAS.cjs');
9
+ var _chunk4PVF24BBcjs = require('./chunk-4PVF24BB.cjs');
10
10
 
11
11
  // src/core/actions/watchWalletStatus.ts
12
12
  function watchWalletStatus(client, callback) {
@@ -16,7 +16,7 @@ function watchWalletStatus(client, callback) {
16
16
  return result;
17
17
  });
18
18
  }
19
- const firstResult = new (0, _chunkF3F4BCGVcjs.Deferred)();
19
+ const firstResult = new (0, _chunkH4BK3CNVcjs.Deferred)();
20
20
  let hasResolved = false;
21
21
  return client.listenerRequest(
22
22
  {
@@ -49,7 +49,8 @@ function savePotentialToken(interactionToken) {
49
49
  // src/core/utils/computeProductId.ts
50
50
  var _viem = require('viem');
51
51
  function computeProductId({ domain }) {
52
- return _viem.keccak256.call(void 0, _viem.toHex.call(void 0, domain));
52
+ const effectiveDomain = _nullishCoalesce(domain, () => ( window.location.host));
53
+ return _viem.keccak256.call(void 0, _viem.toHex.call(void 0, effectiveDomain));
53
54
  }
54
55
 
55
56
  // src/core/actions/sendInteraction.ts
@@ -78,6 +79,13 @@ async function openSso(client, args) {
78
79
  });
79
80
  }
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
+
81
89
  // src/core/actions/trackPurchaseStatus.ts
82
90
  async function trackPurchaseStatus(args) {
83
91
  if (typeof window === "undefined") {
@@ -105,14 +113,15 @@ async function trackPurchaseStatus(args) {
105
113
  // src/core/actions/wrapper/siweAuthenticate.ts
106
114
  var _siwe = require('viem/siwe');
107
115
  async function siweAuthenticate(client, { siwe, metadata }) {
108
- const realStatement = _nullishCoalesce(_optionalChain([siwe, 'optionalAccess', _ => _.statement]), () => ( `I confirm that I want to use my Frak wallet on: ${client.config.metadata.name}`));
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}`));
109
118
  const builtSiwe = {
110
119
  ...siwe,
111
120
  statement: realStatement,
112
- nonce: _nullishCoalesce(_optionalChain([siwe, 'optionalAccess', _2 => _2.nonce]), () => ( _siwe.generateSiweNonce.call(void 0, ))),
113
- uri: _nullishCoalesce(_optionalChain([siwe, 'optionalAccess', _3 => _3.uri]), () => ( `https://${client.config.domain}`)),
114
- version: _nullishCoalesce(_optionalChain([siwe, 'optionalAccess', _4 => _4.version]), () => ( "1")),
115
- domain: client.config.domain
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
116
125
  };
117
126
  const result = await displayModal(client, {
118
127
  metadata,
@@ -229,7 +238,7 @@ async function processReferral(client, {
229
238
  });
230
239
  }
231
240
  async function pushReferralInteraction(referrer) {
232
- const interaction = _chunk4OJ2NPAScjs.ReferralInteractionEncoder.referred({
241
+ const interaction = _chunk4PVF24BBcjs.ReferralInteractionEncoder.referred({
233
242
  referrer
234
243
  });
235
244
  await sendInteraction(client, { productId, interaction });
@@ -241,16 +250,16 @@ async function processReferral(client, {
241
250
  pushReferralInteraction,
242
251
  frakContext
243
252
  });
244
- _chunkF3F4BCGVcjs.FrakContextManager.replaceUrl({
245
- url: _optionalChain([window, 'access', _5 => _5.location, 'optionalAccess', _6 => _6.href]),
246
- context: _optionalChain([options, 'optionalAccess', _7 => _7.alwaysAppendUrl]) ? { r: currentWallet } : null
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
247
256
  });
248
257
  return status;
249
258
  } catch (error) {
250
259
  console.log("Error processing referral", { error });
251
- _chunkF3F4BCGVcjs.FrakContextManager.replaceUrl({
252
- url: _optionalChain([window, 'access', _8 => _8.location, 'optionalAccess', _9 => _9.href]),
253
- context: _optionalChain([options, 'optionalAccess', _10 => _10.alwaysAppendUrl]) ? { r: _optionalChain([walletStatus, 'optionalAccess', _11 => _11.wallet]) } : null
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
254
263
  });
255
264
  return mapErrorToState(error);
256
265
  }
@@ -261,8 +270,8 @@ async function processReferralLogic({
261
270
  pushReferralInteraction,
262
271
  frakContext
263
272
  }) {
264
- let currentWallet = _optionalChain([initialWalletStatus, 'optionalAccess', _12 => _12.wallet]);
265
- if (!_optionalChain([frakContext, 'optionalAccess', _13 => _13.r])) {
273
+ let currentWallet = _optionalChain([initialWalletStatus, 'optionalAccess', _14 => _14.wallet]);
274
+ if (!_optionalChain([frakContext, 'optionalAccess', _15 => _15.r])) {
266
275
  return { status: "no-referrer", currentWallet };
267
276
  }
268
277
  if (!currentWallet) {
@@ -271,7 +280,7 @@ async function processReferralLogic({
271
280
  if (currentWallet && _viem.isAddressEqual.call(void 0, frakContext.r, currentWallet)) {
272
281
  return { status: "self-referral", currentWallet };
273
282
  }
274
- if (!_optionalChain([initialWalletStatus, 'optionalAccess', _14 => _14.interactionSession])) {
283
+ if (!_optionalChain([initialWalletStatus, 'optionalAccess', _16 => _16.interactionSession])) {
275
284
  currentWallet = await getFreshWalletStatus();
276
285
  }
277
286
  await pushReferralInteraction(frakContext.r);
@@ -281,21 +290,21 @@ async function ensureWalletConnected(client, {
281
290
  modalConfig,
282
291
  walletStatus
283
292
  }) {
284
- if (!_optionalChain([walletStatus, 'optionalAccess', _15 => _15.interactionSession])) {
293
+ if (!_optionalChain([walletStatus, 'optionalAccess', _17 => _17.interactionSession])) {
285
294
  if (!modalConfig) {
286
295
  return void 0;
287
296
  }
288
297
  const result = await displayModal(client, modalConfig);
289
- return _nullishCoalesce(_optionalChain([result, 'optionalAccess', _16 => _16.login, 'optionalAccess', _17 => _17.wallet]), () => ( void 0));
298
+ return _nullishCoalesce(_optionalChain([result, 'optionalAccess', _18 => _18.login, 'optionalAccess', _19 => _19.wallet]), () => ( void 0));
290
299
  }
291
300
  return _nullishCoalesce(walletStatus.wallet, () => ( void 0));
292
301
  }
293
302
  function mapErrorToState(error) {
294
- if (error instanceof _chunkF3F4BCGVcjs.FrakRpcError) {
303
+ if (error instanceof _chunkH4BK3CNVcjs.FrakRpcError) {
295
304
  switch (error.code) {
296
- case _chunkF3F4BCGVcjs.RpcErrorCodes.walletNotConnected:
305
+ case _chunkH4BK3CNVcjs.RpcErrorCodes.walletNotConnected:
297
306
  return "no-wallet";
298
- case _chunkF3F4BCGVcjs.RpcErrorCodes.serverErrorForInteractionDelegation:
307
+ case _chunkH4BK3CNVcjs.RpcErrorCodes.serverErrorForInteractionDelegation:
299
308
  return "no-session";
300
309
  default:
301
310
  return "error";
@@ -310,7 +319,7 @@ async function referralInteraction(client, {
310
319
  modalConfig,
311
320
  options
312
321
  } = {}) {
313
- const frakContext = _chunkF3F4BCGVcjs.FrakContextManager.parse({
322
+ const frakContext = _chunkH4BK3CNVcjs.FrakContextManager.parse({
314
323
  url: window.location.href
315
324
  });
316
325
  const currentWalletStatus = await watchWalletStatus(client);
@@ -338,4 +347,5 @@ async function referralInteraction(client, {
338
347
 
339
348
 
340
349
 
341
- exports.watchWalletStatus = watchWalletStatus; exports.sendInteraction = sendInteraction; exports.displayModal = displayModal; exports.openSso = openSso; exports.trackPurchaseStatus = trackPurchaseStatus; exports.siweAuthenticate = siweAuthenticate; exports.sendTransaction = sendTransaction; exports.modalBuilder = modalBuilder; exports.processReferral = processReferral; exports.referralInteraction = referralInteraction;
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
@@ -9,11 +9,11 @@
9
9
 
10
10
 
11
11
 
12
- var _chunkBHZDDGW6cjs = require('../../chunk-BHZDDGW6.cjs');
13
- require('../../chunk-F3F4BCGV.cjs');
14
- require('../../chunk-4OJ2NPAS.cjs');
15
- require('../../chunk-QSXZKZJA.cjs');
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
 
@@ -24,4 +24,6 @@ require('../../chunk-QSXZKZJA.cjs');
24
24
 
25
25
 
26
26
 
27
- exports.displayModal = _chunkBHZDDGW6cjs.displayModal; exports.modalBuilder = _chunkBHZDDGW6cjs.modalBuilder; exports.openSso = _chunkBHZDDGW6cjs.openSso; exports.processReferral = _chunkBHZDDGW6cjs.processReferral; exports.referralInteraction = _chunkBHZDDGW6cjs.referralInteraction; exports.sendInteraction = _chunkBHZDDGW6cjs.sendInteraction; exports.sendTransaction = _chunkBHZDDGW6cjs.sendTransaction; exports.siweAuthenticate = _chunkBHZDDGW6cjs.siweAuthenticate; exports.trackPurchaseStatus = _chunkBHZDDGW6cjs.trackPurchaseStatus; exports.watchWalletStatus = _chunkBHZDDGW6cjs.watchWalletStatus;
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;
@@ -1,7 +1,7 @@
1
- import { a as NexusClient, W as WalletStatusReturnType, M as ModalStepTypes, D as DisplayModalParamsType, d as ModalRpcStepsResultType, O as OpenSsoParamsType, j as SendTransactionModalStepType, n as FinalModalStepType, o as FinalActionType, L as LoginModalStepType, m as OpenInteractionSessionModalStepType, b as ModalRpcMetadata } from '../../FrakContext-DBdWC7ls.cjs';
1
+ import { a as NexusClient, W as WalletStatusReturnType, M as ModalStepTypes, D as DisplayModalParamsType, e as ModalRpcStepsResultType, O as OpenSsoParamsType, G as GetProductInformationReturnType, k as SendTransactionModalStepType, o as FinalModalStepType, q as FinalActionType, L as LoginModalStepType, n as OpenInteractionSessionModalStepType, c as ModalRpcMetadata } from '../../FrakContext-DKSVaeVb.cjs';
2
2
  import { S as SendInteractionParamsType, a as SendInteractionReturnType } from '../../interaction-BngPoHA0.cjs';
3
- import { P as ProcessReferralOptions } from '../../processReferral-BWSIamn2.cjs';
4
- export { S as SendTransactionParams, a as SiweAuthenticateModalParams, p as processReferral, b as sendTransaction, s as siweAuthenticate } from '../../processReferral-BWSIamn2.cjs';
3
+ import { P as ProcessReferralOptions } from '../../processReferral-DUP8imQV.cjs';
4
+ export { S as SendTransactionParams, a as SiweAuthenticateModalParams, p as processReferral, b as sendTransaction, s as siweAuthenticate } from '../../processReferral-DUP8imQV.cjs';
5
5
  import { Hex } from 'viem';
6
6
  import 'viem/chains';
7
7
  import 'viem/siwe';
@@ -36,6 +36,12 @@ declare function displayModal<T extends ModalStepTypes[] = ModalStepTypes[]>(cli
36
36
  */
37
37
  declare function openSso(client: NexusClient, args: OpenSsoParamsType): Promise<void>;
38
38
 
39
+ /**
40
+ * Function used to get the current product information
41
+ * @param client
42
+ */
43
+ declare function getProductInformation(client: NexusClient): Promise<GetProductInformationReturnType>;
44
+
39
45
  /**
40
46
  * Function used to track the status of a purchase
41
47
  */
@@ -72,7 +78,7 @@ type ModalBuilder = ModalStepBuilder<[
72
78
  * @param openSession
73
79
  */
74
80
  declare function modalBuilder(client: NexusClient, { metadata, login, openSession, }: {
75
- metadata: ModalRpcMetadata;
81
+ metadata?: ModalRpcMetadata;
76
82
  login?: LoginModalStepType["params"];
77
83
  openSession?: OpenInteractionSessionModalStepType["params"];
78
84
  }): ModalBuilder;
@@ -83,4 +89,4 @@ declare function referralInteraction(client: NexusClient, { productId, modalConf
83
89
  options?: ProcessReferralOptions;
84
90
  }): Promise<unknown>;
85
91
 
86
- export { type ModalBuilder, type ModalStepBuilder, displayModal, modalBuilder, openSso, referralInteraction, sendInteraction, trackPurchaseStatus, watchWalletStatus };
92
+ export { type ModalBuilder, type ModalStepBuilder, displayModal, getProductInformation, modalBuilder, openSso, referralInteraction, sendInteraction, trackPurchaseStatus, watchWalletStatus };
@@ -1,7 +1,7 @@
1
- import { a as NexusClient, W as WalletStatusReturnType, M as ModalStepTypes, D as DisplayModalParamsType, d as ModalRpcStepsResultType, O as OpenSsoParamsType, j as SendTransactionModalStepType, n as FinalModalStepType, o as FinalActionType, L as LoginModalStepType, m as OpenInteractionSessionModalStepType, b as ModalRpcMetadata } from '../../FrakContext-CDVlUN75.js';
1
+ import { a as NexusClient, W as WalletStatusReturnType, M as ModalStepTypes, D as DisplayModalParamsType, e as ModalRpcStepsResultType, O as OpenSsoParamsType, G as GetProductInformationReturnType, k as SendTransactionModalStepType, o as FinalModalStepType, q as FinalActionType, L as LoginModalStepType, n as OpenInteractionSessionModalStepType, c as ModalRpcMetadata } from '../../FrakContext-DjeuWC2U.js';
2
2
  import { S as SendInteractionParamsType, a as SendInteractionReturnType } from '../../interaction-BngPoHA0.js';
3
- import { P as ProcessReferralOptions } from '../../processReferral-CFyGAENf.js';
4
- export { S as SendTransactionParams, a as SiweAuthenticateModalParams, p as processReferral, b as sendTransaction, s as siweAuthenticate } from '../../processReferral-CFyGAENf.js';
3
+ import { P as ProcessReferralOptions } from '../../processReferral-CJI_Rc4K.js';
4
+ export { S as SendTransactionParams, a as SiweAuthenticateModalParams, p as processReferral, b as sendTransaction, s as siweAuthenticate } from '../../processReferral-CJI_Rc4K.js';
5
5
  import { Hex } from 'viem';
6
6
  import 'viem/chains';
7
7
  import 'viem/siwe';
@@ -36,6 +36,12 @@ declare function displayModal<T extends ModalStepTypes[] = ModalStepTypes[]>(cli
36
36
  */
37
37
  declare function openSso(client: NexusClient, args: OpenSsoParamsType): Promise<void>;
38
38
 
39
+ /**
40
+ * Function used to get the current product information
41
+ * @param client
42
+ */
43
+ declare function getProductInformation(client: NexusClient): Promise<GetProductInformationReturnType>;
44
+
39
45
  /**
40
46
  * Function used to track the status of a purchase
41
47
  */
@@ -72,7 +78,7 @@ type ModalBuilder = ModalStepBuilder<[
72
78
  * @param openSession
73
79
  */
74
80
  declare function modalBuilder(client: NexusClient, { metadata, login, openSession, }: {
75
- metadata: ModalRpcMetadata;
81
+ metadata?: ModalRpcMetadata;
76
82
  login?: LoginModalStepType["params"];
77
83
  openSession?: OpenInteractionSessionModalStepType["params"];
78
84
  }): ModalBuilder;
@@ -83,4 +89,4 @@ declare function referralInteraction(client: NexusClient, { productId, modalConf
83
89
  options?: ProcessReferralOptions;
84
90
  }): Promise<unknown>;
85
91
 
86
- export { type ModalBuilder, type ModalStepBuilder, displayModal, modalBuilder, openSso, referralInteraction, sendInteraction, trackPurchaseStatus, watchWalletStatus };
92
+ export { type ModalBuilder, type ModalStepBuilder, displayModal, getProductInformation, modalBuilder, openSso, referralInteraction, sendInteraction, trackPurchaseStatus, watchWalletStatus };