@coinbase/cdp-react 0.0.73 → 0.0.74
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/components/CopyEvmKeyButton/index.js +1 -1
- package/dist/components/CopySolanaKeyButton/index.js +1 -1
- package/dist/components/ExportWallet/index.js +1 -1
- package/dist/hooks/useKeyExportPostMessage.d.ts +1 -2
- package/dist/hooks/useKeyExportPostMessage.js +60 -62
- package/dist/index.js +1 -1
- package/dist/types/secureIframe.d.ts +4 -77
- package/dist/types/secureIframe.js +3 -13
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +5 -5
|
@@ -5,7 +5,7 @@ import { useRef as j, useState as i, useCallback as E } from "react";
|
|
|
5
5
|
import "../ui/Button/index.js";
|
|
6
6
|
import { IframeButton as K } from "../ui/IframeButton/index.js";
|
|
7
7
|
import { useKeyExportPostMessage as T } from "../../hooks/useKeyExportPostMessage.js";
|
|
8
|
-
import "
|
|
8
|
+
import "@coinbase/cdp-core";
|
|
9
9
|
const F = ({
|
|
10
10
|
address: p,
|
|
11
11
|
className: n = "",
|
|
@@ -5,7 +5,7 @@ import { useRef as K, useState as i, useCallback as T } from "react";
|
|
|
5
5
|
import "../ui/Button/index.js";
|
|
6
6
|
import { IframeButton as U } from "../ui/IframeButton/index.js";
|
|
7
7
|
import { useKeyExportPostMessage as v } from "../../hooks/useKeyExportPostMessage.js";
|
|
8
|
-
import "
|
|
8
|
+
import "@coinbase/cdp-core";
|
|
9
9
|
const F = ({
|
|
10
10
|
address: m,
|
|
11
11
|
className: p = "",
|
|
@@ -51,7 +51,7 @@ import "../../utils/isApiError.js";
|
|
|
51
51
|
import "../../utils/isEmailInvalid.js";
|
|
52
52
|
import "../../utils/parseValuesFromPhoneNumber.js";
|
|
53
53
|
import "../../utils/sendIframeMessage.js";
|
|
54
|
-
import "
|
|
54
|
+
import "@coinbase/cdp-core";
|
|
55
55
|
import "../Fund/FundForm.js";
|
|
56
56
|
import "../Fund/FundTitle.js";
|
|
57
57
|
import "../Fund/FundProvider.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RefObject } from 'react';
|
|
2
|
-
import { SecureIframeChainType, SecureIframeKeyExportIncomingMessage,
|
|
2
|
+
import { SecureIframeChainType, SecureIframeKeyExportIncomingMessage, SecureIframeStatus, IframeTheme } from '../types/secureIframe';
|
|
3
3
|
export interface UseKeyExportPostMessageProps {
|
|
4
4
|
address: string;
|
|
5
5
|
type: SecureIframeChainType;
|
|
@@ -13,7 +13,6 @@ export interface UseKeyExportPostMessageProps {
|
|
|
13
13
|
theme?: IframeTheme;
|
|
14
14
|
}
|
|
15
15
|
export declare const sendKeyExportMessage: (el: HTMLIFrameElement | null, message: SecureIframeKeyExportIncomingMessage) => void;
|
|
16
|
-
export declare const isKeyExportMessage: (message: unknown) => message is SecureIframeKeyExportIncomingMessage | SecureIframeKeyExportOutgoingMessage;
|
|
17
16
|
export declare const useKeyExportPostMessage: ({ address, basePath, copiedLabel, icon, iframeRef, label, onStatusUpdate, projectId, theme, type, }: UseKeyExportPostMessageProps) => {
|
|
18
17
|
iframeUrl: string;
|
|
19
18
|
isPending: boolean;
|
|
@@ -1,84 +1,82 @@
|
|
|
1
|
-
import { getAccessToken as P, getAccessTokenExpiration as C } from "@coinbase/cdp-core";
|
|
2
|
-
import { useCurrentUser as
|
|
3
|
-
import { useState as
|
|
4
|
-
import { SECURE_IFRAME_KEY_EXPORT_EVENT_TYPE as a, SECURE_IFRAME_EVENT_TYPE_PREFIX as F } from "../types/secureIframe.js";
|
|
1
|
+
import { buildKeyExportIframeUrl as K, getAccessToken as P, getAccessTokenExpiration as L, SECURE_IFRAME_KEY_EXPORT_EVENT_TYPE as n, isSecureIframeKeyExportMessage as C } from "@coinbase/cdp-core";
|
|
2
|
+
import { useCurrentUser as N } from "@coinbase/cdp-hooks";
|
|
3
|
+
import { useState as w, useRef as Y, useMemo as F, useCallback as A, useEffect as _ } from "react";
|
|
5
4
|
import "libphonenumber-js";
|
|
6
|
-
import { sendIframeMessage as
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
},
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
projectId: u,
|
|
21
|
-
theme: n,
|
|
22
|
-
type: l
|
|
5
|
+
import { sendIframeMessage as x } from "../utils/sendIframeMessage.js";
|
|
6
|
+
const k = "https://secure-wallet.cdp.coinbase.com", G = (o, s) => {
|
|
7
|
+
x(o, s);
|
|
8
|
+
}, O = ({
|
|
9
|
+
address: o,
|
|
10
|
+
basePath: s = k,
|
|
11
|
+
copiedLabel: E,
|
|
12
|
+
icon: d,
|
|
13
|
+
iframeRef: t,
|
|
14
|
+
label: p,
|
|
15
|
+
onStatusUpdate: g,
|
|
16
|
+
projectId: y,
|
|
17
|
+
theme: a,
|
|
18
|
+
type: T
|
|
23
19
|
}) => {
|
|
24
|
-
const { currentUser:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
const { currentUser: c } = N(), [I, M] = w(!0), [i, R] = w(!1), l = Y(!1), S = F(() => K({
|
|
21
|
+
projectId: y,
|
|
22
|
+
label: p,
|
|
23
|
+
copiedLabel: E,
|
|
24
|
+
icon: d,
|
|
25
|
+
basePath: s
|
|
26
|
+
}), [y, p, E, d, s]), f = A(async () => {
|
|
27
|
+
if (!c || !t.current) return;
|
|
28
|
+
const r = await P({ forceRefresh: !0 }), e = await L();
|
|
29
|
+
G(t.current, {
|
|
30
|
+
type: n.GET_PRIVATE_KEY,
|
|
32
31
|
payload: {
|
|
33
|
-
address:
|
|
34
|
-
type:
|
|
32
|
+
address: o,
|
|
33
|
+
type: T,
|
|
35
34
|
authState: {
|
|
36
|
-
accessToken:
|
|
37
|
-
expiresAt:
|
|
38
|
-
user:
|
|
35
|
+
accessToken: r || "",
|
|
36
|
+
expiresAt: e || 0,
|
|
37
|
+
user: c
|
|
39
38
|
},
|
|
40
|
-
theme:
|
|
39
|
+
theme: a
|
|
41
40
|
}
|
|
42
41
|
});
|
|
43
|
-
}, [
|
|
44
|
-
(
|
|
45
|
-
|
|
42
|
+
}, [c, o, T, a, t]), m = A(
|
|
43
|
+
(r, e) => {
|
|
44
|
+
g?.(r, e), M(!1);
|
|
46
45
|
},
|
|
47
|
-
[
|
|
46
|
+
[g]
|
|
48
47
|
);
|
|
49
|
-
return
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
type:
|
|
48
|
+
return _(() => {
|
|
49
|
+
const r = l.current;
|
|
50
|
+
l.current = i, r && i && a && x(t.current, {
|
|
51
|
+
type: n.THEME,
|
|
53
52
|
payload: {
|
|
54
|
-
theme:
|
|
53
|
+
theme: a
|
|
55
54
|
}
|
|
56
55
|
});
|
|
57
|
-
}, [
|
|
58
|
-
const
|
|
59
|
-
let
|
|
56
|
+
}, [a, i, t]), _(() => {
|
|
57
|
+
const r = (e) => {
|
|
58
|
+
let u = "";
|
|
60
59
|
try {
|
|
61
|
-
|
|
62
|
-
} catch (
|
|
63
|
-
console.error("Error parsing iframe origin",
|
|
60
|
+
u = new URL(s || k).origin;
|
|
61
|
+
} catch (U) {
|
|
62
|
+
console.error("Error parsing iframe origin", U);
|
|
64
63
|
}
|
|
65
|
-
if (!(!
|
|
66
|
-
switch (
|
|
67
|
-
case
|
|
68
|
-
|
|
64
|
+
if (!(!u || e.origin !== u) && C(e.data))
|
|
65
|
+
switch (e.data?.type) {
|
|
66
|
+
case n.LISTENING:
|
|
67
|
+
R(!0), f();
|
|
69
68
|
break;
|
|
70
|
-
case
|
|
71
|
-
m(
|
|
69
|
+
case n.STATUS:
|
|
70
|
+
m(e.data.payload.status, e.data.payload.message);
|
|
72
71
|
break;
|
|
73
72
|
}
|
|
74
73
|
};
|
|
75
|
-
return window.addEventListener("message",
|
|
76
|
-
window.removeEventListener("message",
|
|
74
|
+
return window.addEventListener("message", r), () => {
|
|
75
|
+
window.removeEventListener("message", r);
|
|
77
76
|
};
|
|
78
|
-
}, [
|
|
77
|
+
}, [f, m, s]), { iframeUrl: S, isPending: I };
|
|
79
78
|
};
|
|
80
79
|
export {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
q as useKeyExportPostMessage
|
|
80
|
+
G as sendKeyExportMessage,
|
|
81
|
+
O as useKeyExportPostMessage
|
|
84
82
|
};
|
package/dist/index.js
CHANGED
|
@@ -46,7 +46,7 @@ import { isApiError as hr } from "./utils/isApiError.js";
|
|
|
46
46
|
import { isEmailInvalid as Sr } from "./utils/isEmailInvalid.js";
|
|
47
47
|
import { parseValuesFromPhoneNumber as kr } from "./utils/parseValuesFromPhoneNumber.js";
|
|
48
48
|
import { sendIframeMessage as Lr } from "./utils/sendIframeMessage.js";
|
|
49
|
-
import "
|
|
49
|
+
import "@coinbase/cdp-core";
|
|
50
50
|
import { FundForm as Wr } from "./components/Fund/FundForm.js";
|
|
51
51
|
import { FundTitle as br } from "./components/Fund/FundTitle.js";
|
|
52
52
|
import { useFundContext as wr } from "./components/Fund/FundProvider.js";
|
|
@@ -1,77 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export type IframeTheme =
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
};
|
|
24
|
-
export type SecureIframeAuthState = Parameters<AuthManager["setAuthState"]>[0];
|
|
25
|
-
export type SecureIframeChainType = "evm" | "solana";
|
|
26
|
-
export type SecureIframeContext = {
|
|
27
|
-
authState: SecureIframeAuthState;
|
|
28
|
-
theme?: IframeTheme;
|
|
29
|
-
};
|
|
30
|
-
export declare const SECURE_IFRAME_EVENT_TYPE_PREFIX = "CDP_WEB_SECURE_IFRAME_";
|
|
31
|
-
export declare const SECURE_IFRAME_EVENT_TYPE: {
|
|
32
|
-
readonly INIT: "CDP_WEB_SECURE_IFRAME_INIT";
|
|
33
|
-
readonly LISTENING: "CDP_WEB_SECURE_IFRAME_LISTENING";
|
|
34
|
-
readonly STATUS: "CDP_WEB_SECURE_IFRAME_STATUS";
|
|
35
|
-
readonly THEME: "CDP_WEB_SECURE_IFRAME_THEME";
|
|
36
|
-
};
|
|
37
|
-
export type SecureIframeEventType = typeof SECURE_IFRAME_EVENT_TYPE;
|
|
38
|
-
export type SecureIframeInitMessage = {
|
|
39
|
-
type: SecureIframeEventType["INIT"];
|
|
40
|
-
payload: SecureIframeContext;
|
|
41
|
-
};
|
|
42
|
-
export type SecureIframeThemeMessage = {
|
|
43
|
-
type: SecureIframeEventType["THEME"];
|
|
44
|
-
payload: {
|
|
45
|
-
theme: Partial<IframeTheme>;
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
export type SecureIframeIncomingMessage = SecureIframeInitMessage | SecureIframeThemeMessage;
|
|
49
|
-
export type SecureIframeListeningMessage = {
|
|
50
|
-
type: SecureIframeEventType["LISTENING"];
|
|
51
|
-
};
|
|
52
|
-
export type SecureIframeStatus = "ready" | "success" | "error" | "expiring" | "expired";
|
|
53
|
-
export type SecureIframeStatusMessage = {
|
|
54
|
-
type: SecureIframeEventType["STATUS"];
|
|
55
|
-
payload: {
|
|
56
|
-
status: SecureIframeStatus;
|
|
57
|
-
message?: string;
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
export type SecureIframeOutgoingMessage = SecureIframeListeningMessage | SecureIframeStatusMessage;
|
|
61
|
-
export declare const SECURE_IFRAME_KEY_EXPORT_EVENT_TYPE: {
|
|
62
|
-
readonly GET_PRIVATE_KEY: "CDP_WEB_SECURE_IFRAME_GET_PRIVATE_KEY";
|
|
63
|
-
readonly INIT: "CDP_WEB_SECURE_IFRAME_INIT";
|
|
64
|
-
readonly LISTENING: "CDP_WEB_SECURE_IFRAME_LISTENING";
|
|
65
|
-
readonly STATUS: "CDP_WEB_SECURE_IFRAME_STATUS";
|
|
66
|
-
readonly THEME: "CDP_WEB_SECURE_IFRAME_THEME";
|
|
67
|
-
};
|
|
68
|
-
export type SecureIframeKeyExportEventType = typeof SECURE_IFRAME_KEY_EXPORT_EVENT_TYPE;
|
|
69
|
-
export type SecureIframeGetPrivateKeyMessage = {
|
|
70
|
-
type: SecureIframeKeyExportEventType["GET_PRIVATE_KEY"];
|
|
71
|
-
payload: SecureIframeContext & {
|
|
72
|
-
address: string;
|
|
73
|
-
type: SecureIframeChainType;
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
export type SecureIframeKeyExportIncomingMessage = SecureIframeIncomingMessage | SecureIframeGetPrivateKeyMessage;
|
|
77
|
-
export type SecureIframeKeyExportOutgoingMessage = SecureIframeOutgoingMessage;
|
|
1
|
+
import { SECURE_IFRAME_EVENT_TYPE_PREFIX, SECURE_IFRAME_KEY_EXPORT_EVENT_TYPE, SecureIframeTheme, SecureIframeAuthState, SecureIframeChainType, SecureIframeContext, SecureIframeStatus, SecureIframeEventType, SecureIframeInitMessage, SecureIframeThemeMessage, SecureIframeIncomingMessage, SecureIframeListeningMessage, SecureIframeStatusMessage, SecureIframeOutgoingMessage, SecureIframeKeyExportEventType, SecureIframeGetPrivateKeyMessage, SecureIframeKeyExportIncomingMessage, SecureIframeKeyExportOutgoingMessage } from '@coinbase/cdp-core';
|
|
2
|
+
export type IframeTheme = SecureIframeTheme;
|
|
3
|
+
export { SECURE_IFRAME_EVENT_TYPE_PREFIX, SECURE_IFRAME_KEY_EXPORT_EVENT_TYPE };
|
|
4
|
+
export type { SecureIframeAuthState, SecureIframeChainType, SecureIframeContext, SecureIframeStatus, SecureIframeEventType, SecureIframeInitMessage, SecureIframeThemeMessage, SecureIframeIncomingMessage, SecureIframeListeningMessage, SecureIframeStatusMessage, SecureIframeOutgoingMessage, SecureIframeKeyExportEventType, SecureIframeGetPrivateKeyMessage, SecureIframeKeyExportIncomingMessage, SecureIframeKeyExportOutgoingMessage, };
|
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
import "@coinbase/cdp-core";
|
|
2
|
-
const E = "CDP_WEB_SECURE_IFRAME_", T = {
|
|
3
|
-
INIT: `${E}INIT`,
|
|
4
|
-
LISTENING: `${E}LISTENING`,
|
|
5
|
-
STATUS: `${E}STATUS`,
|
|
6
|
-
THEME: `${E}THEME`
|
|
7
|
-
}, I = {
|
|
8
|
-
...T,
|
|
9
|
-
GET_PRIVATE_KEY: `${E}GET_PRIVATE_KEY`
|
|
10
|
-
};
|
|
1
|
+
import { SECURE_IFRAME_EVENT_TYPE_PREFIX as R, SECURE_IFRAME_KEY_EXPORT_EVENT_TYPE as T } from "@coinbase/cdp-core";
|
|
11
2
|
export {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
I as SECURE_IFRAME_KEY_EXPORT_EVENT_TYPE
|
|
3
|
+
R as SECURE_IFRAME_EVENT_TYPE_PREFIX,
|
|
4
|
+
T as SECURE_IFRAME_KEY_EXPORT_EVENT_TYPE
|
|
15
5
|
};
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.0.
|
|
1
|
+
export declare const VERSION = "0.0.74";
|
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.74",
|
|
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.74",
|
|
19
|
+
"@coinbase/cdp-hooks": "^0.0.74"
|
|
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.74",
|
|
51
|
+
"@coinbase/cdp-hooks": "^0.0.74"
|
|
52
52
|
},
|
|
53
53
|
"size-limit": [
|
|
54
54
|
{
|