@coinbase/cdp-react 0.0.74 → 0.0.76
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.
|
@@ -1,86 +1,88 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as a, Fragment as m, jsx as r } from "react/jsx-runtime";
|
|
2
2
|
import { useIsSignedIn as L, useSignInWithEmail as j, useLinkEmail as k, useVerifyEmailOTP as H } from "@coinbase/cdp-hooks";
|
|
3
|
-
import { useRef as
|
|
3
|
+
import { useRef as S, useLayoutEffect as M } from "react";
|
|
4
4
|
import { EmailForm as V } from "../../forms/EmailForm/index.js";
|
|
5
5
|
import { OTPForm as q } from "../../forms/OTPForm/index.js";
|
|
6
6
|
import { SwitchSlideTransition as z } from "../../ui/SwitchSlideTransition/index.js";
|
|
7
7
|
import { useEmailForm as A } from "../hooks/useEmailForm.js";
|
|
8
8
|
import { useOTPForm as B } from "../hooks/useOTPForm.js";
|
|
9
9
|
import { SignInCredentials as G } from "../SignInCredentials.js";
|
|
10
|
-
import { useSignInContext as
|
|
10
|
+
import { useSignInContext as E } from "../SignInProvider.js";
|
|
11
11
|
import "../../CDPReactProvider/index.js";
|
|
12
12
|
const J = ["email", "otp"], N = ({
|
|
13
13
|
step: n,
|
|
14
|
-
autoFocus:
|
|
15
|
-
onSuccess:
|
|
14
|
+
autoFocus: s,
|
|
15
|
+
onSuccess: h,
|
|
16
16
|
children: c
|
|
17
17
|
}) => {
|
|
18
|
-
const l =
|
|
19
|
-
submit: (e) =>
|
|
20
|
-
}), { resendCountdown:
|
|
21
|
-
passwordLength:
|
|
22
|
-
submit: (e) =>
|
|
18
|
+
const l = S(null), P = 6, { isSignedIn: T } = L(), { state: t } = E(), { signInWithEmail: O } = j(), { linkEmail: I } = k(), { verifyEmailOTP: v } = H(), u = n || t.step, i = u === "credentials" ? "email" : "otp", d = S(i), { setEmail: b, submitEmail: f } = A({
|
|
19
|
+
submit: (e) => T ? I(e) : O({ email: e })
|
|
20
|
+
}), { resendCountdown: w, resetOTP: F, setOTP: R, startResendTimer: D, submitOtp: W } = B({
|
|
21
|
+
passwordLength: P,
|
|
22
|
+
submit: (e) => v({ flowId: t.flowId, otp: e })
|
|
23
23
|
}), p = () => {
|
|
24
|
-
|
|
24
|
+
D(60);
|
|
25
25
|
}, C = () => {
|
|
26
|
-
|
|
26
|
+
F(), f({ email: t.email, onSuccess: p });
|
|
27
27
|
}, x = (e) => {
|
|
28
|
-
e.preventDefault(), f({ email:
|
|
28
|
+
e.preventDefault(), f({ email: t.email, onSuccess: p });
|
|
29
29
|
}, y = (e) => {
|
|
30
|
-
e.preventDefault()
|
|
30
|
+
e.preventDefault();
|
|
31
|
+
const o = new FormData(e.currentTarget).get("otp") || t.otp;
|
|
32
|
+
W({ otp: o, onSuccess: h });
|
|
31
33
|
};
|
|
32
34
|
return M(() => {
|
|
33
|
-
d.current !==
|
|
34
|
-
}, [
|
|
35
|
+
d.current !== i && (l.current?.transition.toggle(i), d.current = i);
|
|
36
|
+
}, [i]), /* @__PURE__ */ r(
|
|
35
37
|
z,
|
|
36
38
|
{
|
|
37
|
-
autoFocus:
|
|
39
|
+
autoFocus: s,
|
|
38
40
|
animateHeight: !1,
|
|
39
41
|
items: J,
|
|
40
42
|
initialEntered: !0,
|
|
41
|
-
direction:
|
|
43
|
+
direction: i === "otp" ? "left" : "right",
|
|
42
44
|
transitionRef: l,
|
|
43
|
-
children: ({ itemKey: e, ...
|
|
44
|
-
let
|
|
45
|
-
return e === "email" && (
|
|
45
|
+
children: ({ itemKey: e, ...g }) => {
|
|
46
|
+
let o = null;
|
|
47
|
+
return e === "email" && (o = /* @__PURE__ */ r(
|
|
46
48
|
V,
|
|
47
49
|
{
|
|
48
|
-
email:
|
|
49
|
-
error:
|
|
50
|
-
isPending:
|
|
51
|
-
onEmailChange:
|
|
50
|
+
email: t.email,
|
|
51
|
+
error: i === "email" && t.error || "",
|
|
52
|
+
isPending: t.isPending,
|
|
53
|
+
onEmailChange: b,
|
|
52
54
|
onSubmit: x
|
|
53
55
|
}
|
|
54
|
-
)), e === "otp" && (
|
|
56
|
+
)), e === "otp" && (o = /* @__PURE__ */ r(
|
|
55
57
|
q,
|
|
56
58
|
{
|
|
57
|
-
canResetOTP:
|
|
58
|
-
error:
|
|
59
|
-
isPending:
|
|
60
|
-
onOTPChange:
|
|
59
|
+
canResetOTP: t.canResetOTP,
|
|
60
|
+
error: i === "otp" && t.error || "",
|
|
61
|
+
isPending: t.isPending,
|
|
62
|
+
onOTPChange: R,
|
|
61
63
|
onResendOTP: C,
|
|
62
64
|
onSubmit: y,
|
|
63
|
-
otp:
|
|
64
|
-
resendCountdown:
|
|
65
|
-
successMessage:
|
|
65
|
+
otp: t.otp,
|
|
66
|
+
resendCountdown: w,
|
|
67
|
+
successMessage: t.isSuccess ? "Success!" : void 0
|
|
66
68
|
}
|
|
67
|
-
)), /* @__PURE__ */
|
|
69
|
+
)), /* @__PURE__ */ r("div", { ...g, children: c ? c({ step: u, Form: o }) : o });
|
|
68
70
|
}
|
|
69
71
|
}
|
|
70
72
|
);
|
|
71
|
-
}, Q = ({ step: n }) => /* @__PURE__ */ m
|
|
73
|
+
}, Q = ({ step: n }) => /* @__PURE__ */ a(m, { children: [
|
|
72
74
|
n === "credentials" && "Sign in",
|
|
73
75
|
n === "verification" && "Enter verification code"
|
|
74
76
|
] }), U = ({ step: n }) => {
|
|
75
|
-
const { state:
|
|
76
|
-
return /* @__PURE__ */ m
|
|
77
|
+
const { state: s } = E();
|
|
78
|
+
return /* @__PURE__ */ a(m, { children: [
|
|
77
79
|
n === "credentials" && "We’ll send you a verification code via email.",
|
|
78
|
-
n === "verification" && /* @__PURE__ */ m
|
|
80
|
+
n === "verification" && /* @__PURE__ */ a(m, { children: [
|
|
79
81
|
"Enter the 6 digit code sent to ",
|
|
80
|
-
/* @__PURE__ */
|
|
82
|
+
/* @__PURE__ */ r(G, { children: s.email })
|
|
81
83
|
] })
|
|
82
84
|
] });
|
|
83
|
-
},
|
|
85
|
+
}, rt = {
|
|
84
86
|
description: U,
|
|
85
87
|
forms: N,
|
|
86
88
|
title: Q
|
|
@@ -89,5 +91,5 @@ export {
|
|
|
89
91
|
N as SignInWithEmail,
|
|
90
92
|
U as SignInWithEmailDescription,
|
|
91
93
|
Q as SignInWithEmailTitle,
|
|
92
|
-
|
|
94
|
+
rt as config
|
|
93
95
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as a, Fragment as p, jsx as s } from "react/jsx-runtime";
|
|
2
2
|
import { useIsSignedIn as H, useSignInWithSms as U, useLinkSms as q, useVerifySmsOTP as z } from "@coinbase/cdp-hooks";
|
|
3
3
|
import "libphonenumber-js";
|
|
4
|
-
import { useRef as
|
|
4
|
+
import { useRef as N, useState as T, useEffect as A, useLayoutEffect as B, useMemo as G } from "react";
|
|
5
5
|
import { OTPForm as J } from "../../forms/OTPForm/index.js";
|
|
6
6
|
import { PhoneNumberForm as Q } from "../../forms/PhoneNumberForm/index.js";
|
|
7
7
|
import { SwitchSlideTransition as X } from "../../ui/SwitchSlideTransition/index.js";
|
|
@@ -10,105 +10,107 @@ import { parseValuesFromPhoneNumber as Z } from "../../../utils/parseValuesFromP
|
|
|
10
10
|
import { useOTPForm as _ } from "../hooks/useOTPForm.js";
|
|
11
11
|
import { usePhoneNumberForm as $ } from "../hooks/usePhoneNumberForm.js";
|
|
12
12
|
import { SignInCredentials as K } from "../SignInCredentials.js";
|
|
13
|
-
import { useSignInContext as
|
|
13
|
+
import { useSignInContext as O } from "../SignInProvider.js";
|
|
14
14
|
import "../../CDPReactProvider/index.js";
|
|
15
|
-
const ee = ["phoneNumber", "otp"],
|
|
15
|
+
const ee = ["phoneNumber", "otp"], te = ({
|
|
16
16
|
step: o,
|
|
17
|
-
autoFocus:
|
|
18
|
-
onSuccess:
|
|
19
|
-
children:
|
|
17
|
+
autoFocus: i,
|
|
18
|
+
onSuccess: m,
|
|
19
|
+
children: h
|
|
20
20
|
}) => {
|
|
21
|
-
const d =
|
|
21
|
+
const d = N(null), v = 6, { isSignedIn: C } = H(), { state: t } = O(), { signInWithSms: I } = U(), { linkSms: F } = q(), { verifySmsOTP: y } = z(), [c, w] = T("US"), [u, f] = T({
|
|
22
22
|
value: "",
|
|
23
23
|
e164: ""
|
|
24
|
-
}), l = o ||
|
|
25
|
-
submit: (e) =>
|
|
26
|
-
}), { resendCountdown:
|
|
27
|
-
passwordLength:
|
|
28
|
-
submit: (e) => y({ flowId:
|
|
29
|
-
}),
|
|
30
|
-
e.value !==
|
|
24
|
+
}), l = o || t.step, n = l === "credentials" ? "phoneNumber" : "otp", b = N(n), { setPhoneNumber: R, submitPhoneNumber: S } = $({
|
|
25
|
+
submit: (e) => C ? F(e) : I({ phoneNumber: e })
|
|
26
|
+
}), { resendCountdown: D, resetOTP: E, setOTP: W, startResendTimer: x, submitOtp: j } = _({
|
|
27
|
+
passwordLength: v,
|
|
28
|
+
submit: (e) => y({ flowId: t.flowId, otp: e })
|
|
29
|
+
}), L = (e) => {
|
|
30
|
+
e.value !== u.value && (f(e), R(e.e164));
|
|
31
31
|
};
|
|
32
32
|
A(() => {
|
|
33
|
-
if (
|
|
33
|
+
if (t.phoneNumber === u.e164)
|
|
34
34
|
return;
|
|
35
|
-
const e = Z(
|
|
35
|
+
const e = Z(t.phoneNumber, c);
|
|
36
36
|
f(e);
|
|
37
|
-
}, [
|
|
38
|
-
const
|
|
37
|
+
}, [t.phoneNumber, c, u.e164]);
|
|
38
|
+
const g = () => {
|
|
39
39
|
x(60);
|
|
40
|
-
},
|
|
41
|
-
E(), S({ phoneNumber:
|
|
42
|
-
}, k = (e) => {
|
|
43
|
-
e.preventDefault(), S({ phoneNumber: n.phoneNumber, onSuccess: P });
|
|
40
|
+
}, k = () => {
|
|
41
|
+
E(), S({ phoneNumber: t.phoneNumber, onSuccess: g });
|
|
44
42
|
}, M = (e) => {
|
|
45
|
-
e.preventDefault(),
|
|
43
|
+
e.preventDefault(), S({ phoneNumber: t.phoneNumber, onSuccess: g });
|
|
44
|
+
}, V = (e) => {
|
|
45
|
+
e.preventDefault();
|
|
46
|
+
const r = new FormData(e.currentTarget).get("otp") || t.otp;
|
|
47
|
+
j({ otp: r, onSuccess: m });
|
|
46
48
|
};
|
|
47
49
|
return B(() => {
|
|
48
|
-
b.current !==
|
|
49
|
-
}, [
|
|
50
|
+
b.current !== n && (d.current?.transition.toggle(n), b.current = n);
|
|
51
|
+
}, [n]), /* @__PURE__ */ s(
|
|
50
52
|
X,
|
|
51
53
|
{
|
|
52
|
-
autoFocus:
|
|
54
|
+
autoFocus: i ? "input[type='tel']" : !1,
|
|
53
55
|
animateHeight: !1,
|
|
54
56
|
items: ee,
|
|
55
57
|
initialEntered: !0,
|
|
56
|
-
direction:
|
|
58
|
+
direction: n === "otp" ? "left" : "right",
|
|
57
59
|
transitionRef: d,
|
|
58
|
-
children: ({ itemKey: e, ...
|
|
59
|
-
let
|
|
60
|
-
return e === "phoneNumber" && (
|
|
60
|
+
children: ({ itemKey: e, ...P }) => {
|
|
61
|
+
let r = null;
|
|
62
|
+
return e === "phoneNumber" && (r = /* @__PURE__ */ s(
|
|
61
63
|
Q,
|
|
62
64
|
{
|
|
63
65
|
countryCode: c,
|
|
64
|
-
error:
|
|
65
|
-
isPending:
|
|
66
|
-
onCountryCodeChange:
|
|
67
|
-
onPhoneNumberChange:
|
|
68
|
-
onSubmit:
|
|
69
|
-
phoneNumber:
|
|
66
|
+
error: n === "phoneNumber" && t.error || "",
|
|
67
|
+
isPending: t.isPending,
|
|
68
|
+
onCountryCodeChange: w,
|
|
69
|
+
onPhoneNumberChange: L,
|
|
70
|
+
onSubmit: M,
|
|
71
|
+
phoneNumber: u
|
|
70
72
|
}
|
|
71
|
-
)), e === "otp" && (
|
|
73
|
+
)), e === "otp" && (r = /* @__PURE__ */ s(
|
|
72
74
|
J,
|
|
73
75
|
{
|
|
74
|
-
canResetOTP:
|
|
75
|
-
error:
|
|
76
|
-
isPending:
|
|
76
|
+
canResetOTP: t.canResetOTP,
|
|
77
|
+
error: n === "otp" && t.error || "",
|
|
78
|
+
isPending: t.isPending,
|
|
77
79
|
onOTPChange: W,
|
|
78
|
-
onResendOTP:
|
|
79
|
-
onSubmit:
|
|
80
|
-
otp:
|
|
81
|
-
resendCountdown:
|
|
82
|
-
successMessage:
|
|
80
|
+
onResendOTP: k,
|
|
81
|
+
onSubmit: V,
|
|
82
|
+
otp: t.otp,
|
|
83
|
+
resendCountdown: D,
|
|
84
|
+
successMessage: t.isSuccess ? "Success!" : void 0
|
|
83
85
|
}
|
|
84
|
-
)), /* @__PURE__ */
|
|
86
|
+
)), /* @__PURE__ */ s("div", { ...P, children: h ? h({ step: l, Form: r }) : r });
|
|
85
87
|
}
|
|
86
88
|
}
|
|
87
89
|
);
|
|
88
|
-
},
|
|
90
|
+
}, ne = ({ step: o }) => /* @__PURE__ */ a(p, { children: [
|
|
89
91
|
o === "credentials" && "Sign in",
|
|
90
92
|
o === "verification" && "Enter verification code"
|
|
91
93
|
] }), oe = ({ step: o }) => {
|
|
92
|
-
const { state:
|
|
93
|
-
() => Y(
|
|
94
|
-
[
|
|
94
|
+
const { state: i } = O(), m = G(
|
|
95
|
+
() => Y(i.phoneNumber),
|
|
96
|
+
[i.phoneNumber]
|
|
95
97
|
);
|
|
96
|
-
return /* @__PURE__ */
|
|
98
|
+
return /* @__PURE__ */ a(p, { children: [
|
|
97
99
|
o === "credentials" && "We’ll send you a verification code via text.",
|
|
98
|
-
o === "verification" && /* @__PURE__ */
|
|
100
|
+
o === "verification" && /* @__PURE__ */ a(p, { children: [
|
|
99
101
|
"Enter the 6 digit code sent to",
|
|
100
102
|
" ",
|
|
101
|
-
|
|
103
|
+
m ? /* @__PURE__ */ s(K, { children: m }) : "your phone number"
|
|
102
104
|
] })
|
|
103
105
|
] });
|
|
104
|
-
},
|
|
106
|
+
}, ge = {
|
|
105
107
|
description: oe,
|
|
106
|
-
forms:
|
|
107
|
-
title:
|
|
108
|
+
forms: te,
|
|
109
|
+
title: ne
|
|
108
110
|
};
|
|
109
111
|
export {
|
|
110
|
-
|
|
112
|
+
te as SignInWithSms,
|
|
111
113
|
oe as SignInWithSmsDescription,
|
|
112
|
-
|
|
113
|
-
|
|
114
|
+
ne as SignInWithSmsTitle,
|
|
115
|
+
ge as config
|
|
114
116
|
};
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.0.
|
|
1
|
+
export declare const VERSION = "0.0.76";
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coinbase/cdp-react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.76",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@internationalized/number": "3.6.4",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"react": ">=18.2.0 <19.2.0",
|
|
18
|
-
"@coinbase/cdp-
|
|
19
|
-
"@coinbase/cdp-
|
|
18
|
+
"@coinbase/cdp-hooks": "^0.0.76",
|
|
19
|
+
"@coinbase/cdp-core": "^0.0.76"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@size-limit/preset-big-lib": "^11.2.0",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"vite": "^7.0.4",
|
|
48
48
|
"vite-plugin-dts": "^4.5.4",
|
|
49
49
|
"vite-plugin-lib-inject-css": "^2.2.2",
|
|
50
|
-
"@coinbase/cdp-core": "^0.0.
|
|
51
|
-
"@coinbase/cdp-hooks": "^0.0.
|
|
50
|
+
"@coinbase/cdp-core": "^0.0.76",
|
|
51
|
+
"@coinbase/cdp-hooks": "^0.0.76"
|
|
52
52
|
},
|
|
53
53
|
"size-limit": [
|
|
54
54
|
{
|