@moon-x/react-native-sdk 0.26.0 → 0.28.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.
package/dist/index.js CHANGED
@@ -33,42 +33,42 @@ __export(index_exports, {
33
33
  MOONPAY_CONSUMER_SESSION_ERROR_CODES: () => import_sdk12.MOONPAY_CONSUMER_SESSION_ERROR_CODES,
34
34
  MoonKeyProvider: () => MoonXProvider,
35
35
  MoonXProvider: () => MoonXProvider,
36
- PostMessageMethod: () => import_utils11.PostMessageMethod,
37
- PostMessageType: () => import_utils11.PostMessageType,
36
+ PostMessageMethod: () => import_utils10.PostMessageMethod,
37
+ PostMessageType: () => import_utils10.PostMessageType,
38
38
  connectWalletConnect: () => connectWalletConnect,
39
39
  listWalletConnectSessions: () => listWalletConnectSessions,
40
40
  registerPresenceOtpCodeProvider: () => import_sdk13.registerPresenceOtpCodeProvider,
41
41
  restoreWalletConnectSession: () => restoreWalletConnectSession,
42
- useAddPasskey: () => import_react9.useAddPasskey,
42
+ useAddPasskey: () => import_react10.useAddPasskey,
43
43
  useAppConfig: () => useAppConfig,
44
44
  useAttachOAuth: () => useAttachOAuth,
45
- useBulkImport: () => import_react9.useBulkImport,
46
- useChangeEmail: () => import_react9.useChangeEmail,
47
- useCreateWallet: () => import_react9.useCreateWallet,
45
+ useBulkImport: () => import_react10.useBulkImport,
46
+ useChangeEmail: () => import_react10.useChangeEmail,
47
+ useCreateWallet: () => import_react10.useCreateWallet,
48
48
  useDetachOAuth: () => useDetachOAuth,
49
- useEphemeralSigner: () => import_react9.useEphemeralSigner,
49
+ useEphemeralSigner: () => import_react10.useEphemeralSigner,
50
50
  useExportKey: () => useExportKey,
51
51
  useExternalWallets: () => useExternalWallets,
52
52
  useFundWallet: () => useFundWallet,
53
- useImportKey: () => import_react9.useImportKey,
54
- useLinkEmail: () => import_react9.useLinkEmail,
53
+ useImportKey: () => import_react10.useImportKey,
54
+ useLinkEmail: () => import_react10.useLinkEmail,
55
55
  useLoginWithEmail: () => useLoginWithEmail,
56
56
  useLoginWithOAuth: () => useLoginWithOAuth,
57
- useLogout: () => import_react9.useLogout,
57
+ useLogout: () => import_react10.useLogout,
58
58
  useMoonKey: () => useMoonX,
59
59
  useMoonX: () => useMoonX,
60
60
  useMoonXContext: () => useMoonXContext,
61
- usePasskeyStatus: () => import_react9.usePasskeyStatus,
62
- useRegisterPasskey: () => import_react9.useRegisterPasskey,
63
- useRemovePasskey: () => import_react9.useRemovePasskey,
64
- useUser: () => import_react9.useUser,
65
- useWallets: () => import_react9.useWallets
61
+ usePasskeyStatus: () => import_react10.usePasskeyStatus,
62
+ useRegisterPasskey: () => import_react10.useRegisterPasskey,
63
+ useRemovePasskey: () => import_react10.useRemovePasskey,
64
+ useUser: () => import_react10.useUser,
65
+ useWallets: () => import_react10.useWallets
66
66
  });
67
67
  module.exports = __toCommonJS(index_exports);
68
68
 
69
69
  // src/provider.tsx
70
- var import_react2 = require("react");
71
- var import_react_native2 = require("react-native");
70
+ var import_react3 = require("react");
71
+ var import_react_native3 = require("react-native");
72
72
  var import_react_native_webview = require("react-native-webview");
73
73
 
74
74
  // src/sdk/create-sdk-instance.ts
@@ -546,6 +546,24 @@ function getSessionMethods(bridge, publishableKey, relyingPartyOrigin, session,
546
546
  await refreshUser();
547
547
  return result;
548
548
  },
549
+ // Redeems the provider's token for a link (useAttachOAuth). The user
550
+ // stays the same account, so unlike verifyOAuth this isn't a login: a
551
+ // failed link leaves the session-resume binding and the published user
552
+ // alone, and a successful one refreshes the user like linkEmailWithCode.
553
+ verifyOAuthLink: async (params) => {
554
+ const refreshUser = session.captureUserRefresh();
555
+ await auth().verifyOAuthLink(params);
556
+ await refreshUser();
557
+ },
558
+ // linked_accounts changed, so the published user is read again, the same
559
+ // as after a link. (Core's own refresh needs a raw setUser, which the
560
+ // session-managed provider doesn't hand it.)
561
+ detachOAuth: async (idpUserId) => {
562
+ const refreshUser = session.captureUserRefresh();
563
+ const result = await general().detachOAuth(idpUserId);
564
+ await refreshUser();
565
+ return result;
566
+ },
549
567
  // The account's email changes, so the provider's user is read again
550
568
  // before the change resolves, the same as a link.
