@coinbase/cdp-react 0.0.109 → 0.0.110
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/assets/OAuthStatusModal.css +1 -1
- package/dist/assets/SignIn.css +1 -1
- package/dist/assets/SignInImage.css +1 -1
- package/dist/assets/StatusView.css +1 -0
- package/dist/assets/SwitchTransition.css +1 -1
- package/dist/chunks/{CDPReactProvider.CFWIUvzR.js → CDPReactProvider.BWInVuNJ.js} +89 -86
- package/dist/chunks/LinkAuthFlow.0FnIchwa.js +144 -0
- package/dist/chunks/index.Du1vsLh6.js +23 -0
- package/dist/components/CDPReactProvider/index.d.ts +7 -1
- package/dist/components/CDPReactProvider/index.js +11 -7
- package/dist/components/EnrollMfa/index.js +1 -1
- package/dist/components/EnrollMfaModal/index.js +1 -1
- package/dist/components/ExportWallet/index.js +6 -4
- package/dist/components/ExportWalletModal/index.js +1 -1
- package/dist/components/Fund/index.js +1 -1
- package/dist/components/FundModal/index.js +1 -1
- package/dist/components/LinkAuth/LinkAuthFlow.js +9 -5
- package/dist/components/LinkAuth/LinkAuthFlowBackButton.js +2 -2
- package/dist/components/LinkAuth/LinkAuthFlowProvider.d.ts +22 -8
- package/dist/components/LinkAuth/LinkAuthFlowProvider.js +2 -2
- package/dist/components/LinkAuth/LinkAuthItem.js +1 -1
- package/dist/components/LinkAuth/LinkAuthItems.js +35 -28
- package/dist/components/LinkAuth/LinkAuthProvider.js +25 -18
- package/dist/components/LinkAuth/index.d.ts +2 -2
- package/dist/components/LinkAuth/index.js +63 -62
- package/dist/components/LinkAuth/types.d.ts +6 -1
- package/dist/components/LinkAuth/types.js +5 -3
- package/dist/components/LinkAuth/utils.js +3 -3
- package/dist/components/LinkAuthModal/index.d.ts +1 -1
- package/dist/components/LinkAuthModal/index.js +56 -46
- package/dist/components/OAuthStatusModal/index.js +113 -135
- package/dist/components/SignIn/SignInAuthMethodButtons.d.ts +5 -2
- package/dist/components/SignIn/SignInAuthMethodButtons.js +83 -52
- package/dist/components/SignIn/SignInBackButton.js +1 -1
- package/dist/components/SignIn/SignInDescription.js +2 -2
- package/dist/components/SignIn/SignInForm.js +2 -2
- package/dist/components/SignIn/SignInImage.d.ts +12 -3
- package/dist/components/SignIn/SignInImage.js +36 -13
- package/dist/components/SignIn/SignInProvider.js +5 -4
- package/dist/components/SignIn/SignInTitle.js +2 -2
- package/dist/components/SignIn/flows/SignInWithEmail.d.ts +0 -4
- package/dist/components/SignIn/flows/SignInWithEmail.js +73 -74
- package/dist/components/SignIn/flows/SignInWithOAuth.js +1 -1
- package/dist/components/SignIn/flows/SignInWithSiwe.d.ts +27 -0
- package/dist/components/SignIn/flows/SignInWithSiwe.js +63 -0
- package/dist/components/SignIn/flows/SignInWithSms.d.ts +0 -6
- package/dist/components/SignIn/flows/SignInWithSms.js +85 -86
- package/dist/components/SignIn/hooks/useEmailForm.js +13 -13
- package/dist/components/SignIn/hooks/useFlowTransition.d.ts +14 -0
- package/dist/components/SignIn/hooks/useFlowTransition.js +13 -0
- package/dist/components/SignIn/hooks/useOTPForm.js +29 -29
- package/dist/components/SignIn/hooks/usePhoneNumberForm.js +10 -10
- package/dist/components/SignIn/hooks/useStartSiwe.d.ts +10 -0
- package/dist/components/SignIn/hooks/useStartSiwe.js +24 -0
- package/dist/components/SignIn/index.d.ts +2 -2
- package/dist/components/SignIn/index.js +29 -29
- package/dist/components/SignIn/types.d.ts +24 -2
- package/dist/components/SignIn/types.js +5 -1
- package/dist/components/SignIn/useSignInReducer.js +67 -46
- package/dist/components/SignInModal/index.d.ts +1 -1
- package/dist/components/SignInModal/index.js +77 -67
- package/dist/components/SiweStatusView/connectors/baseAccount.d.ts +22 -0
- package/dist/components/SiweStatusView/connectors/baseAccount.js +49 -0
- package/dist/components/SiweStatusView/connectors/siweConnectors.d.ts +6 -0
- package/dist/components/SiweStatusView/connectors/siweConnectors.js +9 -0
- package/dist/components/SiweStatusView/connectors/types.d.ts +45 -0
- package/dist/components/SiweStatusView/connectors/types.js +2 -0
- package/dist/components/SiweStatusView/getSiweErrorMessage.d.ts +13 -0
- package/dist/components/SiweStatusView/getSiweErrorMessage.js +15 -0
- package/dist/components/SiweStatusView/index.d.ts +36 -0
- package/dist/components/SiweStatusView/index.js +71 -0
- package/dist/components/SiweStatusView/toSiweProvider.d.ts +10 -0
- package/dist/components/SiweStatusView/toSiweProvider.js +13 -0
- package/dist/components/SiweStatusView/useSiweFlow.d.ts +37 -0
- package/dist/components/SiweStatusView/useSiweFlow.js +35 -0
- package/dist/components/VerifyMfa/index.js +1 -1
- package/dist/components/VerifyMfaInline/index.js +1 -1
- package/dist/components/VerifyMfaModal/index.js +1 -1
- package/dist/components/ui/StatusView/index.d.ts +35 -0
- package/dist/components/ui/StatusView/index.js +55 -0
- package/dist/components/ui/SwitchFadeTransition/index.d.ts +1 -1
- package/dist/components/ui/SwitchFadeTransition/index.js +8 -12
- package/dist/components/ui/SwitchSlideTransition/index.d.ts +1 -1
- package/dist/components/ui/SwitchSlideTransition/index.js +8 -12
- package/dist/components/ui/SwitchTransition/index.d.ts +10 -3
- package/dist/components/ui/SwitchTransition/index.js +99 -98
- package/dist/hooks/useVerifyMfaModal.js +1 -1
- package/dist/icons/IconBaseColorLogo.d.ts +10 -0
- package/dist/icons/IconBaseColorLogo.js +13 -0
- package/dist/icons/IconBaseLogo.d.ts +24 -0
- package/dist/icons/IconBaseLogo.js +13 -0
- package/dist/icons/index.d.ts +2 -0
- package/dist/icons/index.js +36 -32
- package/dist/index.js +230 -225
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +13 -6
- package/dist/assets/SwitchFadeTransition.css +0 -1
- package/dist/assets/SwitchSlideTransition.css +0 -1
- package/dist/chunks/LinkAuthFlow.S1XbYaG5.js +0 -111
- package/dist/chunks/index.IrJ_irKX.js +0 -17
|
@@ -1,106 +1,105 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useIsSignedIn as
|
|
3
|
-
import {
|
|
4
|
-
import { OTPForm as
|
|
5
|
-
import { PhoneNumberForm as
|
|
6
|
-
import { SwitchSlideTransition as
|
|
7
|
-
import { usePhoneNumberState as
|
|
8
|
-
import { formatPhoneNumber as
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import "
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import { jsxs as c, Fragment as a, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { useIsSignedIn as j, useSignInWithSms as L, useLinkSms as M, useVerifySmsOTP as k } from "@coinbase/cdp-hooks";
|
|
3
|
+
import { useMemo as A } from "react";
|
|
4
|
+
import { OTPForm as H } from "../../forms/OTPForm/index.js";
|
|
5
|
+
import { PhoneNumberForm as V } from "../../forms/PhoneNumberForm/index.js";
|
|
6
|
+
import { SwitchSlideTransition as q } from "../../ui/SwitchSlideTransition/index.js";
|
|
7
|
+
import { usePhoneNumberState as z } from "../../../hooks/usePhoneNumberState.js";
|
|
8
|
+
import { formatPhoneNumber as B } from "../../../utils/formatPhoneNumber.js";
|
|
9
|
+
import { useFlowTransition as G } from "../hooks/useFlowTransition.js";
|
|
10
|
+
import { useOTPForm as J } from "../hooks/useOTPForm.js";
|
|
11
|
+
import { usePhoneNumberForm as Q } from "../hooks/usePhoneNumberForm.js";
|
|
12
|
+
import { SignInCredentials as U } from "../SignInCredentials.js";
|
|
13
|
+
import { useSignInContext as l } from "../SignInProvider.js";
|
|
14
|
+
import { STEPS as X } from "../types.js";
|
|
15
|
+
const Y = ({
|
|
16
|
+
step: t,
|
|
17
|
+
autoFocus: s,
|
|
18
|
+
onSuccess: i,
|
|
19
|
+
children: h
|
|
19
20
|
}) => {
|
|
20
|
-
const
|
|
21
|
-
submit: (
|
|
22
|
-
}), { phoneNumberObject:
|
|
23
|
-
phoneNumber:
|
|
24
|
-
onPhoneNumberChange:
|
|
25
|
-
}), { resendCountdown:
|
|
26
|
-
passwordLength:
|
|
27
|
-
submit: (
|
|
28
|
-
}),
|
|
29
|
-
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
|
|
21
|
+
const { isSignedIn: b } = j(), { state: n } = l(), { signInWithSms: S } = L(), { linkSms: g } = M(), { verifySmsOTP: P } = k(), m = t || n.step, u = n.authMethod === "sms", { transitionRef: N } = G(m, u), { setPhoneNumber: T, submitPhoneNumber: d } = Q({
|
|
22
|
+
submit: (e) => b ? g(e) : S({ phoneNumber: e })
|
|
23
|
+
}), { phoneNumberObject: C, countryCode: O, handlePhoneNumberChange: v, handleCountryCodeChange: I } = z({
|
|
24
|
+
phoneNumber: n.phoneNumber,
|
|
25
|
+
onPhoneNumberChange: T
|
|
26
|
+
}), { resendCountdown: F, resetOTP: w, setOTP: D, startResendTimer: R, submitOtp: W } = J({
|
|
27
|
+
passwordLength: 6,
|
|
28
|
+
submit: (e) => P({ flowId: n.flowId, otp: e })
|
|
29
|
+
}), p = () => {
|
|
30
|
+
R(60);
|
|
31
|
+
}, x = () => {
|
|
32
|
+
w(), d({ phoneNumber: n.phoneNumber, onSuccess: p });
|
|
33
|
+
}, y = (e) => {
|
|
34
|
+
e.preventDefault(), d({ phoneNumber: n.phoneNumber, onSuccess: p });
|
|
35
|
+
}, E = (e) => {
|
|
36
|
+
e.preventDefault();
|
|
37
|
+
const o = new FormData(e.currentTarget).get("otp") || n.otp;
|
|
38
|
+
W({ otp: o, onSuccess: i });
|
|
38
39
|
};
|
|
39
|
-
return
|
|
40
|
-
|
|
41
|
-
}, [t]), /* @__PURE__ */ s(
|
|
42
|
-
J,
|
|
40
|
+
return /* @__PURE__ */ r(
|
|
41
|
+
q,
|
|
43
42
|
{
|
|
44
|
-
autoFocus:
|
|
43
|
+
autoFocus: s ? "input[type='tel']" : !1,
|
|
45
44
|
animateHeight: !1,
|
|
46
|
-
items:
|
|
45
|
+
items: X,
|
|
47
46
|
initialEntered: !0,
|
|
48
|
-
direction:
|
|
49
|
-
transitionRef:
|
|
50
|
-
children: ({ itemKey:
|
|
51
|
-
let
|
|
52
|
-
return
|
|
53
|
-
|
|
47
|
+
direction: m === "verification" ? "left" : "right",
|
|
48
|
+
transitionRef: N,
|
|
49
|
+
children: ({ itemKey: e, ...f }) => {
|
|
50
|
+
let o = null;
|
|
51
|
+
return e === "credentials" && (o = /* @__PURE__ */ r(
|
|
52
|
+
V,
|
|
54
53
|
{
|
|
55
|
-
countryCode:
|
|
56
|
-
error:
|
|
57
|
-
isPending:
|
|
58
|
-
onCountryCodeChange:
|
|
59
|
-
onPhoneNumberChange:
|
|
60
|
-
onSubmit:
|
|
61
|
-
phoneNumber:
|
|
54
|
+
countryCode: O,
|
|
55
|
+
error: m === e && n.error || "",
|
|
56
|
+
isPending: u && n.status === "pending",
|
|
57
|
+
onCountryCodeChange: I,
|
|
58
|
+
onPhoneNumberChange: v,
|
|
59
|
+
onSubmit: y,
|
|
60
|
+
phoneNumber: C
|
|
62
61
|
}
|
|
63
|
-
)),
|
|
64
|
-
|
|
62
|
+
)), e === "verification" && (o = /* @__PURE__ */ r(
|
|
63
|
+
H,
|
|
65
64
|
{
|
|
66
|
-
canResetOTP:
|
|
67
|
-
error:
|
|
68
|
-
isPending:
|
|
69
|
-
onOTPChange:
|
|
70
|
-
onResendOTP:
|
|
71
|
-
onSubmit:
|
|
72
|
-
otp:
|
|
73
|
-
resendCountdown:
|
|
74
|
-
successMessage:
|
|
65
|
+
canResetOTP: n.canResetOTP,
|
|
66
|
+
error: m === e && n.error || "",
|
|
67
|
+
isPending: u && n.status === "pending",
|
|
68
|
+
onOTPChange: D,
|
|
69
|
+
onResendOTP: x,
|
|
70
|
+
onSubmit: E,
|
|
71
|
+
otp: n.otp,
|
|
72
|
+
resendCountdown: F,
|
|
73
|
+
successMessage: u && n.status === "success" ? "Success!" : void 0
|
|
75
74
|
}
|
|
76
|
-
)), /* @__PURE__ */
|
|
75
|
+
)), /* @__PURE__ */ r("div", { ...f, children: h ? h({ step: e, Form: o }) : o });
|
|
77
76
|
}
|
|
78
77
|
}
|
|
79
78
|
);
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
] }),
|
|
84
|
-
const { state:
|
|
85
|
-
() =>
|
|
86
|
-
[
|
|
79
|
+
}, Z = ({ step: t }) => /* @__PURE__ */ c(a, { children: [
|
|
80
|
+
t === "credentials" && "Sign in",
|
|
81
|
+
t === "verification" && "Enter verification code"
|
|
82
|
+
] }), _ = ({ step: t }) => {
|
|
83
|
+
const { state: s } = l(), i = A(
|
|
84
|
+
() => B(s.phoneNumber),
|
|
85
|
+
[s.phoneNumber]
|
|
87
86
|
);
|
|
88
|
-
return /* @__PURE__ */
|
|
89
|
-
|
|
90
|
-
|
|
87
|
+
return /* @__PURE__ */ c(a, { children: [
|
|
88
|
+
t === "credentials" && "We’ll send you a verification code via text.",
|
|
89
|
+
t === "verification" && /* @__PURE__ */ c(a, { children: [
|
|
91
90
|
"Enter the 6 digit code sent to",
|
|
92
91
|
" ",
|
|
93
|
-
|
|
92
|
+
i ? /* @__PURE__ */ r(U, { children: i }) : "your phone number"
|
|
94
93
|
] })
|
|
95
94
|
] });
|
|
96
|
-
},
|
|
97
|
-
description:
|
|
98
|
-
forms:
|
|
99
|
-
title:
|
|
95
|
+
}, pe = {
|
|
96
|
+
description: _,
|
|
97
|
+
forms: Y,
|
|
98
|
+
title: Z
|
|
100
99
|
};
|
|
101
100
|
export {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
101
|
+
Y as SignInWithSms,
|
|
102
|
+
_ as SignInWithSmsDescription,
|
|
103
|
+
Z as SignInWithSmsTitle,
|
|
104
|
+
pe as config
|
|
106
105
|
};
|
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
import "@coinbase/cdp-hooks";
|
|
2
2
|
import { useCallback as p, useMemo as m } from "react";
|
|
3
3
|
import { isApiError as y } from "../../../utils/isApiError.js";
|
|
4
|
-
import { useSignInContext as
|
|
4
|
+
import { useSignInContext as u } from "../SignInProvider.js";
|
|
5
5
|
const f = ({
|
|
6
|
-
submit:
|
|
6
|
+
submit: e
|
|
7
7
|
}) => {
|
|
8
|
-
const { state:
|
|
9
|
-
(
|
|
10
|
-
o({ type: "SET_EMAIL", payload: { email:
|
|
8
|
+
const { state: a, dispatch: o } = u(), s = "An error occurred while signing in. Please try again.", n = p(
|
|
9
|
+
(t) => {
|
|
10
|
+
o({ type: "SET_EMAIL", payload: { email: t } });
|
|
11
11
|
},
|
|
12
12
|
[o]
|
|
13
13
|
), i = p(
|
|
14
14
|
async ({
|
|
15
|
-
email:
|
|
15
|
+
email: t,
|
|
16
16
|
onSuccess: l,
|
|
17
17
|
onError: E
|
|
18
18
|
}) => {
|
|
19
|
-
if (
|
|
20
|
-
o({ type: "SUBMIT_EMAIL", payload: { email:
|
|
19
|
+
if (a.status !== "pending") {
|
|
20
|
+
o({ type: "SUBMIT_EMAIL", payload: { email: t } });
|
|
21
21
|
try {
|
|
22
|
-
const { flowId: r } = await t
|
|
22
|
+
const { flowId: r } = await e(t);
|
|
23
23
|
o({ type: "SUBMIT_EMAIL_SUCCESS", payload: { flowId: r } }), l?.();
|
|
24
24
|
} catch (r) {
|
|
25
|
-
const c = y(r) ? r : r instanceof Error && r.message ||
|
|
25
|
+
const c = y(r) ? r : r instanceof Error && r.message || s;
|
|
26
26
|
o({ type: "SUBMIT_EMAIL_FAILURE", payload: { error: c } }), console.error(r), E?.(c);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
|
-
[o,
|
|
30
|
+
[o, a.status, e]
|
|
31
31
|
);
|
|
32
32
|
return m(
|
|
33
33
|
() => ({
|
|
34
|
-
setEmail:
|
|
34
|
+
setEmail: n,
|
|
35
35
|
submitEmail: i
|
|
36
36
|
}),
|
|
37
|
-
[
|
|
37
|
+
[n, i]
|
|
38
38
|
);
|
|
39
39
|
};
|
|
40
40
|
export {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SwitchTransitionRef } from '../../ui/SwitchTransition';
|
|
2
|
+
import { SignInState } from '../types';
|
|
3
|
+
type Step = SignInState["step"];
|
|
4
|
+
/**
|
|
5
|
+
* A hook that transitions between steps in a sign in flow.
|
|
6
|
+
*
|
|
7
|
+
* @param {Step} step - The step to transition to.
|
|
8
|
+
* @param {boolean} isActive - Whether the flow is active.
|
|
9
|
+
* @returns {SwitchTransitionRef<Step>} - The transition ref.
|
|
10
|
+
*/
|
|
11
|
+
export declare const useFlowTransition: (step: Step, isActive: boolean) => {
|
|
12
|
+
transitionRef: import('react').RefObject<SwitchTransitionRef<"verification" | "credentials"> | null>;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useRef as u, useLayoutEffect as e } from "react";
|
|
2
|
+
import "react/jsx-runtime";
|
|
3
|
+
import "@coinbase/cdp-hooks";
|
|
4
|
+
import "../../../chunks/CDPReactProvider.BWInVuNJ.js";
|
|
5
|
+
const l = (r, t) => {
|
|
6
|
+
const n = u(null), o = u(r);
|
|
7
|
+
return e(() => {
|
|
8
|
+
!t || o.current === r || (n.current?.transition.toggle(r), o.current = r);
|
|
9
|
+
}, [t, r]), { transitionRef: n };
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
l as useFlowTransition
|
|
13
|
+
};
|
|
@@ -1,57 +1,57 @@
|
|
|
1
1
|
import "@coinbase/cdp-hooks";
|
|
2
|
-
import { useCallback as
|
|
2
|
+
import { useCallback as a, useEffect as f, useMemo as l } from "react";
|
|
3
3
|
import { useTimer as E } from "../../../hooks/useTimer.js";
|
|
4
4
|
import { isApiError as S } from "../../../utils/isApiError.js";
|
|
5
5
|
import { useSignInContext as _ } from "../SignInProvider.js";
|
|
6
6
|
const A = ({
|
|
7
|
-
passwordLength:
|
|
7
|
+
passwordLength: i,
|
|
8
8
|
submit: T
|
|
9
9
|
}) => {
|
|
10
|
-
const { state:
|
|
10
|
+
const { state: s, dispatch: e } = _(), {
|
|
11
11
|
timeRemaining: o,
|
|
12
12
|
start: c,
|
|
13
|
-
reset:
|
|
14
|
-
} = E(), p = "An error occurred while signing in. Please try again.", m =
|
|
15
|
-
(
|
|
16
|
-
e({ type: "SET_OTP", payload: { otp:
|
|
13
|
+
reset: t
|
|
14
|
+
} = E(), p = "An error occurred while signing in. Please try again.", m = a(
|
|
15
|
+
(r) => {
|
|
16
|
+
e({ type: "SET_OTP", payload: { otp: r } });
|
|
17
17
|
},
|
|
18
18
|
[e]
|
|
19
|
-
), y =
|
|
19
|
+
), y = a(
|
|
20
20
|
async ({
|
|
21
|
-
otp:
|
|
22
|
-
onSuccess:
|
|
23
|
-
onError:
|
|
21
|
+
otp: r,
|
|
22
|
+
onSuccess: P,
|
|
23
|
+
onError: d
|
|
24
24
|
}) => {
|
|
25
|
-
if (
|
|
26
|
-
if (
|
|
27
|
-
e({ type: "SET_OTP", payload: { otp:
|
|
25
|
+
if (s.status !== "pending") {
|
|
26
|
+
if (r.length !== i) {
|
|
27
|
+
e({ type: "SET_OTP", payload: { otp: r } });
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
|
-
e({ type: "SUBMIT_OTP", payload: { otp:
|
|
30
|
+
e({ type: "SUBMIT_OTP", payload: { otp: r } });
|
|
31
31
|
try {
|
|
32
|
-
await T(
|
|
33
|
-
} catch (
|
|
34
|
-
const O = S(
|
|
35
|
-
e({ type: "SUBMIT_OTP_FAILURE", payload: { error: O } }), console.error(
|
|
32
|
+
await T(r), e({ type: "SUBMIT_OTP_SUCCESS", payload: { otp: r } }), P?.(), t();
|
|
33
|
+
} catch (n) {
|
|
34
|
+
const O = S(n) ? n : n instanceof Error && n.message || p;
|
|
35
|
+
e({ type: "SUBMIT_OTP_FAILURE", payload: { error: O } }), console.error(n), d?.(O);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
|
-
[e,
|
|
40
|
-
),
|
|
41
|
-
e({ type: "RESET_OTP" }),
|
|
42
|
-
}, [e,
|
|
43
|
-
return
|
|
44
|
-
o === 0 &&
|
|
45
|
-
}, [o,
|
|
39
|
+
[e, s.status, i, T, t]
|
|
40
|
+
), u = a(() => {
|
|
41
|
+
e({ type: "RESET_OTP" }), t();
|
|
42
|
+
}, [e, t]);
|
|
43
|
+
return f(() => {
|
|
44
|
+
o === 0 && s.step === "verification" && !s.canResetOTP && (e({ type: "ALLOW_RESET_OTP" }), t());
|
|
45
|
+
}, [o, t, s.step, s.canResetOTP, e]), l(
|
|
46
46
|
() => ({
|
|
47
47
|
resendCountdown: o,
|
|
48
|
-
resetOTP:
|
|
49
|
-
resetResendTimer:
|
|
48
|
+
resetOTP: u,
|
|
49
|
+
resetResendTimer: t,
|
|
50
50
|
setOTP: m,
|
|
51
51
|
startResendTimer: c,
|
|
52
52
|
submitOtp: y
|
|
53
53
|
}),
|
|
54
|
-
[o,
|
|
54
|
+
[o, u, t, m, c, y]
|
|
55
55
|
);
|
|
56
56
|
};
|
|
57
57
|
export {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import "@coinbase/cdp-hooks";
|
|
2
|
-
import { useCallback as p, useMemo as
|
|
3
|
-
import { isApiError as
|
|
4
|
-
import { useSignInContext as
|
|
5
|
-
const
|
|
2
|
+
import { useCallback as p, useMemo as u } from "react";
|
|
3
|
+
import { isApiError as l } from "../../../utils/isApiError.js";
|
|
4
|
+
import { useSignInContext as y } from "../SignInProvider.js";
|
|
5
|
+
const M = ({
|
|
6
6
|
submit: t
|
|
7
7
|
}) => {
|
|
8
|
-
const { state:
|
|
8
|
+
const { state: s, dispatch: o } = y(), n = "An error occurred while signing in. Please try again.", a = p(
|
|
9
9
|
(e) => {
|
|
10
10
|
o({ type: "SET_PHONE_NUMBER", payload: { phoneNumber: e } });
|
|
11
11
|
},
|
|
@@ -16,20 +16,20 @@ const U = ({
|
|
|
16
16
|
onSuccess: E,
|
|
17
17
|
onError: m
|
|
18
18
|
}) => {
|
|
19
|
-
if (
|
|
19
|
+
if (s.status !== "pending") {
|
|
20
20
|
o({ type: "SUBMIT_PHONE_NUMBER", payload: { phoneNumber: e } });
|
|
21
21
|
try {
|
|
22
22
|
const { flowId: r } = await t(e);
|
|
23
23
|
o({ type: "SUBMIT_PHONE_NUMBER_SUCCESS", payload: { flowId: r } }), E?.();
|
|
24
24
|
} catch (r) {
|
|
25
|
-
const c =
|
|
25
|
+
const c = l(r) ? r : r instanceof Error && r.message || n;
|
|
26
26
|
o({ type: "SUBMIT_PHONE_NUMBER_FAILURE", payload: { error: c } }), console.error(r), m?.(c);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
|
-
[o,
|
|
30
|
+
[o, s.status, t]
|
|
31
31
|
);
|
|
32
|
-
return
|
|
32
|
+
return u(
|
|
33
33
|
() => ({
|
|
34
34
|
setPhoneNumber: a,
|
|
35
35
|
submitPhoneNumber: i
|
|
@@ -38,5 +38,5 @@ const U = ({
|
|
|
38
38
|
);
|
|
39
39
|
};
|
|
40
40
|
export {
|
|
41
|
-
|
|
41
|
+
M as usePhoneNumberForm
|
|
42
42
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SiweProviderType } from '../../SiweStatusView';
|
|
2
|
+
/**
|
|
3
|
+
* Bridges useSiweFlow to the SignIn reducer so the inline status view reflects the attempt.
|
|
4
|
+
*
|
|
5
|
+
* @param {SiweProviderType} provider - The SIWE provider to authenticate with.
|
|
6
|
+
* @returns {(onSuccess?: () => void) => Promise<void>} A function that starts the SIWE flow.
|
|
7
|
+
*
|
|
8
|
+
* @see {@link useSiweFlow}
|
|
9
|
+
*/
|
|
10
|
+
export declare const useStartSiwe: (provider: SiweProviderType) => (onSuccess?: () => void) => Promise<void>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useCallback as p } from "react";
|
|
2
|
+
import "react/jsx-runtime";
|
|
3
|
+
import "@coinbase/cdp-hooks";
|
|
4
|
+
import "../../ui/Button/index.js";
|
|
5
|
+
import "@coinbase/cdp-core";
|
|
6
|
+
import { useSiweFlow as s } from "../../SiweStatusView/useSiweFlow.js";
|
|
7
|
+
import "libphonenumber-js";
|
|
8
|
+
import { useSignInContext as a } from "../SignInProvider.js";
|
|
9
|
+
const y = (o) => {
|
|
10
|
+
const { dispatch: t } = a(), { start: r } = s(o);
|
|
11
|
+
return p(
|
|
12
|
+
(S) => r({
|
|
13
|
+
onStart: () => t({ type: "SUBMIT_SIWE", payload: { authMethod: `siwe:${o}` } }),
|
|
14
|
+
onSuccess: () => {
|
|
15
|
+
t({ type: "SUBMIT_SIWE_SUCCESS" }), S?.();
|
|
16
|
+
},
|
|
17
|
+
onError: (e) => t({ type: "SUBMIT_SIWE_FAILURE", payload: { error: e ?? "" } })
|
|
18
|
+
}),
|
|
19
|
+
[r, t, o]
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
y as useStartSiwe
|
|
24
|
+
};
|
|
@@ -8,7 +8,7 @@ import { SignInForm, SignInFormProps } from './SignInForm';
|
|
|
8
8
|
import { SignInImage, SignInImageProps } from './SignInImage';
|
|
9
9
|
import { useSignInContext } from './SignInProvider';
|
|
10
10
|
import { SignInTitle, SignInTitleProps } from './SignInTitle';
|
|
11
|
-
import { SignInState, SignInAction } from './types';
|
|
11
|
+
import { SignInState, SignInAction, SignInStatus } from './types';
|
|
12
12
|
/**
|
|
13
13
|
* Props for the SignIn component
|
|
14
14
|
*/
|
|
@@ -139,4 +139,4 @@ export interface SignInProps extends Omit<HTMLAttributes<HTMLDivElement>, "child
|
|
|
139
139
|
* ```
|
|
140
140
|
*/
|
|
141
141
|
export declare const SignIn: ({ authMethods, ...props }: SignInProps) => import("react/jsx-runtime").JSX.Element;
|
|
142
|
-
export { SignInAuthMethodButtons, SignInBackButton, SignInDescription, SignInFooter, SignInForm, SignInImage, SignInTitle, useSignInContext, type SignInAuthMethodButtonsProps, type SignInBackButtonProps, type SignInDescriptionProps, type SignInFormProps, type SignInImageProps, type SignInTitleProps, type SignInState, type SignInAction, };
|
|
142
|
+
export { SignInAuthMethodButtons, SignInBackButton, SignInDescription, SignInFooter, SignInForm, SignInImage, SignInTitle, useSignInContext, type SignInAuthMethodButtonsProps, type SignInBackButtonProps, type SignInDescriptionProps, type SignInFormProps, type SignInImageProps, type SignInTitleProps, type SignInState, type SignInAction, type SignInStatus, };
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import { jsx as n, jsxs as
|
|
2
|
-
import { u } from "../../chunks/useSendComponentCallOnce.BI4daEvm.js";
|
|
1
|
+
import { jsx as n, jsxs as e, Fragment as p } from "react/jsx-runtime";
|
|
2
|
+
import { u as f } from "../../chunks/useSendComponentCallOnce.BI4daEvm.js";
|
|
3
3
|
import "react";
|
|
4
|
-
import { u
|
|
5
|
-
import { SignInAuthMethodButtons as
|
|
4
|
+
import { u } from "../../chunks/CDPReactProvider.BWInVuNJ.js";
|
|
5
|
+
import { SignInAuthMethodButtons as d } from "./SignInAuthMethodButtons.js";
|
|
6
6
|
import { SignInBackButton as I } from "./SignInBackButton.js";
|
|
7
7
|
import { SignInDescription as S } from "./SignInDescription.js";
|
|
8
8
|
import { SignInFooter as b } from "./SignInFooter.js";
|
|
9
9
|
import { SignInForm as k } from "./SignInForm.js";
|
|
10
10
|
import { SignInImage as w } from "./SignInImage.js";
|
|
11
|
-
import { SignInProvider as
|
|
12
|
-
import { SignInTitle as
|
|
11
|
+
import { SignInProvider as v, useSignInContext as C } from "./SignInProvider.js";
|
|
12
|
+
import { SignInTitle as N } from "./SignInTitle.js";
|
|
13
13
|
import "@coinbase/cdp-hooks";
|
|
14
|
-
import '../../assets/SignIn.css';const
|
|
14
|
+
import '../../assets/SignIn.css';const x = "SignIn-module__footer___3Gkbc", r = {
|
|
15
15
|
"sign-in": "SignIn-module__sign-in___cYpee",
|
|
16
16
|
"title-desc-wrapper": "SignIn-module__title-desc-wrapper___VpPcA",
|
|
17
17
|
"back-button": "SignIn-module__back-button___bmE-y",
|
|
18
18
|
"back-button-wrapper": "SignIn-module__back-button-wrapper___Q9FA1",
|
|
19
|
-
footer:
|
|
20
|
-
},
|
|
21
|
-
className:
|
|
19
|
+
footer: x
|
|
20
|
+
}, A = ({
|
|
21
|
+
className: m = "",
|
|
22
22
|
children: o,
|
|
23
|
-
onSuccess:
|
|
24
|
-
...
|
|
23
|
+
onSuccess: s,
|
|
24
|
+
..._
|
|
25
25
|
}) => {
|
|
26
|
-
const { state:
|
|
27
|
-
return /* @__PURE__ */
|
|
28
|
-
|
|
29
|
-
!
|
|
30
|
-
/* @__PURE__ */ n("div", { className:
|
|
31
|
-
/* @__PURE__ */ n(
|
|
32
|
-
|
|
33
|
-
/* @__PURE__ */
|
|
34
|
-
/* @__PURE__ */ n(
|
|
35
|
-
/* @__PURE__ */ n(S, { step:
|
|
26
|
+
const { state: g } = C(), { showCoinbaseFooter: l } = u(), c = typeof o == "function" ? o(g) : o;
|
|
27
|
+
return /* @__PURE__ */ e("div", { className: `${r["sign-in"]} ${m}`, ..._, children: [
|
|
28
|
+
c,
|
|
29
|
+
!c && /* @__PURE__ */ e(p, { children: [
|
|
30
|
+
/* @__PURE__ */ n("div", { className: r["back-button-wrapper"], children: /* @__PURE__ */ n(I, { className: r["back-button"] }) }),
|
|
31
|
+
/* @__PURE__ */ n(k, { onSuccess: s, children: ({ authMethod: t, step: i, Form: a }) => t.startsWith("siwe:") && i === "verification" ? a : /* @__PURE__ */ e(p, { children: [
|
|
32
|
+
/* @__PURE__ */ n(w, { authMethod: t, step: i }),
|
|
33
|
+
/* @__PURE__ */ e("div", { className: r["title-desc-wrapper"], children: [
|
|
34
|
+
/* @__PURE__ */ n(N, { step: i, authMethod: t }),
|
|
35
|
+
/* @__PURE__ */ n(S, { step: i, authMethod: t })
|
|
36
36
|
] }),
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
a,
|
|
38
|
+
i === "credentials" && /* @__PURE__ */ n(d, { activeMethod: t, onSuccess: s })
|
|
39
39
|
] }) }),
|
|
40
|
-
|
|
40
|
+
l && /* @__PURE__ */ n(b, { className: r.footer })
|
|
41
41
|
] })
|
|
42
42
|
] });
|
|
43
|
-
}, V = ({ authMethods:
|
|
43
|
+
}, V = ({ authMethods: m, ...o }) => (f("sign_in"), /* @__PURE__ */ n(v, { authMethods: m, children: /* @__PURE__ */ n(A, { ...o }) }));
|
|
44
44
|
export {
|
|
45
45
|
V as SignIn,
|
|
46
|
-
|
|
46
|
+
d as SignInAuthMethodButtons,
|
|
47
47
|
I as SignInBackButton,
|
|
48
48
|
S as SignInDescription,
|
|
49
49
|
b as SignInFooter,
|
|
50
50
|
k as SignInForm,
|
|
51
51
|
w as SignInImage,
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
N as SignInTitle,
|
|
53
|
+
C as useSignInContext
|
|
54
54
|
};
|
|
@@ -21,10 +21,11 @@ export interface SignInTitleAndDescriptionProps {
|
|
|
21
21
|
* @property {string} email - The email address of the user.
|
|
22
22
|
* @property {string | APIError | null} error - The error message or APIError object.
|
|
23
23
|
* @property {string} flowId - The flow ID of the current sign-in flow.
|
|
24
|
-
* @property {boolean} isPending - Whether the form state is pending.
|
|
25
|
-
* @property {boolean} isSuccess - Whether the sign-in flow is successful.
|
|
24
|
+
* @property {boolean} isPending - Whether the form state is pending. **Deprecated**: use `status === "pending"`.
|
|
25
|
+
* @property {boolean} isSuccess - Whether the sign-in flow is successful. **Deprecated**: use `status === "success"`.
|
|
26
26
|
* @property {string} otp - The OTP code entered by the user.
|
|
27
27
|
* @property {string} phoneNumber - The phone number of the user.
|
|
28
|
+
* @property {SignInStatus} status - The current status of the active flow.
|
|
28
29
|
* @property {AuthMethod | "otp" | "success"} step - The current step of the sign-in flow.
|
|
29
30
|
*
|
|
30
31
|
* @see {@link SignIn}
|
|
@@ -37,12 +38,20 @@ export interface SignInState {
|
|
|
37
38
|
email: string;
|
|
38
39
|
error: string | APIError | null;
|
|
39
40
|
flowId: string;
|
|
41
|
+
/** @deprecated Use `status === "pending"` instead. */
|
|
40
42
|
isPending: boolean;
|
|
43
|
+
/** @deprecated Use `status === "success"` instead. */
|
|
41
44
|
isSuccess: boolean;
|
|
42
45
|
otp: string;
|
|
43
46
|
phoneNumber: string;
|
|
47
|
+
/** The current status of the active flow. */
|
|
48
|
+
status: SignInStatus;
|
|
44
49
|
step: "credentials" | "verification";
|
|
45
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* The status of the active sign-in flow.
|
|
53
|
+
*/
|
|
54
|
+
export type SignInStatus = "idle" | "pending" | "success" | "error";
|
|
46
55
|
/**
|
|
47
56
|
* The actions that can be performed on the SignIn state.
|
|
48
57
|
*
|
|
@@ -129,6 +138,18 @@ export type SignInAction = {
|
|
|
129
138
|
type: "GO_TO_PREVIOUS_STEP";
|
|
130
139
|
} | {
|
|
131
140
|
type: "RESET_STATE";
|
|
141
|
+
} | {
|
|
142
|
+
type: "SUBMIT_SIWE";
|
|
143
|
+
payload: {
|
|
144
|
+
authMethod: AuthMethod;
|
|
145
|
+
};
|
|
146
|
+
} | {
|
|
147
|
+
type: "SUBMIT_SIWE_SUCCESS";
|
|
148
|
+
} | {
|
|
149
|
+
type: "SUBMIT_SIWE_FAILURE";
|
|
150
|
+
payload: {
|
|
151
|
+
error: string | APIError;
|
|
152
|
+
};
|
|
132
153
|
};
|
|
133
154
|
/**
|
|
134
155
|
* Shared props for a sign in flow.
|
|
@@ -150,3 +171,4 @@ export interface SignInFlowConfig {
|
|
|
150
171
|
description: FC<SignInTitleAndDescriptionProps>;
|
|
151
172
|
title: FC<SignInTitleAndDescriptionProps>;
|
|
152
173
|
}
|
|
174
|
+
export declare const STEPS: ["credentials", "verification"];
|