@coinbase/cdp-api-client 0.0.122 → 0.0.123
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/index.js +81 -80
- package/dist/esm/index11.js +1 -1
- package/dist/esm/index13.js +38 -7
- package/dist/esm/index15.js +67 -358
- package/dist/esm/index16.js +34 -852
- package/dist/esm/index17.js +14 -38
- package/dist/esm/index18.js +8 -2
- package/dist/esm/index19.js +2 -70
- package/dist/esm/index20.js +355 -29
- package/dist/esm/index21.js +852 -14
- package/dist/esm/index22.js +2 -2
- package/dist/esm/index23.js +2 -2
- package/dist/esm/index24.js +2 -2
- package/dist/esm/index3.js +1 -1
- package/dist/esm/index4.js +1 -1
- package/dist/esm/index6.js +213 -168
- package/dist/types/index.d.ts +8 -0
- package/package.json +1 -1
package/dist/esm/index22.js
CHANGED
package/dist/esm/index23.js
CHANGED
package/dist/esm/index24.js
CHANGED
package/dist/esm/index3.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { __require as r } from "./
|
|
1
|
+
import { __require as r } from "./index18.js";
|
|
2
2
|
r();
|
package/dist/esm/index4.js
CHANGED
package/dist/esm/index6.js
CHANGED
|
@@ -1,244 +1,286 @@
|
|
|
1
1
|
import { Analytics as d } from "./index2.js";
|
|
2
2
|
import "./index3.js";
|
|
3
|
-
import
|
|
4
|
-
import { ERROR_DOCS_PAGE_URL as
|
|
5
|
-
import { isRefreshTokenUnavailableError as
|
|
3
|
+
import p from "axios";
|
|
4
|
+
import { ERROR_DOCS_PAGE_URL as R } from "./index10.js";
|
|
5
|
+
import { isRefreshTokenUnavailableError as P, UnknownApiError as U, HttpErrorType as m, isOpenAPIError as $, APIError as f, UnknownError as S, RefreshTokenUnavailableError as A } from "./index7.js";
|
|
6
6
|
const k = () => typeof window < "u" && typeof document < "u";
|
|
7
|
-
let n =
|
|
7
|
+
let n = p.create({
|
|
8
8
|
baseURL: "https://api.cdp.coinbase.com/platform"
|
|
9
|
-
}),
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
}), g = p.create({
|
|
10
|
+
baseURL: "https://api.cdp.coinbase.com/platform"
|
|
11
|
+
}), h = null, w = null;
|
|
12
|
+
const ee = (t) => {
|
|
13
|
+
const a = t.basePath || "https://api.cdp.coinbase.com/platform";
|
|
14
|
+
if (n = p.create({
|
|
15
|
+
baseURL: a,
|
|
13
16
|
// Only enable cookies in browser environments where they're supported
|
|
14
17
|
withCredentials: k()
|
|
15
|
-
}), n.interceptors.request.use(async (
|
|
16
|
-
const
|
|
17
|
-
if (!h ||
|
|
18
|
-
return
|
|
19
|
-
const
|
|
20
|
-
requestMethod:
|
|
21
|
-
requestHost:
|
|
22
|
-
requestPath:
|
|
23
|
-
requestData:
|
|
18
|
+
}), g = p.create({ baseURL: a }), n.interceptors.request.use(async (e) => {
|
|
19
|
+
const s = Z(e), r = v(e);
|
|
20
|
+
if (!h || y(r.pathname) || _(r.pathname) && !await h.isSignedIn() || !B(r.pathname))
|
|
21
|
+
return e;
|
|
22
|
+
const o = await h.getXWalletAuth({
|
|
23
|
+
requestMethod: s,
|
|
24
|
+
requestHost: r.host,
|
|
25
|
+
requestPath: r.pathname,
|
|
26
|
+
requestData: e.data
|
|
24
27
|
});
|
|
25
|
-
return
|
|
26
|
-
}), n.interceptors.request.use(async (
|
|
27
|
-
const
|
|
28
|
-
if (!h ||
|
|
29
|
-
return
|
|
30
|
-
const
|
|
31
|
-
return
|
|
28
|
+
return o && (e.headers["X-Wallet-Auth"] = o), e;
|
|
29
|
+
}), n.interceptors.request.use(async (e) => {
|
|
30
|
+
const s = v(e);
|
|
31
|
+
if (!h || y(s.pathname) || _(s.pathname) && !await h.isSignedIn())
|
|
32
|
+
return e;
|
|
33
|
+
const r = await h.getToken();
|
|
34
|
+
return r && r !== "" && (e.headers.Authorization = `Bearer ${r}`), e;
|
|
32
35
|
}), !k()) {
|
|
33
|
-
const
|
|
34
|
-
n.interceptors.request.use(async (
|
|
35
|
-
let
|
|
36
|
-
return
|
|
36
|
+
const e = t.platform ? `CDP/reactnative/${t.platform}` : "CDP/reactnative";
|
|
37
|
+
n.interceptors.request.use(async (s) => {
|
|
38
|
+
let r = s.headers["User-Agent"];
|
|
39
|
+
return r = r ? `${r} ${e}` : e, s.headers["User-Agent"] = r, s;
|
|
37
40
|
});
|
|
38
41
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
),
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
42
|
+
t.refreshTokenStorage && x(
|
|
43
|
+
t.refreshTokenStorage,
|
|
44
|
+
t.retryTokenReads ?? !1,
|
|
45
|
+
t.failClosedOnMissingToken ?? !1
|
|
46
|
+
), t.appAttestation && q(t.appAttestation, t.platform), t.debugging && (n.interceptors.request.use((e) => (console.log("Request:", e), e)), n.interceptors.response.use((e) => (console.log("Response:", e), e))), n.interceptors.request.use((e) => e._fallbackRetry ? (delete e._fallbackRetry, e) : (k() && w && (e.baseURL = `https://${w}/platform`), e)), n.interceptors.response.use(
|
|
47
|
+
(e) => e,
|
|
48
|
+
async (e) => {
|
|
49
|
+
if (!p.isAxiosError(e) || !j(e))
|
|
50
|
+
return Promise.reject(e);
|
|
51
|
+
const s = e.config;
|
|
52
|
+
return C(s) ? e.response?.status === 401 ? b(s) : I(e, s) : Promise.reject(e);
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
}, j = (t) => {
|
|
56
|
+
const a = !t.response, e = t.response?.status === 401;
|
|
57
|
+
return a || e;
|
|
58
|
+
}, C = (t) => {
|
|
59
|
+
const a = w ? `https://${w}/platform` : null;
|
|
60
|
+
return !!(a && t?.baseURL === a && t.url && H(t.url));
|
|
61
|
+
}, b = (t) => n({
|
|
62
|
+
...t,
|
|
63
|
+
baseURL: void 0,
|
|
64
|
+
_fallbackRetry: !0
|
|
65
|
+
}), I = async (t, a) => {
|
|
66
|
+
const e = a.url?.match(/\/v2\/embedded-wallet-api\/projects\/([^/]+)\//)?.[1];
|
|
67
|
+
if (!e)
|
|
68
|
+
return Promise.reject(t);
|
|
69
|
+
try {
|
|
70
|
+
const r = (await g.get(
|
|
71
|
+
`/v2/embedded-wallet-api/projects/${e}/config`
|
|
72
|
+
)).data?.activeCookieDomain ?? null;
|
|
73
|
+
return M(r), r !== null ? Promise.reject(t) : b(a);
|
|
74
|
+
} catch {
|
|
75
|
+
return Promise.reject(t);
|
|
76
|
+
}
|
|
77
|
+
}, te = (t) => {
|
|
78
|
+
h = t;
|
|
79
|
+
}, M = (t) => {
|
|
80
|
+
const a = t?.trim() || null;
|
|
81
|
+
if (a && !/^[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?)*$/.test(
|
|
82
|
+
a
|
|
83
|
+
)) {
|
|
84
|
+
console.warn(`[CDP] Invalid cookie domain ignored: "${a}"`), w = null;
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
w = a;
|
|
88
|
+
}, q = (t, a) => {
|
|
89
|
+
n.interceptors.request.use(async (e) => {
|
|
90
|
+
const s = v(e);
|
|
91
|
+
if (!K(s.pathname) || !t.isEnabled())
|
|
92
|
+
return e;
|
|
51
93
|
try {
|
|
52
|
-
if (
|
|
53
|
-
const
|
|
54
|
-
if (!
|
|
55
|
-
return
|
|
56
|
-
const
|
|
94
|
+
if (a === "ios") {
|
|
95
|
+
const r = s.pathname.match(/\/projects\/([^/]+)\//);
|
|
96
|
+
if (!r || !r[1])
|
|
97
|
+
return e;
|
|
98
|
+
const c = `/v2/embedded-wallet-api/projects/${r[1]}/attestation/challenge`, u = (await n.post(c)).data.challenge;
|
|
57
99
|
if (!u)
|
|
58
|
-
return console.warn("Failed to fetch assertion challenge"),
|
|
59
|
-
const i = await
|
|
100
|
+
return console.warn("Failed to fetch assertion challenge"), e;
|
|
101
|
+
const i = await t.generateAssertion(u);
|
|
60
102
|
if (!i)
|
|
61
|
-
return
|
|
62
|
-
|
|
103
|
+
return e;
|
|
104
|
+
e.headers["X-App-Attestation-Assertion"] = i.assertion, e.headers["X-App-Attestation-Key-ID"] = i.keyId, e.headers["X-App-Attestation-Challenge"] = u;
|
|
63
105
|
} else {
|
|
64
|
-
const
|
|
65
|
-
if (!
|
|
66
|
-
return
|
|
67
|
-
|
|
106
|
+
const r = await t.generateAssertion(JSON.stringify(e.data));
|
|
107
|
+
if (!r)
|
|
108
|
+
return e;
|
|
109
|
+
e.headers["X-Integrity-Token"] = r.assertion, e.headers["X-Package-Name"] = t.appIdentifier;
|
|
68
110
|
}
|
|
69
|
-
return
|
|
70
|
-
} catch (
|
|
111
|
+
return e;
|
|
112
|
+
} catch (r) {
|
|
71
113
|
throw new Error(
|
|
72
|
-
`App attestation required but assertion generation failed: ${
|
|
114
|
+
`App attestation required but assertion generation failed: ${r instanceof Error ? r.message : String(r)}`
|
|
73
115
|
);
|
|
74
116
|
}
|
|
75
117
|
});
|
|
76
|
-
},
|
|
77
|
-
...
|
|
118
|
+
}, D = (t, a) => ({
|
|
119
|
+
...t,
|
|
78
120
|
headers: {
|
|
79
|
-
...
|
|
80
|
-
"X-Idempotency-Key":
|
|
121
|
+
...t.headers || {},
|
|
122
|
+
"X-Idempotency-Key": a
|
|
81
123
|
}
|
|
82
|
-
}),
|
|
83
|
-
|
|
124
|
+
}), re = async (t, a) => {
|
|
125
|
+
W(t), a && a !== "" && (t = D(t, a));
|
|
84
126
|
try {
|
|
85
|
-
return (await n(
|
|
86
|
-
} catch (
|
|
87
|
-
if (
|
|
88
|
-
throw
|
|
89
|
-
if (
|
|
90
|
-
throw new
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
127
|
+
return (await n(t)).data;
|
|
128
|
+
} catch (e) {
|
|
129
|
+
if (P(e))
|
|
130
|
+
throw e;
|
|
131
|
+
if (p.isAxiosError(e) && !e.response)
|
|
132
|
+
throw new U(
|
|
133
|
+
m.unknown,
|
|
134
|
+
e.cause instanceof Error ? e.cause.message : e.message,
|
|
135
|
+
e.cause
|
|
94
136
|
);
|
|
95
|
-
if (
|
|
96
|
-
if (
|
|
137
|
+
if (p.isAxiosError(e) && e.response) {
|
|
138
|
+
if ($(e.response.data))
|
|
97
139
|
throw new f(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
140
|
+
e.response.status,
|
|
141
|
+
e.response.data.errorType,
|
|
142
|
+
e.response.data.errorMessage,
|
|
143
|
+
e.response.data.correlationId,
|
|
144
|
+
e.response.data.errorLink,
|
|
145
|
+
e.cause
|
|
104
146
|
);
|
|
105
147
|
{
|
|
106
|
-
const s =
|
|
148
|
+
const s = e.response.status;
|
|
107
149
|
switch (s) {
|
|
108
150
|
case 401:
|
|
109
151
|
throw new f(
|
|
110
152
|
s,
|
|
111
|
-
|
|
153
|
+
m.unauthorized,
|
|
112
154
|
"Unauthorized.",
|
|
113
155
|
void 0,
|
|
114
|
-
`${
|
|
115
|
-
|
|
156
|
+
`${R}#unauthorized`,
|
|
157
|
+
e.cause
|
|
116
158
|
);
|
|
117
159
|
case 404:
|
|
118
160
|
throw new f(
|
|
119
161
|
s,
|
|
120
|
-
|
|
162
|
+
m.not_found,
|
|
121
163
|
"API not found.",
|
|
122
164
|
void 0,
|
|
123
|
-
`${
|
|
124
|
-
|
|
165
|
+
`${R}#not_found`,
|
|
166
|
+
e.cause
|
|
125
167
|
);
|
|
126
168
|
case 502:
|
|
127
169
|
throw new f(
|
|
128
170
|
s,
|
|
129
|
-
|
|
171
|
+
m.bad_gateway,
|
|
130
172
|
"Bad gateway.",
|
|
131
173
|
void 0,
|
|
132
|
-
`${
|
|
133
|
-
|
|
174
|
+
`${R}`,
|
|
175
|
+
e.cause
|
|
134
176
|
);
|
|
135
177
|
case 503:
|
|
136
178
|
throw new f(
|
|
137
179
|
s,
|
|
138
|
-
|
|
180
|
+
m.service_unavailable,
|
|
139
181
|
"Service unavailable. Please try again later.",
|
|
140
182
|
void 0,
|
|
141
|
-
`${
|
|
142
|
-
|
|
183
|
+
`${R}`,
|
|
184
|
+
e.cause
|
|
143
185
|
);
|
|
144
186
|
default: {
|
|
145
|
-
let
|
|
146
|
-
if (
|
|
187
|
+
let r = "";
|
|
188
|
+
if (e.response.data)
|
|
147
189
|
try {
|
|
148
|
-
|
|
190
|
+
r = JSON.stringify(e.response.data);
|
|
149
191
|
} catch {
|
|
150
|
-
|
|
192
|
+
r = String(e.response.data);
|
|
151
193
|
}
|
|
152
|
-
const o =
|
|
194
|
+
const o = r ? `An unexpected error occurred: ${r}` : "An unexpected error occurred.";
|
|
153
195
|
throw new f(
|
|
154
196
|
s,
|
|
155
|
-
|
|
197
|
+
m.unexpected_error,
|
|
156
198
|
o,
|
|
157
199
|
void 0,
|
|
158
|
-
`${
|
|
159
|
-
|
|
200
|
+
`${R}`,
|
|
201
|
+
e.cause
|
|
160
202
|
);
|
|
161
203
|
}
|
|
162
204
|
}
|
|
163
205
|
}
|
|
164
206
|
}
|
|
165
|
-
throw new S("Something went wrong.",
|
|
207
|
+
throw new S("Something went wrong.", e instanceof Error ? e : void 0);
|
|
166
208
|
}
|
|
167
|
-
}, E = 4,
|
|
168
|
-
if (
|
|
169
|
-
const { token:
|
|
170
|
-
return { token:
|
|
209
|
+
}, E = 4, L = [25, 50, 100], T = async (t) => {
|
|
210
|
+
if (t.getRefreshTokenWithOutcome) {
|
|
211
|
+
const { token: a, outcome: e, errorMessage: s } = await t.getRefreshTokenWithOutcome();
|
|
212
|
+
return { token: a, outcome: e, errorMessage: s };
|
|
171
213
|
}
|
|
172
|
-
return { token: await
|
|
173
|
-
},
|
|
174
|
-
let
|
|
175
|
-
for (let
|
|
176
|
-
const o = await
|
|
177
|
-
if (
|
|
214
|
+
return { token: await t.getRefreshToken() };
|
|
215
|
+
}, O = async (t) => {
|
|
216
|
+
let a = null, e, s;
|
|
217
|
+
for (let r = 0; r < E; r++) {
|
|
218
|
+
const o = await T(t);
|
|
219
|
+
if (a = o.token, e = o.outcome, s = o.errorMessage, a)
|
|
178
220
|
return {
|
|
179
|
-
token:
|
|
180
|
-
attempt:
|
|
181
|
-
outcome:
|
|
221
|
+
token: a,
|
|
222
|
+
attempt: r,
|
|
223
|
+
outcome: e,
|
|
182
224
|
errorMessage: s
|
|
183
225
|
};
|
|
184
|
-
const
|
|
185
|
-
|
|
226
|
+
const c = L[r];
|
|
227
|
+
c !== void 0 && await new Promise((l) => setTimeout(l, c));
|
|
186
228
|
}
|
|
187
229
|
return {
|
|
188
|
-
token:
|
|
230
|
+
token: a,
|
|
189
231
|
attempt: E - 1,
|
|
190
|
-
outcome:
|
|
232
|
+
outcome: e,
|
|
191
233
|
errorMessage: s
|
|
192
234
|
};
|
|
193
|
-
},
|
|
235
|
+
}, x = (t, a, e) => {
|
|
194
236
|
n.interceptors.response.use(
|
|
195
237
|
async (s) => {
|
|
196
238
|
try {
|
|
197
|
-
if (
|
|
239
|
+
if (N(s)) {
|
|
198
240
|
d.sendSessionRefreshEvent({
|
|
199
241
|
name: "refresh_token_response"
|
|
200
242
|
});
|
|
201
|
-
const
|
|
202
|
-
|
|
243
|
+
const r = s.data?.refreshToken;
|
|
244
|
+
r && (d.sendSessionRefreshEvent({
|
|
203
245
|
name: "refresh_token_received"
|
|
204
246
|
}), await Promise.race([
|
|
205
|
-
|
|
247
|
+
t.setRefreshToken(r),
|
|
206
248
|
new Promise(
|
|
207
|
-
(o,
|
|
249
|
+
(o, c) => setTimeout(() => c(new Error("setRefreshToken timed out after 5000ms")), 5e3)
|
|
208
250
|
)
|
|
209
251
|
]), d.sendSessionRefreshEvent({
|
|
210
252
|
name: "refresh_token_stored"
|
|
211
253
|
}));
|
|
212
254
|
}
|
|
213
|
-
} catch (
|
|
214
|
-
const o =
|
|
255
|
+
} catch (r) {
|
|
256
|
+
const o = r instanceof Error ? r.message : String(r);
|
|
215
257
|
d.sendSessionRefreshEvent({
|
|
216
258
|
name: "refresh_token_store_failed",
|
|
217
259
|
error_message: o
|
|
218
|
-
}), console.warn("Failed to store refresh token:",
|
|
260
|
+
}), console.warn("Failed to store refresh token:", r);
|
|
219
261
|
}
|
|
220
262
|
return s;
|
|
221
263
|
},
|
|
222
264
|
(s) => Promise.reject(s)
|
|
223
265
|
), n.interceptors.request.use(async (s) => {
|
|
224
|
-
if (
|
|
225
|
-
const
|
|
226
|
-
let o = null,
|
|
266
|
+
if (X(s.url)) {
|
|
267
|
+
const r = F(s.url);
|
|
268
|
+
let o = null, c = 0, l, u;
|
|
227
269
|
try {
|
|
228
|
-
const i =
|
|
229
|
-
o = i.token,
|
|
270
|
+
const i = a ? await O(t) : { ...await T(t), attempt: 0 };
|
|
271
|
+
o = i.token, c = i.attempt, l = i.outcome, u = i.errorMessage;
|
|
230
272
|
} catch (i) {
|
|
231
|
-
if (u = i instanceof Error ? i.message : String(i),
|
|
273
|
+
if (u = i instanceof Error ? i.message : String(i), l = "error", d.sendSessionRefreshEvent({
|
|
232
274
|
name: "refresh_token_retrieve_failed",
|
|
233
275
|
error_message: u
|
|
234
|
-
}), console.warn("Failed to retrieve refresh token:", i),
|
|
235
|
-
throw new
|
|
276
|
+
}), console.warn("Failed to retrieve refresh token:", i), r && e)
|
|
277
|
+
throw new A("error", u);
|
|
236
278
|
}
|
|
237
279
|
if (o)
|
|
238
280
|
d.sendSessionRefreshEvent({
|
|
239
281
|
name: "refresh_token_retrieved",
|
|
240
|
-
attempt:
|
|
241
|
-
read_outcome:
|
|
282
|
+
attempt: c,
|
|
283
|
+
read_outcome: l,
|
|
242
284
|
error_message: u
|
|
243
285
|
}), s.data = {
|
|
244
286
|
...s.data,
|
|
@@ -246,57 +288,60 @@ const B = (e) => {
|
|
|
246
288
|
};
|
|
247
289
|
else if (d.sendSessionRefreshEvent({
|
|
248
290
|
name: "refresh_token_missing",
|
|
249
|
-
attempt:
|
|
250
|
-
read_outcome:
|
|
291
|
+
attempt: c,
|
|
292
|
+
read_outcome: l,
|
|
251
293
|
error_message: u
|
|
252
|
-
}),
|
|
253
|
-
throw new
|
|
254
|
-
|
|
294
|
+
}), r && e)
|
|
295
|
+
throw new A(
|
|
296
|
+
l === "error" ? "error" : "not_found",
|
|
255
297
|
u
|
|
256
298
|
);
|
|
257
299
|
}
|
|
258
|
-
if (
|
|
300
|
+
if (z(s.url))
|
|
259
301
|
try {
|
|
260
302
|
d.sendSessionRefreshEvent({
|
|
261
303
|
name: "refresh_token_removing_token"
|
|
262
|
-
}), await
|
|
263
|
-
} catch (
|
|
264
|
-
console.warn("Failed to remove refresh token:",
|
|
304
|
+
}), await t.removeRefreshToken();
|
|
305
|
+
} catch (r) {
|
|
306
|
+
console.warn("Failed to remove refresh token:", r);
|
|
265
307
|
}
|
|
266
308
|
return s;
|
|
267
309
|
});
|
|
268
|
-
},
|
|
269
|
-
const
|
|
270
|
-
return
|
|
271
|
-
|
|
310
|
+
}, z = (t) => t ? /^\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/logout$/.test(t) : !1, X = (t) => t ? /^\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/(refresh|logout)$/.test(t) : !1, F = (t) => t ? /^\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/refresh$/.test(t) : !1, N = (t) => {
|
|
311
|
+
const a = t.config.url;
|
|
312
|
+
return a ? /^\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/(verify\/(email|sms|siwe|oauth\/.*)|refresh)$/.test(
|
|
313
|
+
a
|
|
272
314
|
) : !1;
|
|
273
|
-
},
|
|
315
|
+
}, W = (t) => {
|
|
274
316
|
if (!n.getUri() || n.getUri() === "")
|
|
275
317
|
throw new Error("CDP client URI not configured. Call configure() first.");
|
|
276
|
-
if (!
|
|
318
|
+
if (!t.url || t.url === "")
|
|
277
319
|
throw new Error("AxiosRequestConfig URL is empty. This should never happen.");
|
|
278
|
-
if (!
|
|
320
|
+
if (!t.method || t.method === "")
|
|
279
321
|
throw new Error("AxiosRequestConfig method is empty. This should never happen.");
|
|
280
|
-
},
|
|
281
|
-
if (!
|
|
322
|
+
}, Z = (t) => t.method?.toString().toUpperCase() || "GET", v = (t) => {
|
|
323
|
+
if (!t.url)
|
|
282
324
|
throw new Error("URL is required for authentication");
|
|
283
|
-
const
|
|
284
|
-
return new URL(
|
|
285
|
-
},
|
|
286
|
-
const
|
|
287
|
-
return
|
|
288
|
-
},
|
|
289
|
-
const
|
|
290
|
-
return
|
|
291
|
-
},
|
|
325
|
+
const e = (t.baseURL ?? n.getUri()) + t.url;
|
|
326
|
+
return new URL(e);
|
|
327
|
+
}, y = (t) => {
|
|
328
|
+
const a = /^(\/platform)?\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/(refresh|logout)$/, e = /^(\/platform)?\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/(mfa)$/, s = /^(\/platform)?\/v2\/embedded-wallet-api\/projects\/[^/]+\/config$/, r = /^(\/platform)?\/v2\/embedded-wallet-api\/projects\/[^/]+\/attestation\/(challenge|register)$/;
|
|
329
|
+
return a.test(t) || e.test(t) || s.test(t) || r.test(t);
|
|
330
|
+
}, B = (t) => !/^(\/platform)?\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/custom\/authenticate$/.test(t), _ = (t) => {
|
|
331
|
+
const a = /^(\/platform)?\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/(init)$/, e = /^(\/platform)?\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/verify\//;
|
|
332
|
+
return a.test(t) || e.test(t);
|
|
333
|
+
}, H = (t) => /^\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/(init$|verify\/|refresh$|logout$)/.test(
|
|
334
|
+
t
|
|
335
|
+
), K = (t) => [
|
|
292
336
|
// Auth flows: prevent account takeover on mobile clients
|
|
293
337
|
/\/auth\/verify\//,
|
|
294
338
|
// VerifyEmailAuthentication, VerifySmsAuthentication, VerifyOAuthCode, VerifyOAuthEndUserIdentity
|
|
295
339
|
/\/auth\/refresh$/
|
|
296
340
|
// RefreshAccessToken
|
|
297
|
-
].some((
|
|
341
|
+
].some((e) => e.test(t));
|
|
298
342
|
export {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
343
|
+
re as cdpApiClient,
|
|
344
|
+
ee as configureCdpApiClient,
|
|
345
|
+
te as setAuthManager,
|
|
346
|
+
M as setCookieDomain
|
|
302
347
|
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3551,6 +3551,14 @@ export declare type ServiceUnavailableErrorResponse = Error_2;
|
|
|
3551
3551
|
*/
|
|
3552
3552
|
export declare const setAuthManager: (manager: AuthManager) => void;
|
|
3553
3553
|
|
|
3554
|
+
/**
|
|
3555
|
+
* Updates the active cookie domain used for first-party auth routing.
|
|
3556
|
+
* Call after fetching project config to enable (non-null) or disable (null) cookie domain routing.
|
|
3557
|
+
*
|
|
3558
|
+
* @param domain - The active cookie domain, or null to route through the default CDP URL.
|
|
3559
|
+
*/
|
|
3560
|
+
export declare const setCookieDomain: (domain: string | null) => void;
|
|
3561
|
+
|
|
3554
3562
|
/**
|
|
3555
3563
|
* Signs a 32-byte sighash using the child key derived from the end user's Bitcoin HD (Hierarchical Deterministic) account at the given child path. The child path [change, address_index] must correspond to the same path used to derive the address that controls the UTXO being spent. One call is required per UTXO input in the transaction.
|
|
3556
3564
|
* @summary Sign a Bitcoin hash with an end user account
|