551
569
  confirmEmailChangeNewCode: async (params) => {
@@ -622,12 +640,39 @@ var createSdkInstance = ({
622
640
  });
623
641
 
624
642
  // src/provider.tsx
625
- var import_utils5 = require("@moon-x/core/utils");
643
+ var import_utils6 = require("@moon-x/core/utils");
626
644
 
627
645
  // src/components/presence-otp-prompt.tsx
646
+ var import_react2 = __toESM(require("react"));
647
+ var import_react_native2 = require("react-native");
648
+ var import_sdk9 = require("@moon-x/core/sdk");
649
+
650
+ // src/components/use-reduce-motion.ts
628
651
  var import_react = require("react");
629
652
  var import_react_native = require("react-native");
630
- var import_sdk9 = require("@moon-x/core/sdk");
653
+ var lastKnown;
654
+ var useReduceMotion = () => {
655
+ const [state, setState] = (0, import_react.useState)(() => ({
656
+ reduceMotion: lastKnown ?? true,
657
+ settled: lastKnown !== void 0
658
+ }));
659
+ (0, import_react.useEffect)(() => {
660
+ let live = true;
661
+ const update = (enabled) => {
662
+ lastKnown = enabled;
663
+ if (live) setState({ reduceMotion: enabled, settled: true });
664
+ };
665
+ import_react_native.AccessibilityInfo.isReduceMotionEnabled().then(update).catch(() => {
666
+ if (live) setState((current) => ({ ...current, settled: true }));
667
+ });
668
+ const subscription = import_react_native.AccessibilityInfo.addEventListener("reduceMotionChanged", update);
669
+ return () => {
670
+ live = false;
671
+ subscription.remove();
672
+ };
673
+ }, []);
674
+ return state;
675
+ };
631
676
 
632
677
  // src/components/presence-otp-gate.ts
633
678
  var createPresenceOtpGate = () => {
@@ -739,42 +784,160 @@ var createPresenceOtpController = (onChange) => {
739
784
  };
740
785
  };
741
786
 
742
- // src/components/presence-otp-prompt.tsx
743
- var import_jsx_runtime = require("react/jsx-runtime");
744
- var DEFAULT_COPY = {
745
- title: "Check your email",
746
- description: "Enter the verification code we sent to confirm this wallet action.",
747
- hint: "Didn't get it? Check spam, or cancel and try again in a minute.",
748
- verify: "Verify",
749
- verifying: "Verifying...",
750
- cancel: "Cancel",
751
- invalidCode: "That code was incorrect. Try again.",
752
- incompleteCode: "Enter the 6-digit code."
787
+ // src/components/presence-otp-strings.ts
788
+ var import_utils3 = require("@moon-x/core/utils");
789
+ var PROMPT_LANGUAGES = ["en", "de", "es", "fr", "it", "pt"];
790
+ var COPY = {
791
+ en: {
792
+ title: "Check your email",
793
+ description: "Enter the code we sent to confirm this wallet action.",
794
+ hint: "",
795
+ verify: "Verify",
796
+ verifying: "Verifying\u2026",
797
+ cancel: "Cancel",
798
+ close: "Close",
799
+ invalidCode: "That code didn't work. Try again.",
800
+ incompleteCode: "Enter the 6-digit code.",
801
+ codeLabel: "Verification code"
802
+ },
803
+ de: {
804
+ title: "Pr\xFCfe deine E-Mails",
805
+ description: "Gib den Code ein, den wir dir gesendet haben, um diese Wallet-Aktion zu best\xE4tigen.",
806
+ hint: "",
807
+ verify: "Best\xE4tigen",
808
+ verifying: "Wird best\xE4tigt\u2026",
809
+ cancel: "Abbrechen",
810
+ close: "Schlie\xDFen",
811
+ invalidCode: "Der Code hat nicht funktioniert. Versuche es erneut.",
812
+ incompleteCode: "Gib den 6-stelligen Code ein.",
813
+ codeLabel: "Best\xE4tigungscode"
814
+ },
815
+ es: {
816
+ title: "Revisa tu correo",
817
+ description: "Introduce el c\xF3digo que te enviamos para confirmar esta acci\xF3n de la billetera.",
818
+ hint: "",
819
+ verify: "Verificar",
820
+ verifying: "Verificando\u2026",
821
+ cancel: "Cancelar",
822
+ close: "Cerrar",
823
+ invalidCode: "Ese c\xF3digo no funcion\xF3. Int\xE9ntalo de nuevo.",
824
+ incompleteCode: "Introduce el c\xF3digo de 6 d\xEDgitos.",
825
+ codeLabel: "C\xF3digo de verificaci\xF3n"
826
+ },
827
+ fr: {
828
+ title: "Consultez vos e-mails",
829
+ description: "Saisissez le code que nous vous avons envoy\xE9 pour confirmer cette action sur le portefeuille.",
830
+ hint: "",
831
+ verify: "V\xE9rifier",
832
+ verifying: "V\xE9rification\u2026",
833
+ cancel: "Annuler",
834
+ close: "Fermer",
835
+ invalidCode: "Ce code n'a pas fonctionn\xE9. R\xE9essayez.",
836
+ incompleteCode: "Saisissez le code \xE0 6 chiffres.",
837
+ codeLabel: "Code de v\xE9rification"
838
+ },
839
+ it: {
840
+ title: "Controlla la tua email",
841
+ description: "Inserisci il codice che ti abbiamo inviato per confermare questa azione sul wallet.",
842
+ hint: "",
843
+ verify: "Verifica",
844
+ verifying: "Verifica in corso\u2026",
845
+ cancel: "Annulla",
846
+ close: "Chiudi",
847
+ invalidCode: "Il codice non \xE8 valido. Riprova.",
848
+ incompleteCode: "Inserisci il codice a 6 cifre.",
849
+ codeLabel: "Codice di verifica"
850
+ },
851
+ pt: {
852
+ title: "Verifique seu e-mail",
853
+ description: "Digite o c\xF3digo que enviamos para confirmar esta a\xE7\xE3o na carteira.",
854
+ hint: "",
855
+ verify: "Verificar",
856
+ verifying: "Verificando\u2026",
857
+ cancel: "Cancelar",
858
+ close: "Fechar",
859
+ invalidCode: "Esse c\xF3digo n\xE3o funcionou. Tente novamente.",
860
+ incompleteCode: "Digite o c\xF3digo de 6 d\xEDgitos.",
861
+ codeLabel: "C\xF3digo de verifica\xE7\xE3o"
862
+ }
863
+ };
864
+ var LIGHT_COLORS = {
865
+ background: "#ffffff",
866
+ surface: "#f4f3f9",
867
+ border: "#e6e4ef",
868
+ text: "#010101",
869
+ mutedText: "#747386",
870
+ accent: "#010101",
871
+ accentText: "#fcfbff",
872
+ error: "#c41f1f",
873
+ errorSurface: "#f6e4e4",
874
+ backdrop: "rgba(1, 1, 1, 0.32)"
753
875
  };
754
- var DEFAULT_COLORS = {
755
- background: "#0a0a0a",
756
- surface: "#141414",
757
- border: "#333",
758
- text: "#fafafa",
759
- mutedText: "#a1a1aa",
760
- accent: "#3b82f6",
761
- accentText: "#fff",
762
- error: "#f87171"
876
+ var DARK_COLORS = {
877
+ background: "#0b0b0d",
878
+ surface: "#17171b",
879
+ border: "#292930",
880
+ text: "#fcfbff",
881
+ mutedText: "#9e9bae",
882
+ accent: "#fcfbff",
883
+ accentText: "#010101",
884
+ error: "#ff9b98",
885
+ errorSurface: "#3c0202",
886
+ backdrop: "rgba(1, 1, 1, 0.32)"
763
887
  };
888
+ var deviceLanguage = () => {
889
+ try {
890
+ return Intl.DateTimeFormat().resolvedOptions().locale;
891
+ } catch {
892
+ return void 0;
893
+ }
894
+ };
895
+ var resolvePromptCopy = (language) => {
896
+ return COPY[(0, import_utils3.resolveLanguage)(language ?? deviceLanguage(), PROMPT_LANGUAGES, "en")];
897
+ };
898
+ var resolvePromptColors = (displayMode, systemScheme) => {
899
+ const dark = displayMode === "dark" || displayMode !== "light" && systemScheme === "dark";
900
+ return dark ? DARK_COLORS : LIGHT_COLORS;
901
+ };
902
+
903
+ // src/components/presence-otp-prompt.tsx
904
+ var import_jsx_runtime = require("react/jsx-runtime");
764
905
  var OTP_LENGTH = 6;
906
+ var SHEET_MAX_WIDTH = 480;
907
+ var COMPACT_MAX_WIDTH = 360;
765
908
  var PresenceOtpPrompt = ({
766
909
  publishableKey,
767
910
  options
768
911
  }) => {
769
- const [state, setState] = (0, import_react.useState)(
912
+ const [state, setState] = (0, import_react2.useState)(
770
913
  IDLE_PRESENCE_OTP_STATE
771
914
  );
772
- const [code, setCode] = (0, import_react.useState)("");
773
- const [incomplete, setIncomplete] = (0, import_react.useState)(false);
774
- const controllerRef = (0, import_react.useRef)(null);
775
- const copy = { ...DEFAULT_COPY, ...options?.copy };
776
- const colors = { ...DEFAULT_COLORS, ...options?.colors };
777
- (0, import_react.useEffect)(() => {
915
+ const [code, setCode] = (0, import_react2.useState)("");
916
+ const [incomplete, setIncomplete] = (0, import_react2.useState)(false);
917
+ const [edited, setEdited] = (0, import_react2.useState)(false);
918
+ const [focused, setFocused] = (0, import_react2.useState)(false);
919
+ const controllerRef = (0, import_react2.useRef)(null);
920
+ const inputRef = (0, import_react2.useRef)(null);
921
+ const sheetOffset = (0, import_react2.useRef)(new import_react_native2.Animated.Value(0)).current;
922
+ const shake = (0, import_react2.useRef)(new import_react_native2.Animated.Value(0)).current;
923
+ const caret = (0, import_react2.useRef)(new import_react_native2.Animated.Value(1)).current;
924
+ const { reduceMotion, settled: motionSettled } = useReduceMotion();
925
+ const shakePending = (0, import_react2.useRef)(false);
926
+ const scheme = (0, import_react_native2.useColorScheme)();
927
+ const { width } = (0, import_react_native2.useWindowDimensions)();
928
+ const copy = { ...resolvePromptCopy(options?.language), ...options?.copy };
929
+ const colors = {
930
+ ...resolvePromptColors(options?.displayMode, scheme),
931
+ ...options?.colors
932
+ };
933
+ const visible = state.request !== null;
934
+ const submitting = state.submitting;
935
+ const invalid = state.invalidCode && !edited;
936
+ const error = incomplete ? copy.incompleteCode : invalid ? copy.invalidCode : null;
937
+ const complete = code.length === OTP_LENGTH;
938
+ const sheet = width <= SHEET_MAX_WIDTH;
939
+ const compact = width <= COMPACT_MAX_WIDTH;
940
+ (0, import_react2.useEffect)(() => {
778
941
  const controller = createPresenceOtpController(setState);
779
942
  controllerRef.current = controller;
780
943
  const unregister = (0, import_sdk9.registerPresenceOtpCodeProvider)(
@@ -789,11 +952,63 @@ var PresenceOtpPrompt = ({
789
952
  setState(IDLE_PRESENCE_OTP_STATE);
790
953
  };
791
954
  }, [publishableKey]);
792
- (0, import_react.useEffect)(() => {
955
+ const shakeCells = () => {
956
+ shake.setValue(0);
957
+ import_react_native2.Animated.sequence(
958
+ [-6, 6, -4, 4, -2, 0].map(
959
+ (toValue) => import_react_native2.Animated.timing(shake, {
960
+ toValue,
961
+ duration: 60,
962
+ easing: import_react_native2.Easing.linear,
963
+ useNativeDriver: true
964
+ })
965
+ )
966
+ ).start();
967
+ };
968
+ (0, import_react2.useEffect)(() => {
793
969
  setCode("");
794
970
  setIncomplete(false);
971
+ setEdited(false);
972
+ shakePending.current = false;
973
+ if (!state.request) return;
974
+ inputRef.current?.focus();
975
+ if (!state.invalidCode) return;
976
+ if (!motionSettled) shakePending.current = true;
977
+ else if (!reduceMotion) shakeCells();
795
978
  }, [state.request]);
796
- (0, import_react.useEffect)(() => {
979
+ (0, import_react2.useEffect)(() => {
980
+ if (!motionSettled || !shakePending.current) return;
981
+ shakePending.current = false;
982
+ if (!reduceMotion) shakeCells();
983
+ }, [motionSettled]);
984
+ (0, import_react2.useEffect)(() => {
985
+ if (!visible) return;
986
+ sheetOffset.setValue(reduceMotion ? 0 : 24);
987
+ import_react_native2.Animated.timing(sheetOffset, {
988
+ toValue: 0,
989
+ duration: 240,
990
+ easing: import_react_native2.Easing.out(import_react_native2.Easing.cubic),
991
+ useNativeDriver: true
992
+ }).start();
993
+ }, [visible]);
994
+ (0, import_react2.useEffect)(() => {
995
+ caret.setValue(1);
996
+ if (!focused || reduceMotion) return;
997
+ const blink = import_react_native2.Animated.loop(
998
+ import_react_native2.Animated.sequence([
999
+ import_react_native2.Animated.timing(caret, { toValue: 0, duration: 0, delay: 530, useNativeDriver: true }),
1000
+ import_react_native2.Animated.timing(caret, { toValue: 1, duration: 0, delay: 530, useNativeDriver: true })
1001
+ ])
1002
+ );
1003
+ blink.start();
1004
+ return () => blink.stop();
1005
+ }, [focused, reduceMotion, code]);
1006
+ (0, import_react2.useEffect)(() => {
1007
+ if (error && import_react_native2.Platform.OS === "ios") {
1008
+ import_react_native2.AccessibilityInfo.announceForAccessibility(error);
1009
+ }
1010
+ }, [error]);
1011
+ (0, import_react2.useEffect)(() => {
797
1012
  const request = state.request;
798
1013
  if (!request?.expiresAt || state.submitting) return;
799
1014
  const expire = () => controllerRef.current?.expire(request);
@@ -808,160 +1023,451 @@ var PresenceOtpPrompt = ({
808
1023
  const close = () => {
809
1024
  controllerRef.current?.cancel();
810
1025
  };
811
- const submit = () => {
812
- const normalized = code.trim();
813
- if (!/^\d{6}$/.test(normalized)) {
1026
+ const submit = (value = code) => {
1027
+ if (!/^\d{6}$/.test(value)) {
814
1028
  setIncomplete(true);
815
1029
  return;
816
1030
  }
817
- controllerRef.current?.submit(normalized);
1031
+ controllerRef.current?.submit(value);
818
1032
  };
819
- const submitting = state.submitting;
820
- const error = incomplete ? copy.incompleteCode : state.invalidCode ? copy.invalidCode : null;
821
- const complete = code.length === OTP_LENGTH;
1033
+ const changeCode = (next) => {
1034
+ if (submitting) return;
1035
+ const clean = next.replace(/\D/g, "").slice(0, OTP_LENGTH);
1036
+ setCode(clean);
1037
+ setIncomplete(false);
1038
+ setEdited(true);
1039
+ if (clean.length === OTP_LENGTH) submit(clean);
1040
+ };
1041
+ const cells = Array.from({ length: OTP_LENGTH }, (_, index) => {
1042
+ const digit = code[index] ?? "";
1043
+ const current = focused && !submitting && index === Math.min(code.length, OTP_LENGTH - 1);
1044
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react2.default.Fragment, { children: [
1045
+ index === OTP_LENGTH / 2 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.View, { style: [styles.separator, { backgroundColor: colors.mutedText }] }),
1046
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1047
+ import_react_native2.View,
1048
+ {
1049
+ style: [
1050
+ styles.cell,
1051
+ compact && styles.cellCompact,
1052
+ { backgroundColor: colors.background, borderColor: colors.border },
1053
+ current && { borderColor: colors.accent },
1054
+ invalid && { borderColor: colors.error, backgroundColor: colors.errorSurface }
1055
+ ],
1056
+ children: digit ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.Text, { style: [styles.cellText, { color: invalid ? colors.error : colors.text }], children: digit }) : current && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1057
+ import_react_native2.Animated.View,
1058
+ {
1059
+ style: [styles.caret, { backgroundColor: colors.accent, opacity: caret }]
1060
+ }
1061
+ )
1062
+ }
1063
+ )
1064
+ ] }, index);
1065
+ });
822
1066
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
823
- import_react_native.Modal,
1067
+ import_react_native2.Modal,
824
1068
  {
825
- visible: state.request !== null,
1069
+ visible,
826
1070
  transparent: true,
827
1071
  animationType: "fade",
828
1072
  onRequestClose: close,
829
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.View, { style: styles.backdrop, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native.View, { style: [styles.card, { backgroundColor: colors.background }], children: [
830
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.Text, { style: [styles.title, { color: colors.text }], children: copy.title }),
831
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.Text, { style: [styles.body, { color: colors.mutedText }], children: copy.description }),
832
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
833
- import_react_native.TextInput,
834
- {
835
- autoFocus: true,
836
- style: [
837
- styles.input,
838
- {
839
- borderColor: colors.border,
840
- backgroundColor: colors.surface,
841
- color: colors.text
842
- }
843
- ],
844
- value: code,
845
- onChangeText: (next) => {
846
- setCode(next.replace(/\D/g, "").slice(0, OTP_LENGTH));
847
- setIncomplete(false);
848
- },
849
- onSubmitEditing: submit,
850
- editable: !submitting,
851
- keyboardType: "number-pad",
852
- textContentType: "oneTimeCode",
853
- autoComplete: "sms-otp",
854
- maxLength: OTP_LENGTH,
855
- placeholder: "123456",
856
- placeholderTextColor: colors.mutedText,
857
- accessibilityLabel: "Verification code",
858
- returnKeyType: "done"
859
- }
860
- ),
861
- error !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
862
- import_react_native.Text,
863
- {
864
- style: [styles.error, { color: colors.error }],
865
- accessibilityLiveRegion: "polite",
866
- children: error
867
- }
868
- ),
869
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
870
- import_react_native.Pressable,
871
- {
872
- onPress: submit,
873
- disabled: submitting || !complete,
874
- style: [
875
- styles.primaryButton,
876
- { backgroundColor: colors.accent },
877
- (submitting || !complete) && styles.primaryButtonDisabled
878
- ],
879
- accessibilityRole: "button",
880
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.Text, { style: [styles.primaryButtonText, { color: colors.accentText }], children: submitting ? copy.verifying : copy.verify })
881
- }
882
- ),
883
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
884
- import_react_native.Pressable,
885
- {
886
- onPress: close,
887
- disabled: submitting,
888
- style: [styles.ghostButton, submitting && styles.primaryButtonDisabled],
889
- accessibilityRole: "button",
890
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.Text, { style: [styles.ghostButtonText, { color: colors.mutedText }], children: copy.cancel })
891
- }
892
- ),
893
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.Text, { style: [styles.hint, { color: colors.mutedText }], children: copy.hint })
894
- ] }) })
1073
+ onShow: () => inputRef.current?.focus(),
1074
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1075
+ import_react_native2.KeyboardAvoidingView,
1076
+ {
1077
+ behavior: import_react_native2.Platform.OS === "ios" ? "padding" : void 0,
1078
+ style: [
1079
+ styles.backdrop,
1080
+ sheet ? styles.backdropSheet : styles.backdropCentered,
1081
+ { backgroundColor: colors.backdrop }
1082
+ ],
1083
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
1084
+ import_react_native2.Animated.View,
1085
+ {
1086
+ accessibilityViewIsModal: true,
1087
+ style: [
1088
+ styles.card,
1089
+ sheet ? styles.sheet : styles.centered,
1090
+ {
1091
+ backgroundColor: colors.background,
1092
+ borderColor: colors.border,
1093
+ transform: [{ translateY: sheetOffset }]
1094
+ }
1095
+ ],
1096
+ children: [
1097
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.View, { style: styles.header, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1098
+ import_react_native2.Pressable,
1099
+ {
1100
+ onPress: close,
1101
+ disabled: submitting,
1102
+ hitSlop: 8,
1103
+ accessibilityRole: "button",
1104
+ accessibilityLabel: copy.close,
1105
+ style: ({ pressed }) => [
1106
+ styles.iconButton,
1107
+ { backgroundColor: pressed ? colors.border : colors.surface },
1108
+ submitting && styles.disabled
1109
+ ],
1110
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CloseIcon, { color: colors.mutedText })
1111
+ }
1112
+ ) }),
1113
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
1114
+ import_react_native2.ScrollView,
1115
+ {
1116
+ bounces: false,
1117
+ keyboardShouldPersistTaps: "handled",
1118
+ contentContainerStyle: styles.content,
1119
+ children: [
1120
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native2.View, { style: styles.body, children: [
1121
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native2.View, { style: styles.hero, children: [
1122
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.View, { style: [styles.iconDisc, { backgroundColor: colors.surface }], children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MailIcon, { color: colors.text }) }),
1123
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native2.View, { style: styles.heroText, children: [
1124
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.Text, { accessibilityRole: "header", style: [styles.title, { color: colors.text }], children: copy.title }),
1125
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.Text, { style: [styles.description, { color: colors.mutedText }], children: copy.description })
1126
+ ] })
1127
+ ] }),
1128
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native2.View, { children: [
1129
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1130
+ import_react_native2.Animated.View,
1131
+ {
1132
+ accessibilityElementsHidden: true,
1133
+ importantForAccessibility: "no-hide-descendants",
1134
+ style: [
1135
+ styles.cells,
1136
+ compact && styles.cellsCompact,
1137
+ submitting && styles.cellsBusy,
1138
+ { transform: [{ translateX: shake }] }
1139
+ ],
1140
+ children: cells
1141
+ }
1142
+ ),
1143
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1144
+ import_react_native2.TextInput,
1145
+ {
1146
+ ref: inputRef,
1147
+ autoFocus: true,
1148
+ value: code,
1149
+ onChangeText: changeCode,
1150
+ onSubmitEditing: () => submit(),
1151
+ onFocus: () => setFocused(true),
1152
+ onBlur: () => setFocused(false),
1153
+ keyboardType: "number-pad",
1154
+ textContentType: "oneTimeCode",
1155
+ autoComplete: "sms-otp",
1156
+ autoCorrect: false,
1157
+ spellCheck: false,
1158
+ caretHidden: true,
1159
+ selectionColor: colors.accent,
1160
+ accessibilityLabel: copy.codeLabel,
1161
+ returnKeyType: "done",
1162
+ style: styles.codeInput
1163
+ }
1164
+ )
1165
+ ] }),
1166
+ error !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native2.View, { style: styles.error, accessibilityLiveRegion: "polite", children: [
1167
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlertIcon, { color: colors.error }),
1168
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.Text, { style: [styles.errorText, { color: colors.error }], children: error })
1169
+ ] })
1170
+ ] }),
1171
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native2.View, { style: styles.actions, children: [
1172
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
1173
+ import_react_native2.Pressable,
1174
+ {
1175
+ onPress: () => submit(),
1176
+ disabled: !complete || submitting,
1177
+ accessibilityRole: "button",
1178
+ accessibilityState: { disabled: !complete || submitting, busy: submitting },
1179
+ style: ({ pressed }) => [
1180
+ styles.button,
1181
+ { backgroundColor: colors.accent },
1182
+ pressed && styles.pressed,
1183
+ !complete && !submitting && styles.disabled
1184
+ ],
1185
+ children: [
1186
+ submitting && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.ActivityIndicator, { size: "small", color: colors.accentText }),
1187
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.Text, { style: [styles.buttonText, { color: colors.accentText }], children: submitting ? copy.verifying : copy.verify })
1188
+ ]
1189
+ }
1190
+ ),
1191
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1192
+ import_react_native2.Pressable,
1193
+ {
1194
+ onPress: close,
1195
+ disabled: submitting,
1196
+ accessibilityRole: "button",
1197
+ style: ({ pressed }) => [
1198
+ styles.button,
1199
+ pressed && { backgroundColor: colors.surface },
1200
+ submitting && styles.disabled
1201
+ ],
1202
+ children: ({ pressed }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1203
+ import_react_native2.Text,
1204
+ {
1205
+ style: [styles.buttonText, { color: pressed ? colors.text : colors.mutedText }],
1206
+ children: copy.cancel
1207
+ }
1208
+ )
1209
+ }
1210
+ ),
1211
+ copy.hint ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.Text, { style: [styles.hint, { color: colors.mutedText }], children: copy.hint }) : null
1212
+ ] })
1213
+ ]
1214
+ }
1215
+ )
1216
+ ]
1217
+ }
1218
+ )
1219
+ }
1220
+ )
895
1221
  }
