@coinbase/cdp-react 0.0.54 → 0.0.56

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.
Files changed (41) hide show
  1. package/dist/assets/ManageAuth.css +1 -0
  2. package/dist/assets/ManageAuthItem.css +1 -0
  3. package/dist/assets/ManageAuthModal.css +1 -0
  4. package/dist/chunks/useSendComponentCallOnce.BHZMuo6E.js +273 -0
  5. package/dist/components/AuthButton/index.js +1 -1
  6. package/dist/components/Fund/index.js +1 -1
  7. package/dist/components/FundModal/index.js +1 -1
  8. package/dist/components/ManageAuth/ManageAuthItem.d.ts +9 -0
  9. package/dist/components/ManageAuth/ManageAuthItem.js +77 -0
  10. package/dist/components/ManageAuth/ManageAuthProvider.d.ts +8 -0
  11. package/dist/components/ManageAuth/ManageAuthProvider.js +64 -0
  12. package/dist/components/ManageAuth/index.d.ts +9 -0
  13. package/dist/components/ManageAuth/index.js +51 -0
  14. package/dist/components/ManageAuth/types.d.ts +13 -0
  15. package/dist/components/ManageAuth/types.js +1 -0
  16. package/dist/components/ManageAuthModal/index.d.ts +20 -0
  17. package/dist/components/ManageAuthModal/index.js +53 -0
  18. package/dist/components/OAuthStatusModal/index.js +53 -51
  19. package/dist/components/SendEvmTransactionButton/index.js +1 -1
  20. package/dist/components/SendSolanaTransactionButton/index.js +1 -1
  21. package/dist/components/SignIn/SignInAuthMethodButtons.js +20 -15
  22. package/dist/components/SignIn/index.js +1 -1
  23. package/dist/components/SignInModal/index.js +1 -1
  24. package/dist/components/SignOutButton/index.js +1 -1
  25. package/dist/icons/IconMinus.d.ts +2 -0
  26. package/dist/icons/IconMinus.js +7 -0
  27. package/dist/icons/IconPlus.d.ts +2 -0
  28. package/dist/icons/IconPlus.js +7 -0
  29. package/dist/icons/IconXLogo.d.ts +2 -0
  30. package/dist/icons/IconXLogo.js +13 -0
  31. package/dist/icons/index.d.ts +4 -0
  32. package/dist/icons/index.js +28 -20
  33. package/dist/index.d.ts +2 -0
  34. package/dist/index.js +136 -115
  35. package/dist/theme/theme.d.ts +10 -0
  36. package/dist/theme/tokens.d.ts +30 -0
  37. package/dist/theme/tokens.js +7 -1
  38. package/dist/version.d.ts +1 -0
  39. package/dist/version.js +4 -0
  40. package/package.json +5 -5
  41. package/dist/chunks/useSendComponentCallOnce.CUgcsUye.js +0 -219
