@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.mjs CHANGED
@@ -3,22 +3,22 @@ import {
3
3
  createContext,
4
4
  useCallback,
5
5
  useContext,
6
- useEffect as useEffect2,
6
+ useEffect as useEffect3,
7
7
  useLayoutEffect,
8
8
  useMemo,
9
9
  useReducer,
10
10
  useRef as useRef2,
11
- useState as useState2,
11
+ useState as useState3,
12
12
  useSyncExternalStore
13
13
  } from "react";
14
14
  import {
15
- Animated,
15
+ Animated as Animated2,
16
16
  AppState,
17
- Platform,
17
+ Platform as Platform2,
18
18
  Pressable as Pressable2,
19
19
  StyleSheet as StyleSheet2,
20
20
  Text as Text2,
21
- useWindowDimensions,
21
+ useWindowDimensions as useWindowDimensions2,
22
22
  View as View2
23
23
  } from "react-native";
24
24
  import { WebView } from "react-native-webview";
@@ -521,6 +521,24 @@ function getSessionMethods(bridge, publishableKey, relyingPartyOrigin, session,
521
521
  await refreshUser();
522
522
  return result;
523
523
  },
524
+ // Redeems the provider's token for a link (useAttachOAuth). The user
525
+ // stays the same account, so unlike verifyOAuth this isn't a login: a
526
+ // failed link leaves the session-resume binding and the published user
527
+ // alone, and a successful one refreshes the user like linkEmailWithCode.
528
+ verifyOAuthLink: async (params) => {
529
+ const refreshUser = session.captureUserRefresh();
530
+ await auth().verifyOAuthLink(params);
531
+ await refreshUser();
532
+ },
533
+ // linked_accounts changed, so the published user is read again, the same
534
+ // as after a link. (Core's own refresh needs a raw setUser, which the
535
+ // session-managed provider doesn't hand it.)
536
+ detachOAuth: async (idpUserId) => {
537
+ const refreshUser = session.captureUserRefresh();
538
+ const result = await general().detachOAuth(idpUserId);
539
+ await refreshUser();
540
+ return result;
541
+ },
524
542
  // The account's email changes, so the provider's user is read again
525
543
  // before the change resolves, the same as a link.
