@coinbase/cdp-react 0.0.41 → 0.0.42

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.
@@ -6,11 +6,11 @@ export interface AppConfig {
6
6
  appName?: string;
7
7
  appLogoUrl?: string;
8
8
  showCoinbaseFooter?: boolean;
9
- authMethods?: AuthMethod[];
9
+ authMethods?: [AuthMethod, ...AuthMethod[]];
10
10
  }
11
11
  export type Config = AppConfig & CDPHooksConfig;
12
12
  export type CDPReactProviderProps = {
13
13
  config: Config;
14
14
  } & ThemeProviderProps;
15
15
  export declare const CDPReactProvider: ({ children, config, theme }: CDPReactProviderProps) => import("react/jsx-runtime").JSX.Element;
16
- export declare const useAppConfig: () => AppConfig;
16
+ export declare const useAppConfig: () => Required<AppConfig>;
@@ -1,63 +1,77 @@
1
- import { jsx as t } from "react/jsx-runtime";
2
- import { CDPContext as A, CDPHooksProvider as O } from "@coinbase/cdp-hooks";
3
- import { createContext as b, useMemo as r, useContext as f } from "react";
4
- import { ThemeProvider as w } from "../ThemeProvider/index.js";
5
- const E = [
1
+ import { jsx as c } from "react/jsx-runtime";
2
+ import { CDPContext as L, CDPHooksProvider as O } from "@coinbase/cdp-hooks";
3
+ import { createContext as v, useMemo as f, useContext as l } from "react";
4
+ import { ThemeProvider as b } from "../ThemeProvider/index.js";
5
+ const w = (o) => {
6
+ try {
7
+ return JSON.stringify(o);
8
+ } catch {
9
+ }
10
+ return "";
11
+ }, T = [
6
12
  /** Email OTP method */
7
13
  "email",
8
14
  /** SMS OTP method */
9
15
  "sms"
10
- ], F = ({ children: o, config: e, theme: n }) => {
16
+ ], _ = ({ children: o, config: r, theme: n }) => {
11
17
  const {
12
- appName: i,
18
+ appName: a,
13
19
  appLogoUrl: s,
14
- showCoinbaseFooter: a,
15
- authMethods: p,
16
- projectId: c,
17
- useMock: C,
20
+ showCoinbaseFooter: h,
21
+ authMethods: i,
22
+ projectId: p,
23
+ useMock: e,
18
24
  debugging: u,
19
- basePath: d,
25
+ basePath: g,
20
26
  ethereum: P,
21
27
  solana: x
22
- } = e, { createOnLogin: m } = P ?? {}, { createOnLogin: g } = x ?? {}, v = r(
28
+ } = r, { createOnLogin: d } = P ?? {}, { createOnLogin: C } = x ?? {}, A = f(
23
29
  () => ({
24
- projectId: c,
25
- useMock: C,
30
+ projectId: p,
31
+ useMock: e,
26
32
  debugging: u,
27
- basePath: d,
28
- ethereum: { createOnLogin: m },
29
- solana: { createOnLogin: g }
33
+ basePath: g,
34
+ ethereum: { createOnLogin: d },
35
+ solana: { createOnLogin: C }
30
36
  }),
31
- [c, C, u, d, m, g]
32
- ), L = r(
33
- () => ({ appName: i, appLogoUrl: s, showCoinbaseFooter: a, authMethods: p }),
34
- [i, s, a, p]
35
- ), h = /* @__PURE__ */ t(M, { config: L, children: /* @__PURE__ */ t(w, { theme: n, children: o }) });
36
- return f(A) ? h : /* @__PURE__ */ t(O, { config: v, children: h });
37
- }, l = b(void 0), D = {
37
+ [p, e, u, g, d, C]
38
+ ), m = /* @__PURE__ */ c(y, { config: { appName: a, appLogoUrl: s, showCoinbaseFooter: h, authMethods: i }, children: /* @__PURE__ */ c(b, { theme: n, children: o }) });
39
+ return l(L) ? m : /* @__PURE__ */ c(O, { config: A, children: m });
40
+ }, M = v(void 0), t = {
38
41
  appName: "",
39
42
  appLogoUrl: "",
40
43
  showCoinbaseFooter: !0,
41
44
  authMethods: ["email"]
42
- }, M = ({ children: o, config: e }) => {
43
- const n = r(
44
- () => ({
45
+ }, y = ({ children: o, config: r }) => {
46
+ const {
47
+ appName: n = t.appName,
48
+ appLogoUrl: a = t.appLogoUrl,
49
+ showCoinbaseFooter: s = t.showCoinbaseFooter,
50
+ authMethods: h = t.authMethods
51
+ } = r ?? {}, i = w(h), p = f(() => {
52
+ let e = ["email"];
53
+ try {
54
+ e = JSON.parse(i);
55
+ } catch {
56
+ }
57
+ return {
45
58
  app: {
46
- ...D,
47
- ...e
59
+ appName: n,
60
+ appLogoUrl: a,
61
+ showCoinbaseFooter: s,
62
+ authMethods: Array.isArray(e) && e?.length ? e : t.authMethods
48
63
  }
49
- }),
50
- [e]
51
- );
52
- return /* @__PURE__ */ t(l.Provider, { value: n, children: o });
53
- }, N = () => {
54
- const o = f(l);
64
+ };
65
+ }, [n, a, s, i]);
66
+ return /* @__PURE__ */ c(M.Provider, { value: p, children: o });
67
+ }, j = () => {
68
+ const o = l(M);
55
69
  if (!o)
56
70
  throw new Error("useAppConfig must be used within an AppConfigProvider");
57
71
  return o.app;
58
72
  };
59
73
  export {
60
- E as AUTH_METHODS,
61
- F as CDPReactProvider,
62
- N as useAppConfig
74
+ T as AUTH_METHODS,
75
+ _ as CDPReactProvider,
76
+ j as useAppConfig
63
77
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coinbase/cdp-react",
3
- "version": "0.0.41",
3
+ "version": "0.0.42",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "@internationalized/number": "3.6.4",
@@ -14,8 +14,8 @@
14
14
  },
15
15
  "peerDependencies": {
16
16
  "react": ">=18.2.0",
17
- "@coinbase/cdp-core": "^0.0.41",
18
- "@coinbase/cdp-hooks": "^0.0.41"
17
+ "@coinbase/cdp-core": "^0.0.42",
18
+ "@coinbase/cdp-hooks": "^0.0.42"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@size-limit/preset-big-lib": "^11.2.0",
@@ -45,8 +45,8 @@
45
45
  "vite": "^7.0.4",
46
46
  "vite-plugin-dts": "^4.5.4",
47
47
  "vite-plugin-lib-inject-css": "^2.2.2",
48
- "@coinbase/cdp-core": "^0.0.41",
49
- "@coinbase/cdp-hooks": "^0.0.41"
48
+ "@coinbase/cdp-core": "^0.0.42",
49
+ "@coinbase/cdp-hooks": "^0.0.42"
50
50
  },
51
51
  "size-limit": [
52
52
  {