@moon-x/react-native-sdk 0.25.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/README.md +9 -3
- package/dist/ethereum.js +227 -51
- package/dist/ethereum.mjs +228 -43
- package/dist/index.d.mts +43 -4
- package/dist/index.d.ts +43 -4
- package/dist/index.js +799 -293
- package/dist/index.mjs +736 -221
- package/dist/solana.js +227 -51
- package/dist/solana.mjs +228 -43
- package/dist/tron.js +227 -51
- package/dist/tron.mjs +228 -43
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -3,22 +3,22 @@ import {
|
|
|
3
3
|
createContext,
|
|
4
4
|
useCallback,
|
|
5
5
|
useContext,
|
|
6
|
-
useEffect as
|
|
6
|
+
useEffect as useEffect3,
|
|
7
7
|
useLayoutEffect,
|
|
8
8
|
useMemo,
|
|
9
9
|
useReducer,
|
|
10
10
|
useRef as useRef2,
|
|
11
|
-
useState as
|
|
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";
|
|
@@ -520,6 +520,32 @@ function getSessionMethods(bridge, publishableKey, relyingPartyOrigin, session,
|
|
|
520
520
|
const result = await auth().linkEmailWithCode(params);
|
|
521
521
|
await refreshUser();
|
|
522
522
|
return result;
|
|
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
|
+
},
|
|
542
|
+
// The account's email changes, so the provider's user is read again
|
|
543
|
+
// before the change resolves, the same as a link.
|
|
544
|
+
confirmEmailChangeNewCode: async (params) => {
|
|
545
|
+
const refreshUser = session.captureUserRefresh();
|
|
546
|
+
const result = await auth().confirmEmailChangeNewCode(params);
|
|
547
|
+
await refreshUser();
|
|
548
|
+
return result;
|
|
523
549
|
}
|
|
524
550
|
};
|
|
525
551
|
}
|
|
@@ -592,17 +618,53 @@ var createSdkInstance = ({
|
|
|
592
618
|
import { PostMessageMethod as PostMessageMethod4, PostMessageType as PostMessageType4 } from "@moon-x/core/utils";
|
|
593
619
|
|
|
594
620
|
// src/components/presence-otp-prompt.tsx
|
|
595
|
-
import { useEffect, useRef, useState } from "react";
|
|
621
|
+
import React, { useEffect as useEffect2, useRef, useState as useState2 } from "react";
|
|
596
622
|
import {
|
|
623
|
+
AccessibilityInfo as AccessibilityInfo2,
|
|
624
|
+
ActivityIndicator,
|
|
625
|
+
Animated,
|
|
626
|
+
Easing,
|
|
627
|
+
KeyboardAvoidingView,
|
|
597
628
|
Modal,
|
|
629
|
+
Platform,
|
|
598
630
|
Pressable,
|
|
631
|
+
ScrollView,
|
|
599
632
|
StyleSheet,
|
|
600
633
|
Text,
|
|
601
634
|
TextInput,
|
|
602
|
-
View
|
|
635
|
+
View,
|
|
636
|
+
useColorScheme,
|
|
637
|
+
useWindowDimensions
|
|
603
638
|
} from "react-native";
|
|
604
639
|
import { registerPresenceOtpCodeProvider } from "@moon-x/core/sdk";
|
|
605
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
|
+
|
|
606
668
|
// src/components/presence-otp-gate.ts
|
|
607
669
|
var createPresenceOtpGate = () => {
|
|
608
670
|
let cancelledChallengeId = null;
|
|
@@ -713,42 +775,160 @@ var createPresenceOtpController = (onChange) => {
|
|
|
713
775
|
};
|
|
714
776
|
};
|
|
715
777
|
|
|
716
|
-
// src/components/presence-otp-
|
|
717
|
-
import {
|
|
718
|
-
var
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
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)"
|
|
727
866
|
};
|
|
728
|
-
var
|
|
729
|
-
background: "#
|
|
730
|
-
surface: "#
|
|
731
|
-
border: "#
|
|
732
|
-
text: "#
|
|
733
|
-
mutedText: "#
|
|
734
|
-
accent: "#
|
|
735
|
-
accentText: "#
|
|
736
|
-
error: "#
|
|
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)"
|
|
737
878
|
};
|
|
879
|
+
var deviceLanguage = () => {
|
|
880
|
+
try {
|
|
881
|
+
return Intl.DateTimeFormat().resolvedOptions().locale;
|
|
882
|
+
} catch {
|
|
883
|
+
return void 0;
|
|
884
|
+
}
|
|
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";
|
|
738
896
|
var OTP_LENGTH = 6;
|
|
897
|
+
var SHEET_MAX_WIDTH = 480;
|
|
898
|
+
var COMPACT_MAX_WIDTH = 360;
|
|
739
899
|
var PresenceOtpPrompt = ({
|
|
740
900
|
publishableKey,
|
|
741
901
|
options
|
|
742
902
|
}) => {
|
|
743
|
-
const [state, setState] =
|
|
903
|
+
const [state, setState] = useState2(
|
|
744
904
|
IDLE_PRESENCE_OTP_STATE
|
|
745
905
|
);
|
|
746
|
-
const [code, setCode] =
|
|
747
|
-
const [incomplete, setIncomplete] =
|
|
906
|
+
const [code, setCode] = useState2("");
|
|
907
|
+
const [incomplete, setIncomplete] = useState2(false);
|
|
908
|
+
const [edited, setEdited] = useState2(false);
|
|
909
|
+
const [focused, setFocused] = useState2(false);
|
|
748
910
|
const controllerRef = useRef(null);
|
|
749
|
-
const
|
|
750
|
-
const
|
|
751
|
-
|
|
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(() => {
|
|
752
932
|
const controller = createPresenceOtpController(setState);
|
|
753
933
|
controllerRef.current = controller;
|
|
754
934
|
const unregister = registerPresenceOtpCodeProvider(
|
|
@@ -763,11 +943,63 @@ var PresenceOtpPrompt = ({
|
|
|
763
943
|
setState(IDLE_PRESENCE_OTP_STATE);
|
|
764
944
|
};
|
|
765
945
|
}, [publishableKey]);
|
|
766
|
-
|
|
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(() => {
|
|
767
960
|
setCode("");
|
|
768
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();
|
|
769
969
|
}, [state.request]);
|
|
770
|
-
|
|
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(() => {
|
|
771
1003
|
const request = state.request;
|
|
772
1004
|
if (!request?.expiresAt || state.submitting) return;
|
|
773
1005
|
const expire = () => controllerRef.current?.expire(request);
|
|
@@ -782,155 +1014,446 @@ var PresenceOtpPrompt = ({
|
|
|
782
1014
|
const close = () => {
|
|
783
1015
|
controllerRef.current?.cancel();
|
|
784
1016
|
};
|
|
785
|
-
const submit = () => {
|
|
786
|
-
|
|
787
|
-
if (!/^\d{6}$/.test(normalized)) {
|
|
1017
|
+
const submit = (value = code) => {
|
|
1018
|
+
if (!/^\d{6}$/.test(value)) {
|
|
788
1019
|
setIncomplete(true);
|
|
789
1020
|
return;
|
|
790
1021
|
}
|
|
791
|
-
controllerRef.current?.submit(
|
|
1022
|
+
controllerRef.current?.submit(value);
|
|
792
1023
|
};
|
|
793
|
-
const
|
|
794
|
-
|
|
795
|
-
|
|
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
|
+
});
|
|
796
1057
|
return /* @__PURE__ */ jsx(
|
|
797
1058
|
Modal,
|
|
798
1059
|
{
|
|
799
|
-
visible
|
|
1060
|
+
visible,
|
|
800
1061
|
transparent: true,
|
|
801
1062
|
animationType: "fade",
|
|
802
1063
|
onRequestClose: close,
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
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
|
+
)
|
|
869
1212
|
}
|
|
870
1213
|
);
|
|
871
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
|
+
] });
|
|
872
1228
|
var styles = StyleSheet.create({
|
|
873
1229
|
backdrop: {
|
|
874
|
-
flex: 1
|
|
1230
|
+
flex: 1
|
|
1231
|
+
},
|
|
1232
|
+
backdropSheet: {
|
|
1233
|
+
justifyContent: "flex-end"
|
|
1234
|
+
},
|
|
1235
|
+
backdropCentered: {
|
|
875
1236
|
alignItems: "center",
|
|
876
1237
|
justifyContent: "center",
|
|
877
|
-
padding: 16
|
|
878
|
-
backgroundColor: "rgba(0, 0, 0, 0.45)"
|
|
1238
|
+
padding: 16
|
|
879
1239
|
},
|
|
880
1240
|
card: {
|
|
881
1241
|
width: "100%",
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
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
|
|
885
1292
|
},
|
|
886
1293
|
title: {
|
|
887
1294
|
fontSize: 20,
|
|
888
|
-
|
|
1295
|
+
lineHeight: 24,
|
|
1296
|
+
fontWeight: "500",
|
|
1297
|
+
letterSpacing: -0.4,
|
|
1298
|
+
textAlign: "center"
|
|
889
1299
|
},
|
|
890
|
-
|
|
1300
|
+
description: {
|
|
891
1301
|
fontSize: 14,
|
|
892
|
-
|
|
1302
|
+
lineHeight: 20,
|
|
1303
|
+
textAlign: "center"
|
|
893
1304
|
},
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
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,
|
|
898
1321
|
borderRadius: 12,
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
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
|
|
903
1357
|
},
|
|
904
1358
|
error: {
|
|
905
|
-
|
|
906
|
-
|
|
1359
|
+
flexDirection: "row",
|
|
1360
|
+
alignItems: "center",
|
|
1361
|
+
justifyContent: "center",
|
|
1362
|
+
gap: 4
|
|
907
1363
|
},
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
1364
|
+
errorText: {
|
|
1365
|
+
flexShrink: 1,
|
|
1366
|
+
fontSize: 12,
|
|
1367
|
+
fontWeight: "500",
|
|
1368
|
+
textAlign: "center"
|
|
913
1369
|
},
|
|
914
|
-
|
|
915
|
-
|
|
1370
|
+
actions: {
|
|
1371
|
+
gap: 8,
|
|
1372
|
+
paddingTop: 24
|
|
1373
|
+
},
|
|
1374
|
+
button: {
|
|
1375
|
+
flexDirection: "row",
|
|
1376
|
+
alignItems: "center",
|
|
1377
|
+
justifyContent: "center",
|
|
1378
|
+
gap: 8,
|
|
1379
|
+
height: 48,
|
|
1380
|
+
paddingHorizontal: 20,
|
|
1381
|
+
borderRadius: 999
|
|
916
1382
|
},
|
|
917
|
-
|
|
1383
|
+
buttonText: {
|
|
918
1384
|
fontSize: 16,
|
|
919
|
-
fontWeight: "
|
|
1385
|
+
fontWeight: "500"
|
|
920
1386
|
},
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
alignItems: "center"
|
|
1387
|
+
pressed: {
|
|
1388
|
+
opacity: 0.88,
|
|
1389
|
+
transform: [{ scale: 0.985 }]
|
|
925
1390
|
},
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
fontWeight: "500"
|
|
1391
|
+
disabled: {
|
|
1392
|
+
opacity: 0.5
|
|
929
1393
|
},
|
|
930
1394
|
hint: {
|
|
931
1395
|
fontSize: 12,
|
|
932
|
-
|
|
1396
|
+
lineHeight: 16,
|
|
933
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
|
|
934
1457
|
}
|
|
935
1458
|
});
|
|
936
1459
|
|
|
@@ -1766,8 +2289,8 @@ var NativeProvider = ({ publishableKey, config, children }) => {
|
|
|
1766
2289
|
() => makeRelyingPartyOriginResolver(bridge, publishableKey, relyingPartyOrigin),
|
|
1767
2290
|
[bridge, publishableKey, relyingPartyOrigin]
|
|
1768
2291
|
);
|
|
1769
|
-
const [sensitiveVisible, setSensitiveVisible] =
|
|
1770
|
-
const [captchaChallengeVisible, setCaptchaChallengeVisible] =
|
|
2292
|
+
const [sensitiveVisible, setSensitiveVisible] = useState3(false);
|
|
2293
|
+
const [captchaChallengeVisible, setCaptchaChallengeVisible] = useState3(false);
|
|
1771
2294
|
const cancelRef = useRef2(null);
|
|
1772
2295
|
const webViewVisible = sensitiveVisible || captchaChallengeVisible;
|
|
1773
2296
|
const [
|
|
@@ -1803,15 +2326,15 @@ var NativeProvider = ({ publishableKey, config, children }) => {
|
|
|
1803
2326
|
session.mount();
|
|
1804
2327
|
return session.unmount;
|
|
1805
2328
|
}, [session]);
|
|
1806
|
-
|
|
2329
|
+
useEffect3(() => {
|
|
1807
2330
|
session.setReady(ready);
|
|
1808
2331
|
}, [session, ready]);
|
|
1809
2332
|
const { sessionStatus } = sessionSnapshot;
|
|
1810
|
-
|
|
2333
|
+
useEffect3(() => {
|
|
1811
2334
|
if (!sessionResume || !ready || sessionStatus !== "authenticated") return;
|
|
1812
2335
|
void sessionResume.bind();
|
|
1813
2336
|
}, [sessionResume, ready, sessionStatus, revalidatedAt]);
|
|
1814
|
-
|
|
2337
|
+
useEffect3(() => {
|
|
1815
2338
|
const subscription = AppState.addEventListener("change", (nextState) => {
|
|
1816
2339
|
if (nextState === "active") {
|
|
1817
2340
|
session.restartSession();
|
|
@@ -1819,18 +2342,18 @@ var NativeProvider = ({ publishableKey, config, children }) => {
|
|
|
1819
2342
|
});
|
|
1820
2343
|
return () => subscription.remove();
|
|
1821
2344
|
}, [session]);
|
|
1822
|
-
const { height: screenHeight } =
|
|
2345
|
+
const { height: screenHeight } = useWindowDimensions2();
|
|
1823
2346
|
const SHEET_TOP_OFFSET = 80;
|
|
1824
|
-
const sheetTranslateY = useRef2(new
|
|
1825
|
-
const backdropOpacity = useRef2(new
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
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, {
|
|
1829
2352
|
toValue: webViewVisible ? 0 : screenHeight,
|
|
1830
2353
|
duration: 280,
|
|
1831
2354
|
useNativeDriver: true
|
|
1832
2355
|
}),
|
|
1833
|
-
|
|
2356
|
+
Animated2.timing(backdropOpacity, {
|
|
1834
2357
|
toValue: webViewVisible ? 0.5 : 0,
|
|
1835
2358
|
duration: 280,
|
|
1836
2359
|
useNativeDriver: true
|
|
@@ -1939,13 +2462,13 @@ var NativeProvider = ({ publishableKey, config, children }) => {
|
|
|
1939
2462
|
);
|
|
1940
2463
|
const sessionResumeRef = useRef2(sessionResume);
|
|
1941
2464
|
sessionResumeRef.current = sessionResume;
|
|
1942
|
-
|
|
2465
|
+
useEffect3(() => {
|
|
1943
2466
|
return () => {
|
|
1944
2467
|
sessionResumeRef.current?.cancelPendingBinds();
|
|
1945
2468
|
bridge.cleanup("provider_unmounted");
|
|
1946
2469
|
};
|
|
1947
2470
|
}, [bridge]);
|
|
1948
|
-
|
|
2471
|
+
useEffect3(
|
|
1949
2472
|
() => bridge.register(
|
|
1950
2473
|
PostMessageType4.INIT,
|
|
1951
2474
|
PostMessageMethod4.CAPTCHA_CHALLENGE_VISIBILITY,
|
|
@@ -1957,13 +2480,13 @@ var NativeProvider = ({ publishableKey, config, children }) => {
|
|
|
1957
2480
|
),
|
|
1958
2481
|
[bridge]
|
|
1959
2482
|
);
|
|
1960
|
-
|
|
2483
|
+
useEffect3(() => {
|
|
1961
2484
|
const unsubscribe = bridge.onResponseError((error) => {
|
|
1962
2485
|
if (error.message === "no_session") session.retrySession();
|
|
1963
2486
|
});
|
|
1964
2487
|
return unsubscribe;
|
|
1965
2488
|
}, [bridge, session]);
|
|
1966
|
-
|
|
2489
|
+
useEffect3(() => {
|
|
1967
2490
|
let cancelled = false;
|
|
1968
2491
|
const unregister = bridge.register(
|
|
1969
2492
|
PostMessageType4.INIT,
|
|
@@ -2010,7 +2533,7 @@ var NativeProvider = ({ publishableKey, config, children }) => {
|
|
|
2010
2533
|
}
|
|
2011
2534
|
),
|
|
2012
2535
|
/* @__PURE__ */ jsx2(
|
|
2013
|
-
|
|
2536
|
+
Animated2.View,
|
|
2014
2537
|
{
|
|
2015
2538
|
style: [styles2.backdrop, { opacity: backdropOpacity }],
|
|
2016
2539
|
pointerEvents: webViewVisible ? "auto" : "none",
|
|
@@ -2026,7 +2549,7 @@ var NativeProvider = ({ publishableKey, config, children }) => {
|
|
|
2026
2549
|
}
|
|
2027
2550
|
),
|
|
2028
2551
|
/* @__PURE__ */ jsxs2(
|
|
2029
|
-
|
|
2552
|
+
Animated2.View,
|
|
2030
2553
|
{
|
|
2031
2554
|
style: [
|
|
2032
2555
|
styles2.sheetContainer,
|
|
@@ -2074,8 +2597,8 @@ var NativeProvider = ({ publishableKey, config, children }) => {
|
|
|
2074
2597
|
webviewDebuggingEnabled: __DEV__,
|
|
2075
2598
|
javaScriptEnabled: true,
|
|
2076
2599
|
domStorageEnabled: true,
|
|
2077
|
-
sharedCookiesEnabled:
|
|
2078
|
-
thirdPartyCookiesEnabled:
|
|
2600
|
+
sharedCookiesEnabled: Platform2.OS === "ios",
|
|
2601
|
+
thirdPartyCookiesEnabled: Platform2.OS === "android",
|
|
2079
2602
|
startInLoadingState: false,
|
|
2080
2603
|
originWhitelist: ["https://*", "http://*"],
|
|
2081
2604
|
style: styles2.webView
|
|
@@ -2169,6 +2692,7 @@ var styles2 = StyleSheet2.create({
|
|
|
2169
2692
|
import {
|
|
2170
2693
|
useAddPasskey,
|
|
2171
2694
|
useBulkImport,
|
|
2695
|
+
useChangeEmail,
|
|
2172
2696
|
useCreateWallet,
|
|
2173
2697
|
useEphemeralSigner,
|
|
2174
2698
|
useImportKey,
|
|
@@ -2183,15 +2707,15 @@ import {
|
|
|
2183
2707
|
|
|
2184
2708
|
// src/hooks/use-app-config.ts
|
|
2185
2709
|
import { PostMessageMethod as PostMessageMethod5, PostMessageType as PostMessageType5 } from "@moon-x/core/utils";
|
|
2186
|
-
import { useEffect as
|
|
2710
|
+
import { useEffect as useEffect4, useState as useState4 } from "react";
|
|
2187
2711
|
var useAppConfig = (publishableKey) => {
|
|
2188
2712
|
const { sdk, _bridge } = useMoonXContext();
|
|
2189
2713
|
const resolvedKey = publishableKey ?? sdk.publishableKey;
|
|
2190
2714
|
const ready = sdk.ready;
|
|
2191
|
-
const [appConfig, setAppConfig] =
|
|
2192
|
-
const [isLoading, setIsLoading] =
|
|
2193
|
-
const [error, setError] =
|
|
2194
|
-
|
|
2715
|
+
const [appConfig, setAppConfig] = useState4(null);
|
|
2716
|
+
const [isLoading, setIsLoading] = useState4(true);
|
|
2717
|
+
const [error, setError] = useState4(null);
|
|
2718
|
+
useEffect4(() => {
|
|
2195
2719
|
if (!resolvedKey) {
|
|
2196
2720
|
setIsLoading(false);
|
|
2197
2721
|
return;
|
|
@@ -2226,8 +2750,7 @@ var useAppConfig = (publishableKey) => {
|
|
|
2226
2750
|
};
|
|
2227
2751
|
|
|
2228
2752
|
// src/hooks/use-attach-oauth.ts
|
|
2229
|
-
import {
|
|
2230
|
-
import { useState as useState4 } from "react";
|
|
2753
|
+
import { useState as useState5 } from "react";
|
|
2231
2754
|
|
|
2232
2755
|
// src/lib/oauth-deep-link.ts
|
|
2233
2756
|
var openOAuthFlow = async ({
|
|
@@ -2267,8 +2790,8 @@ var parseOAuthRedirect = async (redirectUrl) => {
|
|
|
2267
2790
|
|
|
2268
2791
|
// src/hooks/use-attach-oauth.ts
|
|
2269
2792
|
var useAttachOAuth = (params) => {
|
|
2270
|
-
const { sdk,
|
|
2271
|
-
const [state, setState] =
|
|
2793
|
+
const { sdk, _oauthRedirectUri } = useMoonXContext();
|
|
2794
|
+
const [state, setState] = useState5({ status: "idle" });
|
|
2272
2795
|
return {
|
|
2273
2796
|
state,
|
|
2274
2797
|
attachOAuth: async (provider) => {
|
|
@@ -2276,15 +2799,9 @@ var useAttachOAuth = (params) => {
|
|
|
2276
2799
|
try {
|
|
2277
2800
|
const redirectUri = params?.redirectUri || _oauthRedirectUri;
|
|
2278
2801
|
if (!redirectUri) throw new Error("oauth_redirect_uri_missing");
|
|
2279
|
-
const startResult = await
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
{
|
|
2283
|
-
publishableKey: sdk.publishableKey,
|
|
2284
|
-
provider,
|
|
2285
|
-
attach: true,
|
|
2286
|
-
login_redirect_url: redirectUri
|
|
2287
|
-
}
|
|
2802
|
+
const startResult = await sdk.beginOAuthLink(
|
|
2803
|
+
provider,
|
|
2804
|
+
redirectUri
|
|
2288
2805
|
);
|
|
2289
2806
|
if (!startResult.redirect_url) {
|
|
2290
2807
|
throw new Error("start_oauth_failed");
|
|
@@ -2296,18 +2813,16 @@ var useAttachOAuth = (params) => {
|
|
|
2296
2813
|
});
|
|
2297
2814
|
const parsed = await parseOAuthRedirect(redirectUrl);
|
|
2298
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
|
+
}
|
|
2299
2819
|
setState({ status: "verifying" });
|
|
2300
|
-
await
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
code: parsed.code,
|
|
2307
|
-
token: parsed.token,
|
|
2308
|
-
state: parsed.state
|
|
2309
|
-
}
|
|
2310
|
-
);
|
|
2820
|
+
await sdk.verifyOAuthLink({
|
|
2821
|
+
provider,
|
|
2822
|
+
code: parsed.code,
|
|
2823
|
+
token: parsed.token,
|
|
2824
|
+
state: parsed.state
|
|
2825
|
+
});
|
|
2311
2826
|
setState({ status: "complete" });
|
|
2312
2827
|
} catch (e) {
|
|
2313
2828
|
const err = e instanceof Error ? e : new Error(String(e));
|
|
@@ -2320,23 +2835,22 @@ var useAttachOAuth = (params) => {
|
|
|
2320
2835
|
};
|
|
2321
2836
|
|
|
2322
2837
|
// src/hooks/use-detach-oauth.ts
|
|
2323
|
-
import { PostMessageMethod as PostMessageMethod7, PostMessageType as PostMessageType7 } from "@moon-x/core/utils";
|
|
2324
2838
|
var useDetachOAuth = () => {
|
|
2325
|
-
const { sdk
|
|
2839
|
+
const { sdk } = useMoonXContext();
|
|
2326
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.
|
|
2327
2845
|
detachOAuth: async (idpUserId) => {
|
|
2328
|
-
await
|
|
2329
|
-
PostMessageType7.AUTH,
|
|
2330
|
-
PostMessageMethod7.DETACH_OAUTH,
|
|
2331
|
-
{ publishableKey: sdk.publishableKey, idpUserId }
|
|
2332
|
-
);
|
|
2846
|
+
await sdk.detachOAuth(idpUserId);
|
|
2333
2847
|
}
|
|
2334
2848
|
};
|
|
2335
2849
|
};
|
|
2336
2850
|
|
|
2337
2851
|
// src/hooks/use-export-key.ts
|
|
2338
2852
|
import { getInternalPresenceTokens as getInternalPresenceTokens2, SCOPES_EXPORT_KEY } from "@moon-x/core/sdk";
|
|
2339
|
-
import { PostMessageMethod as
|
|
2853
|
+
import { PostMessageMethod as PostMessageMethod6, PostMessageType as PostMessageType6 } from "@moon-x/core/utils";
|
|
2340
2854
|
var parseExportKeyResult = (value) => {
|
|
2341
2855
|
if (!value || typeof value !== "object" || !("status" in value)) {
|
|
2342
2856
|
return { status: "failed", error: "invalid_export_key_result" };
|
|
@@ -2380,8 +2894,8 @@ var useExportKey = () => {
|
|
|
2380
2894
|
title: "Export key",
|
|
2381
2895
|
flowPath: `/export-key?${params.toString()}#${secrets.toString()}`,
|
|
2382
2896
|
onMount: ({ bridge, setResult }) => bridge.register(
|
|
2383
|
-
|
|
2384
|
-
|
|
2897
|
+
PostMessageType6.WALLET,
|
|
2898
|
+
PostMessageMethod6.EXPORT_KEY_RESULT,
|
|
2385
2899
|
(result) => {
|
|
2386
2900
|
setResult(parseExportKeyResult(result));
|
|
2387
2901
|
}
|
|
@@ -2427,14 +2941,14 @@ var useLoginWithEmail = (callbacks) => {
|
|
|
2427
2941
|
};
|
|
2428
2942
|
|
|
2429
2943
|
// src/hooks/use-login-with-oauth.ts
|
|
2430
|
-
import { PostMessageMethod as
|
|
2431
|
-
import { useEffect as
|
|
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";
|
|
2432
2946
|
var useLoginWithOAuth = (params) => {
|
|
2433
2947
|
const { sdk, _bridge, _oauthRedirectUri, _beginAuthFlow } = useMoonXContext();
|
|
2434
|
-
const [state, setState] =
|
|
2948
|
+
const [state, setState] = useState6({ status: "idle" });
|
|
2435
2949
|
const activeFlow = useRef3(null);
|
|
2436
2950
|
const mounted = useRef3(true);
|
|
2437
|
-
|
|
2951
|
+
useEffect5(() => {
|
|
2438
2952
|
mounted.current = true;
|
|
2439
2953
|
return () => {
|
|
2440
2954
|
mounted.current = false;
|
|
@@ -2461,8 +2975,8 @@ var useLoginWithOAuth = (params) => {
|
|
|
2461
2975
|
throw new Error("oauth_redirect_uri_missing");
|
|
2462
2976
|
}
|
|
2463
2977
|
const startResult = await _bridge.send(
|
|
2464
|
-
|
|
2465
|
-
|
|
2978
|
+
PostMessageType7.AUTH,
|
|
2979
|
+
PostMessageMethod7.START_OAUTH,
|
|
2466
2980
|
{
|
|
2467
2981
|
publishableKey: sdk.publishableKey,
|
|
2468
2982
|
provider,
|
|
@@ -2509,17 +3023,17 @@ var useLoginWithOAuth = (params) => {
|
|
|
2509
3023
|
var useMoonX = () => useMoonXContext().sdk;
|
|
2510
3024
|
|
|
2511
3025
|
// src/external-wallets/use-external-wallets.ts
|
|
2512
|
-
import { useCallback as useCallback3, useEffect as
|
|
3026
|
+
import { useCallback as useCallback3, useEffect as useEffect6, useRef as useRef4, useState as useState7 } from "react";
|
|
2513
3027
|
var useExternalWallets = (connectors) => {
|
|
2514
|
-
const [wallets, setWallets] =
|
|
2515
|
-
const [connected, setConnected] =
|
|
3028
|
+
const [wallets, setWallets] = useState7([]);
|
|
3029
|
+
const [connected, setConnected] = useState7(
|
|
2516
3030
|
null
|
|
2517
3031
|
);
|
|
2518
|
-
const [status, setStatus] =
|
|
2519
|
-
const [error, setError] =
|
|
2520
|
-
const [refreshNonce, setRefreshNonce] =
|
|
3032
|
+
const [status, setStatus] = useState7("idle");
|
|
3033
|
+
const [error, setError] = useState7(null);
|
|
3034
|
+
const [refreshNonce, setRefreshNonce] = useState7(0);
|
|
2521
3035
|
const unsubscribeRef = useRef4(null);
|
|
2522
|
-
|
|
3036
|
+
useEffect6(() => {
|
|
2523
3037
|
let cancelled = false;
|
|
2524
3038
|
void Promise.all(
|
|
2525
3039
|
connectors.map(async (connector) => ({
|
|
@@ -2533,7 +3047,7 @@ var useExternalWallets = (connectors) => {
|
|
|
2533
3047
|
cancelled = true;
|
|
2534
3048
|
};
|
|
2535
3049
|
}, [connectors, refreshNonce]);
|
|
2536
|
-
|
|
3050
|
+
useEffect6(
|
|
2537
3051
|
() => () => {
|
|
2538
3052
|
unsubscribeRef.current?.();
|
|
2539
3053
|
},
|
|
@@ -2874,13 +3388,13 @@ var restoreWalletConnectSession = (options) => {
|
|
|
2874
3388
|
// src/index.ts
|
|
2875
3389
|
import { MOONPAY_CONSUMER_SESSION_ERROR_CODES } from "@moon-x/core/sdk";
|
|
2876
3390
|
import { registerPresenceOtpCodeProvider as registerPresenceOtpCodeProvider2 } from "@moon-x/core/sdk";
|
|
2877
|
-
import { PostMessageMethod as
|
|
3391
|
+
import { PostMessageMethod as PostMessageMethod8, PostMessageType as PostMessageType8 } from "@moon-x/core/utils";
|
|
2878
3392
|
export {
|
|
2879
3393
|
MOONPAY_CONSUMER_SESSION_ERROR_CODES,
|
|
2880
3394
|
MoonXProvider as MoonKeyProvider,
|
|
2881
3395
|
MoonXProvider,
|
|
2882
|
-
|
|
2883
|
-
|
|
3396
|
+
PostMessageMethod8 as PostMessageMethod,
|
|
3397
|
+
PostMessageType8 as PostMessageType,
|
|
2884
3398
|
connectWalletConnect,
|
|
2885
3399
|
listWalletConnectSessions,
|
|
2886
3400
|
registerPresenceOtpCodeProvider2 as registerPresenceOtpCodeProvider,
|
|
@@ -2889,6 +3403,7 @@ export {
|
|
|
2889
3403
|
useAppConfig,
|
|
2890
3404
|
useAttachOAuth,
|
|
2891
3405
|
useBulkImport,
|
|
3406
|
+
useChangeEmail,
|
|
2892
3407
|
useCreateWallet,
|
|
2893
3408
|
useDetachOAuth,
|
|
2894
3409
|
useEphemeralSigner,
|