@getpara/react-sdk 2.0.0-alpha.13 → 2.0.0-alpha.15
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/components/BiometricCreationStep/BiometricCreationStep.js +1 -2
- package/dist/modal/components/BiometricLoginStep/BiometricLoginStep.js +12 -19
- package/dist/modal/stores/modal/actions.js +0 -3
- package/dist/provider/actions/index.d.ts +1 -0
- package/dist/provider/actions/index.js +2 -0
- package/dist/provider/hooks/mutations/index.d.ts +1 -0
- package/dist/provider/hooks/mutations/index.js +2 -0
- package/dist/provider/hooks/utils/useClient.d.ts +1 -1
- package/dist/provider/hooks/utils/useFormattedBiometricHints.d.ts +4 -0
- package/dist/provider/hooks/utils/useFormattedBiometricHints.js +27 -0
- package/dist/provider/hooks/utils/useInternalClient.js +2 -2
- package/dist/provider/providers/AuthProvider.js +7 -8
- package/package.json +8 -8
|
@@ -16,7 +16,6 @@ const BiometricCreationStep = () => {
|
|
|
16
16
|
const { presentSignupUi } = useAuthActions();
|
|
17
17
|
const signupState = useModalStore((state) => state.getSignupState());
|
|
18
18
|
const authStepRoute = useModalStore((state) => state.authStepRoute);
|
|
19
|
-
const isPasskeySupported = useModalStore((state) => state.isPasskeySupported);
|
|
20
19
|
const [isCopied, copy] = useCopyToClipboard();
|
|
21
20
|
const handleCopy = () => {
|
|
22
21
|
if (signupState == null ? void 0 : signupState.passkeyUrl) {
|
|
@@ -37,7 +36,7 @@ const BiometricCreationStep = () => {
|
|
|
37
36
|
/* @__PURE__ */ jsx(CpslText, { variant: "bodyS", color: "secondary", weight: "medium", children: isBoth ? "Choose a password or set up a passkey" : "Your Passkey keeps your account safe." })
|
|
38
37
|
] }),
|
|
39
38
|
/* @__PURE__ */ jsxs(InnerStepContainer, { children: [
|
|
40
|
-
isPasskeySupported ? /* @__PURE__ */ jsxs(CpslButton, { fullWidth: true, onClick: onClick(AuthMethod.PASSKEY), children: [
|
|
39
|
+
(signupState == null ? void 0 : signupState.isPasskeySupported) ? /* @__PURE__ */ jsxs(CpslButton, { fullWidth: true, onClick: onClick(AuthMethod.PASSKEY), children: [
|
|
41
40
|
/* @__PURE__ */ jsx(CpslIcon, { slot: "start", icon: "key" }),
|
|
42
41
|
isBoth ? "Create Passkey" : "Create"
|
|
43
42
|
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -14,19 +14,12 @@ const BiometricLoginStep = () => {
|
|
|
14
14
|
const loginState = useModalStore((state) => state.getLoginState());
|
|
15
15
|
const para = useInternalClient();
|
|
16
16
|
const { biometricHints, presentLoginUi } = useAuthActions();
|
|
17
|
-
const isPasskeySupported = useModalStore((state) => state.isPasskeySupported);
|
|
18
|
-
const [isPasskey, isPassword, hasHints, isPasskeyOnKnownDevice] = [
|
|
19
|
-
!!(loginState == null ? void 0 : loginState.passkeyUrl),
|
|
20
|
-
!!(loginState == null ? void 0 : loginState.passwordUrl),
|
|
21
|
-
(_a = loginState == null ? void 0 : loginState.biometricHints) == null ? void 0 : _a.length,
|
|
22
|
-
isPasskeySupported && !!(biometricHints == null ? void 0 : biometricHints.isOnKnownDevice)
|
|
23
|
-
];
|
|
24
|
-
const knownDeviceLink = loginState == null ? void 0 : loginState.passkeyKnownDeviceUrl;
|
|
25
|
-
const isPasskeyUnavailable = hasHints && !(biometricHints == null ? void 0 : biometricHints.isOnKnownDevice) || !isPasskeySupported;
|
|
26
|
-
const displayWelcomeBack = hasHints || isPasskeyOnKnownDevice || isPassword;
|
|
27
17
|
if (!loginState) {
|
|
28
18
|
return null;
|
|
29
19
|
}
|
|
20
|
+
const { passkeyUrl, passkeyKnownDeviceUrl, passwordUrl, isPasskeySupported } = loginState;
|
|
21
|
+
const { isOnKnownDevice = false, formattedHints } = biometricHints || {};
|
|
22
|
+
const isPasskey = !!passkeyUrl, isPassword = !!passwordUrl, isNeither = !isPasskey && !isPassword, hasHints = (_a = formattedHints == null ? void 0 : formattedHints.length) != null ? _a : 0 > 0, isPasskeyOnKnownDevice = isPasskeySupported && isOnKnownDevice, isPasskeyUnavailable = hasHints && !isOnKnownDevice || !isPasskeySupported || isNeither, displayKnownDevices = isPasskeyUnavailable && !!biometricHints && (hasHints || !!passkeyKnownDeviceUrl), displayWelcomeBack = isPasskeyOnKnownDevice || isPassword;
|
|
30
23
|
return /* @__PURE__ */ jsxs(StepContainer, { $wide: true, children: [
|
|
31
24
|
/* @__PURE__ */ jsxs(InnerStepContainer, { children: [
|
|
32
25
|
displayWelcomeBack && /* @__PURE__ */ jsx(Heading, { variant: "headingS", weight: "bold", children: "Welcome back," }),
|
|
@@ -34,15 +27,15 @@ const BiometricLoginStep = () => {
|
|
|
34
27
|
] }),
|
|
35
28
|
/* @__PURE__ */ jsxs(MainContainer, { children: [
|
|
36
29
|
isPassword && /* @__PURE__ */ jsx(CpslButton, { fullWidth: true, onClick: () => presentLoginUi(AuthMethod.PASSWORD, loginState), children: "Login" }),
|
|
37
|
-
isPasskey &&
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
] })
|
|
30
|
+
isPasskey && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
31
|
+
displayKnownDevices && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
32
|
+
/* @__PURE__ */ jsx(KnownDevices, { hints: biometricHints, link: passkeyKnownDeviceUrl }),
|
|
33
|
+
/* @__PURE__ */ jsx(CpslDivider, { children: "or" })
|
|
34
|
+
] }),
|
|
35
|
+
/* @__PURE__ */ jsx(CpslButton, { fullWidth: true, onClick: () => presentLoginUi(AuthMethod.PASSKEY, loginState), children: isPasskeyUnavailable ? "Continue anyway" : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
36
|
+
/* @__PURE__ */ jsx(CpslIcon, { slot: "start", icon: "key" }),
|
|
37
|
+
"Login with passkey"
|
|
38
|
+
] }) })
|
|
46
39
|
] })
|
|
47
40
|
] })
|
|
48
41
|
] });
|
|
@@ -32,9 +32,6 @@ const getActions = (set, get) => ({
|
|
|
32
32
|
set({ onRampStep: onRampStep - 1 });
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
|
-
if (!flow) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
35
|
const onModalStepChange = get().onModalStepChange;
|
|
39
36
|
const signupState = get().getSignupState();
|
|
40
37
|
const iFrameUrl = get().iFrameUrl;
|
|
@@ -25,3 +25,4 @@ export declare const createGuestWallets: import("./utils.js").CoreAction<"create
|
|
|
25
25
|
export declare const signMessage: import("./utils.js").CoreAction<"signMessage">;
|
|
26
26
|
export declare const signTransaction: import("./utils.js").CoreAction<"signTransaction">;
|
|
27
27
|
export declare const getWalletBalance: import("./utils.js").CoreAction<"getWalletBalance">;
|
|
28
|
+
export declare const issueJwt: import("./utils.js").CoreAction<"issueJwt">;
|
|
@@ -28,6 +28,7 @@ const createGuestWallets = generateAction("createGuestWallets");
|
|
|
28
28
|
const signMessage = generateAction("signMessage");
|
|
29
29
|
const signTransaction = generateAction("signTransaction");
|
|
30
30
|
const getWalletBalance = generateAction("getWalletBalance");
|
|
31
|
+
const issueJwt = generateAction("issueJwt");
|
|
31
32
|
export {
|
|
32
33
|
claimPregenWallets,
|
|
33
34
|
createGuestWallets,
|
|
@@ -38,6 +39,7 @@ export {
|
|
|
38
39
|
enable2fa,
|
|
39
40
|
getWalletBalance,
|
|
40
41
|
hasPregenWallet,
|
|
42
|
+
issueJwt,
|
|
41
43
|
keepSessionAlive,
|
|
42
44
|
loginExternalWallet,
|
|
43
45
|
logout,
|
|
@@ -24,4 +24,5 @@ export declare const useUpdatePregenWalletIdentifier: () => import("../../types/
|
|
|
24
24
|
export declare const useCreateGuestWallets: () => import("../../types/utils.js").CoreMethodHook<"createGuestWallets">;
|
|
25
25
|
export declare const useSignMessage: () => import("../../types/utils.js").CoreMethodHook<"signMessage">;
|
|
26
26
|
export declare const useSignTransaction: () => import("../../types/utils.js").CoreMethodHook<"signTransaction">;
|
|
27
|
+
export declare const useIssueJwt: () => import("../../types/utils.js").CoreMethodHook<"issueJwt">;
|
|
27
28
|
export declare const useCreateGuestWalletsState: import("../../types/utils.js").CoreMethodStateHook<"createGuestWallets">;
|
|
@@ -31,6 +31,7 @@ const useUpdatePregenWalletIdentifier = generateHook(
|
|
|
31
31
|
const useCreateGuestWallets = generateHook("createGuestWallets", actions.createGuestWallets);
|
|
32
32
|
const useSignMessage = generateHook("signMessage", actions.signMessage);
|
|
33
33
|
const useSignTransaction = generateHook("signTransaction", actions.signTransaction);
|
|
34
|
+
const useIssueJwt = generateHook("issueJwt", actions.issueJwt);
|
|
34
35
|
const useCreateGuestWalletsState = generateStateHook("createGuestWallets");
|
|
35
36
|
export {
|
|
36
37
|
useClaimPregenWallets,
|
|
@@ -42,6 +43,7 @@ export {
|
|
|
42
43
|
useCreateWalletPerType,
|
|
43
44
|
useEnable2fa,
|
|
44
45
|
useHasPregenWallet,
|
|
46
|
+
useIssueJwt,
|
|
45
47
|
useKeepSessionAlive,
|
|
46
48
|
useLoginExternalWallet,
|
|
47
49
|
useLogout,
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__async
|
|
4
|
+
} from "../../../chunk-MMUBH76A.js";
|
|
5
|
+
import { useQuery } from "@tanstack/react-query";
|
|
6
|
+
import { useModalStore } from "../../../modal/stores/index.js";
|
|
7
|
+
import { formatBiometricHints } from "@getpara/react-common";
|
|
8
|
+
import { useClient } from "./useClient.js";
|
|
9
|
+
const queryKey = ["FORMATTED_BIOMETRIC_HINTS"];
|
|
10
|
+
const useFormattedBiometricHints = () => {
|
|
11
|
+
var _a;
|
|
12
|
+
const client = useClient();
|
|
13
|
+
const loginState = useModalStore((state) => state.getLoginState());
|
|
14
|
+
return useQuery({
|
|
15
|
+
queryKey: [...queryKey, (_a = loginState == null ? void 0 : loginState.biometricHints) != null ? _a : "undefined"],
|
|
16
|
+
queryFn: () => __async(void 0, null, function* () {
|
|
17
|
+
if (!client || !(loginState == null ? void 0 : loginState.biometricHints)) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
const isPasskeySupported = yield client.isPasskeySupported();
|
|
21
|
+
return formatBiometricHints(loginState.biometricHints, isPasskeySupported);
|
|
22
|
+
})
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
export {
|
|
26
|
+
useFormattedBiometricHints
|
|
27
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "../../../chunk-MMUBH76A.js";
|
|
3
|
-
import {
|
|
3
|
+
import { useClient } from "./useClient.js";
|
|
4
4
|
const useInternalClient = () => {
|
|
5
|
-
const client =
|
|
5
|
+
const client = useClient();
|
|
6
6
|
return client;
|
|
7
7
|
};
|
|
8
8
|
export {
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
__spreadValues
|
|
6
6
|
} from "../../chunk-MMUBH76A.js";
|
|
7
7
|
import { jsx } from "react/jsx-runtime";
|
|
8
|
-
import {
|
|
8
|
+
import { useUserAgent } from "@getpara/react-common";
|
|
9
9
|
import { createContext, useCallback, useContext, useEffect, useMemo } from "react";
|
|
10
10
|
import { useModalStore } from "../../modal/stores/index.js";
|
|
11
11
|
import { ModalStep } from "../../modal/utils/steps.js";
|
|
@@ -33,6 +33,7 @@ import { useGoBack } from "../../modal/hooks/useGoBack.js";
|
|
|
33
33
|
import { isExternalWallet } from "@getpara/user-management-client";
|
|
34
34
|
import { routeMobileExternalWallet } from "../../modal/utils/routeMobileExternalWallet.js";
|
|
35
35
|
import { useStore } from "../stores/useStore.js";
|
|
36
|
+
import { useFormattedBiometricHints } from "../hooks/utils/useFormattedBiometricHints.js";
|
|
36
37
|
const AuthContext = createContext({
|
|
37
38
|
signUpOrLogIn: () => {
|
|
38
39
|
},
|
|
@@ -67,6 +68,7 @@ function AuthProvider({
|
|
|
67
68
|
overrides = {}
|
|
68
69
|
}) {
|
|
69
70
|
const para = useInternalClient();
|
|
71
|
+
const userAgent = useUserAgent();
|
|
70
72
|
const onLoginRef = useStore((state) => state.onLoginRef);
|
|
71
73
|
const setIsOpen = useStore((state) => state.setIsOpen);
|
|
72
74
|
const bareModal = useStore((state) => {
|
|
@@ -89,10 +91,6 @@ function AuthProvider({
|
|
|
89
91
|
const authStepRoute = useModalStore((state) => state.authStepRoute);
|
|
90
92
|
const isIFrameReady = useModalStore((state) => state.isIFrameReady);
|
|
91
93
|
const goBack = useGoBack();
|
|
92
|
-
const biometricHints = useMemo(() => {
|
|
93
|
-
var _a;
|
|
94
|
-
return formatBiometricHints((_a = loginState == null ? void 0 : loginState.biometricHints) != null ? _a : []);
|
|
95
|
-
}, [loginState == null ? void 0 : loginState.biometricHints]);
|
|
96
94
|
const { mutate: mutateSignUpOrLogIn, isPending: isSignUpOrLogInPending } = useSignUpOrLogIn();
|
|
97
95
|
const {
|
|
98
96
|
mutate: mutateVerifyNewAccount,
|
|
@@ -108,6 +106,7 @@ function AuthProvider({
|
|
|
108
106
|
const { mutate: mutateSetup2fa, isPending: isSetup2faPending } = useSetup2fa();
|
|
109
107
|
const { mutate: mutateCreateGuestWallets, isPending: isCreateGuestWalletsPending } = useCreateGuestWallets();
|
|
110
108
|
const { mutate: mutateLogout } = useLogout();
|
|
109
|
+
const { data: biometricHints } = useFormattedBiometricHints();
|
|
111
110
|
const goBackIfPopupClosedOnSteps = (steps) => {
|
|
112
111
|
var _a;
|
|
113
112
|
if (((_a = refs.popupWindow.current) == null ? void 0 : _a.closed) && (!refs.currentStep.current || steps.includes(refs.currentStep.current))) {
|
|
@@ -267,7 +266,7 @@ function AuthProvider({
|
|
|
267
266
|
break;
|
|
268
267
|
case "signup":
|
|
269
268
|
{
|
|
270
|
-
const isPassword = !!authState.passwordUrl, isPasswordOnly = isPassword && !authState.passkeyUrl;
|
|
269
|
+
const isPassword = !!authState.passwordUrl, isPasswordOnly = isPassword && (!authState.passkeyUrl || (userAgent == null ? void 0 : userAgent.device.type) === "mobile" && !authState.isPasskeySupported);
|
|
271
270
|
if (isPassword) {
|
|
272
271
|
setIFrameUrl(authState.passwordUrl);
|
|
273
272
|
}
|
|
@@ -291,7 +290,7 @@ function AuthProvider({
|
|
|
291
290
|
});
|
|
292
291
|
const verifyNewAccount = (verificationCode) => __async(this, null, function* () {
|
|
293
292
|
mutateVerifyNewAccount(
|
|
294
|
-
{ verificationCode },
|
|
293
|
+
{ verificationCode, useShortUrls: true },
|
|
295
294
|
{
|
|
296
295
|
onSuccess: onNewAuthState
|
|
297
296
|
}
|
|
@@ -455,7 +454,7 @@ function AuthProvider({
|
|
|
455
454
|
createGuestWallets,
|
|
456
455
|
isCreateGuestWalletsPending,
|
|
457
456
|
logout,
|
|
458
|
-
biometricHints
|
|
457
|
+
biometricHints: biometricHints || void 0
|
|
459
458
|
}),
|
|
460
459
|
[
|
|
461
460
|
presentSignupUi,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/react-sdk",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.15",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"*.css"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@getpara/react-common": "2.0.0-alpha.
|
|
19
|
-
"@getpara/react-components": "2.0.0-alpha.
|
|
20
|
-
"@getpara/web-sdk": "2.0.0-alpha.
|
|
18
|
+
"@getpara/react-common": "2.0.0-alpha.15",
|
|
19
|
+
"@getpara/react-components": "2.0.0-alpha.15",
|
|
20
|
+
"@getpara/web-sdk": "2.0.0-alpha.15",
|
|
21
21
|
"date-fns": "^3.6.0",
|
|
22
22
|
"framer-motion": "11.3.28",
|
|
23
23
|
"libphonenumber-js": "^1.11.1",
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
"cli": "node ./dist/cli/cli.mjs"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@getpara/cosmos-wallet-connectors": "2.0.0-alpha.
|
|
37
|
-
"@getpara/evm-wallet-connectors": "2.0.0-alpha.
|
|
38
|
-
"@getpara/solana-wallet-connectors": "2.0.0-alpha.
|
|
36
|
+
"@getpara/cosmos-wallet-connectors": "2.0.0-alpha.15",
|
|
37
|
+
"@getpara/evm-wallet-connectors": "2.0.0-alpha.15",
|
|
38
|
+
"@getpara/solana-wallet-connectors": "2.0.0-alpha.15",
|
|
39
39
|
"@testing-library/dom": "^10.4.0",
|
|
40
40
|
"@testing-library/react": "^16.3.0",
|
|
41
41
|
"@testing-library/react-hooks": "^8.0.1",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"resolutions": {
|
|
64
64
|
"styled-components": "^6"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "f837a1584f2a0b5d61c9b7a91cd74a68c01d5161"
|
|
67
67
|
}
|