@coinbase/cdp-react-native 0.0.83 → 0.0.85

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.
@@ -0,0 +1,7 @@
1
+ import { getDefaultExportFromCjs as r } from "./index18.js";
2
+ import { __require as o } from "./index12.js";
3
+ var t = o();
4
+ const a = /* @__PURE__ */ r(t);
5
+ export {
6
+ a as default
7
+ };
@@ -0,0 +1,50 @@
1
+ function n() {
2
+ try {
3
+ return typeof navigator < "u" && navigator.product === "ReactNative";
4
+ } catch {
5
+ return !1;
6
+ }
7
+ }
8
+ function r() {
9
+ try {
10
+ if (typeof window > "u")
11
+ return typeof process < "u" && process.env && "__NEXT_PROCESSED_ENV" in process.env;
12
+ const e = window;
13
+ return !!(e.__NEXT_DATA__ || e.next || document.getElementById("__next"));
14
+ } catch {
15
+ return !1;
16
+ }
17
+ }
18
+ function o() {
19
+ try {
20
+ if (typeof window > "u")
21
+ return !1;
22
+ const e = window;
23
+ return !!(e.__VUE__ || e.__VUE_DEVTOOLS_GLOBAL_HOOK__ || document.querySelector("[data-v-]"));
24
+ } catch {
25
+ return !1;
26
+ }
27
+ }
28
+ function u() {
29
+ try {
30
+ if (typeof window > "u")
31
+ return !1;
32
+ const e = window;
33
+ return e.__REACT_DEVTOOLS_GLOBAL_HOOK__ || e.React ? !0 : !!document.querySelector(
34
+ "[data-reactroot], [data-reactid], ._reactRoot, ._reactRootContainer"
35
+ );
36
+ } catch {
37
+ return !1;
38
+ }
39
+ }
40
+ function a() {
41
+ return u() ? "react" : n() ? "react-native" : r() ? "nextjs" : o() ? "vue" : "unknown";
42
+ }
43
+ let t = null;
44
+ function i() {
45
+ return t === null && (t = a()), t;
46
+ }
47
+ export {
48
+ a as detectFramework,
49
+ i as getFramework
50
+ };
@@ -0,0 +1,41 @@
1
+ import { __module as h } from "./index13.js";
2
+ import { __require as S } from "./index14.js";
3
+ import { __require as q } from "./index15.js";
4
+ import { __require as w } from "./index16.js";
5
+ var x;
6
+ function G() {
7
+ return x ? h.exports : (x = 1, function() {
8
+ var v = S(), p = q().utf8, B = w(), F = q().bin, d = function(o, f) {
9
+ o.constructor == String ? f && f.encoding === "binary" ? o = F.stringToBytes(o) : o = p.stringToBytes(o) : B(o) ? o = Array.prototype.slice.call(o, 0) : !Array.isArray(o) && o.constructor !== Uint8Array && (o = o.toString());
10
+ for (var u = v.bytesToWords(o), a = o.length * 8, n = 1732584193, r = -271733879, i = -1732584194, t = 271733878, e = 0; e < u.length; e++)
11
+ u[e] = (u[e] << 8 | u[e] >>> 24) & 16711935 | (u[e] << 24 | u[e] >>> 8) & 4278255360;
12
+ u[a >>> 5] |= 128 << a % 32, u[(a + 64 >>> 9 << 4) + 14] = a;
13
+ for (var _ = d._ff, c = d._gg, l = d._hh, y = d._ii, e = 0; e < u.length; e += 16) {
14
+ var T = n, b = r, A = i, I = t;
15
+ n = _(n, r, i, t, u[e + 0], 7, -680876936), t = _(t, n, r, i, u[e + 1], 12, -389564586), i = _(i, t, n, r, u[e + 2], 17, 606105819), r = _(r, i, t, n, u[e + 3], 22, -1044525330), n = _(n, r, i, t, u[e + 4], 7, -176418897), t = _(t, n, r, i, u[e + 5], 12, 1200080426), i = _(i, t, n, r, u[e + 6], 17, -1473231341), r = _(r, i, t, n, u[e + 7], 22, -45705983), n = _(n, r, i, t, u[e + 8], 7, 1770035416), t = _(t, n, r, i, u[e + 9], 12, -1958414417), i = _(i, t, n, r, u[e + 10], 17, -42063), r = _(r, i, t, n, u[e + 11], 22, -1990404162), n = _(n, r, i, t, u[e + 12], 7, 1804603682), t = _(t, n, r, i, u[e + 13], 12, -40341101), i = _(i, t, n, r, u[e + 14], 17, -1502002290), r = _(r, i, t, n, u[e + 15], 22, 1236535329), n = c(n, r, i, t, u[e + 1], 5, -165796510), t = c(t, n, r, i, u[e + 6], 9, -1069501632), i = c(i, t, n, r, u[e + 11], 14, 643717713), r = c(r, i, t, n, u[e + 0], 20, -373897302), n = c(n, r, i, t, u[e + 5], 5, -701558691), t = c(t, n, r, i, u[e + 10], 9, 38016083), i = c(i, t, n, r, u[e + 15], 14, -660478335), r = c(r, i, t, n, u[e + 4], 20, -405537848), n = c(n, r, i, t, u[e + 9], 5, 568446438), t = c(t, n, r, i, u[e + 14], 9, -1019803690), i = c(i, t, n, r, u[e + 3], 14, -187363961), r = c(r, i, t, n, u[e + 8], 20, 1163531501), n = c(n, r, i, t, u[e + 13], 5, -1444681467), t = c(t, n, r, i, u[e + 2], 9, -51403784), i = c(i, t, n, r, u[e + 7], 14, 1735328473), r = c(r, i, t, n, u[e + 12], 20, -1926607734), n = l(n, r, i, t, u[e + 5], 4, -378558), t = l(t, n, r, i, u[e + 8], 11, -2022574463), i = l(i, t, n, r, u[e + 11], 16, 1839030562), r = l(r, i, t, n, u[e + 14], 23, -35309556), n = l(n, r, i, t, u[e + 1], 4, -1530992060), t = l(t, n, r, i, u[e + 4], 11, 1272893353), i = l(i, t, n, r, u[e + 7], 16, -155497632), r = l(r, i, t, n, u[e + 10], 23, -1094730640), n = l(n, r, i, t, u[e + 13], 4, 681279174), t = l(t, n, r, i, u[e + 0], 11, -358537222), i = l(i, t, n, r, u[e + 3], 16, -722521979), r = l(r, i, t, n, u[e + 6], 23, 76029189), n = l(n, r, i, t, u[e + 9], 4, -640364487), t = l(t, n, r, i, u[e + 12], 11, -421815835), i = l(i, t, n, r, u[e + 15], 16, 530742520), r = l(r, i, t, n, u[e + 2], 23, -995338651), n = y(n, r, i, t, u[e + 0], 6, -198630844), t = y(t, n, r, i, u[e + 7], 10, 1126891415), i = y(i, t, n, r, u[e + 14], 15, -1416354905), r = y(r, i, t, n, u[e + 5], 21, -57434055), n = y(n, r, i, t, u[e + 12], 6, 1700485571), t = y(t, n, r, i, u[e + 3], 10, -1894986606), i = y(i, t, n, r, u[e + 10], 15, -1051523), r = y(r, i, t, n, u[e + 1], 21, -2054922799), n = y(n, r, i, t, u[e + 8], 6, 1873313359), t = y(t, n, r, i, u[e + 15], 10, -30611744), i = y(i, t, n, r, u[e + 6], 15, -1560198380), r = y(r, i, t, n, u[e + 13], 21, 1309151649), n = y(n, r, i, t, u[e + 4], 6, -145523070), t = y(t, n, r, i, u[e + 11], 10, -1120210379), i = y(i, t, n, r, u[e + 2], 15, 718787259), r = y(r, i, t, n, u[e + 9], 21, -343485551), n = n + T >>> 0, r = r + b >>> 0, i = i + A >>> 0, t = t + I >>> 0;
16
+ }
17
+ return v.endian([n, r, i, t]);
18
+ };
19
+ d._ff = function(o, f, u, a, n, r, i) {
20
+ var t = o + (f & u | ~f & a) + (n >>> 0) + i;
21
+ return (t << r | t >>> 32 - r) + f;
22
+ }, d._gg = function(o, f, u, a, n, r, i) {
23
+ var t = o + (f & a | u & ~a) + (n >>> 0) + i;
24
+ return (t << r | t >>> 32 - r) + f;
25
+ }, d._hh = function(o, f, u, a, n, r, i) {
26
+ var t = o + (f ^ u ^ a) + (n >>> 0) + i;
27
+ return (t << r | t >>> 32 - r) + f;
28
+ }, d._ii = function(o, f, u, a, n, r, i) {
29
+ var t = o + (u ^ (f | ~a)) + (n >>> 0) + i;
30
+ return (t << r | t >>> 32 - r) + f;
31
+ }, d._blocksize = 16, d._digestsize = 16, h.exports = function(o, f) {
32
+ if (o == null)
33
+ throw new Error("Illegal argument " + o);
34
+ var u = v.wordsToBytes(d(o, f));
35
+ return f && f.asBytes ? u : f && f.asString ? F.bytesToString(u) : v.bytesToHex(u);
36
+ };
37
+ }(), h.exports);
38
+ }
39
+ export {
40
+ G as __require
41
+ };
@@ -0,0 +1,4 @@
1
+ var e = { exports: {} };
2
+ export {
3
+ e as __module
4
+ };
@@ -0,0 +1,72 @@
1
+ import { __module as a } from "./index17.js";
2
+ var h;
3
+ function c() {
4
+ return h ? a.exports : (h = 1, function() {
5
+ var f = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", u = {
6
+ // Bit-wise rotation left
7
+ rotl: function(r, t) {
8
+ return r << t | r >>> 32 - t;
9
+ },
10
+ // Bit-wise rotation right
11
+ rotr: function(r, t) {
12
+ return r << 32 - t | r >>> t;
13
+ },
14
+ // Swap big-endian to little-endian and vice versa
15
+ endian: function(r) {
16
+ if (r.constructor == Number)
17
+ return u.rotl(r, 8) & 16711935 | u.rotl(r, 24) & 4278255360;
18
+ for (var t = 0; t < r.length; t++)
19
+ r[t] = u.endian(r[t]);
20
+ return r;
21
+ },
22
+ // Generate an array of any length of random bytes
23
+ randomBytes: function(r) {
24
+ for (var t = []; r > 0; r--)
25
+ t.push(Math.floor(Math.random() * 256));
26
+ return t;
27
+ },
28
+ // Convert a byte array to big-endian 32-bit words
29
+ bytesToWords: function(r) {
30
+ for (var t = [], n = 0, o = 0; n < r.length; n++, o += 8)
31
+ t[o >>> 5] |= r[n] << 24 - o % 32;
32
+ return t;
33
+ },
34
+ // Convert big-endian 32-bit words to a byte array
35
+ wordsToBytes: function(r) {
36
+ for (var t = [], n = 0; n < r.length * 32; n += 8)
37
+ t.push(r[n >>> 5] >>> 24 - n % 32 & 255);
38
+ return t;
39
+ },
40
+ // Convert a byte array to a hex string
41
+ bytesToHex: function(r) {
42
+ for (var t = [], n = 0; n < r.length; n++)
43
+ t.push((r[n] >>> 4).toString(16)), t.push((r[n] & 15).toString(16));
44
+ return t.join("");
45
+ },
46
+ // Convert a hex string to a byte array
47
+ hexToBytes: function(r) {
48
+ for (var t = [], n = 0; n < r.length; n += 2)
49
+ t.push(parseInt(r.substr(n, 2), 16));
50
+ return t;
51
+ },
52
+ // Convert a byte array to a base-64 string
53
+ bytesToBase64: function(r) {
54
+ for (var t = [], n = 0; n < r.length; n += 3)
55
+ for (var o = r[n] << 16 | r[n + 1] << 8 | r[n + 2], e = 0; e < 4; e++)
56
+ n * 8 + e * 6 <= r.length * 8 ? t.push(f.charAt(o >>> 6 * (3 - e) & 63)) : t.push("=");
57
+ return t.join("");
58
+ },
59
+ // Convert a base-64 string to a byte array
60
+ base64ToBytes: function(r) {
61
+ r = r.replace(/[^A-Z0-9+\/]/ig, "");
62
+ for (var t = [], n = 0, o = 0; n < r.length; o = ++n % 4)
63
+ o != 0 && t.push((f.indexOf(r.charAt(n - 1)) & Math.pow(2, -2 * o + 8) - 1) << o * 2 | f.indexOf(r.charAt(n)) >>> 6 - o * 2);
64
+ return t;
65
+ }
66
+ };
67
+ a.exports = u;
68
+ }(), a.exports);
69
+ }
70
+ export {
71
+ c as __require
72
+ };
@@ -0,0 +1,37 @@
1
+ var o, u;
2
+ function c() {
3
+ if (u) return o;
4
+ u = 1;
5
+ var t = {
6
+ // UTF-8 encoding
7
+ utf8: {
8
+ // Convert a string to a byte array
9
+ stringToBytes: function(n) {
10
+ return t.bin.stringToBytes(unescape(encodeURIComponent(n)));
11
+ },
12
+ // Convert a byte array to a string
13
+ bytesToString: function(n) {
14
+ return decodeURIComponent(escape(t.bin.bytesToString(n)));
15
+ }
16
+ },
17
+ // Binary encoding
18
+ bin: {
19
+ // Convert a string to a byte array
20
+ stringToBytes: function(n) {
21
+ for (var e = [], r = 0; r < n.length; r++)
22
+ e.push(n.charCodeAt(r) & 255);
23
+ return e;
24
+ },
25
+ // Convert a byte array to a string
26
+ bytesToString: function(n) {
27
+ for (var e = [], r = 0; r < n.length; r++)
28
+ e.push(String.fromCharCode(n[r]));
29
+ return e.join("");
30
+ }
31
+ }
32
+ };
33
+ return o = t, o;
34
+ }
35
+ export {
36
+ c as __require
37
+ };
@@ -0,0 +1,23 @@
1
+ /*!
2
+ * Determine if an object is a Buffer
3
+ *
4
+ * @author Feross Aboukhadijeh <https://feross.org>
5
+ * @license MIT
6
+ */
7
+ var f, e;
8
+ function t() {
9
+ if (e) return f;
10
+ e = 1, f = function(r) {
11
+ return r != null && (u(r) || n(r) || !!r._isBuffer);
12
+ };
13
+ function u(r) {
14
+ return !!r.constructor && typeof r.constructor.isBuffer == "function" && r.constructor.isBuffer(r);
15
+ }
16
+ function n(r) {
17
+ return typeof r.readFloatLE == "function" && typeof r.slice == "function" && u(r.slice(0, 0));
18
+ }
19
+ return f;
20
+ }
21
+ export {
22
+ t as __require
23
+ };
@@ -0,0 +1,4 @@
1
+ var r = { exports: {} };
2
+ export {
3
+ r as __module
4
+ };
@@ -0,0 +1,6 @@
1
+ function e(t) {
2
+ return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
3
+ }
4
+ export {
5
+ e as getDefaultExportFromCjs
6
+ };
@@ -1,10 +1,10 @@
1
- import { createEndUserApplePayOnrampOrder as y, APIError as h } from "@coinbase/cdp-api-client";
2
- import { useCurrentUser as f, useConfig as g } from "@coinbase/cdp-hooks";
3
- import v, { createContext as b, useReducer as k, useCallback as n, useEffect as C } from "react";
4
- import { checkUserVerification as U } from "./index5.js";
5
- const x = b(null);
6
- function q({ children: t }) {
7
- const [s, r] = k(A, p), { currentUser: o } = f(), { config: i } = g(), c = n(() => {
1
+ import { createEndUserApplePayOnrampOrder as f, APIError as h } from "@coinbase/cdp-api-client";
2
+ import { useCurrentUser as g, useConfig as v } from "@coinbase/cdp-hooks";
3
+ import C, { createContext as U, useReducer as x, useCallback as n, useEffect as A } from "react";
4
+ import { checkUserVerification as E } from "./index5.js";
5
+ const I = U(null);
6
+ function w({ children: t, debug: a = !1 }) {
7
+ const [p, r] = x(P, i), { currentUser: o } = g(), { config: d } = v(), c = n(() => {
8
8
  if (!o)
9
9
  return r({
10
10
  type: "validation_error",
@@ -12,7 +12,7 @@ function q({ children: t }) {
12
12
  code: "user_not_authenticated"
13
13
  }
14
14
  }), null;
15
- const { missingVerification: e } = U(o);
15
+ const { missingVerification: e } = E(o);
16
16
  return e ? (r({
17
17
  type: "validation_error",
18
18
  error: {
@@ -20,16 +20,16 @@ function q({ children: t }) {
20
20
  }
21
21
  }), null) : (r({ type: "reset" }), o);
22
22
  }, [o]);
23
- C(() => {
23
+ A(() => {
24
24
  c();
25
25
  }, [c]);
26
- const d = n(
26
+ const l = n(
27
27
  async (e) => {
28
28
  const u = c();
29
29
  if (u)
30
30
  try {
31
31
  r({ type: "purchase_requested" });
32
- const a = await y(i.projectId, u.userId, {
32
+ const s = await f(d.projectId, u.userId, {
33
33
  agreementAcceptedAt: (/* @__PURE__ */ new Date()).toISOString(),
34
34
  // TODO: Do we need to verify the user owns the destination address?
35
35
  destination: e.destination,
@@ -42,73 +42,67 @@ function q({ children: t }) {
42
42
  },
43
43
  isSandbox: e.isSandbox
44
44
  });
45
- r({ type: "purchase_started", data: a });
46
- } catch (a) {
47
- a instanceof h ? r({
45
+ r({ type: "purchase_started", data: s });
46
+ } catch (s) {
47
+ s instanceof h ? r({
48
48
  type: "purchase_error",
49
49
  error: {
50
50
  code: "api_error",
51
- correlationId: a.correlationId,
52
- message: a.errorMessage
51
+ correlationId: s.correlationId,
52
+ message: s.errorMessage
53
53
  }
54
54
  }) : r({
55
55
  type: "purchase_error",
56
56
  error: {
57
- message: a instanceof Error ? a.message : "Failed to create order"
57
+ message: s instanceof Error ? s.message : "Failed to create order"
58
58
  }
59
59
  });
60
60
  }
61
61
  },
62
62
  [c]
63
- ), l = n((e) => {
64
- switch (e.type) {
65
- case "onramp_api.load_error":
66
- r({
67
- type: "purchase_error",
68
- error: e.error
69
- });
70
- break;
71
- case "onramp_api.commit_error":
72
- r({
73
- type: "purchase_error",
74
- error: e.error
75
- });
76
- break;
77
- case "onramp_api.polling_error":
78
- r({
79
- type: "purchase_error",
80
- error: e.error
81
- });
82
- break;
83
- case "onramp_api.polling_success":
84
- r({ type: "purchase_success" });
85
- break;
86
- case "onramp_api.cancel":
87
- r({ type: "reset" });
88
- break;
89
- }
90
- }, []), m = n(() => {
63
+ ), m = n(
64
+ (e) => {
65
+ switch (e.type) {
66
+ case "onramp_api.load_error":
67
+ case "onramp_api.commit_error":
68
+ case "onramp_api.polling_error":
69
+ r({
70
+ type: "purchase_error",
71
+ error: e.error
72
+ });
73
+ break;
74
+ case "onramp_api.polling_success":
75
+ r({ type: "purchase_success" });
76
+ break;
77
+ case "onramp_api.cancel":
78
+ r({ type: "reset" });
79
+ break;
80
+ }
81
+ },
82
+ [a]
83
+ ), _ = n(() => {
91
84
  r({ type: "reset" });
92
- }, []), _ = {
93
- ...s,
94
- createOrder: d,
95
- paymentEventHandler: l,
96
- reset: m
85
+ }, []), y = {
86
+ ...p,
87
+ createOrder: l,
88
+ paymentEventHandler: m,
89
+ reset: _,
90
+ debug: a
97
91
  };
98
- return /* @__PURE__ */ v.createElement(x.Provider, { value: _ }, t);
92
+ return /* @__PURE__ */ C.createElement(I.Provider, { value: y }, t);
99
93
  }
100
- const p = {
94
+ const i = {
101
95
  status: "idle",
102
96
  data: void 0,
103
97
  error: void 0
104
98
  };
105
- function A(t, s) {
106
- switch (s.type) {
99
+ function P(t, a) {
100
+ switch (a.type) {
107
101
  case "validation_error":
108
102
  return {
109
103
  ...t,
110
104
  status: "error",
111
- error: s.error
105
+ error: a.error
112
106
  };
113
107
  case "purchase_requested":
114
108
  return {
@@ -120,7 +114,7 @@ function A(t, s) {
120
114
  return {
121
115
  ...t,
122
116
  status: "pending",
123
- data: s.data,
117
+ data: a.data,
124
118
  error: void 0
125
119
  };
126
120
  case "purchase_success":
@@ -132,15 +126,15 @@ function A(t, s) {
132
126
  return {
133
127
  ...t,
134
128
  status: "error",
135
- error: s.error
129
+ error: a.error
136
130
  };
137
131
  case "reset":
138
- return p;
132
+ return i;
139
133
  default:
140
134
  return t;
141
135
  }
142
136
  }
143
137
  export {
144
- x as ApplePayContext,
145
- q as ApplePayProvider
138
+ I as ApplePayContext,
139
+ w as ApplePayProvider
146
140
  };
@@ -1,7 +1,10 @@
1
- import { useContext as r } from "react";
2
- import { ApplePayContext as t } from "./index2.js";
3
- function s() {
4
- const e = r(t);
1
+ import "./index6.js";
2
+ import { useSendHookCallOnce as r } from "./index7.js";
3
+ import { useContext as t } from "react";
4
+ import { ApplePayContext as o } from "./index2.js";
5
+ function u() {
6
+ r("use_apple_pay");
7
+ const e = t(o);
5
8
  if (!e)
6
9
  throw new Error("useApplePay must be used within an ApplePayProvider");
7
10
  return {
@@ -13,5 +16,5 @@ function s() {
13
16
  };
14
17
  }
15
18
  export {
16
- s as useApplePay
19
+ u as useApplePay
17
20
  };
@@ -1,34 +1,41 @@
1
- import a, { useContext as c, useCallback as d } from "react";
2
- import { StyleSheet as p, Platform as l, View as g } from "react-native";
3
- import { WebView as v } from "react-native-webview";
4
- import { ApplePayContext as w } from "./index2.js";
5
- import { parseWebViewMessage as f } from "./index6.js";
6
- function N({ style: o }) {
7
- const e = c(w);
1
+ import "./index6.js";
2
+ import i, { useContext as p, useCallback as d } from "react";
3
+ import { useSendComponentCallOnce as c } from "./index8.js";
4
+ import { StyleSheet as l, Platform as g, View as v } from "react-native";
5
+ import { WebView as w } from "react-native-webview";
6
+ import { ApplePayContext as f } from "./index2.js";
7
+ import { parseWebViewMessage as u } from "./index9.js";
8
+ function V({ style: s }) {
9
+ c("apple_pay_button");
10
+ const e = p(f);
8
11
  if (!e)
9
12
  throw new Error("ApplePayButton must be used within an ApplePayProvider");
10
- const t = e.data?.paymentLink.url, s = d(
11
- (r) => {
12
- const n = f(r.nativeEvent.data);
13
- n.success && e.paymentEventHandler(n.event);
13
+ const n = e.data?.paymentLink.url, r = d(
14
+ (a) => {
15
+ e.debug && console.log(
16
+ "[ApplePayButton] Received webview event:",
17
+ JSON.stringify(a.nativeEvent.data, null, 2)
18
+ );
19
+ const t = u(a.nativeEvent.data);
20
+ e.debug && console.log("[ApplePayButton] Parsed event:", JSON.stringify(t, null, 2)), t.success && e.paymentEventHandler(t.event);
14
21
  },
15
22
  [e.paymentEventHandler]
16
23
  );
17
- return l.OS !== "ios" ? (__DEV__ && console.warn("ApplePayButton is only available on iOS"), null) : t ? /* @__PURE__ */ a.createElement(g, { style: [i.container, o] }, /* @__PURE__ */ a.createElement(
18
- v,
24
+ return g.OS !== "ios" ? (__DEV__ && console.warn("ApplePayButton is only available on iOS"), null) : n ? /* @__PURE__ */ i.createElement(v, { style: [o.container, s] }, /* @__PURE__ */ i.createElement(
25
+ w,
19
26
  {
20
- source: { uri: t },
21
- injectedJavaScriptBeforeContentLoaded: u,
22
- injectedJavaScript: m,
23
- onMessage: s,
27
+ source: { uri: n },
28
+ injectedJavaScriptBeforeContentLoaded: m,
29
+ injectedJavaScript: y,
30
+ onMessage: r,
24
31
  startInLoadingState: !0,
25
- style: i.webView,
32
+ style: o.webView,
26
33
  originWhitelist: ["https://*", "apple-pay://*"],
27
34
  mixedContentMode: "compatibility"
28
35
  }
29
36
  )) : null;
30
37
  }
31
- const i = p.create({
38
+ const o = l.create({
32
39
  container: {
33
40
  height: 48,
34
41
  width: "100%",
@@ -39,7 +46,7 @@ const i = p.create({
39
46
  flex: 1,
40
47
  backgroundColor: "transparent"
41
48
  }
42
- }), u = `
49
+ }), m = `
43
50
  (function() {
44
51
  // Flag to prevent duplicate installations
45
52
  window.__cdpEventForwarderInstalled = true;
@@ -98,7 +105,7 @@ const i = p.create({
98
105
 
99
106
  true;
100
107
  })();
101
- `, m = `
108
+ `, y = `
102
109
  (function() {
103
110
  if (window.__cdpEventForwarderInstalled) {
104
111
  return true;
@@ -121,5 +128,5 @@ const i = p.create({
121
128
  })();
122
129
  `;
123
130
  export {
124
- N as ApplePayButton
131
+ V as ApplePayButton
125
132
  };
@@ -1,42 +1,60 @@
1
- const n = [
2
- "onramp_api.load_pending",
3
- "onramp_api.load_success",
4
- "onramp_api.load_error",
5
- "onramp_api.polling_success",
6
- "onramp_api.commit_error",
7
- "onramp_api.cancel"
8
- ];
9
- function o(s) {
10
- let e;
11
- try {
12
- e = JSON.parse(s);
13
- } catch {
14
- return { success: !1, reason: "Invalid JSON" };
15
- }
16
- if (!a(e))
17
- return { success: !1, reason: "Invalid message structure" };
18
- const r = e.eventName ?? e.type;
19
- return r ? t(r) ? {
20
- success: !0,
21
- event: {
22
- type: r,
23
- message: e.message,
24
- error: {
25
- code: e.data?.errorCode,
26
- message: e.data?.errorMessage
27
- }
1
+ import p from "./index10.js";
2
+ import { getFramework as m } from "./index11.js";
3
+ const y = "1f8d3e558f493e38a037dbfadb8ba344", v = "d473b1dcc969105adab157226cd9cf63", i = Symbol.for("@coinbase/cdp-analytics");
4
+ function g() {
5
+ const t = globalThis;
6
+ return t[i] || (t[i] = {
7
+ identifier: "",
8
+ enabled: !0,
9
+ isProduction: !1,
10
+ isUsingMocks: !1,
11
+ sendEvent: o,
12
+ sendActionCallEvent: (e) => o({ ...e, type: "action_call" }),
13
+ sendHookCallEvent: (e) => o({ ...e, type: "hook_call" }),
14
+ sendComponentCallEvent: (e) => o({ ...e, type: "component_call" }),
15
+ versionRegistry: {},
16
+ registerPackageVersion: (e, s) => {
17
+ n.versionRegistry[e] = s;
28
18
  }
29
- } : { success: !1, reason: "Unknown event type" } : { success: !1, reason: "Missing event type" };
19
+ }), t[i];
30
20
  }
31
- function a(s) {
32
- if (typeof s != "object" || s === null)
33
- return !1;
34
- const e = s;
35
- return typeof e.eventName == "string" || typeof e.type == "string";
21
+ const n = g();
22
+ async function o(t) {
23
+ if (!n.enabled || !n.identifier)
24
+ return;
25
+ const e = Date.now(), r = [{
26
+ user_id: n.identifier,
27
+ event_type: t.type,
28
+ platform: c() ? "web" : "native",
29
+ timestamp: e,
30
+ event_properties: {
31
+ project_name: "cdp-embedded-wallet",
32
+ framework: m(),
33
+ isLocalHost: u(),
34
+ isUsingMocks: n.isUsingMocks,
35
+ package_versions: n.versionRegistry,
36
+ ...t
37
+ }
38
+ }], a = JSON.stringify(r), d = e.toString(), l = p(a + d), f = {
39
+ client: n.isProduction ? v : y,
40
+ e: a,
41
+ checksum: l
42
+ };
43
+ await fetch("https://cca-lite.coinbase.com/amp", {
44
+ method: "POST",
45
+ mode: "no-cors",
46
+ headers: {
47
+ "Content-Type": "application/json"
48
+ },
49
+ body: JSON.stringify(f)
50
+ });
51
+ }
52
+ function c() {
53
+ return typeof window < "u" && typeof document < "u";
36
54
  }
37
- function t(s) {
38
- return n.includes(s);
55
+ function u() {
56
+ return c() ? window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1" : !1;
39
57
  }
40
58
  export {
41
- o as parseWebViewMessage
59
+ n as Analytics
42
60
  };
@@ -0,0 +1,11 @@
1
+ import { useRef as r, useEffect as t } from "react";
2
+ import { Analytics as n } from "./index6.js";
3
+ function s(e) {
4
+ const o = r(!1);
5
+ t(() => {
6
+ o.current || (n.sendHookCallEvent({ name: e }), o.current = !0);
7
+ }, [e]);
8
+ }
9
+ export {
10
+ s as useSendHookCallOnce
11
+ };
@@ -0,0 +1,11 @@
1
+ import { useRef as t, useEffect as o } from "react";
2
+ import { Analytics as r } from "./index6.js";
3
+ function s(e) {
4
+ const n = t(!1);
5
+ o(() => {
6
+ n.current || (r.sendComponentCallEvent({ name: e }), n.current = !0);
7
+ }, [e]);
8
+ }
9
+ export {
10
+ s as useSendComponentCallOnce
11
+ };
@@ -0,0 +1,51 @@
1
+ const a = [
2
+ "onramp_api.load_pending",
3
+ "onramp_api.load_success",
4
+ "onramp_api.load_error",
5
+ "onramp_api.polling_start",
6
+ "onramp_api.polling_success",
7
+ "onramp_api.polling_error",
8
+ "onramp_api.commit_success",
9
+ "onramp_api.commit_error",
10
+ "onramp_api.cancel"
11
+ ];
12
+ function o(s) {
13
+ let e;
14
+ try {
15
+ e = JSON.parse(s);
16
+ } catch {
17
+ return { success: !1, reason: "Invalid JSON" };
18
+ }
19
+ if (!n(e))
20
+ return { success: !1, reason: "Invalid message structure" };
21
+ const r = e.eventName ?? e.type;
22
+ return r ? t(r) ? e.data?.errorCode || e.data?.errorMessage ? {
23
+ success: !0,
24
+ event: {
25
+ type: r,
26
+ message: e.message,
27
+ error: {
28
+ code: e.data?.errorCode,
29
+ message: e.data?.errorMessage
30
+ }
31
+ }
32
+ } : {
33
+ success: !0,
34
+ event: {
35
+ type: r,
36
+ message: e.message
37
+ }
38
+ } : { success: !1, reason: "Unknown event type" } : { success: !1, reason: "Missing event type" };
39
+ }
40
+ function n(s) {
41
+ if (typeof s != "object" || s === null)
42
+ return !1;
43
+ const e = s;
44
+ return typeof e.eventName == "string" || typeof e.type == "string";
45
+ }
46
+ function t(s) {
47
+ return a.includes(s);
48
+ }
49
+ export {
50
+ o as parseWebViewMessage
51
+ };
@@ -15,15 +15,17 @@ export declare interface ApplePayContextValue {
15
15
  status: ApplePayOnrampStatus;
16
16
  error: OnrampError | undefined;
17
17
  reset: () => void;
18
+ debug: boolean;
18
19
  paymentEventHandler: (event: OnrampEvent) => void;
19
20
  }
20
21
 
21
22
  export declare type ApplePayOnrampStatus = "idle" | "pending" | "error" | "success";
22
23
 
23
- export declare function ApplePayProvider({ children }: ApplePayProviderProps): JSX.Element;
24
+ export declare function ApplePayProvider({ children, debug }: ApplePayProviderProps): JSX.Element;
24
25
 
25
26
  export declare interface ApplePayProviderProps {
26
27
  children: ReactNode;
28
+ debug?: boolean;
27
29
  }
28
30
 
29
31
  export declare interface CreateOrderOptions {
@@ -33,14 +35,16 @@ export declare interface CreateOrderOptions {
33
35
  };
34
36
  purchase: {
35
37
  amount: string;
36
- currency: "usdc" | string;
38
+ currency: "usdc" | (string & {});
37
39
  };
38
40
  payment: {
39
- currency: "usd" | string;
41
+ currency: "usd" | (string & {});
40
42
  };
41
43
  isSandbox?: boolean;
42
44
  }
43
45
 
46
+ declare const ONRAMP_EVENT_TYPES: readonly ["onramp_api.load_pending", "onramp_api.load_success", "onramp_api.load_error", "onramp_api.polling_start", "onramp_api.polling_success", "onramp_api.polling_error", "onramp_api.commit_success", "onramp_api.commit_error", "onramp_api.cancel"];
47
+
44
48
  export declare interface OnrampError {
45
49
  correlationId?: string;
46
50
  message?: string;
@@ -60,7 +64,7 @@ declare type OnrampEvent = {
60
64
  message?: string;
61
65
  } | OnrampErrorEvent;
62
66
 
63
- declare type OnrampEventType = "onramp_api.load_pending" | "onramp_api.load_success" | "onramp_api.load_error" | "onramp_api.commit_success" | "onramp_api.commit_error" | "onramp_api.cancel" | "onramp_api.polling_start" | "onramp_api.polling_success" | "onramp_api.polling_error";
67
+ declare type OnrampEventType = (typeof ONRAMP_EVENT_TYPES)[number];
64
68
 
65
69
  export declare function useApplePay(): UseApplePayReturn;
66
70
 
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@coinbase/cdp-react-native",
3
- "version": "0.0.83",
3
+ "version": "0.0.85",
4
4
  "type": "module",
5
5
  "peerDependencies": {
6
6
  "react": ">=18.2.0",
7
7
  "react-native": ">=0.70.0",
8
8
  "react-native-webview": ">=13.0.0",
9
- "@coinbase/cdp-hooks": "^0.0.83",
10
- "@coinbase/cdp-api-client": "^0.0.83",
11
- "@coinbase/cdp-core": "^0.0.83"
9
+ "@coinbase/cdp-api-client": "^0.0.85",
10
+ "@coinbase/cdp-core": "^0.0.85",
11
+ "@coinbase/cdp-hooks": "^0.0.85"
12
12
  },
13
13
  "devDependencies": {
14
14
  "@testing-library/react": "^16.0.0",
@@ -17,9 +17,9 @@
17
17
  "react-dom": "^19.1.2",
18
18
  "react-native": "^0.79.6",
19
19
  "react-native-webview": "^13.13.5",
20
- "@coinbase/cdp-api-client": "0.0.83",
21
- "@coinbase/cdp-core": "0.0.83",
22
- "@coinbase/cdp-hooks": "0.0.83"
20
+ "@coinbase/cdp-api-client": "0.0.85",
21
+ "@coinbase/cdp-core": "0.0.85",
22
+ "@coinbase/cdp-hooks": "0.0.85"
23
23
  },
24
24
  "files": [
25
25
  "dist/**",