@moon-x/react-sdk 0.5.0 → 0.7.0

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 (3) hide show
  1. package/dist/index.js +213 -153
  2. package/dist/index.mjs +92 -24
  3. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -23432,38 +23432,68 @@ var AuthProvider = function AuthProvider(param) {
23432
23432
  var finalUrl = _react3.useMemo.call(void 0, function() {
23433
23433
  return buildUrl(iframeUrl, _object_spread({
23434
23434
  publishableKey: publishableKey
23435
- }, config), _optionalChain([
23436
- appConfig,
23437
- 'optionalAccess',
23438
- function(_1182) {
23439
- return _1182.enable_captcha;
23440
- }
23441
- ]), // Pass enable_captcha from app config
23442
- _optionalChain([
23443
- appConfig,
23444
- 'optionalAccess',
23445
- function(_1183) {
23446
- return _1183.captcha_sitekey;
23447
- }
23448
- ]));
23435
+ }, config));
23449
23436
  }, [
23450
23437
  iframeUrl,
23451
23438
  publishableKey,
23452
- config,
23453
- _optionalChain([
23454
- appConfig,
23455
- 'optionalAccess',
23456
- function(_1184) {
23457
- return _1184.enable_captcha;
23439
+ config
23440
+ ]);
23441
+ _react3.useEffect.call(void 0, function() {
23442
+ if (typeof document === "undefined") return;
23443
+ var targets = [
23444
+ {
23445
+ origin: _utils.getIframeOrigin.call(void 0, iframeUrl),
23446
+ crossorigin: false
23447
+ },
23448
+ {
23449
+ origin: _utils.getIframeOrigin.call(void 0, _utils.getMoonKeyApiUrl.call(void 0)),
23450
+ crossorigin: true
23458
23451
  }
23459
- ]),
23460
- _optionalChain([
23461
- appConfig,
23462
- 'optionalAccess',
23463
- function(_1185) {
23464
- return _1185.captcha_sitekey;
23452
+ ].filter(function(t) {
23453
+ return !!t.origin;
23454
+ });
23455
+ var added = [];
23456
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
23457
+ try {
23458
+ for(var _iterator = targets[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
23459
+ var _step_value = _step.value, origin = _step_value.origin, crossorigin = _step_value.crossorigin;
23460
+ var sel = 'link[data-moonkey-preconnect="'.concat(origin, '"]');
23461
+ if (document.head.querySelector(sel)) continue;
23462
+ for(var _i = 0, _iter = [
23463
+ "preconnect",
23464
+ "dns-prefetch"
23465
+ ]; _i < _iter.length; _i++){
23466
+ var rel = _iter[_i];
23467
+ var link = document.createElement("link");
23468
+ link.rel = rel;
23469
+ link.href = origin;
23470
+ if (crossorigin && rel === "preconnect") link.crossOrigin = "anonymous";
23471
+ link.setAttribute("data-moonkey-preconnect", origin);
23472
+ document.head.appendChild(link);
23473
+ added.push(link);
23474
+ }
23465
23475
  }
23466
- ])
23476
+ } catch (err) {
23477
+ _didIteratorError = true;
23478
+ _iteratorError = err;
23479
+ } finally{
23480
+ try {
23481
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
23482
+ _iterator.return();
23483
+ }
23484
+ } finally{
23485
+ if (_didIteratorError) {
23486
+ throw _iteratorError;
23487
+ }
23488
+ }
23489
+ }
23490
+ return function() {
23491
+ return added.forEach(function(l) {
23492
+ return l.remove();
23493
+ });
23494
+ };
23495
+ }, [
23496
+ iframeUrl
23467
23497
  ]);
23468
23498
  _react3.useEffect.call(void 0, function() {
23469
23499
  setIsMounted(true);
@@ -23661,12 +23691,12 @@ var AuthProvider = function AuthProvider(param) {
23661
23691
  if (!isIframeReady || !isMounted || !_optionalChain([
23662
23692
  iframeRef,
23663
23693
  'access',
23664
- function(_1186) {
23665
- return _1186.current;
23694
+ function(_1182) {
23695
+ return _1182.current;
23666
23696
  },
23667
23697
  'optionalAccess',
23668
- function(_1187) {
23669
- return _1187.contentWindow;
23698
+ function(_1183) {
23699
+ return _1183.contentWindow;
23670
23700
  }
23671
23701
  ])) {
23672
23702
  return [
@@ -23689,9 +23719,9 @@ var AuthProvider = function AuthProvider(param) {
23689
23719
  case 1:
23690
23720
  _state.trys.push([
23691
23721
  1,
23692
- 5,
23722
+ 6,
23693
23723
  ,
23694
- 6
23724
+ 7
23695
23725
  ]);
23696
23726
  client = createPostMessageClient(iframeRef.current.contentWindow, publishableKey);
23697
23727
  return [
@@ -23705,12 +23735,25 @@ var AuthProvider = function AuthProvider(param) {
23705
23735
  isAuth = _optionalChain([
23706
23736
  response,
23707
23737
  'optionalAccess',
23708
- function(_1188) {
23709
- return _1188.isAuthenticated;
23738
+ function(_1184) {
23739
+ return _1184.isAuthenticated;
23710
23740
  }
23711
23741
  ]) || false;
23712
23742
  userData = null;
23713
23743
  if (!isAuth) return [
23744
+ 3,
23745
+ 5
23746
+ ];
23747
+ rawUserData = _nullishCoalesce(_optionalChain([
23748
+ response,
23749
+ 'optionalAccess',
23750
+ function(_1185) {
23751
+ return _1185.user;
23752
+ }
23753
+ ]), function() {
23754
+ return null;
23755
+ });
23756
+ if (!!rawUserData) return [
23714
23757
  3,
23715
23758
  4
23716
23759
  ];
@@ -23722,18 +23765,20 @@ var AuthProvider = function AuthProvider(param) {
23722
23765
  ];
23723
23766
  case 3:
23724
23767
  rawUserData = _state.sent();
23768
+ _state.label = 4;
23769
+ case 4:
23725
23770
  if (_optionalChain([
23726
23771
  rawUserData,
23727
23772
  'optionalAccess',
23728
- function(_1189) {
23729
- return _1189.id_token;
23773
+ function(_1186) {
23774
+ return _1186.id_token;
23730
23775
  }
23731
23776
  ])) {
23732
23777
  idTokenStorage.set(rawUserData.id_token);
23733
23778
  }
23734
23779
  userData = _lib.sanitizeUserData.call(void 0, rawUserData);
23735
- _state.label = 4;
23736
- case 4:
23780
+ _state.label = 5;
23781
+ case 5:
23737
23782
  authCheckCacheRef.current = {
23738
23783
  timestamp: Date.now(),
23739
23784
  isAuthenticated: isAuth,
@@ -23743,16 +23788,16 @@ var AuthProvider = function AuthProvider(param) {
23743
23788
  setUser(userData);
23744
23789
  return [
23745
23790
  3,
23746
- 6
23791
+ 7
23747
23792
  ];
23748
- case 5:
23793
+ case 6:
23749
23794
  error = _state.sent();
23750
23795
  console.error("Failed to recheck auth status:", error);
23751
23796
  return [
23752
23797
  3,
23753
- 6
23798
+ 7
23754
23799
  ];
23755
- case 6:
23800
+ case 7:
23756
23801
  return [
23757
23802
  2
23758
23803
  ];
@@ -23774,21 +23819,21 @@ var AuthProvider = function AuthProvider(param) {
23774
23819
  var rawUserData = _optionalChain([
23775
23820
  response,
23776
23821
  'optionalAccess',
23777
- function(_1190) {
23778
- return _1190.data;
23822
+ function(_1187) {
23823
+ return _1187.data;
23779
23824
  }
23780
23825
  ]) || response;
23781
23826
  if (_optionalChain([
23782
23827
  rawUserData,
23783
23828
  'optionalAccess',
23784
- function(_1191) {
23785
- return _1191.id_token;
23829
+ function(_1188) {
23830
+ return _1188.id_token;
23786
23831
  }
23787
23832
  ]) || _optionalChain([
23788
23833
  rawUserData,
23789
23834
  'optionalAccess',
23790
- function(_1192) {
23791
- return _1192.idToken;
23835
+ function(_1189) {
23836
+ return _1189.idToken;
23792
23837
  }
23793
23838
  ])) {
23794
23839
  var idToken = rawUserData.id_token || rawUserData.idToken;
@@ -23868,12 +23913,12 @@ var AuthProvider = function AuthProvider(param) {
23868
23913
  if (!isIframeReady || !isMounted || !_optionalChain([
23869
23914
  iframeRef,
23870
23915
  'access',
23871
- function(_1193) {
23872
- return _1193.current;
23916
+ function(_1190) {
23917
+ return _1190.current;
23873
23918
  },
23874
23919
  'optionalAccess',
23875
- function(_1194) {
23876
- return _1194.contentWindow;
23920
+ function(_1191) {
23921
+ return _1191.contentWindow;
23877
23922
  }
23878
23923
  ])) return;
23879
23924
  if (initialAuthCheckDone.current) return;
@@ -23889,9 +23934,9 @@ var AuthProvider = function AuthProvider(param) {
23889
23934
  case 0:
23890
23935
  _state.trys.push([
23891
23936
  0,
23892
- 4,
23937
+ 5,
23893
23938
  ,
23894
- 5
23939
+ 6
23895
23940
  ]);
23896
23941
  initialAuthCheckDone.current = true;
23897
23942
  iframeOrigin = _utils.getIframeOrigin.call(void 0, iframeUrl);
@@ -23907,12 +23952,25 @@ var AuthProvider = function AuthProvider(param) {
23907
23952
  isAuth = _optionalChain([
23908
23953
  response,
23909
23954
  'optionalAccess',
23910
- function(_1195) {
23911
- return _1195.isAuthenticated;
23955
+ function(_1192) {
23956
+ return _1192.isAuthenticated;
23912
23957
  }
23913
23958
  ]) || false;
23914
23959
  userData = null;
23915
23960
  if (!isAuth) return [
23961
+ 3,
23962
+ 4
23963
+ ];
23964
+ rawUserData = _nullishCoalesce(_optionalChain([
23965
+ response,
23966
+ 'optionalAccess',
23967
+ function(_1193) {
23968
+ return _1193.user;
23969
+ }
23970
+ ]), function() {
23971
+ return null;
23972
+ });
23973
+ if (!!rawUserData) return [
23916
23974
  3,
23917
23975
  3
23918
23976
  ];
@@ -23924,18 +23982,20 @@ var AuthProvider = function AuthProvider(param) {
23924
23982
  ];
23925
23983
  case 2:
23926
23984
  rawUserData = _state.sent();
23985
+ _state.label = 3;
23986
+ case 3:
23927
23987
  if (_optionalChain([
23928
23988
  rawUserData,
23929
23989
  'optionalAccess',
23930
- function(_1196) {
23931
- return _1196.id_token;
23990
+ function(_1194) {
23991
+ return _1194.id_token;
23932
23992
  }
23933
23993
  ])) {
23934
23994
  idTokenStorage.set(rawUserData.id_token);
23935
23995
  }
23936
23996
  userData = _lib.sanitizeUserData.call(void 0, rawUserData);
23937
- _state.label = 3;
23938
- case 3:
23997
+ _state.label = 4;
23998
+ case 4:
23939
23999
  authCheckCacheRef.current = {
23940
24000
  timestamp: Date.now(),
23941
24001
  isAuthenticated: isAuth,
@@ -23946,9 +24006,9 @@ var AuthProvider = function AuthProvider(param) {
23946
24006
  setIsReady(true);
23947
24007
  return [
23948
24008
  3,
23949
- 5
24009
+ 6
23950
24010
  ];
23951
- case 4:
24011
+ case 5:
23952
24012
  error = _state.sent();
23953
24013
  console.error("[AuthProvider] Failed to check auth status:", error);
23954
24014
  setIsAuthenticatedWithRef(false);
@@ -23956,9 +24016,9 @@ var AuthProvider = function AuthProvider(param) {
23956
24016
  setIsReady(true);
23957
24017
  return [
23958
24018
  3,
23959
- 5
24019
+ 6
23960
24020
  ];
23961
- case 5:
24021
+ case 6:
23962
24022
  return [
23963
24023
  2
23964
24024
  ];
@@ -24090,8 +24150,8 @@ var AuthProvider = function AuthProvider(param) {
24090
24150
  if (_optionalChain([
24091
24151
  appearance,
24092
24152
  'optionalAccess',
24093
- function(_1197) {
24094
- return _1197.accentColor;
24153
+ function(_1195) {
24154
+ return _1195.accentColor;
24095
24155
  }
24096
24156
  ])) {
24097
24157
  var a = appearance.accentColor;
@@ -24106,8 +24166,8 @@ var AuthProvider = function AuthProvider(param) {
24106
24166
  if (_optionalChain([
24107
24167
  appearance,
24108
24168
  'optionalAccess',
24109
- function(_1198) {
24110
- return _1198.backgroundColor;
24169
+ function(_1196) {
24170
+ return _1196.backgroundColor;
24111
24171
  }
24112
24172
  ])) {
24113
24173
  var bg = appearance.backgroundColor;
@@ -24131,8 +24191,8 @@ var AuthProvider = function AuthProvider(param) {
24131
24191
  var appearanceColors = _nullishCoalesce(_optionalChain([
24132
24192
  appearance,
24133
24193
  'optionalAccess',
24134
- function(_1199) {
24135
- return _1199.colors;
24194
+ function(_1197) {
24195
+ return _1197.colors;
24136
24196
  }
24137
24197
  ]), function() {
24138
24198
  return {};
@@ -24173,8 +24233,8 @@ var AuthProvider = function AuthProvider(param) {
24173
24233
  if (!_optionalChain([
24174
24234
  appearance,
24175
24235
  'optionalAccess',
24176
- function(_1200) {
24177
- return _1200.borderRadius;
24236
+ function(_1198) {
24237
+ return _1198.borderRadius;
24178
24238
  }
24179
24239
  ])) return {};
24180
24240
  if (typeof appearance.borderRadius === "string") {
@@ -24190,12 +24250,12 @@ var AuthProvider = function AuthProvider(param) {
24190
24250
  colors: _object_spread({}, baseThemeColors, derived, appearanceColors, _optionalChain([
24191
24251
  config,
24192
24252
  'optionalAccess',
24193
- function(_1201) {
24194
- return _1201.theme;
24253
+ function(_1199) {
24254
+ return _1199.theme;
24195
24255
  },
24196
24256
  'optionalAccess',
24197
- function(_1202) {
24198
- return _1202.colors;
24257
+ function(_1200) {
24258
+ return _1200.colors;
24199
24259
  }
24200
24260
  ])),
24201
24261
  borderRadius: _object_spread({
@@ -24206,30 +24266,30 @@ var AuthProvider = function AuthProvider(param) {
24206
24266
  }, appearanceBorderRadius, _optionalChain([
24207
24267
  config,
24208
24268
  'optionalAccess',
24209
- function(_1203) {
24210
- return _1203.theme;
24269
+ function(_1201) {
24270
+ return _1201.theme;
24211
24271
  },
24212
24272
  'optionalAccess',
24213
- function(_1204) {
24214
- return _1204.borderRadius;
24273
+ function(_1202) {
24274
+ return _1202.borderRadius;
24215
24275
  }
24216
24276
  ])),
24217
24277
  fontFamily: _nullishCoalesce(_nullishCoalesce(_optionalChain([
24218
24278
  config,
24219
24279
  'optionalAccess',
24220
- function(_1205) {
24221
- return _1205.theme;
24280
+ function(_1203) {
24281
+ return _1203.theme;
24222
24282
  },
24223
24283
  'optionalAccess',
24224
- function(_1206) {
24225
- return _1206.fontFamily;
24284
+ function(_1204) {
24285
+ return _1204.fontFamily;
24226
24286
  }
24227
24287
  ]), function() {
24228
24288
  return _optionalChain([
24229
24289
  appearance,
24230
24290
  'optionalAccess',
24231
- function(_1207) {
24232
- return _1207.fontFamily;
24291
+ function(_1205) {
24292
+ return _1205.fontFamily;
24233
24293
  }
24234
24294
  ]);
24235
24295
  }), function() {
@@ -24377,14 +24437,14 @@ var MoonKeyProvider = function MoonKeyProvider(param) {
24377
24437
  if (_optionalChain([
24378
24438
  config,
24379
24439
  'optionalAccess',
24380
- function(_1208) {
24381
- return _1208.defaultChain;
24440
+ function(_1206) {
24441
+ return _1206.defaultChain;
24382
24442
  }
24383
24443
  ]) || _optionalChain([
24384
24444
  config,
24385
24445
  'optionalAccess',
24386
- function(_1209) {
24387
- return _1209.supportedChains;
24446
+ function(_1207) {
24447
+ return _1207.supportedChains;
24388
24448
  }
24389
24449
  ])) {
24390
24450
  _lib.validateChainConfig.call(void 0, {
@@ -24399,12 +24459,12 @@ var MoonKeyProvider = function MoonKeyProvider(param) {
24399
24459
  if (!_optionalChain([
24400
24460
  config,
24401
24461
  'optionalAccess',
24402
- function(_1210) {
24403
- return _1210.walletConnect;
24462
+ function(_1208) {
24463
+ return _1208.walletConnect;
24404
24464
  },
24405
24465
  'optionalAccess',
24406
- function(_1211) {
24407
- return _1211.projectId;
24466
+ function(_1209) {
24467
+ return _1209.projectId;
24408
24468
  }
24409
24469
  ])) {
24410
24470
  return;
@@ -24429,12 +24489,12 @@ var MoonKeyProvider = function MoonKeyProvider(param) {
24429
24489
  projectId = _optionalChain([
24430
24490
  config,
24431
24491
  'optionalAccess',
24432
- function(_1212) {
24433
- return _1212.walletConnect;
24492
+ function(_1210) {
24493
+ return _1210.walletConnect;
24434
24494
  },
24435
24495
  'optionalAccess',
24436
- function(_1213) {
24437
- return _1213.projectId;
24496
+ function(_1211) {
24497
+ return _1211.projectId;
24438
24498
  }
24439
24499
  ]);
24440
24500
  if (!projectId) {
@@ -24496,12 +24556,12 @@ var MoonKeyProvider = function MoonKeyProvider(param) {
24496
24556
  _optionalChain([
24497
24557
  config,
24498
24558
  'optionalAccess',
24499
- function(_1214) {
24500
- return _1214.walletConnect;
24559
+ function(_1212) {
24560
+ return _1212.walletConnect;
24501
24561
  },
24502
24562
  'optionalAccess',
24503
- function(_1215) {
24504
- return _1215.projectId;
24563
+ function(_1213) {
24564
+ return _1213.projectId;
24505
24565
  }
24506
24566
  ])
24507
24567
  ]);
@@ -24512,15 +24572,15 @@ var MoonKeyProvider = function MoonKeyProvider(param) {
24512
24572
  appearance: _optionalChain([
24513
24573
  config,
24514
24574
  'optionalAccess',
24515
- function(_1216) {
24516
- return _1216.appearance;
24575
+ function(_1214) {
24576
+ return _1214.appearance;
24517
24577
  }
24518
24578
  ]),
24519
24579
  loginMethods: _optionalChain([
24520
24580
  config,
24521
24581
  'optionalAccess',
24522
- function(_1217) {
24523
- return _1217.loginMethods;
24582
+ function(_1215) {
24583
+ return _1215.loginMethods;
24524
24584
  }
24525
24585
  ]) || [
24526
24586
  "email"
@@ -24528,143 +24588,143 @@ var MoonKeyProvider = function MoonKeyProvider(param) {
24528
24588
  prefill: _optionalChain([
24529
24589
  config,
24530
24590
  'optionalAccess',
24531
- function(_1218) {
24532
- return _1218.prefill;
24591
+ function(_1216) {
24592
+ return _1216.prefill;
24533
24593
  }
24534
24594
  ]),
24535
24595
  walletChainType: _optionalChain([
24536
24596
  config,
24537
24597
  'optionalAccess',
24538
- function(_1219) {
24539
- return _1219.walletChainType;
24598
+ function(_1217) {
24599
+ return _1217.walletChainType;
24540
24600
  }
24541
24601
  ]),
24542
24602
  isDark: _optionalChain([
24543
24603
  config,
24544
24604
  'optionalAccess',
24545
- function(_1220) {
24546
- return _1220.isDark;
24605
+ function(_1218) {
24606
+ return _1218.isDark;
24547
24607
  }
24548
24608
  ]),
24549
24609
  theme: _optionalChain([
24550
24610
  config,
24551
24611
  'optionalAccess',
24552
- function(_1221) {
24553
- return _1221.theme;
24612
+ function(_1219) {
24613
+ return _1219.theme;
24554
24614
  }
24555
24615
  ]),
24556
24616
  emailConfig: {
24557
24617
  skipVerifiedSuccess: _optionalChain([
24558
24618
  config,
24559
24619
  'optionalAccess',
24560
- function(_1222) {
24561
- return _1222.emailConfig;
24620
+ function(_1220) {
24621
+ return _1220.emailConfig;
24562
24622
  },
24563
24623
  'optionalAccess',
24564
- function(_1223) {
24565
- return _1223.skipVerifiedSuccess;
24624
+ function(_1221) {
24625
+ return _1221.skipVerifiedSuccess;
24566
24626
  }
24567
24627
  ]) || false,
24568
24628
  verifiedDisplayTime: _optionalChain([
24569
24629
  config,
24570
24630
  'optionalAccess',
24571
- function(_1224) {
24572
- return _1224.emailConfig;
24631
+ function(_1222) {
24632
+ return _1222.emailConfig;
24573
24633
  },
24574
24634
  'optionalAccess',
24575
- function(_1225) {
24576
- return _1225.verifiedDisplayTime;
24635
+ function(_1223) {
24636
+ return _1223.verifiedDisplayTime;
24577
24637
  }
24578
24638
  ]) || 3e3,
24579
24639
  verifyEmailTitle: _optionalChain([
24580
24640
  config,
24581
24641
  'optionalAccess',
24582
- function(_1226) {
24583
- return _1226.emailConfig;
24642
+ function(_1224) {
24643
+ return _1224.emailConfig;
24584
24644
  },
24585
24645
  'optionalAccess',
24586
- function(_1227) {
24587
- return _1227.verifyEmailTitle;
24646
+ function(_1225) {
24647
+ return _1225.verifyEmailTitle;
24588
24648
  }
24589
24649
  ]) || "Verify email",
24590
24650
  verifyEmailResendTitle: _optionalChain([
24591
24651
  config,
24592
24652
  'optionalAccess',
24593
- function(_1228) {
24594
- return _1228.emailConfig;
24653
+ function(_1226) {
24654
+ return _1226.emailConfig;
24595
24655
  },
24596
24656
  'optionalAccess',
24597
- function(_1229) {
24598
- return _1229.verifyEmailResendTitle;
24657
+ function(_1227) {
24658
+ return _1227.verifyEmailResendTitle;
24599
24659
  }
24600
24660
  ]) || "Resend code",
24601
24661
  resendCodeTime: _optionalChain([
24602
24662
  config,
24603
24663
  'optionalAccess',
24604
- function(_1230) {
24605
- return _1230.emailConfig;
24664
+ function(_1228) {
24665
+ return _1228.emailConfig;
24606
24666
  },
24607
24667
  'optionalAccess',
24608
- function(_1231) {
24609
- return _1231.resendCodeTime;
24668
+ function(_1229) {
24669
+ return _1229.resendCodeTime;
24610
24670
  }
24611
24671
  ]) || 60
24612
24672
  },
24613
24673
  passkeyEnrollConfig: _optionalChain([
24614
24674
  config,
24615
24675
  'optionalAccess',
24616
- function(_1232) {
24617
- return _1232.passkeyEnrollConfig;
24676
+ function(_1230) {
24677
+ return _1230.passkeyEnrollConfig;
24618
24678
  }
24619
24679
  ]),
24620
24680
  signMessageConfig: _optionalChain([
24621
24681
  config,
24622
24682
  'optionalAccess',
24623
- function(_1233) {
24624
- return _1233.signMessageConfig;
24683
+ function(_1231) {
24684
+ return _1231.signMessageConfig;
24625
24685
  }
24626
24686
  ]),
24627
24687
  exportKeyConfig: _optionalChain([
24628
24688
  config,
24629
24689
  'optionalAccess',
24630
- function(_1234) {
24631
- return _1234.exportKeyConfig;
24690
+ function(_1232) {
24691
+ return _1232.exportKeyConfig;
24632
24692
  }
24633
24693
  ]),
24634
24694
  signTransactionConfig: _optionalChain([
24635
24695
  config,
24636
24696
  'optionalAccess',
24637
- function(_1235) {
24638
- return _1235.signTransactionConfig;
24697
+ function(_1233) {
24698
+ return _1233.signTransactionConfig;
24639
24699
  }
24640
24700
  ]),
24641
24701
  sendTransactionConfig: _optionalChain([
24642
24702
  config,
24643
24703
  'optionalAccess',
24644
- function(_1236) {
24645
- return _1236.sendTransactionConfig;
24704
+ function(_1234) {
24705
+ return _1234.sendTransactionConfig;
24646
24706
  }
24647
24707
  ]),
24648
24708
  solana: _optionalChain([
24649
24709
  config,
24650
24710
  'optionalAccess',
24651
- function(_1237) {
24652
- return _1237.solana;
24711
+ function(_1235) {
24712
+ return _1235.solana;
24653
24713
  }
24654
24714
  ]),
24655
24715
  ethereum: {
24656
24716
  defaultChain: _optionalChain([
24657
24717
  config,
24658
24718
  'optionalAccess',
24659
- function(_1238) {
24660
- return _1238.defaultChain;
24719
+ function(_1236) {
24720
+ return _1236.defaultChain;
24661
24721
  }
24662
24722
  ]),
24663
24723
  supportedChains: _optionalChain([
24664
24724
  config,
24665
24725
  'optionalAccess',
24666
- function(_1239) {
24667
- return _1239.supportedChains;
24726
+ function(_1237) {
24727
+ return _1237.supportedChains;
24668
24728
  }
24669
24729
  ])
24670
24730
  }
@@ -24724,8 +24784,8 @@ var requiresReconnection = function requiresReconnection(error) {
24724
24784
  return _instanceof(error, SessionExpiredError) || _instanceof(error, SessionNotFoundError) || _optionalChain([
24725
24785
  error,
24726
24786
  'optionalAccess',
24727
- function(_1240) {
24728
- return _1240.requiresReconnection;
24787
+ function(_1238) {
24788
+ return _1238.requiresReconnection;
24729
24789
  }
24730
24790
  ]) === true;
24731
24791
  };
package/dist/index.mjs CHANGED
@@ -850,7 +850,7 @@ var useMoonKey = function useMoonKey() {
850
850
  };
851
851
  };
852
852
  // src/components/auth-provider.tsx
853
- import { getIframeOrigin as getIframeOrigin2, getIframeUrl as getIframeUrl3, PostMessageClient as PostMessageClient10, PostMessageMethod as PostMessageMethod28, PostMessageType as PostMessageType29 } from "@moon-x/core/utils";
853
+ import { getIframeOrigin as getIframeOrigin2, getIframeUrl as getIframeUrl3, getMoonKeyApiUrl, PostMessageClient as PostMessageClient10, PostMessageMethod as PostMessageMethod28, PostMessageType as PostMessageType29 } from "@moon-x/core/utils";
854
854
  import { useCallback as useCallback11, useEffect as useEffect36, useMemo as useMemo4, useRef as useRef18, useState as useState52 } from "react";
855
855
  import { createPortal as createPortal2 } from "react-dom";
856
856
  // src/hooks/use-close-iframe.ts
@@ -17648,14 +17648,68 @@ var AuthProvider = function AuthProvider(param) {
17648
17648
  var finalUrl = useMemo4(function() {
17649
17649
  return buildUrl(iframeUrl, _object_spread({
17650
17650
  publishableKey: publishableKey
17651
- }, config), appConfig === null || appConfig === void 0 ? void 0 : appConfig.enable_captcha, // Pass enable_captcha from app config
17652
- appConfig === null || appConfig === void 0 ? void 0 : appConfig.captcha_sitekey);
17651
+ }, config));
17653
17652
  }, [
17654
17653
  iframeUrl,
17655
17654
  publishableKey,
17656
- config,
17657
- appConfig === null || appConfig === void 0 ? void 0 : appConfig.enable_captcha,
17658
- appConfig === null || appConfig === void 0 ? void 0 : appConfig.captcha_sitekey
17655
+ config
17656
+ ]);
17657
+ useEffect36(function() {
17658
+ if (typeof document === "undefined") return;
17659
+ var targets = [
17660
+ {
17661
+ origin: getIframeOrigin2(iframeUrl),
17662
+ crossorigin: false
17663
+ },
17664
+ {
17665
+ origin: getIframeOrigin2(getMoonKeyApiUrl()),
17666
+ crossorigin: true
17667
+ }
17668
+ ].filter(function(t) {
17669
+ return !!t.origin;
17670
+ });
17671
+ var added = [];
17672
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
17673
+ try {
17674
+ for(var _iterator = targets[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
17675
+ var _step_value = _step.value, origin = _step_value.origin, crossorigin = _step_value.crossorigin;
17676
+ var sel = 'link[data-moonkey-preconnect="'.concat(origin, '"]');
17677
+ if (document.head.querySelector(sel)) continue;
17678
+ for(var _i = 0, _iter = [
17679
+ "preconnect",
17680
+ "dns-prefetch"
17681
+ ]; _i < _iter.length; _i++){
17682
+ var rel = _iter[_i];
17683
+ var link = document.createElement("link");
17684
+ link.rel = rel;
17685
+ link.href = origin;
17686
+ if (crossorigin && rel === "preconnect") link.crossOrigin = "anonymous";
17687
+ link.setAttribute("data-moonkey-preconnect", origin);
17688
+ document.head.appendChild(link);
17689
+ added.push(link);
17690
+ }
17691
+ }
17692
+ } catch (err) {
17693
+ _didIteratorError = true;
17694
+ _iteratorError = err;
17695
+ } finally{
17696
+ try {
17697
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
17698
+ _iterator.return();
17699
+ }
17700
+ } finally{
17701
+ if (_didIteratorError) {
17702
+ throw _iteratorError;
17703
+ }
17704
+ }
17705
+ }
17706
+ return function() {
17707
+ return added.forEach(function(l) {
17708
+ return l.remove();
17709
+ });
17710
+ };
17711
+ }, [
17712
+ iframeUrl
17659
17713
  ]);
17660
17714
  useEffect36(function() {
17661
17715
  setIsMounted(true);
@@ -17846,7 +17900,7 @@ var AuthProvider = function AuthProvider(param) {
17846
17900
  var recheckAuthStatus = useCallback11(function() {
17847
17901
  var forceRefresh = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
17848
17902
  return _async_to_generator(function() {
17849
- var _iframeRef_current, now, cacheAge, cachedAuth, client, response, isAuth, userData, rawUserData, error;
17903
+ var _iframeRef_current, now, cacheAge, cachedAuth, client, response, isAuth, userData, _ref, rawUserData, error;
17850
17904
  return _ts_generator(this, function(_state) {
17851
17905
  switch(_state.label){
17852
17906
  case 0:
@@ -17871,9 +17925,9 @@ var AuthProvider = function AuthProvider(param) {
17871
17925
  case 1:
17872
17926
  _state.trys.push([
17873
17927
  1,
17874
- 5,
17928
+ 6,
17875
17929
  ,
17876
- 6
17930
+ 7
17877
17931
  ]);
17878
17932
  client = createPostMessageClient(iframeRef.current.contentWindow, publishableKey);
17879
17933
  return [
@@ -17887,6 +17941,11 @@ var AuthProvider = function AuthProvider(param) {
17887
17941
  isAuth = (response === null || response === void 0 ? void 0 : response.isAuthenticated) || false;
17888
17942
  userData = null;
17889
17943
  if (!isAuth) return [
17944
+ 3,
17945
+ 5
17946
+ ];
17947
+ rawUserData = (_ref = response === null || response === void 0 ? void 0 : response.user) !== null && _ref !== void 0 ? _ref : null;
17948
+ if (!!rawUserData) return [
17890
17949
  3,
17891
17950
  4
17892
17951
  ];
@@ -17898,12 +17957,14 @@ var AuthProvider = function AuthProvider(param) {
17898
17957
  ];
17899
17958
  case 3:
17900
17959
  rawUserData = _state.sent();
17960
+ _state.label = 4;
17961
+ case 4:
17901
17962
  if (rawUserData === null || rawUserData === void 0 ? void 0 : rawUserData.id_token) {
17902
17963
  idTokenStorage.set(rawUserData.id_token);
17903
17964
  }
17904
17965
  userData = sanitizeUserData(rawUserData);
17905
- _state.label = 4;
17906
- case 4:
17966
+ _state.label = 5;
17967
+ case 5:
17907
17968
  authCheckCacheRef.current = {
17908
17969
  timestamp: Date.now(),
17909
17970
  isAuthenticated: isAuth,
@@ -17913,16 +17974,16 @@ var AuthProvider = function AuthProvider(param) {
17913
17974
  setUser(userData);
17914
17975
  return [
17915
17976
  3,
17916
- 6
17977
+ 7
17917
17978
  ];
17918
- case 5:
17979
+ case 6:
17919
17980
  error = _state.sent();
17920
17981
  console.error("Failed to recheck auth status:", error);
17921
17982
  return [
17922
17983
  3,
17923
- 6
17984
+ 7
17924
17985
  ];
17925
- case 6:
17986
+ case 7:
17926
17987
  return [
17927
17988
  2
17928
17989
  ];
@@ -18026,15 +18087,15 @@ var AuthProvider = function AuthProvider(param) {
18026
18087
  }
18027
18088
  var checkAuthStatus = function checkAuthStatus() {
18028
18089
  return _async_to_generator(function() {
18029
- var iframeOrigin, client, response, isAuth, userData, rawUserData, error;
18090
+ var iframeOrigin, client, response, isAuth, userData, _ref, rawUserData, error;
18030
18091
  return _ts_generator(this, function(_state) {
18031
18092
  switch(_state.label){
18032
18093
  case 0:
18033
18094
  _state.trys.push([
18034
18095
  0,
18035
- 4,
18096
+ 5,
18036
18097
  ,
18037
- 5
18098
+ 6
18038
18099
  ]);
18039
18100
  initialAuthCheckDone.current = true;
18040
18101
  iframeOrigin = getIframeOrigin2(iframeUrl);
@@ -18050,6 +18111,11 @@ var AuthProvider = function AuthProvider(param) {
18050
18111
  isAuth = (response === null || response === void 0 ? void 0 : response.isAuthenticated) || false;
18051
18112
  userData = null;
18052
18113
  if (!isAuth) return [
18114
+ 3,
18115
+ 4
18116
+ ];
18117
+ rawUserData = (_ref = response === null || response === void 0 ? void 0 : response.user) !== null && _ref !== void 0 ? _ref : null;
18118
+ if (!!rawUserData) return [
18053
18119
  3,
18054
18120
  3
18055
18121
  ];
@@ -18061,12 +18127,14 @@ var AuthProvider = function AuthProvider(param) {
18061
18127
  ];
18062
18128
  case 2:
18063
18129
  rawUserData = _state.sent();
18130
+ _state.label = 3;
18131
+ case 3:
18064
18132
  if (rawUserData === null || rawUserData === void 0 ? void 0 : rawUserData.id_token) {
18065
18133
  idTokenStorage.set(rawUserData.id_token);
18066
18134
  }
18067
18135
  userData = sanitizeUserData(rawUserData);
18068
- _state.label = 3;
18069
- case 3:
18136
+ _state.label = 4;
18137
+ case 4:
18070
18138
  authCheckCacheRef.current = {
18071
18139
  timestamp: Date.now(),
18072
18140
  isAuthenticated: isAuth,
@@ -18077,9 +18145,9 @@ var AuthProvider = function AuthProvider(param) {
18077
18145
  setIsReady(true);
18078
18146
  return [
18079
18147
  3,
18080
- 5
18148
+ 6
18081
18149
  ];
18082
- case 4:
18150
+ case 5:
18083
18151
  error = _state.sent();
18084
18152
  console.error("[AuthProvider] Failed to check auth status:", error);
18085
18153
  setIsAuthenticatedWithRef(false);
@@ -18087,9 +18155,9 @@ var AuthProvider = function AuthProvider(param) {
18087
18155
  setIsReady(true);
18088
18156
  return [
18089
18157
  3,
18090
- 5
18158
+ 6
18091
18159
  ];
18092
- case 5:
18160
+ case 6:
18093
18161
  return [
18094
18162
  2
18095
18163
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moon-x/react-sdk",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "description": "React authentication hooks and components for MoonKey",
5
5
  "license": "UNLICENSED",
6
6
  "main": "dist/index.js",
@@ -52,7 +52,7 @@
52
52
  "tweetnacl": "1.0.3",
53
53
  "viem": "^2.38.2",
54
54
  "wagmi": "^2.18.1",
55
- "@moon-x/core": "0.7.0"
55
+ "@moon-x/core": "0.9.0"
56
56
  },
57
57
  "devDependencies": {
58
58
  "tsup": "^8.0.0",