@moon-x/react-native-sdk 0.15.1 → 0.15.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ethereum.mjs CHANGED
@@ -162,13 +162,15 @@ import { PostMessageMethod as PostMessageMethod3, PostMessageType as PostMessage
162
162
 
163
163
  // src/transport/webview-bridge.ts
164
164
  import {
165
- FORWARDED_ERROR_FIELDS
165
+ FORWARDED_ERROR_FIELDS,
166
+ getPostMessageRequestTimeout,
167
+ POST_MESSAGE_REQUEST_TIMEOUT_MS
166
168
  } from "@moon-x/core/utils";
167
169
 
168
170
  // src/provider.tsx
169
171
  import { SDKProvider } from "@moon-x/core/react";
170
172
  import { validatePublishableKey } from "@moon-x/core/lib";
171
- import { jsx, jsxs } from "react/jsx-runtime";
173
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
172
174
  var MoonXContext = createContext(null);
173
175
  var useMoonXContext = () => {
174
176
  const ctx = useContext(MoonXContext);
package/dist/index.js CHANGED
@@ -428,7 +428,6 @@ var import_utils4 = require("@moon-x/core/utils");
428
428
 
429
429
  // src/transport/webview-bridge.ts
430
430
  var import_utils3 = require("@moon-x/core/utils");
431
- var REQUEST_TIMEOUT_MS = 3e4;
432
431
  var RETRYABLE_METHODS = /* @__PURE__ */ new Set([
433
432
  "GET_APP_CONFIG",
434
433
  "GET_BALANCE",
@@ -442,7 +441,11 @@ var RETRYABLE_METHODS = /* @__PURE__ */ new Set([
442
441
  "GET_DEK_INFO",
443
442
  "LIST_EPHEMERAL_SIGNERS"
444
443
  ]);
445
- var RETRY_ATTEMPT_TIMEOUTS_MS = [5e3, 1e4, REQUEST_TIMEOUT_MS];
444
+ var RETRY_ATTEMPT_TIMEOUTS_MS = [
445
+ 5e3,
446
+ 1e4,
447
+ import_utils3.POST_MESSAGE_REQUEST_TIMEOUT_MS
448
+ ];
446
449
  var RETRY_BACKOFF_MS = [200, 400];
447
450
  var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
448
451
  var TimeoutError = class extends Error {
@@ -584,7 +587,7 @@ var WebViewBridge = class {
584
587
  type,
585
588
  method,
586
589
  payload,
587
- REQUEST_TIMEOUT_MS
590
+ (0, import_utils3.getPostMessageRequestTimeout)(method)
588
591
  );
589
592
  }
590
593
  let lastError;
@@ -753,7 +756,9 @@ var MoonXProvider = ({
753
756
  [bridge, publishableKey, relyingPartyOrigin]
754
757
  );
755
758
  const [sensitiveVisible, setSensitiveVisible] = (0, import_react.useState)(false);
759
+ const [captchaChallengeVisible, setCaptchaChallengeVisible] = (0, import_react.useState)(false);
756
760
  const cancelRef = (0, import_react.useRef)(null);
761
+ const webViewVisible = sensitiveVisible || captchaChallengeVisible;
757
762
  const [
758
763
  {
759
764
  ready,
@@ -801,17 +806,17 @@ var MoonXProvider = ({
801
806
  (0, import_react.useEffect)(() => {
802
807
  import_react_native.Animated.parallel([
803
808
  import_react_native.Animated.timing(sheetTranslateY, {
804
- toValue: sensitiveVisible ? 0 : screenHeight,
809
+ toValue: webViewVisible ? 0 : screenHeight,
805
810
  duration: 280,
806
811
  useNativeDriver: true
807
812
  }),
808
813
  import_react_native.Animated.timing(backdropOpacity, {
809
- toValue: sensitiveVisible ? 0.5 : 0,
814
+ toValue: webViewVisible ? 0.5 : 0,
810
815
  duration: 280,
811
816
  useNativeDriver: true
812
817
  })
813
818
  ]).start();
814
- }, [sensitiveVisible, sheetTranslateY, backdropOpacity, screenHeight]);
819
+ }, [webViewVisible, sheetTranslateY, backdropOpacity, screenHeight]);
815
820
  const initialSourceUri = (0, import_react.useMemo)(() => {
816
821
  const base = iframeUrl.replace(/\/$/, "");
817
822
  const sep = base.includes("?") ? "&" : "?";
@@ -925,6 +930,18 @@ var MoonXProvider = ({
925
930
  bridge.cleanup("provider_unmounted");
926
931
  };
927
932
  }, [bridge]);
933
+ (0, import_react.useEffect)(
934
+ () => bridge.register(
935
+ import_utils4.PostMessageType.INIT,
936
+ import_utils4.PostMessageMethod.CAPTCHA_CHALLENGE_VISIBILITY,
937
+ (payload) => {
938
+ if (typeof payload?.visible === "boolean") {
939
+ setCaptchaChallengeVisible(payload.visible);
940
+ }
941
+ }
942
+ ),
943
+ [bridge]
944
+ );
928
945
  (0, import_react.useEffect)(() => {
929
946
  const unsubscribe = bridge.onResponseError((error) => {
930
947
  sessionRevalidationGate.request({
@@ -1036,12 +1053,14 @@ var MoonXProvider = ({
1036
1053
  import_react_native.Animated.View,
1037
1054
  {
1038
1055
  style: [styles.backdrop, { opacity: backdropOpacity }],
1039
- pointerEvents: sensitiveVisible ? "auto" : "none",
1056
+ pointerEvents: webViewVisible ? "auto" : "none",
1040
1057
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1041
1058
  import_react_native.Pressable,
1042
1059
  {
1043
1060
  style: import_react_native.StyleSheet.absoluteFill,
1044
- onPress: () => cancelRef.current?.()
1061
+ onPress: () => {
1062
+ if (sensitiveVisible) cancelRef.current?.();
1063
+ }
1045
1064
  }
1046
1065
  )
1047
1066
  }
@@ -1052,24 +1071,26 @@ var MoonXProvider = ({
1052
1071
  style: [
1053
1072
  styles.sheetContainer,
1054
1073
  {
1055
- top: SHEET_TOP_OFFSET,
1074
+ top: captchaChallengeVisible ? 0 : SHEET_TOP_OFFSET,
1056
1075
  transform: [{ translateY: sheetTranslateY }]
1057
1076
  }
1058
1077
  ],
1059
- pointerEvents: sensitiveVisible ? "auto" : "none",
1078
+ pointerEvents: webViewVisible ? "auto" : "none",
1060
1079
  children: [
1061
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.View, { style: styles.sheetGrabber }),
1062
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native.View, { style: styles.modalChrome, children: [
1063
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.View, { style: styles.modalTitleSpacer }),
1064
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1065
- import_react_native.Pressable,
1066
- {
1067
- onPress: () => cancelRef.current?.(),
1068
- hitSlop: 12,
1069
- style: styles.closeButton,
1070
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.Text, { style: styles.closeButtonText, children: closeLabel })
1071
- }
1072
- )
1080
+ sensitiveVisible && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
1081
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.View, { style: styles.sheetGrabber }),
1082
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native.View, { style: styles.modalChrome, children: [
1083
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.View, { style: styles.modalTitleSpacer }),
1084
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1085
+ import_react_native.Pressable,
1086
+ {
1087
+ onPress: () => cancelRef.current?.(),
1088
+ hitSlop: 12,
1089
+ style: styles.closeButton,
1090
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.Text, { style: styles.closeButtonText, children: closeLabel })
1091
+ }
1092
+ )
1093
+ ] })
1073
1094
  ] }),
1074
1095
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1075
1096
  import_react_native_webview.WebView,
package/dist/index.mjs CHANGED
@@ -399,9 +399,10 @@ import { PostMessageMethod as PostMessageMethod3, PostMessageType as PostMessage
399
399
 
400
400
  // src/transport/webview-bridge.ts
401
401
  import {
402
- FORWARDED_ERROR_FIELDS
402
+ FORWARDED_ERROR_FIELDS,
403
+ getPostMessageRequestTimeout,
404
+ POST_MESSAGE_REQUEST_TIMEOUT_MS
403
405
  } from "@moon-x/core/utils";
404
- var REQUEST_TIMEOUT_MS = 3e4;
405
406
  var RETRYABLE_METHODS = /* @__PURE__ */ new Set([
406
407
  "GET_APP_CONFIG",
407
408
  "GET_BALANCE",
@@ -415,7 +416,11 @@ var RETRYABLE_METHODS = /* @__PURE__ */ new Set([
415
416
  "GET_DEK_INFO",
416
417
  "LIST_EPHEMERAL_SIGNERS"
417
418
  ]);
418
- var RETRY_ATTEMPT_TIMEOUTS_MS = [5e3, 1e4, REQUEST_TIMEOUT_MS];
419
+ var RETRY_ATTEMPT_TIMEOUTS_MS = [
420
+ 5e3,
421
+ 1e4,
422
+ POST_MESSAGE_REQUEST_TIMEOUT_MS
423
+ ];
419
424
  var RETRY_BACKOFF_MS = [200, 400];
420
425
  var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
421
426
  var TimeoutError = class extends Error {
@@ -557,7 +562,7 @@ var WebViewBridge = class {
557
562
  type,
558
563
  method,
559
564
  payload,
560
- REQUEST_TIMEOUT_MS
565
+ getPostMessageRequestTimeout(method)
561
566
  );
562
567
  }
563
568
  let lastError;
@@ -703,7 +708,7 @@ var createSessionRevalidationGate = () => {
703
708
  };
704
709
 
705
710
  // src/provider.tsx
706
- import { jsx, jsxs } from "react/jsx-runtime";
711
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
707
712
  var DEFAULT_IFRAME_URL = "https://iframe.moonx-dev.com";
708
713
  var MoonXContext = createContext(null);
709
714
  var MoonXProvider = ({
@@ -726,7 +731,9 @@ var MoonXProvider = ({
726
731
  [bridge, publishableKey, relyingPartyOrigin]
727
732
  );
728
733
  const [sensitiveVisible, setSensitiveVisible] = useState(false);
734
+ const [captchaChallengeVisible, setCaptchaChallengeVisible] = useState(false);
729
735
  const cancelRef = useRef(null);
736
+ const webViewVisible = sensitiveVisible || captchaChallengeVisible;
730
737
  const [
731
738
  {
732
739
  ready,
@@ -774,17 +781,17 @@ var MoonXProvider = ({
774
781
  useEffect(() => {
775
782
  Animated.parallel([
776
783
  Animated.timing(sheetTranslateY, {
777
- toValue: sensitiveVisible ? 0 : screenHeight,
784
+ toValue: webViewVisible ? 0 : screenHeight,
778
785
  duration: 280,
779
786
  useNativeDriver: true
780
787
  }),
781
788
  Animated.timing(backdropOpacity, {
782
- toValue: sensitiveVisible ? 0.5 : 0,
789
+ toValue: webViewVisible ? 0.5 : 0,
783
790
  duration: 280,
784
791
  useNativeDriver: true
785
792
  })
786
793
  ]).start();
787
- }, [sensitiveVisible, sheetTranslateY, backdropOpacity, screenHeight]);
794
+ }, [webViewVisible, sheetTranslateY, backdropOpacity, screenHeight]);
788
795
  const initialSourceUri = useMemo(() => {
789
796
  const base = iframeUrl.replace(/\/$/, "");
790
797
  const sep = base.includes("?") ? "&" : "?";
@@ -898,6 +905,18 @@ var MoonXProvider = ({
898
905
  bridge.cleanup("provider_unmounted");
899
906
  };
900
907
  }, [bridge]);
908
+ useEffect(
909
+ () => bridge.register(
910
+ PostMessageType3.INIT,
911
+ PostMessageMethod3.CAPTCHA_CHALLENGE_VISIBILITY,
912
+ (payload) => {
913
+ if (typeof payload?.visible === "boolean") {
914
+ setCaptchaChallengeVisible(payload.visible);
915
+ }
916
+ }
917
+ ),
918
+ [bridge]
919
+ );
901
920
  useEffect(() => {
902
921
  const unsubscribe = bridge.onResponseError((error) => {
903
922
  sessionRevalidationGate.request({
@@ -1009,12 +1028,14 @@ var MoonXProvider = ({
1009
1028
  Animated.View,
1010
1029
  {
1011
1030
  style: [styles.backdrop, { opacity: backdropOpacity }],
1012
- pointerEvents: sensitiveVisible ? "auto" : "none",
1031
+ pointerEvents: webViewVisible ? "auto" : "none",
1013
1032
  children: /* @__PURE__ */ jsx(
1014
1033
  Pressable,
1015
1034
  {
1016
1035
  style: StyleSheet.absoluteFill,
1017
- onPress: () => cancelRef.current?.()
1036
+ onPress: () => {
1037
+ if (sensitiveVisible) cancelRef.current?.();
1038
+ }
1018
1039
  }
1019
1040
  )
1020
1041
  }
@@ -1025,24 +1046,26 @@ var MoonXProvider = ({
1025
1046
  style: [
1026
1047
  styles.sheetContainer,
1027
1048
  {
1028
- top: SHEET_TOP_OFFSET,
1049
+ top: captchaChallengeVisible ? 0 : SHEET_TOP_OFFSET,
1029
1050
  transform: [{ translateY: sheetTranslateY }]
1030
1051
  }
1031
1052
  ],
1032
- pointerEvents: sensitiveVisible ? "auto" : "none",
1053
+ pointerEvents: webViewVisible ? "auto" : "none",
1033
1054
  children: [
1034
- /* @__PURE__ */ jsx(View, { style: styles.sheetGrabber }),
1035
- /* @__PURE__ */ jsxs(View, { style: styles.modalChrome, children: [
1036
- /* @__PURE__ */ jsx(View, { style: styles.modalTitleSpacer }),
1037
- /* @__PURE__ */ jsx(
1038
- Pressable,
1039
- {
1040
- onPress: () => cancelRef.current?.(),
1041
- hitSlop: 12,
1042
- style: styles.closeButton,
1043
- children: /* @__PURE__ */ jsx(Text, { style: styles.closeButtonText, children: closeLabel })
1044
- }
1045
- )
1055
+ sensitiveVisible && /* @__PURE__ */ jsxs(Fragment, { children: [
1056
+ /* @__PURE__ */ jsx(View, { style: styles.sheetGrabber }),
1057
+ /* @__PURE__ */ jsxs(View, { style: styles.modalChrome, children: [
1058
+ /* @__PURE__ */ jsx(View, { style: styles.modalTitleSpacer }),
1059
+ /* @__PURE__ */ jsx(
1060
+ Pressable,
1061
+ {
1062
+ onPress: () => cancelRef.current?.(),
1063
+ hitSlop: 12,
1064
+ style: styles.closeButton,
1065
+ children: /* @__PURE__ */ jsx(Text, { style: styles.closeButtonText, children: closeLabel })
1066
+ }
1067
+ )
1068
+ ] })
1046
1069
  ] }),
1047
1070
  /* @__PURE__ */ jsx(
1048
1071
  WebView,
package/dist/solana.mjs CHANGED
@@ -160,13 +160,15 @@ import { PostMessageMethod as PostMessageMethod3, PostMessageType as PostMessage
160
160
 
161
161
  // src/transport/webview-bridge.ts
162
162
  import {
163
- FORWARDED_ERROR_FIELDS
163
+ FORWARDED_ERROR_FIELDS,
164
+ getPostMessageRequestTimeout,
165
+ POST_MESSAGE_REQUEST_TIMEOUT_MS
164
166
  } from "@moon-x/core/utils";
165
167
 
166
168
  // src/provider.tsx
167
169
  import { SDKProvider } from "@moon-x/core/react";
168
170
  import { validatePublishableKey } from "@moon-x/core/lib";
169
- import { jsx, jsxs } from "react/jsx-runtime";
171
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
170
172
  var MoonXContext = createContext(null);
171
173
  var useMoonXContext = () => {
172
174
  const ctx = useContext(MoonXContext);
package/dist/tron.mjs CHANGED
@@ -159,13 +159,15 @@ import { PostMessageMethod as PostMessageMethod3, PostMessageType as PostMessage
159
159
 
160
160
  // src/transport/webview-bridge.ts
161
161
  import {
162
- FORWARDED_ERROR_FIELDS
162
+ FORWARDED_ERROR_FIELDS,
163
+ getPostMessageRequestTimeout,
164
+ POST_MESSAGE_REQUEST_TIMEOUT_MS
163
165
  } from "@moon-x/core/utils";
164
166
 
165
167
  // src/provider.tsx
166
168
  import { SDKProvider } from "@moon-x/core/react";
167
169
  import { validatePublishableKey } from "@moon-x/core/lib";
168
- import { jsx, jsxs } from "react/jsx-runtime";
170
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
169
171
  var MoonXContext = createContext(null);
170
172
  var useMoonXContext = () => {
171
173
  const ctx = useContext(MoonXContext);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moon-x/react-native-sdk",
3
- "version": "0.15.1",
3
+ "version": "0.15.2",
4
4
  "description": "Headless MoonX React Native SDK with WebView-backed transport, native passkeys, and app-owned UI.",
5
5
  "license": "UNLICENSED",
6
6
  "main": "dist/index.js",
@@ -57,7 +57,7 @@
57
57
  "vitest": "4.1.0"
58
58
  },
59
59
  "dependencies": {
60
- "@moon-x/core": "0.18.0"
60
+ "@moon-x/core": "0.18.1"
61
61
  },
62
62
  "peerDependencies": {
63
63
  "@expo/config-plugins": ">=10.0.0",