@coinbase/cdp-api-client 0.0.85 → 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.
- package/dist/esm/index10.js +1 -1
- package/dist/esm/index12.js +38 -7
- package/dist/esm/index14.js +67 -375
- package/dist/esm/index15.js +34 -835
- package/dist/esm/index16.js +21 -2
- package/dist/esm/index17.js +8 -2
- package/dist/esm/index18.js +2 -39
- package/dist/esm/index19.js +378 -2
- package/dist/esm/index20.js +835 -69
- package/dist/esm/index21.js +2 -35
- package/dist/esm/index22.js +2 -21
- package/dist/esm/index23.js +2 -2
- package/dist/esm/index3.js +1 -1
- package/dist/esm/index4.js +1 -1
- package/dist/esm/index7.js +22 -19
- package/package.json +1 -1
package/dist/esm/index21.js
CHANGED
|
@@ -1,37 +1,4 @@
|
|
|
1
|
-
var
|
|
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
|
-
}
|
|
1
|
+
var r = { exports: {} };
|
|
35
2
|
export {
|
|
36
|
-
|
|
3
|
+
r as __module
|
|
37
4
|
};
|
package/dist/esm/index22.js
CHANGED
|
@@ -1,23 +1,4 @@
|
|
|
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
|
-
}
|
|
1
|
+
var r = {};
|
|
21
2
|
export {
|
|
22
|
-
|
|
3
|
+
r as __exports
|
|
23
4
|
};
|
package/dist/esm/index23.js
CHANGED
package/dist/esm/index3.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { __require as r } from "./
|
|
1
|
+
import { __require as r } from "./index17.js";
|
|
2
2
|
r();
|
package/dist/esm/index4.js
CHANGED
package/dist/esm/index7.js
CHANGED
|
@@ -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
|
-
}),
|
|
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 =
|
|
15
|
-
if (!
|
|
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
|
|
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
|
|
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 (!
|
|
26
|
+
if (!n || p(t.pathname) || f(t.pathname) && !await n.isSignedIn())
|
|
27
27
|
return e;
|
|
28
|
-
const s = await
|
|
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
|
-
|
|
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
|
-
}),
|
|
43
|
-
|
|
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
|
|
103
|
+
let o = "";
|
|
104
104
|
if (t.response.data)
|
|
105
105
|
try {
|
|
106
|
-
|
|
106
|
+
o = JSON.stringify(t.response.data);
|
|
107
107
|
} catch {
|
|
108
|
-
|
|
108
|
+
o = String(t.response.data);
|
|
109
109
|
}
|
|
110
|
-
const
|
|
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
|
-
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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) =>
|
|
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
|
-
|
|
182
|
+
j as cdpApiClient,
|
|
180
183
|
$ as configureCdpApiClient,
|
|
181
184
|
x as setAuthManager
|
|
182
185
|
};
|