@coinbase/cdp-react 0.0.7 → 0.0.9
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/README.md
CHANGED
|
@@ -32,6 +32,13 @@ npm install @coinbase/cdp-react @coinbase/cdp-core @coinbase/cdp-hooks
|
|
|
32
32
|
1. Sign in or create an account on the [CDP Portal](https://portal.cdp.coinbase.com)
|
|
33
33
|
2. On your dashboard, select a project from the dropdown at the at the top, and copy the Project ID
|
|
34
34
|
|
|
35
|
+
### Allowlist your local app
|
|
36
|
+
|
|
37
|
+
1. Navigate to the [Embedded Wallet Configuration](https://portal.cdp.coinbase.com/products/embedded-wallets/cors)
|
|
38
|
+
in CDP Portal, and click Add origin to include your local app
|
|
39
|
+
2. Enter the origin of your locally running app - e.g., `http://localhost:3000`
|
|
40
|
+
3. Click Add origin again to save your changes
|
|
41
|
+
|
|
35
42
|
### Setup Provider
|
|
36
43
|
|
|
37
44
|
Next, you need to wrap your application with the `CDPReactProvider`.
|
|
@@ -2,19 +2,19 @@ import { jsxs as o, jsx as t } from "react/jsx-runtime";
|
|
|
2
2
|
import { useSignInWithEmail as U, useVerifyEmailOTP as A } from "@coinbase/cdp-hooks";
|
|
3
3
|
import { Form as R, FormSubmit as C } from "@radix-ui/react-form";
|
|
4
4
|
import { useState as I, useEffect as T, useRef as F } from "react";
|
|
5
|
-
import { Button as O } from "../Button/index.js";
|
|
6
5
|
import { Field as B } from "../Field/index.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { VisuallyHidden as W } from "../VisuallyHidden/index.js";
|
|
12
|
-
import { IconCoinbaseWordmark as D } from "../../icons/IconCoinbaseWordmark.js";
|
|
13
|
-
import { IconLock as $ } from "../../icons/IconLock.js";
|
|
6
|
+
import { OTP as x } from "../OTP/index.js";
|
|
7
|
+
import { ServerError as O } from "../ServerError/index.js";
|
|
8
|
+
import { IconCoinbaseWordmark as V } from "../../icons/IconCoinbaseWordmark.js";
|
|
9
|
+
import { IconLock as W } from "../../icons/IconLock.js";
|
|
14
10
|
import { isApiError as P } from "../../utils/isApiError.js";
|
|
15
|
-
import { isEmailInvalid as
|
|
11
|
+
import { isEmailInvalid as k } from "../../utils/isEmailInvalid.js";
|
|
16
12
|
import { s } from "../../chunks/SignIn.module.Dl3CqKQ_.js";
|
|
17
13
|
import { useSignInContext as g } from "./SignInProvider.js";
|
|
14
|
+
import { withValidityState as D } from "../Input/index.js";
|
|
15
|
+
import { Button as b } from "../Button/index.js";
|
|
16
|
+
import { LoadingSpinner as $ } from "../LoadingSpinner/index.js";
|
|
17
|
+
import { VisuallyHidden as j } from "../VisuallyHidden/index.js";
|
|
18
18
|
const q = ({ submit: u }) => {
|
|
19
19
|
const { state: n, dispatch: d } = g(), e = () => d({ type: "CLEAR_ERROR" }), f = (p) => (p.preventDefault(), u(n.email));
|
|
20
20
|
return /* @__PURE__ */ o(
|
|
@@ -32,9 +32,9 @@ const q = ({ submit: u }) => {
|
|
|
32
32
|
validators: [
|
|
33
33
|
["valueMissing", "Email is required"],
|
|
34
34
|
["typeMismatch", "Use a valid email address"],
|
|
35
|
-
[
|
|
35
|
+
[k, "Use a valid email address"]
|
|
36
36
|
],
|
|
37
|
-
children:
|
|
37
|
+
children: D({
|
|
38
38
|
type: "email",
|
|
39
39
|
placeholder: "name@example.com",
|
|
40
40
|
required: !0,
|
|
@@ -45,8 +45,8 @@ const q = ({ submit: u }) => {
|
|
|
45
45
|
})
|
|
46
46
|
}
|
|
47
47
|
),
|
|
48
|
-
n.error && /* @__PURE__ */ t(
|
|
49
|
-
/* @__PURE__ */ t(C, { asChild: !0, children: /* @__PURE__ */ t(
|
|
48
|
+
n.error && /* @__PURE__ */ t(O, { error: n.error, className: s.serverError }),
|
|
49
|
+
/* @__PURE__ */ t(C, { asChild: !0, children: /* @__PURE__ */ t(b, { type: "submit", isPending: n.isPending, children: "Continue with email" }) })
|
|
50
50
|
]
|
|
51
51
|
}
|
|
52
52
|
);
|
|
@@ -68,7 +68,7 @@ const q = ({ submit: u }) => {
|
|
|
68
68
|
onSubmit: h,
|
|
69
69
|
children: [
|
|
70
70
|
/* @__PURE__ */ t(
|
|
71
|
-
|
|
71
|
+
x,
|
|
72
72
|
{
|
|
73
73
|
ref: c,
|
|
74
74
|
name: "otp",
|
|
@@ -84,12 +84,12 @@ const q = ({ submit: u }) => {
|
|
|
84
84
|
),
|
|
85
85
|
/* @__PURE__ */ o("div", { className: s.formFooter, children: [
|
|
86
86
|
(e.isPending && !e.canResetOTP || e.error) && /* @__PURE__ */ o("div", { className: s.serverStateWrapper, children: [
|
|
87
|
-
e.isPending && !e.canResetOTP && /* @__PURE__ */ t(
|
|
88
|
-
e.error && /* @__PURE__ */ t(
|
|
87
|
+
e.isPending && !e.canResetOTP && /* @__PURE__ */ t($, { className: s.loadingSpinner }),
|
|
88
|
+
e.error && /* @__PURE__ */ t(O, { error: e.error, className: s.serverError })
|
|
89
89
|
] }),
|
|
90
90
|
/* @__PURE__ */ o("div", { children: [
|
|
91
91
|
e.canResetOTP && /* @__PURE__ */ t(C, { asChild: !0, children: /* @__PURE__ */ t(
|
|
92
|
-
|
|
92
|
+
b,
|
|
93
93
|
{
|
|
94
94
|
type: "button",
|
|
95
95
|
onClick: E,
|
|
@@ -104,7 +104,7 @@ const q = ({ submit: u }) => {
|
|
|
104
104
|
n,
|
|
105
105
|
"s"
|
|
106
106
|
] }),
|
|
107
|
-
/* @__PURE__ */ o(
|
|
107
|
+
/* @__PURE__ */ o(j, { children: [
|
|
108
108
|
n,
|
|
109
109
|
" ",
|
|
110
110
|
n === 1 ? "second" : "seconds"
|
|
@@ -121,7 +121,7 @@ const q = ({ submit: u }) => {
|
|
|
121
121
|
onSuccess: d,
|
|
122
122
|
...e
|
|
123
123
|
}) => {
|
|
124
|
-
const c = "An error occurred while signing in. Please try again.", [h, E] = I(0), [m, y] = I(!1), _ = U(),
|
|
124
|
+
const c = "An error occurred while signing in. Please try again.", [h, E] = I(0), [m, y] = I(!1), _ = U(), L = A(), { state: i, dispatch: l } = g(), N = (a) => {
|
|
125
125
|
E(a), y(!0);
|
|
126
126
|
};
|
|
127
127
|
T(() => {
|
|
@@ -141,13 +141,13 @@ const q = ({ submit: u }) => {
|
|
|
141
141
|
const { flowId: r } = await _({
|
|
142
142
|
email: a
|
|
143
143
|
});
|
|
144
|
-
l({ type: "SUBMIT_EMAIL_SUCCESS", payload: { flowId: r } }),
|
|
144
|
+
l({ type: "SUBMIT_EMAIL_SUCCESS", payload: { flowId: r } }), N(60);
|
|
145
145
|
} catch (r) {
|
|
146
146
|
const S = P(r) ? r : r instanceof Error && r.message || c;
|
|
147
147
|
l({ type: "SUBMIT_EMAIL_FAILURE", payload: { error: S } }), console.error(r);
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
|
-
},
|
|
150
|
+
}, w = async (a) => {
|
|
151
151
|
if (!i.isPending) {
|
|
152
152
|
if (a.length !== 6) {
|
|
153
153
|
l({ type: "SET_OTP", payload: { otp: a } });
|
|
@@ -155,7 +155,7 @@ const q = ({ submit: u }) => {
|
|
|
155
155
|
}
|
|
156
156
|
l({ type: "SUBMIT_OTP", payload: { otp: a } });
|
|
157
157
|
try {
|
|
158
|
-
await
|
|
158
|
+
await L({
|
|
159
159
|
flowId: i.flowId,
|
|
160
160
|
otp: a
|
|
161
161
|
}), l({ type: "SUBMIT_OTP_SUCCESS", payload: { otp: a } }), d?.();
|
|
@@ -169,14 +169,13 @@ const q = ({ submit: u }) => {
|
|
|
169
169
|
};
|
|
170
170
|
return /* @__PURE__ */ o(u, { className: `${s.form} ${n}`, ...e, children: [
|
|
171
171
|
i.step === "email" && /* @__PURE__ */ t(q, { submit: v }),
|
|
172
|
-
i.step === "otp" && /* @__PURE__ */ t(H, { submit:
|
|
172
|
+
i.step === "otp" && /* @__PURE__ */ t(H, { submit: w, reset: M, resetCountdown: h }),
|
|
173
173
|
/* @__PURE__ */ t("hr", { className: s.hr }),
|
|
174
174
|
/* @__PURE__ */ o("div", { className: s.footer, children: [
|
|
175
|
-
/* @__PURE__ */ t(
|
|
175
|
+
/* @__PURE__ */ t(W, { className: s.icon }),
|
|
176
176
|
/* @__PURE__ */ o("p", { children: [
|
|
177
|
-
"Secured by",
|
|
178
|
-
" "
|
|
179
|
-
/* @__PURE__ */ t("a", { href: "https://www.coinbase.com/security", target: "_blank", rel: "noreferrer", children: /* @__PURE__ */ t(D, { className: s.coinbaseIcon, "aria-label": "Coinbase" }) })
|
|
177
|
+
"Secured by ",
|
|
178
|
+
/* @__PURE__ */ t(V, { className: s.coinbaseIcon, "aria-label": "Coinbase" })
|
|
180
179
|
] })
|
|
181
180
|
] })
|
|
182
181
|
] });
|
|
@@ -2,13 +2,13 @@ import { jsxs as o, jsx as n } from "react/jsx-runtime";
|
|
|
2
2
|
import { Dialog as g, DialogTrigger as c, DialogPortal as m, DialogOverlay as _, DialogContent as d, DialogClose as I, DialogTitle as p, DialogDescription as u } from "@radix-ui/react-dialog";
|
|
3
3
|
import "react";
|
|
4
4
|
import { IconXMark as h } from "../../icons/IconXMark.js";
|
|
5
|
-
import { Button as r } from "../Button/index.js";
|
|
6
5
|
import { SignIn as S } from "../SignIn/index.js";
|
|
7
6
|
import { useTheme as D } from "../ThemeProvider/index.js";
|
|
8
7
|
import { SignInImage as M } from "../SignIn/SignInImage.js";
|
|
9
8
|
import { SignInTitle as f } from "../SignIn/SignInTitle.js";
|
|
10
9
|
import { SignInDescription as v } from "../SignIn/SignInDescription.js";
|
|
11
10
|
import { SignInForm as N } from "../SignIn/SignInForm.js";
|
|
11
|
+
import { Button as r } from "../Button/index.js";
|
|
12
12
|
import '../../assets/SignInModal.css';const y = "SignInModal-module__trigger___IcJ8x", T = "SignInModal-module__modal___PErrT", C = "SignInModal-module__signIn___hQuJk", x = "SignInModal-module__signInForm___6-UdI", B = "SignInModal-module__signInTitle___AF-XA", F = "SignInModal-module__signInDescription___SZjXu", W = "SignInModal-module__signInImage___hMBda", j = "SignInModal-module__closeWrapper___cx8Zq", X = "SignInModal-module__closeButton___yf-ZW", Z = "SignInModal-module__overlay___-0rmi", b = "SignInModal-module__spacer___x-lRH", i = {
|
|
13
13
|
trigger: y,
|
|
14
14
|
modal: T,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as s } from "react/jsx-runtime";
|
|
2
2
|
import { useSignOut as r } from "@coinbase/cdp-hooks";
|
|
3
3
|
import "react";
|
|
4
|
-
import { Button as m } from "../Button/index.js";
|
|
5
4
|
import "../../theme/theme.js";
|
|
5
|
+
import { Button as m } from "../Button/index.js";
|
|
6
6
|
import '../../assets/SignOutButton.css';const g = "SignOutButton-module__signOutButton___WNhmy", c = {
|
|
7
7
|
signOutButton: g
|
|
8
8
|
}, l = ({ children: t, variant: n = "primary", onSuccess: o }) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coinbase/cdp-react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
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.9",
|
|
13
|
+
"@coinbase/cdp-hooks": "^0.0.9"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@size-limit/preset-big-lib": "^11.2.0",
|
|
@@ -34,20 +34,22 @@
|
|
|
34
34
|
"vite": "^7.0.4",
|
|
35
35
|
"vite-plugin-dts": "^4.5.4",
|
|
36
36
|
"vite-plugin-lib-inject-css": "^2.2.2",
|
|
37
|
-
"@coinbase/cdp-core": "^0.0.
|
|
38
|
-
"@coinbase/cdp-hooks": "^0.0.
|
|
37
|
+
"@coinbase/cdp-core": "^0.0.9",
|
|
38
|
+
"@coinbase/cdp-hooks": "^0.0.9"
|
|
39
39
|
},
|
|
40
40
|
"size-limit": [
|
|
41
41
|
{
|
|
42
42
|
"name": "full-package",
|
|
43
43
|
"path": "./dist/index.js",
|
|
44
44
|
"import": "*",
|
|
45
|
+
"running": false,
|
|
45
46
|
"limit": "65 KB"
|
|
46
47
|
},
|
|
47
48
|
{
|
|
48
49
|
"name": "single-component",
|
|
49
50
|
"path": "./dist/components/SignIn/index.js",
|
|
50
51
|
"import": "{ SignIn }",
|
|
52
|
+
"running": false,
|
|
51
53
|
"limit": "65 KB"
|
|
52
54
|
}
|
|
53
55
|
],
|