@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 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 d, DeveloperJWTAuthenticationType as E, EmailAuthenticationType as A, EndUserBtcAccountAddressType as u, EndUserBtcAccountNetwork as p, EndUserOnrampFeeType as h, EndUserOnrampOrderStatus as m, ErrorType as U, EvmEip7702DelegationNetwork as l, EvmEip7702DelegationOperationStatus as g, EvmSwapsNetwork as y, EvmUserOperationNetwork as S, EvmUserOperationStatus as v, InitiateEmailAuthenticationNextStepType as T, InitiateEmailAuthenticationRequestType as W, InitiateSiweAuthenticationRequestType as f, InitiateSmsAuthenticationNextStepType as k, InitiateSmsAuthenticationRequestType as w, InitiateSmsMfaEnrollmentType as B, InitiateTotpMfaEnrollmentType as O, IosAttestationRegistrationResponsePlatform as N, MfaMethod as M, Network as P, OAuth2ProviderType as C, OtpEmailLogoModerationStatus as I, RefreshAccessTokenBodyGrantType as D, SendEvmAssetWithEndUserAccountBodyNetwork as x, SendEvmTransactionWithEndUserAccountBodyNetwork as F, SendSolanaAssetWithEndUserAccountBodyNetwork as H, SendSolanaTransactionWithEndUserAccountBodyNetwork as R, SignBtcHashWithEndUserAccountBodyAddressType as b, SignBtcHashWithEndUserAccountBodyChange as V, SignBtcHashWithEndUserAccountBodyNetwork as q, SiweAuthenticationType as j, SmsAuthenticationType as G, SpendPermissionNetwork as J } from "./index5.js";
5
- import { configureCdpApiClient as _, setAuthManager as z } from "./index6.js";
6
- import { APIError as Q, HttpErrorType as X, UnknownApiError as Y, UnknownError as Z, isOpenAPIError as $ } from "./index7.js";
7
- import { authenticateUserWithCustomAuth as te, createDelegationForEndUser as ne, createDelegationForEndUserAccount as re, createEndUserApplePayOnrampOrder as ie, createEndUserBtcAccount as oe, createEndUserEvmAccount as ae, createEndUserEvmSmartAccount as se, createEndUserEvmSwap as ce, createEndUserSolanaAccount as de, createEvmEip7702DelegationWithEndUserAccount as Ee, createSpendPermissionWithEndUserAccount as Ae, enableSpendPermissionWithEndUserAccount as ue, exportEndUserEvmAccount as pe, exportEndUserSolanaAccount as he, generateAttestationChallenge as me, getAuthenticatedEndUser as Ue, getDelegationForEndUser as le, getDelegationForEndUserAccount as ge, getEndUserEvmSwapPrice as ye, getEvmEip7702DelegationOperationByIdWithEndUserAccount as Se, getMfaConfig as ve, getProjectConfig as Te, getUserOperationWithEndUserAccount as We, initiateAuthentication as fe, initiateMfaEnrollment as ke, initiateMfaEnrollment2 as we, initiateMfaVerification as Be, listSpendPermissionsWithEndUserAccount as Oe, logOutEndUser as Ne, receiveOAuthCallback as Me, receiveOAuthCallbackPost as Pe, recordMfaEnrollmentPrompted as Ce, refreshAccessToken as Ie, registerAttestation as De, registerTemporaryWalletSecret as xe, revokeDelegationForEndUser as Fe, revokeDelegationForEndUserAccount as He, revokeSpendPermissionWithEndUserAccount as Re, sendEvmAssetWithEndUserAccount as be, sendEvmTransactionWithEndUserAccount as Ve, sendSolanaAssetWithEndUserAccount as qe, sendSolanaTransactionWithEndUserAccount as je, sendUserOperationWithEndUserAccount as Ge, signBtcHashWithEndUserAccount as Je, signEvmHashWithEndUserAccount as Le, signEvmMessageWithEndUserAccount as _e, signEvmTransactionWithEndUserAccount as ze, signEvmTypedDataWithEndUserAccount as Ke, signSolanaHashWithEndUserAccount as Qe, signSolanaMessageWithEndUserAccount as Xe, signSolanaTransactionWithEndUserAccount as Ye, submitMfaEnrollment as Ze, submitMfaVerification as $e, verifyEmailAuthentication as et, verifyOAuthCode as tt, verifyOAuthEndUserIdentity as nt, verifySiweAuthentication as rt, verifySmsAuthentication as it } from "./index8.js";
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
- Q as APIError,
10
+ z as APIError,
11
11
  s as CapabilityName,