896
1222
  );
897
1223
  };
898
- var styles = import_react_native.StyleSheet.create({
1224
+ var CloseIcon = ({ color }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native2.View, { style: styles.closeIcon, children: [
1225
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.View, { style: [styles.closeBar, { backgroundColor: color, transform: [{ rotate: "45deg" }] }] }),
1226
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.View, { style: [styles.closeBar, { backgroundColor: color, transform: [{ rotate: "-45deg" }] }] })
1227
+ ] });
1228
+ var MailIcon = ({ color }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native2.View, { style: styles.mailIcon, children: [
1229
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.View, { style: [styles.mailBody, { borderColor: color }] }),
1230
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.View, { style: [styles.mailFlap, styles.mailFlapLeft, { backgroundColor: color }] }),
1231
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.View, { style: [styles.mailFlap, styles.mailFlapRight, { backgroundColor: color }] })
1232
+ ] });
1233
+ var AlertIcon = ({ color }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native2.View, { style: [styles.alertIcon, { borderColor: color }], children: [
1234
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.View, { style: [styles.alertStem, { backgroundColor: color }] }),
1235
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native2.View, { style: [styles.alertDot, { backgroundColor: color }] })
1236
+ ] });
1237
+ var styles = import_react_native2.StyleSheet.create({
899
1238
  backdrop: {
900
- flex: 1,
1239
+ flex: 1
1240
+ },
1241
+ backdropSheet: {
1242
+ justifyContent: "flex-end"
1243
+ },
1244
+ backdropCentered: {
901
1245
  alignItems: "center",
902
1246
  justifyContent: "center",
903
- padding: 16,
904
- backgroundColor: "rgba(0, 0, 0, 0.45)"
1247
+ padding: 16
905
1248
  },
906
1249
  card: {
907
1250
  width: "100%",
908
- maxWidth: 384,
909
- padding: 24,
910
- borderRadius: 14
1251
+ maxHeight: "100%",
1252
+ overflow: "hidden"
1253
+ },
1254
+ sheet: {
1255
+ borderTopLeftRadius: 24,
1256
+ borderTopRightRadius: 24,
1257
+ borderTopWidth: 1
1258
+ },
1259
+ centered: {
1260
+ maxWidth: 400,
1261
+ borderRadius: 24,
1262
+ borderWidth: 1
1263
+ },
1264
+ header: {
1265
+ flexDirection: "row",
1266
+ justifyContent: "flex-end",
1267
+ alignItems: "center",
1268
+ height: 56,
1269
+ paddingHorizontal: 16
1270
+ },
1271
+ iconButton: {
1272
+ width: 32,
1273
+ height: 32,
1274
+ borderRadius: 8,
1275
+ alignItems: "center",
1276
+ justifyContent: "center"
1277
+ },
1278
+ content: {
1279
+ paddingHorizontal: 24,
1280
+ // Clear of the home indicator when the keyboard is down.
1281
+ paddingBottom: 32
1282
+ },
1283
+ body: {
1284
+ gap: 16
1285
+ },
1286
+ hero: {
1287
+ alignItems: "center",
1288
+ gap: 16,
1289
+ paddingTop: 8
1290
+ },
1291
+ iconDisc: {
1292
+ width: 64,
1293
+ height: 64,
1294
+ borderRadius: 32,
1295
+ alignItems: "center",
1296
+ justifyContent: "center"
1297
+ },
1298
+ heroText: {
1299
+ width: "100%",
1300
+ gap: 4
911
1301
  },
912
1302
  title: {
913
1303
  fontSize: 20,
914
- fontWeight: "600"
1304
+ lineHeight: 24,
1305
+ fontWeight: "500",
1306
+ letterSpacing: -0.4,
1307
+ textAlign: "center"
915
1308
  },
916
- body: {
1309
+ description: {
917
1310
  fontSize: 14,
918
- marginTop: 8
1311
+ lineHeight: 20,
1312
+ textAlign: "center"
919
1313
  },
920
- input: {
921
- marginTop: 16,
922
- paddingVertical: 12,
923
- paddingHorizontal: 16,
1314
+ cells: {
1315
+ flexDirection: "row",
1316
+ alignItems: "center",
1317
+ justifyContent: "center",
1318
+ gap: 8
1319
+ },
1320
+ cellsCompact: {
1321
+ gap: 6
1322
+ },
1323
+ cellsBusy: {
1324
+ opacity: 0.6
1325
+ },
1326
+ cell: {
1327
+ width: 44,
1328
+ height: 52,
1329
+ borderWidth: 1,
924
1330
  borderRadius: 12,
925
- borderWidth: import_react_native.StyleSheet.hairlineWidth,
926
- fontSize: 24,
927
- letterSpacing: 8,
928
- textAlign: "center"
1331
+ alignItems: "center",
1332
+ justifyContent: "center"
1333
+ },
1334
+ cellCompact: {
1335
+ width: 38,
1336
+ height: 48
1337
+ },
1338
+ cellText: {
1339
+ fontSize: 18,
1340
+ fontWeight: "500",
1341
+ fontVariant: ["tabular-nums"]
1342
+ },
1343
+ caret: {
1344
+ width: 1.5,
1345
+ height: 20,
1346
+ borderRadius: 1
1347
+ },
1348
+ separator: {
1349
+ width: 4,
1350
+ height: 4,
1351
+ borderRadius: 2,
1352
+ marginHorizontal: 4,
1353
+ opacity: 0.6
1354
+ },
1355
+ codeInput: {
1356
+ position: "absolute",
1357
+ top: 0,
1358
+ right: 0,
1359
+ bottom: 0,
1360
+ left: 0,
1361
+ // Not 0: iOS stops delivering touches to a view that is fully transparent.
1362
+ opacity: 0.015,
1363
+ color: "transparent",
1364
+ backgroundColor: "transparent",
1365
+ borderWidth: 0
929
1366
  },
930
1367
  error: {
931
- fontSize: 13,
932
- marginTop: 8
1368
+ flexDirection: "row",
1369
+ alignItems: "center",
1370
+ justifyContent: "center",
1371
+ gap: 4
933
1372
  },
934
- primaryButton: {
935
- marginTop: 16,
936
- paddingVertical: 12,
937
- borderRadius: 12,
938
- alignItems: "center"
1373
+ errorText: {
1374
+ flexShrink: 1,
1375
+ fontSize: 12,
1376
+ fontWeight: "500",
1377
+ textAlign: "center"
939
1378
  },
940
- primaryButtonDisabled: {
941
- opacity: 0.5
1379
+ actions: {
1380
+ gap: 8,
1381
+ paddingTop: 24
942
1382
  },
943
- primaryButtonText: {
1383
+ button: {
1384
+ flexDirection: "row",
1385
+ alignItems: "center",
1386
+ justifyContent: "center",
1387
+ gap: 8,
1388
+ height: 48,
1389
+ paddingHorizontal: 20,
1390
+ borderRadius: 999
1391
+ },
1392
+ buttonText: {
944
1393
  fontSize: 16,
945
- fontWeight: "600"
1394
+ fontWeight: "500"
946
1395
  },
947
- ghostButton: {
948
- marginTop: 8,
949
- paddingVertical: 12,
950
- alignItems: "center"
1396
+ pressed: {
1397
+ opacity: 0.88,
1398
+ transform: [{ scale: 0.985 }]
951
1399
  },
952
- ghostButtonText: {
953
- fontSize: 15,
954
- fontWeight: "500"
1400
+ disabled: {
1401
+ opacity: 0.5
955
1402
  },
956
1403
  hint: {
957
1404
  fontSize: 12,
958
- marginTop: 4,
1405
+ lineHeight: 16,
959
1406
  textAlign: "center"
1407
+ },
1408
+ closeIcon: {
1409
+ width: 16,
1410
+ height: 16,
1411
+ alignItems: "center",
1412
+ justifyContent: "center"
1413
+ },
1414
+ closeBar: {
1415
+ position: "absolute",
1416
+ width: 12,
1417
+ height: 1.5,
1418
+ borderRadius: 1
1419
+ },
1420
+ mailIcon: {
1421
+ width: 28,
1422
+ height: 28
1423
+ },
1424
+ mailBody: {
1425
+ position: "absolute",
1426
+ top: 5,
1427
+ left: 2,
1428
+ width: 24,
1429
+ height: 18,
1430
+ borderWidth: 2,
1431
+ borderRadius: 3
1432
+ },
1433
+ mailFlap: {
1434
+ position: "absolute",
1435
+ top: 10.6,
1436
+ width: 13,
1437
+ height: 2,
1438
+ borderRadius: 1
1439
+ },
1440
+ mailFlapLeft: {
1441
+ left: 2,
1442
+ transform: [{ rotate: "29.8deg" }]
1443
+ },
1444
+ mailFlapRight: {
1445
+ left: 13,
1446
+ transform: [{ rotate: "-29.8deg" }]
1447
+ },
1448
+ alertIcon: {
1449
+ width: 14,
1450
+ height: 14,
1451
+ borderRadius: 7,
1452
+ borderWidth: 1.25,
1453
+ alignItems: "center",
1454
+ justifyContent: "center",
1455
+ gap: 1
1456
+ },
1457
+ alertStem: {
1458
+ width: 1.5,
1459
+ height: 4,
1460
+ borderRadius: 1
1461
+ },
1462
+ alertDot: {
1463
+ width: 1.5,
1464
+ height: 1.5,
1465
+ borderRadius: 1
960
1466
  }
961
1467
  });
962
1468
 
963
1469
  // src/transport/webview-bridge.ts
964
- var import_utils3 = require("@moon-x/core/utils");
1470
+ var import_utils4 = require("@moon-x/core/utils");
965
1471
  var RETRYABLE_METHODS = /* @__PURE__ */ new Set([
966
1472
  "GET_APP_CONFIG",
967
1473
  "GET_BALANCE",
@@ -979,7 +1485,7 @@ var RETRYABLE_METHODS = /* @__PURE__ */ new Set([
979
1485
  var RETRY_ATTEMPT_TIMEOUTS_MS = [
980
1486
  5e3,
981
1487
  1e4,
982
- import_utils3.POST_MESSAGE_REQUEST_TIMEOUT_MS
1488
+ import_utils4.POST_MESSAGE_REQUEST_TIMEOUT_MS
983
1489
  ];
984
1490
  var RETRY_BACKOFF_MS = [200, 400];
985
1491
  var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
@@ -1064,7 +1570,7 @@ var WebViewBridge = class {
1064
1570
  resolver.resolve(message.data);
1065
1571
  } else {
1066
1572
  const err = new Error(message.error || "WebView bridge error");
1067
- for (const key of import_utils3.FORWARDED_ERROR_FIELDS) {
1573
+ for (const key of import_utils4.FORWARDED_ERROR_FIELDS) {
1068
1574
  const value = message[key];
1069
1575
  if (value !== void 0) {
1070
1576
  err[key] = value;
@@ -1124,7 +1630,7 @@ var WebViewBridge = class {
1124
1630
  type,
1125
1631
  method,
1126
1632
  payload,
1127
- (0, import_utils3.getPostMessageRequestTimeout)(method)
1633
+ (0, import_utils4.getPostMessageRequestTimeout)(method)
1128
1634
  );
1129
1635
  }
1130
1636
  let lastError;
@@ -1224,7 +1730,7 @@ var WebViewBridge = class {
1224
1730
  };
1225
1731
 
1226
1732
  // src/provider.tsx
1227
- var import_react3 = require("@moon-x/core/react");
1733
+ var import_react4 = require("@moon-x/core/react");
1228
1734
  var import_lib2 = require("@moon-x/core/lib");
1229
1735
 
1230
1736
  // src/webview-lifecycle.ts
@@ -1462,7 +1968,7 @@ function createNativeSession(reads) {
1462
1968
 
1463
1969
  // src/session-resume.ts
1464
1970
  var import_sdk10 = require("@moon-x/core/sdk");
1465
- var import_utils4 = require("@moon-x/core/utils");
1971
+ var import_utils5 = require("@moon-x/core/utils");
1466
1972
  var LOGOUT_TOMBSTONE = '{"loggedOut":true}';
1467
1973
  var sharedStates = /* @__PURE__ */ new Map();
1468
1974
  var sharedState = (publishableKey) => {
@@ -1646,8 +2152,8 @@ var createNativeSessionResume = ({
1646
2152
  let result = null;
1647
2153
  try {
1648
2154
  result = await bridge.send(
1649
- import_utils4.PostMessageType.AUTH,
1650
- import_utils4.PostMessageMethod.SESSION_RESUME_BIND,
2155
+ import_utils5.PostMessageType.AUTH,
2156
+ import_utils5.PostMessageMethod.SESSION_RESUME_BIND,
1651
2157
  { publishableKey, publicKey: record.publicKey }
1652
2158
  );
1653
2159
  } catch {
@@ -1670,8 +2176,8 @@ var createNativeSessionResume = ({
1670
2176
  const sessionId = record?.sessionId;
1671
2177
  if (!record || !sessionId) return false;
1672
2178
  const check = await bridge.send(
1673
- import_utils4.PostMessageType.AUTH,
1674
- import_utils4.PostMessageMethod.IS_AUTHENTICATED,
2179
+ import_utils5.PostMessageType.AUTH,
2180
+ import_utils5.PostMessageMethod.IS_AUTHENTICATED,
1675
2181
  { publishableKey, resumeSessionId: sessionId }
1676
2182
  );
1677
2183
  if (check?.isAuthenticated === true) return true;
@@ -1684,8 +2190,8 @@ var createNativeSessionResume = ({
1684
2190
  const signature = (0, import_sdk10.signSessionResume)(record.privateKey, sessionId, challenge);
1685
2191
  if (!signature) return false;
1686
2192
  const resumed = await bridge.send(
1687
- import_utils4.PostMessageType.AUTH,
1688
- import_utils4.PostMessageMethod.SESSION_RESUME,
2193
+ import_utils5.PostMessageType.AUTH,
2194
+ import_utils5.PostMessageMethod.SESSION_RESUME,
1689
2195
  { publishableKey, sessionId, challenge, signature }
1690
2196
  );
1691
2197
  if (resumed?.resumeRejected) {
@@ -1759,7 +2265,7 @@ var createNativeSessionResume = ({
1759
2265
  // src/provider.tsx
1760
2266
  var import_jsx_runtime2 = require("react/jsx-runtime");
1761
2267
  var DEFAULT_IFRAME_URL = "https://x-iframe.moonpay.com";
1762
- var MoonXContext = (0, import_react2.createContext)(null);
2268
+ var MoonXContext = (0, import_react3.createContext)(null);
1763
2269
  var MoonXProvider = ({
1764
2270
  publishableKey,
1765
2271
  config,
@@ -1771,20 +2277,20 @@ var MoonXProvider = ({
1771
2277
  var NativeProvider = ({ publishableKey, config, children }) => {
1772
2278
  const iframeUrl = config?.iframeUrl ?? DEFAULT_IFRAME_URL;
1773
2279
  const relyingPartyOrigin = config?.relyingPartyOrigin ?? "";
1774
- const webViewRef = (0, import_react2.useRef)(null);
1775
- const bridge = (0, import_react2.useMemo)(
2280
+ const webViewRef = (0, import_react3.useRef)(null);
2281
+ const bridge = (0, import_react3.useMemo)(
1776
2282
  () => new WebViewBridge(
1777
2283
  webViewRef
1778
2284
  ),
1779
2285
  []
1780
2286
  );
1781
- const relyingPartyOriginResolver = (0, import_react2.useMemo)(
2287
+ const relyingPartyOriginResolver = (0, import_react3.useMemo)(
1782
2288
  () => makeRelyingPartyOriginResolver(bridge, publishableKey, relyingPartyOrigin),
1783
2289
  [bridge, publishableKey, relyingPartyOrigin]
1784
2290
  );
1785
- const [sensitiveVisible, setSensitiveVisible] = (0, import_react2.useState)(false);
1786
- const [captchaChallengeVisible, setCaptchaChallengeVisible] = (0, import_react2.useState)(false);
1787
- const cancelRef = (0, import_react2.useRef)(null);
2291
+ const [sensitiveVisible, setSensitiveVisible] = (0, import_react3.useState)(false);
2292
+ const [captchaChallengeVisible, setCaptchaChallengeVisible] = (0, import_react3.useState)(false);
2293
+ const cancelRef = (0, import_react3.useRef)(null);
1788
2294
  const webViewVisible = sensitiveVisible || captchaChallengeVisible;
1789
2295
  const [
1790
2296
  {
@@ -1793,9 +2299,9 @@ var NativeProvider = ({ publishableKey, config, children }) => {
1793
2299
  key: webViewKey
1794
2300
  },
1795
2301
  dispatchWebViewLifecycle
1796
- ] = (0, import_react2.useReducer)(webViewLifecycleReducer, initialWebViewLifecycleState);
2302
+ ] = (0, import_react3.useReducer)(webViewLifecycleReducer, initialWebViewLifecycleState);
1797
2303
  const sessionResumeStorage = config?.sessionResumeStorage;
1798
- const sessionResume = (0, import_react2.useMemo)(
2304
+ const sessionResume = (0, import_react3.useMemo)(
1799
2305
  () => sessionResumeStorage ? createNativeSessionResume({
1800
2306
  bridge,
1801
2307
  publishableKey,
@@ -1804,67 +2310,67 @@ var NativeProvider = ({ publishableKey, config, children }) => {
1804
2310
  }) : void 0,
1805
2311
  [bridge, publishableKey, sessionResumeStorage]
1806
2312
  );
1807
- const session = (0, import_react2.useMemo)(
2313
+ const session = (0, import_react3.useMemo)(
1808
2314
  () => createNativeSession({
1809
- getCurrentSession: () => bridge.send(import_utils5.PostMessageType.AUTH, import_utils5.PostMessageMethod.GET_CURRENT_SESSION, { publishableKey }),
1810
- getUser: () => bridge.send(import_utils5.PostMessageType.AUTH, import_utils5.PostMessageMethod.GET_USER, { publishableKey }),
2315
+ getCurrentSession: () => bridge.send(import_utils6.PostMessageType.AUTH, import_utils6.PostMessageMethod.GET_CURRENT_SESSION, { publishableKey }),
2316
+ getUser: () => bridge.send(import_utils6.PostMessageType.AUTH, import_utils6.PostMessageMethod.GET_USER, { publishableKey }),
1811
2317
  resume: sessionResume?.resume
1812
2318
  }),
1813
2319
  [bridge, publishableKey, sessionResume]
1814
2320
  );
1815
- const sessionSnapshot = (0, import_react2.useSyncExternalStore)(session.subscribe, session.getSnapshot, session.getSnapshot);
2321
+ const sessionSnapshot = (0, import_react3.useSyncExternalStore)(session.subscribe, session.getSnapshot, session.getSnapshot);
1816
2322
  const { isAuthenticated, user, revalidatedAt } = sessionSnapshot;
1817
2323
  const { beginAuthFlow, refreshUser } = session;
1818
- (0, import_react2.useLayoutEffect)(() => {
2324
+ (0, import_react3.useLayoutEffect)(() => {
1819
2325
  session.mount();
1820
2326
  return session.unmount;
1821
2327
  }, [session]);
1822
- (0, import_react2.useEffect)(() => {
2328
+ (0, import_react3.useEffect)(() => {
1823
2329
  session.setReady(ready);
1824
2330
  }, [session, ready]);
1825
2331
  const { sessionStatus } = sessionSnapshot;
1826
- (0, import_react2.useEffect)(() => {
2332
+ (0, import_react3.useEffect)(() => {
1827
2333
  if (!sessionResume || !ready || sessionStatus !== "authenticated") return;
1828
2334
  void sessionResume.bind();
1829
2335
  }, [sessionResume, ready, sessionStatus, revalidatedAt]);
1830
- (0, import_react2.useEffect)(() => {
1831
- const subscription = import_react_native2.AppState.addEventListener("change", (nextState) => {
2336
+ (0, import_react3.useEffect)(() => {
2337
+ const subscription = import_react_native3.AppState.addEventListener("change", (nextState) => {
1832
2338
  if (nextState === "active") {
1833
2339
  session.restartSession();
1834
2340
  }
1835
2341
  });
1836
2342
  return () => subscription.remove();
1837
2343
  }, [session]);
1838
- const { height: screenHeight } = (0, import_react_native2.useWindowDimensions)();
2344
+ const { height: screenHeight } = (0, import_react_native3.useWindowDimensions)();
1839
2345
  const SHEET_TOP_OFFSET = 80;
1840
- const sheetTranslateY = (0, import_react2.useRef)(new import_react_native2.Animated.Value(screenHeight)).current;
1841
- const backdropOpacity = (0, import_react2.useRef)(new import_react_native2.Animated.Value(0)).current;
1842
- (0, import_react2.useEffect)(() => {
1843
- import_react_native2.Animated.parallel([
1844
- import_react_native2.Animated.timing(sheetTranslateY, {
2346
+ const sheetTranslateY = (0, import_react3.useRef)(new import_react_native3.Animated.Value(screenHeight)).current;
2347
+ const backdropOpacity = (0, import_react3.useRef)(new import_react_native3.Animated.Value(0)).current;
2348
+ (0, import_react3.useEffect)(() => {
2349
+ import_react_native3.Animated.parallel([
2350
+ import_react_native3.Animated.timing(sheetTranslateY, {
1845
2351
  toValue: webViewVisible ? 0 : screenHeight,
1846
2352
  duration: 280,
1847
2353
  useNativeDriver: true
1848
2354
  }),
1849
- import_react_native2.Animated.timing(backdropOpacity, {
2355
+ import_react_native3.Animated.timing(backdropOpacity, {
1850
2356
  toValue: webViewVisible ? 0.5 : 0,
1851
2357
  duration: 280,
1852
2358
  useNativeDriver: true
1853
2359
  })
1854
2360
  ]).start();
1855
2361
  }, [webViewVisible, sheetTranslateY, backdropOpacity, screenHeight]);
1856
- const initialSourceUri = (0, import_react2.useMemo)(() => {
2362
+ const initialSourceUri = (0, import_react3.useMemo)(() => {
1857
2363
  const base = iframeUrl.replace(/\/$/, "");
1858
2364
  const sep = base.includes("?") ? "&" : "?";
1859
2365
  return `${base}${sep}publishableKey=${encodeURIComponent(publishableKey)}`;
1860
2366
  }, [iframeUrl, publishableKey]);
1861
- const handleMessage = (0, import_react2.useCallback)(
2367
+ const handleMessage = (0, import_react3.useCallback)(
1862
2368
  (event) => {
1863
2369
  bridge.handleMessage({ nativeEvent: { data: event.nativeEvent.data } });
1864
2370
  },
1865
2371
  [bridge]
1866
2372
  );
1867
- const navigateWebView = (0, import_react2.useCallback)(
2373
+ const navigateWebView = (0, import_react3.useCallback)(
1868
2374
  (path) => {
1869
2375
  const ref = webViewRef.current;
1870
2376
  if (!ref) return;
@@ -1879,7 +2385,7 @@ var NativeProvider = ({ publishableKey, config, children }) => {
1879
2385
  },
1880
2386
  [iframeUrl, publishableKey]
1881
2387
  );
1882
- const runSensitiveFlow = (0, import_react2.useCallback)(
2388
+ const runSensitiveFlow = (0, import_react3.useCallback)(
1883
2389
  (options) => {
1884
2390
  setSensitiveVisible(true);
1885
2391
  navigateWebView(options.flowPath);
@@ -1921,7 +2427,7 @@ var NativeProvider = ({ publishableKey, config, children }) => {
1921
2427
  },
1922
2428
  [bridge, navigateWebView]
1923
2429
  );
1924
- const sdk = (0, import_react2.useMemo)(
2430
+ const sdk = (0, import_react3.useMemo)(
1925
2431
  () => createSdkInstance({
1926
2432
  bridge,
1927
2433
  publishableKey,
@@ -1953,18 +2459,18 @@ var NativeProvider = ({ publishableKey, config, children }) => {
1953
2459
  sessionSnapshot
1954
2460
  ]
1955
2461
  );
1956
- const sessionResumeRef = (0, import_react2.useRef)(sessionResume);
2462
+ const sessionResumeRef = (0, import_react3.useRef)(sessionResume);
1957
2463
  sessionResumeRef.current = sessionResume;
1958
- (0, import_react2.useEffect)(() => {
2464
+ (0, import_react3.useEffect)(() => {
1959
2465
  return () => {
1960
2466
  sessionResumeRef.current?.cancelPendingBinds();
1961
2467
  bridge.cleanup("provider_unmounted");
1962
2468
  };
1963
2469
  }, [bridge]);
1964
- (0, import_react2.useEffect)(
2470
+ (0, import_react3.useEffect)(
1965
2471
  () => bridge.register(
1966
- import_utils5.PostMessageType.INIT,
1967
- import_utils5.PostMessageMethod.CAPTCHA_CHALLENGE_VISIBILITY,
2472
+ import_utils6.PostMessageType.INIT,
2473
+ import_utils6.PostMessageMethod.CAPTCHA_CHALLENGE_VISIBILITY,
1968
2474
  (payload) => {
1969
2475
  if (typeof payload?.visible === "boolean") {
1970
2476
  setCaptchaChallengeVisible(payload.visible);
@@ -1973,17 +2479,17 @@ var NativeProvider = ({ publishableKey, config, children }) => {
1973
2479
  ),
1974
2480
  [bridge]
1975
2481
  );
1976
- (0, import_react2.useEffect)(() => {
2482
+ (0, import_react3.useEffect)(() => {
1977
2483
  const unsubscribe = bridge.onResponseError((error) => {
1978
2484
  if (error.message === "no_session") session.retrySession();
1979
2485
  });
1980
2486
  return unsubscribe;
1981
2487
  }, [bridge, session]);
1982
- (0, import_react2.useEffect)(() => {
2488
+ (0, import_react3.useEffect)(() => {
1983
2489
  let cancelled = false;
1984
2490
  const unregister = bridge.register(
1985
- import_utils5.PostMessageType.INIT,
1986
- import_utils5.PostMessageMethod.READY,
2491
+ import_utils6.PostMessageType.INIT,
2492
+ import_utils6.PostMessageMethod.READY,
1987
2493
  () => {
1988
2494
  if (!cancelled) dispatchWebViewLifecycle({ type: "ready" });
1989
2495
  }
@@ -1997,7 +2503,7 @@ var NativeProvider = ({ publishableKey, config, children }) => {
1997
2503
  clearTimeout(fallback);
1998
2504
  };
1999
2505
  }, [bridge, webViewRecoveryNonce]);
2000
- const contextValue = (0, import_react2.useMemo)(
2506
+ const contextValue = (0, import_react3.useMemo)(
2001
2507
  () => ({
2002
2508
  sdk,
2003
2509
  _bridge: bridge,
@@ -2016,7 +2522,7 @@ var NativeProvider = ({ publishableKey, config, children }) => {
2016
2522
  ]
2017
2523
  );
2018
2524
  const closeLabel = config?.sensitiveModalCopy?.closeLabel ?? "Done";
2019
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(MoonXContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react3.SDKProvider, { value: sdk, children: [
2525
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(MoonXContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react4.SDKProvider, { value: sdk, children: [
2020
2526
  children,
2021
2527
  config?.presenceOtpPrompt !== false && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2022
2528
  PresenceOtpPrompt,
@@ -2026,14 +2532,14 @@ var NativeProvider = ({ publishableKey, config, children }) => {
2026
2532
  }
2027
2533
  ),
2028
2534
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2029
- import_react_native2.Animated.View,
2535
+ import_react_native3.Animated.View,
2030
2536
  {
2031
2537
  style: [styles2.backdrop, { opacity: backdropOpacity }],
2032
2538
  pointerEvents: webViewVisible ? "auto" : "none",
2033
2539
  children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2034
- import_react_native2.Pressable,
2540
+ import_react_native3.Pressable,
2035
2541
  {
2036
- style: import_react_native2.StyleSheet.absoluteFill,
2542
+ style: import_react_native3.StyleSheet.absoluteFill,
2037
2543
  onPress: () => {
2038
2544
  if (sensitiveVisible) cancelRef.current?.();
2039
2545
  }
@@ -2042,7 +2548,7 @@ var NativeProvider = ({ publishableKey, config, children }) => {
2042
2548
  }
2043
2549
  ),
2044
2550
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2045
- import_react_native2.Animated.View,
2551
+ import_react_native3.Animated.View,
2046
2552
  {
2047
2553
  style: [
2048
2554
  styles2.sheetContainer,
@@ -2054,16 +2560,16 @@ var NativeProvider = ({ publishableKey, config, children }) => {
2054
2560
  pointerEvents: webViewVisible ? "auto" : "none",
2055
2561
  children: [
2056
2562
  sensitiveVisible && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
2057
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native2.View, { style: styles2.sheetGrabber }),
2058
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_native2.View, { style: styles2.modalChrome, children: [
2059
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native2.View, { style: styles2.modalTitleSpacer }),
2563
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native3.View, { style: styles2.sheetGrabber }),
2564
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_native3.View, { style: styles2.modalChrome, children: [
2565
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native3.View, { style: styles2.modalTitleSpacer }),
2060
2566
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2061
- import_react_native2.Pressable,
2567
+ import_react_native3.Pressable,
2062
2568
  {
2063
2569
  onPress: () => cancelRef.current?.(),
2064
2570
  hitSlop: 12,
2065
2571
  style: styles2.closeButton,
2066
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native2.Text, { style: styles2.closeButtonText, children: closeLabel })
2572
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native3.Text, { style: styles2.closeButtonText, children: closeLabel })
2067
2573
  }
2068
2574
  )
2069
2575
  ] })
@@ -2090,8 +2596,8 @@ var NativeProvider = ({ publishableKey, config, children }) => {
2090
2596
  webviewDebuggingEnabled: __DEV__,
2091
2597
  javaScriptEnabled: true,
2092
2598
  domStorageEnabled: true,
2093
- sharedCookiesEnabled: import_react_native2.Platform.OS === "ios",
2094
- thirdPartyCookiesEnabled: import_react_native2.Platform.OS === "android",
2599
+ sharedCookiesEnabled: import_react_native3.Platform.OS === "ios",
2600
+ thirdPartyCookiesEnabled: import_react_native3.Platform.OS === "android",
2095
2601
  startInLoadingState: false,
2096
2602
  originWhitelist: ["https://*", "http://*"],
2097
2603
  style: styles2.webView
@@ -2104,13 +2610,13 @@ var NativeProvider = ({ publishableKey, config, children }) => {
2104
2610
  ] }) });
2105
2611
  };
2106
2612
  var useMoonXContext = () => {
2107
- const ctx = (0, import_react2.useContext)(MoonXContext);
2613
+ const ctx = (0, import_react3.useContext)(MoonXContext);
2108
2614
  if (!ctx) {
2109
2615
  throw new Error("useMoonX must be used within a MoonXProvider");
2110
2616
  }
2111
2617
  return ctx;
2112
2618
  };
2113
- var styles2 = import_react_native2.StyleSheet.create({
2619
+ var styles2 = import_react_native3.StyleSheet.create({
2114
2620
  backdrop: {
2115
2621
  position: "absolute",
2116
2622
  top: 0,
@@ -2160,7 +2666,7 @@ var styles2 = import_react_native2.StyleSheet.create({
2160
2666
  paddingBottom: 12,
2161
2667
  paddingHorizontal: 16,
2162
2668
  backgroundColor: "#0a0a0a",
2163
- borderBottomWidth: import_react_native2.StyleSheet.hairlineWidth,
2669
+ borderBottomWidth: import_react_native3.StyleSheet.hairlineWidth,
2164
2670
  borderBottomColor: "#222"
2165
2671
  },
2166
2672
  // Empty flex spacer keeps the close button right-aligned without
@@ -2182,19 +2688,19 @@ var styles2 = import_react_native2.StyleSheet.create({
2182
2688
  });
2183
2689
 
2184
2690
  // src/hooks/index.ts
2185
- var import_react9 = require("@moon-x/core/react");
2691
+ var import_react10 = require("@moon-x/core/react");
2186
2692
 
2187
2693
  // src/hooks/use-app-config.ts
2188
- var import_utils6 = require("@moon-x/core/utils");
2189
- var import_react4 = require("react");
2694
+ var import_utils7 = require("@moon-x/core/utils");
2695
+ var import_react5 = require("react");
2190
2696
  var useAppConfig = (publishableKey) => {
2191
2697
  const { sdk, _bridge } = useMoonXContext();
2192
2698
  const resolvedKey = publishableKey ?? sdk.publishableKey;
2193
2699
  const ready = sdk.ready;
2194
- const [appConfig, setAppConfig] = (0, import_react4.useState)(null);
2195
- const [isLoading, setIsLoading] = (0, import_react4.useState)(true);
2196
- const [error, setError] = (0, import_react4.useState)(null);
2197
- (0, import_react4.useEffect)(() => {
2700
+ const [appConfig, setAppConfig] = (0, import_react5.useState)(null);
2701
+ const [isLoading, setIsLoading] = (0, import_react5.useState)(true);
2702
+ const [error, setError] = (0, import_react5.useState)(null);
2703
+ (0, import_react5.useEffect)(() => {
2198
2704
  if (!resolvedKey) {
2199
2705
  setIsLoading(false);
2200
2706
  return;
@@ -2208,7 +2714,7 @@ var useAppConfig = (publishableKey) => {
2208
2714
  setError(null);
2209
2715
  setAppConfig(null);
2210
2716
  try {
2211
- const config = await _bridge.send(import_utils6.PostMessageType.AUTH, import_utils6.PostMessageMethod.GET_APP_CONFIG, {
2717
+ const config = await _bridge.send(import_utils7.PostMessageType.AUTH, import_utils7.PostMessageMethod.GET_APP_CONFIG, {
2212
2718
  publishableKey: resolvedKey
2213
2719
  });
2214
2720
  if (!cancelled) setAppConfig(config);
@@ -2229,8 +2735,7 @@ var useAppConfig = (publishableKey) => {
2229
2735
  };
2230
2736
 
2231
2737
  // src/hooks/use-attach-oauth.ts
2232
- var import_utils7 = require("@moon-x/core/utils");
2233
- var import_react5 = require("react");
2738
+ var import_react6 = require("react");
2234
2739
 
2235
2740
  // src/lib/oauth-deep-link.ts
2236
2741
  var openOAuthFlow = async ({
@@ -2270,8 +2775,8 @@ var parseOAuthRedirect = async (redirectUrl) => {
2270
2775
 
2271
2776
  // src/hooks/use-attach-oauth.ts
2272
2777
  var useAttachOAuth = (params) => {
2273
- const { sdk, _bridge, _oauthRedirectUri } = useMoonXContext();
2274
- const [state, setState] = (0, import_react5.useState)({ status: "idle" });
2778
+ const { sdk, _oauthRedirectUri } = useMoonXContext();
2779
+ const [state, setState] = (0, import_react6.useState)({ status: "idle" });
2275
2780
  return {
2276
2781
  state,
2277
2782
  attachOAuth: async (provider) => {
@@ -2279,15 +2784,9 @@ var useAttachOAuth = (params) => {
2279
2784
  try {
2280
2785
  const redirectUri = params?.redirectUri || _oauthRedirectUri;
2281
2786
  if (!redirectUri) throw new Error("oauth_redirect_uri_missing");
2282
- const startResult = await _bridge.send(
2283
- import_utils7.PostMessageType.AUTH,
2284
- import_utils7.PostMessageMethod.START_OAUTH,
2285
- {
2286
- publishableKey: sdk.publishableKey,
2287
- provider,
2288
- attach: true,
2289
- login_redirect_url: redirectUri
2290
- }
2787
+ const startResult = await sdk.beginOAuthLink(
2788
+ provider,
2789
+ redirectUri
2291
2790
  );
2292
2791
  if (!startResult.redirect_url) {
2293
2792
  throw new Error("start_oauth_failed");
@@ -2299,18 +2798,16 @@ var useAttachOAuth = (params) => {
2299
2798
  });
2300
2799
  const parsed = await parseOAuthRedirect(redirectUrl);
2301
2800
  if (parsed.error) throw new Error(parsed.error);
2801
+ if (!parsed.code && !parsed.token) {
2802
+ throw new Error("oauth_no_code_or_token");
2803
+ }
2302
2804
  setState({ status: "verifying" });
2303
- await _bridge.send(
2304
- import_utils7.PostMessageType.AUTH,
2305
- import_utils7.PostMessageMethod.ATTACH_OAUTH,
2306
- {
2307
- publishableKey: sdk.publishableKey,
2308
- provider,
2309
- code: parsed.code,
2310
- token: parsed.token,
2311
- state: parsed.state
2312
- }
2313
- );
2805
+ await sdk.verifyOAuthLink({
2806
+ provider,
2807
+ code: parsed.code,
2808
+ token: parsed.token,
2809
+ state: parsed.state
2810
+ });
2314
2811
  setState({ status: "complete" });
2315
2812
  } catch (e) {
2316
2813
  const err = e instanceof Error ? e : new Error(String(e));
@@ -2323,23 +2820,22 @@ var useAttachOAuth = (params) => {
2323
2820
  };
2324
2821
 
2325
2822
  // src/hooks/use-detach-oauth.ts
2326
- var import_utils8 = require("@moon-x/core/utils");
2327
2823
  var useDetachOAuth = () => {
2328
- const { sdk, _bridge } = useMoonXContext();
2824
+ const { sdk } = useMoonXContext();
2329
2825
  return {
2826
+ // Removes a Google or Apple sign-in by its id in the user's
2827
+ // linked_accounts, with the presence step-up first when the backend asks
2828
+ // for one. Rejects with last_login_method rather than leave the account
2829
+ // with no way to sign in.
2330
2830
  detachOAuth: async (idpUserId) => {
2331
- await _bridge.send(
2332
- import_utils8.PostMessageType.AUTH,
2333
- import_utils8.PostMessageMethod.DETACH_OAUTH,
2334
- { publishableKey: sdk.publishableKey, idpUserId }
2335
- );
2831
+ await sdk.detachOAuth(idpUserId);
2336
2832
  }
2337
2833
  };
2338
2834
  };
2339
2835
 
2340
2836
  // src/hooks/use-export-key.ts
2341
2837
  var import_sdk11 = require("@moon-x/core/sdk");
2342
- var import_utils9 = require("@moon-x/core/utils");
2838
+ var import_utils8 = require("@moon-x/core/utils");
2343
2839
  var parseExportKeyResult = (value) => {
2344
2840
  if (!value || typeof value !== "object" || !("status" in value)) {
2345
2841
  return { status: "failed", error: "invalid_export_key_result" };
@@ -2383,8 +2879,8 @@ var useExportKey = () => {
2383
2879
  title: "Export key",
2384
2880
  flowPath: `/export-key?${params.toString()}#${secrets.toString()}`,
2385
2881
  onMount: ({ bridge, setResult }) => bridge.register(
2386
- import_utils9.PostMessageType.WALLET,
2387
- import_utils9.PostMessageMethod.EXPORT_KEY_RESULT,
2882
+ import_utils8.PostMessageType.WALLET,
2883
+ import_utils8.PostMessageMethod.EXPORT_KEY_RESULT,
2388
2884
  (result) => {
2389
2885
  setResult(parseExportKeyResult(result));
2390
2886
  }
@@ -2407,13 +2903,13 @@ var useFundWallet = () => {
2407
2903
  };
2408
2904
 
2409
2905
  // src/hooks/use-login-with-email.ts
2410
- var import_react6 = require("@moon-x/core/react");
2411
- var import_react7 = require("react");
2906
+ var import_react7 = require("@moon-x/core/react");
2907
+ var import_react8 = require("react");
2412
2908
  var useLoginWithEmail = (callbacks) => {
2413
- const login = (0, import_react6.useLoginWithEmail)(callbacks);
2909
+ const login = (0, import_react7.useLoginWithEmail)(callbacks);
2414
2910
  const { _beginAuthFlow } = useMoonXContext();
2415
2911
  const coreLoginWithCode = login.loginWithCode;
2416
- const loginWithCode = (0, import_react7.useCallback)(
2912
+ const loginWithCode = (0, import_react8.useCallback)(
2417
2913
  async (params) => {
2418
2914
  const finishAuthFlow = _beginAuthFlow();
2419
2915
  try {
@@ -2428,14 +2924,14 @@ var useLoginWithEmail = (callbacks) => {
2428
2924
  };
2429
2925
 
2430
2926
  // src/hooks/use-login-with-oauth.ts
2431
- var import_utils10 = require("@moon-x/core/utils");
2432
- var import_react8 = require("react");
2927
+ var import_utils9 = require("@moon-x/core/utils");
2928
+ var import_react9 = require("react");
2433
2929
  var useLoginWithOAuth = (params) => {
2434
2930
  const { sdk, _bridge, _oauthRedirectUri, _beginAuthFlow } = useMoonXContext();
2435
- const [state, setState] = (0, import_react8.useState)({ status: "idle" });
2436
- const activeFlow = (0, import_react8.useRef)(null);
2437
- const mounted = (0, import_react8.useRef)(true);
2438
- (0, import_react8.useEffect)(() => {
2931
+ const [state, setState] = (0, import_react9.useState)({ status: "idle" });
2932
+ const activeFlow = (0, import_react9.useRef)(null);
2933
+ const mounted = (0, import_react9.useRef)(true);
2934
+ (0, import_react9.useEffect)(() => {
2439
2935
  mounted.current = true;
2440
2936
  return () => {
2441
2937
  mounted.current = false;
@@ -2462,8 +2958,8 @@ var useLoginWithOAuth = (params) => {
2462
2958
  throw new Error("oauth_redirect_uri_missing");
2463
2959
  }
2464
2960
  const startResult = await _bridge.send(
2465
- import_utils10.PostMessageType.AUTH,
2466
- import_utils10.PostMessageMethod.START_OAUTH,
2961
+ import_utils9.PostMessageType.AUTH,
2962
+ import_utils9.PostMessageMethod.START_OAUTH,
2467
2963
  {
2468
2964
  publishableKey: sdk.publishableKey,
2469
2965
  provider,
@@ -2510,17 +3006,17 @@ var useLoginWithOAuth = (params) => {
2510
3006
  var useMoonX = () => useMoonXContext().sdk;
2511
3007
 
2512
3008
  // src/external-wallets/use-external-wallets.ts
2513
- var import_react10 = require("react");
3009
+ var import_react11 = require("react");
2514
3010
  var useExternalWallets = (connectors) => {
2515
- const [wallets, setWallets] = (0, import_react10.useState)([]);
2516
- const [connected, setConnected] = (0, import_react10.useState)(
3011
+ const [wallets, setWallets] = (0, import_react11.useState)([]);
3012
+ const [connected, setConnected] = (0, import_react11.useState)(
2517
3013
  null
2518
3014
  );
2519
- const [status, setStatus] = (0, import_react10.useState)("idle");
2520
- const [error, setError] = (0, import_react10.useState)(null);
2521
- const [refreshNonce, setRefreshNonce] = (0, import_react10.useState)(0);
2522
- const unsubscribeRef = (0, import_react10.useRef)(null);
2523
- (0, import_react10.useEffect)(() => {
3015
+ const [status, setStatus] = (0, import_react11.useState)("idle");
3016
+ const [error, setError] = (0, import_react11.useState)(null);
3017
+ const [refreshNonce, setRefreshNonce] = (0, import_react11.useState)(0);
3018
+ const unsubscribeRef = (0, import_react11.useRef)(null);
3019
+ (0, import_react11.useEffect)(() => {
2524
3020
  let cancelled = false;
2525
3021
  void Promise.all(
2526
3022
  connectors.map(async (connector) => ({
@@ -2534,13 +3030,13 @@ var useExternalWallets = (connectors) => {
2534
3030
  cancelled = true;
2535
3031
  };
2536
3032
  }, [connectors, refreshNonce]);
2537
- (0, import_react10.useEffect)(
3033
+ (0, import_react11.useEffect)(
2538
3034
  () => () => {
2539
3035
  unsubscribeRef.current?.();
2540
3036
  },
2541
3037
  []
2542
3038
  );
2543
- const connect = (0, import_react10.useCallback)(
3039
+ const connect = (0, import_react11.useCallback)(
2544
3040
  async (id) => {
2545
3041
  const connector = connectors.find((candidate) => candidate.info.id === id);
2546
3042
  if (!connector) throw new Error(`External wallet "${id}" not found`);
@@ -2571,7 +3067,7 @@ var useExternalWallets = (connectors) => {
2571
3067
  },
2572
3068
  [connectors]
2573
3069
  );
2574
- const switchAccount = (0, import_react10.useCallback)(
3070
+ const switchAccount = (0, import_react11.useCallback)(
2575
3071
  async (address, chainId) => {
2576
3072
  if (!connected) throw new Error("No external wallet connected");
2577
3073
  const activeAccount = await connected.switchAccount(address, chainId);
@@ -2581,7 +3077,7 @@ var useExternalWallets = (connectors) => {
2581
3077
  },
2582
3078
  [connected]
2583
3079
  );
2584
- const disconnect = (0, import_react10.useCallback)(async () => {
3080
+ const disconnect = (0, import_react11.useCallback)(async () => {
2585
3081
  try {
2586
3082
  await connected?.disconnect();
2587
3083
  } finally {
@@ -2869,7 +3365,7 @@ var restoreWalletConnectSession = (options) => {
2869
3365
  // src/index.ts
2870
3366
  var import_sdk12 = require("@moon-x/core/sdk");
2871
3367
  var import_sdk13 = require("@moon-x/core/sdk");
2872
- var import_utils11 = require("@moon-x/core/utils");
3368
+ var import_utils10 = require("@moon-x/core/utils");
2873
3369
  // Annotate the CommonJS export names for ESM import in node:
2874
3370
  0 && (module.exports = {
2875
3371
  MOONPAY_CONSUMER_SESSION_ERROR_CODES,