@coinbase/cdp-react 0.0.17 → 0.0.18
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.
|
@@ -13,7 +13,7 @@ import '../../assets/AuthButton.css';const B = "AuthButton-module__loading___JpD
|
|
|
13
13
|
onSignOutSuccess: h,
|
|
14
14
|
...p
|
|
15
15
|
}) => {
|
|
16
|
-
const i = _(), u = v(), [m, s] = c(u), [t, d] = c(!1), [n, r] = c(void 0), o = w(!1), I = () => {
|
|
16
|
+
const { isInitialized: i } = _(), { isSignedIn: u } = v(), [m, s] = c(u), [t, d] = c(!1), [n, r] = c(void 0), o = w(!1), I = () => {
|
|
17
17
|
g?.(), r(S);
|
|
18
18
|
}, O = () => {
|
|
19
19
|
h?.(), s(!1);
|
|
@@ -19,7 +19,7 @@ import '../../assets/SendTransactionButton.css';const P = {
|
|
|
19
19
|
variant: p = "primary",
|
|
20
20
|
...g
|
|
21
21
|
}) => {
|
|
22
|
-
const [h, c] = _(!1), m = y(), E = v(
|
|
22
|
+
const [h, c] = _(!1), { sendEvmTransaction: m } = y(), E = v(
|
|
23
23
|
async (d) => {
|
|
24
24
|
d.preventDefault(), o?.(d);
|
|
25
25
|
try {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as i, jsx as o, Fragment as A } from "react/jsx-runtime";
|
|
2
2
|
import { useSignInWithEmail as U, useVerifyEmailOTP as V } from "@coinbase/cdp-hooks";
|
|
3
3
|
import { Form as P, FormSubmit as R } from "@radix-ui/react-form";
|
|
4
4
|
import { useState as v, useEffect as y, useRef as B } from "react";
|
|
@@ -29,8 +29,8 @@ import '../../assets/SignInForm.css';const J = "SignInForm-module__form___8Mc3V"
|
|
|
29
29
|
hr: H,
|
|
30
30
|
icon: X
|
|
31
31
|
}, Y = ({ submit: _ }) => {
|
|
32
|
-
const { state:
|
|
33
|
-
return /* @__PURE__ */
|
|
32
|
+
const { state: s, dispatch: d } = E(), e = () => d({ type: "CLEAR_ERROR" }), u = (p) => (p.preventDefault(), _(s.email));
|
|
33
|
+
return /* @__PURE__ */ i(
|
|
34
34
|
P,
|
|
35
35
|
{
|
|
36
36
|
className: n.form,
|
|
@@ -52,29 +52,29 @@ import '../../assets/SignInForm.css';const J = "SignInForm-module__form___8Mc3V"
|
|
|
52
52
|
type: "email",
|
|
53
53
|
placeholder: "name@example.com",
|
|
54
54
|
required: !0,
|
|
55
|
-
value:
|
|
55
|
+
value: s.email,
|
|
56
56
|
onChange: (p) => {
|
|
57
57
|
d({ type: "SET_EMAIL", payload: { email: p.target.value } });
|
|
58
58
|
}
|
|
59
59
|
})
|
|
60
60
|
}
|
|
61
61
|
),
|
|
62
|
-
|
|
63
|
-
/* @__PURE__ */ o(R, { asChild: !0, children: /* @__PURE__ */ o(C, { type: "submit", isPending:
|
|
62
|
+
s.error && /* @__PURE__ */ o(O, { error: s.error, className: n["server-error"] }),
|
|
63
|
+
/* @__PURE__ */ o(R, { asChild: !0, children: /* @__PURE__ */ o(C, { type: "submit", isPending: s.isPending, children: "Continue with email" }) })
|
|
64
64
|
]
|
|
65
65
|
}
|
|
66
66
|
);
|
|
67
67
|
}, z = ({
|
|
68
68
|
reset: _,
|
|
69
|
-
resetCountdown:
|
|
69
|
+
resetCountdown: s,
|
|
70
70
|
submit: d
|
|
71
71
|
}) => {
|
|
72
|
-
const { state: e, dispatch: u } = E(), p = () => u({ type: "CLEAR_ERROR" }), l = B([]), f = (c) => (c.preventDefault(), d(e.otp)),
|
|
72
|
+
const { state: e, dispatch: u } = E(), p = () => u({ type: "CLEAR_ERROR" }), l = B([]), f = (c) => (c.preventDefault(), d(e.otp)), h = () => {
|
|
73
73
|
_(), l.current[0]?.focus();
|
|
74
74
|
};
|
|
75
75
|
return y(() => {
|
|
76
76
|
e.step === "otp" && l.current[0]?.focus();
|
|
77
|
-
}, [e.step]), /* @__PURE__ */
|
|
77
|
+
}, [e.step]), /* @__PURE__ */ i(
|
|
78
78
|
P,
|
|
79
79
|
{
|
|
80
80
|
className: `${n.form}`,
|
|
@@ -96,32 +96,32 @@ import '../../assets/SignInForm.css';const J = "SignInForm-module__form___8Mc3V"
|
|
|
96
96
|
autoSubmit: !0
|
|
97
97
|
}
|
|
98
98
|
),
|
|
99
|
-
/* @__PURE__ */
|
|
100
|
-
(e.isPending && !e.canResetOTP || e.error) && /* @__PURE__ */
|
|
99
|
+
/* @__PURE__ */ i("div", { className: n["form-footer"], children: [
|
|
100
|
+
(e.isPending && !e.canResetOTP || e.error) && /* @__PURE__ */ i("div", { className: n["server-state-wrapper"], children: [
|
|
101
101
|
e.isPending && !e.canResetOTP && /* @__PURE__ */ o($, { className: n["loading-spinner"] }),
|
|
102
102
|
e.error && /* @__PURE__ */ o(O, { error: e.error, className: n["server-error"] })
|
|
103
103
|
] }),
|
|
104
|
-
/* @__PURE__ */
|
|
104
|
+
/* @__PURE__ */ i("div", { className: n["resend-wrapper"], children: [
|
|
105
105
|
e.canResetOTP && /* @__PURE__ */ o(R, { asChild: !0, children: /* @__PURE__ */ o(
|
|
106
106
|
C,
|
|
107
107
|
{
|
|
108
108
|
type: "button",
|
|
109
|
-
onClick:
|
|
109
|
+
onClick: h,
|
|
110
110
|
isPending: e.isPending,
|
|
111
111
|
variant: "linkPrimary",
|
|
112
112
|
children: "Resend code"
|
|
113
113
|
}
|
|
114
114
|
) }),
|
|
115
|
-
!e.canResetOTP && /* @__PURE__ */ o("div", { className: n["reset-timer"], children: /* @__PURE__ */
|
|
115
|
+
!e.canResetOTP && /* @__PURE__ */ o("div", { className: n["reset-timer"], children: /* @__PURE__ */ i("p", { children: [
|
|
116
116
|
"Resend code in ",
|
|
117
|
-
/* @__PURE__ */
|
|
118
|
-
|
|
117
|
+
/* @__PURE__ */ i("span", { "aria-hidden": "true", children: [
|
|
118
|
+
s,
|
|
119
119
|
"s"
|
|
120
120
|
] }),
|
|
121
|
-
/* @__PURE__ */
|
|
122
|
-
|
|
121
|
+
/* @__PURE__ */ i(j, { children: [
|
|
122
|
+
s,
|
|
123
123
|
" ",
|
|
124
|
-
|
|
124
|
+
s === 1 ? "second" : "seconds"
|
|
125
125
|
] })
|
|
126
126
|
] }) })
|
|
127
127
|
] })
|
|
@@ -129,20 +129,20 @@ import '../../assets/SignInForm.css';const J = "SignInForm-module__form___8Mc3V"
|
|
|
129
129
|
]
|
|
130
130
|
}
|
|
131
131
|
);
|
|
132
|
-
},
|
|
132
|
+
}, he = ({
|
|
133
133
|
as: _ = "div",
|
|
134
|
-
className:
|
|
134
|
+
className: s = "",
|
|
135
135
|
onSuccess: d,
|
|
136
136
|
...e
|
|
137
137
|
}) => {
|
|
138
|
-
const l = "An error occurred while signing in. Please try again.", [f,
|
|
139
|
-
|
|
138
|
+
const l = "An error occurred while signing in. Please try again.", [f, h] = v(0), [c, S] = v(!1), { signInWithEmail: w } = U(), { verifyEmailOTP: b } = V(), { state: a, dispatch: m } = E(), { showCoinbaseFooter: F } = k(), L = (t) => {
|
|
139
|
+
h(t), S(!0);
|
|
140
140
|
};
|
|
141
141
|
y(() => {
|
|
142
142
|
if (!c)
|
|
143
143
|
return;
|
|
144
144
|
const t = setInterval(() => {
|
|
145
|
-
|
|
145
|
+
h((r) => r > 1 ? r - 1 : (S(!1), 0));
|
|
146
146
|
}, 1e3);
|
|
147
147
|
return () => clearInterval(t);
|
|
148
148
|
}, [c]), y(() => {
|
|
@@ -179,16 +179,16 @@ import '../../assets/SignInForm.css';const J = "SignInForm-module__form___8Mc3V"
|
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
}, N = () => {
|
|
182
|
-
m({ type: "RESET_OTP" }),
|
|
182
|
+
m({ type: "RESET_OTP" }), S(!1), I(a.email);
|
|
183
183
|
};
|
|
184
|
-
return /* @__PURE__ */
|
|
184
|
+
return /* @__PURE__ */ i(_, { className: `${n["form-wrapper"]} ${s}`, ...e, children: [
|
|
185
185
|
a.step === "email" && /* @__PURE__ */ o(Y, { submit: I }),
|
|
186
186
|
a.step === "otp" && /* @__PURE__ */ o(z, { submit: M, reset: N, resetCountdown: f }),
|
|
187
|
-
F && /* @__PURE__ */
|
|
187
|
+
F && /* @__PURE__ */ i(A, { children: [
|
|
188
188
|
/* @__PURE__ */ o("hr", { className: n.hr }),
|
|
189
|
-
/* @__PURE__ */
|
|
189
|
+
/* @__PURE__ */ i("div", { className: n.footer, children: [
|
|
190
190
|
/* @__PURE__ */ o(W, { className: n.icon }),
|
|
191
|
-
/* @__PURE__ */
|
|
191
|
+
/* @__PURE__ */ i("p", { children: [
|
|
192
192
|
"Secured by",
|
|
193
193
|
" ",
|
|
194
194
|
/* @__PURE__ */ o(D, { className: n["coinbase-icon"], "aria-label": "Coinbase" })
|
|
@@ -198,5 +198,5 @@ import '../../assets/SignInForm.css';const J = "SignInForm-module__form___8Mc3V"
|
|
|
198
198
|
] });
|
|
199
199
|
};
|
|
200
200
|
export {
|
|
201
|
-
|
|
201
|
+
he as SignInForm
|
|
202
202
|
};
|
|
@@ -6,7 +6,7 @@ import "../../theme/theme.js";
|
|
|
6
6
|
import '../../assets/SignOutButton.css';const e = {
|
|
7
7
|
"sign-out-button": "SignOutButton-module__sign-out-button___qiybe"
|
|
8
8
|
}, O = ({ children: t, variant: o = "primary", onSuccess: n }) => {
|
|
9
|
-
const i = r(), u = async () => {
|
|
9
|
+
const { signOut: i } = r(), u = async () => {
|
|
10
10
|
await i(), n?.();
|
|
11
11
|
};
|
|
12
12
|
return /* @__PURE__ */ s(m, { variant: o, className: e["sign-out-button"], onClick: u, children: t || "Sign out" });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coinbase/cdp-react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.18",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@radix-ui/react-dialog": "^1.1.14",
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
},
|
|
10
10
|
"peerDependencies": {
|
|
11
11
|
"react": ">=18.2.0",
|
|
12
|
-
"@coinbase/cdp-core": "^0.0.
|
|
13
|
-
"@coinbase/cdp-hooks": "^0.0.
|
|
12
|
+
"@coinbase/cdp-core": "^0.0.18",
|
|
13
|
+
"@coinbase/cdp-hooks": "^0.0.18"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@size-limit/preset-big-lib": "^11.2.0",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"vite": "^7.0.4",
|
|
39
39
|
"vite-plugin-dts": "^4.5.4",
|
|
40
40
|
"vite-plugin-lib-inject-css": "^2.2.2",
|
|
41
|
-
"@coinbase/cdp-core": "^0.0.
|
|
42
|
-
"@coinbase/cdp-hooks": "^0.0.
|
|
41
|
+
"@coinbase/cdp-core": "^0.0.18",
|
|
42
|
+
"@coinbase/cdp-hooks": "^0.0.18"
|
|
43
43
|
},
|
|
44
44
|
"size-limit": [
|
|
45
45
|
{
|