@@ -0,0 +1 @@
1
+ .ManageAuth-module__manage-auth___4Hpt3{box-sizing:border-box;font:var(--cdp-web-font-size-base) / 1.5 var(--cdp-web-font-family-body);font-optical-sizing:auto;background-color:var(--cdp-web-colors-page-bg-default);color:var(--cdp-web-colors-page-text-default);display:flex;flex-direction:column;max-width:38.25em;overflow:hidden;width:100%;padding-bottom:1.5em}.ManageAuth-module__manage-auth___4Hpt3 *{box-sizing:border-box}.ManageAuth-module__list___lVrdU{display:flex;flex-direction:column;gap:.5em;list-style:none;margin:0;padding:0}.ManageAuth-module__error-wrapper___a9Edn{padding:.5em;background-color:var(--cdp-web-colors-bg-negativeWash);border-radius:.5em;margin:.5em 1.5em}.ManageAuth-module__error-text___43EOm{color:var(--cdp-web-colors-fg-onNegativeWash)}
@@ -0,0 +1 @@
1
+ .ManageAuthItem-module__item___a8mWi{display:flex;align-items:center;justify-content:space-between;height:3em;padding:.5em 1em;margin:0 1.5em;border:1px solid var(--cdp-web-colors-page-border-default);border-radius:.75em;transition:all .2s}.ManageAuthItem-module__item-content___dNkjt{display:flex;align-items:center;gap:.75em;flex:1}.ManageAuthItem-module__item-icon___-uLZ2{display:flex;align-items:center;justify-content:center;width:1.5em;height:1.5em;color:var(--cdp-web-colors-page-text-default)}.ManageAuthItem-module__item-text___kwvK6{display:flex;flex-direction:column;gap:.125em}.ManageAuthItem-module__item-label___u6HnP{font-weight:400;font-size:1em;color:var(--cdp-web-colors-page-text-default)}.ManageAuthItem-module__item-value___YnTDg{font-size:.875em;color:var(--cdp-web-colors-page-text-default)}.ManageAuthItem-module__item-action___JObQh{display:flex;align-items:center}.ManageAuthItem-module__button___NngMz{width:1.5em;height:1.5em;padding:0;font-size:1.25em}.ManageAuthItem-module__button___NngMz:disabled{opacity:.5;cursor:not-allowed}
@@ -0,0 +1 @@
1
+ .ManageAuthModal-module__header___irbw4{display:flex;align-items:center;justify-content:space-between;margin-bottom:1em;padding:1.5em 1.5em 0}.ManageAuthModal-module__title___2Z3vb{font-size:1.25em;font-weight:600;margin:0;color:var(--cdp-web-colors-page-text-default)}.ManageAuthModal-module__close-icon___WnVrd{width:1.25em;height:1.25em}
@@ -0,0 +1,273 @@
1
+ import { useRef as M, useEffect as q } from "react";
2
+ function U(s) {
3
+ return s && s.__esModule && Object.prototype.hasOwnProperty.call(s, "default") ? s.default : s;
4
+ }
5
+ var E = { exports: {} }, T = { exports: {} }, S;
6
+ function H() {
7
+ return S || (S = 1, function() {
8
+ var s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", l = {
9
+ // Bit-wise rotation left
10
+ rotl: function(c, u) {
11
+ return c << u | c >>> 32 - u;
12
+ },
13
+ // Bit-wise rotation right
14
+ rotr: function(c, u) {
15
+ return c << 32 - u | c >>> u;
16
+ },
17
+ // Swap big-endian to little-endian and vice versa
18
+ endian: function(c) {
19
+ if (c.constructor == Number)
20
+ return l.rotl(c, 8) & 16711935 | l.rotl(c, 24) & 4278255360;
21
+ for (var u = 0; u < c.length; u++)
22
+ c[u] = l.endian(c[u]);
23
+ return c;
24
+ },
25
+ // Generate an array of any length of random bytes
26
+ randomBytes: function(c) {
27
+ for (var u = []; c > 0; c--)
28
+ u.push(Math.floor(Math.random() * 256));
29
+ return u;
30
+ },
31
+ // Convert a byte array to big-endian 32-bit words
32
+ bytesToWords: function(c) {
33
+ for (var u = [], a = 0, f = 0; a < c.length; a++, f += 8)
34
+ u[f >>> 5] |= c[a] << 24 - f % 32;
35
+ return u;
36
+ },
37
+ // Convert big-endian 32-bit words to a byte array
38
+ wordsToBytes: function(c) {
39
+ for (var u = [], a = 0; a < c.length * 32; a += 8)
40
+ u.push(c[a >>> 5] >>> 24 - a % 32 & 255);
41
+ return u;
42
+ },
43
+ // Convert a byte array to a hex string
44
+ bytesToHex: function(c) {
45
+ for (var u = [], a = 0; a < c.length; a++)
46
+ u.push((c[a] >>> 4).toString(16)), u.push((c[a] & 15).toString(16));
47
+ return u.join("");
48
+ },
49
+ // Convert a hex string to a byte array
50
+ hexToBytes: function(c) {
51
+ for (var u = [], a = 0; a < c.length; a += 2)
52
+ u.push(parseInt(c.substr(a, 2), 16));
53
+ return u;
54
+ },
55
+ // Convert a byte array to a base-64 string
56
+ bytesToBase64: function(c) {
57
+ for (var u = [], a = 0; a < c.length; a += 3)
58
+ for (var f = c[a] << 16 | c[a + 1] << 8 | c[a + 2], d = 0; d < 4; d++)
59
+ a * 8 + d * 6 <= c.length * 8 ? u.push(s.charAt(f >>> 6 * (3 - d) & 63)) : u.push("=");
60
+ return u.join("");
61
+ },
62
+ // Convert a base-64 string to a byte array
63
+ base64ToBytes: function(c) {
64
+ c = c.replace(/[^A-Z0-9+\/]/ig, "");
65
+ for (var u = [], a = 0, f = 0; a < c.length; f = ++a % 4)
66
+ f != 0 && u.push((s.indexOf(c.charAt(a - 1)) & Math.pow(2, -2 * f + 8) - 1) << f * 2 | s.indexOf(c.charAt(a)) >>> 6 - f * 2);
67
+ return u;
68
+ }
69
+ };
70
+ T.exports = l;
71
+ }()), T.exports;
72
+ }
73
+ var F, m;
74
+ function x() {
75
+ if (m) return F;
76
+ m = 1;
77
+ var s = {
78
+ // UTF-8 encoding
79
+ utf8: {
80
+ // Convert a string to a byte array
81
+ stringToBytes: function(l) {
82
+ return s.bin.stringToBytes(unescape(encodeURIComponent(l)));
83
+ },
84
+ // Convert a byte array to a string
85
+ bytesToString: function(l) {
86
+ return decodeURIComponent(escape(s.bin.bytesToString(l)));
87
+ }
88
+ },
89
+ // Binary encoding
90
+ bin: {
91
+ // Convert a string to a byte array
92
+ stringToBytes: function(l) {
93
+ for (var c = [], u = 0; u < l.length; u++)
94
+ c.push(l.charCodeAt(u) & 255);
95
+ return c;
96
+ },
97
+ // Convert a byte array to a string
98
+ bytesToString: function(l) {
99
+ for (var c = [], u = 0; u < l.length; u++)
100
+ c.push(String.fromCharCode(l[u]));
101
+ return c.join("");
102
+ }
103
+ }
104
+ };
105
+ return F = s, F;
106
+ }
107
+ /*!
108
+ * Determine if an object is a Buffer
109
+ *
110
+ * @author Feross Aboukhadijeh <https://feross.org>
111
+ * @license MIT
112
+ */
113
+ var B, O;
114
+ function N() {
115
+ if (O) return B;
116
+ O = 1, B = function(c) {
117
+ return c != null && (s(c) || l(c) || !!c._isBuffer);
118
+ };
119
+ function s(c) {
120
+ return !!c.constructor && typeof c.constructor.isBuffer == "function" && c.constructor.isBuffer(c);
121
+ }
122
+ function l(c) {
123
+ return typeof c.readFloatLE == "function" && typeof c.slice == "function" && s(c.slice(0, 0));
124
+ }
125
+ return B;
126
+ }
127
+ var A;
128
+ function V() {
129
+ return A || (A = 1, function() {
130
+ var s = H(), l = x().utf8, c = N(), u = x().bin, a = function(f, d) {
131
+ f.constructor == String ? d && d.encoding === "binary" ? f = u.stringToBytes(f) : f = l.stringToBytes(f) : c(f) ? f = Array.prototype.slice.call(f, 0) : !Array.isArray(f) && f.constructor !== Uint8Array && (f = f.toString());
132
+ for (var o = s.bytesToWords(f), y = f.length * 8, r = 1732584193, t = -271733879, e = -1732584194, n = 271733878, i = 0; i < o.length; i++)
133
+ o[i] = (o[i] << 8 | o[i] >>> 24) & 16711935 | (o[i] << 24 | o[i] >>> 8) & 4278255360;
134
+ o[y >>> 5] |= 128 << y % 32, o[(y + 64 >>> 9 << 4) + 14] = y;
135
+ for (var p = a._ff, h = a._gg, v = a._hh, _ = a._ii, i = 0; i < o.length; i += 16) {
136
+ var P = r, D = t, I = e, L = n;
137
+ r = p(r, t, e, n, o[i + 0], 7, -680876936), n = p(n, r, t, e, o[i + 1], 12, -389564586), e = p(e, n, r, t, o[i + 2], 17, 606105819), t = p(t, e, n, r, o[i + 3], 22, -1044525330), r = p(r, t, e, n, o[i + 4], 7, -176418897), n = p(n, r, t, e, o[i + 5], 12, 1200080426), e = p(e, n, r, t, o[i + 6], 17, -1473231341), t = p(t, e, n, r, o[i + 7], 22, -45705983), r = p(r, t, e, n, o[i + 8], 7, 1770035416), n = p(n, r, t, e, o[i + 9], 12, -1958414417), e = p(e, n, r, t, o[i + 10], 17, -42063), t = p(t, e, n, r, o[i + 11], 22, -1990404162), r = p(r, t, e, n, o[i + 12], 7, 1804603682), n = p(n, r, t, e, o[i + 13], 12, -40341101), e = p(e, n, r, t, o[i + 14], 17, -1502002290), t = p(t, e, n, r, o[i + 15], 22, 1236535329), r = h(r, t, e, n, o[i + 1], 5, -165796510), n = h(n, r, t, e, o[i + 6], 9, -1069501632), e = h(e, n, r, t, o[i + 11], 14, 643717713), t = h(t, e, n, r, o[i + 0], 20, -373897302), r = h(r, t, e, n, o[i + 5], 5, -701558691), n = h(n, r, t, e, o[i + 10], 9, 38016083), e = h(e, n, r, t, o[i + 15], 14, -660478335), t = h(t, e, n, r, o[i + 4], 20, -405537848), r = h(r, t, e, n, o[i + 9], 5, 568446438), n = h(n, r, t, e, o[i + 14], 9, -1019803690), e = h(e, n, r, t, o[i + 3], 14, -187363961), t = h(t, e, n, r, o[i + 8], 20, 1163531501), r = h(r, t, e, n, o[i + 13], 5, -1444681467), n = h(n, r, t, e, o[i + 2], 9, -51403784), e = h(e, n, r, t, o[i + 7], 14, 1735328473), t = h(t, e, n, r, o[i + 12], 20, -1926607734), r = v(r, t, e, n, o[i + 5], 4, -378558), n = v(n, r, t, e, o[i + 8], 11, -2022574463), e = v(e, n, r, t, o[i + 11], 16, 1839030562), t = v(t, e, n, r, o[i + 14], 23, -35309556), r = v(r, t, e, n, o[i + 1], 4, -1530992060), n = v(n, r, t, e, o[i + 4], 11, 1272893353), e = v(e, n, r, t, o[i + 7], 16, -155497632), t = v(t, e, n, r, o[i + 10], 23, -1094730640), r = v(r, t, e, n, o[i + 13], 4, 681279174), n = v(n, r, t, e, o[i + 0], 11, -358537222), e = v(e, n, r, t, o[i + 3], 16, -722521979), t = v(t, e, n, r, o[i + 6], 23, 76029189), r = v(r, t, e, n, o[i + 9], 4, -640364487), n = v(n, r, t, e, o[i + 12], 11, -421815835), e = v(e, n, r, t, o[i + 15], 16, 530742520), t = v(t, e, n, r, o[i + 2], 23, -995338651), r = _(r, t, e, n, o[i + 0], 6, -198630844), n = _(n, r, t, e, o[i + 7], 10, 1126891415), e = _(e, n, r, t, o[i + 14], 15, -1416354905), t = _(t, e, n, r, o[i + 5], 21, -57434055), r = _(r, t, e, n, o[i + 12], 6, 1700485571), n = _(n, r, t, e, o[i + 3], 10, -1894986606), e = _(e, n, r, t, o[i + 10], 15, -1051523), t = _(t, e, n, r, o[i + 1], 21, -2054922799), r = _(r, t, e, n, o[i + 8], 6, 1873313359), n = _(n, r, t, e, o[i + 15], 10, -30611744), e = _(e, n, r, t, o[i + 6], 15, -1560198380), t = _(t, e, n, r, o[i + 13], 21, 1309151649), r = _(r, t, e, n, o[i + 4], 6, -145523070), n = _(n, r, t, e, o[i + 11], 10, -1120210379), e = _(e, n, r, t, o[i + 2], 15, 718787259), t = _(t, e, n, r, o[i + 9], 21, -343485551), r = r + P >>> 0, t = t + D >>> 0, e = e + I >>> 0, n = n + L >>> 0;
138
+ }
139
+ return s.endian([r, t, e, n]);
140
+ };
141
+ a._ff = function(f, d, o, y, r, t, e) {
142
+ var n = f + (d & o | ~d & y) + (r >>> 0) + e;
143
+ return (n << t | n >>> 32 - t) + d;
144
+ }, a._gg = function(f, d, o, y, r, t, e) {
145
+ var n = f + (d & y | o & ~y) + (r >>> 0) + e;
146
+ return (n << t | n >>> 32 - t) + d;
147
+ }, a._hh = function(f, d, o, y, r, t, e) {
148
+ var n = f + (d ^ o ^ y) + (r >>> 0) + e;
149
+ return (n << t | n >>> 32 - t) + d;
150
+ }, a._ii = function(f, d, o, y, r, t, e) {
151
+ var n = f + (o ^ (d | ~y)) + (r >>> 0) + e;
152
+ return (n << t | n >>> 32 - t) + d;
153
+ }, a._blocksize = 16, a._digestsize = 16, E.exports = function(f, d) {
154
+ if (f == null)
155
+ throw new Error("Illegal argument " + f);
156
+ var o = s.wordsToBytes(a(f, d));
157
+ return d && d.asBytes ? o : d && d.asString ? u.bytesToString(o) : s.bytesToHex(o);
158
+ };
159
+ }()), E.exports;
160
+ }
161
+ var G = V();
162
+ const J = /* @__PURE__ */ U(G);
163
+ function K() {
164
+ try {
165
+ return typeof navigator < "u" && navigator.product === "ReactNative";
166
+ } catch {
167
+ return !1;
168
+ }
169
+ }
170
+ function $() {
171
+ try {
172
+ if (typeof window > "u")
173
+ return typeof process < "u" && process.env && "__NEXT_PROCESSED_ENV" in process.env;
174
+ const s = window;
175
+ return !!(s.__NEXT_DATA__ || s.next || document.getElementById("__next"));
176
+ } catch {
177
+ return !1;
178
+ }
179
+ }
180
+ function z() {
181
+ try {
182
+ if (typeof window > "u")
183
+ return !1;
184
+ const s = window;
185
+ return !!(s.__VUE__ || s.__VUE_DEVTOOLS_GLOBAL_HOOK__ || document.querySelector("[data-v-]"));
186
+ } catch {
187
+ return !1;
188
+ }
189
+ }
190
+ function W() {
191
+ try {
192
+ if (typeof window > "u")
193
+ return !1;
194
+ const s = window;
195
+ return s.__REACT_DEVTOOLS_GLOBAL_HOOK__ || s.React ? !0 : !!document.querySelector(
196
+ "[data-reactroot], [data-reactid], ._reactRoot, ._reactRootContainer"
197
+ );
198
+ } catch {
199
+ return !1;
200
+ }
201
+ }
202
+ function X() {
203
+ return W() ? "react" : K() ? "react-native" : $() ? "nextjs" : z() ? "vue" : "unknown";
204
+ }
205
+ let R = null;
206
+ function Z() {
207
+ return R === null && (R = X()), R;
208
+ }
209
+ const b = "1f8d3e558f493e38a037dbfadb8ba344", Q = "d473b1dcc969105adab157226cd9cf63", C = Symbol.for("@coinbase/cdp-analytics");
210
+ function Y() {
211
+ const s = globalThis;
212
+ return s[C] || (s[C] = {
213
+ identifier: "",
214
+ enabled: !0,
215
+ isProduction: !1,
216
+ isUsingMocks: !1,
217
+ sendEvent: w,
218
+ sendActionCallEvent: (l) => w({ ...l, type: "action_call" }),
219
+ sendHookCallEvent: (l) => w({ ...l, type: "hook_call" }),
220
+ sendComponentCallEvent: (l) => w({ ...l, type: "component_call" }),
221
+ versionRegistry: {},
222
+ registerPackageVersion: (l, c) => {
223
+ g.versionRegistry[l] = c;
224
+ }
225
+ }), s[C];
226
+ }
227
+ const g = Y();
228
+ async function w(s) {
229
+ if (!g.enabled || !g.identifier)
230
+ return;
231
+ const l = Date.now(), u = [{
232
+ user_id: g.identifier,
233
+ event_type: s.type,
234
+ platform: k() ? "web" : "native",
235
+ timestamp: l,
236
+ event_properties: {
237
+ project_name: "cdp-embedded-wallet",
238
+ framework: Z(),
239
+ isLocalHost: j(),
240
+ isUsingMocks: g.isUsingMocks,
241
+ package_versions: g.versionRegistry,
242
+ ...s
243
+ }
244
+ }], a = JSON.stringify(u), f = l.toString(), d = J(a + f), o = {
245
+ client: g.isProduction ? Q : b,
246
+ e: a,
247
+ checksum: d
248
+ };
249
+ await fetch("https://cca-lite.coinbase.com/amp", {
250
+ method: "POST",
251
+ mode: "no-cors",
252
+ headers: {
253
+ "Content-Type": "application/json"
254
+ },
255
+ body: JSON.stringify(o)
256
+ });
257
+ }
258
+ function k() {
259
+ return typeof window < "u" && typeof document < "u";
260
+ }
261
+ function j() {
262
+ return k() ? window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1" : !1;
263
+ }
264
+ function nt(s) {
265
+ const l = M(!1);
266
+ q(() => {
267
+ l.current || (g.sendComponentCallEvent({ name: s }), l.current = !0);
268
+ }, [s]);
269
+ }
270
+ export {
271
+ g as A,
272
+ nt as u
273
+ };
@@ -1,6 +1,6 @@
1
1
  import { jsx as u, jsxs as j, Fragment as k } from "react/jsx-runtime";
