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