@coinbase/cdp-api-client 0.0.86 → 0.0.87

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.
@@ -1,4 +1,4 @@
1
- const o = "0.0.86";
1
+ const o = "0.0.87";
2
2
  export {
3
3
  o as VERSION
4
4
  };
@@ -4,43 +4,43 @@ import { UnknownApiError as m, HttpErrorType as u, isOpenAPIError as v, APIError
4
4
  const h = () => typeof window < "u" && typeof document < "u";
5
5
  let a = c.create({
6
6
  baseURL: "https://api.cdp.coinbase.com/platform"
7
- }), o = null;
7
+ }), n = null;
8
8
  const $ = (r) => {
9
9
  a = c.create({
10
10
  baseURL: r.basePath || "https://api.cdp.coinbase.com/platform",
11
11
  // Only enable cookies in browser environments where they're supported
12
12
  withCredentials: h()
13
13
  }), a.interceptors.request.use(async (e) => {
14
- const t = b(e), s = l(e);
15
- if (!o || p(s.pathname) || w(s.pathname) && !await o.isSignedIn() || !q(s.pathname))
14
+ const t = g(e), s = l(e);
15
+ if (!n || p(s.pathname) || f(s.pathname) && !await n.isSignedIn() || !T(s.pathname))
16
16
  return e;
17
- const n = await o.getXWalletAuth({
17
+ const o = await n.getXWalletAuth({
18
18
  requestMethod: t,
19
19
  requestHost: s.host,
20
20
  requestPath: s.pathname,
21
21
  requestData: e.data
22
22
  });
23
- return n && (e.headers["X-Wallet-Auth"] = n), e;
23
+ return o && (e.headers["X-Wallet-Auth"] = o), e;
24
24
  }), a.interceptors.request.use(async (e) => {
25
25
  const t = l(e);
26
- if (!o || p(t.pathname) || w(t.pathname) && !await o.isSignedIn())
26
+ if (!n || p(t.pathname) || f(t.pathname) && !await n.isSignedIn())
27
27
  return e;
28
- const s = await o.getToken();
28
+ const s = await n.getToken();
29
29
  return s && s !== "" && (e.headers.Authorization = `Bearer ${s}`), e;
30
30
  }), h() || a.interceptors.request.use(async (e) => {
31
31
  let t = e.headers["User-Agent"];
32
32
  return t = t ? `${t} CDP/reactnative` : "CDP/reactnative", e.headers["User-Agent"] = t, e;
33
33
  }), r.refreshTokenStorage && R(r.refreshTokenStorage), r.debugging && (a.interceptors.request.use((e) => (console.log("Request:", e), e)), a.interceptors.response.use((e) => (console.log("Response:", e), e)));
34
34
  }, x = (r) => {
35
- o = r;
35
+ n = r;
36
36
  }, A = (r, e) => ({
37
37
  ...r,
38
38
  headers: {
39
39
  ...r.headers || {},
40
40
  "X-Idempotency-Key": e
41
41
  }
42
- }), I = async (r, e) => {
43
- T(r), e && e !== "" && (r = A(r, e));
42
+ }), j = async (r, e) => {
43
+ b(r), e && e !== "" && (r = A(r, e));
44
44
  try {
45
45
  return (await a(r)).data;
46
46
  } catch (t) {
@@ -100,18 +100,18 @@ const $ = (r) => {
100
100
  t.cause
101
101
  );
102
102
  default: {
103
- let n = "";
103
+ let o = "";
104
104
  if (t.response.data)
105
105
  try {
106
- n = JSON.stringify(t.response.data);
106
+ o = JSON.stringify(t.response.data);
107
107
  } catch {
108
- n = String(t.response.data);
108
+ o = String(t.response.data);
109
109
  }
110
- const f = n ? `An unexpected error occurred: ${n}` : "An unexpected error occurred.";
110
+ const w = o ? `An unexpected error occurred: ${o}` : "An unexpected error occurred.";
111
111
  throw new i(
112
112
  s,
113
113
  u.unexpected_error,
114
- f,
114
+ w,
115
115
  void 0,
116
116
  `${d}`,
117
117
  t.cause
@@ -159,24 +159,27 @@ const $ = (r) => {
159
159
  return e ? /^\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/(verify\/(email|sms|oauth\/.*)|refresh)$/.test(
160
160
  e
161
161
  ) : !1;
162
- }, T = (r) => {
162
+ }, b = (r) => {
163
163
  if (!a.getUri() || a.getUri() === "")
164
164
  throw new Error("CDP client URI not configured. Call configure() first.");
165
165
  if (!r.url || r.url === "")
166
166
  throw new Error("AxiosRequestConfig URL is empty. This should never happen.");
167
167
  if (!r.method || r.method === "")
168
168
  throw new Error("AxiosRequestConfig method is empty. This should never happen.");
169
- }, b = (r) => r.method?.toString().toUpperCase() || "GET", l = (r) => {
169
+ }, g = (r) => r.method?.toString().toUpperCase() || "GET", l = (r) => {
170
170
  if (!r.url)
171
171
  throw new Error("URL is required for authentication");
172
172
  const e = a.getUri() + r.url;
173
173
  return new URL(e);
174
- }, p = (r) => /^\/platform\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/(refresh|logout)$/.test(r), q = (r) => !/^\/platform\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/custom\/authenticate$/.test(r), w = (r) => {
174
+ }, p = (r) => {
175
+ const e = /^\/platform\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/(refresh|logout)$/, t = /^\/platform\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/(mfa)$/, s = /^\/platform\/v2\/embedded-wallet-api\/projects\/[^/]+\/config$/;
176
+ return e.test(r) || t.test(r) || s.test(r);
177
+ }, T = (r) => !/^\/platform\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/custom\/authenticate$/.test(r), f = (r) => {
175
178
  const e = /^\/platform\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/(init)$/, t = /^\/platform\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/verify\//;
176
179
  return e.test(r) || t.test(r);
177
180
  };
178
181
  export {
179
- I as cdpApiClient,
182
+ j as cdpApiClient,
180
183
  $ as configureCdpApiClient,
181
184
  x as setAuthManager
182
185
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coinbase/cdp-api-client",
3
- "version": "0.0.86",
3
+ "version": "0.0.87",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist/**",