@coinbase/cdp-react 0.0.61 → 0.0.63
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/IframeButton.css +1 -1
- package/dist/components/CopyEvmKeyButton/index.d.ts +5 -2
- package/dist/components/CopyEvmKeyButton/index.js +39 -37
- package/dist/components/CopySolanaKeyButton/index.d.ts +5 -2
- package/dist/components/CopySolanaKeyButton/index.js +45 -43
- package/dist/components/ExportWallet/index.js +62 -56
- package/dist/components/SignIn/SignInProvider.js +21 -18
- package/dist/components/SignIn/types.d.ts +5 -0
- package/dist/components/SignIn/useSignInReducer.js +7 -2
- package/dist/components/ui/IframeButton/index.d.ts +7 -3
- package/dist/components/ui/IframeButton/index.js +127 -39
- package/dist/hooks/useKeyExportPostMessage.d.ts +6 -4
- package/dist/hooks/useKeyExportPostMessage.js +55 -48
- package/dist/types/secureIframe.d.ts +31 -3
- package/dist/types/secureIframe.js +4 -6
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
.IframeButton-module__iframe-button___XeAhH{position:relative;width:min-content;height:3.5em;padding-left:2.5em;padding-right:2.5em}.IframeButton-module__iframe-button___XeAhH>*{grid-area:center}.IframeButton-module__iframe-button___XeAhH.IframeButton-module__full-width___lQWpM{width:100%}.IframeButton-module__iframe-button___XeAhH.IframeButton-module__size-lg___HCOiF{height:4em}.IframeButton-module__iframe-button___XeAhH.IframeButton-module__size-md___p44a4{height:3.5em}.IframeButton-module__iframe-button___XeAhH.IframeButton-module__size-sm___U8ILi{padding-left:2em;padding-right:2em;height:3em}.IframeButton-module__iframe-button___XeAhH.IframeButton-module__size-xs___S2jGa{padding-left:1.5em;padding-right:1.5em;height:2.5em}.IframeButton-module__loading-skeleton___fzBol{border-radius:var(--cdp-web-borderRadius-cta);width:calc(100% - .5em);height:calc(100% - .5em);position:absolute;top:50%;left:50%;transform:translate3d(-50%,-50%,0)}.IframeButton-module__label___Vvl8W{visibility:hidden;white-space:nowrap;position:relative}.IframeButton-module__iframe-button___XeAhH.IframeButton-module__with-icon___KBiq1 .IframeButton-module__label___Vvl8W{padding-left:1em}.IframeButton-module__iframe___0RBLL{border:none;width:100%;height:100%;position:absolute;top:50%;left:50%;transform:translate3d(-50%,-50%,0)}.IframeButton-module__iframe___0RBLL.IframeButton-module__hidden___LcF1X{display:none}
|
|
1
|
+
.IframeButton-module__iframe-button___XeAhH{position:relative;width:min-content;height:3.5em;padding-left:2.5em;padding-right:2.5em}.IframeButton-module__iframe-button___XeAhH>*{grid-area:center}.IframeButton-module__iframe-button___XeAhH.IframeButton-module__full-width___lQWpM{width:100%}.IframeButton-module__iframe-button___XeAhH.IframeButton-module__size-lg___HCOiF{height:4em}.IframeButton-module__iframe-button___XeAhH.IframeButton-module__size-md___p44a4{height:3.5em}.IframeButton-module__iframe-button___XeAhH.IframeButton-module__size-sm___U8ILi{padding-left:2em;padding-right:2em;height:3em}.IframeButton-module__iframe-button___XeAhH.IframeButton-module__size-xs___S2jGa{padding-left:1.5em;padding-right:1.5em;height:2.5em}.IframeButton-module__loading-skeleton___fzBol{border-radius:var(--cdp-web-borderRadius-cta);width:calc(100% - .5em);height:calc(100% - .5em);position:absolute;top:50%;left:50%;transform:translate3d(-50%,-50%,0)}.IframeButton-module__label___Vvl8W{visibility:hidden;white-space:nowrap;position:relative}.IframeButton-module__iframe-button___XeAhH.IframeButton-module__with-icon___KBiq1 .IframeButton-module__label___Vvl8W{padding-left:1em}.IframeButton-module__iframe___0RBLL{border:none;width:100%;height:100%;position:absolute;top:50%;left:50%;transform:translate3d(-50%,-50%,0)}.IframeButton-module__iframe___0RBLL.IframeButton-module__hidden___LcF1X{display:none}.IframeButton-module__computed-style___ciB13{position:absolute;visibility:hidden;pointer-events:none;background-color:var(--cdp-web-colors-page-bg-default);border-radius:var(--cdp-web-borderRadius-cta);font-size:var(--cdp-web-font-size-base);font-family:var(--cdp-web-font-family-cta);font-weight:500}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ButtonProps } from '../ui/Button';
|
|
2
|
-
|
|
2
|
+
import { IframeTheme } from '../../types/secureIframe';
|
|
3
|
+
interface CopyEvmKeyButtonProps extends Pick<ButtonProps, "size" | "fullWidth"> {
|
|
3
4
|
address: string;
|
|
4
5
|
className?: string;
|
|
5
6
|
copiedLabel?: string;
|
|
@@ -8,6 +9,8 @@ interface CopyEvmKeyButtonProps extends Pick<ButtonProps, "variant" | "size" | "
|
|
|
8
9
|
onReady?: () => void;
|
|
9
10
|
onSuccess?: () => void;
|
|
10
11
|
onError?: (error?: string) => void;
|
|
12
|
+
theme?: Partial<IframeTheme>;
|
|
13
|
+
variant?: Extract<ButtonProps["variant"], "primary" | "secondary">;
|
|
11
14
|
}
|
|
12
|
-
declare const CopyEvmKeyButton: ({ address, className, copiedLabel, icon, fullWidth, label, onReady, onSuccess, onError, size, variant, }: CopyEvmKeyButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
declare const CopyEvmKeyButton: ({ address, className, copiedLabel, icon, fullWidth, label, onReady, onSuccess, onError, size, theme: themeOverrides, variant, }: CopyEvmKeyButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
16
|
export { CopyEvmKeyButton as unstable_CopyEvmKeyButton, type CopyEvmKeyButtonProps as unstable_CopyEvmKeyButtonProps, };
|
|
@@ -1,58 +1,60 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useConfig as
|
|
3
|
-
import { useRef as
|
|
1
|
+
import { jsx as x } from "react/jsx-runtime";
|
|
2
|
+
import { useConfig as E } from "@coinbase/cdp-hooks";
|
|
3
|
+
import { useRef as I, useState as K, useCallback as T, useEffect as j } from "react";
|
|
4
4
|
import "../ui/Button/index.js";
|
|
5
|
-
import { IframeButton as
|
|
6
|
-
import { useKeyExportPostMessage as
|
|
5
|
+
import { IframeButton as k } from "../ui/IframeButton/index.js";
|
|
6
|
+
import { useKeyExportPostMessage as w } from "../../hooks/useKeyExportPostMessage.js";
|
|
7
7
|
import "@coinbase/cdp-core";
|
|
8
|
-
import "../../theme/cssVariables.js";
|
|
9
|
-
import "../../theme/theme.js";
|
|
10
|
-
import "../../theme/tokens.js";
|
|
11
8
|
const A = ({
|
|
12
|
-
address:
|
|
13
|
-
className:
|
|
14
|
-
copiedLabel:
|
|
9
|
+
address: n,
|
|
10
|
+
className: p = "",
|
|
11
|
+
copiedLabel: u = "Copied",
|
|
15
12
|
icon: o = !0,
|
|
16
13
|
fullWidth: c,
|
|
17
|
-
label:
|
|
18
|
-
onReady:
|
|
19
|
-
onSuccess:
|
|
14
|
+
label: r = "Copy key",
|
|
15
|
+
onReady: m,
|
|
16
|
+
onSuccess: s,
|
|
20
17
|
onError: i,
|
|
21
|
-
size:
|
|
22
|
-
|
|
18
|
+
size: h,
|
|
19
|
+
theme: d,
|
|
20
|
+
variant: l
|
|
23
21
|
}) => {
|
|
24
22
|
const {
|
|
25
|
-
config: { projectId:
|
|
26
|
-
} =
|
|
27
|
-
(
|
|
28
|
-
|
|
23
|
+
config: { projectId: y, secureIframeBasePath: C }
|
|
24
|
+
} = E(), f = I(null), [e, g] = K(void 0), b = T(
|
|
25
|
+
(t, P) => {
|
|
26
|
+
t === "ready" && m?.(), t === "success" && s?.(), t === "error" && i?.(P);
|
|
29
27
|
},
|
|
30
|
-
[
|
|
31
|
-
), { iframeUrl:
|
|
32
|
-
address:
|
|
28
|
+
[m, s, i]
|
|
29
|
+
), { iframeUrl: v, isPending: B, onThemeChange: a } = w({
|
|
30
|
+
address: n,
|
|
33
31
|
type: "evm",
|
|
34
|
-
projectId:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
basePath: y,
|
|
39
|
-
copiedLabel: n,
|
|
32
|
+
projectId: y,
|
|
33
|
+
label: r,
|
|
34
|
+
basePath: C,
|
|
35
|
+
copiedLabel: u,
|
|
40
36
|
icon: o,
|
|
41
37
|
iframeRef: f,
|
|
42
|
-
onStatusUpdate:
|
|
38
|
+
onStatusUpdate: b,
|
|
39
|
+
theme: e
|
|
43
40
|
});
|
|
44
|
-
return
|
|
45
|
-
|
|
41
|
+
return j(() => {
|
|
42
|
+
e && a(e);
|
|
43
|
+
}, [e, a]), /* @__PURE__ */ x(
|
|
44
|
+
k,
|
|
46
45
|
{
|
|
47
46
|
ref: f,
|
|
48
|
-
src:
|
|
47
|
+
src: v,
|
|
49
48
|
allow: "clipboard-read; clipboard-write",
|
|
50
|
-
isPending:
|
|
51
|
-
label:
|
|
49
|
+
isPending: B,
|
|
50
|
+
label: r,
|
|
52
51
|
icon: o,
|
|
53
52
|
fullWidth: c,
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
onThemeChange: g,
|
|
54
|
+
size: h,
|
|
55
|
+
theme: d,
|
|
56
|
+
variant: l,
|
|
57
|
+
className: p
|
|
56
58
|
}
|
|
57
59
|
);
|
|
58
60
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ButtonProps } from '../ui/Button';
|
|
2
|
-
|
|
2
|
+
import { IframeTheme } from '../../types/secureIframe';
|
|
3
|
+
interface CopySolanaKeyButtonProps extends Pick<ButtonProps, "size" | "fullWidth"> {
|
|
3
4
|
address: string;
|
|
4
5
|
className?: string;
|
|
5
6
|
copiedLabel?: string;
|
|
@@ -8,6 +9,8 @@ interface CopySolanaKeyButtonProps extends Pick<ButtonProps, "variant" | "size"
|
|
|
8
9
|
onReady?: () => void;
|
|
9
10
|
onSuccess?: () => void;
|
|
10
11
|
onError?: (error?: string) => void;
|
|
12
|
+
theme?: Partial<IframeTheme>;
|
|
13
|
+
variant?: Extract<ButtonProps["variant"], "primary" | "secondary">;
|
|
11
14
|
}
|
|
12
|
-
declare const CopySolanaKeyButton: ({ address, className, copiedLabel, icon, fullWidth, label, onReady, onSuccess, onError, size, variant, }: CopySolanaKeyButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
declare const CopySolanaKeyButton: ({ address, className, copiedLabel, icon, fullWidth, label, onReady, onSuccess, onError, size, theme: themeOverrides, variant, }: CopySolanaKeyButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
16
|
export { CopySolanaKeyButton as unstable_CopySolanaKeyButton, type CopySolanaKeyButtonProps as unstable_CopySolanaKeyButtonProps, };
|
|
@@ -1,58 +1,60 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useConfig as
|
|
3
|
-
import { useRef as
|
|
1
|
+
import { jsx as I } from "react/jsx-runtime";
|
|
2
|
+
import { useConfig as K } from "@coinbase/cdp-hooks";
|
|
3
|
+
import { useRef as S, useState as T, useCallback as j, useEffect as k } from "react";
|
|
4
4
|
import "../ui/Button/index.js";
|
|
5
|
-
import { IframeButton as
|
|
6
|
-
import { useKeyExportPostMessage as
|
|
5
|
+
import { IframeButton as w } from "../ui/IframeButton/index.js";
|
|
6
|
+
import { useKeyExportPostMessage as U } from "../../hooks/useKeyExportPostMessage.js";
|
|
7
7
|
import "@coinbase/cdp-core";
|
|
8
|
-
import "../../theme/cssVariables.js";
|
|
9
|
-
import "../../theme/theme.js";
|
|
10
|
-
import "../../theme/tokens.js";
|
|
11
8
|
const A = ({
|
|
12
|
-
address:
|
|
13
|
-
className:
|
|
14
|
-
copiedLabel:
|
|
15
|
-
icon:
|
|
9
|
+
address: f,
|
|
10
|
+
className: p = "",
|
|
11
|
+
copiedLabel: u = "Copied",
|
|
12
|
+
icon: t = !0,
|
|
16
13
|
fullWidth: c,
|
|
17
|
-
label:
|
|
18
|
-
onReady:
|
|
19
|
-
onSuccess:
|
|
20
|
-
onError:
|
|
21
|
-
size:
|
|
22
|
-
|
|
14
|
+
label: r = "Copy key",
|
|
15
|
+
onReady: a,
|
|
16
|
+
onSuccess: s,
|
|
17
|
+
onError: m,
|
|
18
|
+
size: l,
|
|
19
|
+
theme: h,
|
|
20
|
+
variant: d
|
|
23
21
|
}) => {
|
|
24
22
|
const {
|
|
25
|
-
config: { projectId:
|
|
26
|
-
} =
|
|
27
|
-
(o,
|
|
28
|
-
o === "ready" &&
|
|
23
|
+
config: { projectId: y, secureIframeBasePath: C }
|
|
24
|
+
} = K(), i = S(null), [e, g] = T(void 0), b = j(
|
|
25
|
+
(o, x) => {
|
|
26
|
+
o === "ready" && a?.(), o === "success" && s?.(), o === "error" && m?.(x);
|
|
29
27
|
},
|
|
30
|
-
[
|
|
31
|
-
), { iframeUrl:
|
|
32
|
-
address:
|
|
28
|
+
[a, s, m]
|
|
29
|
+
), { iframeUrl: B, isPending: P, onThemeChange: n } = U({
|
|
30
|
+
address: f,
|
|
33
31
|
type: "solana",
|
|
34
|
-
projectId:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
onStatusUpdate: d
|
|
32
|
+
projectId: y,
|
|
33
|
+
label: r,
|
|
34
|
+
basePath: C,
|
|
35
|
+
copiedLabel: u,
|
|
36
|
+
icon: t,
|
|
37
|
+
iframeRef: i,
|
|
38
|
+
onStatusUpdate: b,
|
|
39
|
+
theme: e
|
|
43
40
|
});
|
|
44
|
-
return
|
|
45
|
-
|
|
41
|
+
return k(() => {
|
|
42
|
+
e && n(e);
|
|
43
|
+
}, [e, n]), /* @__PURE__ */ I(
|
|
44
|
+
w,
|
|
46
45
|
{
|
|
47
|
-
ref:
|
|
48
|
-
src:
|
|
46
|
+
ref: i,
|
|
47
|
+
src: B,
|
|
49
48
|
allow: "clipboard-read; clipboard-write",
|
|
50
|
-
isPending:
|
|
51
|
-
label:
|
|
52
|
-
icon:
|
|
49
|
+
isPending: P,
|
|
50
|
+
label: r,
|
|
51
|
+
icon: t,
|
|
53
52
|
fullWidth: c,
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
onThemeChange: g,
|
|
54
|
+
size: l,
|
|
55
|
+
theme: h,
|
|
56
|
+
variant: d,
|
|
57
|
+
className: p
|
|
56
58
|
}
|
|
57
59
|
);
|
|
58
60
|
};
|
|
@@ -1,110 +1,116 @@
|
|
|
1
|
-
import { jsx as o, jsxs as
|
|
2
|
-
import { useCurrentUser as
|
|
3
|
-
import { c as
|
|
4
|
-
import { createContext as
|
|
5
|
-
import { CopyAddress as
|
|
6
|
-
import { unstable_CopyEvmKeyButton as
|
|
7
|
-
import { unstable_CopySolanaKeyButton as
|
|
8
|
-
import { Banner as
|
|
9
|
-
import { CoinbaseFooter as
|
|
1
|
+
import { jsx as o, jsxs as W, Fragment as f } from "react/jsx-runtime";
|
|
2
|
+
import { useCurrentUser as v } from "@coinbase/cdp-hooks";
|
|
3
|
+
import { c as E } from "../../chunks/lite.1fxw3LjI.js";
|
|
4
|
+
import { createContext as C, useMemo as p, useContext as w } from "react";
|
|
5
|
+
import { CopyAddress as b } from "../CopyAddress/index.js";
|
|
6
|
+
import { unstable_CopyEvmKeyButton as h } from "../CopyEvmKeyButton/index.js";
|
|
7
|
+
import { unstable_CopySolanaKeyButton as A } from "../CopySolanaKeyButton/index.js";
|
|
8
|
+
import { Banner as y } from "../ui/Banner/index.js";
|
|
9
|
+
import { CoinbaseFooter as S } from "../ui/CoinbaseFooter/index.js";
|
|
10
10
|
import "../../index.js";
|
|
11
11
|
import { useAppConfig as B } from "../CDPReactProvider/index.js";
|
|
12
|
-
import '../../assets/ExportWallet.css';const
|
|
12
|
+
import '../../assets/ExportWallet.css';const g = "ExportWallet-module__footer___NvrFY", i = {
|
|
13
13
|
"export-wallet": "ExportWallet-module__export-wallet___EyZys",
|
|
14
14
|
"export-wallet-title": "ExportWallet-module__export-wallet-title___MuI09",
|
|
15
|
-
footer:
|
|
16
|
-
},
|
|
15
|
+
footer: g
|
|
16
|
+
}, _ = C({
|
|
17
17
|
address: "",
|
|
18
|
-
type: "evm"
|
|
18
|
+
type: "evm-eoa"
|
|
19
19
|
}), m = () => {
|
|
20
|
-
const t =
|
|
20
|
+
const t = w(_);
|
|
21
21
|
if (!t)
|
|
22
22
|
throw new Error("useExportWalletContext must be used within a ExportWalletProvider");
|
|
23
23
|
return t;
|
|
24
|
-
},
|
|
24
|
+
}, F = ({
|
|
25
25
|
address: t,
|
|
26
|
-
children:
|
|
27
|
-
onIframeError:
|
|
26
|
+
children: e,
|
|
27
|
+
onIframeError: r,
|
|
28
28
|
onIframeReady: n,
|
|
29
29
|
onCopySuccess: l
|
|
30
30
|
}) => {
|
|
31
|
-
const { currentUser: a } =
|
|
32
|
-
() => !!a?.solanaAccounts?.find((
|
|
31
|
+
const { currentUser: a } = v(), s = p(
|
|
32
|
+
() => !!a?.solanaAccounts?.find((u) => u === t),
|
|
33
33
|
[a?.solanaAccounts, t]
|
|
34
|
-
)
|
|
35
|
-
() => (
|
|
36
|
-
[
|
|
34
|
+
), c = p(
|
|
35
|
+
() => !!a?.evmSmartAccounts?.find((u) => u === t),
|
|
36
|
+
[a?.evmSmartAccounts, t]
|
|
37
|
+
), x = s ? "solana" : c ? "evm-smart" : "evm-eoa", d = p(
|
|
38
|
+
() => ({ address: t, type: x, onIframeError: r, onIframeReady: n, onCopySuccess: l }),
|
|
39
|
+
[t, x, r, n, l]
|
|
37
40
|
);
|
|
38
|
-
return /* @__PURE__ */ o(
|
|
39
|
-
},
|
|
41
|
+
return /* @__PURE__ */ o(_.Provider, { value: d, children: e });
|
|
42
|
+
}, K = ({
|
|
40
43
|
children: t,
|
|
41
|
-
className:
|
|
42
|
-
as:
|
|
44
|
+
className: e = "",
|
|
45
|
+
as: r = "h2",
|
|
43
46
|
...n
|
|
44
|
-
}) => /* @__PURE__ */ o(
|
|
47
|
+
}) => /* @__PURE__ */ o(r, { className: E(i["export-wallet-title"], e), ...n, children: t || "Export your wallet" }), N = (t) => {
|
|
48
|
+
const { type: e } = m();
|
|
49
|
+
return e === "evm-smart" ? /* @__PURE__ */ o(y, { variant: "warning", ...t, children: "Cannot export a smart account's private key" }) : /* @__PURE__ */ o(y, { variant: "warning", ...t, children: "Do not share your private key with anyone" });
|
|
50
|
+
}, P = ({
|
|
45
51
|
label: t = "Your wallet address",
|
|
46
|
-
...
|
|
52
|
+
...e
|
|
47
53
|
}) => {
|
|
48
|
-
const { address:
|
|
49
|
-
return /* @__PURE__ */ o(
|
|
50
|
-
},
|
|
54
|
+
const { address: r } = m();
|
|
55
|
+
return /* @__PURE__ */ o(b, { address: r, label: t, ...e });
|
|
56
|
+
}, j = ({
|
|
51
57
|
fullWidth: t = !0,
|
|
52
|
-
...
|
|
58
|
+
...e
|
|
53
59
|
}) => {
|
|
54
|
-
const { address:
|
|
60
|
+
const { address: r, type: n, onIframeError: l, onIframeReady: a, onCopySuccess: s } = m();
|
|
55
61
|
return n === "solana" ? /* @__PURE__ */ o(
|
|
56
|
-
|
|
62
|
+
A,
|
|
57
63
|
{
|
|
58
64
|
fullWidth: t,
|
|
59
|
-
address:
|
|
65
|
+
address: r,
|
|
60
66
|
onError: l,
|
|
61
67
|
onReady: a,
|
|
62
68
|
onSuccess: s,
|
|
63
|
-
...
|
|
69
|
+
...e
|
|
64
70
|
}
|
|
65
|
-
) : n === "evm" ? /* @__PURE__ */ o(
|
|
66
|
-
|
|
71
|
+
) : n === "evm-eoa" ? /* @__PURE__ */ o(
|
|
72
|
+
h,
|
|
67
73
|
{
|
|
68
74
|
fullWidth: t,
|
|
69
|
-
address:
|
|
75
|
+
address: r,
|
|
70
76
|
onError: l,
|
|
71
77
|
onReady: a,
|
|
72
78
|
onSuccess: s,
|
|
73
|
-
...
|
|
79
|
+
...e
|
|
74
80
|
}
|
|
75
81
|
) : null;
|
|
76
|
-
},
|
|
82
|
+
}, k = (t) => /* @__PURE__ */ o(S, { ...t }), G = ({
|
|
77
83
|
address: t,
|
|
78
|
-
children:
|
|
79
|
-
className:
|
|
84
|
+
children: e,
|
|
85
|
+
className: r = "",
|
|
80
86
|
onIframeError: n,
|
|
81
87
|
onIframeReady: l,
|
|
82
88
|
onCopySuccess: a,
|
|
83
89
|
...s
|
|
84
90
|
}) => {
|
|
85
|
-
const { showCoinbaseFooter:
|
|
86
|
-
return /* @__PURE__ */ o("div", { className: i
|
|
87
|
-
|
|
91
|
+
const { showCoinbaseFooter: c } = B();
|
|
92
|
+
return /* @__PURE__ */ o("div", { className: E(i["export-wallet"], r), ...s, children: /* @__PURE__ */ o(
|
|
93
|
+
F,
|
|
88
94
|
{
|
|
89
95
|
address: t,
|
|
90
96
|
onIframeReady: l,
|
|
91
97
|
onCopySuccess: a,
|
|
92
98
|
onIframeError: n,
|
|
93
|
-
children:
|
|
94
|
-
/* @__PURE__ */ o(
|
|
95
|
-
/* @__PURE__ */ o(g, {}),
|
|
99
|
+
children: e || /* @__PURE__ */ W(f, { children: [
|
|
100
|
+
/* @__PURE__ */ o(K, {}),
|
|
96
101
|
/* @__PURE__ */ o(N, {}),
|
|
97
102
|
/* @__PURE__ */ o(P, {}),
|
|
98
|
-
|
|
103
|
+
/* @__PURE__ */ o(j, {}),
|
|
104
|
+
c && /* @__PURE__ */ o(k, { className: i.footer })
|
|
99
105
|
] })
|
|
100
106
|
}
|
|
101
107
|
) });
|
|
102
108
|
};
|
|
103
109
|
export {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
+
G as unstable_ExportWallet,
|
|
111
|
+
P as unstable_ExportWalletCopyAddress,
|
|
112
|
+
j as unstable_ExportWalletCopyKeyButton,
|
|
113
|
+
k as unstable_ExportWalletFooter,
|
|
114
|
+
K as unstable_ExportWalletTitle,
|
|
115
|
+
N as unstable_ExportWalletWarning
|
|
110
116
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
1
|
+
import { jsx as h } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as m, useContext as l, useMemo as i } from "react";
|
|
3
3
|
import { useAppConfig as f } from "../CDPReactProvider/index.js";
|
|
4
4
|
import "@coinbase/cdp-hooks";
|
|
5
5
|
import { useSignInReducer as p } from "./useSignInReducer.js";
|
|
6
|
-
const
|
|
6
|
+
const a = {
|
|
7
7
|
authMethod: "email",
|
|
8
8
|
authMethods: ["email"],
|
|
9
9
|
canResetOTP: !1,
|
|
@@ -15,28 +15,31 @@ const r = {
|
|
|
15
15
|
otp: "",
|
|
16
16
|
phoneNumber: "",
|
|
17
17
|
step: "credentials"
|
|
18
|
-
},
|
|
19
|
-
state:
|
|
18
|
+
}, u = m({
|
|
19
|
+
state: a,
|
|
20
20
|
dispatch: () => {
|
|
21
21
|
}
|
|
22
|
-
}),
|
|
23
|
-
const t =
|
|
22
|
+
}), M = () => {
|
|
23
|
+
const t = l(u);
|
|
24
24
|
if (!t)
|
|
25
25
|
throw new Error("useSignInContext must be used within a SignInProvider");
|
|
26
26
|
return t;
|
|
27
|
-
},
|
|
27
|
+
}, v = ({
|
|
28
28
|
children: t,
|
|
29
|
-
authMethods:
|
|
29
|
+
authMethods: n
|
|
30
30
|
}) => {
|
|
31
|
-
const { authMethods:
|
|
32
|
-
...
|
|
33
|
-
authMethod:
|
|
34
|
-
authMethods:
|
|
35
|
-
}),
|
|
36
|
-
|
|
31
|
+
const { authMethods: o } = f(), e = i(() => n?.filter((d) => o.includes(d)) ?? o, [n, o]), [s, r] = p({
|
|
32
|
+
...a,
|
|
33
|
+
authMethod: e?.[0] || "email",
|
|
34
|
+
authMethods: e
|
|
35
|
+
}), c = i(
|
|
36
|
+
() => ({ state: { ...s, authMethods: e }, dispatch: r }),
|
|
37
|
+
[s, r, e]
|
|
38
|
+
);
|
|
39
|
+
return /* @__PURE__ */ h(u.Provider, { value: c, children: t });
|
|
37
40
|
};
|
|
38
41
|
export {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
u as SignInContext,
|
|
43
|
+
v as SignInProvider,
|
|
44
|
+
M as useSignInContext
|
|
42
45
|
};
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { useReducer as
|
|
1
|
+
import { useReducer as u } from "react";
|
|
2
2
|
import "@coinbase/cdp-hooks";
|
|
3
3
|
import "../CDPReactProvider/index.js";
|
|
4
4
|
function l(e, r) {
|
|
5
5
|
switch (r.type) {
|
|
6
|
+
case "SET_AUTH_METHODS":
|
|
7
|
+
return {
|
|
8
|
+
...e,
|
|
9
|
+
authMethods: r.payload.authMethods
|
|
10
|
+
};
|
|
6
11
|
case "SET_AUTH_METHOD":
|
|
7
12
|
return {
|
|
8
13
|
...e,
|
|
@@ -87,7 +92,7 @@ function l(e, r) {
|
|
|
87
92
|
throw new Error("Unknown action type");
|
|
88
93
|
}
|
|
89
94
|
}
|
|
90
|
-
const s = (e) =>
|
|
95
|
+
const s = (e) => u(l, e);
|
|
91
96
|
export {
|
|
92
97
|
s as useSignInReducer
|
|
93
98
|
};
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { IframeHTMLAttributes, ReactNode } from 'react';
|
|
2
|
-
import { ButtonSize } from '../../../theme/theme';
|
|
2
|
+
import { ButtonSize, ButtonVariant } from '../../../theme/theme';
|
|
3
|
+
import { IframeTheme } from '../../../types/secureIframe';
|
|
3
4
|
interface IframeButtonProps extends IframeHTMLAttributes<HTMLIFrameElement> {
|
|
4
|
-
isPending?: boolean;
|
|
5
|
-
label: ReactNode;
|
|
6
5
|
icon?: boolean;
|
|
6
|
+
isPending?: boolean;
|
|
7
7
|
fullWidth?: boolean;
|
|
8
|
+
label: ReactNode;
|
|
9
|
+
onThemeChange?: (theme: IframeTheme) => void;
|
|
8
10
|
size?: ButtonSize;
|
|
11
|
+
theme?: Partial<IframeTheme>;
|
|
12
|
+
variant?: Extract<ButtonVariant, "primary" | "secondary">;
|
|
9
13
|
}
|
|
10
14
|
export declare const IframeButton: import('react').ForwardRefExoticComponent<IframeButtonProps & import('react').RefAttributes<HTMLIFrameElement>>;
|
|
11
15
|
export {};
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { c as
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
1
|
+
import { jsxs as w, jsx as g } from "react/jsx-runtime";
|
|
2
|
+
import { c as p } from "../../../chunks/lite.1fxw3LjI.js";
|
|
3
|
+
import { forwardRef as y, useRef as x, useMemo as v, useState as T, useEffect as S } from "react";
|
|
4
|
+
import { useTheme as z } from "../../ThemeProvider/index.js";
|
|
5
|
+
import { LoadingSkeleton as $ } from "../LoadingSkeleton/index.js";
|
|
6
|
+
import "../../../theme/theme.js";
|
|
7
|
+
import { colorsBase as u } from "../../../theme/tokens.js";
|
|
8
|
+
import '../../../assets/IframeButton.css';const H = "IframeButton-module__label___Vvl8W", R = "IframeButton-module__iframe___0RBLL", C = "IframeButton-module__hidden___LcF1X", s = {
|
|
6
9
|
"iframe-button": "IframeButton-module__iframe-button___XeAhH",
|
|
7
10
|
"full-width": "IframeButton-module__full-width___lQWpM",
|
|
8
11
|
"size-lg": "IframeButton-module__size-lg___HCOiF",
|
|
@@ -10,41 +13,126 @@ import '../../../assets/IframeButton.css';const c = "IframeButton-module__label_
|
|
|
10
13
|
"size-sm": "IframeButton-module__size-sm___U8ILi",
|
|
11
14
|
"size-xs": "IframeButton-module__size-xs___S2jGa",
|
|
12
15
|
"loading-skeleton": "IframeButton-module__loading-skeleton___fzBol",
|
|
13
|
-
label:
|
|
16
|
+
label: H,
|
|
14
17
|
"with-icon": "IframeButton-module__with-icon___KBiq1",
|
|
15
|
-
iframe:
|
|
16
|
-
hidden:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
)
|
|
18
|
+
iframe: R,
|
|
19
|
+
hidden: C,
|
|
20
|
+
"computed-style": "IframeButton-module__computed-style___ciB13"
|
|
21
|
+
}, L = {
|
|
22
|
+
pageBg: u.white,
|
|
23
|
+
buttonBg: u.blue500,
|
|
24
|
+
buttonBgHover: "#0748d6",
|
|
25
|
+
buttonBgPressed: "#0b3eae",
|
|
26
|
+
buttonBgFocus: u.blue550,
|
|
27
|
+
buttonBorder: u.blue550,
|
|
28
|
+
buttonBorderHover: "#0748d6",
|
|
29
|
+
buttonBorderPressed: "#0b3eae",
|
|
30
|
+
buttonBorderFocus: u.blue550,
|
|
31
|
+
buttonBorderFocusInset: u.white,
|
|
32
|
+
buttonText: u.white,
|
|
33
|
+
buttonTextHover: u.white,
|
|
34
|
+
buttonTextPressed: u.white,
|
|
35
|
+
buttonTextFocus: u.white,
|
|
36
|
+
buttonBorderRadius: 99999,
|
|
37
|
+
buttonFontSize: 16,
|
|
38
|
+
buttonFontWeight: 500,
|
|
39
|
+
buttonSize: "md",
|
|
40
|
+
fontUrl: "",
|
|
41
|
+
fontFamily: ""
|
|
42
|
+
}, W = Object.keys(L), N = (r) => W.every(
|
|
43
|
+
(e) => e === "fontUrl" || e === "buttonSize" ? !0 : r[e] !== void 0
|
|
44
|
+
), c = (r, e, t) => (e.style.backgroundColor = `var(--cdp-web-${r})`, P(getComputedStyle(e).backgroundColor, t)), P = (r, e) => {
|
|
45
|
+
if (!r || typeof r != "string")
|
|
46
|
+
return console.warn("Invalid color input:", r), "";
|
|
47
|
+
const t = r.trim();
|
|
48
|
+
if (t.startsWith("#"))
|
|
49
|
+
return /^#[0-9A-Fa-f]{6}([0-9A-Fa-f]{2})?$/.test(t) ? t.toLowerCase() : (console.warn("Invalid hex color:", t), "");
|
|
50
|
+
if (t === "transparent") return "transparent";
|
|
51
|
+
if (t === "none") return "none";
|
|
52
|
+
const o = e.getContext("2d", { willReadFrequently: !0 });
|
|
53
|
+
if (!o)
|
|
54
|
+
return console.warn("Could not create canvas context"), "";
|
|
55
|
+
if (o.fillStyle = t, o.fillStyle.startsWith("#"))
|
|
56
|
+
return o.fillStyle.toLowerCase();
|
|
57
|
+
o.fillRect(0, 0, 1, 1);
|
|
58
|
+
const d = o.getImageData(0, 0, 1, 1), [l, n, m, a] = d.data, i = l.toString(16).padStart(2, "0"), b = n.toString(16).padStart(2, "0"), f = m.toString(16).padStart(2, "0");
|
|
59
|
+
if (a < 255) {
|
|
60
|
+
const _ = a.toString(16).padStart(2, "0");
|
|
61
|
+
return `#${i}${b}${f}${_}`;
|
|
62
|
+
}
|
|
63
|
+
return `#${i}${b}${f}`;
|
|
64
|
+
}, k = (r, e, t, o) => {
|
|
65
|
+
const d = getComputedStyle(t), l = c("colors-page-bg-default", t, o), n = c(`colors-cta-${e}-bg-default`, t, o), m = c(`colors-cta-${e}-bg-hover`, t, o), a = c(`colors-cta-${e}-bg-pressed`, t, o), i = c(`colors-cta-${e}-text-default`, t, o);
|
|
66
|
+
return {
|
|
67
|
+
pageBg: l,
|
|
68
|
+
buttonBg: n,
|
|
69
|
+
buttonBgHover: m,
|
|
70
|
+
buttonBgPressed: a,
|
|
71
|
+
buttonBgFocus: n,
|
|
72
|
+
buttonBorder: n,
|
|
73
|
+
buttonBorderHover: m,
|
|
74
|
+
buttonBorderPressed: a,
|
|
75
|
+
buttonBorderFocus: c(`colors-cta-${e}-border-focus`, t, o),
|
|
76
|
+
buttonBorderFocusInset: l,
|
|
77
|
+
buttonBorderRadius: parseInt(d.borderRadius),
|
|
78
|
+
buttonFontSize: parseInt(d.fontSize),
|
|
79
|
+
buttonFontWeight: parseInt(d.fontWeight),
|
|
80
|
+
buttonText: i,
|
|
81
|
+
buttonTextHover: c(`colors-cta-${e}-text-hover`, t, o),
|
|
82
|
+
buttonTextPressed: i,
|
|
83
|
+
buttonTextFocus: i,
|
|
84
|
+
buttonSize: (r === "none" ? "md" : r) ?? "md",
|
|
85
|
+
fontFamily: d.fontFamily,
|
|
86
|
+
fontUrl: ""
|
|
87
|
+
};
|
|
88
|
+
}, j = {
|
|
89
|
+
xs: s["size-xs"],
|
|
90
|
+
sm: s["size-sm"],
|
|
91
|
+
md: s["size-md"],
|
|
92
|
+
lg: s["size-lg"]
|
|
93
|
+
}, U = y(
|
|
94
|
+
({ className: r = "", isPending: e, label: t, icon: o, fullWidth: d, size: l, theme: n, onThemeChange: m, ...a }, i) => {
|
|
95
|
+
const { theme: b } = z(), f = x(null), _ = x(null), B = v(() => !!n && N(n), [n]), [h, I] = T(
|
|
96
|
+
B ? n : void 0
|
|
97
|
+
);
|
|
98
|
+
return S(() => {
|
|
99
|
+
if (B || !f.current || !_.current) return;
|
|
100
|
+
const F = k(
|
|
101
|
+
l ?? "md",
|
|
102
|
+
a.variant ?? "primary",
|
|
103
|
+
f.current,
|
|
104
|
+
_.current
|
|
105
|
+
);
|
|
106
|
+
I({ ...F, ...n });
|
|
107
|
+
}, [a.variant, l, B, n, b]), S(() => {
|
|
108
|
+
h && m?.(h);
|
|
109
|
+
}, [h, m]), /* @__PURE__ */ w(
|
|
110
|
+
"div",
|
|
111
|
+
{
|
|
112
|
+
className: p(
|
|
113
|
+
s["iframe-button"],
|
|
114
|
+
o && s["with-icon"],
|
|
115
|
+
d && s["full-width"],
|
|
116
|
+
l && j[l]
|
|
117
|
+
),
|
|
118
|
+
children: [
|
|
119
|
+
/* @__PURE__ */ g("span", { className: s.label, children: t }),
|
|
120
|
+
e && /* @__PURE__ */ g($, { className: p(s["loading-skeleton"]) }),
|
|
121
|
+
/* @__PURE__ */ g(
|
|
122
|
+
"iframe",
|
|
123
|
+
{
|
|
124
|
+
ref: i,
|
|
125
|
+
className: p(s.iframe, e ? s.hidden : void 0, r),
|
|
126
|
+
...a
|
|
127
|
+
}
|
|
128
|
+
),
|
|
129
|
+
!B && /* @__PURE__ */ g("div", { ref: f, className: s["computed-style"], children: /* @__PURE__ */ g("canvas", { ref: _ }) })
|
|
130
|
+
]
|
|
131
|
+
}
|
|
132
|
+
);
|
|
133
|
+
}
|
|
46
134
|
);
|
|
47
|
-
|
|
135
|
+
U.displayName = "IframeButton";
|
|
48
136
|
export {
|
|
49
|
-
|
|
137
|
+
U as IframeButton
|
|
50
138
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { RefObject } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { SecureIframeStatus, SecureIframeEventType, SecureIframeIncomingMessage, SecureIframeOutgoingMessage, SecureIframeInitMessage } from '../types/secureIframe';
|
|
2
|
+
import { SecureIframeStatus, SecureIframeEventType, SecureIframeIncomingMessage, SecureIframeOutgoingMessage, SecureIframeInitMessage, IframeTheme } from '../types/secureIframe';
|
|
4
3
|
export declare const SECURE_IFRAME_KEY_EXPORT_EVENT_TYPE: Readonly<{
|
|
5
4
|
GET_PRIVATE_KEY: "CDP_WEB_SECURE_IFRAME_GET_PRIVATE_KEY";
|
|
6
5
|
INIT: "CDP_WEB_SECURE_IFRAME_INIT";
|
|
7
6
|
LISTENING: "CDP_WEB_SECURE_IFRAME_LISTENING";
|
|
8
7
|
STATUS: "CDP_WEB_SECURE_IFRAME_STATUS";
|
|
8
|
+
THEME: "CDP_WEB_SECURE_IFRAME_THEME";
|
|
9
9
|
}>;
|
|
10
10
|
export type SecureIframeKeyExportEventType = SecureIframeEventType & typeof SECURE_IFRAME_KEY_EXPORT_EVENT_TYPE;
|
|
11
11
|
export type SecureIframeGetPrivateKeyMessage = {
|
|
@@ -19,7 +19,7 @@ export type SecureIframeGetPrivateKeyMessage = {
|
|
|
19
19
|
};
|
|
20
20
|
export type SecureIframeKeyExportIncomingMessage = SecureIframeIncomingMessage | SecureIframeGetPrivateKeyMessage;
|
|
21
21
|
export type SecureIframeKeyExportOutgoingMessage = SecureIframeOutgoingMessage;
|
|
22
|
-
export interface UseKeyExportPostMessageProps
|
|
22
|
+
export interface UseKeyExportPostMessageProps {
|
|
23
23
|
address: string;
|
|
24
24
|
type: "evm" | "solana";
|
|
25
25
|
basePath?: string;
|
|
@@ -29,10 +29,12 @@ export interface UseKeyExportPostMessageProps extends Pick<ButtonProps, "variant
|
|
|
29
29
|
icon: boolean;
|
|
30
30
|
iframeRef: RefObject<HTMLIFrameElement | null>;
|
|
31
31
|
onStatusUpdate?: (status: SecureIframeStatus, message?: string) => void;
|
|
32
|
+
theme?: IframeTheme;
|
|
32
33
|
}
|
|
33
34
|
export declare const sendKeyExportMessage: (el: HTMLIFrameElement | null, message: SecureIframeKeyExportIncomingMessage) => void;
|
|
34
35
|
export declare const isKeyExportMessage: (message: unknown) => message is SecureIframeKeyExportIncomingMessage | SecureIframeKeyExportOutgoingMessage;
|
|
35
|
-
export declare const useKeyExportPostMessage: ({ address, basePath, copiedLabel, icon, iframeRef, label, onStatusUpdate, projectId,
|
|
36
|
+
export declare const useKeyExportPostMessage: ({ address, basePath, copiedLabel, icon, iframeRef, label, onStatusUpdate, projectId, theme, type, }: UseKeyExportPostMessageProps) => {
|
|
36
37
|
iframeUrl: string;
|
|
37
38
|
isPending: boolean;
|
|
39
|
+
onThemeChange: (newTheme: Partial<IframeTheme>) => void;
|
|
38
40
|
};
|
|
@@ -1,83 +1,90 @@
|
|
|
1
|
-
import { getAccessToken as
|
|
2
|
-
import { useCurrentUser as
|
|
3
|
-
import { useState as
|
|
4
|
-
import {
|
|
5
|
-
import "../components/ui/Button/index.js";
|
|
6
|
-
import { SECURE_IFRAME_EVENT_TYPE_PREFIX as h, SECURE_IFRAME_EVENT_TYPE as C } from "../types/secureIframe.js";
|
|
1
|
+
import { getAccessToken as R, getAccessTokenExpiration as w } from "@coinbase/cdp-core";
|
|
2
|
+
import { useCurrentUser as S } from "@coinbase/cdp-hooks";
|
|
3
|
+
import { useState as k, useMemo as C, useCallback as u, useEffect as K } from "react";
|
|
4
|
+
import { SECURE_IFRAME_EVENT_TYPE_PREFIX as f, SECURE_IFRAME_EVENT_TYPE as x } from "../types/secureIframe.js";
|
|
7
5
|
import "libphonenumber-js";
|
|
8
|
-
import { sendIframeMessage as
|
|
9
|
-
const
|
|
10
|
-
...
|
|
11
|
-
GET_PRIVATE_KEY: `${
|
|
12
|
-
}),
|
|
13
|
-
|
|
14
|
-
},
|
|
15
|
-
|
|
6
|
+
import { sendIframeMessage as A } from "../utils/sendIframeMessage.js";
|
|
7
|
+
const g = "https://secure-wallet.cdp.coinbase.com", n = Object.freeze({
|
|
8
|
+
...x,
|
|
9
|
+
GET_PRIVATE_KEY: `${f}GET_PRIVATE_KEY`
|
|
10
|
+
}), Y = (t, s) => {
|
|
11
|
+
A(t, s);
|
|
12
|
+
}, V = (t) => typeof t == "object" && t !== null && "type" in t && typeof t.type == "string" && !!n[t.type.replace(
|
|
13
|
+
f,
|
|
16
14
|
""
|
|
17
|
-
)],
|
|
15
|
+
)], H = ({
|
|
18
16
|
address: t,
|
|
19
|
-
basePath: s =
|
|
20
|
-
copiedLabel:
|
|
17
|
+
basePath: s = g,
|
|
18
|
+
copiedLabel: c,
|
|
21
19
|
icon: T,
|
|
22
|
-
iframeRef:
|
|
23
|
-
label:
|
|
24
|
-
onStatusUpdate:
|
|
20
|
+
iframeRef: o,
|
|
21
|
+
label: i,
|
|
22
|
+
onStatusUpdate: _,
|
|
25
23
|
projectId: E,
|
|
26
|
-
|
|
27
|
-
type:
|
|
28
|
-
variant: p
|
|
24
|
+
theme: m,
|
|
25
|
+
type: d
|
|
29
26
|
}) => {
|
|
30
|
-
const { currentUser:
|
|
27
|
+
const { currentUser: a } = S(), [I, U] = k(!0), h = C(() => {
|
|
31
28
|
const e = ["fullWidth"];
|
|
32
|
-
return E && e.push(`projectId=${E.trim()}`),
|
|
33
|
-
}, [E,
|
|
34
|
-
if (!
|
|
35
|
-
const e = await
|
|
36
|
-
|
|
37
|
-
type:
|
|
29
|
+
return E && e.push(`projectId=${E.trim()}`), i && e.push(`label=${encodeURIComponent(i.trim())}`), c && e.push(`copiedLabel=${encodeURIComponent(c.trim())}`), T && e.push("icon"), `${s}?${e.join("&")}`;
|
|
30
|
+
}, [E, i, c, T, s]), y = u(async () => {
|
|
31
|
+
if (!a || !o.current) return;
|
|
32
|
+
const e = await R(), r = await w();
|
|
33
|
+
Y(o.current, {
|
|
34
|
+
type: n.GET_PRIVATE_KEY,
|
|
38
35
|
payload: {
|
|
39
36
|
address: t,
|
|
40
|
-
type:
|
|
37
|
+
type: d,
|
|
41
38
|
authState: {
|
|
42
39
|
accessToken: e || "",
|
|
43
40
|
expiresAt: r || 0,
|
|
44
|
-
user:
|
|
41
|
+
user: a
|
|
45
42
|
},
|
|
46
|
-
theme:
|
|
43
|
+
theme: m
|
|
47
44
|
}
|
|
48
45
|
});
|
|
49
|
-
}, [
|
|
46
|
+
}, [a, t, d, m, o]), l = u(
|
|
50
47
|
(e, r) => {
|
|
51
|
-
|
|
48
|
+
_?.(e, r), U(!1);
|
|
52
49
|
},
|
|
53
|
-
[
|
|
50
|
+
[_]
|
|
51
|
+
), M = u(
|
|
52
|
+
(e) => {
|
|
53
|
+
A(o.current, {
|
|
54
|
+
type: n.THEME,
|
|
55
|
+
payload: {
|
|
56
|
+
theme: e
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
[o]
|
|
54
61
|
);
|
|
55
|
-
return
|
|
62
|
+
return K(() => {
|
|
56
63
|
const e = (r) => {
|
|
57
|
-
let
|
|
64
|
+
let p = "";
|
|
58
65
|
try {
|
|
59
|
-
|
|
66
|
+
p = new URL(s || g).origin;
|
|
60
67
|
} catch (P) {
|
|
61
68
|
console.error("Error parsing iframe origin", P);
|
|
62
69
|
}
|
|
63
|
-
if (!(!
|
|
70
|
+
if (!(!p || r.origin !== p) && V(r.data))
|
|
64
71
|
switch (r.data?.type) {
|
|
65
|
-
case
|
|
72
|
+
case n.LISTENING:
|
|
66
73
|
y();
|
|
67
74
|
break;
|
|
68
|
-
case
|
|
69
|
-
|
|
75
|
+
case n.STATUS:
|
|
76
|
+
l(r.data.payload.status, r.data.payload.message);
|
|
70
77
|
break;
|
|
71
78
|
}
|
|
72
79
|
};
|
|
73
80
|
return window.addEventListener("message", e), () => {
|
|
74
81
|
window.removeEventListener("message", e);
|
|
75
82
|
};
|
|
76
|
-
}, [y,
|
|
83
|
+
}, [y, l, s]), { iframeUrl: h, isPending: I, onThemeChange: M };
|
|
77
84
|
};
|
|
78
85
|
export {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
86
|
+
n as SECURE_IFRAME_KEY_EXPORT_EVENT_TYPE,
|
|
87
|
+
V as isKeyExportMessage,
|
|
88
|
+
Y as sendKeyExportMessage,
|
|
89
|
+
H as useKeyExportPostMessage
|
|
83
90
|
};
|
|
@@ -1,21 +1,49 @@
|
|
|
1
1
|
import { AuthManager } from '@coinbase/cdp-core';
|
|
2
|
-
|
|
2
|
+
export type IframeTheme = {
|
|
3
|
+
pageBg: string;
|
|
4
|
+
buttonBg: string;
|
|
5
|
+
buttonBgHover: string;
|
|
6
|
+
buttonBgPressed: string;
|
|
7
|
+
buttonBgFocus: string;
|
|
8
|
+
buttonBorder: string;
|
|
9
|
+
buttonBorderHover: string;
|
|
10
|
+
buttonBorderPressed: string;
|
|
11
|
+
buttonBorderFocus: string;
|
|
12
|
+
buttonBorderFocusInset: string;
|
|
13
|
+
buttonText: string;
|
|
14
|
+
buttonTextHover: string;
|
|
15
|
+
buttonTextPressed: string;
|
|
16
|
+
buttonTextFocus: string;
|
|
17
|
+
buttonBorderRadius: number;
|
|
18
|
+
buttonFontSize: number;
|
|
19
|
+
buttonFontWeight: number;
|
|
20
|
+
buttonSize: "xs" | "sm" | "md" | "lg";
|
|
21
|
+
fontUrl: string;
|
|
22
|
+
fontFamily: string;
|
|
23
|
+
};
|
|
3
24
|
export type SecureIframeAuthState = Parameters<AuthManager["setAuthState"]>[0];
|
|
4
25
|
export declare const SECURE_IFRAME_EVENT_TYPE_PREFIX = "CDP_WEB_SECURE_IFRAME_";
|
|
5
26
|
export declare const SECURE_IFRAME_EVENT_TYPE: {
|
|
6
27
|
readonly INIT: "CDP_WEB_SECURE_IFRAME_INIT";
|
|
7
28
|
readonly LISTENING: "CDP_WEB_SECURE_IFRAME_LISTENING";
|
|
8
29
|
readonly STATUS: "CDP_WEB_SECURE_IFRAME_STATUS";
|
|
30
|
+
readonly THEME: "CDP_WEB_SECURE_IFRAME_THEME";
|
|
9
31
|
};
|
|
10
32
|
export type SecureIframeEventType = typeof SECURE_IFRAME_EVENT_TYPE;
|
|
11
33
|
export type SecureIframeInitMessage = {
|
|
12
34
|
type: SecureIframeEventType["INIT"];
|
|
13
35
|
payload: {
|
|
14
36
|
authState: SecureIframeAuthState;
|
|
15
|
-
theme
|
|
37
|
+
theme?: IframeTheme;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export type SecureIframeThemeMessage = {
|
|
41
|
+
type: SecureIframeEventType["THEME"];
|
|
42
|
+
payload: {
|
|
43
|
+
theme: Partial<IframeTheme>;
|
|
16
44
|
};
|
|
17
45
|
};
|
|
18
|
-
export type SecureIframeIncomingMessage = SecureIframeInitMessage;
|
|
46
|
+
export type SecureIframeIncomingMessage = SecureIframeInitMessage | SecureIframeThemeMessage;
|
|
19
47
|
export type SecureIframeListeningMessage = {
|
|
20
48
|
type: SecureIframeEventType["LISTENING"];
|
|
21
49
|
};
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import "@coinbase/cdp-core";
|
|
2
|
-
|
|
3
|
-
import "../theme/theme.js";
|
|
4
|
-
import "../theme/tokens.js";
|
|
5
|
-
const E = "CDP_WEB_SECURE_IFRAME_", N = {
|
|
2
|
+
const E = "CDP_WEB_SECURE_IFRAME_", I = {
|
|
6
3
|
INIT: `${E}INIT`,
|
|
7
4
|
LISTENING: `${E}LISTENING`,
|
|
8
|
-
STATUS: `${E}STATUS
|
|
5
|
+
STATUS: `${E}STATUS`,
|
|
6
|
+
THEME: `${E}THEME`
|
|
9
7
|
};
|
|
10
8
|
export {
|
|
11
|
-
|
|
9
|
+
I as SECURE_IFRAME_EVENT_TYPE,
|
|
12
10
|
E as SECURE_IFRAME_EVENT_TYPE_PREFIX
|
|
13
11
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coinbase/cdp-react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.63",
|
|
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-core": "^0.0.
|
|
19
|
-
"@coinbase/cdp-hooks": "^0.0.
|
|
18
|
+
"@coinbase/cdp-core": "^0.0.63",
|
|
19
|
+
"@coinbase/cdp-hooks": "^0.0.63"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@size-limit/preset-big-lib": "^11.2.0",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"vite": "^7.0.4",
|
|
47
47
|
"vite-plugin-dts": "^4.5.4",
|
|
48
48
|
"vite-plugin-lib-inject-css": "^2.2.2",
|
|
49
|
-
"@coinbase/cdp-core": "^0.0.
|
|
50
|
-
"@coinbase/cdp-hooks": "^0.0.
|
|
49
|
+
"@coinbase/cdp-core": "^0.0.63",
|
|
50
|
+
"@coinbase/cdp-hooks": "^0.0.63"
|
|
51
51
|
},
|
|
52
52
|
"size-limit": [
|
|
53
53
|
{
|