@volr/react-ui 0.1.124 → 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.cjs
CHANGED
|
@@ -5130,6 +5130,8 @@ function AccountModal({ isOpen, onClose, onError }) {
|
|
|
5130
5130
|
const [currentView, setCurrentView] = React13.useState("main");
|
|
5131
5131
|
const [selectedPayment, setSelectedPayment] = React13.useState(null);
|
|
5132
5132
|
const [isLoggingOut, setIsLoggingOut] = React13.useState(false);
|
|
5133
|
+
const prevUserRef = React13.useRef(user ?? null);
|
|
5134
|
+
const [closingAfterLogin, setClosingAfterLogin] = React13.useState(false);
|
|
5133
5135
|
const [depositAssets, setDepositAssets] = React13.useState([]);
|
|
5134
5136
|
const [depositLoading, setDepositLoading] = React13.useState(false);
|
|
5135
5137
|
const [depositError, setDepositError] = React13.useState(null);
|
|
@@ -5160,6 +5162,29 @@ function AccountModal({ isOpen, onClose, onError }) {
|
|
|
5160
5162
|
}, 200);
|
|
5161
5163
|
}
|
|
5162
5164
|
}, [onClose]);
|
|
5165
|
+
React13.useEffect(() => {
|
|
5166
|
+
if (!isOpen) {
|
|
5167
|
+
setClosingAfterLogin(false);
|
|
5168
|
+
prevUserRef.current = user ?? null;
|
|
5169
|
+
return;
|
|
5170
|
+
}
|
|
5171
|
+
const wasLoggedOut = prevUserRef.current == null;
|
|
5172
|
+
const isNowLoggedIn = user != null;
|
|
5173
|
+
if (wasLoggedOut && isNowLoggedIn) {
|
|
5174
|
+
setClosingAfterLogin(true);
|
|
5175
|
+
setTimeout(() => {
|
|
5176
|
+
onClose();
|
|
5177
|
+
}, 0);
|
|
5178
|
+
}
|
|
5179
|
+
prevUserRef.current = user ?? null;
|
|
5180
|
+
}, [isOpen, user, onClose]);
|
|
5181
|
+
if (closingAfterLogin && isOpen) {
|
|
5182
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Modal, { open: isOpen, onOpenChange: handleOpenChange, children: [
|
|
5183
|
+
/* @__PURE__ */ jsxRuntime.jsx(ModalHeader, { onClose: () => {
|
|
5184
|
+
} }),
|
|
5185
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "volr:text-center volr:py-8", children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "volr:text-sm volr-text-secondary", children: "Completing login..." }) })
|
|
5186
|
+
] });
|
|
5187
|
+
}
|
|
5163
5188
|
if (!user) {
|
|
5164
5189
|
return /* @__PURE__ */ jsxRuntime.jsx(SigninModal, { isOpen, onClose, onError });
|
|
5165
5190
|
}
|
|
@@ -6637,6 +6662,17 @@ function SignRequestModal({ open, onOpenChange }) {
|
|
|
6637
6662
|
);
|
|
6638
6663
|
}
|
|
6639
6664
|
var VolrUIContext = React13__default.default.createContext(null);
|
|
6665
|
+
function getCurrentRpId() {
|
|
6666
|
+
if (typeof window === "undefined") return "localhost";
|
|
6667
|
+
return window.location.hostname;
|
|
6668
|
+
}
|
|
6669
|
+
function isPasskeyDomainMismatch(user) {
|
|
6670
|
+
const currentRpId = getCurrentRpId();
|
|
6671
|
+
const registered = user?.registeredPasskeys;
|
|
6672
|
+
if (user?.keyStorageType !== "passkey") return false;
|
|
6673
|
+
if (!Array.isArray(registered) || registered.length === 0) return false;
|
|
6674
|
+
return !registered.some((p) => p?.rpId === currentRpId);
|
|
6675
|
+
}
|
|
6640
6676
|
var useVolrUI = () => {
|
|
6641
6677
|
const context = React13.useContext(VolrUIContext);
|
|
6642
6678
|
if (!context) {
|
|
@@ -7038,6 +7074,7 @@ function OnboardingChecker({
|
|
|
7038
7074
|
const { user, provider, isLoading } = react.useVolrContext();
|
|
7039
7075
|
const { isOpen: isModalOpen } = useVolrModal();
|
|
7040
7076
|
const modalWasOpened = React13__default.default.useRef(false);
|
|
7077
|
+
const pendingMismatchOnboarding = React13__default.default.useRef(false);
|
|
7041
7078
|
React13.useEffect(() => {
|
|
7042
7079
|
if (isModalOpen) {
|
|
7043
7080
|
modalWasOpened.current = true;
|
|
@@ -7047,15 +7084,21 @@ function OnboardingChecker({
|
|
|
7047
7084
|
if (isLoading) {
|
|
7048
7085
|
return;
|
|
7049
7086
|
}
|
|
7087
|
+
const passkeyDomainMismatch = isPasskeyDomainMismatch(user);
|
|
7050
7088
|
if (isModalOpen) {
|
|
7089
|
+
if (passkeyDomainMismatch) {
|
|
7090
|
+
pendingMismatchOnboarding.current = true;
|
|
7091
|
+
}
|
|
7051
7092
|
onHideOnboarding();
|
|
7052
7093
|
return;
|
|
7053
7094
|
}
|
|
7054
7095
|
if (modalWasOpened.current) {
|
|
7055
|
-
|
|
7056
|
-
|
|
7096
|
+
if (!passkeyDomainMismatch && !pendingMismatchOnboarding.current) {
|
|
7097
|
+
onHideOnboarding();
|
|
7098
|
+
return;
|
|
7099
|
+
}
|
|
7057
7100
|
}
|
|
7058
|
-
if (user?.keyStorageType) {
|
|
7101
|
+
if (user?.keyStorageType && !passkeyDomainMismatch && !pendingMismatchOnboarding.current) {
|
|
7059
7102
|
onHideOnboarding();
|
|
7060
7103
|
return;
|
|
7061
7104
|
}
|
|
@@ -7063,6 +7106,15 @@ function OnboardingChecker({
|
|
|
7063
7106
|
onHideOnboarding();
|
|
7064
7107
|
return;
|
|
7065
7108
|
}
|
|
7109
|
+
if (pendingMismatchOnboarding.current) {
|
|
7110
|
+
pendingMismatchOnboarding.current = false;
|
|
7111
|
+
onShowOnboarding();
|
|
7112
|
+
return;
|
|
7113
|
+
}
|
|
7114
|
+
if (passkeyDomainMismatch) {
|
|
7115
|
+
onShowOnboarding();
|
|
7116
|
+
return;
|
|
7117
|
+
}
|
|
7066
7118
|
if (user && enforceSelection) {
|
|
7067
7119
|
if (!keyStorageType) {
|
|
7068
7120
|
console.error(
|