526
544
  confirmEmailChangeNewCode: async (params) => {
@@ -600,17 +618,53 @@ var createSdkInstance = ({
600
618
  import { PostMessageMethod as PostMessageMethod4, PostMessageType as PostMessageType4 } from "@moon-x/core/utils";
601
619
 
602
620
  // src/components/presence-otp-prompt.tsx
603
- import { useEffect, useRef, useState } from "react";
621
+ import React, { useEffect as useEffect2, useRef, useState as useState2 } from "react";
604
622
  import {
623
+ AccessibilityInfo as AccessibilityInfo2,
624
+ ActivityIndicator,
625
+ Animated,
626
+ Easing,
627
+ KeyboardAvoidingView,
605
628
  Modal,
629
+ Platform,
606
630
  Pressable,
631
+ ScrollView,
607
632
  StyleSheet,
608
633
  Text,
609
634
  TextInput,
610
- View
635
+ View,
636
+ useColorScheme,
637
+ useWindowDimensions
611
638
  } from "react-native";
612
639
  import { registerPresenceOtpCodeProvider } from "@moon-x/core/sdk";
613
640
 
641
+ // src/components/use-reduce-motion.ts
642
+ import { useEffect, useState } from "react";
643
+ import { AccessibilityInfo } from "react-native";
644
+ var lastKnown;
645
+ var useReduceMotion = () => {
646
+ const [state, setState] = useState(() => ({
647
+ reduceMotion: lastKnown ?? true,
648
+ settled: lastKnown !== void 0
649
+ }));
650
+ useEffect(() => {
651
+ let live = true;
652
+ const update = (enabled) => {
653
+ lastKnown = enabled;
654
+ if (live) setState({ reduceMotion: enabled, settled: true });
655
+ };
656
+ AccessibilityInfo.isReduceMotionEnabled().then(update).catch(() => {
657
+ if (live) setState((current) => ({ ...current, settled: true }));
658
+ });
659
+ const subscription = AccessibilityInfo.addEventListener("reduceMotionChanged", update);
660
+ return () => {
661
+ live = false;
662
+ subscription.remove();
663
+ };
664
+ }, []);
665
+ return state;
666
+ };
667
+
614
668
  // src/components/presence-otp-gate.ts
615
669
  var createPresenceOtpGate = () => {
616
670
  let cancelledChallengeId = null;
@@ -721,42 +775,160 @@ var createPresenceOtpController = (onChange) => {
721
775
  };
722
776
  };
723
777
 
724
- // src/components/presence-otp-prompt.tsx
725
- import { jsx, jsxs } from "react/jsx-runtime";
726
- var DEFAULT_COPY = {
727
- title: "Check your email",
728
- description: "Enter the verification code we sent to confirm this wallet action.",
729
- hint: "Didn't get it? Check spam, or cancel and try again in a minute.",
730
- verify: "Verify",
731
- verifying: "Verifying...",
732
- cancel: "Cancel",
733
- invalidCode: "That code was incorrect. Try again.",
734
- incompleteCode: "Enter the 6-digit code."
778
+ // src/components/presence-otp-strings.ts
779
+ import { resolveLanguage } from "@moon-x/core/utils";
780
+ var PROMPT_LANGUAGES = ["en", "de", "es", "fr", "it", "pt"];
781
+ var COPY = {
782
+ en: {
783
+ title: "Check your email",
784
+ description: "Enter the code we sent to confirm this wallet action.",
785
+ hint: "",
786
+ verify: "Verify",
787
+ verifying: "Verifying\u2026",
788
+ cancel: "Cancel",
789
+ close: "Close",
790
+ invalidCode: "That code didn't work. Try again.",
791
+ incompleteCode: "Enter the 6-digit code.",
792
+ codeLabel: "Verification code"
793
+ },
794
+ de: {
795
+ title: "Pr\xFCfe deine E-Mails",
796
+ description: "Gib den Code ein, den wir dir gesendet haben, um diese Wallet-Aktion zu best\xE4tigen.",
797
+ hint: "",
798
+ verify: "Best\xE4tigen",
799
+ verifying: "Wird best\xE4tigt\u2026",
800
+ cancel: "Abbrechen",
801
+ close: "Schlie\xDFen",
802
+ invalidCode: "Der Code hat nicht funktioniert. Versuche es erneut.",
803
+ incompleteCode: "Gib den 6-stelligen Code ein.",
804
+ codeLabel: "Best\xE4tigungscode"
805
+ },
806
+ es: {
807
+ title: "Revisa tu correo",
808
+ description: "Introduce el c\xF3digo que te enviamos para confirmar esta acci\xF3n de la billetera.",
809
+ hint: "",
810
+ verify: "Verificar",
811
+ verifying: "Verificando\u2026",
812
+ cancel: "Cancelar",
813
+ close: "Cerrar",
814
+ invalidCode: "Ese c\xF3digo no funcion\xF3. Int\xE9ntalo de nuevo.",
815
+ incompleteCode: "Introduce el c\xF3digo de 6 d\xEDgitos.",
816
+ codeLabel: "C\xF3digo de verificaci\xF3n"
817
+ },
818
+ fr: {
819
+ title: "Consultez vos e-mails",
820
+ description: "Saisissez le code que nous vous avons envoy\xE9 pour confirmer cette action sur le portefeuille.",
821
+ hint: "",
822
+ verify: "V\xE9rifier",
823
+ verifying: "V\xE9rification\u2026",
824
+ cancel: "Annuler",
825
+ close: "Fermer",
826
+ invalidCode: "Ce code n'a pas fonctionn\xE9. R\xE9essayez.",
827
+ incompleteCode: "Saisissez le code \xE0 6 chiffres.",
828
+ codeLabel: "Code de v\xE9rification"
829
+ },
830
+ it: {
831
+ title: "Controlla la tua email",
832
+ description: "Inserisci il codice che ti abbiamo inviato per confermare questa azione sul wallet.",
833
+ hint: "",
834
+ verify: "Verifica",
835
+ verifying: "Verifica in corso\u2026",
836
+ cancel: "Annulla",
837
+ close: "Chiudi",
838
+ invalidCode: "Il codice non \xE8 valido. Riprova.",
839
+ incompleteCode: "Inserisci il codice a 6 cifre.",
840
+ codeLabel: "Codice di verifica"
841
+ },
842
+ pt: {
843
+ title: "Verifique seu e-mail",
844
+ description: "Digite o c\xF3digo que enviamos para confirmar esta a\xE7\xE3o na carteira.",
845
+ hint: "",
846
+ verify: "Verificar",
847
+ verifying: "Verificando\u2026",
848
+ cancel: "Cancelar",
849
+ close: "Fechar",
850
+ invalidCode: "Esse c\xF3digo n\xE3o funcionou. Tente novamente.",
851
+ incompleteCode: "Digite o c\xF3digo de 6 d\xEDgitos.",
852
+ codeLabel: "C\xF3digo de verifica\xE7\xE3o"
853
+ }
854
+ };
855
+ var LIGHT_COLORS = {
856
+ background: "#ffffff",
857
+ surface: "#f4f3f9",
858
+ border: "#e6e4ef",
859
+ text: "#010101",
860
+ mutedText: "#747386",
861
+ accent: "#010101",
862
+ accentText: "#fcfbff",
863
+ error: "#c41f1f",
864
+ errorSurface: "#f6e4e4",
865
+ backdrop: "rgba(1, 1, 1, 0.32)"
866
+ };
867
+ var DARK_COLORS = {
868
+ background: "#0b0b0d",
869
+ surface: "#17171b",
870
+ border: "#292930",
871
+ text: "#fcfbff",
872
+ mutedText: "#9e9bae",
873
+ accent: "#fcfbff",
874
+ accentText: "#010101",
875
+ error: "#ff9b98",
876
+ errorSurface: "#3c0202",
877
+ backdrop: "rgba(1, 1, 1, 0.32)"
735
878
  };
736
- var DEFAULT_COLORS = {
737
- background: "#0a0a0a",
738
- surface: "#141414",
739
- border: "#333",
740
- text: "#fafafa",
741
- mutedText: "#a1a1aa",
742
- accent: "#3b82f6",
743
- accentText: "#fff",
744
- error: "#f87171"
879
+ var deviceLanguage = () => {
880
+ try {
881
+ return Intl.DateTimeFormat().resolvedOptions().locale;
882
+ } catch {
883
+ return void 0;
884
+ }
745
885
  };
886
+ var resolvePromptCopy = (language) => {
887
+ return COPY[resolveLanguage(language ?? deviceLanguage(), PROMPT_LANGUAGES, "en")];
888
+ };
889
+ var resolvePromptColors = (displayMode, systemScheme) => {
890
+ const dark = displayMode === "dark" || displayMode !== "light" && systemScheme === "dark";
891
+ return dark ? DARK_COLORS : LIGHT_COLORS;
892
+ };
893
+
894
+ // src/components/presence-otp-prompt.tsx
895
+ import { jsx, jsxs } from "react/jsx-runtime";
746
896
  var OTP_LENGTH = 6;
897
+ var SHEET_MAX_WIDTH = 480;
898
+ var COMPACT_MAX_WIDTH = 360;
747
899
  var PresenceOtpPrompt = ({
748
900
  publishableKey,
749
901
  options
750
902
  }) => {
751
- const [state, setState] = useState(
903
+ const [state, setState] = useState2(
752
904
  IDLE_PRESENCE_OTP_STATE
753
905
  );
754
- const [code, setCode] = useState("");
755
- const [incomplete, setIncomplete] = useState(false);
906
+ const [code, setCode] = useState2("");
907
+ const [incomplete, setIncomplete] = useState2(false);
908
+ const [edited, setEdited] = useState2(false);
909
+ const [focused, setFocused] = useState2(false);
756
910
  const controllerRef = useRef(null);
757
- const copy = { ...DEFAULT_COPY, ...options?.copy };
758
- const colors = { ...DEFAULT_COLORS, ...options?.colors };
759
- useEffect(() => {
911
+ const inputRef = useRef(null);
912
+ const sheetOffset = useRef(new Animated.Value(0)).current;
913
+ const shake = useRef(new Animated.Value(0)).current;
914
+ const caret = useRef(new Animated.Value(1)).current;
915
+ const { reduceMotion, settled: motionSettled } = useReduceMotion();
916
+ const shakePending = useRef(false);
917
+ const scheme = useColorScheme();
918
+ const { width } = useWindowDimensions();
919
+ const copy = { ...resolvePromptCopy(options?.language), ...options?.copy };
920
+ const colors = {
921
+ ...resolvePromptColors(options?.displayMode, scheme),
922
+ ...options?.colors
923
+ };
924
+ const visible = state.request !== null;
925
+ const submitting = state.submitting;
926
+ const invalid = state.invalidCode && !edited;
927
+ const error = incomplete ? copy.incompleteCode : invalid ? copy.invalidCode : null;
928
+ const complete = code.length === OTP_LENGTH;
929
+ const sheet = width <= SHEET_MAX_WIDTH;
930
+ const compact = width <= COMPACT_MAX_WIDTH;
931
+ useEffect2(() => {
760
932
  const controller = createPresenceOtpController(setState);
761
933
  controllerRef.current = controller;
762
934
  const unregister = registerPresenceOtpCodeProvider(
@@ -771,11 +943,63 @@ var PresenceOtpPrompt = ({
771
943
  setState(IDLE_PRESENCE_OTP_STATE);
772
944
  };
773
945
  }, [publishableKey]);
774
- useEffect(() => {
946
+ const shakeCells = () => {
947
+ shake.setValue(0);
948
+ Animated.sequence(
949
+ [-6, 6, -4, 4, -2, 0].map(
950
+ (toValue) => Animated.timing(shake, {
951
+ toValue,
952
+ duration: 60,
953
+ easing: Easing.linear,
954
+ useNativeDriver: true
955
+ })
956
+ )
957
+ ).start();
958
+ };
959
+ useEffect2(() => {
775
960
  setCode("");
776
961
  setIncomplete(false);
962
+ setEdited(false);
963
+ shakePending.current = false;
964
+ if (!state.request) return;
965
+ inputRef.current?.focus();
966
+ if (!state.invalidCode) return;
967
+ if (!motionSettled) shakePending.current = true;
968
+ else if (!reduceMotion) shakeCells();
777
969
  }, [state.request]);
778
- useEffect(() => {
970
+ useEffect2(() => {
971
+ if (!motionSettled || !shakePending.current) return;
972
+ shakePending.current = false;
973
+ if (!reduceMotion) shakeCells();
974
+ }, [motionSettled]);
975
+ useEffect2(() => {
976
+ if (!visible) return;
977
+ sheetOffset.setValue(reduceMotion ? 0 : 24);
978
+ Animated.timing(sheetOffset, {
979
+ toValue: 0,
980
+ duration: 240,
981
+ easing: Easing.out(Easing.cubic),
982
+ useNativeDriver: true
983
+ }).start();
984
+ }, [visible]);
985
+ useEffect2(() => {
986
+ caret.setValue(1);
987
+ if (!focused || reduceMotion) return;
988
+ const blink = Animated.loop(
989
+ Animated.sequence([
990
+ Animated.timing(caret, { toValue: 0, duration: 0, delay: 530, useNativeDriver: true }),
991
+ Animated.timing(caret, { toValue: 1, duration: 0, delay: 530, useNativeDriver: true })
992
+ ])
993
+ );
994
+ blink.start();
995
+ return () => blink.stop();
996
+ }, [focused, reduceMotion, code]);
997
+ useEffect2(() => {
998
+ if (error && Platform.OS === "ios") {
999
+ AccessibilityInfo2.announceForAccessibility(error);
1000
+ }
1001
+ }, [error]);
1002
+ useEffect2(() => {
779
1003
  const request = state.request;
780
1004
  if (!request?.expiresAt || state.submitting) return;
781
1005
  const expire = () => controllerRef.current?.expire(request);
@@ -790,155 +1014,446 @@ var PresenceOtpPrompt = ({
790
1014
  const close = () => {
791
1015
  controllerRef.current?.cancel();
792
1016
  };
793
- const submit = () => {
794
- const normalized = code.trim();
795
- if (!/^\d{6}$/.test(normalized)) {
1017
+ const submit = (value = code) => {
1018
+ if (!/^\d{6}$/.test(value)) {
796
1019
  setIncomplete(true);
797
1020
  return;
798
1021
  }
799
- controllerRef.current?.submit(normalized);
1022
+ controllerRef.current?.submit(value);
800
1023
  };
801
- const submitting = state.submitting;
802
- const error = incomplete ? copy.incompleteCode : state.invalidCode ? copy.invalidCode : null;
803
- const complete = code.length === OTP_LENGTH;
1024
+ const changeCode = (next) => {
1025
+ if (submitting) return;
1026
+ const clean = next.replace(/\D/g, "").slice(0, OTP_LENGTH);
1027
+ setCode(clean);
1028
+ setIncomplete(false);
1029
+ setEdited(true);
1030
+ if (clean.length === OTP_LENGTH) submit(clean);
1031
+ };
1032
+ const cells = Array.from({ length: OTP_LENGTH }, (_, index) => {
1033
+ const digit = code[index] ?? "";
1034
+ const current = focused && !submitting && index === Math.min(code.length, OTP_LENGTH - 1);
1035
+ return /* @__PURE__ */ jsxs(React.Fragment, { children: [
1036
+ index === OTP_LENGTH / 2 && /* @__PURE__ */ jsx(View, { style: [styles.separator, { backgroundColor: colors.mutedText }] }),
1037
+ /* @__PURE__ */ jsx(
1038
+ View,
1039
+ {
1040
+ style: [
1041
+ styles.cell,
1042
+ compact && styles.cellCompact,
1043
+ { backgroundColor: colors.background, borderColor: colors.border },
1044
+ current && { borderColor: colors.accent },
1045
+ invalid && { borderColor: colors.error, backgroundColor: colors.errorSurface }
1046
+ ],
1047
+ children: digit ? /* @__PURE__ */ jsx(Text, { style: [styles.cellText, { color: invalid ? colors.error : colors.text }], children: digit }) : current && /* @__PURE__ */ jsx(
1048
+ Animated.View,
1049
+ {
1050
+ style: [styles.caret, { backgroundColor: colors.accent, opacity: caret }]
1051
+ }
1052
+ )
1053
+ }
1054
+ )
1055
+ ] }, index);
1056
+ });
804
1057
  return /* @__PURE__ */ jsx(
805
1058
  Modal,
806
1059
  {
807
- visible: state.request !== null,
1060
+ visible,
808
1061
  transparent: true,
809
1062
  animationType: "fade",
810
1063
  onRequestClose: close,
811
- children: /* @__PURE__ */ jsx(View, { style: styles.backdrop, children: /* @__PURE__ */ jsxs(View, { style: [styles.card, { backgroundColor: colors.background }], children: [
812
- /* @__PURE__ */ jsx(Text, { style: [styles.title, { color: colors.text }], children: copy.title }),
813
- /* @__PURE__ */ jsx(Text, { style: [styles.body, { color: colors.mutedText }], children: copy.description }),
814
- /* @__PURE__ */ jsx(
815
- TextInput,
816
- {
817
- autoFocus: true,
818
- style: [
819
- styles.input,
820
- {
821
- borderColor: colors.border,
822
- backgroundColor: colors.surface,
823
- color: colors.text
824
- }
825
- ],
826
- value: code,
827
- onChangeText: (next) => {
828
- setCode(next.replace(/\D/g, "").slice(0, OTP_LENGTH));
829
- setIncomplete(false);
830
- },
831
- onSubmitEditing: submit,
832
- editable: !submitting,
833
- keyboardType: "number-pad",
834
- textContentType: "oneTimeCode",
835
- autoComplete: "sms-otp",
836
- maxLength: OTP_LENGTH,
837
- placeholder: "123456",
838
- placeholderTextColor: colors.mutedText,
839
- accessibilityLabel: "Verification code",
840
- returnKeyType: "done"
841
- }
842
- ),
843
- error !== null && /* @__PURE__ */ jsx(
844
- Text,
845
- {
846
- style: [styles.error, { color: colors.error }],
847
- accessibilityLiveRegion: "polite",
848
- children: error
849
- }
850
- ),
851
- /* @__PURE__ */ jsx(
852
- Pressable,
853
- {
854
- onPress: submit,
855
- disabled: submitting || !complete,
856
- style: [
857
- styles.primaryButton,
858
- { backgroundColor: colors.accent },
859
- (submitting || !complete) && styles.primaryButtonDisabled
860
- ],
861
- accessibilityRole: "button",
862
- children: /* @__PURE__ */ jsx(Text, { style: [styles.primaryButtonText, { color: colors.accentText }], children: submitting ? copy.verifying : copy.verify })
863
- }
864
- ),
865
- /* @__PURE__ */ jsx(
866
- Pressable,
867
- {
868
- onPress: close,
869
- disabled: submitting,
870
- style: [styles.ghostButton, submitting && styles.primaryButtonDisabled],
871
- accessibilityRole: "button",
872
- children: /* @__PURE__ */ jsx(Text, { style: [styles.ghostButtonText, { color: colors.mutedText }], children: copy.cancel })
873
- }
874
- ),
875
- /* @__PURE__ */ jsx(Text, { style: [styles.hint, { color: colors.mutedText }], children: copy.hint })
876
- ] }) })
1064
+ onShow: () => inputRef.current?.focus(),
1065
+ children: /* @__PURE__ */ jsx(
1066
+ KeyboardAvoidingView,
1067
+ {
1068
+ behavior: Platform.OS === "ios" ? "padding" : void 0,
1069
+ style: [
1070
+ styles.backdrop,
1071
+ sheet ? styles.backdropSheet : styles.backdropCentered,
1072
+ { backgroundColor: colors.backdrop }
1073
+ ],
1074
+ children: /* @__PURE__ */ jsxs(
1075
+ Animated.View,
1076
+ {
1077
+ accessibilityViewIsModal: true,
1078
+ style: [
1079
+ styles.card,
1080
+ sheet ? styles.sheet : styles.centered,
1081
+ {
1082
+ backgroundColor: colors.background,
1083
+ borderColor: colors.border,
1084
+ transform: [{ translateY: sheetOffset }]
1085
+ }
1086
+ ],
1087
+ children: [
1088
+ /* @__PURE__ */ jsx(View, { style: styles.header, children: /* @__PURE__ */ jsx(
1089
+ Pressable,
1090
+ {
1091
+ onPress: close,
1092
+ disabled: submitting,
1093
+ hitSlop: 8,
1094
+ accessibilityRole: "button",
1095
+ accessibilityLabel: copy.close,
1096
+ style: ({ pressed }) => [
1097
+ styles.iconButton,
1098
+ { backgroundColor: pressed ? colors.border : colors.surface },
1099
+ submitting && styles.disabled
1100
+ ],
1101
+ children: /* @__PURE__ */ jsx(CloseIcon, { color: colors.mutedText })
1102
+ }
1103
+ ) }),
1104
+ /* @__PURE__ */ jsxs(
1105
+ ScrollView,
1106
+ {
1107
+ bounces: false,
1108
+ keyboardShouldPersistTaps: "handled",
1109
+ contentContainerStyle: styles.content,
1110
+ children: [
1111
+ /* @__PURE__ */ jsxs(View, { style: styles.body, children: [
1112
+ /* @__PURE__ */ jsxs(View, { style: styles.hero, children: [
1113
+ /* @__PURE__ */ jsx(View, { style: [styles.iconDisc, { backgroundColor: colors.surface }], children: /* @__PURE__ */ jsx(MailIcon, { color: colors.text }) }),
1114
+ /* @__PURE__ */ jsxs(View, { style: styles.heroText, children: [
1115
+ /* @__PURE__ */ jsx(Text, { accessibilityRole: "header", style: [styles.title, { color: colors.text }], children: copy.title }),
1116
+ /* @__PURE__ */ jsx(Text, { style: [styles.description, { color: colors.mutedText }], children: copy.description })
1117
+ ] })
1118
+ ] }),
1119
+ /* @__PURE__ */ jsxs(View, { children: [
1120
+ /* @__PURE__ */ jsx(
1121
+ Animated.View,
1122
+ {
1123
+ accessibilityElementsHidden: true,
1124
+ importantForAccessibility: "no-hide-descendants",
1125
+ style: [
1126
+ styles.cells,
1127
+ compact && styles.cellsCompact,
1128
+ submitting && styles.cellsBusy,
1129
+ { transform: [{ translateX: shake }] }
1130
+ ],
1131
+ children: cells
1132
+ }
1133
+ ),
1134
+ /* @__PURE__ */ jsx(
1135
+ TextInput,
1136
+ {
1137
+ ref: inputRef,
1138
+ autoFocus: true,
1139
+ value: code,
1140
+ onChangeText: changeCode,
1141
+ onSubmitEditing: () => submit(),
1142
+ onFocus: () => setFocused(true),
1143
+ onBlur: () => setFocused(false),
1144
+ keyboardType: "number-pad",
1145
+ textContentType: "oneTimeCode",
1146
+ autoComplete: "sms-otp",
1147
+ autoCorrect: false,
1148
+ spellCheck: false,
1149
+ caretHidden: true,
1150
+ selectionColor: colors.accent,
1151
+ accessibilityLabel: copy.codeLabel,
1152
+ returnKeyType: "done",
1153
+ style: styles.codeInput
1154
+ }
1155
+ )
1156
+ ] }),
1157
+ error !== null && /* @__PURE__ */ jsxs(View, { style: styles.error, accessibilityLiveRegion: "polite", children: [
1158
+ /* @__PURE__ */ jsx(AlertIcon, { color: colors.error }),
1159
+ /* @__PURE__ */ jsx(Text, { style: [styles.errorText, { color: colors.error }], children: error })
1160
+ ] })
1161
+ ] }),
1162
+ /* @__PURE__ */ jsxs(View, { style: styles.actions, children: [
1163
+ /* @__PURE__ */ jsxs(
1164
+ Pressable,
1165
+ {
1166
+ onPress: () => submit(),
1167
+ disabled: !complete || submitting,
1168
+ accessibilityRole: "button",
1169
+ accessibilityState: { disabled: !complete || submitting, busy: submitting },
1170
+ style: ({ pressed }) => [
1171
+ styles.button,
1172
+ { backgroundColor: colors.accent },
1173
+ pressed && styles.pressed,
1174
+ !complete && !submitting && styles.disabled
1175
+ ],
1176
+ children: [
1177
+ submitting && /* @__PURE__ */ jsx(ActivityIndicator, { size: "small", color: colors.accentText }),
1178
+ /* @__PURE__ */ jsx(Text, { style: [styles.buttonText, { color: colors.accentText }], children: submitting ? copy.verifying : copy.verify })
1179
+ ]
1180
+ }
1181
+ ),
1182
+ /* @__PURE__ */ jsx(
1183
+ Pressable,
1184
+ {
1185
+ onPress: close,
1186
+ disabled: submitting,
1187
+ accessibilityRole: "button",
1188
+ style: ({ pressed }) => [
1189
+ styles.button,
1190
+ pressed && { backgroundColor: colors.surface },
1191
+ submitting && styles.disabled
1192
+ ],
1193
+ children: ({ pressed }) => /* @__PURE__ */ jsx(
1194
+ Text,
1195
+ {
1196
+ style: [styles.buttonText, { color: pressed ? colors.text : colors.mutedText }],
1197
+ children: copy.cancel
1198
+ }
1199
+ )
1200
+ }
1201
+ ),
1202
+ copy.hint ? /* @__PURE__ */ jsx(Text, { style: [styles.hint, { color: colors.mutedText }], children: copy.hint }) : null
1203
+ ] })
1204
+ ]
1205
+ }
1206
+ )
1207
+ ]
1208
+ }
1209
+ )
1210
+ }
1211
+ )
877
1212
  }
878
1213
  );
879
1214
  };
1215
+ var CloseIcon = ({ color }) => /* @__PURE__ */ jsxs(View, { style: styles.closeIcon, children: [
1216
+ /* @__PURE__ */ jsx(View, { style: [styles.closeBar, { backgroundColor: color, transform: [{ rotate: "45deg" }] }] }),
1217
+ /* @__PURE__ */ jsx(View, { style: [styles.closeBar, { backgroundColor: color, transform: [{ rotate: "-45deg" }] }] })
1218
+ ] });
1219
+ var MailIcon = ({ color }) => /* @__PURE__ */ jsxs(View, { style: styles.mailIcon, children: [
1220
+ /* @__PURE__ */ jsx(View, { style: [styles.mailBody, { borderColor: color }] }),
1221
+ /* @__PURE__ */ jsx(View, { style: [styles.mailFlap, styles.mailFlapLeft, { backgroundColor: color }] }),
1222
+ /* @__PURE__ */ jsx(View, { style: [styles.mailFlap, styles.mailFlapRight, { backgroundColor: color }] })
1223
+ ] });
1224
+ var AlertIcon = ({ color }) => /* @__PURE__ */ jsxs(View, { style: [styles.alertIcon, { borderColor: color }], children: [
1225
+ /* @__PURE__ */ jsx(View, { style: [styles.alertStem, { backgroundColor: color }] }),
1226
+ /* @__PURE__ */ jsx(View, { style: [styles.alertDot, { backgroundColor: color }] })
1227
+ ] });
880
1228
  var styles = StyleSheet.create({
881
1229
  backdrop: {
882
- flex: 1,
1230
+ flex: 1
1231
+ },
1232
+ backdropSheet: {
1233
+ justifyContent: "flex-end"
1234
+ },
1235
+ backdropCentered: {
883
1236
  alignItems: "center",
884
1237
  justifyContent: "center",
885
- padding: 16,
886
- backgroundColor: "rgba(0, 0, 0, 0.45)"
1238
+ padding: 16
887
1239
  },
888
1240
  card: {
889
1241
  width: "100%",
890
- maxWidth: 384,
891
- padding: 24,
892
- borderRadius: 14
1242
+ maxHeight: "100%",
1243
+ overflow: "hidden"
1244
+ },
1245
+ sheet: {
1246
+ borderTopLeftRadius: 24,
1247
+ borderTopRightRadius: 24,
1248
+ borderTopWidth: 1
1249
+ },
1250
+ centered: {
1251
+ maxWidth: 400,
1252
+ borderRadius: 24,
1253
+ borderWidth: 1
1254
+ },
1255
+ header: {
1256
+ flexDirection: "row",
1257
+ justifyContent: "flex-end",
1258
+ alignItems: "center",
1259
+ height: 56,
1260
+ paddingHorizontal: 16
1261
+ },
1262
+ iconButton: {
1263
+ width: 32,
1264
+ height: 32,
1265
+ borderRadius: 8,
1266
+ alignItems: "center",
1267
+ justifyContent: "center"
1268
+ },
1269
+ content: {
1270
+ paddingHorizontal: 24,
1271
+ // Clear of the home indicator when the keyboard is down.
1272
+ paddingBottom: 32
1273
+ },
1274
+ body: {
1275
+ gap: 16
1276
+ },
1277
+ hero: {
1278
+ alignItems: "center",
1279
+ gap: 16,
1280
+ paddingTop: 8
1281
+ },
1282
+ iconDisc: {
1283
+ width: 64,
1284
+ height: 64,
1285
+ borderRadius: 32,
1286
+ alignItems: "center",
1287
+ justifyContent: "center"
1288
+ },
1289
+ heroText: {
1290
+ width: "100%",
1291
+ gap: 4
893
1292
  },
894
1293
  title: {
895
1294
  fontSize: 20,
896
- fontWeight: "600"
1295
+ lineHeight: 24,
1296
+ fontWeight: "500",
1297
+ letterSpacing: -0.4,
1298
+ textAlign: "center"
897
1299
  },
898
- body: {
1300
+ description: {
899
1301
  fontSize: 14,
900
- marginTop: 8
1302
+ lineHeight: 20,
1303
+ textAlign: "center"
901
1304
  },
902
- input: {
903
- marginTop: 16,
904
- paddingVertical: 12,
905
- paddingHorizontal: 16,
1305
+ cells: {
1306
+ flexDirection: "row",
1307
+ alignItems: "center",
1308
+ justifyContent: "center",
1309
+ gap: 8
1310
+ },
1311
+ cellsCompact: {
1312
+ gap: 6
1313
+ },
1314
+ cellsBusy: {
1315
+ opacity: 0.6
1316
+ },
1317
+ cell: {
1318
+ width: 44,
1319
+ height: 52,
1320
+ borderWidth: 1,
906
1321
  borderRadius: 12,
907
- borderWidth: StyleSheet.hairlineWidth,
908
- fontSize: 24,
909
- letterSpacing: 8,
910
- textAlign: "center"
1322
+ alignItems: "center",
1323
+ justifyContent: "center"
1324
+ },
1325
+ cellCompact: {
1326
+ width: 38,
1327
+ height: 48
1328
+ },
1329
+ cellText: {
1330
+ fontSize: 18,
1331
+ fontWeight: "500",
1332
+ fontVariant: ["tabular-nums"]
1333
+ },
1334
+ caret: {
1335
+ width: 1.5,
1336
+ height: 20,
1337
+ borderRadius: 1
1338
+ },
1339
+ separator: {
1340
+ width: 4,
1341
+ height: 4,
1342
+ borderRadius: 2,
1343
+ marginHorizontal: 4,
1344
+ opacity: 0.6
1345
+ },
1346
+ codeInput: {
1347
+ position: "absolute",
1348
+ top: 0,
1349
+ right: 0,
1350
+ bottom: 0,
1351
+ left: 0,
1352
+ // Not 0: iOS stops delivering touches to a view that is fully transparent.
1353
+ opacity: 0.015,
1354
+ color: "transparent",
1355
+ backgroundColor: "transparent",
1356
+ borderWidth: 0
911
1357
  },
912
1358
  error: {
913
- fontSize: 13,
914
- marginTop: 8
1359
+ flexDirection: "row",
1360
+ alignItems: "center",
1361
+ justifyContent: "center",
1362
+ gap: 4
915
1363
  },
916
- primaryButton: {
917
- marginTop: 16,
918
- paddingVertical: 12,
919
- borderRadius: 12,
920
- alignItems: "center"
1364
+ errorText: {
1365
+ flexShrink: 1,
1366
+ fontSize: 12,
1367
+ fontWeight: "500",
1368
+ textAlign: "center"
921
1369
  },
922
- primaryButtonDisabled: {
923
- opacity: 0.5
1370
+ actions: {
1371
+ gap: 8,
1372
+ paddingTop: 24
924
1373
  },
925
- primaryButtonText: {
1374
+ button: {
1375
+ flexDirection: "row",
1376
+ alignItems: "center",
1377
+ justifyContent: "center",
1378
+ gap: 8,
1379
+ height: 48,
1380
+ paddingHorizontal: 20,
1381
+ borderRadius: 999
1382
+ },
1383
+ buttonText: {
926
1384
  fontSize: 16,
927
- fontWeight: "600"
1385
+ fontWeight: "500"
928
1386
  },
929
- ghostButton: {
930
- marginTop: 8,
931
- paddingVertical: 12,
932
- alignItems: "center"
1387
+ pressed: {
1388
+ opacity: 0.88,
1389
+ transform: [{ scale: 0.985 }]
933
1390
  },
934
- ghostButtonText: {
935
- fontSize: 15,
936
- fontWeight: "500"
1391
+ disabled: {
1392
+ opacity: 0.5
937
1393
  },
938
1394
  hint: {
939
1395
  fontSize: 12,
940
- marginTop: 4,
1396
+ lineHeight: 16,
941
1397
  textAlign: "center"
1398
+ },
1399
+ closeIcon: {
1400
+ width: 16,
1401
+ height: 16,
1402
+ alignItems: "center",
1403
+ justifyContent: "center"
1404
+ },
1405
+ closeBar: {
1406
+ position: "absolute",
1407
+ width: 12,
1408
+ height: 1.5,
1409
+ borderRadius: 1
1410
+ },
1411
+ mailIcon: {
1412
+ width: 28,
1413
+ height: 28
1414
+ },
1415
+ mailBody: {
1416
+ position: "absolute",
1417
+ top: 5,
1418
+ left: 2,
1419
+ width: 24,
1420
+ height: 18,
1421
+ borderWidth: 2,
1422
+ borderRadius: 3
1423
+ },
1424
+ mailFlap: {
1425
+ position: "absolute",
1426
+ top: 10.6,
1427
+ width: 13,
1428
+ height: 2,
1429
+ borderRadius: 1
1430
+ },
1431
+ mailFlapLeft: {
1432
+ left: 2,
1433
+ transform: [{ rotate: "29.8deg" }]
1434
+ },
1435
+ mailFlapRight: {
1436
+ left: 13,
1437
+ transform: [{ rotate: "-29.8deg" }]
1438
+ },
1439
+ alertIcon: {
1440
+ width: 14,
1441
+ height: 14,
1442
+ borderRadius: 7,
1443
+ borderWidth: 1.25,
1444
+ alignItems: "center",
1445
+ justifyContent: "center",
1446
+ gap: 1
1447
+ },
1448
+ alertStem: {
1449
+ width: 1.5,
1450
+ height: 4,
1451
+ borderRadius: 1
1452
+ },
1453
+ alertDot: {
1454
+ width: 1.5,
1455
+ height: 1.5,
1456
+ borderRadius: 1
942
1457
  }
943
1458
  });
944
1459
 
@@ -1774,8 +2289,8 @@ var NativeProvider = ({ publishableKey, config, children }) => {
1774
2289
  () => makeRelyingPartyOriginResolver(bridge, publishableKey, relyingPartyOrigin),
1775
2290
  [bridge, publishableKey, relyingPartyOrigin]
1776
2291
  );
1777
- const [sensitiveVisible, setSensitiveVisible] = useState2(false);
1778
- const [captchaChallengeVisible, setCaptchaChallengeVisible] = useState2(false);
2292
+ const [sensitiveVisible, setSensitiveVisible] = useState3(false);
2293
+ const [captchaChallengeVisible, setCaptchaChallengeVisible] = useState3(false);
1779
2294
  const cancelRef = useRef2(null);
1780
2295
  const webViewVisible = sensitiveVisible || captchaChallengeVisible;
1781
2296
  const [
@@ -1811,15 +2326,15 @@ var NativeProvider = ({ publishableKey, config, children }) => {
1811
2326
  session.mount();
1812
2327
  return session.unmount;
1813
2328
  }, [session]);
1814
- useEffect2(() => {
2329
+ useEffect3(() => {
1815
2330
  session.setReady(ready);
1816
2331
  }, [session, ready]);
1817
2332
  const { sessionStatus } = sessionSnapshot;
1818
- useEffect2(() => {
2333
+ useEffect3(() => {
1819
2334
  if (!sessionResume || !ready || sessionStatus !== "authenticated") return;
1820
2335
  void sessionResume.bind();
1821
2336
  }, [sessionResume, ready, sessionStatus, revalidatedAt]);
1822
- useEffect2(() => {
2337
+ useEffect3(() => {
1823
2338
  const subscription = AppState.addEventListener("change", (nextState) => {
1824
2339
  if (nextState === "active") {
1825
2340
  session.restartSession();
@@ -1827,18 +2342,18 @@ var NativeProvider = ({ publishableKey, config, children }) => {
1827
2342
  });
1828
2343
  return () => subscription.remove();
1829
2344
  }, [session]);
1830
- const { height: screenHeight } = useWindowDimensions();
2345
+ const { height: screenHeight } = useWindowDimensions2();
1831
2346
  const SHEET_TOP_OFFSET = 80;
1832
- const sheetTranslateY = useRef2(new Animated.Value(screenHeight)).current;
1833
- const backdropOpacity = useRef2(new Animated.Value(0)).current;
1834
- useEffect2(() => {
1835
- Animated.parallel([
1836
- Animated.timing(sheetTranslateY, {
2347
+ const sheetTranslateY = useRef2(new Animated2.Value(screenHeight)).current;
2348
+ const backdropOpacity = useRef2(new Animated2.Value(0)).current;
2349
+ useEffect3(() => {
2350
+ Animated2.parallel([
2351
+ Animated2.timing(sheetTranslateY, {
1837
2352
  toValue: webViewVisible ? 0 : screenHeight,
1838
2353
  duration: 280,
1839
2354
  useNativeDriver: true
1840
2355
  }),
1841
- Animated.timing(backdropOpacity, {
2356
+ Animated2.timing(backdropOpacity, {
1842
2357
  toValue: webViewVisible ? 0.5 : 0,
1843
2358
  duration: 280,
1844
2359
  useNativeDriver: true
@@ -1947,13 +2462,13 @@ var NativeProvider = ({ publishableKey, config, children }) => {
1947
2462
  );
1948
2463
  const sessionResumeRef = useRef2(sessionResume);
1949
2464
  sessionResumeRef.current = sessionResume;
1950
- useEffect2(() => {
2465
+ useEffect3(() => {
1951
2466
  return () => {
1952
2467
  sessionResumeRef.current?.cancelPendingBinds();
1953
2468
  bridge.cleanup("provider_unmounted");
1954
2469
  };
1955
2470
  }, [bridge]);
1956
- useEffect2(
2471
+ useEffect3(
1957
2472
  () => bridge.register(
1958
2473
  PostMessageType4.INIT,
1959
2474
  PostMessageMethod4.CAPTCHA_CHALLENGE_VISIBILITY,
@@ -1965,13 +2480,13 @@ var NativeProvider = ({ publishableKey, config, children }) => {
1965
2480
  ),
1966
2481
  [bridge]
1967
2482
  );
1968
- useEffect2(() => {
2483
+ useEffect3(() => {
1969
2484
  const unsubscribe = bridge.onResponseError((error) => {
1970
2485
  if (error.message === "no_session") session.retrySession();
1971
2486
  });
1972
2487
  return unsubscribe;
1973
2488
  }, [bridge, session]);
1974
- useEffect2(() => {
2489
+ useEffect3(() => {
1975
2490
  let cancelled = false;
1976
2491
  const unregister = bridge.register(
1977
2492
  PostMessageType4.INIT,
@@ -2018,7 +2533,7 @@ var NativeProvider = ({ publishableKey, config, children }) => {
2018
2533
  }
2019
2534
  ),
2020
2535
  /* @__PURE__ */ jsx2(
2021
- Animated.View,
2536
+ Animated2.View,
2022
2537
  {
2023
2538
  style: [styles2.backdrop, { opacity: backdropOpacity }],
2024
2539
  pointerEvents: webViewVisible ? "auto" : "none",
@@ -2034,7 +2549,7 @@ var NativeProvider = ({ publishableKey, config, children }) => {
2034
2549
  }
2035
2550
  ),
2036
2551
  /* @__PURE__ */ jsxs2(
2037
- Animated.View,
2552
+ Animated2.View,
2038
2553
  {
2039
2554
  style: [
2040
2555
  styles2.sheetContainer,
@@ -2082,8 +2597,8 @@ var NativeProvider = ({ publishableKey, config, children }) => {
2082
2597
  webviewDebuggingEnabled: __DEV__,
2083
2598
  javaScriptEnabled: true,
2084
2599
  domStorageEnabled: true,
2085
- sharedCookiesEnabled: Platform.OS === "ios",
2086
- thirdPartyCookiesEnabled: Platform.OS === "android",
2600
+ sharedCookiesEnabled: Platform2.OS === "ios",
2601
+ thirdPartyCookiesEnabled: Platform2.OS === "android",
2087
2602
  startInLoadingState: false,
2088
2603
  originWhitelist: ["https://*", "http://*"],
2089
2604
  style: styles2.webView
@@ -2192,15 +2707,15 @@ import {
2192
2707
 
2193
2708
  // src/hooks/use-app-config.ts
2194
2709
  import { PostMessageMethod as PostMessageMethod5, PostMessageType as PostMessageType5 } from "@moon-x/core/utils";
2195
- import { useEffect as useEffect3, useState as useState3 } from "react";
2710
+ import { useEffect as useEffect4, useState as useState4 } from "react";
2196
2711
  var useAppConfig = (publishableKey) => {
2197
2712
  const { sdk, _bridge } = useMoonXContext();
2198
2713
  const resolvedKey = publishableKey ?? sdk.publishableKey;
2199
2714
  const ready = sdk.ready;
2200
- const [appConfig, setAppConfig] = useState3(null);
2201
- const [isLoading, setIsLoading] = useState3(true);
2202
- const [error, setError] = useState3(null);
2203
- useEffect3(() => {
2715
+ const [appConfig, setAppConfig] = useState4(null);
2716
+ const [isLoading, setIsLoading] = useState4(true);
2717
+ const [error, setError] = useState4(null);
2718
+ useEffect4(() => {
2204
2719
  if (!resolvedKey) {
2205
2720
  setIsLoading(false);
2206
2721
  return;
@@ -2235,8 +2750,7 @@ var useAppConfig = (publishableKey) => {
2235
2750
  };
2236
2751
 
2237
2752
  // src/hooks/use-attach-oauth.ts
2238
- import { PostMessageMethod as PostMessageMethod6, PostMessageType as PostMessageType6 } from "@moon-x/core/utils";
2239
- import { useState as useState4 } from "react";
2753
+ import { useState as useState5 } from "react";
2240
2754
 
2241
2755
  // src/lib/oauth-deep-link.ts
2242
2756
  var openOAuthFlow = async ({
@@ -2276,8 +2790,8 @@ var parseOAuthRedirect = async (redirectUrl) => {
2276
2790
 
2277
2791
  // src/hooks/use-attach-oauth.ts
2278
2792
  var useAttachOAuth = (params) => {
2279
- const { sdk, _bridge, _oauthRedirectUri } = useMoonXContext();
2280
- const [state, setState] = useState4({ status: "idle" });
2793
+ const { sdk, _oauthRedirectUri } = useMoonXContext();
2794
+ const [state, setState] = useState5({ status: "idle" });
2281
2795
  return {
2282
2796
  state,
2283
2797
  attachOAuth: async (provider) => {
@@ -2285,15 +2799,9 @@ var useAttachOAuth = (params) => {
2285
2799
  try {
2286
2800
  const redirectUri = params?.redirectUri || _oauthRedirectUri;
2287
2801
  if (!redirectUri) throw new Error("oauth_redirect_uri_missing");
2288
- const startResult = await _bridge.send(
2289
- PostMessageType6.AUTH,
2290
- PostMessageMethod6.START_OAUTH,
2291
- {
2292
- publishableKey: sdk.publishableKey,
2293
- provider,
2294
- attach: true,
2295
- login_redirect_url: redirectUri
2296
- }
2802
+ const startResult = await sdk.beginOAuthLink(
2803
+ provider,
2804
+ redirectUri
2297
2805
  );
2298
2806
  if (!startResult.redirect_url) {
2299
2807
  throw new Error("start_oauth_failed");
@@ -2305,18 +2813,16 @@ var useAttachOAuth = (params) => {
2305
2813
  });
2306
2814
  const parsed = await parseOAuthRedirect(redirectUrl);
2307
2815
  if (parsed.error) throw new Error(parsed.error);
2816
+ if (!parsed.code && !parsed.token) {
2817
+ throw new Error("oauth_no_code_or_token");
2818
+ }
2308
2819
  setState({ status: "verifying" });
2309
- await _bridge.send(
2310
- PostMessageType6.AUTH,
2311
- PostMessageMethod6.ATTACH_OAUTH,
2312
- {
2313
- publishableKey: sdk.publishableKey,
2314
- provider,
2315
- code: parsed.code,
2316
- token: parsed.token,
2317
- state: parsed.state
2318
- }
2319
- );
2820
+ await sdk.verifyOAuthLink({
2821
+ provider,
2822
+ code: parsed.code,
2823
+ token: parsed.token,
2824
+ state: parsed.state
2825
+ });
2320
2826
  setState({ status: "complete" });
2321
2827
  } catch (e) {
2322
2828
  const err = e instanceof Error ? e : new Error(String(e));
@@ -2329,23 +2835,22 @@ var useAttachOAuth = (params) => {
2329
2835
  };
2330
2836
 
2331
2837
  // src/hooks/use-detach-oauth.ts
2332
- import { PostMessageMethod as PostMessageMethod7, PostMessageType as PostMessageType7 } from "@moon-x/core/utils";
2333
2838
  var useDetachOAuth = () => {
2334
- const { sdk, _bridge } = useMoonXContext();
2839
+ const { sdk } = useMoonXContext();
2335
2840
  return {
2841
+ // Removes a Google or Apple sign-in by its id in the user's
2842
+ // linked_accounts, with the presence step-up first when the backend asks
2843
+ // for one. Rejects with last_login_method rather than leave the account
2844
+ // with no way to sign in.
2336
2845
  detachOAuth: async (idpUserId) => {
2337
- await _bridge.send(
2338
- PostMessageType7.AUTH,
2339
- PostMessageMethod7.DETACH_OAUTH,
2340
- { publishableKey: sdk.publishableKey, idpUserId }
2341
- );
2846
+ await sdk.detachOAuth(idpUserId);
2342
2847
  }
2343
2848
  };
2344
2849
  };
2345
2850
 
2346
2851
  // src/hooks/use-export-key.ts
2347
2852
  import { getInternalPresenceTokens as getInternalPresenceTokens2, SCOPES_EXPORT_KEY } from "@moon-x/core/sdk";
2348
- import { PostMessageMethod as PostMessageMethod8, PostMessageType as PostMessageType8 } from "@moon-x/core/utils";
2853
+ import { PostMessageMethod as PostMessageMethod6, PostMessageType as PostMessageType6 } from "@moon-x/core/utils";
2349
2854
  var parseExportKeyResult = (value) => {
2350
2855
  if (!value || typeof value !== "object" || !("status" in value)) {
2351
2856
  return { status: "failed", error: "invalid_export_key_result" };
@@ -2389,8 +2894,8 @@ var useExportKey = () => {
2389
2894
  title: "Export key",
2390
2895
  flowPath: `/export-key?${params.toString()}#${secrets.toString()}`,
2391
2896
  onMount: ({ bridge, setResult }) => bridge.register(
2392
- PostMessageType8.WALLET,
2393
- PostMessageMethod8.EXPORT_KEY_RESULT,
2897
+ PostMessageType6.WALLET,
2898
+ PostMessageMethod6.EXPORT_KEY_RESULT,
2394
2899
  (result) => {
2395
2900
  setResult(parseExportKeyResult(result));
2396
2901
  }
@@ -2436,14 +2941,14 @@ var useLoginWithEmail = (callbacks) => {
2436
2941
  };
2437
2942
 
2438
2943
  // src/hooks/use-login-with-oauth.ts
2439
- import { PostMessageMethod as PostMessageMethod9, PostMessageType as PostMessageType9 } from "@moon-x/core/utils";
2440
- import { useEffect as useEffect4, useRef as useRef3, useState as useState5 } from "react";
2944
+ import { PostMessageMethod as PostMessageMethod7, PostMessageType as PostMessageType7 } from "@moon-x/core/utils";
2945
+ import { useEffect as useEffect5, useRef as useRef3, useState as useState6 } from "react";
2441
2946
  var useLoginWithOAuth = (params) => {
2442
2947
  const { sdk, _bridge, _oauthRedirectUri, _beginAuthFlow } = useMoonXContext();
2443
- const [state, setState] = useState5({ status: "idle" });
2948
+ const [state, setState] = useState6({ status: "idle" });
2444
2949
  const activeFlow = useRef3(null);
2445
2950
  const mounted = useRef3(true);
2446
- useEffect4(() => {
2951
+ useEffect5(() => {
2447
2952
  mounted.current = true;
2448
2953
  return () => {
2449
2954
  mounted.current = false;
@@ -2470,8 +2975,8 @@ var useLoginWithOAuth = (params) => {
2470
2975
  throw new Error("oauth_redirect_uri_missing");
2471
2976
  }
2472
2977
  const startResult = await _bridge.send(
2473
- PostMessageType9.AUTH,
2474
- PostMessageMethod9.START_OAUTH,
2978
+ PostMessageType7.AUTH,
2979
+ PostMessageMethod7.START_OAUTH,
2475
2980
  {
2476
2981
  publishableKey: sdk.publishableKey,
2477
2982
  provider,
@@ -2518,17 +3023,17 @@ var useLoginWithOAuth = (params) => {
2518
3023
  var useMoonX = () => useMoonXContext().sdk;
2519
3024
 
2520
3025
  // src/external-wallets/use-external-wallets.ts
2521
- import { useCallback as useCallback3, useEffect as useEffect5, useRef as useRef4, useState as useState6 } from "react";
3026
+ import { useCallback as useCallback3, useEffect as useEffect6, useRef as useRef4, useState as useState7 } from "react";
2522
3027
  var useExternalWallets = (connectors) => {
2523
- const [wallets, setWallets] = useState6([]);
2524
- const [connected, setConnected] = useState6(
3028
+ const [wallets, setWallets] = useState7([]);
3029
+ const [connected, setConnected] = useState7(
2525
3030
  null
2526
3031
  );
2527
- const [status, setStatus] = useState6("idle");
2528
- const [error, setError] = useState6(null);
2529
- const [refreshNonce, setRefreshNonce] = useState6(0);
3032
+ const [status, setStatus] = useState7("idle");
3033
+ const [error, setError] = useState7(null);
3034
+ const [refreshNonce, setRefreshNonce] = useState7(0);
2530
3035
  const unsubscribeRef = useRef4(null);
2531
- useEffect5(() => {
3036
+ useEffect6(() => {
2532
3037
  let cancelled = false;
2533
3038
  void Promise.all(
2534
3039
  connectors.map(async (connector) => ({
@@ -2542,7 +3047,7 @@ var useExternalWallets = (connectors) => {
2542
3047
  cancelled = true;
2543
3048
  };
2544
3049
  }, [connectors, refreshNonce]);
2545
- useEffect5(
3050
+ useEffect6(
2546
3051
  () => () => {
2547
3052
  unsubscribeRef.current?.();
2548
3053
  },
@@ -2883,13 +3388,13 @@ var restoreWalletConnectSession = (options) => {
2883
3388
  // src/index.ts
2884
3389
  import { MOONPAY_CONSUMER_SESSION_ERROR_CODES } from "@moon-x/core/sdk";
2885
3390
  import { registerPresenceOtpCodeProvider as registerPresenceOtpCodeProvider2 } from "@moon-x/core/sdk";
2886
- import { PostMessageMethod as PostMessageMethod10, PostMessageType as PostMessageType10 } from "@moon-x/core/utils";
3391
+ import { PostMessageMethod as PostMessageMethod8, PostMessageType as PostMessageType8 } from "@moon-x/core/utils";
2887
3392
  export {
2888
3393
  MOONPAY_CONSUMER_SESSION_ERROR_CODES,
2889
3394
  MoonXProvider as MoonKeyProvider,
2890
3395
  MoonXProvider,
2891
- PostMessageMethod10 as PostMessageMethod,
2892
- PostMessageType10 as PostMessageType,
3396
+ PostMessageMethod8 as PostMessageMethod,
3397
+ PostMessageType8 as PostMessageType,
2893
3398
  connectWalletConnect,
2894
3399
  listWalletConnectSessions,
2895
3400
  registerPresenceOtpCodeProvider2 as registerPresenceOtpCodeProvider,