@volr/react-ui 0.1.123 → 0.1.125
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.cjs +55 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +55 -3
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -5125,6 +5125,8 @@ function AccountModal({ isOpen, onClose, onError }) {
|
|
|
5125
5125
|
const [currentView, setCurrentView] = useState("main");
|
|
5126
5126
|
const [selectedPayment, setSelectedPayment] = useState(null);
|
|
5127
5127
|
const [isLoggingOut, setIsLoggingOut] = useState(false);
|
|
5128
|
+
const prevUserRef = useRef(user ?? null);
|
|
5129
|
+
const [closingAfterLogin, setClosingAfterLogin] = useState(false);
|
|
5128
5130
|
const [depositAssets, setDepositAssets] = useState([]);
|
|
5129
5131
|
const [depositLoading, setDepositLoading] = useState(false);
|
|
5130
5132
|
const [depositError, setDepositError] = useState(null);
|
|
@@ -5155,6 +5157,29 @@ function AccountModal({ isOpen, onClose, onError }) {
|
|
|
5155
5157
|
}, 200);
|
|
5156
5158
|
}
|
|
5157
5159
|
}, [onClose]);
|
|
5160
|
+
useEffect(() => {
|
|
5161
|
+
if (!isOpen) {
|
|
5162
|
+
setClosingAfterLogin(false);
|
|
5163
|
+
prevUserRef.current = user ?? null;
|
|
5164
|
+
return;
|
|
5165
|
+
}
|
|
5166
|
+
const wasLoggedOut = prevUserRef.current == null;
|
|
5167
|
+
const isNowLoggedIn = user != null;
|
|
5168
|
+
if (wasLoggedOut && isNowLoggedIn) {
|
|
5169
|
+
setClosingAfterLogin(true);
|
|
5170
|
+
setTimeout(() => {
|
|
5171
|
+
onClose();
|
|
5172
|
+
}, 0);
|
|
5173
|
+
}
|
|
5174
|
+
prevUserRef.current = user ?? null;
|
|
5175
|
+
}, [isOpen, user, onClose]);
|
|
5176
|
+
if (closingAfterLogin && isOpen) {
|
|
5177
|
+
return /* @__PURE__ */ jsxs(Modal, { open: isOpen, onOpenChange: handleOpenChange, children: [
|
|
5178
|
+
/* @__PURE__ */ jsx(ModalHeader, { onClose: () => {
|
|
5179
|
+
} }),
|
|
5180
|
+
/* @__PURE__ */ jsx("div", { className: "volr:text-center volr:py-8", children: /* @__PURE__ */ jsx("p", { className: "volr:text-sm volr-text-secondary", children: "Completing login..." }) })
|
|
5181
|
+
] });
|
|
5182
|
+
}
|
|
5158
5183
|
if (!user) {
|
|
5159
5184
|
return /* @__PURE__ */ jsx(SigninModal, { isOpen, onClose, onError });
|
|
5160
5185
|
}
|
|
@@ -6632,6 +6657,17 @@ function SignRequestModal({ open, onOpenChange }) {
|
|
|
6632
6657
|
);
|
|
6633
6658
|
}
|
|
6634
6659
|
var VolrUIContext = React13.createContext(null);
|
|
6660
|
+
function getCurrentRpId() {
|
|
6661
|
+
if (typeof window === "undefined") return "localhost";
|
|
6662
|
+
return window.location.hostname;
|
|
6663
|
+
}
|
|
6664
|
+
function isPasskeyDomainMismatch(user) {
|
|
6665
|
+
const currentRpId = getCurrentRpId();
|
|
6666
|
+
const registered = user?.registeredPasskeys;
|
|
6667
|
+
if (user?.keyStorageType !== "passkey") return false;
|
|
6668
|
+
if (!Array.isArray(registered) || registered.length === 0) return false;
|
|
6669
|
+
return !registered.some((p) => p?.rpId === currentRpId);
|
|
6670
|
+
}
|
|
6635
6671
|
var useVolrUI = () => {
|
|
6636
6672
|
const context = useContext(VolrUIContext);
|
|
6637
6673
|
if (!context) {
|
|
@@ -7033,6 +7069,7 @@ function OnboardingChecker({
|
|
|
7033
7069
|
const { user, provider, isLoading } = useVolrContext();
|
|
7034
7070
|
const { isOpen: isModalOpen } = useVolrModal();
|
|
7035
7071
|
const modalWasOpened = React13.useRef(false);
|
|
7072
|
+
const pendingMismatchOnboarding = React13.useRef(false);
|
|
7036
7073
|
useEffect(() => {
|
|
7037
7074
|
if (isModalOpen) {
|
|
7038
7075
|
modalWasOpened.current = true;
|
|
@@ -7042,15 +7079,21 @@ function OnboardingChecker({
|
|
|
7042
7079
|
if (isLoading) {
|
|
7043
7080
|
return;
|
|
7044
7081
|
}
|
|
7082
|
+
const passkeyDomainMismatch = isPasskeyDomainMismatch(user);
|
|
7045
7083
|
if (isModalOpen) {
|
|
7084
|
+
if (passkeyDomainMismatch) {
|
|
7085
|
+
pendingMismatchOnboarding.current = true;
|
|
7086
|
+
}
|
|
7046
7087
|
onHideOnboarding();
|
|
7047
7088
|
return;
|
|
7048
7089
|
}
|
|
7049
7090
|
if (modalWasOpened.current) {
|
|
7050
|
-
|
|
7051
|
-
|
|
7091
|
+
if (!passkeyDomainMismatch && !pendingMismatchOnboarding.current) {
|
|
7092
|
+
onHideOnboarding();
|
|
7093
|
+
return;
|
|
7094
|
+
}
|
|
7052
7095
|
}
|
|
7053
|
-
if (user?.keyStorageType) {
|
|
7096
|
+
if (user?.keyStorageType && !passkeyDomainMismatch && !pendingMismatchOnboarding.current) {
|
|
7054
7097
|
onHideOnboarding();
|
|
7055
7098
|
return;
|
|
7056
7099
|
}
|
|
@@ -7058,6 +7101,15 @@ function OnboardingChecker({
|
|
|
7058
7101
|
onHideOnboarding();
|
|
7059
7102
|
return;
|
|
7060
7103
|
}
|
|
7104
|
+
if (pendingMismatchOnboarding.current) {
|
|
7105
|
+
pendingMismatchOnboarding.current = false;
|
|
7106
|
+
onShowOnboarding();
|
|
7107
|
+
return;
|
|
7108
|
+
}
|
|
7109
|
+
if (passkeyDomainMismatch) {
|
|
7110
|
+
onShowOnboarding();
|
|
7111
|
+
return;
|
|
7112
|
+
}
|
|
7061
7113
|
if (user && enforceSelection) {
|
|
7062
7114
|
if (!keyStorageType) {
|
|
7063
7115
|
console.error(
|