12
12
  c as CreateEndUserBtcAccountBodyAddressType,
13
- d as CreateEndUserBtcAccountBodyNetwork,
14
- E as DeveloperJWTAuthenticationType,
13
+ E as CreateEndUserBtcAccountBodyNetwork,
14
+ d as DeveloperJWTAuthenticationType,
15
15
  A as EmailAuthenticationType,
16
16
  u as EndUserBtcAccountAddressType,
17
17
  p as EndUserBtcAccountNetwork,
18
- h as EndUserOnrampFeeType,
19
- m as EndUserOnrampOrderStatus,
20
- U as ErrorType,
21
- l as EvmEip7702DelegationNetwork,
18
+ m as EndUserOnrampFeeType,
19
+ h as EndUserOnrampOrderStatus,
20
+ l as ErrorType,
21
+ U as EvmEip7702DelegationNetwork,
22
22
  g as EvmEip7702DelegationOperationStatus,
23
- y as EvmSwapsNetwork,
24
- S as EvmUserOperationNetwork,
23
+ S as EvmSwapsNetwork,
24
+ y as EvmUserOperationNetwork,
25
25
  v as EvmUserOperationStatus,
26
- X as HttpErrorType,
26
+ K as HttpErrorType,
27
27
  T as InitiateEmailAuthenticationNextStepType,
28
- W as InitiateEmailAuthenticationRequestType,
29
- f as InitiateSiweAuthenticationRequestType,
28
+ f as InitiateEmailAuthenticationRequestType,
29
+ W as InitiateSiweAuthenticationRequestType,
30
30
  k as InitiateSmsAuthenticationNextStepType,
31
- w as InitiateSmsAuthenticationRequestType,
32
- B as InitiateSmsMfaEnrollmentType,
33
- O as InitiateTotpMfaEnrollmentType,
34
- N as IosAttestationRegistrationResponsePlatform,
35
- M as MfaMethod,
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
- x as SendEvmAssetWithEndUserAccountBodyNetwork,
41
- F as SendEvmTransactionWithEndUserAccountBodyNetwork,
42
- H as SendSolanaAssetWithEndUserAccountBodyNetwork,
43
- R as SendSolanaTransactionWithEndUserAccountBodyNetwork,
44
- b as SignBtcHashWithEndUserAccountBodyAddressType,
45
- V as SignBtcHashWithEndUserAccountBodyChange,
46
- q as SignBtcHashWithEndUserAccountBodyNetwork,
47
- j as SiweAuthenticationType,
48
- G as SmsAuthenticationType,
49
- J as SpendPermissionNetwork,
50
- Y as UnknownApiError,
51
- Z as UnknownError,
52
- te as authenticateUserWithCustomAuth,
53
- _ as configureCdpApiClient,
54
- ne as createDelegationForEndUser,
55
- re as createDelegationForEndUserAccount,
56
- ie as createEndUserApplePayOnrampOrder,
57
- oe as createEndUserBtcAccount,
58
- ae as createEndUserEvmAccount,
59
- se as createEndUserEvmSmartAccount,
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
- Ee as createEvmEip7702DelegationWithEndUserAccount,
63
- Ae as createSpendPermissionWithEndUserAccount,
64
- ue as enableSpendPermissionWithEndUserAccount,
65
- pe as exportEndUserEvmAccount,
61
+ Ae as createEvmEip7702DelegationWithEndUserAccount,
62
+ ue as createSpendPermissionWithEndUserAccount,
63
+ pe as enableSpendPermissionWithEndUserAccount,
64
+ me as exportEndUserEvmAccount,
66
65
  he as exportEndUserSolanaAccount,
67
- me as generateAttestationChallenge,
66
+ le as generateAttestationChallenge,
68
67
  Ue as getAuthenticatedEndUser,
69
- le as getDelegationForEndUser,
70
- ge as getDelegationForEndUserAccount,
68
+ ge as getDelegationForEndUser,
69
+ Se as getDelegationForEndUserAccount,
71
70
  ye as getEndUserEvmSwapPrice,