2
2
  import { useIsInitialized as y, useIsSignedIn as z } from "@coinbase/cdp-hooks";
3
- import { u as D } from "../../chunks/useSendComponentCallOnce.CUgcsUye.js";
3
+ import { u as D } from "../../chunks/useSendComponentCallOnce.BHZMuo6E.js";
4
4
  import { useState as m, useRef as M, useCallback as x, useEffect as f } from "react";
5
5
  import { SignInModal as N } from "../SignInModal/index.js";
6
6
  import { SignOutButton as $ } from "../SignOutButton/index.js";
@@ -1,5 +1,5 @@
1
1
  import { jsx as n, jsxs as i, Fragment as f } from "react/jsx-runtime";
2
- import { u as p } from "../../chunks/useSendComponentCallOnce.CUgcsUye.js";
2
+ import { u as p } from "../../chunks/useSendComponentCallOnce.BHZMuo6E.js";
3
3
  import { useId as c } from "react";
4
4
  import { useAppConfig as F } from "../CDPReactProvider/index.js";
5
5
  import { CoinbaseFooter as a } from "../ui/CoinbaseFooter/index.js";
@@ -1,5 +1,5 @@
1
1
  import { jsx as o, jsxs as i, Fragment as p } from "react/jsx-runtime";
2
- import { u as w } from "../../chunks/useSendComponentCallOnce.CUgcsUye.js";
2
+ import { u as w } from "../../chunks/useSendComponentCallOnce.BHZMuo6E.js";
3
3
  import { createContext as j, useState as A, useCallback as F, useMemo as S, useId as $, useContext as z } from "react";
