@getpara/react-sdk 1.13.1 → 1.14.1
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/modal/ParaModal.js +1 -1
- package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.d.ts +1 -3
- package/dist/modal/components/BiometricCreationStep/BiometricCreationStep.js +2 -2
- package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +8 -8
- package/dist/modal/components/Body/Body.js +1 -1
- package/dist/modal/components/ModalContent/ModalContent.js +61 -6
- package/dist/modal/components/OAuth/OAuth.js +9 -4
- package/dist/modal/components/VerificationCodeStep/VerificationCodeStep.js +9 -3
- package/dist/modal/constants/constants.js +1 -1
- package/dist/modal/hooks/useCreateAccount.d.ts +1 -3
- package/dist/modal/hooks/useCreateAccount.js +6 -44
- package/dist/modal/hooks/useGoBack.js +2 -1
- package/dist/modal/stores/modal/actions.js +1 -1
- package/dist/modal/stores/modal/useModalStore.d.ts +3 -2
- package/dist/modal/types/externalWallets.d.ts +3 -1
- package/dist/modal/types/externalWallets.js +1 -0
- package/dist/modal/utils/openPopup.d.ts +9 -3
- package/dist/modal/utils/openPopup.js +2 -2
- package/package.json +5 -5
package/dist/modal/ParaModal.js
CHANGED
|
@@ -271,7 +271,7 @@ const ParaModalInner = forwardRef(
|
|
|
271
271
|
useEffect(() => {
|
|
272
272
|
const closePopupWindow = () => {
|
|
273
273
|
var _a;
|
|
274
|
-
(_a = refs.popupWindow.current) == null ? void 0 : _a.close();
|
|
274
|
+
(_a = refs.popupWindow.current) == null ? void 0 : _a.window.close();
|
|
275
275
|
};
|
|
276
276
|
if (typeof window !== "undefined") {
|
|
277
277
|
window.addEventListener(ParaEvent.WALLETS_CHANGE_EVENT, updateActiveWallet);
|
|
@@ -9,8 +9,8 @@ import { InnerStepContainer, StepContainer, Heading, QRContainer } from "../comm
|
|
|
9
9
|
import { useCopyToClipboard, UserIdentifier } from "@getpara/react-common";
|
|
10
10
|
import { useCreateAccount } from "../../hooks/useCreateAccount.js";
|
|
11
11
|
import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
|
|
12
|
-
const BiometricCreationStep = (
|
|
13
|
-
const createAccount = useCreateAccount(
|
|
12
|
+
const BiometricCreationStep = () => {
|
|
13
|
+
const createAccount = useCreateAccount();
|
|
14
14
|
const para = useInternalClient();
|
|
15
15
|
const appName = useThemeStore((state) => state.appName);
|
|
16
16
|
const webAuthURLForCreate = useModalStore((state) => state.webAuthURLForCreate);
|
|
@@ -75,14 +75,14 @@ const BiometricOnly = ({
|
|
|
75
75
|
}) => {
|
|
76
76
|
const [hasHints, isOnKnownDevice] = [biometricLocationHints.length > 0, formattedHints.isOnKnownDevice];
|
|
77
77
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
78
|
-
(hasHints && !isOnKnownDevice || !passkeysSupported) && /* @__PURE__ */
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
] })
|
|
78
|
+
(hasHints && !isOnKnownDevice || !passkeysSupported) && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
79
|
+
/* @__PURE__ */ jsx(KnownDevices, { hints: formattedHints, link: shortLoginLink, showCurrentDevice: true }),
|
|
80
|
+
/* @__PURE__ */ jsx(CpslDivider, { children: "or" })
|
|
81
|
+
] }),
|
|
82
|
+
/* @__PURE__ */ jsx(CpslButton, { fullWidth: true, onClick: handlePasskeyClick, children: hasHints && !isOnKnownDevice || !passkeysSupported ? "Continue anyway" : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
83
|
+
/* @__PURE__ */ jsx(CpslIcon, { slot: "start", icon: "key" }),
|
|
84
|
+
"Login with passkey"
|
|
85
|
+
] }) })
|
|
86
86
|
] });
|
|
87
87
|
};
|
|
88
88
|
const MainContainer = styled(InnerStepContainer)`
|
|
@@ -118,7 +118,7 @@ const Body = ({ oAuthMethods, twoFactorAuthEnabled, disableEmailLogin, disablePh
|
|
|
118
118
|
return /* @__PURE__ */ jsx(TwoFactorDoneStep, { onClose });
|
|
119
119
|
}
|
|
120
120
|
case ModalStep.BIOMETRIC_CREATION: {
|
|
121
|
-
return /* @__PURE__ */ jsx(BiometricCreationStep, {
|
|
121
|
+
return /* @__PURE__ */ jsx(BiometricCreationStep, {});
|
|
122
122
|
}
|
|
123
123
|
case ModalStep.AWAITING_OAUTH: {
|
|
124
124
|
return /* @__PURE__ */ jsx(AwaitingOAuthStep, {});
|
|
@@ -68,7 +68,9 @@ const ModalContent = forwardRef(
|
|
|
68
68
|
const setStep = useModalStore((state) => state.setStep);
|
|
69
69
|
const setBiometricLocationHints = useModalStore((state) => state.setBiometricLocationHints);
|
|
70
70
|
const setWebAuthURLForLogin = useModalStore((state) => state.setWebAuthURLForLogin);
|
|
71
|
+
const setWebAuthURLForCreate = useModalStore((state) => state.setWebAuthURLForCreate);
|
|
71
72
|
const setPasswordUrlForLogin = useModalStore((state) => state.setPasswordUrlForLogin);
|
|
73
|
+
const setIFrameUrl = useModalStore((state) => state.setIFrameUrl);
|
|
72
74
|
const setSupportedAuthMethods = useModalStore((state) => state.setSupportedAuthMethods);
|
|
73
75
|
const setOnRampConfig = useModalStore((state) => state.setOnRampConfig);
|
|
74
76
|
const accountAddFundTab = useModalStore((state) => state.accountAddFundTab);
|
|
@@ -77,7 +79,7 @@ const ModalContent = forwardRef(
|
|
|
77
79
|
const authStepRoute = useModalStore((state) => state.authStepRoute);
|
|
78
80
|
const isIFrameReady = useModalStore((state) => state.isIFrameReady);
|
|
79
81
|
const goBack = useGoBack();
|
|
80
|
-
const createAccount = useCreateAccount(
|
|
82
|
+
const createAccount = useCreateAccount();
|
|
81
83
|
const biometricLocationHints = useModalStore((state) => {
|
|
82
84
|
var _a2;
|
|
83
85
|
return (_a2 = state.biometricLocationHints) != null ? _a2 : [];
|
|
@@ -116,9 +118,7 @@ const ModalContent = forwardRef(
|
|
|
116
118
|
});
|
|
117
119
|
function awaitLoginTransition() {
|
|
118
120
|
return __async(this, null, function* () {
|
|
119
|
-
const { isComplete, isError, needsWallet } = yield para.waitForLoginAndSetup(
|
|
120
|
-
popupWindow: refs.popupWindow.current
|
|
121
|
-
});
|
|
121
|
+
const { isComplete, isError, needsWallet } = yield para.waitForLoginAndSetup();
|
|
122
122
|
if (isError) {
|
|
123
123
|
[ModalStep.AWAITING_BIOMETRIC_LOGIN, ModalStep.AWAITING_PASSWORD_LOGIN].includes(refs.currentStep.current) && goBack();
|
|
124
124
|
return;
|
|
@@ -141,6 +141,25 @@ const ModalContent = forwardRef(
|
|
|
141
141
|
}
|
|
142
142
|
});
|
|
143
143
|
}
|
|
144
|
+
const awaitWalletCreationTransition = () => __async(void 0, null, function* () {
|
|
145
|
+
var _a2;
|
|
146
|
+
const isComplete = yield para.waitForAccountCreation();
|
|
147
|
+
window.clearTimeout((_a2 = refs.poll.current) == null ? void 0 : _a2.timeout);
|
|
148
|
+
refs.poll.current = void 0;
|
|
149
|
+
refs.popupWindow.current = void 0;
|
|
150
|
+
if (isComplete) {
|
|
151
|
+
setWebAuthURLForCreate("");
|
|
152
|
+
setIFrameUrl("");
|
|
153
|
+
if (para.isNoWalletConfig) {
|
|
154
|
+
const is2faComplete = twoFactorAuthEnabled ? (yield para.check2FAStatus()).isSetup : true;
|
|
155
|
+
setStep(is2faComplete ? ModalStep.LOGIN_DONE : ModalStep.SETUP_2FA);
|
|
156
|
+
} else {
|
|
157
|
+
setStep(ModalStep.AWAITING_WALLET_CREATION);
|
|
158
|
+
}
|
|
159
|
+
} else if (refs.currentStep.current === ModalStep.AWAITING_BIOMETRIC_CREATION) {
|
|
160
|
+
goBack();
|
|
161
|
+
}
|
|
162
|
+
});
|
|
144
163
|
useEffect(() => {
|
|
145
164
|
if (currentStep !== ModalStep.AWAITING_WALLET_CREATION || walletCreationInProgress) {
|
|
146
165
|
return;
|
|
@@ -225,6 +244,21 @@ const ModalContent = forwardRef(
|
|
|
225
244
|
};
|
|
226
245
|
}
|
|
227
246
|
}, [currentStep, webAuthURLForLogin, passwordUrlForLogin]);
|
|
247
|
+
useEffect(() => {
|
|
248
|
+
var _a2;
|
|
249
|
+
if (![ModalStep.BIOMETRIC_CREATION, ModalStep.AWAITING_BIOMETRIC_CREATION, ModalStep.PASSWORD_CREATION].includes(
|
|
250
|
+
currentStep
|
|
251
|
+
)) {
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
if (((_a2 = refs.poll.current) == null ? void 0 : _a2.action) === "signup") {
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
refs.poll.current = {
|
|
258
|
+
action: "signup",
|
|
259
|
+
timeout: window.setTimeout(awaitWalletCreationTransition, DEFAULTS.POLLING_INTERVAL_MS)
|
|
260
|
+
};
|
|
261
|
+
}, [currentStep]);
|
|
228
262
|
const handleClose = () => {
|
|
229
263
|
onClose();
|
|
230
264
|
if (currentStep === ModalStep.EXTERNAL_WALLET_VERIFICATION && para.isExternalWalletAuth) {
|
|
@@ -235,9 +269,11 @@ const ModalContent = forwardRef(
|
|
|
235
269
|
var _a2, _b, _c;
|
|
236
270
|
refs.currentStep.current = currentStep;
|
|
237
271
|
let resetPoll = false;
|
|
238
|
-
if (![ModalStep.AWAITING_BIOMETRIC_CREATION, ModalStep.PASSWORD_CREATION].includes(
|
|
272
|
+
if (![ModalStep.BIOMETRIC_CREATION, ModalStep.AWAITING_BIOMETRIC_CREATION, ModalStep.PASSWORD_CREATION].includes(
|
|
273
|
+
currentStep
|
|
274
|
+
)) {
|
|
239
275
|
para.exitAccountCreation();
|
|
240
|
-
resetPoll = ["
|
|
276
|
+
resetPoll = ["signup"].includes((_a2 = refs.poll.current) == null ? void 0 : _a2.action);
|
|
241
277
|
}
|
|
242
278
|
if (![ModalStep.AWAITING_PASSWORD_LOGIN, ModalStep.AWAITING_BIOMETRIC_LOGIN, ModalStep.BIOMETRIC_LOGIN].includes(
|
|
243
279
|
currentStep
|
|
@@ -304,6 +340,25 @@ const ModalContent = forwardRef(
|
|
|
304
340
|
para.exitLoops();
|
|
305
341
|
};
|
|
306
342
|
}, []);
|
|
343
|
+
useEffect(() => {
|
|
344
|
+
const checkPopup = window.setInterval(() => {
|
|
345
|
+
if (refs.popupWindow.current && refs.popupWindow.current.window.closed) {
|
|
346
|
+
const { type } = refs.popupWindow.current;
|
|
347
|
+
const stepRef = refs.currentStep.current;
|
|
348
|
+
switch (true) {
|
|
349
|
+
case (type === "CREATE_PASSKEY" && stepRef === ModalStep.AWAITING_BIOMETRIC_CREATION):
|
|
350
|
+
case (type === "LOGIN_PASSKEY" && stepRef === ModalStep.AWAITING_BIOMETRIC_LOGIN):
|
|
351
|
+
case (type === "LOGIN_PASSWORD" && stepRef === ModalStep.AWAITING_PASSWORD_LOGIN):
|
|
352
|
+
goBack();
|
|
353
|
+
break;
|
|
354
|
+
}
|
|
355
|
+
refs.popupWindow.current = void 0;
|
|
356
|
+
}
|
|
357
|
+
}, 3200);
|
|
358
|
+
return () => {
|
|
359
|
+
window.clearInterval(checkPopup);
|
|
360
|
+
};
|
|
361
|
+
}, []);
|
|
307
362
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
308
363
|
/* @__PURE__ */ jsx(
|
|
309
364
|
Body,
|
|
@@ -17,13 +17,16 @@ import { routeMobileExternalWallet } from "../../utils/routeMobileExternalWallet
|
|
|
17
17
|
import { useGoBack } from "../../hooks/useGoBack.js";
|
|
18
18
|
import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
|
|
19
19
|
import { useSetLoginURLs } from "../../hooks/useSetLoginURLs.js";
|
|
20
|
+
import { useUserAgent } from "@getpara/react-common";
|
|
20
21
|
const HAS_MORE_LENGTH = 3;
|
|
21
22
|
const OAuth = ({ methods }) => {
|
|
23
|
+
const userAgent = useUserAgent();
|
|
22
24
|
const goBack = useGoBack();
|
|
23
25
|
const oAuthLogoVariant = useThemeStore((state) => state.oAuthLogoVariant);
|
|
24
26
|
const isDark = useThemeStore((state) => state.isDark);
|
|
25
27
|
const para = useInternalClient();
|
|
26
28
|
const refs = useModalStore((state) => state.refs);
|
|
29
|
+
const isPasskeySupported = useModalStore((state) => state.isPasskeySupported);
|
|
27
30
|
const setFlow = useModalStore((state) => state.setFlow);
|
|
28
31
|
const setStep = useModalStore((state) => state.setStep);
|
|
29
32
|
const setAuthInfo = useUserInfoStore((state) => state.setAuthInfo);
|
|
@@ -53,6 +56,7 @@ const OAuth = ({ methods }) => {
|
|
|
53
56
|
setStep(ModalStep.AUTH_MORE);
|
|
54
57
|
};
|
|
55
58
|
const handleMethodClick = (method) => () => __async(void 0, null, function* () {
|
|
59
|
+
var _a;
|
|
56
60
|
switch (method) {
|
|
57
61
|
case OAuthMethod.FARCASTER:
|
|
58
62
|
if (!farcasterConnectUri) {
|
|
@@ -73,7 +77,7 @@ const OAuth = ({ methods }) => {
|
|
|
73
77
|
type: "OAUTH",
|
|
74
78
|
current: refs.popupWindow.current
|
|
75
79
|
});
|
|
76
|
-
const { email, isError, userExists } = yield para.waitForOAuth({ popupWindow: refs.popupWindow.current });
|
|
80
|
+
const { email, isError, userExists } = yield para.waitForOAuth({ popupWindow: (_a = refs.popupWindow.current) == null ? void 0 : _a.window });
|
|
77
81
|
refs.popupWindow.current = void 0;
|
|
78
82
|
if ((isError || !email) && refs.currentStep.current === ModalStep.AWAITING_OAUTH) {
|
|
79
83
|
goBack();
|
|
@@ -96,17 +100,18 @@ const OAuth = ({ methods }) => {
|
|
|
96
100
|
setFlow("signUp");
|
|
97
101
|
const supportsPasskey = supportedCreateAuthMethods.has(AuthMethod.PASSKEY);
|
|
98
102
|
const supportsPassword = supportedCreateAuthMethods.has(AuthMethod.PASSWORD);
|
|
103
|
+
const isMobileNoPasskey = !isPasskeySupported && (userAgent == null ? void 0 : userAgent.device.type) === "mobile";
|
|
99
104
|
if (supportsPasskey) {
|
|
100
105
|
setWebAuthURLForCreate(yield para.shortenLoginLink(yield para.getSetUpBiometricsURL({ authType: "email" })));
|
|
101
|
-
if (!supportsPassword) {
|
|
106
|
+
if (!supportsPassword && !isMobileNoPasskey) {
|
|
102
107
|
setStep(ModalStep.BIOMETRIC_CREATION);
|
|
103
108
|
return;
|
|
104
109
|
}
|
|
105
110
|
}
|
|
106
|
-
if (supportsPassword) {
|
|
111
|
+
if (supportsPassword || isMobileNoPasskey) {
|
|
107
112
|
setIFrameUrl(yield para.shortenLoginLink(yield para.getSetupPasswordURL({ authType: "email", theme })));
|
|
108
113
|
}
|
|
109
|
-
setAuthStepRoute(supportsPasskey ? ModalStep.BIOMETRIC_CREATION : ModalStep.PASSWORD_CREATION);
|
|
114
|
+
setAuthStepRoute(supportsPasskey && !isMobileNoPasskey ? ModalStep.BIOMETRIC_CREATION : ModalStep.PASSWORD_CREATION);
|
|
110
115
|
break;
|
|
111
116
|
}
|
|
112
117
|
});
|
|
@@ -11,9 +11,12 @@ import { useModalStore, useThemeStore, useUserInfoStore } from "../../stores/ind
|
|
|
11
11
|
import { Heading, InnerStepContainer, StepContainer } from "../common.js";
|
|
12
12
|
import { AuthMethod } from "@getpara/core-sdk";
|
|
13
13
|
import { useInternalClient } from "../../../provider/hooks/utils/useInternalClient.js";
|
|
14
|
+
import { useUserAgent } from "@getpara/react-common";
|
|
14
15
|
const VerificationCodeStep = () => {
|
|
16
|
+
const userAgent = useUserAgent();
|
|
15
17
|
const theme = useThemeStore((state) => state.theme);
|
|
16
18
|
const authInfo = useUserInfoStore((state) => state.getAuthInfo());
|
|
19
|
+
const isPasskeySupported = useModalStore((state) => state.isPasskeySupported);
|
|
17
20
|
const setStep = useModalStore((state) => state.setStep);
|
|
18
21
|
const setWebAuthURLForCreate = useModalStore((state) => state.setWebAuthURLForCreate);
|
|
19
22
|
const setIFrameUrl = useModalStore((state) => state.setIFrameUrl);
|
|
@@ -60,7 +63,10 @@ const VerificationCodeStep = () => {
|
|
|
60
63
|
if (code.length === 6 && /^\d+$/.test(code)) {
|
|
61
64
|
try {
|
|
62
65
|
const supportedCreateAuthMethods = yield para.getSupportedCreateAuthMethods();
|
|
63
|
-
|
|
66
|
+
const supportsPasskey = supportedCreateAuthMethods.has(AuthMethod.PASSKEY);
|
|
67
|
+
const supportsPassword = supportedCreateAuthMethods.has(AuthMethod.PASSWORD) || !isPasskeySupported;
|
|
68
|
+
const isMobileNoPasskey = !isPasskeySupported && (userAgent == null ? void 0 : userAgent.device.type) === "mobile";
|
|
69
|
+
if (supportsPasskey && supportsPassword && !isMobileNoPasskey) {
|
|
64
70
|
setIsIFrameReady(false);
|
|
65
71
|
const webAuthUrl = isEmail ? yield para.verifyEmail({ verificationCode: code }) : yield para.verifyPhone({ verificationCode: code });
|
|
66
72
|
const passwordAuthUrl = yield para.getSetupPasswordURL({ authType: authInfo == null ? void 0 : authInfo.authType, theme });
|
|
@@ -68,14 +74,14 @@ const VerificationCodeStep = () => {
|
|
|
68
74
|
setIFrameUrl(yield para.shortenLoginLink(passwordAuthUrl));
|
|
69
75
|
setAuthStepRoute(ModalStep.BIOMETRIC_CREATION);
|
|
70
76
|
return;
|
|
71
|
-
} else if (
|
|
77
|
+
} else if (supportsPassword) {
|
|
72
78
|
setIsIFrameReady(false);
|
|
73
79
|
isEmail ? yield para.verifyEmail({ verificationCode: code }) : yield para.verifyPhone({ verificationCode: code });
|
|
74
80
|
const url = yield para.getSetupPasswordURL({ authType: authInfo == null ? void 0 : authInfo.authType, theme });
|
|
75
81
|
setIFrameUrl(yield para.shortenLoginLink(url));
|
|
76
82
|
setAuthStepRoute(ModalStep.PASSWORD_CREATION);
|
|
77
83
|
return;
|
|
78
|
-
} else {
|
|
84
|
+
} else if (!isMobileNoPasskey) {
|
|
79
85
|
const url = isEmail ? yield para.verifyEmail({ verificationCode: code }) : yield para.verifyPhone({ verificationCode: code });
|
|
80
86
|
setWebAuthURLForCreate(yield para.shortenLoginLink(url));
|
|
81
87
|
setStep(ModalStep.BIOMETRIC_CREATION);
|
|
@@ -1,71 +1,33 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import
|
|
3
|
-
__async
|
|
4
|
-
} from "../../chunk-MMUBH76A.js";
|
|
5
|
-
import { useInternalClient } from "../../provider/hooks/utils/useInternalClient.js";
|
|
6
|
-
import { DEFAULTS } from "../constants/defaults.js";
|
|
2
|
+
import "../../chunk-MMUBH76A.js";
|
|
7
3
|
import { useModalStore } from "../stores/index.js";
|
|
8
4
|
import { openPopup } from "../utils/openPopup.js";
|
|
9
5
|
import { ModalStep } from "../utils/steps.js";
|
|
10
|
-
|
|
11
|
-
function useCreateAccount({ twoFactorAuthEnabled = false } = {}) {
|
|
12
|
-
const para = useInternalClient();
|
|
13
|
-
const goBack = useGoBack();
|
|
6
|
+
function useCreateAccount() {
|
|
14
7
|
const refs = useModalStore((state) => state.refs);
|
|
15
8
|
const setStep = useModalStore((state) => state.setStep);
|
|
16
9
|
const webAuthURLForCreate = useModalStore((state) => state.webAuthURLForCreate);
|
|
17
|
-
const setWebAuthURLForCreate = useModalStore((state) => state.setWebAuthURLForCreate);
|
|
18
|
-
const setIFrameUrl = useModalStore((state) => state.setIFrameUrl);
|
|
19
|
-
const awaitWalletCreationTransition = () => __async(this, null, function* () {
|
|
20
|
-
var _a;
|
|
21
|
-
const isComplete = yield para.waitForAccountCreation({ popupWindow: refs.popupWindow.current });
|
|
22
|
-
window.clearTimeout((_a = refs.poll.current) == null ? void 0 : _a.timeout);
|
|
23
|
-
refs.poll.current = void 0;
|
|
24
|
-
refs.popupWindow.current = void 0;
|
|
25
|
-
if (isComplete) {
|
|
26
|
-
setWebAuthURLForCreate("");
|
|
27
|
-
setIFrameUrl("");
|
|
28
|
-
if (para.isNoWalletConfig) {
|
|
29
|
-
const is2faComplete = twoFactorAuthEnabled ? (yield para.check2FAStatus()).isSetup : true;
|
|
30
|
-
setStep(is2faComplete ? ModalStep.LOGIN_DONE : ModalStep.SETUP_2FA);
|
|
31
|
-
} else {
|
|
32
|
-
setStep(ModalStep.AWAITING_WALLET_CREATION);
|
|
33
|
-
}
|
|
34
|
-
} else if (refs.currentStep.current === ModalStep.AWAITING_BIOMETRIC_CREATION) {
|
|
35
|
-
goBack();
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
10
|
return {
|
|
39
11
|
withPasskey: () => {
|
|
40
|
-
var _a
|
|
41
|
-
if (((_a = refs.poll.current) == null ? void 0 : _a.action)
|
|
12
|
+
var _a;
|
|
13
|
+
if (((_a = refs.poll.current) == null ? void 0 : _a.action) !== "signup") {
|
|
42
14
|
return;
|
|
43
15
|
}
|
|
44
|
-
clearTimeout((_b = refs.poll.current) == null ? void 0 : _b.timeout);
|
|
45
16
|
refs.popupWindow.current = openPopup({
|
|
46
17
|
url: webAuthURLForCreate,
|
|
47
18
|
target: "ParaPasskey",
|
|
48
19
|
type: "CREATE_PASSKEY",
|
|
49
20
|
current: refs.popupWindow.current
|
|
50
21
|
});
|
|
51
|
-
refs.poll.current = {
|
|
52
|
-
action: "createPasskey",
|
|
53
|
-
timeout: window.setTimeout(awaitWalletCreationTransition, DEFAULTS.POLLING_INTERVAL_MS)
|
|
54
|
-
};
|
|
55
22
|
if (refs.currentStep.current !== ModalStep.AWAITING_BIOMETRIC_CREATION) {
|
|
56
23
|
setStep(ModalStep.AWAITING_BIOMETRIC_CREATION);
|
|
57
24
|
}
|
|
58
25
|
},
|
|
59
26
|
withPassword: () => {
|
|
60
|
-
var _a
|
|
61
|
-
if (((_a = refs.poll.current) == null ? void 0 : _a.action)
|
|
27
|
+
var _a;
|
|
28
|
+
if (((_a = refs.poll.current) == null ? void 0 : _a.action) !== "signup") {
|
|
62
29
|
return;
|
|
63
30
|
}
|
|
64
|
-
clearTimeout((_b = refs.poll.current) == null ? void 0 : _b.timeout);
|
|
65
|
-
refs.poll.current = {
|
|
66
|
-
action: "createPassword",
|
|
67
|
-
timeout: window.setTimeout(awaitWalletCreationTransition, DEFAULTS.POLLING_INTERVAL_MS)
|
|
68
|
-
};
|
|
69
31
|
if (refs.currentStep.current !== ModalStep.PASSWORD_CREATION) {
|
|
70
32
|
setStep(ModalStep.PASSWORD_CREATION);
|
|
71
33
|
}
|
|
@@ -5,7 +5,8 @@ import { useExternalWallets } from "../providers/ExternalWalletContext.js";
|
|
|
5
5
|
import { useModalStore } from "../stores/index.js";
|
|
6
6
|
import { getAddFundsStep, ModalStep } from "../utils/steps.js";
|
|
7
7
|
const useGoBack = () => {
|
|
8
|
-
const
|
|
8
|
+
const refs = useModalStore((state) => state.refs);
|
|
9
|
+
const currentStep = refs.currentStep.current;
|
|
9
10
|
const setStep = useModalStore((state) => state.setStep);
|
|
10
11
|
const accountAddFundTab = useModalStore((state) => state.accountAddFundTab);
|
|
11
12
|
const decrementStep = useModalStore((state) => state.decrementStep);
|
|
@@ -38,7 +38,7 @@ const getActions = (set, get) => ({
|
|
|
38
38
|
set({ step: prevStep, stepDirection: -1 });
|
|
39
39
|
onModalStepChange == null ? void 0 : onModalStepChange({ previousStep: currentStep, currentStep: prevStep, canGoBack: get().hasPreviousStep() });
|
|
40
40
|
}
|
|
41
|
-
(_a = refs.popupWindow.current) == null ? void 0 : _a.close();
|
|
41
|
+
(_a = refs.popupWindow.current) == null ? void 0 : _a.window.close();
|
|
42
42
|
refs.popupWindow.current = void 0;
|
|
43
43
|
},
|
|
44
44
|
hasPreviousStep: () => {
|
|
@@ -4,6 +4,7 @@ import { Tab as AddFundsTabType } from '../../components/AddFunds/AddFundsContex
|
|
|
4
4
|
import { AuthMethod } from '@getpara/core-sdk';
|
|
5
5
|
import { BiometricLocationHint } from '@getpara/user-management-client';
|
|
6
6
|
import { MutableRefObject } from 'react';
|
|
7
|
+
import { PopupWindow } from '../../utils/openPopup.js';
|
|
7
8
|
type Flow = 'login' | 'signUp' | 'account';
|
|
8
9
|
type ActiveWallet = [string | undefined, WalletType | undefined];
|
|
9
10
|
export declare enum OnRampStep {
|
|
@@ -43,9 +44,9 @@ interface ModalState {
|
|
|
43
44
|
isIFrameReady: boolean | undefined;
|
|
44
45
|
authStepRoute: ModalStep | undefined;
|
|
45
46
|
refs: {
|
|
46
|
-
popupWindow: MutableRefObject<
|
|
47
|
+
popupWindow: MutableRefObject<PopupWindow>;
|
|
47
48
|
poll: MutableRefObject<{
|
|
48
|
-
action: 'login' | '
|
|
49
|
+
action: 'login' | 'signup';
|
|
49
50
|
timeout: number;
|
|
50
51
|
}>;
|
|
51
52
|
currentStep: MutableRefObject<ModalStep>;
|
|
@@ -5,7 +5,8 @@ export declare enum EvmWallet {
|
|
|
5
5
|
WALLETCONNECT = "WALLETCONNECT",
|
|
6
6
|
ZERION = "ZERION",
|
|
7
7
|
SAFE = "SAFE",
|
|
8
|
-
RABBY = "RABBY"
|
|
8
|
+
RABBY = "RABBY",
|
|
9
|
+
OKX = "OKX"
|
|
9
10
|
}
|
|
10
11
|
export declare enum SolanaWallet {
|
|
11
12
|
PHANTOM = "PHANTOM",
|
|
@@ -29,5 +30,6 @@ export declare const ExternalWallet: {
|
|
|
29
30
|
ZERION: EvmWallet.ZERION;
|
|
30
31
|
SAFE: EvmWallet.SAFE;
|
|
31
32
|
RABBY: EvmWallet.RABBY;
|
|
33
|
+
OKX: EvmWallet.OKX;
|
|
32
34
|
};
|
|
33
35
|
export type TExternalWallet = keyof typeof ExternalWallet;
|
|
@@ -10,6 +10,7 @@ var EvmWallet = /* @__PURE__ */ ((EvmWallet2) => {
|
|
|
10
10
|
EvmWallet2["ZERION"] = "ZERION";
|
|
11
11
|
EvmWallet2["SAFE"] = "SAFE";
|
|
12
12
|
EvmWallet2["RABBY"] = "RABBY";
|
|
13
|
+
EvmWallet2["OKX"] = "OKX";
|
|
13
14
|
return EvmWallet2;
|
|
14
15
|
})(EvmWallet || {});
|
|
15
16
|
var SolanaWallet = /* @__PURE__ */ ((SolanaWallet2) => {
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
type PopupType = 'OAUTH' | 'LOGIN_PASSKEY' | 'CREATE_PASSKEY' | 'TRANSACTION_REVIEW' | 'CREATE_PASSWORD' | 'LOGIN_PASSWORD';
|
|
2
|
+
export type PopupWindow = {
|
|
3
|
+
window: Window;
|
|
4
|
+
type: PopupType;
|
|
5
|
+
};
|
|
1
6
|
export declare function openPopup({ url, target, type, current, }: {
|
|
2
7
|
url: string;
|
|
3
8
|
target: string;
|
|
4
|
-
type:
|
|
5
|
-
current?:
|
|
6
|
-
}):
|
|
9
|
+
type: PopupType;
|
|
10
|
+
current?: PopupWindow;
|
|
11
|
+
}): PopupWindow;
|
|
12
|
+
export {};
|
|
@@ -9,7 +9,7 @@ function openPopup({
|
|
|
9
9
|
if (typeof window === "undefined") {
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
|
-
current == null ? void 0 : current.close();
|
|
12
|
+
current == null ? void 0 : current.window.close();
|
|
13
13
|
const popUpWidth = 560;
|
|
14
14
|
let popUpHeight;
|
|
15
15
|
switch (type) {
|
|
@@ -53,7 +53,7 @@ function openPopup({
|
|
|
53
53
|
popupWindow = window.open(url, "_blank");
|
|
54
54
|
}, 0);
|
|
55
55
|
}
|
|
56
|
-
return popupWindow;
|
|
56
|
+
return { window: popupWindow, type };
|
|
57
57
|
}
|
|
58
58
|
export {
|
|
59
59
|
openPopup
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/react-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
"*.css"
|
|
13
13
|
],
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@getpara/react-common": "1.
|
|
16
|
-
"@getpara/react-components": "1.
|
|
17
|
-
"@getpara/web-sdk": "1.
|
|
15
|
+
"@getpara/react-common": "1.14.1",
|
|
16
|
+
"@getpara/react-components": "1.14.1",
|
|
17
|
+
"@getpara/web-sdk": "1.14.1",
|
|
18
18
|
"@tanstack/react-query": "^5.0.0",
|
|
19
19
|
"date-fns": "^3.6.0",
|
|
20
20
|
"framer-motion": "11.3.28",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"resolutions": {
|
|
52
52
|
"styled-components": "^6"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "694c785ee8c0623379631d1514ca604ce5916326"
|
|
55
55
|
}
|