72
- Se as getEvmEip7702DelegationOperationByIdWithEndUserAccount,
73
- ve as getMfaConfig,
74
- Te as getProjectConfig,
71
+ ve as getEvmEip7702DelegationOperationByIdWithEndUserAccount,
72
+ Te as getMfaConfig,
73
+ fe as getProjectConfig,
75
74
  We as getUserOperationWithEndUserAccount,
76
- fe as initiateAuthentication,
77
- ke as initiateMfaEnrollment,
75
+ ke as initiateAuthentication,
76
+ Oe as initiateMfaEnrollment,
78
77
  we as initiateMfaEnrollment2,
79
78
  Be as initiateMfaVerification,
80
- $ as isOpenAPIError,
81
- Oe as listSpendPermissionsWithEndUserAccount,
79
+ Z as isOpenAPIError,
80
+ $ as isRefreshTokenUnavailableError,
81
+ ee as isTransientTokenReadError,
82
+ Me as listSpendPermissionsWithEndUserAccount,
82
83
  Ne as logOutEndUser,
83
- Me as receiveOAuthCallback,
84
- Pe as receiveOAuthCallbackPost,
85
- Ce as recordMfaEnrollmentPrompted,
86
- Ie as refreshAccessToken,
87
- De as registerAttestation,
88
- xe as registerTemporaryWalletSecret,
89
- Fe as revokeDelegationForEndUser,
90
- He as revokeDelegationForEndUserAccount,
91
- Re as revokeSpendPermissionWithEndUserAccount,
92
- be as sendEvmAssetWithEndUserAccount,
93
- Ve as sendEvmTransactionWithEndUserAccount,
94
- qe as sendSolanaAssetWithEndUserAccount,
95
- je as sendSolanaTransactionWithEndUserAccount,
96
- Ge as sendUserOperationWithEndUserAccount,
97
- z as setAuthManager,
98
- Je as signBtcHashWithEndUserAccount,
99
- Le as signEvmHashWithEndUserAccount,
100
- _e as signEvmMessageWithEndUserAccount,
101
- ze as signEvmTransactionWithEndUserAccount,
102
- Ke as signEvmTypedDataWithEndUserAccount,
103
- Qe as signSolanaHashWithEndUserAccount,
104
- Xe as signSolanaMessageWithEndUserAccount,
105
- Ye as signSolanaTransactionWithEndUserAccount,
106
- Ze as submitMfaEnrollment,
107
- $e as submitMfaVerification,
108
- et as verifyEmailAuthentication,
109
- tt as verifyOAuthCode,
110
- nt as verifyOAuthEndUserIdentity,
111
- rt as verifySiweAuthentication,
112
- it as verifySmsAuthentication
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
  };
@@ -1,4 +1,4 @@
1
- import { __exports as n } from "./index22.js";
1
+ import { __exports as n } from "./index21.js";
2
2
  var $;