4
4
  import { c as x } from "../../chunks/lite.1fxw3LjI.js";
5
5
  import { useAppConfig as V } from "../CDPReactProvider/index.js";
@@ -0,0 +1,9 @@
1
+ import { AuthMethod as ConfiguredAuthMethod } from '../CDPReactProvider';
2
+ interface ManageAuthItemProps {
3
+ authMethod: ConfiguredAuthMethod;
4
+ displayValue: string;
5
+ isLinked: boolean;
6
+ onLink: (method: ConfiguredAuthMethod) => void;
7
+ }
8
+ declare const ManageAuthItem: ({ authMethod, displayValue, isLinked, onLink }: ManageAuthItemProps) => import("react/jsx-runtime").JSX.Element;
9
+ export { ManageAuthItem as unstable_ManageAuthItem, type ManageAuthItemProps as unstable_ManageAuthItemProps, };
@@ -0,0 +1,77 @@
1
+ import { jsxs as l, jsx as e } from "react/jsx-runtime";
2
+ import { useCallback as s } from "react";
3
+ import { Button as m } from "../ui/Button/index.js";
4
+ import { IconAppleLogo as _ } from "../../icons/IconAppleLogo.js";
5
+ import { IconEnvelope as d } from "../../icons/IconEnvelope.js";
6
+ import { IconGoogleLogo as h } from "../../icons/IconGoogleLogo.js";
7
+ import { IconPhone as g } from "../../icons/IconPhone.js";
8
+ import { IconMinus as p } from "../../icons/IconMinus.js";
9
+ import { IconPlus as b } from "../../icons/IconPlus.js";
10
+ import '../../assets/ManageAuthItem.css';const I = "ManageAuthItem-module__item___a8mWi", A = "ManageAuthItem-module__button___NngMz", t = {
11
+ item: I,
12
+ "item-content": "ManageAuthItem-module__item-content___dNkjt",
13
+ "item-icon": "ManageAuthItem-module__item-icon___-uLZ2",
14
+ "item-text": "ManageAuthItem-module__item-text___kwvK6",
15
+ "item-label": "ManageAuthItem-module__item-label___u6HnP",
16
+ "item-value": "ManageAuthItem-module__item-value___YnTDg",
17
+ "item-action": "ManageAuthItem-module__item-action___JObQh",
18
+ button: A
19
+ }, v = (a) => {
20
+ switch (a) {
21
+ case "email":
22
+ return /* @__PURE__ */ e(d, { "aria-label": "Email" });
23
+ case "sms":
24
+ return /* @__PURE__ */ e(g, { "aria-label": "Phone" });
25
+ case "oauth:google":
26
+ return /* @__PURE__ */ e(h, { "aria-label": "Google" });
27
+ case "oauth:apple":
28
+ return /* @__PURE__ */ e(_, { "aria-label": "Apple" });
29
+ default:
30
+ return null;
31
+ }
32
+ }, f = (a) => {
33
+ switch (a) {
34
+ case "email":
35
+ return "Email";
36
+ case "sms":
37
+ return "Phone";
38
+ case "oauth:google":
39
+ return "Google";
40
+ case "oauth:apple":
41
+ return "Apple";
42
+ default:
43
+ return null;
44
+ }
45
+ }, G = ({ authMethod: a, displayValue: o, isLinked: r, onLink: i }) => {
46
+ const c = v(a), n = f(a), u = s(() => {
47
+ i(a);
48
+ }, [a, i]);
49
+ return /* @__PURE__ */ l("div", { className: t.item, children: [
50
+ /* @__PURE__ */ l("div", { className: t["item-content"], children: [
51
+ /* @__PURE__ */ e("div", { className: t["item-icon"], children: c }),
52
+ /* @__PURE__ */ e("div", { className: t["item-text"], children: o ? /* @__PURE__ */ e("div", { className: t["item-value"], children: o }) : /* @__PURE__ */ e("div", { className: t["item-label"], children: n }) })
53
+ ] }),
54
+ /* @__PURE__ */ e("div", { className: t["item-action"], children: r ? /* @__PURE__ */ e(
55
+ m,
56
+ {
57
+ variant: "secondary",
58
+ className: t.button,
59
+ disabled: !0,
60
+ "aria-label": `Unlink ${n}`,
61
+ children: /* @__PURE__ */ e(p, { "aria-hidden": "true" })
62
+ }
63
+ ) : /* @__PURE__ */ e(
64
+ m,
65
+ {
66
+ variant: "primary",
67
+ className: t.button,
68
+ onClick: u,
69
+ "aria-label": `Link ${n}`,
70
+ children: /* @__PURE__ */ e(b, { "aria-hidden": "true" })
71
+ }
72
+ ) })
73
+ ] });
74
+ };
75
+ export {
76
+ G as unstable_ManageAuthItem
77
+ };
@@ -0,0 +1,8 @@
1
+ import { ReactNode } from 'react';
2
+ import { unstable_ManageAuthState as ManageAuthState } from './types';
3
+ interface ManageAuthProviderProps {
4
+ children: ReactNode;
5
+ }
6
+ declare const ManageAuthProvider: ({ children }: ManageAuthProviderProps) => import("react/jsx-runtime").JSX.Element;
7
+ declare const useManageAuthContext: () => ManageAuthState;
8
+ export { ManageAuthProvider as unstable_ManageAuthProvider, useManageAuthContext as unstable_useManageAuthContext, type ManageAuthProviderProps as unstable_ManageAuthProviderProps, };
@@ -0,0 +1,64 @@
1
+ import { jsx as m } from "react/jsx-runtime";
2
+ import { useCurrentUser as p } from "@coinbase/cdp-hooks";
3
+ import { createContext as c, useState as r, useMemo as g, useContext as M } from "react";
4
+ import { useAppConfig as f } from "../CDPReactProvider/index.js";
5
+ const l = c(void 0), y = ({ children: t }) => {
6
+ const [o, s] = r(null), [n, i] = r(null), { currentUser: e } = p(), { authMethods: h } = f(), u = h.map((a) => {
7
+ switch (a) {
8
+ case "email":
9
+ return e?.authenticationMethods.email ? {
10
+ isLinked: !0,
11
+ displayValue: e.authenticationMethods.email.email,
12
+ method: "email"
13
+ } : {
14
+ isLinked: !1,
15
+ displayValue: "",
16
+ method: "email"
17
+ };
18
+ case "sms":
19
+ return e?.authenticationMethods.sms ? {
20
+ isLinked: !0,
21
+ displayValue: e.authenticationMethods.sms.phoneNumber,
22
+ method: "sms"
23
+ } : {
24
+ isLinked: !1,
25
+ displayValue: "",
26
+ method: "sms"
27
+ };
28
+ case "oauth:google":
29
+ return e?.authenticationMethods.google ? {
30
+ isLinked: !0,
31
+ displayValue: e.authenticationMethods.google.email ?? "",
32
+ method: "oauth:google"
33
+ } : {
34
+ isLinked: !1,
35
+ displayValue: "",
36
+ method: "oauth:google"
37
+ };
38
+ case "oauth:apple":
39
+ return e?.authenticationMethods.apple ? {
40
+ isLinked: !0,
41
+ displayValue: e.authenticationMethods.apple.email ?? "",
42
+ method: "oauth:apple"
43
+ } : {
44
+ isLinked: !1,
45
+ displayValue: "",
46
+ method: "oauth:apple"
47
+ };
48
+ }
49
+ return null;
50
+ }).filter((a) => a !== null), d = g(
51
+ () => ({ error: n, setError: i, manageAuthMethods: u, methodToLink: o, setMethodToLink: s }),
52
+ [n, i, u, o, s]
53
+ );
54
+ return /* @__PURE__ */ m(l.Provider, { value: d, children: t });
55
+ }, C = () => {
56
+ const t = M(l);
57
+ if (!t)
58
+ throw new Error("useManageAuthContext must be used within a ManageAuthProvider");
59
+ return t;
60
+ };
61
+ export {
62
+ y as unstable_ManageAuthProvider,
63
+ C as unstable_useManageAuthContext
64
+ };
@@ -0,0 +1,9 @@
1
+ import { HTMLAttributes, ReactNode } from 'react';
2
+ import { unstable_ManageAuthState as ManageAuthState } from './types';
3
+ interface ManageAuthProps extends Omit<HTMLAttributes<HTMLDivElement>, "children"> {
4
+ children?: ReactNode | ((state: ManageAuthState) => ReactNode);
5
+ onLinkSuccess?: (method: string) => void;
6
+ }
7
+ declare const ManageAuthContent: ({ className, onLinkSuccess, ...props }: ManageAuthProps) => import("react/jsx-runtime").JSX.Element;
8
+ declare const ManageAuth: (props: ManageAuthProps) => import("react/jsx-runtime").JSX.Element;
9
+ export { ManageAuthContent as unstable_ManageAuthContent, ManageAuth as unstable_ManageAuth, type ManageAuthProps as unstable_ManageAuthProps, };
@@ -0,0 +1,51 @@
1
+ import { jsx as r, jsxs as p, Fragment as _ } from "react/jsx-runtime";
2
+ import { useLinkOAuth as d } from "@coinbase/cdp-hooks";
3
+ import { u as g } from "../../chunks/useSendComponentCallOnce.BHZMuo6E.js";
4
+ import { useCallback as A } from "react";
5
+ import { Error as f } from "../ui/Error/index.js";
6
+ import { unstable_ManageAuthItem as k } from "./ManageAuthItem.js";
7
+ import { unstable_useManageAuthContext as x, unstable_ManageAuthProvider as M } from "./ManageAuthProvider.js";
8
+ import "../CDPReactProvider/index.js";
9
+ import '../../assets/ManageAuth.css';const C = "ManageAuth-module__list___lVrdU", t = {
10
+ "manage-auth": "ManageAuth-module__manage-auth___4Hpt3",
11
+ list: C,
12
+ "error-wrapper": "ManageAuth-module__error-wrapper___a9Edn",
13
+ "error-text": "ManageAuth-module__error-text___43EOm"
14
+ }, E = ({ className: n = "", onLinkSuccess: o, ...u }) => {
15
+ const { manageAuthMethods: c, setMethodToLink: s, error: l, setError: i } = x(), { linkOAuth: m } = d(), h = A(
16
+ (e) => {
17
+ try {
18
+ if (e === "email")
19
+ s("email");
20
+ else if (e === "sms")
21
+ s("sms");
22
+ else if (e.startsWith("oauth:")) {
23
+ const a = e.replace("oauth:", "");
24
+ m(a);
25
+ } else
26
+ throw new Error(`Unsupported auth method: ${e}`);
27
+ o?.(e);
28
+ } catch (a) {
29
+ i(a instanceof Error ? a.message : "An unknown error occurred");
30
+ }
31
+ },
32
+ [m, o, i, s]
33
+ );
34
+ return /* @__PURE__ */ r("div", { className: `${t["manage-auth"]} ${n}`, ...u, children: /* @__PURE__ */ p(_, { children: [
35
+ l && /* @__PURE__ */ r("div", { className: t["error-wrapper"], children: /* @__PURE__ */ r(f, { role: "alert", children: /* @__PURE__ */ r("span", { className: t["error-text"], children: l }) }) }),
36
+ /* @__PURE__ */ r("ul", { className: t.list, children: c.map((e) => /* @__PURE__ */ r("li", { children: /* @__PURE__ */ r(
37
+ k,
38
+ {
39
+ authMethod: e.method,
40
+ displayValue: e.displayValue,
41
+ isLinked: e.isLinked,
42
+ onLink: h
43
+ },
44
+ e.method
45
+ ) }, e.method)) })
46
+ ] }) });
47
+ }, V = (n) => (g("manage_auth"), /* @__PURE__ */ r(M, { children: /* @__PURE__ */ r(E, { ...n }) }));
48
+ export {
49
+ V as unstable_ManageAuth,
50
+ E as unstable_ManageAuthContent
51
+ };
@@ -0,0 +1,13 @@
1
+ import { AuthMethod as ConfiguredAuthMethod } from '../CDPReactProvider';
2
+ export type unstable_ManageAuthMethod = {
3
+ isLinked: boolean;
4
+ displayValue: string;
5
+ method: ConfiguredAuthMethod;
6
+ };
7
+ export interface unstable_ManageAuthState {
8
+ methodToLink: ConfiguredAuthMethod | null;
9
+ setMethodToLink: (method: ConfiguredAuthMethod) => void;
10
+ manageAuthMethods: unstable_ManageAuthMethod[];
11
+ error: string | null;
12
+ setError: (error: string | null) => void;
13
+ }
@@ -0,0 +1 @@
1
+ import "../CDPReactProvider/index.js";
@@ -0,0 +1,20 @@
1
+ import { ReactNode } from 'react';
2
+ import { ButtonProps } from '../ui/Button';
3
+ import { ModalContentProps } from '../ui/Modal';
4
+ interface ManageAuthModalTriggerProps extends Partial<Pick<ButtonProps, "className" | "fullWidth" | "size" | "style" | "variant">> {
5
+ children?: ReactNode;
6
+ label?: ReactNode;
7
+ }
8
+ interface ManageAuthModalContentProps extends ModalContentProps {
9
+ onLinkSuccess?: (method: string) => void;
10
+ }
11
+ interface ManageAuthModalProps {
12
+ children?: ReactNode;
13
+ open?: boolean;
14
+ setIsOpen?: (value: boolean) => void;
15
+ onLinkSuccess?: (method: string) => void;
16
+ }
17
+ declare const ManageAuthModalTrigger: ({ children, className, label, ...props }: ManageAuthModalTriggerProps) => import("react/jsx-runtime").JSX.Element;
18
+ declare const ManageAuthModalContent: (props: ManageAuthModalContentProps) => import("react/jsx-runtime").JSX.Element;
19
+ declare const ManageAuthModal: ({ children, open, setIsOpen, onLinkSuccess }: ManageAuthModalProps) => import("react/jsx-runtime").JSX.Element;
20
+ export { ManageAuthModal as unstable_ManageAuthModal, ManageAuthModalContent as unstable_ManageAuthModalContent, ManageAuthModalTrigger as unstable_ManageAuthModalTrigger, type ManageAuthModalProps as unstable_ManageAuthModalProps, type ManageAuthModalContentProps as unstable_ManageAuthModalContentProps, type ManageAuthModalTriggerProps as unstable_ManageAuthModalTriggerProps, };
@@ -0,0 +1,53 @@
1
+ import { jsx as e, jsxs as o, Fragment as d } from "react/jsx-runtime";
2
+ import { u as p } from "../../chunks/useSendComponentCallOnce.BHZMuo6E.js";
3
+ import { createContext as A, useMemo as C, useContext as f } from "react";
4
+ import { unstable_ManageAuth as x } from "../ManageAuth/index.js";
5
+ import { Button as h } from "../ui/Button/index.js";
6
+ import { IconXMark as b } from "../../icons/IconXMark.js";
7
+ import "../CDPReactProvider/index.js";
8
+ import { Modal as T, ModalContent as k, ModalClose as v, ModalTrigger as w, ModalTitle as y, ModalDescription as L } from "../ui/Modal/index.js";
9
+ import { VisuallyHidden as D } from "../ui/VisuallyHidden/index.js";
10
+ import { childrenHasComponent as u } from "../../utils/childrenHasComponent.js";
11
+ import '../../assets/ManageAuthModal.css';const N = "ManageAuthModal-module__header___irbw4", V = "ManageAuthModal-module__title___2Z3vb", l = {
12
+ header: N,
13
+ title: V,
14
+ "close-icon": "ManageAuthModal-module__close-icon___WnVrd"
15
+ }, M = A(null), j = () => {
16
+ const a = f(M);
17
+ if (!a)
18
+ throw new Error("useManageAuthModalContext must be used within a ManageAuthModal");
19
+ return a;
20
+ }, c = ({
21
+ children: a,
22
+ className: t = "",
23
+ label: r,
24
+ ...n
25
+ }) => /* @__PURE__ */ e(w, { asChild: !0, children: a || /* @__PURE__ */ e(h, { className: t, ...n, children: r || "Link accounts" }) }), s = (a) => {
26
+ const { onLinkSuccess: t } = j();
27
+ return /* @__PURE__ */ o(k, { ...a, children: [
28
+ /* @__PURE__ */ e(H, {}),
29
+ /* @__PURE__ */ o("div", { className: l.header, children: [
30
+ /* @__PURE__ */ e("h2", { className: l.title, children: "Link a profile" }),
31
+ /* @__PURE__ */ e(v, { asChild: !0, children: /* @__PURE__ */ e(h, { "aria-label": "Close", size: "md", variant: "transparentSecondary", children: /* @__PURE__ */ e(b, { className: l["close-icon"] }) }) })
32
+ ] }),
33
+ /* @__PURE__ */ e(x, { onLinkSuccess: t })
34
+ ] });
35
+ }, X = ({ children: a, open: t, setIsOpen: r, onLinkSuccess: n }) => {
36
+ p("manage_auth_modal");
37
+ const m = a ? u(a, c) : !1, i = a ? u(a, s) : !1, g = !m && !i, _ = C(() => ({ onLinkSuccess: n }), [n]);
38
+ return /* @__PURE__ */ e(M.Provider, { value: _, children: /* @__PURE__ */ e(T, { open: t, onOpenChange: r, children: g ? /* @__PURE__ */ o(d, { children: [
39
+ /* @__PURE__ */ e(c, { children: a }),
40
+ /* @__PURE__ */ e(s, {})
41
+ ] }) : /* @__PURE__ */ o(d, { children: [
42
+ a,
43
+ !i && /* @__PURE__ */ e(s, {})
44
+ ] }) }) });
45
+ }, H = () => /* @__PURE__ */ o(D, { children: [
46
+ /* @__PURE__ */ e(y, { children: "Link a profile" }),
47
+ /* @__PURE__ */ e(L, { children: "Link additional authentication methods to your account" })
48
+ ] });
49
+ export {
50
+ X as unstable_ManageAuthModal,
51
+ s as unstable_ManageAuthModalContent,
52
+ c as unstable_ManageAuthModalTrigger
53
+ };