@coinbase/cdp-api-client 0.0.118 → 0.0.120
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 -86
- package/dist/esm/index14.js +1 -1
- package/dist/esm/index15.js +1 -1
- package/dist/esm/index18.js +1 -1
- package/dist/esm/index21.js +2 -2
- package/dist/esm/index22.js +2 -2
- package/dist/esm/index23.js +2 -2
- package/dist/esm/index4.js +1 -1
- package/dist/esm/index5.js +13 -20
- package/dist/esm/index6.js +186 -171
- package/dist/esm/index7.js +31 -8
- package/dist/types/index.d.ts +82 -28
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -1,113 +1,114 @@
|
|
|
1
1
|
import { Analytics as e } from "./index2.js";
|
|
2
2
|
import "./index3.js";
|
|
3
3
|
import { VERSION as t } from "./index4.js";
|
|
4
|
-
import { CapabilityName as s, CreateEndUserBtcAccountBodyAddressType as c, CreateEndUserBtcAccountBodyNetwork as
|
|
5
|
-
import { configureCdpApiClient as
|
|
6
|
-
import { APIError as
|
|
7
|
-
import { authenticateUserWithCustomAuth as
|
|
4
|
+
import { CapabilityName as s, CreateEndUserBtcAccountBodyAddressType as c, CreateEndUserBtcAccountBodyNetwork as E, DeveloperJWTAuthenticationType as d, EmailAuthenticationType as A, EndUserBtcAccountAddressType as u, EndUserBtcAccountNetwork as p, EndUserOnrampFeeType as m, EndUserOnrampOrderStatus as h, ErrorType as l, EvmEip7702DelegationNetwork as U, EvmEip7702DelegationOperationStatus as g, EvmSwapsNetwork as S, EvmUserOperationNetwork as y, EvmUserOperationStatus as v, InitiateEmailAuthenticationNextStepType as T, InitiateEmailAuthenticationRequestType as f, InitiateSiweAuthenticationRequestType as W, InitiateSmsAuthenticationNextStepType as k, InitiateSmsAuthenticationRequestType as O, InitiateSmsMfaEnrollmentType as w, InitiateTotpMfaEnrollmentType as B, IosAttestationRegistrationResponsePlatform as M, MfaMethod as N, Network as P, OAuth2ProviderType as C, OtpEmailLogoModerationStatus as I, RefreshAccessTokenBodyGrantType as D, SendEvmAssetWithEndUserAccountBodyNetwork as R, SendEvmTransactionWithEndUserAccountBodyNetwork as b, SendSolanaAssetWithEndUserAccountBodyNetwork as x, SendSolanaTransactionWithEndUserAccountBodyNetwork as F, SignBtcHashWithEndUserAccountBodyChange as H, SiweAuthenticationType as V, SmsAuthenticationType as q, SpendPermissionNetwork as j } from "./index5.js";
|
|
5
|
+
import { configureCdpApiClient as J, setAuthManager as L } from "./index6.js";
|
|
6
|
+
import { APIError as z, HttpErrorType as K, RefreshTokenUnavailableError as Q, UnknownApiError as X, UnknownError as Y, isOpenAPIError as Z, isRefreshTokenUnavailableError as $, isTransientTokenReadError as ee } from "./index7.js";
|
|
7
|
+
import { authenticateUserWithCustomAuth as ne, createDelegationForEndUser as re, createDelegationForEndUserAccount as ie, createEndUserApplePayOnrampOrder as oe, createEndUserBtcAccount as ae, createEndUserEvmAccount as se, createEndUserEvmSmartAccount as ce, createEndUserEvmSwap as Ee, createEndUserSolanaAccount as de, createEvmEip7702DelegationWithEndUserAccount as Ae, createSpendPermissionWithEndUserAccount as ue, enableSpendPermissionWithEndUserAccount as pe, exportEndUserEvmAccount as me, exportEndUserSolanaAccount as he, generateAttestationChallenge as le, getAuthenticatedEndUser as Ue, getDelegationForEndUser as ge, getDelegationForEndUserAccount as Se, getEndUserEvmSwapPrice as ye, getEvmEip7702DelegationOperationByIdWithEndUserAccount as ve, getMfaConfig as Te, getProjectConfig as fe, getUserOperationWithEndUserAccount as We, initiateAuthentication as ke, initiateMfaEnrollment as Oe, initiateMfaEnrollment2 as we, initiateMfaVerification as Be, listSpendPermissionsWithEndUserAccount as Me, logOutEndUser as Ne, receiveOAuthCallback as Pe, receiveOAuthCallbackPost as Ce, recordMfaEnrollmentPrompted as Ie, refreshAccessToken as De, registerAttestation as Re, registerTemporaryWalletSecret as be, revokeDelegationForEndUser as xe, revokeDelegationForEndUserAccount as Fe, revokeSpendPermissionWithEndUserAccount as He, sendEvmAssetWithEndUserAccount as Ve, sendEvmTransactionWithEndUserAccount as qe, sendSolanaAssetWithEndUserAccount as je, sendSolanaTransactionWithEndUserAccount as Ge, sendUserOperationWithEndUserAccount as Je, signBtcHashWithEndUserAccount as Le, signEvmHashWithEndUserAccount as _e, signEvmMessageWithEndUserAccount as ze, signEvmTransactionWithEndUserAccount as Ke, signEvmTypedDataWithEndUserAccount as Qe, signSolanaHashWithEndUserAccount as Xe, signSolanaMessageWithEndUserAccount as Ye, signSolanaTransactionWithEndUserAccount as Ze, submitMfaEnrollment as $e, submitMfaVerification as et, verifyEmailAuthentication as tt, verifyOAuthCode as nt, verifyOAuthEndUserIdentity as rt, verifySiweAuthentication as it, verifySmsAuthentication as ot } from "./index8.js";
|
|
8
8
|
e.registerPackageVersion("api_client", t);
|
|
9
9
|
export {
|
|
10
|
-
|
|
10
|
+
z as APIError,
|
|
11
11
|
s as CapabilityName,
|
|
12
12
|
c as CreateEndUserBtcAccountBodyAddressType,
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
E as CreateEndUserBtcAccountBodyNetwork,
|
|
14
|
+
d as DeveloperJWTAuthenticationType,
|
|
15
15
|
A as EmailAuthenticationType,
|
|
16
16
|
u as EndUserBtcAccountAddressType,
|
|
17
17
|
p as EndUserBtcAccountNetwork,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
m as EndUserOnrampFeeType,
|
|
19
|
+
h as EndUserOnrampOrderStatus,
|
|
20
|
+
l as ErrorType,
|
|
21
|
+
U as EvmEip7702DelegationNetwork,
|
|
22
22
|
g as EvmEip7702DelegationOperationStatus,
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
S as EvmSwapsNetwork,
|
|
24
|
+
y as EvmUserOperationNetwork,
|
|
25
25
|
v as EvmUserOperationStatus,
|
|
26
|
-
|
|
26
|
+
K as HttpErrorType,
|
|
27
27
|
T as InitiateEmailAuthenticationNextStepType,
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
f as InitiateEmailAuthenticationRequestType,
|
|
29
|
+
W as InitiateSiweAuthenticationRequestType,
|
|
30
30
|
k as InitiateSmsAuthenticationNextStepType,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
O as InitiateSmsAuthenticationRequestType,
|
|
32
|
+
w as InitiateSmsMfaEnrollmentType,
|
|
33
|
+
B as InitiateTotpMfaEnrollmentType,
|
|
34
|
+
M as IosAttestationRegistrationResponsePlatform,
|
|
35
|
+
N as MfaMethod,
|
|
36
36
|
P as Network,
|
|
37
37
|
C as OAuth2ProviderType,
|
|
38
38
|
I as OtpEmailLogoModerationStatus,
|
|
39
39
|
D as RefreshAccessTokenBodyGrantType,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
Y as
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
ce as createEndUserEvmSwap,
|
|
40
|
+
Q as RefreshTokenUnavailableError,
|
|
41
|
+
R as SendEvmAssetWithEndUserAccountBodyNetwork,
|
|
42
|
+
b as SendEvmTransactionWithEndUserAccountBodyNetwork,
|
|
43
|
+
x as SendSolanaAssetWithEndUserAccountBodyNetwork,
|
|
44
|
+
F as SendSolanaTransactionWithEndUserAccountBodyNetwork,
|
|
45
|
+
H as SignBtcHashWithEndUserAccountBodyChange,
|
|
46
|
+
V as SiweAuthenticationType,
|
|
47
|
+
q as SmsAuthenticationType,
|
|
48
|
+
j as SpendPermissionNetwork,
|
|
49
|
+
X as UnknownApiError,
|
|
50
|
+
Y as UnknownError,
|
|
51
|
+
ne as authenticateUserWithCustomAuth,
|
|
52
|
+
J as configureCdpApiClient,
|
|
53
|
+
re as createDelegationForEndUser,
|
|
54
|
+
ie as createDelegationForEndUserAccount,
|
|
55
|
+
oe as createEndUserApplePayOnrampOrder,
|
|
56
|
+
ae as createEndUserBtcAccount,
|
|
57
|
+
se as createEndUserEvmAccount,
|
|
58
|
+
ce as createEndUserEvmSmartAccount,
|
|
59
|
+
Ee as createEndUserEvmSwap,
|
|
61
60
|
de as createEndUserSolanaAccount,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
Ae as createEvmEip7702DelegationWithEndUserAccount,
|
|
62
|
+
ue as createSpendPermissionWithEndUserAccount,
|
|
63
|
+
pe as enableSpendPermissionWithEndUserAccount,
|
|
64
|
+
me as exportEndUserEvmAccount,
|
|
66
65
|
he as exportEndUserSolanaAccount,
|
|
67
|
-
|
|
66
|
+
le as generateAttestationChallenge,
|
|
68
67
|
Ue as getAuthenticatedEndUser,
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
ge as getDelegationForEndUser,
|
|
69
|
+
Se as getDelegationForEndUserAccount,
|
|
71
70
|
ye as getEndUserEvmSwapPrice,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
ve as getEvmEip7702DelegationOperationByIdWithEndUserAccount,
|
|
72
|
+
Te as getMfaConfig,
|
|
73
|
+
fe as getProjectConfig,
|
|
75
74
|
We as getUserOperationWithEndUserAccount,
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
ke as initiateAuthentication,
|
|
76
|
+
Oe as initiateMfaEnrollment,
|
|
78
77
|
we as initiateMfaEnrollment2,
|
|
79
78
|
Be as initiateMfaVerification,
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
Z as isOpenAPIError,
|
|
80
|
+
$ as isRefreshTokenUnavailableError,
|
|
81
|
+
ee as isTransientTokenReadError,
|
|
82
|
+
Me as listSpendPermissionsWithEndUserAccount,
|
|
82
83
|
Ne as logOutEndUser,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
84
|
+
Pe as receiveOAuthCallback,
|
|
85
|
+
Ce as receiveOAuthCallbackPost,
|
|
86
|
+
Ie as recordMfaEnrollmentPrompted,
|
|
87
|
+
De as refreshAccessToken,
|
|
88
|
+
Re as registerAttestation,
|
|
89
|
+
be as registerTemporaryWalletSecret,
|
|
90
|
+
xe as revokeDelegationForEndUser,
|
|
91
|
+
Fe as revokeDelegationForEndUserAccount,
|
|
92
|
+
He as revokeSpendPermissionWithEndUserAccount,
|
|
93
|
+
Ve as sendEvmAssetWithEndUserAccount,
|
|
94
|
+
qe as sendEvmTransactionWithEndUserAccount,
|
|
95
|
+
je as sendSolanaAssetWithEndUserAccount,
|
|
96
|
+
Ge as sendSolanaTransactionWithEndUserAccount,
|
|
97
|
+
Je as sendUserOperationWithEndUserAccount,
|
|
98
|
+
L as setAuthManager,
|
|
99
|
+
Le as signBtcHashWithEndUserAccount,
|
|
100
|
+
_e as signEvmHashWithEndUserAccount,
|
|
101
|
+
ze as signEvmMessageWithEndUserAccount,
|
|
102
|
+
Ke as signEvmTransactionWithEndUserAccount,
|
|
103
|
+
Qe as signEvmTypedDataWithEndUserAccount,
|
|
104
|
+
Xe as signSolanaHashWithEndUserAccount,
|
|
105
|
+
Ye as signSolanaMessageWithEndUserAccount,
|
|
106
|
+
Ze as signSolanaTransactionWithEndUserAccount,
|
|
107
|
+
$e as submitMfaEnrollment,
|
|
108
|
+
et as submitMfaVerification,
|
|
109
|
+
tt as verifyEmailAuthentication,
|
|
110
|
+
nt as verifyOAuthCode,
|
|
111
|
+
rt as verifyOAuthEndUserIdentity,
|
|
112
|
+
it as verifySiweAuthentication,
|
|
113
|
+
ot as verifySmsAuthentication
|
|
113
114
|
};
|
package/dist/esm/index14.js
CHANGED
package/dist/esm/index15.js
CHANGED
package/dist/esm/index18.js
CHANGED
package/dist/esm/index21.js
CHANGED
package/dist/esm/index22.js
CHANGED
package/dist/esm/index23.js
CHANGED
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,287 +1,302 @@
|
|
|
1
|
-
import { Analytics as
|
|
1
|
+
import { Analytics as d } 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 w from "axios";
|
|
4
|
+
import { ERROR_DOCS_PAGE_URL as m } from "./index9.js";
|
|
5
|
+
import { isRefreshTokenUnavailableError as y, UnknownApiError as T, HttpErrorType as p, isOpenAPIError as P, APIError as f, UnknownError as S, RefreshTokenUnavailableError as v } from "./index7.js";
|
|
6
|
+
const k = () => typeof window < "u" && typeof document < "u";
|
|
7
|
+
let n = w.create({
|
|
8
8
|
baseURL: "https://api.cdp.coinbase.com/platform"
|
|
9
|
-
}),
|
|
10
|
-
const
|
|
11
|
-
if (n =
|
|
12
|
-
baseURL:
|
|
9
|
+
}), h = null;
|
|
10
|
+
const B = (e) => {
|
|
11
|
+
if (n = w.create({
|
|
12
|
+
baseURL: e.basePath || "https://api.cdp.coinbase.com/platform",
|
|
13
13
|
// Only enable cookies in browser environments where they're supported
|
|
14
|
-
withCredentials:
|
|
14
|
+
withCredentials: k()
|
|
15
15
|
}), n.interceptors.request.use(async (r) => {
|
|
16
|
-
const
|
|
17
|
-
if (!
|
|
16
|
+
const t = L(r), s = R(r);
|
|
17
|
+
if (!h || _(s.pathname) || A(s.pathname) && !await h.isSignedIn() || !X(s.pathname))
|
|
18
18
|
return r;
|
|
19
|
-
const a = await
|
|
20
|
-
requestMethod:
|
|
19
|
+
const a = await h.getXWalletAuth({
|
|
20
|
+
requestMethod: t,
|
|
21
21
|
requestHost: s.host,
|
|
22
22
|
requestPath: s.pathname,
|
|
23
23
|
requestData: r.data
|
|
24
24
|
});
|
|
25
25
|
return a && (r.headers["X-Wallet-Auth"] = a), r;
|
|
26
26
|
}), n.interceptors.request.use(async (r) => {
|
|
27
|
-
const
|
|
28
|
-
if (!
|
|
27
|
+
const t = R(r);
|
|
28
|
+
if (!h || _(t.pathname) || A(t.pathname) && !await h.isSignedIn())
|
|
29
29
|
return r;
|
|
30
|
-
const s = await
|
|
30
|
+
const s = await h.getToken();
|
|
31
31
|
return s && s !== "" && (r.headers.Authorization = `Bearer ${s}`), r;
|
|
32
|
-
}), !
|
|
33
|
-
const r =
|
|
34
|
-
n.interceptors.request.use(async (
|
|
35
|
-
let s =
|
|
36
|
-
return s = s ? `${s} ${r}` : r,
|
|
32
|
+
}), !k()) {
|
|
33
|
+
const r = e.platform ? `CDP/reactnative/${e.platform}` : "CDP/reactnative";
|
|
34
|
+
n.interceptors.request.use(async (t) => {
|
|
35
|
+
let s = t.headers["User-Agent"];
|
|
36
|
+
return s = s ? `${s} ${r}` : r, t.headers["User-Agent"] = s, t;
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
n.interceptors.request.use(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
39
|
+
e.refreshTokenStorage && I(
|
|
40
|
+
e.refreshTokenStorage,
|
|
41
|
+
e.retryTokenReads ?? !1,
|
|
42
|
+
e.failClosedOnMissingToken ?? !1
|
|
43
|
+
), e.appAttestation && b(e.appAttestation, e.platform), e.debugging && (n.interceptors.request.use((r) => (console.log("Request:", r), r)), n.interceptors.response.use((r) => (console.log("Response:", r), r)));
|
|
44
|
+
}, K = (e) => {
|
|
45
|
+
h = e;
|
|
46
|
+
}, b = (e, r) => {
|
|
47
|
+
n.interceptors.request.use(async (t) => {
|
|
48
|
+
const s = R(t);
|
|
49
|
+
if (!D(s.pathname) || !e.isEnabled())
|
|
50
|
+
return t;
|
|
47
51
|
try {
|
|
48
52
|
if (r === "ios") {
|
|
49
53
|
const a = s.pathname.match(/\/projects\/([^/]+)\//);
|
|
50
54
|
if (!a || !a[1])
|
|
51
|
-
return
|
|
52
|
-
const
|
|
53
|
-
if (!
|
|
54
|
-
return console.warn("Failed to fetch assertion challenge"),
|
|
55
|
-
const
|
|
56
|
-
if (!
|
|
57
|
-
return
|
|
58
|
-
|
|
55
|
+
return t;
|
|
56
|
+
const l = `/v2/embedded-wallet-api/projects/${a[1]}/attestation/challenge`, u = (await n.post(l)).data.challenge;
|
|
57
|
+
if (!u)
|
|
58
|
+
return console.warn("Failed to fetch assertion challenge"), t;
|
|
59
|
+
const i = await e.generateAssertion(u);
|
|
60
|
+
if (!i)
|
|
61
|
+
return t;
|
|
62
|
+
t.headers["X-App-Attestation-Assertion"] = i.assertion, t.headers["X-App-Attestation-Key-ID"] = i.keyId, t.headers["X-App-Attestation-Challenge"] = u;
|
|
59
63
|
} else {
|
|
60
|
-
const a = await
|
|
64
|
+
const a = await e.generateAssertion(JSON.stringify(t.data));
|
|
61
65
|
if (!a)
|
|
62
|
-
return
|
|
63
|
-
|
|
66
|
+
return t;
|
|
67
|
+
t.headers["X-Integrity-Token"] = a.assertion, t.headers["X-Package-Name"] = e.appIdentifier;
|
|
64
68
|
}
|
|
65
|
-
return
|
|
69
|
+
return t;
|
|
66
70
|
} catch (a) {
|
|
67
71
|
throw new Error(
|
|
68
72
|
`App attestation required but assertion generation failed: ${a instanceof Error ? a.message : String(a)}`
|
|
69
73
|
);
|
|
70
74
|
}
|
|
71
75
|
});
|
|
72
|
-
},
|
|
73
|
-
...
|
|
76
|
+
}, $ = (e, r) => ({
|
|
77
|
+
...e,
|
|
74
78
|
headers: {
|
|
75
|
-
...
|
|
79
|
+
...e.headers || {},
|
|
76
80
|
"X-Idempotency-Key": r
|
|
77
81
|
}
|
|
78
|
-
}),
|
|
79
|
-
|
|
82
|
+
}), G = async (e, r) => {
|
|
83
|
+
x(e), r && r !== "" && (e = $(e, r));
|
|
80
84
|
try {
|
|
81
|
-
return (await n(
|
|
82
|
-
} catch (
|
|
83
|
-
if (
|
|
84
|
-
throw
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
return (await n(e)).data;
|
|
86
|
+
} catch (t) {
|
|
87
|
+
if (y(t))
|
|
88
|
+
throw t;
|
|
89
|
+
if (w.isAxiosError(t) && !t.response)
|
|
90
|
+
throw new T(
|
|
91
|
+
p.unknown,
|
|
92
|
+
t.cause instanceof Error ? t.cause.message : t.message,
|
|
93
|
+
t.cause
|
|
88
94
|
);
|
|
89
|
-
if (
|
|
90
|
-
if (
|
|
91
|
-
throw new
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
if (w.isAxiosError(t) && t.response) {
|
|
96
|
+
if (P(t.response.data))
|
|
97
|
+
throw new f(
|
|
98
|
+
t.response.status,
|
|
99
|
+
t.response.data.errorType,
|
|
100
|
+
t.response.data.errorMessage,
|
|
101
|
+
t.response.data.correlationId,
|
|
102
|
+
t.response.data.errorLink,
|
|
103
|
+
t.cause
|
|
98
104
|
);
|
|
99
105
|
{
|
|
100
|
-
const s =
|
|
106
|
+
const s = t.response.status;
|
|
101
107
|
switch (s) {
|
|
102
108
|
case 401:
|
|
103
|
-
throw new
|
|
109
|
+
throw new f(
|
|
104
110
|
s,
|
|
105
|
-
|
|
111
|
+
p.unauthorized,
|
|
106
112
|
"Unauthorized.",
|
|
107
113
|
void 0,
|
|
108
|
-
`${
|
|
109
|
-
|
|
114
|
+
`${m}#unauthorized`,
|
|
115
|
+
t.cause
|
|
110
116
|
);
|
|
111
117
|
case 404:
|
|
112
|
-
throw new
|
|
118
|
+
throw new f(
|
|
113
119
|
s,
|
|
114
|
-
|
|
120
|
+
p.not_found,
|
|
115
121
|
"API not found.",
|
|
116
122
|
void 0,
|
|
117
|
-
`${
|
|
118
|
-
|
|
123
|
+
`${m}#not_found`,
|
|
124
|
+
t.cause
|
|
119
125
|
);
|
|
120
126
|
case 502:
|
|
121
|
-
throw new
|
|
127
|
+
throw new f(
|
|
122
128
|
s,
|
|
123
|
-
|
|
129
|
+
p.bad_gateway,
|
|
124
130
|
"Bad gateway.",
|
|
125
131
|
void 0,
|
|
126
|
-
`${
|
|
127
|
-
|
|
132
|
+
`${m}`,
|
|
133
|
+
t.cause
|
|
128
134
|
);
|
|
129
135
|
case 503:
|
|
130
|
-
throw new
|
|
136
|
+
throw new f(
|
|
131
137
|
s,
|
|
132
|
-
|
|
138
|
+
p.service_unavailable,
|
|
133
139
|
"Service unavailable. Please try again later.",
|
|
134
140
|
void 0,
|
|
135
|
-
`${
|
|
136
|
-
|
|
141
|
+
`${m}`,
|
|
142
|
+
t.cause
|
|
137
143
|
);
|
|
138
144
|
default: {
|
|
139
145
|
let a = "";
|
|
140
|
-
if (
|
|
146
|
+
if (t.response.data)
|
|
141
147
|
try {
|
|
142
|
-
a = JSON.stringify(
|
|
148
|
+
a = JSON.stringify(t.response.data);
|
|
143
149
|
} catch {
|
|
144
|
-
a = String(
|
|
150
|
+
a = String(t.response.data);
|
|
145
151
|
}
|
|
146
152
|
const o = a ? `An unexpected error occurred: ${a}` : "An unexpected error occurred.";
|
|
147
|
-
throw new
|
|
153
|
+
throw new f(
|
|
148
154
|
s,
|
|
149
|
-
|
|
155
|
+
p.unexpected_error,
|
|
150
156
|
o,
|
|
151
157
|
void 0,
|
|
152
|
-
`${
|
|
153
|
-
|
|
158
|
+
`${m}`,
|
|
159
|
+
t.cause
|
|
154
160
|
);
|
|
155
161
|
}
|
|
156
162
|
}
|
|
157
163
|
}
|
|
158
164
|
}
|
|
159
|
-
throw new
|
|
165
|
+
throw new S("Something went wrong.", t instanceof Error ? t : void 0);
|
|
160
166
|
}
|
|
161
|
-
},
|
|
162
|
-
if (
|
|
163
|
-
const { token: r, outcome:
|
|
164
|
-
return { token: r, outcome:
|
|
167
|
+
}, E = 4, U = [25, 50, 100], g = async (e) => {
|
|
168
|
+
if (e.getRefreshTokenWithOutcome) {
|
|
169
|
+
const { token: r, outcome: t, errorMessage: s } = await e.getRefreshTokenWithOutcome();
|
|
170
|
+
return { token: r, outcome: t, errorMessage: s };
|
|
165
171
|
}
|
|
166
|
-
return { token: await
|
|
167
|
-
},
|
|
168
|
-
let r = null,
|
|
169
|
-
for (let a = 0; a <
|
|
170
|
-
const o = await
|
|
171
|
-
if (r = o.token,
|
|
172
|
+
return { token: await e.getRefreshToken() };
|
|
173
|
+
}, q = async (e) => {
|
|
174
|
+
let r = null, t, s;
|
|
175
|
+
for (let a = 0; a < E; a++) {
|
|
176
|
+
const o = await g(e);
|
|
177
|
+
if (r = o.token, t = o.outcome, s = o.errorMessage, r)
|
|
172
178
|
return {
|
|
173
179
|
token: r,
|
|
174
180
|
attempt: a,
|
|
175
|
-
outcome:
|
|
181
|
+
outcome: t,
|
|
176
182
|
errorMessage: s
|
|
177
183
|
};
|
|
178
|
-
const
|
|
179
|
-
|
|
184
|
+
const l = U[a];
|
|
185
|
+
l !== void 0 && await new Promise((c) => setTimeout(c, l));
|
|
180
186
|
}
|
|
181
187
|
return {
|
|
182
188
|
token: r,
|
|
183
|
-
attempt:
|
|
184
|
-
outcome:
|
|
189
|
+
attempt: E - 1,
|
|
190
|
+
outcome: t,
|
|
185
191
|
errorMessage: s
|
|
186
192
|
};
|
|
187
|
-
},
|
|
193
|
+
}, I = (e, r, t) => {
|
|
188
194
|
n.interceptors.response.use(
|
|
189
|
-
async (
|
|
195
|
+
async (s) => {
|
|
190
196
|
try {
|
|
191
|
-
if (
|
|
192
|
-
|
|
197
|
+
if (O(s)) {
|
|
198
|
+
d.sendSessionRefreshEvent({
|
|
193
199
|
name: "refresh_token_response"
|
|
194
200
|
});
|
|
195
|
-
const
|
|
196
|
-
|
|
201
|
+
const a = s.data?.refreshToken;
|
|
202
|
+
a && (d.sendSessionRefreshEvent({
|
|
197
203
|
name: "refresh_token_received"
|
|
198
204
|
}), await Promise.race([
|
|
199
|
-
|
|
205
|
+
e.setRefreshToken(a),
|
|
200
206
|
new Promise(
|
|
201
|
-
(
|
|
207
|
+
(o, l) => setTimeout(() => l(new Error("setRefreshToken timed out after 5000ms")), 5e3)
|
|
202
208
|
)
|
|
203
|
-
]),
|
|
209
|
+
]), d.sendSessionRefreshEvent({
|
|
204
210
|
name: "refresh_token_stored"
|
|
205
211
|
}));
|
|
206
212
|
}
|
|
207
|
-
} catch (
|
|
208
|
-
const
|
|
209
|
-
|
|
213
|
+
} catch (a) {
|
|
214
|
+
const o = a instanceof Error ? a.message : String(a);
|
|
215
|
+
d.sendSessionRefreshEvent({
|
|
210
216
|
name: "refresh_token_store_failed",
|
|
211
|
-
error_message:
|
|
212
|
-
}), console.warn("Failed to store refresh token:",
|
|
217
|
+
error_message: o
|
|
218
|
+
}), console.warn("Failed to store refresh token:", a);
|
|
213
219
|
}
|
|
214
|
-
return
|
|
220
|
+
return s;
|
|
215
221
|
},
|
|
216
|
-
(
|
|
217
|
-
), n.interceptors.request.use(async (
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
name: "refresh_token_retrieved",
|
|
228
|
-
attempt: a,
|
|
229
|
-
read_outcome: o,
|
|
230
|
-
error_message: u
|
|
231
|
-
}), e.data = {
|
|
232
|
-
...e.data,
|
|
233
|
-
refreshToken: s
|
|
234
|
-
}) : i.sendSessionRefreshEvent({
|
|
235
|
-
name: "refresh_token_missing",
|
|
236
|
-
attempt: a,
|
|
237
|
-
read_outcome: o,
|
|
222
|
+
(s) => Promise.reject(s)
|
|
223
|
+
), n.interceptors.request.use(async (s) => {
|
|
224
|
+
if (j(s.url)) {
|
|
225
|
+
const a = C(s.url);
|
|
226
|
+
let o = null, l = 0, c, u;
|
|
227
|
+
try {
|
|
228
|
+
const i = r ? await q(e) : { ...await g(e), attempt: 0 };
|
|
229
|
+
o = i.token, l = i.attempt, c = i.outcome, u = i.errorMessage;
|
|
230
|
+
} catch (i) {
|
|
231
|
+
if (u = i instanceof Error ? i.message : String(i), c = "error", d.sendSessionRefreshEvent({
|
|
232
|
+
name: "refresh_token_retrieve_failed",
|
|
238
233
|
error_message: u
|
|
239
|
-
})
|
|
234
|
+
}), console.warn("Failed to retrieve refresh token:", i), a && t)
|
|
235
|
+
throw new v("error", u);
|
|
240
236
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
237
|
+
if (o)
|
|
238
|
+
d.sendSessionRefreshEvent({
|
|
239
|
+
name: "refresh_token_retrieved",
|
|
240
|
+
attempt: l,
|
|
241
|
+
read_outcome: c,
|
|
242
|
+
error_message: u
|
|
243
|
+
}), s.data = {
|
|
244
|
+
...s.data,
|
|
245
|
+
refreshToken: o
|
|
246
|
+
};
|
|
247
|
+
else if (d.sendSessionRefreshEvent({
|
|
248
|
+
name: "refresh_token_missing",
|
|
249
|
+
attempt: l,
|
|
250
|
+
read_outcome: c,
|
|
251
|
+
error_message: u
|
|
252
|
+
}), a && t)
|
|
253
|
+
throw new v(
|
|
254
|
+
c === "error" ? "error" : "not_found",
|
|
255
|
+
u
|
|
256
|
+
);
|
|
250
257
|
}
|
|
251
|
-
|
|
258
|
+
if (M(s.url))
|
|
259
|
+
try {
|
|
260
|
+
d.sendSessionRefreshEvent({
|
|
261
|
+
name: "refresh_token_removing_token"
|
|
262
|
+
}), await e.removeRefreshToken();
|
|
263
|
+
} catch (a) {
|
|
264
|
+
console.warn("Failed to remove refresh token:", a);
|
|
265
|
+
}
|
|
266
|
+
return s;
|
|
252
267
|
});
|
|
253
|
-
},
|
|
254
|
-
const r =
|
|
268
|
+
}, M = (e) => e ? /^\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/logout$/.test(e) : !1, j = (e) => e ? /^\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/(refresh|logout)$/.test(e) : !1, C = (e) => e ? /^\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/refresh$/.test(e) : !1, O = (e) => {
|
|
269
|
+
const r = e.config.url;
|
|
255
270
|
return r ? /^\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/(verify\/(email|sms|siwe|oauth\/.*)|refresh)$/.test(
|
|
256
271
|
r
|
|
257
272
|
) : !1;
|
|
258
|
-
},
|
|
273
|
+
}, x = (e) => {
|
|
259
274
|
if (!n.getUri() || n.getUri() === "")
|
|
260
275
|
throw new Error("CDP client URI not configured. Call configure() first.");
|
|
261
|
-
if (!
|
|
276
|
+
if (!e.url || e.url === "")
|
|
262
277
|
throw new Error("AxiosRequestConfig URL is empty. This should never happen.");
|
|
263
|
-
if (!
|
|
278
|
+
if (!e.method || e.method === "")
|
|
264
279
|
throw new Error("AxiosRequestConfig method is empty. This should never happen.");
|
|
265
|
-
},
|
|
266
|
-
if (!
|
|
280
|
+
}, L = (e) => e.method?.toString().toUpperCase() || "GET", R = (e) => {
|
|
281
|
+
if (!e.url)
|
|
267
282
|
throw new Error("URL is required for authentication");
|
|
268
|
-
const r = n.getUri() +
|
|
283
|
+
const r = n.getUri() + e.url;
|
|
269
284
|
return new URL(r);
|
|
270
|
-
}, _ = (
|
|
271
|
-
const r = /^\/platform\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/(refresh|logout)$/,
|
|
272
|
-
return r.test(
|
|
273
|
-
},
|
|
274
|
-
const r = /^\/platform\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/(init)$/,
|
|
275
|
-
return r.test(
|
|
276
|
-
},
|
|
285
|
+
}, _ = (e) => {
|
|
286
|
+
const r = /^\/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$/, a = /^\/platform\/v2\/embedded-wallet-api\/projects\/[^/]+\/attestation\/(challenge|register)$/;
|
|
287
|
+
return r.test(e) || t.test(e) || s.test(e) || a.test(e);
|
|
288
|
+
}, X = (e) => !/^\/platform\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/custom\/authenticate$/.test(e), A = (e) => {
|
|
289
|
+
const r = /^\/platform\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/(init)$/, t = /^\/platform\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/verify\//;
|
|
290
|
+
return r.test(e) || t.test(e);
|
|
291
|
+
}, D = (e) => [
|
|
277
292
|
// Auth flows: prevent account takeover on mobile clients
|
|
278
293
|
/\/auth\/verify\//,
|
|
279
294
|
// VerifyEmailAuthentication, VerifySmsAuthentication, VerifyOAuthCode, VerifyOAuthEndUserIdentity
|
|
280
295
|
/\/auth\/refresh$/
|
|
281
296
|
// RefreshAccessToken
|
|
282
|
-
].some((
|
|
297
|
+
].some((t) => t.test(e));
|
|
283
298
|
export {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
299
|
+
G as cdpApiClient,
|
|
300
|
+
B as configureCdpApiClient,
|
|
301
|
+
K as setAuthManager
|
|
287
302
|
};
|
package/dist/esm/index7.js
CHANGED
|
@@ -22,8 +22,8 @@ class a extends Error {
|
|
|
22
22
|
* @param errorLink - URL to documentation about this error
|
|
23
23
|
* @param cause - The cause of the error
|
|
24
24
|
*/
|
|
25
|
-
constructor(e, o,
|
|
26
|
-
super(
|
|
25
|
+
constructor(e, o, n, t, s, i) {
|
|
26
|
+
super(n, { cause: i }), this.name = "APIError", this.statusCode = e, this.errorType = o, this.errorMessage = n, t !== void 0 && (this.correlationId = t), s !== void 0 && (this.errorLink = s);
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
29
|
* Convert the error to a JSON object, excluding undefined properties
|
|
@@ -49,11 +49,11 @@ class d extends a {
|
|
|
49
49
|
* @param errorMessage - The error message
|
|
50
50
|
* @param cause - The cause of the error
|
|
51
51
|
*/
|
|
52
|
-
constructor(e, o,
|
|
53
|
-
super(0, e, o, void 0, void 0,
|
|
52
|
+
constructor(e, o, n) {
|
|
53
|
+
super(0, e, o, void 0, void 0, n), this.name = "UnknownApiError";
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
class
|
|
56
|
+
class l extends Error {
|
|
57
57
|
/**
|
|
58
58
|
* Constructor for the UnknownError class
|
|
59
59
|
*
|
|
@@ -64,13 +64,36 @@ class c extends Error {
|
|
|
64
64
|
super(e, { cause: o }), this.name = "UnknownError";
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
function
|
|
67
|
+
function E(r) {
|
|
68
68
|
return r !== null && typeof r == "object" && "errorType" in r && typeof r.errorType == "string" && "errorMessage" in r && typeof r.errorMessage == "string";
|
|
69
69
|
}
|
|
70
|
+
class h extends Error {
|
|
71
|
+
/** Stable discriminator used for cross-package detection. */
|
|
72
|
+
code = "CDP_REFRESH_TOKEN_UNAVAILABLE";
|
|
73
|
+
/**
|
|
74
|
+
* The read outcome that produced this error:
|
|
75
|
+
* - `"not_found"`: storage returned no token (the user may be genuinely signed out).
|
|
76
|
+
* - `"error"`: the read threw or reported an error (e.g. storage locked / not ready).
|
|
77
|
+
*/
|
|
78
|
+
outcome;
|
|
79
|
+
/**
|
|
80
|
+
* Constructor for the RefreshTokenUnavailableError class
|
|
81
|
+
*
|
|
82
|
+
* @param outcome - The read outcome that produced this error.
|
|
83
|
+
* @param message - An optional human-readable message.
|
|
84
|
+
*/
|
|
85
|
+
constructor(e, o) {
|
|
86
|
+
super(o ?? `Refresh token unavailable in local storage (${e})`), this.name = "RefreshTokenUnavailableError", this.outcome = e;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const p = (r) => typeof r == "object" && r !== null && r.code === "CDP_REFRESH_TOKEN_UNAVAILABLE", c = /user interaction is not allowed/i, T = (r) => r.outcome === "error" && c.test(r.message ?? "");
|
|
70
90
|
export {
|
|
71
91
|
a as APIError,
|
|
72
92
|
u as HttpErrorType,
|
|
93
|
+
h as RefreshTokenUnavailableError,
|
|
73
94
|
d as UnknownApiError,
|
|
74
|
-
|
|
75
|
-
|
|
95
|
+
l as UnknownError,
|
|
96
|
+
E as isOpenAPIError,
|
|
97
|
+
p as isRefreshTokenUnavailableError,
|
|
98
|
+
T as isTransientTokenReadError
|
|
76
99
|
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -210,6 +210,15 @@ export declare type CdpOptions = {
|
|
|
210
210
|
* reads are synchronous and have no such race. Defaults to false.
|
|
211
211
|
*/
|
|
212
212
|
retryTokenReads?: boolean;
|
|
213
|
+
/**
|
|
214
|
+
* Whether an unreadable/missing refresh token should fail closed (throw
|
|
215
|
+
* {@link RefreshTokenUnavailableError}) instead of proceeding with a token-less
|
|
216
|
+
* refresh. Enable only where the stored token is the sole transport (native,
|
|
217
|
+
* which has no cookies). On web the httpOnly cookie is the primary transport and
|
|
218
|
+
* storage is a supplemental mirror, so an empty mirror must NOT block the refresh.
|
|
219
|
+
* Defaults to false.
|
|
220
|
+
*/
|
|
221
|
+
failClosedOnMissingToken?: boolean;
|
|
213
222
|
/**
|
|
214
223
|
* Optional app attestation for native mobile platforms.
|
|
215
224
|
* When provided, adds assertion headers to sensitive API calls to prove app integrity.
|
|
@@ -323,7 +332,7 @@ export declare interface CreateEndUserApplePayOnrampOrderRequest {
|
|
|
323
332
|
export declare type CreateEndUserApplePayOnrampOrderResult = NonNullable<Awaited<ReturnType<typeof createEndUserApplePayOnrampOrder>>>;
|
|
324
333
|
|
|
325
334
|
/**
|
|
326
|
-
* Creates a Bitcoin HD (Hierarchical Deterministic) account for an end user at the given address type and network. Returns the
|
|
335
|
+
* 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
336
|
* @summary Create end user Bitcoin HD (Hierarchical Deterministic) account
|
|
328
337
|
*/
|
|
329
338
|
export declare const createEndUserBtcAccount: (userId: string, createEndUserBtcAccountBody: CreateEndUserBtcAccountBody, params?: CreateEndUserBtcAccountParams, options?: SecondParameter<typeof cdpApiClient<EndUser>>) => Promise<EndUser>;
|
|
@@ -850,7 +859,7 @@ export declare interface EndUser {
|
|
|
850
859
|
solanaAccounts: string[];
|
|
851
860
|
/** The list of Solana accounts associated with the end user. End users can have up to 10 Solana accounts. */
|
|
852
861
|
solanaAccountObjects: EndUserSolanaAccount[];
|
|
853
|
-
/** The list of Bitcoin HD (Hierarchical Deterministic) accounts associated with the end user.
|
|
862
|
+
/** 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
863
|
btcAccountObjects?: EndUserBtcAccount[];
|
|
855
864
|
/** The date and time when the end user was created, in ISO 8601 format. */
|
|
856
865
|
createdAt: string;
|
|
@@ -867,15 +876,20 @@ export declare interface EndUserApplePayOnrampOrderCreateResponse {
|
|
|
867
876
|
}
|
|
868
877
|
|
|
869
878
|
/**
|
|
870
|
-
* Information about a Bitcoin HD (Hierarchical Deterministic) account associated with an end user. Unlike EVM and Solana accounts, there is no single address
|
|
879
|
+
* 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
880
|
*/
|
|
872
881
|
export declare interface EndUserBtcAccount {
|
|
873
882
|
/** The Bitcoin address type and derivation path standard used for this account. */
|
|
874
883
|
addressType: EndUserBtcAccountAddressType;
|
|
875
884
|
/** The Bitcoin network this account is associated with. */
|
|
876
885
|
network: EndUserBtcAccountNetwork;
|
|
877
|
-
/** The BIP-32 extended public key (xpub) at the account derivation path, base58check encoded
|
|
878
|
-
|
|
886
|
+
/** 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. */
|
|
887
|
+
xpub?: string;
|
|
888
|
+
/**
|
|
889
|
+
* 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.
|
|
890
|
+
* @pattern ^[0-9a-f]{64}$
|
|
891
|
+
*/
|
|
892
|
+
xpubHash: string;
|
|
879
893
|
/** The date and time when the account was created, in ISO 8601 format. */
|
|
880
894
|
createdAt: string;
|
|
881
895
|
}
|
|
@@ -1443,6 +1457,10 @@ export declare type GetAuthenticatedEndUserParams = {
|
|
|
1443
1457
|
* @pattern ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
|
|
1444
1458
|
*/
|
|
1445
1459
|
projectID?: ProjectIDOptionalParameter;
|
|
1460
|
+
/**
|
|
1461
|
+
* When `true`, each Bitcoin account in `btcAccountObjects` includes its raw `xpub`. When `false` (the default), only `xpubHash` is returned.
|
|
1462
|
+
*/
|
|
1463
|
+
includeBtcXpubs?: boolean;
|
|
1446
1464
|
};
|
|
1447
1465
|
|
|
1448
1466
|
export declare type GetAuthenticatedEndUserResult = NonNullable<Awaited<ReturnType<typeof getAuthenticatedEndUser>>>;
|
|
@@ -2143,6 +2161,28 @@ export declare const IosAttestationRegistrationResponsePlatform: {
|
|
|
2143
2161
|
*/
|
|
2144
2162
|
export declare function isOpenAPIError(obj: unknown): obj is Error_2;
|
|
2145
2163
|
|
|
2164
|
+
/**
|
|
2165
|
+
* Type guard for {@link RefreshTokenUnavailableError} that is robust to the class
|
|
2166
|
+
* being duplicated across bundled package boundaries by checking a stable `code`
|
|
2167
|
+
* discriminator rather than the prototype chain.
|
|
2168
|
+
*
|
|
2169
|
+
* @param error - The value to check
|
|
2170
|
+
* @returns True if the value is a RefreshTokenUnavailableError
|
|
2171
|
+
*/
|
|
2172
|
+
export declare const isRefreshTokenUnavailableError: (error: unknown) => error is RefreshTokenUnavailableError;
|
|
2173
|
+
|
|
2174
|
+
/**
|
|
2175
|
+
* Determines whether a {@link RefreshTokenUnavailableError} represents a transient
|
|
2176
|
+
* read failure (the token exists but is momentarily unreadable) rather than a
|
|
2177
|
+
* definitive one. Only a locked secure store qualifies, so a later refresh can
|
|
2178
|
+
* recover; a genuinely absent token or any other read error is definitive and
|
|
2179
|
+
* callers should treat it as a hard sign-out condition.
|
|
2180
|
+
*
|
|
2181
|
+
* @param error - The refresh-token-unavailable error to classify.
|
|
2182
|
+
* @returns True if the read failure is transient and the session should be kept.
|
|
2183
|
+
*/
|
|
2184
|
+
export declare const isTransientTokenReadError: (error: RefreshTokenUnavailableError) => boolean;
|
|
2185
|
+
|
|
2146
2186
|
export declare interface ListResponse {
|
|
2147
2187
|
/** The token for the next page of items, if any. */
|
|
2148
2188
|
nextPageToken?: string;
|
|
@@ -2559,6 +2599,38 @@ export declare interface RefreshTokenStorage {
|
|
|
2559
2599
|
removeRefreshToken(): Promise<void>;
|
|
2560
2600
|
}
|
|
2561
2601
|
|
|
2602
|
+
/**
|
|
2603
|
+
* Error thrown by the request interceptor when a token refresh is attempted but
|
|
2604
|
+
* the refresh token cannot be read from local storage — either genuinely absent
|
|
2605
|
+
* or the read failed (e.g. an OS secure store that is temporarily locked or not
|
|
2606
|
+
* yet ready after an app resume).
|
|
2607
|
+
*
|
|
2608
|
+
* This is deliberately distinct from a server-side rejection of a refresh token
|
|
2609
|
+
* (HTTP 401): when this error is thrown, no request reaches the server. Consumers
|
|
2610
|
+
* should treat it as a recoverable, local condition and avoid destructive actions
|
|
2611
|
+
* (such as signing the user out) on a merely transient read failure.
|
|
2612
|
+
*
|
|
2613
|
+
* Prefer {@link isRefreshTokenUnavailableError} over `instanceof` when detecting
|
|
2614
|
+
* this error, since bundlers can duplicate the class across package boundaries.
|
|
2615
|
+
*/
|
|
2616
|
+
export declare class RefreshTokenUnavailableError extends Error {
|
|
2617
|
+
/** Stable discriminator used for cross-package detection. */
|
|
2618
|
+
readonly code = "CDP_REFRESH_TOKEN_UNAVAILABLE";
|
|
2619
|
+
/**
|
|
2620
|
+
* The read outcome that produced this error:
|
|
2621
|
+
* - `"not_found"`: storage returned no token (the user may be genuinely signed out).
|
|
2622
|
+
* - `"error"`: the read threw or reported an error (e.g. storage locked / not ready).
|
|
2623
|
+
*/
|
|
2624
|
+
readonly outcome: "not_found" | "error";
|
|
2625
|
+
/**
|
|
2626
|
+
* Constructor for the RefreshTokenUnavailableError class
|
|
2627
|
+
*
|
|
2628
|
+
* @param outcome - The read outcome that produced this error.
|
|
2629
|
+
* @param message - An optional human-readable message.
|
|
2630
|
+
*/
|
|
2631
|
+
constructor(outcome: "not_found" | "error", message?: string);
|
|
2632
|
+
}
|
|
2633
|
+
|
|
2562
2634
|
/**
|
|
2563
2635
|
* Verifies an iOS App Attest attestation payload and registers the device's public key for future assertion validation. **This endpoint is iOS-only.** Android devices use a different flow (see below).
|
|
2564
2636
|
|
|
@@ -3118,10 +3190,6 @@ export declare type SignBtcHashWithEndUserAccountBody = {
|
|
|
3118
3190
|
* @pattern ^[a-zA-Z0-9-]{1,100}$
|
|
3119
3191
|
*/
|
|
3120
3192
|
walletSecretId: string;
|
|
3121
|
-
/** The Bitcoin address type of the account to sign with. */
|
|
3122
|
-
addressType: SignBtcHashWithEndUserAccountBodyAddressType;
|
|
3123
|
-
/** The Bitcoin network of the account to sign with. */
|
|
3124
|
-
network: SignBtcHashWithEndUserAccountBodyNetwork;
|
|
3125
3193
|
/** The BIP-32 change level index. 0 for external (receive) addresses, 1 for internal (change) addresses, as defined by BIP-44. */
|
|
3126
3194
|
change: SignBtcHashWithEndUserAccountBodyChange;
|
|
3127
3195
|
/**
|
|
@@ -3135,15 +3203,11 @@ export declare type SignBtcHashWithEndUserAccountBody = {
|
|
|
3135
3203
|
* @pattern ^[0-9a-fA-F]{64}$
|
|
3136
3204
|
*/
|
|
3137
3205
|
hash: string;
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
export declare type SignBtcHashWithEndUserAccountBodyAddressType = (typeof SignBtcHashWithEndUserAccountBodyAddressType)[keyof typeof SignBtcHashWithEndUserAccountBodyAddressType];
|
|
3144
|
-
|
|
3145
|
-
export declare const SignBtcHashWithEndUserAccountBodyAddressType: {
|
|
3146
|
-
readonly segwit: "segwit";
|
|
3206
|
+
/**
|
|
3207
|
+
* 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.
|
|
3208
|
+
* @pattern ^[0-9a-f]{64}$
|
|
3209
|
+
*/
|
|
3210
|
+
xpubHash: string;
|
|
3147
3211
|
};
|
|
3148
3212
|
|
|
3149
3213
|
/**
|
|
@@ -3156,16 +3220,6 @@ export declare const SignBtcHashWithEndUserAccountBodyChange: {
|
|
|
3156
3220
|
readonly NUMBER_1: 1;
|
|
3157
3221
|
};
|
|
3158
3222
|
|
|
3159
|
-
/**
|
|
3160
|
-
* The Bitcoin network of the account to sign with.
|
|
3161
|
-
*/
|
|
3162
|
-
export declare type SignBtcHashWithEndUserAccountBodyNetwork = (typeof SignBtcHashWithEndUserAccountBodyNetwork)[keyof typeof SignBtcHashWithEndUserAccountBodyNetwork];
|
|
3163
|
-
|
|
3164
|
-
export declare const SignBtcHashWithEndUserAccountBodyNetwork: {
|
|
3165
|
-
readonly bitcoin: "bitcoin";
|
|
3166
|
-
readonly "bitcoin-testnet": "bitcoin-testnet";
|
|
3167
|
-
};
|
|
3168
|
-
|
|
3169
3223
|
export declare type SignBtcHashWithEndUserAccountParams = {
|
|
3170
3224
|
/**
|
|
3171
3225
|
* The ID of the CDP Project. Required for end users authenticated using custom auth (i.e. a non-CDP JWT provider).
|