3
3
  function Z() {
4
4
  if ($) return n;
@@ -1,4 +1,4 @@
1
- import { __module as E } from "./index23.js";
1
+ import { __module as E } from "./index22.js";
2
2
  E.exports;
3
3
  var we;
4
4
  function Ye() {
@@ -1,4 +1,4 @@
1
- import { __module as a } from "./index21.js";
1
+ import { __module as a } from "./index23.js";
2
2
  var h;
3
3
  function c() {
4
4
  return h ? a.exports : (h = 1, (function() {
@@ -1,4 +1,4 @@
1
- var r = { exports: {} };
1
+ var r = {};
2
2
  export {
3
- r as __module
3
+ r as __exports
4
4
  };
@@ -1,4 +1,4 @@
1
- var r = {};
1
+ var e = { exports: {} };
2
2
  export {
3
- r as __exports
3
+ e as __module
4
4
  };
@@ -1,4 +1,4 @@
1
- var e = { exports: {} };
1
+ var r = { exports: {} };
2
2
  export {
3
- e as __module
3
+ r as __module
4
4
  };
@@ -1,4 +1,4 @@
1
- const o = "0.0.118";
1
+ const o = "0.0.120";
2
2
  export {
3
3
  o as VERSION
4
4
  };
@@ -142,11 +142,11 @@ const e = {
142
142
  avalanche: "avalanche",
143
143
  ethereum: "ethereum",
144
144
  "ethereum-sepolia": "ethereum-sepolia"
145
- }, b = {
145
+ }, f = {
146
146
  approved: "approved",
147
147
  pending: "pending",
148
148
  rejected: "rejected"
149
- }, f = {
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
- }, g = {
157
+ }, v = {
158
158
  UNSPECIFIED: "UNSPECIFIED",
159
159
  PENDING: "PENDING",
160
160
  SUBMITTED: "SUBMITTED",
161
161
  COMPLETED: "COMPLETED",
162
162
  FAILED: "FAILED"
163
- }, v = {
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
- }, U = {
238
+ }, D = {
239
239
  solana: "solana",
240
240
  "solana-devnet": "solana-devnet"
241
- }, D = {
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
- f as EvmEip7702DelegationNetwork,
270
- g as EvmEip7702DelegationOperationStatus,
264
+ b as EvmEip7702DelegationNetwork,
265
+ v as EvmEip7702DelegationOperationStatus,
271
266
  h as EvmSwapsNetwork,
272
267
  y as EvmUserOperationNetwork,
273
- v as EvmUserOperationStatus,
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
- b as OtpEmailLogoModerationStatus,
280
+ f as OtpEmailLogoModerationStatus,
286
281
  O as RefreshAccessTokenBodyGrantType,
287
282
  P as SendEvmAssetWithEndUserAccountBodyNetwork,
288
283
  x as SendEvmTransactionWithEndUserAccountBodyNetwork,
289
- D as SendSolanaAssetWithEndUserAccountBodyNetwork,
290
- U as SendSolanaTransactionWithEndUserAccountBodyNetwork,
291
- M as SignBtcHashWithEndUserAccountBodyAddressType,
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
@@ -1,287 +1,302 @@
1
- import { Analytics as i } from "./index2.js";
1
+ import { Analytics as d } from "./index2.js";
2
2
  import "./index3.js";
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({
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
- }), c = null;
10
- const N = (t) => {
11
- if (n = p.create({
12
- baseURL: t.basePath || "https://api.cdp.coinbase.com/platform",
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: v()
14
+ withCredentials: k()
15
15
  }), n.interceptors.request.use(async (r) => {
16
- const e = C(r), s = w(r);
17
- if (!c || _(s.pathname) || A(s.pathname) && !await c.isSignedIn() || !O(s.pathname))
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 c.getXWalletAuth({
20
- requestMethod: e,
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 e = w(r);
28
- if (!c || _(e.pathname) || A(e.pathname) && !await c.isSignedIn())
27
+ const t = R(r);
28
+ if (!h || _(t.pathname) || A(t.pathname) && !await h.isSignedIn())
29
29
  return r;
30
- const s = await c.getToken();
30
+ const s = await h.getToken();
31
31
  return s && s !== "" && (r.headers.Authorization = `Bearer ${s}`), r;
32
- }), !v()) {
33
- const r = t.platform ? `CDP/reactnative/${t.platform}` : "CDP/reactnative";
34
- n.interceptors.request.use(async (e) => {
35
- let s = e.headers["User-Agent"];
36
- return s = s ? `${s} ${r}` : r, e.headers["User-Agent"] = s, e;
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
- 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
- n.interceptors.request.use(async (e) => {
44
- const s = w(e);
45
- if (!x(s.pathname) || !t.isEnabled())
46
- return e;
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 e;
52
- const u = `/v2/embedded-wallet-api/projects/${a[1]}/attestation/challenge`, m = (await n.post(u)).data.challenge;
53
- if (!m)
54
- return console.warn("Failed to fetch assertion challenge"), e;
55
- const f = await t.generateAssertion(m);
56
- if (!f)
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"] = m;
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 t.generateAssertion(JSON.stringify(e.data));
64
+ const a = await e.generateAssertion(JSON.stringify(t.data));
61
65
  if (!a)
62
- return e;
63
- e.headers["X-Integrity-Token"] = a.assertion, e.headers["X-Package-Name"] = t.appIdentifier;
66
+ return t;
67
+ t.headers["X-Integrity-Token"] = a.assertion, t.headers["X-Package-Name"] = e.appIdentifier;
64
68
  }
65
- return e;
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
- }, S = (t, r) => ({
73
- ...t,
76
+ }, $ = (e, r) => ({
77
+ ...e,
74
78
  headers: {
75
- ...t.headers || {},
79
+ ...e.headers || {},
76
80
  "X-Idempotency-Key": r
77
81
  }
78
- }), H = async (t, r) => {
79
- j(t), r && r !== "" && (t = S(t, r));
82
+ }), G = async (e, r) => {
83
+ x(e), r && r !== "" && (e = $(e, r));
80
84
  try {
81
- return (await n(t)).data;
82
- } catch (e) {
83
- if (p.isAxiosError(e) && !e.response)
84
- throw new g(
85
- d.unknown,
86
- e.cause instanceof Error ? e.cause.message : e.message,
87
- e.cause
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 (p.isAxiosError(e) && e.response) {
90
- if (y(e.response.data))
91
- throw new l(
92
- e.response.status,
93
- e.response.data.errorType,
94
- e.response.data.errorMessage,
95
- e.response.data.correlationId,
96
- e.response.data.errorLink,
97
- e.cause
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 = e.response.status;
106
+ const s = t.response.status;
101
107
  switch (s) {
102
108
  case 401:
103
- throw new l(
109
+ throw new f(
104
110
  s,
105
- d.unauthorized,
111
+ p.unauthorized,
106
112
  "Unauthorized.",
107
113
  void 0,
108
- `${h}#unauthorized`,
109
- e.cause
114
+ `${m}#unauthorized`,
115
+ t.cause
110
116
  );
111
117
  case 404:
112
- throw new l(
118
+ throw new f(
113
119
  s,
114
- d.not_found,
120
+ p.not_found,
115
121
  "API not found.",
116
122
  void 0,
117
- `${h}#not_found`,
118
- e.cause
123
+ `${m}#not_found`,
124
+ t.cause
119
125
  );
120
126
  case 502:
121
- throw new l(
127
+ throw new f(
122
128
  s,
123
- d.bad_gateway,
129
+ p.bad_gateway,
124
130
  "Bad gateway.",
125
131
  void 0,
126
- `${h}`,
127
- e.cause
132
+ `${m}`,
133
+ t.cause
128
134
  );
129
135
  case 503:
130
- throw new l(
136
+ throw new f(
131
137
  s,
132
- d.service_unavailable,
138
+ p.service_unavailable,
133
139
  "Service unavailable. Please try again later.",
134
140
  void 0,
135
- `${h}`,
136
- e.cause
141
+ `${m}`,
142
+ t.cause
137
143
  );
138
144
  default: {
139
145
  let a = "";
140
- if (e.response.data)
146
+ if (t.response.data)
141
147
  try {
142
- a = JSON.stringify(e.response.data);
148
+ a = JSON.stringify(t.response.data);
143
149
  } catch {
144
- a = String(e.response.data);
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 l(
153
+ throw new f(
148
154
  s,
149
- d.unexpected_error,
155
+ p.unexpected_error,
150
156
  o,
151
157
  void 0,
152
- `${h}`,
153
- e.cause
158
+ `${m}`,
159
+ t.cause
154
160
  );
155
161
  }
156
162
  }
157
163
  }
158
164
  }
159
- throw new T("Something went wrong.", e instanceof Error ? e : void 0);
165
+ throw new S("Something went wrong.", t instanceof Error ? t : void 0);
160
166
  }
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 };
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 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 { 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: e,
181
+ outcome: t,
176
182
  errorMessage: s
177
183
  };
178
- const u = b[a];
179
- u !== void 0 && await new Promise((R) => setTimeout(R, u));
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: k - 1,
184
- outcome: e,
189
+ attempt: E - 1,
190
+ outcome: t,
185
191
  errorMessage: s
186
192
  };
187
- }, U = (t, r) => {
193
+ }, I = (e, r, t) => {
188
194
  n.interceptors.response.use(
189
- async (e) => {
195
+ async (s) => {
190
196
  try {
191
- if (q(e)) {
192
- i.sendSessionRefreshEvent({
197
+ if (O(s)) {
198
+ d.sendSessionRefreshEvent({
193
199
  name: "refresh_token_response"
194
200
  });
195
- const s = e.data?.refreshToken;
196
- s && (i.sendSessionRefreshEvent({
201
+ const a = s.data?.refreshToken;
202
+ a && (d.sendSessionRefreshEvent({
197
203
  name: "refresh_token_received"
198
204
  }), await Promise.race([
199
- t.setRefreshToken(s),
205
+ e.setRefreshToken(a),
200
206
  new Promise(
201
- (a, o) => setTimeout(() => o(new Error("setRefreshToken timed out after 5000ms")), 5e3)
207
+ (o, l) => setTimeout(() => l(new Error("setRefreshToken timed out after 5000ms")), 5e3)
202
208
  )
203
- ]), i.sendSessionRefreshEvent({
209
+ ]), d.sendSessionRefreshEvent({
204
210
  name: "refresh_token_stored"
205
211
  }));
206
212
  }
207
- } catch (s) {
208
- const a = s instanceof Error ? s.message : String(s);
209
- i.sendSessionRefreshEvent({
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: a
212
- }), console.warn("Failed to store refresh token:", s);
217
+ error_message: o
218
+ }), console.warn("Failed to store refresh token:", a);
213
219
  }
214
- return e;
220
+ return s;
215
221
  },
216
- (e) => Promise.reject(e)
217
- ), n.interceptors.request.use(async (e) => {
218
- try {
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({
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
- I(e.url) && (i.sendSessionRefreshEvent({
242
- name: "refresh_token_removing_token"
243
- }), await t.removeRefreshToken());
244
- } catch (s) {
245
- const a = s instanceof Error ? s.message : String(s);
246
- i.sendSessionRefreshEvent({
247
- name: "refresh_token_retrieve_failed",
248
- error_message: a
249
- }), console.warn("Failed to retrieve refresh token:", s);
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
- return e;
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
- }, 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) => {
254
- const r = t.config.url;
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
- }, j = (t) => {
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 (!t.url || t.url === "")
276
+ if (!e.url || e.url === "")
262
277
  throw new Error("AxiosRequestConfig URL is empty. This should never happen.");
263
- if (!t.method || t.method === "")
278
+ if (!e.method || e.method === "")
264
279
  throw new Error("AxiosRequestConfig method is empty. This should never happen.");
265
- }, C = (t) => t.method?.toString().toUpperCase() || "GET", w = (t) => {
266
- if (!t.url)
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() + t.url;
283
+ const r = n.getUri() + e.url;
269
284
  return new URL(r);
270
- }, _ = (t) => {
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)$/;
272
- return r.test(t) || e.test(t) || s.test(t) || a.test(t);
273
- }, O = (t) => !/^\/platform\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/custom\/authenticate$/.test(t), A = (t) => {
274
- const r = /^\/platform\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/(init)$/, e = /^\/platform\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/verify\//;
275
- return r.test(t) || e.test(t);
276
- }, x = (t) => [
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((e) => e.test(t));
297
+ ].some((t) => t.test(e));
283
298
  export {
284
- H as cdpApiClient,
285
- N as configureCdpApiClient,
286
- z as setAuthManager
299
+ G as cdpApiClient,
300
+ B as configureCdpApiClient,
301
+ K as setAuthManager
287
302
  };
@@ -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, t, n, s, i) {
26
- super(t, { cause: i }), this.name = "APIError", this.statusCode = e, this.errorType = o, this.errorMessage = t, n !== void 0 && (this.correlationId = n), s !== void 0 && (this.errorLink = s);
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, t) {
53
- super(0, e, o, void 0, void 0, t), this.name = "UnknownApiError";
52
+ constructor(e, o, n) {
53
+ super(0, e, o, void 0, void 0, n), this.name = "UnknownApiError";
54
54
  }
55
55
  }
56
- class c extends Error {
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 p(r) {
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
- c as UnknownError,
75
- p as isOpenAPIError
95
+ l as UnknownError,
96
+ E as isOpenAPIError,
97
+ p as isRefreshTokenUnavailableError,
98
+ T as isTransientTokenReadError
76
99
  };
@@ -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 full end user resource including the extended public key (xpub) which can be used to derive child addresses for UTXO discovery. An end user can have one Bitcoin account per address type and network combination.
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. An end user can have one Bitcoin account per address type and network combination. */
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 field — the extended public key (xpub) replaces it, enabling derivation of unlimited child addresses for UTXO discovery.
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. Use this to derive child addresses for UTXO scanning. */
878
- extendedPublicKey: string;
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
- * The Bitcoin address type of the account to sign with.
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).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coinbase/cdp-api-client",
3
- "version": "0.0.118",
3
+ "version": "0.0.120",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist/**",