@coinbase/cdp-api-client 0.0.117 → 0.0.119
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 +87 -89
- package/dist/esm/index10.js +1 -1
- package/dist/esm/index12.js +38 -7
- package/dist/esm/index14.js +67 -358
- package/dist/esm/index15.js +34 -852
- package/dist/esm/index16.js +14 -38
- package/dist/esm/index17.js +8 -2
- package/dist/esm/index18.js +2 -70
- package/dist/esm/index19.js +355 -29
- package/dist/esm/index20.js +852 -14
- package/dist/esm/index3.js +1 -1
- package/dist/esm/index4.js +1 -1
- package/dist/esm/index5.js +13 -20
- package/dist/esm/index6.js +110 -84
- package/dist/types/index.d.ts +32 -28
- package/package.json +1 -1
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/index5.js
CHANGED
|
@@ -142,11 +142,11 @@ const e = {
|
|
|
142
142
|
avalanche: "avalanche",
|
|
143
143
|
ethereum: "ethereum",
|
|
144
144
|
"ethereum-sepolia": "ethereum-sepolia"
|
|
145
|
-
},
|
|
145
|
+
}, f = {
|
|
146
146
|
approved: "approved",
|
|
147
147
|
pending: "pending",
|
|
148
148
|
rejected: "rejected"
|
|
149
|
-
},
|
|
149
|
+
}, b = {
|
|
150
150
|
"base-sepolia": "base-sepolia",
|
|
151
151
|
base: "base",
|
|
152
152
|
arbitrum: "arbitrum",
|
|
@@ -154,13 +154,13 @@ const e = {
|
|
|
154
154
|
polygon: "polygon",
|
|
155
155
|
ethereum: "ethereum",
|
|
156
156
|
"ethereum-sepolia": "ethereum-sepolia"
|
|
157
|
-
},
|
|
157
|
+
}, v = {
|
|
158
158
|
UNSPECIFIED: "UNSPECIFIED",
|
|
159
159
|
PENDING: "PENDING",
|
|
160
160
|
SUBMITTED: "SUBMITTED",
|
|
161
161
|
COMPLETED: "COMPLETED",
|
|
162
162
|
FAILED: "FAILED"
|
|
163
|
-
},
|
|
163
|
+
}, g = {
|
|
164
164
|
pending: "pending",
|
|
165
165
|
signed: "signed",
|
|
166
166
|
broadcast: "broadcast",
|
|
@@ -235,10 +235,10 @@ const e = {
|
|
|
235
235
|
"arbitrum-sepolia": "arbitrum-sepolia",
|
|
236
236
|
world: "world",
|
|
237
237
|
"world-sepolia": "world-sepolia"
|
|
238
|
-
},
|
|
238
|
+
}, D = {
|
|
239
239
|
solana: "solana",
|
|
240
240
|
"solana-devnet": "solana-devnet"
|
|
241
|
-
},
|
|
241
|
+
}, U = {
|
|
242
242
|
solana: "solana",
|
|
243
243
|
"solana-devnet": "solana-devnet"
|
|
244
244
|
}, q = {
|
|
@@ -247,11 +247,6 @@ const e = {
|
|
|
247
247
|
bitcoin: "bitcoin",
|
|
248
248
|
"bitcoin-testnet": "bitcoin-testnet"
|
|
249
249
|
}, M = {
|
|
250
|
-
segwit: "segwit"
|
|
251
|
-
}, k = {
|
|
252
|
-
bitcoin: "bitcoin",
|
|
253
|
-
"bitcoin-testnet": "bitcoin-testnet"
|
|
254
|
-
}, B = {
|
|
255
250
|
NUMBER_0: 0,
|
|
256
251
|
NUMBER_1: 1
|
|
257
252
|
};
|
|
@@ -266,11 +261,11 @@ export {
|
|
|
266
261
|
A as EndUserOnrampFeeType,
|
|
267
262
|
S as EndUserOnrampOrderStatus,
|
|
268
263
|
t as ErrorType,
|
|
269
|
-
|
|
270
|
-
|
|
264
|
+
b as EvmEip7702DelegationNetwork,
|
|
265
|
+
v as EvmEip7702DelegationOperationStatus,
|
|
271
266
|
h as EvmSwapsNetwork,
|
|
272
267
|
y as EvmUserOperationNetwork,
|
|
273
|
-
|
|
268
|
+
g as EvmUserOperationStatus,
|
|
274
269
|
_ as InitiateEmailAuthenticationNextStepType,
|
|
275
270
|
o as InitiateEmailAuthenticationRequestType,
|
|
276
271
|
r as InitiateSiweAuthenticationRequestType,
|
|
@@ -282,15 +277,13 @@ export {
|
|
|
282
277
|
w as MfaMethod,
|
|
283
278
|
T as Network,
|
|
284
279
|
e as OAuth2ProviderType,
|
|
285
|
-
|
|
280
|
+
f as OtpEmailLogoModerationStatus,
|
|
286
281
|
O as RefreshAccessTokenBodyGrantType,
|
|
287
282
|
P as SendEvmAssetWithEndUserAccountBodyNetwork,
|
|
288
283
|
x as SendEvmTransactionWithEndUserAccountBodyNetwork,
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
M as
|
|
292
|
-
B as SignBtcHashWithEndUserAccountBodyChange,
|
|
293
|
-
k as SignBtcHashWithEndUserAccountBodyNetwork,
|
|
284
|
+
U as SendSolanaAssetWithEndUserAccountBodyNetwork,
|
|
285
|
+
D as SendSolanaTransactionWithEndUserAccountBodyNetwork,
|
|
286
|
+
M as SignBtcHashWithEndUserAccountBodyChange,
|
|
294
287
|
p as SiweAuthenticationType,
|
|
295
288
|
l as SmsAuthenticationType,
|
|
296
289
|
E as SpendPermissionNetwork
|
package/dist/esm/index6.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { Analytics as
|
|
1
|
+
import { Analytics as i } from "./index2.js";
|
|
2
2
|
import "./index3.js";
|
|
3
|
-
import
|
|
4
|
-
import { ERROR_DOCS_PAGE_URL as
|
|
5
|
-
import { UnknownApiError as
|
|
6
|
-
const
|
|
7
|
-
let n =
|
|
3
|
+
import p from "axios";
|
|
4
|
+
import { ERROR_DOCS_PAGE_URL as h } from "./index9.js";
|
|
5
|
+
import { UnknownApiError as g, HttpErrorType as d, isOpenAPIError as y, APIError as l, UnknownError as T } from "./index7.js";
|
|
6
|
+
const v = () => typeof window < "u" && typeof document < "u";
|
|
7
|
+
let n = p.create({
|
|
8
8
|
baseURL: "https://api.cdp.coinbase.com/platform"
|
|
9
|
-
}),
|
|
9
|
+
}), c = null;
|
|
10
10
|
const N = (t) => {
|
|
11
|
-
if (n =
|
|
11
|
+
if (n = p.create({
|
|
12
12
|
baseURL: t.basePath || "https://api.cdp.coinbase.com/platform",
|
|
13
13
|
// Only enable cookies in browser environments where they're supported
|
|
14
|
-
withCredentials:
|
|
14
|
+
withCredentials: v()
|
|
15
15
|
}), n.interceptors.request.use(async (r) => {
|
|
16
|
-
const e =
|
|
17
|
-
if (!
|
|
16
|
+
const e = C(r), s = w(r);
|
|
17
|
+
if (!c || _(s.pathname) || A(s.pathname) && !await c.isSignedIn() || !O(s.pathname))
|
|
18
18
|
return r;
|
|
19
|
-
const a = await
|
|
19
|
+
const a = await c.getXWalletAuth({
|
|
20
20
|
requestMethod: e,
|
|
21
21
|
requestHost: s.host,
|
|
22
22
|
requestPath: s.pathname,
|
|
@@ -24,38 +24,38 @@ const N = (t) => {
|
|
|
24
24
|
});
|
|
25
25
|
return a && (r.headers["X-Wallet-Auth"] = a), r;
|
|
26
26
|
}), n.interceptors.request.use(async (r) => {
|
|
27
|
-
const e =
|
|
28
|
-
if (!
|
|
27
|
+
const e = w(r);
|
|
28
|
+
if (!c || _(e.pathname) || A(e.pathname) && !await c.isSignedIn())
|
|
29
29
|
return r;
|
|
30
|
-
const s = await
|
|
30
|
+
const s = await c.getToken();
|
|
31
31
|
return s && s !== "" && (r.headers.Authorization = `Bearer ${s}`), r;
|
|
32
|
-
}), !
|
|
32
|
+
}), !v()) {
|
|
33
33
|
const r = t.platform ? `CDP/reactnative/${t.platform}` : "CDP/reactnative";
|
|
34
34
|
n.interceptors.request.use(async (e) => {
|
|
35
35
|
let s = e.headers["User-Agent"];
|
|
36
36
|
return s = s ? `${s} ${r}` : r, e.headers["User-Agent"] = s, e;
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
-
t.refreshTokenStorage &&
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
},
|
|
39
|
+
t.refreshTokenStorage && U(t.refreshTokenStorage, t.retryTokenReads ?? !1), t.appAttestation && P(t.appAttestation, t.platform), t.debugging && (n.interceptors.request.use((r) => (console.log("Request:", r), r)), n.interceptors.response.use((r) => (console.log("Response:", r), r)));
|
|
40
|
+
}, z = (t) => {
|
|
41
|
+
c = t;
|
|
42
|
+
}, P = (t, r) => {
|
|
43
43
|
n.interceptors.request.use(async (e) => {
|
|
44
|
-
const s =
|
|
45
|
-
if (!
|
|
44
|
+
const s = w(e);
|
|
45
|
+
if (!x(s.pathname) || !t.isEnabled())
|
|
46
46
|
return e;
|
|
47
47
|
try {
|
|
48
48
|
if (r === "ios") {
|
|
49
49
|
const a = s.pathname.match(/\/projects\/([^/]+)\//);
|
|
50
50
|
if (!a || !a[1])
|
|
51
51
|
return e;
|
|
52
|
-
const
|
|
53
|
-
if (!
|
|
52
|
+
const u = `/v2/embedded-wallet-api/projects/${a[1]}/attestation/challenge`, m = (await n.post(u)).data.challenge;
|
|
53
|
+
if (!m)
|
|
54
54
|
return console.warn("Failed to fetch assertion challenge"), e;
|
|
55
|
-
const f = await t.generateAssertion(
|
|
55
|
+
const f = await t.generateAssertion(m);
|
|
56
56
|
if (!f)
|
|
57
57
|
return e;
|
|
58
|
-
e.headers["X-App-Attestation-Assertion"] = f.assertion, e.headers["X-App-Attestation-Key-ID"] = f.keyId, e.headers["X-App-Attestation-Challenge"] =
|
|
58
|
+
e.headers["X-App-Attestation-Assertion"] = f.assertion, e.headers["X-App-Attestation-Key-ID"] = f.keyId, e.headers["X-App-Attestation-Challenge"] = m;
|
|
59
59
|
} else {
|
|
60
60
|
const a = await t.generateAssertion(JSON.stringify(e.data));
|
|
61
61
|
if (!a)
|
|
@@ -69,26 +69,26 @@ const N = (t) => {
|
|
|
69
69
|
);
|
|
70
70
|
}
|
|
71
71
|
});
|
|
72
|
-
},
|
|
72
|
+
}, S = (t, r) => ({
|
|
73
73
|
...t,
|
|
74
74
|
headers: {
|
|
75
75
|
...t.headers || {},
|
|
76
76
|
"X-Idempotency-Key": r
|
|
77
77
|
}
|
|
78
|
-
}),
|
|
79
|
-
|
|
78
|
+
}), H = async (t, r) => {
|
|
79
|
+
j(t), r && r !== "" && (t = S(t, r));
|
|
80
80
|
try {
|
|
81
81
|
return (await n(t)).data;
|
|
82
82
|
} catch (e) {
|
|
83
|
-
if (
|
|
84
|
-
throw new
|
|
85
|
-
|
|
83
|
+
if (p.isAxiosError(e) && !e.response)
|
|
84
|
+
throw new g(
|
|
85
|
+
d.unknown,
|
|
86
86
|
e.cause instanceof Error ? e.cause.message : e.message,
|
|
87
87
|
e.cause
|
|
88
88
|
);
|
|
89
|
-
if (
|
|
90
|
-
if (
|
|
91
|
-
throw new
|
|
89
|
+
if (p.isAxiosError(e) && e.response) {
|
|
90
|
+
if (y(e.response.data))
|
|
91
|
+
throw new l(
|
|
92
92
|
e.response.status,
|
|
93
93
|
e.response.data.errorType,
|
|
94
94
|
e.response.data.errorMessage,
|
|
@@ -100,39 +100,39 @@ const N = (t) => {
|
|
|
100
100
|
const s = e.response.status;
|
|
101
101
|
switch (s) {
|
|
102
102
|
case 401:
|
|
103
|
-
throw new
|
|
103
|
+
throw new l(
|
|
104
104
|
s,
|
|
105
|
-
|
|
105
|
+
d.unauthorized,
|
|
106
106
|
"Unauthorized.",
|
|
107
107
|
void 0,
|
|
108
|
-
`${
|
|
108
|
+
`${h}#unauthorized`,
|
|
109
109
|
e.cause
|
|
110
110
|
);
|
|
111
111
|
case 404:
|
|
112
|
-
throw new
|
|
112
|
+
throw new l(
|
|
113
113
|
s,
|
|
114
|
-
|
|
114
|
+
d.not_found,
|
|
115
115
|
"API not found.",
|
|
116
116
|
void 0,
|
|
117
|
-
`${
|
|
117
|
+
`${h}#not_found`,
|
|
118
118
|
e.cause
|
|
119
119
|
);
|
|
120
120
|
case 502:
|
|
121
|
-
throw new
|
|
121
|
+
throw new l(
|
|
122
122
|
s,
|
|
123
|
-
|
|
123
|
+
d.bad_gateway,
|
|
124
124
|
"Bad gateway.",
|
|
125
125
|
void 0,
|
|
126
|
-
`${
|
|
126
|
+
`${h}`,
|
|
127
127
|
e.cause
|
|
128
128
|
);
|
|
129
129
|
case 503:
|
|
130
|
-
throw new
|
|
130
|
+
throw new l(
|
|
131
131
|
s,
|
|
132
|
-
|
|
132
|
+
d.service_unavailable,
|
|
133
133
|
"Service unavailable. Please try again later.",
|
|
134
134
|
void 0,
|
|
135
|
-
`${
|
|
135
|
+
`${h}`,
|
|
136
136
|
e.cause
|
|
137
137
|
);
|
|
138
138
|
default: {
|
|
@@ -143,53 +143,70 @@ const N = (t) => {
|
|
|
143
143
|
} catch {
|
|
144
144
|
a = String(e.response.data);
|
|
145
145
|
}
|
|
146
|
-
const
|
|
147
|
-
throw new
|
|
146
|
+
const o = a ? `An unexpected error occurred: ${a}` : "An unexpected error occurred.";
|
|
147
|
+
throw new l(
|
|
148
148
|
s,
|
|
149
|
-
|
|
150
|
-
|
|
149
|
+
d.unexpected_error,
|
|
150
|
+
o,
|
|
151
151
|
void 0,
|
|
152
|
-
`${
|
|
152
|
+
`${h}`,
|
|
153
153
|
e.cause
|
|
154
154
|
);
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
-
throw new
|
|
159
|
+
throw new T("Something went wrong.", e instanceof Error ? e : void 0);
|
|
160
160
|
}
|
|
161
|
-
},
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
return { token: r, attempt: e };
|
|
166
|
-
const s = P[e];
|
|
167
|
-
s !== void 0 && await new Promise((a) => setTimeout(a, s));
|
|
161
|
+
}, k = 4, b = [25, 50, 100], E = async (t) => {
|
|
162
|
+
if (t.getRefreshTokenWithOutcome) {
|
|
163
|
+
const { token: r, outcome: e, errorMessage: s } = await t.getRefreshTokenWithOutcome();
|
|
164
|
+
return { token: r, outcome: e, errorMessage: s };
|
|
168
165
|
}
|
|
169
|
-
return { token:
|
|
170
|
-
},
|
|
166
|
+
return { token: await t.getRefreshToken() };
|
|
167
|
+
}, $ = async (t) => {
|
|
168
|
+
let r = null, e, s;
|
|
169
|
+
for (let a = 0; a < k; a++) {
|
|
170
|
+
const o = await E(t);
|
|
171
|
+
if (r = o.token, e = o.outcome, s = o.errorMessage, r)
|
|
172
|
+
return {
|
|
173
|
+
token: r,
|
|
174
|
+
attempt: a,
|
|
175
|
+
outcome: e,
|
|
176
|
+
errorMessage: s
|
|
177
|
+
};
|
|
178
|
+
const u = b[a];
|
|
179
|
+
u !== void 0 && await new Promise((R) => setTimeout(R, u));
|
|
180
|
+
}
|
|
181
|
+
return {
|
|
182
|
+
token: r,
|
|
183
|
+
attempt: k - 1,
|
|
184
|
+
outcome: e,
|
|
185
|
+
errorMessage: s
|
|
186
|
+
};
|
|
187
|
+
}, U = (t, r) => {
|
|
171
188
|
n.interceptors.response.use(
|
|
172
189
|
async (e) => {
|
|
173
190
|
try {
|
|
174
|
-
if (
|
|
175
|
-
|
|
191
|
+
if (q(e)) {
|
|
192
|
+
i.sendSessionRefreshEvent({
|
|
176
193
|
name: "refresh_token_response"
|
|
177
194
|
});
|
|
178
195
|
const s = e.data?.refreshToken;
|
|
179
|
-
s && (
|
|
196
|
+
s && (i.sendSessionRefreshEvent({
|
|
180
197
|
name: "refresh_token_received"
|
|
181
198
|
}), await Promise.race([
|
|
182
199
|
t.setRefreshToken(s),
|
|
183
200
|
new Promise(
|
|
184
|
-
(a,
|
|
201
|
+
(a, o) => setTimeout(() => o(new Error("setRefreshToken timed out after 5000ms")), 5e3)
|
|
185
202
|
)
|
|
186
|
-
]),
|
|
203
|
+
]), i.sendSessionRefreshEvent({
|
|
187
204
|
name: "refresh_token_stored"
|
|
188
205
|
}));
|
|
189
206
|
}
|
|
190
207
|
} catch (s) {
|
|
191
208
|
const a = s instanceof Error ? s.message : String(s);
|
|
192
|
-
|
|
209
|
+
i.sendSessionRefreshEvent({
|
|
193
210
|
name: "refresh_token_store_failed",
|
|
194
211
|
error_message: a
|
|
195
212
|
}), console.warn("Failed to store refresh token:", s);
|
|
@@ -199,55 +216,64 @@ const N = (t) => {
|
|
|
199
216
|
(e) => Promise.reject(e)
|
|
200
217
|
), n.interceptors.request.use(async (e) => {
|
|
201
218
|
try {
|
|
202
|
-
if (
|
|
203
|
-
const {
|
|
204
|
-
|
|
219
|
+
if (M(e.url)) {
|
|
220
|
+
const {
|
|
221
|
+
token: s,
|
|
222
|
+
attempt: a,
|
|
223
|
+
outcome: o,
|
|
224
|
+
errorMessage: u
|
|
225
|
+
} = r ? await $(t) : { ...await E(t), attempt: 0 };
|
|
226
|
+
s ? (i.sendSessionRefreshEvent({
|
|
205
227
|
name: "refresh_token_retrieved",
|
|
206
|
-
attempt: a
|
|
228
|
+
attempt: a,
|
|
229
|
+
read_outcome: o,
|
|
230
|
+
error_message: u
|
|
207
231
|
}), e.data = {
|
|
208
232
|
...e.data,
|
|
209
233
|
refreshToken: s
|
|
210
|
-
}) :
|
|
234
|
+
}) : i.sendSessionRefreshEvent({
|
|
211
235
|
name: "refresh_token_missing",
|
|
212
|
-
attempt: a
|
|
236
|
+
attempt: a,
|
|
237
|
+
read_outcome: o,
|
|
238
|
+
error_message: u
|
|
213
239
|
});
|
|
214
240
|
}
|
|
215
|
-
|
|
241
|
+
I(e.url) && (i.sendSessionRefreshEvent({
|
|
216
242
|
name: "refresh_token_removing_token"
|
|
217
243
|
}), await t.removeRefreshToken());
|
|
218
244
|
} catch (s) {
|
|
219
245
|
const a = s instanceof Error ? s.message : String(s);
|
|
220
|
-
|
|
246
|
+
i.sendSessionRefreshEvent({
|
|
221
247
|
name: "refresh_token_retrieve_failed",
|
|
222
248
|
error_message: a
|
|
223
249
|
}), console.warn("Failed to retrieve refresh token:", s);
|
|
224
250
|
}
|
|
225
251
|
return e;
|
|
226
252
|
});
|
|
227
|
-
},
|
|
253
|
+
}, I = (t) => t ? /^\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/logout$/.test(t) : !1, M = (t) => t ? /^\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/(refresh|logout)$/.test(t) : !1, q = (t) => {
|
|
228
254
|
const r = t.config.url;
|
|
229
255
|
return r ? /^\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/(verify\/(email|sms|siwe|oauth\/.*)|refresh)$/.test(
|
|
230
256
|
r
|
|
231
257
|
) : !1;
|
|
232
|
-
},
|
|
258
|
+
}, j = (t) => {
|
|
233
259
|
if (!n.getUri() || n.getUri() === "")
|
|
234
260
|
throw new Error("CDP client URI not configured. Call configure() first.");
|
|
235
261
|
if (!t.url || t.url === "")
|
|
236
262
|
throw new Error("AxiosRequestConfig URL is empty. This should never happen.");
|
|
237
263
|
if (!t.method || t.method === "")
|
|
238
264
|
throw new Error("AxiosRequestConfig method is empty. This should never happen.");
|
|
239
|
-
},
|
|
265
|
+
}, C = (t) => t.method?.toString().toUpperCase() || "GET", w = (t) => {
|
|
240
266
|
if (!t.url)
|
|
241
267
|
throw new Error("URL is required for authentication");
|
|
242
268
|
const r = n.getUri() + t.url;
|
|
243
269
|
return new URL(r);
|
|
244
|
-
},
|
|
270
|
+
}, _ = (t) => {
|
|
245
271
|
const r = /^\/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$/, a = /^\/platform\/v2\/embedded-wallet-api\/projects\/[^/]+\/attestation\/(challenge|register)$/;
|
|
246
272
|
return r.test(t) || e.test(t) || s.test(t) || a.test(t);
|
|
247
|
-
},
|
|
273
|
+
}, O = (t) => !/^\/platform\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/custom\/authenticate$/.test(t), A = (t) => {
|
|
248
274
|
const r = /^\/platform\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/(init)$/, e = /^\/platform\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/verify\//;
|
|
249
275
|
return r.test(t) || e.test(t);
|
|
250
|
-
},
|
|
276
|
+
}, x = (t) => [
|
|
251
277
|
// Auth flows: prevent account takeover on mobile clients
|
|
252
278
|
/\/auth\/verify\//,
|
|
253
279
|
// VerifyEmailAuthentication, VerifySmsAuthentication, VerifyOAuthCode, VerifyOAuthEndUserIdentity
|
|
@@ -255,7 +281,7 @@ const N = (t) => {
|
|
|
255
281
|
// RefreshAccessToken
|
|
256
282
|
].some((e) => e.test(t));
|
|
257
283
|
export {
|
|
258
|
-
|
|
284
|
+
H as cdpApiClient,
|
|
259
285
|
N as configureCdpApiClient,
|
|
260
|
-
|
|
286
|
+
z as setAuthManager
|
|
261
287
|
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -323,7 +323,7 @@ export declare interface CreateEndUserApplePayOnrampOrderRequest {
|
|
|
323
323
|
export declare type CreateEndUserApplePayOnrampOrderResult = NonNullable<Awaited<ReturnType<typeof createEndUserApplePayOnrampOrder>>>;
|
|
324
324
|
|
|
325
325
|
/**
|
|
326
|
-
* Creates a Bitcoin HD (Hierarchical Deterministic) account for an end user at the given address type and network. Returns the
|
|
326
|
+
* Creates a Bitcoin HD (Hierarchical Deterministic) account for an end user at the given address type and network. Returns the end user with every Bitcoin account's extended public key (`xpub`) populated, used to derive child addresses. End users can have up to 10 Bitcoin accounts, each identified by its `xpubHash`; multiple accounts may share the same address type and network.
|
|
327
327
|
* @summary Create end user Bitcoin HD (Hierarchical Deterministic) account
|
|
328
328
|
*/
|
|
329
329
|
export declare const createEndUserBtcAccount: (userId: string, createEndUserBtcAccountBody: CreateEndUserBtcAccountBody, params?: CreateEndUserBtcAccountParams, options?: SecondParameter<typeof cdpApiClient<EndUser>>) => Promise<EndUser>;
|
|
@@ -850,7 +850,7 @@ export declare interface EndUser {
|
|
|
850
850
|
solanaAccounts: string[];
|
|
851
851
|
/** The list of Solana accounts associated with the end user. End users can have up to 10 Solana accounts. */
|
|
852
852
|
solanaAccountObjects: EndUserSolanaAccount[];
|
|
853
|
-
/** The list of Bitcoin HD (Hierarchical Deterministic) accounts associated with the end user.
|
|
853
|
+
/** The list of Bitcoin HD (Hierarchical Deterministic) accounts associated with the end user. End users can have up to 10 Bitcoin accounts. Each account's `xpub` may be omitted; whether it is returned depends on the operation that produced this end user (see the `xpub` field). */
|
|
854
854
|
btcAccountObjects?: EndUserBtcAccount[];
|
|
855
855
|
/** The date and time when the end user was created, in ISO 8601 format. */
|
|
856
856
|
createdAt: string;
|
|
@@ -867,15 +867,20 @@ export declare interface EndUserApplePayOnrampOrderCreateResponse {
|
|
|
867
867
|
}
|
|
868
868
|
|
|
869
869
|
/**
|
|
870
|
-
* Information about a Bitcoin HD (Hierarchical Deterministic) account associated with an end user. Unlike EVM and Solana accounts, there is no single address
|
|
870
|
+
* Information about a Bitcoin HD (Hierarchical Deterministic) account associated with an end user. Unlike EVM and Solana accounts, there is no single address: the account is identified by `xpubHash`, and the extended public key (xpub), when present, derives child addresses for UTXO discovery.
|
|
871
871
|
*/
|
|
872
872
|
export declare interface EndUserBtcAccount {
|
|
873
873
|
/** The Bitcoin address type and derivation path standard used for this account. */
|
|
874
874
|
addressType: EndUserBtcAccountAddressType;
|
|
875
875
|
/** The Bitcoin network this account is associated with. */
|
|
876
876
|
network: EndUserBtcAccountNetwork;
|
|
877
|
-
/** The BIP-32 extended public key (xpub) at the account derivation path, base58check encoded
|
|
878
|
-
|
|
877
|
+
/** The BIP-32 extended public key (xpub) at the account derivation path, base58check encoded, used to derive child addresses. Present only when the response includes it explicitly (the `createEndUserBtcAccount` response, or `getAuthenticatedEndUser` with `includeBtcXpubs=true`); otherwise omitted. */
|
|
878
|
+
xpub?: string;
|
|
879
|
+
/**
|
|
880
|
+
* The lowercase hex-encoded SHA-256 of the UTF-8 bytes of the `xpub` string (the base58check-encoded form exactly as returned, not the decoded key bytes). Used as a stable identifier to select the proper account during signing. This is intentionally not the BIP-32 key fingerprint: hashing the full string form avoids the fingerprint's 4-byte collision risk and yields an identifier that can be recomputed consistently without decoding the key.
|
|
881
|
+
* @pattern ^[0-9a-f]{64}$
|
|
882
|
+
*/
|
|
883
|
+
xpubHash: string;
|
|
879
884
|
/** The date and time when the account was created, in ISO 8601 format. */
|
|
880
885
|
createdAt: string;
|
|
881
886
|
}
|
|
@@ -1443,6 +1448,10 @@ export declare type GetAuthenticatedEndUserParams = {
|
|
|
1443
1448
|
* @pattern ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
|
|
1444
1449
|
*/
|
|
1445
1450
|
projectID?: ProjectIDOptionalParameter;
|
|
1451
|
+
/**
|
|
1452
|
+
* When `true`, each Bitcoin account in `btcAccountObjects` includes its raw `xpub`. When `false` (the default), only `xpubHash` is returned.
|
|
1453
|
+
*/
|
|
1454
|
+
includeBtcXpubs?: boolean;
|
|
1446
1455
|
};
|
|
1447
1456
|
|
|
1448
1457
|
export declare type GetAuthenticatedEndUserResult = NonNullable<Awaited<ReturnType<typeof getAuthenticatedEndUser>>>;
|
|
@@ -2540,6 +2549,19 @@ export declare type RefreshAccessTokenResult = NonNullable<Awaited<ReturnType<ty
|
|
|
2540
2549
|
export declare interface RefreshTokenStorage {
|
|
2541
2550
|
/** Retrieves the stored refresh token. */
|
|
2542
2551
|
getRefreshToken(): Promise<string | null>;
|
|
2552
|
+
/**
|
|
2553
|
+
* Retrieves the stored refresh token with read outcome metadata.
|
|
2554
|
+
*
|
|
2555
|
+
* @returns Promise that resolves to the stored token and read outcome.
|
|
2556
|
+
*/
|
|
2557
|
+
getRefreshTokenWithOutcome?(): Promise<{
|
|
2558
|
+
/** The stored refresh token, or null if not found or on error. */
|
|
2559
|
+
token: string | null;
|
|
2560
|
+
/** The outcome of the read: found, not found, or error. */
|
|
2561
|
+
outcome: "found" | "not_found" | "error";
|
|
2562
|
+
/** The error message when the read failed. */
|
|
2563
|
+
errorMessage?: string;
|
|
2564
|
+
}>;
|
|
2543
2565
|
/** Stores a refresh token securely. */
|
|
2544
2566
|
setRefreshToken(token: string): Promise<void>;
|
|
2545
2567
|
/** Removes the stored refresh token. */
|
|
@@ -3105,10 +3127,6 @@ export declare type SignBtcHashWithEndUserAccountBody = {
|
|
|
3105
3127
|
* @pattern ^[a-zA-Z0-9-]{1,100}$
|
|
3106
3128
|
*/
|
|
3107
3129
|
walletSecretId: string;
|
|
3108
|
-
/** The Bitcoin address type of the account to sign with. */
|
|
3109
|
-
addressType: SignBtcHashWithEndUserAccountBodyAddressType;
|
|
3110
|
-
/** The Bitcoin network of the account to sign with. */
|
|
3111
|
-
network: SignBtcHashWithEndUserAccountBodyNetwork;
|
|
3112
3130
|
/** The BIP-32 change level index. 0 for external (receive) addresses, 1 for internal (change) addresses, as defined by BIP-44. */
|
|
3113
3131
|
change: SignBtcHashWithEndUserAccountBodyChange;
|
|
3114
3132
|
/**
|
|
@@ -3122,15 +3140,11 @@ export declare type SignBtcHashWithEndUserAccountBody = {
|
|
|
3122
3140
|
* @pattern ^[0-9a-fA-F]{64}$
|
|
3123
3141
|
*/
|
|
3124
3142
|
hash: string;
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
export declare type SignBtcHashWithEndUserAccountBodyAddressType = (typeof SignBtcHashWithEndUserAccountBodyAddressType)[keyof typeof SignBtcHashWithEndUserAccountBodyAddressType];
|
|
3131
|
-
|
|
3132
|
-
export declare const SignBtcHashWithEndUserAccountBodyAddressType: {
|
|
3133
|
-
readonly segwit: "segwit";
|
|
3143
|
+
/**
|
|
3144
|
+
* The lowercase hex-encoded SHA-256 of the UTF-8 bytes of the `xpub` string (the base58check-encoded form exactly as returned, not the decoded key bytes). Selects which of the end user's Bitcoin accounts signs. Use the `xpubHash` returned with the account when it is created or retrieved.
|
|
3145
|
+
* @pattern ^[0-9a-f]{64}$
|
|
3146
|
+
*/
|
|
3147
|
+
xpubHash: string;
|
|
3134
3148
|
};
|
|
3135
3149
|
|
|
3136
3150
|
/**
|
|
@@ -3143,16 +3157,6 @@ export declare const SignBtcHashWithEndUserAccountBodyChange: {
|
|
|
3143
3157
|
readonly NUMBER_1: 1;
|
|
3144
3158
|
};
|
|
3145
3159
|
|
|
3146
|
-
/**
|
|
3147
|
-
* The Bitcoin network of the account to sign with.
|
|
3148
|
-
*/
|
|
3149
|
-
export declare type SignBtcHashWithEndUserAccountBodyNetwork = (typeof SignBtcHashWithEndUserAccountBodyNetwork)[keyof typeof SignBtcHashWithEndUserAccountBodyNetwork];
|
|
3150
|
-
|
|
3151
|
-
export declare const SignBtcHashWithEndUserAccountBodyNetwork: {
|
|
3152
|
-
readonly bitcoin: "bitcoin";
|
|
3153
|
-
readonly "bitcoin-testnet": "bitcoin-testnet";
|
|
3154
|
-
};
|
|
3155
|
-
|
|
3156
3160
|
export declare type SignBtcHashWithEndUserAccountParams = {
|
|
3157
3161
|
/**
|
|
3158
3162
|
* The ID of the CDP Project. Required for end users authenticated using custom auth (i.e. a non-CDP JWT provider).
|