@coinbase/cdp-api-client 0.0.58 → 0.0.61

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.
@@ -1,18 +1,18 @@
1
- import h from "axios";
1
+ import c from "axios";
2
2
  import { ERROR_DOCS_PAGE_URL as d } from "./index9.js";
3
3
  import { UnknownApiError as m, HttpErrorType as u, isOpenAPIError as v, APIError as i, UnknownError as y } from "./index8.js";
4
- const c = () => typeof window < "u" && typeof document < "u";
5
- let a = h.create({
4
+ const h = () => typeof window < "u" && typeof document < "u";
5
+ let a = c.create({
6
6
  baseURL: "https://api.cdp.coinbase.com/platform"
7
7
  }), o = null;
8
- const C = (r) => {
9
- a = h.create({
8
+ const $ = (r) => {
9
+ a = c.create({
10
10
  baseURL: r.basePath || "https://api.cdp.coinbase.com/platform",
11
11
  // Only enable cookies in browser environments where they're supported
12
- withCredentials: c()
12
+ withCredentials: h()
13
13
  }), a.interceptors.request.use(async (e) => {
14
- const t = g(e), s = l(e);
15
- if (!o || p(s.pathname) || w(s.pathname) && !await o.isSignedIn())
14
+ const t = b(e), s = l(e);
15
+ if (!o || p(s.pathname) || w(s.pathname) && !await o.isSignedIn() || !q(s.pathname))
16
16
  return e;
17
17
  const n = await o.getXWalletAuth({
18
18
  requestMethod: t,
@@ -27,30 +27,30 @@ const C = (r) => {
27
27
  return e;
28
28
  const s = await o.getToken();
29
29
  return s && s !== "" && (e.headers.Authorization = `Bearer ${s}`), e;
30
- }), c() || a.interceptors.request.use(async (e) => {
30
+ }), h() || a.interceptors.request.use(async (e) => {
31
31
  let t = e.headers["User-Agent"];
32
32
  return t = t ? `${t} CDP/reactnative` : "CDP/reactnative", e.headers["User-Agent"] = t, e;
33
- }), r.refreshTokenStorage && A(r.refreshTokenStorage), r.debugging && (a.interceptors.request.use((e) => (console.log("Request:", e), e)), a.interceptors.response.use((e) => (console.log("Response:", e), e)));
34
- }, $ = (r) => {
33
+ }), r.refreshTokenStorage && R(r.refreshTokenStorage), r.debugging && (a.interceptors.request.use((e) => (console.log("Request:", e), e)), a.interceptors.response.use((e) => (console.log("Response:", e), e)));
34
+ }, x = (r) => {
35
35
  o = r;
36
- }, R = (r, e) => ({
36
+ }, A = (r, e) => ({
37
37
  ...r,
38
38
  headers: {
39
39
  ...r.headers || {},
40
40
  "X-Idempotency-Key": e
41
41
  }
42
- }), x = async (r, e) => {
43
- T(r), e && e !== "" && (r = R(r, e));
42
+ }), I = async (r, e) => {
43
+ T(r), e && e !== "" && (r = A(r, e));
44
44
  try {
45
45
  return (await a(r)).data;
46
46
  } catch (t) {
47
- if (h.isAxiosError(t) && !t.response)
47
+ if (c.isAxiosError(t) && !t.response)
48
48
  throw new m(
49
49
  u.unknown,
50
50
  t.cause instanceof Error ? t.cause.message : t.message,
51
51
  t.cause
52
52
  );
53
- if (h.isAxiosError(t) && t.response) {
53
+ if (c.isAxiosError(t) && t.response) {
54
54
  if (v(t.response.data))
55
55
  throw new i(
56
56
  t.response.status,
@@ -125,11 +125,11 @@ const C = (r) => {
125
125
  t instanceof Error ? t : void 0
126
126
  );
127
127
  }
128
- }, A = (r) => {
128
+ }, R = (r) => {
129
129
  a.interceptors.response.use(
130
130
  async (e) => {
131
131
  try {
132
- if (P(e)) {
132
+ if (U(e)) {
133
133
  const t = e.data?.refreshToken;
134
134
  t && await r.setRefreshToken(t);
135
135
  }
@@ -141,20 +141,20 @@ const C = (r) => {
141
141
  (e) => Promise.reject(e)
142
142
  ), a.interceptors.request.use(async (e) => {
143
143
  try {
144
- if (U(e.url)) {
144
+ if (k(e.url)) {
145
145
  const t = await r.getRefreshToken();
146
146
  t && (e.data = {
147
147
  ...e.data,
148
148
  refreshToken: t
149
149
  });
150
150
  }
151
- k(e.url) && await r.removeRefreshToken();
151
+ P(e.url) && await r.removeRefreshToken();
152
152
  } catch (t) {
153
153
  console.warn("Failed to retrieve refresh token:", t);
154
154
  }
155
155
  return e;
156
156
  });
157
- }, k = (r) => r ? /^\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/logout$/.test(r) : !1, U = (r) => r ? /^\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/(refresh|logout)$/.test(r) : !1, P = (r) => {
157
+ }, P = (r) => r ? /^\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/logout$/.test(r) : !1, k = (r) => r ? /^\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/(refresh|logout)$/.test(r) : !1, U = (r) => {
158
158
  const e = r.config.url;
159
159
  return e ? /^\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/(verify\/(email|sms|oauth\/.*)|refresh)$/.test(
160
160
  e
@@ -166,17 +166,17 @@ const C = (r) => {
166
166
  throw new Error("AxiosRequestConfig URL is empty. This should never happen.");
167
167
  if (!r.method || r.method === "")
168
168
  throw new Error("AxiosRequestConfig method is empty. This should never happen.");
169
- }, g = (r) => r.method?.toString().toUpperCase() || "GET", l = (r) => {
169
+ }, b = (r) => r.method?.toString().toUpperCase() || "GET", l = (r) => {
170
170
  if (!r.url)
171
171
  throw new Error("URL is required for authentication");
172
172
  const e = a.getUri() + r.url;
173
173
  return new URL(e);
174
- }, p = (r) => /^\/platform\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/(refresh|logout)$/.test(r), w = (r) => {
174
+ }, p = (r) => /^\/platform\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/(refresh|logout)$/.test(r), q = (r) => !/^\/platform\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/custom\/authenticate$/.test(r), w = (r) => {
175
175
  const e = /^\/platform\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/(init)$/, t = /^\/platform\/v2\/embedded-wallet-api\/projects\/[^/]+\/auth\/verify\//;
176
176
  return e.test(r) || t.test(r);
177
177
  };
178
178
  export {
179
- x as cdpApiClient,
180
- C as configureCdpApiClient,
181
- $ as setAuthManager
179
+ I as cdpApiClient,
180
+ $ as configureCdpApiClient,
181
+ x as setAuthManager
182
182
  };
@@ -148,6 +148,16 @@ export declare const AssetType: {
148
148
  readonly crypto: "crypto";
149
149
  };
150
150
 
151
+ export declare const authenticateUserWithCustomAuth: (projectId: string, options?: SecondParameter<typeof cdpApiClient>) => Promise<AuthenticateUserWithCustomAuth200>;
152
+
153
+ export declare type AuthenticateUserWithCustomAuth200 = {
154
+ endUser: EndUser;
155
+ isNewEndUser: boolean;
156
+ message: string;
157
+ };
158
+
159
+ export declare type AuthenticateUserWithCustomAuthResult = NonNullable<Awaited<ReturnType<typeof authenticateUserWithCustomAuth>>>;
160
+
151
161
  export declare type AuthenticationMethod = EmailAuthentication | SmsAuthentication | DeveloperJWTAuthentication | OAuth2Authentication;
152
162
 
153
163
  export declare type AuthenticationMethods = AuthenticationMethod[];
@@ -273,18 +283,21 @@ export declare const CoolPaymentMethodType: {
273
283
  };
274
284
 
275
285
  export declare interface CreateAccountRequest {
276
- type: CreateAccountRequestType;
277
286
  owner: string;
278
287
  name?: string;
279
288
  projectIds?: ProjectId[];
280
289
  }
281
290
 
282
- export declare type CreateAccountRequestType = (typeof CreateAccountRequestType)[keyof typeof CreateAccountRequestType];
291
+ export declare const createCustomAuthConfig: (projectId: string, createCustomAuthConfigRequest: CreateCustomAuthConfigRequest, options?: SecondParameter<typeof cdpApiClient>) => Promise<CustomAuthConfig>;
283
292
 
284
- export declare const CreateAccountRequestType: {
285
- readonly entity: "entity";
286
- readonly customer: "customer";
287
- };
293
+ export declare interface CreateCustomAuthConfigRequest {
294
+ enabled: boolean;
295
+ jwksUrl: string;
296
+ issuer: string;
297
+ audience?: string;
298
+ }
299
+
300
+ export declare type CreateCustomAuthConfigResult = NonNullable<Awaited<ReturnType<typeof createCustomAuthConfig>>>;
288
301
 
289
302
  export declare const createEndUserEvmAccount: (projectId: string, userId: string, createEndUserEvmAccountBody: CreateEndUserEvmAccountBody, options?: SecondParameter<typeof cdpApiClient>) => Promise<EndUser>;
290
303
 
@@ -378,6 +391,15 @@ export declare type CreateSwapQuoteResponseAllOfTransaction = {
378
391
 
379
392
  export declare type CreateSwapQuoteResponseWrapper = CreateSwapQuoteResponse | SwapUnavailableResponse;
380
393
 
394
+ export declare interface CustomAuthConfig {
395
+ enabled: boolean;
396
+ jwksUrl: string;
397
+ issuer: string;
398
+ audience?: string;
399
+ createdAt?: string;
400
+ updatedAt?: string;
401
+ }
402
+
381
403
  export declare type Customer = CustomerAllOf & CustomerBase & CustomerAllOfTwo & Required<Pick<CustomerAllOf & CustomerBase & CustomerAllOfTwo, "capabilities" | "requirement" | "type">>;
382
404
 
383
405
  export declare type CustomerAllOf = {
@@ -933,7 +955,7 @@ export declare interface Individual {
933
955
  phone?: string;
934
956
  address?: PhysicalAddress;
935
957
  dateOfBirth?: DateOfBirth;
936
- taxResidency?: string;
958
+ taxNumber?: string;
937
959
  nationalities?: string[];
938
960
  verification?: IndividualVerification;
939
961
  }
@@ -1113,6 +1135,11 @@ export declare type LimitUsed = {
1113
1135
  asset: string;
1114
1136
  };
1115
1137
 
1138
+ export declare interface LinkableAccount {
1139
+ accountId: AccountId;
1140
+ type: AccountType;
1141
+ }
1142
+
1116
1143
  export declare interface LinkableEntity {
1117
1144
  entityId: EntityId;
1118
1145
  name: string;
@@ -1169,8 +1196,8 @@ export declare type ListSpendPermissionsWithEndUserAccount200AllOf = {
1169
1196
  };
1170
1197
 
1171
1198
  export declare type ListSpendPermissionsWithEndUserAccountParams = {
1172
- pageSize?: number;
1173
- pageToken?: string;
1199
+ pageSize?: PageSizeParameter;
1200
+ pageToken?: PageTokenParameter;
1174
1201
  };
1175
1202
 
1176
1203
  export declare type ListSpendPermissionsWithEndUserAccountResult = NonNullable<Awaited<ReturnType<typeof listSpendPermissionsWithEndUserAccount>>>;
@@ -1246,6 +1273,8 @@ export declare interface OAuth2Authentication {
1246
1273
  type: OAuth2ProviderType;
1247
1274
  sub: string;
1248
1275
  email?: string;
1276
+ name?: string;
1277
+ username?: string;
1249
1278
  }
1250
1279
 
1251
1280
  export declare type OAuth2ProviderType = (typeof OAuth2ProviderType)[keyof typeof OAuth2ProviderType];
@@ -1274,8 +1303,13 @@ export declare interface OnchainDataColumnSchema {
1274
1303
 
1275
1304
  export declare interface OnchainDataQuery {
1276
1305
  sql: string;
1306
+ cache?: OnchainDataQueryCache;
1277
1307
  }
1278
1308
 
1309
+ export declare type OnchainDataQueryCache = {
1310
+ maxAgeMs?: number;
1311
+ };
1312
+
1279
1313
  export declare interface OnchainDataResult {
1280
1314
  result?: OnchainDataResultResultItem[];
1281
1315
  schema?: OnchainDataResultSchema;
@@ -1284,6 +1318,7 @@ export declare interface OnchainDataResult {
1284
1318
 
1285
1319
  export declare type OnchainDataResultMetadata = {
1286
1320
  cached?: boolean;
1321
+ executionTimestamp?: string;
1287
1322
  executionTimeMs?: number;
1288
1323
  rowCount?: number;
1289
1324
  };
@@ -1336,6 +1371,11 @@ export declare interface OnchainDataTableSchema {
1336
1371
  columns?: OnchainDataColumnSchema[];
1337
1372
  }
1338
1373
 
1374
+ export declare interface OnchainTransaction {
1375
+ txHash: string;
1376
+ network: Network;
1377
+ }
1378
+
1339
1379
  export declare interface OnrampOrder {
1340
1380
  orderId: string;
1341
1381
  paymentTotal: string;
@@ -1659,7 +1699,17 @@ export declare const RequirementErrorCode: {
1659
1699
  readonly verification_document_expired: "verification_document_expired";
1660
1700
  };
1661
1701
 
1662
- export declare type RequirementField = string;
1702
+ export declare type RequirementField = (typeof RequirementField)[keyof typeof RequirementField];
1703
+
1704
+ export declare const RequirementField: {
1705
+ readonly individualfirstName: "individual.firstName";
1706
+ readonly individuallastName: "individual.lastName";
1707
+ readonly individualdateOfBirth: "individual.dateOfBirth";
1708
+ readonly individualaddress: "individual.address";
1709
+ readonly individualnationalityCode: "individual.nationalityCode";
1710
+ readonly individualtaxNumber: "individual.taxNumber";
1711
+ readonly individualverificationdocument: "individual.verification.document";
1712
+ };
1663
1713
 
1664
1714
  export declare interface RevokeSpendPermissionRequest {
1665
1715
  walletSecretId: string;
@@ -1678,11 +1728,11 @@ export declare interface Role {
1678
1728
  name: string;
1679
1729
  description?: string | null;
1680
1730
  permissions: Permission[];
1681
- createdAt: string;
1682
- updatedAt: string;
1731
+ createdAt?: string;
1732
+ updatedAt?: string;
1683
1733
  }
1684
1734
 
1685
- export declare type RoleId = string;
1735
+ export declare type RoleId = "role_entity_admin" | "role_entity_viewer" | string;
1686
1736
 
1687
1737
  export declare type Rule = SignEvmTransactionRule | SendEvmTransactionRule | SignEvmMessageRule | SignEvmTypedDataRule | SignSolTransactionRule | SendSolTransactionRule | SignSolMessageRule | SignEvmHashRule | PrepareUserOperationRule | SendUserOperationRule;
1688
1738
 
@@ -2398,8 +2448,8 @@ export declare interface Transfer {
2398
2448
  targetAsset?: string;
2399
2449
  exchangeRate?: TransferExchangeRate;
2400
2450
  fees?: TransferFees;
2451
+ onchainTransactions?: OnchainTransaction[];
2401
2452
  completedAt?: string;
2402
- sourceDepositInstructions?: TransferSourceDepositsInstructions;
2403
2453
  failureReason?: string;
2404
2454
  reversalReason?: TransferReversalReason;
2405
2455
  cancellationReason?: TransferCancellationReason;
@@ -2492,30 +2542,6 @@ export declare interface TransfersAccount {
2492
2542
 
2493
2543
  export declare type TransferSource = TransfersAccount | PaymentMethod;
2494
2544
 
2495
- export declare interface TransferSourceDepositsInstructions {
2496
- paymentMethodType: TransferSourceDepositsInstructionsPaymentMethodType;
2497
- asset: TransferSourceDepositsInstructionsAsset;
2498
- accountName: string;
2499
- accountAddress: string;
2500
- accountNumber: string;
2501
- routingNumber: string;
2502
- bankName: string;
2503
- bankAddress: string;
2504
- bankCountryName: string;
2505
- }
2506
-
2507
- export declare type TransferSourceDepositsInstructionsAsset = (typeof TransferSourceDepositsInstructionsAsset)[keyof typeof TransferSourceDepositsInstructionsAsset];
2508
-
2509
- export declare const TransferSourceDepositsInstructionsAsset: {
2510
- readonly usd: "usd";
2511
- };
2512
-
2513
- export declare type TransferSourceDepositsInstructionsPaymentMethodType = (typeof TransferSourceDepositsInstructionsPaymentMethodType)[keyof typeof TransferSourceDepositsInstructionsPaymentMethodType];
2514
-
2515
- export declare const TransferSourceDepositsInstructionsPaymentMethodType: {
2516
- readonly fedwire: "fedwire";
2517
- };
2518
-
2519
2545
  export declare type TransferStatus = (typeof TransferStatus)[keyof typeof TransferStatus];
2520
2546
 
2521
2547
  export declare const TransferStatus: {
@@ -2882,6 +2908,7 @@ export declare const X402VerifyInvalidReason: {
2882
2908
  readonly invalid_payment_requirements: "invalid_payment_requirements";
2883
2909
  readonly invalid_payload: "invalid_payload";
2884
2910
  readonly invalid_exact_evm_payload_authorization_value: "invalid_exact_evm_payload_authorization_value";
2911
+ readonly invalid_exact_evm_payload_authorization_value_too_low: "invalid_exact_evm_payload_authorization_value_too_low";
2885
2912
  readonly invalid_exact_evm_payload_authorization_valid_after: "invalid_exact_evm_payload_authorization_valid_after";
2886
2913
  readonly invalid_exact_evm_payload_authorization_valid_before: "invalid_exact_evm_payload_authorization_valid_before";
2887
2914
  readonly invalid_exact_evm_payload_authorization_typed_data_message: "invalid_exact_evm_payload_authorization_typed_data_message";
@@ -2907,6 +2934,8 @@ export declare const X402VerifyInvalidReason: {
2907
2934
  readonly invalid_exact_svm_payload_transaction_sender_ata_not_found: "invalid_exact_svm_payload_transaction_sender_ata_not_found";
2908
2935
  readonly invalid_exact_svm_payload_transaction_simulation_failed: "invalid_exact_svm_payload_transaction_simulation_failed";
2909
2936
  readonly invalid_exact_svm_payload_transaction_transfer_to_incorrect_ata: "invalid_exact_svm_payload_transaction_transfer_to_incorrect_ata";
2937
+ readonly invalid_exact_svm_payload_transaction_fee_payer_included_in_instruction_accounts: "invalid_exact_svm_payload_transaction_fee_payer_included_in_instruction_accounts";
2938
+ readonly invalid_exact_svm_payload_transaction_fee_payer_transferring_funds: "invalid_exact_svm_payload_transaction_fee_payer_transferring_funds";
2910
2939
  };
2911
2940
 
2912
2941
  export declare type X402VerifyResponseResponse = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coinbase/cdp-api-client",
3
- "version": "0.0.58",
3
+ "version": "0.0.61",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist/**",